KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcb_generator.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2023 Alex Shvartzkop <[email protected]>
5 * Copyright (C) 2023 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#ifndef GENERATOR_H_
26#define GENERATOR_H_
27
28
29#include <unordered_set>
30#include <string_any_map.h>
31
32#include <lset.h>
33#include <pcb_group.h>
34
35class EDIT_POINTS;
36class BOARD;
37class BOARD_ITEM;
39class GENERATOR_TOOL;
40class STATUS_MIN_MAX_POPUP;
41
42
44{
45public:
46
47 PCB_GENERATOR( BOARD_ITEM* aParent, PCB_LAYER_ID aLayer );
48
49 virtual ~PCB_GENERATOR();
50
51 /*
52 * Clone() this and all descendants
53 */
54 PCB_GENERATOR* DeepClone() const;
55
56 virtual void EditStart( GENERATOR_TOOL* aTool, BOARD* aBoard, BOARD_COMMIT* aCommit );
57
58 virtual void EditPush( GENERATOR_TOOL* aTool, BOARD* aBoard, BOARD_COMMIT* aCommit,
59 const wxString& aCommitMsg = wxEmptyString, int aCommitFlags = 0 );
60
61 virtual void EditRevert( GENERATOR_TOOL* aTool, BOARD* aBoard, BOARD_COMMIT* aCommit );
62
63 virtual void Remove( GENERATOR_TOOL* aTool, BOARD* aBoard, BOARD_COMMIT* aCommit );
64
65 virtual bool Update( GENERATOR_TOOL* aTool, BOARD* aBoard, BOARD_COMMIT* aCommit );
66
67#define STATUS_ITEMS_ONLY true
68
69 virtual std::vector<EDA_ITEM*> GetPreviewItems( GENERATOR_TOOL* aTool,
70 PCB_BASE_EDIT_FRAME* aFrame,
71 bool aStatusItemsOnly = false );
72
73 virtual bool MakeEditPoints( std::shared_ptr<EDIT_POINTS> aEditPoints ) const;
74
75 virtual bool UpdateFromEditPoints( std::shared_ptr<EDIT_POINTS> aEditPoints,
76 BOARD_COMMIT* aCommit );
77
78 virtual bool UpdateEditPoints( std::shared_ptr<EDIT_POINTS> aEditPoints );
79
80 const BOX2I GetBoundingBox() const override;
81
82 VECTOR2I GetPosition() const override { return m_origin; }
83 void SetPosition( const VECTOR2I& aPos ) override { m_origin = aPos; }
84
85 void Move( const VECTOR2I& aMoveVector ) override;
86
87 void Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) override;
88
89 void Flip( const VECTOR2I& aCentre, bool aFlipLeftRight ) override;
90
91 bool AddItem( BOARD_ITEM* aItem ) override;
92
93 LSET GetLayerSet() const override;
94
95 virtual void SetLayer( PCB_LAYER_ID aLayer ) override;
96
97 virtual wxString GetGeneratorType() const;
98
99 virtual const STRING_ANY_MAP GetProperties() const;
100
101 virtual void SetProperties( const STRING_ANY_MAP& aProps );
102
103 virtual std::vector<std::pair<wxString, wxVariant>> GetRowData();
104
105 virtual void ShowPropertiesDialog( PCB_BASE_EDIT_FRAME* aEditFrame ) {};
106
107 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
108
109 virtual wxString GetPluralName() const = 0;
110
111#if defined(DEBUG)
112 void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
113#endif
114
115 wxString GetClass() const override;
116
117 static inline bool ClassOf( const EDA_ITEM* aItem );
118
119#ifdef GENERATOR_ORDER
120 int GetUpdateOrder() const { return m_updateOrder; }
121 void SetUpdateOrder( int aValue ) { m_updateOrder = aValue; }
122#endif
123
124protected:
126
128
129#ifdef GENERATOR_ORDER
130 int m_updateOrder = 0;
131#endif
132
133 friend class GENERATORS_MGR;
134};
135
136#endif /* GENERATOR_H_ */
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:79
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:289
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:89
EDIT_POINTS is a VIEW_ITEM that manages EDIT_POINTs and EDIT_LINEs and draws them.
Definition: edit_points.h:330
A factory which returns an instance of a PCB_GENERATOR.
Handle actions specific to filling copper zones.
LSET is a set of PCB_LAYER_IDs.
Definition: lset.h:35
Common, abstract interface for edit frames.
virtual ~PCB_GENERATOR()
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
virtual void SetProperties(const STRING_ANY_MAP &aProps)
wxString m_generatorType
virtual void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
virtual void Remove(GENERATOR_TOOL *aTool, BOARD *aBoard, BOARD_COMMIT *aCommit)
virtual void EditRevert(GENERATOR_TOOL *aTool, BOARD *aBoard, BOARD_COMMIT *aCommit)
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
wxString GetClass() const override
Return the class name.
virtual bool UpdateEditPoints(std::shared_ptr< EDIT_POINTS > aEditPoints)
LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
virtual bool MakeEditPoints(std::shared_ptr< EDIT_POINTS > aEditPoints) const
virtual void ShowPropertiesDialog(PCB_BASE_EDIT_FRAME *aEditFrame)
virtual wxString GetPluralName() const =0
bool AddItem(BOARD_ITEM *aItem) override
Add item to group.
virtual void EditPush(GENERATOR_TOOL *aTool, BOARD *aBoard, BOARD_COMMIT *aCommit, const wxString &aCommitMsg=wxEmptyString, int aCommitFlags=0)
VECTOR2I m_origin
static bool ClassOf(const EDA_ITEM *aItem)
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
PCB_GENERATOR * DeepClone() const
void SetPosition(const VECTOR2I &aPos) override
Definition: pcb_generator.h:83
void Flip(const VECTOR2I &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
virtual void EditStart(GENERATOR_TOOL *aTool, BOARD *aBoard, BOARD_COMMIT *aCommit)
virtual std::vector< EDA_ITEM * > GetPreviewItems(GENERATOR_TOOL *aTool, PCB_BASE_EDIT_FRAME *aFrame, bool aStatusItemsOnly=false)
VECTOR2I GetPosition() const override
Definition: pcb_generator.h:82
virtual bool Update(GENERATOR_TOOL *aTool, BOARD *aBoard, BOARD_COMMIT *aCommit)
void Move(const VECTOR2I &aMoveVector) override
Move this object.
virtual std::vector< std::pair< wxString, wxVariant > > GetRowData()
virtual const STRING_ANY_MAP GetProperties() const
virtual wxString GetGeneratorType() const
virtual bool UpdateFromEditPoints(std::shared_ptr< EDIT_POINTS > aEditPoints, BOARD_COMMIT *aCommit)
A set of BOARD_ITEMs (i.e., without duplicates).
Definition: pcb_group.h:52
A name/value tuple with unique names and wxAny values.
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:60
Class to handle a set of BOARD_ITEMs.