]> Creatis software - bbtk.git/commitdiff
*** empty log message ***
authorguigues <guigues>
Wed, 3 Dec 2008 13:35:22 +0000 (13:35 +0000)
committerguigues <guigues>
Wed, 3 Dec 2008 13:35:22 +0000 (13:35 +0000)
14 files changed:
kernel/src/bbtkBlackBox.cxx
kernel/src/bbtkBlackBox.h
packages/kw/bbs/appli/exampleSlider.bbs
packages/kw/src/bbkwLayoutSplit.h
packages/kw/src/bbkwOutputText.cxx [new file with mode: 0644]
packages/kw/src/bbkwOutputText.h [new file with mode: 0644]
packages/kw/src/bbkwSlicer.h
packages/kw/src/bbkwSlider.h
packages/std/src/bbstdFilesFromDirectory.cxx
packages/vtk/src/bbvtkImagePlanes.cxx
packages/vtk/src/bbvtkImagePlanes.h
packages/wxvtk/src/bbwxvtkViewer2D.cxx
packages/wxvtk/src/bbwxvtkViewer2D.h
packages/wxvtk/src/bbwxvtkViewer3D.cxx

index 5fc7d01babe0b9224cb59e7b194a34e24e9aafe7..f8ad055c388726fdc01ea57d9618ccbff060c30b 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkBlackBox.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/12/03 09:34:37 $
-  Version:   $Revision: 1.30 $
+  Date:      $Date: 2008/12/03 13:35:22 $
+  Version:   $Revision: 1.31 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
@@ -488,7 +488,6 @@ namespace bbtk
       {
        bbtkDebugMessage("modified",2,"-> Status set to modified"<<std::endl);
        this->bbSetStatus(MODIFIED); 
-       std::cout << "Status set to modified" <<std::endl;
       }
  
     this->bbSignalOutputModification(false);
