From cb4f548b5df0172cc7fad02345d7eb3d7a4fa3aa Mon Sep 17 00:00:00 2001 From: dsarrut Date: Tue, 27 Apr 2010 06:07:02 +0000 Subject: [PATCH] - bug corrected --- vv/vvBinaryImageOverlayActor.cxx | 8 +++ vv/vvBinaryImageOverlayActor.h | 1 + vv/vvImageContour.cxx | 18 +++---- vv/vvImageContour.h | 2 +- vv/vvROIActor.cxx | 39 +++++++++++++- vv/vvROIActor.h | 6 +++ vv/vvSlicer.cxx | 3 ++ vv/vvStructureSetActor.cxx | 2 + vv/vvToolStructureSetManager.cxx | 88 ++++++++++++++++++++++++-------- vv/vvToolStructureSetManager.h | 5 ++ 10 files changed, 140 insertions(+), 32 deletions(-) diff --git a/vv/vvBinaryImageOverlayActor.cxx b/vv/vvBinaryImageOverlayActor.cxx index 1ea3c6f..d69879c 100644 --- a/vv/vvBinaryImageOverlayActor.cxx +++ b/vv/vvBinaryImageOverlayActor.cxx @@ -111,6 +111,14 @@ void vvBinaryImageOverlayActor::initialize() { //------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ +void vvBinaryImageOverlayActor::SetOpacity(double d) { + mAlpha = d; + // TODO !!lut->SetTableValue(1, mColor[0], mColor[1], mColor[2], mAlpha); // FG +} +//------------------------------------------------------------------------------ + + //------------------------------------------------------------------------------ void vvBinaryImageOverlayActor::setImage(vvImage::Pointer image, double bg) { mImage = image; diff --git a/vv/vvBinaryImageOverlayActor.h b/vv/vvBinaryImageOverlayActor.h index f33014d..ccf08ef 100644 --- a/vv/vvBinaryImageOverlayActor.h +++ b/vv/vvBinaryImageOverlayActor.h @@ -43,6 +43,7 @@ class vvBinaryImageOverlayActor void setColor(double r, double g, double b); void setImage(vvImage::Pointer image, double bg); void initialize(); + void SetOpacity(double d); protected: vvSlicer * mSlicer; diff --git a/vv/vvImageContour.cxx b/vv/vvImageContour.cxx index 3521579..1c5354e 100644 --- a/vv/vvImageContour.cxx +++ b/vv/vvImageContour.cxx @@ -282,8 +282,8 @@ void vvImageContour::createNewActor(vtkActor ** actor, void vvImageContour::updateActor(vtkActor * actor, vtkMarchingSquares * squares, vtkImageClip * clipper, - int threshold, int orientation, int slice) { - + double threshold, int orientation, int slice) { + // Set parameter for the MarchigSquare squares->SetValue(0, threshold); @@ -320,15 +320,15 @@ void vvImageContour::updateActor(vtkActor * actor, if (mHiddenImage) delete extent2; // Move the actor to be visible - DD(orientation); - DD(slice); + // DD(orientation); +// DD(slice); //TO SIMPLiFY :!!!!!!!!! == ??????? // actor->SetPosition(-1,-1,-1); switch (orientation) { case 0: - DD(mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[0]); + // DD(mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[0]); if (mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[0] > slice) { actor->SetPosition(1,0,0); } @@ -337,7 +337,7 @@ void vvImageContour::updateActor(vtkActor * actor, } break; case 1: - DD(mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[1]); + // DD(mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[1]); if (mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[1] > slice) { actor->SetPosition(0,1,0); } @@ -346,13 +346,13 @@ void vvImageContour::updateActor(vtkActor * actor, } break; case 2: - DD(mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[2]); + // DD(mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[2]); if (mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[2] > slice) { - DD("1"); + // DD("1"); actor->SetPosition(0,0,1); } else { - DD("-1"); + // DD("-1"); actor->SetPosition(0,0,-1); } break; diff --git a/vv/vvImageContour.h b/vv/vvImageContour.h index 12bb2dc..d7cf62c 100644 --- a/vv/vvImageContour.h +++ b/vv/vvImageContour.h @@ -73,7 +73,7 @@ class vvImageContour void updateActor(vtkActor * actor, vtkMarchingSquares * squares, vtkImageClip * clipper, - int threshold, int orientation, int slice); + double threshold, int orientation, int slice); void createActor(int orientation, int slice); int computeCurrentOrientation(); diff --git a/vv/vvROIActor.cxx b/vv/vvROIActor.cxx index f1eb222..13e906b 100644 --- a/vv/vvROIActor.cxx +++ b/vv/vvROIActor.cxx @@ -34,6 +34,7 @@ vvROIActor::vvROIActor() { mImageContour.clear(); mOverlayActors.clear(); + mIsVisible = true; } //------------------------------------------------------------------------------ @@ -58,6 +59,29 @@ void vvROIActor::SetSlicerManager(vvSlicerManager * s) { //------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ +void vvROIActor::SetVisible(bool b) { + mIsVisible = b; + if (!b) { // remove actor + for(unsigned int i= 0; ihideActors(); + } + else { + for(unsigned int i= 0; ishowActors(); + } + Update(); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +bool vvROIActor::IsVisible() { + return mIsVisible; +} +//------------------------------------------------------------------------------ + + //------------------------------------------------------------------------------ void vvROIActor::Initialize() { if (mROI->GetImage()) { @@ -101,7 +125,9 @@ void vvROIActor::Update() { //------------------------------------------------------------------------------ void vvROIActor::UpdateSlice(int slicer, int slices) { - if (!mROI->GetImage()) return; + if (!mROI->GetImage()) return; + + if (!mIsVisible) return; if (!mSlicerManager) { std::cerr << "Error. No mSlicerManager ?" << std::endl; @@ -118,3 +144,14 @@ void vvROIActor::UpdateSlice(int slicer, int slices) { // mSlicerManager->GetSlicer(slicer)->GetRenderWindow()->Render(); } //------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvROIActor::SetOpacity(double d) { + mOpacity = d; + for(unsigned int i=0; mOverlayActors.size(); i++) { + mOverlayActors[i]->SetOpacity(d); + } +} +//------------------------------------------------------------------------------ + diff --git a/vv/vvROIActor.h b/vv/vvROIActor.h index 016a103..afe7636 100644 --- a/vv/vvROIActor.h +++ b/vv/vvROIActor.h @@ -38,6 +38,9 @@ class vvROIActor: public QObject { void SetSlicerManager(vvSlicerManager * s); void Update(); void Initialize(); + void SetVisible(bool b); + bool IsVisible(); + void SetOpacity(double x); public slots: void UpdateSlice(int slicer, int slices); @@ -47,6 +50,9 @@ public slots: vvSlicerManager * mSlicerManager; std::vector mImageContour; std::vector mOverlayActors; + + bool mIsVisible; + double mOpacity; }; // end class vvROIActor //------------------------------------------------------------------------------ diff --git a/vv/vvSlicer.cxx b/vv/vvSlicer.cxx index 256981f..415d4a8 100644 --- a/vv/vvSlicer.cxx +++ b/vv/vvSlicer.cxx @@ -1375,6 +1375,9 @@ void vvSlicer::SetSlice(int slice) SetContourSlice(); this->Modified(); this->UpdateDisplayExtent(); + + // DD("SetSlice de slicer = Render"); + this->Render(); } //---------------------------------------------------------------------------- diff --git a/vv/vvStructureSetActor.cxx b/vv/vvStructureSetActor.cxx index 819a653..16df512 100644 --- a/vv/vvStructureSetActor.cxx +++ b/vv/vvStructureSetActor.cxx @@ -48,10 +48,12 @@ void vvStructureSetActor::SetSlicerManager(vvSlicerManager * s) { //------------------------------------------------------------------------------ vvROIActor * vvStructureSetActor::GetROIActor(int n) { + DD(n); if (mMapROIIndex.find(n) == mMapROIIndex.end()) { std::cerr << "No ROI number " << n << std::endl; return NULL; } + DD(mMapROIIndex[n]); return mROIActors[mMapROIIndex[n]]; } //------------------------------------------------------------------------------ diff --git a/vv/vvToolStructureSetManager.cxx b/vv/vvToolStructureSetManager.cxx index ac53fb5..5fcd2af 100644 --- a/vv/vvToolStructureSetManager.cxx +++ b/vv/vvToolStructureSetManager.cxx @@ -94,28 +94,9 @@ void vvToolStructureSetManager::InputIsSelected(vvSlicerManager *m) { // connect(m, SIGNAL(LeftButtonReleaseSignal(int)), SLOT(LeftButtonReleaseEvent(int))); connect(mTree, SIGNAL(itemSelectionChanged()), this, SLOT(selectedItemChangedInTree())); -} -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -void vvToolStructureSetManager::selectedItemChangedInTree() { - DD("selectedItemChangedInTree"); - QList l = mTree->selectedItems(); - DD(l.size()); - QTreeWidgetItem * w = l[0]; - if (mMapTreeWidgetToROI.find(w) == mMapTreeWidgetToROI.end()) return; // Search for SS (first) - clitk::DicomRT_ROI * roi = mMapTreeWidgetToROI[w]; - DD(roi->GetName()); - setCurrentSelectedROI(roi); -} -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -void vvToolStructureSetManager::setCurrentSelectedROI(clitk::DicomRT_ROI * roi) { - // mCheckBoxShow = // get roi actor .../ + connect(mCheckBoxShow, SIGNAL(toggled(bool)), this, SLOT(visibleROIToggled(bool))); + // TODO connect(mOpacitySlider, SIGNAL(valueChanged(int), this, SLOT(opacityChanged(int)))); } //------------------------------------------------------------------------------ @@ -235,6 +216,7 @@ void vvToolStructureSetManager::openBinaryImage() { mCurrentStructureSet = mStructureSetsList[index]; mCurrentStructureSetActor = mStructureSetActorsList[index]; mCurrentStructureSetIndex = index; + DD(mCurrentStructureSetIndex); DD(mCurrentStructureSet->GetName()); // Open images @@ -323,3 +305,67 @@ void vvToolStructureSetManager::apply() { close(); } //------------------------------------------------------------------------------ + + + +//------------------------------------------------------------------------------ +// CURRENT ROI INTERACTION +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolStructureSetManager::selectedItemChangedInTree() { + DD("selectedItemChangedInTree"); + QList l = mTree->selectedItems(); + DD(l.size()); + QTreeWidgetItem * w = l[0]; + if (mMapTreeWidgetToROI.find(w) == mMapTreeWidgetToROI.end()) return; // Search for SS (first) + clitk::DicomRT_ROI * roi = mMapTreeWidgetToROI[w]; + DD(roi->GetName()); + //setCurrentSelectedROI(roi); + + mROInameLabel->setText(roi->GetName().c_str()); + DD(roi->GetROINumber()); + DD(mCurrentStructureSetIndex); + vvROIActor * actor = mStructureSetActorsList[mCurrentStructureSetIndex]->GetROIActor(roi->GetROINumber()); + mCurrentROI = roi; + mCurrentROIActor = actor; + + DD(actor); + DD(actor->IsVisible()); + mCheckBoxShow->setChecked(actor->IsVisible()); + + //actor->SetSelected(true); // remove old selection + + DD("ici"); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolStructureSetManager::visibleROIToggled(bool b) { + DD(b); + mCurrentROIActor->SetVisible(b); + //mCurrentROIActor->Update(); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolStructureSetManager::opacityChanged(int v) { + DD(v); + mCurrentROIActor->SetOpacity((double)v/100.0); + mCurrentROIActor->Update(); +} +//------------------------------------------------------------------------------ + + + + +//------------------------------------------------------------------------------ +//void vvToolStructureSetManager::getActorFromROI() { +// mStructureSetActorsList[mCurrentStructureSetIndex]->GetROIActor(n); +//} +//------------------------------------------------------------------------------ + + diff --git a/vv/vvToolStructureSetManager.h b/vv/vvToolStructureSetManager.h index 0295513..8421473 100644 --- a/vv/vvToolStructureSetManager.h +++ b/vv/vvToolStructureSetManager.h @@ -24,6 +24,7 @@ #include "vvToolWidgetBase.h" #include "clitkDicomRT_StructureSet.h" #include "ui_vvToolStructureSetManager.h" +#include "vvROIActor.h" class vvStructureSetActor; @@ -51,12 +52,16 @@ public slots: void LeftButtonReleaseEvent(int slicer); void openBinaryImage(); void selectedItemChangedInTree(); + void visibleROIToggled(bool b); + void opacityChanged(int v); protected: Ui::vvToolStructureSetManager ui; clitk::DicomRT_StructureSet * mCurrentStructureSet; vvStructureSetActor * mCurrentStructureSetActor; int mCurrentStructureSetIndex; + clitk::DicomRT_ROI * mCurrentROI; + vvROIActor * mCurrentROIActor; vtkLookupTable * mDefaultLUTColor; void setCurrentSelectedROI(clitk::DicomRT_ROI * roi); -- 2.47.1