]> Creatis software - clitk.git/commitdiff
Display a line between the 2 profile points.
authortbaudier <thomas.baudier@creatis.insa-lyon.fr>
Mon, 1 Feb 2016 07:38:48 +0000 (08:38 +0100)
committertbaudier <thomas.baudier@creatis.insa-lyon.fr>
Mon, 1 Feb 2016 07:38:48 +0000 (08:38 +0100)
Debug problem of extent
+ Try to debug the line display with landmark

vv/vvMainWindow.cxx
vv/vvSlicer.cxx
vv/vvSlicer.h
vv/vvSlicerManagerCommand.cxx
vv/vvToolProfile.cxx

index 0dce60f6a42e23497bfb462a8b12f66c6c490021..b1a2e11fb526098bfdd8d881f88e745b601c518e 100644 (file)
@@ -3526,10 +3526,10 @@ void vvMainWindow::ShowLastImage()
 void vvMainWindow::UpdateRenderWindows()
 { 
   for (unsigned int i = 0; i < mSlicerManagers.size(); i++) {
-    mSlicerManagers[i]->GetSlicer(0)->UpdateLandmarks();
-    mSlicerManagers[i]->GetSlicer(1)->UpdateLandmarks();
-    mSlicerManagers[i]->GetSlicer(2)->UpdateLandmarks();
-    mSlicerManagers[i]->GetSlicer(3)->UpdateLandmarks();
+      for (unsigned int j = 0; j < 4; ++j) {
+        mSlicerManagers[i]->GetSlicer(j)->RemoveLandmarks();
+        mSlicerManagers[i]->GetSlicer(j)->DisplayLandmarks();
+      }
   }
   if (NOViewWidget->GetRenderWindow()) NOViewWidget->GetRenderWindow()->Render();
   if (NEViewWidget->GetRenderWindow()) NEViewWidget->GetRenderWindow()->Render();
index 4bad01b0a6819dbcd3d932b0962dc7299ac79572..de7055d1c0ec6722e7f48b89393c5f04fb86b040 100644 (file)
@@ -1187,17 +1187,19 @@ void vvSlicer::UpdateDisplayExtent()
   }
   else if(mVF)
     mVFActor->SetVisibility(false);
+    
+    
+    double boundsT [6];
+      for(unsigned int i=0; i<6; i++)
+        boundsT[i] = ImageActor->GetBounds()[i];
+      boundsT[ this->SliceOrientation*2   ] = ImageActor->GetBounds()[ this->SliceOrientation*2  ]-fabs(this->GetInput()->GetSpacing()[this->SliceOrientation]);
+      boundsT[ this->SliceOrientation*2+1 ] = ImageActor->GetBounds()[ this->SliceOrientation*2+1 ]+fabs(this->GetInput()->GetSpacing()[this->SliceOrientation]);
+
 
   // Landmarks actor
   if (mLandActor) {
     if (mClipBox) {
-      double bounds [6];
-      for(unsigned int i=0; i<6; i++)
-        bounds[i] = ImageActor->GetBounds()[i];
-      bounds[ this->SliceOrientation*2   ] = ImageActor->GetBounds()[ this->SliceOrientation*2  ]-fabs(this->GetInput()->GetSpacing()[this->SliceOrientation]);
-      bounds[ this->SliceOrientation*2+1 ] = ImageActor->GetBounds()[ this->SliceOrientation*2+1 ]+fabs(this->GetInput()->GetSpacing()[this->SliceOrientation]);
-      mClipBox->SetBounds(bounds);
-      UpdateLandmarks();
+      RemoveLandmarks();
     }
     
     position[this->SliceOrientation] = offset;
@@ -1222,6 +1224,12 @@ void vvSlicer::UpdateDisplayExtent()
         cam->SetClippingRange(range - sumSpacing, range + sumSpacing);
       }
     }
+    
+    if (mLandActor) {
+        if (mClipBox) {
+            DisplayLandmarks();
+        }
+    }
   }
   emit UpdateDisplayExtentEnd(mSlicerNumber);
 }
@@ -1732,8 +1740,10 @@ void vvSlicer::Render()
 #endif
     mFusionMapper->Update();
   }
-  if (mLandMapper)
-    UpdateLandmarks();
+  if (mLandMapper) {
+    RemoveLandmarks();
+    DisplayLandmarks();
+  }
 
     this->GetRenderWindow()->Render();
 }
@@ -1753,24 +1763,43 @@ void vvSlicer::UpdateCursorPosition()
 
 
 //----------------------------------------------------------------------------
