]> Creatis software - bbtk.git/commitdiff
KWWidgets support
authorguigues <guigues>
Tue, 2 Dec 2008 08:38:08 +0000 (08:38 +0000)
committerguigues <guigues>
Tue, 2 Dec 2008 08:38:08 +0000 (08:38 +0000)
kernel/src/CMakeLists.txt
kernel/src/bbtkKW.cxx
kernel/src/bbtkKWBlackBox.cxx
kernel/src/bbtkKWBlackBox.h
kernel/src/vtkKWBlackBoxDialog.cxx [new file with mode: 0644]
kernel/src/vtkKWBlackBoxDialog.h [new file with mode: 0644]
packages/kw/src/CMakeLists.txt
packages/kw/src/bbkwSlicer.cxx
packages/kw/src/vtkKWSlicer.cxx
packages/kw/src/vtkKWSlicer.h

index 03e8354e48b6fb26b5bcd301cc5ebab8e875c58a..f01315324b47f07de6a030be075fd632d07b7d60 100644 (file)
@@ -184,6 +184,13 @@ ADD_DEF(BBTK_EXPORT_SYMBOLS)
 FILE(GLOB SOURCES "." "*.cxx" "*.cpp") 
 # "ThirdParty/wx/treemultictrl/*.cpp")
 FILE(GLOB SOURCES_H "." "*.h" )
+
+IF(BBTK_USE_KWWIDGETS)
+include("${KWWidgets_CMAKE_DIR}/KWWidgetsWrappingMacros.cmake")
+kwwidgets_wrap_tcl(bbtk LIB_TCL_SRCS "vtkKWBlackBoxDialog.cxx" "")
+SET(SOURCES ${SOURCES} ${LIB_TCL_SRCS})
+ENDIF(BBTK_USE_KWWIDGETS)
+
 #-----------------------------------------------------------------------------
 # lib definition
 ADD_LIBRARY(bbtk SHARED ${SOURCES} ${SOURCES_H})
@@ -203,6 +210,7 @@ ENDIF(UNIX)
 #ENDIF(UNIX)
 #-----------------------------------------------------------------------------
 
+
 #-----------------------------------------------------------------------------
 # EO bbtk library creation
 #-----------------------------------------------------------------------------
index f4eb6fcd5d31276d505753d9d92bb2fe3446fb7b..cf88699327d7fbb24cf8db5714a7cf660b1551b9 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkKW.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/11/29 21:41:32 $
-  Version:   $Revision: 1.1 $
+  Date:      $Date: 2008/12/02 08:38:08 $
+  Version:   $Revision: 1.2 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
@@ -39,6 +39,9 @@
 #include "vtkMultiThreader.h"
 
 #include <ctime>