@@ -505,7 +504,8 @@ namespace bbtk
   void BlackBox::bbSignalOutputModification(bool reaction)
   {
     bbtkDebugMessageInc("process",5,
-                       "=> BlackBox::bbSignalOutputModification() ["
+                       "=> BlackBox::bbSignalOutputModification("
+                       <<reaction<<") ["
                        <<bbGetFullName()<<"]"<<std::endl);
     
     OutputConnectorMapType::iterator change = bbGetOutputConnectorMap().end();
@@ -533,11 +533,11 @@ namespace bbtk
   //=========================================================================   
   //=========================================================================  
   void BlackBox::bbSignalOutputModification(const std::string& output,
-       bool reaction)
+                                           bool reaction)
   {
     bbtkDebugMessageInc("process",5,
                        "=> BlackBox::bbSignalOutputModification("
-                       <<output<<") ["
+                       <<output<<","<<reaction<<") ["
                        <<bbGetFullName()<<"]"<<std::endl);
     
     OutputConnectorMapType::iterator i = bbGetOutputConnectorMap().find(output);
index 2082d77676c6e57a072f13e5f717d59ced7da307..729365a315d23775c3d2ffd31369a0c05ffad69f 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkBlackBox.h,v $
   Language:  C++
-  Date:      $Date: 2008/12/03 09:34:37 $
-  Version:   $Revision: 1.15 $
+  Date:      $Date: 2008/12/03 13:35:22 $
+  Version:   $Revision: 1.16 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
@@ -105,26 +105,36 @@ namespace bbtk
 
     ///  Signals that the BlackBox has been modified through the input connector c
     /// and propagates it downward
+    /// ** NOT USER INTENDED **
     virtual void bbSetModifiedStatus(BlackBoxInputConnector* c = 0);
+
     /// Signals that the BlackBox outputs have been modified 
-    /// without marking the box as MODIFIED because its output state is ok. 
+    /// (without marking the box as MODIFIED because its output state is ok : don't care if you understand : use it !).
     /// This method should be used by widgets in response 
     /// to user interaction when **ALL** outputs have been modified
-    /// (after the outputs has been updated !)
+    /// (after the outputs has been updated !).
+    /// DO NOT PASS reaction = false OR WILL NOT WORK PROPERLY
+    /// ** USER INTENDED **
     virtual void bbSignalOutputModification(bool reaction = true);
-    ///  Signals that the BlackBox output "output_name" have been modified 
-    /// without marking the box as MODIFIED because its output state is ok
+    /// Signals that the BlackBox output "output_name" has been modified 
+    /// (without marking the box as MODIFIED because its output state is ok : don't care if you understand : use it !)
     /// This method should be used by widgets in response to user interaction 
     /// only when **ONE** output has been modified
     /// (after the output has been updated !)
+    /// DO NOT PASS reaction = false OR WILL NOT WORK PROPERLY
+    /// ** USER INTENDED **
     virtual void bbSignalOutputModification( const std::string& output_name,
 bool reaction = true);
-    ///  Signals that the BlackBox vector of outputs "output_name" 
-    ///  have been modified 
-    /// without marking the box as MODIFIED because its output state is ok. 
+    /// Signals that the BlackBox vector of outputs "output_name" 
+    /// have been modified.
+    /// Should be used when more than ONE output is modified but not ALL 
+    /// (optimization issue).
+    /// (without marking the box as MODIFIED because its output state is ok). 
     /// This method should be used by widgets in response to user interaction 
     /// When more than one output has been changed but not all
     /// (after the outputs have been updated of course!)
+    /// DO NOT PASS reaction = false OR WILL NOT WORK PROPERLY
+    /// ** USER INTENDED **
     virtual void bbSignalOutputModification( const std::vector<std::string>& output_name,
 bool reaction = true);
 
index 11ea4ed17ee9bbb6b62e5a449a34a6106510cd5e..1eb6e4595c75dae5ec2d0d3caebddd9e4c245b44 100644 (file)
@@ -1,4 +1,4 @@
 load kw
-new Slider s
+new kwSlider s
 exec s
-unload kw
+#unload kw
index 7aad4daae6bff2cda2ae86e4a2fc75dcf181dd12..a6b5e198349538b9d1963c1f6d30887965082044 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbkwLayoutSplit.h,v $
   Language:  C++
-  Date:      $Date: 2008/12/02 13:37:56 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2008/12/03 13:35:27 $
+  Version:   $Revision: 1.3 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
@@ -77,7 +77,7 @@ namespace bbkw
 //=================================================================
 // BlackBox description
   BBTK_BEGIN_DESCRIBE_BLACK_BOX(LayoutSplit,bbtk::KWBlackBox);
-  BBTK_NAME("LayoutSplit");
+  BBTK_NAME("kwLayoutSplit");
   BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
   BBTK_DESCRIPTION("Widget which splits a window in two fixed size parts (vtkKWSplitFrame)");
   // Already inserted for any KwBlackBox  BBTK_CATEGORY("widget");
diff --git a/packages/kw/src/bbkwOutputText.cxx b/packages/kw/src/bbkwOutputText.cxx
new file mode 100644 (file)
index 0000000..509d46c
--- /dev/null
@@ -0,0 +1,117 @@
+/*=========================================================================                                                                               
+  Program:   bbtk
+  Module:    $RCSfile: bbkwOutputText.cxx,v $
+  Language:  C++
+  Date:      $Date: 2008/12/03 13:35:27 $
+  Version:   $Revision: 1.1 $
+=========================================================================*/
+
+/* ---------------------------------------------------------------------
+
+* 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 Short description in one line
+ *
+ * Long 
+ * description
+ *  
+ */
+
+#ifdef USE_KWWIDGETS
+
+#include "bbkwOutputText.h"
+#include "bbkwPackage.h"
+#include "bbtkUtilities.h"
+
+#include "vtkKWLabel.h"
+/*
+#include "vtkObjectFactory.h"
+#include "vtkCommand.h"
+*/
+namespace bbkw
+{
+
+  //--------------------------------------------------------------------------
+  //-------------------------------------------------------------------------
+  // KwBlackBox implementation
+  //--------------------------------------------------------------------------
+  //--------------------------------------------------------------------------
+
+   //--------------------------------------------------------------------------
+  BBTK_BLACK_BOX_IMPLEMENTATION(OutputText,bbtk::KWBlackBox);
+  BBTK_ADD_BLACK_BOX_TO_PACKAGE(kw,OutputText);
+  
+  //--------------------------------------------------------------------------
+  void OutputText::bbUserConstructor() 
+  { 
+    bbSetInputIn("");
+    bbSetOutputWidget(0);
+  }
+  
+ //--------------------------------------------------------------------------
+  void OutputText::Process() 
+  {
+    vtkKWLabel* s = (vtkKWLabel*)bbGetOutputWidget();
+    if (s)
+      {
+       s->SetText( bbGetInputIn().c_str() );
+      }
+  }
+  //--------------------------------------------------------------------------
+
+  //--------------------------------------------------------------------------
+  void OutputText::CreateWidget(vtkKWFrame* parent) 
+  {
+    vtkKWLabel* s = vtkKWLabel::New();
+    bbSetOutputWidget(s);
+    //    s->AddObserver(vtkKWScale::ScaleValueChangingEvent,this);
+    s->SetParent((vtkKWWidget*)parent);
+    s->Create();
+
+    s->SetText(bbGetInputIn().c_str() );
+    // s->SetResolution(1.0);
+    // s->SetLength(150);
+  }
+  //--------------------------------------------------------------------------
+
+  //--------------------------------------------------------------------------
+  /*  
+  void OutputText::Execute(vtkObject* caller, unsigned long, void*)
+  {
+    //    std::cout << "$$$$$$$$$$$$ OutputText CB $$$$$$$$$$$$"<<std::endl;
+    vtkKWScale* scale = (vtkKWScale*)caller;
+    bbSetOutputOut( scale->GetValue() );
+    bbSetInputIn( scale->GetValue() );
+    // and signal that the output has changed
+    bbSignalOutputModification("Out");    
+  } 
+  */
+  //--------------------------------------------------------------------------
+  
+
+
+} //namespace bbkw
+
+#endif // USE_KWWIDGETS
+
+
diff --git a/packages/kw/src/bbkwOutputText.h b/packages/kw/src/bbkwOutputText.h
new file mode 100644 (file)
index 0000000..70eb419
--- /dev/null
@@ -0,0 +1,96 @@
+/*=========================================================================                                                                               
+  Program:   bbtk
+  Module:    $RCSfile: bbkwOutputText.h,v $
+  Language:  C++
+  Date:      $Date: 2008/12/03 13:35:27 $
+  Version:   $Revision: 1.1 $
+=========================================================================*/
+
+/* ---------------------------------------------------------------------
+
+* 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 Short description in one line
+ * 
+ * Long description which 
+ * can span multiple lines
+*/
+
+/**
+ * \class bbkw::OutputText
+ * \brief 
+
+ * \class bbkw::OutputTextWidget
+ * \brief 
+ */
+
+#ifdef USE_KWWIDGETS
+
+#ifndef __bbkwOutputText_h_INCLUDED__
+#define __bbkwOutputText_h_INCLUDED__
+
+// Include KWBlackBox definition
+#include "bbtkKWBlackBox.h"
+
+//#include "vtkCommand.h"
+
+
+namespace bbkw
+{
+  
+  //------------------------------------------------------------------------
+  // The black box
+  class /*BBTK_EXPORT*/ OutputText : public bbtk::KWBlackBox //, public vtkCommand
+  {
+    
+    BBTK_BLACK_BOX_INTERFACE(OutputText,bbtk::KWBlackBox);
+    BBTK_DECLARE_INPUT(In,std::string);
+    BBTK_PROCESS(Process);
+    BBTK_CREATE_KWWIDGET(CreateWidget);
+    void Process();
+    void CreateWidget(vtkKWFrame*);
+    //    virtual void Execute(vtkObject* caller, unsigned long, void*);
+ protected:
+    virtual void bbUserConstructor();
+  };
+  //=================================================================
+  //=================================================================
+  // the black box description
+  BBTK_BEGIN_DESCRIBE_BLACK_BOX(OutputText,bbtk::KWBlackBox);
+  BBTK_NAME("kwOutputText");
+  BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
+  // Already inserted for any KWBlackBox  BBTK_CATEGORY("widget");
+  BBTK_DESCRIPTION("OutputText widget (vtkKWLabel)");
+  BBTK_INPUT(OutputText,In,"Text to display",std::string,"");
+  BBTK_END_DESCRIBE_BLACK_BOX(OutputText);
+  //=================================================================
+  
+
+
+} //namespace bbkw
+
+#endif  //__bbtkkwOutputText_h_INCLUDED__
+
+#endif // USE_KWWIDGETS
index 158dd0c9d2789449c48fc3154bd5834f54377085..0fa1eefb48e01d2bba9244a9215ff596f03a6766 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbkwSlicer.h,v $
   Language:  C++
-  Date:      $Date: 2008/12/02 13:37:56 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2008/12/03 13:35:27 $
+  Version:   $Revision: 1.3 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
@@ -83,7 +83,7 @@ namespace bbkw
   //=================================================================
   // the black box description
   BBTK_BEGIN_DESCRIBE_BLACK_BOX(Slicer,bbtk::KWBlackBox);
-  BBTK_NAME("Slicer");
+  BBTK_NAME("kwSlicer");
   BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
   // Already inserted for any KWBlackBox  BBTK_CATEGORY("widget");
   BBTK_DESCRIPTION("Slicer widget (vtkKWSlicer)");
index f2be2cc3ad0de049bd7079fef161c36f9965eba6..c37f4759f36fa6d6ea89b488716bc8db681d4690 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbkwSlider.h,v $
   Language:  C++
-  Date:      $Date: 2008/12/02 13:37:56 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2008/12/03 13:35:27 $
+  Version:   $Revision: 1.3 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
@@ -94,7 +94,7 @@ namespace bbkw
   //=================================================================
   // the black box description
   BBTK_BEGIN_DESCRIBE_BLACK_BOX(Slider,bbtk::KWBlackBox);
-  BBTK_NAME("Slider");
+  BBTK_NAME("kwSlider");
   BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
   // Already inserted for any KWBlackBox  BBTK_CATEGORY("widget");
   BBTK_DESCRIPTION("Slider widget (vtkKWScale)");
index d7c747e660d7e3638f77a9a100168d92c12dcceb..60696231cf5d464266364efde142fa5d730246ad 100644 (file)
@@ -52,7 +52,7 @@ void FilesFromDirectory::bbUserDestructor()
 std::string FilesFromDirectory::NormalizePath(std::string const &pathname)
 {
 #ifdef _WIN32
-   const char FILESEPARATOR = '\\;
+   const char FILESEPARATOR = '\\';
 #else
    const char FILESEPARATOR = '/';
 #endif
index 79ab3850b81e61815cc83328d6940080d02b13cb..b405d90f90cc6678f15e4fe59829d818608d92fe 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbvtkImagePlanes.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/12/03 09:34:39 $
-  Version:   $Revision: 1.14 $
+  Date:      $Date: 2008/12/03 13:35:32 $
+  Version:   $Revision: 1.15 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
 #include "bbvtkPackage.h"
 #include "vtkCellPicker.h"
 #include "vtkProperty.h"
+
 #include "vtkMetaImageWriter.h"
+#include "vtkPNGWriter.h"
 
 #include "bbstdCast.h"
+#include <vtkCommand.h>
+
+#include "vtkImageData.h"
+//#include "vtkOutlineFilter.h"
+//#include "vtkPolyDataMapper.h"
+//#include "vtkActor.h"
+#include "vtkImagePlaneWidget.h"
+#include "vtkCellPicker.h"
+//#include "vtkProperty.h"
+
+//#include "vtkRenderer.h"
+//#include "vtkCamera.h"
+
+#include "vtkPlaneWidget.h"
+
+
 namespace bbstd
 {
+
   //====================================================================
   BBTK_BLACK_BOX_TEMPLATE2_IMPLEMENTATION(Cast,
                                          bbtk::AtomicBlackBox);
@@ -52,6 +71,8 @@ namespace bbstd
 using namespace bbstd;
 namespace bbvtk
 {
+
+
   //====================================================================
   // Add the specialized adaptors to the package
   typedef vtkImagePlaneWidget* I;
@@ -64,31 +85,66 @@ namespace bbvtk
 namespace bbvtk
 {
 
+  //================================================================
+ class myCallbackPlane : public vtkCommand
+ {
+ public:
+   static myCallbackPlane *New()
+      {
+         return new myCallbackPlane;
+      }
+   virtual void Execute(vtkObject *caller, unsigned long, void*)
+   {
+       currentBlackBox->Process();
+       currentBlackBox->bbSignalOutputModification();
+   } 
+   void SetCurrentBlackBox(ImagePlanes *cBB) {currentBlackBox = cBB;};    
+   void SetVtkPlaneWidget( vtkImagePlaneWidget *planeWidget );
+   myCallbackPlane() {};
+
+ private:
+   vtkPlaneWidget *planeWidget;
+   ImagePlanes *currentBlackBox;
+ };
+  //================================================================
+
+
+
+  //================================================================
+
    BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,ImagePlanes)
    BBTK_BLACK_BOX_IMPLEMENTATION(ImagePlanes,bbtk::AtomicBlackBox);
 
    void ImagePlanes::bbUserConstructor() 
    { 
-     planeWidgetX = planeWidgetY = planeWidgetZ = 0;
-     imageX       = imageY       = imageZ       = 0;
+     bbSetOutputPlaneX(0);
+     bbSetOutputPlaneY(0);
+     bbSetOutputPlaneZ(0);
+     bbSetOutputImageX(0);
+     bbSetOutputImageY(0);
+     bbSetOutputImageZ(0);
      bbSetInputIn(0);
      std::vector<double> vect;
-     vect.push_back(512);
-     vect.push_back(256);
+     vect.push_back(0);
+     vect.push_back(0);
      bbSetInputWindowLevel (vect);  
-
-     bbSetModifiedStatus();
    }
    
    void ImagePlanes::bbUserCopyConstructor(bbtk::BlackBox::Pointer) 
    { 
-     planeWidgetX = planeWidgetY = planeWidgetZ = 0;
-     imageX       = imageY       = imageZ       = 0;
+     bbSetOutputPlaneX(0);
+     bbSetOutputPlaneY(0);
+     bbSetOutputPlaneZ(0);
+     bbSetOutputImageX(0);
+     bbSetOutputImageY(0);
+     bbSetOutputImageZ(0);
    }
 
    void ImagePlanes::Init() 
    {  
-     if (planeWidgetX != 0) return;
+
+     /// CREATION DES WIDGETS
+     if (bbGetOutputPlaneX() != 0) return;
        
      // The shared picker enables us to use 3 planes at one time
      // and gets the picking order right
@@ -96,14 +152,14 @@ namespace bbvtk
      picker->SetTolerance(0.005);
   
      // The 3 image plane widgets 
-     planeWidgetX = vtkImagePlaneWidget::New();
+     vtkImagePlaneWidget* planeWidgetX = vtkImagePlaneWidget::New();
      planeWidgetX->DisplayTextOn();
      planeWidgetX->SetPicker(picker);
      planeWidgetX->SetKeyPressActivationValue('x');
      vtkProperty* prop1 = planeWidgetX->GetPlaneProperty();
      prop1->SetColor(1, 0, 0);
 
-     planeWidgetY = vtkImagePlaneWidget::New();
+     vtkImagePlaneWidget* planeWidgetY = vtkImagePlaneWidget::New();
      planeWidgetY->DisplayTextOn();
      planeWidgetY->SetPicker(picker);
      planeWidgetY->SetKeyPressActivationValue('y');
@@ -111,7 +167,7 @@ namespace bbvtk
      prop2->SetColor(1, 1, 0);
      planeWidgetY->SetLookupTable(planeWidgetX->GetLookupTable());
 
-     planeWidgetZ = vtkImagePlaneWidget::New();
+     vtkImagePlaneWidget* planeWidgetZ = vtkImagePlaneWidget::New();
      planeWidgetZ->DisplayTextOn();
      planeWidgetZ->SetPicker(picker);
      planeWidgetZ->SetKeyPressActivationValue('z');
@@ -122,6 +178,9 @@ namespace bbvtk
      bbSetOutputPlaneX(planeWidgetX);
      bbSetOutputPlaneY(planeWidgetY);
      bbSetOutputPlaneZ(planeWidgetZ);
+     bbSetOutputImageX(planeWidgetX->GetResliceOutput());
+     bbSetOutputImageY(planeWidgetY->GetResliceOutput());
+     bbSetOutputImageZ(planeWidgetZ->GetResliceOutput());
 
      picker->UnRegister(NULL);
      
@@ -136,10 +195,9 @@ namespace bbvtk
   void ImagePlanes::bbUserDestructor()
   {
 
-    if (planeWidgetX) planeWidgetX->UnRegister(NULL);
-    if (planeWidgetY) planeWidgetY->UnRegister(NULL);
-    if (planeWidgetZ) planeWidgetZ->UnRegister(NULL);
-
+    if (bbGetOutputPlaneX()) bbGetOutputPlaneX()->UnRegister(NULL);
+    if (bbGetOutputPlaneY()) bbGetOutputPlaneY()->UnRegister(NULL);
+    if (bbGetOutputPlaneZ()) bbGetOutputPlaneZ()->UnRegister(NULL);
   }
   
 //---------------------------------------------------------------------  
@@ -147,61 +205,53 @@ namespace bbvtk
    {
      if (bbGetInputIn()!=0)
        {
+        // Create the widgets if not already done
         Init();
 
-        int xMin, xMax, yMin, yMax, zMin, zMax;
-        bbGetInputIn()->GetExtent(xMin, xMax, yMin, yMax, zMin, zMax);
+        if ( bbGetInputIn() != image)
+          {
+            // Input image has changed : reinitialize planes
+            image = bbGetInputIn();
 
-         // Initial values : center of the volume (in real world, not in pixels!)
-         double xSpacing, ySpacing, zSpacing;
-        bbGetInputIn()->GetSpacing(xSpacing, ySpacing, zSpacing);
-        
-        planeWidgetX->SetInput(bbGetInputIn());
-        planeWidgetX->SetPlaneOrientationToXAxes();     
-        planeWidgetX->SetSlicePosition((xMax+xMin)/2.*xSpacing);
-        planeWidgetX->GetResliceOutput()->Update();
-        bbSetOutput("ImageX", planeWidgetX->GetResliceOutput());
-        
-        
-        vtkMetaImageWriter *writer = vtkMetaImageWriter::New();
-        
-        std::string newFilenameX("newFilenameX.mhd");
-        writer->SetInput(planeWidgetX->GetResliceOutput());
-        writer->SetFileName(newFilenameX.c_str());
-        writer->Update();
+            int xMin, xMax, yMin, yMax, zMin, zMax;
+            bbGetInputIn()->GetExtent(xMin, xMax, yMin, yMax, zMin, zMax);
+            
+            // Initial values : center of the volume (in real world, not in pixels!)
+            double xSpacing, ySpacing, zSpacing;
+            bbGetInputIn()->GetSpacing(xSpacing, ySpacing, zSpacing);
+            
+            bbGetOutputPlaneX()->SetInput(bbGetInputIn());
+            bbGetOutputPlaneX()->SetPlaneOrientationToXAxes();  
+            bbGetOutputPlaneX()->SetSlicePosition((xMax+xMin)/2.*xSpacing);
+            
+            bbGetOutputPlaneY()->SetInput(bbGetInputIn());
+            bbGetOutputPlaneY()->SetPlaneOrientationToYAxes();
+            bbGetOutputPlaneY()->SetSlicePosition((yMax+yMin)/2.*ySpacing);
+            
+            bbGetOutputPlaneZ()->SetInput(bbGetInputIn());
+            bbGetOutputPlaneZ()->SetPlaneOrientationToZAxes();
+            bbGetOutputPlaneZ()->SetSlicePosition((zMax+zMin)/2.*zSpacing);
+            
+            if (bbGetInputWindowLevel()[0]!=0)
+              {
+                bbGetOutputPlaneZ()->SetWindowLevel(bbGetInputWindowLevel()[0],
+                                                    bbGetInputWindowLevel()[1]);
+              }
+            else 
+              {
+                double *range = image->GetScalarRange();
+                bbGetOutputPlaneZ()->SetWindowLevel(range[1] - range[0],
+                                                    0.5*(range[1]+range[0]));
+              }
+          }
         
-        //planeWidgetX->GetResliceOutput()->Print(std::cout);
-
-        planeWidgetY->SetInput(bbGetInputIn());
-        planeWidgetY->SetPlaneOrientationToYAxes();
-        planeWidgetY->SetSlicePosition((yMax+yMin)/2.*ySpacing);
-        planeWidgetY->GetResliceOutput()->Update(); 
-        bbSetOutput("ImageY", planeWidgetY->GetResliceOutput());
-        //planeWidgetY->GetResliceOutput()->Print(std::cout);
         
-        std::string newFilenameY("newFilenameY.mhd");
-        writer->SetInput(planeWidgetY->GetResliceOutput());
-        writer->SetFileName(newFilenameY.c_str());
-        writer->Update();
-                
-        planeWidgetZ->SetInput(bbGetInputIn());
-        planeWidgetZ->SetPlaneOrientationToZAxes();
-        planeWidgetZ->SetSlicePosition((zMax+zMin)/2.*zSpacing);
-        planeWidgetZ->GetResliceOutput()->Update(); 
-        bbSetOutput("ImageZ", planeWidgetZ->GetResliceOutput());
-       // planeWidgetZ->GetResliceOutput()->Print(std::cout);
-       
-       // planeWidgetZ->SetWindowLevel(512,256);
-       
-        std::string newFilenameZ("newFilenameZ.mhd");
-        writer->SetInput(planeWidgetZ->GetResliceOutput());
-        writer->SetFileName(newFilenameZ.c_str());
-        writer->Update();
-       
-         planeWidgetZ->SetWindowLevel(bbGetInputWindowLevel()[0],bbGetInputWindowLevel()[1]);
-       
-       // writer->vtkMetaImageWriter::Delete();
+        // UPDATE DES SORTIES 
+        bbGetOutputPlaneX()->GetResliceOutput()->Update();
+        bbGetOutputPlaneY()->GetResliceOutput()->Update(); 
+        bbGetOutputPlaneZ()->GetResliceOutput()->Update(); 
         
+                
        }
    }
 }//namespace bbtk
index 91c1475b7e895a3ce265f4a729938e3821e9dd8f..0bb4c788cd43c38875c6f70d6fade69224295e3d 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbvtkImagePlanes.h,v $
   Language:  C++
-  Date:      $Date: 2008/12/03 09:34:39 $
-  Version:   $Revision: 1.9 $
+  Date:      $Date: 2008/12/03 13:35:32 $
+  Version:   $Revision: 1.10 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
 
 #include "bbtkAtomicBlackBox.h"
 
-#include "vtkImageData.h"
-//#include "vtkOutlineFilter.h"
-//#include "vtkPolyDataMapper.h"
-//#include "vtkActor.h"
-#include "vtkImagePlaneWidget.h"
-#include "vtkCellPicker.h"
-//#include "vtkProperty.h"
 
-//#include "vtkRenderer.h"
-//#include "vtkCamera.h"
-
-#include <vtkCommand.h>
-#include "vtkPlaneWidget.h"
+class vtkImageData;
+class vtkImagePlaneWidget;
 
 namespace bbvtk
 {
@@ -96,13 +86,7 @@ namespace bbvtk
     virtual void bbUserDestructor();
     void Init();
   private:
-    vtkImagePlaneWidget* planeWidgetX;
-    vtkImagePlaneWidget* planeWidgetY;
-    vtkImagePlaneWidget* planeWidgetZ;
-    vtkImageData* imageX;
-    vtkImageData* imageY;    
-    vtkImageData* imageZ;
-
+    vtkImageData* image;
   };
    
   //=================================================================
@@ -126,31 +110,6 @@ namespace bbvtk
 
 
 
- class myCallbackPlane : public vtkCommand
- {
- public:
-   static myCallbackPlane *New()
-      {
-         return new myCallbackPlane;
-      }
-   virtual void Execute(vtkObject *caller, unsigned long, void*)
-   {
-       std::cout << "entree ds myCallbackPlane::Execute()" << std::endl;
-       printf("Execute Call Back on %p\n",caller); 
-
-       currentBlackBox->bbSetModifiedStatus();
-   } 
-   void SetCurrentBlackBox(bbtk::AtomicBlackBox *cBB) {currentBlackBox = cBB;};    
-   void SetVtkPlaneWidget( vtkImagePlaneWidget *planeWidget );
-   myCallbackPlane() 
-   {
-      // std::cout << "entree Constr myCallbackPlane" << std::endl;
-   };
-
- private:
-   vtkPlaneWidget *planeWidget;
-   bbtk::AtomicBlackBox *currentBlackBox;
- };
 
 
 }//namespace bbvtk
index e366505a15fe33dcccd1db67d19d5397b5b1cd95..929147e12b02085c35ee26a838b39b21adee96ed 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbwxvtkViewer2D.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/12/03 09:34:41 $
-  Version:   $Revision: 1.26 $
+  Date:      $Date: 2008/12/03 13:35:35 $
+  Version:   $Revision: 1.27 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -94,7 +94,8 @@ namespace bbwxvtk
     //  wxvtkrenderwindowinteractor->Render();
     //  imageViewer->GetRenderer()->ResetCameraClippingRange();
 
-  
+    imageViewer->GetRenderer()->SetBackground(0.1,0.1,0.2);
+
   }
   //-------------------------------------------------------------------------
   
@@ -136,16 +137,15 @@ namespace bbwxvtk
       {
        backImageData = mDefaultImage;
        mUpdateCamera = true;
-       std::cout << "Viewer2DWidget::UpdateView() passe par 1" << std::endl;
       }
     else if ( ( mBox->bbGetInputIn() != NULL ) && 
+             //      (true) ) //
              (backImageData != mBox->bbGetInputIn()) ) 
       {
        backImageData = mBox->bbGetInputIn();
        backImageData->Update();
        imageViewer->SetInput( backImageData );
        mUpdateCamera = true;
-               std::cout << "Viewer2DWidget::UpdateView() passe par 2" << std::endl;
       }
 
     if (mUpdateCamera)
@@ -155,10 +155,19 @@ namespace bbwxvtk
        backImageData->GetSpacing(spx,spy,spz);
        backImageData->GetExtent (x1,x2,y1,y2,z1,z2);
        
+       double *range = backImageData->GetScalarRange();
+       imageViewer->SetColorWindow(range[1] - range[0]);
+       imageViewer->SetColorLevel(0.5 * (range[1] + range[0]));
+
+       imageViewer->GetRenderer()->ResetCamera();
+       double bounds[6];
+       imageViewer->GetRenderer()->ComputeVisiblePropBounds(bounds);
+       imageViewer->GetRenderer()->ResetCameraClippingRange(bounds);
+       
        //      bbtkMessage("Output",2,"Viewer2D '"<<mBox->bbGetName()<<"' - Image :"<<std::endl);
        //      std::cout << " extent  = "<< x1<<"-"<<x2<<" x "<<y1<<"-"<<y2<<" x "<<z1<<"-"<<z2<<std::endl;
        //      std::cout << " spacing = "<<spx << " - "<< spy << " - "<<spz<<std::endl;
-       
+       /*
        vtkCamera *camera = imageViewer->GetRenderer()->GetActiveCamera();
 
        camera->SetViewUp    ( spx*0,         -spy*1,        spz*0 );
@@ -170,8 +179,17 @@ namespace bbwxvtk
        //   
        //      imageViewer->GetRenderer()->ResetCamera(x1,x2,y1,y2,z1,z2);
        mUpdateCamera = false;
-       std::cout << "Viewer2DWidget::UpdateView() passe par 3" << std::endl;
-      }
+       //      std::cout << "Viewer2DWidget::UpdateView() passe par 3" << std::endl;
+       imageViewer->SetColorWindow(512);
+       imageViewer->SetColorLevel(256);
+       */
+        /*
+       for (int i=0;i<10;i++)
+         for (int j=0;j<10;j++)
+           std::cout << mBox->bbGetInputIn()->GetScalarComponentAsFloat(i,j,0,0)
+                     << std::endl;
+        */
+    }
   
     //  std::cout << "OW = "<< mBox->bbGetWindow() << std::endl;
     //  std::cout << "CW = "<< mBox->bbGetContainingWindow() << std::endl;
@@ -179,7 +197,7 @@ namespace bbwxvtk
     
     int orientation = mBox->bbGetInputOrientation();
     if (orientation<0 || orientation>2) {
-       bbtkMessage("Output", 2, "Viewer2D : Orientation was not 0< <2 "<<std::endl);
+      bbtkMessage("Output", 2, "Viewer2D : Orientation was not 0< <2 "<<std::endl);
        orientation=2; // Why not?      
     }
     // mBox->bbIsShown() is necessary to be sure that the wxWindow is already 
@@ -193,9 +211,12 @@ namespace bbwxvtk
                //      std::cout << "slice = "<<z<<std::endl;
                int ext[6];
                backImageData->GetWholeExtent(ext);
-
-               //      std::cout << "ext = "<<ext[4]<<" - "<<ext[5]<<std::endl;
-
+               /*
+               std::cout << "ext = "<<ext[0]<<" - "<<ext[1]<<" ; "
+                         <<ext[2]<<" - "<<ext[3]<<" ; "
+                         <<ext[4]<<" - "<<ext[5]
+                         <<std::endl;
+               */
             switch(orientation){
               case 0:
                if (z<ext[0]) { z=ext[0]; }
@@ -218,36 +239,15 @@ namespace bbwxvtk
                z = ext[5]; // Why not?
            }
 
-           //      std::cout << "V2D Render "<<std::endl;
-           //      imageViewer->SetSliceOrientation (orientation);
-           //     imageViewer->SetSlice( z );
-
-          //            wxvtkrenderwindowinteractor->Update();
-          //            wxvtkrenderwindowinteractor->Render();
-          //          imageViewer->GetRenderer()->ResetCameraClippingRange();
-           //xvtkrenderwindowinteractor->Refresh();
+           bbtkDebugMessage("Output",3,"Viewer2D : slice = "<<z<<std::endl);
+           imageViewer->SetSliceOrientation (orientation);
            wxvtkrenderwindowinteractor->Render();
-    imageViewer->GetRenderer()->ResetCameraClippingRange();
-           imageViewer->SetSliceOrientation (orientation);
-          imageViewer->SetSlice( z );
-
-std::cout << "Viewer2DWidget::UpdateView() passe par 4" << std::endl;      
-/*
-       #if (VTK_MAJOR_VERSION >= 5)
-               imageViewer->SetSlice( z );
-       #else
-               imageViewer->SetZSlice( z );
-       #endif
-*/
-//           imageViewer->SetSliceOrientation (orientation);
-//        imageViewer->SetSlice( z );
-               
-               //imageViewer->UpdateDisplayExtent();
-  } 
-
+           imageViewer->SetSlice( z );
 
