]> Creatis software - creaMaracasVisu.git/commitdiff
changes in qt for volume rendering with gpu support, if you are working with volume...
authorJuan Prieto <Juan.Prieto@creatis.insa-lyon.fr>
Wed, 5 Oct 2011 16:26:53 +0000 (16:26 +0000)
committerJuan Prieto <Juan.Prieto@creatis.insa-lyon.fr>
Wed, 5 Oct 2011 16:26:53 +0000 (16:26 +0000)
34 files changed:
CMakeLists.txt
appli/QtVTKViewer/qtvtkviewer.cxx
lib/GUI/Base/SurfaceRenderer/wxMaracasSurfaceRenderingManager.cxx
lib/GUI/Base/SurfaceRenderer/wxMaracasSurfaceRenderingManager.h
lib/GUI/Base/VolumeRenderer/volumerendererdata.cxx
lib/GUI/Base/VolumeRenderer/volumerendererdata.h
lib/GUI/Qt/SurfaceRenderer/CMakeLists.txt
lib/GUI/Qt/SurfaceRenderer/qtsurfacerenderer.cxx [new file with mode: 0644]
lib/GUI/Qt/SurfaceRenderer/qtsurfacerenderer.h [new file with mode: 0644]
lib/GUI/Qt/SurfaceRenderer/qtsurfacerenderer.ui [new file with mode: 0644]
lib/GUI/Qt/SurfaceRenderer/qtsurfacerendererpanel.cxx
lib/GUI/Qt/SurfaceRenderer/qtsurfacerendererpanel.h
lib/GUI/Qt/SurfaceRenderer/qtsurfacerendererpanel.ui
lib/GUI/Qt/Viewers/CMakeLists.txt
lib/GUI/Qt/Viewers/qtvtkviewer.cpp
lib/GUI/Qt/Viewers/qtvtkviewer.h
lib/GUI/Qt/Viewers/qtvtkviewerwidget.cxx
lib/GUI/Qt/Viewers/qtvtkviewerwidget.h
lib/GUI/Qt/Viewers/qtvtkviewerwidget.ui
lib/GUI/Qt/VolumeRenderer/qtvolumerendererpanel.cxx
lib/GUI/Qt/VolumeRenderer/qtvolumerendererpanel.h
lib/GUI/Qt/VolumeRenderer/qtvolumerendererpanel.ui
lib/Kernel/VTKObjects/SurfaceRenderer/wxMaracasSurfaceRenderingManagerData.cxx
lib/Kernel/VTKObjects/SurfaceRenderer/wxMaracasSurfaceRenderingManagerData.h
lib/Kernel/VTKObjects/SurfaceRenderer/wxMaracasSurfaceRenderingManagerDataMhd.cxx
lib/Kernel/VTKObjects/ViewerWidgets/imageplanewidget.cxx
lib/Kernel/VTKObjects/ViewerWidgets/imageplanewidget.h
lib/Kernel/VTKObjects/VolumeRenderer/volumerenderermanager.cxx
lib/Kernel/VTKObjects/VolumeRenderer/volumerenderermanager.h
lib/Kernel/VTKObjects/VolumeRenderer/volumerenderermanagerdata.cxx
lib/Kernel/VTKObjects/VolumeRenderer/volumerenderermanagerdata.h
lib/maracasVisuLib/CMakeLists.txt
lib/maracasVisuLib/src/kernel/PlanesOperations.cxx
lib/maracasVisuLib/src/kernel/PlanesOperations.h

index 0f417366128f1685e21f123d2c4e2006413178a2..1d6b3f08305bccb40f349f76b31a1c53d876ffbd 100644 (file)
@@ -43,12 +43,11 @@ CREA_PREVENT_IN_SOURCE_BUILD()
 #SET(USE_GDCM_VTK ON)
 SET(USE_WXWIDGETS ON)
 SET(USE_VTK ON)
-SET(USE_ITK ON)
 SET(USE_BOOST ON)
 
 OPTION(QT_USE_QTUITOOLS "QT_USE_QTUITOOLS" OFF)
 IF(QT_USE_QTUITOOLS)
-       SET(USE_QT4 ON)
+       SET(USE_QT4 ON)        
 ELSE(QT_USE_QTUITOOLS)
        SET(USE_QT4 OFF)
 ENDIF(QT_USE_QTUITOOLS)
index 76778d49b1f9ff32253aa41941de821fba1a601e..fb6abc8a840bd3c3e03f8906a6cf0d9724130314 100644 (file)
@@ -1,22 +1,9 @@
 
 //----------------------------------------------------------------------
-//             File:                   ann_sample.cpp
-//             Programmer:             Sunil Arya and David Mount
-//             Last modified:  03/04/98 (Release 0.1)
-//             Description:    Sample program for ANN
-//----------------------------------------------------------------------
-// Copyright (c) 1997-2005 University of Maryland and Sunil Arya and
-// David Mount.  All Rights Reserved.
-//
-// This software and related documentation is part of the Approximate
-// Nearest Neighbor Library (ANN).  This software is provided under
-// the provisions of the Lesser GNU Public License (LGPL).  See the
-// file ../ReadMe.txt for further information.
-//
-// The University of Maryland (U.M.) and the authors make no
-// representations about the suitability or fitness of this software for
-// any purpose.  It is provided "as is" without express or implied
-// warranty.
+//             File:               qtvtkviewer.cxx
+//             Programmer:         Prieto
+//             Last modified:  25/08/11 (Release 0.1)
+//             Description:    Sample program fro qtvtkviewer
 //----------------------------------------------------------------------
 
 #include "qtvtkviewerwidget.h"
 
 #include "iostream"
 
-
-#include "OpenImageDialog.h"
+#include "vtkMetaImageReader.h"
+//#include "OpenImageDialog.h"
 
 using namespace std;
