+void SUPERVGUI_Service::addMacroNode() {
+ SUPERVGUI_Main* aMain = Supervision.getMain();
+ if (aMain==0) {
+ QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NO_SUPERVISION_WINDOW"));
+ } else if (!aMain->isEditable()) {
+ QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_CREATE_NODE"));
+ } else {
+ if (myMFile) {
+ SUPERV_Graph aNode;
+ if (aMain->getDataflow()->IsStreamGraph()) {
+ SUPERV_StreamGraph aSGraph = aMain->getDataflow()->ToStreamGraph();
+ if (!SUPERV_isNull(aSGraph))
+ aNode = aSGraph->StreamMNode(myMFile->name().latin1());
+ // TMP: while stream macro nodes doesn't impemented
+ if (CORBA::is_nil(aNode)) {
+ aNode = aSGraph->MNode(myMFile->name().latin1());
+ }
+ }
+ else
+ aNode = aMain->getDataflow()->MNode(myMFile->name().latin1());
+ if (CORBA::is_nil(aNode)) {
+ QMessageBox::warning(0, tr("ERROR"), tr("MSG_CANT_CREATE_NODE"));
+ return;
+ }
+ //to appear a new node in the top-left corner of the current viewport
+ int cx, cy;
+ aMain->getCanvasView()->viewportToContents(myX, myY, cx, cy);
+ aNode->Coords(cx, cy);
+ myX += NODE_DX;
+ myY += NODE_DY;
+ aMain->addMacroNode(SUPERV::CNode::_narrow(aNode));
+ }
+ else {
+ QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NONODE_TOADD"));
+ }
+ }
+}
+
+void SUPERVGUI_Service::loadGraph() {
+ if ( getenv( "ENABLE_MACRO_NODE" ) == NULL )
+ // error! if ENABLE_MACRO_NODE is set - we should NOT get here by any means..
+ {
+ //MESSAGE("Error: ENABLE_MACRO_NODE is not set, but loadGraph() was called!");
+ return;
+ }
+
+ QString aFileName = QAD_FileDlg::getFileName(QAD_Application::getDesktop(),
+ "",
+ "*.xml",
+ tr("MSG_GRAPH_INSERT"),
+ true);
+ if (aFileName.isEmpty()) return;
+
+ myMacroPane->clear();
+
+ myMFile = new QFile(aFileName);
+ if (!myMFile->open(IO_ReadOnly)) {
+ QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"),
+ tr("MSG_CANT_LOADSCRIPT"));
+ delete myMFile; myMFile = 0;
+ return;
+ }
+
+ QTextStream* aStream = new QTextStream(myMFile);
+ if (aStream->atEnd()) {
+ QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"),
+ tr("MSG_EMTY_FILE"));
+ delete aStream;
+ myMFile->close();
+ delete myMFile; myMFile = 0;
+ return;
+ }