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 
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;
98 }
99 
100 
102 {
103  return new SCH_LINE( *this );
104 }
105 
106 static const char* style_names[] =
107 {
108  "solid", "dashed", "dotted", "dash_dot", nullptr
109 };
110 
111 const char* SCH_LINE::GetLineStyleName( int aStyle )
112 {
113  const char * styleName = style_names[1];
114 
115  switch( aStyle )
116  {
117  case PLOTDASHTYPE_SOLID:
118  styleName = style_names[0];
119  break;
120 
121  default:
122  case PLOTDASHTYPE_DASH:
123  styleName = style_names[1];
124  break;
125 
126  case PLOTDASHTYPE_DOT:
127  styleName = style_names[2];
128  break;
129 
131  styleName = style_names[3];
132  break;
133  }
134 
135  return styleName;
136 }
137 
138 
139 int SCH_LINE::GetLineStyleInternalId( const wxString& aStyleName )
140 {
141  int id = -1; // Default style id
142 
143  for( int ii = 0; style_names[ii] != nullptr; ii++ )
144  {
145  if( aStyleName == style_names[ii] )
146  {
147  id = ii;
148  break;
149  }
150  }
151 
152  return id;
153 }
154 
155 
156 void SCH_LINE::Move( const wxPoint& aOffset )
157 {
158  if( aOffset != wxPoint( 0, 0 ) )
159  {
160  m_start += aOffset;
161  m_end += aOffset;
162  SetModified();
163  }
164 }
165 
166 
167 void SCH_LINE::MoveStart( const wxPoint& aOffset )
168 {
169  if( aOffset != wxPoint( 0, 0 ) )
170  {
171  m_start += aOffset;
172  SetModified();
173  }
174 }
175 
176 
177 void SCH_LINE::MoveEnd( const wxPoint& aOffset )
178 {
179  if( aOffset != wxPoint( 0, 0 ) )
180  {
181  m_end += aOffset;
182  SetModified();
183  }
184 }
185 
186 
187 #if defined(DEBUG)
188 
189 void SCH_LINE::Show( int nestLevel, std::ostream& os ) const
190 {
191  NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str()
192  << " layer=\"" << m_Layer << '"'
193  << " startIsDangling=\"" << m_startIsDangling
194  << '"' << " endIsDangling=\""
195  << m_endIsDangling << '"' << ">"
196  << " <start" << m_start << "/>"
197  << " <end" << m_end << "/>" << "</"
198  << GetClass().Lower().mb_str() << ">\n";
199 }
200 
201 #endif
202 
203 
205 {
206  int width = 25;
207 
208  int xmin = std::min( m_start.x, m_end.x ) - width;
209  int ymin = std::min( m_start.y, m_end.y ) - width;
210 
211  int xmax = std::max( m_start.x, m_end.x ) + width;
212  int ymax = std::max( m_start.y, m_end.y ) + width;
213 
214  // return a rectangle which is [pos,dim) in nature. therefore the +1
215  EDA_RECT ret( wxPoint( xmin, ymin ), wxSize( xmax - xmin + 1, ymax - ymin + 1 ) );
216 
217  return ret;
218 }
219 
220 
221 double SCH_LINE::GetLength() const
222 {
223  return GetLineLength( m_start, m_end );
224 }
225 
226 
228 {
229  return GetLayerColor( m_Layer );
230 }
231 
232 
233 void SCH_LINE::SetLineColor( const COLOR4D aColor )
234 {
235  if( aColor == GetDefaultColor() )
236  m_color = COLOR4D::UNSPECIFIED;
237  else
238  m_color = aColor;
239 }
240 
241 
242 void SCH_LINE::SetLineColor( const double r, const double g, const double b, const double a )
243 {
244  COLOR4D newColor(r, g, b, a);
245 
246  if( newColor == GetDefaultColor() || newColor == COLOR4D::UNSPECIFIED )
247  m_color = COLOR4D::UNSPECIFIED;
248  else
249  {
250  // Eeschema does not allow alpha channel in colors
251  newColor.a = 1.0;
252  m_color = newColor;
253  }
254 }
255 
256 
258 {
259  if( m_color == COLOR4D::UNSPECIFIED )
260  return GetLayerColor( m_Layer );
261 
262  return m_color;
263 }
264 
266 {
267  if( m_Layer == LAYER_NOTES )
268  return PLOTDASHTYPE_DASH;
269 
270  return PLOTDASHTYPE_SOLID;
271 }
272 
273 
274 void SCH_LINE::SetLineStyle( const int aStyle )
275 {
276  if( aStyle == GetDefaultStyle() )
277  m_style = -1;
278  else
279  m_style = aStyle;
280 }
281 
282 
284 {
285  if( m_style >= 0 )
286  return m_style;
287 
288  return GetDefaultStyle();
289 }
290 
291 
293 {
294  if( m_Layer == LAYER_BUS )
295  return GetDefaultBusThickness();
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  if( m_Layer == LAYER_BUS )
316  return GetDefaultBusThickness();
317 
318  return GetDefaultLineThickness();
319 }
320 
321 
322 void SCH_LINE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset )
323 {
324  COLOR4D color = ( m_color != COLOR4D::UNSPECIFIED ) ? m_color : GetLayerColor( m_Layer );
325  int width = GetPenSize();
326  wxPoint start = m_start;
327  wxPoint end = m_end;
328 
329  GRLine( panel->GetClipBox(), DC, start.x, start.y, end.x, end.y, width, color,
331 }
332 
333 
334 void SCH_LINE::MirrorX( int aXaxis_position )
335 {
336  MIRROR( m_start.y, aXaxis_position );
337  MIRROR( m_end.y, aXaxis_position );
338 }
339 
340 
341 void SCH_LINE::MirrorY( int aYaxis_position )
342 {
343  MIRROR( m_start.x, aYaxis_position );
344  MIRROR( m_end.x, aYaxis_position );
345 }
346 
347 
348 void SCH_LINE::Rotate( wxPoint aPosition )
349 {
350  RotatePoint( &m_start, aPosition, 900 );
351  RotatePoint( &m_end, aPosition, 900 );
352 }
353 
354 
355 void SCH_LINE::RotateStart( wxPoint aPosition )
356 {
357  RotatePoint( &m_start, aPosition, 900 );
358 }
359 
360 
361 void SCH_LINE::RotateEnd( wxPoint aPosition )
362 {
363  RotatePoint( &m_end, aPosition, 900 );
364 }
365 
366 
367 bool SCH_LINE::IsSameQuadrant( SCH_LINE* aLine, const wxPoint& aPosition )
368 {
369  wxPoint first;
370  wxPoint second;
371 
372  if( m_start == aPosition )
373  first = m_end - aPosition;
374  else if( m_end == aPosition )
375  first = m_start - aPosition;
376  else
377  return false;
378 
379  if( aLine->m_start == aPosition )
380  second = aLine->m_end - aPosition;
381  else if( aLine->m_end == aPosition )
382  second = aLine->m_start - aPosition;
383  else
384  return false;
385 
386  return ( sign( first.x ) == sign( second.x ) &&
387  sign( first.y ) == sign( second.y ) );
388 }
389 
390 
392 {
393  wxCHECK_MSG( aLine != NULL && aLine->Type() == SCH_LINE_T, false,
394  wxT( "Cannot test line segment for overlap." ) );
395 
396  wxPoint firstSeg = m_end - m_start;
397  wxPoint secondSeg = aLine->m_end - aLine->m_start;
398 
399  // Use long long here to avoid overflow in calculations
400  return !( (long long) firstSeg.x * secondSeg.y - (long long) firstSeg.y * secondSeg.x );
401 }
402 
403 
405 {
406  auto less = []( const wxPoint& lhs, const wxPoint& rhs ) -> bool
407  {
408  if( lhs.x == rhs.x )
409  return lhs.y < rhs.y;
410  return lhs.x < rhs.x;
411  };
412 
413  wxCHECK_MSG( aLine != NULL && aLine->Type() == SCH_LINE_T, NULL,
414  wxT( "Cannot test line segment for overlap." ) );
415 
416  if( this == aLine || GetLayer() != aLine->GetLayer() )
417  return NULL;
418 
419  auto leftmost_start = aLine->m_start;
420  auto leftmost_end = aLine->m_end;
421 
422  auto rightmost_start = m_start;
423  auto rightmost_end = m_end;
424 
425  // We place the start to the left and below the end of both lines
426  if( leftmost_start != std::min( { leftmost_start, leftmost_end }, less ) )
427  std::swap( leftmost_start, leftmost_end );
428  if( rightmost_start != std::min( { rightmost_start, rightmost_end }, less ) )
429  std::swap( rightmost_start, rightmost_end );
430 
431  // -leftmost is the line that starts farthest to the left
432  // -other is the line that is _not_ leftmost
433  // -rightmost is the line that ends farthest to the right. This may or
434  // may not be 'other' as the second line may be completely covered by
435  // the first.
436  if( less( rightmost_start, leftmost_start ) )
437  {
438  std::swap( leftmost_start, rightmost_start );
439  std::swap( leftmost_end, rightmost_end );
440  }
441 
442  auto other_start = rightmost_start;
443  auto other_end = rightmost_end;
444 
445  if( less( rightmost_end, leftmost_end ) )
446  {
447  rightmost_start = leftmost_start;
448  rightmost_end = leftmost_end;
449  }
450 
451  // If we end one before the beginning of the other, no overlap is possible
452  if( less( leftmost_end, other_start ) )
453  {
454  return NULL;
455  }
456 
457  // Search for a common end:
458  if( ( leftmost_start == other_start ) &&
459  ( leftmost_end == other_end ) ) // Trivial case
460  {
461  auto ret = new SCH_LINE( *aLine );
462  ret->SetStartPoint( leftmost_start );
463  ret->SetEndPoint( leftmost_end );
464  return ret;
465  }
466 
467  bool colinear = false;
468 
469  /* Test alignment: */
470  if( ( leftmost_start.y == leftmost_end.y ) &&
471  ( other_start.y == other_end.y ) ) // Horizontal segment
472  {
473  colinear = ( leftmost_start.y == other_start.y );
474  }
475  else if( ( leftmost_start.x == leftmost_end.x ) &&
476  ( other_start.x == other_end.x ) ) // Vertical segment
477  {
478  colinear = ( leftmost_start.x == other_start.x );
479  }
480  else
481  {
482  // We use long long here to avoid overflow -- it enforces promotion
483  // Don't use double as we need to make a direct comparison
484  // The slope of the left-most line is dy/dx. Then we check that the slope
485  // from the left most start to the right most start is the same as well as
486  // the slope from the left most start to right most end.
487  long long dx = leftmost_end.x - leftmost_start.x;
488  long long dy = leftmost_end.y - leftmost_start.y;
489  colinear = ( ( ( other_start.y - leftmost_start.y ) * dx ==
490  ( other_start.x - leftmost_start.x ) * dy ) &&
491  ( ( other_end.y - leftmost_start.y ) * dx ==
492  ( other_end.x - leftmost_start.x ) * dy ) );
493  }
494 
495  // Make a new segment that merges the 2 segments
496  if( colinear )
497  {
498  leftmost_end = rightmost_end;
499 
500  auto ret = new SCH_LINE( *aLine );
501  ret->SetStartPoint( leftmost_start );
502  ret->SetEndPoint( leftmost_end );
503  return ret;
504  }
505 
506  return NULL;
507 }
508 
509 
510 void SCH_LINE::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList )
511 {
512  if( GetLayer() == LAYER_NOTES )
513  return;
514 
515  if( ( GetLayer() == LAYER_BUS ) || ( GetLayer() == LAYER_WIRE ) )
516  {
518  m_start );
519  aItemList.push_back( item );
520 
522  m_end );
523  aItemList.push_back( item1 );
524  }
525 }
526 
527 
528 bool SCH_LINE::UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemList )
529 {
530  bool previousStartState = m_startIsDangling;
531  bool previousEndState = m_endIsDangling;
532 
534 
535  if( GetLayer() == LAYER_WIRE )
536  {
537  for( DANGLING_END_ITEM item : aItemList )
538  {
539  if( item.GetItem() == this )
540  continue;
541 
542  if( item.GetType() == BUS_START_END ||
543  item.GetType() == BUS_END_END ||
544  item.GetType() == BUS_ENTRY_END )
545  continue;
546 
547  if( m_start == item.GetPosition() )
548  m_startIsDangling = false;
549 
550  if( m_end == item.GetPosition() )
551  m_endIsDangling = false;
552 
553  if( (m_startIsDangling == false) && (m_endIsDangling == false) )
554  break;
555  }
556  }
557  else if( GetLayer() == LAYER_BUS || GetLayer() == LAYER_NOTES )
558  {
559  // Lines on the notes layer and the bus layer cannot be tested for dangling ends.
560  previousStartState = previousEndState = m_startIsDangling = m_endIsDangling = false;
561  }
562 
563  return ( previousStartState != m_startIsDangling ) || ( previousEndState != m_endIsDangling );
564 }
565 
566 
568 {
569  if( m_Layer == LAYER_WIRE || m_Layer == LAYER_BUS )
570  return true;
571 
572  return false;
573 }
574 
575 
576 bool SCH_LINE::CanConnect( const SCH_ITEM* aItem ) const
577 {
578  switch( aItem->Type() )
579  {
580  case SCH_JUNCTION_T:
581  case SCH_NO_CONNECT_T:
582  case SCH_LABEL_T:
583  case SCH_GLOBAL_LABEL_T:
584  case SCH_HIER_LABEL_T:
586  case SCH_COMPONENT_T:
587  case SCH_SHEET_T:
588  case SCH_SHEET_PIN_T:
589  return true;
590 
591  default:
592  return aItem->GetLayer() == m_Layer;
593  }
594 }
595 
596 
597 void SCH_LINE::GetConnectionPoints( std::vector< wxPoint >& aPoints ) const
598 {
599  aPoints.push_back( m_start );
600  aPoints.push_back( m_end );
601 }
602 
603 
604 wxString SCH_LINE::GetSelectMenuText( EDA_UNITS_T aUnits ) const
605 {
606  wxString txtfmt, orient;
607 
608  if( m_start.x == m_end.x )
609  orient = _( "Vertical" );
610  else if( m_start.y == m_end.y )
611  orient = _( "Horizontal" );
612 
613  switch( m_Layer )
614  {
615  case LAYER_NOTES:
616  txtfmt = _( "%s Graphic Line from (%s, %s) to (%s, %s)" );
617  break;
618 
619  case LAYER_WIRE:
620  txtfmt = _( "%s Wire from (%s, %s) to (%s, %s)" );
621  break;
622 
623  case LAYER_BUS:
624  txtfmt = _( "%s Bus from (%s, %s) to (%s, %s)" );
625  break;
626 
627  default:
628  txtfmt = _( "%s Line on Unknown Layer from (%s, %s) to (%s, %s)" );
629  }
630 
631  return wxString::Format( txtfmt,
632  orient,
633  MessageTextFromValue( aUnits, m_start.x ),
634  MessageTextFromValue( aUnits, m_start.y ),
635  MessageTextFromValue( aUnits, m_end.x ),
636  MessageTextFromValue( aUnits, m_end.y ) );
637 }
638 
639 
640 BITMAP_DEF SCH_LINE::GetMenuImage() const
641 {
642  if( m_Layer == LAYER_NOTES )
643  return add_dashed_line_xpm;
644  else if( m_Layer == LAYER_WIRE )
645  return add_line_xpm;
646 
647  return add_bus_xpm;
648 }
649 
650 
652  SCH_SHEET_PATH* aSheetPath )
653 {
654  // Net list item not required for graphic lines.
655  if( (GetLayer() != LAYER_BUS) && (GetLayer() != LAYER_WIRE) )
656  return;
657 
658  NETLIST_OBJECT* item = new NETLIST_OBJECT();
659  item->m_SheetPath = *aSheetPath;
660  item->m_SheetPathInclude = *aSheetPath;
661  item->m_Comp = (SCH_ITEM*) this;
662  item->m_Start = m_start;
663  item->m_End = m_end;
664 
665  if( GetLayer() == LAYER_BUS )
666  {
667  item->m_Type = NET_BUS;
668  }
669  else /* WIRE */
670  {
671  item->m_Type = NET_SEGMENT;
672  }
673 
674  aNetListItems.push_back( item );
675 }
676 
677 
678 bool SCH_LINE::operator <( const SCH_ITEM& aItem ) const
679 {
680  if( Type() != aItem.Type() )
681  return Type() < aItem.Type();
682 
683  SCH_LINE* line = (SCH_LINE*) &aItem;
684 
685  if( GetLength() != line->GetLength() )
686  return GetLength() < line->GetLength();
687 
688  if( m_start.x != line->m_start.x )
689  return m_start.x < line->m_start.x;
690 
691  if( m_start.y != line->m_start.y )
692  return m_start.y < line->m_start.y;
693 
694  return false;
695 }
696 
697 
698 bool SCH_LINE::HitTest( const wxPoint& aPosition, int aAccuracy ) const
699 {
700  // Insure minimum accuracy
701  if( aAccuracy == 0 )
702  aAccuracy = ( GetPenSize() / 2 ) + 4;
703 
704  return TestSegmentHit( aPosition, m_start, m_end, aAccuracy );
705 }
706 
707 
708 bool SCH_LINE::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
709 {
710  if( m_Flags & ( STRUCT_DELETED | SKIP_STRUCT ) )
711  return false;
712 
713  EDA_RECT rect = aRect;
714 
715  if ( aAccuracy )
716  rect.Inflate( aAccuracy );
717 
718  if( aContained )
719  return rect.Contains( m_start ) && rect.Contains( m_end );
720 
721  return rect.Intersects( m_start, m_end );
722 }
723 
724 
726 {
727  SCH_LINE* item = (SCH_LINE*) aItem;
728 
729  std::swap( m_Layer, item->m_Layer );
730 
731  std::swap( m_start, item->m_start );
732  std::swap( m_end, item->m_end );
733  std::swap( m_startIsDangling, item->m_startIsDangling );
734  std::swap( m_endIsDangling, item->m_endIsDangling );
735  std::swap( m_style, item->m_style );
736  std::swap( m_size, item->m_size );
737  std::swap( m_color, item->m_color );
738 }
739 
740 
741 bool SCH_LINE::doIsConnected( const wxPoint& aPosition ) const
742 {
743  if( m_Layer != LAYER_WIRE && m_Layer != LAYER_BUS )
744  return false;
745 
746  return IsEndPoint( aPosition );
747 }
748 
749 
750 void SCH_LINE::Plot( PLOTTER* aPlotter )
751 {
752  if( m_color != COLOR4D::UNSPECIFIED )
753  aPlotter->SetColor( m_color );
754  else
755  aPlotter->SetColor( GetLayerColor( GetLayer() ) );
756 
757  aPlotter->SetCurrentLineWidth( GetPenSize() );
758 
759  aPlotter->SetDash( GetLineStyle() );
760 
761  aPlotter->MoveTo( m_start );
762  aPlotter->FinishTo( m_end );
763 
764  aPlotter->SetDash( 0 );
765 }
766 
767 
768 void SCH_LINE::SetPosition( const wxPoint& aPosition )
769 {
770  m_end = m_end - ( m_start - aPosition );
771  m_start = aPosition;
772 }
773 
774 
776 {
777  return wxPoint( ( m_start.x + m_end.x ) / 2, ( m_start.y + m_end.y ) / 2 );
778 }
779 
780 
782 {
783  wxString msg;
784 
785  switch( GetLayer() )
786  {
787  case LAYER_WIRE:
788  msg = _( "Net Wire" );
789  break;
790 
791  case LAYER_BUS:
792  msg = _( "Bus Wire" );
793  break;
794 
795  default:
796  msg = _( "Graphical" );
797  return;
798  }
799 
800  aList.push_back( MSG_PANEL_ITEM( _( "Line Type" ), msg, DARKCYAN ) );
801 
802  if( auto conn = Connection( *g_CurrentSheet ) )
803  {
804 #if defined(DEBUG)
805  conn->AppendDebugInfoToMsgPanel( aList );
806 
807  msg.Printf( "%zu", m_connected_items.size() );
808  aList.push_back( MSG_PANEL_ITEM( _( "Connections" ), msg, BROWN ) );
809 #else
810  conn->AppendInfoToMsgPanel( aList );
811 #endif
812  }
813 }
814 
815 
816 int SCH_EDIT_FRAME::EditLine( SCH_LINE* aLine, bool aRedraw )
817 {
818  if( aLine == NULL )
819  return wxID_CANCEL;
820 
821  // We purposely disallow editing everything except graphic lines
822  if( aLine->GetLayer() != LAYER_NOTES )
823  return wxID_CANCEL;
824 
825  DIALOG_EDIT_LINE_STYLE dlg( this, aLine );
826 
827  if( dlg.ShowModal() == wxID_CANCEL )
828  return wxID_CANCEL;
829 
830  if( aRedraw )
831  RefreshItem( aLine );
832 
833  return wxID_OK;
834 }
void Rotate(wxPoint aPosition) override
Function Rotate rotates the item around aPosition 90 degrees in the clockwise direction.
Definition: sch_line.cpp:348
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:528
void GetConnectionPoints(std::vector< wxPoint > &aPoints) const override
Function GetConnectionPoints add all the connection points for this item to aPoints.
Definition: sch_line.cpp:597
void FinishTo(const wxPoint &pos)
Definition: plotter.h:251
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:510
static const char * style_names[]
Definition: sch_line.cpp:106
SCH_LAYER_ID m_Layer
Definition: sch_item.h:119
void SetModified()
COLOR4D GetLineColor() const
Definition: sch_line.cpp:257
int EditLine(SCH_LINE *aLine, bool aRedraw)
Function EditLine displays the dialog for editing the parameters of aLine.
Definition: sch_line.cpp:816
wxString GetClass() const override
Function GetClass returns the class name.
Definition: sch_line.h:60
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:200
static wxPenStyle getwxPenStyle(PlotDashType aType)
Definition: sch_line.cpp:46
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:125
void RotateEnd(wxPoint aPosition)
Definition: sch_line.cpp:361
void MoveStart(const wxPoint &aMoveVector)
Definition: sch_line.cpp:167
bool IsParallel(SCH_LINE *aLine)
Definition: sch_line.cpp:391
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:750
SCH_SHEET_PATH m_SheetPath
bool CanConnect(const SCH_ITEM *aItem) const override
Definition: sch_line.cpp:576
virtual EDA_RECT * GetClipBox()
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:216
NETLIST_ITEM_T m_Type
COLOR4D GetLayerColor(SCH_LAYER_ID aLayer)
Definition: eeschema.cpp:174
EDA_ITEM * m_Comp
int GetDefaultWidth() const
Definition: sch_line.cpp:292
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:698
void RotateStart(wxPoint aPosition)
Definition: sch_line.cpp:355
void Move(const wxPoint &aMoveVector) override
Function Move moves the item by aMoveVector to a new position.
Definition: sch_line.cpp:156
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:781
wxString MessageTextFromValue(EDA_UNITS_T aUnits, int aValue, bool aUseMils)
Definition: base_units.cpp:125
void SetLineColor(const COLOR4D aColor)
Definition: sch_line.cpp:233
void MIRROR(T &aPoint, const T &aMirrorRef)
Definition: macros.h:122
bool IsConnectable() const override
Function IsConnectable returns true if the schematic item can connect to another schematic item.
Definition: sch_line.cpp:567
double a
Alpha component.
Definition: color4d.h:312
void SetLineStyle(const int aStyle)
Definition: sch_line.cpp:274
void MirrorX(int aXaxis_position) override
Function MirrorX mirrors item relative to the X axis about aXaxis_position.
Definition: sch_line.cpp:334
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:640
wxPoint MidPoint()
Definition: sch_line.cpp:775
double GetLength() const
Function GetLength.
Definition: sch_line.cpp:221
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:123
bool IsEndPoint(const wxPoint &aPoint) const
Definition: sch_line.h:83
Class SCH_SHEET_PATH.
int GetDefaultStyle() const
Definition: sch_line.cpp:265
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:139
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:741
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:725
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: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:367
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:404
COLOR4D GetDefaultColor() const
Definition: sch_line.cpp:227
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:101
void MoveEnd(const wxPoint &aMoveVector)
Definition: sch_line.cpp:177
bool operator<(const SCH_ITEM &aItem) const override
Definition: sch_line.cpp:678
static const char * GetLineStyleName(int aStyle)
Definition: sch_line.cpp:111
#define max(a, b)
Definition: auxiliary.h:86
void RefreshItem(EDA_ITEM *aItem, bool isAddOrDelete=false)
Mark an item for refresh.
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:181
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:157
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:341
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:204
void Draw(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aOffset) override
Function Draw Draw a schematic item.
Definition: sch_line.cpp:322
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:604
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:122
void SetPosition(const wxPoint &aPosition) override
Function SetPosition set the schematic item position to aPosition.
Definition: sch_line.cpp:768
Definition of the NETLIST_OBJECT class.
int GetLineStyle() const
Definition: sch_line.cpp:283
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:61
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:204
#define min(a, b)
Definition: auxiliary.h:85
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:651
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
Definition: colors.h:62