-}
+    } 
+    
+    
+  }
 
 
   vtkRenderer * Viewer2DWidget::GetRenderer()
@@ -270,23 +270,14 @@ std::cout << "Viewer2DWidget::UpdateView() passe par 4" << std::endl;
 
   void Viewer2D::Process() 
   { 
-    // LG : Bug on Linux (wxGTK) when initial slice != 0 on first time 
-    // (see wxvtk/bbs/appli/ExampleSimpleSlicer)
-    // I think there is a problem with rendering before window 
-    // has been reparented ... we have to check this 
-    
-std::cout << "Viewer2D::Process() passe par 5" << std::endl;      
-    
-         Viewer2DWidget* w = (Viewer2DWidget*)bbGetOutputWidget(); 
-         
+    Viewer2DWidget* w = (Viewer2DWidget*)bbGetOutputWidget(); 
     if (w)
-       {
-std::cout << "Viewer2D::Process() passe par 6" << std::endl;
-               w->UpdateView();
-               bbSetOutputRenderer( ((Viewer2DWidget*)bbGetOutputWidget())->GetRenderer() );
-       }
-         bbSetOutputOut( bbGetInputSlice() );
-         
+      {
+       w->UpdateView();
+       bbSetOutputRenderer( ((Viewer2DWidget*)bbGetOutputWidget())->GetRenderer() );
+      }
+    bbSetOutputOut( bbGetInputSlice() );
+    
   }
   
 
