]> Creatis software - clitk.git/commitdiff
First version of reslicing transform
authorSimon Rit <simon.rit@creatis.insa-lyon.fr>
Fri, 10 Aug 2012 13:11:26 +0000 (15:11 +0200)
committerSimon Rit <simon.rit@creatis.insa-lyon.fr>
Fri, 10 Aug 2012 13:11:26 +0000 (15:11 +0200)
vv/qt_ui/vvMainWindow.ui
vv/vvMainWindow.cxx
vv/vvMainWindow.h
vv/vvSlicer.cxx
vv/vvSlicer.h
vv/vvSlicerManager.cxx
vv/vvSlicerManager.h
vv/vvSlicerManagerCommand.cxx

index 789e59f3564050deb3418e0c1ba28f97b320ee8e..8d3d8ff90806dbd4810e7a111be8650f0dd300ea 100644 (file)
        <property name="spacing">
         <number>2</number>
        </property>
-       <item row="0" column="17">
-        <spacer>
-         <property name="orientation">
-          <enum>Qt::Horizontal</enum>
-         </property>
-         <property name="sizeHint" stdset="0">
-          <size>
-           <width>40</width>
-           <height>20</height>
-          </size>
-         </property>
-        </spacer>
-       </item>
        <item row="0" column="0">
         <widget class="QPushButton" name="goToCursorPushButton">
          <property name="sizePolicy">
          </item>
         </widget>
        </item>
-       <item row="0" column="19">
+       <item row="0" column="21">
         <widget class="QPushButton" name="viewButton">
          <property name="sizePolicy">
           <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
          </property>
         </widget>
        </item>
-       <item row="0" column="18">
-        <widget class="Line" name="line_3">
-         <property name="orientation">
-          <enum>Qt::Vertical</enum>
-         </property>
-        </widget>
-       </item>
        <item row="0" column="4">
         <widget class="QSpinBox" name="frameRateSpinBox">
          <property name="minimum">
          </property>
         </widget>
        </item>
+       <item row="0" column="19">
+        <widget class="QComboBox" name="slicingPresetComboBox">
+         <item>
+          <property name="text">
+           <string>World</string>
+          </property>
+         </item>
+         <item>
+          <property name="text">
+           <string>Voxels</string>
+          </property>
+         </item>
+        </widget>
+       </item>
+       <item row="0" column="18">
+        <widget class="QLabel" name="label_2">
+         <property name="text">
+          <string>Slice to</string>
+         </property>
+        </widget>
+       </item>
+       <item row="0" column="17">
+        <spacer name="horizontalSpacer">
+         <property name="orientation">
+          <enum>Qt::Horizontal</enum>
+         </property>
+         <property name="sizeHint" stdset="0">
+          <size>
+           <width>40</width>
+           <height>20</height>
+          </size>
+         </property>
+        </spacer>
+       </item>
       </layout>
      </widget>
     </item>
      <x>0</x>
      <y>0</y>
      <width>1008</width>
-     <height>22</height>
+     <height>25</height>
     </rect>
    </property>
    <property name="defaultUp">
index 9fc078cb1c09dbcdd362e17cda4fbdb5b6f75eeb..38f4f8b8d643ab72ca8c93ac28dbe55d3badd4ce 100644 (file)
@@ -309,10 +309,10 @@ vvMainWindow::vvMainWindow():vvMainWindowBase()
   connect(levelSpinBox,SIGNAL(editingFinished()),this,SLOT(WindowLevelEdited()));
   connect(colorMapComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(UpdateColorMap()));
   connect(presetComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(UpdateWindowLevel()));
+  connect(slicingPresetComboBox, SIGNAL(currentIndexChanged(int)),this,SLOT(UpdateSlicingPreset()));
   connect(inverseButton,SIGNAL(clicked()),this,SLOT(SwitchWindowLevel()));
   connect(applyWindowLevelToAllButton,SIGNAL(clicked()),this,SLOT(ApplyWindowLevelToAllImages()));
 
-
   connect(this,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(ShowContextMenu(QPoint)));
 
   connect(linkPanel,SIGNAL(addLink(QString,QString)),this,SLOT(AddLink(QString,QString)));
