~ubuntu-branches/debian/stretch/3depict/stretch

« back to all changes in this revision

Viewing changes to .pc/wx3-startup/src/gui/mainFrame.h

  • Committer: Package Import Robot
  • Author(s): D Haley
  • Date: 2014-06-09 22:54:00 UTC
  • Revision ID: package-import@ubuntu.com-20140609225400-mxteq4a0xq9cfws3
Tags: 0.0.16-2
Add wx 3.0 startup patch (Closes: #746609)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *      3Depict.h - main program header
 
3
 *      Copyright (C) 2013 D Haley
 
4
 *
 
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.
 
9
 
 
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.
 
14
 
 
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/>.
 
17
*/
 
18
 
 
19
 
 
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>
 
28
#include <wx/dnd.h>
 
29
#include <wx/grid.h>
 
30
#include <wx/treectrl.h>
 
31
#if wxCHECK_VERSION(2,9,0)
 
32
#include <wx/filehistory.h>
 
33
#endif
 
34
// end wxGlade
 
35
 
 
36
//Local stuff
 
37
#include "wx/wxcommon.h"
 
38
#include "wx/wxcomponents.h"
 
39
#include "glPane.h"
 
40
#include "mathglPane.h"
 
41
#include "cropPanel.h" // cropping tools
 
42
 
 
43
#include "backend/viscontrol.h"
 
44
#include "backend/configFile.h"
 
45
 
 
46
#ifndef THREEDEPICT_H 
 
47
#define THREEDEPICT_H
 
48
 
 
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
 
52
#endif
 
53
 
 
54
class FileDropTarget;
 
55
 
 
56
enum
 
57
{
 
58
        MESSAGE_ERROR=1,
 
59
        MESSAGE_INFO,
 
60
        MESSAGE_HINT,
 
61
        MESSAGE_NONE_BUT_HINT,
 
62
        MESSAGE_NONE
 
63
};
 
64
 
 
65
class MainWindowFrame: public wxFrame {
 
66
public:
 
67
    // begin wxGlade: MainWindowFrame::ids
 
68
    // end wxGlade
 
69
 
 
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();
 
72
 
 
73
    //Drop the following files onto the given window XY coordinates.
 
74
    void OnDropFiles(const wxArrayString &files, int x, int y);
 
75
 
 
76
    bool isCurrentlyUpdatingScene() const { return currentlyUpdatingScene;};
 
77
 
 
78
    void linkCropWidgets();
 
79
 
 
80
    wxSize getNiceWindowSize() const ;
 
81
 
 
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;
 
85
 
 
86
private:
 
87
    // begin wxGlade: MainWindowFrame::methods
 
88
    void set_properties();
 
89
    void do_layout();
 
90
    // end wxGlade
 
91
   
 
92
        //!Give a message in the satus bar
 
93
        void statusMessage(const char *message, unsigned int messageType=MESSAGE_ERROR); 
 
94
 
 
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
 
98
        bool doSceneUpdate();
 
99
 
 
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);
 
104
 
 
105
        //!Load any errors that were detected in the last refresh into the filter tree
 
106
        void setFilterTreeAnalysisImages(); 
 
107
 
 
108
        //!Update the effects UI from some effects vector
 
109
        void updateFxUI(const vector<const Effect *> &fx);
 
110
 
 
111
        void setLockUI(bool amlocking,unsigned int lockMode);
 
112
 
 
113
        //Did the opengl panel initialise correctly?
 
114
        bool glPanelOK;
 
115
        //!Scene - user interaction interface "visualisation control"
 
116
        VisController visControl;
 
117
 
 
118
        //!Program on-disk configuration class
 
119
        ConfigFile configFile;
 
120
 
 
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
 
130
        bool haveAborted;
 
131
 
 
132
        //!source item when dragging a filter in the tree control
 
133
        wxTreeItemId *filterTreeDragSource;
 
134
 
 
135
        //!Drag and drop functionality
 
136
        FileDropTarget *dropTarget;
 
137
        
 
138
        //!Current fullscreen status
 
139
        unsigned int fullscreenState;
 
140
 
 
141
        //!Did the main frame's constructor complete OK?
 
142
        bool initedOK;
 
143
 
 
144
        //The type of status message last sent to user
 
145
        unsigned int lastMessageType;
 
146
 
 
147
        //Pointer to version check thread, occasionally initialised at startup to
 
148
        // check online for new program updates
 
149
        VersionCheckThread *verCheckThread;
 
150
 
 
151
        //Map to convert filter drop down choices to IDs
 
152
        map<std::string,size_t> filterMap;
 
153
   
 
154
        //TODO: Refactor -  remove me.
 
155
        // True if there are pending updates for the mahthgl window
 
156
        bool plotUpdates;
 
157
protected:
 
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;
 
168
 
 
169
    wxMenuItem *editUndoMenuItem,*editRedoMenuItem;
 
170
    wxMenuItem *editRangeMenuItem;
 
171
    wxMenuItem *fileSave;
 
172
    wxMenu *recentFilesMenu;
 
173
    wxMenu *fileMenu;
 
174
    wxMenu *fileExport;
 
175
    wxFileHistory *recentHistory;
 
176
    ProgressData lastProgressData;
 
177
 
 
178
 
 
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;
 
200
    wxPanel* noteData;
 
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;
 
230
    wxPanel* notePost;
 
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;
 
242
    wxPanel* noteTools;
 
243
    wxNotebook* notebookControl;
 
244
    wxPanel* panelLeft;
 
245
    wxPanel* panelView;
 
246
    BasicGLPane* panelTop;
 
247
    MathGLPane* panelSpectra;
 
248
    wxStaticText* plotListLabel;
 
249
    wxListBox* plotList;
 
250
    wxPanel* window_2_pane_2;
 
251
    wxSplitterWindow* splitterSpectra;
 
252
    CopyGrid* gridRawData;
 
253
    wxButton* btnRawDataSave;
 
254
    wxButton* btnRawDataClip;
 
255
    wxPanel* noteRaw;
 
256
    wxTextCtrl* textConsoleOut;
 
257
    wxPanel* noteDataViewConsole;
 
258
    wxNotebook* noteDataView;
 
259
    wxPanel* panelBottom;
 
260
    wxSplitterWindow* splitTopBottom;
 
261
    wxPanel* panelRight;
 
262
    wxSplitterWindow* splitLeftRight;
 
263
    wxStatusBar* MainFrame_statusbar;
 
264
    // end wxGlade
 
265
 
 
266
    //Set the state for the state menu
 
267
    void setSaveStatus();
 
268
 
 
269
    DECLARE_EVENT_TABLE();
 
270
 
 
271
public:
 
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>
 
292
#else
 
293
     virtual void OnTreeKeyDown(wxTreeEvent &event); // wxGlade: <event_handler>
 
294
#endif
 
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>
 
303
 
 
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>
 
307
    
 
308
 
 
309
    virtual void OnEditUndo(wxCommandEvent &event);    
 
310
    virtual void OnEditRedo(wxCommandEvent &event);    
 
311
    virtual void OnEditRange(wxCommandEvent &event);    
 
312
    virtual void OnEditPreferences(wxCommandEvent &event);    
 
313
   
 
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>
 
334
 
 
335
    virtual void OnComboFilterEnter(wxCommandEvent &event); // 
 
336
    virtual void OnComboFilter(wxCommandEvent &event); // 
 
337
    
 
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>
 
365
 
 
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>
 
370
 
 
371
    virtual void OnTreeBeginLabelEdit(wxTreeEvent &evt);
 
372
    virtual void OnTreeEndLabelEdit(wxTreeEvent &evt);
 
373
    
 
374
    virtual void OnUpdateTimer(wxTimerEvent &evt);
 
375
    virtual void OnAutosaveTimer(wxTimerEvent &evt);
 
376
 
 
377
    virtual void OnCheckUpdatesThread(wxCommandEvent &evt);
 
378
 
 
379
    virtual void SetCommandLineFiles(wxArrayString &files);
 
380
    virtual void updateLastRefreshBox();
 
381
 
 
382
    //return type of file, based upon heuristic check
 
383
    static unsigned int guessFileType(const std::string &file);
 
384
 
 
385
    //See if the user wants to save the current state
 
386
    void checkAskSaveState();
 
387
    
 
388
    //Check to see if we need to reload an autosave file (and reload it, as needed)
 
389
    void checkReloadAutosave();
 
390
 
 
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();
 
396
 
 
397
    void onPanelSpectraUpdate() {plotUpdates=true;} ;
 
398
 
 
399
    bool initOK() const {return initedOK;}
 
400
 
 
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();
 
406
                };
 
407
 
 
408
 
 
409
    //Update the enabled status for the range entry in the edit menu
 
410
    void updateEditRangeMenu();
 
411
 
 
412
}; // wxGlade: end class
 
413
 
 
414
 
 
415
class FileDropTarget : public wxFileDropTarget
 
416
{
 
417
private:
 
418
        MainWindowFrame *frame;
 
419
public:
 
420
        FileDropTarget(MainWindowFrame *f) {
 
421
                frame = f;
 
422
        }
 
423
 
 
424
        virtual bool OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& files)
 
425
        {
 
426
                frame->OnDropFiles(files, x, y);
 
427
 
 
428
                return true;
 
429
        };
 
430
 
 
431
};
 
432
 
 
433
#endif