HistogramWidget Class Reference

#include <HistogramWidget.h>

Collaboration diagram for HistogramWidget:

Collaboration graph
[legend]

List of all members.

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

 DECLARE_CLASS (HistogramWidget)

Private Attributes

pHistogramhistogram
pPlotterplotter
int idTransferenceFunction
int histogramSize
int idHistogram
bool transferenceFunctionHasPoints
bool transferenceFunctionHasColor
int type


Detailed Description

Definition at line 31 of file HistogramWidget.h.


Constructor & Destructor Documentation

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)
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 ( wxWindow *  parent,
wxWindowID  id 
)

Definition at line 70 of file HistogramWidget.cxx.

References histogram, histogramSize, idHistogram, idTransferenceFunction, plotter, pPlotter::setPopUpMenu(), pPlotter::setType(), transferenceFunctionHasColor, transferenceFunctionHasPoints, and type.

00071                 : wxPanel(parent,id){
00072 
00073 
00074                         SetBackgroundColour(wxColour(255,255,255));
00075                         histogram = NULL;       
00076                         
00077                         //plotter
00078                         plotter=new pPlotter(this, 400,350);
00079 
00080                         //is a plotter of histograms
00081                         plotter->setType(2);
00082                         //setting the popMenu
00083                         plotter->setPopUpMenu(true,true,true,true,true,true,false,false,false,false,false,false,false);
00084                         histogramSize=0;
00085                         idTransferenceFunction=-1;
00086                         idHistogram=-1;
00087                         transferenceFunctionHasColor=true;
00088                         transferenceFunctionHasPoints=true;
00089                         this->type=type;;
00090                 
00091                                 
00092         }

Here is the call graph for this function:

HistogramWidget::~HistogramWidget (  ) 

Definition at line 103 of file HistogramWidget.cxx.

References histogram, and plotter.

00104         {
00105                 delete histogram;
00106                 delete plotter;
00107 
00108         }


Member Function Documentation

void HistogramWidget::drawHistogram (  ) 

Definition at line 112 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().

00113         {
00114                 //int xValues[MAX],yValues[MAX],extent[6];
00115                 double* xValues;
00116                 double* yValues;
00117                 
00118                 vtkImageData* histogramImageData=histogram->getHistogram();
00119                 
00120                 //size
00121                 histogramSize=histogram->getSize();
00122 
00123                 //plotting
00124                 xValues=(double*)malloc(NUM_POINTS*sizeof(double));
00125                 yValues=(double*)malloc(NUM_POINTS*sizeof(double));
00126                 
00127                 unsigned short* histogramPointer=(unsigned short*)histogramImageData->GetScalarPointer(0,0,0);
00128                 
00129                 for(int i=0; i< histogramSize; i++)
00130                 {
00131                         xValues[i]=i;
00132                         yValues[i]=log( (double) histogramPointer[i]);
00133                 }
00134 
00135                 
00136                 pGraphicalFunction* histogramFunction=plotter->getFunctionForVectors(xValues,histogramSize,yValues,histogramSize);
00137                 
00138                 if (histogramFunction)
00139                 {
00140                         histogramFunction->setEditable(false);
00141                         //smooth function
00142                         histogramFunction->setType(2);
00143                         //it is an histogram
00144                         histogramFunction->setmType(2);
00145                         idHistogram=plotter->addFunction(histogramFunction);
00146                         //for setting range the vision
00147                         plotter->addFunctionToMove(histogramFunction);
00148                         wxPen mypen1(*wxBLUE, 1, wxSOLID );
00149                         mypen1.SetWidth(2);
00150                         histogramFunction->SetPen( mypen1 );
00151                 }
00152                         
00153                         free(xValues);
00154                         free(yValues);
00155                 
00156         }

Here is the call graph for this function:

Here is the caller graph for this function:

void HistogramWidget::drawTransferenceFunction (  ) 

Definition at line 161 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().

00162         {
00163         
00164                         double xValues[5],yValues[5];
00165                         //xValues
00166                         int maxValueGrey=histogram->getMaximumLevelOfGrey();
00167                         xValues[0]=0;
00168                         xValues[1]=maxValueGrey/16;
00169                         xValues[2]=maxValueGrey/8;
00170                         xValues[3]=maxValueGrey/16+(maxValueGrey-maxValueGrey/2)/2;
00171                         xValues[4]=maxValueGrey;
00172                         
00173                         //yValues
00174                         yValues[0]=0;
00175                         yValues[1]=25;
00176                         yValues[2]=100;
00177                         yValues[3]=25;
00178                         yValues[4]=0;
00179                         
00180                         pGraphicalFunction * tf = plotter ->getFunctionForVectors( xValues, 5, yValues, 5 ); 
00181                 printf("EED %p HistogramWidget::drawTransferenceFunction %p\n", this , tf);             
00182                         // Including and drawing the created function in the plotter
00183                         if (tf)
00184                         {
00185                                 tf->setType(1);
00186                                 //is the actual Function
00187                                 tf->setActual(true);
00188                                 //show points
00189                                 tf->SetShowPoints(true);
00190                                 idTransferenceFunction=plotter->addFunction( tf );
00191                                 if(type==1)
00192                                         plotter->addFunctionToMove(tf);
00193                                 wxPen mypen(*wxBLACK,0.5, wxSOLID  );
00194                                 mypen.SetWidth(2);
00195                                 tf->SetPen( mypen );
00196                         }
00197         }

