Pcbnew header housekeeping round 1.

This commit is contained in:
Wayne Stambaugh 2021-06-04 09:04:30 -04:00
parent 2533fb22b3
commit 2a6c7a7c0f
14 changed files with 876 additions and 872 deletions

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2017 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2017-2021 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -33,197 +33,183 @@
#include <pcb_edit_frame.h>
/**
* ACTION_PLUGIN
* This is the parent class from where any action plugin class must
* derive
* This is the parent class from where any action plugin class must derive.
*/
class ACTION_PLUGIN
{
public:
// association between the plugin and its menu id
// m_actionMenuId set to 0 means the corresponding menuitem to call this
// action is not yet created
int m_actionMenuId;
// Same for button id
int m_actionButtonId;
// Icon for the action button and menu entry
wxBitmap iconBitmap;
// If show_on_toolbar is true a button will be added to top toolbar
bool show_on_toolbar;
public:
ACTION_PLUGIN() : m_actionMenuId( 0 ), m_actionButtonId( 0 ),
show_on_toolbar( false ) {}
virtual ~ACTION_PLUGIN();
/**
* Function GetCategoryName
* @return the category name of the action (to be able to group action under the same submenu)
* @return the category name of the action (to be able to group action under the same submenu).
*/
virtual wxString GetCategoryName() = 0;
/**
* Function GetName
* @return the name of the action
* @return the name of the action.
*/
virtual wxString GetName() = 0;
/**
* Function GetDescription
* @return a description of the action plugin
* @return a description of the action plugin.
*/
virtual wxString GetDescription() = 0;
/**
* Function GetShowToolbarButton
* @return true if button should be shown on top toolbar
* @return true if button should be shown on top toolbar.
*/
virtual bool GetShowToolbarButton() = 0;
/**
* Function GetIconFileName
* @param aDark true if requesting dark theme icon
* @return a path to icon for the action plugin button
* @param aDark set to true if requesting dark theme icon.
* @return a path to icon for the action plugin button.
*/
virtual wxString GetIconFileName( bool aDark ) = 0;
/**
* Function GetPluginPath
* @return a path this plugin was loaded from
* @return a path this plugin was loaded from.
*/
virtual wxString GetPluginPath() = 0;
/**
* Function GetObject
* This method gets the pointer to the object from where this action constructs
* @return it's a void pointer, as it could be a PyObject or any other
* This method gets the pointer to the object from where this action constructs.
*
* @return it's a void pointer, as it could be a PyObject or any other
*/
virtual void* GetObject() = 0;
/**
* Function Run
* This method the the action
* This method the the action.
*/
virtual void Run() = 0;
/**
* Function register_action
* It's the standard method of a "ACTION_PLUGIN" to register itself into
* the ACTION_PLUGINS singleton manager
* It's the standard method of a "ACTION_PLUGIN" to register itself into the ACTION_PLUGINS
* singleton manager.
*/
void register_action();
// association between the plugin and its menu id
// m_actionMenuId set to 0 means the corresponding menuitem to call this
// action is not yet created
int m_actionMenuId;
// Same for button id
int m_actionButtonId;
// Icon for the action button and menu entry
wxBitmap iconBitmap;
// If show_on_toolbar is true a button will be added to top toolbar
bool show_on_toolbar;
};
/**
* ACTION_PLUGINS
* Mainly static. Storing all plugins informations.
* Mainly static. Storing all plugins information.
*/
class ACTION_PLUGINS
{
private:
/**
* ACTION_PLUGIN system wide static list
*/
static std::vector<ACTION_PLUGIN*> m_actionsList;
static bool m_actionRunning;
public:
/**
* Function register_action
* An action calls this static method when it wants to register itself
* into the system actions
* into the system actions.
*
* @param aAction is the action plugin to be registered
* @param aAction is the action plugin to be registered.
*/
static void register_action( ACTION_PLUGIN* aAction );
/**
* Function deregister_object
* Anyone calls this method to deregister an object which builds a action,
* it will lookup on the vector calling GetObject until find, then removed
* and deleted
* Deregister an object which builds a action.
*
* @param aObject is the action plugin object to be deregistered
* Lookup on the vector calling GetObject until find, then removed and deleted.
*
* @param aObject is the action plugin object to be deregistered.
*/
static bool deregister_object( void* aObject );
/**
* Function GetAction
* @param aName is the action plugin name
* @param aName is the action plugin name.
* @return a action object by it's name or NULL if it isn't available.
*/
static ACTION_PLUGIN* GetAction( const wxString& aName );
/**
* Function SetActionMenu
* Associate a menu id to an action plugin
* @param aIndex is the action index
* @param idMenu is the associated menuitem id
* Associate a menu id to an action plugin.
*
* @param aIndex is the action index.
* @param idMenu is the associated menuitem ID.
*/
static void SetActionMenu( int aIndex, int idMenu );
/**
* Function GetActionByMenu
* find action plugin associated to a menu id
* @param aMenu is the menu id (defined with SetActionMenu)
* @return the associated ACTION_PLUGIN (or null if not found)
* Find action plugin associated to a menu ID.
*
* @param aMenu is the menu id (defined with SetActionMenu).
* @return the associated ACTION_PLUGIN (or null if not found).
*/
static ACTION_PLUGIN* GetActionByMenu( int aMenu );
/**
* Function SetActionButton
* Associate a button id to an action plugin
* @param aAction is the action
* @param idButton is the associated menuitem id
* Associate a button id to an action plugin.
*
* @param aAction is the action.
* @param idButton is the associated menuitem ID.
*/
static void SetActionButton( ACTION_PLUGIN* aAction, int idButton );
/**
* Function GetActionByButton
* find action plugin associated to a button id
* @param aButton is the button id (defined with SetActionButton)
* @return the associated ACTION_PLUGIN (or null if not found)
* Find action plugin associated to a button ID.
*
* @param aButton is the button id (defined with SetActionButton).
* @return the associated ACTION_PLUGIN (or null if not found).
*/
static ACTION_PLUGIN* GetActionByButton( int aButton );
/**
* Function GetActionByPath
* find action plugin by module path
* @param aPath the path of plugin
* @return the corresponding ACTION_PLUGIN (or null if not found)
* Find action plugin by module path.
*
* @param aPath is the path of plugin.
* @return the corresponding ACTION_PLUGIN (or null if not found).
*/
static ACTION_PLUGIN* GetActionByPath( const wxString& aPath );
/**
* Function GetAction
* @param aIndex is the action index in list.
* @return a action object by it's number or NULL if it isn't available.
* @param aIndex is the action index in list
*/
static ACTION_PLUGIN* GetAction( int aIndex );
/**
* Function GetActionsCount
* @return the number of actions available into the system
* @return the number of actions available into the system.
*/
static int GetActionsCount();
/**
* Function IsActionRunning
* @return Is an action running right now
* @return true if an action running right now otherwise false.
*/
static bool IsActionRunning();
/**
* Function SetActionRunning
* @param aRunning sets whether an action is running now.
*/
static void SetActionRunning( bool aRunning );
/**
* Unloads (deregisters) all action plugins
* Unload (deregister) all action plugins.
*/
static void UnloadAll();
private:
/**
* ACTION_PLUGIN system wide static list.
*/
static std::vector<ACTION_PLUGIN*> m_actionsList;
static bool m_actionRunning;
};
#endif /* PCBNEW_ACTION_PLUGINS_H */

View File

