GLPreviewFrame.h

Go to the documentation of this file.
00001 // -*- c-basic-offset: 4 -*-
00023 #ifndef _GLPREVIEWFRAME_H
00024 #define _GLPREVIEWFRAME_H
00025 
00026 class GLRenderer;
00027 class wxToolBar;
00028 class wxToggleButton;
00029 class wxCheckBox;
00030 class wxTextCtrl;
00031 class wxBitmapButton;
00032 class wxSpinButton;
00033 class wxScrolledWindow;
00034 class wxBoxSizer;
00035 class wxStaticBoxSizer;
00036 class wxStaticText;
00037 class wxSlider;
00038 class GLViewer;
00039 class GLPreview;
00040 class GLOverview;
00041 class ViewState;
00042 class wxSpinEvent;
00043 class wxChoice;
00044 #if wxCHECK_VERSION(2,9,1)
00045 //forward declaration for wxInfoBar works only for wxGTK
00046 //for other systems wxInfoBar is defined as preprocessor macro and not as class
00047 //class wxInfoBar;
00048 #include <wx/infobar.h>
00049 #endif
00050 
00051 class MeshManager;
00052 
00053 class ToolHelper;
00054 class PreviewToolHelper;
00055 class PanosphereOverviewToolHelper;
00056 class PlaneOverviewToolHelper;
00057 class Tool;
00058 class PreviewTool;
00059 class PreviewCropTool;
00060 class DragTool;
00061 class OverviewDragTool;
00062 class PanosphereOverviewCameraTool;
00063 class PlaneOverviewCameraTool;
00064 class PreviewDragTool;
00065 class PreviewIdentifyTool;
00066 class PreviewDifferenceTool;
00067 class PreviewPanoMaskTool;
00068 class PreviewControlPointTool;
00069 class PreviewLayoutLinesTool;
00070 class PreviewColorPickerTool;
00071 class PreviewEditCPTool;
00072 
00073 class PanosphereOverviewProjectionGridTool;
00074 class PreviewProjectionGridTool;
00075 class PanosphereSphereTool;
00076 
00077 class PanosphereOverviewOutlinesTool;
00078 class PlaneOverviewOutlinesTool;
00079 
00080 class PreviewGuideTool;
00081 
00082 class GLPreviewFrame;
00083 
00084 class GLwxAuiManager;
00085 class GLwxAuiFloatingFrame;
00086 
00087 #include <wx/string.h>
00088 #include <wx/frame.h>
00089 #include <wx/aui/aui.h>
00090 #include <wx/clrpicker.h>
00091 #include "hugin/GuiLevel.h"
00092 
00093 #include <iostream>
00094 
00095 // the image toggle buttons need a special event handler to trap mouse enter and
00096 // leave events.
00097 class ImageToogleButtonEventHandler : public wxEvtHandler
00098 {
00099 public:
00100     ImageToogleButtonEventHandler(unsigned int image_number,
00101                                   wxToolBarToolBase* identify_toolbutton_in,
00102                                   HuginBase::Panorama * m_pano);
00103     void OnChange(wxCommandEvent &e);
00104     void AddIdentifyTool(PreviewIdentifyTool** identify_tool_in);
00105 protected:
00106     void OnEnter(wxMouseEvent & e);
00107     void OnLeave(wxMouseEvent & e);
00108 private:
00109     DECLARE_EVENT_TABLE()
00110     unsigned int image_number;
00111     std::vector<PreviewIdentifyTool**> identify_tools;
00112     wxToolBarToolBase *identify_toolbutton;
00113     HuginBase::Panorama * m_pano;
00114 };
00115 
00116 class ImageGroupButtonEventHandler : public wxEvtHandler
00117 {
00118 public:
00119     ImageGroupButtonEventHandler(unsigned int image_number, GLPreviewFrame* frame_in, HuginBase::Panorama* m_pano);
00120     void OnChange(wxCommandEvent &e);
00121     void AddDragTool(DragTool** drag_tool_in);
00122     void AddIdentifyTool(PreviewIdentifyTool** identify_tool_in);
00123 protected:
00124     void OnEnter(wxMouseEvent & e);
00125     void OnLeave(wxMouseEvent & e);
00126 private:
00127     DECLARE_EVENT_TABLE()
00128     unsigned int image_number;
00129     std::vector<DragTool**> drag_tools;
00130     std::vector<PreviewIdentifyTool**> identify_tools;
00131     GLPreviewFrame* frame;
00132     HuginBase::Panorama * m_pano;
00133 };
00134 
00135 
00139 class GLwxAuiFloatingFrame : public wxAuiFloatingFrame {
00140 public:
00141     GLwxAuiFloatingFrame(wxWindow* parent,
00142                    GLwxAuiManager* owner_mgr,
00143                    const wxAuiPaneInfo& pane,
00144                    wxWindowID id = wxID_ANY,
00145                    long style = wxRESIZE_BORDER | wxSYSTEM_MENU | wxCAPTION |
00146 //                                wxFRAME_NO_TASKBAR | 
00147                                 wxFRAME_FLOAT_ON_PARENT | 
00148                                 wxCLIP_CHILDREN
00149                    ) : wxAuiFloatingFrame(parent, (wxAuiManager*) owner_mgr, pane, id, style) {}
00150 
00151 
00152     void OnActivate(wxActivateEvent& evt);
00153     void OnMoveFinished();
00154 //    void OnClose(wxCloseEvent& event);
00155 
00156     DECLARE_EVENT_TABLE()
00157 
00158 };
00159 
00164 class GLwxAuiManager : public wxAuiManager {
00165 public:
00166     GLwxAuiManager(GLPreviewFrame* frame, GLPreview * preview, GLOverview * overview) : frame(frame), preview(preview), overview(overview) {}
00167     GLwxAuiFloatingFrame* CreateFloatingFrame(wxWindow* parent, const wxAuiPaneInfo& p);
00168     GLPreviewFrame * getPreviewFrame() {return frame;}
00169     GLPreview * getGLPreview() {return preview;}
00170     GLOverview * getGLOverview() {return overview;}
00171 
00172 private:
00173     GLPreviewFrame * frame;
00174     GLPreview * preview;
00175     GLOverview * overview;
00176 };
00177 
00178 
00179 
00187 class GLPreviewFrame : public wxFrame, public HuginBase::PanoramaObserver
00188 {
00189 public:
00190 
00193     GLPreviewFrame(wxFrame * frame, HuginBase::Panorama &pano);
00194 
00197     virtual ~GLPreviewFrame();
00198 
00199     virtual void panoramaChanged(HuginBase::Panorama &pano);
00200     virtual void panoramaImagesChanged(HuginBase::Panorama &pano, const HuginBase::UIntSet &changed);
00201     
00202     void MakePreviewTools(PreviewToolHelper * helper);
00203     void MakePanosphereOverviewTools(PanosphereOverviewToolHelper * helper);
00204     void MakePlaneOverviewTools(PlaneOverviewToolHelper* helper);
00205     
00206     void SetImageButtonColour(unsigned int image_nr, unsigned char red,
00207                               unsigned char green, unsigned char blue);
00208     void SetStatusMessage(wxString message);
00211     void FillBlendChoice();
00213     void LoadOpenGLLayout();
00215     void InitPreviews();
00217     void SetGuiLevel(GuiLevel newLevel);
00218 
00219     GLwxAuiManager* getAuiManager() {return m_mgr;}
00220     GLPreview* getPreview() {return m_GLPreview;}
00221     GLOverview* getOverview() {return m_GLOverview;}
00222 
00223     void PauseResize();
00224     void ContinueResize();
00225     bool CanResize() {return GLresize;}
00226 
00233     void redrawPreview();
00235     void SetShowProjectionHints(bool new_value);
00236     void OnShowEvent(wxShowEvent& e);
00237     
00238     bool individualDragging();
00239     void ToggleImageInDragGroup(unsigned int image_nr, bool update_check_box = true);
00240     void RemoveImageFromDragGroup(unsigned int image_nr, bool update_check_box = true);
00241     void AddImageToDragGroup(unsigned int image_nr, bool update_check_box = true);
00242     void SetDragGroupImages(HuginBase::UIntSet imageDragGroup_in, bool update_check_box = true);
00243     HuginBase::UIntSet GetDragGroupImages();
00244     void ClearDragGroupImages(bool update_check_box = true);
00249     void UpdateGlobalWhiteBalance(double redFactor, double blueFactor);
00250     void UpdateIdentifyTools(std::set<unsigned int> new_image_set);
00251 
00252     wxColour GetPreviewBackgroundColor();
00253     
00254 protected:
00255 
00256     bool GLresize;
00257 
00258     void OnClose(wxCloseEvent& e);
00259 
00260     void OnOverviewToggle(wxCommandEvent& e);
00261 
00262     void OnCenterHorizontally(wxCommandEvent & e);
00263     void OnFitPano(wxCommandEvent& e);
00264     void OnStraighten(wxCommandEvent & e);
00265     void OnShowAll(wxCommandEvent & e);
00266     void OnShowNone(wxCommandEvent & e);
00267     void OnPhotometric(wxCommandEvent & e);
00268     void OnIdentify(wxCommandEvent &e);
00269     void OnAutocrop(wxCommandEvent &e);
00270     void OnStackAutocrop(wxCommandEvent &e);
00271     void OnControlPoint(wxCommandEvent &e);
00272     void OnNumTransform(wxCommandEvent & e);
00273     void OnChangeFOV(wxScrollEvent & e);
00274     void OnTrackChangeFOV(wxScrollEvent & e);
00275     void OnExposureChanged(wxCommandEvent & e);
00276     void OnProjParameterChanged(wxCommandEvent & e);
00278     void OnProjParameterReset(wxCommandEvent & e);
00280     void OnSwitchPreviewGrid(wxCommandEvent & e);
00282     void OnUserExit(wxCommandEvent & e);
00283 
00284     void OnDefaultExposure( wxCommandEvent & e );
00285     void OnDecreaseExposure( wxSpinEvent & e );
00286     void OnIncreaseExposure( wxSpinEvent & e );
00287 
00288     void OnBlendChoice(wxCommandEvent & e);
00289     void OnDragChoice(wxCommandEvent & e);
00290 
00291     void KeyDown(wxKeyEvent & e);
00292     void KeyUp(wxKeyEvent & e);
00293 
00294     void DragChoiceLayout( int index );
00295     void OnProjectionChoice(wxCommandEvent & e);
00296     void OnOverviewModeChoice(wxCommandEvent & e);
00298     void OnROIChanged(wxCommandEvent & e);
00300     void OnResetCrop(wxCommandEvent & e);
00301     void OnHFOVChanged(wxCommandEvent & e);
00302     void OnVFOVChanged(wxCommandEvent & e);
00304     void OnHideProjectionHints(wxCommandEvent &e);
00305     // No HDR display yet
00306     // void OnOutputChoice(wxCommandEvent & e);
00307     // update tools according to blend mode choice
00308     void updateBlendMode();
00309     // update the panorama display
00310     void updatePano();
00312     void OnFullScreen(wxCommandEvent &e);
00314     void OnSelectMode(wxNotebookEvent &e);
00316     void OnToolModeChanging(wxNotebookEvent &e);
00318     void OnLayoutScaleChange(wxScrollEvent &e);
00320     void OnColorPicker(wxCommandEvent &e);
00322     void OnEditCPTool(wxCommandEvent &e);
00324     void OnPreviewBackgroundColorChanged(wxColourPickerEvent & e);
00326     void OnGuideChanged(wxCommandEvent &e);
00328     void OnShowMainFrame(wxCommandEvent &e);
00329     // assistant related event handler
00330     void OnLoadImages( wxCommandEvent & e );
00331     void OnAlign( wxCommandEvent & e );
00332     void OnCreate( wxCommandEvent & e );
00333     void OnLensTypeChanged (wxCommandEvent & e);
00334     void OnFocalLengthChanged(wxCommandEvent & e);
00335     void OnCropFactorChanged(wxCommandEvent & e);
00336 
00338     void OnCreateCP(wxCommandEvent & e);
00340     void OnRemoveCP(wxCommandEvent & e);
00342     void OnMenuClose(wxMenuEvent & e);
00344     void OnSelectContextMenu(wxContextMenuEvent& e);
00346     void OnSelectAllMenu(wxCommandEvent& e);
00347     void OnSelectMedianMenu(wxCommandEvent& e);
00348     void OnSelectDarkestMenu(wxCommandEvent& e);
00349     void OnSelectBrightestMenu(wxCommandEvent& e);
00350     void OnSelectKeepSelection(wxCommandEvent& e);
00351     void OnSelectResetSelection(wxCommandEvent& e);
00352 private:
00356     void EnableGroupCheckboxes(bool isShown);
00361     bool UpdateOverviewMode(int newMode);
00363     void UpdateRoiDisplay(const HuginBase::PanoramaOptions opts);
00365     GLwxAuiManager * m_mgr;
00366 
00367     void SetMode(int newMode);
00368     HuginBase::Panorama & m_pano;
00369 
00370     GLPreview * m_GLPreview;
00371     GLOverview * m_GLOverview;
00372 
00373     GuiLevel m_guiLevel;
00374 
00375     ViewState* m_view_state;
00376 
00377     int m_mode;
00378     int non_layout_blend_mode;
00379     wxToolBar* m_ToolBar_Identify;
00380     wxToolBar* m_ToolBar_ColorPicker;
00381     wxToolBar* m_ToolBar_editCP;
00382     wxNotebook* m_tool_notebook;
00383     wxPanel* m_projection_panel;
00384     wxSlider * m_HFOVSlider;
00385     wxSlider * m_VFOVSlider;
00386     wxTextCtrl * m_HFOVText;
00387     wxTextCtrl * m_VFOVText;
00388     wxTextCtrl * m_ROILeftTxt;
00389     wxTextCtrl * m_ROIRightTxt;
00390     wxTextCtrl * m_ROITopTxt;
00391     wxTextCtrl * m_ROIBottomTxt;
00392     wxChoice * m_BlendModeChoice;
00393     wxChoice * m_DragModeChoice;
00394     wxChoice * m_ProjectionChoice;
00395     wxChoice * m_OverviewModeChoice;
00396     wxChoice * m_GuideChoiceCrop;
00397     wxChoice * m_GuideChoiceDrag;
00398     wxChoice * m_GuideChoiceProj;
00399     // No HDR display yet.
00400     // wxChoice * m_outputModeChoice;
00401     wxTextCtrl * m_exposureTextCtrl;
00402     wxBitmapButton * m_defaultExposureBut;
00403     wxSpinButton * m_exposureSpinBut;
00404 #if wxCHECK_VERSION(2, 9, 1)
00406     wxInfoBar * m_infoBar;
00407 #else
00408     // True if the status bar text has been replaced with projection information
00409     bool m_projectionStatusPushed;
00410 #endif
00411     //assistant related controls
00412     wxStaticText * m_imagesText;
00413     wxButton * m_alignButton;
00414     wxButton * m_createButton;
00415     wxChoice   * m_lensTypeChoice;
00416     wxTextCtrl * m_focalLengthText;
00417     wxTextCtrl * m_cropFactorText;
00418     wxButton   * m_loadLensButton;
00419     wxMenu* m_filemenuSimple;
00420     wxMenu* m_filemenuAdvanced;
00421     wxMenu* m_selectAllMenu;
00422 #if wxCHECK_VERSION(2,9,2)
00423     wxButton* m_selectAllButton;
00424 #else
00425     wxBitmapButton* m_selectAllButton;
00426 #endif
00427     enum SelectAllMode
00428     {
00429         SELECT_ALL_IMAGES = 0,
00430         SELECT_MEDIAN_IMAGES = 1,
00431         SELECT_BRIGHTEST_IMAGES = 2,
00432         SELECT_DARKEST_IMAGES = 3,
00433     };
00434     SelectAllMode m_selectAllMode;
00435     bool m_selectKeepSelection;
00436 
00437     int m_degDigits;
00438 
00439     wxColour m_preview_background_color;
00440 
00441     wxString m_choices[3];
00442     int m_oldProjFormat;
00443     // index of difference mode
00444     int m_differenceIndex;
00445 
00446     wxScrolledWindow * m_ButtonPanel;
00447     wxBoxSizer * m_ButtonSizer;
00448     wxStaticBoxSizer * m_ToggleButtonSizer;
00449 
00450     wxBoxSizer * m_topsizer;
00451     wxBoxSizer * m_projParamSizer;
00452     std::vector<wxStaticText *> m_projParamNamesLabel;
00453     std::vector<wxTextCtrl *>   m_projParamTextCtrl;
00454     std::vector<wxSlider *>     m_projParamSlider;
00455 
00456 #ifdef USE_TOGGLE_BUTTON
00457     std::vector<wxToggleButton *> m_ToggleButtons;
00458 #else
00459     std::vector<wxCheckBox *> m_ToggleButtons;
00460 #endif
00461     std::vector<wxCheckBox *> m_GroupToggleButtons;
00462     std::vector<wxPanel *> m_ToggleButtonPanel;
00463     std::vector<ImageToogleButtonEventHandler *> toogle_button_event_handlers;
00464     std::vector<ImageGroupButtonEventHandler *> toggle_group_button_event_handlers;
00465 
00466     DECLARE_EVENT_TABLE()
00467 
00468     // tools
00469     PreviewToolHelper *preview_helper;
00470     
00471     PreviewCropTool *crop_tool;
00472     HuginBase::UIntSet imageDragGroup;
00473     PreviewDragTool *drag_tool;
00474     PreviewColorPickerTool *color_picker_tool;
00475     PreviewEditCPTool* edit_cp_tool;
00476 
00477     PreviewIdentifyTool *identify_tool;
00478     PreviewIdentifyTool *panosphere_overview_identify_tool;
00479     PreviewIdentifyTool *plane_overview_identify_tool;
00480 
00481     PreviewDifferenceTool *difference_tool;
00482     PreviewDifferenceTool *plane_difference_tool;
00483     PreviewDifferenceTool *panosphere_difference_tool;
00484     
00485     PreviewControlPointTool *preview_control_point_tool;
00486     PreviewControlPointTool *panosphere_control_point_tool;
00487     PreviewControlPointTool *plane_control_point_tool;
00488 
00489     PreviewPanoMaskTool *pano_mask_tool;    
00490 
00491     bool m_showProjectionHints;
00492     PreviewLayoutLinesTool *m_preview_layoutLinesTool;
00493     PreviewLayoutLinesTool *m_panosphere_layoutLinesTool;
00494     PreviewLayoutLinesTool *m_plane_layoutLinesTool;
00495 
00496     PanosphereOverviewProjectionGridTool * overview_projection_grid;
00497     PreviewProjectionGridTool * preview_projection_grid;
00498     PanosphereSphereTool * panosphere_sphere_tool;
00499 
00500     PanosphereOverviewToolHelper *panosphere_overview_helper;
00501 
00502     PlaneOverviewToolHelper *plane_overview_helper;
00503 
00504     OverviewDragTool *overview_drag_tool;
00505 
00506     PanosphereOverviewCameraTool *panosphere_overview_camera_tool;
00507     PlaneOverviewCameraTool *plane_overview_camera_tool;
00508     
00509     PanosphereOverviewOutlinesTool *overview_outlines_tool;
00510     PlaneOverviewOutlinesTool *plane_overview_outlines_tool;
00511 
00512     PreviewGuideTool *preview_guide_tool;
00513 
00514     void TurnOffTools(std::set<Tool*> tools);
00515 
00516 #ifdef __WXGTK__
00517     bool loadedLayout;
00518 #endif
00519 
00523     bool HasNonZeroTranslationPlaneParameters();
00525     void ResetTranslationPlaneParameters();
00526     void CleanButtonColours();
00532     void ShowProjectionWarnings();
00533 };
00534 
00535 
00536 #endif // _GLPREVIEWFRAME_H

Generated on 1 Sep 2015 for Hugintrunk by  doxygen 1.4.7