+
+extern "C" int Bbtk_Init(Tcl_Interp *interp);
+
 namespace bbtk
 {
 
@@ -113,6 +116,9 @@ namespace bbtk
        mgKWApp = vtkKWApplication::New();
        mgKWApp->SetName("bbtk");
 
+       Bbtk_Init(interp);
+
+
        /*
        if (mgMultiThreader == 0)
          {
@@ -126,7 +132,7 @@ namespace bbtk
        */
 
        // Dies as soon as it starts because no window at this point !!!
-       mgKWApp->Start();
+       //      mgKWApp->Start();
 
        /*
        clock_t endwait;
index f1de79ed6ed67b9afb44fc9e9d49bc009e511cb8..d6615986de028d9d0b5f7894785f88b3e9f1c277 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkKWBlackBox.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/11/29 21:41:33 $
-  Version:   $Revision: 1.1 $
+  Date:      $Date: 2008/12/02 08:38:08 $
+  Version:   $Revision: 1.2 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
 
  
 #include "bbtkKWBlackBox.h"
-#include "vtkObjectFactory.h"
+#include "vtkKWBlackBoxDialog.h"
 
 
 namespace bbtk
 {
 
 
-  //=========================================================================
-  // vtkKWBlackBoxWindow
-  //=========================================================================
-
-
-
-  //=========================================================================
-  vtkKWBlackBoxWindow::vtkKWBlackBoxWindow()
-    : mShown(false)
-  {
-    bbtkDebugMessage("kw",9,"vtkKWBlackBoxWindow::vtkKWBlackBoxWindow()"
-                    <<std::endl);
-    KW::IncNbWindowsAlive();
-  }
-  //=========================================================================
-
-
-
-  //=========================================================================
-  vtkKWBlackBoxWindow::~vtkKWBlackBoxWindow()
-  {
-    bbtkDebugMessage("kw",9,"vtkKWBlackBoxWindow::~vtkKWBlackBoxWindow() "
-                    <<this<<std::endl);
-    bbHide();
-    KW::DecNbWindowsAlive();
-    if (!mBox.expired())
-      {
-       mBox.lock()->bbSetWindow(0);
-      }
-  }
-  //========================================================================= 
-
-
-  //=========================================================================
-  void vtkKWBlackBoxWindow::bbShow()
-  {
-    if (bbIsShown()) return;
-    bbtkDebugMessage("kw",9,"vtkKWBlackBoxWindow::bbShow()"<<std::endl);
-    KW::IncNbWindowsShown();
-    mShown = true;
-  }
-  //=========================================================================
-
-  //=========================================================================
-  void vtkKWBlackBoxWindow::bbHide()
-  {
-    if (!bbIsShown()) return;
-    bbtkDebugMessage("kw",9,"vtkKWBlackBoxWindow::bbHide()"<<std::endl);
-    KW::DecNbWindowsShown();
-    mShown = false;
-  }
-  //=========================================================================
-
-  //=========================================================================
-  void vtkKWBlackBoxWindow::bbClose()
-  {
-  }
-  //=========================================================================
-
-
-  //=========================================================================
-  // vtkKWBlackBoxDialog
-  //=========================================================================
-  
-  //-------------------------------------------------------------------------
-  vtkStandardNewMacro( vtkKWBlackBoxDialog );
-  vtkCxxRevisionMacro(vtkKWBlackBoxDialog, "$Revision: 1.1 $");
-  //-------------------------------------------------------------------------
-
-  //=========================================================================
-  vtkKWBlackBoxDialog::vtkKWBlackBoxDialog()
-  {
-    bbtkDebugMessage("kw",9,"vtkKWBlackBoxDialog::vtkKWBlackBoxDialog()"
-                    <<std::endl);
-  }
-  //=========================================================================
-  
-  //=========================================================================
-  void vtkKWBlackBoxDialog::bbShow()
-  { 
-    if (bbIsShown()) return;
-    bbtkDebugMessage("kw",5,"vtkKWBlackBoxDialog::bbShow() ["
-                    <<bbGetBlackBox()->bbGetFullName()<<"]"<<std::endl);
-    vtkKWBlackBoxWindow::bbShow();
-    //SetReturnCode( kwDialog::ShowModal() ); 
-    this->Display();
-    bbClose();
-  }
-  //=========================================================================
-
-  //=========================================================================
-  void vtkKWBlackBoxDialog::bbHide()
-  {
-    bbtkDebugMessage("kw",9,"vtkKWBlackBoxDialog::bbHide()"<<std::endl);
-    vtkKWBlackBoxWindow::bbHide();
-    //    Hide();
-    this->Withdraw();
-  }
-  //=========================================================================
-
-  //=========================================================================
-  void vtkKWBlackBoxDialog::bbClose()
-  {
-    bbtkDebugMessage("kw",9,"vtkKWBlackBoxDialog::bbClose()"<<std::endl);
-    this->Done = vtkKWDialog::StatusCanceled;
-    //   this->Delete();
-  }
-  //=========================================================================
-
-  //=========================================================================
-  void vtkKWBlackBoxDialog::Cancel()
-  {
-    bbtkDebugMessage("kw",9,"vtkKWBlackBoxDialog::Cancel()"<<std::endl);
-    this->Delete();
-  }
-  //=========================================================================
-  //=========================================================================
-  vtkKWBlackBoxDialog::~vtkKWBlackBoxDialog()
-  {
-  }
-  //=========================================================================
-
-
-
-
-
-  //=========================================================================
-  // vtkKWBlackBoxFrame
-  //=========================================================================
-
-  //-------------------------------------------------------------------------
-  vtkStandardNewMacro( vtkKWBlackBoxFrame );
-  vtkCxxRevisionMacro(vtkKWBlackBoxFrame, "$Revision: 1.1 $");
-  //-------------------------------------------------------------------------
-  //=========================================================================
-  vtkKWBlackBoxFrame::vtkKWBlackBoxFrame()
-  {
-    bbtkDebugMessage("kw",9,"vtkKWBlackBoxFrame::vtkKWBlackBoxFrame()"<<std::endl);
-  }
-  //=========================================================================
-  
-  //=========================================================================
-  vtkKWBlackBoxFrame::~vtkKWBlackBoxFrame()
-  {
-  }
-  //=========================================================================
-
-  //=========================================================================
-  void vtkKWBlackBoxFrame::bbShow() 
-  { 
-    if (bbIsShown()) return;
-    bbtkDebugMessage("kw",5,"vtkKWBlackBoxFrame::bbShow("
-                    <<bbGetBlackBox()->bbGetFullName()<<")"<<std::endl);
-    vtkKWBlackBoxWindow::bbShow();
-    // vtkKWFrame::Show();
-    this->Display();
-    // This Update is ** MANDATORY ** 
-    // to synchronize kwvtkRenderWindowInteractor objects
-    // (force kw objects creation **NOW**)
-    /*
-
-#if defined(_WIN32)
-      kwFrame::Refresh();
-#endif
-
-      kwFrame::Update();
-      kwFrame::SetFocus();
-    */
-    if (bbGetBlackBox()) bbGetBlackBox()->bbUserOnShow();
-  }
-  //=========================================================================
-
-  //=========================================================================
-  void vtkKWBlackBoxFrame::bbHide()
-  {
-    bbtkDebugMessage("kw",9,"vtkKWBlackBoxFrame::bbHide()"<<std::endl);
-    vtkKWBlackBoxWindow::bbHide();
-    //  vtkKWFrame::Hide();
-    this->Withdraw();
-    if (bbGetBlackBox()) bbGetBlackBox()->bbUserOnHide();
-  }
-  //=========================================================================
-
-  //=========================================================================
-  void vtkKWBlackBoxFrame::bbClose()
-  {
-    bbtkDebugMessage("kw",9,"vtkKWBlackBoxFrame::bbClose()"<<std::endl);
-    //    vtkKWFrame::Close();
-    this->Delete();
-  }
-  //=========================================================================
-
 
   /*
   //=========================================================================
@@ -544,10 +352,10 @@ namespace bbtk
                //              win->SetHeight( bbGetInputWinHeight() );
                KW::GetApplication()->AddWindow((vtkKWWindowBase*)win);
                win->Create();
-               std::cout << "TclName='"<<win->GetTclName()<<"'"<<std::endl;
+               //              std::cout << "TclName='"<<win->GetTclName()<<"'"<<std::endl;
                
                bbUserCreateWidget(win);
-               KW::GetApplication()->Script("pack %s -side left -anchor c -expand y",
+               KW::GetApplication()->Script("pack %s -side top -expand yes",
                                             bbGetOutputWidget()->GetWidgetName());
                /*
                bbGetOutputWidget()->SetParent(win);
@@ -587,7 +395,9 @@ namespace bbtk
        // Show the window
 
        show->bbShow(); 
-       KW::GetApplication()->Start();
+       //      std::cout << "KW::GetApplication()->Start();"<<std::endl;
+       //      KW::GetApplication()->Start();
+       //      std::cout << "AFTER KW::GetApplication()->Start();"<<std::endl;
        
       }                  
     //   
index dec705f1c0f887c832d1ff2f9e3739a792e410da..78aa8af99c7121ecc69c53e65102ae0c0c8c9bec 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkKWBlackBox.h,v $
   Language:  C++
-  Date:      $Date: 2008/11/29 21:41:34 $
-  Version:   $Revision: 1.1 $
+  Date:      $Date: 2008/12/02 08:38:08 $
+  Version:   $Revision: 1.2 $
 ========================================================================*/
 
 
 
 
 #include "bbtkKW.h"
