From: dsarrut Date: Tue, 15 Feb 2011 11:33:47 +0000 (+0000) Subject: correct bug when reload X-Git-Tag: v1.2.0~240 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=7d7668046785090bc4ded5d15da5f94586af8a4d;p=clitk.git correct bug when reload --- diff --git a/vv/vvBinaryImageOverlayActor.cxx b/vv/vvBinaryImageOverlayActor.cxx index a30206f..907bcb6 100644 --- a/vv/vvBinaryImageOverlayActor.cxx +++ b/vv/vvBinaryImageOverlayActor.cxx @@ -77,7 +77,7 @@ void vvBinaryImageOverlayActor::SetSlicer(vvSlicer * slicer) //------------------------------------------------------------------------------ -void vvBinaryImageOverlayActor::Initialize() +void vvBinaryImageOverlayActor::Initialize(bool IsVisible) { if (!mSlicer) { std::cerr << "ERROR. Please use setSlicer before setSlicer in vvBinaryImageOverlayActor." << std::endl; @@ -94,11 +94,8 @@ void vvBinaryImageOverlayActor::Initialize() vtkImageMapToRGBA * mOverlayMapper = vtkImageMapToRGBA::New(); mOverlayMapper->SetInput(mImage->GetVTKImages()[0]); // DS TODO : to change if it is 4D !!! - // DD("change to nb of intensity"); double range[2]; mImage->GetVTKImages()[0]->GetScalarRange(range); - // DD(range[0]); -// DD(range[1]); int n = range[1]-range[0]+1; mColorLUT->SetRange(range[0],range[1]); mColorLUT->SetNumberOfTableValues(n); @@ -123,7 +120,7 @@ void vvBinaryImageOverlayActor::Initialize() vtkImageActor * mOverlayActor = vtkImageActor::New(); mOverlayActor->SetInput(mOverlayMapper->GetOutput()); mOverlayActor->SetPickable(0); - mOverlayActor->SetVisibility(true); + mOverlayActor->SetVisibility(IsVisible); //mOverlayActor->SetOpacity(1.0); mMapperList.push_back(mOverlayMapper); @@ -179,8 +176,6 @@ void vvBinaryImageOverlayActor::SetOpacity(double d) //------------------------------------------------------------------------------ void vvBinaryImageOverlayActor::SetImage(vvImage::Pointer image, double bg, bool modeBG) { - // DD("vvBinaryImageOverlayActor::SetImage"); - //DD(modeBG); mImage = image; if (modeBG) { mBackgroundValue = bg; @@ -282,9 +277,6 @@ void vvBinaryImageOverlayActor::ComputeExtent(int orientation, int * inExtent, int * outExtent) { - // std::cout << "InExtent = " << inExtent[0] << " " << inExtent[1] << " " << inExtent[2] << " " - // << inExtent[3] << " " << inExtent[4] << " " << inExtent[5] << std::endl; - // DD(orientation); switch (orientation) { case vtkImageViewer2::SLICE_ORIENTATION_XY: for(int i=0; i<4; i++) outExtent[i] = inExtent[i]; @@ -300,8 +292,6 @@ void vvBinaryImageOverlayActor::ComputeExtent(int orientation, outExtent[0] = outExtent[1] = slice; break; } - // std::cout << "OutExtent = " << outExtent[0] << " " << outExtent[1] << " " << outExtent[2] << " " - // << outExtent[3] << " " << outExtent[4] << " " << outExtent[5] << std::endl; } //------------------------------------------------------------------------------ diff --git a/vv/vvBinaryImageOverlayActor.h b/vv/vvBinaryImageOverlayActor.h index fedd284..eb8a3ad 100644 --- a/vv/vvBinaryImageOverlayActor.h +++ b/vv/vvBinaryImageOverlayActor.h @@ -40,7 +40,7 @@ class vvBinaryImageOverlayActor void SetColor(double r, double g, double b); void SetOpacity(double d); void SetImage(vvImage::Pointer image, double bg, bool modeBG=true); - void Initialize(); + void Initialize(bool IsVisible=true); void UpdateColor(); void UpdateSlice(int slicer, int slice); void HideActors(); diff --git a/vv/vvImageContour.cxx b/vv/vvImageContour.cxx index 99da398..1ee32cf 100644 --- a/vv/vvImageContour.cxx +++ b/vv/vvImageContour.cxx @@ -33,7 +33,8 @@ vvImageContour::vvImageContour() mTSlice = -1; mSlice = 0; mHiddenImageIsUsed = false; - mDisplayModeIsPreserveMemory = true; + mDisplayModeIsPreserveMemory = false; + SetPreserveMemoryModeEnabled(false); } //------------------------------------------------------------------------------ @@ -133,22 +134,18 @@ void vvImageContour::ShowActors() { if (!mSlicer) return; mSlice = mSlicer->GetSlice(); mTSlice = mSlicer->GetTSlice(); - // for(unsigned int i=0; iVisibilityOn(); Update(mValue); - //} } //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ void vvImageContour::Update(double value) { - // DD(value); if (!mSlicer) return; if (mPreviousValue == value) { if (mPreviousSlice == mSlicer->GetSlice()) { if (mPreviousTSlice == mSlicer->GetTSlice()) { - // DD("vvImageContour::update nothing"); return; // Nothing to do } } @@ -159,7 +156,7 @@ void vvImageContour::Update(double value) { // Get current slice mSlice = mSlicer->GetSlice(); - // DD(mDisplayModeIsPreserveMemory); + if (mDisplayModeIsPreserveMemory) { UpdateWithPreserveMemoryMode(); } @@ -179,27 +176,17 @@ void vvImageContour::Update(double value) { //------------------------------------------------------------------------------ void vvImageContour::UpdateWithPreserveMemoryMode() { // Only change actor visibility if tslice change - //DD(mTSlice); - //DD(mSlice); int mPreviousTslice = mTSlice; - // ; - // if (mTSlice != mSlicer->GetTSlice()) { - // if (mTSlice != -1) mTsliceToSetOff = mTSlice; - // mSquaresActorList[mTSlice]->VisibilityOff(); mTSlice = mSlicer->GetTSlice(); - // } - // else return; - // DD(mTSlice); + vtkMarchingSquares * mSquares = mSquaresList[mTSlice]; vtkImageClip * mClipper = mClipperList[mTSlice]; vtkActor * mSquaresActor = mSquaresActorList[mTSlice]; int orientation = ComputeCurrentOrientation(); - // DD(orientation); - //DD(mValue); - //DD(mSlice); - //DD(mPreviousTslice); + UpdateActor(mSquaresActor, mSquares, mClipper, mValue, orientation, mSlice); mSquaresActorList[mTSlice]->VisibilityOn(); + if (mPreviousTslice != mTSlice) { if (mPreviousTslice != -1) mSquaresActorList[mPreviousTslice]->VisibilityOff(); } @@ -215,7 +202,6 @@ void vvImageContour::InitializeCacheMode() { mListOfCachedContourActors.resize(dim); for(int d=0; dGetImage()->GetSize()[d]; - //DD(size); mListOfCachedContourActors[d].resize(size); for(int j=0; jSetValue(0, threshold); // Get image extent @@ -314,6 +300,7 @@ void vvImageContour::UpdateActor(vtkActor * actor, extent2 = new int[6]; int * extent3; extent3 = mHiddenImage->GetFirstVTKImageData()->GetExtent(); + for(int i=0; i<6; i++) extent2[i] = extent3[i]; double s = (double)extent[orientation*2]*(double)mSlicer->GetImage()->GetSpacing()[orientation]; // in mm @@ -327,47 +314,58 @@ void vvImageContour::UpdateActor(vtkActor * actor, extent2[orientation*2] = (int)floor(s); extent2[orientation*2+1] = extent2[orientation*2]; } + + // Do not display a contour if there is no contour on this slice + if (extent2[orientation*2+1] > extent3[orientation*2+1]) { + actor->VisibilityOff(); + return; + } + else actor->VisibilityOn(); + } else { extent2 = extent; } + clipper->SetOutputWholeExtent(extent2[0],extent2[1],extent2[2], extent2[3],extent2[4],extent2[5]); if (mHiddenImage) delete extent2; // Move the actor to be visible - // DD(orientation); - // DD(slice); - - //TO SIMPLiFY :!!!!!!!!! == ??????? - // actor->SetPosition(-1,-1,-1); - switch (orientation) { case 0: + actor->SetPosition(-1,0,0); + /* // DD(mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[0]); if (mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[0] > slice) { - actor->SetPosition(1,0,0); + actor->SetPosition(1,0,0); } else { actor->SetPosition(-1,0,0); - } + }*/ break; case 1: + actor->SetPosition(0,-1,0); + /* // DD(mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[1]); if (mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[1] > slice) { actor->SetPosition(0,1,0); } else { actor->SetPosition(0,-1,0); } + */ break; case 2: - // DD(mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[2]); + actor->SetPosition(0,0,-1); + /* + 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/vvROIActor.cxx b/vv/vvROIActor.cxx index 7a07b29..90e507e 100644 --- a/vv/vvROIActor.cxx +++ b/vv/vvROIActor.cxx @@ -88,7 +88,7 @@ void vvROIActor::UpdateImage() mImageContour[i]->HideActors(); delete mImageContour[i]; } - Initialize(); + Initialize(mIsVisible); Update(); // No Render } //------------------------------------------------------------------------------ @@ -143,7 +143,7 @@ bool vvROIActor::IsContourVisible() { //------------------------------------------------------------------------------ -void vvROIActor::Initialize() { +void vvROIActor::Initialize(bool IsVisible) { if (mROI->GetImage()) { mImageContour.clear(); mOverlayActors.clear(); @@ -157,6 +157,7 @@ void vvROIActor::Initialize() { mImageContour[i]->SetColor(mContourColor[0], mContourColor[1], mContourColor[2]); mImageContour[i]->SetLineWidth(mContourWidth); mImageContour[i]->SetPreserveMemoryModeEnabled(true); + //mImageContour[i]->SetPreserveMemoryModeEnabled(false); // SEG FAULT !!! mImageContour[i]->SetSlicer(mSlicerManager->GetSlicer(i)); mImageContour[i]->HideActors(); @@ -176,7 +177,7 @@ void vvROIActor::Initialize() { mROI->GetDisplayColor()[2]); mOverlayActors[i]->SetOpacity(mOpacity); mOverlayActors[i]->SetSlicer(mSlicerManager->GetSlicer(i)); - mOverlayActors[i]->Initialize(); + mOverlayActors[i]->Initialize(IsVisible); } connect(mSlicerManager,SIGNAL(UpdateSlice(int,int)),this,SLOT(UpdateSlice(int, int))); @@ -271,7 +272,6 @@ double vvROIActor::GetOpacity() //------------------------------------------------------------------------------ void vvROIActor::SetSelected(bool b) { - DD(" Not used yet"); mIsSelected = b; if (b) { for(int i=0; iNumberOfSlicers(); i++) { diff --git a/vv/vvROIActor.h b/vv/vvROIActor.h index 52142bb..d20259e 100644 --- a/vv/vvROIActor.h +++ b/vv/vvROIActor.h @@ -38,7 +38,7 @@ class vvROIActor: public QObject { clitk::DicomRT_ROI * GetROI() { return mROI; } void SetSlicerManager(vvSlicerManager * s); void Update(); - void Initialize(); + void Initialize(bool IsVisible=true); void SetVisible(bool b); void SetContourVisible(bool b); bool IsVisible();