@@ -295,7 +286,7 @@ std::cout << "Viewer2D::Process() passe par 6" << std::endl;
     bbSetInputIn(NULL);
     bbSetInputSlice(0);
     bbSetOutputWidget(0);
-    bbSetInputOrientation(0);
+    bbSetInputOrientation(2);
   }
 
   /**
@@ -305,9 +296,7 @@ std::cout << "Viewer2D::Process() passe par 6" << std::endl;
    */ 
   void Viewer2D::CreateWidget(wxWindow* parent)
   {
-  std::cout << "Viewer2D::CreateWidget() passe par 7" << std::endl;
     Viewer2DWidget* w = new Viewer2DWidget(this,parent);//bbGetWxParent());
-
     bbSetOutputWidget(w);
   }
 
index 4ddaa9aa9cb107e5593fdfd2275d94901d3f5e98..c49437539f49ddabe3a39fbbddc152ca54e8fa08 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbwxvtkViewer2D.h,v $
   Language:  C++
-  Date:      $Date: 2008/11/24 15:45:54 $
-  Version:   $Revision: 1.10 $
+  Date:      $Date: 2008/12/03 13:35:35 $
+  Version:   $Revision: 1.11 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -58,7 +58,7 @@ namespace bbwxvtk
     Viewer2DWidget(Viewer2D* box, wxWindow *parent);
     ~Viewer2DWidget();
     void UpdateView();
