]> Creatis software - creaMaracasVisu.git/commitdiff
ViewerNV 2D with color Transfer Function
authorJuan Prieto <Juan.Prieto@creatis.insa-lyon.fr>
Mon, 27 Jul 2009 07:58:19 +0000 (07:58 +0000)
committerJuan Prieto <Juan.Prieto@creatis.insa-lyon.fr>
Mon, 27 Jul 2009 07:58:19 +0000 (07:58 +0000)
13 files changed:
bbtk/src/bbmaracasvisuShowNPoints.cxx
bbtk/src/bbmaracasvisuTransferFunctionView.cxx
bbtk/src/bbmaracasvisuViewerNV.cxx
bbtk/src/bbmaracasvisuViewerNV.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkImageViewer2_XYZ.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkImageViewer2_XYZ.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracas_N_ViewersWidget.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracas_N_ViewersWidget.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracas_ViewerWidget.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracas_ViewerWidget.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtk2DBaseView.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtk2DBaseView.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR2DView.cxx

index 1a1b2c64f776142b75ab6c11c224dd53befe6c08..6b35fe33e6a5265d2bb30aa64c334adeb5255b1b 100644 (file)
@@ -161,12 +161,22 @@ void WidgetShowNPoints::AddPoint(int x, int y, int z, std::string label)
        sphereActor->SetMapper(sphereMapper);
        sphereActor->SetOrigin(0, 0, 0);
        double spc[3];
+       if(mimage==NULL){
+               wxMessageDialog dialog(this, _T("Image Not Set"),_T("Image Not Set"),wxICON_ERROR);
+               dialog.ShowModal();
+               return;
+       }
        mimage->GetSpacing(spc);
        sphereActor->SetPosition( spc[0]*x , spc[1]*y , spc[2]*z );
        sphereActor->GetProperty()->SetColor( mcolour[0] , mcolour[1] , mcolour[2] );
        sphereActor->GetProperty()->SetOpacity( mopacity );
 
        lstActorsSphere.push_back(sphereActor);
+       if(renderer==NULL){
+               wxMessageDialog dialog(this, _T("Renderer Not Set"),_T("Renderer Not Set"),wxICON_ERROR);
+               dialog.ShowModal();             
+               return;
+       }
        renderer->AddActor( sphereActor );
 
        // Actor
@@ -432,7 +442,7 @@ void ShowNPoints::bbUserSetDefaultValues()
 {
        mwxwidget = NULL;
 
-       bbSetInputRadio(0.5);
+       bbSetInputRadio(1);
        bbSetInputOpacity(1);
 
        std::vector<double> colour;
index 137f82b6b61a2eeb815732bfeded97b975773fda..fb08960103c2527342858756b5930475927995cd 100644 (file)
@@ -80,6 +80,9 @@ void TransferFunctionView::bbUserSetDefaultValues()
        _tfun = NULL;
        _ctfun = NULL;   
 
+       bbSetOutputOpacityFunction(0);
+       bbSetOutputColorFunction(0);
+
 }
 
        
index 4dfa24f457ab4461afc5360d90db87e94ebf4d01..ae65750acbf5673d2d0f57438e1ff4045abb8c94 100644 (file)
@@ -72,11 +72,11 @@ void ViewerNV::Process()
                
                if(!compareVectors(type, currenttype)){
                        mwxwidget->SetType(&type);
-                       mwxwidget->UpdateLayout(img);
+                       mwxwidget->UpdateLayout(img);                   
                }else if (img != currentimg){           
                        mwxwidget->SetImage(img);
                        //mwxwidget->UpdateLayout(img);
-               }
+               }               
                currenttype = type;
                currentimg = img;
                
@@ -104,6 +104,10 @@ void ViewerNV::Process()
                if (wvbv2!=NULL) { bbSetOutputRenderer2( wvbv2->GetRenderer() ); }
                if (wvbv3!=NULL) { bbSetOutputRenderer3( wvbv3->GetRenderer() ); }
                if (wvbv4!=NULL) { bbSetOutputRenderer4( wvbv4->GetRenderer() ); }
