1 // SUPERV SUPERVGUI : GUI for Supervisor component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : SUPERVGUI_Main.cxx
25 // Author : Francis KLOSS
30 #include "SALOMEDSClient.hxx"
31 #include "SALOMEDS_Study.hxx"
32 #include "SALOMEDS_SObject.hxx"
33 #include <boost/shared_ptr.hpp>
34 using namespace boost;
36 #include "NOTIFICATION.hxx"
37 #include "SALOME_Event.hxx"
38 #include "SUPERVGraph_ViewFrame.h"
40 #include "LogWindow.h"
41 #include "OB_Browser.h"
42 #include "OB_ListItem.h"
43 #include "SalomeApp_Application.h"
44 #include "SalomeApp_ImportOperation.h"
45 #include "SalomeApp_Study.h"
46 #include "SUIT_FileDlg.h"
47 #include "SUIT_MessageBox.h"
48 #include "SUIT_Operation.h"
49 #include "SUIT_Session.h"
50 #include "SUIT_Study.h"
51 #include "QtxDblSpinBox.h"
53 #include "SUPERVGUI.h"
54 #include "SUPERVGUI_Def.h"
55 #include "SUPERVGUI_Main.h"
56 #include "SUPERVGUI_Notification.h"
57 #include "SUPERVGUI_Information.h"
58 #include "SUPERVGUI_CanvasControlNode.h"
59 #include "SUPERVGUI_CanvasPort.h"
61 #include <qvalidator.h>
65 #include <qlineedit.h>
66 #include <qcombobox.h>
68 SUPERVGUI_Main::SUPERVGUI_Main(SUPERVGraph_ViewFrame* theParent, SUIT_Desktop* theDesktop, SUPERV_Graph theDataFlow )
69 : SUPERVGraph_View(theParent),
72 myLogFileName( QString::null ),
80 Trace("SUPERVGUI_Main::SUPERVGUI_Main (copy)");
81 theParent->setViewWidget(this);
82 dataflow = theDataFlow;
83 if (SUPERV_isNull(dataflow)) {
84 QMessageBox::warning(0, tr("ERROR"), tr("MSG_CANT_COPY"));
91 void SUPERVGUI_Main::init(SUIT_Desktop* theDesktop) {
92 Trace("SUPERVGUI_Main::init");
93 SUIT_Application* anActApp = SUIT_Session::session()->activeApplication();
96 myNService = dynamic_cast<SalomeApp_Application*>( anActApp )->namingService();
102 myThread = new SUPERVGUI_Thread();
103 myThread->setMain(this);
105 myCurrentView = CANVAS;
106 myIsFromStudy = false;
108 study = anActApp->activeStudy();
110 //mkr: Supervision module already connected to the
111 //active study. So, we have to commented this code!
112 /*_PTR(Study) studyDoc = (( SalomeApp_Study* )study)->studyDS();
113 bool aLocked = studyDoc->GetProperties()->IsLocked();
114 _PTR(StudyBuilder) builder ( studyDoc->NewBuilder() );
115 _PTR(SComponent) father = studyDoc->FindComponent(STUDY_SUPERVISION);
117 SUIT_Operation* op = new SalomeApp_ImportOperation( study->application() );
119 if (aLocked) studyDoc->GetProperties()->SetLocked(false);
120 father = builder->NewComponent(STUDY_SUPERVISION);
121 _PTR(GenericAttribute) anAttr = builder->FindOrCreateAttribute(father, "AttributeName");
122 _PTR(AttributeName) aName ( anAttr );
123 aName->SetValue( dynamic_cast<CAM_Application*>( study->application() )->moduleTitle( "SUPERV" ).latin1() );
125 anAttr = builder->FindOrCreateAttribute(father, "AttributePixMap");
126 _PTR(AttributePixMap) aPixmap ( anAttr );
127 aPixmap->SetPixMap( "ICON_OBJBROWSER_Supervision" );
129 SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
131 MESSAGE("NULL Supervision module!");
135 builder->DefineComponentInstance(father, SalomeApp_Application::orb()->object_to_string(aSupMod->getEngine()));
136 //dynamic_cast<SALOMEDS_Study*>( studyDoc )->ConvertObjectToIOR(aSupMod->getEngine()));
137 if (aLocked) studyDoc->GetProperties()->SetLocked(true);
142 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( study->application() );
144 objectBrowser = app->objectBrowser();
146 myArray = new SUPERVGUI_CanvasArray( this, resMgr() );
147 myArrayView = new SUPERVGUI_ArrayView( myArray, this );
149 myCanvas = new SUPERVGUI_Canvas( this, resMgr() );
150 myCanvasView = new SUPERVGUI_CanvasView(myCanvas, this);
152 message = app->logWindow();
153 notification = new NOTIFICATION_Consumer();
155 QBoxLayout * layout = new QVBoxLayout(this);
156 layout->setMargin(0);
157 layout->setSpacing(0);
158 layout->addWidget(myCanvasView);
159 layout->addWidget(myArrayView);
161 if (myCurrentView == CANVAS || myCurrentView == CONTROLFLOW) {
167 if ( myLogged && !myLogFileName.isEmpty() && QFile::exists( myLogFileName ) ) {
168 myLogFile = fopen( myLogFileName.latin1(), "a" );
169 if ( myLogFile == NULL )
172 myTimer = new QTimer( this );
173 connect( myTimer, SIGNAL(timeout()), this, SLOT(checkExecution()) );
176 SUPERVGUI_Main::~SUPERVGUI_Main() {
177 Trace("SUPERVGUI_Main::~SUPERVGUI_Main");
179 // close all opened SubGraphs
180 QMap<QString, SUIT_ViewWindow*/*QAD_StudyFrame**/>::iterator it;
181 for (it = mySubGraphs.begin(); it != mySubGraphs.end(); ++it) {
182 it.data()->removeEventFilter(this);
183 it.data()->disconnect();
184 //it.data()->close();
186 //QAD_Study* aStudy = it.data()->getStudy();
187 //aStudy->removeStudyFrame(it.data());
188 //remove view from internal view manager's list of views
189 //it.data()->getViewManager()->removeView(it.data());
190 SUIT_ViewManager* aVM = it.data()->getViewManager();
191 STD_Application* anApp = dynamic_cast<STD_Application*>( SUIT_Session::session()->activeApplication() );
192 if ( anApp ) anApp->removeViewManager(aVM);
193 if ( aVM ) delete aVM;
197 mySubGraphMap.clear();
199 QAD_StudyFrame* aSubGraph;
200 for (aSubGraph = mySubGraphs.first(); aSubGraph; aSubGraph = mySubGraphs.next()) {
201 aSubGraph->removeEventFilter(this);
206 if ( myLogFile != NULL) {
210 // delete notification; // kloss : nota bene : quand un datalow est detruit : verifier que les canaux de notification sont aussi detruit
211 notification->_remove_ref(); // kloss : nota bene : quand un datalow est detruit : verifier que les canaux de notification sont aussi detruit
217 SUIT_ResourceMgr* SUPERVGUI_Main::resMgr() const
219 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( study->application() );
220 return app ? app->resourceMgr() : 0;
223 void SUPERVGUI_Main::filterNotification() {
224 Trace("SUPERVGUI_Main::filterNotification");
225 SUPERVGUI_Notification* dlg = new SUPERVGUI_Notification(this);
226 dlg->setFiltered( myFiltered );
227 dlg->setLogged( myLogged, myLogFileName );
228 dlg->setWarning( myWarning );
229 dlg->setStep( myStep );
230 dlg->setTrace( myTrace );
231 dlg->setVerbose( myVerbose );
232 if ( dlg->exec() == QDialog::Accepted ) {
233 myLogged = dlg->getLogged();
234 myLogFileName = dlg->getLogFile();
235 myFiltered = dlg->getFiltered();
236 myWarning = dlg->getWarning();
237 myStep = dlg->getStep();
238 myTrace = dlg->getTrace();
239 myVerbose = dlg->getVerbose();
241 if ( myLogFile != NULL) {
245 if ( myLogged && !myLogFileName.isEmpty() && QFile::exists( myLogFileName ) ) {
246 myLogFile = fopen( myLogFileName.latin1(), "a" );
247 if ( myLogFile == NULL ) {
249 QMessageBox::warning( SUIT_Session::session()->activeApplication()->desktop(), tr("ERROR"), tr( "ERR_CANT_OPEN_LOG_FILE" ) );
255 void SUPERVGUI_Main::changeDSGraphParameters() {
256 SUPERVGUI_DSGraphParameters* aDlg = new SUPERVGUI_DSGraphParameters(dataflow, dataflow->IsReadOnly());
262 void SUPERVGUI_Main::syncAsync() {
263 Trace("SUPERVGUI_Main::syncAsync");
264 QTimer::singleShot(1, this, SLOT(sync()));
269 * Called by thread when dataflow is executing
271 void SUPERVGUI_Main::execute( char * theNodeName, SUPERV::GraphState theNodeState ) {
272 if (myCurrentView == CANVAS || myCurrentView == CONTROLFLOW) {
273 SUPERVGUI_CanvasNode* aNode = (SUPERVGUI_CanvasNode*) myCanvas->child(theNodeName, "SUPERVGUI_CanvasNode");
277 else if (myCurrentView == CANVASTABLE) {
278 SUPERVGUI_CanvasCellNode* aNode = (SUPERVGUI_CanvasCellNode*) myArray->child(theNodeName, "SUPERVGUI_CanvasCellNode");
283 // asv : 26.01.05 : Bug PAL7164 : puting out-value to study if the "put_to_Study" flag is set on a
284 // CanvasPort the functionality was moved from SUPERVGUI_CanvasPortOut::sync() method please, see
285 // comment in that method for details.
286 if ( theNodeState == SUPERV::DoneState ) {
287 SUPERVGUI_CanvasNode* aNode = (SUPERVGUI_CanvasNode*) myCanvas->child(theNodeName, "SUPERVGUI_CanvasNode");
289 //cout << " *** theNode " << theNodeName << " received DONE_STATE *** " << endl;
290 SUPERVGUI_CanvasPortOut* aPortOut;
291 QObjectList* aPortList = aNode->queryList("SUPERVGUI_CanvasPortOut");
292 QObjectListIt aPortIt(*aPortList);
293 while ((aPortOut=(SUPERVGUI_CanvasPortOut*)aPortIt.current()) != 0) {
295 if ( aPortOut->isInStudy() && aPortOut->getEngine()->State() == SUPERV::ReadyState ) {
296 //cout << " *** " << theNodeName << "[" << aPortOut->name() << "]--> goes into study *** " << endl;
297 putDataStudy( aPortOut->getEngine(), STUDY_PORT_OUT );
302 //else //normal case if Node is not found is when node is a graph! it can receive DoneState as well!
303 // MESSAGE( "ERROR in SUPERVGUI_Main::execute() : CanvasNode \"" << theNodeName << "\" NOT FOUND in myCanvas" );
308 void SUPERVGUI_Main::sync() {
309 Trace("SUPERVGUI_Main::sync");
310 if ((SUPERV_isNull(dataflow)))
312 QString t = tr("GRAPH_TITLE");
314 t += dataflow->Name();
317 //study->updateObjBrowser();
318 //mkr: we have to update object browser only if there are some ports datas in the study
319 //or if dataflow is in the study itself. It is done in the
320 //1) putDataStudy(...) method (it called when we put in study data of port
321 // or if port is in study and execution is finished)
322 //2) addDataflowToStudy() method (it is called as a slot when we add in study dataflow itself).
323 //So, we commented updateObjBrowser function here!
324 //SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
325 //if ( aSupMod ) aSupMod->updateObjBrowser();
326 //else MESSAGE("NULL Supervision module!");
328 if (myCurrentView == CANVASTABLE) {
337 void SUPERVGUI_Main::showCanvasTable() {
338 if (myCurrentView == CANVASTABLE)
341 if (myArray->create()) {
342 myCanvasView->hide();
344 myCurrentView = CANVASTABLE;
349 void SUPERVGUI_Main::showContolFlow() {
351 if (myCurrentView == CANVASTABLE) {
356 myCurrentView = CONTROLFLOW;
357 myCanvas->setControlView();
360 myCanvasView->show();
364 void SUPERVGUI_Main::showCanvas() {
365 if (myCurrentView == CANVAS)
369 if (myCurrentView == CANVASTABLE) {
374 myCurrentView = CANVAS;
375 myCanvas->setFullView();
378 myCanvasView->show();
382 void SUPERVGUI_Main::insertFile() {
383 Trace("SUPERVGUI_Main::insertFile");
385 if ( !ReadyToModify() ) // null dataflow or executing, ..
388 QString f = SUIT_FileDlg::getFileName(SUIT_Session::session()->activeApplication()->desktop(),
391 tr("MSG_GRAPH_INSERT"),
393 if ( !f.isEmpty() ) { // not Cancel, but "OK" was pressed with valid file name
395 Editing(); // PAL6170: GUI->Engine: setting "Editing" flag, why here? -> see 7960
397 if (dataflow->Import(f.latin1())) {
398 if (myCurrentView == CANVASTABLE) {
402 else { // (myCurrentView == CANVAS || myCurrentView == CONTROLFLOW) {
407 QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("ERROR"), tr("MSG_BAD_FILE").arg(f));
412 void SUPERVGUI_Main::copy() {
413 Trace("SUPERVGUI_Main::copy");
414 if (dataflow->ThreadsMax() == 0) {
415 QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("WARNING"), tr("MSG_NOTHING_COPY"));
419 SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
421 MESSAGE("NULL Supervision module!");
425 SUPERVGraph_ViewFrame* aViewFrame = dynamic_cast<SUPERVGraph_ViewFrame*>( aSupMod->createGraph() );
427 SUPERV_Graph aNewGraph; // = dataflow->StreamCopy();
428 if ( dataflow->IsStreamGraph() ) {
429 SUPERV_StreamGraph aSGraph = dataflow->ToStreamGraph();
430 if ( SUPERV_isNull(aSGraph) ) {
431 QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("WARNING"), tr("MSG_CANT_COPY"));
434 aNewGraph = aSGraph->StreamCopy();
437 aNewGraph = dataflow->Copy();
439 QString aNewName(tr("MSG_COPY_PREFIX").arg(++myCopyNum));
440 aNewName += dataflow->Name();
441 aNewGraph->SetName(aNewName);
442 /*SUPERVGUI_Main* m = */new SUPERVGUI_Main(aViewFrame,
443 aSupMod->application()->desktop(),//getDesktop(),
449 void SUPERVGUI_Main::openSubGraph(SUPERV_CNode theNode, bool correct)
451 if (theNode->IsMacro()) {
452 // get SubGraph from MacroNode
453 SUPERV_Graph aMacro = SUPERV::Graph::_narrow(theNode);
455 if (aMacro->IsStreamMacro())
456 aGraph = aMacro->StreamObjRef();
458 aGraph = aMacro->FlowObjRef();
461 if (SUPERV_isNull(aGraph)) {
462 QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("WARNING"), tr("MSG_NOACCESS"));
466 QString aGraphName = aGraph->Name();
467 SUIT_ViewWindow* aStudyFrame;
468 if (mySubGraphs.contains(aGraphName)) {
469 aStudyFrame = mySubGraphs[aGraphName];
470 aStudyFrame->setActiveWindow();
471 aStudyFrame->setFocus();
474 SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
476 MESSAGE("NULL Supervision module!");
480 aStudyFrame = aSupMod->createGraph();
482 SUPERVGraph_ViewFrame* aViewFrame = dynamic_cast<SUPERVGraph_ViewFrame*>( aStudyFrame );
484 /*SUPERVGUI_Main* m = */new SUPERVGUI_Main(aViewFrame,
485 aSupMod->application()->desktop(),//getDesktop(),
487 // connect(aStudyFrame, SIGNAL(sfStudyFrameClosing(QAD_StudyFrame*)),
488 // this, SLOT(onSubGraphClosed(QAD_StudyFrame*)));
489 connect(aSupMod->application()->desktop(), SIGNAL(windowActivated( SUIT_ViewWindow* )),
490 this, SLOT(onSubGraphActivated( SUIT_ViewWindow* )));
491 aStudyFrame->installEventFilter(this);
493 mySubGraphs.insert(aGraphName, aStudyFrame);
494 mySubGraphMap.insert(aGraphName, theNode->Name());
500 if (!correct) myLastGraph = aStudyFrame;
505 bool SUPERVGUI_Main::eventFilter( QObject* o, QEvent* e)
507 // workaround to get close event
508 if (o->inherits("SUIT_ViewWindow"/*"QAD_StudyFrame"*/) && e->type() == QEvent::Close) {
509 SUIT_ViewWindow* aFrame = (SUIT_ViewWindow*) o;
510 onSubGraphClosed(aFrame);
512 return SUPERVGraph_View::eventFilter(o, e);
515 // workaround to fix PAL6255 -> opened SubGraph is not on top
516 void SUPERVGUI_Main::onSubGraphActivated(SUIT_ViewWindow* theStudyFrame)
519 SUIT_ViewWindow* aFrame = myLastGraph;
521 aFrame->setActiveWindow();
526 void SUPERVGUI_Main::onSubGraphClosed(SUIT_ViewWindow* theStudyFrame)
528 if ( SUPERVGraph_ViewFrame* supervFrame = dynamic_cast<SUPERVGraph_ViewFrame*>( theStudyFrame ) ) {
529 theStudyFrame->removeEventFilter(this);
530 disconnect(theStudyFrame, 0, this, 0);
532 SUPERVGraph_View* view = supervFrame->getViewWidget();
533 SUPERVGUI_Main* aGraph = dynamic_cast<SUPERVGUI_Main*>(view);
535 QString aGraphName = aGraph->getDataflow()->Name();
536 QMap<QString, QString>::iterator it = mySubGraphMap.find(aGraphName);
537 if (it != mySubGraphMap.end()) {
538 QString aNodeName = it.data();
539 SUPERVGUI_CanvasNode* aNode = (SUPERVGUI_CanvasNode*)
540 myCanvas->child(aNodeName, "SUPERVGUI_CanvasNode");
545 mySubGraphMap.remove(it);
547 mySubGraphs.remove(aGraphName);
552 void SUPERVGUI_Main::run( const bool andSuspend ) {
553 Trace("SUPERVGUI_Main::run");
554 if ( SUPERV_isNull(dataflow) )
557 if ( dataflow->IsEditing() ) { // not currently Executing
559 // asv 31.01.05 : fix for PAL7854, Editing moved from SUPERVGUI.cxx runDataflow(), stepByStep() to here..
560 Editing(); // remove old executor, update GUI (all nodes to "No Status")
562 if ( !dataflow->IsValid() ) {
563 QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("ERROR"), tr("MSG_DF_NOTVALID") + QString(" : ") + QString(dataflow->Messages()));
565 else if (!dataflow->IsExecutable()) {
566 QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("ERROR"), tr("MSG_DF_NOTEXECUTABLE") + QString(" : ") + QString(dataflow->Messages()));
568 else if (myCanvasView->isAnyLinkCreating()) {
569 QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("ERROR"), tr("MSG_CRL_NOTCOMPLETE"));
572 myRunTime = QDateTime::currentDateTime();
573 const bool result = andSuspend ? dataflow->Start() : dataflow->Run();
575 QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("ERROR"), tr("MSG_DF_BADEXECUTE"));
576 if ( dataflow->State() == SUPERV::ErrorState ) {
581 //myExecuted = true; // set to true on first execution. for correct publishing in Study
582 myThread->startThread(tr("MSG_GRAPH_STARTED"));
587 QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("ERROR"), tr("MSG_DF_RUNNING"));
592 void SUPERVGUI_Main::kill() {
593 Trace("SUPERVGUI_Main::kill");
594 if ((SUPERV_isNull(dataflow)))
597 if (dataflow->IsEditing()) {
598 QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("ERROR"), tr("MSG_DF_NOTRUNNING"));
600 else if (dataflow->Kill()) {
601 getMessage()->putMessage( tr("MSG_GRAPH_KILLED") );
605 QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("ERROR"), tr("MSG_CANTKILL_DF"));
609 void SUPERVGUI_Main::suspendResume() {
610 Trace("SUPERVGUI_Main::suspendResume");
611 if ((SUPERV_isNull(dataflow))) return;
613 if (dataflow->IsEditing()) {
614 QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("ERROR"), tr("MSG_DF_NOTRUNNING"));
615 } else if (dataflow->State() == SUPERV_Suspend) {
616 if (dataflow->Resume()) {
617 myThread->startThread(tr("MSG_DF_RESUMED"));
619 QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("ERROR"), tr("MSG_CANT_RESUME"));
622 if (dataflow->Suspend()) {
624 getMessage()->putMessage( tr("MSG_GRAPH_SUSPENDED") );
626 QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("ERROR"), tr("MSG_CANT_SUSPEND"));
630 /* asv : 15.12.04 : commented out stopRestart() in Main and CanvasNode because it's not called from anywhere,
631 the comment from kloss below may be explaining it, but it's in French and I do not understand it..
632 It also calls deprecated method of Engine: ReStart().
633 void SUPERVGUI_Main::stopRestart() { // kloss : a reviser et a connecter dans le popup du dataflow (pas de creation de bouton)
634 Trace("SUPERVGUI_Main::stopRestart");
635 if ((SUPERV_isNull(dataflow))) return;
637 if (dataflow->IsEditing()) {
638 QMessageBox::warning(0, tr("ERROR"), tr("MSG_DF_NOTRUNNING"));
639 } else if (dataflow->State() == SUPERV_Stop) {
640 if (dataflow->ReStart()) {
641 message->setMessage(tr("MSG_DF_RESTARTED"));
644 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_RESTART"));
647 if (dataflow->Stop()) {
650 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_STOP"));
655 void SUPERVGUI_Main::addNode() {
656 Trace("SUPERVGUI_Main::addNode");
658 if ( !ReadyToModify() ) // null dataflow or executing, ..
661 SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
663 MESSAGE("NULL Supervision module!");
667 //Editing(); // PAL6170: GUI->Engine: setting "Editing" flag, commented: PAL7960
668 aSupMod->getBrowser()->choose();
672 * Add Computation node
674 void SUPERVGUI_Main::addComputeNode(SUPERV_CNode theNode) {
675 switch (myCurrentView) {
683 SUPERVGUI_CanvasNode* aNode = new SUPERVGUI_CanvasComputeNode( resMgr(), myCanvas, this, theNode);
684 aNode->move(theNode->X(), theNode->Y());
685 if (myCurrentView == CONTROLFLOW) aNode->hideAll();
696 void SUPERVGUI_Main::addGOTONode(SUPERV_CNode theNode) {
697 switch (myCurrentView) {
705 SUPERVGUI_CanvasNode* aNode = new SUPERVGUI_CanvasGotoNode( resMgr(), myCanvas, this, theNode);
706 aNode->move(theNode->X(), theNode->Y());
707 if (myCurrentView == CONTROLFLOW) aNode->hideAll();
718 void SUPERVGUI_Main::addControlNode(SUPERV_CNode theStartNode, SUPERV_CNode theEndNode, bool Update) {
719 switch (myCurrentView) {
727 SUPERVGUI_CanvasStartNode* aStartNode = new SUPERVGUI_CanvasStartNode( resMgr(), myCanvas, this, theStartNode);
728 aStartNode->move(theStartNode->X(), theStartNode->Y());
729 if (myCurrentView == CONTROLFLOW) aStartNode->hideAll();
731 SUPERVGUI_CanvasEndNode* aEndNode = new SUPERVGUI_CanvasEndNode( resMgr(), myCanvas, this, theEndNode, aStartNode);
732 aEndNode->move(theEndNode->X(), theEndNode->Y());
733 if (myCurrentView == CONTROLFLOW) aEndNode->hideAll();
747 void SUPERVGUI_Main::addMacroNode(SUPERV_CNode theNode) {
748 switch (myCurrentView) {
756 SUPERVGUI_CanvasNode* aNode = new SUPERVGUI_CanvasMacroNode( resMgr(), myCanvas, this, theNode);
757 aNode->move(theNode->X(), theNode->Y());
758 if (myCurrentView == CONTROLFLOW) aNode->hideAll();
766 SUPERVGUI_CanvasArray* SUPERVGUI_Main::getCanvasArray() {
767 Trace("SUPERVGUI_Main::getCanvasArray");
771 SUPERVGUI_ArrayView* SUPERVGUI_Main::getArrayView() {
772 Trace("SUPERVGUI_Main::getArrayView");
776 SUPERVGUI_Canvas* SUPERVGUI_Main::getCanvas() {
777 Trace("SUPERVGUI_Main::getCanvas");
781 SUPERVGUI_CanvasView* SUPERVGUI_Main::getCanvasView() {
782 Trace("SUPERVGUI_Main::getCanvasView");
783 return(myCanvasView);
786 SUPERV_Graph SUPERVGUI_Main::getDataflow() {
787 Trace("SUPERVGUI_Main::getDataflow");
791 LogWindow* SUPERVGUI_Main::getMessage() {
792 Trace("SUPERVGUI_Main::getMessage");
796 SUIT_Study* SUPERVGUI_Main::getStudy() {
797 Trace("SUPERVGUI_Main::getStudy");
801 bool SUPERVGUI_Main::isArrayShown() {
802 Trace("SUPERVGUI_Main::isArrayShown");
803 return(myCurrentView == CANVASTABLE);
806 void SUPERVGUI_Main::showPopup(QPopupMenu* p, QMouseEvent* e) {
807 Trace("SUPERVGUI_Main::showPopup");
808 // To check is Supervision active?
809 if (myIsLocked) return;
810 //if (dataflow->IsExecuting()) return;
812 CAM_Application* anApp = ( CAM_Application* )(SUIT_Session::session()->activeApplication());
813 if ( anApp->activeModule()->moduleName().compare( anApp->moduleTitle( "SUPERV" ) ) !=0 ) return;
815 if (e->button() == RightButton) {
816 p->exec(e->globalPos());
820 void SUPERVGUI_Main::changeInformation() {
821 SUPERVGUI_Information* aDlg = new SUPERVGUI_Information(SUPERV::CNode::_narrow(dataflow), dataflow->IsReadOnly());
827 void SUPERVGUI_Main::chooseData(QListViewItem* item) {
828 Trace("SUPERVGUI_Main::chooseData");
830 QString id = ((OB_ListItem*)item)->text(2);// <=> get entry
832 _PTR(SObject) object ( (( SalomeApp_Study* )study)->studyDS()->FindObjectID(id.latin1()) );
833 _PTR(GenericAttribute) anAttr;
834 if (object->FindAttribute(anAttr, "AttributeIOR")) {
835 _PTR(AttributeIOR) anIOR ( anAttr );
837 // asv : 13.12.04 : commented out use of portIn field, but it seems that it
838 // should be replaced with some analogious code... selection of IOR was done -
839 // put its value into port.
840 //portIn->setValue(ior);
842 SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
844 MESSAGE("NULL Supervision module!");
850 setCursor(aSupMod->getCursor());
851 objectBrowser->setCursor(aSupMod->getCursor());
852 aSupMod->putInfo("");
858 _PTR(SObject) SearchOrCreateSOWithName( _PTR(Study) const theStudy,
859 _PTR(StudyBuilder) const theBuilder,
860 _PTR(SObject) const theSO,
862 bool* theDoneSomething ) {
863 _PTR(SObject) aResult;
864 _PTR(AttributeName) aName;
865 _PTR(GenericAttribute) anAttr;
866 _PTR(ChildIterator) anIterator ( theStudy->NewChildIterator(theSO) );
867 for (; anIterator->More(); anIterator->Next()) {
868 if (anIterator->Value()->FindAttribute(anAttr, "AttributeName")) {
870 if (strcmp(aName->Value().c_str(), theName) == 0) {
871 aResult = anIterator->Value();
877 // if aResule was found then theDoneSomething=false and we return
878 *theDoneSomething = !aResult ? 1 : 0;//->_is_nil();
879 if ( !*theDoneSomething )
883 aResult = theBuilder->NewObject( theSO );
884 anAttr = theBuilder->FindOrCreateAttribute(aResult, "AttributeName");
886 aName->SetValue(theName);
891 * Return true if dataflow is already in the study
893 bool SUPERVGUI_Main::isDataflowInStudy() const {
894 _PTR(Study) aStudy = (( SalomeApp_Study* )study)->studyDS();
895 _PTR(SObject) aSO ( aStudy->FindObjectIOR( dataflow->getIOR() ) );
896 return ( aSO ? true : false );
900 * Create a "Supervision" object in the Study and a "dataflow" object under it
901 * aDoneSomething will be true if "Supervision" or "dataflow" object were created (not found).
903 _PTR(SObject) createDataflowSObj( SUIT_Study* study,
904 SUPERV::Graph_var dataflow,
905 _PTR(StudyBuilder) aBuilder,
906 bool& aDoneSomething ) {
907 _PTR(Study) aStudy = (( SalomeApp_Study* )study)->studyDS();
908 _PTR(GenericAttribute) anAttr;
909 _PTR(AttributeName) aName;
911 // Find or create "Supervisor -> aNewDataflow_1" SObjects in the study
912 _PTR(SObject) aSO = aStudy->FindObjectIOR( dataflow->getIOR() );
913 if ( !aSO ) { // dataflow SObject not found in the study
914 aDoneSomething = true;
915 _PTR(SComponent) aComponent = aStudy->FindComponent(STUDY_SUPERVISION);
916 if ( !aComponent ) { // is supervision component not found, then create it
917 aComponent = aBuilder->NewComponent(STUDY_SUPERVISION);
918 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributeName");
920 aName->SetValue( (( CAM_Application* )(study->application()))->moduleTitle( "SUPERV" ).latin1() );
922 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributePixMap");
923 _PTR(AttributePixMap) aPixmap ( anAttr );
924 aPixmap->SetPixMap( "ICON_OBJBROWSER_Supervision" );
926 SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
928 aBuilder->DefineComponentInstance(aComponent, SalomeApp_Application::orb()->object_to_string(aSupMod->getEngine()));
929 //dynamic_cast<SALOMEDS_Study*>( aStudy )->ConvertObjectToIOR(aSupMod->getEngine()));
930 else MESSAGE("NULL Supervision module!");
933 // create dataflow SObject ("aNewDataflow_1")
934 aSO = aBuilder->NewObject(aComponent);
935 anAttr = aBuilder->FindOrCreateAttribute(aSO, "AttributeName");
937 aName->SetValue(dataflow->Name());
938 anAttr = aBuilder->FindOrCreateAttribute(aSO, "AttributeIOR");
939 _PTR(AttributeIOR) anIORAttr ( anAttr );
940 anIORAttr->SetValue(dataflow->getIOR());
946 void SUPERVGUI_Main::addDataflowToStudy() {
948 _PTR(StudyBuilder) aBuilder ( (( SalomeApp_Study* )study)->studyDS()->NewBuilder() );
949 aBuilder->NewCommand();
950 _PTR(SObject) aDF ( createDataflowSObj( study, dataflow, aBuilder, isCreated ) );
952 aBuilder->CommitCommand();
953 // what is this register/unregister?? don't know..
954 SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
956 MESSAGE("NULL Supervision module!");
959 aSupMod->unregisterGraph(this);
960 aSupMod->registerGraph(dataflow->getIOR(), this);
962 if ( !myThread->running() )
963 aSupMod->updateObjBrowser();
966 MESSAGE( "ERROR: failed to find or create dataflow SObject" );
967 aBuilder->AbortCommand();
971 bool SUPERVGUI_Main::putDataStudy( SUPERV_Port p, const char* inout ) {
972 Trace("SUPERVGUI_Main::putDataStudy");
974 bool PublishOtherComponent = false;
976 // static variable to ensure that only one instance (thread) is executing this function
977 static bool isIn = false;
978 if (isIn) return true;
981 _PTR(Study) aStudy = (( SalomeApp_Study* )study)->studyDS();
982 const bool aLocked = aStudy->GetProperties()->IsLocked();
983 _PTR(StudyBuilder) aBuilder ( aStudy->NewBuilder() );
984 bool aDoneSomething = false;
986 // asv 23.11.04 : fix for PAL6852 if the study is locked -- then we can't put anything in it.
988 MESSAGE( "The study is locked and can not be modified!" );
993 // check if the port and its node are good
994 if ( CORBA::is_nil( p ) || CORBA::is_nil( p->Node() ) ) {
995 MESSAGE( "putInStudy ERROR: port or node are NULL!" );
1000 // open new command. Commit or Abort it depending on aDoneSomething variable or error
1001 aBuilder->NewCommand();
1003 // Find or create "Supervisor -> aNewDataflow_1" SObjects in the study
1004 _PTR(SObject) aSO = createDataflowSObj( study, dataflow, aBuilder, aDoneSomething );
1007 MESSAGE( "ERROR: putDataStudy() could not find or create dataflow SObject" );
1008 aBuilder->AbortCommand();
1013 // Create "Run -> Time and date, etc." SObjects
1014 if ( p->State() == SUPERV::ReadyState ) { // if port contains valid computed value
1016 aSO = SearchOrCreateSOWithName( aStudy, aBuilder, aSO, QString("Run ") + myRunTime.toString(), &aDoneSomething ); // get run time SO
1017 aSO = SearchOrCreateSOWithName( aStudy, aBuilder, aSO, p->Node()->Name(), &aDoneSomething ); // get node SO
1018 aSO = SearchOrCreateSOWithName( aStudy, aBuilder, aSO, inout, &aDoneSomething ); // get in/out SO
1019 aSO = SearchOrCreateSOWithName( aStudy, aBuilder, aSO, p->Name(), &aDoneSomething ); // get port SO
1021 // create IOR attribute for port SObject (usually with "return" name)
1022 _PTR(GenericAttribute) anAttr ( aBuilder->FindOrCreateAttribute(aSO, "AttributeIOR") );
1023 _PTR(AttributeIOR) anIORAttr ( anAttr );
1025 // if we have not created anything (all SObject already existed) and we have the same IORAttribute
1026 // on the needed SObject -> then don't do anything! it's already there!
1027 if ( !aDoneSomething && strcmp(anIORAttr->Value().c_str(), p->ToString()) == 0 ) {
1028 aBuilder->AbortCommand();
1033 aDoneSomething = true; // going to set some value to anIORAttr any way from this point..
1035 // set object value to the study: if object is external, then put it with
1036 // help of the specific component - owner
1038 // get according component driver for result object
1039 SALOME_LifeCycleCORBA aLCC( myNService );
1040 SUPERV_FNode aFNode = SUPERV::FNode::_narrow( p->Node() );
1041 if ( !aFNode->_is_nil() ) {
1042 Engines::Component_var aComponent = aLCC.FindOrLoad_Component( aFNode->GetContainer(), aFNode->GetComponentName() );
1043 SALOMEDS::Driver_var aDriver = SALOMEDS::Driver::_narrow( aComponent );
1044 if ( !CORBA::is_nil( aDriver ) ) { // if driver was found, publish object
1045 CORBA::Object_ptr anObject = new CORBA::Object();
1046 CORBA::Any* anAny = p->ToAny();
1047 (*anAny) >>= anObject;
1049 if ( aDriver->CanPublishInStudy( anObject ) ) {
1050 SALOMEDS::SObject_var aTmpSO;// = aSO;
1051 SALOMEDS_Study* aSStudy = dynamic_cast<SALOMEDS_Study*>( aStudy.get() );
1052 if ( !aSStudy ) return false;
1053 aTmpSO = aDriver->PublishInStudy( aSStudy->GetStudy(), aTmpSO, anObject, "" );
1054 aBuilder->Addreference(aSO, _PTR(SObject)(new SALOMEDS_SObject( aTmpSO )) );
1055 PublishOtherComponent = true;
1057 else { // can't publish object: abort transaction
1058 MESSAGE( "CanPublishInStudy() returned FALSE. ok, AbortCommand.." );
1059 aBuilder->AbortCommand();
1064 else { // component has no driver, but could store IORs (like Calculator)
1065 _PTR(SObject) anIORSO ( aStudy->FindObjectIOR( p->ToString() ) );
1067 aBuilder->Addreference(aSO, anIORSO);
1069 PublishOtherComponent = true;
1071 else { // Hm... the object (==port value) was not found, so we don't publish it.
1072 MESSAGE( "The object (==port value) was not found, so we don't publish it" );
1073 aBuilder->AbortCommand();
1079 else { // FNode is NULL -> bad
1080 MESSAGE( "FNode is NULL." );
1081 if ( SUPERV::INode::_narrow( p->Node() ) ) { // mkr : IPAL10175
1082 _PTR(SObject) anIORSO ( aStudy->FindObjectIOR( p->ToString() ) );
1084 aBuilder->Addreference(aSO, anIORSO);
1087 MESSAGE( "FNode and INode are NULL. Not good at all. Aborting command." );
1088 aBuilder->AbortCommand();
1095 anIORAttr->SetValue( p->ToString() ); // ior attribute already set for the prevoius condition
1099 if ( aDoneSomething )
1100 aBuilder->CommitCommand();
1102 aBuilder->AbortCommand();
1104 SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
1106 if ( PublishOtherComponent )
1107 dynamic_cast<SalomeApp_Application*>( study->application() )->updateObjectBrowser(true);
1109 aSupMod->updateObjBrowser();
1111 else MESSAGE("NULL Supervision module!");
1118 void SUPERVGUI_Main::ActivatePanning()
1120 if (myCanvasView->isVisible()) {
1121 myCanvasView->ActivatePanning();
1122 } else if (myArrayView->isVisible()) {
1123 myArrayView->ActivatePanning();
1128 void SUPERVGUI_Main::ResetView()
1130 if (myCanvasView->isVisible()) {
1131 myCanvasView->ResetView();
1132 } else if (myArrayView->isVisible()) {
1133 myArrayView->ResetView();
1137 void SUPERVGUI_Main::syncNotification() {
1147 while (notification->Receive(&graph, &node, &type, &message, &sender, &counter, &date, &stamp)) {
1148 // if (isFiltered(graph, node, type, message, sender, counter, date, stamp)) {
1150 mess += "NOTIF: "; mess += graph;
1151 mess += " / " ; mess += node;
1152 mess += " / " ; mess += type;
1153 mess += " / " ; mess += message;
1154 getMessage()->putMessage(mess.latin1());
1159 bool SUPERVGUI_Main::isFiltered(char* graph, char* node, char* type, char* message,
1160 char* sender, long counter, char* date, long stamp) {
1161 Trace("SUPERVGUI_Main::isFiltered");
1163 if (strcmp(getDataflow()->Name(), graph) == 0) {
1164 SUPERVGUI_CanvasNode* n;
1165 QObjectList* nodes = queryList("SUPERVGUI_CanvasNode");
1166 QObjectListIt i(*nodes);
1167 while ((n=(SUPERVGUI_CanvasNode*)i.current()) != 0) {
1169 if (strcmp(n->name(), node) == 0) {
1170 if (strcmp(type, NOTIF_WARNING) == 0) {
1172 } else if (strcmp(type, NOTIF_STEP) == 0) {
1174 } else if (strcmp(type, NOTIF_TRACE) == 0) {
1176 } else if (strcmp(type, NOTIF_VERBOSE) == 0) {
1183 if ( myLogged && myLogFile && ( ( !myFiltered ) || b ) ) {
1184 fprintf( myLogFile, "NOTIF %ld\t%s\t%s\t%ld\t%s\t%s\t%s\t%s\n", stamp, date, sender, counter, graph, node, type, message );
1185 fflush( myLogFile );
1191 void SUPERVGUI_Main::closeEvent(QCloseEvent* e) {
1196 void SUPERVGUI_Main::setPaletteBackgroundColor(const QColor& color) {
1198 myCanvas->setBackgroundColor(color);
1199 myCanvasView->setPaletteBackgroundColor(color.light());
1200 myArray->setBackgroundColor(color);
1201 myArrayView->setPaletteBackgroundColor(color.light());
1203 SUPERVGraph_View::setPaletteBackgroundColor(color);
1206 QPtrList< char * > SUPERVGUI_Main::getEventNodes() {
1207 return myEventNodes;
1210 void SUPERVGUI_Main::setEventNodes(QPtrList< char * > theEventNodes) {
1211 myEventNodes = theEventNodes;
1214 QPtrList< SUPERV::GraphState > SUPERVGUI_Main::getStates() {
1218 void SUPERVGUI_Main::setStates(QPtrList< SUPERV::GraphState > theStates) {
1219 myStates = theStates;
1222 int SUPERVGUI_Main::getNodesNumber() {
1223 //create a list of nodes of the graph
1224 SUPERV_Nodes nodes = getDataflow()->Nodes();
1225 int RetVal = nodes->CNodes.length() + nodes->FNodes.length() +
1226 nodes->INodes.length() + nodes->GNodes.length() +
1227 nodes->LNodes.length() + nodes->SNodes.length();
1231 SUPERVGUI_Thread* SUPERVGUI_Main::getMyThread() {
1235 void SUPERVGUI_Main::startTimer() {
1236 myTimer->start(500);
1239 void SUPERVGUI_Main::executionFinished() {
1240 SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
1242 //aSupMod->updateObjBrowser();
1243 // PAL10611: update all modules data
1244 aSupMod->getApp()->updateObjectBrowser(true);
1245 else MESSAGE("NULL Supervision module!");
1251 void SUPERVGUI_Main::checkExecution() {
1252 if (myThread->finished()) {
1254 executionFinished();
1259 * Editing() is to be called by any operation in GUI before modification of a datamodel
1260 * (add/remove ports or nodes, etc.). It is used to resolve inconsistancies between 2 data models
1261 * in Engine: Editor and Executor. During and after execution, the values of ports and statuses of nodes
1262 * are taken from Executor data model. But when user starts editing the graph - these changes must
1263 * be applied to Editor data model. This function destroys Executor data model and moves to Editor.
1265 void SUPERVGUI_Main::Editing() {
1266 if ( !SUPERV_isNull( dataflow ) )
1267 dataflow->Editing();
1269 // updata GUI, Nodes' statuses and Ports' values could change.
1273 void SUPERVGUI_Main::removeArrayChild(SUPERV::CNode_ptr theNode)
1275 // mkr: since the deletion of the node allow only in CANVAS view,
1276 // it is necessary to remove the CanvasArray's children, which
1277 // have the same CNode engine as deleting node. This CNode is given
1280 const QObjectList* aChList = myArray->children();
1281 if ( aChList ) { // asv 27.01.05 : fix for 7817
1282 QObjectListIt aItChList(*aChList);
1283 SUPERVGUI_CanvasNode* anObjNode;
1284 while ((anObjNode = (SUPERVGUI_CanvasNode*)aItChList.current()) != 0) {
1286 if ((QString(anObjNode->getEngine()->Name())).compare(QString(theNode->Name())) == 0) {
1287 myArray->removeChild(anObjNode);
1291 } // end of if ( ChList )
1296 * ReadyToModify() must be called before any modification
1297 * operation - asks to kill execution of dataflow. If returns false -
1298 * modification (==Editing() ) is not allowed.
1300 bool SUPERVGUI_Main::ReadyToModify() {
1301 if ( CORBA::is_nil( dataflow ) )
1303 if ( dataflow->IsExecuting() ) {
1304 bool quit = SUIT_MessageBox::warn2( SUIT_Session::session()->activeApplication()->desktop(), // 0=Yes, 1=No
1305 tr("WARNING"), tr("MSG_GRAPH_ISRUN"), tr( "BUT_YES" ), tr( "BUT_CANCEL" ), 0, 1, 0 );
1306 if ( quit ) // user selected NOT to kill dataflow and NOT to add new node
1308 else if ( dataflow->IsExecuting() ) // user selected to kill the dataflow and add new node after that
1309 kill(); // checking again for IsExecuting to be sure that it was not finished while MB was up
1314 void SUPERVGUI_Main::resizeView( QResizeEvent* theEvent )
1316 if ( (myCurrentView == CANVAS || myCurrentView == CONTROLFLOW) && getCanvas() )
1317 if ( getCanvas()->width() < theEvent->size().width()
1319 getCanvas()->height() < theEvent->size().height() )
1320 getCanvas()->resize( theEvent->size().width(), theEvent->size().height() );
1321 if ( myCurrentView == CANVASTABLE && getCanvasArray() )
1322 if ( getCanvasArray()->width() < theEvent->size().width()
1324 getCanvasArray()->height() < theEvent->size().height() )
1325 getCanvasArray()->resize( theEvent->size().width(), theEvent->size().height() );
1328 /******************************* SUPERVGUI_Thread class ****************************************/
1329 SUPERVGUI_Thread::SUPERVGUI_Thread()
1335 SUPERVGUI_Thread::~SUPERVGUI_Thread()
1337 //it is a virtual destructor and needs to be determine here
1340 void SUPERVGUI_Thread::startThread(const char* m)
1345 myMain->getMessage()->putMessage(m);
1352 void SUPERVGUI_Thread::setMain( SUPERVGUI_Main* theMain )
1357 void SUPERVGUI_Thread::KillThread( bool theValue )
1360 myIsActive = !(theValue);
1364 template<class TObject, typename TArg, typename TArg1, typename TArg2,
1365 typename TStoreArg = TArg, typename TStoreArg1 = TArg1, typename TStoreArg2 = TArg2>
1366 class TVoidMemFun3ArgEvent: public SALOME_Event{
1368 typedef void (TObject::* TAction)(TArg,TArg1,TArg2);
1369 TVoidMemFun3ArgEvent(TObject* theObject, TAction theAction, TArg theArg, TArg1 theArg1, TArg2 theArg2):
1370 myObject(theObject),
1371 myAction(theAction),
1376 virtual void Execute(){
1377 (myObject->*myAction)(myArg,myArg1,myArg2);
1387 typedef TVoidMemFun3ArgEvent<SUPERVGUI_Thread, SUPERV_CNode&, SUPERV::GraphEvent&, SUPERV::GraphState&> TMainRunEvent;
1390 * main_thread_run must be executed in the qt main thread
1391 * It is activated by calling ProcessVoidEvent
1393 void SUPERVGUI_Thread::main_thread_run(SUPERV_CNode& aNode, SUPERV::GraphEvent& aEvent, SUPERV::GraphState& aState)
1395 // in case node "said" something during changing state through notification mechanism - output it
1396 myMain->syncNotification();
1398 // "kill" or undefined event came
1399 if (( aEvent == SUPERV::UndefinedEvent && aState == SUPERV::UndefinedState ) ||
1400 ( aEvent == SUPERV::NoEvent && aState == SUPERV::NoState ) ||
1401 ( aEvent == SUPERV::KillEvent && aState == SUPERV::KillState )) {
1405 else { // a "normal" execution event came
1407 if ( aNode != NULL && !CORBA::is_nil( aNode ) )
1408 aName = aNode->Name();
1410 // What follow is not quite sure. The entire function is posted to the main qt thread.
1411 // So all executions are serialized. Is it really possible to call execute when another
1412 // execute is running. I don't think so (C Caremoli)
1413 // this function is asynchronious. The call does NOT wait when SUPERVGUI_Main::execute finishes
1414 // handling the event. So: SUPERVGUI_Main::execute must be fast, in order we don't get here again
1415 // on the next loop iteration, BEFORE previous SUPERVGUI_Main::execute finished.
1416 myMain->execute(aName, aState );
1419 // execution is finished. just set a "finished" message(s)
1420 if ( !myIsActive ) {
1421 switch ( myMain->getDataflow()->State() ) {
1422 case SUPERV_Editing :
1423 myMain->getMessage()->putMessage( myMain->getDataflow()->IsReadOnly()?
1424 tr("MSG_GRAPH_READONLY"): tr("MSG_GRAPH_EDITING") );
1426 case SUPERV_Suspend :
1427 myMain->getMessage()->putMessage( tr("MSG_GRAPH_SUSPENDED") );
1430 myMain->getMessage()->putMessage( tr("MSG_GRAPH_FINISHED") );
1433 myMain->getMessage()->putMessage( tr("MSG_GRAPH_ABORTED") );
1436 myMain->getMessage()->putMessage( tr("MSG_GRAPH_KILLED") );
1440 // asv 03.02.05 : fix for PAL6859, not very good, but works..
1442 } // end of if !myIsActive
1445 void SUPERVGUI_Thread::run()
1447 myMain->startTimer();
1449 // GUI cycle to handle events coming for Engine
1450 while ( myIsActive ) {
1452 SUPERV_CNode aNode = NULL;
1453 SUPERV::GraphEvent aEvent = SUPERV::UndefinedEvent ;
1454 SUPERV::GraphState aState = SUPERV::UndefinedState ;
1456 // blocking function of Engine. Return from there only after anEvent happens on node aNode
1457 myMain->getDataflow()->Event(aNode, aEvent, aState);
1459 ProcessVoidEvent( new TMainRunEvent( this, &SUPERVGUI_Thread::main_thread_run,aNode, aEvent, aState ) );
1461 } // end of while( myIsActive )
1466 /******************************* SUPERVGUI_DSGraphParameters class ****************************************/
1470 SUPERVGUI_DSGraphParameters::SUPERVGUI_DSGraphParameters(SUPERV_Graph theGraph, bool isReadOnly)
1471 : QDialog( SUIT_Session::session()->activeApplication()->desktop(), "", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
1473 Trace("SUPERVGUI_DSGraphParameters::SUPERVGUI_DSGraphParameters");
1474 setCaption( tr( "TLT_DSGRAPHPARAMS" ) );
1475 setSizeGripEnabled( true );
1478 QGridLayout* TopLayout = new QGridLayout( this );
1479 TopLayout->setSpacing( 6 );
1480 TopLayout->setMargin( 11 );
1482 QGroupBox* TopGroup = new QGroupBox( this, "TopGroup" );
1483 TopGroup->setColumnLayout(0, Qt::Vertical );
1484 TopGroup->layout()->setSpacing( 0 );
1485 TopGroup->layout()->setMargin( 0 );
1486 QGridLayout* TopGroupLayout = new QGridLayout( TopGroup->layout() );
1487 TopGroupLayout->setAlignment( Qt::AlignTop );
1488 TopGroupLayout->setSpacing( 6 );
1489 TopGroupLayout->setMargin( 11 );
1492 QLabel* DeltaTimeL = new QLabel( tr( "DELTATIME_LBL" ), TopGroup );
1493 TopGroupLayout->addWidget( DeltaTimeL, 0, 0 );
1495 myDeltaTime = new QtxDblSpinBox( 0.0, 1.0, 0.1, TopGroup );
1496 myDeltaTime->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
1497 TopGroupLayout->addWidget( myDeltaTime, 0, 1 );
1500 QLabel* TimeOutL = new QLabel( tr( "TIMEOUT_LBL" ), TopGroup);
1501 TopGroupLayout->addWidget( TimeOutL, 1, 0 );
1503 myTimeOut = new QLineEdit( TopGroup );
1504 myTimeOut->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
1505 myTimeOut->setValidator( new QIntValidator(this) );
1506 myTimeOut->setMinimumSize( 100, 0 );
1507 myTimeOut->setReadOnly( isReadOnly );
1508 TopGroupLayout->addWidget( myTimeOut, 1, 1 );
1511 QLabel* DataStreamTraceL = new QLabel( tr( "DATASTREAMTRACE_LBL" ), TopGroup);
1512 TopGroupLayout->addWidget( DataStreamTraceL, 2, 0 );
1514 myDataStreamTrace = new QComboBox( TopGroup );
1515 myDataStreamTrace->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
1516 myDataStreamTrace->insertItem("WithoutTrace");
1517 myDataStreamTrace->insertItem("SummaryTrace");
1518 myDataStreamTrace->insertItem("DetailedTrace");
1519 TopGroupLayout->addWidget( myDataStreamTrace, 2, 1 );
1521 QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
1522 GroupButtons->setColumnLayout(0, Qt::Vertical );
1523 GroupButtons->layout()->setSpacing( 0 );
1524 GroupButtons->layout()->setMargin( 0 );
1525 QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
1526 GroupButtonsLayout->setAlignment( Qt::AlignTop );
1527 GroupButtonsLayout->setSpacing( 6 );
1528 GroupButtonsLayout->setMargin( 11 );
1530 QPushButton* okB = new QPushButton( tr( "BUT_OK" ), GroupButtons );
1531 QPushButton* cancelB = new QPushButton( tr( "BUT_CANCEL" ), GroupButtons );
1533 GroupButtonsLayout->addWidget( okB, 0, 0 );
1534 GroupButtonsLayout->addItem ( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
1535 GroupButtonsLayout->addWidget( cancelB, 0, 2 );
1537 TopLayout->addWidget( TopGroup, 0, 0 );
1538 TopLayout->addWidget( GroupButtons, 1, 0 );
1540 connect( okB, SIGNAL( clicked() ), this, SLOT( accept() ) );
1541 connect( cancelB, SIGNAL( clicked() ), this, SLOT( reject() ) );
1549 SUPERVGUI_DSGraphParameters::~SUPERVGUI_DSGraphParameters() {
1550 Trace("SUPERVGUI_DSGraphParameters::~SUPERVGUI_DSGraphParameters");
1556 void SUPERVGUI_DSGraphParameters::setData() {
1559 SUPERV::KindOfDataStreamTrace aDataStreamTrace;
1561 // myGraph->StreamParams(aTimeOut, aDataStreamTrace, aDeltaTime);
1562 if (myGraph->IsStreamGraph()) {
1563 SUPERV_StreamGraph aSGraph = myGraph->ToStreamGraph();
1564 if (!SUPERV_isNull(aSGraph))
1565 aSGraph->StreamParams(aTimeOut, aDataStreamTrace, aDeltaTime);
1568 myDeltaTime->setValue(aDeltaTime);
1569 myTimeOut->setText(QString("%1").arg(aTimeOut));
1570 myDataStreamTrace->setCurrentItem((int)aDataStreamTrace);
1576 void SUPERVGUI_DSGraphParameters::accept() {
1577 // myGraph->SetStreamParams( myTimeOut->text().toLong(),
1578 // (SUPERV::KindOfDataStreamTrace) myDataStreamTrace->currentItem(),
1579 // myDeltaTime->value());
1580 if (myGraph->IsStreamGraph()) {
1581 SUPERV_StreamGraph aSGraph = myGraph->ToStreamGraph();
1582 if (!SUPERV_isNull(aSGraph))
1583 aSGraph->SetStreamParams( myTimeOut->text().toLong(),
1584 (SUPERV::KindOfDataStreamTrace) myDataStreamTrace->currentItem(),
1585 myDeltaTime->value());