# The BlackBox Interpreter
SUBDIRS(bbi)
+SUBDIRS(bbI)
# Black box code generator from xml
SUBDIRS(bbfy)
echo "> cd ${BIN}/../@BBTK_BBDOC_REL_PATH@"
cd ${BIN}/../@BBTK_BBDOC_REL_PATH@
-echo "> ${BIN}/bbi ./make-index"
-${BIN}/bbi ./make-index
+echo "> ${BIN}/bbi -N -q ./make-index"
+${BIN}/bbi -N -q ./make-index
echo "** Done ! **"
Program: bbtk
Module: $RCSfile: bbtkBlackBox.cxx,v $
Language: C++
-Date: $Date: 2008/07/23 11:46:10 $
-Version: $Revision: 1.22 $
+Date: $Date: 2008/07/24 14:37:05 $
+Version: $Revision: 1.23 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See doc/license.txt or
"=> BlackBox::bbExecute() ["
<<bbGetFullName()<<"]"<<std::endl);
- wxBusyCursor wait;
- //EED Wx::BeginBusyCursor();
+ Wx::BusyCursor wait;
// If execution frozen : return
if (bbGlobalGetFreezeExecution())
// Calls the main recursive update method
bbBackwardUpdate(Connection::Pointer());
- //EED Wx::EndBusyCursor();
-
bbtkDebugMessageDec("process",2,
"<= BlackBox::bbExecute() ["
<<bbGetFullName()<<"]"<<std::endl);
Program: bbtk
Module: $RCSfile: bbtkComplexBlackBox.cxx,v $
Language: C++
-Date: $Date: 2008/04/24 11:49:59 $
-Version: $Revision: 1.19 $
+Date: $Date: 2008/07/24 14:37:05 $
+Version: $Revision: 1.20 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
* \brief class bbtk::ComplexBlackBox : user defined complex black boxes
*/
#include "bbtkComplexBlackBox.h"
+#include "bbtkWx.h"
#include "bbtkBlackBoxDescriptor.h"
#include "bbtkFactory.h"
#include "bbtkConfigurationFile.h"
<<bbGetFullName()<<"]"<<std::endl);
- Wx::BeginBusyCursor();
+ Wx::BusyCursor wait;
if (mExecutionList.size() != 0)
{
}
}
- Wx::EndBusyCursor();
-
-
}
//==================================================================
//===========================================================
#ifdef BBTK_COMPILE_ERROR_MESSAGES
-#include "bbtkWx.h"
+//#include "bbtkWx.h"
#define bbtkError(MESSAGE) \
do \
{ \
- bbtk::Wx::ResetCursor(); \
std::ostringstream s; \
s << MESSAGE; \
std::ostringstream f; \
#include "bbtkObject.h"
#include "bbtkMessageManager.h"
+#include "bbtkPackage.h"
namespace bbtk
{
//=======================================================================
Object::ObjectListType Object::mgObjectList;
+ Object::ObjectListType Object::mgPackageList;
//=======================================================================
//=======================================================================
}
//=======================================================================
+ //=======================================================================
+ void Object::InsertInPackageList(Pointer p)
+ {
+ bbtkDebugMessage("object",9,"##> Object::InsertInPackageList(\""
+ <<p->GetObjectName()<<"\" ["<<p<<"])"<<std::endl);
+ boost::weak_ptr<Object> w(p);
+ mgPackageList.insert(w);
+ }
+ //=======================================================================
+
//=======================================================================
void Object::RemoveFromObjectList(WeakPointer p)
+ void Object::ReleasePackages()
+ {
+ bbtkDebugMessage("object",1,"##> Object::ReleasePackages()"<<std::endl);
+ // Release package pointers
+ ObjectListType::iterator i;
+ for (i = mgPackageList.begin();
+ i!= mgPackageList.end();
+ ++i)
+ {
+ if (i->use_count() != 0)
+ {
+ // Object::Pointer p(i->lock());
+ Package::WeakPointer w(i->lock()->GetThisPointer<Package>());
+ Package::Release(w);
+ /*
+ if (p->GetObjectName().find(name) != std::string::npos )
+ {
+ std::cout << n << "/" << mgObjectList.size() << " ";
+ PrintObjectInfo(p);
+ m += p->GetObjectSize();
+ n++;
+ }
+ */
+ }
+ }
-
+ }
+
//=======================================================================
StaticInitTime::~StaticInitTime()
{
+ Object::ReleasePackages();
+
if (PrintObjectListInfo)
{
std::cout << std::endl
Program: bbtk
Module: $RCSfile: bbtkObject.h,v $
Language: C++
- Date: $Date: 2008/07/23 11:46:11 $
- Version: $Revision: 1.5 $
+ Date: $Date: 2008/07/24 14:37:05 $
+ 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
static void InsertInObjectList(Pointer);
static void RemoveFromObjectList(WeakPointer);
+ static void InsertInPackageList(Pointer);
+ static void ReleasePackages();
+
static void PrintObjectListInfo(const std::string& name);
// static void PrintObjectInfo(const std::string& name);
static void PrintObjectInfo(const Pointer& o);
private:
typedef std::set<boost::weak_ptr<Object> > ObjectListType;
static ObjectListType mgObjectList;
+ static ObjectListType mgPackageList;
WeakPointer mThisPointer;
Pointer mThisPointerLocked;
static bool PrintObjectListInfo;
private:
- static bbtk::Object mObject;
+ static bbtk::Object mObject;
};
Program: bbtk
Module: $RCSfile: bbtkPackage.h,v $
Language: C++
- Date: $Date: 2008/05/21 12:50:11 $
- Version: $Revision: 1.9 $
+ Date: $Date: 2008/07/24 14:37:05 $
+ 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
VERSION, \
BBTK_STRINGIFY_SYMBOL(BBTK_VERSION) \
); \
+ bbtk::Object::InsertInPackageList( NAME ## GetPackagePointer() ); \
return NAME ## GetPackagePointer(); \
} \
BBTK_PACKAGE_EXPORT const std::string& \
Program: bbtk
Module: $RCSfile: bbtkSystem.h,v $
Language: C++
- Date: $Date: 2008/04/23 08:34:06 $
- Version: $Revision: 1.4 $
+ Date: $Date: 2008/07/24 14:37:05 $
+ 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
// ----------------------------------------------------------------------------
// wx headers
// ----------------------------------------------------------------------------
-#include "bbtkWx.h"
+//#include "bbtkWx.h"
/*
#ifdef _USE_WXWIDGETS_
#include "bbtkWx.h"
#include "bbtkMessageManager.h"
-#include <boost/signal.hpp>
-//#include <boost/bind.hpp>
namespace bbtk
{
+ //=========================================================================
+ class WxApp;
+ //=========================================================================
+ //=========================================================================
+ static WxApp* mgWxApp = 0;
static wxWindow* mgTopWindow = 0;
+ static wxWindow* mgTopWindowParent = 0;
+ static bool mgAutoDestroyTopWindow = true;
static int mgNbWindowsAlive = 0;
static int mgNbWindowsShown = 0;
- static bool mgAutoDestroyTopWindow = true;
+ //=========================================================================
+ //=========================================================================
// BBTKWXSIG
static Wx::Signal_type mgWxSignal;
// \BBTKWXSIG
+ //=========================================================================
+
+ //=========================================================================
+ // The wxApp class which is used when no user wxApp was created
+ class WxApp : public wxApp
+ {
+ public:
+ bool OnInit( );
+ int OnExit() { return true; }
+ };
+ //=========================================================================
+ IMPLEMENT_APP_NO_MAIN(WxApp);
+ //=========================================================================
+ bool WxApp::OnInit( )
+ {
+ wxApp::OnInit();
+#ifdef __WXGTK__
+ //See http://www.wxwindows.org/faqgtk.htm#locale
+ setlocale(LC_NUMERIC, "C");
+#endif
+ return true;
+ }
+ //=========================================================================
+
+ //=========================================================================
+ void Wx::CreateWxAppIfNeeded()
+ {
+ if (wxApp::GetInstance()==0)
+ {
+ if (mgWxApp != 0)
+ {
+ bbtkGlobalError("Wx::CreateWxAppIfNeeded() : INTERNAL ERROR ! (wxApp::GetInstance()==0) && (mgWxApp != 0)");
+ }
+ bbtkDebugMessage("wx",1," --> Creating bbtk wxApp"<<std::endl);
+ mgWxApp = new WxApp;
+ wxApp::SetInstance(mgWxApp);
+ wxInitialize();
+ }
+ }
+ //=========================================================================
//=========================================================================
- void Wx::CreateTopWindow(wxWindow* parent, bool autodestroy)
+ void Wx::DestroyWxAppIfNeeded()
{
+ if (mgWxApp!= 0)
+ {
+ bbtkDebugMessage("wx",1," --> Destructing bbtk WxApp"<<std::endl);
+ //delete mgWxApp;
+ // mgWxApp = 0;
+ // Uninit wx
+ // wxUninitialize();
+ }
+ }
+ //=========================================================================
+
+ //=========================================================================
+ void Wx::SetTopWindowParent(wxWindow* w)
+ {
+ if (mgTopWindowParent != 0)
+ {
+ bbtkGlobalError("Wx::SetTopWindowParent : top window parent != 0");
+ }
+ mgTopWindowParent = w;
+ }
+ //=========================================================================
+
+ //=========================================================================
+ void Wx::CreateTopWindowIfNeeded()
+ {
+ if (mgTopWindow!=0) return;
+ bbtkDebugMessage("wx",1," --> Creating bbtk top window"<<std::endl);
+
+ CreateWxAppIfNeeded();
+
wxWindow* top =
- new wxFrame(parent,
+ new wxFrame(mgTopWindowParent,
-1,
_T("TOP BBTK FRAME (YOU SHOULD NOT SEE ME !!)"));
top->Hide();
+
Wx::SetTopWindow(top);
- mgAutoDestroyTopWindow = autodestroy;
}
//=========================================================================
-
+
+ //=========================================================================
+ void Wx::DestroyTopWindowIfNeeded()
+ {
+ if ( (mgNbWindowsAlive==0) &&
+ (mgAutoDestroyTopWindow) )
+ {
+ bbtkDebugMessage("wx",1," --> Destructing bbtk top window"<<std::endl);
+ mgTopWindow->Close();
+ mgTopWindow = 0;
+
+ DestroyWxAppIfNeeded();
+ }
+ }
+ //=========================================================================
+
+ //=========================================================================
+ void Wx::LoopUntilAllWindowsClose()
+ {
+ int i = 0;
+ while (mgTopWindow != 0)
+ {
+ if (i % 100 == 0)
+ {
+ bbtkDebugMessage("wx",2,"Wx::Loop "<<i << std::endl);
+ }
+ i++;
+ wxMilliSleep(10);
+
+ }
+ }
+ //=========================================================================
+
//=========================================================================
wxWindow* Wx::GetTopWindow()
{
- if (mgTopWindow==0) Wx::CreateTopWindow(0);
+ Wx::CreateTopWindowIfNeeded();
return mgTopWindow;
}
//=========================================================================
// \BBTKWXSIG
//=========================================================================
- void Wx::AutoDestroyTopWindow(bool b)
+ void Wx::SetAutoDestroyTopWindow(bool b)
{
mgAutoDestroyTopWindow = b;
}
mgNbWindowsAlive--;
bbtkDebugMessage("wx",2,"* Number of windows alive = "<<mgNbWindowsAlive
<<std::endl);
- if ( (mgNbWindowsAlive==0) &&
- (mgAutoDestroyTopWindow) )
- {
- bbtkDebugMessage("wx",2," --> Destructing top window"<<std::endl);
- mgTopWindow->Close();
- mgTopWindow = 0;
- }
- // BBTKWXSIG
+
+ DestroyTopWindowIfNeeded();
+ // BBTKWXSIG
mgWxSignal();
// \BBTKWXSIG
}
mgNbWindowsShown--;
bbtkDebugMessage("wx",2,"* Number of windows shown = "<<mgNbWindowsShown
<<std::endl);
- if ( (mgNbWindowsAlive==0) &&
- (mgAutoDestroyTopWindow) )
- {
- bbtkDebugMessage("wx",2," --> Destructing top window"<<std::endl);
- mgTopWindow->Close();
- mgTopWindow = 0;
- }
+
+ DestroyTopWindowIfNeeded();
+
// BBTKWXSIG
mgWxSignal();
// \BBTKWXSIG
}
//=========================================================================
+
+ //=========================================================================
+ Wx::BusyCursor::BusyCursor()
+ {
+ if (TopWindowExists())
+ {
+ bbtkDebugMessage("wx",2,
+ "Wx::BusyCursor::BusyCursor()"<<std::endl);
+ ::wxBeginBusyCursor();
+ }
+ }
+ Wx::BusyCursor::~BusyCursor()
+ {
+ if (TopWindowExists())
+ {
+ bbtkDebugMessage("wx",2,
+ "Wx::BusyCursor::~BusyCursor()"<<std::endl);
+ ::wxEndBusyCursor();
+ }
+ }
+ //=========================================================================
+
+ /*
//=========================================================================
void Wx::ResetCursor()
{
::wxEndBusyCursor();
}
//=========================================================================
-
+ */
}
#ifndef __bbtkWx_h_INCLUDED__
#define __bbtkWx_h_INCLUDED__
-
-/*
-#ifdef wxUSE_STD_IOSTREAM
-#undef wxUSE_STD_IOSTREAM
-#endif
-#define wxUSE_STD_IOSTREAM 0
-*/
-
+//===========================================================================
// Wx headers
#ifdef _USE_WXWIDGETS_
// For compilers that support precompilation, includes "wx/wx.h".
#endif //__WXGTK__
// EO Wx headers
+#else //_USE_WXWIDGETS_
+
+// define wxWindow
+typedef void wxWindow;
+
+#endif // EO _USE_WXWIDGETS_
+//===========================================================================
+
+//===========================================================================
#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...)
typedef Signal_type::slot_function_type Slot_function_type;
// \BBTKWXSIG
+ /*
static void ResetCursor();
static void BeginBusyCursor();
static void EndBusyCursor();
+ */
+
+ static void LoopUntilAllWindowsClose();
+
+ class BusyCursor
+ {
+ public:
+ BusyCursor();
+ ~BusyCursor();
+ };
+
+ static void SetTopWindowParent(wxWindow*);
+ static void SetAutoDestroyTopWindow(bool);
- 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();
static bool TopWindowExists();
-
- static void AutoDestroyTopWindow(bool);
static void IncNbWindowsAlive();
static void DecNbWindowsAlive();
// BBTKWXSIG
static void AddSignalObserver(Slot_function_type);
// \BBTKWXSIG
+
private:
+
+ static void CreateWxAppIfNeeded();
+ static void DestroyWxAppIfNeeded();
+
+ static void CreateTopWindowIfNeeded();
+ static void DestroyTopWindowIfNeeded();
+
/// Sets the creation time parent of all bbtk windows
static void SetTopWindow(wxWindow*);
}; // struct Wx
+
+#ifdef _USE_WXWIDGETS_
//==================================================================
/// Conversion std::string to wxString
inline wxString std2wx(const std::string& s){
return s2;
}
//==================================================================
-
+#endif // EO _USE_WXWIDGETS
} // namespace bbtk
-
-#else // _USE_WXWIDGETS
-
-
-namespace bbtk
-{
-
- struct BBTK_EXPORT Wx
- {
- static void ResetCursor() {}
- static void BeginBusyCursor() {}
- static void EndBusyCursor() {}
- static void CreateInvisibleTopWindow() {}
- static wxWindow* GetTopWindow() { return 0; }
- static void SetTopWindow(wxWindow*) {}
- static void IncNbWindowsAlive() {}
- static void DecNbWindowsAlive() {}
- static int GetNbWindowsAlive() { return 0; }
- static bool IsSomeWindowAlive() { return false; }
-
- static void IncNbWindowsShown() {}
- static void DecNbWindowsShown() {}
- static int GetNbWindowsShown() { return 0; }
- static bool IsSomeWindowShown() { return false; }
- }; // struct Wx
-
-} // namespace bbtk
-
-
-
-#endif // EO _USE_WXWIDGETS
#endif // EO __bbtkWx_h_INCLUDED__
Program: bbtk
Module: $RCSfile: bbtkWxBlackBox.cxx,v $
Language: C++
- Date: $Date: 2008/07/23 11:46:11 $
- Version: $Revision: 1.24 $
+ Date: $Date: 2008/07/24 14:37:06 $
+ Version: $Revision: 1.25 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
<<bbGetBlackBox()->bbGetFullName()<<"]"<<std::endl);
WxBlackBoxWindow::bbShow();
SetReturnCode( wxDialog::ShowModal() );
- bbHide();
+ bbClose();
}
//=========================================================================
//=========================================================================
void WxBlackBoxDialog::bbClose()
{
- wxDialog::Close();
+ bbtkDebugMessage("wx",9,"WxBlackBoxDialog::bbClose()"<<std::endl);
+ wxDialog::Destroy();
}
//=========================================================================
//=========================================================================
void WxBlackBoxFrame::bbClose()
{
+ bbtkDebugMessage("wx",9,"WxBlackBoxFrame::bbClose()"<<std::endl);
wxFrame::Close();
}
//=========================================================================
Program: bbtk
Module: $RCSfile: bbtkWxBlackBox.h,v $
Language: C++
- Date: $Date: 2008/05/15 08:02:36 $
- Version: $Revision: 1.16 $
+ Date: $Date: 2008/07/24 14:37:06 $
+ 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
BBTK_DECLARE_OUTPUT(Widget, wxWindow*);//WxBlackBoxWidget*);
public:
+ /// Main processing method of the box. Overloaded to handle windows inclusion : if the output Widget is connected then the execution is transfered to the box to which it is connected (as the container window must be created and displayed - this box will be executed by the normal pipeline recursion mechanism)
+ virtual void bbExecute(bool force = false);
+
+
typedef WxBlackBoxWindow Window;
/// Returns the **OWN** window associated to the box
void bbInitAttributes();
protected :
- /// Main processing method of the box. Overloaded to handle windows inclusion : if the output Widget is connected then the execution is transfered to the box to which it is connected (the container window must be created and displayed - this box will be also executed by the normal pipeline recursion mechanism)
- virtual void bbExecute(bool force = false);
+ /// For Forward update mechanism when execution is called
+ /// on a contained window
/// Is set to true before transfering update to parent
/// in order to not re-transfer a second time...
bool bbmUpdateTransferedToParent;
Program: bbtk
Module: $RCSfile: bbtkWxGUIConsole.cxx,v $
Language: C++
- Date: $Date: 2008/06/19 09:46:41 $
- Version: $Revision: 1.13 $
+ Date: $Date: 2008/07/24 14:37:06 $
+ 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
cmdsizer->Add (mWxGUICommand, 0, wxALL | wxGROW, 5);
- // Creates the parent window of all bbtk windows as a child of this
- Wx::CreateTopWindow(this,true);
+ // Set the parent window of all bbtk windows as a child of this
+ bbtk::Wx::SetTopWindowParent(this);
+ // Top Window Auto Destroys when no more black box window alive
+ // : this is the default
+ // bbtk::Wx::SetAutoDestroyTopWindow(true);
// Add the method OnWxSignal as a Wx::Signal observer
bbtkAddWxSignalObserver(WxGUIConsole::OnWxSignal);
// Overloaded Show method to handle bbtk::Wx::TopWindow auto-destruction
bool WxGUIConsole::Show(bool show)
{
- Wx::AutoDestroyTopWindow(!show);
+ bbtk::Wx::SetAutoDestroyTopWindow(!show);
return wxFrame::Show(show);
}
//================================================================
Program: bbtk
Module: $RCSfile: bbtkWxGUIScriptingInterface.cxx,v $
Language: C++
- Date: $Date: 2008/07/23 11:46:11 $
- Version: $Revision: 1.14 $
+ Date: $Date: 2008/07/24 14:37:06 $
+ Version: $Revision: 1.15 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
// 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);
+ // parent window of all bbtk windows will be a child of this
+ Wx::SetTopWindowParent(this);
// Add the method OnWxSignal as a Wx::Signal observer
//bbtkAddWxSignalObserver(WxGUIPackageBrowser2Window::OnWxSignal);
Program: bbtk
Module: $RCSfile: bbtkWxGUITextEditor.cxx,v $
Language: C++
- Date: $Date: 2008/07/23 11:46:11 $
- Version: $Revision: 1.14 $
+ Date: $Date: 2008/07/24 14:37:06 $
+ Version: $Revision: 1.15 $
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 the parent window of all bbtk windows as a child of this
- Wx::CreateTopWindow(this);
+ // parent window of all bbtk windows will be a child of this
+ Wx::SetTopWindowParent(this);
// Add the method OnWxSignal as a Wx::Signal observer
//bbtkAddWxSignalObserver(WxGUITextEditorWindow::OnWxSignal);
{
ccommand=bbGetInputIn().substr(pos1,pos2-pos1);
}
- for (int i=0 ; i < ccommand.length() ; i++)
+ for (unsigned int i=0 ; i < ccommand.length() ; i++)
{
if (ccommand[i]==39)
{
Program: bbtk
Module: $RCSfile: bbwxDirectorySelector.cxx,v $
Language: C++
- Date: $Date: 2008/04/18 12:59:52 $
- Version: $Revision: 1.4 $
+ Date: $Date: 2008/07/24 14:37:06 $
+ 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
#include "bbwxDirectorySelector.h"
+#include "bbtkWx.h"
#include "bbwxPackage.h"
#include <wx/dirdlg.h>
Program: bbtk
Module: $RCSfile: bbwxFileSelector.cxx,v $
Language: C++
- Date: $Date: 2008/06/26 07:37:11 $
- Version: $Revision: 1.3 $
+ Date: $Date: 2008/07/24 14:37:06 $
+ 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
#include "bbwxFileSelector.h"
#include "bbwxPackage.h"
+#include "bbtkWx.h"
#include <wx/filedlg.h>