+
+               if(bbGetInputColorFunction()!=NULL){
+                       mwxwidget->setColorTransferFunction(bbGetInputColorFunction());
+               }
        }       
 }
 
@@ -144,6 +148,7 @@ void ViewerNV::bbUserSetDefaultValues()
                bbSetOutputRenderer2( NULL );
                bbSetOutputRenderer3( NULL );
                bbSetOutputRenderer4( NULL );
+               bbSetInputColorFunction(NULL);
 }
 
        //-----------------------------------------------------------------     
index e92aa7336d6bb833e597fd278500055b4d427dce..51d24a3fb6d06f832d475074480998b44889f1b4 100644 (file)
@@ -46,6 +46,7 @@ class /*BBTK_EXPORT*/ ViewerNV
   BBTK_DECLARE_INPUT(Title,std::string);
       BBTK_DECLARE_INPUT(In, vtkImageData *);
          BBTK_DECLARE_INPUT(nTypeView, std::vector<int> );
+         BBTK_DECLARE_INPUT(ColorFunction, vtkColorTransferFunction* );
       BBTK_DECLARE_OUTPUT(wxVtkBaseView1,wxVtkBaseView*);
       BBTK_DECLARE_OUTPUT(wxVtkBaseView2,wxVtkBaseView*);
       BBTK_DECLARE_OUTPUT(wxVtkBaseView3,wxVtkBaseView*);
@@ -79,6 +80,7 @@ BBTK_DESCRIPTION("Viewer : N view configuration 2D and 3D");
   BBTK_INPUT(ViewerNV,Title,"Title prepended to the text",std::string,"");
        BBTK_INPUT(ViewerNV,In,"Input image",vtkImageData*,"");
        BBTK_INPUT(ViewerNV,nTypeView,"vector of viewer types (default 5 0 1 3 ): -1=Z_2DwithOutAxis 0=Z_2D 1=X_2D 2=Y_2D 3=Plane 4=Sphere 5=3D 6=3Dplane",std::vector<int>,"");
+       BBTK_INPUT(ViewerNV,ColorFunction,"Optional: set a different color for the viewers 2D",vtkColorTransferFunction*,"");
        BBTK_OUTPUT(ViewerNV,wxVtkBaseView1,"wxVtkBaseView 1",wxVtkBaseView  *,"");
        BBTK_OUTPUT(ViewerNV,wxVtkBaseView2,"wxVtkBaseView 2",wxVtkBaseView  *,"");
        BBTK_OUTPUT(ViewerNV,wxVtkBaseView3,"wxVtkBaseView 3",wxVtkBaseView  *,"");
index dc98f557912409b647c4e9043269ffd8acc35c7a..c692f96ed76db559906340690f774792721f58a7 100644 (file)
@@ -9,7 +9,7 @@ vtkImageViewer2_XYZ::vtkImageViewer2_XYZ()
        _vtkimageviewer2=  vtkImageViewer2::New();
        _vtkimageviewer2->GetRenderer()->GradientBackgroundOn();
        _vtkimageviewer2->GetRenderer()->SetBackground( 0.33 , 0.33 , 0.33 );
-       _vtkimageviewer2->GetRenderer()->SetBackground2( 0.66 , 0.66 , 0.66 );
+       _vtkimageviewer2->GetRenderer()->SetBackground2( 0.66 , 0.66 , 0.66 );  
 }
 //-------------------------------------------------------------------
 vtkImageViewer2_XYZ::~vtkImageViewer2_XYZ()
@@ -84,3 +84,13 @@ vtkImageViewer2 *vtkImageViewer2_XYZ::GetVtkImageViewer2()
 {
        return _vtkimageviewer2;
 }
+
+void vtkImageViewer2_XYZ::setColorTransferFunction(vtkColorTransferFunction* colortable){
+
+       vtkImageMapToWindowLevelColors* imagemaptowindowlevel = _vtkimageviewer2->GetWindowLevel();
+
+       if(colortable!=NULL&&colortable->GetSize()>0){
+               imagemaptowindowlevel->SetLookupTable(colortable);
+       }
+
+}
index ebac223770d4654df472581b9e44facc9e6944df..472ac9b830743b8bcb097a140b02f96d718c8c01 100644 (file)
@@ -7,6 +7,8 @@
 //------------------------------------------------------------------
 #include "marTypes.h"
 #include "vtkImageViewer2.h"