-using namespace creaMaracasVisuKernel;
-
+//using namespace creaMaracasVisuKernel;
 
 int main(int argc, char **argv)
 {
@@ -46,7 +32,7 @@ int main(int argc, char **argv)
 
     vtkImageData* img = 0;
 
-    if (argc < 2){
+    /*if (argc < 2){
 
         OpenImageDialog open(true);
         img = open.getImageData();
@@ -56,14 +42,14 @@ int main(int argc, char **argv)
                       << std::endl ;
             return EXIT_FAILURE;
          }
-    }else{
+    }else*/
+    if(argc==2){
         std::string inputFilename = argv[1];
 
         vtkMetaImageReader* reader = vtkMetaImageReader::New();
         reader->SetFileName(inputFilename.c_str());
         reader->Update();
         img = reader->GetOutput();
-
     }
 
 
@@ -79,12 +65,10 @@ int main(int argc, char **argv)
 
     mainwindow->show();
 
-    viewer->setImage(img);
+    if(img)
+        viewer->setImage(img);
     //viewer->SetLookupTable((vtkLookupTable*)colortransfer);
 
-
-
-
     return app.exec();
 }
 
index 220fecc48b3de5649a752e8f96d228c74ac335d6..ac816f6241cfcf4f38b6a1d7198f8422a9b01877 100644 (file)
@@ -3,8 +3,8 @@
   Program:   wxMaracas
   Module:    $RCSfile: wxMaracasSurfaceRenderingManager.cxx,v $
   Language:  C++
-  Date:      $Date: 2011/06/28 16:56:13 $
-  Version:   $Revision: 1.1 $
+  Date:      $Date: 2011/10/05 16:26:55 $
+  Version:   $Revision: 1.2 $
 
   Copyright: (c) 2002, 2003
   License:
 #include "wxMaracasSurfaceRenderingManager.h"
 #include "wxMaracasSurfaceRenderingManagerDataMhd.h"
 
+
+#include "vtkPLYReader.h"
+#include "vtkSmartPointer.h"
+
 /**
 **     Start of the manager class
 **/
@@ -63,7 +67,7 @@ void wxMaracasSurfaceRenderingManager::Update(int pid)throw(char*){
 **     Adds a prop3D to the manager and returns the identifier
 **/
 int wxMaracasSurfaceRenderingManager::addProp3D(int idTP, vtkProp3D* prop3D, std::string dataname)  throw(char*){
-       checkInvariant();
+        //checkInvariant();
        if(prop3D != NULL){
                wxMaracasSurfaceRenderingManagerData* data = new wxMaracasSurfaceRenderingManagerData(prop3D, dataname, _interactor);
                prop3Dvect.push_back(data);
@@ -85,7 +89,7 @@ int wxMaracasSurfaceRenderingManager::addProp3D(int idTP, vtkProp3D* prop3D, std
 }
 int wxMaracasSurfaceRenderingManager::addPropMHD(int idTP, vtkImageData* imagedata, std::string dataname) throw(char*){
        checkInvariant();
-       if(imagedata != NULL){
+       if(imagedata != NULL){                
                image = imagedata;
                wxMaracasSurfaceRenderingManagerData* data = new wxMaracasSurfaceRenderingManagerDataMhd(imagedata, dataname, _interactor);
                prop3Dvect.push_back(data);     
@@ -112,15 +116,20 @@ int wxMaracasSurfaceRenderingManager::addPropMHD(int idTP, vtkImageData* imageda
 void wxMaracasSurfaceRenderingManager::addRemoveActor(int propid, bool addremove)  throw(char*){
        checkInvariant();
        
-       wxMaracasSurfaceRenderingManagerData* data = this->getViewData(propid);         
-       if(data->getProp3D()!=NULL){
+        wxMaracasSurfaceRenderingManagerData* data = this->getViewData(propid);
+        if(data && data->getProp3D()!=NULL){
                if(addremove){
                        _renderer->AddViewProp(data->getProp3D());
                }else{
                        _renderer->RemoveViewProp(data->getProp3D());
                }
                _renderer->Render();
-       }
+        }else {
+            if(addremove && propid == 0 && image){
+                addPropMHD(0, image, "id0");
+            }
+            return;
+        }
 }
 /**
 **     adds or removes the surface box depending of the bool value
@@ -187,17 +196,29 @@ void wxMaracasSurfaceRenderingManager::changeIsoValue(int propid, double min, do
 
 vtkProp3D* wxMaracasSurfaceRenderingManager:: getProp3D(std::string filename){
        if(filename.compare("")!= 0){
-               vtkSTLReader *STLReader=vtkSTLReader::New();
+
+            vtkSmartPointer<vtkPolyData> polydata = vtkSmartPointer<vtkPolyData>::New();
+            std::string ext = filename.substr(filename.find_last_of("."), 4);
+            if(ext.compare(STL)==0){
+                vtkSmartPointer<vtkSTLReader> STLReader=vtkSmartPointer<vtkSTLReader>::New();
                STLReader->SetFileName(filename.c_str());
                STLReader->Update();
-               vtkPolyDataMapper* dataMapper = vtkPolyDataMapper::New();
-               dataMapper->SetInput(STLReader->GetOutput());
-               
-               vtkActor* dataActor = vtkActor::New();
-               dataActor->SetMapper(dataMapper);       
-               dataActor->GetProperty()->SetOpacity(1);
-               
-               return dataActor;
+                polydata->DeepCopy(STLReader->GetOutput());
+
+            }else if(ext.compare(PLY)==0){
+                vtkSmartPointer<vtkPLYReader> plyreader =vtkSmartPointer<vtkPLYReader>::New();
+                plyreader->SetFileName(filename.c_str());
+                plyreader->Update();
+                polydata->DeepCopy(plyreader->GetOutput());
+            }
+
+            vtkSmartPointer<vtkPolyDataMapper> dataMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
+            dataMapper->SetInput(polydata);
+
+            vtkActor* dataActor = vtkActor::New();
+            dataActor->SetMapper(dataMapper);
+            dataActor->GetProperty()->SetOpacity(1);
+            return dataActor;
        }       
        return NULL;
 }
@@ -219,6 +240,10 @@ vtkImageData* wxMaracasSurfaceRenderingManager::getImageData(){
        return image;
 }
 
+void wxMaracasSurfaceRenderingManager::setImageData(vtkImageData* img){
+    image = img;
+}
+
 void wxMaracasSurfaceRenderingManager::checkInvariant()  throw(char*){
        if(this->_renderer==NULL){
                throw "Renderer not set";
@@ -227,14 +252,19 @@ void wxMaracasSurfaceRenderingManager::checkInvariant()  throw(char*){
 
 wxMaracasSurfaceRenderingManagerData* wxMaracasSurfaceRenderingManager::getViewData(int id) throw(char*){
     int i;
-       for(i = 0; i < (int)(prop3Dvect.size());i++){
-               if(prop3Dvect[i]->getId() == id){
-                       return prop3Dvect[i];
-               }
-       }
-       throw "id not found in the data";
+    for(i = 0; i < (int)(prop3Dvect.size());i++){
+            if(prop3Dvect[i]->getId() == id){
+                    return prop3Dvect[i];
+            }
+    }
+    return 0;
+#ifndef USE_QT
+    throw "id not found in the data";
+#else
+    return NULL;
+#endif
+
 
-       return NULL;
 }
 
 int wxMaracasSurfaceRenderingManager::getMaxIsoValue(int propid) throw(char*){
@@ -272,8 +302,10 @@ void wxMaracasSurfaceRenderingManager::deleteActor(int propid) throw (char *){
                delete data;
                prop3Dvect.pop_back();
        }else{
+#ifndef USE_QT
+                throw "id not found in the data";
+#endif
 
-               throw "id not found in the data";
        }   
 }
 
@@ -282,7 +314,8 @@ void wxMaracasSurfaceRenderingManager::enableBoundingBox(int propid, bool enable
 
     wxMaracasSurfaceRenderingManagerData* data = this->getViewData(propid);
 
-    data->enableBoxWidget(enable);
+    if(data)
+        data->enableBoxWidget(enable);
 }
 void wxMaracasSurfaceRenderingManager::Transform(vtkMatrix4x4* tmatrix){
        
@@ -300,3 +333,7 @@ void wxMaracasSurfaceRenderingManager::saveProp3DSTL(int propid,const char* file
             data->saveProp3DSTL(filename);
     }
 }
+
+void wxMaracasSurfaceRenderingManager::loadProp3DSTL(const char* filename){
+    this->addProp3D(-1, this->getProp3D(filename), filename);
+}
index bd857fee154ccdeddf65ba79d2490ce97ae05a5a..63427972a6c9e3709e1004675c94df63005c9814 100644 (file)
@@ -3,8 +3,8 @@
   Program:   wxMaracas
   Module:    $RCSfile: wxMaracasSurfaceRenderingManager.h,v $
   Language:  C++
-  Date:      $Date: 2011/06/28 16:56:13 $
-  Version:   $Revision: 1.1 $
+  Date:      $Date: 2011/10/05 16:26:55 $
+  Version:   $Revision: 1.2 $
 
   Copyright: (c) 2002, 2003
   License:
@@ -28,6 +28,8 @@
 #include "wxMaracasSurfaceRenderingManagerData.h"
 
 
+
+
 class wxMaracasSurfaceRenderingManager  {
 
 public:
@@ -84,6 +86,8 @@ public:
        **/
        vtkImageData* getImageData();
 
+        virtual void setImageData(vtkImageData* img);
+
        /**
        **      adds or removes an actor depending of the bool value
        **/
@@ -129,6 +133,10 @@ public:
         void enableBoundingBox(int propid, bool enable);
 
         void saveProp3DSTL(int propid,const char* filename);
+
+        void loadProp3DSTL(const char* filename);
+
+
        
 private:       
        std::vector<wxMaracasSurfaceRenderingManagerData*> prop3Dvect;
index c19456f445c0ac20960148beabedad0353922a38..15ca192e41efbba91210ee55e3c90decd3bb63ce 100644 (file)
@@ -1,33 +1,51 @@
 #include "volumerendererdata.h"
 #include "vtkObjectFactory.h"
 
-vtkCxxRevisionMacro(VolumeRendererData, "$Revision: 1.6 $");
+vtkCxxRevisionMacro(VolumeRendererData, "$Revision: 1.7 $");
 vtkStandardNewMacro(VolumeRendererData);
 
 VolumeRendererData::VolumeRendererData()
 {
-    VolRendData = 0;
+    VolRendManager = 0;
     ImageData = 0;
     Renderer = 0;
     Interactor = 0;
+    LookUpTable = 0;
+    //ImageDataSeparateComponents = false;
 }
 
 
 void VolumeRendererData::ShowVolume(bool checked){
-    if(checked){
-          //  invariant();
-            //cout<<"JPRG::VolumeRendererData::ShowVolume"<<endl;
-            if(VolRendData==NULL)
-            {
-                VolRendData = new VolumeRendererManagerData(ImageData, true);
+
+    try{
+        if(checked){
+                invariant();
+                cout<<"JPRG::VolumeRendererData::ShowVolume"<<endl;
+                if(!VolRendManager){
+                    VolRendManager = new VolumeRendererManager();
+                    VolRendManager->addVolume(ImageData, Interactor);
+                }
+                if(LookUpTable)
+                    VolRendManager->SetLookupTable(LookUpTable);
+                vector< vtkProp3D* > props = VolRendManager->getProps3D();
+                for(unsigned i = 0; i < props.size(); i++){
+                    Renderer->AddActor(props[i]);
+                }
+
+        }else{
+            vector< vtkProp3D* > props = VolRendManager->getProps3D();
+            for(unsigned i = 0; i < props.size(); i++){
+                Renderer->RemoveActor(props[i]);
             }
-            VolRendData->SetLookupTable(LookUpTable);
-            Renderer->AddActor(VolRendData->getProp3D());
-    }else{
-        Renderer->RemoveActor(VolRendData->getProp3D());
-      //  VolRendData->Delete();
-      //  VolRendData = 0;
+            delete VolRendManager;
+            VolRendManager = 0;
+        }
+    }catch(char* e){
+        cout<<"Exception in: "<<e<<endl;
+    }catch(exception e){
+        cout<<"Exception in: "<<e.what()<<endl;
     }
+
 }
 
 void VolumeRendererData::invariant(){
@@ -41,37 +59,46 @@ void VolumeRendererData::invariant(){
 void VolumeRendererData::OpacityChanged(vector<double> greyvalues, vector<double> values){
     //invariant();
 
-    if(VolRendData==NULL)
-    {
-          VolRendData = new VolumeRendererManagerData(ImageData, true);
 
+    if(VolRendManager==NULL)
+    {
+        ShowVolume(true);
     }
-    VolRendData->SetLookupTable(LookUpTable);
-    VolRendData->setVolumeOpacity(greyvalues,values);
+    VolRendManager->setVolumeOpacity(greyvalues,values);
 
 }
 
 void  VolumeRendererData::BoundingBoxChanged(bool checked){
    // invariant();
 
-    if(VolRendData==NULL)
+    if(VolRendManager==NULL)
     {
-         VolRendData = new VolumeRendererManagerData(ImageData, true);
-         VolRendData->SetLookupTable(LookUpTable);
+         ShowVolume(true);
     }
 
 
-    if(VolRendData && Interactor){
+    if(VolRendManager && Interactor){
         if(checked){
-            VolRendData->EnableBoundingBox(Interactor);
+            VolRendManager->EnableBoundingBox(Interactor);
         }else{
-            VolRendData->DisableBoundingBox();
+            VolRendManager->DisableBoundingBox();
         }
     }
 }
 
 void VolumeRendererData::changeCompositeMIPFunction(int function){
     invariant();
-    if(VolRendData)
-        VolRendData->changeCompositeMIPFunction(function);
+    if(VolRendManager)
+        VolRendManager->changeCompositeMIPFunction(0, function);
+}
+
+/**
+  changes the interoplation type of the volume
+  type = 0 linear
+  type = 1 nearest
+   */
+void VolumeRendererData::changeInterpolationType(int type){
+    invariant();
+    if(VolRendManager)
+        VolRendManager->changeInterpolationType(type);
 }
index 95a7eb8ebcb7da4e3f4446926bf49c49362a9ba6..36f605bd0f60b164af3dca4884eebf6356cc1f8a 100644 (file)
@@ -2,7 +2,7 @@
 #define VOLUMERENDERERDATA_H
 
 
-#include "volumerenderermanagerdata.h"
+#include "volumerenderermanager.h"
 #include "vtkRenderWindowInteractor.h"
 #include "vtkObject.h"
 
@@ -15,25 +15,45 @@ public:
     vtkTypeRevisionMacro(VolumeRendererData,vtkObject);
     //
 
-    vtkSetObjectMacro(ImageData, vtkImageData)
-    vtkSetObjectMacro(Renderer, vtkRenderer)
-    vtkSetObjectMacro(LookUpTable, vtkLookupTable)
-    vtkSetObjectMacro(Interactor, vtkRenderWindowInteractor)
+    vtkSetObjectMacro(ImageData, vtkImageData);
+    //vtkSetMacro(ImageDataSeparateComponents, bool);
+
+    vtkSetObjectMacro(Renderer, vtkRenderer);
+    vtkSetObjectMacro(LookUpTable, vtkLookupTable);
+    vtkSetObjectMacro(Interactor, vtkRenderWindowInteractor);
+
+
+
     void BoundingBoxChanged(bool checked);
      void ShowVolume(bool enable);
      void OpacityChanged(vector<double> greyvalues, vector<double> values);
 
+     /**
+       chages the ray cast function type
+       function = 0 composite
+       function = 1 MIP (maximum intensity pixel)
+       */
     void changeCompositeMIPFunction(int function);
 
+    /**
+      changes the interoplation type of the volume
+      type = 0 linear
+      type = 1 nearest
+       */
+    void changeInterpolationType(int type);
+
 
 protected:
     VolumeRendererData();
-    VolumeRendererManagerData* VolRendData;
+    VolumeRendererManager* VolRendManager;
     vtkImageData* ImageData;
     vtkRenderer* Renderer;
     vtkLookupTable* LookUpTable;
     vtkRenderWindowInteractor* Interactor;
 
+//    bool ImageDataSeparateComponents;
+
+
 private:
 
     void invariant();
index 9aee37997e0d260a6e6190a8cc3ca2a76ca55024..df0fd890402f62aa93ef69bf3b0f148aee21395c 100644 (file)
@@ -56,7 +56,7 @@ IF ( BUILD_${LIBRARY_NAME} )
        # If this is NOT done, then the ui_*.h files will not be generated
        #add_executable(qtproject ${qtproject_SRCS} ${qtproject_UIS_H} )
 
-        FILE(GLOB ${LIBRARY_NAME}_HEADERS "*.h" "*.txx" "${PROJECT_BINARY_DIR}/lib/GUI/Qt/VTK/VolumeRenderer/*.h")
+        FILE(GLOB ${LIBRARY_NAME}_HEADERS "*.h" "*.txx" "${PROJECT_BINARY_DIR}/lib/GUI/Qt/VTK/SurfaceRenderer/*.h")
 
 
        set(${LIBRARY_NAME}_SOURCES ${${LIBRARY_NAME}_SOURCES} ${${LIBRARY_NAME}_UIS_H})
diff --git a/lib/GUI/Qt/SurfaceRenderer/qtsurfacerenderer.cxx b/lib/GUI/Qt/SurfaceRenderer/qtsurfacerenderer.cxx
new file mode 100644 (file)
index 0000000..2907ce7
--- /dev/null
@@ -0,0 +1,58 @@
+#include "qtsurfacerenderer.h"
+#include "ui_qtsurfacerenderer.h"
+
+
+#include <qtsurfacerendererpanel.h>
+
+QtSurfaceRenderer::QtSurfaceRenderer(QWidget *parent) :
+    QWidget(parent),
+    ui(new Ui::QtSurfaceRenderer)
+{
+    ui->setupUi(this);
+
+    this->ui->tabWidgetSurface->removeTab(1);
+    this->ui->tabWidgetSurface->removeTab(0);
+
+
+    QtSurfaceRendererPanel* surfacepanel = new QtSurfaceRendererPanel(this);
+    this->ui->tabWidgetSurface->addTab(surfacepanel, QString("Surface Rendering"));
+
+    Renderer = 0;
+    Interactor = 0;
+}
+
+QtSurfaceRenderer::~QtSurfaceRenderer()
+{
+    delete ui;
+}
+
+void QtSurfaceRenderer::SetImageData(vtkImageData* img){
+    this->ui->tabWidgetSurface->setCurrentIndex(0);
+    QtSurfaceRendererPanel* surfacepanel = (QtSurfaceRendererPanel*)this->ui->tabWidgetSurface->currentWidget();    
+    surfacepanel->setInteractor(Interactor);
+    surfacepanel->setRenderer(Renderer);
+    surfacepanel->setImageData(img);
+}
+
+void QtSurfaceRenderer::on_pushbuttonAddTab_clicked()
+{
+
+    QtSurfaceRendererPanel* surfacepanel = new QtSurfaceRendererPanel(this);    
+    surfacepanel->setRenderer(Renderer);
+    surfacepanel->setInteractor(Interactor);
+
+    this->ui->tabWidgetSurface->addTab(surfacepanel, QString("Surface Rendering"));
+}
+
+void QtSurfaceRenderer::on_tabWidgetSurface_tabCloseRequested(int index)
+{
+    if(index != 0){
+
+        QtSurfaceRendererPanel* surfacepanel = (QtSurfaceRendererPanel*)this->ui->tabWidgetSurface->currentWidget();
+        surfacepanel->enableBoundingBox(0, false);
+        surfacepanel->deleteActor(0);
+
+        this->ui->tabWidgetSurface->removeTab(index);
+    }
+}
+
diff --git a/lib/GUI/Qt/SurfaceRenderer/qtsurfacerenderer.h b/lib/GUI/Qt/SurfaceRenderer/qtsurfacerenderer.h
new file mode 100644 (file)
index 0000000..6ffe36e
--- /dev/null
@@ -0,0 +1,37 @@
+#ifndef QTSURFACERENDERER_H
+#define QTSURFACERENDERER_H
+
+#include <QWidget>
+#include "wxMaracasSurfaceRenderingManager.h"
+
+namespace Ui {
+    class QtSurfaceRenderer;
+}
+
+class QtSurfaceRenderer : public QWidget,public vtkObject
+{
+    Q_OBJECT
+
+public:
+    explicit QtSurfaceRenderer(QWidget *parent = 0);
+
+    ~QtSurfaceRenderer();
+
+    vtkSetMacro(Renderer, vtkRenderer*);
+    vtkSetMacro(Interactor, vtkRenderWindowInteractor*);
+
+    void SetImageData(vtkImageData* img);
+private slots:
+    void on_pushbuttonAddTab_clicked();
+
+    void on_tabWidgetSurface_tabCloseRequested(int index);
+
+
+private:
+    Ui::QtSurfaceRenderer *ui;
+
+    vtkRenderer* Renderer;
+    vtkRenderWindowInteractor* Interactor;
+};
+
+#endif // QTSURFACERENDERER_H
diff --git a/lib/GUI/Qt/SurfaceRenderer/qtsurfacerenderer.ui b/lib/GUI/Qt/SurfaceRenderer/qtsurfacerenderer.ui
new file mode 100644 (file)
index 0000000..a9af6d4
--- /dev/null
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>QtSurfaceRenderer</class>
+ <widget class="QWidget" name="QtSurfaceRenderer">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>266</width>
+    <height>454</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Form</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <item>
+    <widget class="QPushButton" name="pushbuttonAddTab">
+     <property name="text">
+      <string>+</string>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <widget class="QTabWidget" name="tabWidgetSurface">
+     <property name="currentIndex">
+      <number>0</number>
+     </property>
+     <property name="elideMode">
+      <enum>Qt::ElideNone</enum>
+     </property>
+     <property name="tabsClosable">
+      <bool>true</bool>
+     </property>
+     <widget class="QWidget" name="tab">
+      <attribute name="title">
+       <string>SN</string>
+      </attribute>
+      <zorder>pushbuttonAddTab</zorder>
+     </widget>
+     <widget class="QWidget" name="tab_2">
+      <attribute name="title">
+       <string>SN2</string>
+      </attribute>
+     </widget>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
index 8a190bdde955f9d60b8f02d885bcc498f1889000..b675aa60a52ecda699b47c195e6f0cbc8faf6437 100644 (file)
@@ -8,6 +8,7 @@
 
 #include "Color.xpm"
 #include "Save.xpm"
+#include "OpenImage.xpm"
 
 QtSurfaceRendererPanel::QtSurfaceRendererPanel(QWidget *parent) :
     QWidget(parent),
@@ -18,21 +19,21 @@ QtSurfaceRendererPanel::QtSurfaceRendererPanel(QWidget *parent) :
 
     this->ui->pushButtonColorChooser->setIcon(QIcon(Color_xpm));
     this->ui->pushButtonSave->setIcon(QIcon(Save_xpm));
+    this->ui->pushButtonOpen->setIcon(QIcon(OpenImage_xpm));
 }
 
 QtSurfaceRendererPanel::~QtSurfaceRendererPanel()
-{
+{   
     delete ui;
 }
-void QtSurfaceRendererPanel::SetImageData(vtkImageData* img){
-    this->addPropMHD(0, img, "");
-    this->enableBoundingBox(0, false);
-
+void QtSurfaceRendererPanel::setImageData(vtkImageData* img){
     double *range  =img->GetScalarRange();
 
-    this->ui->horizontalSliderMinIso->setRange(range[0], range[1] - 1);
+    this->ui->horizontalSliderMinIso->setRange(range[0], range[1]);
 
-    this->ui->horizontalSliderMaxIso->setRange(range[0] + 1, range[1]);
+    this->ui->horizontalSliderMaxIso->setRange(range[0], range[1]);
+
+    wxMaracasSurfaceRenderingManager::setImageData(img);
 }
 
 void QtSurfaceRendererPanel::on_OpacitySlider_valueChanged(int value)
@@ -77,6 +78,10 @@ void QtSurfaceRendererPanel::on_pushButtonColorChooser_clicked()
 void QtSurfaceRendererPanel::on_checkBox_clicked(bool checked)
 {
     this->addRemoveActor(0, checked);
+    if(!checked){
+        this->ui->checkBoxBoundingBox->setCheckState(Qt::Unchecked);
+        this->on_checkBoxBoundingBox_clicked(false);
+    }
 }
 
 void QtSurfaceRendererPanel::on_horizontalSliderMaxIso_valueChanged(int value)
@@ -107,12 +112,12 @@ void QtSurfaceRendererPanel::onIsoValueChanged(){
 void QtSurfaceRendererPanel::on_pushButtonSave_clicked()
 {
     QString filename = QFileDialog::getSaveFileName(this,
-                                                    tr("Save STL File"),
+                                                    tr("Save Mesh File"),
                                                     QDir::currentPath(),
-                                                    tr("STL files (*.stl);") );
+                                                    tr("Mesh files (*.stl *.ply)") );
 
     if( !filename.isNull() ){
-        filename.append(".stl");
+        //filename.append(".stl");
         this->saveProp3DSTL(0, filename.toStdString().c_str());
     }
 
@@ -123,3 +128,17 @@ void QtSurfaceRendererPanel::on_checkBoxBoundingBox_clicked(bool checked)
     this->enableBoundingBox(0, checked);
 
 }
+
+void QtSurfaceRendererPanel::on_pushButtonOpen_clicked(bool checked)
+{
+
+}
+
+void QtSurfaceRendererPanel::on_pushButtonOpen_clicked()
+{
+    QString filename = QFileDialog::getOpenFileName(this, tr("Load Mesh File"), QDir::currentPath(),  tr("Mesh files (*.stl *.ply)"));
+
+    if(!filename.isNull()){
+        this->loadProp3DSTL(filename.toStdString().c_str());
+    }
+}
index 3810f56ccd6039950c5b8f7e03ec9b123a33c9dc..d583d1103c53048b7ec31beacb67bab9f6bb601b 100644 (file)
@@ -18,8 +18,7 @@ public:
     explicit QtSurfaceRendererPanel(QWidget *parent = 0);
     ~QtSurfaceRendererPanel();
 
-    void SetImageData(vtkImageData* img);
-
+    virtual void setImageData(vtkImageData* img);
 private slots:    
 
     void on_OpacitySlider_valueChanged(int value);
@@ -40,6 +39,11 @@ private slots:
 
     void on_checkBoxBoundingBox_clicked(bool checked);
 
+    void on_pushButtonOpen_clicked(bool checked);
+
+    void on_pushButtonOpen_clicked();
+
+
 private:
     Ui::QtSurfaceRendererPanel *ui;
 
index 3d9550b542e07b773eee7bd823f75cd18200caed..2af643ba709b5199f204e428e105c4d5d968dc01 100644 (file)
@@ -6,7 +6,7 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>145</width>
+    <width>197</width>
     <height>299</height>
    </rect>
   </property>
@@ -21,7 +21,7 @@
      </property>
     </widget>
    </item>
-   <item row="0" column="1">
+   <item row="0" column="2">
     <widget class="QCheckBox" name="checkBoxBoundingBox">
      <property name="enabled">
       <bool>false</bool>
      </property>
     </widget>
    </item>
-   <item row="2" column="0" colspan="2">
+   <item row="1" column="2">
+    <widget class="QPushButton" name="pushButtonOpen">
+     <property name="text">
+      <string/>
+     </property>
+     <property name="icon">
+      <iconset>
+       <normaloff>../../../../data/Icons/OpenImage.xpm</normaloff>../../../../data/Icons/OpenImage.xpm</iconset>
+     </property>
+    </widget>
+   </item>
+   <item row="2" column="0" colspan="3">
     <widget class="Line" name="line">
      <property name="orientation">
       <enum>Qt::Horizontal</enum>
      </property>
     </widget>
    </item>
-   <item row="3" column="0" colspan="2">
+   <item row="3" column="0" colspan="3">
     <layout class="QGridLayout" name="gridLayout_2">
      <item row="0" column="0">
       <widget class="QLabel" name="LabelOpacity">
      </item>
     </layout>
    </item>
-   <item row="4" column="0" colspan="2">
+   <item row="4" column="0" colspan="3">
     <widget class="Line" name="line_2">
      <property name="orientation">
       <enum>Qt::Horizontal</enum>
      </property>
     </widget>
    </item>
-   <item row="5" column="0" colspan="2">
+   <item row="5" column="0" colspan="3">
     <layout class="QGridLayout" name="gridLayout">
      <item row="0" column="0" colspan="2">
       <widget class="QLabel" name="labelIsoValue">
index a72202cb79c0b6b578c982c974cd597a1d2f57be..e32e3388ff9d1cf2695ed184f4135d759c6eae1b 100644 (file)
@@ -106,7 +106,6 @@ IF ( BUILD_${LIBRARY_NAME} )
   # USER! : The default is to create a Dynamic Library.
   # if you need to create a static library
   # comment out the following line :
-
   SET(${LIBRARY_NAME}_INSTALL_TREE_RELATIVE_INCLUDE_PATHS include/creaMaracasVisu)
   SET(${LIBRARY_NAME}_INSTALL_FOLDER creaMaracasVisu)
   CREA_ADD_LIBRARY( ${LIBRARY_NAME} )
index 8a67db4eacb04e980cd9e74079027c1b0f8c2300..d4c0685c25f922ab1d882a13a0953e371a671a64 100644 (file)
@@ -1,12 +1,14 @@
 #include "qtvtkviewer.h"
 
+#include "vtkImageMapToColors.h"
+
 QtVTKViewer::QtVTKViewer(QWidget* parent)
     : QVTKWidget(parent)
 {
 
 
     this->GetRenderWindow()->AddRenderer(vtkRenderer::New());
-    this->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->SetBackground(0,0,0);
+    this->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->SetBackground(1,1,1);
 
     SuperImagePlaneWidget::initialize(this->GetRenderWindow()->GetInteractor());
 
@@ -71,3 +73,9 @@ void QtVTKViewer::mousePressEvent(QMouseEvent* event){
 #endif
     }
 }
+
+void QtVTKViewer::SetOutputFormatToRGBA(){
+    _xwidget->GetColorMap()->SetOutputFormatToRGBA();
+    _ywidget->GetColorMap()->SetOutputFormatToRGBA();
+    _zwidget->GetColorMap()->SetOutputFormatToRGBA();
+}
index 15b8a760b51b707a950ae61617a9ea0fa63b3262..a72b4c5e6f84d83f8c944c550b7e187f333a21bb 100644 (file)
@@ -17,6 +17,7 @@ public:
 
     typedef ImagePlaneWidget SuperImagePlaneWidget;
 
+    void SetOutputFormatToRGBA();
 private:
 
     void invariant();
@@ -31,7 +32,7 @@ private:
     *       finding an object in the scene
     *
     */
-    double _rayorigin[4];    
+    double _rayorigin[4];        
 
 protected:
     // overloaded mouse press handler
index 8f586fe8ab097ef78eceb0db0c552717684b232f..7229daa1dac9ceb50c47be70ca5cb7542ce7443c 100644 (file)
@@ -4,14 +4,17 @@
 
 
 QtVTKViewerWidget::QtVTKViewerWidget(QWidget *parent) :
-    QWidget(parent)
+    QWidget(parent),
+    ui(new Ui::QtVTKViewerWidget)
 {
-    setupUi(this);
+    ui->setupUi(this);
+
+    ui->m_VolumeRender->SetRenderer(this->getRenderer());
+    ui->m_VolumeRender->SetInteractor(ui->_qtvtkviewer->GetRenderWindow()->GetInteractor());
+
+    ui->m_SurfaceRender->SetRenderer(this->getRenderer());
+    ui->m_SurfaceRender->SetInteractor(ui->_qtvtkviewer->GetRenderWindow()->GetInteractor());
 
-    this->m_VolumeRender->SetRenderer(this->getRenderer());
-    this->m_VolumeRender->SetInteractor(this->_qtvtkviewer->GetRenderWindow()->GetInteractor());
-    this->m_SurfaceRender->setRenderer(this->getRenderer());
-    this->m_SurfaceRender->setInteractor(this->_qtvtkviewer->GetRenderWindow()->GetInteractor());
 }
 
 QtVTKViewerWidget::~QtVTKViewerWidget()
@@ -20,21 +23,63 @@ QtVTKViewerWidget::~QtVTKViewerWidget()
 }
 
 vtkRenderer* QtVTKViewerWidget::getRenderer(){
-    return this->_qtvtkviewer->GetRenderWindow()->GetRenderers()->GetFirstRenderer();
+    return ui->_qtvtkviewer->GetRenderWindow()->GetRenderers()->GetFirstRenderer();
 }
 
 void QtVTKViewerWidget::setImage(vtkImageData* img){
-    this->_qtvtkviewer->setImage(img);
-    this->m_VolumeRender->SetImageData(img);
-    this->m_SurfaceRender->SetImageData(img);
+
+
+    ui->_qtvtkviewer->setImage(img);
+    ui->m_VolumeRender->SetImageData(img);
+    ui->m_SurfaceRender->SetImageData(img);
+
+    int *extent = img->GetExtent();
+
+
+    ui->horizontalSliderX->setRange(extent[0], extent[1]);
+    ui->horizontalSliderY->setRange(extent[2], extent[3]);
+    ui->horizontalSliderZ->setRange(extent[4], extent[5]);
+
 }
 
 void QtVTKViewerWidget::SetLookupTable(vtkLookupTable *lookuptable){
-    this->_qtvtkviewer->SetLookupTable(lookuptable);
-    this->m_VolumeRender->SetLookUpTable(lookuptable);
+
+    ui->_qtvtkviewer->SetLookupTable(lookuptable);
+    ui->m_VolumeRender->SetLookUpTable(lookuptable);
 }
 
 void QtVTKViewerWidget::on_checkBoxShowPlanes_clicked(){
 
-    this->_qtvtkviewer->showPlanes(checkBoxShowPlanes->isChecked());
+    ui->_qtvtkviewer->showPlanes(ui->checkBoxShowPlanes->isChecked());
+}
+
+void QtVTKViewerWidget::SetOutputFormatToRGBA(){
+    ui->_qtvtkviewer->SetOutputFormatToRGBA();
+}
+
+void QtVTKViewerWidget::on_checkBoxShowImageActor_clicked(bool checked)
+{
+    if(!(ui->_qtvtkviewer->showImageActors(checked))){
+        ui->checkBoxShowImageActor->setCheckState(Qt::Unchecked);
+    }
+}
+
+void QtVTKViewerWidget::on_horizontalSliderX_valueChanged(int value)
+{
+
+    ui->lineEditX->setText(QString::number(value));
+    ui->_qtvtkviewer->setSliceXImageActor(value);
+
+}
+
+void QtVTKViewerWidget::on_horizontalSliderY_valueChanged(int value)
+{
+    ui->lineEditY->setText(QString::number(value));
+    ui->_qtvtkviewer->setSliceYImageActor(value);
+}
+
+void QtVTKViewerWidget::on_horizontalSliderZ_valueChanged(int value)
+{
+    ui->lineEditZ->setText(QString::number(value));
+    ui->_qtvtkviewer->setSliceZImageActor(value);
 }
index 70be6143cfd809017df1867bf4752c5e0549906f..7f946210daff80b52cbb50e79c9b59680f3b0075 100644 (file)
@@ -14,7 +14,7 @@ namespace Ui {
     class QtVTKViewerWidget;
 }
 
-class QtVTKViewerWidget : public QWidget, Ui_QtVTKViewerWidget
+class QtVTKViewerWidget : public QWidget
 {
     Q_OBJECT
 
@@ -28,9 +28,23 @@ public:
 
     void SetLookupTable(vtkLookupTable *lookuptable);    
 
+    void SetOutputFormatToRGBA();
+
 private slots:
     void on_checkBoxShowPlanes_clicked();
 
+    void on_checkBoxShowImageActor_clicked(bool checked);
+
+    void on_horizontalSliderX_valueChanged(int value);
+
+    void on_horizontalSliderY_valueChanged(int value);
+
+    void on_horizontalSliderZ_valueChanged(int value);
+
+private:
+    Ui::QtVTKViewerWidget *ui;
+    bool _firstset;
+
 };
 
 #endif // QTVTKVIEWERWIDGET_H
index 553d4b9a97dfb497f987b2b301b0b00cb00456b6..d7d8ae42207ed5964bbfb52deb96c05a9ee22f3c 100644 (file)
       </sizepolicy>
      </property>
      <property name="currentIndex">
-      <number>2</number>
+      <number>0</number>
      </property>
      <widget class="QWidget" name="page">
       <property name="geometry">
        <rect>
         <x>0</x>
         <y>0</y>
-        <width>98</width>
-        <height>28</height>
+        <width>155</width>
+        <height>505</height>
        </rect>
       </property>
       <attribute name="label">
        <string>Image Widget</string>
       </attribute>
-      <widget class="QCheckBox" name="checkBoxShowPlanes">
-       <property name="enabled">
-        <bool>true</bool>
-       </property>
+      <widget class="QWidget" name="">
        <property name="geometry">
         <rect>
-         <x>10</x>
+         <x>0</x>
          <y>20</y>
-         <width>111</width>
-         <height>22</height>
+         <width>201</width>
+         <height>246</height>
         </rect>
        </property>
-       <property name="text">
-        <string>Show Planes</string>
-       </property>
-       <property name="checked">
-        <bool>true</bool>
-       </property>
-       <property name="tristate">
-        <bool>false</bool>
-       </property>
+       <layout class="QVBoxLayout" name="verticalLayout">
+        <item>
+         <widget class="QCheckBox" name="checkBoxShowPlanes">
+          <property name="enabled">
+           <bool>true</bool>
+          </property>
+          <property name="text">
+           <string>Show Planes</string>
+          </property>
+          <property name="checked">
+           <bool>true</bool>
+          </property>
+          <property name="tristate">
+           <bool>false</bool>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <layout class="QFormLayout" name="formLayout">
+          <item row="0" column="0" colspan="2">
+           <widget class="QCheckBox" name="checkBoxShowImageActor">
+            <property name="text">
+             <string>Show Image Actor</string>
+            </property>
+           </widget>
+          </item>
+          <item row="1" column="0">
+           <spacer name="horizontalSpacer_4">
+            <property name="orientation">
+             <enum>Qt::Horizontal</enum>
+            </property>
+            <property name="sizeHint" stdset="0">
+             <size>
+              <width>18</width>
+              <height>20</height>
+             </size>
+            </property>
+           </spacer>
+          </item>
+          <item row="1" column="1">
+           <layout class="QGridLayout" name="gridLayout">
+            <item row="0" column="0">
+             <widget class="QLabel" name="labelx">
+              <property name="text">
+               <string>X  slice =</string>
+              </property>
+             </widget>
+            </item>
+            <item row="0" column="1">
+             <spacer name="horizontalSpacer">
+              <property name="orientation">
+               <enum>Qt::Horizontal</enum>
+              </property>
+              <property name="sizeHint" stdset="0">
+               <size>
+                <width>40</width>
+                <height>20</height>
+               </size>
+              </property>
+             </spacer>
+            </item>
+            <item row="0" column="2">
+             <widget class="QLineEdit" name="lineEditX"/>
+            </item>
+            <item row="1" column="0" colspan="3">
+             <widget class="QSlider" name="horizontalSliderX">
+              <property name="orientation">
+               <enum>Qt::Horizontal</enum>
+              </property>
+             </widget>
+            </item>
+            <item row="2" column="0">
+             <widget class="QLabel" name="label">
+              <property name="text">
+               <string>Y slice =</string>
+              </property>
+             </widget>
+            </item>
+            <item row="2" column="1">
+             <spacer name="horizontalSpacer_2">
+              <property name="orientation">
+               <enum>Qt::Horizontal</enum>
+              </property>
+              <property name="sizeHint" stdset="0">
+               <size>
+                <width>40</width>
+                <height>20</height>
+               </size>
+              </property>
+             </spacer>
+            </item>
+            <item row="2" column="2">
+             <widget class="QLineEdit" name="lineEditY"/>
+            </item>
+            <item row="3" column="0" colspan="3">
+             <widget class="QSlider" name="horizontalSliderY">
+              <property name="orientation">
+               <enum>Qt::Horizontal</enum>
+              </property>
+             </widget>
+            </item>
+            <item row="4" column="0">
+             <widget class="QLabel" name="label_2">
+              <property name="text">
+               <string>Z  slice =</string>
+              </property>
+             </widget>
+            </item>
+            <item row="4" column="1">
+             <spacer name="horizontalSpacer_3">
+              <property name="orientation">
+               <enum>Qt::Horizontal</enum>
+              </property>
+              <property name="sizeHint" stdset="0">
+               <size>
+                <width>40</width>
+                <height>20</height>
+               </size>
+              </property>
+             </spacer>
+            </item>
+            <item row="4" column="2">
+             <widget class="QLineEdit" name="lineEditZ"/>
+            </item>
+            <item row="5" column="0" colspan="3">
+             <widget class="QSlider" name="horizontalSliderZ">
+              <property name="orientation">
+               <enum>Qt::Horizontal</enum>
+              </property>
+             </widget>
+            </item>
+           </layout>
+          </item>
+         </layout>
+        </item>
+       </layout>
       </widget>
      </widget>
      <widget class="QWidget" name="page_2">
        <rect>
         <x>0</x>
         <y>0</y>
-        <width>98</width>
-        <height>28</height>
+        <width>155</width>
+        <height>505</height>
        </rect>
       </property>
       <attribute name="label">
          <x>0</x>
          <y>0</y>
          <width>181</width>
-         <height>121</height>
+         <height>221</height>
         </rect>
        </property>
        <property name="sizePolicy">
       <attribute name="label">
        <string>Surface Rendering</string>
       </attribute>
-      <widget class="QtSurfaceRendererPanel" name="m_SurfaceRender" native="true">
+      <widget class="QtSurfaceRenderer" name="m_SurfaceRender" native="true">
        <property name="geometry">
         <rect>
          <x>0</x>
          <y>0</y>
-         <width>151</width>
-         <height>271</height>
+         <width>221</width>
+         <height>381</height>
         </rect>
        </property>
       </widget>
        <verstretch>0</verstretch>
       </sizepolicy>
      </property>
+     <zorder>toolBox</zorder>
+     <zorder>toolBox</zorder>
+     <zorder>toolBox</zorder>
     </widget>
    </item>
   </layout>
    <container>1</container>
   </customwidget>
   <customwidget>
-   <class>QtSurfaceRendererPanel</class>
+   <class>QtSurfaceRenderer</class>
    <extends>QWidget</extends>
-   <header location="global">qtsurfacerendererpanel.h</header>
+   <header location="global">qtsurfacerenderer.h</header>
    <container>1</container>
   </customwidget>
  </customwidgets>
  <resources/>
- <connections/>
+ <connections>
+  <connection>
+   <sender>checkBoxShowImageActor</sender>
+   <signal>clicked(bool)</signal>
+   <receiver>horizontalSliderX</receiver>
+   <slot>setEnabled(bool)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>81</x>
+     <y>132</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>81</x>
+     <y>182</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>checkBoxShowImageActor</sender>
+   <signal>clicked(bool)</signal>
+   <receiver>horizontalSliderY</receiver>
+   <slot>setEnabled(bool)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>128</x>
+     <y>122</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>124</x>
+     <y>236</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>checkBoxShowImageActor</sender>
+   <signal>clicked(bool)</signal>
+   <receiver>horizontalSliderZ</receiver>
+   <slot>setEnabled(bool)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>48</x>
+     <y>120</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>87</x>
+     <y>297</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
 </ui>
index f0a431d596f643a63626a2ff271ed5d892e4850f..779621ca178337e664a4aa1c8d7ce2f2c05920e5 100644 (file)
@@ -20,10 +20,14 @@ void QtVolumeRendererPanel::on_checkBoxShowVolume_clicked(bool checked)
 {
     try{
         ShowVolume(checked);
-        on_opacitySlider_valueChanged(this->ui->opacitySlider->value());
+        //JCP 27/09/12
+        //on_opacitySlider_valueChanged(this->ui->opacitySlider->value());
     }catch(char * e){
         cout<<e<<endl;
         QMessageBox::critical(this, tr("Volume Rendering"), tr(e), QMessageBox::Ok);
+    }catch(exception e){
+        cout<<e.what()<<endl;
+        QMessageBox::critical(this, tr("Volume Rendering"), tr(e.what()), QMessageBox::Ok);
     }
 }
 
@@ -35,10 +39,12 @@ void QtVolumeRendererPanel::on_opacitySlider_valueChanged(int value)
 
         double* range = ImageData->GetScalarRange();
         vector<double> greylevel;
-        greylevel.push_back(range[0]);
+        greylevel.push_back(0);        
+        greylevel.push_back(1);
         greylevel.push_back(range[1]);
 
         vector<double> vectvalue;
+        vectvalue.push_back(0);
         vectvalue.push_back(value/100.0);
         vectvalue.push_back(value/100.0);
 
@@ -72,3 +78,24 @@ void QtVolumeRendererPanel::on_radioButtonComposite_clicked(bool checked)
         this->changeCompositeMIPFunction(0);
     }
 }
+
+void QtVolumeRendererPanel::on_radioButtonLinear_clicked(bool checked)
+{
+    if(checked){
+        this->changeInterpolationType(0);
+    }
+}
+
+void QtVolumeRendererPanel::on_radioButtonNearest_clicked(bool checked)
+{
+    if(checked){
+        this->changeInterpolationType(1);
+    }
+}
+
+void QtVolumeRendererPanel::on_radioButtonMinIP_clicked(bool checked)
+{
+    if(checked){
+        this->changeCompositeMIPFunction(2);
+    }
+}
index 22750e7be3a8a180cec0ea23ced628e8c93a98cd..5cd1d1cf7d8ff73c1fa2173852cf1cbce5bcc0ec 100644 (file)
@@ -28,6 +28,12 @@ private slots:
 
     void on_radioButtonComposite_clicked(bool checked);
 
+    void on_radioButtonLinear_clicked(bool checked);
+
+    void on_radioButtonNearest_clicked(bool checked);
+
+    void on_radioButtonMinIP_clicked(bool checked);
+
 private:
     Ui::QtVolumeRendererPanel *ui;
     void invariant();
index de487459c2ff4d8db23052ade23af89b6f96d0f8..9859706040a569d2fcdb49b4c82ae476583f95e4 100644 (file)
@@ -6,15 +6,15 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>186</width>
-    <height>137</height>
+    <width>275</width>
+    <height>213</height>
    </rect>
   </property>
   <property name="windowTitle">
    <string>Form</string>
   </property>
-  <layout class="QVBoxLayout" name="verticalLayout">
-   <item>
+  <layout class="QGridLayout" name="gridLayout_4">
+   <item row="0" column="0">
     <layout class="QHBoxLayout" name="horizontalLayout">
      <item>
       <widget class="QCheckBox" name="checkBoxShowVolume">
      </item>
     </layout>
    </item>
-   <item>
-    <layout class="QHBoxLayout" name="horizontalLayout_2">
-     <item>
+   <item row="1" column="0">
+    <layout class="QGridLayout" name="gridLayout_3">
+     <item row="0" column="0" colspan="2">
+      <widget class="QLabel" name="label_3">
+       <property name="text">
+        <string>Ray Cast Function</string>
+       </property>
+      </widget>
+     </item>
+     <item row="1" column="0">
       <widget class="QRadioButton" name="radioButtonComposite">
+       <property name="toolTip">
+        <string>Change the Ray Cast Function To Composite (All)</string>
+       </property>
        <property name="text">
         <string>Composite</string>
        </property>
        <property name="checked">
         <bool>true</bool>
        </property>
+       <property name="autoExclusive">
+        <bool>true</bool>
+       </property>
        <attribute name="buttonGroup">
         <string>buttonGroup</string>
        </attribute>
       </widget>
      </item>
-     <item>
+     <item row="1" column="1">
       <widget class="QRadioButton" name="radioButtonMIP">
+       <property name="toolTip">
+        <string>Change the Ray Cast Function To Maximum Intensity Pixel</string>
+       </property>
        <property name="text">
-        <string>MIP </string>
+        <string>MaxIP </string>
        </property>
        <property name="checked">
         <bool>false</bool>
        </property>
+       <property name="autoExclusive">
+        <bool>true</bool>
+       </property>
        <attribute name="buttonGroup">
         <string>buttonGroup</string>
        </attribute>
       </widget>
      </item>
+     <item row="1" column="2">
+      <widget class="QRadioButton" name="radioButtonMinIP">
+       <property name="toolTip">
+        <string>Change the Ray Cast Function To Minimum Intensity Pixel</string>
+       </property>
+       <property name="text">
+        <string>MinIP</string>
+       </property>
+       <property name="autoExclusive">
+        <bool>true</bool>
+       </property>
+       <attribute name="buttonGroup">
+        <string>buttonGroup</string>
+       </attribute>
+      </widget>
+     </item>
+    </layout>
+   </item>
+   <item row="2" column="0">
+    <layout class="QGridLayout" name="gridLayout_2">
+     <item row="0" column="0">
+      <widget class="QLabel" name="label_2">
+       <property name="text">
+        <string>Interpolation</string>
+       </property>
+      </widget>
+     </item>
+     <item row="1" column="0">
+      <widget class="QRadioButton" name="radioButtonLinear">
+       <property name="text">
+        <string>Linear</string>
+       </property>
+       <property name="checked">
+        <bool>true</bool>
+       </property>
+       <attribute name="buttonGroup">
+        <string>buttonGroup_2</string>
+       </attribute>
+      </widget>
+     </item>
+     <item row="1" column="1">
+      <widget class="QRadioButton" name="radioButtonNearest">
+       <property name="text">
+        <string>Nearest</string>
+       </property>
+       <attribute name="buttonGroup">
+        <string>buttonGroup_2</string>
+       </attribute>
+      </widget>
+     </item>
     </layout>
    </item>
-   <item>
+   <item row="3" column="0">
     <layout class="QGridLayout" name="gridLayout">
      <item row="0" column="0">
       <widget class="QLabel" name="label">
    <slot>setEnabled(bool)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>57</x>
-     <y>21</y>
+     <x>134</x>
+     <y>93</y>
     </hint>
     <hint type="destinationlabel">
-     <x>110</x>
-     <y>25</y>
+     <x>524</x>
+     <y>93</y>
     </hint>
    </hints>
   </connection>
    <slot>setEnabled(bool)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>61</x>
-     <y>30</y>
+     <x>134</x>
+     <y>93</y>
     </hint>
     <hint type="destinationlabel">
-     <x>57</x>
-     <y>126</y>
+     <x>77</x>
+     <y>626</y>
     </hint>
    </hints>
   </connection>
   <connection>
    <sender>checkBoxShowVolume</sender>
    <signal>toggled(bool)</signal>
-   <receiver>radioButtonComposite</receiver>
+   <receiver>radioButtonLinear</receiver>
    <slot>setEnabled(bool)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>41</x>
-     <y>23</y>
+     <x>134</x>
+     <y>93</y>
     </hint>
     <hint type="destinationlabel">
-     <x>36</x>
-     <y>54</y>
+     <x>29</x>
+     <y>495</y>
     </hint>
    </hints>
   </connection>
   <connection>
    <sender>checkBoxShowVolume</sender>
    <signal>toggled(bool)</signal>
-   <receiver>radioButtonMIP</receiver>
+   <receiver>radioButtonNearest</receiver>
    <slot>setEnabled(bool)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>69</x>
-     <y>16</y>
+     <x>134</x>
+     <y>93</y>
     </hint>
     <hint type="destinationlabel">
-     <x>143</x>
-     <y>46</y>
+     <x>532</x>
+     <y>495</y>
     </hint>
    </hints>
   </connection>
  </connections>
  <buttongroups>
+  <buttongroup name="buttonGroup_2"/>
   <buttongroup name="buttonGroup">
    <property name="exclusive">
     <bool>true</bool>
index b302cac4e54b44f58b07cf377c117eebfe5e1dc5..510ec5c53b3ddb681a14a2664e0f5c8c8304205d 100644 (file)
@@ -3,6 +3,7 @@
 
 #include <vtkSmartPointer.h>
 #include "vtkSTLWriter.h"
+#include "vtkPLYWriter.h"
 
 /********************************************************************************************
 ** Start of data viewmanagerData
@@ -114,12 +115,25 @@ void wxMaracasSurfaceRenderingManagerData::setDataname(std::string dataname){
 
 void wxMaracasSurfaceRenderingManagerData::saveProp3DSTL(const char* filename){
     if(_dataMapper){
-        vtkSmartPointer<vtkSTLWriter> stlWriter =
-        vtkSmartPointer<vtkSTLWriter>::New();
-          stlWriter->SetFileName(filename);
-          stlWriter->SetInput(_dataMapper->GetInput());
-          stlWriter->SetFileTypeToBinary();
-          stlWriter->Write();
+
+        std::string filena(filename);
+        std::string ext = filena.substr(filena.find_last_of("."), 4);
+        if(ext.compare(PLY) == 0){
+            vtkSmartPointer<vtkPLYWriter> plywriter =
+            vtkSmartPointer<vtkPLYWriter>::New();
+              plywriter->SetFileName(filename);
+              plywriter->SetInput(_dataMapper->GetInput());
+              plywriter->Write();
+        }else if(ext.compare(PLY) == 0){
+            vtkSmartPointer<vtkSTLWriter> stlWriter =
+            vtkSmartPointer<vtkSTLWriter>::New();
+              stlWriter->SetFileName(filename);
+              stlWriter->SetInput(_dataMapper->GetInput());
+              stlWriter->SetFileTypeToBinary();
+              stlWriter->Write();
+        }else{
+            cout<<"unsupported format"<<endl;
+        }
     }
 }
 
index 11b0a0fc53fb7deb75210f337eeb9588831fdf9a..150524566adcf1e455be19790ee139d5b22bfe58 100644 (file)
@@ -10,6 +10,9 @@
 #include "vtkBoxWidget.h"
 
 
+#define PLY  ".ply"
+#define STL  ".stl"
+
 
 class wxMaracasSurfaceRenderingManagerData {
 
index 2b55cdaabe29fd3f2443a975505fe38f4f754018..3deb86ef088541c86dd48093bcd77fbbdacbe309 100644 (file)
@@ -67,7 +67,7 @@ wxMaracasSurfaceRenderingManagerDataMhd::wxMaracasSurfaceRenderingManagerDataMhd
 
 
             _boxWidgetS1->HandlesOn ();
-            _boxWidgetS1->EnabledOn();
+            _boxWidgetS1->EnabledOff();
        }else{          
                _dataMapper->SetInput(_cleanFilter->GetOutput());                               
        }
@@ -91,6 +91,8 @@ void wxMaracasSurfaceRenderingManagerDataMhd::enableBoxWidget(bool enable){
         }else{
             _boxWidgetS1->EnabledOff();
         }
+    }else{
+        cout<<"box widget not initialized!"<<endl;
     }
 }
 
index 4e81652ff7f21402b8702a03c4864e9d62917965..3d53fb596edf48341132f34b4ca7ff5b359c4bef 100644 (file)
@@ -1,14 +1,27 @@
 #include "imageplanewidget.h"
 
+#include "vtkSmartPointer.h"
+#include "vector"
+#include "vtkImageActor.h"
+#include "vtkImageAppendComponents.h"
+#include "vtkRenderWindowInteractor.h"
+
+using namespace std;
+
 ImagePlaneWidget::ImagePlaneWidget()
 {
     _img = 0;
     _xwidget = 0;
     _ywidget = 0;
     _zwidget = 0;
+    m_Interactor = 0;
+    _imageactorx = 0;
+    _imageactory = 0;
+    _imageactorz = 0;
 }
 
 void ImagePlaneWidget::initialize(vtkRenderWindowInteractor* interactor){
+    m_Interactor = interactor;
     // Plane widget
     _xwidget = vtkImagePlaneWidget::New( );
     _ywidget = vtkImagePlaneWidget::New( );
@@ -18,8 +31,49 @@ void ImagePlaneWidget::initialize(vtkRenderWindowInteractor* interactor){
     _xwidget->SetInteractor( interactor );
     _ywidget->SetInteractor( interactor );
     _zwidget->SetInteractor( interactor );
+
 }
+bool ImagePlaneWidget::showImageActors(bool show){
+    if(show && m_Interactor){
+        if(!_imageactorx){
+            initializeImageActors();
+        }
+        m_Interactor->GetRenderWindow ()->GetRenderers ()->GetFirstRenderer ()->AddViewProp(_imageactorx);
+        m_Interactor->GetRenderWindow ()->GetRenderers ()->GetFirstRenderer ()->AddViewProp(_imageactory);
+        m_Interactor->GetRenderWindow ()->GetRenderers ()->GetFirstRenderer ()->AddViewProp(_imageactorz);
+        return true;
+    }else if(_imageactorx){
+        m_Interactor->GetRenderWindow ()->GetRenderers ()->GetFirstRenderer ()->RemoveViewProp(_imageactorx);
+        m_Interactor->GetRenderWindow ()->GetRenderers ()->GetFirstRenderer ()->RemoveViewProp(_imageactory);
+        m_Interactor->GetRenderWindow ()->GetRenderers ()->GetFirstRenderer ()->RemoveViewProp(_imageactorz);
+        return true;
+    }
+
+    return false;
+}
+
+void ImagePlaneWidget::initializeImageActors(){
+
+    int *w_ext = _img->GetWholeExtent();
+    //cout<<w_ext[0]<<" "<<w_ext[1]<<" "<<w_ext[2]<<" "<<w_ext[3]<<" "<<w_ext[4]<<" "<<w_ext[5]<<" "<<endl;
+    _imageactorx = vtkImageActor::New();
+    _imageactorx->SetInput(_img);
+    xslice =  (w_ext[4] + w_ext[5])/2;
+    _imageactorx->SetDisplayExtent(w_ext[0], w_ext[1], w_ext[2], w_ext[3], xslice, xslice);
+
 
+    _imageactory = vtkImageActor::New();
+    _imageactory->SetInput(_img);
+    yslice =  (w_ext[2] + w_ext[3])/2;
+    _imageactory->SetDisplayExtent(w_ext[0], w_ext[1], yslice, yslice, w_ext[4], w_ext[5]);
+
+    _imageactorz = vtkImageActor::New();
+    _imageactorz->SetInput(_img);
+    zslice =  (w_ext[0] + w_ext[1])/2;
+    _imageactorz->SetDisplayExtent(zslice, zslice, w_ext[2], w_ext[3], w_ext[4], w_ext[5]);
+
+
+}
 
 void ImagePlaneWidget::setImage(vtkImageData* img){
     _img = img;
@@ -93,3 +147,23 @@ void ImagePlaneWidget::invariant(){
         throw "The widgets are not initialized";
     }
 }
+
+
+void ImagePlaneWidget::setSliceXImageActor(int value){
+    int *w_ext = _img->GetWholeExtent();
+    xslice = value;
+    _imageactorx->SetDisplayExtent(w_ext[0], w_ext[1], w_ext[2], w_ext[3], xslice, xslice);
+    m_Interactor->Render();
+}
+void ImagePlaneWidget::setSliceYImageActor(int value){
+    int *w_ext = _img->GetWholeExtent();
+    yslice = value;
+    _imageactory->SetDisplayExtent(w_ext[0], w_ext[1], yslice, yslice, w_ext[4], w_ext[5]);
+    m_Interactor->Render();
+}
+void ImagePlaneWidget::setSliceZImageActor(int value){
+    int *w_ext = _img->GetWholeExtent();
+    zslice = value;
+    _imageactorz->SetDisplayExtent(zslice, zslice, w_ext[2], w_ext[3], w_ext[4], w_ext[5]);
+    m_Interactor->Render();
+}
index 1dae6bd4ebf825f3707b5aabf73f86fe873243f8..60678be39e1729cb28a5175c966e4c59d9a94f04 100644 (file)
@@ -7,6 +7,8 @@
 #include "vtkImagePlaneWidget.h"
 #include "vtkImageData.h"
 #include "vtkColorTransferFunction.h"
+#include "vtkImageViewer2.h"
+#include "vtkSmartPointer.h"
 
 class ImagePlaneWidget
 {
@@ -19,17 +21,36 @@ public:
 
     virtual void SetColorTable(vtkColorTransferFunction *lookuptable);
 
-    virtual void showPlanes(bool show);
+    virtual void showPlanes(bool show);    
 
-    void initialize(vtkRenderWindowInteractor* interactor);
+    virtual bool showImageActors(bool show);
+
+    void setSliceXImageActor(int value);
+    void setSliceYImageActor(int value);
+    void setSliceZImageActor(int value);
 protected:
 
     vtkImageData* _img;
     vtkImagePlaneWidget* _xwidget;
     vtkImagePlaneWidget* _ywidget;
     vtkImagePlaneWidget* _zwidget;
+    vtkImageActor * _imageactorx;
+    vtkImageActor* _imageactory;
+    vtkImageActor* _imageactorz;
+
+    int xslice;
+    int yslice;
+    int zslice;
+
+    void initialize(vtkRenderWindowInteractor* interactor);
+
+    void initializeImageActors();
+
 private:
     void invariant();
+
+    vtkRenderWindowInteractor* m_Interactor;
+
 };
 
 #endif // IMAGEPLANEWIDGET_H
index dcc3c114392e0c4747ce5bab554d6ee3c01c3580..66895417b249be748dcbd31df6cba15fa7ca028d 100644 (file)
@@ -5,8 +5,8 @@
   Program:   wxMaracas
   Module:    $RCSfile: volumerenderermanager.cxx,v $
   Language:  C++
-  Date:      $Date: 2011/05/31 19:03:03 $
-  Version:   $Revision: 1.1 $
+  Date:      $Date: 2011/10/05 16:27:04 $
+  Version:   $Revision: 1.2 $
 
   Copyright: (c) 2002, 2003
   License:
 
 #include <vtkMetaImageReader.h>
 #include <vtkImageCast.h>
+
+#include "vtkImageLuminance.h"
+#include "vtkImageAppendComponents.h"
+#include "vtkSmartPointer.h"
+
+#include <map>
+
+using namespace std;
+
 /**
 **     Start of the manager class
 **/
@@ -27,6 +36,13 @@ VolumeRendererManager::VolumeRendererManager(){
         _idCount=0;
 }
 VolumeRendererManager::~VolumeRendererManager(){
+    _renderer = 0;
+    _idCount=0;
+    image = 0;
+    for(unsigned i = 0; i < prop3Dvect.size();i++){
+        prop3Dvect[i]->Delete();
+    }
+    prop3Dvect.clear();
 }
 
 /**
@@ -52,6 +68,261 @@ void VolumeRendererManager::Update(int ppid){
         _renderer->Render();
 }
 
+/**
+* @pre   The image can have one or multiple components per voxel, and volume rendering is performed seprately over the
+         three of them. If the image has multiple components and the separate components flag is set to false, then
+         the vtkImageAppendComponents is used to create a single image.
+* @post  The volume rendering is performed over the image vol
+* @param vtkImageData* the image volume
+* @param bool separatecomponents, if the image has multiple components, then a mapper is used for each of the channels
+              if this flag is set to false and the volume has multiple components, vtkImageAppendComponents is used to create
+              a single representation of the image.
+*/
+int VolumeRendererManager::addVolume(vtkImageData* img, vtkRenderWindowInteractor* interactor, bool independentcomponents){
+    if(img->GetNumberOfScalarComponents() > 1 && !independentcomponents){
+
+
+        image = img;
+
+
+        vtkSmartPointer< vtkImageLuminance > luminance = vtkSmartPointer< vtkImageLuminance >::New();
+        luminance->SetInput(img);
+        luminance->Update();
+
+        vtkSmartPointer< vtkImageAppendComponents > append = vtkSmartPointer< vtkImageAppendComponents >::New();
+        append->SetInput(0, img);
+        append->SetInput(1, luminance->GetOutput());
+        append->Update();
+
+
+
+        VolumeRendererManagerData* data = new VolumeRendererManagerData(append->GetOutput(), true);
+        data->SetIndependentComponents(independentcomponents);
+
+
+        prop3Dvect.push_back(data);
+
+        data->setId(_idCount);
+        _idCount++;
+
+        return _idCount-1;
+
+
+        /*image = img;
+
+        vector< vtkImageData* > vectimg;
+        GetImages(img, vectimg);
+        vtkBoxWidget* boxw = 0;
+        for(unsigned i = 0; i < vectimg.size(); i++){
+            VolumeRendererManagerData* data = new VolumeRendererManagerData(vectimg[i], "");
+
+            vtkColorTransferFunction* colorf = data->GetColorFunction();
+            colorf->RemoveAllPoints();
+            double r = 0, g = 0, b = 0;
+            for(unsigned j = 0; j < 255; j++){
+
+                if(i == 0){
+                    r = j/255.0;
+                    g = 0;
+                    b = 0;
+                }else if(i == 1){
+                    r = 0;
+                    g = j/255.0;
+                    b = 0;
+                }else if(i == 2){
+                    r = 0;
+                    g = 0;
+                    b = j/255.0;
+                }
+
+                colorf->AddRGBPoint(j, r, g, b);
+            }
+
+            prop3Dvect.push_back(data);
+
+            data->setId(_idCount);
+            _idCount++;
+
+            if(!boxw){
+                EnableBoundingBox(interactor, data->getId());
+                DisableBoundingBox(data->getId());
+                boxw = data->GetBoxWidget();
+            }else{
+                data->SetBoxWidget(boxw);
+            }
+        }
+
+        boxw->RemoveAllObservers();
+
+        vtkBoxWidgetCallback *callback = vtkBoxWidgetCallback::New();
+
+        for(unsigned i = 0; i < prop3Dvect.size(); i++){
+            VolumeRendererManagerData* data = prop3Dvect[i];
+            callback->AddMapper(data->GetVolumeMapper());
+        }
+
+        boxw->AddObserver(vtkCommand::InteractionEvent, callback);
+        callback->Delete();
+
+        return _idCount-1;*/
+
+        /*vtkImageData* imgshort = 0;
+        imgshort = vtkImageData::New();
+        imgshort->SetNumberOfScalarComponents(1);
+        imgshort->SetExtent(img->GetExtent());
+        imgshort->SetSpacing(img->GetSpacing());
+        imgshort->SetOrigin(img->GetOrigin());
+        imgshort->SetScalarTypeToUnsignedShort();
+        imgshort->AllocateScalars();
+        GetImageDouble(img, imgshort);
+
+        VolumeRendererManagerData* data = new VolumeRendererManagerData(imgshort, "");
+
+        vtkColorTransferFunction* colorf = data->GetColorFunction();
+        colorf->RemoveAllPoints();
+
+        map< unsigned short, vector< double > > colormap;
+
+        int *extent = img->GetExtent();
+
+        for(unsigned i = extent[0]; i < extent[1]; i++){
+            for(unsigned j = extent[2]; j < extent[3]; j++){
+                for(unsigned k = extent[4]; k < extent[5]; k++){
+
+                    unsigned char *imgpoint = ((unsigned char*)img->GetScalarPointer(i, j, k));
+                    double temp = (double)(0.299*imgpoint[0] + 0.587*imgpoint[1] + 0.114*imgpoint[2]);
+                    unsigned short val = temp*255.0;
+
+                    vector< double > rgb;
+                    rgb.push_back(0.299*imgpoint[0]);
+                    rgb.push_back(0.587*imgpoint[1]);
+                    rgb.push_back(0.114*imgpoint[2]);
+
+                    colormap[val] = rgb;
+                }
+            }
+        }
+
+
+
+        map< unsigned short, vector< double > >::iterator it;
+        for(it = colormap.begin(); it != colormap.end(); ++it){
+
+            colorf->AddRGBPoint((*it).first, (*it).second[0] / 255.0, (*it).second[1] / 255.0, (*it).second[2] / 255.0);
+        }
+
+        prop3Dvect.push_back(data);
+
+        data->setId(_idCount);
+        EnableBoundingBox(interactor, data->getId());
+        DisableBoundingBox(data->getId());
+        _idCount++;*/
+
+
+    }else{
+        image = img;
+
+        VolumeRendererManagerData* data = new VolumeRendererManagerData(img, "");
+        prop3Dvect.push_back(data);
+
+
+        data->setId(_idCount);
+        _idCount++;
+
+        EnableBoundingBox(interactor, data->getId());
+        DisableBoundingBox(data->getId());
+
+
+
+        return data->getId();
+
+    }
+}
+
+/**
+  *  @pre the image is not null and has more than one scalar component
+  *  @post Each component in the image is put in a single image
+  *  @param vtkImageData* img, multiple component image i.e. an image of vectors like an rgb
+  *  @return vtkImageData* double type image
+  */
+void VolumeRendererManager::GetImageDouble(vtkImageData* img, vtkImageData* imgushort){
+
+
+    int *extent = img->GetExtent();
+
+    for(unsigned i = extent[0]; i < extent[1]; i++){
+        for(unsigned j = extent[2]; j < extent[3]; j++){
+            for(unsigned k = extent[4]; k < extent[5]; k++){
+                if(img->GetScalarType() == VTK_UNSIGNED_CHAR){
+                    unsigned char *imgpoint = ((unsigned char*)img->GetScalarPointer(i, j, k));
+
+                    unsigned short *vectimgpoint = (unsigned short*)imgushort->GetScalarPointer(i, j, k);
+                    double temp = (double)(0.299*imgpoint[0] + 0.587*imgpoint[1] + 0.114*imgpoint[2]);
+                    *vectimgpoint = temp*255.0;
+
+                }
+            }
+        }
+    }
+}
+
+/**
+  *  @pre the image is not null and has more than one scalar component
+  *  @post Each component in the image is separated to form a different image
+  *  @param vtkImageData* img, multiple component image i.e. an image of vectors like an rgb
+  *  @return vector<vtkImageData* > a vector of images, one for each component
+  */
+void VolumeRendererManager::GetImages(vtkImageData* img, vector<vtkImageData* >& vectimg){
+
+    for(unsigned i = 0; i < img->GetNumberOfScalarComponents(); i++){
+        vectimg.push_back(vtkImageData::New());
+        vectimg[i]->SetNumberOfScalarComponents(1);
+        vectimg[i]->SetExtent(img->GetExtent());
+        vectimg[i]->SetSpacing(img->GetSpacing());
+        vectimg[i]->SetOrigin(img->GetOrigin());
+        vectimg[i]->SetScalarType(img->GetScalarType());
+        vectimg[i]->AllocateScalars();
+    }
+
+    int *extent = img->GetExtent();
+
+    for(unsigned i = extent[0]; i < extent[1]; i++){
+        for(unsigned j = extent[2]; j < extent[3]; j++){
+            for(unsigned k = extent[4]; k < extent[5]; k++){
+                if(img->GetScalarType() == VTK_UNSIGNED_CHAR){
+                    unsigned char *imgpoint = ((unsigned char*)img->GetScalarPointer(i, j, k));
+
+                    for(unsigned l = 0; l < vectimg.size(); l++){
+                        unsigned char *vectimgpoint = (unsigned char*)vectimg[l]->GetScalarPointer(i, j, k);
+                        *vectimgpoint = imgpoint[l];
+                    }
+                }else if(img->GetScalarType() == VTK_CHAR){
+                    char *imgpoint = ((char*)img->GetScalarPointer(i, j, k));
+
+                   for(unsigned l = 0; l < vectimg.size(); l++){
+                        char *vectimgpoint = ( char*)vectimg[l]->GetScalarPointer(i, j, k);
+                       *vectimgpoint = imgpoint[l];
+                   }
+               }else if(img->GetScalarType() == VTK_UNSIGNED_SHORT){
+                    unsigned short *imgpoint = ((unsigned short*)img->GetScalarPointer(i, j, k));
+
+                    for(unsigned l = 0; l < vectimg.size(); l++){
+                        unsigned short *vectimgpoint = (unsigned short*)vectimg[l]->GetScalarPointer(i, j, k);
+                        *vectimgpoint = imgpoint[l];
+                    }
+                }else if(img->GetScalarType() == VTK_SHORT){
+                     short *imgpoint = ((short*)img->GetScalarPointer(i, j, k));
+
+                    for(unsigned l = 0; l < vectimg.size(); l++){
+                         short *vectimgpoint = ( short*)vectimg[l]->GetScalarPointer(i, j, k);
+                        *vectimgpoint = imgpoint[l];
+                    }
+                }
+            }
+        }
+    }
+}
+
 /**
 **     Adds a prop3D to the manager and returns the identifier
 **/
@@ -200,5 +471,83 @@ vtkColorTransferFunction* VolumeRendererManager::GetColorFunction(int volumeid){
 }
 
 void VolumeRendererManager::changeCompositeMIPFunction(int id, int function) throw (char *){
+    if(id == -1){
+        for(unsigned i = 0; i < prop3Dvect.size(); i++)
+            prop3Dvect[i]->changeCompositeMIPFunction(function);
+    }else{
         getViewData(id)->changeCompositeMIPFunction(function);
+    }
+}
+
+/**
+  Changes the interpolation of the volume rendering.
+  type == 0 for linear interpolation
+  type == 1 for nearest interpolation
+  */
+void VolumeRendererManager::changeInterpolationType(int type, int propid){
+    if(propid == -1){
+        for(unsigned i = 0; i < prop3Dvect.size(); i++)
+            prop3Dvect[i]->changeInterpolationType(type);
+    }else{
+        getViewData(propid)->changeInterpolationType(type);
+    }
+}
+
+/**
+  * Set the lookuptable to the volumes in memory
+  * if the id is set then it only changes the lookup table for a specific volume
+ */
+void VolumeRendererManager::SetLookupTable(vtkLookupTable* lookup, int id){
+    if(id == -1){
+        for(unsigned i = 0; i < prop3Dvect.size(); i++)
+            prop3Dvect[i]->SetLookupTable(lookup);
+    }else{
+        getViewData(id)->SetLookupTable(lookup);
+    }
+
+}
+
+/**
+  * @returns all the props3D in this manager
+*/
+vector< vtkProp3D* > VolumeRendererManager::getProps3D(){
+
+    vector< vtkProp3D* >  propvects;
+    for(unsigned i = 0; i < prop3Dvect.size(); i++){
+        propvects.push_back(prop3Dvect[i]->getProp3D());
+    }
+    return propvects;
+}
+
+/**
+  *  @param std::vector<double> greylevel, the corresponding greylevel in the image
+  *  @param std::vector<double> value, the corresponding value for the opacity
+  *  @param int propid, the correspoding id, by default it applies the changes to the first volume in the array
+  */
+void VolumeRendererManager::setVolumeOpacity(std::vector<double> greylevel, std::vector<double> value, int propid){
+    if(propid == -1){
+        for(unsigned i = 0; i < prop3Dvect.size(); i++)
+            prop3Dvect[i]->setVolumeOpacity(greylevel, value);
+    }else{
+        getViewData(propid)->setVolumeOpacity(greylevel, value);
+    }
+}
+
+void VolumeRendererManager::EnableBoundingBox(vtkRenderWindowInteractor* interactor, int propid){
+    if(propid == -1){
+        for(unsigned i = 0; i < prop3Dvect.size(); i++)
+            prop3Dvect[i]->EnableBoundingBox(interactor);
+    }else{
+        getViewData(propid)->EnableBoundingBox(interactor);
+    }
+}
+
+void VolumeRendererManager::DisableBoundingBox(int propid){
+
+    if(propid == -1){
+        for(unsigned i = 0; i < prop3Dvect.size(); i++)
+            prop3Dvect[i]->DisableBoundingBox();
+    }else{
+        getViewData(propid)->DisableBoundingBox();
+    }
 }
index 72a912496969cc2cdbf01d4d3bc14ce46add8227..bf7c6809ed1767b2011bbe59c38d9844c317bbf1 100644 (file)
@@ -4,8 +4,8 @@
   Program:   wxMaracas
   Module:    $RCSfile: volumerenderermanager.h,v $
   Language:  C++
-  Date:      $Date: 2011/05/31 19:03:03 $
-  Version:   $Revision: 1.1 $
+  Date:      $Date: 2011/10/05 16:27:04 $
+  Version:   $Revision: 1.2 $
 
   Copyright: (c) 2002, 2003
   License:
@@ -50,6 +50,18 @@ public:
         **/
         int addVolume(int idTP, vtkImageData* img, std::string dataname) throw (char*);
 
+        /**
+        * @pre   The image can have one or multiple components per voxel, and volume rendering is performed seprately over the
+                 three of them. If the image has multiple components and the separate components flag is set to false, then
+                 the vtkImageAppendComponents is used to create a single image.
+        * @post  The volume rendering is performed over the image vol
+        * @param vtkImageData* the image volume
+        * @param bool independentcomponents, if the image has multiple components, the mapper will be created either for managing
+                        an rgb image plus a luminance channel (the luminance will be calculated using the luminance image filter)
+                        to control the opacity or to manage the multiple components in a single image
+        */
+        int addVolume(vtkImageData* img, vtkRenderWindowInteractor* interactor, bool independentcomponents = false);
+
         /**
         **     loads a prop3D from a nSTL file
         **/
@@ -106,6 +118,37 @@ public:
 
         vtkPiecewiseFunction* GetTransferFunction(int volumeid);
         vtkColorTransferFunction* GetColorFunction(int volumeid);
+
+
+        /**
+          Changes the interpolation of the volume rendering.
+          type == 0 for linear interpolation
+          type == 1 for nearest interpolation
+          */
+        void changeInterpolationType(int type, int propid = -1);
+
+        /**
+          * Set the lookuptable to the volumes in memory
+          * if the id is set then it only changes the lookup table for a specific volume
+         */
+        void SetLookupTable(vtkLookupTable* lookup, int id = -1);
+
+        /**
+          * @returns all the props3D in this manager
+        */
+        vector< vtkProp3D* > getProps3D();
+
+        /**
+          *  @param std::vector<double> greylevel, the corresponding greylevel in the image
+          *  @param std::vector<double> value, the corresponding value for the opacity
+          *  @param int propid, the correspoding id, by default it applies the changes to the first volume in the array
+          */
+        void setVolumeOpacity(std::vector<double> greylevel, std::vector<double> value, int propid = -1);
+
+
+        void EnableBoundingBox(vtkRenderWindowInteractor* interactor, int propid = -1);
+
+        void DisableBoundingBox(int propid = -1);
 private:
         std::vector<VolumeRendererManagerData*> prop3Dvect;
 
@@ -114,6 +157,21 @@ private:
 
         int _idCount;
 
+        /**
+          *  @pre the image is not null and has more than one scalar component
+          *  @post Each component in the image is separated to form a different image
+          *  @param vtkImageData* img, multiple component image i.e. an image of vectors like an rgb
+          *  @return vector<vtkImageData* > a vector of images, one for each component
+          */
+        void GetImages(vtkImageData* img, vector<vtkImageData* >& images);
+
+        /**
+          *  @pre the image is not null and has more than one scalar component
+          *  @post Each component in the image is put in a single image
+          *  @param vtkImageData* img, multiple component image i.e. an image of vectors like an rgb
+          *  @return vtkImageData* double type image
+          */
+        void GetImageDouble(vtkImageData* img, vtkImageData* imgdouble);
 
 
 
index f267e3f983aee2bc401bbeced394ff32623cadcb..3e6ad74dda2afae136efb66e602c061bfdbf8297 100644 (file)
@@ -9,9 +9,20 @@
 #include "boxSurfaceObserver.h"
 #include "vtkProperty.h"
 
+#include <vtkVolumeRayCastMapper.h>
+
+#if VTK_MAJOR_VERSION >= 5
+    #if VTK_MINOR_VERSION >= 6
+        #include "vtkGPUVolumeRayCastMapper.h"
+    #endif
+#endif
 
 using namespace std;
 
+VolumeRendererManagerData::VolumeRendererManagerData(vtkImageData* vol, bool usegpu){
+    Initialize(vol, "", usegpu);
+}
+
 VolumeRendererManagerData::VolumeRendererManagerData(vtkImageData* vol, std::string dataname){
 
     Initialize(vol, dataname);
@@ -26,35 +37,30 @@ VolumeRendererManagerData::VolumeRendererManagerData(vtkImageData* vol, vtkRende
 
 }
 
-VolumeRendererManagerData::VolumeRendererManagerData(vtkImageData* vol, bool usegpu, std::string dataname){
-    Initialize(vol, dataname, usegpu);
-}
-
 void VolumeRendererManagerData::Initialize(vtkImageData* vol, std::string dataname, bool usegpu){
+    _id = 0;
     _vol = vol;
     _dataname = dataname;
 
-    _tfun = vtkPiecewiseFunction::New();
-    _ctfun = vtkColorTransferFunction::New();
 
     _volumePlanes  = vtkPlanes::New();
 
     _volumeProperty = vtkVolumeProperty::New();
     _volumeProperty->SetInterpolationTypeToLinear();
     //_volumeProperty->ShadeOn();
-    _volumeProperty->DisableGradientOpacityOn();
-    _volumeProperty->SetColor(_ctfun);
+    _volumeProperty->DisableGradientOpacityOn();    
+    _tfun = vtkPiecewiseFunction::New();
     _volumeProperty->SetScalarOpacity(_tfun );
-
+    _ctfun = vtkColorTransferFunction::New();
 
     _newvol = vtkVolume::New();
-    _newvol->SetProperty(_volumeProperty );
+    _newvol->SetProperty(_volumeProperty );    
+
 
-    _volumeMapper = 0;
-    _volumeMappergpu = 0;
     _compositeFunction = 0;
     _MIPFunction = 0;
-    _boxWidgetS1 = 0;
+
+    BoxWidget = 0;
 
 /* EED9Juin2011
     if(usegpu && _vol->GetDataDimension() > 2){
@@ -82,33 +88,31 @@ void VolumeRendererManagerData::Initialize(vtkImageData* vol, std::string datana
     }
 */
 
-       vtkVolumeMapper *volMapperTmp;
-    if(usegpu && _vol->GetDataDimension() > 2){
-               #if (VTK_MAYOR_VERSION>=5 && VTK_MINOR_VERSION>=6)
-                       _volumeMappergpu                                                                = vtkGPUVolumeRayCastMapper::New();
-                       _volumeMappergpu->AutoAdjustSampleDistancesOn();
-                       volMapperTmp                                                                    = _volumeMappergpu;
-               #else
-                       _compositeFunction                                                              = vtkVolumeRayCastCompositeFunction::New();
-                       _MIPFunction                                                                    = vtkVolumeRayCastMIPFunction::New();
-                       _volumeMapper           = vtkVolumeRayCastMapper::New();
-                       _volumeMapper->SetVolumeRayCastFunction(_compositeFunction);
-                       _volumeMapper->AutoAdjustSampleDistancesOn();
-                       volMapperTmp                                                                    = _volumeMapper;
-               #endif
-    }else{
-        _compositeFunction                                                             = vtkVolumeRayCastCompositeFunction::New();
-        _MIPFunction                                                                   = vtkVolumeRayCastMIPFunction::New();
-        _volumeMapper                                                                  = vtkVolumeRayCastMapper::New();
-        _volumeMapper->SetVolumeRayCastFunction(_compositeFunction);
-               _volumeMapper->AutoAdjustSampleDistancesOn();
-               volMapperTmp                                                                    = _volumeMapper;
-    }
+       VolumeMapper = 0;
+#if VTK_MAJOR_VERSION >= 5
+    #if VTK_MINOR_VERSION >= 6
+       vtkGPUVolumeRayCastMapper * volumeMappergpu = vtkGPUVolumeRayCastMapper::New();
+       volumeMappergpu->AutoAdjustSampleDistancesOn();
+       VolumeMapper = volumeMappergpu;
+    #endif
+#else
+
+       _volumeProperty->SetColor(_ctfun);
+
+
+       _compositeFunction                                                              = vtkVolumeRayCastCompositeFunction::New();
+       _MIPFunction                                                                    = vtkVolumeRayCastMIPFunction::New();
+       vtkVolumeRayCastMapper* volumeMapper                                                                    = vtkVolumeRayCastMapper::New();
+       volumeMapper->SetVolumeRayCastFunction(_compositeFunction);
+               volumeMapper->AutoAdjustSampleDistancesOn();
+               VolumeMapper                                                                    = volumeMapper;
+#endif
 
-       volMapperTmp->SetClippingPlanes( _volumePlanes );
-       _newvol->SetMapper(volMapperTmp );
-       volMapperTmp->SetInput( _vol );
-       volMapperTmp->Update();
+
+        VolumeMapper->SetClippingPlanes( _volumePlanes );
+        _newvol->SetMapper(VolumeMapper );
+        VolumeMapper->SetInput( _vol );
+        VolumeMapper->Update();
     _newvol->Update();
 }
 
@@ -126,54 +130,71 @@ VolumeRendererManagerData::~VolumeRendererManagerData()
             _compositeFunction->Delete();
         if(_MIPFunction)
             _MIPFunction->Delete();
-        if(_volumeMapper)
-            _volumeMapper->Delete();
-        if(_volumeMappergpu)
-            _volumeMappergpu->Delete();
-        if(_boxWidgetS1){
+        if(VolumeMapper)
+            VolumeMapper->Delete();
+
+        if(BoxWidget){
             DisableBoundingBox();
         }
 
 }
+void VolumeRendererManagerData::SetIndependentComponents(bool independent){
+
+    if(!independent){
+        _volumeProperty->IndependentComponentsOff();
+    }else{
+        _volumeProperty->IndependentComponentsOn();
+    }
+}
 
 void VolumeRendererManagerData::EnableBoundingBox(vtkRenderWindowInteractor* interactor)
 {
 //EED9Juin2011    if(_volumeMappergpu){
-    if(_boxWidgetS1==NULL){
-        _boxWidgetS1 = vtkBoxWidget::New();
-        _boxWidgetS1->SetInteractor( interactor );
-        _boxWidgetS1->SetPlaceFactor(1.01);
 
-        _boxWidgetS1->SetInput( _vol );
-        _boxWidgetS1->InsideOutOn();
-        _boxWidgetS1->PlaceWidget();
+    if(!BoxWidget){
+        BoxWidget = vtkBoxWidget::New();
+        BoxWidget->SetInteractor( interactor );
+        BoxWidget->SetPlaceFactor(1.01);
+
+        BoxWidget->SetInput( _vol );
+        BoxWidget->InsideOutOn();
+        BoxWidget->PlaceWidget();
+
 
         vtkBoxWidgetCallback *callback = vtkBoxWidgetCallback::New();
 
-               if (_volumeMapper!=0){
-                       callback->SetMapper(_volumeMapper);
-               } else {
-                       callback->SetMapper(_volumeMappergpu);
-               }
 
-        _boxWidgetS1->AddObserver(vtkCommand::InteractionEvent, callback);
+        callback->SetMapper(VolumeMapper);
+
+
+        BoxWidget->AddObserver(vtkCommand::InteractionEvent, callback);
         callback->Delete();
-        _boxWidgetS1->EnabledOn();
-        _boxWidgetS1->GetSelectedFaceProperty()->SetOpacity(0.0);
+
+        BoxWidget->EnabledOn();
+        BoxWidget->GetSelectedFaceProperty()->SetOpacity(0.0);
+
         cout<<"JPRG::VolumeRendererManagerData::EnableBoundingBox::CREATE"<<endl;
+
     }else{
+
+        BoxWidget->EnabledOn();
+
         cout<<"JPRG::VolumeRendererManagerData::EnableBoundingBox"<<endl;
-        _boxWidgetS1->EnabledOn();
+
     }
 //EED9Juin2011  }
 }
 
 void VolumeRendererManagerData::DisableBoundingBox(){
-    if(_boxWidgetS1){
+
+    if(BoxWidget){
+        BoxWidget->EnabledOff();
+        //BoxWidget->Delete();
+        //BoxWidget = 0;
+
         cout<<"JPRG::VolumeRendererManagerData::DisableBoundingBox"<<endl;
-        _boxWidgetS1->EnabledOff();
-        //_boxWidgetS1->Delete();
-        //_boxWidgetS1 = 0;
+
+
     }
 }
 
@@ -228,7 +249,7 @@ void VolumeRendererManagerData::checkInvariant()throw (char *){
         if(!_MIPFunction){
                 throw "No MIP function initialized";
         }
-        if(!_volumeMapper && !_volumeMappergpu){
+        if(!VolumeMapper){
                 throw "No volume mapper initialized";
         }
 }
@@ -272,26 +293,68 @@ void VolumeRendererManagerData::setDataname(std::string dataname){
 }
 
 void VolumeRendererManagerData::changeCompositeMIPFunction(int function){
-        checkInvariant();
-        if(_volumeMapper){
+        //checkInvariant();
+        if(VolumeMapper){
+#if VTK_MAJOR_VERSION >= 5
+    #if VTK_MINOR_VERSION >= 6
+            if(dynamic_cast<vtkVolumeRayCastMapper*>(VolumeMapper)){
+                vtkVolumeRayCastMapper* volumemapper = dynamic_cast<vtkVolumeRayCastMapper*>(VolumeMapper);
+                if(function == 0){
+                        volumemapper->SetVolumeRayCastFunction(_compositeFunction);
+                }else{
+                        volumemapper->SetVolumeRayCastFunction(_MIPFunction);
+                }
+            }else if(dynamic_cast<vtkGPUVolumeRayCastMapper*>(VolumeMapper)){
+                vtkGPUVolumeRayCastMapper* volumemapper = dynamic_cast<vtkGPUVolumeRayCastMapper*>(VolumeMapper);
+                if(function == 0){
+                    volumemapper->SetBlendModeToComposite();
+                }else if(function == 1){
+                    volumemapper->SetBlendModeToMaximumIntensity();
+                }else if(function == 2){
+                    volumemapper->SetBlendModeToMinimumIntensity();
+                }
+            }
+    #endif
+#else
+            vtkGPUVolumeRayCastMapper* volumemapper = dynamic_cast<vtkGPUVolumeRayCastMapper*>(VolumeMapper);
             if(function == 0){
-                    _volumeMapper->SetVolumeRayCastFunction(_compositeFunction);
-            }else{
-                    _volumeMapper->SetVolumeRayCastFunction(_MIPFunction);
+                volumemapper->SetBlendModeToComposite();
+            }else if(function == 1){
+                volumemapper->SetBlendModeToMaximumIntensity();
+            }else if(function == 2){
+                volumemapper->SetBlendModeToMinimumIntensity();
             }
+#endif
         }
 
 }
 
 void VolumeRendererManagerData::SetLookupTable(vtkLookupTable* lookuptable){
-     _ctfun->RemoveAllPoints();
-     vtkColorTransferFunction* colort = (vtkColorTransferFunction*)lookuptable;
-     for(int i = 0; i < colort->GetSize(); i++){
-         double val[6];
-         colort->GetNodeValue(i, val);
-         cout<< "JPRG::VolumeRendererManagerData::SetLookupTable::"<<val[0]<<" "<< val[1]<<" "<<val[2]<<" "<< val[3]<<endl;
-         _ctfun->AddRGBPoint(val[0], val[1], val[2], val[3]);
-     }
-     _newvol->Update();
+    if(lookuptable){
+         _ctfun->RemoveAllPoints();
+         vtkColorTransferFunction* colort = (vtkColorTransferFunction*)lookuptable;
+         for(int i = 0; i < colort->GetSize(); i++){
+             double val[6];
+             colort->GetNodeValue(i, val);
+             cout<< "JPRG::VolumeRendererManagerData::SetLookupTable::"<<val[0]<<" "<< val[1]<<" "<<val[2]<<" "<< val[3]<<endl;
+             _ctfun->AddRGBPoint(val[0], val[1], val[2], val[3]);
+         }
+         _newvol->Update();
+    }
+
+}
+
+void VolumeRendererManagerData::changeInterpolationType(int type){
+    //checkInvariant();
+    if(type == 0){
+        _volumeProperty->SetInterpolationTypeToLinear();
+    }else if(type == 1){
+        _volumeProperty->SetInterpolationTypeToNearest();
+    }
+}
+
+void VolumeRendererManagerData::SetColorTransferFunction(int i, vtkColorTransferFunction* colorf){
+
+    _volumeProperty->SetColor(i, colorf);
 
 }
index ea1cd4a88d490a21c14774e07c94189f788542b5..fd530b65aacf4e34e0b89bc458ead76bc9ee7e95 100644 (file)
@@ -6,7 +6,7 @@
 #include <vtkVolumeRayCastCompositeFunction.h>
 #include <vtkPlanes.h>
 #include <vtkVolumeMapper.h>
-#include <vtkVolumeRayCastMapper.h>
+
 #include <vtkVolumeProperty.h>
 #include <vtkVolume.h>
 #include <vtkPiecewiseFunction.h>
 #include <vtkBoxWidget.h>
 #include <vtkAbstractMapper.h>
 
-#if (VTK_MAYOR_VERSION>=5 && VTK_MINOR_VERSION>=6)
-  #include <vtkGPUVolumeRayCastMapper.h>
-#endif
-
 
 #include <vector>
 
+using namespace std;
 
 // Callback for moving the planes from the box widget to the mapper
 class vtkBoxWidgetCallback : public vtkCommand
@@ -36,23 +33,30 @@ public:
   virtual void Execute(vtkObject *caller, unsigned long, void*)
     {
       vtkBoxWidget *widget = reinterpret_cast<vtkBoxWidget*>(caller);
-      if (this->Mapper)
-        {
-        vtkPlanes *planes = vtkPlanes::New();
-        widget->GetPlanes(planes);
-        this->Mapper->SetClippingPlanes(planes);
-        planes->Delete();
-        }
+      vtkPlanes *planes = vtkPlanes::New();
+      widget->GetPlanes(planes);
+      for(unsigned i = 0; i< VectorMapper.size(); i++){
+          VectorMapper[i]->SetClippingPlanes(planes);
+      }
+      planes->Delete();
     }
   void SetMapper(vtkAbstractMapper* m)
-    { this->Mapper = m; }
+    { if(VectorMapper.size() == 0){
+          VectorMapper.push_back(m);
+      }else{
+          VectorMapper[0] = m;
+      }
+    }
+
+  void AddMapper(vtkAbstractMapper* m){
+      VectorMapper.push_back(m);
+  }
 
 protected:
   vtkBoxWidgetCallback()
-    { this->Mapper = 0; }
+    {  }
 
-  //vtkVolumeRayCastMapper *Mapper;
-  vtkAbstractMapper *Mapper;
+  vector< vtkAbstractMapper* > VectorMapper;
 };
 
 
@@ -61,7 +65,9 @@ class VolumeRendererManagerData  : public vtkObject{
 public:
         VolumeRendererManagerData(vtkImageData* vol, std::string dataname="");
         VolumeRendererManagerData(vtkImageData* vol, vtkRenderer* render, std::string dataname="");
-        VolumeRendererManagerData(vtkImageData* vol, bool usegpu, std::string dataname="");
+        VolumeRendererManagerData(vtkImageData* vol, bool usegpu);
+
+
         ~VolumeRendererManagerData();
 
         /**
@@ -130,6 +136,24 @@ public:
 
         void EnableBoundingBox(vtkRenderWindowInteractor* interactor);
         void DisableBoundingBox();
+
+        /**
+          changes the interoplation type of the volume
+          type = 0 linear
+          type = 1 nearest
+           */
+        void changeInterpolationType(int type);
+
+
+        vtkGetMacro(BoxWidget, vtkBoxWidget*);
+        vtkSetMacro(BoxWidget, vtkBoxWidget*);
+
+        vtkGetMacro(VolumeMapper, vtkVolumeMapper*);
+        vtkSetMacro(VolumeMapper, vtkVolumeMapper*);
+
+        void SetColorTransferFunction(int i, vtkColorTransferFunction* colorf);
+
+        void SetIndependentComponents(bool independent);
 protected:
         /**
          * Prop 3D (data actor)
@@ -149,16 +173,7 @@ private:
         int _id;
 
         vtkVolumeRayCastCompositeFunction      *_compositeFunction;
-        vtkPlanes                                                      *_volumePlanes;
-        vtkVolumeRayCastMapper                     *_volumeMapper;
-       
-       
-#if (VTK_MAYOR_VERSION>=5 && VTK_MINOR_VERSION>=6)
-               vtkGPUVolumeRayCastMapper           *_volumeMappergpu;
-#else  
-               vtkVolumeRayCastMapper                      *_volumeMappergpu;
-#endif 
-       
+        vtkPlanes                              *_volumePlanes;
        
         vtkVolumeProperty                                      *_volumeProperty;
         vtkVolume                                                      *_newvol;
@@ -168,7 +183,8 @@ private:
         /**
         ** boxwidget to control the volume
         **/
-        vtkBoxWidget* _boxWidgetS1;
+        vtkBoxWidget* BoxWidget;
+        vtkVolumeMapper *VolumeMapper;
 
         void Initialize(vtkImageData* vol, std::string dataname, bool usegpu = false);
 
index 83d09b1e2979edda9e241ebb016dc28dcf07cc44..fc4152ef0d6db49eef75c63b6ae2db8536816246 100644 (file)
@@ -162,14 +162,24 @@ FILE(GLOB ${LIBRARY_NAME}_HEADERS_CUTMODULE src/CutModule/interface/*.h src/CutM
 
  # Sets the settings for macro CREA_ADVANCED_INSTALL_LIBRARY_FOR_CMAKE
   SET(${LIBRARY_NAME}_INSTALL_FOLDER ${LIBRARY_NAME})
+
   SET(${LIBRARY_NAME}_LIBRARIES ${LIBRARY_NAME}
-                               BaseVolumeRenderer
-                               BaseSurfaceRenderer
-                               GUIWxSurfaceRenderer
-                               GUIWxVolumeRenderer
-                               KernelViewerWidgets
-                               KernelVolumeRenderer
-                               KernelSurfaceRenderer   )
+             KernelVolumeRenderer
+             KernelViewerWidgets
+             KernelSurfaceRenderer
+             BaseVolumeRenderer
+             BaseSurfaceRenderer
+       )
+
+#  SET(${LIBRARY_NAME}_LIBRARIES ${LIBRARY_NAME}
+#                              BaseVolumeRenderer
+#                              BaseSurfaceRenderer
+#                              GUIWxSurfaceRenderer
+#                              GUIWxVolumeRenderer
+#                              KernelViewerWidgets
+#                              KernelVolumeRenderer
+#                              KernelSurfaceRenderer   )
+
 
 #  FILE(RELATIVE_PATH
  #   ${LIBRARY_NAME}_BUILD_TREE_RELATIVE_INCLUDE_PATHS
index b0c7ebd797257cd7abf1452e1ae4c30f71c0ef98..a87830acf664837290cc268f1b654c38797f02cb 100644 (file)
@@ -5,6 +5,8 @@
 ** Start of data viewmanagerData
 *********************************************************************************************/
 
+using namespace std;
+
 PlanesOperations::PlanesOperations()
 {      
 }
@@ -63,7 +65,7 @@ double* PlanesOperations::getNormal(double* vect)
        return vectnorm;
 }
 
-double* PlanesOperations::makeVector(double podouble0[3], double podouble1[3])
+double* PlanesOperations::makeVector(double *podouble0, double *podouble1)
 {
        double *vect;
        vect = new double[3];
@@ -75,7 +77,134 @@ double* PlanesOperations::makeVector(double podouble0[3], double podouble1[3])
        return vect;
 }
 
+void PlanesOperations::getCrossProduct(double* vect0,double* vect1, double* vectres){
+    vectres[0] = vect0[1]*vect1[2]-(vect0[2]*vect1[1]);
+    vectres[1] = -(vect0[0]*vect1[2]-(vect0[2]*vect1[0]));
+    vectres[2] = vect0[0]*vect1[1]-(vect0[1]*vect1[0]);
+}
+
+void PlanesOperations::getNormal(double* vect, double* vectnorm){
+
+    double mag = getMagnitud(vect);
+
+    if(mag!=0){
+            vectnorm[0] = vect[0]/mag;
+            vectnorm[1] = vect[1]/mag;
+            vectnorm[2] = vect[2]/mag;
+    }else{
+            vectnorm[0] = 0;
+            vectnorm[1] = 0;
+            vectnorm[2] = 0;
+    }
+}
+
+void PlanesOperations::makeVector(double* podouble0, double* podouble1, double* vectres){
+    vectres[0] = podouble1[0] - podouble0[0];
+    vectres[1] = podouble1[1] - podouble0[1];
+    vectres[2] = podouble1[2] - podouble0[2];
+}
+
 double PlanesOperations::getDotProduct(double* vect0,double* vect1){
        return vect0[0]*vect1[0] + vect0[1]*vect1[1] + vect0[2]*vect1[2];
 }
 
+void PlanesOperations::addVectors(double* vect0, double* vect1, double*vectres){
+
+    vectres[0]= vect0[0] + vect1[0];
+    vectres[1]= vect0[1] + vect1[1];
+    vectres[2]= vect0[2] + vect1[2];
+}
+
+void PlanesOperations::scalarVector(double* vect0, double scalar, double*vectres){
+
+    vectres[0]= vect0[0]*scalar;
+    vectres[1]= vect0[1]*scalar;
+    vectres[2]= vect0[2]*scalar;
+}
+
+vector<double> PlanesOperations::getCrossProduct(vector<double> vect0,vector<double> vect1){
+  
+       vector<double> vectCross;
+       
+       for(unsigned i = 0; i < vect0.size(); i++){
+         
+         unsigned ii = (i + 1 == vect0.size())? 0: i + 1;
+         unsigned iii = (ii + 1 == vect0.size())? 0: ii + 1;
+         
+         vectCross.push_back( vect0[ii]*vect1[iii]- vect0[iii]*vect1[ii] );
+         
+       }
+       return vectCross;
+  
+}
+double  PlanesOperations::getDotProduct(vector<double> vect0,vector<double> vect1){
+  
+  double sum = 0;
+  
+  for(unsigned i = 0; i < vect0.size(); i++) sum += vect0[i]*vect1[i];
+  
+  return sum;
+}
+vector<double> PlanesOperations::getNormal(vector<double> vect){
+       vector<double> vectnorm;
+       double mag = getMagnitud(vect); 
+       
+       for(unsigned i = 0; i < vect.size(); i++){
+         
+         if(mag != 0){
+           vectnorm.push_back(vect[i]/mag);
+         }else{
+           vectnorm.push_back(0);
+         }
+       }
+       return vectnorm;
+}
+double  PlanesOperations::getMagnitud(vector<double> vect){
+  double mag = 0;
+  
+  for(unsigned i = 0; i < vect.size(); i++) mag += pow(vect[i], 2);
+  
+  mag = sqrt(mag);
+
+  //std::cout<<"mag "<<mag <<std::endl;
+
+  return mag;
+}
+vector<double> PlanesOperations::makeVector(vector<double> podouble0, vector<double> podouble1){
+  
+  vector<double> vector;
+  
+  for(unsigned i = 0; i < podouble0.size(); i++){    
+    vector.push_back(podouble1[i] - podouble0[i]);    
+  }
+  return vector;
+}
+
+/**
+*    Adds to vectors, the result is in vectres;
+*@param double* vect0, the first vector
+*@param double* vect1, the second vector
+*@param double* vectres, the resulting vector
+*/
+vector<double> PlanesOperations::addVectors(vector<double> vect0, vector<double> vect1){
+    vector<double> vectres;
+    for(unsigned i = 0; i < vect0.size(); i++){
+        vectres.push_back(vect0[i] + vect1[i]);
+    }
+    return vectres;
+}
+
+/**
+*    multiply a vector with a given scalar
+*@param double* vect0, the vector
+*@param double scalar, the scalar value
+*@param double* vectres, the resulting vector
+*/
+vector<double> PlanesOperations::scalarVector(vector<double> vect0, double scalar){
+    vector<double> vectres;
+    for(unsigned i = 0; i < vect0.size(); i++){
+        vectres.push_back(vect0[i]*scalar);
+    }
+    return vectres;
+}
+
index 451bd10732d3dc29e3eb27103e55d13d990b3f29..ea9c2ee8fd76190ed0aef8627fa2792f4b3252d9 100644 (file)
@@ -4,6 +4,9 @@
 #include <math.h>
 
 #include <iostream>
+#include <vector>
+
+using namespace std;
 
 class PlanesOperations  {
 
@@ -13,11 +16,49 @@ public:
        
        
 
-       double* getCrossProduct(double* vect0,double* vect1);
-       double getDotProduct(double* vect0,double* vect1);
+    double* getCrossProduct(double* vect0,double* vect1);
+    double getDotProduct(double* vect0,double* vect1);
     double* getNormal(double* vect);
     double getMagnitud(double* vect);
-    double* makeVector(double podouble0[3], double podouble1[3]);      
+    double* makeVector(double *podouble0, double* podouble1);
+
+    void getCrossProduct(double* vect0,double* vect1, double* vectres);
+    void getNormal(double* vect, double* vectnorm);
+    void makeVector(double* podouble0, double* podouble1, double* vectres);
+    /**
+    *    Adds to vectors, the result is in vectres;
+    *@param double* vect0, the first vector
+    *@param double* vect1, the second vector
+    *@param double* vectres, the resulting vector
+    */
+    void addVectors(double* vect0, double* vect1, double*vectres);
+    /**
+    *    multiply a vector with a given scalar
+    *@param double* vect0, the vector
+    *@param double scalar, the scalar value
+    *@param double* vectres, the resulting vector
+    */
+    void scalarVector(double* vect0, double scalar, double*vectres);
+    
+    vector<double> getCrossProduct(vector<double> vect0,vector<double> vect1);
+    double  getDotProduct(vector<double> vect0,vector<double> vect1);
+    vector<double> getNormal(vector<double> vect);
+    double  getMagnitud(vector<double> vect);
+    vector<double> makeVector(vector<double> podouble0, vector<double> podouble1);
+    /**
+    *    Adds to vectors, the result is in vectres;
+    *@param double* vect0, the first vector
+    *@param double* vect1, the second vector
+    *@param double* vectres, the resulting vector
+    */
+    vector<double> addVectors(vector<double> vect0, vector<double> vect1);
+    /**
+    *    multiply a vector with a given scalar
+    *@param double* vect0, the vector
+    *@param double scalar, the scalar value
+    *@param double* vectres, the resulting vector
+    */
+    vector<double> scalarVector(vector<double> vect0, double scalar);
        
 };