[3ff100]: src / hugin1 / hugin / GLPreviewFrame.h Maximize Restore History

Download this file

GLPreviewFrame.h    515 lines (437 with data), 17.5 kB

  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
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
// -*- c-basic-offset: 4 -*-
/** @file GLPreviewFrame.h
*
* @author James Legg and Pablo d'Angelo <pablo.dangelo@web.de>
* @author Darko Makreshanski
*
* This 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 software 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this software; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef _GLPREVIEWFRAME_H
#define _GLPREVIEWFRAME_H
class GLRenderer;
class wxToolBar;
class wxToggleButton;
class wxCheckBox;
class wxTextCtrl;
class wxBitmapButton;
class wxSpinButton;
class wxScrolledWindow;
class wxBoxSizer;
class wxStaticBoxSizer;
class wxStaticText;
class wxSlider;
class GLViewer;
class GLPreview;
class GLOverview;
class ViewState;
class wxSpinEvent;
class wxChoice;
#if wxCHECK_VERSION(2,9,1)
//forward declaration for wxInfoBar works only for wxGTK
//for other systems wxInfoBar is defined as preprocessor macro and not as class
//class wxInfoBar;
#include <wx/infobar.h>
#endif
class MeshManager;
class ToolHelper;
class PreviewToolHelper;
class PanosphereOverviewToolHelper;
class PlaneOverviewToolHelper;
class Tool;
class PreviewTool;
class PreviewCropTool;
class DragTool;
class OverviewDragTool;
class PanosphereOverviewCameraTool;
class PlaneOverviewCameraTool;
class PreviewDragTool;
class PreviewIdentifyTool;
class PreviewDifferenceTool;
class PreviewPanoMaskTool;
class PreviewControlPointTool;
class PreviewLayoutLinesTool;
class PreviewColorPickerTool;
class PreviewEditCPTool;
class PanosphereOverviewProjectionGridTool;
class PreviewProjectionGridTool;
class PanosphereSphereTool;
class PanosphereOverviewOutlinesTool;
class PlaneOverviewOutlinesTool;
class PreviewGuideTool;
class GLPreviewFrame;
class GLwxAuiManager;
class GLwxAuiFloatingFrame;
#include <wx/string.h>
#include <wx/frame.h>
#include <wx/aui/aui.h>
#include <wx/clrpicker.h>
#include "hugin/GuiLevel.h"
#include <iostream>
// the image toggle buttons need a special event handler to trap mouse enter and
// leave events.
class ImageToogleButtonEventHandler : public wxEvtHandler
{
public:
ImageToogleButtonEventHandler(unsigned int image_number,
wxToolBarToolBase* identify_toolbutton_in,
PT::Panorama * m_pano);
void OnChange(wxCommandEvent &e);
void AddIdentifyTool(PreviewIdentifyTool** identify_tool_in);
protected:
void OnEnter(wxMouseEvent & e);
void OnLeave(wxMouseEvent & e);
private:
DECLARE_EVENT_TABLE()
unsigned int image_number;
std::vector<PreviewIdentifyTool**> identify_tools;
wxToolBarToolBase *identify_toolbutton;
PT::Panorama * m_pano;
};
class ImageGroupButtonEventHandler : public wxEvtHandler
{
public:
ImageGroupButtonEventHandler(unsigned int image_number, GLPreviewFrame* frame_in, PT::Panorama* m_pano);
void OnChange(wxCommandEvent &e);
void AddDragTool(DragTool** drag_tool_in);
void AddIdentifyTool(PreviewIdentifyTool** identify_tool_in);
protected:
void OnEnter(wxMouseEvent & e);
void OnLeave(wxMouseEvent & e);
private:
DECLARE_EVENT_TABLE()
unsigned int image_number;
std::vector<DragTool**> drag_tools;
std::vector<PreviewIdentifyTool**> identify_tools;
GLPreviewFrame* frame;
PT::Panorama * m_pano;
};
/**
* subclass for a floating frame of the dock manager
*/
class GLwxAuiFloatingFrame : public wxAuiFloatingFrame {
public:
GLwxAuiFloatingFrame(wxWindow* parent,
GLwxAuiManager* owner_mgr,
const wxAuiPaneInfo& pane,
wxWindowID id = wxID_ANY,
long style = wxRESIZE_BORDER | wxSYSTEM_MENU | wxCAPTION |
// wxFRAME_NO_TASKBAR |
wxFRAME_FLOAT_ON_PARENT |
wxCLIP_CHILDREN
) : wxAuiFloatingFrame(parent, (wxAuiManager*) owner_mgr, pane, id, style) {}
void OnActivate(wxActivateEvent& evt);
void OnMoveFinished();
// void OnClose(wxCloseEvent& event);
DECLARE_EVENT_TABLE()
};
/**
* customized subclass of the dock manager, created just for the purpose to create a workaround for the bug that exists while using wxAUI and OpenGL
* the bug is similar to the one described here http://www.kirix.com/forums/viewtopic.php?f=15&t=175
*/
class GLwxAuiManager : public wxAuiManager {
public:
GLwxAuiManager(GLPreviewFrame* frame, GLPreview * preview, GLOverview * overview) : frame(frame), preview(preview), overview(overview) {}
GLwxAuiFloatingFrame* CreateFloatingFrame(wxWindow* parent, const wxAuiPaneInfo& p);
GLPreviewFrame * getPreviewFrame() {return frame;}
GLPreview * getGLPreview() {return preview;}
GLOverview * getGLOverview() {return overview;}
private:
GLPreviewFrame * frame;
GLPreview * preview;
GLOverview * overview;
};
/** The OpenGL preview frame
*
* Contains the GLViewer and various controls for it.
*
* it is not created with XRC, because it is highly dynamic, buttons
* have to be added etc.
*/
class GLPreviewFrame : public wxFrame, public PT::PanoramaObserver, public AppBase::MultiProgressDisplay
{
public:
/** ctor.
*/
GLPreviewFrame(wxFrame * frame, PT::Panorama &pano);
/** dtor.
*/
virtual ~GLPreviewFrame();
void panoramaChanged(PT::Panorama &pano);
void panoramaImagesChanged(PT::Panorama &pano, const PT::UIntSet &changed);
void updateProgressDisplay();
void MakePreviewTools(PreviewToolHelper * helper);
void MakePanosphereOverviewTools(PanosphereOverviewToolHelper * helper);
void MakePlaneOverviewTools(PlaneOverviewToolHelper* helper);
void SetImageButtonColour(unsigned int image_nr, unsigned char red,
unsigned char green, unsigned char blue);
void SetStatusMessage(wxString message);
/** fills the blend wxChoice with all valid blend modes and restore the last used one
*/
void FillBlendChoice();
/** loads the layout of the OpenGL windows and restores it */
void LoadOpenGLLayout();
/** init previews */
void InitPreviews();
/** sets the gui level */
void SetGuiLevel(GuiLevel newLevel);
GLwxAuiManager* getAuiManager() {return m_mgr;}
GLPreview* getPreview() {return m_GLPreview;}
GLOverview* getOverview() {return m_GLOverview;}
void PauseResize();
void ContinueResize();
bool CanResize() {return GLresize;}
/** Display an updated version of the preview images.
* Redraws happen automatically when the panorama changes, and when the
* preview's internal real time sliders are used. This is only needed
* occasionally, such as when a image finishes loading and its place holder
* can be replaced with the real image.
*/
void redrawPreview();
/** set status if projection hints should be shown or not*/
void SetShowProjectionHints(bool new_value);
void OnShowEvent(wxShowEvent& e);
bool individualDragging();
void ToggleImageInDragGroup(unsigned int image_nr, bool update_check_box = true);
void RemoveImageFromDragGroup(unsigned int image_nr, bool update_check_box = true);
void AddImageToDragGroup(unsigned int image_nr, bool update_check_box = true);
void SetDragGroupImages(PT::UIntSet imageDragGroup_in, bool update_check_box = true);
PT::UIntSet GetDragGroupImages();
void ClearDragGroupImages(bool update_check_box = true);
/** updates the global white balance
* @param redFactor multiplies all WhiteBalanceRed of individuel images with this factor
* @param blueFactor multiplies all WhiteBalanceBlue of individuel images with this factor
*/
void UpdateGlobalWhiteBalance(double redFactor, double blueFactor);
void UpdateIdentifyTools(std::set<unsigned int> new_image_set);
wxColour GetPreviewBackgroundColor();
protected:
bool GLresize;
void OnClose(wxCloseEvent& e);
void OnOverviewToggle(wxCommandEvent& e);
void OnCenterHorizontally(wxCommandEvent & e);
void OnFitPano(wxCommandEvent& e);
void OnStraighten(wxCommandEvent & e);
void OnShowAll(wxCommandEvent & e);
void OnShowNone(wxCommandEvent & e);
void OnPhotometric(wxCommandEvent & e);
void OnIdentify(wxCommandEvent &e);
void OnAutocrop(wxCommandEvent &e);
void OnStackAutocrop(wxCommandEvent &e);
void OnControlPoint(wxCommandEvent &e);
void OnNumTransform(wxCommandEvent & e);
void OnChangeFOV(wxScrollEvent & e);
void OnTrackChangeFOV(wxScrollEvent & e);
void OnExposureChanged(wxCommandEvent & e);
void OnProjParameterChanged(wxCommandEvent & e);
/** event handler for reset projection parameters */
void OnProjParameterReset(wxCommandEvent & e);
/** event handler for switch on/off grid on preview */
void OnSwitchPreviewGrid(wxCommandEvent & e);
/** user wants to quit program */
void OnUserExit(wxCommandEvent & e);
void OnDefaultExposure( wxCommandEvent & e );
void OnDecreaseExposure( wxSpinEvent & e );
void OnIncreaseExposure( wxSpinEvent & e );
void OnBlendChoice(wxCommandEvent & e);
void OnDragChoice(wxCommandEvent & e);
void KeyDown(wxKeyEvent & e);
void KeyUp(wxKeyEvent & e);
void DragChoiceLayout( int index );
void OnProjectionChoice(wxCommandEvent & e);
void OnOverviewModeChoice(wxCommandEvent & e);
/** event handler for changed roi */
void OnROIChanged(wxCommandEvent & e);
/** event handler to reset crop area */
void OnResetCrop(wxCommandEvent & e);
void OnHFOVChanged(wxCommandEvent & e);
void OnVFOVChanged(wxCommandEvent & e);
/** event handler when user hides the infobar */
void OnHideProjectionHints(wxCommandEvent &e);
// No HDR display yet
// void OnOutputChoice(wxCommandEvent & e);
// update tools according to blend mode choice
void updateBlendMode();
// update the panorama display
void updatePano();
/** event handler for full screen */
void OnFullScreen(wxCommandEvent &e);
/** event handler for selection of new mode */
void OnSelectMode(wxNotebookEvent &e);
/** event handler for blocking changing mode when panorama contains no images*/
void OnToolModeChanging(wxNotebookEvent &e);
/** event handler for change scale of layout mode */
void OnLayoutScaleChange(wxScrollEvent &e);
/** event handler when starting color picker */
void OnColorPicker(wxCommandEvent &e);
/** event handler when starting edit cp tool */
void OnEditCPTool(wxCommandEvent &e);
/** event handler when user changes background color */
void OnPreviewBackgroundColorChanged(wxColourPickerEvent & e);
/** event handler when user selects different guide */
void OnGuideChanged(wxCommandEvent &e);
/** event handler to show main frame */
void OnShowMainFrame(wxCommandEvent &e);
// assistant related event handler
void OnLoadImages( wxCommandEvent & e );
void OnAlign( wxCommandEvent & e );
void OnCreate( wxCommandEvent & e );
void OnLensTypeChanged (wxCommandEvent & e);
void OnFocalLengthChanged(wxCommandEvent & e);
void OnCropFactorChanged(wxCommandEvent & e);
/** handler for creating cp in pano space */
void OnCreateCP(wxCommandEvent & e);
/** handler to remove cp */
void OnRemoveCP(wxCommandEvent & e);
/** handle menu close event */
void OnMenuClose(wxMenuEvent & e);
private:
/** changes the visibility of the group check boxes
* @param isShown true if the group checkboxes should be visible
*/
void EnableGroupCheckboxes(bool isShown);
/** updates the mode of the overview window
* @param newMode overview mode which should be setted
* @return true, of mode was successful changed to desired mode
*/
bool UpdateOverviewMode(int newMode);
/** update display of ROI */
void UpdateRoiDisplay(const HuginBase::PanoramaOptions opts);
/** The dock manager */
GLwxAuiManager * m_mgr;
void SetMode(int newMode);
PT::Panorama & m_pano;
GLPreview * m_GLPreview;
GLOverview * m_GLOverview;
GuiLevel m_guiLevel;
ViewState* m_view_state;
int m_mode;
int non_layout_blend_mode;
wxToolBar* m_ToolBar_Identify;
wxToolBar* m_ToolBar_ColorPicker;
wxToolBar* m_ToolBar_editCP;
wxNotebook* m_tool_notebook;
wxPanel* m_projection_panel;
wxSlider * m_HFOVSlider;
wxSlider * m_VFOVSlider;
wxTextCtrl * m_HFOVText;
wxTextCtrl * m_VFOVText;
wxTextCtrl * m_ROILeftTxt;
wxTextCtrl * m_ROIRightTxt;
wxTextCtrl * m_ROITopTxt;
wxTextCtrl * m_ROIBottomTxt;
wxChoice * m_BlendModeChoice;
wxChoice * m_DragModeChoice;
wxChoice * m_ProjectionChoice;
wxChoice * m_OverviewModeChoice;
wxChoice * m_GuideChoiceCrop;
wxChoice * m_GuideChoiceDrag;
wxChoice * m_GuideChoiceProj;
// No HDR display yet.
// wxChoice * m_outputModeChoice;
wxTextCtrl * m_exposureTextCtrl;
wxBitmapButton * m_defaultExposureBut;
wxSpinButton * m_exposureSpinBut;
#if wxCHECK_VERSION(2, 9, 1)
/// Bar for context sensitive projection information.
wxInfoBar * m_infoBar;
#else
// True if the status bar text has been replaced with projection information
bool m_projectionStatusPushed;
#endif
//assistant related controls
wxStaticText * m_imagesText;
wxButton * m_alignButton;
wxButton * m_createButton;
wxChoice * m_lensTypeChoice;
wxTextCtrl * m_focalLengthText;
wxTextCtrl * m_cropFactorText;
wxButton * m_loadLensButton;
wxMenu* m_filemenuSimple;
int m_degDigits;
wxColour m_preview_background_color;
wxString m_choices[3];
int m_oldProjFormat;
// index of difference mode
int m_differenceIndex;
wxScrolledWindow * m_ButtonPanel;
wxBoxSizer * m_ButtonSizer;
wxStaticBoxSizer * m_ToggleButtonSizer;
wxBoxSizer * m_topsizer;
wxBoxSizer * m_projParamSizer;
std::vector<wxStaticText *> m_projParamNamesLabel;
std::vector<wxTextCtrl *> m_projParamTextCtrl;
std::vector<wxSlider *> m_projParamSlider;
#ifdef USE_TOGGLE_BUTTON
std::vector<wxToggleButton *> m_ToggleButtons;
#else
std::vector<wxCheckBox *> m_ToggleButtons;
#endif
std::vector<wxCheckBox *> m_GroupToggleButtons;
std::vector<wxPanel *> m_ToggleButtonPanel;
std::vector<ImageToogleButtonEventHandler *> toogle_button_event_handlers;
std::vector<ImageGroupButtonEventHandler *> toggle_group_button_event_handlers;
DECLARE_EVENT_TABLE()
// tools
PreviewToolHelper *preview_helper;
PreviewCropTool *crop_tool;
PT::UIntSet imageDragGroup;
PreviewDragTool *drag_tool;
PreviewColorPickerTool *color_picker_tool;
PreviewEditCPTool* edit_cp_tool;
PreviewIdentifyTool *identify_tool;
PreviewIdentifyTool *panosphere_overview_identify_tool;
PreviewIdentifyTool *plane_overview_identify_tool;
PreviewDifferenceTool *difference_tool;
PreviewDifferenceTool *plane_difference_tool;
PreviewDifferenceTool *panosphere_difference_tool;
PreviewControlPointTool *preview_control_point_tool;
PreviewControlPointTool *panosphere_control_point_tool;
PreviewControlPointTool *plane_control_point_tool;
PreviewPanoMaskTool *pano_mask_tool;
bool m_showProjectionHints;
PreviewLayoutLinesTool *m_preview_layoutLinesTool;
PreviewLayoutLinesTool *m_panosphere_layoutLinesTool;
PreviewLayoutLinesTool *m_plane_layoutLinesTool;
PanosphereOverviewProjectionGridTool * overview_projection_grid;
PreviewProjectionGridTool * preview_projection_grid;
PanosphereSphereTool * panosphere_sphere_tool;
PanosphereOverviewToolHelper *panosphere_overview_helper;
PlaneOverviewToolHelper *plane_overview_helper;
OverviewDragTool *overview_drag_tool;
PanosphereOverviewCameraTool *panosphere_overview_camera_tool;
PlaneOverviewCameraTool *plane_overview_camera_tool;
PanosphereOverviewOutlinesTool *overview_outlines_tool;
PlaneOverviewOutlinesTool *plane_overview_outlines_tool;
PreviewGuideTool *preview_guide_tool;
void TurnOffTools(std::set<Tool*> tools);
#ifdef __WXGTK__
bool loadedLayout;
#endif
/** check, if panorama has non-zero translation plane parameters
* @returns true, if panorama has non-zero translation parameters
*/
bool HasNonZeroTranslationPlaneParameters();
/** resets all translation plane parameters to zero */
void ResetTranslationPlaneParameters();
void CleanButtonColours();
/** Tell the user anything suspicious about the projection choice.
* If nothing is suspicious, any previous message is removed.
* In wxWidgets 2.9, this appears as an wxInfoBar. Older versions do not
* have this. so the status bar is used instead.
*/
void ShowProjectionWarnings();
};
#endif // _GLPREVIEWFRAME_H