2012-01-14 19:50:32 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
2020-09-16 18:26:34 +00:00
|
|
|
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
2012-01-14 19:50:32 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2020-11-11 23:05:59 +00:00
|
|
|
#ifndef DIMENSION_H
|
|
|
|
#define DIMENSION_H
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2020-11-14 18:11:28 +00:00
|
|
|
#include <board_item.h>
|
2020-10-04 23:34:59 +00:00
|
|
|
#include <pcb_text.h>
|
2020-09-12 20:09:40 +00:00
|
|
|
#include <geometry/shape.h>
|
2011-09-20 15:07:52 +00:00
|
|
|
|
|
|
|
|
2011-09-23 13:57:12 +00:00
|
|
|
class LINE_READER;
|
2013-01-12 17:32:24 +00:00
|
|
|
class MSG_PANEL_ITEM;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2011-08-01 15:29:27 +00:00
|
|
|
|
2020-09-09 03:17:08 +00:00
|
|
|
/// How to display the units in a dimension's text
|
|
|
|
enum class DIM_UNITS_FORMAT
|
|
|
|
{
|
|
|
|
NO_SUFFIX, // 1234.0
|
|
|
|
BARE_SUFFIX, // 1234.0 mm
|
|
|
|
PAREN_SUFFIX // 1234.0 (mm)
|
|
|
|
};
|
|
|
|
|
|
|
|
/// Where to place the text on a dimension
|
|
|
|
enum class DIM_TEXT_POSITION
|
|
|
|
{
|
|
|
|
OUTSIDE, ///< Text appears outside the dimension line (default)
|
|
|
|
INLINE, ///< Text appears in line with the dimension line
|
|
|
|
MANUAL ///< Text placement is manually set by the user
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Used for storing the units selection in the file because EDA_UNITS alone doesn't cut it
|
|
|
|
*/
|
|
|
|
enum class DIM_UNITS_MODE
|
|
|
|
{
|
|
|
|
INCHES,
|
|
|
|
MILS,
|
|
|
|
MILLIMETRES,
|
|
|
|
AUTOMATIC
|
|
|
|
};
|
|
|
|
|
2020-09-12 20:09:40 +00:00
|
|
|
/**
|
|
|
|
* Frame to show around dimension text
|
|
|
|
*/
|
|
|
|
enum class DIM_TEXT_FRAME
|
|
|
|
{
|
|
|
|
NONE,
|
2020-09-16 18:26:34 +00:00
|
|
|
RECTANGLE,
|
2020-09-12 20:09:40 +00:00
|
|
|
CIRCLE,
|
|
|
|
ROUNDRECT
|
|
|
|
};
|
|
|
|
|
2014-02-11 12:22:30 +00:00
|
|
|
/**
|
2020-09-09 03:17:08 +00:00
|
|
|
* Abstract dimension API
|
2014-02-11 12:22:30 +00:00
|
|
|
*
|
2020-09-09 03:17:08 +00:00
|
|
|
* Some notes about dimension nomenclature:
|
|
|
|
*
|
|
|
|
* - "feature points" are the points being measured by the dimension. For an example, the start
|
|
|
|
* and end points of a line to be measured. These are the first points picked when drawing a
|
|
|
|
* new dimension. Dimensions can have one or more feature points: linear dimensions (the only
|
|
|
|
* type supported in KiCad 5 and earlier) have two feature points; leader dimensions have one;
|
|
|
|
* and ordinate dimensions can have in theory an unlimited number of feature points.
|
|
|
|
*
|
|
|
|
* - "feature lines" are lines that coincide with feature points. Not all dimension types have
|
|
|
|
* feature lines. The actual start and end of feature lines is calculated from dimension style
|
|
|
|
* properties (offset from feature point to start of feature line, height of crossbar, and height
|
|
|
|
* of feature line past crossbar, for example in linear dimensions)
|
2014-02-11 12:22:30 +00:00
|
|
|
*
|
2020-09-09 03:17:08 +00:00
|
|
|
* - "crossbar" refers to the perpendicular line (usually with arrows at each end) between feature
|
|
|
|
* lines on linear dimensions
|
2014-02-11 12:22:30 +00:00
|
|
|
*/
|
2020-11-11 23:05:59 +00:00
|
|
|
class DIMENSION_BASE : public BOARD_ITEM
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2013-03-13 18:53:58 +00:00
|
|
|
public:
|
2020-11-11 23:05:59 +00:00
|
|
|
DIMENSION_BASE( BOARD_ITEM* aParent, KICAD_T aType = PCB_DIMENSION_T );
|
2020-09-12 20:09:40 +00:00
|
|
|
|
|
|
|
bool IsType( const KICAD_T aScanTypes[] ) const override
|
|
|
|
{
|
|
|
|
if( BOARD_ITEM::IsType( aScanTypes ) )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
for( const KICAD_T* p = aScanTypes; *p != EOT; ++p )
|
|
|
|
{
|
|
|
|
if( *p == PCB_LOCATE_GRAPHIC_T )
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2012-01-14 19:50:32 +00:00
|
|
|
|
2020-09-12 14:23:07 +00:00
|
|
|
void SetParent( EDA_ITEM* aParent ) override;
|
|
|
|
|
2020-09-09 03:17:08 +00:00
|
|
|
/**
|
|
|
|
* The dimension's origin is the first feature point for the dimension. Every dimension has
|
|
|
|
* one or more feature points, so every dimension has at least an origin.
|
|
|
|
* @return the origin point of this dimension
|
|
|
|
*/
|
|
|
|
virtual const wxPoint& GetStart() const { return m_start; }
|
2021-01-19 16:08:37 +00:00
|
|
|
virtual void SetStart( const wxPoint& aPoint ) { m_start = aPoint; }
|
2012-01-14 19:50:32 +00:00
|
|
|
|
2020-09-09 03:17:08 +00:00
|
|
|
virtual const wxPoint& GetEnd() const { return m_end; }
|
2021-01-19 16:08:37 +00:00
|
|
|
virtual void SetEnd( const wxPoint& aPoint ) { m_end = aPoint; }
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2020-11-03 22:45:26 +00:00
|
|
|
wxPoint GetPosition() const override { return m_start; }
|
|
|
|
void SetPosition( const wxPoint& aPos ) override { m_start = aPos; }
|
2020-09-09 03:17:08 +00:00
|
|
|
|
2020-09-11 23:52:45 +00:00
|
|
|
bool GetOverrideTextEnabled() const { return m_overrideTextEnabled; }
|
|
|
|
void SetOverrideTextEnabled( bool aOverride ) { m_overrideTextEnabled = aOverride; }
|
|
|
|
|
|
|
|
wxString GetOverrideText() const { return m_valueString; }
|
|
|
|
void SetOverrideText( const wxString& aValue ) { m_valueString = aValue; }
|
2020-09-09 03:17:08 +00:00
|
|
|
|
|
|
|
int GetMeasuredValue() const { return m_measuredValue; }
|
|
|
|
|
2020-09-11 02:38:30 +00:00
|
|
|
/**
|
2020-09-11 23:52:45 +00:00
|
|
|
* @return the dimension value, rendered with precision / zero suppression but no units, etc
|
2020-09-11 02:38:30 +00:00
|
|
|
*/
|
2020-09-11 23:52:45 +00:00
|
|
|
wxString GetValueText() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Updates the dimension's cached text and geometry
|
|
|
|
*/
|
|
|
|
void Update()
|
|
|
|
{
|
|
|
|
updateGeometry();
|
|
|
|
updateText();
|
|
|
|
}
|
2018-08-28 20:14:47 +00:00
|
|
|
|
2020-09-09 03:17:08 +00:00
|
|
|
wxString GetPrefix() const { return m_prefix; }
|
2020-09-11 23:52:45 +00:00
|
|
|
void SetPrefix( const wxString& aPrefix );
|
2020-05-15 23:25:33 +00:00
|
|
|
|
2020-09-09 03:17:08 +00:00
|
|
|
wxString GetSuffix() const { return m_suffix; }
|
2020-09-11 23:52:45 +00:00
|
|
|
void SetSuffix( const wxString& aSuffix );
|
2020-05-15 23:25:33 +00:00
|
|
|
|
2020-11-11 23:05:59 +00:00
|
|
|
void GetUnits( EDA_UNITS& aUnits ) const { aUnits = m_units; }
|
2020-10-02 20:51:24 +00:00
|
|
|
void SetUnits( EDA_UNITS aUnits );
|
2013-03-13 18:53:58 +00:00
|
|
|
|
2020-09-09 03:17:08 +00:00
|
|
|
DIM_UNITS_MODE GetUnitsMode() const;
|
|
|
|
void SetUnitsMode( DIM_UNITS_MODE aMode );
|
2013-03-13 18:53:58 +00:00
|
|
|
|
2020-09-09 03:17:08 +00:00
|
|
|
void SetAutoUnits( bool aAuto = true ) { m_autoUnits = aAuto; }
|
2011-11-30 21:15:56 +00:00
|
|
|
|
2020-09-09 03:17:08 +00:00
|
|
|
DIM_UNITS_FORMAT GetUnitsFormat() const { return m_unitsFormat; }
|
|
|
|
void SetUnitsFormat( const DIM_UNITS_FORMAT aFormat ) { m_unitsFormat = aFormat; }
|
2011-11-30 21:15:56 +00:00
|
|
|
|
2020-09-09 03:17:08 +00:00
|
|
|
int GetPrecision() const { return m_precision; }
|
|
|
|
void SetPrecision( int aPrecision ) { m_precision = aPrecision; }
|
2008-04-01 05:21:50 +00:00
|
|
|
|
2020-09-09 03:17:08 +00:00
|
|
|
bool GetSuppressZeroes() const { return m_suppressZeroes; }
|
|
|
|
void SetSuppressZeroes( bool aSuppress ) { m_suppressZeroes = aSuppress; }
|
2009-08-03 07:55:08 +00:00
|
|
|
|
2020-09-09 03:17:08 +00:00
|
|
|
bool GetKeepTextAligned() const { return m_keepTextAligned; }
|
|
|
|
void SetKeepTextAligned( bool aKeepAligned ) { m_keepTextAligned = aKeepAligned; }
|
2011-12-14 04:29:25 +00:00
|
|
|
|
2020-09-09 03:17:08 +00:00
|
|
|
void SetTextPositionMode( DIM_TEXT_POSITION aMode ) { m_textPosition = aMode; }
|
|
|
|
DIM_TEXT_POSITION GetTextPositionMode() const { return m_textPosition; }
|
2011-12-14 04:29:25 +00:00
|
|
|
|
2020-09-09 03:17:08 +00:00
|
|
|
int GetArrowLength() const { return m_arrowLength; }
|
|
|
|
void SetArrowLength( int aLength ) { m_arrowLength = aLength; }
|
2014-02-11 12:22:30 +00:00
|
|
|
|
2020-09-09 03:17:08 +00:00
|
|
|
void SetExtensionOffset( int aOffset ) { m_extensionOffset = aOffset; }
|
|
|
|
int GetExtensionOffset() const { return m_extensionOffset; }
|
2014-02-11 12:22:30 +00:00
|
|
|
|
2020-09-09 03:17:08 +00:00
|
|
|
int GetLineThickness() const { return m_lineThickness; }
|
|
|
|
void SetLineThickness( int aWidth ) { m_lineThickness = aWidth; }
|
2014-02-11 12:22:30 +00:00
|
|
|
|
2020-09-09 03:17:08 +00:00
|
|
|
void SetLayer( PCB_LAYER_ID aLayer ) override;
|
|
|
|
|
|
|
|
void SetTextSize( const wxSize& aTextSize )
|
2014-02-11 12:22:30 +00:00
|
|
|
{
|
2020-09-09 03:17:08 +00:00
|
|
|
m_text.SetTextSize( aTextSize );
|
2014-02-11 12:22:30 +00:00
|
|
|
}
|
|
|
|
|
2020-09-11 23:52:45 +00:00
|
|
|
/**
|
|
|
|
* Sets the override text - has no effect if m_overrideValue == false
|
|
|
|
* @param aNewText is the text to use as the value
|
|
|
|
*/
|
2020-09-09 03:17:08 +00:00
|
|
|
void SetText( const wxString& aNewText );
|
2020-09-11 23:52:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieves the value text or override text, not including prefix or suffix
|
|
|
|
* @return the value portion of the dimension text (either overridden or not)
|
|
|
|
*/
|
2020-09-09 03:17:08 +00:00
|
|
|
const wxString GetText() const;
|
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
PCB_TEXT& Text() { return m_text; }
|
|
|
|
PCB_TEXT& Text() const { return *( const_cast<PCB_TEXT*> ( &m_text ) ); }
|
2020-09-09 03:17:08 +00:00
|
|
|
|
2014-02-11 12:22:30 +00:00
|
|
|
/**
|
2020-09-09 03:17:08 +00:00
|
|
|
* @return a list of line segments that make up this dimension (for drawing, plotting, etc)
|
2014-02-11 12:22:30 +00:00
|
|
|
*/
|
2020-09-12 20:09:40 +00:00
|
|
|
const std::vector<std::shared_ptr<SHAPE>>& GetShapes() const { return m_shapes; }
|
2020-09-09 03:17:08 +00:00
|
|
|
|
|
|
|
// BOARD_ITEM overrides
|
|
|
|
|
|
|
|
void Move( const wxPoint& offset ) override;
|
|
|
|
void Rotate( const wxPoint& aRotCentre, double aAngle ) override;
|
|
|
|
void Flip( const wxPoint& aCentre, bool aFlipLeftRight ) override;
|
2014-03-12 09:46:11 +00:00
|
|
|
|
|
|
|
/**
|
2020-09-09 03:17:08 +00:00
|
|
|
* Mirror the Dimension , relative to a given horizontal axis
|
|
|
|
* the text is not mirrored. only its position (and angle) is mirrored
|
|
|
|
* the layer is not changed
|
|
|
|
* @param axis_pos : vertical axis position
|
2014-03-12 09:46:11 +00:00
|
|
|
*/
|
2020-09-09 03:17:08 +00:00
|
|
|
void Mirror( const wxPoint& axis_pos, bool aMirrorLeftRight = false );
|
|
|
|
|
|
|
|
void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
|
|
|
|
|
|
|
|
bool HitTest( const wxPoint& aPosition, int aAccuracy ) const override;
|
|
|
|
bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
|
|
|
|
|
|
|
|
const EDA_RECT GetBoundingBox() const override;
|
|
|
|
|
2020-09-19 11:47:43 +00:00
|
|
|
std::shared_ptr<SHAPE> GetEffectiveShape( PCB_LAYER_ID aLayer ) const override;
|
|
|
|
|
2020-09-09 03:17:08 +00:00
|
|
|
wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
|
|
|
|
|
2020-09-17 00:54:58 +00:00
|
|
|
const BOX2I ViewBBox() const override;
|
2020-09-09 03:17:08 +00:00
|
|
|
|
2021-02-03 23:33:36 +00:00
|
|
|
void TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer, PCB_LAYER_ID aLayer,
|
|
|
|
int aClearance, int aError, ERROR_LOC aErrorLoc,
|
|
|
|
bool aIgnoreLineWidth ) const override;
|
|
|
|
|
2020-09-09 03:17:08 +00:00
|
|
|
#if defined(DEBUG)
|
|
|
|
virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
|
|
|
|
#endif
|
|
|
|
|
|
|
|
protected:
|
2014-03-12 09:46:11 +00:00
|
|
|
|
|
|
|
/**
|
2020-09-09 03:17:08 +00:00
|
|
|
* Updates the cached geometry of the dimension after changing any of its properties
|
2014-03-12 09:46:11 +00:00
|
|
|
*/
|
2020-09-09 03:17:08 +00:00
|
|
|
virtual void updateGeometry() = 0;
|
2014-02-11 12:22:30 +00:00
|
|
|
|
|
|
|
/**
|
2020-09-09 03:17:08 +00:00
|
|
|
* Updates the text field value from the current geometry (called by updateGeometry normally)
|
2014-02-11 12:22:30 +00:00
|
|
|
*/
|
2020-09-11 23:52:45 +00:00
|
|
|
virtual void updateText();
|
2020-09-09 03:17:08 +00:00
|
|
|
|
2020-09-12 20:09:40 +00:00
|
|
|
template<typename ShapeType>
|
2020-10-01 19:11:35 +00:00
|
|
|
void addShape( const ShapeType& aShape );
|
2020-09-12 20:09:40 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Finds the intersection between a given segment and polygon outline
|
|
|
|
* @param aPoly is the polygon to collide
|
|
|
|
* @param aSeg is the segment to collide
|
|
|
|
* @param aStart if true will start from aSeg.A, otherwise aSeg.B
|
|
|
|
* @return a point on aSeg that collides with aPoly closest to the start, if one exists
|
|
|
|
*/
|
|
|
|
static OPT_VECTOR2I segPolyIntersection( SHAPE_POLY_SET& aPoly, SEG& aSeg, bool aStart = true );
|
|
|
|
|
2020-09-09 03:17:08 +00:00
|
|
|
// Value format
|
2020-09-11 23:52:45 +00:00
|
|
|
bool m_overrideTextEnabled; ///< Manually specify the displayed measurement value
|
|
|
|
wxString m_valueString; ///< Displayed value when m_overrideValue = true
|
2020-09-09 03:17:08 +00:00
|
|
|
wxString m_prefix; ///< String prepended to the value
|
|
|
|
wxString m_suffix; ///< String appended to the value
|
|
|
|
EDA_UNITS m_units; ///< 0 = inches, 1 = mm
|
|
|
|
bool m_autoUnits; ///< If true, follow the currently selected UI units
|
|
|
|
DIM_UNITS_FORMAT m_unitsFormat; ///< How to render the units suffix
|
|
|
|
int m_precision; ///< Number of digits to display after decimal
|
|
|
|
bool m_suppressZeroes; ///< Suppress trailing zeroes
|
|
|
|
|
|
|
|
// Geometry
|
|
|
|
int m_lineThickness; ///< Thickness used for all graphics in the dimension
|
|
|
|
int m_arrowLength; ///< Length of arrow shapes
|
|
|
|
int m_extensionOffset; ///< Distance from feature points to extension line start
|
|
|
|
DIM_TEXT_POSITION m_textPosition; ///< How to position the text
|
|
|
|
bool m_keepTextAligned; ///< Calculate text orientation to match dimension
|
|
|
|
|
|
|
|
// Internal
|
2020-10-04 23:34:59 +00:00
|
|
|
PCB_TEXT m_text; ///< The actual text object
|
2020-09-09 03:17:08 +00:00
|
|
|
int m_measuredValue; ///< value of PCB dimensions
|
|
|
|
wxPoint m_start;
|
|
|
|
wxPoint m_end;
|
|
|
|
|
2020-09-12 20:09:40 +00:00
|
|
|
///< Internal cache of drawn shapes
|
|
|
|
std::vector<std::shared_ptr<SHAPE>> m_shapes;
|
|
|
|
|
|
|
|
static constexpr float s_arrowAngle = 27.5;
|
2020-09-09 03:17:08 +00:00
|
|
|
};
|
2014-02-11 12:22:30 +00:00
|
|
|
|
2020-09-09 03:17:08 +00:00
|
|
|
/**
|
|
|
|
* For better understanding of the points that make a dimension:
|
|
|
|
*
|
|
|
|
* Note: historically KiCad called extension lines "feature lines", and also note that what we
|
|
|
|
* call the "crossbar line" here is more commonly called the "dimension line"
|
|
|
|
*
|
|
|
|
* Start (feature point 1) End (feature point 2)
|
|
|
|
* | |
|
|
|
|
* | <-- extension lines --> |
|
|
|
|
* | |
|
|
|
|
* | m_arrowG2F m_arrowD2F |
|
|
|
|
* | / \ |
|
|
|
|
* Crossbar start |/_______crossbar line________\| Crossbar end
|
|
|
|
* |\ m_text /|
|
|
|
|
* | \ / |
|
|
|
|
* | m_arrowG1F m_arrowD1F |
|
|
|
|
* | |
|
|
|
|
* m_featureLineGF m_featureLineDF
|
|
|
|
*/
|
2014-02-11 12:22:30 +00:00
|
|
|
|
2020-09-09 03:17:08 +00:00
|
|
|
/**
|
|
|
|
* An aligned dimension measures the distance between two feature points. It has a crossbar
|
|
|
|
* (dimension line) that stays parallel with the vector between the feature points.
|
|
|
|
*
|
|
|
|
* The height (distance from features to crossbar) can be set directly, or set by manipulating the
|
|
|
|
* crossbar start or end point (with the point editor).
|
|
|
|
*/
|
2020-11-11 23:05:59 +00:00
|
|
|
class ALIGNED_DIMENSION : public DIMENSION_BASE
|
2020-09-09 03:17:08 +00:00
|
|
|
{
|
2020-09-22 02:32:40 +00:00
|
|
|
protected:
|
2020-09-09 03:17:08 +00:00
|
|
|
// Geometry
|
|
|
|
int m_height; ///< Perpendicular distance from features to crossbar
|
|
|
|
int m_extensionHeight; ///< Length of extension lines past the crossbar
|
2018-07-21 12:49:19 +00:00
|
|
|
|
2020-09-09 03:17:08 +00:00
|
|
|
wxPoint m_crossBarStart; ///< Crossbar start control point
|
|
|
|
wxPoint m_crossBarEnd; ///< Crossbar end control point
|
|
|
|
|
|
|
|
public:
|
2020-09-22 02:32:40 +00:00
|
|
|
ALIGNED_DIMENSION( BOARD_ITEM* aParent, KICAD_T aType = PCB_DIM_ALIGNED_T );
|
2020-09-09 03:17:08 +00:00
|
|
|
|
|
|
|
// Do not create a copy constructor & operator=.
|
|
|
|
// The ones generated by the compiler are adequate.
|
|
|
|
|
|
|
|
~ALIGNED_DIMENSION() = default;
|
|
|
|
|
|
|
|
static inline bool ClassOf( const EDA_ITEM* aItem )
|
2018-07-21 12:49:19 +00:00
|
|
|
{
|
2020-09-12 20:09:40 +00:00
|
|
|
return aItem && PCB_DIM_ALIGNED_T == aItem->Type();
|
2018-07-21 12:49:19 +00:00
|
|
|
}
|
2010-04-23 09:54:40 +00:00
|
|
|
|
2020-09-09 03:17:08 +00:00
|
|
|
EDA_ITEM* Clone() const override;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2020-09-09 03:17:08 +00:00
|
|
|
virtual void SwapData( BOARD_ITEM* aImage ) override;
|
|
|
|
|
2020-09-12 20:09:40 +00:00
|
|
|
BITMAP_DEF GetMenuImage() const override;
|
|
|
|
|
2020-09-09 03:17:08 +00:00
|
|
|
const wxPoint& GetCrossbarStart() const { return m_crossBarStart; }
|
|
|
|
|
|
|
|
const wxPoint& GetCrossbarEnd() const { return m_crossBarEnd; }
|
2013-03-13 18:53:58 +00:00
|
|
|
|
2008-04-01 05:21:50 +00:00
|
|
|
/**
|
2020-09-09 03:17:08 +00:00
|
|
|
* Sets the distance from the feature points to the crossbar line
|
|
|
|
* @param aHeight is the new height.
|
2008-04-01 05:21:50 +00:00
|
|
|
*/
|
2021-01-19 16:08:37 +00:00
|
|
|
void SetHeight( int aHeight ) { m_height = aHeight; }
|
2020-09-09 03:17:08 +00:00
|
|
|
int GetHeight() const { return m_height; }
|
2008-04-01 05:21:50 +00:00
|
|
|
|
|
|
|
/**
|
2020-09-09 03:17:08 +00:00
|
|
|
* Updates stored height basing on points coordinates.
|
|
|
|
* @param aCrossbarStart is the start point of the crossbar
|
2008-04-01 05:21:50 +00:00
|
|
|
*/
|
2020-09-09 03:17:08 +00:00
|
|
|
void UpdateHeight( const wxPoint& aCrossbarStart, const wxPoint& aCrossbarEnd );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2020-09-09 03:17:08 +00:00
|
|
|
void SetExtensionHeight( int aHeight ) { m_extensionHeight = aHeight; }
|
|
|
|
int GetExtensionHeight() const { return m_extensionHeight; }
|
2008-04-01 05:21:50 +00:00
|
|
|
|
2020-09-09 03:17:08 +00:00
|
|
|
/**
|
|
|
|
* Function GetAngle
|
|
|
|
* Returns angle of the crossbar.
|
|
|
|
* @return Angle of the crossbar line expressed in radians.
|
|
|
|
*/
|
|
|
|
double GetAngle() const
|
|
|
|
{
|
|
|
|
wxPoint delta( m_end - m_start );
|
|
|
|
|
|
|
|
return atan2( (double)delta.y, (double)delta.x );
|
|
|
|
}
|
2008-01-06 12:43:57 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
wxString GetClass() const override
|
2007-08-08 20:51:08 +00:00
|
|
|
{
|
2020-09-09 03:17:08 +00:00
|
|
|
return wxT( "ALIGNED_DIMENSION" );
|
2007-08-08 20:51:08 +00:00
|
|
|
}
|
2011-02-25 16:23:24 +00:00
|
|
|
|
2021-01-19 16:08:37 +00:00
|
|
|
void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
|
|
|
|
|
2020-09-09 03:17:08 +00:00
|
|
|
protected:
|
2011-07-14 15:42:44 +00:00
|
|
|
|
2020-09-09 03:17:08 +00:00
|
|
|
void updateGeometry() override;
|
2011-08-01 15:29:27 +00:00
|
|
|
|
2020-09-09 03:17:08 +00:00
|
|
|
void updateText() override;
|
2007-06-05 12:10:51 +00:00
|
|
|
};
|
|
|
|
|
2020-09-12 20:09:40 +00:00
|
|
|
|
2020-09-22 02:32:40 +00:00
|
|
|
/**
|
|
|
|
* An orthogonal dimension is like an aligned dimension, but the extension lines are locked to the
|
|
|
|
* X or Y axes, and the measurement is only taken in the X or Y direction.
|
|
|
|
*/
|
|
|
|
class ORTHOGONAL_DIMENSION : public ALIGNED_DIMENSION
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum class DIR
|
|
|
|
{
|
|
|
|
HORIZONTAL, // Aligned with x-axis
|
|
|
|
VERTICAL // Aligned with y-axis
|
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
|
|
|
// Geometry
|
|
|
|
DIR m_orientation; ///< What axis to lock the dimension line to
|
|
|
|
|
|
|
|
public:
|
|
|
|
ORTHOGONAL_DIMENSION( BOARD_ITEM* aParent );
|
|
|
|
|
|
|
|
~ORTHOGONAL_DIMENSION() = default;
|
|
|
|
|
|
|
|
static inline bool ClassOf( const EDA_ITEM* aItem )
|
|
|
|
{
|
|
|
|
return aItem && PCB_DIM_ORTHOGONAL_T == aItem->Type();
|
|
|
|
}
|
|
|
|
|
|
|
|
EDA_ITEM* Clone() const override;
|
|
|
|
|
|
|
|
void SwapData( BOARD_ITEM* aImage ) override;
|
|
|
|
|
|
|
|
BITMAP_DEF GetMenuImage() const override;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the orientation of the dimension line (so, perpendicular to the feature lines)
|
|
|
|
* @param aOrientation is the orientation the dimension should take
|
|
|
|
*/
|
|
|
|
void SetOrientation( DIR aOrientation ) { m_orientation = aOrientation; }
|
|
|
|
DIR GetOrientation() const { return m_orientation; }
|
|
|
|
|
|
|
|
wxString GetClass() const override
|
|
|
|
{
|
|
|
|
return wxT( "ORTHOGONAL_DIMENSION" );
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
void updateGeometry() override;
|
|
|
|
|
|
|
|
void updateText() override;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-09-12 20:09:40 +00:00
|
|
|
/**
|
|
|
|
* A leader is a dimension-like object pointing to a specific point.
|
|
|
|
*
|
|
|
|
* A guide to the geometry of a leader:
|
|
|
|
*
|
|
|
|
* a
|
|
|
|
* _
|
|
|
|
* |\
|
|
|
|
* \
|
|
|
|
* b---c TEXT
|
|
|
|
*
|
|
|
|
* Point (a) is m_start, point (b) is m_end, point (c) is the end of the "text line"
|
|
|
|
* The b-c line is drawn from b to the text center, and clipped on the text bounding box.
|
|
|
|
*/
|
2020-11-11 23:05:59 +00:00
|
|
|
class LEADER : public DIMENSION_BASE
|
2020-09-12 20:09:40 +00:00
|
|
|
{
|
|
|
|
DIM_TEXT_FRAME m_textFrame;
|
|
|
|
|
|
|
|
public:
|
|
|
|
LEADER( BOARD_ITEM* aParent );
|
|
|
|
|
|
|
|
static inline bool ClassOf( const EDA_ITEM* aItem )
|
|
|
|
{
|
|
|
|
return aItem && PCB_DIM_LEADER_T == aItem->Type();
|
|
|
|
}
|
|
|
|
|
|
|
|
EDA_ITEM* Clone() const override;
|
|
|
|
|
|
|
|
virtual void SwapData( BOARD_ITEM* aImage ) override;
|
|
|
|
|
|
|
|
BITMAP_DEF GetMenuImage() const override;
|
|
|
|
|
|
|
|
wxString GetClass() const override
|
|
|
|
{
|
|
|
|
return wxT( "LEADER" );
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetTextFrame( DIM_TEXT_FRAME aFrame ) { m_textFrame = aFrame; }
|
|
|
|
DIM_TEXT_FRAME GetTextFrame() const { return m_textFrame; }
|
|
|
|
|
2020-09-24 21:23:16 +00:00
|
|
|
void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
|
|
|
|
|
2020-09-12 20:09:40 +00:00
|
|
|
protected:
|
|
|
|
|
|
|
|
void updateGeometry() override;
|
|
|
|
};
|
|
|
|
|
2020-09-17 00:54:58 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Marks the center of a circle or arc with a cross shape
|
|
|
|
* The size and orientation of the cross is adjustable.
|
|
|
|
* m_start always marks the center being measured; m_end marks the end of one leg of the cross.
|
|
|
|
*/
|
2020-11-11 23:05:59 +00:00
|
|
|
class CENTER_DIMENSION : public DIMENSION_BASE
|
2020-09-17 00:54:58 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
|
|
|
CENTER_DIMENSION( BOARD_ITEM* aParent );
|
|
|
|
|
|
|
|
static inline bool ClassOf( const EDA_ITEM* aItem )
|
|
|
|
{
|
|
|
|
return aItem && PCB_DIM_CENTER_T == aItem->Type();
|
|
|
|
}
|
|
|
|
|
|
|
|
EDA_ITEM* Clone() const override;
|
|
|
|
|
|
|
|
virtual void SwapData( BOARD_ITEM* aImage ) override;
|
|
|
|
|
|
|
|
BITMAP_DEF GetMenuImage() const override;
|
|
|
|
|
|
|
|
wxString GetClass() const override
|
|
|
|
{
|
|
|
|
return wxT( "CENTER_DIMENSION" );
|
|
|
|
}
|
|
|
|
|
|
|
|
const EDA_RECT GetBoundingBox() const override;
|
|
|
|
|
|
|
|
const BOX2I ViewBBox() const override;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
void updateGeometry() override;
|
|
|
|
};
|
|
|
|
|
2020-11-11 23:05:59 +00:00
|
|
|
#endif // DIMENSION_H
|