+QPtrList< char * > SUPERVGUI_Main::getEventNodes() {
+ return myEventNodes;
+}
+
+void SUPERVGUI_Main::setEventNodes(QPtrList< char * > theEventNodes) {
+ myEventNodes = theEventNodes;
+}
+
+QPtrList< SUPERV::GraphState > SUPERVGUI_Main::getStates() {
+ return myStates;
+}
+
+void SUPERVGUI_Main::setStates(QPtrList< SUPERV::GraphState > theStates) {
+ myStates = theStates;
+}
+
+int SUPERVGUI_Main::getNodesNumber() {
+ //create a list of nodes of the graph
+ SUPERV_Nodes nodes = getDataflow()->Nodes();
+ int RetVal = nodes->CNodes.length() + nodes->FNodes.length() +
+ nodes->INodes.length() + nodes->GNodes.length() +
+ nodes->LNodes.length() + nodes->SNodes.length();
+ return RetVal;
+}
+
+SUPERVGUI_Thread* SUPERVGUI_Main::getMyThread() {
+ return myThread;
+}
+
+void SUPERVGUI_Main::startTimer() {
+ myTimer->start(500);
+}
+
+void SUPERVGUI_Main::executionFinished() {
+ getStudy()->updateObjBrowser();
+ myCanvas->update();
+ myArray->update();
+}
+
+void SUPERVGUI_Main::checkExecution() {
+ if (myThread->finished()) {
+ myTimer->stop();
+ executionFinished();
+ }
+}
+
+/**
+ * Editing() is to be called by any operation in GUI before modification of a datamodel
+ * (add/remove ports or nodes, etc.). It is used to resolve inconsistancies between 2 data models
+ * in Engine: Editor and Executor. During and after execution, the values of ports and statuses of nodes
+ * are taken from Executor data model. But when user starts editing the graph - these changes must
+ * be applied to Editor data model. This function destroys Executor data model and moves to Editor.
+ */
+void SUPERVGUI_Main::Editing() {
+ if ( !SUPERV_isNull( dataflow ) )
+ dataflow->Editing();
+
+ // updata GUI, Nodes' statuses and Ports' values could change.
+ sync();
+}
+
+void SUPERVGUI_Main::removeArrayChild(SUPERV::CNode_ptr theNode)
+{
+ // mkr: since the deletion of the node allow only in CANVAS view,
+ // it is necessary to remove the CanvasArray's children, which
+ // have the same CNode engine as deleting node. This CNode is given
+ // as argument
+ if (myArray) {
+ const QObjectList* aChList = myArray->children();
+ if ( aChList ) { // asv 27.01.05 : fix for 7817
+ QObjectListIt aItChList(*aChList);
+ SUPERVGUI_CanvasNode* anObjNode;
+ while ((anObjNode = (SUPERVGUI_CanvasNode*)aItChList.current()) != 0) {
+ ++aItChList;
+ if ((QString(anObjNode->getEngine()->Name())).compare(QString(theNode->Name())) == 0) {
+ myArray->removeChild(anObjNode);
+ delete anObjNode;
+ }
+ }
+ } // end of if ( ChList )
+ }
+}
+
+/**
+ * ReadyToModify() must be called before any modification
+ * operation - asks to kill execution of dataflow. If returns false -
+ * modification (==Editing() ) is not allowed.
+ */
+bool SUPERVGUI_Main::ReadyToModify() {
+ if ( CORBA::is_nil( dataflow ) )
+ return false;
+ if ( dataflow->IsExecuting() ) {
+ bool quit = QAD_MessageBox::warn2( QAD_Application::getDesktop(), // 0=Yes, 1=No
+ tr("WARNING"), tr("MSG_GRAPH_ISRUN"), tr( "BUT_YES" ), tr( "BUT_CANCEL" ), 0, 1, 0 );
+ if ( quit ) // user selected NOT to kill dataflow and NOT to add new node
+ return false;
+ else if ( dataflow->IsExecuting() ) // user selected to kill the dataflow and add new node after that
+ kill(); // checking again for IsExecuting to be sure that it was not finished while MB was up
+ }
+ return true;
+}
+
+/******************************* SUPERVGUI_Thread class ****************************************/
+SUPERVGUI_Thread::SUPERVGUI_Thread()
+ :QThread()
+{
+ myIsActive = false;
+}
+
+SUPERVGUI_Thread::~SUPERVGUI_Thread()
+{
+ //it is a virtual destructor and needs to be determine here
+}
+
+void SUPERVGUI_Thread::startThread(const char* m)
+{
+ if (!myIsActive) {
+ myIsActive = true;
+ start();
+ myMain->getMessage()->setMessage(m);
+ myMain->sync();
+ }
+}
+
+void SUPERVGUI_Thread::setMain( SUPERVGUI_Main* theMain )
+{
+ myMain = theMain;
+}
+
+void SUPERVGUI_Thread::KillThread( bool theValue )
+{
+ myMutex.lock();
+ myIsActive = !(theValue);
+ myMutex.unlock();
+}
+
+typedef TVoidMemFun2ArgEvent<SUPERVGUI_Main, char*, SUPERV::GraphState> TNodeSyncEvent;
+
+void SUPERVGUI_Thread::run()
+{
+ myMain->startTimer();
+
+ // GUI cycle to handle events coming for Engine
+ while ( myIsActive ) {
+
+ SUPERV_CNode aNode = NULL;
+ SUPERV::GraphEvent aEvent = SUPERV::UndefinedEvent ;
+ SUPERV::GraphState aState = SUPERV::UndefinedState ;
+
+ // blocking function of Engine. Return from there only after anEvent happens on node aNode
+ myMain->getDataflow()->Event(aNode, aEvent, aState);
+
+ // "kill" or undefined event came
+ if (( aEvent == SUPERV::UndefinedEvent && aState == SUPERV::UndefinedState ) ||
+ ( aEvent == SUPERV::NoEvent && aState == SUPERV::NoState ) ||
+ ( aEvent == SUPERV::KillEvent && aState == SUPERV::KillState )) {
+
+ myIsActive = false;
+ }
+ else { // a "normal" execution event came
+ char* aName = NULL;
+ if ( aNode != NULL && !CORBA::is_nil( aNode ) )
+ aName = aNode->Name();
+
+ // this function is asynchronious. The call does NOT wait when SUPERVGUI_Main::execute finishes
+ // handling the event. So: SUPERVGUI_Main::execute must be fast, in order we don't get here again
+ // on the next loop iteration, BEFORE previous SUPERVGUI_Main::execute finished.
+ ProcessVoidEvent( new TNodeSyncEvent( myMain, &SUPERVGUI_Main::execute, aName, aState ) );
+ }
+
+ // execution is finished. just set a "finished" message(s)
+ if ( !myIsActive ) {
+ switch ( myMain->getDataflow()->State() ) {
+ case SUPERV_Editing :
+ myMain->getMessage()->setMessage( myMain->getDataflow()->IsReadOnly()?
+ tr("MSG_GRAPH_READONLY"): tr("MSG_GRAPH_EDITING") );
+ break;
+ case SUPERV_Suspend :
+ myMain->getMessage()->setMessage( tr("MSG_GRAPH_SUSPENDED") );
+ break;
+ case SUPERV_Done :
+ myMain->getMessage()->setMessage( tr("MSG_GRAPH_FINISHED") );
+ break;
+ case SUPERV_Error :
+ myMain->getMessage()->setMessage( tr("MSG_GRAPH_ABORTED") );
+ break;
+ case SUPERV_Kill:
+ myMain->getMessage()->setMessage( tr("MSG_GRAPH_KILLED") );
+ break;
+ } // end of switch
+
+ // asv 03.02.05 : fix for PAL6859, not very good, but works..
+ myMain->sync();
+ } // end of if !myIsActive
+ } // end of while( myIsActive )
+
+ QThread::exit();
+}
+
+/******************************* SUPERVGUI_DSGraphParameters class ****************************************/
+/*!
+ Constructor
+*/
+SUPERVGUI_DSGraphParameters::SUPERVGUI_DSGraphParameters(SUPERV_Graph theGraph, bool isReadOnly)
+ : QDialog( QAD_Application::getDesktop(), "", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
+{
+ Trace("SUPERVGUI_DSGraphParameters::SUPERVGUI_DSGraphParameters");
+ setCaption( tr( "TLT_DSGRAPHPARAMS" ) );
+ setSizeGripEnabled( true );
+ myGraph = theGraph;
+
+ QGridLayout* TopLayout = new QGridLayout( this );
+ TopLayout->setSpacing( 6 );
+ TopLayout->setMargin( 11 );
+
+ QGroupBox* TopGroup = new QGroupBox( this, "TopGroup" );
+ TopGroup->setColumnLayout(0, Qt::Vertical );
+ TopGroup->layout()->setSpacing( 0 );
+ TopGroup->layout()->setMargin( 0 );
+ QGridLayout* TopGroupLayout = new QGridLayout( TopGroup->layout() );
+ TopGroupLayout->setAlignment( Qt::AlignTop );
+ TopGroupLayout->setSpacing( 6 );
+ TopGroupLayout->setMargin( 11 );
+
+ // DeltaTime
+ QLabel* DeltaTimeL = new QLabel( tr( "DELTATIME_LBL" ), TopGroup );
+ TopGroupLayout->addWidget( DeltaTimeL, 0, 0 );
+
+ myDeltaTime = new QAD_SpinBoxDbl( TopGroup, 0.0, 1.0, 0.1);
+ myDeltaTime->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+ TopGroupLayout->addWidget( myDeltaTime, 0, 1 );
+
+ // TimeOut
+ QLabel* TimeOutL = new QLabel( tr( "TIMEOUT_LBL" ), TopGroup);
+ TopGroupLayout->addWidget( TimeOutL, 1, 0 );
+
+ myTimeOut = new QLineEdit( TopGroup );
+ myTimeOut->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+ myTimeOut->setValidator( new QIntValidator(this) );
+ myTimeOut->setMinimumSize( 100, 0 );
+ myTimeOut->setReadOnly( isReadOnly );
+ TopGroupLayout->addWidget( myTimeOut, 1, 1 );
+
+ // DataStreamTrace
+ QLabel* DataStreamTraceL = new QLabel( tr( "DATASTREAMTRACE_LBL" ), TopGroup);
+ TopGroupLayout->addWidget( DataStreamTraceL, 2, 0 );
+
+ myDataStreamTrace = new QComboBox( TopGroup );
+ myDataStreamTrace->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+ myDataStreamTrace->insertItem("WithoutTrace");
+ myDataStreamTrace->insertItem("SummaryTrace");
+ myDataStreamTrace->insertItem("DetailedTrace");
+ TopGroupLayout->addWidget( myDataStreamTrace, 2, 1 );
+
+ QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
+ GroupButtons->setColumnLayout(0, Qt::Vertical );
+ GroupButtons->layout()->setSpacing( 0 );
+ GroupButtons->layout()->setMargin( 0 );
+ QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
+ GroupButtonsLayout->setAlignment( Qt::AlignTop );
+ GroupButtonsLayout->setSpacing( 6 );
+ GroupButtonsLayout->setMargin( 11 );
+
+ QPushButton* okB = new QPushButton( tr( "BUT_OK" ), GroupButtons );
+ QPushButton* cancelB = new QPushButton( tr( "BUT_CANCEL" ), GroupButtons );
+
+ GroupButtonsLayout->addWidget( okB, 0, 0 );
+ GroupButtonsLayout->addItem ( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
+ GroupButtonsLayout->addWidget( cancelB, 0, 2 );
+
+ TopLayout->addWidget( TopGroup, 0, 0 );
+ TopLayout->addWidget( GroupButtons, 1, 0 );
+
+ connect( okB, SIGNAL( clicked() ), this, SLOT( accept() ) );
+ connect( cancelB, SIGNAL( clicked() ), this, SLOT( reject() ) );
+
+ setData();
+}
+
+/*!
+ Destructor
+*/
+SUPERVGUI_DSGraphParameters::~SUPERVGUI_DSGraphParameters() {
+ Trace("SUPERVGUI_DSGraphParameters::~SUPERVGUI_DSGraphParameters");
+}
+
+/*!
+ Sets data function
+*/
+void SUPERVGUI_DSGraphParameters::setData() {
+ double aDeltaTime;
+ long aTimeOut;
+ SUPERV::KindOfDataStreamTrace aDataStreamTrace;
+
+// myGraph->StreamParams(aTimeOut, aDataStreamTrace, aDeltaTime);
+ if (myGraph->IsStreamGraph()) {
+ SUPERV_StreamGraph aSGraph = myGraph->ToStreamGraph();
+ if (!SUPERV_isNull(aSGraph))
+ aSGraph->StreamParams(aTimeOut, aDataStreamTrace, aDeltaTime);
+ }
+
+ myDeltaTime->setValue(aDeltaTime);
+ myTimeOut->setText(QString("%1").arg(aTimeOut));
+ myDataStreamTrace->setCurrentItem((int)aDataStreamTrace);
+}
+
+/*!
+ <OK> button slot
+*/
+void SUPERVGUI_DSGraphParameters::accept() {
+// myGraph->SetStreamParams( myTimeOut->text().toLong(),
+// (SUPERV::KindOfDataStreamTrace) myDataStreamTrace->currentItem(),
+// myDeltaTime->value());
+ if (myGraph->IsStreamGraph()) {
+ SUPERV_StreamGraph aSGraph = myGraph->ToStreamGraph();
+ if (!SUPERV_isNull(aSGraph))
+ aSGraph->SetStreamParams( myTimeOut->text().toLong(),
+ (SUPERV::KindOfDataStreamTrace) myDataStreamTrace->currentItem(),
+ myDeltaTime->value());
+ }
+ QDialog::accept();
+}