Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ImageCanvasGLBase.hh
1 #ifndef __ImageCanvasGLBase_hh__
2 #define __ImageCanvasGLBase_hh__
3 
4 // must be first
5 #include "biasgl.h"
6 #include <bias_config.h>
7 
8 #ifndef BIAS_HAVE_WXWIDGETS
9 # error Please recompile BIAS with USE_WXWIDGETS to use this lib.
10 #endif // BIAS_HAVE_WXWIDGETS
11 
12 #ifndef BIAS_HAVE_OPENGL
13 # error Please recompile BIAS with USE_OPENGL to use this lib.
14 #endif // BIAS_HAVE_OPENGL
15 
16 // BIAS
17 #include <Gui/OpenGLCanvas.hh>
18 #include <Gui/ImgObjGL.hh>
19 #include <Base/Image/ImageBase.hh>
20 
21 // STD
22 #include <string>
23 
24 namespace BIAS {
25  /**
26  @class ImageCanvasGLBase
27  @ingroup g_gui
28  @brief 2D image display canvas using OpenGL rendering internally.
29 
30  Thus zooming, interpolation etc is easy and very fast.
31  In particular useful if you use shared contexts to display OPenGL Image (ids).
32  This class should not have extended dependencies.
33  Use The CG Version to display non power of two textures bceause you need a shder for display.
34 
35  An OpenGL texture (id) is displayed.
36  This can be created by feeding in a BIAS image, the "value" image.
37 
38  Thus the true values from "valueimage" are displayed even with fewer bit depth display.
39  \author Jan Woetzel */
40  class BIASGui_EXPORT ImageCanvasGLBase : public BIAS::OpenGLCanvas
41  {
42  public:
43  virtual ~ImageCanvasGLBase(); ///< destructor
44 
45  // ctors
47  wxFrame* parent
48  ,wxWindowID id = -1
49  ,const wxPoint& pos = wxDefaultPosition
50  ,const wxSize& size = wxDefaultSize
51  ,long style = 0
52  ,const wxString& name = AsciiToWx("ImageCanvasGLBase")
53  ,int* attribList = NULL
54  ,const wxPalette& palette = wxNullPalette );
55 
56  ///
57  /// constructor using a shared context
59  wxFrame* parent
60  ,wxGLContext* sharedContext = NULL
61  ,wxWindowID id = -1
62  ,const wxPoint& pos = wxDefaultPosition
63  ,const wxSize& size = wxDefaultSize
64  ,long style=0
65  ,const wxString& name=AsciiToWx("ImageCanvasGLBase")
66  ,int* attribList = 0
67  ,const wxPalette& palette = wxNullPalette );
68 
69  virtual void DisplayCalls();
70 
71  virtual void InitMembers();
72 
73  // unique id for OpenGL texture object
74  GLuint GetTexId() const;
75 
76  // GL_TEXTURE_2D or GL_TEXTURE_RECTANGLE_NV
77  GLenum GetTexTarget() const;
78 
79  bool ValidTexobj(const ImgObjGL & t) const;
80 
81  /** feed in an existing, possibly shared, GL texture obj for display
82  note: it is *no* good idea to call thsi method Show because it conflicts with WX::Show(bool) (JW) */
83  int Set(const ImgObjGL & NewTexobj,
84  const std::string & name=std::string("ImgObjGL") );
85 
86  int Set(
87  BIAS::ImageBase & img,
88  //BIAS::Image<unsigned char>& img,
89  const std::string & name=std::string("Image<unsigned char>"),
90  const bool & forcePow2tex=true,
91  const bool & flipY=true
92  );
93 
94  /** sets imaeg as a RECT texture JW */
95  int SetRECT(
96  BIAS::ImageBase & img,
97  //BIAS::Image<unsigned char>& img,
98  const std::string & name=std::string("RECT Image<unsigned char>"),
99  const bool & flipY=true
100  );
101 
102 
103  //int Set(BIAS::ImageBase& img, const std::string & name=std::string("ImageBase"));
104 
105 
106  //void CreateTexObjFromValueImage_andBind();
107 
108  ImgObjGL GetTexobj() const {return texobj;};
109  ImgObjGL & GetTexobj() {return texobj;};
110 
111  /** set to true for prettier OpenGL texture mipmapping display (which costs performance) JW */
112  void EnableMipMapping(const bool & avoidAliasingByMipmapping=true);
113 
114 
115 
116  protected:
117  // OpenGL texture really used for display:
118  // textraget must be GL_TEXTURE_2D in this Base class
119  // because a shader is required to display a GL_TEXTURE_RECTANGLE_NV
120  // look for a derived class adding Cg shaders to use rectangle textures without padding them to pow2.
121  // holds all gl specific texture information
123 
124  // name identifier
125  std::string name;
126 
127  // 0..1 (Orig) coordinate of an interest point used to determine a zoom region
129  // scale factor for zoom, >1 to zoom in
130  float scalefactor;
131 
132  //DECLARE_EVENT_TABLE();
133  }; // ImageCanvasGL
134 
135 } // namespace BIAS
136 
137 #endif
wxString AsciiToWx(const char *thestring)
Converts a C string to a wxString.
Definition: StringConv.hh:32
OpenGL canvases with additinal event handling (JW)
Definition: OpenGLCanvas.hh:68
data holder describing OpenGL texture objects in addition to its unique texID.
Definition: ImgObjGL.hh:34
ImgObjGL GetTexobj() const
2D image display canvas using OpenGL rendering internally.
BIAS::Vector2< float > InterestPoint
This is the base class for images in BIAS.
Definition: ImageBase.hh:102