&& getNodeType() != SUPERV::EndSwitchNode) {
popup->insertItem(tr("MSG_RENAME"), this, SLOT(rename()));
myDeleteItem = popup->insertItem(tr("MSG_DELETE"), this, SLOT(remove()));
+ // Copy Node functionality
+ popup->insertItem(tr("ITM_COPY_NODE"), this, SLOT(copy()));
popup->insertSeparator();
}
popup->insertItem(tr("MSG_BROWSE"), this, SLOT(browse()));
addPortMenu->insertItem( tr( "MNU_OUTPUT" ), this, SLOT(addOutputPort()));
popup->insertItem( tr( "MNU_ADD_PORT" ), addPortMenu);
+
+ // Paste Port functionality
+ int aPasteItem = popup->insertItem(tr("ITM_PASTE_PORT"), this, SLOT(pastePort()));
+ if (SUPERV_isNull(myMain->getCopyPort()) || !(myMain->getCopyPort()))
+ popup->setItemEnabled(aPasteItem, false);
+ else if (getNodeType() == SUPERV::LoopNode && !myMain->getCopyPort()->IsInput())
+ popup->setItemEnabled(aPasteItem, false);
+
popup->insertItem( tr( "MNU_MANAGE_PORTS" ), this, SLOT(managePorts()));
}
if ( getNodeType() != SUPERV::FactoryNode &&
aCanvas->update();
}
+void SUPERVGUI_CanvasNode::copy() {
+ Trace("SUPERVGUI_CanvasNode::copy()");
+ //MESSAGE(" -> SUPERVGUI_CanvasNode::copy()");
+ getMain()->setCopyNode(getEngine());
+}
+
void SUPERVGUI_CanvasNode::suspendResume() {
Trace("SUPERVGUI_CanvasNode::suspendResume");
int n = queryList("SUPERVGUI_CanvasNode")->count();
}
}
+void SUPERVGUI_CanvasNode::pastePort()
+{
+ //MESSAGE(" -> SUPERVGUI_CanvasNode::pastePort()");
+
+ SUPERV_Port aPort = myMain->getCopyPort();
+ if (!SUPERV_isNull(aPort)) {
+ SUPERV_INode aNode = getInlineNode();
+ if (!SUPERV_isNull(aNode)) {
+ QString aName = aPort->Name();
+ QString aType = aPort->Type();
+ SUPERV_Port aPastePort;
+ if (aPort->IsInput()) {
+ //check if port with such name is alredy exists
+ QStringList aNames = getPortsNamesIN(aNode, true);
+ if (aNames.contains(aName))
+ QMessageBox::warning( QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_PORT_EXIST") );
+ else
+ aPastePort = aNode->InPort(aName.latin1(), aType.latin1());
+ }
+ else {
+ //check if port with such name is already exists
+ QStringList aNames = getPortsNamesIN(aNode, false);
+ if (aNames.contains(aName))
+ QMessageBox::warning( QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_PORT_EXIST") );
+ else
+ aPastePort = aNode->OutPort(aName.latin1(), aType.latin1());
+ }
+ if (!SUPERV_isNull(aPastePort))
+ createPort(aPastePort.in());
+ }
+ }
+}
+
/**
* Called on "Edit ports" popup menu command. See SUPERVGUI_ManagePortsDlg.h
* for detailed description of the functionality
myGUIEventLoopFinished( true )
{
Trace("SUPERVGUI_Main::SUPERVGUI_Main (copy)");
+ myCopyPort = 0;
+ myCopyNode = 0;
+ myXCopyNode = 0;
+ myYCopyNode = 0;
theParent->setViewWidget(this);
dataflow = theDataFlow;
if (SUPERV_isNull(dataflow)) {
Supervision.getBrowser()->choose();
}
+void SUPERVGUI_Main::pasteNode() {
+ Trace("SUPERVGUI_Main::pasteNode");
+ //MESSAGE(" -> SUPERVGUI_Main::pasteNode()");
+ SUPERV_CNode aNode = getCopyNode();
+ if (!SUPERV_isNull(aNode)) {
+
+ //collect all python functions names of allready exist InLine nodes
+ //in QStringList for automatic change of function's name on Paste of InLine node
+ QStringList aFuncNames;
+ SUPERV_Nodes nodes = dataflow->Nodes();
+ //InLine nodes
+ for(int i = 0; i < nodes->INodes.length(); i++)
+ aFuncNames.append(nodes->INodes[i]->PyFuncName());
+ //Loop nodes
+ for(int i = 0; i < nodes->LNodes.length(); i++) {
+ aFuncNames.append(nodes->LNodes[i]->PyInitName());
+ aFuncNames.append(nodes->LNodes[i]->PyMoreName());
+ aFuncNames.append(nodes->LNodes[i]->PyNextName());
+ }
+ //Switch nodes
+ for(int i = 0; i < nodes->SNodes.length(); i++)
+ aFuncNames.append(nodes->SNodes[i]->PyFuncName());
+ //GOTO nodes
+ for(int i = 0; i < nodes->GNodes.length(); i++)
+ aFuncNames.append(nodes->GNodes[i]->PyFuncName());
+
+ int id, fid;
+ QString aOriginalName;
+ //automatic change of function's name on Paste of InLine node
+ QString aFName;
+ SUPERV::ListOfStrings aFunc;
+ if (aNode->Kind() == SUPERV::InLineNode
+ ||
+ aNode->Kind() == SUPERV::GOTONode
+ ||
+ aNode->Kind() == SUPERV::SwitchNode) {
+ //original name of the function
+ aOriginalName = SUPERV::INode::_narrow(aNode)->PyFuncName();
+ id = 1; //increment index
+ aFName = aOriginalName + QString("_") + QString::number(id);
+ while (aFuncNames.contains(aFName))
+ aFName = aOriginalName + QString("_") + QString::number(id++);
+
+ //correct python function
+ aFunc = *SUPERV::INode::_narrow(aNode)->PyFunction();
+ for (int i=0; i < aFunc.length(); i++) {
+ fid = QString(aFunc[i]).find(aOriginalName);
+ if (fid >= 0)
+ aFunc[i] = QString(aFunc[i]).replace(fid, aOriginalName.length(), aFName);
+ }
+ }
+ QString aInitFName, aMoreFName, aNextFName;
+ SUPERV::ListOfStrings aInitFunc, aMoreFunc, aNextFunc;
+ if (aNode->Kind() == SUPERV::LoopNode) {
+ //original name of the Init function
+ aOriginalName = SUPERV::LNode::_narrow(aNode)->PyInitName();
+ id = 1; //increment index
+ aInitFName = aOriginalName + QString("_") + QString::number(id);
+ while (aFuncNames.contains(aInitFName))
+ aInitFName = aOriginalName + QString("_") + QString::number(id++);
+
+ //correct python Init function
+ aInitFunc = *SUPERV::LNode::_narrow(aNode)->PyInit();
+ for (int i=0; i < aInitFunc.length(); i++) {
+ fid = QString(aInitFunc[i]).find(aOriginalName);
+ if (fid >= 0)
+ aInitFunc[i] = QString(aInitFunc[i]).replace(fid, aOriginalName.length(), aInitFName);
+ }
+
+ //original name of the More function
+ aOriginalName = SUPERV::LNode::_narrow(aNode)->PyMoreName();
+ id = 1; //increment index
+ aMoreFName = aOriginalName + QString("_") + QString::number(id);
+ while (aFuncNames.contains(aMoreFName))
+ aMoreFName = aOriginalName + QString("_") + QString::number(id++);
+
+ //correct python More function
+ aMoreFunc = *SUPERV::LNode::_narrow(aNode)->PyMore();
+ for (int i=0; i < aMoreFunc.length(); i++) {
+ fid = QString(aMoreFunc[i]).find(aOriginalName);
+ if (fid >= 0)
+ aMoreFunc[i] = QString(aMoreFunc[i]).replace(fid, aOriginalName.length(), aMoreFName);
+ }
+
+ //original name of the Next function
+ aOriginalName = SUPERV::LNode::_narrow(aNode)->PyNextName();
+ id = 1; //increment index
+ aNextFName = aOriginalName + QString("_") + QString::number(id);
+ while (aFuncNames.contains(aNextFName))
+ aNextFName = aOriginalName + QString("_") + QString::number(id++);
+
+ //correct python Init function
+ aNextFunc = *SUPERV::LNode::_narrow(aNode)->PyNext();
+ for (int i=0; i < aNextFunc.length(); i++) {
+ fid = QString(aNextFunc[i]).find(aOriginalName);
+ if (fid >= 0)
+ aNextFunc[i] = QString(aNextFunc[i]).replace(fid, aOriginalName.length(), aNextFName);
+ }
+ }
+
+ int cx, cy;
+ //2.8 point of improvements: Adding node to graph window with taking into account zoom factor
+ QWMatrix aWM = myCanvasView->worldMatrix();
+ switch (aNode->Kind()) {
+ case 0: // Factory Node
+ {
+ SUPERV_FNode aFNode = dataflow->FNode(SUPERV::FNode::_narrow(aNode)->GetComponentName(),
+ SUPERV::FNode::_narrow(aNode)->GetInterfaceName(),
+ *SUPERV::FNode::_narrow(aNode)->Service());
+ if (SUPERV_isNull(aFNode)) {
+ QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_CREATE_NODE"));
+ return;
+ }
+
+ SUPERV_INode aDummyEndNode;
+ Supervision.getBrowser()->addNode(SUPERV::CNode::_narrow(aFNode), aDummyEndNode, myXCopyNode, myYCopyNode);
+ }
+ break;
+ case 2: // Computing Node
+ {
+ SUPERV_CNode aCNode = dataflow->CNode(*SUPERV::CNode::_narrow(aNode)->Service());
+ if (SUPERV_isNull(aCNode)) {
+ QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_CREATE_NODE"));
+ return;
+ }
+
+ SUPERV_INode aDummyEndNode;
+ Supervision.getBrowser()->addNode(aCNode, aDummyEndNode, myXCopyNode, myYCopyNode);
+ }
+ break;
+ case 3: //InLineNode
+ {
+ SUPERV_INode aINode = dataflow->INode(aFName,
+ aFunc);
+
+ if (SUPERV_isNull(aINode)) {
+ QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_CREATE_NODE"));
+ return;
+ }
+ //add all ports of coping node to the new node, which will be paste
+ SUPERV_Ports aPList = aNode->Ports();
+ QString aName, aType;
+ for (int i = 0; i < aPList->length(); i++) {
+ aName = aPList[i].in()->Name();
+ aType = aPList[i].in()->Type();
+ if (aPList[i].in()->IsInput())
+ aINode->InPort(aName.latin1(), aType.latin1());
+ else
+ aINode->OutPort(aName.latin1(), aType.latin1());
+ }
+
+ SUPERV_INode aDummyEndNode;
+ Supervision.getBrowser()->addNode(SUPERV::CNode::_narrow(aINode), aDummyEndNode, myXCopyNode, myYCopyNode);
+ }
+ break;
+ case 4: //LoopNode
+ {
+ SUPERV_INode aEndNode;
+ SUPERV_LNode aStartNode = dataflow->LNode(aInitFName,
+ aInitFunc,
+ aMoreFName,
+ aMoreFunc,
+ aNextFName,
+ aNextFunc,
+ aEndNode);
+ if (SUPERV_isNull(aStartNode) || SUPERV_isNull(aEndNode)) {
+ QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_CREATE_NODE"));
+ return;
+ }
+ //add all ports of coping node to the new node, which will be paste
+ SUPERV_Ports aPList = aNode->Ports();
+ QString aName, aType;
+ for (int i = 0; i < aPList->length(); i++) {
+ aName = aPList[i].in()->Name();
+ aType = aPList[i].in()->Type();
+ if (aPList[i].in()->IsInput())
+ aStartNode->InPort(aName.latin1(), aType.latin1());
+ else
+ aStartNode->OutPort(aName.latin1(), aType.latin1());
+ }
+
+ Supervision.getBrowser()->addNode(SUPERV::CNode::_narrow(aStartNode), aEndNode, myXCopyNode, myYCopyNode);
+ }
+ break;
+ case 6: //SwitchNode
+ {
+ SUPERV_INode aEndNode;
+ SUPERV_SNode aStartNode = dataflow->SNode(aFName,
+ aFunc,
+ aEndNode);
+ if (SUPERV_isNull(aStartNode) || SUPERV_isNull(aEndNode)) {
+ QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_CREATE_NODE"));
+ return;
+ }
+ //add all ports of coping start switch node to the new start node, which will be paste
+ SUPERV_Ports aPList = aNode->Ports();
+ QString aName, aType;
+ for (int i = 0; i < aPList->length(); i++) {
+ aName = aPList[i].in()->Name();
+ aType = aPList[i].in()->Type();
+ if (aPList[i].in()->IsInput())
+ aStartNode->InPort(aName.latin1(), aType.latin1());
+ else
+ aStartNode->OutPort(aName.latin1(), aType.latin1());
+ }
+ //add all ports of coping end switch node to the new end node, which will be paste
+ SUPERV_INode aNodeEnd = SUPERV::SNode::_narrow(aNode)->Coupled();
+ if (!SUPERV_isNull(aNodeEnd)) {
+ aPList = aNodeEnd->Ports();
+ for (int i = 0; i < aPList->length(); i++) {
+ //createPort(aPList[i].in());
+ aName = aPList[i].in()->Name();
+ aType = aPList[i].in()->Type();
+ if (aPList[i].in()->IsInput())
+ aEndNode->InPort(aName.latin1(), aType.latin1());
+ else
+ aEndNode->OutPort(aName.latin1(), aType.latin1());
+ }
+ }
+
+ Supervision.getBrowser()->addNode(SUPERV::CNode::_narrow(aStartNode), aEndNode, myXCopyNode, myYCopyNode);
+ }
+ break;
+ case 8: //GotoNode
+ {
+ SUPERV_GNode aGNode = dataflow->GNode(aFName,
+ aFunc, "");
+ if (SUPERV_isNull(aGNode)) {
+ QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_CREATE_NODE"));
+ return;
+ }
+ //add all ports of coping node to the new node, which will be paste
+ SUPERV_Ports aPList = aNode->Ports();
+ QString aName, aType;
+ for (int i = 0; i < aPList->length(); i++) {
+ aName = aPList[i].in()->Name();
+ aType = aPList[i].in()->Type();
+ if (aPList[i].in()->IsInput())
+ aGNode->InPort(aName.latin1(), aType.latin1());
+ else
+ aGNode->OutPort(aName.latin1(), aType.latin1());
+ }
+
+ SUPERV_INode aDummyEndNode;
+ Supervision.getBrowser()->addNode(SUPERV::CNode::_narrow(aGNode), aDummyEndNode, myXCopyNode, myYCopyNode);
+ }
+ break;
+ case 10: //MacroNode
+ {
+ /* to implement in the future */
+ /*
+ //get SubGraph from MacroNode
+ SUPERV_Graph aMacro = SUPERV::Graph::_narrow(aNode);
+ SUPERV_Graph aGraph;
+ if (aMacro->IsStreamMacro())
+ aGraph = aMacro->StreamObjRef();
+ else
+ aGraph = aMacro->FlowObjRef();
+ SUPERV_Graph aMacroNode = dataflow->GraphMNode(aGraph);
+
+ if (SUPERV_isNull(aMacroNode)) {
+ QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_CREATE_NODE"));
+ return;
+ }
+
+ SUPERV_INode aDummyEndNode;
+ Supervision.getBrowser()->addNode(SUPERV::CNode::_narrow(aMacroNode), aDummyEndNode, myXCopyNode, myYCopyNode);
+ */
+ }
+ break;
+ }
+ }
+}
+
/**
* Add Computation node
*/