]> Creatis software - bbtk.git/blobdiff - kernel/src/bbtkWxBlackBox.cxx
*** empty log message ***
[bbtk.git] / kernel / src / bbtkWxBlackBox.cxx
index be78a7ec853e3ef2197eee8218b4d9a80d4e7ae8..e4a8410357eedb865837908d5effa2763157f6df 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkWxBlackBox.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/04/22 14:30:25 $
-  Version:   $Revision: 1.14 $
+  Date:      $Date: 2008/04/23 14:49:28 $
+  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
@@ -379,6 +379,7 @@ namespace bbtk
     bbSetOutputWidget(0);
 
     bbSetWidgetEventHandler(0);
+    bbSetUpdateTransferedToParent(false);
   }
   //=========================================================================
 
@@ -423,42 +424,81 @@ namespace bbtk
   /// Main processing method of the box.
   IOStatus WxBlackBox::bbBackwardUpdate( Connection::Pointer caller )
   {
-    bbtkDebugMessageInc("Process",1,
-                       "=> WxBlackBox::bbBackwardUpdate("
-                       <<(caller?caller->GetFullName():"0")<<") ["
-                       <<bbGetFullName()<<"]"<<std::endl);
+    bbtkDebugMessage("Process",1,
+                    "=> WxBlackBox::bbBackwardUpdate("
+                    <<(caller?caller->GetFullName():"0")<<") ["
+                    <<bbGetFullName()<<"]"<<std::endl);
+    // If the caller's box to is not the box to connected to the 
+    // output 'Widget'
+    if ( ! (( bbGetStatus() == MODIFIED ) ||
+           ( bbBoxProcessModeIsAlways() )) )
+      {
+       bbtkDebugMessage("Process",2,"Up-to-date : nothing to do"<<std::endl);
+       bbtkDebugMessage("Process",1,
+                        "<= WxBlackBox::bbBackwardUpdate("
+                        <<(caller?caller->GetFullName():"0")<<") ["
+                        <<bbGetFullName()<<"]"<<std::endl);
+       return bbGetStatus();
+      }
+    BlackBox::OutputConnectorMapType::const_iterator i 
+      = bbGetOutputConnectorMap().find("Widget") ;
+    if ( i->second->GetConnectionVector().size() != 0 )
+      
+      {
+       BlackBox::Pointer to = 
+         i->second->GetConnectionVector()[0]->GetBlackBoxTo();
+               
+       if (caller) 
+         {
+           bbtkDebugMessage("Process",2,
+                            "-> Output 'Widget' connected to '"
+                            <<to->bbGetFullName()<<"' - caller->to = '"
+                            <<caller->GetBlackBoxTo()->bbGetFullName()
+                            <<"'"
+                            <<std::endl);
+         }
+       else
+         {
+           bbtkDebugMessage("Process",2,
+                            "-> Output 'Widget' connected to '"
+                            <<to->bbGetFullName()<<"'"
+                            <<std::endl);
+         }
+       if ((caller==0) ||
+           ((caller!=0) && 
+            (caller->GetBlackBoxTo() != to))&&
+           (!bbGetUpdateTransferedToParent()))
+         {
+           bbtkDebugMessage("Process",2,
+                            "   ... Transfering update order to parent"
+                            <<std::endl);
+           
+           bbSetUpdateTransferedToParent(true);
+           i->second->GetConnectionVector().front() //.lock()
+             ->GetBlackBoxTo()->bbExecute(false);
+         }
+       else
+         {
+           bbSetUpdateTransferedToParent(false);
+           bbtkDebugMessage("Process",2,
+                            "   ... No need to transfer to parent"
+                            <<std::endl);
+         }
+      }
+    /*    
+
     // If the caller is not the connection to the output widget
     // and the output 'Widget' is connected then 
     // we must execute the parent box 
     // but only one time 
-    // (this is the role of the flag UpdateTransferedToParent=
+    // (this is the role of the flag UpdateTransferedToParent)
     if ( (caller==0) ||
         ((caller!=0)&&(caller->GetBlackBoxFromOutput()!="Widget"))
         )
       {
-       BlackBox::OutputConnectorMapType::const_iterator i 
-         = bbGetOutputConnectorMap().find("Widget") ;
-       if ( i->second->GetConnectionVector().size() != 0 )
-            
-         {
-           bbtkDebugMessage("Process",2,
-                            "-> Output 'Widget' connected : transfering update order to parent"
-                            <<std::endl);
-           if ( bbGetUpdateTransferedToParent() )          
-             {
-               bbSetUpdateTransferedToParent(false);
-               bbtkDebugMessage("Process",2,
-                                "   ... already transfered : abort"
-                                <<std::endl);
-             }
-           else 
-             {
-               bbSetUpdateTransferedToParent(true);
-               i->second->GetConnectionVector().front() //.lock()
-                 ->GetBlackBoxTo()->bbExecute(false);
-             }
-         }
       }
+    */
     // call 'standard' BlackBox execution method
     if (!bbGetUpdateTransferedToParent()) 
       {