2012-01-14 19:50:32 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2017-07-01 13:16:51 +00:00
|
|
|
* Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
|
|
|
* 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 13:57:40 +00:00
|
|
|
/**
|
|
|
|
* @file class_zone.h
|
|
|
|
* @brief Classes to handle copper zones
|
|
|
|
*/
|
2007-12-09 12:59:06 +00:00
|
|
|
|
2011-12-14 04:29:25 +00:00
|
|
|
#ifndef CLASS_ZONE_H_
|
|
|
|
#define CLASS_ZONE_H_
|
2007-12-09 12:59:06 +00:00
|
|
|
|
2011-09-20 13:57:40 +00:00
|
|
|
|
2008-09-26 19:51:36 +00:00
|
|
|
#include <vector>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <gr_basic.h>
|
|
|
|
#include <class_board_item.h>
|
2018-02-02 20:57:12 +00:00
|
|
|
#include <board_connected_item.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <layers_id_colors_and_visibility.h>
|
|
|
|
#include <PolyLine.h>
|
2017-03-07 12:06:00 +00:00
|
|
|
#include <geometry/shape_poly_set.h>
|
2018-01-30 14:34:09 +00:00
|
|
|
#include <zone_settings.h>
|
2007-12-29 19:15:58 +00:00
|
|
|
|
2011-08-01 15:29:27 +00:00
|
|
|
|
2011-09-20 13:57:40 +00:00
|
|
|
class EDA_RECT;
|
2011-09-20 15:07:52 +00:00
|
|
|
class LINE_READER;
|
2011-09-20 13:57:40 +00:00
|
|
|
class EDA_DRAW_PANEL;
|
|
|
|
class PCB_EDIT_FRAME;
|
|
|
|
class BOARD;
|
|
|
|
class ZONE_CONTAINER;
|
2013-01-12 17:32:24 +00:00
|
|
|
class MSG_PANEL_ITEM;
|
|
|
|
|
2017-12-04 18:06:47 +00:00
|
|
|
typedef std::vector<SEG> ZONE_SEGMENT_FILL;
|
2011-08-01 15:29:27 +00:00
|
|
|
|
2011-09-20 15:07:52 +00:00
|
|
|
/**
|
|
|
|
* Class ZONE_CONTAINER
|
|
|
|
* handles a list of polygons defining a copper zone.
|
|
|
|
* A zone is described by a main polygon, a time stamp, a layer, and a net name.
|
|
|
|
* Other polygons inside the main polygon are holes in the zone.
|
2008-01-23 22:39:09 +00:00
|
|
|
*/
|
2009-10-21 19:16:25 +00:00
|
|
|
class ZONE_CONTAINER : public BOARD_CONNECTED_ITEM
|
2007-12-09 12:59:06 +00:00
|
|
|
{
|
|
|
|
public:
|
2011-09-20 15:07:52 +00:00
|
|
|
|
2017-03-07 12:06:00 +00:00
|
|
|
/**
|
|
|
|
* Zone hatch styles
|
|
|
|
*/
|
|
|
|
typedef enum HATCH_STYLE { NO_HATCH, DIAGONAL_FULL, DIAGONAL_EDGE } HATCH_STYLE;
|
|
|
|
|
2008-09-26 19:51:36 +00:00
|
|
|
ZONE_CONTAINER( BOARD* parent );
|
2012-01-14 19:50:32 +00:00
|
|
|
|
|
|
|
ZONE_CONTAINER( const ZONE_CONTAINER& aZone );
|
2016-05-31 08:27:52 +00:00
|
|
|
ZONE_CONTAINER& operator=( const ZONE_CONTAINER &aOther );
|
2012-01-14 19:50:32 +00:00
|
|
|
|
2008-01-23 22:39:09 +00:00
|
|
|
~ZONE_CONTAINER();
|
|
|
|
|
2018-08-28 20:14:47 +00:00
|
|
|
static inline bool ClassOf( const EDA_ITEM* aItem )
|
|
|
|
{
|
|
|
|
return aItem && ( ( PCB_ZONE_AREA_T == aItem->Type() ) ||
|
2018-09-29 17:58:31 +00:00
|
|
|
( PCB_SEGZONE_T == aItem->Type() ) );
|
2018-08-28 20:14:47 +00:00
|
|
|
}
|
|
|
|
|
2011-09-20 15:07:52 +00:00
|
|
|
/**
|
|
|
|
* Function GetPosition
|
2017-03-07 12:06:00 +00:00
|
|
|
*
|
|
|
|
* Returns a reference to the first corner of the polygon set.
|
|
|
|
*
|
|
|
|
* \warning The implementation of this function relies on the fact that wxPoint and VECTOR2I
|
|
|
|
* have the same layout. If you intend to use the returned reference directly, please note
|
|
|
|
* that you are _only_ allowed to use members x and y. Any use on anything that is not one of
|
|
|
|
* these members will have undefined behaviour.
|
|
|
|
*
|
2009-08-06 18:30:46 +00:00
|
|
|
* @return a wxPoint, position of the first point of the outline
|
|
|
|
*/
|
2017-12-18 17:24:25 +00:00
|
|
|
const wxPoint GetPosition() const override;
|
2016-09-24 18:53:15 +00:00
|
|
|
void SetPosition( const wxPoint& aPos ) override {}
|
2011-11-24 17:32:51 +00:00
|
|
|
|
2012-01-29 19:29:19 +00:00
|
|
|
/**
|
|
|
|
* Function SetPriority
|
|
|
|
* @param aPriority = the priority level
|
|
|
|
*/
|
|
|
|
void SetPriority( unsigned aPriority ) { m_priority = aPriority; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function GetPriority
|
|
|
|
* @return the priority level of this zone
|
|
|
|
*/
|
|
|
|
unsigned GetPriority() const { return m_priority; }
|
|
|
|
|
2018-04-10 10:52:12 +00:00
|
|
|
void GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) override;
|
2008-01-23 22:39:09 +00:00
|
|
|
|
2017-12-01 15:53:58 +00:00
|
|
|
void SetLayerSet( LSET aLayerSet );
|
|
|
|
|
|
|
|
virtual LSET GetLayerSet() const override;
|
|
|
|
|
2008-01-23 22:39:09 +00:00
|
|
|
/**
|
|
|
|
* Function Draw
|
|
|
|
* Draws the zone outline.
|
|
|
|
* @param panel = current Draw Panel
|
|
|
|
* @param DC = current Device Context
|
2008-04-01 05:21:50 +00:00
|
|
|
* @param aDrawMode = GR_OR, GR_XOR, GR_COPY ..
|
2010-12-14 15:56:30 +00:00
|
|
|
* @param offset = Draw offset (usually wxPoint(0,0))
|
2008-01-23 22:39:09 +00:00
|
|
|
*/
|
2011-09-20 15:07:52 +00:00
|
|
|
void Draw( EDA_DRAW_PANEL* panel,
|
|
|
|
wxDC* DC,
|
2012-09-01 13:38:27 +00:00
|
|
|
GR_DRAWMODE aDrawMode,
|
2016-09-24 18:53:15 +00:00
|
|
|
const wxPoint& offset = ZeroOffset ) override;
|
2008-01-23 22:39:09 +00:00
|
|
|
|
2008-09-26 19:51:36 +00:00
|
|
|
/**
|
|
|
|
* Function DrawDrawFilledArea
|
|
|
|
* Draws the filled area for this zone (polygon list .m_FilledPolysList)
|
|
|
|
* @param panel = current Draw Panel
|
|
|
|
* @param DC = current Device Context
|
|
|
|
* @param offset = Draw offset (usually wxPoint(0,0))
|
|
|
|
* @param aDrawMode = GR_OR, GR_XOR, GR_COPY ..
|
|
|
|
*/
|
2011-01-21 19:30:59 +00:00
|
|
|
void DrawFilledArea( EDA_DRAW_PANEL* panel,
|
|
|
|
wxDC* DC,
|
2012-09-01 13:38:27 +00:00
|
|
|
GR_DRAWMODE aDrawMode,
|
2011-01-21 19:30:59 +00:00
|
|
|
const wxPoint& offset = ZeroOffset );
|
2008-01-31 20:53:44 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function DrawWhileCreateOutline
|
2011-09-20 15:07:52 +00:00
|
|
|
* Draws the zone outline when it is created.
|
|
|
|
* The moving edges are in XOR graphic mode, old segment in draw_mode graphic mode
|
|
|
|
* (usually GR_OR). The closing edge has its own shape.
|
2008-01-31 20:53:44 +00:00
|
|
|
* @param panel = current Draw Panel
|
|
|
|
* @param DC = current Device Context
|
|
|
|
* @param draw_mode = draw mode: OR, XOR ..
|
|
|
|
*/
|
2012-09-01 13:38:27 +00:00
|
|
|
void DrawWhileCreateOutline( EDA_DRAW_PANEL* panel, wxDC* DC,
|
|
|
|
GR_DRAWMODE draw_mode = GR_OR );
|
2008-09-26 19:51:36 +00:00
|
|
|
|
2013-11-24 17:48:14 +00:00
|
|
|
/** Function GetBoundingBox (virtual)
|
2011-03-29 19:33:07 +00:00
|
|
|
* @return an EDA_RECT that is the bounding box of the zone outline
|
2008-11-18 18:13:55 +00:00
|
|
|
*/
|
2016-09-24 18:53:15 +00:00
|
|
|
const EDA_RECT GetBoundingBox() const override;
|
2008-11-18 18:13:55 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
int GetClearance( BOARD_CONNECTED_ITEM* aItem = NULL ) const override;
|
2011-08-09 03:41:20 +00:00
|
|
|
|
2008-09-26 19:51:36 +00:00
|
|
|
/**
|
|
|
|
* Function IsOnCopperLayer
|
|
|
|
* @return true if this zone is on a copper layer, false if on a technical layer
|
|
|
|
*/
|
2017-12-01 15:53:58 +00:00
|
|
|
bool IsOnCopperLayer() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function CommonLayerExist
|
|
|
|
* Test if this zone shares a common layer with the given layer set
|
|
|
|
*/
|
|
|
|
bool CommonLayerExists( const LSET aLayerSet ) const;
|
|
|
|
|
|
|
|
virtual void SetLayer( PCB_LAYER_ID aLayer ) override;
|
|
|
|
|
|
|
|
virtual PCB_LAYER_ID GetLayer() const override;
|
|
|
|
|
|
|
|
virtual bool IsOnLayer( PCB_LAYER_ID ) const override;
|
|
|
|
|
|
|
|
virtual void ViewGetLayers( int aLayers[], int& aCount ) const override;
|
|
|
|
|
2017-12-04 18:06:47 +00:00
|
|
|
void SetFillMode( ZONE_FILL_MODE aFillMode ) { m_FillMode = aFillMode; }
|
|
|
|
ZONE_FILL_MODE GetFillMode() const { return m_FillMode; }
|
2011-11-30 21:15:56 +00:00
|
|
|
|
2012-05-29 18:10:56 +00:00
|
|
|
void SetThermalReliefGap( int aThermalReliefGap ) { m_ThermalReliefGap = aThermalReliefGap; }
|
2012-03-08 20:44:03 +00:00
|
|
|
int GetThermalReliefGap( D_PAD* aPad = NULL ) const;
|
2011-11-30 21:15:56 +00:00
|
|
|
|
2012-01-14 19:50:32 +00:00
|
|
|
void SetThermalReliefCopperBridge( int aThermalReliefCopperBridge )
|
|
|
|
{
|
|
|
|
m_ThermalReliefCopperBridge = aThermalReliefCopperBridge;
|
|
|
|
}
|
2012-03-08 20:44:03 +00:00
|
|
|
int GetThermalReliefCopperBridge( D_PAD* aPad = NULL ) const;
|
2011-11-30 21:15:56 +00:00
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
void SetArcSegmentCount( int aArcSegCount ) { m_ArcToSegmentsCount = aArcSegCount; }
|
|
|
|
int GetArcSegmentCount() const { return m_ArcToSegmentsCount; }
|
2011-11-30 21:15:56 +00:00
|
|
|
|
|
|
|
bool IsFilled() const { return m_IsFilled; }
|
|
|
|
void SetIsFilled( bool isFilled ) { m_IsFilled = isFilled; }
|
|
|
|
|
|
|
|
int GetZoneClearance() const { return m_ZoneClearance; }
|
|
|
|
void SetZoneClearance( int aZoneClearance ) { m_ZoneClearance = aZoneClearance; }
|
|
|
|
|
2012-02-24 23:23:46 +00:00
|
|
|
ZoneConnection GetPadConnection( D_PAD* aPad = NULL ) const;
|
|
|
|
void SetPadConnection( ZoneConnection aPadConnection ) { m_PadConnection = aPadConnection; }
|
2011-11-30 21:15:56 +00:00
|
|
|
|
|
|
|
int GetMinThickness() const { return m_ZoneMinThickness; }
|
|
|
|
void SetMinThickness( int aMinThickness ) { m_ZoneMinThickness = aMinThickness; }
|
2011-02-25 20:37:48 +00:00
|
|
|
|
2017-03-07 12:06:00 +00:00
|
|
|
int GetSelectedCorner() const
|
|
|
|
{
|
|
|
|
// Transform relative indices to global index
|
|
|
|
int globalIndex;
|
|
|
|
m_Poly->GetGlobalIndex( *m_CornerSelection, globalIndex );
|
|
|
|
|
|
|
|
return globalIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetSelectedCorner( int aCorner )
|
|
|
|
{
|
|
|
|
SHAPE_POLY_SET::VERTEX_INDEX selectedCorner;
|
|
|
|
|
|
|
|
// If the global index of the corner is correct, assign it to m_CornerSelection
|
|
|
|
if( m_Poly->GetRelativeIndices( aCorner, &selectedCorner ) )
|
|
|
|
{
|
|
|
|
if( m_CornerSelection == nullptr )
|
|
|
|
m_CornerSelection = new SHAPE_POLY_SET::VERTEX_INDEX;
|
|
|
|
|
|
|
|
*m_CornerSelection = selectedCorner;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
throw( std::out_of_range( "aCorner-th vertex does not exist" ) );
|
|
|
|
}
|
2013-03-20 14:50:12 +00:00
|
|
|
|
2014-05-04 17:08:36 +00:00
|
|
|
///
|
|
|
|
// Like HitTest but selects the current corner to be operated on
|
|
|
|
void SetSelectedCorner( const wxPoint& aPosition );
|
|
|
|
|
2013-03-26 09:58:40 +00:00
|
|
|
int GetLocalFlags() const { return m_localFlgs; }
|
|
|
|
void SetLocalFlags( int aFlags ) { m_localFlgs = aFlags; }
|
2013-03-20 14:50:12 +00:00
|
|
|
|
2017-12-04 18:06:47 +00:00
|
|
|
ZONE_SEGMENT_FILL& FillSegments() { return m_FillSegmList; }
|
|
|
|
const ZONE_SEGMENT_FILL& FillSegments() const { return m_FillSegmList; }
|
2013-03-20 14:50:12 +00:00
|
|
|
|
2017-03-07 12:06:00 +00:00
|
|
|
SHAPE_POLY_SET* Outline() { return m_Poly; }
|
|
|
|
const SHAPE_POLY_SET* Outline() const { return const_cast< SHAPE_POLY_SET* >( m_Poly ); }
|
2013-03-20 14:50:12 +00:00
|
|
|
|
2017-03-07 12:06:00 +00:00
|
|
|
void SetOutline( SHAPE_POLY_SET* aOutline ) { m_Poly = aOutline; }
|
2013-03-20 14:50:12 +00:00
|
|
|
|
2013-09-21 18:09:41 +00:00
|
|
|
/**
|
|
|
|
* Function HitTest
|
|
|
|
* tests if a point is near an outline edge or a corner of this zone.
|
2014-11-02 16:25:04 +00:00
|
|
|
* @param aPosition the wxPoint to test
|
2013-09-21 18:09:41 +00:00
|
|
|
* @return bool - true if a hit, else false
|
|
|
|
*/
|
2016-09-24 18:53:15 +00:00
|
|
|
virtual bool HitTest( const wxPoint& aPosition ) const override;
|
2008-09-26 19:51:36 +00:00
|
|
|
|
2013-09-21 18:09:41 +00:00
|
|
|
/**
|
|
|
|
* Function HitTest
|
|
|
|
* tests if a point is inside the zone area, i.e. inside the main outline
|
|
|
|
* and outside holes.
|
2014-11-02 16:25:04 +00:00
|
|
|
* @param aPosition : the wxPoint to test
|
2013-09-21 18:09:41 +00:00
|
|
|
* @return bool - true if a hit, else false
|
|
|
|
*/
|
|
|
|
bool HitTestInsideZone( const wxPoint& aPosition ) const
|
|
|
|
{
|
2017-03-07 12:06:00 +00:00
|
|
|
return m_Poly->Contains( VECTOR2I( aPosition ), 0 );
|
2013-09-21 18:09:41 +00:00
|
|
|
}
|
|
|
|
|
2008-11-27 10:12:46 +00:00
|
|
|
/**
|
|
|
|
* Function HitTestFilledArea
|
|
|
|
* tests if the given wxPoint is within the bounds of a filled area of this zone.
|
|
|
|
* @param aRefPos A wxPoint to test
|
|
|
|
* @return bool - true if a hit, else false
|
|
|
|
*/
|
2012-03-15 14:31:16 +00:00
|
|
|
bool HitTestFilledArea( const wxPoint& aRefPos ) const;
|
2008-11-27 10:12:46 +00:00
|
|
|
|
2013-05-01 19:01:14 +00:00
|
|
|
/**
|
|
|
|
* Function TransformSolidAreasShapesToPolygonSet
|
|
|
|
* Convert solid areas full shapes to polygon set
|
|
|
|
* (the full shape is the polygon area with a thick outline)
|
|
|
|
* Used in 3D view
|
|
|
|
* Arcs (ends of segments) are approximated by segments
|
|
|
|
* @param aCornerBuffer = a buffer to store the polygons
|
|
|
|
* @param aCircleToSegmentsCount = the number of segments to approximate a circle
|
|
|
|
* @param aCorrectionFactor = the correction to apply to arcs radius to roughly
|
|
|
|
* keep arc radius when approximated by segments
|
|
|
|
*/
|
2015-07-27 19:45:57 +00:00
|
|
|
void TransformSolidAreasShapesToPolygonSet( SHAPE_POLY_SET& aCornerBuffer,
|
2014-11-30 17:07:02 +00:00
|
|
|
int aCircleToSegmentsCount,
|
2016-07-19 17:35:25 +00:00
|
|
|
double aCorrectionFactor ) const;
|
2013-05-01 19:01:14 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function TransformOutlinesShapeWithClearanceToPolygon
|
|
|
|
* Convert the outlines shape to a polygon with no holes
|
|
|
|
* inflated (optional) by max( aClearanceValue, the zone clearance)
|
|
|
|
* (holes are linked to external outline by overlapping segments)
|
|
|
|
* Used in filling zones calculations
|
|
|
|
* Circles (vias) and arcs (ends of tracks) are approximated by segments
|
|
|
|
* @param aCornerBuffer = a buffer to store the polygon
|
2014-12-19 19:09:53 +00:00
|
|
|
* @param aMinClearanceValue = the min clearance around outlines
|
|
|
|
* @param aUseNetClearance = true to use a clearance which is the max value between
|
|
|
|
* aMinClearanceValue and the net clearance
|
|
|
|
* false to use aMinClearanceValue only
|
|
|
|
* if both aMinClearanceValue = 0 and aUseNetClearance = false: create the zone outline polygon.
|
2013-05-01 19:01:14 +00:00
|
|
|
*/
|
2015-07-27 19:45:57 +00:00
|
|
|
void TransformOutlinesShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer,
|
2017-03-07 12:06:00 +00:00
|
|
|
int aMinClearanceValue,
|
2017-12-04 18:06:47 +00:00
|
|
|
bool aUseNetClearance ) const;
|
2017-11-29 18:51:01 +00:00
|
|
|
|
|
|
|
void TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer,
|
|
|
|
int aClearanceValue,
|
|
|
|
int aCircleToSegmentsCount,
|
|
|
|
double aCorrectionFactor ) const override;
|
|
|
|
|
2009-08-06 18:30:46 +00:00
|
|
|
/**
|
2008-01-23 22:39:09 +00:00
|
|
|
* Function HitTestForCorner
|
2017-03-07 12:06:00 +00:00
|
|
|
* tests if the given wxPoint is near a corner.
|
|
|
|
* @param refPos is the wxPoint to test.
|
|
|
|
* @param aCornerHit [out] is the index of the closest vertex found, useless when return
|
|
|
|
* value is false.
|
|
|
|
* @return bool - true if some corner was found to be closer to refPos than aClearance; false
|
|
|
|
* otherwise.
|
|
|
|
*/
|
|
|
|
bool HitTestForCorner( const wxPoint& refPos, SHAPE_POLY_SET::VERTEX_INDEX& aCornerHit ) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function HitTestForCorner
|
|
|
|
* tests if the given wxPoint is near a corner.
|
|
|
|
* @param refPos is the wxPoint to test.
|
|
|
|
* @return bool - true if some corner was found to be closer to refPos than aClearance; false
|
|
|
|
* otherwise.
|
|
|
|
*/
|
|
|
|
bool HitTestForCorner( const wxPoint& refPos ) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function HitTestForEdge
|
|
|
|
* tests if the given wxPoint is near a segment defined by 2 corners.
|
|
|
|
* @param refPos is the wxPoint to test.
|
|
|
|
* @param aCornerHit [out] is the index of the closest vertex found, useless when return
|
|
|
|
* value is false.
|
|
|
|
* @return bool - true if some edge was found to be closer to refPos than aClearance.
|
2008-01-23 22:39:09 +00:00
|
|
|
*/
|
2017-03-07 12:06:00 +00:00
|
|
|
bool HitTestForEdge( const wxPoint& refPos, SHAPE_POLY_SET::VERTEX_INDEX& aCornerHit ) const;
|
2008-01-23 22:39:09 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function HitTestForEdge
|
2011-03-01 13:59:21 +00:00
|
|
|
* tests if the given wxPoint is near a segment defined by 2 corners.
|
2017-03-07 12:06:00 +00:00
|
|
|
* @param refPos is the wxPoint to test.
|
|
|
|
* @return bool - true if some edge was found to be closer to refPos than aClearance.
|
2008-01-23 22:39:09 +00:00
|
|
|
*/
|
2017-03-07 12:06:00 +00:00
|
|
|
bool HitTestForEdge( const wxPoint& refPos ) const;
|
2008-01-23 22:39:09 +00:00
|
|
|
|
2013-09-21 18:09:41 +00:00
|
|
|
/** @copydoc BOARD_ITEM::HitTest(const EDA_RECT& aRect,
|
|
|
|
* bool aContained = true, int aAccuracy ) const
|
|
|
|
*/
|
2016-09-24 18:53:15 +00:00
|
|
|
bool HitTest( const EDA_RECT& aRect, bool aContained = true, int aAccuracy = 0 ) const override;
|
2008-01-06 12:43:57 +00:00
|
|
|
|
2008-12-03 10:32:53 +00:00
|
|
|
|
2011-07-16 16:04:49 +00:00
|
|
|
/**
|
|
|
|
* Function UnFill
|
|
|
|
* Removes the zone filling
|
|
|
|
* @return true if a previous filling is removed, false if no change
|
|
|
|
* (when no filling found)
|
|
|
|
*/
|
2011-09-20 15:07:52 +00:00
|
|
|
bool UnFill();
|
2008-12-03 10:32:53 +00:00
|
|
|
|
2008-01-23 22:39:09 +00:00
|
|
|
/* Geometric transformations: */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function Move
|
|
|
|
* Move the outlines
|
|
|
|
* @param offset = moving vector
|
|
|
|
*/
|
2016-09-24 18:53:15 +00:00
|
|
|
void Move( const wxPoint& offset ) override;
|
2008-01-23 22:39:09 +00:00
|
|
|
|
|
|
|
/**
|
2008-02-01 21:30:45 +00:00
|
|
|
* Function MoveEdge
|
2014-05-04 17:08:36 +00:00
|
|
|
* Move the outline Edge
|
2008-02-01 21:30:45 +00:00
|
|
|
* @param offset = moving vector
|
2014-05-04 17:08:36 +00:00
|
|
|
* @param aEdge = start point of the outline edge
|
2008-02-01 21:30:45 +00:00
|
|
|
*/
|
2014-05-04 17:08:36 +00:00
|
|
|
void MoveEdge( const wxPoint& offset, int aEdge );
|
2008-02-01 21:30:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function Rotate
|
2008-01-23 22:39:09 +00:00
|
|
|
* Move the outlines
|
|
|
|
* @param centre = rot centre
|
|
|
|
* @param angle = in 0.1 degree
|
|
|
|
*/
|
2016-09-24 18:53:15 +00:00
|
|
|
void Rotate( const wxPoint& centre, double angle ) override;
|
2008-01-23 22:39:09 +00:00
|
|
|
|
2009-08-01 19:26:05 +00:00
|
|
|
/**
|
|
|
|
* Function Flip
|
|
|
|
* Flip this object, i.e. change the board side for this object
|
|
|
|
* (like Mirror() but changes layer)
|
2010-12-14 15:56:30 +00:00
|
|
|
* @param aCentre - the rotation point.
|
2009-08-01 19:26:05 +00:00
|
|
|
*/
|
2016-09-24 18:53:15 +00:00
|
|
|
virtual void Flip( const wxPoint& aCentre ) override;
|
2009-08-01 19:26:05 +00:00
|
|
|
|
2008-01-23 22:39:09 +00:00
|
|
|
/**
|
|
|
|
* Function Mirror
|
|
|
|
* Mirror the outlines , relative to a given horizontal axis
|
|
|
|
* the layer is not changed
|
|
|
|
* @param mirror_ref = vertical axis position
|
|
|
|
*/
|
2011-09-20 15:07:52 +00:00
|
|
|
void Mirror( const wxPoint& mirror_ref );
|
2008-04-01 05:21:50 +00:00
|
|
|
|
2008-01-23 22:39:09 +00:00
|
|
|
/**
|
|
|
|
* Function GetClass
|
|
|
|
* returns the class name.
|
|
|
|
* @return wxString
|
|
|
|
*/
|
2016-09-24 18:53:15 +00:00
|
|
|
wxString GetClass() const override
|
2008-01-23 22:39:09 +00:00
|
|
|
{
|
|
|
|
return wxT( "ZONE_CONTAINER" );
|
|
|
|
}
|
2008-04-01 05:21:50 +00:00
|
|
|
|
2011-07-14 15:42:44 +00:00
|
|
|
/** Access to m_Poly parameters
|
2008-09-26 19:51:36 +00:00
|
|
|
*/
|
2008-04-01 05:21:50 +00:00
|
|
|
|
2011-12-14 04:29:25 +00:00
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
int GetNumCorners( void ) const
|
2008-04-01 05:21:50 +00:00
|
|
|
{
|
2017-03-07 12:06:00 +00:00
|
|
|
return m_Poly->TotalVertices();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function Iterate
|
|
|
|
* returns an iterator to visit all points of the zone's main outline without holes.
|
|
|
|
* @return SHAPE_POLY_SET::ITERATOR - an iterator to visit the zone vertices without holes.
|
|
|
|
*/
|
|
|
|
SHAPE_POLY_SET::ITERATOR Iterate()
|
|
|
|
{
|
|
|
|
return m_Poly->Iterate();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function IterateWithHoles
|
|
|
|
* returns an iterator to visit all points of the zone's main outline with holes.
|
|
|
|
* @return SHAPE_POLY_SET::ITERATOR - an iterator to visit the zone vertices with holes.
|
|
|
|
*/
|
|
|
|
SHAPE_POLY_SET::ITERATOR IterateWithHoles()
|
|
|
|
{
|
|
|
|
return m_Poly->IterateWithHoles();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function CIterateWithHoles
|
|
|
|
* returns an iterator to visit all points of the zone's main outline with holes.
|
|
|
|
* @return SHAPE_POLY_SET::ITERATOR - an iterator to visit the zone vertices with holes.
|
|
|
|
*/
|
|
|
|
SHAPE_POLY_SET::CONST_ITERATOR CIterateWithHoles() const
|
|
|
|
{
|
|
|
|
return m_Poly->CIterateWithHoles();
|
2008-04-01 05:21:50 +00:00
|
|
|
}
|
|
|
|
|
2008-09-26 19:51:36 +00:00
|
|
|
void RemoveAllContours( void )
|
2008-04-01 05:21:50 +00:00
|
|
|
{
|
|
|
|
m_Poly->RemoveAllContours();
|
|
|
|
}
|
|
|
|
|
2017-03-07 12:06:00 +00:00
|
|
|
const VECTOR2I& GetCornerPosition( int aCornerIndex ) const
|
2008-04-01 05:21:50 +00:00
|
|
|
{
|
2017-03-07 12:06:00 +00:00
|
|
|
SHAPE_POLY_SET::VERTEX_INDEX index;
|
|
|
|
|
|
|
|
// Convert global to relative indices
|
|
|
|
if( !m_Poly->GetRelativeIndices( aCornerIndex, &index ) )
|
|
|
|
throw( std::out_of_range( "aCornerIndex-th vertex does not exist" ) );
|
|
|
|
|
|
|
|
return m_Poly->CVertex( index );
|
2008-04-01 05:21:50 +00:00
|
|
|
}
|
|
|
|
|
2008-09-26 19:51:36 +00:00
|
|
|
void SetCornerPosition( int aCornerIndex, wxPoint new_pos )
|
2008-04-01 05:21:50 +00:00
|
|
|
{
|
2017-03-07 12:06:00 +00:00
|
|
|
SHAPE_POLY_SET::VERTEX_INDEX relativeIndices;
|
|
|
|
|
|
|
|
// Convert global to relative indices
|
|
|
|
if( m_Poly->GetRelativeIndices( aCornerIndex, &relativeIndices ) )
|
|
|
|
{
|
|
|
|
m_Poly->Vertex( relativeIndices ).x = new_pos.x;
|
|
|
|
m_Poly->Vertex( relativeIndices ).y = new_pos.y;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
throw( std::out_of_range( "aCornerIndex-th vertex does not exist" ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function NewHole
|
|
|
|
* creates a new hole on the zone; i.e., a new contour on the zone's outline.
|
|
|
|
*/
|
|
|
|
void NewHole()
|
|
|
|
{
|
|
|
|
m_Poly->NewHole();
|
2008-04-01 05:21:50 +00:00
|
|
|
}
|
|
|
|
|
2017-03-07 12:06:00 +00:00
|
|
|
/**
|
2017-06-19 11:29:57 +00:00
|
|
|
* Add a new corner to the zone outline (to the main outline or a hole)
|
|
|
|
* @param aPosition is the position of the new corner.
|
|
|
|
* @param aHoleIdx is the index of the hole (-1 for the main outline, >= 0 for hole).
|
2017-03-07 12:06:00 +00:00
|
|
|
* @param aAllowDuplication is a flag to indicate whether it is allowed to add this corner
|
|
|
|
* even if it is duplicated.
|
2017-06-19 11:29:57 +00:00
|
|
|
* @return true if the corner was added, false if error (aHoleIdx > hole count -1)
|
2017-03-07 12:06:00 +00:00
|
|
|
*/
|
2017-06-19 11:29:57 +00:00
|
|
|
bool AppendCorner( wxPoint aPosition, int aHoleIdx, bool aAllowDuplication = false );
|
2008-10-23 10:26:06 +00:00
|
|
|
|
2017-03-07 12:06:00 +00:00
|
|
|
HATCH_STYLE GetHatchStyle() const
|
2008-10-23 10:26:06 +00:00
|
|
|
{
|
2017-03-07 12:06:00 +00:00
|
|
|
return m_hatchStyle;
|
2008-10-23 10:26:06 +00:00
|
|
|
}
|
2011-02-21 19:43:59 +00:00
|
|
|
|
2017-03-07 12:06:00 +00:00
|
|
|
void SetHatchStyle( HATCH_STYLE aStyle )
|
2012-06-09 17:00:13 +00:00
|
|
|
{
|
2017-03-07 12:06:00 +00:00
|
|
|
m_hatchStyle = aStyle;
|
2012-06-09 17:00:13 +00:00
|
|
|
}
|
|
|
|
|
2013-05-01 19:01:14 +00:00
|
|
|
/**
|
2010-11-12 16:59:16 +00:00
|
|
|
* Function IsSame
|
2011-11-30 21:15:56 +00:00
|
|
|
* tests if 2 zones are equivalent:
|
2009-08-23 15:22:44 +00:00
|
|
|
* 2 zones are equivalent if they have same parameters and same outlines
|
2011-11-30 21:15:56 +00:00
|
|
|
* info, filling is not taken into account
|
2009-08-23 15:22:44 +00:00
|
|
|
* @param aZoneToCompare = zone to compare with "this"
|
|
|
|
*/
|
2011-11-30 21:15:56 +00:00
|
|
|
bool IsSame( const ZONE_CONTAINER &aZoneToCompare );
|
2011-02-21 19:43:59 +00:00
|
|
|
|
2012-06-02 21:19:17 +00:00
|
|
|
/**
|
|
|
|
* Function ClearFilledPolysList
|
|
|
|
* clears the list of filled polygons.
|
|
|
|
*/
|
|
|
|
void ClearFilledPolysList()
|
|
|
|
{
|
2013-05-14 18:47:01 +00:00
|
|
|
m_FilledPolysList.RemoveAllContours();
|
2012-06-02 21:19:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function GetFilledPolysList
|
|
|
|
* returns a reference to the list of filled polygons.
|
|
|
|
* @return Reference to the list of filled polygons.
|
|
|
|
*/
|
2017-12-01 15:53:58 +00:00
|
|
|
|
|
|
|
//TODO - This should be called for each layer on which the zone exists
|
|
|
|
|
2015-07-27 19:45:57 +00:00
|
|
|
const SHAPE_POLY_SET& GetFilledPolysList() const
|
2012-06-02 21:19:17 +00:00
|
|
|
{
|
|
|
|
return m_FilledPolysList;
|
|
|
|
}
|
|
|
|
|
2017-11-23 16:20:27 +00:00
|
|
|
void CacheTriangulation();
|
|
|
|
|
2012-06-02 21:19:17 +00:00
|
|
|
/**
|
2017-12-04 18:06:47 +00:00
|
|
|
* Function SetFilledPolysList
|
2012-06-02 21:19:17 +00:00
|
|
|
* sets the list of filled polygons.
|
|
|
|
*/
|
2017-12-04 18:06:47 +00:00
|
|
|
void SetFilledPolysList( SHAPE_POLY_SET& aPolysList )
|
2012-06-02 21:19:17 +00:00
|
|
|
{
|
|
|
|
m_FilledPolysList = aPolysList;
|
|
|
|
}
|
|
|
|
|
2017-12-04 18:06:47 +00:00
|
|
|
/**
|
|
|
|
* Function SetFilledPolysList
|
|
|
|
* sets the list of filled polygons.
|
|
|
|
*/
|
2018-06-22 23:35:07 +00:00
|
|
|
void SetRawPolysList( SHAPE_POLY_SET& aPolysList )
|
|
|
|
{
|
|
|
|
m_RawPolysList = aPolysList;
|
|
|
|
}
|
2017-12-04 18:06:47 +00:00
|
|
|
|
|
|
|
|
2011-02-21 19:43:59 +00:00
|
|
|
/**
|
|
|
|
* Function GetSmoothedPoly
|
|
|
|
* returns a pointer to the corner-smoothed version of
|
|
|
|
* m_Poly if it exists, otherwise it returns m_Poly.
|
2017-03-07 12:06:00 +00:00
|
|
|
* @return SHAPE_POLY_SET* - pointer to the polygon.
|
2011-02-21 19:43:59 +00:00
|
|
|
*/
|
2017-12-04 18:06:47 +00:00
|
|
|
bool BuildSmoothedPoly( SHAPE_POLY_SET& aSmoothedPoly ) const;
|
2011-02-21 19:43:59 +00:00
|
|
|
|
2012-07-13 18:55:29 +00:00
|
|
|
void SetCornerSmoothingType( int aType ) { m_cornerSmoothingType = aType; };
|
2011-09-20 15:07:52 +00:00
|
|
|
|
2012-07-13 18:55:29 +00:00
|
|
|
int GetCornerSmoothingType() const { return m_cornerSmoothingType; };
|
2011-02-21 19:43:59 +00:00
|
|
|
|
2015-05-15 12:49:11 +00:00
|
|
|
void SetCornerRadius( unsigned int aRadius );
|
2011-02-21 19:43:59 +00:00
|
|
|
|
2012-07-13 18:55:29 +00:00
|
|
|
unsigned int GetCornerRadius() const { return m_cornerRadius; };
|
2011-07-14 15:42:44 +00:00
|
|
|
|
2017-04-07 06:02:26 +00:00
|
|
|
/**
|
|
|
|
* add a polygon to the zone outline
|
|
|
|
* if the zone outline is empty, this is the main outline
|
|
|
|
* else it is a hole inside the main outline
|
|
|
|
*/
|
2012-06-09 17:00:13 +00:00
|
|
|
void AddPolygon( std::vector< wxPoint >& aPolygon );
|
|
|
|
|
2017-12-04 18:06:47 +00:00
|
|
|
void SetFillSegments( const ZONE_SEGMENT_FILL& aSegments )
|
2012-06-09 17:00:13 +00:00
|
|
|
{
|
2017-12-04 18:06:47 +00:00
|
|
|
m_FillSegmList = aSegments;
|
2012-06-09 17:00:13 +00:00
|
|
|
}
|
|
|
|
|
2017-03-22 13:43:10 +00:00
|
|
|
SHAPE_POLY_SET& RawPolysList()
|
|
|
|
{
|
|
|
|
return m_RawPolysList;
|
|
|
|
}
|
|
|
|
|
2018-04-10 10:52:12 +00:00
|
|
|
wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override;
|
2011-07-14 15:42:44 +00:00
|
|
|
|
2017-02-20 12:20:39 +00:00
|
|
|
BITMAP_DEF GetMenuImage() const override;
|
2011-12-14 17:25:42 +00:00
|
|
|
|
2017-02-20 12:20:39 +00:00
|
|
|
EDA_ITEM* Clone() const override;
|
2012-03-17 14:39:27 +00:00
|
|
|
|
2012-07-13 18:55:29 +00:00
|
|
|
/**
|
|
|
|
* Accessors to parameters used in Keepout zones:
|
|
|
|
*/
|
|
|
|
bool GetIsKeepout() const { return m_isKeepout; }
|
2012-07-14 16:27:25 +00:00
|
|
|
bool GetDoNotAllowCopperPour() const { return m_doNotAllowCopperPour; }
|
2012-07-13 18:55:29 +00:00
|
|
|
bool GetDoNotAllowVias() const { return m_doNotAllowVias; }
|
|
|
|
bool GetDoNotAllowTracks() const { return m_doNotAllowTracks; }
|
|
|
|
|
|
|
|
void SetIsKeepout( bool aEnable ) { m_isKeepout = aEnable; }
|
2012-07-14 16:27:25 +00:00
|
|
|
void SetDoNotAllowCopperPour( bool aEnable ) { m_doNotAllowCopperPour = aEnable; }
|
2012-07-13 18:55:29 +00:00
|
|
|
void SetDoNotAllowVias( bool aEnable ) { m_doNotAllowVias = aEnable; }
|
|
|
|
void SetDoNotAllowTracks( bool aEnable ) { m_doNotAllowTracks = aEnable; }
|
|
|
|
|
2017-03-07 12:06:00 +00:00
|
|
|
/**
|
|
|
|
* Hatch related methods
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function GetHatchPitch
|
|
|
|
* @return int - the zone hatch pitch in iu.
|
|
|
|
*/
|
|
|
|
int GetHatchPitch() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function GetDefaultHatchPitchMils
|
2017-07-01 13:16:51 +00:00
|
|
|
* @return int - the default hatch pitch in internal units.
|
2017-03-07 12:06:00 +00:00
|
|
|
*/
|
2017-07-01 13:16:51 +00:00
|
|
|
static int GetDefaultHatchPitch();
|
2017-03-07 12:06:00 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function SetHatch
|
|
|
|
* sets all hatch parameters for the zone.
|
|
|
|
* @param aHatchStyle is the style of the hatch, specified as one of HATCH_STYLE possible
|
|
|
|
* values.
|
|
|
|
* @param aHatchPitch is the hatch pitch in iu.
|
|
|
|
* @param aRebuildHatch is a flag to indicate whether to re-hatch after having set the
|
|
|
|
* previous parameters.
|
|
|
|
*/
|
|
|
|
void SetHatch( int aHatchStyle, int aHatchPitch, bool aRebuildHatch );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function SetHatchPitch
|
|
|
|
* sets the hatch pitch parameter for the zone.
|
|
|
|
* @param aPitch is the hatch pitch in iu.
|
|
|
|
*/
|
|
|
|
void SetHatchPitch( int aPitch );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function UnHatch
|
|
|
|
* clears the zone's hatch.
|
|
|
|
*/
|
|
|
|
void UnHatch();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function Hatch
|
|
|
|
* computes the hatch lines depending on the hatch parameters and stores it in the zone's
|
|
|
|
* attribute m_HatchLines.
|
|
|
|
*/
|
|
|
|
void Hatch();
|
|
|
|
|
|
|
|
const std::vector<SEG>& GetHatchLines() const { return m_HatchLines; }
|
|
|
|
|
2018-02-20 14:51:40 +00:00
|
|
|
bool GetHV45() const { return m_hv45; }
|
|
|
|
void SetHV45( bool aConstrain ) { m_hv45 = aConstrain; }
|
2017-12-01 15:53:58 +00:00
|
|
|
|
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
|
2012-05-29 18:10:56 +00:00
|
|
|
|
2017-10-31 13:59:03 +00:00
|
|
|
virtual void SwapData( BOARD_ITEM* aImage ) override;
|
2015-06-12 15:13:18 +00:00
|
|
|
|
2012-05-29 18:10:56 +00:00
|
|
|
private:
|
2015-06-12 15:13:18 +00:00
|
|
|
|
2017-03-07 12:06:00 +00:00
|
|
|
SHAPE_POLY_SET* m_Poly; ///< Outline of the zone.
|
2012-07-13 18:55:29 +00:00
|
|
|
int m_cornerSmoothingType;
|
|
|
|
unsigned int m_cornerRadius;
|
|
|
|
|
2017-12-01 15:53:58 +00:00
|
|
|
LSET m_layerSet;
|
|
|
|
|
2012-07-13 18:55:29 +00:00
|
|
|
/* Priority: when a zone outline is inside and other zone, if its priority is higher
|
|
|
|
* the other zone priority, it will be created inside.
|
|
|
|
* if priorities are equal, a DRC error is set
|
|
|
|
*/
|
2012-05-29 18:10:56 +00:00
|
|
|
unsigned m_priority;
|
2012-07-13 18:55:29 +00:00
|
|
|
|
|
|
|
/* A zone outline can be a keepout zone.
|
|
|
|
* It will be never filled, and DRC should test for pads, tracks and vias
|
|
|
|
*/
|
|
|
|
bool m_isKeepout;
|
|
|
|
|
|
|
|
/* For keepout zones only:
|
|
|
|
* what is not allowed inside the keepout ( pads, tracks and vias )
|
|
|
|
*/
|
2012-07-14 16:27:25 +00:00
|
|
|
bool m_doNotAllowCopperPour;
|
2012-07-13 18:55:29 +00:00
|
|
|
bool m_doNotAllowVias;
|
|
|
|
bool m_doNotAllowTracks;
|
|
|
|
|
2012-05-29 18:10:56 +00:00
|
|
|
ZoneConnection m_PadConnection;
|
2013-03-18 19:36:07 +00:00
|
|
|
int m_ZoneClearance; ///< Clearance value in internal units.
|
|
|
|
int m_ZoneMinThickness; ///< Minimum thickness value in filled areas.
|
|
|
|
|
|
|
|
/** The number of segments to convert a circle to a polygon. Valid values are
|
|
|
|
#ARC_APPROX_SEGMENTS_COUNT_LOW_DEF or #ARC_APPROX_SEGMENTS_COUNT_HIGHT_DEF. */
|
|
|
|
int m_ArcToSegmentsCount;
|
|
|
|
|
|
|
|
/** True when a zone was filled, false after deleting the filled areas. */
|
|
|
|
bool m_IsFilled;
|
|
|
|
|
|
|
|
///< Width of the gap in thermal reliefs.
|
|
|
|
int m_ThermalReliefGap;
|
|
|
|
|
|
|
|
///< Width of the copper bridge in thermal reliefs.
|
|
|
|
int m_ThermalReliefCopperBridge;
|
|
|
|
|
|
|
|
|
2017-12-04 18:06:47 +00:00
|
|
|
/// How to fill areas: ZFM_POLYGONS => use filled polygons, ZFM_SEGMENTS => fill with segments.
|
|
|
|
ZONE_FILL_MODE m_FillMode;
|
2012-06-02 21:19:17 +00:00
|
|
|
|
2017-03-07 12:06:00 +00:00
|
|
|
/// The index of the corner being moved or nullptr if no corner is selected.
|
|
|
|
SHAPE_POLY_SET::VERTEX_INDEX* m_CornerSelection;
|
2013-03-20 14:50:12 +00:00
|
|
|
|
2015-01-22 12:06:34 +00:00
|
|
|
/// Variable used in polygon calculations.
|
|
|
|
int m_localFlgs;
|
2013-03-20 14:50:12 +00:00
|
|
|
|
|
|
|
/** Segments used to fill the zone (#m_FillMode ==1 ), when fill zone by segment is used.
|
|
|
|
* In this case the segments have #m_ZoneMinThickness width.
|
|
|
|
*/
|
2017-12-04 18:06:47 +00:00
|
|
|
ZONE_SEGMENT_FILL m_FillSegmList;
|
2013-03-20 14:50:12 +00:00
|
|
|
|
2012-06-02 21:19:17 +00:00
|
|
|
/* set of filled polygons used to draw a zone as a filled area.
|
|
|
|
* from outlines (m_Poly) but unlike m_Poly these filled polygons have no hole
|
2012-07-25 18:46:25 +00:00
|
|
|
* (they are all in one piece) In very simple cases m_FilledPolysList is same
|
2012-06-02 21:19:17 +00:00
|
|
|
* as m_Poly. In less simple cases (when m_Poly has holes) m_FilledPolysList is
|
|
|
|
* a polygon equivalent to m_Poly, without holes but with extra outline segment
|
|
|
|
* connecting "holes" with external main outline. In complex cases an outline
|
|
|
|
* described by m_Poly can have many filled areas
|
|
|
|
*/
|
2017-03-07 12:06:00 +00:00
|
|
|
SHAPE_POLY_SET m_FilledPolysList;
|
2017-04-25 09:06:24 +00:00
|
|
|
SHAPE_POLY_SET m_RawPolysList;
|
2017-03-07 12:06:00 +00:00
|
|
|
|
|
|
|
HATCH_STYLE m_hatchStyle; // hatch style, see enum above
|
|
|
|
int m_hatchPitch; // for DIAGONAL_EDGE, distance between 2 hatch lines
|
|
|
|
std::vector<SEG> m_HatchLines; // hatch lines
|
2017-11-23 16:20:27 +00:00
|
|
|
std::vector<int> m_insulatedIslands;
|
|
|
|
|
2018-02-20 14:51:40 +00:00
|
|
|
bool m_hv45; // constrain edges to horizontal, vertical or 45º
|
|
|
|
|
2017-03-07 12:06:00 +00:00
|
|
|
/**
|
|
|
|
* Union to handle conversion between references to wxPoint and to VECTOR2I.
|
|
|
|
*
|
|
|
|
* The function GetPosition(), that returns a reference to a wxPoint, needs some existing
|
|
|
|
* wxPoint object that it can point to. The header of this function cannot be changed, as it
|
|
|
|
* overrides the function from the base class BOARD_ITEM. This made sense when ZONE_CONTAINER
|
|
|
|
* was implemented using the legacy CPolyLine class, that worked with wxPoints. However,
|
|
|
|
* m_Poly is now a SHAPE_POLY_SET, whose corners are objects of type VECTOR2I, not wxPoint.
|
|
|
|
* Thus, we cannot directly reference the first corner of m_Poly, so a modified version of it
|
|
|
|
* that can be read as a wxPoint needs to be handled.
|
|
|
|
* Taking advantage of the fact that both wxPoint and VECTOR2I have the same memory layout
|
|
|
|
* (two integers: x, y), this union let us convert a reference to a VECTOR2I into a reference
|
|
|
|
* to a wxPoint.
|
|
|
|
*
|
|
|
|
* The idea is the following: in GetPosition(), m_Poly->GetCornerPosition( 0 ) returns a
|
|
|
|
* reference to the first corner of the polygon set. If we retrieve its memory direction, we
|
|
|
|
* can tell the compiler to cast that pointer to a WX_VECTOR_CONVERTER pointer. We can finally
|
|
|
|
* shape that memory layout as a wxPoint picking the wx member of the union.
|
|
|
|
*
|
|
|
|
* Although this solution is somewhat unstable, as it relies on the fact that the memory
|
|
|
|
* layout is exactly the same, it is the best attempt to keep backwards compatibility while
|
|
|
|
* using the new SHAPE_POLY_SET.
|
|
|
|
*/
|
|
|
|
typedef union {
|
|
|
|
wxPoint wx;
|
|
|
|
VECTOR2I vector;
|
|
|
|
} WX_VECTOR_CONVERTER;
|
|
|
|
|
|
|
|
// Sanity check: assure that the conversion VECTOR2I->wxPoint using the previous union is
|
|
|
|
// correct, making sure that the access for x and y attributes is still safe.
|
|
|
|
static_assert(offsetof(wxPoint,x) == offsetof(VECTOR2I,x),
|
|
|
|
"wxPoint::x and VECTOR2I::x have different offsets");
|
|
|
|
|
|
|
|
static_assert(offsetof(wxPoint,y) == offsetof(VECTOR2I,y),
|
|
|
|
"wxPoint::y and VECTOR2I::y have different offsets");
|
|
|
|
|
2007-12-09 12:59:06 +00:00
|
|
|
};
|
|
|
|
|
2008-01-23 22:39:09 +00:00
|
|
|
|
2011-12-14 04:29:25 +00:00
|
|
|
#endif // CLASS_ZONE_H_
|