]> Creatis software - clitk.git/commitdiff
Add RemoveActors
authorDavid Sarrut <david.sarrut@gmail.com>
Fri, 30 Mar 2012 13:16:57 +0000 (15:16 +0200)
committerDavid Sarrut <david.sarrut@gmail.com>
Fri, 30 Mar 2012 13:16:57 +0000 (15:16 +0200)
vv/vvImageContour.cxx
vv/vvImageContour.h

index 173bde0e900e9f80b28cdf5c85bf87d906b8afb7..e89f84be3a1a2779e42963e2ef6781cf7d40c2a4 100644 (file)
@@ -37,6 +37,7 @@ vvImageContour::vvImageContour()
   SetPreserveMemoryModeEnabled(true);
   mPreviousOrientation = -1;
   mDepth = 1.0;
+  mSlice = 0;
 }
 //------------------------------------------------------------------------------
 
@@ -44,8 +45,24 @@ vvImageContour::vvImageContour()
 //------------------------------------------------------------------------------
 vvImageContour::~vvImageContour()
 {
-  for (unsigned int i = 0; i < mSlicer->GetImage()->GetVTKImages().size(); i++) {
-    mSlicer->GetRenderer()->RemoveActor(mSquaresActorList[i]);
+  mSquaresActorList.clear();
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvImageContour::RemoveActors()
+{
+  for (unsigned int i = 0; i < mSquaresActorList.size(); i++) {
+    if (mSlicer != 0) {
+      if (mSlicer!= NULL) {
+        if (mSlicer->GetRenderer() != NULL) {
+          if (mSquaresActorList[i] != NULL)  {
+            mSlicer->GetRenderer()->RemoveActor(mSquaresActorList[i]);
+          }
+        }
+      }   
+    }
   }
 }
 //------------------------------------------------------------------------------
@@ -63,7 +80,7 @@ void vvImageContour::SetSlicer(vvSlicer * slicer) {
 
 
 //------------------------------------------------------------------------------
-void vvImageContour::SetImage(vvImage * image) {
+void vvImageContour::SetImage(vvImage::Pointer image) {
   for (unsigned int numImage = 0; numImage < image->GetVTKImages().size(); numImage++) {
     mClipperList[numImage]->SetInput(image->GetVTKImages()[numImage]);
   }
@@ -134,6 +151,20 @@ void vvImageContour::ShowActors() {
 //------------------------------------------------------------------------------
 
 
+//------------------------------------------------------------------------------
+void vvImageContour::SetDepth(double d) 
+{ 
+  mDepth = d+0.5; // FIXME to not be equal to overlay 
+  // Move the actor to be visible
+  double position[3] = {0, 0, 0};
+ int orientation = ComputeCurrentOrientation();
+  position[orientation] = -mDepth;
+
+  for(uint i=0; i<mSquaresActorList.size(); i++)
+    mSquaresActorList[i]->SetPosition(position);
+}
+//------------------------------------------------------------------------------
+
 //------------------------------------------------------------------------------
 void vvImageContour::Update(double value) {
   if (!mSlicer) return;
@@ -338,9 +369,11 @@ void vvImageContour::UpdateActor(vtkActor * actor,
   if (mHiddenImageIsUsed) delete extent2;
 
   // Move the actor to be visible
-  double position[3] = {0, 0, 0};
-  position[orientation] = -mDepth;
-  actor->SetPosition(position);
+  SetDepth(mDepth);
+  // double position[3] = {0, 0, 0};
+  // DD(mDepth);
+  // position[orientation] = -mDepth;
+  // actor->SetPosition(position);
   
   mapper->Update();
 }
index c66a9a3bfb372c3098f3cf6b42a73b117fb8db1d..aa786bfa575a74cea1498dff8a0e806c77fddef8 100644 (file)
@@ -41,7 +41,7 @@ public:
   void ShowActors();
   void SetColor(double r, double g, double b);
   void SetLineWidth(double w);
-  void SetImage(vvImage * image);
+  void SetImage(vvImage::Pointer image);
   void SetPreserveMemoryModeEnabled(bool b);
   void SetDepth(double d);
   void RemoveActors();
@@ -54,7 +54,7 @@ protected:
   int mPreviousTSlice;
   double mPreviousValue;
   bool mHiddenImageIsUsed;
-  vvImage * mHiddenImage;
+  vvImage::Pointer mHiddenImage;
   bool mDisplayModeIsPreserveMemory;
   double mDepth;