Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ScaledImageCanvas.cpp
1 #include "ScaledImageCanvas.hh"
2 
3 #include <Gui/StringConv.hh>
4 #include <Base/Image/ImageConvert.hh>
5 #include <Image/PyramidImage.hh>
6 
7 using namespace BIAS;
8 using namespace std;
9 
10 
11 namespace BIAS {
12 
16 
20 
24 
26  };
27 }
28 
29 
31 ScaledImageCanvas(wxWindow* parent, wxStatusBar* sbar,
32  int sbarid, wxWindowID id,
33  const wxPoint& pos, const wxSize& size,
34  long style, const wxString& name)
35  : wxPanel(parent, id, pos, size, style, name), scaledf_()
36 {
37  MiaScWi_ = new ImageCanvas(this, sbar, sbarid, -1, wxDefaultPosition,
38  //wxSize(320, 240),
39  wxDefaultSize, wxHSCROLL | wxVSCROLL, name);
40 
41  //count of steps in sliders
42  slider_sc_digits = 100;
43  slider_of_digits = 100;
44 
45  ///-------------SIZES---------------
46  //Box for values of sliders/slider borders
47  box_size.SetHeight(20);
48  box_size.SetWidth(85);
49 
50  //Box for values of slider steps
51  box_size_steps.SetHeight(20);
52  box_size_steps.SetWidth(60);
53 
54  //Box for CheckBoxes
55  box_size_checks.SetHeight(20);
56  box_size_checks.SetWidth(150);
57  ///---------------------------------
58 
59  ///---HISTO/AUTOSCALE CHECK BOXES---
60  Check_Auto_Sc_Of_ = new wxCheckBox(this, ID_Check_Auto_Sc_Of,
61  wxT("Auto(Scale/Offset)"), wxDefaultPosition,
63  ///---------------------------------
64 
65  wxBoxSizer *hbox_scale = new wxBoxSizer(wxHORIZONTAL);
66  wxBoxSizer *hbox_offset = new wxBoxSizer(wxHORIZONTAL);
67 
68  //unimplemented !
69  DrawRoi_=false;
70 
71  MinScale_ = 0.1;
72  MaxScale_ = 100.0;
73  MinOffSet_= -100.0;
74  MaxOffSet_= 100.0;
75 
76  ///---SCALE SLIDER---
77  int scale_value = (int)(slider_sc_digits/2);
78  ScaleSL_ = new wxSlider(this, ID_Scale, scale_value, 0,
79  slider_sc_digits, wxDefaultPosition,
80  wxSize(-1, -1), wxSL_HORIZONTAL);
81  scale_old = scale_value;
82 
83  double scal_v = ScaleSL_->GetValue();
84  ostringstream sc_stream; sc_stream << scal_v;
85  Scale_Text_ = new wxStaticText(this, -1, AsciiToWx(sc_stream.str()),
86  wxDefaultPosition, box_size, wxSP_ARROW_KEYS);
87  sc_stream.clear();
88  Scale_L_ = new wxTextCtrl(this, ID_Scale_L, wxT("0.1"),
89  wxDefaultPosition, box_size, wxTE_PROCESS_ENTER);
90  Scale_R_ = new wxTextCtrl(this, ID_Scale_R, wxT("100.0"),
91  wxDefaultPosition, box_size, wxTE_PROCESS_ENTER);
92 
93  //constructing steps-text-window and putting current value in it
94  sc_stream << slider_sc_digits;
95  wxString value_sc_steps = AsciiToWx(sc_stream.str());
96  Scale_Steps_ = new wxSpinCtrl(this, ID_Scale_Steps, value_sc_steps,
97  wxDefaultPosition, box_size_steps,
98  wxSP_ARROW_KEYS, 1, 80000);
99 
100  hbox_scale->Add(new wxStaticText( this, -1, _T("Scale: ") ), 0, wxALL, 3);
101  hbox_scale->Add(Scale_Text_);
102  hbox_scale->Add(new wxStaticText( this, -1, _T(" [ ") ), 0, wxALL, 3);
103  hbox_scale->Add(Scale_L_);
104  hbox_scale->Add(ScaleSL_, 1, wxALL | wxGROW, 3);
105  hbox_scale->Add(Scale_R_);
106  hbox_scale->Add(new wxStaticText( this, -1, _T("] Steps: ") ), 0, wxALL, 3);
107  hbox_scale->Add(Scale_Steps_);
108  hbox_scale->Add(new wxStaticText( this, -1, _T(" | ") ), 0, wxALL, 3);
109 
110  wxStaticText* temp = new wxStaticText(this, -1, wxT(""),
111  wxDefaultPosition, box_size_checks, wxSP_ARROW_KEYS);
112  hbox_scale->Add(temp);
113 
114  ///------------------
115 
116  ///---OFFSET SLIDER---
117  int offset_value = (int)(slider_of_digits/2);
118  OffsSL_ = new wxSlider(this, ID_Offset, offset_value, 0,
119  slider_of_digits, wxDefaultPosition,
120  wxSize(-1, -1), wxSL_HORIZONTAL);
121  offset_old = offset_value;
122 
123  ostringstream of_stream; of_stream << OffsSL_->GetValue();
124  Offset_Text_ = new wxStaticText(this, -1, AsciiToWx(of_stream.str()),
125  wxDefaultPosition, box_size, wxSP_ARROW_KEYS);
126  of_stream.clear();
127  Offset_L_ = new wxTextCtrl(this, ID_Offset_L, wxT("-100.0"),
128  wxDefaultPosition, box_size, wxTE_PROCESS_ENTER);
129  Offset_R_ = new wxTextCtrl(this, ID_Offset_R, wxT("100.0"),
130  wxDefaultPosition, box_size, wxTE_PROCESS_ENTER);
131 
132  //constructing steps-text-window and putting current value in it
133  of_stream << slider_of_digits;
134  wxString value_of_steps = AsciiToWx(of_stream.str());
135  Offset_Steps_ = new wxSpinCtrl(this, ID_Offset_Steps, value_of_steps,
136  wxDefaultPosition, box_size_steps,
137  wxSP_ARROW_KEYS, 1, 80000);
138 
139  hbox_offset->Add(new wxStaticText( this, -1, _T("Offset: ") ), 0, wxALL, 3);
140  hbox_offset->Add(Offset_Text_);
141  hbox_offset->Add(new wxStaticText( this, -1, _T(" [ ") ), 0, wxALL, 3);
142  hbox_offset->Add(Offset_L_);
143  hbox_offset->Add(OffsSL_, 1, wxALL | wxGROW, 3);
144  hbox_offset->Add(Offset_R_);
145  hbox_offset->Add(new wxStaticText( this, -1, _T("] Steps: ") ), 0, wxALL, 3);
146  hbox_offset->Add(Offset_Steps_);
147  hbox_offset->Add(new wxStaticText( this, -1, _T(" | ") ), 0, wxALL, 3);
148  hbox_offset->Add(Check_Auto_Sc_Of_);
149  ///-------------------
150 
151  wxBoxSizer *vbox = new wxBoxSizer(wxVERTICAL);
152 
153  vbox->Add(MiaScWi_, 1, wxALL | wxGROW, 0);
154  vbox->Add(hbox_scale, 0, wxGROW, 0);
155  vbox->Add(hbox_offset, 0, wxGROW, 0);
156  vbox->SetSizeHints(this);
157  SetSizer(vbox);
158 
159  p_StatBar=NULL;
160 
161  //Shut the AutoScale/Offset Box ON
162  AutoadaptScale_ = true;
164 
165 
166  //SetScaleRange(0.5, 50.0);
167  //SetOffsetRange(-100.0, 100.0);
168  SetRanges(0.5, 50.0, -100.0, 100.0);
169 
170  //Set that the ranges of sliders were:
171  //scale: from 0.1*value to 10*value
172  //offset:from value-100 to value+100
173  //SetNiceRanges(10.0, 100.0);
174 }
175 
176 
179 {
180  if (MiaScWi_) { delete MiaScWi_; MiaScWi_ = NULL; }
181  if (ScaleSL_) { delete ScaleSL_; ScaleSL_ = NULL; }
182  if (OffsSL_) { delete OffsSL_; OffsSL_ = NULL; }
183 }
184 
185 
187 SetStatusBarPtr(wxStatusBar* p_sbar)
188 {
189  p_StatBar=p_sbar;
190 }
191 
194 }
195 
196 
198 SetStatusText(const std::string & s){
199  if(p_StatBar==NULL){
200  wxMessageBox( AsciiToWx(string("p_StatBar NULL. " + s)) );
201  return;
202  }
203  BIASASSERT(p_StatBar!=NULL);
204  p_StatBar->SetStatusText(AsciiToWx(s));
205 }
206 
207 
209 RaiseZoomWindow(const bool raise_or_lower)
210 {
211  BIASASSERT(MiaScWi_);
212  MiaScWi_->RaiseZoomWindow(raise_or_lower);
213 }
214 
215 
217 Show(ImageBase& im, string name)
218 {
219  ImageName_=name;
220  switch (im.GetStorageType()) {
221  case ImageBase::ST_float:
222  origim_=im;
223  break;
224  // case ImageBase::ST_unsignedshortint:
225  default:
227  break;
228  }
230  if (AutoadaptScale_) {
231  double scale=0, shift=0;
232  scaledf_.CalcScaleShift(0.0, 255.0, scale, shift);
233  //cout <<"Scale: "<<scale<<" shift: "<<shift<<endl;
234  double a1, a2, b1, b2;
235  if(scale < 0){
236  a1 = scale*10; a2 = scale/10;
237  }
238  else if(scale > 0){
239  a1 = scale/10; a2 = scale*10;
240  }
241  else{
242  a1 = 0.0; a2 = 10.0;
243  }
244 
245  if(shift < 0){
246  b1 = shift*10; b2 = shift/10;
247  }
248  else if(shift > 0){
249  b1 = shift/10; b2 = shift*10;
250  }
251  else{
252  b1 = -50.0; b2 = 50.0;
253  }
254 
255  SetRanges(a1, a2, b1, b2);
256 
257  SetOffset(shift, false);
258  SetScale(scale, false);
259  }
261 }
262 
263 
265 Show(PyramidImage<float>& pim, string name)
266 {
267  Image<float> im;
268  pim.GetSingleImage(im);
269  Show(im, name);
270 }
271 
272 
274 SetScale(double c_scale)
275 {
276  return SetScale(c_scale, true);
277 }
278 
279 
281 SetScale(double scale, bool update)
282 {
283  if (scale<MinScale_){
284  ScaleSL_->SetValue(0);
285  cout << "invalid scale (too small) - clipping it to minimum" << endl;
286  }
287  else if (scale>MaxScale_){
288  ScaleSL_->SetValue(slider_sc_digits);
289  cout << "invalid scale (too big) - clipping it to maximum" << endl;
290  }
291  else{
292  int value=(int)rint((scale-MinScale_)*(double)slider_sc_digits/
293  (MaxScale_-MinScale_));
294  BIASASSERT(value>=0);
295  //BIASASSERT(value<=1000);
296  ScaleSL_->SetValue(value);
297  }
298 
299  if(update)
301  return 0;
302 }
303 
304 
306 SetOffset(double offset)
307 {
308  return SetOffset(offset, true);
309 }
310 
311 
313 SetOffset(double offset, bool update)
314 {
315  if (offset < MinOffSet_){
316  OffsSL_->SetValue(0);
317  cout << "invalid offset (too small) - clipping it to minimum" << endl;
318  }
319  else if(offset > MaxOffSet_){
320  OffsSL_->SetValue(slider_of_digits);
321  cout << "invalid offset (too big) - clipping it to maximum" << endl;
322  }
323  else{
324  int value=(int)rint((offset-MinOffSet_)*(double)slider_of_digits/
326  //BIASASSERT(value>=0);
327  //BIASASSERT(value<=1000);
328  OffsSL_->SetValue(value);
329  }
330 
331  if(update)
333  return 0;
334 }
335 
338 {
339  if (!origim_.IsEmpty()){
341  double sc=1.0, ofs=0.0;
342 
343  //REAL VALUES OF SCALE AND OFFSET
344  sc=((double)(ScaleSL_->GetValue())*(MaxScale_-MinScale_)/
345  (double)slider_sc_digits)+MinScale_;
346 
347  ofs=((double)(OffsSL_->GetValue())*(MaxOffSet_-MinOffSet_)/
348  (double)slider_of_digits)+MinOffSet_;
349 
350  //VALUES OF SLIDERS
351  scale_old = ScaleSL_->GetValue();
352  offset_old = OffsSL_->GetValue();
353 
354  ostringstream sc_stream; sc_stream << sc;
355  ostringstream of_stream; of_stream << ofs;
356 
357  wxString value_sc = AsciiToWx(sc_stream.str());
358  wxString value_of = AsciiToWx(of_stream.str());
359 
360  Scale_Text_->SetLabel(value_sc);
361  Offset_Text_->SetLabel(value_of);
362 
363  //Set NEW VALUES
364  ScaleSL_->SetValue(scale_old);
365  OffsSL_->SetValue(offset_old);
366 
367  //cerr << "Scale: "<<sc<<"\tOffset: "<<ofs<<endl;
368  stringstream ss;
369  ss<<"scale "<<sc<<" offset: "<<ofs;
370  //if (p_parent!=NULL) {
371  // p_parent->SetStatusText(ss.str().c_str() );
372  //} else {
373  //cout<<ss.str()<<endl;
374  //}
375 
376  scale_border_l_value = Scale_L_->GetValue();
377  scale_border_r_value = Scale_R_->GetValue();
378  offset_border_l_value = Offset_L_->GetValue();
379  offset_border_r_value = Offset_R_->GetValue();
380 
381  scaledf_.ScaleShift(sc, ofs);
382  Image<float> scaled_cropped(scaledf_);
383  scaled_cropped.BelowThresholdToValue(0.0, 0.0);
384  scaled_cropped.AboveThresholdToValue(255.0, 255.0);
385 
386  if (ImageConvert::ConvertST(scaled_cropped, ucim_,
388  BIASERR("error converting to unsigned char");
389  }
392  } else {
393  rgbim_=ucim_;
394  }
396 
397  //BIASASSERT(this->SBar_ != NULL);
398  ss.str("");
399  ss<<"scale= ";
400  ss<<sc;
401  ss<<" offset=";
402  ss<<ofs;
403  //MiaScWi_->SBar_->SetStatusText(ss.str(), 0); // SBarID_ );
404  // cout<<"DBG "<<ss.str()<<endl;
405  /// \todo: write ofsfet and scale to StatusText instead of cout (JW)
406  }
407 }
408 
409 
412 {
413  double scale = ((double)(ScaleSL_->GetValue())*(MaxScale_-MinScale_)/
414  (double)slider_sc_digits)+MinScale_;
415 
416  double offset = ((double)(OffsSL_->GetValue())*(MaxOffSet_-MinOffSet_)/
417  (double)slider_of_digits)+MinOffSet_;
418 
419  //CHECK IF VALUES IN BORDER-VALUE-TEXTS ARE CORRECT
420  double scale_l = atof(WxToAscii(Scale_L_->GetValue()));
421  double scale_r = atof(WxToAscii(Scale_R_->GetValue()));
422 
423  if(scale_l > scale_r){
424  //that means that Scale-right-border was changed
425  if(scale_l_old == scale_l){
426  ostringstream sc_stream;
427  sc_stream << scale_l;
428  Scale_R_->SetValue(AsciiToWx(sc_stream.str()));
429  scale_r = scale_l;
430  }
431  //that means that Scale-left-border was changed
432  if(scale_r_old == scale_r){
433  ostringstream sc_stream;
434  sc_stream << scale_r;
435  Scale_L_->SetValue(AsciiToWx(sc_stream.str()));
436  scale_l = scale_r;
437  }
438  }
439 
440  //UPDATE MIN_SCALE, MAX_SCALE
441  MinScale_ = scale_l;
442  MaxScale_ = scale_r;
443 
444  scale_l_old = scale_l;
445  scale_r_old = scale_r;
446 
447  //CHECK IF VALUES IN BORDER-VALUE-TEXTS ARE CORRECT
448  double offset_l = atof(WxToAscii(Offset_L_->GetValue()));
449  double offset_r = atof(WxToAscii(Offset_R_->GetValue()));
450 
451  if(offset_l > offset_r){
452  //that means thant Scale-right-border was changed
453  if(offset_r_old != offset_r){
454  ostringstream of_stream;
455  offset_r = offset_l;
456  of_stream << offset_r;
457  Offset_R_->SetValue(AsciiToWx(of_stream.str()));
458  }
459  //that means thant Scale-left-border was changed
460  else if(offset_l_old != offset_l){
461  ostringstream of_stream;
462  offset_l = offset_r;
463  of_stream << offset_l;
464  Offset_L_->SetValue(AsciiToWx(of_stream.str()));
465  }
466  }
467 
468  offset_l_old = offset_l;
469  offset_r_old = offset_r;
470 
471  //UPDATE MIN_OFFSET, MAX_OFFSET
472  MinOffSet_ = offset_l;
473  MaxOffSet_ = offset_r;
474 
475  //UPDATE SCALE OFFSET SLIDERS (+STEPS)
476 
477  int scale_new =(int)rint((scale - MinScale_)*(double)slider_sc_digits/
478  (MaxScale_ - MinScale_));
479  int offset_new = (int)rint((offset - MinOffSet_)*(double)slider_of_digits/
480  (MaxOffSet_ - MinOffSet_));
481 
482  if(scale_new > (int)slider_sc_digits)
483  ScaleSL_->SetValue((int)slider_sc_digits);
484  else if(scale_new < 0)
485  ScaleSL_->SetValue((int)0);
486  else
487  ScaleSL_->SetValue((int)scale_new);
488 
489  if(offset_new > (int)slider_of_digits)
490  OffsSL_->SetValue((int)slider_of_digits);
491  else if(offset_new < 0)
492  OffsSL_->SetValue((int)0);
493  else
494  OffsSL_->SetValue((int)offset_new);
495 }
496 
497 
500 {
501  return MiaScWi_;
502 }
503 
504 
507 {
508  return origim_;
509 }
510 
512 {
513  return scaledf_;
514 }
515 
516 
517 BEGIN_EVENT_TABLE (ScaledImageCanvas, wxPanel)
518 EVT_CHECKBOX(ID_Check_Auto_Sc_Of, ScaledImageCanvas::OnAutoScaleOffset)
519 
520 EVT_TEXT_ENTER(ID_Scale_L, ScaledImageCanvas::OnScaleOffsetBorders)
521 EVT_TEXT_ENTER(ID_Scale_R, ScaledImageCanvas::OnScaleOffsetBorders)
522 EVT_SPINCTRL(ID_Scale_Steps, ScaledImageCanvas::OnScaleOffsetSteps)
523 
524 EVT_TEXT_ENTER(ID_Offset_L, ScaledImageCanvas::OnScaleOffsetBorders)
525 EVT_TEXT_ENTER(ID_Offset_R, ScaledImageCanvas::OnScaleOffsetBorders)
526 EVT_SPINCTRL(ID_Offset_Steps, ScaledImageCanvas::OnScaleOffsetSteps)
527 EVT_MOUSEWHEEL (ScaledImageCanvas::OnMouseWheel)
528 EVT_SCROLL(ScaledImageCanvas::OnScaleOffset)
529 END_EVENT_TABLE()
530 
531 
532 void ScaledImageCanvas::
533 SetRanges(double value_sc_double_l,
534  double value_sc_double_r,
535  double value_of_double_l,
536  double value_of_double_r){
537  ostringstream sc_stream_l; sc_stream_l << value_sc_double_l;
538  Scale_L_->SetValue(AsciiToWx(sc_stream_l.str()));
539  ostringstream sc_stream_r; sc_stream_r << value_sc_double_r;
540  Scale_R_->SetValue(AsciiToWx(sc_stream_r.str()));
541 
542  ostringstream of_stream_l; of_stream_l << value_of_double_l;
543  Offset_L_->SetValue(AsciiToWx(of_stream_l.str()));
544  ostringstream of_stream_r; of_stream_r << value_of_double_r;
545  Offset_R_->SetValue(AsciiToWx(of_stream_r.str()));
546 
547  UpdateScaleOffsetBorders();
548  UpdateScaleOffset();
549 }
550 
551 
554  double &value_sc_double_l,
555  double &value_sc_double_r,
556  double &value_of_double_l,
557  double &value_of_double_r,
558  double &scale,
559  double &offset,
560  int &value_sc_steps,
561  int &value_of_steps)
562 {
563  value_sc_steps = Scale_Steps_->GetValue();
564  value_of_steps = Offset_Steps_->GetValue();
565 
566  scale=((double)(ScaleSL_->GetValue())*(MaxScale_-MinScale_)/
567  (double)slider_sc_digits)+MinScale_;
568 
569  offset=((double)(OffsSL_->GetValue())*(MaxOffSet_-MinOffSet_)/
570  (double)slider_of_digits)+MinOffSet_;
571 
572  value_sc_double_l = atof(WxToAscii(Scale_L_->GetValue()));
573  value_sc_double_r = atof(WxToAscii(Scale_R_->GetValue()));
574  value_of_double_l = atof(WxToAscii(Offset_L_->GetValue()));
575  value_of_double_r = atof(WxToAscii(Offset_R_->GetValue()));
576  Auto = AutoadaptScale_;
577 }
578 
579 
582  double value_sc_double_l,
583  double value_sc_double_r,
584  double value_of_double_l,
585  double value_of_double_r,
586  double scale,
587  double offset,
588  int value_sc_steps,
589  int value_of_steps)
590 {
591 
592  Check_Auto_Sc_Of_->SetValue(Auto);
593  SetAutoadaptScale(Auto);
594  if(Auto)
595  {
596  AutoScale_();
597  }
598  else
599  {
600  Scale_Steps_->SetValue(value_sc_steps);
601  Offset_Steps_->SetValue(value_of_steps);
602 
603  SetScaleRange(value_sc_double_l,value_sc_double_r); //sets MinScale_,MaxScale_
604  SetOffsetRange(value_of_double_l,value_of_double_r); //sets MinOffSet_, MaxOffSet_
605 
606  SetRanges(value_sc_double_l,value_sc_double_r
607  ,value_of_double_l,value_of_double_r);
608 
609  SetScale(scale);
610  SetOffset(offset);
611  }
612 }
613 
615 SetNiceRanges(double scale_factor,
616  double offset_factor){
617  //correct the real slider-values from the beginning
618  ScaleSL_->SetValue((int)rint((double)(ScaleSL_->GetValue())));
619  OffsSL_->SetValue((int)rint((double)(OffsSL_->GetValue())));
620 
621  if(scale_factor > 0.0 &&
622  offset_factor > 0.0){
623  //get real scale and offset values
624  double value_sc_double = ((double)(ScaleSL_->GetValue())*
626  (double)slider_sc_digits)+MinScale_;
627  double value_of_double = ((double)(OffsSL_->GetValue())*
629  (double)slider_of_digits)+MinOffSet_;
630 
631  //set borders of sliders as scale: (scale_value/scale_factor,
632  // scale_value*scale_factor);
633  // offset: (offset_value-offset_factor,
634  // offset_value+offset_factor);
635 
636  double value_sc_double_l = value_sc_double/scale_factor;
637  ostringstream sc_stream_l; sc_stream_l << value_sc_double_l;
638  Scale_L_->SetValue(AsciiToWx(sc_stream_l.str()));
639  double value_sc_double_r = value_sc_double*scale_factor;
640  ostringstream sc_stream_r; sc_stream_r << value_sc_double_r;
641  Scale_R_->SetValue(AsciiToWx(sc_stream_r.str()));
642 
643  double value_of_double_l = value_of_double-offset_factor;
644  ostringstream of_stream_l; of_stream_l << value_of_double_l;
645  Offset_L_->SetValue(AsciiToWx(of_stream_l.str()));
646  double value_of_double_r = value_of_double+offset_factor;
647  ostringstream of_stream_r; of_stream_r << value_of_double_r;
648  Offset_R_->SetValue(AsciiToWx(of_stream_r.str()));
649 
652  }
653 }
654 
655 
657 OnScaleOffset(wxScrollEvent & )
658 {
659  if(scale_old != ScaleSL_->GetValue() ||
660  offset_old != OffsSL_->GetValue()){
661  AutoadaptScale_ = false;
662  Check_Auto_Sc_Of_->SetValue(false);
664  }
665 }
666 
667 
669 OnScaleOffsetBorders(wxCommandEvent & )
670 {
671  if(scale_border_l_value != Scale_L_->GetValue() ||
672  scale_border_r_value != Scale_R_->GetValue() ||
673  offset_border_l_value != Offset_L_->GetValue() ||
674  offset_border_r_value != Offset_R_->GetValue()){
676  /**
677  cout << MinScale_ << " to " << MaxScale_ << " - Scale Bord" << endl;
678  cout << MinOffSet_ << " to " << MaxOffSet_ << " - Offset Bord" << endl;
679  **/
681  /**
682  cout << MinScale_ << " to " << MaxScale_ << " - Scale Update" << endl;
683  cout << MinOffSet_ << " to " << MaxOffSet_ << " - Offset Update" << endl;
684  **/
685  }
686 }
687 
688 
690 OnScaleOffsetSteps(wxSpinEvent & )
691 {
692  //UPDATE SLIDER-VALUES
693  int value_sc_steps_new = Scale_Steps_->GetValue();
694  int value_of_steps_new = Offset_Steps_->GetValue();
695 
696  double diff_sc = ((double)value_sc_steps_new)/((double)slider_sc_digits);
697  if(diff_sc != 1.0){
698  ScaleSL_->SetValue((int)rint((double)ScaleSL_->GetValue()*diff_sc));
699  ScaleSL_->SetRange(0, value_sc_steps_new);
700  }
701 
702  double diff_of = ((double)value_of_steps_new)/((double)slider_of_digits);
703  if(diff_of != 1.0){
704  OffsSL_->SetValue((int)rint((double)OffsSL_->GetValue()*diff_of));
705  OffsSL_->SetRange(0, value_of_steps_new);
706  }
707 
708  slider_sc_digits = value_sc_steps_new;
709  slider_of_digits = value_of_steps_new;
710 
711  cout << endl;
712  cout << slider_sc_digits << endl;
713  cout << slider_of_digits << endl;
714 
716 }
717 
718 
720 OnAutoScaleOffset(wxCommandEvent& /*event*/)
721 {
724  AutoScale_();
726  }
727 }
728 
730 OnMouseWheel(wxMouseEvent &event){
731  //should be handled by the ImageCanvas function OnMouseWheel
732  event.Skip();
733 }
734 
735 
738 {
739  if (AutoadaptScale_) {
740  double scale=0, shift=0;
742  scaledf_.CalcScaleShift(0.0, 255.0, scale, shift);
743 
744  double a1, a2, b1, b2;
745  if(scale < 0){
746  a1 = scale*10; a2 = scale/10;
747  }
748  else if(scale > 0){
749  a1 = scale/10; a2 = scale*10;
750  }
751  else{
752  a1 = 0.0; a2 = 10.0;
753  }
754 
755  if(shift < 0){
756  b1 = shift*10; b2 = shift/10;
757  }
758  else if(shift > 0){
759  b1 = shift/10; b2 = shift*10;
760  }
761  else{
762  b1 = -50.0; b2 = 50.0;
763  }
764 
765  SetRanges(a1, a2, b1, b2);
766 
767  SetScale(scale, false);
768  SetOffset(shift, false);
769  }
770 }
771 
772 
774 OnHisto(wxCommandEvent& /*event*/)
775 {}
int SetOffset(double offset)
void SetNiceRanges(double scale_factor, double offset_factor)
set ranges so that they would look beautiful
int AboveThresholdToValue(StorageType Threshold, StorageType Value)
sets alls pixels with values above Threshold to Value
Definition: Image.cpp:1028
void KeepScrollPosition(bool flag)
wxString AsciiToWx(const char *thestring)
Converts a C string to a wxString.
Definition: StringConv.hh:32
bool IsEmpty() const
check if ImageData_ points to allocated image buffer or not
Definition: ImageBase.hh:245
int BelowThresholdToValue(StorageType Threshold, StorageType Value)
sets alls pixels with values below Threshold to Value
Definition: Image.cpp:1013
void GetSingleImage(Image< StorageType > &im) const
returns a single image containing all pyramid images
void SetStatusBarPtr(wxStatusBar *p_sbar)
pointer to sbar to be used JW
void OnScaleOffset(wxScrollEvent &event)
void OnAutoScaleOffset(wxCommandEvent &event)
float image storage type
Definition: ImageBase.hh:118
display image in wx application, provides zoom and investigation functionality
Definition: ImageCanvas.hh:38
int ScaleShift(double Scale, double Shift)
scales and shifts image (all channels simultanously)
Definition: Image.cpp:1064
BIAS::Image< float > scaledf_
void OnHisto(wxCommandEvent &event)
void SetScaleRange(double min, double max)
void RaiseZoomWindow(const bool raise_or_lower)
void SetOffsetRange(double min, double max)
void GetScaleParameters(bool &Auto, double &value_sc_double_l, double &value_sc_double_r, double &value_of_double_l, double &value_of_double_r, double &scale, double &offset, int &value_sc_steps, int &value_of_steps)
BIAS::Image< unsigned char > rgbim_
static int ConvertST(const BIAS::ImageBase &source, BIAS::ImageBase &dest, ImageBase::EStorageType targetST)
Function to convert the storage type of images e.g.
color values, 3 channels, order: red,green,blue
Definition: ImageBase.hh:131
void Show(BIAS::ImageBase &im, std::string name)
void RaiseZoomWindow(const bool raise_or_lower)
void SetStatusText(const std::string &s)
display text to sbar if one is assigned
ScaledImageCanvas(wxWindow *parent, wxStatusBar *sbar=NULL, int sbarid=0, wxWindowID id=-1, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL, const wxString &name=wxT("ScaledScrolledWindow"))
BIAS::ImageBase & GetOrigimg()
void SetRanges(double value_sc_double_l, double value_sc_double_r, double value_of_double_l, double value_of_double_r)
set ranges of sliders
BIAS::Image< unsigned char > ucim_
void OnMouseWheel(wxMouseEvent &event)
enum EColorModel GetColorModel() const
Definition: ImageBase.hh:407
void OnScaleOffsetSteps(wxSpinEvent &event)
static int Convert(BIAS::ImageBase &source, BIAS::ImageBase &dest, enum BIAS::ImageBase::EColorModel targetColorModel, bool bPlanar=false)
main general conversion function, calls desired specialized functions, always initializes the destIma...
enum EStorageType GetStorageType() const
Definition: ImageBase.hh:414
(8bit) unsigned char image storage type
Definition: ImageBase.hh:112
virtual void Show(BIAS::Image< unsigned char > &im, std::string name="")
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 ...
void OnScaleOffsetBorders(wxCommandEvent &event)
BIAS::ImageBase & GetShownImage()
This is the base class for images in BIAS.
Definition: ImageBase.hh:102
void SetScaleParameters(bool Auto, double value_sc_double_l, double value_sc_double_r, double value_of_double_l, double value_of_double_r, double scale, double offset, int value_sc_steps, int value_of_steps)
int CalcScaleShift(double Min, double Max, double &Scale, double &Shift) const
calculate the values needed by ScaleShiftBetween
Definition: Image.cpp:1222
void KeepScrollPosition(bool flag)