From 0d2c2b622e94b353cef04e5bd39d9f8de7b0d6a7 Mon Sep 17 00:00:00 2001 From: dsarrut Date: Wed, 19 May 2010 06:08:12 +0000 Subject: [PATCH] - update function name (with Uppercase) --- vv/vvImageContour.cxx | 86 +++++++++++++----------------- vv/vvImageContour.h | 28 +++++----- vv/vvROIActor.cxx | 110 ++++++++++++++++++++++++++++++--------- vv/vvROIActor.h | 9 ++++ vv/vvStructureSetActor.h | 4 +- vv/vvToolBinarize.cxx | 62 +++++++++++----------- 6 files changed, 180 insertions(+), 119 deletions(-) diff --git a/vv/vvImageContour.cxx b/vv/vvImageContour.cxx index 56024c8..0e4e428 100644 --- a/vv/vvImageContour.cxx +++ b/vv/vvImageContour.cxx @@ -52,15 +52,14 @@ vvImageContour::~vvImageContour() //------------------------------------------------------------------------------ -void vvImageContour::setSlicer(vvSlicer * slicer) -{ - mSlicer = slicer; +void vvImageContour::SetSlicer(vvSlicer * slicer) { + mSlicer = slicer; // Create an actor for each time slice for (unsigned int numImage = 0; numImage < mSlicer->GetImage()->GetVTKImages().size(); numImage++) { vtkImageClip * mClipper = vtkImageClip::New(); vtkMarchingSquares * mSquares = vtkMarchingSquares::New(); vtkActor * mSquaresActor = vtkActor::New(); - createNewActor(&mSquaresActor, &mSquares, &mClipper, numImage); + CreateNewActor(&mSquaresActor, &mSquares, &mClipper, numImage); mSquaresActorList.push_back(mSquaresActor); mSquaresList.push_back(mSquares); mClipperList.push_back(mClipper); @@ -70,8 +69,7 @@ void vvImageContour::setSlicer(vvSlicer * slicer) //------------------------------------------------------------------------------ -void vvImageContour::setImage(vvImage::Pointer image) -{ +void vvImageContour::SetImage(vvImage::Pointer image) { for (unsigned int numImage = 0; numImage < image->GetVTKImages().size(); numImage++) { mClipperList[numImage]->SetInput(image->GetVTKImages()[numImage]); } @@ -82,27 +80,26 @@ void vvImageContour::setImage(vvImage::Pointer image) //------------------------------------------------------------------------------ -void vvImageContour::setPreserveMemoryModeEnabled(bool b) -{ +void vvImageContour::SetPreserveMemoryModeEnabled(bool b) { // FastCache mode work only if threshold is always the same if (mDisplayModeIsPreserveMemory == b) return; mDisplayModeIsPreserveMemory = b; if (!b) { - hideActors(); - initializeCacheMode(); - } else { + HideActors(); + InitializeCacheMode(); + } + else { for(unsigned int d=0; dGetProperty()->SetColor(r,g,b); } @@ -121,8 +118,7 @@ void vvImageContour::SetLineWidth(double w) //------------------------------------------------------------------------------ -void vvImageContour::hideActors() -{ +void vvImageContour::HideActors() { if (!mSlicer) return; mSlice = mSlicer->GetSlice(); for(unsigned int i=0; iGetSlice(); mTSlice = mSlicer->GetTSlice(); // for(unsigned int i=0; iVisibilityOn(); - update(mValue); + Update(mValue); //} } //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ -void vvImageContour::update(double value) -{ +void vvImageContour::Update(double value) { // DD(value); if (!mSlicer) return; if (mPreviousValue == value) { @@ -167,9 +161,10 @@ void vvImageContour::update(double value) mSlice = mSlicer->GetSlice(); // DD(mDisplayModeIsPreserveMemory); if (mDisplayModeIsPreserveMemory) { - updateWithPreserveMemoryMode(); - } else { - updateWithFastCacheMode(); + UpdateWithPreserveMemoryMode(); + } + else { + UpdateWithFastCacheMode(); } @@ -184,8 +179,7 @@ void vvImageContour::update(double value) //------------------------------------------------------------------------------ -void vvImageContour::updateWithPreserveMemoryMode() -{ +void vvImageContour::UpdateWithPreserveMemoryMode() { // Only change actor visibility if tslice change //DD(mTSlice); //DD(mSlice); @@ -201,12 +195,12 @@ void vvImageContour::updateWithPreserveMemoryMode() vtkMarchingSquares * mSquares = mSquaresList[mTSlice]; vtkImageClip * mClipper = mClipperList[mTSlice]; vtkActor * mSquaresActor = mSquaresActorList[mTSlice]; - int orientation = computeCurrentOrientation(); + int orientation = ComputeCurrentOrientation(); // DD(orientation); //DD(mValue); //DD(mSlice); //DD(mPreviousTslice); - updateActor(mSquaresActor, mSquares, mClipper, mValue, orientation, mSlice); + UpdateActor(mSquaresActor, mSquares, mClipper, mValue, orientation, mSlice); mSquaresActorList[mTSlice]->VisibilityOn(); if (mPreviousTslice != mTSlice) { if (mPreviousTslice != -1) mSquaresActorList[mPreviousTslice]->VisibilityOff(); @@ -216,8 +210,7 @@ void vvImageContour::updateWithPreserveMemoryMode() //------------------------------------------------------------------------------ -void vvImageContour::initializeCacheMode() -{ +void vvImageContour::InitializeCacheMode() { mPreviousSlice = mPreviousOrientation = 0; int dim = mSlicer->GetImage()->GetNumberOfDimensions(); @@ -235,8 +228,7 @@ void vvImageContour::initializeCacheMode() //------------------------------------------------------------------------------ -int vvImageContour::computeCurrentOrientation() -{ +int vvImageContour::ComputeCurrentOrientation() { // Get extent of image in the slicer int* extent = mSlicer->GetImageActor()->GetDisplayExtent(); @@ -254,10 +246,9 @@ int vvImageContour::computeCurrentOrientation() //------------------------------------------------------------------------------ -void vvImageContour::updateWithFastCacheMode() -{ +void vvImageContour::UpdateWithFastCacheMode() { // Compute orientation - int orientation = computeCurrentOrientation(); + int orientation = ComputeCurrentOrientation(); if ((mPreviousSlice == mSlice) && (mPreviousOrientation == orientation)) return; @@ -268,8 +259,8 @@ void vvImageContour::updateWithFastCacheMode() vtkImageClip * mClipper; vtkMarchingSquares * mSquares; vtkActor * mSquaresActor; - createNewActor(&mSquaresActor, &mSquares, &mClipper, 0); - updateActor(mSquaresActor, mSquares, mClipper, mValue, orientation, mSlice); + CreateNewActor(&mSquaresActor, &mSquares, &mClipper, 0); + UpdateActor(mSquaresActor, mSquares, mClipper, mValue, orientation, mSlice); mListOfCachedContourActors[orientation][mSlice] = mSquaresActor; mSquaresActor->VisibilityOn(); } @@ -283,11 +274,10 @@ void vvImageContour::updateWithFastCacheMode() //------------------------------------------------------------------------------ -void vvImageContour::createNewActor(vtkActor ** actor, - vtkMarchingSquares ** squares, - vtkImageClip ** clipper, - int numImage) -{ +void vvImageContour::CreateNewActor(vtkActor ** actor, + vtkMarchingSquares ** squares, + vtkImageClip ** clipper, + int numImage) { vtkActor * mSquaresActor = (*actor = vtkActor::New()); vtkImageClip * mClipper = (*clipper = vtkImageClip::New()); vtkMarchingSquares * mSquares = (*squares = vtkMarchingSquares::New()); @@ -310,12 +300,10 @@ void vvImageContour::createNewActor(vtkActor ** actor, //------------------------------------------------------------------------------ -void vvImageContour::updateActor(vtkActor * actor, - vtkMarchingSquares * squares, - vtkImageClip * clipper, - double threshold, int orientation, int slice) -{ - +void vvImageContour::UpdateActor(vtkActor * actor, + vtkMarchingSquares * squares, + vtkImageClip * clipper, + double threshold, int orientation, int slice) { // Set parameter for the MarchigSquare squares->SetValue(0, threshold); @@ -351,7 +339,7 @@ void vvImageContour::updateActor(vtkActor * actor, // Move the actor to be visible // DD(orientation); -// DD(slice); + // DD(slice); //TO SIMPLiFY :!!!!!!!!! == ??????? // actor->SetPosition(-1,-1,-1); diff --git a/vv/vvImageContour.h b/vv/vvImageContour.h index 747ecd8..d93a3f3 100644 --- a/vv/vvImageContour.h +++ b/vv/vvImageContour.h @@ -34,14 +34,14 @@ class vvImageContour vvImageContour(); ~vvImageContour(); - void setSlicer(vvSlicer * slicer); - void update(double value); - void hideActors(); - void showActors(); - void setColor(double r, double g, double b); + void SetSlicer(vvSlicer * slicer); + void Update(double value); + void HideActors(); + void ShowActors(); + void SetColor(double r, double g, double b); void SetLineWidth(double w); - void setImage(vvImage::Pointer image); - void setPreserveMemoryModeEnabled(bool b); + void SetImage(vvImage::Pointer image); + void SetPreserveMemoryModeEnabled(bool b); protected: vvSlicer * mSlicer; @@ -65,18 +65,18 @@ class vvImageContour std::vector > mListOfCachedContourActors; // Functions - void initializeCacheMode(); - void updateWithPreserveMemoryMode(); - void updateWithFastCacheMode(); - void createNewActor(vtkActor ** actor, + void InitializeCacheMode(); + void UpdateWithPreserveMemoryMode(); + void UpdateWithFastCacheMode(); + void CreateNewActor(vtkActor ** actor, vtkMarchingSquares ** squares, vtkImageClip ** clipper, int numImage); - void updateActor(vtkActor * actor, + void UpdateActor(vtkActor * actor, vtkMarchingSquares * squares, vtkImageClip * clipper, double threshold, int orientation, int slice); - void createActor(int orientation, int slice); - int computeCurrentOrientation(); + void CreateActor(int orientation, int slice); + int ComputeCurrentOrientation(); }; // end class vvImageContour //------------------------------------------------------------------------------ diff --git a/vv/vvROIActor.cxx b/vv/vvROIActor.cxx index abf3eb6..2ffde5d 100644 --- a/vv/vvROIActor.cxx +++ b/vv/vvROIActor.cxx @@ -36,8 +36,11 @@ vvROIActor::vvROIActor() mImageContour.clear(); mOverlayActors.clear(); mIsVisible = true; + mIsContourVisible = false; mOpacity = 0.7; mIsSelected = false; + mContourWidth = 2; + mContourColor.resize(3); } //------------------------------------------------------------------------------ @@ -58,8 +61,14 @@ void vvROIActor::SetROI(clitk::DicomRT_ROI * s) //------------------------------------------------------------------------------ -void vvROIActor::SetSlicerManager(vvSlicerManager * s) -{ +void vvROIActor::SetContourWidth(int n) { + mContourWidth = n; +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvROIActor::SetSlicerManager(vvSlicerManager * s) { mSlicerManager = s; } //------------------------------------------------------------------------------ @@ -82,30 +91,58 @@ void vvROIActor::SetVisible(bool b) //------------------------------------------------------------------------------ -bool vvROIActor::IsVisible() -{ +void vvROIActor::SetContourVisible(bool b) { + mIsContourVisible = b; + if (!b) { // remove actor + for(unsigned int i= 0; iHideActors(); + mImageContour[i]->HideActors(); + } + } + else { + for(unsigned int i= 0; iShowActors(); + mImageContour[i]->ShowActors(); + } + } + Update(); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +bool vvROIActor::IsVisible() { return mIsVisible; } //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ -void vvROIActor::Initialize() -{ +bool vvROIActor::IsContourVisible() { + return mIsContourVisible; +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvROIActor::Initialize() { if (mROI->GetImage()) { mImageContour.clear(); mOverlayActors.clear(); for(int i=0; iNumberOfSlicers(); i++) { mImageContour.push_back(new vvImageContour); - mImageContour[i]->setSlicer(mSlicerManager->GetSlicer(i)); - mImageContour[i]->setImage(mROI->GetImage()); + mImageContour[i]->SetSlicer(mSlicerManager->GetSlicer(i)); + mImageContour[i]->SetImage(mROI->GetImage()); //mImageContour[i]->setColor(1.0, 0.0, 0.0); - mImageContour[i]->setColor(1.0-mROI->GetDisplayColor()[0], - 1.0-mROI->GetDisplayColor()[1], - 1.0-mROI->GetDisplayColor()[2]); - mImageContour[i]->setPreserveMemoryModeEnabled(true); - mImageContour[i]->setSlicer(mSlicerManager->GetSlicer(i)); - + mContourColor[0] = 1.0-mROI->GetDisplayColor()[0]; + mContourColor[1] = 1.0-mROI->GetDisplayColor()[1]; + mContourColor[2] = 1.0-mROI->GetDisplayColor()[2]; + mImageContour[i]->SetColor(mContourColor[0], mContourColor[1], mContourColor[2]); + mImageContour[i]->SetLineWidth(mContourWidth); + mImageContour[i]->SetPreserveMemoryModeEnabled(true); + mImageContour[i]->SetSlicer(mSlicerManager->GetSlicer(i)); + mImageContour[i]->HideActors(); + mOverlayActors.push_back(new vvBinaryImageOverlayActor); mOverlayActors[i]->SetImage(mROI->GetImage(), mROI->GetBackgroundValueLabelImage()); mOverlayActors[i]->SetColor(mROI->GetDisplayColor()[0], @@ -146,13 +183,18 @@ void vvROIActor::UpdateSlice(int slicer, int slices) exit(0); } - // CONTOUR HERE - DD("vvROIActor::UpdateSlice"); - DD(mROI->GetName()); - DD(mIsSelected); - DD(mROI->GetBackgroundValueLabelImage()); + // CONTOUR HERE + // DD("vvROIActor::UpdateSlice"); + //DD(mROI->GetName()); + //DD(mIsSelected); + //DD(mROI->GetBackgroundValueLabelImage()); if (mIsSelected) { - mImageContour[slicer]->update(1.0);//mROI->GetBackgroundValueLabelImage()); + mImageContour[slicer]->Update(1.0);//mROI->GetBackgroundValueLabelImage()); + // mImageContour[slicer]->showActors(); + } + if (mIsContourVisible) { + mImageContour[slicer]->SetLineWidth(mContourWidth); + mImageContour[slicer]->Update(mROI->GetBackgroundValueLabelImage()+1); // mImageContour[slicer]->showActors(); } @@ -187,8 +229,23 @@ void vvROIActor::SetOpacity(double d) //------------------------------------------------------------------------------ -void vvROIActor::UpdateColor() -{ +void vvROIActor::SetContourColor(double r, double v, double b) { + mContourColor[0] = r; + mContourColor[1] = v; + mContourColor[2] = b; +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +std::vector & vvROIActor::GetContourColor() { + return mContourColor; +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvROIActor::UpdateColor() { for(unsigned int i=0; iSetOpacity(mOpacity); mOverlayActors[i]->SetColor(mROI->GetDisplayColor()[0], @@ -196,6 +253,11 @@ void vvROIActor::UpdateColor() mROI->GetDisplayColor()[2]); mOverlayActors[i]->UpdateColor(); } + for(unsigned int i=0; iSetLineWidth(mContourWidth); + mImageContour[i]->SetColor(mContourColor[0], mContourColor[1], mContourColor[2]); + mImageContour[i]->Update(mROI->GetBackgroundValueLabelImage()+1); + } } //------------------------------------------------------------------------------ @@ -215,11 +277,11 @@ void vvROIActor::SetSelected(bool b) if (b) { for(int i=0; iNumberOfSlicers(); i++) { mImageContour[i]->SetLineWidth(3.0); - mImageContour[i]->showActors(); + mImageContour[i]->ShowActors(); } } else { for(int i=0; iNumberOfSlicers(); i++) { - mImageContour[i]->hideActors(); + mImageContour[i]->HideActors(); } } } diff --git a/vv/vvROIActor.h b/vv/vvROIActor.h index bb5c16b..a7cbd5c 100644 --- a/vv/vvROIActor.h +++ b/vv/vvROIActor.h @@ -40,10 +40,16 @@ class vvROIActor: public QObject { void Update(); void Initialize(); void SetVisible(bool b); + void SetContourVisible(bool b); bool IsVisible(); + bool IsContourVisible(); void SetOpacity(double x); double GetOpacity(); void SetSelected(bool b); + void SetContourWidth(int n); + int GetContourWidth() { return mContourWidth; } + void SetContourColor(double r, double v, double b); + std::vector & GetContourColor(); public slots: void UpdateSlice(int slicer, int slices); @@ -56,8 +62,11 @@ public slots: std::vector mOverlayActors; bool mIsVisible; + bool mIsContourVisible; double mOpacity; bool mIsSelected; + int mContourWidth; + std::vector mContourColor; }; // end class vvROIActor //------------------------------------------------------------------------------ diff --git a/vv/vvStructureSetActor.h b/vv/vvStructureSetActor.h index 119169d..9a6f95a 100644 --- a/vv/vvStructureSetActor.h +++ b/vv/vvStructureSetActor.h @@ -36,7 +36,9 @@ class vvStructureSetActor: public QObject { void SetSlicerManager(vvSlicerManager * s); void CreateNewROIActor(int n); vvROIActor* GetROIActor(int n); - + int GetNumberOfROIs() { return mROIActors.size(); } + std::vector & GetROIList() { return mROIActors; } + protected: clitk::DicomRT_StructureSet * mStructureSet; vvSlicerManager * mSlicerManager; diff --git a/vv/vvToolBinarize.cxx b/vv/vvToolBinarize.cxx index 6821ba2..afd07b1 100644 --- a/vv/vvToolBinarize.cxx +++ b/vv/vvToolBinarize.cxx @@ -14,7 +14,7 @@ - BSD See included LICENSE.txt file - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html -======================================================================-====*/ + ======================================================================-====*/ #include "vvToolBinarize.h" #include "vvSlicerManager.h" @@ -92,9 +92,9 @@ void vvToolBinarize::InteractiveDisplayToggled(bool b) RemoveVTKObjects(); } else { for(unsigned int i=0; ishowActors(); + mImageContour[i]->ShowActors(); if (mRadioButtonLowerThan->isChecked()) - mImageContourLower[i]->showActors(); + mImageContourLower[i]->ShowActors(); } if (mCurrentSlicerManager) mCurrentSlicerManager->Render(); @@ -107,8 +107,8 @@ void vvToolBinarize::InteractiveDisplayToggled(bool b) void vvToolBinarize::RemoveVTKObjects() { for(unsigned int i=0; ihideActors(); - mImageContourLower[i]->hideActors(); + mImageContour[i]->HideActors(); + mImageContourLower[i]->HideActors(); } if (mCurrentSlicerManager) mCurrentSlicerManager->Render(); @@ -141,14 +141,14 @@ void vvToolBinarize::enableLowerThan(bool b) if (!b) { mThresholdSlider1->resetMaximum(); for(unsigned int i=0; ihideActors(); + mImageContourLower[i]->HideActors(); } mCurrentSlicerManager->Render(); } else { valueChangedT1(mThresholdSlider1->GetValue()); valueChangedT2(mThresholdSlider2->GetValue()); for(unsigned int i=0; ishowActors(); + mImageContourLower[i]->ShowActors(); } mCurrentSlicerManager->Render(); } @@ -182,10 +182,10 @@ void vvToolBinarize::InputIsSelected(vvSlicerManager * m) mFGSlider->SetImage(mCurrentImage); mBGSlider->SetImage(mCurrentImage); // DD(mCurrentSlicerManager->GetFileName().c_str()); -// mFGSlider->SetMaximum(mCurrentImage->GetFirstVTKImageData()->GetScalarTypeMax()); -// mFGSlider->SetMinimum(mCurrentImage->GetFirstVTKImageData()->GetScalarTypeMin()); -// mBGSlider->SetMaximum(mCurrentImage->GetFirstVTKImageData()->GetScalarTypeMax()); -// mBGSlider->SetMinimum(mCurrentImage->GetFirstVTKImageData()->GetScalarTypeMin()); + // mFGSlider->SetMaximum(mCurrentImage->GetFirstVTKImageData()->GetScalarTypeMax()); + // mFGSlider->SetMinimum(mCurrentImage->GetFirstVTKImageData()->GetScalarTypeMin()); + // mBGSlider->SetMaximum(mCurrentImage->GetFirstVTKImageData()->GetScalarTypeMax()); + // mBGSlider->SetMinimum(mCurrentImage->GetFirstVTKImageData()->GetScalarTypeMin()); // Output is uchar ... mFGSlider->SetMaximum(255); @@ -201,11 +201,11 @@ void vvToolBinarize::InputIsSelected(vvSlicerManager * m) // VTK objects for interactive display for(int i=0; iNumberOfSlicers(); i++) { mImageContour.push_back(new vvImageContour); - mImageContour[i]->setSlicer(mCurrentSlicerManager->GetSlicer(i)); - mImageContour[i]->setColor(1.0, 0.0, 0.0); + mImageContour[i]->SetSlicer(mCurrentSlicerManager->GetSlicer(i)); + mImageContour[i]->SetColor(1.0, 0.0, 0.0); mImageContourLower.push_back(new vvImageContour); - mImageContourLower[i]->setSlicer(mCurrentSlicerManager->GetSlicer(i)); - mImageContourLower[i]->setColor(0.0, 0.0, 1.0); + mImageContourLower[i]->SetSlicer(mCurrentSlicerManager->GetSlicer(i)); + mImageContourLower[i]->SetColor(0.0, 0.0, 1.0); } valueChangedT1(mThresholdSlider1->GetValue()); @@ -236,10 +236,10 @@ void vvToolBinarize::UpdateSlice(int slicer,int slices) { if (!mInteractiveDisplayIsEnabled) return; if (!mCurrentSlicerManager) close(); - mImageContour[slicer]->update(mThresholdSlider1->GetValue()); - if (mRadioButtonLowerThan->isChecked()) - mImageContourLower[slicer]->update(mThresholdSlider2->GetValue()); - // mCurrentSlicerManager->GetSlicer(slicer)->Render(); + mImageContour[slicer]->Update(mThresholdSlider1->GetValue()); + if (mRadioButtonLowerThan->isChecked()) + mImageContourLower[slicer]->Update(mThresholdSlider2->GetValue()); + // mCurrentSlicerManager->GetSlicer(slicer)->Render(); } //------------------------------------------------------------------------------ @@ -249,14 +249,14 @@ void vvToolBinarize::GetArgsInfoFromGUI() { /* //KEEP THIS FOR READING GGO FROM FILE - int argc=1; - std::string a = "toto"; - char * const* argv = new char*; - //a.c_str(); - struct cmdline_parser_params p; - p.check_required = 0; - int good = cmdline_parser_ext(argc, argv, &args_info, &p); - DD(good); + int argc=1; + std::string a = "toto"; + char * const* argv = new char*; + //a.c_str(); + struct cmdline_parser_params p; + p.check_required = 0; + int good = cmdline_parser_ext(argc, argv, &args_info, &p); + DD(good); */ mArgsInfo.imagetypes_flag = 0; @@ -336,8 +336,8 @@ void vvToolBinarize::valueChangedT2(double v) if (mRadioButtonLowerThan->isChecked()) { mThresholdSlider1->SetMaximum(v); if (!mInteractiveDisplayIsEnabled) return; - for(int i=0; iNumberOfSlicers(); i++) { - mImageContourLower[i]->update(v); + for(int i=0;iNumberOfSlicers(); i++) { + mImageContourLower[i]->Update(v); } // mCurrentSlicerManager->Render(); } @@ -353,8 +353,8 @@ void vvToolBinarize::valueChangedT1(double v) mThresholdSlider2->SetMinimum(v); // int m1 = (int)lrint(v); if (!mInteractiveDisplayIsEnabled) return; - for(int i=0; iNumberOfSlicers(); i++) { - mImageContour[i]->update(v); + for(int i=0;iNumberOfSlicers(); i++) { + mImageContour[i]->Update(v); } // mCurrentSlicerManager->Render(); } -- 2.47.1