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