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 This class plots image's histograms in a plotter
30 //---------------------
32 //----------------------
33 #include "Histogram.h"
34 #include "vtkImageCast.h"
36 // ----------------------------------------------------------------------------
37 // WX headers inclusion.
38 // For compilers that support precompilation, includes <wx/wx.h>.
39 // ----------------------------------------------------------------------------
45 //----------------------------------------------------------------------------
46 // Class implementation
47 //----------------------------------------------------------------------------
49 IMPLEMENT_CLASS(Histogram, wxWindow)
50 //----------------------------------------------------------------------------
52 //----------------------------------------------------------------------------
54 BEGIN_EVENT_TABLE(Histogram, wxWindow)
55 EVT_SIZE (Histogram::OnSize)
57 //---------------------
59 //----------------------
61 //EED Borrame 07Mai2009
62 //Histogram::Histogram( wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, int flag,vtkImageData* imageData):
63 Histogram::Histogram( wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, int flag):
64 wxPanel(parent,id,pos,size,flag)
66 SetBackgroundColour(wxColour(255,255,255));
68 //EED Borrame 07Mai2009
69 // histogram= new pHistogram(imageData);
72 plotter=new pPlotterWindow(this, -1, wxPoint(0,0), wxSize(742,476), wxSUNKEN_BORDER );
74 plotter->AddLayer(new pPlotterScaleX());
75 plotter->AddLayer(new pPlotterScaleY());
76 //is a plotter of histograms
79 plotter->setPopUpMenu(true,true,true,true,true,true,false,false,false,false,false,false,false);
84 //EED Borrame 07Mai2009
91 Histogram::~Histogram()
98 void Histogram::Configure(vtkImageData* imageData)
100 histogram= new pHistogram(imageData);
105 Draw the histogram in the plotter
107 void Histogram::drawHistogram()
109 //int xValues[MAX],yValues[MAX],extent[6];
113 vtkImageData* histogramImageData=histogram->getHistogram();
116 histogramSize=histogram->getSize();
119 xValues=(double*)malloc(NUM_POINTS*sizeof(double));
120 yValues=(double*)malloc(NUM_POINTS*sizeof(double));
122 double* histogramPointer=(double*)histogramImageData->GetScalarPointer(0,0,0);
125 for(i=0; i< histogramSize; i++)
128 if (histogramPointer[i]==0)
132 yValues[i]=log(histogramPointer[i])*10;
133 } // if histogramPointer
137 pGraphicalFunction* histogramFunction=plotter->getFunctionForVectors(xValues,histogramSize,yValues,histogramSize);
139 if (histogramFunction)
141 histogramFunction->setEditable(false);
143 histogramFunction->setType(2);
145 histogramFunction->setmType(2);
146 idHistogram=plotter->addFunction(histogramFunction);
147 //for setting range the vision
148 plotter->addFunctionToMove(histogramFunction);
149 wxPen mypen1(*wxBLUE, 1, wxSOLID );
151 histogramFunction->SetPen( mypen1 );
158 //plotter->setPopUpMenu(true,true,false,false,true,true,false,false,false,false,false,false,false);
162 if the user resize the window
164 void Histogram::OnSize(wxSizeEvent &WXUNUSED(event))
167 GetClientSize(&scrX,&scrY);
168 plotter->SetSize(scrX,scrY);
171 pGraphicalFunction* actual=plotter->getFunction(idTransferenceFunction);
172 actual->setScreens(scrX,scrY);
178 get a point of the Histogram
181 int Histogram::getHistogramPoint(int gValue)
183 return histogram->getHistogramPoint(gValue);
187 //-------------------
188 // Getter and setters
189 //-------------------
191 int Histogram::getHistogramSize()
193 return histogramSize;
196 wxWindow* Histogram::GetWindow()
201 pPlotterWindow* Histogram::GetPlotterWindow()