-
-
Notifications
You must be signed in to change notification settings - Fork 484
/
pl_editor_frame.h
295 lines (231 loc) · 8.84 KB
/
pl_editor_frame.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 CERN
* Copyright (C) 2016-2023 KiCad Developers, see AUTHORS.txt for contributors.
* @author Jean-Pierre Charras, jp.charras at wanadoo.fr
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef _PL_EDITOR_FRAME_H
#define _PL_EDITOR_FRAME_H
#include <eda_draw_frame.h>
#include <base_screen.h>
#include "pl_editor_layout.h"
#include "pl_draw_panel_gal.h"
#include <memory>
class PL_DRAW_PANEL_GAL;
class PROPERTIES_FRAME;
class DS_DATA_ITEM;
class wxChoice;
class NL_PL_EDITOR_PLUGIN;
/**
* The main window used in the drawing sheet editor.
*/
class PL_EDITOR_FRAME : public EDA_DRAW_FRAME
{
public:
PL_EDITOR_FRAME( KIWAY* aKiway, wxWindow* aParent );
~PL_EDITOR_FRAME();
PROPERTIES_FRAME* GetPropertiesFrame() { return m_propertiesPagelayout; }
/**
* Show the dialog displaying the list of DS_DATA_ITEM items in the page layout
*/
void ShowDesignInspector();
bool OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl ) override;
/**
* Load a .kicad_wks drawing sheet file.
*
* @param aFullFileName is the filename.
*/
bool LoadDrawingSheetFile( const wxString& aFullFileName );
/**
* Save the current layout in a .kicad_wks drawing sheet file.
*
* @param aFullFileName is the filename.
*/
bool SaveDrawingSheetFile( const wxString& aFullFileName );
/**
* Load a .kicad_wks drawing sheet file, and add items to the current layout list.
*
* @param aFullFileName is the filename.
*/
bool InsertDrawingSheetFile( const wxString& aFullFileName );
/**
* Get if the drawing sheet has been modified but not saved.
*
* @return true if the any changes have not been saved
*/
bool IsContentModified() const override;
/**
* Event handler for the wxID_EXIT and wxID_CLOSE events.
*/
void OnExit( wxCommandEvent& aEvent );
bool canCloseWindow( wxCloseEvent& aCloseEvent ) override;
void doCloseWindow() override;
// The Tool Framework initialization
void setupTools();
// Virtual basic functions:
void ReCreateHToolbar() override;
void UpdateToolbarControlSizes() override;
void SetPageSettings(const PAGE_INFO&) override;
const PAGE_INFO& GetPageSettings () const override;
const VECTOR2I GetPageSizeIU() const override;
PL_DRAW_PANEL_GAL* GetCanvas() const override;
SELECTION& GetCurrentSelection() override;
const VECTOR2I& GetGridOrigin() const override { return m_grid_origin; }
void SetGridOrigin( const VECTOR2I& aPoint ) override { m_grid_origin = aPoint; }
/**
* Calculate the position (in page, in iu) of the corner used as coordinate origin
* of items.
*/
VECTOR2I ReturnCoordOriginCorner() const;
const TITLE_BLOCK& GetTitleBlock() const override;
void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) override;
void CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged ) override;
void DisplayGridMsg() override;
void UpdateStatusBar() override;
/**
* Must be called to initialize parameters when a new drawing sheet is loaded
*/
void OnNewDrawingSheet();
/**
* Create or update the right vertical toolbar.
*/
void ReCreateVToolbar() override;
/**
* Create or update the left vertical toolbar.
*
* @note This is currently not used.
*/
void ReCreateOptToolbar() override;
const PL_EDITOR_LAYOUT& GetPageLayout() const { return m_pageLayout; }
PL_EDITOR_LAYOUT& GetPageLayout() { return m_pageLayout; }
const BOX2I GetDocumentExtents( bool aIncludeAllVisible = true ) const override;
/**
* Drawing sheet editor can show the title block using a page number 1 or another number.
*
* This is because some items can be shown (or not) only on page 1 (a feature which
* looks like word processing option "page 1 differs from other pages").
*
* @return true if the page 1 is selected, and false if not.
*/
bool GetPageNumberOption() const;
/**
* Display the short filename (if exists) loaded file on the caption of the main window.
*/
void UpdateTitleAndInfo();
/**
* Display the size of the sheet to the message panel.
*/
void UpdateMsgPanelInfo();
void LoadSettings( APP_SETTINGS_BASE* aCfg ) override;
void SaveSettings( APP_SETTINGS_BASE* aCfg ) override;
void OnSelectPage( wxCommandEvent& event );
/**
* Called when the user select one of the 4 page corner as corner reference (or the
* left top paper corner).
*/
void OnSelectCoordOriginCorner( wxCommandEvent& event );
/**
* Open a dialog frame to print layers.
*/
void ToPrinter( bool doPreview );
void Files_io( wxCommandEvent& event );
/**
* Print a page.
*
* @param aDC is the device context used by the print function.
*/
virtual void PrintPage( const RENDER_SETTINGS* aSettings ) override;
void OnFileHistory( wxCommandEvent& event );
void OnClearFileHistory( wxCommandEvent& aEvent );
/**
* @return the filename of the current layout descr file
* If this is the default (no loaded file) returns a empty name
* or a new design.
*/
wxString GetCurrentFileName() const override;
/**
* Store the current layout description file filename.
*/
void SetCurrentFileName( const wxString& aName );
/**
* Refresh the library tree and redraw the window.
*/
void HardRedraw() override;
/**
* Add a new item to the drawing sheet item list.
*
* @param aType is the type of item:
* DS_TEXT, DS_SEGMENT, DS_RECT, DS_POLYPOLYGON
* @param aIdx is the position in list to insert the new item.
* @return a reference to the new item.
*/
DS_DATA_ITEM* AddDrawingSheetItem( int aType );
/**
* Must be called after a change in order to set the "modify" flag.
*/
void OnModify() override;
/**
* Save a copy of the description (in a S expr string) for Undo/redo commands.
*/
void SaveCopyInUndoList();
/**
* Redo the last edit:
* - Place the current edited layout in undo list.
* - Get the previous version of the current edited layout.
*/
void GetLayoutFromRedoList();
/**
* Undo the last edit:
* - Place the current layout in Redo list.
* - Get the previous version of the current edited layout.
*/
void GetLayoutFromUndoList();
/**
* Apply the last command in Undo List without stacking a Redo. Used to clean the
* Undo stack after canceling a command.
*/
void RollbackFromUndo();
void ClearUndoORRedoList( UNDO_REDO_LIST whichList, int aItemCount = -1 ) override;
protected:
bool saveCurrentPageLayout();
void setupUIConditions() override;
void doReCreateMenuBar() override;
void DoWithAcceptedFiles() override;
DECLARE_EVENT_TABLE();
private:
void handleActivateEvent( wxActivateEvent& aEvent ) override;
void handleIconizeEvent( wxIconizeEvent& aEvent ) override;
protected:
/// The last filename chosen to be proposed to the user
PROPERTIES_FRAME* m_propertiesPagelayout;
private:
PL_EDITOR_LAYOUT m_pageLayout;
int m_propertiesFrameWidth; // last width (in pixels) of m_propertiesPagelayout
wxChoice* m_originSelectBox; // Corner origin choice for coordinates
int m_originSelectChoice; // the last choice for m_originSelectBox
wxChoice* m_pageSelectBox; // The page number sel'ector (page 1 or other pages
// useful when there are some items which are
wxString m_mruImagePath; // Most recently used path for placing a new image
// only on page 1, not on page 1
VECTOR2I m_grid_origin;
std::unique_ptr<NL_PL_EDITOR_PLUGIN> m_spaceMouse;
};
#endif /* _PL_EDITOR_FRAME_H */