From: srit Date: Tue, 29 Mar 2011 09:10:17 +0000 (+0000) Subject: Use QSharedPointers for vvROIActors X-Git-Tag: v1.2.0~91 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=8ba069c89cddf44e9bd529b781bb5ddfd8d21adf;p=clitk.git Use QSharedPointers for vvROIActors --- diff --git a/vv/vvStructureSetActor.cxx b/vv/vvStructureSetActor.cxx index 9a9ac8c..86fcdb1 100644 --- a/vv/vvStructureSetActor.cxx +++ b/vv/vvStructureSetActor.cxx @@ -44,7 +44,7 @@ int vvStructureSetActor::GetNumberOfROIs() //------------------------------------------------------------------------------ -std::vector & vvStructureSetActor::GetROIList() +std::vector< QSharedPointer > & 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 actor = QSharedPointer(new vvROIActor); + if (old == -1) + mROIActors.push_back(actor); + else + mROIActors[old] = actor; actor->SetBGMode(modeBG); actor->SetROI(roi); actor->SetSlicerManager(mSlicerManager); diff --git a/vv/vvStructureSetActor.h b/vv/vvStructureSetActor.h index ce2434a..6b88cd7 100644 --- a/vv/vvStructureSetActor.h +++ b/vv/vvStructureSetActor.h @@ -21,6 +21,7 @@ #include "clitkDicomRT_StructureSet.h" #include +#include 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 & GetROIList(); + std::vector< QSharedPointer > & GetROIList(); protected: clitk::DicomRT_StructureSet * mStructureSet; vvSlicerManager * mSlicerManager; - std::vector mROIActors; + std::vector< QSharedPointer > mROIActors; std::map mMapROIIndex; }; // end class vvStructureSetActor diff --git a/vv/vvToolStructureSetManager.cxx b/vv/vvToolStructureSetManager.cxx index 2d50d8a..502514d 100644 --- a/vv/vvToolStructureSetManager.cxx +++ b/vv/vvToolStructureSetManager.cxx @@ -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; iGetNumberOfROIs(); 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) {