]> Creatis software - bbtk.git/blobdiff - kernel/src/bbtkBlackBox.cxx
*** empty log message ***
[bbtk.git] / kernel / src / bbtkBlackBox.cxx
index ae56fd4beb0a3adc978f22e65090b3c25f2625ab..d2137752f2e8aee1d3084543d6c786427e001b71 100644 (file)
@@ -3,8 +3,8 @@
 Program:   bbtk
 Module:    $RCSfile: bbtkBlackBox.cxx,v $
 Language:  C++
-Date:      $Date: 2008/04/22 08:29:09 $
-Version:   $Revision: 1.13 $
+Date:      $Date: 2008/06/19 09:46:41 $
+Version:   $Revision: 1.21 $
                                                                                 
 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
 l'Image). All rights reserved. See doc/license.txt or
@@ -65,7 +65,7 @@ namespace bbtk
     bbtkDebugMessage("object",2,"##> BlackBox::Deleter(\""<<name<<"\") : deleting black box"<<std::endl);
     
     b->bbDelete();
-    
+
     bbtkDebugMessage("object",2,"##> BlackBox::Deleter(\""<<name<<"\") : releasing descriptor ["<<desc.lock()<<"]"<<std::endl);
     
     if (!desc.expired()) 
@@ -103,6 +103,9 @@ namespace bbtk
   }
   //=========================================================================
 
+  //=========================================================================
+  BlackBox::BlackBox(const BlackBox&)
+  {}
 
   //=========================================================================
   BlackBox::BlackBox(BlackBox& from, const std::string &name) 
