]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/HistogramBase.cxx
#2490 creaMaracasVisu Feature New High - Histogram Interaction
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / pPlotter / HistogramBase.cxx
1 /*# ---------------------------------------------------------------------
2 #
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
4 #                        pour la Sant�)
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
8 #
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.
15 #
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
20 #  liability.
21 #
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 # ------------------------------------------------------------------------ */
25
26
27 #include "HistogramBase.h"
28
29 // -- inluces for HistogramMinMaxLevel
30 #include "pPlotterWindow.h"
31 #include "Histogram.h"
32
33
34
35
36 //-----------------------------------------------------------------------------
37 //-----------------------------------------------------------------------------
38 //-----------------------------------------------------------------------------
39         HistogramBase::HistogramBase()
40         {               
41         }
42
43 //-----------------------------------------------------------------------------
44         HistogramBase::~HistogramBase()
45         {
46         }
47
48 //-----------------------------------------------------------------------------
49         HistogramBase* HistogramBase::GetConcretComponent()
50         {
51                 return this;
52         }
53
54 //-----------------------------------------------------------------------------
55 //-----------------------------------------------------------------------------
56 //-----------------------------------------------------------------------------
57         HistogramDecorator::HistogramDecorator()
58         {               
59         }
60
61 //-----------------------------------------------------------------------------
62         HistogramDecorator::~HistogramDecorator()
63         {
64         }
65
66 //-----------------------------------------------------------------------------
67         HistogramBase* HistogramDecorator::GetConcretComponent()
68         {
69                 return _histogrambase->GetConcretComponent();
70         }
71
72
73
74 //-----------------------------------------------------------------------------
75 //-----------------------------------------------------------------------------
76 //-----------------------------------------------------------------------------
77         HistogramMinMaxLevel::HistogramMinMaxLevel(HistogramBase* histogrambase)
78         {               
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 );
92                 panel->Layout();
93                 _panel = panel;
94         }
95
96 //-----------------------------------------------------------------------------
97         HistogramMinMaxLevel::~HistogramMinMaxLevel()
98         {
99         }
100
101 //-----------------------------------------------------------------------------
102         wxWindow* HistogramMinMaxLevel::GetWindow()
103         {
104                 return _panel;
105         }
106
107 //-----------------------------------------------------------------------------
108         void HistogramMinMaxLevel::Configure(vtkImageData* img)
109         {
110                 _histogrambase->Configure(img); 
111                 double range[2];
112                 img->GetScalarRange(range);
113                 _barrange2->SetScalarType( img->GetScalarType() );
114                 _barrange2->SetMinMaxValue(range[0],range[1]);
115         }
116
117 //-----------------------------------------------------------------------------
118 void HistogramMinMaxLevel::onBarRangeChange(wxCommandEvent& event)
119 {
120         printf ("EED HistogramMinMaxLevel::onBarrangeChange\n");
121         Histogram*                      histogram               = (Histogram*)GetConcretComponent();
122         pPlotterWindow*         plotterwindow   = histogram->GetPlotterWindow();        
123
124         plotterwindow->setLineGuidesCondition(true);
125         double startvalue = _barrange2->GetStartValue();
126         plotterwindow->setRealGuideX( startvalue*100 );
127         plotterwindow->setRealGuideY( startvalue*100 );
128         
129         if (plotterwindow->drawGuideLines()==true)
130         {
131                 printf ("YES \n");
132         } else {
133                 printf ("NO \n");
134         }
135
136         plotterwindow->UpdateAll();
137
138 }
139
140
141
142