+}
+
+/**
+ * Import an InLine node from Library into the dataflow
+ */
+bool SUPERVGUI_Library::Import( SUPERV::Graph_var theDataflow, SUPERV::INode_var& theNode,
+ SUPERV::INode_var& theEndNode, const int i ) const {
+ try {
+ QDomNodeList aNodes;
+ QDomDocument doc;
+ if ( getNodes( doc, aNodes ) ) { // xml is ok
+ if ( i >=0 && i < aNodes.length() ) { // index is ok
+ // 1. retrieve the node with given index
+ QDomElement aNode = aNodes.item( i ).toElement();
+ // 2. create an Engines node
+ QDomNamedNodeMap aNodeAtt = aNode.attributes();
+ const int aKind = aNodeAtt.namedItem( NODE_KIND_ATT ).nodeValue().toInt();
+ QString aNodeName = aNodeAtt.namedItem( NODE_NAME_ATT ).nodeValue();
+ switch ( aKind ) {
+ case SUPERV::InLineNode : // PyFunction
+ case SUPERV::GOTONode :
+ {
+ // get all the Python function
+ QString aPyFuncName;
+ SUPERV::ListOfStrings_var aPyFunc = new SUPERV::ListOfStrings();
+ getStrings( aNode, FUNC_NAME_ATT, aPyFuncName, FUNC_ELEMENT, aPyFunc );
+
+ // create the corresponding Engines node
+ SUPERV::INode_var aINode;
+ if ( aKind == SUPERV::InLineNode )
+ aINode = theDataflow->INode( aPyFuncName.latin1(), aPyFunc );
+ else
+ aINode = theDataflow->GNode( aPyFuncName.latin1(), aPyFunc, "" );
+
+ aINode->SetName( aNodeName.latin1() ); // try to set the same name of node (might be changed by CNode::SetName)
+ addPorts( aINode, aNode, PORT_ELEMENT ); // add stored ports
+
+ theNode = aINode; // init out-parameter
+ return true;
+ }
+ case SUPERV::LoopNode : // PyInit, PyNext, PyMore, PyEndLoopFunction
+ {
+ // get all required Python function
+ QString aInitName, aMoreName, aNextName, aELName;
+ SUPERV::ListOfStrings_var aInitFunc = new SUPERV::ListOfStrings(),
+ aMoreFunc = new SUPERV::ListOfStrings(),
+ aNextFunc = new SUPERV::ListOfStrings(),
+ aELFunc = new SUPERV::ListOfStrings();
+ getStrings( aNode, FUNC_INIT_NAME_ATT, aInitName, FUNC_INIT_ELEMENT, aInitFunc );
+ getStrings( aNode, FUNC_MORE_NAME_ATT, aMoreName, FUNC_MORE_ELEMENT, aMoreFunc );
+ getStrings( aNode, FUNC_NEXT_NAME_ATT, aNextName, FUNC_NEXT_ELEMENT, aNextFunc );
+ getStrings( aNode, FUNC_EL_NAME_ATT, aELName, FUNC_EL_ELEMENT, aELFunc );
+
+ // create Engines Loop node
+ SUPERV::INode_var aELNode;
+ SUPERV::INode_var aINode = theDataflow->LNode( aInitName.latin1(), aInitFunc,
+ aMoreName.latin1(), aMoreFunc,
+ aNextName.latin1(), aNextFunc, aELNode );
+ // EndLoop node may have or may NOT have pyFunc. set it if it was stored.
+ if ( !aELName.isEmpty() )
+ aELNode->SetPyFunction( aELName.latin1(), aELFunc );
+
+ aINode->SetName( aNodeName.latin1() );// try to set the same name of node (might be changed by CNode::SetName)
+ addPorts( aINode, aNode, PORT_ELEMENT ); // add stored ports
+
+ theNode = aINode; // init out-parameters
+ theEndNode = aELNode;
+ return true;
+ }
+ case SUPERV::SwitchNode : // PyFunction, PyESFunction, ESPorts
+ {
+ // get all required Python function
+ QString aPyFuncName, aESPyFuncName;
+ SUPERV::ListOfStrings_var aPyFunc = new SUPERV::ListOfStrings(),
+ aESPyFunc = new SUPERV::ListOfStrings();
+ getStrings( aNode, FUNC_NAME_ATT, aPyFuncName, FUNC_ELEMENT, aPyFunc );
+ getStrings( aNode, FUNC_ES_NAME_ATT, aESPyFuncName, FUNC_ES_ELEMENT, aESPyFunc );
+
+ // create Engines Switch node
+ SUPERV::INode_var aESNode;
+ SUPERV::INode_var aINode = theDataflow->SNode( aPyFuncName.latin1(), aPyFunc, aESNode );
+
+ // EndSwitch node may have or may NOT have pyFunc
+ if ( !aESPyFuncName.isEmpty() )
+ aESNode->SetPyFunction( aESPyFuncName.latin1(), aESPyFunc );
+
+ aINode->SetName( aNodeName.latin1() );// try to set the same name of node (might be changed by CNode::SetName)
+ addPorts( aINode, aNode, PORT_ELEMENT ); // add stored ports
+ addPorts( aESNode, aNode, ES_PORT_ELEMENT ); // add stores ports of EndSwitch
+
+ theNode = aINode; // init out-parameters
+ theEndNode = aESNode;
+ return true;
+ }
+ default: // wrong kind of node error
+ QAD_MessageBox::error1( (QWidget*)QAD_Application::getDesktop(), tr( "ERROR" ), tr( "MSG_ERROR_IMPORT_BAD_KIND_OF_NODE" ), tr( "OK" ) );
+ return false;
+ } // switch ( kind_of_node )
+ } // if ( index >= 0...)
+ else {
+ QAD_MessageBox::error1( (QWidget*)QAD_Application::getDesktop(), tr( "ERROR" ), tr( "MSG_ERROR_IMPORT_BAD_INDEX" ), tr( "OK" ) );
+ }
+ } // if ( getNodes() )
+ else {
+ return false; // no MB, getNodes() in case of errors displays MB itself
+ }
+ } // try
+ catch ( ... ) {