@@ -138,16 +141,17 @@ namespace bbtk
   /// Main processing method of the box.
   void BlackBox::bbExecute(bool force)
   {
-    bbtkDebugMessageInc("Process",1,
+    bbtkDebugMessageInc("process",2,
                        "=> BlackBox::bbExecute() ["
                        <<bbGetFullName()<<"]"<<std::endl);
  
-    Wx::BeginBusyCursor();
+       wxBusyCursor wait;
+    //EED Wx::BeginBusyCursor();
 
     // If execution frozen : return
     if (bbGlobalGetFreezeExecution()) 
       {
-       bbtkDebugMessage("Process",1,
+       bbtkDebugMessage("process",2,
                         " -> FreezeExecution global flag is 'true' : abort execution"<<std::endl);
       }
 
@@ -157,9 +161,9 @@ namespace bbtk
     // Calls the main recursive update method 
     bbBackwardUpdate(Connection::Pointer());
 
-    Wx::EndBusyCursor();
+    //EED Wx::EndBusyCursor();
 
-    bbtkDebugMessageDec("Process",1,
+    bbtkDebugMessageDec("process",2,
                        "<= BlackBox::bbExecute() ["
                        <<bbGetFullName()<<"]"<<std::endl);
   }
@@ -368,7 +372,7 @@ namespace bbtk
   /// 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"
@@ -417,55 +421,65 @@ namespace bbtk
   ///  Signals that the BlackBox has been modified
   void BlackBox::bbSetModifiedStatus(BlackBoxInputConnector* c)
   {
-    bbtkDebugMessageInc("Process",5,
-                       "=> BlackBox::bbSetModifiedStatus("<<c<<") ["
-                       <<bbGetFullName()<<"]"<<std::endl);
-   
+    bbtkDebugMessage("modified",1,
+                    "==> BlackBox::bbSetModifiedStatus("<<c<<") ["
+                    <<bbGetFullName()<<"]"<<std::endl);
+    
     if ( (c==bbGetInputConnectorMap().find("WinHide")->second) )
-        //      && (bbCanReact()))
+      //        && (bbCanReact()))
       {
-       bbtkDebugMessage("Process",9,
+       bbtkDebugMessage("modified",2,
                         "-> Hide triggered by WinHide input change"
                         <<std::endl);
        this->bbHideWindow();
        this->bbSetStatus(MODIFIED); 
        return;
       }
+    if ( (c==bbGetInputConnectorMap().find("WinClose")->second) )
+      //        && (bbCanReact()))
+      {
+       bbtkDebugMessage("modified",2,
+                        "-> Close triggered by WinClose input change"
+                        <<std::endl);
+       this->bbHideWindow();
+       this->bbSetStatus(MODIFIED); 
+       return;
+      }
+    
     if ( ( bbBoxProcessModeIsReactive()  ||
           (c==bbGetInputConnectorMap().find("BoxExecute")->second))
         && (bbCanReact() ) )
       {
-       bbtkDebugMessage("Process",9,
+       bbtkDebugMessage("modified",2,
                         "-> Execution triggered by Reactive mode or BoxExecute input change"<<std::endl);
        this->bbSetStatus(MODIFIED); 
         bbGlobalAddToExecutionList( GetThisPointer<BlackBox>() );
       }
     else if ( bbGetStatus() == MODIFIED ) //! this->bbIsUptodate()) 
       { 
-       bbtkDebugMessage("Process",5,"-> Already modified"<<std::endl);
-       bbtkDebugDecTab("Process",5);
+       bbtkDebugMessage("modified",2,"-> Already modified"<<std::endl);
        return;
       }
     else 
       {
-       bbtkDebugMessage("Process",5,"-> Status set to modified"<<std::endl);
-       bbtkDebugDecTab("Process",5);
+       bbtkDebugMessage("modified",2,"-> Status set to modified"<<std::endl);
        this->bbSetStatus(MODIFIED); 
       }
  
     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);
     
@@ -486,7 +500,7 @@ namespace bbtk
 
     if (reaction) bbGlobalProcessExecutionList();
 
-    bbtkDebugMessageDec("Process",5,
+    bbtkDebugMessageDec("process",5,
                        "<= BlackBox::bbSignalOutputModification() ["
                        <<bbGetFullName()<<"]"<<std::endl);
     
@@ -496,7 +510,7 @@ namespace bbtk
   void BlackBox::bbSignalOutputModification(const std::string& output,
        bool reaction)
   {
-    bbtkDebugMessageInc("Process",5,
+    bbtkDebugMessageInc("process",5,
                        "=> BlackBox::bbSignalOutputModification("
                        <<output<<") ["
                        <<bbGetFullName()<<"]"<<std::endl);
@@ -518,7 +532,7 @@ namespace bbtk
       }
   if (reaction) bbGlobalProcessExecutionList();
 
-  bbtkDebugMessageDec("Process",5,
+  bbtkDebugMessageDec("process",5,
                       "<= BlackBox::bbSignalOutputModification("
                       <<output<<") ["
                       <<bbGetFullName()<<"]"<<std::endl);
@@ -529,7 +543,7 @@ namespace bbtk
   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;
@@ -554,7 +568,7 @@ namespace bbtk
       }
   if (reaction) bbGlobalProcessExecutionList();
 
-   bbtkDebugMessageDec("Process",5,
+   bbtkDebugMessageDec("process",5,
                       "<= BlackBox::bbSignalOutputModification(vector of outputs) ["
                        <<bbGetFullName()<<"]"<<std::endl);
 
@@ -567,7 +581,7 @@ namespace bbtk
   ///          else MODIFIED 
   IOStatus BlackBox::bbUpdateInputs(bool excludeParent)
   {
-    bbtkDebugMessageInc("Process",4,
+    bbtkDebugMessageInc("process",4,
                        "=> BlackBox::bbUpdateInputs() ["
                        <<bbGetFullName()<<"]"
                        <<std::endl);   
@@ -589,7 +603,7 @@ namespace bbtk
        if (t==MODIFIED) s = MODIFIED;
       }
     
-   bbtkDebugMessageDec("Process",4,
+   bbtkDebugMessageDec("process",4,
                        "<= BlackBox::bbUpdateInputs() ["
                        <<bbGetFullName()<<"]"
                        <<std::endl);   
@@ -602,7 +616,7 @@ namespace bbtk
  
   //=========================================================================
   /// Connects the input <name> to the connection c
-  void BlackBox::bbConnectInput( const std::string& name, Connection::Pointer c)
+  void BlackBox::bbConnectInput( const std::string& name, Connection* c)
   {
     bbtkDebugMessage("connection",2,
                        "==> BlackBox::bbConnectInput(\""
@@ -631,7 +645,7 @@ namespace bbtk
 
   //=========================================================================  
   /// Connects the output <name> to the connection c
-  void BlackBox::bbConnectOutput( const std::string& name, Connection::Pointer c)
+  void BlackBox::bbConnectOutput( const std::string& name, Connection* c)
   {
     bbtkDebugMessage("connection",2,
                     "==> BlackBox::bbConnectOutput(\""<<name<<"\","
@@ -656,7 +670,7 @@ namespace bbtk
 
   //=========================================================================
   /// Disconnects the input <name> from the connection c
-  void BlackBox::bbDisconnectInput( const std::string& name, Connection::Pointer c)
+  void BlackBox::bbDisconnectInput( const std::string& name, Connection* c)
   {
 
     bbtkDebugMessage("connection",2,
@@ -691,7 +705,7 @@ namespace bbtk
 
   //=========================================================================
   /// Disconnects the output <name> from the connection c
-  void BlackBox::bbDisconnectOutput( const std::string& name, Connection::Pointer c)
+  void BlackBox::bbDisconnectOutput( const std::string& name, Connection* c)
   {
     bbtkDebugMessage("connection",2,
                     "==> BlackBox::bbDisconnectOutput(\""<<name
@@ -951,21 +965,21 @@ namespace bbtk
        {
          if (i->second)
            {
-             Connection::Pointer con = i->second->GetConnection();
+             Connection* con = i->second->GetConnection();
              if (con!=NULL){
-               BlackBox::Pointer a=con->GetBlackBoxFrom();
-               BlackBox::Pointer b=con->GetBlackBoxTo();
+               BlackBox::Pointer a=con->GetOriginalBlackBoxFrom();
+               BlackBox::Pointer b=con->GetOriginalBlackBoxTo();
                fprintf(ff,"  ");
                a->bbWriteDotInputOutputName(ff,false,detail,level);
                if (detail==1)
                  {
-                   fprintf(ff,":%s",con->GetBlackBoxFromOutput().c_str());
+                   fprintf(ff,":%s",con->GetOriginalBlackBoxFromOutput().c_str());
                  }
                fprintf(ff,"->");
                b->bbWriteDotInputOutputName(ff,true,detail,level);
                if (detail==1)
                  {
-                   fprintf(ff,":%s",con->GetBlackBoxToInput().c_str());
+                   fprintf(ff,":%s",con->GetOriginalBlackBoxToInput().c_str());
                  }
                fprintf(ff,"%s\n",";");
              }  // if con
@@ -1012,11 +1026,11 @@ namespace bbtk
        ivalue.push_back(bbGetInputAsString(i->first));
        if (ivalue.back().size()>valuelmax) valuelmax = ivalue.back().size();
        std::string s("");
-       Connection::Pointer con = i->second->GetConnection();
+       Connection* con = i->second->GetConnection();
        if (con!=0){
-         s = con->GetBlackBoxFrom()->bbGetName();
+         s = con->GetOriginalBlackBoxFrom()->bbGetName();
          s += ".";
-         s += con->GetBlackBoxFromOutput();
+         s += con->GetOriginalBlackBoxFromOutput();
        }  // if con
        iconn.push_back(s);
       }
@@ -1031,15 +1045,15 @@ namespace bbtk
        ovalue.push_back(bbGetOutputAsString(o->first));
        if (ovalue.back().size()>valuelmax) valuelmax = ovalue.back().size();
        std::vector<std::string> ss;
-       const std::vector<Connection::WeakPointer>& con 
+       const std::vector<Connection*>& con 
          = o->second->GetConnectionVector();
-       std::vector<Connection::WeakPointer>::const_iterator c;
+       std::vector<Connection*>::const_iterator c;
        for (c=con.begin();c!=con.end();++c) 
          {
            std::string s;
-           s = (*c).lock()->GetBlackBoxTo()->bbGetName();
+           s = (*c)->GetOriginalBlackBoxTo()->bbGetName();
            s += ".";
-           s += (*c).lock()->GetBlackBoxToInput();
+           s += (*c)->GetOriginalBlackBoxToInput();
            ss.push_back(s);
        }  // if con
        oconn.push_back(ss);
@@ -1104,7 +1118,7 @@ namespace bbtk
   //=========================================================================
    void BlackBox::bbGlobalProcessExecutionList()
    {   
-     bbtkDebugMessageInc("Process",1,
+     bbtkDebugMessageInc("process",3,
                         "=> BlackBox::bbGlobalProcessExecutionList()"
                         <<std::endl);     
      
@@ -1113,13 +1127,13 @@ namespace bbtk
          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);     
      
@@ -1153,13 +1167,6 @@ namespace bbtk
        } 
 
 
-  //=========================================================================
-  // Static members initialization
-/*EED
-  bool BlackBox::bbmgSomeBoxExecuting = false;
-  bool BlackBox::bbmgFreezeExecution = false;
-  std::set<BlackBox*> BlackBox::bbmgExecutionList;
-*/
    //=========================================================================
 
   //=========================================================================
@@ -1170,6 +1177,16 @@ namespace bbtk
   }
   //=========================================================================
 
+  void BlackBox::bbUserOnShowWidget(std::string nameInput)
+  {
+         bbtk::BlackBoxInputConnector *cc;
+         cc = this->bbGetInputConnectorMap().find( nameInput.c_str() )->second;
+         if (cc->GetConnection()!=NULL) 
+         {
+                 cc->GetConnection()->GetBlackBoxFrom()->bbUserOnShow();
+         }
+  }
+
 
 
 }  // EO namespace bbtk