]> Creatis software - bbtk.git/commitdiff
Global factory in course of removal... does not compile but have to commit to continu...
authorguigues <guigues>
Fri, 7 Mar 2008 08:40:14 +0000 (08:40 +0000)
committerguigues <guigues>
Fri, 7 Mar 2008 08:40:14 +0000 (08:40 +0000)
15 files changed:
kernel/src/bbtkBlackBox.cxx
kernel/src/bbtkBlackBoxDescriptor.h
kernel/src/bbtkExecuter.cxx
kernel/src/bbtkExecuter.h
kernel/src/bbtkFactory.cxx
kernel/src/bbtkFactory.h
kernel/src/bbtkInterpreter.cxx
kernel/src/bbtkInterpreter.h
kernel/src/bbtkPackage.cxx
kernel/src/bbtkPackage.h
kernel/src/bbtkVirtualExec.h
kernel/src/bbtkWxConsole.cxx
kernel/src/bbtkWxConsole.h
packages/wxvtk/bbs/appli/ExampleBasicImageApplication.bbs [new file with mode: 0644]
packages/wxvtk/bbs/boxes/bbBasicImageApplication.bbs [new file with mode: 0644]

index 7955ccfc4ab4a0b1b77f13ae4246c6675c870d3c..94610b0645b0cde78dedb497d4466e5d10522ff3 100644 (file)
@@ -3,8 +3,8 @@
 Program:   bbtk
 Module:    $RCSfile: bbtkBlackBox.cxx,v $
 Language:  C++
-Date:      $Date: 2008/02/20 16:05:38 $
-Version:   $Revision: 1.5 $
+Date:      $Date: 2008/03/07 08:40:14 $
+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
@@ -649,28 +649,40 @@ namespace bbtk
     // Looks for the adaptor
     if (bbGetOutputType(output).name() != typeid(std::string).name() ) 
       {
-       BlackBox* a = 0;
-       try
+       // Look for factory 
+       Package* p = bbGetDescriptor()->GetPackage();
+       if ((p != 0) && ( ! p->GetFactorySet().empty() ) )
          {
-           a = NewAdaptor(  
-                          bbGetOutputType(output),
-                          typeid(std::string),
-                          "");
-         } catch (bbtk::Exception e) 
+           Factory* f = *p->GetFactorySet().begin();
+           BlackBox* a = 0;
+           try
+             {
+               a = f->NewAdaptor(  
+                                 bbGetOutputType(output),
+                                 typeid(std::string),
+                                 "");
+             } catch (bbtk::Exception e) 
+             {
+             }
+           if (a!=NULL){
+             //                        bbUpdate();
+             a->bbSetInput("In",bbGetOutput(output));
+             a->bbExecute();
+             v = a->bbGetOutput("Out").unsafe_get<std::string>() ;
+           } else {
+             v="? (no adaptor found)";
+           }
+         }
+       else 
          {
+           v="? (no factory found)";
          }
-       if (a!=NULL){
-         //                    bbUpdate();
-         a->bbSetInput("In",bbGetOutput(output));
-         a->bbExecute();
-         v = a->bbGetOutput("Out").unsafe_get<std::string>() ;
-       } else {
-         v="? (no adaptor found)";
-       }
-      } else {
-      //         bbUpdate();
-      v = bbGetOutput(output).unsafe_get<std::string>() ;
-    }
+      } 
+    else 
+      {
+       //         bbUpdate();
+       v = bbGetOutput(output).unsafe_get<std::string>() ;
+      }
     return v;
   }
   //=========================================================================
