KiCad PCB EDA Suite
sch_line.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
30 #include <fctsys.h>
31 #include <gr_basic.h>
32 #include <macros.h>
33 #include <class_drawpanel.h>
34 #include <plotter.h>
35 #include <base_units.h>
36 #include <eeschema_config.h>
37 #include <general.h>
38 #include <list_operations.h>
39 #include <sch_line.h>
40 #include <sch_edit_frame.h>
41 #include <netlist_object.h>
42 
44 
45 
46 static wxPenStyle getwxPenStyle( PlotDashType aType )
47 {
48  switch( aType )
49  {
50  case PLOTDASHTYPE_SOLID: return wxPENSTYLE_SOLID;
51  case PLOTDASHTYPE_DASH: return wxPENSTYLE_SHORT_DASH;
52  case PLOTDASHTYPE_DOT: return wxPENSTYLE_DOT;
53  case PLOTDASHTYPE_DASHDOT: return wxPENSTYLE_DOT_DASH;
54  }
55 
56  wxFAIL_MSG( "Unhandled PlotDashType" );
57  return wxPENSTYLE_SOLID;
58 }
59 
60 
61 SCH_LINE::SCH_LINE( const wxPoint& pos, int layer ) :
62  SCH_ITEM( NULL, SCH_LINE_T )
63 {
64  m_start = pos;
65  m_end = pos;
67  m_size = 0;
68  m_style = -1;
69  m_color = COLOR4D::UNSPECIFIED;
70 
71  switch( layer )
72  {
73  default:
75  break;
76 
77  case LAYER_WIRE:
79  break;
80 
81  case LAYER_BUS:
83  break;
84  }
85 }
86 
87 
88 SCH_LINE::SCH_LINE( const SCH_LINE& aLine ) :
89  SCH_ITEM( aLine )
90 {
91  m_start = aLine.m_start;
92  m_end = aLine.m_end;
93  m_size = aLine.m_size;
94  m_style = aLine.m_style;
95  m_color = aLine.m_color;
97 }
98 
99 
101 {
102  return new SCH_LINE( *this );
103 }
104 
105 static const char* style_names[] =
106 {
107  "solid", "dashed", "dotted", "dash_dot", nullptr
108 };
109 
110 const char* SCH_LINE::GetLineStyleName( int aStyle )
111 {
112  const char * styleName = style_names[1];
113 
114  switch( aStyle )
115  {
116  case PLOTDASHTYPE_SOLID:
117  styleName = style_names[0];
118  break;
119 
120  default:
121  case PLOTDASHTYPE_DASH:
122  styleName = style_names[1];
123  break;
124 
125  case PLOTDASHTYPE_DOT:
126  styleName = style_names[2];
127  break;
128 
130  styleName = style_names[3];
131  break;
132  }
133 
134  return styleName;
135 }
136 
137 
138 int SCH_LINE::GetLineStyleInternalId( const wxString& aStyleName )
139 {
140  int id = -1; // Default style id
141 
142  for( int ii = 0; style_names[ii] != nullptr; ii++ )
143  {
144  if( aStyleName == style_names[ii] )
145  {
146  id = ii;
147  break;
148  }
149  }
150 
151  return id;
152 }
153 
154 
155 void SCH_LINE::Move( const wxPoint& aOffset )
156 {
157  if( (m_Flags & STARTPOINT) == 0 && aOffset != wxPoint( 0, 0 ) )
158  {
159  m_start += aOffset;
160  SetModified();
161  }
162 
163  if( (m_Flags & ENDPOINT) == 0 && aOffset != wxPoint( 0, 0 ) )
164  {
165  m_end += aOffset;
166  SetModified();
167  }
168 }
169 
170 
171 #if defined(DEBUG)
172 
173 void SCH_LINE::Show( int nestLevel, std::ostream& os ) const
174 {
175  NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str()
176  << " layer=\"" << m_Layer << '"'
177  << " startIsDangling=\"" << m_startIsDangling
178  << '"' << " endIsDangling=\""
179  << m_endIsDangling << '"' << ">"
180  << " <start" << m_start << "/>"
181  << " <end" << m_end << "/>" << "</"
182  << GetClass().Lower().mb_str() << ">\n";
183 }
184 
185 #endif
186 
187 
189 {
190  int width = 25;
191 
192  int xmin = std::min( m_start.x, m_end.x ) - width;
193  int ymin = std::min( m_start.y, m_end.y ) - width;
194 
195  int xmax = std::max( m_start.x, m_end.x ) + width;
196  int ymax = std::max( m_start.y, m_end.y ) + width;
197 
198  // return a rectangle which is [pos,dim) in nature. therefore the +1
199  EDA_RECT ret( wxPoint( xmin, ymin ), wxSize( xmax - xmin + 1, ymax - ymin + 1 ) );
200 
201  return ret;
202 }
203 
204 
205 double SCH_LINE::GetLength() const
206 {
207  return GetLineLength( m_start, m_end );
208 }
209 
210 
212 {
213  return GetLayerColor( m_Layer );
214 }
215 
216 
217 void SCH_LINE::SetLineColor( const COLOR4D aColor )
218 {
219  if( aColor == GetDefaultColor() )
220  m_color = COLOR4D::UNSPECIFIED;
221  else
222  m_color = aColor;
223 }
224 
225 
226 void SCH_LINE::SetLineColor( const double r, const double g, const double b, const double a )
227 {
228  COLOR4D newColor(r, g, b, a);
229 
230  if( newColor == GetDefaultColor() || newColor == COLOR4D::UNSPECIFIED )
231  m_color = COLOR4D::UNSPECIFIED;
232  else
233  {
234  // Eeschema does not allow alpha channel in colors
235  newColor.a = 1.0;
236  m_color = newColor;
237  }
238 }
239 
240 
242 {
243  if( m_color == COLOR4D::UNSPECIFIED )
244  return GetLayerColor( m_Layer );
245 
246  return m_color;
247 }
248 
250 {
251  if( m_Layer == LAYER_NOTES )
252  return PLOTDASHTYPE_DASH;
253 
254  return PLOTDASHTYPE_SOLID;
255 }
256 
257 
258 void SCH_LINE::SetLineStyle( const int aStyle )
259 {
260  if( aStyle == GetDefaultStyle() )
261  m_style = -1;
262  else
263  m_style = aStyle;
264 }
265 
266 
268 {
269  if( m_style >= 0 )
270  return m_style;
271 
272  return GetDefaultStyle();
273 }
274 
275 
277 {
278  if( m_Layer == LAYER_BUS )
279  return GetDefaultBusThickness();
280 
281  return GetDefaultLineThickness();
282 }
283 
284 
285 void SCH_LINE::SetLineWidth( const int aSize )
286 {
287  if( aSize == GetDefaultWidth() )
288  m_size = 0;
289  else
290  m_size = aSize;
291 }
292 
293 
295 {
296  if( m_size > 0 )
297  return m_size;
298 
299  if( m_Layer == LAYER_BUS )
300  return GetDefaultBusThickness();
301 
302  return GetDefaultLineThickness();
303 }
304 
305 
306 void SCH_LINE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset,
307  GR_DRAWMODE DrawMode, COLOR4D Color )
308 {
309  COLOR4D color;
310  int width = GetPenSize();
311 
312  if( Color != COLOR4D::UNSPECIFIED )
313  color = Color;
314  else if( m_color != COLOR4D::UNSPECIFIED )
315  color = m_color;
316  else
318 
319  GRSetDrawMode( DC, DrawMode );
320 
321  wxPoint start = m_start;
322  wxPoint end = m_end;
323 
324  if( ( m_Flags & STARTPOINT ) == 0 )
325  start += offset;
326 
327  if( ( m_Flags & ENDPOINT ) == 0 )
328  end += offset;
329 
330  GRLine( panel->GetClipBox(), DC, start.x, start.y, end.x, end.y, width, color,
332 
333  if( m_startIsDangling )
334  DrawDanglingSymbol( panel, DC, start, color );
335 
336  if( m_endIsDangling )
337  DrawDanglingSymbol( panel, DC, end, color );
338 }
339 
340 
341 void SCH_LINE::MirrorX( int aXaxis_position )
342 {
343  MIRROR( m_start.y, aXaxis_position );
344  MIRROR( m_end.y, aXaxis_position );
345 }
346 
347 
348 void SCH_LINE::MirrorY( int aYaxis_position )
349 {
350  MIRROR( m_start.x, aYaxis_position );
351  MIRROR( m_end.x, aYaxis_position );
352 }
353 
354 
355 void SCH_LINE::Rotate( wxPoint aPosition )
356 {
357  RotatePoint( &m_start, aPosition, 900 );
358  RotatePoint( &m_end, aPosition, 900 );
359 }
360 
361 
362 bool SCH_LINE::IsSameQuadrant( SCH_LINE* aLine, const wxPoint& aPosition )
363 {
364  wxPoint first;
365  wxPoint second;
366 
367  if( m_start == aPosition )
368  first = m_end - aPosition;
369  else if( m_end == aPosition )
370  first = m_start - aPosition;
371  else
372  return false;
373 
374  if( aLine->m_start == aPosition )
375  second = aLine->m_end - aPosition;
376  else if( aLine->m_end == aPosition )
377  second = aLine->m_start - aPosition;
378  else
379  return false;
380 
381  return ( sign( first.x ) == sign( second.x ) &&
382  sign( first.y ) == sign( second.y ) );
383 }
384 
385 
387 {
388  wxCHECK_MSG( aLine != NULL && aLine->Type() == SCH_LINE_T, false,
389  wxT( "Cannot test line segment for overlap." ) );
390 
391  wxPoint firstSeg = m_end - m_start;
392  wxPoint secondSeg = aLine->m_end - aLine->m_start;
393 
394  // Use long long here to avoid overflow in calculations
395  return !( (long long) firstSeg.x * secondSeg.y - (long long) firstSeg.y * secondSeg.x );
396 }
397 
398 
400 {
401  auto less = []( const wxPoint& lhs, const wxPoint& rhs ) -> bool
402  {
403  if( lhs.x == rhs.x )
404  return lhs.y < rhs.y;
405  return lhs.x < rhs.x;
406  };
407  wxCHECK_MSG( aLine != NULL && aLine->Type() == SCH_LINE_T, NULL,
408  wxT( "Cannot test line segment for overlap." ) );
409 
410  if( this == aLine || GetLayer() != aLine->GetLayer() )
411  return NULL;
412 
413  SCH_LINE leftmost = SCH_LINE( *aLine );
414  SCH_LINE rightmost = SCH_LINE( *this );
415 
416  // We place the start to the left and below the end of both lines
417  if( leftmost.m_start != std::min( { leftmost.m_start, leftmost.m_end }, less ) )
418  std::swap( leftmost.m_start, leftmost.m_end );
419  if( rightmost.m_start != std::min( { rightmost.m_start, rightmost.m_end }, less ) )
420  std::swap( rightmost.m_start, rightmost.m_end );
421 
422  // -leftmost is the line that starts farthest to the left
423  // -other is the line that is _not_ leftmost
424  // -rightmost is the line that ends farthest to the right. This may or
425  // may not be 'other' as the second line may be completely covered by
426  // the first.
427  if( less( rightmost.m_start, leftmost.m_start ) )
428  std::swap( leftmost, rightmost );
429 
430  SCH_LINE other = SCH_LINE( rightmost );
431 
432  if( less( rightmost.m_end, leftmost.m_end ) )
433  rightmost = leftmost;
434 
435  // If we end one before the beginning of the other, no overlap is possible
436  if( less( leftmost.m_end, other.m_start ) )
437  {
438  return NULL;
439  }
440 
441  // Search for a common end:
442  if( ( leftmost.m_start == other.m_start )
443  && ( leftmost.m_end == other.m_end ) ) // Trivial case
444  {
445  return new SCH_LINE( leftmost );
446  }
447 
448  bool colinear = false;
449 
450  /* Test alignment: */
451  if( ( leftmost.m_start.y == leftmost.m_end.y )
452  && ( other.m_start.y == other.m_end.y ) ) // Horizontal segment
453  {
454  colinear = ( leftmost.m_start.y == other.m_start.y );
455  }
456  else if( ( leftmost.m_start.x == leftmost.m_end.x )
457  && ( other.m_start.x == other.m_end.x ) ) // Vertical segment
458  {
459  colinear = ( leftmost.m_start.x == other.m_start.x );
460  }
461  else
462  {
463  // We use long long here to avoid overflow -- it enforces promotion
464  // Don't use double as we need to make a direct comparison
465  // The slope of the left-most line is dy/dx. Then we check that the slope
466  // from the left most start to the right most start is the same as well as
467  // the slope from the left most start to right most end.
468  long long dx = leftmost.m_end.x - leftmost.m_start.x;
469  long long dy = leftmost.m_end.y - leftmost.m_start.y;
470  colinear = ( ( ( other.m_start.y - leftmost.m_start.y ) * dx ==
471  ( other.m_start.x - leftmost.m_start.x ) * dy ) &&
472  ( ( other.m_end.y - leftmost.m_start.y ) * dx ==
473  ( other.m_end.x - leftmost.m_start.x ) * dy ) );
474  }
475 
476  // Make a new segment that merges the 2 segments
477  if( colinear )
478  {
479  leftmost.m_end = rightmost.m_end;
480  return new SCH_LINE( leftmost );
481  }
482 
483  return NULL;
484 }
485 
486 
487 void SCH_LINE::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList )
488 {
489  if( GetLayer() == LAYER_NOTES )
490  return;
491 
492  if( ( GetLayer() == LAYER_BUS ) || ( GetLayer() == LAYER_WIRE ) )
493  {
495  m_start );
496  aItemList.push_back( item );
497 
499  m_end );
500  aItemList.push_back( item1 );
501  }
502 }
503 
504 
505 bool SCH_LINE::IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemList )
506 {
507  bool previousStartState = m_startIsDangling;
508  bool previousEndState = m_endIsDangling;
509 
511 
512  if( GetLayer() == LAYER_WIRE )
513  {
514  for( DANGLING_END_ITEM item : aItemList )
515  {
516  if( item.GetItem() == this )
517  continue;
518 
519  if( item.GetType() == NO_CONNECT_END ||
520  item.GetType() == BUS_START_END ||
521  item.GetType() == BUS_END_END ||
522  item.GetType() == BUS_ENTRY_END )
523  continue;
524 
525  if( m_start == item.GetPosition() )
526  m_startIsDangling = false;
527 
528  if( m_end == item.GetPosition() )
529  m_endIsDangling = false;
530 
531  if( (m_startIsDangling == false) && (m_endIsDangling == false) )
532  break;
533  }
534  }
535  else if( GetLayer() == LAYER_BUS || GetLayer() == LAYER_NOTES )
536  {
537  // Lines on the notes layer and the bus layer cannot be tested for dangling ends.
538  previousStartState = previousEndState = m_startIsDangling = m_endIsDangling = false;
539  }
540 
541  return ( previousStartState != m_startIsDangling ) || ( previousEndState != m_endIsDangling );
542 }
543 
544 
545 bool SCH_LINE::IsSelectStateChanged( const wxRect& aRect )
546 {
547  bool previousState = IsSelected();
548 
549  if( aRect.Contains( m_start ) && aRect.Contains( m_end ) )
550  {
551  SetFlags( SELECTED );
553  }
554  else if( aRect.Contains( m_start ) )
555  {
558  }
559  else if( aRect.Contains( m_end ) )
560  {
561  ClearFlags( ENDPOINT );
563  }
564  else
565  {
567  }
568 
569  return previousState != IsSelected();
570 }
571 
572 
574 {
575  if( m_Layer == LAYER_WIRE || m_Layer == LAYER_BUS )
576  return true;
577 
578  return false;
579 }
580 
581 
582 bool SCH_LINE::CanConnect( const SCH_ITEM* aItem ) const
583 {
584  switch( aItem->Type() )
585  {
586  case SCH_JUNCTION_T:
587  case SCH_NO_CONNECT_T:
588  case SCH_LABEL_T:
589  case SCH_GLOBAL_LABEL_T:
592  case SCH_COMPONENT_T:
593  case SCH_SHEET_T:
594  case SCH_SHEET_PIN_T:
595  return true;
596 
597  default:
598  return aItem->GetLayer() == m_Layer;
599  }
600 }
601 
602 
603 void SCH_LINE::GetConnectionPoints( std::vector< wxPoint >& aPoints ) const
604 {
605  aPoints.push_back( m_start );
606  aPoints.push_back( m_end );
607 }
608 
609 
611 {
612  wxString menuText, txtfmt, orient;
613 
614  if( m_start.x == m_end.x )
615  orient = _( "Vert." );
616  else if( m_start.y == m_end.y )
617  orient = _( "Horiz." );
618 
619  switch( m_Layer )
620  {
621  case LAYER_NOTES:
622  txtfmt = _( "%s Graphic Line from (%s,%s) to (%s,%s)" );
623  break;
624 
625  case LAYER_WIRE:
626  txtfmt = _( "%s Wire from (%s,%s) to (%s,%s)" );
627  break;
628 
629  case LAYER_BUS:
630  txtfmt = _( "%s Bus from (%s,%s) to (%s,%s)" );
631  break;
632 
633  default:
634  txtfmt += _( "%s Line on Unknown Layer from (%s,%s) to (%s,%s)" );
635  }
636 
637  menuText.Printf( txtfmt, GetChars( orient ),
642 
643  return menuText;
644 }
645 
646 
648 {
649  if( m_Layer == LAYER_NOTES )
650  return add_dashed_line_xpm;
651  else if( m_Layer == LAYER_WIRE )
652  return add_line_xpm;
653 
654  return add_bus_xpm;
655 }
656 
657 
659  SCH_SHEET_PATH* aSheetPath )
660 {
661  // Net list item not required for graphic lines.
662  if( (GetLayer() != LAYER_BUS) && (GetLayer() != LAYER_WIRE) )
663  return;
664 
665  NETLIST_OBJECT* item = new NETLIST_OBJECT();
666  item->m_SheetPath = *aSheetPath;
667  item->m_SheetPathInclude = *aSheetPath;
668  item->m_Comp = (SCH_ITEM*) this;
669  item->m_Start = m_start;
670  item->m_End = m_end;
671 
672  if( GetLayer() == LAYER_BUS )
673  {
674  item->m_Type = NET_BUS;
675  }
676  else /* WIRE */
677  {
678  item->m_Type = NET_SEGMENT;
679  }
680 
681  aNetListItems.push_back( item );
682 }
683 
684 
685 bool SCH_LINE::operator <( const SCH_ITEM& aItem ) const
686 {
687  if( Type() != aItem.Type() )
688  return Type() < aItem.Type();
689 
690  SCH_LINE* line = (SCH_LINE*) &aItem;
691 
692  if( GetLength() != line->GetLength() )
693  return GetLength() < line->GetLength();
694 
695  if( m_start.x != line->m_start.x )
696  return m_start.x < line->m_start.x;
697 
698  if( m_start.y != line->m_start.y )
699  return m_start.y < line->m_start.y;
700 
701  return false;
702 }
703 
704 
705 bool SCH_LINE::HitTest( const wxPoint& aPosition, int aAccuracy ) const
706 {
707  return TestSegmentHit( aPosition, m_start, m_end, aAccuracy );
708 }
709 
710 
711 bool SCH_LINE::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
712 {
713  if( m_Flags & ( STRUCT_DELETED | SKIP_STRUCT ) )
714  return false;
715 
716  EDA_RECT rect = aRect;
717 
718  if ( aAccuracy )
719  rect.Inflate( aAccuracy );
720 
721  if( aContained )
722  return rect.Contains( m_start ) && rect.Contains( m_end );
723 
724  return rect.Intersects( m_start, m_end );
725 }
726 
727 
729 {
730  SCH_LINE* item = (SCH_LINE*) aItem;
731 
732  std::swap( m_Layer, item->m_Layer );
733 
734  std::swap( m_start, item->m_start );
735  std::swap( m_end, item->m_end );
736  std::swap( m_startIsDangling, item->m_startIsDangling );
737  std::swap( m_endIsDangling, item->m_endIsDangling );
738  std::swap( m_style, item->m_style );
739  std::swap( m_size, item->m_size );
740  std::swap( m_color, item->m_color );
741 }
742 
743 
744 bool SCH_LINE::doIsConnected( const wxPoint& aPosition ) const
745 {
746  if( m_Layer != LAYER_WIRE && m_Layer != LAYER_BUS )
747  return false;
748 
749  return IsEndPoint( aPosition );
750 }
751 
752 
753 void SCH_LINE::Plot( PLOTTER* aPlotter )
754 {
755  if( m_color != COLOR4D::UNSPECIFIED )
756  aPlotter->SetColor( m_color );
757  else
758  aPlotter->SetColor( GetLayerColor( GetLayer() ) );
759 
760  aPlotter->SetCurrentLineWidth( GetPenSize() );
761 
762  aPlotter->SetDash( GetLineStyle() );
763 
764  aPlotter->MoveTo( m_start );
765  aPlotter->FinishTo( m_end );
766 
767  aPlotter->SetDash( 0 );
768 }
769 
770 
771 void SCH_LINE::SetPosition( const wxPoint& aPosition )
772 {
773  m_end = m_end - ( m_start - aPosition );
774  m_start = aPosition;
775 }
776 
777 
779 {
780  return wxPoint( ( m_start.x + m_end.x ) / 2, ( m_start.y + m_end.y ) / 2 );
781 }
782 
783 
784 int SCH_EDIT_FRAME::EditLine( SCH_LINE* aLine, bool aRedraw )
785 {
786  if( aLine == NULL )
787  return wxID_CANCEL;
788 
789  // We purposely disallow editing everything except graphic lines
790  if( aLine->GetLayer() != LAYER_NOTES )
791  return wxID_CANCEL;
792 
793  DIALOG_EDIT_LINE_STYLE dlg( this );
794  wxString units = GetAbbreviatedUnitsLabel( g_UserUnit );
795  int old_style = aLine->GetLineStyle();
796  int old_width = aLine->GetPenSize();
797  COLOR4D old_color = aLine->GetLineColor();
798 
799  dlg.SetDefaultStyle( aLine->GetDefaultStyle() );
800  dlg.SetDefaultWidth( StringFromValue( g_UserUnit, aLine->GetDefaultWidth(), false ) );
801  dlg.SetDefaultColor( aLine->GetDefaultColor() );
802 
803  dlg.SetWidth( StringFromValue( g_UserUnit, old_width, false ) );
804  dlg.SetStyle( old_style );
805  dlg.SetLineWidthUnits( units );
806  dlg.SetColor( old_color, true );
807 
808  dlg.Layout();
809  dlg.Fit();
810  dlg.SetMinSize( dlg.GetSize() );
811  if( dlg.ShowModal() == wxID_CANCEL )
812  return wxID_CANCEL;
813 
814  int new_width = std::max( 1, ValueFromString( dlg.GetWidth() ) );
815  int new_style = dlg.GetStyle();
816  COLOR4D new_color = dlg.GetColor();
817 
818  if( new_width != old_width || new_style != old_style || new_color != old_color )
819  {
820  SaveCopyInUndoList( (SCH_ITEM*) aLine, UR_CHANGED );
821  aLine->SetLineWidth( new_width );
822  aLine->SetLineStyle( new_style );
823  aLine->SetLineColor( new_color );
824 
825  OnModify();
826  if( aRedraw )
827  m_canvas->Refresh();
828  }
829 
830  return wxID_OK;
831 }
void Rotate(wxPoint aPosition) override
Function Rotate rotates the item around aPosition 90 degrees in the clockwise direction.
Definition: sch_line.cpp:355
void GetConnectionPoints(std::vector< wxPoint > &aPoints) const override
Function GetConnectionPoints add all the connection points for this item to aPoints.
Definition: sch_line.cpp:603
void FinishTo(const wxPoint &pos)
Definition: plotter.h:250
int m_style
Line style.
Definition: sch_line.h:48
wxString CoordinateToString(int aValue, bool aConvertToMils)
Function CoordinateToString is a helper to convert the integer coordinate aValue to a string in inche...
Definition: base_units.cpp:118
KICAD_T Type() const
Function Type()
Definition: base_struct.h:227
void GetEndPoints(std::vector< DANGLING_END_ITEM > &aItemList) override
Function GetEndPoints adds the schematic item end points to aItemList if the item has end points...
Definition: sch_line.cpp:487
static const char * style_names[]
Definition: sch_line.cpp:105
SCH_LAYER_ID m_Layer
void SetModified()
int EditLine(SCH_LINE *aLine, bool aRedraw)
Function EditLine displays the dialog for editing the parameters of aLine.
Definition: sch_line.cpp:784
wxString GetClass() const override
Function GetClass returns the class name.
Definition: sch_line.h:64
void SetStyle(const int aStyle)
double GetLineLength(const wxPoint &aPointA, const wxPoint &aPointB)
Function GetLineLength returns the length of a line segment defined by aPointA and aPointB...
Definition: trigo.h:191
bool IsSelectStateChanged(const wxRect &aRect) override
Function IsSelectStateChanged checks if the selection state of an item inside aRect has changed...
Definition: sch_line.cpp:545
PNG memory record (file in memory).
Definition: bitmap_types.h:41
void GRSetDrawMode(wxDC *DC, GR_DRAWMODE draw_mode)
Definition: gr_basic.cpp:318
static wxPenStyle getwxPenStyle(PlotDashType aType)
Definition: sch_line.cpp:46
void SetWidth(const wxString &aWidth)
Implementation of conversion functions that require both schematic and board internal units...
SCH_SHEET_PATH m_SheetPathInclude
virtual void SetColor(COLOR4D color)=0
bool Contains(const wxPoint &aPoint) const
Function Contains.
COLOR4D GetLineColor() const
Definition: sch_line.cpp:241
bool m_endIsDangling
True if end point is not connected.
Definition: sch_line.h:44
void DrawDanglingSymbol(EDA_DRAW_PANEL *panel, wxDC *DC, const wxPoint &pos, const COLOR4D &Color)
Definition: eeredraw.cpp:37
void SetLineWidth(const int aSize)
Definition: sch_line.cpp:285
#define SKIP_STRUCT
flag indicating that the structure should be ignored
Definition: base_struct.h:138
wxString StringFromValue(EDA_UNITS_T aUnit, int aValue, bool aAddUnitSymbol)
Function StringFromValue returns the string from aValue according to units (inch, mm ...
Definition: base_units.cpp:204
bool IsParallel(SCH_LINE *aLine)
Definition: sch_line.cpp:386
int color
Definition: DXF_plotter.cpp:62
int GetDefaultLineThickness()
Default line thickness used to draw/plot items having a default thickness line value (i...
Subclass of DIALOG_EDIT_LINE_STYLE_BASE, which is generated by wxFormBuilder.
void Plot(PLOTTER *aPlotter) override
Function Plot plots the schematic item to aPlotter.
Definition: sch_line.cpp:753
bool IsSelected() const
Definition: base_struct.h:250
SCH_LAYER_ID GetLayer() const
Function GetLayer returns the layer this item is on.
SCH_SHEET_PATH m_SheetPath
bool CanConnect(const SCH_ITEM *aItem) const override
Definition: sch_line.cpp:582
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:317
NETLIST_ITEM_T m_Type
int GetState(int type) const
Definition: base_struct.h:266
COLOR4D GetLayerColor(SCH_LAYER_ID aLayer)
Definition: eeschema.cpp:167
EDA_ITEM * m_Comp
void Move(const wxPoint &aMoveVector) override
Function Move moves the item by aMoveVector to a new position.
Definition: sch_line.cpp:155
This file contains miscellaneous commonly used macros and functions.
Class NETLIST_OBJECT_LIST is a container holding and owning NETLIST_OBJECTs, which are connected item...
void SetLineColor(const COLOR4D aColor)
Definition: sch_line.cpp:217
void SetColor(const COLOR4D &aColor, bool aRefresh)
void SetDefaultStyle(const int aStyle)
void MIRROR(T &aPoint, const T &aMirrorRef)
Definition: macros.h:111
#define SELECTED
Definition: base_struct.h:134
bool IsConnectable() const override
Function IsConnectable returns true if the schematic item can connect to another schematic item...
Definition: sch_line.cpp:573
void SetLineWidthUnits(const wxString &aUnits)
COLOR4D GetDefaultColor() const
Definition: sch_line.cpp:211
bool HitTest(const wxPoint &aPosition, int aAccuracy) const override
Function HitTest tests if aPosition is contained within or on the bounding box of an item...
Definition: sch_line.cpp:705
double a
Alpha component.
Definition: color4d.h:294
void SetLineStyle(const int aStyle)
Definition: sch_line.cpp:258
void MirrorX(int aXaxis_position) override
Function MirrorX mirrors item relative to the X axis about aXaxis_position.
Definition: sch_line.cpp:341
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:282
COLOR4D m_color
Line color.
Definition: sch_line.h:49
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
Definition: sch_line.cpp:647
wxPoint MidPoint()
Definition: sch_line.cpp:778
GR_DRAWMODE
Drawmode. Compositing mode plus a flag or two.
Definition: gr_basic.h:37
wxString GetAbbreviatedUnitsLabel(EDA_UNITS_T aUnit)
Definition: base_units.cpp:484
bool m_startIsDangling
True if start point is not connected.
Definition: sch_line.h:43
int ValueFromString(EDA_UNITS_T aUnits, const wxString &aTextValue)
Function ValueFromString converts aTextValue in aUnits to internal units used by the application...
Definition: base_units.cpp:369
#define BRIGHTENED
item is drawn with a bright contour
Definition: base_struct.h:151
#define STRUCT_DELETED
flag indication structures to be erased
Definition: base_struct.h:136
EDA_RECT * GetClipBox()
Class SCH_SHEET_PATH.
void GRLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color, wxPenStyle aStyle)
Definition: gr_basic.cpp:380
static int GetLineStyleInternalId(const wxString &aStyleName)
Definition: sch_line.cpp:138
bool doIsConnected(const wxPoint &aPosition) const override
Function doIsConnected provides the object specific test to see if it is connected to aPosition...
Definition: sch_line.cpp:744
int GetLineStyle() const
Definition: sch_line.cpp:267
wxPoint m_end
Line end point.
Definition: sch_line.h:46
void SwapData(SCH_ITEM *aItem) override
Function SwapData swap the internal data structures aItem with the schematic item.
Definition: sch_line.cpp:728
wxString GetSelectMenuText() const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
Definition: sch_line.cpp:610
YYCODETYPE lhs
EDA_UNITS_T g_UserUnit
Global variables definitions.
Definition: common.cpp:56
void MoveTo(const wxPoint &pos)
Definition: plotter.h:240
bool IsSameQuadrant(SCH_LINE *aLine, const wxPoint &aPosition)
Check if two lines are in the same quadrant as each other, using a reference point as the origin...
Definition: sch_line.cpp:362
int m_size
Line pensize.
Definition: sch_line.h:47
bool IsEndPoint(const wxPoint &aPoint) const
Definition: sch_line.h:69
int GetDefaultWidth() const
Definition: sch_line.cpp:276
Base plotter engine class.
Definition: plotter.h:96
bool Intersects(const EDA_RECT &aRect) const
Function Intersects tests for a common area between rectangles.
EDA_ITEM * MergeOverlap(SCH_LINE *aLine)
Check line against aLine to see if it overlaps and merge if it does.
Definition: sch_line.cpp:399
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
Segment description base class to describe items which have 2 end points (track, wire, draw line ...)
Definition: sch_line.h:41
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: sch_line.cpp:100
bool operator<(const SCH_ITEM &aItem) const override
Definition: sch_line.cpp:685
static const char * GetLineStyleName(int aStyle)
Definition: sch_line.cpp:110
#define max(a, b)
Definition: auxiliary.h:86
PlotDashType
Enum for choosing dashed line type.
Definition: plotter.h:83
STATUS_FLAGS m_Flags
Flag bits for editing and other uses.
Definition: base_struct.h:204
#define ENDPOINT
Definition: base_struct.h:133
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:180
virtual void SetDash(int dashed)=0
int GetDefaultStyle() const
Definition: sch_line.cpp:249
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:283
void MirrorY(int aYaxis_position) override
Function MirrorY mirrors item relative to the Y axis about aYaxis_position.
Definition: sch_line.cpp:348
int GetPenSize() const override
Function GetPenSize virtual pure.
Definition: sch_line.cpp:294
void SetDefaultWidth(const wxString &aWidth)
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes...
Definition: sch_line.cpp:188
Class DANGLING_END_ITEM is a helper class used to store the state of schematic items that can be conn...
void Draw(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aOffset, GR_DRAWMODE aDrawMode, COLOR4D aColor=COLOR4D::UNSPECIFIED) override
Function Draw Draw a schematic item.
Definition: sch_line.cpp:306
bool TestSegmentHit(const wxPoint &aRefPoint, wxPoint aStart, wxPoint aEnd, int aDist)
Function TestSegmentHit test for hit on line segment i.e.
Definition: trigo.cpp:142
void SetPosition(const wxPoint &aPosition) override
Function SetPosition set the schematic item position to aPosition.
Definition: sch_line.cpp:771
Definition of the NETLIST_OBJECT class.
double GetLength() const
Function GetLength.
Definition: sch_line.cpp:205
void SetDefaultColor(const COLOR4D &aColor)
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
int GetDefaultBusThickness()
Default line thickness used to draw/plot busses.
wxPoint m_start
Line start point.
Definition: sch_line.h:45
SCH_LINE(const wxPoint &pos=wxPoint(0, 0), int layer=LAYER_NOTES)
Definition: sch_line.cpp:61
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
#define min(a, b)
Definition: auxiliary.h:85
#define STARTPOINT
Definition: base_struct.h:132
int sign(T val)
Definition: math_util.h:44
virtual void SetCurrentLineWidth(int width, void *aData=NULL)=0
Set the line width for the next drawing.
void GetNetListItem(NETLIST_OBJECT_LIST &aNetListItems, SCH_SHEET_PATH *aSheetPath) override
Function GetNetListItem creates a new NETLIST_OBJECT for the schematic object and adds it to aNetList...
Definition: sch_line.cpp:658
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
bool IsDanglingStateChanged(std::vector< DANGLING_END_ITEM > &aItemList) override
Function IsDanglingStateChanged tests the schematic item to aItemList to check if it&#39;s dangling state...
Definition: sch_line.cpp:505