46#include <api/board/board_types.pb.h>
79 if(
OPT_VECTOR2I intersection = ( *seg ).Intersect( aSeg ) )
81 if( ( *intersection - start ).SquaredEuclideanNorm()
82 < ( endpoint - start ).SquaredEuclideanNorm() )
83 endpoint = *intersection;
87 if( start == endpoint )
102 std::vector<VECTOR2I> intersections = aCircle.
Intersect( aSeg );
106 if( ( intersection - start ).SquaredEuclideanNorm()
107 < ( endpoint - start ).SquaredEuclideanNorm() )
108 endpoint = intersection;
111 if( start == endpoint )
123 std::vector<std::shared_ptr<SHAPE>>& aSegmentsAfterKnockout )
126 const bool containsA = aPoly.
Contains( aSeg.
A );
127 const bool containsB = aPoly.
Contains( aSeg.
B );
133 aSegmentsAfterKnockout.emplace_back(
new SHAPE_SEGMENT( aSeg.
A, *endpointA ) );
141 if( ( *endpointB == aSeg.
A && *endpointA == aSeg.
B )
142 || ( *endpointA == *endpointB && aSeg.
A == aSeg.
B ) )
147 aSegmentsAfterKnockout.emplace_back(
new SHAPE_SEGMENT( *endpointB, aSeg.
B ) );
150 if( !containsA && !containsB && !endpointA && !endpointB )
151 aSegmentsAfterKnockout.emplace_back(
new SHAPE_SEGMENT( aSeg ) );
182 return fp->GetTransform().Apply(
m_start );
191 return fp->GetTransform().Apply(
m_end );
200 m_start = fp->GetTransform().InverseApply( aPoint );
209 m_end = fp->GetTransform().InverseApply( aPoint );
239 return *
this == other;
292 double similarity = 1.0;
339 dimension.mutable_id()->set_value(
m_Uuid.AsStdString() );
341 dimension.set_locked(
IsLocked() ? types::LockedState::LS_LOCKED
342 : types::LockedState::LS_UNLOCKED );
346 types::Text*
text = dimension.mutable_text();
351 dimension.set_prefix(
m_prefix.ToUTF8() );
352 dimension.set_suffix(
m_suffix.ToUTF8() );
355 dimension.set_unit_format(
357 dimension.set_arrow_direction(
363 dimension.mutable_parent()->set_value( parent->m_Uuid.AsStdString() );
365 dimension.mutable_parent()->set_value(
board->m_Uuid.AsStdString() );
368 dimension.mutable_arrow_length()->set_value_nm(
m_arrowLength );
370 dimension.set_text_position(
375 aContainer.PackFrom( dimension );
382 kiapi::board::types::Dimension dimension;
384 if( !aContainer.UnpackTo( &dimension ) )
389 SetLocked( dimension.locked() == types::LockedState::LS_LOCKED );
399 SetPrefix( wxString::FromUTF8( dimension.prefix() ) );
400 SetSuffix( wxString::FromUTF8( dimension.suffix() ) );
481template<
typename ShapeType>
484 m_shapes.push_back( std::make_shared<ShapeType>( aShape ) );
490 struct lconv* lc = localeconv();
491 wxChar sep = lc->decimal_point[0];
504 default: precision = precision - 4;
break;
508 wxString format = wxT(
"%." ) + wxString::Format( wxT(
"%i" ), precision ) + wxT(
"f" );
514 while(
text.EndsWith(
'0' ) )
518 if(
text.EndsWith(
'.' ) ||
text.EndsWith( sep ) )
555 if( lengthConstraint && lengthConstraint->
GetValue() )
702 m_start = fp->GetTransform().InverseApply( boardStart );
703 m_end = fp->GetTransform().InverseApply( boardEnd );
717 Mirror( aCentre, aFlipDirection );
727 const VECTOR2I libAxis = fp->GetTransform().InverseApply( axis_pos );
732 p.x = 2 * libAxis.
x - p.x;
734 p.y = 2 * libAxis.
y - p.y;
741 mirrorPt( libTextPos );
758 MIRROR( newPos, axis_pos, aFlipDirection );
793 std::vector<MSG_PANEL_ITEM>& aList )
798 wxCHECK_RET(
m_parent !=
nullptr, wxT(
"PCB_TEXT::GetMsgPanelInfo() m_Parent is NULL." ) );
803 aList.emplace_back(
_(
"Prefix" ),
GetPrefix() );
819 default: msg = wxT(
"%" ) + wxString::Format( wxT(
"1.%df" ),
GetPrecision() );
822 aList.emplace_back(
_(
"Precision" ), wxString::Format( msg, 0.0 ) );
825 aList.emplace_back(
_(
"Suffix" ),
GetSuffix() );
834 aList.emplace_back(
_(
"Font" ),
GetFont() ?
GetFont()->GetName() :
_(
"Default" ) );
844 wxString start = wxString::Format( wxT(
"@(%s, %s)" ),
848 aList.emplace_back( start, wxEmptyString );
853 wxString start = wxString::Format( wxT(
"@(%s, %s)" ),
857 wxString
end = wxString::Format( wxT(
"@(%s, %s)" ),
861 aList.emplace_back( start,
end );
865 aList.emplace_back(
_(
"Status" ),
_(
"Locked" ) );
873 std::shared_ptr<SHAPE_COMPOUND> effectiveShape = std::make_shared<SHAPE_COMPOUND>();
877 for(
const std::shared_ptr<SHAPE>& shape :
GetShapes() )
878 effectiveShape->AddShape( shape->Clone() );
880 return effectiveShape;
893 for(
const std::shared_ptr<SHAPE>& shape :
GetShapes() )
895 if( shape->Collide( aPosition, dist_max ) )
926 for(
const std::shared_ptr<SHAPE>& shape :
GetShapes() )
939 int xmin, xmax, ymin, ymax;
947 for(
const std::shared_ptr<SHAPE>& shape :
GetShapes() )
949 BOX2I shapeBox = shape->BBox();
952 xmin = std::min( xmin, shapeBox.
GetOrigin().
x );
953 xmax = std::max( xmax, shapeBox.
GetEnd().
x );
954 ymin = std::min( ymin, shapeBox.
GetOrigin().
y );
955 ymax = std::max( ymax, shapeBox.
GetEnd().
y );
971 return wxString::Format(
_(
"Dimension '%s' on %s" ),
1030 int aClearance,
int aError,
ERROR_LOC aErrorLoc,
1031 bool aIgnoreLineWidth )
const
1033 wxASSERT_MSG( !aIgnoreLineWidth, wxT(
"IgnoreLineWidth has no meaning for dimensions." ) );
1035 for(
const std::shared_ptr<SHAPE>& shape :
m_shapes )
1044 aError, aErrorLoc );
1053 wxFAIL_MSG( wxT(
"PCB_DIMENSION_BASE::TransformShapeToPolygon unknown shape type." ) );
1083 kiapi::board::types::Dimension dimension;
1086 aContainer.UnpackTo( &dimension );
1090 dimension.mutable_aligned()->mutable_height()->set_value_nm(
m_height );
1091 dimension.mutable_aligned()->mutable_extension_height()->set_value_nm(
m_extensionHeight );
1093 aContainer.PackFrom( dimension );
1104 kiapi::board::types::Dimension dimension;
1105 aContainer.UnpackTo( &dimension );
1107 if( !dimension.has_aligned() )
1112 SetHeight( dimension.aligned().height().value_nm());
1123 wxASSERT( aImage->
Type() ==
Type() );
1151 VECTOR2D crossBar( aCrossbarEnd - aCrossbarStart );
1153 if( height.
Cross( crossBar ) > 0 )
1180 extension =
VECTOR2I( -dimension.
y, dimension.
x );
1182 extension =
VECTOR2I( dimension.
y, -dimension.
x );
1248 if( crossbarCenter.
x == 0 )
1250 else if( crossbarCenter.
x < 0 )
1255 VECTOR2I textOffset = crossbarCenter;
1257 textOffset = crossbarCenter + textOffset.
Resize( textOffsetDistance );
1318 kiapi::board::types::Dimension dimension;
1321 aContainer.UnpackTo( &dimension );
1325 dimension.mutable_orthogonal()->mutable_height()->set_value_nm(
m_height );
1326 dimension.mutable_orthogonal()->mutable_extension_height()->set_value_nm(
m_extensionHeight );
1329 ? types::AxisAlignment::AA_Y_AXIS
1330 : types::AxisAlignment::AA_X_AXIS );
1331 aContainer.PackFrom( dimension );
1342 kiapi::board::types::Dimension dimension;
1343 aContainer.UnpackTo( &dimension );
1345 if( !dimension.has_orthogonal() )
1350 SetHeight( dimension.orthogonal().height().value_nm());
1352 SetOrientation( dimension.orthogonal().alignment() == types::AxisAlignment::AA_Y_AXIS
1364 wxASSERT( aImage->
Type() ==
Type() );
1496 textOffset.
y = -textOffsetDistance;
1498 textOffset.
x = -textOffsetDistance;
1500 textOffset += crossbarCenter;
1511 if( abs( crossbarCenter.
x ) > abs( crossbarCenter.
y ) )
1546 else if( angle < -ANGLE_45 && angle >= -
ANGLE_135 )
1591 kiapi::board::types::Dimension dimension;
1594 aContainer.UnpackTo( &dimension );
1598 dimension.mutable_leader()->set_border_style(
1602 aContainer.PackFrom( dimension );
1613 kiapi::board::types::Dimension dimension;
1614 aContainer.UnpackTo( &dimension );
1616 if( !dimension.has_leader() )
1637 wxASSERT( aImage->
Type() ==
Type() );
1687 VECTOR2I firstLine( boardEnd - boardStart );
1691 SEG arrowSeg( boardStart, boardEnd );
1712 arrowSegEnd = boardEnd;
1744 if( textSegEnd && *arrowSegEnd == boardEnd )
1759 wxString start = wxString::Format( wxT(
"@(%s, %s)" ),
1763 aList.emplace_back( start, wxEmptyString );
1788 kiapi::board::types::Dimension dimension;
1791 aContainer.UnpackTo( &dimension );
1795 dimension.mutable_radial()->mutable_leader_length()->set_value_nm(
m_leaderLength );
1797 aContainer.PackFrom( dimension );
1808 kiapi::board::types::Dimension dimension;
1809 aContainer.UnpackTo( &dimension );
1811 if( !dimension.has_radial() )
1832 wxASSERT( aImage->
Type() ==
Type() );
1919 VECTOR2I radial( boardEnd - boardStart );
1922 SEG arrowSeg( boardEnd, boardEnd + radial );
1950 kiapi::board::types::Dimension dimension;
1953 aContainer.UnpackTo( &dimension );
1958 aContainer.PackFrom( dimension );
1969 kiapi::board::types::Dimension dimension;
1970 aContainer.UnpackTo( &dimension );
1972 if( !dimension.has_center() )
1992 wxASSERT( aImage->
Type() ==
Type() );
2007 int xmin, xmax, ymin, ymax;
2015 for(
const std::shared_ptr<SHAPE>& shape :
GetShapes() )
2017 BOX2I shapeBox = shape->BBox();
2020 xmin = std::min( xmin, shapeBox.
GetOrigin().
x );
2021 xmax = std::max( xmax, shapeBox.
GetEnd().
x );
2022 ymin = std::min( ymin, shapeBox.
GetOrigin().
y );
2023 ymax = std::max( ymax, shapeBox.
GetEnd().
y );
2065 VECTOR2I arm( boardEnd - boardStart );
2131 const wxString groupDimension =
_HKI(
"Dimension Properties" );
2151 auto isMultiArrowDirection =
2174 auto usesOverrideText =
2175 [isLeader, hasValueMode](
INSPECTABLE* aItem ) ->
bool
2177 return aItem && !isLeader( aItem ) && !hasValueMode( aItem );
2182 auto valueModeValidator =
2188 return std::nullopt;
2194 else if( !aValue.GetAs( &mode ) )
2195 return std::nullopt;
2200 return std::make_unique<VALIDATION_ERROR_MSG>(
2201 _(
"Driving requires both dimension endpoints bound to objects" ) );
2204 return std::nullopt;
2209 auto drivingValueValidator =
2215 return std::nullopt;
2219 if( !aValue.GetAs( &
text ) )
2220 return std::nullopt;
2226 return std::make_unique<VALIDATION_ERROR_MSG>(
2227 _(
"Enter a positive length for a driving dimension" ) );
2230 return std::nullopt;
2255 .SetValidator( std::move( drivingValueValidator ) );
2302 const wxString groupText =
_HKI(
"Text Properties" );
2309 const auto isTextOrientationWriteable =
2352 const wxString groupDimension =
_HKI(
"Dimension Properties" );
2367 _HKI(
"Vertical Justification" ),
2370 _HKI(
"Hyperlink" ),
2400 _HKI(
"Vertical Justification" ),
2403 _HKI(
"Hyperlink" ),
2427 const wxString groupDimension =
_HKI(
"Dimension Properties" );
2438 _HKI(
"Vertical Justification" ),
2441 _HKI(
"Hyperlink" ),
2470 const wxString groupDimension =
_HKI(
"Dimension Properties" );
2480 _HKI(
"Vertical Justification" ),
2483 _HKI(
"Hyperlink" ),
2514 _HKI(
"Vertical Justification" ),
2517 _HKI(
"Hyperlink" ),
KICOMMON_API types::KiCadObjectType ToProtoEnum(KICAD_T aValue)
KICOMMON_API KICAD_T FromProtoEnum(types::KiCadObjectType aValue)
ERROR_LOC
When approximating an arc or circle, should the error be placed on the outside or inside of the curve...
constexpr EDA_IU_SCALE pcbIUScale
BITMAPS
A list of all bitmap identifiers.
@ add_orthogonal_dimension
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Container for design settings for a BOARD object.
DIM_PRECISION m_DimensionPrecision
Number of digits after the decimal.
DIM_UNITS_FORMAT m_DimensionUnitsFormat
bool m_DimensionSuppressZeroes
bool m_DimensionKeepTextAligned
int GetLineThickness(PCB_LAYER_ID aLayer) const
Return the default graphic segment thickness from the layer class for the given layer.
DIM_TEXT_POSITION m_DimensionTextPosition
DIM_UNITS_MODE m_DimensionUnitsMode
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
BOARD_ITEM(BOARD_ITEM *aParent, KICAD_T idtype, PCB_LAYER_ID aLayer=F_Cu)
void SetUuidDirect(const KIID &aUuid)
Raw UUID assignment.
void SetLocked(bool aLocked) override
PCB_LAYER_ID GetFlippedLayer(PCB_LAYER_ID aLayer) const
Return the layer paired with aLayer on the opposite side of the board.
bool IsLocked() const override
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
virtual double GetCoverageArea(int aTextMargin) const
Return the board area this item covers, used to rank candidates under the cursor so a click on a smal...
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
FOOTPRINT * GetParentFootprint() const
bool IsSideSpecific() const
wxString GetLayerName() const
Return the name of the PCB layer on which the item resides.
constexpr BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
constexpr void SetHeight(size_type val)
constexpr const Vec GetEnd() const
constexpr BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
constexpr coord_type GetY() const
constexpr size_type GetWidth() const
constexpr coord_type GetX() const
constexpr BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
constexpr const Vec GetCenter() const
constexpr bool Contains(const Vec &aPoint) const
constexpr void SetWidth(size_type val)
constexpr void SetX(coord_type val)
constexpr const Vec & GetOrigin() const
constexpr void SetY(coord_type val)
constexpr coord_type GetRight() const
constexpr bool Intersects(const BOX2< Vec > &aRect) const
constexpr coord_type GetBottom() const
Represent basic circle geometry with utility geometry functions.
std::vector< VECTOR2I > Intersect(const CIRCLE &aCircle) const
Compute the intersection points between this circle and aCircle.
bool Contains(const VECTOR2I &aP) const
Return true if aP is on the circumference of this circle.
ORIGIN_TRANSFORMS & GetOriginTransforms() override
Return a reference to the default ORIGIN_TRANSFORMS object.
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.
EDA_ITEM * m_parent
Owner.
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
virtual VECTOR2I GetTextPos() const
virtual const wxString & GetText() const
Return the string associated with the text object.
virtual void SetTextPos(const VECTOR2I &aPoint)
virtual int GetTextHeight() const
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
KIFONT::FONT * GetFont() const
void SetMirrored(bool isMirrored)
BOX2I GetTextBox(const RENDER_SETTINGS *aSettings, int aLine=-1) const
Useful in multiline texts to calculate the full text or a line area (for zones filling,...
virtual int GetTextWidth() const
virtual void ClearBoundingBoxCache()
double Similarity(const EDA_TEXT &aOther) const
virtual void ClearRenderCache()
int GetEffectiveTextPenWidth(int aDefaultPenWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultPenWidth.
std::shared_ptr< SHAPE_COMPOUND > GetEffectiveTextShape(bool aTriangulate=true, const BOX2I &aBBox=BOX2I(), const EDA_ANGLE &aAngle=ANGLE_0) const
Build a list of segments (SHAPE_SEGMENT) to describe a text shape.
void SetTextAngleDegrees(double aOrientation)
virtual void SetText(const wxString &aText)
bool operator==(const EDA_TEXT &aRhs) const
static ENUM_MAP< T > & Instance()
Class that other classes need to inherit from, in order to be inspectable.
Contains methods for drawing PCB-specific items.
virtual PCB_RENDER_SETTINGS * GetSettings() override
Return a pointer to current settings that are going to be used when drawing items.
PCB specific render settings.
const std::unordered_set< KIID > & GetConstrainedItems() const
PCB_LAYER_ID GetPrimaryHighContrastLayer() const
Return the board layer which is in high-contrast mode.
bool GetHighContrast() 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.
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
bool IsLayerVisibleCached(int aLayer) const
PAINTER * GetPainter() const
Return the painter object used by the view for drawing VIEW_ITEM objects.
A geometric constraint between board items (issue #2329).
std::optional< double > GetValue() const
EDA_UNITS GetUnits() const
bool m_autoUnits
If true, follow the currently selected UI units.
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
void Update()
Update the dimension's cached text and geometry.
void ChangeSuffix(const wxString &aSuffix)
void OnFootprintRescaled(double aRatioX, double aRatioY, double aLinearFactor, const VECTOR2I &aAnchor, const EDA_ANGLE &aParentRotate) override
Apply a parent footprint scale to this item.
wxString GetOverrideText() const
wxString GetSuffix() const
std::vector< std::shared_ptr< SHAPE > > m_shapes
Internal cache of drawn shapes.
double Similarity(const BOARD_ITEM &aOther) const override
Return a measure of how likely the other object is to represent the same object.
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc, bool aIgnoreLineWidth=false) const override
Convert the item shape to a closed polygon.
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
void ClearRenderCache() override
int m_lineThickness
Thickness used for all graphics in the dimension.
virtual void SetEnd(const VECTOR2I &aPoint)
void Move(const VECTOR2I &offset) override
Move this object.
void SetUnitsFormat(const DIM_UNITS_FORMAT aFormat)
bool m_suppressZeroes
Suppress trailing zeroes.
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
void ChangeLineThickness(int aWidth)
int GetLineThickness() const
void SetUnits(EDA_UNITS aUnits)
VECTOR2I m_start
Start, FP-relative when in a footprint, board absolute otherwise.
DIM_PRECISION m_precision
Number of digits to display after decimal.
virtual void SetStart(const VECTOR2I &aPoint)
void addShape(const ShapeType &aShape)
void SetPrefix(const wxString &aPrefix)
wxString m_suffix
String appended to the value.
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
void ChangeOverrideText(const wxString &aValue)
void SetExtensionOffset(int aOffset)
std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING aFlash=FLASHING::DEFAULT, DRC_CONSTRAINT_T aUsage=NULL_CONSTRAINT) const override
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
void SetSuppressZeroes(bool aSuppress)
bool m_inClearRenderCache
re-entrancy guard
PCB_DIMENSION_BASE(BOARD_ITEM *aParent, KICAD_T aType=PCB_DIMENSION_T)
void ChangeExtensionOffset(int aOffset)
int m_extensionOffset
Distance from feature points to extension line start.
DIM_TEXT_POSITION GetTextPositionMode() const
void ChangeArrowDirection(const DIM_ARROW_DIRECTION &aDirection)
bool GetKeepTextAligned() const
void OnFootprintTransformed() override
Hook for items inside a footprint to refresh after the FP transform changes (translate,...
void ChangeTextAngleDegrees(double aDegrees)
bool m_keepTextAligned
Calculate text orientation to match dimension.
DIM_PRECISION GetPrecision() const
wxString GetPrefix() const
void SetOverrideTextEnabled(bool aOverride)
void SetSuffix(const wxString &aSuffix)
bool operator==(const PCB_DIMENSION_BASE &aOther) const
void ChangeValueMode(DIM_VALUE_MODE aMode)
Property panel setter for value mode override text flag lives on dimension length constraint is board...
const std::vector< std::shared_ptr< SHAPE > > & GetShapes() const
DIM_UNITS_MODE GetUnitsMode() const
void drawAnArrow(VECTOR2I aStartPoint, EDA_ANGLE anAngle, int aLength)
Draws an arrow and updates the shape container.
void SetTextPositionMode(DIM_TEXT_POSITION aMode)
virtual void updateText()
Update the text field value from the current geometry (called by updateGeometry normally).
bool HitTest(const VECTOR2I &aPosition, int aAccuracy) const override
Test if aPosition is inside or on the boundary of this item.
EDA_UNITS m_units
0 = inches, 1 = mm
int m_measuredValue
value of PCB dimensions
DIM_VALUE_MODE GetValueMode() const
Value mode from board state via DimensionValueMode.
DIM_UNITS_FORMAT GetUnitsFormat() const
void SetLineThickness(int aWidth)
void SetArrowLength(int aLength)
DIM_ARROW_DIRECTION GetArrowDirection() const
wxString m_valueString
Displayed value when m_overrideValue = true.
void ChangeTextPositionMode(DIM_TEXT_POSITION aMode)
virtual VECTOR2I GetEnd() const
void ChangePrecision(DIM_PRECISION aPrecision)
void StyleFromSettings(const BOARD_DESIGN_SETTINGS &aSettings, bool aCheckSide) override
void SetPrecision(DIM_PRECISION aPrecision)
bool m_overrideTextEnabled
Manually specify the displayed measurement value.
DIM_UNITS_FORMAT m_unitsFormat
How to render the units suffix.
int GetMeasuredValue() const
bool GetSuppressZeroes() const
void SetArrowDirection(const DIM_ARROW_DIRECTION &aDirection)
const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
DIM_TEXT_POSITION m_textPosition
How to position the text.
void SetOverrideText(const wxString &aValue)
wxString GetValueText() const
int GetExtensionOffset() const
double ViewGetLOD(int aLayer, const KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
void ChangePrefix(const wxString &aPrefix)
wxString m_prefix
String prepended to the value.
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
virtual VECTOR2I GetStart() const
The dimension's origin is the first feature point for the dimension.
DIM_ARROW_DIRECTION m_arrowDirection
direction of dimension arrow.
void ChangeKeepTextAligned(bool aKeepAligned)
void ChangeUnitsFormat(const DIM_UNITS_FORMAT aFormat)
wxString GetValueFieldText() const
Mode aware value for panel driving shows constraint length arbitrary shows override text otherwise sh...
void ChangeArrowLength(int aLength)
void ChangeSuppressZeroes(bool aSuppress)
int GetArrowLength() const
double GetCoverageArea(int aTextMargin) const override
Return the board area this item covers, used to rank candidates under the cursor so a click on a smal...
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 ChangeValueFieldText(const wxString &aText)
Property panel setter for value arbitrary text owned by dimension driving edits board level constrain...
double GetTextAngleDegreesProp() const
bool GetOverrideTextEnabled() const
void SetUnitsMode(DIM_UNITS_MODE aMode)
int m_arrowLength
Length of arrow shapes.
virtual void Mirror(const VECTOR2I &axis_pos, FLIP_DIRECTION aFlipDirection) override
Mirror the dimension relative to a given horizontal axis.
VECTOR2I m_end
End, FP-relative when in a footprint, board absolute otherwise.
void ChangeUnitsMode(DIM_UNITS_MODE aMode)
void SetKeepTextAligned(bool aKeepAligned)
std::vector< int > ViewGetLayers() const override
Return the all the layers within the VIEW the object is painted on.
VECTOR2I GetPosition() const override
For better understanding of the points that make a dimension:
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 Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
int m_height
Perpendicular distance from features to crossbar.
void ChangeExtensionHeight(int aHeight)
void updateText() override
Update the text field value from the current geometry (called by updateGeometry normally).
void SetExtensionHeight(int aHeight)
VECTOR2I m_crossBarStart
Crossbar start control point.
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
void Mirror(const VECTOR2I &axis_pos, FLIP_DIRECTION aFlipDirection) override
Mirror the dimension relative to a given horizontal axis.
void UpdateHeight(const VECTOR2I &aCrossbarStart, const VECTOR2I &aCrossbarEnd)
Update the stored height basing on points coordinates.
virtual void swapData(BOARD_ITEM *aImage) override
int m_extensionHeight
Length of extension lines past the crossbar.
void CopyFrom(const BOARD_ITEM *aOther) override
void SetHeight(int aHeight)
Set the distance from the feature points to the crossbar line.
VECTOR2I m_crossBarEnd
Crossbar end control point.
PCB_DIM_ALIGNED(BOARD_ITEM *aParent, KICAD_T aType=PCB_DIM_ALIGNED_T)
void ChangeHeight(int aHeight)
void updateGeometry() override
Update the cached geometry of the dimension after changing any of its properties.
int GetExtensionHeight() 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.
Mark the center of a circle or arc with a cross shape.
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
void updateGeometry() override
Update the cached geometry of the dimension after changing any of its properties.
const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
void CopyFrom(const BOARD_ITEM *aOther) override
virtual void swapData(BOARD_ITEM *aImage) override
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
PCB_DIM_CENTER(BOARD_ITEM *aParent)
void updateText() override
Update the text field value from the current geometry (called by updateGeometry normally).
A leader is a dimension-like object pointing to a specific point.
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.
DIM_TEXT_BORDER m_textBorder
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
DIM_TEXT_BORDER GetTextBorder() const
void CopyFrom(const BOARD_ITEM *aOther) override
virtual void swapData(BOARD_ITEM *aImage) override
void updateGeometry() override
Update the cached geometry of the dimension after changing any of its properties.
void updateText() override
Update the text field value from the current geometry (called by updateGeometry normally).
void SetTextBorder(DIM_TEXT_BORDER aBorder)
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
PCB_DIM_LEADER(BOARD_ITEM *aParent)
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
void ChangeTextBorder(DIM_TEXT_BORDER aBorder)
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
An orthogonal dimension is like an aligned dimension, but the extension lines are locked to the X or ...
void swapData(BOARD_ITEM *aImage) override
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
void updateText() override
Update the text field value from the current geometry (called by updateGeometry normally).
void CopyFrom(const BOARD_ITEM *aOther) override
void SetOrientation(DIR aOrientation)
Set the orientation of the dimension line (so, perpendicular to the feature lines).
void updateGeometry() override
Update the cached geometry of the dimension after changing any of its properties.
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
DIR m_orientation
What axis to lock the dimension line to.
void Mirror(const VECTOR2I &axis_pos, FLIP_DIRECTION aFlipDirection) override
Mirror the dimension relative to a given horizontal axis.
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
PCB_DIM_ORTHOGONAL(BOARD_ITEM *aParent)
A radial dimension indicates either the radius or diameter of an arc or circle.
int GetLeaderLength() const
PCB_DIM_RADIAL(BOARD_ITEM *aParent)
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
void updateText() override
Update the text field value from the current geometry (called by updateGeometry normally).
virtual void swapData(BOARD_ITEM *aImage) override
void SetLeaderLength(int aLength)
void CopyFrom(const BOARD_ITEM *aOther) override
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
void updateGeometry() override
Update the cached geometry of the dimension after changing any of its properties.
void ChangeLeaderLength(int aLength)
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
EDA_ANGLE GetLibTextAngle() const
Text angle in the parent footprint's lib frame, or absolute when not in a footprint.
void StyleFromSettings(const BOARD_DESIGN_SETTINGS &aSettings, bool aCheckSide) override
const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
EDA_ANGLE GetTextAngle() const override
void Offset(const VECTOR2I &aOffset) override
void SetLibTextAngle(const EDA_ANGLE &aAngle)
double ViewGetLOD(int aLayer, const KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
VECTOR2I GetTextPos() const override
PCB_TEXT(BOARD_ITEM *parent, KICAD_T idtype=PCB_TEXT_T)
void OnFootprintRescaled(double aRatioX, double aRatioY, double aLinearFactor, const VECTOR2I &aAnchor, const EDA_ANGLE &aParentRotate) override
Apply a parent footprint scale to this item.
std::vector< int > ViewGetLayers() const override
Return the all the layers within the VIEW the object is painted on.
bool TextHitTest(const VECTOR2I &aPoint, int aAccuracy=0) const override
Test if aPoint is within the bounds of this object.
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
int GetTextThickness() const override
void SetTextAngle(const EDA_ANGLE &aAngle) override
wxString GetShownText(RESOLUTION_CONTEXT aContext, int aDepth=0) const override
Return the string actually shown after processing of the base text.
void SetLibTextPos(const VECTOR2I &aPos)
PROPERTY_BASE & SetAvailableFunc(std::function< bool(INSPECTABLE *)> aFunc)
Set a callback function to determine whether an object provides this property.
PROPERTY_BASE & SetWriteableFunc(std::function< bool(INSPECTABLE *)> aFunc)
PROPERTY_BASE & SetValidator(PROPERTY_VALIDATOR_FN &&aValidator)
PROPERTY_BASE & SetIsCopyable(bool aIsCopyable=true)
void InheritsAfter(TYPE_ID aDerived, TYPE_ID aBase)
Declare an inheritance relationship between types.
void Mask(TYPE_ID aDerived, TYPE_ID aBase, const wxString &aName)
Sets a base class property as masked in a derived class.
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 AddTypeCast(TYPE_CAST_BASE *aCast)
Register a type converter.
void AddShape(SHAPE *aShape)
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
Represent a set of closed polygons.
void Rotate(const EDA_ANGLE &aAngle, const VECTOR2I &aCenter={ 0, 0 }) override
Rotate all vertices by a given angle.
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)
int NewOutline()
Creates a new empty polygon in the set and returns its index.
SEGMENT_ITERATOR IterateSegments(int aFirst, int aLast, bool aIterateHoles=false)
Return an iterator object, for iterating between aFirst and aLast outline, with or without holes (def...
CONST_SEGMENT_ITERATOR CIterateSegments(int aFirst, int aLast, bool aIterateHoles=false) const
Return an iterator object, for iterating between aFirst and aLast outline, with or without holes (def...
SEGMENT_ITERATOR_TEMPLATE< SEG > SEGMENT_ITERATOR
bool Contains(const VECTOR2I &aP, int aSubpolyIndex=-1, int aAccuracy=0, bool aUseBBoxCaches=false) const
Return true if a given subpolygon contains the point aP.
SEGMENT_ITERATOR_TEMPLATE< const SEG > CONST_SEGMENT_ITERATOR
const SEG & GetSeg() const
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE) const
A lower-precision version of StringFromValue().
void SetUserUnits(EDA_UNITS aUnits)
constexpr extended_type Cross(const VECTOR2< T > &aVector) const
Compute cross product of self with aVector.
T EuclideanNorm() const
Compute the Euclidean norm of the vector, which is defined as sqrt(x ** 2 + y ** 2).
VECTOR2< T > Resize(T aNewLength) const
Return a vector of the same direction, but length specified in aNewLength.
DIM_VALUE_MODE DimensionValueMode(BOARD *aBoard, const PCB_DIMENSION_BASE *aDimension)
The value mode aDimension is in, derived from state: a self driving length means Driving,...
bool DimensionHasValueMode(const PCB_DIMENSION_BASE *aDimension)
True for dimension types with a measured value aligned orthogonal or radial offering the Driven Drivi...
PCB_CONSTRAINT * FindDimensionLengthConstraint(BOARD *aBoard, const PCB_DIMENSION_BASE *aDimension)
Self FIXED_LENGTH constraint whose members are exactly aDimension START and END or nullptr the drivin...
bool DimensionCanDrive(BOARD *aBoard, const PCB_DIMENSION_BASE *aDimension)
True when Driving mode may be offered for aDimension needs both endpoints bound via DimensionEndpoint...
DIM_VALUE_MODE
Mode a value bearing dimension value is in Driven mirrors measured geometry Driving forces geometry t...
void TransformCircleToPolygon(SHAPE_LINE_CHAIN &aBuffer, const VECTOR2I &aCenter, int aRadius, int aError, ERROR_LOC aErrorLoc, int aMinSegCount=0)
Convert a circle to a polygon, using multiple straight lines.
void TransformOvalToPolygon(SHAPE_POLY_SET &aBuffer, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aWidth, int aError, ERROR_LOC aErrorLoc, int aMinSegCount=0)
Convert a oblong shape to a polygon, using multiple segments.
static constexpr EDA_ANGLE ANGLE_0
static constexpr EDA_ANGLE ANGLE_90
static constexpr EDA_ANGLE ANGLE_VERTICAL
static constexpr EDA_ANGLE ANGLE_HORIZONTAL
static constexpr EDA_ANGLE ANGLE_45
static constexpr EDA_ANGLE ANGLE_270
static constexpr EDA_ANGLE FULL_CIRCLE
static constexpr EDA_ANGLE ANGLE_180
static constexpr EDA_ANGLE ANGLE_135
#define PCB_EDIT_FRAME_NAME
a few functions useful in geometry calculations.
FLASHING
Enum used during connectivity building to ensure we do not query connectivity while building the data...
@ LAYER_CONSTRAINT_SHADOW
Shadow layer for items bound to a constraint.
PCB_LAYER_ID
A quick note on layer IDs:
constexpr void MIRROR(T &aPoint, const T &aMirrorRef)
Updates aPoint with the mirror of aPoint relative to the aMirrorRef.
@ LEFT_RIGHT
Flip left to right (around the Y axis)
@ TOP_BOTTOM
Flip top to bottom (around the X axis)
KICOMMON_API wxString StringFromValue(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits, double aValue, bool aAddUnitsText=false, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Return the string from aValue according to aUnits (inch, mm ...) for display.
KICOMMON_API double DoubleValueFromString(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits, const wxString &aTextValue, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Convert aTextValue to a double.
KICOMMON_API double ToUserUnit(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnit, double aValue)
Convert aValue in internal units to the appropriate user units defined by aUnit.
KICOMMON_API wxString GetText(EDA_UNITS aUnits, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Get the units string for a given units type.
KICOMMON_API wxString GetLabel(EDA_UNITS aUnits, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Get the units string for a given units type.
bool ShapeHitTest(const SHAPE_LINE_CHAIN &aHitter, const SHAPE &aHittee, bool aHitteeContained)
Perform a shape-to-shape hit test.
KICOMMON_API wxString EllipsizeMenuText(const wxString &aString)
Ellipsize text (at the end) to be no more than 36 characters.
KICOMMON_API wxString EllipsizeStatusText(wxWindow *aWindow, const wxString &aString)
Ellipsize text (at the end) to be no more than 1/3 of the window width.
KICOMMON_API void PackCustomProperties(google::protobuf::RepeatedPtrField< types::CustomProperty > *aOutput, const EDA_ITEM &aItem)
KICOMMON_API VECTOR2I UnpackVector2(const types::Vector2 &aInput, const EDA_IU_SCALE &aScale)
KICOMMON_API void PackVector2(types::Vector2 &aOutput, const VECTOR2I &aInput, const EDA_IU_SCALE &aScale)
KICOMMON_API void UnpackCustomProperties(const google::protobuf::RepeatedPtrField< types::CustomProperty > &aInput, EDA_ITEM &aItem)
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
static const int INWARD_ARROW_LENGTH_TO_HEAD_RATIO
static const EDA_ANGLE s_arrowAngle(27.5, DEGREES_T)
static struct DIMENSION_DESC _DIMENSION_DESC
static OPT_VECTOR2I segPolyIntersection(const SHAPE_POLY_SET &aPoly, const SEG &aSeg, bool aStart=true)
Find the intersection between a given segment and polygon outline.
static OPT_VECTOR2I segCircleIntersection(CIRCLE &aCircle, SEG &aSeg, bool aStart=true)
static void CollectKnockedOutSegments(const SHAPE_POLY_SET &aPoly, const SEG &aSeg, std::vector< std::shared_ptr< SHAPE > > &aSegmentsAfterKnockout)
Knockout a polygon from a segment.
DIM_TEXT_POSITION
Where to place the text on a dimension.
@ OUTSIDE
Text appears outside the dimension line (default)
@ MANUAL
Text placement is manually set by the user.
@ INLINE
Text appears in line with the dimension line.
DIM_UNITS_FORMAT
How to display the units in a dimension's text.
DIM_UNITS_MODE
Used for storing the units selection in the file because EDA_UNITS alone doesn't cut it.
DIM_ARROW_DIRECTION
Used for dimension's arrow.
DIM_TEXT_BORDER
Frame to show around dimension text.
#define TYPE_HASH(x)
Macro to generate unique identifier for a type.
#define ENUM_TO_WXANY(type)
@ PT_DEGREE
Angle expressed in degrees.
@ PT_SIZE
Size expressed in distance units (mm/inch)
#define REGISTER_TYPE(x)
Helper macro to map type hashes to names.
std::optional< std::unique_ptr< VALIDATION_ERROR > > VALIDATOR_RESULT
Null optional means validation succeeded.
std::optional< VECTOR2I > OPT_VECTOR2I
ORTHOGONAL_DIMENSION_DESC()
SHAPE_CIRCLE circle(c.m_circle_center, c.m_circle_radius)
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.
@ PCB_DIM_ORTHOGONAL_T
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
@ PCB_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
@ PCB_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
@ PCB_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
@ PCB_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
constexpr int sign(T val)
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D