]> Creatis software - clitk.git/commitdiff
solved bug 457
authorRomulo Pinho <pinho@lyon.fnclcc.fr>
Thu, 26 May 2011 16:43:29 +0000 (18:43 +0200)
committerRomulo Pinho <pinho@lyon.fnclcc.fr>
Thu, 26 May 2011 16:43:29 +0000 (18:43 +0200)
- but there's another bug
+ change of orientation does not work

vv/vvImageContour.cxx
vv/vvImageContour.h
vv/vvSlicer.cxx
vv/vvSlicerManager.cxx
vv/vvToolBinarize.cxx

index 99bc6e495858a5156cc6951600e555edb7a31be7..ab6d8202647e24485c156f51251e4dbbf4be6fc0 100644 (file)
@@ -35,6 +35,7 @@ vvImageContour::vvImageContour()
   mHiddenImageIsUsed = false;
   mDisplayModeIsPreserveMemory = true;
   SetPreserveMemoryModeEnabled(true);
+  mPreviousOrientation = -1;
 }
 //------------------------------------------------------------------------------
 
@@ -134,11 +135,15 @@ void vvImageContour::ShowActors() {
 
 //------------------------------------------------------------------------------
 void vvImageContour::Update(double value) {
+  std::cout << "vvImageContour::Update " << value << std::endl;
   if (!mSlicer) return;
   if (mPreviousValue == value) {
     if (mPreviousSlice == mSlicer->GetSlice()) {
       if (mPreviousTSlice == mSlicer->GetTSlice()) {
-        return; // Nothing to do
+        if (mPreviousOrientation == ComputeCurrentOrientation()) {
+          std::cout << "Nothing to do" << std::endl;
+          return; // Nothing to do
+        }
       }
     }
   }
@@ -161,6 +166,7 @@ void vvImageContour::Update(double value) {
   mPreviousTSlice = mSlicer->GetTSlice();
   mPreviousSlice  = mSlicer->GetSlice();
   mPreviousValue  = value;
+  mPreviousOrientation = ComputeCurrentOrientation();
 }
 //------------------------------------------------------------------------------
 
@@ -172,11 +178,12 @@ void vvImageContour::UpdateWithPreserveMemoryMode() {
   mTSlice = mSlicer->GetTSlice();
 
   vtkMarchingSquares * mSquares = mSquaresList[mTSlice];
+  vtkPolyDataMapper* mapper = mSquaresMapperList[mTSlice];
   vtkImageClip * mClipper = mClipperList[mTSlice];
   vtkActor * mSquaresActor = mSquaresActorList[mTSlice];
   int orientation = ComputeCurrentOrientation();
 
-  UpdateActor(mSquaresActor, mSquares, mClipper, mValue, orientation, mSlice);
+  UpdateActor(mSquaresActor, mapper, mSquares, mClipper, mValue, orientation, mSlice);
   //mSquaresActorList[mTSlice]->VisibilityOn();
 
   if (mPreviousTslice != mTSlice) {
@@ -280,9 +287,12 @@ void vvImageContour::CreateNewActor(int numImage) {
 
 //------------------------------------------------------------------------------
 void vvImageContour::UpdateActor(vtkActor * actor, 
+                                 vtkPolyDataMapper * mapper, 
                                  vtkMarchingSquares * squares, 
                                  vtkImageClip * clipper, 
                                  double threshold, int orientation, int slice) {
+  std::cout << "vvImageContour::UpdateActor" << std::endl;
+  
    // Set parameter for the MarchigSquare
   squares->SetValue(0, threshold);
 
@@ -327,44 +337,49 @@ void vvImageContour::UpdateActor(vtkActor * actor,
   if (mHiddenImageIsUsed) delete extent2;
 
   // Move the actor to be visible
-  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);
-    } 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:
-    actor->SetPosition(0,0,-1);
-    /*
-    DD(mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[2]);
-    if (mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[2] > slice) {
-      DD("1");
-      actor->SetPosition(0,0,1);
-    } else {
-     DD("-1");
-      actor->SetPosition(0,0,-1);
-    }
-    */
-    break;
-  }
-
-  squares->Update();
+  double position[3] = {0, 0, 0};
+  position[orientation] = -1;
+  actor->SetPosition(position);
+  
+//   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);
+//     } 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:
+//     actor->SetPosition(0,0,-1);
+//     /*
+//     DD(mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[2]);
+//     if (mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[2] > slice) {
+//       DD("1");
+//       actor->SetPosition(0,0,1);
+//     } else {
+//      DD("-1");
+//       actor->SetPosition(0,0,-1);
+//     }
+//     */
+//     break;
+//   }
+
+  mapper->Update();
+  actor->VisibilityOn();
 }
 //------------------------------------------------------------------------------
 
index 1cf2e569b9df57def7a2312176f0b107cac369f7..d35ce4bd2255b5aeba33ecd203ac94853cffdce6 100644 (file)
@@ -71,7 +71,7 @@ protected:
   void UpdateWithPreserveMemoryMode();
   void UpdateWithFastCacheMode();
   void CreateNewActor(int numImage);
-  void UpdateActor(vtkActor * actor, vtkMarchingSquares * squares, vtkImageClip * clipper,
+  void UpdateActor(vtkActor * actor, vtkPolyDataMapper * mapper, vtkMarchingSquares * squares, vtkImageClip * clipper,
                    double threshold, int orientation, int slice);
   void CreateActor(int orientation, int slice);
   int ComputeCurrentOrientation();
index 30e8ccbf2f7a31478d41672e6fd08d013c0ef28d..c9d9be21d9e64d3f3227d313879a9f91f4e391bb 100644 (file)
@@ -1045,7 +1045,11 @@ void vvSlicer::FlipHorizontalView()
   vtkCamera *cam = this->Renderer ? this->Renderer->GetActiveCamera() : NULL;
   if (cam) {
     double *position = cam->GetPosition();
-    switch (this->SliceOrientation) {
+    double factor[3] = {1, 1, 1};
+    factor[this->SliceOrientation] = -1;
+    cam->SetPosition(factor[0]*position[0],factor[1]*position[1],factor[2]*position[2]);
+    
+/*    switch (this->SliceOrientation) {
     case vtkImageViewer2::SLICE_ORIENTATION_XY:
       cam->SetPosition(position[0],position[1],-position[2]);
       break;
@@ -1057,7 +1061,8 @@ void vvSlicer::FlipHorizontalView()
     case vtkImageViewer2::SLICE_ORIENTATION_YZ:
       cam->SetPosition(-position[0],position[1],position[2]);
       break;
-    }
+    }*/
+
     this->Renderer->ResetCameraClippingRange();
     this->UpdateDisplayExtent();
   }
index c3f5c0c4bc2d278dfc03ebfb15045f2a2315a7bf..59410567ffdc472933096d32fd84aa9efd7c447d 100644 (file)
@@ -916,6 +916,7 @@ void vvSlicerManager::UpdateSlice(int slicer)
 //----------------------------------------------------------------------------
 void vvSlicerManager::UpdateTSlice(int slicer)
 {
+  std::cout << "vvSlicerManager::UpdateTSlice" << std::endl;
   if (mPreviousSlice[slicer] == mSlicers[slicer]->GetSlice()) {
     if (mPreviousTSlice[slicer] == mSlicers[slicer]->GetTSlice()) {
       //      DD("************** NOTHING ***********");
index 5cde3234b373ce4bc70ee972514b366b9dbdcfcd..338e2ea6b9c67debf54a00a7e4fdffe53d4a948e 100644 (file)
@@ -247,6 +247,7 @@ void vvToolBinarize::InputIsSelected(vvSlicerManager * m)
 //------------------------------------------------------------------------------
 void vvToolBinarize::UpdateSlice(int slicer,int slices)
 {
+  std::cout << "vvToolBinarize::UpdateSlice" << std::endl;
   if (!mInteractiveDisplayIsEnabled) return;
   if (!mCurrentSlicerManager) close();
   mImageContour[slicer]->Update(mThresholdSlider1->GetValue());