]> Creatis software - clitk.git/blobdiff - vv/vvToolStructureSetManager.cxx
changes in license header
[clitk.git] / vv / vvToolStructureSetManager.cxx
index 502514d2e1ee82eef530ebdc8fbfe80e546d2c68..16d53cb91cce2c0bcf8d5ed9dfe10c7e2bf693aa 100644 (file)
@@ -3,7 +3,7 @@
 
   Authors belong to:
   - University of LYON              http://www.universite-lyon.fr/
-  - Léon Bérard cancer center       http://oncora1.lyon.fnclcc.fr
+  - Léon Bérard cancer center       http://www.centreleonberard.fr
   - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
 
   This software is distributed WITHOUT ANY WARRANTY; without even
@@ -14,7 +14,7 @@
 
   - BSD        See included LICENSE.txt file
   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
-  ======================================================================-====*/
+  ===========================================================================**/
 
 // vv
 #include "vvToolStructureSetManager.h"
@@ -27,7 +27,8 @@
 #include <QFileDialog>
 #include <QMessageBox>
 #include <QColorDialog>
-
+#include <QAbstractEventDispatcher>
 // vtk
 #include <vtkLookupTable.h>
 #include <vtkRenderWindow.h>
@@ -100,6 +101,14 @@ vvToolStructureSetManager::vvToolStructureSetManager(vvMainWindowBase * parent,
 vvToolStructureSetManager::~vvToolStructureSetManager()
 {
   m_NumberOfTool--;
+  
+  // clearing the list at this point avoids
+  // segfaulting due to events being dispatched
+  // after object destruction
+  mTreeWidgetList.clear();
+  mTree->clearSelection();
+
+  //std::cout << "vvToolStructureSetManager::~vvToolStructureSetManager()" << std::endl;
 }
 //------------------------------------------------------------------------------
 
@@ -119,6 +128,8 @@ void vvToolStructureSetManager::Initialize() {
 //------------------------------------------------------------------------------
 void vvToolStructureSetManager::InputIsSelected(vvSlicerManager *m)
 {
+  //std::cout << "vvToolStructureSetManager::InputIsSelected()" << std::endl;
+  
   //int mTabNumber = parent->GetTab()->addTab(this, "");
   //  this->setFixedWidth(120);
   //this->setPreferedHeight(441);  
@@ -250,7 +261,7 @@ void vvToolStructureSetManager::OpenBinaryImage()
     std::vector<std::string> filenames;
     filenames.push_back(filename[i].toStdString());
     reader->SetInputFilenames(filenames);
-    reader->Update(IMAGE);
+    reader->Update(vvImageReader::IMAGE);
     QApplication::restoreOverrideCursor();
 
     if (reader->GetLastError().size() != 0) {
@@ -261,10 +272,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();
 }
 //------------------------------------------------------------------------------
@@ -356,6 +367,8 @@ void vvToolStructureSetManager::apply()
 //------------------------------------------------------------------------------
 bool vvToolStructureSetManager::close()
 {
+  //std::cout << "vvToolStructureSetManager::close()" << std::endl;
+
   return vvToolWidgetBase::close();
 }
 //------------------------------------------------------------------------------
@@ -364,6 +377,8 @@ bool vvToolStructureSetManager::close()
 //------------------------------------------------------------------------------
 void vvToolStructureSetManager::closeEvent(QCloseEvent *event) 
 {
+  //std::cout << "vvToolStructureSetManager::closeEvent()" << std::endl;
+
   std::vector<vvSlicerManager*>::iterator iter = std::find(mListOfInputs.begin(), mListOfInputs.end(), mCurrentSlicerManager);
   if (iter != mListOfInputs.end()) mListOfInputs.erase(iter);
   
@@ -393,6 +408,7 @@ void vvToolStructureSetManager::closeEvent(QCloseEvent *event)
 
 //------------------------------------------------------------------------------
 void vvToolStructureSetManager::SelectedItemChangedInTree() {
+  
   // Search which roi is selected
   QList<QTreeWidgetItem *> l = mTree->selectedItems();
   if (l.size() == 0) {
@@ -402,6 +418,8 @@ void vvToolStructureSetManager::SelectedItemChangedInTree() {
     return;
   }
   QTreeWidgetItem * w = l[0];
+  //std::cout << "selected item -> " << w->text(1).toStdString() << std::endl;
+  //std::cout << "m_NumberOfTool -> " << m_NumberOfTool << std::endl;
   if (mMapTreeWidgetToROI.find(w) == mMapTreeWidgetToROI.end()) {
     mCurrentROIActor = NULL;
     mCurrentROI = NULL;
@@ -575,7 +593,7 @@ void vvToolStructureSetManager::ReloadCurrentROI() {
   // Reload image
   vvImageReader::Pointer reader = vvImageReader::New();
   reader->SetInputFilename(mCurrentROI->GetFilename());
-  reader->Update(IMAGE);
+  reader->Update(vvImageReader::IMAGE);
   if (reader->GetLastError() != "") {
     QMessageBox::information(mMainWindowBase, tr("Sorry, error. Could not reload"), reader->GetLastError().c_str());
     return;