From dea0efc567d8332b2e7eb936e3ba4ac1c11b2542 Mon Sep 17 00:00:00 2001 From: Eduardo DAVILA Date: Mon, 18 Dec 2017 12:47:23 +0100 Subject: [PATCH] #3162 creaMaracasVisu Bug New Normal - Threshold layer --- .../bbcreaMaracasVisuShowNPoints_Reset.cxx | 3 -- bbtk/src/bbmaracasvisuShowNPoints.cxx | 3 -- bbtk/src/bbmaracasvisuShowNPoints.h | 2 +- .../wxWindows/Contour/ContourExtractData.cxx | 30 ++++++++++++------- .../ColorLayerImageView.cxx | 2 +- .../ThresholdImageView/LayerImageBase.cxx | 8 +++-- .../ThresholdImageView/LayerImageBase.h | 1 + .../ThresholdImageViewPanel.cxx | 8 ++--- .../ThresholdImageViewPanel.h | 2 +- .../wxWindows/widgets/WidgetShowNPoints.cxx | 26 +++++++++++----- .../wxWindows/widgets/wxVtk2DBaseView.cxx | 7 +++++ .../wxWindows/widgets/wxVtk2DBaseView.h | 1 + 12 files changed, 59 insertions(+), 34 deletions(-) diff --git a/bbtk/src/bbcreaMaracasVisuShowNPoints_Reset.cxx b/bbtk/src/bbcreaMaracasVisuShowNPoints_Reset.cxx index a4c96a9..20ad1cb 100644 --- a/bbtk/src/bbcreaMaracasVisuShowNPoints_Reset.cxx +++ b/bbtk/src/bbcreaMaracasVisuShowNPoints_Reset.cxx @@ -29,12 +29,9 @@ void ShowNPoints_Reset::Process() // bbSetOutputOut( bbGetInputIn() ); // std::cout << "Output value = " <DeleteAllPoints(); bbGetInputWidgetShowNPoints()->GetModelShowNPoints()->SetFirstTime(true); - -printf("EED ShowNPoints_Reset::Process End\n"); } //===== // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) diff --git a/bbtk/src/bbmaracasvisuShowNPoints.cxx b/bbtk/src/bbmaracasvisuShowNPoints.cxx index 796b3c1..e571357 100644 --- a/bbtk/src/bbmaracasvisuShowNPoints.cxx +++ b/bbtk/src/bbmaracasvisuShowNPoints.cxx @@ -97,7 +97,6 @@ BBTK_BLACK_BOX_IMPLEMENTATION(ShowNPoints,bbtk::WxBlackBox); //----------------------------------------------------------------- void ShowNPoints::Process() { -printf("EED ShowNPoints::Process Start\n"); if (mwxwidget!=NULL) { mwxwidget->SetRenderer( bbGetInputRenderer() ); @@ -109,7 +108,6 @@ printf("EED ShowNPoints::Process Start\n"); if ( mwxwidget->GetModelShowNPoints()->GetFirstTime()==true ) { -printf("EED ShowNPoints::Process firsttime\n"); mwxwidget->GetModelShowNPoints()->SetFirstTime(false); mwxwidget->SetInitLstPoints( bbGetInputInitLstPointsX() , bbGetInputInitLstPointsY() , bbGetInputInitLstPointsZ() , bbGetInputInitLstLabels() ); } @@ -120,7 +118,6 @@ printf("EED ShowNPoints::Process firsttime\n"); bbSetOutputlstLabels( mwxwidget->GetModelShowNPoints()->GetLstLabels() ); bbSetOutputWidgetShowNPoints( (WidgetShowNPoints*)mwxwidget ); } // mwxwidget -printf("EED ShowNPoints::Process End\n"); } //----------------------------------------------------------------- diff --git a/bbtk/src/bbmaracasvisuShowNPoints.h b/bbtk/src/bbmaracasvisuShowNPoints.h index 46ff3ec..cfeee43 100644 --- a/bbtk/src/bbmaracasvisuShowNPoints.h +++ b/bbtk/src/bbmaracasvisuShowNPoints.h @@ -106,7 +106,7 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(ShowNPoints,bbtk::WxBlackBox); BBTK_INPUT(ShowNPoints,InitLstPointsY,"Initial lst of points Y",std::vector,""); BBTK_INPUT(ShowNPoints,InitLstPointsZ,"Initial lst of points Z",std::vector,""); BBTK_INPUT(ShowNPoints,InitLstLabels,"Initial lst of labels",std::vector,""); - BBTK_INPUT(ShowNPoints,Type,"Type of the widget. 0(default): N-points, 1:Just one point",int,""); + BBTK_INPUT(ShowNPoints,Type,"Type of the widget. 0(default): N-points, 1:Just one point, 2:Add/DeleteAll points, 3:As 0 with out save/load option",int,""); BBTK_OUTPUT(ShowNPoints , lstPointsX , " list of points X ", std::vector ,""); BBTK_OUTPUT(ShowNPoints , lstPointsY , " list of points Y ", std::vector ,""); diff --git a/lib/maracasVisuLib/src/interface/wxWindows/Contour/ContourExtractData.cxx b/lib/maracasVisuLib/src/interface/wxWindows/Contour/ContourExtractData.cxx index a0cfd9a..c08f5d9 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/Contour/ContourExtractData.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/Contour/ContourExtractData.cxx @@ -387,10 +387,13 @@ void ContourExtractData::PutVtkImageDataResultValue( int x, int y, int z, double { unsigned short *pValue; unsigned short *pMask; - pValue = (unsigned short *)imagedataValueResult->GetScalarPointer(x,y,z); - pMask = (unsigned short *)imagedataMaskResult->GetScalarPointer(x,y,z); - *pMask = 255; - *pValue = (unsigned short)value; +//EED 2017-12-18 + imagedataValueResult->SetScalarComponentFromDouble(x,y,z,0,value); + imagedataMaskResult->SetScalarComponentFromDouble(x,y,z,0,255); +// pValue = (unsigned short *)imagedataValueResult->GetScalarPointer(x,y,z); +// *pValue = (unsigned short)value; +// pMask = (unsigned char *)imagedataMaskResult->GetScalarPointer(x,y,z); +// *pMask = 255; } //------------------------------------------------------------------------ @@ -407,8 +410,8 @@ void ContourExtractData::ResetImageResult(int z) imagedataValueResult->GetExtent(ext); int size = (ext[1]-ext[0]+1) * (ext[3]-ext[2]+1); - memset(pValue,0,size*2); - memset(pMask,0,size*2); + memset(pValue,0, size*imagedataValueResult->GetScalarSize() ); + memset(pMask,0, size*imagedataMaskResult->GetScalarSize() ); } // if } @@ -558,8 +561,11 @@ void ContourExtractData::InitVtkImagesResult() imagedataValueResult->Delete(); } imagedataValueResult = vtkImageData::New(); - // imagedataValueResult->SetScalarType(scalartype); - imagedataValueResult->SetScalarTypeToUnsignedShort(); + +//EED 2017-12-18 + imagedataValueResult->SetScalarType(scalartype); + //imagedataValueResult->SetScalarTypeToUnsignedShort(); + imagedataValueResult->SetSpacing(spc); imagedataValueResult->SetDimensions( newDim ); imagedataValueResult->AllocateScalars(); @@ -569,8 +575,12 @@ void ContourExtractData::InitVtkImagesResult() imagedataMaskResult->Delete(); } imagedataMaskResult = vtkImageData::New(); - // imagedataMaskResult->SetScalarType(scalartype); - imagedataMaskResult->SetScalarTypeToUnsignedShort(); + +//EED 2017-12-18 +// imagedataMaskResult->SetScalarType(scalartype); +// imagedataMaskResult->SetScalarTypeToUnsignedShort(); + imagedataMaskResult->SetScalarTypeToUnsignedChar(); + imagedataMaskResult->SetSpacing(spc); imagedataMaskResult->SetDimensions( newDim ); imagedataMaskResult->AllocateScalars(); diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageView.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageView.cxx index 7cb4e90..07634e3 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageView.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageView.cxx @@ -429,7 +429,7 @@ void ColorLayerImageView::ConfigLookupTable() // virtual end = GrayLevel_TO_colorTableIndex( GetGreyLevelBoundaries(iColor+1) ); t1 = _transparence_level_boundary[iColor]; t2 = _transparence_level_boundary[iColor+1]; -printf("EED ColorLayerImageView::ConfigLookupTable Make something with transparence \n"); +//printf("EED ColorLayerImageView::ConfigLookupTable Make something with transparence \n"); FillColorTable( start,end, r1,g1,b1, r2,g2,b2, t1,t2 ); }// for } //if diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.cxx index f625d57..06a085a 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.cxx @@ -97,6 +97,7 @@ LayerImageBase::LayerImageBase() _X = -1; _Y = -1; _Z = -1; + _opacity = 1; _thresholdTable = NULL; _thresholdMapper = NULL; _scalarbarActor = NULL; @@ -409,12 +410,10 @@ void LayerImageBase::onThreshold() double y=GetY(); double z=GetZ(); - x = x*_spcBase[0]; y = y*_spcBase[1]; z = z*_spcBase[2]; - CleanXYZ(x,y,z); vtkCamera *camera = _baseView->GetRenderer()->GetActiveCamera(); @@ -509,7 +508,8 @@ void LayerImageBase::onThreshold() _thresholdMapper->SetInput( img ); _thresholdMapper->SetLookupTable( _thresholdTable ); _thresholdActor->SetInput( _thresholdMapper->GetOutput() ); - + _thresholdActor->SetOpacity(_opacity); + _scalarbarActor->SetLookupTable( _thresholdTable ); // _scalarbarActor->SetLookupTable( _thresholdMapper->GetLookupTable() ); _scalarbarActor->SetTitle("Value"); @@ -557,6 +557,8 @@ void LayerImageBase::onThresholdChangeOpacity (int opacity) { _thresholdActor->SetOpacity(opacity/100.0); } +// EED 2017-12-17 + _opacity = (double)opacity/100.0; } //---------------------------------------------------------------------------- diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.h index 3d27d31..e9eec43 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.h @@ -130,6 +130,7 @@ class LayerImageBase double _newSpcLayer[3]; int _dimBase[3]; double _spcBase[3]; + double _opacity; vtkImageData *_image; vtkImageChangeInformation *_imageChangeInformation; diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ThresholdImageViewPanel.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ThresholdImageViewPanel.cxx index c3e7bcf..8bb4a57 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ThresholdImageViewPanel.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ThresholdImageViewPanel.cxx @@ -38,7 +38,7 @@ /** ** Begin of the threshold panel **/ -ThresholdImageViewPanel::ThresholdImageViewPanel(wxWindow* parent, int min, int max, int type) +ThresholdImageViewPanel::ThresholdImageViewPanel(wxWindow* parent, int min, int max, int start, int end, int type) : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN) { _thresholdImageView = new ThresholdImageView(); @@ -51,7 +51,7 @@ ThresholdImageViewPanel::ThresholdImageViewPanel(wxWindow* parent, int min, int _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); + _opacity = new wxSlider(this, wxID_ANY, 50, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator); // double range[2]; // interfMainPanel::getInstance()->getImageRange(range); @@ -75,8 +75,8 @@ ThresholdImageViewPanel::ThresholdImageViewPanel(wxWindow* parent, int min, int _mBarThreshold-> setRepresentedValues( min , max ); _mBarThreshold-> setDeviceBlitStart(10,10); _mBarThreshold-> setIfWithActualDrawed( false ); - _mBarThreshold-> SetStart( min ); - _mBarThreshold-> SetEnd( max ); + _mBarThreshold-> SetStart( start ); + _mBarThreshold-> SetEnd( end ); } diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ThresholdImageViewPanel.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ThresholdImageViewPanel.h index 96fd710..9153d9d 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ThresholdImageViewPanel.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ThresholdImageViewPanel.h @@ -48,7 +48,7 @@ : public wxPanel { public: - ThresholdImageViewPanel(wxWindow * parent, int min, int max, int type); + ThresholdImageViewPanel(wxWindow * parent, int min, int max, int start, int end, int type); ~ThresholdImageViewPanel(); void onThresholdStop(); void SetThresholdImageView(ThresholdImageView* thresholdImageView); diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.cxx index b9f8386..d221713 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.cxx @@ -34,7 +34,7 @@ wxPanel *panel = this; wxSizer *sizer = NULL; - if (mtype==0) + if ((mtype==0) || (mtype==3)) { // Widget interface askPointLabel = new wxStaticText(panel, -1, _T("Point label :")); // JPR @@ -46,8 +46,13 @@ wxButton *btnEraseLastPoint = new wxButton( panel, -1, _T("Erase Last point")); wxButton *btnErasePoint = new wxButton( panel, -1, _T("Erase point")); wxButton *btnDeleteAllPoints = new wxButton( panel, -1, _T("Delete all points")); - wxButton *btnSavePoints = new wxButton( panel, -1, _T("Save points")); - wxButton *btnLoadPoints = new wxButton( panel, -1, _T("Load points")); + wxButton *btnSavePoints = NULL; + wxButton *btnLoadPoints = NULL; + if (mtype==0) + { + btnSavePoints = new wxButton( panel, -1, _T("Save points")); + btnLoadPoints = new wxButton( panel, -1, _T("Load points")); + } txtNrPoints = new wxStaticText(panel,-1, _T(" ")); //NTU: Sliders for opacity and radio change @@ -66,9 +71,11 @@ Connect(btnEraseLastPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnEraseLastPoint); Connect(btnErasePoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnErasePoint); Connect(btnDeleteAllPoints->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnDeleteAllPoints); - Connect(btnSavePoints->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnSavePoints); - Connect(btnLoadPoints->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnLoadPoints); - + if (mtype==0) + { + Connect(btnSavePoints->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnSavePoints); + Connect(btnLoadPoints->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnLoadPoints); + } //NTU: Slider events Connect(sdrOpacity->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints); Connect(sdrRadio->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints); @@ -87,8 +94,11 @@ sizer1->Add(sdrOpacity,1,wxGROW ); sizer1->Add(txRadio); sizer1->Add(sdrRadio,1,wxGROW ); - sizer1->Add(btnSavePoints); - sizer1->Add(btnLoadPoints); + if (mtype==0) + { + sizer1->Add(btnSavePoints); + sizer1->Add(btnLoadPoints); + } sizer = sizer1; } diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtk2DBaseView.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtk2DBaseView.cxx index 1110fc1..3879377 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtk2DBaseView.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtk2DBaseView.cxx @@ -381,6 +381,13 @@ void wxVtk2DBaseView::SetColorLevel(double level) this->Refresh(); } +//------------------------------------------------------------------- +void wxVtk2DBaseView::SetInterpolate(bool iterpolate) +{ + GetVtkBaseData()->SetInterpolate( iterpolate ); + this->Refresh(); +} + //------------------------------------------------------------------- int wxVtk2DBaseView::GetDirection() // virtual { diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtk2DBaseView.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtk2DBaseView.h index 66d7518..380d5a7 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtk2DBaseView.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtk2DBaseView.h @@ -59,6 +59,7 @@ public: void setColorTransferFunction(vtkColorTransferFunction* colortable); void SetColorWindow(double level); void SetColorLevel(double level); + void SetInterpolate(bool iterpolate); virtual int GetDirection(); void SetImageToVtkViewer(vtkImageData *imageData); -- 2.47.1