KiCad PCB EDA Suite
sch_bus_entry.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) 2004 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2004-2021 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 
25 #include <sch_draw_panel.h>
26 #include <bitmaps.h>
27 #include <core/mirror.h>
28 #include <schematic.h>
29 #include <sch_bus_entry.h>
30 #include <sch_edit_frame.h>
31 #include <sch_junction.h>
32 #include <sch_line.h>
33 #include <sch_text.h>
34 #include <project/net_settings.h>
35 #include <project/project_file.h>
37 #include <netclass.h>
38 #include <trigo.h>
39 #include <board_item.h>
40 #include <advanced_config.h>
41 #include <connection_graph.h>
42 #include "sch_painter.h"
43 
44 
45 SCH_BUS_ENTRY_BASE::SCH_BUS_ENTRY_BASE( KICAD_T aType, const wxPoint& pos, bool aFlipY ) :
46  SCH_ITEM( nullptr, aType )
47 {
48  m_pos = pos;
49  m_size.x = Mils2iu( DEFAULT_SCH_ENTRY_SIZE );
50  m_size.y = Mils2iu( DEFAULT_SCH_ENTRY_SIZE );
51 
52  m_stroke.SetWidth( 0 );
54  m_stroke.SetColor( COLOR4D::UNSPECIFIED );
55 
56  if( aFlipY )
57  m_size.y *= -1;
58 
60 
63  m_lastResolvedColor = COLOR4D::UNSPECIFIED;
64 }
65 
66 
67 SCH_BUS_WIRE_ENTRY::SCH_BUS_WIRE_ENTRY( const wxPoint& pos, bool aFlipY ) :
69 {
71  m_connected_bus_item = nullptr;
72 
75  m_lastResolvedColor = COLOR4D::UNSPECIFIED;
76 }
77 
78 
79 SCH_BUS_WIRE_ENTRY::SCH_BUS_WIRE_ENTRY( const wxPoint& pos, int aQuadrant ) :
81 {
82  switch( aQuadrant )
83  {
84  case 1: m_size.x *= 1; m_size.y *= -1; break;
85  case 2: m_size.x *= 1; m_size.y *= 1; break;
86  case 3: m_size.x *= -1; m_size.y *= 1; break;
87  case 4: m_size.x *= -1; m_size.y *= -1; break;
88  default: wxFAIL_MSG( wxT( "SCH_BUS_WIRE_ENTRY ctor: unexpected quadrant" ) );
89  }
90 
92  m_connected_bus_item = nullptr;
93 
96  m_lastResolvedColor = COLOR4D::UNSPECIFIED;
97 }
98 
99 
100 SCH_BUS_BUS_ENTRY::SCH_BUS_BUS_ENTRY( const wxPoint& pos, bool aFlipY ) :
102 {
103  m_layer = LAYER_BUS;
104  m_connected_bus_items[0] = nullptr;
105  m_connected_bus_items[1] = nullptr;
106 
109  m_lastResolvedColor = COLOR4D::UNSPECIFIED;
110 }
111 
112 
114 {
115  return new SCH_BUS_WIRE_ENTRY( *this );
116 }
117 
118 
120 {
121  return new SCH_BUS_BUS_ENTRY( *this );
122 }
123 
124 
125 bool SCH_BUS_ENTRY_BASE::doIsConnected( const wxPoint& aPosition ) const
126 {
127  return ( m_pos == aPosition || GetEnd() == aPosition );
128 }
129 
130 
132 {
133  return wxPoint( m_pos.x + m_size.x, m_pos.y + m_size.y );
134 }
135 
136 
138 {
139  SCH_BUS_ENTRY_BASE* item = dynamic_cast<SCH_BUS_ENTRY_BASE*>( aItem );
140  wxCHECK_RET( item, wxT( "Cannot swap bus entry data with invalid item." ) );
141 
142  std::swap( m_pos, item->m_pos );
143  std::swap( m_size, item->m_size );
144  std::swap( m_stroke, item->m_stroke );
145 
146  std::swap( m_lastResolvedWidth, item->m_lastResolvedWidth );
148  std::swap( m_lastResolvedColor, item->m_lastResolvedColor );
149 }
150 
151 
152 void SCH_BUS_ENTRY_BASE::ViewGetLayers( int aLayers[], int& aCount ) const
153 {
154  aCount = 3;
155  aLayers[0] = LAYER_DANGLING;
156  aLayers[1] = Type() == SCH_BUS_BUS_ENTRY_T ? LAYER_BUS : LAYER_WIRE;
157  aLayers[2] = LAYER_SELECTION_SHADOWS;
158 }
159 
160 
162 {
163  EDA_RECT box;
164 
165  box.SetOrigin( m_pos );
166  box.SetEnd( GetEnd() );
167 
168  box.Normalize();
169  box.Inflate( ( GetPenWidth() / 2 ) + 1 );
170 
171  return box;
172 }
173 
174 
176 {
177  if( m_stroke.GetColor() != COLOR4D::UNSPECIFIED )
178  {
180  }
181  else if( IsConnectable() && !IsConnectivityDirty() )
182  {
183  NETCLASSPTR netclass = NetClass();
184 
185  if( netclass )
186  m_lastResolvedColor = netclass->GetSchematicColor();
187  }
188 
189  return m_lastResolvedColor;
190 }
191 
192 
194 {
196  {
198  }
199  else if( IsConnectable() && !IsConnectivityDirty() )
200  {
201  NETCLASSPTR netclass = NetClass();
202 
203  if( netclass )
204  m_lastResolvedLineStyle = static_cast<PLOT_DASH_TYPE>( netclass->GetLineStyle() );
205  }
206 
208 }
209 
210 
212 {
213  if( m_stroke.GetWidth() > 0 )
214  {
216  }
217  else if( IsConnectable() && !IsConnectivityDirty() )
218  {
219  NETCLASSPTR netclass = NetClass();
220 
221  if( netclass )
222  m_lastResolvedWidth = netclass->GetWireWidth();
223  }
224 
225  return m_lastResolvedWidth;
226 }
227 
228 
230 {
231  if( m_stroke.GetWidth() > 0 )
232  {
234  }
235  else if( IsConnectable() && !IsConnectivityDirty() )
236  {
237  NETCLASSPTR netclass = NetClass();
238 
239  if( netclass )
240  m_lastResolvedWidth = netclass->GetBusWidth();
241  }
242 
243  return m_lastResolvedWidth;
244 }
245 
246 
247 void SCH_BUS_WIRE_ENTRY::GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList )
248 {
249  DANGLING_END_ITEM item( WIRE_ENTRY_END, this, m_pos );
250  aItemList.push_back( item );
251 
252  DANGLING_END_ITEM item1( WIRE_ENTRY_END, this, GetEnd() );
253  aItemList.push_back( item1 );
254 }
255 
256 
257 void SCH_BUS_BUS_ENTRY::GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList )
258 {
259  DANGLING_END_ITEM item( BUS_ENTRY_END, this, m_pos );
260  aItemList.push_back( item );
261 
262  DANGLING_END_ITEM item1( BUS_ENTRY_END, this, GetEnd() );
263  aItemList.push_back( item1 );
264 }
265 
266 
267 void SCH_BUS_ENTRY_BASE::Print( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset )
268 {
269  wxDC* DC = aSettings->GetPrintDC();
270  COLOR4D color = ( GetStrokeColor() == COLOR4D::UNSPECIFIED ) ?
271  aSettings->GetLayerColor( m_layer ) : GetStrokeColor();
272  wxPoint start = m_pos + aOffset;
273  wxPoint end = GetEnd() + aOffset;
274  int penWidth = ( GetPenWidth() == 0 ) ? aSettings->GetDefaultPenWidth() : GetPenWidth();
275 
277  {
278  GRLine( nullptr, DC, start.x, start.y, end.x, end.y, penWidth, color );
279  }
280  else
281  {
282  EDA_RECT clip( (wxPoint) start, wxSize( end.x - start.x, end.y - start.y ) );
283  clip.Normalize();
284 
285  double theta = atan2( end.y - start.y, end.x - start.x );
286  double strokes[] = { 1.0, dash_gap_len( penWidth ), 1.0, dash_gap_len( penWidth ) };
287 
288  switch( GetStrokeStyle() )
289  {
290  default:
292  strokes[0] = strokes[2] = dash_mark_len( penWidth );
293  break;
294  case PLOT_DASH_TYPE::DOT:
295  strokes[0] = strokes[2] = dot_mark_len( penWidth );
296  break;
298  strokes[0] = dash_mark_len( penWidth );
299  strokes[2] = dot_mark_len( penWidth );
300  break;
301  }
302 
303  for( size_t i = 0; i < 10000; ++i )
304  {
305  // Calculations MUST be done in doubles to keep from accumulating rounding
306  // errors as we go.
307  wxPoint next( start.x + strokes[ i % 4 ] * cos( theta ),
308  start.y + strokes[ i % 4 ] * sin( theta ) );
309 
310  // Drawing each segment can be done rounded to ints.
311  wxPoint segStart( KiROUND( start.x ), KiROUND( start.y ) );
312  wxPoint segEnd( KiROUND( next.x ), KiROUND( next.y ) );
313 
314  if( ClipLine( &clip, segStart.x, segStart.y, segEnd.x, segEnd.y ) )
315  break;
316  else if( i % 2 == 0 )
317  GRLine( nullptr, DC, segStart.x, segStart.y, segEnd.x, segEnd.y, penWidth, color );
318 
319  start = next;
320  }
321  }
322 }
323 
324 
326 {
327  MIRROR( m_pos.y, aCenter );
328  m_size.y = -m_size.y;
329 }
330 
331 
333 {
334  MIRROR( m_pos.x, aCenter );
335  m_size.x = -m_size.x;
336 }
337 
338 
339 void SCH_BUS_ENTRY_BASE::Rotate( const wxPoint& aCenter )
340 {
341  RotatePoint( &m_pos, aCenter, 900 );
342  RotatePoint( &m_size.x, &m_size.y, 900 );
343 }
344 
345 
346 bool SCH_BUS_WIRE_ENTRY::UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemList,
347  const SCH_SHEET_PATH* aPath )
348 {
349  bool previousStateStart = m_isDanglingStart;
350  bool previousStateEnd = m_isDanglingEnd;
351 
353 
354  // Store the connection type and state for the start (0) and end (1)
355  bool has_wire[2] = { false };
356  bool has_bus[2] = { false };
357 
358  for( unsigned ii = 0; ii < aItemList.size(); ii++ )
359  {
360  DANGLING_END_ITEM& item = aItemList[ii];
361 
362  if( item.GetItem() == this )
363  continue;
364 
365  switch( item.GetType() )
366  {
367  case WIRE_END:
368  if( m_pos == item.GetPosition() )
369  has_wire[0] = true;
370  else if( GetEnd() == item.GetPosition() )
371  has_wire[1] = true;
372 
373  break;
374 
375  case BUS_END:
376  {
377  // The bus has created 2 DANGLING_END_ITEMs, one per end.
378  DANGLING_END_ITEM& nextItem = aItemList[++ii];
379 
380  if( IsPointOnSegment( item.GetPosition(), nextItem.GetPosition(), m_pos ) )
381  has_bus[0] = true;
382  else if( IsPointOnSegment( item.GetPosition(), nextItem.GetPosition(), GetEnd() ) )
383  has_bus[1] = true;
384  }
385  break;
386 
387  default:
388  break;
389  }
390  }
391 
392  // A bus-wire entry is connected at both ends if it has a bus and a wire on its
393  // ends. Otherwise, we connect only one end (in the case of a wire-wire or bus-bus)
394  if( ( has_wire[0] && has_bus[1] ) || ( has_wire[1] && has_bus[0] ) )
396  else if( has_wire[0] || has_bus[0] )
397  m_isDanglingStart = false;
398  else if( has_wire[1] || has_bus[1] )
399  m_isDanglingEnd = false;
400 
401  return (previousStateStart != m_isDanglingStart) || (previousStateEnd != m_isDanglingEnd);
402 }
403 
404 
405 bool SCH_BUS_BUS_ENTRY::UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemList,
406  const SCH_SHEET_PATH* aPath )
407 {
408  bool previousStateStart = m_isDanglingStart;
409  bool previousStateEnd = m_isDanglingEnd;
410 
412 
413  for( unsigned ii = 0; ii < aItemList.size(); ii++ )
414  {
415  DANGLING_END_ITEM& item = aItemList[ii];
416 
417  if( item.GetItem() == this )
418  continue;
419 
420  switch( item.GetType() )
421  {
422  case BUS_END:
423  {
424  // The bus has created 2 DANGLING_END_ITEMs, one per end.
425  DANGLING_END_ITEM& nextItem = aItemList[++ii];
426 
427  if( IsPointOnSegment( item.GetPosition(), nextItem.GetPosition(), m_pos ) )
428  m_isDanglingStart = false;
429  if( IsPointOnSegment( item.GetPosition(), nextItem.GetPosition(), GetEnd() ) )
430  m_isDanglingEnd = false;
431  }
432  break;
433 
434  default:
435  break;
436  }
437  }
438 
439  return (previousStateStart != m_isDanglingStart) || (previousStateEnd != m_isDanglingEnd);
440 }
441 
442 
444 {
446 }
447 
448 
449 std::vector<wxPoint> SCH_BUS_ENTRY_BASE::GetConnectionPoints() const
450 {
451  return { m_pos, GetEnd() };
452 }
453 
454 
456 {
457  return wxString( _( "Bus to Wire Entry" ) );
458 }
459 
460 
462 {
463  return wxString( _( "Bus to Bus Entry" ) );
464 }
465 
466 
468 {
469  return BITMAPS::add_line2bus;
470 }
471 
472 
474 {
475  return BITMAPS::add_bus2bus;
476 }
477 
478 
479 bool SCH_BUS_ENTRY_BASE::HitTest( const wxPoint& aPosition, int aAccuracy ) const
480 {
481  // Insure minimum accuracy
482  if( aAccuracy == 0 )
483  aAccuracy = ( GetPenWidth() / 2 ) + 4;
484 
485  return TestSegmentHit( aPosition, m_pos, GetEnd(), aAccuracy );
486 }
487 
488 
489 bool SCH_BUS_ENTRY_BASE::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
490 {
491  EDA_RECT rect = aRect;
492 
493  rect.Inflate( aAccuracy );
494 
495  if( aContained )
496  return rect.Contains( GetBoundingBox() );
497 
498  return rect.Intersects( GetBoundingBox() );
499 }
500 
501 
502 void SCH_BUS_ENTRY_BASE::Plot( PLOTTER* aPlotter ) const
503 {
504  auto* settings = static_cast<KIGFX::SCH_RENDER_SETTINGS*>( aPlotter->RenderSettings() );
505 
506  COLOR4D color = ( GetStrokeColor() == COLOR4D::UNSPECIFIED ) ?
507  settings->GetLayerColor( m_layer ) : GetStrokeColor();
508  int penWidth = ( GetPenWidth() == 0 ) ? settings->GetDefaultPenWidth() : GetPenWidth();
509 
510  penWidth = std::max( penWidth, settings->GetMinPenWidth() );
511 
512  aPlotter->SetCurrentLineWidth( penWidth );
513  aPlotter->SetColor( color );
514  aPlotter->SetDash( GetStrokeStyle() );
515  aPlotter->MoveTo( m_pos );
516  aPlotter->FinishTo( GetEnd() );
517 }
518 
519 
521  std::vector<MSG_PANEL_ITEM>& aList )
522 {
523  wxString msg;
524 
525  switch( GetLayer() )
526  {
527  default:
528  case LAYER_WIRE: msg = _( "Wire" ); break;
529  case LAYER_BUS: msg = _( "Bus" ); break;
530  }
531 
532  aList.emplace_back( _( "Bus Entry Type" ), msg );
533 
534  SCH_CONNECTION* conn = nullptr;
535 
536  if( !IsConnectivityDirty() && dynamic_cast<SCH_EDIT_FRAME*>( aFrame ) )
537  conn = Connection();
538 
539  if( conn )
540  {
541  conn->AppendInfoToMsgPanel( aList );
542 
543  if( !conn->IsBus() )
544  {
545  NET_SETTINGS& netSettings = Schematic()->Prj().GetProjectFile().NetSettings();
546  wxString netname = conn->Name();
547  wxString netclassName = netSettings.m_NetClasses.GetDefaultPtr()->GetName();
548 
549  if( netSettings.m_NetClassAssignments.count( netname ) )
550  netclassName = netSettings.m_NetClassAssignments[ netname ];
551 
552  aList.emplace_back( _( "Assigned Netclass" ), netclassName );
553  }
554  }
555 }
556 
557 
558 bool SCH_BUS_ENTRY_BASE::operator <( const SCH_ITEM& aItem ) const
559 {
560  if( Type() != aItem.Type() )
561  return Type() < aItem.Type();
562 
563  auto symbol = static_cast<const SCH_BUS_ENTRY_BASE*>( &aItem );
564 
565  if( GetLayer() != symbol->GetLayer() )
566  return GetLayer() < symbol->GetLayer();
567 
568  if( GetPosition().x != symbol->GetPosition().x )
569  return GetPosition().x < symbol->GetPosition().x;
570 
571  if( GetPosition().y != symbol->GetPosition().y )
572  return GetPosition().y < symbol->GetPosition().y;
573 
574  if( GetEnd().x != symbol->GetEnd().x )
575  return GetEnd().x < symbol->GetEnd().x;
576 
577  return GetEnd().y < symbol->GetEnd().y;
578 }
579 
580 
582 {
583  // Don't generate connections between bus entries and buses, since there is
584  // a connectivity change at that point (e.g. A[7..0] to A7)
585  if( ( aItem->Type() == SCH_LINE_T ) &&
586  ( static_cast<const SCH_LINE*>( aItem )->GetLayer() == LAYER_BUS ) )
587  {
588  return false;
589  }
590 
591  // Same for bus junctions
592  if( ( aItem->Type() == SCH_JUNCTION_T ) &&
593  ( static_cast<const SCH_JUNCTION*>( aItem )->GetLayer() == LAYER_BUS_JUNCTION ) )
594  {
595  return false;
596  }
597 
598  // Don't generate connections between bus entries and bus labels that happen
599  // to land at the same point on the bus wire as this bus entry
600  if( ( aItem->Type() == SCH_LABEL_T ) &&
601  SCH_CONNECTION::IsBusLabel( static_cast<const SCH_LABEL*>( aItem )->GetText() ) )
602  {
603  return false;
604  }
605 
606  // Don't generate connections between two bus-wire entries
607  if( aItem->Type() == SCH_BUS_WIRE_ENTRY_T )
608  return false;
609 
610  return true;
611 }
void FinishTo(const wxPoint &pos)
Definition: plotter.h:273
CITER next(CITER it)
Definition: ptree.cpp:126
std::map< wxString, wxString > m_NetClassAssignments
Definition: net_settings.h:44
bool UpdateDanglingState(std::vector< DANGLING_END_ITEM > &aItemList, const SCH_SHEET_PATH *aPath=nullptr) override
Test the schematic item to aItemList to check if it's dangling state has changed.
void SetWidth(int aWidth)
Definition: sch_item.h:153
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
wxPoint GetPosition() const
Definition: sch_item.h:121
bool doIsConnected(const wxPoint &aPosition) const override
Provide the object specific test to see if it is connected to aPosition.
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
#define DEFAULT_SCH_ENTRY_SIZE
The default text size in mils. (can be changed in preference menu)
#define DEFAULT_WIRE_WIDTH_MILS
The default bus width in mils. (can be changed in preference menu)
SCH_ITEM * m_connected_bus_item
Pointer to the bus item (usually a bus wire) connected to this bus-wire entry, if it is connected to ...
void Print(const RENDER_SETTINGS *aSettings, const wxPoint &aOffset) override
Print a schematic item.
SCH_ITEM * m_connected_bus_items[2]
Pointer to the bus items (usually bus wires) connected to this bus-bus entry (either or both may be n...
SCH_BUS_BUS_ENTRY(const wxPoint &pos=wxPoint(0, 0), bool aFlipY=false)
static bool IsBusLabel(const wxString &aLabel)
Test if aLabel has a bus notation.
bool IsConnectable() const override
virtual PROJECT_FILE & GetProjectFile() const
Definition: project.h:145
SCH_BUS_ENTRY_BASE(KICAD_T aType, const wxPoint &pos=wxPoint(0, 0), bool aFlipY=false)
void Rotate(const wxPoint &aCenter) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
int color
Definition: DXF_plotter.cpp:57
void ViewGetLayers(int aLayers[], int &aCount) const override
Return the all the layers within the VIEW the object is painted on.
SCH_BUS_WIRE_ENTRY(const wxPoint &pos=wxPoint(0, 0), bool aFlipY=false)
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:104
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
bool IsPointOnSegment(const wxPoint &aSegStart, const wxPoint &aSegEnd, const wxPoint &aTestPoint)
Test if aTestPoint is on line defined by aSegStart and aSegEnd.
Definition: trigo.cpp:42
void SetOrigin(const wxPoint &pos)
Definition: eda_rect.h:130
NET_SETTINGS & NetSettings()
Definition: project_file.h:96
void SetPlotStyle(PLOT_DASH_TYPE aPlotStyle)
Definition: sch_item.h:156
wxPoint m_pos
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
wxSize m_size
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:229
The base class for create windows for drawing purpose.
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
bool Contains(const wxPoint &aPoint) const
Definition: eda_rect.cpp:57
void SwapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
bool ClipLine(const EDA_RECT *aClipBox, int &x1, int &y1, int &x2, int &y2)
Test if any part of a line falls within the bounds of a rectangle.
bool IsConnectivityDirty() const
Definition: sch_item.h:413
COLOR4D m_lastResolvedColor
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:77
void MIRROR(T &aPoint, const T &aMirrorRef)
Updates aPoint with the mirror of aPoint relative to the aMirrorRef.
Definition: mirror.h:40
SCH_CONNECTION * Connection(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieve the connection associated with this object in the given sheet.
Definition: sch_item.cpp:138
Base class for a bus or wire entry.
Definition: sch_bus_entry.h:42
virtual bool ConnectionPropagatesTo(const EDA_ITEM *aItem) const override
Return true if this item should propagate connection info to aItem.
PLOT_DASH_TYPE GetStrokeStyle() const
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
NETCLASSPTR NetClass(const SCH_SHEET_PATH *aSheet=nullptr) const
Definition: sch_item.cpp:158
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Return the text to display to be used in the selection clarification context menu when multiple items...
SCH_LAYER_ID m_layer
Definition: sch_item.h:487
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
bool IsDangling() const override
NETCLASSES m_NetClasses
Definition: net_settings.h:40
wxString Name(bool aIgnoreSheet=false) const
std::vector< wxPoint > GetConnectionPoints() const override
Add all the connection points for this item to aPoints.
void AppendInfoToMsgPanel(std::vector< MSG_PANEL_ITEM > &aList) const
Adds information about the connection object to aList.
void Plot(PLOTTER *aPlotter) const override
Plot the schematic item to aPlotter.
constexpr double dot_mark_len(double aLineWidth)
Dashed and dotted line patterns.
void SetEnd(int x, int y)
Definition: eda_rect.h:191
bool TestSegmentHit(const wxPoint &aRefPoint, const wxPoint &aStart, const wxPoint &aEnd, int aDist)
Test if aRefPoint is with aDistance on the line defined by aStart and aEnd.
Definition: trigo.cpp:129
PLOT_DASH_TYPE m_lastResolvedLineStyle
bool m_isDanglingStart
EDA_ITEM * GetItem() const
Definition: sch_item.h:122
PLOT_DASH_TYPE GetPlotStyle() const
Definition: sch_item.h:155
#define _(s)
NET_SETTINGS stores various net-related settings in a project context.
Definition: net_settings.h:32
void GRLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, const COLOR4D &Color, wxPenStyle aStyle)
Definition: gr_basic.cpp:197
void GetEndPoints(std::vector< DANGLING_END_ITEM > &aItemList) override
Add the schematic item end points to aItemList if the item has end points.
wxDC * GetPrintDC() const
int GetWidth() const
Definition: sch_item.h:152
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
constexpr double dash_gap_len(double aLineWidth)
NETCLASS * GetDefaultPtr() const
Definition: netclass.h:258
bool UpdateDanglingState(std::vector< DANGLING_END_ITEM > &aItemList, const SCH_SHEET_PATH *aPath=nullptr) override
Test the schematic item to aItemList to check if it's dangling state has changed.
STROKE_PARAMS m_stroke
virtual int GetPenWidth() const
Definition: sch_item.h:276
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
virtual void SetColor(const COLOR4D &color)=0
PLOT_DASH_TYPE
Dashed line types.
Definition: plotter.h:104
PROJECT & Prj() const override
Return a reference to the project this schematic is part of.
Definition: schematic.h:75
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition: sch_item.h:259
void MoveTo(const wxPoint &pos)
Definition: plotter.h:263
EDA_UNITS
Definition: eda_units.h:38
void Normalize()
Ensures that the height ant width are positive.
Definition: eda_rect.cpp:35
Base plotter engine class.
Definition: plotter.h:121
COLOR4D GetColor() const
Definition: sch_item.h:158
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
const wxString GetName() const
Definition: netclass.h:65
RENDER_SETTINGS * RenderSettings()
Definition: plotter.h:156
void GetEndPoints(std::vector< DANGLING_END_ITEM > &aItemList) override
Add the schematic item end points to aItemList if the item has end points.
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:32
int GetPenWidth() const override
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Return the text to display to be used in the selection clarification context menu when multiple items...
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
Handle the component boundary box.
Definition: eda_rect.h:42
bool m_isDanglingEnd
DANGLING_END_T GetType() const
Definition: sch_item.h:124
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:73
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:99
bool Intersects(const EDA_RECT &aRect) const
Test for a common area between rectangles.
Definition: eda_rect.cpp:150
int GetDefaultPenWidth() const
int m_lastResolvedWidth
void SetColor(const COLOR4D &aColor)
Definition: sch_item.h:159
COLOR4D GetStrokeColor() const
bool operator<(const SCH_ITEM &aItem) const override
Helper class used to store the state of schematic items that can be connected to other schematic item...
Definition: sch_item.h:79
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
bool IsBus() const
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:182
virtual void SetCurrentLineWidth(int width, void *aData=nullptr)=0
Set the line width for the next drawing.
constexpr double dash_mark_len(double aLineWidth)
virtual void SetDash(PLOT_DASH_TYPE dashed)=0
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Inflate the rectangle horizontally by dx and vertically by dy.
Definition: eda_rect.cpp:364
int GetPenWidth() const override
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112
wxPoint GetEnd() const
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103
wxPoint GetPosition() const override