]> Creatis software - bbtk.git/blobdiff - packages/vtk/src/bbvtkImagePlanes.cxx
New widget pipeline : progressing ...
[bbtk.git] / packages / vtk / src / bbvtkImagePlanes.cxx
index 4241c6912daafd9275e21d52dc52f3e62fd3e562..191fcfa426eca62c0f869e548e2d1f94a45431bb 100644 (file)
@@ -1,27 +1,38 @@
-/*=========================================================================
-                                                                                
+/*=========================================================================                                                                               
   Program:   bbtk
   Module:    $RCSfile: bbvtkImagePlanes.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/05/09 10:39:46 $
-  Version:   $Revision: 1.3 $
-                                                                                
-  Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
-  l'Image). All rights reserved. See Doc/License.txt or
-  http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details.
-                                                                                
-     This software is distributed WITHOUT ANY WARRANTY; without even
-     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-     PURPOSE.  See the above copyright notices for more information.
-                                                                                
+  Date:      $Date: 2008/11/25 11:17:23 $
+  Version:   $Revision: 1.10 $
 =========================================================================*/
+
+/* ---------------------------------------------------------------------
+
+* Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
+* Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
+*
+*  This software is governed by the CeCILL-B license under French law and 
+*  abiding by the rules of distribution of free software. You can  use, 
+*  modify and/ or redistribute the software under the terms of the CeCILL-B 
+*  license as circulated by CEA, CNRS and INRIA at the following URL 
+*  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 
+*  or in the file LICENSE.txt.
+*
+*  As a counterpart to the access to the source code and  rights to copy,
+*  modify and redistribute granted by the license, users are provided only
+*  with a limited warranty  and the software's author,  the holder of the
+*  economic rights,  and the successive licensors  have only  limited
+*  liability. 
+*
+*  The fact that you are presently reading this means that you have had
+*  knowledge of the CeCILL-B license and that you accept its terms.
+* ------------------------------------------------------------------------ */                                                                         
+
 /**
  *  \file 
  *  \brief 
  */
 
-
-
 #ifdef _USE_VTK_
 #include "bbvtkImagePlanes.h"
 #include "bbvtkPackage.h"
@@ -49,8 +60,6 @@ namespace bbvtk
 
 }
 
-
-
 namespace bbvtk
 {
 
@@ -58,29 +67,30 @@ namespace bbvtk
    BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,ImagePlanes)
    BBTK_BLACK_BOX_IMPLEMENTATION(ImagePlanes,bbtk::AtomicBlackBox);
 
-
-
-
-
    void ImagePlanes::bbUserConstructor() 
    { 
-     Init();
+     planeWidgetX = planeWidgetY = planeWidgetZ = 0;
      bbSetInputIn(0);
+     std::vector<double> vect;
+     vect.push_back(512);
+     vect.push_back(256);
+     bbSetInputWindowLevel (vect);
    }
-   void ImagePlanes::bbUserCopyConstructor() 
+   
+   void ImagePlanes::bbUserCopyConstructor(bbtk::BlackBox::Pointer) 
    { 
-     Init();
+     planeWidgetX = planeWidgetY = planeWidgetZ = 0;
    }
 
    void ImagePlanes::Init() 
    { 
-     
+     if (planeWidgetX != 0) return;
      // The shared picker enables us to use 3 planes at one time
      // and gets the picking order right
      vtkCellPicker* picker = vtkCellPicker::New();
      picker->SetTolerance(0.005);
   
-     // The 3 image plane widgets are used to probe the dataset.
+     // The 3 image plane widgets 
      planeWidgetX = vtkImagePlaneWidget::New();
      planeWidgetX->DisplayTextOn();
      planeWidgetX->SetPicker(picker);
@@ -96,9 +106,6 @@ namespace bbvtk
      prop2->SetColor(1, 1, 0);
      planeWidgetY->SetLookupTable(planeWidgetX->GetLookupTable());
 
-     // for the z-slice, turn off texture interpolation:
-     // interpolation is now nearest neighbour, to demonstrate
-     // cross-hair cursor snapping to pixel centers
      planeWidgetZ = vtkImagePlaneWidget::New();
      planeWidgetZ->DisplayTextOn();
      planeWidgetZ->SetPicker(picker);
@@ -117,15 +124,20 @@ namespace bbvtk
 //---------------------------------------------------------------------
   void ImagePlanes::bbUserDestructor()
   {
-    planeWidgetX->Delete();
-    planeWidgetY->Delete();
-    planeWidgetZ->Delete();
+
+    if (planeWidgetX) planeWidgetX->UnRegister(NULL);
+    if (planeWidgetY) planeWidgetY->UnRegister(NULL);
+    if (planeWidgetZ) planeWidgetZ->UnRegister(NULL);
+
   }
   
+//---------------------------------------------------------------------  
    void ImagePlanes::Process()
    {
      if (bbGetInputIn()!=0)
        {
+        Init();
+
         int xMin, xMax, yMin, yMax, zMin, zMax;
         bbGetInputIn()->GetExtent(xMin, xMax, yMin, yMax, zMin, zMax);
 
@@ -141,7 +153,9 @@ namespace bbvtk
         planeWidgetZ->SetPlaneOrientationToZAxes();
         planeWidgetZ->SetSlicePosition((zMax+zMin)/2.); 
 
-        planeWidgetZ->SetWindowLevel(512,256);
+       // planeWidgetZ->SetWindowLevel(512,256);
+
+         planeWidgetZ->SetWindowLevel(bbGetInputWindowLevel()[0],bbGetInputWindowLevel()[1]);
        }
    }
 }//namespace bbtk