35#include <api/schematic/schematic_types.pb.h>
44 EDA_SHAPE( aShape, aLineWidth, aFillType )
60 kiapi::schematic::types::SchematicGraphicShape msg;
62 msg.mutable_id()->set_value(
m_Uuid.AsStdString() );
63 msg.set_locked(
IsLocked() ? types::LockedState::LS_LOCKED : types::LockedState::LS_UNLOCKED );
68 aContainer.PackFrom( msg );
76 kiapi::schematic::types::SchematicGraphicShape msg;
78 if( !aContainer.UnpackTo( &msg ) )
82 SetLocked( msg.locked() == types::LockedState::LS_LOCKED );
176 return hitTest( aPosition, aAccuracy );
185 return hitTest( aRect, aContained, aAccuracy );
196 for(
SHAPE* shape : shapes )
202 for(
SHAPE* s : shapes )
208 for(
SHAPE* shape : shapes )
249 int aUnit,
int aBodyStyle,
const VECTOR2I& aOffset,
bool aDimmed )
260 static std::vector<VECTOR2I> ptList;
284 for(
int ii = 0; ii <
chain.PointCount(); ++ii )
307 color.
a = color.
a * 0.4;
362 color = color.
Mix( bg, 0.5f );
373 for(
int jj = 0; jj < outline.
PointCount(); ++jj )
383 aPlotter->
SetDash( pen_size, lineStyle );
389 auto transformBezierPoint = [&](
const VECTOR2D& aPoint )
394 std::vector<VECTOR2I> lineEndingPlotPoints = ptList;
426 aPlotter->
Arc( start, newMid, newEnd, fill, pen_size );
431 aPlotter->
Arc( start, mid,
end, fill, pen_size );
435 start = origArcStart;
455 aPlotter->
PlotPoly( ptList, fill, pen_size,
nullptr );
465 aPlotter->
BezierCurve( transformBezierPoint( curve->Start ), transformBezierPoint( curve->C1 ),
466 transformBezierPoint( curve->C2 ), transformBezierPoint( curve->End ),
GetMaxError(),
472 std::vector<VECTOR2I> plotPts;
474 plotPts.reserve( pts.size() );
477 plotPts.push_back( transformBezierPoint( pt ) );
479 aPlotter->
PlotPoly( plotPts, fill, pen_size,
nullptr );
485 if( !ptList.empty() )
486 ptList.push_back( ptList.front() );
488 aPlotter->
PlotPoly( ptList, fill, pen_size,
nullptr );
523 if( lineEndingPlotPoints.size() >= 2 )
528 for(
const VECTOR2I& pt : lineEndingPlotPoints )
544 endingShape.
SetEnd( endPt );
551 endingShape.
SetEnd( endPt );
579 return schematic->Settings().m_DefaultLineWidth;
604 return wxString::Format(
_(
"Arc, radius %s" ),
608 return wxString::Format(
_(
"Circle, radius %s" ),
612 return wxString::Format(
_(
"Rectangle, width %s height %s" ),
617 return wxString::Format(
_(
"Polyline, %d points" ),
621 return wxString::Format(
_(
"Bezier Curve, %d points" ),
625 return wxString::Format(
_(
"Ellipse, %s x %s" ),
630 return wxString::Format(
_(
"Elliptical Arc, %s x %s" ),
636 return wxEmptyString;
663 std::vector<int> layers( 3 );
766 if( fillEnum.
Choices().GetCount() == 0 )
786 auto isPolygonOrEllipse =
791 const SHAPE_T t = shape->GetShape();
799 auto isNotPolygonOrCircleOrEllipse =
804 const SHAPE_T t = shape->GetShape();
822 auto isSchematicItem =
831 auto isFillColorEditable =
836 if( shape->GetParentSymbol() )
839 return shape->IsSolidFill();
845 const wxString shapeProps =
_HKI(
"Shape Properties" );
860 isNotPolygonOrCircleOrEllipse );
862 isNotPolygonOrCircleOrEllipse );
864 isNotPolygonOrCircleOrEllipse );
866 isNotPolygonOrCircleOrEllipse );
872 isFillColorEditable );
878 fillModeSetter, fillModeGetter ),
879 _HKI(
"Shape Properties" ) )
constexpr EDA_IU_SCALE schIUScale
BITMAPS
A list of all bitmap identifiers.
static const COLOR4D WHITE
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
The base class for create windows for drawing purpose.
void SetFlags(EDA_ITEM_FLAGS aMask)
KICAD_T Type() const
Returns the type of object.
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
virtual void SetEnd(const VECTOR2I &aEnd)
int GetEllipseMinorRadius() const
const VECTOR2I & GetBezierC2() const
VECTOR2I getCenter() const
void rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle)
const SHAPE_POLY_SET & GetHatching() const
FILL_T GetFillMode() const
int GetEllipseMajorRadius() const
std::vector< VECTOR2I > GetPolyPoints() const
Duplicate the polygon outlines into a flat list of VECTOR2I points.
SHAPE_ELLIPSE buildShapeEllipse() const
SHAPE_POLY_SET & GetPolyShape()
void GetEndingTangents(EDA_ANGLE &aStartTangent, EDA_ANGLE &aEndTangent, int aLineWidth=0) const
Compute outward-facing tangent angles at the start and end of the shape.
void ShapeGetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList)
bool operator==(const EDA_SHAPE &aOther) const
virtual void SetBezierC2(const VECTOR2I &aPt)
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
bool IsHatchedFill() const
virtual void SetBezierC1(const VECTOR2I &aPt)
bool GetLineEndingEndpoints(VECTOR2I &aStartPoint, VECTOR2I &aEndPoint) const
Return the source endpoints used to place line endings.
bool hitTest(const VECTOR2I &aPosition, int aAccuracy=0) const
void RebuildBezierToSegmentsPointsList(int aMaxError)
Rebuild the m_bezierPoints vertex list that approximate the Bezier curve by a list of segments.
void flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection)
EDA_SHAPE(SHAPE_T aType, int aLineWidth, FILL_T aFill)
int GetPointCount() const
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
COLOR4D GetFillColor() const
void SwapShape(EDA_SHAPE *aImage)
std::vector< VECTOR2I > GetRectCorners() const
std::vector< VECTOR2I > m_bezierPoints
const LINE_ENDING & GetStartEnding() const
virtual void UpdateHatching() const
void SetArcGeometry(const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd)
Set the three controlling points for an arc.
wxString SHAPE_T_asString() const
double Similarity(const EDA_SHAPE &aOther) const
const VECTOR2I & GetBezierC1() const
std::optional< BEZIER< double > > ShortenedBezierCurve(int aLineWidth) const
Return the cubic Bezier curve shortened for line endings.
const BOX2I getBoundingBox() const
bool ShortenBodyPolyPoints(std::vector< VECTOR2I > &aPoints, bool aClosed, int aOutlineIdx, int aLineWidth) const
Apply line-ending body shortening to copied/generated polyline points.
bool ShortenArcForEndings(EDA_ANGLE &aStartAngle, EDA_ANGLE &aArcAngle, double aRadius, int aLineWidth) const
Shorten an arc body for line endings.
std::vector< VECTOR2D > ShortenedBezierPolyline(int aLineWidth) const
Return the flattened Bezier polyline after line-ending shortening.
const LINE_ENDING & GetEndEnding() const
int GetCornerRadius() const
void SetFillMode(FILL_T aFill)
virtual void SetPolyShape(const SHAPE_POLY_SET &aShape)
virtual void SetStart(const VECTOR2I &aStart)
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
int Compare(const EDA_SHAPE *aOther) const
VECTOR2I GetArcMid() const
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.
std::shared_ptr< wxString > m_text
COLOR4D & Desaturate()
Removes color (in HSL model)
COLOR4D Mix(const COLOR4D &aColor, double aFactor) const
Return a color that is mixed with the input by a factor.
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
void Plot(PLOTTER *aPlotter, const VECTOR2I &aPoint, const EDA_ANGLE &aTangent, int aLineWidth, void *aData=nullptr) const
Base plotter engine class.
virtual void Circle(const VECTOR2I &pos, int diametre, FILL_T fill, int width)=0
virtual void SetDash(int aLineWidth, LINE_STYLE aLineStyle)=0
virtual PLOT_FORMAT GetPlotterType() const =0
Return the effective plot engine in use.
virtual void Rect(const VECTOR2I &p1, const VECTOR2I &p2, FILL_T fill, int width, int aCornerRadius=0)=0
virtual void BezierCurve(const VECTOR2I &aStart, const VECTOR2I &aControl1, const VECTOR2I &aControl2, const VECTOR2I &aEnd, int aTolerance, int aLineThickness)
Generic fallback: Cubic Bezier curve rendered as a polyline.
bool GetColorMode() const
virtual void SetCurrentLineWidth(int width, void *aData=nullptr)=0
Set the line width for the next drawing.
virtual void PlotPoly(const std::vector< VECTOR2I > &aCornerList, FILL_T aFill, int aWidth, void *aData)=0
Draw a polygon ( filled or not ).
virtual void SetColor(const COLOR4D &color)=0
virtual void Arc(const VECTOR2D &aStart, const VECTOR2D &aMid, const VECTOR2D &aEnd, FILL_T aFill, int aWidth)
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.
void OverrideAvailability(TYPE_ID aDerived, TYPE_ID aBase, const wxString &aName, std::function< bool(INSPECTABLE *)> aFunc)
Sets an override availability functor for a base class property of a given derived class.
void OverrideWriteability(TYPE_ID aDerived, TYPE_ID aBase, const wxString &aName, std::function< bool(INSPECTABLE *)> aFunc)
Sets an override writeability functor for a base class property of a given derived class.
void AddTypeCast(TYPE_CAST_BASE *aCast)
Register a type converter.
Holds all the data relating to one schematic.
Base class for any item which can be embedded within the SCHEMATIC container class,...
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 SetLocked(bool aLocked) override
SCH_RENDER_SETTINGS * getRenderSettings(PLOTTER *aPlotter) const
const SYMBOL * GetParentSymbol() const
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
bool IsLocked() const override
virtual bool operator==(const SCH_ITEM &aOther) const
void SetLayer(SCH_LAYER_ID aLayer)
SCH_ITEM(EDA_ITEM *aParent, KICAD_T aType, int aUnit=0, int aBodyStyle=0)
wxString ResolveText(const wxString &aText, const SCH_SHEET_PATH *aPath, int aDepth=0) const
virtual int compare(const SCH_ITEM &aOther, int aCompareFlags=~COMPARE_FLAGS::UNIT) const
Provide the draw object specific comparison called by the == and < operators.
int GetEffectivePenWidth(const SCH_RENDER_SETTINGS *aSettings) const
double SimilarityBase(const SCH_ITEM &aItem) const
Calculate the boilerplate similarity for all LIB_ITEMs without preventing the use above of a pure vir...
VECTOR2I TransformCoordinate(const VECTOR2I &aPoint) const
const KIGFX::COLOR4D & GetBackgroundColor() const override
Return current background color settings.
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
void SetPositionX(int aX)
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
std::vector< SHAPE * > MakeEffectiveShapes(bool aEdgeOnly=false) const override
Make a set of SHAPE objects representing the SCH_SHAPE.
void SetFilled(bool aFilled) override
void Move(const VECTOR2I &aOffset) override
Move the item by aMoveVector to a new position.
void UpdateHatching() const override
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
void SetStroke(const STROKE_PARAMS &aStroke) override
void swapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
double Similarity(const SCH_ITEM &aOther) const override
Return a measure of how likely the other object is to represent the same object.
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.
SCH_SHAPE(SHAPE_T aShape=SHAPE_T::UNDEFINED, SCH_LAYER_ID aLayer=LAYER_NOTES, int aLineWidth=0, FILL_T aFillType=FILL_T::NO_FILL, KICAD_T aType=SCH_SHAPE_T)
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
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 AddPoint(const VECTOR2I &aPosition)
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
void Rotate(const VECTOR2I &aCenter, bool aRotateCCW) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
bool operator==(const SCH_ITEM &aOther) const override
void SetPositionY(int aY)
std::vector< int > ViewGetLayers() const override
Return the layers the item is drawn on (which may be more than its "home" layer)
int GetPenWidth() const override
bool IsEndPoint(const VECTOR2I &aPoint) const override
Test if aPt is an end point of this schematic object.
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
STROKE_PARAMS GetStroke() const override
VECTOR2I GetPosition() const override
int GetEffectiveWidth() const override
int compare(const SCH_ITEM &aOther, int aCompareFlags=0) const override
Provide the draw object specific comparison called by the == and < operators.
int getMaxError() const override
EDA_ANGLE GetCentralAngle() const
Get the "central angle" of the arc - this is the angle at the point of the "pie slice".
EDA_ANGLE GetStartAngle() const
const VECTOR2I & GetCenter() const
SHAPE_LINE_CHAIN ConvertToPolyline(int aMaxError) const
Build a polyline approximation of the ellipse or arc.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
void SetPoint(int aIndex, const VECTOR2I &aPos)
Move a point to a specific location.
void SetClosed(bool aClosed)
Mark the line chain as closed (i.e.
int PointCount() const
Return the number of points (vertices) in this line chain.
void Append(int aX, int aY, bool aAllowDuplication=false)
Append a new point at the end of the line chain.
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
Represent a set of closed polygons.
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Appends a vertex at the end of the given outline/hole (default: the last outline)
SHAPE_LINE_CHAIN & Outline(int aIndex)
Return the reference to aIndex-th outline in the set.
int NewOutline()
Creates a new empty polygon in the set and returns its index.
int OutlineCount() const
Return the number of outlines in the set.
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
An abstract shape on 2D plane.
Simple container to manage line stroke parameters.
LINE_STYLE GetLineStyle() const
KIGFX::COLOR4D GetColor() const
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE) const
A lower-precision version of StringFromValue().
#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
@ FILLED_WITH_BG_BODYCOLOR
@ FILLED_SHAPE
Fill with object color.
#define STRUCT_DELETED
flag indication structures to be erased
#define SKIP_STRUCT
flag indicating that the structure should be ignored
#define IS_MOVING
Item being moved.
@ RECTANGLE
Use RECTANGLE instead of RECT to avoid collision in a Windows header.
a few functions useful in geometry calculations.
SCH_LAYER_ID
Eeschema drawing layers.
@ LAYER_SHAPES_BACKGROUND
@ LAYER_DEVICE_BACKGROUND
@ LAYER_SELECTION_SHADOWS
This file contains miscellaneous commonly used macros and functions.
#define UNIMPLEMENTED_FOR(type)
@ LEFT_RIGHT
Flip left to right (around the Y axis)
@ TOP_BOTTOM
Flip top to bottom (around the X axis)
Message panel definition file.
bool ShapeHitTest(const SHAPE_LINE_CHAIN &aHitter, const SHAPE &aHittee, bool aHitteeContained)
Perform a shape-to-shape hit test.
KICOMMON_API void PackCustomProperties(google::protobuf::RepeatedPtrField< types::CustomProperty > *aOutput, const EDA_ITEM &aItem)
KICOMMON_API void UnpackCustomProperties(const google::protobuf::RepeatedPtrField< types::CustomProperty > &aInput, EDA_ITEM &aItem)
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
#define ENUM_TO_WXANY(type)
Macro to define read-only fields (no setter method available)
@ PT_COORD
Coordinate expressed in distance units (mm/inch)
static struct SCH_SHAPE_DESC _SCH_SHAPE_DESC
LINE_STYLE
Dashed line types.
const SHAPE_LINE_CHAIN chain
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.
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D