//------------------------------------------------------------------------------
-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);
//------------------------------------------------------------------------------
-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]);
}
//------------------------------------------------------------------------------
-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; d<mListOfCachedContourActors.size(); d++)
mListOfCachedContourActors[d].clear();
mListOfCachedContourActors.clear();
- showActors();
+ ShowActors();
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
-void vvImageContour::setColor(double r, double g, double b)
-{
+void vvImageContour::SetColor(double r, double g, double b) {
for(unsigned int i=0; i<mSquaresActorList.size(); i++) {
mSquaresActorList[i]->GetProperty()->SetColor(r,g,b);
}
//------------------------------------------------------------------------------
-void vvImageContour::hideActors()
-{
+void vvImageContour::HideActors() {
if (!mSlicer) return;
mSlice = mSlicer->GetSlice();
for(unsigned int i=0; i<mSquaresActorList.size(); i++) {
//------------------------------------------------------------------------------
-void vvImageContour::showActors()
-{
+void vvImageContour::ShowActors() {
if (!mSlicer) return;
mSlice = mSlicer->GetSlice();
mTSlice = mSlicer->GetTSlice();
// for(unsigned int i=0; i<mSquaresActorList.size(); i++) {
mSquaresActorList[mTSlice]->VisibilityOn();
- update(mValue);
+ Update(mValue);
//}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
-void vvImageContour::update(double value)
-{
+void vvImageContour::Update(double value) {
// DD(value);
if (!mSlicer) return;
if (mPreviousValue == value) {
mSlice = mSlicer->GetSlice();
// DD(mDisplayModeIsPreserveMemory);
if (mDisplayModeIsPreserveMemory) {
- updateWithPreserveMemoryMode();
- } else {
- updateWithFastCacheMode();
+ UpdateWithPreserveMemoryMode();
+ }
+ else {
+ UpdateWithFastCacheMode();
}
//------------------------------------------------------------------------------
-void vvImageContour::updateWithPreserveMemoryMode()
-{
+void vvImageContour::UpdateWithPreserveMemoryMode() {
// Only change actor visibility if tslice change
//DD(mTSlice);
//DD(mSlice);
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();
//------------------------------------------------------------------------------
-void vvImageContour::initializeCacheMode()
-{
+void vvImageContour::InitializeCacheMode() {
mPreviousSlice = mPreviousOrientation = 0;
int dim = mSlicer->GetImage()->GetNumberOfDimensions();
//------------------------------------------------------------------------------
-int vvImageContour::computeCurrentOrientation()
-{
+int vvImageContour::ComputeCurrentOrientation() {
// Get extent of image in the slicer
int* extent = mSlicer->GetImageActor()->GetDisplayExtent();
//------------------------------------------------------------------------------
-void vvImageContour::updateWithFastCacheMode()
-{
+void vvImageContour::UpdateWithFastCacheMode() {
// Compute orientation
- int orientation = computeCurrentOrientation();
+ int orientation = ComputeCurrentOrientation();
if ((mPreviousSlice == mSlice) && (mPreviousOrientation == orientation)) return;
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();
}
//------------------------------------------------------------------------------
-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());
//------------------------------------------------------------------------------
-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);
// Move the actor to be visible
// DD(orientation);
-// DD(slice);
+ // DD(slice);
//TO SIMPLiFY :!!!!!!!!! == ???????
// actor->SetPosition(-1,-1,-1);
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;
std::vector<std::vector<vtkActor*> > 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
//------------------------------------------------------------------------------
mImageContour.clear();
mOverlayActors.clear();
mIsVisible = true;
+ mIsContourVisible = false;
mOpacity = 0.7;
mIsSelected = false;
+ mContourWidth = 2;
+ mContourColor.resize(3);
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
-void vvROIActor::SetSlicerManager(vvSlicerManager * s)
-{
+void vvROIActor::SetContourWidth(int n) {
+ mContourWidth = n;
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvROIActor::SetSlicerManager(vvSlicerManager * s) {
mSlicerManager = s;
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
-bool vvROIActor::IsVisible()
-{
+void vvROIActor::SetContourVisible(bool b) {
+ mIsContourVisible = b;
+ if (!b) { // remove actor
+ for(unsigned int i= 0; i<mOverlayActors.size(); i++) {
+ // mOverlayActors[i]->HideActors();
+ mImageContour[i]->HideActors();
+ }
+ }
+ else {
+ for(unsigned int i= 0; i<mOverlayActors.size(); i++) {
+ // mOverlayActors[i]->ShowActors();
+ 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; i<mSlicerManager->NumberOfSlicers(); 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],
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();
}
//------------------------------------------------------------------------------
-void vvROIActor::UpdateColor()
-{
+void vvROIActor::SetContourColor(double r, double v, double b) {
+ mContourColor[0] = r;
+ mContourColor[1] = v;
+ mContourColor[2] = b;
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+std::vector<double> & vvROIActor::GetContourColor() {
+ return mContourColor;
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvROIActor::UpdateColor() {
for(unsigned int i=0; i<mOverlayActors.size(); i++) {
mOverlayActors[i]->SetOpacity(mOpacity);
mOverlayActors[i]->SetColor(mROI->GetDisplayColor()[0],
mROI->GetDisplayColor()[2]);
mOverlayActors[i]->UpdateColor();
}
+ for(unsigned int i=0; i<mImageContour.size(); i++) {
+ mImageContour[i]->SetLineWidth(mContourWidth);
+ mImageContour[i]->SetColor(mContourColor[0], mContourColor[1], mContourColor[2]);
+ mImageContour[i]->Update(mROI->GetBackgroundValueLabelImage()+1);
+ }
}
//------------------------------------------------------------------------------
if (b) {
for(int i=0; i<mSlicerManager->NumberOfSlicers(); i++) {
mImageContour[i]->SetLineWidth(3.0);
- mImageContour[i]->showActors();
+ mImageContour[i]->ShowActors();
}
} else {
for(int i=0; i<mSlicerManager->NumberOfSlicers(); i++) {
- mImageContour[i]->hideActors();
+ mImageContour[i]->HideActors();
}
}
}
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<double> & GetContourColor();
public slots:
void UpdateSlice(int slicer, int slices);
std::vector<vvBinaryImageOverlayActor *> mOverlayActors;
bool mIsVisible;
+ bool mIsContourVisible;
double mOpacity;
bool mIsSelected;
+ int mContourWidth;
+ std::vector<double> mContourColor;
}; // end class vvROIActor
//------------------------------------------------------------------------------
void SetSlicerManager(vvSlicerManager * s);
void CreateNewROIActor(int n);
vvROIActor* GetROIActor(int n);
-
+ int GetNumberOfROIs() { return mROIActors.size(); }
+ std::vector<vvROIActor*> & GetROIList() { return mROIActors; }
+
protected:
clitk::DicomRT_StructureSet * mStructureSet;
vvSlicerManager * mSlicerManager;
- 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"
RemoveVTKObjects();
} else {
for(unsigned int i=0; i<mImageContour.size(); i++) {
- mImageContour[i]->showActors();
+ mImageContour[i]->ShowActors();
if (mRadioButtonLowerThan->isChecked())
- mImageContourLower[i]->showActors();
+ mImageContourLower[i]->ShowActors();
}
if (mCurrentSlicerManager)
mCurrentSlicerManager->Render();
void vvToolBinarize::RemoveVTKObjects()
{
for(unsigned int i=0; i<mImageContour.size(); i++) {
- mImageContour[i]->hideActors();
- mImageContourLower[i]->hideActors();
+ mImageContour[i]->HideActors();
+ mImageContourLower[i]->HideActors();
}
if (mCurrentSlicerManager)
mCurrentSlicerManager->Render();
if (!b) {
mThresholdSlider1->resetMaximum();
for(unsigned int i=0; i<mImageContour.size(); i++) {
- mImageContourLower[i]->hideActors();
+ mImageContourLower[i]->HideActors();
}
mCurrentSlicerManager->Render();
} else {
valueChangedT1(mThresholdSlider1->GetValue());
valueChangedT2(mThresholdSlider2->GetValue());
for(unsigned int i=0; i<mImageContour.size(); i++) {
- mImageContourLower[i]->showActors();
+ mImageContourLower[i]->ShowActors();
}
mCurrentSlicerManager->Render();
}
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);
// VTK objects for interactive display
for(int i=0; i<mCurrentSlicerManager->NumberOfSlicers(); 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());
{
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();
}
//------------------------------------------------------------------------------
{
/* //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;
if (mRadioButtonLowerThan->isChecked()) {
mThresholdSlider1->SetMaximum(v);
if (!mInteractiveDisplayIsEnabled) return;
- for(int i=0; i<mCurrentSlicerManager->NumberOfSlicers(); i++) {
- mImageContourLower[i]->update(v);
+ for(int i=0;i<mCurrentSlicerManager->NumberOfSlicers(); i++) {
+ mImageContourLower[i]->Update(v);
}
// mCurrentSlicerManager->Render();
}
mThresholdSlider2->SetMinimum(v);
// int m1 = (int)lrint(v);
if (!mInteractiveDisplayIsEnabled) return;
- for(int i=0; i<mCurrentSlicerManager->NumberOfSlicers(); i++) {
- mImageContour[i]->update(v);
+ for(int i=0;i<mCurrentSlicerManager->NumberOfSlicers(); i++) {
+ mImageContour[i]->Update(v);
}
// mCurrentSlicerManager->Render();
}