-#include "vtkKWWidget.h"
-#include "vtkKWWindowBase.h"
-#include "vtkKWFrame.h"
-#include "vtkKWDialog.h"
-
-namespace bbtk
-{
-
-
 
 
   //==================================================================
   // Forward declaration of the class of window associated to a KWBlackBox
   class vtkKWBlackBoxWindow;
+  class vtkKWBlackBoxDialog;
   //==================================================================
 
+
+namespace bbtk
+{
+
+
+
+
   //==================================================================
   // Forward declaration of the widget event handler class
   //  class KWBlackBoxWidgetEventHandler;
@@ -92,7 +91,7 @@ namespace bbtk
     virtual void bbExecute(bool force = false);
 
 
-    typedef vtkKWBlackBoxWindow Window;
+    typedef vtkKWBlackBoxDialog Window;
     
     /// Returns the **OWN** window associated to the box
     /// If 0 returned = no window
@@ -129,6 +128,8 @@ namespace bbtk
 
     // LG 24/11/08 : New widget pipeline
     //    void bbCreateWidgetAndEventHandler(vtkKWWidget* parent); 
+  /// Sets the window
+    inline void bbSetWindow(Window* w) { bbmWindow=w; }
 
          
   protected:
@@ -188,9 +189,7 @@ namespace bbtk
     friend class vtkKWBlackBoxWindow;
     //    friend class KWBlackBoxWidgetEventHandler;
 
-    /// Sets the window
-    inline void bbSetWindow(Window* w) { bbmWindow=w; }
-
+  
     /*
     /// Sets the Widget Event Handler
     inline void bbSetWidgetEventHandler(KWBlackBoxWidgetEventHandler* w) 
@@ -285,74 +284,6 @@ namespace bbtk
 
 
 
-
-  //==================================================================
-  // The base of the hierarchy of windows associated to a KWBlackBox
-  class BBTK_EXPORT vtkKWBlackBoxWindow 
-  {
-  public:
-    vtkKWBlackBoxWindow();
-    virtual ~vtkKWBlackBoxWindow();
-    virtual void bbShow();
-    virtual void bbHide();
-    virtual void bbClose();
-    bool bbIsShown() { return mShown; }
-    void bbSetBlackBox(KWBlackBox::Pointer box) 
-    { 
-      mBox = box; 
-      mBox.lock()->bbSetWindow(this);
-    }
-    virtual KWBlackBox::Pointer bbGetBlackBox() { return mBox.lock(); }
-  private:
-    KWBlackBox::WeakPointer mBox;
-    bool mShown;
-  };
-  //==================================================================
-
-
-  //==================================================================
-  // Dialog window which is modal
-  // Name of window must not begin with uppercase letter 
-  class BBTK_EXPORT  vtkKWBlackBoxDialog : public vtkKWDialog, 
-                                       public vtkKWBlackBoxWindow
-  {
-  public:
-    static vtkKWBlackBoxDialog* New();
-    vtkTypeRevisionMacro(vtkKWBlackBoxDialog,vtkKWDialog);
-    void bbShow();  
-    void bbHide();
-    void bbClose();
-    void Cancel();
-  protected:
-    vtkKWBlackBoxDialog();
-    ~vtkKWBlackBoxDialog();
-  private:
-    vtkKWBlackBoxDialog(const vtkKWBlackBoxDialog&);   // Not implemented.
-    void operator=(const vtkKWBlackBoxDialog&);  // Not implemented.
-  };
-  //==================================================================
-
-  //==================================================================
-  // Frame window which is not modal
-  class BBTK_EXPORT  vtkKWBlackBoxFrame : public vtkKWWindowBase,
-                                      public vtkKWBlackBoxWindow
-  {
-  public:
-    static vtkKWBlackBoxFrame* New();
-    vtkTypeRevisionMacro(vtkKWBlackBoxFrame,vtkKWWindowBase);
-    void bbShow();  
-    void bbHide();
-    void bbClose();
-  protected:
-    vtkKWBlackBoxFrame();
-    ~vtkKWBlackBoxFrame();
-  private:
-    vtkKWBlackBoxFrame(const vtkKWBlackBoxFrame&);   // Not implemented.
-    void operator=(const vtkKWBlackBoxFrame&);  // Not implemented.
-  };
-  //==================================================================
-
-
   /*
   //=================================================================
   // Handles the destroy events of a widget associated to a KWBlackBox 
diff --git a/kernel/src/vtkKWBlackBoxDialog.cxx b/kernel/src/vtkKWBlackBoxDialog.cxx
new file mode 100644 (file)
index 0000000..d7ca41b
--- /dev/null
@@ -0,0 +1,214 @@
+#ifdef USE_KWWIDGETS
+
+#include "vtkKWBlackBoxDialog.h"
+#include "bbtkKW.h"
+#include "vtkObjectFactory.h"
+
+  //=========================================================================
+  // vtkKWBlackBoxWindow
+  //=========================================================================
+
+
+/*
+  //=========================================================================
+  vtkKWBlackBoxWindow::vtkKWBlackBoxWindow()
+    : mShown(false)
+  {
+    bbtkDebugMessage("kw",9,"vtkKWBlackBoxWindow::vtkKWBlackBoxWindow()"
+                    <<std::endl);
+    bbtk::KW::IncNbWindowsAlive();
+  }
+  //=========================================================================
+
+
+
+  //=========================================================================
+  vtkKWBlackBoxWindow::~vtkKWBlackBoxWindow()
+  {
+    bbtkDebugMessage("kw",9,"vtkKWBlackBoxWindow::~vtkKWBlackBoxWindow() "
+                    <<this<<std::endl);
+    bbHide();
+    bbtk::KW::DecNbWindowsAlive();
+    if (!mBox.expired())
+      {
+       mBox.lock()->bbSetWindow(0);
+      }
+  }
+  //========================================================================= 
+
+
+  //=========================================================================
+  void vtkKWBlackBoxWindow::bbShow()
+  {
+    if (bbIsShown()) return;
+    bbtkDebugMessage("kw",9,"vtkKWBlackBoxWindow::bbShow()"<<std::endl);
+    bbtk::KW::IncNbWindowsShown();
+    mShown = true;
+  }
+  //=========================================================================
+
+  //=========================================================================
+  void vtkKWBlackBoxWindow::bbHide()
+  {
+    if (!bbIsShown()) return;
+    bbtkDebugMessage("kw",9,"vtkKWBlackBoxWindow::bbHide()"<<std::endl);
+    bbtk::KW::DecNbWindowsShown();
+    mShown = false;
+  }
+  //=========================================================================
+
+  //=========================================================================
+  void vtkKWBlackBoxWindow::bbClose()
+  {
+  }
+  //=========================================================================
+
+*/
+  //=========================================================================
+  // vtkKWBlackBoxDialog
+  //=========================================================================
+  
+  //-------------------------------------------------------------------------
+  vtkStandardNewMacro( vtkKWBlackBoxDialog );
+  vtkCxxRevisionMacro( vtkKWBlackBoxDialog, "$Revision: 1.1 $");
+  //-------------------------------------------------------------------------
+
+  //=========================================================================
+  vtkKWBlackBoxDialog::vtkKWBlackBoxDialog() 
+    : mShown(false)
+  {
+    bbtkDebugMessage("kw",9,"vtkKWBlackBoxDialog::vtkKWBlackBoxDialog()"
+                    <<std::endl);
+    bbtk::KW::IncNbWindowsAlive();
+  }
+  //=========================================================================
+  
+  //=========================================================================
+  void vtkKWBlackBoxDialog::bbShow()
+  { 
+    if (bbIsShown()) return;
+    bbtkDebugMessage("kw",5,"vtkKWBlackBoxDialog::bbShow() ["
+                    <<bbGetBlackBox()->bbGetFullName()<<"]"<<std::endl);
+    bbtk::KW::IncNbWindowsShown();
+    mShown = true;
+    //    vtkKWBlackBoxWindow::bbShow();
+    //SetReturnCode( kwDialog::ShowModal() ); 
+    this->Display();
+    this->Invoke();
+    //    bbClose();
+  }
+  //=========================================================================
+
+  //=========================================================================
+  void vtkKWBlackBoxDialog::bbHide()
+  {
+    bbtkDebugMessage("kw",9,"vtkKWBlackBoxDialog::bbHide()"<<std::endl);
+    // vtkKWBlackBoxWindow::bbHide();
+    bbtk::KW::DecNbWindowsShown();
+    mShown = false;
+    //    Hide();
+    this->Withdraw(); 
+  }
+  //=========================================================================
+
+  //=========================================================================
+  void vtkKWBlackBoxDialog::bbClose()
+  {
+    bbtkDebugMessage("kw",9,"vtkKWBlackBoxDialog::bbClose()"<<std::endl);
+    this->Done = vtkKWDialog::StatusCanceled;
+    // this->Withdraw();  //   this->Delete();
+  }
+  //=========================================================================
+
+  //=========================================================================
+  void vtkKWBlackBoxDialog::Cancel()
+  {
+    bbtkDebugMessage("kw",9,"vtkKWBlackBoxDialog::Cancel()"<<std::endl);
+    //    this->Delete();
+
+    //    this->Withdraw();
+    bbHide();
+    this->Done = vtkKWDialog::StatusCanceled;
+    //    std::cout << "REFS= "<<this->GetReferenceCount()<<std::endl;
+    //    std::cout << "WINS= "<<this->GetApplication()->GetNumberOfWindows ()<<std::endl;
+    //    this->Delete();
+    
+  }
+  //=========================================================================
+  
+  //=========================================================================
+  vtkKWBlackBoxDialog::~vtkKWBlackBoxDialog()
+  {
+    bbtkDebugMessage("kw",9,"~vtkKWBlackBoxDialog()"<<std::endl);
+    bbHide();
+    bbtk::KW::DecNbWindowsAlive();
+    if (!mBox.expired())
+      {
+       mBox.lock()->bbSetWindow(0);
+      }
+  }
+  //=========================================================================
+
+
+/*
+
+
+  //=========================================================================
+  // vtkKWBlackBoxFrame
+  //=========================================================================
+
+  //-------------------------------------------------------------------------
+  vtkStandardNewMacro( vtkKWBlackBoxFrame );
+  vtkCxxRevisionMacro(vtkKWBlackBoxFrame, "$Revision: 1.1 $");
+  //-------------------------------------------------------------------------
+  //=========================================================================
+  vtkKWBlackBoxFrame::vtkKWBlackBoxFrame()
+  {
+    bbtkDebugMessage("kw",9,"vtkKWBlackBoxFrame::vtkKWBlackBoxFrame()"<<std::endl);
+  }
+  //=========================================================================
+  
+  //=========================================================================
+  vtkKWBlackBoxFrame::~vtkKWBlackBoxFrame()
+  {
+  }
+  //=========================================================================
+
+  //=========================================================================
+  void vtkKWBlackBoxFrame::bbShow() 
+  { 
+    if (bbIsShown()) return;
+    bbtkDebugMessage("kw",5,"vtkKWBlackBoxFrame::bbShow("
+                    <<bbGetBlackBox()->bbGetFullName()<<")"<<std::endl);
+    vtkKWBlackBoxWindow::bbShow();
+    // vtkKWFrame::Show();
+    this->Display();
+    // This Update is ** MANDATORY ** 
+    // to synchronize kwvtkRenderWindowInteractor objects
+    // (force kw objects creation **NOW**)
+    if (bbGetBlackBox()) bbGetBlackBox()->bbUserOnShow();
+  }
+  //=========================================================================
+
+  //=========================================================================
+  void vtkKWBlackBoxFrame::bbHide()
+  {
+    bbtkDebugMessage("kw",9,"vtkKWBlackBoxFrame::bbHide()"<<std::endl);
+    vtkKWBlackBoxWindow::bbHide();
+    //  vtkKWFrame::Hide();
+    this->Withdraw();
+    if (bbGetBlackBox()) bbGetBlackBox()->bbUserOnHide();
+  }
+  //=========================================================================
+
+  //=========================================================================
+  void vtkKWBlackBoxFrame::bbClose()
+  {
+    bbtkDebugMessage("kw",9,"vtkKWBlackBoxFrame::bbClose()"<<std::endl);
+    //    vtkKWFrame::Close();
+    this->Delete();
+  }
+  //=========================================================================
+  */
+#endif
diff --git a/kernel/src/vtkKWBlackBoxDialog.h b/kernel/src/vtkKWBlackBoxDialog.h
new file mode 100644 (file)
index 0000000..f47f89f
--- /dev/null
@@ -0,0 +1,45 @@
+#ifndef __vtkKWBlackBoxDialog_h_INCLUDED__
+#define __vtkKWBlackBoxDialog_h_INCLUDED__
+
+#ifdef USE_KWWIDGETS
+
+#include "bbtkKWBlackBox.h"
+#include "vtkKWDialog.h"
+
+typedef bbtk::KWBlackBox::Pointer BBPointer;
+typedef bbtk::KWBlackBox::WeakPointer BBWeakPointer;
+
+class BBTK_EXPORT vtkKWBlackBoxDialog : public vtkKWDialog
+                                         //public vtkKWBlackBoxWindow
+
+{
+public:
+  
+
+  static vtkKWBlackBoxDialog* New();
+
+  vtkTypeRevisionMacro(vtkKWBlackBoxDialog,vtkKWDialog);
+  void bbShow();  
+  void bbHide();
+  void bbClose();
+  void Cancel();
+  bool bbIsShown() { return mShown; }
+  void bbSetBlackBox(BBPointer box) 
+  { 
+    mBox = box; 
+    mBox.lock()->bbSetWindow(this);
+  }
+  virtual BBPointer bbGetBlackBox() { return mBox.lock(); }
+protected:
+  vtkKWBlackBoxDialog();
+  ~vtkKWBlackBoxDialog();
+private:
+  vtkKWBlackBoxDialog(const vtkKWBlackBoxDialog&);   // Not implemented.
+  void operator=(const vtkKWBlackBoxDialog&);  // Not implemented.
+  BBWeakPointer mBox;
+  bool mShown;
+};
+//==================================================================
+
+#endif
+#endif
index e2d2a1158aa171224a8d35f3eed22a0869a32910..f165f0d5b65db480c40df03cb2a8018fde894864 100644 (file)
@@ -1,5 +1,7 @@
 #---------------------------------------------------------------------------
 # Include src configuration cmake script
 INCLUDE(${BBTK_CMAKE_DIR}/BBTKConfigurePackage_src.cmake)
+#include("${KWWidgets_CMAKE_DIR}/KWWidgetsWrappingMacros.cmake")
+#kwwidgets_wrap_tcl(bbkw LIB_TCL_SRCS "vtkKWSlicer.cxx" "")
 #---------------------------------------------------------------------------
 
index d570549251ee404c9b9fc00506d24333b03068af..e122eaf478cc5348ebf055f8323839579a5d08cc 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbkwSlicer.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/11/29 21:41:58 $
-  Version:   $Revision: 1.1 $
+  Date:      $Date: 2008/12/02 08:38:10 $
+  Version:   $Revision: 1.2 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
@@ -82,15 +82,16 @@ namespace bbkw
     vtkKWSlicer* s = vtkKWSlicer::New();
     bbSetOutputWidget(s);
     s->SetParent(parent);
-    s->Create();
-    s->GetApplication()->Script("pack %s -side left -anchor c -expand y",
-                               s->GetWidgetName());
-
     if (bbGetInputIn()) 
       {
        s->SetImage(bbGetInputIn());
       }
 
+    s->Create();
+    s->GetApplication()->Script("pack %s -side top -expand y",
+                               s->GetWidgetName());
+
+  
   }
 
 } //namespace bbkw
