2011-10-13 19:56:32 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2017-03-20 12:05:38 +00:00
|
|
|
* Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2015-02-18 09:13:17 +00:00
|
|
|
* Copyright (C) 2015 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
2018-03-07 19:18:45 +00:00
|
|
|
* Copyright (C) 2015 Wayne Stambaugh <stambaughw@gmail.com>
|
2023-01-17 16:54:08 +00:00
|
|
|
* Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-10-13 19:56: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-18 01:21:04 +00:00
|
|
|
#include <core/mirror.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <confirm.h>
|
2019-01-29 10:50:50 +00:00
|
|
|
#include <refdes_utils.h>
|
2017-02-20 12:20:39 +00:00
|
|
|
#include <bitmaps.h>
|
2020-06-27 21:27:49 +00:00
|
|
|
#include <unordered_set>
|
2021-07-29 09:56:22 +00:00
|
|
|
#include <string_utils.h>
|
2018-01-29 20:58:58 +00:00
|
|
|
#include <pcb_edit_frame.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>
|
2021-03-20 15:35:37 +00:00
|
|
|
#include <macros.h>
|
2021-06-06 19:03:10 +00:00
|
|
|
#include <pad.h>
|
2020-11-29 14:00:39 +00:00
|
|
|
#include <pcb_marker.h>
|
2020-12-01 14:03:34 +00:00
|
|
|
#include <pcb_group.h>
|
2021-06-11 21:07:02 +00:00
|
|
|
#include <pcb_track.h>
|
2021-12-04 23:52:00 +00:00
|
|
|
#include <pcb_dimension.h>
|
2023-10-23 17:23:24 +00:00
|
|
|
#include <pcb_reference_image.h>
|
2023-03-30 11:49:23 +00:00
|
|
|
#include <pcb_textbox.h>
|
2023-05-24 12:39:25 +00:00
|
|
|
#include <pcb_field.h>
|
2020-11-12 20:19:22 +00:00
|
|
|
#include <footprint.h>
|
2021-06-03 18:05:43 +00:00
|
|
|
#include <zone.h>
|
2016-12-02 17:58:12 +00:00
|
|
|
#include <view/view.h>
|
2020-10-16 15:51:24 +00:00
|
|
|
#include <i18n_utility.h>
|
2022-03-18 19:35:40 +00:00
|
|
|
#include <drc/drc_item.h>
|
|
|
|
#include <geometry/shape_segment.h>
|
2022-05-10 22:01:25 +00:00
|
|
|
#include <geometry/shape_simple.h>
|
2021-07-14 20:03:32 +00:00
|
|
|
#include <convert_shape_list_to_polygon.h>
|
2020-11-29 14:00:39 +00:00
|
|
|
#include <geometry/convex_hull.h>
|
2022-03-18 19:35:40 +00:00
|
|
|
#include "convert_basic_shapes_to_polygon.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
FOOTPRINT::FOOTPRINT( BOARD* parent ) :
|
2020-11-13 12:21:02 +00:00
|
|
|
BOARD_ITEM_CONTAINER((BOARD_ITEM*) parent, PCB_FOOTPRINT_T ),
|
2021-02-26 13:49:40 +00:00
|
|
|
m_boundingBoxCacheTimeStamp( 0 ),
|
|
|
|
m_visibleBBoxCacheTimeStamp( 0 ),
|
|
|
|
m_textExcludedBBoxCacheTimeStamp( 0 ),
|
|
|
|
m_hullCacheTimeStamp( 0 ),
|
2022-07-31 21:14:24 +00:00
|
|
|
m_initial_comments( nullptr ),
|
|
|
|
m_courtyard_cache_timestamp( 0 )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2020-11-13 02:57:11 +00:00
|
|
|
m_attributes = 0;
|
2020-11-14 14:29:11 +00:00
|
|
|
m_layer = F_Cu;
|
2022-01-13 17:27:36 +00:00
|
|
|
m_orient = ANGLE_0;
|
2020-11-13 11:17:15 +00:00
|
|
|
m_fpStatus = FP_PADS_are_LOCKED;
|
2020-11-13 02:57:11 +00:00
|
|
|
m_arflag = 0;
|
|
|
|
m_link = 0;
|
|
|
|
m_lastEditTime = 0;
|
|
|
|
m_localClearance = 0;
|
|
|
|
m_localSolderMaskMargin = 0;
|
|
|
|
m_localSolderPasteMargin = 0;
|
|
|
|
m_localSolderPasteMarginRatio = 0.0;
|
2021-08-08 13:37:14 +00:00
|
|
|
m_zoneConnection = ZONE_CONNECTION::INHERITED;
|
2022-11-28 02:27:34 +00:00
|
|
|
m_fileFormatVersionAtLoad = 0;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2023-05-24 12:39:25 +00:00
|
|
|
// These are the mandatory fields for the editor to work
|
|
|
|
for( int i = 0; i < MANDATORY_FIELDS; i++ )
|
|
|
|
{
|
2023-06-20 14:31:13 +00:00
|
|
|
PCB_FIELD* field = new PCB_FIELD( this, i );
|
|
|
|
m_fields.push_back( field );
|
2023-05-24 12:39:25 +00:00
|
|
|
|
|
|
|
switch( i )
|
|
|
|
{
|
|
|
|
case REFERENCE_FIELD:
|
|
|
|
field->SetLayer( F_SilkS );
|
|
|
|
field->SetVisible( true );
|
|
|
|
break;
|
|
|
|
case VALUE_FIELD:
|
|
|
|
field->SetLayer( F_Fab );
|
|
|
|
field->SetVisible( true );
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
field->SetLayer( F_Fab );
|
|
|
|
field->SetVisible( false );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
m_3D_Drawings.clear();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
FOOTPRINT::FOOTPRINT( const FOOTPRINT& aFootprint ) :
|
2020-10-14 23:37:26 +00:00
|
|
|
BOARD_ITEM_CONTAINER( aFootprint )
|
2012-01-14 19:50:32 +00:00
|
|
|
{
|
2020-11-13 02:57:11 +00:00
|
|
|
m_pos = aFootprint.m_pos;
|
|
|
|
m_fpid = aFootprint.m_fpid;
|
|
|
|
m_attributes = aFootprint.m_attributes;
|
2020-11-13 11:17:15 +00:00
|
|
|
m_fpStatus = aFootprint.m_fpStatus;
|
2020-11-13 02:57:11 +00:00
|
|
|
m_orient = aFootprint.m_orient;
|
|
|
|
m_lastEditTime = aFootprint.m_lastEditTime;
|
|
|
|
m_link = aFootprint.m_link;
|
|
|
|
m_path = aFootprint.m_path;
|
|
|
|
|
2021-02-26 13:49:40 +00:00
|
|
|
m_cachedBoundingBox = aFootprint.m_cachedBoundingBox;
|
|
|
|
m_boundingBoxCacheTimeStamp = aFootprint.m_boundingBoxCacheTimeStamp;
|
|
|
|
m_cachedVisibleBBox = aFootprint.m_cachedVisibleBBox;
|
|
|
|
m_visibleBBoxCacheTimeStamp = aFootprint.m_visibleBBoxCacheTimeStamp;
|
|
|
|
m_cachedTextExcludedBBox = aFootprint.m_cachedTextExcludedBBox;
|
|
|
|
m_textExcludedBBoxCacheTimeStamp = aFootprint.m_textExcludedBBoxCacheTimeStamp;
|
|
|
|
m_cachedHull = aFootprint.m_cachedHull;
|
|
|
|
m_hullCacheTimeStamp = aFootprint.m_hullCacheTimeStamp;
|
|
|
|
|
|
|
|
m_localClearance = aFootprint.m_localClearance;
|
|
|
|
m_localSolderMaskMargin = aFootprint.m_localSolderMaskMargin;
|
|
|
|
m_localSolderPasteMargin = aFootprint.m_localSolderPasteMargin;
|
|
|
|
m_localSolderPasteMarginRatio = aFootprint.m_localSolderPasteMarginRatio;
|
|
|
|
m_zoneConnection = aFootprint.m_zoneConnection;
|
2022-08-19 17:34:53 +00:00
|
|
|
m_netTiePadGroups = aFootprint.m_netTiePadGroups;
|
2022-11-28 02:27:34 +00:00
|
|
|
m_fileFormatVersionAtLoad = aFootprint.m_fileFormatVersionAtLoad;
|
2012-01-14 19:50:32 +00:00
|
|
|
|
2020-12-08 23:43:39 +00:00
|
|
|
std::map<BOARD_ITEM*, BOARD_ITEM*> ptrMap;
|
|
|
|
|
2023-05-24 12:39:25 +00:00
|
|
|
// Copy fields
|
|
|
|
for( PCB_FIELD* field : aFootprint.Fields() )
|
|
|
|
{
|
|
|
|
PCB_FIELD* newField = static_cast<PCB_FIELD*>( field->Clone() );
|
|
|
|
ptrMap[field] = newField;
|
|
|
|
Add( newField, ADD_MODE::APPEND ); // Append to ensure indexes are identical
|
|
|
|
}
|
2020-10-03 11:16:29 +00:00
|
|
|
|
|
|
|
// Copy pads
|
2020-11-12 22:30:02 +00:00
|
|
|
for( PAD* pad : aFootprint.Pads() )
|
2020-10-03 11:16:29 +00:00
|
|
|
{
|
2020-11-12 22:30:02 +00:00
|
|
|
PAD* newPad = static_cast<PAD*>( pad->Clone() );
|
2020-10-03 11:16:29 +00:00
|
|
|
ptrMap[ pad ] = newPad;
|
2021-04-10 18:11:28 +00:00
|
|
|
Add( newPad, ADD_MODE::APPEND ); // Append to ensure indexes are identical
|
2020-10-03 11:16:29 +00:00
|
|
|
}
|
2012-01-14 19:50:32 +00:00
|
|
|
|
2020-10-03 11:16:29 +00:00
|
|
|
// Copy zones
|
2023-03-30 11:49:23 +00:00
|
|
|
for( ZONE* zone : aFootprint.Zones() )
|
2019-10-29 10:09:54 +00:00
|
|
|
{
|
2023-03-30 11:49:23 +00:00
|
|
|
ZONE* newZone = static_cast<ZONE*>( zone->Clone() );
|
2020-10-03 11:16:29 +00:00
|
|
|
ptrMap[ zone ] = newZone;
|
2021-04-10 18:11:28 +00:00
|
|
|
Add( newZone, ADD_MODE::APPEND ); // Append to ensure indexes are identical
|
2019-10-29 10:09:54 +00:00
|
|
|
|
|
|
|
// Ensure the net info is OK and especially uses the net info list
|
|
|
|
// living in the current board
|
|
|
|
// Needed when copying a fp from fp editor that has its own board
|
|
|
|
// Must be NETINFO_LIST::ORPHANED_ITEM for a keepout that has no net.
|
2020-10-03 11:16:29 +00:00
|
|
|
newZone->SetNetCode( -1 );
|
2019-10-29 10:09:54 +00:00
|
|
|
}
|
|
|
|
|
2020-10-03 11:16:29 +00:00
|
|
|
// Copy drawings
|
2020-10-14 23:37:26 +00:00
|
|
|
for( BOARD_ITEM* item : aFootprint.GraphicalItems() )
|
2012-01-14 19:50:32 +00:00
|
|
|
{
|
2020-10-03 11:16:29 +00:00
|
|
|
BOARD_ITEM* newItem = static_cast<BOARD_ITEM*>( item->Clone() );
|
|
|
|
ptrMap[ item ] = newItem;
|
2021-04-10 18:11:28 +00:00
|
|
|
Add( newItem, ADD_MODE::APPEND ); // Append to ensure indexes are identical
|
2020-10-03 11:16:29 +00:00
|
|
|
}
|
2012-01-14 19:50:32 +00:00
|
|
|
|
2020-10-03 11:16:29 +00:00
|
|
|
// Copy groups
|
2020-10-14 23:37:26 +00:00
|
|
|
for( PCB_GROUP* group : aFootprint.Groups() )
|
2020-10-03 11:16:29 +00:00
|
|
|
{
|
|
|
|
PCB_GROUP* newGroup = static_cast<PCB_GROUP*>( group->Clone() );
|
2020-10-13 16:54:01 +00:00
|
|
|
ptrMap[ group ] = newGroup;
|
2021-04-10 18:11:28 +00:00
|
|
|
Add( newGroup, ADD_MODE::APPEND ); // Append to ensure indexes are identical
|
2020-10-13 16:54:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Rebuild groups
|
2020-10-14 23:37:26 +00:00
|
|
|
for( PCB_GROUP* group : aFootprint.Groups() )
|
2020-10-13 16:54:01 +00:00
|
|
|
{
|
|
|
|
PCB_GROUP* newGroup = static_cast<PCB_GROUP*>( ptrMap[ group ] );
|
|
|
|
|
2020-12-20 18:59:07 +00:00
|
|
|
newGroup->GetItems().clear();
|
2020-10-03 11:16:29 +00:00
|
|
|
|
|
|
|
for( BOARD_ITEM* member : group->GetItems() )
|
2021-08-12 20:34:48 +00:00
|
|
|
{
|
|
|
|
if( ptrMap.count( member ) )
|
|
|
|
newGroup->AddItem( ptrMap[ member ] );
|
|
|
|
}
|
2012-01-14 19:50:32 +00:00
|
|
|
}
|
|
|
|
|
2021-12-05 21:56:55 +00:00
|
|
|
// Copy auxiliary data
|
|
|
|
m_3D_Drawings = aFootprint.m_3D_Drawings;
|
2023-06-19 17:08:18 +00:00
|
|
|
m_libDescription = aFootprint.m_libDescription;
|
2021-12-05 21:56:55 +00:00
|
|
|
m_keywords = aFootprint.m_keywords;
|
|
|
|
m_privateLayers = aFootprint.m_privateLayers;
|
2012-01-14 19:50:32 +00:00
|
|
|
|
2021-12-05 21:56:55 +00:00
|
|
|
m_arflag = 0;
|
2015-03-23 08:28:12 +00:00
|
|
|
|
2020-10-14 23:37:26 +00:00
|
|
|
m_initial_comments = aFootprint.m_initial_comments ?
|
|
|
|
new wxArrayString( *aFootprint.m_initial_comments ) : nullptr;
|
2012-01-14 19:50:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
FOOTPRINT::FOOTPRINT( FOOTPRINT&& aFootprint ) :
|
2020-10-14 23:37:26 +00:00
|
|
|
BOARD_ITEM_CONTAINER( aFootprint )
|
2020-07-16 01:11:51 +00:00
|
|
|
{
|
2020-10-14 23:37:26 +00:00
|
|
|
*this = std::move( aFootprint );
|
2020-07-16 01:11:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
FOOTPRINT::~FOOTPRINT()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2022-11-11 17:09:25 +00:00
|
|
|
// Untangle group parents before doing any deleting
|
2023-03-30 11:49:23 +00:00
|
|
|
for( PCB_GROUP* group : m_groups )
|
2022-11-11 17:09:25 +00:00
|
|
|
{
|
|
|
|
for( BOARD_ITEM* item : group->GetItems() )
|
|
|
|
item->SetParentGroup( nullptr );
|
|
|
|
}
|
|
|
|
|
2019-08-11 20:30:33 +00:00
|
|
|
// Clean up the owned elements
|
2013-06-23 19:18:33 +00:00
|
|
|
delete m_initial_comments;
|
2019-08-11 20:30:33 +00:00
|
|
|
|
2023-05-24 12:39:25 +00:00
|
|
|
for( PCB_FIELD* f : m_fields )
|
|
|
|
delete f;
|
|
|
|
|
|
|
|
m_fields.clear();
|
|
|
|
|
2020-11-12 22:30:02 +00:00
|
|
|
for( PAD* p : m_pads )
|
2019-08-11 20:30:33 +00:00
|
|
|
delete p;
|
|
|
|
|
|
|
|
m_pads.clear();
|
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
for( ZONE* zone : m_zones )
|
2020-10-03 11:16:29 +00:00
|
|
|
delete zone;
|
2019-10-29 10:09:54 +00:00
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
m_zones.clear();
|
2019-10-29 10:09:54 +00:00
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
for( PCB_GROUP* group : m_groups )
|
2020-10-03 11:16:29 +00:00
|
|
|
delete group;
|
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
m_groups.clear();
|
2020-10-03 11:16:29 +00:00
|
|
|
|
2020-06-27 18:01:00 +00:00
|
|
|
for( BOARD_ITEM* d : m_drawings )
|
2019-08-11 20:30:33 +00:00
|
|
|
delete d;
|
|
|
|
|
|
|
|
m_drawings.clear();
|
2023-01-11 02:57:51 +00:00
|
|
|
|
|
|
|
if( BOARD* board = GetBoard() )
|
|
|
|
board->IncrementTimeStamp();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2016-05-31 08:27:52 +00:00
|
|
|
|
2023-05-24 12:39:25 +00:00
|
|
|
PCB_FIELD* FOOTPRINT::GetField( MANDATORY_FIELD_T aFieldType )
|
|
|
|
{
|
|
|
|
return m_fields[aFieldType];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const PCB_FIELD* FOOTPRINT::GetField( MANDATORY_FIELD_T aFieldType ) const
|
|
|
|
{
|
|
|
|
return m_fields[aFieldType];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PCB_FIELD* FOOTPRINT::GetFieldById( int aFieldId )
|
|
|
|
{
|
2023-06-06 17:30:03 +00:00
|
|
|
for( PCB_FIELD* field : m_fields )
|
2023-05-24 12:39:25 +00:00
|
|
|
{
|
2023-06-06 17:30:03 +00:00
|
|
|
if( field->GetId() == aFieldId )
|
|
|
|
return field;
|
2023-05-24 12:39:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool FOOTPRINT::HasFieldByName( const wxString& aFieldName ) const
|
|
|
|
{
|
2023-06-06 17:30:03 +00:00
|
|
|
for( PCB_FIELD* field : m_fields )
|
2023-05-24 12:39:25 +00:00
|
|
|
{
|
2023-06-06 17:30:03 +00:00
|
|
|
if( field->GetCanonicalName() == aFieldName )
|
2023-05-24 12:39:25 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
PCB_FIELD* FOOTPRINT::GetFieldByName( const wxString& aFieldName )
|
|
|
|
{
|
2023-06-12 18:12:39 +00:00
|
|
|
if( aFieldName.empty() )
|
|
|
|
return nullptr;
|
|
|
|
|
2023-06-06 17:30:03 +00:00
|
|
|
for( PCB_FIELD* field : m_fields )
|
2023-05-24 12:39:25 +00:00
|
|
|
{
|
2023-06-06 17:30:03 +00:00
|
|
|
if( field->GetName() == aFieldName )
|
|
|
|
return field;
|
2023-05-24 12:39:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxString FOOTPRINT::GetFieldText( const wxString& aFieldName ) const
|
|
|
|
{
|
|
|
|
for( const PCB_FIELD* field : m_fields )
|
|
|
|
{
|
|
|
|
if( aFieldName == field->GetName() || aFieldName == field->GetCanonicalName() )
|
|
|
|
return field->GetText();
|
|
|
|
}
|
|
|
|
|
|
|
|
return wxEmptyString;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT::GetFields( std::vector<PCB_FIELD*>& aVector, bool aVisibleOnly )
|
|
|
|
{
|
|
|
|
for( PCB_FIELD* field : m_fields )
|
|
|
|
{
|
|
|
|
if( aVisibleOnly )
|
|
|
|
{
|
|
|
|
if( !field->IsVisible() || field->GetText().IsEmpty() )
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
aVector.push_back( field );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-06-20 14:31:13 +00:00
|
|
|
PCB_FIELD* FOOTPRINT::AddField( const PCB_FIELD& aField )
|
2023-05-24 12:39:25 +00:00
|
|
|
{
|
|
|
|
int newNdx = m_fields.size();
|
|
|
|
|
2023-06-20 14:31:13 +00:00
|
|
|
m_fields.push_back( new PCB_FIELD( aField ) );
|
2023-05-24 12:39:25 +00:00
|
|
|
return m_fields[newNdx];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT::RemoveField( const wxString& aFieldName )
|
|
|
|
{
|
|
|
|
for( unsigned i = MANDATORY_FIELDS; i < m_fields.size(); ++i )
|
|
|
|
{
|
|
|
|
if( aFieldName == m_fields[i]->GetName( false ) )
|
|
|
|
{
|
|
|
|
m_fields.erase( m_fields.begin() + i );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-10-02 21:10:13 +00:00
|
|
|
void FOOTPRINT::ApplyDefaultSettings( const BOARD& board, bool aStyleFields, bool aStyleText,
|
|
|
|
bool aStyleShapes )
|
2023-05-24 12:39:25 +00:00
|
|
|
{
|
2023-07-10 16:15:37 +00:00
|
|
|
if( aStyleFields )
|
|
|
|
{
|
|
|
|
for( PCB_FIELD* field : m_fields )
|
|
|
|
field->StyleFromSettings( board.GetDesignSettings() );
|
|
|
|
}
|
2023-07-09 11:19:43 +00:00
|
|
|
|
2023-10-02 21:10:13 +00:00
|
|
|
for( BOARD_ITEM* item : m_drawings )
|
2023-07-10 16:15:37 +00:00
|
|
|
{
|
2023-10-02 21:10:13 +00:00
|
|
|
switch( item->Type() )
|
|
|
|
{
|
|
|
|
case PCB_TEXT_T:
|
|
|
|
case PCB_TEXTBOX_T:
|
|
|
|
if( aStyleText )
|
|
|
|
item->StyleFromSettings( board.GetDesignSettings() );
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PCB_SHAPE_T:
|
|
|
|
if( aStyleShapes && !item->IsOnCopperLayer() )
|
|
|
|
item->StyleFromSettings( board.GetDesignSettings() );
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2023-07-10 16:15:37 +00:00
|
|
|
}
|
2023-05-24 12:39:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-08-04 10:37:52 +00:00
|
|
|
bool FOOTPRINT::FixUuids()
|
|
|
|
{
|
|
|
|
// replace null UUIDs if any by a valid uuid
|
|
|
|
std::vector< BOARD_ITEM* > item_list;
|
|
|
|
|
2023-05-24 12:39:25 +00:00
|
|
|
for( PCB_FIELD* field : m_fields )
|
|
|
|
item_list.push_back( field );
|
2021-08-04 10:37:52 +00:00
|
|
|
|
|
|
|
for( PAD* pad : m_pads )
|
|
|
|
item_list.push_back( pad );
|
|
|
|
|
|
|
|
for( BOARD_ITEM* gr_item : m_drawings )
|
|
|
|
item_list.push_back( gr_item );
|
|
|
|
|
|
|
|
// Note: one cannot fix null UUIDs inside the group, but it should not happen
|
|
|
|
// because null uuids can be found in old footprints, therefore without group
|
2023-03-30 11:49:23 +00:00
|
|
|
for( PCB_GROUP* group : m_groups )
|
2021-08-04 10:37:52 +00:00
|
|
|
item_list.push_back( group );
|
|
|
|
|
|
|
|
// Probably notneeded, because old fp do not have zones. But just in case.
|
2023-03-30 11:49:23 +00:00
|
|
|
for( ZONE* zone : m_zones )
|
2021-08-04 10:37:52 +00:00
|
|
|
item_list.push_back( zone );
|
|
|
|
|
|
|
|
bool changed = false;
|
|
|
|
|
|
|
|
for( BOARD_ITEM* item : item_list )
|
|
|
|
{
|
|
|
|
if( item->m_Uuid == niluuid )
|
|
|
|
{
|
|
|
|
const_cast<KIID&>( item->m_Uuid ) = KIID();
|
|
|
|
changed = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return changed;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
FOOTPRINT& FOOTPRINT::operator=( FOOTPRINT&& aOther )
|
2020-07-16 01:11:51 +00:00
|
|
|
{
|
|
|
|
BOARD_ITEM::operator=( aOther );
|
|
|
|
|
2020-11-13 02:57:11 +00:00
|
|
|
m_pos = aOther.m_pos;
|
2020-07-16 01:11:51 +00:00
|
|
|
m_fpid = aOther.m_fpid;
|
2020-11-13 02:57:11 +00:00
|
|
|
m_attributes = aOther.m_attributes;
|
2020-11-13 11:17:15 +00:00
|
|
|
m_fpStatus = aOther.m_fpStatus;
|
2020-11-13 02:57:11 +00:00
|
|
|
m_orient = aOther.m_orient;
|
|
|
|
m_lastEditTime = aOther.m_lastEditTime;
|
|
|
|
m_link = aOther.m_link;
|
|
|
|
m_path = aOther.m_path;
|
|
|
|
|
2021-02-26 13:49:40 +00:00
|
|
|
m_cachedBoundingBox = aOther.m_cachedBoundingBox;
|
|
|
|
m_boundingBoxCacheTimeStamp = aOther.m_boundingBoxCacheTimeStamp;
|
|
|
|
m_cachedVisibleBBox = aOther.m_cachedVisibleBBox;
|
|
|
|
m_visibleBBoxCacheTimeStamp = aOther.m_visibleBBoxCacheTimeStamp;
|
|
|
|
m_cachedTextExcludedBBox = aOther.m_cachedTextExcludedBBox;
|
|
|
|
m_textExcludedBBoxCacheTimeStamp = aOther.m_textExcludedBBoxCacheTimeStamp;
|
|
|
|
m_cachedHull = aOther.m_cachedHull;
|
|
|
|
m_hullCacheTimeStamp = aOther.m_hullCacheTimeStamp;
|
|
|
|
|
|
|
|
m_localClearance = aOther.m_localClearance;
|
|
|
|
m_localSolderMaskMargin = aOther.m_localSolderMaskMargin;
|
|
|
|
m_localSolderPasteMargin = aOther.m_localSolderPasteMargin;
|
|
|
|
m_localSolderPasteMarginRatio = aOther.m_localSolderPasteMarginRatio;
|
|
|
|
m_zoneConnection = aOther.m_zoneConnection;
|
2022-08-19 17:34:53 +00:00
|
|
|
m_netTiePadGroups = aOther.m_netTiePadGroups;
|
2020-07-16 01:11:51 +00:00
|
|
|
|
2023-05-24 12:39:25 +00:00
|
|
|
// Move the fields
|
|
|
|
m_fields.clear();
|
2020-07-16 01:11:51 +00:00
|
|
|
|
2023-05-24 12:39:25 +00:00
|
|
|
for( PCB_FIELD* field : aOther.Fields() )
|
|
|
|
Add( field );
|
2020-07-16 01:11:51 +00:00
|
|
|
|
|
|
|
// Move the pads
|
|
|
|
m_pads.clear();
|
|
|
|
|
2020-11-12 22:30:02 +00:00
|
|
|
for( PAD* pad : aOther.Pads() )
|
2020-07-16 01:11:51 +00:00
|
|
|
Add( pad );
|
|
|
|
|
2020-10-03 11:16:29 +00:00
|
|
|
aOther.Pads().clear();
|
|
|
|
|
2020-07-16 01:11:51 +00:00
|
|
|
// Move the zones
|
2023-03-30 11:49:23 +00:00
|
|
|
m_zones.clear();
|
2020-07-16 01:11:51 +00:00
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
for( ZONE* item : aOther.Zones() )
|
2020-07-16 01:11:51 +00:00
|
|
|
{
|
2020-10-03 11:16:29 +00:00
|
|
|
Add( item );
|
2020-07-16 01:11:51 +00:00
|
|
|
|
|
|
|
// Ensure the net info is OK and especially uses the net info list
|
|
|
|
// living in the current board
|
|
|
|
// Needed when copying a fp from fp editor that has its own board
|
|
|
|
// Must be NETINFO_LIST::ORPHANED_ITEM for a keepout that has no net.
|
|
|
|
item->SetNetCode( -1 );
|
|
|
|
}
|
|
|
|
|
2020-10-03 11:16:29 +00:00
|
|
|
aOther.Zones().clear();
|
|
|
|
|
2020-07-16 01:11:51 +00:00
|
|
|
// Move the drawings
|
|
|
|
m_drawings.clear();
|
|
|
|
|
|
|
|
for( BOARD_ITEM* item : aOther.GraphicalItems() )
|
2020-10-03 11:16:29 +00:00
|
|
|
Add( item );
|
2020-07-16 01:11:51 +00:00
|
|
|
|
2020-10-03 11:16:29 +00:00
|
|
|
aOther.GraphicalItems().clear();
|
|
|
|
|
|
|
|
// Move the groups
|
2023-03-30 11:49:23 +00:00
|
|
|
m_groups.clear();
|
2020-10-03 11:16:29 +00:00
|
|
|
|
|
|
|
for( PCB_GROUP* group : aOther.Groups() )
|
|
|
|
Add( group );
|
|
|
|
|
|
|
|
aOther.Groups().clear();
|
2020-07-16 01:11:51 +00:00
|
|
|
|
2021-12-05 21:56:55 +00:00
|
|
|
// Copy auxiliary data
|
|
|
|
m_3D_Drawings = aOther.m_3D_Drawings;
|
2023-06-19 17:08:18 +00:00
|
|
|
m_libDescription = aOther.m_libDescription;
|
2021-12-05 21:56:55 +00:00
|
|
|
m_keywords = aOther.m_keywords;
|
|
|
|
m_privateLayers = aOther.m_privateLayers;
|
2020-07-16 01:11:51 +00:00
|
|
|
|
|
|
|
m_initial_comments = aOther.m_initial_comments;
|
|
|
|
|
|
|
|
// Clear the other item's containers since this is a move
|
2023-05-24 12:39:25 +00:00
|
|
|
aOther.Fields().clear();
|
2020-07-16 01:11:51 +00:00
|
|
|
aOther.Pads().clear();
|
|
|
|
aOther.Zones().clear();
|
|
|
|
aOther.GraphicalItems().clear();
|
|
|
|
aOther.m_initial_comments = nullptr;
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
FOOTPRINT& FOOTPRINT::operator=( const FOOTPRINT& aOther )
|
2016-05-31 08:27:52 +00:00
|
|
|
{
|
|
|
|
BOARD_ITEM::operator=( aOther );
|
|
|
|
|
2020-11-13 02:57:11 +00:00
|
|
|
m_pos = aOther.m_pos;
|
2016-05-31 08:27:52 +00:00
|
|
|
m_fpid = aOther.m_fpid;
|
2020-11-13 02:57:11 +00:00
|
|
|
m_attributes = aOther.m_attributes;
|
2020-11-13 11:17:15 +00:00
|
|
|
m_fpStatus = aOther.m_fpStatus;
|
2020-11-13 02:57:11 +00:00
|
|
|
m_orient = aOther.m_orient;
|
|
|
|
m_lastEditTime = aOther.m_lastEditTime;
|
|
|
|
m_link = aOther.m_link;
|
|
|
|
m_path = aOther.m_path;
|
|
|
|
|
2021-02-26 13:49:40 +00:00
|
|
|
m_cachedBoundingBox = aOther.m_cachedBoundingBox;
|
|
|
|
m_boundingBoxCacheTimeStamp = aOther.m_boundingBoxCacheTimeStamp;
|
|
|
|
m_cachedVisibleBBox = aOther.m_cachedVisibleBBox;
|
|
|
|
m_visibleBBoxCacheTimeStamp = aOther.m_visibleBBoxCacheTimeStamp;
|
|
|
|
m_cachedTextExcludedBBox = aOther.m_cachedTextExcludedBBox;
|
|
|
|
m_textExcludedBBoxCacheTimeStamp = aOther.m_textExcludedBBoxCacheTimeStamp;
|
|
|
|
m_cachedHull = aOther.m_cachedHull;
|
|
|
|
m_hullCacheTimeStamp = aOther.m_hullCacheTimeStamp;
|
|
|
|
|
|
|
|
m_localClearance = aOther.m_localClearance;
|
|
|
|
m_localSolderMaskMargin = aOther.m_localSolderMaskMargin;
|
|
|
|
m_localSolderPasteMargin = aOther.m_localSolderPasteMargin;
|
|
|
|
m_localSolderPasteMarginRatio = aOther.m_localSolderPasteMarginRatio;
|
|
|
|
m_zoneConnection = aOther.m_zoneConnection;
|
2022-08-19 17:34:53 +00:00
|
|
|
m_netTiePadGroups = aOther.m_netTiePadGroups;
|
2016-05-31 08:27:52 +00:00
|
|
|
|
2020-10-03 11:16:29 +00:00
|
|
|
std::map<BOARD_ITEM*, BOARD_ITEM*> ptrMap;
|
|
|
|
|
2023-05-24 12:39:25 +00:00
|
|
|
// Copy fields
|
|
|
|
m_fields.clear();
|
|
|
|
|
|
|
|
for( PCB_FIELD* field : aOther.GetFields() )
|
|
|
|
{
|
|
|
|
PCB_FIELD* newField = new PCB_FIELD( *field );
|
|
|
|
ptrMap[field] = newField;
|
|
|
|
Add( newField );
|
|
|
|
}
|
|
|
|
|
2020-10-03 11:16:29 +00:00
|
|
|
// Copy pads
|
2019-06-01 23:23:36 +00:00
|
|
|
m_pads.clear();
|
2016-05-31 08:27:52 +00:00
|
|
|
|
2020-11-12 22:30:02 +00:00
|
|
|
for( PAD* pad : aOther.Pads() )
|
2020-10-03 11:16:29 +00:00
|
|
|
{
|
2020-11-12 22:30:02 +00:00
|
|
|
PAD* newPad = new PAD( *pad );
|
2020-10-03 11:16:29 +00:00
|
|
|
ptrMap[ pad ] = newPad;
|
|
|
|
Add( newPad );
|
|
|
|
}
|
2016-05-31 08:27:52 +00:00
|
|
|
|
2020-10-03 11:16:29 +00:00
|
|
|
// Copy zones
|
2023-03-30 11:49:23 +00:00
|
|
|
m_zones.clear();
|
2019-10-29 10:09:54 +00:00
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
for( ZONE* zone : aOther.Zones() )
|
2019-10-29 10:09:54 +00:00
|
|
|
{
|
2023-03-30 11:49:23 +00:00
|
|
|
ZONE* newZone = static_cast<ZONE*>( zone->Clone() );
|
2020-10-03 11:16:29 +00:00
|
|
|
ptrMap[ zone ] = newZone;
|
|
|
|
Add( newZone );
|
2019-10-29 10:09:54 +00:00
|
|
|
|
|
|
|
// Ensure the net info is OK and especially uses the net info list
|
|
|
|
// living in the current board
|
|
|
|
// Needed when copying a fp from fp editor that has its own board
|
|
|
|
// Must be NETINFO_LIST::ORPHANED_ITEM for a keepout that has no net.
|
2020-10-03 11:16:29 +00:00
|
|
|
newZone->SetNetCode( -1 );
|
2019-10-29 10:09:54 +00:00
|
|
|
}
|
|
|
|
|
2020-10-03 11:16:29 +00:00
|
|
|
// Copy drawings
|
2019-06-02 03:55:32 +00:00
|
|
|
m_drawings.clear();
|
2016-05-31 08:27:52 +00:00
|
|
|
|
2020-06-27 18:01:00 +00:00
|
|
|
for( BOARD_ITEM* item : aOther.GraphicalItems() )
|
2016-05-31 08:27:52 +00:00
|
|
|
{
|
2020-10-03 11:16:29 +00:00
|
|
|
BOARD_ITEM* newItem = static_cast<BOARD_ITEM*>( item->Clone() );
|
|
|
|
ptrMap[ item ] = newItem;
|
|
|
|
Add( newItem );
|
|
|
|
}
|
2016-05-31 08:27:52 +00:00
|
|
|
|
2020-10-03 11:16:29 +00:00
|
|
|
// Copy groups
|
2023-03-30 11:49:23 +00:00
|
|
|
m_groups.clear();
|
2020-10-03 11:16:29 +00:00
|
|
|
|
|
|
|
for( PCB_GROUP* group : aOther.Groups() )
|
|
|
|
{
|
|
|
|
PCB_GROUP* newGroup = static_cast<PCB_GROUP*>( group->Clone() );
|
2021-03-06 09:27:41 +00:00
|
|
|
newGroup->GetItems().clear();
|
2020-10-03 11:16:29 +00:00
|
|
|
|
|
|
|
for( BOARD_ITEM* member : group->GetItems() )
|
|
|
|
newGroup->AddItem( ptrMap[ member ] );
|
|
|
|
|
|
|
|
Add( newGroup );
|
2016-05-31 08:27:52 +00:00
|
|
|
}
|
|
|
|
|
2021-12-05 21:56:55 +00:00
|
|
|
// Copy auxiliary data
|
|
|
|
m_3D_Drawings = aOther.m_3D_Drawings;
|
2023-06-19 17:08:18 +00:00
|
|
|
m_libDescription = aOther.m_libDescription;
|
2021-12-05 21:56:55 +00:00
|
|
|
m_keywords = aOther.m_keywords;
|
|
|
|
m_privateLayers = aOther.m_privateLayers;
|
2016-05-31 08:27:52 +00:00
|
|
|
|
2020-07-16 01:11:51 +00:00
|
|
|
m_initial_comments = aOther.m_initial_comments ?
|
|
|
|
new wxArrayString( *aOther.m_initial_comments ) : nullptr;
|
|
|
|
|
2016-05-31 08:27:52 +00:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-05-20 09:08:33 +00:00
|
|
|
bool FOOTPRINT::IsConflicting() const
|
|
|
|
{
|
|
|
|
return HasFlag( COURTYARD_CONFLICT );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
void FOOTPRINT::GetContextualTextVars( wxArrayString* aVars ) const
|
2020-05-27 22:28:36 +00:00
|
|
|
{
|
|
|
|
aVars->push_back( wxT( "REFERENCE" ) );
|
|
|
|
aVars->push_back( wxT( "VALUE" ) );
|
|
|
|
aVars->push_back( wxT( "LAYER" ) );
|
2022-09-11 23:55:33 +00:00
|
|
|
aVars->push_back( wxT( "FOOTPRINT_LIBRARY" ) );
|
|
|
|
aVars->push_back( wxT( "FOOTPRINT_NAME" ) );
|
2023-07-02 09:57:59 +00:00
|
|
|
aVars->push_back( wxT( "SHORT_NET_NAME(<pad_number>)" ) );
|
2022-09-11 23:55:33 +00:00
|
|
|
aVars->push_back( wxT( "NET_NAME(<pad_number>)" ) );
|
|
|
|
aVars->push_back( wxT( "NET_CLASS(<pad_number>)" ) );
|
|
|
|
aVars->push_back( wxT( "PIN_NAME(<pad_number>)" ) );
|
2020-05-27 22:28:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
bool FOOTPRINT::ResolveTextVar( wxString* token, int aDepth ) const
|
2020-04-06 13:06:57 +00:00
|
|
|
{
|
2022-10-15 14:53:33 +00:00
|
|
|
if( GetBoard() && GetBoard()->GetBoardUse() == BOARD_USE::FPHOLDER )
|
|
|
|
return false;
|
|
|
|
|
2020-04-06 13:06:57 +00:00
|
|
|
if( token->IsSameAs( wxT( "REFERENCE" ) ) )
|
|
|
|
{
|
2023-05-24 12:39:25 +00:00
|
|
|
*token = Reference().GetShownText( false, aDepth + 1 );
|
2020-04-06 13:06:57 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if( token->IsSameAs( wxT( "VALUE" ) ) )
|
|
|
|
{
|
2023-05-24 12:39:25 +00:00
|
|
|
*token = Value().GetShownText( false, aDepth + 1 );
|
2020-04-06 13:06:57 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if( token->IsSameAs( wxT( "LAYER" ) ) )
|
|
|
|
{
|
|
|
|
*token = GetLayerName();
|
|
|
|
return true;
|
|
|
|
}
|
2022-04-18 09:09:43 +00:00
|
|
|
else if( token->IsSameAs( wxT( "FOOTPRINT_LIBRARY" ) ) )
|
|
|
|
{
|
2023-09-14 15:35:19 +00:00
|
|
|
*token = m_fpid.GetUniStringLibNickname();
|
2022-04-18 09:09:43 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if( token->IsSameAs( wxT( "FOOTPRINT_NAME" ) ) )
|
|
|
|
{
|
2023-09-14 15:35:19 +00:00
|
|
|
*token = m_fpid.GetUniStringLibItemName();
|
2022-04-18 09:09:43 +00:00
|
|
|
return true;
|
|
|
|
}
|
2023-07-02 09:57:59 +00:00
|
|
|
else if( token->StartsWith( wxT( "SHORT_NET_NAME(" ) )
|
|
|
|
|| token->StartsWith( wxT( "NET_NAME(" ) )
|
|
|
|
|| token->StartsWith( wxT( "NET_CLASS(" ) )
|
2023-08-30 10:43:21 +00:00
|
|
|
|| token->StartsWith( wxT( "PIN_NAME(" ) ) )
|
2022-09-11 23:55:33 +00:00
|
|
|
{
|
|
|
|
wxString padNumber = token->AfterFirst( '(' );
|
|
|
|
padNumber = padNumber.BeforeLast( ')' );
|
|
|
|
|
|
|
|
for( PAD* pad : Pads() )
|
|
|
|
{
|
|
|
|
if( pad->GetNumber() == padNumber )
|
|
|
|
{
|
2023-07-02 09:57:59 +00:00
|
|
|
if( token->StartsWith( wxT( "SHORT_NET_NAME" ) ) )
|
|
|
|
*token = pad->GetShortNetname();
|
|
|
|
else if( token->StartsWith( wxT( "NET_NAME" ) ) )
|
2022-09-11 23:55:33 +00:00
|
|
|
*token = pad->GetNetname();
|
|
|
|
else if( token->StartsWith( wxT( "NET_CLASS" ) ) )
|
|
|
|
*token = pad->GetNetClassName();
|
|
|
|
else
|
|
|
|
*token = pad->GetPinFunction();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-05-24 12:39:25 +00:00
|
|
|
else if( HasFieldByName( *token ) )
|
2020-08-08 21:47:57 +00:00
|
|
|
{
|
2023-05-24 12:39:25 +00:00
|
|
|
*token = GetFieldText( *token );
|
2020-08-08 21:47:57 +00:00
|
|
|
return true;
|
|
|
|
}
|
2020-04-06 13:06:57 +00:00
|
|
|
|
2023-01-17 16:54:08 +00:00
|
|
|
if( GetBoard() && GetBoard()->ResolveTextVar( token, aDepth + 1 ) )
|
|
|
|
return true;
|
|
|
|
|
2020-04-06 13:06:57 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
void FOOTPRINT::ClearAllNets()
|
2015-02-18 09:13:17 +00:00
|
|
|
{
|
|
|
|
// Force the ORPHANED dummy net info for all pads.
|
|
|
|
// ORPHANED dummy net does not depend on a board
|
2020-11-12 22:30:02 +00:00
|
|
|
for( PAD* pad : m_pads )
|
2016-01-29 10:29:56 +00:00
|
|
|
pad->SetNetCode( NETINFO_LIST::ORPHANED );
|
2015-02-18 09:13:17 +00:00
|
|
|
}
|
|
|
|
|
2010-07-20 10:30:40 +00:00
|
|
|
|
2022-02-18 12:23:50 +00:00
|
|
|
void FOOTPRINT::Add( BOARD_ITEM* aBoardItem, ADD_MODE aMode, bool aSkipConnectivity )
|
2014-07-09 12:22:29 +00:00
|
|
|
{
|
|
|
|
switch( aBoardItem->Type() )
|
|
|
|
{
|
2023-06-06 15:09:34 +00:00
|
|
|
case PCB_FIELD_T:
|
2023-06-20 14:31:13 +00:00
|
|
|
// Always append fields
|
|
|
|
m_fields.push_back( static_cast<PCB_FIELD*>( aBoardItem ) );
|
2023-05-24 12:39:25 +00:00
|
|
|
|
2023-06-06 17:30:03 +00:00
|
|
|
break;
|
2014-07-09 12:22:29 +00:00
|
|
|
|
2023-06-06 17:30:03 +00:00
|
|
|
case PCB_TEXT_T:
|
2023-03-30 11:49:23 +00:00
|
|
|
case PCB_DIM_ALIGNED_T:
|
|
|
|
case PCB_DIM_LEADER_T:
|
|
|
|
case PCB_DIM_CENTER_T:
|
|
|
|
case PCB_DIM_RADIAL_T:
|
|
|
|
case PCB_DIM_ORTHOGONAL_T:
|
|
|
|
case PCB_SHAPE_T:
|
|
|
|
case PCB_TEXTBOX_T:
|
2023-10-23 17:23:24 +00:00
|
|
|
case PCB_REFERENCE_IMAGE_T:
|
2019-12-28 00:55:11 +00:00
|
|
|
if( aMode == ADD_MODE::APPEND )
|
2019-06-02 03:55:32 +00:00
|
|
|
m_drawings.push_back( aBoardItem );
|
2014-07-09 12:22:29 +00:00
|
|
|
else
|
2019-06-02 03:55:32 +00:00
|
|
|
m_drawings.push_front( aBoardItem );
|
2014-07-09 12:22:29 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PCB_PAD_T:
|
2019-12-28 00:55:11 +00:00
|
|
|
if( aMode == ADD_MODE::APPEND )
|
2020-11-12 22:30:02 +00:00
|
|
|
m_pads.push_back( static_cast<PAD*>( aBoardItem ) );
|
2014-07-09 12:22:29 +00:00
|
|
|
else
|
2020-11-12 22:30:02 +00:00
|
|
|
m_pads.push_front( static_cast<PAD*>( aBoardItem ) );
|
2014-07-09 12:22:29 +00:00
|
|
|
break;
|
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
case PCB_ZONE_T:
|
2019-12-28 00:55:11 +00:00
|
|
|
if( aMode == ADD_MODE::APPEND )
|
2023-03-30 11:49:23 +00:00
|
|
|
m_zones.push_back( static_cast<ZONE*>( aBoardItem ) );
|
2019-10-29 10:09:54 +00:00
|
|
|
else
|
2023-03-30 11:49:23 +00:00
|
|
|
m_zones.insert( m_zones.begin(), static_cast<ZONE*>( aBoardItem ) );
|
2019-10-29 10:09:54 +00:00
|
|
|
break;
|
|
|
|
|
2020-10-03 11:16:29 +00:00
|
|
|
case PCB_GROUP_T:
|
|
|
|
if( aMode == ADD_MODE::APPEND )
|
2023-03-30 11:49:23 +00:00
|
|
|
m_groups.push_back( static_cast<PCB_GROUP*>( aBoardItem ) );
|
2020-10-03 11:16:29 +00:00
|
|
|
else
|
2023-03-30 11:49:23 +00:00
|
|
|
m_groups.insert( m_groups.begin(), static_cast<PCB_GROUP*>( aBoardItem ) );
|
2020-10-03 11:16:29 +00:00
|
|
|
break;
|
|
|
|
|
2014-07-09 12:22:29 +00:00
|
|
|
default:
|
2014-11-15 19:06:05 +00:00
|
|
|
{
|
|
|
|
wxString msg;
|
2020-11-13 21:07:01 +00:00
|
|
|
msg.Printf( wxT( "FOOTPRINT::Add() needs work: BOARD_ITEM type (%d) not handled" ),
|
2014-11-15 19:06:05 +00:00
|
|
|
aBoardItem->Type() );
|
|
|
|
wxFAIL_MSG( msg );
|
2014-07-09 12:22:29 +00:00
|
|
|
|
2014-11-15 19:06:05 +00:00
|
|
|
return;
|
|
|
|
}
|
2014-07-09 12:22:29 +00:00
|
|
|
}
|
|
|
|
|
2019-08-08 19:50:42 +00:00
|
|
|
aBoardItem->ClearEditFlags();
|
2014-07-09 12:22:29 +00:00
|
|
|
aBoardItem->SetParent( this );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-07 23:29:30 +00:00
|
|
|
void FOOTPRINT::Remove( BOARD_ITEM* aBoardItem, REMOVE_MODE aMode )
|
2014-07-09 12:22:29 +00:00
|
|
|
{
|
|
|
|
switch( aBoardItem->Type() )
|
|
|
|
{
|
2023-06-06 17:30:03 +00:00
|
|
|
case PCB_FIELD_T:
|
|
|
|
{
|
|
|
|
PCB_FIELD* field = static_cast<PCB_FIELD*>( aBoardItem );
|
|
|
|
|
2023-05-24 12:39:25 +00:00
|
|
|
for( auto it = m_fields.begin(); it != m_fields.end(); ++it )
|
|
|
|
{
|
|
|
|
if( *it == aBoardItem )
|
|
|
|
{
|
|
|
|
m_fields.erase( it );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2023-06-06 17:30:03 +00:00
|
|
|
}
|
|
|
|
break;
|
2014-07-09 12:22:29 +00:00
|
|
|
|
2023-06-06 17:30:03 +00:00
|
|
|
case PCB_TEXT_T:
|
2023-03-30 11:49:23 +00:00
|
|
|
case PCB_DIM_ALIGNED_T:
|
|
|
|
case PCB_DIM_CENTER_T:
|
|
|
|
case PCB_DIM_ORTHOGONAL_T:
|
|
|
|
case PCB_DIM_RADIAL_T:
|
|
|
|
case PCB_DIM_LEADER_T:
|
|
|
|
case PCB_SHAPE_T:
|
|
|
|
case PCB_TEXTBOX_T:
|
2023-10-23 17:23:24 +00:00
|
|
|
case PCB_REFERENCE_IMAGE_T:
|
2019-06-11 14:47:54 +00:00
|
|
|
for( auto it = m_drawings.begin(); it != m_drawings.end(); ++it )
|
|
|
|
{
|
|
|
|
if( *it == aBoardItem )
|
|
|
|
{
|
|
|
|
m_drawings.erase( it );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-13 15:31:54 +00:00
|
|
|
break;
|
2014-07-09 12:22:29 +00:00
|
|
|
|
|
|
|
case PCB_PAD_T:
|
2019-06-11 14:47:54 +00:00
|
|
|
for( auto it = m_pads.begin(); it != m_pads.end(); ++it )
|
|
|
|
{
|
2020-11-12 22:30:02 +00:00
|
|
|
if( *it == static_cast<PAD*>( aBoardItem ) )
|
2019-06-11 14:47:54 +00:00
|
|
|
{
|
|
|
|
m_pads.erase( it );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-13 15:31:54 +00:00
|
|
|
break;
|
2014-07-09 12:22:29 +00:00
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
case PCB_ZONE_T:
|
|
|
|
for( auto it = m_zones.begin(); it != m_zones.end(); ++it )
|
2019-10-29 10:09:54 +00:00
|
|
|
{
|
2023-03-30 11:49:23 +00:00
|
|
|
if( *it == static_cast<ZONE*>( aBoardItem ) )
|
2019-10-29 10:09:54 +00:00
|
|
|
{
|
2023-03-30 11:49:23 +00:00
|
|
|
m_zones.erase( it );
|
2019-10-29 10:09:54 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2020-10-03 11:16:29 +00:00
|
|
|
case PCB_GROUP_T:
|
2023-03-30 11:49:23 +00:00
|
|
|
for( auto it = m_groups.begin(); it != m_groups.end(); ++it )
|
2020-10-03 11:16:29 +00:00
|
|
|
{
|
|
|
|
if( *it == static_cast<PCB_GROUP*>( aBoardItem ) )
|
|
|
|
{
|
2023-03-30 11:49:23 +00:00
|
|
|
m_groups.erase( it );
|
2020-10-03 11:16:29 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2014-07-09 12:22:29 +00:00
|
|
|
default:
|
2014-11-15 19:06:05 +00:00
|
|
|
{
|
|
|
|
wxString msg;
|
2020-11-13 21:07:01 +00:00
|
|
|
msg.Printf( wxT( "FOOTPRINT::Remove() needs work: BOARD_ITEM type (%d) not handled" ),
|
2014-11-15 19:06:05 +00:00
|
|
|
aBoardItem->Type() );
|
|
|
|
wxFAIL_MSG( msg );
|
|
|
|
}
|
2014-07-09 12:22:29 +00:00
|
|
|
}
|
2021-02-02 11:57:48 +00:00
|
|
|
|
2021-02-15 13:49:40 +00:00
|
|
|
aBoardItem->SetFlags( STRUCT_DELETED );
|
|
|
|
|
|
|
|
PCB_GROUP* parentGroup = aBoardItem->GetParentGroup();
|
|
|
|
|
|
|
|
if( parentGroup && !( parentGroup->GetFlags() & STRUCT_DELETED ) )
|
|
|
|
parentGroup->RemoveItem( aBoardItem );
|
2018-09-13 21:29:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
double FOOTPRINT::GetArea( int aPadding ) const
|
2018-09-13 21:29:52 +00:00
|
|
|
{
|
2022-08-31 16:17:14 +00:00
|
|
|
BOX2I bbox = GetBoundingBox( false, false );
|
2007-08-06 02:02:39 +00:00
|
|
|
|
2021-02-26 13:49:40 +00:00
|
|
|
double w = std::abs( static_cast<double>( bbox.GetWidth() ) ) + aPadding;
|
|
|
|
double h = std::abs( static_cast<double>( bbox.GetHeight() ) ) + aPadding;
|
|
|
|
return w * h;
|
2010-12-10 19:47:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-09-24 16:15:54 +00:00
|
|
|
int FOOTPRINT::GetLikelyAttribute() const
|
|
|
|
{
|
|
|
|
int smd_count = 0;
|
|
|
|
int tht_count = 0;
|
|
|
|
|
|
|
|
for( PAD* pad : m_pads )
|
|
|
|
{
|
2021-11-29 16:44:45 +00:00
|
|
|
switch( pad->GetProperty() )
|
|
|
|
{
|
|
|
|
case PAD_PROP::FIDUCIAL_GLBL:
|
|
|
|
case PAD_PROP::FIDUCIAL_LOCAL:
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case PAD_PROP::HEATSINK:
|
|
|
|
case PAD_PROP::CASTELLATED:
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case PAD_PROP::NONE:
|
|
|
|
case PAD_PROP::BGA:
|
|
|
|
case PAD_PROP::TESTPOINT:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2021-09-24 16:15:54 +00:00
|
|
|
switch( pad->GetAttribute() )
|
|
|
|
{
|
|
|
|
case PAD_ATTRIB::PTH:
|
|
|
|
tht_count++;
|
|
|
|
break;
|
2021-11-29 16:44:45 +00:00
|
|
|
|
2021-09-24 16:15:54 +00:00
|
|
|
case PAD_ATTRIB::SMD:
|
2023-01-07 15:13:29 +00:00
|
|
|
if( pad->IsOnCopperLayer() )
|
|
|
|
smd_count++;
|
|
|
|
|
2021-09-24 16:15:54 +00:00
|
|
|
break;
|
2021-11-29 16:44:45 +00:00
|
|
|
|
2021-09-24 16:15:54 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-01 09:21:11 +00:00
|
|
|
// Footprints with plated through-hole pads should usually be marked through hole even if they
|
|
|
|
// also have SMD because they might not be auto-placed. Exceptions to this might be shielded
|
2023-01-06 00:55:10 +00:00
|
|
|
if( tht_count > 0 )
|
|
|
|
return FP_THROUGH_HOLE;
|
|
|
|
|
2023-10-01 09:21:11 +00:00
|
|
|
if( smd_count > 0 )
|
|
|
|
return FP_SMD;
|
|
|
|
|
2021-09-24 16:15:54 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxString FOOTPRINT::GetTypeName() const
|
|
|
|
{
|
|
|
|
if( ( m_attributes & FP_SMD ) == FP_SMD )
|
|
|
|
return _( "SMD" );
|
|
|
|
|
|
|
|
if( ( m_attributes & FP_THROUGH_HOLE ) == FP_THROUGH_HOLE )
|
|
|
|
return _( "Through hole" );
|
|
|
|
|
|
|
|
return _( "Other" );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-08-30 23:28:18 +00:00
|
|
|
BOX2I FOOTPRINT::GetFpPadsLocalBbox() const
|
2019-11-01 12:35:42 +00:00
|
|
|
{
|
2022-08-31 09:15:42 +00:00
|
|
|
BOX2I bbox;
|
2019-11-01 12:35:42 +00:00
|
|
|
|
|
|
|
// We want the bounding box of the footprint pads at rot 0, not flipped
|
|
|
|
// Create such a image:
|
2020-11-13 15:15:52 +00:00
|
|
|
FOOTPRINT dummy( *this );
|
2019-11-01 12:35:42 +00:00
|
|
|
|
2022-01-11 00:49:49 +00:00
|
|
|
dummy.SetPosition( VECTOR2I( 0, 0 ) );
|
2022-01-13 17:27:36 +00:00
|
|
|
dummy.SetOrientation( ANGLE_0 );
|
2020-10-14 23:37:26 +00:00
|
|
|
|
2019-11-01 12:35:42 +00:00
|
|
|
if( dummy.IsFlipped() )
|
2022-01-11 00:49:49 +00:00
|
|
|
dummy.Flip( VECTOR2I( 0, 0 ), false );
|
2019-11-01 12:35:42 +00:00
|
|
|
|
2020-11-12 22:30:02 +00:00
|
|
|
for( PAD* pad : dummy.Pads() )
|
2022-08-31 09:15:42 +00:00
|
|
|
bbox.Merge( pad->GetBoundingBox() );
|
2019-11-01 12:35:42 +00:00
|
|
|
|
2023-06-23 23:03:06 +00:00
|
|
|
// Remove the parent and the group from the dummy footprint before deletion
|
2023-01-18 00:40:14 +00:00
|
|
|
dummy.SetParent( nullptr );
|
2023-06-23 23:03:06 +00:00
|
|
|
dummy.SetParentGroup( nullptr );
|
2023-01-18 00:40:14 +00:00
|
|
|
|
2022-08-31 09:15:42 +00:00
|
|
|
return bbox;
|
2019-11-01 12:35:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-08-31 09:15:42 +00:00
|
|
|
const BOX2I FOOTPRINT::GetBoundingBox() const
|
2008-03-13 10:08:42 +00:00
|
|
|
{
|
2021-02-26 13:49:40 +00:00
|
|
|
return GetBoundingBox( true, true );
|
2008-03-13 10:08:42 +00:00
|
|
|
}
|
|
|
|
|
2008-03-15 10:24:32 +00:00
|
|
|
|
2022-08-31 16:17:14 +00:00
|
|
|
const BOX2I FOOTPRINT::GetBoundingBox( bool aIncludeText, bool aIncludeInvisibleText ) const
|
2019-08-20 11:58:14 +00:00
|
|
|
{
|
2023-06-15 19:37:07 +00:00
|
|
|
std::vector<PCB_TEXT*> texts;
|
2021-08-16 09:53:27 +00:00
|
|
|
const BOARD* board = GetBoard();
|
2021-12-05 21:56:55 +00:00
|
|
|
bool isFPEdit = board && board->IsFootprintHolder();
|
2024-02-04 12:54:03 +00:00
|
|
|
PCB_LAYER_ID footprintSide = GetSide();
|
2021-02-26 13:49:40 +00:00
|
|
|
|
|
|
|
if( board )
|
|
|
|
{
|
|
|
|
if( aIncludeText && aIncludeInvisibleText )
|
|
|
|
{
|
|
|
|
if( m_boundingBoxCacheTimeStamp >= board->GetTimeStamp() )
|
|
|
|
return m_cachedBoundingBox;
|
|
|
|
}
|
|
|
|
else if( aIncludeText )
|
|
|
|
{
|
|
|
|
if( m_visibleBBoxCacheTimeStamp >= board->GetTimeStamp() )
|
|
|
|
return m_cachedVisibleBBox;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( m_textExcludedBBoxCacheTimeStamp >= board->GetTimeStamp() )
|
|
|
|
return m_cachedTextExcludedBBox;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-31 09:15:42 +00:00
|
|
|
BOX2I bbox( m_pos );
|
2022-09-16 11:33:56 +00:00
|
|
|
bbox.Inflate( pcbIUScale.mmToIU( 0.25 ) ); // Give a min size to the bbox
|
2019-08-20 11:58:14 +00:00
|
|
|
|
2020-06-27 18:01:00 +00:00
|
|
|
for( BOARD_ITEM* item : m_drawings )
|
2019-08-20 11:58:14 +00:00
|
|
|
{
|
2022-07-17 16:03:15 +00:00
|
|
|
if( m_privateLayers.test( item->GetLayer() ) && !isFPEdit )
|
|
|
|
continue;
|
|
|
|
|
2022-02-08 19:29:54 +00:00
|
|
|
// We want the bitmap bounding box just in the footprint editor
|
|
|
|
// so it will start with the correct initial zoom
|
2023-10-23 17:23:24 +00:00
|
|
|
if( item->Type() == PCB_REFERENCE_IMAGE_T && !isFPEdit )
|
2022-07-17 16:03:15 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
// Handle text separately
|
2023-03-30 11:49:23 +00:00
|
|
|
if( item->Type() == PCB_TEXT_T )
|
2023-06-15 19:37:07 +00:00
|
|
|
{
|
|
|
|
texts.push_back( static_cast<PCB_TEXT*>( item ) );
|
2021-12-05 21:56:55 +00:00
|
|
|
continue;
|
2023-06-15 19:37:07 +00:00
|
|
|
}
|
2021-12-05 21:56:55 +00:00
|
|
|
|
2024-02-04 12:54:03 +00:00
|
|
|
// If we're not including text then drop annotations as well -- unless, of course, it's
|
|
|
|
// an unsided footprint -- in which case it's likely to be nothing *but* annotations.
|
|
|
|
if( !aIncludeText && footprintSide != UNDEFINED_LAYER )
|
2023-08-26 17:44:47 +00:00
|
|
|
{
|
|
|
|
if( BaseType( item->Type() ) == PCB_DIMENSION_T )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if( item->GetLayer() == Cmts_User || item->GetLayer() == Dwgs_User
|
|
|
|
|| item->GetLayer() == Eco1_User || item->GetLayer() == Eco2_User )
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2023-02-18 13:04:12 +00:00
|
|
|
|
2022-08-31 09:15:42 +00:00
|
|
|
bbox.Merge( item->GetBoundingBox() );
|
2019-08-20 11:58:14 +00:00
|
|
|
}
|
|
|
|
|
2023-06-15 19:37:07 +00:00
|
|
|
for( PCB_FIELD* field : m_fields )
|
2024-01-27 23:15:53 +00:00
|
|
|
{
|
|
|
|
// Reference and value get their own processing
|
|
|
|
if( !field->IsReference() && !field->IsValue() )
|
|
|
|
texts.push_back( field );
|
|
|
|
}
|
2023-06-15 19:37:07 +00:00
|
|
|
|
2021-02-26 13:49:40 +00:00
|
|
|
for( PAD* pad : m_pads )
|
2022-08-31 09:15:42 +00:00
|
|
|
bbox.Merge( pad->GetBoundingBox() );
|
2020-09-16 05:04:48 +00:00
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
for( ZONE* zone : m_zones )
|
2022-08-31 09:15:42 +00:00
|
|
|
bbox.Merge( zone->GetBoundingBox() );
|
2021-02-26 13:49:40 +00:00
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
bool noDrawItems = ( m_drawings.empty() && m_pads.empty() && m_zones.empty() );
|
2021-02-26 13:49:40 +00:00
|
|
|
|
2021-06-23 22:58:58 +00:00
|
|
|
// Groups do not contribute to the rect, only their members
|
|
|
|
if( aIncludeText || noDrawItems )
|
2020-09-16 05:04:48 +00:00
|
|
|
{
|
2023-06-15 19:37:07 +00:00
|
|
|
// Only PCB_TEXT and PCB_FIELD items are independently selectable;
|
|
|
|
// PCB_TEXTBOX items go in with other graphic items above.
|
|
|
|
for( PCB_TEXT* text : texts )
|
2021-02-26 13:49:40 +00:00
|
|
|
{
|
2023-06-15 19:37:07 +00:00
|
|
|
if( !isFPEdit && m_privateLayers.test( text->GetLayer() ) )
|
2021-12-05 21:56:55 +00:00
|
|
|
continue;
|
|
|
|
|
2023-07-22 09:48:17 +00:00
|
|
|
if( aIncludeInvisibleText || text->IsVisible() )
|
|
|
|
bbox.Merge( text->GetBoundingBox() );
|
2021-02-26 13:49:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// This can be further optimized when aIncludeInvisibleText is true, but currently
|
|
|
|
// leaving this as is until it's determined there is a noticeable speed hit.
|
|
|
|
bool valueLayerIsVisible = true;
|
|
|
|
bool refLayerIsVisible = true;
|
|
|
|
|
|
|
|
if( board )
|
|
|
|
{
|
|
|
|
// The first "&&" conditional handles the user turning layers off as well as layers
|
|
|
|
// not being present in the current PCB stackup. Values, references, and all
|
|
|
|
// footprint text can also be turned off via the GAL meta-layers, so the 2nd and
|
|
|
|
// 3rd "&&" conditionals handle that.
|
2023-05-24 12:39:25 +00:00
|
|
|
valueLayerIsVisible = board->IsLayerVisible( Value().GetLayer() )
|
2023-08-04 10:13:20 +00:00
|
|
|
&& board->IsElementVisible( LAYER_FP_VALUES )
|
|
|
|
&& board->IsElementVisible( LAYER_FP_TEXT );
|
2021-02-26 13:49:40 +00:00
|
|
|
|
2023-05-24 12:39:25 +00:00
|
|
|
refLayerIsVisible = board->IsLayerVisible( Reference().GetLayer() )
|
2023-08-04 10:13:20 +00:00
|
|
|
&& board->IsElementVisible( LAYER_FP_REFERENCES )
|
|
|
|
&& board->IsElementVisible( LAYER_FP_TEXT );
|
2021-02-26 13:49:40 +00:00
|
|
|
}
|
2020-09-16 05:04:48 +00:00
|
|
|
|
|
|
|
|
2023-05-24 12:39:25 +00:00
|
|
|
if( ( Value().IsVisible() && valueLayerIsVisible )
|
2021-12-04 23:52:00 +00:00
|
|
|
|| aIncludeInvisibleText
|
|
|
|
|| noDrawItems )
|
|
|
|
{
|
2023-05-24 12:39:25 +00:00
|
|
|
bbox.Merge( Value().GetBoundingBox() );
|
2021-12-04 23:52:00 +00:00
|
|
|
}
|
2021-02-26 13:49:40 +00:00
|
|
|
|
2023-05-24 12:39:25 +00:00
|
|
|
if( ( Reference().IsVisible() && refLayerIsVisible )
|
2021-12-04 23:52:00 +00:00
|
|
|
|| aIncludeInvisibleText
|
|
|
|
|| noDrawItems )
|
|
|
|
{
|
2023-05-24 12:39:25 +00:00
|
|
|
bbox.Merge( Reference().GetBoundingBox() );
|
2021-12-04 23:52:00 +00:00
|
|
|
}
|
2021-02-26 13:49:40 +00:00
|
|
|
}
|
2019-08-20 11:58:14 +00:00
|
|
|
|
2021-02-26 13:49:40 +00:00
|
|
|
if( board )
|
|
|
|
{
|
2021-06-23 22:58:58 +00:00
|
|
|
if( ( aIncludeText && aIncludeInvisibleText ) || noDrawItems )
|
2021-02-26 13:49:40 +00:00
|
|
|
{
|
|
|
|
m_boundingBoxCacheTimeStamp = board->GetTimeStamp();
|
2022-08-31 09:15:42 +00:00
|
|
|
m_cachedBoundingBox = bbox;
|
2021-02-26 13:49:40 +00:00
|
|
|
}
|
|
|
|
else if( aIncludeText )
|
|
|
|
{
|
|
|
|
m_visibleBBoxCacheTimeStamp = board->GetTimeStamp();
|
2022-08-31 09:15:42 +00:00
|
|
|
m_cachedVisibleBBox = bbox;
|
2021-02-26 13:49:40 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_textExcludedBBoxCacheTimeStamp = board->GetTimeStamp();
|
2022-08-31 09:15:42 +00:00
|
|
|
m_cachedTextExcludedBBox = bbox;
|
2021-02-26 13:49:40 +00:00
|
|
|
}
|
|
|
|
}
|
2019-08-20 11:58:14 +00:00
|
|
|
|
2022-08-31 09:15:42 +00:00
|
|
|
return bbox;
|
2019-08-20 11:58:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-08-03 16:59:24 +00:00
|
|
|
const BOX2I FOOTPRINT::GetLayerBoundingBox( LSET aLayers ) const
|
|
|
|
{
|
|
|
|
std::vector<PCB_TEXT*> texts;
|
|
|
|
const BOARD* board = GetBoard();
|
|
|
|
bool isFPEdit = board && board->IsFootprintHolder();
|
|
|
|
|
|
|
|
// Start with an uninitialized bounding box
|
|
|
|
BOX2I bbox;
|
|
|
|
|
|
|
|
for( BOARD_ITEM* item : m_drawings )
|
|
|
|
{
|
|
|
|
if( m_privateLayers.test( item->GetLayer() ) && !isFPEdit )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if( ( aLayers & item->GetLayerSet() ).none() )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// We want the bitmap bounding box just in the footprint editor
|
|
|
|
// so it will start with the correct initial zoom
|
2023-10-23 17:23:24 +00:00
|
|
|
if( item->Type() == PCB_REFERENCE_IMAGE_T && !isFPEdit )
|
2023-08-03 16:59:24 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
bbox.Merge( item->GetBoundingBox() );
|
|
|
|
}
|
|
|
|
|
|
|
|
for( PAD* pad : m_pads )
|
|
|
|
{
|
|
|
|
if( ( aLayers & pad->GetLayerSet() ).none() )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
bbox.Merge( pad->GetBoundingBox() );
|
|
|
|
}
|
|
|
|
|
|
|
|
for( ZONE* zone : m_zones )
|
|
|
|
{
|
|
|
|
if( ( aLayers & zone->GetLayerSet() ).none() )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
bbox.Merge( zone->GetBoundingBox() );
|
|
|
|
}
|
|
|
|
|
|
|
|
return bbox;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-02-26 13:49:40 +00:00
|
|
|
SHAPE_POLY_SET FOOTPRINT::GetBoundingHull() const
|
2021-01-31 14:32:14 +00:00
|
|
|
{
|
2021-08-16 09:53:27 +00:00
|
|
|
const BOARD* board = GetBoard();
|
2021-12-05 21:56:55 +00:00
|
|
|
bool isFPEdit = board && board->IsFootprintHolder();
|
2021-02-26 13:49:40 +00:00
|
|
|
|
|
|
|
if( board )
|
|
|
|
{
|
|
|
|
if( m_hullCacheTimeStamp >= board->GetTimeStamp() )
|
|
|
|
return m_cachedHull;
|
|
|
|
}
|
2021-01-31 14:32:14 +00:00
|
|
|
|
2020-11-29 14:00:39 +00:00
|
|
|
SHAPE_POLY_SET rawPolys;
|
2021-01-31 14:32:14 +00:00
|
|
|
SHAPE_POLY_SET hull;
|
2018-02-19 00:00:29 +00:00
|
|
|
|
2020-11-29 14:00:39 +00:00
|
|
|
for( BOARD_ITEM* item : m_drawings )
|
|
|
|
{
|
2021-12-05 21:56:55 +00:00
|
|
|
if( !isFPEdit && m_privateLayers.test( item->GetLayer() ) )
|
|
|
|
continue;
|
|
|
|
|
2023-10-23 17:23:24 +00:00
|
|
|
if( item->Type() != PCB_TEXT_T && item->Type() != PCB_REFERENCE_IMAGE_T )
|
2020-11-29 14:00:39 +00:00
|
|
|
{
|
2022-10-21 12:48:45 +00:00
|
|
|
item->TransformShapeToPolygon( rawPolys, UNDEFINED_LAYER, 0, ARC_LOW_DEF,
|
|
|
|
ERROR_OUTSIDE );
|
2020-11-29 14:00:39 +00:00
|
|
|
}
|
2018-02-22 01:39:46 +00:00
|
|
|
|
2020-11-29 14:00:39 +00:00
|
|
|
// We intentionally exclude footprint text from the bounding hull.
|
|
|
|
}
|
2018-02-19 00:00:29 +00:00
|
|
|
|
2020-11-29 14:00:39 +00:00
|
|
|
for( PAD* pad : m_pads )
|
|
|
|
{
|
2022-10-21 12:48:45 +00:00
|
|
|
pad->TransformShapeToPolygon( rawPolys, UNDEFINED_LAYER, 0, ARC_LOW_DEF, ERROR_OUTSIDE );
|
2021-09-26 22:17:50 +00:00
|
|
|
// In case hole is larger than pad
|
2022-10-21 12:48:45 +00:00
|
|
|
pad->TransformHoleToPolygon( rawPolys, 0, ARC_LOW_DEF, ERROR_OUTSIDE );
|
2020-11-29 14:00:39 +00:00
|
|
|
}
|
2018-02-22 01:39:46 +00:00
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
for( ZONE* zone : m_zones )
|
2018-02-22 01:39:46 +00:00
|
|
|
{
|
2020-11-29 14:00:39 +00:00
|
|
|
for( PCB_LAYER_ID layer : zone->GetLayerSet().Seq() )
|
|
|
|
{
|
2022-03-14 15:52:12 +00:00
|
|
|
const SHAPE_POLY_SET& layerPoly = *zone->GetFilledPolysList( layer );
|
2020-11-29 14:00:39 +00:00
|
|
|
|
|
|
|
for( int ii = 0; ii < layerPoly.OutlineCount(); ii++ )
|
|
|
|
{
|
|
|
|
const SHAPE_LINE_CHAIN& poly = layerPoly.COutline( ii );
|
|
|
|
rawPolys.AddOutline( poly );
|
|
|
|
}
|
|
|
|
}
|
2018-02-22 01:39:46 +00:00
|
|
|
}
|
2018-02-19 00:00:29 +00:00
|
|
|
|
2021-01-09 15:46:00 +00:00
|
|
|
// If there are some graphic items, build the actual hull.
|
|
|
|
// However if no items, create a minimal polygon (can happen if a footprint
|
|
|
|
// is created with no item: it contains only 2 texts.
|
|
|
|
if( rawPolys.OutlineCount() == 0 )
|
|
|
|
{
|
|
|
|
// generate a small dummy rectangular outline around the anchor
|
2022-09-16 11:33:56 +00:00
|
|
|
const int halfsize = pcbIUScale.mmToIU( 1.0 );
|
2021-01-09 15:46:00 +00:00
|
|
|
|
|
|
|
rawPolys.NewOutline();
|
2021-06-23 22:58:58 +00:00
|
|
|
|
2021-01-09 15:46:00 +00:00
|
|
|
// add a square:
|
|
|
|
rawPolys.Append( GetPosition().x - halfsize, GetPosition().y - halfsize );
|
|
|
|
rawPolys.Append( GetPosition().x + halfsize, GetPosition().y - halfsize );
|
|
|
|
rawPolys.Append( GetPosition().x + halfsize, GetPosition().y + halfsize );
|
|
|
|
rawPolys.Append( GetPosition().x - halfsize, GetPosition().y + halfsize );
|
|
|
|
}
|
|
|
|
|
2022-01-01 18:08:03 +00:00
|
|
|
std::vector<VECTOR2I> convex_hull;
|
2020-11-29 14:00:39 +00:00
|
|
|
BuildConvexHull( convex_hull, rawPolys );
|
|
|
|
|
2021-02-26 13:49:40 +00:00
|
|
|
m_cachedHull.RemoveAllContours();
|
|
|
|
m_cachedHull.NewOutline();
|
2020-11-29 14:00:39 +00:00
|
|
|
|
2022-01-01 18:08:03 +00:00
|
|
|
for( const VECTOR2I& pt : convex_hull )
|
2021-02-26 13:49:40 +00:00
|
|
|
m_cachedHull.Append( pt );
|
2021-01-31 14:32:14 +00:00
|
|
|
|
2021-02-26 13:49:40 +00:00
|
|
|
if( board )
|
|
|
|
m_hullCacheTimeStamp = board->GetTimeStamp();
|
2021-01-31 14:32:14 +00:00
|
|
|
|
2021-02-26 13:49:40 +00:00
|
|
|
return m_cachedHull;
|
2021-01-31 14:32:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
void FOOTPRINT::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2020-05-22 10:31:14 +00:00
|
|
|
wxString msg, msg2;
|
2007-08-06 02:02:39 +00:00
|
|
|
|
2023-05-05 13:21:56 +00:00
|
|
|
// Don't use GetShownText(); we want to see the variable references here
|
2023-05-24 12:39:25 +00:00
|
|
|
aList.emplace_back( UnescapeString( Reference().GetText() ),
|
|
|
|
UnescapeString( Value().GetText() ) );
|
2010-12-10 19:47:44 +00:00
|
|
|
|
2020-05-22 10:31:14 +00:00
|
|
|
if( aFrame->IsType( FRAME_FOOTPRINT_VIEWER )
|
2023-09-26 17:31:45 +00:00
|
|
|
|| aFrame->IsType( FRAME_FOOTPRINT_CHOOSER )
|
2020-05-22 10:31:14 +00:00
|
|
|
|| aFrame->IsType( FRAME_FOOTPRINT_EDITOR ) )
|
|
|
|
{
|
2023-01-25 16:46:49 +00:00
|
|
|
size_t padCount = GetPadCount( DO_NOT_INCLUDE_NPTH );
|
2009-10-11 13:04:47 +00:00
|
|
|
|
2023-01-25 16:46:49 +00:00
|
|
|
aList.emplace_back( _( "Library" ), GetFPID().GetLibNickname().wx_str() );
|
2007-08-06 02:02:39 +00:00
|
|
|
|
2023-01-25 16:46:49 +00:00
|
|
|
aList.emplace_back( _( "Footprint Name" ), GetFPID().GetLibItemName().wx_str() );
|
|
|
|
|
|
|
|
aList.emplace_back( _( "Pads" ), wxString::Format( wxT( "%zu" ), padCount ) );
|
|
|
|
|
2023-06-19 17:08:18 +00:00
|
|
|
aList.emplace_back( wxString::Format( _( "Doc: %s" ), GetLibDescription() ),
|
2023-05-05 13:21:56 +00:00
|
|
|
wxString::Format( _( "Keywords: %s" ), GetKeywords() ) );
|
2023-01-25 16:46:49 +00:00
|
|
|
|
|
|
|
return;
|
2020-05-22 10:31:14 +00:00
|
|
|
}
|
2007-08-06 02:02:39 +00:00
|
|
|
|
2023-01-25 16:46:49 +00:00
|
|
|
// aFrame is the board editor:
|
2024-02-04 12:54:03 +00:00
|
|
|
|
|
|
|
switch( GetSide() )
|
|
|
|
{
|
|
|
|
case F_Cu: aList.emplace_back( _( "Board Side" ), _( "Front" ) ); break;
|
|
|
|
case B_Cu: aList.emplace_back( _( "Board Side" ), _( "Back (Flipped)" ) ); break;
|
|
|
|
default: /* unsided: user-layers only, etc. */ break;
|
|
|
|
}
|
2023-01-25 16:46:49 +00:00
|
|
|
|
2020-08-26 21:43:38 +00:00
|
|
|
auto addToken = []( wxString* aStr, const wxString& aAttr )
|
2020-10-14 23:37:26 +00:00
|
|
|
{
|
|
|
|
if( !aStr->IsEmpty() )
|
|
|
|
*aStr += wxT( ", " );
|
2020-08-26 21:43:38 +00:00
|
|
|
|
2020-10-14 23:37:26 +00:00
|
|
|
*aStr += aAttr;
|
|
|
|
};
|
2020-08-26 21:43:38 +00:00
|
|
|
|
|
|
|
wxString status;
|
|
|
|
wxString attrs;
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2023-01-25 16:46:49 +00:00
|
|
|
if( IsLocked() )
|
2021-04-21 14:40:16 +00:00
|
|
|
addToken( &status, _( "Locked" ) );
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2020-11-13 11:17:15 +00:00
|
|
|
if( m_fpStatus & FP_is_PLACED )
|
2020-08-26 21:43:38 +00:00
|
|
|
addToken( &status, _( "autoplaced" ) );
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2020-11-13 02:57:11 +00:00
|
|
|
if( m_attributes & FP_BOARD_ONLY )
|
2020-08-26 21:43:38 +00:00
|
|
|
addToken( &attrs, _( "not in schematic" ) );
|
2007-08-06 02:02:39 +00:00
|
|
|
|
2020-11-13 02:57:11 +00:00
|
|
|
if( m_attributes & FP_EXCLUDE_FROM_POS_FILES )
|
2020-08-26 21:43:38 +00:00
|
|
|
addToken( &attrs, _( "exclude from pos files" ) );
|
|
|
|
|
2020-11-13 02:57:11 +00:00
|
|
|
if( m_attributes & FP_EXCLUDE_FROM_BOM )
|
2020-08-26 21:43:38 +00:00
|
|
|
addToken( &attrs, _( "exclude from BOM" ) );
|
2012-12-06 21:53:00 +00:00
|
|
|
|
2023-04-10 17:10:42 +00:00
|
|
|
if( m_attributes & FP_DNP )
|
|
|
|
addToken( &attrs, _( "DNP" ) );
|
|
|
|
|
2020-11-30 14:35:48 +00:00
|
|
|
aList.emplace_back( _( "Status: " ) + status, _( "Attributes:" ) + wxS( " " ) + attrs );
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2022-02-04 22:44:59 +00:00
|
|
|
aList.emplace_back( _( "Rotation" ), wxString::Format( wxT( "%.4g" ),
|
|
|
|
GetOrientation().AsDegrees() ) );
|
2020-07-06 13:00:36 +00:00
|
|
|
|
2021-10-10 08:05:37 +00:00
|
|
|
msg.Printf( _( "Footprint: %s" ), m_fpid.GetUniStringLibId() );
|
2020-11-30 14:35:48 +00:00
|
|
|
msg2.Printf( _( "3D-Shape: %s" ), m_3D_Drawings.empty() ? _( "<none>" )
|
|
|
|
: m_3D_Drawings.front().m_Filename );
|
|
|
|
aList.emplace_back( msg, msg2 );
|
2007-08-06 02:02:39 +00:00
|
|
|
|
2023-06-19 17:08:18 +00:00
|
|
|
msg.Printf( _( "Doc: %s" ), m_libDescription );
|
2020-11-13 02:57:11 +00:00
|
|
|
msg2.Printf( _( "Keywords: %s" ), m_keywords );
|
2020-11-30 14:35:48 +00:00
|
|
|
aList.emplace_back( msg, msg2 );
|
2007-08-06 02:02:39 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
|
2024-02-04 12:54:03 +00:00
|
|
|
PCB_LAYER_ID FOOTPRINT::GetSide() const
|
|
|
|
{
|
|
|
|
if( const BOARD* board = GetBoard() )
|
|
|
|
{
|
|
|
|
if( board->IsFootprintHolder() )
|
|
|
|
return UNDEFINED_LAYER;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Test pads first; they're the most likely to return a quick answer.
|
|
|
|
for( PAD* pad : m_pads )
|
|
|
|
{
|
|
|
|
if( ( LSET::SideSpecificMask() & pad->GetLayerSet() ).any() )
|
|
|
|
return GetLayer();
|
|
|
|
}
|
|
|
|
|
|
|
|
for( BOARD_ITEM* item : m_drawings )
|
|
|
|
{
|
|
|
|
if( LSET::SideSpecificMask().test( item->GetLayer() ) )
|
|
|
|
return GetLayer();
|
|
|
|
}
|
|
|
|
|
|
|
|
for( ZONE* zone : m_zones )
|
|
|
|
{
|
|
|
|
if( ( LSET::SideSpecificMask() & zone->GetLayerSet() ).any() )
|
|
|
|
return GetLayer();
|
|
|
|
}
|
|
|
|
|
|
|
|
return UNDEFINED_LAYER;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-08-01 17:37:19 +00:00
|
|
|
bool FOOTPRINT::IsOnLayer( PCB_LAYER_ID aLayer ) const
|
2020-11-26 19:45:22 +00:00
|
|
|
{
|
|
|
|
// If we have any pads, fall back on normal checking
|
2023-08-01 17:37:19 +00:00
|
|
|
for( PAD* pad : m_pads )
|
|
|
|
{
|
|
|
|
if( pad->IsOnLayer( aLayer ) )
|
|
|
|
return true;
|
|
|
|
}
|
2020-11-26 19:45:22 +00:00
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
for( ZONE* zone : m_zones )
|
2020-11-26 19:45:22 +00:00
|
|
|
{
|
2023-08-01 17:37:19 +00:00
|
|
|
if( zone->IsOnLayer( aLayer ) )
|
|
|
|
return true;
|
2020-11-26 19:45:22 +00:00
|
|
|
}
|
|
|
|
|
2023-05-24 12:39:25 +00:00
|
|
|
for( PCB_FIELD* field : m_fields )
|
|
|
|
{
|
2023-08-01 17:37:19 +00:00
|
|
|
if( field->IsOnLayer( aLayer ) )
|
|
|
|
return true;
|
2023-05-24 12:39:25 +00:00
|
|
|
}
|
|
|
|
|
2020-11-26 19:45:22 +00:00
|
|
|
for( BOARD_ITEM* item : m_drawings )
|
|
|
|
{
|
2023-08-01 17:37:19 +00:00
|
|
|
if( item->IsOnLayer( aLayer ) )
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool FOOTPRINT::HitTestOnLayer( const VECTOR2I& aPosition, PCB_LAYER_ID aLayer, int aAccuracy ) const
|
|
|
|
{
|
|
|
|
for( PAD* pad : m_pads )
|
|
|
|
{
|
|
|
|
if( pad->IsOnLayer( aLayer ) && pad->HitTest( aPosition, aAccuracy ) )
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
for( ZONE* zone : m_zones )
|
|
|
|
{
|
|
|
|
if( zone->IsOnLayer( aLayer ) && zone->HitTest( aPosition, aAccuracy ) )
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
for( BOARD_ITEM* item : m_drawings )
|
|
|
|
{
|
|
|
|
if( item->Type() != PCB_TEXT_T && item->IsOnLayer( aLayer )
|
|
|
|
&& item->HitTest( aPosition, aAccuracy ) )
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool FOOTPRINT::HitTestOnLayer( const BOX2I& aRect, bool aContained, PCB_LAYER_ID aLayer, int aAccuracy ) const
|
|
|
|
{
|
|
|
|
std::vector<BOARD_ITEM*> items;
|
|
|
|
|
|
|
|
for( PAD* pad : m_pads )
|
|
|
|
{
|
|
|
|
if( pad->IsOnLayer( aLayer ) )
|
|
|
|
items.push_back( pad );
|
|
|
|
}
|
|
|
|
|
|
|
|
for( ZONE* zone : m_zones )
|
|
|
|
{
|
|
|
|
if( zone->IsOnLayer( aLayer ) )
|
|
|
|
items.push_back( zone );
|
|
|
|
}
|
|
|
|
|
|
|
|
for( BOARD_ITEM* item : m_drawings )
|
|
|
|
{
|
|
|
|
if( item->Type() != PCB_TEXT_T && item->IsOnLayer( aLayer ) )
|
|
|
|
items.push_back( item );
|
|
|
|
}
|
|
|
|
|
|
|
|
// If we require the elements to be contained in the rect and any of them are not,
|
|
|
|
// we can return false;
|
|
|
|
// Conversely, if we just require any of the elements to have a hit, we can return true
|
|
|
|
// when the first one is found.
|
|
|
|
for( BOARD_ITEM* item : items )
|
|
|
|
{
|
|
|
|
if( !aContained && item->HitTest( aRect, aContained, aAccuracy ) )
|
|
|
|
return true;
|
|
|
|
else if( aContained && !item->HitTest( aRect, aContained, aAccuracy ) )
|
2020-11-26 19:45:22 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2023-08-01 17:37:19 +00:00
|
|
|
// If we didn't exit in the loop, that means that we did not return false for aContained or
|
|
|
|
// we did not return true for !aContained. So we can just return the bool with a test of
|
|
|
|
// whether there were any elements or not.
|
|
|
|
return !items.empty() && aContained;
|
2020-11-26 19:45:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
bool FOOTPRINT::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
|
2007-08-08 03:50:44 +00:00
|
|
|
{
|
2022-08-31 16:17:14 +00:00
|
|
|
BOX2I rect = GetBoundingBox( false, false );
|
2019-05-05 10:33:34 +00:00
|
|
|
return rect.Inflate( aAccuracy ).Contains( aPosition );
|
2007-08-08 03:50:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
bool FOOTPRINT::HitTestAccurate( const VECTOR2I& aPosition, int aAccuracy ) const
|
2018-02-19 00:00:29 +00:00
|
|
|
{
|
2020-11-29 14:00:39 +00:00
|
|
|
return GetBoundingHull().Collide( aPosition, aAccuracy );
|
2018-02-19 00:00:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-08-31 09:33:46 +00:00
|
|
|
bool FOOTPRINT::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
|
2008-01-06 12:43:57 +00:00
|
|
|
{
|
2022-08-31 09:33:46 +00:00
|
|
|
BOX2I arect = aRect;
|
2013-09-21 18:09:41 +00:00
|
|
|
arect.Inflate( aAccuracy );
|
2011-09-01 21:39:38 +00:00
|
|
|
|
2013-09-21 18:09:41 +00:00
|
|
|
if( aContained )
|
2021-06-23 22:58:58 +00:00
|
|
|
{
|
2021-02-26 17:44:36 +00:00
|
|
|
return arect.Contains( GetBoundingBox( false, false ) );
|
2021-06-23 22:58:58 +00:00
|
|
|
}
|
2013-09-21 18:09:41 +00:00
|
|
|
else
|
2017-05-02 06:44:41 +00:00
|
|
|
{
|
|
|
|
// If the rect does not intersect the bounding box, skip any tests
|
2021-02-26 13:49:40 +00:00
|
|
|
if( !aRect.Intersects( GetBoundingBox( false, false ) ) )
|
2017-05-02 06:44:41 +00:00
|
|
|
return false;
|
|
|
|
|
2024-01-28 14:34:10 +00:00
|
|
|
// If there are no pads, zones, or drawings, allow intersection with text
|
2023-03-30 11:49:23 +00:00
|
|
|
if( m_pads.empty() && m_zones.empty() && m_drawings.empty() )
|
2021-06-23 22:58:58 +00:00
|
|
|
return GetBoundingBox( true, false ).Intersects( arect );
|
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
// Determine if any elements in the FOOTPRINT intersect the rect
|
2020-11-12 22:30:02 +00:00
|
|
|
for( PAD* pad : m_pads )
|
2017-05-02 06:44:41 +00:00
|
|
|
{
|
|
|
|
if( pad->HitTest( arect, false, 0 ) )
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
for( ZONE* zone : m_zones )
|
2019-10-29 10:09:54 +00:00
|
|
|
{
|
|
|
|
if( zone->HitTest( arect, false, 0 ) )
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2023-06-15 19:37:07 +00:00
|
|
|
// PCB fields are selectable on their own, so they don't get tested
|
|
|
|
|
2020-06-27 18:01:00 +00:00
|
|
|
for( BOARD_ITEM* item : m_drawings )
|
2017-05-02 06:44:41 +00:00
|
|
|
{
|
2022-01-30 10:52:52 +00:00
|
|
|
// Text items are selectable on their own, and are therefore excluded from this
|
|
|
|
// test. TextBox items are NOT selectable on their own, and so MUST be included
|
2022-02-08 19:29:54 +00:00
|
|
|
// here. Bitmaps aren't selectable since they aren't displayed.
|
2023-03-30 11:49:23 +00:00
|
|
|
if( item->Type() != PCB_TEXT_T && item->HitTest( arect, false, 0 ) )
|
2017-05-02 06:44:41 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-10-03 11:16:29 +00:00
|
|
|
// Groups are not hit-tested; only their members
|
|
|
|
|
2017-05-02 06:44:41 +00:00
|
|
|
// No items were hit
|
|
|
|
return false;
|
|
|
|
}
|
2008-01-06 12:43:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-08-23 23:10:21 +00:00
|
|
|
PAD* FOOTPRINT::FindPadByNumber( const wxString& aPadNumber, PAD* aSearchAfterMe ) const
|
2008-03-04 04:22:27 +00:00
|
|
|
{
|
2021-08-16 18:52:49 +00:00
|
|
|
bool can_select = aSearchAfterMe ? false : true;
|
|
|
|
|
2020-11-12 22:30:02 +00:00
|
|
|
for( PAD* pad : m_pads )
|
2008-03-04 04:22:27 +00:00
|
|
|
{
|
2021-08-16 18:52:49 +00:00
|
|
|
if( !can_select && pad == aSearchAfterMe )
|
|
|
|
{
|
|
|
|
can_select = true;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2021-08-23 23:10:21 +00:00
|
|
|
if( can_select && pad->GetNumber() == aPadNumber )
|
2008-03-04 04:22:27 +00:00
|
|
|
return pad;
|
|
|
|
}
|
|
|
|
|
2021-04-22 21:20:34 +00:00
|
|
|
return nullptr;
|
2008-03-04 04:22:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
PAD* FOOTPRINT::GetPad( const VECTOR2I& aPosition, LSET aLayerMask )
|
2011-09-15 17:58:35 +00:00
|
|
|
{
|
2020-11-12 22:30:02 +00:00
|
|
|
for( PAD* pad : m_pads )
|
2011-09-15 17:58:35 +00:00
|
|
|
{
|
2012-02-19 04:02:19 +00:00
|
|
|
// ... and on the correct layer.
|
2014-06-24 18:30:39 +00:00
|
|
|
if( !( pad->GetLayerSet() & aLayerMask ).any() )
|
2011-09-15 17:58:35 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
if( pad->HitTest( aPosition ) )
|
|
|
|
return pad;
|
|
|
|
}
|
|
|
|
|
2021-04-22 21:20:34 +00:00
|
|
|
return nullptr;
|
2011-09-15 17:58:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-05-06 22:31:08 +00:00
|
|
|
std::vector<const PAD*> FOOTPRINT::GetPads( const wxString& aPadNumber, const PAD* aIgnore ) const
|
|
|
|
{
|
|
|
|
std::vector<const PAD*> retv;
|
|
|
|
|
|
|
|
for( const PAD* pad : m_pads )
|
|
|
|
{
|
2024-05-07 20:20:22 +00:00
|
|
|
if( ( aIgnore && aIgnore == pad ) || ( pad->GetNumber() != aPadNumber ) )
|
2024-05-06 22:31:08 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
retv.push_back( pad );
|
|
|
|
}
|
|
|
|
|
|
|
|
return retv;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
unsigned FOOTPRINT::GetPadCount( INCLUDE_NPTH_T aIncludeNPTH ) const
|
2013-06-07 13:17:52 +00:00
|
|
|
{
|
|
|
|
if( aIncludeNPTH )
|
2019-06-01 23:23:36 +00:00
|
|
|
return m_pads.size();
|
2013-06-07 13:17:52 +00:00
|
|
|
|
|
|
|
unsigned cnt = 0;
|
|
|
|
|
2020-11-12 22:30:02 +00:00
|
|
|
for( PAD* pad : m_pads )
|
2013-06-07 13:17:52 +00:00
|
|
|
{
|
2021-05-01 14:46:50 +00:00
|
|
|
if( pad->GetAttribute() == PAD_ATTRIB::NPTH )
|
2013-06-07 13:17:52 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
cnt++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return cnt;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-03-09 11:58:23 +00:00
|
|
|
std::set<wxString> FOOTPRINT::GetUniquePadNumbers( INCLUDE_NPTH_T aIncludeNPTH ) const
|
2015-11-11 18:35:26 +00:00
|
|
|
{
|
2021-08-23 23:10:21 +00:00
|
|
|
std::set<wxString> usedNumbers;
|
2015-11-11 18:35:26 +00:00
|
|
|
|
|
|
|
// Create a set of used pad numbers
|
2020-11-12 22:30:02 +00:00
|
|
|
for( PAD* pad : m_pads )
|
2015-11-11 18:35:26 +00:00
|
|
|
{
|
2015-11-13 11:32:42 +00:00
|
|
|
// Skip pads not on copper layers (used to build complex
|
|
|
|
// solder paste shapes for instance)
|
|
|
|
if( ( pad->GetLayerSet() & LSET::AllCuMask() ).none() )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// Skip pads with no name, because they are usually "mechanical"
|
|
|
|
// pads, not "electrical" pads
|
2021-08-23 23:10:21 +00:00
|
|
|
if( pad->GetNumber().IsEmpty() )
|
2015-11-13 11:32:42 +00:00
|
|
|
continue;
|
|
|
|
|
2015-11-11 18:35:26 +00:00
|
|
|
if( !aIncludeNPTH )
|
|
|
|
{
|
2015-11-13 11:32:42 +00:00
|
|
|
// skip NPTH
|
2021-05-01 14:46:50 +00:00
|
|
|
if( pad->GetAttribute() == PAD_ATTRIB::NPTH )
|
2015-11-11 18:35:26 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2021-08-23 23:10:21 +00:00
|
|
|
usedNumbers.insert( pad->GetNumber() );
|
2015-11-11 18:35:26 +00:00
|
|
|
}
|
|
|
|
|
2024-03-09 11:58:23 +00:00
|
|
|
return usedNumbers;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
unsigned FOOTPRINT::GetUniquePadCount( INCLUDE_NPTH_T aIncludeNPTH ) const
|
|
|
|
{
|
|
|
|
return GetUniquePadNumbers( aIncludeNPTH ).size();
|
2015-11-11 18:35:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
void FOOTPRINT::Add3DModel( FP_3DMODEL* a3DModel )
|
2012-06-09 17:00:13 +00:00
|
|
|
{
|
2020-12-28 16:13:15 +00:00
|
|
|
if( nullptr == a3DModel )
|
2016-07-19 17:35:25 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if( !a3DModel->m_Filename.empty() )
|
|
|
|
m_3D_Drawings.push_back( *a3DModel );
|
2012-06-09 17:00:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-13 02:57:11 +00:00
|
|
|
// see footprint.h
|
2022-08-20 09:27:35 +00:00
|
|
|
INSPECT_RESULT FOOTPRINT::Visit( INSPECTOR inspector, void* testData,
|
2022-08-21 19:54:07 +00:00
|
|
|
const std::vector<KICAD_T>& aScanTypes )
|
2007-08-09 21:15:08 +00:00
|
|
|
{
|
2009-11-04 19:08:08 +00:00
|
|
|
#if 0 && defined(DEBUG)
|
2008-03-15 10:24:32 +00:00
|
|
|
std::cout << GetClass().mb_str() << ' ';
|
2008-02-19 00:30:10 +00:00
|
|
|
#endif
|
2007-08-09 21:15:08 +00:00
|
|
|
|
2022-08-20 09:27:35 +00:00
|
|
|
bool drawingsScanned = false;
|
2008-03-15 10:24:32 +00:00
|
|
|
|
2022-08-20 09:27:35 +00:00
|
|
|
for( KICAD_T scanType : aScanTypes )
|
|
|
|
{
|
|
|
|
switch( scanType )
|
2007-08-09 21:15:08 +00:00
|
|
|
{
|
2020-11-13 12:21:02 +00:00
|
|
|
case PCB_FOOTPRINT_T:
|
2022-08-20 09:27:35 +00:00
|
|
|
if( inspector( this, testData ) == INSPECT_RESULT::QUIT )
|
|
|
|
return INSPECT_RESULT::QUIT;
|
|
|
|
|
2007-08-09 21:15:08 +00:00
|
|
|
break;
|
2008-02-19 00:30:10 +00:00
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_PAD_T:
|
2022-08-20 09:27:35 +00:00
|
|
|
if( IterateForward<PAD*>( m_pads, inspector, testData, { scanType } )
|
|
|
|
== INSPECT_RESULT::QUIT )
|
|
|
|
{
|
|
|
|
return INSPECT_RESULT::QUIT;
|
|
|
|
}
|
|
|
|
|
2007-08-09 21:15:08 +00:00
|
|
|
break;
|
2008-02-19 00:30:10 +00:00
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
case PCB_ZONE_T:
|
|
|
|
if( IterateForward<ZONE*>( m_zones, inspector, testData, { scanType } )
|
2022-08-20 09:27:35 +00:00
|
|
|
== INSPECT_RESULT::QUIT )
|
|
|
|
{
|
|
|
|
return INSPECT_RESULT::QUIT;
|
|
|
|
}
|
|
|
|
|
2019-10-29 10:09:54 +00:00
|
|
|
break;
|
|
|
|
|
2023-06-06 15:09:34 +00:00
|
|
|
case PCB_FIELD_T:
|
2023-06-15 19:37:07 +00:00
|
|
|
if( IterateForward<PCB_FIELD*>( m_fields, inspector, testData, { scanType } )
|
|
|
|
== INSPECT_RESULT::QUIT )
|
|
|
|
{
|
2022-08-20 09:27:35 +00:00
|
|
|
return INSPECT_RESULT::QUIT;
|
2023-06-15 19:37:07 +00:00
|
|
|
}
|
2008-02-19 00:30:10 +00:00
|
|
|
|
2023-06-06 15:09:34 +00:00
|
|
|
break;
|
2008-02-19 00:30:10 +00:00
|
|
|
|
2023-06-06 15:09:34 +00:00
|
|
|
case PCB_TEXT_T:
|
2023-03-30 11:49:23 +00:00
|
|
|
case PCB_DIM_ALIGNED_T:
|
|
|
|
case PCB_DIM_LEADER_T:
|
|
|
|
case PCB_DIM_CENTER_T:
|
|
|
|
case PCB_DIM_RADIAL_T:
|
|
|
|
case PCB_DIM_ORTHOGONAL_T:
|
|
|
|
case PCB_SHAPE_T:
|
|
|
|
case PCB_TEXTBOX_T:
|
2022-08-20 09:27:35 +00:00
|
|
|
if( !drawingsScanned )
|
2007-08-24 03:40:04 +00:00
|
|
|
{
|
2022-08-20 09:27:35 +00:00
|
|
|
if( IterateForward<BOARD_ITEM*>( m_drawings, inspector, testData, aScanTypes )
|
|
|
|
== INSPECT_RESULT::QUIT )
|
2007-08-24 03:40:04 +00:00
|
|
|
{
|
2022-08-20 09:27:35 +00:00
|
|
|
return INSPECT_RESULT::QUIT;
|
2007-08-24 03:40:04 +00:00
|
|
|
}
|
2008-03-15 10:24:32 +00:00
|
|
|
|
2022-08-20 09:27:35 +00:00
|
|
|
drawingsScanned = true;
|
2007-08-24 03:40:04 +00:00
|
|
|
}
|
2008-03-15 10:24:32 +00:00
|
|
|
|
2007-08-09 21:15:08 +00:00
|
|
|
break;
|
2008-02-19 00:30:10 +00:00
|
|
|
|
2020-10-03 11:16:29 +00:00
|
|
|
case PCB_GROUP_T:
|
2023-03-30 11:49:23 +00:00
|
|
|
if( IterateForward<PCB_GROUP*>( m_groups, inspector, testData, { scanType } )
|
2022-08-20 09:27:35 +00:00
|
|
|
== INSPECT_RESULT::QUIT )
|
|
|
|
{
|
|
|
|
return INSPECT_RESULT::QUIT;
|
|
|
|
}
|
|
|
|
|
2020-10-03 11:16:29 +00:00
|
|
|
break;
|
|
|
|
|
2007-08-09 21:15:08 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-20 09:27:35 +00:00
|
|
|
return INSPECT_RESULT::CONTINUE;
|
2007-08-09 21:15:08 +00:00
|
|
|
}
|
|
|
|
|
2007-08-08 03:50:44 +00:00
|
|
|
|
2023-01-12 03:27:44 +00:00
|
|
|
wxString FOOTPRINT::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const
|
2011-07-14 15:42:44 +00:00
|
|
|
{
|
2018-01-31 09:08:57 +00:00
|
|
|
wxString reference = GetReference();
|
|
|
|
|
|
|
|
if( reference.IsEmpty() )
|
2020-03-17 16:08:29 +00:00
|
|
|
reference = _( "<no reference designator>" );
|
2018-01-31 09:08:57 +00:00
|
|
|
|
2020-09-19 16:12:00 +00:00
|
|
|
return wxString::Format( _( "Footprint %s" ), reference );
|
2011-07-14 15:42:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-03-08 02:59:07 +00:00
|
|
|
BITMAPS FOOTPRINT::GetMenuImage() const
|
2017-02-20 12:20:39 +00:00
|
|
|
{
|
2021-03-08 02:59:07 +00:00
|
|
|
return BITMAPS::module;
|
2017-02-20 12:20:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
EDA_ITEM* FOOTPRINT::Clone() const
|
2012-01-14 19:50:32 +00:00
|
|
|
{
|
2020-11-13 15:15:52 +00:00
|
|
|
return new FOOTPRINT( *this );
|
2012-01-14 19:50:32 +00:00
|
|
|
}
|
|
|
|
|
2013-04-25 16:29:35 +00:00
|
|
|
|
2023-11-09 13:55:00 +00:00
|
|
|
void FOOTPRINT::RunOnChildren( const std::function<void ( BOARD_ITEM* )>& aFunction ) const
|
2013-12-18 12:39:11 +00:00
|
|
|
{
|
2015-02-15 22:21:52 +00:00
|
|
|
try
|
|
|
|
{
|
2023-05-24 12:39:25 +00:00
|
|
|
for( PCB_FIELD* field : m_fields )
|
2023-11-09 13:55:00 +00:00
|
|
|
aFunction( field );
|
2023-05-24 12:39:25 +00:00
|
|
|
|
2020-11-12 22:30:02 +00:00
|
|
|
for( PAD* pad : m_pads )
|
2023-11-09 13:55:00 +00:00
|
|
|
aFunction( pad );
|
2013-12-18 12:39:11 +00:00
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
for( ZONE* zone : m_zones )
|
2023-11-09 13:55:00 +00:00
|
|
|
aFunction( zone );
|
2019-10-29 10:09:54 +00:00
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
for( PCB_GROUP* group : m_groups )
|
2023-11-09 13:55:00 +00:00
|
|
|
aFunction( group );
|
2020-10-03 11:16:29 +00:00
|
|
|
|
2020-06-27 18:01:00 +00:00
|
|
|
for( BOARD_ITEM* drawing : m_drawings )
|
2023-11-09 13:55:00 +00:00
|
|
|
aFunction( drawing );
|
2015-02-15 22:21:52 +00:00
|
|
|
}
|
2016-10-10 15:04:48 +00:00
|
|
|
catch( std::bad_function_call& )
|
2015-02-15 22:21:52 +00:00
|
|
|
{
|
2022-02-04 22:44:59 +00:00
|
|
|
wxFAIL_MSG( wxT( "Error running FOOTPRINT::RunOnChildren" ) );
|
2015-02-15 22:21:52 +00:00
|
|
|
}
|
2013-12-18 12:39:11 +00:00
|
|
|
}
|
|
|
|
|
2018-03-08 01:40:50 +00:00
|
|
|
|
2024-01-22 23:32:13 +00:00
|
|
|
void FOOTPRINT::RunOnDescendants( const std::function<void( BOARD_ITEM* )>& aFunction,
|
|
|
|
int aDepth ) const
|
2023-11-09 13:55:00 +00:00
|
|
|
{
|
2024-01-22 23:32:13 +00:00
|
|
|
// Avoid freezes with infinite recursion
|
|
|
|
if( aDepth > 20 )
|
|
|
|
return;
|
|
|
|
|
2023-11-09 13:55:00 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
for( PCB_FIELD* field : m_fields )
|
|
|
|
aFunction( field );
|
|
|
|
|
|
|
|
for( PAD* pad : m_pads )
|
|
|
|
aFunction( pad );
|
|
|
|
|
|
|
|
for( ZONE* zone : m_zones )
|
|
|
|
aFunction( zone );
|
|
|
|
|
|
|
|
for( PCB_GROUP* group : m_groups )
|
|
|
|
{
|
|
|
|
aFunction( group );
|
2024-01-22 23:32:13 +00:00
|
|
|
group->RunOnDescendants( aFunction, aDepth + 1 );
|
2023-11-09 13:55:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for( BOARD_ITEM* drawing : m_drawings )
|
|
|
|
{
|
|
|
|
aFunction( drawing );
|
2024-01-22 23:32:13 +00:00
|
|
|
drawing->RunOnDescendants( aFunction, aDepth + 1 );
|
2023-11-09 13:55:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( std::bad_function_call& )
|
|
|
|
{
|
|
|
|
wxFAIL_MSG( wxT( "Error running FOOTPRINT::RunOnDescendants" ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
void FOOTPRINT::ViewGetLayers( int aLayers[], int& aCount ) const
|
2014-07-09 13:02:56 +00:00
|
|
|
{
|
2014-08-04 08:06:24 +00:00
|
|
|
aCount = 2;
|
2017-03-13 03:19:33 +00:00
|
|
|
aLayers[0] = LAYER_ANCHOR;
|
2014-08-04 08:06:24 +00:00
|
|
|
|
2020-11-14 14:29:11 +00:00
|
|
|
switch( m_layer )
|
2014-08-04 08:06:24 +00:00
|
|
|
{
|
2016-03-13 15:39:18 +00:00
|
|
|
default:
|
2022-02-04 22:44:59 +00:00
|
|
|
wxASSERT_MSG( false, wxT( "Illegal layer" ) ); // do you really have footprints placed
|
|
|
|
// on other layers?
|
2020-04-24 23:44:09 +00:00
|
|
|
KI_FALLTHROUGH;
|
|
|
|
|
2014-08-04 08:06:24 +00:00
|
|
|
case F_Cu:
|
2023-08-04 10:13:20 +00:00
|
|
|
aLayers[1] = LAYER_FOOTPRINTS_FR;
|
2014-08-04 08:06:24 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case B_Cu:
|
2023-08-04 10:13:20 +00:00
|
|
|
aLayers[1] = LAYER_FOOTPRINTS_BK;
|
2014-08-04 08:06:24 +00:00
|
|
|
break;
|
|
|
|
}
|
2018-01-04 22:39:36 +00:00
|
|
|
|
2022-03-07 17:03:06 +00:00
|
|
|
if( IsLocked() )
|
|
|
|
aLayers[ aCount++ ] = LAYER_LOCKED_ITEM_SHADOW;
|
2022-03-06 19:11:03 +00:00
|
|
|
|
2022-05-20 09:08:33 +00:00
|
|
|
if( IsConflicting() )
|
|
|
|
aLayers[ aCount++ ] = LAYER_CONFLICTS_SHADOW;
|
|
|
|
|
2020-08-30 21:20:37 +00:00
|
|
|
// If there are no pads, and only drawings on a silkscreen layer, then report the silkscreen
|
|
|
|
// layer as well so that the component can be edited with the silkscreen layer
|
2018-01-04 22:39:36 +00:00
|
|
|
bool f_silk = false, b_silk = false, non_silk = false;
|
|
|
|
|
2020-10-14 23:37:26 +00:00
|
|
|
for( BOARD_ITEM* item : m_drawings )
|
2018-01-04 22:39:36 +00:00
|
|
|
{
|
|
|
|
if( item->GetLayer() == F_SilkS )
|
|
|
|
f_silk = true;
|
|
|
|
else if( item->GetLayer() == B_SilkS )
|
|
|
|
b_silk = true;
|
|
|
|
else
|
|
|
|
non_silk = true;
|
|
|
|
}
|
|
|
|
|
2019-06-01 23:23:36 +00:00
|
|
|
if( ( f_silk || b_silk ) && !non_silk && m_pads.empty() )
|
2018-01-04 22:39:36 +00:00
|
|
|
{
|
|
|
|
if( f_silk )
|
|
|
|
aLayers[ aCount++ ] = F_SilkS;
|
|
|
|
|
|
|
|
if( b_silk )
|
|
|
|
aLayers[ aCount++ ] = B_SilkS;
|
|
|
|
}
|
2014-07-09 13:02:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
double FOOTPRINT::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
|
2014-07-09 13:02:56 +00:00
|
|
|
{
|
2022-03-06 19:11:03 +00:00
|
|
|
if( aLayer == LAYER_LOCKED_ITEM_SHADOW )
|
2022-04-12 09:17:04 +00:00
|
|
|
{
|
|
|
|
// The locked shadow shape is shown only if the footprint itself is visible
|
2023-08-04 10:13:20 +00:00
|
|
|
if( ( m_layer == F_Cu ) && aView->IsLayerVisible( LAYER_FOOTPRINTS_FR ) )
|
2022-04-12 09:17:04 +00:00
|
|
|
return 0.0;
|
|
|
|
|
2023-08-04 10:13:20 +00:00
|
|
|
if( ( m_layer == B_Cu ) && aView->IsLayerVisible( LAYER_FOOTPRINTS_BK ) )
|
2022-04-12 09:17:04 +00:00
|
|
|
return 0.0;
|
|
|
|
|
|
|
|
return std::numeric_limits<double>::max();
|
|
|
|
}
|
2022-03-06 19:11:03 +00:00
|
|
|
|
2022-05-20 09:08:33 +00:00
|
|
|
if( aLayer == LAYER_CONFLICTS_SHADOW && IsConflicting() )
|
|
|
|
{
|
|
|
|
// The locked shadow shape is shown only if the footprint itself is visible
|
2023-08-04 10:13:20 +00:00
|
|
|
if( ( m_layer == F_Cu ) && aView->IsLayerVisible( LAYER_FOOTPRINTS_FR ) )
|
2022-05-20 09:08:33 +00:00
|
|
|
return 0.0;
|
|
|
|
|
2023-08-04 10:13:20 +00:00
|
|
|
if( ( m_layer == B_Cu ) && aView->IsLayerVisible( LAYER_FOOTPRINTS_BK ) )
|
2022-05-20 09:08:33 +00:00
|
|
|
return 0.0;
|
|
|
|
|
|
|
|
return std::numeric_limits<double>::max();
|
|
|
|
}
|
|
|
|
|
2023-08-04 10:13:20 +00:00
|
|
|
int layer = ( m_layer == F_Cu ) ? LAYER_FOOTPRINTS_FR :
|
|
|
|
( m_layer == B_Cu ) ? LAYER_FOOTPRINTS_BK : LAYER_ANCHOR;
|
2016-06-07 13:07:47 +00:00
|
|
|
|
2020-08-30 21:20:37 +00:00
|
|
|
// Currently this is only pertinent for the anchor layer; everything else is drawn from the
|
|
|
|
// children.
|
2020-09-21 15:03:08 +00:00
|
|
|
// The "good" value is experimentally chosen.
|
|
|
|
#define MINIMAL_ZOOM_LEVEL_FOR_VISIBILITY 1.5
|
2020-09-21 06:56:53 +00:00
|
|
|
|
2017-03-13 03:19:33 +00:00
|
|
|
if( aView->IsLayerVisible( layer ) )
|
2020-09-21 06:56:53 +00:00
|
|
|
return MINIMAL_ZOOM_LEVEL_FOR_VISIBILITY;
|
2016-06-07 13:07:47 +00:00
|
|
|
|
2020-09-21 15:03:08 +00:00
|
|
|
return std::numeric_limits<double>::max();
|
2014-07-09 13:02:56 +00:00
|
|
|
}
|
|
|
|
|
2015-06-16 15:03:36 +00:00
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
const BOX2I FOOTPRINT::ViewBBox() const
|
2014-11-13 16:32:59 +00:00
|
|
|
{
|
2022-08-31 16:17:14 +00:00
|
|
|
BOX2I area = GetBoundingBox( true, true );
|
2018-06-12 15:37:02 +00:00
|
|
|
|
2023-03-13 22:44:31 +00:00
|
|
|
// Inflate in case clearance lines are drawn around pads, etc.
|
|
|
|
if( const BOARD* board = GetBoard() )
|
2018-06-12 15:37:02 +00:00
|
|
|
{
|
2023-07-26 19:36:13 +00:00
|
|
|
int biggest_clearance = board->GetMaxClearanceValue();
|
2018-06-12 15:37:02 +00:00
|
|
|
area.Inflate( biggest_clearance );
|
|
|
|
}
|
|
|
|
|
2018-01-30 06:45:53 +00:00
|
|
|
return area;
|
2014-11-13 16:32:59 +00:00
|
|
|
}
|
2014-07-09 13:02:56 +00:00
|
|
|
|
2015-06-16 15:03:36 +00:00
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
bool FOOTPRINT::IsLibNameValid( const wxString & aName )
|
2012-12-10 11:18:42 +00:00
|
|
|
{
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
const wxChar * invalids = StringLibNameInvalidChars( false );
|
2012-12-10 11:18:42 +00:00
|
|
|
|
|
|
|
if( aName.find_first_of( invalids ) != std::string::npos )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
const wxChar* FOOTPRINT::StringLibNameInvalidChars( bool aUserReadable )
|
2012-12-10 11:18:42 +00:00
|
|
|
{
|
2019-06-29 20:31:11 +00:00
|
|
|
// This list of characters is also duplicated in validators.cpp and
|
|
|
|
// lib_id.cpp
|
2022-08-18 19:49:40 +00:00
|
|
|
// TODO: Unify forbidden character lists - Warning, invalid filename characters are not the same
|
|
|
|
// as invalid LIB_ID characters. We will need to separate the FP filenames from FP names before this
|
|
|
|
// can be unified
|
2019-06-29 20:31:11 +00:00
|
|
|
static const wxChar invalidChars[] = wxT("%$<>\t\n\r\"\\/:");
|
|
|
|
static const wxChar invalidCharsReadable[] = wxT("% $ < > 'tab' 'return' 'line feed' \\ \" / :");
|
2012-12-10 11:18:42 +00:00
|
|
|
|
|
|
|
if( aUserReadable )
|
|
|
|
return invalidCharsReadable;
|
|
|
|
else
|
|
|
|
return invalidChars;
|
|
|
|
}
|
|
|
|
|
2012-01-14 19:50:32 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
void FOOTPRINT::Move( const VECTOR2I& aMoveVector )
|
2013-03-13 18:53:58 +00:00
|
|
|
{
|
2023-12-22 21:20:36 +00:00
|
|
|
if( aMoveVector.x == 0 && aMoveVector.y == 0 )
|
|
|
|
return;
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I newpos = m_pos + aMoveVector;
|
2013-03-13 18:53:58 +00:00
|
|
|
SetPosition( newpos );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-13 19:32:00 +00:00
|
|
|
void FOOTPRINT::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle )
|
2013-03-13 18:53:58 +00:00
|
|
|
{
|
2023-12-22 21:20:36 +00:00
|
|
|
if( aAngle == ANGLE_0 )
|
|
|
|
return;
|
|
|
|
|
2022-01-13 19:32:00 +00:00
|
|
|
EDA_ANGLE orientation = GetOrientation();
|
|
|
|
EDA_ANGLE newOrientation = orientation + aAngle;
|
|
|
|
VECTOR2I newpos = m_pos;
|
2022-01-01 06:04:08 +00:00
|
|
|
RotatePoint( newpos, aRotCentre, aAngle );
|
2013-03-13 18:53:58 +00:00
|
|
|
SetPosition( newpos );
|
2022-01-13 19:32:00 +00:00
|
|
|
SetOrientation( newOrientation );
|
2019-04-07 21:09:50 +00:00
|
|
|
|
2023-05-24 12:39:25 +00:00
|
|
|
for( PCB_FIELD* field : m_fields )
|
2023-12-22 21:20:36 +00:00
|
|
|
field->KeepUpright( newOrientation );
|
2019-04-07 21:09:50 +00:00
|
|
|
|
2020-06-27 18:01:00 +00:00
|
|
|
for( BOARD_ITEM* item : m_drawings )
|
2019-04-07 21:09:50 +00:00
|
|
|
{
|
2023-03-30 11:49:23 +00:00
|
|
|
if( item->Type() == PCB_TEXT_T )
|
2023-12-22 21:20:36 +00:00
|
|
|
static_cast<PCB_TEXT*>( item )->KeepUpright( newOrientation );
|
2019-04-07 21:09:50 +00:00
|
|
|
}
|
2021-02-26 13:49:40 +00:00
|
|
|
|
|
|
|
m_boundingBoxCacheTimeStamp = 0;
|
|
|
|
m_visibleBBoxCacheTimeStamp = 0;
|
|
|
|
m_textExcludedBBoxCacheTimeStamp = 0;
|
|
|
|
m_hullCacheTimeStamp = 0;
|
2022-11-30 08:07:32 +00:00
|
|
|
m_courtyard_cache_timestamp = 0;
|
2013-03-13 18:53:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-11-25 03:11:26 +00:00
|
|
|
void FOOTPRINT::SetLayerAndFlip( PCB_LAYER_ID aLayer )
|
|
|
|
{
|
|
|
|
wxASSERT( aLayer == F_Cu || aLayer == B_Cu );
|
|
|
|
|
|
|
|
if( aLayer != GetLayer() )
|
|
|
|
Flip( GetPosition(), true );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
void FOOTPRINT::Flip( const VECTOR2I& aCentre, bool aFlipLeftRight )
|
2013-03-13 18:53:58 +00:00
|
|
|
{
|
2020-10-14 23:37:26 +00:00
|
|
|
// Move footprint to its final position:
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I finalPos = m_pos;
|
2019-07-12 21:02:10 +00:00
|
|
|
|
2019-09-17 16:51:27 +00:00
|
|
|
// Now Flip the footprint.
|
2020-11-13 02:57:11 +00:00
|
|
|
// Flipping a footprint is a specific transform: it is not mirrored like a text.
|
|
|
|
// We have to change the side, and ensure the footprint rotation is modified according to the
|
|
|
|
// transform, because this parameter is used in pick and place files, and when updating the
|
|
|
|
// footprint from library.
|
2019-09-17 16:51:27 +00:00
|
|
|
// When flipped around the X axis (Y coordinates changed) orientation is negated
|
|
|
|
// When flipped around the Y axis (X coordinates changed) orientation is 180 - old orient.
|
2021-06-09 19:32:58 +00:00
|
|
|
// Because it is specific to a footprint, we flip around the X axis, and after rotate 180 deg
|
2019-09-17 16:51:27 +00:00
|
|
|
|
|
|
|
MIRROR( finalPos.y, aCentre.y ); /// Mirror the Y position (around the X axis)
|
2019-07-12 21:02:10 +00:00
|
|
|
|
2013-03-13 18:53:58 +00:00
|
|
|
SetPosition( finalPos );
|
|
|
|
|
|
|
|
// Flip layer
|
2022-11-25 03:11:26 +00:00
|
|
|
BOARD_ITEM::SetLayer( FlipLayer( GetLayer() ) );
|
2013-03-13 18:53:58 +00:00
|
|
|
|
2023-05-31 10:13:04 +00:00
|
|
|
// Calculate the new orientation, and then clear it for pad flipping.
|
|
|
|
EDA_ANGLE newOrientation = -m_orient;
|
|
|
|
newOrientation.Normalize180();
|
|
|
|
m_orient = ANGLE_0;
|
2013-03-13 18:53:58 +00:00
|
|
|
|
2023-05-24 12:39:25 +00:00
|
|
|
// Mirror fields to other side of board.
|
|
|
|
for( PCB_FIELD* field : m_fields )
|
|
|
|
field->Flip( m_pos, false );
|
|
|
|
|
2019-07-12 21:02:10 +00:00
|
|
|
// Mirror pads to other side of board.
|
2020-11-12 22:30:02 +00:00
|
|
|
for( PAD* pad : m_pads )
|
2020-11-13 02:57:11 +00:00
|
|
|
pad->Flip( m_pos, false );
|
2013-03-13 18:53:58 +00:00
|
|
|
|
2023-05-31 10:13:04 +00:00
|
|
|
// Now set the new orientation.
|
|
|
|
m_orient = newOrientation;
|
|
|
|
|
2019-10-29 10:09:54 +00:00
|
|
|
// Mirror zones to other side of board.
|
2023-03-30 11:49:23 +00:00
|
|
|
for( ZONE* zone : m_zones )
|
2021-02-02 00:07:04 +00:00
|
|
|
zone->Flip( m_pos, false );
|
2019-10-29 10:09:54 +00:00
|
|
|
|
2020-11-13 11:17:15 +00:00
|
|
|
// Reverse mirror footprint graphics and texts.
|
2020-10-14 23:37:26 +00:00
|
|
|
for( BOARD_ITEM* item : m_drawings )
|
2023-03-30 11:49:23 +00:00
|
|
|
item->Flip( m_pos, false );
|
2013-03-13 18:53:58 +00:00
|
|
|
|
2019-09-17 16:51:27 +00:00
|
|
|
// Now rotate 180 deg if required
|
|
|
|
if( aFlipLeftRight )
|
2022-01-13 19:32:00 +00:00
|
|
|
Rotate( aCentre, ANGLE_180 );
|
2019-09-17 16:51:27 +00:00
|
|
|
|
2021-02-26 13:49:40 +00:00
|
|
|
m_boundingBoxCacheTimeStamp = 0;
|
|
|
|
m_visibleBBoxCacheTimeStamp = 0;
|
|
|
|
m_textExcludedBBoxCacheTimeStamp = 0;
|
2022-11-30 08:07:32 +00:00
|
|
|
m_courtyard_cache_timestamp = 0;
|
2021-01-31 14:32:14 +00:00
|
|
|
|
2021-02-26 13:49:40 +00:00
|
|
|
m_cachedHull.Mirror( aFlipLeftRight, !aFlipLeftRight, m_pos );
|
2021-02-20 13:25:02 +00:00
|
|
|
|
2022-07-31 21:14:24 +00:00
|
|
|
std::swap( m_courtyard_cache_front, m_courtyard_cache_back );
|
2013-03-13 18:53:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
void FOOTPRINT::SetPosition( const VECTOR2I& aPos )
|
2013-03-13 18:53:58 +00:00
|
|
|
{
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I delta = aPos - m_pos;
|
2013-03-13 18:53:58 +00:00
|
|
|
|
2020-11-13 02:57:11 +00:00
|
|
|
m_pos += delta;
|
2017-01-23 20:30:11 +00:00
|
|
|
|
2023-05-24 12:39:25 +00:00
|
|
|
for( PCB_FIELD* field : m_fields )
|
|
|
|
field->EDA_TEXT::Offset( delta );
|
2013-03-13 18:53:58 +00:00
|
|
|
|
2020-11-12 22:30:02 +00:00
|
|
|
for( PAD* pad : m_pads )
|
2013-03-13 18:53:58 +00:00
|
|
|
pad->SetPosition( pad->GetPosition() + delta );
|
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
for( ZONE* zone : m_zones )
|
2019-10-29 10:09:54 +00:00
|
|
|
zone->Move( delta );
|
|
|
|
|
2020-10-14 23:37:26 +00:00
|
|
|
for( BOARD_ITEM* item : m_drawings )
|
2023-03-30 11:49:23 +00:00
|
|
|
item->Move( delta );
|
2013-03-13 18:53:58 +00:00
|
|
|
|
2021-02-26 13:49:40 +00:00
|
|
|
m_cachedBoundingBox.Move( delta );
|
|
|
|
m_cachedVisibleBBox.Move( delta );
|
|
|
|
m_cachedTextExcludedBBox.Move( delta );
|
2022-11-25 17:19:27 +00:00
|
|
|
m_courtyard_cache_back.Move( delta );
|
|
|
|
m_courtyard_cache_front.Move( delta );
|
2021-02-26 13:49:40 +00:00
|
|
|
m_cachedHull.Move( delta );
|
2013-03-13 18:53:58 +00:00
|
|
|
}
|
|
|
|
|
2013-04-25 16:29:35 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
void FOOTPRINT::MoveAnchorPosition( const VECTOR2I& aMoveVector )
|
2013-03-23 13:30:00 +00:00
|
|
|
{
|
2022-01-30 10:52:52 +00:00
|
|
|
/*
|
|
|
|
* Move the reference point of the footprint
|
2013-03-23 13:30:00 +00:00
|
|
|
* the footprints elements (pads, outlines, edges .. ) are moved
|
|
|
|
* but:
|
|
|
|
* - the footprint position is not modified.
|
|
|
|
* - the relative (local) coordinates of these items are modified
|
2015-03-02 08:28:49 +00:00
|
|
|
* - Draw coordinates are updated
|
2013-03-23 13:30:00 +00:00
|
|
|
*/
|
|
|
|
|
2015-03-02 08:28:49 +00:00
|
|
|
// Update (move) the relative coordinates relative to the new anchor point.
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I moveVector = aMoveVector;
|
|
|
|
RotatePoint( moveVector, -GetOrientation() );
|
2013-03-23 13:30:00 +00:00
|
|
|
|
2023-05-24 12:39:25 +00:00
|
|
|
// Update field local coordinates
|
|
|
|
for( PCB_FIELD* field : m_fields )
|
|
|
|
field->Move( moveVector );
|
2013-03-23 13:30:00 +00:00
|
|
|
|
|
|
|
// Update the pad local coordinates.
|
2020-11-12 22:30:02 +00:00
|
|
|
for( PAD* pad : m_pads )
|
2023-04-02 17:02:41 +00:00
|
|
|
pad->Move( moveVector );
|
2013-03-23 13:30:00 +00:00
|
|
|
|
|
|
|
// Update the draw element coordinates.
|
2020-10-03 11:16:29 +00:00
|
|
|
for( BOARD_ITEM* item : GraphicalItems() )
|
2023-03-30 11:49:23 +00:00
|
|
|
item->Move( moveVector );
|
2013-03-23 13:30:00 +00:00
|
|
|
|
2021-03-07 14:53:27 +00:00
|
|
|
// Update the keepout zones
|
|
|
|
for( ZONE* zone : Zones() )
|
|
|
|
zone->Move( moveVector );
|
|
|
|
|
2021-03-12 17:37:09 +00:00
|
|
|
// Update the 3D models
|
|
|
|
for( FP_3DMODEL& model : Models() )
|
|
|
|
{
|
2022-09-16 11:33:56 +00:00
|
|
|
model.m_Offset.x += pcbIUScale.IUTomm( moveVector.x );
|
|
|
|
model.m_Offset.y -= pcbIUScale.IUTomm( moveVector.y );
|
2021-03-12 17:37:09 +00:00
|
|
|
}
|
|
|
|
|
2021-02-26 13:49:40 +00:00
|
|
|
m_cachedBoundingBox.Move( moveVector );
|
|
|
|
m_cachedVisibleBBox.Move( moveVector );
|
|
|
|
m_cachedTextExcludedBBox.Move( moveVector );
|
|
|
|
m_cachedHull.Move( moveVector );
|
2013-03-23 13:30:00 +00:00
|
|
|
}
|
2013-03-13 18:53:58 +00:00
|
|
|
|
2013-04-25 16:29:35 +00:00
|
|
|
|
2022-01-13 17:27:36 +00:00
|
|
|
void FOOTPRINT::SetOrientation( const EDA_ANGLE& aNewAngle )
|
2013-03-13 18:53:58 +00:00
|
|
|
{
|
2022-01-13 17:27:36 +00:00
|
|
|
EDA_ANGLE angleChange = aNewAngle - m_orient; // change in rotation
|
2013-03-13 18:53:58 +00:00
|
|
|
|
2020-11-13 02:57:11 +00:00
|
|
|
m_orient = aNewAngle;
|
2022-01-13 17:27:36 +00:00
|
|
|
m_orient.Normalize180();
|
2013-03-13 18:53:58 +00:00
|
|
|
|
2023-05-24 12:39:25 +00:00
|
|
|
for( PCB_FIELD* field : m_fields )
|
|
|
|
field->Rotate( GetPosition(), angleChange );
|
|
|
|
|
2020-11-12 22:30:02 +00:00
|
|
|
for( PAD* pad : m_pads )
|
2023-04-02 17:02:41 +00:00
|
|
|
pad->Rotate( GetPosition(), angleChange );
|
2013-03-13 18:53:58 +00:00
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
for( ZONE* zone : m_zones )
|
2022-01-13 19:32:00 +00:00
|
|
|
zone->Rotate( GetPosition(), angleChange );
|
2019-10-29 10:09:54 +00:00
|
|
|
|
2020-10-03 11:16:29 +00:00
|
|
|
for( BOARD_ITEM* item : m_drawings )
|
2023-03-30 11:49:23 +00:00
|
|
|
item->Rotate( GetPosition(), angleChange );
|
2021-01-31 14:32:14 +00:00
|
|
|
|
2021-02-26 13:49:40 +00:00
|
|
|
m_boundingBoxCacheTimeStamp = 0;
|
|
|
|
m_visibleBBoxCacheTimeStamp = 0;
|
|
|
|
m_textExcludedBBoxCacheTimeStamp = 0;
|
2022-11-30 08:07:32 +00:00
|
|
|
m_courtyard_cache_timestamp = 0;
|
2021-02-26 13:49:40 +00:00
|
|
|
|
2022-01-20 20:54:22 +00:00
|
|
|
m_cachedHull.Rotate( angleChange, GetPosition() );
|
2013-03-13 18:53:58 +00:00
|
|
|
}
|
|
|
|
|
2020-05-03 07:59:05 +00:00
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
BOARD_ITEM* FOOTPRINT::Duplicate() const
|
2020-08-10 13:22:02 +00:00
|
|
|
{
|
2022-02-04 14:26:32 +00:00
|
|
|
FOOTPRINT* dupe = static_cast<FOOTPRINT*>( BOARD_ITEM::Duplicate() );
|
2020-08-10 13:22:02 +00:00
|
|
|
|
2023-11-09 13:55:00 +00:00
|
|
|
dupe->RunOnDescendants( [&]( BOARD_ITEM* child )
|
|
|
|
{
|
|
|
|
const_cast<KIID&>( child->m_Uuid ) = KIID();
|
|
|
|
});
|
2020-08-10 13:22:02 +00:00
|
|
|
|
2022-02-04 14:26:32 +00:00
|
|
|
return dupe;
|
2020-08-10 13:22:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
BOARD_ITEM* FOOTPRINT::DuplicateItem( const BOARD_ITEM* aItem, bool aAddToFootprint )
|
2015-02-12 03:22:24 +00:00
|
|
|
{
|
2021-04-22 21:20:34 +00:00
|
|
|
BOARD_ITEM* new_item = nullptr;
|
2015-02-12 03:22:24 +00:00
|
|
|
|
|
|
|
switch( aItem->Type() )
|
|
|
|
{
|
|
|
|
case PCB_PAD_T:
|
|
|
|
{
|
2020-11-12 22:30:02 +00:00
|
|
|
PAD* new_pad = new PAD( *static_cast<const PAD*>( aItem ) );
|
2020-08-10 13:22:02 +00:00
|
|
|
const_cast<KIID&>( new_pad->m_Uuid ) = KIID();
|
2015-02-12 03:22:24 +00:00
|
|
|
|
2020-11-13 02:57:11 +00:00
|
|
|
if( aAddToFootprint )
|
2019-06-01 23:23:36 +00:00
|
|
|
m_pads.push_back( new_pad );
|
2016-05-11 08:17:34 +00:00
|
|
|
|
2015-02-12 03:22:24 +00:00
|
|
|
new_item = new_pad;
|
|
|
|
break;
|
|
|
|
}
|
2016-03-07 07:13:06 +00:00
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
case PCB_ZONE_T:
|
2019-10-29 10:09:54 +00:00
|
|
|
{
|
2023-03-30 11:49:23 +00:00
|
|
|
ZONE* new_zone = new ZONE( *static_cast<const ZONE*>( aItem ) );
|
2020-08-10 13:22:02 +00:00
|
|
|
const_cast<KIID&>( new_zone->m_Uuid ) = KIID();
|
2019-10-29 10:09:54 +00:00
|
|
|
|
2020-11-13 02:57:11 +00:00
|
|
|
if( aAddToFootprint )
|
2023-03-30 11:49:23 +00:00
|
|
|
m_zones.push_back( new_zone );
|
2019-10-29 10:09:54 +00:00
|
|
|
|
|
|
|
new_item = new_zone;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2023-06-06 15:09:34 +00:00
|
|
|
case PCB_FIELD_T:
|
2023-03-30 11:49:23 +00:00
|
|
|
case PCB_TEXT_T:
|
2015-02-12 03:22:24 +00:00
|
|
|
{
|
2023-03-30 11:49:23 +00:00
|
|
|
PCB_TEXT* new_text = new PCB_TEXT( *static_cast<const PCB_TEXT*>( aItem ) );
|
2020-08-10 13:22:02 +00:00
|
|
|
const_cast<KIID&>( new_text->m_Uuid ) = KIID();
|
2015-02-12 03:22:24 +00:00
|
|
|
|
2023-06-06 17:30:03 +00:00
|
|
|
if( aItem->Type() == PCB_FIELD_T )
|
2020-02-02 23:46:26 +00:00
|
|
|
{
|
2023-06-06 17:30:03 +00:00
|
|
|
switch( static_cast<const PCB_FIELD*>( aItem )->GetId() )
|
|
|
|
{
|
|
|
|
case REFERENCE_FIELD: new_text->SetText( wxT( "${REFERENCE}" ) ); break;
|
|
|
|
|
|
|
|
case VALUE_FIELD: new_text->SetText( wxT( "${VALUE}" ) ); break;
|
|
|
|
|
|
|
|
case DATASHEET_FIELD: new_text->SetText( wxT( "${DATASHEET}" ) ); break;
|
|
|
|
|
|
|
|
case FOOTPRINT_FIELD: new_text->SetText( wxT( "${FOOTPRINT}" ) ); break;
|
|
|
|
}
|
2020-02-02 23:46:26 +00:00
|
|
|
}
|
|
|
|
|
2020-11-13 02:57:11 +00:00
|
|
|
if( aAddToFootprint )
|
2020-02-02 23:46:26 +00:00
|
|
|
Add( new_text );
|
2015-02-12 03:22:24 +00:00
|
|
|
|
2020-02-02 23:46:26 +00:00
|
|
|
new_item = new_text;
|
2015-02-12 03:22:24 +00:00
|
|
|
break;
|
|
|
|
}
|
2016-03-07 07:13:06 +00:00
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
case PCB_SHAPE_T:
|
2015-02-12 03:22:24 +00:00
|
|
|
{
|
2023-03-30 11:49:23 +00:00
|
|
|
PCB_SHAPE* new_shape = new PCB_SHAPE( *static_cast<const PCB_SHAPE*>( aItem ) );
|
2020-10-04 23:34:59 +00:00
|
|
|
const_cast<KIID&>( new_shape->m_Uuid ) = KIID();
|
2015-02-12 03:22:24 +00:00
|
|
|
|
2020-11-13 02:57:11 +00:00
|
|
|
if( aAddToFootprint )
|
2020-10-04 23:34:59 +00:00
|
|
|
Add( new_shape );
|
2016-05-11 08:17:34 +00:00
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
new_item = new_shape;
|
2015-02-12 03:22:24 +00:00
|
|
|
break;
|
|
|
|
}
|
2016-03-07 07:13:06 +00:00
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
case PCB_TEXTBOX_T:
|
2022-01-30 10:52:52 +00:00
|
|
|
{
|
2023-03-30 11:49:23 +00:00
|
|
|
PCB_TEXTBOX* new_textbox = new PCB_TEXTBOX( *static_cast<const PCB_TEXTBOX*>( aItem ) );
|
2022-01-30 10:52:52 +00:00
|
|
|
const_cast<KIID&>( new_textbox->m_Uuid ) = KIID();
|
|
|
|
|
|
|
|
if( aAddToFootprint )
|
|
|
|
Add( new_textbox );
|
|
|
|
|
|
|
|
new_item = new_textbox;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
case PCB_DIM_ALIGNED_T:
|
|
|
|
case PCB_DIM_LEADER_T:
|
|
|
|
case PCB_DIM_CENTER_T:
|
|
|
|
case PCB_DIM_RADIAL_T:
|
|
|
|
case PCB_DIM_ORTHOGONAL_T:
|
2021-12-04 23:52:00 +00:00
|
|
|
{
|
|
|
|
PCB_DIMENSION_BASE* dimension = static_cast<PCB_DIMENSION_BASE*>( aItem->Duplicate() );
|
|
|
|
|
|
|
|
if( aAddToFootprint )
|
|
|
|
Add( dimension );
|
|
|
|
|
|
|
|
new_item = dimension;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-10-03 11:16:29 +00:00
|
|
|
case PCB_GROUP_T:
|
2024-01-07 12:57:22 +00:00
|
|
|
{
|
|
|
|
PCB_GROUP* group = static_cast<const PCB_GROUP*>( aItem )->DeepDuplicate();
|
|
|
|
|
|
|
|
if( aAddToFootprint )
|
|
|
|
{
|
|
|
|
group->RunOnDescendants(
|
2024-01-10 08:16:14 +00:00
|
|
|
[&]( BOARD_ITEM* aCurrItem )
|
2024-01-07 12:57:22 +00:00
|
|
|
{
|
2024-01-10 08:16:14 +00:00
|
|
|
Add( aCurrItem );
|
2024-01-07 12:57:22 +00:00
|
|
|
} );
|
|
|
|
|
|
|
|
Add( new_item );
|
|
|
|
}
|
|
|
|
|
|
|
|
new_item = group;
|
2020-10-03 11:16:29 +00:00
|
|
|
break;
|
2024-01-07 12:57:22 +00:00
|
|
|
}
|
2020-10-03 11:16:29 +00:00
|
|
|
|
2020-11-13 12:21:02 +00:00
|
|
|
case PCB_FOOTPRINT_T:
|
2020-10-14 23:37:26 +00:00
|
|
|
// Ignore the footprint itself
|
2015-02-12 03:22:24 +00:00
|
|
|
break;
|
|
|
|
|
2015-02-12 03:22:24 +00:00
|
|
|
default:
|
|
|
|
// Un-handled item for duplication
|
2022-02-04 22:44:59 +00:00
|
|
|
wxFAIL_MSG( wxT( "Duplication not supported for items of class " ) + aItem->GetClass() );
|
2015-02-12 03:22:24 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return new_item;
|
|
|
|
}
|
|
|
|
|
2015-02-12 03:22:24 +00:00
|
|
|
|
2021-08-23 23:10:21 +00:00
|
|
|
wxString FOOTPRINT::GetNextPadNumber( const wxString& aLastPadNumber ) const
|
2015-02-12 03:22:24 +00:00
|
|
|
{
|
2021-08-23 23:10:21 +00:00
|
|
|
std::set<wxString> usedNumbers;
|
2015-02-12 03:22:24 +00:00
|
|
|
|
|
|
|
// Create a set of used pad numbers
|
2020-11-12 22:30:02 +00:00
|
|
|
for( PAD* pad : m_pads )
|
2021-08-23 23:10:21 +00:00
|
|
|
usedNumbers.insert( pad->GetNumber() );
|
2020-05-03 07:59:05 +00:00
|
|
|
|
2021-08-23 23:10:21 +00:00
|
|
|
// Pad numbers aren't technically reference designators, but the formatting is close enough
|
2021-04-17 14:10:59 +00:00
|
|
|
// for these to give us what we need.
|
2021-08-23 23:10:21 +00:00
|
|
|
wxString prefix = UTIL::GetRefDesPrefix( aLastPadNumber );
|
|
|
|
int num = GetTrailingInt( aLastPadNumber );
|
2015-02-12 03:22:24 +00:00
|
|
|
|
2022-02-04 22:44:59 +00:00
|
|
|
while( usedNumbers.count( wxString::Format( wxT( "%s%d" ), prefix, num ) ) )
|
2020-05-03 07:59:05 +00:00
|
|
|
num++;
|
2015-02-12 03:22:24 +00:00
|
|
|
|
2022-02-04 22:44:59 +00:00
|
|
|
return wxString::Format( wxT( "%s%d" ), prefix, num );
|
2015-02-12 03:22:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-07-29 05:18:13 +00:00
|
|
|
void FOOTPRINT::AutoPositionFields()
|
|
|
|
{
|
|
|
|
// Auto-position reference and value
|
|
|
|
BOX2I bbox = GetBoundingBox( false, false );
|
|
|
|
bbox.Inflate( pcbIUScale.mmToIU( 0.2 ) ); // Gap between graphics and text
|
|
|
|
|
|
|
|
if( Reference().GetPosition() == VECTOR2I( 0, 0 ) )
|
|
|
|
{
|
2023-09-07 00:50:51 +00:00
|
|
|
Reference().SetHorizJustify( GR_TEXT_H_ALIGN_CENTER );
|
|
|
|
Reference().SetVertJustify( GR_TEXT_V_ALIGN_CENTER );
|
|
|
|
Reference().SetTextAngle( ANGLE_0 );
|
|
|
|
|
2023-07-29 05:18:13 +00:00
|
|
|
Reference().SetX( bbox.GetCenter().x );
|
|
|
|
Reference().SetY( bbox.GetTop() - Reference().GetTextSize().y / 2 );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( Value().GetPosition() == VECTOR2I( 0, 0 ) )
|
|
|
|
{
|
2023-09-07 00:50:51 +00:00
|
|
|
Value().SetHorizJustify( GR_TEXT_H_ALIGN_CENTER );
|
|
|
|
Value().SetVertJustify( GR_TEXT_V_ALIGN_CENTER );
|
|
|
|
Value().SetTextAngle( ANGLE_0 );
|
|
|
|
|
2023-07-29 05:18:13 +00:00
|
|
|
Value().SetX( bbox.GetCenter().x );
|
|
|
|
Value().SetY( bbox.GetBottom() + Value().GetTextSize().y / 2 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
void FOOTPRINT::IncrementReference( int aDelta )
|
2018-07-24 18:41:08 +00:00
|
|
|
{
|
2020-10-14 23:37:26 +00:00
|
|
|
const wxString& refdes = GetReference();
|
|
|
|
|
|
|
|
SetReference( wxString::Format( wxT( "%s%i" ),
|
2021-04-17 14:10:59 +00:00
|
|
|
UTIL::GetRefDesPrefix( refdes ),
|
|
|
|
GetTrailingInt( refdes ) + aDelta ) );
|
2018-07-24 18:41:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-09-13 10:22:29 +00:00
|
|
|
// Calculate the area of a PolySet, polygons with hole are allowed.
|
2017-12-31 16:46:38 +00:00
|
|
|
static double polygonArea( SHAPE_POLY_SET& aPolySet )
|
2017-12-22 00:49:35 +00:00
|
|
|
{
|
2021-09-13 10:22:29 +00:00
|
|
|
// Ensure all outlines are closed, before calculating the SHAPE_POLY_SET area
|
2017-12-31 16:46:38 +00:00
|
|
|
for( int ii = 0; ii < aPolySet.OutlineCount(); ii++ )
|
2017-12-22 00:49:35 +00:00
|
|
|
{
|
2017-12-31 16:46:38 +00:00
|
|
|
SHAPE_LINE_CHAIN& outline = aPolySet.Outline( ii );
|
|
|
|
outline.SetClosed( true );
|
|
|
|
|
2021-09-13 10:22:29 +00:00
|
|
|
for( int jj = 0; jj < aPolySet.HoleCount( ii ); jj++ )
|
|
|
|
aPolySet.Hole( ii, jj ).SetClosed( true );
|
|
|
|
}
|
2017-12-31 16:46:38 +00:00
|
|
|
|
2021-09-13 10:22:29 +00:00
|
|
|
return aPolySet.Area();
|
2017-12-22 00:49:35 +00:00
|
|
|
}
|
|
|
|
|
2020-11-27 18:04:30 +00:00
|
|
|
|
|
|
|
double FOOTPRINT::GetCoverageArea( const BOARD_ITEM* aItem, const GENERAL_COLLECTOR& aCollector )
|
2017-12-31 16:46:38 +00:00
|
|
|
{
|
2023-12-04 06:50:29 +00:00
|
|
|
int textMargin = aCollector.GetGuide()->Accuracy();
|
2020-11-27 18:04:30 +00:00
|
|
|
SHAPE_POLY_SET poly;
|
|
|
|
|
2020-11-29 14:00:39 +00:00
|
|
|
if( aItem->Type() == PCB_MARKER_T )
|
|
|
|
{
|
|
|
|
const PCB_MARKER* marker = static_cast<const PCB_MARKER*>( aItem );
|
|
|
|
SHAPE_LINE_CHAIN markerShape;
|
|
|
|
|
|
|
|
marker->ShapeToPolygon( markerShape );
|
|
|
|
return markerShape.Area();
|
|
|
|
}
|
2023-10-06 17:04:00 +00:00
|
|
|
else if( aItem->Type() == PCB_GROUP_T || aItem->Type() == PCB_GENERATOR_T )
|
2020-12-01 14:03:34 +00:00
|
|
|
{
|
|
|
|
double combinedArea = 0.0;
|
|
|
|
|
|
|
|
for( BOARD_ITEM* member : static_cast<const PCB_GROUP*>( aItem )->GetItems() )
|
|
|
|
combinedArea += GetCoverageArea( member, aCollector );
|
|
|
|
|
|
|
|
return combinedArea;
|
|
|
|
}
|
|
|
|
if( aItem->Type() == PCB_FOOTPRINT_T )
|
2020-11-27 18:04:30 +00:00
|
|
|
{
|
|
|
|
const FOOTPRINT* footprint = static_cast<const FOOTPRINT*>( aItem );
|
|
|
|
|
2020-11-29 14:00:39 +00:00
|
|
|
poly = footprint->GetBoundingHull();
|
2020-11-27 18:04:30 +00:00
|
|
|
}
|
2023-06-06 15:09:34 +00:00
|
|
|
else if( aItem->Type() == PCB_FIELD_T || aItem->Type() == PCB_TEXT_T )
|
2020-11-27 18:04:30 +00:00
|
|
|
{
|
2023-03-30 11:49:23 +00:00
|
|
|
const PCB_TEXT* text = static_cast<const PCB_TEXT*>( aItem );
|
2020-11-27 18:04:30 +00:00
|
|
|
|
2023-05-29 14:28:48 +00:00
|
|
|
text->TransformTextToPolySet( poly, textMargin, ARC_LOW_DEF, ERROR_INSIDE );
|
2020-11-27 18:04:30 +00:00
|
|
|
}
|
2023-03-30 11:49:23 +00:00
|
|
|
else if( aItem->Type() == PCB_TEXTBOX_T )
|
2022-01-30 10:52:52 +00:00
|
|
|
{
|
2023-03-30 11:49:23 +00:00
|
|
|
const PCB_TEXTBOX* tb = static_cast<const PCB_TEXTBOX*>( aItem );
|
2022-01-30 10:52:52 +00:00
|
|
|
|
2023-05-29 14:28:48 +00:00
|
|
|
tb->TransformTextToPolySet( poly, textMargin, ARC_LOW_DEF, ERROR_INSIDE );
|
2022-01-30 10:52:52 +00:00
|
|
|
}
|
2021-03-20 16:46:19 +00:00
|
|
|
else if( aItem->Type() == PCB_SHAPE_T )
|
|
|
|
{
|
|
|
|
// Approximate "linear" shapes with just their width squared, as we don't want to consider
|
|
|
|
// a linear shape as being much bigger than another for purposes of selection filtering
|
|
|
|
// just because it happens to be really long.
|
|
|
|
|
|
|
|
const PCB_SHAPE* shape = static_cast<const PCB_SHAPE*>( aItem );
|
|
|
|
|
|
|
|
switch( shape->GetShape() )
|
|
|
|
{
|
2021-07-21 18:31:25 +00:00
|
|
|
case SHAPE_T::SEGMENT:
|
|
|
|
case SHAPE_T::ARC:
|
|
|
|
case SHAPE_T::BEZIER:
|
2021-03-20 16:46:19 +00:00
|
|
|
return shape->GetWidth() * shape->GetWidth();
|
|
|
|
|
2023-07-24 16:07:56 +00:00
|
|
|
case SHAPE_T::RECTANGLE:
|
2021-07-21 18:31:25 +00:00
|
|
|
case SHAPE_T::CIRCLE:
|
|
|
|
case SHAPE_T::POLY:
|
2021-03-20 16:46:19 +00:00
|
|
|
{
|
|
|
|
if( !shape->IsFilled() )
|
|
|
|
return shape->GetWidth() * shape->GetWidth();
|
|
|
|
|
|
|
|
KI_FALLTHROUGH;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
2022-10-21 12:48:45 +00:00
|
|
|
shape->TransformShapeToPolygon( poly, UNDEFINED_LAYER, 0, ARC_LOW_DEF, ERROR_OUTSIDE );
|
2021-03-20 16:46:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( aItem->Type() == PCB_TRACE_T || aItem->Type() == PCB_ARC_T )
|
|
|
|
{
|
2021-06-11 21:07:02 +00:00
|
|
|
double width = static_cast<const PCB_TRACK*>( aItem )->GetWidth();
|
2021-03-20 16:46:19 +00:00
|
|
|
return width * width;
|
|
|
|
}
|
2020-11-27 18:04:30 +00:00
|
|
|
else
|
|
|
|
{
|
2022-10-21 12:48:45 +00:00
|
|
|
aItem->TransformShapeToPolygon( poly, UNDEFINED_LAYER, 0, ARC_LOW_DEF, ERROR_OUTSIDE );
|
2020-11-27 18:04:30 +00:00
|
|
|
}
|
2017-12-22 00:49:35 +00:00
|
|
|
|
2020-11-27 18:04:30 +00:00
|
|
|
return polygonArea( poly );
|
2017-12-31 16:46:38 +00:00
|
|
|
}
|
2017-12-22 00:49:35 +00:00
|
|
|
|
2020-11-27 18:04:30 +00:00
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
double FOOTPRINT::CoverageRatio( const GENERAL_COLLECTOR& aCollector ) const
|
2015-02-17 23:58:14 +00:00
|
|
|
{
|
2023-12-04 06:50:29 +00:00
|
|
|
int textMargin = aCollector.GetGuide()->Accuracy();
|
2015-02-17 23:58:14 +00:00
|
|
|
|
2020-11-29 14:00:39 +00:00
|
|
|
SHAPE_POLY_SET footprintRegion( GetBoundingHull() );
|
2020-11-27 18:04:30 +00:00
|
|
|
SHAPE_POLY_SET coveredRegion;
|
2018-02-22 10:10:48 +00:00
|
|
|
|
2022-10-21 12:48:45 +00:00
|
|
|
TransformPadsToPolySet( coveredRegion, UNDEFINED_LAYER, 0, ARC_LOW_DEF, ERROR_OUTSIDE );
|
2015-02-17 23:58:14 +00:00
|
|
|
|
2022-10-21 12:48:45 +00:00
|
|
|
TransformFPShapesToPolySet( coveredRegion, UNDEFINED_LAYER, textMargin, ARC_LOW_DEF,
|
|
|
|
ERROR_OUTSIDE,
|
|
|
|
true, /* include text */
|
|
|
|
false, /* include shapes */
|
|
|
|
false /* include private items */ );
|
2015-02-17 23:58:14 +00:00
|
|
|
|
2018-02-22 10:10:48 +00:00
|
|
|
for( int i = 0; i < aCollector.GetCount(); ++i )
|
|
|
|
{
|
2020-11-27 18:04:30 +00:00
|
|
|
const BOARD_ITEM* item = aCollector[i];
|
2018-02-22 10:10:48 +00:00
|
|
|
|
|
|
|
switch( item->Type() )
|
|
|
|
{
|
2023-06-06 15:09:34 +00:00
|
|
|
case PCB_FIELD_T:
|
2020-11-27 18:04:30 +00:00
|
|
|
case PCB_TEXT_T:
|
2022-01-30 10:52:52 +00:00
|
|
|
case PCB_TEXTBOX_T:
|
2020-11-27 18:04:30 +00:00
|
|
|
case PCB_SHAPE_T:
|
2018-02-22 10:10:48 +00:00
|
|
|
case PCB_TRACE_T:
|
2019-05-17 00:13:21 +00:00
|
|
|
case PCB_ARC_T:
|
2018-02-22 10:10:48 +00:00
|
|
|
case PCB_VIA_T:
|
2023-03-30 11:49:23 +00:00
|
|
|
if( item->GetParent() != this )
|
|
|
|
{
|
|
|
|
item->TransformShapeToPolygon( coveredRegion, UNDEFINED_LAYER, 0, ARC_LOW_DEF,
|
|
|
|
ERROR_OUTSIDE );
|
|
|
|
}
|
2018-02-22 10:10:48 +00:00
|
|
|
break;
|
2020-11-27 18:04:30 +00:00
|
|
|
|
2020-11-29 14:00:39 +00:00
|
|
|
case PCB_FOOTPRINT_T:
|
|
|
|
if( item != this )
|
|
|
|
{
|
|
|
|
const FOOTPRINT* footprint = static_cast<const FOOTPRINT*>( item );
|
|
|
|
coveredRegion.AddOutline( footprint->GetBoundingHull().Outline( 0 ) );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2018-02-22 10:10:48 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-27 18:04:30 +00:00
|
|
|
double footprintRegionArea = polygonArea( footprintRegion );
|
2021-09-13 10:22:29 +00:00
|
|
|
double uncoveredRegionArea = footprintRegionArea - polygonArea( coveredRegion );
|
2020-11-27 18:04:30 +00:00
|
|
|
double coveredArea = footprintRegionArea - uncoveredRegionArea;
|
|
|
|
double ratio = ( coveredArea / footprintRegionArea );
|
2017-12-31 16:46:38 +00:00
|
|
|
|
2021-09-13 10:22:29 +00:00
|
|
|
// Test for negative ratio (should not occur).
|
|
|
|
// better to be conservative (this will result in the disambiguate dialog)
|
|
|
|
if( ratio < 0.0 )
|
|
|
|
return 1.0;
|
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
return std::min( ratio, 1.0 );
|
2015-02-17 23:58:14 +00:00
|
|
|
}
|
2017-03-16 17:09:33 +00:00
|
|
|
|
2017-12-22 00:49:35 +00:00
|
|
|
|
2022-03-16 23:48:24 +00:00
|
|
|
std::shared_ptr<SHAPE> FOOTPRINT::GetEffectiveShape( PCB_LAYER_ID aLayer, FLASHING aFlash ) const
|
2020-08-26 22:04:16 +00:00
|
|
|
{
|
2020-10-25 19:15:32 +00:00
|
|
|
std::shared_ptr<SHAPE_COMPOUND> shape = std::make_shared<SHAPE_COMPOUND>();
|
|
|
|
|
|
|
|
// There are several possible interpretations here:
|
|
|
|
// 1) the bounding box (without or without invisible items)
|
2020-10-25 20:18:33 +00:00
|
|
|
// 2) just the pads and "edges" (ie: non-text graphic items)
|
2020-10-25 19:15:32 +00:00
|
|
|
// 3) the courtyard
|
|
|
|
|
2022-05-10 22:01:25 +00:00
|
|
|
// We'll go with (2) for now, unless the caller is clearly looking for (3)
|
2020-10-25 19:15:32 +00:00
|
|
|
|
2022-05-10 22:01:25 +00:00
|
|
|
if( aLayer == F_CrtYd || aLayer == B_CrtYd )
|
|
|
|
{
|
2022-07-31 21:14:24 +00:00
|
|
|
const SHAPE_POLY_SET& courtyard = GetCourtyard( aLayer );
|
2020-10-25 19:15:32 +00:00
|
|
|
|
2022-05-10 22:01:25 +00:00
|
|
|
if( courtyard.OutlineCount() == 0 ) // malformed/empty polygon
|
|
|
|
return shape;
|
|
|
|
|
|
|
|
shape->AddShape( new SHAPE_SIMPLE( courtyard.COutline( 0 ) ) );
|
|
|
|
}
|
|
|
|
else
|
2020-10-25 20:18:33 +00:00
|
|
|
{
|
2022-05-10 22:01:25 +00:00
|
|
|
for( PAD* pad : Pads() )
|
|
|
|
shape->AddShape( pad->GetEffectiveShape( aLayer, aFlash )->Clone() );
|
|
|
|
|
|
|
|
for( BOARD_ITEM* item : GraphicalItems() )
|
|
|
|
{
|
2023-03-30 11:49:23 +00:00
|
|
|
if( item->Type() == PCB_SHAPE_T )
|
2022-05-10 22:01:25 +00:00
|
|
|
shape->AddShape( item->GetEffectiveShape( aLayer, aFlash )->Clone() );
|
|
|
|
}
|
2020-10-25 20:18:33 +00:00
|
|
|
}
|
2020-08-26 22:04:16 +00:00
|
|
|
|
|
|
|
return shape;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-07-31 21:14:24 +00:00
|
|
|
const SHAPE_POLY_SET& FOOTPRINT::GetCourtyard( PCB_LAYER_ID aLayer ) const
|
2017-03-16 17:09:33 +00:00
|
|
|
{
|
2024-04-18 15:39:42 +00:00
|
|
|
std::lock_guard<std::mutex> lock( m_courtyard_cache_mutex );
|
|
|
|
|
2022-07-31 21:14:24 +00:00
|
|
|
if( GetBoard() && GetBoard()->GetTimeStamp() > m_courtyard_cache_timestamp )
|
|
|
|
const_cast<FOOTPRINT*>( this )->BuildCourtyardCaches();
|
|
|
|
|
|
|
|
if( IsBackLayer( aLayer ) )
|
|
|
|
return m_courtyard_cache_back;
|
|
|
|
else
|
|
|
|
return m_courtyard_cache_front;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT::BuildCourtyardCaches( OUTLINE_ERROR_HANDLER* aErrorHandler )
|
|
|
|
{
|
|
|
|
m_courtyard_cache_front.RemoveAllContours();
|
|
|
|
m_courtyard_cache_back.RemoveAllContours();
|
2020-11-20 13:55:10 +00:00
|
|
|
ClearFlags( MALFORMED_COURTYARDS );
|
2020-10-25 15:02:49 +00:00
|
|
|
|
2022-07-31 21:14:24 +00:00
|
|
|
m_courtyard_cache_timestamp = GetBoard()->GetTimeStamp();
|
|
|
|
|
2017-03-16 17:09:33 +00:00
|
|
|
// Build the courtyard area from graphic items on the courtyard.
|
2023-03-30 11:49:23 +00:00
|
|
|
// Only PCB_SHAPE_T have meaning, graphic texts are ignored.
|
2017-03-16 17:09:33 +00:00
|
|
|
// Collect items:
|
2020-10-04 23:34:59 +00:00
|
|
|
std::vector<PCB_SHAPE*> list_front;
|
|
|
|
std::vector<PCB_SHAPE*> list_back;
|
2023-06-12 18:12:39 +00:00
|
|
|
std::map<int, int> front_width_histogram;
|
|
|
|
std::map<int, int> back_width_histogram;
|
2017-03-16 17:09:33 +00:00
|
|
|
|
2020-08-15 12:10:23 +00:00
|
|
|
for( BOARD_ITEM* item : GraphicalItems() )
|
2017-03-16 17:09:33 +00:00
|
|
|
{
|
2023-03-30 11:49:23 +00:00
|
|
|
if( item->GetLayer() == B_CrtYd && item->Type() == PCB_SHAPE_T )
|
2023-06-12 18:12:39 +00:00
|
|
|
{
|
|
|
|
PCB_SHAPE* shape = static_cast<PCB_SHAPE*>( item );
|
|
|
|
list_back.push_back( shape );
|
|
|
|
back_width_histogram[ shape->GetStroke().GetWidth() ]++;
|
|
|
|
}
|
2017-03-16 17:09:33 +00:00
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
if( item->GetLayer() == F_CrtYd && item->Type() == PCB_SHAPE_T )
|
2023-06-12 18:12:39 +00:00
|
|
|
{
|
|
|
|
PCB_SHAPE* shape = static_cast<PCB_SHAPE*>( item );
|
|
|
|
list_front.push_back( shape );
|
|
|
|
front_width_histogram[ shape->GetStroke().GetWidth() ]++;
|
|
|
|
}
|
2017-03-16 17:09:33 +00:00
|
|
|
}
|
|
|
|
|
2017-03-19 15:38:30 +00:00
|
|
|
if( !list_front.size() && !list_back.size() )
|
2020-10-25 15:02:49 +00:00
|
|
|
return;
|
2017-03-16 17:09:33 +00:00
|
|
|
|
2024-01-24 12:00:21 +00:00
|
|
|
int maxError = pcbIUScale.mmToIU( 0.005 ); // max error for polygonization
|
2022-09-16 11:33:56 +00:00
|
|
|
int chainingEpsilon = pcbIUScale.mmToIU( 0.02 ); // max dist from one endPt to next startPt
|
2017-03-16 17:09:33 +00:00
|
|
|
|
2023-05-29 14:28:48 +00:00
|
|
|
if( ConvertOutlineToPolygon( list_front, m_courtyard_cache_front, maxError, chainingEpsilon,
|
2022-10-14 19:30:56 +00:00
|
|
|
true, aErrorHandler ) )
|
2020-12-24 21:00:41 +00:00
|
|
|
{
|
2023-11-29 19:50:49 +00:00
|
|
|
int width = 0;
|
|
|
|
|
2021-03-31 21:34:13 +00:00
|
|
|
// Touching courtyards, or courtyards -at- the clearance distance are legal.
|
2023-10-05 07:34:24 +00:00
|
|
|
m_courtyard_cache_front.Inflate( -1, CORNER_STRATEGY::CHAMFER_ACUTE_CORNERS, maxError );
|
2021-03-31 21:34:13 +00:00
|
|
|
|
2022-07-31 21:14:24 +00:00
|
|
|
m_courtyard_cache_front.CacheTriangulation( false );
|
2023-06-12 18:12:39 +00:00
|
|
|
auto max = std::max_element( front_width_histogram.begin(), front_width_histogram.end(),
|
|
|
|
[]( const std::pair<int, int>& a, const std::pair<int, int>& b )
|
|
|
|
{
|
|
|
|
return a.second < b.second;
|
|
|
|
} );
|
2023-11-29 19:50:49 +00:00
|
|
|
|
|
|
|
if( max != front_width_histogram.end() )
|
|
|
|
width = max->first;
|
2023-06-12 18:12:39 +00:00
|
|
|
|
|
|
|
if( width == 0 )
|
2023-12-08 21:31:13 +00:00
|
|
|
width = pcbIUScale.mmToIU( DEFAULT_COURTYARD_WIDTH );
|
2023-06-12 18:12:39 +00:00
|
|
|
|
|
|
|
if( m_courtyard_cache_front.OutlineCount() > 0 )
|
|
|
|
m_courtyard_cache_front.Outline( 0 ).SetWidth( width );
|
2020-12-24 21:00:41 +00:00
|
|
|
}
|
2020-12-23 17:33:39 +00:00
|
|
|
else
|
2020-12-24 21:00:41 +00:00
|
|
|
{
|
2020-11-20 13:55:10 +00:00
|
|
|
SetFlags( MALFORMED_F_COURTYARD );
|
2020-12-24 21:00:41 +00:00
|
|
|
}
|
2017-03-20 12:05:38 +00:00
|
|
|
|
2023-11-29 19:50:49 +00:00
|
|
|
if( ConvertOutlineToPolygon( list_back, m_courtyard_cache_back, maxError, chainingEpsilon, true,
|
|
|
|
aErrorHandler ) )
|
2020-12-24 21:00:41 +00:00
|
|
|
{
|
2023-11-29 19:50:49 +00:00
|
|
|
int width = 0;
|
|
|
|
|
2021-03-31 21:34:13 +00:00
|
|
|
// Touching courtyards, or courtyards -at- the clearance distance are legal.
|
2023-10-05 07:34:24 +00:00
|
|
|
m_courtyard_cache_back.Inflate( -1, CORNER_STRATEGY::CHAMFER_ACUTE_CORNERS, maxError );
|
2021-03-31 21:34:13 +00:00
|
|
|
|
2022-07-31 21:14:24 +00:00
|
|
|
m_courtyard_cache_back.CacheTriangulation( false );
|
2023-06-12 18:12:39 +00:00
|
|
|
auto max = std::max_element( back_width_histogram.begin(), back_width_histogram.end(),
|
|
|
|
[]( const std::pair<int, int>& a, const std::pair<int, int>& b )
|
|
|
|
{
|
|
|
|
return a.second < b.second;
|
|
|
|
} );
|
2023-11-29 19:50:49 +00:00
|
|
|
|
|
|
|
if( max != back_width_histogram.end() )
|
|
|
|
width = max->first;
|
2023-06-12 18:12:39 +00:00
|
|
|
|
|
|
|
if( width == 0 )
|
2023-12-08 21:31:13 +00:00
|
|
|
width = pcbIUScale.mmToIU( DEFAULT_COURTYARD_WIDTH );
|
2023-06-12 18:12:39 +00:00
|
|
|
|
|
|
|
if( m_courtyard_cache_back.OutlineCount() > 0 )
|
|
|
|
m_courtyard_cache_back.Outline( 0 ).SetWidth( width );
|
2020-12-24 21:00:41 +00:00
|
|
|
}
|
2020-12-23 17:33:39 +00:00
|
|
|
else
|
2020-12-24 21:00:41 +00:00
|
|
|
{
|
2020-11-20 13:55:10 +00:00
|
|
|
SetFlags( MALFORMED_B_COURTYARD );
|
2020-12-24 21:00:41 +00:00
|
|
|
}
|
2017-03-16 17:09:33 +00:00
|
|
|
}
|
2017-10-31 13:59:03 +00:00
|
|
|
|
2019-09-15 09:10:53 +00:00
|
|
|
|
2022-09-25 16:23:14 +00:00
|
|
|
std::map<wxString, int> FOOTPRINT::MapPadNumbersToNetTieGroups() const
|
|
|
|
{
|
|
|
|
std::map<wxString, int> padNumberToGroupIdxMap;
|
|
|
|
|
|
|
|
for( const PAD* pad : m_pads )
|
|
|
|
padNumberToGroupIdxMap[ pad->GetNumber() ] = -1;
|
|
|
|
|
2023-01-19 15:44:17 +00:00
|
|
|
auto processPad =
|
|
|
|
[&]( wxString aPad, int aGroup )
|
|
|
|
{
|
|
|
|
aPad.Trim( true ).Trim( false );
|
|
|
|
|
|
|
|
if( !aPad.IsEmpty() )
|
|
|
|
padNumberToGroupIdxMap[ aPad ] = aGroup;
|
|
|
|
};
|
|
|
|
|
|
|
|
for( int ii = 0; ii < (int) m_netTiePadGroups.size(); ++ii )
|
2022-09-25 16:23:14 +00:00
|
|
|
{
|
2023-01-18 01:36:05 +00:00
|
|
|
wxString group( m_netTiePadGroups[ ii ] );
|
|
|
|
bool esc = false;
|
|
|
|
wxString pad;
|
2022-09-25 16:23:14 +00:00
|
|
|
|
2023-01-19 15:44:17 +00:00
|
|
|
for( wxUniCharRef ch : group )
|
2023-01-18 01:36:05 +00:00
|
|
|
{
|
|
|
|
if( esc )
|
|
|
|
{
|
|
|
|
esc = false;
|
|
|
|
pad.Append( ch );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch( static_cast<unsigned char>( ch ) )
|
|
|
|
{
|
|
|
|
case '\\':
|
|
|
|
esc = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ',':
|
2023-01-19 15:44:17 +00:00
|
|
|
processPad( pad, ii );
|
2023-01-18 01:36:05 +00:00
|
|
|
pad.Clear();
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
pad.Append( ch );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2023-01-19 15:44:17 +00:00
|
|
|
|
|
|
|
processPad( pad, ii );
|
2022-09-25 16:23:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return padNumberToGroupIdxMap;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::vector<PAD*> FOOTPRINT::GetNetTiePads( PAD* aPad ) const
|
|
|
|
{
|
|
|
|
// First build a map from pad numbers to allowed-shorting-group indexes. This ends up being
|
|
|
|
// something like O(3n), but it still beats O(n^2) for large numbers of pads.
|
|
|
|
|
|
|
|
std::map<wxString, int> padToNetTieGroupMap = MapPadNumbersToNetTieGroups();
|
|
|
|
int groupIdx = padToNetTieGroupMap[ aPad->GetNumber() ];
|
|
|
|
std::vector<PAD*> otherPads;
|
|
|
|
|
|
|
|
if( groupIdx >= 0 )
|
|
|
|
{
|
|
|
|
for( PAD* pad : m_pads )
|
|
|
|
{
|
|
|
|
if( padToNetTieGroupMap[ pad->GetNumber() ] == groupIdx )
|
|
|
|
otherPads.push_back( pad );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return otherPads;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-03-18 19:35:40 +00:00
|
|
|
void FOOTPRINT::CheckFootprintAttributes( const std::function<void( const wxString& )>& aErrorHandler )
|
2021-09-25 15:55:33 +00:00
|
|
|
{
|
2022-10-02 17:19:43 +00:00
|
|
|
int likelyAttr = ( GetLikelyAttribute() & ( FP_SMD | FP_THROUGH_HOLE ) );
|
2022-03-18 19:35:40 +00:00
|
|
|
int setAttr = ( GetAttributes() & ( FP_SMD | FP_THROUGH_HOLE ) );
|
2021-09-25 15:55:33 +00:00
|
|
|
|
2022-10-02 17:19:43 +00:00
|
|
|
if( setAttr && likelyAttr && setAttr != likelyAttr )
|
2021-09-25 15:55:33 +00:00
|
|
|
{
|
|
|
|
wxString msg;
|
|
|
|
|
2022-04-24 22:44:02 +00:00
|
|
|
switch( likelyAttr )
|
2021-09-25 15:55:33 +00:00
|
|
|
{
|
2022-04-24 22:44:02 +00:00
|
|
|
case FP_THROUGH_HOLE:
|
2022-04-23 08:39:34 +00:00
|
|
|
msg.Printf( _( "(expected 'Through hole'; actual '%s')" ), GetTypeName() );
|
2022-04-24 22:44:02 +00:00
|
|
|
break;
|
|
|
|
case FP_SMD:
|
2022-04-23 08:39:34 +00:00
|
|
|
msg.Printf( _( "(expected 'SMD'; actual '%s')" ), GetTypeName() );
|
2022-04-24 22:44:02 +00:00
|
|
|
break;
|
2021-09-25 15:55:33 +00:00
|
|
|
}
|
|
|
|
|
2022-10-02 17:19:43 +00:00
|
|
|
if( aErrorHandler )
|
|
|
|
(aErrorHandler)( msg );
|
2021-09-25 15:55:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-18 19:35:40 +00:00
|
|
|
|
|
|
|
void FOOTPRINT::CheckPads( const std::function<void( const PAD*, int,
|
|
|
|
const wxString& )>& aErrorHandler )
|
2021-10-19 11:24:30 +00:00
|
|
|
{
|
|
|
|
if( aErrorHandler == nullptr )
|
|
|
|
return;
|
|
|
|
|
2022-03-18 19:35:40 +00:00
|
|
|
for( PAD* pad: Pads() )
|
2021-10-19 11:24:30 +00:00
|
|
|
{
|
2022-03-18 19:35:40 +00:00
|
|
|
if( pad->GetAttribute() == PAD_ATTRIB::PTH || pad->GetAttribute() == PAD_ATTRIB::NPTH )
|
|
|
|
{
|
|
|
|
if( pad->GetDrillSizeX() < 1 || pad->GetDrillSizeY() < 1 )
|
|
|
|
(aErrorHandler)( pad, DRCE_PAD_TH_WITH_NO_HOLE, wxEmptyString );
|
|
|
|
}
|
2021-10-19 11:24:30 +00:00
|
|
|
|
2022-03-18 19:35:40 +00:00
|
|
|
if( pad->GetAttribute() == PAD_ATTRIB::PTH )
|
|
|
|
{
|
|
|
|
if( !pad->IsOnCopperLayer() )
|
|
|
|
{
|
|
|
|
(aErrorHandler)( pad, DRCE_PADSTACK, _( "(PTH pad has no copper layers)" ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
LSET lset = pad->GetLayerSet() & LSET::AllCuMask();
|
|
|
|
PCB_LAYER_ID layer = lset.Seq().at( 0 );
|
|
|
|
SHAPE_POLY_SET padOutline;
|
|
|
|
|
2022-10-21 12:48:45 +00:00
|
|
|
pad->TransformShapeToPolygon( padOutline, layer, 0, ARC_HIGH_DEF, ERROR_INSIDE );
|
2022-03-18 19:35:40 +00:00
|
|
|
|
2022-07-22 22:05:25 +00:00
|
|
|
std::shared_ptr<SHAPE_SEGMENT> hole = pad->GetEffectiveHoleShape();
|
|
|
|
SHAPE_POLY_SET holeOutline;
|
2022-03-18 19:35:40 +00:00
|
|
|
|
2022-07-22 22:05:25 +00:00
|
|
|
TransformOvalToPolygon( holeOutline, hole->GetSeg().A, hole->GetSeg().B,
|
2022-10-21 12:48:45 +00:00
|
|
|
hole->GetWidth(), ARC_HIGH_DEF, ERROR_INSIDE );
|
2022-03-18 19:35:40 +00:00
|
|
|
|
2022-07-22 22:05:25 +00:00
|
|
|
padOutline.BooleanSubtract( holeOutline, SHAPE_POLY_SET::POLYGON_MODE::PM_FAST );
|
2022-03-18 19:35:40 +00:00
|
|
|
|
|
|
|
if( padOutline.IsEmpty() )
|
2022-08-19 17:34:53 +00:00
|
|
|
aErrorHandler( pad, DRCE_PADSTACK, _( "(PTH pad's hole leaves no copper)" ) );
|
2022-03-18 19:35:40 +00:00
|
|
|
}
|
|
|
|
}
|
2022-09-03 22:26:27 +00:00
|
|
|
|
|
|
|
if( pad->GetAttribute() == PAD_ATTRIB::SMD )
|
|
|
|
{
|
|
|
|
if( pad->IsOnLayer( F_Cu ) && pad->IsOnLayer( B_Cu ) )
|
|
|
|
{
|
|
|
|
aErrorHandler( pad, DRCE_PADSTACK,
|
|
|
|
_( "(SMD pad appears on both front and back copper)" ) );
|
|
|
|
}
|
|
|
|
else if( pad->IsOnLayer( F_Cu ) )
|
|
|
|
{
|
|
|
|
if( pad->IsOnLayer( B_Mask ) )
|
|
|
|
{
|
|
|
|
aErrorHandler( pad, DRCE_PADSTACK,
|
|
|
|
_( "(SMD pad copper and mask layers don't match)" ) );
|
|
|
|
}
|
|
|
|
else if( pad->IsOnLayer( B_Paste ) )
|
|
|
|
{
|
|
|
|
aErrorHandler( pad, DRCE_PADSTACK,
|
|
|
|
_( "(SMD pad copper and paste layers don't match)" ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( pad->IsOnLayer( B_Cu ) )
|
|
|
|
{
|
|
|
|
if( pad->IsOnLayer( F_Mask ) )
|
|
|
|
{
|
|
|
|
aErrorHandler( pad, DRCE_PADSTACK,
|
|
|
|
_( "(SMD pad copper and mask layers don't match)" ) );
|
|
|
|
}
|
|
|
|
else if( pad->IsOnLayer( F_Paste ) )
|
|
|
|
{
|
|
|
|
aErrorHandler( pad, DRCE_PADSTACK,
|
|
|
|
_( "(SMD pad copper and paste layers don't match)" ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-03-18 19:35:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-09-25 16:23:14 +00:00
|
|
|
void FOOTPRINT::CheckShortingPads( const std::function<void( const PAD*, const PAD*,
|
|
|
|
const VECTOR2I& )>& aErrorHandler )
|
2022-03-18 19:35:40 +00:00
|
|
|
{
|
2022-08-03 09:10:23 +00:00
|
|
|
std::unordered_map<PTR_PTR_CACHE_KEY, int> checkedPairs;
|
2021-10-19 11:24:30 +00:00
|
|
|
|
2022-03-18 19:35:40 +00:00
|
|
|
for( PAD* pad : Pads() )
|
|
|
|
{
|
2022-09-25 16:23:14 +00:00
|
|
|
std::vector<PAD*> netTiePads = GetNetTiePads( pad );
|
|
|
|
|
2022-03-18 19:35:40 +00:00
|
|
|
for( PAD* other : Pads() )
|
2021-10-19 11:24:30 +00:00
|
|
|
{
|
2022-03-18 19:35:40 +00:00
|
|
|
if( other == pad || pad->SameLogicalPadAs( other ) )
|
|
|
|
continue;
|
|
|
|
|
2022-09-25 16:23:14 +00:00
|
|
|
if( alg::contains( netTiePads, other ) )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if( !( ( pad->GetLayerSet() & other->GetLayerSet() ) & LSET::AllCuMask() ).any() )
|
2022-04-23 20:39:00 +00:00
|
|
|
continue;
|
|
|
|
|
2022-03-19 10:40:55 +00:00
|
|
|
// store canonical order so we don't collide in both directions (a:b and b:a)
|
|
|
|
PAD* a = pad;
|
|
|
|
PAD* b = other;
|
2021-10-19 11:24:30 +00:00
|
|
|
|
2022-03-19 10:40:55 +00:00
|
|
|
if( static_cast<void*>( a ) > static_cast<void*>( b ) )
|
|
|
|
std::swap( a, b );
|
|
|
|
|
2022-08-25 14:03:44 +00:00
|
|
|
if( checkedPairs.find( { a, b } ) == checkedPairs.end() )
|
2022-03-18 19:35:40 +00:00
|
|
|
{
|
2022-03-19 10:40:55 +00:00
|
|
|
checkedPairs[ { a, b } ] = 1;
|
2022-03-18 19:35:40 +00:00
|
|
|
|
2022-06-18 18:47:11 +00:00
|
|
|
if( pad->GetBoundingBox().Intersects( other->GetBoundingBox() ) )
|
2022-03-19 10:40:55 +00:00
|
|
|
{
|
2022-06-18 18:47:11 +00:00
|
|
|
VECTOR2I pos;
|
|
|
|
SHAPE* padShape = pad->GetEffectiveShape().get();
|
|
|
|
SHAPE* otherShape = other->GetEffectiveShape().get();
|
|
|
|
|
|
|
|
if( padShape->Collide( otherShape, 0, nullptr, &pos ) )
|
2022-08-19 17:34:53 +00:00
|
|
|
aErrorHandler( pad, other, pos );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT::CheckNetTies( const std::function<void( const BOARD_ITEM* aItem,
|
|
|
|
const BOARD_ITEM* bItem,
|
|
|
|
const BOARD_ITEM* cItem,
|
|
|
|
const VECTOR2I& )>& aErrorHandler )
|
|
|
|
{
|
2022-09-25 16:23:14 +00:00
|
|
|
// First build a map from pad numbers to allowed-shorting-group indexes. This ends up being
|
2022-08-19 17:34:53 +00:00
|
|
|
// something like O(3n), but it still beats O(n^2) for large numbers of pads.
|
|
|
|
|
2022-09-25 16:23:14 +00:00
|
|
|
std::map<wxString, int> padNumberToGroupIdxMap = MapPadNumbersToNetTieGroups();
|
2022-08-19 17:34:53 +00:00
|
|
|
|
|
|
|
// Now collect all the footprint items which are on copper layers
|
|
|
|
|
|
|
|
std::vector<BOARD_ITEM*> copperItems;
|
|
|
|
|
|
|
|
for( BOARD_ITEM* item : m_drawings )
|
|
|
|
{
|
|
|
|
if( item->IsOnCopperLayer() )
|
|
|
|
copperItems.push_back( item );
|
2023-11-09 13:55:00 +00:00
|
|
|
|
|
|
|
item->RunOnDescendants(
|
|
|
|
[&]( BOARD_ITEM* descendent )
|
|
|
|
{
|
|
|
|
if( descendent->IsOnCopperLayer() )
|
|
|
|
copperItems.push_back( descendent );
|
|
|
|
} );
|
2022-08-19 17:34:53 +00:00
|
|
|
}
|
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
for( ZONE* zone : m_zones )
|
2022-08-19 17:34:53 +00:00
|
|
|
{
|
|
|
|
if( !zone->GetIsRuleArea() && zone->IsOnCopperLayer() )
|
|
|
|
copperItems.push_back( zone );
|
|
|
|
}
|
|
|
|
|
2023-05-24 12:39:25 +00:00
|
|
|
for( PCB_FIELD* field : m_fields )
|
|
|
|
{
|
|
|
|
if( field->IsOnCopperLayer() )
|
|
|
|
copperItems.push_back( field );
|
|
|
|
}
|
2022-08-19 17:34:53 +00:00
|
|
|
|
|
|
|
for( PCB_LAYER_ID layer : { F_Cu, In1_Cu, B_Cu } )
|
|
|
|
{
|
|
|
|
// Next, build a polygon-set for the copper on this layer. We don't really care about
|
|
|
|
// nets here, we just want to end up with a set of outlines describing the distinct
|
|
|
|
// copper polygons of the footprint.
|
|
|
|
|
|
|
|
SHAPE_POLY_SET copperOutlines;
|
|
|
|
std::map<int, std::vector<const PAD*>> outlineIdxToPadsMap;
|
|
|
|
|
|
|
|
for( BOARD_ITEM* item : copperItems )
|
|
|
|
{
|
|
|
|
if( item->IsOnLayer( layer ) )
|
|
|
|
{
|
2022-10-21 12:48:45 +00:00
|
|
|
item->TransformShapeToPolygon( copperOutlines, layer, 0, ARC_HIGH_DEF,
|
|
|
|
ERROR_OUTSIDE );
|
2022-08-19 17:34:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
copperOutlines.Simplify( SHAPE_POLY_SET::PM_FAST );
|
|
|
|
|
|
|
|
// Index each pad to the outline in the set that it is part of.
|
|
|
|
|
|
|
|
for( const PAD* pad : m_pads )
|
|
|
|
{
|
|
|
|
for( int ii = 0; ii < copperOutlines.OutlineCount(); ++ii )
|
|
|
|
{
|
|
|
|
if( pad->GetEffectiveShape( layer )->Collide( &copperOutlines.Outline( ii ), 0 ) )
|
|
|
|
outlineIdxToPadsMap[ ii ].emplace_back( pad );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Finally, ensure that each outline which contains multiple pads has all its pads
|
|
|
|
// listed in an allowed-shorting group.
|
|
|
|
|
|
|
|
for( const auto& [ outlineIdx, pads ] : outlineIdxToPadsMap )
|
|
|
|
{
|
|
|
|
if( pads.size() > 1 )
|
|
|
|
{
|
|
|
|
const PAD* firstPad = pads[0];
|
2022-09-25 16:23:14 +00:00
|
|
|
int firstGroupIdx = padNumberToGroupIdxMap[ firstPad->GetNumber() ];
|
2022-08-19 17:34:53 +00:00
|
|
|
|
|
|
|
for( size_t ii = 1; ii < pads.size(); ++ii )
|
|
|
|
{
|
|
|
|
const PAD* thisPad = pads[ii];
|
2022-09-25 16:23:14 +00:00
|
|
|
int thisGroupIdx = padNumberToGroupIdxMap[ thisPad->GetNumber() ];
|
2022-08-19 17:34:53 +00:00
|
|
|
|
|
|
|
if( thisGroupIdx < 0 || thisGroupIdx != firstGroupIdx )
|
2022-06-18 18:47:11 +00:00
|
|
|
{
|
2022-08-19 17:34:53 +00:00
|
|
|
BOARD_ITEM* shortingItem = nullptr;
|
|
|
|
VECTOR2I pos = ( firstPad->GetPosition() + thisPad->GetPosition() ) / 2;
|
|
|
|
|
|
|
|
pos = copperOutlines.Outline( outlineIdx ).NearestPoint( pos );
|
|
|
|
|
|
|
|
for( BOARD_ITEM* item : copperItems )
|
|
|
|
{
|
|
|
|
if( item->HitTest( pos, 1 ) )
|
|
|
|
{
|
|
|
|
shortingItem = item;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( shortingItem )
|
|
|
|
aErrorHandler( shortingItem, firstPad, thisPad, pos );
|
|
|
|
else
|
|
|
|
aErrorHandler( firstPad, thisPad, nullptr, pos );
|
2022-06-18 18:47:11 +00:00
|
|
|
}
|
2022-03-19 10:40:55 +00:00
|
|
|
}
|
2022-03-18 19:35:40 +00:00
|
|
|
}
|
2021-10-19 11:24:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-25 15:55:33 +00:00
|
|
|
|
2022-08-19 17:34:53 +00:00
|
|
|
void FOOTPRINT::CheckNetTiePadGroups( const std::function<void( const wxString& )>& aErrorHandler )
|
|
|
|
{
|
|
|
|
std::set<wxString> padNumbers;
|
2022-09-25 16:23:14 +00:00
|
|
|
wxString msg;
|
2022-08-19 17:34:53 +00:00
|
|
|
|
2023-01-18 01:36:05 +00:00
|
|
|
auto ret = MapPadNumbersToNetTieGroups();
|
|
|
|
|
|
|
|
for( auto [ padNumber, _ ] : ret )
|
2022-08-19 17:34:53 +00:00
|
|
|
{
|
2023-01-18 01:36:05 +00:00
|
|
|
const PAD* pad = FindPadByNumber( padNumber );
|
2022-08-19 17:34:53 +00:00
|
|
|
|
2023-01-18 01:36:05 +00:00
|
|
|
if( !pad )
|
2022-08-19 17:34:53 +00:00
|
|
|
{
|
2023-01-18 01:36:05 +00:00
|
|
|
msg.Printf( _( "(net-tie pad group contains unknown pad number %s)" ), padNumber );
|
|
|
|
aErrorHandler( msg );
|
|
|
|
}
|
|
|
|
else if( !padNumbers.insert( pad->GetNumber() ).second )
|
|
|
|
{
|
|
|
|
msg.Printf( _( "(pad %s appears in more than one net-tie pad group)" ), padNumber );
|
|
|
|
aErrorHandler( msg );
|
2022-08-19 17:34:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-11-11 17:09:25 +00:00
|
|
|
void FOOTPRINT::swapData( BOARD_ITEM* aImage )
|
2017-10-31 13:59:03 +00:00
|
|
|
{
|
2021-08-18 13:34:32 +00:00
|
|
|
wxASSERT( aImage->Type() == PCB_FOOTPRINT_T );
|
2017-10-31 13:59:03 +00:00
|
|
|
|
2023-12-31 21:36:33 +00:00
|
|
|
FOOTPRINT* image = static_cast<FOOTPRINT*>( aImage );
|
|
|
|
|
|
|
|
std::swap( *this, *image );
|
|
|
|
|
|
|
|
RunOnChildren(
|
|
|
|
[&]( BOARD_ITEM* child )
|
|
|
|
{
|
|
|
|
child->SetParent( this );
|
|
|
|
} );
|
|
|
|
|
|
|
|
image->RunOnChildren(
|
|
|
|
[&]( BOARD_ITEM* child )
|
|
|
|
{
|
|
|
|
child->SetParent( image );
|
|
|
|
} );
|
2017-10-31 13:59:03 +00:00
|
|
|
}
|
2019-09-15 09:10:53 +00:00
|
|
|
|
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
bool FOOTPRINT::HasThroughHolePads() const
|
2019-09-15 09:10:53 +00:00
|
|
|
{
|
2020-11-12 22:30:02 +00:00
|
|
|
for( PAD* pad : Pads() )
|
2019-09-15 09:10:53 +00:00
|
|
|
{
|
2021-05-01 14:46:50 +00:00
|
|
|
if( pad->GetAttribute() != PAD_ATTRIB::SMD )
|
2019-09-15 09:10:53 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2020-02-02 18:40:14 +00:00
|
|
|
|
|
|
|
|
2023-09-14 21:39:42 +00:00
|
|
|
bool FOOTPRINT::operator==( const BOARD_ITEM& aOther ) const
|
|
|
|
{
|
|
|
|
if( aOther.Type() != PCB_FOOTPRINT_T )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
const FOOTPRINT& other = static_cast<const FOOTPRINT&>( aOther );
|
|
|
|
|
|
|
|
if( m_pads.size() != other.m_pads.size() )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
for( size_t ii = 0; ii < m_pads.size(); ++ii )
|
|
|
|
{
|
|
|
|
if( !( *m_pads[ii] == *other.m_pads[ii] ) )
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( m_drawings.size() != other.m_drawings.size() )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
for( size_t ii = 0; ii < m_drawings.size(); ++ii )
|
|
|
|
{
|
|
|
|
if( !( *m_drawings[ii] == *other.m_drawings[ii] ) )
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( m_zones.size() != other.m_zones.size() )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
for( size_t ii = 0; ii < m_zones.size(); ++ii )
|
|
|
|
{
|
|
|
|
if( !( *m_zones[ii] == *other.m_zones[ii] ) )
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( m_fields.size() != other.m_fields.size() )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
for( size_t ii = 0; ii < m_fields.size(); ++ii )
|
|
|
|
{
|
|
|
|
if( !( *m_fields[ii] == *other.m_fields[ii] ) )
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
double FOOTPRINT::Similarity( const BOARD_ITEM& aOther ) const
|
|
|
|
{
|
|
|
|
if( aOther.Type() != PCB_FOOTPRINT_T )
|
|
|
|
return 0.0;
|
|
|
|
|
|
|
|
const FOOTPRINT& other = static_cast<const FOOTPRINT&>( aOther );
|
|
|
|
|
|
|
|
double similarity = 1.0;
|
|
|
|
|
|
|
|
for( size_t ii = 0; ii < m_pads.size(); ++ii )
|
|
|
|
{
|
|
|
|
const PAD* pad = m_pads[ii];
|
|
|
|
const PAD* otherPad = other.FindPadByNumber( pad->GetNumber() );
|
|
|
|
|
|
|
|
if( !otherPad )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
similarity *= pad->Similarity( *otherPad );
|
|
|
|
}
|
|
|
|
|
|
|
|
return similarity;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-07-11 11:49:36 +00:00
|
|
|
bool FOOTPRINT::cmp_drawings::operator()( const BOARD_ITEM* itemA, const BOARD_ITEM* itemB ) const
|
|
|
|
{
|
2023-06-12 18:12:39 +00:00
|
|
|
if( itemA->Type() != itemB->Type() )
|
|
|
|
return itemA->Type() < itemB->Type();
|
|
|
|
|
|
|
|
if( itemA->GetLayer() != itemB->GetLayer() )
|
|
|
|
return itemA->GetLayer() < itemB->GetLayer();
|
2020-07-24 22:08:36 +00:00
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
if( itemA->Type() == PCB_SHAPE_T )
|
2020-07-24 22:08:36 +00:00
|
|
|
{
|
2023-03-30 11:49:23 +00:00
|
|
|
const PCB_SHAPE* dwgA = static_cast<const PCB_SHAPE*>( itemA );
|
|
|
|
const PCB_SHAPE* dwgB = static_cast<const PCB_SHAPE*>( itemB );
|
2021-07-11 11:49:36 +00:00
|
|
|
|
2023-06-12 18:12:39 +00:00
|
|
|
if( dwgA->GetShape() != dwgB->GetShape() )
|
|
|
|
return dwgA->GetShape() < dwgB->GetShape();
|
2021-07-11 11:49:36 +00:00
|
|
|
|
2023-11-13 17:36:00 +00:00
|
|
|
// GetStart() and GetEnd() have no meaning with polygons.
|
|
|
|
// We cannot use them for sorting polygons
|
|
|
|
if( dwgA->GetShape() != SHAPE_T::POLY )
|
|
|
|
{
|
2023-06-12 18:12:39 +00:00
|
|
|
if( dwgA->GetStart().x != dwgB->GetStart().x )
|
|
|
|
return dwgA->GetStart().x < dwgB->GetStart().x;
|
|
|
|
if( dwgA->GetStart().y != dwgB->GetStart().y )
|
|
|
|
return dwgA->GetStart().y < dwgB->GetStart().y;
|
|
|
|
|
|
|
|
if( dwgA->GetEnd().x != dwgB->GetEnd().x )
|
|
|
|
return dwgA->GetEnd().x < dwgB->GetEnd().x;
|
|
|
|
if( dwgA->GetEnd().y != dwgB->GetEnd().y )
|
|
|
|
return dwgA->GetEnd().y < dwgB->GetEnd().y;
|
2023-11-13 17:36:00 +00:00
|
|
|
}
|
2021-07-11 11:49:36 +00:00
|
|
|
|
|
|
|
if( dwgA->GetShape() == SHAPE_T::ARC )
|
|
|
|
{
|
2023-06-12 18:12:39 +00:00
|
|
|
if( dwgA->GetCenter().x != dwgB->GetCenter().x )
|
|
|
|
return dwgA->GetCenter().x < dwgB->GetCenter().x;
|
|
|
|
if( dwgA->GetCenter().y != dwgB->GetCenter().y )
|
|
|
|
return dwgA->GetCenter().y < dwgB->GetCenter().y;
|
2021-07-11 11:49:36 +00:00
|
|
|
}
|
|
|
|
else if( dwgA->GetShape() == SHAPE_T::BEZIER )
|
|
|
|
{
|
2023-06-12 18:12:39 +00:00
|
|
|
if( dwgA->GetBezierC1().x != dwgB->GetBezierC1().x )
|
|
|
|
return dwgA->GetBezierC1().x < dwgB->GetBezierC1().x;
|
|
|
|
if( dwgA->GetBezierC1().y != dwgB->GetBezierC1().y )
|
|
|
|
return dwgA->GetBezierC1().y < dwgB->GetBezierC1().y;
|
|
|
|
|
|
|
|
if( dwgA->GetBezierC2().x != dwgB->GetBezierC2().x )
|
|
|
|
return dwgA->GetBezierC2().x < dwgB->GetBezierC2().x;
|
|
|
|
if( dwgA->GetBezierC2().y != dwgB->GetBezierC2().y )
|
|
|
|
return dwgA->GetBezierC2().y < dwgB->GetBezierC2().y;
|
2021-07-11 11:49:36 +00:00
|
|
|
}
|
|
|
|
else if( dwgA->GetShape() == SHAPE_T::POLY )
|
|
|
|
{
|
2023-06-12 18:12:39 +00:00
|
|
|
if( dwgA->GetPolyShape().TotalVertices() != dwgB->GetPolyShape().TotalVertices() )
|
|
|
|
return dwgA->GetPolyShape().TotalVertices() < dwgB->GetPolyShape().TotalVertices();
|
2021-07-11 11:49:36 +00:00
|
|
|
|
|
|
|
for( int ii = 0; ii < dwgA->GetPolyShape().TotalVertices(); ++ii )
|
2023-06-12 18:12:39 +00:00
|
|
|
{
|
|
|
|
if( dwgA->GetPolyShape().CVertex( ii ).x != dwgB->GetPolyShape().CVertex( ii ).x )
|
|
|
|
return dwgA->GetPolyShape().CVertex( ii ).x
|
|
|
|
< dwgB->GetPolyShape().CVertex( ii ).x;
|
|
|
|
if( dwgA->GetPolyShape().CVertex( ii ).y != dwgB->GetPolyShape().CVertex( ii ).y )
|
|
|
|
return dwgA->GetPolyShape().CVertex( ii ).y
|
|
|
|
< dwgB->GetPolyShape().CVertex( ii ).y;
|
|
|
|
}
|
2021-07-11 11:49:36 +00:00
|
|
|
}
|
2020-07-24 22:08:36 +00:00
|
|
|
|
2023-06-12 18:12:39 +00:00
|
|
|
if( dwgA->GetWidth() != dwgB->GetWidth() )
|
|
|
|
return dwgA->GetWidth() < dwgB->GetWidth();
|
2020-07-24 22:08:36 +00:00
|
|
|
}
|
|
|
|
|
2023-06-12 18:12:39 +00:00
|
|
|
if( itemA->m_Uuid != itemB->m_Uuid )
|
|
|
|
return itemA->m_Uuid < itemB->m_Uuid;
|
2020-10-11 17:02:38 +00:00
|
|
|
|
2021-07-11 11:49:36 +00:00
|
|
|
return itemA < itemB;
|
2020-07-24 22:08:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
bool FOOTPRINT::cmp_pads::operator()( const PAD* aFirst, const PAD* aSecond ) const
|
2020-07-24 22:08:36 +00:00
|
|
|
{
|
2021-08-23 23:10:21 +00:00
|
|
|
if( aFirst->GetNumber() != aSecond->GetNumber() )
|
|
|
|
return StrNumCmp( aFirst->GetNumber(), aSecond->GetNumber() ) < 0;
|
2020-07-24 22:08:36 +00:00
|
|
|
|
2023-06-12 18:12:39 +00:00
|
|
|
if( aFirst->GetFPRelativePosition().x != aSecond->GetFPRelativePosition().x )
|
|
|
|
return aFirst->GetFPRelativePosition().x < aSecond->GetFPRelativePosition().x;
|
|
|
|
if( aFirst->GetFPRelativePosition().y != aSecond->GetFPRelativePosition().y )
|
|
|
|
return aFirst->GetFPRelativePosition().y < aSecond->GetFPRelativePosition().y;
|
|
|
|
|
|
|
|
if( aFirst->GetSize().x != aSecond->GetSize().x )
|
|
|
|
return aFirst->GetSize().x < aSecond->GetSize().x;
|
|
|
|
if( aFirst->GetSize().y != aSecond->GetSize().y )
|
|
|
|
return aFirst->GetSize().y < aSecond->GetSize().y;
|
|
|
|
|
|
|
|
if( aFirst->GetShape() != aSecond->GetShape() )
|
|
|
|
return aFirst->GetShape() < aSecond->GetShape();
|
|
|
|
|
|
|
|
if( aFirst->GetLayerSet().Seq() != aSecond->GetLayerSet().Seq() )
|
|
|
|
return aFirst->GetLayerSet().Seq() < aSecond->GetLayerSet().Seq();
|
2021-07-11 11:49:36 +00:00
|
|
|
|
2023-06-12 18:12:39 +00:00
|
|
|
if( aFirst->m_Uuid != aSecond->m_Uuid )
|
|
|
|
return aFirst->m_Uuid < aSecond->m_Uuid;
|
2020-10-11 17:02:38 +00:00
|
|
|
|
|
|
|
return aFirst < aSecond;
|
2020-07-24 22:08:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-06-12 18:12:39 +00:00
|
|
|
bool FOOTPRINT::cmp_padstack::operator()( const PAD* aFirst, const PAD* aSecond ) const
|
|
|
|
{
|
|
|
|
if( aFirst->GetSize().x != aSecond->GetSize().x )
|
|
|
|
return aFirst->GetSize().x < aSecond->GetSize().x;
|
|
|
|
if( aFirst->GetSize().y != aSecond->GetSize().y )
|
|
|
|
return aFirst->GetSize().y < aSecond->GetSize().y;
|
|
|
|
|
|
|
|
if( aFirst->GetShape() != aSecond->GetShape() )
|
|
|
|
return aFirst->GetShape() < aSecond->GetShape();
|
|
|
|
|
|
|
|
if( aFirst->GetLayerSet().Seq() != aSecond->GetLayerSet().Seq() )
|
|
|
|
return aFirst->GetLayerSet().Seq() < aSecond->GetLayerSet().Seq();
|
|
|
|
|
|
|
|
if( aFirst->GetDrillSizeX() != aSecond->GetDrillSizeX() )
|
|
|
|
return aFirst->GetDrillSizeX() < aSecond->GetDrillSizeX();
|
|
|
|
|
|
|
|
if( aFirst->GetDrillSizeY() != aSecond->GetDrillSizeY() )
|
|
|
|
return aFirst->GetDrillSizeY() < aSecond->GetDrillSizeY();
|
|
|
|
|
|
|
|
if( aFirst->GetDrillShape() != aSecond->GetDrillShape() )
|
|
|
|
return aFirst->GetDrillShape() < aSecond->GetDrillShape();
|
|
|
|
|
|
|
|
if( aFirst->GetAttribute() != aSecond->GetAttribute() )
|
|
|
|
return aFirst->GetAttribute() < aSecond->GetAttribute();
|
|
|
|
|
|
|
|
if( aFirst->GetOrientation() != aSecond->GetOrientation() )
|
|
|
|
return aFirst->GetOrientation() < aSecond->GetOrientation();
|
|
|
|
|
|
|
|
if( aFirst->GetSolderMaskExpansion() != aSecond->GetSolderMaskExpansion() )
|
|
|
|
return aFirst->GetSolderMaskExpansion() < aSecond->GetSolderMaskExpansion();
|
|
|
|
|
|
|
|
if( aFirst->GetSolderPasteMargin() != aSecond->GetSolderPasteMargin() )
|
|
|
|
return aFirst->GetSolderPasteMargin() < aSecond->GetSolderPasteMargin();
|
|
|
|
|
|
|
|
if( aFirst->GetLocalSolderMaskMargin() != aSecond->GetLocalSolderMaskMargin() )
|
|
|
|
return aFirst->GetLocalSolderMaskMargin() < aSecond->GetLocalSolderMaskMargin();
|
|
|
|
|
|
|
|
std::shared_ptr<SHAPE_POLY_SET> firstShape = aFirst->GetEffectivePolygon( ERROR_INSIDE );
|
|
|
|
std::shared_ptr<SHAPE_POLY_SET> secondShape = aSecond->GetEffectivePolygon( ERROR_INSIDE );
|
|
|
|
|
|
|
|
if( firstShape->VertexCount() != secondShape->VertexCount() )
|
|
|
|
return firstShape->VertexCount() < secondShape->VertexCount();
|
|
|
|
|
|
|
|
for( int ii = 0; ii < firstShape->VertexCount(); ++ii )
|
|
|
|
{
|
|
|
|
if( firstShape->CVertex( ii ).x != secondShape->CVertex( ii ).x )
|
|
|
|
return firstShape->CVertex( ii ).x < secondShape->CVertex( ii ).x;
|
|
|
|
if( firstShape->CVertex( ii ).y != secondShape->CVertex( ii ).y )
|
|
|
|
return firstShape->CVertex( ii ).y < secondShape->CVertex( ii ).y;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
bool FOOTPRINT::cmp_zones::operator()( const ZONE* aFirst, const ZONE* aSecond ) const
|
2021-07-11 11:49:36 +00:00
|
|
|
{
|
2023-06-12 18:12:39 +00:00
|
|
|
if( aFirst->GetAssignedPriority() != aSecond->GetAssignedPriority() )
|
|
|
|
return aFirst->GetAssignedPriority() < aSecond->GetAssignedPriority();
|
2021-07-11 11:49:36 +00:00
|
|
|
|
2023-06-12 18:12:39 +00:00
|
|
|
if( aFirst->GetLayerSet().Seq() != aSecond->GetLayerSet().Seq() )
|
|
|
|
return aFirst->GetLayerSet().Seq() < aSecond->GetLayerSet().Seq();
|
|
|
|
|
|
|
|
if( aFirst->Outline()->TotalVertices() != aSecond->Outline()->TotalVertices() )
|
|
|
|
return aFirst->Outline()->TotalVertices() < aSecond->Outline()->TotalVertices();
|
2021-07-11 11:49:36 +00:00
|
|
|
|
|
|
|
for( int ii = 0; ii < aFirst->Outline()->TotalVertices(); ++ii )
|
2023-06-12 18:12:39 +00:00
|
|
|
{
|
|
|
|
if( aFirst->Outline()->CVertex( ii ).x != aSecond->Outline()->CVertex( ii ).x )
|
|
|
|
return aFirst->Outline()->CVertex( ii ).x < aSecond->Outline()->CVertex( ii ).x;
|
|
|
|
if( aFirst->Outline()->CVertex( ii ).y != aSecond->Outline()->CVertex( ii ).y )
|
|
|
|
return aFirst->Outline()->CVertex( ii ).y < aSecond->Outline()->CVertex( ii ).y;
|
|
|
|
}
|
2021-07-11 11:49:36 +00:00
|
|
|
|
2023-06-12 18:12:39 +00:00
|
|
|
if( aFirst->m_Uuid != aSecond->m_Uuid )
|
|
|
|
return aFirst->m_Uuid < aSecond->m_Uuid;
|
2021-07-11 11:49:36 +00:00
|
|
|
|
|
|
|
return aFirst < aSecond;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-10-21 12:48:45 +00:00
|
|
|
void FOOTPRINT::TransformPadsToPolySet( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer,
|
|
|
|
int aClearance, int aMaxError, ERROR_LOC aErrorLoc,
|
|
|
|
bool aSkipNPTHPadsWihNoCopper, bool aSkipPlatedPads,
|
|
|
|
bool aSkipNonPlatedPads ) const
|
2021-10-25 19:50:33 +00:00
|
|
|
{
|
|
|
|
for( const PAD* pad : m_pads )
|
|
|
|
{
|
2022-03-06 13:35:46 +00:00
|
|
|
if( !pad->FlashLayer( aLayer ) )
|
2021-10-25 19:50:33 +00:00
|
|
|
continue;
|
|
|
|
|
2022-03-06 13:35:46 +00:00
|
|
|
VECTOR2I clearance( aClearance, aClearance );
|
2021-10-25 19:50:33 +00:00
|
|
|
|
2022-03-06 13:35:46 +00:00
|
|
|
switch( aLayer )
|
2021-10-25 19:50:33 +00:00
|
|
|
{
|
2022-03-06 13:35:46 +00:00
|
|
|
case F_Cu:
|
|
|
|
if( aSkipPlatedPads && pad->FlashLayer( F_Mask ) )
|
|
|
|
continue;
|
2021-10-25 19:50:33 +00:00
|
|
|
|
2022-03-06 13:35:46 +00:00
|
|
|
if( aSkipNonPlatedPads && !pad->FlashLayer( F_Mask ) )
|
|
|
|
continue;
|
2021-10-25 19:50:33 +00:00
|
|
|
|
2022-03-06 13:35:46 +00:00
|
|
|
break;
|
2021-10-25 19:50:33 +00:00
|
|
|
|
2022-03-06 13:35:46 +00:00
|
|
|
case B_Cu:
|
|
|
|
if( aSkipPlatedPads && pad->FlashLayer( B_Mask ) )
|
|
|
|
continue;
|
2021-10-25 19:50:33 +00:00
|
|
|
|
2022-03-06 13:35:46 +00:00
|
|
|
if( aSkipNonPlatedPads && !pad->FlashLayer( B_Mask ) )
|
|
|
|
continue;
|
2021-10-25 19:50:33 +00:00
|
|
|
|
2022-03-06 13:35:46 +00:00
|
|
|
break;
|
2021-10-25 19:50:33 +00:00
|
|
|
|
|
|
|
case F_Mask:
|
|
|
|
case B_Mask:
|
2021-08-22 22:05:47 +00:00
|
|
|
clearance.x += pad->GetSolderMaskExpansion();
|
|
|
|
clearance.y += pad->GetSolderMaskExpansion();
|
2021-10-25 19:50:33 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case F_Paste:
|
|
|
|
case B_Paste:
|
|
|
|
clearance += pad->GetSolderPasteMargin();
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2022-10-21 12:48:45 +00:00
|
|
|
// Our standard TransformShapeToPolygon() routines can't handle differing x:y clearance
|
|
|
|
// values (which get generated when a relative paste margin is used with an oblong pad).
|
|
|
|
// So we apply this huge hack and fake a larger pad to run the transform on.
|
2021-10-25 19:50:33 +00:00
|
|
|
// Of course being a hack it falls down when dealing with custom shape pads (where the
|
|
|
|
// size is only the size of the anchor), so for those we punt and just use clearance.x.
|
|
|
|
|
|
|
|
if( ( clearance.x < 0 || clearance.x != clearance.y )
|
|
|
|
&& pad->GetShape() != PAD_SHAPE::CUSTOM )
|
|
|
|
{
|
2022-01-05 01:42:27 +00:00
|
|
|
VECTOR2I dummySize = pad->GetSize() + clearance + clearance;
|
2021-11-11 17:35:01 +00:00
|
|
|
|
|
|
|
if( dummySize.x <= 0 || dummySize.y <= 0 )
|
|
|
|
continue;
|
|
|
|
|
2021-10-25 19:50:33 +00:00
|
|
|
PAD dummy( *pad );
|
2021-11-11 17:35:01 +00:00
|
|
|
dummy.SetSize( dummySize );
|
2022-10-21 12:48:45 +00:00
|
|
|
dummy.TransformShapeToPolygon( aBuffer, aLayer, 0, aMaxError, aErrorLoc );
|
2021-10-25 19:50:33 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-10-21 12:48:45 +00:00
|
|
|
pad->TransformShapeToPolygon( aBuffer, aLayer, clearance.x, aMaxError, aErrorLoc );
|
2021-10-25 19:50:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-10-21 12:48:45 +00:00
|
|
|
void FOOTPRINT::TransformFPShapesToPolySet( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer,
|
|
|
|
int aClearance, int aError, ERROR_LOC aErrorLoc,
|
|
|
|
bool aIncludeText, bool aIncludeShapes,
|
|
|
|
bool aIncludePrivateItems ) const
|
2021-10-25 19:50:33 +00:00
|
|
|
{
|
2023-05-24 12:39:25 +00:00
|
|
|
std::vector<const PCB_TEXT*> texts; // List of PCB_TEXTs to convert
|
2021-10-25 19:50:33 +00:00
|
|
|
|
|
|
|
for( BOARD_ITEM* item : GraphicalItems() )
|
|
|
|
{
|
2022-07-07 21:27:29 +00:00
|
|
|
if( GetPrivateLayers().test( item->GetLayer() ) && !aIncludePrivateItems )
|
|
|
|
continue;
|
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
if( item->Type() == PCB_TEXT_T && aIncludeText )
|
2021-10-25 19:50:33 +00:00
|
|
|
{
|
2023-03-30 11:49:23 +00:00
|
|
|
PCB_TEXT* text = static_cast<PCB_TEXT*>( item );
|
2021-10-25 19:50:33 +00:00
|
|
|
|
|
|
|
if( aLayer != UNDEFINED_LAYER && text->GetLayer() == aLayer && text->IsVisible() )
|
|
|
|
texts.push_back( text );
|
|
|
|
}
|
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
if( item->Type() == PCB_TEXTBOX_T && aIncludeText )
|
2022-01-30 10:52:52 +00:00
|
|
|
{
|
2023-03-30 11:49:23 +00:00
|
|
|
PCB_TEXTBOX* textbox = static_cast<PCB_TEXTBOX*>( item );
|
2022-01-30 10:52:52 +00:00
|
|
|
|
|
|
|
if( aLayer != UNDEFINED_LAYER && textbox->GetLayer() == aLayer && textbox->IsVisible() )
|
2023-08-25 16:50:36 +00:00
|
|
|
{
|
|
|
|
// border
|
2023-08-31 02:39:07 +00:00
|
|
|
if( textbox->IsBorderEnabled() )
|
|
|
|
textbox->PCB_SHAPE::TransformShapeToPolygon( aBuffer, aLayer, 0, aError, aErrorLoc );
|
2023-08-25 16:50:36 +00:00
|
|
|
// text
|
|
|
|
textbox->TransformTextToPolySet( aBuffer, 0, aError, aErrorLoc );
|
|
|
|
}
|
2022-01-30 10:52:52 +00:00
|
|
|
}
|
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
if( item->Type() == PCB_SHAPE_T && aIncludeShapes )
|
2021-10-25 19:50:33 +00:00
|
|
|
{
|
2023-03-30 11:49:23 +00:00
|
|
|
const PCB_SHAPE* outline = static_cast<PCB_SHAPE*>( item );
|
2021-10-25 19:50:33 +00:00
|
|
|
|
|
|
|
if( aLayer != UNDEFINED_LAYER && outline->GetLayer() == aLayer )
|
2022-10-21 12:48:45 +00:00
|
|
|
outline->TransformShapeToPolygon( aBuffer, aLayer, 0, aError, aErrorLoc );
|
2021-10-25 19:50:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( aIncludeText )
|
|
|
|
{
|
2023-05-24 12:39:25 +00:00
|
|
|
for( const PCB_FIELD* field : m_fields )
|
|
|
|
{
|
|
|
|
if( field->GetLayer() == aLayer && field->IsVisible() )
|
|
|
|
texts.push_back( field );
|
|
|
|
}
|
2021-10-25 19:50:33 +00:00
|
|
|
}
|
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
for( const PCB_TEXT* text : texts )
|
2023-05-28 16:20:11 +00:00
|
|
|
text->TransformTextToPolySet( aBuffer, aClearance, aError, aErrorLoc );
|
2021-10-25 19:50:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-14 19:16:42 +00:00
|
|
|
static struct FOOTPRINT_DESC
|
2020-02-02 18:40:14 +00:00
|
|
|
{
|
2020-11-14 19:16:42 +00:00
|
|
|
FOOTPRINT_DESC()
|
2020-02-02 18:40:14 +00:00
|
|
|
{
|
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 );
|
|
|
|
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" ) )
|
|
|
|
.Map( ZONE_CONNECTION::THT_THERMAL, _HKI( "Thermal reliefs for PTH" ) );
|
|
|
|
}
|
|
|
|
|
2020-08-18 21:42:56 +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 ) );
|
|
|
|
}
|
|
|
|
|
2020-02-05 15:04:12 +00:00
|
|
|
wxPGChoices fpLayers; // footprints might be placed only on F.Cu & B.Cu
|
|
|
|
fpLayers.Add( LSET::Name( F_Cu ), F_Cu );
|
|
|
|
fpLayers.Add( LSET::Name( B_Cu ), B_Cu );
|
|
|
|
|
2020-02-02 18:40:14 +00:00
|
|
|
PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance();
|
2020-11-13 15:15:52 +00:00
|
|
|
REGISTER_TYPE( FOOTPRINT );
|
|
|
|
propMgr.AddTypeCast( new TYPE_CAST<FOOTPRINT, BOARD_ITEM> );
|
|
|
|
propMgr.AddTypeCast( new TYPE_CAST<FOOTPRINT, BOARD_ITEM_CONTAINER> );
|
|
|
|
propMgr.InheritsAfter( TYPE_HASH( FOOTPRINT ), TYPE_HASH( BOARD_ITEM ) );
|
|
|
|
propMgr.InheritsAfter( TYPE_HASH( FOOTPRINT ), TYPE_HASH( BOARD_ITEM_CONTAINER ) );
|
|
|
|
|
2022-11-25 03:11:26 +00:00
|
|
|
auto layer = new PROPERTY_ENUM<FOOTPRINT, PCB_LAYER_ID>( _HKI( "Layer" ),
|
|
|
|
&FOOTPRINT::SetLayerAndFlip, &FOOTPRINT::GetLayer );
|
2020-02-05 15:04:12 +00:00
|
|
|
layer->SetChoices( fpLayers );
|
2020-10-16 15:51:24 +00:00
|
|
|
propMgr.ReplaceProperty( TYPE_HASH( BOARD_ITEM ), _HKI( "Layer" ), layer );
|
2022-11-25 03:11:26 +00:00
|
|
|
|
2022-11-29 23:55:43 +00:00
|
|
|
propMgr.AddProperty( new PROPERTY<FOOTPRINT, double>( _HKI( "Orientation" ),
|
|
|
|
&FOOTPRINT::SetOrientationDegrees, &FOOTPRINT::GetOrientationDegrees,
|
|
|
|
PROPERTY_DISPLAY::PT_DEGREE ) );
|
|
|
|
|
2024-01-18 16:08:34 +00:00
|
|
|
const wxString groupFields = _HKI( "Fields" );
|
2022-11-28 03:40:14 +00:00
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
propMgr.AddProperty( new PROPERTY<FOOTPRINT, wxString>( _HKI( "Reference" ),
|
2022-11-28 03:40:14 +00:00
|
|
|
&FOOTPRINT::SetReference, &FOOTPRINT::GetReferenceAsString ),
|
2024-01-18 16:08:34 +00:00
|
|
|
groupFields );
|
2020-11-13 15:15:52 +00:00
|
|
|
propMgr.AddProperty( new PROPERTY<FOOTPRINT, wxString>( _HKI( "Value" ),
|
2022-11-28 03:40:14 +00:00
|
|
|
&FOOTPRINT::SetValue, &FOOTPRINT::GetValueAsString ),
|
2024-01-18 16:08:34 +00:00
|
|
|
groupFields );
|
2022-11-25 21:29:56 +00:00
|
|
|
|
2023-11-23 20:32:29 +00:00
|
|
|
propMgr.AddProperty( new PROPERTY<FOOTPRINT, wxString>( _HKI( "Library Link" ),
|
2022-11-28 03:40:14 +00:00
|
|
|
NO_SETTER( FOOTPRINT, wxString ), &FOOTPRINT::GetFPIDAsString ),
|
2024-01-18 16:08:34 +00:00
|
|
|
groupFields );
|
2023-11-23 20:32:29 +00:00
|
|
|
propMgr.AddProperty( new PROPERTY<FOOTPRINT, wxString>( _HKI( "Library Description" ),
|
2023-06-19 17:08:18 +00:00
|
|
|
NO_SETTER( FOOTPRINT, wxString ), &FOOTPRINT::GetLibDescription ),
|
2024-01-18 16:08:34 +00:00
|
|
|
groupFields );
|
2022-06-01 11:47:03 +00:00
|
|
|
propMgr.AddProperty( new PROPERTY<FOOTPRINT, wxString>( _HKI( "Keywords" ),
|
2022-11-28 03:40:14 +00:00
|
|
|
NO_SETTER( FOOTPRINT, wxString ), &FOOTPRINT::GetKeywords ),
|
2024-01-18 16:08:34 +00:00
|
|
|
groupFields );
|
2022-11-28 03:40:14 +00:00
|
|
|
|
2023-05-02 13:18:41 +00:00
|
|
|
const wxString groupAttributes = _HKI( "Attributes" );
|
2022-11-25 16:49:21 +00:00
|
|
|
|
2023-11-23 20:32:29 +00:00
|
|
|
propMgr.AddProperty( new PROPERTY<FOOTPRINT, bool>( _HKI( "Not in Schematic" ),
|
2022-11-28 03:40:14 +00:00
|
|
|
&FOOTPRINT::SetBoardOnly, &FOOTPRINT::IsBoardOnly ), groupAttributes );
|
2023-11-23 20:32:29 +00:00
|
|
|
propMgr.AddProperty( new PROPERTY<FOOTPRINT, bool>( _HKI( "Exclude From Position Files" ),
|
2022-11-28 03:40:14 +00:00
|
|
|
&FOOTPRINT::SetExcludedFromPosFiles, &FOOTPRINT::IsExcludedFromPosFiles ),
|
|
|
|
groupAttributes );
|
2023-11-23 20:32:29 +00:00
|
|
|
propMgr.AddProperty( new PROPERTY<FOOTPRINT, bool>( _HKI( "Exclude From Bill of Materials" ),
|
2022-11-28 03:40:14 +00:00
|
|
|
&FOOTPRINT::SetExcludedFromBOM, &FOOTPRINT::IsExcludedFromBOM ),
|
|
|
|
groupAttributes );
|
2023-11-23 20:32:29 +00:00
|
|
|
propMgr.AddProperty( new PROPERTY<FOOTPRINT, bool>( _HKI( "Do not Populate" ),
|
2023-04-10 17:10:42 +00:00
|
|
|
&FOOTPRINT::SetDNP, &FOOTPRINT::IsDNP ),
|
|
|
|
groupAttributes );
|
2022-11-28 03:40:14 +00:00
|
|
|
|
2022-12-27 01:10:22 +00:00
|
|
|
const wxString groupOverrides = _HKI( "Overrides" );
|
2022-11-28 03:40:14 +00:00
|
|
|
|
2022-11-25 16:49:21 +00:00
|
|
|
propMgr.AddProperty( new PROPERTY<FOOTPRINT, bool>(
|
2023-11-23 20:32:29 +00:00
|
|
|
_HKI( "Exempt From Courtyard Requirement" ),
|
2022-11-28 03:40:14 +00:00
|
|
|
&FOOTPRINT::SetAllowMissingCourtyard, &FOOTPRINT::AllowMissingCourtyard ),
|
|
|
|
groupOverrides );
|
2022-11-25 21:29:56 +00:00
|
|
|
propMgr.AddProperty( new PROPERTY<FOOTPRINT, int>( _HKI( "Clearance Override" ),
|
|
|
|
&FOOTPRINT::SetLocalClearance, &FOOTPRINT::GetLocalClearance,
|
2022-11-28 03:40:14 +00:00
|
|
|
PROPERTY_DISPLAY::PT_SIZE ),
|
|
|
|
groupOverrides );
|
2022-11-25 21:29:56 +00:00
|
|
|
propMgr.AddProperty( new PROPERTY<FOOTPRINT, int>( _HKI( "Solderpaste Margin Override" ),
|
|
|
|
&FOOTPRINT::SetLocalSolderPasteMargin, &FOOTPRINT::GetLocalSolderPasteMargin,
|
2022-11-28 03:40:14 +00:00
|
|
|
PROPERTY_DISPLAY::PT_SIZE ),
|
|
|
|
groupOverrides );
|
2022-11-25 21:29:56 +00:00
|
|
|
propMgr.AddProperty( new PROPERTY<FOOTPRINT, double>(
|
|
|
|
_HKI( "Solderpaste Margin Ratio Override" ),
|
|
|
|
&FOOTPRINT::SetLocalSolderPasteMarginRatio,
|
2022-11-28 03:40:14 +00:00
|
|
|
&FOOTPRINT::GetLocalSolderPasteMarginRatio ),
|
|
|
|
groupOverrides );
|
2022-11-25 23:44:02 +00:00
|
|
|
propMgr.AddProperty( new PROPERTY_ENUM<FOOTPRINT, ZONE_CONNECTION>(
|
|
|
|
_HKI( "Zone Connection Style" ),
|
2022-11-28 03:40:14 +00:00
|
|
|
&FOOTPRINT::SetZoneConnection, &FOOTPRINT::GetZoneConnection ),
|
|
|
|
groupOverrides );
|
2020-02-02 18:40:14 +00:00
|
|
|
}
|
2020-11-14 19:16:42 +00:00
|
|
|
} _FOOTPRINT_DESC;
|