@@ -1176,6 +1176,7 @@ void vvMainWindow::ImageInfoChanged()
       }
     }
     WindowLevelChanged();
+    slicingPresetComboBox->setCurrentIndex(mSlicerManagers[index]->GetSlicingPreset());
 
     if (mSlicerManagers[index]->GetSlicer(0)->GetVF()) {
       overlayPanel->getVFName(mSlicerManagers[index]->GetVFName().c_str());
@@ -1721,6 +1722,16 @@ void vvMainWindow::UpdateWindowLevel()
 }
 //------------------------------------------------------------------------------
 
+//------------------------------------------------------------------------------
+void vvMainWindow::UpdateSlicingPreset()
+{
+  if (DataTree->selectedItems().size()) {
+    int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
+    mSlicerManagers[index]->SetSlicingPreset(slicingPresetComboBox->currentIndex());
+  }
+}
+//------------------------------------------------------------------------------
+
 //------------------------------------------------------------------------------
 void vvMainWindow::UpdateColorMap()
 {
index bbdfe263719e83dd037b7c3d4b070834b3624262..c77a59a8a4948a482e6db31d46e816c52056cec7 100644 (file)
@@ -118,6 +118,7 @@ public slots:
   void SetWindowLevel(double w, double l);
   void UpdateColorMap();
   void UpdateWindowLevel();
+  void UpdateSlicingPreset();
   void SwitchWindowLevel();
   void ApplyWindowLevelToAllImages();
   void UpdateLinkManager(std::string id, int slicer, double x, double y, double z, int temps);
index 247820561076c445f95e7943857878d62fd2f672..52fa161c14178a73db07815e46056d403c60c458 100644 (file)
@@ -145,6 +145,9 @@ vvSlicer::vvSlicer()
 #if VTK_MAJOR_VERSION >= 6 || (VTK_MAJOR_VERSION >= 5 && VTK_MINOR_VERSION >= 10)
   this->GetImageActor()->GetMapper()->BorderOn();
 #endif
+
+  mSlicingTransform = vtkSmartPointer<vtkTransform>::New();
+  mConcatenatedTransform = vtkSmartPointer<vtkTransform>::New();
 }
 //------------------------------------------------------------------------------
 
@@ -290,13 +293,20 @@ vvSlicer::~vvSlicer()
 }
 //------------------------------------------------------------------------------
 
+//------------------------------------------------------------------------------
+double* vvSlicer::GetCurrentPosition()
+{
+  return mCurrentBeforeSlicingTransform;
+}
+//------------------------------------------------------------------------------
 
 //------------------------------------------------------------------------------
 void vvSlicer::SetCurrentPosition(double x, double y, double z, int t)
 {
-  mCurrent[0] = x;
-  mCurrent[1] = y;
-  mCurrent[2] = z;
+  mCurrentBeforeSlicingTransform[0]=x;
+  mCurrentBeforeSlicingTransform[1]=y;
+  mCurrentBeforeSlicingTransform[2]=z;
+  mSlicingTransform->GetInverse()->TransformPoint(mCurrentBeforeSlicingTransform,mCurrent);
   mCurrentTSlice = t;
 }
 //------------------------------------------------------------------------------
@@ -314,7 +324,11 @@ void vvSlicer::SetImage(vvImage::Pointer image)
       mImageReslice->AutoCropOutputOn();
       mImageReslice->SetBackgroundColor(-1000,-1000,-1000,1);
     }
-    mImageReslice->SetResliceTransform(mImage->GetTransform());
+
+    mConcatenatedTransform->Identity();
+    mConcatenatedTransform->Concatenate(mImage->GetTransform());
+    mConcatenatedTransform->Concatenate(mSlicingTransform);
+    mImageReslice->SetResliceTransform(mConcatenatedTransform);
     mImageReslice->SetInput(0, mImage->GetFirstVTKImageData());
     mImageReslice->UpdateInformation();
 
