#include <HistogramWidget.h>
Public Member Functions | |
HistogramWidget (wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, int flag, vtkImageData *imageData, int type) | |
HistogramWidget (wxWindow *parent, wxWindowID id) | |
~HistogramWidget () | |
void | drawHistogram () |
void | drawTransferenceFunction () |
void | OnSize (wxSizeEvent &WXUNUSED(event)) |
int | getSizeTransferenceFunction () |
int | getSizeBarColor () |
void | getTransferenceFunctionPoint (int index, int &x, int &y) |
void | getDataBarColorPoint (int index, int &x, int &red, int &green, int &blue) |
int | getHistogramPoint (int gValue) |
float | getMaxShowedPorcentage () |
float | getMinShowedPorcentage () |
float | getActualShowedPorcentage () |
bool | addPointToTransferenceFunction (double x, double y) |
bool | addColorPoint (double x, int red, int green, int blue) |
void | updatePlotter () |
void | erasePointsTransferenceFunction () |
void | eraseColorPoints () |
void | setTransferenceFunctionHasPoints (bool hasPoints) |
void | setTransferenceFunctionHasColor (bool hasColorPoints) |
int | getHistogramSize () |
void | setType (int type) |
void | initializeHistogram (vtkImageData *img) |
void | GetValuesPointsFunction (std::vector< double > &greylevel, std::vector< double > &value) |
void | GetValuesColorPointsFunction (std::vector< double > &greylevel, std::vector< double > &red, std::vector< double > &green, std::vector< double > &blue) |
Private Member Functions | |
wxPanel * | getControls () |
DECLARE_CLASS (HistogramWidget) | |
Private Attributes | |
pHistogram * | histogram |
pPlotter * | plotter |
int | idTransferenceFunction |
int | histogramSize |
int | idHistogram |
bool | transferenceFunctionHasPoints |
bool | transferenceFunctionHasColor |
int | type |
Definition at line 31 of file HistogramWidget.h.
HistogramWidget::HistogramWidget | ( | wxWindow * | parent, | |
wxWindowID | id, | |||
const wxPoint & | pos, | |||
const wxSize & | size, | |||
int | flag, | |||
vtkImageData * | imageData, | |||
int | type | |||
) |
Definition at line 45 of file HistogramWidget.cxx.
00045 : 00046 wxPanel(parent,id,wxDefaultPosition,wxDefaultSize) 00047 { 00048 SetBackgroundColour(wxColour(255,255,255)); 00049 //histogram 00050 histogram= new pHistogram(imageData); 00051 00052 00053 //plotter 00054 plotter=new pPlotter(this, 400,350); 00055 00056 //is a plotter of histograms 00057 plotter->setType(2); 00058 //setting the popMenu 00059 plotter->setPopUpMenu(true,true,true,true,true,true,false,false,false,false,false,false,false); 00060 histogramSize=0; 00061 idTransferenceFunction=-1; 00062 idHistogram=-1; 00063 transferenceFunctionHasColor=true; 00064 transferenceFunctionHasPoints=true; 00065 this->type=type; 00066 00067 this->SetAutoLayout(true); 00068 this->Refresh(); 00069 00070 //drawing 00071 drawHistogram(); 00072 drawTransferenceFunction(); 00073 00074 }
HistogramWidget::HistogramWidget | ( | wxWindow * | parent, | |
wxWindowID | id | |||
) |
Definition at line 76 of file HistogramWidget.cxx.
References histogram, histogramSize, idHistogram, idTransferenceFunction, plotter, pPlotter::setPopUpMenu(), pPlotter::setType(), transferenceFunctionHasColor, transferenceFunctionHasPoints, and type.
00077 : wxPanel(parent,id){ 00078 00079 00080 SetBackgroundColour(wxColour(255,255,255)); 00081 histogram = NULL; 00082 00083 00084 //plotter 00085 plotter=new pPlotter(this, 400,350); 00086 00087 //is a plotter of histograms 00088 plotter->setType(2); 00089 //setting the popMenu 00090 plotter->setPopUpMenu(true,true,true,true,true,true,false,false,false,false,false,false,false); 00091 histogramSize=0; 00092 idTransferenceFunction=-1; 00093 idHistogram=-1; 00094 transferenceFunctionHasColor=true; 00095 transferenceFunctionHasPoints=true; 00096 this->type=type;; 00097 this->SetAutoLayout(true); 00098 this->Refresh(); 00099 00100 00101 }
HistogramWidget::~HistogramWidget | ( | ) |
bool HistogramWidget::addColorPoint | ( | double | x, | |
int | red, | |||
int | green, | |||
int | blue | |||
) |
Definition at line 328 of file HistogramWidget.cxx.
References pPlotter::addColorPoint(), and plotter.
Referenced by HistogramDialog::addColorPoint(), and HistogramDialog::OnLoadData().
00329 { 00330 return plotter->addColorPoint(x,red,green,blue); 00331 }
bool HistogramWidget::addPointToTransferenceFunction | ( | double | x, | |
double | y | |||
) |
Definition at line 312 of file HistogramWidget.cxx.
References pGraphicalFunction::AddPoint(), pPlotter::getFunction(), idTransferenceFunction, and plotter.
Referenced by HistogramDialog::addPointToTransferenceFunction(), and HistogramDialog::OnLoadData().
00313 { 00314 bool result=false; 00315 pGraphicalFunction* tf=plotter->getFunction(idTransferenceFunction); 00316 //printf("EED %p HistogramWidget::addPointToTransferenceFunction tp%p x%f y%f %d\n",this, tf, x ,y, idTransferenceFunction); 00317 if (tf!=NULL) { result=tf->AddPoint(x,y); } 00318 00319 return result; 00320 }
HistogramWidget::DECLARE_CLASS | ( | HistogramWidget | ) | [private] |
void HistogramWidget::drawHistogram | ( | ) |
Definition at line 123 of file HistogramWidget.cxx.
References pPlotter::addFunction(), pPlotter::addFunctionToMove(), pPlotter::getFunctionForVectors(), pHistogram::getHistogram(), pHistogram::getSize(), histogram, histogramSize, idHistogram, NUM_POINTS, plotter, pGraphicalFunction::setEditable(), pGraphicalFunction::setmType(), mpLayer::SetPen(), and pGraphicalFunction::setType().
Referenced by initializeHistogram().
00124 { 00125 //int xValues[MAX],yValues[MAX],extent[6]; 00126 double* xValues; 00127 double* yValues; 00128 00129 vtkImageData* histogramImageData=histogram->getHistogram(); 00130 00131 //size 00132 histogramSize=histogram->getSize(); 00133 00134 //plotting 00135 xValues=(double*)malloc(NUM_POINTS*sizeof(double)); 00136 yValues=(double*)malloc(NUM_POINTS*sizeof(double)); 00137 00138 unsigned short* histogramPointer=(unsigned short*)histogramImageData->GetScalarPointer(0,0,0); 00139 00140 for(int i=0; i< histogramSize; i++) 00141 { 00142 xValues[i]=i; 00143 yValues[i]=log( (double) histogramPointer[i]); 00144 } 00145 00146 00147 pGraphicalFunction* histogramFunction=plotter->getFunctionForVectors(xValues,histogramSize,yValues,histogramSize); 00148 00149 if (histogramFunction) 00150 { 00151 histogramFunction->setEditable(false); 00152 //smooth function 00153 histogramFunction->setType(2); 00154 //it is an histogram 00155 histogramFunction->setmType(2); 00156 idHistogram=plotter->addFunction(histogramFunction); 00157 //for setting range the vision 00158 plotter->addFunctionToMove(histogramFunction); 00159 wxPen mypen1(*wxBLUE, 1, wxSOLID ); 00160 mypen1.SetWidth(2); 00161 histogramFunction->SetPen( mypen1 ); 00162 } 00163 00164 free(xValues); 00165 free(yValues); 00166 00167 }
void HistogramWidget::drawTransferenceFunction | ( | ) |
Definition at line 172 of file HistogramWidget.cxx.
References pPlotter::addFunction(), pPlotter::addFunctionToMove(), pPlotter::getFunctionForVectors(), pHistogram::getMaximumLevelOfGrey(), histogram, idTransferenceFunction, plotter, pGraphicalFunction::setActual(), mpLayer::SetPen(), pGraphicalFunction::SetShowPoints(), pGraphicalFunction::setType(), and type.
Referenced by initializeHistogram().
00173 { 00174 00175 double xValues[5],yValues[5]; 00176 //xValues 00177 int maxValueGrey=histogram->getMaximumLevelOfGrey(); 00178 xValues[0]=0; 00179 xValues[1]=maxValueGrey/16; 00180 xValues[2]=maxValueGrey/8; 00181 xValues[3]=maxValueGrey/16+(maxValueGrey-maxValueGrey/2)/2; 00182 xValues[4]=maxValueGrey; 00183 00184 //yValues 00185 yValues[0]=0; 00186 yValues[1]=25; 00187 yValues[2]=100; 00188 yValues[3]=25; 00189 yValues[4]=0; 00190 00191 pGraphicalFunction * tf = plotter ->getFunctionForVectors( xValues, 5, yValues, 5 ); 00192 printf("EED %p HistogramWidget::drawTransferenceFunction %p\n", this , tf); 00193 // Including and drawing the created function in the plotter 00194 if (tf) 00195 { 00196 tf->setType(1); 00197 //is the actual Function 00198 tf->setActual(true); 00199 //show points 00200 tf->SetShowPoints(true); 00201 idTransferenceFunction=plotter->addFunction( tf ); 00202 if(type==1) 00203 plotter->addFunctionToMove(tf); 00204 wxPen mypen(*wxBLACK,0.5, wxSOLID ); 00205 mypen.SetWidth(2); 00206 tf->SetPen( mypen ); 00207 } 00208 }
void HistogramWidget::eraseColorPoints | ( | ) |
Definition at line 363 of file HistogramWidget.cxx.
References pPlotter::eraseColorPoints(), and plotter.
Referenced by HistogramDialog::eraseColorPoints().
00364 { 00365 plotter->eraseColorPoints(); 00366 }
void HistogramWidget::erasePointsTransferenceFunction | ( | ) |
Definition at line 340 of file HistogramWidget.cxx.
References pGraphicalFunction::deletePointAt(), pPlotter::getFunction(), pGraphicalFunction::getSizePoints(), idTransferenceFunction, plotter, and transferenceFunctionHasPoints.
Referenced by HistogramDialog::erasePointsTransferenceFunction().
00341 { 00342 if(transferenceFunctionHasPoints) 00343 { 00344 // we have to erase the points 00345 pGraphicalFunction* tf=plotter->getFunction(idTransferenceFunction); 00346 if (tf!=NULL){ 00347 int numOfPoints=tf->getSizePoints(); 00348 int i=numOfPoints-1;//-2; 00349 while(i>=0) 00350 { 00351 tf->deletePointAt(i); 00352 i--; 00353 } // while 00354 } // if tf 00355 } // if transferenceFunctionHasPoints 00356 00357 //we set for actual the histogram 00358 //plotter->setActual() 00359 }
float HistogramWidget::getActualShowedPorcentage | ( | ) |
Definition at line 297 of file HistogramWidget.cxx.
References pPlotter::getFunction(), pGraphicalFunction::getMaxX(), pPlotter::getMinShowedPorcentage(), pGraphicalFunction::getMinX(), idHistogram, min, and plotter.
Referenced by HistogramDialog::getActualShowedPorcentage().
00298 { 00299 float porcentageActualX=plotter->getMinShowedPorcentage(); 00300 pGraphicalFunction* histogramFunction=plotter->getFunction(idHistogram); 00301 int min=histogramFunction->getMinX(); 00302 float x=porcentageActualX*(histogramFunction->getMaxX()-min); 00303 return min+ x; 00304 }
wxPanel* HistogramWidget::getControls | ( | ) | [private] |
void HistogramWidget::getDataBarColorPoint | ( | int | index, | |
int & | x, | |||
int & | red, | |||
int & | green, | |||
int & | blue | |||
) |
Definition at line 266 of file HistogramWidget.cxx.
References pPlotter::getBarColorDataAt(), and plotter.
Referenced by HistogramDialog::getDataBarColorPoint(), and HistogramDialog::OnSaveData().
00267 { 00268 double tmp=x; 00269 plotter->getBarColorDataAt(index,tmp,red,green,blue); 00270 x=(int)tmp; 00271 }
int HistogramWidget::getHistogramPoint | ( | int | gValue | ) |
Definition at line 252 of file HistogramWidget.cxx.
References pHistogram::getHistogramPoint(), and histogram.
Referenced by HistogramDialog::getHistogramPoint().
00253 { 00254 return histogram->getHistogramPoint(gValue); 00255 }
int HistogramWidget::getHistogramSize | ( | ) |
Definition at line 388 of file HistogramWidget.cxx.
References histogramSize.
00389 { 00390 return histogramSize; 00391 }
float HistogramWidget::getMaxShowedPorcentage | ( | ) |
Definition at line 275 of file HistogramWidget.cxx.
References pPlotter::getFunction(), pPlotter::getMaxShowedPorcentage(), pGraphicalFunction::getMaxX(), pGraphicalFunction::getMinX(), idHistogram, min, and plotter.
Referenced by HistogramDialog::getMaxShowedPorcentage().
00276 { 00277 float porcentageMaxX=plotter->getMaxShowedPorcentage(); 00278 pGraphicalFunction* histogramFunction=plotter->getFunction(idHistogram); 00279 int min=histogramFunction->getMinX(); 00280 float x=porcentageMaxX*(histogramFunction->getMaxX()-min); 00281 return min+ x; 00282 }
float HistogramWidget::getMinShowedPorcentage | ( | ) |
Definition at line 286 of file HistogramWidget.cxx.
References pPlotter::getFunction(), pGraphicalFunction::getMaxX(), pPlotter::getMinShowedPorcentage(), pGraphicalFunction::getMinX(), idHistogram, min, and plotter.
Referenced by HistogramDialog::getMinShowedPorcentage().
00287 { 00288 float porcentageMinX=plotter->getMinShowedPorcentage(); 00289 pGraphicalFunction* histogramFunction=plotter->getFunction(idHistogram); 00290 int min=histogramFunction->getMinX(); 00291 float x=porcentageMinX*(histogramFunction->getMaxX()-min); 00292 return min+ x; 00293 }
int HistogramWidget::getSizeBarColor | ( | ) |
Definition at line 259 of file HistogramWidget.cxx.
References pPlotter::getColorPointsSize(), and plotter.
Referenced by HistogramDialog::getSizeBarColor(), and HistogramDialog::OnSaveData().
00260 { 00261 return plotter->getColorPointsSize(); 00262 }
int HistogramWidget::getSizeTransferenceFunction | ( | ) |
Definition at line 228 of file HistogramWidget.cxx.
References pPlotter::getFunction(), pGraphicalFunction::getSizePoints(), idTransferenceFunction, and plotter.
Referenced by HistogramDialog::getSizeTransferenceFunction(), and HistogramDialog::OnSaveData().
00229 { 00230 pGraphicalFunction* tf=plotter->getFunction(idTransferenceFunction); 00231 return tf->getSizePoints(); 00232 00233 }
void HistogramWidget::getTransferenceFunctionPoint | ( | int | index, | |
int & | x, | |||
int & | y | |||
) |
Definition at line 237 of file HistogramWidget.cxx.
References pPlotter::getFunction(), pGraphicalFunction::GetPointAt(), pFunctionPoint::getRealX(), pFunctionPoint::getRealY(), idTransferenceFunction, and plotter.
Referenced by HistogramDialog::getTransferenceFunctionPoint(), and HistogramDialog::OnSaveData().
00238 { 00239 pGraphicalFunction* tf=plotter->getFunction(idTransferenceFunction); 00240 if(tf) 00241 { 00242 wxNode* pnode=tf->GetPointAt(index); 00243 pFunctionPoint* point=(pFunctionPoint*)pnode->GetData(); 00244 x=point->getRealX(); 00245 y=point->getRealY(); 00246 } 00247 }
void HistogramWidget::GetValuesColorPointsFunction | ( | std::vector< double > & | greylevel, | |
std::vector< double > & | red, | |||
std::vector< double > & | green, | |||
std::vector< double > & | blue | |||
) |
Returns two vectors, the grey level of the point and its value, the red, green and blue value is between [0,1]
Definition at line 408 of file HistogramWidget.cxx.
References pPlotter::GetValuesColorPointsFunction(), and plotter.
Referenced by HistogramDialog::GetValuesColorPointsFunction().
00412 { 00413 plotter->GetValuesColorPointsFunction(greylevel,red,green,blue); 00414 }
void HistogramWidget::GetValuesPointsFunction | ( | std::vector< double > & | greylevel, | |
std::vector< double > & | value | |||
) |
Returns two vectors, the grey level of the point and its value, the value is between [0,1]
Definition at line 400 of file HistogramWidget.cxx.
References pPlotter::GetValuesPointsFunction(), histogramSize, and plotter.
Referenced by HistogramDialog::GetValuesPointsFunction().
00400 { 00401 plotter->GetValuesPointsFunction(greylevel,value,histogramSize); 00402 }
void HistogramWidget::initializeHistogram | ( | vtkImageData * | img | ) |
Initialize the histogram
Definition at line 105 of file HistogramWidget.cxx.
References drawHistogram(), drawTransferenceFunction(), and histogram.
Referenced by HistogramDialog::initializeHistogram().
00105 { 00106 if(histogram ==NULL){ 00107 histogram= new pHistogram(img); 00108 } 00109 //draw 00110 drawHistogram(); 00111 drawTransferenceFunction(); 00112 }
void HistogramWidget::OnSize | ( | wxSizeEvent & | WXUNUSEDevent | ) |
Definition at line 213 of file HistogramWidget.cxx.
References pPlotter::getFunction(), idTransferenceFunction, plotter, pGraphicalFunction::setScales(), and pGraphicalFunction::setScreens().
00214 { 00215 int scrX,scrY; 00216 GetClientSize(&scrX,&scrY); 00217 plotter->SetSize(scrX,scrY); 00218 pGraphicalFunction* actual=plotter->getFunction(idTransferenceFunction); 00219 if(actual!=NULL){ 00220 actual->setScreens(scrX,scrY); 00221 actual->setScales(); 00222 } 00223 00224 }
void HistogramWidget::setTransferenceFunctionHasColor | ( | bool | hasColorPoints | ) |
Definition at line 384 of file HistogramWidget.cxx.
References transferenceFunctionHasPoints.
Referenced by HistogramDialog::setTransferenceFunctionHasColor().
00385 { 00386 transferenceFunctionHasPoints=hasColorPoints; 00387 }
void HistogramWidget::setTransferenceFunctionHasPoints | ( | bool | hasPoints | ) |
Definition at line 379 of file HistogramWidget.cxx.
References transferenceFunctionHasPoints.
Referenced by HistogramDialog::setTransferenceFunctionHasPoints().
00380 { 00381 transferenceFunctionHasPoints=hasPoints; 00382 }
void HistogramWidget::setType | ( | int | type | ) |
Definition at line 392 of file HistogramWidget.cxx.
void HistogramWidget::updatePlotter | ( | ) |
Definition at line 370 of file HistogramWidget.cxx.
References plotter, and pPlotter::update().
Referenced by HistogramDialog::OnLoadData(), and HistogramDialog::updatePlotter().
pHistogram* HistogramWidget::histogram [private] |
Definition at line 161 of file HistogramWidget.h.
Referenced by drawHistogram(), drawTransferenceFunction(), getHistogramPoint(), HistogramWidget(), initializeHistogram(), and ~HistogramWidget().
int HistogramWidget::histogramSize [private] |
Definition at line 164 of file HistogramWidget.h.
Referenced by drawHistogram(), getHistogramSize(), GetValuesPointsFunction(), and HistogramWidget().
int HistogramWidget::idHistogram [private] |
Definition at line 165 of file HistogramWidget.h.
Referenced by drawHistogram(), getActualShowedPorcentage(), getMaxShowedPorcentage(), getMinShowedPorcentage(), and HistogramWidget().
int HistogramWidget::idTransferenceFunction [private] |
Definition at line 163 of file HistogramWidget.h.
Referenced by addPointToTransferenceFunction(), drawTransferenceFunction(), erasePointsTransferenceFunction(), getSizeTransferenceFunction(), getTransferenceFunctionPoint(), HistogramWidget(), and OnSize().
pPlotter* HistogramWidget::plotter [private] |
Definition at line 162 of file HistogramWidget.h.
Referenced by addColorPoint(), addPointToTransferenceFunction(), drawHistogram(), drawTransferenceFunction(), eraseColorPoints(), erasePointsTransferenceFunction(), getActualShowedPorcentage(), getDataBarColorPoint(), getMaxShowedPorcentage(), getMinShowedPorcentage(), getSizeBarColor(), getSizeTransferenceFunction(), getTransferenceFunctionPoint(), GetValuesColorPointsFunction(), GetValuesPointsFunction(), HistogramWidget(), OnSize(), updatePlotter(), and ~HistogramWidget().
bool HistogramWidget::transferenceFunctionHasColor [private] |
Definition at line 172 of file HistogramWidget.h.
Referenced by HistogramWidget().
bool HistogramWidget::transferenceFunctionHasPoints [private] |
Definition at line 171 of file HistogramWidget.h.
Referenced by erasePointsTransferenceFunction(), HistogramWidget(), setTransferenceFunctionHasColor(), and setTransferenceFunctionHasPoints().
int HistogramWidget::type [private] |
Definition at line 178 of file HistogramWidget.h.
Referenced by drawTransferenceFunction(), and HistogramWidget().