@@ -682,28 +694,38 @@ namespace bbtk
     // Looks for the adaptor
     if (bbGetInputType(input) != typeid(std::string)) 
       {
-       BlackBox* a = 0;
-       try
+       // Look for factory 
+       Package* p = bbGetDescriptor()->GetPackage();
+       if ((p != 0) && ( ! p->GetFactorySet().empty() ) )
          {
-           a = NewAdaptor(  
-                          bbGetInputType(input),
-                          typeid(std::string),
-                          "");
-         }catch (bbtk::Exception e) 
-         {
-         }
-       if (a!=NULL)
-         {
-           //                  bbUpdate();
-           a->bbSetInput("In",bbGetInput(input));
-           a->bbExecute();
-           v = a->bbGetOutput("Out").unsafe_get<std::string>() ;
+           Factory* f = *p->GetFactorySet().begin();
+           BlackBox* a = 0;
+           try
+             {
+               a = f->NewAdaptor(  
+                              bbGetInputType(input),
+                              typeid(std::string),
+                              "");
+             }catch (bbtk::Exception e) 
+             {
+             }
+           if (a!=NULL)
+             {
+               //                      bbUpdate();
+               a->bbSetInput("In",bbGetInput(input));
+               a->bbExecute();
+               v = a->bbGetOutput("Out").unsafe_get<std::string>() ;
+             } 
+           else 
+             {
+               v="? (no adaptor found)";
+             }
          } 
        else 
          {
-           v="? (no adaptor found)";
+           v="? (no factory found)";
          }
-      } 
+      }
     else 
       {
        v = bbGetInput(input).unsafe_get<std::string>() ;
index 1d0ee5d66510d69b0126d079932cddbb805aeb82..6443d50ac93469b756cf5541393c54bf65de6c49 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkBlackBoxDescriptor.h,v $
   Language:  C++
-  Date:      $Date: 2008/02/06 14:14:22 $
-  Version:   $Revision: 1.5 $
+  Date:      $Date: 2008/03/07 08:40:14 $
+  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
@@ -83,7 +83,7 @@ namespace bbtk
     /// Returns the Package to which the box belongs
     Package* GetPackage() { return mPackage; }
     
-    /// Returns the Package to which the box belongs
+    /// Returns the Package to which the box belongs (const pointer)
     const Package* GetPackage() const { return mPackage; }
     
     /// Returns the kind of box 
index 7d24b70fa357ac6f29a5847e0ef11ebef1bd38c9..241573ade7462e73776fdfb48f29080613897eff 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkExecuter.cxx,v $ $
   Language:  C++
-  Date:      $Date: 2008/02/14 20:57:27 $
-  Version:   $Revision: 1.12 $
+  Date:      $Date: 2008/03/07 08:40:14 $
+  Version:   $Revision: 1.13 $
 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -40,14 +40,16 @@ namespace bbtk
  *
  */
   Executer::Executer()
-    : mPackage(0),
-      mRoot(0),
-      mNoExecMode(false),
-      mDialogMode(NoDialog)
+    : 
+    mFactory(0),
+    mRootPackage(0),
+    mRootCBB(0),
+    mNoExecMode(false),
+    mDialogMode(NoDialog)
   {
-    //VirtualExec();
-    
     bbtkDebugMessageInc("Kernel",9,"Executer::Executer()" <<std::endl);
+    mFactory = new Factory;
+    mFactory->SetExecuter(this);
     Reset();
     bbtkDebugDecTab("Kernel",9);
   }
@@ -57,17 +59,19 @@ namespace bbtk
  */
   Executer::~Executer()
   {
-std::cout << "====================================================== delete Executer\n";  
+    //std::cout << "===================================== delete Executer\n";  
      bbtkDebugMessageInc("Kernel",9,"Executer::~Executer()" <<std::endl);
-     if (mRoot) 
+     if (mRootCBB
      {
-        mPackage->UnRegisterBlackBox("workspace");
-        delete mRoot;
+        mRootPackage->UnRegisterBlackBox("workspace");
+        delete mRootCBB;
      }
-     if (mPackage)
+     if (mRootPackage)
      {
-        GetGlobalFactory()->UnLoadPackage("user");
+        GetFactory()->UnLoadPackage("user");
      }
+     delete mFactory;
+
      bbtkDebugDecTab("Kernel",9);
   }
 
@@ -85,38 +89,41 @@ std::cout << "====================================================== delete Exec
     // all user defined CBB otherwise any instance 
     // of a user CBB that is in the 'workspace' would try to 
     // access a user CBB descriptor which has been previously freed
-    if (mRoot)
+    if (mRootCBB)
     {
-       mPackage->UnRegisterBlackBox(mRoot->GetTypeName());
-       delete mRoot;
+       mRootPackage->UnRegisterBlackBox(mRootCBB->GetTypeName());
+       delete mRootCBB;
     }
-    if (mPackage)
+    if (mRootPackage)
     {
-       GetGlobalFactory()->UnLoadPackage("user");
+       GetFactory()->UnLoadPackage("user");
     }
-    GetGlobalFactory()->Reset();
+    GetFactory()->Reset();
+
     // Create user package
-    mPackage = new Package("user","internal to bbi",
+    mRootPackage = new Package("user","internal to bbi",
                            "User defined black boxes",
                            "",
                            BBTK_STRINGIFY_SYMBOL(BBTK_VERSION));
     // Create user workspace
-    mRoot = new ComplexBlackBoxDescriptor("workspace"); //,f);
-    mRoot->AddToAuthor("bbi (internal)");
-    mRoot->AddToDescription("User's workspace");
-    mOpenDefinition.push_back(CBBDefinition(mRoot,"user"));
+    mRootCBB = new ComplexBlackBoxDescriptor("workspace"); //,f);
+    mRootCBB->AddToAuthor("bbi (internal)");
+    mRootCBB->AddToDescription("User's workspace");
+    mOpenDefinition.push_back(CBBDefinition(mRootCBB,"user"));
     // Register it into the user package
-    mPackage->RegisterBlackBox(mRoot);
+    mRootPackage->RegisterBlackBox(mRootCBB);
     // Insert the user package in the factory
-    InsertPackage(mPackage);
-    mOpenPackage.push_back(mPackage);
+    GetFactory()->InsertPackage(mRootPackage);
+    // And in the list of open packages
+    mOpenPackage.push_back(mRootPackage);
+
     bbtkDebugDecTab("Kernel",9);
   }
 
   /// changes the workspace name
   void Executer::SetWorkspaceName( const std::string& n )
   {
-    mPackage->ChangeBlackBoxName( mRoot->GetTypeName(), n );
+    mRootPackage->ChangeBlackBoxName( mRootCBB->GetTypeName(), n );
   }
   
   void Executer::BeginPackage (const std::string &name)
@@ -126,7 +133,7 @@ std::cout << "====================================================== delete Exec
      Package* p;
      try 
       {
-         p = GetGlobalFactory()->GetPackage(name);
+         p = GetFactory()->GetPackage(name);
       }
     catch (Exception e)
       {
@@ -135,7 +142,7 @@ std::cout << "====================================================== delete Exec
                          "",
                          "",
                          BBTK_STRINGIFY_SYMBOL(BBTK_VERSION));
-         InsertPackage(p);
+         GetFactory()->InsertPackage(p);
       }
      mOpenPackage.push_back(p);
   }
@@ -176,30 +183,30 @@ std::cout << "====================================================== delete Exec
     Package* p;
     std::string pname(mOpenDefinition.back().package);
     if (pname.size()>0)
-    {
-      try
       {
-         p = GetGlobalFactory()->GetPackage(pname);
+       try
+         {
+           p = GetFactory()->GetPackage(pname);
+         }
+       catch (Exception e)
+         {
+           p = new Package(pname,
+                           "",
+                           "",
+                           "",
+                           BBTK_STRINGIFY_SYMBOL(BBTK_VERSION));
+           GetFactory()->InsertPackage(p);
+         }
       }
-      catch (Exception e)
+    else
       {
-            p = new Package(pname,
-                       "",
-                       "",
-                       "",
-                       BBTK_STRINGIFY_SYMBOL(BBTK_VERSION));
-           InsertPackage(p);
+       p = mOpenPackage.back();
       }
-    }
-    else
-    {
-       p = mOpenPackage.back();
-    }
     p->RegisterBlackBox(Current());
-
+    
     mOpenDefinition.pop_back();
   }
-
+  
 
   void Executer::Create ( const std::string& nodeType, 
                           const std::string& nodeName)
