#include <HistogramWidget.h>
Public Member Functions | |
HistogramWidget (wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, int flag, vtkImageData *imageData, int type) | |
~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) |
Private Member Functions | |
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 43 of file HistogramWidget.cxx.
00043 : 00044 wxPanel(parent,id,pos,size,flag) 00045 { 00046 SetBackgroundColour(wxColour(255,255,255)); 00047 //histogram 00048 histogram= new pHistogram(imageData); 00049 00050 //plotter 00051 plotter=new pPlotter(this, 400,350); 00052 00053 //is a plotter of histograms 00054 plotter->setType(2); 00055 //setting the popMenu 00056 plotter->setPopUpMenu(true,true,true,true,true,true,false,false,false,false,false,false,false); 00057 histogramSize=0; 00058 idTransferenceFunction=-1; 00059 idHistogram=-1; 00060 transferenceFunctionHasColor=true; 00061 transferenceFunctionHasPoints=true; 00062 this->type=type;; 00063 00064 //drawing 00065 drawHistogram(); 00066 drawTransferenceFunction(); 00067 00068 }
HistogramWidget::~HistogramWidget | ( | ) |
bool HistogramWidget::addColorPoint | ( | double | x, | |
int | red, | |||
int | green, | |||
int | blue | |||
) |
Definition at line 284 of file HistogramWidget.cxx.
References pPlotter::addColorPoint(), and plotter.
Referenced by HistogramDialog::addColorPoint(), and HistogramDialog::OnLoadData().
00285 { 00286 return plotter->addColorPoint(x,red,green,blue); 00287 }
bool HistogramWidget::addPointToTransferenceFunction | ( | double | x, | |
double | y | |||
) |
Definition at line 268 of file HistogramWidget.cxx.
References pGraphicalFunction::AddPoint(), pPlotter::getFunction(), idTransferenceFunction, and plotter.
Referenced by HistogramDialog::addPointToTransferenceFunction(), and HistogramDialog::OnLoadData().
00269 { 00270 bool result=false; 00271 pGraphicalFunction* tf=plotter->getFunction(idTransferenceFunction); 00272 printf("EED %p HistogramWidget::addPointToTransferenceFunction tp%p x%f y%f %d\n",this, tf, x ,y, idTransferenceFunction); 00273 if (tf!=NULL) { result=tf->AddPoint(x,y); } 00274 00275 return result; 00276 }
HistogramWidget::DECLARE_CLASS | ( | HistogramWidget | ) | [private] |
void HistogramWidget::drawHistogram | ( | ) |
Definition at line 79 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().
00080 { 00081 //int xValues[MAX],yValues[MAX],extent[6]; 00082 double* xValues; 00083 double* yValues; 00084 00085 vtkImageData* histogramImageData=histogram->getHistogram(); 00086 00087 //size 00088 histogramSize=histogram->getSize(); 00089 00090 //plotting 00091 xValues=(double*)malloc(NUM_POINTS*sizeof(double)); 00092 yValues=(double*)malloc(NUM_POINTS*sizeof(double)); 00093 00094 unsigned short* histogramPointer=(unsigned short*)histogramImageData->GetScalarPointer(0,0,0); 00095 00096 for(int i=0; i< histogramSize; i++) 00097 { 00098 xValues[i]=i; 00099 yValues[i]=log( (double) histogramPointer[i]); 00100 } 00101 00102 00103 pGraphicalFunction* histogramFunction=plotter->getFunctionForVectors(xValues,histogramSize,yValues,histogramSize); 00104 00105 if (histogramFunction) 00106 { 00107 histogramFunction->setEditable(false); 00108 //smooth function 00109 histogramFunction->setType(2); 00110 //it is an histogram 00111 histogramFunction->setmType(2); 00112 idHistogram=plotter->addFunction(histogramFunction); 00113 //for setting range the vision 00114 plotter->addFunctionToMove(histogramFunction); 00115 wxPen mypen1(*wxBLUE, 1, wxSOLID ); 00116 mypen1.SetWidth(2); 00117 histogramFunction->SetPen( mypen1 ); 00118 } 00119 00120 free(xValues); 00121 free(yValues); 00122 00123 }
void HistogramWidget::drawTransferenceFunction | ( | ) |
Definition at line 128 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.
00129 { 00130 00131 double xValues[5],yValues[5]; 00132 //xValues 00133 int maxValueGrey=histogram->getMaximumLevelOfGrey(); 00134 xValues[0]=0; 00135 xValues[1]=maxValueGrey/16; 00136 xValues[2]=maxValueGrey/8; 00137 xValues[3]=maxValueGrey/16+(maxValueGrey-maxValueGrey/2)/2; 00138 xValues[4]=maxValueGrey; 00139 00140 //yValues 00141 yValues[0]=0; 00142 yValues[1]=25; 00143 yValues[2]=100; 00144 yValues[3]=25; 00145 yValues[4]=0; 00146 00147 pGraphicalFunction * tf = plotter ->getFunctionForVectors( xValues, 5, yValues, 5 ); 00148 printf("EED %p HistogramWidget::drawTransferenceFunction %p\n", this , tf); 00149 // Including and drawing the created function in the plotter 00150 if (tf) 00151 { 00152 tf->setType(1); 00153 //is the actual Function 00154 tf->setActual(true); 00155 //show points 00156 tf->SetShowPoints(true); 00157 idTransferenceFunction=plotter->addFunction( tf ); 00158 if(type==1) 00159 plotter->addFunctionToMove(tf); 00160 wxPen mypen(*wxBLACK,0.5, wxSOLID ); 00161 mypen.SetWidth(2); 00162 tf->SetPen( mypen ); 00163 } 00164 }
void HistogramWidget::eraseColorPoints | ( | ) |
Definition at line 319 of file HistogramWidget.cxx.
References pPlotter::eraseColorPoints(), and plotter.
Referenced by HistogramDialog::eraseColorPoints().
00320 { 00321 plotter->eraseColorPoints(); 00322 }
void HistogramWidget::erasePointsTransferenceFunction | ( | ) |
Definition at line 296 of file HistogramWidget.cxx.
References pGraphicalFunction::deletePointAt(), pPlotter::getFunction(), pGraphicalFunction::getSizePoints(), idTransferenceFunction, plotter, and transferenceFunctionHasPoints.
Referenced by HistogramDialog::erasePointsTransferenceFunction().
00297 { 00298 if(transferenceFunctionHasPoints) 00299 { 00300 // we have to erase the points 00301 pGraphicalFunction* tf=plotter->getFunction(idTransferenceFunction); 00302 if (tf!=NULL){ 00303 int numOfPoints=tf->getSizePoints(); 00304 int i=numOfPoints-1;//-2; 00305 while(i>=0) 00306 { 00307 tf->deletePointAt(i); 00308 i--; 00309 } // while 00310 } // if tf 00311 } // if transferenceFunctionHasPoints 00312 00313 //we set for actual the histogram 00314 //plotter->setActual() 00315 }
float HistogramWidget::getActualShowedPorcentage | ( | ) |
Definition at line 253 of file HistogramWidget.cxx.
References pPlotter::getFunction(), pGraphicalFunction::getMaxX(), pPlotter::getMinShowedPorcentage(), pGraphicalFunction::getMinX(), idHistogram, min, and plotter.
Referenced by HistogramDialog::getActualShowedPorcentage().
00254 { 00255 float porcentageActualX=plotter->getMinShowedPorcentage(); 00256 pGraphicalFunction* histogramFunction=plotter->getFunction(idHistogram); 00257 int min=histogramFunction->getMinX(); 00258 float x=porcentageActualX*(histogramFunction->getMaxX()-min); 00259 return min+ x; 00260 }
void HistogramWidget::getDataBarColorPoint | ( | int | index, | |
int & | x, | |||
int & | red, | |||
int & | green, | |||
int & | blue | |||
) |
Definition at line 222 of file HistogramWidget.cxx.
References pPlotter::getBarColorDataAt(), and plotter.
Referenced by HistogramDialog::getDataBarColorPoint(), and HistogramDialog::OnSaveData().
00223 { 00224 double tmp=x; 00225 plotter->getBarColorDataAt(index,tmp,red,green,blue); 00226 x=(int)tmp; 00227 }
int HistogramWidget::getHistogramPoint | ( | int | gValue | ) |
Definition at line 208 of file HistogramWidget.cxx.
References pHistogram::getHistogramPoint(), and histogram.
Referenced by HistogramDialog::getHistogramPoint().
00209 { 00210 return histogram->getHistogramPoint(gValue); 00211 }
int HistogramWidget::getHistogramSize | ( | ) |
Definition at line 344 of file HistogramWidget.cxx.
References histogramSize.
00345 { 00346 return histogramSize; 00347 }
float HistogramWidget::getMaxShowedPorcentage | ( | ) |
Definition at line 231 of file HistogramWidget.cxx.
References pPlotter::getFunction(), pPlotter::getMaxShowedPorcentage(), pGraphicalFunction::getMaxX(), pGraphicalFunction::getMinX(), idHistogram, min, and plotter.
Referenced by HistogramDialog::getMaxShowedPorcentage().
00232 { 00233 float porcentageMaxX=plotter->getMaxShowedPorcentage(); 00234 pGraphicalFunction* histogramFunction=plotter->getFunction(idHistogram); 00235 int min=histogramFunction->getMinX(); 00236 float x=porcentageMaxX*(histogramFunction->getMaxX()-min); 00237 return min+ x; 00238 }
float HistogramWidget::getMinShowedPorcentage | ( | ) |
Definition at line 242 of file HistogramWidget.cxx.
References pPlotter::getFunction(), pGraphicalFunction::getMaxX(), pPlotter::getMinShowedPorcentage(), pGraphicalFunction::getMinX(), idHistogram, min, and plotter.
Referenced by HistogramDialog::getMinShowedPorcentage().
00243 { 00244 float porcentageMinX=plotter->getMinShowedPorcentage(); 00245 pGraphicalFunction* histogramFunction=plotter->getFunction(idHistogram); 00246 int min=histogramFunction->getMinX(); 00247 float x=porcentageMinX*(histogramFunction->getMaxX()-min); 00248 return min+ x; 00249 }
int HistogramWidget::getSizeBarColor | ( | ) |
Definition at line 215 of file HistogramWidget.cxx.
References pPlotter::getColorPointsSize(), and plotter.
Referenced by HistogramDialog::getSizeBarColor(), and HistogramDialog::OnSaveData().
00216 { 00217 return plotter->getColorPointsSize(); 00218 }
int HistogramWidget::getSizeTransferenceFunction | ( | ) |
Definition at line 184 of file HistogramWidget.cxx.
References pPlotter::getFunction(), pGraphicalFunction::getSizePoints(), idTransferenceFunction, and plotter.
Referenced by HistogramDialog::getSizeTransferenceFunction(), and HistogramDialog::OnSaveData().
00185 { 00186 pGraphicalFunction* tf=plotter->getFunction(idTransferenceFunction); 00187 return tf->getSizePoints(); 00188 00189 }
void HistogramWidget::getTransferenceFunctionPoint | ( | int | index, | |
int & | x, | |||
int & | y | |||
) |
Definition at line 193 of file HistogramWidget.cxx.
References pPlotter::getFunction(), pGraphicalFunction::GetPointAt(), pFunctionPoint::getRealX(), pFunctionPoint::getRealY(), idTransferenceFunction, and plotter.
Referenced by HistogramDialog::getTransferenceFunctionPoint(), and HistogramDialog::OnSaveData().
00194 { 00195 pGraphicalFunction* tf=plotter->getFunction(idTransferenceFunction); 00196 if(tf) 00197 { 00198 wxNode* pnode=tf->GetPointAt(index); 00199 pFunctionPoint* point=(pFunctionPoint*)pnode->GetData(); 00200 x=point->getRealX(); 00201 y=point->getRealY(); 00202 } 00203 }
void HistogramWidget::OnSize | ( | wxSizeEvent & | WXUNUSEDevent | ) |
Definition at line 169 of file HistogramWidget.cxx.
References pPlotter::getFunction(), idTransferenceFunction, plotter, pGraphicalFunction::setScales(), and pGraphicalFunction::setScreens().
00170 { 00171 int scrX,scrY; 00172 GetClientSize(&scrX,&scrY); 00173 plotter->SetSize(scrX,scrY); 00174 pGraphicalFunction* actual=plotter->getFunction(idTransferenceFunction); 00175 if(actual!=NULL){ 00176 actual->setScreens(scrX,scrY); 00177 actual->setScales(); 00178 } 00179 00180 }
void HistogramWidget::setTransferenceFunctionHasColor | ( | bool | hasColorPoints | ) |
Definition at line 340 of file HistogramWidget.cxx.
References transferenceFunctionHasPoints.
Referenced by HistogramDialog::setTransferenceFunctionHasColor().
00341 { 00342 transferenceFunctionHasPoints=hasColorPoints; 00343 }
void HistogramWidget::setTransferenceFunctionHasPoints | ( | bool | hasPoints | ) |
Definition at line 335 of file HistogramWidget.cxx.
References transferenceFunctionHasPoints.
Referenced by HistogramDialog::setTransferenceFunctionHasPoints().
00336 { 00337 transferenceFunctionHasPoints=hasPoints; 00338 }
void HistogramWidget::setType | ( | int | type | ) |
void HistogramWidget::updatePlotter | ( | ) |
Definition at line 326 of file HistogramWidget.cxx.
References plotter, and pPlotter::update().
Referenced by HistogramDialog::OnLoadData(), and HistogramDialog::updatePlotter().
pHistogram* HistogramWidget::histogram [private] |
Definition at line 141 of file HistogramWidget.h.
Referenced by drawHistogram(), drawTransferenceFunction(), getHistogramPoint(), and ~HistogramWidget().
int HistogramWidget::histogramSize [private] |
Definition at line 144 of file HistogramWidget.h.
Referenced by drawHistogram(), and getHistogramSize().
int HistogramWidget::idHistogram [private] |
Definition at line 145 of file HistogramWidget.h.
Referenced by drawHistogram(), getActualShowedPorcentage(), getMaxShowedPorcentage(), and getMinShowedPorcentage().
int HistogramWidget::idTransferenceFunction [private] |
Definition at line 143 of file HistogramWidget.h.
Referenced by addPointToTransferenceFunction(), drawTransferenceFunction(), erasePointsTransferenceFunction(), getSizeTransferenceFunction(), getTransferenceFunctionPoint(), and OnSize().
pPlotter* HistogramWidget::plotter [private] |
Definition at line 142 of file HistogramWidget.h.
Referenced by addColorPoint(), addPointToTransferenceFunction(), drawHistogram(), drawTransferenceFunction(), eraseColorPoints(), erasePointsTransferenceFunction(), getActualShowedPorcentage(), getDataBarColorPoint(), getMaxShowedPorcentage(), getMinShowedPorcentage(), getSizeBarColor(), getSizeTransferenceFunction(), getTransferenceFunctionPoint(), OnSize(), updatePlotter(), and ~HistogramWidget().
bool HistogramWidget::transferenceFunctionHasColor [private] |
Definition at line 152 of file HistogramWidget.h.
bool HistogramWidget::transferenceFunctionHasPoints [private] |
Definition at line 151 of file HistogramWidget.h.
Referenced by erasePointsTransferenceFunction(), setTransferenceFunctionHasColor(), and setTransferenceFunctionHasPoints().
int HistogramWidget::type [private] |