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
|
2021-06-04 13:04:30 +00:00
|
|
|
* Copyright (C) 1992-2021 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 PCB_SHAPE_H
|
|
|
|
#define PCB_SHAPE_H
|
2011-08-01 15:29:27 +00:00
|
|
|
|
2020-11-14 18:11:28 +00:00
|
|
|
#include <board_item.h>
|
2021-07-14 20:03:32 +00:00
|
|
|
#include <eda_shape.h>
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2020-07-02 16:06:09 +00:00
|
|
|
|
2011-09-23 13:57:12 +00:00
|
|
|
class LINE_READER;
|
|
|
|
class EDA_DRAW_FRAME;
|
2020-11-13 15:15:52 +00:00
|
|
|
class FOOTPRINT;
|
2013-01-12 17:32:24 +00:00
|
|
|
class MSG_PANEL_ITEM;
|
2008-01-16 18:48:04 +00:00
|
|
|
|
2011-08-01 15:29:27 +00:00
|
|
|
|
2021-07-14 20:03:32 +00:00
|
|
|
class PCB_SHAPE : public BOARD_ITEM, public EDA_SHAPE
|
2008-01-16 18:48:04 +00:00
|
|
|
{
|
|
|
|
public:
|
2021-07-17 18:52:13 +00:00
|
|
|
PCB_SHAPE( BOARD_ITEM* aParent, KICAD_T idtype, SHAPE_T shapetype );
|
|
|
|
|
|
|
|
PCB_SHAPE( BOARD_ITEM* aParent = NULL, SHAPE_T shapetype = 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
|
|
|
~PCB_SHAPE();
|
2008-01-16 18:48:04 +00:00
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
static inline bool ClassOf( const EDA_ITEM* aItem )
|
2015-02-17 23:53:57 +00:00
|
|
|
{
|
2020-10-04 14:19:33 +00:00
|
|
|
return aItem && PCB_SHAPE_T == aItem->Type();
|
2015-02-17 23:53:57 +00:00
|
|
|
}
|
|
|
|
|
2021-07-14 20:03:32 +00:00
|
|
|
wxString GetClass() const override
|
|
|
|
{
|
|
|
|
return wxT( "PCB_SHAPE" );
|
|
|
|
}
|
|
|
|
|
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-07-17 19:56:18 +00:00
|
|
|
void SetPosition( const wxPoint& aPos ) override { setPosition( aPos ); }
|
|
|
|
wxPoint GetPosition() const override { return getPosition(); }
|
2020-11-14 07:51:21 +00:00
|
|
|
|
2021-07-14 20:03:32 +00:00
|
|
|
wxPoint GetCenter() const override { return getCenter(); }
|
2011-11-29 03:08:14 +00:00
|
|
|
|
2011-12-02 21:56:47 +00:00
|
|
|
/**
|
2021-07-14 20:03:32 +00:00
|
|
|
* Allows items to return their visual center rather than their anchor. For some shapes this
|
|
|
|
* is similar to GetCenter(), but for unfilled shapes a point on the outline is better.
|
2021-07-22 08:36:57 +00:00
|
|
|
*/
|
|
|
|
const wxPoint GetFocusPosition() const override;
|
2020-06-22 22:17:21 +00:00
|
|
|
|
2011-08-08 23:50:55 +00:00
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* Return the parent footprint or NULL if PCB_SHAPE does not belong to a footprint.
|
|
|
|
*
|
|
|
|
* @return the parent footprint or NULL.
|
2011-08-08 23:50:55 +00:00
|
|
|
*/
|
2020-11-13 15:15:52 +00:00
|
|
|
FOOTPRINT* GetParentFootprint() const;
|
2011-08-08 23:50:55 +00:00
|
|
|
|
2020-07-02 16:06:09 +00:00
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* Make a set of SHAPE objects representing the PCB_SHAPE. Caller owns the objects.
|
2020-07-02 16:06:09 +00:00
|
|
|
*/
|
2020-11-14 14:14:34 +00:00
|
|
|
std::shared_ptr<SHAPE> GetEffectiveShape( PCB_LAYER_ID aLayer = UNDEFINED_LAYER ) const override;
|
2020-07-02 16:06:09 +00:00
|
|
|
|
2020-04-24 13:36:10 +00:00
|
|
|
void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
|
2008-01-16 18:48:04 +00:00
|
|
|
|
2021-07-14 20:03:32 +00:00
|
|
|
const EDA_RECT GetBoundingBox() const override { return getBoundingBox(); }
|
2008-01-16 18:48:04 +00:00
|
|
|
|
2021-07-14 20:03:32 +00:00
|
|
|
bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override
|
2008-01-16 18:48:04 +00:00
|
|
|
{
|
2021-07-14 20:03:32 +00:00
|
|
|
return hitTest( aPosition, aAccuracy );
|
2008-01-16 18:48:04 +00:00
|
|
|
}
|
2008-01-22 20:36:46 +00:00
|
|
|
|
2021-07-14 20:03:32 +00:00
|
|
|
bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override
|
|
|
|
{
|
|
|
|
return hitTest( aRect, aContained, aAccuracy );
|
|
|
|
}
|
2008-05-05 19:46:54 +00:00
|
|
|
|
2017-12-18 17:24:25 +00:00
|
|
|
virtual void Move( const wxPoint& aMoveVector ) override;
|
2009-08-01 19:26:05 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
virtual void Rotate( const wxPoint& aRotCentre, double aAngle ) override;
|
2009-08-01 19:26:05 +00:00
|
|
|
|
2019-07-12 21:02:10 +00:00
|
|
|
virtual void Flip( const wxPoint& aCentre, bool aFlipLeftRight ) override;
|
2009-11-16 08:13:40 +00:00
|
|
|
|
2020-06-24 11:12:39 +00:00
|
|
|
void Scale( double aScale );
|
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
2021-07-14 20:03:32 +00:00
|
|
|
* Convert the shape to a closed polygon.
|
2021-06-04 13:04:30 +00:00
|
|
|
*
|
|
|
|
* Used in filling zones calculations. Circles and arcs are approximated by segments.
|
|
|
|
*
|
|
|
|
* @param aCornerBuffer is a buffer to store the polygon.
|
|
|
|
* @param aClearanceValue is the clearance around the pad.
|
|
|
|
* @param aError is the maximum deviation from a true arc.
|
2021-07-14 20:03:32 +00:00
|
|
|
* @param aErrorLoc whether any approximation error shoule be placed inside or outside
|
2021-06-04 13:04:30 +00:00
|
|
|
* @param ignoreLineWidth is used for edge cut items where the line width is only
|
|
|
|
* for visualization
|
2009-11-16 08:13:40 +00:00
|
|
|
*/
|
2020-10-13 10:55:24 +00:00
|
|
|
void TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer,
|
|
|
|
PCB_LAYER_ID aLayer, int aClearanceValue,
|
|
|
|
int aError, ERROR_LOC aErrorLoc,
|
2020-08-12 21:18:13 +00:00
|
|
|
bool ignoreLineWidth = false ) const override;
|
2011-07-14 15:42:44 +00:00
|
|
|
|
2019-12-20 14:11:39 +00:00
|
|
|
virtual wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
|
2008-05-05 19:46:54 +00:00
|
|
|
|
2021-03-08 02:59:07 +00:00
|
|
|
virtual BITMAPS GetMenuImage() const override;
|
2011-08-01 15:29:27 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
virtual 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;
|
2015-09-03 21:05:01 +00:00
|
|
|
|
2017-10-31 13:59:03 +00:00
|
|
|
virtual void SwapData( BOARD_ITEM* aImage ) override;
|
|
|
|
|
2020-07-24 22:08:36 +00:00
|
|
|
struct cmp_drawings
|
|
|
|
{
|
|
|
|
bool operator()( const BOARD_ITEM* aFirst, const BOARD_ITEM* aSecond ) const;
|
|
|
|
};
|
|
|
|
|
2008-04-01 06:07:00 +00:00
|
|
|
#if defined(DEBUG)
|
2016-09-24 18:53:15 +00:00
|
|
|
void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
|
2009-11-16 08:13:40 +00:00
|
|
|
#endif
|
2021-06-04 13:04:30 +00:00
|
|
|
|
|
|
|
protected:
|
2021-07-14 20:03:32 +00:00
|
|
|
double getParentOrientation() const override;
|
|
|
|
wxPoint getParentPosition() const override;
|
2008-01-16 18:48:04 +00:00
|
|
|
};
|
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
#endif // PCB_SHAPE_H
|