@ -3,7 +3,7 @@
*
* Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@gmail.com>
*
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
*
@ -60,15 +60,15 @@ wxPoint BOARD_ITEM::ZeroOffset( 0, 0 );
BOARD::BOARD() :
BOARD_ITEM_CONTAINER( (BOARD_ITEM*) nullptr, PCB_T ),
m_LegacyDesignSettingsLoaded( false ),
m_LegacyCopperEdgeClearanceLoaded( false ),
m_LegacyNetclassesLoaded( false ),
m_boardUse( BOARD_USE::NORMAL ),
m_timeStamp( 1 ),
m_paper( PAGE_INFO::A4 ),
m_project( nullptr ),
m_designSettings( new BOARD_DESIGN_SETTINGS( nullptr, "board.design_settings" ) ),
m_NetInfo( this ),
m_LegacyDesignSettingsLoaded( false ),
m_LegacyCopperEdgeClearanceLoaded( false ),
m_LegacyNetclassesLoaded( false )
m_NetInfo( this )
{
// we have not loaded a board yet, assume latest until then.
m_fileFormatVersionAtLoad = LEGACY_BOARD_FILE_VERSION;

View File

@ -2,7 +2,7 @@
* 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
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -73,7 +73,7 @@ enum LAYER_T
/**
* Container to hold information pertinent to a layer of a BOARD.
* Container to hold information pertinent to a layer of a BOARD.
*/
struct LAYER
{
@ -112,16 +112,16 @@ struct LAYER
* Convert a #LAYER_T enum to a string representation of the layer type.
*
* @param aType The #LAYER_T to convert
* @return const char* - The string representation of the layer type.
* @return The string representation of the layer type.
*/
static const char* ShowType( LAYER_T aType );
/**
* Convert a string to a #LAYER_T
*
* @param aType The const char* to convert
* @return LAYER_T - The binary representation of the layer type, or
* LAYER_T(-1) if the string is invalid
* @param aType The layer name to convert.
* @return The binary representation of the layer type, or
* LAYER_T(-1) if the string is invalid.
*/
static LAYER_T ParseType( const char* aType );
};
@ -130,8 +130,6 @@ struct LAYER
// Helper class to handle high light nets
class HIGH_LIGHT_INFO
{
friend class BOARD;
protected:
std::set<int> m_netCodes; // net(s) selected for highlight (-1 when no net selected )
bool m_highLightOn; // highlight active
@ -146,10 +144,13 @@ protected:
{
Clear();
}
private:
friend class BOARD;
};
/**
* Provides an interface to hook into board modifications and get callbacks
* Provide an interface to hook into board modifications and get callbacks
* on certain modifications that are made to the board. This allows updating
* auxiliary views other than the primary board editor view.
*/
@ -170,6 +171,13 @@ public:
};
DECL_VEC_FOR_SWIG( MARKERS, PCB_MARKER* )
DECL_VEC_FOR_SWIG( ZONES, ZONE* )
DECL_DEQ_FOR_SWIG( TRACKS, TRACK* )
// Dequeue rather than Vector just so we can use moveUnflaggedItems in pcbnew_control.cpp
DECL_DEQ_FOR_SWIG( GROUPS, PCB_GROUP* )
/**
* Flags to specify how the board is being used.
*/
@ -185,65 +193,6 @@ enum class BOARD_USE
*/
class BOARD : public BOARD_ITEM_CONTAINER
{
friend class PCB_EDIT_FRAME;
private:
/// What is this board being used for
BOARD_USE m_boardUse;
int m_timeStamp; // actually a modification counter
wxString m_fileName;
MARKERS m_markers;
DRAWINGS m_drawings;
FOOTPRINTS m_footprints;
TRACKS m_tracks;
GROUPS m_groups;
ZONES m_zones;
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
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
/**
* 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;
NETINFO_LIST m_NetInfo; // net info list (name, design constraints...
std::vector<BOARD_LISTENER*> m_listeners;
// 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 )... );
}
public:
static inline bool ClassOf( const EDA_ITEM* aItem )
{
@ -303,7 +252,7 @@ public:
* - An item may appear in at most one group
* - Each group must contain at least one item
* - If a group specifies a name, it must be unique
* - The graph of groups containing subgroups must be acyclic.
* - The graph of groups containing subgroups must be cyclic.
*/
GROUPS& Groups() { return m_groups; }
const GROUPS& Groups() const { return m_groups; }
@ -348,18 +297,22 @@ public:
void Remove( BOARD_ITEM* aBoardItem, REMOVE_MODE aMode = REMOVE_MODE::NORMAL ) override;
/**
* Must be used if Add() is used using a BULK_x ADD_MODE to generate a change event for listeners
* Must be used if Add() is used using a BULK_x ADD_MODE to generate a change event for
* listeners.
*/
void FinalizeBulkAdd( std::vector<BOARD_ITEM*>& aNewItems );
/**
* Must be used if Remove() is used using a BULK_x REMOVE_MODE to generate a change event for listeners
* Must be used if Remove() is used using a BULK_x REMOVE_MODE to generate a change event
* for listeners.
*/
void FinalizeBulkRemove( std::vector<BOARD_ITEM*>& aRemovedItems );
/**
* Gets the first footprint on the board or nullptr.
* Get the first footprint on the board or nullptr.
*
* This is used primarily by the footprint editor which knows there is only one.
*
* @return first footprint or null pointer
*/
FOOTPRINT* GetFirstFootprint() const
@ -368,13 +321,12 @@ public:
}
/**
* Removes all footprints from the deque and frees the memory associated with them
* Remove all footprints from the deque and free the memory associated with them.
*/
void DeleteAllFootprints();
/**
* @return null if aID is null. Returns an object of Type() == NOT_USED if
* the aID is not found.
* @return null if aID is null. Returns an object of Type() == NOT_USED if the aID is not found.
*/
BOARD_ITEM* GetItem( const KIID& aID ) const;
@ -393,7 +345,7 @@ public:
std::shared_ptr<CONNECTIVITY_DATA> GetConnectivity() const { return m_connectivity; }
/**
* Builds or rebuilds the board connectivity database for the board,
* Build or rebuild the board connectivity database for the board,
* especially the list of connected items, list of nets and rastnest data
* Needed after loading a board to have the connectivity database updated.
*/
@ -409,9 +361,11 @@ public:
PROJECT* GetProject() const { return m_project; }
/**
* Links 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
* 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.
*/
void SetProject( PROJECT* aProject );
@ -437,8 +391,9 @@ public:
/**
* Select the netcode to be highlighted.
* @param aNetCode is the net to highlight
* @param aMulti is true if you want to add a highlighted net without clearing the old one
*
* @param aNetCode is the net to highlight.
* @param aMulti is true if you want to add a highlighted net without clearing the old one.
*/
void SetHighLightNet( int aNetCode, bool aMulti = false );
@ -448,9 +403,10 @@ public:
bool IsHighLightNetON() const { return m_highLight.m_highLightOn; }
/**
* 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
* 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
* the highlight netcode being set.
*/
void HighLightON( bool aValue = true );
@ -464,22 +420,22 @@ public:
}
/**
* @return int - The number of copper layers in the BOARD.
* @return The number of copper layers in the BOARD.
*/
int GetCopperLayerCount() const;
void SetCopperLayerCount( int aCount );
/**
* A proxy function that calls the corresponding function in m_BoardSettings
* Returns a bit-mask of all the layers that are enabled
* @return int - the enabled layers in bit-mapped form.
* A proxy function that calls the corresponding function in m_BoardSettings.
*
* @return the enabled layers in bit-mapped form.
*/
LSET GetEnabledLayers() const;
/**
* A proxy function that calls the correspondent function in m_BoardSettings
* Changes the bit-mask of enabled layers
* @param aLayerMask = The new bit-mask of enabled layers
* A proxy function that calls the correspondent function in m_BoardSettings.
*
* @param aLayerMask the new bit-mask of enabled layers.
*/
void SetEnabledLayers( LSET aLayerMask );
@ -487,7 +443,7 @@ public:
* A proxy function that calls the correspondent function in m_BoardSettings
* tests whether a given layer is enabled
* @param aLayer = The layer to be tested
* @return bool - true if the layer is visible.
* @return true if the layer is visible.
*/
bool IsLayerEnabled( PCB_LAYER_ID aLayer ) const
{
@ -497,22 +453,24 @@ public:
/**
* A proxy function that calls the correspondent function in m_BoardSettings
* tests whether a given layer is visible
* @param aLayer = The layer to be tested
* @return bool - true if the layer is visible.
*
* @param aLayer is the layer to be tested.
* @return true if the layer is visible otherwise false.
*/
bool IsLayerVisible( PCB_LAYER_ID aLayer ) const;
/**
* A proxy function that calls the correspondent function in m_BoardSettings
* Returns a bit-mask of all the layers that are visible
* @return int - the visible layers in bit-mapped form.
* A proxy function that calls the correspondent function in m_BoardSettings.
*
* @return the visible layers in bit-mapped form.
*/
LSET GetVisibleLayers() const;
/**
* A proxy function that calls the correspondent function in m_BoardSettings
* changes the bit-mask of visible layers
* @param aLayerMask = The new bit-mask of visible layers
* changes the bit-mask of visible layers.
*
* @param aLayerMask is the new bit-mask of visible layers.
*/
void SetVisibleLayers( LSET aLayerMask );
@ -520,38 +478,42 @@ public:
// are not stored in the bitmap.
/**
* Returns a set of all the element categories that are visible
* @return the set of visible GAL layers
* Return a set of all the element categories that are visible.
*
* @return the set of visible GAL layers.
* @see enum GAL_LAYER_ID
*/
GAL_SET GetVisibleElements() const;
/**
* A proxy function that calls the correspondent function in m_BoardSettings
* changes the bit-mask of visible element categories
* @param aMask = The new bit-mask of visible element bitmap or-ed from enum GAL_LAYER_ID
* 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
* @see enum GAL_LAYER_ID
*/
void SetVisibleElements( const GAL_SET& aMask );
/**
* Change the bit-mask of visible element categories and layers
* Change the bit-mask of visible element categories and layers.
*
* @see enum GAL_LAYER_ID
*/
void SetVisibleAlls();
/**
* Test whether a given element category is visible. Keep this as an inline function.
* @param aLayer is from the enum by the same name
* @return bool - true if the element is visible.
* 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.
* @see enum GAL_LAYER_ID
*/
bool IsElementVisible( GAL_LAYER_ID aLayer ) const;
/**
* Change the visibility of an element category.
* @param aLayer is from the enum by the same name
* @param aNewState = The new visibility state of the element category
*
* @param aLayer is from the enum by the same name.
* @param aNewState is the new visibility state of the element category.
* @see enum GAL_LAYER_ID
*/
void SetElementVisibility( GAL_LAYER_ID aLayer, bool aNewState );
@ -559,8 +521,9 @@ public:
/**
* Expect either of the two layers on which a footprint can reside, and returns
* whether that layer is visible.
* @param aLayer One of the two allowed layers for footprints: F_Cu or B_Cu
* @return bool - true if the layer is visible, else false.
*
* @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.
*/
bool IsFootprintLayerVisible( PCB_LAYER_ID aLayer ) const;
@ -595,13 +558,14 @@ public:
wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
/**
* 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
* @param aOutlines The SHAPE_POLY_SET to fill in with outlines/holes.
* @param aErrorHandler = an optional DRC_ITEM error handler
* 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.
*
* @param aOutlines is the #SHAPE_POLY_SET to fill in with outlines/holes.
* @param aErrorHandler is an optional DRC_ITEM error handler.
* @return true if success, false if a contour is not valid
*/
bool GetBoardPolygonOutlines( SHAPE_POLY_SET& aOutlines,
@ -609,10 +573,13 @@ public:
/**
* Build a set of polygons which are the outlines of copper items (pads, tracks, vias, texts,
* zones). Holes in vias or pads are ignored. The polygons are not merged.
* Useful to export the shape of copper layers to dxf polygons or 3D viewer
* @param aLayer = A copper layer, like B_Cu, etc.
* @param aOutlines The SHAPE_POLY_SET to fill in with items outline.
* 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.
*/
void ConvertBrdLayerToPolygonalContours( PCB_LAYER_ID aLayer, SHAPE_POLY_SET& aOutlines ) const;
@ -625,30 +592,28 @@ public:
* Return the name of a \a aLayer.
*
* @param aLayer is the #PCB_LAYER_ID of the layer.
*
* @return a string containing the appropriate layer type.
* @return a string containing the name of the layer.
*/
const wxString GetLayerName( PCB_LAYER_ID aLayer ) const;
/**
* Changes the name of the layer given by aLayer.
*
* @param aLayer A layer, like B_Cu, etc.
* @param aLayerName The new layer name
* @return bool - true if aLayerName was legal and unique among other
* layer names at other layer indices and aLayer was within range, else false.
* @return true if aLayerName was legal and unique among other layer names at other layer
* indices and aLayer was within range, else false.
*/
bool SetLayerName( PCB_LAYER_ID aLayer, const wxString& aLayerName );
/**
* Return an "English Standard" name of a PCB layer when given \a aLayerNumber.
*
* 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.
*
* @param aLayerId is the layer identifier (index) to fetch
* @return const wxString - containing the layer name or "BAD INDEX" if aLayerId
* is not legal
* @param aLayerId is the layer identifier (index) to fetch.
* @return a string containing the layer name or "BAD INDEX" if aLayerId is not legal.
*/
static wxString GetStandardLayerName( PCB_LAYER_ID aLayerId )
{
@ -669,8 +634,7 @@ public:
* Return the type of the copper layer given by aLayer.
*
* @param aLayer A layer index, like B_Cu, etc.
* @return LAYER_T - the layer type, or LAYER_T(-1) if the
* index was out of range.
* @return the layer type, or LAYER_T(-1) if the index was out of range.
*/
LAYER_T GetLayerType( PCB_LAYER_ID aLayer ) const;
@ -679,13 +643,13 @@ public:
*
* @param aLayer A layer index, like B_Cu, etc.
* @param aLayerType The new layer type.
* @return bool - true if aLayerType was legal and aLayer was within range, else false.
* @return true if aLayerType was legal and aLayer was within range, else false.
*/
bool SetLayerType( PCB_LAYER_ID aLayer, LAYER_T aLayerType );
/**
* @param aNet Only count nodes belonging to this net
* @return the number of pads members of nets (i.e. with netcode > 0)
* @param aNet Only count nodes belonging to this net.
* @return the number of pads members of nets (i.e. with netcode > 0).
*/
unsigned GetNodesCount( int aNet = -1 ) const;
@ -695,7 +659,7 @@ public:
unsigned GetUnconnectedNetCount() const;
/**
* @return the number of pads in board
* @return the number of pads in board.
*/
unsigned GetPadCount() const;
@ -705,7 +669,7 @@ public:
* The returned list is not sorted and contains pointers to PADS, but those pointers do
* not convey ownership of the respective PADs.
*
* @return D_PADS - a full list of pads
* @return a full list of pads.
*/
const std::vector<PAD*> GetPads() const;
@ -716,15 +680,17 @@ public:
/**
* Search for a net with the given netcode.
*
* @param aNetcode A netcode to search for.
* @return NETINFO_ITEM_ITEM* - the net or NULL if not found.
* @return the net if found or NULL if not found.
*/
NETINFO_ITEM* FindNet( int aNetcode ) const;
/**
* Search for a net with the given name.
*
* @param aNetname A Netname to search for.
* @return NETINFO_ITEM* - the net or NULL if not found.
* @return the net if found or NULL if not found.
*/
NETINFO_ITEM* FindNet( const wxString& aNetname ) const;
@ -740,7 +706,7 @@ public:
#ifndef SWIG
/**
* @return iterator to the first element of the NETINFO_ITEMs list
* @return iterator to the first element of the NETINFO_ITEMs list.
*/
NETINFO_LIST::iterator BeginNets() const
{
@ -748,7 +714,7 @@ public:
}
/**
* @return iterator to the last element of the NETINFO_ITEMs list
* @return iterator to the last element of the NETINFO_ITEMs list.
*/
NETINFO_LIST::iterator EndNets() const
{
@ -757,7 +723,7 @@ public:
#endif
/**
* @return the number of nets (NETINFO_ITEM)
* @return the number of nets (NETINFO_ITEM).
*/
unsigned GetNetCount() const
{
@ -768,7 +734,7 @@ public:
* Calculate the bounding box containing all board items (or board edge segments).
*
* @param aBoardEdgesOnly is true if we are interested in board edge segments only.
* @return EDA_RECT - the board's bounding box
* @return the board's bounding box.
*/
EDA_RECT ComputeBoundingBox( bool aBoardEdgesOnly = false ) const;
@ -778,7 +744,7 @@ public:
}
/**
* Returns the board bounding box calculated using exclusively the board edges (graphics
* Return the board bounding box calculated using exclusively the board edges (graphics
* on Edge.Cuts layer).
*
* If there are items outside of the area limited by Edge.Cuts graphics, the items will
@ -802,8 +768,8 @@ public:
* @param testData Arbitrary data used by the inspector.
* @param scanTypes Which KICAD_T types are of interest and the order
* is significant too, terminated by EOT.
* @return SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan,
* else SCAN_CONTINUE, and determined by the inspector.
* @return SEARCH_QUIT if the Iterator is to stop the scan, else SCAN_CONTINUE, and
* determined by the inspector.
*/
SEARCH_RESULT Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] ) override;
@ -813,8 +779,7 @@ public:
* Finds only the first one, if there is more than one such FOOTPRINT.
*
* @param aReference The reference designator of the FOOTPRINT to find.
* @return FOOTPRINT* - If found, the FOOTPRINT having the given reference designator, else
* nullptr.
* @return If found the FOOTPRINT having the given reference designator, else nullptr.
*/
FOOTPRINT* FindFootprintByReference( const wxString& aReference ) const;
@ -822,15 +787,15 @@ public:
* Search for a FOOTPRINT within this board with the given path.
*
* @param aPath The path ([sheetUUID, .., symbolUUID]) to search for.
* @return FOOTPRINT* - If found, the FOOTPRINT having the given uuid, else NULL.
* @return If found, the FOOTPRINT having the given uuid, else NULL.
*/
FOOTPRINT* FindFootprintByPath( const KIID_PATH& aPath ) const;
/**
* @param aNames An array string to fill with net names.
* @param aSortbyPadsCount true = sort by active pads count, false = no sort (i.e.
* leave the sort by net names)
* @return int - net names count.
* @param aSortbyPadsCount set to true to sort by active pads count, false = no sort (i.e.
* leave the sort by net names).
* @return net names count.
*/
int SortedNetnamesList( wxArrayString& aNames, bool aSortbyPadsCount );
@ -885,14 +850,14 @@ public:
* Return the Zone at a given index.
*
* @param index The array type index into a collection of ZONE *.
* @return ZONE* - a pointer to the Area or NULL if index out of range.
* @return a pointer to the Area or NULL if index out of range.
*/
ZONE* GetArea( int index ) const
{
if( (unsigned) index < m_zones.size() )
return m_zones[index];
return NULL;
return nullptr;
}
/**
@ -913,13 +878,14 @@ public:
/**
* Add an empty copper area to board areas list.
*
* @param aNewZonesList = a PICKED_ITEMS_LIST * where to store new areas pickers (useful
* in undo commands) can be NULL
* @param aNetcode = the netcode of the copper area (0 = no net)
* @param aLayer = the layer of area
* @param aStartPointPosition = position of the first point of the polygon outline of this area
* @param aHatch = hatch option
* @return a reference to the new area
* @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.
*/
ZONE* AddArea( PICKED_ITEMS_LIST* aNewZonesList, int aNetcode, PCB_LAYER_ID aLayer,
wxPoint aStartPointPosition, ZONE_BORDER_DISPLAY_STYLE aHatch );
@ -927,29 +893,34 @@ public:
/**
* Process an area that has been modified, by normalizing its polygon against itself.
* i.e. convert a self-intersecting polygon to one (or more) non self-intersecting polygon(s)
*
* This may change the number and order of copper areas in the net.
* @param aNewZonesList = a PICKED_ITEMS_LIST * where to store new created areas pickers
* @param aCurrArea = the zone to process
* @return true if changes are made
*
* @param aNewZonesList is a PICKED_ITEMS_LIST where to store new created areas pickers.
* @param aCurrArea is the zone to process.
* @return true if changes are made.
*/
bool NormalizeAreaPolygon( PICKED_ITEMS_LIST* aNewZonesList, ZONE* aCurrArea );
/**
* Process an area that has been modified, by normalizing its polygon
* and merging the intersecting polygons for any other areas on the same net.
*
* This may change the number and order of copper areas in the net.
* @param aModifiedZonesList = a PICKED_ITEMS_LIST * where to store deleted or added areas
* (useful in undo commands can be NULL
* @param modified_area = area to test
* @return true if some areas modified
*
* @param aModifiedZonesList is a #PICKED_ITEMS_LIST where to store deleted or added areas
* (useful in undo commands can be NULL).
* @param modified_area is the area to test.
* @return true if some areas modified.
*/
bool OnAreaPolygonModified( PICKED_ITEMS_LIST* aModifiedZonesList, ZONE* modified_area );
/**
* Test for intersection of 2 copper areas
* @param aZone1 = area reference
* @param aZone2 = area to compare for intersection calculations
* @return : false if no intersection, true if intersection
* 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.
*/
bool TestZoneIntersection( ZONE* aZone1, ZONE* aZone2 );
@ -995,7 +966,7 @@ public:
* function.
* </p>
* @note The normal pad list is sorted by increasing netcodes.
* @param aPadList = the list of pads candidates (a std::vector<PAD*>)
* @param aPadList is the list of pads candidates (a std::vector<PAD*>).
* @param aPosition A wxPoint object containing the position to test.
* @param aLayerMask A layer or layers to mask the hit test.
* @return a PAD object pointer to the connected pad.
@ -1005,6 +976,7 @@ public:
/**
* Delete a given pad from the BOARD by removing it from its footprint and from the
* m_NetInfo. Makes no UI calls.
*
* @param aPad is the pad to delete.
*/
void PadDelete( PAD* aPad );
@ -1014,6 +986,7 @@ public:
* 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.
*
* @param aVector Where to put the pad pointers.
* @param aNetCode = the netcode filter:
* = -1 to build the full pad list.
@ -1022,7 +995,7 @@ public:
void GetSortedPadListByXthenYCoord( std::vector<PAD*>& aVector, int aNetCode = -1 ) const;
/**
* Returns data on the length and number of track segments connected to a given track.
* Return data on the length and number of track segments connected to a given track.
* 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.
@ -1033,14 +1006,15 @@ public:
/**
* 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 TRACKS - which are in the net identified by @a aNetCode.
* @return list of track which are in the net identified by @a aNetCode.
*/
TRACKS TracksInNet( int aNetCode );
/**
* Get a footprint by its bounding rectangle at \a aPosition on \a aLayer.
* <p>
*
* 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.
@ -1095,14 +1069,15 @@ public:
*/
void OnItemsChanged( std::vector<BOARD_ITEM*>& aItems );
/*
/**
* Consistency check of internal m_groups structure.
*
* @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 );
/*
/**
* @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.
@ -1117,15 +1092,14 @@ public:
bool enter : 1;
};
/*
/**
* Check which selection tool group operations are legal given the selection.
*
* @return bit field of legal ops.
*/
GroupLegalOpsField GroupLegalOps( const PCB_SELECTION& selection ) const;
public:
// ------------ Run-time caches -------------
std::mutex m_CachesMutex;
std::map< std::pair<BOARD_ITEM*, BOARD_ITEM*>, bool > m_InsideCourtyardCache;
std::map< std::pair<BOARD_ITEM*, BOARD_ITEM*>, bool > m_InsideFCourtyardCache;
@ -1133,5 +1107,65 @@ public:
std::map< std::pair<BOARD_ITEM*, BOARD_ITEM*>, bool > m_InsideAreaCache;
std::map< ZONE*, std::unique_ptr<DRC_RTREE> > m_CopperZoneRTrees;
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 )... );
}
friend class PCB_EDIT_FRAME;
/// What is this board being used for
BOARD_USE m_boardUse;
int m_timeStamp; // actually a modification counter
wxString m_fileName;
MARKERS m_markers;
DRAWINGS m_drawings;
FOOTPRINTS m_footprints;
TRACKS m_tracks;
GROUPS m_groups;
ZONES m_zones;
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
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
/**
* 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;
NETINFO_LIST m_NetInfo; // net info list (name, design constraints...
std::vector<BOARD_LISTENER*> m_listeners;
};
#endif // CLASS_BOARD_H_

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2020-2021 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -48,32 +48,27 @@ enum CLEANUP_RC_CODE {
class CLEANUP_ITEM : public RC_ITEM
{
private:
wxString m_errorMessage;
public:
CLEANUP_ITEM( int aErrorCode );
/**
* Function GetErrorText
* returns the string form of a drc error code.
* Return the string form of a drc error code.
*/
wxString GetErrorText( int aErrorCode = -1, bool aTranslate = true ) const;
private:
wxString m_errorMessage;
};
/**
* VECTOR_CLEANUP_ITEMS_PROVIDER
* is an implementation of the interface named RC_ITEMS_PROVIDER which uses a vector
* An implementation of the interface named RC_ITEMS_PROVIDER which uses a vector
* of pointers to CLEANUP_ITEMs to fulfill the interface. No ownership is taken of the
* vector.
*/
class VECTOR_CLEANUP_ITEMS_PROVIDER : public RC_ITEMS_PROVIDER
{
std::vector<std::shared_ptr<CLEANUP_ITEM> >* m_sourceVector; // owns its CLEANUP_ITEMs
public:
VECTOR_CLEANUP_ITEMS_PROVIDER( std::vector<std::shared_ptr<CLEANUP_ITEM> >* aList ) :
m_sourceVector( aList )
{
@ -115,6 +110,9 @@ public:
m_sourceVector->clear();
}
}
private:
std::vector<std::shared_ptr<CLEANUP_ITEM> >* m_sourceVector; // owns its CLEANUP_ITEMs
};

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2007-2008 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2004-2019 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2004-2021 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -59,96 +59,95 @@
*/
class COLLECTORS_GUIDE
{
public:
virtual ~COLLECTORS_GUIDE() {}
/**
* @return bool - true if the given layer is locked, else false.
* @return true if the given layer is locked, else false.
*/
virtual bool IsLayerLocked( PCB_LAYER_ID layer ) const = 0;
/**
* @return bool - true if the given layer is visible, else false.
* @return true if the given layer is visible, else false.
*/
virtual bool IsLayerVisible( PCB_LAYER_ID layer ) const = 0;
/**
* @return bool - true if should ignore locked layers, else false.
* @return true if should ignore locked layers, else false.
*/
virtual bool IgnoreLockedLayers() const = 0;
/**
* @return bool - true if should ignore non-visible layers, else false.
* @return true if should ignore non-visible layers, else false.
*/
virtual bool IgnoreNonVisibleLayers() const = 0;
/**
* @return int - the preferred layer for HitTest()ing.
* @return the preferred layer for HitTest()ing.
*/
virtual PCB_LAYER_ID GetPreferredLayer() const = 0;
/**
* Provide wildcard behavior regarding the preferred layer.
*
* @return bool - true if should ignore preferred layer, else false.
* @return true if should ignore preferred layer, else false.
*/
virtual bool IgnorePreferredLayer() const = 0;
/**
* @return bool - true if should ignore locked items, else false.
* @return true if should ignore locked items, else false.
*/
virtual bool IgnoreLockedItems() const = 0;
/**
* Determine if the secondary criteria or 2nd choice items should be included.
*
* @return bool - true if should include, else false.
* @return true if should include, else false.
*/
virtual bool IncludeSecondary() const = 0;
/**
* @return bool - true if footprint texts marked as "no show" should be ignored.
* @return true if footprint texts marked as "no show" should be ignored.
*/
virtual bool IgnoreHiddenFPText() const = 0;
/**
* @return bool - true if should ignore footprint text on back layers
* @return true if should ignore footprint text on back layers
*/
virtual bool IgnoreFPTextOnBack() const = 0;
/**
* @return bool - true if should ignore footprint text on front layers.
* @return true if should ignore footprint text on front layers.
*/
virtual bool IgnoreFPTextOnFront() const = 0;
/**
* @return bool - true if should ignore FOOTPRINTs on Back Side.
* @return true if should ignore FOOTPRINTs on Back Side.
*/
virtual bool IgnoreFootprintsOnBack() const = 0;
/**
* @return bool - ture if should ignore FOOTPRINTs on Front Side.
* @return true if should ignore FOOTPRINTs on Front Side.
*/
virtual bool IgnoreFootprintsOnFront() const = 0;
/**
* @return bool - true if should ignore Pads on Back Side.
* @return true if should ignore Pads on Back Side.
*/
virtual bool IgnorePadsOnBack() const = 0;
/**
* @return bool - ture if should ignore PADSs on Front Side.
* @return true if should ignore PADSs on Front Side.
*/
virtual bool IgnorePadsOnFront() const = 0;
/**
* @return bool - ture if should ignore through-hole PADSs.
* @return true if should ignore through-hole PADSs.
*/
virtual bool IgnoreThroughHolePads() const = 0;
/**
* @return bool - true if should ignore PADSs on Front side and Back side.
* @return true if should ignore PADSs on Front side and Back side.
*/
virtual bool IgnorePads() const
{
@ -156,12 +155,12 @@ public:
}
/**
* @return bool - true if should ignore footprint values.
* @return true if should ignore footprint values.
*/
virtual bool IgnoreFPValues() const = 0;
/**
* @return bool - true if should ignore footprint references.
* @return true if should ignore footprint references.
*/
virtual bool IgnoreFPReferences() const = 0;
@ -193,8 +192,8 @@ public:
virtual double OnePixelInIU() const = 0;
/**
* @return bool - true if Inspect() should use BOARD_ITEM::HitTest()
* or false if Inspect() should use BOARD_ITEM::BoundsTest().
* @return true if Inspect() should use BOARD_ITEM::HitTest()
* or false if Inspect() should use BOARD_ITEM::BoundsTest().
virtual bool UseHitTesting() const = 0;
*/
};
@ -217,14 +216,14 @@ public:
* Overload the COLLECTOR::operator[](int) to return a #BOARD_ITEM instead of an #EDA_ITEM.
*
* @param ndx The index into the list.
* @return BOARD_ITEM* - or something derived from it, or NULL.
* @return a board item or NULL.
*/
BOARD_ITEM* operator[]( int ndx ) const override
{
if( (unsigned)ndx < (unsigned)GetCount() )
return (BOARD_ITEM*) m_list[ ndx ];
return NULL;
return nullptr;
}
};
@ -250,7 +249,7 @@ protected:
std::vector<BOARD_ITEM*> m_List2nd;
/**
* Determines which items are to be collected by Inspect()
* Determine which items are to be collected by Inspect().
*/
const COLLECTORS_GUIDE* m_Guide;
@ -313,12 +312,9 @@ public:
*/
static const KICAD_T DraggableItems[];
/**
* Constructor GENERALCOLLECTOR
*/
GENERAL_COLLECTOR()
{
m_Guide = NULL;
m_Guide = nullptr;
m_PrimaryLength = 0;
SetScanTypes( AllBoardItems );
}
@ -343,19 +339,19 @@ public:
const COLLECTORS_GUIDE* GetGuide() const { return m_Guide; }
/**
* @return int - The number if items which met the primary search criteria
* @return The number of items which met the primary search criteria
*/
int GetPrimaryCount() { return m_PrimaryLength; }
/**
* The examining function within the INSPECTOR which is passed to the Iterate function.
*
* Searches and collects all the objects which match the test data.
* Search and collect all the objects which match the test data.
*
* @param testItem An EDA_ITEM to examine.
* @param testData is not used in this class.
* @return SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan,
* else SCAN_CONTINUE;
* else SCAN_CONTINUE;
*/
SEARCH_RESULT Inspect( EDA_ITEM* testItem, void* testData ) override;
@ -370,7 +366,7 @@ public:
* @param aGuide The COLLECTORS_GUIDE to use in collecting items.
*/
void Collect( BOARD_ITEM* aItem, const KICAD_T aScanList[],
const wxPoint& aRefPos, const COLLECTORS_GUIDE& aGuide );
const wxPoint& aRefPos, const COLLECTORS_GUIDE& aGuide );
};
@ -380,40 +376,6 @@ public:
*/
class GENERAL_COLLECTORS_GUIDE : public COLLECTORS_GUIDE
{
private:
// the storage architecture here is not important, since this is only
// a carrier object and its functions are what is used, and data only indirectly.
PCB_LAYER_ID m_preferredLayer;
bool m_ignorePreferredLayer;
LSET m_lockedLayers; ///< bit-mapped layer locked bits
bool m_ignoreLockedLayers;
LSET m_visibleLayers; ///< bit-mapped layer visible bits
bool m_ignoreNonVisibleLayers;
bool m_ignoreLockedItems;
bool m_includeSecondary;
bool m_ignoreHiddenFPText;
bool m_ignoreFPTextOnBack;
bool m_ignoreFPTextOnFront;
bool m_ignoreFootprintsOnBack;
bool m_ignoreFootprintsOnFront;
bool m_ignorePadsOnFront;
bool m_ignorePadsOnBack;
bool m_ignoreThroughHolePads;
bool m_ignoreFPValues;
bool m_ignoreFPReferences;
bool m_ignoreThroughVias;
bool m_ignoreBlindBuriedVias;
bool m_ignoreMicroVias;
bool m_ignoreTracks;
bool m_ignoreZoneFills;
double m_onePixelInIU;
public:
/**
@ -421,8 +383,8 @@ public:
*
* Add more constructors as needed.
*
* @param aVisibleLayerMask = current visible layers (bit mask)
* @param aPreferredLayer = the layer to search first
* @param aVisibleLayerMask is the current visible layers (bit mask).
* @param aPreferredLayer is the layer to search first.
*/
GENERAL_COLLECTORS_GUIDE( LSET aVisibleLayerMask, PCB_LAYER_ID aPreferredLayer,
KIGFX::VIEW* aView )
@ -465,7 +427,7 @@ public:
}
/**
* @return bool - true if the given layer is locked, else false.
* @return true if the given layer is locked, else false.
*/
bool IsLayerLocked( PCB_LAYER_ID aLayerId ) const override
{
@ -478,7 +440,7 @@ public:
}
/**
* @return bool - true if the given layer is visible, else false.
* @return true if the given layer is visible, else false.
*/
bool IsLayerVisible( PCB_LAYER_ID aLayerId ) const override
{
@ -491,13 +453,13 @@ public:
void SetLayerVisibleBits( LSET aLayerBits ) { m_visibleLayers = aLayerBits; }
/**
* @return bool - true if should ignore locked layers, else false.
* @return true if should ignore locked layers, else false.
*/
bool IgnoreLockedLayers() const override { return m_ignoreLockedLayers; }
void SetIgnoreLockedLayers( bool ignore ) { m_ignoreLockedLayers = ignore; }
/**
* @return bool - true if should ignore non-visible layers, else false.
* @return true if should ignore non-visible layers, else false.
*/
bool IgnoreNonVisibleLayers() const override { return m_ignoreNonVisibleLayers; }
void SetIgnoreNonVisibleLayers( bool ignore ) { m_ignoreLockedLayers = ignore; }
@ -511,13 +473,13 @@ public:
/**
* Provide wildcard behavior regarding the preferred layer.
*
* @return bool - true if should ignore preferred layer, else false.
* @return true if should ignore preferred layer, else false.
*/
bool IgnorePreferredLayer() const override { return m_ignorePreferredLayer; }
void SetIgnorePreferredLayer( bool ignore ) { m_ignorePreferredLayer = ignore; }
/**
* @return bool - true if should ignore locked items, else false.
* @return true if should ignore locked items, else false.
*/
bool IgnoreLockedItems() const override { return m_ignoreLockedItems; }
void SetIgnoreLockedItems( bool ignore ) { m_ignoreLockedItems = ignore; }
@ -525,67 +487,67 @@ public:
/**
* Determine if the secondary criteria, or 2nd choice items should be included.
*
* @return bool - true if should include, else false.
* @return true if should include, else false.
*/
bool IncludeSecondary() const override { return m_includeSecondary; }
void SetIncludeSecondary( bool include ) { m_includeSecondary = include; }
/**
* @return bool - true if MTexts marked as "no show" should be ignored.
* @return true if MTexts marked as "no show" should be ignored.
*/
bool IgnoreHiddenFPText() const override { return m_ignoreHiddenFPText; }
void SetIgnoreMTextsMarkedNoShow( bool ignore ) { m_ignoreHiddenFPText = ignore; }
/**
* @return bool - true if should ignore MTexts on back layers
* @return true if should ignore MTexts on back layers
*/
bool IgnoreFPTextOnBack() const override { return m_ignoreFPTextOnBack; }
void SetIgnoreMTextsOnBack( bool ignore ) { m_ignoreFPTextOnBack = ignore; }
/**
* @return bool - true if should ignore MTexts on front layers
* @return true if should ignore MTexts on front layers
*/
bool IgnoreFPTextOnFront() const override { return m_ignoreFPTextOnFront; }
void SetIgnoreMTextsOnFront( bool ignore ) { m_ignoreFPTextOnFront = ignore; }
/**
* @return bool - true if should ignore MODULEs on the back side
* @return true if should ignore MODULEs on the back side
*/
bool IgnoreFootprintsOnBack() const override { return m_ignoreFootprintsOnBack; }
void SetIgnoreModulesOnBack( bool ignore ) { m_ignoreFootprintsOnBack = ignore; }
/**
* @return bool - true if should ignore MODULEs on component layer.
* @return true if should ignore MODULEs on component layer.
*/
bool IgnoreFootprintsOnFront() const override { return m_ignoreFootprintsOnFront; }
void SetIgnoreModulesOnFront( bool ignore ) { m_ignoreFootprintsOnFront = ignore; }
/**
* @return bool - true if should ignore Pads on Back Side.
* @return true if should ignore Pads on Back Side.
*/
bool IgnorePadsOnBack() const override { return m_ignorePadsOnBack; }
void SetIgnorePadsOnBack(bool ignore) { m_ignorePadsOnBack = ignore; }
/**
* @return bool - true if should ignore PADSs on Front Side.
* @return true if should ignore PADSs on Front Side.
*/
bool IgnorePadsOnFront() const override { return m_ignorePadsOnFront; }
void SetIgnorePadsOnFront(bool ignore) { m_ignorePadsOnFront = ignore; }
/**
* @return bool - true if should ignore through-hole PADSs.
* @return true if should ignore through-hole PADSs.
*/
bool IgnoreThroughHolePads() const override { return m_ignoreThroughHolePads; }
void SetIgnoreThroughHolePads(bool ignore) { m_ignoreThroughHolePads = ignore; }
/**
* @return bool - true if should ignore footprints values.
* @return true if should ignore footprints values.
*/
bool IgnoreFPValues() const override { return m_ignoreFPValues; }
void SetIgnoreModulesVals(bool ignore) { m_ignoreFPValues = ignore; }
/**
* @return bool - true if should ignore footprints references.
* @return true if should ignore footprints references.
*/
bool IgnoreFPReferences() const override { return m_ignoreFPReferences; }
void SetIgnoreModulesRefs(bool ignore) { m_ignoreFPReferences = ignore; }
@ -607,6 +569,40 @@ public:
double OnePixelInIU() const override { return m_onePixelInIU; }
void SetOnePixelInIU( double aValue ) { m_onePixelInIU = aValue; }
private:
// the storage architecture here is not important, since this is only
// a carrier object and its functions are what is used, and data only indirectly.
PCB_LAYER_ID m_preferredLayer;
bool m_ignorePreferredLayer;
LSET m_lockedLayers; ///< bit-mapped layer locked bits
bool m_ignoreLockedLayers;
LSET m_visibleLayers; ///< bit-mapped layer visible bits
bool m_ignoreNonVisibleLayers;
bool m_ignoreLockedItems;
bool m_includeSecondary;
bool m_ignoreHiddenFPText;
bool m_ignoreFPTextOnBack;
bool m_ignoreFPTextOnFront;
bool m_ignoreFootprintsOnBack;
bool m_ignoreFootprintsOnFront;
bool m_ignorePadsOnFront;
bool m_ignorePadsOnBack;
bool m_ignoreThroughHolePads;
bool m_ignoreFPValues;
bool m_ignoreFPReferences;
bool m_ignoreThroughVias;
bool m_ignoreBlindBuriedVias;
bool m_ignoreMicroVias;
bool m_ignoreTracks;
bool m_ignoreZoneFills;
double m_onePixelInIU;
};
@ -624,8 +620,7 @@ public:
*
* @param testItem An EDA_ITEM to examine.
* @param testData is not used in this class.
* @return SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan,
* else SCAN_CONTINUE;
* @return SEARCH_QUIT if the Iterator is to stop the scan, else SCAN_CONTINUE;
*/
SEARCH_RESULT Inspect( EDA_ITEM* testItem, void* testData ) override;
@ -646,8 +641,6 @@ public:
*/
class PCB_LAYER_COLLECTOR : public PCB_COLLECTOR
{
PCB_LAYER_ID m_layer_id;
public:
PCB_LAYER_COLLECTOR( PCB_LAYER_ID aLayerId = UNDEFINED_LAYER ) :
m_layer_id( aLayerId )
@ -667,12 +660,15 @@ public:
SEARCH_RESULT Inspect( EDA_ITEM* testItem, void* testData ) override;
/**
* Tests a BOARD_ITEM using this class's Inspector method, which does the collection.
* Test a BOARD_ITEM using this class's Inspector method, which does the collection.
*
* @param aBoard The BOARD_ITEM to scan.
* @param aScanList The KICAD_Ts to gather up.
*/
void Collect( BOARD_ITEM* aBoard, const KICAD_T aScanList[] );
private:
PCB_LAYER_ID m_layer_id;
};
#endif // COLLECTORS_H

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -141,7 +141,7 @@ public:
wxString GetValueText() const;
/**
* Updates the dimension's cached text and geometry
* Update the dimension's cached text and geometry.
*/
void Update()
{
@ -195,14 +195,16 @@ public:
}
/**
* Sets the override text - has no effect if m_overrideValue == false
* @param aNewText is the text to use as the value
* Set the override text - has no effect if m_overrideValue == false.
*
* @param aNewText is the text to use as the value.
*/
void SetText( const wxString& aNewText );
/**
* Retrieves the value text or override text, not including prefix or suffix
* @return the value portion of the dimension text (either overridden or not)
* Retrieve the value text or override text, not including prefix or suffix.
*
* @return the value portion of the dimension text (either overridden or not).
*/
const wxString GetText() const;
@ -210,7 +212,7 @@ public:
const PCB_TEXT& Text() const { return m_text; }
/**
* @return a list of line segments that make up this dimension (for drawing, plotting, etc)
* @return a list of line segments that make up this dimension (for drawing, plotting, etc).
*/
const std::vector<std::shared_ptr<SHAPE>>& GetShapes() const { return m_shapes; }
@ -221,10 +223,12 @@ public:
void Flip( const wxPoint& aCentre, bool aFlipLeftRight ) override;
/**
* Mirror the Dimension , relative to a given horizontal axis
* the text is not mirrored. only its position (and angle) is mirrored
* the layer is not changed
* @param axis_pos : vertical axis position
* Mirror the dimension relative to a given horizontal axis.
*
* The text is not mirrored. Only its position (and angle) is mirrored. The layer is not
* changed.
*
* @param axis_pos is the vertical axis position to mirror around.
*/
void Mirror( const wxPoint& axis_pos, bool aMirrorLeftRight = false );
@ -252,12 +256,12 @@ public:
protected:
/**
* Updates the cached geometry of the dimension after changing any of its properties
* Update the cached geometry of the dimension after changing any of its properties.
*/
virtual void updateGeometry() = 0;
/**
* Updates the text field value from the current geometry (called by updateGeometry normally)
* Update the text field value from the current geometry (called by updateGeometry normally).
*/
virtual void updateText();
@ -265,15 +269,17 @@ protected:
void addShape( const ShapeType& aShape );
/**
* Finds the intersection between a given segment and polygon outline
* @param aPoly is the polygon to collide
* @param aSeg is the segment to collide
* @param aStart if true will start from aSeg.A, otherwise aSeg.B
* @return a point on aSeg that collides with aPoly closest to the start, if one exists
* Find the intersection between a given segment and polygon outline.
*
* @param aPoly is the polygon to collide.
* @param aSeg is the segment to collide.
* @param aStart if true will start from aSeg.A, otherwise aSeg.B.
* @return a point on aSeg that collides with aPoly closest to the start, if one exists.
*/
static OPT_VECTOR2I segPolyIntersection( const SHAPE_POLY_SET& aPoly, const SEG& aSeg, bool aStart = true );
static OPT_VECTOR2I segPolyIntersection( const SHAPE_POLY_SET& aPoly, const SEG& aSeg,
bool aStart = true );
static OPT_VECTOR2I segCircleIntersection( CIRCLE& aCircle, SEG& aSeg, bool aStart = true );
// Value format
bool m_overrideTextEnabled; ///< Manually specify the displayed measurement value
wxString m_valueString; ///< Displayed value when m_overrideValue = true
@ -304,6 +310,7 @@ protected:
static constexpr float s_arrowAngle = 27.5;
};
/**
* For better understanding of the points that make a dimension:
*
@ -333,14 +340,6 @@ protected:
*/
class ALIGNED_DIMENSION : public DIMENSION_BASE
{
protected:
// Geometry
int m_height; ///< Perpendicular distance from features to crossbar
int m_extensionHeight; ///< Length of extension lines past the crossbar
wxPoint m_crossBarStart; ///< Crossbar start control point
wxPoint m_crossBarEnd; ///< Crossbar end control point
public:
ALIGNED_DIMENSION( BOARD_ITEM* aParent, KICAD_T aType = PCB_DIM_ALIGNED_T );
@ -365,15 +364,17 @@ public:
const wxPoint& GetCrossbarEnd() const { return m_crossBarEnd; }
/**
* Sets the distance from the feature points to the crossbar line
* Set the distance from the feature points to the crossbar line.
*
* @param aHeight is the new height.
*/
void SetHeight( int aHeight ) { m_height = aHeight; }
int GetHeight() const { return m_height; }
/**
* Updates stored height basing on points coordinates.
* @param aCrossbarStart is the start point of the crossbar
* Update the stored height basing on points coordinates.
*
* @param aCrossbarStart is the start point of the crossbar.
*/
void UpdateHeight( const wxPoint& aCrossbarStart, const wxPoint& aCrossbarEnd );
@ -381,8 +382,8 @@ public:
int GetExtensionHeight() const { return m_extensionHeight; }
/**
* Function GetAngle
* Returns angle of the crossbar.
* Return the angle of the crossbar.
*
* @return Angle of the crossbar line expressed in radians.
*/
double GetAngle() const
@ -400,10 +401,17 @@ public:
void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
protected:
void updateGeometry() override;
void updateText() override;
// Geometry
int m_height; ///< Perpendicular distance from features to crossbar
int m_extensionHeight; ///< Length of extension lines past the crossbar
wxPoint m_crossBarStart; ///< Crossbar start control point
wxPoint m_crossBarEnd; ///< Crossbar end control point
};
@ -420,11 +428,6 @@ public:
VERTICAL // Aligned with y-axis
};
private:
// Geometry
DIR m_orientation; ///< What axis to lock the dimension line to
public:
ORTHOGONAL_DIMENSION( BOARD_ITEM* aParent );
~ORTHOGONAL_DIMENSION() = default;
@ -441,8 +444,9 @@ public:
BITMAPS GetMenuImage() const override;
/**
* Sets the orientation of the dimension line (so, perpendicular to the feature lines)
* @param aOrientation is the orientation the dimension should take
* Set the orientation of the dimension line (so, perpendicular to the feature lines).
*
* @param aOrientation is the orientation the dimension should take.
*/
void SetOrientation( DIR aOrientation ) { m_orientation = aOrientation; }
DIR GetOrientation() const { return m_orientation; }
@ -454,10 +458,14 @@ public:
void Rotate( const wxPoint& aRotCentre, double aAngle ) override;
protected:
void updateGeometry() override;
void updateText() override;
private:
// Geometry
DIR m_orientation; ///< What axis to lock the dimension line to.
};
@ -477,8 +485,6 @@ protected:
*/
class LEADER : public DIMENSION_BASE
{
DIM_TEXT_FRAME m_textFrame;
public:
LEADER( BOARD_ITEM* aParent );
@ -504,19 +510,21 @@ public:
void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
protected:
void updateGeometry() override;
private:
DIM_TEXT_FRAME m_textFrame;
};
/**
* Marks the center of a circle or arc with a cross shape
* Mark the center of a circle or arc with a cross shape.
*
* The size and orientation of the cross is adjustable.
* m_start always marks the center being measured; m_end marks the end of one leg of the cross.
*/
class CENTER_DIMENSION : public DIMENSION_BASE
{
public:
CENTER_DIMENSION( BOARD_ITEM* aParent );
@ -541,7 +549,6 @@ public:
const BOX2I ViewBBox() const override;
protected:
void updateGeometry() override;
};

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
*
* 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
@ -83,36 +83,6 @@ protected:
class FOOTPRINT_LIST_IMPL : public FOOTPRINT_LIST
{
FOOTPRINT_ASYNC_LOADER* m_loader;
std::vector<std::thread> m_threads;
SYNC_QUEUE<wxString> m_queue_in;
SYNC_QUEUE<wxString> m_queue_out;
std::atomic_size_t m_count_finished;
long long m_list_timestamp;
PROGRESS_REPORTER* m_progress_reporter;
std::atomic_bool m_cancelled;
std::mutex m_join;
/**
* Call aFunc, pushing any IO_ERRORs and std::exceptions it throws onto m_errors.
*
* @return true if no error occurred.
*/
bool CatchErrors( const std::function<void()>& aFunc );
protected:
void startWorkers( FP_LIB_TABLE* aTable, wxString const* aNickname,
FOOTPRINT_ASYNC_LOADER* aLoader, unsigned aNThreads ) override;
bool joinWorkers() override;
void stopWorkers() override;
/**
* Function loader_job
* loads footprints from m_queue_in.
*/
void loader_job();
public:
FOOTPRINT_LIST_IMPL();
virtual ~FOOTPRINT_LIST_IMPL();
@ -122,6 +92,36 @@ public:
bool ReadFootprintFiles( FP_LIB_TABLE* aTable, const wxString* aNickname = nullptr,
PROGRESS_REPORTER* aProgressReporter = nullptr ) override;
protected:
void startWorkers( FP_LIB_TABLE* aTable, wxString const* aNickname,
FOOTPRINT_ASYNC_LOADER* aLoader, unsigned aNThreads ) override;
bool joinWorkers() override;
void stopWorkers() override;
/**
* Load footprints from m_queue_in.
*/
void loader_job();
private:
/**
* Call aFunc, pushing any IO_ERRORs and std::exceptions it throws onto m_errors.
*
* @return true if no error occurred.
*/
bool CatchErrors( const std::function<void()>& aFunc );
FOOTPRINT_ASYNC_LOADER* m_loader;
std::vector<std::thread> m_threads;
SYNC_QUEUE<wxString> m_queue_in;
SYNC_QUEUE<wxString> m_queue_out;
std::atomic_size_t m_count_finished;
long long m_list_timestamp;
PROGRESS_REPORTER* m_progress_reporter;
std::atomic_bool m_cancelled;
std::mutex m_join;
};
extern FOOTPRINT_LIST_IMPL GFootprintList; // KIFACE scope.

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 NBEE Embedded Systems SL, Miguel Angel Ajo <miguelangel@ajo.es>
* Copyright (C) 2013-2020 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2013-2021 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -46,8 +46,7 @@ const wxString WIZARD_PARAM_UNITS_PERCENT = "%"; // Percent (0% -> 1
const wxString WIZARD_PARAM_UNITS_STRING = "string"; // String
/**
* FOOTPRINT_WIZARD
* This is the parent class from where any footprint wizard class must derive
* The parent class from where any footprint wizard class must derive.
*/
class FOOTPRINT_WIZARD
{
@ -56,113 +55,98 @@ public:
virtual ~FOOTPRINT_WIZARD();
/**
* Function GetName
* @return the name of the wizard
* @return the name of the wizard.
*/
virtual wxString GetName() = 0;
/**
* Function GetImage
* @return an svg image of the wizard to be rendered
* @return an svg image of the wizard to be rendered.
*/
virtual wxString GetImage() = 0;
/**
* Function GetDescription
* @return a description of the footprint wizard
* @return a description of the footprint wizard.
*/
virtual wxString GetDescription() = 0;
/**
* Function GetNumParameterPages
* @return the number of parameter pages that this wizard will show to the user
* @return the number of parameter pages that this wizard will show to the user.
*/
virtual int GetNumParameterPages() = 0;
/**
* Function GetParameterPageName
* @param aPage is the page we want the name of
* @return a string with the page name
* @param aPage is the page we want the name of.
* @return a string with the page name.
*/
virtual wxString GetParameterPageName( int aPage ) = 0;
/**
* Function GetParameterNames
* @param aPage is the page we want the parameter names of
* @return an array string with the parameter names on a certain page
* @param aPage is the page we want the parameter names of.
* @return an array string with the parameter names on a certain page.
*/
virtual wxArrayString GetParameterNames( int aPage ) = 0;
/**
* Function GetParameterTypes
* @param aPage is the page we want the parameter types of
* @param aPage is the page we want the parameter types of.
* @return an array string with the parameter types on a certain page
* "IU" for internal units, "UNITS" for units (0,1,2,3...,N)
* "IU" for internal units, "UNITS" for units (0,1,2,3...,N).
*/
virtual wxArrayString GetParameterTypes( int aPage ) = 0;
/**
* Function GetParameterValues
* @param aPage is the page we want the parameter values of
* @return an array of parameter values
* @param aPage is the page we want the parameter values of.
* @return an array of parameter values.
*/
virtual wxArrayString GetParameterValues( int aPage ) = 0;
/**
* Function GetParameterErrors
* @param aPage is the page we want to know the errors of
* @return an array of errors (if any) for the parameters, empty strings for OK parameters
* @param aPage is the page we want to know the errors of.
* @return an array of errors (if any) for the parameters, empty strings for OK parameters.
*/
virtual wxArrayString GetParameterErrors( int aPage ) = 0;
/**
* Function GetParameterHints
* @param aPage is the page we want to know the hints of
* @return an array of hints (if any) for the parameters, empty string for no hints
* @param aPage is the page we want to know the hints of.
* @return an array of hints (if any) for the parameters, empty string for no hints.
*/
virtual wxArrayString GetParameterHints( int aPage ) = 0;
/**
* Function GetParamaterDesignators
* @param aPage is the page we want to know the designators of
* @return an array of designators (blank strings for no designators
* @param aPage is the page we want to know the designators of.
* @return an array of designators (blank strings for no designators.
*/
virtual wxArrayString GetParameterDesignators( int aPage ) = 0;
/**
* Function SetParameterValues
* @param aPage is the page we want to set the parameters in
* @param aValues are the values we want to set into the parameters
* @return an array of parameter values
* @param aPage is the page we want to set the parameters in.
* @param aValues are the values we want to set into the parameters.
* @return an array of parameter values.
*/
virtual wxString SetParameterValues( int aPage, wxArrayString& aValues ) = 0;
/**
* Function ResetParameters
* Reset all wizard parameters to default values
* Reset all wizard parameters to default values.
*/
virtual void ResetParameters() = 0;
/**
* Function GetFootprint
* This method builds the footprint itself and returns it to the caller function
* @return PCB footprint built from the parameters given to the class
* @param aMessage a wxString to store messages (if any) generated by the
* footprint generator
* Build the footprint itself and returns it to the caller function.
*
* @param aMessage is storage for messages (if any) generated by the footprint generator.
* @return a footprint built from the parameters given to the class.
*/
virtual FOOTPRINT* GetFootprint( wxString* aMessage ) = 0;
/**
* Function GetObject
* This method gets the pointer to the object from where this wizard constructs
* @return it's a void pointer, as it could be a PyObject or any other
* Get the object from where this wizard constructs.
*
* @return it's a void pointer as it could be a PyObject or any other.
*/
virtual void* GetObject() = 0;
/**
* Function register_wizard
* It's the standard method of a "FOOTPRINT_WIZARD" to register itself into
* The standard method of a "FOOTPRINT_WIZARD" to register itself into
* the FOOTPRINT_WIZARD_LIST singleton manager
*/
void register_wizard();
@ -171,54 +155,50 @@ public:
class FOOTPRINT_WIZARD_LIST
{
private:
/**
* FOOTPRINT_WIZARD system wide static list
*/
static std::vector<FOOTPRINT_WIZARD*> m_FootprintWizards;
public:
/**
* Function register_wizard
* A footprint wizard calls this static method when it wants to register itself
* into the system wizards
* Note: if it is already registered, this function do nothing
* if n existing wizard with the same name exists, this existing wizard will be
* unregistered.
* @param aWizard is the footprint wizard to be registered
* into the system wizards.
*
* @note If it is already registered, this function does nothing if an existing wizard
* with the same name exists, this existing wizard will be unregistered.
*
* @param aWizard is the footprint wizard to be registered.
*/
static void register_wizard( FOOTPRINT_WIZARD* aWizard );
/**
* Function deregister_object
* Anyone calls this method to deregister an object which builds a wizard,
* it will lookup on the vector calling GetObject until find, then removed
* and deleted
* Unregister an object which builds a wizard.
*
* @param aObject is the footprint wizard object to be deregistered
* Lookup in the vector calling GetObject until find, then removed and deleted.
*
* @param aObject is the footprint wizard object to be unregistered.
*/
static bool deregister_object( void* aObject );
/**
* Function GetWizard
* @param aName is the footprint wizard name
* @param aName is the footprint wizard name.
* @return a wizard object by it's name or NULL if it isn't available.
*/
static FOOTPRINT_WIZARD* GetWizard( const wxString& aName );
/**
* Function GetWizard
* @param aIndex is the wizard index in list.
* @return a wizard object by it's number or NULL if it isn't available.
* @param aIndex is the wizard index in list
*/
static FOOTPRINT_WIZARD* GetWizard( int aIndex );
/**
* Function GetWizardsCount
* @return the number of wizards available into the system
*/
static int GetWizardsCount();
private:
/**
* FOOTPRINT_WIZARD system wide static list
*/
static std::vector<FOOTPRINT_WIZARD*> m_FootprintWizards;
};
#endif /* PCBNEW_FOOTPRINT_WIZARDS_H */

View File

@ -49,31 +49,9 @@ enum WizardParameterColumnNames
WIZ_COL_UNITS
};
/**
* FOOTPRINT_WIZARD_FRAME
*/
class FOOTPRINT_WIZARD_FRAME : public PCB_BASE_EDIT_FRAME
{
private:
wxPanel* m_parametersPanel; ///< Panel for the page list and parameter grid
wxListBox* m_pageList; ///< The list of pages
WX_GRID* m_parameterGrid; ///< The list of parameters
int m_parameterGridPage; ///< the page currently displayed by m_parameterGrid
///< it is most of time the m_pageList selection, but
///< can differ during transitions between pages.
wxTextCtrl* m_buildMessageBox;
wxString m_auiPerspective; ///< Encoded string describing the AUI layout
bool m_wizardListShown; ///< A show-once flag for the wizard list
protected:
wxString m_wizardName; ///< name of the current wizard
wxString m_wizardDescription; ///< description of the wizard
wxString m_wizardStatus; ///< current wizard status
public:
FOOTPRINT_WIZARD_FRAME( KIWAY* aKiway, wxWindow* parent, FRAME_T aFrameType );
~FOOTPRINT_WIZARD_FRAME();
@ -205,6 +183,24 @@ private:
void OnEditItemRequest( BOARD_ITEM* aItem ) override {}
DECLARE_EVENT_TABLE()
protected:
wxString m_wizardName; ///< name of the current wizard
wxString m_wizardDescription; ///< description of the wizard
wxString m_wizardStatus; ///< current wizard status
private:
wxPanel* m_parametersPanel; ///< Panel for the page list and parameter grid
wxListBox* m_pageList; ///< The list of pages
WX_GRID* m_parameterGrid; ///< The list of parameters
int m_parameterGridPage; ///< the page currently displayed by m_parameterGrid
///< it is most of time the m_pageList selection, but
///< can differ during transitions between pages.
wxTextCtrl* m_buildMessageBox;
wxString m_auiPerspective; ///< Encoded string describing the AUI layout
bool m_wizardListShown; ///< A show-once flag for the wizard list
};

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2012-2015 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
* Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -34,27 +34,18 @@ class PCB_BASE_FRAME;
*/
class PCB_LAYER_BOX_SELECTOR : public LAYER_BOX_SELECTOR
{
PCB_BASE_FRAME* m_boardFrame;
LSET m_layerMaskDisable; // A mask to remove some (not allowed) layers
// from layer list
bool m_showNotEnabledBrdlayers; // true to list all allowed layers
// (with not activated layers flagged)
wxString m_undefinedLayerName; // if not empty add an item with this name which sets
// the layer to UNDEFINED_LAYER
public:
// If you are thinking the constructor is a bit curious, just remember it is automatically
// generated when used in wxFormBuilder files, and so must have the same signature as the
// wxBitmapComboBox constructor. In particular, value and style are not used by this class.
PCB_LAYER_BOX_SELECTOR( wxWindow* parent, wxWindowID id,
const wxString& value = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
int n = 0, const wxString choices[] = NULL, int style = 0 ) :
const wxString& value = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
int n = 0, const wxString choices[] = nullptr, int style = 0 ) :
LAYER_BOX_SELECTOR( parent, id, pos, size, n, choices )
{
m_boardFrame = NULL;
m_boardFrame = nullptr;
m_showNotEnabledBrdlayers = false;
}
@ -63,7 +54,7 @@ public:
// use with wxFormBuilder.
void SetBoardFrame( PCB_BASE_FRAME* aFrame ) { m_boardFrame = aFrame; };
// SetLayerSet allows disableing some layers, which are not shown in list
// SetLayerSet allows disabling some layers, which are not shown in list
void SetNotAllowedLayerSet( LSET aMask ) { m_layerMaskDisable = aMask; }
// If the UNDEFINED_LAYER should be selectable, give it a name here. Usually either
@ -74,7 +65,7 @@ public:
void Resync() override;
// Allow (or not) the layers not activated for the current board to be shown in layer
// selector. Not actavated layers have their names appended with "(not activated)".
// selector. Not activated layers have their names appended with "(not activated)".
void ShowNonActivatedLayers( bool aShow ) { m_showNotEnabledBrdlayers = aShow; }
private:
@ -88,6 +79,15 @@ private:
wxString getLayerName( LAYER_NUM aLayer ) const override;
LSET getEnabledLayers() const;
PCB_BASE_FRAME* m_boardFrame;
LSET m_layerMaskDisable; // A mask to remove some (not allowed) layers
// from layer list
bool m_showNotEnabledBrdlayers; // true to list all allowed layers
// (with not activated layers flagged)
wxString m_undefinedLayerName; // if not empty add an item with this name which sets
// the layer to UNDEFINED_LAYER
};
#endif // PCB_LAYER_BOX_SELECTOR_H

