]> Creatis software - creaMaracasVisu.git/commitdiff
#3162 creaMaracasVisu Bug New Normal - Threshold layer
authorEduardo DAVILA <davila@localhost.localdomain>
Mon, 18 Dec 2017 11:47:23 +0000 (12:47 +0100)
committerEduardo DAVILA <davila@localhost.localdomain>
Mon, 18 Dec 2017 11:47:23 +0000 (12:47 +0100)
12 files changed:
bbtk/src/bbcreaMaracasVisuShowNPoints_Reset.cxx
bbtk/src/bbmaracasvisuShowNPoints.cxx
bbtk/src/bbmaracasvisuShowNPoints.h
lib/maracasVisuLib/src/interface/wxWindows/Contour/ContourExtractData.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageView.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ThresholdImageViewPanel.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ThresholdImageViewPanel.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtk2DBaseView.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtk2DBaseView.h

index a4c96a9fb8c338f2a8e090ecbafbe4bc3db26ba7..20ad1cb9abe8669e9a6db9f24886886f1cb0357e 100644 (file)
@@ -29,12 +29,9 @@ void ShowNPoints_Reset::Process()
 //    bbSetOutputOut( bbGetInputIn() );
 //    std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
   
-printf("EED ShowNPoints_Reset::Process Start\n");
 
        bbGetInputWidgetShowNPoints()->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)
index 796b3c1091916502dd6eb9080968c478a2f21eb5..e57135756ccf3dd2da59a388773d3f8ff9d004e1 100644 (file)
@@ -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");
 }
 
 //-----------------------------------------------------------------
index 46ff3ec2424b6be3a5742cd281ed47155804a875..cfeee438b6ccb5a8ab7d1dcbb35ac57c6f8f7411 100644 (file)
@@ -106,7 +106,7 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(ShowNPoints,bbtk::WxBlackBox);
   BBTK_INPUT(ShowNPoints,InitLstPointsY,"Initial lst of points Y",std::vector<int>,"");
   BBTK_INPUT(ShowNPoints,InitLstPointsZ,"Initial lst of points Z",std::vector<int>,"");
   BBTK_INPUT(ShowNPoints,InitLstLabels,"Initial lst of labels",std::vector<std::string>,"");
-  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<int> ,"");
   BBTK_OUTPUT(ShowNPoints , lstPointsY , " list of points Y ", std::vector<int> ,"");
index a0cfd9ae1e2cb27a3ffcf29866f95e0da7fc886a..c08f5d977fa6307339d3bcfb6c9b189681d9a98d 100644 (file)
@@ -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();
index 7cb4e902648ed14d2ffe5291297ef34ddd73fddd..07634e33399c311890428c732c515f1a07893f09 100644 (file)
@@ -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                          
index f625d57174f484f40986fe6e4afc9f8692e238f4..06a085a5634fbf8c4bb87aabbc3a31be2fa09484 100644 (file)
@@ -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;
 }
 
 //----------------------------------------------------------------------------
index 3d27d31b71145cda4a3316a17861719214340247..e9eec4326fb1accd52bf854fb4da8b5fe686ee7f 100644 (file)
@@ -130,6 +130,7 @@ class LayerImageBase
                double                                          _newSpcLayer[3];
                int                                             _dimBase[3];
                double                                          _spcBase[3];
+               double                                          _opacity;
 
                vtkImageData                            *_image;
                vtkImageChangeInformation       *_imageChangeInformation;
index c3e7bcf772573022a2c8152be00c513167522a25..8bb4a574e726a3014d6a543b168ce85e5b133709 100644 (file)
@@ -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 );  
        }
        
        
index 96fd710167a3e3ca8ee9136aada29621bc594d07..9153d9d14a7e9db5630644c28cdd93ce0e25fea2 100644 (file)
@@ -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);
index b9f838613aa9859363c6c55b850fa51caee9b8b2..d221713dba5553bac5ab3eb6d48f68398f77254e 100644 (file)
@@ -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
                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
                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);
                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;
        }
 
index 1110fc11f1d824b8a0e012978bf8ce28f062370a..3879377f94e3ba33d93aae257bed0007e9f3e8e8 100644 (file)
@@ -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
 {
index 66d7518510ae35a13d763d6186920a16234fa476..380d5a7d228f054501ea83dbdec1a79d0c73716b 100644 (file)
@@ -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);