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

Generated on 28 Sep 2016 for Hugintrunk by  doxygen 1.4.7