X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=vv%2FvvToolStructureSetManager.cxx;h=151435faaf2c4d8f7f8480eaa79101029c431ba5;hb=6f9b6f5da142c3c2e7c8a2ff8d0a517b90b240d3;hp=2d50d8a6d0b8836020bf196012d8fed2220baf72;hpb=fad7d69a7df544d05deaa19b81bd770aa4c7dd47;p=clitk.git diff --git a/vv/vvToolStructureSetManager.cxx b/vv/vvToolStructureSetManager.cxx index 2d50d8a..151435f 100644 --- a/vv/vvToolStructureSetManager.cxx +++ b/vv/vvToolStructureSetManager.cxx @@ -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 #include #include - +#include + // vtk #include #include @@ -99,8 +100,15 @@ vvToolStructureSetManager::vvToolStructureSetManager(vvMainWindowBase * parent, //------------------------------------------------------------------------------ vvToolStructureSetManager::~vvToolStructureSetManager() { - disconnect(mTree, SIGNAL(itemSelectionChanged()), this, SLOT(SelectedItemChangedInTree())); 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; } //------------------------------------------------------------------------------ @@ -120,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); @@ -127,6 +137,7 @@ void vvToolStructureSetManager::InputIsSelected(vvSlicerManager *m) if (mCurrentImage->GetNumberOfDimensions() != 3) { QMessageBox::information(this,tr("Sorry only 3D yet"), tr("Sorry only 3D yet")); close(); + return; } // Hide selector HideInputSelector(); // splitter @@ -251,7 +262,7 @@ void vvToolStructureSetManager::OpenBinaryImage() std::vector filenames; filenames.push_back(filename[i].toStdString()); reader->SetInputFilenames(filenames); - reader->Update(IMAGE); + reader->Update(vvImageReader::IMAGE); QApplication::restoreOverrideCursor(); if (reader->GetLastError().size() != 0) { @@ -265,6 +276,7 @@ void vvToolStructureSetManager::OpenBinaryImage() AddImage(binaryImage, filename[i].toStdString(), mBackgroundValueSpinBox->value()); mOpenedBinaryImage.push_back(binaryImage); } + UpdateImage(); } //------------------------------------------------------------------------------ @@ -356,6 +368,8 @@ void vvToolStructureSetManager::apply() //------------------------------------------------------------------------------ bool vvToolStructureSetManager::close() { + //std::cout << "vvToolStructureSetManager::close()" << std::endl; + return vvToolWidgetBase::close(); } //------------------------------------------------------------------------------ @@ -364,6 +378,8 @@ bool vvToolStructureSetManager::close() //------------------------------------------------------------------------------ void vvToolStructureSetManager::closeEvent(QCloseEvent *event) { + //std::cout << "vvToolStructureSetManager::closeEvent()" << std::endl; + std::vector::iterator iter = std::find(mListOfInputs.begin(), mListOfInputs.end(), mCurrentSlicerManager); if (iter != mListOfInputs.end()) mListOfInputs.erase(iter); @@ -372,14 +388,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) { @@ -399,6 +409,7 @@ void vvToolStructureSetManager::closeEvent(QCloseEvent *event) //------------------------------------------------------------------------------ void vvToolStructureSetManager::SelectedItemChangedInTree() { + // Search which roi is selected QList l = mTree->selectedItems(); if (l.size() == 0) { @@ -408,6 +419,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; @@ -581,7 +594,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;