Here is the call graph for this function:

Here is the caller graph for this function:

void HistogramWidget::OnSize ( wxSizeEvent &  WXUNUSED(event)  ) 

Definition at line 202 of file HistogramWidget.cxx.

References pPlotter::getFunction(), idTransferenceFunction, plotter, pGraphicalFunction::setScales(), and pGraphicalFunction::setScreens().

00203         {
00204                 int scrX,scrY;
00205                 GetClientSize(&scrX,&scrY);
00206                 plotter->SetSize(scrX,scrY);
00207                 pGraphicalFunction* actual=plotter->getFunction(idTransferenceFunction);
00208                 if(actual!=NULL){
00209                         actual->setScreens(scrX,scrY);
00210                         actual->setScales();
00211                 }
00212                 
00213         }

Here is the call graph for this function:

int HistogramWidget::getSizeTransferenceFunction (  ) 

Definition at line 217 of file HistogramWidget.cxx.

References pPlotter::getFunction(), pGraphicalFunction::getSizePoints(), idTransferenceFunction, and plotter.

Referenced by HistogramDialog::getSizeTransferenceFunction(), and HistogramDialog::OnSaveData().

00218         {
00219                 pGraphicalFunction* tf=plotter->getFunction(idTransferenceFunction);
00220                 return tf->getSizePoints();
00221 
00222         }

Here is the call graph for this function:

Here is the caller graph for this function:

int HistogramWidget::getSizeBarColor (  ) 

Definition at line 248 of file HistogramWidget.cxx.

References pPlotter::getColorPointsSize(), and plotter.

Referenced by HistogramDialog::getSizeBarColor(), and HistogramDialog::OnSaveData().

00249         {
00250                 return  plotter->getColorPointsSize();
00251         }

Here is the call graph for this function:

Here is the caller graph for this function:

void HistogramWidget::getTransferenceFunctionPoint ( int  index,
int &  x,
int &  y 
)

Definition at line 226 of file HistogramWidget.cxx.

References pPlotter::getFunction(), pGraphicalFunction::GetPointAt(), pFunctionPoint::getRealX(), pFunctionPoint::getRealY(), idTransferenceFunction, and plotter.

Referenced by HistogramDialog::getTransferenceFunctionPoint(), and HistogramDialog::OnSaveData().

00227         {
00228                 pGraphicalFunction* tf=plotter->getFunction(idTransferenceFunction);
00229                 if(tf)
00230                 {
00231                         wxNode* pnode=tf->GetPointAt(index);
00232                         pFunctionPoint* point=(pFunctionPoint*)pnode->GetData();
00233                         x=point->getRealX();
00234                         y=point->getRealY();
00235                 }
00236         }

Here is the call graph for this function:

Here is the caller graph for this function:

void HistogramWidget::getDataBarColorPoint ( int  index,
int &  x,
int &  red,
int &  green,
int &  blue 
)

Definition at line 255 of file HistogramWidget.cxx.

References pPlotter::getBarColorDataAt(), and plotter.

Referenced by HistogramDialog::getDataBarColorPoint(), and HistogramDialog::OnSaveData().

00256         {
00257                 double tmp=x;
00258                 plotter->getBarColorDataAt(index,tmp,red,green,blue);
00259                 x=(int)tmp;
00260         }

Here is the call graph for this function:

Here is the caller graph for this function:

int HistogramWidget::getHistogramPoint ( int  gValue  ) 

Definition at line 241 of file HistogramWidget.cxx.

References pHistogram::getHistogramPoint(), and histogram.

Referenced by HistogramDialog::getHistogramPoint().

00242         {
00243                 return histogram->getHistogramPoint(gValue);
00244         }

Here is the call graph for this function:

Here is the caller graph for this function:

float HistogramWidget::getMaxShowedPorcentage (  ) 

Definition at line 264 of file HistogramWidget.cxx.

References pPlotter::getFunction(), pPlotter::getMaxShowedPorcentage(), pGraphicalFunction::getMaxX(), pGraphicalFunction::getMinX(), idHistogram, min, and plotter.

Referenced by HistogramDialog::getMaxShowedPorcentage().

