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 "sch_painter.h"
41 
42 
43 SCH_BUS_ENTRY_BASE::SCH_BUS_ENTRY_BASE( KICAD_T aType, const wxPoint& pos, bool aFlipY ) :
44  SCH_ITEM( nullptr, aType )
45 {
46  m_pos = pos;
47  m_size.x = Mils2iu( DEFAULT_SCH_ENTRY_SIZE );
48  m_size.y = Mils2iu( DEFAULT_SCH_ENTRY_SIZE );
49 
50  m_stroke.SetWidth( 0 );
52  m_stroke.SetColor( COLOR4D::UNSPECIFIED );
53 
54  if( aFlipY )
55  m_size.y *= -1;
56 
58 }
59 
60 
61 SCH_BUS_WIRE_ENTRY::SCH_BUS_WIRE_ENTRY( const wxPoint& pos, bool aFlipY ) :
63 {
65  m_connected_bus_item = nullptr;
66 }
67 
68 
69 SCH_BUS_WIRE_ENTRY::SCH_BUS_WIRE_ENTRY( const wxPoint& pos, int aQuadrant ) :
71 {
72  switch( aQuadrant )
73  {
74  case 1: m_size.x *= 1; m_size.y *= -1; break;
75  case 2: m_size.x *= 1; m_size.y *= 1; break;
76  case 3: m_size.x *= -1; m_size.y *= 1; break;
77  case 4: m_size.x *= -1; m_size.y *= -1; break;
78  default: wxFAIL_MSG( "SCH_BUS_WIRE_ENTRY ctor: unexpected quadrant" );
79  }
80 
82  m_connected_bus_item = nullptr;
83 }
84 
85 
86 SCH_BUS_BUS_ENTRY::SCH_BUS_BUS_ENTRY( const wxPoint& pos, bool aFlipY ) :
88 {
90  m_connected_bus_items[0] = nullptr;
91  m_connected_bus_items[1] = nullptr;
92 }
93 
94 
96 {
97  return new SCH_BUS_WIRE_ENTRY( *this );
98 }
99 
100 
102 {
103  return new SCH_BUS_BUS_ENTRY( *this );
104 }
105 
106 
107 bool SCH_BUS_ENTRY_BASE::doIsConnected( const wxPoint& aPosition ) const
108 {
109  return ( m_pos == aPosition || GetEnd() == aPosition );
110 }
111 
112 
114 {
115  return wxPoint( m_pos.x + m_size.x, m_pos.y + m_size.y );
116 }
117 
118 
120 {
121  SCH_BUS_ENTRY_BASE* item = dynamic_cast<SCH_BUS_ENTRY_BASE*>( aItem );
122  wxCHECK_RET( item, wxT( "Cannot swap bus entry data with invalid item." ) );
123 
124  std::swap( m_pos, item->m_pos );
125  std::swap( m_size, item->m_size );
126  std::swap( m_stroke, item->m_stroke );
127 }
128 
129 
130 void SCH_BUS_ENTRY_BASE::ViewGetLayers( int aLayers[], int& aCount ) const
131 {
132  aCount = 2;
133  aLayers[0] = Type() == SCH_BUS_BUS_ENTRY_T ? LAYER_BUS : LAYER_WIRE;
134  aLayers[1] = LAYER_SELECTION_SHADOWS;
135 }
136 
137 
139 {
140  EDA_RECT box;
141 
142  box.SetOrigin( m_pos );
143  box.SetEnd( GetEnd() );
144 
145  box.Normalize();
146  box.Inflate( ( GetPenWidth() / 2 ) + 1 );
147 
148  return box;
149 }
150 
151 
153 {
154  NETCLASSPTR netclass = NetClass();
155 
156  if( netclass && netclass->GetSchematicColor() != COLOR4D::UNSPECIFIED )
157  return netclass->GetSchematicColor();
158 
159  return m_stroke.GetColor();
160 }
161 
162 
164 {
165  NETCLASSPTR netclass = NetClass();
166 
167  if( netclass )
168  return (PLOT_DASH_TYPE) netclass->GetLineStyle();
169 
170  return m_stroke.GetPlotStyle();
171 }
172 
173 
175 {
176  if( m_stroke.GetWidth() > 0 )
177  return m_stroke.GetWidth();
178 
179  NETCLASSPTR netclass = NetClass();
180 
181  if( netclass )
182  return netclass->GetWireWidth();
183 
184  if( Schematic() )
185  return std::max( Schematic()->Settings().m_DefaultWireThickness, 1 );
186 
187  return Mils2iu( DEFAULT_WIRE_WIDTH_MILS );
188 }
189 
190 
192 {
193  if( m_stroke.GetWidth() > 0 )
194  return m_stroke.GetWidth();
195 
196  NETCLASSPTR netclass = NetClass();
197 
198  if( netclass )
199  return netclass->GetBusWidth();
200 
201  if( Schematic() )
202  return std::max( Schematic()->Settings().m_DefaultBusThickness, 1 );
203 
204  return Mils2iu( DEFAULT_BUS_WIDTH_MILS );
205 }
206 
207 
208 void SCH_BUS_WIRE_ENTRY::GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList )
209 {
210  DANGLING_END_ITEM item( WIRE_ENTRY_END, this, m_pos );
211  aItemList.push_back( item );
212 
213  DANGLING_END_ITEM item1( WIRE_ENTRY_END, this, GetEnd() );
214  aItemList.push_back( item1 );
215 }
216 
217 
218 void SCH_BUS_BUS_ENTRY::GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList )
219 {
220  DANGLING_END_ITEM item( BUS_ENTRY_END, this, m_pos );
221  aItemList.push_back( item );
222 
223  DANGLING_END_ITEM item1( BUS_ENTRY_END, this, GetEnd() );
224  aItemList.push_back( item1 );
225 }
226 
227 
228 void SCH_BUS_ENTRY_BASE::Print( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset )
229 {
230  wxDC* DC = aSettings->GetPrintDC();
231  COLOR4D color = ( GetStrokeColor() == COLOR4D::UNSPECIFIED ) ?
232  aSettings->GetLayerColor( m_layer ) : GetStrokeColor();
233  wxPoint start = m_pos + aOffset;
234  wxPoint end = GetEnd() + aOffset;
235  int penWidth = ( GetPenWidth() == 0 ) ? aSettings->GetDefaultPenWidth() : GetPenWidth();
236 
238  {
239  GRLine( nullptr, DC, start.x, start.y, end.x, end.y, penWidth, color );
240  }
241  else
242  {
243  EDA_RECT clip( (wxPoint) start, wxSize( end.x - start.x, end.y - start.y ) );
244  clip.Normalize();
245 
246  double theta = atan2( end.y - start.y, end.x - start.x );
247  double strokes[] = { 1.0, dash_gap_len( penWidth ), 1.0, dash_gap_len( penWidth ) };
248 
249  switch( GetStrokeStyle() )
250  {
251  default:
253  strokes[0] = strokes[2] = dash_mark_len( penWidth );
254  break;
255  case PLOT_DASH_TYPE::DOT:
256  strokes[0] = strokes[2] = dot_mark_len( penWidth );
257  break;
259  strokes[0] = dash_mark_len( penWidth );
260  strokes[2] = dot_mark_len( penWidth );
261  break;
262  }
263 
264  for( size_t i = 0; i < 10000; ++i )
265  {
266  // Calculations MUST be done in doubles to keep from accumulating rounding
267  // errors as we go.
268  wxPoint next( start.x + strokes[ i % 4 ] * cos( theta ),
269  start.y + strokes[ i % 4 ] * sin( theta ) );
270 
271  // Drawing each segment can be done rounded to ints.
272  wxPoint segStart( KiROUND( start.x ), KiROUND( start.y ) );
273  wxPoint segEnd( KiROUND( next.x ), KiROUND( next.y ) );
274 
275  if( ClipLine( &clip, segStart.x, segStart.y, segEnd.x, segEnd.y ) )
276  break;
277  else if( i % 2 == 0 )
278  GRLine( nullptr, DC, segStart.x, segStart.y, segEnd.x, segEnd.y, penWidth, color );
279 
280  start = next;
281  }
282  }
283 }
284 
285 
287 {
288  MIRROR( m_pos.y, aCenter );
289  m_size.y = -m_size.y;
290 }
291 
292 
294 {
295  MIRROR( m_pos.x, aCenter );
296  m_size.x = -m_size.x;
297 }
298 
299 
300 void SCH_BUS_ENTRY_BASE::Rotate( const wxPoint& aCenter )
301 {
302  RotatePoint( &m_pos, aCenter, 900 );
303  RotatePoint( &m_size.x, &m_size.y, 900 );
304 }
305 
306 
307 bool SCH_BUS_WIRE_ENTRY::UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemList,
308  const SCH_SHEET_PATH* aPath )
309 {
310  bool previousStateStart = m_isDanglingStart;
311  bool previousStateEnd = m_isDanglingEnd;
312 
314 
315  // Store the connection type and state for the start (0) and end (1)
316  bool has_wire[2] = { false };
317  bool has_bus[2] = { false };
318 
319  for( unsigned ii = 0; ii < aItemList.size(); ii++ )
320  {
321  DANGLING_END_ITEM& item = aItemList[ii];
322 
323  if( item.GetItem() == this )
324  continue;
325 
326  switch( item.GetType() )
327  {
328  case WIRE_END:
329  if( m_pos == item.GetPosition() )
330  has_wire[0] = true;
331  else if( GetEnd() == item.GetPosition() )
332  has_wire[1] = true;
333 
334  break;
335 
336  case BUS_END:
337  {
338  // The bus has created 2 DANGLING_END_ITEMs, one per end.
339  DANGLING_END_ITEM& nextItem = aItemList[++ii];
340 
341  if( IsPointOnSegment( item.GetPosition(), nextItem.GetPosition(), m_pos ) )
342  has_bus[0] = true;
343  else if( IsPointOnSegment( item.GetPosition(), nextItem.GetPosition(), GetEnd() ) )
344  has_bus[1] = true;
345  }
346  break;
347 
348  default:
349  break;
350  }
351  }
352 
353  // A bus-wire entry is connected at both ends if it has a bus and a wire on its
354  // ends. Otherwise, we connect only one end (in the case of a wire-wire or bus-bus)
355  if( ( has_wire[0] && has_bus[1] ) || ( has_wire[1] && has_bus[0] ) )
357  else if( has_wire[0] || has_bus[0] )
358  m_isDanglingStart = false;
359  else if( has_wire[1] || has_bus[1] )
360  m_isDanglingEnd = false;
361 
362  return (previousStateStart != m_isDanglingStart) || (previousStateEnd != m_isDanglingEnd);
363 }
364 
365 
366 bool SCH_BUS_BUS_ENTRY::UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemList,
367  const SCH_SHEET_PATH* aPath )
368 {
369  bool previousStateStart = m_isDanglingStart;
370  bool previousStateEnd = m_isDanglingEnd;
371 
373 
374  for( unsigned ii = 0; ii < aItemList.size(); ii++ )
375  {
376  DANGLING_END_ITEM& item = aItemList[ii];
377 
378  if( item.GetItem() == this )
379  continue;
380 
381  switch( item.GetType() )
382  {
383  case BUS_END:
384  {
385  // The bus has created 2 DANGLING_END_ITEMs, one per end.
386  DANGLING_END_ITEM& nextItem = aItemList[++ii];
387 
388  if( IsPointOnSegment( item.GetPosition(), nextItem.GetPosition(), m_pos ) )
389  m_isDanglingStart = false;
390  if( IsPointOnSegment( item.GetPosition(), nextItem.GetPosition(), GetEnd() ) )
391  m_isDanglingEnd = false;
392  }
393  break;
394 
395  default:
396  break;
397  }
398  }
399 
400  return (previousStateStart != m_isDanglingStart) || (previousStateEnd != m_isDanglingEnd);
401 }
402 
403 
405 {
407 }
408 
409 
410 std::vector<wxPoint> SCH_BUS_ENTRY_BASE::GetConnectionPoints() const
411 {
412  return { m_pos, GetEnd() };
413 }
414 
415 
417 {
418  return wxString( _( "Bus to Wire Entry" ) );
419 }
420 
421 
423 {
424  return wxString( _( "Bus to Bus Entry" ) );
425 }
426 
427 
429 {
430  return BITMAPS::add_line2bus;
431 }
432 
433 
435 {
436  return BITMAPS::add_bus2bus;
437 }
438 
439 
440 bool SCH_BUS_ENTRY_BASE::HitTest( const wxPoint& aPosition, int aAccuracy ) const
441 {
442  // Insure minimum accuracy
443  if( aAccuracy == 0 )
444  aAccuracy = ( GetPenWidth() / 2 ) + 4;
445 
446  return TestSegmentHit( aPosition, m_pos, GetEnd(), aAccuracy );
447 }
448 
449 
450 bool SCH_BUS_ENTRY_BASE::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
451 {
452  EDA_RECT rect = aRect;
453 
454  rect.Inflate( aAccuracy );
455 
456  if( aContained )
457  return rect.Contains( GetBoundingBox() );
458 
459  return rect.Intersects( GetBoundingBox() );
460 }
461 
462 
463 void SCH_BUS_ENTRY_BASE::Plot( PLOTTER* aPlotter ) const
464 {
465  auto* settings = static_cast<KIGFX::SCH_RENDER_SETTINGS*>( aPlotter->RenderSettings() );
466 
467  COLOR4D color = ( GetStrokeColor() == COLOR4D::UNSPECIFIED ) ?
468  settings->GetLayerColor( m_layer ) : GetStrokeColor();
469  int penWidth = ( GetPenWidth() == 0 ) ? settings->GetDefaultPenWidth() : GetPenWidth();
470 
471  penWidth = std::max( penWidth, settings->GetMinPenWidth() );
472 
473  aPlotter->SetCurrentLineWidth( penWidth );
474  aPlotter->SetColor( color );
475  aPlotter->SetDash( GetStrokeStyle() );
476  aPlotter->MoveTo( m_pos );
477  aPlotter->FinishTo( GetEnd() );
478 }
479 
480 
482  std::vector<MSG_PANEL_ITEM>& aList )
483 {
484  wxString msg;
485 
486  switch( GetLayer() )
487  {
488  default:
489  case LAYER_WIRE: msg = _( "Wire" ); break;
490  case LAYER_BUS: msg = _( "Bus" ); break;
491  }
492 
493  aList.emplace_back( _( "Bus Entry Type" ), msg );
494 
495  SCH_CONNECTION* conn = dynamic_cast<SCH_EDIT_FRAME*>( aFrame ) ? Connection() : nullptr;
496 
497  if( conn )
498  {
499  conn->AppendInfoToMsgPanel( aList );
500 
501  if( !conn->IsBus() )
502  {
503  NET_SETTINGS& netSettings = Schematic()->Prj().GetProjectFile().NetSettings();
504  wxString netname = conn->Name();
505  wxString netclassName = netSettings.m_NetClasses.GetDefaultPtr()->GetName();
506 
507  if( netSettings.m_NetClassAssignments.count( netname ) )
508  netclassName = netSettings.m_NetClassAssignments[ netname ];
509 
510  aList.emplace_back( _( "Assigned Netclass" ), netclassName );
511  }
512  }
513 }
514 
515 
516 bool SCH_BUS_ENTRY_BASE::operator <( const SCH_ITEM& aItem ) const
517 {
518  if( Type() != aItem.Type() )
519  return Type() < aItem.Type();
520 
521  auto symbol = static_cast<const SCH_BUS_ENTRY_BASE*>( &aItem );
522 
523  if( GetLayer() != symbol->GetLayer() )
524  return GetLayer() < symbol->GetLayer();
525 
526  if( GetPosition().x != symbol->GetPosition().x )
527  return GetPosition().x < symbol->GetPosition().x;
528 
529  if( GetPosition().y != symbol->GetPosition().y )
530  return GetPosition().y < symbol->GetPosition().y;
531 
532  if( GetEnd().x != symbol->GetEnd().x )
533  return GetEnd().x < symbol->GetEnd().x;
534 
535  return GetEnd().y < symbol->GetEnd().y;
536 }
537 
538 
540 {
541  // Don't generate connections between bus entries and buses, since there is
542  // a connectivity change at that point (e.g. A[7..0] to A7)
543  if( ( aItem->Type() == SCH_LINE_T ) &&
544  ( static_cast<const SCH_LINE*>( aItem )->GetLayer() == LAYER_BUS ) )
545  {
546  return false;
547  }
548 
549  // Same for bus junctions
550  if( ( aItem->Type() == SCH_JUNCTION_T ) &&
551  ( static_cast<const SCH_JUNCTION*>( aItem )->GetLayer() == LAYER_BUS_JUNCTION ) )
552  {
553  return false;
554  }
555 
556  // Don't generate connections between bus entries and bus labels that happen
557  // to land at the same point on the bus wire as this bus entry
558  if( ( aItem->Type() == SCH_LABEL_T ) &&
559  SCH_CONNECTION::IsBusLabel( static_cast<const SCH_LABEL*>( aItem )->GetText() ) )
560  {
561  return false;
562  }
563 
564  // Don't generate connections between two bus-wire entries
565  if( aItem->Type() == SCH_BUS_WIRE_ENTRY_T )
566  return false;
567 
568  return true;
569 }
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.
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:97
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:121
NET_SETTINGS & NetSettings()
Definition: project_file.h:94
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.
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:131
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:145
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:481
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:182
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
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:212
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:274
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:257
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
#define DEFAULT_BUS_WIDTH_MILS
The default noconnect size in mils.
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:100
bool Intersects(const EDA_RECT &aRect) const
Test for a common area between rectangles.
Definition: eda_rect.cpp:150
int GetDefaultPenWidth() const
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 contained within or on the bounding box of an 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:113
wxPoint GetEnd() const
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103
wxPoint GetPosition() const override