+#include "vtkImageMapToWindowLevelColors.h"
+#include "vtkColorTransferFunction.h"
 
 class  creaMaracasVisu_EXPORT vtkImageViewer2_XYZ{
 public:
@@ -22,6 +24,8 @@ public:
        int                             GetZSlice();
        vtkImageViewer2 *GetVtkImageViewer2();
 
+       void setColorTransferFunction(vtkColorTransferFunction* colortable);
+
 private:
        int     _x1,_x2,_y1,_y2,_z1,_z2;
        vtkImageViewer2 *_vtkimageviewer2;
index 4ad8c77b282f5c3c39b0d85dda5d6b0c900c0e74..3cfdc1a9e69ec210799c3be347428827ea4a100a 100644 (file)
@@ -3,8 +3,8 @@
   Program:   wxMaracas
   Module:    $RCSfile: wxMaracas_N_ViewersWidget.cxx,v $
   Language:  C++
-  Date:      $Date: 2009/06/05 06:07:39 $
-  Version:   $Revision: 1.10 $
+  Date:      $Date: 2009/07/27 07:58:20 $
+  Version:   $Revision: 1.11 $
 
   Copyright: (c) 2002, 2003
   License:
@@ -282,4 +282,18 @@ double wxMaracas_N_ViewersWidget :: GetZ()
 //     return wxwindow1->GetZ();
 }
 
+void wxMaracas_N_ViewersWidget::setColorTransferFunction(vtkColorTransferFunction* colortable){
+    if (wxwindow1!=NULL) {
+               wxwindow1->setColorTransferFunction(colortable);
+       }
+       if (wxwindow2!=NULL) {
+               wxwindow2->setColorTransferFunction(colortable);
+       }
+       if (wxwindow3!=NULL) {
+               wxwindow3->setColorTransferFunction(colortable);
+       }
+       if (wxwindow4!=NULL) {
+               wxwindow4->setColorTransferFunction(colortable);
+       }
+}
 
index 2efb923e0b2dd6b6dd45f6c6bde90cf26bd0309d..67a0e0c7b362081e6805187bbfa790d31c1a5eac 100644 (file)
@@ -3,8 +3,8 @@
   Program:   wxMaracas
   Module:    $RCSfile: wxMaracas_N_ViewersWidget.h,v $
   Language:  C++
-  Date:      $Date: 2009/06/05 06:07:39 $
-  Version:   $Revision: 1.6 $
+  Date:      $Date: 2009/07/27 07:58:20 $
+  Version:   $Revision: 1.7 $
 
   Copyright: (c) 2002, 2003
   License:
@@ -78,6 +78,8 @@ class creaMaracasVisu_EXPORT wxMaracas_N_ViewersWidget : public wxPanel
        double GetY();
        double GetZ();
 
+       void setColorTransferFunction(vtkColorTransferFunction* colortable);
+
        //------------------------------------------------------------------------------------------------------------
        // Attributes
        //------------------------------------------------------------------------------------------------------------
index c6d2e895a6d8f62dce9d993a821ac044c7006f33..7e68a7575230282ded95bc99735d6f2a6a72e3d5 100644 (file)
@@ -3,8 +3,8 @@
   Program:   wxMaracas
   Module:    $RCSfile: wxMaracas_ViewerWidget.cxx,v $
   Language:  C++
-  Date:      $Date: 2009/06/22 10:31:44 $
-  Version:   $Revision: 1.14 $
+  Date:      $Date: 2009/07/27 07:58:20 $
+  Version:   $Revision: 1.15 $
 
   Copyright: (c) 2002, 2003
   License:
 //             return mvtk2Dbaseview->GetVtkBaseData()->GetZ();
        }
 
