00001
00023 #ifndef _GL_VIEWER_H
00024 #define _GL_VIEWER_H
00025
00026 #include "ViewState.h"
00027 #include "base_wx/platform.h"
00028 #include <wx/glcanvas.h>
00029 #include <utility>
00030 #include <vigra/diff2d.hxx>
00031
00032 class GLRenderer;
00033 class GLPanosphereOverviewRenderer;
00034 class GLPlaneOverviewRenderer;
00035 class TextureManager;
00036 class MeshManager;
00037 class ToolHelper;
00038 class PreviewToolHelper;
00039 class OverviewToolHelper;
00040 class PanosphereOverviewToolHelper;
00041 class PlaneOverviewToolHelper;
00042 class GLPreviewFrame;
00043
00044
00045
00046
00051 class GLViewer: public wxGLCanvas
00052 {
00053 public:
00054 GLViewer(
00055 wxWindow* parent,
00056 PT::Panorama &pano,
00057 int args[],
00058 GLPreviewFrame *frame,
00059 wxGLContext * shared_context = NULL
00060 );
00061 virtual ~GLViewer();
00062 void RedrawE(wxPaintEvent& e);
00063 void Resized(wxSizeEvent& e);
00064 void Redraw();
00065 static void RefreshWrapper(void *obj);
00066 void SetUpContext();
00067 void SetPhotometricCorrect(bool state);
00068 virtual void SetLayoutMode(bool state);
00069 virtual void SetLayoutScale(double scale);
00070
00071 VisualizationState * m_visualization_state;
00072 static ViewState * m_view_state;
00073
00074 void SetActive(bool active) {this->active = active;}
00075 bool IsActive() {return active;}
00076
00077 #if defined __WXGTK__ || wxCHECK_VERSION(2,9,0)
00078 wxGLContext * GetContext() {return m_glContext;}
00079 #endif
00080
00081 void SetViewerBackground(wxColour col);
00082
00084 void SetOverlayText(const wxString text);
00086 void SetOverlayVisibility(const bool isVisible);
00087
00088 protected:
00089 void OnEraseBackground(wxEraseEvent& e);
00090 void MouseMotion(wxMouseEvent& e);
00091 void MouseLeave(wxMouseEvent & e);
00092 void MouseButtons(wxMouseEvent& e);
00093 void MouseWheel(wxMouseEvent& e);
00094 void KeyDown(wxKeyEvent & e);
00095 void KeyUp(wxKeyEvent & e);
00096
00097 DECLARE_EVENT_TABLE()
00098
00099 ToolHelper *m_tool_helper;
00100 GLRenderer *m_renderer;
00101 #if defined __WXGTK__ || wxCHECK_VERSION(2,9,0)
00102 wxGLContext *m_glContext;
00103 #endif
00104 PT::Panorama * m_pano;
00105
00106 wxString m_overlayText;
00107 bool m_overlay;
00108 virtual void setUp() = 0;
00109
00110 bool started_creation, redrawing;
00111 static bool initialised_glew;
00112 vigra::Diff2D offset;
00113 GLPreviewFrame *frame;
00114
00115 bool active;
00116
00117 wxColour m_background_color;
00118 };
00119
00120 class GLPreview : public GLViewer
00121 {
00122 public:
00123 GLPreview(
00124 wxWindow* parent,
00125 PT::Panorama &pano,
00126 int args[],
00127 GLPreviewFrame *frame,
00128 wxGLContext * shared_context = NULL
00129 ) : GLViewer(parent, pano, args, frame, shared_context) {}
00130 void setUp();
00131
00132 };
00133
00134 class GLOverview : public GLViewer
00135 {
00136 public:
00137 GLOverview(
00138 wxWindow* parent,
00139 PT::Panorama &pano,
00140 int args[],
00141 GLPreviewFrame *frame,
00142 wxGLContext * shared_context = NULL
00143 ) : GLViewer(parent, pano, args, frame, shared_context) {
00144 panosphere_m_renderer = 0;
00145 plane_m_renderer = 0;
00146 }
00147
00148 void SetPanosphereMode();
00149 void SetPlaneMode();
00150
00151 void setUp();
00152
00153 virtual void SetLayoutMode(bool state);
00154 virtual void SetLayoutScale(double scale);
00155
00156 enum OverviewMode {
00157 PANOSPHERE,
00158 PLANE
00159 };
00160
00161 void SetMode(OverviewMode mode);
00162 OverviewMode GetMode() {return mode;}
00163
00164 protected:
00165
00166 OverviewMode mode;
00167
00168 PanosphereOverviewVisualizationState * panosphere_m_visualization_state;
00169 PanosphereOverviewToolHelper * panosphere_m_tool_helper;
00170 GLPanosphereOverviewRenderer * panosphere_m_renderer;
00171
00172 PlaneOverviewVisualizationState * plane_m_visualization_state;
00173 PlaneOverviewToolHelper * plane_m_tool_helper;
00174 GLPlaneOverviewRenderer * plane_m_renderer;
00175
00176 };
00177
00178 #endif