42#include <api/schematic/schematic_types.pb.h>
98 kiapi::schematic::types::Line line;
104 ToProtoEnum<SCH_LAYER_ID, kiapi::schematic::types::SchematicLayer>(
GetLayer() ) );
106 aContainer.PackFrom( line );
112 kiapi::schematic::types::Line line;
114 if( !aContainer.UnpackTo( &line ) )
121 FromProtoEnum<SCH_LAYER_ID, kiapi::schematic::types::SchematicLayer>( line.layer() );
145 default:
return _(
"Graphic Line" );
177void SCH_LINE::Show(
int nestLevel, std::ostream& os )
const
179 NestedSpace( nestLevel, os ) <<
'<' <<
GetClass().Lower().mb_str()
180 <<
" layer=\"" <<
m_layer <<
'"'
182 <<
'"' <<
" endIsDangling=\""
184 <<
" <start" <<
m_start <<
"/>"
185 <<
" <end" <<
m_end <<
"/>" <<
"</"
186 <<
GetClass().Lower().mb_str() <<
">\n";
254 if( newColor == COLOR4D::UNSPECIFIED )
342 const VECTOR2I& offset,
bool aForceNoFill,
bool aDimmed )
347 if(
color == COLOR4D::UNSPECIFIED )
355 if( lineStyle <= LINE_STYLE::FIRST_TYPE )
407 vec =
m_end - aPoint;
419 if( aPoint ==
m_end )
422 vec =
m_end - aPoint;
430 wxCHECK_MSG( aLine !=
nullptr && aLine->
Type() ==
SCH_LINE_T,
false,
431 wxT(
"Cannot test line segment for overlap." ) );
437 return !( (
long long) firstSeg.
x * secondSeg.
y - (
long long) firstSeg.
y * secondSeg.
x );
447 return lhs.
y < rhs.y;
449 return lhs.
x < rhs.x;
452 wxCHECK_MSG( aLine !=
nullptr && aLine->
Type() ==
SCH_LINE_T,
nullptr,
453 wxT(
"Cannot test line segment for overlap." ) );
465 if( leftmost_start != std::min( { leftmost_start, leftmost_end }, less ) )
466 std::swap( leftmost_start, leftmost_end );
467 if( rightmost_start != std::min( { rightmost_start, rightmost_end }, less ) )
468 std::swap( rightmost_start, rightmost_end );
474 if( less( rightmost_start, leftmost_start ) )
476 std::swap( leftmost_start, rightmost_start );
477 std::swap( leftmost_end, rightmost_end );
480 VECTOR2I other_start = rightmost_start;
483 if( less( rightmost_end, leftmost_end ) )
485 rightmost_start = leftmost_start;
486 rightmost_end = leftmost_end;
490 if( less( leftmost_end, other_start ) )
496 if( ( leftmost_start == other_start ) && ( leftmost_end == other_end ) )
509 bool colinear =
false;
512 if( ( leftmost_start.
y == leftmost_end.
y ) &&
513 ( other_start.
y == other_end.
y ) )
515 colinear = ( leftmost_start.
y == other_start.
y );
517 else if( ( leftmost_start.
x == leftmost_end.
x ) &&
518 ( other_start.
x == other_end.
x ) )
520 colinear = ( leftmost_start.
x == other_start.
x );
528 long long dx = leftmost_end.
x - leftmost_start.
x;
529 long long dy = leftmost_end.
y - leftmost_start.
y;
530 colinear = ( ( ( other_start.
y - leftmost_start.
y ) * dx ==
531 ( other_start.
x - leftmost_start.
x ) * dy ) &&
532 ( ( other_end.
y - leftmost_start.
y ) * dx ==
533 ( other_end.
x - leftmost_start.
x ) * dy ) );
542 bool touching = leftmost_end == rightmost_start;
544 if( touching && aCheckJunctions && aScreen->
IsJunction( leftmost_end ) )
548 leftmost_end = rightmost_end;
585 std::vector<DANGLING_END_ITEM>& aItemListByPos,
597 it < aItemListByPos.end() && it->GetPosition() ==
m_start; it++ )
613 it < aItemListByPos.end() && it->GetPosition() ==
m_end; it++ )
648 switch( aItem->
Type() )
680 wxCHECK( line,
false );
697 switch( aItem->
Type() )
714 aPoints.push_back(
m_end );
726 case LAYER_WIRE: txtfmt =
_(
"Vertical Wire, length %s" );
break;
727 case LAYER_BUS: txtfmt =
_(
"Vertical Bus, length %s" );
break;
728 default: txtfmt =
_(
"Vertical Graphic Line, length %s" );
break;
735 case LAYER_WIRE: txtfmt =
_(
"Horizontal Wire, length %s" );
break;
736 case LAYER_BUS: txtfmt =
_(
"Horizontal Bus, length %s" );
break;
737 default: txtfmt =
_(
"Horizontal Graphic Line, length %s" );
break;
744 case LAYER_WIRE: txtfmt =
_(
"Wire, length %s" );
break;
745 case LAYER_BUS: txtfmt =
_(
"Bus, length %s" );
break;
746 default: txtfmt =
_(
"Graphic Line, length %s" );
break;
750 return wxString::Format( txtfmt,
758 return BITMAPS::add_dashed_line;
760 return BITMAPS::add_line;
762 return BITMAPS::add_bus;
798 aAccuracy = abs( aAccuracy );
847 int aUnit,
int aBodyStyle,
const VECTOR2I& aOffset,
bool aDimmed )
856 if(
color == COLOR4D::UNSPECIFIED )
867 aPlotter->
SetDash( penWidth, LINE_STYLE::SOLID );
870 std::vector<wxString> properties;
880 properties.emplace_back( wxString::Format( wxT(
"!%s = %s" ),
882 connection->Name() ) );
884 properties.emplace_back(
885 wxString::Format( wxT(
"!%s = %s" ),
_(
"Resolved netclass" ),
893 for(
const std::shared_ptr<SCH_CONNECTION>& member : connection->Members() )
894 properties.emplace_back( wxT(
"!" ) + member->Name() );
899 if( !properties.empty() )
920 default: msg =
_(
"Graphical" );
break;
923 aList.emplace_back(
_(
"Line Type" ), msg );
928 aList.emplace_back(
_(
"Line Style" ),
_(
"from netclass" ) );
943 aList.emplace_back(
_(
"Resolved Netclass" ),
1010 double similarity = 1.0;
1037 if( lineStyleEnum.
Choices().GetCount() == 0 )
1039 lineStyleEnum.
Map( LINE_STYLE::SOLID,
_HKI(
"Solid" ) )
1040 .
Map( LINE_STYLE::DASH,
_HKI(
"Dashed" ) )
1041 .
Map( LINE_STYLE::DOT,
_HKI(
"Dotted" ) )
1042 .
Map( LINE_STYLE::DASHDOT,
_HKI(
"Dash-Dot" ) )
1043 .
Map( LINE_STYLE::DASHDOTDOT,
_HKI(
"Dash-Dot-Dot" ) );
1048 if( wireLineStyleEnum.
Choices().GetCount() == 0 )
1050 wireLineStyleEnum.
Map( WIRE_STYLE::DEFAULT,
_HKI(
"Default" ) )
1051 .
Map( WIRE_STYLE::SOLID,
_HKI(
"Solid" ) )
1052 .
Map( WIRE_STYLE::DASH,
_HKI(
"Dashed" ) )
1053 .
Map( WIRE_STYLE::DOT,
_HKI(
"Dotted" ) )
1054 .
Map( WIRE_STYLE::DASHDOT,
_HKI(
"Dash-Dot" ) )
1055 .
Map( WIRE_STYLE::DASHDOTDOT,
_HKI(
"Dash-Dot-Dot" ) );
1062 auto isGraphicLine =
1066 return line->IsGraphicLine();
1075 return line->IsWire() || line->IsBus();
constexpr EDA_IU_SCALE schIUScale
BITMAPS
A list of all bitmap identifiers.
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
constexpr BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
constexpr bool Contains(const Vec &aPoint) const
constexpr bool Intersects(const BOX2< Vec > &aRect) const
static std::vector< DANGLING_END_ITEM >::iterator get_lower_pos(std::vector< DANGLING_END_ITEM > &aItemListByPos, const VECTOR2I &aPos)
Helper class used to store the state of schematic items that can be connected to other schematic item...
DANGLING_END_T GetType() const
EDA_ITEM * GetItem() const
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.
ENUM_MAP & Map(T aValue, const wxString &aName)
static ENUM_MAP< T > & Instance()
Class that other classes need to inherit from, in order to be inspectable.
A color representation with 4 components: red, green, blue, alpha.
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
wxDC * GetPrintDC() const
static constexpr double LOD_HIDE
Return this constant from ViewGetLOD() to hide the item unconditionally.
static constexpr double LOD_SHOW
Return this constant from ViewGetLOD() to show the item unconditionally.
static constexpr double lodScaleForThreshold(int aWhatIu, int aThresholdIu)
Get the scale at which aWhatIu would be drawn at the same size as aThresholdIu on screen.
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
std::string AsStdString() const
Base plotter engine class.
void MoveTo(const VECTOR2I &pos)
virtual void SetDash(int aLineWidth, LINE_STYLE aLineStyle)=0
void FinishTo(const VECTOR2I &pos)
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
PROPERTY_BASE & SetAvailableFunc(std::function< bool(INSPECTABLE *)> aFunc)
Set a callback function to determine whether an object provides this property.
Provide class metadata.Helper macro to map type hashes to names.
void InheritsAfter(TYPE_ID aDerived, TYPE_ID aBase)
Declare an inheritance relationship between types.
static PROPERTY_MANAGER & Instance()
PROPERTY_BASE & AddProperty(PROPERTY_BASE *aProperty, const wxString &aGroup=wxEmptyString)
Register a property.
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,...
SCH_RENDER_SETTINGS * getRenderSettings(PLOTTER *aPlotter) const
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
std::shared_ptr< NETCLASS > GetEffectiveNetClass(const SCH_SHEET_PATH *aSheet=nullptr) const
void SetLayer(SCH_LAYER_ID aLayer)
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
void SetConnectivityDirty(bool aDirty=true)
bool IsConnectivityDirty() const
void SwapFlags(SCH_ITEM *aItem)
Swap the non-temp and non-edit flags.
SCH_CONNECTION * Connection(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieve the connection associated with this object in the given sheet.
int GetEffectivePenWidth(const SCH_RENDER_SETTINGS *aSettings) const
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
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 UpdateDanglingState(std::vector< DANGLING_END_ITEM > &aItemListByType, std::vector< DANGLING_END_ITEM > &aItemListByPos, const SCH_SHEET_PATH *aPath=nullptr) override
Test the schematic item to aItemList to check if it's dangling state has changed.
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
SCH_LINE(const VECTOR2I &pos=VECTOR2I(0, 0), int layer=LAYER_NOTES)
bool IsWire() const
Return true if the line is a wire.
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
void SetWireStyle(const WIRE_STYLE aStyle)
void SetLineColor(const COLOR4D &aColor)
bool CanConnect(const SCH_ITEM *aItem) const override
bool IsParallel(const SCH_LINE *aLine) const
void SetLineWidth(const int aSize)
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
virtual STROKE_PARAMS GetStroke() const override
int GetAngleFrom(const VECTOR2I &aPoint) const
void GetSelectedPoints(std::vector< VECTOR2I > &aPoints) const
COLOR4D m_lastResolvedColor
LINE_STYLE GetEffectiveLineStyle() const
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.
void Plot(PLOTTER *aPlotter, bool aBackground, const SCH_PLOT_OPTS &aPlotOpts, int aUnit, int aBodyStyle, const VECTOR2I &aOffset, bool aDimmed) override
Plot the item to aPlotter.
wxString m_operatingPoint
wxString GetClass() const override
Return the class name.
void Rotate(const VECTOR2I &aCenter, bool aRotateCCW) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
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.
LINE_STYLE m_lastResolvedLineStyle
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.
void Print(const SCH_RENDER_SETTINGS *aSettings, int aUnit, int aBodyStyle, const VECTOR2I &aOffset, bool aForceNoFill, bool aDimmed) override
Print an item.
bool HasConnectivityChanges(const SCH_ITEM *aItem, const SCH_SHEET_PATH *aInstance=nullptr) const override
Check if aItem has connectivity changes against this object.
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
void SetLineStyle(const LINE_STYLE aStyle)
VECTOR2I m_end
Line end point.
void Move(const VECTOR2I &aMoveVector) override
Move the item by aMoveVector to a new position.
LINE_STYLE 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
wxString GetFriendlyName() const override
double ViewGetLOD(int aLayer, const KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
bool operator==(const SCH_ITEM &aOther) const override
bool operator<(const SCH_ITEM &aItem) const override
bool IsEndPoint(const VECTOR2I &aPoint) const
WIRE_STYLE GetWireStyle() const
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
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.
std::vector< int > ViewGetLayers() const override
Return the layers the item is drawn on (which may be more than its "home" layer)
void MoveStart(const VECTOR2I &aMoveVector)
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
SCH_LINE * BreakAt(const VECTOR2I &aPoint)
Break this segment into two at the specified point.
void SetEndPoint(const VECTOR2I &aPosition)
double Similarity(const SCH_ITEM &aOther) const override
Return a measure of how likely the other object is to represent the same object.
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 SetLineStyle(LINE_STYLE aLineStyle)
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)
LINE_STYLE GetLineStyle() const
KIGFX::COLOR4D GetColor() const
static void Stroke(const SHAPE *aShape, LINE_STYLE aLineStyle, int aWidth, const KIGFX::RENDER_SETTINGS *aRenderSettings, const std::function< void(const VECTOR2I &a, const VECTOR2I &b)> &aStroker)
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE) const
A lower-precision version of StringFromValue().
double Distance(const VECTOR2< extended_type > &aVector) const
Compute the distance between two vectors.
#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
static constexpr EDA_ANGLE ANGLE_270
#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)
SCH_LAYER_ID
Eeschema drawing layers.
@ LAYER_NET_COLOR_HIGHLIGHT
@ LAYER_SELECTION_SHADOWS
constexpr void MIRROR(T &aPoint, const T &aMirrorRef)
Updates aPoint with the mirror of aPoint relative to the aMirrorRef.
KICOMMON_API VECTOR2I UnpackVector2(const types::Vector2 &aInput)
KICOMMON_API void PackVector2(types::Vector2 &aOutput, const VECTOR2I &aInput)
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
#define IMPLEMENT_ENUM_TO_WXANY(type)
static struct SCH_LINE_DESC _SCH_LINE_DESC
wxString UnescapeString(const wxString &aSource)
LINE_STYLE
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)
Calculate the new point of coord coord pX, pY, for a rotation center 0, 0.
VECTOR2< int32_t > VECTOR2I