From da163855471fe218bef04ee518b126fc066d24aa Mon Sep 17 00:00:00 2001 From: davila Date: Thu, 18 Dec 2014 15:50:59 +0100 Subject: [PATCH] #2490 creaMaracasVisu Feature New High - Histogram Interaction --- bbtk/src/bbmaracasvisuHistogramView.cxx | 16 ++++++---- bbtk/src/bbmaracasvisuHistogramView.h | 15 +++++----- .../wxWindows/widgets/pPlotter/mBarRange2.h | 6 ++-- .../wxWindows/widgets/pPlotter/pFigure.cxx | 6 ++-- .../wxWindows/widgets/pPlotter/pHistogram.cxx | 29 +++++++++---------- 5 files changed, 38 insertions(+), 34 deletions(-) diff --git a/bbtk/src/bbmaracasvisuHistogramView.cxx b/bbtk/src/bbmaracasvisuHistogramView.cxx index c510b41..a310168 100644 --- a/bbtk/src/bbmaracasvisuHistogramView.cxx +++ b/bbtk/src/bbmaracasvisuHistogramView.cxx @@ -37,10 +37,11 @@ BBTK_BLACK_BOX_IMPLEMENTATION(HistogramView,bbtk::WxBlackBox); void HistogramView::Process() { printf("EED HistogramView::Process Start \n"); - if (firsttime==true){ + if (firsttime==true) + { firsttime=false; // histogram_wxwidget = new Histogram( wxpanel , -1, wxPoint(0,0), wxSize(400,400),wxNO_BORDER ); - histogram_wxwidget->Configure( bbGetInputIn() ); + _histogramMinMaxLevel->Configure( bbGetInputIn() ); } printf("EED HistogramView::Process End \n"); } @@ -55,10 +56,15 @@ void HistogramView::CreateWidget(wxWindow* parent) // histogram_wxwidget = new Histogram( parent , -1, wxPoint(0,0), wxSize(400,400),wxNO_BORDER ,bbGetInputIn()); wxPanel *wxpanel =new wxPanel(parent); wxpanel->SetSize(400,400); - histogram_wxwidget = new Histogram( parent , -1, wxPoint(0,0), wxSize(400,400),wxNO_BORDER ); + +//Borrame +// histogram_wxwidget = new Histogram( parent , -1, wxPoint(0,0), wxSize(400,400),wxNO_BORDER ); - bbtkDebugDecTab("Core",9); - bbSetOutputWidget( histogram_wxwidget ); + Histogram* histogram = new Histogram( parent , -1, wxPoint(0,0), wxSize(400,400), /*wxNO_BORDER*/ wxBORDER_DEFAULT ); + _histogramMinMaxLevel = new HistogramMinMaxLevel( (HistogramBase*)histogram ); + + bbtkDebugDecTab("Core",9); + bbSetOutputWidget( _histogramMinMaxLevel->GetWindow() ); // bbSetOutputWidget( wxpanel ); } diff --git a/bbtk/src/bbmaracasvisuHistogramView.h b/bbtk/src/bbmaracasvisuHistogramView.h index 5cec903..bb69be2 100644 --- a/bbtk/src/bbmaracasvisuHistogramView.h +++ b/bbtk/src/bbmaracasvisuHistogramView.h @@ -30,6 +30,7 @@ #include "vtkImageData.h" #include "Histogram.h" +#include "HistogramBase.h" namespace bbcreaMaracasVisu @@ -47,16 +48,16 @@ class /*BBTK_EXPORT*/ HistogramView void CreateWidget(wxWindow*); private: - bool firsttime; - Histogram *histogram_wxwidget; - wxPanel *wxpanel; + bool firsttime; + HistogramMinMaxLevel* _histogramMinMaxLevel; + wxPanel* wxpanel; }; BBTK_BEGIN_DESCRIBE_BLACK_BOX(HistogramView,bbtk::WxBlackBox); -BBTK_NAME("HistogramView"); -BBTK_AUTHOR("eduardo.davila [at] creatis.insa-lyon.fr"); -BBTK_DESCRIPTION("Histogram window"); -BBTK_CATEGORY("viewer"); + BBTK_NAME("HistogramView"); + BBTK_AUTHOR("eduardo.davila [at] creatis.insa-lyon.fr"); + BBTK_DESCRIPTION("Histogram window"); + BBTK_CATEGORY("viewer"); BBTK_INPUT(HistogramView,In,"Input image",vtkImageData*,""); BBTK_END_DESCRIBE_BLACK_BOX(HistogramView); } diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/mBarRange2.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/mBarRange2.h index e883c98..cf3441d 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/mBarRange2.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/mBarRange2.h @@ -35,8 +35,8 @@ * \brief */ -#ifndef __ThresholdImageViewPanel_h__ -#define __ThresholdImageViewPanel_h__ +#ifndef __mBarRange2_h__ +#define __mBarRange2_h__ #include @@ -78,5 +78,5 @@ END_DECLARE_EVENT_TYPES() }; -#endif +#endif //__mBarRange2_h__ diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pFigure.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pFigure.cxx index f2bbf1f..a1aef5e 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pFigure.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pFigure.cxx @@ -56,10 +56,10 @@ IMPLEMENT_CLASS(pFigure, wxObject) */ pFigure :: pFigure(int edges_n, int _w, int _h, int _orientation, bool bar_orientation) { - edges = edges_n; + edges = edges_n; orientation = _orientation; - width = _w; - heigth = _h; + width = _w; + heigth = _h; setBarOrientation( bar_orientation ); } diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pHistogram.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pHistogram.cxx index cbfee52..c14e951 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pHistogram.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pHistogram.cxx @@ -74,14 +74,6 @@ pHistogram::pHistogram(vtkImageData* imageData) points = vtkImageData::New(); size = 100; sizeImage = 0; - //cast - /* - vtkImageCast* cast= vtkImageCast::New(); - cast->SetInput(imageData); - cast->SetOutputScalarTypeToInt(); - cast->Update(); - */ - //build the histogram buildHistogram(imageData); } @@ -176,8 +168,7 @@ printf("EED pHistogram::setPoints colums:%d\n", (int)(resulttable->GetNumberOfCo unsigned short* dataImagePointerUS = (unsigned short*)imageData->GetScalarPointer(0,0,0); float* dataImagePointerF = (float*)imageData->GetScalarPointer(0,0,0); double* dataImagePointerD = (double*)imageData->GetScalarPointer(0,0,0); - - double* dataHistogramPointer = (double*)points->GetScalarPointer(0,0,0); + double* dataHistogramPointer = (double*)points->GetScalarPointer(0,0,0); /* Range of greys @@ -202,9 +193,9 @@ printf("EED pHistogram::setPoints colums:%d\n", (int)(resulttable->GetNumberOfCo int ext[6]; imageData->GetExtent(ext); int sx,sy,sz; - sx=ext[1]-ext[0]+1; - sy=ext[3]-ext[2]+1; - sz=ext[5]-ext[4]+1; + sx = ext[1]-ext[0]+1; + sy = ext[3]-ext[2]+1; + sz = ext[5]-ext[4]+1; sizeImage=sx*sy*sz; @@ -217,7 +208,7 @@ printf("EED pHistogram::setPoints colums:%d\n", (int)(resulttable->GetNumberOfCo dataHistogramPointer[i]=0; } - int j=0; + long int j=0; if (imageData->GetScalarType()==VTK_CHAR) @@ -301,8 +292,14 @@ image */ int pHistogram::getIndex(double gValue) { - - double p=((double)gValue-minLevelOfGrey)/(maxLevelOfGrey-minLevelOfGrey); + double p; + double diff=maxLevelOfGrey-minLevelOfGrey; + if (diff!=0) + { + p=((double)gValue-minLevelOfGrey)/(maxLevelOfGrey-minLevelOfGrey); + } else { + p=0; + } double k=p*(size-1); //std::cout<<"gValue "<