-void vvSlicer::UpdateLandmarks()
+void vvSlicer::RemoveLandmarks()
 { 
   vtkPolyData *pd = static_cast<vtkPolyData*>(mLandClipper->GetInput());
   if (pd->GetPoints()) {
-    //mLandGlyph->SetRange(0,1);
-    //mLandGlyph->Modified();
-    //mLandGlyph->Update();
 
-    mClipBox->Modified();
-    mLandClipper->Update();
-    mLandMapper->Update();
-    //Let's add the captions
     //First remove all captions:
     for(unsigned int i=0;i<mLandLabelActors.size();i++) {
        this->Renderer->RemoveActor2D(mLandLabelActors[i]);
        //allActors2D->Remove (mLandLabelActors[i]);
     }
     mLandLabelActors.clear();
+  }
+}
+//----------------------------------------------------------------------------
+
+
+//----------------------------------------------------------------------------
+void vvSlicer::DisplayLandmarks()
+{ 
+
+  double bounds [6];
+  for(unsigned int i=0; i<6; i++)
+    bounds[i] = ImageActor->GetBounds()[i];
+  bounds[ this->SliceOrientation*2   ] = ImageActor->GetBounds()[ this->SliceOrientation*2  ]-fabs(this->GetInput()->GetSpacing()[this->SliceOrientation]);
+  bounds[ this->SliceOrientation*2+1 ] = ImageActor->GetBounds()[ this->SliceOrientation*2+1 ]+fabs(this->GetInput()->GetSpacing()[this->SliceOrientation]);
+  mClipBox->SetBounds(bounds);
+
+
+  vtkPolyData *pd = static_cast<vtkPolyData*>(mLandClipper->GetInput());
+  if (pd->GetPoints()) {
+    //mLandGlyph->SetRange(0,1);
+    //mLandGlyph->Modified();
+    //mLandGlyph->Update();
+
+    mClipBox->Modified();
+    mLandClipper->Update();
+    mLandMapper->Update();
     //Next add the captions to the displayed points
     for (vtkIdType id=0; id<mLandClipper->GetOutput()->GetNumberOfPoints(); id++) {
          double *position = mLandClipper->GetOutput()->GetPoint(id);
index e5d79229c29e40a33bf37f005e6400f8beb78369..20111e160371c94a15d90f15fabf16ed75accc90 100644 (file)
@@ -170,7 +170,8 @@ public:
 
   void GetExtremasAroundMousePointer(double & min, double & max, vtkImageData *image, vtkTransform *transform);
 
-  void UpdateLandmarks();
+  void RemoveLandmarks();
+  void DisplayLandmarks();
   void ForceUpdateDisplayExtent();
 
   int* GetDisplayExtent();
index 661dd21141ec5998bb51ffffa4f7437ede99c4e7..07164f69ad56ed1a2073282fe3a235dc92a8fba5 100644 (file)
@@ -383,7 +383,8 @@ void vvSlicerManagerCommand::Execute(vtkObject *caller,
       if (newLandmark) {
         this->SM->AddNewLandmark(xWorld,yWorld,zWorld,
                               this->SM->GetSlicer(VisibleInWindow)->GetTSlice());
-        this->SM->GetSlicer(VisibleInWindow)->UpdateLandmarks();
+        this->SM->GetSlicer(VisibleInWindow)->RemoveLandmarks();
+        //this->SM->GetSlicer(VisibleInWindow)->DisplayLandmarks();
         this->SM->Render();
       }
       if (event == vtkCommand::PickEvent || event == vtkCommand::StartPickEvent) {
index c8540a01c8f81b21d6ea3b38a84b5e2def7c1a91..f0c47d56e377748ec962bf247f492943cdc374ea 100644 (file)
@@ -19,6 +19,8 @@
 #include <QFileDialog>
 #include <QShortcut>
 
+#include <algorithm>
+
 // vv
 #include "vvToolProfile.h"
 #include "vvProgressDialog.h"
@@ -125,6 +127,8 @@ void vvToolProfile::selectPoint1()
 {
   QString position = "";
   
+  if(mCurrentSlicerManager) {
+      cout << mCurrentSlicerManager->GetSelectedSlicer() << endl;
     if (mPoint1Selected) {
       ProfileWidget->hide();
       vtkSmartPointer<vtkChartXY> chart = vtkSmartPointer<vtkChartXY>::New();
@@ -139,27 +143,23 @@ void vvToolProfile::selectPoint1()
   }
   
   mPoint1Selected = false;
-  if(mCurrentSlicerManager) {
+
       if(mCurrentSlicerManager->GetSelectedSlicer() != -1) {
           double *pos;
-          int *index;
           pos = new double [4];
           pos[0] = pos[1] = pos[2] = pos[3] = 0;
-          index = new int [mCurrentSlicerManager->GetImage()->GetNumberOfDimensions()];
           
           int i(0);
           while (i<mCurrentSlicerManager->GetImage()->GetNumberOfDimensions() && i<3) {
             pos[i] = mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetCursorPosition()[i];
-            index[i] = (int) (pos[i] - mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetInput()->GetOrigin()[i])/mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetInput()->GetSpacing()[i];
             position += QString::number(pos[i],'f',1) + " ";
-            mPoint1[i] = index[i];
+            mPoint1[i] = round((pos[i] - mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetInput()->GetOrigin()[i])/mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetInput()->GetSpacing()[i]);
             ++i;
           }
           if (mCurrentSlicerManager->GetImage()->GetNumberOfDimensions() == 4) {
             pos[3] = mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetTSlice();
-            index[3] = (int)pos[3];
             position += QString::number(pos[3],'f',1) + " ";
-            mPoint1[3] = index[3];
+            mPoint1[3] = round(pos[3]);
           }
           mPoint1Selected = true;
           mCurrentSlicerManager->AddLandmarkProfile(pos[0], pos[1], pos[2], pos[3]);
@@ -180,6 +180,7 @@ void vvToolProfile::selectPoint2()
 {
   QString position = "";
   
+  if(mCurrentSlicerManager) {
   if (mPoint2Selected) {
       ProfileWidget->hide();
       vtkSmartPointer<vtkChartXY> chart = vtkSmartPointer<vtkChartXY>::New();
@@ -194,27 +195,22 @@ void vvToolProfile::selectPoint2()
   }
   
   mPoint2Selected = false;
-  if(mCurrentSlicerManager) {
       if(mCurrentSlicerManager->GetSelectedSlicer() != -1) {
           double *pos;
-          int *index;
           pos = new double [4];
           pos[0] = pos[1] = pos[2] = pos[3] = 0;;
-          index = new int [mCurrentSlicerManager->GetImage()->GetNumberOfDimensions()];
           
           int i(0);
           while (i<mCurrentSlicerManager->GetImage()->GetNumberOfDimensions() &&i<3) {
             pos[i] = mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetCursorPosition()[i];
-            index[i] = (int) (pos[i] - mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetInput()->GetOrigin()[i])/mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetInput()->GetSpacing()[i];
             position += QString::number(pos[i],'f',1) + " ";
-            mPoint2[i] = index[i];
+            mPoint2[i] = round((pos[i] - mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetInput()->GetOrigin()[i])/mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetInput()->GetSpacing()[i]);
             ++i;
           }
           if (mCurrentSlicerManager->GetImage()->GetNumberOfDimensions() == 4) {
             pos[3] = mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetTSlice();
-            index[3] = (int)pos[3];
             position += QString::number(pos[3],'f',1) + " ";
-            mPoint2[3] = index[3];
+            mPoint2[3] = round(pos[3]);
           }
           mPoint2Selected = true;
           mCurrentSlicerManager->AddLandmarkProfile(pos[0], pos[1], pos[2], pos[3]);
@@ -261,16 +257,14 @@ bool vvToolProfile::isPointsSelected()
 void vvToolProfile::computeProfile()
 {
     if (!mCurrentSlicerManager) close();
-
     QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
     GetArgsInfoFromGUI();
     ProfileWidget->hide();
-    
+   
     // Main filter
     mFilter->SetInputVVImage(mCurrentImage);
     mFilter->SetArgsInfo(mArgsInfo);
     mFilter->Update();
-    //mImageLine = mFilter->GetOutputVVImage();
     
     vtkSmartPointer<vtkTable> table = vtkSmartPointer<vtkTable>::New();
     vtkSmartPointer<vtkFloatArray> arrX = vtkSmartPointer<vtkFloatArray>::New();
@@ -432,6 +426,8 @@ void vvToolProfile::GetArgsInfoFromGUI()
 
   mArgsInfo.input_arg = new char;
   mArgsInfo.output_arg = new char;
+  
+
 }
 //------------------------------------------------------------------------------
 
@@ -565,6 +561,7 @@ void vvToolProfile::DisplayLine(int slicer)
   
   if(mCurrentSlicerManager) {
       if(mCurrentSlicerManager->GetSelectedSlicer() != -1) {
+          if (std::min(mPoint1[mCurrentSlicerManager->GetSlicer(slicer)->GetOrientation()],mPoint2[mCurrentSlicerManager->GetSlicer(slicer)->GetOrientation()]) <= mCurrentSlicerManager->GetSlicer(slicer)->GetSlice() && std::max(mPoint1[mCurrentSlicerManager->GetSlicer(slicer)->GetOrientation()],mPoint2[mCurrentSlicerManager->GetSlicer(slicer)->GetOrientation()]) >= mCurrentSlicerManager->GetSlicer(slicer)->GetSlice()) {
             vtkSmartPointer<vtkBox> clippingBox = vtkSmartPointer<vtkBox>::New();
             double extent[6];
             for (int j=0; j<6; ++j) {
@@ -594,6 +591,7 @@ void vvToolProfile::DisplayLine(int slicer)
             mLineActors[slicer]->GetProperty()->SetOpacity(0.995);
 
             mCurrentSlicerManager->GetSlicer(slicer)->GetRenderer()->AddActor(mLineActors[slicer]);
+         }
       }
   }
 }