Header clean up round 3.

This commit is contained in:
Wayne Stambaugh 2020-12-19 18:29:10 -05:00
parent 46314f6483
commit f06a5894b3
24 changed files with 622 additions and 681 deletions

View File

@ -71,11 +71,11 @@ DIALOG_PAGES_SETTINGS::DIALOG_PAGES_SETTINGS( EDA_DRAW_FRAME* aParent, double aI
DIALOG_PAGES_SETTINGS_BASE( aParent ), DIALOG_PAGES_SETTINGS_BASE( aParent ),
m_parent( aParent ), m_parent( aParent ),
m_screen( m_parent->GetScreen() ), m_screen( m_parent->GetScreen() ),
m_pageBitmap( nullptr ),
m_initialized( false ), m_initialized( false ),
m_pageBitmap( nullptr ),
m_iuPerMils( aIuPerMils ),
m_customSizeX( aParent, m_userSizeXLabel, m_userSizeXCtrl, m_userSizeXUnits, false ), m_customSizeX( aParent, m_userSizeXLabel, m_userSizeXCtrl, m_userSizeXUnits, false ),
m_customSizeY( aParent, m_userSizeYLabel, m_userSizeYCtrl, m_userSizeYUnits, false ), m_customSizeY( aParent, m_userSizeYLabel, m_userSizeYCtrl, m_userSizeYUnits, false )
m_iuPerMils( aIuPerMils )
{ {
m_projectPath = Prj().GetProjectPath(); m_projectPath = Prj().GetProjectPath();
m_maxPageSizeMils = aMaxUserSizeMils; m_maxPageSizeMils = aMaxUserSizeMils;

View File

@ -81,8 +81,8 @@ public:
* @param aId is the string to populate the #LIB_ID object. * @param aId is the string to populate the #LIB_ID object.
* @param aFix indicates invalid chars should be replaced with '_'. * @param aFix indicates invalid chars should be replaced with '_'.
* *
* @return int - minus 1 (i.e. -1) means success, >= 0 indicates the character offset into * @return minus 1 (i.e. -1) means success, >= 0 indicates the character offset into
* aId at which an error was detected. * aId at which an error was detected.
*/ */
int Parse( const UTF8& aId, bool aFix = false ); int Parse( const UTF8& aId, bool aFix = false );
@ -106,9 +106,12 @@ public:
const UTF8& GetLibItemName() const { return m_itemName; } const UTF8& GetLibItemName() const { return m_itemName; }
/** /**
* Get strings for display messages in dialogs.
*
* Equivalent to m_itemName.wx_str(), but more explicit when building a Unicode string
* in messages.
*
* @return the library item name, i.e. footprintName in a wxString (UTF16 or 32). * @return the library item name, i.e. footprintName in a wxString (UTF16 or 32).
* useful to display messages in dialogs
* Equivalent to m_itemName.wx_str(), but more explicit when building a Unicode string in messages.
*/ */
const wxString GetUniStringLibItemName() const { return m_itemName.wx_str(); } const wxString GetUniStringLibItemName() const { return m_itemName.wx_str(); }
@ -134,8 +137,7 @@ public:
/** /**
* @return the fully formatted text of the LIB_ID in a wxString (UTF16 or UTF32), * @return the fully formatted text of the LIB_ID in a wxString (UTF16 or UTF32),
* suitable to display the LIB_ID in dialogs. * suitable to display the LIB_ID in dialogs.
* Equivalent to Format().wx_str(), but more explicit when building a Unicode string in messages.
*/ */
wxString GetUniStringLibId() const wxString GetUniStringLibId() const
{ {
@ -152,13 +154,16 @@ public:
const UTF8& aRevision = "" ); const UTF8& aRevision = "" );
/** /**
* @return true is the #LIB_ID is valid. * Check if this LID_ID is valid.
* *
* A valid #LIB_ID must have both the library nickname and the library item name defined. * A valid #LIB_ID must have both the library nickname and the library item name defined.
* The revision field is optional. * The revision field is optional.
* *
* @note A return value of true does not indicated that the #LIB_ID is a valid #LIB_TABLE * @note A return value of true does not indicated that the #LIB_ID is a valid #LIB_TABLE
* entry. * entry.
*
* @return true is the #LIB_ID is valid.
*
*/ */
bool IsValid() const bool IsValid() const
{ {
@ -191,7 +196,6 @@ public:
* library nickname, library entry name, and revision strings respectively. * library nickname, library entry name, and revision strings respectively.
* *
* @param aLibId is the LIB_ID to compare against. * @param aLibId is the LIB_ID to compare against.
*
* @return -1 if less than \a aLibId, 1 if greater than \a aLibId, and 0 if equal to \a aLibId. * @return -1 if less than \a aLibId, 1 if greater than \a aLibId, and 0 if equal to \a aLibId.
*/ */
int compare( const LIB_ID& aLibId ) const; int compare( const LIB_ID& aLibId ) const;
@ -228,7 +232,7 @@ public:
protected: protected:
/** /**
* Tests whether a unicode character is a legal LIB_ID item name character. * Tests whether a Unicode character is a legal LIB_ID item name character.
* *
* The criteria for legal LIB_ID character is as follows: * The criteria for legal LIB_ID character is as follows:
* - For both symbol and footprint names, neither '/' or ':' are legal. They are * - For both symbol and footprint names, neither '/' or ':' are legal. They are
@ -247,16 +251,16 @@ protected:
* name is not the file name. * name is not the file name.
* *
* *
* @note @a aUniChar is expected to be a 32 bit unicode character, not a UTF8 char, that use * @note @a aUniChar is expected to be a 32 bit Unicode character, not a UTF8 char, that use
* a variable length coding value. * a variable length coding value.
*/ */
static bool isLegalChar( unsigned aUniChar ); static bool isLegalChar( unsigned aUniChar );
/** /**
* Tests whether a unicode character is a legal LIB_ID library nickname character * Tests whether a Unicode character is a legal LIB_ID library nickname character
* *
* @note @a aUniChar is expected to be a 32 bit unicode character, not a UTF8 char, that use * @note @a aUniChar is expected to be a 32 bit Unicode character, not a UTF8 char, that use
* a variable length coding value. * a variable length coding value.
*/ */
static bool isLegalLibraryNameChar( unsigned aUniChar ); static bool isLegalLibraryNameChar( unsigned aUniChar );

View File

@ -276,11 +276,7 @@ private:
*/ */
class LIB_TABLE : public PROJECT::_ELEM class LIB_TABLE : public PROJECT::_ELEM
{ {
friend class PANEL_FP_LIB_TABLE;
friend class LIB_TABLE_GRID;
public: public:
/** /**
* Parse the #LIB_TABLE_LEXER s-expression library table format into the appropriate * Parse the #LIB_TABLE_LEXER s-expression library table format into the appropriate
* #LIB_TABLE_ROW objects. * #LIB_TABLE_ROW objects.
@ -493,7 +489,6 @@ public:
static UTF8 FormatOptions( const PROPERTIES* aProperties ); static UTF8 FormatOptions( const PROPERTIES* aProperties );
protected: protected:
/** /**
* Return a #LIB_TABLE_ROW if \a aNickname is found in this table or in any chained * Return a #LIB_TABLE_ROW if \a aNickname is found in this table or in any chained
* fallBack table fragment, else NULL. * fallBack table fragment, else NULL.
@ -517,6 +512,11 @@ protected:
reindex(); reindex();
} }
private:
friend class PANEL_FP_LIB_TABLE;
friend class LIB_TABLE_GRID;
protected:
LIB_TABLE_ROWS rows; LIB_TABLE_ROWS rows;
/// this is a non-owning index into the LIB_TABLE_ROWS table /// this is a non-owning index into the LIB_TABLE_ROWS table

View File

@ -3,7 +3,7 @@
* *
* Copyright (C) 2017 Chris Pavlina <pavlina.chris@gmail.com> * Copyright (C) 2017 Chris Pavlina <pavlina.chris@gmail.com>
* Copyright (C) 2014 Henner Zeller <h.zeller@acm.org> * Copyright (C) 2014 Henner Zeller <h.zeller@acm.org>
* Copyright (C) 2014-2018 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2014-2020 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software: you can redistribute it and/or modify it * 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 * under the terms of the GNU General Public License as published by the
@ -75,37 +75,6 @@ class EDA_COMBINED_MATCHER;
class LIB_TREE_NODE class LIB_TREE_NODE
{ {
public: public:
enum TYPE {
ROOT, LIB, LIBID, UNIT, INVALID
};
typedef std::vector<std::unique_ptr<LIB_TREE_NODE>> PTR_VECTOR;
LIB_TREE_NODE* m_Parent; // Parent node or null
PTR_VECTOR m_Children; // List of child nodes
enum TYPE m_Type; // Node type
/**
* The rank of the item before any search terms are applied. This is
* a fairly expensive sort (involving string compares) so it helps to
* store the result of that sort.
*/
int m_IntrinsicRank;
int m_Score; // The score of an item resulting from the search algorithm.
bool m_Pinned; // Item should appear at top when there is no search string
wxString m_Name; // Actual name of the part
wxString m_Desc; // Description to be displayed
wxString m_MatchName; // Normalized name for matching
wxString m_SearchText; // Descriptive text to search
bool m_Normalized; // Support for lazy normalization.
LIB_ID m_LibId; // LIB_ID determined by the parent library nickname and alias name.
int m_Unit; // Actual unit, or zero
bool m_IsRoot; // Indicates if the symbol is a root symbol instead of an alias.
/** /**
* Update the score for this part. This is accumulative - it will be * Update the score for this part. This is accumulative - it will be
* called once per search term. * called once per search term.
@ -138,6 +107,37 @@ public:
LIB_TREE_NODE(); LIB_TREE_NODE();
virtual ~LIB_TREE_NODE() {} virtual ~LIB_TREE_NODE() {}
enum TYPE {
ROOT, LIB, LIBID, UNIT, INVALID
};
typedef std::vector<std::unique_ptr<LIB_TREE_NODE>> PTR_VECTOR;
LIB_TREE_NODE* m_Parent; // Parent node or null
PTR_VECTOR m_Children; // List of child nodes
enum TYPE m_Type; // Node type
/**
* The rank of the item before any search terms are applied. This is
* a fairly expensive sort (involving string compares) so it helps to
* store the result of that sort.
*/
int m_IntrinsicRank;
int m_Score; // The score of an item resulting from the search algorithm.
bool m_Pinned; // Item should appear at top when there is no search string
wxString m_Name; // Actual name of the part
wxString m_Desc; // Description to be displayed
wxString m_MatchName; // Normalized name for matching
wxString m_SearchText; // Descriptive text to search
bool m_Normalized; // Support for lazy normalization.
LIB_ID m_LibId; // LIB_ID determined by the parent library nickname and alias name.
int m_Unit; // Actual unit, or zero
bool m_IsRoot; // Indicates if the symbol is a root symbol instead of an alias.
}; };
@ -146,7 +146,6 @@ public:
*/ */
class LIB_TREE_NODE_UNIT: public LIB_TREE_NODE class LIB_TREE_NODE_UNIT: public LIB_TREE_NODE
{ {
public: public:
/** /**
* The addresses of CMP_TREE_NODEs are used as unique IDs for the * The addresses of CMP_TREE_NODEs are used as unique IDs for the
@ -155,7 +154,6 @@ public:
LIB_TREE_NODE_UNIT( LIB_TREE_NODE_UNIT const& _ ) = delete; LIB_TREE_NODE_UNIT( LIB_TREE_NODE_UNIT const& _ ) = delete;
void operator=( LIB_TREE_NODE_UNIT const& _ ) = delete; void operator=( LIB_TREE_NODE_UNIT const& _ ) = delete;
/** /**
* Construct a unit node. * Construct a unit node.
* *
@ -189,7 +187,6 @@ public:
LIB_TREE_NODE_LIB_ID( LIB_TREE_NODE_LIB_ID const& _ ) = delete; LIB_TREE_NODE_LIB_ID( LIB_TREE_NODE_LIB_ID const& _ ) = delete;
void operator=( LIB_TREE_NODE_LIB_ID const& _ ) = delete; void operator=( LIB_TREE_NODE_LIB_ID const& _ ) = delete;
/** /**
* Construct a #LIB_ID node. * Construct a #LIB_ID node.
* *
@ -237,7 +234,6 @@ public:
LIB_TREE_NODE_LIB( LIB_TREE_NODE_LIB const& _ ) = delete; LIB_TREE_NODE_LIB( LIB_TREE_NODE_LIB const& _ ) = delete;
void operator=( LIB_TREE_NODE_LIB const& _ ) = delete; void operator=( LIB_TREE_NODE_LIB const& _ ) = delete;
/** /**
* Construct an empty library node. * Construct an empty library node.
* *

View File

@ -271,8 +271,6 @@ protected:
static LIB_TREE_NODE* ToNode( wxDataViewItem aItem ); static LIB_TREE_NODE* ToNode( wxDataViewItem aItem );
static unsigned int IntoArray( LIB_TREE_NODE const& aNode, wxDataViewItemArray& aChildren ); static unsigned int IntoArray( LIB_TREE_NODE const& aNode, wxDataViewItemArray& aChildren );
LIB_TREE_NODE_ROOT m_tree;
/** /**
* Creates the adapter * Creates the adapter
* @param aParent is the parent frame * @param aParent is the parent frame
@ -331,7 +329,7 @@ protected:
* @param aItem item to get formatting for * @param aItem item to get formatting for
* @param aCol column number of interest * @param aCol column number of interest
* @param aAttr receiver for attributes * @param aAttr receiver for attributes
* @return true iff the item has non-default attributes * @return true if the item has non-default attributes
*/ */
bool GetAttr( wxDataViewItem const& aItem, bool GetAttr( wxDataViewItem const& aItem,
unsigned int aCol, unsigned int aCol,
@ -340,7 +338,7 @@ protected:
/** /**
* @return a unicode string to mark a node name like * @return a unicode string to mark a node name like
* a pinned library name * a pinned library name
* This is not an ascii7 char, but a unicode char * This is not an ASCII7 char, but a unicode char
*/ */
const wxString GetPinningSymbol() const const wxString GetPinningSymbol() const
{ {
@ -348,22 +346,6 @@ protected:
} }
private: private:
EDA_BASE_FRAME* m_parent;
CMP_FILTER_TYPE m_filter;
bool m_show_units;
LIB_ID m_preselect_lib_id;
int m_preselect_unit;
int m_freeze;
wxDataViewColumn* m_col_part;
wxDataViewColumn* m_col_desc;
wxDataViewCtrl* m_widget;
int m_colWidths[NUM_COLS];
wxArrayString m_pinnedLibs;
wxString m_pinnedKey;
/** /**
* Find any results worth highlighting and expand them, according to given criteria * Find any results worth highlighting and expand them, according to given criteria
* The highest-scoring node is written to aHighScore * The highest-scoring node is written to aHighScore
@ -385,6 +367,26 @@ private:
* Find and expand a library if there is only one. Return the best match (if any). * Find and expand a library if there is only one. Return the best match (if any).
*/ */
LIB_TREE_NODE* ShowSingleLibrary(); LIB_TREE_NODE* ShowSingleLibrary();
protected:
LIB_TREE_NODE_ROOT m_tree;
private:
EDA_BASE_FRAME* m_parent;
CMP_FILTER_TYPE m_filter;
bool m_show_units;
LIB_ID m_preselect_lib_id;
int m_preselect_unit;
int m_freeze;
wxDataViewColumn* m_col_part;
wxDataViewColumn* m_col_desc;
wxDataViewCtrl* m_widget;
int m_colWidths[NUM_COLS];
wxArrayString m_pinnedLibs;
wxString m_pinnedKey;
}; };
#endif // LIB_TREE_MODEL_ADAPTER_H #endif // LIB_TREE_MODEL_ADAPTER_H

View File

@ -1,7 +1,7 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * 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-2020 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -35,15 +35,13 @@
class wxSingleInstanceChecker; class wxSingleInstanceChecker;
/** /**
* Function LockFile * Test to see if \a aFileName can be locked (is not already locked) and only then
* tests to see if aFileName can be locked (is not already locked) and only then
* returns a wxSingleInstanceChecker protecting aFileName. * returns a wxSingleInstanceChecker protecting aFileName.
*/ */
std::unique_ptr<wxSingleInstanceChecker> LockFile( const wxString& aFileName ); std::unique_ptr<wxSingleInstanceChecker> LockFile( const wxString& aFileName );
/** /**
* Function GetKicadLockFilePath * @return A wxString containing the path for lockfiles in Kicad.
* @return A wxString containing the path for lockfiles in Kicad
*/ */
wxString GetKicadLockFilePath(); wxString GetKicadLockFilePath();

View File

@ -36,7 +36,8 @@ public:
} }
protected: protected:
void DoLogRecord( wxLogLevel aLevel, const wxString& aMsg, const wxLogRecordInfo& aInfo ) override void DoLogRecord( wxLogLevel aLevel, const wxString& aMsg,
const wxLogRecordInfo& aInfo ) override
{ {
// Only forward the message if it is a trace message // Only forward the message if it is a trace message
if( aLevel == wxLOG_Trace ) if( aLevel == wxLOG_Trace )

View File

@ -71,7 +71,7 @@
#define KI_FALLTHROUGH [[clang::fallthrough]] #define KI_FALLTHROUGH [[clang::fallthrough]]
#elif KI_HAS_CPP_ATTRIBUTE( gnu::fallthrough ) #elif KI_HAS_CPP_ATTRIBUTE( gnu::fallthrough )
// GNU-specific C++ attribute to sliencing the warning // GNU-specific C++ attribute to silencing the warning
#define KI_FALLTHROUGH [[gnu::fallthrough]] #define KI_FALLTHROUGH [[gnu::fallthrough]]
#elif defined( __GNUC__ ) && __GNUC__ >= 7 #elif defined( __GNUC__ ) && __GNUC__ >= 7
@ -85,17 +85,19 @@
#endif #endif
/** /**
* Macro TO_UTF8 * Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
* converts a wxString to a UTF8 encoded C string for all wxWidgets build modes. *
* wxstring is a wxString, not a wxT() or _(). The scope of the return value * wxstring is a wxString, not a wxT() or _(). The scope of the return value
* is very limited and volatile, but can be used with printf() style functions well. * is very limited and volatile, but can be used with printf() style functions well.
* NOTE: Trying to convert it to a function is tricky because of the *
* type of the parameter! * @note Trying to convert it to a function is tricky because of the type of the
* parameter!
*/ */
#define TO_UTF8( wxstring ) ( (const char*) (wxstring).utf8_str() ) #define TO_UTF8( wxstring ) ( (const char*) (wxstring).utf8_str() )
/** /**
* Stringifies the given parameter by placing in quotes * Stringifies the given parameter by placing in quotes.
*
* @param cstring STRING (no spaces) * @param cstring STRING (no spaces)
* @return "STRING" * @return "STRING"
*/ */
@ -103,8 +105,7 @@
#define TO_STR(x) TO_STR2(x) #define TO_STR(x) TO_STR2(x)
/** /**
* function FROM_UTF8 * Convert a UTF8 encoded C string to a wxString for all wxWidgets build modes.
* converts a UTF8 encoded C string to a wxString for all wxWidgets build modes.
*/ */
static inline wxString FROM_UTF8( const char* cstring ) static inline wxString FROM_UTF8( const char* cstring )
{ {

View File

@ -28,11 +28,11 @@
#define MAIL_TYPE_H_ #define MAIL_TYPE_H_
/** /**
* Enum MAIL_T * The set of mail types sendable via #KIWAY::ExpressMail() and supplied as
* is the set of mail types sendable via KIWAY::ExpressMail() and supplied as * the @a aCommand parameter to that function.
* the @a aCommand parameter to that function. Such mail will be received in *
* KIWAY_PLAYER::KiwayMailIn( KIWAY_EXPRESS& aEvent ) and aEvent.Command() will * Such mail will be received in KIWAY_PLAYER::KiwayMailIn( KIWAY_EXPRESS& aEvent ) and
* match aCommand to KIWAY::ExpressMail(). * aEvent.Command() will match aCommand to KIWAY::ExpressMail().
*/ */
enum MAIL_T enum MAIL_T
{ {

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2009-2014 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2009-2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2014 KiCad Developers, see CHANGELOG.TXT for contributors. * Copyright (C) 2009-2020 KiCad Developers, see CHANGELOG.TXT for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -46,8 +46,6 @@ using KIGFX::RENDER_SETTINGS;
/* /*
* Marker are mainly used to show a DRC or ERC error or warning * Marker are mainly used to show a DRC or ERC error or warning
*/ */
class MARKER_BASE class MARKER_BASE
{ {
public: public:
@ -58,50 +56,37 @@ public:
MARKER_SIMUL MARKER_SIMUL
}; };
wxPoint m_Pos; ///< position of the marker MARKER_BASE( int aScalingFactor, std::shared_ptr<RC_ITEM> aItem,
TYPEMARKER aType = MARKER_UNSPEC );
protected:
TYPEMARKER m_markerType; // The type of marker (useful to filter markers)
bool m_excluded; // User has excluded this specific error
std::shared_ptr<RC_ITEM> m_rcItem;
int m_scalingFactor; // Scaling factor to convert corners coordinates
// to internat units coordinates
EDA_RECT m_shapeBoundingBox; // Bounding box of the graphic symbol, relative
// to the position of the shape, in marker shape
// units
public:
MARKER_BASE( int aScalingFactor, std::shared_ptr<RC_ITEM> aItem, TYPEMARKER aType = MARKER_UNSPEC );
virtual ~MARKER_BASE(); virtual ~MARKER_BASE();
/** The scaling factor to convert polygonal shape coordinates to internal units /**
* The scaling factor to convert polygonal shape coordinates to internal units.
*/ */
int MarkerScale() const { return m_scalingFactor; } int MarkerScale() const { return m_scalingFactor; }
/** Returns the shape polygon in internal units in a SHAPE_LINE_CHAIN /**
* the coordinates are relatives to the marker position (are not absolute) * Return the shape polygon in internal units in a #SHAPE_LINE_CHAIN the coordinates
* @param aPolygon is the SHAPE_LINE_CHAIN to fill with the shape * are relatives to the marker position (are not absolute).
*
* @param aPolygon is the #SHAPE_LINE_CHAIN to fill with the shape.
*/ */
void ShapeToPolygon( SHAPE_LINE_CHAIN& aPolygon, int aScale = -1 ) const; void ShapeToPolygon( SHAPE_LINE_CHAIN& aPolygon, int aScale = -1 ) const;
/** /**
* Function PrintMarker * Print the shape is the polygon defined in m_Corners (array of wxPoints).
* Prints the shape is the polygon defined in m_Corners (array of wxPoints).
*/ */
void PrintMarker( RENDER_SETTINGS* aSettings, const wxPoint& aOffset ); void PrintMarker( RENDER_SETTINGS* aSettings, const wxPoint& aOffset );
/** /**
* Function GetPos * @return the position of this marker in internal units.
* @return the position of this MARKER in internal units.
*/ */
const wxPoint& GetPos() const { return m_Pos; } const wxPoint& GetPos() const { return m_Pos; }
virtual const KIID GetUUID() const = 0; virtual const KIID GetUUID() const = 0;
/** /**
* accessors to set/get marker type (DRC, ERC, or other) * Accessors to set/get marker type (DRC, ERC, or other)
*/ */
void SetMarkerType( enum TYPEMARKER aMarkerType ) { m_markerType = aMarkerType; } void SetMarkerType( enum TYPEMARKER aMarkerType ) { m_markerType = aMarkerType; }
enum TYPEMARKER GetMarkerType() const { return m_markerType; } enum TYPEMARKER GetMarkerType() const { return m_markerType; }
@ -110,25 +95,21 @@ public:
void SetExcluded( bool aExcluded ) { m_excluded = aExcluded; } void SetExcluded( bool aExcluded ) { m_excluded = aExcluded; }
/** /**
* Function GetReporter * @return the #RC_ITEM held within this marker so that its interface may be used.
* returns the DRC_ITEM held within this MARKER so that its
* interface may be used.
* @return const& DRC_ITEM
*/ */
// fixme: use shared_ptr
std::shared_ptr<RC_ITEM> GetRCItem() const { return m_rcItem; } std::shared_ptr<RC_ITEM> GetRCItem() const { return m_rcItem; }
/** /**
* Tests if the given wxPoint is within the bounds of this object. * Test if the given wxPoint is within the bounds of this object.
* @param aHitPosition is the wxPoint to test (in internal units) *
* @return bool - true if a hit, else false * @param aHitPosition is the wxPoint to test (in internal units).
* @return true if a hit, else false.
*/ */
bool HitTestMarker( const wxPoint& aHitPosition, int aAccuracy ) const; bool HitTestMarker( const wxPoint& aHitPosition, int aAccuracy ) const;
/** /**
* Function GetBoundingBoxMarker * Return the orthogonal, bounding box of this object for display purposes.
* returns the orthogonal, bounding box of this object for display purposes. *
* This box should be an enclosing perimeter for visible components of this * This box should be an enclosing perimeter for visible components of this
* object, and the units should be in the pcb or schematic coordinate system. * object, and the units should be in the pcb or schematic coordinate system.
* It is OK to overestimate the size by a few counts. * It is OK to overestimate the size by a few counts.
@ -137,6 +118,20 @@ public:
protected: protected:
virtual KIGFX::COLOR4D getColor() const = 0; virtual KIGFX::COLOR4D getColor() const = 0;
public:
wxPoint m_Pos; ///< position of the marker
protected:
TYPEMARKER m_markerType; // The type of marker (useful to filter markers)
bool m_excluded; // User has excluded this specific error
std::shared_ptr<RC_ITEM> m_rcItem;
int m_scalingFactor; // Scaling factor to convert corners coordinates
// to internal units coordinates
EDA_RECT m_shapeBoundingBox; // Bounding box of the graphic symbol, relative
// to the position of the shape, in marker shape
// units
}; };

View File

@ -1,7 +1,7 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2004-2017 KiCad Developers. * Copyright (C) 2004-2020 KiCad Developers.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -26,8 +26,7 @@
/** /**
* @file menus_helpers.h * @file menus_helpers.h
* @brief Usefull macros and inline functions to create menus items * @brief Macros and inline functions to create menus items in menubars or popup menus.
* in menubars or popup menus
*/ */
@ -41,36 +40,34 @@ class TOOL_INTERACTIVE;
void AddMenuLanguageList( ACTION_MENU* aMasterMenu, TOOL_INTERACTIVE* aControlTool ); void AddMenuLanguageList( ACTION_MENU* aMasterMenu, TOOL_INTERACTIVE* aControlTool );
/** /**
* Add a bitmap to a menuitem * Add a bitmap to a menuitem.
*
* It is added only if use images in menus config option allows it. For wxITEM_CHECK
* or wxITEM_RADIO menuitems, the bitmap is added only on Windows, other platforms do
* not support it
*
* @param aMenu is the menuitem. * @param aMenu is the menuitem.
* @param aImage is the icon to add to aMenu. * @param aImage is the icon to add to aMenu.
* It is added only if use images in menus config option allows it.
* For wxITEM_CHECK or wxITEM_RADIO menuitems, the bitmap is added only
* on Windows, other platforms do not support it
*/ */
void AddBitmapToMenuItem( wxMenuItem* aMenu, const wxBitmap& aImage ); void AddBitmapToMenuItem( wxMenuItem* aMenu, const wxBitmap& aImage );
/** /**
* Function AddMenuItem * Create and insert a menu item with an icon into \a aMenu.
* is an inline helper function to create and insert a menu item with an icon
* into \a aMenu
* *
* @param aMenu is the menu to add the new item. * @param aMenu is the menu to add the new item.
* @param aId is the command ID for the new menu item. * @param aId is the command ID for the new menu item.
* @param aText is the string for the new menu item. * @param aText is the string for the new menu item.
* @param aImage is the icon to add to the new menu item. * @param aImage is the icon to add to the new menu item.
* @param aType is the type of menu :wxITEM_NORMAL (default), wxITEM_CHECK ... * @param aType is the type of menu :wxITEM_NORMAL (default), wxITEM_CHECK ...
* @return a pointer to the new created wxMenuItem * @return a pointer to the new created wxMenuItem.
*/ */
wxMenuItem* AddMenuItem( wxMenu* aMenu, int aId, const wxString& aText, wxMenuItem* AddMenuItem( wxMenu* aMenu, int aId, const wxString& aText,
const wxBitmap& aImage, wxItemKind aType = wxITEM_NORMAL ); const wxBitmap& aImage, wxItemKind aType = wxITEM_NORMAL );
/** /**
* Function AddMenuItem * Create and insert a menu item with an icon and a help message string into \a aMenu.
* is an inline helper function to create and insert a menu item with an icon
* and a help message string into \a aMenu
* *
* @param aMenu is the menu to add the new item. * @param aMenu is the menu to add the new item.
* @param aId is the command ID for the new menu item. * @param aId is the command ID for the new menu item.
@ -78,33 +75,30 @@ wxMenuItem* AddMenuItem( wxMenu* aMenu, int aId, const wxString& aText,
* @param aHelpText is the help message string for the new menu item. * @param aHelpText is the help message string for the new menu item.
* @param aImage is the icon to add to the new menu item. * @param aImage is the icon to add to the new menu item.
* @param aType is the type of menu :wxITEM_NORMAL (default), wxITEM_CHECK ... * @param aType is the type of menu :wxITEM_NORMAL (default), wxITEM_CHECK ...
* @return a pointer to the new created wxMenuItem * @return a pointer to the new created wxMenuItem.
*/ */
wxMenuItem* AddMenuItem( wxMenu* aMenu, int aId, const wxString& aText, wxMenuItem* AddMenuItem( wxMenu* aMenu, int aId, const wxString& aText,
const wxString& aHelpText, const wxBitmap& aImage, const wxString& aHelpText, const wxBitmap& aImage,
wxItemKind aType = wxITEM_NORMAL ); wxItemKind aType = wxITEM_NORMAL );
/** /**
* Function AddMenuItem * Create and insert a menu item with an icon into \a aSubMenu in \a aMenu.
* is an inline helper function to create and insert a menu item with an icon
* into \a aSubMenu in \a aMenu
* *
* @param aMenu is the menu to add the new submenu item. * @param aMenu is the menu to add the new submenu item.
* @param aSubMenu is the submenu to add the new menu. * @param aSubMenu is the submenu to add the new menu.
* @param aId is the command ID for the new menu item. * @param aId is the command ID for the new menu item.
* @param aText is the string for the new menu item. * @param aText is the string for the new menu item.
* @param aImage is the icon to add to the new menu item. * @param aImage is the icon to add to the new menu item.
* @return a pointer to the new created wxMenuItem * @return a pointer to the new created wxMenuItem,
*/ */
wxMenuItem* AddMenuItem( wxMenu* aMenu, wxMenu* aSubMenu, int aId, wxMenuItem* AddMenuItem( wxMenu* aMenu, wxMenu* aSubMenu, int aId,
const wxString& aText, const wxBitmap& aImage ); const wxString& aText, const wxBitmap& aImage );
/** /**
* Function AddMenuItem * Create and insert a menu item with an icon and a help message string into
* is an inline helper function to create and insert a menu item with an icon * \a aSubMenu in \a aMenu.
* and a help message string into \a aSubMenu in \a aMenu
* *
* @param aMenu is the menu to add the new submenu item. * @param aMenu is the menu to add the new submenu item.
* @param aSubMenu is the submenu to add the new menu. * @param aSubMenu is the submenu to add the new menu.
@ -112,7 +106,7 @@ wxMenuItem* AddMenuItem( wxMenu* aMenu, wxMenu* aSubMenu, int aId,
* @param aText is the string for the new menu item. * @param aText is the string for the new menu item.
* @param aHelpText is the help message string for the new menu item. * @param aHelpText is the help message string for the new menu item.
* @param aImage is the icon to add to the new menu item. * @param aImage is the icon to add to the new menu item.
* @return a pointer to the new created wxMenuItem * @return a pointer to the new created wxMenuItem.
*/ */
wxMenuItem* AddMenuItem( wxMenu* aMenu, wxMenu* aSubMenu, int aId, wxMenuItem* AddMenuItem( wxMenu* aMenu, wxMenu* aSubMenu, int aId,
const wxString& aText, const wxString& aHelpText, const wxString& aText, const wxString& aHelpText,

View File

@ -2,6 +2,8 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright 2017 CERN * Copyright 2017 CERN
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
*
* @author Maciej Suminski <maciej.suminski@cern.ch> * @author Maciej Suminski <maciej.suminski@cern.ch>
* @author Bernhard Stegmaier <stegmaier@sw-systems.de> * @author Bernhard Stegmaier <stegmaier@sw-systems.de>
* *
@ -48,14 +50,16 @@ public:
* or to return data for the whole container. * or to return data for the whole container.
*/ */
static constexpr int UNDEFINED_TYPE = 0; static constexpr int UNDEFINED_TYPE = 0;
static_assert( FIRST_TYPE_VAL > UNDEFINED_TYPE, "FIRST_TYPE_VAL has to be greater than UNDEFINED_TYPE" ); static_assert( FIRST_TYPE_VAL > UNDEFINED_TYPE,
static_assert( FIRST_TYPE_VAL < LAST_TYPE_VAL, "FIRST_TYPE_VAL has to be greater than LAST_TYPE_VAL" ); "FIRST_TYPE_VAL has to be greater than UNDEFINED_TYPE" );
static_assert( FIRST_TYPE_VAL < LAST_TYPE_VAL,
"FIRST_TYPE_VAL has to be greater than LAST_TYPE_VAL" );
/** /**
* Helper for defining a list of library draw object pointers. The Boost * Helper for defining a list of library draw object pointers.
* pointer containers are responsible for deleting object pointers placed *
* in them. If you access a object pointer from the list, do not delete * The Boost pointer containers are responsible for deleting object pointers placed
* it directly. * in them. If you access a object pointer from the list, do not delete it directly.
*/ */
typedef boost::ptr_vector<T> ITEM_PTR_VECTOR; typedef boost::ptr_vector<T> ITEM_PTR_VECTOR;
@ -157,9 +161,11 @@ public:
}; };
///> The non-const iterator ///> The non-const iterator
typedef ITERATOR_BASE<T, MULTIVECTOR<T, FIRST_TYPE_VAL, LAST_TYPE_VAL>, typename ITEM_PTR_VECTOR::iterator> ITERATOR; typedef ITERATOR_BASE<T, MULTIVECTOR<T, FIRST_TYPE_VAL, LAST_TYPE_VAL>,
typename ITEM_PTR_VECTOR::iterator> ITERATOR;
///> The const iterator ///> The const iterator
typedef ITERATOR_BASE<const T, const MULTIVECTOR<T, FIRST_TYPE_VAL, LAST_TYPE_VAL>, typename ITEM_PTR_VECTOR::const_iterator> CONST_ITERATOR; typedef ITERATOR_BASE<const T, const MULTIVECTOR<T, FIRST_TYPE_VAL, LAST_TYPE_VAL>,
typename ITEM_PTR_VECTOR::const_iterator> CONST_ITERATOR;
MULTIVECTOR() MULTIVECTOR()

View File

@ -41,48 +41,17 @@ DECL_SET_FOR_SWIG( STRINGSET, wxString )
/** /**
* NETCLASS * A collection of nets and the parameters used to route or test these nets.
* handles a collection of nets and the parameters used to route or
* test these nets.
*/ */
class NETCLASS class NETCLASS
{ {
protected:
wxString m_Name; ///< Name of the net class
wxString m_Description; ///< what this NETCLASS is for.
STRINGSET m_Members; ///< names of NET members of this class
/// The units on these parameters is Internal Units (1 nm)
OPT<int> m_Clearance; ///< clearance when routing
OPT<int> m_TrackWidth; ///< track width used to route NETs in this NETCLASS
OPT<int> m_ViaDia; ///< via diameter
OPT<int> m_ViaDrill; ///< via drill hole diameter
OPT<int> m_uViaDia; ///< microvia diameter
OPT<int> m_uViaDrill; ///< microvia drill hole diameter
OPT<int> m_diffPairWidth;
OPT<int> m_diffPairGap;
OPT<int> m_diffPairViaGap;
int m_wireWidth;
int m_busWidth;
COLOR4D m_schematicColor;
int m_lineStyle;
COLOR4D m_PcbColor; ///< Optional color override for this netclass (PCB context)
public: public:
static const char Default[]; ///< the name of the default NETCLASS static const char Default[]; ///< the name of the default NETCLASS
/** /**
* Constructor * Create a NETCLASS instance with \a aName.
* stuffs a NETCLASS instance with aParent, aName, and optionally the initialParameters *
* @param aName = the name of this new netclass * @param aName is the name of this new netclass.
*/ */
NETCLASS( const wxString& aName ); NETCLASS( const wxString& aName );
@ -97,8 +66,7 @@ public:
void SetName( const wxString& aName ) { m_Name = aName; } void SetName( const wxString& aName ) { m_Name = aName; }
/** /**
* Function GetCount * Return the number of nets in this NETCLASS, i.e. using these rules.
* returns the number of nets in this NETCLASS, i.e. using these rules.
*/ */
unsigned GetCount() const unsigned GetCount() const
{ {
@ -106,8 +74,7 @@ public:
} }
/** /**
* Function Clear * Empties the collection of members.
* empties the collection of members.
*/ */
void Clear() void Clear()
{ {
@ -115,8 +82,8 @@ public:
} }
/** /**
* Function Add * Adds \a aNetname to this NETCLASS if it is not already in this NETCLASS.
* adds \a aNetname to this NETCLASS if it is not already in this NETCLASS. *
* It is harmless to try and add a second identical name. * It is harmless to try and add a second identical name.
*/ */
void Add( const wxString& aNetname ) void Add( const wxString& aNetname )
@ -133,8 +100,7 @@ public:
const_iterator end() const { return m_Members.end(); } const_iterator end() const { return m_Members.end(); }
/** /**
* Function Remove * Remove NET \a aName from the collection of members.
* will remove NET name \a aName from the collection of members.
*/ */
void Remove( iterator aName ) void Remove( iterator aName )
{ {
@ -142,8 +108,7 @@ public:
} }
/** /**
* Function Remove * Remove NET \a aName from the collection of members.
* will remove NET name \a aName from the collection of members.
*/ */
void Remove( const wxString& aName ) void Remove( const wxString& aName )
{ {
@ -209,6 +174,34 @@ public:
#if defined(DEBUG) #if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const; void Show( int nestLevel, std::ostream& os ) const;
#endif #endif
protected:
wxString m_Name; ///< Name of the net class
wxString m_Description; ///< what this NETCLASS is for.
STRINGSET m_Members; ///< names of NET members of this class
/// The units on these parameters is Internal Units (1 nm)
OPT<int> m_Clearance; ///< clearance when routing
OPT<int> m_TrackWidth; ///< track width used to route NETs in this NETCLASS
OPT<int> m_ViaDia; ///< via diameter
OPT<int> m_ViaDrill; ///< via drill hole diameter
OPT<int> m_uViaDia; ///< microvia diameter
OPT<int> m_uViaDrill; ///< microvia drill hole diameter
OPT<int> m_diffPairWidth;
OPT<int> m_diffPairGap;
OPT<int> m_diffPairViaGap;
int m_wireWidth;
int m_busWidth;
COLOR4D m_schematicColor;
int m_lineStyle;
COLOR4D m_PcbColor; ///< Optional color override for this netclass (PCB context)
}; };
@ -217,24 +210,20 @@ DECL_MAP_FOR_SWIG( NETCLASS_MAP, wxString, NETCLASSPTR )
/** /**
* NETCLASSES * A container for NETCLASS instances.
* is a container for NETCLASS instances. It owns all its NETCLASSes. This container will *
* always have a default NETCLASS with the name given by const NETCLASS::Default. * It owns all its NETCLASSes. This container will always have a default NETCLASS with the
* name given by const NETCLASS::Default.
*/ */
class NETCLASSES class NETCLASSES
{ {
private:
NETCLASS_MAP m_NetClasses; // All the netclasses EXCEPT the default one
NETCLASSPTR m_default;
public: public:
NETCLASSES(); NETCLASSES();
~NETCLASSES(); ~NETCLASSES();
/** /**
* Function Clear * Destroy any contained NETCLASS instances except the default one, and clears any
* destroys any contained NETCLASS instances except the Default one, and clears any * members from the default one.
* members from the Default one.
*/ */
void Clear() void Clear()
{ {
@ -251,8 +240,7 @@ public:
const_iterator end() const { return m_NetClasses.end(); } const_iterator end() const { return m_NetClasses.end(); }
/** /**
* Function GetCount * @return the number of netclasses excluding the default one.
* @return the number of netclasses, excluding the default one.
*/ */
unsigned GetCount() const unsigned GetCount() const
{ {
@ -260,7 +248,6 @@ public:
} }
/** /**
* Function GetDefault
* @return the default net class. * @return the default net class.
*/ */
NETCLASSPTR GetDefault() const NETCLASSPTR GetDefault() const
@ -274,32 +261,37 @@ public:
} }
/** /**
* Function Add * Add \a aNetclass and puts it into this NETCLASSES container.
* takes \a aNetclass and puts it into this NETCLASSES container. *
* @param aNetclass is netclass to add * @param aNetclass is netclass to add
* @return true if the name within aNetclass is unique and it could be inserted OK, * @return true if the name within aNetclass is unique and it could be inserted OK,
* else false because the name was not unique. * else false because the name was not unique.
*/ */
bool Add( const NETCLASSPTR& aNetclass ); bool Add( const NETCLASSPTR& aNetclass );
/** /**
* Function Remove * Remove a #NETCLASS from this container but does not destroy/delete it.
* removes a NETCLASS from this container but does not destroy/delete it. *
* @param aNetName is the name of the net to delete, and it may not be NETCLASS::Default. * @param aNetName is the name of the net to delete, and it may not be NETCLASS::Default.
* @return NETCLASSPTR - the NETCLASS associated with aNetName if found and removed, else NULL. * @return a pointer to the #NETCLASS associated with \a aNetName if found and removed,
* else NULL.
*/ */
NETCLASSPTR Remove( const wxString& aNetName ); NETCLASSPTR Remove( const wxString& aNetName );
/** /**
* Function Find * Search this container for a NETCLASS given by \a aName.
* searches this container for a NETCLASS given by \a aName. *
* @param aName is the name of the NETCLASS to search for. * @param aName is the name of the #NETCLASS to search for.
* @return NETCLASSPTR - if found, else NULL. * @return a pointer to the #NETCLASS if found, else NULL.
*/ */
NETCLASSPTR Find( const wxString& aName ) const; NETCLASSPTR Find( const wxString& aName ) const;
/// Provide public access to m_NetClasses so it gets swigged. /// Provide public access to m_NetClasses so it gets swigged.
NETCLASS_MAP& NetClasses() { return m_NetClasses; } NETCLASS_MAP& NetClasses() { return m_NetClasses; }
private:
NETCLASS_MAP m_NetClasses; // All the netclasses EXCEPT the default one
NETCLASSPTR m_default;
}; };
#endif // CLASS_NETCLASS_H #endif // CLASS_NETCLASS_H

View File

@ -1,7 +1,7 @@
/* /*
* This program source code file is part of KICAD, a free EDA CAD application. * This program source code file is part of KICAD, a free EDA CAD application.
* *
* Copyright (C) 2016 Kicad Developers, see change_log.txt for contributors. * Copyright (C) 2016-20 Kicad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -29,224 +29,223 @@
#include <vector> #include <vector>
#include <utility> #include <utility>
/* /**
model subscriber implementation using links to represent connections. * A model subscriber implementation using links to represent connections. Subscribers
subscribers can be removed during notification. * can be removed during notification. If no observers are registered, size is the size
if no observers are registered, size is the size of a shared_ptr. * of a shared_ptr.
*/ */
namespace UTIL
{
class LINK;
namespace UTIL { namespace DETAIL
{
struct OBSERVABLE_BASE
{
public:
OBSERVABLE_BASE();
OBSERVABLE_BASE( OBSERVABLE_BASE& other );
class LINK; ~OBSERVABLE_BASE();
namespace DETAIL { size_t size() const;
struct OBSERVABLE_BASE { private:
public: friend class UTIL::LINK;
OBSERVABLE_BASE();
OBSERVABLE_BASE( OBSERVABLE_BASE& other );
~OBSERVABLE_BASE(); struct IMPL
{
IMPL( OBSERVABLE_BASE* owned_by = nullptr );
bool is_shared() const;
void set_shared();
~IMPL();
size_t size() const; void add_observer( void* observer );
void remove_observer( void* observer );
void collect();
private: bool is_iterating() const;
friend class UTIL::LINK;
struct IMPL
{
IMPL( OBSERVABLE_BASE* owned_by = nullptr );
bool is_shared() const;
void set_shared();
~IMPL();
void add_observer( void* observer );
void remove_observer( void* observer );
void collect();
bool is_iterating() const;
void enter_iteration();
void leave_iteration();
std::vector<void*> observers_;
unsigned int iteration_count_;
OBSERVABLE_BASE* owned_by_;
};
void allocate_impl();
void allocate_shared_impl();
void deallocate_impl();
std::shared_ptr<IMPL> get_shared_impl();
protected:
void on_observers_empty();
void enter_iteration(); void enter_iteration();
void leave_iteration(); void leave_iteration();
void add_observer( void* observer ); std::vector<void*> observers_;
void remove_observer( void* observer ); unsigned int iteration_count_;
OBSERVABLE_BASE* owned_by_;
std::shared_ptr<IMPL> impl_;
}; };
void allocate_impl();
void allocate_shared_impl();
void deallocate_impl();
std::shared_ptr<IMPL> get_shared_impl();
protected:
void on_observers_empty();
void enter_iteration();
void leave_iteration();
void add_observer( void* observer );
void remove_observer( void* observer );
std::shared_ptr<IMPL> impl_;
};
} // namespace DETAIL
/**
* Simple RAII-handle to a subscription.
*/
class LINK
{
public:
LINK();
LINK( std::shared_ptr<DETAIL::OBSERVABLE_BASE::IMPL> token, void* observer );
LINK( LINK&& other );
LINK( const LINK& ) = delete;
void operator=( const LINK& ) = delete;
LINK& operator=( LINK&& other );
void reset();
explicit operator bool() const;
~LINK();
private:
std::shared_ptr<DETAIL::OBSERVABLE_BASE::IMPL> token_;
void* observer_;
};
template <typename ObserverInterface>
class OBSERVABLE : public DETAIL::OBSERVABLE_BASE
{
public:
/**
* Construct an observable with empty non-shared subscription list.
*/
OBSERVABLE() {}
/**
* Construct an observable with a shared subscription list.
*
* @param aInherit Observable to share the subscription list with.
*/
OBSERVABLE( OBSERVABLE& aInherit ) : OBSERVABLE_BASE( aInherit ) {}
/**
* Add a subscription without RAII link.
*
* @param aObserver Observer to subscribe.
*/
void SubscribeUnmanaged( ObserverInterface* aObserver )
{
OBSERVABLE_BASE::add_observer( static_cast<void*>( aObserver ) );
} }
// /**
// Simple RAII-handle to a subscription. * Add a subscription returning an RAII link.
// *
class LINK { * @param aObserver observer to subscribe
public: * @return RAII link controlling the lifetime of the subscription
LINK(); */
LINK( std::shared_ptr<DETAIL::OBSERVABLE_BASE::IMPL> token, void* observer ); LINK Subscribe( ObserverInterface* aObserver )
LINK( LINK&& other );
LINK( const LINK& ) = delete;
void operator=( const LINK& ) = delete;
LINK& operator=( LINK&& other );
void reset();
explicit operator bool() const;
~LINK();
private:
std::shared_ptr<DETAIL::OBSERVABLE_BASE::IMPL> token_;
void* observer_;
};
//
//
//
template<typename ObserverInterface>
class OBSERVABLE :
public DETAIL::OBSERVABLE_BASE
{ {
public: OBSERVABLE_BASE::add_observer( static_cast<void*>( aObserver ) );
/** return LINK( impl_, static_cast<void*>( aObserver ) );
* Function Observable() }
* Constructor. Constructs an observable with empty non-shared subscription list.
*/
OBSERVABLE() {}
/** /**
* Function Observable(OBSERVABLE&) * Cancel the subscription of a subscriber.
* Constructor. Constructs an observable with a shared subscription list. *
* @param aInherit Observable to share the subscription list with. * This can be called during notification calls.
*/ *
OBSERVABLE( OBSERVABLE& aInherit ) * @param aObserver observer to remove from the subscription list.
: OBSERVABLE_BASE( aInherit ) */
{} void Unsubscribe( ObserverInterface* aObserver )
{
OBSERVABLE_BASE::remove_observer( static_cast<void*>( aObserver ) );
}
/** /**
* Function SubscribeUnmanaged * Notify event to all subscribed observers.
* adds a subscription without RAII link. *
* @param aObserver Observer to subscribe * @param Ptr is a pointer to method of the observer interface.
*/ * @param aArgs is a list of arguments to each notification call, will be perfectly forwarded.
void SubscribeUnmanaged( ObserverInterface* aObserver ) */
template <typename... Args1, typename... Args2>
void Notify( void ( ObserverInterface::*Ptr )( Args1... ), Args2&&... aArgs )
{
static_assert( sizeof...( Args1 ) == sizeof...( Args2 ), "argument counts don't match" );
if( impl_ )
{ {
OBSERVABLE_BASE::add_observer( static_cast<void*>(aObserver) ); enter_iteration();
} try
/**
* Function Subscribe
* adds a subscription returning an RAII link
* @param aObserver observer to subscribe
* @return RAII link controlling the lifetime of the subscription
*/
LINK Subscribe( ObserverInterface* aObserver ) {
OBSERVABLE_BASE::add_observer( static_cast<void*>(aObserver) );
return LINK( impl_, static_cast<void*>(aObserver) );
}
/**
* Function Unsubscribe
* cancels the subscription of a subscriber. Can be called during notification calls.
* @param aObserver observer to remove from the subscription list
*/
void Unsubscribe( ObserverInterface* aObserver )
{
OBSERVABLE_BASE::remove_observer( static_cast<void*>(aObserver) );
}
/**
* Function Notify
* Notifies event to all subscribed observers.
* @param Ptr pointer to method of the Observer-interface
* @param aArgs list of arguments to each notification call, will be perfectly forwarded.
*/
template< typename... Args1, typename... Args2 >
void Notify( void(ObserverInterface::*Ptr)(Args1...), Args2&&... aArgs )
{
static_assert(sizeof...(Args1) == sizeof...(Args2), "argument counts don't match");
if( impl_ )
{ {
enter_iteration(); for( auto* void_ptr : impl_->observers_ )
try { {
for( auto* void_ptr : impl_->observers_ ) if( void_ptr )
{ {
if( void_ptr ) auto* typed_ptr = static_cast<ObserverInterface*>( void_ptr );
{ ( typed_ptr->*Ptr )( std::forward<Args2>( aArgs )... );
auto* typed_ptr = static_cast<ObserverInterface*>(void_ptr);
(typed_ptr->*Ptr)(std::forward<Args2>( aArgs )...);
}
} }
} }
catch(...)
{
leave_iteration();
throw;
}
leave_iteration();
} }
} catch( ... )
/**
* Function Notify
* Notifies event to all subscribed observers but one to be ignore.
* @param Ptr pointer to method of the Observer-interface
* @param aIgnore observer to ignore during this notification
* @param aArgs list of arguments to each notification call, will be perfectly forwarded.
*/
template< typename... Args1, typename... Args2 >
void NotifyIgnore( void(ObserverInterface::*Ptr)(Args1...), ObserverInterface* aIgnore,
Args2&&... aArgs )
{
static_assert(sizeof...(Args1) == sizeof...(Args2), "argument counts don't match");
if( impl_ )
{ {
enter_iteration(); leave_iteration();
throw;
}
try leave_iteration();
}
}
/**
* Notify event to all subscribed observers but one to be ignore.
*
* @param Ptr is a pointer to method of the observer interface.
* @param aIgnore is an observer to ignore during this notification.
* @param aArgs is a list of arguments to each notification call, will be perfectly forwarded.
*/
template <typename... Args1, typename... Args2>
void NotifyIgnore( void ( ObserverInterface::*Ptr )( Args1... ), ObserverInterface* aIgnore,
Args2&&... aArgs )
{
static_assert( sizeof...( Args1 ) == sizeof...( Args2 ), "argument counts don't match" );
if( impl_ )
{
enter_iteration();
try
{
for( auto* void_ptr : impl_->observers_ )
{ {
for(auto* void_ptr : impl_->observers_) if( void_ptr && void_ptr != aIgnore )
{ {
if( void_ptr && void_ptr != aIgnore ) auto* typed_ptr = static_cast<ObserverInterface*>( void_ptr );
{ ( typed_ptr->*Ptr )( std::forward<Args2>( aArgs )... );
auto* typed_ptr = static_cast<ObserverInterface*>(void_ptr);
(typed_ptr->*Ptr)(std::forward<Args2>( aArgs )...);
}
} }
} }
catch(...)
{
leave_iteration();
throw;
}
leave_iteration();
} }
catch( ... )
{
leave_iteration();
throw;
}
leave_iteration();
} }
}
};
}; } // namespace UTIL
}
#endif #endif

View File

@ -36,7 +36,8 @@
* The functions are templated to allow use with any size scalar * The functions are templated to allow use with any size scalar
* parameter: an int, a long long int, or a double. * parameter: an int, a long long int, or a double.
*/ */
class ORIGIN_TRANSFORMS { class ORIGIN_TRANSFORMS
{
public: public:
/** /**
* The supported Display Origin Transform types * The supported Display Origin Transform types
@ -52,14 +53,10 @@ public:
REL_Y_COORD, //< A relative Y coordinate REL_Y_COORD, //< A relative Y coordinate
}; };
public:
ORIGIN_TRANSFORMS(); ORIGIN_TRANSFORMS();
virtual ~ORIGIN_TRANSFORMS(); virtual ~ORIGIN_TRANSFORMS();
// =============== Single-axis Transforms ===============
virtual int ToDisplay( int aValue, virtual int ToDisplay( int aValue,
COORD_TYPES_T aCoordType ) const; COORD_TYPES_T aCoordType ) const;
@ -79,8 +76,6 @@ public:
COORD_TYPES_T aCoordType ) const; COORD_TYPES_T aCoordType ) const;
// =============== Two-axis Transforms ===============
template<class T> template<class T>
T ToDisplayAbs( const T& aValue ) const T ToDisplayAbs( const T& aValue ) const
{ {
@ -124,9 +119,6 @@ public:
protected: protected:
// =============== Generic Relative Transforms ===============
template<class T> inline static template<class T> inline static
T ToDisplayRel( T aInternalValue, T ToDisplayRel( T aInternalValue,
bool aInvertAxis ) bool aInvertAxis )
@ -154,9 +146,6 @@ protected:
return internalValue; return internalValue;
} }
// =============== Generic Absolute Transforms ===============
template<class T> inline static template<class T> inline static
T ToDisplayAbs( T aInternalValue, T ToDisplayAbs( T aInternalValue,
int aUserOrigin, int aUserOrigin,

View File

@ -34,8 +34,6 @@
class EDA_ITEM; class EDA_ITEM;
/** /**
* ORIGIN_VIEWITEM
*
* View item to draw an origin marker. * View item to draw an origin marker.
*/ */
namespace KIGFX { namespace KIGFX {
@ -73,8 +71,10 @@ public:
} }
#endif #endif
/** Get class name /**
* @return string "ORIGIN_VIEWITEM" * Get class name.
*
* @return string "ORIGIN_VIEWITEM"
*/ */
wxString GetClass() const override wxString GetClass() const override
{ {
@ -82,10 +82,12 @@ public:
} }
/** /**
* Function SetDrawAtZero() * Set the draw at zero flag.
* Set the draw at zero flag. When set the marker will be drawn when it's position is 0,0. *
* Otherwise it will not be drawn when its position is 0,0 * When set the marker will be drawn when it's position is 0,0. Otherwise it will not
* @param aDrawFlag The value to set the draw at zero flag * be drawn when its position is 0,0.
*
* @param aDrawFlag The value to set the draw at zero flag.
*/ */
inline void SetDrawAtZero( bool aDrawFlag ) inline void SetDrawAtZero( bool aDrawFlag )
{ {

View File

@ -1,7 +1,7 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 1992-2016 KiCad Developers, see CHANGELOG.TXT for contributors. * Copyright (C) 1992-2020 KiCad Developers, see CHANGELOG.TXT for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -27,8 +27,7 @@
#include <string> #include <string>
/** /**
* Enum PAD_SHAPE_T * The set of pad shapes, used with PAD::{Set,Get}Shape()
* is the set of pad shapes, used with PAD::{Set,Get}Shape()
*/ */
enum PAD_SHAPE_T enum PAD_SHAPE_T
{ {
@ -37,9 +36,11 @@ enum PAD_SHAPE_T
PAD_SHAPE_OVAL, PAD_SHAPE_OVAL,
PAD_SHAPE_TRAPEZOID, PAD_SHAPE_TRAPEZOID,
PAD_SHAPE_ROUNDRECT, PAD_SHAPE_ROUNDRECT,
PAD_SHAPE_CHAMFERED_RECT, // Rectangle with a champered corner ( and with rounded other corners)
// Rectangle with a chamfered corner ( and with rounded other corners).
PAD_SHAPE_CHAMFERED_RECT,
PAD_SHAPE_CUSTOM // A shape defined by user, using a set of basic shapes PAD_SHAPE_CUSTOM // A shape defined by user, using a set of basic shapes
// (thick segments, circles, arcs, polygons // (thick segments, circles, arcs, polygons.
}; };
static inline std::string PAD_SHAPE_T_asString( PAD_SHAPE_T a ) static inline std::string PAD_SHAPE_T_asString( PAD_SHAPE_T a )
@ -60,8 +61,7 @@ static inline std::string PAD_SHAPE_T_asString( PAD_SHAPE_T a )
/** /**
* Enum PAD_DRILL_SHAPE_T * The set of pad drill shapes, used with PAD::{Set,Get}DrillShape()
* is the set of pad drill shapes, used with PAD::{Set,Get}DrillShape()
*/ */
enum PAD_DRILL_SHAPE_T enum PAD_DRILL_SHAPE_T
{ {
@ -71,8 +71,8 @@ enum PAD_DRILL_SHAPE_T
/** /**
* Enum PAD_ATTR_T * The set of pad shapes, used with PAD::{Set,Get}Attribute().
* is the set of pad shapes, used with PAD::{Set,Get}Attribute() *
* The double name is for convenience of Python devs * The double name is for convenience of Python devs
*/ */
enum PAD_ATTR_T enum PAD_ATTR_T
@ -88,9 +88,8 @@ enum PAD_ATTR_T
/** /**
* Enum PAD_PROP_T * Ghe set of pad properties used in Gerber files (Draw files, and P&P files)
* is the set of pad properties used in Gerber files (Draw files, and P&P files) * to define some properties in fabrication or test files.
* to define some properties in fabrication or test files
*/ */
enum PAD_PROP_T enum PAD_PROP_T
{ {

View File

@ -2,8 +2,8 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2007-2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2007-2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2008-2013 Wayne Stambaugh <stambaughw@verizon.net> * Copyright (C) 2008-2013 Wayne Stambaugh <stambaughw@gmail.com>
* Copyright (C) 1992-2013 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2007-2020 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -42,19 +42,17 @@
/** /**
* PAGE_INFO * Describe the page size and margins of a paper page on which to eventually print or plot.
* describes the page size and margins of a paper page on which to *
* eventually print or plot. Paper sizes are often described in inches. * Paper sizes are often described in inches. Here paper is described in 1/1000th of an
* Here paper is described in 1/1000th of an inch (mils). For convenience * inch (mils). For convenience there are some read only accessors for internal units
* there are some read only accessors for internal units (IU), which is a compile * which is a compile time calculation, not runtime.
* time calculation, not runtime.
* *
* @author Dick Hollenbeck * @author Dick Hollenbeck
*/ */
class PAGE_INFO class PAGE_INFO
{ {
public: public:
PAGE_INFO( const wxString& aType = PAGE_INFO::A3, bool IsPortrait = false ); PAGE_INFO( const wxString& aType = PAGE_INFO::A3, bool IsPortrait = false );
// paper size names which are part of the public API, pass to SetType() or // paper size names which are part of the public API, pass to SetType() or
@ -80,9 +78,8 @@ public:
/** /**
* Function SetType * Set the name of the page type and also the sizes and margins commonly associated with
* sets the name of the page type and also the sizes and margins * that type name.
* commonly associated with that type name.
* *
* @param aStandardPageDescriptionName is a wxString constant giving one of: * @param aStandardPageDescriptionName is a wxString constant giving one of:
* "A5" "A4" "A3" "A2" "A1" "A0" "A" "B" "C" "D" "E" "GERBER", "USLetter", "USLegal", * "A5" "A4" "A3" "A2" "A1" "A0" "A" "B" "C" "D" "E" "GERBER", "USLetter", "USLegal",
@ -91,46 +88,41 @@ public:
* static PAGE_INFO::SetUserWidthMils() and * static PAGE_INFO::SetUserWidthMils() and
* static PAGE_INFO::SetUserHeightMils(); * static PAGE_INFO::SetUserHeightMils();
* @param aIsPortrait Set to true to set page orientation to portrait mode. * @param aIsPortrait Set to true to set page orientation to portrait mode.
* * @return true if @a aStandarePageDescription was a recognized type.
* @return bool - true if @a aStandarePageDescription was a recognized type.
*/ */
bool SetType( const wxString& aStandardPageDescriptionName, bool aIsPortrait = false ); bool SetType( const wxString& aStandardPageDescriptionName, bool aIsPortrait = false );
const wxString& GetType() const { return m_type; } const wxString& GetType() const { return m_type; }
/** /**
* Function IsDefault
* @return True if the object has the default page settings which are A3, landscape. * @return True if the object has the default page settings which are A3, landscape.
*/ */
bool IsDefault() const { return m_type == PAGE_INFO::A3 && !m_portrait; } bool IsDefault() const { return m_type == PAGE_INFO::A3 && !m_portrait; }
/** /**
* Function IsCustom * @return true if the type is Custom.
* returns true if the type is Custom
*/ */
bool IsCustom() const; bool IsCustom() const;
/** /**
* Function SetPortrait * Rotate the paper page 90 degrees.
* will rotate the paper page 90 degrees. This PAGE_INFO may either be in *
* portrait or landscape mode. Use this function to change from one to the * This PAGE_INFO may either be in portrait or landscape mode. Use this function to
* other mode. * change from one mode to the other mode.
* @param aIsPortrait if true and not already in portrait mode, will change *
* this PAGE_INFO to portrait mode. Or if false and not already in landscape mode, * @param aIsPortrait if true and not already in portrait mode, will change this
* will change this PAGE_INFO to landscape mode. * PAGE_INFO to portrait mode. Or if false and not already in
* landscape mode, will change this PAGE_INFO to landscape mode.
*/ */
void SetPortrait( bool aIsPortrait ); void SetPortrait( bool aIsPortrait );
bool IsPortrait() const { return m_portrait; } bool IsPortrait() const { return m_portrait; }
/** /**
* Function GetWxOrientation.
* @return ws' style printing orientation (wxPORTRAIT or wxLANDSCAPE). * @return ws' style printing orientation (wxPORTRAIT or wxLANDSCAPE).
*/ */
wxPrintOrientation GetWxOrientation() const { return IsPortrait() ? wxPORTRAIT : wxLANDSCAPE; } wxPrintOrientation GetWxOrientation() const { return IsPortrait() ? wxPORTRAIT : wxLANDSCAPE; }
/** /**
* Function GetPaperId * @return wxPrintData's style paper id associated with page type name.
* @return wxPaperSize - wxPrintData's style paper id associated with
* page type name.
*/ */
wxPaperSize GetPaperId() const { return m_paper_id; } wxPaperSize GetPaperId() const { return m_paper_id; }
@ -151,40 +143,29 @@ public:
#endif #endif
/** /**
* Function SetCustomWidthMils * Set the width of Custom page in mils for any custom page constructed or made via
* sets the width of Custom page in mils, for any custom page * SetType() after making this call.
* constructed or made via SetType() after making this call.
*/ */
static void SetCustomWidthMils( int aWidthInMils ); static void SetCustomWidthMils( int aWidthInMils );
/** /**
* Function SetCustomHeightMils * Set the height of Custom page in mils for any custom page constructed or made via
* sets the height of Custom page in mils, for any custom page * SetType() after making this call.
* constructed or made via SetType() after making this call.
*/ */
static void SetCustomHeightMils( int aHeightInMils ); static void SetCustomHeightMils( int aHeightInMils );
/** /**
* Function GetCustomWidthMils. * @return custom paper width in mils.
* @return int - custom paper width in mils.
*/ */
static int GetCustomWidthMils() { return s_user_width; } static int GetCustomWidthMils() { return s_user_width; }
/** /**
* Function GetCustomHeightMils. * @return custom paper height in mils.
* @return int - custom paper height in mils.
*/ */
static int GetCustomHeightMils() { return s_user_height; } static int GetCustomHeightMils() { return s_user_height; }
/** /**
* Function GetStandardSizes * Output the page class to \a aFormatter in s-expression form.
* returns the standard page types, such as "A4", "A3", etc.
static wxArrayString GetStandardSizes();
*/
/**
* Function Format
* outputs the page class to \a aFormatter in s-expression form.
* *
* @param aFormatter The #OUTPUTFORMATTER object to write to. * @param aFormatter The #OUTPUTFORMATTER object to write to.
* @param aNestLevel The indentation next level. * @param aNestLevel The indentation next level.
@ -197,9 +178,7 @@ protected:
// only the class implementation(s) may use this constructor // only the class implementation(s) may use this constructor
PAGE_INFO( const wxSize& aSizeMils, const wxString& aName, wxPaperSize aPaperId ); PAGE_INFO( const wxSize& aSizeMils, const wxString& aName, wxPaperSize aPaperId );
private: private:
// standard pre-defined sizes // standard pre-defined sizes
static const PAGE_INFO pageA5; static const PAGE_INFO pageA5;
static const PAGE_INFO pageA4; static const PAGE_INFO pageA4;

View File

@ -3,6 +3,8 @@
* *
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2013 CERN * Copyright (C) 2013 CERN
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
*
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch> * @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
* @author Maciej Suminski <maciej.suminski@cern.ch> * @author Maciej Suminski <maciej.suminski@cern.ch>
* *
@ -43,35 +45,31 @@ class GAL;
class VIEW_ITEM; class VIEW_ITEM;
/** /**
* PAINTER * Contains all the knowledge about how to draw graphical object onto any particular
* contains all the knowledge about how to draw graphical object onto * output device.
* any particular output device. *
* This knowledge is held outside the individual graphical objects so that * This knowledge is held outside the individual graphical objects so that alternative
* alternative output devices may be used, and so that the graphical objects * output devices may be used, and so that the graphical objects themselves to not
* themselves to not contain drawing routines. Drawing routines in the objects * contain drawing routines. Drawing routines in the objects cause problems with usages
* cause problems with usages of the objects as simple container objects in * of the objects as simple container objects in DLL/DSOs. PAINTER is an abstract layer
* DLL/DSOs. * because every module (pcbnew, eeschema, etc.) has to draw different kinds of objects.
* PAINTER is an abstract layer, because every module (pcbnew, eeschema, etc.)
* has to draw different kinds of objects.
*/ */
class PAINTER class PAINTER
{ {
public: public:
/** /**
* Constructor PAINTER( GAL* ) * Initialize this object for painting on any of the polymorphic
* initializes this object for painting on any of the polymorphic
* GRAPHICS_ABSTRACTION_LAYER* derivatives. * GRAPHICS_ABSTRACTION_LAYER* derivatives.
* *
* @param aGal is a pointer to a polymorphic GAL device on which * @param aGal is a pointer to a polymorphic GAL device on which to draw (i.e. Cairo,
* to draw (i.e. Cairo, OpenGL, wxDC) * OpenGL, wxDC). No ownership is given to this PAINTER of aGal.
* No ownership is given to this PAINTER of aGal.
*/ */
PAINTER( GAL* aGal ); PAINTER( GAL* aGal );
virtual ~PAINTER(); virtual ~PAINTER();
/** /**
* Function SetGAL
* Changes Graphics Abstraction Layer used for drawing items for a new one. * Changes Graphics Abstraction Layer used for drawing items for a new one.
*
* @param aGal is the new GAL instance. * @param aGal is the new GAL instance.
*/ */
void SetGAL( GAL* aGal ) void SetGAL( GAL* aGal )
@ -80,26 +78,27 @@ public:
} }
/** /**
* Function ApplySettings
* Loads colors and display modes settings that are going to be used when drawing items. * Loads colors and display modes settings that are going to be used when drawing items.
*
* @param aSettings are settings to be applied. * @param aSettings are settings to be applied.
*/ */
virtual void ApplySettings( const RENDER_SETTINGS* aSettings ) = 0; virtual void ApplySettings( const RENDER_SETTINGS* aSettings ) = 0;
/** /**
* Function GetAdapter * Return a pointer to current settings that are going to be used when drawing items.
* Returns pointer to current settings that are going to be used when drawing items. *
* @return Current rendering settings. * @return Current rendering settings.
*/ */
virtual RENDER_SETTINGS* GetSettings() = 0; virtual RENDER_SETTINGS* GetSettings() = 0;
/** /**
* Function Draw * Takes an instance of VIEW_ITEM and passes it to a function that knows how to draw
* Takes an instance of VIEW_ITEM and passes it to a function that know how to draw the item. * the item.
*
* @param aItem is an item to be drawn. * @param aItem is an item to be drawn.
* @param aLayer tells which layer is currently rendered so that draw functions * @param aLayer tells which layer is currently rendered so that draw functions may
* may know what to draw (eg. for pads there are separate layers for holes, because they * know what to draw (eg. for pads there are separate layers for holes,
* have other dimensions then the pad itself. * because they have other dimensions then the pad itself.
*/ */
virtual bool Draw( const VIEW_ITEM* aItem, int aLayer ) = 0; virtual bool Draw( const VIEW_ITEM* aItem, int aLayer ) = 0;

View File

@ -1,7 +1,7 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2004-2018 KiCad Developers, see CHANGELOG.TXT for contributors. * Copyright (C) 2004-2020 KiCad Developers, see CHANGELOG.TXT for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -40,14 +40,6 @@ class TOOL_MANAGER;
class PANEL_HOTKEYS_EDITOR : public RESETTABLE_PANEL class PANEL_HOTKEYS_EDITOR : public RESETTABLE_PANEL
{ {
protected:
EDA_BASE_FRAME* m_frame;
bool m_readOnly;
std::vector<TOOL_MANAGER*> m_toolManagers;
HOTKEY_STORE m_hotkeyStore;
WIDGET_HOTKEY_LIST* m_hotkeyListCtrl;
public: public:
PANEL_HOTKEYS_EDITOR( EDA_BASE_FRAME* aFrame, wxWindow* aWindow, bool aReadOnly ); PANEL_HOTKEYS_EDITOR( EDA_BASE_FRAME* aFrame, wxWindow* aWindow, bool aReadOnly );
@ -64,28 +56,33 @@ public:
} }
private: private:
/** /**
* Install the button panel (global reset/default, import/export) * Install the button panel (global reset/default, import/export)
* @param aSizer the dialog to install on *
* @param aSizer the dialog to install on.
*/ */
void installButtons( wxSizer* aSizer ); void installButtons( wxSizer* aSizer );
/** /**
* Function OnFilterSearch * Handle a change in the hotkey filter text.
* Handle a change in the hoteky filter text
* *
* @param aEvent: the search event, used to get the search query * @param aEvent is the search event, used to get the search query.
*/ */
void OnFilterSearch( wxCommandEvent& aEvent ); void OnFilterSearch( wxCommandEvent& aEvent );
/** /**
* Function ImportHotKeys * Put up a dialog allowing the user to select a hotkeys file and then overlays those
* Puts up a dialog allowing the user to select a hotkeys file and then overlays those
* hotkeys onto the current hotkey store. * hotkeys onto the current hotkey store.
*/ */
void ImportHotKeys(); void ImportHotKeys();
protected:
EDA_BASE_FRAME* m_frame;
bool m_readOnly;
std::vector<TOOL_MANAGER*> m_toolManagers;
HOTKEY_STORE m_hotkeyStore;
WIDGET_HOTKEY_LIST* m_hotkeyListCtrl;
}; };

View File

@ -3,7 +3,7 @@
* *
* Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2008-2016 Wayne Stambaugh <stambaughw@verizon.net> * Copyright (C) 2008-2016 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -68,35 +68,14 @@ struct MAGNETIC_SETTINGS;
wxDECLARE_EVENT( BOARD_CHANGED, wxCommandEvent ); wxDECLARE_EVENT( BOARD_CHANGED, wxCommandEvent );
/** /**
* PCB_BASE_FRAME * Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
* basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
*/ */
class PCB_BASE_FRAME : public EDA_DRAW_FRAME class PCB_BASE_FRAME : public EDA_DRAW_FRAME
{ {
protected:
BOARD* m_pcb;
PCB_DISPLAY_OPTIONS m_displayOptions;
PCB_ORIGIN_TRANSFORMS m_originTransforms;
PCBNEW_SETTINGS* m_settings; // No ownership, just a shortcut
virtual void unitsChangeRefresh() override;
/**
* Function loadFootprint
* attempts to load \a aFootprintId from the footprint library table.
*
* @param aFootprintId is the #LIB_ID of component footprint to load.
* @return the #FOOTPRINT if found or NULL if \a aFootprintId not found in any of the
* libraries in the table returned from #Prj().PcbFootprintLibs().
* @throw IO_ERROR if an I/O error occurs or a #PARSE_ERROR if a file parsing error
* occurs while reading footprint library files.
*/
FOOTPRINT* loadFootprint( const LIB_ID& aFootprintId );
public: public:
PCB_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType, PCB_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType,
const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize, const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize,
long aStyle, const wxString& aFrameName ); long aStyle, const wxString& aFrameName );
~PCB_BASE_FRAME(); ~PCB_BASE_FRAME();
@ -106,15 +85,15 @@ public:
EDA_3D_VIEWER* Get3DViewerFrame(); EDA_3D_VIEWER* Get3DViewerFrame();
/** /**
* Update the 3D view, if the viewer is opened by this frame * Update the 3D view, if the viewer is opened by this frame.
* @param aTitle = the new title of the 3D frame, or nullptr *
* to do not change the frame title * @param aTitle is the new title of the 3D frame, or nullptr to do not change the
* frame title
*/ */
virtual void Update3DView( bool aReloadRequest, const wxString* aTitle = nullptr ); virtual void Update3DView( bool aReloadRequest, const wxString* aTitle = nullptr );
/** /**
* Function LoadFootprint * Attempt to load \a aFootprintId from the footprint library table.
* attempts to load \a aFootprintId from the footprint library table.
* *
* @param aFootprintId is the #LIB_ID of component footprint to load. * @param aFootprintId is the #LIB_ID of component footprint to load.
* @return the #FOOTPRINT if found or NULL if \a aFootprintId not found in any of the * @return the #FOOTPRINT if found or NULL if \a aFootprintId not found in any of the
@ -123,12 +102,12 @@ public:
FOOTPRINT* LoadFootprint( const LIB_ID& aFootprintId ); FOOTPRINT* LoadFootprint( const LIB_ID& aFootprintId );
/** /**
* Function GetBoardBoundingBox * Calculate the bounding box containing all board items (or board edge segments).
* calculates the bounding box containing all board items (or board edge segments). *
* @param aBoardEdgesOnly is true if we are interested in board edge segments only. * @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 GetBoardBoundingBox( bool aBoardEdgesOnly = false ) const; EDA_RECT GetBoardBoundingBox( bool aBoardEdgesOnly = false ) const;
const BOX2I GetDocumentExtents( bool aIncludeAllVisible = true ) const override const BOX2I GetDocumentExtents( bool aIncludeAllVisible = true ) const override
{ {
@ -170,14 +149,16 @@ public:
void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) override; void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) override;
/** /**
* Returns the BOARD_DESIGN_SETTINGS for the open project * Returns the BOARD_DESIGN_SETTINGS for the open project.
*
* Overloaded in FOOTPRINT_EDIT_FRAME. * Overloaded in FOOTPRINT_EDIT_FRAME.
*/ */
virtual BOARD_DESIGN_SETTINGS& GetDesignSettings() const; virtual BOARD_DESIGN_SETTINGS& GetDesignSettings() const;
/** /**
* Helper to retrieve the current color settings * Helper to retrieve the current color settings.
* @return a pointer to the active COLOR_SETTINGS *
* @return a pointer to the active COLOR_SETTINGS.
*/ */
virtual COLOR_SETTINGS* GetColorSettings() override virtual COLOR_SETTINGS* GetColorSettings() override
{ {
@ -190,9 +171,8 @@ public:
void SetDrawBgColor( COLOR4D aColor ) override; void SetDrawBgColor( COLOR4D aColor ) override;
/** /**
* Function GetDisplayOptions
* Display options control the way tracks, vias, outlines and other things are shown * Display options control the way tracks, vias, outlines and other things are shown
* (for instance solid or sketch mode) * (for instance solid or sketch mode).
*/ */
const PCB_DISPLAY_OPTIONS& GetDisplayOptions() const { return m_displayOptions; } const PCB_DISPLAY_OPTIONS& GetDisplayOptions() const { return m_displayOptions; }
void SetDisplayOptions( const PCB_DISPLAY_OPTIONS& aOptions ); void SetDisplayOptions( const PCB_DISPLAY_OPTIONS& aOptions );
@ -201,18 +181,17 @@ public:
void SetZoneSettings( const ZONE_SETTINGS& aSettings ); void SetZoneSettings( const ZONE_SETTINGS& aSettings );
/** /**
* Function GetPlotSettings * Return the #PCB_PLOT_PARAMS for the BOARD owned by this frame.
* returns the PCB_PLOT_PARAMS for the BOARD owned by this frame. *
* Overloaded in FOOTPRINT_EDIT_FRAME. * Overloaded in FOOTPRINT_EDIT_FRAME.
*/ */
virtual const PCB_PLOT_PARAMS& GetPlotSettings() const; virtual const PCB_PLOT_PARAMS& GetPlotSettings() const;
virtual void SetPlotSettings( const PCB_PLOT_PARAMS& aSettings ); virtual void SetPlotSettings( const PCB_PLOT_PARAMS& aSettings );
/** /**
* Function SetBoard * Set the #m_Pcb member in such as way as to ensure deleting any previous #BOARD.
* sets the m_Pcb member in such as way as to ensure deleting any previous *
* BOARD. * @param aBoard is the #BOARD to put into the frame.
* @param aBoard The BOARD to put into the frame.
*/ */
virtual void SetBoard( BOARD* aBoard ); virtual void SetBoard( BOARD* aBoard );
@ -223,7 +202,6 @@ public:
} }
/** /**
* Function GetModel()
* @return the primary data model. * @return the primary data model.
*/ */
virtual BOARD_ITEM_CONTAINER* GetModel() const = 0; virtual BOARD_ITEM_CONTAINER* GetModel() const = 0;
@ -242,60 +220,56 @@ public:
/** /**
* Shows the 3D view frame. * Shows the 3D view frame.
* If it does not exist, it is created. *
* If it exists, it is bring to the foreground * If it does not exist, it is created. If it exists, it is brought to the foreground.
*/ */
EDA_3D_VIEWER* CreateAndShow3D_Frame(); EDA_3D_VIEWER* CreateAndShow3D_Frame();
/** /**
* Function GetCollectorsGuide * @return global configuration options.
* @return GENERAL_COLLECTORS_GUIDE - that considers the global configuration options.
*/ */
GENERAL_COLLECTORS_GUIDE GetCollectorsGuide(); GENERAL_COLLECTORS_GUIDE GetCollectorsGuide();
/** /**
* Function SelectLibrary * Put up a dialog and allows the user to pick a library, for unspecified use.
* puts up a dialog and allows the user to pick a library, for unspecified use.
* *
* @param aNicknameExisting is the current choice to highlight * @param aNicknameExisting is the current choice to highlight.
* @return wxString - the library or wxEmptyString on abort. * @return the library or wxEmptyString on abort.
*/ */
wxString SelectLibrary( const wxString& aNicknameExisting ); wxString SelectLibrary( const wxString& aNicknameExisting );
/** /**
* Function GetFootprintFromBoardByReference * @return a reference to the footprint found by its reference on the current board. The
* @return a reference to the footprint found by its refence on the curent board. The
* reference is entered by the user from a dialog (by awxTextCtlr, or a list of * reference is entered by the user from a dialog (by awxTextCtlr, or a list of
* available references) * available references)
*/ */
FOOTPRINT* GetFootprintFromBoardByReference(); FOOTPRINT* GetFootprintFromBoardByReference();
/** /**
* Function OnModify
* Must be called after a change in order to set the "modify" flag of the current screen * Must be called after a change in order to set the "modify" flag of the current screen
* and update the date in frame reference. * and update the date in frame reference.
*
* Do not forget to call this basic OnModify function to update info in derived OnModify * Do not forget to call this basic OnModify function to update info in derived OnModify
* functions. * functions.
*/ */
virtual void OnModify(); virtual void OnModify();
// footprints (footprints)
/** /**
* Function CreateNewFootprint * Creates a new footprint, at position 0,0.
* Creates a new footprint, at position 0,0 *
* The new footprint contains only 2 texts: a reference and a value: * The new footprint contains only 2 texts: a reference and a value:
* Reference = REF** * Reference = REF**
* Value = "VAL**" or Footprint name in lib * Value = "VAL**" or Footprint name in lib
* Note: they are dummy texts, which will be replaced by the actual texts *
* when the fooprint is placed on a board and a netlist is read * @note They are dummy texts, which will be replaced by the actual texts when the
* @param aFootprintName = name of the new footprint in library * footprint is placed on a board and a netlist is read.
*
* @param aFootprintName is the name of the new footprint in library.
*/ */
FOOTPRINT* CreateNewFootprint( const wxString& aFootprintName ); FOOTPRINT* CreateNewFootprint( const wxString& aFootprintName );
/** /**
* Function PlaceFootprint * Places \a aFootprint at the current cursor position and updates footprint coordinates
* places \a aFootprint at the current cursor position and updates footprint coordinates
* with the new position. * with the new position.
* *
* @param aRecreateRatsnest A bool true redraws the footprint ratsnest. * @param aRecreateRatsnest A bool true redraws the footprint ratsnest.
@ -305,71 +279,69 @@ public:
void ShowPadPropertiesDialog( PAD* aPad ); void ShowPadPropertiesDialog( PAD* aPad );
/** /**
* Function SelectFootprintFromLibTree * Open a dialog to select a footprint.
* opens a dialog to select a footprint.
* *
* @param aPreslect = if valid, the LIB_ID to select (otherwise the global history is used) * @param aPreslect if valid, the #LIB_ID to select (otherwise the global history is used).
*/ */
FOOTPRINT* SelectFootprintFromLibTree( LIB_ID aPreselect = LIB_ID() ); FOOTPRINT* SelectFootprintFromLibTree( LIB_ID aPreselect = LIB_ID() );
/** /**
* Adds the given footprint to the board. * Add the given footprint to the board.
* @param aFootprint *
* @param aDC (can be NULL ) = the current Device Context, to draw the new footprint * @param aDC is the current Device Context, to draw the new footprint (can be NULL ).
*/ */
virtual void AddFootprintToBoard( FOOTPRINT* aFootprint ); virtual void AddFootprintToBoard( FOOTPRINT* aFootprint );
/** /**
* Function SelectFootprintFromLibBrowser * Launch the footprint viewer to select the name of a footprint to load.
* launches the footprint viewer to select the name of a footprint to load.
* *
* @return the selected footprint name or an empty string if no selection was made. * @return the selected footprint name or an empty string if no selection was made.
*/ */
wxString SelectFootprintFromLibBrowser(); wxString SelectFootprintFromLibBrowser();
/** /**
* Function Compile_Ratsnest * Create the entire board ratsnest.
* Create the entire board ratsnest. *
* Must be called after a board change (changes for * This must be called after a board change (changes for pads, footprints or a read
* pads, footprints or a read netlist ). * netlist ).
* @param aDC = the current device context (can be NULL) *
* @param aDisplayStatus : if true, display the computation results * @param aDC is the current device context (can be NULL).
* @param aDisplayStatus if true, display the computation results.
*/ */
void Compile_Ratsnest( bool aDisplayStatus ); void Compile_Ratsnest( bool aDisplayStatus );
/* Functions relative to Undo/redo commands: */
/** /**
* Function SaveCopyInUndoList (virtual pure) * Create a new entry in undo list of commands.
* Creates a new entry in undo list of commands. *
* add a picker to handle aItemToCopy * @param aItemToCopy is the board item modified by the command to undo.
* @param aItemToCopy = the board item modified by the command to undo * @param aTypeCommand is the command type (see enum #UNDO_REDO).
* @param aTypeCommand = command type (see enum UNDO_REDO) * @param aTransformPoint is the reference point of the transformation, for
* @param aTransformPoint = the reference point of the transformation, for * commands like move
* commands like move
*/ */
virtual void SaveCopyInUndoList( EDA_ITEM* aItemToCopy, UNDO_REDO aTypeCommand, virtual void SaveCopyInUndoList( EDA_ITEM* aItemToCopy, UNDO_REDO aTypeCommand,
const wxPoint& aTransformPoint = wxPoint( 0, 0 ) ) = 0; const wxPoint& aTransformPoint = wxPoint( 0, 0 ) ) = 0;
/** /**
* Function SaveCopyInUndoList (virtual pure, overloaded).
* Creates a new entry in undo list of commands. * Creates a new entry in undo list of commands.
* add a list of pickers to handle a list of items *
* @param aItemsList = the list of items modified by the command to undo * @param aItemsList is the list of items modified by the command to undo.
* @param aTypeCommand = command type (see enum UNDO_REDO) * @param aTypeCommand is the command type (see enum #UNDO_REDO)
* @param aTransformPoint = the reference point of the transformation, * @param aTransformPoint is the reference point of the transformation,
* for commands like move * for commands like move.
*/ */
virtual void SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList, UNDO_REDO aTypeCommand, virtual void SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList, UNDO_REDO aTypeCommand,
const wxPoint& aTransformPoint = wxPoint( 0, 0 ) ) = 0; const wxPoint& aTransformPoint = wxPoint( 0, 0 ) ) = 0;
/** Install the dialog box for layer selection /**
* @param aDefaultLayer = Preselection (NB_PCB_LAYERS for "(Deselect)" layer) * Show the dialog box for layer selection.
* @param aNotAllowedLayersMask = a layer mask for not allowed layers *
* (= 0 to show all layers in use) * @param aDefaultLayer is the default layer to select. Use #NB_PCB_LAYERS if no selection
* @param aDlgPosition = position of dialog ( defualt = centered) * is desired.
* @return the selected layer id * @param aNotAllowedLayersMask is a layer mask for not allowed layers. Use 0 to show all
* layers in use.
* @param aDlgPosition is the position of dialog (default is centered).
* @return the selected layer id.
*/ */
PCB_LAYER_ID SelectLayer( PCB_LAYER_ID aDefaultLayer, LSET aNotAllowedLayersMask = LSET(), PCB_LAYER_ID SelectLayer( PCB_LAYER_ID aDefaultLayer, LSET aNotAllowedLayersMask = LSET(),
wxPoint aDlgPosition = wxDefaultPosition ); wxPoint aDlgPosition = wxDefaultPosition );
@ -404,26 +376,43 @@ public:
virtual void OnUpdateLayerAlpha( wxUpdateUIEvent& aEvent ) {} virtual void OnUpdateLayerAlpha( wxUpdateUIEvent& aEvent ) {}
/** /**
* Function DisplayGridMsg()
*
* Display the current grid pane on the status bar. * Display the current grid pane on the status bar.
*/ */
void DisplayGridMsg() override; void DisplayGridMsg() override;
PCB_DRAW_PANEL_GAL* GetCanvas() const override; PCB_DRAW_PANEL_GAL* GetCanvas() const override;
///> @copydoc EDA_DRAW_FRAME::UseGalCanvas
virtual void ActivateGalCanvas() override; virtual void ActivateGalCanvas() override;
/** /**
* Does nothing. Should be overriden in derived classes which support autozoom. * Does nothing. Should be overridden in derived classes which support autozoom.
*/ */
virtual void SetAutoZoom( bool aAutoZoom ) {} virtual void SetAutoZoom( bool aAutoZoom ) {}
/** /**
* Always returns false. Should be overriden in derived classes which support autozoom. * Always returns false. Should be overridden in derived classes which support autozoom.
*/ */
virtual bool GetAutoZoom() { return false; } virtual bool GetAutoZoom() { return false; }
protected:
/**
* Attempts to load \a aFootprintId from the footprint library table.
*
* @param aFootprintId is the #LIB_ID of component footprint to load.
* @return the #FOOTPRINT if found or NULL if \a aFootprintId not found in any of the
* libraries in the table returned from #Prj().PcbFootprintLibs().
* @throw IO_ERROR if an I/O error occurs or a #PARSE_ERROR if a file parsing error
* occurs while reading footprint library files.
*/
FOOTPRINT* loadFootprint( const LIB_ID& aFootprintId );
BOARD* m_pcb;
PCB_DISPLAY_OPTIONS m_displayOptions;
PCB_ORIGIN_TRANSFORMS m_originTransforms;
PCBNEW_SETTINGS* m_settings; // No ownership, just a shortcut
virtual void unitsChangeRefresh() override;
}; };
#endif // PCB_BASE_FRAME_H #endif // PCB_BASE_FRAME_H

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2007-2014 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2007-2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -33,16 +33,16 @@
#include <project/board_project_settings.h> #include <project/board_project_settings.h>
/** /**
* PCB_DISPLAY_OPTIONS * Container for display options like enable/disable some optional drawings.
* handles display options like enable/disable some optional drawings.
*/ */
class PCB_DISPLAY_OPTIONS class PCB_DISPLAY_OPTIONS
{ {
public: public:
PCB_DISPLAY_OPTIONS();
/** /**
* Enum TRACE_CLEARANCE_DISPLAY_MODE_T * The set of values for DISPLAY_OPTIONS.ShowTrackClearanceMode parameter option.
* is the set of values for DISPLAY_OPTIONS.ShowTrackClearanceMode parameter option. *
* This parameter controls how to show tracks and vias clearance area. * This parameter controls how to show tracks and vias clearance area.
*/ */
enum TRACE_CLEARANCE_DISPLAY_MODE_T { enum TRACE_CLEARANCE_DISPLAY_MODE_T {
@ -92,7 +92,7 @@ public:
/// Ratsnest draw mode (all layers vs only visible layers) /// Ratsnest draw mode (all layers vs only visible layers)
RATSNEST_MODE m_RatsnestMode; RATSNEST_MODE m_RatsnestMode;
int m_MaxLinksShowed; // in track creation: number of hairwires shown int m_MaxLinksShowed; // in track creation: number of airwires shown
bool m_ShowModuleRatsnest; // When moving a footprint: allows displaying a ratsnest bool m_ShowModuleRatsnest; // When moving a footprint: allows displaying a ratsnest
bool m_ShowGlobalRatsnest; // If true, show all bool m_ShowGlobalRatsnest; // If true, show all
bool m_DisplayRatsnestLinesCurved; // Airwires can be drawn as straight lines (false) bool m_DisplayRatsnestLinesCurved; // Airwires can be drawn as straight lines (false)
@ -106,8 +106,8 @@ public:
double m_ZoneOpacity; ///< Opacity override for filled zone areas double m_ZoneOpacity; ///< Opacity override for filled zone areas
/** /**
* Enum PCB_DISPLAY_ORIGIN_OPTIONS_T * The set of values for DISPLAY_OPTIONS.DisplayOrigin parameter option.
* is the set of values for DISPLAY_OPTIONS.DisplayOrigin parameter option. *
* This parameter controls what is used as the origin point for location values * This parameter controls what is used as the origin point for location values
*/ */
enum PCB_DISPLAY_ORIGIN_OPTIONS_T { enum PCB_DISPLAY_ORIGIN_OPTIONS_T {
@ -121,9 +121,6 @@ public:
bool m_DisplayInvertXAxis; //< true: Invert the X axis for display bool m_DisplayInvertXAxis; //< true: Invert the X axis for display
bool m_DisplayInvertYAxis; //< true: Invert the Y axis for display bool m_DisplayInvertYAxis; //< true: Invert the Y axis for display
public:
PCB_DISPLAY_OPTIONS();
}; };
#endif // PCBSTRUCT_H_ #endif // PCBSTRUCT_H_

View File

@ -25,11 +25,6 @@
/** /**
* @file class_pcb_group.h * @file class_pcb_group.h
* @brief Class to handle a set of BOARD_ITEMs. * @brief Class to handle a set of BOARD_ITEMs.
* Group parent is always board, not logical parent group.
* Group is transparent container - e.g., its position is derived from the position
* of its members.
* A selection containing a group implicitly contains its members. However other operations
* on sets of items, like committing, updating the view, etc the set is explicit.
*/ */
#ifndef CLASS_PCB_GROUP_H_ #ifndef CLASS_PCB_GROUP_H_
@ -46,6 +41,11 @@ class VIEW;
/** /**
* PCB_GROUP is a set of BOARD_ITEMs (i.e., without duplicates) * PCB_GROUP is a set of BOARD_ITEMs (i.e., without duplicates)
*
* The group parent is always board, not logical parent group. The group is transparent
* container - e.g., its position is derived from the position of its members. A selection
* containing a group implicitly contains its members. However other operations on sets of
* items, like committing, updating the view, etc the set is explicit.
*/ */
class PCB_GROUP : public BOARD_ITEM class PCB_GROUP : public BOARD_ITEM
{ {
@ -88,6 +88,7 @@ public:
/* /*
* Searches for highest level group containing item. * Searches for highest level group containing item.
*
* @param scope restricts the search to groups within the group scope. * @param scope restricts the search to groups within the group scope.
* @return group containing item, if it exists, otherwise, NULL * @return group containing item, if it exists, otherwise, NULL
*/ */
@ -121,12 +122,12 @@ public:
EDA_ITEM* Clone() const override; EDA_ITEM* Clone() const override;
/* /*
* Clone() this and all descendents * Clone() this and all descendants
*/ */
PCB_GROUP* DeepClone() const; PCB_GROUP* DeepClone() const;
/* /*
* Duplicate() this and all descendents * Duplicate() this and all descendants
*/ */
PCB_GROUP* DeepDuplicate() const; PCB_GROUP* DeepDuplicate() const;
@ -146,7 +147,8 @@ public:
const EDA_RECT GetBoundingBox() const override; const EDA_RECT GetBoundingBox() const override;
///> @copydoc EDA_ITEM::Visit ///> @copydoc EDA_ITEM::Visit
SEARCH_RESULT Visit( INSPECTOR aInspector, void* aTestData, const KICAD_T aScanTypes[] ) override; SEARCH_RESULT Visit( INSPECTOR aInspector, void* aTestData,
const KICAD_T aScanTypes[] ) override;
///> @copydoc VIEW_ITEM::ViewGetLayers ///> @copydoc VIEW_ITEM::ViewGetLayers
void ViewGetLayers( int aLayers[], int& aCount ) const override; void ViewGetLayers( int aLayers[], int& aCount ) const override;
@ -174,15 +176,17 @@ public:
/** /**
* Invokes a function on all members of the group. * Invokes a function on all members of the group.
* Note that this function should not add or remove items to the group *
* @note This function should not add or remove items to the group.
*
* @param aFunction is the function to be invoked. * @param aFunction is the function to be invoked.
*/ */
void RunOnChildren( const std::function<void ( BOARD_ITEM* )>& aFunction ) const; void RunOnChildren( const std::function<void ( BOARD_ITEM* )>& aFunction ) const;
/** /**
* Invokes a function on all descendents of the group. * Invokes a function on all descendants of the group.
* Note that this function should not add or remove items to the group or descendent *
* groups. * @note This function should not add or remove items to the group or descendant groups.
* @param aFunction is the function to be invoked. * @param aFunction is the function to be invoked.
*/ */
void RunOnDescendants( const std::function<void( BOARD_ITEM* )>& aFunction ) const; void RunOnDescendants( const std::function<void( BOARD_ITEM* )>& aFunction ) const;

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2009-2018 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2009-2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -33,17 +33,15 @@
/* Handle info to display a board */ /* Handle info to display a board */
class PCB_SCREEN : public BASE_SCREEN class PCB_SCREEN : public BASE_SCREEN
{ {
public:
PCB_LAYER_ID m_Active_Layer;
PCB_LAYER_ID m_Route_Layer_TOP;
PCB_LAYER_ID m_Route_Layer_BOTTOM;
public: public:
/** /**
* Constructor
* @param aPageSizeIU is the size of the initial paper page in internal units. * @param aPageSizeIU is the size of the initial paper page in internal units.
*/ */
PCB_SCREEN( const wxSize& aPageSizeIU ); PCB_SCREEN( const wxSize& aPageSizeIU );
PCB_LAYER_ID m_Active_Layer;
PCB_LAYER_ID m_Route_Layer_TOP;
PCB_LAYER_ID m_Route_Layer_BOTTOM;
}; };
#endif // PCB_SCREEN_H #endif // PCB_SCREEN_H