00265         {
00266                 float  porcentageMaxX=plotter->getMaxShowedPorcentage();
00267                 pGraphicalFunction* histogramFunction=plotter->getFunction(idHistogram);
00268                 int min=histogramFunction->getMinX();
00269                 float x=porcentageMaxX*(histogramFunction->getMaxX()-min);
00270                 return min+ x;
00271         }

Here is the call graph for this function:

Here is the caller graph for this function:

float HistogramWidget::getMinShowedPorcentage (  ) 

Definition at line 275 of file HistogramWidget.cxx.

References pPlotter::getFunction(), pGraphicalFunction::getMaxX(), pPlotter::getMinShowedPorcentage(), pGraphicalFunction::getMinX(), idHistogram, min, and plotter.

Referenced by HistogramDialog::getMinShowedPorcentage().

00276         {
00277                 float  porcentageMinX=plotter->getMinShowedPorcentage();
00278                 pGraphicalFunction* histogramFunction=plotter->getFunction(idHistogram);
00279                 int min=histogramFunction->getMinX();
00280                 float x=porcentageMinX*(histogramFunction->getMaxX()-min);
00281                 return min+ x;
00282         }

Here is the call graph for this function:

Here is the caller graph for this function:

float HistogramWidget::getActualShowedPorcentage (  ) 

Definition at line 286 of file HistogramWidget.cxx.

References pPlotter::getFunction(), pGraphicalFunction::getMaxX(), pPlotter::getMinShowedPorcentage(), pGraphicalFunction::getMinX(), idHistogram, min, and plotter.

Referenced by HistogramDialog::getActualShowedPorcentage().

00287         {
00288                 float  porcentageActualX=plotter->getMinShowedPorcentage();
00289                 pGraphicalFunction* histogramFunction=plotter->getFunction(idHistogram);
00290                 int min=histogramFunction->getMinX();
00291                 float x=porcentageActualX*(histogramFunction->getMaxX()-min);
00292                 return min+ x;
00293         }

Here is the call graph for this function:

Here is the caller graph for this function:

bool HistogramWidget::addPointToTransferenceFunction ( double  x,
double  y 
)

Definition at line 301 of file HistogramWidget.cxx.

References pGraphicalFunction::AddPoint(), pPlotter::getFunction(), idTransferenceFunction, and plotter.

Referenced by HistogramDialog::addPointToTransferenceFunction(), and HistogramDialog::OnLoadData().

00302         {
00303                 bool result=false;
00304                 pGraphicalFunction* tf=plotter->getFunction(idTransferenceFunction);
00305 printf("EED %p HistogramWidget::addPointToTransferenceFunction tp%p x%f y%f %d\n",this, tf, x ,y, idTransferenceFunction);
00306                 if (tf!=NULL) { result=tf->AddPoint(x,y); }
00307                 
00308                 return result;
00309         }

Here is the call graph for this function:

Here is the caller graph for this function:

bool HistogramWidget::addColorPoint ( double  x,
int  red,
int  green,
int  blue 
)

Definition at line 317 of file HistogramWidget.cxx.

References pPlotter::addColorPoint(), and plotter.

Referenced by HistogramDialog::addColorPoint(), and HistogramDialog::OnLoadData().

00318         {
00319                 return plotter->addColorPoint(x,red,green,blue);
00320         }

Here is the call graph for this function:

Here is the caller graph for this function:

void HistogramWidget::updatePlotter (  ) 

Definition at line 359 of file HistogramWidget.cxx.

References plotter, and pPlotter::update().

Referenced by HistogramDialog::OnLoadData(), and HistogramDialog::updatePlotter().

00360         {
00361                 plotter->update();
00362         }

Here is the call graph for this function:

Here is the caller graph for this function:

void HistogramWidget::erasePointsTransferenceFunction (  ) 

Definition at line 329 of file HistogramWidget.cxx.

References pGraphicalFunction::deletePointAt(), pPlotter::getFunction(), pGraphicalFunction::getSizePoints(), idTransferenceFunction, plotter, and transferenceFunctionHasPoints.

Referenced by HistogramDialog::erasePointsTransferenceFunction().

00330         {
00331                 if(transferenceFunctionHasPoints)
00332                 {
00333                         // we have to erase the points
00334                         pGraphicalFunction* tf=plotter->getFunction(idTransferenceFunction);
00335                         if (tf!=NULL){
00336                                 int numOfPoints=tf->getSizePoints();
00337                                 int i=numOfPoints-1;//-2;
00338                                 while(i>=0)
00339                                 {
00340                                         tf->deletePointAt(i);
00341                                         i--;
00342                                 } // while
00343                         } // if tf
00344                 } // if transferenceFunctionHasPoints
00345                 
00346         //we set for actual the histogram
00347                 //plotter->setActual()
00348         }

Here is the call graph for this function:

Here is the caller graph for this function:

void HistogramWidget::eraseColorPoints (  ) 

Definition at line 352 of file HistogramWidget.cxx.

References pPlotter::eraseColorPoints(), and plotter.

Referenced by HistogramDialog::eraseColorPoints().

00353         {
00354                 plotter->eraseColorPoints();
00355         }

Here is the call graph for this function:

Here is the caller graph for this function:

void HistogramWidget::setTransferenceFunctionHasPoints ( bool  hasPoints  ) 

Definition at line 368 of file HistogramWidget.cxx.

References transferenceFunctionHasPoints.

Referenced by HistogramDialog::setTransferenceFunctionHasPoints().

00369         {
00370                 transferenceFunctionHasPoints=hasPoints;
00371         }

Here is the caller graph for this function:

void HistogramWidget::setTransferenceFunctionHasColor ( bool  hasColorPoints  ) 

Definition at line 373 of file HistogramWidget.cxx.

References transferenceFunctionHasPoints.

Referenced by HistogramDialog::setTransferenceFunctionHasColor().

00374         {
00375                 transferenceFunctionHasPoints=hasColorPoints;
00376         }

Here is the caller graph for this function:

int HistogramWidget::getHistogramSize (  ) 

Definition at line 377 of file HistogramWidget.cxx.

References histogramSize.

00378         {
00379                 return histogramSize;
00380         }

void HistogramWidget::setType ( int  type  ) 

Definition at line 381 of file HistogramWidget.cxx.

00382         {
00383                 this->type=type;
00384         }

void HistogramWidget::initializeHistogram ( vtkImageData *  img  ) 

Initialize the histogram

Definition at line 94 of file HistogramWidget.cxx.

References drawHistogram(), drawTransferenceFunction(), and histogram.

Referenced by HistogramDialog::initializeHistogram().

00094                                                                   {
00095                 if(histogram ==NULL){
00096                         histogram= new pHistogram(img);
00097                 }               
00098                 //draw
00099                 drawHistogram();
00100                 drawTransferenceFunction();
00101         }

Here is the call graph for this function:

Here is the caller graph for this function:

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 389 of file HistogramWidget.cxx.

References pPlotter::GetValuesPointsFunction(), histogramSize, and plotter.

Referenced by HistogramDialog::GetValuesPointsFunction().

00389                                                                                                           {
00390                 plotter->GetValuesPointsFunction(greylevel,value,histogramSize);
00391         }

Here is the call graph for this function:

Here is the caller graph for this function:

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 397 of file HistogramWidget.cxx.

References pPlotter::GetValuesColorPointsFunction(), and plotter.

Referenced by HistogramDialog::GetValuesColorPointsFunction().

00401         {
00402                 plotter->GetValuesColorPointsFunction(greylevel,red,green,blue);
00403         }

Here is the call graph for this function:

Here is the caller graph for this function:

HistogramWidget::DECLARE_CLASS ( HistogramWidget   )  [private]


Member Data Documentation

pHistogram* HistogramWidget::histogram [private]

Definition at line 160 of file HistogramWidget.h.

Referenced by drawHistogram(), drawTransferenceFunction(), getHistogramPoint(), HistogramWidget(), initializeHistogram(), and ~HistogramWidget().

pPlotter* HistogramWidget::plotter [private]

Definition at line 161 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().

int HistogramWidget::idTransferenceFunction [private]

Definition at line 162 of file HistogramWidget.h.

Referenced by addPointToTransferenceFunction(), drawTransferenceFunction(), erasePointsTransferenceFunction(), getSizeTransferenceFunction(), getTransferenceFunctionPoint(), HistogramWidget(), and OnSize().

int HistogramWidget::histogramSize [private]

Definition at line 163 of file HistogramWidget.h.

Referenced by drawHistogram(), getHistogramSize(), GetValuesPointsFunction(), and HistogramWidget().

int HistogramWidget::idHistogram [private]

Definition at line 164 of file HistogramWidget.h.

Referenced by drawHistogram(), getActualShowedPorcentage(), getMaxShowedPorcentage(), getMinShowedPorcentage(), and HistogramWidget().

bool HistogramWidget::transferenceFunctionHasPoints [private]

Definition at line 170 of file HistogramWidget.h.

Referenced by erasePointsTransferenceFunction(), HistogramWidget(), setTransferenceFunctionHasColor(), and setTransferenceFunctionHasPoints().

bool HistogramWidget::transferenceFunctionHasColor [private]

Definition at line 171 of file HistogramWidget.h.

Referenced by HistogramWidget().

int HistogramWidget::type [private]

Definition at line 176 of file HistogramWidget.h.

Referenced by drawTransferenceFunction(), and HistogramWidget().


The documentation for this class was generated from the following files:
Generated on Wed Jul 29 16:35:43 2009 for creaMaracasVisu_lib by  doxygen 1.5.3