44#include <api/board/board_types.pb.h>
71 if(
OPT_VECTOR2I intersection = ( *seg ).Intersect( aSeg ) )
73 if( ( *intersection - start ).SquaredEuclideanNorm()
74 < ( endpoint - start ).SquaredEuclideanNorm() )
75 endpoint = *intersection;
79 if( start == endpoint )
94 std::vector<VECTOR2I> intersections = aCircle.
Intersect( aSeg );
98 if( ( intersection - start ).SquaredEuclideanNorm()
99 < ( endpoint - start ).SquaredEuclideanNorm() )
100 endpoint = intersection;
103 if( start == endpoint )
115 std::vector<std::shared_ptr<SHAPE>>& aSegmentsAfterKnockout )
118 const bool containsA = aPoly.
Contains( aSeg.
A );
119 const bool containsB = aPoly.
Contains( aSeg.
B );
125 aSegmentsAfterKnockout.emplace_back(
new SHAPE_SEGMENT( aSeg.
A, *endpointA ) );
133 if( ( *endpointB == aSeg.
A && *endpointA == aSeg.
B )
134 || ( *endpointA == *endpointB && aSeg.
A == aSeg.
B ) )
139 aSegmentsAfterKnockout.emplace_back(
new SHAPE_SEGMENT( *endpointB, aSeg.
B ) );
142 if( !containsA && !containsB && !endpointA && !endpointB )
143 aSegmentsAfterKnockout.emplace_back(
new SHAPE_SEGMENT( aSeg ) );
149 m_overrideTextEnabled( false ),
151 m_autoUnits( false ),
155 m_suppressZeroes( false ),
158 m_extensionOffset( 0 ),
160 m_keepTextAligned( true ),
161 m_measuredValue( 0 ),
162 m_inClearRenderCache( false )
176 return *
this == other;
229 double similarity = 1.0;
277 dimension.set_layer( ToProtoEnum<PCB_LAYER_ID, BoardLayer>(
GetLayer() ) );
278 dimension.set_locked(
IsLocked() ? types::LockedState::LS_LOCKED
279 : types::LockedState::LS_UNLOCKED );
281 google::protobuf::Any any;
283 any.UnpackTo( dimension.mutable_text() );
285 types::Text*
text = dimension.mutable_text();
290 dimension.set_prefix(
m_prefix.ToUTF8() );
291 dimension.set_suffix(
m_suffix.ToUTF8() );
293 dimension.set_unit( ToProtoEnum<DIM_UNITS_MODE, DimensionUnit>(
GetUnitsMode() ) );
294 dimension.set_unit_format(
295 ToProtoEnum<DIM_UNITS_FORMAT, DimensionUnitFormat>(
m_unitsFormat ) );
296 dimension.set_arrow_direction(
297 ToProtoEnum<DIM_ARROW_DIRECTION, DimensionArrowDirection>(
m_arrowDirection ) );
298 dimension.set_precision( ToProtoEnum<DIM_PRECISION, DimensionPrecision>(
m_precision ) );
302 dimension.mutable_arrow_length()->set_value_nm(
m_arrowLength );
304 dimension.set_text_position(
305 ToProtoEnum<DIM_TEXT_POSITION, DimensionTextPosition>(
m_textPosition ) );
308 aContainer.PackFrom( dimension );
315 kiapi::board::types::Dimension dimension;
317 if( !aContainer.UnpackTo( &dimension ) )
320 SetLayer( FromProtoEnum<PCB_LAYER_ID, kiapi::board::types::BoardLayer>( dimension.layer() ) );
322 SetLocked( dimension.locked() == types::LockedState::LS_LOCKED );
324 google::protobuf::Any any;
325 any.PackFrom( dimension.text() );
330 SetPrefix( wxString::FromUTF8( dimension.prefix() ) );
331 SetSuffix( wxString::FromUTF8( dimension.suffix() ) );
333 SetUnitsMode( FromProtoEnum<DIM_UNITS_MODE>( dimension.unit() ) );
334 SetUnitsFormat( FromProtoEnum<DIM_UNITS_FORMAT>( dimension.unit_format() ) );
335 SetArrowDirection( FromProtoEnum<DIM_ARROW_DIRECTION>( dimension.arrow_direction() ) );
336 SetPrecision( FromProtoEnum<DIM_PRECISION>( dimension.precision() ) );
377 case DIM_UNITS_FORMAT::NO_SUFFIX:
380 case DIM_UNITS_FORMAT::BARE_SUFFIX:
384 case DIM_UNITS_FORMAT::PAREN_SUFFIX:
412template<
typename ShapeType>
415 m_shapes.push_back( std::make_shared<ShapeType>( aShape ) );
421 struct lconv* lc = localeconv();
422 wxChar sep = lc->decimal_point[0];
432 case EDA_UNITS::INCH: precision = precision - 4;
break;
433 case EDA_UNITS::MILS: precision = std::max( 0, precision - 7 );
break;
434 case EDA_UNITS::MM: precision = precision - 5;
break;
435 default: precision = precision - 4;
break;
439 wxString format = wxT(
"%." ) + wxString::Format( wxT(
"%i" ), precision ) + wxT(
"f" );
445 while(
text.Last() ==
'0' )
449 if(
text.Last() ==
'.' ||
text.Last() == sep )
483 return DIM_UNITS_MODE::AUTOMATIC;
490 case EDA_UNITS::INCH:
return DIM_UNITS_MODE::INCH;
491 case EDA_UNITS::MM:
return DIM_UNITS_MODE::MM;
492 case EDA_UNITS::MILS:
return DIM_UNITS_MODE::MILS;
502 case DIM_UNITS_MODE::INCH:
507 case DIM_UNITS_MODE::MILS:
512 case DIM_UNITS_MODE::MM:
517 case DIM_UNITS_MODE::AUTOMATIC:
573 Mirror( aCentre, aFlipDirection );
583 MIRROR( newPos, axis_pos, aFlipDirection );
601 std::vector<MSG_PANEL_ITEM>& aList )
606 wxCHECK_RET(
m_parent !=
nullptr, wxT(
"PCB_TEXT::GetMsgPanelInfo() m_Parent is NULL." ) );
611 aList.emplace_back(
_(
"Prefix" ),
GetPrefix() );
623 case DIM_PRECISION::V_VV: msg = wxT(
"0.00 in / 0 mils / 0.0 mm" );
break;
624 case DIM_PRECISION::V_VVV: msg = wxT(
"0.000 in / 0 mils / 0.00 mm" );
break;
625 case DIM_PRECISION::V_VVVV: msg = wxT(
"0.0000 in / 0.0 mils / 0.000 mm" );
break;
626 case DIM_PRECISION::V_VVVVV: msg = wxT(
"0.00000 in / 0.00 mils / 0.0000 mm" );
break;
627 default: msg = wxT(
"%" ) + wxString::Format( wxT(
"1.%df" ),
GetPrecision() );
630 aList.emplace_back(
_(
"Precision" ), wxString::Format( msg, 0.0 ) );
633 aList.emplace_back(
_(
"Suffix" ),
GetSuffix() );
642 aList.emplace_back(
_(
"Font" ),
GetFont() ?
GetFont()->GetName() :
_(
"Default" ) );
652 wxString start = wxString::Format( wxT(
"@(%s, %s)" ),
656 aList.emplace_back( start, wxEmptyString );
661 wxString start = wxString::Format( wxT(
"@(%s, %s)" ),
665 wxString
end = wxString::Format( wxT(
"@(%s, %s)" ),
669 aList.emplace_back( start,
end );
673 aList.emplace_back(
_(
"Status" ),
_(
"Locked" ) );
681 std::shared_ptr<SHAPE_COMPOUND> effectiveShape = std::make_shared<SHAPE_COMPOUND>();
685 for(
const std::shared_ptr<SHAPE>& shape :
GetShapes() )
686 effectiveShape->AddShape( shape->Clone() );
688 return effectiveShape;
701 for(
const std::shared_ptr<SHAPE>& shape :
GetShapes() )
703 if( shape->Collide( aPosition, dist_max ) )
731 int xmin, xmax, ymin, ymax;
739 for(
const std::shared_ptr<SHAPE>& shape :
GetShapes() )
741 BOX2I shapeBox = shape->BBox();
744 xmin = std::min( xmin, shapeBox.
GetOrigin().
x );
745 xmax = std::max( xmax, shapeBox.
GetEnd().
x );
746 ymin = std::min( ymin, shapeBox.
GetOrigin().
y );
747 ymax = std::max( ymax, shapeBox.
GetEnd().
y );
763 return wxString::Format(
_(
"Dimension '%s' on %s" ),
781 int aClearance,
int aError,
ERROR_LOC aErrorLoc,
782 bool aIgnoreLineWidth )
const
784 wxASSERT_MSG( !aIgnoreLineWidth, wxT(
"IgnoreLineWidth has no meaning for dimensions." ) );
786 for(
const std::shared_ptr<SHAPE>& shape :
m_shapes )
804 wxFAIL_MSG( wxT(
"PCB_DIMENSION_BASE::TransformShapeToPolygon unknown shape type." ) );
828 kiapi::board::types::Dimension dimension;
831 aContainer.UnpackTo( &dimension );
833 PackVector2( *dimension.mutable_aligned()->mutable_start(),
m_start );
834 PackVector2( *dimension.mutable_aligned()->mutable_end(),
m_end );
835 dimension.mutable_aligned()->mutable_height()->set_value_nm(
m_height );
836 dimension.mutable_aligned()->mutable_extension_height()->set_value_nm(
m_extensionHeight );
838 aContainer.PackFrom( dimension );
849 kiapi::board::types::Dimension dimension;
850 aContainer.UnpackTo( &dimension );
852 if( !dimension.has_aligned() )
855 SetStart( UnpackVector2( dimension.aligned().start() ) );
856 SetEnd( UnpackVector2( dimension.aligned().end() ) );
857 SetHeight( dimension.aligned().height().value_nm());
868 wxASSERT( aImage->
Type() ==
Type() );
889 return BITMAPS::add_aligned_dimension;
896 VECTOR2D crossBar( aCrossbarEnd - aCrossbarStart );
898 if( height.
Cross( crossBar ) > 0 )
923 extension =
VECTOR2I( -dimension.
y, dimension.
x );
925 extension =
VECTOR2I( dimension.
y, -dimension.
x );
991 if( crossbarCenter.
x == 0 )
993 else if( crossbarCenter.
x < 0 )
998 VECTOR2I textOffset = crossbarCenter;
1000 textOffset = crossbarCenter + textOffset.
Resize( textOffsetDistance );
1055 kiapi::board::types::Dimension dimension;
1058 aContainer.UnpackTo( &dimension );
1060 PackVector2( *dimension.mutable_orthogonal()->mutable_start(),
m_start );
1061 PackVector2( *dimension.mutable_orthogonal()->mutable_end(),
m_end );
1062 dimension.mutable_orthogonal()->mutable_height()->set_value_nm(
m_height );
1063 dimension.mutable_orthogonal()->mutable_extension_height()->set_value_nm(
m_extensionHeight );
1066 ? types::AxisAlignment::AA_Y_AXIS
1067 : types::AxisAlignment::AA_X_AXIS );
1068 aContainer.PackFrom( dimension );
1079 kiapi::board::types::Dimension dimension;
1080 aContainer.UnpackTo( &dimension );
1082 if( !dimension.has_orthogonal() )
1085 SetStart( UnpackVector2( dimension.orthogonal().start() ) );
1086 SetEnd( UnpackVector2( dimension.orthogonal().end() ) );
1087 SetHeight( dimension.orthogonal().height().value_nm());
1089 SetOrientation( dimension.orthogonal().alignment() == types::AxisAlignment::AA_Y_AXIS
1101 wxASSERT( aImage->
Type() ==
Type() );
1128 return BITMAPS::add_orthogonal_dimension;
1231 textOffset.
y = -textOffsetDistance;
1233 textOffset.
x = -textOffsetDistance;
1235 textOffset += crossbarCenter;
1246 if( abs( crossbarCenter.
x ) > abs( crossbarCenter.
y ) )
1281 else if( angle < -ANGLE_45 && angle >= -
ANGLE_135 )
1320 kiapi::board::types::Dimension dimension;
1323 aContainer.UnpackTo( &dimension );
1325 PackVector2( *dimension.mutable_leader()->mutable_start(),
m_start );
1326 PackVector2( *dimension.mutable_leader()->mutable_end(),
m_end );
1327 dimension.mutable_leader()->set_border_style(
1328 ToProtoEnum<DIM_TEXT_BORDER, kiapi::board::types::DimensionTextBorderStyle>(
1331 aContainer.PackFrom( dimension );
1342 kiapi::board::types::Dimension dimension;
1343 aContainer.UnpackTo( &dimension );
1345 if( !dimension.has_leader() )
1348 SetStart( UnpackVector2( dimension.leader().start() ) );
1349 SetEnd( UnpackVector2( dimension.leader().end() ) );
1350 SetTextBorder( FromProtoEnum<DIM_TEXT_BORDER>( dimension.leader().border_style() ) );
1366 wxASSERT( aImage->
Type() ==
Type() );
1379 return BITMAPS::add_leader;
1438 arrowSegEnd =
m_end;
1448 case DIM_TEXT_BORDER::RECTANGLE:
1456 case DIM_TEXT_BORDER::CIRCLE:
1470 if( textSegEnd && *arrowSegEnd ==
m_end )
1485 wxString start = wxString::Format( wxT(
"@(%s, %s)" ),
1489 aList.emplace_back( start, wxEmptyString );
1509 kiapi::board::types::Dimension dimension;
1512 aContainer.UnpackTo( &dimension );
1514 PackVector2( *dimension.mutable_radial()->mutable_center(),
m_start );
1515 PackVector2( *dimension.mutable_radial()->mutable_radius_point(),
m_end );
1516 dimension.mutable_radial()->mutable_leader_length()->set_value_nm(
m_leaderLength );
1518 aContainer.PackFrom( dimension );
1529 kiapi::board::types::Dimension dimension;
1530 aContainer.UnpackTo( &dimension );
1532 if( !dimension.has_radial() )
1535 SetStart( UnpackVector2( dimension.radial().center() ) );
1536 SetEnd( UnpackVector2( dimension.radial().radius_point() ) );
1553 wxASSERT( aImage->
Type() ==
Type() );
1566 return BITMAPS::add_radial_dimension;
1662 kiapi::board::types::Dimension dimension;
1665 aContainer.UnpackTo( &dimension );
1667 PackVector2( *dimension.mutable_center()->mutable_center(),
m_start );
1668 PackVector2( *dimension.mutable_center()->mutable_end(),
m_end );
1670 aContainer.PackFrom( dimension );
1681 kiapi::board::types::Dimension dimension;
1682 aContainer.UnpackTo( &dimension );
1684 if( !dimension.has_center() )
1687 SetStart( UnpackVector2( dimension.center().center() ) );
1688 SetEnd( UnpackVector2( dimension.center().end() ) );
1704 wxASSERT( aImage->
Type() ==
Type() );
1712 return BITMAPS::add_center_dimension;
1769 .Map( DIM_PRECISION::X,
_HKI(
"0" ) )
1770 .Map( DIM_PRECISION::X_X,
_HKI(
"0.0" ) )
1771 .Map( DIM_PRECISION::X_XX,
_HKI(
"0.00" ) )
1772 .Map( DIM_PRECISION::X_XXX,
_HKI(
"0.000" ) )
1773 .Map( DIM_PRECISION::X_XXXX,
_HKI(
"0.0000" ) )
1774 .Map( DIM_PRECISION::X_XXXXX,
_HKI(
"0.00000" ) )
1775 .Map( DIM_PRECISION::V_VV,
_HKI(
"0.00 in / 0 mils / 0.0 mm" ) )
1776 .Map( DIM_PRECISION::V_VVV,
_HKI(
"0.000 / 0 / 0.00" ) )
1777 .Map( DIM_PRECISION::V_VVVV,
_HKI(
"0.0000 / 0.0 / 0.000" ) )
1778 .Map( DIM_PRECISION::V_VVVVV,
_HKI(
"0.00000 / 0.00 / 0.0000" ) );
1781 .Map( DIM_UNITS_FORMAT::NO_SUFFIX,
_HKI(
"1234.0" ) )
1782 .Map( DIM_UNITS_FORMAT::BARE_SUFFIX,
_HKI(
"1234.0 mm" ) )
1783 .Map( DIM_UNITS_FORMAT::PAREN_SUFFIX,
_HKI(
"1234.0 (mm)" ) );
1786 .Map( DIM_UNITS_MODE::INCH,
_HKI(
"Inches" ) )
1787 .Map( DIM_UNITS_MODE::MILS,
_HKI(
"Mils" ) )
1788 .Map( DIM_UNITS_MODE::MM,
_HKI(
"Millimeters" ) )
1789 .Map( DIM_UNITS_MODE::AUTOMATIC,
_HKI(
"Automatic" ) );
1792 .Map( DIM_ARROW_DIRECTION::INWARD,
_HKI(
"Inward" ) )
1793 .Map( DIM_ARROW_DIRECTION::OUTWARD,
_HKI(
"Outward" ) );
1806 const wxString groupDimension =
_HKI(
"Dimension Properties" );
1820 auto isMultiArrowDirection =
1866 const wxString groupText =
_HKI(
"Text Properties" );
1868 const auto isTextOrientationWriteable =
1882 PROPERTY_DISPLAY::PT_DEGREE ),
1909 const wxString groupDimension =
_HKI(
"Dimension Properties" );
1924 _HKI(
"Vertical Justification" ),
1927 _HKI(
"Hyperlink" ),
1957 _HKI(
"Vertical Justification" ),
1960 _HKI(
"Hyperlink" ),
1984 const wxString groupDimension =
_HKI(
"Dimension Properties" );
1988 PROPERTY_DISPLAY::PT_SIZE ),
1995 _HKI(
"Vertical Justification" ),
1998 _HKI(
"Hyperlink" ),
2012 .Map( DIM_TEXT_BORDER::NONE,
_HKI(
"None" ) )
2013 .Map( DIM_TEXT_BORDER::RECTANGLE,
_HKI(
"Rectangle" ) )
2014 .Map( DIM_TEXT_BORDER::CIRCLE,
_HKI(
"Circle" ) );
2027 const wxString groupDimension =
_HKI(
"Dimension Properties" );
2037 _HKI(
"Vertical Justification" ),
2040 _HKI(
"Hyperlink" ),
2071 _HKI(
"Vertical Justification" ),
2074 _HKI(
"Hyperlink" ),
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.
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
virtual void SetLocked(bool aLocked)
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.
virtual bool IsLocked() 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
Linked list: Link (parent struct).
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
int GetTextHeight() const
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
const VECTOR2I & GetTextPos() const
const EDA_ANGLE & GetTextAngle() const
virtual const wxString & GetText() const
Return the string associated with the text object.
void SetTextPos(const VECTOR2I &aPoint)
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
KIFONT::FONT * GetFont() const
BOX2I GetTextBox(int aLine=-1) const
Useful in multiline texts to calculate the full text or a line area (for zones filling,...
void SetMirrored(bool isMirrored)
void Offset(const VECTOR2I &aOffset)
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)
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
int GetTextThickness() const
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.
std::string AsStdString() 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)
wxString GetOverrideText() const
wxString GetSuffix() const
std::vector< std::shared_ptr< SHAPE > > m_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.
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 SetUnits(EDA_UNITS aUnits)
DIM_PRECISION m_precision
Number of digits to display after decimal.
std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer, FLASHING aFlash=FLASHING::DEFAULT) const override
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
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)
void SetSuppressZeroes(bool aSuppress)
bool m_inClearRenderCache
re-entrancy guard
PCB_DIMENSION_BASE(BOARD_ITEM *aParent, KICAD_T aType=PCB_DIMENSION_T)
int m_extensionOffset
Distance from feature points to extension line start.
void ChangeArrowDirection(const DIM_ARROW_DIRECTION &aDirection)
bool GetKeepTextAligned() const
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
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_UNITS_FORMAT GetUnitsFormat() const
void SetLineThickness(int aWidth)
void SetArrowLength(int aLength)
virtual const VECTOR2I & GetStart() const
The dimension's origin is the first feature point for the dimension.
DIM_ARROW_DIRECTION GetArrowDirection() const
wxString m_valueString
Displayed value when m_overrideValue = true.
void ChangePrecision(DIM_PRECISION aPrecision)
virtual void SetEnd(const VECTOR2I &aPoint)
void SetPrecision(DIM_PRECISION aPrecision)
bool m_overrideTextEnabled
Manually specify the displayed measurement value.
virtual void SetStart(const VECTOR2I &aPoint)
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
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.
DIM_ARROW_DIRECTION m_arrowDirection
direction of dimension arrow.
void ChangeKeepTextAligned(bool aKeepAligned)
void ChangeUnitsFormat(const DIM_UNITS_FORMAT aFormat)
void ChangeSuppressZeroes(bool aSuppress)
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.
double GetTextAngleDegreesProp() const
bool GetOverrideTextEnabled() const
void SetUnitsMode(DIM_UNITS_MODE aMode)
int m_arrowLength
Length of arrow shapes.
virtual const VECTOR2I & GetEnd() const
virtual void Mirror(const VECTOR2I &axis_pos, FLIP_DIRECTION aFlipDirection) override
Mirror the dimension relative to a given horizontal axis.
VECTOR2I m_end
Internal cache of drawn shapes.
void ChangeUnitsMode(DIM_UNITS_MODE aMode)
void SetKeepTextAligned(bool aKeepAligned)
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 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.
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)
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
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 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 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.
const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
wxString GetShownText(bool aAllowExtraText, int aDepth=0) const override
Return the string actually shown after processing of the base text.
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.
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)
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.
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.
const VECTOR2I GetCenter() const
Base class for iterating over all segments in a given SHAPE_POLY_SET.
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...
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.
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.
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_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
PCB_LAYER_ID FlipLayer(PCB_LAYER_ID aLayerId, int aCopperLayersCount)
FLASHING
Enum used during connectivity building to ensure we do not query connectivity while building the data...
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.
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.
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.
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)
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 ENUM_TO_WXANY(type)
Macro to define read-only fields (no setter method available)
@ PT_SIZE
Size expressed in distance units (mm/inch)
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_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
constexpr int sign(T val)
VECTOR2< int32_t > VECTOR2I