Salome HOME
Merging with JR_ASV_2_1_0_deb_with_KERNEL_Head branch, which contains many bug fixes...
[modules/superv.git] / src / Supervision / GNode_Impl.cxx
index 6d7cd4a29a6866193ed7e3bc5d54bbe167563626..7c770df016e972f22cab5d17fc83cabd6aec15ca 100644 (file)
@@ -130,31 +130,6 @@ GNode_Impl::GNode_Impl( CORBA::ORB_ptr orb ,
 //  endService( "GNode_Impl::GNode_Impl" );  
 }
 
-GNode_Impl::GNode_Impl( CORBA::ORB_ptr orb ,
-                     PortableServer::POA_ptr poa ,
-                     PortableServer::ObjectId * contId , 
-                     const char *instanceName ,
-                      const char *interfaceName ,
-                      GraphExecutor::DataFlow * aDataFlowExecutor ,
-                      GraphExecutor::InNode * aDataFlowExecutorNode ) :
-//  Engines_Component_i(orb, poa, contId, instanceName, interfaceName, false, false) {
-  INode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowExecutor , aDataFlowExecutorNode ) {
-//  beginService( "GNode_Impl::GNode_Impl" );
-  if ( DataFlowExecutorNode() && DataFlowExecutorNode()->IsGOTONode() ) {
-//    MESSAGE( "GNode_Impl::GNode_Impl " << DataFlowExecutorNode()->Name()
-//             << " _poa->activate_object" );
-    _thisObj = this ;
-    _id = _poa->activate_object(_thisObj);
-  }
-  else {
-//    MESSAGE( "GNode_Impl::GNode_Impl NO _poa->activate_object" );
-  }
-  _Orb = CORBA::ORB::_duplicate(orb);
-  _Poa = poa ;
-  _ContId = contId ;
-//  endService( "GNode_Impl::GNode_Impl" );  
-}
-
 GNode_Impl::~GNode_Impl() {
   beginService( "GNode_Impl::~GNode_Impl" );
   endService( "GNode_Impl::~GNode_Impl" );
@@ -169,6 +144,9 @@ void GNode_Impl::destroy() {
       delete(_id) ;
       _thisObj->_remove_ref();
     }
+    else {
+      MESSAGE("GNode_Impl::destroy ERROR ") ;
+    }
   }
 //  endService( "GNode_Impl::Destroy" );
 }
@@ -177,6 +155,18 @@ bool GNode_Impl::Delete() {
   beginService( "GNode_Impl::Delete" );
   bool RetVal = false ;
   if ( DataFlowEditor()->IsEditing() ) {
+    if ( DataFlowNode() ) {
+      GraphBase::GOTONode * aGOTONode = DataFlowNode()->GOTONode() ;
+      if ( aGOTONode ) {
+        GraphBase::GOTONode * aCoupledNode = (GraphBase::GOTONode * ) aGOTONode->CoupledNode() ;
+        if ( aCoupledNode && ( aCoupledNode->IsOneOfGOTONodes() || aCoupledNode->IsDataFlowNode() ||
+                               aCoupledNode->IsDataStreamNode() ) ) {
+          aCoupledNode->CoupledNode( NULL ) ;
+          aCoupledNode->MacroObject( SUPERV::Graph::_nil() ) ;
+          aCoupledNode->GraphMacroLevel( 0 ) ;
+        }
+      }
+    }
     DeletePorts() ;
     RetVal = DataFlowEditor()->RemoveNode( Name() ) ;
     if ( RetVal )
@@ -227,3 +217,31 @@ SUPERV::INode_ptr GNode_Impl::Coupled() {
   return SUPERV::INode::_duplicate( iobject ) ;
 }
 
+bool GNode_Impl::SetCoupled( const char * anInLineNode )
+{
+  GraphBase::InLineNode * CoupledINode = (GraphBase::InLineNode * ) DataFlowEditor()->Graph()->GetGraphNode( anInLineNode ) ;
+  if ( !CoupledINode ) {
+    
+    // asv : 2.11.04 : nullify Coupled node if anInLineNode == "" (bug 7113)
+    if ( anInLineNode==NULL || !strlen( anInLineNode ) ) {
+      DataFlowNode()->CoupledNode( NULL );
+    }
+
+    return false;
+  } 
+  if ( ( IsGOTO() && ( CoupledINode->IsInLineNode() || CoupledINode->IsLoopNode() || CoupledINode->IsSwitchNode() ) ) ||
+       ( !IsGOTO() && ( IsLoop() || IsSwitch() || IsEndLoop() || IsEndSwitch() ) ) ) {
+    DataFlowNode()->CoupledNode( CoupledINode ) ;
+    if ( CoupledINode && IsSwitch() ) {
+      DataFlowEditor()->AddLink( Name() , "Default" ,CoupledINode->Name() , "Default" ) ;
+    }
+    else if ( CoupledINode && ( IsLoop() || IsEndLoop() ) ) {
+      DataFlowEditor()->AddLink( Name() , "DoLoop" , CoupledINode->Name() , "DoLoop" ) ;
+    }
+    else if ( CoupledINode && IsGOTO() ) {
+      DataFlowEditor()->AddLink( Name() , "OutGate" ,CoupledINode->Name() , "InGate" ) ;
+    }
+    return  true ;
+  }
+  return false ; 
+}