1 /*# ---------------------------------------------------------------------
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9 # This software is governed by the CeCILL-B license under French law and
10 # abiding by the rules of distribution of free software. You can use,
11 # modify and/ or redistribute the software under the terms of the CeCILL-B
12 # license as circulated by CEA, CNRS and INRIA at the following URL
13 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 # or in the file LICENSE.txt.
16 # As a counterpart to the access to the source code and rights to copy,
17 # modify and redistribute granted by the license, users are provided only
18 # with a limited warranty and the software's author, the holder of the
19 # economic rights, and the successive licensors have only limited
22 # The fact that you are presently reading this means that you have had
23 # knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
27 #include "HistogramBase.h"
29 // -- inluces for HistogramMinMaxLevel
30 #include "pPlotterWindow.h"
31 #include "Histogram.h"
36 //-----------------------------------------------------------------------------
37 //-----------------------------------------------------------------------------
38 //-----------------------------------------------------------------------------
39 HistogramBase::HistogramBase()
43 //-----------------------------------------------------------------------------
44 HistogramBase::~HistogramBase()
48 //-----------------------------------------------------------------------------
49 HistogramBase* HistogramBase::GetConcretComponent()
54 //-----------------------------------------------------------------------------
55 //-----------------------------------------------------------------------------
56 //-----------------------------------------------------------------------------
57 HistogramDecorator::HistogramDecorator()
61 //-----------------------------------------------------------------------------
62 HistogramDecorator::~HistogramDecorator()
66 //-----------------------------------------------------------------------------
67 HistogramBase* HistogramDecorator::GetConcretComponent()
69 return _histogrambase->GetConcretComponent();
74 //-----------------------------------------------------------------------------
75 //-----------------------------------------------------------------------------
76 //-----------------------------------------------------------------------------
77 HistogramMinMaxLevel::HistogramMinMaxLevel(HistogramBase* histogrambase)
79 _histogrambase = histogrambase;
80 wxWindow *histogramebasePanel =_histogrambase->GetWindow();
81 wxPanel *panel = new wxPanel( histogramebasePanel->GetParent() , -1, wxDefaultPosition, wxSize(600,600) );
82 histogramebasePanel->Reparent(panel);
83 _barrange2 = new mBarRange2(panel, 30, 20);
84 _barrange2->PushEventHandler((wxEvtHandler*)this);
85 Connect(_barrange2->GetId(), wxEVT_BarRange2_Change ,
86 (wxObjectEventFunction) (wxCommandEventFunction) &HistogramMinMaxLevel::onBarRangeChange );
87 wxFlexGridSizer* sizer = new wxFlexGridSizer(1);
88 sizer->Add( histogramebasePanel , 1, wxGROW );
89 sizer->Add( _barrange2 , 1, wxGROW );
90 panel->SetSizer( sizer );
91 panel->SetAutoLayout( true );
96 //-----------------------------------------------------------------------------
97 HistogramMinMaxLevel::~HistogramMinMaxLevel()
101 //-----------------------------------------------------------------------------
102 wxWindow* HistogramMinMaxLevel::GetWindow()
107 //-----------------------------------------------------------------------------
108 void HistogramMinMaxLevel::Configure(vtkImageData* img)
110 _histogrambase->Configure(img);
112 img->GetScalarRange(range);
113 _barrange2->SetScalarType( img->GetScalarType() );
114 _barrange2->SetMinMaxValue(range[0],range[1]);
117 //-----------------------------------------------------------------------------
118 void HistogramMinMaxLevel::onBarRangeChange(wxCommandEvent& event)
120 Histogram* histogram = (Histogram*)GetConcretComponent();
121 pPlotterWindow* plotterwindow = histogram->GetPlotterWindow();
123 plotterwindow->setLineGuidesCondition(true);
124 double startvalue = _barrange2->GetStartValue();
125 plotterwindow->setRealGuideX( startvalue*100 );
126 plotterwindow->setRealGuideY( startvalue*100 );
128 if (plotterwindow->drawGuideLines()==true)
135 plotterwindow->UpdateAll();