X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=vv%2FvvToolROIManager.cxx;h=791db06f8922e537dc45409373bbf6884b49468d;hb=0ef2d6ae784a865d069ca5dc77b540f859011848;hp=d5d66ef51848bdfba6413fb0f8f3196faec5840f;hpb=6d66b6a238133e2e237e792e46b27c6e71227d78;p=clitk.git diff --git a/vv/vvToolROIManager.cxx b/vv/vvToolROIManager.cxx index d5d66ef..791db06 100644 --- a/vv/vvToolROIManager.cxx +++ b/vv/vvToolROIManager.cxx @@ -48,6 +48,8 @@ ADD_TOOL(vvToolROIManager); //------------------------------------------------------------------------------ +int vvToolROIManager::nbTotalROI = 0; + //------------------------------------------------------------------------------ vvToolROIManager::vvToolROIManager(vvMainWindowBase * parent, Qt::WindowFlags f): QWidget(parent->GetTab()), @@ -213,8 +215,9 @@ void vvToolROIManager::InitializeNewTool(bool ReadStateFlag) connect(mDepthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(ChangeDepth(int))); connect(mReloadButton, SIGNAL(clicked()), this, SLOT(ReloadCurrentROI())); connect(mCheckBoxShowAll, SIGNAL(stateChanged(int)), this, SLOT(AllVisibleROIToggled(int))); - connect(mContourCheckBoxShowAll, SIGNAL(toggled(bool)), this, SLOT(AllVisibleContourROIToggled(bool))); + connect(mContourCheckBoxShowAll, SIGNAL(stateChanged(int)), this, SLOT(AllVisibleContourROIToggled(int))); connect(mCloseButton, SIGNAL(clicked()), this, SLOT(close())); + connect(mRemoveButton, SIGNAL(clicked()), this, SLOT(RemoveROI())); } //------------------------------------------------------------------------------ @@ -226,13 +229,6 @@ void vvToolROIManager::InputIsSelected(vvSlicerManager *m) mCurrentSlicerManager = m; mCurrentImage = mCurrentSlicerManager->GetImage(); - // Refuse if non 3D image - if (mCurrentImage->GetNumberOfDimensions() != 3) { - QMessageBox::information(this,tr("Warning"), tr("Warning 3D ROI on a 4D image will results in some display bugs")); - //close(); - //return; - } - // Change gui mLabelInputInfo->setText(QString("%1").arg(m->GetFileName().c_str())); @@ -252,6 +248,43 @@ void vvToolROIManager::AnImageIsBeingClosed(vvSlicerManager * m) } //------------------------------------------------------------------------------ +void vvToolROIManager::RemoveROI() +{ + + // Search the indice of the selected ROI + QList l = mTree->selectedItems(); + if (l.size() == 0) + return; + + QTreeWidgetItem * w = l[0]; + if (w == NULL) return; + if (w == 0) return; + if (mMapTreeWidgetToROI.find(w) == mMapTreeWidgetToROI.end()) { + return; + } + + clitk::DicomRT_ROI * roi = mMapTreeWidgetToROI[w]; + if (roi == NULL) return; + + // Get selected roi actor + int n = roi->GetROINumber(); + + disconnect(mTree, SIGNAL(itemSelectionChanged()), this, SLOT(SelectedItemChangedInTree())); + mROIActorsList[n]->RemoveActors(); + mROIActorsList.erase(mROIActorsList.begin()+n); + mROIList.erase(mROIList.begin()+n); + mTreeWidgetList.erase(mTreeWidgetList.begin()+n); + + for (int i = n; i < mROIActorsList.size(); ++i) { + mROIList[i]->SetROINumber(i); + mTreeWidgetList[i].data()->setText(0, QString("%1").arg(mROIList[i]->GetROINumber())); + } + connect(mTree, SIGNAL(itemSelectionChanged()), this, SLOT(SelectedItemChangedInTree())); + for(int i=0; iGetNumberOfSlicers(); i++) { + mCurrentSlicerManager->GetSlicer(i)->Render(); + } +} +//------------------------------------------------------------------------------ //------------------------------------------------------------------------------ void vvToolROIManager::close() @@ -264,6 +297,7 @@ void vvToolROIManager::close() disconnect(mChangeContourColorButton, SIGNAL(clicked()), this, SLOT(ChangeContourColor())); disconnect(mContourWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(ChangeContourWidth(int))); disconnect(mDepthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(ChangeDepth(int))); + disconnect(mRemoveButton, SIGNAL(clicked()), this, SLOT(RemoveROI())); // Remove actors for (unsigned int i = 0; i < mROIActorsList.size(); i++) { @@ -424,8 +458,9 @@ void vvToolROIManager::AddImage(vvImage * binaryImage, } // Compute roi index - int n = mROIList.size(); - + + int n = nbTotalROI; + ++nbTotalROI; // Compute the name of the new ROI // std::ostringstream oss; // oss << vtksys::SystemTools::GetFilenameName(vtksys::SystemTools::GetFilenameWithoutLastExtension(filename)); @@ -439,7 +474,7 @@ void vvToolROIManager::AddImage(vvImage * binaryImage, // Create ROI clitk::DicomRT_ROI::Pointer roi = clitk::DicomRT_ROI::New(); - roi->SetFromBinaryImage(binaryImage, n, name, color, filename); + roi->SetFromBinaryImage(binaryImage, mROIList.size(), name, color, filename); // Add a new roi to the list mROIList.push_back(roi); @@ -467,7 +502,7 @@ void vvToolROIManager::AddImage(vvImage * binaryImage, // CheckBox for "All" if (actor->IsVisible()) mNumberOfVisibleROI++; if (actor->IsContourVisible()) mNumberOfVisibleContourROI++; - AllVisibleContourROIToggled(true); + AllVisibleContourROIToggled(1); // Add ROI in tree mTreeWidgetList.push_back(QSharedPointer(new QTreeWidgetItem(mTree))); @@ -487,6 +522,25 @@ void vvToolROIManager::AddImage(vvImage * binaryImage, // Update UpdateAllROIStatus(); + + if (mCurrentImage->GetNumberOfDimensions() > 3) { + + //Modifications to avoid display bug with a 4D image + QSharedPointer CurrentROIActorTemp; + CurrentROIActorTemp = mCurrentROIActor; + mCurrentROIActor = actor; + + int VisibleInWindow(0); + mCurrentSlicerManager->GetSlicer(VisibleInWindow)->SetCurrentPosition(-VTK_DOUBLE_MAX,-VTK_DOUBLE_MAX,-VTK_DOUBLE_MAX,mCurrentSlicerManager->GetSlicer(VisibleInWindow)->GetMaxCurrentTSlice()); + mCurrentSlicerManager->GetSlicer(VisibleInWindow)->Render(); + + VisibleROIToggled(false); + VisibleROIToggled(true); + + mCurrentROIActor = CurrentROIActorTemp; + + } + } //------------------------------------------------------------------------------ @@ -499,7 +553,7 @@ void vvToolROIManager::UpdateAllContours() for(unsigned int i=0; iUpdate(); } - mCurrentSlicerManager->Render(); + //mCurrentSlicerManager->Render(); } //------------------------------------------------------------------------------ @@ -508,22 +562,31 @@ void vvToolROIManager::UpdateAllContours() void vvToolROIManager::UpdateAllROIStatus() { int nbVisible = 0; + int nbContourVisible = 0; int nb = mROIList.size(); for(int i=0; iIsVisible()) { nbVisible++; } + if (mROIActorsList[i]->IsContourVisible()) { + nbContourVisible++; + } } // change the states disconnect(mCheckBoxShowAll, SIGNAL(stateChanged(int)), this, SLOT(AllVisibleROIToggled(int))); - disconnect(mContourCheckBoxShowAll, SIGNAL(toggled(bool)), this, SLOT(AllVisibleContourROIToggled(bool))); + disconnect(mContourCheckBoxShowAll, SIGNAL(stateChanged(int)), this, SLOT(AllVisibleContourROIToggled(int))); if (nbVisible == nb) mCheckBoxShowAll->setCheckState(Qt::Checked); else { if (nbVisible == 0) mCheckBoxShowAll->setCheckState(Qt::Unchecked); else mCheckBoxShowAll->setCheckState(Qt::PartiallyChecked); } - connect(mContourCheckBoxShowAll, SIGNAL(toggled(bool)), this, SLOT(AllVisibleContourROIToggled(bool))); + if (nbContourVisible == nb) mContourCheckBoxShowAll->setCheckState(Qt::Checked); + else { + if (nbContourVisible == 0) mContourCheckBoxShowAll->setCheckState(Qt::Unchecked); + else mContourCheckBoxShowAll->setCheckState(Qt::PartiallyChecked); + } + connect(mContourCheckBoxShowAll, SIGNAL(stateChanged(int)), this, SLOT(AllVisibleContourROIToggled(int))); connect(mCheckBoxShowAll, SIGNAL(stateChanged(int)), this, SLOT(AllVisibleROIToggled(int))); } //------------------------------------------------------------------------------ @@ -569,6 +632,7 @@ void vvToolROIManager::SelectedItemChangedInTree() disconnect(mChangeContourColorButton, SIGNAL(clicked()), this, SLOT(ChangeContourColor())); disconnect(mContourWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(ChangeContourWidth(int))); disconnect(mDepthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(ChangeDepth(int))); + disconnect(mRemoveButton, SIGNAL(clicked()), this, SLOT(RemoveROI())); mROInameLabel->setText(roi->GetName().c_str()); mCheckBoxShow->setChecked(actor->IsVisible()); @@ -587,6 +651,7 @@ void vvToolROIManager::SelectedItemChangedInTree() connect(mChangeContourColorButton, SIGNAL(clicked()), this, SLOT(ChangeContourColor())); connect(mContourWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(ChangeContourWidth(int))); connect(mDepthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(ChangeDepth(int))); + connect(mRemoveButton, SIGNAL(clicked()), this, SLOT(RemoveROI())); // Set the current color to the selected ROI name @@ -631,6 +696,7 @@ void vvToolROIManager::VisibleContourROIToggled(bool b) if (mCurrentROIActor->IsContourVisible() == b) return; // nothing to do mCurrentROIActor->SetContourVisible(b); mCurrentROIActor->UpdateColor(); + UpdateAllROIStatus(); mCurrentSlicerManager->Render(); } //------------------------------------------------------------------------------ @@ -650,6 +716,7 @@ void vvToolROIManager::OpacityChanged(int v) //------------------------------------------------------------------------------ void vvToolROIManager::AllVisibleROIToggled(int b) { + disconnect(mCheckBoxShowAll, SIGNAL(stateChanged(int)), this, SLOT(AllVisibleROIToggled(int))); bool status = false; if ((mCheckBoxShowAll->checkState() == Qt::Checked) || (mCheckBoxShowAll->checkState() == Qt::PartiallyChecked)) status = true; @@ -661,13 +728,15 @@ void vvToolROIManager::AllVisibleROIToggled(int b) else mCheckBoxShowAll->setCheckState(Qt::Unchecked); mCheckBoxShow->setChecked(status); mCurrentSlicerManager->Render(); + connect(mCheckBoxShowAll, SIGNAL(stateChanged(int)), this, SLOT(AllVisibleROIToggled(int))); } //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ -void vvToolROIManager::AllVisibleContourROIToggled(bool b) +void vvToolROIManager::AllVisibleContourROIToggled(int b) { + disconnect(mContourCheckBoxShowAll, SIGNAL(stateChanged(int)), this, SLOT(AllVisibleContourROIToggled(int))); bool status = false; if ((mContourCheckBoxShowAll->checkState() == Qt::Checked) || (mContourCheckBoxShowAll->checkState() == Qt::PartiallyChecked)) status = true; @@ -680,6 +749,7 @@ void vvToolROIManager::AllVisibleContourROIToggled(bool b) else mContourCheckBoxShowAll->setCheckState(Qt::Unchecked); mContourCheckBoxShow->setChecked(status); mCurrentSlicerManager->Render(); + connect(mContourCheckBoxShowAll, SIGNAL(stateChanged(int)), this, SLOT(AllVisibleContourROIToggled(int))); } //------------------------------------------------------------------------------