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 <sch_draw_panel.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 #include <sch_view.h>
43 
45 
46 
47 static wxPenStyle getwxPenStyle( PlotDashType aType )
48 {
49  switch( aType )
50  {
51  case PLOTDASHTYPE_SOLID: return wxPENSTYLE_SOLID;
52  case PLOTDASHTYPE_DASH: return wxPENSTYLE_SHORT_DASH;
53  case PLOTDASHTYPE_DOT: return wxPENSTYLE_DOT;
54  case PLOTDASHTYPE_DASHDOT: return wxPENSTYLE_DOT_DASH;
55  }
56 
57  wxFAIL_MSG( "Unhandled PlotDashType" );
58  return wxPENSTYLE_SOLID;
59 }
60 
61 
62 SCH_LINE::SCH_LINE( const wxPoint& pos, int layer ) :
63  SCH_ITEM( NULL, SCH_LINE_T )
64 {
65  m_start = pos;
66  m_end = pos;
68  m_size = 0;
69  m_style = -1;
70  m_color = COLOR4D::UNSPECIFIED;
71 
72  switch( layer )
73  {
74  default:
76  break;
77 
78  case LAYER_WIRE:
80  break;
81 
82  case LAYER_BUS:
84  break;
85  }
86 }
87 
88 
89 SCH_LINE::SCH_LINE( const SCH_LINE& aLine ) :
90  SCH_ITEM( aLine )
91 {
92  m_start = aLine.m_start;
93  m_end = aLine.m_end;
94  m_size = aLine.m_size;
95  m_style = aLine.m_style;
96  m_color = aLine.m_color;
99 }
100 
101 
103 {
104  return new SCH_LINE( *this );
105 }
106 
107 static const char* style_names[] =
108 {
109  "solid", "dashed", "dotted", "dash_dot", nullptr
110 };
111 
112 const char* SCH_LINE::GetLineStyleName( int aStyle )
113 {
114  const char * styleName = style_names[1];
115 
116  switch( aStyle )
117  {
118  case PLOTDASHTYPE_SOLID:
119  styleName = style_names[0];
120  break;
121 
122  default:
123  case PLOTDASHTYPE_DASH:
124  styleName = style_names[1];
125  break;
126 
127  case PLOTDASHTYPE_DOT:
128  styleName = style_names[2];
129  break;
130 
132  styleName = style_names[3];
133  break;
134  }
135 
136  return styleName;
137 }
138 
139 
140 int SCH_LINE::GetLineStyleInternalId( const wxString& aStyleName )
141 {
142  int id = -1; // Default style id
143 
144  for( int ii = 0; style_names[ii] != nullptr; ii++ )
145  {
146  if( aStyleName == style_names[ii] )
147  {
148  id = ii;
149  break;
150  }
151  }
152 
153  return id;
154 }
155 
156 
157 void SCH_LINE::Move( const wxPoint& aOffset )
158 {
159  if( (m_Flags & STARTPOINT) == 0 && aOffset != wxPoint( 0, 0 ) )
160  {
161  m_start += aOffset;
162  SetModified();
163  }
164 
165  if( (m_Flags & ENDPOINT) == 0 && aOffset != wxPoint( 0, 0 ) )
166  {
167  m_end += aOffset;
168  SetModified();
169  }
170 }
171 
172 
173 #if defined(DEBUG)
174 
175 void SCH_LINE::Show( int nestLevel, std::ostream& os ) const
176 {
177  NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str()
178  << " layer=\"" << m_Layer << '"'
179  << " startIsDangling=\"" << m_startIsDangling
180  << '"' << " endIsDangling=\""
181  << m_endIsDangling << '"' << ">"
182  << " <start" << m_start << "/>"
183  << " <end" << m_end << "/>" << "</"
184  << GetClass().Lower().mb_str() << ">\n";
185 }
186 
187 #endif
188 
189 
191 {
192  int width = 25;
193 
194  int xmin = std::min( m_start.x, m_end.x ) - width;
195  int ymin = std::min( m_start.y, m_end.y ) - width;
196 
197  int xmax = std::max( m_start.x, m_end.x ) + width;
198  int ymax = std::max( m_start.y, m_end.y ) + width;
199 
200  // return a rectangle which is [pos,dim) in nature. therefore the +1
201  EDA_RECT ret( wxPoint( xmin, ymin ), wxSize( xmax - xmin + 1, ymax - ymin + 1 ) );
202 
203  return ret;
204 }
205 
206 
207 double SCH_LINE::GetLength() const
208 {
209  return GetLineLength( m_start, m_end );
210 }
211 
212 
214 {
215  return GetLayerColor( m_Layer );
216 }
217 
218 
219 void SCH_LINE::SetLineColor( const COLOR4D aColor )
220 {
221  if( aColor == GetDefaultColor() )
222  m_color = COLOR4D::UNSPECIFIED;
223  else
224  m_color = aColor;
225 }
226 
227 
228 void SCH_LINE::SetLineColor( const double r, const double g, const double b, const double a )
229 {
230  COLOR4D newColor(r, g, b, a);
231 
232  if( newColor == GetDefaultColor() || newColor == COLOR4D::UNSPECIFIED )
233  m_color = COLOR4D::UNSPECIFIED;
234  else
235  {
236  // Eeschema does not allow alpha channel in colors
237  newColor.a = 1.0;
238  m_color = newColor;
239  }
240 }
241 
242 
244 {
245  if( m_color == COLOR4D::UNSPECIFIED )
246  return GetLayerColor( m_Layer );
247 
248  return m_color;
249 }
250 
252 {
253  if( m_Layer == LAYER_NOTES )
254  return PLOTDASHTYPE_DASH;
255 
256  return PLOTDASHTYPE_SOLID;
257 }
258 
259 
260 void SCH_LINE::SetLineStyle( const int aStyle )
261 {
262  if( aStyle == GetDefaultStyle() )
263  m_style = -1;
264  else
265  m_style = aStyle;
266 }
267 
268 
270 {
271  if( m_style >= 0 )
272  return m_style;
273 
274  return GetDefaultStyle();
275 }
276 
277 
279 {
280  if( m_Layer == LAYER_BUS )
281  return GetDefaultBusThickness();
282 
283  return GetDefaultLineThickness();
284 }
285 
286 
287 void SCH_LINE::SetLineWidth( const int aSize )
288 {
289  if( aSize == GetDefaultWidth() )
290  m_size = 0;
291  else
292  m_size = aSize;
293 }
294 
295 
297 {
298  if( m_size > 0 )
299  return m_size;
300 
301  if( m_Layer == LAYER_BUS )
302  return GetDefaultBusThickness();
303 
304  return GetDefaultLineThickness();
305 }
306 
307 
308 void SCH_LINE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset,
309  GR_DRAWMODE DrawMode, COLOR4D Color )
310 {
311  COLOR4D color;
312  int width = GetPenSize();
313 
314  if( Color != COLOR4D::UNSPECIFIED )
315  color = Color;
316  else if( m_color != COLOR4D::UNSPECIFIED )
317  color = m_color;
318  else
320 
321  GRSetDrawMode( DC, DrawMode );
322 
323  wxPoint start = m_start;
324  wxPoint end = m_end;
325 
326  if( ( m_Flags & STARTPOINT ) == 0 )
327  start += offset;
328 
329  if( ( m_Flags & ENDPOINT ) == 0 )
330  end += offset;
331 
332  GRLine( panel->GetClipBox(), DC, start.x, start.y, end.x, end.y, width, color,
334 
335  if( m_startIsDangling )
336  DrawDanglingSymbol( panel, DC, start, color );
337 
338  if( m_endIsDangling )
339  DrawDanglingSymbol( panel, DC, end, color );
340 }
341 
342 
343 void SCH_LINE::MirrorX( int aXaxis_position )
344 {
345  MIRROR( m_start.y, aXaxis_position );
346  MIRROR( m_end.y, aXaxis_position );
347 }
348 
349 
350 void SCH_LINE::MirrorY( int aYaxis_position )
351 {
352  MIRROR( m_start.x, aYaxis_position );
353  MIRROR( m_end.x, aYaxis_position );
354 }
355 
356 
357 void SCH_LINE::Rotate( wxPoint aPosition )
358 {
359  RotatePoint( &m_start, aPosition, 900 );
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 ) &&
384  sign( first.y ) == sign( second.y ) );
385 }
386 
387 
389 {
390  wxCHECK_MSG( aLine != NULL && aLine->Type() == SCH_LINE_T, false,
391  wxT( "Cannot test line segment for overlap." ) );
392 
393  wxPoint firstSeg = m_end - m_start;
394  wxPoint secondSeg = aLine->m_end - aLine->m_start;
395 
396  // Use long long here to avoid overflow in calculations
397  return !( (long long) firstSeg.x * secondSeg.y - (long long) firstSeg.y * secondSeg.x );
398 }
399 
400 
402 {
403  auto less = []( const wxPoint& lhs, const wxPoint& rhs ) -> bool
404  {
405  if( lhs.x == rhs.x )
406  return lhs.y < rhs.y;
407  return lhs.x < rhs.x;
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  SCH_LINE leftmost = SCH_LINE( *aLine );
416  SCH_LINE rightmost = SCH_LINE( *this );
417 
418  // We place the start to the left and below the end of both lines
419  if( leftmost.m_start != std::min( { leftmost.m_start, leftmost.m_end }, less ) )
420  std::swap( leftmost.m_start, leftmost.m_end );
421  if( rightmost.m_start != std::min( { rightmost.m_start, rightmost.m_end }, less ) )
422  std::swap( rightmost.m_start, rightmost.m_end );
423 
424  // -leftmost is the line that starts farthest to the left
425  // -other is the line that is _not_ leftmost
426  // -rightmost is the line that ends farthest to the right. This may or
427  // may not be 'other' as the second line may be completely covered by
428  // the first.
429  if( less( rightmost.m_start, leftmost.m_start ) )
430  std::swap( leftmost, rightmost );
431 
432  SCH_LINE other = SCH_LINE( rightmost );
433 
434  if( less( rightmost.m_end, leftmost.m_end ) )
435  rightmost = leftmost;
436 
437  // If we end one before the beginning of the other, no overlap is possible
438  if( less( leftmost.m_end, other.m_start ) )
439  {
440  return NULL;
441  }
442 
443  // Search for a common end:
444  if( ( leftmost.m_start == other.m_start )
445  && ( leftmost.m_end == other.m_end ) ) // Trivial case
446  {
447  return new SCH_LINE( leftmost );
448  }
449 
450  bool colinear = false;
451 
452  /* Test alignment: */
453  if( ( leftmost.m_start.y == leftmost.m_end.y )
454  && ( other.m_start.y == other.m_end.y ) ) // Horizontal segment
455  {
456  colinear = ( leftmost.m_start.y == other.m_start.y );
457  }
458  else if( ( leftmost.m_start.x == leftmost.m_end.x )
459  && ( other.m_start.x == other.m_end.x ) ) // Vertical segment
460  {
461  colinear = ( leftmost.m_start.x == other.m_start.x );
462  }
463  else
464  {
465  // We use long long here to avoid overflow -- it enforces promotion
466  // Don't use double as we need to make a direct comparison
467  // The slope of the left-most line is dy/dx. Then we check that the slope
468  // from the left most start to the right most start is the same as well as
469  // the slope from the left most start to right most end.
470  long long dx = leftmost.m_end.x - leftmost.m_start.x;
471  long long dy = leftmost.m_end.y - leftmost.m_start.y;
472  colinear = ( ( ( other.m_start.y - leftmost.m_start.y ) * dx ==
473  ( other.m_start.x - leftmost.m_start.x ) * dy ) &&
474  ( ( other.m_end.y - leftmost.m_start.y ) * dx ==
475  ( other.m_end.x - leftmost.m_start.x ) * dy ) );
476  }
477 
478  // Make a new segment that merges the 2 segments
479  if( colinear )
480  {
481  leftmost.m_end = rightmost.m_end;
482  return new SCH_LINE( leftmost );
483  }
484 
485  return NULL;
486 }
487 
488 
489 void SCH_LINE::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList )
490 {
491  if( GetLayer() == LAYER_NOTES )
492  return;
493 
494  if( ( GetLayer() == LAYER_BUS ) || ( GetLayer() == LAYER_WIRE ) )
495  {
497  m_start );
498  aItemList.push_back( item );
499 
501  m_end );
502  aItemList.push_back( item1 );
503  }
504 }
505 
506 
507 bool SCH_LINE::UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemList )
508 {
509  bool previousStartState = m_startIsDangling;
510  bool previousEndState = m_endIsDangling;
511 
513 
514  if( GetLayer() == LAYER_WIRE )
515  {
516  for( DANGLING_END_ITEM item : aItemList )
517  {
518  if( item.GetItem() == this )
519  continue;
520 
521  if( item.GetType() == NO_CONNECT_END ||
522  item.GetType() == BUS_START_END ||
523  item.GetType() == BUS_END_END ||
524  item.GetType() == BUS_ENTRY_END )
525  continue;
526 
527  if( m_start == item.GetPosition() )
528  m_startIsDangling = false;
529 
530  if( m_end == item.GetPosition() )
531  m_endIsDangling = false;
532 
533  if( (m_startIsDangling == false) && (m_endIsDangling == false) )
534  break;
535  }
536  }
537  else if( GetLayer() == LAYER_BUS || GetLayer() == LAYER_NOTES )
538  {
539  // Lines on the notes layer and the bus layer cannot be tested for dangling ends.
540  previousStartState = previousEndState = m_startIsDangling = m_endIsDangling = false;
541  }
542 
543  return ( previousStartState != m_startIsDangling ) || ( previousEndState != m_endIsDangling );
544 }
545 
546 
547 bool SCH_LINE::IsSelectStateChanged( const wxRect& aRect )
548 {
549  bool previousState = IsSelected();
550 
551  if( aRect.Contains( m_start ) && aRect.Contains( m_end ) )
552  {
553  SetFlags( SELECTED );
555  }
556  else if( aRect.Contains( m_start ) )
557  {
560  }
561  else if( aRect.Contains( m_end ) )
562  {
563  ClearFlags( ENDPOINT );
565  }
566  else
567  {
569  }
570 
571  return previousState != IsSelected();
572 }
573 
574 
576 {
577  if( m_Layer == LAYER_WIRE || m_Layer == LAYER_BUS )
578  return true;
579 
580  return false;
581 }
582 
583 
584 bool SCH_LINE::CanConnect( const SCH_ITEM* aItem ) const
585 {
586  switch( aItem->Type() )
587  {
588  case SCH_JUNCTION_T:
589  case SCH_NO_CONNECT_T:
590  case SCH_LABEL_T:
591  case SCH_GLOBAL_LABEL_T:
594  case SCH_COMPONENT_T:
595  case SCH_SHEET_T:
596  case SCH_SHEET_PIN_T:
597  return true;
598 
599  default:
600  return aItem->GetLayer() == m_Layer;
601  }
602 }
603 
604 
605 void SCH_LINE::GetConnectionPoints( std::vector< wxPoint >& aPoints ) const
606 {
607  aPoints.push_back( m_start );
608  aPoints.push_back( m_end );
609 }
610 
611 
612 wxString SCH_LINE::GetSelectMenuText( EDA_UNITS_T aUnits ) const
613 {
614  wxString txtfmt, orient;
615 
616  if( m_start.x == m_end.x )
617  orient = _( "Vertical" );
618  else if( m_start.y == m_end.y )
619  orient = _( "Horizontal" );
620 
621  switch( m_Layer )
622  {
623  case LAYER_NOTES:
624  txtfmt = _( "%s Graphic Line from (%s, %s) to (%s, %s)" );
625  break;
626 
627  case LAYER_WIRE:
628  txtfmt = _( "%s Wire from (%s, %s) to (%s, %s)" );
629  break;
630 
631  case LAYER_BUS:
632  txtfmt = _( "%s Bus from (%s, %s) to (%s, %s)" );
633  break;
634 
635  default:
636  txtfmt = _( "%s Line on Unknown Layer from (%s, %s) to (%s, %s)" );
637  }
638 
639  return wxString::Format( txtfmt,
640  orient,
641  MessageTextFromValue( aUnits, m_start.x ),
642  MessageTextFromValue( aUnits, m_start.y ),
643  MessageTextFromValue( aUnits, m_end.x ),
644  MessageTextFromValue( aUnits, m_end.y ) );
645 }
646 
647 
649 {
650  if( m_Layer == LAYER_NOTES )
651  return add_dashed_line_xpm;
652  else if( m_Layer == LAYER_WIRE )
653  return add_line_xpm;
654 
655  return add_bus_xpm;
656 }
657 
658 
660  SCH_SHEET_PATH* aSheetPath )
661 {
662  // Net list item not required for graphic lines.
663  if( (GetLayer() != LAYER_BUS) && (GetLayer() != LAYER_WIRE) )
664  return;
665 
666  NETLIST_OBJECT* item = new NETLIST_OBJECT();
667  item->m_SheetPath = *aSheetPath;
668  item->m_SheetPathInclude = *aSheetPath;
669  item->m_Comp = (SCH_ITEM*) this;
670  item->m_Start = m_start;
671  item->m_End = m_end;
672 
673  if( GetLayer() == LAYER_BUS )
674  {
675  item->m_Type = NET_BUS;
676  }
677  else /* WIRE */
678  {
679  item->m_Type = NET_SEGMENT;
680  }
681 
682  aNetListItems.push_back( item );
683 }
684 
685 
686 bool SCH_LINE::operator <( const SCH_ITEM& aItem ) const
687 {
688  if( Type() != aItem.Type() )
689  return Type() < aItem.Type();
690 
691  SCH_LINE* line = (SCH_LINE*) &aItem;
692 
693  if( GetLength() != line->GetLength() )
694  return GetLength() < line->GetLength();
695 
696  if( m_start.x != line->m_start.x )
697  return m_start.x < line->m_start.x;
698 
699  if( m_start.y != line->m_start.y )
700  return m_start.y < line->m_start.y;
701 
702  return false;
703 }
704 
705 
706 bool SCH_LINE::HitTest( const wxPoint& aPosition, int aAccuracy ) const
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  return wxPoint( ( m_start.x + m_end.x ) / 2, ( m_start.y + m_end.y ) / 2 );
782 }
783 
784 
785 int SCH_EDIT_FRAME::EditLine( SCH_LINE* aLine, bool aRedraw )
786 {
787  if( aLine == NULL )
788  return wxID_CANCEL;
789 
790  // We purposely disallow editing everything except graphic lines
791  if( aLine->GetLayer() != LAYER_NOTES )
792  return wxID_CANCEL;
793 
794  DIALOG_EDIT_LINE_STYLE dlg( this, aLine );
795 
796  if( dlg.ShowModal() == wxID_CANCEL )
797  return wxID_CANCEL;
798 
799  if( aRedraw )
800  RefreshItem( aLine );
801 
802  return wxID_OK;
803 }
void Rotate(wxPoint aPosition) override
Function Rotate rotates the item around aPosition 90 degrees in the clockwise direction.
Definition: sch_line.cpp:357
bool UpdateDanglingState(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:507
void GetConnectionPoints(std::vector< wxPoint > &aPoints) const override
Function GetConnectionPoints add all the connection points for this item to aPoints.
Definition: sch_line.cpp:605
void FinishTo(const wxPoint &pos)
Definition: plotter.h:251
int m_style
Line style.
Definition: sch_line.h:48
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201
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:489
static const char * style_names[]
Definition: sch_line.cpp:107
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:785
wxString GetClass() const override
Function GetClass returns the class name.
Definition: sch_line.h:64
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:547
PNG memory record (file in memory).
Definition: bitmap_types.h:43
void GRSetDrawMode(wxDC *DC, GR_DRAWMODE draw_mode)
Definition: gr_basic.cpp:223
static wxPenStyle getwxPenStyle(PlotDashType aType)
Definition: sch_line.cpp:47
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:243
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:287
#define SKIP_STRUCT
flag indicating that the structure should be ignored
Definition: base_struct.h:125
bool IsParallel(SCH_LINE *aLine)
Definition: sch_line.cpp:388
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
bool IsSelected() const
Definition: base_struct.h:224
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:584
virtual EDA_RECT * GetClipBox()
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:216
NETLIST_ITEM_T m_Type
int GetState(int type) const
Definition: base_struct.h:240
COLOR4D GetLayerColor(SCH_LAYER_ID aLayer)
Definition: eeschema.cpp:174
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:157
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...
wxString MessageTextFromValue(EDA_UNITS_T aUnits, int aValue, bool aUseMils)
Definition: base_units.cpp:125
void SetLineColor(const COLOR4D aColor)
Definition: sch_line.cpp:219
void MIRROR(T &aPoint, const T &aMirrorRef)
Definition: macros.h:111
#define SELECTED
Definition: base_struct.h:121
bool IsConnectable() const override
Function IsConnectable returns true if the schematic item can connect to another schematic item...
Definition: sch_line.cpp:575
COLOR4D GetDefaultColor() const
Definition: sch_line.cpp:213
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:706
double a
Alpha component.
Definition: color4d.h:290
void SetLineStyle(const int aStyle)
Definition: sch_line.cpp:260
void MirrorX(int aXaxis_position) override
Function MirrorX mirrors item relative to the X axis about aXaxis_position.
Definition: sch_line.cpp:343
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:256
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:648
wxPoint MidPoint()
Definition: sch_line.cpp:779
GR_DRAWMODE
Drawmode. Compositing mode plus a flag or two.
Definition: gr_basic.h:37
bool m_startIsDangling
True if start point is not connected.
Definition: sch_line.h:43
#define BRIGHTENED
item is drawn with a bright contour
Definition: base_struct.h:138
#define STRUCT_DELETED
flag indication structures to be erased
Definition: base_struct.h:123
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:285
static int GetLineStyleInternalId(const wxString &aStyleName)
Definition: sch_line.cpp:140
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
int GetLineStyle() const
Definition: sch_line.cpp:269
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:729
YYCODETYPE lhs
void MoveTo(const wxPoint &pos)
Definition: plotter.h:241
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:47
bool IsEndPoint(const wxPoint &aPoint) const
Definition: sch_line.h:69
int GetDefaultWidth() const
Definition: sch_line.cpp:278
Base plotter engine class.
Definition: plotter.h:97
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:401
Segment description base class to describe items which have 2 end points (track, wire, draw line ...)
Definition: sch_line.h:41
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:102
bool operator<(const SCH_ITEM &aItem) const override
Definition: sch_line.cpp:686
static const char * GetLineStyleName(int aStyle)
Definition: sch_line.cpp:112
#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:178
#define ENDPOINT
Definition: base_struct.h:120
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:154
virtual void SetDash(int dashed)=0
int GetDefaultStyle() const
Definition: sch_line.cpp:251
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:257
void MirrorY(int aYaxis_position) override
Function MirrorY mirrors item relative to the Y axis about aYaxis_position.
Definition: sch_line.cpp:350
int GetPenSize() const override
Function GetPenSize virtual pure.
Definition: sch_line.cpp:296
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes...
Definition: sch_line.cpp:190
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:308
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:612
bool TestSegmentHit(const wxPoint &aRefPoint, wxPoint aStart, wxPoint aEnd, int aDist)
Function TestSegmentHit test for hit on line segment i.e.
Definition: trigo.cpp:122
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.
double GetLength() const
Function GetLength.
Definition: sch_line.cpp:207
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
EDA_UNITS_T
Definition: common.h:159
SCH_LINE(const wxPoint &pos=wxPoint(0, 0), int layer=LAYER_NOTES)
Definition: sch_line.cpp:62
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:119
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:659
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39