KiCad PCB EDA Suite
pcb_base_edit_frame.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) 2014 CERN
5  * Copyright (C) 2020-2021 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * @author Maciej Suminski <maciej.suminski@cern.ch>
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 2
12  * of the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, you may find one here:
21  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
22  * or you may search the http://www.gnu.org website for the version 2 license,
23  * or you may write to the Free Software Foundation, Inc.,
24  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25  */
26 
27 #ifndef BASE_EDIT_FRAME_H
28 #define BASE_EDIT_FRAME_H
29 
30 #include <pcb_base_frame.h>
31 
35 
40 {
41 public:
42  PCB_BASE_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType,
43  const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize,
44  long aStyle, const wxString& aFrameName );
45 
46  virtual ~PCB_BASE_EDIT_FRAME();
47 
48  bool TryBefore( wxEvent& aEvent ) override;
49 
50  void doCloseWindow() override;
51 
63  wxString CreateNewLibrary( const wxString& aLibName = wxEmptyString,
64  const wxString& aProposedName = wxEmptyString );
65 
66  wxString CreateNewProjectLibrary( const wxString& aLibName = wxEmptyString,
67  const wxString& aProposedName = wxEmptyString );
68 
75  bool AddLibrary( const wxString& aLibName = wxEmptyString, FP_LIB_TABLE* aTable = nullptr );
76 
83  virtual void OnEditItemRequest( BOARD_ITEM* aItem ) = 0;
84 
93  void SaveCopyInUndoList( EDA_ITEM* aItemToCopy, UNDO_REDO aTypeCommand ) override;
94 
103  void SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList, UNDO_REDO aCommandType ) override;
104 
110  void RestoreCopyFromRedoList( wxCommandEvent& aEvent );
111 
117  void RestoreCopyFromUndoList( wxCommandEvent& aEvent );
118 
123  void RollbackFromUndo();
124 
133 
137  bool UndoRedoBlocked() const
138  {
139  return m_undoRedoBlocked;
140  }
141 
145  void UndoRedoBlock( bool aBlock = true )
146  {
147  m_undoRedoBlocked = aBlock;
148  }
149 
155  void SetGridVisibility( bool aVisible ) override;
156 
157  void SetObjectVisible( GAL_LAYER_ID aLayer, bool aVisible = true );
158 
162  int GetRotationAngle() const { return m_rotationAngle; }
163 
167  void SetRotationAngle( int aRotationAngle );
168 
169  void ShowTextPropertiesDialog( BOARD_ITEM* aText );
171 
173  void ActivateGalCanvas() override;
174 
176  virtual void SetBoard( BOARD* aBoard ) override;
177 
178  COLOR_SETTINGS* GetColorSettings() const override;
179 
180  /* full undo redo management : */
181 
182  // use EDA_BASE_FRAME::ClearUndoRedoList()
183  // use EDA_BASE_FRAME::PushCommandToUndoList( PICKED_ITEMS_LIST* aItem )
184  // use EDA_BASE_FRAME::PushCommandToRedoList( PICKED_ITEMS_LIST* aItem )
185 
197  void ClearUndoORRedoList( UNDO_REDO_LIST whichList, int aItemCount = -1 ) override;
198 
205  wxString GetDesignRulesPath();
206 
208 
212  virtual void OnLayerAlphaChanged();
213 
214 protected:
220  FP_LIB_TABLE* selectLibTable( bool aOptional = false );
221 
226  wxString createNewLibrary( const wxString& aLibName, const wxString& aProposedName,
227  FP_LIB_TABLE* aTable );
228 
229  void handleActivateEvent( wxActivateEvent& aEvent ) override;
230 
231  void unitsChangeRefresh() override;
232 
233 protected:
234  int m_rotationAngle; // Rotation step (in tenths of a degree)
236 
239 };
240 
241 #endif
void RollbackFromUndo()
Perform an undo of the last edit without logging a corresponding redo.
Definition: undo_redo.cpp:578
void RestoreCopyFromUndoList(wxCommandEvent &aEvent)
Undo the last edit:
Definition: undo_redo.cpp:315
PCB_BASE_EDIT_FRAME(KIWAY *aKiway, wxWindow *aParent, FRAME_T aFrameType, const wxString &aTitle, const wxPoint &aPos, const wxSize &aSize, long aStyle, const wxString &aFrameName)
void SetObjectVisible(GAL_LAYER_ID aLayer, bool aVisible=true)
void SaveCopyInUndoList(EDA_ITEM *aItemToCopy, UNDO_REDO aTypeCommand) override
Create a new entry in undo list of commands.
Definition: undo_redo.cpp:179
void ActivateGalCanvas() override
Set the #m_Pcb member in such as way as to ensure deleting any previous BOARD.
wxString GetDesignRulesPath()
Return the absolute path to the design rules file for the currently-loaded board.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:80
APPEARANCE_CONTROLS * m_appearancePanel
void handleActivateEvent(wxActivateEvent &aEvent) override
Handle a window activation event.
FRAME_T
The set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
Definition: frame_type.h:32
GAL_LAYER_ID
GAL layers are "virtual" layers, i.e.
Definition: layer_ids.h:184
virtual void OnEditItemRequest(BOARD_ITEM *aItem)=0
Install the corresponding dialog editor for the given item.
void UndoRedoBlock(bool aBlock=true)
Enable/disable undo and redo operations.
void PutDataInPreviousState(PICKED_ITEMS_LIST *aList)
Used in undo or redo command.
Definition: undo_redo.cpp:375
APPEARANCE_CONTROLS * GetAppearancePanel()
UNDO_REDO
Undo Redo considerations: Basically we have 3 cases New item Deleted item Modified item there is also...
void unitsChangeRefresh() override
Called when when the units setting has changed to allow for any derived classes to handle refreshing ...
virtual void OnLayerAlphaChanged()
Notify the frame that the layer Alpha is being changed.
void ShowTextPropertiesDialog(BOARD_ITEM *aText)
void doCloseWindow() override
Classes used in Pcbnew, CvPcb and GerbView.
bool TryBefore(wxEvent &aEvent) override
wxString CreateNewProjectLibrary(const wxString &aLibName=wxEmptyString, const wxString &aProposedName=wxEmptyString)
wxString CreateNewLibrary(const wxString &aLibName=wxEmptyString, const wxString &aProposedName=wxEmptyString)
If a library name is given, creates a new footprint library in the project folder with the given name...
void ClearUndoORRedoList(UNDO_REDO_LIST whichList, int aItemCount=-1) override
Free the undo or redo list from List element.
Definition: undo_redo.cpp:553
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:260
bool AddLibrary(const wxString &aLibName=wxEmptyString, FP_LIB_TABLE *aTable=nullptr)
Add an existing library to either the global or project library table.
A holder to handle information on schematic or board items.
bool UndoRedoBlocked() const
Check if the undo and redo operations are currently blocked.
UNDO_REDO_LIST
Specifies whether we are interacting with the undo or redo stacks.
void ShowGraphicItemPropertiesDialog(BOARD_ITEM *aItem)
int GetRotationAngle() const
Return the angle used for rotate operations.
void SetGridVisibility(bool aVisible) override
Override this function in the PCB_BASE_EDIT_FRAME to refill the layer widget.
Common, abstract interface for edit frames.
FP_LIB_TABLE * selectLibTable(bool aOptional=false)
Prompts a user to select global or project library tables.
PANEL_SELECTION_FILTER * m_selectionFilterPanel
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:190
virtual void SetBoard(BOARD *aBoard) override
Set the #m_Pcb member in such as way as to ensure deleting any previous BOARD.
void RestoreCopyFromRedoList(wxCommandEvent &aEvent)
Redo the last edit:
Definition: undo_redo.cpp:345
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100
Color settings are a bit different than most of the settings objects in that there can be more than o...
Abstract interface for BOARD_ITEMs capable of storing other items inside.
void SetRotationAngle(int aRotationAngle)
Set the angle used for rotate operations.
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
COLOR_SETTINGS * GetColorSettings() const override
Helper to retrieve the current color settings.
wxString createNewLibrary(const wxString &aLibName, const wxString &aProposedName, FP_LIB_TABLE *aTable)
Create a new library in the given table (presumed to be either the global or project library table).