00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef LUX_WXGLVIEWER_H
00024 #define LUX_WXGLVIEWER_H
00025
00026 #include "wxviewer.h"
00027
00028 #ifdef LUX_USE_OPENGL
00029 #include "wx/wx.h"
00030 #include "wx/glcanvas.h"
00031 #endif // LUX_USE_OPENGL
00032
00033 #include "geometry/point.h"
00034
00035 namespace lux
00036 {
00037
00038 #ifdef LUX_USE_OPENGL
00039
00040 #define ID_ANIMATIONUPDATE 3000
00041
00042 class LuxGLViewer : public wxGLCanvas, public wxViewerBase {
00043 public:
00044 LuxGLViewer(wxWindow *parent, int textureW = 256, int textureH = 256);
00045 ~LuxGLViewer();
00046
00047 protected:
00048 DECLARE_EVENT_TABLE()
00049 void OnPaint(wxPaintEvent &event);
00050 void OnEraseBackground(wxEraseEvent &event);
00051 void OnSize(wxSizeEvent &event);
00052 void OnMouse(wxMouseEvent &event);
00053 void OnTimer(wxTimerEvent &event);
00054
00055
00056 virtual wxWindow* GetWindow();
00057 virtual wxViewerSelection GetSelection();
00058 virtual void SetMode(wxViewerMode mode);
00059 virtual void SetRulersEnabled(bool enabled, bool normalized);
00060 virtual void SetLogoData(const unsigned char *data, unsigned int length) { m_logoData = data; m_logoDataSize = length; }
00061 virtual void SetZoom(const wxViewerSelection *selection);
00062 virtual void SetSelection(const wxViewerSelection *selection);
00063 virtual void SetHighlight(const wxViewerSelection *selection);
00064 virtual void Reload();
00065 virtual void Reset();
00066
00067 private:
00068 void CreateTextures();
00069 void DeleteTextures();
00070 Point TransformPoint(const Point &p);
00071 Point InverseTransformPoint(const Point &p);
00072 void DrawMarchingAnts(const wxViewerSelection &selection, float red, float green, float blue);
00073 void DrawRulers();
00074
00075 wxGLContext m_glContext;
00076
00077 int m_imageW, m_imageH;
00078 const int m_textureW, m_textureH;
00079 int m_tilesX, m_tilesY, m_tilesNr;
00080 unsigned int *m_tileTextureNames;
00081 int m_postScaleOffsetX, m_postScaleOffsetY, m_preScaleOffsetX, m_preScaleOffsetY;
00082 float m_scale;
00083 float m_scaleExp;
00084 int m_viewX, m_viewY;
00085 int m_viewW, m_viewH;
00086 int m_windowW, m_windowH;
00087 int m_prevWindowW, m_prevWindowH;
00088 int m_prevMouseX, m_prevMouseY;
00089 bool m_texturesReady;
00090 bool m_imageChanged;
00091 bool m_useAlpha;
00092
00093 wxTimer* m_animTimer;
00094 int m_stipple;
00095 wxViewerSelection m_selection;
00096 bool m_selectionChanged;
00097 wxViewerSelection m_highlightSel;
00098 bool m_refreshMarchingAntsOnly;
00099 bool m_trackMousePos;
00100 bool m_rulersEnabled;
00101 int m_rulerSize;
00102 bool m_rulersNormalized;
00103 const unsigned char *m_logoData;
00104 unsigned int m_logoDataSize;
00105
00106 wxViewerMode m_controlMode;
00107 wxViewerMode m_displayMode;
00108
00109
00110 class FontGenerator {
00111 public:
00112 FontGenerator();
00113 ~FontGenerator();
00114 void Init();
00115 void DrawText(const char* text, int x=0, int y=0, bool vertical=false);
00116 bool isInitialized;
00117 unsigned int m_texName, m_texW, m_texH;
00118
00119 } m_fontgen;
00120
00121 };
00122
00123 #else // LUX_USE_OPENGL
00124
00125
00126 class LuxGLViewer : public wxWindow, public wxViewerBase {
00127 public:
00128 LuxGLViewer(wxWindow *parent, int textureW = 256, int textureH = 256) {}
00129 virtual wxWindow* GetWindow() { return this; }
00130 };
00131
00132 #endif // LUX_USE_OPENGL
00133
00134 }
00135
00136 #endif // LUX_WXGLVIEWER_H