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 
202 void SCH_LINE::ViewGetLayers( int aLayers[], int& aCount ) const
203 {
204  aCount = 2;
205  aLayers[0] = m_Layer;
206  aLayers[1] = LAYER_SELECTION_SHADOWS;
207 }
208 
209 
211 {
212  int width = 25;
213 
214  int xmin = std::min( m_start.x, m_end.x ) - width;
215  int ymin = std::min( m_start.y, m_end.y ) - width;
216 
217  int xmax = std::max( m_start.x, m_end.x ) + width;
218  int ymax = std::max( m_start.y, m_end.y ) + width;
219 
220  // return a rectangle which is [pos,dim) in nature. therefore the +1
221  EDA_RECT ret( wxPoint( xmin, ymin ), wxSize( xmax - xmin + 1, ymax - ymin + 1 ) );
222 
223  return ret;
224 }
225 
226 
227 double SCH_LINE::GetLength() const
228 {
229  return GetLineLength( m_start, m_end );
230 }
231 
232 
234 {
235  return GetLayerColor( m_Layer );
236 }
237 
238 
239 void SCH_LINE::SetLineColor( const COLOR4D aColor )
240 {
241  if( aColor == GetDefaultColor() )
242  m_color = COLOR4D::UNSPECIFIED;
243  else
244  m_color = aColor;
245 }
246 
247 
248 void SCH_LINE::SetLineColor( const double r, const double g, const double b, const double a )
249 {
250  COLOR4D newColor(r, g, b, a);
251 
252  if( newColor == GetDefaultColor() || newColor == COLOR4D::UNSPECIFIED )
253  m_color = COLOR4D::UNSPECIFIED;
254  else
255  {
256  // Eeschema does not allow alpha channel in colors
257  newColor.a = 1.0;
258  m_color = newColor;
259  }
260 }
261 
262 
264 {
265  if( m_color == COLOR4D::UNSPECIFIED )
266  return GetLayerColor( m_Layer );
267 
268  return m_color;
269 }
270 
272 {
273  if( m_Layer == LAYER_NOTES )
274  return PLOTDASHTYPE_DASH;
275 
276  return PLOTDASHTYPE_SOLID;
277 }
278 
279 
280 void SCH_LINE::SetLineStyle( const int aStyle )
281 {
282  if( aStyle == GetDefaultStyle() )
283  m_style = -1;
284  else
285  m_style = aStyle;
286 }
287 
288 
290 {
291  if( m_style >= 0 )
292  return m_style;
293 
294  return GetDefaultStyle();
295 }
296 
297 
299 {
300  if( m_Layer == LAYER_BUS )
301  return GetDefaultBusThickness();
302  else if( m_Layer == LAYER_WIRE )
303  return GetDefaultWireThickness();
304 
305  return GetDefaultLineThickness();
306 }
307 
308 
309 void SCH_LINE::SetLineWidth( const int aSize )
310 {
311  if( aSize == GetDefaultWidth() )
312  m_size = 0;
313  else
314  m_size = aSize;
315 }
316 
317 
319 {
320  if( m_size > 0 )
321  return m_size;
322 
323  return GetDefaultWidth();
324 }
325 
326 
327 void SCH_LINE::Print( wxDC* DC, const wxPoint& offset )
328 {
329  COLOR4D color = ( m_color != COLOR4D::UNSPECIFIED ) ? m_color : GetLayerColor( m_Layer );
330  int width = GetPenSize();
331  wxPoint start = m_start;
332  wxPoint end = m_end;
333 
334  GRLine( nullptr, DC, start.x, start.y, end.x, end.y, width, color,
336 }
337 
338 
339 void SCH_LINE::MirrorX( int aXaxis_position )
340 {
341  MIRROR( m_start.y, aXaxis_position );
342  MIRROR( m_end.y, aXaxis_position );
343 }
344 
345 
346 void SCH_LINE::MirrorY( int aYaxis_position )
347 {
348  MIRROR( m_start.x, aYaxis_position );
349  MIRROR( m_end.x, aYaxis_position );
350 }
351 
352 
353 void SCH_LINE::Rotate( wxPoint aPosition )
354 {
355  RotatePoint( &m_start, aPosition, 900 );
356  RotatePoint( &m_end, aPosition, 900 );
357 }
358 
359 
360 void SCH_LINE::RotateStart( wxPoint aPosition )
361 {
362  RotatePoint( &m_start, aPosition, 900 );
363 }
364 
365 
366 void SCH_LINE::RotateEnd( wxPoint aPosition )
367 {
368  RotatePoint( &m_end, aPosition, 900 );
369 }
370 
371 
372 bool SCH_LINE::IsSameQuadrant( SCH_LINE* aLine, const wxPoint& aPosition )
373 {
374  wxPoint first;
375  wxPoint second;
376 
377  if( m_start == aPosition )
378  first = m_end - aPosition;
379  else if( m_end == aPosition )
380  first = m_start - aPosition;
381  else
382  return false;
383 
384  if( aLine->m_start == aPosition )
385  second = aLine->m_end - aPosition;
386  else if( aLine->m_end == aPosition )
387  second = aLine->m_start - aPosition;
388  else
389  return false;
390 
391  return ( sign( first.x ) == sign( second.x ) && sign( first.y ) == sign( second.y ) );
392 }
393 
394 
396 {
397  wxCHECK_MSG( aLine != NULL && aLine->Type() == SCH_LINE_T, false,
398  wxT( "Cannot test line segment for overlap." ) );
399 
400  wxPoint firstSeg = m_end - m_start;
401  wxPoint secondSeg = aLine->m_end - aLine->m_start;
402 
403  // Use long long here to avoid overflow in calculations
404  return !( (long long) firstSeg.x * secondSeg.y - (long long) firstSeg.y * secondSeg.x );
405 }
406 
407 
409 {
410  auto less = []( const wxPoint& lhs, const wxPoint& rhs ) -> bool
411  {
412  if( lhs.x == rhs.x )
413  return lhs.y < rhs.y;
414  return lhs.x < rhs.x;
415  };
416 
417  wxCHECK_MSG( aLine != NULL && aLine->Type() == SCH_LINE_T, NULL,
418  wxT( "Cannot test line segment for overlap." ) );
419 
420  if( this == aLine || GetLayer() != aLine->GetLayer() )
421  return NULL;
422 
423  auto leftmost_start = aLine->m_start;
424  auto leftmost_end = aLine->m_end;
425 
426  auto rightmost_start = m_start;
427  auto rightmost_end = m_end;
428 
429  // We place the start to the left and below the end of both lines
430  if( leftmost_start != std::min( { leftmost_start, leftmost_end }, less ) )
431  std::swap( leftmost_start, leftmost_end );
432  if( rightmost_start != std::min( { rightmost_start, rightmost_end }, less ) )
433  std::swap( rightmost_start, rightmost_end );
434 
435  // -leftmost is the line that starts farthest to the left
436  // -other is the line that is _not_ leftmost
437  // -rightmost is the line that ends farthest to the right. This may or
438  // may not be 'other' as the second line may be completely covered by
439  // the first.
440  if( less( rightmost_start, leftmost_start ) )
441  {
442  std::swap( leftmost_start, rightmost_start );
443  std::swap( leftmost_end, rightmost_end );
444  }
445 
446  auto other_start = rightmost_start;
447  auto other_end = rightmost_end;
448 
449  if( less( rightmost_end, leftmost_end ) )
450  {
451  rightmost_start = leftmost_start;
452  rightmost_end = leftmost_end;
453  }
454 
455  // If we end one before the beginning of the other, no overlap is possible
456  if( less( leftmost_end, other_start ) )
457  {
458  return NULL;
459  }
460 
461  // Search for a common end:
462  if( ( leftmost_start == other_start ) &&
463  ( leftmost_end == other_end ) ) // Trivial case
464  {
465  auto ret = new SCH_LINE( *aLine );
466  ret->SetStartPoint( leftmost_start );
467  ret->SetEndPoint( leftmost_end );
468  return ret;
469  }
470 
471  bool colinear = false;
472 
473  /* Test alignment: */
474  if( ( leftmost_start.y == leftmost_end.y ) &&
475  ( other_start.y == other_end.y ) ) // Horizontal segment
476  {
477  colinear = ( leftmost_start.y == other_start.y );
478  }
479  else if( ( leftmost_start.x == leftmost_end.x ) &&
480  ( other_start.x == other_end.x ) ) // Vertical segment
481  {
482  colinear = ( leftmost_start.x == other_start.x );
483  }
484  else
485  {
486  // We use long long here to avoid overflow -- it enforces promotion
487  // Don't use double as we need to make a direct comparison
488  // The slope of the left-most line is dy/dx. Then we check that the slope
489  // from the left most start to the right most start is the same as well as
490  // the slope from the left most start to right most end.
491  long long dx = leftmost_end.x - leftmost_start.x;
492  long long dy = leftmost_end.y - leftmost_start.y;
493  colinear = ( ( ( other_start.y - leftmost_start.y ) * dx ==
494  ( other_start.x - leftmost_start.x ) * dy ) &&
495  ( ( other_end.y - leftmost_start.y ) * dx ==
496  ( other_end.x - leftmost_start.x ) * dy ) );
497  }
498 
499  // Make a new segment that merges the 2 segments
500  if( colinear )
501  {
502  leftmost_end = rightmost_end;
503 
504  auto ret = new SCH_LINE( *aLine );
505  ret->SetStartPoint( leftmost_start );
506  ret->SetEndPoint( leftmost_end );
507  return ret;
508  }
509 
510  return NULL;
511 }
512 
513 
514 void SCH_LINE::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList )
515 {
516  if( GetLayer() == LAYER_NOTES )
517  return;
518 
519  if( ( GetLayer() == LAYER_BUS ) || ( GetLayer() == LAYER_WIRE ) )
520  {
522  m_start );
523  aItemList.push_back( item );
524 
526  m_end );
527  aItemList.push_back( item1 );
528  }
529 }
530 
531 
532 bool SCH_LINE::UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemList )
533 {
534  bool previousStartState = m_startIsDangling;
535  bool previousEndState = m_endIsDangling;
536 
538 
539  if( GetLayer() == LAYER_WIRE )
540  {
541  for( DANGLING_END_ITEM item : aItemList )
542  {
543  if( item.GetItem() == this )
544  continue;
545 
546  if( item.GetType() == BUS_START_END ||
547  item.GetType() == BUS_END_END ||
548  item.GetType() == BUS_ENTRY_END )
549  continue;
550 
551  if( m_start == item.GetPosition() )
552  m_startIsDangling = false;
553 
554  if( m_end == item.GetPosition() )
555  m_endIsDangling = false;
556 
557  if( (m_startIsDangling == false) && (m_endIsDangling == false) )
558  break;
559  }
560  }
561  else if( GetLayer() == LAYER_BUS || GetLayer() == LAYER_NOTES )
562  {
563  // Lines on the notes layer and the bus layer cannot be tested for dangling ends.
564  previousStartState = previousEndState = m_startIsDangling = m_endIsDangling = false;
565  }
566 
567  return ( previousStartState != m_startIsDangling ) || ( previousEndState != m_endIsDangling );
568 }
569 
570 
572 {
573  if( m_Layer == LAYER_WIRE || m_Layer == LAYER_BUS )
574  return true;
575 
576  return false;
577 }
578 
579 
580 bool SCH_LINE::CanConnect( const SCH_ITEM* aItem ) const
581 {
582  switch( aItem->Type() )
583  {
584  case SCH_JUNCTION_T:
585  case SCH_NO_CONNECT_T:
586  case SCH_LABEL_T:
587  case SCH_GLOBAL_LABEL_T:
588  case SCH_HIER_LABEL_T:
590  case SCH_COMPONENT_T:
591  case SCH_SHEET_T:
592  case SCH_SHEET_PIN_T:
593  return true;
594 
595  default:
596  return aItem->GetLayer() == m_Layer;
597  }
598 }
599 
600 
601 void SCH_LINE::GetConnectionPoints( std::vector< wxPoint >& aPoints ) const
602 {
603  aPoints.push_back( m_start );
604  aPoints.push_back( m_end );
605 }
606 
607 
608 void SCH_LINE::GetSelectedPoints( std::vector< wxPoint >& aPoints ) const
609 {
610  if( m_Flags & STARTPOINT )
611  aPoints.push_back( m_start );
612 
613  if( m_Flags & ENDPOINT )
614  aPoints.push_back( m_end );
615 }
616 
617 
618 wxString SCH_LINE::GetSelectMenuText( EDA_UNITS_T aUnits ) const
619 {
620  wxString txtfmt, orient;
621 
622  if( m_start.x == m_end.x )
623  orient = _( "Vertical" );
624  else if( m_start.y == m_end.y )
625  orient = _( "Horizontal" );
626 
627  switch( m_Layer )
628  {
629  case LAYER_NOTES: txtfmt = _( "%s Graphic Line from (%s, %s) to (%s, %s)" ); break;
630  case LAYER_WIRE: txtfmt = _( "%s Wire from (%s, %s) to (%s, %s)" ); break;
631  case LAYER_BUS: txtfmt = _( "%s Bus from (%s, %s) to (%s, %s)" ); break;
632  default: txtfmt = _( "%s Line on Unknown Layer from (%s, %s) to (%s, %s)" ); break;
633  }
634 
635  return wxString::Format( txtfmt,
636  orient,
637  MessageTextFromValue( aUnits, m_start.x ),
638  MessageTextFromValue( aUnits, m_start.y ),
639  MessageTextFromValue( aUnits, m_end.x ),
640  MessageTextFromValue( aUnits, m_end.y ) );
641 }
642 
643 
644 BITMAP_DEF SCH_LINE::GetMenuImage() const
645 {
646  if( m_Layer == LAYER_NOTES )
647  return add_dashed_line_xpm;
648  else if( m_Layer == LAYER_WIRE )
649  return add_line_xpm;
650 
651  return add_bus_xpm;
652 }
653 
654 
656  SCH_SHEET_PATH* aSheetPath )
657 {
658  // Net list item not required for graphic lines.
659  if( (GetLayer() != LAYER_BUS) && (GetLayer() != LAYER_WIRE) )
660  return;
661 
662  NETLIST_OBJECT* item = new NETLIST_OBJECT();
663  item->m_SheetPath = *aSheetPath;
664  item->m_SheetPathInclude = *aSheetPath;
665  item->m_Comp = (SCH_ITEM*) this;
666  item->m_Start = m_start;
667  item->m_End = m_end;
668 
669  if( GetLayer() == LAYER_BUS )
670  {
671  item->m_Type = NET_BUS;
672  }
673  else /* WIRE */
674  {
675  item->m_Type = NET_SEGMENT;
676  }
677 
678  aNetListItems.push_back( item );
679 }
680 
681 
682 bool SCH_LINE::operator <( const SCH_ITEM& aItem ) const
683 {
684  if( Type() != aItem.Type() )
685  return Type() < aItem.Type();
686 
687  SCH_LINE* line = (SCH_LINE*) &aItem;
688 
689  if( GetLength() != line->GetLength() )
690  return GetLength() < line->GetLength();
691 
692  if( m_start.x != line->m_start.x )
693  return m_start.x < line->m_start.x;
694 
695  if( m_start.y != line->m_start.y )
696  return m_start.y < line->m_start.y;
697 
698  return false;
699 }
700 
701 
702 bool SCH_LINE::HitTest( const wxPoint& aPosition, int aAccuracy ) const
703 {
704  // Insure minimum accuracy
705  if( aAccuracy == 0 )
706  aAccuracy = ( GetPenSize() / 2 ) + 4;
707 
708  return TestSegmentHit( aPosition, m_start, m_end, aAccuracy );
709 }
710 
711 
712 bool SCH_LINE::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
713 {
714  if( m_Flags & ( STRUCT_DELETED | SKIP_STRUCT ) )
715  return false;
716 
717  EDA_RECT rect = aRect;
718 
719  if ( aAccuracy )
720  rect.Inflate( aAccuracy );
721 
722  if( aContained )
723  return rect.Contains( m_start ) && rect.Contains( m_end );
724 
725  return rect.Intersects( m_start, m_end );
726 }
727 
728 
730 {
731  SCH_LINE* item = (SCH_LINE*) aItem;
732 
733  std::swap( m_Layer, item->m_Layer );
734 
735  std::swap( m_start, item->m_start );
736  std::swap( m_end, item->m_end );
737  std::swap( m_startIsDangling, item->m_startIsDangling );
738  std::swap( m_endIsDangling, item->m_endIsDangling );
739  std::swap( m_style, item->m_style );
740  std::swap( m_size, item->m_size );
741  std::swap( m_color, item->m_color );
742 }
743 
744 
745 bool SCH_LINE::doIsConnected( const wxPoint& aPosition ) const
746 {
747  if( m_Layer != LAYER_WIRE && m_Layer != LAYER_BUS )
748  return false;
749 
750  return IsEndPoint( aPosition );
751 }
752 
753 
754 void SCH_LINE::Plot( PLOTTER* aPlotter )
755 {
756  if( m_color != COLOR4D::UNSPECIFIED )
757  aPlotter->SetColor( m_color );
758  else
759  aPlotter->SetColor( GetLayerColor( GetLayer() ) );
760 
761  aPlotter->SetCurrentLineWidth( GetPenSize() );
762 
763  aPlotter->SetDash( GetLineStyle() );
764 
765  aPlotter->MoveTo( m_start );
766  aPlotter->FinishTo( m_end );
767 
768  aPlotter->SetDash( 0 );
769 }
770 
771 
772 void SCH_LINE::SetPosition( const wxPoint& aPosition )
773 {
774  m_end = m_end - ( m_start - aPosition );
775  m_start = aPosition;
776 }
777 
778 
780 {
781  wxString msg;
782 
783  switch( GetLayer() )
784  {
785  case LAYER_WIRE: msg = _( "Net Wire" ); break;
786  case LAYER_BUS: msg = _( "Bus Wire" ); break;
787  default: msg = _( "Graphical" ); return;
788  }
789 
790  aList.push_back( MSG_PANEL_ITEM( _( "Line Type" ), msg, DARKCYAN ) );
791 
792  if( auto conn = Connection( *g_CurrentSheet ) )
793  {
794 #if defined(DEBUG)
795  conn->AppendDebugInfoToMsgPanel( aList );
796 
797  msg.Printf( "%zu", m_connected_items.size() );
798  aList.push_back( MSG_PANEL_ITEM( _( "Connections" ), msg, BROWN ) );
799 #else
800  conn->AppendInfoToMsgPanel( aList );
801 #endif
802  }
803 }
804 
void Rotate(wxPoint aPosition) override
Function Rotate rotates the item around aPosition 90 degrees in the clockwise direction.
Definition: sch_line.cpp:353
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:532
void GetConnectionPoints(std::vector< wxPoint > &aPoints) const override
Function GetConnectionPoints add all the connection points for this item to aPoints.
Definition: sch_line.cpp:601
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:514
static const char * style_names[]
Definition: sch_line.cpp:104
SCH_LAYER_ID m_Layer
Definition: sch_item.h:119
void SetModified()
Definition: base_struct.cpp:98
COLOR4D GetLineColor() const
Definition: sch_line.cpp:263
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:327
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:309
#define SKIP_STRUCT
flag indicating that the structure should be ignored
Definition: base_struct.h:131
void RotateEnd(wxPoint aPosition)
Definition: sch_line.cpp:366
void MoveStart(const wxPoint &aMoveVector)
Definition: sch_line.cpp:165
bool IsParallel(SCH_LINE *aLine)
Definition: sch_line.cpp:395
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:754
SCH_SHEET_PATH m_SheetPath
bool CanConnect(const SCH_ITEM *aItem) const override
Definition: sch_line.cpp:580
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
void ViewGetLayers(int aLayers[], int &aCount) const override
Function ViewGetLayers returns the layers the item is drawn on (which may be more than its "home" lay...
Definition: sch_line.cpp:202
int GetDefaultWidth() const
Definition: sch_line.cpp:298
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:702
void RotateStart(wxPoint aPosition)
Definition: sch_line.cpp:360
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:779
wxString MessageTextFromValue(EDA_UNITS_T aUnits, int aValue, bool aUseMils)
Definition: base_units.cpp:125
void SetLineColor(const COLOR4D aColor)
Definition: sch_line.cpp:239
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:571
double a
Alpha component.
Definition: color4d.h:304
void SetLineStyle(const int aStyle)
Definition: sch_line.cpp:280
void MirrorX(int aXaxis_position) override
Function MirrorX mirrors item relative to the X axis about aXaxis_position.
Definition: sch_line.cpp:339
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:644
double GetLength() const
Function GetLength.
Definition: sch_line.cpp:227
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:129
bool IsEndPoint(const wxPoint &aPoint) const
Definition: sch_line.h:83
Class SCH_SHEET_PATH.
int GetDefaultStyle() const
Definition: sch_line.cpp:271
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:745
void GetSelectedPoints(std::vector< wxPoint > &aPoints) const
Definition: sch_line.cpp:608
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:729
SCH_CONNECTION * Connection(const SCH_SHEET_PATH &aPath) const
Retrieves the connection associated with this object in the given sheet.
Definition: sch_item.cpp:128
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:372
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:408
COLOR4D GetDefaultColor() const
Definition: sch_line.cpp:233
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:682
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:187
#define ENDPOINT
ends. (Used to support dragging.)
Definition: base_struct.h:126
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:163
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:346
int GetPenSize() const override
Function GetPenSize virtual pure.
Definition: sch_line.cpp:318
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
Definition: sch_line.cpp:210
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:618
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:772
Definition of the NETLIST_OBJECT class.
int GetLineStyle() const
Definition: sch_line.cpp:289
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:154
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:210
#define min(a, b)
Definition: auxiliary.h:85
#define STARTPOINT
When a line is selected, these flags indicate which.
Definition: base_struct.h:125
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:655
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
Definition: colors.h:62