]> Creatis software - clitk.git/commitdiff
Use QSharedPointers for vvROIActors
authorsrit <srit>
Tue, 29 Mar 2011 09:10:17 +0000 (09:10 +0000)
committersrit <srit>
Tue, 29 Mar 2011 09:10:17 +0000 (09:10 +0000)
vv/vvStructureSetActor.cxx
vv/vvStructureSetActor.h
vv/vvToolStructureSetManager.cxx

index 9a9ac8c674f4dd6e61aa84832c1dd260d6f7b30f..86fcdb1a6db0819c45f24a53f0ef911958473bc4 100644 (file)
@@ -44,7 +44,7 @@ int vvStructureSetActor::GetNumberOfROIs()
 
 
 //------------------------------------------------------------------------------
-std::vector<vvROIActor*> & vvStructureSetActor::GetROIList() 
+std::vector< QSharedPointer<vvROIActor> > & vvStructureSetActor::GetROIList() 
 { 
   return mROIActors; 
 }
@@ -74,7 +74,7 @@ vvROIActor * vvStructureSetActor::GetROIActor(int n)
     std::cerr << "No ROI number " << n << std::endl;
     return NULL;
   }
-  return mROIActors[mMapROIIndex[n]];
+  return mROIActors[mMapROIIndex[n]].data();
 }
 //------------------------------------------------------------------------------
 
@@ -91,15 +91,15 @@ void vvStructureSetActor::CreateNewROIActor(int n, bool modeBG)
 
   // If already exist : delete it
   int old = -1;
-  if (mMapROIIndex.find(n) != mMapROIIndex.end()) {
-    delete mROIActors[mMapROIIndex[n]];
+  if (mMapROIIndex.find(n) != mMapROIIndex.end())
     old = mMapROIIndex[n];
-  }
 
   // Add ROI Actors
-  vvROIActor * actor = new vvROIActor;
-  if (old == -1) mROIActors.push_back(actor);
-  else mROIActors[old] = actor;
+  QSharedPointer<vvROIActor> actor = QSharedPointer<vvROIActor>(new vvROIActor);
+  if (old == -1)
+    mROIActors.push_back(actor);
+  else
+    mROIActors[old] = actor;
   actor->SetBGMode(modeBG);
   actor->SetROI(roi);
   actor->SetSlicerManager(mSlicerManager);
index ce2434aa3446211a74fe5d2a8766ecc80287a69a..6b88cd77825266623cf45e205922f4008c852e62 100644 (file)
@@ -21,6 +21,7 @@
 
 #include "clitkDicomRT_StructureSet.h"
 #include <QObject>
+#include <QSharedPointer>
 
 class vvSlicerManager;
 class vvROIActor;
@@ -37,12 +38,12 @@ class vvStructureSetActor: public QObject {
   void CreateNewROIActor(int n, bool modeBG=true);
   vvROIActor* GetROIActor(int n);
   int GetNumberOfROIs();
-  std::vector<vvROIActor*> & GetROIList();
+  std::vector< QSharedPointer<vvROIActor> > & GetROIList();
   
  protected:
   clitk::DicomRT_StructureSet * mStructureSet;
   vvSlicerManager * mSlicerManager;
-  std::vector<vvROIActor*> mROIActors;
+  std::vector< QSharedPointer<vvROIActor> > mROIActors;
   std::map<int, int> mMapROIIndex;
 
 }; // end class vvStructureSetActor
index 2d50d8a6d0b8836020bf196012d8fed2220baf72..502514d2e1ee82eef530ebdc8fbfe80e546d2c68 100644 (file)
@@ -99,7 +99,6 @@ vvToolStructureSetManager::vvToolStructureSetManager(vvMainWindowBase * parent,
 //------------------------------------------------------------------------------
 vvToolStructureSetManager::~vvToolStructureSetManager()
 {
-  disconnect(mTree, SIGNAL(itemSelectionChanged()), this, SLOT(SelectedItemChangedInTree()));
   m_NumberOfTool--;
 }
 //------------------------------------------------------------------------------
@@ -262,9 +261,10 @@ void vvToolStructureSetManager::OpenBinaryImage()
       return;
     }
     vvImage::Pointer binaryImage = reader->GetOutput();
-    AddImage(binaryImage, filename[i].toStdString(), mBackgroundValueSpinBox->value());
+    //AddImage(binaryImage, filename[i].toStdString(), mBackgroundValueSpinBox->value());
     mOpenedBinaryImage.push_back(binaryImage);
   }
+DD(mOpenedBinaryImage.back()->GetOrigin()[0]);
   UpdateImage();
 }
 //------------------------------------------------------------------------------
@@ -372,14 +372,8 @@ void vvToolStructureSetManager::closeEvent(QCloseEvent *event)
 
   mCheckBoxShowAll->setCheckState(Qt::Unchecked);
   mContourCheckBoxShowAll->setCheckState(Qt::Unchecked);
-  if (mCurrentSlicerManager != 0) mCurrentSlicerManager->Render();
-  if (mCurrentStructureSetActor) {
-    for(int i=0; i<mCurrentStructureSetActor->GetNumberOfROIs(); i++) {
-      mCurrentStructureSetActor->GetROIList()[i]->SetVisible(false);
-      mCurrentStructureSetActor->GetROIList()[i]->SetContourVisible(false);
-      delete mCurrentStructureSetActor->GetROIList()[i];
-    }
-  }
+  if (mCurrentSlicerManager != 0)
+    mCurrentSlicerManager->Render();
 
   if (!isWindow()) {
     if (m_NumberOfTool == 1) {