index 0c9cd4777b7d160192ce19e4d7aff8384150b621..adc9bf9d52f675ea2d12c82dc60fab074ebaa71f 100644 (file)
@@ -7,6 +7,7 @@
 #include "vtkImageViewer2.h"
 #include "vtkKWApplication.h"
 #include "vtkKWFrame.h"
+#include "vtkKWSplitFrame.h"
 #include "vtkKWFrameWithLabel.h"
 #include "vtkKWMenu.h"
 #include "vtkKWMenuButton.h"
 #include "vtkRenderWindowInteractor.h"
 #include "vtkXMLImageDataReader.h"
 
-//#include "vtkKWWidgetsPaths.h"
+//#include "vtkKWWidgetsPaths.h" 
 #include "vtkToolkits.h"
 
 #include <vtksys/SystemTools.hxx>
 
-namespace bbkw
-{
+//namespace bbkw {
 
 //----------------------------------------------------------------------------
 vtkStandardNewMacro( vtkKWSlicer );
-vtkCxxRevisionMacro(vtkKWSlicer, "$Revision: 1.1 $");
+vtkCxxRevisionMacro(vtkKWSlicer, "$Revision: 1.2 $");
 
 //----------------------------------------------------------------------------
 vtkKWSlicer::vtkKWSlicer()
 {
+  this->Frame = NULL;
   this->RenderWidget = NULL;
+  this->Image = NULL;
   this->ImageViewer = NULL;
   this->SliceScale = NULL;
   this->WindowLevelPresetSelector = NULL;
@@ -48,6 +50,10 @@ vtkKWSlicer::vtkKWSlicer()
 //----------------------------------------------------------------------------
 vtkKWSlicer::~vtkKWSlicer()
 {
+ if (this->Frame)
+    {
+    this->Frame->Delete();
+    }
   if (this->SliceScale)
     {
     this->SliceScale->Delete();
@@ -87,18 +93,32 @@ void vtkKWSlicer::CreateWidget()
 
   vtkKWApplication *app = this->GetApplication();
 
+  // Add a SplitFrame
+  Frame =  vtkKWSplitFrame::New();
+  Frame->SetFrame1MinimumSize(150);
+  Frame->SetFrame2MinimumSize(250);    
+  Frame->SetOrientationToVertical ();
+  Frame->SetExpandableFrameToFrame2();
+  Frame->SetParent(this);
+  Frame->Create();
+  app->Script("pack %s -side top -expand yes",// -fill both",
+             this->Frame->GetWidgetName());
   // Add a render widget, attach it to the view frame, and pack
 
   if (!this->RenderWidget)
     {
     this->RenderWidget = vtkKWRenderWidget::New();
     }
-  this->RenderWidget->SetParent(this); //->GetViewFrame());
+  this->RenderWidget->SetParent(Frame->GetFrame2());
   this->RenderWidget->Create();
   this->RenderWidget->CornerAnnotationVisibilityOn();
 
-  app->Script("pack %s -expand y -fill both -anchor c -expand y", 
-              this->RenderWidget->GetWidgetName());
+  //  app->Script("grid %s -row 0 -column 0 -columnspan 2  -sticky nsew -padx 8 -pady 8",
+  app->Script("pack %s -side top -expand y -fill both -padx 2 -pady 2",
+             //  app->Script("pack %s -expand y -fill both -anchor c -expand y", 
+             this->RenderWidget->GetWidgetName());
+  //  this->Script("grid rowconfigure %s 1 -weight 1 -minsize 100",
+  //               this->RenderWidget->GetWidgetName());
 
   // Create a volume reader
   /*
@@ -127,6 +147,7 @@ void vtkKWSlicer::CreateWidget()
   this->ImageViewer->SetupInteractor(
     this->RenderWidget->GetRenderWindow()->GetInteractor());
 
+
   // Reset the window/level and the camera
   /*
   reader->Update();
@@ -154,19 +175,24 @@ void vtkKWSlicer::CreateWidget()
     {
     this->SliceScale = vtkKWScale::New();
     }
-  this->SliceScale->SetParent(this); //->GetViewPanelFrame());
+  this->SliceScale->SetParent(Frame->GetFrame1());
   this->SliceScale->Create();
-  this->SliceScale->SetCommand(this, "SetSliceFromScaleCallback");
+  //  this->SliceScale->SetCommand(this, "SetSliceFromScaleCallback");
 
-  app->Script("pack %s -side top -expand n -fill x -padx 2 -pady 2",
+  app->Script("pack %s -side top -expand n -fill x",
               this->SliceScale->GetWidgetName());
+  //app->Script("grid %s -row 1 -column 1 -sticky nsew -padx 8",
+             //app->Script("pack %s -side right -expand n -fill x -padx 2 -pady 2",
+  //         this->SliceScale->GetWidgetName());
+  //  this->Script("grid rowconfigure %s 0 -weight 1",
+  //               this->SliceScale->GetWidgetName());
 
   // Create a menu button to control the orientation
 
   vtkKWMenuButtonWithSpinButtonsWithLabel *orientation_menubutton =
     vtkKWMenuButtonWithSpinButtonsWithLabel::New();
 
-  orientation_menubutton->SetParent(this); //->GetMainPanelFrame());
+  orientation_menubutton->SetParent(Frame->GetFrame1());
   orientation_menubutton->Create();
   orientation_menubutton->SetLabelText("Orientation:");
   orientation_menubutton->SetPadX(2);
@@ -174,20 +200,28 @@ void vtkKWSlicer::CreateWidget()
   orientation_menubutton->SetBorderWidth(2);
   orientation_menubutton->SetReliefToGroove();
 
-  app->Script("pack %s -side top -anchor nw -expand n -fill x",
+  app->Script("pack %s -side top -expand n -fill x",
               orientation_menubutton->GetWidgetName());
 
+  //  this->Script("grid %s -row 1 -column 0",
+             //app->Script("pack %s -side left -anchor nw -expand n -fill x",
+  //              orientation_menubutton->GetWidgetName());
+  //  this->Script("grid rowconfigure %s 1 -weight 1",
+  //             orientation_menubutton->GetWidgetName());
+
   vtkKWMenuButton *mb = orientation_menubutton->GetWidget()->GetWidget();
-  vtkKWMenu *menu = mb->GetMenu();
+  vtkKWMenu *menu = OrientationMenu = mb->GetMenu();
 
-  menu->AddRadioButton("X-Y", this, "SetSliceOrientationToXYCallback");
-  menu->AddRadioButton("X-Z", this, "SetSliceOrientationToXZCallback");
-  menu->AddRadioButton("Y-Z", this, "SetSliceOrientationToYZCallback");
+  menu->AddRadioButton("X-Y"); //, this, "SetSliceOrientationToXYCallback");
+  menu->AddRadioButton("X-Z"); //, this, "SetSliceOrientationToXZCallback");
+  menu->AddRadioButton("Y-Z"); //, this, "SetSliceOrientationToYZCallback");
 
   mb->SetValue("X-Y");
 
-  // Create a window/level preset selector
 
+  
+  // Create a window/level preset selector
+  /*
   vtkKWFrameWithLabel *wl_frame = vtkKWFrameWithLabel::New();
   wl_frame->SetParent(this); //->GetMainPanelFrame());
   wl_frame->Create();
@@ -203,6 +237,7 @@ void vtkKWSlicer::CreateWidget()
   this->WindowLevelPresetSelector->SetParent(wl_frame->GetFrame());
   this->WindowLevelPresetSelector->Create();
   this->WindowLevelPresetSelector->ThumbnailColumnVisibilityOn();
+  
   this->WindowLevelPresetSelector->SetPresetAddCommand(
     this, "WindowLevelPresetAddCallback");
   this->WindowLevelPresetSelector->SetPresetApplyCommand(
@@ -212,6 +247,7 @@ void vtkKWSlicer::CreateWidget()
   this->WindowLevelPresetSelector->SetPresetHasChangedCommand(
     this, "WindowLevelPresetHasChangedCallback");
 
+
   app->Script("pack %s -side top -anchor nw -expand n -fill x",
               this->WindowLevelPresetSelector->GetWidgetName());
 
@@ -233,35 +269,88 @@ void vtkKWSlicer::CreateWidget()
   this->AnimationWidget->Create();
   this->AnimationWidget->SetRenderWidget(this->RenderWidget);
   this->AnimationWidget->SetAnimationTypeToSlice();
-  this->AnimationWidget->SetSliceSetCommand(this, "SetSliceCallback");
-  this->AnimationWidget->SetSliceGetCommand(this, "GetSliceCallback");
+  //  this->AnimationWidget->SetSliceSetCommand(this, "SetSliceCallback");
+  //  this->AnimationWidget->SetSliceGetCommand(this, "GetSliceCallback");
 
   app->Script("pack %s -side top -anchor nw -expand n -fill x",
               this->AnimationWidget->GetWidgetName());
-
+  */
   this->UpdateSliceRanges();
 
+  // Callbacks
+  this->AddCallbackCommandObserver( this->SliceScale, 
+                                   vtkKWScale::ScaleValueChangingEvent);
+  this->AddCallbackCommandObserver( menu, 
+                                   vtkKWMenu::MenuItemInvokedEvent);
+
+
   // Deallocate local objects
 
   //  reader->Delete();
   orientation_menubutton->Delete();
-  wl_frame->Delete();
-  animation_frame->Delete();
+  //  wl_frame->Delete();
+  //  animation_frame->Delete();
+  UpdateImage();
 }
 
 
 //----------------------------------------------------------------------------
+void vtkKWSlicer::ProcessCallbackCommandEvents(
+  vtkObject *caller, unsigned long event, void *calldata)
+{
+  std::cout << "###### vtkKWSlicer::ProcessCallbackCommandEvents" << std::endl;
+  if (caller == this->SliceScale && 
+      event == vtkKWScale::ScaleValueChangingEvent)
+    {
+      this->SetSliceFromScaleCallback(*((double*)calldata));
+    }
+  if (caller == this->OrientationMenu && 
+      event == vtkKWMenu::MenuItemInvokedEvent)
+    {
+      int i = *((int*)calldata);
+      //      std::cout << i << std::endl;
+      if (i==0) this->SetSliceOrientationToXYCallback();
+      else if (i==1) this->SetSliceOrientationToXZCallback();
+      else if (i==2) this->SetSliceOrientationToYZCallback();
+         
+
+      //      this->SetSliceFromScaleCallback(*((double*)calldata));
+    }
+
+  /*
+  // We received a notification from the application that its value was
+  // changed. Let's propagate that value to our scale widget
+
+  if (caller == myapp && event == vtkCommand::ModifiedEvent)
+    {
+    this->Scale->SetValue(myapp->GetMyValue());
+    }
+  */
+  this->Superclass::ProcessCallbackCommandEvents(caller, event, calldata);
+}
+ //----------------------------------------------------------------------------
+
+ //----------------------------------------------------------------------------
 void vtkKWSlicer::SetImage(vtkImageData* image)
 {
-  vtkImageData* i = vtkImageData::New();
-  i->ShallowCopy(image);
-  this->ImageViewer->SetInput(i);
-  double *range = i->GetScalarRange();
+  Image = vtkImageData::New();
+  Image->ShallowCopy(image);
+  UpdateImage();
+}
+//----------------------------------------------------------------------------
+
+//----------------------------------------------------------------------------
+void vtkKWSlicer::UpdateImage()
+{
+  if (!Image) return;
+  if (!this->IsCreated()) return;
+  this->ImageViewer->SetInput(Image);
+  double *range = Image->GetScalarRange();
   this->ImageViewer->SetColorWindow(range[1] - range[0]);
   this->ImageViewer->SetColorLevel(0.5 * (range[1] + range[0]));
   this->RenderWidget->ResetCamera(); 
-  i->Delete();
   this->UpdateSliceRanges();
+  Image->Delete();
 }
 //----------------------------------------------------------------------------
 
@@ -269,6 +358,7 @@ void vtkKWSlicer::SetImage(vtkImageData* image)
 void vtkKWSlicer::SetSliceFromScaleCallback(double value)
 {
   this->ImageViewer->SetSlice((int)value);
+  this->ImageViewer->Render();
 }
 
 //----------------------------------------------------------------------------
@@ -302,8 +392,10 @@ void vtkKWSlicer::UpdateSliceRanges()
     this->ImageViewer->GetSliceMin(), this->ImageViewer->GetSliceMax());
   this->SliceScale->SetValue(this->ImageViewer->GetSlice());
 
+  /*
   this->AnimationWidget->SetSliceRange(
     this->ImageViewer->GetSliceMin(), this->ImageViewer->GetSliceMax());
+  */
 }
 
 //----------------------------------------------------------------------------
@@ -367,5 +459,5 @@ void vtkKWSlicer::WindowLevelPresetHasChangedCallback(int id)
 }
 
 