+       void wxMaracas_ViewerWidget::setColorTransferFunction(vtkColorTransferFunction* colortable){            
+               if(mvtkmpr2Dview_X!=NULL){
+                       mvtkmpr2Dview_X->setColorTransferFunction(colortable);
+               }
+               if(mvtkmpr2Dview_Y!=NULL){
+                       mvtkmpr2Dview_Y->setColorTransferFunction(colortable);
+               }
+               if(mvtkmpr2Dview_Z!=NULL){
+                       mvtkmpr2Dview_Z->setColorTransferFunction(colortable);
+               }
+       }
\ No newline at end of file
index caa733e2e2068297e45133232f5d99e14015283b..77a37edf9d9f6c8f07611d648c960c963a8831cc 100644 (file)
@@ -3,8 +3,8 @@
   Program:   wxMaracas
   Module:    $RCSfile: wxMaracas_ViewerWidget.h,v $
   Language:  C++
-  Date:      $Date: 2009/06/05 06:07:39 $
-  Version:   $Revision: 1.6 $
+  Date:      $Date: 2009/07/27 07:58:20 $
+  Version:   $Revision: 1.7 $
 
   Copyright: (c) 2002, 2003
   License:
@@ -76,6 +76,7 @@
        // Attributes
        //------------------------------------------------------------------------------------------------------------
 
+       void setColorTransferFunction(vtkColorTransferFunction* colortable);
   private:
                int                                                             mType;
 
index 45a387a363f244dc823acce94a70a3ccb5bb518b..a7a406ba828a7bc7c37e7f113559bcabf52f4291 100644 (file)
@@ -241,3 +241,8 @@ void wxVtk2DBaseView::GetSpacing(double spc[3])  // virtual
    imageData->GetSpacing(spc);
 }
 
+void wxVtk2DBaseView::setColorTransferFunction(vtkColorTransferFunction* colortable){
+       if(_imageViewer2XYZ!=NULL){
+               _imageViewer2XYZ->setColorTransferFunction(colortable);
+       }
+}
index 749401273e0ba6df5239bcc58ce17eb3619d45a1..7ceccfb34f905bb327c97be8925e39c29ccc28a6 100644 (file)
@@ -34,6 +34,7 @@ public:
        virtual void                    TransformCoordinate_spacing_ModelToView(double &X,double &Y, double &Z);
        virtual void                    GetSpacing(double spc[3]);
 
+       void setColorTransferFunction(vtkColorTransferFunction* colortable);
 
 private:
        vtkBaseData                                                     *_vtkbasedata;
index 0ec8f0dc196e5a1c1b4b7d6c9a12adb0d32a7d4b..2163d69de9a5be80a0f129d68621af2bd42dee97 100644 (file)
@@ -63,52 +63,60 @@ void wxVtkMPR2DView::Configure(){
                _visibleAxis = true;
 
        // Axe A
-               _ptsA = vtkPoints::New();
-               _ptsA->SetNumberOfPoints(2);
-               _ptsA->SetPoint(0, -1000        , -1000 , -1000 );
-               _ptsA->SetPoint(1,  1000        ,  1000 ,  1000 );
-               vtkCellArray *linesA;
-               linesA = vtkCellArray::New();
-               linesA->InsertNextCell(2);
-               linesA->InsertCellPoint(0);
-               linesA->InsertCellPoint(1);
-               _pdA = vtkPolyData::New();
-               _pdA->SetPoints( _ptsA );
-               _pdA->SetLines( linesA );
-               linesA->Delete();  //do not delete lines ??
-               _lineAActor                                             =       vtkActor::New();
-               _lineAMapper                                    =       vtkPolyDataMapper::New();
-               _lineAMapper->SetInput(_pdA);
-               _lineAMapper->ImmediateModeRenderingOn();
-               _lineAActor->SetMapper(_lineAMapper);
-//             _lineAActor->GetProperty()->BackfaceCullingOn();
-               _lineAActor->GetProperty()->SetDiffuseColor(1,0,0);
-               _lineAActor->GetProperty()->SetLineWidth(2);
-               _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _lineAActor );
+               if(_lineAActor==NULL){
+                       _ptsA = vtkPoints::New();
+                       _ptsA->SetNumberOfPoints(2);
+                       _ptsA->SetPoint(0, -1000        , -1000 , -1000 );
+                       _ptsA->SetPoint(1,  1000        ,  1000 ,  1000 );
+                       vtkCellArray *linesA;
+                       linesA = vtkCellArray::New();
+                       linesA->InsertNextCell(2);
+                       linesA->InsertCellPoint(0);
+                       linesA->InsertCellPoint(1);
+                       _pdA = vtkPolyData::New();
+                       _pdA->SetPoints( _ptsA );
+                       _pdA->SetLines( linesA );
+                       linesA->Delete();  //do not delete lines ??
+                       _lineAActor                                             =       vtkActor::New();
+                       _lineAMapper                                    =       vtkPolyDataMapper::New();
+
+                       _lineAMapper->SetInput(_pdA);
+                       _lineAMapper->ImmediateModeRenderingOn();
+                       _lineAActor->SetMapper(_lineAMapper);
+       //              _lineAActor->GetProperty()->BackfaceCullingOn();
+                       _lineAActor->GetProperty()->SetDiffuseColor(1,0,0);
+                       _lineAActor->GetProperty()->SetLineWidth(2);
+                       _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _lineAActor );
+               }
+
+
+               
 
        // Axe B
