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 <class_pl_editor_screen.h>
38 #include <class_pl_editor_layout.h>
39 
40 class PROPERTIES_FRAME;
41 class DESIGN_TREE_FRAME;
42 class WORKSHEET_DATAITEM;
43 
44 
49 #define PL_EDITOR_FRAME_NAME wxT( "PlEditorFrame" )
50 
52 {
54 
55  int m_designTreeWidth; // the last width (in pixels) of m_treePagelayout
56  int m_propertiesFrameWidth; // the last width (in pixels) of m_propertiesPagelayout
57 
58  wxChoice* m_originSelectBox; // Corner origin choice for coordinates
59  int m_originSelectChoice; // the last choice for m_originSelectBox
60  wxChoice* m_pageSelectBox; // The page number sel'ector (page 1 or other pages
61  // usefull when there are some items which are
62  // only on page 1, not on page 1
63 
65 
66 protected:
68  wxString m_lastFileName;
71 
72 private:
73  // list of PARAM_CFG_xxx to read/write parameters saved in config
75 
76 public:
77  PL_EDITOR_FRAME( KIWAY* aKiway, wxWindow* aParent );
79 
80  bool OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl ) override;
81 
87  bool LoadPageLayoutDescrFile( const wxString& aFullFileName );
88 
94  bool SavePageLayoutDescrFile( const wxString& aFullFileName );
95 
102  bool InsertPageLayoutDescrFile( const wxString& aFullFileName );
103 
104  void OnCloseWindow( wxCloseEvent& Event );
105 
106  // Virtual basic functions:
107  void RedrawActiveWindow( wxDC* DC, bool EraseBg ) override;
108  void ReCreateHToolbar() override;
109 
110  void SetPageSettings(const PAGE_INFO&) override;
111  const PAGE_INFO& GetPageSettings () const override;
112  const wxSize GetPageSizeIU() const override;
113 
120  const wxString GetZoomLevelIndicator() const override;
121 
122  PL_EDITOR_SCREEN* GetScreen() const override
123  {
125  }
126 
127  const wxPoint& GetAuxOrigin() const override
128  {
129  static wxPoint dummy; // ( 0,0 );
130  return dummy;
131  }
132  void SetAuxOrigin( const wxPoint& aPosition ) override {}
133 
134  const wxPoint& GetGridOrigin() const override
135  {
136  return m_grid_origin;
137  }
138  void SetGridOrigin( const wxPoint& aPoint ) override
139  {
140  m_grid_origin = aPoint;
141  }
142 
143  const TITLE_BLOCK& GetTitleBlock() const override;
144  void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) override;
145 
146  void UpdateStatusBar() override;
147 
152  void OnNewPageLayout();
153 
158  void ReCreateVToolbar() override;
159 
164  void ReCreateOptToolbar();
165 
166  void ReCreateMenuBar() override;
167  void OnLeftClick( wxDC* aDC, const wxPoint& aMousePos ) override;
168  void OnLeftDClick( wxDC* aDC, const wxPoint& aMousePos ) override;
169  bool OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu ) override;
170  double BestZoom() override;
171 
172  // Events created by clicking on the design tree list:
173  void OnTreeSelection( wxTreeEvent& event );
174  void OnTreeMiddleClick( wxTreeEvent& event );
175  void OnTreeRightClick( wxTreeEvent& event );
176 
177  const PL_EDITOR_LAYOUT& GetPageLayout() const { return m_pageLayout; }
178 
187  bool GetPageNumberOption() const
188  {
189  return m_pageSelectBox->GetSelection() == 0;
190  }
191 
196  void UpdateTitleAndInfo();
197 
207 
208  void LoadSettings( wxConfigBase* aCfg ) override;
209 
210  void SaveSettings( wxConfigBase* aCfg ) override;
211 
212  void Process_Special_Functions( wxCommandEvent& event );
213  void OnSelectOptionToolbar( wxCommandEvent& event );
214 
219  void OnSelectCoordOriginCorner( wxCommandEvent& event );
220 
229  void OnSelectTitleBlockDisplayMode( wxCommandEvent& event );
230 
231  void OnUpdateTitleBlockDisplayNormalMode( wxUpdateUIEvent& event );
232  void OnUpdateTitleBlockDisplaySpecialMode( wxUpdateUIEvent& event );
233  void OnUpdateSelectTool( wxUpdateUIEvent& aEvent );
234 
240  virtual int BlockCommand( EDA_KEY key ) override;
241 
246  virtual void HandleBlockPlace( wxDC* DC ) override;
247 
259  virtual bool HandleBlockEnd( wxDC* DC ) override;
260 
269  void Block_Move( wxDC* DC );
270 
275  void OnQuit( wxCommandEvent& event );
276 
278  EDA_HOTKEY* GetHotKeyDescription( int aCommand ) const override;
279 
289  bool OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosition, EDA_ITEM* aItem = NULL ) override;
290 
291  void Process_Settings( wxCommandEvent& event );
292  void Process_Config( wxCommandEvent& event );
293 
299  void ToPlotter( wxCommandEvent& event );
300 
305  void ToPrinter( wxCommandEvent& event );
306 
307  void Files_io( wxCommandEvent& event );
308  bool GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey = 0 ) override;
309 
317  virtual void PrintPage( wxDC* aDC, LSET aPrintMasklayer,
318  bool aPrintMirrorMode, void * aData ) override;
319 
320  void OnFileHistory( wxCommandEvent& event );
321 
327  const wxString& GetCurrFileName() const;
328 
332  void SetCurrFileName( const wxString& aName );
333 
339  void RebuildDesignTree();
340 
349  WORKSHEET_DATAITEM * AddPageLayoutItem( int aType, int aIdx = -1 );
350 
356 
362  WORKSHEET_DATAITEM *Locate( const wxPoint& aPosition );
363 
368  void MoveItem( WORKSHEET_DATAITEM* aItem );
369 
374  void PlaceItem( WORKSHEET_DATAITEM* aItem );
375 
380  void OnModify()
381  {
382  GetScreen()->SetModify();
383  }
384 
389  void SaveCopyInUndoList();
390 
395  void GetLayoutFromRedoList( wxCommandEvent& event );
396 
401  void GetLayoutFromUndoList( wxCommandEvent& event );
402 
408 
409  DECLARE_EVENT_TABLE()
410 };
411 
412 #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.
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:53
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.
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:309
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...
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:257
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 an other 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:57
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:151
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 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.