@@ -1271,34 +1285,29 @@ void vvSlicer::Render()
 
   if (ca->GetVisibility()) {
     std::stringstream worldPos;
-    double X = (mCurrent[0] - this->GetInput()->GetOrigin()[0])/this->GetInput()->GetSpacing()[0];
-    double Y = (mCurrent[1] - this->GetInput()->GetOrigin()[1])/this->GetInput()->GetSpacing()[1];
-    double Z = (mCurrent[2] - this->GetInput()->GetOrigin()[2])/this->GetInput()->GetSpacing()[2];
-    
-//     if (X < this->GetInput()->GetWholeExtent()[0]) X = this->GetInput()->GetWholeExtent()[0];
-//     else if (X > this->GetInput()->GetWholeExtent()[1]) X = this->GetInput()->GetWholeExtent()[1]; 
-//     if (Y < this->GetInput()->GetWholeExtent()[2]) Y = this->GetInput()->GetWholeExtent()[2];
-//     else if (Y > this->GetInput()->GetWholeExtent()[3]) Y = this->GetInput()->GetWholeExtent()[3]; 
-//     if (Z < this->GetInput()->GetWholeExtent()[4]) Z = this->GetInput()->GetWholeExtent()[4];
-//     else if (Z > this->GetInput()->GetWholeExtent()[5]) Z = this->GetInput()->GetWholeExtent()[5]; 
-
-    if (X >= this->GetInput()->GetWholeExtent()[0] &&
-        X <= this->GetInput()->GetWholeExtent()[1] &&
-        Y >= this->GetInput()->GetWholeExtent()[2] &&
-        Y <= this->GetInput()->GetWholeExtent()[3] &&
-        Z >= this->GetInput()->GetWholeExtent()[4] &&
-        Z <= this->GetInput()->GetWholeExtent()[5]) {
+    double pt[3];
+    mConcatenatedTransform->TransformPoint(mCurrent, pt);
+    double X = (pt[0] - mImage->GetVTKImages()[mCurrentTSlice]->GetOrigin()[0])/mImage->GetVTKImages()[mCurrentTSlice]->GetSpacing()[0];
+    double Y = (pt[1] - mImage->GetVTKImages()[mCurrentTSlice]->GetOrigin()[1])/mImage->GetVTKImages()[mCurrentTSlice]->GetSpacing()[1];
+    double Z = (pt[2] - mImage->GetVTKImages()[mCurrentTSlice]->GetOrigin()[2])/mImage->GetVTKImages()[mCurrentTSlice]->GetSpacing()[2];
+
+    if (X >= mImage->GetVTKImages()[mCurrentTSlice]->GetWholeExtent()[0]-0.5 &&
+        X <= mImage->GetVTKImages()[mCurrentTSlice]->GetWholeExtent()[1]+0.5 &&
+        Y >= mImage->GetVTKImages()[mCurrentTSlice]->GetWholeExtent()[2]-0.5 &&
+        Y <= mImage->GetVTKImages()[mCurrentTSlice]->GetWholeExtent()[3]+0.5 &&
+        Z >= mImage->GetVTKImages()[mCurrentTSlice]->GetWholeExtent()[4]-0.5 &&
+        Z <= mImage->GetVTKImages()[mCurrentTSlice]->GetWholeExtent()[5]+0.5) {
 
       
       int ix, iy, iz;
-      double value = this->GetScalarComponentAsDouble(this->GetInput(), X, Y, Z, ix, iy, iz);
+      double value = this->GetScalarComponentAsDouble(mImage->GetVTKImages()[mCurrentTSlice], X, Y, Z, ix, iy, iz);
 
       if(ImageActor->GetVisibility())
         worldPos << "data value : " << value << std::endl;
 
-      worldPos << "mm : " << lrint(mCurrent[0]) << ' '
-                          << lrint(mCurrent[1]) << ' '
-                          << lrint(mCurrent[2]) << ' '
+      worldPos << "mm : " << lrint(mCurrentBeforeSlicingTransform[0]) << ' '
+                          << lrint(mCurrentBeforeSlicingTransform[1]) << ' '
+                          << lrint(mCurrentBeforeSlicingTransform[2]) << ' '
                           << mCurrentTSlice
                           << std::endl;
       worldPos << "pixel : " << ix << ' '
index c09001dcb38e90d66080459f0152d4ea77c80e28..44e1a2cdde7ef23c7baa53c68651fadd497db516 100644 (file)
@@ -140,10 +140,11 @@ public:
     return mCursor;
   }
 
+  vtkTransform * GetSlicingTransform() { return mSlicingTransform; }
+  vtkTransform * GetConcatenatedTransform() { return mConcatenatedTransform; }
+
   void SetCurrentPosition(double x, double y, double z, int t);
-  double* GetCurrentPosition() {
-    return mCurrent;
-  }
+  double* GetCurrentPosition();
 
   void UpdateCursorPosition();
   void SetCursorVisibility(bool s);
@@ -207,6 +208,8 @@ protected:
   vvLandmarks* mLandmarks;
 
   vtkSmartPointer<vtkImageReslice> mImageReslice;
+  vtkSmartPointer<vtkTransform> mSlicingTransform;
+  vtkSmartPointer<vtkTransform> mConcatenatedTransform;
   vtkSmartPointer<vtkImageReslice> mOverlayReslice;
   vtkSmartPointer<vtkImageMapToWindowLevelColors> mOverlayMapper;
   vtkSmartPointer<vvBlendImageActor> mOverlayActor;
@@ -235,6 +238,7 @@ protected:
 
   int mCurrentTSlice;
   double mCurrent[3];
+  double mCurrentBeforeSlicingTransform[3];
   double mCursor[4];
   int mSubSampling;
   int mScale;
index c86928f96825f8bc50d4b7778394ed786ccbeefa..18049702c0845fc89bcde6798a81c7aa8257fdf3 100644 (file)
@@ -72,6 +72,7 @@ vvSlicerManager::vvSlicerManager(int numberOfSlicers)
 
   mPreviousSlice.resize(numberOfSlicers);
   mPreviousTSlice.resize(numberOfSlicers);
+  mSlicingPreset = 0;
 }
 //----------------------------------------------------------------------------
 
@@ -570,36 +571,42 @@ void vvSlicerManager::SetOpacity(int i, double factor)
 //----------------------------------------------------------------------------
 void vvSlicerManager::UpdateViews(int current,int slicer)
 {
-  double x = (mSlicers[slicer]->GetCurrentPosition()[0] - mSlicers[slicer]->GetInput()->GetOrigin()[0])
+  double p[3], pt[3];
+  p[0] = mSlicers[slicer]->GetCurrentPosition()[0];
+  p[1] = mSlicers[slicer]->GetCurrentPosition()[1];
+  p[2] = mSlicers[slicer]->GetCurrentPosition()[2];
+  mSlicers[slicer]->GetSlicingTransform()->GetInverse()->TransformPoint(p, pt);
+
+  double x = (pt[0] - mSlicers[slicer]->GetInput()->GetOrigin()[0])
     /mSlicers[slicer]->GetInput()->GetSpacing()[0];
-  double y = (mSlicers[slicer]->GetCurrentPosition()[1] - mSlicers[slicer]->GetInput()->GetOrigin()[1])
+  double y = (pt[1] - mSlicers[slicer]->GetInput()->GetOrigin()[1])
     /mSlicers[slicer]->GetInput()->GetSpacing()[1];
-  double z = (mSlicers[slicer]->GetCurrentPosition()[2] - mSlicers[slicer]->GetInput()->GetOrigin()[2])
+  double z = (pt[2] - mSlicers[slicer]->GetInput()->GetOrigin()[2])
     /mSlicers[slicer]->GetInput()->GetSpacing()[2];
 
-  if (x >= mSlicers[slicer]->GetInput()->GetWholeExtent()[0] &&
-      x <= mSlicers[slicer]->GetInput()->GetWholeExtent()[1] &&
-      y >= mSlicers[slicer]->GetInput()->GetWholeExtent()[2] &&
-      y <= mSlicers[slicer]->GetInput()->GetWholeExtent()[3] &&
-      z >= mSlicers[slicer]->GetInput()->GetWholeExtent()[4] &&
-      z <= mSlicers[slicer]->GetInput()->GetWholeExtent()[5]) {
+  if (x >= mSlicers[slicer]->GetInput()->GetWholeExtent()[0]-0.5 &&
+      x <= mSlicers[slicer]->GetInput()->GetWholeExtent()[1]+0.5 &&
+      y >= mSlicers[slicer]->GetInput()->GetWholeExtent()[2]-0.5 &&
+      y <= mSlicers[slicer]->GetInput()->GetWholeExtent()[3]+0.5 &&
+      z >= mSlicers[slicer]->GetInput()->GetWholeExtent()[4]-0.5 &&
+      z <= mSlicers[slicer]->GetInput()->GetWholeExtent()[5]+0.5) {
     mSlicers[slicer]->UpdateCursorPosition();
     mSlicers[slicer]->SetCursorColor(10,212,255);
 
     switch (mSlicers[slicer]->GetSliceOrientation()) {
     case vtkImageViewer2::SLICE_ORIENTATION_XY:
-      if (mSlicers[slicer]->GetSlice() != (int)floor(z))
-        mSlicers[slicer]->SetSlice((int)floor(z));
+      if (mSlicers[slicer]->GetSlice() != (int)lrint(z))
+        mSlicers[slicer]->SetSlice((int)lrint(z));
       break;
 
     case vtkImageViewer2::SLICE_ORIENTATION_XZ:
-      if (mSlicers[slicer]->GetSlice() != (int)floor(y))
-        mSlicers[slicer]->SetSlice((int)floor(y));
+      if (mSlicers[slicer]->GetSlice() != (int)lrint(y))
+        mSlicers[slicer]->SetSlice((int)lrint(y));
       break;
 
     case vtkImageViewer2::SLICE_ORIENTATION_YZ:
-      if (mSlicers[slicer]->GetSlice() != (int)floor(x))
-        mSlicers[slicer]->SetSlice((int)floor(x));
+      if (mSlicers[slicer]->GetSlice() != (int)lrint(x))
+        mSlicers[slicer]->SetSlice((int)lrint(x));
       break;
     }
     mSlicers[slicer]->Render();
@@ -609,10 +616,7 @@ void vvSlicerManager::UpdateViews(int current,int slicer)
           && mSlicers[i]->GetRenderer()->GetDraw()
           && mSlicers[i]->GetRenderWindow()->GetSize()[0] > 2
           && mSlicers[i]->GetRenderWindow()->GetSize()[1] > 2) {
-        mSlicers[i]->SetCurrentPosition(mSlicers[slicer]->GetCurrentPosition()[0],
-                                        mSlicers[slicer]->GetCurrentPosition()[1],
-                                        mSlicers[slicer]->GetCurrentPosition()[2],
-                                        mSlicers[slicer]->GetTSlice());
+        mSlicers[i]->SetCurrentPosition(p[0], p[1], p[2], mSlicers[slicer]->GetTSlice());
         mSlicers[i]->UpdateCursorPosition();
         if (current) { //do not display corner annotation if image is the one picked
           mSlicers[i]->SetCurrentPosition(-VTK_DOUBLE_MAX,-VTK_DOUBLE_MAX,
@@ -652,19 +656,21 @@ void vvSlicerManager::UpdateViews(int current,int slicer)
 //----------------------------------------------------------------------------
 void vvSlicerManager::UpdateLinked(int slicer)
 {
-  double x = (mSlicers[slicer]->GetCurrentPosition()[0] - mSlicers[slicer]->GetInput()->GetOrigin()[0])
-    /mSlicers[slicer]->GetInput()->GetSpacing()[0];
-  double y = (mSlicers[slicer]->GetCurrentPosition()[1] - mSlicers[slicer]->GetInput()->GetOrigin()[1])
-    /mSlicers[slicer]->GetInput()->GetSpacing()[1];
-  double z = (mSlicers[slicer]->GetCurrentPosition()[2] - mSlicers[slicer]->GetInput()->GetOrigin()[2])
-    /mSlicers[slicer]->GetInput()->GetSpacing()[2];
-
-  if (x >= mSlicers[slicer]->GetInput()->GetWholeExtent()[0] &&
-      x <= mSlicers[slicer]->GetInput()->GetWholeExtent()[1] &&
-      y >= mSlicers[slicer]->GetInput()->GetWholeExtent()[2] &&
-      y <= mSlicers[slicer]->GetInput()->GetWholeExtent()[3] &&
-      z >= mSlicers[slicer]->GetInput()->GetWholeExtent()[4] &&
-      z <= mSlicers[slicer]->GetInput()->GetWholeExtent()[5]) {
+  double p[3], pt[3];
+  p[0] = mSlicers[slicer]->GetCurrentPosition()[0];
+  p[1] = mSlicers[slicer]->GetCurrentPosition()[1];
+  p[2] = mSlicers[slicer]->GetCurrentPosition()[2];
+  mSlicers[slicer]->GetSlicingTransform()->GetInverse()->TransformPoint(p, pt);
+  double x = (pt[0] - mSlicers[slicer]->GetInput()->GetOrigin()[0]) / mSlicers[slicer]->GetInput()->GetSpacing()[0];
+  double y = (pt[1] - mSlicers[slicer]->GetInput()->GetOrigin()[1]) / mSlicers[slicer]->GetInput()->GetSpacing()[1];
+  double z = (pt[2] - mSlicers[slicer]->GetInput()->GetOrigin()[2]) / mSlicers[slicer]->GetInput()->GetSpacing()[2];
+
+  if (x >= mSlicers[slicer]->GetInput()->GetWholeExtent()[0]-0.5 &&
+      x <= mSlicers[slicer]->GetInput()->GetWholeExtent()[1]+0.5 &&
+      y >= mSlicers[slicer]->GetInput()->GetWholeExtent()[2]-0.5 &&
+      y <= mSlicers[slicer]->GetInput()->GetWholeExtent()[3]+0.5 &&
+      z >= mSlicers[slicer]->GetInput()->GetWholeExtent()[4]-0.5 &&
+      z <= mSlicers[slicer]->GetInput()->GetWholeExtent()[5]+0.5) {
     for (std::list<std::string>::const_iterator i = mLinkedId.begin(); i != mLinkedId.end(); i++) {
       emit UpdateLinkManager(*i, slicer,mSlicers[slicer]->GetCurrentPosition()[0],
                              mSlicers[slicer]->GetCurrentPosition()[1],
@@ -682,6 +688,11 @@ void vvSlicerManager::UpdateLinkedNavigation(vvSlicer *refSlicer, bool bPropagat
   refCam->GetPosition(refPosition);
   refCam->GetFocalPoint(refFocal);
   
+  refSlicer->GetSlicingTransform()->TransformPoint(refPosition);
+  refSlicer->GetSlicingTransform()->TransformPoint(refFocal);
+  mSlicers[0]->GetSlicingTransform()->GetInverse()->TransformPoint(refPosition);
+  mSlicers[0]->GetSlicingTransform()->GetInverse()->TransformPoint(refFocal);
+
   for ( unsigned int i = 0; i < mSlicers.size(); i++) {
     vtkCamera *camera = mSlicers[i]->GetRenderer()->GetActiveCamera();
     camera->SetParallelScale(refCam->GetParallelScale());
@@ -729,10 +740,13 @@ void vvSlicerManager::UpdateLinkedNavigation(vvSlicer *refSlicer, bool bPropagat
         focal[2]    = refFocal[2];
       }
     }
-
+DD(camera->GetFocalPoint()[0] << ' ' << camera->GetFocalPoint()[1] << ' ' << camera->GetFocalPoint()[2])
     camera->SetFocalPoint(focal);
+DD(camera->GetFocalPoint()[0] << ' ' << camera->GetFocalPoint()[1] << ' ' << camera->GetFocalPoint()[2])
+DD(camera->GetPosition()[0] << ' ' << camera->GetPosition()[1] << ' ' << camera->GetPosition()[2])
     camera->SetPosition(position);
-  
+DD(camera->GetPosition()[0] << ' ' << camera->GetPosition()[1] << ' ' << camera->GetPosition()[2])
+
     //Fix for bug #243
     mSlicers[i]->ForceUpdateDisplayExtent();
   }
@@ -1057,6 +1071,38 @@ void vvSlicerManager::UpdateSliceRange(int slicer)
 }
 //----------------------------------------------------------------------------
 
+//----------------------------------------------------------------------------
+void vvSlicerManager::SetSlicingPreset(int preset)
+{
+  if(mSlicingPreset==preset)
+    return;
+
+  vtkMatrix4x4 *mImageTransformInverse = vtkMatrix4x4::New();
+  mImage->GetTransform()->GetInverse(mImageTransformInverse);
+
+  for(int i=0; i< this->GetNumberOfSlicers(); i++){
+    switch(preset)
+    {
+    case 0: // World
+      this->GetSlicer(i)->GetSlicingTransform()->Identity();
+      break;
+    case 1: // Voxels
+      this->GetSlicer(i)->GetSlicingTransform()->SetMatrix(mImageTransformInverse);
+      break;
+    default:
+      mImageTransformInverse->Delete();
+      return;
+    }
+    this->GetSlicer(i)->ForceUpdateDisplayExtent();
+    this->GetSlicer(i)->ResetCamera();
+    this->GetSlicer(i)->Render();
+  }
+
+  mImageTransformInverse->Delete();
+  mSlicingPreset = preset;
+}
+
+//----------------------------------------------------------------------------
 
 //----------------------------------------------------------------------------
 void vvSlicerManager::SetPreset(int preset)
@@ -1140,7 +1186,7 @@ void vvSlicerManager::SetLocalColorWindowing(const int slicer, const bool bCtrlK
   else {
     this->mSlicers[slicer]->GetExtremasAroundMousePointer(min, max,
                                                           this->mSlicers[slicer]->GetImage()->GetVTKImages()[t],
-                                                          this->mSlicers[slicer]->GetImage()->GetTransform());
+                                                          this->mSlicers[slicer]->GetConcatenatedTransform());
     this->SetColorWindow(max-min);
     this->SetColorLevel(0.5*(min+max));
     this->SetPreset(6);
index 9858d69fdb23f0615c8666e8ee24e1d68e200148..b469277ff38d84f407aac0752cf30dfba1961946 100644 (file)
@@ -151,6 +151,9 @@ class vvSlicerManager : public QObject {
   int GetPreset() {
     return mPreset;
   }
+  int GetSlicingPreset() {
+    return mSlicingPreset;
+  }
   int GetOverlayColor() const {
     return mOverlayColor;
   }
@@ -203,6 +206,7 @@ class vvSlicerManager : public QObject {
   void UpdateSlice(int slicer);
   void UpdateTSlice(int slicer);
   void UpdateSliceRange(int slicer);
+  void SetSlicingPreset(int preset);
 
   vvLandmarks *GetLandmarks();
   void AddLandmark(float x,float y,float z,float t);
@@ -251,6 +255,7 @@ protected:
   bool mFusionShowLegend;
 
   int mPreset;
+  int mSlicingPreset;
   vvImageReader::LoadedImageType mType;
   std::string mVFComponent;
   std::string mOverlayComponent;
index 1b7103301b7d9f0544c731c14ccca913a623657d..9929e9d4f5c0b4e005dcf5ea7723ba21422d0c1f 100644 (file)
@@ -362,7 +362,12 @@ void vvSlicerManagerCommand::Execute(vtkObject *caller,
         zWorld = z;
         break;
       }
-      this->SM->GetSlicer(VisibleInWindow)->SetCurrentPosition(xWorld,yWorld,zWorld,
+
+      double p[3]; p[0] = xWorld; p[1] = yWorld; p[2] = zWorld;
+      double pt[3];
+      this->SM->GetSlicer(VisibleInWindow)->GetSlicingTransform()->TransformPoint(p, pt);
+
+      this->SM->GetSlicer(VisibleInWindow)->SetCurrentPosition(pt[0],pt[1],pt[2],
           this->SM->GetSlicer(VisibleInWindow)->GetTSlice());
       if (newLandmark) {
         this->SM->AddLandmark(xWorld,yWorld,zWorld,