Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ImageCanvas.hh
1 #ifndef __ImageCanvas_hh__
2 #define __ImageCanvas_hh__
3 
4 
5 
6 // this should not be necessary because it is already checked in the CMakeLists.txt
7 //#ifndef BIAS_HAVE_WXWIDGETS
8 //# error BIAS_HAVE_WXWIDGETS not defined but required by ImageCanvas. Please enable BIAS_HAVE_WXWIDGETS in CMake configure step.
9 //#endif
10 #include <wx/wx.h>
11 #include <wx/dcbuffer.h>
12 #include <wx/thread.h>
13 
14 #include <bias_config.h>
15 #include <Base/Common/BIASpragmaStart.hh>
16 #include <Base/Common/BIASpragmaEnd.hh>
17 #include <Base/Debug/Debug.hh>
18 #include <Base/Image/Image.hh>
19 
20 
21 
22 #define D_IC_IM (1<<0)
23 
24 
25 namespace BIAS{
26 
27  class ZoomFrame;
28  class HistoFrame;
29  class ImageLegendFrame;
30  template <class T> class PyramidImage;
31 
32 
33  /** @class ImageCanvas
34  @ingroup g_gui
35  @brief display image in wx application, provides zoom and investigation
36  functionality
37  @author woelk */
38  class BIASGui_EXPORT ImageCanvas
39  : public wxScrolledWindow, public BIAS::Debug
40  {
41  public:
42  ImageCanvas(wxWindow* parent, wxStatusBar* sbar=NULL,
43  int sbarid=0, wxWindowID id = -1,
44  const wxPoint& pos = wxDefaultPosition,
45  const wxSize& size = wxSize(320, 240),
46  long style = ( (wxHSCROLL | wxVSCROLL) & wxTRANSPARENT),
47  const wxString& name = wxT("ScrolledWindow"));
48  ~ImageCanvas();
49 
50 
51  virtual void Show(BIAS::Image<unsigned char>& im, std::string name="");
52  virtual void Show(BIAS::ImageBase& origim, BIAS::Image<unsigned char>& scaledrgbim,
53  std::string name="");
54  virtual void Show(BIAS::PyramidImage<unsigned char>& pim, std::string name="");
55 
56  //returns the position of the histogramm window
57  wxPoint GetHistoPos();
58  //returns the size of the histogramm window
59  wxSize GetHistoSize();
60  //returns the position of the histogramm window
61  wxPoint GetValueBarPos();
62  //returns the size of the histogramm window
63  wxSize GetValueBarSize();
64 
65  //The Method that shows Histogramm-Window if it's not visible yet
66  void ShowHistogramm(wxPoint pos = wxPoint(10,10),
67  wxSize size = wxSize(100,100));
68  void ShowHistogramm(ImageBase& image,
69  wxPoint pos = wxPoint(10,10),
70  wxSize size = wxSize(100,100));
71 
72  void ShowImageValueBar(wxPoint pos = wxPoint(10,10),
73  wxSize size = wxSize(100,100));
74  void ShowImageValueBar(ImageBase& image,
75  wxPoint pos = wxPoint(10,10),
76  wxSize size = wxSize(100,100));
77  void HideImageValueBar();
78 
79  // to let user access classic hide/show function
80  virtual bool Show(bool show=true) {return wxScrolledWindow::Show(show);}
81 
82  inline BIAS::ImageBase *GetOrigImage() { return &origim_; }
83  //return the 3 channel image which is displays on screen
84  inline BIAS::Image<unsigned char>* GetImageShown(){ return &rgbim_;}
85 
86  bool GetMousePos(int &x, int &y);
87 
88  inline void SetDefaultZoom(unsigned z)
89  { DefaultZoom_=z; }
90 
91  /**
92  * Canvas now uses double buffering to avoid flickering, so it should be ok
93  * to always clear the canvas.
94  */
95  inline void SetClearDrawingContext(bool clear)
96  { ClearDrawingContext_=clear; }
97 
98  inline void SetShowScaled(bool on){ShowScaled_ = on;}
99  inline bool GetShowScaled(){return ShowScaled_;}
100 
101  /** Sets the size of the scaled image. Only used if show scaled is on. */
102  inline void SetScaledImageSize(int width, int height)
103  {
104  ScaledImageSizeX_ = width;
105  ScaledImageSizeY_ = height;
106  }
107 
108  /**
109  Set the quality used for image size rescaling
110  false: Uses the normal default scaling method of pixel replication
111  true: Uses bicubic and box averaging resampling methods for upsampling
112  and downsampling respectively
113  */
114  inline void SetHighScaleQuality(bool on)
115  {
116  UseHighScaleQuality_ = on;
117  }
118 
119  bool HistogrammIsShown();
120  bool ImageValueBarIsShown();
121  void KeepScrollPosition(bool flag);
122 
123  /** \brief Set the color which is used to draw the roi. */
124  void SetRoiColor(unsigned char red,unsigned char green,
125  unsigned char blue, unsigned alpha = 128);
126  inline void DrawRoi(bool enable){ DrawRoi_ = enable; Refresh();}
127  inline bool IsRoiDrawn(){return DrawRoi_; }
128  // raises or lowers the zoom window if it is shown
129  void RaiseZoomWindow(const bool raise_or_lower);
130 
131  protected:
132  void InitHisto(wxPoint pos = wxPoint(10,10),
133  wxSize size = wxSize(100,100));
134  void InitImageValueBar(wxPoint pos = wxPoint(10,10),
135  wxSize size = wxSize(100,100));
136 
137  void UpdateStatusBar(unsigned x, unsigned y);
138  void Zoom(unsigned x, unsigned y);
139 
140  virtual void OnPaint(wxPaintEvent& event);
141  virtual void OnErase(wxEraseEvent& event);
142  virtual void OnSize(wxSizeEvent& event);
143  virtual void OnMouseMove(wxMouseEvent &event);
144  virtual void OnMouseLeave(wxMouseEvent &event);
145  virtual void OnMouseEnter(wxMouseEvent &event);
146  virtual void OnMouseWheel(wxMouseEvent &event);
147  virtual void OnRightMouseButton(wxMouseEvent &event);
148  virtual void OnLeftMouseButton(wxMouseEvent &event);
149  virtual void OnKeyPress(wxKeyEvent &event);
150  virtual void PaintRoiOnDc_(wxBufferedPaintDC& dc);
151 
155 
159 
160  wxBitmap *RoiBitmap_;
161  wxBitmap *Bitmap_;
162  wxImage *wxRoiImage_;
163  wxImage *wximage_;
164  wxMutex wxbitmap_mutex_, origim_mutex_;
165  wxStatusBar *SBar_;
166 
167  // for scaled-down display
169  bool DrawRoi_;
171  // Canvas now uses double buffering to avoid flickering,
172  // so it should be ok to always clear the canvas.
174 
175  int ScaledImageSizeX_,ScaledImageSizeY_;
177  int SBarID_;
178  int SBarWidths_[2];
179  int mousex_, mousey_;
180 
181  unsigned DefaultZoom_;
182  unsigned width_, height_;
183  unsigned lastwidth_, lastheight_;
184 
185  std::string ImageName_;
186  wxString Title_;
187 
188  DECLARE_EVENT_TABLE()
189  }; // ImageCanvas
190 } // namespace
191 
192 #endif // __ImageCanvas_hh__
BIAS::ImageBase origim_
Definition: ImageCanvas.hh:156
It&#39;s a Frame used to have a Histogramm Canvas, which describes a histogramm of current image...
Definition: HistoFrame.hh:47
void SetScaledImageSize(int width, int height)
Sets the size of the scaled image.
Definition: ImageCanvas.hh:102
display image in wx application, provides zoom and investigation functionality
Definition: ImageCanvas.hh:38
wxBitmap * RoiBitmap_
Definition: ImageCanvas.hh:160
BIAS::ImageBase * GetOrigImage()
Definition: ImageCanvas.hh:82
wxImage * wxRoiImage_
Definition: ImageCanvas.hh:162
Frame to display a Image legend, for example in biasviewwx.
used by ImageCanvas and ScaledImageCanvas, should not be used directly
Definition: ZoomFrame.hh:23
wxStatusBar * SBar_
Definition: ImageCanvas.hh:165
HistoFrame * MyHistoWin_
Definition: ImageCanvas.hh:153
std::string ImageName_
Definition: ImageCanvas.hh:185
void SetShowScaled(bool on)
Definition: ImageCanvas.hh:98
void DrawRoi(bool enable)
Definition: ImageCanvas.hh:126
ImageLegendFrame * MyValueBarFrame_
Definition: ImageCanvas.hh:154
wxBitmap * Bitmap_
Definition: ImageCanvas.hh:161
Class for holding multiple downsampled images.
Definition: ImageCanvas.hh:30
BIAS::Image< unsigned char > roimask_
Definition: ImageCanvas.hh:158
BIAS::Image< unsigned char > rgbim_
Definition: ImageCanvas.hh:157
void SetDefaultZoom(unsigned z)
Definition: ImageCanvas.hh:88
wxMutex wxbitmap_mutex_
Definition: ImageCanvas.hh:164
void SetHighScaleQuality(bool on)
Set the quality used for image size rescaling false: Uses the normal default scaling method of pixel ...
Definition: ImageCanvas.hh:114
BIAS::Image< unsigned char > * GetImageShown()
Definition: ImageCanvas.hh:84
virtual bool Show(bool show=true)
Definition: ImageCanvas.hh:80
unsigned DefaultZoom_
Definition: ImageCanvas.hh:181
wxImage * wximage_
Definition: ImageCanvas.hh:163
This is the base class for images in BIAS.
Definition: ImageBase.hh:102
ZoomFrame * MyZoomWin_
Definition: ImageCanvas.hh:152
void SetClearDrawingContext(bool clear)
Canvas now uses double buffering to avoid flickering, so it should be ok to always clear the canvas...
Definition: ImageCanvas.hh:95