From b44e1db0d66c00e0726e88dd49c5d8fbb775f558 Mon Sep 17 00:00:00 2001 From: caballero Date: Mon, 9 Mar 2009 12:36:02 +0000 Subject: [PATCH] Added boost signal to validate --- src2/creaImageIOGimmick.h | 3 +++ src2/creaImageIOGimmickView.cpp | 13 +++++++++++++ src2/creaImageIOGimmickView.h | 22 ++++++++++++++++++++++ src2/creaImageIOWxGimmickReaderDialog.cpp | 16 ++++++++-------- src2/creaImageIOWxGimmickReaderDialog.h | 7 ++----- 5 files changed, 48 insertions(+), 13 deletions(-) diff --git a/src2/creaImageIOGimmick.h b/src2/creaImageIOGimmick.h index b61874b..cdb7676 100644 --- a/src2/creaImageIOGimmick.h +++ b/src2/creaImageIOGimmick.h @@ -24,6 +24,9 @@ namespace creaImageIO /** * \defgroup Tree Attributed tree management */ + /** + * \defgroup Previewer Preview related + */ /** * \ingroup Controller diff --git a/src2/creaImageIOGimmickView.cpp b/src2/creaImageIOGimmickView.cpp index a16c096..a587a8d 100644 --- a/src2/creaImageIOGimmickView.cpp +++ b/src2/creaImageIOGimmickView.cpp @@ -1,6 +1,10 @@ #include #include +#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 diff --git a/src2/creaImageIOGimmickView.h b/src2/creaImageIOGimmickView.h index 011e471..f2baa23 100644 --- a/src2/creaImageIOGimmickView.h +++ b/src2/creaImageIOGimmickView.h @@ -9,6 +9,10 @@ #include #include +// Signal/slot mechanism for progress events +#include +#include + #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 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 ImageEventQueueType; ImageEventQueueType mImageEventQueue; + + ValidationSignalType mValidationSignal; }; // EO class GimmickView diff --git a/src2/creaImageIOWxGimmickReaderDialog.cpp b/src2/creaImageIOWxGimmickReaderDialog.cpp index 69572a3..6c311fb 100644 --- a/src2/creaImageIOWxGimmickReaderDialog.cpp +++ b/src2/creaImageIOWxGimmickReaderDialog.cpp @@ -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() //================================================================ diff --git a/src2/creaImageIOWxGimmickReaderDialog.h b/src2/creaImageIOWxGimmickReaderDialog.h index 54f929c..8b597df 100644 --- a/src2/creaImageIOWxGimmickReaderDialog.h +++ b/src2/creaImageIOWxGimmickReaderDialog.h @@ -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 : -- 2.45.1