IF (BBTK_COMPILE_ERROR_MESSAGES)
ADD_DEF( BBTK_COMPILE_ERROR_MESSAGES )
ENDIF (BBTK_COMPILE_ERROR_MESSAGES)
-
-ADD_DEF(_USE_BOOST__)
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# BOOST C++
-OPTION(BBTK_USE_BOOST "Use the boost C++ library" ON)
-IF(BBTK_USE_BOOST)
-ADD_DEF( _USE_BOOST_ )
-ENDIF(BBTK_USE_BOOST)
+OPTION(BBTK_USE_INTERNAL_BOOST "Use the internal boost C++ library" OFF)
#-----------------------------------------------------------------------------
MARK_AS_ADVANCED(LATEX_tth_CONVERTER)
ENDIF(USE_TTH)
#-----------------------------------------------------------------------------
+
+
+#-----------------------------------------------------------------------------
+# TO DO : FIND BOOST
+SET(USE_BOOST TRUE)
+IF(USE_BOOST)
+ FIND_PACKAGE(Boost REQUIRED)
+ MESSAGE(STATUS "Looking for boost C++ library... - found in ${Boost_INCLUDE_DIRS}")
+ INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
+ LINK_DIRECTORIES( ${Boost_LIBRARY_DIRS} )
+ SET(BBTK_BOOST_LIBRARIES
+ boost_signals
+ )
+ENDIF(USE_BOOST)
+#-----------------------------------------------------------------------------
ENDIF(BBTK_USE_WXWIDGETS)
#-----------------------------------------------------------------------------
+#-----------------------------------------------------------------------------
+# BOOST
+IF(BBTK_USE_BOOST)
+ SET(BBTK_LINK_LIBRARIES
+ ${BBTK_LINK_LIBRARIES}
+ ${BBTK_BOOST_LIBRARIES}
+ )
+ENDIF(BBTK_USE_BOOST)
+#-----------------------------------------------------------------------------
+
#-----------------------------------------------------------------------------
# On unix systems, need to link against dl for dynamic librairies open/close
IF(UNIX)
Program: bbtk
Module: $RCSfile: bbtkAny.h,v $
Language: C++
- Date: $Date: 2008/02/20 16:05:38 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2008/04/24 10:11:27 $
+ Version: $Revision: 1.3 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See doc/license.txt or
#include "bbtkMessageManager.h"
#include "bbtkException.h"
-#ifdef _USE_BOOST_
#include <boost/type_traits/is_pointer.hpp>
-#endif
namespace bbtk
{
-/*
-
-// TRY TO INCLUDE BOOST DIRECTLY : OK WORKS !
-#include <algorithm>
-#include <typeinfo>
-
-#include "boost/config.hpp"
-#include <boost/type_traits/remove_reference.hpp>
-#include <boost/type_traits/is_reference.hpp>
-#include <boost/throw_exception.hpp>
-#include <boost/static_assert.hpp>
-
-
-namespace bbtk
-{
-
-
- class bad_any_cast : public std::bad_cast
- {
- public:
- virtual const char * what() const throw()
- {
- return "boost::bad_any_cast: "
- "failed conversion using boost::any_cast";
- }
- };
-
- typedef any<thing> anything;
-
- template<typename ValueType>
- ValueType * any_cast(anything * operand)
- {
- return operand && operand->type() == typeid(ValueType)
- ? &static_cast<anything::holder<ValueType> *>(operand->content)->held
- : 0;
- }
-
- template<typename ValueType>
- const ValueType * any_cast(const anything * operand)
- {
- return any_cast<ValueType>(const_cast<anything *>(operand));
- }
-
- template<typename ValueType>
- ValueType any_cast(const anything & operand)
- {
- typedef BOOST_DEDUCED_TYPENAME boost::remove_reference<ValueType>::type nonref;
-
-#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
- // If 'nonref' is still reference type, it means the user has not
- // specialized 'remove_reference'.
-
- // Please use BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION macro
- // to generate specialization of remove_reference for your class
- // See type traits library documentation for details
- BOOST_STATIC_ASSERT(!boost::is_reference<nonref>::value);
-#endif
-
- const nonref * result = any_cast<nonref>(&operand);
- if(!result)
- boost::throw_exception(bad_any_cast());
- return *result;
- }
-
- template<typename ValueType>
- ValueType any_cast(anything & operand)
- {
- typedef BOOST_DEDUCED_TYPENAME boost::remove_reference<ValueType>::type nonref;
-
-#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
- // The comment in the above version of 'any_cast' explains when this
- // assert is fired and what to do.
- BOOST_STATIC_ASSERT(!is_reference<nonref>::value);
-#endif
-
- nonref * result = any_cast<nonref>(&operand);
- if(!result)
- boost::throw_exception(bad_any_cast());
- return *result;
- }
-
- // Note: The "unsafe" versions of any_cast are not part of the
- // public interface and may be removed at any time. They are
- // required where we know what type is stored in the any and can't
- // use typeid() comparison, e.g., when our types may travel across
- // different shared libraries.
- template<typename ValueType>
- inline ValueType * unsafe_any_cast(anything * operand)
- {
- return &static_cast<anything::holder<ValueType> *>(operand->content)->held;
- }
-
- template<typename ValueType>
- inline const ValueType * unsafe_any_cast(const anything * operand)
- {
- return unsafe_any_cast<ValueType>(const_cast<anything *>(operand));
- }
-}
-*/ // EO TRY TO INCLUDE BOOST
-
#endif
Program: bbtk
Module: $RCSfile: bbtkAtomicBlackBox.cxx,v $
Language: C++
- Date: $Date: 2008/04/21 12:43:05 $
- Version: $Revision: 1.5 $
+ Date: $Date: 2008/04/24 10:11:27 $
+ Version: $Revision: 1.6 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
/// Main processing method of the box.
IOStatus AtomicBlackBox::bbBackwardUpdate( Connection::Pointer caller )
{
- bbtkDebugMessageInc("Process",1,
+ bbtkDebugMessageInc("process",3,
"=> AtomicBlackBox::bbBackwardUpdate("
<<(caller?caller->GetFullName():"0")<<") ["
<<bbGetFullName()<<"]"<<std::endl);
- bbtkDebugMessage("Process",5,"Initial Status = "<<bbGetStatus()
+ bbtkDebugMessage("process",5,"Initial Status = "<<bbGetStatus()
<<std::endl);
- bbtkDebugMessage("Process",5,"BoxProcessMode = "
+ bbtkDebugMessage("process",5,"BoxProcessMode = "
<<bbGetInputBoxProcessMode()<<std::endl);
// Updates its inputs
IOStatus s = bbUpdateInputs();
- bbtkDebugMessage("Process",6,"Inputs post-update status = "<<s<<std::endl);
+ bbtkDebugMessage("process",6,"Inputs post-update status = "<<s<<std::endl);
// If all inputs are in UPTODATE post-update status
// and mProcessMode is not "Always"
// then the box is now UPTODATE
}
else
{
- bbtkDebugMessage("Process",5,"Up-to-date : nothing to do"<<std::endl);
+ bbtkDebugMessage("process",5,"Up-to-date : nothing to do"<<std::endl);
}
- bbtkDebugMessage("Process",5,"Final Status = "
+ bbtkDebugMessage("process",5,"Final Status = "
<<bbGetStatus()<<std::endl);
- bbtkDebugMessage("Process",1,
+ bbtkDebugMessage("process",3,
"<= AtomicBlackBox::bbBackwardUpdate() ["
<<bbGetFullName()<<"]"<<std::endl);
- bbtkDebugDecTab("Process",1);
return bbGetStatus();
Program: bbtk
Module: $RCSfile: bbtkAtomicBlackBoxGetSetFunctor.h,v $
Language: C++
- Date: $Date: 2008/02/07 11:06:37 $
- Version: $Revision: 1.1 $
+ Date: $Date: 2008/04/24 10:11:27 $
+ Version: $Revision: 1.2 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
///
virtual bool IsPointerType() const
{
-#ifdef _USE_BOOST_
- return boost::is_pointer<T>::value;
-#else
- return false;
-#endif
+ return boost::is_pointer<T>::value;
}
private:
Program: bbtk
Module: $RCSfile: bbtkAtomicBlackBoxMacros.h,v $
Language: C++
- Date: $Date: 2008/04/18 12:59:15 $
- Version: $Revision: 1.5 $
+ Date: $Date: 2008/04/24 10:11:27 $
+ Version: $Revision: 1.6 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
public: \
inline void bbUserProcess() \
{ \
- bbtkDebugMessageInc("Process",1,"=> "<<bbGetTypeName()<<"::bbUserProcess() [" \
- <<bbGetFullName()<<"]"<<std::endl); \
+ bbtkDebugMessage("process",1,"**> Processing ["<<bbGetFullName() \
+ <<"]"<<std::endl); \
CALLBACK(); \
- bbtkDebugMessageDec("Process",1,"<= "<<bbGetTypeName()<<"::bbUserProcess() [" \
- <<bbGetFullName()<<"]"<<std::endl); \
+ bbtkDebugMessage("process",1,"<** Processing ["<<bbGetFullName() \
+ <<"]"<<std::endl); \
}
//============================================================================
Program: bbtk
Module: $RCSfile: bbtkBlackBox.cxx,v $
Language: C++
-Date: $Date: 2008/04/23 14:49:27 $
-Version: $Revision: 1.15 $
+Date: $Date: 2008/04/24 10:11:27 $
+Version: $Revision: 1.16 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See doc/license.txt or
/// Main processing method of the box.
void BlackBox::bbExecute(bool force)
{
- bbtkDebugMessageInc("Process",1,
+ bbtkDebugMessageInc("process",2,
"=> BlackBox::bbExecute() ["
<<bbGetFullName()<<"]"<<std::endl);
// If execution frozen : return
if (bbGlobalGetFreezeExecution())
{
- bbtkDebugMessage("Process",1,
+ bbtkDebugMessage("process",2,
" -> FreezeExecution global flag is 'true' : abort execution"<<std::endl);
}
Wx::EndBusyCursor();
- bbtkDebugMessageDec("Process",1,
+ bbtkDebugMessageDec("process",2,
"<= BlackBox::bbExecute() ["
<<bbGetFullName()<<"]"<<std::endl);
}
/// User overloadable destruction method of a black box
void BlackBox::bbUserDelete()
{
- bbtkDebugMessage("Process",5,
+ bbtkDebugMessage("process",5,
"=> BlackBox::bbUserDelete() ["
<<bbGetFullName()<<"]"
<<" : not overloaded; using standard deletion"
this->bbSignalOutputModification(false);
/*
- bbtkDebugMessageDec("Process",5,
+ bbtkDebugMessageDec("process",5,
"<= BlackBox::bbSetModifiedStatus("<<c<<") ["
<<bbGetFullName()<<"]"<<std::endl);
*/
//=========================================================================
void BlackBox::bbSignalOutputModification(bool reaction)
{
- bbtkDebugMessageInc("Process",5,
+ bbtkDebugMessageInc("process",5,
"=> BlackBox::bbSignalOutputModification() ["
<<bbGetFullName()<<"]"<<std::endl);
if (reaction) bbGlobalProcessExecutionList();
- bbtkDebugMessageDec("Process",5,
+ bbtkDebugMessageDec("process",5,
"<= BlackBox::bbSignalOutputModification() ["
<<bbGetFullName()<<"]"<<std::endl);
void BlackBox::bbSignalOutputModification(const std::string& output,
bool reaction)
{
- bbtkDebugMessageInc("Process",5,
+ bbtkDebugMessageInc("process",5,
"=> BlackBox::bbSignalOutputModification("
<<output<<") ["
<<bbGetFullName()<<"]"<<std::endl);
}
if (reaction) bbGlobalProcessExecutionList();
- bbtkDebugMessageDec("Process",5,
+ bbtkDebugMessageDec("process",5,
"<= BlackBox::bbSignalOutputModification("
<<output<<") ["
<<bbGetFullName()<<"]"<<std::endl);
void BlackBox::bbSignalOutputModification(const std::vector<std::string>& output,
bool reaction)
{
- bbtkDebugMessageInc("Process",5,
+ bbtkDebugMessageInc("process",5,
"=> BlackBox::bbSignalOutputModification(vector of outputs) ["
<<bbGetFullName()<<"]"<<std::endl);
OutputConnectorMapType::iterator i;
}
if (reaction) bbGlobalProcessExecutionList();
- bbtkDebugMessageDec("Process",5,
+ bbtkDebugMessageDec("process",5,
"<= BlackBox::bbSignalOutputModification(vector of outputs) ["
<<bbGetFullName()<<"]"<<std::endl);
/// else MODIFIED
IOStatus BlackBox::bbUpdateInputs(bool excludeParent)
{
- bbtkDebugMessageInc("Process",4,
+ bbtkDebugMessageInc("process",4,
"=> BlackBox::bbUpdateInputs() ["
<<bbGetFullName()<<"]"
<<std::endl);
if (t==MODIFIED) s = MODIFIED;
}
- bbtkDebugMessageDec("Process",4,
+ bbtkDebugMessageDec("process",4,
"<= BlackBox::bbUpdateInputs() ["
<<bbGetFullName()<<"]"
<<std::endl);
//=========================================================================
void BlackBox::bbGlobalProcessExecutionList()
{
- bbtkDebugMessageInc("Process",1,
+ bbtkDebugMessageInc("process",3,
"=> BlackBox::bbGlobalProcessExecutionList()"
<<std::endl);
i!=bbmgExecutionList.end();
++i)
{
- bbtkDebugMessage("Process",2,
+ bbtkDebugMessage("process",4,
" -> Executing "<<(*i)->bbGetFullName()<<std::endl);
(*i)->bbExecute(true);
}
bbmgExecutionList.clear();
- bbtkDebugMessageDec("Process",1,
+ bbtkDebugMessageDec("process",3,
"<= BlackBox::bbGlobalProcessExecutionList()"
<<std::endl);
Program: bbtk
Module: $RCSfile: bbtkBlackBoxInputConnector.cxx,v $
Language: C++
- Date: $Date: 2008/04/22 14:30:25 $
- Version: $Revision: 1.4 $
+ Date: $Date: 2008/04/24 10:11:28 $
+ Version: $Revision: 1.5 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
IOStatus BlackBoxInputConnector::BackwardUpdate()
{
- bbtkDebugMessageInc("Process",4,"BlackBoxInputConnector::BackwardUpdate()"
- <<std::endl);
+ bbtkDebugMessage("process",9,"==> BlackBoxInputConnector::BackwardUpdate()"
+ <<std::endl);
if (mConnection) //.lock())
{
mStatus = UPTODATE;
}
- bbtkDecTab("Process",4);
-
return mStatus;
}
Program: bbtk
Module: $RCSfile: bbtkBlackBoxOutputConnector.cxx,v $
Language: C++
- Date: $Date: 2008/04/23 14:49:27 $
- Version: $Revision: 1.6 $
+ Date: $Date: 2008/04/24 10:11:28 $
+ Version: $Revision: 1.7 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
(*i)->SetModifiedStatus();
}
- // bbtkDebugDecTab("Process",5);
}
Program: bbtk
Module: $RCSfile: bbtkComplexBlackBox.cxx,v $
Language: C++
-Date: $Date: 2008/04/23 14:49:27 $
-Version: $Revision: 1.16 $
+Date: $Date: 2008/04/24 10:11:28 $
+Version: $Revision: 1.17 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
/// Executes the box so that its outputs are up-to-date on exit
void ComplexBlackBox::bbExecute(bool force)
{
- bbtkDebugMessageInc("Process",1,
- "ComplexBlackBox::bbExecute() ["
+ bbtkDebugMessageInc("process",2,
+ "=> ComplexBlackBox::bbExecute() ["
<<bbGetFullName()<<"]"<<std::endl);
i!=mExecutionList.end();
++i)
{
- bbtkDebugMessage("Process",2," -> Executing '"<<*i<<"'"<<std::endl);
+ bbtkDebugMessage("process",3," -> Executing '"<<*i<<"'"<<std::endl);
mBlackBoxMap[*i]->bbExecute(force);
}
}
Wx::EndBusyCursor();
-
- bbtkDebugDecTab("Process",1);
}
//==================================================================
//==================================================================
IOStatus ComplexBlackBox::bbBackwardUpdate(Connection::Pointer caller)
{
- bbtkDebugMessageInc("Process",1,
- "ComplexBlackBox::bbBackwardUpdate("
+ bbtkDebugMessageInc("process",3,
+ "==> ComplexBlackBox::bbBackwardUpdate("
<<(caller?caller->GetFullName():"0")<<") ["
<<bbGetFullName()<<"]"<<std::endl);
// bbtkInternalError("ComplexBlackBox::bbBackwardUpdate should never be called !");
// Get the internal box
BlackBox::Pointer b = bbUnsafeGetBlackBox ( d->GetTarget() );
// Calls BackwardUpdate on it
- bbtkDebugMessageInc("Process",2,"Internal box connected to output : "<<d->GetTarget()<<std::endl);
+ bbtkDebugMessageInc("process",4,"Internal box connected to output : "<<d->GetTarget()<<std::endl);
// Because internal box can also be a complex box we have to
// temporarily change the connection BlackBoxFromOutput to the
// mapped one
// ??? STATUS OF CBBs ???
// ??? Here it is only the final status of the boxes connected to the output
if (s1==MODIFIED) s=MODIFIED;
- bbtkDebugDecTab("Process",2);
}
else
{
bbtkError("Connection '"<<caller->GetFullName()<<"' does not point to a valid output of the complex box !");
}
- bbtkDebugDecTab("Process",1);
return s;
Program: bbtk
Module: $RCSfile: bbtkConnection.cxx,v $
Language: C++
- Date: $Date: 2008/04/23 14:49:27 $
- Version: $Revision: 1.11 $
+ Date: $Date: 2008/04/24 10:11:28 $
+ Version: $Revision: 1.12 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See doc/license.txt or
/// Backward Update
IOStatus Connection::BackwardUpdate()
{
- bbtkDebugMessageInc("Process",2,
- "Connection::BackwardUpdate() ["
- <<GetFullName()<<"]"<<std::endl);
+ bbtkDebugMessage("process",5,
+ "===> Connection::BackwardUpdate() ["
+ <<GetFullName()<<"]"<<std::endl);
IOStatus s = UPTODATE;
s = mFrom->bbBackwardUpdate(GetThisPointer<Connection>());
if (mAdaptor && (s==MODIFIED)) mAdaptor->bbSetModifiedStatus();
- bbtkDebugDecTab("Process",2);
-
+ bbtkDebugMessage("process",5,
+ "<=== Connection::BackwardUpdate() ["
+ <<GetFullName()<<"]"<<std::endl);
return s;
}
//==================================================================
/// Forward Update
void Connection::ForwardUpdate()
{
- bbtkDebugMessageInc("Process",2,
+ bbtkDebugMessageInc("process",2,
"Connection::ForwardUpdate() ["
<<GetFullName()<<"]"<<std::endl);
mTo->bbForwardUpdate(this);
- bbtkDebugDecTab("Process",2);
+ bbtkDebugDecTab("process",2);
}
//==================================================================
*/
/// doing necessary conversions (adaptation or pointer cast)
void Connection::TransferData()
{
- bbtkDebugMessageInc("Process",3,
+ bbtkDebugMessageInc("data",3,
"Connection::TransferData() ["
<<GetFullName()<<"]"<<std::endl);
// If no adaptor but source type is an any and target is not an any
else if ( mFromAny && (! mToAny) )
{
- bbtkDebugMessage("Data",3,
- "Connection::TransferData() ["
- <<GetFullName()<<"]"<<std::endl);
- bbtkDebugMessage("Data",3,
+ bbtkDebugMessage("data",3,
" * Source type is an "
<<HumanTypeName<Data>()
<<" which contains a <"
<<HumanTypeName(mFrom->bbGetOutput(mOutput).type())
<<">"<<std::endl);
- bbtkDebugMessage("Data",3,
+ bbtkDebugMessage("data",3,
" * Target type is <"
<<HumanTypeName(mTo->bbGetInputType(mInput))
<<">"<<std::endl);
if (mFrom->bbGetOutput(mOutput)
.contains( mTo->bbGetInputType(mInput) ) )
{
- bbtkDebugMessage("Data",3,
+ bbtkDebugMessage("data",3,
" -> Equal types : transfer ok"<<std::endl);
mTo->bbSetInput( mInput,
mFrom->bbGetOutput(mOutput),
}
if (adaptor)
{
- bbtkDebugMessage("Data",3," -> Adaptor found : using it"
+ bbtkDebugMessage("data",3," -> Adaptor found : using it"
<<std::endl);
adaptor->bbSetInput("In",mFrom->bbGetOutput(mOutput),false);
adaptor->bbExecute();
(mTo->bbGetDescriptor()->GetInputDescriptor(mInput)
->IsPointerType()) )
{
- bbtkDebugMessage("Data",3,
+ bbtkDebugMessage("data",3,
" -> No adaptor found but source and target types are both pointers : trying up or down cast"<<std::endl);
void* nptr =
mTo->bbSetInput(mInput, mFrom->bbGetOutput(mOutput),false);
}
- bbtkDebugDecTab("Process",3);
}
//==================================================================
Program: bbtk
Module: $RCSfile: bbtkMessageManager.cxx,v $
Language: C++
- Date: $Date: 2008/04/23 14:49:27 $
- Version: $Revision: 1.10 $
+ Date: $Date: 2008/04/24 10:11:28 $
+ 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
mMessageLevel[key] = 0;
mMessageHelp[key] = "Messages generated by the core classes of the lib";
if (mMaxMessageLength<key.length()) mMaxMessageLength = key.length();
- key ="Process";
+ key ="process";
mMessageLevel[key] = 0;
mMessageHelp[key] = "Messages related to box processing";
if (mMaxMessageLength<key.length()) mMaxMessageLength = key.length();
#include "bbtkWx.h"
#include "bbtkMessageManager.h"
+#include <boost/signal.hpp>
+//#include <boost/bind.hpp>
namespace bbtk
{
-//EED
static wxWindow* mgTopWindow = 0;
static int mgNbWindowsAlive = 0;
static int mgNbWindowsShown = 0;
+ static bool mgAutoDestroyTopWindow = true;
- void Wx::CreateInvisibleTopWindow(wxWindow* parent)
+ // BBTKWXSIG
+ static Wx::Signal_type mgWxSignal;
+ // \BBTKWXSIG
+
+
+ //=========================================================================
+ void Wx::CreateTopWindow(wxWindow* parent, bool autodestroy)
{
- wxWindow* top = new wxFrame(parent,
- -1,_T("TOP (YOU SHOULD NOT SEE ME !!)"));
+ wxWindow* top =
+ new wxFrame(parent,
+ -1,
+ _T("TOP BBTK FRAME (YOU SHOULD NOT SEE ME !!)"));
top->Hide();
Wx::SetTopWindow(top);
+ mgAutoDestroyTopWindow = autodestroy;
}
-
- void Wx::ResetCursor()
+ //=========================================================================
+
+ //=========================================================================
+ wxWindow* Wx::GetTopWindow()
+ {
+ if (mgTopWindow==0) Wx::CreateTopWindow(0);
+ return mgTopWindow;
+ }
+ //=========================================================================
+
+ //=========================================================================
+ bool Wx::TopWindowExists()
{
- if (!GetTopWindow()) return;
- bbtkDebugMessage("wx",9,"wx::ResetCursor()"<<std::endl);
- while (wxIsBusy()) ::wxEndBusyCursor();
+ return (mgTopWindow!=0);
}
- void Wx::BeginBusyCursor()
+ //=========================================================================
+
+ // BBTKWXSIG
+ //=========================================================================
+ void Wx::AddSignalObserver(Slot_function_type f)
{
- if (!GetTopWindow()) return;
- bbtkDebugMessage("wx",9,"wx::BeginBusyCursor()"<<std::endl);
- ::wxBeginBusyCursor();
+ mgWxSignal.connect(f);
}
- void Wx::EndBusyCursor()
+ //=========================================================================
+ // \BBTKWXSIG
+
+ //=========================================================================
+ void Wx::AutoDestroyTopWindow(bool b)
{
- if (!GetTopWindow()) return;
- bbtkDebugMessage("wx",9,"wx::EndBusyCursor()"<<std::endl);
- ::wxEndBusyCursor();
+ mgAutoDestroyTopWindow = b;
}
+ //=========================================================================
//=========================================================================
void Wx::SetTopWindow(wxWindow* w)
mgTopWindow = w;
}
//=========================================================================
+
+
+ //=========================================================================
+ void Wx::IncNbWindowsAlive()
+ {
+ mgNbWindowsAlive++;
+ bbtkDebugMessage("wx",2,"* Number of windows alive = "<<mgNbWindowsAlive
+ <<std::endl);
+ // BBTKWXSIG
+ mgWxSignal();
+ // \BBTKWXSIG
+ }
+ //=========================================================================
+
//=========================================================================
void Wx::DecNbWindowsAlive()
{
mgNbWindowsAlive--;
- /*
- if ( (bbmgNbWindowsAlive==0) &&
- bbmgTopWindow && (!bbmgTopWindow->IsShown()))
+ bbtkDebugMessage("wx",2,"* Number of windows alive = "<<mgNbWindowsAlive
+ <<std::endl);
+ if ( (mgNbWindowsAlive==0) &&
+ (mgAutoDestroyTopWindow) )
{
- bbmgTopWindow->Close();
+ bbtkDebugMessage("wx",2," --> Destructing top window"<<std::endl);
+ mgTopWindow->Close();
+ mgTopWindow = 0;
}
- */
+ // BBTKWXSIG
+ mgWxSignal();
+ // \BBTKWXSIG
+ }
+ //=========================================================================
+
+ //=========================================================================
+ void Wx::IncNbWindowsShown()
+ {
+ mgNbWindowsShown++;
+ bbtkDebugMessage("wx",2,"* Number of windows shown = "<<mgNbWindowsShown
+ <<std::endl);
+ // BBTKWXSIG
+ mgWxSignal();
+ // \BBTKWXSIG
}
//=========================================================================
void Wx::DecNbWindowsShown()
{
mgNbWindowsShown--;
- if ( (mgNbWindowsShown==0) &&
- mgTopWindow && (!mgTopWindow->IsShown()))
+ bbtkDebugMessage("wx",2,"* Number of windows shown = "<<mgNbWindowsShown
+ <<std::endl);
+ if ( (mgNbWindowsAlive==0) &&
+ (mgAutoDestroyTopWindow) )
{
- mgTopWindow->Close();
+ bbtkDebugMessage("wx",2," --> Destructing top window"<<std::endl);
+ mgTopWindow->Close();
+ mgTopWindow = 0;
}
+ // BBTKWXSIG
+ mgWxSignal();
+ // \BBTKWXSIG
}
//=========================================================================
+
//=========================================================================
-/*EED
- // Static members
- wxWindow* Wx::mgTopWindow = 0;
- int Wx::mgNbWindowsAlive = 0;
- int Wx::mgNbWindowsShown = 0;
-*/
+ int Wx::GetNbWindowsAlive()
+ {
+ return mgNbWindowsAlive;
+ }
+ //=========================================================================
+
+ //=========================================================================
+ bool Wx::IsSomeWindowAlive()
+ {
+ return (mgNbWindowsAlive>0);
+ }
+ //=========================================================================
+
+
+ //=========================================================================
+ int Wx::GetNbWindowsShown()
+ {
+ return mgNbWindowsShown;
+ }
+ //=========================================================================
+
+ //=========================================================================
+ bool Wx::IsSomeWindowShown()
+ {
+ return (mgNbWindowsShown>0);
+ }
+ //=========================================================================
+
+ //=========================================================================
+ void Wx::ResetCursor()
+ {
+ if (!TopWindowExists()) return;
+ bbtkDebugMessage("wx",9,"Wx::ResetCursor()"<<std::endl);
+ while (wxIsBusy()) ::wxEndBusyCursor();
+ }
+ //=========================================================================
+ //=========================================================================
+ void Wx::BeginBusyCursor()
+ {
+ if (!TopWindowExists()) return;
+ bbtkDebugMessage("wx",9,"Wx::BeginBusyCursor()"<<std::endl);
+ ::wxBeginBusyCursor();
+ }
+ //=========================================================================
+ //=========================================================================
+ void Wx::EndBusyCursor()
+ {
+ if (!TopWindowExists()) return;
+ bbtkDebugMessage("wx",9,"Wx::EndBusyCursor()"<<std::endl);
+ ::wxEndBusyCursor();
+ }
//=========================================================================
-//EED
- wxWindow* Wx::GetTopWindow()
- {
- return mgTopWindow;
- }
-
- void Wx::IncNbWindowsAlive()
- {
- mgNbWindowsAlive++;
- }
-
- int Wx::GetNbWindowsAlive()
- {
- return mgNbWindowsAlive;
- }
-
- bool Wx::IsSomeWindowAlive()
- {
- return (mgNbWindowsAlive>0);
- }
-
- void Wx::IncNbWindowsShown()
- {
- mgNbWindowsShown++;
- }
-
- int Wx::GetNbWindowsShown()
- {
- return mgNbWindowsShown;
- }
-
- bool Wx::IsSomeWindowShown()
- {
- return (mgNbWindowsShown>0);
- }
-
}
#endif
#include "bbtkSystem.h"
+// SIGNAL/SLOT MECHANISM
+// FOR bbtk WINDOWS CREATION/DESTRUCTION OBSERVATION
+// BBTKWXSIG
+#include <boost/signal.hpp>
+#include <boost/bind.hpp>
+// \BBTKWXSIG
+
namespace bbtk
{
//==================================================================
/// Global wx handlers (cursor...)
+// BBTKWXSIG
+#define bbtkAddWxSignalObserver(METHOD) \
+ Wx::AddSignalObserver(boost::bind(&METHOD, this))
+// \BBTKWXSIG
+
struct BBTK_EXPORT Wx
{
public:
+ // BBTKWXSIG
+ typedef boost::signals::trackable SignalObserver;
+ typedef boost::signal<void ()> Signal_type;
+ typedef Signal_type::slot_function_type Slot_function_type;
+ // \BBTKWXSIG
+
static void ResetCursor();
static void BeginBusyCursor();
static void EndBusyCursor();
- static int mBeginBusyCallsCount;
- static void CreateInvisibleTopWindow(wxWindow* parent=0);
- /// Returns the global parent of all bbtk windows
+ static void CreateTopWindow(wxWindow* parent=0, bool autodestroy=true);
+ /// Returns the creation time parent of all bbtk windows
+ /// (window can be reparented after creation)
static wxWindow* GetTopWindow();
- /// Sets the global parent of all bbtk windows
- static void SetTopWindow(wxWindow*);
+ static bool TopWindowExists();
+
+ static void AutoDestroyTopWindow(bool);
static void IncNbWindowsAlive();
static void DecNbWindowsAlive();
static void DecNbWindowsShown();
static int GetNbWindowsShown();
static bool IsSomeWindowShown();
-
-/*EED
+
+ // BBTKWXSIG
+ static void AddSignalObserver(Slot_function_type);
+ // \BBTKWXSIG
private:
- static wxWindow* mgTopWindow;
- static int mgNbWindowsAlive;
- static int mgNbWindowsShown;
-*/
+ /// Sets the creation time parent of all bbtk windows
+ static void SetTopWindow(wxWindow*);
}; // struct Wx
//==================================================================
Program: bbtk
Module: $RCSfile: bbtkWxBlackBox.cxx,v $
Language: C++
- Date: $Date: 2008/04/23 14:49:28 $
- Version: $Revision: 1.15 $
+ Date: $Date: 2008/04/24 10:11:28 $
+ Version: $Revision: 1.16 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
mBox.lock()->bbGetFullName()<<")"<<std::endl);
mBox.lock()->bbSetWindow(this);
Wx::IncNbWindowsAlive();
- bbtkDebugMessage("wx",5," -> Number of windows alive = "
- <<Wx::GetNbWindowsAlive()<<std::endl);
}
//=========================================================================
{
mBox.lock()->bbSetWindow(0);
}
- else
- {
- }
- bbtkDebugMessage("wx",5," -> Number of windows alive = "
- <<Wx::GetNbWindowsAlive()<<std::endl);
}
//=========================================================================
bbtkDebugMessage("wx",9,"WxBlackBoxWindow::bbShow()"<<std::endl);
Wx::IncNbWindowsShown();
mShown = true;
- bbtkDebugMessage("wx",5," -> Number of windows shown = "
- <<Wx::GetNbWindowsShown()<<std::endl);
}
//=========================================================================
bbtkDebugMessage("wx",9,"WxBlackBoxWindow::bbHide()"<<std::endl);
Wx::DecNbWindowsShown();
mShown = false;
- bbtkDebugMessage("wx",5," -> Number of windows shown = "
- <<Wx::GetNbWindowsShown()<<std::endl);
}
//=========================================================================
/// Main processing method of the box.
void WxBlackBox::bbExecute(bool force)
{
- bbtkDebugMessageInc("Process",1,
+ bbtkDebugMessageInc("process",2,
"=> WxBlackBox::bbExecute() ["
<<bbGetFullName()<<"]"<<std::endl);
if ( i->second->GetConnectionVector().size() != 0 )
{
- bbtkDebugMessage("Process",2,
+ bbtkDebugMessage("process",3,
"-> Output 'Widget' connected : transfering execution to parent"
<<std::endl);
}
//
- bbtkDebugMessageDec("Process",1,
+ bbtkDebugMessageDec("process",2,
"<= WxBlackBox::bbExecute() ["
<<bbGetFullName()<<"]"<<std::endl);
}
/// Main processing method of the box.
IOStatus WxBlackBox::bbBackwardUpdate( Connection::Pointer caller )
{
- bbtkDebugMessage("Process",1,
+ bbtkDebugMessage("process",3,
"=> WxBlackBox::bbBackwardUpdate("
<<(caller?caller->GetFullName():"0")<<") ["
<<bbGetFullName()<<"]"<<std::endl);
if ( ! (( bbGetStatus() == MODIFIED ) ||
( bbBoxProcessModeIsAlways() )) )
{
- bbtkDebugMessage("Process",2,"Up-to-date : nothing to do"<<std::endl);
- bbtkDebugMessage("Process",1,
+ bbtkDebugMessage("process",3,"Up-to-date : nothing to do"<<std::endl);
+ bbtkDebugMessage("process",3,
"<= WxBlackBox::bbBackwardUpdate("
<<(caller?caller->GetFullName():"0")<<") ["
<<bbGetFullName()<<"]"<<std::endl);
if (caller)
{
- bbtkDebugMessage("Process",2,
+ bbtkDebugMessage("process",3,
"-> Output 'Widget' connected to '"
<<to->bbGetFullName()<<"' - caller->to = '"
<<caller->GetBlackBoxTo()->bbGetFullName()
}
else
{
- bbtkDebugMessage("Process",2,
+ bbtkDebugMessage("process",3,
"-> Output 'Widget' connected to '"
<<to->bbGetFullName()<<"'"
<<std::endl);
(caller->GetBlackBoxTo() != to))&&
(!bbGetUpdateTransferedToParent()))
{
- bbtkDebugMessage("Process",2,
+ bbtkDebugMessage("process",3,
" ... Transfering update order to parent"
<<std::endl);
else
{
bbSetUpdateTransferedToParent(false);
- bbtkDebugMessage("Process",2,
+ bbtkDebugMessage("process",3,
" ... No need to transfer to parent"
<<std::endl);
}
AtomicBlackBox::bbBackwardUpdate(caller);
}
- bbtkDebugMessageDec("Process",1,
+ bbtkDebugMessageDec("process",3,
"<= WxBlackBox::bbBackwardUpdate() ["
<<bbGetFullName()<<"]"<<std::endl);
/// (called after bbProcess during bbExecute)
void WxBlackBox::bbShowWindow()
{
- bbtkDebugMessageInc("Process",1,"=> WxBlackBox::bbShowWindow() ["
+ bbtkDebugMessageInc("wx",1,"=> WxBlackBox::bbShowWindow() ["
<<bbGetFullName()<<"]"<<std::endl);
// If Event Handler for the widget does not exist or is obsolete : create it
{
if (bbGetWidgetEventHandler()==0)
{
- bbtkDebugMessage("Process",3,
+ bbtkDebugMessage("wx",3,
"-> No widget event handler : creating one"
<<std::endl);
new WxBlackBoxWidgetEventHandler(GetThisPointer<WxBlackBox>(),
else if ( ! bbGetWidgetEventHandler()->IsHandlerOf
( bbGetOutputWidget() ) )
{
- bbtkDebugMessage("Process",3,
+ bbtkDebugMessage("wx",3,
"-> Obsolete widget event handler : re-creating one"
<<std::endl);
delete bbGetWidgetEventHandler();
->GetConnectionVector().size() != 0 )
{
- bbtkDebugMessage("Process",2,
+ bbtkDebugMessage("wx",2,
"-> Output 'Widget' connected : nothing to do"
<<std::endl);
- bbtkDebugDecTab("Process",1);
return;
}
// If the window already exists : no need creating it
if (bbGetWindow()!=0)
{
- bbtkDebugMessage("Process",2,
+ bbtkDebugMessage("wx",2,
"-> Window already exists"
<<std::endl);
show = bbGetWindow();
// Else if the widget exists : create window
else if (bbGetOutputWidget()!=0)
{
- bbtkDebugMessage("Process",2,
+ bbtkDebugMessage("wx",2,
"-> Widget exists : creating the window"
<<std::endl);
// Input WinDialog set to true : creating a Dialog
if (bbGetInputWinDialog())
{
- bbtkDebugMessage("Process",2,
+ bbtkDebugMessage("wx",2,
" Input WinDialog set to true : creating a Dialog"
<<std::endl);
show = (Window*) new WxBlackBoxDialog( GetThisPointer<WxBlackBox>(),
// Input WinDialog set to false : creating a Frame
else
{
- bbtkDebugMessage("Process",2,
+ bbtkDebugMessage("process",2,
" Input WinDialog set to false : creating a Frame"
<<std::endl);
show = (Window*) new WxBlackBoxFrame( GetThisPointer<WxBlackBox>(),
}
else
{
- bbtkDebugMessage("Process",2,"-> Already shown : nothing to do"<<std::endl);
+ bbtkDebugMessage("wx",2,"-> Already shown : nothing to do"<<std::endl);
}
- bbtkDebugMessage("Process",1,"<= WxBlackBox::bbShowWindow() ["
+ bbtkDebugMessage("wx",1,"<= WxBlackBox::bbShowWindow() ["
<<bbGetFullName()<<"]"<<std::endl);
- bbtkDebugDecTab("Process",1);
+
}
//==================================================================
//==================================================================
void WxBlackBox::bbHideWindow()
{
- bbtkDebugMessageInc("Process",1,"=> WxBlackBox::bbHideWindow() ["
+ bbtkDebugMessageInc("wx",1,"=> WxBlackBox::bbHideWindow() ["
<<bbGetFullName()<<"]"<<std::endl);
if (bbGetWindow()!=0) bbGetWindow()->bbHide();
- bbtkDebugMessageDec("Process",1,"<= WxBlackBox::bbHideWindow() ["
+ bbtkDebugMessageDec("wx",1,"<= WxBlackBox::bbHideWindow() ["
<<bbGetFullName()<<"]"<<std::endl);
}
//==================================================================
Program: bbtk
Module: $RCSfile: bbtkWxBlackBox.h,v $
Language: C++
- Date: $Date: 2008/04/22 14:30:25 $
- Version: $Revision: 1.13 $
+ Date: $Date: 2008/04/24 10:11:28 $
+ Version: $Revision: 1.14 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
public: \
inline void bbUserCreateWidget() \
{ \
- bbtkDebugMessageInc("Process",1,"=> "<<bbGetTypeName()<<"::bbUserCreateWidget() [" \
+ bbtkDebugMessageInc("process",1,"**> Creating widget for [" \
<<bbGetFullName()<<"]"<<std::endl); \
CALLBACK(); \
- bbtkDebugMessageDec("Process",1,"<= "<<bbGetTypeName()<<"::bbUserCreateWidget() [" \
+ bbtkDebugMessageInc("process",1,"<** Creating widget for [" \
<<bbGetFullName()<<"]"<<std::endl); \
}
Program: bbtk
Module: $RCSfile: bbtkWxGUIConsole.cxx,v $
Language: C++
- Date: $Date: 2008/04/23 14:49:28 $
- Version: $Revision: 1.8 $
+ Date: $Date: 2008/04/24 10:11:28 $
+ Version: $Revision: 1.9 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
cmdsizer->Add (mWxGUICommand, 0, wxALL | wxGROW, 5);
- // Creates and sets the parent window of all bbtk windows
- /*
- wxWindow* top = new wxPanel(this,-1);//,_T("top"));
- top->Hide();
- Wx::SetTopWindow(top);
- */
- Wx::CreateInvisibleTopWindow(this);
+ // Creates the parent window of all bbtk windows as a child of this
+ Wx::CreateTopWindow(this,true);
+ // Add the method OnWxSignal as a Wx::Signal observer
+ bbtkAddWxSignalObserver(WxGUIConsole::OnWxSignal);
+
// Layout
//EED SetSizer(sizer);
}
//================================================================
+ //================================================================
+ void WxGUIConsole::OnWxSignal()
+ {
+ if ((!Wx::TopWindowExists())&&(!IsShown()))
+ {
+ bbtkDebugMessage("wx",2," --> bbtk top window destroyed and WxGUIConsole not shown => destructing"<<std::endl);
+ Close();
+ }
+ }
+ //================================================================
//================================================================
void WxGUIConsole::WxGUICommandEnter(const std::string& command)
}
//================================================================
-
+ //================================================================
+ // Overloaded Show method to handle bbtk::Wx::TopWindow auto-destruction
+ bool WxGUIConsole::Show(bool show)
+ {
+ Wx::AutoDestroyTopWindow(!show);
+ wxFrame::Show(show);
+ }
+ //================================================================
+
//================================================================
BEGIN_EVENT_TABLE(WxGUIConsole, wxFrame)
EVT_MENU(ID_Menu_Quit, WxGUIConsole::OnMenuQuit)
Program: bbtk
Module: $RCSfile: bbtkWxGUIConsole.h,v $
Language: C++
- Date: $Date: 2008/04/18 12:59:16 $
- Version: $Revision: 1.3 $
+ Date: $Date: 2008/04/24 10:11:28 $
+ Version: $Revision: 1.4 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
// WxGUICommand callbacks
void WxGUICommandEnter(const std::string&);
+
+ // Overloaded Show method to handle bbtk::Wx::TopWindow auto-destruction
+ virtual bool Show(bool show = true);
+
+
private:
wxAuiManager m_mgr;
Interpreter::Pointer mInterpreter;
wxButton* mwxButtonRun;
public:
-
-
+
+ // Callback invoked by bbtk top window when something changes
+ void OnWxSignal();
DECLARE_EVENT_TABLE()
};
Program: bbtk
Module: $RCSfile: bbtkWxGUIPackageBrowser.cxx,v $
Language: C++
- Date: $Date: 2008/04/18 12:59:16 $
- Version: $Revision: 1.4 $
+ Date: $Date: 2008/04/24 10:11:28 $
+ Version: $Revision: 1.5 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
SetSizer(sizer);
- // Creates and sets the parent window of all bbtk windows
- wxWindow* top = new wxPanel(this,-1);
- top->Hide();
-
- Wx::SetTopWindow(top);
-
+
+ // Creates the parent window of all bbtk windows as a child of this
+ Wx::CreateTopWindow(this);
+ // bbtkAddWxObserver(WxGUIConsole::OnWxSignal);
+
+
SetAutoLayout(true);
Layout();
}
Program: bbtk
Module: $RCSfile: bbtkWxGUIPackageBrowser2.cxx,v $
Language: C++
-Date: $Date: 2008/04/23 09:31:23 $
-Version: $Revision: 1.6 $
+Date: $Date: 2008/04/24 10:11:28 $
+Version: $Revision: 1.7 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
SetSizer(sizer);
- // Creates and sets the parent window of all bbtk windows
- wxWindow* top = new wxPanel(this,-1);
- top->Hide();
-
- Wx::SetTopWindow(top);
-
+ // Creates the parent window of all bbtk windows as a child of this
+ Wx::CreateTopWindow(this);
+ // Add the method OnWxSignal as a Wx::Signal observer
+ //bbtkAddWxSignalObserver(WxGUIPackageBrowser2Window::OnWxSignal);
+
SetAutoLayout(true);
Layout();
}
Program: bbtk
Module: $RCSfile: bbtkWxGUIScriptingInterface.cxx,v $
Language: C++
- Date: $Date: 2008/04/22 14:30:25 $
- Version: $Revision: 1.6 $
+ Date: $Date: 2008/04/24 10:11:28 $
+ Version: $Revision: 1.7 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
mWxGUICommand->SetFocus();
- // Creates and sets the parent window of all bbtk windows
- wxWindow* top = new wxPanel(this,-1);//,_T("top"));
- top->Hide();
- Wx::SetTopWindow(top);
//
// m_mgr.AddPane(mwxButtonRun,
// wxAuiPaneInfo().Name(wxT("button_run_content")));
+ // Creates the parent window of all bbtk windows as a child of this
+ Wx::CreateTopWindow(this);
+ // Add the method OnWxSignal as a Wx::Signal observer
+ //bbtkAddWxSignalObserver(WxGUIPackageBrowser2Window::OnWxSignal);
//.PaneBorder(false));
m_mgr.Update();
Program: bbtk
Module: $RCSfile: bbtkWxGUITextEditor.cxx,v $
Language: C++
- Date: $Date: 2008/04/22 14:30:25 $
- Version: $Revision: 1.9 $
+ Date: $Date: 2008/04/24 10:11:28 $
+ Version: $Revision: 1.10 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
SetSizer(sizer);
- // Creates and sets the parent window of all bbtk windows
- wxWindow* top = new wxPanel(this,-1);
- top->Hide();
+ // Creates the parent window of all bbtk windows as a child of this
+ Wx::CreateTopWindow(this);
+ // Add the method OnWxSignal as a Wx::Signal observer
+ //bbtkAddWxSignalObserver(WxGUITextEditorWindow::OnWxSignal);
- Wx::SetTopWindow(top);
SetAutoLayout(true);
Layout();