KiCad PCB EDA Suite
pl_editor_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) 2013 CERN
5  * Copyright (C) 2016-2019 KiCad Developers, see AUTHORS.txt for contributors.
6  * @author Jean-Pierre Charras, jp.charras at wanadoo.fr
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
26 #ifndef _PL_EDITOR_FRAME_H
27 #define _PL_EDITOR_FRAME_H
28 
29 
30 #include <config_params.h>
31 #include <eda_draw_frame.h>
32 #include <base_screen.h>
33 #include "pl_editor_layout.h"
34 #include "pl_draw_panel_gal.h"
35 
36 class PL_DRAW_PANEL_GAL;
37 class PROPERTIES_FRAME;
38 class DS_DATA_ITEM;
39 
40 
47 {
49 
50  int m_propertiesFrameWidth; // the last width (in pixels) of m_propertiesPagelayout
51 
52  wxChoice* m_originSelectBox; // Corner origin choice for coordinates
53  int m_originSelectChoice; // the last choice for m_originSelectBox
54  wxChoice* m_pageSelectBox; // The page number sel'ector (page 1 or other pages
55  // usefull when there are some items which are
56  // only on page 1, not on page 1
57  wxPoint m_grid_origin;
58 
59 protected:
62 
63  void setupUIConditions() override;
64 
65 public:
66  PL_EDITOR_FRAME( KIWAY* aKiway, wxWindow* aParent );
68 
70 
74  void ShowDesignInspector();
75 
76  bool OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl ) override;
77 
83  bool LoadPageLayoutDescrFile( const wxString& aFullFileName );
84 
90  bool SavePageLayoutDescrFile( const wxString& aFullFileName );
91 
97  bool InsertPageLayoutDescrFile( const wxString& aFullFileName );
98 
104  bool IsContentModified() override;
105 
106  /*
107  * Function OnExit
108  * Event handler for the wxID_EXIT and wxID_CLOSE events
109  */
110  void OnExit( wxCommandEvent& aEvent );
111 
112  bool canCloseWindow( wxCloseEvent& aCloseEvent ) override;
113  void doCloseWindow() override;
114 
115  // The Tool Framework initalization
116  void setupTools();
117 
118  // Virtual basic functions:
119  void ReCreateHToolbar() override;
120  void UpdateToolbarControlSizes() override;
121 
122  void SetPageSettings(const PAGE_INFO&) override;
123  const PAGE_INFO& GetPageSettings () const override;
124  const wxSize GetPageSizeIU() const override;
125 
126  PL_DRAW_PANEL_GAL* GetCanvas() const override;
127  SELECTION& GetCurrentSelection() override;
128 
129  const wxPoint& GetGridOrigin() const override { return m_grid_origin; }
130  void SetGridOrigin( const wxPoint& aPoint ) override { m_grid_origin = aPoint; }
131 
136  wxPoint ReturnCoordOriginCorner() const;
137 
138  const TITLE_BLOCK& GetTitleBlock() const override;
139  void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) override;
140 
141  void CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged ) override;
142 
143  void DisplayGridMsg() override;
144 
145  void UpdateStatusBar() override;
146 
150  void OnNewPageLayout();
151 
155  void ReCreateVToolbar() override;
156 
161  void ReCreateOptToolbar() override;
162 
163  void ReCreateMenuBar() override;
164 
165  const PL_EDITOR_LAYOUT& GetPageLayout() const { return m_pageLayout; }
167 
168  const BOX2I GetDocumentExtents( bool aIncludeAllVisible = true ) const override;
169 
176  bool GetPageNumberOption() const
177  {
178  return m_pageSelectBox->GetSelection() == 0;
179  }
180 
184  void UpdateTitleAndInfo();
185 
186  void InstallPreferences( PAGED_DIALOG* aParent, PANEL_HOTKEYS_EDITOR* aHotkeysPanel ) override;
187 
188  void LoadSettings( APP_SETTINGS_BASE* aCfg ) override;
189 
190  void SaveSettings( APP_SETTINGS_BASE* aCfg ) override;
191 
192  void OnSelectPage( wxCommandEvent& event );
193 
198  void OnSelectCoordOriginCorner( wxCommandEvent& event );
199 
207  void OnSelectTitleBlockDisplayMode( wxCommandEvent& event );
208 
213  void ToPrinter( bool doPreview );
214 
215  void Files_io( wxCommandEvent& event );
216 
221  virtual void PrintPage( const RENDER_SETTINGS* aSettings ) override;
222 
223  void OnFileHistory( wxCommandEvent& event );
224  void OnClearFileHistory( wxCommandEvent& aEvent );
225 
231  wxString GetCurrentFileName() const override;
232 
236  void SetCurrentFileName( const wxString& aName );
237 
241  void HardRedraw() override;
242 
251  DS_DATA_ITEM* AddPageLayoutItem( int aType );
252 
256  void OnModify()
257  {
258  GetScreen()->SetModify();
259  }
260 
264  void SaveCopyInUndoList();
265 
270  void GetLayoutFromRedoList();
271 
276  void GetLayoutFromUndoList();
277 
282  void RollbackFromUndo();
283 
287  void ClearUndoORRedoList( UNDO_REDO_LIST whichList, int aItemCount = -1 ) override;
288 
289 protected:
290  bool saveCurrentPageLayout();
291 
292  DECLARE_EVENT_TABLE()
293 };
294 
295 #endif /* _PL_EDITOR_FRAME_H */
void OnFileHistory(wxCommandEvent &event)
void ToPrinter(bool doPreview)
Function ToPrinter Open a dialog frame to print layers.
virtual void PrintPage(const RENDER_SETTINGS *aSettings) override
Virtual function PrintPage used to print a page.
bool IsContentModified() override
Get if the page layout has been modified but not saved.
PROPERTIES_FRAME * GetPropertiesFrame()
void HardRedraw() override
Refresh the library tree and redraw the window.
PL_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
const PAGE_INFO & GetPageSettings() const override
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
void ClearUndoORRedoList(UNDO_REDO_LIST whichList, int aItemCount=-1) override
Function ClearUndoORRedoList.
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock) override
void ReCreateVToolbar() override
creates or updates the right vertical toolbar.
wxPoint ReturnCoordOriginCorner() const
calculate the position (in page, in iu) of the corner used as coordinate origin of items
void ReCreateMenuBar() override
Recreates the menu bar.
PROPERTIES_FRAME display properties of the current item.
PL_EDITOR_FRAME is the main window used in the drawing sheet editor.
void UpdateStatusBar() override
Update the status bar information.
bool canCloseWindow(wxCloseEvent &aCloseEvent) override
void OnClearFileHistory(wxCommandEvent &aEvent)
PL_EDITOR_LAYOUT & GetPageLayout()
void GetLayoutFromRedoList()
Redo the last edit:
void UpdateToolbarControlSizes() override
Update the sizes of any controls in the toolbars of the frame.
The base class for create windows for drawing purpose.
Hold the information shown in the lower right corner of a plot, printout, or editing view.
Definition: title_block.h:40
const wxSize GetPageSizeIU() const override
Works off of GetPageSettings() to return the size of the paper page in the internal units of this par...
void OnModify()
Must be called after a change in order to set the "modify" flag.
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
wxString GetCurrentFileName() const override
void SetPageSettings(const PAGE_INFO &) override
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:99
PL_EDITOR_FRAME(KIWAY *aKiway, wxWindow *aParent)
bool OpenProjectFiles(const std::vector< wxString > &aFileSet, int aCtl) override
Open a project or set of files given by aFileList.
void OnExit(wxCommandEvent &aEvent)
Describe the page size and margins of a paper page on which to eventually print or plot.
Definition: page_info.h:53
void OnSelectCoordOriginCorner(wxCommandEvent &event)
called when the user select one of the 4 page corner as corner reference (or the left top paper corne...
void ShowDesignInspector()
Show the dialog displaying the list of DS_DATA_ITEM items in the page layout.
void OnNewPageLayout()
Must be called to initialize parameters when a new page layout description is loaded.
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:260
const TITLE_BLOCK & GetTitleBlock() const override
PL_EDITOR_LAYOUT.
bool SavePageLayoutDescrFile(const wxString &aFullFileName)
Function SavePageLayoutDescrFile Save the current layout in a .kicad_wks page layout descr file.
SELECTION & GetCurrentSelection() override
Get the current selection from the canvas area.
void doCloseWindow() override
PL_EDITOR_LAYOUT m_pageLayout
bool GetPageNumberOption() const
Drawing sheet editor can show the title block using a page number 1 or another number.
const wxPoint & GetGridOrigin() const override
Return the absolute coordinates of the origin of the snap grid.
void OnSelectPage(wxCommandEvent &event)
void InstallPreferences(PAGED_DIALOG *aParent, PANEL_HOTKEYS_EDITOR *aHotkeysPanel) override
Allow a frame to load its preference panels (if any) into the preferences dialog.
wxChoice * m_pageSelectBox
UNDO_REDO_LIST
Remove the aItemCount of old commands from aList and delete commands, pickers and picked items if nee...
void SetCurrentFileName(const wxString &aName)
Stores the current layout descr file filename.
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
void ReCreateOptToolbar() override
Create or update the left vertical toolbar (option toolbar.
void UpdateTitleAndInfo()
Displays the short filename (if exists) loaded file on the caption of the main window.
Drawing sheet structure type definitions.
Definition: ds_data_item.h:95
PROPERTIES_FRAME * m_propertiesPagelayout
The last filename chosen to be proposed to the user.
void DisplayGridMsg() override
Display current grid size in the status bar.
void SetGridOrigin(const wxPoint &aPoint) override
bool InsertPageLayoutDescrFile(const wxString &aFullFileName)
Function InsertPageLayoutDescrFile Loads a .kicad_wks page layout descr file, and add items to the cu...
bool LoadPageLayoutDescrFile(const wxString &aFullFileName)
Function LoadPageLayoutDescrFile Loads a .kicad_wks page layout descr file.
void SaveCopyInUndoList()
Save a copy of the description (in a S expr string) for Undo/redo commands.
const BOX2I GetDocumentExtents(bool aIncludeAllVisible=true) const override
Returns bbox of document with option to not include some items.
void setupUIConditions() override
Setup the UI conditions for the various actions and their controls in this frame.
void SetModify()
Definition: base_screen.h:59
BASE_SCREEN class implementation.
DS_DATA_ITEM * AddPageLayoutItem(int aType)
Function AddPageLayoutItem Add a new item to the page layout item list.
const PL_EDITOR_LAYOUT & GetPageLayout() const
void RollbackFromUndo()
Apply the last command in Undo List without stacking a Redo.
virtual BASE_SCREEN * GetScreen() const
Return a pointer to a BASE_SCREEN or one of its derivatives.
void OnSelectTitleBlockDisplayMode(wxCommandEvent &event)
Toggle the display mode between the normal mode and the editor mode: In normal mode,...
void GetLayoutFromUndoList()
Undo the last edit:
void ReCreateHToolbar() override
wxChoice * m_originSelectBox
void Files_io(wxCommandEvent &event)