2012-01-14 19:50:32 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2019-06-04 07:23:12 +00:00
|
|
|
* Copyright (C) 2019 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2022-01-08 15:56:41 +00:00
|
|
|
* Copyright (C) 1992-2022 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 ZONE_H
|
|
|
|
#define ZONE_H
|
2007-12-09 12:59:06 +00:00
|
|
|
|
2011-09-20 13:57:40 +00:00
|
|
|
|
2020-07-01 02:21:59 +00:00
|
|
|
#include <mutex>
|
2008-09-26 19:51:36 +00:00
|
|
|
#include <vector>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <gr_basic.h>
|
2020-11-14 18:11:28 +00:00
|
|
|
#include <board_item.h>
|
2018-02-02 20:57:12 +00:00
|
|
|
#include <board_connected_item.h>
|
2021-07-29 09:47:43 +00:00
|
|
|
#include <layer_ids.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>
|
2022-03-05 16:18:42 +00:00
|
|
|
#include <teardrop/teardrop_types.h>
|
2007-12-29 19:15:58 +00:00
|
|
|
|
2011-08-01 15:29:27 +00:00
|
|
|
|
2011-09-20 15:07:52 +00:00
|
|
|
class LINE_READER;
|
2011-09-20 13:57:40 +00:00
|
|
|
class PCB_EDIT_FRAME;
|
|
|
|
class BOARD;
|
2020-11-11 23:05:59 +00:00
|
|
|
class ZONE;
|
2013-01-12 17:32:24 +00:00
|
|
|
class MSG_PANEL_ITEM;
|
|
|
|
|
2011-08-01 15:29:27 +00:00
|
|
|
|
2011-09-20 15:07:52 +00:00
|
|
|
/**
|
2021-03-09 00:00:03 +00:00
|
|
|
* Handle a list of polygons defining a copper zone.
|
|
|
|
*
|
|
|
|
* A zone is described by a main polygon, a time stamp, a layer or a layer set, and a net name.
|
2011-09-20 15:07:52 +00:00
|
|
|
* Other polygons inside the main polygon are holes in the zone.
|
2019-10-26 15:49:29 +00:00
|
|
|
*
|
2020-11-11 23:05:59 +00:00
|
|
|
* a item ZONE is living in a board
|
|
|
|
* a variant FP_ZONE is living in a footprint
|
2008-01-23 22:39:09 +00:00
|
|
|
*/
|
2020-11-11 23:05:59 +00:00
|
|
|
class ZONE : public BOARD_CONNECTED_ITEM
|
2007-12-09 12:59:06 +00:00
|
|
|
{
|
|
|
|
public:
|
2011-09-20 15:07:52 +00:00
|
|
|
|
2019-10-26 15:49:29 +00:00
|
|
|
/**
|
2021-03-09 00:00:03 +00:00
|
|
|
* The ctor to build ZONE, but compatible with FP_ZONE requirement.
|
2020-11-11 23:05:59 +00:00
|
|
|
* if aInFP is true, a FP_ZONE is actually built
|
2019-10-26 15:49:29 +00:00
|
|
|
* (same item, but with a specific type id:
|
2020-11-11 23:05:59 +00:00
|
|
|
* The type is PCB_ZONE_T for a ZONE
|
|
|
|
* The type is PCB_FP_ZONE_T for a FP_ZONE
|
2019-10-26 15:49:29 +00:00
|
|
|
*/
|
2020-11-11 23:05:59 +00:00
|
|
|
ZONE( BOARD_ITEM_CONTAINER* parent, bool aInFP = false );
|
2012-01-14 19:50:32 +00:00
|
|
|
|
2020-11-11 23:05:59 +00:00
|
|
|
ZONE( const ZONE& aZone );
|
|
|
|
ZONE& operator=( const ZONE &aOther );
|
2012-01-14 19:50:32 +00:00
|
|
|
|
2020-11-11 23:05:59 +00:00
|
|
|
~ZONE();
|
2008-01-23 22:39:09 +00:00
|
|
|
|
2018-08-28 20:14:47 +00:00
|
|
|
static inline bool ClassOf( const EDA_ITEM* aItem )
|
|
|
|
{
|
2020-11-11 23:05:59 +00:00
|
|
|
return aItem && aItem->Type() == PCB_ZONE_T;
|
2018-08-28 20:14:47 +00:00
|
|
|
}
|
|
|
|
|
2020-11-15 17:48:25 +00:00
|
|
|
/**
|
|
|
|
* Not all ZONEs are *really* BOARD_CONNECTED_ITEMs....
|
|
|
|
*/
|
|
|
|
bool IsConnected() const override
|
|
|
|
{
|
|
|
|
return !GetIsRuleArea();
|
|
|
|
}
|
|
|
|
|
2020-07-27 17:56:15 +00:00
|
|
|
/**
|
|
|
|
* Copy aZone data to me
|
|
|
|
*/
|
2020-11-11 23:05:59 +00:00
|
|
|
void InitDataFromSrcInCopyCtor( const ZONE& aZone );
|
2020-07-27 17:56:15 +00:00
|
|
|
|
2022-10-07 21:21:24 +00:00
|
|
|
/**
|
|
|
|
* For rule areas which exclude footprints (and therefore participate in courtyard conflicts
|
|
|
|
* during move).
|
|
|
|
*/
|
|
|
|
bool IsConflicting() const;
|
|
|
|
|
2011-09-20 15:07:52 +00:00
|
|
|
/**
|
2022-01-01 06:04:08 +00:00
|
|
|
* @return a VECTOR2I, position of the first point of the outline
|
2009-08-06 18:30:46 +00:00
|
|
|
*/
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I GetPosition() const override;
|
|
|
|
void SetPosition( const VECTOR2I& aPos ) override {}
|
2011-11-24 17:32:51 +00:00
|
|
|
|
2012-01-29 19:29:19 +00:00
|
|
|
/**
|
2021-03-09 00:00:03 +00:00
|
|
|
* @param aPriority is the priority level.
|
2012-01-29 19:29:19 +00:00
|
|
|
*/
|
2022-03-01 14:53:35 +00:00
|
|
|
void SetAssignedPriority( unsigned aPriority ) { m_priority = aPriority; }
|
2012-01-29 19:29:19 +00:00
|
|
|
|
|
|
|
/**
|
2021-03-09 00:00:03 +00:00
|
|
|
* @return the priority level of this zone.
|
2012-01-29 19:29:19 +00:00
|
|
|
*/
|
2022-03-01 14:53:35 +00:00
|
|
|
unsigned GetAssignedPriority() const { return m_priority; }
|
|
|
|
|
|
|
|
bool HigherPriority( const ZONE* aOther ) const;
|
|
|
|
|
|
|
|
bool SameNet( const ZONE* aOther ) const;
|
2012-01-29 19:29:19 +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-23 22:39:09 +00:00
|
|
|
|
2020-08-09 11:22:09 +00:00
|
|
|
void SetLayerSet( LSET aLayerSet ) override;
|
2022-09-22 14:05:06 +00:00
|
|
|
virtual LSET GetLayerSet() const override { return m_layerSet; }
|
2017-12-01 15:53:58 +00:00
|
|
|
|
2020-06-24 01:09:15 +00:00
|
|
|
wxString GetZoneName() const { return m_zoneName; }
|
|
|
|
void SetZoneName( const wxString& aName ) { m_zoneName = aName; }
|
|
|
|
|
2022-08-05 02:40:38 +00:00
|
|
|
bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override
|
2021-01-06 18:53:55 +00:00
|
|
|
{
|
|
|
|
return BOARD_ITEM::Matches( GetZoneName(), aSearchData );
|
|
|
|
}
|
|
|
|
|
2020-09-21 19:20:20 +00:00
|
|
|
/**
|
2022-08-31 09:15:42 +00:00
|
|
|
* @return the bounding box of the zone outline.
|
2008-11-18 18:13:55 +00:00
|
|
|
*/
|
2022-08-31 09:15:42 +00:00
|
|
|
const BOX2I GetBoundingBox() const override;
|
2008-11-18 18:13:55 +00:00
|
|
|
|
2020-09-21 19:20:20 +00:00
|
|
|
/**
|
2022-10-01 21:09:38 +00:00
|
|
|
* Used to preload the zone bounding box cache so we don't have to worry about mutex-locking
|
|
|
|
* it each time.
|
2020-09-21 19:20:20 +00:00
|
|
|
*/
|
2022-10-01 21:09:38 +00:00
|
|
|
void CacheBoundingBox();
|
2020-09-21 19:20:20 +00:00
|
|
|
|
2020-05-29 12:36:45 +00:00
|
|
|
/**
|
2021-03-09 00:00:03 +00:00
|
|
|
* Return any local clearances set in the "classic" (ie: pre-rule) system. These are
|
2020-05-29 12:36:45 +00:00
|
|
|
* things like zone clearance which are NOT an override.
|
2021-03-09 00:00:03 +00:00
|
|
|
*
|
2020-05-29 12:36:45 +00:00
|
|
|
* @param aSource [out] optionally reports the source as a user-readable string
|
2021-03-09 00:00:03 +00:00
|
|
|
* @return the clearance in internal units.
|
2020-05-29 12:36:45 +00:00
|
|
|
*/
|
2020-09-05 16:00:29 +00:00
|
|
|
int GetLocalClearance( wxString* aSource ) const override;
|
|
|
|
|
|
|
|
int GetLocalClearance() const { return GetLocalClearance( nullptr ); }
|
|
|
|
void SetLocalClearance( int aClearance ) { m_ZoneClearance = aClearance; }
|
2011-08-09 03:41:20 +00:00
|
|
|
|
2008-09-26 19:51:36 +00:00
|
|
|
/**
|
2021-03-09 00:00:03 +00:00
|
|
|
* @return true if this zone is on a copper layer, false if on a technical layer.
|
2008-09-26 19:51:36 +00:00
|
|
|
*/
|
2019-07-25 11:08:41 +00:00
|
|
|
bool IsOnCopperLayer() const override;
|
2017-12-01 15:53:58 +00:00
|
|
|
|
|
|
|
virtual void SetLayer( PCB_LAYER_ID aLayer ) override;
|
|
|
|
|
|
|
|
virtual PCB_LAYER_ID GetLayer() const override;
|
|
|
|
|
2022-02-18 10:12:11 +00:00
|
|
|
// Return the first layer in GUI sequence.
|
|
|
|
PCB_LAYER_ID GetFirstLayer() const;
|
|
|
|
|
2017-12-01 15:53:58 +00:00
|
|
|
virtual bool IsOnLayer( PCB_LAYER_ID ) const override;
|
|
|
|
|
|
|
|
virtual void ViewGetLayers( int aLayers[], int& aCount ) const override;
|
2020-07-11 17:42:00 +00:00
|
|
|
|
2020-09-21 15:03:08 +00:00
|
|
|
double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
|
2017-12-01 15:53:58 +00:00
|
|
|
|
2020-09-17 13:14:45 +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
|
|
|
|
2020-09-05 16:00:29 +00:00
|
|
|
void SetThermalReliefGap( int aThermalReliefGap )
|
|
|
|
{
|
2020-09-17 13:14:45 +00:00
|
|
|
if( m_thermalReliefGap != aThermalReliefGap )
|
2020-09-05 16:00:29 +00:00
|
|
|
SetNeedRefill( true );
|
|
|
|
|
2020-09-17 13:14:45 +00:00
|
|
|
m_thermalReliefGap = aThermalReliefGap;
|
2020-09-05 16:00:29 +00:00
|
|
|
}
|
2021-07-26 19:35:12 +00:00
|
|
|
|
2020-09-17 13:14:45 +00:00
|
|
|
int GetThermalReliefGap() const { return m_thermalReliefGap; }
|
2020-11-12 22:30:02 +00:00
|
|
|
int GetThermalReliefGap( PAD* aPad, wxString* aSource = nullptr ) const;
|
2011-11-30 21:15:56 +00:00
|
|
|
|
2020-09-17 13:14:45 +00:00
|
|
|
void SetThermalReliefSpokeWidth( int aThermalReliefSpokeWidth )
|
2012-01-14 19:50:32 +00:00
|
|
|
{
|
2020-09-17 13:14:45 +00:00
|
|
|
if( m_thermalReliefSpokeWidth != aThermalReliefSpokeWidth )
|
2019-03-14 13:35:55 +00:00
|
|
|
SetNeedRefill( true );
|
|
|
|
|
2020-09-17 13:14:45 +00:00
|
|
|
m_thermalReliefSpokeWidth = aThermalReliefSpokeWidth;
|
2012-01-14 19:50:32 +00:00
|
|
|
}
|
2021-07-26 19:35:12 +00:00
|
|
|
|
2020-09-17 13:14:45 +00:00
|
|
|
int GetThermalReliefSpokeWidth() const { return m_thermalReliefSpokeWidth; }
|
2011-11-30 21:15:56 +00:00
|
|
|
|
2020-02-05 09:43:52 +00:00
|
|
|
/**
|
|
|
|
* Compute the area currently occupied by the zone fill.
|
|
|
|
*
|
|
|
|
* @return the currently filled area
|
|
|
|
*/
|
|
|
|
double CalculateFilledArea();
|
|
|
|
|
2022-01-08 15:56:41 +00:00
|
|
|
/**
|
|
|
|
* Compute the area of the zone outline (not the filled area).
|
|
|
|
* @return the currently calculated area
|
|
|
|
*/
|
|
|
|
double CalculateOutlineArea();
|
|
|
|
|
2020-02-05 09:43:52 +00:00
|
|
|
/**
|
|
|
|
* This area is cached from the most recent call to CalculateFilledArea().
|
|
|
|
*
|
|
|
|
* @return the filled area
|
|
|
|
*/
|
|
|
|
double GetFilledArea()
|
|
|
|
{
|
|
|
|
return m_area;
|
|
|
|
}
|
|
|
|
|
2022-01-08 15:56:41 +00:00
|
|
|
/**
|
|
|
|
* This area is cached from the most recent call to CalculateOutlineArea().
|
|
|
|
*
|
|
|
|
* @return the outline area
|
|
|
|
*/
|
|
|
|
double GetOutlineArea()
|
|
|
|
{
|
|
|
|
return m_outlinearea;
|
|
|
|
}
|
|
|
|
|
2020-07-01 02:21:59 +00:00
|
|
|
std::mutex& GetLock()
|
|
|
|
{
|
|
|
|
return m_lock;
|
|
|
|
}
|
|
|
|
|
2020-09-17 13:14:45 +00:00
|
|
|
int GetFillFlag( PCB_LAYER_ID aLayer )
|
|
|
|
{
|
2022-09-19 17:09:09 +00:00
|
|
|
return m_fillFlags.test( aLayer );
|
2020-09-17 13:14:45 +00:00
|
|
|
}
|
2021-07-26 19:35:12 +00:00
|
|
|
|
2022-11-01 13:19:33 +00:00
|
|
|
void SetFillFlag( PCB_LAYER_ID aLayer, bool aFlag ) { m_fillFlags.set( aLayer, aFlag ); }
|
2020-09-17 13:14:45 +00:00
|
|
|
|
|
|
|
bool IsFilled() const { return m_isFilled; }
|
|
|
|
void SetIsFilled( bool isFilled ) { m_isFilled = isFilled; }
|
2011-11-30 21:15:56 +00:00
|
|
|
|
2019-03-14 13:35:55 +00:00
|
|
|
bool NeedRefill() const { return m_needRefill; }
|
|
|
|
void SetNeedRefill( bool aNeedRefill ) { m_needRefill = aNeedRefill; }
|
|
|
|
|
2020-09-05 16:00:29 +00:00
|
|
|
ZONE_CONNECTION GetPadConnection() const { return m_PadConnection; }
|
|
|
|
void SetPadConnection( ZONE_CONNECTION aPadConnection ) { m_PadConnection = aPadConnection; }
|
2011-11-30 21:15:56 +00:00
|
|
|
|
|
|
|
int GetMinThickness() const { return m_ZoneMinThickness; }
|
2019-03-14 13:35:55 +00:00
|
|
|
void SetMinThickness( int aMinThickness )
|
|
|
|
{
|
|
|
|
if( m_ZoneMinThickness != aMinThickness )
|
|
|
|
SetNeedRefill( true );
|
|
|
|
|
|
|
|
m_ZoneMinThickness = aMinThickness;
|
|
|
|
}
|
2011-02-25 20:37:48 +00:00
|
|
|
|
2020-08-07 14:04:34 +00:00
|
|
|
int GetHatchThickness() const { return m_hatchThickness; }
|
|
|
|
void SetHatchThickness( int aThickness ) { m_hatchThickness = aThickness; }
|
2018-02-18 09:09:13 +00:00
|
|
|
|
2020-08-07 14:04:34 +00:00
|
|
|
int GetHatchGap() const { return m_hatchGap; }
|
|
|
|
void SetHatchGap( int aStep ) { m_hatchGap = aStep; }
|
2018-02-18 09:09:13 +00:00
|
|
|
|
2022-01-19 00:22:40 +00:00
|
|
|
EDA_ANGLE GetHatchOrientation() const { return m_hatchOrientation; }
|
|
|
|
void SetHatchOrientation( const EDA_ANGLE& aStep ) { m_hatchOrientation = aStep; }
|
2018-02-18 09:09:13 +00:00
|
|
|
|
2020-08-07 14:04:34 +00:00
|
|
|
int GetHatchSmoothingLevel() const { return m_hatchSmoothingLevel; }
|
|
|
|
void SetHatchSmoothingLevel( int aLevel ) { m_hatchSmoothingLevel = aLevel; }
|
2018-02-18 09:09:13 +00:00
|
|
|
|
2020-08-07 14:04:34 +00:00
|
|
|
double GetHatchSmoothingValue() const { return m_hatchSmoothingValue; }
|
|
|
|
void SetHatchSmoothingValue( double aValue ) { m_hatchSmoothingValue = aValue; }
|
|
|
|
|
|
|
|
double GetHatchHoleMinArea() const { return m_hatchHoleMinArea; }
|
|
|
|
void SetHatchHoleMinArea( double aPct ) { m_hatchHoleMinArea = aPct; }
|
|
|
|
|
|
|
|
int GetHatchBorderAlgorithm() const { return m_hatchBorderAlgorithm; }
|
|
|
|
void SetHatchBorderAlgorithm( int aAlgo ) { m_hatchBorderAlgorithm = aAlgo; }
|
2018-02-18 09:09:13 +00:00
|
|
|
|
2017-03-07 12:06:00 +00:00
|
|
|
int GetSelectedCorner() const
|
|
|
|
{
|
|
|
|
// Transform relative indices to global index
|
2018-12-20 00:12:43 +00:00
|
|
|
int globalIndex = -1;
|
|
|
|
|
|
|
|
if( m_CornerSelection )
|
|
|
|
m_Poly->GetGlobalIndex( *m_CornerSelection, globalIndex );
|
2017-03-07 12:06:00 +00:00
|
|
|
|
|
|
|
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
|
|
|
///
|
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-03-07 12:06:00 +00:00
|
|
|
SHAPE_POLY_SET* Outline() { return m_Poly; }
|
2020-12-20 18:44:13 +00:00
|
|
|
const SHAPE_POLY_SET* Outline() const { return 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
|
|
|
|
2020-08-26 22:04:16 +00:00
|
|
|
// @copydoc BOARD_ITEM::GetEffectiveShape
|
2020-12-12 15:14:41 +00:00
|
|
|
virtual std::shared_ptr<SHAPE>
|
2022-03-16 23:48:24 +00:00
|
|
|
GetEffectiveShape( PCB_LAYER_ID aLayer = UNDEFINED_LAYER,
|
|
|
|
FLASHING aFlash = FLASHING::DEFAULT ) const override;
|
2020-08-26 22:04:16 +00:00
|
|
|
|
2013-09-21 18:09:41 +00:00
|
|
|
/**
|
2021-03-09 00:00:03 +00:00
|
|
|
* Test if a point is near an outline edge or a corner of this zone.
|
|
|
|
*
|
2022-01-01 06:04:08 +00:00
|
|
|
* @param aPosition the VECTOR2I to test
|
2021-03-09 00:00:03 +00:00
|
|
|
* @return true if a hit, else false
|
2013-09-21 18:09:41 +00:00
|
|
|
*/
|
2022-01-01 06:04:08 +00:00
|
|
|
bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
|
2008-09-26 19:51:36 +00:00
|
|
|
|
2008-11-27 10:12:46 +00:00
|
|
|
/**
|
2022-01-01 06:04:08 +00:00
|
|
|
* Test if the given VECTOR2I is within the bounds of a filled area of this zone.
|
2021-03-09 00:00:03 +00:00
|
|
|
*
|
2020-06-24 02:19:08 +00:00
|
|
|
* @param aLayer is the layer to test on
|
2022-01-01 06:04:08 +00:00
|
|
|
* @param aRefPos A VECTOR2I to test
|
2020-08-05 20:15:27 +00:00
|
|
|
* @param aAccuracy Expand the distance by which the areas are expanded for the hittest
|
2021-03-09 00:00:03 +00:00
|
|
|
* @return true if a hit, else false
|
2008-11-27 10:12:46 +00:00
|
|
|
*/
|
2022-01-01 06:04:08 +00:00
|
|
|
bool HitTestFilledArea( PCB_LAYER_ID aLayer, const VECTOR2I& aRefPos, int aAccuracy = 0 ) const;
|
2008-11-27 10:12:46 +00:00
|
|
|
|
2020-04-14 16:57:18 +00:00
|
|
|
/**
|
2021-03-09 00:00:03 +00:00
|
|
|
* Test if the given point is contained within a cutout of the zone.
|
2020-04-14 16:57:18 +00:00
|
|
|
*
|
|
|
|
* @param aRefPos is the point to test
|
|
|
|
* @param aOutlineIdx is the index of the outline containing the cutout
|
|
|
|
* @param aHoleIdx is the index of the hole
|
|
|
|
* @return true if aRefPos is inside a zone cutout
|
|
|
|
*/
|
|
|
|
bool HitTestCutout( const VECTOR2I& aRefPos, int* aOutlineIdx = nullptr,
|
2020-12-12 15:14:41 +00:00
|
|
|
int* aHoleIdx = nullptr ) const;
|
2020-04-14 16:57:18 +00:00
|
|
|
|
2019-07-13 22:34:09 +00:00
|
|
|
/**
|
|
|
|
* Some intersecting zones, despite being on the same layer with the same net, cannot be
|
|
|
|
* merged due to other parameters such as fillet radius. The copper pour will end up
|
2020-08-12 18:42:40 +00:00
|
|
|
* effectively merged though, so we need to do some calculations with them in mind.
|
2019-07-13 22:34:09 +00:00
|
|
|
*/
|
2022-11-01 10:55:35 +00:00
|
|
|
void GetInteractingZones( PCB_LAYER_ID aLayer, std::vector<ZONE*>* aSameNetCollidingZones,
|
|
|
|
std::vector<ZONE*>* aOtherNetIntersectingZones ) const;
|
2019-07-13 22:34:09 +00:00
|
|
|
|
2019-05-14 12:39:34 +00:00
|
|
|
/**
|
2013-05-01 19:01:14 +00:00
|
|
|
* 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
|
2021-03-09 00:00:03 +00:00
|
|
|
*
|
2020-06-24 02:19:08 +00:00
|
|
|
* @param aLayer is the layer of the zone to retrieve
|
2022-10-21 12:48:45 +00:00
|
|
|
* @param aBuffer = a buffer to store the polygons
|
2019-05-14 12:39:34 +00:00
|
|
|
* @param aError = Maximum error allowed between true arc and polygon approx
|
2013-05-01 19:01:14 +00:00
|
|
|
*/
|
2022-10-21 12:48:45 +00:00
|
|
|
void TransformSolidAreasShapesToPolygon( PCB_LAYER_ID aLayer, SHAPE_POLY_SET& aBuffer ) const;
|
2013-05-01 19:01:14 +00:00
|
|
|
|
2019-05-14 12:39:34 +00:00
|
|
|
/**
|
2013-05-01 19:01:14 +00:00
|
|
|
* 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
|
2021-03-09 00:00:03 +00:00
|
|
|
* Circles (vias) and arcs (ends of tracks) are approximated by segments.
|
|
|
|
*
|
2022-10-21 12:48:45 +00:00
|
|
|
* @param aBuffer is a buffer to store the polygon
|
2021-03-09 00:00:03 +00:00
|
|
|
* @param aClearance is the min clearance around outlines
|
|
|
|
* @param aBoardOutline is the board outline (if a valid one exists; nullptr otherwise)
|
2013-05-01 19:01:14 +00:00
|
|
|
*/
|
2022-10-21 12:48:45 +00:00
|
|
|
void TransformSmoothedOutlineToPolygon( SHAPE_POLY_SET& aBuffer, int aClearance,
|
2022-02-21 15:19:20 +00:00
|
|
|
int aError, ERROR_LOC aErrorLoc,
|
2020-10-10 22:09:00 +00:00
|
|
|
SHAPE_POLY_SET* aBoardOutline ) const;
|
2017-11-29 18:51:01 +00:00
|
|
|
|
2018-11-14 23:34:32 +00:00
|
|
|
/**
|
|
|
|
* Convert the zone shape to a closed polygon
|
|
|
|
* Used in filling zones calculations
|
|
|
|
* Circles and arcs are approximated by segments
|
2021-03-09 00:00:03 +00:00
|
|
|
*
|
2020-06-24 02:19:08 +00:00
|
|
|
* @param aLayer is the layer of the filled zone to retrieve
|
2022-10-21 12:48:45 +00:00
|
|
|
* @param aBuffer is a buffer to store the polygon
|
|
|
|
* @param aClearance is the clearance around the pad
|
2021-03-09 00:00:03 +00:00
|
|
|
* @param aError is the maximum deviation from true circle
|
2022-10-21 12:48:45 +00:00
|
|
|
* @param ignoreLineWidth is used for edge cut items where the line width is only for
|
|
|
|
* visualization
|
2018-11-14 23:34:32 +00:00
|
|
|
*/
|
2022-10-21 12:48:45 +00:00
|
|
|
void TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer,
|
|
|
|
int aClearance, int aError, ERROR_LOC aErrorLoc,
|
|
|
|
bool ignoreLineWidth = false ) const override;
|
2017-11-29 18:51:01 +00:00
|
|
|
|
2009-08-06 18:30:46 +00:00
|
|
|
/**
|
2022-01-01 06:04:08 +00:00
|
|
|
* Test if the given VECTOR2I is near a corner.
|
2021-03-09 00:00:03 +00:00
|
|
|
*
|
2022-01-01 06:04:08 +00:00
|
|
|
* @param refPos is the VECTOR2I to test.
|
2018-11-17 00:34:12 +00:00
|
|
|
* @param aAccuracy increase the item bounding box by this amount.
|
2022-07-16 17:41:59 +00:00
|
|
|
* @param aCornerHit [out, optional] is the index of the closest vertex found when return
|
|
|
|
* value is true
|
2021-03-09 00:00:03 +00:00
|
|
|
* @return true if some corner was found to be closer to refPos than aClearance; false
|
|
|
|
* otherwise.
|
2017-03-07 12:06:00 +00:00
|
|
|
*/
|
2022-01-01 06:04:08 +00:00
|
|
|
bool HitTestForCorner( const VECTOR2I& refPos, int aAccuracy,
|
2022-07-16 17:41:59 +00:00
|
|
|
SHAPE_POLY_SET::VERTEX_INDEX* aCornerHit = nullptr ) const;
|
2017-03-07 12:06:00 +00:00
|
|
|
|
|
|
|
/**
|
2022-01-01 06:04:08 +00:00
|
|
|
* Test if the given VECTOR2I is near a segment defined by 2 corners.
|
2021-03-09 00:00:03 +00:00
|
|
|
*
|
2022-01-01 06:04:08 +00:00
|
|
|
* @param refPos is the VECTOR2I to test.
|
2018-11-17 00:34:12 +00:00
|
|
|
* @param aAccuracy increase the item bounding box by this amount.
|
2022-07-16 17:41:59 +00:00
|
|
|
* @param aCornerHit [out, optional] is the index of the closest vertex found when return
|
|
|
|
* value is true.
|
2021-03-09 00:00:03 +00:00
|
|
|
* @return true if some edge was found to be closer to refPos than aClearance.
|
2008-01-23 22:39:09 +00:00
|
|
|
*/
|
2022-01-01 06:04:08 +00:00
|
|
|
bool HitTestForEdge( const VECTOR2I& refPos, int aAccuracy,
|
2022-07-16 17:41:59 +00:00
|
|
|
SHAPE_POLY_SET::VERTEX_INDEX* aCornerHit = nullptr ) const;
|
2008-01-23 22:39:09 +00:00
|
|
|
|
2021-03-09 00:00:03 +00:00
|
|
|
/**
|
2022-08-31 16:17:14 +00:00
|
|
|
* @copydoc BOARD_ITEM::HitTest(const BOX2I& aRect, bool aContained, int aAccuracy) const
|
2013-09-21 18:09:41 +00:00
|
|
|
*/
|
2022-08-31 09:33:46 +00:00
|
|
|
bool HitTest( const BOX2I& aRect, bool aContained = true, int aAccuracy = 0 ) const override;
|
2008-01-06 12:43:57 +00:00
|
|
|
|
2011-07-16 16:04:49 +00:00
|
|
|
/**
|
2021-03-09 00:00:03 +00:00
|
|
|
* Removes the zone filling.
|
|
|
|
*
|
|
|
|
* @return true if a previous filling is removed, false if no change (when no filling found).
|
2011-07-16 16:04:49 +00:00
|
|
|
*/
|
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: */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Move the outlines
|
2021-03-09 00:00:03 +00:00
|
|
|
*
|
|
|
|
* @param offset is moving vector
|
2008-01-23 22:39:09 +00:00
|
|
|
*/
|
2022-01-01 06:04:08 +00:00
|
|
|
void Move( const VECTOR2I& offset ) override;
|
2008-01-23 22:39:09 +00:00
|
|
|
|
|
|
|
/**
|
2021-03-09 00:00:03 +00:00
|
|
|
* Move the outline Edge.
|
|
|
|
*
|
|
|
|
* @param offset is moving vector
|
|
|
|
* @param aEdge is start point of the outline edge
|
2008-02-01 21:30:45 +00:00
|
|
|
*/
|
2022-01-01 06:04:08 +00:00
|
|
|
void MoveEdge( const VECTOR2I& offset, int aEdge );
|
2008-02-01 21:30:45 +00:00
|
|
|
|
|
|
|
/**
|
2022-01-13 19:32:00 +00:00
|
|
|
* Rotate the outlines.
|
2021-03-09 00:00:03 +00:00
|
|
|
*
|
|
|
|
* @param aCentre is rot centre
|
2008-01-23 22:39:09 +00:00
|
|
|
*/
|
2022-01-13 19:32:00 +00:00
|
|
|
void Rotate( const VECTOR2I& aCentre, const EDA_ANGLE& aAngle ) override;
|
2008-01-23 22:39:09 +00:00
|
|
|
|
2009-08-01 19:26:05 +00:00
|
|
|
/**
|
|
|
|
* Flip this object, i.e. change the board side for this object
|
2021-03-09 00:00:03 +00:00
|
|
|
* (like Mirror() but changes layer).
|
|
|
|
*
|
|
|
|
* @param aCentre is the rotation point.
|
2009-08-01 19:26:05 +00:00
|
|
|
*/
|
2022-01-01 06:04:08 +00:00
|
|
|
virtual void Flip( const VECTOR2I& aCentre, bool aFlipLeftRight ) override;
|
2009-08-01 19:26:05 +00:00
|
|
|
|
2008-01-23 22:39:09 +00:00
|
|
|
/**
|
2021-03-09 00:00:03 +00:00
|
|
|
* Mirror the outlines relative to a given horizontal axis the layer is not changed.
|
|
|
|
*
|
|
|
|
* @param aMirrorRef is axis position
|
2019-07-12 21:02:10 +00:00
|
|
|
* @param aMirrorLeftRight mirror across Y axis (otherwise mirror across X)
|
2008-01-23 22:39:09 +00:00
|
|
|
*/
|
2022-01-01 06:04:08 +00:00
|
|
|
void Mirror( const VECTOR2I& aMirrorRef, bool aMirrorLeftRight );
|
2008-04-01 05:21:50 +00:00
|
|
|
|
2008-01-23 22:39:09 +00:00
|
|
|
/**
|
2021-03-09 00:00:03 +00:00
|
|
|
* @return the class name.
|
2008-01-23 22:39:09 +00:00
|
|
|
*/
|
2016-09-24 18:53:15 +00:00
|
|
|
wxString GetClass() const override
|
2008-01-23 22:39:09 +00:00
|
|
|
{
|
2020-11-11 23:05:59 +00:00
|
|
|
return wxT( "ZONE" );
|
2008-01-23 22:39:09 +00:00
|
|
|
}
|
2008-04-01 05:21:50 +00:00
|
|
|
|
2021-03-09 00:00:03 +00:00
|
|
|
/**
|
|
|
|
* Access to m_Poly parameters
|
2008-09-26 19:51:36 +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();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-03-09 00:00:03 +00:00
|
|
|
* Return an iterator to visit all points of the zone's main outline without holes.
|
|
|
|
*
|
|
|
|
* @return an iterator to visit the zone vertices without holes.
|
2017-03-07 12:06:00 +00:00
|
|
|
*/
|
|
|
|
SHAPE_POLY_SET::ITERATOR Iterate()
|
|
|
|
{
|
|
|
|
return m_Poly->Iterate();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-03-09 00:00:03 +00:00
|
|
|
* Return an iterator to visit all points of the zone's main outline with holes.
|
|
|
|
*
|
|
|
|
* @return an iterator to visit the zone vertices with holes.
|
2017-03-07 12:06:00 +00:00
|
|
|
*/
|
|
|
|
SHAPE_POLY_SET::ITERATOR IterateWithHoles()
|
|
|
|
{
|
|
|
|
return m_Poly->IterateWithHoles();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-03-09 00:00:03 +00:00
|
|
|
* Return an iterator to visit all points of the zone's main outline with holes.
|
|
|
|
*
|
|
|
|
* @return an iterator to visit the zone vertices with holes.
|
2017-03-07 12:06:00 +00:00
|
|
|
*/
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
void SetCornerPosition( int aCornerIndex, const VECTOR2I& 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 ) )
|
|
|
|
{
|
2019-03-23 18:26:44 +00:00
|
|
|
if( m_Poly->CVertex( relativeIndices ).x != new_pos.x
|
|
|
|
|| m_Poly->CVertex( relativeIndices ).y != new_pos.y )
|
|
|
|
{
|
2019-03-14 13:35:55 +00:00
|
|
|
SetNeedRefill( true );
|
2019-03-23 18:26:44 +00:00
|
|
|
m_Poly->SetVertex( relativeIndices, new_pos );
|
|
|
|
}
|
2017-03-07 12:06:00 +00:00
|
|
|
}
|
|
|
|
else
|
2020-12-12 15:14:41 +00:00
|
|
|
{
|
2017-03-07 12:06:00 +00:00
|
|
|
throw( std::out_of_range( "aCornerIndex-th vertex does not exist" ) );
|
2020-12-12 15:14:41 +00:00
|
|
|
}
|
2017-03-07 12:06:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-03-09 00:00:03 +00:00
|
|
|
* Create a new hole on the zone; i.e., a new contour on the zone's outline.
|
2017-03-07 12:06:00 +00:00
|
|
|
*/
|
|
|
|
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)
|
2021-03-09 00:00:03 +00:00
|
|
|
*
|
2017-06-19 11:29:57 +00:00
|
|
|
* @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
|
|
|
*/
|
2022-01-01 06:04:08 +00:00
|
|
|
bool AppendCorner( VECTOR2I aPosition, int aHoleIdx, bool aAllowDuplication = false );
|
2008-10-23 10:26:06 +00:00
|
|
|
|
2020-08-07 14:04:34 +00:00
|
|
|
ZONE_BORDER_DISPLAY_STYLE GetHatchStyle() const { return m_borderStyle; }
|
|
|
|
void SetHatchStyle( ZONE_BORDER_DISPLAY_STYLE aStyle ) { m_borderStyle = aStyle; }
|
2012-06-09 17:00:13 +00:00
|
|
|
|
2013-05-01 19:01:14 +00:00
|
|
|
/**
|
2021-03-09 00:00:03 +00:00
|
|
|
* Test if 2 zones are equivalent.
|
|
|
|
*
|
|
|
|
* Zones are equivalent if they have same parameters and same outline info.
|
|
|
|
*
|
|
|
|
* @note Filling is not taken into account.
|
|
|
|
*
|
|
|
|
* @param aZoneToCompare is the zone to compare with "this"
|
2009-08-23 15:22:44 +00:00
|
|
|
*/
|
2020-11-11 23:05:59 +00:00
|
|
|
bool IsSame( const ZONE &aZoneToCompare );
|
2011-02-21 19:43:59 +00:00
|
|
|
|
2020-07-24 00:25:34 +00:00
|
|
|
bool HasFilledPolysForLayer( PCB_LAYER_ID aLayer ) const
|
|
|
|
{
|
|
|
|
return m_FilledPolysList.count( aLayer ) > 0;
|
|
|
|
}
|
|
|
|
|
2021-03-09 00:00:03 +00:00
|
|
|
/**
|
|
|
|
* @return a reference to the list of filled polygons.
|
2012-06-02 21:19:17 +00:00
|
|
|
*/
|
2022-02-15 17:34:38 +00:00
|
|
|
const std::shared_ptr<SHAPE_POLY_SET>& GetFilledPolysList( PCB_LAYER_ID aLayer ) const
|
2012-06-02 21:19:17 +00:00
|
|
|
{
|
2020-06-24 02:19:08 +00:00
|
|
|
wxASSERT( m_FilledPolysList.count( aLayer ) );
|
|
|
|
return m_FilledPolysList.at( aLayer );
|
2012-06-02 21:19:17 +00:00
|
|
|
}
|
|
|
|
|
2021-08-12 16:58:30 +00:00
|
|
|
SHAPE_POLY_SET* GetFill( PCB_LAYER_ID aLayer )
|
|
|
|
{
|
|
|
|
wxASSERT( m_FilledPolysList.count( aLayer ) );
|
2022-02-15 17:34:38 +00:00
|
|
|
return m_FilledPolysList.at( aLayer ).get();
|
2021-08-12 16:58:30 +00:00
|
|
|
}
|
|
|
|
|
2021-03-09 00:00:03 +00:00
|
|
|
/**
|
|
|
|
* Create a list of triangles that "fill" the solid areas used for instance to draw
|
|
|
|
* these solid areas on OpenGL.
|
2018-12-02 17:00:33 +00:00
|
|
|
*/
|
2020-09-14 17:54:14 +00:00
|
|
|
void CacheTriangulation( PCB_LAYER_ID aLayer = UNDEFINED_LAYER );
|
2017-11-23 16:20:27 +00:00
|
|
|
|
2021-03-09 00:00:03 +00:00
|
|
|
/**
|
|
|
|
* Set the list of filled polygons.
|
2012-06-02 21:19:17 +00:00
|
|
|
*/
|
2020-11-18 19:50:36 +00:00
|
|
|
void SetFilledPolysList( PCB_LAYER_ID aLayer, const SHAPE_POLY_SET& aPolysList )
|
2012-06-02 21:19:17 +00:00
|
|
|
{
|
2022-02-15 17:34:38 +00:00
|
|
|
m_FilledPolysList[aLayer] = std::make_shared<SHAPE_POLY_SET>( aPolysList );
|
2012-06-02 21:19:17 +00:00
|
|
|
}
|
|
|
|
|
2020-06-26 02:19:51 +00:00
|
|
|
/**
|
2021-03-09 00:00:03 +00:00
|
|
|
* Check if a given filled polygon is an insulated island.
|
|
|
|
*
|
2020-06-26 02:19:51 +00:00
|
|
|
* @param aLayer is the layer to test
|
2020-12-20 18:50:45 +00:00
|
|
|
* @param aPolyIdx is an index into m_FilledPolysList[aLayer]
|
2020-06-26 02:19:51 +00:00
|
|
|
* @return true if the given polygon is insulated (i.e. has no net connection)
|
|
|
|
*/
|
2020-12-20 18:44:13 +00:00
|
|
|
bool IsIsland( PCB_LAYER_ID aLayer, int aPolyIdx ) const;
|
2020-06-26 02:19:51 +00:00
|
|
|
|
|
|
|
void SetIsIsland( PCB_LAYER_ID aLayer, int aPolyIdx )
|
|
|
|
{
|
|
|
|
m_insulatedIslands[aLayer].insert( aPolyIdx );
|
|
|
|
}
|
2017-12-04 18:06:47 +00:00
|
|
|
|
2020-10-10 22:09:00 +00:00
|
|
|
bool BuildSmoothedPoly( SHAPE_POLY_SET& aSmoothedPoly, PCB_LAYER_ID aLayer,
|
2020-10-29 21:17:57 +00:00
|
|
|
SHAPE_POLY_SET* aBoardOutline,
|
|
|
|
SHAPE_POLY_SET* aSmoothedPolyWithApron = nullptr ) 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
|
|
|
|
2019-06-04 07:23:12 +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
|
|
|
|
2019-06-04 07:23:12 +00:00
|
|
|
unsigned int GetCornerRadius() const { return m_cornerRadius; }
|
|
|
|
|
2020-04-14 16:57:18 +00:00
|
|
|
/**
|
|
|
|
* Remove a cutout from the zone.
|
|
|
|
*
|
|
|
|
* @param aOutlineIdx is the zone outline the hole belongs to
|
|
|
|
* @param aHoleIdx is the hole in the outline to remove
|
|
|
|
*/
|
|
|
|
void RemoveCutout( int aOutlineIdx, int aHoleIdx );
|
|
|
|
|
2017-04-07 06:02:26 +00:00
|
|
|
/**
|
2021-03-09 00:00:03 +00:00
|
|
|
* Add a polygon to the zone outline.
|
|
|
|
*
|
|
|
|
* If the zone outline is empty, this is the main outline. Otherwise it is a hole
|
|
|
|
* inside the main outline.
|
2017-04-07 06:02:26 +00:00
|
|
|
*/
|
2022-01-01 06:04:08 +00:00
|
|
|
void AddPolygon( std::vector<VECTOR2I>& aPolygon );
|
2012-06-09 17:00:13 +00:00
|
|
|
|
2019-05-21 02:31:40 +00:00
|
|
|
void AddPolygon( const SHAPE_LINE_CHAIN& aPolygon );
|
|
|
|
|
2022-09-19 16:09:59 +00:00
|
|
|
wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const override;
|
2011-07-14 15:42:44 +00:00
|
|
|
|
2021-03-08 02:59:07 +00:00
|
|
|
BITMAPS 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
|
|
|
|
2022-01-08 15:56:41 +00:00
|
|
|
/**
|
|
|
|
* @return true if the zone is a teardrop area
|
|
|
|
*/
|
|
|
|
bool IsTeardropArea() const { return m_teardropType != TEARDROP_TYPE::TD_NONE; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the type of teardrop if the zone is a teardrop area
|
|
|
|
* for non teardrop area, the type must be TEARDROP_TYPE::TD_NONE
|
|
|
|
*/
|
|
|
|
void SetTeardropAreaType( TEARDROP_TYPE aType ) { m_teardropType = aType; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the type of the teardrop ( has meaning only if the zone is a teardrop area)
|
|
|
|
*/
|
|
|
|
TEARDROP_TYPE GetTeardropAreaType() const { return m_teardropType; }
|
|
|
|
|
2012-07-13 18:55:29 +00:00
|
|
|
/**
|
2020-09-21 23:32:07 +00:00
|
|
|
* Accessors to parameters used in Rule Area zones:
|
2012-07-13 18:55:29 +00:00
|
|
|
*/
|
2021-10-26 16:19:30 +00:00
|
|
|
bool GetIsRuleArea() const { return m_isRuleArea; }
|
2012-07-14 16:27:25 +00:00
|
|
|
bool GetDoNotAllowCopperPour() const { return m_doNotAllowCopperPour; }
|
2021-10-26 16:19:30 +00:00
|
|
|
bool GetDoNotAllowVias() const { return m_doNotAllowVias; }
|
|
|
|
bool GetDoNotAllowTracks() const { return m_doNotAllowTracks; }
|
|
|
|
bool GetDoNotAllowPads() const { return m_doNotAllowPads; }
|
2020-05-07 00:30:46 +00:00
|
|
|
bool GetDoNotAllowFootprints() const { return m_doNotAllowFootprints; }
|
2012-07-13 18:55:29 +00:00
|
|
|
|
2021-10-26 16:19:30 +00:00
|
|
|
void SetIsRuleArea( bool aEnable ) { m_isRuleArea = aEnable; }
|
2012-07-14 16:27:25 +00:00
|
|
|
void SetDoNotAllowCopperPour( bool aEnable ) { m_doNotAllowCopperPour = aEnable; }
|
2021-10-26 16:19:30 +00:00
|
|
|
void SetDoNotAllowVias( bool aEnable ) { m_doNotAllowVias = aEnable; }
|
|
|
|
void SetDoNotAllowTracks( bool aEnable ) { m_doNotAllowTracks = aEnable; }
|
|
|
|
void SetDoNotAllowPads( bool aEnable ) { m_doNotAllowPads = aEnable; }
|
2020-05-07 00:30:46 +00:00
|
|
|
void SetDoNotAllowFootprints( bool aEnable ) { m_doNotAllowFootprints = aEnable; }
|
2012-07-13 18:55:29 +00:00
|
|
|
|
2021-10-26 16:19:30 +00:00
|
|
|
const ISLAND_REMOVAL_MODE GetIslandRemovalMode() const { return m_islandRemovalMode; }
|
|
|
|
void SetIslandRemovalMode( ISLAND_REMOVAL_MODE aRemove ) { m_islandRemovalMode = aRemove; }
|
2020-06-26 02:19:51 +00:00
|
|
|
|
2021-10-26 16:19:30 +00:00
|
|
|
long long int GetMinIslandArea() const { return m_minIslandArea; }
|
2020-06-26 02:19:51 +00:00
|
|
|
void SetMinIslandArea( long long int aArea ) { m_minIslandArea = aArea; }
|
2020-06-24 02:19:08 +00:00
|
|
|
|
2017-03-07 12:06:00 +00:00
|
|
|
/**
|
2020-08-07 14:04:34 +00:00
|
|
|
* HatchBorder related methods
|
2017-03-07 12:06:00 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2021-03-09 00:00:03 +00:00
|
|
|
* @return the zone hatch pitch in iu.
|
2017-03-07 12:06:00 +00:00
|
|
|
*/
|
2020-08-07 14:04:34 +00:00
|
|
|
int GetBorderHatchPitch() const;
|
2017-03-07 12:06:00 +00:00
|
|
|
|
|
|
|
/**
|
2021-03-09 00:00:03 +00:00
|
|
|
* @return 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
|
|
|
|
|
|
|
/**
|
2021-03-09 00:00:03 +00:00
|
|
|
* Set all hatch parameters for the zone.
|
|
|
|
*
|
2022-02-12 16:37:27 +00:00
|
|
|
* @param aBorderHatchStyle is the style of the hatch, specified as one of HATCH_STYLE
|
|
|
|
possible values.
|
|
|
|
* @param aBorderHatchPitch is the hatch pitch in iu.
|
|
|
|
* @param aRebuildBorderHatch is a flag to indicate whether to re-hatch after having set the
|
2017-03-07 12:06:00 +00:00
|
|
|
* previous parameters.
|
|
|
|
*/
|
2022-02-12 16:37:27 +00:00
|
|
|
void SetBorderDisplayStyle( ZONE_BORDER_DISPLAY_STYLE aBorderHatchStyle, int aBorderHatchPitch,
|
|
|
|
bool aRebuilBorderdHatch );
|
2017-03-07 12:06:00 +00:00
|
|
|
|
|
|
|
/**
|
2021-03-09 00:00:03 +00:00
|
|
|
* Set the hatch pitch parameter for the zone.
|
|
|
|
*
|
|
|
|
* @param aPitch is the hatch pitch in iu.
|
2017-03-07 12:06:00 +00:00
|
|
|
*/
|
2022-02-12 16:37:27 +00:00
|
|
|
void SetBorderHatchPitch( int aPitch );
|
2017-03-07 12:06:00 +00:00
|
|
|
|
|
|
|
/**
|
2021-03-09 00:00:03 +00:00
|
|
|
* Clear the zone's hatch.
|
2017-03-07 12:06:00 +00:00
|
|
|
*/
|
2021-03-09 00:00:03 +00:00
|
|
|
void UnHatchBorder();
|
2017-03-07 12:06:00 +00:00
|
|
|
|
|
|
|
/**
|
2021-03-09 00:00:03 +00:00
|
|
|
* Compute the hatch lines depending on the hatch parameters and stores it in the zone's
|
2020-08-07 14:04:34 +00:00
|
|
|
* attribute m_borderHatchLines.
|
2017-03-07 12:06:00 +00:00
|
|
|
*/
|
2020-08-07 14:04:34 +00:00
|
|
|
void HatchBorder();
|
2017-03-07 12:06:00 +00:00
|
|
|
|
2020-08-07 14:04:34 +00:00
|
|
|
const std::vector<SEG>& GetHatchLines() const { return m_borderHatchLines; }
|
2017-03-07 12:06:00 +00:00
|
|
|
|
2020-11-26 20:21:15 +00:00
|
|
|
/**
|
|
|
|
* Build the hash value of m_FilledPolysList, and store it internally in m_filledPolysHash.
|
|
|
|
* Used in zone filling calculations, to know if m_FilledPolysList is up to date.
|
2019-03-21 14:27:05 +00:00
|
|
|
*/
|
2020-11-26 20:21:15 +00:00
|
|
|
void BuildHashValue( PCB_LAYER_ID aLayer );
|
2019-03-21 14:27:05 +00:00
|
|
|
|
2020-11-26 20:21:15 +00:00
|
|
|
/**
|
|
|
|
* @return the hash value previously calculated by BuildHashValue().
|
2019-03-21 14:27:05 +00:00
|
|
|
*/
|
2020-11-26 20:21:15 +00:00
|
|
|
MD5_HASH GetHashValue( PCB_LAYER_ID aLayer );
|
2019-03-21 14:27:05 +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 ); }
|
2022-11-01 13:19:33 +00:00
|
|
|
|
|
|
|
void SetFillPoly( PCB_LAYER_ID aLayer, SHAPE_POLY_SET* aPoly )
|
|
|
|
{
|
|
|
|
m_FilledPolysList[ aLayer ] = std::make_shared<SHAPE_POLY_SET>( *aPoly );
|
|
|
|
SetFillFlag( aLayer, true );
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2019-10-26 15:49:29 +00:00
|
|
|
protected:
|
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;
|
|
|
|
|
2020-06-24 01:09:15 +00:00
|
|
|
/// An optional unique name for this zone, used for identifying it in DRC checking
|
|
|
|
wxString m_zoneName;
|
|
|
|
|
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
|
|
|
|
*/
|
2020-09-21 23:32:07 +00:00
|
|
|
bool m_isRuleArea;
|
2012-07-13 18:55:29 +00:00
|
|
|
|
2022-01-08 15:56:41 +00:00
|
|
|
/* A zone outline can be a teardrop zone with different rules for priority
|
Fix typos in pcbnew sub-directory
Found via `codespell -q 3 -S *.po,./thirdparty,./Documentation/changelogs -L aactual,acount,aline,alocation,alog,anormal,anumber,aother,apoints,aparent,aray,ba,busses,dout,einstance,leaded,modul,ontext,ot,overide,serie,te,,tesselate,tesselator,tht`
2022-06-29 20:21:10 +00:00
|
|
|
* (always bigger priority than copper zones) and never removed from a
|
2022-01-08 15:56:41 +00:00
|
|
|
* copper zone having the same netcode
|
|
|
|
*/
|
|
|
|
TEARDROP_TYPE m_teardropType;
|
|
|
|
|
2012-07-13 18:55:29 +00:00
|
|
|
/* 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;
|
2020-05-07 00:30:46 +00:00
|
|
|
bool m_doNotAllowPads;
|
|
|
|
bool m_doNotAllowFootprints;
|
2012-07-13 18:55:29 +00:00
|
|
|
|
2019-12-28 00:55:11 +00:00
|
|
|
ZONE_CONNECTION m_PadConnection;
|
2020-09-17 13:14:45 +00:00
|
|
|
int m_ZoneClearance; // Clearance value in internal units.
|
|
|
|
int m_ZoneMinThickness; // Minimum thickness value in filled areas.
|
|
|
|
int m_fillVersion; // See BOARD_DESIGN_SETTINGS for version
|
|
|
|
// differences.
|
2020-06-26 02:19:51 +00:00
|
|
|
ISLAND_REMOVAL_MODE m_islandRemovalMode;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* When island removal mode is set to AREA, islands below this area will be removed.
|
|
|
|
* If this value is negative, all islands will be removed.
|
|
|
|
*/
|
2020-09-17 13:14:45 +00:00
|
|
|
long long int m_minIslandArea;
|
2020-06-24 02:19:08 +00:00
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
/** True when a zone was filled, false after deleting the filled areas. */
|
2020-09-17 13:14:45 +00:00
|
|
|
bool m_isFilled;
|
2013-03-18 19:36:07 +00:00
|
|
|
|
2021-03-09 00:00:03 +00:00
|
|
|
/**
|
|
|
|
* False when a zone was refilled, true after changes in zone params.
|
2019-03-14 13:35:55 +00:00
|
|
|
* m_needRefill = false does not imply filled areas are up to date, just
|
|
|
|
* the zone was refilled after edition, and does not need refilling
|
|
|
|
*/
|
2020-09-17 13:14:45 +00:00
|
|
|
bool m_needRefill;
|
2013-03-18 19:36:07 +00:00
|
|
|
|
2020-09-17 13:14:45 +00:00
|
|
|
int m_thermalReliefGap; // Width of the gap in thermal reliefs.
|
|
|
|
int m_thermalReliefSpokeWidth; // Width of the copper bridge in thermal reliefs.
|
2013-03-18 19:36:07 +00:00
|
|
|
|
|
|
|
|
2021-03-09 00:00:03 +00:00
|
|
|
/**
|
|
|
|
* How to fill areas:
|
|
|
|
*
|
2019-12-20 14:11:39 +00:00
|
|
|
* ZONE_FILL_MODE::POLYGONS => use solid polygons
|
|
|
|
* ZONE_FILL_MODE::HATCH_PATTERN => use a grid pattern as shape
|
2018-02-18 09:09:13 +00:00
|
|
|
*/
|
2020-09-17 13:14:45 +00:00
|
|
|
ZONE_FILL_MODE m_fillMode;
|
2020-08-07 14:04:34 +00:00
|
|
|
int m_hatchThickness; // thickness of lines (if 0 -> solid shape)
|
|
|
|
int m_hatchGap; // gap between lines (0 -> solid shape
|
2022-01-19 00:22:40 +00:00
|
|
|
EDA_ANGLE m_hatchOrientation; // orientation of grid lines
|
2020-08-07 14:04:34 +00:00
|
|
|
int m_hatchSmoothingLevel; // 0 = no smoothing
|
|
|
|
// 1 = fillet
|
|
|
|
// 2 = arc low def
|
|
|
|
// 3 = arc high def
|
|
|
|
double m_hatchSmoothingValue; // hole chamfer/fillet size (ratio of hole size)
|
|
|
|
double m_hatchHoleMinArea; // min size before holes are dropped (ratio)
|
|
|
|
int m_hatchBorderAlgorithm; // 0 = use min zone thickness
|
|
|
|
// 1 = use hatch thickness
|
2018-02-18 09:09:13 +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
|
|
|
|
2020-09-17 13:14:45 +00:00
|
|
|
int m_localFlgs; // Variable used in polygon calculations.
|
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
|
|
|
|
*/
|
2022-02-15 17:34:38 +00:00
|
|
|
std::map<PCB_LAYER_ID, std::shared_ptr<SHAPE_POLY_SET>> m_FilledPolysList;
|
2020-06-24 02:19:08 +00:00
|
|
|
|
2020-09-21 19:20:20 +00:00
|
|
|
/// Temp variables used while filling
|
2022-09-19 17:09:09 +00:00
|
|
|
LSET m_fillFlags;
|
2020-09-17 13:14:45 +00:00
|
|
|
|
2020-06-24 02:19:08 +00:00
|
|
|
/// A hash value used in zone filling calculations to see if the filled areas are up to date
|
|
|
|
std::map<PCB_LAYER_ID, MD5_HASH> m_filledPolysHash;
|
2017-03-07 12:06:00 +00:00
|
|
|
|
2020-08-07 14:04:34 +00:00
|
|
|
ZONE_BORDER_DISPLAY_STYLE m_borderStyle; // border display style, see enum above
|
|
|
|
int m_borderHatchPitch; // for DIAGONAL_EDGE, distance between 2 lines
|
|
|
|
std::vector<SEG> m_borderHatchLines; // hatch lines
|
2020-06-26 02:19:51 +00:00
|
|
|
|
|
|
|
/// For each layer, a set of insulated islands that were not removed
|
|
|
|
std::map<PCB_LAYER_ID, std::set<int>> m_insulatedIslands;
|
2017-11-23 16:20:27 +00:00
|
|
|
|
2020-11-11 23:05:59 +00:00
|
|
|
double m_area; // The filled zone area
|
2022-01-08 15:56:41 +00:00
|
|
|
double m_outlinearea; // The outline zone area
|
2020-07-01 02:21:59 +00:00
|
|
|
|
|
|
|
/// Lock used for multi-threaded filling on multi-layer zones
|
|
|
|
std::mutex m_lock;
|
2007-12-09 12:59:06 +00:00
|
|
|
};
|
|
|
|
|
2008-01-23 22:39:09 +00:00
|
|
|
|
2019-10-26 15:49:29 +00:00
|
|
|
/**
|
2021-03-09 00:00:03 +00:00
|
|
|
* A specialization of ZONE for use in footprints.
|
2019-10-26 15:49:29 +00:00
|
|
|
*/
|
2020-11-11 23:05:59 +00:00
|
|
|
class FP_ZONE : public ZONE
|
2019-10-26 15:49:29 +00:00
|
|
|
{
|
|
|
|
public:
|
2020-11-11 23:05:59 +00:00
|
|
|
FP_ZONE( BOARD_ITEM_CONTAINER* aParent );
|
|
|
|
FP_ZONE( const FP_ZONE& aZone );
|
|
|
|
FP_ZONE& operator=( const FP_ZONE &aOther );
|
2019-10-26 15:49:29 +00:00
|
|
|
|
|
|
|
EDA_ITEM* Clone() const override;
|
2019-10-28 09:15:03 +00:00
|
|
|
|
2020-09-21 15:03:08 +00:00
|
|
|
double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
|
2019-10-26 15:49:29 +00:00
|
|
|
};
|
|
|
|
|
2020-11-11 23:05:59 +00:00
|
|
|
#endif // ZONE_H
|