X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=vv%2FvvToolROIManager.cxx;h=c092976fba89b7755d8d5547c769228cf1ed2ce0;hb=1067d8bb60a85eab30e875d6a325938b01ec6aaa;hp=c86b4b2018fa89496b042f7780a5b6948e03039c;hpb=3a823a03d4a2217e41e4dd3b05a8ea825bb762a5;p=clitk.git diff --git a/vv/vvToolROIManager.cxx b/vv/vvToolROIManager.cxx index c86b4b2..c092976 100644 --- a/vv/vvToolROIManager.cxx +++ b/vv/vvToolROIManager.cxx @@ -22,7 +22,6 @@ #include "vvImageWriter.h" #include "vvROIActor.h" #include "vvSlicer.h" -#include "vvROIActor.h" #include "vvMeshReader.h" #include "vvStructSelector.h" #include "vvToolManager.h" @@ -54,7 +53,7 @@ vvToolROIManager::vvToolROIManager(vvMainWindowBase * parent, Qt::WindowFlags f) QWidget(parent->GetTab()), vvToolBase(parent), Ui::vvToolROIManager() -{ +{ // Store parent mMainWindow = parent; @@ -94,7 +93,7 @@ vvToolROIManager::vvToolROIManager(vvMainWindowBase * parent, Qt::WindowFlags f) //------------------------------------------------------------------------------ vvToolROIManager::~vvToolROIManager() -{ +{ mROIActorsList.clear(); } //------------------------------------------------------------------------------ @@ -102,7 +101,8 @@ vvToolROIManager::~vvToolROIManager() //------------------------------------------------------------------------------ // STATIC -void vvToolROIManager::Initialize() { +void vvToolROIManager::Initialize() +{ SetToolName("ROIManager"); SetToolMenuName("Open ROI (binary image or RT-STRUCT)"); SetToolIconFilename(":/common/icons/tool-roi.png"); @@ -115,7 +115,7 @@ void vvToolROIManager::Initialize() { //------------------------------------------------------------------------------ void vvToolROIManager::InitializeNewTool(bool ReadStateFlag) -{ +{ // Check if we need to start a new tool or read in the state file to load if (ReadStateFlag == false) { // Select the current image as the target @@ -221,18 +221,11 @@ void vvToolROIManager::InitializeNewTool(bool ReadStateFlag) //------------------------------------------------------------------------------ void vvToolROIManager::InputIsSelected(vvSlicerManager *m) -{ +{ // Initialization 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())); @@ -244,7 +237,7 @@ void vvToolROIManager::InputIsSelected(vvSlicerManager *m) //------------------------------------------------------------------------------ void vvToolROIManager::AnImageIsBeingClosed(vvSlicerManager * m) -{ +{ if (m == mCurrentSlicerManager) { close(); return; @@ -255,7 +248,7 @@ void vvToolROIManager::AnImageIsBeingClosed(vvSlicerManager * m) //------------------------------------------------------------------------------ void vvToolROIManager::close() -{ +{ disconnect(mTree, SIGNAL(itemSelectionChanged()), this, SLOT(SelectedItemChangedInTree())); disconnect(mCheckBoxShow, SIGNAL(toggled(bool)), this, SLOT(VisibleROIToggled(bool))); disconnect(mOpacitySlider, SIGNAL(valueChanged(int)), this, SLOT(OpacityChanged(int))); @@ -280,8 +273,8 @@ void vvToolROIManager::close() //------------------------------------------------------------------------------ -void vvToolROIManager::SelectedImageHasChanged(vvSlicerManager * m) { - +void vvToolROIManager::SelectedImageHasChanged(vvSlicerManager * m) +{ if (mCurrentSlicerManager == NULL) return; if (m == NULL) return; if (m != mCurrentSlicerManager) hide(); @@ -294,7 +287,7 @@ void vvToolROIManager::SelectedImageHasChanged(vvSlicerManager * m) { //------------------------------------------------------------------------------ void vvToolROIManager::Open() -{ +{ // Open images QString Extensions = "Images or Dicom-Struct files ( *.mha *.mhd *.hdr *.his *.dcm RS*)"; Extensions += ";;All Files (*)"; @@ -315,7 +308,7 @@ void vvToolROIManager::Open() //------------------------------------------------------------------------------ void vvToolROIManager::OpenBinaryImage(QStringList & filename) -{ +{ if (filename.size() == 0) return; vvProgressDialog p("Reading ROI ...", true); @@ -359,7 +352,7 @@ void vvToolROIManager::OpenBinaryImage(QStringList & filename) //------------------------------------------------------------------------------ void vvToolROIManager::OpenDicomImage(std::string filename) -{ +{ // GUI selector of roi vvMeshReader reader; reader.SetFilename(filename); @@ -411,7 +404,7 @@ void vvToolROIManager::AddImage(vvImage * binaryImage, std::string name, std::string filename, double BG, bool modeBG) -{ +{ // Check Dimension int dim = mCurrentImage->GetNumberOfDimensions(); int bin_dim = binaryImage->GetNumberOfDimensions(); @@ -467,7 +460,8 @@ void vvToolROIManager::AddImage(vvImage * binaryImage, // CheckBox for "All" if (actor->IsVisible()) mNumberOfVisibleROI++; if (actor->IsContourVisible()) mNumberOfVisibleContourROI++; - + AllVisibleContourROIToggled(true); + // Add ROI in tree mTreeWidgetList.push_back(QSharedPointer(new QTreeWidgetItem(mTree))); QTreeWidgetItem * w = mTreeWidgetList.back().data(); @@ -486,13 +480,32 @@ 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; + + } + } //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ void vvToolROIManager::UpdateAllContours() -{ +{ if (mCurrentSlicerManager == NULL) return; // Render loaded ROIs (the first is sufficient) for(unsigned int i=0; i l = mTree->selectedItems(); if (l.size() == 0) { @@ -610,7 +625,8 @@ void vvToolROIManager::SelectedItemChangedInTree() { //------------------------------------------------------------------------------ -void vvToolROIManager::VisibleROIToggled(bool b) { +void vvToolROIManager::VisibleROIToggled(bool b) +{ if (mCurrentROIActor == NULL) return; if (b == mCurrentROIActor->IsVisible()) return; // nothing to do mCurrentROIActor->SetVisible(b); @@ -621,7 +637,8 @@ void vvToolROIManager::VisibleROIToggled(bool b) { //------------------------------------------------------------------------------ -void vvToolROIManager::VisibleContourROIToggled(bool b) { +void vvToolROIManager::VisibleContourROIToggled(bool b) +{ if (mCurrentROIActor == NULL) return; if (mCurrentROIActor->IsContourVisible() == b) return; // nothing to do mCurrentROIActor->SetContourVisible(b); @@ -632,7 +649,8 @@ void vvToolROIManager::VisibleContourROIToggled(bool b) { //------------------------------------------------------------------------------ -void vvToolROIManager::OpacityChanged(int v) { +void vvToolROIManager::OpacityChanged(int v) +{ if (mCurrentROIActor == NULL) return; mCurrentROIActor->SetOpacity((double)v/100.0); mCurrentROIActor->UpdateColor(); @@ -642,7 +660,8 @@ void vvToolROIManager::OpacityChanged(int v) { //------------------------------------------------------------------------------ -void vvToolROIManager::AllVisibleROIToggled(int b) { +void vvToolROIManager::AllVisibleROIToggled(int b) +{ bool status = false; if ((mCheckBoxShowAll->checkState() == Qt::Checked) || (mCheckBoxShowAll->checkState() == Qt::PartiallyChecked)) status = true; @@ -659,7 +678,8 @@ void vvToolROIManager::AllVisibleROIToggled(int b) { //------------------------------------------------------------------------------ -void vvToolROIManager::AllVisibleContourROIToggled(bool b) { +void vvToolROIManager::AllVisibleContourROIToggled(bool b) +{ bool status = false; if ((mContourCheckBoxShowAll->checkState() == Qt::Checked) || (mContourCheckBoxShowAll->checkState() == Qt::PartiallyChecked)) status = true; @@ -677,7 +697,8 @@ void vvToolROIManager::AllVisibleContourROIToggled(bool b) { //------------------------------------------------------------------------------ -void vvToolROIManager::ChangeColor() { +void vvToolROIManager::ChangeColor() +{ if (mCurrentROIActor == NULL) return; QColor color; color.setRgbF(mCurrentROIActor->GetROI()->GetDisplayColor()[0], @@ -702,7 +723,8 @@ void vvToolROIManager::ChangeColor() { //------------------------------------------------------------------------------ -void vvToolROIManager::ChangeContourColor() { +void vvToolROIManager::ChangeContourColor() +{ if (mCurrentROIActor == NULL) return; QColor color; color.setRgbF(mCurrentROIActor->GetContourColor()[0], @@ -719,7 +741,8 @@ void vvToolROIManager::ChangeContourColor() { //------------------------------------------------------------------------------ -void vvToolROIManager::ChangeContourWidth(int n) { +void vvToolROIManager::ChangeContourWidth(int n) +{ if (mCurrentROIActor == NULL) return; mCurrentROIActor->SetContourWidth(n); mCurrentROIActor->UpdateColor(); @@ -729,7 +752,8 @@ void vvToolROIManager::ChangeContourWidth(int n) { //------------------------------------------------------------------------------ -void vvToolROIManager::ChangeDepth(int n) { +void vvToolROIManager::ChangeDepth(int n) +{ if (mCurrentROIActor == NULL) return; mCurrentROIActor->SetDepth(n); // mCurrentROIActor->UpdateImage(); // FIXME @@ -742,7 +766,8 @@ void vvToolROIManager::ChangeDepth(int n) { //------------------------------------------------------------------------------ -void vvToolROIManager::ReloadCurrentROI() { +void vvToolROIManager::ReloadCurrentROI() +{ if (mCurrentROI->GetFilename() == "") { return; // do nothing (contour from rt struct do not reload) } @@ -783,7 +808,7 @@ void vvToolROIManager::ReloadCurrentROI() { //------------------------------------------------------------------------------ void vvToolROIManager::SaveState(std::auto_ptr & m_XmlWriter) -{ +{ // Get index of the image int n = mMainWindow->GetSlicerManagers().size(); int index=-1; @@ -829,7 +854,7 @@ void vvToolROIManager::SaveState(std::auto_ptr & m_XmlWriter) //------------------------------------------------------------------------------ void vvToolROIManager::ReadXMLInformation() -{ +{ std::string value=""; mInitialImageIndex = -1; while (!(m_XmlReader->isEndElement() && value == GetToolName().toStdString())) { @@ -851,7 +876,7 @@ void vvToolROIManager::ReadXMLInformation() //------------------------------------------------------------------------------ void vvToolROIManager::ReadXMLInformation_ROI() -{ +{ QString s; std::string value=""; QSharedPointer param = QSharedPointer(new vvROIActor);