@@ -231,7 +238,7 @@ std::cout << "====================================================== delete Exec
   void Executer::Update (const std::string &nodeName) // would 'Execute' be more meaningfull ?
   {
  // if in root
-     if (Current()==mRoot) 
+     if (Current()==mRootCBB
      {
         if (!mNoExecMode) 
         {
@@ -253,7 +260,7 @@ std::cout << "====================================================== delete Exec
                                const std::string& help)
   {
     // If the input is defined in the Root box
-    if (Current()==mRoot) 
+    if (Current()==mRootCBB
       {
       // If the dialog mode is set to NoDialog
       // and the user passed the name in the Inputs map 
@@ -323,15 +330,15 @@ std::cout << "====================================================== delete Exec
     if ( b->bbGetInputType(input) !=  typeid(std::string) ) 
       {
          BlackBox* a =
-         NewAdaptor(typeid(std::string),
-                    b->bbGetInputType(input),
-                    "tmp");
+          GetFactory()->NewAdaptor(typeid(std::string),
+                                   b->bbGetInputType(input),
+                                   "tmp");
          if (!a) 
-         {
-            bbtkError("No <"<<
-                      TypeName(b->bbGetInputType(input))
-                      <<"> to <std::string> found");
-         }
+          {
+            bbtkError("No <"<<
+                      TypeName(b->bbGetInputType(input))
+                      <<"> to <std::string> found");
+          }
          std::string v(value);
          a->bbSetInput("In",v);
          a->bbExecute();
@@ -355,55 +362,55 @@ std::cout << "====================================================== delete Exec
     // Looks for the adaptor
     if (b->bbGetOutputType(output) != typeid(std::string)) 
       {
-      BlackBox* a =
-          NewAdaptor(
-             b->bbGetOutputType(output),
-             typeid(std::string),
-             "tmp");
-      if (!a) 
-        {
-        bbtkError("No <"<<
-                   TypeName(b->bbGetOutputType(output))
-                   <<"> to <std::string> found");
-        }
+       BlackBox* a =
+          GetFactory()->NewAdaptor(
+                                  b->bbGetOutputType(output),
+                                  typeid(std::string),
+                                  "tmp");
+       if (!a) 
+         {
+           bbtkError("No <"<<
+                     TypeName(b->bbGetOutputType(output))
+                     <<"> to <std::string> found");
+         }
         b->bbExecute();
-
+       
         a->bbSetInput("In",b->bbGetOutput(output));
         a->bbExecute();
         std::string r = a->bbGetOutput("Out").unsafe_get<std::string>();
-       //std::string v = *((std::string*)a->bbGetOutput("Out")) ;
-       //   std::cout << a->bbGetOutput("Out").unsafe_get<std::string>() 
-       //             << std::endl;
-       //std::string v(value);
-       //b->bbSetInput(input,a->bbGetOutput("Out"));
+       //std::string v = *((std::string*)a->bbGetOutput("Out")) ;
+       //   std::cout << a->bbGetOutput("Out").unsafe_get<std::string>() 
+       //             << std::endl;
+       //std::string v(value);
+       //b->bbSetInput(input,a->bbGetOutput("Out"));
         a->bbDelete();
         return r;
       }
     else
       {
-       b->bbExecute();
-       return b->bbGetOutput(output).unsafe_get<std::string>();
-       // std::string v = *((std::string*)b->bbGetOutput(output)) ;
-       // std::cout << b->bbGetOutput("Out").unsafe_get<std::string>() 
-       //   << std::endl;
-       // b->bbSetInput(input,&v);
+       b->bbExecute();
+       return b->bbGetOutput(output).unsafe_get<std::string>();
+       // std::string v = *((std::string*)b->bbGetOutput(output)) ;
+       // std::cout << b->bbGetOutput("Out").unsafe_get<std::string>() 
+       //   << std::endl;
+       // b->bbSetInput(input,&v);
       }
   }
 
 
   void Executer::Author(const std::string &authorName)
   {
-    Current()->AddToAuthor(authorName,Current()==mRoot);
+    Current()->AddToAuthor(authorName,Current()==mRootCBB);
   }
 
   void Executer::Category(const std::string &category)
   {
-    Current()->AddToCategory(category,Current()==mRoot);
+    Current()->AddToCategory(category,Current()==mRootCBB);
   }
 
   void Executer::Description(const std::string &d)
   {
-     Current()->AddToDescription(d,Current()==mRoot);
+    Current()->AddToDescription(d,Current()==mRootCBB);
   }
 
 
@@ -457,11 +464,11 @@ std::cout << "====================================================== delete Exec
     Package* p;
     try
     {
-       p = GetGlobalFactory()->GetPackage(nameblackbox);
+       p = GetFactory()->GetPackage(nameblackbox);
     }
     catch (Exception e)
     {
-       p = mPackage;
+       p = mRootPackage;
     }
     // Generating documentation-help of workspace
     p->SetDocURL(filename_rootHtml);
index ef109b365488bc5ad45441ad98d4384bfe64e184..b77a3c9eb6cd57e55380def5fab3ee95bba8013a 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkExecuter.h,v $ $
   Language:  C++
-  Date:      $Date: 2008/02/14 20:26:54 $
-  Version:   $Revision: 1.9 $
+  Date:      $Date: 2008/03/07 08:40:14 $
+  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
@@ -38,6 +38,9 @@
 namespace bbtk
 {
 
+  class Interpreter;
+
+
   class /*BBTK_EXPORT*/ Executer : public VirtualExec
   {
 
@@ -45,13 +48,16 @@ namespace bbtk
 
     /// Constructor
     Executer();
-
-    ///
-    //  void SetFactory(Factory* f);
-
     /// Destructor
     ~Executer();
     
+
+    /// Gets the factory used by the executer
+    Factory* GetFactory() { return mFactory; }
+    /// Gets the factory used by the executer (const)
+    const Factory* GetFactory() const { return mFactory; }
+
+
     /// Sets the inputs of the workspace : 
     void SetInputs(const std::map<std::string,std::string>& m) { mInputs = m; }
 
@@ -135,7 +141,7 @@ namespace bbtk
     /// prints the list off the boxes of the current box
     void PrintBoxes();
 
-   /// Generate a HTML with a gif file with the actual pipeline (Graphviz-dot needed). Returns the file path
+   /// Generate a HTML with a gif file with the current pipeline (Graphviz-dot needed). Returns the file path
     std::string ShowGraph(const std::string &nameblackbox, 
                          const std::string &detailStr, 
                          const std::string &levelStr,
@@ -144,7 +150,7 @@ namespace bbtk
                          const std::string &custom_title,
                          bool system_display = true);
 
-   /// Generate a HTML with a gif file with the actual pipeline (Graphviz-dot needed). Returns the file path
+   /// Generate a HTML with a gif file with the current pipeline (Graphviz-dot needed). Returns the file path
     std::string ShowGraphInstances(const std::string &nameblackbox, int detail, int level, bool system_display=true);
 
    /// Description of the actual pipeline
@@ -170,14 +176,19 @@ namespace bbtk
     // ATTRIBUTES
      
     /// The factory used
-    //   Factory* mFactory;
-
-    /// The Root Package
-    Package* mPackage;
+    Factory* mFactory;
     
-    /// The root ComplexBlackBox, in which operations are done when outside a define/endefine block
+    /// The Root Package 
+    /// Contains the root ComplexBlabkBox
+    /// In which ComplexBlackBoxes are put by default
+    /// Its name in bbi is 'user'
+    Package* mRootPackage;
+    
+    /// The root ComplexBlackBox
+    /// in which operations are done when outside a define/endefine block
     /// Its name in bbi is 'workspace'  
-    ComplexBlackBoxDescriptor* mRoot;
+    ComplexBlackBoxDescriptor* mRootCBB;
 
     /// Struct that stores info on user defined complex black boxes
     struct CBBDefinition
@@ -190,16 +201,13 @@ namespace bbtk
 
     /// The stack of current working ComplexBlackBox
     /// (is a stack for nested definitions)
-    /// only contains the root when outside a define/endefine block
+    /// only contains the root cbb when outside a define/endefine block
     std::deque<CBBDefinition> mOpenDefinition;
 
     /// The stack of current working package
     /// (is a stack for nested definitions)
     std::deque<Package*> mOpenPackage;
 
-    /// flag which is true when we are inside a Define/EndDefine block
-    //    bool mDefineFlag;
-    
     /// The input values of the Root ComplexBlackBox
     std::map<std::string,std::string> mInputs;
     
index 74d515ded67b1fb1106fe203631eac73c8eeba44..5e9c395b9ff66c5119043a2c7c6105a4e4427c08 100644 (file)
@@ -4,8 +4,8 @@ Program:   bbtk
 Module:    $RCSfile: bbtkFactory.cxx,v $
 Language:  C++
 
-Date:      $Date: 2008/03/04 08:09:04 $
-Version:   $Revision: 1.26 $
+Date:      $Date: 2008/03/07 08:40:14 $
+Version:   $Revision: 1.27 $
                                                                                 
 
 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
@@ -37,20 +37,6 @@ PURPOSE.  See the above copyright notices for more information.
 
 #include <cctype>    // std::toupper
 
-// was in gdcm ...
-/*
-#ifdef _MSC_VER
-#   define getcwd _getcwd
-#endif
-
-#if defined(_MSC_VER) || defined(__BORLANDC__)
-#   include <direct.h>
-#else
-#   include <unistd.h>
-#endif
-
-*/
-
 
 namespace bbtk
 {
@@ -61,6 +47,7 @@ namespace bbtk
   //===================================================================
   /// Default ctor
   Factory::Factory()
+    : mExecuter(0)
   {
     bbtkDebugMessage("Kernel",7,"Factory::Factory()"<<std::endl);
   }
@@ -202,8 +189,6 @@ namespace bbtk
     // Invokes the accessor to the PackageUnit pointer
     pack.mPackage = ((PackageAccessor)getpack)();
     
-    mPackageMap[pkgname] = pack;
-    
     // Test bbtk build version ok
     if ( pack.mPackage->GetBBTKVersion() != bbtk::GetVersion() )
       {
@@ -215,6 +200,9 @@ namespace bbtk
                  << " whereas application build with version "
                  << bbtk::GetVersion());
       }
+
+    pack.mPackage->AddFactory(this);
+    mPackageMap[pkgname] = pack;
     
     std::string separator =
       ConfigurationFile::GetInstance().Get_file_separator ();
@@ -444,71 +432,85 @@ namespace bbtk
 
   //===================================================================
   /// \brief Close the package referenced by the iterator 
-  ///
-  /// If it is a dynamically loaded package 
-  /// - Loads and calls the function "<name>DeletePackage" of the dynamic library (responsible for package desallocation)
-  /// - Closes the dynamic library
-  /// - Erases the package entry in the packages map
-  ///
-  /// Else simply erases the package entry in the packages map
-  void Factory::ClosePackage(PackageMapType::iterator& i) 
+ ///
+ /// First removes the factory from the set of factories which use the package
+ /// If the set is empty then :
+ /// If it is a dynamically loaded package :
+ /// - Loads and calls the function "<name>DeletePackage" of the dynamic library (responsible for package desallocation)
+ /// - Closes the dynamic library
+ /// Else :
+ /// - deletes the package normally
+ /// 
+ /// Finally erases the package entry in the packages map
+ void Factory::ClosePackage(PackageMapType::iterator& i) 
   {   
      bbtkDebugMessageInc("Kernel",7,"Factory::ClosePackage(\""
                          <<i->second.mPackage->GetName()
                         <<"\")"<<std::endl);
 
-     if (i->second.mDynamicLibraryHandler) 
-     {
-      // If it is a dynamically loaded package
-      // Loads the Package delete function
-
-        std::string delfname(i->second.mPackage->GetName());
-        delfname += "DeletePackage";
+     
+     // Removes this from the set of factories which use the package
+     i->second.mPackage->RemoveFactory(this);
+     
+     // If no more factory which use it 
+     if (i->second.mPackage->GetFactorySet().empty())
+       {
+        // If it is a dynamically loaded package       
+        if (i->second.mDynamicLibraryHandler) 
+          {
+            
+            
+            // Loads the Package delete function
+            
+            std::string delfname(i->second.mPackage->GetName());
+            delfname += "DeletePackage";
 #if defined(__GNUC__)     
-        void *delf = dlsym(i->second.mDynamicLibraryHandler, delfname.c_str());
-        if (!delf)
-        {
-           bbtkError("could not close package \""
-                     <<i->second.mPackage->GetName()
-                     <<"\" :"<<dlerror());
-        }    
+            void *delf = dlsym(i->second.mDynamicLibraryHandler, delfname.c_str());
+            if (!delf)
+              {
+                bbtkError("could not close package \""
+                          <<i->second.mPackage->GetName()
+                          <<"\" :"<<dlerror());
+              }    
 #elif defined(_WIN32)
-   void *delf = GetProcAddress(i->second.mDynamicLibraryHandler, 
-                                 delfname.c_str());
-     if (!delf)
-     {  
-       bbtkError("could not close package \""
-                <<i->second.mPackage->GetName()
-                <<"\" : "<<delfname
-                <<" symbol not found (how did you open it ???");
-               //<<"\" :"<<dlerror());
-     }    
+            void *delf = GetProcAddress(i->second.mDynamicLibraryHandler, 
+                                        delfname.c_str());
+            if (!delf)
+              {  
+                bbtkError("could not close package \""
+                          <<i->second.mPackage->GetName()
+                          <<"\" : "<<delfname
+                          <<" symbol not found (how did you open it ???");
+                //<<"\" :"<<dlerror());
+              }    
 #endif     
-
-   // deletes the package
-   ((PackageDeleteFunction)delf)();
-
-   // closes the dl handler
+            
+            // deletes the package
+            ((PackageDeleteFunction)delf)();
+            
+            // closes the dl handler
 #if defined(__GNUC__)  
-    dlclose(i->second.mDynamicLibraryHandler);  
+            dlclose(i->second.mDynamicLibraryHandler);  
 #elif defined(_WIN32)
-
-    FreeLibrary(i->second.mDynamicLibraryHandler);
+            
+            FreeLibrary(i->second.mDynamicLibraryHandler);
 #endif
-    }
-    else 
-    {  
-       // If it is a manually inserted package 
-       delete i->second.mPackage;
-    }
+          }
 
-    // remove the entry in the map
-    mPackageMap.erase(i);
-    bbtkDebugDecTab("Kernel",7);
- }
-  //===================================================================
+        else 
+          {  
+            // If it is a manually inserted package : delete it normally
+            delete i->second.mPackage;
+          }
+       }
+     
+     // in any cases remove the entry in the map
+     mPackageMap.erase(i);
 
+     bbtkDebugDecTab("Kernel",7);
+  }
+  //===================================================================
+  
 
 
   //===================================================================  
@@ -614,12 +616,12 @@ namespace bbtk
     bbtkDebugMessageInc("Kernel",9,"Factory::InsertPackage(\""<<
                         p->GetName()<<"\")"<<std::endl);
 
+    p->AddFactory(this);
     PackageInfoType pack;
     pack.mDynamicLibraryHandler = 0;
-    
     pack.mPackage = p;
-
     mPackageMap[p->GetName()] = pack;
+
     bbtkDebugDecTab("Kernel",9);
   }
   //===================================================================
@@ -639,12 +641,12 @@ namespace bbtk
     
     if (i!=mPackageMap.end())
       {
-      ClosePackage(i);
+       ClosePackage(i);
       }
     else 
       {
-      bbtkError("Factory::RemovePackage(\""<<
-                 p->GetName()<<"\") : package absent from factory");
+       bbtkError("Factory::RemovePackage(\""<<
+                 p->GetName()<<"\") : package absent from factory");
       }
 
     bbtkDebugDecTab("Kernel",9);
index 35c04e6e3e42e21f812502ccba739f8d27e325a2..75acb76c5908c1f144237f86431375c9e81429f6 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkFactory.h,v $
   Language:  C++
-  Date:      $Date: 2008/03/03 14:55:55 $
-  Version:   $Revision: 1.9 $
+  Date:      $Date: 2008/03/07 08:40:14 $
+  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
@@ -35,6 +35,9 @@
 
 namespace bbtk
 {
+
+  class Executer;
+
   class BBTK_EXPORT Factory
   {
 
@@ -42,7 +45,7 @@ namespace bbtk
 
     Factory();
     ~Factory();
-
+    
     void LoadPackage( const std::string& name );
     void UnLoadPackage( const std::string& name );
     void PrintPackages(bool details = true, bool adaptors = false) const;
@@ -82,6 +85,14 @@ namespace bbtk
       IndexEntryType;
     void CreateHtmlIndex(IndexEntryType type, const std::string& filename);
 
+    /// Sets the executer who created the factory (if any)
+    void SetExecuter(Executer *e) { mExecuter = e; }
+    /// Gets the executer who created the factory (if any)
+    Executer* GetExecuter() { return mExecuter; }
+    /// Gets the executer who created the factory (if any) - const
+    const Executer* GetExecuter() const { return mExecuter; }
+
+
   private:
 
     bool DoLoadPackage(std::string libname,
@@ -106,6 +117,9 @@ namespace bbtk
     /// The map of packages
     PackageMapType mPackageMap;
 
+    /// The executer which created the factory (if any)
+    Executer* mExecuter;
+
     void CloseAllPackages();
     void ClosePackage(PackageMapType::iterator& i);
 
@@ -113,6 +127,8 @@ namespace bbtk
   // class Factory
 
 
+
+  /*
   /// SYSTEM METHOD : Global method returning the global factory object pointer
   inline Factory*& GlobalFactoryPointer() 
   {
@@ -218,7 +234,7 @@ namespace bbtk
   {
     GetGlobalFactory()->WriteDotFilePackagesList(ff);
   }
-
+  */
 }// namespace bbtk
 
 
index 28dbfe43798c7b94b7c46668c8df21f3035bdc79..e9bf1e8c8cef24bb0af3c64b2162b637a33acb73 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkInterpreter.cxx,v $ $
   Language:  C++
-  Date:      $Date: 2008/03/03 14:55:55 $
-  Version:   $Revision: 1.39 $
+  Date:      $Date: 2008/03/07 08:40:14 $
+  Version:   $Revision: 1.40 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -37,7 +37,7 @@
 namespace bbtk
 {
 
-Interpreter* Interpreter::mGlobalInterpreter = NULL;
+  //Interpreter* Interpreter::mGlobalInterpreter = NULL;
 
  //=======================================================================
  /**
@@ -45,15 +45,17 @@ Interpreter* Interpreter::mGlobalInterpreter = NULL;
    */
   Interpreter::Interpreter() 
     :
+#ifdef _USE_WXWIDGETS_
+    mWxConsole(0),
+#endif
     mCommandLine(false)
   {
     bbtk::MessageManager::RegisterMessageType("Echo","Level>0 : Prints the 'echo' commands of the user.\n\tLevel>1 : Prints the command being interpreted",1);
     bbtk::MessageManager::RegisterMessageType("Interpreter","Messages of the interpreter",0);
     bbtkDebugMessageInc("Interpreter",9,"Interpreter::Interpreter()" <<std::endl);
  
-    mGlobalInterpreter = this;
-
     mExecuter = new bbtk::Executer();
+    mExecuter->SetInterpreter(this);
     
     // For the time being, comment out previous line, and
     // uncomment next line to check Transcriptor
@@ -291,7 +293,6 @@ Interpreter* Interpreter::mGlobalInterpreter = NULL;
 std::cout << "=========================================~Interpreter()" << std::endl;
     bbtkDebugMessageInc("Interpreter",9,"Interpreter::~Interpreter()" <<std::endl);
     delete mExecuter;
-    //delete mFactory;
 
     bbtkDebugDecTab("Interpreter",9);
   }
@@ -573,16 +574,16 @@ void Interpreter::InterpretLine( const std::string& line, bool &insideComment )
        // if 'source' was given
        if (words.size()==3) 
          {
-           this->mExecuter->SetCurrentFileName(words[1]);
+           GetExecuter()->SetCurrentFileName(words[1]);
          }
         break;
 
       case cLoad:
-        LoadPackage(words[1]);
+        GetExecuter()->GetFactory()->LoadPackage(words[1]);
         break;
 
       case cUnload:
-        UnLoadPackage(words[1]);
+        GetExecuter()->GetFactory()->UnLoadPackage(words[1]);
         break;
 
       case cQuit :
@@ -1093,7 +1094,7 @@ void Interpreter::Help(const std::vector<std::string>& words)
     {
       if (words[1]=="packages") 
       {
-         PrintPackages(true);
+         GetExecuter()->GetFactory()->PrintPackages(true);
          return;
       }
       try 
@@ -1104,16 +1105,16 @@ void Interpreter::Help(const std::vector<std::string>& words)
       {
          try 
          {
-            HelpPackage(words[1]);
+            GetExecuter()->GetFactory()->HelpPackage(words[1]);
 #ifdef _USE_WXWIDGETS_
-           if ( WxConsole::GetInstance() != 0 )
+           if ( mWxConsole != 0 )
              {
                std::string url = 
                  ConfigurationFile::GetInstance().Get_doc_path();
                url += "/bbdoc/" + words[1] + "/index.html";
                if (Utilities::FileExists(url)) 
                  {
-                   WxConsole::GetInstance()->ShowHtmlPage(url);
+                   mWxConsole->ShowHtmlPage(url);
                  }
              }
 #endif     
@@ -1123,9 +1124,9 @@ void Interpreter::Help(const std::vector<std::string>& words)
             try 
             {
              std::string package;
-             HelpBlackBox(words[1],package);
+             GetExecuter()->GetFactory()->HelpBlackBox(words[1],package);
 #ifdef _USE_WXWIDGETS_
-              if ( WxConsole::GetInstance() != 0 )
+              if ( mWxConsole != 0 )
                 {
                   std::string url = 
                     ConfigurationFile::GetInstance().Get_doc_path();
@@ -1133,7 +1134,7 @@ void Interpreter::Help(const std::vector<std::string>& words)
                   if (Utilities::FileExists(url))
                     {
                       url += "#" + words[1];
-                      WxConsole::GetInstance()->ShowHtmlPage(url);
+                      mWxConsole->ShowHtmlPage(url);
                     }
                 }
 #endif
@@ -1142,7 +1143,7 @@ void Interpreter::Help(const std::vector<std::string>& words)
              {
                try
                  {
-                   this->mExecuter->ShowRelations(words[1],"0","9999");
+                   GetExecuter()->ShowRelations(words[1],"0","9999");
                  }
                catch (bbtk::Exception h){
                  bbtkError("\""<<words[1].c_str()
@@ -1158,12 +1159,12 @@ void Interpreter::Help(const std::vector<std::string>& words)
       {
          if ( words[1]=="packages" )
          {
-            PrintPackages(true,true);
+            GetExecuter()->GetFactory()->PrintPackages(true,true);
             return;
           }
          try 
          {
-            HelpPackage(words[1],true);
+            GetExecuter()->GetFactory()->HelpPackage(words[1],true);
          }
          catch (bbtk::Exception f) 
          {
@@ -1531,7 +1532,7 @@ void Interpreter::Graph(const std::vector<std::string>& words)
     bool system_display = true;
 
 #ifdef _USE_WXWIDGETS_
-    if ( WxConsole::GetInstance() != 0 ) system_display = false; 
+    if ( mWxConsole != 0 ) system_display = false; 
 #endif
  
     if (words.size()==1) 
@@ -1564,8 +1565,8 @@ void Interpreter::Graph(const std::vector<std::string>& words)
       } 
     
 #ifdef _USE_WXWIDGETS_
-    if ( WxConsole::GetInstance() != 0 )
-      WxConsole::GetInstance()->ShowHtmlPage(page);
+    if ( mWxConsole != 0 )
+      mWxConsole->ShowHtmlPage(page);
 #endif
   }
 //=======================================================================
@@ -1581,7 +1582,7 @@ void  Interpreter::Index(const std::string& filename,
   else if (type=="Packages") t = Factory::Packages;
   else if (type=="Adaptors") t = Factory::Adaptors;
   
-  GetGlobalFactory()->CreateHtmlIndex(t,filename);
+  GetExecuter()->GetFactory()->CreateHtmlIndex(t,filename);
 }
 //=======================================================================
 
index 124323be80bdc9ed46abdad1984b48e18dfa303a..eb8e09c07b118d567b3dd2804c05276aa2d820bd 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkInterpreter.h,v $ $
   Language:  C++
-  Date:      $Date: 2008/03/03 08:06:36 $
-  Version:   $Revision: 1.12 $
+  Date:      $Date: 2008/03/07 08:40:14 $
+  Version:   $Revision: 1.13 $
 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
 namespace bbtk
 {
 
-
+#ifdef _USE_WXWIDGETS_
+  class WxConsole;
+#endif
+  
   class BBTK_EXPORT Interpreter
   {
 
@@ -94,8 +97,6 @@ namespace bbtk
     /// Destructor
     ~Interpreter();
 
-   static Interpreter* mGlobalInterpreter;
-
     /// Launches a command line interpreter (with a prompt)
     void CommandLineInterpreter();
 
@@ -167,6 +168,19 @@ namespace bbtk
     /// Sets the bool that indicates wether we are in command line context
     void SetCommandLine(bool v = true) { mCommandLine = v; }
 
+#ifdef _USE_WXWIDGETS_
+    /// Sets the WxConsole that created the interpreter (if any)
+    void SetWxConsole(WxConsole* c) { mWxConsole = c; }
+    /// Gets the WxConsole that created the interpreter (if any) 
+    WxConsole* GetWxConsole() { return mWxConsole; }
+    /// Gets the WxConsole that created the interpreter (if any) - const 
+    const WxConsole* GetWxConsole() const { return mWxConsole; }
+#endif
+
+    /// Gets the Executer 
+    VirtualExec* GetExecuter() { return mExecuter; }
+    /// Gets the Executer (const)
+    const VirtualExec* GetExecuter() const { return mExecuter; }
 
   private:
 
@@ -180,12 +194,14 @@ namespace bbtk
     //==================================================================
     // ATTRIBUTES
 
-    /// The factory
-    //    bbtk::Factory* mFactory;
-
-    /// The command executer
+    /// The command executer used
     bbtk::VirtualExec* mExecuter;
 
+#ifdef _USE_WXWIDGETS_
+    /// The WxConsole which uses the interpreter (0 if none)
+    bbtk::WxConsole* mWxConsole;
+#endif
+
     /// Vector of open files 
     std::vector<std::ifstream*> mFile;
 
@@ -208,6 +224,10 @@ namespace bbtk
     std::deque< char* > mHistory;
 
   };
+  // EO class Interpreter
+
+
+
 
 
   // The "Quit" exception
index 7d70c2511faefa7bdbd63ba5935f5932b440996b..cdc19203d9e2408d0b46f81e0b7785a10e0741ec 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkPackage.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/02/18 10:41:02 $
-  Version:   $Revision: 1.9 $
+  Date:      $Date: 2008/03/07 08:40:14 $
+  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
@@ -35,11 +35,12 @@ namespace bbtk
                   const std::string& description,
                   const std::string& version,
                   const std::string& BBTKVersion) 
-    : mName(name),
-      mAuthor(author),
-      mDescription(description),
-      mVersion(version),
-      mBBTKVersion(BBTKVersion)
+    :
+    mName(name),
+    mAuthor(author),
+    mDescription(description),
+    mVersion(version),
+    mBBTKVersion(BBTKVersion)
   {
     std::string default_doc_dir = ConfigurationFile::GetInstance().Get_default_temp_dir();
     char c = default_doc_dir.c_str()[strlen(default_doc_dir.c_str())-1];
index fb7b32c375c6b7fad0ee18c82c3015b7a892b99b..1dfc854f4f0bb577e364157a21006084c770e1da 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkPackage.h,v $
   Language:  C++
-  Date:      $Date: 2008/02/05 12:16:55 $
-  Version:   $Revision: 1.4 $
+  Date:      $Date: 2008/03/07 08:40:14 $
+  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
@@ -105,7 +105,19 @@ namespace bbtk
     const BlackBoxMapType& GetBlackBoxMap() const { return mBlackBoxMap; }
     BlackBoxMapType& GetBlackBoxMap() { return mBlackBoxMap; }
 
+    // Factories management
+    /// Adds the factory to the set of factories which use the package
+    void AddFactory(Factory* f) { mFactorySet.insert(f); }
+    /// Removes the factory from the set of factories which use the package
+    void RemoveFactory(Factory* f) { mFactorySet.erase(f); }
+
+    /// Gets the set of factories which use the package
+    std::set<Factory*>& GetFactorySet() { return mFactorySet; }
+    /// Gets the set of factories which use the package (const)
+    const std::set<Factory*>& GetFactorySet() const { return mFactorySet; }
+    
   private:
+
     /// The name of the package
     std::string mName;
     /// The author of the package
@@ -152,13 +164,16 @@ namespace bbtk
       std::string mTypeOut;
     };
     
-    //typedef std::string AdaptorKey;
-
     /// The type of map of adaptor descriptors
     typedef std::map< AdaptorKey, BlackBoxDescriptor*> AdaptorMapType;
 
     /// The map of adaptors descriptors
     AdaptorMapType mAdaptorMap;
+
+
+    /// The set of factories which contain the package 
+    std::set<Factory*> mFactorySet;
+    
   };
   // EO class Package
   //====================================================================
index 96a264b55a8f3fbd0231ae163dcb5be5254f885b..1bb48a94fab0729263345db374c2202d34eee9a8 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkVirtualExec.h,v $ $
   Language:  C++
-  Date:      $Date: 2008/02/06 09:27:52 $
-  Version:   $Revision: 1.7 $
+  Date:      $Date: 2008/03/07 08:40:14 $
+  Version:   $Revision: 1.8 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
 #define __bbtkVirtualExec_h__
 
 #include "bbtkSystem.h"
-#include "bbtkComplexBlackBox.h"
+//#include "bbtkComplexBlackBox.h"
 #include "bbtkFactory.h"
-#include <string>
-#include <deque>
+//#include <string>
+//#include <deque>
 
 namespace bbtk
 {
 
+  class Interpreter;
+
   class /*BBTK_EXPORT*/ VirtualExec   // All methods are pure virtual
   {
 
@@ -48,6 +50,20 @@ namespace bbtk
     }
     DialogModeType;
 
+    VirtualExec() : mInterpreter(0) {}
+
+    /// Sets the interpreter who uses it 
+    void SetInterpreter(Interpreter* i) { mInterpreter = i; }
+    /// Gets the interpreter who uses it 
+    Interpreter* GetInterpreter() { return mInterpreter; }
+    /// Gets the interpreter who uses it (const)
+    const Interpreter* GetInterpreter() const { return mInterpreter; }
+
+    /// Gets the factory used by the executer
+    virtual Factory* GetFactory() { return 0; }
+    /// Gets the factory used by the executer (const)
+    virtual const Factory* GetFactory() const { return 0; }
+    
     /// Sets the inputs of the workspace : 
     virtual void SetInputs(const std::map<std::string,std::string>& m) = 0;
 
@@ -156,6 +172,9 @@ namespace bbtk
 
   private:
 
+   /// The interpreter which uses it (0 if none)
+    Interpreter* mInterpreter;
+    /*
     /// Gets the current working black box 
     virtual ComplexBlackBoxDescriptor* Current() = 0;
     
@@ -204,6 +223,7 @@ namespace bbtk
 
     /// Dialog mode
     DialogModeType mDialogMode;
+    */
   };
 }
 #endif
index 78cc417378da1005b2b2f59842416b5877548a71..c988e33380d4eef8d10883dee5a0a7f6d03d3ab4 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkWxConsole.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/03/03 10:48:47 $
-  Version:   $Revision: 1.6 $
+  Date:      $Date: 2008/03/07 08:40:14 $
+  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
@@ -161,6 +161,7 @@ namespace bbtk
   {    
     mInstance = this;
     mInterpreter = new bbtk::Interpreter();
+    mInterpreter->SetWxConsole(this);
     mInterpreter->SetCommandLine(true);
     //==============
     // Menu
index 41ca170e2d96d6193cc86b43e4c7bb49ac6eb6b8..7649c2205a549db2e8ed072660c3e0711578099d 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkWxConsole.h,v $
   Language:  C++
-  Date:      $Date: 2008/03/03 10:48:48 $
-  Version:   $Revision: 1.5 $
+  Date:      $Date: 2008/03/07 08:40:14 $
+  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
@@ -57,7 +57,14 @@ namespace bbtk
     WxConsole( wxWindow *parent, wxString title, wxSize size);
     ~WxConsole();
 
-    static WxConsole* GetInstance() { return mInstance; }
+    //    static WxConsole* GetInstance() { return mInstance; }
+    
+    /// Returns the Interpreter used 
+    /// ONLY ONE FOR THE MOMENT BUT IN THE FUTURE CAN BE DIFFERENT 
+    /// (DIFFERENT WORKSPACES)
+    Interpreter* GetInterpreter() { return mInterpreter; }
+    /// Returns the Interpreter used (const)
+    const Interpreter* GetInterpreter() const { return mInterpreter; }
 
     /// Sets the inputs of the workspace : 
     /// the map is passed as is to the Executer
@@ -68,7 +75,8 @@ namespace bbtk
     /// which creates but does not execute pipelines.
     void SetNoExecMode(bool b) { mInterpreter->SetNoExecMode(b); }
 
-    void SetDialogMode(Interpreter::DialogModeType t) { mInterpreter->SetDialogMode(t); }
+    void SetDialogMode(Interpreter::DialogModeType t) 
+    { mInterpreter->SetDialogMode(t); }
     
     /// Runs the interpretation of a file
     void InterpretFile( const std::string& filename) 
diff --git a/packages/wxvtk/bbs/appli/ExampleBasicImageApplication.bbs b/packages/wxvtk/bbs/appli/ExampleBasicImageApplication.bbs
new file mode 100644 (file)
index 0000000..da88857
--- /dev/null
@@ -0,0 +1,48 @@
+
+
+description "Demo of the box <a href=#bbBasicImageApplication>BasicImageApplication</a> : creates an interactive image thresholding application"
+author "laurent.guigues@creatis.insa-lyon.fr"
+category "example"
+
+## THE APPLICATION BOX
+include /home/guigues/coding/Sofa/bbtk/packages/wxvtk/bbs/boxes/bbBasicImageApplication
+#include wxvtk/boxes/bbBasicImageApplication
+new BasicImageApplication appli
+set appli.WinTitle "ExampleBasicImageApplication"
+
+## THE FILTER 
+new BinaryThresholdImageFilter filter
+connect appli.AlgorithmInput filter.In
+connect filter.Out appli.AlgorithmOutput
+
+## THE WINDOW FOR PARAMETERS TUNING
+new LayoutLine parametersWindow
+new Slider upperThresholdSlider
+set upperThresholdSlider.Title "upper threshold"
+set upperThresholdSlider.In 100
+new Slider lowerThresholdSlider
+set lowerThresholdSlider.Title "lower threshold"
+set lowerThresholdSlider.In 0
+connect lowerThresholdSlider.Widget parametersWindow.Widget1
+connect upperThresholdSlider.Widget parametersWindow.Widget2
+connect upperThresholdSlider.Out filter.UpperThreshold
+connect lowerThresholdSlider.Out filter.LowerThreshold
+
+
+connect parametersWindow.Widget appli.ParametersWidget
+set appli.ParametersWindowHeight 200
+set appli.ParametersWindowWidth 400
+#set appli.Refresh Reactive
+
+#message Process 3
+## GO !
+#message All 9
+#graph
+
+#message Wx 9 
+exec appli
+#graph
+
+
+
+
diff --git a/packages/wxvtk/bbs/boxes/bbBasicImageApplication.bbs b/packages/wxvtk/bbs/boxes/bbBasicImageApplication.bbs
new file mode 100644 (file)
index 0000000..d83f1a7
--- /dev/null
@@ -0,0 +1,115 @@
+include wxvtk/boxes/bbDoubleSlicer
+load wx
+load std
+load itk
+load itkvtk 
+load vtk
+
+
+define BasicImageApplication
+
+##
+   description "Interface of a 'standard' image application. Displays two images : before/after processing; Offers buttons : open/parameters/run/save/quit. See <a href='../demo/index.html#DemoBasicImageApplication'>DemoBasicImageApplication.bbs</a>. Screenshot : <center><img src='../demo/DemoBasicImageApplication1.png' width=400></center>."
+  author "laurent.guigues@creatis.insa-lyon.fr"
+  category "widget"
+##
+
+
+# WINDOWS CREATION
+  new LayoutSplit mainWindow
+  set mainWindow.Proportion 90
+
+  new DoubleSlicer viewer
+
+  new LayoutLine buttonsBar
+  
+  new CommandButton openButton
+  new CommandButton paramButton
+  new CommandButton runButton
+  new CommandButton saveButton
+  new CommandButton quitButton
+
+  connect viewer.Widget      mainWindow.Widget1
+  connect buttonsBar.Widget  mainWindow.Widget2
+
+  connect openButton.Widget  buttonsBar.Widget1
+  connect paramButton.Widget buttonsBar.Widget2
+  connect runButton.Widget   buttonsBar.Widget3
+  connect saveButton.Widget  buttonsBar.Widget4
+  connect quitButton.Widget  buttonsBar.Widget5
+
+  set viewer.Orientation 0
+  set buttonsBar.Orientation 0
+
+#OPEN
+  set openButton.Label "Open"
+  set paramButton.Label "Parameters"
+  set saveButton.Label "Save"
+  new FileSelector openFileDialog
+  connect openButton.BoxChange openFileDialog.BoxExecute
+  connect openButton.BoxChange viewer.RefreshSlicer1
+  set openFileDialog.Message "Select input image"
+  set openFileDialog.OpenSave "Open"
+#READER
+  new MetaImageReader reader 
+#  set reader.Filename  "/home/guigues/coding/Sofa/bbtk/data/thorax.hdr"
+  connect openFileDialog.Out reader.In
+
+  connect reader.Out viewer.In1
+
+
+# RUN
+  set runButton.Label "Run"
+  new MultipleInputs refreshViewerOut 
+  connect refreshViewerOut.Out viewer.RefreshSlicer2
+  connect runButton.BoxChange refreshViewerOut.In1
+
+#QUIT
+  set quitButton.Label "Quit"
+  set quitButton.In "quit"
+  
+
+#SAVE 
+  new ImageWriter writer
+  new FileSelector saveFileDialog
+  set saveFileDialog.BoxProcessMode Always
+  set saveFileDialog.DefaultFile "out.hdr"
+  set saveFileDialog.Message "Select output image"
+  set saveFileDialog.OpenSave "Save"
+  connect saveFileDialog.Out writer.Filename
+  connect saveButton.BoxChange refreshViewerOut.In2
+  connect saveButton.BoxChange writer.BoxExecute
+
+#PARAMETERS 
+  new LayoutSplit paramWindow
+  set paramWindow.Proportion 80
+  set paramWindow.WinTitle "Parameters"
+#  new LayoutLine userParamWindow
+#  connect userParamWindow.Widget paramWindow.Widget1
+  new CommandButton paramWindowCloseButton
+  set paramWindowCloseButton.Label "Close"
+  connect paramWindowCloseButton.Widget paramWindow.Widget2
+  connect paramWindowCloseButton.BoxChange paramWindow.WinHide
+  connect paramButton.BoxChange paramWindow.BoxExecute
+
+
+# INPUTS / OUTPUTS 
+  new anyItkImagePointerRelay imageOut
+  connect imageOut.Out viewer.In2
+  connect imageOut.Out writer.In
+  
+  input AlgorithmOutput imageOut.In "Plug here the output of your algorithm"
+  output AlgorithmInput reader.Out "Plug this output to the input of your algorithm"
+  input ParametersWidget paramWindow.Widget1 "Connect here your parameter tuning widget"
+
+  input ParametersWindowWidth paramWindow.WinWidth "The width of the parameters window"
+  input ParametersWindowHeight paramWindow.WinHeight "The height of the parameters window"
+  input WinTitle mainWindow.WinTitle "Title of the main window"
+
+  input Refresh viewer.BoxProcessModeSlicer2 "Set to 'Reactive' to have automatic refresh when image or parameters change"
+
+  exec mainWindow
+
+
+endefine
+