101 [aStyleName](
const auto& it ) {
return it.second == aStyleName; } );
104 id = resultIt->first;
112 if( aOffset != wxPoint( 0, 0 ) )
123 if( aOffset != wxPoint( 0, 0 ) )
133 if( aOffset != wxPoint( 0, 0 ) )
143 void SCH_LINE::Show(
int nestLevel, std::ostream& os )
const 145 NestedSpace( nestLevel, os ) <<
'<' <<
GetClass().Lower().mb_str()
146 <<
" layer=\"" <<
m_layer <<
'"' 148 <<
'"' <<
" endIsDangling=\"" 150 <<
" <start" <<
m_start <<
"/>" 151 <<
" <end" <<
m_end <<
"/>" <<
"</" 152 <<
GetClass().Lower().mb_str() <<
">\n";
174 int xmax = std::max(
m_start.x,
m_end.x ) + width + extra;
175 int ymax = std::max(
m_start.y,
m_end.y ) + width + extra;
177 EDA_RECT ret( wxPoint( xmin, ymin ), wxSize( xmax - xmin, ymax - ymin ) );
199 if( newColor == COLOR4D::UNSPECIFIED )
218 return netclass->GetSchematicColor();
235 SetLineStyle( static_cast<PLOT_DASH_TYPE>( aStyleId ) );
297 return netclass->GetWireWidth();
309 return netclass->GetBusWidth();
324 if(
color == COLOR4D::UNSPECIFIED )
334 GRLine(
nullptr, DC, start.x, start.y, end.x, end.y, penWidth,
color );
338 EDA_RECT clip( (wxPoint) start, wxSize( end.x - start.x, end.y - start.y ) );
341 double theta = atan2( end.y - start.y, end.x - start.x );
359 for(
size_t i = 0; i < 10000; ++i )
363 wxPoint
next( start.x + strokes[ i % 4 ] * cos( theta ),
364 start.y + strokes[ i % 4 ] * sin( theta ) );
370 if(
ClipLine( &clip, segStart.x, segStart.y, segEnd.x, segEnd.y ) )
372 else if( i % 2 == 0 )
373 GRLine(
nullptr, DC, segStart.x, segStart.y, segEnd.x, segEnd.y, penWidth,
color );
420 first =
m_end - aPosition;
421 else if(
m_end == aPosition )
426 if( aLine->
m_start == aPosition )
427 second = aLine->
m_end - aPosition;
428 else if( aLine->
m_end == aPosition )
429 second = aLine->
m_start - aPosition;
433 return (
sign( first.x ) ==
sign( second.x ) &&
sign( first.y ) ==
sign( second.y ) );
440 wxT(
"Cannot test line segment for overlap." ) );
446 return !( (
long long) firstSeg.x * secondSeg.y - (
long long) firstSeg.y * secondSeg.x );
452 auto less = [](
const wxPoint& lhs,
const wxPoint& rhs ) ->
bool 455 return lhs.y < rhs.y;
457 return lhs.x < rhs.x;
461 wxT(
"Cannot test line segment for overlap." ) );
466 auto leftmost_start = aLine->
m_start;
467 auto leftmost_end = aLine->
m_end;
469 auto rightmost_start =
m_start;
470 auto rightmost_end =
m_end;
473 if( leftmost_start != std::min( { leftmost_start, leftmost_end }, less ) )
474 std::swap( leftmost_start, leftmost_end );
475 if( rightmost_start != std::min( { rightmost_start, rightmost_end }, less ) )
476 std::swap( rightmost_start, rightmost_end );
482 if( less( rightmost_start, leftmost_start ) )
484 std::swap( leftmost_start, rightmost_start );
485 std::swap( leftmost_end, rightmost_end );
488 wxPoint other_start = rightmost_start;
489 wxPoint other_end = rightmost_end;
491 if( less( rightmost_end, leftmost_end ) )
493 rightmost_start = leftmost_start;
494 rightmost_end = leftmost_end;
498 if( less( leftmost_end, other_start ) )
504 if( ( leftmost_start == other_start ) && ( leftmost_end == other_end ) )
507 ret->SetStartPoint( leftmost_start );
508 ret->SetEndPoint( leftmost_end );
516 bool colinear =
false;
519 if( ( leftmost_start.y == leftmost_end.y ) &&
520 ( other_start.y == other_end.y ) )
522 colinear = ( leftmost_start.y == other_start.y );
524 else if( ( leftmost_start.x == leftmost_end.x ) &&
525 ( other_start.x == other_end.x ) )
527 colinear = ( leftmost_start.x == other_start.x );
535 long long dx = leftmost_end.x - leftmost_start.x;
536 long long dy = leftmost_end.y - leftmost_start.y;
537 colinear = ( ( ( other_start.y - leftmost_start.y ) * dx ==
538 ( other_start.x - leftmost_start.x ) * dy ) &&
539 ( ( other_end.y - leftmost_start.y ) * dx ==
540 ( other_end.x - leftmost_start.x ) * dy ) );
549 bool touching = leftmost_end == rightmost_start;
551 if( touching && aCheckJunctions && aScreen->
IsJunctionNeeded( leftmost_end ) )
555 leftmost_end = rightmost_end;
558 ret->SetStartPoint( leftmost_start );
559 ret->SetEndPoint( leftmost_end );
589 aItemList.push_back( item );
592 aItemList.push_back( item1 );
606 if( item.GetItem() == this )
614 || item.GetType() ==
PIN_END ) )
619 if(
m_start == item.GetPosition() )
622 if(
m_end == item.GetPosition() )
653 switch( aItem->
Type() )
671 switch( aItem->
Type() )
702 aPoints.push_back(
m_end );
708 wxString txtfmt, orient;
714 case LAYER_WIRE: txtfmt =
_(
"Vertical Wire, length %s" );
break;
715 case LAYER_BUS: txtfmt =
_(
"Vertical Bus, length %s" );
break;
716 default: txtfmt =
_(
"Vertical Graphic Line, length %s" );
break;
723 case LAYER_WIRE: txtfmt =
_(
"Horizontal Wire, length %s" );
break;
724 case LAYER_BUS: txtfmt =
_(
"Horizontal Bus, length %s" );
break;
725 default: txtfmt =
_(
"Horizontal Graphic Line, length %s" );
break;
732 case LAYER_WIRE: txtfmt =
_(
"Wire, length %s" );
break;
733 case LAYER_BUS: txtfmt =
_(
"Bus, length %s" );
break;
734 default: txtfmt =
_(
"Graphic Line, length %s" );
break;
759 auto line = static_cast<const SCH_LINE*>( &aItem );
761 if(
GetLayer() != line->GetLayer() )
762 return GetLayer() < line->GetLayer();
831 auto* settings = static_cast<KIGFX::SCH_RENDER_SETTINGS*>( aPlotter->
RenderSettings() );
835 if(
color == COLOR4D::UNSPECIFIED )
842 case LAYER_WIRE: penWidth = settings->m_DefaultWireThickness;
break;
843 case LAYER_BUS: penWidth = settings->m_DefaultBusThickness;
break;
850 penWidth = std::max( penWidth, settings->GetMinPenWidth() );
877 default: msg =
_(
"Graphical" );
break;
883 msg =
_(
"from netclass" );
895 conn->AppendInfoToMsgPanel( aList );
898 wxString netname = conn->Name();
904 aList.push_back(
MSG_PANEL_ITEM(
_(
"Assigned Netclass" ), netclassName ) );
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
void Rotate(wxPoint aPosition) override
Rotate the item around aPosition 90 degrees in the clockwise direction.
void FinishTo(const wxPoint &pos)
void GetEndPoints(std::vector< DANGLING_END_ITEM > &aItemList) override
Add the schematic item end points to aItemList if the item has end points.
static const char * GetLineStyleName(PLOT_DASH_TYPE aStyle)
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.
std::map< wxString, wxString > m_NetClassAssignments
wxString MessageTextFromValue(EDA_UNITS aUnits, int aValue, bool aAddUnitLabel, EDA_DATA_TYPE aType)
Convert a value to a string using double notation.
COLOR4D GetLineColor() const
Returns COLOR4D::UNSPECIFIED if a custom color hasn't been set for this line.
void SetWidth(int aWidth)
Plot settings, and plotting engines (PostScript, Gerber, HPGL and DXF)
wxString GetClass() const override
Return the class name.
bool IsGraphicLine() const
Returns if the line is a graphic (non electrical line)
double GetLineLength(const wxPoint &aPointA, const wxPoint &aPointB)
Return the length of a line segment defined by aPointA and aPointB.
PNG memory record (file in memory).
const BITMAP_OPAQUE add_dashed_line_xpm[1]
wxPoint GetStartPoint() const
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
bool IsWire() const
Returns true if the line is a wire.
bool IsJunctionNeeded(const wxPoint &aPosition, bool aNew=false)
Test if a junction is required for the items at aPosition on the screen.
virtual void SetColor(COLOR4D color)=0
const wxString & GetName() const
bool m_endIsDangling
True if end point is not connected.
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
void SetLineWidth(const int aSize)
virtual PROJECT_FILE & GetProjectFile() const
void RotateEnd(wxPoint aPosition)
void MoveStart(const wxPoint &aMoveVector)
SCHEMATIC_SETTINGS & Settings() const
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
void Plot(PLOTTER *aPlotter) override
Plot the schematic item to aPlotter.
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
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.
NET_SETTINGS & NetSettings()
#define DASH_MARK_LEN(aLineWidth)
Schematic editor (Eeschema) main window.
void SetPlotStyle(PLOT_DASH_TYPE aPlotStyle)
bool CanConnect(const SCH_ITEM *aItem) const override
void RotatePoint(int *pX, int *pY, double angle)
The base class for create windows for drawing purpose.
void ViewGetLayers(int aLayers[], int &aCount) const override
Return the layers the item is drawn on (which may be more than its "home" layer)
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Return the text to display to be used in the selection clarification context menu when multiple items...
bool Contains(const wxPoint &aPoint) const
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 HitTest(const wxPoint &aPosition, int aAccuracy=0) const override
Test if aPosition is contained within or on the bounding box of an item.
void RotateStart(wxPoint aPosition)
bool UsesDefaultStroke() const
Test if the SCH_LINE object uses the default stroke settings.
void Move(const wxPoint &aMoveVector) override
Move the item by aMoveVector to a new position.
void MIRROR(T &aPoint, const T &aMirrorRef)
Updates aPoint with the mirror of aPoint relative to the aMirrorRef.
SCH_CONNECTION * Connection(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieve the connection associated with this object in the given sheet.
bool TestSegmentHit(const wxPoint &aRefPoint, wxPoint aStart, wxPoint aEnd, int aDist)
Test if aRefPoint is with aDistance on the line defined by aStart and aEnd.
NETCLASSPTR NetClass(const SCH_SHEET_PATH *aSheet=nullptr) const
bool IsConnectable() const override
PLOT_DASH_TYPE GetDefaultStyle() const
void SetLineStyle(const PLOT_DASH_TYPE aStyle)
const std::map< PLOT_DASH_TYPE, const char * > lineStyleNames
BITMAP_DEF GetMenuImage() const override
Return a pointer to an image to be used in menus.
PLOT_DASH_TYPE GetLineStyle() const
const BITMAP_OPAQUE add_line_xpm[1]
#define DOT_MARK_LEN(aLineWidth)
bool m_startIsDangling
True if start point is not connected.
int m_DefaultWireThickness
int GetPenWidth() const override
PLOT_DASH_TYPE GetPlotStyle() const
NET_SETTINGS stores various net-related settings in a project context.
wxDC * GetPrintDC() const
void SetLineColor(const COLOR4D &aColor)
bool IsEndPoint(const wxPoint &aPoint) const
#define STRUCT_DELETED
flag indication structures to be erased
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
NETCLASS * GetDefaultPtr() const
void GRLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color, wxPenStyle aStyle)
bool doIsConnected(const wxPoint &aPosition) const override
Provide the object specific test to see if it is connected to aPosition.
void GetSelectedPoints(std::vector< wxPoint > &aPoints) const
#define DEFAULT_LINE_THICKNESS
The default wire width in mils. (can be changed in preference menu)
static PLOT_DASH_TYPE GetLineStyleByName(const wxString &aStyleName)
wxPoint m_end
Line end point.
void SwapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
STROKE_PARAMS m_stroke
Line stroke properties.
PLOT_DASH_TYPE
Dashed line types.
PROJECT & Prj() const override
Return a reference to the project this schematic is part of.
#define DEFAULT_BUS_THICKNESS
The default noconnect size in mils.
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
void MoveTo(const wxPoint &pos)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
void Normalize()
Ensures that the height ant width are positive.
#define STARTPOINT
When a line is selected, these flags indicate which.
Base plotter engine class.
RENDER_SETTINGS * RenderSettings()
PLOT_DASH_TYPE GetEffectiveLineStyle() const
Segment description base class to describe items which have 2 end points (track, wire,...
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
void MoveEnd(const wxPoint &aMoveVector)
bool operator<(const SCH_ITEM &aItem) const override
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
#define DEFAULT_WIRE_THICKNESS
The default bus width in mils. (can be changed in preference menu)
void Print(const RENDER_SETTINGS *aSettings, const wxPoint &aOffset) override
Print a schematic item.
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
Handle the component boundary box.
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
#define DASH_GAP_LEN(aLineWidth)
A base class for most all the KiCad significant classes used in schematics and boards.
std::vector< MSG_PANEL_ITEM > MSG_PANEL_ITEMS
bool Intersects(const EDA_RECT &aRect) const
Test for a common area between rectangles.
const BITMAP_OPAQUE add_bus_xpm[1]
int GetDefaultPenWidth() const
void SetColor(const COLOR4D &aColor)
#define ENDPOINT
ends. (Used to support dragging.)
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.
bool IsParallel(const SCH_LINE *aLine) const
bool IsSameQuadrant(const SCH_LINE *aLine, const wxPoint &aPosition) const
Check if two lines are in the same quadrant as each other, using a reference point as the origin.
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Helper class used to store the state of schematic items that can be connected to other schematic item...
EDA_MSG_ITEM is used EDA_MSG_PANEL as the item type for displaying messages.
#define SKIP_STRUCT
flag indicating that the structure should be ignored
void SetPosition(const wxPoint &aPosition) override
Base class for any item which can be embedded within the SCHEMATIC container class,...
wxPoint m_start
Line start point.
bool IsBus() const
Returns true if the line is a bus.
int m_DefaultBusThickness
SCH_LINE(const wxPoint &pos=wxPoint(0, 0), int layer=LAYER_NOTES)
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.
std::vector< wxPoint > GetConnectionPoints() const override
Add all the connection points for this item to aPoints.
KICAD_T Type() const
Returns the type of object.
virtual void SetCurrentLineWidth(int width, void *aData=NULL)=0
Set the line width for the next drawing.
A color representation with 4 components: red, green, blue, alpha.
wxPoint GetEndPoint() const