2011-10-17 20:01:27 +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
|
2012-06-08 09:56:42 +00:00
|
|
|
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
2024-01-10 11:28:29 +00:00
|
|
|
* Copyright (C) 1992-2024 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-10-17 20:01:27 +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
|
|
|
|
*/
|
|
|
|
|
2019-05-14 12:39:34 +00:00
|
|
|
#include <bitmaps.h>
|
|
|
|
#include <geometry/geometry_utils.h>
|
2020-08-26 22:04:16 +00:00
|
|
|
#include <geometry/shape_null.h>
|
2020-10-15 00:46:32 +00:00
|
|
|
#include <pcb_edit_frame.h>
|
2019-05-14 12:39:34 +00:00
|
|
|
#include <pcb_screen.h>
|
2020-11-12 20:19:22 +00:00
|
|
|
#include <board.h>
|
2021-06-06 19:03:10 +00:00
|
|
|
#include <board_design_settings.h>
|
|
|
|
#include <pad.h>
|
2020-11-11 23:05:59 +00:00
|
|
|
#include <zone.h>
|
2023-03-30 11:49:23 +00:00
|
|
|
#include <footprint.h>
|
2021-07-29 09:56:22 +00:00
|
|
|
#include <string_utils.h>
|
2012-07-30 07:40:25 +00:00
|
|
|
#include <math_for_graphics.h>
|
2023-02-10 04:38:51 +00:00
|
|
|
#include <properties/property_validators.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <settings/color_settings.h>
|
|
|
|
#include <settings/settings_manager.h>
|
2020-10-14 03:37:48 +00:00
|
|
|
#include <trigo.h>
|
2020-10-16 15:51:24 +00:00
|
|
|
#include <i18n_utility.h>
|
2024-03-06 18:24:50 +00:00
|
|
|
#include <mutex>
|
2007-12-09 12:59:06 +00:00
|
|
|
|
2021-08-08 13:37:14 +00:00
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
ZONE::ZONE( BOARD_ITEM_CONTAINER* aParent ) :
|
|
|
|
BOARD_CONNECTED_ITEM( aParent, PCB_ZONE_T ),
|
|
|
|
m_Poly( nullptr ),
|
2024-02-03 20:14:57 +00:00
|
|
|
m_teardropType( TEARDROP_TYPE::TD_NONE ),
|
2023-03-30 11:49:23 +00:00
|
|
|
m_isFilled( false ),
|
|
|
|
m_CornerSelection( nullptr ),
|
2022-09-21 02:15:41 +00:00
|
|
|
m_area( 0.0 ),
|
|
|
|
m_outlinearea( 0.0 )
|
2007-12-09 12:59:06 +00:00
|
|
|
{
|
2024-02-03 20:14:57 +00:00
|
|
|
m_Poly = new SHAPE_POLY_SET(); // Outlines
|
2021-08-08 13:37:14 +00:00
|
|
|
SetLocalFlags( 0 ); // flags temporary used in zone calculations
|
|
|
|
m_fillVersion = 5; // set the "old" way to build filled polygon areas (< 6.0.x)
|
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
if( GetParentFootprint() )
|
|
|
|
SetIsRuleArea( true ); // Zones living in footprints have the rule area option
|
|
|
|
|
2024-02-03 19:56:31 +00:00
|
|
|
if( aParent->GetBoard() )
|
|
|
|
aParent->GetBoard()->GetDesignSettings().GetDefaultZoneSettings().ExportSetting( *this );
|
2024-02-03 20:14:57 +00:00
|
|
|
else
|
|
|
|
ZONE_SETTINGS().ExportSetting( *this );
|
2022-11-25 14:30:51 +00:00
|
|
|
|
2021-10-13 15:59:48 +00:00
|
|
|
m_needRefill = false; // True only after edits.
|
2007-12-09 12:59:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-07-21 23:14:56 +00:00
|
|
|
ZONE::ZONE( const ZONE& aZone ) :
|
|
|
|
BOARD_CONNECTED_ITEM( aZone ),
|
2020-07-20 10:26:48 +00:00
|
|
|
m_Poly( nullptr ),
|
|
|
|
m_CornerSelection( nullptr )
|
2012-01-14 19:50:32 +00:00
|
|
|
{
|
2020-07-27 17:56:15 +00:00
|
|
|
InitDataFromSrcInCopyCtor( aZone );
|
2012-01-14 19:50:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-11 23:05:59 +00:00
|
|
|
ZONE& ZONE::operator=( const ZONE& aOther )
|
2016-05-31 08:27:52 +00:00
|
|
|
{
|
|
|
|
BOARD_CONNECTED_ITEM::operator=( aOther );
|
|
|
|
|
2020-07-27 17:56:15 +00:00
|
|
|
InitDataFromSrcInCopyCtor( aOther );
|
2019-09-05 14:36:23 +00:00
|
|
|
|
2016-05-31 08:27:52 +00:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-11 23:05:59 +00:00
|
|
|
ZONE::~ZONE()
|
2007-12-09 12:59:06 +00:00
|
|
|
{
|
2008-01-31 20:53:44 +00:00
|
|
|
delete m_Poly;
|
2017-03-07 12:06:00 +00:00
|
|
|
delete m_CornerSelection;
|
2023-01-11 02:57:51 +00:00
|
|
|
|
|
|
|
if( BOARD* board = GetBoard() )
|
|
|
|
board->IncrementTimeStamp();
|
2007-12-09 12:59:06 +00:00
|
|
|
}
|
|
|
|
|
2011-10-17 20:01:27 +00:00
|
|
|
|
2020-11-11 23:05:59 +00:00
|
|
|
void ZONE::InitDataFromSrcInCopyCtor( const ZONE& aZone )
|
2019-10-26 15:49:29 +00:00
|
|
|
{
|
2019-10-29 10:09:54 +00:00
|
|
|
// members are expected non initialize in this.
|
2022-09-22 14:05:06 +00:00
|
|
|
// InitDataFromSrcInCopyCtor() is expected to be called only from a copy constructor.
|
2020-03-15 08:39:42 +00:00
|
|
|
|
|
|
|
// Copy only useful EDA_ITEM flags:
|
2020-11-14 18:11:28 +00:00
|
|
|
m_flags = aZone.m_flags;
|
2020-08-18 13:26:22 +00:00
|
|
|
m_forceVisible = aZone.m_forceVisible;
|
2020-03-15 08:39:42 +00:00
|
|
|
|
2020-07-18 22:55:06 +00:00
|
|
|
// Replace the outlines for aZone outlines.
|
|
|
|
delete m_Poly;
|
|
|
|
m_Poly = new SHAPE_POLY_SET( *aZone.m_Poly );
|
2019-10-29 10:09:54 +00:00
|
|
|
|
2020-08-18 13:26:22 +00:00
|
|
|
m_cornerSmoothingType = aZone.m_cornerSmoothingType;
|
|
|
|
m_cornerRadius = aZone.m_cornerRadius;
|
|
|
|
m_zoneName = aZone.m_zoneName;
|
|
|
|
m_priority = aZone.m_priority;
|
2020-09-21 23:32:07 +00:00
|
|
|
m_isRuleArea = aZone.m_isRuleArea;
|
2020-12-24 16:29:23 +00:00
|
|
|
SetLayerSet( aZone.GetLayerSet() );
|
2020-07-01 02:21:59 +00:00
|
|
|
|
2020-08-18 13:26:22 +00:00
|
|
|
m_doNotAllowCopperPour = aZone.m_doNotAllowCopperPour;
|
|
|
|
m_doNotAllowVias = aZone.m_doNotAllowVias;
|
|
|
|
m_doNotAllowTracks = aZone.m_doNotAllowTracks;
|
|
|
|
m_doNotAllowPads = aZone.m_doNotAllowPads;
|
|
|
|
m_doNotAllowFootprints = aZone.m_doNotAllowFootprints;
|
2019-10-26 15:49:29 +00:00
|
|
|
|
2020-07-18 22:55:06 +00:00
|
|
|
m_PadConnection = aZone.m_PadConnection;
|
|
|
|
m_ZoneClearance = aZone.m_ZoneClearance; // clearance value
|
|
|
|
m_ZoneMinThickness = aZone.m_ZoneMinThickness;
|
2020-09-17 13:14:45 +00:00
|
|
|
m_fillVersion = aZone.m_fillVersion;
|
2020-07-18 22:55:06 +00:00
|
|
|
m_islandRemovalMode = aZone.m_islandRemovalMode;
|
|
|
|
m_minIslandArea = aZone.m_minIslandArea;
|
|
|
|
|
2020-09-17 13:14:45 +00:00
|
|
|
m_isFilled = aZone.m_isFilled;
|
|
|
|
m_needRefill = aZone.m_needRefill;
|
2022-01-08 15:56:41 +00:00
|
|
|
m_teardropType = aZone.m_teardropType;
|
2020-07-18 22:55:06 +00:00
|
|
|
|
2020-09-17 13:14:45 +00:00
|
|
|
m_thermalReliefGap = aZone.m_thermalReliefGap;
|
|
|
|
m_thermalReliefSpokeWidth = aZone.m_thermalReliefSpokeWidth;
|
2020-07-01 02:21:59 +00:00
|
|
|
|
2020-09-17 13:14:45 +00:00
|
|
|
m_fillMode = aZone.m_fillMode; // solid vs. hatched
|
2020-08-18 13:26:22 +00:00
|
|
|
m_hatchThickness = aZone.m_hatchThickness;
|
|
|
|
m_hatchGap = aZone.m_hatchGap;
|
|
|
|
m_hatchOrientation = aZone.m_hatchOrientation;
|
|
|
|
m_hatchSmoothingLevel = aZone.m_hatchSmoothingLevel;
|
|
|
|
m_hatchSmoothingValue = aZone.m_hatchSmoothingValue;
|
|
|
|
m_hatchBorderAlgorithm = aZone.m_hatchBorderAlgorithm;
|
|
|
|
m_hatchHoleMinArea = aZone.m_hatchHoleMinArea;
|
2020-07-18 22:55:06 +00:00
|
|
|
|
|
|
|
// For corner moving, corner index to drag, or nullptr if no selection
|
2020-07-20 10:26:48 +00:00
|
|
|
delete m_CornerSelection;
|
2020-08-18 13:26:22 +00:00
|
|
|
m_CornerSelection = nullptr;
|
2020-07-18 22:55:06 +00:00
|
|
|
|
2024-06-12 10:05:56 +00:00
|
|
|
aZone.GetLayerSet().RunOnLayers(
|
|
|
|
[&]( PCB_LAYER_ID layer )
|
|
|
|
{
|
|
|
|
std::shared_ptr<SHAPE_POLY_SET> fill = aZone.m_FilledPolysList.at( layer );
|
2022-02-15 17:34:38 +00:00
|
|
|
|
2024-06-12 10:05:56 +00:00
|
|
|
if( fill )
|
|
|
|
m_FilledPolysList[layer] = std::make_shared<SHAPE_POLY_SET>( *fill );
|
|
|
|
else
|
|
|
|
m_FilledPolysList[layer] = std::make_shared<SHAPE_POLY_SET>();
|
2022-02-15 17:34:38 +00:00
|
|
|
|
2024-06-12 10:05:56 +00:00
|
|
|
m_filledPolysHash[layer] = aZone.m_filledPolysHash.at( layer );
|
|
|
|
m_insulatedIslands[layer] = aZone.m_insulatedIslands.at( layer );
|
|
|
|
} );
|
2019-10-26 15:49:29 +00:00
|
|
|
|
2020-08-18 13:26:22 +00:00
|
|
|
m_borderStyle = aZone.m_borderStyle;
|
|
|
|
m_borderHatchPitch = aZone.m_borderHatchPitch;
|
|
|
|
m_borderHatchLines = aZone.m_borderHatchLines;
|
2019-10-26 15:49:29 +00:00
|
|
|
|
|
|
|
SetLocalFlags( aZone.GetLocalFlags() );
|
|
|
|
|
2020-08-18 13:26:22 +00:00
|
|
|
m_netinfo = aZone.m_netinfo;
|
|
|
|
m_area = aZone.m_area;
|
2022-09-21 02:15:41 +00:00
|
|
|
m_outlinearea = aZone.m_outlinearea;
|
2019-10-26 15:49:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-11 23:05:59 +00:00
|
|
|
EDA_ITEM* ZONE::Clone() const
|
2012-01-14 19:50:32 +00:00
|
|
|
{
|
2020-11-11 23:05:59 +00:00
|
|
|
return new ZONE( *this );
|
2012-01-14 19:50:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-03-01 14:53:35 +00:00
|
|
|
bool ZONE::HigherPriority( const ZONE* aOther ) const
|
|
|
|
{
|
2022-08-25 15:54:34 +00:00
|
|
|
// Teardrops are always higher priority than regular zones, so if one zone is a teardrop
|
|
|
|
// and the other is not, then return higher priority as the teardrop
|
|
|
|
if( ( m_teardropType == TEARDROP_TYPE::TD_NONE )
|
|
|
|
^ ( aOther->m_teardropType == TEARDROP_TYPE::TD_NONE ) )
|
|
|
|
{
|
|
|
|
return static_cast<int>( m_teardropType ) > static_cast<int>( aOther->m_teardropType );
|
|
|
|
}
|
|
|
|
|
2022-03-01 14:53:35 +00:00
|
|
|
if( m_priority != aOther->m_priority )
|
|
|
|
return m_priority > aOther->m_priority;
|
|
|
|
|
|
|
|
return m_Uuid > aOther->m_Uuid;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool ZONE::SameNet( const ZONE* aOther ) const
|
|
|
|
{
|
|
|
|
return GetNetCode() == aOther->GetNetCode();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-11 23:05:59 +00:00
|
|
|
bool ZONE::UnFill()
|
2011-07-16 16:04:49 +00:00
|
|
|
{
|
2020-06-24 02:19:08 +00:00
|
|
|
bool change = false;
|
|
|
|
|
2022-02-15 17:34:38 +00:00
|
|
|
for( std::pair<const PCB_LAYER_ID, std::shared_ptr<SHAPE_POLY_SET>>& pair : m_FilledPolysList )
|
2020-06-24 02:19:08 +00:00
|
|
|
{
|
2022-02-15 17:34:38 +00:00
|
|
|
change |= !pair.second->IsEmpty();
|
2021-03-19 19:32:44 +00:00
|
|
|
m_insulatedIslands[pair.first].clear();
|
2022-02-15 17:34:38 +00:00
|
|
|
pair.second->RemoveAllContours();
|
2020-06-24 02:19:08 +00:00
|
|
|
}
|
|
|
|
|
2020-09-17 13:14:45 +00:00
|
|
|
m_isFilled = false;
|
2022-09-19 17:09:09 +00:00
|
|
|
m_fillFlags.reset();
|
2011-07-16 16:04:49 +00:00
|
|
|
|
|
|
|
return change;
|
|
|
|
}
|
2007-12-09 12:59:06 +00:00
|
|
|
|
2011-10-17 20:01:27 +00:00
|
|
|
|
2022-10-07 21:21:24 +00:00
|
|
|
bool ZONE::IsConflicting() const
|
|
|
|
{
|
|
|
|
return HasFlag( COURTYARD_CONFLICT );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I ZONE::GetPosition() const
|
2008-10-29 15:26:53 +00:00
|
|
|
{
|
2022-01-01 06:04:08 +00:00
|
|
|
return GetCornerPosition( 0 );
|
2011-11-29 17:25:30 +00:00
|
|
|
}
|
2011-01-20 18:40:33 +00:00
|
|
|
|
2011-11-24 17:32:51 +00:00
|
|
|
|
2020-11-11 23:05:59 +00:00
|
|
|
PCB_LAYER_ID ZONE::GetLayer() const
|
2017-10-30 17:21:07 +00:00
|
|
|
{
|
2023-08-08 11:34:57 +00:00
|
|
|
if( m_layerSet.count() == 1 )
|
|
|
|
return m_layerSet.UIOrder()[0];
|
|
|
|
else
|
|
|
|
return UNDEFINED_LAYER;
|
2017-10-30 17:21:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-02-18 10:12:11 +00:00
|
|
|
PCB_LAYER_ID ZONE::GetFirstLayer() const
|
|
|
|
{
|
2023-08-08 11:34:57 +00:00
|
|
|
if( m_layerSet.count() )
|
2022-02-18 10:12:11 +00:00
|
|
|
return m_layerSet.UIOrder()[0];
|
|
|
|
else
|
|
|
|
return UNDEFINED_LAYER;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-11 23:05:59 +00:00
|
|
|
bool ZONE::IsOnCopperLayer() const
|
2017-10-30 17:21:07 +00:00
|
|
|
{
|
2020-06-24 02:19:08 +00:00
|
|
|
return ( m_layerSet & LSET::AllCuMask() ).count() > 0;
|
2017-10-30 17:21:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-11 23:05:59 +00:00
|
|
|
void ZONE::SetLayer( PCB_LAYER_ID aLayer )
|
2017-10-30 17:21:07 +00:00
|
|
|
{
|
|
|
|
SetLayerSet( LSET( aLayer ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-11 23:05:59 +00:00
|
|
|
void ZONE::SetLayerSet( LSET aLayerSet )
|
2017-10-30 17:21:07 +00:00
|
|
|
{
|
2017-09-29 16:49:09 +00:00
|
|
|
if( aLayerSet.count() == 0 )
|
|
|
|
return;
|
|
|
|
|
2019-03-14 13:35:55 +00:00
|
|
|
if( m_layerSet != aLayerSet )
|
2020-06-24 02:19:08 +00:00
|
|
|
{
|
2019-03-14 13:35:55 +00:00
|
|
|
SetNeedRefill( true );
|
|
|
|
|
2020-06-24 02:19:08 +00:00
|
|
|
UnFill();
|
|
|
|
|
2020-07-01 02:21:59 +00:00
|
|
|
m_FilledPolysList.clear();
|
|
|
|
m_filledPolysHash.clear();
|
|
|
|
m_insulatedIslands.clear();
|
|
|
|
|
2024-06-12 10:05:56 +00:00
|
|
|
aLayerSet.RunOnLayers(
|
|
|
|
[&]( PCB_LAYER_ID layer )
|
|
|
|
{
|
|
|
|
m_FilledPolysList[layer] = std::make_shared<SHAPE_POLY_SET>();
|
|
|
|
m_filledPolysHash[layer] = {};
|
|
|
|
m_insulatedIslands[layer] = {};
|
|
|
|
} );
|
2020-06-24 02:19:08 +00:00
|
|
|
}
|
|
|
|
|
2017-10-30 17:21:07 +00:00
|
|
|
m_layerSet = aLayerSet;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-11 23:05:59 +00:00
|
|
|
void ZONE::ViewGetLayers( int aLayers[], int& aCount ) const
|
2017-10-30 17:21:07 +00:00
|
|
|
{
|
2022-11-05 12:00:56 +00:00
|
|
|
aCount = 0;
|
2017-10-30 17:21:07 +00:00
|
|
|
|
2024-06-12 10:05:56 +00:00
|
|
|
m_layerSet.RunOnLayers(
|
|
|
|
[&]( PCB_LAYER_ID layer )
|
|
|
|
{
|
|
|
|
aLayers[ aCount++ ] = layer;
|
|
|
|
aLayers[ aCount++ ] = layer + static_cast<int>( LAYER_ZONE_START );
|
|
|
|
} );
|
2022-10-07 21:21:24 +00:00
|
|
|
|
|
|
|
if( IsConflicting() )
|
|
|
|
aLayers[ aCount++ ] = LAYER_CONFLICTS_SHADOW;
|
2017-10-30 17:21:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-11 23:05:59 +00:00
|
|
|
double ZONE::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
|
2020-07-11 17:42:00 +00:00
|
|
|
{
|
2020-09-21 15:03:08 +00:00
|
|
|
constexpr double HIDE = std::numeric_limits<double>::max();
|
2020-07-11 17:42:00 +00:00
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
if( !aView )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if( !aView->IsLayerVisible( LAYER_ZONES ) )
|
|
|
|
return HIDE;
|
|
|
|
|
|
|
|
if( FOOTPRINT* parentFP = GetParentFootprint() )
|
|
|
|
{
|
|
|
|
bool flipped = parentFP->GetLayer() == B_Cu;
|
|
|
|
|
|
|
|
// Handle Render tab switches
|
2023-08-04 10:13:20 +00:00
|
|
|
if( !flipped && !aView->IsLayerVisible( LAYER_FOOTPRINTS_FR ) )
|
2023-03-30 11:49:23 +00:00
|
|
|
return HIDE;
|
|
|
|
|
2023-08-04 10:13:20 +00:00
|
|
|
if( flipped && !aView->IsLayerVisible( LAYER_FOOTPRINTS_BK ) )
|
2023-03-30 11:49:23 +00:00
|
|
|
return HIDE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Other layers are shown without any conditions
|
|
|
|
return 0.0;
|
2020-07-11 17:42:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-08-01 17:37:19 +00:00
|
|
|
bool ZONE::IsOnLayer( PCB_LAYER_ID aLayer ) const
|
2017-10-30 17:21:07 +00:00
|
|
|
{
|
2020-06-24 02:19:08 +00:00
|
|
|
return m_layerSet.test( aLayer );
|
2017-10-30 17:21:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-08-31 09:15:42 +00:00
|
|
|
const BOX2I ZONE::GetBoundingBox() const
|
2008-05-02 05:16:35 +00:00
|
|
|
{
|
2022-10-02 18:30:43 +00:00
|
|
|
if( const BOARD* board = GetBoard() )
|
2022-10-01 21:09:38 +00:00
|
|
|
{
|
2022-10-02 18:30:43 +00:00
|
|
|
std::unordered_map<const ZONE*, BOX2I>& cache = board->m_ZoneBBoxCache;
|
2022-10-01 21:09:38 +00:00
|
|
|
|
2024-03-07 13:02:16 +00:00
|
|
|
{
|
|
|
|
std::shared_lock<std::shared_mutex> readLock( board->m_CachesMutex );
|
2024-03-06 14:26:30 +00:00
|
|
|
|
2024-03-07 13:02:16 +00:00
|
|
|
auto cacheIter = cache.find( this );
|
2024-03-06 14:26:30 +00:00
|
|
|
|
2024-03-07 13:02:16 +00:00
|
|
|
if( cacheIter != cache.end() )
|
|
|
|
return cacheIter->second;
|
|
|
|
}
|
2022-10-01 21:09:38 +00:00
|
|
|
|
|
|
|
BOX2I bbox = m_Poly->BBox();
|
2024-03-06 14:26:30 +00:00
|
|
|
|
2024-03-07 13:02:16 +00:00
|
|
|
{
|
|
|
|
std::unique_lock<std::shared_mutex> writeLock( board->m_CachesMutex );
|
|
|
|
cache[ this ] = bbox;
|
|
|
|
}
|
2022-10-02 18:30:43 +00:00
|
|
|
|
2022-10-01 21:09:38 +00:00
|
|
|
return bbox;
|
|
|
|
}
|
|
|
|
|
2022-08-31 09:15:42 +00:00
|
|
|
return m_Poly->BBox();
|
2008-05-02 05:16:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-10-01 21:09:38 +00:00
|
|
|
void ZONE::CacheBoundingBox()
|
|
|
|
{
|
2024-03-07 13:02:16 +00:00
|
|
|
// GetBoundingBox() will cache it for us, and there's no sense duplicating the somewhat tricky
|
|
|
|
// locking code.
|
|
|
|
GetBoundingBox();
|
2022-10-01 21:09:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-12 22:30:02 +00:00
|
|
|
int ZONE::GetThermalReliefGap( PAD* aPad, wxString* aSource ) const
|
2012-03-08 20:44:03 +00:00
|
|
|
{
|
2021-08-08 13:37:14 +00:00
|
|
|
if( aPad->GetLocalThermalGapOverride() == 0 )
|
2020-09-10 18:35:11 +00:00
|
|
|
{
|
|
|
|
if( aSource )
|
|
|
|
*aSource = _( "zone" );
|
|
|
|
|
2020-09-17 13:14:45 +00:00
|
|
|
return m_thermalReliefGap;
|
2020-09-10 18:35:11 +00:00
|
|
|
}
|
|
|
|
|
2021-08-08 13:37:14 +00:00
|
|
|
return aPad->GetLocalThermalGapOverride( aSource );
|
2020-09-10 18:35:11 +00:00
|
|
|
|
2012-03-08 20:44:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-11 23:05:59 +00:00
|
|
|
void ZONE::SetCornerRadius( unsigned int aRadius )
|
2015-05-15 12:49:11 +00:00
|
|
|
{
|
2019-03-14 13:35:55 +00:00
|
|
|
if( m_cornerRadius != aRadius )
|
|
|
|
SetNeedRefill( true );
|
|
|
|
|
2015-05-15 12:49:11 +00:00
|
|
|
m_cornerRadius = aRadius;
|
2017-11-02 20:41:29 +00:00
|
|
|
}
|
2015-05-15 12:49:11 +00:00
|
|
|
|
|
|
|
|
2020-11-26 20:21:15 +00:00
|
|
|
static SHAPE_POLY_SET g_nullPoly;
|
|
|
|
|
|
|
|
|
2024-06-24 21:19:43 +00:00
|
|
|
HASH_128 ZONE::GetHashValue( PCB_LAYER_ID aLayer )
|
2020-11-26 20:21:15 +00:00
|
|
|
{
|
|
|
|
if( !m_filledPolysHash.count( aLayer ) )
|
|
|
|
return g_nullPoly.GetHash();
|
|
|
|
else
|
|
|
|
return m_filledPolysHash.at( aLayer );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ZONE::BuildHashValue( PCB_LAYER_ID aLayer )
|
|
|
|
{
|
|
|
|
if( !m_FilledPolysList.count( aLayer ) )
|
|
|
|
m_filledPolysHash[aLayer] = g_nullPoly.GetHash();
|
|
|
|
else
|
2022-02-15 17:34:38 +00:00
|
|
|
m_filledPolysHash[aLayer] = m_FilledPolysList.at( aLayer )->GetHash();
|
2020-11-26 20:21:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
bool ZONE::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
|
2007-12-29 19:15:58 +00:00
|
|
|
{
|
2021-07-01 13:28:01 +00:00
|
|
|
// When looking for an "exact" hit aAccuracy will be 0 which works poorly for very thin
|
|
|
|
// lines. Give it a floor.
|
2022-09-16 11:33:56 +00:00
|
|
|
int accuracy = std::max( aAccuracy, pcbIUScale.mmToIU( 0.1 ) );
|
2018-11-17 00:34:12 +00:00
|
|
|
|
|
|
|
return HitTestForCorner( aPosition, accuracy * 2 ) || HitTestForEdge( aPosition, accuracy );
|
2007-12-29 19:15:58 +00:00
|
|
|
}
|
|
|
|
|
2017-03-07 12:06:00 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
bool ZONE::HitTestForCorner( const VECTOR2I& refPos, int aAccuracy,
|
2022-07-16 17:41:59 +00:00
|
|
|
SHAPE_POLY_SET::VERTEX_INDEX* aCornerHit ) const
|
2007-12-29 19:15:58 +00:00
|
|
|
{
|
2018-11-17 00:34:12 +00:00
|
|
|
return m_Poly->CollideVertex( VECTOR2I( refPos ), aCornerHit, aAccuracy );
|
2007-12-29 19:15:58 +00:00
|
|
|
}
|
|
|
|
|
2008-01-31 20:53:44 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
bool ZONE::HitTestForEdge( const VECTOR2I& refPos, int aAccuracy,
|
2022-07-16 17:41:59 +00:00
|
|
|
SHAPE_POLY_SET::VERTEX_INDEX* aCornerHit ) const
|
2007-12-29 19:15:58 +00:00
|
|
|
{
|
2018-11-17 00:34:12 +00:00
|
|
|
return m_Poly->CollideEdge( VECTOR2I( refPos ), aCornerHit, aAccuracy );
|
2017-03-07 12:06:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-08-31 09:33:46 +00:00
|
|
|
bool ZONE::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
|
2008-01-06 12:43:57 +00:00
|
|
|
{
|
2017-05-01 12:10:24 +00:00
|
|
|
// Calculate bounding box for zone
|
2022-08-31 09:33:46 +00:00
|
|
|
BOX2I bbox = GetBoundingBox();
|
2014-11-08 12:25:29 +00:00
|
|
|
bbox.Normalize();
|
2013-09-21 18:09:41 +00:00
|
|
|
|
2022-08-31 09:33:46 +00:00
|
|
|
BOX2I arect = aRect;
|
2017-05-01 12:10:24 +00:00
|
|
|
arect.Normalize();
|
|
|
|
arect.Inflate( aAccuracy );
|
|
|
|
|
2013-09-21 18:09:41 +00:00
|
|
|
if( aContained )
|
2017-05-01 12:10:24 +00:00
|
|
|
{
|
|
|
|
return arect.Contains( bbox );
|
|
|
|
}
|
2020-08-18 13:26:22 +00:00
|
|
|
else
|
2013-09-21 18:09:41 +00:00
|
|
|
{
|
2019-07-12 21:02:10 +00:00
|
|
|
// Fast test: if aBox is outside the polygon bounding box, rectangles cannot intersect
|
2017-05-01 12:10:24 +00:00
|
|
|
if( !arect.Intersects( bbox ) )
|
2013-09-21 18:09:41 +00:00
|
|
|
return false;
|
|
|
|
|
2017-03-07 12:06:00 +00:00
|
|
|
int count = m_Poly->TotalVertices();
|
2019-07-12 21:02:10 +00:00
|
|
|
|
|
|
|
for( int ii = 0; ii < count; ii++ )
|
2013-09-21 18:09:41 +00:00
|
|
|
{
|
2022-08-31 09:33:46 +00:00
|
|
|
VECTOR2I vertex = m_Poly->CVertex( ii );
|
|
|
|
VECTOR2I vertexNext = m_Poly->CVertex( ( ii + 1 ) % count );
|
2017-05-01 12:10:24 +00:00
|
|
|
|
|
|
|
// Test if the point is within the rect
|
2022-01-11 00:49:49 +00:00
|
|
|
if( arect.Contains( vertex ) )
|
2013-09-21 18:09:41 +00:00
|
|
|
return true;
|
2017-05-01 12:10:24 +00:00
|
|
|
|
|
|
|
// Test if this edge intersects the rect
|
2022-01-11 00:49:49 +00:00
|
|
|
if( arect.Intersects( vertex, vertexNext ) )
|
2017-05-01 12:10:24 +00:00
|
|
|
return true;
|
2013-09-21 18:09:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2008-01-06 12:43:57 +00:00
|
|
|
}
|
2007-12-29 19:15:58 +00:00
|
|
|
|
2011-01-20 18:40:33 +00:00
|
|
|
|
2024-01-10 11:28:29 +00:00
|
|
|
std::optional<int> ZONE::GetLocalClearance() const
|
2011-08-09 03:41:20 +00:00
|
|
|
{
|
2024-01-10 11:28:29 +00:00
|
|
|
return m_isRuleArea ? 0 : m_ZoneClearance;
|
2011-08-09 03:41:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
bool ZONE::HitTestFilledArea( PCB_LAYER_ID aLayer, const VECTOR2I& aRefPos, int aAccuracy ) const
|
2008-11-27 10:12:46 +00:00
|
|
|
{
|
2020-09-21 23:32:07 +00:00
|
|
|
// Rule areas have no filled area, but it's generally nice to treat their interior as if it were
|
|
|
|
// filled so that people don't have to select them by their outline (which is min-width)
|
|
|
|
if( GetIsRuleArea() )
|
2022-02-15 17:34:38 +00:00
|
|
|
return m_Poly->Contains( aRefPos, -1, aAccuracy );
|
2020-06-30 00:37:57 +00:00
|
|
|
|
2020-06-24 02:19:08 +00:00
|
|
|
if( !m_FilledPolysList.count( aLayer ) )
|
|
|
|
return false;
|
|
|
|
|
2022-02-15 17:34:38 +00:00
|
|
|
return m_FilledPolysList.at( aLayer )->Contains( aRefPos, -1, aAccuracy );
|
2008-11-27 10:12:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-11 23:05:59 +00:00
|
|
|
bool ZONE::HitTestCutout( const VECTOR2I& aRefPos, int* aOutlineIdx, int* aHoleIdx ) const
|
2020-04-14 16:57:18 +00:00
|
|
|
{
|
|
|
|
// Iterate over each outline polygon in the zone and then iterate over
|
|
|
|
// each hole it has to see if the point is in it.
|
|
|
|
for( int i = 0; i < m_Poly->OutlineCount(); i++ )
|
|
|
|
{
|
|
|
|
for( int j = 0; j < m_Poly->HoleCount( i ); j++ )
|
|
|
|
{
|
|
|
|
if( m_Poly->Hole( i, j ).PointInside( aRefPos ) )
|
|
|
|
{
|
|
|
|
if( aOutlineIdx )
|
|
|
|
*aOutlineIdx = i;
|
|
|
|
|
|
|
|
if( aHoleIdx )
|
|
|
|
*aHoleIdx = j;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-11 23:05:59 +00:00
|
|
|
void ZONE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
|
2007-12-29 19:15:58 +00:00
|
|
|
{
|
2022-11-25 16:49:21 +00:00
|
|
|
wxString msg = GetFriendlyName();
|
2007-12-29 19:15:58 +00:00
|
|
|
|
2020-08-18 13:26:22 +00:00
|
|
|
// Display Cutout instead of Outline for holes inside a zone (i.e. when num contour !=0).
|
2017-03-07 12:06:00 +00:00
|
|
|
// Check whether the selected corner is in a hole; i.e., in any contour but the first one.
|
|
|
|
if( m_CornerSelection != nullptr && m_CornerSelection->m_contour > 0 )
|
2020-05-21 17:42:42 +00:00
|
|
|
msg << wxT( " " ) << _( "Cutout" );
|
2008-01-05 13:37:51 +00:00
|
|
|
|
2020-11-30 14:35:48 +00:00
|
|
|
aList.emplace_back( _( "Type" ), msg );
|
2007-12-29 19:15:58 +00:00
|
|
|
|
2020-09-21 23:32:07 +00:00
|
|
|
if( GetIsRuleArea() )
|
2012-11-23 09:10:37 +00:00
|
|
|
{
|
|
|
|
msg.Empty();
|
2013-01-12 17:32:24 +00:00
|
|
|
|
2012-11-23 09:10:37 +00:00
|
|
|
if( GetDoNotAllowVias() )
|
2020-05-07 00:30:46 +00:00
|
|
|
AccumulateDescription( msg, _( "No vias" ) );
|
2013-01-12 17:32:24 +00:00
|
|
|
|
2012-11-23 09:10:37 +00:00
|
|
|
if( GetDoNotAllowTracks() )
|
2020-05-10 14:55:15 +00:00
|
|
|
AccumulateDescription( msg, _( "No tracks" ) );
|
2020-05-07 00:30:46 +00:00
|
|
|
|
|
|
|
if( GetDoNotAllowPads() )
|
2020-05-10 14:55:15 +00:00
|
|
|
AccumulateDescription( msg, _( "No pads" ) );
|
2013-01-12 17:32:24 +00:00
|
|
|
|
2012-11-23 09:10:37 +00:00
|
|
|
if( GetDoNotAllowCopperPour() )
|
2020-05-10 14:55:15 +00:00
|
|
|
AccumulateDescription( msg, _( "No copper zones" ) );
|
2020-05-07 00:30:46 +00:00
|
|
|
|
|
|
|
if( GetDoNotAllowFootprints() )
|
2020-05-10 14:55:15 +00:00
|
|
|
AccumulateDescription( msg, _( "No footprints" ) );
|
2012-11-23 09:10:37 +00:00
|
|
|
|
2020-09-21 23:32:07 +00:00
|
|
|
if( !msg.IsEmpty() )
|
2022-07-22 22:05:25 +00:00
|
|
|
aList.emplace_back( _( "Restrictions" ), msg );
|
2012-11-23 09:10:37 +00:00
|
|
|
}
|
|
|
|
else if( IsOnCopperLayer() )
|
2008-01-31 20:53:44 +00:00
|
|
|
{
|
2021-10-31 16:32:24 +00:00
|
|
|
if( aFrame->GetName() == PCB_EDIT_FRAME_NAME )
|
|
|
|
{
|
|
|
|
aList.emplace_back( _( "Net" ), UnescapeString( GetNetname() ) );
|
2020-05-21 17:42:42 +00:00
|
|
|
|
2022-08-14 11:03:18 +00:00
|
|
|
aList.emplace_back( _( "Resolved Netclass" ),
|
|
|
|
UnescapeString( GetEffectiveNetClass()->GetName() ) );
|
2021-10-31 16:32:24 +00:00
|
|
|
}
|
2012-01-29 19:29:19 +00:00
|
|
|
|
|
|
|
// Display priority level
|
2022-03-01 14:53:35 +00:00
|
|
|
aList.emplace_back( _( "Priority" ),
|
|
|
|
wxString::Format( wxT( "%d" ), GetAssignedPriority() ) );
|
2008-09-26 19:51:36 +00:00
|
|
|
}
|
2007-12-29 19:15:58 +00:00
|
|
|
|
2021-10-31 16:32:24 +00:00
|
|
|
if( aFrame->GetName() == PCB_EDIT_FRAME_NAME )
|
|
|
|
{
|
|
|
|
if( IsLocked() )
|
|
|
|
aList.emplace_back( _( "Status" ), _( "Locked" ) );
|
|
|
|
}
|
2021-04-21 14:40:16 +00:00
|
|
|
|
2023-08-03 14:03:04 +00:00
|
|
|
LSEQ layers = m_layerSet.Seq();
|
2020-06-24 02:19:08 +00:00
|
|
|
wxString layerDesc;
|
|
|
|
|
2023-08-03 14:03:04 +00:00
|
|
|
if( layers.size() == 1 )
|
2020-06-24 02:19:08 +00:00
|
|
|
{
|
2023-08-03 14:03:04 +00:00
|
|
|
layerDesc.Printf( _( "%s" ), GetBoard()->GetLayerName( layers[0] ) );
|
|
|
|
}
|
|
|
|
else if (layers.size() == 2 )
|
|
|
|
{
|
|
|
|
layerDesc.Printf( _( "%s and %s" ),
|
|
|
|
GetBoard()->GetLayerName( layers[0] ),
|
|
|
|
GetBoard()->GetLayerName( layers[1] ) );
|
|
|
|
}
|
|
|
|
else if (layers.size() == 3 )
|
|
|
|
{
|
|
|
|
layerDesc.Printf( _( "%s, %s and %s" ),
|
|
|
|
GetBoard()->GetLayerName( layers[0] ),
|
|
|
|
GetBoard()->GetLayerName( layers[1] ),
|
|
|
|
GetBoard()->GetLayerName( layers[2] ) );
|
|
|
|
}
|
|
|
|
else if( layers.size() > 3 )
|
|
|
|
{
|
2023-08-10 15:15:37 +00:00
|
|
|
layerDesc.Printf( _( "%s, %s and %d more" ),
|
2023-08-03 14:03:04 +00:00
|
|
|
GetBoard()->GetLayerName( layers[0] ),
|
|
|
|
GetBoard()->GetLayerName( layers[1] ),
|
2023-08-10 15:15:37 +00:00
|
|
|
static_cast<int>( layers.size() - 2 ) );
|
2020-06-24 02:19:08 +00:00
|
|
|
}
|
|
|
|
|
2020-11-30 14:35:48 +00:00
|
|
|
aList.emplace_back( _( "Layer" ), layerDesc );
|
2007-12-29 19:15:58 +00:00
|
|
|
|
2020-06-24 01:09:15 +00:00
|
|
|
if( !m_zoneName.empty() )
|
2020-11-30 14:35:48 +00:00
|
|
|
aList.emplace_back( _( "Name" ), m_zoneName );
|
2020-06-24 01:09:15 +00:00
|
|
|
|
2020-09-17 13:14:45 +00:00
|
|
|
switch( m_fillMode )
|
2018-02-18 09:09:13 +00:00
|
|
|
{
|
2020-05-21 17:42:42 +00:00
|
|
|
case ZONE_FILL_MODE::POLYGONS: msg = _( "Solid" ); break;
|
|
|
|
case ZONE_FILL_MODE::HATCH_PATTERN: msg = _( "Hatched" ); break;
|
|
|
|
default: msg = _( "Unknown" ); break;
|
2018-02-18 09:09:13 +00:00
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2020-11-30 14:35:48 +00:00
|
|
|
aList.emplace_back( _( "Fill Mode" ), msg );
|
2008-10-07 09:32:56 +00:00
|
|
|
|
2022-09-19 09:25:20 +00:00
|
|
|
aList.emplace_back( _( "Filled Area" ),
|
|
|
|
aFrame->MessageTextFromValue( m_area, true, EDA_DATA_TYPE::AREA ) );
|
2020-02-05 09:43:52 +00:00
|
|
|
|
2020-05-21 17:42:42 +00:00
|
|
|
wxString source;
|
2022-02-18 10:12:11 +00:00
|
|
|
int clearance = GetOwnClearance( UNDEFINED_LAYER, &source );
|
2008-10-08 12:36:27 +00:00
|
|
|
|
2021-10-31 16:32:24 +00:00
|
|
|
if( !source.IsEmpty() )
|
|
|
|
{
|
|
|
|
aList.emplace_back( wxString::Format( _( "Min Clearance: %s" ),
|
2022-09-19 09:25:20 +00:00
|
|
|
aFrame->MessageTextFromValue( clearance ) ),
|
2021-10-31 16:32:24 +00:00
|
|
|
wxString::Format( _( "(from %s)" ),
|
|
|
|
source ) );
|
|
|
|
}
|
2020-06-10 18:46:38 +00:00
|
|
|
|
2022-03-04 09:42:32 +00:00
|
|
|
if( !m_FilledPolysList.empty() )
|
|
|
|
{
|
2023-08-03 14:03:04 +00:00
|
|
|
int count = 0;
|
2022-03-04 09:42:32 +00:00
|
|
|
|
2022-07-22 22:05:25 +00:00
|
|
|
for( std::pair<const PCB_LAYER_ID, std::shared_ptr<SHAPE_POLY_SET>>& ii: m_FilledPolysList )
|
|
|
|
count += ii.second->TotalVertices();
|
2022-03-04 09:42:32 +00:00
|
|
|
|
2022-07-22 22:05:25 +00:00
|
|
|
aList.emplace_back( _( "Corner Count" ), wxString::Format( wxT( "%d" ), count ) );
|
2022-03-04 09:42:32 +00:00
|
|
|
}
|
2007-12-29 19:15:58 +00:00
|
|
|
}
|
2008-01-06 12:43:57 +00:00
|
|
|
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
void ZONE::Move( const VECTOR2I& offset )
|
2008-01-06 12:43:57 +00:00
|
|
|
{
|
2008-12-03 10:32:53 +00:00
|
|
|
/* move outlines */
|
2019-07-12 21:02:10 +00:00
|
|
|
m_Poly->Move( offset );
|
2008-01-31 20:53:44 +00:00
|
|
|
|
2020-08-07 14:04:34 +00:00
|
|
|
HatchBorder();
|
2008-12-03 10:32:53 +00:00
|
|
|
|
2022-11-20 23:57:18 +00:00
|
|
|
/* move fills */
|
2022-02-15 17:34:38 +00:00
|
|
|
for( std::pair<const PCB_LAYER_ID, std::shared_ptr<SHAPE_POLY_SET>>& pair : m_FilledPolysList )
|
|
|
|
pair.second->Move( offset );
|
2022-11-20 23:57:18 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* move boundingbox cache
|
|
|
|
*
|
|
|
|
* While the cache will get nuked at the conclusion of the operation, we use it for some
|
|
|
|
* things (such as drawing the parent group) during the move.
|
|
|
|
*/
|
|
|
|
if( GetBoard() )
|
|
|
|
{
|
|
|
|
auto it = GetBoard()->m_ZoneBBoxCache.find( this );
|
2023-01-11 02:57:51 +00:00
|
|
|
|
2022-11-20 23:57:18 +00:00
|
|
|
if( it != GetBoard()->m_ZoneBBoxCache.end() )
|
|
|
|
it->second.Move( offset );
|
|
|
|
}
|
2008-01-06 12:43:57 +00:00
|
|
|
}
|
|
|
|
|
2008-09-26 19:51:36 +00:00
|
|
|
|
2022-11-25 16:49:21 +00:00
|
|
|
wxString ZONE::GetFriendlyName() const
|
|
|
|
{
|
|
|
|
if( GetIsRuleArea() )
|
|
|
|
return _( "Rule Area" );
|
|
|
|
else if( IsTeardropArea() )
|
|
|
|
return _( "Teardrop Area" );
|
|
|
|
else if( IsOnCopperLayer() )
|
|
|
|
return _( "Copper Zone" );
|
|
|
|
else
|
|
|
|
return _( "Non-copper Zone" );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
void ZONE::MoveEdge( const VECTOR2I& offset, int aEdge )
|
2008-02-01 21:30:45 +00:00
|
|
|
{
|
2017-04-16 16:32:47 +00:00
|
|
|
int next_corner;
|
2008-02-01 21:30:45 +00:00
|
|
|
|
2017-04-16 16:32:47 +00:00
|
|
|
if( m_Poly->GetNeighbourIndexes( aEdge, nullptr, &next_corner ) )
|
|
|
|
{
|
2019-03-23 18:26:44 +00:00
|
|
|
m_Poly->SetVertex( aEdge, m_Poly->CVertex( aEdge ) + VECTOR2I( offset ) );
|
|
|
|
m_Poly->SetVertex( next_corner, m_Poly->CVertex( next_corner ) + VECTOR2I( offset ) );
|
2020-08-07 14:04:34 +00:00
|
|
|
HatchBorder();
|
2019-03-14 13:35:55 +00:00
|
|
|
|
|
|
|
SetNeedRefill( true );
|
2017-04-16 16:32:47 +00:00
|
|
|
}
|
2008-02-01 21:30:45 +00:00
|
|
|
}
|
|
|
|
|
2008-01-31 20:53:44 +00:00
|
|
|
|
2022-01-13 19:32:00 +00:00
|
|
|
void ZONE::Rotate( const VECTOR2I& aCentre, const EDA_ANGLE& aAngle )
|
2008-01-06 12:43:57 +00:00
|
|
|
{
|
2023-03-17 11:07:37 +00:00
|
|
|
m_Poly->Rotate( aAngle, aCentre );
|
2020-08-07 14:04:34 +00:00
|
|
|
HatchBorder();
|
2009-08-01 19:58:01 +00:00
|
|
|
|
|
|
|
/* rotate filled areas: */
|
2022-02-15 17:34:38 +00:00
|
|
|
for( std::pair<const PCB_LAYER_ID, std::shared_ptr<SHAPE_POLY_SET>>& pair : m_FilledPolysList )
|
|
|
|
pair.second->Rotate( aAngle, aCentre );
|
2008-01-06 12:43:57 +00:00
|
|
|
}
|
|
|
|
|
2011-01-20 18:40:33 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
void ZONE::Flip( const VECTOR2I& aCentre, bool aFlipLeftRight )
|
2009-08-01 19:26:05 +00:00
|
|
|
{
|
2019-07-12 21:02:10 +00:00
|
|
|
Mirror( aCentre, aFlipLeftRight );
|
2017-10-30 17:21:07 +00:00
|
|
|
|
2023-10-11 23:21:47 +00:00
|
|
|
std::map<PCB_LAYER_ID, SHAPE_POLY_SET> fillsCopy;
|
|
|
|
|
|
|
|
for( auto& [oldLayer, shapePtr] : m_FilledPolysList )
|
|
|
|
{
|
|
|
|
fillsCopy[oldLayer] = *shapePtr;
|
|
|
|
}
|
|
|
|
|
2022-02-18 10:12:11 +00:00
|
|
|
SetLayerSet( FlipLayerMask( GetLayerSet(), GetBoard()->GetCopperLayerCount() ) );
|
2023-10-11 23:21:47 +00:00
|
|
|
|
|
|
|
for( auto& [oldLayer, shape] : fillsCopy )
|
|
|
|
{
|
|
|
|
PCB_LAYER_ID newLayer = FlipLayer( oldLayer, GetBoard()->GetCopperLayerCount() );
|
|
|
|
SetFilledPolysList( newLayer, shape );
|
|
|
|
}
|
2009-08-01 19:26:05 +00:00
|
|
|
}
|
2008-01-06 12:43:57 +00:00
|
|
|
|
2011-01-20 18:40:33 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
void ZONE::Mirror( const VECTOR2I& aMirrorRef, bool aMirrorLeftRight )
|
2008-01-06 12:43:57 +00:00
|
|
|
{
|
2022-01-01 06:04:08 +00:00
|
|
|
m_Poly->Mirror( aMirrorLeftRight, !aMirrorLeftRight, aMirrorRef );
|
2008-01-31 20:53:44 +00:00
|
|
|
|
2020-08-07 14:04:34 +00:00
|
|
|
HatchBorder();
|
2009-08-01 19:58:01 +00:00
|
|
|
|
2022-02-15 17:34:38 +00:00
|
|
|
for( std::pair<const PCB_LAYER_ID, std::shared_ptr<SHAPE_POLY_SET>>& pair : m_FilledPolysList )
|
|
|
|
pair.second->Mirror( aMirrorLeftRight, !aMirrorLeftRight, aMirrorRef );
|
2008-01-06 12:43:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-11 23:05:59 +00:00
|
|
|
void ZONE::RemoveCutout( int aOutlineIdx, int aHoleIdx )
|
2020-04-14 16:57:18 +00:00
|
|
|
{
|
|
|
|
// Ensure the requested cutout is valid
|
|
|
|
if( m_Poly->OutlineCount() < aOutlineIdx || m_Poly->HoleCount( aOutlineIdx ) < aHoleIdx )
|
|
|
|
return;
|
|
|
|
|
|
|
|
SHAPE_POLY_SET cutPoly( m_Poly->Hole( aOutlineIdx, aHoleIdx ) );
|
|
|
|
|
|
|
|
// Add the cutout back to the zone
|
|
|
|
m_Poly->BooleanAdd( cutPoly, SHAPE_POLY_SET::PM_FAST );
|
|
|
|
|
|
|
|
SetNeedRefill( true );
|
|
|
|
}
|
2012-02-24 23:23:46 +00:00
|
|
|
|
|
|
|
|
2020-11-11 23:05:59 +00:00
|
|
|
void ZONE::AddPolygon( const SHAPE_LINE_CHAIN& aPolygon )
|
2019-05-21 02:31:40 +00:00
|
|
|
{
|
|
|
|
wxASSERT( aPolygon.IsClosed() );
|
|
|
|
|
|
|
|
// Add the outline as a new polygon in the polygon set
|
|
|
|
if( m_Poly->OutlineCount() == 0 )
|
|
|
|
m_Poly->AddOutline( aPolygon );
|
|
|
|
else
|
|
|
|
m_Poly->AddHole( aPolygon );
|
|
|
|
|
|
|
|
SetNeedRefill( true );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
void ZONE::AddPolygon( std::vector<VECTOR2I>& aPolygon )
|
2012-06-09 17:00:13 +00:00
|
|
|
{
|
|
|
|
if( aPolygon.empty() )
|
|
|
|
return;
|
|
|
|
|
2017-03-07 12:06:00 +00:00
|
|
|
SHAPE_LINE_CHAIN outline;
|
|
|
|
|
|
|
|
// Create an outline and populate it with the points of aPolygon
|
2022-01-01 06:04:08 +00:00
|
|
|
for( const VECTOR2I& pt : aPolygon )
|
2020-05-21 17:42:42 +00:00
|
|
|
outline.Append( pt );
|
2012-06-09 17:00:13 +00:00
|
|
|
|
2017-03-07 12:06:00 +00:00
|
|
|
outline.SetClosed( true );
|
2012-06-09 17:00:13 +00:00
|
|
|
|
2020-04-14 17:00:09 +00:00
|
|
|
AddPolygon( outline );
|
2017-03-07 12:06:00 +00:00
|
|
|
}
|
2012-06-09 17:00:13 +00:00
|
|
|
|
2017-04-07 06:02:26 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
bool ZONE::AppendCorner( VECTOR2I aPosition, int aHoleIdx, bool aAllowDuplication )
|
2017-06-19 11:29:57 +00:00
|
|
|
{
|
|
|
|
// Ensure the main outline exists:
|
|
|
|
if( m_Poly->OutlineCount() == 0 )
|
|
|
|
m_Poly->NewOutline();
|
|
|
|
|
|
|
|
// If aHoleIdx >= 0, the corner musty be added to the hole, index aHoleIdx.
|
|
|
|
// (remember: the index of the first hole is 0)
|
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
|
|
|
// Return error if it does not exist.
|
2017-06-19 11:29:57 +00:00
|
|
|
if( aHoleIdx >= m_Poly->HoleCount( 0 ) )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
m_Poly->Append( aPosition.x, aPosition.y, -1, aHoleIdx, aAllowDuplication );
|
|
|
|
|
2019-03-14 13:35:55 +00:00
|
|
|
SetNeedRefill( true );
|
|
|
|
|
2017-06-19 11:29:57 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-06-27 09:11:55 +00:00
|
|
|
wxString ZONE::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const
|
2011-07-14 15:42:44 +00:00
|
|
|
{
|
2023-08-03 14:03:04 +00:00
|
|
|
LSEQ layers = m_layerSet.Seq();
|
2020-06-24 02:19:08 +00:00
|
|
|
wxString layerDesc;
|
|
|
|
|
2023-08-03 14:03:04 +00:00
|
|
|
if( layers.size() == 1 )
|
2020-06-24 02:19:08 +00:00
|
|
|
{
|
2023-08-03 14:03:04 +00:00
|
|
|
layerDesc.Printf( _( "on %s" ), GetBoard()->GetLayerName( layers[0] ) );
|
|
|
|
}
|
|
|
|
else if (layers.size() == 2 )
|
|
|
|
{
|
|
|
|
layerDesc.Printf( _( "on %s and %s" ),
|
|
|
|
GetBoard()->GetLayerName( layers[0] ),
|
|
|
|
GetBoard()->GetLayerName( layers[1] ) );
|
|
|
|
}
|
|
|
|
else if (layers.size() == 3 )
|
|
|
|
{
|
|
|
|
layerDesc.Printf( _( "on %s, %s and %s" ),
|
|
|
|
GetBoard()->GetLayerName( layers[0] ),
|
|
|
|
GetBoard()->GetLayerName( layers[1] ),
|
|
|
|
GetBoard()->GetLayerName( layers[2] ) );
|
|
|
|
}
|
|
|
|
else if( layers.size() > 3 )
|
|
|
|
{
|
2023-08-09 23:38:43 +00:00
|
|
|
layerDesc.Printf( _( "on %s, %s and %zu more" ),
|
2023-08-03 14:03:04 +00:00
|
|
|
GetBoard()->GetLayerName( layers[0] ),
|
|
|
|
GetBoard()->GetLayerName( layers[1] ),
|
|
|
|
layers.size() - 2 );
|
2020-06-24 02:19:08 +00:00
|
|
|
}
|
|
|
|
|
2020-11-19 22:33:18 +00:00
|
|
|
// Check whether the selected contour is a hole (contour index > 0)
|
|
|
|
if( m_CornerSelection != nullptr && m_CornerSelection->m_contour > 0 )
|
|
|
|
{
|
|
|
|
if( GetIsRuleArea() )
|
2023-08-03 14:03:04 +00:00
|
|
|
return wxString::Format( _( "Rule Area Cutout %s" ), layerDesc );
|
2020-11-19 22:33:18 +00:00
|
|
|
else
|
2023-08-03 14:03:04 +00:00
|
|
|
return wxString::Format( _( "Zone Cutout %s" ), layerDesc );
|
2020-11-19 22:33:18 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( GetIsRuleArea() )
|
2023-08-03 14:03:04 +00:00
|
|
|
return wxString::Format( _( "Rule Area %s" ), layerDesc );
|
2020-11-19 22:33:18 +00:00
|
|
|
else
|
2023-08-03 14:03:04 +00:00
|
|
|
return wxString::Format( _( "Zone %s %s" ), GetNetnameMsg(), layerDesc );
|
2020-11-19 22:33:18 +00:00
|
|
|
}
|
2015-12-27 15:51:13 +00:00
|
|
|
}
|
2017-02-20 12:20:39 +00:00
|
|
|
|
|
|
|
|
2020-11-11 23:05:59 +00:00
|
|
|
int ZONE::GetBorderHatchPitch() const
|
2017-03-07 12:06:00 +00:00
|
|
|
{
|
2020-08-07 14:04:34 +00:00
|
|
|
return m_borderHatchPitch;
|
2017-03-07 12:06:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-02-12 16:37:27 +00:00
|
|
|
void ZONE::SetBorderDisplayStyle( ZONE_BORDER_DISPLAY_STYLE aBorderHatchStyle,
|
2022-09-19 09:25:20 +00:00
|
|
|
int aBorderHatchPitch, bool aRebuildBorderHatch )
|
2022-02-12 16:37:27 +00:00
|
|
|
{
|
|
|
|
aBorderHatchPitch = std::max( aBorderHatchPitch,
|
2022-09-16 11:33:56 +00:00
|
|
|
pcbIUScale.mmToIU( ZONE_BORDER_HATCH_MINDIST_MM ) );
|
2022-02-12 16:37:27 +00:00
|
|
|
aBorderHatchPitch = std::min( aBorderHatchPitch,
|
2022-09-16 11:33:56 +00:00
|
|
|
pcbIUScale.mmToIU( ZONE_BORDER_HATCH_MAXDIST_MM ) );
|
2022-02-12 16:37:27 +00:00
|
|
|
SetBorderHatchPitch( aBorderHatchPitch );
|
|
|
|
m_borderStyle = aBorderHatchStyle;
|
|
|
|
|
|
|
|
if( aRebuildBorderHatch )
|
2020-08-07 14:04:34 +00:00
|
|
|
HatchBorder();
|
2017-03-07 12:06:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-02-12 16:37:27 +00:00
|
|
|
void ZONE::SetBorderHatchPitch( int aPitch )
|
2017-03-07 12:06:00 +00:00
|
|
|
{
|
2020-08-07 14:04:34 +00:00
|
|
|
m_borderHatchPitch = aPitch;
|
2017-03-07 12:06:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-11 23:05:59 +00:00
|
|
|
void ZONE::UnHatchBorder()
|
2017-03-07 12:06:00 +00:00
|
|
|
{
|
2020-08-07 14:04:34 +00:00
|
|
|
m_borderHatchLines.clear();
|
2017-03-07 12:06:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Creates hatch lines inside the outline of the complex polygon
|
2022-01-11 00:49:49 +00:00
|
|
|
// sort function used in ::HatchBorder to sort points by descending VECTOR2I.x values
|
2017-03-07 12:06:00 +00:00
|
|
|
bool sortEndsByDescendingX( const VECTOR2I& ref, const VECTOR2I& tst )
|
|
|
|
{
|
|
|
|
return tst.x < ref.x;
|
|
|
|
}
|
|
|
|
|
2017-07-01 13:16:51 +00:00
|
|
|
|
2020-11-11 23:05:59 +00:00
|
|
|
void ZONE::HatchBorder()
|
2017-03-07 12:06:00 +00:00
|
|
|
{
|
2020-08-07 14:04:34 +00:00
|
|
|
UnHatchBorder();
|
2017-03-07 12:06:00 +00:00
|
|
|
|
2020-08-07 14:04:34 +00:00
|
|
|
if( m_borderStyle == ZONE_BORDER_DISPLAY_STYLE::NO_HATCH
|
|
|
|
|| m_borderHatchPitch == 0
|
|
|
|
|| m_Poly->IsEmpty() )
|
|
|
|
{
|
2017-03-07 12:06:00 +00:00
|
|
|
return;
|
2020-08-07 14:04:34 +00:00
|
|
|
}
|
2017-03-07 12:06:00 +00:00
|
|
|
|
|
|
|
// define range for hatch lines
|
2019-03-23 18:26:44 +00:00
|
|
|
int min_x = m_Poly->CVertex( 0 ).x;
|
|
|
|
int max_x = m_Poly->CVertex( 0 ).x;
|
|
|
|
int min_y = m_Poly->CVertex( 0 ).y;
|
|
|
|
int max_y = m_Poly->CVertex( 0 ).y;
|
2017-03-07 12:06:00 +00:00
|
|
|
|
|
|
|
for( auto iterator = m_Poly->IterateWithHoles(); iterator; iterator++ )
|
|
|
|
{
|
|
|
|
if( iterator->x < min_x )
|
|
|
|
min_x = iterator->x;
|
|
|
|
|
|
|
|
if( iterator->x > max_x )
|
|
|
|
max_x = iterator->x;
|
|
|
|
|
|
|
|
if( iterator->y < min_y )
|
|
|
|
min_y = iterator->y;
|
|
|
|
|
|
|
|
if( iterator->y > max_y )
|
|
|
|
max_y = iterator->y;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Calculate spacing between 2 hatch lines
|
|
|
|
int spacing;
|
|
|
|
|
2020-08-07 14:04:34 +00:00
|
|
|
if( m_borderStyle == ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_EDGE )
|
|
|
|
spacing = m_borderHatchPitch;
|
2017-03-07 12:06:00 +00:00
|
|
|
else
|
2020-08-07 14:04:34 +00:00
|
|
|
spacing = m_borderHatchPitch * 2;
|
2017-03-07 12:06:00 +00:00
|
|
|
|
|
|
|
// set the "length" of hatch lines (the length on horizontal axis)
|
2020-08-07 14:04:34 +00:00
|
|
|
int hatch_line_len = m_borderHatchPitch;
|
2017-03-07 12:06:00 +00:00
|
|
|
|
|
|
|
// To have a better look, give a slope depending on the layer
|
2023-05-12 21:03:54 +00:00
|
|
|
int layer = GetFirstLayer();
|
|
|
|
std::vector<int> slope_flags;
|
2017-03-07 12:06:00 +00:00
|
|
|
|
2023-05-12 21:03:54 +00:00
|
|
|
if( IsTeardropArea() )
|
|
|
|
slope_flags = { 1, -1 };
|
|
|
|
else if( layer & 1 )
|
|
|
|
slope_flags = { 1 };
|
2017-03-07 12:06:00 +00:00
|
|
|
else
|
2023-05-12 21:03:54 +00:00
|
|
|
slope_flags = { -1 };
|
2017-03-07 12:06:00 +00:00
|
|
|
|
2023-05-12 21:03:54 +00:00
|
|
|
for( int slope_flag : slope_flags )
|
2017-03-07 12:06:00 +00:00
|
|
|
{
|
2023-05-12 21:03:54 +00:00
|
|
|
double slope = 0.707106 * slope_flag; // 45 degrees slope
|
|
|
|
int64_t max_a, min_a;
|
2017-03-07 12:06:00 +00:00
|
|
|
|
2023-05-12 21:03:54 +00:00
|
|
|
if( slope_flag == 1 )
|
2017-03-07 12:06:00 +00:00
|
|
|
{
|
2023-05-12 21:03:54 +00:00
|
|
|
max_a = KiROUND( max_y - slope * min_x );
|
|
|
|
min_a = KiROUND( min_y - slope * max_x );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
max_a = KiROUND( max_y - slope * max_x );
|
|
|
|
min_a = KiROUND( min_y - slope * min_x );
|
2017-03-07 12:06:00 +00:00
|
|
|
}
|
|
|
|
|
2023-05-12 21:03:54 +00:00
|
|
|
min_a = (min_a / spacing) * spacing;
|
|
|
|
|
|
|
|
// calculate an offset depending on layer number,
|
|
|
|
// for a better look of hatches on a multilayer board
|
|
|
|
int offset = (layer * 7) / 8;
|
|
|
|
min_a += offset;
|
|
|
|
|
|
|
|
// loop through hatch lines
|
|
|
|
std::vector<VECTOR2I> pointbuffer;
|
|
|
|
pointbuffer.reserve( 256 );
|
2017-03-07 12:06:00 +00:00
|
|
|
|
2023-05-12 21:03:54 +00:00
|
|
|
for( int64_t a = min_a; a < max_a; a += spacing )
|
2017-03-07 12:06:00 +00:00
|
|
|
{
|
2023-05-12 21:03:54 +00:00
|
|
|
pointbuffer.clear();
|
2017-03-07 12:06:00 +00:00
|
|
|
|
2023-05-12 21:03:54 +00:00
|
|
|
// Iterate through all vertices
|
|
|
|
for( auto iterator = m_Poly->IterateSegmentsWithHoles(); iterator; iterator++ )
|
2017-03-07 12:06:00 +00:00
|
|
|
{
|
2023-05-12 21:03:54 +00:00
|
|
|
const SEG seg = *iterator;
|
|
|
|
double x, y;
|
2017-03-07 12:06:00 +00:00
|
|
|
|
2023-05-12 21:03:54 +00:00
|
|
|
if( FindLineSegmentIntersection( a, slope, seg.A.x, seg.A.y, seg.B.x, seg.B.y, x, y ) )
|
|
|
|
pointbuffer.emplace_back( KiROUND( x ), KiROUND( y ) );
|
|
|
|
}
|
2017-03-07 12:06:00 +00:00
|
|
|
|
2023-05-12 21:03:54 +00:00
|
|
|
// sort points in order of descending x (if more than 2) to
|
|
|
|
// ensure the starting point and the ending point of the same segment
|
|
|
|
// are stored one just after the other.
|
|
|
|
if( pointbuffer.size() > 2 )
|
|
|
|
sort( pointbuffer.begin(), pointbuffer.end(), sortEndsByDescendingX );
|
2017-03-07 12:06:00 +00:00
|
|
|
|
2023-05-12 21:03:54 +00:00
|
|
|
// creates lines or short segments inside the complex polygon
|
|
|
|
for( size_t ip = 0; ip + 1 < pointbuffer.size(); ip += 2 )
|
|
|
|
{
|
|
|
|
int dx = pointbuffer[ip + 1].x - pointbuffer[ip].x;
|
|
|
|
|
|
|
|
// Push only one line for diagonal hatch,
|
|
|
|
// or for small lines < twice the line length
|
|
|
|
// else push 2 small lines
|
|
|
|
if( m_borderStyle == ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_FULL
|
|
|
|
|| std::abs( dx ) < 2 * hatch_line_len )
|
|
|
|
{
|
|
|
|
m_borderHatchLines.emplace_back( SEG( pointbuffer[ip], pointbuffer[ ip + 1] ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
double dy = pointbuffer[ip + 1].y - pointbuffer[ip].y;
|
|
|
|
slope = dy / dx;
|
|
|
|
|
|
|
|
if( dx > 0 )
|
|
|
|
dx = hatch_line_len;
|
|
|
|
else
|
|
|
|
dx = -hatch_line_len;
|
|
|
|
|
|
|
|
int x1 = KiROUND( pointbuffer[ip].x + dx );
|
|
|
|
int x2 = KiROUND( pointbuffer[ip + 1].x - dx );
|
|
|
|
int y1 = KiROUND( pointbuffer[ip].y + dx * slope );
|
|
|
|
int y2 = KiROUND( pointbuffer[ip + 1].y - dx * slope );
|
|
|
|
|
|
|
|
m_borderHatchLines.emplace_back( SEG( pointbuffer[ip].x, pointbuffer[ip].y,
|
|
|
|
x1, y1 ) );
|
|
|
|
|
|
|
|
m_borderHatchLines.emplace_back( SEG( pointbuffer[ip+1].x, pointbuffer[ip+1].y,
|
|
|
|
x2, y2 ) );
|
|
|
|
}
|
2017-03-07 12:06:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-11 23:05:59 +00:00
|
|
|
int ZONE::GetDefaultHatchPitch()
|
2017-07-01 13:16:51 +00:00
|
|
|
{
|
2023-02-11 02:54:40 +00:00
|
|
|
return pcbIUScale.mmToIU( ZONE_BORDER_HATCH_DIST_MM );
|
2017-07-01 13:16:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-03-08 02:59:07 +00:00
|
|
|
BITMAPS ZONE::GetMenuImage() const
|
2017-02-20 12:20:39 +00:00
|
|
|
{
|
2021-03-08 02:59:07 +00:00
|
|
|
return BITMAPS::add_zone;
|
2017-02-20 12:20:39 +00:00
|
|
|
}
|
2017-10-31 13:59:03 +00:00
|
|
|
|
2018-06-22 23:35:07 +00:00
|
|
|
|
2022-11-11 17:09:25 +00:00
|
|
|
void ZONE::swapData( BOARD_ITEM* aImage )
|
2017-10-31 13:59:03 +00:00
|
|
|
{
|
2023-03-30 11:49:23 +00:00
|
|
|
assert( aImage->Type() == PCB_ZONE_T );
|
2017-10-31 13:59:03 +00:00
|
|
|
|
2022-10-21 17:41:21 +00:00
|
|
|
std::swap( *static_cast<ZONE*>( this ), *static_cast<ZONE*>( aImage) );
|
2017-10-31 13:59:03 +00:00
|
|
|
}
|
2017-11-23 16:20:27 +00:00
|
|
|
|
2018-06-22 23:35:07 +00:00
|
|
|
|
2020-11-11 23:05:59 +00:00
|
|
|
void ZONE::CacheTriangulation( PCB_LAYER_ID aLayer )
|
2017-11-23 16:20:27 +00:00
|
|
|
{
|
2020-09-14 17:54:14 +00:00
|
|
|
if( aLayer == UNDEFINED_LAYER )
|
|
|
|
{
|
2022-10-21 17:41:21 +00:00
|
|
|
for( auto& [ layer, poly ] : m_FilledPolysList )
|
|
|
|
poly->CacheTriangulation();
|
2022-03-08 23:54:34 +00:00
|
|
|
|
|
|
|
m_Poly->CacheTriangulation( false );
|
2020-09-14 17:54:14 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( m_FilledPolysList.count( aLayer ) )
|
2022-02-15 17:34:38 +00:00
|
|
|
m_FilledPolysList[ aLayer ]->CacheTriangulation();
|
2020-09-14 17:54:14 +00:00
|
|
|
}
|
2017-11-23 16:20:27 +00:00
|
|
|
}
|
2017-12-04 18:06:47 +00:00
|
|
|
|
2018-06-22 23:35:07 +00:00
|
|
|
|
2020-12-20 18:44:13 +00:00
|
|
|
bool ZONE::IsIsland( PCB_LAYER_ID aLayer, int aPolyIdx ) const
|
2020-06-26 02:19:51 +00:00
|
|
|
{
|
|
|
|
if( GetNetCode() < 1 )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if( !m_insulatedIslands.count( aLayer ) )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return m_insulatedIslands.at( aLayer ).count( aPolyIdx );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-11-01 10:55:35 +00:00
|
|
|
void ZONE::GetInteractingZones( PCB_LAYER_ID aLayer, std::vector<ZONE*>* aSameNetCollidingZones,
|
|
|
|
std::vector<ZONE*>* aOtherNetIntersectingZones ) const
|
2019-07-13 22:34:09 +00:00
|
|
|
{
|
2022-09-16 11:33:56 +00:00
|
|
|
int epsilon = pcbIUScale.mmToIU( 0.001 );
|
2022-10-01 21:09:38 +00:00
|
|
|
BOX2I bbox = GetBoundingBox();
|
2022-09-16 18:16:15 +00:00
|
|
|
|
|
|
|
bbox.Inflate( epsilon );
|
2019-07-13 22:34:09 +00:00
|
|
|
|
2020-11-11 23:05:59 +00:00
|
|
|
for( ZONE* candidate : GetBoard()->Zones() )
|
2019-07-13 22:34:09 +00:00
|
|
|
{
|
2019-07-28 16:31:26 +00:00
|
|
|
if( candidate == this )
|
|
|
|
continue;
|
|
|
|
|
2020-08-12 18:42:40 +00:00
|
|
|
if( !candidate->GetLayerSet().test( aLayer ) )
|
2019-07-28 16:31:26 +00:00
|
|
|
continue;
|
|
|
|
|
2022-11-01 10:55:35 +00:00
|
|
|
if( candidate->GetIsRuleArea() || candidate->IsTeardropArea() )
|
2019-07-28 16:31:26 +00:00
|
|
|
continue;
|
|
|
|
|
2022-10-01 21:09:38 +00:00
|
|
|
if( !candidate->GetBoundingBox().Intersects( bbox ) )
|
2022-09-16 18:16:15 +00:00
|
|
|
continue;
|
|
|
|
|
2022-11-01 10:55:35 +00:00
|
|
|
if( candidate->GetNetCode() == GetNetCode() )
|
2019-07-13 22:34:09 +00:00
|
|
|
{
|
2022-11-03 11:10:08 +00:00
|
|
|
if( m_Poly->Collide( candidate->m_Poly ) )
|
|
|
|
aSameNetCollidingZones->push_back( candidate );
|
2019-07-13 22:34:09 +00:00
|
|
|
}
|
2022-11-01 10:55:35 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
aOtherNetIntersectingZones->push_back( candidate );
|
|
|
|
}
|
2019-07-13 22:34:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-11 23:05:59 +00:00
|
|
|
bool ZONE::BuildSmoothedPoly( SHAPE_POLY_SET& aSmoothedPoly, PCB_LAYER_ID aLayer,
|
|
|
|
SHAPE_POLY_SET* aBoardOutline,
|
|
|
|
SHAPE_POLY_SET* aSmoothedPolyWithApron ) const
|
2017-12-04 18:06:47 +00:00
|
|
|
{
|
2020-08-30 14:18:35 +00:00
|
|
|
if( GetNumCorners() <= 2 ) // malformed zone. polygon calculations will not like it ...
|
2017-12-04 18:06:47 +00:00
|
|
|
return false;
|
|
|
|
|
2021-08-08 19:09:12 +00:00
|
|
|
// Processing of arc shapes in zones is not yet supported because Clipper can't do boolean
|
2022-03-04 12:11:07 +00:00
|
|
|
// operations on them. The poly outline must be converted to segments first.
|
2022-03-14 15:52:12 +00:00
|
|
|
SHAPE_POLY_SET flattened = m_Poly->CloneDropTriangulation();
|
2021-08-08 19:09:12 +00:00
|
|
|
flattened.ClearArcs();
|
|
|
|
|
2020-10-10 22:09:00 +00:00
|
|
|
if( GetIsRuleArea() )
|
|
|
|
{
|
|
|
|
// We like keepouts just the way they are....
|
2021-08-08 19:09:12 +00:00
|
|
|
aSmoothedPoly = flattened;
|
2020-10-10 22:09:00 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-08-16 09:53:27 +00:00
|
|
|
const BOARD* board = GetBoard();
|
|
|
|
int maxError = ARC_HIGH_DEF;
|
|
|
|
bool keepExternalFillets = false;
|
2022-03-05 16:18:42 +00:00
|
|
|
bool smooth_requested = m_cornerSmoothingType == ZONE_SETTINGS::SMOOTHING_CHAMFER
|
|
|
|
|| m_cornerSmoothingType == ZONE_SETTINGS::SMOOTHING_FILLET;
|
|
|
|
|
2022-10-21 17:41:21 +00:00
|
|
|
if( IsTeardropArea() )
|
|
|
|
{
|
|
|
|
// We use teardrop shapes with no smoothing; these shapes are already optimized
|
2022-03-05 16:18:42 +00:00
|
|
|
smooth_requested = false;
|
2022-10-21 17:41:21 +00:00
|
|
|
}
|
2020-08-12 18:42:40 +00:00
|
|
|
|
2020-08-30 14:18:35 +00:00
|
|
|
if( board )
|
|
|
|
{
|
2021-01-23 15:43:13 +00:00
|
|
|
BOARD_DESIGN_SETTINGS& bds = board->GetDesignSettings();
|
|
|
|
|
|
|
|
maxError = bds.m_MaxError;
|
|
|
|
keepExternalFillets = bds.m_ZoneKeepExternalFillets;
|
2020-08-30 14:18:35 +00:00
|
|
|
}
|
2020-08-12 18:42:40 +00:00
|
|
|
|
2020-08-30 14:18:35 +00:00
|
|
|
auto smooth = [&]( SHAPE_POLY_SET& aPoly )
|
|
|
|
{
|
2022-03-05 16:18:42 +00:00
|
|
|
if( !smooth_requested )
|
|
|
|
return;
|
|
|
|
|
2020-08-30 14:18:35 +00:00
|
|
|
switch( m_cornerSmoothingType )
|
|
|
|
{
|
|
|
|
case ZONE_SETTINGS::SMOOTHING_CHAMFER:
|
|
|
|
aPoly = aPoly.Chamfer( (int) m_cornerRadius );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ZONE_SETTINGS::SMOOTHING_FILLET:
|
|
|
|
{
|
|
|
|
aPoly = aPoly.Fillet( (int) m_cornerRadius, maxError );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
};
|
2020-08-12 18:42:40 +00:00
|
|
|
|
2021-08-08 19:09:12 +00:00
|
|
|
SHAPE_POLY_SET* maxExtents = &flattened;
|
2020-08-30 14:18:35 +00:00
|
|
|
SHAPE_POLY_SET withFillets;
|
2017-12-04 18:06:47 +00:00
|
|
|
|
2021-08-08 19:09:12 +00:00
|
|
|
aSmoothedPoly = flattened;
|
2019-05-22 14:47:38 +00:00
|
|
|
|
2020-08-30 14:18:35 +00:00
|
|
|
// Should external fillets (that is, those applied to concave corners) be kept? While it
|
|
|
|
// seems safer to never have copper extend outside the zone outline, 5.1.x and prior did
|
|
|
|
// indeed fill them so we leave the mode available.
|
2022-03-05 16:18:42 +00:00
|
|
|
if( keepExternalFillets && smooth_requested )
|
2020-08-30 14:18:35 +00:00
|
|
|
{
|
2021-08-08 19:09:12 +00:00
|
|
|
withFillets = flattened;
|
2020-08-30 14:18:35 +00:00
|
|
|
smooth( withFillets );
|
2021-08-08 19:09:12 +00:00
|
|
|
withFillets.BooleanAdd( flattened, SHAPE_POLY_SET::PM_FAST );
|
2020-08-30 14:18:35 +00:00
|
|
|
maxExtents = &withFillets;
|
2019-05-22 14:47:38 +00:00
|
|
|
}
|
2020-08-25 18:03:21 +00:00
|
|
|
|
2022-11-01 10:55:35 +00:00
|
|
|
// We now add in the areas of any same-net, intersecting zones. This keeps us from smoothing
|
|
|
|
// corners at an intersection (which often produces undesired divots between the intersecting
|
|
|
|
// zones -- see #2752).
|
|
|
|
//
|
|
|
|
// After smoothing, we'll subtract back out everything outside of our zone.
|
|
|
|
std::vector<ZONE*> sameNetCollidingZones;
|
2023-11-17 17:48:05 +00:00
|
|
|
std::vector<ZONE*> diffNetIntersectingZones;
|
|
|
|
GetInteractingZones( aLayer, &sameNetCollidingZones, &diffNetIntersectingZones );
|
2022-11-01 10:55:35 +00:00
|
|
|
|
|
|
|
for( ZONE* sameNetZone : sameNetCollidingZones )
|
2021-08-09 07:16:04 +00:00
|
|
|
{
|
2023-11-17 17:48:05 +00:00
|
|
|
BOX2I sameNetBoundingBox = sameNetZone->GetBoundingBox();
|
2022-11-01 10:55:35 +00:00
|
|
|
|
2023-11-17 17:48:05 +00:00
|
|
|
// Note: a two-pass algorithm could use sameNetZone's actual fill instead of its outline.
|
|
|
|
// This would obviate the need for the below wrinkles, in addition to fixing both issues
|
|
|
|
// in #16095.
|
|
|
|
// (And we wouldn't need to collect all the diffNetIntersectingZones either.)
|
2023-03-08 01:02:47 +00:00
|
|
|
|
2023-11-17 17:48:05 +00:00
|
|
|
SHAPE_POLY_SET sameNetPoly = sameNetZone->Outline()->CloneDropTriangulation();
|
|
|
|
SHAPE_POLY_SET diffNetPoly;
|
2022-11-01 10:55:35 +00:00
|
|
|
|
|
|
|
// Of course there's always a wrinkle. The same-net intersecting zone *might* get knocked
|
|
|
|
// out along the border by a higher-priority, different-net zone. #12797
|
2023-11-17 17:48:05 +00:00
|
|
|
for( ZONE* diffNetZone : diffNetIntersectingZones )
|
2022-11-01 10:55:35 +00:00
|
|
|
{
|
2023-11-17 17:48:05 +00:00
|
|
|
if( diffNetZone->HigherPriority( sameNetZone )
|
|
|
|
&& diffNetZone->GetBoundingBox().Intersects( sameNetBoundingBox ) )
|
2022-11-01 10:55:35 +00:00
|
|
|
{
|
2023-11-17 17:48:05 +00:00
|
|
|
diffNetPoly.BooleanAdd( *diffNetZone->Outline(), SHAPE_POLY_SET::PM_FAST );
|
2022-11-01 10:55:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-11-17 17:48:05 +00:00
|
|
|
// Second wrinkle. After unioning the higher priority, different net zones together, we
|
|
|
|
// need to check to see if they completely enclose our zone. If they do, then we need to
|
|
|
|
// treat the enclosed zone as isolated, not connected to the outer zone. #13915
|
|
|
|
bool isolated = false;
|
|
|
|
|
2023-03-08 01:02:47 +00:00
|
|
|
if( diffNetPoly.OutlineCount() )
|
2023-11-17 17:48:05 +00:00
|
|
|
{
|
|
|
|
SHAPE_POLY_SET thisPoly = Outline()->CloneDropTriangulation();
|
|
|
|
|
|
|
|
thisPoly.BooleanSubtract( diffNetPoly, SHAPE_POLY_SET::PM_FAST );
|
|
|
|
isolated = thisPoly.OutlineCount() == 0;
|
|
|
|
}
|
2023-03-08 01:02:47 +00:00
|
|
|
|
2023-11-17 17:48:05 +00:00
|
|
|
if( !isolated )
|
|
|
|
{
|
|
|
|
sameNetPoly.ClearArcs();
|
2023-03-08 01:02:47 +00:00
|
|
|
aSmoothedPoly.BooleanAdd( sameNetPoly, SHAPE_POLY_SET::PM_FAST );
|
2023-11-17 17:48:05 +00:00
|
|
|
}
|
2021-08-09 07:16:04 +00:00
|
|
|
}
|
2020-08-30 14:18:35 +00:00
|
|
|
|
2021-02-03 11:56:15 +00:00
|
|
|
if( aBoardOutline )
|
2022-03-14 15:52:12 +00:00
|
|
|
aSmoothedPoly.BooleanIntersection( *aBoardOutline, SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
|
2020-10-10 22:09:00 +00:00
|
|
|
|
2020-08-30 14:18:35 +00:00
|
|
|
smooth( aSmoothedPoly );
|
2017-12-04 18:06:47 +00:00
|
|
|
|
2020-10-29 21:17:57 +00:00
|
|
|
if( aSmoothedPolyWithApron )
|
|
|
|
{
|
2022-03-14 15:52:12 +00:00
|
|
|
SHAPE_POLY_SET poly = maxExtents->CloneDropTriangulation();
|
2023-10-05 07:34:24 +00:00
|
|
|
poly.Inflate( m_ZoneMinThickness, CORNER_STRATEGY::ROUND_ALL_CORNERS, maxError );
|
2020-10-29 21:17:57 +00:00
|
|
|
*aSmoothedPolyWithApron = aSmoothedPoly;
|
2021-02-03 11:56:15 +00:00
|
|
|
aSmoothedPolyWithApron->BooleanIntersection( poly, SHAPE_POLY_SET::PM_FAST );
|
2020-10-29 21:17:57 +00:00
|
|
|
}
|
|
|
|
|
2020-10-10 12:10:52 +00:00
|
|
|
aSmoothedPoly.BooleanIntersection( *maxExtents, SHAPE_POLY_SET::PM_FAST );
|
2020-08-12 18:42:40 +00:00
|
|
|
|
2017-12-04 18:06:47 +00:00
|
|
|
return true;
|
2020-08-30 14:18:35 +00:00
|
|
|
}
|
2017-12-13 23:33:20 +00:00
|
|
|
|
2020-02-05 09:43:52 +00:00
|
|
|
|
2020-11-11 23:05:59 +00:00
|
|
|
double ZONE::CalculateFilledArea()
|
2020-02-05 09:43:52 +00:00
|
|
|
{
|
|
|
|
m_area = 0.0;
|
|
|
|
|
|
|
|
// Iterate over each outline polygon in the zone and then iterate over
|
|
|
|
// each hole it has to compute the total area.
|
2022-02-15 17:34:38 +00:00
|
|
|
for( std::pair<const PCB_LAYER_ID, std::shared_ptr<SHAPE_POLY_SET>>& pair : m_FilledPolysList )
|
2020-02-05 09:43:52 +00:00
|
|
|
{
|
2022-02-15 17:34:38 +00:00
|
|
|
std::shared_ptr<SHAPE_POLY_SET>& poly = pair.second;
|
2020-02-05 09:43:52 +00:00
|
|
|
|
2022-02-15 17:34:38 +00:00
|
|
|
for( int i = 0; i < poly->OutlineCount(); i++ )
|
2020-02-05 09:43:52 +00:00
|
|
|
{
|
2022-02-15 17:34:38 +00:00
|
|
|
m_area += poly->Outline( i ).Area();
|
2020-06-24 02:19:08 +00:00
|
|
|
|
2022-02-15 17:34:38 +00:00
|
|
|
for( int j = 0; j < poly->HoleCount( i ); j++ )
|
|
|
|
m_area -= poly->Hole( i, j ).Area();
|
2020-02-05 09:43:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return m_area;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-08 15:56:41 +00:00
|
|
|
double ZONE::CalculateOutlineArea()
|
|
|
|
{
|
|
|
|
m_outlinearea = std::abs( m_Poly->Area() );
|
|
|
|
return m_outlinearea;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-10-21 12:48:45 +00:00
|
|
|
void ZONE::TransformSmoothedOutlineToPolygon( SHAPE_POLY_SET& aBuffer, int aClearance,
|
2022-02-21 15:19:20 +00:00
|
|
|
int aMaxError, ERROR_LOC aErrorLoc,
|
2020-11-11 23:05:59 +00:00
|
|
|
SHAPE_POLY_SET* aBoardOutline ) const
|
2017-12-13 23:33:20 +00:00
|
|
|
{
|
|
|
|
// Creates the zone outline polygon (with holes if any)
|
|
|
|
SHAPE_POLY_SET polybuffer;
|
2022-02-18 10:12:11 +00:00
|
|
|
|
|
|
|
// TODO: using GetFirstLayer() means it only works for single-layer zones....
|
|
|
|
BuildSmoothedPoly( polybuffer, GetFirstLayer(), aBoardOutline );
|
2017-12-13 23:33:20 +00:00
|
|
|
|
|
|
|
// Calculate the polygon with clearance
|
|
|
|
// holes are linked to the main outline, so only one polygon is created.
|
2020-05-18 16:11:57 +00:00
|
|
|
if( aClearance )
|
2019-05-14 12:39:34 +00:00
|
|
|
{
|
2021-08-16 09:53:27 +00:00
|
|
|
const BOARD* board = GetBoard();
|
|
|
|
int maxError = ARC_HIGH_DEF;
|
2019-05-22 14:47:38 +00:00
|
|
|
|
|
|
|
if( board )
|
|
|
|
maxError = board->GetDesignSettings().m_MaxError;
|
|
|
|
|
2022-02-21 15:19:20 +00:00
|
|
|
if( aErrorLoc == ERROR_OUTSIDE )
|
2023-05-29 14:28:48 +00:00
|
|
|
aClearance += maxError;
|
2022-02-21 15:19:20 +00:00
|
|
|
|
2023-10-05 07:34:24 +00:00
|
|
|
polybuffer.Inflate( aClearance, CORNER_STRATEGY::ROUND_ALL_CORNERS, maxError );
|
2019-05-14 12:39:34 +00:00
|
|
|
}
|
2019-07-13 16:35:57 +00:00
|
|
|
|
2017-12-13 23:33:20 +00:00
|
|
|
polybuffer.Fracture( SHAPE_POLY_SET::PM_FAST );
|
2022-10-21 12:48:45 +00:00
|
|
|
aBuffer.Append( polybuffer );
|
2017-12-13 23:33:20 +00:00
|
|
|
}
|
2019-10-26 15:49:29 +00:00
|
|
|
|
2020-08-18 13:26:22 +00:00
|
|
|
|
2022-03-16 23:48:24 +00:00
|
|
|
std::shared_ptr<SHAPE> ZONE::GetEffectiveShape( PCB_LAYER_ID aLayer, FLASHING aFlash ) const
|
2020-08-26 22:04:16 +00:00
|
|
|
{
|
|
|
|
if( m_FilledPolysList.find( aLayer ) == m_FilledPolysList.end() )
|
2022-06-18 18:47:11 +00:00
|
|
|
return std::make_shared<SHAPE_NULL>();
|
2020-08-26 22:04:16 +00:00
|
|
|
else
|
2022-06-18 18:47:11 +00:00
|
|
|
return m_FilledPolysList.at( aLayer );
|
2020-08-26 22:04:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-10-21 12:48:45 +00:00
|
|
|
void ZONE::TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance,
|
|
|
|
int aError, ERROR_LOC aErrorLoc, bool aIgnoreLineWidth ) const
|
2021-10-25 19:50:33 +00:00
|
|
|
{
|
2022-02-04 22:44:59 +00:00
|
|
|
wxASSERT_MSG( !aIgnoreLineWidth, wxT( "IgnoreLineWidth has no meaning for zones." ) );
|
2021-10-25 19:50:33 +00:00
|
|
|
|
|
|
|
if( !m_FilledPolysList.count( aLayer ) )
|
|
|
|
return;
|
|
|
|
|
2022-07-11 19:26:56 +00:00
|
|
|
if( !aClearance )
|
|
|
|
{
|
2022-10-21 12:48:45 +00:00
|
|
|
aBuffer.Append( *m_FilledPolysList.at( aLayer ) );
|
2022-07-11 19:26:56 +00:00
|
|
|
return;
|
|
|
|
}
|
2022-09-16 04:38:10 +00:00
|
|
|
|
2022-07-11 19:26:56 +00:00
|
|
|
SHAPE_POLY_SET temp_buf = m_FilledPolysList.at( aLayer )->CloneDropTriangulation();
|
2021-10-25 19:50:33 +00:00
|
|
|
|
2022-01-10 17:14:19 +00:00
|
|
|
// Rebuild filled areas only if clearance is not 0
|
2023-05-29 15:22:06 +00:00
|
|
|
if( aClearance > 0 || aErrorLoc == ERROR_OUTSIDE )
|
|
|
|
{
|
|
|
|
if( aErrorLoc == ERROR_OUTSIDE )
|
|
|
|
aClearance += aError;
|
2022-02-21 15:19:20 +00:00
|
|
|
|
2023-10-05 07:34:24 +00:00
|
|
|
temp_buf.InflateWithLinkedHoles( aClearance, CORNER_STRATEGY::ROUND_ALL_CORNERS, aError,
|
2023-05-29 15:22:06 +00:00
|
|
|
SHAPE_POLY_SET::PM_FAST );
|
|
|
|
}
|
2022-07-11 19:26:56 +00:00
|
|
|
|
2022-10-21 12:48:45 +00:00
|
|
|
aBuffer.Append( temp_buf );
|
2021-10-25 19:50:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-10-21 12:48:45 +00:00
|
|
|
void ZONE::TransformSolidAreasShapesToPolygon( PCB_LAYER_ID aLayer, SHAPE_POLY_SET& aBuffer ) const
|
2021-10-25 19:50:33 +00:00
|
|
|
{
|
2022-02-15 17:34:38 +00:00
|
|
|
if( m_FilledPolysList.count( aLayer ) && !m_FilledPolysList.at( aLayer )->IsEmpty() )
|
2022-10-21 12:48:45 +00:00
|
|
|
aBuffer.Append( *m_FilledPolysList.at( aLayer ) );
|
2021-10-25 19:50:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-09-14 21:39:42 +00:00
|
|
|
bool ZONE::operator==( const BOARD_ITEM& aOther ) const
|
|
|
|
{
|
|
|
|
if( aOther.Type() != Type() )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
const ZONE& other = static_cast<const ZONE&>( aOther );
|
2024-04-13 03:05:00 +00:00
|
|
|
return *this == other;
|
|
|
|
}
|
|
|
|
|
2023-09-14 21:39:42 +00:00
|
|
|
|
2024-04-13 03:05:00 +00:00
|
|
|
bool ZONE::operator==( const ZONE& aOther ) const
|
|
|
|
{
|
|
|
|
if( GetIsRuleArea() != aOther.GetIsRuleArea() )
|
2023-09-14 21:39:42 +00:00
|
|
|
return false;
|
|
|
|
|
2024-04-13 03:05:00 +00:00
|
|
|
if( GetLayerSet() != aOther.GetLayerSet() )
|
2023-09-14 21:39:42 +00:00
|
|
|
return false;
|
|
|
|
|
2024-04-13 03:05:00 +00:00
|
|
|
if( GetNetCode() != aOther.GetNetCode() )
|
2023-09-14 21:39:42 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
if( GetIsRuleArea() )
|
|
|
|
{
|
2024-04-13 03:05:00 +00:00
|
|
|
if( GetDoNotAllowCopperPour() != aOther.GetDoNotAllowCopperPour() )
|
2023-09-14 21:39:42 +00:00
|
|
|
return false;
|
2024-04-13 03:05:00 +00:00
|
|
|
if( GetDoNotAllowTracks() != aOther.GetDoNotAllowTracks() )
|
2023-09-14 21:39:42 +00:00
|
|
|
return false;
|
2024-04-13 03:05:00 +00:00
|
|
|
if( GetDoNotAllowVias() != aOther.GetDoNotAllowVias() )
|
2023-09-14 21:39:42 +00:00
|
|
|
return false;
|
2024-04-13 03:05:00 +00:00
|
|
|
if( GetDoNotAllowFootprints() != aOther.GetDoNotAllowFootprints() )
|
2023-09-14 21:39:42 +00:00
|
|
|
return false;
|
2024-04-13 03:05:00 +00:00
|
|
|
if( GetDoNotAllowPads() != aOther.GetDoNotAllowPads() )
|
2023-09-14 21:39:42 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-04-13 03:05:00 +00:00
|
|
|
if( GetAssignedPriority() != aOther.GetAssignedPriority() )
|
2023-09-14 21:39:42 +00:00
|
|
|
return false;
|
|
|
|
|
2024-04-13 03:05:00 +00:00
|
|
|
if( GetMinThickness() != aOther.GetMinThickness() )
|
2023-09-14 21:39:42 +00:00
|
|
|
return false;
|
|
|
|
|
2024-04-13 03:05:00 +00:00
|
|
|
if( GetCornerSmoothingType() != aOther.GetCornerSmoothingType() )
|
2023-09-14 21:39:42 +00:00
|
|
|
return false;
|
|
|
|
|
2024-04-13 03:05:00 +00:00
|
|
|
if( GetCornerRadius() != aOther.GetCornerRadius() )
|
2023-09-14 21:39:42 +00:00
|
|
|
return false;
|
|
|
|
|
2024-04-13 03:05:00 +00:00
|
|
|
if( GetTeardropParams() != aOther.GetTeardropParams() )
|
2023-09-14 21:39:42 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2024-04-13 03:05:00 +00:00
|
|
|
if( GetNumCorners() != aOther.GetNumCorners() )
|
2023-09-14 21:39:42 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
for( int ii = 0; ii < GetNumCorners(); ii++ )
|
|
|
|
{
|
2024-04-13 03:05:00 +00:00
|
|
|
if( GetCornerPosition( ii ) != aOther.GetCornerPosition( ii ) )
|
2023-09-14 21:39:42 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
double ZONE::Similarity( const BOARD_ITEM& aOther ) const
|
|
|
|
{
|
|
|
|
if( aOther.Type() != Type() )
|
|
|
|
return 0.0;
|
|
|
|
|
|
|
|
const ZONE& other = static_cast<const ZONE&>( aOther );
|
|
|
|
|
|
|
|
if( GetIsRuleArea() != other.GetIsRuleArea() )
|
|
|
|
return 0.0;
|
|
|
|
|
|
|
|
double similarity = 1.0;
|
|
|
|
|
|
|
|
if( GetLayerSet() != other.GetLayerSet() )
|
|
|
|
similarity *= 0.9;
|
|
|
|
|
|
|
|
if( GetNetCode() != other.GetNetCode() )
|
|
|
|
similarity *= 0.9;
|
|
|
|
|
|
|
|
if( !GetIsRuleArea() )
|
|
|
|
{
|
|
|
|
if( GetAssignedPriority() != other.GetAssignedPriority() )
|
|
|
|
similarity *= 0.9;
|
|
|
|
|
|
|
|
if( GetMinThickness() != other.GetMinThickness() )
|
|
|
|
similarity *= 0.9;
|
|
|
|
|
|
|
|
if( GetCornerSmoothingType() != other.GetCornerSmoothingType() )
|
|
|
|
similarity *= 0.9;
|
|
|
|
|
|
|
|
if( GetCornerRadius() != other.GetCornerRadius() )
|
|
|
|
similarity *= 0.9;
|
|
|
|
|
|
|
|
if( GetTeardropParams() != other.GetTeardropParams() )
|
|
|
|
similarity *= 0.9;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( GetDoNotAllowCopperPour() != other.GetDoNotAllowCopperPour() )
|
|
|
|
similarity *= 0.9;
|
|
|
|
if( GetDoNotAllowTracks() != other.GetDoNotAllowTracks() )
|
|
|
|
similarity *= 0.9;
|
|
|
|
if( GetDoNotAllowVias() != other.GetDoNotAllowVias() )
|
|
|
|
similarity *= 0.9;
|
|
|
|
if( GetDoNotAllowFootprints() != other.GetDoNotAllowFootprints() )
|
|
|
|
similarity *= 0.9;
|
|
|
|
if( GetDoNotAllowPads() != other.GetDoNotAllowPads() )
|
|
|
|
similarity *= 0.9;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<VECTOR2I> corners;
|
|
|
|
std::vector<VECTOR2I> otherCorners;
|
|
|
|
VECTOR2I lastCorner( 0, 0 );
|
|
|
|
|
|
|
|
for( int ii = 0; ii < GetNumCorners(); ii++ )
|
|
|
|
{
|
|
|
|
corners.push_back( lastCorner - GetCornerPosition( ii ) );
|
|
|
|
lastCorner = GetCornerPosition( ii );
|
|
|
|
}
|
|
|
|
|
|
|
|
lastCorner = VECTOR2I( 0, 0 );
|
|
|
|
for( int ii = 0; ii < other.GetNumCorners(); ii++ )
|
|
|
|
{
|
|
|
|
otherCorners.push_back( lastCorner - other.GetCornerPosition( ii ) );
|
|
|
|
lastCorner = other.GetCornerPosition( ii );
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t longest = alg::longest_common_subset( corners, otherCorners );
|
|
|
|
|
|
|
|
similarity *= std::pow( 0.9, GetNumCorners() + other.GetNumCorners() - 2 * longest );
|
|
|
|
|
|
|
|
return similarity;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-11 23:05:59 +00:00
|
|
|
static struct ZONE_DESC
|
2020-02-02 18:40:14 +00:00
|
|
|
{
|
2020-11-11 23:05:59 +00:00
|
|
|
ZONE_DESC()
|
2020-02-02 18:40:14 +00:00
|
|
|
{
|
2023-02-02 08:11:27 +00:00
|
|
|
ENUM_MAP<PCB_LAYER_ID>& layerEnum = ENUM_MAP<PCB_LAYER_ID>::Instance();
|
|
|
|
|
|
|
|
if( layerEnum.Choices().GetCount() == 0 )
|
|
|
|
{
|
|
|
|
layerEnum.Undefined( UNDEFINED_LAYER );
|
|
|
|
|
|
|
|
for( LSEQ seq = LSET::AllLayersMask().Seq(); seq; ++seq )
|
|
|
|
layerEnum.Map( *seq, LSET::Name( *seq ) );
|
|
|
|
}
|
|
|
|
|
2022-11-25 23:44:02 +00:00
|
|
|
ENUM_MAP<ZONE_CONNECTION>& zcMap = ENUM_MAP<ZONE_CONNECTION>::Instance();
|
|
|
|
|
|
|
|
if( zcMap.Choices().GetCount() == 0 )
|
|
|
|
{
|
|
|
|
zcMap.Undefined( ZONE_CONNECTION::INHERITED );
|
2024-02-04 23:01:16 +00:00
|
|
|
zcMap.Map( ZONE_CONNECTION::INHERITED, _HKI( "Inherited" ) )
|
|
|
|
.Map( ZONE_CONNECTION::NONE, _HKI( "None" ) )
|
|
|
|
.Map( ZONE_CONNECTION::THERMAL, _HKI( "Thermal reliefs" ) )
|
|
|
|
.Map( ZONE_CONNECTION::FULL, _HKI( "Solid" ) )
|
2022-11-25 23:44:02 +00:00
|
|
|
.Map( ZONE_CONNECTION::THT_THERMAL, _HKI( "Thermal reliefs for PTH" ) );
|
|
|
|
}
|
2020-09-05 16:00:29 +00:00
|
|
|
|
2022-12-09 03:24:13 +00:00
|
|
|
ENUM_MAP<ZONE_FILL_MODE>& zfmMap = ENUM_MAP<ZONE_FILL_MODE>::Instance();
|
|
|
|
|
|
|
|
if( zfmMap.Choices().GetCount() == 0 )
|
|
|
|
{
|
|
|
|
zfmMap.Undefined( ZONE_FILL_MODE::POLYGONS );
|
2024-02-04 23:01:16 +00:00
|
|
|
zfmMap.Map( ZONE_FILL_MODE::POLYGONS, _HKI( "Solid fill" ) )
|
2022-12-09 03:24:13 +00:00
|
|
|
.Map( ZONE_FILL_MODE::HATCH_PATTERN, _HKI( "Hatch pattern" ) );
|
|
|
|
}
|
|
|
|
|
2024-02-04 23:01:16 +00:00
|
|
|
ENUM_MAP<ISLAND_REMOVAL_MODE>& irmMap = ENUM_MAP<ISLAND_REMOVAL_MODE>::Instance();
|
|
|
|
|
|
|
|
if( irmMap.Choices().GetCount() == 0 )
|
|
|
|
{
|
|
|
|
irmMap.Undefined( ISLAND_REMOVAL_MODE::ALWAYS );
|
|
|
|
irmMap.Map( ISLAND_REMOVAL_MODE::ALWAYS, _HKI( "Always" ) )
|
|
|
|
.Map( ISLAND_REMOVAL_MODE::NEVER, _HKI( "Never" ) )
|
|
|
|
.Map( ISLAND_REMOVAL_MODE::AREA, _HKI( "Below area limit" ) );
|
|
|
|
}
|
|
|
|
|
2020-02-02 18:40:14 +00:00
|
|
|
PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance();
|
2020-11-11 23:05:59 +00:00
|
|
|
REGISTER_TYPE( ZONE );
|
|
|
|
propMgr.InheritsAfter( TYPE_HASH( ZONE ), TYPE_HASH( BOARD_CONNECTED_ITEM ) );
|
2022-12-01 04:36:53 +00:00
|
|
|
|
|
|
|
// Mask layer and position properties; they aren't useful in current form
|
2023-06-27 14:16:29 +00:00
|
|
|
auto posX = new PROPERTY<ZONE, int>( _HKI( "Position X" ), NO_SETTER( ZONE, int ),
|
|
|
|
static_cast<int ( ZONE::* )() const>( &ZONE::GetX ),
|
2022-12-01 21:54:36 +00:00
|
|
|
PROPERTY_DISPLAY::PT_COORD,
|
|
|
|
ORIGIN_TRANSFORMS::ABS_X_COORD );
|
2023-03-26 23:43:16 +00:00
|
|
|
posX->SetIsHiddenFromPropertiesManager();
|
2022-12-01 04:36:53 +00:00
|
|
|
|
2022-12-01 21:54:36 +00:00
|
|
|
auto posY = new PROPERTY<ZONE, int>( _HKI( "Position Y" ), NO_SETTER( ZONE, int ),
|
2023-06-27 14:16:29 +00:00
|
|
|
static_cast<int ( ZONE::* )() const>( &ZONE::GetY ),
|
2022-12-01 21:54:36 +00:00
|
|
|
PROPERTY_DISPLAY::PT_COORD,
|
|
|
|
ORIGIN_TRANSFORMS::ABS_Y_COORD );
|
2023-03-26 23:43:16 +00:00
|
|
|
posY->SetIsHiddenFromPropertiesManager();
|
2022-12-01 04:36:53 +00:00
|
|
|
|
|
|
|
propMgr.ReplaceProperty( TYPE_HASH( BOARD_ITEM ), _HKI( "Position X" ), posX );
|
|
|
|
propMgr.ReplaceProperty( TYPE_HASH( BOARD_ITEM ), _HKI( "Position Y" ), posY );
|
2022-12-03 02:59:17 +00:00
|
|
|
|
|
|
|
auto isCopperZone =
|
|
|
|
[]( INSPECTABLE* aItem ) -> bool
|
|
|
|
{
|
|
|
|
if( ZONE* zone = dynamic_cast<ZONE*>( aItem ) )
|
|
|
|
return !zone->GetIsRuleArea() && IsCopperLayer( zone->GetFirstLayer() );
|
2022-12-03 03:38:15 +00:00
|
|
|
|
|
|
|
return false;
|
2022-12-03 02:59:17 +00:00
|
|
|
};
|
2022-12-09 03:24:13 +00:00
|
|
|
|
|
|
|
auto isHatchedFill =
|
|
|
|
[]( INSPECTABLE* aItem ) -> bool
|
|
|
|
{
|
|
|
|
if( ZONE* zone = dynamic_cast<ZONE*>( aItem ) )
|
|
|
|
return zone->GetFillMode() == ZONE_FILL_MODE::HATCH_PATTERN;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
};
|
2023-01-11 02:57:51 +00:00
|
|
|
|
2024-02-05 11:05:31 +00:00
|
|
|
auto isAreaBasedIslandRemoval =
|
2024-02-04 23:01:16 +00:00
|
|
|
[]( INSPECTABLE* aItem ) -> bool
|
|
|
|
{
|
|
|
|
if( ZONE* zone = dynamic_cast<ZONE*>( aItem ) )
|
|
|
|
return zone->GetIslandRemovalMode() == ISLAND_REMOVAL_MODE::AREA;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
|
2023-03-26 23:43:16 +00:00
|
|
|
// Layer property is hidden because it only holds a single layer and zones actually use
|
2023-02-10 04:38:51 +00:00
|
|
|
// a layer set
|
2023-02-10 01:45:23 +00:00
|
|
|
propMgr.ReplaceProperty( TYPE_HASH( BOARD_CONNECTED_ITEM ), _HKI( "Layer" ),
|
|
|
|
new PROPERTY_ENUM<ZONE, PCB_LAYER_ID>( _HKI( "Layer" ),
|
|
|
|
&ZONE::SetLayer,
|
|
|
|
&ZONE::GetLayer ) )
|
2023-03-26 23:43:16 +00:00
|
|
|
.SetIsHiddenFromPropertiesManager();
|
2022-12-01 04:36:53 +00:00
|
|
|
|
2022-12-08 05:09:39 +00:00
|
|
|
propMgr.OverrideAvailability( TYPE_HASH( ZONE ), TYPE_HASH( BOARD_CONNECTED_ITEM ),
|
|
|
|
_HKI( "Net" ), isCopperZone );
|
|
|
|
propMgr.OverrideAvailability( TYPE_HASH( ZONE ), TYPE_HASH( BOARD_CONNECTED_ITEM ),
|
|
|
|
_HKI( "Net Class" ), isCopperZone );
|
|
|
|
|
2023-02-10 01:45:23 +00:00
|
|
|
propMgr.AddProperty( new PROPERTY<ZONE, unsigned>( _HKI( "Priority" ),
|
2024-02-04 23:01:16 +00:00
|
|
|
&ZONE::SetAssignedPriority, &ZONE::GetAssignedPriority ) )
|
2023-02-10 01:45:23 +00:00
|
|
|
.SetAvailableFunc( isCopperZone );
|
2022-11-25 23:44:02 +00:00
|
|
|
|
2020-11-11 23:05:59 +00:00
|
|
|
propMgr.AddProperty( new PROPERTY<ZONE, wxString>( _HKI( "Name" ),
|
|
|
|
&ZONE::SetZoneName, &ZONE::GetZoneName ) );
|
2022-11-28 03:40:14 +00:00
|
|
|
|
2022-12-27 01:10:22 +00:00
|
|
|
const wxString groupFill = _HKI( "Fill Style" );
|
2022-12-09 03:24:13 +00:00
|
|
|
|
2023-02-10 04:38:51 +00:00
|
|
|
propMgr.AddProperty( new PROPERTY_ENUM<ZONE, ZONE_FILL_MODE>( _HKI( "Fill Mode" ),
|
2024-02-04 23:01:16 +00:00
|
|
|
&ZONE::SetFillMode, &ZONE::GetFillMode ),
|
|
|
|
groupFill )
|
|
|
|
.SetAvailableFunc( isCopperZone );
|
2023-02-10 01:45:23 +00:00
|
|
|
|
2023-02-10 04:38:51 +00:00
|
|
|
propMgr.AddProperty( new PROPERTY<ZONE, EDA_ANGLE>( _HKI( "Orientation" ),
|
2024-02-04 23:01:16 +00:00
|
|
|
&ZONE::SetHatchOrientation, &ZONE::GetHatchOrientation,
|
|
|
|
PROPERTY_DISPLAY::PT_DEGREE ),
|
|
|
|
groupFill )
|
|
|
|
.SetAvailableFunc( isCopperZone )
|
2023-02-10 04:38:51 +00:00
|
|
|
.SetWriteableFunc( isHatchedFill );
|
|
|
|
|
|
|
|
auto atLeastMinWidthValidator =
|
|
|
|
[]( const wxAny&& aValue, EDA_ITEM* aZone ) -> VALIDATOR_RESULT
|
|
|
|
{
|
|
|
|
int val = aValue.As<int>();
|
|
|
|
ZONE* zone = dynamic_cast<ZONE*>( aZone );
|
|
|
|
wxCHECK( zone, std::nullopt );
|
2022-12-09 03:24:13 +00:00
|
|
|
|
2023-02-10 04:38:51 +00:00
|
|
|
if( val < zone->GetMinThickness() )
|
|
|
|
{
|
|
|
|
return std::make_unique<VALIDATION_ERROR_MSG>(
|
2024-02-05 11:05:31 +00:00
|
|
|
_( "Cannot be less than zone minimum width" ) );
|
2023-02-10 04:38:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return std::nullopt;
|
|
|
|
};
|
|
|
|
|
2024-02-05 11:05:31 +00:00
|
|
|
propMgr.AddProperty( new PROPERTY<ZONE, int>( _HKI( "Hatch Width" ),
|
2024-02-04 23:01:16 +00:00
|
|
|
&ZONE::SetHatchThickness, &ZONE::GetHatchThickness, PROPERTY_DISPLAY::PT_SIZE ),
|
|
|
|
groupFill )
|
|
|
|
.SetAvailableFunc( isCopperZone )
|
2023-02-10 01:45:23 +00:00
|
|
|
.SetWriteableFunc( isHatchedFill )
|
2023-02-10 04:38:51 +00:00
|
|
|
.SetValidator( atLeastMinWidthValidator );
|
2022-12-09 03:24:13 +00:00
|
|
|
|
2024-02-05 11:05:31 +00:00
|
|
|
propMgr.AddProperty( new PROPERTY<ZONE, int>( _HKI( "Hatch Gap" ),
|
2024-02-04 23:01:16 +00:00
|
|
|
&ZONE::SetHatchGap, &ZONE::GetHatchGap, PROPERTY_DISPLAY::PT_SIZE ),
|
|
|
|
groupFill )
|
|
|
|
.SetAvailableFunc( isCopperZone )
|
2023-02-10 01:45:23 +00:00
|
|
|
.SetWriteableFunc( isHatchedFill )
|
2023-02-10 04:38:51 +00:00
|
|
|
.SetValidator( atLeastMinWidthValidator );
|
2022-12-09 03:24:13 +00:00
|
|
|
|
2024-02-05 11:05:31 +00:00
|
|
|
propMgr.AddProperty( new PROPERTY<ZONE, double>( _HKI( "Hatch Minimum Hole Ratio" ),
|
2024-02-04 23:01:16 +00:00
|
|
|
&ZONE::SetHatchHoleMinArea, &ZONE::GetHatchHoleMinArea ),
|
|
|
|
groupFill )
|
|
|
|
.SetAvailableFunc( isCopperZone )
|
|
|
|
.SetWriteableFunc( isHatchedFill )
|
|
|
|
.SetValidator( PROPERTY_VALIDATORS::PositiveRatioValidator );
|
|
|
|
|
2022-12-09 03:24:13 +00:00
|
|
|
// TODO: Smoothing effort needs to change to enum (in dialog too)
|
2024-02-05 11:05:31 +00:00
|
|
|
propMgr.AddProperty( new PROPERTY<ZONE, int>( _HKI( "Smoothing Effort" ),
|
2024-02-04 23:01:16 +00:00
|
|
|
&ZONE::SetHatchSmoothingLevel, &ZONE::GetHatchSmoothingLevel ),
|
|
|
|
groupFill )
|
|
|
|
.SetAvailableFunc( isCopperZone )
|
|
|
|
.SetWriteableFunc( isHatchedFill );
|
|
|
|
|
2024-02-05 11:05:31 +00:00
|
|
|
propMgr.AddProperty( new PROPERTY<ZONE, double>( _HKI( "Smoothing Amount" ),
|
2024-02-04 23:01:16 +00:00
|
|
|
&ZONE::SetHatchSmoothingValue, &ZONE::GetHatchSmoothingValue ),
|
|
|
|
groupFill )
|
|
|
|
.SetAvailableFunc( isCopperZone )
|
|
|
|
.SetWriteableFunc( isHatchedFill );
|
|
|
|
|
2024-02-05 11:05:31 +00:00
|
|
|
propMgr.AddProperty( new PROPERTY_ENUM<ZONE, ISLAND_REMOVAL_MODE>( _HKI( "Remove Islands" ),
|
2024-02-04 23:01:16 +00:00
|
|
|
&ZONE::SetIslandRemovalMode, &ZONE::GetIslandRemovalMode ),
|
|
|
|
groupFill )
|
|
|
|
.SetAvailableFunc( isCopperZone );
|
|
|
|
|
2024-02-05 11:05:31 +00:00
|
|
|
propMgr.AddProperty( new PROPERTY<ZONE, long long int>( _HKI( "Minimum Island Area" ),
|
2024-02-04 23:01:16 +00:00
|
|
|
&ZONE::SetMinIslandArea, &ZONE::GetMinIslandArea, PROPERTY_DISPLAY::PT_AREA ),
|
|
|
|
groupFill )
|
|
|
|
.SetAvailableFunc( isCopperZone )
|
2024-02-05 11:05:31 +00:00
|
|
|
.SetWriteableFunc( isAreaBasedIslandRemoval );
|
2022-12-09 03:24:13 +00:00
|
|
|
|
2024-02-04 23:01:16 +00:00
|
|
|
const wxString groupElectrical = _HKI( "Electrical" );
|
2022-11-28 03:40:14 +00:00
|
|
|
|
2024-01-10 11:28:29 +00:00
|
|
|
auto clearanceOverride = new PROPERTY<ZONE, std::optional<int>>( _HKI( "Clearance" ),
|
2020-11-11 23:05:59 +00:00
|
|
|
&ZONE::SetLocalClearance, &ZONE::GetLocalClearance,
|
2022-12-03 02:59:17 +00:00
|
|
|
PROPERTY_DISPLAY::PT_SIZE );
|
|
|
|
clearanceOverride->SetAvailableFunc( isCopperZone );
|
2023-02-10 04:38:51 +00:00
|
|
|
constexpr int maxClearance = pcbIUScale.mmToIU( ZONE_CLEARANCE_MAX_VALUE_MM );
|
|
|
|
clearanceOverride->SetValidator( PROPERTY_VALIDATORS::RangeIntValidator<0, maxClearance> );
|
2023-01-11 02:57:51 +00:00
|
|
|
|
2022-12-03 02:59:17 +00:00
|
|
|
auto minWidth = new PROPERTY<ZONE, int>( _HKI( "Minimum Width" ),
|
2020-11-11 23:05:59 +00:00
|
|
|
&ZONE::SetMinThickness, &ZONE::GetMinThickness,
|
2022-12-03 02:59:17 +00:00
|
|
|
PROPERTY_DISPLAY::PT_SIZE );
|
|
|
|
minWidth->SetAvailableFunc( isCopperZone );
|
2023-02-10 04:38:51 +00:00
|
|
|
constexpr int minMinWidth = pcbIUScale.mmToIU( ZONE_THICKNESS_MIN_VALUE_MM );
|
|
|
|
clearanceOverride->SetValidator( PROPERTY_VALIDATORS::RangeIntValidator<minMinWidth,
|
|
|
|
INT_MAX> );
|
2023-01-11 02:57:51 +00:00
|
|
|
|
2022-12-03 02:59:17 +00:00
|
|
|
auto padConnections = new PROPERTY_ENUM<ZONE, ZONE_CONNECTION>( _HKI( "Pad Connections" ),
|
|
|
|
&ZONE::SetPadConnection, &ZONE::GetPadConnection );
|
|
|
|
padConnections->SetAvailableFunc( isCopperZone );
|
|
|
|
|
|
|
|
auto thermalGap = new PROPERTY<ZONE, int>( _HKI( "Thermal Relief Gap" ),
|
2020-11-11 23:05:59 +00:00
|
|
|
&ZONE::SetThermalReliefGap, &ZONE::GetThermalReliefGap,
|
2022-12-03 02:59:17 +00:00
|
|
|
PROPERTY_DISPLAY::PT_SIZE );
|
|
|
|
thermalGap->SetAvailableFunc( isCopperZone );
|
2023-02-10 04:38:51 +00:00
|
|
|
thermalGap->SetValidator( PROPERTY_VALIDATORS::PositiveIntValidator );
|
2022-12-03 02:59:17 +00:00
|
|
|
|
|
|
|
auto thermalSpokeWidth = new PROPERTY<ZONE, int>( _HKI( "Thermal Relief Spoke Width" ),
|
2020-11-11 23:05:59 +00:00
|
|
|
&ZONE::SetThermalReliefSpokeWidth, &ZONE::GetThermalReliefSpokeWidth,
|
2022-12-03 02:59:17 +00:00
|
|
|
PROPERTY_DISPLAY::PT_SIZE );
|
|
|
|
thermalSpokeWidth->SetAvailableFunc( isCopperZone );
|
2023-02-10 04:38:51 +00:00
|
|
|
thermalSpokeWidth->SetValidator( atLeastMinWidthValidator );
|
2022-12-03 02:59:17 +00:00
|
|
|
|
2024-02-04 23:01:16 +00:00
|
|
|
propMgr.AddProperty( clearanceOverride, groupElectrical );
|
|
|
|
propMgr.AddProperty( minWidth, groupElectrical );
|
|
|
|
propMgr.AddProperty( padConnections, groupElectrical );
|
|
|
|
propMgr.AddProperty( thermalGap, groupElectrical );
|
|
|
|
propMgr.AddProperty( thermalSpokeWidth, groupElectrical );
|
2020-02-02 18:40:14 +00:00
|
|
|
}
|
2020-11-11 23:05:59 +00:00
|
|
|
} _ZONE_DESC;
|
2020-09-05 16:00:29 +00:00
|
|
|
|
2022-11-25 23:44:02 +00:00
|
|
|
IMPLEMENT_ENUM_TO_WXANY( ZONE_CONNECTION )
|
2022-12-09 03:24:13 +00:00
|
|
|
IMPLEMENT_ENUM_TO_WXANY( ZONE_FILL_MODE )
|
2024-02-04 23:01:16 +00:00
|
|
|
IMPLEMENT_ENUM_TO_WXANY( ISLAND_REMOVAL_MODE )
|