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( EDIT_POINTS& aEditPoints ) const;
74
75 virtual bool UpdateFromEditPoints( EDIT_POINTS& aEditPoints );
76
77 virtual bool UpdateEditPoints( 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 void Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) override;
87
88 void Flip( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection ) override;
89
90 void Mirror( const VECTOR2I& aCentre, FLIP_DIRECTION aMirrorDirection ) override;
91
92 bool AddItem( BOARD_ITEM* aItem ) override;
93
94 LSET GetLayerSet() const override;
95
96 virtual void SetLayer( PCB_LAYER_ID aLayer ) override;
97
98 virtual wxString GetGeneratorType() const;
99
100 virtual const STRING_ANY_MAP GetProperties() const;
101
102 virtual void SetProperties( const STRING_ANY_MAP& aProps );
103
104 virtual std::vector<std::pair<wxString, wxVariant>> GetRowData();
105
106 virtual void ShowPropertiesDialog( PCB_BASE_EDIT_FRAME* aEditFrame ) {};
107
108 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
109
110 virtual wxString GetPluralName() const = 0;
111
112#if defined(DEBUG)
113 void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
114#endif
115
116 wxString GetClass() const override;
117
118 static inline bool ClassOf( const EDA_ITEM* aItem );
119
120#ifdef GENERATOR_ORDER
121 int GetUpdateOrder() const { return m_updateOrder; }
122 void SetUpdateOrder( int aValue ) { m_updateOrder = aValue; }
123#endif
124
125protected:
127
129
130#ifdef GENERATOR_ORDER
131 int m_updateOrder = 0;
132#endif
133
134 friend class GENERATORS_MGR;
135
136 void baseMirror( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection );
137};
138
139#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:290
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:353
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:36
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)
void baseMirror(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection)
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 UpdateFromEditPoints(EDIT_POINTS &aEditPoints)
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
void Mirror(const VECTOR2I &aCentre, FLIP_DIRECTION aMirrorDirection) override
Mirror this object relative to a given horizontal axis the layer is not changed.
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.
virtual bool MakeEditPoints(EDIT_POINTS &aEditPoints) const
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 bool UpdateEditPoints(EDIT_POINTS &aEditPoints)
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()
virtual const STRING_ANY_MAP GetProperties() const
virtual wxString GetGeneratorType() const
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
FLIP_DIRECTION
Definition: mirror.h:27
Class to handle a set of BOARD_ITEMs.