]> Creatis software - clitk.git/blobdiff - vv/vvSlicer.cxx
- add other types/dim (warning still bugs ! do not use)
[clitk.git] / vv / vvSlicer.cxx
index 256981fba78528394cb9f21b67828f7efefc94f8..331c236977b12d00ad9785dd5492d6aa685d479a 100644 (file)
@@ -88,6 +88,7 @@ vvSlicer::vvSlicer()
   mSubSampling = 5;
   mScale = 1;
   mVFLog = 0;
+  mVFWidth = 1;
 
   std::string text = "F1 = sagital; F2 = coronal; F3 = axial\n";
   text += "F5 = horizontal flip; F6 = vertical flip\n\n";
@@ -281,6 +282,26 @@ void vvSlicer::SetImage(vvImage::Pointer image)
     {
       mImage = image;
       this->Superclass::SetInput(image->GetVTKImages()[0]);
+
+      // Prevent crash when reload -> change slice if outside extent
+      int extent[6];
+      this->GetInput()->GetWholeExtent(extent);
+      if (SliceOrientation == 0) {
+        if (Slice >= extent[1]) {
+          Slice = (extent[1]-extent[0])/2.0;
+        }
+      }
+      if (SliceOrientation == 1) {
+        if (Slice >= extent[3]) {
+          Slice = (extent[3]-extent[2])/2.0;
+        }
+      }
+      if (SliceOrientation == 2) {
+        if (Slice >= extent[5]) {
+          Slice = (extent[5]-extent[4])/2.0;
+        }
+      }
+
       this->UpdateDisplayExtent();
       mCurrentTSlice = 0;
       ca->SetText(0,mFileName.c_str());
@@ -423,6 +444,7 @@ void vvSlicer::SetVF(vvImage::Pointer vf)
         mVFActor = vtkActor::New();
       mVFActor->SetMapper(mVFMapper);
       mVFActor->SetPickable(0);
+      mVFActor->GetProperty()->SetLineWidth(mVFWidth);
       this->UpdateDisplayExtent();
       this->GetRenderer()->AddActor(mVFActor);
 
@@ -545,6 +567,17 @@ void vvSlicer::SetVFScale(int scale)
 }
 //------------------------------------------------------------------------------
 
+//------------------------------------------------------------------------------
+void vvSlicer::SetVFWidth(int width)
+{
+  mVFWidth = width;
+  if (mVFActor)
+    mVFActor->GetProperty()->SetLineWidth(mVFWidth);
+  UpdateDisplayExtent();
+  Render();
+}
+//------------------------------------------------------------------------------
+
 
 //------------------------------------------------------------------------------
 void vvSlicer::SetVFLog(int log)
@@ -1375,7 +1408,11 @@ void vvSlicer::SetSlice(int slice)
   SetContourSlice();
   this->Modified();
   this->UpdateDisplayExtent();
-  this->Render();
+
+  //  DD("SetSlice de slicer = Render");
+
+  // Seems to work without this line
+  //  this->Render();
 }
 //----------------------------------------------------------------------------