Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ScaledImageCanvas.hh
1 #ifndef __ScaledImageCanvas_hh__
2 #define __ScaledImageCanvas_hh__
3 
4 #include <bias_config.h>
5 
6 #ifndef BIAS_HAVE_WXWIDGETS
7 # error BIAS_HAVE_WXWIDGETS not defined but required by ScaledImageCanvas. Please enable BIAS_HAVE_WXWIDGETS in CMake configure step.
8 #endif
9 
10 #include <Base/Common/BIASpragmaStart.hh>
11 #include <wx/wx.h>
12 #include <wx/spinctrl.h>
13 #include <Base/Common/BIASpragmaEnd.hh>
14 
15 #include <Base/Image/Image.hh>
16 #include <Gui/ImageCanvas.hh>
17 
18 
19 namespace BIAS {
20 
21  template <class T> class PyramidImage;
22 
23  /** @class ScaledImageCanvas
24  @ingroup g_gui
25  @brief display float images in wx application, provides zoom, scale,
26  shift and investigation functionality
27  @author woelk */
28  class BIASGui_EXPORT ScaledImageCanvas
29  : public wxPanel
30  {
31  public:
32  ScaledImageCanvas(wxWindow* parent, wxStatusBar* sbar=NULL,
33  int sbarid=0, wxWindowID id = -1,
34  const wxPoint& pos = wxDefaultPosition,
35  const wxSize& size = wxDefaultSize,
36  long style = wxTAB_TRAVERSAL,
37  const wxString& name = wxT("ScaledScrolledWindow"));
39 
40  void Show(BIAS::ImageBase& im, std::string name);
41 
42  void Show(BIAS::PyramidImage<float>& pim, std::string name);
43 
44  // to let user access classic hide/show function
45  virtual bool Show(bool show=true) {return MiaScWi_->Show(show);};
46  //inline void DrawRoi(bool enable){ DrawRoi_ = enable; Refresh();};
47  inline void SetScaleRange(double min, double max)
48  { BIASASSERT(max>min); MinScale_=min; MaxScale_=max; }
49 
50  inline void SetOffsetRange(double min, double max)
51  { BIASASSERT(max>min); MinOffSet_=min; MaxOffSet_=max; }
52 
53  int SetScale(double scale);
54  int SetScale(double scale, bool update);
55 
56  int SetOffset(double offset);
57  int SetOffset(double offset, bool update);
58 
59  inline void SetDefaultZoom(unsigned z)
60  { MiaScWi_->SetDefaultZoom(z); }
61 
62  /**
63  Set the quality used for image size rescaling
64  false: Uses the normal default scaling method of pixel replication
65  true: Uses bicubic (SLOW!!) and box averaging resampling
66  methods for upsampling and downsampling respectively
67  */
68  inline void SetHighScaleQuality(bool on)
69  {
70  if(MiaScWi_)
71  MiaScWi_->SetHighScaleQuality(on);
72  }
73 
74  /** @return (pointer) to class member ImageCanvas used for display JW */
75  ImageCanvas* GetImageCanvas();
76 
77  /** @return datat image origim_ class member JW */
78  BIAS::ImageBase & GetOrigimg();
79 
80  /** @return the image that is shown in the canvas JF */
81  BIAS::ImageBase& GetShownImage();
82 
83  /** pointer to sbar to be used JW */
84  void SetStatusBarPtr(wxStatusBar* p_sbar);
85 
86  /** display text to sbar if one is assigned */
87  void SetStatusText(const std::string & s);
88 
89  /** recalculate scale and shift for each new frame or not ?*/
90  void SetAutoadaptScale(const bool b){AutoadaptScale_ = b;}
91 
92  /** set ranges so that they would look beautiful **/
93  void SetNiceRanges(double scale_factor,
94  double offset_factor);
95 
96  /** set ranges of sliders **/
97  void SetRanges(double value_sc_double_l,
98  double value_sc_double_r,
99  double value_of_double_l,
100  double value_of_double_r);
101 
102  void GetScaleParameters(bool &Auto,
103  double &value_sc_double_l,
104  double &value_sc_double_r,
105  double &value_of_double_l,
106  double &value_of_double_r,
107  double &scale,
108  double &offset,
109  int &value_sc_steps,
110  int &value_of_steps);
111 
112  void SetScaleParameters(bool Auto,
113  double value_sc_double_l,
114  double value_sc_double_r,
115  double value_of_double_l,
116  double value_of_double_r,
117  double scale,
118  double offset,
119  int value_sc_steps,
120  int value_of_steps);
121 
122 
123  void UpdateHistogramm(ImageBase image);
124 
125  void KeepScrollPosition(bool flag);
126  // raises or lowers the zoom window if it is shown
127  void RaiseZoomWindow(const bool raise_or_lower);
128 
129 
130  protected:
131  void OnScaleOffset (wxScrollEvent & event);
132  void OnScaleOffsetSteps (wxSpinEvent & event);
133  void OnScaleOffsetBorders(wxCommandEvent & event);
134 
135  void OnAutoScaleOffset (wxCommandEvent& event);
136  void OnHisto (wxCommandEvent& event);
137  void OnMouseWheel(wxMouseEvent &event);
138 
139  void UpdateScaleOffset();
140  void UpdateScaleOffsetBorders();
141  void AutoScale_();
142 
143  wxCheckBox* Check_Auto_Sc_Of_;
144  wxCheckBox* Check_Histo_;
145 
146  //Controls to change Scale-Slider Parameters
147  wxStaticText* Scale_Text_;
148 
149  wxTextCtrl* Scale_L_;
150  wxTextCtrl* Scale_R_;
151  wxSpinCtrl* Scale_Steps_;
152 
153  double scale_l_old;
155  double scale_r_old;
156 
157  //Controls to change Offset-Slider Parameters
158  wxStaticText* Offset_Text_;
159 
160  wxTextCtrl* Offset_L_;
161  wxTextCtrl* Offset_R_;
162  wxSpinCtrl* Offset_Steps_;
163 
164  double offset_l_old;
166  double offset_r_old;
167 
168  //Sizes of text/spin/checkboxes
169  wxSize box_size;
172 
173  //Count of steps in sliders
176 
177  //Old Values of sliders, text/spin/checkboxes
180 
183 
184 
185  wxString string_base;
186 
187  // data member
188  ImageCanvas *MiaScWi_; // true data image
189  wxSlider *ScaleSL_, *OffsSL_;
193  std::string ImageName_;
194  double MinScale_, MaxScale_, MinOffSet_, MaxOffSet_;
195  bool DrawRoi_;
196  // pointer to statusbar to use if any
197  wxStatusBar * p_StatBar;
199  DECLARE_EVENT_TABLE()
200  }; // ScaledImageCanvas
201 
202 } // namespace
203 
204 
205 #endif // __ScaledImageCanvas_hh__
display image in wx application, provides zoom and investigation functionality
Definition: ImageCanvas.hh:38
BIAS::Image< float > scaledf_
void SetDefaultZoom(unsigned z)
void SetHighScaleQuality(bool on)
Set the quality used for image size rescaling false: Uses the normal default scaling method of pixel ...
void SetScaleRange(double min, double max)
void SetOffsetRange(double min, double max)
virtual bool Show(bool show=true)
BIAS::Image< unsigned char > ucim_
void SetAutoadaptScale(const bool b)
recalculate scale and shift for each new frame or not ?
display float images in wx application, provides zoom, scale, shift and investigation functionality ...
This is the base class for images in BIAS.
Definition: ImageBase.hh:102