]> Creatis software - creaImageIO.git/commitdiff
Added boost signal to validate
authorcaballero <caballero>
Mon, 9 Mar 2009 12:36:02 +0000 (12:36 +0000)
committercaballero <caballero>
Mon, 9 Mar 2009 12:36:02 +0000 (12:36 +0000)
src2/creaImageIOGimmick.h
src2/creaImageIOGimmickView.cpp
src2/creaImageIOGimmickView.h
src2/creaImageIOWxGimmickReaderDialog.cpp
src2/creaImageIOWxGimmickReaderDialog.h

index b61874b0831c4e39044f82d892bd1b36157e4fe5..cdb76764fcb99f143b7ccac4c6d4c827f691151e 100644 (file)
@@ -24,6 +24,9 @@ namespace creaImageIO
        /**
        * \defgroup Tree Attributed tree management
        */
+       /**
+       * \defgroup Previewer Preview related
+       */
 
        /**
        * \ingroup Controller
index a16c09675fc323a6e41a9807e1339792bfb4c982..a587a8d2b825e1fc45c0bea1abbf95114657be42 100644 (file)
@@ -1,6 +1,10 @@
 #include <creaImageIOGimmickView.h>
 #include <creaImageIOSystem.h>
 
+#include "boost/filesystem.hpp"
+
+namespace fs = boost::filesystem;
+
 namespace creaImageIO
 {
   //======================================================================
@@ -181,6 +185,7 @@ namespace creaImageIO
        {
                mMessage="Selection OK !";
        }
+       mValidationSignal(valid);
        SetMessage(mMessage);
        return valid;
   }
@@ -294,6 +299,14 @@ namespace creaImageIO
        mImageEventQueue.push_back(ImageEventType(i->second,image));
       }
   }
+
+  //====================================================================
+
+  //====================================================================
+  void GimmickView::ConnectValidationObserver(ValidationCallbackType callback)
+  {
+    mValidationSignal.connect(callback);
+  }
          
   
 } // EO namespace creaImageIO
index 011e47141e6bd533cd51c906baee552f8cebfb53..f2baa23406faefbdd82a54255669c1c9b12f0c7a 100644 (file)
@@ -9,6 +9,10 @@
 #include <vtkImageData.h>
 #include <creaImageIOMultiThreadImageReader.h>
 
+// Signal/slot mechanism for progress events
+#include <boost/signal.hpp>
+#include <boost/bind.hpp>
+
 #define GIMMICK_NO_IMAGE_SELECTION 0
 #define GIMMICK_2D_IMAGE_SELECTION 2
 #define GIMMICK_3D_IMAGE_SELECTION 3
@@ -108,6 +112,22 @@ namespace creaImageIO
                                       MultiThreadImageReaderUser::EventType t,
                                       vtkImageData* image);
 
+         //=============================================
+      typedef boost::signal<void (bool)>  ValidationSignalType;
+      typedef ValidationSignalType::slot_function_type ValidationCallbackType;
+      //=============================================
+
+     //==================================================================
+      /// 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:
+      /// ConnectValidationObserver ( boost::bind( &C::f , c, _1 ) );
+      void ConnectValidationObserver(ValidationCallbackType callback);
+     //==================================================================
+
     private:
       /// Controller which manages the interaction with the model
       Gimmick* mGimmick;
@@ -134,6 +154,8 @@ namespace creaImageIO
       // queue of image event 
       typedef std::deque<ImageEventType> ImageEventQueueType;
       ImageEventQueueType mImageEventQueue;
+
+         ValidationSignalType mValidationSignal;
       
     };
     // EO class GimmickView
index 69572a33c9a363d0e476dae50e06eda944fc0d08..6c311fbb95bea391f79f1740db0c01707305c579 100644 (file)
@@ -36,7 +36,7 @@ namespace creaImageIO
       
       mGimmick = new Gimmick();
       mGimmick->Initialize();
-     
+    
       
       mView = new WxGimmickView(mGimmick,
                                this,
@@ -47,6 +47,9 @@ namespace creaImageIO
                                max_dim,
                                threads);
       mView->Initialize();
+          // Connect the AddProgress callback
+      mView->ConnectValidationObserver
+      ( boost::bind( &WxGimmickReaderDialog::OnValid , this, _1 ) );
     }
     catch (crea::Exception e)
     {
@@ -85,20 +88,17 @@ namespace creaImageIO
   }
 
   ///Callback method on a selection
-  void WxGimmickReaderDialog::OnValid(wxCommandEvent& event)
+  void WxGimmickReaderDialog::OnValid(bool t)
   {
-    //   bool t=mView->ValidateSelection(event.GetClientData());
-    // TO DO 
-    //   mOkButton->Enable(t);
+    mOkButton->Enable(t);
   }
 
 
 
  
   //================================================================
-  BEGIN_EVENT_TABLE(WxGimmickReaderDialog, wxDialog)
-       EVT_COMMAND(wxID_ANY, 0, WxGimmickReaderDialog::OnValid) 
-  END_EVENT_TABLE()
+  //BEGIN_EVENT_TABLE(WxGimmickReaderDialog, wxDialog)
+  //END_EVENT_TABLE()
   //================================================================
 
 
index 54f929c044b0f2eb7160c3af039a11dea5085311..8b597dfe533be6657b12cc3ced78de24b9863a2f 100644 (file)
@@ -50,12 +50,9 @@ namespace creaImageIO
     void OnSelChanged(EventType& event);
     void OnContextualMenu(EventType& event);
     void OnMenuTest(wxCommandEvent& event);
-       void OnValid(wxCommandEvent& event);
+       void OnValid(bool valid);
     //    void OnButtonOk(wxCommandEvent& event);
-    //    void OnButtonCancel(wxCommandEvent& event);
-
-    DECLARE_EVENT_TABLE()
-       
+    //    void OnButtonCancel(wxCommandEvent& event);  
        
   private :