2012-01-14 19:50:32 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2018-07-22 12:50:35 +00:00
|
|
|
* Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2013-05-01 19:01:14 +00:00
|
|
|
* Copyright (C) 2013 Wayne Stambaugh <stambaughw@verizon.net>
|
2018-07-22 12:50:35 +00:00
|
|
|
* Copyright (C) 1992-2018 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-10-04 23:34:59 +00:00
|
|
|
#ifndef FP_SHAPE_H
|
|
|
|
#define FP_SHAPE_H
|
2011-08-01 15:29:27 +00:00
|
|
|
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2013-11-19 18:58:12 +00:00
|
|
|
#include <wx/gdicmn.h>
|
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
#include <pcb_shape.h>
|
2011-01-14 17:43:30 +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
|
|
|
|
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
class FP_SHAPE : public PCB_SHAPE
|
2007-08-06 20:26:59 +00:00
|
|
|
{
|
|
|
|
public:
|
2021-07-21 18:31:25 +00:00
|
|
|
FP_SHAPE( FOOTPRINT* parent, SHAPE_T aShape = SHAPE_T::SEGMENT );
|
2012-01-14 19:50:32 +00:00
|
|
|
|
2016-05-30 08:44:48 +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
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
~FP_SHAPE();
|
2007-08-06 20:26:59 +00:00
|
|
|
|
2014-06-06 09:44:21 +00:00
|
|
|
static inline bool ClassOf( const EDA_ITEM* aItem )
|
|
|
|
{
|
2020-10-04 14:19:33 +00:00
|
|
|
return aItem && PCB_FP_SHAPE_T == aItem->Type();
|
2014-06-06 09:44:21 +00:00
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
else if( *p == PCB_LOCATE_BOARD_EDGE_T )
|
2020-11-14 14:29:11 +00:00
|
|
|
return m_layer == Edge_Cuts;
|
2020-05-15 23:25:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-02-08 09:11:04 +00:00
|
|
|
/**
|
|
|
|
* Sets the angle for arcs, and normalizes it within the range 0 - 360 degrees.
|
|
|
|
* @param aAngle is tenths of degrees, but will soon be degrees.
|
|
|
|
* @param aUpdateEnd = true to update also arc end coordinates m_thirdPoint and
|
2021-07-18 12:31:56 +00:00
|
|
|
* m_thirdPoint0, so must be called after setting m_Start, m_start0, m_End and m_end0
|
2021-02-08 09:11:04 +00:00
|
|
|
*/
|
2020-10-08 09:59:17 +00:00
|
|
|
void SetAngle( double aAngle, bool aUpdateEnd = true ) override;
|
2020-08-15 15:42:18 +00:00
|
|
|
|
2015-07-31 19:04:30 +00:00
|
|
|
/**
|
|
|
|
* Move an edge of the footprint.
|
|
|
|
* This is a footprint shape modification.
|
|
|
|
* (should be only called by a footprint editing function)
|
|
|
|
*/
|
2016-09-24 18:53:15 +00:00
|
|
|
void Move( const wxPoint& aMoveVector ) override;
|
2015-07-31 19:04:30 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Mirror an edge of the footprint.
|
|
|
|
* Do not change the layer
|
|
|
|
* This is a footprint shape modification.
|
|
|
|
* (should be only called by a footprint editing function)
|
|
|
|
*/
|
2020-02-02 17:52:19 +00:00
|
|
|
void Mirror( const wxPoint& aCentre, bool aMirrorAroundXAxis );
|
2015-07-31 19:04:30 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Rotate an edge of the footprint.
|
|
|
|
* This is a footprint shape modification.
|
|
|
|
* (should be only called by a footprint editing function )
|
|
|
|
*/
|
2016-09-24 18:53:15 +00:00
|
|
|
void Rotate( const wxPoint& aRotCentre, double aAngle ) override;
|
2015-07-31 19:04:30 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Flip entity relative to aCentre.
|
2020-11-13 21:07:01 +00:00
|
|
|
* The item is mirrored, and layer changed to the paired corresponding layer if it is on a
|
|
|
|
* paired layer.
|
|
|
|
* This function should be called only from FOOTPRINT::Flip because it is not usual to flip
|
2020-03-16 15:47:01 +00:00
|
|
|
* an item alone, without flipping the parent footprint (consider Mirror() instead).
|
2015-07-31 19:04:30 +00:00
|
|
|
*/
|
2019-07-12 21:02:10 +00:00
|
|
|
void Flip( const wxPoint& aCentre, bool aFlipLeftRight ) override;
|
2014-09-24 16:42:56 +00:00
|
|
|
|
2018-02-17 18:03:22 +00:00
|
|
|
bool IsParentFlipped() const;
|
|
|
|
|
2021-07-18 12:31:56 +00:00
|
|
|
void SetStart0( const wxPoint& aPoint ) { m_start0 = aPoint; }
|
|
|
|
const wxPoint& GetStart0() const { return m_start0; }
|
2011-12-14 04:29:25 +00:00
|
|
|
|
2021-07-18 12:31:56 +00:00
|
|
|
void SetEnd0( const wxPoint& aPoint ) { m_end0 = aPoint; }
|
|
|
|
const wxPoint& GetEnd0() const { return m_end0; }
|
2007-08-06 20:26:59 +00:00
|
|
|
|
2021-07-18 12:31:56 +00:00
|
|
|
void SetThirdPoint0( const wxPoint& aPoint ){ m_thirdPoint0 = aPoint; }
|
|
|
|
const wxPoint& GetThirdPoint0() const { return m_thirdPoint0; }
|
2020-08-15 15:42:18 +00:00
|
|
|
|
2021-07-18 12:31:56 +00:00
|
|
|
void SetBezierC1_0( const wxPoint& aPoint ) { m_bezierC1_0 = aPoint; }
|
|
|
|
const wxPoint& GetBezierC1_0() const { return m_bezierC1_0; }
|
2018-07-07 11:04:01 +00:00
|
|
|
|
2021-07-18 12:31:56 +00:00
|
|
|
void SetBezierC2_0( const wxPoint& aPoint ) { m_bezierC2_0 = aPoint; }
|
|
|
|
const wxPoint& GetBezierC2_0() const { return m_bezierC2_0; }
|
2018-07-07 11:04:01 +00:00
|
|
|
|
2015-07-31 19:04:30 +00:00
|
|
|
/**
|
|
|
|
* Set relative coordinates from draw coordinates.
|
2020-03-16 15:47:01 +00:00
|
|
|
* Call in only when the geometry or the footprint is modified and therefore the relative
|
|
|
|
* coordinates have to be updated from the draw coordinates.
|
2015-07-31 19:04:30 +00:00
|
|
|
*/
|
2014-07-09 09:59:24 +00:00
|
|
|
void SetLocalCoord();
|
|
|
|
|
2015-07-31 19:04:30 +00:00
|
|
|
/**
|
|
|
|
* Set draw coordinates (absolute values ) from relative coordinates.
|
2020-03-16 15:47:01 +00:00
|
|
|
* Must be called when a relative coordinate has changed in order to see the changes on screen
|
2015-07-31 19:04:30 +00:00
|
|
|
*/
|
2011-09-17 15:31:21 +00:00
|
|
|
void SetDrawCoord();
|
2007-08-06 20:26:59 +00:00
|
|
|
|
2020-04-24 13:36:10 +00:00
|
|
|
void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
|
2008-02-22 17:34:11 +00:00
|
|
|
|
2016-09-25 17:06:49 +00:00
|
|
|
wxString GetClass() const override
|
2007-08-07 06:21:19 +00:00
|
|
|
{
|
2007-08-08 20:51:08 +00:00
|
|
|
return wxT( "MGRAPHIC" );
|
2007-08-07 06:21:19 +00:00
|
|
|
}
|
|
|
|
|
2021-02-19 21:06:28 +00:00
|
|
|
wxString GetParentAsString() const { return m_parent->m_Uuid.AsString(); }
|
|
|
|
|
2019-12-20 14:11:39 +00:00
|
|
|
wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
|
2008-05-05 19:53:31 +00:00
|
|
|
|
2021-03-08 02:59:07 +00:00
|
|
|
BITMAPS GetMenuImage() const override;
|
2011-08-01 15:29:27 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
EDA_ITEM* Clone() const override;
|
2012-03-17 14:39:27 +00:00
|
|
|
|
2020-09-21 15:03:08 +00:00
|
|
|
double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
|
2015-02-28 17:39:05 +00:00
|
|
|
|
2007-09-13 11:28:58 +00:00
|
|
|
#if defined(DEBUG)
|
2016-09-25 17:06:49 +00:00
|
|
|
void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
|
2007-08-06 20:26:59 +00:00
|
|
|
#endif
|
2012-05-30 21:40:32 +00:00
|
|
|
|
2021-07-18 12:31:56 +00:00
|
|
|
protected:
|
|
|
|
wxPoint m_start0; ///< Start point or circle center, relative to footprint origin, orient 0.
|
|
|
|
wxPoint m_end0; ///< End point or circle edge, relative to footprint origin, orient 0.
|
|
|
|
wxPoint m_thirdPoint0; ///< End point for an arc.
|
|
|
|
wxPoint m_bezierC1_0; ///< Bezier Control Point 1, relative to footprint origin, orient 0.
|
|
|
|
wxPoint m_bezierC2_0; ///< Bezier Control Point 2, relative to footprint origin, orient 0.
|
2007-06-05 12:10:51 +00:00
|
|
|
};
|
2011-08-01 15:29:27 +00:00
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
#endif // FP_SHAPE_H
|