2 This class plots image's histograms in a plotter
5 //---------------------
7 //----------------------
9 #include "vtkImageCast.h"
11 // ----------------------------------------------------------------------------
12 // WX headers inclusion.
13 // For compilers that support precompilation, includes <wx/wx.h>.
14 // ----------------------------------------------------------------------------
20 //----------------------------------------------------------------------------
21 // Class implementation
22 //----------------------------------------------------------------------------
24 IMPLEMENT_CLASS(Histogram, wxWindow)
25 //----------------------------------------------------------------------------
27 //----------------------------------------------------------------------------
29 BEGIN_EVENT_TABLE(Histogram, wxWindow)
30 EVT_SIZE (Histogram::OnSize)
32 //---------------------
34 //----------------------
36 //EED Borrame 07Mai2009
37 //Histogram::Histogram( wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, int flag,vtkImageData* imageData):
38 Histogram::Histogram( wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, int flag):
39 wxPanel(parent,id,pos,size,flag)
41 SetBackgroundColour(wxColour(255,255,255));
43 //EED Borrame 07Mai2009
44 // histogram= new pHistogram(imageData);
47 plotter=new pPlotterWindow(this, -1, wxPoint(0,0), wxSize(742,476), wxSUNKEN_BORDER );
49 plotter->AddLayer(new pPlotterScaleX());
50 plotter->AddLayer(new pPlotterScaleY());
51 //is a plotter of histograms
54 plotter->setPopUpMenu(true,true,true,true,true,true,false,false,false,false,false,false,false);
59 //EED Borrame 07Mai2009
66 Histogram::~Histogram()
73 void Histogram::Configure(vtkImageData* imageData)
75 histogram= new pHistogram(imageData);
80 Draw the histogram in the plotter
82 void Histogram::drawHistogram()
84 //int xValues[MAX],yValues[MAX],extent[6];
88 vtkImageData* histogramImageData=histogram->getHistogram();
91 histogramSize=histogram->getSize();
94 xValues=(double*)malloc(NUM_POINTS*sizeof(double));
95 yValues=(double*)malloc(NUM_POINTS*sizeof(double));
97 unsigned short* histogramPointer=(unsigned short*)histogramImageData->GetScalarPointer(0,0,0);
99 for(int i=0; i< histogramSize; i++)
102 yValues[i]=log( (double) histogramPointer[i])*10;
106 pGraphicalFunction* histogramFunction=plotter->getFunctionForVectors(xValues,histogramSize,yValues,histogramSize);
108 if (histogramFunction)
110 histogramFunction->setEditable(false);
112 histogramFunction->setType(2);
114 histogramFunction->setmType(2);
115 idHistogram=plotter->addFunction(histogramFunction);
116 //for setting range the vision
117 plotter->addFunctionToMove(histogramFunction);
118 wxPen mypen1(*wxBLUE, 1, wxSOLID );
120 histogramFunction->SetPen( mypen1 );
127 //plotter->setPopUpMenu(true,true,false,false,true,true,false,false,false,false,false,false,false);
131 if the user resize the window
133 void Histogram::OnSize(wxSizeEvent &WXUNUSED(event))
136 GetClientSize(&scrX,&scrY);
137 plotter->SetSize(scrX,scrY);
139 pGraphicalFunction* actual=plotter->getFunction(idTransferenceFunction);
140 actual->setScreens(scrX,scrY);
146 get a point of the Histogram
149 int Histogram::getHistogramPoint(int gValue)
151 return histogram->getHistogramPoint(gValue);
155 //-------------------
156 // Getter and setters
157 //-------------------
159 int Histogram::getHistogramSize()
161 return histogramSize;