]> Creatis software - creaImageIO.git/commitdiff
*** empty log message ***
authordonadio <donadio>
Tue, 28 Apr 2009 14:42:44 +0000 (14:42 +0000)
committerdonadio <donadio>
Tue, 28 Apr 2009 14:42:44 +0000 (14:42 +0000)
src2/CMakeLists.txt
src2/creaImageIOWxGimmickPanel.cpp [new file with mode: 0644]
src2/creaImageIOWxGimmickPanel.h [new file with mode: 0644]

index 18228ce069b3ac854ce9d51ff57be6d69c9c2ea7..54b2ba80bc08763f843f722fe8c46835fa6e3e29 100644 (file)
@@ -45,6 +45,7 @@ SET( SRCS
   creaImageIOWxTreeView
   creaImageIOWxGimmickReaderDialog
   creaImageIOWxGimmickFrame
+  creaImageIOWxGimmickPanel
 
   # 
   BlockScopeWxApp
diff --git a/src2/creaImageIOWxGimmickPanel.cpp b/src2/creaImageIOWxGimmickPanel.cpp
new file mode 100644 (file)
index 0000000..13ca31b
--- /dev/null
@@ -0,0 +1,104 @@
+#include <creaImageIOWxGimmickPanel.h>
+#include <creaImageIOSystem.h>
+
+namespace creaImageIO
+{
+  // CTor
+  WxGimmickPanel::WxGimmickPanel(wxWindow *parent, 
+                                              wxWindowID id,
+                                              const wxPoint& pos,
+                                              const wxSize& size,
+                                              int threads)
+ :   wxPanel( parent, 
+                 id, 
+                 pos,
+                 size,
+                 wxRESIZE_BORDER | 
+             wxSYSTEM_MENU  |
+                 wxCLOSE_BOX |
+                 wxMAXIMIZE_BOX | 
+                 wxMINIMIZE_BOX | 
+                 wxCAPTION  
+              ),
+     mGimmick(0),
+     mView(0)
+  {
+    GimmickDebugMessage(1,"WxGimmickPanel::WxGimmickPanel"
+                       <<std::endl);
+    wxBoxSizer *topsizer = new wxBoxSizer(wxVERTICAL);
+    
+    try {
+      
+      mGimmick = new Gimmick();
+      mGimmick->Initialize();
+     
+      int min_dim = GIMMICK_2D_IMAGE_SELECTION;
+         int max_dim = GIMMICK_3D_IMAGE_SELECTION;
+      mView = new WxGimmickView(mGimmick,
+                               this,
+                               -1,
+                               wxDefaultPosition,
+                               size,
+                               min_dim,
+                               max_dim,
+                               threads);
+      mView->Initialize();
+         // Connect the AddProgress callback
+      mView->ConnectValidationObserver ( boost::bind( &WxGimmickPanel::OnSelectedImage , this, _1 ) );
+    }
+    catch (crea::Exception e)
+    {
+      e.Print();
+      return;
+    }
+
+    topsizer->Add( mView,1,wxGROW,0);
+
+    SetSizer( topsizer );     
+    Layout(); 
+  }
+
+  /// Destructor
+  WxGimmickPanel::~WxGimmickPanel()
+  {
+    GimmickDebugMessage(1,"WxGimmickPanel::~WxGimmickPanel"
+                       <<std::endl);
+    if (mView) 
+      {
+       delete mView;
+      }
+    if (mGimmick) 
+      {
+       mGimmick->Finalize();
+       delete mGimmick;
+      }
+  }
+  
+//======================================================================
+  
+//====================================================================== 
+  
+  ///Callback method on a selection
+  void WxGimmickPanel::OnSelectedImage(bool t)
+  {
+               //GetSelectedImages(std::vector<vtkImageData*>& s, int dim);
+               mSendImageSignal(t);
+  }
+
+  //================================================================
+  //  BEGIN_EVENT_TABLE(WxGimmickPanel, wxDialog)
+  //    END_EVENT_TABLE()
+  //================================================================
+
+
+  //====================================================================
+
+  //====================================================================
+  void WxGimmickPanel::ConnectSendImageObserver(SendImageCallbackType callback)
+  {
+    mSendImageSignal.connect(callback);
+  }
+
+} // EO namespace creaImageIO
+
+
diff --git a/src2/creaImageIOWxGimmickPanel.h b/src2/creaImageIOWxGimmickPanel.h
new file mode 100644 (file)
index 0000000..dd873f6
--- /dev/null
@@ -0,0 +1,75 @@
+#ifndef __creaImageIOWxGimmickPanel_h_INCLUDED__
+#define __creaImageIOWxGimmickPanel_h_INCLUDED__
+
+#ifdef USE_WXWIDGETS
+
+// Signal/slot mechanism for progress events
+#include <boost/signal.hpp>
+#include <boost/bind.hpp>
+
+#include <creaImageIOWxGimmickView.h>
+#include <creaWx.h>
+
+namespace creaImageIO
+{
+  /**
+   * \ingroup GUI
+   */
+  //=====================================================================
+ //=====================================================================
+  class CREAIMAGEIO_EXPORT WxGimmickPanel : public wxPanel
+  {
+  public:
+    WxGimmickPanel();    
+    WxGimmickPanel(wxWindow *parent, 
+                  const wxWindowID id,
+                  const wxPoint& pos, 
+                  const wxSize& size,
+                  int threads = 0);
+    
+    ~WxGimmickPanel();
+
+      //=============================================
+      typedef boost::signal<void (bool)> SendImageSignalType;
+      typedef SendImageSignalType::slot_function_type SendImageCallbackType;
+      //=============================================
+
+     //==================================================================
+      /// Adds the function f to the list of functions to call 
+      /// when the addition progresses.
+      /// f is of type ProgressCallbackType which is:
+      /// void (*ProgressCallbackType)(Progress&)
+      /// To pass a member function 'f' of an instance 'c' of a class 'C' 
+      /// as callback you have to 'bind' it, i.e. call:
+      /// ConnectSendImageObserver ( boost::bind( &C::f , c, _1 ) );
+      void ConnectSendImageObserver(SendImageCallbackType callback);
+     //==================================================================
+
+       //===============================================================================================
+       //Image Selection
+       //===============================================================================================
+
+       void GetSelectedImages(std::vector<vtkImageData*>& s, int dim)
+    { mView->GetSelectedImages(s, dim); }
+
+    void OnSelectedImage(bool t);
+
+    //    DECLARE_EVENT_TABLE();
+  private :
+    
+    Gimmick*       mGimmick;
+    WxGimmickView* mView;
+
+       ///The sendImage signal
+       SendImageSignalType mSendImageSignal;
+
+  }; // class WxGimmickPanel
+  //=====================================================================
+
+  
+} // EO namespace creaImageIO
+
+
+#endif // USE_WIDGETS
+// EOF
+#endif