2020-01-04 23:48:18 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2007 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
2023-02-28 15:34:07 +00:00
|
|
|
* Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
2020-01-04 23:48:18 +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
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef CLASS_BOARD_H_
|
|
|
|
#define CLASS_BOARD_H_
|
|
|
|
|
|
|
|
#include <board_item_container.h>
|
2020-10-26 02:29:53 +00:00
|
|
|
#include <common.h> // Needed for stl hash extensions
|
2021-07-14 20:03:32 +00:00
|
|
|
#include <convert_shape_list_to_polygon.h> // for OUTLINE_ERROR_HANDLER
|
2022-08-26 15:42:22 +00:00
|
|
|
#include <hash.h>
|
2021-07-29 09:47:43 +00:00
|
|
|
#include <layer_ids.h>
|
2020-01-04 23:48:18 +00:00
|
|
|
#include <netinfo.h>
|
2021-06-03 18:05:43 +00:00
|
|
|
#include <pcb_item_containers.h>
|
2020-01-04 23:48:18 +00:00
|
|
|
#include <pcb_plot_params.h>
|
|
|
|
#include <title_block.h>
|
2020-12-16 13:31:32 +00:00
|
|
|
#include <tools/pcb_selection.h>
|
2024-03-06 14:26:30 +00:00
|
|
|
#include <shared_mutex>
|
2021-06-06 19:30:42 +00:00
|
|
|
#include <list>
|
2020-01-04 23:48:18 +00:00
|
|
|
|
2021-06-06 19:03:10 +00:00
|
|
|
class BOARD_DESIGN_SETTINGS;
|
|
|
|
class BOARD_CONNECTED_ITEM;
|
2020-08-11 19:37:07 +00:00
|
|
|
class BOARD_COMMIT;
|
2021-06-03 18:05:43 +00:00
|
|
|
class DRC_RTREE;
|
2020-01-04 23:48:18 +00:00
|
|
|
class PCB_BASE_FRAME;
|
|
|
|
class PCB_EDIT_FRAME;
|
|
|
|
class PICKED_ITEMS_LIST;
|
|
|
|
class BOARD;
|
2021-06-03 18:05:43 +00:00
|
|
|
class FOOTPRINT;
|
2020-11-11 23:05:59 +00:00
|
|
|
class ZONE;
|
2021-06-11 21:07:02 +00:00
|
|
|
class PCB_TRACK;
|
2020-11-12 22:30:02 +00:00
|
|
|
class PAD;
|
2021-06-03 17:03:25 +00:00
|
|
|
class PCB_GROUP;
|
2023-10-06 17:04:00 +00:00
|
|
|
class PCB_GENERATOR;
|
2020-11-14 18:11:28 +00:00
|
|
|
class PCB_MARKER;
|
2020-01-04 23:48:18 +00:00
|
|
|
class MSG_PANEL_ITEM;
|
|
|
|
class NETLIST;
|
|
|
|
class REPORTER;
|
|
|
|
class SHAPE_POLY_SET;
|
|
|
|
class CONNECTIVITY_DATA;
|
|
|
|
class COMPONENT;
|
2020-03-26 11:02:59 +00:00
|
|
|
class PROJECT;
|
2021-11-25 16:19:03 +00:00
|
|
|
class PROGRESS_REPORTER;
|
2023-03-25 10:44:46 +00:00
|
|
|
struct ISOLATED_ISLANDS;
|
2020-01-04 23:48:18 +00:00
|
|
|
|
2023-02-28 15:34:07 +00:00
|
|
|
// The default value for m_outlinesChainingEpsilon to convert a board outlines to polygons
|
|
|
|
// It is the max dist between 2 end points to see them connected
|
|
|
|
#define DEFAULT_CHAINING_EPSILON_MM 0.01
|
|
|
|
|
2019-05-17 00:13:21 +00:00
|
|
|
// Forward declare endpoint from class_track.h
|
|
|
|
enum ENDPOINT_T : int;
|
|
|
|
|
2022-08-03 09:10:23 +00:00
|
|
|
|
|
|
|
struct PTR_PTR_CACHE_KEY
|
|
|
|
{
|
|
|
|
BOARD_ITEM* A;
|
|
|
|
BOARD_ITEM* B;
|
|
|
|
|
|
|
|
bool operator==(const PTR_PTR_CACHE_KEY& other) const
|
|
|
|
{
|
|
|
|
return A == other.A && B == other.B;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-08-22 11:36:41 +00:00
|
|
|
struct PTR_LAYER_CACHE_KEY
|
|
|
|
{
|
|
|
|
BOARD_ITEM* A;
|
|
|
|
PCB_LAYER_ID Layer;
|
|
|
|
|
|
|
|
bool operator==(const PTR_LAYER_CACHE_KEY& other) const
|
|
|
|
{
|
|
|
|
return A == other.A && Layer == other.Layer;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-08-03 09:10:23 +00:00
|
|
|
struct PTR_PTR_LAYER_CACHE_KEY
|
|
|
|
{
|
|
|
|
BOARD_ITEM* A;
|
|
|
|
BOARD_ITEM* B;
|
|
|
|
PCB_LAYER_ID Layer;
|
|
|
|
|
|
|
|
bool operator==(const PTR_PTR_LAYER_CACHE_KEY& other) const
|
|
|
|
{
|
|
|
|
return A == other.A && B == other.B && Layer == other.Layer;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
namespace std
|
|
|
|
{
|
|
|
|
template <>
|
|
|
|
struct hash<PTR_PTR_CACHE_KEY>
|
|
|
|
{
|
|
|
|
std::size_t operator()( const PTR_PTR_CACHE_KEY& k ) const
|
|
|
|
{
|
2022-08-26 15:42:22 +00:00
|
|
|
std::size_t seed = 0xa82de1c0;
|
|
|
|
hash_combine( seed, k.A, k.B );
|
|
|
|
return seed;
|
2022-08-03 09:10:23 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-08-22 11:36:41 +00:00
|
|
|
template <>
|
|
|
|
struct hash<PTR_LAYER_CACHE_KEY>
|
|
|
|
{
|
|
|
|
std::size_t operator()( const PTR_LAYER_CACHE_KEY& k ) const
|
|
|
|
{
|
2022-08-26 15:42:22 +00:00
|
|
|
std::size_t seed = 0xa82de1c0;
|
|
|
|
hash_combine( seed, k.A, k.Layer );
|
|
|
|
return seed;
|
2022-08-22 11:36:41 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-08-03 09:10:23 +00:00
|
|
|
template <>
|
|
|
|
struct hash<PTR_PTR_LAYER_CACHE_KEY>
|
|
|
|
{
|
|
|
|
std::size_t operator()( const PTR_PTR_LAYER_CACHE_KEY& k ) const
|
|
|
|
{
|
2022-08-26 15:42:22 +00:00
|
|
|
std::size_t seed = 0xa82de1c0;
|
|
|
|
hash_combine( seed, k.A, k.B, k.Layer );
|
|
|
|
return seed;
|
2022-08-03 09:10:23 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-01-04 23:48:18 +00:00
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* The allowed types of layers, same as Specctra DSN spec.
|
2020-01-04 23:48:18 +00:00
|
|
|
*/
|
|
|
|
enum LAYER_T
|
|
|
|
{
|
|
|
|
LT_UNDEFINED = -1,
|
|
|
|
LT_SIGNAL,
|
|
|
|
LT_POWER,
|
|
|
|
LT_MIXED,
|
|
|
|
LT_JUMPER
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* Container to hold information pertinent to a layer of a BOARD.
|
2020-01-04 23:48:18 +00:00
|
|
|
*/
|
|
|
|
struct LAYER
|
|
|
|
{
|
|
|
|
LAYER()
|
|
|
|
{
|
|
|
|
clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
void clear()
|
|
|
|
{
|
|
|
|
m_type = LT_SIGNAL;
|
|
|
|
m_visible = true;
|
|
|
|
m_number = 0;
|
|
|
|
m_name.clear();
|
2020-09-22 21:50:59 +00:00
|
|
|
m_userName.clear();
|
2020-01-04 23:48:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
LAYER( const wxString& aName = wxEmptyString,
|
|
|
|
LAYER_T aType = LT_SIGNAL, bool aVisible = true, int aNumber = -1 ) :
|
|
|
|
m_name( aName ),
|
|
|
|
m_type( aType ),
|
|
|
|
m_visible( aVisible ),
|
|
|
|
m_number( aNumber )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
2020-09-22 21:50:59 +00:00
|
|
|
wxString m_name; ///< The canonical name of the layer. @see #LSET::Name
|
|
|
|
wxString m_userName; ///< The user defined name of the layer.
|
|
|
|
LAYER_T m_type; ///< The type of the layer. @see #LAYER_T
|
2020-01-04 23:48:18 +00:00
|
|
|
bool m_visible;
|
2020-09-22 21:50:59 +00:00
|
|
|
int m_number; ///< The layer ID. @see PCB_LAYER_ID
|
2020-01-04 23:48:18 +00:00
|
|
|
|
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* Convert a #LAYER_T enum to a string representation of the layer type.
|
|
|
|
*
|
|
|
|
* @param aType The #LAYER_T to convert
|
2021-06-04 13:04:30 +00:00
|
|
|
* @return The string representation of the layer type.
|
2020-01-04 23:48:18 +00:00
|
|
|
*/
|
|
|
|
static const char* ShowType( LAYER_T aType );
|
|
|
|
|
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* Convert a string to a #LAYER_T
|
|
|
|
*
|
2021-06-04 13:04:30 +00:00
|
|
|
* @param aType The layer name to convert.
|
|
|
|
* @return The binary representation of the layer type, or
|
|
|
|
* LAYER_T(-1) if the string is invalid.
|
2020-01-04 23:48:18 +00:00
|
|
|
*/
|
|
|
|
static LAYER_T ParseType( const char* aType );
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Helper class to handle high light nets
|
|
|
|
class HIGH_LIGHT_INFO
|
|
|
|
{
|
|
|
|
protected:
|
2020-05-24 17:30:23 +00:00
|
|
|
std::set<int> m_netCodes; // net(s) selected for highlight (-1 when no net selected )
|
|
|
|
bool m_highLightOn; // highlight active
|
2020-01-04 23:48:18 +00:00
|
|
|
|
|
|
|
void Clear()
|
|
|
|
{
|
2020-05-24 17:30:23 +00:00
|
|
|
m_netCodes.clear();
|
2020-01-04 23:48:18 +00:00
|
|
|
m_highLightOn = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
HIGH_LIGHT_INFO()
|
|
|
|
{
|
|
|
|
Clear();
|
|
|
|
}
|
2021-06-04 13:04:30 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
friend class BOARD;
|
2020-01-04 23:48:18 +00:00
|
|
|
};
|
|
|
|
|
2020-04-12 19:29:16 +00:00
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* Provide an interface to hook into board modifications and get callbacks
|
2020-04-12 19:29:16 +00:00
|
|
|
* on certain modifications that are made to the board. This allows updating
|
|
|
|
* auxiliary views other than the primary board editor view.
|
|
|
|
*/
|
|
|
|
class BOARD;
|
|
|
|
|
|
|
|
class BOARD_LISTENER
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~BOARD_LISTENER() { }
|
|
|
|
virtual void OnBoardItemAdded( BOARD& aBoard, BOARD_ITEM* aBoardItem ) { }
|
2020-12-07 23:29:30 +00:00
|
|
|
virtual void OnBoardItemsAdded( BOARD& aBoard, std::vector<BOARD_ITEM*>& aBoardItem ) { }
|
2020-04-12 19:29:16 +00:00
|
|
|
virtual void OnBoardItemRemoved( BOARD& aBoard, BOARD_ITEM* aBoardItem ) { }
|
2020-12-07 23:29:30 +00:00
|
|
|
virtual void OnBoardItemsRemoved( BOARD& aBoard, std::vector<BOARD_ITEM*>& aBoardItem ) { }
|
2020-04-12 19:29:16 +00:00
|
|
|
virtual void OnBoardNetSettingsChanged( BOARD& aBoard ) { }
|
|
|
|
virtual void OnBoardItemChanged( BOARD& aBoard, BOARD_ITEM* aBoardItem ) { }
|
2020-12-07 23:29:30 +00:00
|
|
|
virtual void OnBoardItemsChanged( BOARD& aBoard, std::vector<BOARD_ITEM*>& aBoardItem ) { }
|
2020-04-12 19:29:16 +00:00
|
|
|
virtual void OnBoardHighlightNetChanged( BOARD& aBoard ) { }
|
2023-08-17 14:24:59 +00:00
|
|
|
virtual void OnBoardRatsnestChanged( BOARD& aBoard ) { }
|
2020-04-12 19:29:16 +00:00
|
|
|
};
|
|
|
|
|
2023-09-14 21:39:42 +00:00
|
|
|
/**
|
|
|
|
* Set of BOARD_ITEMs ordered by UUID.
|
|
|
|
*/
|
|
|
|
typedef std::set<BOARD_ITEM*, CompareByUuid> BOARD_ITEM_SET;
|
2020-01-04 23:48:18 +00:00
|
|
|
|
2020-02-27 17:46:49 +00:00
|
|
|
/**
|
|
|
|
* Flags to specify how the board is being used.
|
|
|
|
*/
|
|
|
|
enum class BOARD_USE
|
|
|
|
{
|
|
|
|
NORMAL, // A normal board
|
|
|
|
FPHOLDER // A board that holds a single footprint
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-01-04 23:48:18 +00:00
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* Information pertinent to a Pcbnew printed circuit board.
|
2020-01-04 23:48:18 +00:00
|
|
|
*/
|
|
|
|
class BOARD : public BOARD_ITEM_CONTAINER
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static inline bool ClassOf( const EDA_ITEM* aItem )
|
|
|
|
{
|
|
|
|
return aItem && PCB_T == aItem->Type();
|
|
|
|
}
|
|
|
|
|
2020-02-27 17:46:49 +00:00
|
|
|
/**
|
|
|
|
* Set what the board is going to be used for.
|
|
|
|
*
|
|
|
|
* @param aUse is the flag
|
|
|
|
*/
|
|
|
|
void SetBoardUse( BOARD_USE aUse ) { m_boardUse = aUse; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get what the board use is.
|
|
|
|
*
|
|
|
|
* @return what the board is being used for
|
|
|
|
*/
|
2020-12-20 18:44:13 +00:00
|
|
|
BOARD_USE GetBoardUse() const { return m_boardUse; }
|
2020-02-27 17:46:49 +00:00
|
|
|
|
2021-06-03 18:05:43 +00:00
|
|
|
void IncrementTimeStamp();
|
2021-02-26 19:19:56 +00:00
|
|
|
|
2021-08-16 09:53:27 +00:00
|
|
|
int GetTimeStamp() const { return m_timeStamp; }
|
2021-02-26 13:49:40 +00:00
|
|
|
|
2020-02-27 17:46:49 +00:00
|
|
|
/**
|
|
|
|
* Find out if the board is being used to hold a single footprint for editing/viewing.
|
|
|
|
*
|
|
|
|
* @return if the board is just holding a footprint
|
|
|
|
*/
|
2020-12-20 18:44:13 +00:00
|
|
|
bool IsFootprintHolder() const
|
2020-02-27 17:46:49 +00:00
|
|
|
{
|
|
|
|
return m_boardUse == BOARD_USE::FPHOLDER;
|
|
|
|
}
|
|
|
|
|
2020-01-04 23:48:18 +00:00
|
|
|
void SetFileName( const wxString& aFileName ) { m_fileName = aFileName; }
|
|
|
|
|
|
|
|
const wxString &GetFileName() const { return m_fileName; }
|
|
|
|
|
2020-08-19 18:21:24 +00:00
|
|
|
const TRACKS& Tracks() const { return m_tracks; }
|
2020-01-04 23:48:18 +00:00
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
const FOOTPRINTS& Footprints() const { return m_footprints; }
|
2020-01-04 23:48:18 +00:00
|
|
|
|
2020-09-25 17:37:03 +00:00
|
|
|
const DRAWINGS& Drawings() const { return m_drawings; }
|
2020-01-04 23:48:18 +00:00
|
|
|
|
2020-11-11 23:05:59 +00:00
|
|
|
const ZONES& Zones() const { return m_zones; }
|
2020-01-04 23:48:18 +00:00
|
|
|
|
2023-10-06 17:04:00 +00:00
|
|
|
const GENERATORS& Generators() const { return m_generators; }
|
|
|
|
|
2020-12-20 18:44:13 +00:00
|
|
|
const MARKERS& Markers() const { return m_markers; }
|
2020-02-28 00:05:40 +00:00
|
|
|
|
2024-03-27 22:42:30 +00:00
|
|
|
// SWIG requires non-const accessors for some reason to make the custom iterators in board.i
|
|
|
|
// work. It would be good to remove this if we can figure out how to fix that.
|
|
|
|
#ifdef SWIG
|
|
|
|
DRAWINGS& Drawings() { return m_drawings; }
|
|
|
|
TRACKS& Tracks() { return m_tracks; }
|
|
|
|
#endif
|
|
|
|
|
2023-09-14 21:39:42 +00:00
|
|
|
const BOARD_ITEM_SET GetItemSet();
|
2023-02-11 09:03:19 +00:00
|
|
|
|
2020-08-11 19:37:07 +00:00
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* The groups must maintain the following invariants. These are checked by
|
2020-08-11 19:37:07 +00:00
|
|
|
* GroupsSanityCheck():
|
|
|
|
* - An item may appear in at most one group
|
2020-09-22 21:50:59 +00:00
|
|
|
* - Each group must contain at least one item
|
2020-08-11 19:37:07 +00:00
|
|
|
* - If a group specifies a name, it must be unique
|
2021-06-04 13:04:30 +00:00
|
|
|
* - The graph of groups containing subgroups must be cyclic.
|
2020-08-11 19:37:07 +00:00
|
|
|
*/
|
2020-12-20 18:44:13 +00:00
|
|
|
const GROUPS& Groups() const { return m_groups; }
|
2020-08-11 19:37:07 +00:00
|
|
|
|
2020-01-04 23:48:18 +00:00
|
|
|
const std::vector<BOARD_CONNECTED_ITEM*> AllConnectedItems();
|
|
|
|
|
2020-08-19 18:21:24 +00:00
|
|
|
const std::map<wxString, wxString>& GetProperties() const { return m_properties; }
|
|
|
|
void SetProperties( const std::map<wxString, wxString>& aProps ) { m_properties = aProps; }
|
|
|
|
|
2023-05-24 11:08:52 +00:00
|
|
|
void GetContextualTextVars( wxArrayString* aVars ) const;
|
2020-08-19 18:21:24 +00:00
|
|
|
bool ResolveTextVar( wxString* token, int aDepth ) const;
|
2020-01-04 23:48:18 +00:00
|
|
|
|
2020-05-31 21:42:04 +00:00
|
|
|
/// Visibility settings stored in board prior to 6.0, only used for loading legacy files
|
|
|
|
LSET m_LegacyVisibleLayers;
|
|
|
|
GAL_SET m_LegacyVisibleItems;
|
|
|
|
|
|
|
|
/// True if the legacy board design settings were loaded from a file
|
|
|
|
bool m_LegacyDesignSettingsLoaded;
|
2020-11-19 13:25:30 +00:00
|
|
|
bool m_LegacyCopperEdgeClearanceLoaded;
|
2020-05-31 21:42:04 +00:00
|
|
|
|
|
|
|
/// True if netclasses were loaded from the file
|
|
|
|
bool m_LegacyNetclassesLoaded;
|
|
|
|
|
2020-01-04 23:48:18 +00:00
|
|
|
BOARD();
|
|
|
|
~BOARD();
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I GetPosition() const override;
|
|
|
|
void SetPosition( const VECTOR2I& aPos ) override;
|
|
|
|
const VECTOR2I GetFocusPosition() const override { return GetBoundingBox().GetCenter(); }
|
2020-01-04 23:48:18 +00:00
|
|
|
|
|
|
|
bool IsEmpty() const
|
|
|
|
{
|
2020-11-12 23:50:33 +00:00
|
|
|
return m_drawings.empty() && m_footprints.empty() && m_tracks.empty() && m_zones.empty();
|
2020-01-04 23:48:18 +00:00
|
|
|
}
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
void Move( const VECTOR2I& aMoveVector ) override;
|
2020-01-04 23:48:18 +00:00
|
|
|
|
|
|
|
void SetFileFormatVersionAtLoad( int aVersion ) { m_fileFormatVersionAtLoad = aVersion; }
|
2021-06-08 21:11:48 +00:00
|
|
|
int GetFileFormatVersionAtLoad() const { return m_fileFormatVersionAtLoad; }
|
|
|
|
|
|
|
|
void SetGenerator( const wxString& aGenerator ) { m_generator = aGenerator; }
|
|
|
|
const wxString& GetGenerator() const { return m_generator; }
|
2020-01-04 23:48:18 +00:00
|
|
|
|
2022-02-18 12:23:50 +00:00
|
|
|
///< @copydoc BOARD_ITEM_CONTAINER::Add()
|
|
|
|
void Add( BOARD_ITEM* aItem, ADD_MODE aMode = ADD_MODE::INSERT,
|
|
|
|
bool aSkipConnectivity = false ) override;
|
2020-01-04 23:48:18 +00:00
|
|
|
|
2022-02-18 12:23:50 +00:00
|
|
|
///< @copydoc BOARD_ITEM_CONTAINER::Remove()
|
2020-12-07 23:29:30 +00:00
|
|
|
void Remove( BOARD_ITEM* aBoardItem, REMOVE_MODE aMode = REMOVE_MODE::NORMAL ) override;
|
|
|
|
|
2024-03-25 21:37:40 +00:00
|
|
|
/**
|
|
|
|
* An efficient way to remove all items of a certain type from the board.
|
|
|
|
* Because of how items are stored, this method has some limitations in order to preserve
|
|
|
|
* performance: tracks, vias, and arcs are all removed together by PCB_TRACE_T, and all graphics
|
|
|
|
* and text object types are removed together by PCB_SHAPE_T. If you need something more
|
|
|
|
* granular than that, use BOARD::Remove.
|
|
|
|
* @param aTypes is a list of one or more types to remove, or leave default to remove all
|
|
|
|
*/
|
2024-03-26 23:38:28 +00:00
|
|
|
void RemoveAll( std::initializer_list<KICAD_T> aTypes = { PCB_NETINFO_T, PCB_MARKER_T,
|
|
|
|
PCB_GROUP_T, PCB_ZONE_T,
|
|
|
|
PCB_GENERATOR_T, PCB_FOOTPRINT_T,
|
|
|
|
PCB_TRACE_T, PCB_SHAPE_T } );
|
2024-03-25 21:37:40 +00:00
|
|
|
|
2020-12-07 23:29:30 +00:00
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* Must be used if Add() is used using a BULK_x ADD_MODE to generate a change event for
|
|
|
|
* listeners.
|
2020-12-07 23:29:30 +00:00
|
|
|
*/
|
|
|
|
void FinalizeBulkAdd( std::vector<BOARD_ITEM*>& aNewItems );
|
|
|
|
|
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* Must be used if Remove() is used using a BULK_x REMOVE_MODE to generate a change event
|
|
|
|
* for listeners.
|
2020-12-07 23:29:30 +00:00
|
|
|
*/
|
|
|
|
void FinalizeBulkRemove( std::vector<BOARD_ITEM*>& aRemovedItems );
|
2020-01-04 23:48:18 +00:00
|
|
|
|
2022-02-15 15:19:39 +00:00
|
|
|
void CacheTriangulation( PROGRESS_REPORTER* aReporter = nullptr,
|
|
|
|
const std::vector<ZONE*>& aZones = {} );
|
2022-02-15 12:17:31 +00:00
|
|
|
|
2020-01-04 23:48:18 +00:00
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* Get the first footprint on the board or nullptr.
|
|
|
|
*
|
2020-11-08 21:29:04 +00:00
|
|
|
* This is used primarily by the footprint editor which knows there is only one.
|
2021-06-04 13:04:30 +00:00
|
|
|
*
|
2020-11-13 11:17:15 +00:00
|
|
|
* @return first footprint or null pointer
|
2020-01-04 23:48:18 +00:00
|
|
|
*/
|
2020-11-13 15:15:52 +00:00
|
|
|
FOOTPRINT* GetFirstFootprint() const
|
2020-01-04 23:48:18 +00:00
|
|
|
{
|
2020-11-12 23:50:33 +00:00
|
|
|
return m_footprints.empty() ? nullptr : m_footprints.front();
|
2020-01-04 23:48:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* Remove all footprints from the deque and free the memory associated with them.
|
2020-01-04 23:48:18 +00:00
|
|
|
*/
|
2021-06-03 18:05:43 +00:00
|
|
|
void DeleteAllFootprints();
|
2020-01-04 23:48:18 +00:00
|
|
|
|
2020-08-11 19:37:07 +00:00
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* @return null if aID is null. Returns an object of Type() == NOT_USED if the aID is not found.
|
2020-08-11 19:37:07 +00:00
|
|
|
*/
|
2020-09-25 17:37:03 +00:00
|
|
|
BOARD_ITEM* GetItem( const KIID& aID ) const;
|
2020-01-04 23:48:18 +00:00
|
|
|
|
2020-04-24 13:36:10 +00:00
|
|
|
void FillItemMap( std::map<KIID, EDA_ITEM*>& aMap );
|
|
|
|
|
2020-09-19 19:41:54 +00:00
|
|
|
/**
|
|
|
|
* Convert cross-references back and forth between ${refDes:field} and ${kiid:field}
|
|
|
|
*/
|
2021-03-06 09:27:41 +00:00
|
|
|
wxString ConvertCrossReferencesToKIIDs( const wxString& aSource ) const;
|
|
|
|
wxString ConvertKIIDsToCrossReferences( const wxString& aSource ) const;
|
2020-09-19 19:41:54 +00:00
|
|
|
|
2020-01-04 23:48:18 +00:00
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* Return a list of missing connections between components/tracks.
|
|
|
|
* @return an object that contains information about missing connections.
|
2020-01-04 23:48:18 +00:00
|
|
|
*/
|
2020-03-26 11:02:59 +00:00
|
|
|
std::shared_ptr<CONNECTIVITY_DATA> GetConnectivity() const { return m_connectivity; }
|
2020-01-04 23:48:18 +00:00
|
|
|
|
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* Build or rebuild the board connectivity database for the board,
|
2020-01-04 23:48:18 +00:00
|
|
|
* especially the list of connected items, list of nets and rastnest data
|
|
|
|
* Needed after loading a board to have the connectivity database updated.
|
|
|
|
*/
|
2023-01-23 23:55:29 +00:00
|
|
|
bool BuildConnectivity( PROGRESS_REPORTER* aReporter = nullptr );
|
2020-01-04 23:48:18 +00:00
|
|
|
|
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* Delete all MARKERS from the board.
|
2020-01-04 23:48:18 +00:00
|
|
|
*/
|
|
|
|
void DeleteMARKERs();
|
|
|
|
|
2020-08-04 00:41:56 +00:00
|
|
|
void DeleteMARKERs( bool aWarningsAndErrors, bool aExclusions );
|
|
|
|
|
2020-08-26 23:52:12 +00:00
|
|
|
PROJECT* GetProject() const { return m_project; }
|
2020-05-31 21:42:04 +00:00
|
|
|
|
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* Link a board to a given project.
|
|
|
|
*
|
|
|
|
* Should be called immediately after loading board in order for everything to work.
|
|
|
|
*
|
|
|
|
* @param aProject is a loaded project to link to.
|
2022-09-26 03:04:13 +00:00
|
|
|
* @param aReferenceOnly avoids taking ownership of settings stored in project if true
|
2020-05-31 21:42:04 +00:00
|
|
|
*/
|
2022-09-26 03:04:13 +00:00
|
|
|
void SetProject( PROJECT* aProject, bool aReferenceOnly = false );
|
2020-05-31 21:42:04 +00:00
|
|
|
|
|
|
|
void ClearProject();
|
2020-03-26 11:02:59 +00:00
|
|
|
|
2020-09-29 11:33:44 +00:00
|
|
|
/**
|
|
|
|
* Rebuild DRC markers from the serialized data in BOARD_DESIGN_SETTINGS.
|
2023-04-15 09:54:53 +00:00
|
|
|
*
|
|
|
|
* @param aCreateMarkers if true, create markers from serialized data; if false only
|
|
|
|
* use serialized data to set existing markers to excluded.
|
|
|
|
* The former is used on board load; the later after a DRC.
|
2020-09-29 11:33:44 +00:00
|
|
|
*/
|
2023-04-15 09:54:53 +00:00
|
|
|
std::vector<PCB_MARKER*> ResolveDRCExclusions( bool aCreateMarkers );
|
2020-09-29 11:33:44 +00:00
|
|
|
|
2024-01-11 00:55:18 +00:00
|
|
|
/**
|
|
|
|
* Scan existing markers and record data from any that are Excluded.
|
|
|
|
*/
|
|
|
|
void RecordDRCExclusions();
|
|
|
|
|
2022-09-29 16:07:42 +00:00
|
|
|
/**
|
|
|
|
* Update the visibility flags on the current unconnected ratsnest lines.
|
|
|
|
*/
|
|
|
|
void UpdateRatsnestExclusions();
|
|
|
|
|
2020-01-04 23:48:18 +00:00
|
|
|
/**
|
|
|
|
* Reset all high light data to the init state
|
|
|
|
*/
|
2020-04-12 19:29:16 +00:00
|
|
|
void ResetNetHighLight();
|
2020-01-04 23:48:18 +00:00
|
|
|
|
|
|
|
/**
|
2020-05-24 17:30:23 +00:00
|
|
|
* @return the set of net codes that should be highlighted
|
2020-01-04 23:48:18 +00:00
|
|
|
*/
|
2020-05-24 17:30:23 +00:00
|
|
|
const std::set<int>& GetHighLightNetCodes() const
|
|
|
|
{
|
|
|
|
return m_highLight.m_netCodes;
|
|
|
|
}
|
2020-04-12 19:29:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Select the netcode to be highlighted.
|
2021-06-04 13:04:30 +00:00
|
|
|
*
|
|
|
|
* @param aNetCode is the net to highlight.
|
|
|
|
* @param aMulti is true if you want to add a highlighted net without clearing the old one.
|
2020-04-12 19:29:16 +00:00
|
|
|
*/
|
2020-05-24 17:30:23 +00:00
|
|
|
void SetHighLightNet( int aNetCode, bool aMulti = false );
|
2020-01-04 23:48:18 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return true if a net is currently highlighted
|
|
|
|
*/
|
|
|
|
bool IsHighLightNetON() const { return m_highLight.m_highLightOn; }
|
|
|
|
|
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* Enable or disable net highlighting.
|
|
|
|
*
|
|
|
|
* If a netcode >= 0 has been set with SetHighLightNet and aValue is true, the net will be
|
|
|
|
* highlighted. If aValue is false, net highlighting will be disabled regardless of
|
2020-04-21 06:31:44 +00:00
|
|
|
* the highlight netcode being set.
|
2020-01-04 23:48:18 +00:00
|
|
|
*/
|
2020-04-12 19:29:16 +00:00
|
|
|
void HighLightON( bool aValue = true );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Disable net highlight.
|
|
|
|
*/
|
|
|
|
void HighLightOFF()
|
|
|
|
{
|
|
|
|
HighLightON( false );
|
|
|
|
}
|
2020-01-04 23:48:18 +00:00
|
|
|
|
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* @return The number of copper layers in the BOARD.
|
2020-01-04 23:48:18 +00:00
|
|
|
*/
|
|
|
|
int GetCopperLayerCount() const;
|
|
|
|
void SetCopperLayerCount( int aCount );
|
|
|
|
|
2022-11-24 18:05:37 +00:00
|
|
|
int LayerDepth( PCB_LAYER_ID aStartLayer, PCB_LAYER_ID aEndLayer ) const;
|
|
|
|
|
2020-01-04 23:48:18 +00:00
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* A proxy function that calls the corresponding function in m_BoardSettings.
|
|
|
|
*
|
|
|
|
* @return the enabled layers in bit-mapped form.
|
2020-01-04 23:48:18 +00:00
|
|
|
*/
|
|
|
|
LSET GetEnabledLayers() const;
|
|
|
|
|
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* A proxy function that calls the correspondent function in m_BoardSettings.
|
|
|
|
*
|
|
|
|
* @param aLayerMask the new bit-mask of enabled layers.
|
2020-01-04 23:48:18 +00:00
|
|
|
*/
|
|
|
|
void SetEnabledLayers( LSET aLayerMask );
|
|
|
|
|
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* A proxy function that calls the correspondent function in m_BoardSettings
|
2020-01-04 23:48:18 +00:00
|
|
|
* tests whether a given layer is enabled
|
|
|
|
* @param aLayer = The layer to be tested
|
2021-06-04 13:04:30 +00:00
|
|
|
* @return true if the layer is visible.
|
2020-01-04 23:48:18 +00:00
|
|
|
*/
|
2021-06-06 19:03:10 +00:00
|
|
|
bool IsLayerEnabled( PCB_LAYER_ID aLayer ) const;
|
2020-01-04 23:48:18 +00:00
|
|
|
|
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* A proxy function that calls the correspondent function in m_BoardSettings
|
2020-01-04 23:48:18 +00:00
|
|
|
* tests whether a given layer is visible
|
2021-06-04 13:04:30 +00:00
|
|
|
*
|
|
|
|
* @param aLayer is the layer to be tested.
|
|
|
|
* @return true if the layer is visible otherwise false.
|
2020-01-04 23:48:18 +00:00
|
|
|
*/
|
2020-05-31 21:42:04 +00:00
|
|
|
bool IsLayerVisible( PCB_LAYER_ID aLayer ) const;
|
2020-01-04 23:48:18 +00:00
|
|
|
|
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* A proxy function that calls the correspondent function in m_BoardSettings.
|
|
|
|
*
|
|
|
|
* @return the visible layers in bit-mapped form.
|
2020-01-04 23:48:18 +00:00
|
|
|
*/
|
|
|
|
LSET GetVisibleLayers() const;
|
|
|
|
|
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* A proxy function that calls the correspondent function in m_BoardSettings
|
2021-06-04 13:04:30 +00:00
|
|
|
* changes the bit-mask of visible layers.
|
|
|
|
*
|
|
|
|
* @param aLayerMask is the new bit-mask of visible layers.
|
2020-01-04 23:48:18 +00:00
|
|
|
*/
|
|
|
|
void SetVisibleLayers( LSET aLayerMask );
|
|
|
|
|
|
|
|
// these 2 functions are not tidy at this time, since there are PCB_LAYER_IDs that
|
|
|
|
// are not stored in the bitmap.
|
|
|
|
|
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* Return a set of all the element categories that are visible.
|
|
|
|
*
|
|
|
|
* @return the set of visible GAL layers.
|
2020-01-04 23:48:18 +00:00
|
|
|
* @see enum GAL_LAYER_ID
|
|
|
|
*/
|
2020-05-31 21:42:04 +00:00
|
|
|
GAL_SET GetVisibleElements() const;
|
2020-01-04 23:48:18 +00:00
|
|
|
|
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* A proxy function that calls the correspondent function in m_BoardSettings.
|
|
|
|
*
|
|
|
|
* @param aMask is the new bit-mask of visible element bitmap or-ed from enum GAL_LAYER_ID
|
2020-01-04 23:48:18 +00:00
|
|
|
* @see enum GAL_LAYER_ID
|
|
|
|
*/
|
2020-05-31 21:42:04 +00:00
|
|
|
void SetVisibleElements( const GAL_SET& aMask );
|
2020-01-04 23:48:18 +00:00
|
|
|
|
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* Change the bit-mask of visible element categories and layers.
|
|
|
|
*
|
2020-01-04 23:48:18 +00:00
|
|
|
* @see enum GAL_LAYER_ID
|
|
|
|
*/
|
|
|
|
void SetVisibleAlls();
|
|
|
|
|
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* Test whether a given element category is visible.
|
|
|
|
*
|
|
|
|
* @param aLayer is from the enum by the same name.
|
|
|
|
* @return true if the element is visible otherwise false.
|
2020-01-04 23:48:18 +00:00
|
|
|
* @see enum GAL_LAYER_ID
|
|
|
|
*/
|
|
|
|
bool IsElementVisible( GAL_LAYER_ID aLayer ) const;
|
|
|
|
|
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* Change the visibility of an element category.
|
2021-06-04 13:04:30 +00:00
|
|
|
*
|
|
|
|
* @param aLayer is from the enum by the same name.
|
|
|
|
* @param aNewState is the new visibility state of the element category.
|
2020-01-04 23:48:18 +00:00
|
|
|
* @see enum GAL_LAYER_ID
|
|
|
|
*/
|
|
|
|
void SetElementVisibility( GAL_LAYER_ID aLayer, bool aNewState );
|
|
|
|
|
|
|
|
/**
|
2020-11-13 11:17:15 +00:00
|
|
|
* Expect either of the two layers on which a footprint can reside, and returns
|
2020-01-04 23:48:18 +00:00
|
|
|
* whether that layer is visible.
|
2021-06-04 13:04:30 +00:00
|
|
|
*
|
|
|
|
* @param aLayer is one of the two allowed layers for footprints: F_Cu or B_Cu
|
|
|
|
* @return true if the layer is visible, otherwise false.
|
2020-01-04 23:48:18 +00:00
|
|
|
*/
|
2021-03-06 09:27:41 +00:00
|
|
|
bool IsFootprintLayerVisible( PCB_LAYER_ID aLayer ) const;
|
2020-01-04 23:48:18 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the BOARD_DESIGN_SETTINGS for this BOARD
|
|
|
|
*/
|
2021-06-06 19:03:10 +00:00
|
|
|
BOARD_DESIGN_SETTINGS& GetDesignSettings() const;
|
2020-01-04 23:48:18 +00:00
|
|
|
|
2023-08-04 16:28:36 +00:00
|
|
|
// Tented vias are vias covered by solder mask. So because the solder mask is a negative
|
|
|
|
// layer, tented vias are NOT plotted on solder mask layers
|
|
|
|
bool GetTentVias() const { return !m_plotOptions.GetPlotViaOnMaskLayer(); }
|
|
|
|
void SetTentVias( bool aFlag ) { m_plotOptions.SetPlotViaOnMaskLayer( !aFlag ); }
|
2021-08-22 22:05:47 +00:00
|
|
|
|
2020-01-04 23:48:18 +00:00
|
|
|
const PAGE_INFO& GetPageSettings() const { return m_paper; }
|
|
|
|
void SetPageSettings( const PAGE_INFO& aPageSettings ) { m_paper = aPageSettings; }
|
|
|
|
|
|
|
|
const PCB_PLOT_PARAMS& GetPlotOptions() const { return m_plotOptions; }
|
|
|
|
void SetPlotOptions( const PCB_PLOT_PARAMS& aOptions ) { m_plotOptions = aOptions; }
|
|
|
|
|
|
|
|
TITLE_BLOCK& GetTitleBlock() { return m_titles; }
|
2020-12-20 18:44:13 +00:00
|
|
|
const TITLE_BLOCK& GetTitleBlock() const { return m_titles; }
|
2020-01-04 23:48:18 +00:00
|
|
|
void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) { m_titles = aTitleBlock; }
|
|
|
|
|
2023-01-12 03:27:44 +00:00
|
|
|
wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override;
|
2020-01-04 23:48:18 +00:00
|
|
|
|
2023-03-05 13:27:22 +00:00
|
|
|
EDA_UNITS GetUserUnits() { return m_userUnits; }
|
|
|
|
void SetUserUnits( EDA_UNITS aUnits ) { m_userUnits = aUnits; }
|
|
|
|
|
2023-03-13 20:25:27 +00:00
|
|
|
/**
|
|
|
|
* Update any references within aItem (or its descendants) to the user units. Primarily
|
|
|
|
* for automatic-unit dimensions.
|
|
|
|
*/
|
|
|
|
void UpdateUserUnits( BOARD_ITEM* aItem, KIGFX::VIEW* aView );
|
|
|
|
|
2020-01-04 23:48:18 +00:00
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* Extract the board outlines and build a closed polygon from lines, arcs and circle items
|
|
|
|
* on edge cut layer.
|
|
|
|
*
|
|
|
|
* Any closed outline inside the main outline is a hole. All contours should be closed,
|
|
|
|
* i.e. have valid vertices to build a closed polygon.
|
2020-01-04 23:48:18 +00:00
|
|
|
*
|
2021-06-04 13:04:30 +00:00
|
|
|
* @param aOutlines is the #SHAPE_POLY_SET to fill in with outlines/holes.
|
|
|
|
* @param aErrorHandler is an optional DRC_ITEM error handler.
|
2023-05-16 11:39:16 +00:00
|
|
|
* @param aAllowUseArcsInPolygons = an optional option to allow adding arcs in
|
|
|
|
* SHAPE_LINE_CHAIN polylines/polygons when building outlines from aShapeList
|
|
|
|
* This is mainly for export to STEP files
|
2023-12-12 19:13:40 +00:00
|
|
|
* @param aIncludeNPTHAsOutlines = an optional option to include NPTH pad holes
|
|
|
|
* in board outlines. These holes can be seen like holes created by closed shapes
|
|
|
|
* drawn on edge cut layer inside the board main outline.
|
2020-01-04 23:48:18 +00:00
|
|
|
* @return true if success, false if a contour is not valid
|
|
|
|
*/
|
2020-11-20 13:55:10 +00:00
|
|
|
bool GetBoardPolygonOutlines( SHAPE_POLY_SET& aOutlines,
|
2023-05-16 11:39:16 +00:00
|
|
|
OUTLINE_ERROR_HANDLER* aErrorHandler = nullptr,
|
2023-12-12 19:13:40 +00:00
|
|
|
bool aAllowUseArcsInPolygons = false,
|
|
|
|
bool aIncludeNPTHAsOutlines = false );
|
2020-01-04 23:48:18 +00:00
|
|
|
|
|
|
|
/**
|
2023-02-28 15:34:07 +00:00
|
|
|
* @return a epsilon value that is the max distance between 2 points to see them
|
|
|
|
* at the same coordinate when building the board outlines and tray to connect 2 end points
|
|
|
|
* when buildind the outlines of the board
|
|
|
|
* Too small value do not allow connecting 2 shapes (i.e. segments) not exactly connected
|
|
|
|
* Too large value do not allow safely connecting 2 shapes like very short segments.
|
|
|
|
*/
|
|
|
|
int GetOutlinesChainingEpsilon() { return( m_outlinesChainingEpsilon ); }
|
|
|
|
void SetOutlinesChainingEpsilon( int aValue) { m_outlinesChainingEpsilon = aValue; }
|
|
|
|
|
|
|
|
/**
|
2020-10-13 10:55:24 +00:00
|
|
|
* Build a set of polygons which are the outlines of copper items (pads, tracks, vias, texts,
|
2021-06-04 13:04:30 +00:00
|
|
|
* zones).
|
|
|
|
*
|
|
|
|
* Holes in vias or pads are ignored. The polygons are not merged. This is useful to
|
|
|
|
* export the shape of copper layers to dxf polygons or 3D viewer/
|
|
|
|
*
|
|
|
|
* @param aLayer is a copper layer, like B_Cu, etc.
|
|
|
|
* @param aOutlines is the SHAPE_POLY_SET to fill in with items outline.
|
2020-01-04 23:48:18 +00:00
|
|
|
*/
|
2021-03-06 09:27:41 +00:00
|
|
|
void ConvertBrdLayerToPolygonalContours( PCB_LAYER_ID aLayer, SHAPE_POLY_SET& aOutlines ) const;
|
2020-01-04 23:48:18 +00:00
|
|
|
|
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* Return the ID of a layer.
|
2020-01-04 23:48:18 +00:00
|
|
|
*/
|
2023-05-19 02:05:12 +00:00
|
|
|
PCB_LAYER_ID GetLayerID( const wxString& aLayerName ) const;
|
2020-01-04 23:48:18 +00:00
|
|
|
|
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* Return the name of a \a aLayer.
|
|
|
|
*
|
|
|
|
* @param aLayer is the #PCB_LAYER_ID of the layer.
|
2021-06-04 13:04:30 +00:00
|
|
|
* @return a string containing the name of the layer.
|
2020-01-04 23:48:18 +00:00
|
|
|
*/
|
|
|
|
const wxString GetLayerName( PCB_LAYER_ID aLayer ) const;
|
|
|
|
|
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* Changes the name of the layer given by aLayer.
|
2020-01-04 23:48:18 +00:00
|
|
|
* @param aLayer A layer, like B_Cu, etc.
|
|
|
|
* @param aLayerName The new layer name
|
2021-06-04 13:04:30 +00:00
|
|
|
* @return true if aLayerName was legal and unique among other layer names at other layer
|
|
|
|
* indices and aLayer was within range, else false.
|
2020-01-04 23:48:18 +00:00
|
|
|
*/
|
|
|
|
bool SetLayerName( PCB_LAYER_ID aLayer, const wxString& aLayerName );
|
|
|
|
|
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* Return an "English Standard" name of a PCB layer when given \a aLayerNumber.
|
2021-06-04 13:04:30 +00:00
|
|
|
*
|
2020-01-04 23:48:18 +00:00
|
|
|
* This function is static so it can be called without a BOARD instance. Use
|
|
|
|
* GetLayerName() if want the layer names of a specific BOARD, which could
|
|
|
|
* be different than the default if the user has renamed any copper layers.
|
|
|
|
*
|
2021-06-04 13:04:30 +00:00
|
|
|
* @param aLayerId is the layer identifier (index) to fetch.
|
|
|
|
* @return a string containing the layer name or "BAD INDEX" if aLayerId is not legal.
|
2020-01-04 23:48:18 +00:00
|
|
|
*/
|
|
|
|
static wxString GetStandardLayerName( PCB_LAYER_ID aLayerId )
|
|
|
|
{
|
|
|
|
// a BOARD's standard layer name is the PCB_LAYER_ID fixed name
|
2020-08-31 00:20:45 +00:00
|
|
|
return LayerName( aLayerId );
|
2020-01-04 23:48:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* Return the type of the copper layer given by aLayer.
|
2020-01-04 23:48:18 +00:00
|
|
|
*
|
|
|
|
* @param aIndex A layer index in m_Layer
|
|
|
|
* @param aLayer A reference to a LAYER description.
|
|
|
|
* @return false if the index was out of range.
|
|
|
|
*/
|
|
|
|
bool SetLayerDescr( PCB_LAYER_ID aIndex, const LAYER& aLayer );
|
|
|
|
|
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* Return the type of the copper layer given by aLayer.
|
2020-01-04 23:48:18 +00:00
|
|
|
*
|
|
|
|
* @param aLayer A layer index, like B_Cu, etc.
|
2021-06-04 13:04:30 +00:00
|
|
|
* @return the layer type, or LAYER_T(-1) if the index was out of range.
|
2020-01-04 23:48:18 +00:00
|
|
|
*/
|
|
|
|
LAYER_T GetLayerType( PCB_LAYER_ID aLayer ) const;
|
|
|
|
|
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* Change the type of the layer given by aLayer.
|
2020-01-04 23:48:18 +00:00
|
|
|
*
|
|
|
|
* @param aLayer A layer index, like B_Cu, etc.
|
|
|
|
* @param aLayerType The new layer type.
|
2021-06-04 13:04:30 +00:00
|
|
|
* @return true if aLayerType was legal and aLayer was within range, else false.
|
2020-01-04 23:48:18 +00:00
|
|
|
*/
|
|
|
|
bool SetLayerType( PCB_LAYER_ID aLayer, LAYER_T aLayerType );
|
|
|
|
|
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* @param aNet Only count nodes belonging to this net.
|
|
|
|
* @return the number of pads members of nets (i.e. with netcode > 0).
|
2020-01-04 23:48:18 +00:00
|
|
|
*/
|
2020-10-27 11:03:35 +00:00
|
|
|
unsigned GetNodesCount( int aNet = -1 ) const;
|
2020-01-04 23:48:18 +00:00
|
|
|
|
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* Return a reference to a list of all the pads.
|
|
|
|
*
|
|
|
|
* The returned list is not sorted and contains pointers to PADS, but those pointers do
|
|
|
|
* not convey ownership of the respective PADs.
|
|
|
|
*
|
2021-06-04 13:04:30 +00:00
|
|
|
* @return a full list of pads.
|
2020-01-04 23:48:18 +00:00
|
|
|
*/
|
2020-11-12 22:30:02 +00:00
|
|
|
const std::vector<PAD*> GetPads() const;
|
2020-01-04 23:48:18 +00:00
|
|
|
|
|
|
|
void BuildListOfNets()
|
|
|
|
{
|
|
|
|
m_NetInfo.buildListOfNets();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* Search for a net with the given netcode.
|
2021-06-04 13:04:30 +00:00
|
|
|
*
|
2020-01-04 23:48:18 +00:00
|
|
|
* @param aNetcode A netcode to search for.
|
2021-06-04 13:04:30 +00:00
|
|
|
* @return the net if found or NULL if not found.
|
2020-01-04 23:48:18 +00:00
|
|
|
*/
|
|
|
|
NETINFO_ITEM* FindNet( int aNetcode ) const;
|
|
|
|
|
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* Search for a net with the given name.
|
2021-06-04 13:04:30 +00:00
|
|
|
*
|
2020-01-04 23:48:18 +00:00
|
|
|
* @param aNetname A Netname to search for.
|
2021-06-04 13:04:30 +00:00
|
|
|
* @return the net if found or NULL if not found.
|
2020-01-04 23:48:18 +00:00
|
|
|
*/
|
|
|
|
NETINFO_ITEM* FindNet( const wxString& aNetname ) const;
|
|
|
|
|
2023-10-15 21:45:18 +00:00
|
|
|
/**
|
|
|
|
* Fetch the coupled netname for a given net.
|
|
|
|
*
|
|
|
|
* This accepts netnames suffixed by 'P', 'N', '+', '-', as well as additional numbers and
|
|
|
|
* underscores following the suffix. So NET_P_123 is a valid positive net name matched to
|
|
|
|
* NET_N_123.
|
|
|
|
*
|
|
|
|
* @return the polarity of the given net (or 0 if it is not a diffpair net).
|
|
|
|
*/
|
|
|
|
int MatchDpSuffix( const wxString& aNetName, wxString& aComplementNet );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the coupled net for a given net. If not a diffpair, nullptr is returned.
|
|
|
|
*/
|
|
|
|
NETINFO_ITEM* DpCoupledNet( const NETINFO_ITEM* aNet );
|
|
|
|
|
2020-02-05 10:54:25 +00:00
|
|
|
const NETINFO_LIST& GetNetInfo() const
|
|
|
|
{
|
|
|
|
return m_NetInfo;
|
|
|
|
}
|
|
|
|
|
2023-10-04 20:01:33 +00:00
|
|
|
void RemoveUnusedNets( BOARD_COMMIT* aCommit )
|
2020-01-04 23:48:18 +00:00
|
|
|
{
|
2023-10-04 20:01:33 +00:00
|
|
|
m_NetInfo.RemoveUnusedNets( aCommit );
|
2020-01-04 23:48:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef SWIG
|
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* @return iterator to the first element of the NETINFO_ITEMs list.
|
2020-01-04 23:48:18 +00:00
|
|
|
*/
|
|
|
|
NETINFO_LIST::iterator BeginNets() const
|
|
|
|
{
|
|
|
|
return m_NetInfo.begin();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* @return iterator to the last element of the NETINFO_ITEMs list.
|
2020-01-04 23:48:18 +00:00
|
|
|
*/
|
|
|
|
NETINFO_LIST::iterator EndNets() const
|
|
|
|
{
|
|
|
|
return m_NetInfo.end();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* @return the number of nets (NETINFO_ITEM).
|
2020-01-04 23:48:18 +00:00
|
|
|
*/
|
|
|
|
unsigned GetNetCount() const
|
|
|
|
{
|
|
|
|
return m_NetInfo.GetNetCount();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* Calculate the bounding box containing all board items (or board edge segments).
|
|
|
|
*
|
2020-01-04 23:48:18 +00:00
|
|
|
* @param aBoardEdgesOnly is true if we are interested in board edge segments only.
|
2021-06-04 13:04:30 +00:00
|
|
|
* @return the board's bounding box.
|
2020-01-04 23:48:18 +00:00
|
|
|
*/
|
2022-08-30 23:28:18 +00:00
|
|
|
BOX2I ComputeBoundingBox( bool aBoardEdgesOnly = false ) const;
|
2020-01-04 23:48:18 +00:00
|
|
|
|
2022-08-31 09:15:42 +00:00
|
|
|
const BOX2I GetBoundingBox() const override
|
2020-01-04 23:48:18 +00:00
|
|
|
{
|
|
|
|
return ComputeBoundingBox( false );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* Return the board bounding box calculated using exclusively the board edges (graphics
|
2020-09-22 21:50:59 +00:00
|
|
|
* on Edge.Cuts layer).
|
|
|
|
*
|
|
|
|
* If there are items outside of the area limited by Edge.Cuts graphics, the items will
|
|
|
|
* not be taken into account.
|
|
|
|
*
|
2020-01-04 23:48:18 +00:00
|
|
|
* @return bounding box calculated using exclusively the board edges.
|
|
|
|
*/
|
2022-08-31 09:15:42 +00:00
|
|
|
const BOX2I GetBoardEdgesBoundingBox() const
|
2020-01-04 23:48:18 +00:00
|
|
|
{
|
|
|
|
return ComputeBoundingBox( true );
|
|
|
|
}
|
|
|
|
|
2020-04-24 13:36:10 +00:00
|
|
|
void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
|
2020-01-04 23:48:18 +00:00
|
|
|
|
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* May be re-implemented for each derived class in order to handle
|
2020-01-04 23:48:18 +00:00
|
|
|
* all the types given by its member data. Implementations should call
|
|
|
|
* inspector->Inspect() on types in scanTypes[], and may use IterateForward()
|
|
|
|
* to do so on lists of such data.
|
|
|
|
* @param inspector An INSPECTOR instance to use in the inspection.
|
|
|
|
* @param testData Arbitrary data used by the inspector.
|
2022-08-20 09:27:35 +00:00
|
|
|
* @param scanTypes Which KICAD_T types are of interest and the order to process them in.
|
2021-06-04 13:04:30 +00:00
|
|
|
* @return SEARCH_QUIT if the Iterator is to stop the scan, else SCAN_CONTINUE, and
|
|
|
|
* determined by the inspector.
|
2020-01-04 23:48:18 +00:00
|
|
|
*/
|
2022-08-20 09:27:35 +00:00
|
|
|
INSPECT_RESULT Visit( INSPECTOR inspector, void* testData,
|
2022-08-21 19:54:07 +00:00
|
|
|
const std::vector<KICAD_T>& scanTypes ) override;
|
2020-01-04 23:48:18 +00:00
|
|
|
|
|
|
|
/**
|
2020-11-13 15:15:52 +00:00
|
|
|
* Search for a FOOTPRINT within this board with the given reference designator.
|
2020-09-22 21:50:59 +00:00
|
|
|
*
|
2020-11-13 15:15:52 +00:00
|
|
|
* Finds only the first one, if there is more than one such FOOTPRINT.
|
2020-09-22 21:50:59 +00:00
|
|
|
*
|
2020-11-13 15:15:52 +00:00
|
|
|
* @param aReference The reference designator of the FOOTPRINT to find.
|
2021-06-04 13:04:30 +00:00
|
|
|
* @return If found the FOOTPRINT having the given reference designator, else nullptr.
|
2020-01-04 23:48:18 +00:00
|
|
|
*/
|
2020-11-13 15:15:52 +00:00
|
|
|
FOOTPRINT* FindFootprintByReference( const wxString& aReference ) const;
|
2020-01-04 23:48:18 +00:00
|
|
|
|
|
|
|
/**
|
2020-11-13 15:15:52 +00:00
|
|
|
* Search for a FOOTPRINT within this board with the given path.
|
2020-09-22 21:50:59 +00:00
|
|
|
*
|
2020-02-20 12:11:04 +00:00
|
|
|
* @param aPath The path ([sheetUUID, .., symbolUUID]) to search for.
|
2021-06-04 13:04:30 +00:00
|
|
|
* @return If found, the FOOTPRINT having the given uuid, else NULL.
|
2020-01-04 23:48:18 +00:00
|
|
|
*/
|
2020-11-13 15:15:52 +00:00
|
|
|
FOOTPRINT* FindFootprintByPath( const KIID_PATH& aPath ) const;
|
2020-01-04 23:48:18 +00:00
|
|
|
|
2020-07-06 10:51:04 +00:00
|
|
|
/**
|
2022-09-03 18:29:02 +00:00
|
|
|
* Return the set of netname candidates for netclass assignment.
|
2020-07-06 10:51:04 +00:00
|
|
|
*/
|
2022-09-03 18:29:02 +00:00
|
|
|
std::set<wxString> GetNetClassAssignmentCandidates() const;
|
2020-07-06 10:51:04 +00:00
|
|
|
|
2020-01-04 23:48:18 +00:00
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* Copy NETCLASS info to each NET, based on NET membership in a NETCLASS.
|
|
|
|
*
|
2020-01-04 23:48:18 +00:00
|
|
|
* Must be called after a Design Rules edit, or after reading a netlist (or editing
|
|
|
|
* the list of nets) Also this function removes the non existing nets in netclasses
|
|
|
|
* and add net nets in default netclass (this happens after reading a netlist)
|
|
|
|
*/
|
2022-11-22 14:24:20 +00:00
|
|
|
void SynchronizeNetsAndNetClasses( bool aResetTrackAndViaSizes );
|
2020-01-04 23:48:18 +00:00
|
|
|
|
2020-08-19 18:21:24 +00:00
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* Copy the current project's text variables into the boards property cache.
|
2020-08-19 18:21:24 +00:00
|
|
|
*/
|
|
|
|
void SynchronizeProperties();
|
2020-01-04 23:48:18 +00:00
|
|
|
|
2023-09-14 21:39:42 +00:00
|
|
|
/**
|
|
|
|
* Return the Similarity. Because we compare board to board, we just return 1.0 here
|
|
|
|
*/
|
|
|
|
double Similarity( const BOARD_ITEM& aOther ) const override
|
|
|
|
{
|
|
|
|
return 1.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator==( const BOARD_ITEM& aOther ) const override;
|
|
|
|
|
2020-01-04 23:48:18 +00:00
|
|
|
wxString GetClass() const override
|
|
|
|
{
|
|
|
|
return wxT( "BOARD" );
|
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(DEBUG)
|
|
|
|
void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/*************************/
|
|
|
|
/* Copper Areas handling */
|
|
|
|
/*************************/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the .m_NetCode member of all copper areas, according to the area Net Name
|
|
|
|
* The SetNetCodesFromNetNames is an equivalent to net name, for fast comparisons.
|
|
|
|
* However the Netcode is an arbitrary equivalence, it must be set after each netlist read
|
|
|
|
* or net change
|
|
|
|
* Must be called after pad netcodes are calculated
|
|
|
|
* @return : error count
|
|
|
|
* For non copper areas, netcode is set to 0
|
|
|
|
*/
|
2020-08-26 23:52:12 +00:00
|
|
|
int SetAreasNetCodesFromNetNames();
|
2020-01-04 23:48:18 +00:00
|
|
|
|
|
|
|
/**
|
2020-11-19 22:35:32 +00:00
|
|
|
* Return the Zone at a given index.
|
2020-09-22 21:50:59 +00:00
|
|
|
*
|
2020-11-11 23:05:59 +00:00
|
|
|
* @param index The array type index into a collection of ZONE *.
|
2021-06-04 13:04:30 +00:00
|
|
|
* @return a pointer to the Area or NULL if index out of range.
|
2020-01-04 23:48:18 +00:00
|
|
|
*/
|
2020-11-11 23:05:59 +00:00
|
|
|
ZONE* GetArea( int index ) const
|
2020-01-04 23:48:18 +00:00
|
|
|
{
|
2020-08-26 23:52:12 +00:00
|
|
|
if( (unsigned) index < m_zones.size() )
|
|
|
|
return m_zones[index];
|
2020-01-04 23:48:18 +00:00
|
|
|
|
2021-06-04 13:04:30 +00:00
|
|
|
return nullptr;
|
2020-01-04 23:48:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* @return a std::list of pointers to all board zones (possibly including zones in footprints)
|
|
|
|
*/
|
2021-03-06 09:27:41 +00:00
|
|
|
std::list<ZONE*> GetZoneList( bool aIncludeZonesInFootprints = false ) const;
|
2020-09-22 21:50:59 +00:00
|
|
|
|
|
|
|
/**
|
2020-11-11 23:05:59 +00:00
|
|
|
* @return The number of copper pour areas or ZONEs.
|
2020-01-04 23:48:18 +00:00
|
|
|
*/
|
|
|
|
int GetAreaCount() const
|
|
|
|
{
|
2020-08-26 23:52:12 +00:00
|
|
|
return static_cast<int>( m_zones.size() );
|
2020-01-04 23:48:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Functions used in test, merge and cut outlines */
|
|
|
|
|
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* Add an empty copper area to board areas list.
|
|
|
|
*
|
2021-06-04 13:04:30 +00:00
|
|
|
* @param aNewZonesList is a PICKED_ITEMS_LIST * where to store new areas pickers (useful
|
|
|
|
* in undo commands) can be NULL.
|
|
|
|
* @param aNetcode is the netcode of the copper area (0 = no net).
|
|
|
|
* @param aLayer is the layer of area.
|
|
|
|
* @param aStartPointPosition is position of the first point of the polygon outline of this
|
|
|
|
* area.
|
|
|
|
* @param aHatch is the hatch option.
|
|
|
|
* @return a reference to the new area.
|
2020-01-04 23:48:18 +00:00
|
|
|
*/
|
2020-11-11 23:05:59 +00:00
|
|
|
ZONE* AddArea( PICKED_ITEMS_LIST* aNewZonesList, int aNetcode, PCB_LAYER_ID aLayer,
|
2022-01-01 18:57:44 +00:00
|
|
|
VECTOR2I aStartPointPosition, ZONE_BORDER_DISPLAY_STYLE aHatch );
|
2020-01-04 23:48:18 +00:00
|
|
|
|
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* Test for intersection of 2 copper areas.
|
|
|
|
*
|
|
|
|
* @param aZone1 is the area reference.
|
|
|
|
* @param aZone2 is the area to compare for intersection calculations.
|
|
|
|
* @return false if no intersection, true if intersection.
|
2020-01-04 23:48:18 +00:00
|
|
|
*/
|
2020-11-11 23:05:59 +00:00
|
|
|
bool TestZoneIntersection( ZONE* aZone1, ZONE* aZone2 );
|
2020-01-04 23:48:18 +00:00
|
|
|
|
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* Find a pad \a aPosition on \a aLayer.
|
2020-01-04 23:48:18 +00:00
|
|
|
*
|
2022-01-04 01:00:40 +00:00
|
|
|
* @param aPosition A VECTOR2I object containing the position to hit test.
|
2020-01-04 23:48:18 +00:00
|
|
|
* @param aLayerMask A layer or layers to mask the hit test.
|
2020-11-12 22:30:02 +00:00
|
|
|
* @return A pointer to a PAD object if found or NULL if not found.
|
2020-01-04 23:48:18 +00:00
|
|
|
*/
|
2022-01-01 06:04:08 +00:00
|
|
|
PAD* GetPad( const VECTOR2I& aPosition, LSET aLayerMask ) const;
|
|
|
|
PAD* GetPad( const VECTOR2I& aPosition ) const
|
2020-01-04 23:48:18 +00:00
|
|
|
{
|
|
|
|
return GetPad( aPosition, LSET().set() );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* Find a pad connected to \a aEndPoint of \a aTrace.
|
2020-01-04 23:48:18 +00:00
|
|
|
*
|
2021-06-11 21:07:02 +00:00
|
|
|
* @param aTrace A pointer to a PCB_TRACK object to hit test against.
|
2020-01-04 23:48:18 +00:00
|
|
|
* @param aEndPoint The end point of \a aTrace the hit test against.
|
2020-11-12 22:30:02 +00:00
|
|
|
* @return A pointer to a PAD object if found or NULL if not found.
|
2020-01-04 23:48:18 +00:00
|
|
|
*/
|
2021-06-11 21:07:02 +00:00
|
|
|
PAD* GetPad( const PCB_TRACK* aTrace, ENDPOINT_T aEndPoint ) const;
|
2020-01-04 23:48:18 +00:00
|
|
|
|
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* Return pad found at \a aPosition on \a aLayerMask using the fast search method.
|
2020-01-04 23:48:18 +00:00
|
|
|
* <p>
|
|
|
|
* The fast search method only works if the pad list has already been built.
|
|
|
|
* </p>
|
2022-01-04 01:00:40 +00:00
|
|
|
* @param aPosition A VECTOR2I object containing the position to hit test.
|
2020-01-04 23:48:18 +00:00
|
|
|
* @param aLayerMask A layer or layers to mask the hit test.
|
2020-11-12 22:30:02 +00:00
|
|
|
* @return A pointer to a PAD object if found or NULL if not found.
|
2020-01-04 23:48:18 +00:00
|
|
|
*/
|
2022-01-01 06:04:08 +00:00
|
|
|
PAD* GetPadFast( const VECTOR2I& aPosition, LSET aLayerMask ) const;
|
2020-01-04 23:48:18 +00:00
|
|
|
|
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* Locate the pad connected at \a aPosition on \a aLayer starting at list position
|
2020-01-04 23:48:18 +00:00
|
|
|
* \a aPad
|
|
|
|
* <p>
|
|
|
|
* This function uses a fast search in this sorted pad list and it is faster than
|
|
|
|
* GetPadFast(). This list is a sorted pad list must be built before calling this
|
|
|
|
* function.
|
|
|
|
* </p>
|
|
|
|
* @note The normal pad list is sorted by increasing netcodes.
|
2021-06-04 13:04:30 +00:00
|
|
|
* @param aPadList is the list of pads candidates (a std::vector<PAD*>).
|
2022-01-04 01:00:40 +00:00
|
|
|
* @param aPosition A VECTOR2I object containing the position to test.
|
2020-01-04 23:48:18 +00:00
|
|
|
* @param aLayerMask A layer or layers to mask the hit test.
|
2020-11-12 22:30:02 +00:00
|
|
|
* @return a PAD object pointer to the connected pad.
|
2020-01-04 23:48:18 +00:00
|
|
|
*/
|
2022-01-01 06:04:08 +00:00
|
|
|
PAD* GetPad( std::vector<PAD*>& aPadList, const VECTOR2I& aPosition, LSET aLayerMask ) const;
|
2020-01-04 23:48:18 +00:00
|
|
|
|
|
|
|
/**
|
2020-11-13 11:17:15 +00:00
|
|
|
* First empties then fills the vector with all pads and sorts them by increasing x
|
|
|
|
* coordinate, and for increasing y coordinate for same values of x coordinates. The vector
|
|
|
|
* only holds pointers to the pads and those pointers are only references to pads which are
|
|
|
|
* owned by the BOARD through other links.
|
2021-06-04 13:04:30 +00:00
|
|
|
*
|
2020-01-04 23:48:18 +00:00
|
|
|
* @param aVector Where to put the pad pointers.
|
|
|
|
* @param aNetCode = the netcode filter:
|
|
|
|
* = -1 to build the full pad list.
|
|
|
|
* = a given netcode to build the pad list relative to the given net
|
|
|
|
*/
|
2021-03-06 09:27:41 +00:00
|
|
|
void GetSortedPadListByXthenYCoord( std::vector<PAD*>& aVector, int aNetCode = -1 ) const;
|
2020-01-04 23:48:18 +00:00
|
|
|
|
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* Return data on the length and number of track segments connected to a given track.
|
2020-01-04 23:48:18 +00:00
|
|
|
* This uses the connectivity data for the board to calculate connections
|
|
|
|
*
|
|
|
|
* @param aTrack Starting track (can also be a via) to check against for connection.
|
|
|
|
* @return a tuple containing <number, length, package length>
|
|
|
|
*/
|
2021-06-11 21:07:02 +00:00
|
|
|
std::tuple<int, double, double> GetTrackLength( const PCB_TRACK& aTrack ) const;
|
2020-01-04 23:48:18 +00:00
|
|
|
|
2022-08-20 15:40:08 +00:00
|
|
|
/**
|
|
|
|
* Collect all the TRACKs and VIAs that are members of a net given by aNetCode.
|
|
|
|
* Used from python.
|
|
|
|
*
|
|
|
|
* @param aNetCode gives the id of the net.
|
|
|
|
* @return list of track which are in the net identified by @a aNetCode.
|
|
|
|
*/
|
|
|
|
TRACKS TracksInNet( int aNetCode );
|
|
|
|
|
2020-01-04 23:48:18 +00:00
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* Get a footprint by its bounding rectangle at \a aPosition on \a aLayer.
|
2021-06-04 13:04:30 +00:00
|
|
|
*
|
2020-01-04 23:48:18 +00:00
|
|
|
* If more than one footprint is at \a aPosition, then the closest footprint on the
|
|
|
|
* active layer is returned. The distance is calculated via manhattan distance from
|
|
|
|
* the center of the bounding rectangle to \a aPosition.
|
|
|
|
*
|
2022-01-04 01:00:40 +00:00
|
|
|
* @param aPosition A VECTOR2I object containing the position to test.
|
2020-01-04 23:48:18 +00:00
|
|
|
* @param aActiveLayer Layer to test.
|
|
|
|
* @param aVisibleOnly Search only the visible layers if true.
|
2020-10-21 03:48:06 +00:00
|
|
|
* @param aIgnoreLocked Ignore locked footprints when true.
|
2020-01-04 23:48:18 +00:00
|
|
|
*/
|
2022-01-01 18:57:44 +00:00
|
|
|
FOOTPRINT* GetFootprint( const VECTOR2I& aPosition, PCB_LAYER_ID aActiveLayer,
|
2021-03-06 09:27:41 +00:00
|
|
|
bool aVisibleOnly, bool aIgnoreLocked = false ) const;
|
2020-01-04 23:48:18 +00:00
|
|
|
|
2023-07-26 19:36:13 +00:00
|
|
|
/**
|
|
|
|
* Returns the maximum clearance value for any object on the board. This considers
|
|
|
|
* the clearances from board design settings as well as embedded clearances in footprints,
|
|
|
|
* pads and zones. Includes electrical, physical, hole and edge clearances.
|
|
|
|
*/
|
2024-03-03 13:54:46 +00:00
|
|
|
int GetMaxClearanceValue() const
|
|
|
|
{
|
|
|
|
return m_maxClearanceValue;
|
|
|
|
};
|
2023-07-26 19:36:13 +00:00
|
|
|
|
2020-01-04 23:48:18 +00:00
|
|
|
/**
|
|
|
|
* Map all nets in the given board to nets with the same name (if any) in the destination
|
2024-04-01 23:55:37 +00:00
|
|
|
* board. If there are missing nets in the destination board, they will be created.
|
|
|
|
*
|
2020-01-04 23:48:18 +00:00
|
|
|
*/
|
2024-04-01 23:55:37 +00:00
|
|
|
void MapNets( BOARD* aDestBoard );
|
2020-01-04 23:48:18 +00:00
|
|
|
|
|
|
|
void SanitizeNetcodes();
|
2020-04-12 19:29:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Add a listener to the board to receive calls whenever something on the
|
|
|
|
* board has been modified. The board does not take ownership of the
|
2020-09-22 21:50:59 +00:00
|
|
|
* listener object. Make sure to call RemoveListener before deleting the
|
2020-04-12 19:29:16 +00:00
|
|
|
* listener object. The order of listener invocations is not guaranteed.
|
|
|
|
* If the specified listener object has been added before, it will not be
|
|
|
|
* added again.
|
|
|
|
*/
|
|
|
|
void AddListener( BOARD_LISTENER* aListener );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove the specified listener. If it has not been added before, it
|
|
|
|
* will do nothing.
|
|
|
|
*/
|
|
|
|
void RemoveListener( BOARD_LISTENER* aListener );
|
|
|
|
|
2022-08-11 03:10:58 +00:00
|
|
|
/**
|
|
|
|
* Remove all listeners
|
|
|
|
*/
|
|
|
|
void RemoveAllListeners();
|
|
|
|
|
2020-04-12 19:29:16 +00:00
|
|
|
/**
|
|
|
|
* Notify the board and its listeners that an item on the board has
|
|
|
|
* been modified in some way.
|
|
|
|
*/
|
|
|
|
void OnItemChanged( BOARD_ITEM* aItem );
|
2020-01-04 23:48:18 +00:00
|
|
|
|
2020-12-07 23:29:30 +00:00
|
|
|
/**
|
|
|
|
* Notify the board and its listeners that an item on the board has
|
|
|
|
* been modified in some way.
|
|
|
|
*/
|
|
|
|
void OnItemsChanged( std::vector<BOARD_ITEM*>& aItems );
|
|
|
|
|
2023-08-17 14:24:59 +00:00
|
|
|
/**
|
|
|
|
* Notify the board and its listeners that the ratsnest has been recomputed.
|
|
|
|
*/
|
|
|
|
void OnRatsnestChanged();
|
|
|
|
|
2021-06-04 13:04:30 +00:00
|
|
|
/**
|
2020-08-11 19:37:07 +00:00
|
|
|
* Consistency check of internal m_groups structure.
|
2021-06-04 13:04:30 +00:00
|
|
|
*
|
2020-08-11 19:37:07 +00:00
|
|
|
* @param repair if true, modify groups structure until it passes the sanity check.
|
|
|
|
* @return empty string on success. Or error description if there's a problem.
|
|
|
|
*/
|
|
|
|
wxString GroupsSanityCheck( bool repair = false );
|
|
|
|
|
2021-06-04 13:04:30 +00:00
|
|
|
/**
|
2020-08-11 19:37:07 +00:00
|
|
|
* @param repair if true, make one modification to groups structure that brings it
|
|
|
|
* closer to passing the sanity check.
|
|
|
|
* @return empty string on success. Or error description if there's a problem.
|
|
|
|
*/
|
|
|
|
wxString GroupsSanityCheckInternal( bool repair );
|
|
|
|
|
|
|
|
struct GroupLegalOpsField
|
|
|
|
{
|
|
|
|
bool create : 1;
|
|
|
|
bool ungroup : 1;
|
|
|
|
bool removeItems : 1;
|
|
|
|
};
|
|
|
|
|
2021-06-04 13:04:30 +00:00
|
|
|
/**
|
2020-08-11 19:37:07 +00:00
|
|
|
* Check which selection tool group operations are legal given the selection.
|
2021-06-04 13:04:30 +00:00
|
|
|
*
|
2020-08-11 19:37:07 +00:00
|
|
|
* @return bit field of legal ops.
|
|
|
|
*/
|
2020-12-16 13:31:32 +00:00
|
|
|
GroupLegalOpsField GroupLegalOps( const PCB_SELECTION& selection ) const;
|
2021-02-26 19:19:56 +00:00
|
|
|
|
2023-05-12 21:03:54 +00:00
|
|
|
bool LegacyTeardrops() const { return m_legacyTeardrops; }
|
|
|
|
void SetLegacyTeardrops( bool aFlag ) { m_legacyTeardrops = aFlag; }
|
|
|
|
|
2021-07-14 20:03:32 +00:00
|
|
|
// --------- Item order comparators ---------
|
|
|
|
|
|
|
|
struct cmp_items
|
|
|
|
{
|
|
|
|
bool operator() ( const BOARD_ITEM* aFirst, const BOARD_ITEM* aSecond ) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct cmp_drawings
|
|
|
|
{
|
|
|
|
bool operator()( const BOARD_ITEM* aFirst, const BOARD_ITEM* aSecond ) const;
|
|
|
|
};
|
|
|
|
|
2021-02-27 00:18:04 +00:00
|
|
|
// ------------ Run-time caches -------------
|
2024-03-07 13:02:16 +00:00
|
|
|
mutable std::shared_mutex m_CachesMutex;
|
2022-08-28 20:20:03 +00:00
|
|
|
std::unordered_map<PTR_PTR_CACHE_KEY, bool> m_IntersectsCourtyardCache;
|
|
|
|
std::unordered_map<PTR_PTR_CACHE_KEY, bool> m_IntersectsFCourtyardCache;
|
|
|
|
std::unordered_map<PTR_PTR_CACHE_KEY, bool> m_IntersectsBCourtyardCache;
|
2022-08-28 16:41:39 +00:00
|
|
|
std::unordered_map<PTR_PTR_LAYER_CACHE_KEY, bool> m_IntersectsAreaCache;
|
|
|
|
std::unordered_map<PTR_PTR_LAYER_CACHE_KEY, bool> m_EnclosedByAreaCache;
|
2022-08-03 09:10:23 +00:00
|
|
|
std::unordered_map< wxString, LSET > m_LayerExpressionCache;
|
|
|
|
std::unordered_map<ZONE*, std::unique_ptr<DRC_RTREE>> m_CopperZoneRTreeCache;
|
2023-05-12 21:03:54 +00:00
|
|
|
std::shared_ptr<DRC_RTREE> m_CopperItemRTreeCache;
|
2022-10-01 21:09:38 +00:00
|
|
|
mutable std::unordered_map<const ZONE*, BOX2I> m_ZoneBBoxCache;
|
|
|
|
|
2022-06-17 21:50:59 +00:00
|
|
|
// ------------ DRC caches -------------
|
|
|
|
std::vector<ZONE*> m_DRCZones;
|
|
|
|
std::vector<ZONE*> m_DRCCopperZones;
|
|
|
|
int m_DRCMaxClearance;
|
|
|
|
int m_DRCMaxPhysicalClearance;
|
2023-10-13 07:57:21 +00:00
|
|
|
ZONE* m_SolderMaskBridges; // A container to build bridges on solder mask layers
|
2023-03-25 10:44:46 +00:00
|
|
|
std::map<ZONE*, std::map<PCB_LAYER_ID, ISOLATED_ISLANDS>> m_ZoneIsolatedIslandsMap;
|
2021-08-12 16:58:30 +00:00
|
|
|
|
2021-06-04 13:04:30 +00:00
|
|
|
private:
|
|
|
|
// The default copy constructor & operator= are inadequate,
|
|
|
|
// either write one or do not use it at all
|
|
|
|
BOARD( const BOARD& aOther ) = delete;
|
|
|
|
|
|
|
|
BOARD& operator=( const BOARD& aOther ) = delete;
|
|
|
|
|
|
|
|
template <typename Func, typename... Args>
|
|
|
|
void InvokeListeners( Func&& aFunc, Args&&... args )
|
|
|
|
{
|
|
|
|
for( auto&& l : m_listeners )
|
|
|
|
( l->*aFunc )( std::forward<Args>( args )... );
|
|
|
|
}
|
|
|
|
|
2024-03-03 13:54:46 +00:00
|
|
|
|
|
|
|
void UpdateMaxClearanceCache();
|
|
|
|
|
2021-06-04 13:04:30 +00:00
|
|
|
friend class PCB_EDIT_FRAME;
|
|
|
|
|
2023-02-28 15:34:07 +00:00
|
|
|
|
|
|
|
/// the max distance between 2 end point to see them connected when building the board outlines
|
|
|
|
int m_outlinesChainingEpsilon;
|
|
|
|
|
2021-06-04 13:04:30 +00:00
|
|
|
/// What is this board being used for
|
|
|
|
BOARD_USE m_boardUse;
|
|
|
|
int m_timeStamp; // actually a modification counter
|
|
|
|
|
|
|
|
wxString m_fileName;
|
2024-03-25 21:37:40 +00:00
|
|
|
|
|
|
|
// These containers only have const accessors and must only be modified by Add()/Remove()
|
2021-06-04 13:04:30 +00:00
|
|
|
MARKERS m_markers;
|
|
|
|
DRAWINGS m_drawings;
|
|
|
|
FOOTPRINTS m_footprints;
|
|
|
|
TRACKS m_tracks;
|
|
|
|
GROUPS m_groups;
|
|
|
|
ZONES m_zones;
|
2023-10-06 17:04:00 +00:00
|
|
|
GENERATORS m_generators;
|
2021-06-04 13:04:30 +00:00
|
|
|
|
2024-03-26 01:58:02 +00:00
|
|
|
// Cache for fast access to items in the containers above by KIID, including children
|
|
|
|
std::unordered_map<KIID, BOARD_ITEM*> m_itemByIdCache;
|
|
|
|
|
2021-06-04 13:04:30 +00:00
|
|
|
LAYER m_layers[PCB_LAYER_ID_COUNT];
|
|
|
|
|
|
|
|
HIGH_LIGHT_INFO m_highLight; // current high light data
|
|
|
|
HIGH_LIGHT_INFO m_highLightPrevious; // a previously stored high light data
|
|
|
|
|
|
|
|
int m_fileFormatVersionAtLoad; // the version loaded from the file
|
2021-06-08 21:11:48 +00:00
|
|
|
wxString m_generator; // the generator tag from the file
|
2021-06-04 13:04:30 +00:00
|
|
|
|
|
|
|
std::map<wxString, wxString> m_properties;
|
|
|
|
std::shared_ptr<CONNECTIVITY_DATA> m_connectivity;
|
|
|
|
|
|
|
|
PAGE_INFO m_paper;
|
|
|
|
TITLE_BLOCK m_titles; // text in lower right of screen and plots
|
|
|
|
PCB_PLOT_PARAMS m_plotOptions;
|
|
|
|
PROJECT* m_project; // project this board is a part of
|
2023-03-05 13:27:22 +00:00
|
|
|
EDA_UNITS m_userUnits;
|
2021-06-04 13:04:30 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* All of the board design settings are stored as a JSON object inside the project file. The
|
|
|
|
* object itself is located here because the alternative is to require a valid project be
|
|
|
|
* passed in when constructing a BOARD, since things in the BOARD constructor rely on access
|
|
|
|
* to the BOARD_DESIGN_SETTINGS object.
|
|
|
|
*
|
|
|
|
* A reference to this object is set up in the PROJECT_FILE for the PROJECT this board is
|
|
|
|
* part of, so that the JSON load/store operations work. This link is established when
|
|
|
|
* boards are loaded from disk.
|
|
|
|
*/
|
|
|
|
std::unique_ptr<BOARD_DESIGN_SETTINGS> m_designSettings;
|
|
|
|
|
2023-05-12 21:03:54 +00:00
|
|
|
/**
|
|
|
|
* Teardrops in 7.0 were applied as a post-processing step (rather than from pad and via
|
|
|
|
* properties). If this flag is set, then auto-teardrop-generation will be disabled.
|
|
|
|
*/
|
|
|
|
bool m_legacyTeardrops = false;
|
|
|
|
|
2024-03-06 18:48:49 +00:00
|
|
|
bool m_skipMaxClearanceCacheUpdate;
|
2024-03-03 13:54:46 +00:00
|
|
|
int m_maxClearanceValue; // cached value
|
|
|
|
|
2021-06-04 13:04:30 +00:00
|
|
|
NETINFO_LIST m_NetInfo; // net info list (name, design constraints...
|
|
|
|
|
|
|
|
std::vector<BOARD_LISTENER*> m_listeners;
|
2020-08-11 19:37:07 +00:00
|
|
|
};
|
2021-06-04 13:04:30 +00:00
|
|
|
|
2022-08-03 09:10:23 +00:00
|
|
|
|
2020-01-04 23:48:18 +00:00
|
|
|
#endif // CLASS_BOARD_H_
|