Salome HOME
Merge from OCC_development_generic_2006
[modules/superv.git] / src / GraphEditor / DataFlowEditor_DataFlow.lxx
index 699c7a1ef4bb78bcfd19ee45adaa76469ddc3e34..24f63f6f932c1423e893233dab6e184265c81c0f 100644 (file)
@@ -33,6 +33,8 @@ inline void GraphEditor::DataFlow::ReadOnly() {
   _ReadOnly = true ;
 }
 
+//JR 07.07.2005 : old code from the first prototype
+#if 0
 inline char * GraphEditor::DataFlow::DataFlowInfo() {
   ostringstream s;
   IsValid() ;
@@ -56,19 +58,21 @@ inline char * GraphEditor::DataFlow::NodeInfo( const char * aNodeName ) {
     s << aNodeName << " not found" << ends ;
   return CORBA::string_dup( s.str().c_str() );
 }
+#endif
 
-inline bool GraphEditor::DataFlow::LoadDataFlow( const GraphBase::SGraph *aDataFlow ) {
+inline bool GraphEditor::DataFlow::LoadDataFlow( const GraphBase::SGraph * aDataFlow ) {
   if ( _ReadOnly )
     return false ;
   _EditedAfterExecution = true ;
   return GraphEditor::OutNode::LoadDataFlow( aDataFlow ) ; 
 } ;
 
-inline bool GraphEditor::DataFlow::LoadXml( const char* myFileName ) {
+inline bool GraphEditor::DataFlow::LoadXml( const char* myFileName ,
+                                            GraphBase::ListOfSGraphs & aListOfDataFlows ) {
   if ( _ReadOnly )
     return false ;
   _EditedAfterExecution = true ;
-  return GraphEditor::OutNode::LoadXml( myFileName ) ; 
+  return GraphEditor::OutNode::LoadXml( myFileName , aListOfDataFlows ) ; 
 } ;
 
 inline bool GraphEditor::DataFlow::LoadInfo( const GraphBase::SNode &aDataFlowInfo ) {
@@ -87,8 +91,9 @@ inline bool GraphEditor::DataFlow::SavePy(const char* myFileName ) {
 } ;
 
 // get all DataFlow informations (for a .XML file) :
-inline GraphBase::SGraph * GraphEditor::DataFlow::GetDataFlow() {
-   return GraphEditor::OutNode::GetDataFlow() ; 
+inline GraphBase::ListOfSGraphs * GraphEditor::DataFlow::GetDataFlows() {
+  GraphBase::ListOfSGraphs * aListOfDataFlows = new GraphBase::ListOfSGraphs;
+  return GraphEditor::OutNode::GetDataFlows( aListOfDataFlows ) ; 
 } ;
 
 //    void DateModification() ;
@@ -97,19 +102,19 @@ inline GraphBase::SGraph * GraphEditor::DataFlow::GetDataFlow() {
 //   return GraphEditor::OutNode::GetInfo() ; 
 //} ;
 
-inline GraphBase::ListOfNodes * GraphEditor::DataFlow::GetNodes() const {
+inline GraphBase::ListOfSNodes * GraphEditor::DataFlow::GetNodes() const {
    return Graph()->GetNodes() ; 
 } ;
 
-inline GraphBase::ListOfLinks * GraphEditor::DataFlow::GetLinks() const {
+inline GraphBase::ListOfSLinks * GraphEditor::DataFlow::GetLinks() const {
    return Graph()->GetLinks() ; 
 } ;
 
-inline GraphBase::ListOfGraphs * GraphEditor::DataFlow::GetGraphs() const {
+inline GraphBase::ListOfSGraphs * GraphEditor::DataFlow::GetGraphs() const {
    return Graph()->GetGraphs() ; 
 } ;
 
-inline GraphBase::ListOfLinks * GraphEditor::DataFlow::GetDatas() const {
+inline GraphBase::ListOfSLinks * GraphEditor::DataFlow::GetDatas() const {
    return Graph()->GetDatas() ; 
 } ;
 
@@ -161,7 +166,14 @@ inline GraphEditor::InNode * GraphEditor::DataFlow::AddNode(
                                         NodeComment , NodeX , NodeY ) ;
 //  MESSAGE( "<-- GraphEditor::DataFlow::AddNode( " << aNode->Name() << " )" ) ;
 //  cout << "<-- GraphEditor::DataFlow::AddNode( " << aNode->Name() << " )" << endl ;
-  cdebug_out << "GraphEditor::DataFlow::AddNode( " << aNode->Name() << " )" << endl ;
+  cdebug_out << "GraphEditor::DataFlow::AddNode( " ;
+  if ( aNode ) {
+    cdebug << aNode->Name() << " )" ;
+  }
+  else {
+    cdebug << "NULL ) Node not created" ;
+  }
+  cdebug << endl ;
   return aNode ;
 } ;
 
@@ -240,21 +252,21 @@ inline bool GraphEditor::DataFlow::HasInput(const char * ToServiceParameterName
 inline bool GraphEditor::DataFlow::AddLink( const char* FromNodeName ,
                                             const char* FromServiceParameterName ,
                                            const char* ToNodeName ,
-                                            const char* ToServiceParameterName ,
-                                           const CORBA::Any aValue ) {
+                                            const char* ToServiceParameterName ) {
+//                                         , const CORBA::Any aValue ) {
   if ( !_ReadOnly ) {
     GraphEditor::InNode * aFromNode = GetNode( FromNodeName ) ;
     if ( aFromNode ) {
-      GraphBase::OutPort * anOutPort = aFromNode->GetChangeOutPort( FromServiceParameterName ) ;
-      if ( anOutPort ) {
-        CORBA::Any const * theValue = anOutPort->Value() ; // Keep the type !
+//      GraphBase::OutPort * anOutPort = aFromNode->GetChangeOutPort( FromServiceParameterName ) ;
+//      if ( anOutPort ) {
+//        CORBA::Any const * theValue = anOutPort->Value() ; // Keep the type !
         _EditedAfterExecution = true ;
         return GraphEditor::OutNode::AddLink( FromNodeName ,
                                               FromServiceParameterName ,
                                               ToNodeName ,
-                                              ToServiceParameterName ,
-                                              *theValue ) ;
-      }
+                                              ToServiceParameterName ) ;
+//                                              , *theValue ) ;
+//      }
     }
   }
   return false ;
@@ -283,7 +295,7 @@ inline bool GraphEditor::DataFlow::AddLinkCoord(
                          const int nXY ,
                          const int* X ,
                          const int* Y ) {
-  _EditedAfterExecution = true ;
+  //_EditedAfterExecution = true ; // mkr : fix for bug IPAL9818
   return GraphEditor::OutNode::AddLinkCoord( FromNodeName ,
                                              FromServiceParameterName ,
                                              ToNodeName ,
@@ -299,7 +311,7 @@ inline bool GraphEditor::DataFlow::AddLinkCoord(
                          const int index ,
                          const int X ,
                          const int Y ) {
-  _EditedAfterExecution = true ;
+  //_EditedAfterExecution = true ; // mkr : fix for bug IPAL9818
   return GraphEditor::OutNode::AddLinkCoord( FromNodeName ,
                                              FromServiceParameterName ,
                                              ToNodeName ,
@@ -315,7 +327,7 @@ inline bool GraphEditor::DataFlow::ChangeLinkCoord(
                          const int index ,
                          const int X ,
                          const int Y ) {
-  _EditedAfterExecution = true ;
+  //_EditedAfterExecution = true ; // mkr : fix for bug IPAL9818
   return GraphEditor::OutNode::ChangeLinkCoord( FromNodeName ,
                                                 FromServiceParameterName ,
                                                 ToNodeName ,
@@ -329,7 +341,7 @@ inline bool GraphEditor::DataFlow::RemoveLinkCoord(
                          const char* ToNodeName ,
                          const char* ToServiceParameterName ,
                          const int index ) {
-  _EditedAfterExecution = true ;
+  //_EditedAfterExecution = true ; // mkr : fix for bug IPAL9818
   return GraphEditor::OutNode::RemoveLinkCoord( FromNodeName ,
                                                 FromServiceParameterName ,
                                                 ToNodeName ,
@@ -392,57 +404,32 @@ inline bool GraphEditor::DataFlow::RemoveLink(
 inline bool GraphEditor::DataFlow::AddInputData( const char* ToNodeName ,
                                                  const char* ToParameterName ,
                                                  const CORBA::Any aValue ) {
-#if 0
-  GraphBase::Node *toNode ;
-  GraphBase::InPort *toPort ;
-  char *aNode ;
-  char *aPort ;
-  NodePort( ToNodeName , ToParameterName , &aNode , &aPort ) ;
-  toNode = GetChangeGraphNode( aNode ) ;
-  if ( toNode ) {
-    toPort = toNode->GetChangeInPort( aPort ) ;
-    if ( toPort && ( toPort->IsConnected() ||
-                     toPort->IsDataConnected() ) ) {
-      RemoveLink( toNode->Name() , toPort->PortName() ) ;
-    }
-  }
-  else {
-    toPort = NULL ;
-  }
-  delete aNode ;
-  delete aPort ;
-#endif
   if ( !IsValid() ) {
     return false ;
   }
   return Graph()->AddInputData( ToNodeName , ToParameterName , aValue ) ; 
 } ;
 
-inline bool GraphEditor::DataFlow::AddInputSharedData(const char* ToNodeName1 ,
-                                                      const char* ToParameterName1 ,
-                                                      const char* ToNodeName2 ,
-                                                      const char* ToParameterName2 ) {
-  if ( !IsValid() ) {
-    return false ;
-  }
-  return GraphEditor::OutNode::AddInputData( ToNodeName1 , ToParameterName1 ,
-                                             ToNodeName2 , ToParameterName2 ) ;
-} ;
-
-inline const CORBA::Any *GraphEditor::DataFlow::GetInData(
+//JR 30.03.2005inline const CORBA::Any *GraphEditor::DataFlow::GetInData(
+inline const CORBA::Any GraphEditor::DataFlow::GetInData(
                                    const char * ToNodeName ,
                                    const char * ToParameterName ) {
   return GraphEditor::OutNode::GetInData( ToNodeName ,
                                           ToParameterName ) ;
 }
-inline const CORBA::Any *GraphEditor::DataFlow::GetOutData(
+//JR 30.03.2005inline const CORBA::Any *GraphEditor::DataFlow::GetOutData(
+inline const CORBA::Any GraphEditor::DataFlow::GetOutData(
                                    const char * FromNodeName ,
                                    const char * FromParameterName ) {
   return GraphEditor::OutNode::GetOutData( FromNodeName ,
                                            FromParameterName ) ;
 }
 
+//JR Optional parameter kLoopSwitch (default = true) :
+//In some cases we do not need to check the validity of loops and switchs
+//inline bool GraphEditor::DataFlow::IsValid(bool kLoopSwitch ) {
 inline bool GraphEditor::DataFlow::IsValid() {
+//  return GraphEditor::OutNode::IsValid( kLoopSwitch ) ;
   return GraphEditor::OutNode::IsValid() ;
 }
 
@@ -450,21 +437,21 @@ inline bool GraphEditor::DataFlow::IsExecutable() {
   return GraphEditor::OutNode::IsExecutable() ;
 }
 
+inline void GraphEditor::DataFlow::Executing() {
+  cdebug << "Editor::DataFlow::Executing() : set _Executing = true " << endl ;
+  _Executing = true ;
+}
+
 inline bool GraphEditor::DataFlow::IsExecuting() {
-  if ( _DataFlowExecutor ) {
-    if ( _DataFlowExecutor->IsDone() ) {
-      _Executing = false ;
-    }
-    else {
-    _Executing = true ;
-    }
-  }
-  else {
-    _Executing = false ;
-  }
   return _Executing ;
 }
 
+
+inline void GraphEditor::DataFlow::Editing() {
+  cdebug << "Editor::DataFlow::Editing() : set _Executing = false " << endl ;
+  _Executing = false ;
+}
+
 inline bool GraphEditor::DataFlow::IsEditing() {
   return !IsExecuting() ;
 }
@@ -477,40 +464,60 @@ inline bool GraphEditor::DataFlow::EditedAfterExecution() {
   return _EditedAfterExecution ;
 }
 
+inline bool GraphEditor::DataFlow::UnValid() {
+  Editing() ;
+  EditedAfterExecution( true ) ;
+  return GraphEditor::OutNode::UnValid() ;
+}
+
 inline bool GraphEditor::DataFlow::IsReadOnly() {
   return _ReadOnly ;
 }
 
 inline long GraphEditor::DataFlow::LevelMax() {
-  if ( !IsValid() ) {
+//  if ( !IsValid( false ) ) {
+//  if ( !IsExecutable() ) {
+  // mkr : IPAL9974 -->
+  int SubStreamGraphsNumber = 0 ;
+  if ( !IsValid() || !Graph()->Sort( SubStreamGraphsNumber ) ) {
+  // mkr : IPAL9974 <-- 
     return 0 ;
   }
   return Graph()->LevelMax() ;
 }
 
 inline SUPERV::ListOfStrings * GraphEditor::DataFlow::LevelNodes(long aLevel ) {
-  if ( !IsValid() ) {
+//  if ( !IsValid( false ) ) {
+//  if ( !IsExecutable() ) {
+  if ( !IsValid() ) { // mkr : IPAL9974
     return ((SUPERV::ListOfStrings * ) NULL ) ;
   }
   return Graph()->LevelNodes( aLevel ) ;
 }
 
 inline long GraphEditor::DataFlow::ThreadsMax() {
-  if ( !IsValid() ) {
+//  if ( !IsValid() ) {
+//  if ( !IsExecutable() ) {
+  // mkr : IPAL9974 -->
+  int SubStreamGraphsNumber = 0 ;      
+  if ( !IsValid()  || !Graph()->Sort( SubStreamGraphsNumber ) ) {
+  // mkr : IPAL9974 <--
     return 0 ;
   }
   return Graph()->ThreadsMax() ;
 }
 
 inline long GraphEditor::DataFlow::SubGraphsNumber() {
-  if ( !IsValid() ) {
+//  if ( !IsValid() ) {
+  if ( !IsExecutable() ) {
     return 0 ;
   }
   return Graph()->SubGraphsNumber() ;
 }
 
 inline long GraphEditor::DataFlow::SubStreamGraphsNumber() {
-  if ( !IsValid() ) {
+//  if ( !IsValid() ) {
+  if ( !IsExecutable() ) {
     return 0 ;
   }
   return StreamGraph()->SubStreamGraphsNumber() ;
@@ -518,7 +525,7 @@ inline long GraphEditor::DataFlow::SubStreamGraphsNumber() {
 
 inline void GraphEditor::DataFlow::Executor(
                                GraphExecutor::DataFlow * DataFlowExecutor ) {
-  _Executing = true ;
+//  _Executing = true ;
   _DataFlowExecutor = DataFlowExecutor ;
 }