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 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 
30 #ifndef _PL_EDITOR_FRAME_H
31 #define _PL_EDITOR_FRAME_H
32 
33 
34 #include <config_params.h>
35 #include <draw_frame.h>
36 #include <class_drawpanel.h>
37 #include <pl_editor_screen.h>
38 #include <pl_editor_layout.h>
39 
40 class PROPERTIES_FRAME;
41 class DESIGN_TREE_FRAME;
42 class WORKSHEET_DATAITEM;
43 
44 
51 {
53 
54  int m_designTreeWidth; // the last width (in pixels) of m_treePagelayout
55  int m_propertiesFrameWidth; // the last width (in pixels) of m_propertiesPagelayout
56 
57  wxChoice* m_originSelectBox; // Corner origin choice for coordinates
58  int m_originSelectChoice; // the last choice for m_originSelectBox
59  wxChoice* m_pageSelectBox; // The page number sel'ector (page 1 or other pages
60  // usefull when there are some items which are
61  // only on page 1, not on page 1
62 
64 
65 protected:
67  wxString m_lastFileName;
70 
71 private:
72  // list of PARAM_CFG_xxx to read/write parameters saved in config
74 
75 public:
76  PL_EDITOR_FRAME( KIWAY* aKiway, wxWindow* aParent );
78 
79  bool OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl ) override;
80 
86  bool LoadPageLayoutDescrFile( const wxString& aFullFileName );
87 
93  bool SavePageLayoutDescrFile( const wxString& aFullFileName );
94 
101  bool InsertPageLayoutDescrFile( const wxString& aFullFileName );
102 
103  void OnCloseWindow( wxCloseEvent& Event );
104 
105  // Virtual basic functions:
106  void RedrawActiveWindow( wxDC* DC, bool EraseBg ) override;
107  void ReCreateHToolbar() override;
108 
109  void SetPageSettings(const PAGE_INFO&) override;
110  const PAGE_INFO& GetPageSettings () const override;
111  const wxSize GetPageSizeIU() const override;
112 
119  const wxString GetZoomLevelIndicator() const override;
120 
121  PL_EDITOR_SCREEN* GetScreen() const override
122  {
124  }
125 
126  const wxPoint& GetAuxOrigin() const override
127  {
128  static wxPoint dummy; // ( 0,0 );
129  return dummy;
130  }
131  void SetAuxOrigin( const wxPoint& aPosition ) override {}
132 
133  const wxPoint& GetGridOrigin() const override
134  {
135  return m_grid_origin;
136  }
137  void SetGridOrigin( const wxPoint& aPoint ) override
138  {
139  m_grid_origin = aPoint;
140  }
141 
142  const TITLE_BLOCK& GetTitleBlock() const override;
143  void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) override;
144 
145  void UpdateStatusBar() override;
146 
151  void OnNewPageLayout();
152 
157  void ReCreateVToolbar() override;
158 
163  void ReCreateOptToolbar();
164 
165  void ReCreateMenuBar() override;
166  void OnLeftClick( wxDC* aDC, const wxPoint& aMousePos ) override;
167  void OnLeftDClick( wxDC* aDC, const wxPoint& aMousePos ) override;
168  bool OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu ) override;
169  double BestZoom() override;
170 
171  // Events created by clicking on the design tree list:
172  void OnTreeSelection( wxTreeEvent& event );
173  void OnTreeMiddleClick( wxTreeEvent& event );
174  void OnTreeRightClick( wxTreeEvent& event );
175 
176  const PL_EDITOR_LAYOUT& GetPageLayout() const { return m_pageLayout; }
177 
186  bool GetPageNumberOption() const
187  {
188  return m_pageSelectBox->GetSelection() == 0;
189  }
190 
195  void UpdateTitleAndInfo();
196 
206 
207  void LoadSettings( wxConfigBase* aCfg ) override;
208 
209  void SaveSettings( wxConfigBase* aCfg ) override;
210 
211  void Process_Special_Functions( wxCommandEvent& event );
212  void OnSelectOptionToolbar( wxCommandEvent& event );
213 
218  void OnSelectCoordOriginCorner( wxCommandEvent& event );
219 
228  void OnSelectTitleBlockDisplayMode( wxCommandEvent& event );
229 
230  void OnUpdateTitleBlockDisplayNormalMode( wxUpdateUIEvent& event );
231  void OnUpdateTitleBlockDisplaySpecialMode( wxUpdateUIEvent& event );
232  void OnUpdateSelectTool( wxUpdateUIEvent& aEvent );
233 
239  virtual int BlockCommand( EDA_KEY key ) override;
240 
245  virtual void HandleBlockPlace( wxDC* DC ) override;
246 
258  virtual bool HandleBlockEnd( wxDC* DC ) override;
259 
268  void Block_Move( wxDC* DC );
269 
274  void OnQuit( wxCommandEvent& event );
275 
277  EDA_HOTKEY* GetHotKeyDescription( int aCommand ) const override;
278 
288  bool OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosition, EDA_ITEM* aItem = NULL ) override;
289 
290  void Process_Settings( wxCommandEvent& event );
291  void Process_Config( wxCommandEvent& event );
292 
298  void ToPlotter( wxCommandEvent& event );
299 
304  void ToPrinter( wxCommandEvent& event );
305 
306  void Files_io( wxCommandEvent& event );
307  bool GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey = 0 ) override;
308 
316  virtual void PrintPage( wxDC* aDC, LSET aPrintMasklayer,
317  bool aPrintMirrorMode, void * aData ) override;
318 
319  void OnFileHistory( wxCommandEvent& event );
320 
326  const wxString& GetCurrFileName() const;
327 
331  void SetCurrFileName( const wxString& aName );
332 
338  void RebuildDesignTree();
339 
348  WORKSHEET_DATAITEM * AddPageLayoutItem( int aType, int aIdx = -1 );
349 
355 
361  WORKSHEET_DATAITEM *Locate( const wxPoint& aPosition );
362 
367  void MoveItem( WORKSHEET_DATAITEM* aItem );
368 
373  void PlaceItem( WORKSHEET_DATAITEM* aItem );
374 
379  void OnModify()
380  {
381  GetScreen()->SetModify();
382  }
383 
388  void SaveCopyInUndoList();
389 
394  void GetLayoutFromRedoList( wxCommandEvent& event );
395 
400  void GetLayoutFromUndoList( wxCommandEvent& event );
401 
407 
408  DECLARE_EVENT_TABLE()
409 };
410 
411 #endif /* _PL_EDITOR_FRAME_H */
void OnFileHistory(wxCommandEvent &event)
A list of parameters type.
PARAM_CFG_ARRAY m_configSettings
const PL_EDITOR_LAYOUT & GetPageLayout() const
bool OnHotKey(wxDC *aDC, int aHotkeyCode, const wxPoint &aPosition, EDA_ITEM *aItem=NULL) override
Function OnHotKey.
const PAGE_INFO & GetPageSettings() const override
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock) override
void RemoveLastCommandInUndoList()
Remove the last command in Undo List.
void GetLayoutFromUndoList(wxCommandEvent &event)
Undo the last edition:
WORKSHEET_DATAITEM * AddPageLayoutItem(int aType, int aIdx=-1)
Function AddPageLayoutItem Add a new item to the page layout item list.
void ReCreateVToolbar() override
creates or updates the right vertical toolbar.
void ReCreateMenuBar() override
Function ReCreateMenuBar Creates recreates the menu bar.
Class PROPERTIES_FRAME display properties of the current item.
Class PL_EDITOR_FRAME is the main window used in the page layout editor.
void UpdateStatusBar() override
Function UpdateStatusBar updates the status bar information.
void OnTreeMiddleClick(wxTreeEvent &event)
bool OnRightClick(const wxPoint &aMousePos, wxMenu *aPopMenu) override
void Block_Move(wxDC *DC)
Function Block_Move moves all items within the selected block.
void Process_Special_Functions(wxCommandEvent &event)
void OnCloseWindow(wxCloseEvent &Event)
const wxPoint & GetAuxOrigin() const override
Function GetAuxOrigin returns the origin of the axis used for plotting and various exports...
The common library.
void GetLayoutFromRedoList(wxCommandEvent &event)
Redo the last edition:
void SetAuxOrigin(const wxPoint &aPosition) override
Class EDA_DRAW_FRAME is the base class for create windows for drawing purpose.
Definition: draw_frame.h:63
virtual void HandleBlockPlace(wxDC *DC) override
Function HandleBlockPlace handles the block place command.
Class TITLE_BLOCK holds the information shown in the lower right corner of a plot, printout, or editing view.
Definition: title_block.h:39
const wxSize GetPageSizeIU() const override
Function GetPageSizeIU works off of GetPageSettings() to return the size of the paper page in the int...
EDA_HOTKEY * GetHotKeyDescription(int aCommand) const override
>
PARAM_CFG_ARRAY & GetConfigurationSettings(void)
Populates the applicatios settings list.
void OnModify()
Must be called after a change in order to set the "modify" flag of the current screen.
virtual int BlockCommand(EDA_KEY key) override
Function BlockCommand returns the block command (BLOCK_MOVE, BLOCK_COPY...) corresponding to the aKey...
void OnSelectOptionToolbar(wxCommandEvent &event)
void Process_Settings(wxCommandEvent &event)
void Process_Config(wxCommandEvent &event)
void RedrawActiveWindow(wxDC *DC, bool EraseBg) override
Class DESIGN_TREE_FRAME is the left window showing the list of items.
virtual BASE_SCREEN * GetScreen() const
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
Definition: draw_frame.h:369
void SetPageSettings(const PAGE_INFO &) override
Class LSET is a set of PCB_LAYER_IDs.
void OnLeftDClick(wxDC *aDC, const wxPoint &aMousePos) override
PL_EDITOR_FRAME(KIWAY *aKiway, wxWindow *aParent)
bool OpenProjectFiles(const std::vector< wxString > &aFileSet, int aCtl) override
Class PAGE_INFO describes the page size and margins of a paper page on which to eventually print or p...
Definition: page_info.h:49
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 OnUpdateTitleBlockDisplaySpecialMode(wxUpdateUIEvent &event)
WORKSHEET_DATAITEM * Locate(const wxPoint &aPosition)
Function Locate.
void OnNewPageLayout()
Must be called to initialize parameters when a new page layout description is loaded.
PL_EDITOR_SCREEN * GetScreen() const override
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
Class KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within...
Definition: kiway.h:258
const TITLE_BLOCK & GetTitleBlock() const override
Class PL_EDITOR_LAYOUT holds list of GERBER_DRAW_ITEM currently loaded.
uint32_t EDA_KEY
Definition: common.h:52
wxString m_lastFileName
The last filename chosen to be proposed to the user.
bool SavePageLayoutDescrFile(const wxString &aFullFileName)
Function SavePageLayoutDescrFile Save the current layout in a .kicad_wks page layout descr file...
void ToPrinter(wxCommandEvent &event)
Function ToPrinter Open a dialog frame to print layers.
void OnTreeRightClick(wxTreeEvent &event)
PL_EDITOR_LAYOUT m_pageLayout
const wxPoint & GetGridOrigin() const override
Function GetGridOrigin returns the absolute coordinates of the origin of the snap grid...
const wxString GetZoomLevelIndicator() const override
Function GetZoomLevelIndicator returns a human readable value which can be displayed as zoom level in...
wxChoice * m_pageSelectBox
void ToPlotter(wxCommandEvent &event)
Function ToPlotter Open a dialog frame to create plot and drill files relative to the current board...
double BestZoom() override
Return the zoom level which displays the full page on screen.
void OnLeftClick(wxDC *aDC, const wxPoint &aMousePos) override
bool GeneralControl(wxDC *aDC, const wxPoint &aPosition, EDA_KEY aHotKey=0) override
Function GeneralControl performs application specific control using aDC at aPosition in logical units...
void OnTreeSelection(wxTreeEvent &event)
bool GetPageNumberOption() const
Page layout editor can show the title block using a page number 1 or another number.
void UpdateTitleAndInfo()
Displays the short filename (if exists) loaded file on the caption of the main window.
class EDA_HOTKEY is a class to handle hot key commands.
Definition: hotkeys_basic.h:59
void SaveSettings(wxConfigBase *aCfg) override
Function SaveSettings saves common frame parameters to a configuration data file. ...
WORKSHEET_DATAITEM * GetSelectedItem()
Function GetSelectedItem.
static LIB_PART * dummy()
Used when a LIB_PART is not found in library to draw a dummy shape This component is a 400 mils squar...
void OnQuit(wxCommandEvent &event)
Function OnQuit called on request of application quit.
void SetCurrFileName(const wxString &aName)
Stores the current layout descr file filename.
void ReCreateOptToolbar()
Create or update the left vertical toolbar (option toolbar.
PROPERTIES_FRAME * m_propertiesPagelayout
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...
void PlaceItem(WORKSHEET_DATAITEM *aItem)
Save in Undo list the layout, and place an item being moved.
bool LoadPageLayoutDescrFile(const wxString &aFullFileName)
Function LoadPageLayoutDescrFile Loads a .kicad_wks page layout descr file.
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:162
virtual bool HandleBlockEnd(wxDC *DC) override
Function HandleBlockEnd( ) handles the end of a block command, It is called at the end of the definit...
void SaveCopyInUndoList()
Save a copy of the description (in a S expr string) for Undo/redo commands.
void RebuildDesignTree()
Function RebuildDesignTree Re creates the design graphic tree list items, and ensures each item has a...
void MoveItem(WORKSHEET_DATAITEM *aItem)
Initialize a move item command.
virtual void PrintPage(wxDC *aDC, LSET aPrintMasklayer, bool aPrintMirrorMode, void *aData) override
Virtual function PrintPage used to print a page.
void SetModify()
Definition: base_screen.h:324
void OnUpdateTitleBlockDisplayNormalMode(wxUpdateUIEvent &event)
void OnSelectTitleBlockDisplayMode(wxCommandEvent &event)
Toggle the display mode between the normal mode and the editor mode: In normal mode, title block texts are shown like they will be shown in other kicad applications: the format symbols in texts are replaced by the actual text.
void ReCreateHToolbar() override
wxChoice * m_originSelectBox
void OnUpdateSelectTool(wxUpdateUIEvent &aEvent)
const wxString & GetCurrFileName() const
DESIGN_TREE_FRAME * m_treePagelayout
void Files_io(wxCommandEvent &event)
void LoadSettings(wxConfigBase *aCfg) override
Function LoadSettings loads common frame parameters from a configuration file.