From 096822cf3513065cfa25e378679339a5ae4684cf Mon Sep 17 00:00:00 2001 From: Eduardo Davila Date: Mon, 29 Jun 2009 11:02:02 +0000 Subject: [PATCH] no message --- .../bouml/wxVtkViewer/wxVtkViewer/2.session | 8 +- lib/maracasVisuLib/CMakeLists.txt | 144 +--------- .../wxWindows/Contour/ContourExtractData.cxx | 85 ++++-- .../wxWindows/Contour/ContourExtractData.h | 19 ++ .../ThresholdImageView/ThresholdImageView.cxx | 246 ++++++++++++++++++ .../ThresholdImageView/ThresholdImageView.h | 58 +++++ .../ThresholdImageViewPanel.cxx | 145 +++++++++++ .../ThresholdImageViewPanel.h | 52 ++++ 8 files changed, 605 insertions(+), 152 deletions(-) create mode 100644 lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ThresholdImageView.cxx create mode 100644 lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ThresholdImageView.h create mode 100644 lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ThresholdImageViewPanel.cxx create mode 100644 lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ThresholdImageViewPanel.h diff --git a/lib/doxygen/bouml/wxVtkViewer/wxVtkViewer/2.session b/lib/doxygen/bouml/wxVtkViewer/wxVtkViewer/2.session index f43b2b4..4de21ad 100644 --- a/lib/doxygen/bouml/wxVtkViewer/wxVtkViewer/2.session +++ b/lib/doxygen/bouml/wxVtkViewer/wxVtkViewer/2.session @@ -1,12 +1,12 @@ -window_sizes 1396 856 329 1061 729 70 +window_sizes 1075 856 201 868 729 70 diagrams active classdiagram_ref 128002 // wxVtkViewer class Diagram 1 - 1058 709 100 4 98 0 + 864 709 100 4 150 0 classdiagram_ref 128130 // wxVtkViewer class Diagram 2 - 870 691 100 4 9 0 + 870 691 100 4 255 0 end show_stereotypes -selected classdiagram_ref 128130 // wxVtkViewer class Diagram 2 +selected classdiagram_ref 128002 // wxVtkViewer class Diagram 1 open classview_ref 128002 // wxVtkViewer end diff --git a/lib/maracasVisuLib/CMakeLists.txt b/lib/maracasVisuLib/CMakeLists.txt index 9b12f8f..92ea29a 100644 --- a/lib/maracasVisuLib/CMakeLists.txt +++ b/lib/maracasVisuLib/CMakeLists.txt @@ -53,6 +53,9 @@ IF ( BUILD_${LIBRARY_NAME} ) FILE(GLOB ${LIBRARY_NAME}_HEADERS_CONTOUR "src/interface/wxWindows/Contour/*.h") FILE(GLOB ${LIBRARY_NAME}_SOURCES_CONTOUR src/interface/wxWindows/Contour/*.cxx src/interface/wxWindows/Contour/*.cpp src/interface/wxWindows/Contour/*.cc) + + FILE(GLOB ${LIBRARY_NAME}_HEADERS_ThresholdImageView "src/interface/wxWindows/widgets/ThresholdImageView/*.h") + FILE(GLOB ${LIBRARY_NAME}_SOURCES_ThresholdImageView src/interface/wxWindows/widgets/ThresholdImageView/*.cxx src/interface/wxWindows/widgets/ThresholdImageView/*.cpp src/interface/wxWindows/widgets/ThresholdImageView/*.cc) FILE(GLOB ${LIBRARY_NAME}_HEADERS_WIDGETS "src/interface/wxWindows/widgets/*.h") FILE(GLOB ${LIBRARY_NAME}_SOURCES_WIDGETS src/interface/wxWindows/widgets/*.cxx src/interface/wxWindows/widgets/*.cpp src/interface/wxWindows/widgets/*.cc) @@ -68,73 +71,13 @@ IF ( BUILD_${LIBRARY_NAME} ) SET ( ${LIBRARY_NAME}_HEADERS - #src/interface/wxWindows/manualContour.h - #src/interface/wxWindows/wxMaracasMPR.h - #src/interface/wxWindows/wxMaracas_ManualTree_MPR.h ${${LIBRARY_NAME}_HEADERS_WXWIN} - #src/interface/wxWindows/Contour/AutoControlPoints.h - #src/interface/wxWindows/Contour/ContourCrownWidget.h - #src/interface/wxWindows/Contour/ContourExtractData.h - #src/interface/wxWindows/Contour/ContourPropagation.h - #src/interface/wxWindows/Contour/contoursIntersection.h - #src/interface/wxWindows/Contour/ContourVOIWidget.h - #src/interface/wxWindows/Contour/ExtractControlPoints2D.h - #src/interface/wxWindows/Contour/Propagation.h - #src/interface/wxWindows/Contour/vectorFunctions.h - ${${LIBRARY_NAME}_HEADERS_CONTOUR} -## src/interface/wxWindows/wxMaracasImageBrowser02.h -## src/interface/wxWindows/widgets/wxReadingPriorityPanel.h - #src/interface/wxWindows/widgets/ContourView.h - #src/interface/wxWindows/widgets/InterfaceVtkPanelWidgets.h - #src/interface/wxWindows/widgets/LineView.h - #src/interface/wxWindows/widgets/PointView.h - #src/interface/wxWindows/widgets/UtilVtk3DGeometriSelection.h - #src/interface/wxWindows/widgets/vtkClosePolyData.h - #src/interface/wxWindows/widgets/wxMaracasIRMView.h - #src/interface/wxWindows/widgets/wxMaracasIRMViewManager.h - #src/interface/wxWindows/widgets/wxMaracas_ViewerWidget.h - #src/interface/wxWindows/widgets/wxMaracas_N_ViewersWidget.h - #src/interface/wxWindows/widgets/wxManualTree_MPRWidget.h - #src/interface/wxWindows/widgets/wxMPRBaseData.h - #src/interface/wxWindows/widgets/wxMPRWidget.h - #src/interface/wxWindows/widgets/wxSTLWidget_03.h - #src/interface/wxWindows/widgets/wxVTKRenderWindowInteractor.h - #src/interface/wxWindows/widgets/wxVTKRenderWindowInteractorEditContour.h - #src/interface/wxWindows/widgets/wxVtkBaseView.h - ${${LIBRARY_NAME}_HEADERS_WIDGETS} - #src/interface/wxWindows/widgets/pPlotter/Histogram.h - #src/interface/wxWindows/widgets/pPlotter/HistogramDialog.h - #src/interface/wxWindows/widgets/pPlotter/HistogramWidget.h - #src/interface/wxWindows/widgets/pPlotter/LogicalColorBar.h - #src/interface/wxWindows/widgets/pPlotter/mBarRange.h - #src/interface/wxWindows/widgets/pPlotter/mathplot.h - #src/interface/wxWindows/widgets/pPlotter/MaximumsDialog.h - #src/interface/wxWindows/widgets/pPlotter/pColorBar.h - #src/interface/wxWindows/widgets/pPlotter/pColorPoint.h - #src/interface/wxWindows/widgets/pPlotter/pFigure.h - #src/interface/wxWindows/widgets/pPlotter/pFunctionPoint.h - #src/interface/wxWindows/widgets/pPlotter/pGraphicalFunction.h - #src/interface/wxWindows/widgets/pPlotter/pHistogram.h - #src/interface/wxWindows/widgets/pPlotter/pLogicalFunction.h - #src/interface/wxWindows/widgets/pPlotter/pPlotter.h - #src/interface/wxWindows/widgets/pPlotter/pPlotterLayer.h - #src/interface/wxWindows/widgets/pPlotter/pPlotterScaleX.h - #src/interface/wxWindows/widgets/pPlotter/pPlotterScaleY.h - #src/interface/wxWindows/widgets/pPlotter/pPlotterWindow.h - ${${LIBRARY_NAME}_HEADERS_PPLOTTER} - ${${LIBRARY_NAME}_HEADERS_MANUAL_CONTOUR} - - include/matrix.h - - #src/kernel/marImageData.h - #src/kernel/marDicomBase.h - #src/kernel/marObject.h - #src/kernel/volume.hxx - #src/kernel/marTypes.h - #src/kernel/marParameters.h - #src/kernel/marDynData.h - #src/kernel/creaMaracasVisu_EXPORT.h - #src/kernel/vtkSTLExtractor.h + ${${LIBRARY_NAME}_HEADERS_CONTOUR} + ${${LIBRARY_NAME}_HEADERS_ThresholdImageView} + ${${LIBRARY_NAME}_HEADERS_WIDGETS} + ${${LIBRARY_NAME}_HEADERS_PPLOTTER} + ${${LIBRARY_NAME}_HEADERS_MANUAL_CONTOUR} + include/matrix.h ${${LIBRARY_NAME}_HEADERS_KERNEL} ) #---------------------------------------------------------------------------- @@ -146,71 +89,12 @@ IF ( BUILD_${LIBRARY_NAME} ) # OR MANUALLY LIST YOUR FILES WITH NEXT COMMAND (WITHOUT EXTENSION) SET ( ${LIBRARY_NAME}_SOURCES - #src/interface/wxWindows/manualContour.cpp - #src/interface/wxWindows/wxMaracasMPR.cxx - #src/interface/wxWindows/wxMaracas_ManualTree_MPR.cxx ${${LIBRARY_NAME}_SOURCES_WXWIN} - #src/interface/wxWindows/Contour/AutoControlPoints.cxx - #src/interface/wxWindows/Contour/ContourCrownWidget.cxx - #src/interface/wxWindows/Contour/ContourExtractData.cxx - #src/interface/wxWindows/Contour/ContourPropagation.cxx - #src/interface/wxWindows/Contour/contoursIntersection.cxx - #src/interface/wxWindows/Contour/ContourVOIWidget.cxx - #src/interface/wxWindows/Contour/ExtractControlPoints2D.cxx - #src/interface/wxWindows/Contour/Propagation.cxx - #src/interface/wxWindows/Contour/vectorFunctions.cxx - ${${LIBRARY_NAME}_SOURCES_CONTOUR} -# src/interface/wxWindows/wxMaracasImageBrowser02.cxx -# src/interface/wxWindows/widgets/wxReadingPriorityPanel.cpp - #src/interface/wxWindows/widgets/ContourView.cxx - #src/interface/wxWindows/widgets/InterfaceVtkPanelWidgets.cxx - #src/interface/wxWindows/widgets/LineView.cxx - #src/interface/wxWindows/widgets/PointView.cxx - #src/interface/wxWindows/widgets/UtilVtk3DGeometriSelection.cxx - #src/interface/wxWindows/widgets/vtkClosePolyData.cxx - #src/interface/wxWindows/widgets/wxManualTree_MPRWidget.cxx - #src/interface/wxWindows/widgets/wxMaracas_ViewerWidget.cxx - #src/interface/wxWindows/widgets/wxMaracas_N_ViewersWidget.cxx - #src/interface/wxWindows/widgets/wxMaracasIRMView.cxx - #src/interface/wxWindows/widgets/wxMaracasIRMViewManager.cxx - #src/interface/wxWindows/widgets/wxMPRWidget.cxx - #src/interface/wxWindows/widgets/wxMPRBaseData.cxx - #src/interface/wxWindows/widgets/wxSTLWidget_03.cxx - #src/interface/wxWindows/widgets/wxVTKRenderWindowInteractor.cxx - #src/interface/wxWindows/widgets/wxVTKRenderWindowInteractorEditContour.cxx - #src/interface/wxWindows/widgets/wxVtkBaseView.cxx - ${${LIBRARY_NAME}_SOURCES_WIDGETS} - #src/interface/wxWindows/widgets/pPlotter/Histogram.cxx - #src/interface/wxWindows/widgets/pPlotter/HistogramDialog.cxx - #src/interface/wxWindows/widgets/pPlotter/HistogramWidget.cxx - #src/interface/wxWindows/widgets/pPlotter/LogicalColorBar.cxx - #src/interface/wxWindows/widgets/pPlotter/mBarRange.cxx - #src/interface/wxWindows/widgets/pPlotter/mathplot.cxx - #src/interface/wxWindows/widgets/pPlotter/MaximumsDialog.cxx - #src/interface/wxWindows/widgets/pPlotter/pColorBar.cxx - #src/interface/wxWindows/widgets/pPlotter/pColorPoint.cxx - #src/interface/wxWindows/widgets/pPlotter/pFigure.cxx - #src/interface/wxWindows/widgets/pPlotter/pFunctionPoint.cxx - #src/interface/wxWindows/widgets/pPlotter/pGraphicalFunction.cxx - #src/interface/wxWindows/widgets/pPlotter/pHistogram.cxx - #src/interface/wxWindows/widgets/pPlotter/pLogicalFunction.cxx - #src/interface/wxWindows/widgets/pPlotter/pPlotter.cxx - #src/interface/wxWindows/widgets/pPlotter/pPlotterLayer.cxx - #src/interface/wxWindows/widgets/pPlotter/pPlotterScaleX.cxx - #src/interface/wxWindows/widgets/pPlotter/pPlotterScaleY.cxx - #src/interface/wxWindows/widgets/pPlotter/pPlotterWindow.cxx - ${${LIBRARY_NAME}_SOURCES_PPLOTTER} - ${${LIBRARY_NAME}_SOURCES_MANUAL_CONTOUR} - -### - #src/kernel/marImageData.cpp - #src/kernel/marDicomBase.cpp -# src/kernel/marGdcmDicom.cpp - #src/kernel/marObject.cpp - #src/kernel/volume.cxx - #src/kernel/marParameters.cpp - #src/kernel/marDynData.cpp - #src/kernel/vtkSTLExtractor.cpp + ${${LIBRARY_NAME}_SOURCES_CONTOUR} + ${${LIBRARY_NAME}_SOURCES_ThresholdImageView} + ${${LIBRARY_NAME}_SOURCES_WIDGETS} + ${${LIBRARY_NAME}_SOURCES_PPLOTTER} + ${${LIBRARY_NAME}_SOURCES_MANUAL_CONTOUR} ${${LIBRARY_NAME}_SOURCES_KERNEL} ) #---------------------------------------------------------------------------- diff --git a/lib/maracasVisuLib/src/interface/wxWindows/Contour/ContourExtractData.cxx b/lib/maracasVisuLib/src/interface/wxWindows/Contour/ContourExtractData.cxx index 4d7c69a..7989c0d 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/Contour/ContourExtractData.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/Contour/ContourExtractData.cxx @@ -475,6 +475,51 @@ void ContourExtractData::InitVtkImagesResult() } +//------------------------------------------------------------------------ +void ContourExtractData::InitVolumeStatistics() +{ + vol_rCountRange = 0; + vol_rsize = 0; + vol_minValue = 9999999; + vol_maxValue =-9999999; + vol_acum_average = 0; + vol_acum_standardeviation = 0; +} + +//------------------------------------------------------------------------ +void ContourExtractData::SetVolumeStatistics(int rCountRange, + int rsize, + double minValue, + double maxValue, + double acum_average, + double acum_standardeviation) +{ + vol_rCountRange = vol_rCountRange + rCountRange; + vol_rsize = vol_rsize + rsize; + + if (minValuevol_maxValue){ vol_maxValue = maxValue; } + + vol_acum_average = vol_acum_average + acum_average; + vol_acum_standardeviation = vol_acum_standardeviation + acum_standardeviation; +} + +//------------------------------------------------------------------------ +void ContourExtractData::GetVolumeStatistics(int *vol_rCountRange, + int *vol_rsize, + double *vol_minValue, + double *vol_maxValue, + double *vol_average, + double *vol_standardeviation) +{ + *vol_rCountRange = this->vol_rCountRange; + *vol_rsize = this->vol_rsize; + *vol_minValue = this->vol_minValue; + *vol_maxValue = this->vol_maxValue; + *vol_average = this->vol_acum_average / this->vol_rsize; + *vol_standardeviation = sqrt(this->vol_acum_standardeviation / this->vol_rsize); +} + //------------------------------------------------------------------------ void ContourExtractData::Statistics( std::vector *inputLstValue, @@ -485,15 +530,17 @@ void ContourExtractData::Statistics( std::vector *inputLstValue, double *rmin, double *rmax, double *raverage, - double *rstandardeviation) + double *rstandardeviation + ) { - double min = 0; - double max = 0; - double average = 0; - double standardeviation = 0; - double acum = 0; - int size = 0; - int countRange = 0; + double min = 0; + double max = 0; + double average = 0; + double standardeviation = 0; + double acum_average = 0; + double acum_standardeviation = 0; + int size = 0; + int countRange = 0; double ng; if (inputLstValue!=NULL) @@ -507,25 +554,27 @@ void ContourExtractData::Statistics( std::vector *inputLstValue, for ( i=0; ing) min=ng; // Min if ((ng>=grayRangeMin) && (ng<=grayRangeMax)) countRange++; // countRange - } - average = acum / size; + } // for average + average = acum_average / size; // Standar Deviation - acum=0; + acum_standardeviation=0; double tmp; for ( i=0; i lstManConMod; @@ -64,6 +72,17 @@ void InitVtkImagesResult(); + //--Volume Statistics-- + int vol_rCountRange; + int vol_rsize; + double vol_minValue; + double vol_maxValue; + double vol_acum_average; + double vol_acum_standardeviation; + void SetVolumeStatistics(int rCountRange, int rsize, + double minValue,double maxValue, + double acum_average, double acum_standardeviation); + }; diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ThresholdImageView.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ThresholdImageView.cxx new file mode 100644 index 0000000..426bf80 --- /dev/null +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ThresholdImageView.cxx @@ -0,0 +1,246 @@ + +/** + * \file + * \brief Class bbtk::ThresholdImageView . + */ + + +#include "ThresholdImageView.h" + + + + //========================================================================= + ThresholdImageView::ThresholdImageView( ) + { + _actorPresent = false; + } + + //========================================================================= + ThresholdImageView::~ThresholdImageView() + { + } + //========================================================================= + + +//---------------------------------------------------------------------------- +void ThresholdImageView::SetImage(vtkImageData* image) +{ + _image = image; +} + +//---------------------------------------------------------------------------- +void ThresholdImageView::SetwxVtkBaseView(wxVtkBaseView *baseview) +{ + _baseView = baseview; +} + +//---------------------------------------------------------------------------- +void ThresholdImageView::SetZ(int z) +{ + _Z = z; +} + +//---------------------------------------------------------------------------- +void ThresholdImageView::SetminMax(int min, int max) +{ + _min = min; + _max = max; +} + +//---------------------------------------------------------------------------- +void ThresholdImageView::onThreshold() +{ + int z = _Z; + double range[2]; + + vtkImageData *img = _image; + img->GetScalarRange(range); + + int minTot = floor (range[0]); + int maxTot = ceil (range[1]); + +//EED _pannew->onThresholdInstantChange(minMax); + + int minVal = floor (_min); + int maxVal = floor (_max); + + if (!_actorPresent) + { + if (_imageReslicer==NULL) + { + _imageReslicer = vtkImageReslice::New(); + _imageReslicer->SetInput( img ); + _imageReslicer->SetInformationInput(img); + _imageReslicer->SetResliceAxesDirectionCosines(1,0,0, 0,1,0 ,0,0,1); + _imageReslicer->SetOutputDimensionality(2); + _imageReslicer->SetInterpolationModeToLinear(); + } + + _imageReslicer->SetResliceAxesOrigin(0,0,z); + + img = _imageReslicer->GetOutput(); + img->Update(); + img->UpdateInformation(); + + wxVtkBaseView *baseView = _baseView; + + if (_thresholdTable==NULL) + { + //Lookup Table + _thresholdTable = vtkLookupTable::New(); + _thresholdTable->SetNumberOfTableValues(maxTot+1); + _thresholdTable->SetTableRange(range); + _thresholdTable->SetAlphaRange(0, 1); + _thresholdTable->SetValueRange(0, 1); + _thresholdTable->SetSaturationRange(0, 0); + _thresholdTable->SetRampToLinear( ); + } + + //Assign a fake color for the upper image, and set the white as transparent + int i; + for(i = minTot; i <= maxTot; i++) + { + if( i >= minVal && i <= maxVal ) + { + _thresholdTable->SetTableValue(i, 1.0, 0.0, 0.0, 1); + } + else if( i >= minTot && i < minVal ) + { + _thresholdTable->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent + } + else if( i > maxVal && i < maxTot ) + { + _thresholdTable->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent + } + else + { + _thresholdTable->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent + } + } + _thresholdTable->Build( ); + + if (_thresholdMapper==NULL) + { + _thresholdMapper = vtkImageMapToColors::New( ); + } + + _thresholdMapper->SetLookupTable( _thresholdTable ); + _thresholdMapper->SetInput( img ); + + if (_thresholdActor==NULL) + { + _thresholdActor = vtkImageActor::New( ); + _thresholdActor->SetOpacity( 0.6 ); + _thresholdActor->InterpolateOn( ); + _thresholdActor->SetPosition( 0,0, 900-1 ); + } + + _thresholdActor->SetInput( _thresholdMapper->GetOutput() ); + + baseView->GetRenderer()->AddActor( _thresholdActor ); + _actorPresent = true; + } + + else + { + _imageReslicer->SetResliceAxesOrigin(0,0,z); + img = _imageReslicer->GetOutput(); + img->Update(); + img->UpdateInformation(); + + //Assign a fake color for the upper image, and set the white as transparent + int i; + for(i = minTot; i <= maxTot; i++) + { + if( i >= minVal && i <= maxVal ) + { + _thresholdTable->SetTableValue(i, 1.0, 0.0, 0.0, 1); + } + else if( i >= minTot && i < minVal ) + { + _thresholdTable->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent + } + else if( i > maxVal && i < maxTot ) + { + _thresholdTable->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent + } + else + { + _thresholdTable->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent + } + } + + _thresholdTable->Build( ); + _thresholdMapper->SetLookupTable( _thresholdTable ); + _thresholdMapper->SetInput( img ); + _thresholdActor->SetInput( _thresholdMapper->GetOutput() ); + } + /* + vtkImageViewer2* viewer = vtkImageViewer2::New(); + viewer->SetInput( upperImageActor->GetInput() ); + viewer->SetColorLevel((range[1]-range[0])/2); + viewer->SetColorWindow(range[1]); + viewer->GetRenderer()->AddActor( upperImageActor ); + viewer->Render(); + */ +//EED _theViewPanel->RefreshInterface(); +} + + +//---------------------------------------------------------------------------- +void ThresholdImageView::onThresholdChange() +{ + if (_actorPresent) + { + onThreshold(); + } +} + +//---------------------------------------------------------------------------- +void ThresholdImageView::onThresholdInterpolation(bool interpolate) +{ + if (_thresholdActor!=NULL) + { + if (interpolate) + { + _thresholdActor->InterpolateOn( ); + } + + else + { + _thresholdActor->InterpolateOff( ); + } + +//EED _theViewPanel->RefreshInterface(); + } +} + +//---------------------------------------------------------------------------- +void ThresholdImageView::onThresholdChangeOpacity (int opacity) +{ + if (_actorPresent) + { + _thresholdActor->SetOpacity(opacity*0.1); + } + +//EED _theViewPanel->RefreshInterface(); +} + +//---------------------------------------------------------------------------- +void ThresholdImageView::onThresholdRemove() +{ + if (_actorPresent) + { + wxVtkBaseView * baseView = _baseView; + baseView->GetRenderer()->RemoveActor( _thresholdActor ); + _actorPresent = false; + } + +//EED _theViewPanel->RefreshInterface(); +} + + + + +// EOF + diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ThresholdImageView.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ThresholdImageView.h new file mode 100644 index 0000000..56dd8a6 --- /dev/null +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ThresholdImageView.h @@ -0,0 +1,58 @@ + + + +/** + * \file + * \brief Class ThresholdImageView . + */ + +/** + * \class ThresholdImageView + * \brief + */ + +#ifndef __ThresholdImageView_h__ +#define __ThresholdImageView_h__ + +#include +#include +#include +#include +#include +#include "wxVtkBaseView.h" + + + +class ThresholdImageView + { + public: + ThresholdImageView( ); + ~ThresholdImageView(); + void onThreshold(); + void onThresholdChange(); + void onThresholdInterpolation(bool interpolate); + void onThresholdChangeOpacity (int opacity); + void onThresholdRemove(); + + void SetImage(vtkImageData* image); + void SetwxVtkBaseView(wxVtkBaseView *baseview); + + void SetZ(int z); + void SetminMax(int min, int max); + + private: + int _Z; + double _min; + double _max; + bool _actorPresent; + vtkImageData *_image; + vtkImageReslice *_imageReslicer; + vtkLookupTable *_thresholdTable; + vtkImageMapToColors *_thresholdMapper; + vtkImageActor *_thresholdActor; + wxVtkBaseView *_baseView; + protected: + }; + +#endif + diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ThresholdImageViewPanel.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ThresholdImageViewPanel.cxx new file mode 100644 index 0000000..4ad0d44 --- /dev/null +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ThresholdImageViewPanel.cxx @@ -0,0 +1,145 @@ + + +/** + * \file + * \brief ClassThresholdImageViewPanel . + */ + + +#include "ThresholdImageViewPanel.h" + + + +/** + ** Begin of the threshold panel + **/ +ThresholdImageViewPanel::ThresholdImageViewPanel(wxWindow* parent) +: wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN) +{ + _thresholdImageView = new ThresholdImageView(); + + wxButton *thresholdGoBtn = new wxButton(this,wxID_ANY,_T("Show/Hide Color"), wxDefaultPosition, wxSize(200,30) ); + _interpolationCheckBox = new wxCheckBox(this, -1, _T("Image interpolation") ); + _interpolationCheckBox->SetValue(true); + _opacity = new wxSlider(this, wxID_ANY, 6, 1, 10, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator); + _thresholdGo = false; + + double range[2]; +// interfMainPanel::getInstance()->getImageRange(range); + + int min = (int)floor (range[0]); + int max = (int)ceil (range[1]); + + _mBarThreshold = new mBarRange(this,70,65); + _mBarThreshold->SetMin(0); + _mBarThreshold->SetStart(0); + _mBarThreshold-> SetOrientation( true ); + _mBarThreshold-> setActiveStateTo(true); + _mBarThreshold-> setVisibleLabels( true ); + _mBarThreshold-> setDeviceEndMargin(10); + _mBarThreshold-> setRepresentedValues( min , max ); + _mBarThreshold-> setDeviceBlitStart(10,10); + _mBarThreshold-> setIfWithActualDrawed( false ); + _mBarThreshold-> SetStart( min ); + _mBarThreshold-> SetEnd( max ); + + Connect( thresholdGoBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &ThresholdImageViewPanel::onThresholdGo ); + Connect( _interpolationCheckBox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &ThresholdImageViewPanel::onThresholdInterpolation ); + + wxFlexGridSizer * sizer = new wxFlexGridSizer(1); + sizer -> Add( new wxStaticText(this,-1,_T("Image Threshold")) , 1, wxGROW ); + sizer -> Add( _mBarThreshold, 1, wxGROW ); + sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW ); + sizer -> Add( new wxStaticText(this,-1,_T("Opacity Level")) , 1, wxGROW ); + sizer -> Add( _opacity, 1, wxGROW ); + sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW ); + sizer -> Add( thresholdGoBtn, 1, wxGROW ); + sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW ); + sizer -> Add( _interpolationCheckBox, 1, wxGROW ); + + this->SetSizer( sizer ); + this->SetAutoLayout( true ); + this->Layout(); +} + +//---------------------------------------------------------------------------- +ThresholdImageViewPanel::~ThresholdImageViewPanel(){ +} + + +//---------------------------------------------------------------------------- +void ThresholdImageViewPanel::SetThresholdImageView(ThresholdImageView* thresholdImageView) +{ + _thresholdImageView = thresholdImageView; +} + + +//---------------------------------------------------------------------------- +void ThresholdImageViewPanel::onThresholdChange(wxCommandEvent& event) +{ + if (_thresholdGo) + { + _thresholdImageView->onThresholdChange(); + + //std::cout<< "Valor Min: " << minVal << " & Valor Max: " << maxVal << std::endl; + } +} + +//---------------------------------------------------------------------------- +void ThresholdImageViewPanel::onThresholdGo(wxCommandEvent& event) +{ + if (!_thresholdGo) + { + _thresholdImageView->onThreshold(); + _thresholdGo=true; + } + else + { + _thresholdImageView->onThresholdRemove( ); + _thresholdGo=false; + } +} + +//---------------------------------------------------------------------------- +void ThresholdImageViewPanel::onThresholdStop() +{ + if (_thresholdGo) + { + _thresholdImageView->onThresholdRemove( ); + _thresholdGo=false; + } +} + +//---------------------------------------------------------------------------- +void ThresholdImageViewPanel::onThresholdInstantChange(double range[]) +{ + range[0] = _mBarThreshold->GetStart(); + range[1] = _mBarThreshold->GetEnd(); +} + +//---------------------------------------------------------------------------- +void ThresholdImageViewPanel::onThresholdInterpolation(wxCommandEvent& event) +{ + _thresholdImageView->onThresholdInterpolation(_interpolationCheckBox->GetValue()); +} + +//---------------------------------------------------------------------------- +void ThresholdImageViewPanel::onChangeOpacity(wxScrollEvent& event) +{ + int opacity = _opacity->GetValue(); + _thresholdImageView->onThresholdChangeOpacity(opacity); +} + + + +BEGIN_EVENT_TABLE(ThresholdImageViewPanel, wxPanel) + EVT_COMMAND(wxID_ANY, wxEVT_TSBAR_START, ThresholdImageViewPanel::onThresholdChange) + EVT_COMMAND(wxID_ANY, wxEVT_TSBAR_END, ThresholdImageViewPanel::onThresholdChange) + EVT_COMMAND(wxID_ANY, wxEVT_TSBAR_MOVED, ThresholdImageViewPanel::onThresholdChange) + EVT_SCROLL(ThresholdImageViewPanel::onChangeOpacity) +END_EVENT_TABLE() + + + +// EOF + diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ThresholdImageViewPanel.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ThresholdImageViewPanel.h new file mode 100644 index 0000000..54d9985 --- /dev/null +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ThresholdImageViewPanel.h @@ -0,0 +1,52 @@ + + +/** + * \file + * \brief Class ThresholdImageViewPanel . + */ + +/** + * \class ThresholdImageViewPanel + * \brief + */ + +#ifndef __ThresholdImageViewPanel_h__ +#define __ThresholdImageViewPanel_h__ + + +#include +#include "mBarRange.h" +#include "ThresholdImageView.h" + + + class ThresholdImageViewPanel + : public wxPanel + { + public: + ThresholdImageViewPanel(wxWindow * parent); + ~ThresholdImageViewPanel(); + void onThresholdStop(); + void onThresholdInstantChange(double range[]); + void SetThresholdImageView(ThresholdImageView* thresholdImageView); + + private: + + bool _thresholdGo; + ThresholdImageView *_thresholdImageView; + mBarRange *_mBarThreshold; + wxSlider *_opacity; + wxCheckBox *_interpolationCheckBox; + + void onThresholdChange(wxCommandEvent& event); + void onThresholdGo(wxCommandEvent& event); + void onThresholdInterpolation(wxCommandEvent& event); + void onChangeOpacity(wxScrollEvent& event); + + DECLARE_EVENT_TABLE() + }; + + + + +#endif + -- 2.46.2