-       vtkRenderer             *GetRenderer();
+    vtkRenderer                *GetRenderer();
   private:
     Viewer2D                    *mBox;
     vtkImageViewer2            *imageViewer;
@@ -67,7 +67,7 @@ namespace bbwxvtk
     wxVTKRenderWindowInteractor *wxvtkrenderwindowinteractor;
     bool mUpdateCamera;
 
-       vtkImplicitPlaneWidget * maPlane1, * maPlane2, * mbPlane1, * mbPlane2;
+    vtkImplicitPlaneWidget * maPlane1, * maPlane2, * mbPlane1, * mbPlane2;
   };
   
   //------------------------------------------------------------------------
index d856439593b1756c4f13b306f3feb960a36a30fa..73b75560c5fc8131f6fc8625a2ce5a4fc9404284 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbwxvtkViewer3D.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/11/25 13:18:38 $
-  Version:   $Revision: 1.12 $
+  Date:      $Date: 2008/12/03 13:35:35 $
+  Version:   $Revision: 1.13 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -208,13 +208,18 @@ void Viewer3DWidget::Refresh(bool eraseBackground , const wxRect* rect )
     vtkRenderer *renderer = w->GetRenderer();
     if (renderer!=NULL)
       {
+       bbSetOutputRenderer( renderer );
+         
        if (bbGetInputIn1()!=NULL) {renderer->AddActor( bbGetInputIn1() ); }
        if (bbGetInputIn2()!=NULL) {renderer->AddActor( bbGetInputIn2() ); }
        if (bbGetInputIn3()!=NULL) {renderer->AddActor( bbGetInputIn3() ); }
        if (bbGetInputIn4()!=NULL) {renderer->AddActor( bbGetInputIn4() ); }
        if (bbGetInputIn5()!=NULL) {renderer->AddActor( bbGetInputIn5() ); }
        renderer->ResetCamera();
-       bbSetOutputRenderer( renderer );
+        double bounds[6];
+        renderer->ComputeVisiblePropBounds(bounds);
+        renderer->ResetCameraClippingRange(bounds);
+
          }
 
     bbSetOutputWidget(w);