-} // namespace kw
+//} // namespace kw
 #endif // USE_KWWIDGETS
index 431eb6d2e9107ef4acb3e53ca7ffabe123c12b85..74a0368268ca046f66a82198cdb5525fd88e92d2 100644 (file)
@@ -4,7 +4,7 @@
 #define __vtkKWSlicer_h
 
 
-#include "vtkKWFrame.h"
+#include "vtkKWCompositeWidget.h"
 
 class vtkImageData;
 class vtkKWRenderWidget;
@@ -12,17 +12,19 @@ class vtkImageViewer2;
 class vtkKWScale;
 class vtkKWWindowLevelPresetSelector;
 class vtkKWSimpleAnimationWidget;
+class vtkKWMenu;
+class vtkKWSplitFrame;
 
-namespace bbkw
-{
+//namespace bbkw {
 
-class vtkKWSlicer : public vtkKWFrame
+class vtkKWSlicer : public vtkKWCompositeWidget
 {
 public:
   static vtkKWSlicer* New();
-  vtkTypeRevisionMacro(vtkKWSlicer,vtkKWFrame);
+  vtkTypeRevisionMacro(vtkKWSlicer,vtkKWCompositeWidget);
 
   void SetImage(vtkImageData*);
+  void UpdateImage();
 
   // Description:
   // Callbacks
@@ -39,6 +41,9 @@ public:
   virtual void WindowLevelPresetUpdateCallback(int id);
   virtual void WindowLevelPresetHasChangedCallback(int id);
 
+  void ProcessCallbackCommandEvents(vtkObject *caller, 
+                                   unsigned long event, 
+                                   void *calldata);
 protected:
   vtkKWSlicer();
   ~vtkKWSlicer();
@@ -46,13 +51,14 @@ protected:
   // Description:
   // Create the widget.
   virtual void CreateWidget();
-
+  vtkKWSplitFrame                     *Frame;
+  vtkImageData                   *Image;
   vtkImageViewer2                *ImageViewer; 
   vtkKWScale                     *SliceScale;
   vtkKWWindowLevelPresetSelector *WindowLevelPresetSelector;
   vtkKWRenderWidget              *RenderWidget;
   vtkKWSimpleAnimationWidget     *AnimationWidget;
-
+  vtkKWMenu                      *OrientationMenu;
   virtual void UpdateSliceRanges();
 
 private:
@@ -60,6 +66,6 @@ private:
   void operator=(const vtkKWSlicer&);  // Not implemented.
 };
 
-}
+//}
 #endif
 #endif