-               _ptsB = vtkPoints::New();
-               _ptsB->SetNumberOfPoints(2);
-               _ptsB->SetPoint(0, -1000        , -1000 , -1000 );
-               _ptsB->SetPoint(1,  1000        ,  1000 ,  1000 );
-               vtkCellArray *linesB;
-               linesB = vtkCellArray::New();
-               linesB->InsertNextCell(2);
-               linesB->InsertCellPoint(0);
-               linesB->InsertCellPoint(1);
-               _pdB = vtkPolyData::New();
-               _pdB->SetPoints( _ptsB );
-               _pdB->SetLines( linesB );
-               linesB->Delete();  //do not delete lines ??
-               _lineBActor                                             =       vtkActor::New();
-               _lineBMapper                                    =       vtkPolyDataMapper::New();
-               _lineBMapper->SetInput(_pdB);
-               _lineBMapper->ImmediateModeRenderingOn();
-               _lineBActor->SetMapper(_lineBMapper);
-//             _lineBActor->GetProperty()->BackfaceCullingOn();
-               _lineBActor->GetProperty()->SetDiffuseColor(1,0,0);
-               _lineBActor->GetProperty()->SetLineWidth(2);
-               _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _lineBActor );
+               if(_lineBActor==NULL){
+                       _ptsB = vtkPoints::New();
+                       _ptsB->SetNumberOfPoints(2);
+                       _ptsB->SetPoint(0, -1000        , -1000 , -1000 );
+                       _ptsB->SetPoint(1,  1000        ,  1000 ,  1000 );
+                       vtkCellArray *linesB;
+                       linesB = vtkCellArray::New();
+                       linesB->InsertNextCell(2);
+                       linesB->InsertCellPoint(0);
+                       linesB->InsertCellPoint(1);
+                       _pdB = vtkPolyData::New();
+                       _pdB->SetPoints( _ptsB );
+                       _pdB->SetLines( linesB );
+                       linesB->Delete();  //do not delete lines ??
+                       _lineBActor                                             =       vtkActor::New();
+                       _lineBMapper                                    =       vtkPolyDataMapper::New();
+                       _lineBMapper->SetInput(_pdB);
+                       _lineBMapper->ImmediateModeRenderingOn();
+                       _lineBActor->SetMapper(_lineBMapper);
+       //              _lineBActor->GetProperty()->BackfaceCullingOn();
+                       _lineBActor->GetProperty()->SetDiffuseColor(1,0,0);
+                       _lineBActor->GetProperty()->SetLineWidth(2);
+                       _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _lineBActor );
+               }
 
        
                vtkCamera *camera =_imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->GetActiveCamera();