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 <pcb_group.h>
33
34class EDIT_POINTS;
35class BOARD;
36class BOARD_ITEM;
38class GENERATOR_TOOL;
39class STATUS_MIN_MAX_POPUP;
40
41
43{
44public:
45
46 PCB_GENERATOR( BOARD_ITEM* aParent, PCB_LAYER_ID aLayer );
47
48 virtual ~PCB_GENERATOR();
49
50 /*
51 * Clone() this and all descendants
52 */
53 PCB_GENERATOR* DeepClone() const;
54
55 virtual void EditStart( GENERATOR_TOOL* aTool, BOARD* aBoard, BOARD_COMMIT* aCommit );
56
57 virtual void EditPush( GENERATOR_TOOL* aTool, BOARD* aBoard, BOARD_COMMIT* aCommit,
58 const wxString& aCommitMsg = wxEmptyString, int aCommitFlags = 0 );
59
60 virtual void EditRevert( GENERATOR_TOOL* aTool, BOARD* aBoard, BOARD_COMMIT* aCommit );
61
62 virtual void Remove( GENERATOR_TOOL* aTool, BOARD* aBoard, BOARD_COMMIT* aCommit );
63
64 virtual bool Update( GENERATOR_TOOL* aTool, BOARD* aBoard, BOARD_COMMIT* aCommit );
65
66#define STATUS_ITEMS_ONLY true
67
68 virtual std::vector<EDA_ITEM*> GetPreviewItems( GENERATOR_TOOL* aTool,
69 PCB_BASE_EDIT_FRAME* aFrame,
70 bool aStatusItemsOnly = false );
71
72 virtual bool MakeEditPoints( std::shared_ptr<EDIT_POINTS> aEditPoints ) const;
73
74 virtual bool UpdateFromEditPoints( std::shared_ptr<EDIT_POINTS> aEditPoints,
75 BOARD_COMMIT* aCommit );
76
77 virtual bool UpdateEditPoints( std::shared_ptr<EDIT_POINTS> aEditPoints );
78
79 const BOX2I GetBoundingBox() const override;
80
81 VECTOR2I GetPosition() const override { return m_origin; }
82 void SetPosition( const VECTOR2I& aPos ) override { m_origin = aPos; }
83
84 void Move( const VECTOR2I& aMoveVector ) override;
85
86 bool AddItem( BOARD_ITEM* aItem ) override;
87
88 LSET GetLayerSet() const override;
89
90 virtual void SetLayer( PCB_LAYER_ID aLayer ) override;
91
92 virtual wxString GetGeneratorType() const;
93
94 virtual const STRING_ANY_MAP GetProperties() const;
95
96 virtual void SetProperties( const STRING_ANY_MAP& aProps );
97
98 virtual std::vector<std::pair<wxString, wxVariant>> GetRowData();
99
100 virtual void ShowPropertiesDialog( PCB_BASE_EDIT_FRAME* aEditFrame ) {};
101
102 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override;
103
104 virtual wxString GetPluralName() const = 0;
105
106#if defined(DEBUG)
107 void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
108#endif
109
110 wxString GetClass() const override;
111
112 static inline bool ClassOf( const EDA_ITEM* aItem );
113
114#ifdef GENERATOR_ORDER
115 int GetUpdateOrder() const { return m_updateOrder; }
116 void SetUpdateOrder( int aValue ) { m_updateOrder = aValue; }
117#endif
118
119protected:
121
123
124#ifdef GENERATOR_ORDER
125 int m_updateOrder = 0;
126#endif
127
128 friend class GENERATORS_MGR;
129};
130
131#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:77
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:282
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:88
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: layer_ids.h:575
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)
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)
PCB_GENERATOR * DeepClone() const
void SetPosition(const VECTOR2I &aPos) override
Definition: pcb_generator.h:82
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:81
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()
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const override
Return a user-visible description string of this item.
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:51
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.