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
|
2017-06-13 23:47:05 +00:00
|
|
|
* Copyright (C) 1992-2017 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
|
|
|
|
*/
|
|
|
|
|
2011-09-20 15:07:52 +00:00
|
|
|
/**
|
|
|
|
* @file class_dimension.h
|
|
|
|
* @brief DIMENSION class definition.
|
|
|
|
*/
|
2011-08-01 15:29:27 +00:00
|
|
|
|
2011-12-14 04:29:25 +00:00
|
|
|
#ifndef DIMENSION_H_
|
|
|
|
#define DIMENSION_H_
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_board_item.h>
|
2012-06-09 17:00:13 +00:00
|
|
|
#include <class_pcb_text.h>
|
2011-09-20 15:07:52 +00:00
|
|
|
|
|
|
|
|
2011-09-23 13:57:12 +00:00
|
|
|
class LINE_READER;
|
|
|
|
class TEXTE_PCB;
|
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
|
|
|
|
2014-02-11 12:22:30 +00:00
|
|
|
/**
|
2020-01-10 14:31:00 +00:00
|
|
|
* DIMENSION
|
2014-02-11 12:22:30 +00:00
|
|
|
*
|
|
|
|
* For better understanding of the points that make a dimension:
|
|
|
|
*
|
|
|
|
* m_featureLineGO m_featureLineDO
|
|
|
|
* | |
|
|
|
|
* | |
|
|
|
|
* | |
|
|
|
|
* | m_arrowG2F m_arrowD2F |
|
|
|
|
* | / \ |
|
|
|
|
* m_crossBarO|/____________________________\|m_crossBarF
|
|
|
|
* |\ m_Text /|
|
|
|
|
* | \ / |
|
|
|
|
* | m_arrowG1F m_arrowD1F |
|
|
|
|
* | |
|
|
|
|
* m_featureLineGF m_featureLineDF
|
|
|
|
*/
|
2010-04-23 09:54:40 +00:00
|
|
|
class DIMENSION : public BOARD_ITEM
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2014-03-12 09:46:11 +00:00
|
|
|
int m_Width; ///< Line width
|
|
|
|
int m_Shape; ///< Currently always 0.
|
2019-12-20 14:11:39 +00:00
|
|
|
EDA_UNITS m_Unit; ///< 0 = inches, 1 = mm
|
2018-07-21 12:49:19 +00:00
|
|
|
bool m_UseMils; ///< If inches, use mils.
|
2014-03-12 09:46:11 +00:00
|
|
|
int m_Value; ///< value of PCB dimensions.
|
|
|
|
int m_Height; ///< length of feature lines
|
2012-12-19 19:31:36 +00:00
|
|
|
TEXTE_PCB m_Text;
|
|
|
|
|
2013-03-13 18:53:58 +00:00
|
|
|
public:
|
2014-02-11 12:22:30 +00:00
|
|
|
// TODO private: These member should be private. they are public only due to legacy code
|
2012-12-19 19:31:36 +00:00
|
|
|
wxPoint m_crossBarO, m_crossBarF;
|
|
|
|
wxPoint m_featureLineGO, m_featureLineGF;
|
|
|
|
wxPoint m_featureLineDO, m_featureLineDF;
|
2014-02-11 12:22:30 +00:00
|
|
|
wxPoint m_arrowD1F, m_arrowD2F;
|
|
|
|
wxPoint m_arrowG1F, m_arrowG2F;
|
2013-03-13 18:53:58 +00:00
|
|
|
|
2010-04-23 09:54:40 +00:00
|
|
|
DIMENSION( BOARD_ITEM* aParent );
|
2012-01-14 19:50:32 +00:00
|
|
|
|
2016-05-31 08:27:52 +00:00
|
|
|
// Do not create a copy constructor & operator=.
|
|
|
|
// The ones generated by the compiler are adequate.
|
2012-01-14 19:50:32 +00:00
|
|
|
|
2010-04-23 09:54:40 +00:00
|
|
|
~DIMENSION();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2018-08-28 20:14:47 +00:00
|
|
|
static inline bool ClassOf( const EDA_ITEM* aItem )
|
|
|
|
{
|
|
|
|
return aItem && PCB_DIMENSION_T == aItem->Type();
|
|
|
|
}
|
|
|
|
|
2020-05-15 23:25:33 +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;
|
|
|
|
}
|
|
|
|
|
2013-03-13 18:53:58 +00:00
|
|
|
void SetValue( int aValue ) { m_Value = aValue; }
|
|
|
|
|
|
|
|
int GetValue() const { return m_Value; }
|
|
|
|
|
2017-12-18 17:24:25 +00:00
|
|
|
const wxPoint GetPosition() const override;
|
2011-11-30 21:15:56 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
void SetPosition( const wxPoint& aPos ) override;
|
2011-11-30 21:15:56 +00:00
|
|
|
|
|
|
|
void SetTextSize( const wxSize& aTextSize )
|
2007-12-01 03:42:52 +00:00
|
|
|
{
|
2017-01-23 20:30:11 +00:00
|
|
|
m_Text.SetTextSize( aTextSize );
|
2007-12-01 03:42:52 +00:00
|
|
|
}
|
2008-04-01 05:21:50 +00:00
|
|
|
|
2017-03-13 03:19:33 +00:00
|
|
|
void SetLayer( PCB_LAYER_ID aLayer ) override;
|
2009-08-03 07:55:08 +00:00
|
|
|
|
2011-12-14 04:29:25 +00:00
|
|
|
void SetShape( int aShape ) { m_Shape = aShape; }
|
2017-01-23 20:30:11 +00:00
|
|
|
int GetShape() const { return m_Shape; }
|
2011-12-14 04:29:25 +00:00
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
int GetWidth() const { return m_Width; }
|
2011-12-14 04:29:25 +00:00
|
|
|
void SetWidth( int aWidth ) { m_Width = aWidth; }
|
|
|
|
|
2014-02-11 12:22:30 +00:00
|
|
|
/**
|
|
|
|
* Function SetOrigin
|
|
|
|
* Sets a new origin of the crossbar line. All remaining lines are adjusted after that.
|
|
|
|
* @param aOrigin is the new point to be used as the new origin of the crossbar line.
|
2019-10-31 23:25:50 +00:00
|
|
|
* @param aPrecision number of decimal places for mils (scaled appropriately for other units).
|
2014-02-11 12:22:30 +00:00
|
|
|
*/
|
2019-10-31 23:25:50 +00:00
|
|
|
void SetOrigin( const wxPoint& aOrigin, int aPrecision );
|
2014-02-11 12:22:30 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function GetOrigin
|
|
|
|
* @return Origin of the crossbar line.
|
|
|
|
*/
|
|
|
|
const wxPoint& GetOrigin() const
|
|
|
|
{
|
2014-03-12 09:46:11 +00:00
|
|
|
return m_featureLineGO;
|
2014-02-11 12:22:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function SetEnd
|
|
|
|
* Sets a new end of the crossbar line. All remaining lines are adjusted after that.
|
|
|
|
* @param aEnd is the new point to be used as the new end of the crossbar line.
|
2019-10-31 23:25:50 +00:00
|
|
|
* @param aPrecision number of decimal places for mils (scaled appropriately for other units).
|
2014-02-11 12:22:30 +00:00
|
|
|
*/
|
2019-10-31 23:25:50 +00:00
|
|
|
void SetEnd( const wxPoint& aEnd, int aPrecision );
|
2014-02-11 12:22:30 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function GetEnd
|
|
|
|
* @return End of the crossbar line.
|
|
|
|
*/
|
|
|
|
const wxPoint& GetEnd()
|
|
|
|
{
|
2014-03-12 09:46:11 +00:00
|
|
|
return m_featureLineDO;
|
2014-02-11 12:22:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function SetHeight
|
|
|
|
* Sets the length of feature lines.
|
|
|
|
* @param aHeight is the new height.
|
2019-10-31 23:25:50 +00:00
|
|
|
* @param aPrecision number of decimal places for mils (scaled appropriately for other units).
|
2014-02-11 12:22:30 +00:00
|
|
|
*/
|
2019-10-31 23:25:50 +00:00
|
|
|
void SetHeight( int aHeight, int aPrecision );
|
2014-03-12 09:46:11 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function GetHeight
|
|
|
|
* Returns the length of feature lines.
|
|
|
|
*/
|
|
|
|
int GetHeight() const
|
|
|
|
{
|
|
|
|
return m_Height;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function UpdateHeight
|
|
|
|
* Updates stored height basing on points coordinates.
|
|
|
|
*/
|
|
|
|
void UpdateHeight();
|
2014-02-11 12:22:30 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function GetAngle
|
|
|
|
* Returns angle of the crossbar.
|
2014-03-12 09:46:11 +00:00
|
|
|
* @return Angle of the crossbar line expressed in radians.
|
2014-02-11 12:22:30 +00:00
|
|
|
*/
|
|
|
|
double GetAngle() const
|
|
|
|
{
|
|
|
|
wxPoint delta( m_featureLineDO - m_featureLineGO );
|
|
|
|
|
2016-01-17 15:59:24 +00:00
|
|
|
return atan2( (double)delta.y, (double)delta.x );
|
2014-02-11 12:22:30 +00:00
|
|
|
}
|
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
|
|
|
* Function AdjustDimensionDetails
|
2010-04-23 09:54:40 +00:00
|
|
|
* Calculate coordinates of segments used to draw the dimension.
|
2019-10-31 23:25:50 +00:00
|
|
|
* @param aPrecision number of decimal places for mils (scaled appropriately for other units).
|
2010-04-23 09:54:40 +00:00
|
|
|
*/
|
2019-10-31 23:25:50 +00:00
|
|
|
void AdjustDimensionDetails( int aPrecision );
|
2018-07-21 12:49:19 +00:00
|
|
|
|
2019-12-20 14:11:39 +00:00
|
|
|
void GetUnits( EDA_UNITS& aUnits, bool& aUseMils ) const
|
2018-07-21 12:49:19 +00:00
|
|
|
{
|
|
|
|
aUnits = m_Unit;
|
|
|
|
aUseMils = m_UseMils;
|
|
|
|
}
|
|
|
|
|
2019-12-20 14:11:39 +00:00
|
|
|
void SetUnits( EDA_UNITS aUnits, bool aUseMils )
|
2018-07-21 12:49:19 +00:00
|
|
|
{
|
|
|
|
m_Unit = aUnits;
|
|
|
|
m_UseMils = aUseMils;
|
|
|
|
}
|
2010-04-23 09:54:40 +00:00
|
|
|
|
2012-12-19 19:31:36 +00:00
|
|
|
void SetText( const wxString& NewText );
|
|
|
|
const wxString GetText() const;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2013-03-13 18:53:58 +00:00
|
|
|
TEXTE_PCB& Text() { return m_Text; }
|
|
|
|
TEXTE_PCB& Text() const { return *(const_cast<TEXTE_PCB*> (&m_Text)); }
|
|
|
|
|
2008-04-01 05:21:50 +00:00
|
|
|
/**
|
|
|
|
* Function Move
|
|
|
|
* @param offset : moving vector
|
|
|
|
*/
|
2016-09-24 18:53:15 +00:00
|
|
|
void Move( const wxPoint& offset ) override;
|
|
|
|
void Rotate( const wxPoint& aRotCentre, double aAngle ) override;
|
2019-07-12 21:02:10 +00:00
|
|
|
void Flip( const wxPoint& aCentre, bool aFlipLeftRight ) override;
|
2008-04-01 05:21:50 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function Mirror
|
|
|
|
* 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
|
|
|
|
*/
|
2019-07-12 21:02:10 +00:00
|
|
|
void Mirror( const wxPoint& axis_pos, bool aMirrorLeftRight = false );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2020-04-24 13:36:10 +00:00
|
|
|
void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
|
2008-04-01 05:21:50 +00:00
|
|
|
|
2019-05-05 10:33:34 +00:00
|
|
|
bool HitTest( const wxPoint& aPosition, int aAccuracy ) const override;
|
|
|
|
bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
|
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
|
|
|
{
|
|
|
|
return wxT( "DIMENSION" );
|
|
|
|
}
|
2011-02-25 16:23:24 +00:00
|
|
|
|
2013-11-24 17:48:14 +00:00
|
|
|
// Virtual function
|
2019-05-05 10:33:34 +00:00
|
|
|
const EDA_RECT GetBoundingBox() const override;
|
2011-07-14 15:42:44 +00:00
|
|
|
|
2019-12-20 14:11:39 +00:00
|
|
|
wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
|
2011-08-01 15:29:27 +00:00
|
|
|
|
2017-02-20 12:20:39 +00:00
|
|
|
BITMAP_DEF GetMenuImage() const override;
|
2011-12-14 17:25:42 +00:00
|
|
|
|
2019-05-05 10:33:34 +00:00
|
|
|
EDA_ITEM* Clone() const override;
|
2012-03-17 14:39:27 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
virtual const BOX2I ViewBBox() const override;
|
2013-09-16 12:44:03 +00:00
|
|
|
|
2017-10-31 13:59:03 +00:00
|
|
|
virtual void SwapData( BOARD_ITEM* aImage ) override;
|
|
|
|
|
2011-12-14 17:25:42 +00:00
|
|
|
#if defined(DEBUG)
|
2016-09-24 18:53:15 +00:00
|
|
|
virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
|
2011-12-14 17:25:42 +00:00
|
|
|
#endif
|
2007-06-05 12:10:51 +00:00
|
|
|
};
|
|
|
|
|
2012-12-19 19:31:36 +00:00
|
|
|
#endif // DIMENSION_H_
|