95 std::list<const SCH_LINE *> checkedLines;
96 checkedLines.push_back(
this);
102 std::list<const SCH_LINE *> &checkedLines,
109 if( std::find(checkedLines.begin(), checkedLines.end(), connected ) == checkedLines.end() )
112 checkedLines.push_back( connectedLine );
117 if( !netName.IsEmpty() )
172void SCH_LINE::Show(
int nestLevel, std::ostream& os )
const
174 NestedSpace( nestLevel, os ) <<
'<' <<
GetClass().Lower().mb_str()
175 <<
" layer=\"" <<
m_layer <<
'"'
177 <<
'"' <<
" endIsDangling=\""
179 <<
" <start" <<
m_start <<
"/>"
180 <<
" <end" <<
m_end <<
"/>" <<
"</"
181 <<
GetClass().Lower().mb_str() <<
">\n";
199 constexpr double HIDE = std::numeric_limits<double>::max();
200 constexpr double SHOW = 0.0;
255 if( newColor == COLOR4D::UNSPECIFIED )
362 if(
color == COLOR4D::UNSPECIFIED )
437 vec =
m_end - aPoint;
449 if( aPoint ==
m_end )
452 vec =
m_end - aPoint;
460 wxCHECK_MSG( aLine !=
nullptr && aLine->
Type() ==
SCH_LINE_T,
false,
461 wxT(
"Cannot test line segment for overlap." ) );
467 return !( (
long long) firstSeg.
x * secondSeg.
y - (
long long) firstSeg.
y * secondSeg.
x );
477 return lhs.
y < rhs.y;
479 return lhs.
x < rhs.x;
482 wxCHECK_MSG( aLine !=
nullptr && aLine->
Type() ==
SCH_LINE_T,
nullptr,
483 wxT(
"Cannot test line segment for overlap." ) );
495 if( leftmost_start != std::min( { leftmost_start, leftmost_end }, less ) )
496 std::swap( leftmost_start, leftmost_end );
497 if( rightmost_start != std::min( { rightmost_start, rightmost_end }, less ) )
498 std::swap( rightmost_start, rightmost_end );
504 if( less( rightmost_start, leftmost_start ) )
506 std::swap( leftmost_start, rightmost_start );
507 std::swap( leftmost_end, rightmost_end );
510 VECTOR2I other_start = rightmost_start;
513 if( less( rightmost_end, leftmost_end ) )
515 rightmost_start = leftmost_start;
516 rightmost_end = leftmost_end;
520 if( less( leftmost_end, other_start ) )
526 if( ( leftmost_start == other_start ) && ( leftmost_end == other_end ) )
539 bool colinear =
false;
542 if( ( leftmost_start.
y == leftmost_end.
y ) &&
543 ( other_start.
y == other_end.
y ) )
545 colinear = ( leftmost_start.
y == other_start.
y );
547 else if( ( leftmost_start.
x == leftmost_end.
x ) &&
548 ( other_start.
x == other_end.
x ) )
550 colinear = ( leftmost_start.
x == other_start.
x );
558 long long dx = leftmost_end.
x - leftmost_start.
x;
559 long long dy = leftmost_end.
y - leftmost_start.
y;
560 colinear = ( ( ( other_start.
y - leftmost_start.
y ) * dx ==
561 ( other_start.
x - leftmost_start.
x ) * dy ) &&
562 ( ( other_end.
y - leftmost_start.
y ) * dx ==
563 ( other_end.
x - leftmost_start.
x ) * dy ) );
572 bool touching = leftmost_end == rightmost_start;
574 if( touching && aCheckJunctions && aScreen->
IsJunction( leftmost_end ) )
578 leftmost_end = rightmost_end;
626 if( item.GetItem() ==
this )
632 if(
m_start == item.GetPosition() )
635 if(
m_end == item.GetPosition() )
668 switch( aItem->
Type() )
687 switch( aItem->
Type() )
715 switch( aItem->
Type() )
732 aPoints.push_back(
m_end );
744 case LAYER_WIRE: txtfmt =
_(
"Vertical Wire, length %s" );
break;
745 case LAYER_BUS: txtfmt =
_(
"Vertical Bus, length %s" );
break;
746 default: txtfmt =
_(
"Vertical Graphic Line, length %s" );
break;
753 case LAYER_WIRE: txtfmt =
_(
"Horizontal Wire, length %s" );
break;
754 case LAYER_BUS: txtfmt =
_(
"Horizontal Bus, length %s" );
break;
755 default: txtfmt =
_(
"Horizontal Graphic Line, length %s" );
break;
762 case LAYER_WIRE: txtfmt =
_(
"Wire, length %s" );
break;
763 case LAYER_BUS: txtfmt =
_(
"Bus, length %s" );
break;
764 default: txtfmt =
_(
"Graphic Line, length %s" );
break;
816 aAccuracy =
abs( aAccuracy );
868 int penWidth = std::max(
GetPenWidth(), settings->GetMinPenWidth() );
871 if(
color == COLOR4D::UNSPECIFIED )
885 std::vector<wxString> properties;
895 connection->Name() ) );
898 _(
"Resolved netclass" ),
906 for( std::shared_ptr<SCH_CONNECTION>& member : connection->Members() )
907 properties.emplace_back( wxT(
"!" ) + member->Name() );
912 if( !properties.empty() )
932 default: msg =
_(
"Graphical" );
break;
935 aList.emplace_back(
_(
"Line Type" ), msg );
940 aList.emplace_back(
_(
"Line Style" ),
_(
"from netclass" ) );
955 aList.emplace_back(
_(
"Resolved Netclass" ),
constexpr EDA_IU_SCALE schIUScale
BITMAPS
A list of all bitmap identifiers.
bool Intersects(const BOX2< Vec > &aRect) const
bool Contains(const Vec &aPoint) const
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Helper class used to store the state of schematic items that can be connected to other schematic item...
The base class for create windows for drawing purpose.
A base class for most all the KiCad significant classes used in schematics and boards.
KICAD_T Type() const
Returns the type of object.
A color representation with 4 components: red, green, blue, alpha.
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
int GetDefaultPenWidth() const
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
wxDC * GetPrintDC() const
Store schematic specific render settings.
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Base plotter engine class.
virtual void SetDash(int aLineWidth, PLOT_DASH_TYPE aLineStyle)=0
void MoveTo(const VECTOR2I &pos)
void FinishTo(const VECTOR2I &pos)
RENDER_SETTINGS * RenderSettings()
virtual void SetCurrentLineWidth(int width, void *aData=nullptr)=0
Set the line width for the next drawing.
virtual void HyperlinkMenu(const BOX2I &aBox, const std::vector< wxString > &aDestURLs)
Create a clickable hyperlink menu with a rectangular click area.
virtual void SetColor(const COLOR4D &color)=0
Holds all the data relating to one schematic.
SCHEMATIC_SETTINGS & Settings() const
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
void AppendInfoToMsgPanel(std::vector< MSG_PANEL_ITEM > &aList) const
Adds information about the connection object to aList.
Schematic editor (Eeschema) main window.
Base class for any item which can be embedded within the SCHEMATIC container class,...
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
SCH_ITEM_SET & ConnectedItems(const SCH_SHEET_PATH &aPath)
Retrieve the set of items connected to this item on the given sheet.
std::shared_ptr< NETCLASS > GetEffectiveNetClass(const SCH_SHEET_PATH *aSheet=nullptr) const
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
void SetConnectivityDirty(bool aDirty=true)
bool IsConnectivityDirty() const
SCH_CONNECTION * Connection(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieve the connection associated with this object in the given sheet.
SCH_ITEM * Duplicate(bool doClone=false) const
Routine to create a new copy of given item.
Segment description base class to describe items which have 2 end points (track, wire,...
int GetPenWidth() const override
void Rotate(const VECTOR2I &aCenter) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
bool doIsConnected(const VECTOR2I &aPosition) const override
Provide the object specific test to see if it is connected to aPosition.
void GetEndPoints(std::vector< DANGLING_END_ITEM > &aItemList) override
Add the schematic item end points to aItemList if the item has end points.
void SetStartPoint(const VECTOR2I &aPosition)
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
bool m_startIsDangling
True if start point is not connected.
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
void SetPosition(const VECTOR2I &aPosition) override
std::vector< VECTOR2I > GetConnectionPoints() const override
Add all the connection points for this item to aPoints.
int GetReverseAngleFrom(const VECTOR2I &aPoint) const
double ViewGetLOD(int aLayer, KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
SCH_LINE(const VECTOR2I &pos=VECTOR2I(0, 0), int layer=LAYER_NOTES)
bool IsWire() const
Return true if the line is a wire.
void RotateEnd(const VECTOR2I &aCenter)
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
void ViewGetLayers(int aLayers[], int &aCount) const override
Return the layers the item is drawn on (which may be more than its "home" layer)
void SetLineColor(const COLOR4D &aColor)
bool CanConnect(const SCH_ITEM *aItem) const override
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const override
Return a user-visible description string of this item.
bool IsParallel(const SCH_LINE *aLine) const
void SetLineWidth(const int aSize)
void RotateStart(const VECTOR2I &aCenter)
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
int GetAngleFrom(const VECTOR2I &aPoint) const
void GetSelectedPoints(std::vector< VECTOR2I > &aPoints) const
COLOR4D m_lastResolvedColor
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.
wxString m_operatingPoint
wxString GetClass() const override
Return the class name.
VECTOR2I GetEndPoint() const
VECTOR2I GetStartPoint() const
bool ConnectionPropagatesTo(const EDA_ITEM *aItem) const override
Return true if this item should propagate connection info to aItem.
SCH_LINE * MergeOverlap(SCH_SCREEN *aScreen, SCH_LINE *aLine, bool aCheckJunctions)
Check line against aLine to see if it overlaps and merge if it does.
VECTOR2I m_start
Line start point.
bool IsBus() const
Return true if the line is a bus.
VECTOR2I m_end
Line end point.
PLOT_DASH_TYPE m_lastResolvedLineStyle
void Move(const VECTOR2I &aMoveVector) override
Move the item by aMoveVector to a new position.
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 SetLineStyle(const PLOT_DASH_TYPE aStyle)
PLOT_DASH_TYPE GetLineStyle() const
void MoveEnd(const VECTOR2I &aMoveVector)
STROKE_PARAMS m_stroke
Line stroke properties.
bool m_endIsDangling
True if end point is not connected.
void SwapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
bool IsConnectable() const override
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
bool operator<(const SCH_ITEM &aItem) const override
void Print(const RENDER_SETTINGS *aSettings, const VECTOR2I &aOffset) override
Print a schematic item.
wxString GetNetname(const SCH_SHEET_PATH &aSheet)
This function travel though all the connected wire segments to look for connected labels.
bool IsEndPoint(const VECTOR2I &aPoint) const
void Plot(PLOTTER *aPlotter, bool aBackground) const override
Plot the schematic item to aPlotter.
bool IsGraphicLine() const
Return if the line is a graphic (non electrical line)
COLOR4D GetLineColor() const
Returns COLOR4D::UNSPECIFIED if a custom color hasn't been set for this line.
void MoveStart(const VECTOR2I &aMoveVector)
PLOT_DASH_TYPE GetEffectiveLineStyle() const
SCH_LINE * BreakAt(const VECTOR2I &aPoint)
Break this segment into two at the specified point.
wxString FindWireSegmentNetNameRecursive(SCH_LINE *line, std::list< const SCH_LINE * > &checkedLines, const SCH_SHEET_PATH &aSheet) const
Recursively called function to travel through the connected wires and find a connected net name label...
void SetEndPoint(const VECTOR2I &aPosition)
bool IsJunction(const VECTOR2I &aPosition) const
Test if a junction is required for the items at aPosition on the screen.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
void SetWidth(int aWidth)
void SetColor(const KIGFX::COLOR4D &aColor)
void GetMsgPanelInfo(UNITS_PROVIDER *aUnitsProvider, std::vector< MSG_PANEL_ITEM > &aList, bool aIncludeStyle=true, bool aIncludeWidth=true)
static void Stroke(const SHAPE *aShape, PLOT_DASH_TYPE aLineStyle, int aWidth, const KIGFX::RENDER_SETTINGS *aRenderSettings, std::function< void(const VECTOR2I &a, const VECTOR2I &b)> aStroker)
KIGFX::COLOR4D GetColor() const
PLOT_DASH_TYPE GetPlotStyle() const
void SetPlotStyle(PLOT_DASH_TYPE aPlotStyle)
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
A lower-precision version of StringFromValue().
#define DEFAULT_BUS_WIDTH_MILS
The default noconnect size in mils.
#define DEFAULT_WIRE_WIDTH_MILS
The default bus width in mils. (can be changed in preference menu)
#define DEFAULT_LINE_WIDTH_MILS
The default wire width in mils. (can be changed in preference menu)
static constexpr EDA_ANGLE & ANGLE_90
#define STRUCT_DELETED
flag indication structures to be erased
#define ENDPOINT
ends. (Used to support dragging.)
#define SKIP_STRUCT
flag indicating that the structure should be ignored
#define STARTPOINT
When a line is selected, these flags indicate which.
void GRLine(wxDC *DC, int x1, int y1, int x2, int y2, int width, const COLOR4D &Color, wxPenStyle aStyle)
@ LAYER_SELECTION_SHADOWS
void MIRROR(T &aPoint, const T &aMirrorRef)
Updates aPoint with the mirror of aPoint relative to the aMirrorRef.
wxString GetText(EDA_UNITS aUnits, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Get the units string for a given units type.
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
Plot settings, and plotting engines (PostScript, Gerber, HPGL and DXF)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
wxString UnescapeString(const wxString &aSource)
PLOT_DASH_TYPE
Dashed line types.
constexpr int MilsToIU(int mils) const
constexpr int mmToIU(double mm) const
bool TestSegmentHit(const VECTOR2I &aRefPoint, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aDist)
Test if aRefPoint is with aDistance on the line defined by aStart and aEnd.
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
double GetLineLength(const VECTOR2I &aPointA, const VECTOR2I &aPointB)
Return the length of a line segment defined by aPointA and aPointB.
double EuclideanNorm(const VECTOR2I &vector)
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".