View File

@ -31,12 +31,10 @@ class COLOR_SETTINGS;
class PCB_PLOT_PARAMS_PARSER;
/**
* PCB_PLOT_PARAMS
* handles plot parameters and options when plotting/printing a board.
* Parameters and options when plotting/printing a board.
*/
class PCB_PLOT_PARAMS
{
friend class PCB_PLOT_PARAMS_PARSER;
public:
enum DrillMarksType {
NO_DRILL_SHAPE = 0,
@ -44,149 +42,6 @@ public:
FULL_DRILL_SHAPE = 2
};
private:
// If true, do not plot NPTH pads
// (mainly used to disable NPTH pads plotting on copper layers)
bool m_skipNPTH_Pads;
/** FILLED or SKETCH selects how to plot filled objects.
* FILLED or SKETCH not available with all drivers: some have fixed mode
*/
OUTLINE_MODE m_plotMode;
/** DXF format: Plot items in outline (polygon) mode
* In polygon mode, each item to plot is converted to a polygon, and all
* polygons are merged.
*/
bool m_DXFplotPolygonMode;
/**
* DXF format: Units to use when plotting the DXF
*/
DXF_UNITS m_DXFplotUnits;
/// Plot format type (chooses the driver to be used)
PLOT_FORMAT m_format;
/// Holes can be not plotted, have a small mark or plotted in actual size
DrillMarksType m_drillMarks;
/// Choose how represent text with PS, PDF and DXF drivers
PLOT_TEXT_MODE m_textMode;
/// When true set the scale to fit the board in the page
bool m_autoScale;
/// Global scale factor, 1.0 plots a board with its actual size.
double m_scale;
/// Mirror the plot around the X axis
bool m_mirror;
/// Plot in negative color (supported only by some drivers)
bool m_negative;
/// True if vias are drawn on Mask layer (ie untented, *exposed* by mask)
bool m_plotViaOnMaskLayer;
/// True to plot/print frame references
bool m_plotFrameRef;
/// If false always plot (merge) the pcb edge layer on other layers
bool m_excludeEdgeLayer;
/// Set of layers to plot
LSET m_layerSelection;
/** When plotting gerber files, use a conventional set of Protel extensions
* instead of .gbr, that is now the offical gerber file extension
* this is a deprecated feature
*/
bool m_useGerberProtelExtensions;
/// Include attributes from the Gerber X2 format (chapter 5 in revision J2)
bool m_useGerberX2format;
/// Disable aperure macros in Gerber format (only for broken Gerber readers)
/// Ideally, should be never selected.
bool m_gerberDisableApertMacros;
/// Include netlist info (only in Gerber X2 format) (chapter ? in revision ?)
bool m_includeGerberNetlistInfo;
/// generate the auxiliary "job file" in gerber format
bool m_createGerberJobFile;
/// precision of coordinates in Gerber files: accepted 5 or 6
/// when units are in mm (6 or 7 in inches, but Pcbnew uses mm).
/// 6 is the internal resolution of Pcbnew, but not alwys accepted by board maker
/// 5 is the minimal value for professional boards.
int m_gerberPrecision;
/// precision of coordinates in SVG files: accepted 3 - 6
/// 6 is the internal resolution of Pcbnew
unsigned m_svgPrecision;
/// units for SVG plot
/// false for metric, true for inch/mils
bool m_svgUseInch;
/// Plot gerbers using auxiliary (drill) origin instead of absolue coordinates
bool m_useAuxOrigin;
/// On gerbers 'scrape' away the solder mask from silkscreen (trim silks)
bool m_subtractMaskFromSilk;
/// Autoscale the plot to fit an A4 (landscape?) sheet
bool m_A4Output;
/// Scale ratio index (UI only)
int m_scaleSelection;
/// Output directory for plot files (usually relative to the board file)
wxString m_outputDirectory;
/// Enable plotting of part references
bool m_plotReference;
/// Enable plotting of part values
bool m_plotValue;
/// Force plotting of fields marked invisible
bool m_plotInvisibleText;
/// Plots pads outlines on fab layers
bool m_sketchPadsOnFabLayers;
int m_sketchPadLineWidth;
/* These next two scale factors are intended to compensate plotters
* (mainly printers) X and Y scale error. Therefore they are expected very
* near 1.0; only X and Y dimensions are adjusted: circles are plotted as
* circles, even if X and Y fine scale differ; because of this it is mostly
* useful for printers: postscript plots would be best adjusted using
* the prologue (that would change the whole output matrix
*/
double m_fineScaleAdjustX; ///< fine scale adjust X axis
double m_fineScaleAdjustY; ///< fine scale adjust Y axis
/** This width factor is intended to compensate PS printers/ plotters that do
* not strictly obey line width settings. Only used to plot pads and tracks
*/
int m_widthAdjust;
int m_HPGLPenNum; ///< HPGL only: pen number selection(1 to 9)
int m_HPGLPenSpeed; ///< HPGL only: pen speed, always in cm/s (1 to 99 cm/s)
double m_HPGLPenDiam; ///< HPGL only: pen diameter in MILS, useful to fill areas
///< However, it is in mm in hpgl files.
/// Pointer to active color settings to be used for plotting
COLOR_SETTINGS* m_colors;
/// Dummy colors object that can be created if there is no Pgm context
std::shared_ptr<COLOR_SETTINGS> m_default_colors;
public:
PCB_PLOT_PARAMS();
void SetSkipPlotNPTH_Pads( bool aSkip ) { m_skipNPTH_Pads = aSkip; }
@ -196,11 +51,12 @@ public:
void Parse( PCB_PLOT_PARAMS_PARSER* aParser );
/**
* Compare current settings to aPcbPlotParams, including not saved parameters in brd file
* @param aPcbPlotParams = the PCB_PLOT_PARAMS to compare
* @param aCompareOnlySavedPrms = true to compare only saved in file parameters,
* and false to compare the full set of parameters.
* @return true is parameters are same, false if one (or more) parameter does not match
* Compare current settings to aPcbPlotParams, including not saved parameters in brd file.
*
* @param aPcbPlotParams is the #PCB_PLOT_PARAMS to compare/
* @param aCompareOnlySavedPrms set to true to compare only saved in file parameters,
* or false to compare the full set of parameters.
* @return true is parameters are same, false if one (or more) parameter does not match.
*/
bool IsSameAs( const PCB_PLOT_PARAMS &aPcbPlotParams ) const;
@ -305,9 +161,11 @@ public:
unsigned GetSvgPrecision() const { return m_svgPrecision; }
bool GetSvgUseInch() const { return m_svgUseInch; }
/** Default precision of coordinates in Gerber files.
* when units are in mm (7 in inches, but Pcbnew uses mm).
* 6 is the internal resolution of Pcbnew, so the default is 6
/**
* Default precision of coordinates in Gerber files.
*
* When units are in mm (7 in inches, but Pcbnew uses mm).
* 6 is the internal resolution of Pcbnew, so the default is 6.
*/
static int GetGerberDefaultPrecision() { return 6; }
@ -337,6 +195,154 @@ public:
void SetHPGLPenNum( int aVal ) { m_HPGLPenNum = aVal; }
int GetHPGLPenNum() const { return m_HPGLPenNum; }
private:
friend class PCB_PLOT_PARAMS_PARSER;
// If true, do not plot NPTH pads
// (mainly used to disable NPTH pads plotting on copper layers)
bool m_skipNPTH_Pads;
/**
* FILLED or SKETCH selects how to plot filled objects.
*
* FILLED or SKETCH not available with all drivers: some have fixed mode
*/
OUTLINE_MODE m_plotMode;
/**
* DXF format: Plot items in outline (polygon) mode.
*
* In polygon mode, each item to plot is converted to a polygon and all polygons are merged.
*/
bool m_DXFplotPolygonMode;
/**
* DXF format: Units to use when plotting the DXF
*/
DXF_UNITS m_DXFplotUnits;
/// Plot format type (chooses the driver to be used)
PLOT_FORMAT m_format;
/// Holes can be not plotted, have a small mark or plotted in actual size
DrillMarksType m_drillMarks;
/// Choose how represent text with PS, PDF and DXF drivers
PLOT_TEXT_MODE m_textMode;
/// When true set the scale to fit the board in the page
bool m_autoScale;
/// Global scale factor, 1.0 plots a board with its actual size.
double m_scale;
/// Mirror the plot around the X axis
bool m_mirror;
/// Plot in negative color (supported only by some drivers)
bool m_negative;
/// True if vias are drawn on Mask layer (ie untented, *exposed* by mask)
bool m_plotViaOnMaskLayer;
/// True to plot/print frame references
bool m_plotFrameRef;
/// If false always plot (merge) the pcb edge layer on other layers
bool m_excludeEdgeLayer;
/// Set of layers to plot
LSET m_layerSelection;
/** When plotting gerber files, use a conventional set of Protel extensions
* instead of .gbr, that is now the official gerber file extension
* this is a deprecated feature
*/
bool m_useGerberProtelExtensions;
/// Include attributes from the Gerber X2 format (chapter 5 in revision J2)
bool m_useGerberX2format;
/// Disable aperture macros in Gerber format (only for broken Gerber readers)
/// Ideally, should be never selected.
bool m_gerberDisableApertMacros;
/// Include netlist info (only in Gerber X2 format) (chapter ? in revision ?)
bool m_includeGerberNetlistInfo;
/// generate the auxiliary "job file" in gerber format
bool m_createGerberJobFile;
/// precision of coordinates in Gerber files: accepted 5 or 6
/// when units are in mm (6 or 7 in inches, but Pcbnew uses mm).
/// 6 is the internal resolution of Pcbnew, but not always accepted by board maker
/// 5 is the minimal value for professional boards.
int m_gerberPrecision;
/// precision of coordinates in SVG files: accepted 3 - 6
/// 6 is the internal resolution of Pcbnew
unsigned m_svgPrecision;
/// units for SVG plot
/// false for metric, true for inch/mils
bool m_svgUseInch;
/// Plot gerbers using auxiliary (drill) origin instead of absolute coordinates
bool m_useAuxOrigin;
/// On gerbers 'scrape' away the solder mask from silkscreen (trim silks)
bool m_subtractMaskFromSilk;
/// Autoscale the plot to fit an A4 (landscape?) sheet
bool m_A4Output;
/// Scale ratio index (UI only)
int m_scaleSelection;
/// Output directory for plot files (usually relative to the board file)
wxString m_outputDirectory;
/// Enable plotting of part references
bool m_plotReference;
/// Enable plotting of part values
bool m_plotValue;
/// Force plotting of fields marked invisible
bool m_plotInvisibleText;
/// Plots pads outlines on fab layers
bool m_sketchPadsOnFabLayers;
int m_sketchPadLineWidth;
/* These next two scale factors are intended to compensate plotters
* (mainly printers) X and Y scale error. Therefore they are expected very
* near 1.0; only X and Y dimensions are adjusted: circles are plotted as
* circles, even if X and Y fine scale differ; because of this it is mostly
* useful for printers: postscript plots would be best adjusted using
* the prologue (that would change the whole output matrix
*/
double m_fineScaleAdjustX; ///< fine scale adjust X axis
double m_fineScaleAdjustY; ///< fine scale adjust Y axis
/**
* This width factor is intended to compensate PS printers/ plotters that do
* not strictly obey line width settings. Only used to plot pads and tracks.
*/
int m_widthAdjust;
int m_HPGLPenNum; ///< HPGL only: pen number selection(1 to 9)
int m_HPGLPenSpeed; ///< HPGL only: pen speed, always in cm/s (1 to 99 cm/s)
double m_HPGLPenDiam; ///< HPGL only: pen diameter in MILS, useful to fill areas
///< However, it is in mm in hpgl files.
/// Pointer to active color settings to be used for plotting
COLOR_SETTINGS* m_colors;
/// Dummy colors object that can be created if there is no Pgm context
std::shared_ptr<COLOR_SETTINGS> m_default_colors;
};

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2018 Jean-Pierre Charras jp.charras at wanadoo.fr
* Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -41,26 +41,6 @@ class MSG_PANEL_ITEM;
class PCB_SHAPE : public BOARD_ITEM
{
protected:
int m_width; // thickness of lines ...
bool m_filled; // Pretty much what it says on the tin...
wxPoint m_start; // Line start point or Circle and Arc center
wxPoint m_end; // Line end point or circle and arc start point
wxPoint m_thirdPoint; // Used only for Arcs: arc end point
PCB_SHAPE_TYPE m_shape; // Shape: line, Circle, Arc
double m_angle; // Used only for Arcs: Arc angle in 1/10 deg
wxPoint m_bezierC1; // Bezier Control Point 1
wxPoint m_bezierC2; // Bezier Control Point 2
std::vector<wxPoint> m_bezierPoints;
SHAPE_POLY_SET m_poly; // Stores the S_POLYGON shape
// Computes the bounding box for an arc
void computeArcBBox( EDA_RECT& aBBox ) const;
const std::vector<wxPoint> buildBezierToSegmentsPointsList( int aMinSegLen ) const;
public:
PCB_SHAPE( BOARD_ITEM* aParent = NULL, KICAD_T idtype = PCB_SHAPE_T );
@ -117,10 +97,11 @@ public:
int GetWidth() const { return m_width; }
/**
* Sets the angle for arcs, and normalizes it within the range 0 - 360 degrees.
* Set the angle for arcs, and normalizes it within the range 0 - 360 degrees.
*
* @param aAngle is tenths of degrees, but will soon be degrees.
* @param aUpdateEnd = true to update also arc end coordinates m_thirdPoint,
* so must be called after setting m_Start and m_End
* @param aUpdateEnd set to true to update also arc end coordinates m_thirdPoint,
* so must be called after setting m_Start and m_End.
*/
virtual void SetAngle( double aAngle, bool aUpdateEnd = true );
double GetAngle() const { return m_angle; }
@ -138,8 +119,7 @@ public:
wxPoint GetPosition() const override;
/**
* Function GetStart
* returns the starting point of the graphic
* Return the starting point of the graphic.
*/
const wxPoint& GetStart() const { return m_start; }
int GetStartY() { return m_start.y; }
@ -149,8 +129,7 @@ public:
void SetStartX( int x ) { m_start.x = x; }
/**
* Function GetEnd
* returns the ending point of the graphic
* Return the ending point of the graphic.
*/
const wxPoint& GetEnd() const { return m_end; }
int GetEndY() { return m_end.y; }
@ -181,27 +160,26 @@ public:
std::vector<wxPoint> GetRectCorners() const;
/**
* function GetArcAngleStart()
* @return the angle of the starting point of this arc, between 0 and 3600 in 0.1 deg
* @return the angle of the starting point of this arc, between 0 and 3600 in 0.1 deg.
*/
double GetArcAngleStart() const;
/**
* function GetArcAngleEnd()
* @return the angle of the ending point of this arc, between 0 and 3600 in 0.1 deg
* @return the angle of the ending point of this arc, between 0 and 3600 in 0.1 deg.
*/
double GetArcAngleEnd() const;
/**
* Function GetRadius
* returns the radius of this item
* Has meaning only for arc and circle
* Return the radius of this item.
*
* Has meaning only for arcs and circles.
*/
int GetRadius() const;
/**
* Initialize the start arc point. can be used for circles
* to initialize one point of the cicumference
* Initialize the start arc point.
*
* Can be used for circles to initialize one point of the cicumference.
*/
void SetArcStart( const wxPoint& aArcStartPoint )
{
@ -209,16 +187,15 @@ public:
}
/**
* Initialize the end arc point. can be used for circles
* to initialize one point of the cicumference
* Initialize the end arc point.
*
* Can be used for circles to initialize one point of the cicumference.
*/
void SetArcEnd( const wxPoint& aArcEndPoint )
{
m_thirdPoint = aArcEndPoint;
}
/** For arcs and circles:
*/
void SetCenter( const wxPoint& aCenterPoint ) { m_start = aCenterPoint; }
/**
@ -235,17 +212,18 @@ public:
}
/**
* Function GetParentFootprint
* returns a pointer to the parent footprint, or NULL if PCB_SHAPE does not
* belong to a footprint.
* @return FOOTPRINT* - pointer to the parent footprint or NULL.
* Return the parent footprint or NULL if PCB_SHAPE does not belong to a footprint.
*
* @return the parent footprint or NULL.
*/
FOOTPRINT* GetParentFootprint() const;
// Accessors:
const std::vector<wxPoint>& GetBezierPoints() const { return m_bezierPoints; }
/** Build and return the list of corners in a std::vector<wxPoint>
/**
* Build and return the list of corners in a std::vector<wxPoint>
*
* It must be used only to convert the SHAPE_POLY_SET internal corner buffer
* to a list of wxPoints, and nothing else, because it duplicates the buffer,
* that is inefficient to know for instance the corner count
@ -273,20 +251,22 @@ public:
m_bezierPoints = aPoints;
}
/** Rebuild the m_BezierPoints vertex list that approximate the Bezier curve
* by a list of segments
* Has meaning only for S_CURVE DRAW_SEGMENT shape
* @param aMinSegLen is the min length of segments approximating the shape.
* the last segment can be shorter
* This param avoid having too many very short segment in list.
* a good value is m_Width/2 to m_Width
/**
* Rebuild the m_BezierPoints vertex list that approximate the Bezier curve
* by a list of segments.
*
* Has meaning only for S_CURVE DRAW_SEGMENT shape.
*
* @param aMinSegLen is the min length of segments approximating the he. shape last segment
* can be shorter. This parameter avoids having too many very short segment in list.
* A good value is m_Width/2 to m_Width.
*/
void RebuildBezierToSegmentsPointsList( int aMinSegLen );
void SetPolyPoints( const std::vector<wxPoint>& aPoints );
/**
* Makes a set of SHAPE objects representing the PCB_SHAPE. Caller owns the objects.
* Make a set of SHAPE objects representing the PCB_SHAPE. Caller owns the objects.
*/
std::vector<SHAPE*> MakeEffectiveShapes() const; // fixme: move to shape_compound
std::shared_ptr<SHAPE> GetEffectiveShape( PCB_LAYER_ID aLayer = UNDEFINED_LAYER ) const override;
@ -304,11 +284,11 @@ public:
}
/**
* Function GetLength
* returns the length of the track using the hypotenuse calculation.
* @return double - the length of the track
* Return the length of the track using the hypotenuse calculation.
*
* @return the length of the track
*/
double GetLength() const;
double GetLength() const;
virtual void Move( const wxPoint& aMoveVector ) override;
@ -319,15 +299,15 @@ public:
void Scale( double aScale );
/**
* Function TransformShapeWithClearanceToPolygon
* Convert the draw segment to a closed polygon
* Used in filling zones calculations
* Circles and arcs are approximated by segments
* @param aCornerBuffer = a buffer to store the polygon
* @param aClearanceValue = the clearance around the pad
* @param aError = the maximum deviation from a true arc
* @param ignoreLineWidth = used for edge cut items where the line width is only
* for visualization
* Convert the draw segment to a closed polygon.
*
* Used in filling zones calculations. Circles and arcs are approximated by segments.
*
* @param aCornerBuffer is a buffer to store the polygon.
* @param aClearanceValue is the clearance around the pad.
* @param aError is the maximum deviation from a true arc.
* @param ignoreLineWidth is used for edge cut items where the line width is only
* for visualization
*/
void TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer,
PCB_LAYER_ID aLayer, int aClearanceValue,
@ -352,6 +332,26 @@ public:
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
#endif
protected:
// Compute the bounding box for an arc
void computeArcBBox( EDA_RECT& aBBox ) const;
const std::vector<wxPoint> buildBezierToSegmentsPointsList( int aMinSegLen ) const;
int m_width; // thickness of lines ...
bool m_filled; // Pretty much what it says on the tin...
wxPoint m_start; // Line start point or Circle and Arc center
wxPoint m_end; // Line end point or circle and arc start point
wxPoint m_thirdPoint; // Used only for Arcs: arc end point
PCB_SHAPE_TYPE m_shape; // Shape: line, Circle, Arc
double m_angle; // Used only for Arcs: Arc angle in 1/10 deg
wxPoint m_bezierC1; // Bezier Control Point 1
wxPoint m_bezierC2; // Bezier Control Point 2
std::vector<wxPoint> m_bezierPoints;
SHAPE_POLY_SET m_poly; // Stores the S_POLYGON shape
};
#endif // PCB_SHAPE_H

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -34,11 +34,6 @@ class LINE_READER;
class PCB_TARGET : public BOARD_ITEM
{
int m_shape; // bit 0 : 0 = draw +, 1 = draw X
int m_size;
int m_lineWidth;
wxPoint m_pos;
public:
PCB_TARGET( BOARD_ITEM* aParent );
@ -104,6 +99,12 @@ public:
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
#endif
private:
int m_shape; // bit 0 : 0 = draw +, 1 = draw X
int m_size;
int m_lineWidth;
wxPoint m_pos;
};

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -60,10 +60,6 @@ class wxFileName;
// A helper class to plot board items
class BRDITEMS_PLOTTER : public PCB_PLOT_PARAMS
{
PLOTTER* m_plotter;
BOARD* m_board;
LSET m_layerMask;
public:
BRDITEMS_PLOTTER( PLOTTER* aPlotter, BOARD* aBoard, const PCB_PLOT_PARAMS& aPlotOpts )
: PCB_PLOT_PARAMS( aPlotOpts )
@ -105,45 +101,48 @@ public:
/**
* Plot a pad.
* unlike other items, a pad had not a specific color,
* and be drawn as a non filled item although the plot mode is filled
* color and plot mode are needed by this function
*
* Unlike other items, a pad had not a specific color and be drawn as a non filled item
* although the plot mode is filled color and plot mode are needed by this function.
*/
void PlotPad( const PAD* aPad, COLOR4D aColor, OUTLINE_MODE aPlotMode );
/**
* plot items like text and graphics,
* but not tracks and footprints
* Plot items like text and graphics but not tracks and footprints.
*/
void PlotBoardGraphicItems();
/** Function PlotDrillMarks
/**
* Draw a drill mark for pads and vias.
* Must be called after all drawings, because it
* redraw the drill mark on a pad or via, as a negative (i.e. white) shape in
* FILLED plot mode (for PS and PDF outputs)
*
* Must be called after all drawings, because it redraws the drill mark on a pad or via, as
* a negative (i.e. white) shape in FILLED plot mode (for PS and PDF outputs).
*/
void PlotDrillMarks();
/**
* Function getColor
* @return the layer color
* @param aLayer = the layer id
* White color is special: cannot be seen on a white paper
* and in B&W mode, is plotted as white but other colors are plotted in BLACK
* so the returned color is LIGHTGRAY when the layer color is WHITE
* White color is special because it cannot be seen on a white paper in B&W mode. It is
* plotted as white but other colors are plotted in BLACK so the returned color is LIGHTGRAY
* when the layer color is WHITE.
*
* @param aLayer is the layer id.
* @return the layer color.
*/
COLOR4D getColor( LAYER_NUM aLayer ) const;
private:
/** Helper function to plot a single drill mark. It compensate and clamp
* the drill mark size depending on the current plot options
/**
* Helper function to plot a single drill mark.
*
* It compensate and clamp the drill mark size depending on the current plot options.
*/
void plotOneDrillMark( PAD_DRILL_SHAPE_T aDrillShape,
const wxPoint& aDrillPos, wxSize aDrillSize,
const wxSize& aPadSize,
void plotOneDrillMark( PAD_DRILL_SHAPE_T aDrillShape, const wxPoint& aDrillPos,
wxSize aDrillSize, const wxSize& aPadSize,
double aOrientation, int aSmallDrill );
PLOTTER* m_plotter;
BOARD* m_board;
LSET m_layerMask;
};
PLOTTER* StartPlotBoard( BOARD* aBoard,
@ -153,27 +152,28 @@ PLOTTER* StartPlotBoard( BOARD* aBoard,
const wxString& aSheetDesc );
/**
* Function PlotOneBoardLayer
* main function to plot one copper or technical layer.
* It prepare options and calls the specialized plot function,
* according to the layer type
* @param aBoard = the board to plot
* @param aPlotter = the plotter to use
* @param aLayer = the layer id to plot
* @param aPlotOpt = the plot options (files, sketch). Has meaning for some formats only
* Plot one copper or technical layer.
*
* It prepares options and calls the specialized plot function according to the layer type.
*
* @param aBoard is the board to plot.
* @param aPlotter is the plotter to use.
* @param aLayer is the layer id to plot.
* @param aPlotOpt is the plot options (files, sketch). Has meaning for some formats only.
*/
void PlotOneBoardLayer( BOARD* aBoard, PLOTTER* aPlotter, PCB_LAYER_ID aLayer,
const PCB_PLOT_PARAMS& aPlotOpt );
/**
* Function PlotStandardLayer
* plot copper or technical layers.
* not used for silk screen layers, because these layers have specific
* requirements, mainly for pads
* @param aBoard = the board to plot
* @param aPlotter = the plotter to use
* @param aLayerMask = the mask to define the layers to plot
* @param aPlotOpt = the plot options (files, sketch). Has meaning for some formats only
* Plot copper or technical layers.
*
* This is not used for silk screen layers because these layers have specific requirements.
* This is mainly for pads.
*
* @param aBoard is the board to plot.
* @param aPlotter is the plotter to use.
* @param aLayerMask is the mask to define the layers to plot.
* @param aPlotOpt is the plot options (files, sketch). Has meaning for some formats only.
*
* aPlotOpt has 3 important options to control this plot,
* which are set, depending on the layer type to plot
@ -183,34 +183,34 @@ void PlotOneBoardLayer( BOARD* aBoard, PLOTTER* aPlotter, PCB_LAYER_ID aLayer,
* SetSkipPlotNPTH_Pads( bool aSkip )
* aSkip = true to skip NPTH Pads, when the pad size and the pad hole
* have the same size. Used in GERBER format only.
* SetDrillMarksType( DrillMarksType aVal ) controle the actual hole:
* SetDrillMarksType( DrillMarksType aVal ) control the actual hole:
* no hole, small hole, actual hole
*/
void PlotStandardLayer( BOARD* aBoard, PLOTTER* aPlotter, LSET aLayerMask,
const PCB_PLOT_PARAMS& aPlotOpt );
/**
* Function PlotLayerOutlines
* plot copper outline of a copper layer.
* @param aBoard = the board to plot
* @param aPlotter = the plotter to use
* @param aLayerMask = the mask to define the layers to plot
* @param aPlotOpt = the plot options. Has meaning for some formats only
* Plot copper outline of a copper layer.
*
* @param aBoard is the board to plot.
* @param aPlotter is the plotter to use.
* @param aLayerMask is the mask to define the layers to plot.
* @param aPlotOpt is the plot options. Has meaning for some formats only.
*/
void PlotLayerOutlines( BOARD* aBoard, PLOTTER* aPlotter,
LSET aLayerMask, const PCB_PLOT_PARAMS& aPlotOpt );
/**
* Function BuildPlotFileName (helper function)
* Complete a plot filename: forces the output directory,
* add a suffix to the name and sets the specified extension
* the suffix is usually the layer name
* replaces not allowed chars in suffix by '_'
* @param aFilename = the wxFileName to initialize
* Contains the base filename
* @param aOutputDir = the path
* @param aSuffix = the suffix to add to the base filename
* @param aExtension = the file extension
* Complete a plot filename.
*
* It forces the output directory, adds a suffix to the name, and sets the specified extension.
* The suffix is usually the layer name and replaces illegal file name character in the suffix
* with an underscore character.
*
* @param aFilename is the file name to initialize that contains the base filename.
* @param aOutputDir is the path.
* @param aSuffix is the suffix to add to the base filename.
* @param aExtension is the file extension.
*/
void BuildPlotFileName( wxFileName* aFilename,
const wxString& aOutputDir,
@ -219,56 +219,56 @@ void BuildPlotFileName( wxFileName* aFilename,
/**
* Function GetGerberProtelExtension
* @return the appropriate Gerber file extension for \a aLayer
* used by Protel, and still sometimes in use (although the
* official Gerber Ext is now .gbr)
*/
const wxString GetGerberProtelExtension( LAYER_NUM aLayer );
/**
* Function GetGerberFileFunctionAttribute
* Returns the "file function" attribute for \a aLayer, as defined in the
* Gerber file format specification J1 (chapter 5). The returned string includes
* the "%TF.FileFunction" attribute prefix and the "*%" suffix.
* @param aBoard = the board, needed to get the total count of copper layers
* @param aLayer = the layer number to create the attribute for
* Return the "file function" attribute for \a aLayer, as defined in the
* Gerber file format specification J1 (chapter 5).
*
* The returned string includes the "%TF.FileFunction" attribute prefix and the "*%" suffix.
*
* @param aBoard is the board, needed to get the total count of copper layers.
* @param aLayer is the layer number to create the attribute for.
* @return The attribute, as a text string
*/
const wxString GetGerberFileFunctionAttribute( const BOARD* aBoard, LAYER_NUM aLayer );
/**
* Calculates some X2 attributes, as defined in the
* Gerber file format specification J4 (chapter 5) and add them
* the to the gerber file header:
* Calculate some X2 attributes as defined in the Gerber file format specification J4
* (chapter 5) and add them the to the gerber file header.
*
* TF.GenerationSoftware
* TF.CreationDate
* TF.ProjectId
* file format attribute is not added
* @param aPlotter = the current plotter.
* @param aBoard = the board, needed to extract some info
* @param aUseX1CompatibilityMode = false to generate X2 attributes, true to
* use X1 compatibility (X2 attributes added as structured comments,
* starting by "G04 #@! " followed by the X2 attribute
*
* @param aPlotter is the current plotter.
* @param aBoard is the board, needed to extract some info.
* @param aUseX1CompatibilityMode set to false to generate X2 attributes, true to
* use X1 compatibility (X2 attributes added as structured comments,
* starting by "G04 #@! " followed by the X2 attribute
*/
void AddGerberX2Header( PLOTTER* aPlotter,
const BOARD* aBoard, bool aUseX1CompatibilityMode = false );
void AddGerberX2Header( PLOTTER* aPlotter, const BOARD* aBoard,
bool aUseX1CompatibilityMode = false );
/**
* Calculates some X2 attributes, as defined in the Gerber file format
* specification and add them to the gerber file header:
* Calculate some X2 attributes as defined in the Gerber file format specification and add them
* to the gerber file header.
*
* TF.GenerationSoftware
* TF.CreationDate
* TF.ProjectId
* TF.FileFunction
* TF.FilePolarity
*
* @param aPlotter = the current plotter.
* @param aBoard = the board, needed to extract some info
* @param aLayer = the layer number to create the attribute for
* @param aUseX1CompatibilityMode = false to generate X2 attributes, true to
* use X1 compatibility (X2 attributes added as structured comments,
* starting by "G04 #@! " followed by the X2 attribute
* @param aPlotter is the current plotter.
* @param aBoard is the board, needed to extract some info.
* @param aLayer is the layer number to create the attribute for.
* @param aUseX1CompatibilityMode set to false to generate X2 attributes, true to use X1
* compatibility (X2 attributes added as structured comments, starting by "G04 #@! "
* followed by the X2 attribute.
*/
void AddGerberX2Attribute( PLOTTER* aPlotter, const BOARD* aBoard,
LAYER_NUM aLayer, bool aUseX1CompatibilityMode );