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-2019 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 <sch_draw_panel.h>
34 #include <plotter.h>
35 #include <base_units.h>
36 #include <eeschema_config.h>
37 #include <general.h>
38 #include <sch_line.h>
39 #include <sch_edit_frame.h>
40 #include <netlist_object.h>
41 #include <sch_view.h>
42 
43 
44 static wxPenStyle getwxPenStyle( PlotDashType aType )
45 {
46  switch( aType )
47  {
48  case PLOTDASHTYPE_SOLID: return wxPENSTYLE_SOLID;
49  case PLOTDASHTYPE_DASH: return wxPENSTYLE_SHORT_DASH;
50  case PLOTDASHTYPE_DOT: return wxPENSTYLE_DOT;
51  case PLOTDASHTYPE_DASHDOT: return wxPENSTYLE_DOT_DASH;
52  }
53 
54  wxFAIL_MSG( "Unhandled PlotDashType" );
55  return wxPENSTYLE_SOLID;
56 }
57 
58 
59 SCH_LINE::SCH_LINE( const wxPoint& pos, int layer ) :
60  SCH_ITEM( NULL, SCH_LINE_T )
61 {
62  m_start = pos;
63  m_end = pos;
65  m_size = 0;
66  m_style = -1;
67  m_color = COLOR4D::UNSPECIFIED;
68 
69  switch( layer )
70  {
71  default:
73  break;
74 
75  case LAYER_WIRE:
77  break;
78 
79  case LAYER_BUS:
81  break;
82  }
83 }
84 
85 
86 SCH_LINE::SCH_LINE( const SCH_LINE& aLine ) :
87  SCH_ITEM( aLine )
88 {
89  m_start = aLine.m_start;
90  m_end = aLine.m_end;
91  m_size = aLine.m_size;
92  m_style = aLine.m_style;
93  m_color = aLine.m_color;
96 }
97 
98 
100 {
101  return new SCH_LINE( *this );
102 }
103 
104 static const char* style_names[] =
105 {
106  "solid", "dashed", "dotted", "dash_dot", nullptr
107 };
108 
109 const char* SCH_LINE::GetLineStyleName( int aStyle )
110 {
111  const char * styleName = style_names[1];
112 
113  switch( aStyle )
114  {
115  case PLOTDASHTYPE_SOLID:
116  styleName = style_names[0];
117  break;
118 
119  default:
120  case PLOTDASHTYPE_DASH:
121  styleName = style_names[1];
122  break;
123 
124  case PLOTDASHTYPE_DOT:
125  styleName = style_names[2];
126  break;
127 
129  styleName = style_names[3];
130  break;
131  }
132 
133  return styleName;
134 }
135 
136 
137 int SCH_LINE::GetLineStyleInternalId( const wxString& aStyleName )
138 {
139  int id = -1; // Default style id
140 
141  for( int ii = 0; style_names[ii] != nullptr; ii++ )
142  {
143  if( aStyleName == style_names[ii] )
144  {
145  id = ii;
146  break;
147  }
148  }
149 
150  return id;
151 }
152 
153 
154 void SCH_LINE::Move( const wxPoint& aOffset )
155 {
156  if( aOffset != wxPoint( 0, 0 ) )
157  {
158  m_start += aOffset;
159  m_end += aOffset;
160  SetModified();
161  }
162 }
163 
164 
165 void SCH_LINE::MoveStart( const wxPoint& aOffset )
166 {
167  if( aOffset != wxPoint( 0, 0 ) )
168  {
169  m_start += aOffset;
170  SetModified();
171  }
172 }
173 
174 
175 void SCH_LINE::MoveEnd( const wxPoint& aOffset )
176 {
177  if( aOffset != wxPoint( 0, 0 ) )
178  {
179  m_end += aOffset;
180  SetModified();
181  }
182 }
183 
184 
185 #if defined(DEBUG)
186 
187 void SCH_LINE::Show( int nestLevel, std::ostream& os ) const
188 {
189  NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str()
190  << " layer=\"" << m_Layer << '"'
191  << " startIsDangling=\"" << m_startIsDangling
192  << '"' << " endIsDangling=\""
193  << m_endIsDangling << '"' << ">"
194  << " <start" << m_start << "/>"
195  << " <end" << m_end << "/>" << "</"
196  << GetClass().Lower().mb_str() << ">\n";
197 }
198 
199 #endif
200 
201 
203 {
204  int width = 25;
205 
206  int xmin = std::min( m_start.x, m_end.x ) - width;
207  int ymin = std::min( m_start.y, m_end.y ) - width;
208 
209  int xmax = std::max( m_start.x, m_end.x ) + width;
210  int ymax = std::max( m_start.y, m_end.y ) + width;
211 
212  // return a rectangle which is [pos,dim) in nature. therefore the +1
213  EDA_RECT ret( wxPoint( xmin, ymin ), wxSize( xmax - xmin + 1, ymax - ymin + 1 ) );
214 
215  return ret;
216 }
217 
218 
219 double SCH_LINE::GetLength() const
220 {
221  return GetLineLength( m_start, m_end );
222 }
223 
224 
226 {
227  return GetLayerColor( m_Layer );
228 }
229 
230 
231 void SCH_LINE::SetLineColor( const COLOR4D aColor )
232 {
233  if( aColor == GetDefaultColor() )
234  m_color = COLOR4D::UNSPECIFIED;
235  else
236  m_color = aColor;
237 }
238 
239 
240 void SCH_LINE::SetLineColor( const double r, const double g, const double b, const double a )
241 {
242  COLOR4D newColor(r, g, b, a);
243 
244  if( newColor == GetDefaultColor() || newColor == COLOR4D::UNSPECIFIED )
245  m_color = COLOR4D::UNSPECIFIED;
246  else
247  {
248  // Eeschema does not allow alpha channel in colors
249  newColor.a = 1.0;
250  m_color = newColor;
251  }
252 }
253 
254 
256 {
257  if( m_color == COLOR4D::UNSPECIFIED )
258  return GetLayerColor( m_Layer );
259 
260  return m_color;
261 }
262 
264 {
265  if( m_Layer == LAYER_NOTES )
266  return PLOTDASHTYPE_DASH;
267 
268  return PLOTDASHTYPE_SOLID;
269 }
270 
271 
272 void SCH_LINE::SetLineStyle( const int aStyle )
273 {
274  if( aStyle == GetDefaultStyle() )
275  m_style = -1;
276  else
277  m_style = aStyle;
278 }
279 
280 
282 {
283  if( m_style >= 0 )
284  return m_style;
285 
286  return GetDefaultStyle();
287 }
288 
289 
291 {
292  if( m_Layer == LAYER_BUS )
293  return GetDefaultBusThickness();
294  else if( m_Layer == LAYER_WIRE )
295  return GetDefaultWireThickness();
296 
297  return GetDefaultLineThickness();
298 }
299 
300 
301 void SCH_LINE::SetLineWidth( const int aSize )
302 {
303  if( aSize == GetDefaultWidth() )
304  m_size = 0;
305  else
306  m_size = aSize;
307 }
308 
309 
311 {
312  if( m_size > 0 )
313  return m_size;
314 
315  return GetDefaultWidth();
316 }
317 
318 
319 void SCH_LINE::Print( wxDC* DC, const wxPoint& offset )
320 {
321  COLOR4D color = ( m_color != COLOR4D::UNSPECIFIED ) ? m_color : GetLayerColor( m_Layer );
322  int width = GetPenSize();
323  wxPoint start = m_start;
324  wxPoint end = m_end;
325 
326  GRLine( nullptr, DC, start.x, start.y, end.x, end.y, width, color,
328 }
329 
330 
331 void SCH_LINE::MirrorX( int aXaxis_position )
332 {
333  MIRROR( m_start.y, aXaxis_position );
334  MIRROR( m_end.y, aXaxis_position );
335 }
336 
337 
338 void SCH_LINE::MirrorY( int aYaxis_position )
339 {
340  MIRROR( m_start.x, aYaxis_position );
341  MIRROR( m_end.x, aYaxis_position );
342 }
343 
344 
345 void SCH_LINE::Rotate( wxPoint aPosition )
346 {
347  RotatePoint( &m_start, aPosition, 900 );
348  RotatePoint( &m_end, aPosition, 900 );
349 }
350 
351 
352 void SCH_LINE::RotateStart( wxPoint aPosition )
353 {
354  RotatePoint( &m_start, aPosition, 900 );
355 }
356 
357 
358 void SCH_LINE::RotateEnd( wxPoint aPosition )
359 {
360  RotatePoint( &m_end, aPosition, 900 );
361 }
362 
363 
364 bool SCH_LINE::IsSameQuadrant( SCH_LINE* aLine, const wxPoint& aPosition )
365 {
366  wxPoint first;
367  wxPoint second;
368 
369  if( m_start == aPosition )
370  first = m_end - aPosition;
371  else if( m_end == aPosition )
372  first = m_start - aPosition;
373  else
374  return false;
375 
376  if( aLine->m_start == aPosition )
377  second = aLine->m_end - aPosition;
378  else if( aLine->m_end == aPosition )
379  second = aLine->m_start - aPosition;
380  else
381  return false;
382 
383  return ( sign( first.x ) == sign( second.x ) && sign( first.y ) == sign( second.y ) );
384 }
385 
386 
388 {
389  wxCHECK_MSG( aLine != NULL && aLine->Type() == SCH_LINE_T, false,
390  wxT( "Cannot test line segment for overlap." ) );
391 
392  wxPoint firstSeg = m_end - m_start;
393  wxPoint secondSeg = aLine->m_end - aLine->m_start;
394 
395  // Use long long here to avoid overflow in calculations
396  return !( (long long) firstSeg.x * secondSeg.y - (long long) firstSeg.y * secondSeg.x );
397 }
398 
399 
401 {
402  auto less = []( const wxPoint& lhs, const wxPoint& rhs ) -> bool
403  {
404  if( lhs.x == rhs.x )
405  return lhs.y < rhs.y;
406  return lhs.x < rhs.x;
407  };
408 
409  wxCHECK_MSG( aLine != NULL && aLine->Type() == SCH_LINE_T, NULL,
410  wxT( "Cannot test line segment for overlap." ) );
411 
412  if( this == aLine || GetLayer() != aLine->GetLayer() )
413  return NULL;
414 
415  auto leftmost_start = aLine->m_start;
416  auto leftmost_end = aLine->m_end;
417 
418  auto rightmost_start = m_start;
419  auto rightmost_end = m_end;
420 
421  // We place the start to the left and below the end of both lines
422  if( leftmost_start != std::min( { leftmost_start, leftmost_end }, less ) )
423  std::swap( leftmost_start, leftmost_end );
424  if( rightmost_start != std::min( { rightmost_start, rightmost_end }, less ) )
425  std::swap( rightmost_start, rightmost_end );
426 
427  // -leftmost is the line that starts farthest to the left
428  // -other is the line that is _not_ leftmost
429  // -rightmost is the line that ends farthest to the right. This may or
430  // may not be 'other' as the second line may be completely covered by
431  // the first.
432  if( less( rightmost_start, leftmost_start ) )
433  {
434  std::swap( leftmost_start, rightmost_start );
435  std::swap( leftmost_end, rightmost_end );
436  }
437 
438  auto other_start = rightmost_start;
439  auto other_end = rightmost_end;
440 
441  if( less( rightmost_end, leftmost_end ) )
442  {
443  rightmost_start = leftmost_start;
444  rightmost_end = leftmost_end;
445  }
446 
447  // If we end one before the beginning of the other, no overlap is possible
448  if( less( leftmost_end, other_start ) )
449  {
450  return NULL;
451  }
452 
453  // Search for a common end:
454  if( ( leftmost_start == other_start ) &&
455  ( leftmost_end == other_end ) ) // Trivial case
456  {
457  auto ret = new SCH_LINE( *aLine );
458  ret->SetStartPoint( leftmost_start );
459  ret->SetEndPoint( leftmost_end );
460  return ret;
461  }
462 
463  bool colinear = false;
464 
465  /* Test alignment: */
466  if( ( leftmost_start.y == leftmost_end.y ) &&
467  ( other_start.y == other_end.y ) ) // Horizontal segment
468  {
469  colinear = ( leftmost_start.y == other_start.y );
470  }
471  else if( ( leftmost_start.x == leftmost_end.x ) &&
472  ( other_start.x == other_end.x ) ) // Vertical segment
473  {
474  colinear = ( leftmost_start.x == other_start.x );
475  }
476  else
477  {
478  // We use long long here to avoid overflow -- it enforces promotion
479  // Don't use double as we need to make a direct comparison
480  // The slope of the left-most line is dy/dx. Then we check that the slope
481  // from the left most start to the right most start is the same as well as
482  // the slope from the left most start to right most end.
483  long long dx = leftmost_end.x - leftmost_start.x;
484  long long dy = leftmost_end.y - leftmost_start.y;
485  colinear = ( ( ( other_start.y - leftmost_start.y ) * dx ==
486  ( other_start.x - leftmost_start.x ) * dy ) &&
487  ( ( other_end.y - leftmost_start.y ) * dx ==
488  ( other_end.x - leftmost_start.x ) * dy ) );
489  }
490 
491  // Make a new segment that merges the 2 segments
492  if( colinear )
493  {
494  leftmost_end = rightmost_end;
495 
496  auto ret = new SCH_LINE( *aLine );
497  ret->SetStartPoint( leftmost_start );
498  ret->SetEndPoint( leftmost_end );
499  return ret;
500  }
501 
502  return NULL;
503 }
504 
505 
506 void SCH_LINE::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList )
507 {
508  if( GetLayer() == LAYER_NOTES )
509  return;
510 
511  if( ( GetLayer() == LAYER_BUS ) || ( GetLayer() == LAYER_WIRE ) )
512  {
514  m_start );
515  aItemList.push_back( item );
516 
518  m_end );
519  aItemList.push_back( item1 );
520  }
521 }
522 
523 
524 bool SCH_LINE::UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemList )
525 {
526  bool previousStartState = m_startIsDangling;
527  bool previousEndState = m_endIsDangling;
528 
530 
531  if( GetLayer() == LAYER_WIRE )
532  {
533  for( DANGLING_END_ITEM item : aItemList )
534  {
535  if( item.GetItem() == this )
536  continue;
537 
538  if( item.GetType() == BUS_START_END ||
539  item.GetType() == BUS_END_END ||
540  item.GetType() == BUS_ENTRY_END )
541  continue;
542 
543  if( m_start == item.GetPosition() )
544  m_startIsDangling = false;
545 
546  if( m_end == item.GetPosition() )
547  m_endIsDangling = false;
548 
549  if( (m_startIsDangling == false) && (m_endIsDangling == false) )
550  break;
551  }
552  }
553  else if( GetLayer() == LAYER_BUS || GetLayer() == LAYER_NOTES )
554  {
555  // Lines on the notes layer and the bus layer cannot be tested for dangling ends.
556  previousStartState = previousEndState = m_startIsDangling = m_endIsDangling = false;
557  }
558 
559  return ( previousStartState != m_startIsDangling ) || ( previousEndState != m_endIsDangling );
560 }
561 
562 
564 {
565  if( m_Layer == LAYER_WIRE || m_Layer == LAYER_BUS )
566  return true;
567 
568  return false;
569 }
570 
571 
572 bool SCH_LINE::CanConnect( const SCH_ITEM* aItem ) const
573 {
574  switch( aItem->Type() )
575  {
576  case SCH_JUNCTION_T:
577  case SCH_NO_CONNECT_T:
578  case SCH_LABEL_T:
579  case SCH_GLOBAL_LABEL_T:
580  case SCH_HIER_LABEL_T:
582  case SCH_COMPONENT_T:
583  case SCH_SHEET_T:
584  case SCH_SHEET_PIN_T:
585  return true;
586 
587  default:
588  return aItem->GetLayer() == m_Layer;
589  }
590 }
591 
592 
593 void SCH_LINE::GetConnectionPoints( std::vector< wxPoint >& aPoints ) const
594 {
595  aPoints.push_back( m_start );
596  aPoints.push_back( m_end );
597 }
598 
599 
600 void SCH_LINE::GetSelectedPoints( std::vector< wxPoint >& aPoints ) const
601 {
602  if( m_Flags & STARTPOINT )
603  aPoints.push_back( m_start );
604 
605  if( m_Flags & ENDPOINT )
606  aPoints.push_back( m_end );
607 }
608 
609 
610 wxString SCH_LINE::GetSelectMenuText( EDA_UNITS_T aUnits ) const
611 {
612  wxString txtfmt, orient;
613 
614  if( m_start.x == m_end.x )
615  orient = _( "Vertical" );
616  else if( m_start.y == m_end.y )
617  orient = _( "Horizontal" );
618 
619  switch( m_Layer )
620  {
621  case LAYER_NOTES: txtfmt = _( "%s Graphic Line from (%s, %s) to (%s, %s)" ); break;
622  case LAYER_WIRE: txtfmt = _( "%s Wire from (%s, %s) to (%s, %s)" ); break;
623  case LAYER_BUS: txtfmt = _( "%s Bus from (%s, %s) to (%s, %s)" ); break;
624  default: txtfmt = _( "%s Line on Unknown Layer from (%s, %s) to (%s, %s)" ); break;
625  }
626 
627  return wxString::Format( txtfmt,
628  orient,
629  MessageTextFromValue( aUnits, m_start.x ),
630  MessageTextFromValue( aUnits, m_start.y ),
631  MessageTextFromValue( aUnits, m_end.x ),
632  MessageTextFromValue( aUnits, m_end.y ) );
633 }
634 
635 
636 BITMAP_DEF SCH_LINE::GetMenuImage() const
637 {
638  if( m_Layer == LAYER_NOTES )
639  return add_dashed_line_xpm;
640  else if( m_Layer == LAYER_WIRE )
641  return add_line_xpm;
642 
643  return add_bus_xpm;
644 }
645 
646 
648  SCH_SHEET_PATH* aSheetPath )
649 {
650  // Net list item not required for graphic lines.
651  if( (GetLayer() != LAYER_BUS) && (GetLayer() != LAYER_WIRE) )
652  return;
653 
654  NETLIST_OBJECT* item = new NETLIST_OBJECT();
655  item->m_SheetPath = *aSheetPath;
656  item->m_SheetPathInclude = *aSheetPath;
657  item->m_Comp = (SCH_ITEM*) this;
658  item->m_Start = m_start;
659  item->m_End = m_end;
660 
661  if( GetLayer() == LAYER_BUS )
662  {
663  item->m_Type = NET_BUS;
664  }
665  else /* WIRE */
666  {
667  item->m_Type = NET_SEGMENT;
668  }
669 
670  aNetListItems.push_back( item );
671 }
672 
673 
674 bool SCH_LINE::operator <( const SCH_ITEM& aItem ) const
675 {
676  if( Type() != aItem.Type() )
677  return Type() < aItem.Type();
678 
679  SCH_LINE* line = (SCH_LINE*) &aItem;
680 
681  if( GetLength() != line->GetLength() )
682  return GetLength() < line->GetLength();
683 
684  if( m_start.x != line->m_start.x )
685  return m_start.x < line->m_start.x;
686 
687  if( m_start.y != line->m_start.y )
688  return m_start.y < line->m_start.y;
689 
690  return false;
691 }
692 
693 
694 bool SCH_LINE::HitTest( const wxPoint& aPosition, int aAccuracy ) const
695 {
696  // Insure minimum accuracy
697  if( aAccuracy == 0 )
698  aAccuracy = ( GetPenSize() / 2 ) + 4;
699 
700  return TestSegmentHit( aPosition, m_start, m_end, aAccuracy );
701 }
702 
703 
704 bool SCH_LINE::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
705 {
706  if( m_Flags & ( STRUCT_DELETED | SKIP_STRUCT ) )
707  return false;
708 
709  EDA_RECT rect = aRect;
710 
711  if ( aAccuracy )
712  rect.Inflate( aAccuracy );
713 
714  if( aContained )
715  return rect.Contains( m_start ) && rect.Contains( m_end );
716 
717  return rect.Intersects( m_start, m_end );
718 }
719 
720 
722 {
723  SCH_LINE* item = (SCH_LINE*) aItem;
724 
725  std::swap( m_Layer, item->m_Layer );
726 
727  std::swap( m_start, item->m_start );
728  std::swap( m_end, item->m_end );
729  std::swap( m_startIsDangling, item->m_startIsDangling );
730  std::swap( m_endIsDangling, item->m_endIsDangling );
731  std::swap( m_style, item->m_style );
732  std::swap( m_size, item->m_size );
733  std::swap( m_color, item->m_color );
734 }
735 
736 
737 bool SCH_LINE::doIsConnected( const wxPoint& aPosition ) const
738 {
739  if( m_Layer != LAYER_WIRE && m_Layer != LAYER_BUS )
740  return false;
741 
742  return IsEndPoint( aPosition );
743 }
744 
745 
746 void SCH_LINE::Plot( PLOTTER* aPlotter )
747 {
748  if( m_color != COLOR4D::UNSPECIFIED )
749  aPlotter->SetColor( m_color );
750  else
751  aPlotter->SetColor( GetLayerColor( GetLayer() ) );
752 
753  aPlotter->SetCurrentLineWidth( GetPenSize() );
754 
755  aPlotter->SetDash( GetLineStyle() );
756 
757  aPlotter->MoveTo( m_start );
758  aPlotter->FinishTo( m_end );
759 
760  aPlotter->SetDash( 0 );
761 }
762 
763 
764 void SCH_LINE::SetPosition( const wxPoint& aPosition )
765 {
766  m_end = m_end - ( m_start - aPosition );
767  m_start = aPosition;
768 }
769 
770 
772 {
773  wxString msg;
774 
775  switch( GetLayer() )
776  {
777  case LAYER_WIRE: msg = _( "Net Wire" ); break;
778  case LAYER_BUS: msg = _( "Bus Wire" ); break;
779  default: msg = _( "Graphical" ); return;
780  }
781 
782  aList.push_back( MSG_PANEL_ITEM( _( "Line Type" ), msg, DARKCYAN ) );
783 
784  if( auto conn = Connection( *g_CurrentSheet ) )
785  {
786 #if defined(DEBUG)
787  conn->AppendDebugInfoToMsgPanel( aList );
788 
789  msg.Printf( "%zu", m_connected_items.size() );
790  aList.push_back( MSG_PANEL_ITEM( _( "Connections" ), msg, BROWN ) );
791 #else
792  conn->AppendInfoToMsgPanel( aList );
793 #endif
794  }
795 }
796 
void Rotate(wxPoint aPosition) override
Function Rotate rotates the item around aPosition 90 degrees in the clockwise direction.
Definition: sch_line.cpp:345
bool UpdateDanglingState(std::vector< DANGLING_END_ITEM > &aItemList) override
Function IsDanglingStateChanged tests the schematic item to aItemList to check if it's dangling state...
Definition: sch_line.cpp:524
void GetConnectionPoints(std::vector< wxPoint > &aPoints) const override
Function GetConnectionPoints add all the connection points for this item to aPoints.
Definition: sch_line.cpp:593
void FinishTo(const wxPoint &pos)
Definition: plotter.h:254
int m_style
Line style.
Definition: sch_line.h:44
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:506
static const char * style_names[]
Definition: sch_line.cpp:104
SCH_LAYER_ID m_Layer
Definition: sch_item.h:119
void SetModified()
COLOR4D GetLineColor() const
Definition: sch_line.cpp:255
wxString GetClass() const override
Function GetClass returns the class name.
Definition: sch_line.h:60
int GetDefaultWireThickness()
Default line thickness used to draw/plot wires.
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:202
void Print(wxDC *aDC, const wxPoint &aOffset) override
Function Print Print a schematic item.
Definition: sch_line.cpp:319
static wxPenStyle getwxPenStyle(PlotDashType aType)
Definition: sch_line.cpp:44
Implementation of conversion functions that require both schematic and board internal units.
SCH_SHEET_PATH m_SheetPathInclude
virtual void SetColor(COLOR4D color)=0
bool m_endIsDangling
True if end point is not connected.
Definition: sch_line.h:40
void SetLineWidth(const int aSize)
Definition: sch_line.cpp:301
#define SKIP_STRUCT
flag indicating that the structure should be ignored
Definition: base_struct.h:118
void RotateEnd(wxPoint aPosition)
Definition: sch_line.cpp:358
void MoveStart(const wxPoint &aMoveVector)
Definition: sch_line.cpp:165
bool IsParallel(SCH_LINE *aLine)
Definition: sch_line.cpp:387
int color
Definition: DXF_plotter.cpp:62
int GetDefaultLineThickness()
Default line thickness used to draw/plot items having a default thickness line value (i....
void Plot(PLOTTER *aPlotter) override
Function Plot plots the schematic item to aPlotter.
Definition: sch_line.cpp:746
SCH_SHEET_PATH m_SheetPath
bool CanConnect(const SCH_ITEM *aItem) const override
Definition: sch_line.cpp:572
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:229
NETLIST_ITEM_T m_Type
COLOR4D GetLayerColor(SCH_LAYER_ID aLayer)
Definition: eeschema.cpp:160
EDA_ITEM * m_Comp
int GetDefaultWidth() const
Definition: sch_line.cpp:290
std::unordered_set< SCH_ITEM * > m_connected_items
Stores pointers to other items that are connected to this one (schematic only)
Definition: sch_item.h:125
bool Contains(const wxPoint &aPoint) const
Function Contains.
bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const override
Function HitTest tests if aPosition is contained within or on the bounding box of an item.
Definition: sch_line.cpp:694
void RotateStart(wxPoint aPosition)
Definition: sch_line.cpp:352
void Move(const wxPoint &aMoveVector) override
Function Move moves the item by aMoveVector to a new position.
Definition: sch_line.cpp:154
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 GetMsgPanelInfo(EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM > &aList) override
Function GetMsgPanelInfo populates aList of MSG_PANEL_ITEM objects with it's internal state for displ...
Definition: sch_line.cpp:771
wxString MessageTextFromValue(EDA_UNITS_T aUnits, int aValue, bool aUseMils)
Definition: base_units.cpp:125
void SetLineColor(const COLOR4D aColor)
Definition: sch_line.cpp:231
void MIRROR(T &aPoint, const T &aMirrorRef)
Definition: macros.h:123
bool IsConnectable() const override
Function IsConnectable returns true if the schematic item can connect to another schematic item.
Definition: sch_line.cpp:563
double a
Alpha component.
Definition: color4d.h:304
void SetLineStyle(const int aStyle)
Definition: sch_line.cpp:272
void MirrorX(int aXaxis_position) override
Function MirrorX mirrors item relative to the X axis about aXaxis_position.
Definition: sch_line.cpp:331
COLOR4D m_color
Line color.
Definition: sch_line.h:45
SCH_SHEET_PATH * g_CurrentSheet
With the new connectivity algorithm, many more places than before want to know what the current sheet...
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
Definition: sch_line.cpp:636
double GetLength() const
Function GetLength.
Definition: sch_line.cpp:219
bool m_startIsDangling
True if start point is not connected.
Definition: sch_line.h:39
#define STRUCT_DELETED
flag indication structures to be erased
Definition: base_struct.h:116
bool IsEndPoint(const wxPoint &aPoint) const
Definition: sch_line.h:83
Class SCH_SHEET_PATH.
int GetDefaultStyle() const
Definition: sch_line.cpp:263
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:230
static int GetLineStyleInternalId(const wxString &aStyleName)
Definition: sch_line.cpp:137
#define _(s)
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:737
void GetSelectedPoints(std::vector< wxPoint > &aPoints) const
Definition: sch_line.cpp:600
wxPoint m_end
Line end point.
Definition: sch_line.h:42
void SwapData(SCH_ITEM *aItem) override
Function SwapData swap the internal data structures aItem with the schematic item.
Definition: sch_line.cpp:721
SCH_CONNECTION * Connection(const SCH_SHEET_PATH &aPath) const
Retrieves the connection associated with this object in the given sheet.
Definition: sch_item.cpp:127
YYCODETYPE lhs
SCH_LAYER_ID GetLayer() const
Function GetLayer returns the layer this item is on.
Definition: sch_item.h:193
void MoveTo(const wxPoint &pos)
Definition: plotter.h:244
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:364
int m_size
Line pensize.
Definition: sch_line.h:43
Base plotter engine class.
Definition: plotter.h:97
EDA_ITEM * MergeOverlap(SCH_LINE *aLine)
Check line against aLine to see if it overlaps and merge if it does.
Definition: sch_line.cpp:400
COLOR4D GetDefaultColor() const
Definition: sch_line.cpp:225
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:37
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: sch_line.cpp:99
void MoveEnd(const wxPoint &aMoveVector)
Definition: sch_line.cpp:175
bool operator<(const SCH_ITEM &aItem) const override
Definition: sch_line.cpp:674
static const char * GetLineStyleName(int aStyle)
Definition: sch_line.cpp:109
#define max(a, b)
Definition: auxiliary.h:86
PlotDashType
Enum for choosing dashed line type.
Definition: plotter.h:84
STATUS_FLAGS m_Flags
Flag bits for editing and other uses.
Definition: base_struct.h:174
#define ENDPOINT
ends. (Used to support dragging.)
Definition: base_struct.h:113
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:150
std::vector< MSG_PANEL_ITEM > MSG_PANEL_ITEMS
Definition: msgpanel.h:102
virtual void SetDash(int dashed)=0
bool Intersects(const EDA_RECT &aRect) const
Function Intersects tests for a common area between rectangles.
void MirrorY(int aYaxis_position) override
Function MirrorY mirrors item relative to the Y axis about aYaxis_position.
Definition: sch_line.cpp:338
int GetPenSize() const override
Function GetPenSize virtual pure.
Definition: sch_line.cpp:310
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
Definition: sch_line.cpp:202
Class DANGLING_END_ITEM is a helper class used to store the state of schematic items that can be conn...
Definition: sch_item.h:67
wxString GetSelectMenuText(EDA_UNITS_T aUnits) const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
Definition: sch_line.cpp:610
Class EDA_MSG_ITEM is used EDA_MSG_PANEL as the item type for displaying messages.
Definition: msgpanel.h:53
bool TestSegmentHit(const wxPoint &aRefPoint, wxPoint aStart, wxPoint aEnd, int aDist)
Function TestSegmentHit test for hit on line segment i.e.
Definition: trigo.cpp:126
void SetPosition(const wxPoint &aPosition) override
Function SetPosition set the schematic item position to aPosition.
Definition: sch_line.cpp:764
Definition of the NETLIST_OBJECT class.
int GetLineStyle() const
Definition: sch_line.cpp:281
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
Definition: sch_item.h:114
int GetDefaultBusThickness()
Default line thickness used to draw/plot busses.
wxPoint m_start
Line start point.
Definition: sch_line.h:41
EDA_UNITS_T
Definition: common.h:157
SCH_LINE(const wxPoint &pos=wxPoint(0, 0), int layer=LAYER_NOTES)
Definition: sch_line.cpp:59
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:197
#define min(a, b)
Definition: auxiliary.h:85
#define STARTPOINT
When a line is selected, these flags indicate which.
Definition: base_struct.h:112
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:647
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
Definition: colors.h:62