using namespace std;
#include "SUPERVGUI_Service.h"
#include "SUPERVGUI_Main.h"
+#include "SUPERVGUI_Library.h"
#include "SUPERVGUI.h"
#include "QAD_Tools.h"
#include "QAD_FileDlg.h"
myStackWidget = new QWidgetStack(aPythonPane);
// other pane
- myScriptPane = new SUPERVGUI_PythonEditPane(myStackWidget);
+ myScriptPane = new SUPERVGUI_PythonEditPane( myStackWidget, true );
myOtherId = myStackWidget->addWidget(myScriptPane);
// loop pane
QTabWidget* aLoopTabPane = new QTabWidget(myStackWidget);
- myInitPane = new SUPERVGUI_PythonEditPane(myStackWidget);
+ myInitPane = new SUPERVGUI_PythonEditPane( myStackWidget, true );
aLoopTabPane->addTab(myInitPane, "Init");
- myMorePane = new SUPERVGUI_PythonEditPane(myStackWidget);
+ myMorePane = new SUPERVGUI_PythonEditPane( myStackWidget, true );
aLoopTabPane->addTab(myMorePane, "More");
- myNextPane = new SUPERVGUI_PythonEditPane(myStackWidget);
+ myNextPane = new SUPERVGUI_PythonEditPane( myStackWidget, true );
aLoopTabPane->addTab(myNextPane, "Next");
myLoopId = myStackWidget->addWidget(aLoopTabPane);
myTabPane->addTab(aPythonPane, tr("INLINE_PANE"));
// Create Tab for Macro node only if environmental variable ENABLE_MACRO_NODE is set
- if ( getenv( "ENABLE_MACRO_NODE" ) != NULL )
- {
- QWidget* aMacroPane = new QWidget(myTabPane);
- QVBoxLayout* aMacroLayout = new QVBoxLayout(aMacroPane, 0, 4);
- aMacroLayout->setMargin(5);
- aMacroLayout->setSpacing(10);
-
- QHBoxLayout* aLoadLayout = new QHBoxLayout(aMacroPane); //!!
- aLoadLayout->addStretch();
-
- QPushButton* aLoadBtn = new QPushButton(tr("BUT_LOAD"), aMacroPane);
- connect(aLoadBtn, SIGNAL(clicked()), this, SLOT(loadGraph()));
+ if ( getenv( "ENABLE_MACRO_NODE" ) != NULL ) {
+ QWidget* aMacroPane = new QWidget(myTabPane);
+ QVBoxLayout* aMacroLayout = new QVBoxLayout(aMacroPane, 0, 4);
+ aMacroLayout->setMargin(5);
+ aMacroLayout->setSpacing(10);
+
+ QHBoxLayout* aLoadLayout = new QHBoxLayout(aMacroPane); //!!
+ aLoadLayout->addStretch();
+
+ QPushButton* aLoadBtn = new QPushButton(tr("BUT_LOAD"), aMacroPane);
+ connect(aLoadBtn, SIGNAL(clicked()), this, SLOT(loadGraph()));
- aLoadLayout->addWidget(aLoadBtn);
+ aLoadLayout->addWidget(aLoadBtn);
- aMacroLayout->addLayout(aLoadLayout);
+ aMacroLayout->addLayout(aLoadLayout);
- myMacroPane = new QListView(aMacroPane);
- myMacroPane->addColumn(tr("COL_COMPONENTS"));
- myMacroPane->addColumn(tr("COL_PORTTYPE"));
- myMacroPane->addColumn(tr("COL_PORTWAY"));
- myMacroPane->setColumnAlignment(1, AlignLeft);
- myMacroPane->setColumnAlignment(2, AlignLeft);
- myMacroPane->setColumnAlignment(3, AlignLeft);
- myMacroPane->setSelectionMode(QListView::Extended);
- myMacroPane->setRootIsDecorated(true);
- aMacroLayout->addWidget(myMacroPane); //!!
-
- QPushButton* aAddBtn = new QPushButton(tr("TIT_ADDFNODE"), aMacroPane);
- connect(aAddBtn, SIGNAL(clicked()), this, SLOT(addMacroNode()));
- aAddBtn->setDefault(true);
-
- aMacroLayout->addWidget(aAddBtn);
-
- myTabPane->addTab(aMacroPane, tr("MACRO_PANE"));
- }
+ myMacroPane = new QListView(aMacroPane);
+ myMacroPane->addColumn(tr("COL_COMPONENTS"));
+ myMacroPane->addColumn(tr("COL_PORTTYPE"));
+ myMacroPane->addColumn(tr("COL_PORTWAY"));
+ myMacroPane->setColumnAlignment(1, AlignLeft);
+ myMacroPane->setColumnAlignment(2, AlignLeft);
+ myMacroPane->setColumnAlignment(3, AlignLeft);
+ myMacroPane->setSelectionMode(QListView::Extended);
+ myMacroPane->setRootIsDecorated(true);
+ aMacroLayout->addWidget(myMacroPane); //!!
+
+ QPushButton* aAddBtn = new QPushButton(tr("TIT_ADDFNODE"), aMacroPane);
+ connect(aAddBtn, SIGNAL(clicked()), this, SLOT(addMacroNode()));
+ aAddBtn->setDefault(true);
+
+ aMacroLayout->addWidget(aAddBtn);
+ myTabPane->addTab(aMacroPane, tr("MACRO_PANE"));
+ }
+
aMainLayout->addWidget(myTabPane);
// Close button
const char* interface = item->parent()->text(0).latin1();
const char* component = item->parent()->parent()->text(0).latin1();
SALOME_ModuleCatalog::Acomponent_ptr myComponent = (*aModuleCatalog)->GetComponent(aDesktop->getComponentName(component));
- if (myComponent==NULL) {
+ if ( myComponent == NULL ) {
QMessageBox::warning(aDesktop, tr("ERROR"), tr("MSG_CANT_CHOOSE_SERVICE"));
- } else {
+ }
+ else {
const SALOME_ModuleCatalog::Service* myService = myComponent->GetService(interface, service);
- b = true;
-
- SUPERV_CNode node = aMain->getDataflow()->CNode(*myService);
- if (CORBA::is_nil(node)) {
+ SUPERV_CNode aNode = aMain->getDataflow()->CNode(*myService);
+ if ( CORBA::is_nil( aNode ) ) {
QMessageBox::warning(aDesktop, 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;
- //2.8 point of improvements: Adding node to graph window with taking into account zoom factor
- QWMatrix aWM = aMain->getCanvasView()->worldMatrix();
- aMain->getCanvasView()->viewportToContents(myX, myY, cx, cy);
- //2.8 point of improvements:
- cx = (int)((double)cx/aWM.m11());
- cy = (int)((double)cy/aWM.m22());
- node->Coords(cx, cy);
- myX += (int)(NODE_DX*aWM.m11());
- myY += (int)(NODE_DY*aWM.m22());
- aMain->addComputeNode(SUPERV::CNode::_narrow(node));
+
+ SUPERV::INode_var aDummyEndNode;
+ addNode( aNode, aDummyEndNode, myX, myY );
+ b = true; // at least one node was added
}
}
}
- if (!b) {
+ if ( !b ) {
QMessageBox::warning(aDesktop, tr("WARNING"), tr("MSG_NONODE_TOADD"));
}
}
SALOME_ModuleCatalog::Acomponent_ptr myComponent = (*aModuleCatalog)->GetComponent(component);
if (myComponent==NULL) {
QMessageBox::warning(aDesktop, tr("ERROR"), tr("MSG_CANT_CHOOSE_SERVICE"));
- } else {
+ }
+ else {
const SALOME_ModuleCatalog::Service* myService = myComponent->GetService(interface, service);
- b = true;
-
- MESSAGE ( " myService->TypeOfNode == " << myService->TypeOfNode )
-
- int cx, cy;
-
- //2.8 point of improvements: Adding node to graph window with taking into account zoom factor
- QWMatrix aWM = aMain->getCanvasView()->worldMatrix();
-
+ SUPERV_CNode aNode;
if ( myService->TypeOfNode == 0 ) { // ComputeNode
- SUPERV_CNode node = aMain->getDataflow()->CNode(*myService);
- if (CORBA::is_nil(node)) {
+ aNode = aMain->getDataflow()->CNode(*myService);
+ if (CORBA::is_nil( aNode ) ) {
QMessageBox::warning(aDesktop, tr("ERROR"), tr("MSG_CANT_CREATE_NODE"));
return;
}
- //to appear a new node in the top-left corner of the current viewport
- aMain->getCanvasView()->viewportToContents(myX, myY, cx, cy);
- //2.8 point of improvements:
- cx = (int)((double)cx/aWM.m11());
- cy = (int)((double)cy/aWM.m22());
- node->Coords(cx, cy);
- myX += (int)(NODE_DX*aWM.m11());
- myY += (int)(NODE_DY*aWM.m22());
- aMain->addComputeNode(SUPERV::CNode::_narrow(node));
- } else { // Factory Node
- SUPERV_FNode node = aMain->getDataflow()->FNode(component, interface, *myService);
- if (CORBA::is_nil(node)) {
+ }
+ else { // Factory Node
+ aNode = aMain->getDataflow()->FNode(component, interface, *myService);
+ if ( CORBA::is_nil( aNode ) ) {
QMessageBox::warning(aDesktop, tr("ERROR"), tr("MSG_CANT_CREATE_NODE"));
return;
}
- //to appear a new node in the top-left corner of the current viewport
- aMain->getCanvasView()->viewportToContents(myX, myY, cx, cy);
- //2.8 point of improvements:
- cx = (int)((double)cx/aWM.m11());
- cy = (int)((double)cy/aWM.m22());
- node->Coords(cx, cy);
- myX += (int)(NODE_DX*aWM.m11());
- myY += (int)(NODE_DY*aWM.m22());
- aMain->addComputeNode(SUPERV::CNode::_narrow(node));
-
}
+ SUPERV::INode_var aDummyEndNode;
+ addNode( aNode, aDummyEndNode, myX, myY );
+ b = true;
}
}
}
- if (!b) {
+ if ( !b ) {
QMessageBox::warning(aDesktop, tr("WARNING"), tr("MSG_NONODE_TOADD"));
}
}
SUPERVGUI_Main* aMain = Supervision.getMain();
if (aMain==0) {
QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NO_SUPERVISION_WINDOW"));
- } else if (!aMain->isEditable()) {
+ }
+ else if (!aMain->isEditable()) {
QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_CREATE_NODE"));
- } else {
+ }
+ else {
int aSel = myTypeCombo->currentItem();
- int cx, cy;
-
- //2.8 point of improvements: Adding node to graph window with taking into account zoom factor
- QWMatrix aWM = aMain->getCanvasView()->worldMatrix();
-
switch (aSel) {
case 0: // Computation
{
- SUPERV_INode aNode = aMain->getDataflow()->INode(myScriptPane->getFuncName().latin1(),
+ SUPERV_CNode aNode = aMain->getDataflow()->INode(myScriptPane->getFuncName().latin1(),
(myScriptPane->getFunction()).in());
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
- aMain->getCanvasView()->viewportToContents(myX, myY, cx, cy);
- //2.8 point of improvements:
- cx = (int)((double)cx/aWM.m11());
- cy = (int)((double)cy/aWM.m22());
- aNode->Coords(cx, cy);
- myX += (int)(NODE_DX*aWM.m11());
- myY += (int)(NODE_DY*aWM.m22());
- aMain->addComputeNode(SUPERV::CNode::_narrow(aNode));
+ SUPERV::INode_var aDummyEndNode;
+ addNode( aNode, aDummyEndNode, myX, myY );
}
break;
case 1: // Switch
{
SUPERV_INode aEndNode;
- SUPERV_SNode aStartNode = aMain->getDataflow()->SNode(myScriptPane->getFuncName().latin1(),
+ SUPERV_CNode aStartNode = aMain->getDataflow()->SNode(myScriptPane->getFuncName().latin1(),
(myScriptPane->getFunction()).in(),
aEndNode);
if (CORBA::is_nil(aStartNode) || CORBA::is_nil(aEndNode)) {
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
- aMain->getCanvasView()->viewportToContents(myX, myY, cx, cy);
- //2.8 point of improvements:
- cx = (int)((double)cx/aWM.m11());
- cy = (int)((double)cy/aWM.m22());
- aStartNode->Coords(cx, cy);
- aEndNode->Coords(cx + LABEL_WIDTH*2, cy);
- myX += (int)(NODE_DX*aWM.m11());
- myY += (int)(NODE_DY*aWM.m22());
- aMain->addControlNode(SUPERV::CNode::_narrow(aStartNode), SUPERV::CNode::_narrow(aEndNode), true);
+ addNode( aStartNode, aEndNode, myX, myY );
}
break;
case 2: // Loop
{
SUPERV_INode aEndNode;
- SUPERV_LNode aStartNode = aMain->getDataflow()->LNode(myInitPane->getFuncName().latin1(), (myInitPane->getFunction()).in(),
+ SUPERV_CNode aStartNode = aMain->getDataflow()->LNode(myInitPane->getFuncName().latin1(), (myInitPane->getFunction()).in(),
myMorePane->getFuncName().latin1(), (myMorePane->getFunction()).in(),
myNextPane->getFuncName().latin1(), (myNextPane->getFunction()).in(),
aEndNode);
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
- aMain->getCanvasView()->viewportToContents(myX, myY, cx, cy);
- //2.8 point of improvements:
- cx = (int)((double)cx/aWM.m11());
- cy = (int)((double)cy/aWM.m22());
- aStartNode->Coords(cx, cy);
- aEndNode->Coords(cx + LABEL_WIDTH*2, cy);
- myX += (int)(NODE_DX*aWM.m11());
- myY += (int)(NODE_DY*aWM.m22());
- aMain->addControlNode(SUPERV::CNode::_narrow(aStartNode), SUPERV::CNode::_narrow(aEndNode), true);
+ addNode( aStartNode, aEndNode, myX, myY );
}
break;
case 3: // GoTo
{
- SUPERV_GNode aGotoNode;
+ SUPERV_CNode aGotoNode;
if (myScriptPane->isDefined())
aGotoNode = aMain->getDataflow()->GNode(myScriptPane->getFuncName().latin1(),
(myScriptPane->getFunction()).in(), "");
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
- aMain->getCanvasView()->viewportToContents(myX, myY, cx, cy);
- //2.8 point of improvements:
- cx = (int)((double)cx/aWM.m11());
- cy = (int)((double)cy/aWM.m22());
- aGotoNode->Coords(cx, cy);
- myX += (int)(NODE_DX*aWM.m11());
- myY += (int)(NODE_DY*aWM.m22());
- aMain->addGOTONode(SUPERV::GNode::_narrow(aGotoNode));
+ SUPERV::INode_var aDummyEndNode;
+ addNode( aGotoNode, aDummyEndNode, myX, myY );
}
break;
}
SUPERVGUI_Main* aMain = Supervision.getMain();
if (aMain==0) {
QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NO_SUPERVISION_WINDOW"));
- } else if (!aMain->isEditable()) {
+ }
+ else if (!aMain->isEditable()) {
QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_CREATE_NODE"));
- } else {
- if (myMFile) {
- SUPERV_Graph aNode;
+ }
+ else {
+ if ( myMFile ) {
+ SUPERV_CNode aNode;
if (aMain->getDataflow()->IsStreamGraph()) {
SUPERV_StreamGraph aSGraph = aMain->getDataflow()->ToStreamGraph();
if (!SUPERV_isNull(aSGraph))
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;
- //2.8 point of improvements: Adding node to graph window with taking into account zoom factor
- QWMatrix aWM = aMain->getCanvasView()->worldMatrix();
- aMain->getCanvasView()->viewportToContents(myX, myY, cx, cy);
- //2.8 point of improvements:
- cx = (int)((double)cx/aWM.m11());
- cy = (int)((double)cy/aWM.m22());
- aNode->Coords(cx, cy);
- myX += (int)(NODE_DX*aWM.m11());
- myY += (int)(NODE_DY*aWM.m22());
- aMain->addMacroNode(SUPERV::CNode::_narrow(aNode));
+
+ SUPERV::INode_var aDummyEndNode;
+ addNode( aNode, aDummyEndNode, myX, myY );
}
else {
QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NONODE_TOADD"));
//*****************************************************
// Pane for Python script editing
//*****************************************************
-SUPERVGUI_PythonEditPane::SUPERVGUI_PythonEditPane(QWidget* theParent)
- : QFrame(theParent)
+SUPERVGUI_PythonEditPane::SUPERVGUI_PythonEditPane( QWidget* theParent, const bool isNodeCreation )
+ : myIsWithLibrary( isNodeCreation ),
+ QFrame( theParent )
{
- QGridLayout* aEditLayout = new QGridLayout(this, 2, 4);
+ QGridLayout* aEditLayout = new QGridLayout( this, 2, 8, 0, 6 );
// First row
+ if ( myIsWithLibrary ) {
+ QPushButton* aLibBtn = new QPushButton(tr("BUT_LIBRARY"), this);
+ connect(aLibBtn, SIGNAL(clicked()), this, SLOT(library()));
+ aEditLayout->addMultiCellWidget( aLibBtn, 0, 0, 1, 2 );
+ }
+
QPushButton* aLoadBtn = new QPushButton(tr("BUT_LOAD"), this);
connect(aLoadBtn, SIGNAL(clicked()), this, SLOT(loadFile()));
- aEditLayout->addWidget(aLoadBtn, 0, 2);
+ aEditLayout->addMultiCellWidget( aLoadBtn, 0, 0, 3, 4 );
- myNextBtn = new QPushButton(tr("BUT_NEXT"), this);
- myNextBtn->setEnabled(false);
- connect(myNextBtn, SIGNAL(clicked()), this, SLOT(readFunction()));
+ myFunctionsCombo = new QComboBox( this );
+ connect( myFunctionsCombo, SIGNAL( activated( int ) ), this, SLOT( readFunction( int ) ) );
- aEditLayout->addWidget(myNextBtn, 0, 3);
+ aEditLayout->addMultiCellWidget( myFunctionsCombo, 0, 0, 5, 7 );
//Second row
myText = new QTextEdit(this);
- myText->setWordWrap(QTextEdit::FixedColumnWidth);
- myText->setWrapColumnOrWidth(80);
+ myText->setTextFormat( Qt::PlainText ); // NOT rich text, so text() returns plain text
+ myText->setWordWrap( QTextEdit::FixedColumnWidth );
+ myText->setWrapColumnOrWidth( 80 );
connect( myText, SIGNAL( returnPressed() ), this, SLOT( autoIndentLine() ) );
- aEditLayout->addMultiCellWidget(myText, 1, 1, 0, 3);
+ aEditLayout->addMultiCellWidget( myText, 1, 1, 0, 7 );
+ //aEditLayout->setColStretch( 3, 1 ); // to allow myFunctionsCombo be larger when needed
+}
+
+/**
+ * Return a text between "def" and "("
+ * "def" must begin with position 0, which means that only global function definitions are possible
+ */
+QString getFunctionName( const QString& aLine ) {
+ int aDefPos = aLine.find("def");
+ if ( aDefPos == 0 ) { // only global function definitions!
+ int aStart = aLine.find(" ", aDefPos);
+ int aEnd = aLine.find("(", aStart);
+ QString aName = aLine.mid(aStart, (aEnd-aStart));
+ return aName.stripWhiteSpace();
+ }
+ return QString();
}
/**
aLine = theStream.readLine();
if ( !aLine.isNull() && aLine.find("def") == 0 ) {
+ myFunctionsCombo->insertItem( getFunctionName( aLine ) ); // aLine now == function name
+
aPyFunction += aLine;
aPyFunction += '\n';
aLine = theStream.readLine();
// asv : 23.11.04 : added "|| aLine.isEmpty()" - fix for PAL6870. readLine() returns an empty
// string for "\n" string, it trails \n caracter. but we accept such lines..
- while ( !aLine.isNull() && ( aLine.isEmpty() || aLine[0].isSpace() ) ) {
+ // asv : 22.12.04 : aLine[0].isSpace() || aLine[0]=='#' -> line must begin with space or tab
+ // (a normal code with indentation) or comment sign.
+ while ( !aLine.isNull() && ( aLine.isEmpty() || aLine[0].isSpace() || aLine[0] == '#' ) ) {
aPyFunction += aLine;
aPyFunction += '\n';
aLine = theStream.readLine();
}
myPyFunctions.clear();
- myPyIndex = -1;
- myNextBtn->setEnabled( false );
+ myFunctionsCombo->clear();
myText->clear();
QTextStream aFileReader(&aFile);
initPyFunctions( aFileReader );
- if ( myPyFunctions.size() ) {
- myNextBtn->setEnabled( true );
- myPyIndex = 0;
- readFunction();
- }
+ if ( myPyFunctions.size() )
+ readFunction( 0 );
}
/**
* asv : Comment above is old! Present model: just take an already read string = PyFunction
* from the list which is filled in loadFile().
*/
-void SUPERVGUI_PythonEditPane::readFunction() {
+void SUPERVGUI_PythonEditPane::readFunction( int i ) {
myText->clear();
- if ( myPyIndex != -1 && myPyFunctions.size() && myPyFunctions.size() > myPyIndex )
- myText->append( myPyFunctions[ myPyIndex++ ] );
- if ( myPyFunctions.size() <= myPyIndex ) // last index was reached
- myNextBtn->setEnabled( false );
+ if ( i != -1 && myPyFunctions.size() && myPyFunctions.size() > i )
+ myText->append( myPyFunctions[ i ] );
+
+ // asv : 30.11.04 : 2.7 - Inline node function editor improvement
+ // 2.7.1 - set focus to editor widget on editor window opening
+ // 2.7.2 - scroll to the beginning of function on editor window opening
+ myText->setFocus();
+ myText->ensureVisible( 0,0 );
}
/**
* Returns the text after "def" and before "(" -- first defined function name
*/
QString SUPERVGUI_PythonEditPane::getFuncName() {
- QString aName("");
for (int i=0; i < myText->paragraphs(); i++) {
- QString aLine = myText->text(i);
- int aDefPos = aLine.find("def");
- if (aDefPos == 0) {
- int aStart = aLine.find(" ", aDefPos);
- int aEnd = aLine.find("(", aStart);
- QString aName = aLine.mid(aStart, (aEnd-aStart));
- return aName.stripWhiteSpace();
- }
+ QString aName = getFunctionName( myText->text(i) );
+ if ( !aName.isEmpty() )
+ return aName;
}
- return aName;
+ return QString();
}
/**
void SUPERVGUI_PythonEditPane::setFunction(SUPERV_Strings theStr) {
- int aLen = theStr->length();
- for (int i=0; i < aLen; i++)
+ myText->clear();
+ for ( int i=0, aLen = theStr->length(); i < aLen; i++ )
myText->append(QString(theStr[i]));
// asv : 30.11.04 : 2.7 - Inline node function editor improvement
}
}
+/**
+ * Create a node by loading it from an external XML library file
+ * This slot opens a dialog box which then "lives" by itself..
+ */
+void SUPERVGUI_PythonEditPane::library() {
+ SUPERVGUI_LibDlg* aDlg = new SUPERVGUI_LibDlg( this );
+ aDlg->exec();
+}
/*!
* Edit Python dialog
*/
-SUPERVGUI_EditPythonDlg::SUPERVGUI_EditPythonDlg(bool isLoop)
- :QDialog(QAD_Application::getDesktop(), 0, true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
+SUPERVGUI_EditPythonDlg::SUPERVGUI_EditPythonDlg( bool isLoop )
+ :QDialog(QAD_Application::getDesktop(), 0, true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
{
setSizeGripEnabled( true );
setCaption(tr("TIT_FUNC_PYTHON"));
QVBoxLayout* aMainLayout = new QVBoxLayout(this, 7, 4);
if (isLoop) {
QTabWidget* aLoopTabPane = new QTabWidget(this);
- myInitPane = new SUPERVGUI_PythonEditPane(this);
+ myInitPane = new SUPERVGUI_PythonEditPane( this, false ); // library == false, since no creation of a node is needed here
aLoopTabPane->addTab(myInitPane, "Init");
- myMorePane = new SUPERVGUI_PythonEditPane(this);
+ myMorePane = new SUPERVGUI_PythonEditPane( this, false );
aLoopTabPane->addTab(myMorePane, "More");
- myNextPane = new SUPERVGUI_PythonEditPane(this);
+ myNextPane = new SUPERVGUI_PythonEditPane( this, false );
aLoopTabPane->addTab(myNextPane, "Next");
aMainLayout->addWidget(aLoopTabPane);
} else {
- myEditPane = new SUPERVGUI_PythonEditPane(this);
+ myEditPane = new SUPERVGUI_PythonEditPane( this, false );
aMainLayout->addWidget(myEditPane);
}
QGroupBox* aBtnBox = new QGroupBox( this );
aMainLayout->addWidget(aBtnBox);
}
+
+/**
+ * Do the following actions for newly created Engine's CNode:
+ * 1. Create a presentation for it (CanvasNode)
+ * 2. Place the CanvasNode to the current top-left corner or the current viewport
+ * 3. Increment the coordinates of the next CanvasNode (new nodes are "cascaded" when several of them are created at once)
+ * PS theEndNode is passed only for Loop and Switch nodes (EndLoop and EndSwitch)
+ */
+void SUPERVGUI_Service::addNode( SUPERV::CNode_var theNode, SUPERV::INode_var theEndNode, int& theX, int& theY ) {
+ if ( !CORBA::is_nil( theNode ) ) {
+ int cx, cy; //to appear a new node in the top-left corner of the current viewport
+ SUPERVGUI_Main* aMain = Supervision.getMain();
+
+ //2.8 point of improvements: Adding node to graph window with taking into account zoom factor
+ QWMatrix aWM = aMain->getCanvasView()->worldMatrix();
+ aMain->getCanvasView()->viewportToContents(theX, theY, cx, cy);
+
+ //2.8 point of improvements:
+ cx = (int)((double)cx/aWM.m11());
+ cy = (int)((double)cy/aWM.m22());
+ theNode->Coords(cx, cy);
+ if ( !CORBA::is_nil( theEndNode ) )
+ theEndNode->Coords(cx + LABEL_WIDTH*2, cy);
+ theX += (int)(NODE_DX*aWM.m11());
+ theY += (int)(NODE_DY*aWM.m22());
+
+ if ( theNode->IsGOTO() )
+ aMain->addGOTONode( theNode );
+ else if ( theNode->IsMacro() )
+ aMain->addMacroNode( theNode );
+ else if ( theNode->IsLoop() || theNode->IsSwitch() )
+ aMain->addControlNode( theNode, SUPERV::CNode::_narrow( theEndNode ), true );
+ else
+ aMain->addComputeNode( theNode );
+ }
+}
+