2
* 3Depict.h - main program header
3
* Copyright (C) 2013 D Haley
5
* This program is free software: you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation, either version 3 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program. If not, see <http://www.gnu.org/licenses/>.
20
// begin wxGlade: ::dependencies
21
#include <wx/splitter.h>
22
#include <wx/filename.h>
23
#include <wx/statline.h>
24
#include <wx/notebook.h>
25
#include <wx/spinctrl.h>
26
#include <wx/listctrl.h>
27
#include <wx/docview.h>
30
#include <wx/treectrl.h>
31
#if wxCHECK_VERSION(2,9,0)
32
#include <wx/filehistory.h>
37
#include "wx/wxcommon.h"
38
#include "wx/wxcomponents.h"
40
#include "mathglPane.h"
41
#include "cropPanel.h" // cropping tools
43
#include "backend/viscontrol.h"
44
#include "backend/configFile.h"
49
//Workaround for keypress not detected under MSW wx3.0 and apple
50
#if wxCHECK_VERSION(2,9,0) && ( defined(__WIN32) || defined(__WIN64) || defined(__APPLE__)) || wxCHECK_VERSION(3,0,0)
51
#define WX_TREE_WORKAROUND
61
MESSAGE_NONE_BUT_HINT,
65
class MainWindowFrame: public wxFrame {
67
// begin wxGlade: MainWindowFrame::ids
70
MainWindowFrame(wxWindow* parent, int id, const wxString& title, const wxPoint& pos=wxDefaultPosition, const wxSize& size=wxDefaultSize, long style=wxDEFAULT_FRAME_STYLE);
71
virtual ~MainWindowFrame();
73
//Drop the following files onto the given window XY coordinates.
74
void OnDropFiles(const wxArrayString &files, int x, int y);
76
bool isCurrentlyUpdatingScene() const { return currentlyUpdatingScene;};
78
void linkCropWidgets();
80
wxSize getNiceWindowSize() const ;
82
//Obtain the filterId that is associated with the given tree node.
83
// returns false if it is not able to do so (eg invalid TreeItemId)
84
bool getTreeFilterId(const wxTreeItemId &tId, size_t &filterId) const;
87
// begin wxGlade: MainWindowFrame::methods
88
void set_properties();
92
//!Give a message in the satus bar
93
void statusMessage(const char *message, unsigned int messageType=MESSAGE_ERROR);
95
//!Update the progress information in the status bar
96
void updateProgressStatus();
97
//!Perform an update to the 3D Scene. Returns false if refresh failed
100
//!Update the post-processing effects in the 3D scene.
101
void updatePostEffects();
102
//!Load a file into the panel given the full path to the file
103
bool loadFile(const wxString &dataFile,bool merge=false,bool noUpdate=false);
105
//!Load any errors that were detected in the last refresh into the filter tree
106
void setFilterTreeAnalysisImages();
108
//!Update the effects UI from some effects vector
109
void updateFxUI(const vector<const Effect *> &fx);
111
void setLockUI(bool amlocking,unsigned int lockMode);
113
//Did the opengl panel initialise correctly?
115
//!Scene - user interaction interface "visualisation control"
116
VisController visControl;
118
//!Program on-disk configuration class
119
ConfigFile configFile;
121
//!Blocking bool to prevent functions from responding to programatically generated wx events
122
bool programmaticEvent;
123
//!A flag stating if the first update needs a refresh after GL window OK
124
bool requireFirstUpdate;
125
//!Have we set the combo cam/stash text in this session?
126
bool haveSetComboCamText,haveSetComboStashText;
127
//!Are we in the middle of updating the scene?
128
bool currentlyUpdatingScene;
129
//!Have we aborted an update
132
//!source item when dragging a filter in the tree control
133
wxTreeItemId *filterTreeDragSource;
135
//!Drag and drop functionality
136
FileDropTarget *dropTarget;
138
//!Current fullscreen status
139
unsigned int fullscreenState;
141
//!Did the main frame's constructor complete OK?
144
//The type of status message last sent to user
145
unsigned int lastMessageType;
147
//Pointer to version check thread, occasionally initialised at startup to
148
// check online for new program updates
149
VersionCheckThread *verCheckThread;
151
//Map to convert filter drop down choices to IDs
152
map<std::string,size_t> filterMap;
154
//TODO: Refactor - remove me.
155
// True if there are pending updates for the mahthgl window
158
wxTimer *statusTimer;
159
wxTimer *progressTimer;
160
wxTimer *updateTimer; //Periodically calls itself to check for updates from user interaction
161
wxTimer *autoSaveTimer; //Periodically calls itself to create an autosave state file
162
wxMenuItem *checkMenuControlPane;
163
wxMenuItem *checkMenuRawDataPane;
164
wxMenuItem *checkMenuSpectraList;
165
wxMenuItem *menuViewFullscreen;
166
wxMenuItem *checkViewLegend;
167
wxMenuItem *checkViewWorldAxis;
169
wxMenuItem *editUndoMenuItem,*editRedoMenuItem;
170
wxMenuItem *editRangeMenuItem;
171
wxMenuItem *fileSave;
172
wxMenu *recentFilesMenu;
175
wxFileHistory *recentHistory;
176
ProgressData lastProgressData;
179
// begin wxGlade: MainWindowFrame::attributes
180
wxMenuBar* MainFrame_Menu;
181
wxStaticText* lblSettings;
182
wxComboBox* comboStash;
183
wxButton* btnStashManage;
184
wxStaticLine* stashFilterStaticSep;
185
wxStaticText* filteringLabel;
186
wxComboBox* comboFilters;
187
TextTreeCtrl* treeFilters;
188
wxStaticText* lastRefreshLabel;
189
wxListCtrl* listLastRefresh;
190
wxCheckBox* checkAutoUpdate;
191
wxButton* refreshButton;
192
wxButton* btnFilterTreeExpand;
193
wxButton* btnFilterTreeCollapse;
194
wxBitmapButton* btnFilterTreeErrs;
195
wxPanel* filterTreePane;
196
wxStaticText* propGridLabel;
197
wxCustomPropGrid* gridFilterPropGroup;
198
wxPanel* filterPropertyPane;
199
wxSplitterWindow* filterSplitter;
201
wxStaticText* labelCameraName;
202
wxComboBox* comboCamera;
203
wxButton* buttonRemoveCam;
204
wxStaticLine* cameraNamePropertySepStaticLine;
205
wxCustomPropGrid* gridCameraProperties;
206
wxScrolledWindow* noteCamera;
207
wxCheckBox* checkPostProcessing;
208
wxCheckBox* checkFxCrop;
209
wxCheckBox* checkFxCropCameraFrame;
210
wxComboBox* comboFxCropAxisOne;
211
CropPanel* panelFxCropOne;
212
wxComboBox* comboFxCropAxisTwo;
213
CropPanel* panelFxCropTwo;
214
wxStaticText* labelFxCropDx;
215
wxTextCtrl* textFxCropDx;
216
wxStaticText* labelFxCropDy;
217
wxTextCtrl* textFxCropDy;
218
wxStaticText* labelFxCropDz;
219
wxTextCtrl* textFxCropDz;
220
wxPanel* noteFxPanelCrop;
221
wxCheckBox* checkFxEnableStereo;
222
wxStaticText* lblFxStereoMode;
223
wxComboBox* comboFxStereoMode;
224
wxStaticBitmap* bitmapFxStereoGlasses;
225
wxStaticText* labelFxStereoBaseline;
226
wxSlider* sliderFxStereoBaseline;
227
wxCheckBox* checkFxStereoLensFlip;
228
wxPanel* noteFxPanelStereo;
229
wxNotebook* noteEffects;
231
wxStaticText* labelAppearance;
232
wxCheckBox* checkAlphaBlend;
233
wxCheckBox* checkLighting;
234
wxStaticLine* static_line_1;
235
wxStaticText* labelPerformance;
236
wxCheckBox* checkWeakRandom;
237
wxCheckBox* checkLimitOutput;
238
wxTextCtrl* textLimitOutput;
239
wxCheckBox* checkCaching;
240
wxStaticText* labelMaxRamUsage;
241
wxSpinCtrl* spinCachePercent;
243
wxNotebook* notebookControl;
246
BasicGLPane* panelTop;
247
MathGLPane* panelSpectra;
248
wxStaticText* plotListLabel;
250
wxPanel* window_2_pane_2;
251
wxSplitterWindow* splitterSpectra;
252
CopyGrid* gridRawData;
253
wxButton* btnRawDataSave;
254
wxButton* btnRawDataClip;
256
wxTextCtrl* textConsoleOut;
257
wxPanel* noteDataViewConsole;
258
wxNotebook* noteDataView;
259
wxPanel* panelBottom;
260
wxSplitterWindow* splitTopBottom;
262
wxSplitterWindow* splitLeftRight;
263
wxStatusBar* MainFrame_statusbar;
266
//Set the state for the state menu
267
void setSaveStatus();
269
DECLARE_EVENT_TABLE();
272
virtual void OnFileOpen(wxCommandEvent &event); // wxGlade: <event_handler>
273
virtual void OnFileMerge(wxCommandEvent &event); // wxGlade: <event_handler>
274
virtual void OnFileSave(wxCommandEvent &event); // wxGlade: <event_handler>
275
virtual void OnFileSaveAs(wxCommandEvent &event); // wxGlade: <event_handler>
276
virtual void OnFileExportPlot(wxCommandEvent &event); // wxGlade: <event_handler>
277
virtual void OnFileExportImage(wxCommandEvent &event); // wxGlade: <event_handler>
278
virtual void OnFileExportIons(wxCommandEvent &event); // wxGlade: <event_handler>
279
virtual void OnFileExportRange(wxCommandEvent &event); // wxGlade: <event_handler>
280
virtual void OnFileExit(wxCommandEvent &event); // wxGlade: <event_handler>
281
virtual void OnViewControlPane(wxCommandEvent &event); // wxGlade: <event_handler>
282
virtual void OnViewRawDataPane(wxCommandEvent &event); // wxGlade: <event_handler>
283
virtual void OnHelpHelp(wxCommandEvent &event); // wxGlade: <event_handler>
284
virtual void OnHelpContact(wxCommandEvent &event); // wxGlade: <event_handler>
285
virtual void OnHelpAbout(wxCommandEvent &event); // wxGlade: <event_handler>
286
virtual void OnComboStashText(wxCommandEvent &event); // wxGlade: <event_handler>
287
virtual void OnComboStashEnter(wxCommandEvent &event); // wxGlade: <event_handler>
288
virtual void OnComboStash(wxCommandEvent &event); // wxGlade: <event_handler>
289
virtual void OnTreeEndDrag(wxTreeEvent &event); // wxGlade: <event_handler>
290
#if defined(WX_TREE_WORKAROUND)
291
virtual void OnTreeKeyDown(wxKeyEvent &event); // wxGlade: <event_handler>
293
virtual void OnTreeKeyDown(wxTreeEvent &event); // wxGlade: <event_handler>
295
virtual void OnTreeSelectionPreChange(wxTreeEvent &event); // wxGlade: <event_handler>
296
virtual void OnTreeSelectionChange(wxTreeEvent &event); // wxGlade: <event_handler>
297
virtual void OnTreeDeleteItem(wxTreeEvent &event); // wxGlade: <event_handler>
298
virtual void OnTreeBeginDrag(wxTreeEvent &event); // wxGlade: <event_handler>
299
virtual void OnBtnExpandTree(wxCommandEvent &event); // wxGlade: <event_handler>
300
virtual void OnBtnCollapseTree(wxCommandEvent &event); // wxGlade: <event_handler>
301
virtual void OnBtnFilterTreeErrs(wxCommandEvent &event); // wxGlade: <event_handler>
302
virtual void OnComboCameraText(wxCommandEvent &event); // wxGlade: <event_handler>
304
virtual void OnGridFilterPropertyChange(wxGridEvent &event); // wxGlade: <event_handler>
305
virtual void OnComboCameraEnter(wxCommandEvent &event); // wxGlade: <event_handler>
306
virtual void OnComboCamera(wxCommandEvent &event); // wxGlade: <event_handler>
309
virtual void OnEditUndo(wxCommandEvent &event);
310
virtual void OnEditRedo(wxCommandEvent &event);
311
virtual void OnEditRange(wxCommandEvent &event);
312
virtual void OnEditPreferences(wxCommandEvent &event);
314
virtual void OnButtonRemoveCam(wxCommandEvent &event); // wxGlade: <event_handler>
315
virtual void OnCheckPostProcess(wxCommandEvent &event); // wxGlade: <event_handler>
316
virtual void OnFxCropCheck(wxCommandEvent &event); // wxGlade: <event_handler>
317
virtual void OnFxCropCamFrameCheck(wxCommandEvent &event); // wxGlade: <event_handler>
318
virtual void OnFxCropAxisOne(wxCommandEvent &event); // wxGlade: <event_handler>
319
virtual void OnFxCropAxisTwo(wxCommandEvent &event); // wxGlade: <event_handler>
320
virtual void OnFxStereoEnable(wxCommandEvent &event); // wxGlade: <event_handler>
321
virtual void OnFxStereoCombo(wxCommandEvent &event); // wxGlade: <event_handler>
322
virtual void OnFxStereoBaseline(wxScrollEvent &event); // wxGlade: <event_handler>
323
virtual void OnFxStereoLensFlip(wxCommandEvent &event); // wxGlade: <event_handler>
324
virtual void OnButtonStashDialog(wxCommandEvent &event); // wxGlade: <event_handler>
325
virtual void OnCheckAlpha(wxCommandEvent &event); // wxGlade: <event_handler>
326
virtual void OnCheckLighting(wxCommandEvent &event); // wxGlade: <event_handler>
327
virtual void OnCheckCacheEnable(wxCommandEvent &event); // wxGlade: <event_handler>
328
virtual void OnCheckWeakRandom(wxCommandEvent &event); // wxGlade: <event_handler>
329
virtual void OnCacheRamUsageSpin(wxSpinEvent &event); // wxGlade: <event_handler>
330
virtual void OnSpectraListbox(wxCommandEvent &event); // wxGlade: <event_handler>
331
virtual void OnCheckLimitOutput(wxCommandEvent &event); // wxGlade: <event_handler>
332
virtual void OnTextLimitOutput(wxCommandEvent &event); // wxGlade: <event_handler>
333
virtual void OnTextLimitOutputEnter(wxCommandEvent &event); // wxGlade: <event_handler>
335
virtual void OnComboFilterEnter(wxCommandEvent &event); //
336
virtual void OnComboFilter(wxCommandEvent &event); //
338
virtual void OnStatusBarTimer(wxTimerEvent &event); //
339
virtual void OnFilterGridCellEditorShow(wxGridEvent &event); //
340
virtual void OnFilterGridCellEditorHide(wxGridEvent &event); //
341
virtual void OnCameraGridCellEditorShow(wxGridEvent &event); //
342
virtual void OnCameraGridCellEditorHide(wxGridEvent &event); //
343
virtual void OnProgressTimer(wxTimerEvent &event);
344
virtual void OnProgressAbort(wxCommandEvent &event);
345
virtual void OnViewFullscreen(wxCommandEvent &event);
346
virtual void OnButtonRefresh(wxCommandEvent &event);
347
virtual void OnButtonGridCopy(wxCommandEvent &event);
348
virtual void OnButtonGridSave(wxCommandEvent &event);
349
virtual void OnRawDataUnsplit(wxSplitterEvent &event);
350
virtual void OnFilterPropDoubleClick(wxSplitterEvent &event);
351
virtual void OnControlUnsplit(wxSplitterEvent &event);
352
virtual void OnControlSplitMove(wxSplitterEvent &event);
353
virtual void OnFilterSplitMove(wxSplitterEvent &event);
354
virtual void OnTopBottomSplitMove(wxSplitterEvent &event);
355
virtual void OnSpectraUnsplit(wxSplitterEvent &event);
356
virtual void OnViewSpectraList(wxCommandEvent &event);
357
virtual void OnViewPlotLegend(wxCommandEvent &event);
358
virtual void OnViewWorldAxis(wxCommandEvent &event);
359
virtual void OnViewBackground(wxCommandEvent &event);
360
virtual void OnClose(wxCloseEvent &evt);
361
virtual void OnComboCameraSetFocus(wxFocusEvent &evt);
362
virtual void OnComboStashSetFocus(wxFocusEvent &evt);
363
virtual void OnNoteDataView(wxNotebookEvent &evt);
364
virtual void OnGridCameraPropertyChange(wxGridEvent &event); // wxGlade: <event_handler>
366
virtual void OnFileExportVideo(wxCommandEvent &event);
367
virtual void OnFileExportFilterVideo(wxCommandEvent &event);
368
virtual void OnFileExportPackage(wxCommandEvent &event);
369
virtual void OnRecentFile(wxCommandEvent &event); // wxGlade: <event_handler>
371
virtual void OnTreeBeginLabelEdit(wxTreeEvent &evt);
372
virtual void OnTreeEndLabelEdit(wxTreeEvent &evt);
374
virtual void OnUpdateTimer(wxTimerEvent &evt);
375
virtual void OnAutosaveTimer(wxTimerEvent &evt);
377
virtual void OnCheckUpdatesThread(wxCommandEvent &evt);
379
virtual void SetCommandLineFiles(wxArrayString &files);
380
virtual void updateLastRefreshBox();
382
//return type of file, based upon heuristic check
383
static unsigned int guessFileType(const std::string &file);
385
//See if the user wants to save the current state
386
void checkAskSaveState();
388
//Check to see if we need to reload an autosave file (and reload it, as needed)
389
void checkReloadAutosave();
391
//Restore user UI defaults from config file (except panel defaults, which
392
// due to wx behviour need to be done after window show)
393
void restoreConfigDefaults();
394
//Restore panel layout defaults
395
void restoreConfigPanelDefaults();
397
void onPanelSpectraUpdate() {plotUpdates=true;} ;
399
bool initOK() const {return initedOK;}
401
//This is isolated from the layout code, due to "bug" 4815 in wx. The splitter window
402
//does not know how to choose a good size until the window is shown
403
void fixSplitterWindow() {
404
filterSplitter->SplitHorizontally(filterTreePane,filterPropertyPane);
405
restoreConfigPanelDefaults();
409
//Update the enabled status for the range entry in the edit menu
410
void updateEditRangeMenu();
412
}; // wxGlade: end class
415
class FileDropTarget : public wxFileDropTarget
418
MainWindowFrame *frame;
420
FileDropTarget(MainWindowFrame *f) {
424
virtual bool OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& files)
426
frame->OnDropFiles(files, x, y);