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::onShowToolbar()
554 SUPERVGraph_ViewFrame* aVF = (SUPERVGraph_ViewFrame*)this->parent();
556 aVF->getToolBar()->show();
559 void SUPERVGUI_Main::run( const bool andSuspend ) {
560 Trace("SUPERVGUI_Main::run");
561 if ( SUPERV_isNull(dataflow) )
564 if ( dataflow->IsEditing() ) { // not currently Executing
566 // asv 31.01.05 : fix for PAL7854, Editing moved from SUPERVGUI.cxx runDataflow(), stepByStep() to here..
567 Editing(); // remove old executor, update GUI (all nodes to "No Status")
569 if ( !dataflow->IsValid() ) {
570 QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("ERROR"), tr("MSG_DF_NOTVALID") + QString(" : ") + QString(dataflow->Messages()));
572 else if (!dataflow->IsExecutable()) {
573 QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("ERROR"), tr("MSG_DF_NOTEXECUTABLE") + QString(" : ") + QString(dataflow->Messages()));
575 else if (myCanvasView->isAnyLinkCreating()) {
576 QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("ERROR"), tr("MSG_CRL_NOTCOMPLETE"));
579 myRunTime = QDateTime::currentDateTime();
580 const bool result = andSuspend ? dataflow->Start() : dataflow->Run();
582 QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("ERROR"), tr("MSG_DF_BADEXECUTE"));
583 if ( dataflow->State() == SUPERV::ErrorState ) {
588 //myExecuted = true; // set to true on first execution. for correct publishing in Study
589 myThread->startThread(tr("MSG_GRAPH_STARTED"));
594 QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("ERROR"), tr("MSG_DF_RUNNING"));
599 void SUPERVGUI_Main::kill() {
600 Trace("SUPERVGUI_Main::kill");
601 if ((SUPERV_isNull(dataflow)))
604 if (dataflow->IsEditing()) {
605 QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("ERROR"), tr("MSG_DF_NOTRUNNING"));
607 else if (dataflow->Kill()) {
608 getMessage()->putMessage( tr("MSG_GRAPH_KILLED") );
612 QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("ERROR"), tr("MSG_CANTKILL_DF"));
616 void SUPERVGUI_Main::suspendResume() {
617 Trace("SUPERVGUI_Main::suspendResume");
618 if ((SUPERV_isNull(dataflow))) return;
620 if (dataflow->IsEditing()) {
621 QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("ERROR"), tr("MSG_DF_NOTRUNNING"));
622 } else if (dataflow->State() == SUPERV_Suspend) {
623 if (dataflow->Resume()) {
624 myThread->startThread(tr("MSG_DF_RESUMED"));
626 QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("ERROR"), tr("MSG_CANT_RESUME"));
629 if (dataflow->Suspend()) {
631 getMessage()->putMessage( tr("MSG_GRAPH_SUSPENDED") );
633 QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("ERROR"), tr("MSG_CANT_SUSPEND"));
637 /* asv : 15.12.04 : commented out stopRestart() in Main and CanvasNode because it's not called from anywhere,
638 the comment from kloss below may be explaining it, but it's in French and I do not understand it..
639 It also calls deprecated method of Engine: ReStart().
640 void SUPERVGUI_Main::stopRestart() { // kloss : a reviser et a connecter dans le popup du dataflow (pas de creation de bouton)
641 Trace("SUPERVGUI_Main::stopRestart");
642 if ((SUPERV_isNull(dataflow))) return;
644 if (dataflow->IsEditing()) {
645 QMessageBox::warning(0, tr("ERROR"), tr("MSG_DF_NOTRUNNING"));
646 } else if (dataflow->State() == SUPERV_Stop) {
647 if (dataflow->ReStart()) {
648 message->setMessage(tr("MSG_DF_RESTARTED"));
651 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_RESTART"));
654 if (dataflow->Stop()) {
657 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_STOP"));
662 void SUPERVGUI_Main::addNode() {
663 Trace("SUPERVGUI_Main::addNode");
665 if ( !ReadyToModify() ) // null dataflow or executing, ..
668 SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
670 MESSAGE("NULL Supervision module!");
674 //Editing(); // PAL6170: GUI->Engine: setting "Editing" flag, commented: PAL7960
675 aSupMod->getBrowser()->choose();
679 * Add Computation node
681 void SUPERVGUI_Main::addComputeNode(SUPERV_CNode theNode) {
682 switch (myCurrentView) {
690 SUPERVGUI_CanvasNode* aNode = new SUPERVGUI_CanvasComputeNode( resMgr(), myCanvas, this, theNode);
691 aNode->move(theNode->X(), theNode->Y());
692 if (myCurrentView == CONTROLFLOW) aNode->hideAll();
703 void SUPERVGUI_Main::addGOTONode(SUPERV_CNode theNode) {
704 switch (myCurrentView) {
712 SUPERVGUI_CanvasNode* aNode = new SUPERVGUI_CanvasGotoNode( resMgr(), myCanvas, this, theNode);
713 aNode->move(theNode->X(), theNode->Y());
714 if (myCurrentView == CONTROLFLOW) aNode->hideAll();
725 void SUPERVGUI_Main::addControlNode(SUPERV_CNode theStartNode, SUPERV_CNode theEndNode, bool Update) {
726 switch (myCurrentView) {
734 SUPERVGUI_CanvasStartNode* aStartNode = new SUPERVGUI_CanvasStartNode( resMgr(), myCanvas, this, theStartNode);
735 aStartNode->move(theStartNode->X(), theStartNode->Y());
736 if (myCurrentView == CONTROLFLOW) aStartNode->hideAll();
738 SUPERVGUI_CanvasEndNode* aEndNode = new SUPERVGUI_CanvasEndNode( resMgr(), myCanvas, this, theEndNode, aStartNode);
739 aEndNode->move(theEndNode->X(), theEndNode->Y());
740 if (myCurrentView == CONTROLFLOW) aEndNode->hideAll();
754 void SUPERVGUI_Main::addMacroNode(SUPERV_CNode theNode) {
755 switch (myCurrentView) {
763 SUPERVGUI_CanvasNode* aNode = new SUPERVGUI_CanvasMacroNode( resMgr(), myCanvas, this, theNode);
764 aNode->move(theNode->X(), theNode->Y());
765 if (myCurrentView == CONTROLFLOW) aNode->hideAll();
773 SUPERVGUI_CanvasArray* SUPERVGUI_Main::getCanvasArray() {
774 Trace("SUPERVGUI_Main::getCanvasArray");
778 SUPERVGUI_ArrayView* SUPERVGUI_Main::getArrayView() {
779 Trace("SUPERVGUI_Main::getArrayView");
783 SUPERVGUI_Canvas* SUPERVGUI_Main::getCanvas() {
784 Trace("SUPERVGUI_Main::getCanvas");
788 SUPERVGUI_CanvasView* SUPERVGUI_Main::getCanvasView() {
789 Trace("SUPERVGUI_Main::getCanvasView");
790 return(myCanvasView);
793 SUPERV_Graph SUPERVGUI_Main::getDataflow() {
794 Trace("SUPERVGUI_Main::getDataflow");
798 LogWindow* SUPERVGUI_Main::getMessage() {
799 Trace("SUPERVGUI_Main::getMessage");
803 SUIT_Study* SUPERVGUI_Main::getStudy() {
804 Trace("SUPERVGUI_Main::getStudy");
808 bool SUPERVGUI_Main::isArrayShown() {
809 Trace("SUPERVGUI_Main::isArrayShown");
810 return(myCurrentView == CANVASTABLE);
813 void SUPERVGUI_Main::showPopup(QPopupMenu* p, QMouseEvent* e) {
814 Trace("SUPERVGUI_Main::showPopup");
815 // To check is Supervision active?
816 if (myIsLocked) return;
817 //if (dataflow->IsExecuting()) return;
819 CAM_Application* anApp = ( CAM_Application* )(SUIT_Session::session()->activeApplication());
820 if ( anApp->activeModule()->moduleName().compare( anApp->moduleTitle( "SUPERV" ) ) !=0 ) return;
822 if (e->button() == RightButton) {
823 p->exec(e->globalPos());
827 void SUPERVGUI_Main::changeInformation() {
828 SUPERVGUI_Information* aDlg = new SUPERVGUI_Information(SUPERV::CNode::_narrow(dataflow), dataflow->IsReadOnly());
834 void SUPERVGUI_Main::chooseData(QListViewItem* item) {
835 Trace("SUPERVGUI_Main::chooseData");
837 QString id = ((OB_ListItem*)item)->text(2);// <=> get entry
839 _PTR(SObject) object ( (( SalomeApp_Study* )study)->studyDS()->FindObjectID(id.latin1()) );
840 _PTR(GenericAttribute) anAttr;
841 if (object->FindAttribute(anAttr, "AttributeIOR")) {
842 _PTR(AttributeIOR) anIOR ( anAttr );
844 // asv : 13.12.04 : commented out use of portIn field, but it seems that it
845 // should be replaced with some analogious code... selection of IOR was done -
846 // put its value into port.
847 //portIn->setValue(ior);
849 SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
851 MESSAGE("NULL Supervision module!");
857 setCursor(aSupMod->getCursor());
858 objectBrowser->setCursor(aSupMod->getCursor());
859 aSupMod->putInfo("");
865 _PTR(SObject) SearchOrCreateSOWithName( _PTR(Study) const theStudy,
866 _PTR(StudyBuilder) const theBuilder,
867 _PTR(SObject) const theSO,
869 bool* theDoneSomething ) {
870 _PTR(SObject) aResult;
871 _PTR(AttributeName) aName;
872 _PTR(GenericAttribute) anAttr;
873 _PTR(ChildIterator) anIterator ( theStudy->NewChildIterator(theSO) );
874 for (; anIterator->More(); anIterator->Next()) {
875 if (anIterator->Value()->FindAttribute(anAttr, "AttributeName")) {
877 if (strcmp(aName->Value().c_str(), theName) == 0) {
878 aResult = anIterator->Value();
884 // if aResule was found then theDoneSomething=false and we return
885 *theDoneSomething = !aResult ? 1 : 0;//->_is_nil();
886 if ( !*theDoneSomething )
890 aResult = theBuilder->NewObject( theSO );
891 anAttr = theBuilder->FindOrCreateAttribute(aResult, "AttributeName");
893 aName->SetValue(theName);
898 * Return true if dataflow is already in the study
900 bool SUPERVGUI_Main::isDataflowInStudy() const {
901 _PTR(Study) aStudy = (( SalomeApp_Study* )study)->studyDS();
902 _PTR(SObject) aSO ( aStudy->FindObjectIOR( dataflow->getIOR() ) );
903 return ( aSO ? true : false );
907 * Create a "Supervision" object in the Study and a "dataflow" object under it
908 * aDoneSomething will be true if "Supervision" or "dataflow" object were created (not found).
910 _PTR(SObject) createDataflowSObj( SUIT_Study* study,
911 SUPERV::Graph_var dataflow,
912 _PTR(StudyBuilder) aBuilder,
913 bool& aDoneSomething ) {
914 _PTR(Study) aStudy = (( SalomeApp_Study* )study)->studyDS();
915 _PTR(GenericAttribute) anAttr;
916 _PTR(AttributeName) aName;
918 // Find or create "Supervisor -> aNewDataflow_1" SObjects in the study
919 _PTR(SObject) aSO = aStudy->FindObjectIOR( dataflow->getIOR() );
920 if ( !aSO ) { // dataflow SObject not found in the study
921 aDoneSomething = true;
922 _PTR(SComponent) aComponent = aStudy->FindComponent(STUDY_SUPERVISION);
923 if ( !aComponent ) { // is supervision component not found, then create it
924 aComponent = aBuilder->NewComponent(STUDY_SUPERVISION);
925 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributeName");
927 aName->SetValue( (( CAM_Application* )(study->application()))->moduleTitle( "SUPERV" ).latin1() );
929 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributePixMap");
930 _PTR(AttributePixMap) aPixmap ( anAttr );
931 aPixmap->SetPixMap( "ICON_OBJBROWSER_Supervision" );
933 SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
935 aBuilder->DefineComponentInstance(aComponent, SalomeApp_Application::orb()->object_to_string(aSupMod->getEngine()));
936 //dynamic_cast<SALOMEDS_Study*>( aStudy )->ConvertObjectToIOR(aSupMod->getEngine()));
937 else MESSAGE("NULL Supervision module!");
940 // create dataflow SObject ("aNewDataflow_1")
941 aSO = aBuilder->NewObject(aComponent);
942 anAttr = aBuilder->FindOrCreateAttribute(aSO, "AttributeName");
944 aName->SetValue(dataflow->Name());
945 anAttr = aBuilder->FindOrCreateAttribute(aSO, "AttributeIOR");
946 _PTR(AttributeIOR) anIORAttr ( anAttr );
947 anIORAttr->SetValue(dataflow->getIOR());
953 void SUPERVGUI_Main::addDataflowToStudy() {
955 _PTR(StudyBuilder) aBuilder ( (( SalomeApp_Study* )study)->studyDS()->NewBuilder() );
956 aBuilder->NewCommand();
957 _PTR(SObject) aDF ( createDataflowSObj( study, dataflow, aBuilder, isCreated ) );
959 aBuilder->CommitCommand();
960 // what is this register/unregister?? don't know..
961 SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
963 MESSAGE("NULL Supervision module!");
966 aSupMod->unregisterGraph(this);
967 aSupMod->registerGraph(dataflow->getIOR(), this);
969 if ( !myThread->running() )
970 aSupMod->updateObjBrowser();
973 MESSAGE( "ERROR: failed to find or create dataflow SObject" );
974 aBuilder->AbortCommand();
978 bool SUPERVGUI_Main::putDataStudy( SUPERV_Port p, const char* inout ) {
979 Trace("SUPERVGUI_Main::putDataStudy");
981 bool PublishOtherComponent = false;
983 // static variable to ensure that only one instance (thread) is executing this function
984 static bool isIn = false;
985 if (isIn) return true;
988 _PTR(Study) aStudy = (( SalomeApp_Study* )study)->studyDS();
989 const bool aLocked = aStudy->GetProperties()->IsLocked();
990 _PTR(StudyBuilder) aBuilder ( aStudy->NewBuilder() );
991 bool aDoneSomething = false;
993 // asv 23.11.04 : fix for PAL6852 if the study is locked -- then we can't put anything in it.
995 MESSAGE( "The study is locked and can not be modified!" );
1000 // check if the port and its node are good
1001 if ( CORBA::is_nil( p ) || CORBA::is_nil( p->Node() ) ) {
1002 MESSAGE( "putInStudy ERROR: port or node are NULL!" );
1007 // open new command. Commit or Abort it depending on aDoneSomething variable or error
1008 aBuilder->NewCommand();
1010 // Find or create "Supervisor -> aNewDataflow_1" SObjects in the study
1011 _PTR(SObject) aSO = createDataflowSObj( study, dataflow, aBuilder, aDoneSomething );
1014 MESSAGE( "ERROR: putDataStudy() could not find or create dataflow SObject" );
1015 aBuilder->AbortCommand();
1020 // Create "Run -> Time and date, etc." SObjects
1021 if ( p->State() == SUPERV::ReadyState ) { // if port contains valid computed value
1023 aSO = SearchOrCreateSOWithName( aStudy, aBuilder, aSO, QString("Run ") + myRunTime.toString(), &aDoneSomething ); // get run time SO
1024 aSO = SearchOrCreateSOWithName( aStudy, aBuilder, aSO, p->Node()->Name(), &aDoneSomething ); // get node SO
1025 aSO = SearchOrCreateSOWithName( aStudy, aBuilder, aSO, inout, &aDoneSomething ); // get in/out SO
1026 aSO = SearchOrCreateSOWithName( aStudy, aBuilder, aSO, p->Name(), &aDoneSomething ); // get port SO
1028 // create IOR attribute for port SObject (usually with "return" name)
1029 _PTR(GenericAttribute) anAttr ( aBuilder->FindOrCreateAttribute(aSO, "AttributeIOR") );
1030 _PTR(AttributeIOR) anIORAttr ( anAttr );
1032 // if we have not created anything (all SObject already existed) and we have the same IORAttribute
1033 // on the needed SObject -> then don't do anything! it's already there!
1034 if ( !aDoneSomething && strcmp(anIORAttr->Value().c_str(), p->ToString()) == 0 ) {
1035 aBuilder->AbortCommand();
1040 aDoneSomething = true; // going to set some value to anIORAttr any way from this point..
1042 // set object value to the study: if object is external, then put it with
1043 // help of the specific component - owner
1045 // get according component driver for result object
1046 SALOME_LifeCycleCORBA aLCC( myNService );
1047 SUPERV_FNode aFNode = SUPERV::FNode::_narrow( p->Node() );
1048 if ( !aFNode->_is_nil() ) {
1049 Engines::Component_var aComponent = aLCC.FindOrLoad_Component( aFNode->GetContainer(), aFNode->GetComponentName() );
1050 SALOMEDS::Driver_var aDriver = SALOMEDS::Driver::_narrow( aComponent );
1051 if ( !CORBA::is_nil( aDriver ) ) { // if driver was found, publish object
1052 CORBA::Object_ptr anObject = new CORBA::Object();
1053 CORBA::Any* anAny = p->ToAny();
1054 (*anAny) >>= anObject;
1056 if ( aDriver->CanPublishInStudy( anObject ) ) {
1057 SALOMEDS::SObject_var aTmpSO;// = aSO;
1058 SALOMEDS_Study* aSStudy = dynamic_cast<SALOMEDS_Study*>( aStudy.get() );
1059 if ( !aSStudy ) return false;
1060 aTmpSO = aDriver->PublishInStudy( aSStudy->GetStudy(), aTmpSO, anObject, "" );
1061 aBuilder->Addreference(aSO, _PTR(SObject)(new SALOMEDS_SObject( aTmpSO )) );
1062 PublishOtherComponent = true;
1064 else { // can't publish object: abort transaction
1065 MESSAGE( "CanPublishInStudy() returned FALSE. ok, AbortCommand.." );
1066 aBuilder->AbortCommand();
1071 else { // component has no driver, but could store IORs (like Calculator)
1072 _PTR(SObject) anIORSO ( aStudy->FindObjectIOR( p->ToString() ) );
1074 aBuilder->Addreference(aSO, anIORSO);
1076 PublishOtherComponent = true;
1078 else { // Hm... the object (==port value) was not found, so we don't publish it.
1079 MESSAGE( "The object (==port value) was not found, so we don't publish it" );
1080 aBuilder->AbortCommand();
1086 else { // FNode is NULL -> bad
1087 MESSAGE( "FNode is NULL." );
1088 if ( SUPERV::INode::_narrow( p->Node() ) ) { // mkr : IPAL10175
1089 _PTR(SObject) anIORSO ( aStudy->FindObjectIOR( p->ToString() ) );
1091 aBuilder->Addreference(aSO, anIORSO);
1094 MESSAGE( "FNode and INode are NULL. Not good at all. Aborting command." );
1095 aBuilder->AbortCommand();
1102 anIORAttr->SetValue( p->ToString() ); // ior attribute already set for the prevoius condition
1106 if ( aDoneSomething )
1107 aBuilder->CommitCommand();
1109 aBuilder->AbortCommand();
1111 SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
1113 if ( PublishOtherComponent )
1114 dynamic_cast<SalomeApp_Application*>( study->application() )->updateObjectBrowser(true);
1116 aSupMod->updateObjBrowser();
1118 else MESSAGE("NULL Supervision module!");
1125 void SUPERVGUI_Main::ActivatePanning()
1127 if (myCanvasView->isVisible()) {
1128 myCanvasView->ActivatePanning();
1129 } else if (myArrayView->isVisible()) {
1130 myArrayView->ActivatePanning();
1135 void SUPERVGUI_Main::ResetView()
1137 if (myCanvasView->isVisible()) {
1138 myCanvasView->ResetView();
1139 } else if (myArrayView->isVisible()) {
1140 myArrayView->ResetView();
1144 void SUPERVGUI_Main::syncNotification() {
1154 while (notification->Receive(&graph, &node, &type, &message, &sender, &counter, &date, &stamp)) {
1155 // if (isFiltered(graph, node, type, message, sender, counter, date, stamp)) {
1157 mess += "NOTIF: "; mess += graph;
1158 mess += " / " ; mess += node;
1159 mess += " / " ; mess += type;
1160 mess += " / " ; mess += message;
1161 getMessage()->putMessage(mess.latin1());
1166 bool SUPERVGUI_Main::isFiltered(char* graph, char* node, char* type, char* message,
1167 char* sender, long counter, char* date, long stamp) {
1168 Trace("SUPERVGUI_Main::isFiltered");
1170 if (strcmp(getDataflow()->Name(), graph) == 0) {
1171 SUPERVGUI_CanvasNode* n;
1172 QObjectList* nodes = queryList("SUPERVGUI_CanvasNode");
1173 QObjectListIt i(*nodes);
1174 while ((n=(SUPERVGUI_CanvasNode*)i.current()) != 0) {
1176 if (strcmp(n->name(), node) == 0) {
1177 if (strcmp(type, NOTIF_WARNING) == 0) {
1179 } else if (strcmp(type, NOTIF_STEP) == 0) {
1181 } else if (strcmp(type, NOTIF_TRACE) == 0) {
1183 } else if (strcmp(type, NOTIF_VERBOSE) == 0) {
1190 if ( myLogged && myLogFile && ( ( !myFiltered ) || b ) ) {
1191 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 );
1192 fflush( myLogFile );
1198 void SUPERVGUI_Main::closeEvent(QCloseEvent* e) {
1203 void SUPERVGUI_Main::setPaletteBackgroundColor(const QColor& color) {
1205 myCanvas->setBackgroundColor(color);
1206 myCanvasView->setPaletteBackgroundColor(color.light());
1207 myArray->setBackgroundColor(color);
1208 myArrayView->setPaletteBackgroundColor(color.light());
1210 SUPERVGraph_View::setPaletteBackgroundColor(color);
1213 QPtrList< char * > SUPERVGUI_Main::getEventNodes() {
1214 return myEventNodes;
1217 void SUPERVGUI_Main::setEventNodes(QPtrList< char * > theEventNodes) {
1218 myEventNodes = theEventNodes;
1221 QPtrList< SUPERV::GraphState > SUPERVGUI_Main::getStates() {
1225 void SUPERVGUI_Main::setStates(QPtrList< SUPERV::GraphState > theStates) {
1226 myStates = theStates;
1229 int SUPERVGUI_Main::getNodesNumber() {
1230 //create a list of nodes of the graph
1231 SUPERV_Nodes nodes = getDataflow()->Nodes();
1232 int RetVal = nodes->CNodes.length() + nodes->FNodes.length() +
1233 nodes->INodes.length() + nodes->GNodes.length() +
1234 nodes->LNodes.length() + nodes->SNodes.length();
1238 SUPERVGUI_Thread* SUPERVGUI_Main::getMyThread() {
1242 void SUPERVGUI_Main::startTimer() {
1243 myTimer->start(500);
1246 void SUPERVGUI_Main::executionFinished() {
1247 SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
1249 //aSupMod->updateObjBrowser();
1250 // PAL10611: update all modules data
1251 aSupMod->getApp()->updateObjectBrowser(true);
1252 else MESSAGE("NULL Supervision module!");
1258 void SUPERVGUI_Main::checkExecution() {
1259 if (myThread->finished()) {
1261 executionFinished();
1266 * Editing() is to be called by any operation in GUI before modification of a datamodel
1267 * (add/remove ports or nodes, etc.). It is used to resolve inconsistancies between 2 data models
1268 * in Engine: Editor and Executor. During and after execution, the values of ports and statuses of nodes
1269 * are taken from Executor data model. But when user starts editing the graph - these changes must
1270 * be applied to Editor data model. This function destroys Executor data model and moves to Editor.
1272 void SUPERVGUI_Main::Editing() {
1273 if ( !SUPERV_isNull( dataflow ) )
1274 dataflow->Editing();
1276 // updata GUI, Nodes' statuses and Ports' values could change.
1280 void SUPERVGUI_Main::removeArrayChild(SUPERV::CNode_ptr theNode)
1282 // mkr: since the deletion of the node allow only in CANVAS view,
1283 // it is necessary to remove the CanvasArray's children, which
1284 // have the same CNode engine as deleting node. This CNode is given
1287 const QObjectList* aChList = myArray->children();
1288 if ( aChList ) { // asv 27.01.05 : fix for 7817
1289 QObjectListIt aItChList(*aChList);
1290 SUPERVGUI_CanvasNode* anObjNode;
1291 while ((anObjNode = (SUPERVGUI_CanvasNode*)aItChList.current()) != 0) {
1293 if ((QString(anObjNode->getEngine()->Name())).compare(QString(theNode->Name())) == 0) {
1294 myArray->removeChild(anObjNode);
1298 } // end of if ( ChList )
1303 * ReadyToModify() must be called before any modification
1304 * operation - asks to kill execution of dataflow. If returns false -
1305 * modification (==Editing() ) is not allowed.
1307 bool SUPERVGUI_Main::ReadyToModify() {
1308 if ( CORBA::is_nil( dataflow ) )
1310 if ( dataflow->IsExecuting() ) {
1311 bool quit = SUIT_MessageBox::warn2( SUIT_Session::session()->activeApplication()->desktop(), // 0=Yes, 1=No
1312 tr("WARNING"), tr("MSG_GRAPH_ISRUN"), tr( "BUT_YES" ), tr( "BUT_CANCEL" ), 0, 1, 0 );
1313 if ( quit ) // user selected NOT to kill dataflow and NOT to add new node
1315 else if ( dataflow->IsExecuting() ) // user selected to kill the dataflow and add new node after that
1316 kill(); // checking again for IsExecuting to be sure that it was not finished while MB was up
1321 void SUPERVGUI_Main::resizeView( QResizeEvent* theEvent )
1323 if ( (myCurrentView == CANVAS || myCurrentView == CONTROLFLOW) && getCanvas() )
1324 if ( getCanvas()->width() < theEvent->size().width()
1326 getCanvas()->height() < theEvent->size().height() )
1327 getCanvas()->resize( theEvent->size().width(), theEvent->size().height() );
1328 if ( myCurrentView == CANVASTABLE && getCanvasArray() )
1329 if ( getCanvasArray()->width() < theEvent->size().width()
1331 getCanvasArray()->height() < theEvent->size().height() )
1332 getCanvasArray()->resize( theEvent->size().width(), theEvent->size().height() );
1335 /******************************* SUPERVGUI_Thread class ****************************************/
1336 SUPERVGUI_Thread::SUPERVGUI_Thread()
1342 SUPERVGUI_Thread::~SUPERVGUI_Thread()
1344 //it is a virtual destructor and needs to be determine here
1347 void SUPERVGUI_Thread::startThread(const char* m)
1352 myMain->getMessage()->putMessage(m);
1359 void SUPERVGUI_Thread::setMain( SUPERVGUI_Main* theMain )
1364 void SUPERVGUI_Thread::KillThread( bool theValue )
1367 myIsActive = !(theValue);
1371 template<class TObject, typename TArg, typename TArg1, typename TArg2,
1372 typename TStoreArg = TArg, typename TStoreArg1 = TArg1, typename TStoreArg2 = TArg2>
1373 class TVoidMemFun3ArgEvent: public SALOME_Event{
1375 typedef void (TObject::* TAction)(TArg,TArg1,TArg2);
1376 TVoidMemFun3ArgEvent(TObject* theObject, TAction theAction, TArg theArg, TArg1 theArg1, TArg2 theArg2):
1377 myObject(theObject),
1378 myAction(theAction),
1383 virtual void Execute(){
1384 (myObject->*myAction)(myArg,myArg1,myArg2);
1394 typedef TVoidMemFun3ArgEvent<SUPERVGUI_Thread, SUPERV_CNode&, SUPERV::GraphEvent&, SUPERV::GraphState&> TMainRunEvent;
1397 * main_thread_run must be executed in the qt main thread
1398 * It is activated by calling ProcessVoidEvent
1400 void SUPERVGUI_Thread::main_thread_run(SUPERV_CNode& aNode, SUPERV::GraphEvent& aEvent, SUPERV::GraphState& aState)
1402 // in case node "said" something during changing state through notification mechanism - output it
1403 myMain->syncNotification();
1405 // "kill" or undefined event came
1406 if (( aEvent == SUPERV::UndefinedEvent && aState == SUPERV::UndefinedState ) ||
1407 ( aEvent == SUPERV::NoEvent && aState == SUPERV::NoState ) ||
1408 ( aEvent == SUPERV::KillEvent && aState == SUPERV::KillState )) {
1412 else { // a "normal" execution event came
1414 if ( aNode != NULL && !CORBA::is_nil( aNode ) )
1415 aName = aNode->Name();
1417 // What follow is not quite sure. The entire function is posted to the main qt thread.
1418 // So all executions are serialized. Is it really possible to call execute when another
1419 // execute is running. I don't think so (C Caremoli)
1420 // this function is asynchronious. The call does NOT wait when SUPERVGUI_Main::execute finishes
1421 // handling the event. So: SUPERVGUI_Main::execute must be fast, in order we don't get here again
1422 // on the next loop iteration, BEFORE previous SUPERVGUI_Main::execute finished.
1423 myMain->execute(aName, aState );
1426 // execution is finished. just set a "finished" message(s)
1427 if ( !myIsActive ) {
1428 switch ( myMain->getDataflow()->State() ) {
1429 case SUPERV_Editing :
1430 myMain->getMessage()->putMessage( myMain->getDataflow()->IsReadOnly()?
1431 tr("MSG_GRAPH_READONLY"): tr("MSG_GRAPH_EDITING") );
1433 case SUPERV_Suspend :
1434 myMain->getMessage()->putMessage( tr("MSG_GRAPH_SUSPENDED") );
1437 myMain->getMessage()->putMessage( tr("MSG_GRAPH_FINISHED") );
1440 myMain->getMessage()->putMessage( tr("MSG_GRAPH_ABORTED") );
1443 myMain->getMessage()->putMessage( tr("MSG_GRAPH_KILLED") );
1447 // asv 03.02.05 : fix for PAL6859, not very good, but works..
1449 } // end of if !myIsActive
1452 void SUPERVGUI_Thread::run()
1454 myMain->startTimer();
1456 // GUI cycle to handle events coming for Engine
1457 while ( myIsActive ) {
1459 SUPERV_CNode aNode = NULL;
1460 SUPERV::GraphEvent aEvent = SUPERV::UndefinedEvent ;
1461 SUPERV::GraphState aState = SUPERV::UndefinedState ;
1463 // blocking function of Engine. Return from there only after anEvent happens on node aNode
1464 myMain->getDataflow()->Event(aNode, aEvent, aState);
1466 ProcessVoidEvent( new TMainRunEvent( this, &SUPERVGUI_Thread::main_thread_run,aNode, aEvent, aState ) );
1468 } // end of while( myIsActive )
1473 /******************************* SUPERVGUI_DSGraphParameters class ****************************************/
1477 SUPERVGUI_DSGraphParameters::SUPERVGUI_DSGraphParameters(SUPERV_Graph theGraph, bool isReadOnly)
1478 : QDialog( SUIT_Session::session()->activeApplication()->desktop(), "", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
1480 Trace("SUPERVGUI_DSGraphParameters::SUPERVGUI_DSGraphParameters");
1481 setCaption( tr( "TLT_DSGRAPHPARAMS" ) );
1482 setSizeGripEnabled( true );
1485 QGridLayout* TopLayout = new QGridLayout( this );
1486 TopLayout->setSpacing( 6 );
1487 TopLayout->setMargin( 11 );
1489 QGroupBox* TopGroup = new QGroupBox( this, "TopGroup" );
1490 TopGroup->setColumnLayout(0, Qt::Vertical );
1491 TopGroup->layout()->setSpacing( 0 );
1492 TopGroup->layout()->setMargin( 0 );
1493 QGridLayout* TopGroupLayout = new QGridLayout( TopGroup->layout() );
1494 TopGroupLayout->setAlignment( Qt::AlignTop );
1495 TopGroupLayout->setSpacing( 6 );
1496 TopGroupLayout->setMargin( 11 );
1499 QLabel* DeltaTimeL = new QLabel( tr( "DELTATIME_LBL" ), TopGroup );
1500 TopGroupLayout->addWidget( DeltaTimeL, 0, 0 );
1502 myDeltaTime = new QtxDblSpinBox( 0.0, 1.0, 0.1, TopGroup );
1503 myDeltaTime->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
1504 TopGroupLayout->addWidget( myDeltaTime, 0, 1 );
1507 QLabel* TimeOutL = new QLabel( tr( "TIMEOUT_LBL" ), TopGroup);
1508 TopGroupLayout->addWidget( TimeOutL, 1, 0 );
1510 myTimeOut = new QLineEdit( TopGroup );
1511 myTimeOut->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
1512 myTimeOut->setValidator( new QIntValidator(this) );
1513 myTimeOut->setMinimumSize( 100, 0 );
1514 myTimeOut->setReadOnly( isReadOnly );
1515 TopGroupLayout->addWidget( myTimeOut, 1, 1 );
1518 QLabel* DataStreamTraceL = new QLabel( tr( "DATASTREAMTRACE_LBL" ), TopGroup);
1519 TopGroupLayout->addWidget( DataStreamTraceL, 2, 0 );
1521 myDataStreamTrace = new QComboBox( TopGroup );
1522 myDataStreamTrace->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
1523 myDataStreamTrace->insertItem("WithoutTrace");
1524 myDataStreamTrace->insertItem("SummaryTrace");
1525 myDataStreamTrace->insertItem("DetailedTrace");
1526 TopGroupLayout->addWidget( myDataStreamTrace, 2, 1 );
1528 QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
1529 GroupButtons->setColumnLayout(0, Qt::Vertical );
1530 GroupButtons->layout()->setSpacing( 0 );
1531 GroupButtons->layout()->setMargin( 0 );
1532 QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
1533 GroupButtonsLayout->setAlignment( Qt::AlignTop );
1534 GroupButtonsLayout->setSpacing( 6 );
1535 GroupButtonsLayout->setMargin( 11 );
1537 QPushButton* okB = new QPushButton( tr( "BUT_OK" ), GroupButtons );
1538 QPushButton* cancelB = new QPushButton( tr( "BUT_CANCEL" ), GroupButtons );
1540 GroupButtonsLayout->addWidget( okB, 0, 0 );
1541 GroupButtonsLayout->addItem ( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
1542 GroupButtonsLayout->addWidget( cancelB, 0, 2 );
1544 TopLayout->addWidget( TopGroup, 0, 0 );
1545 TopLayout->addWidget( GroupButtons, 1, 0 );
1547 connect( okB, SIGNAL( clicked() ), this, SLOT( accept() ) );
1548 connect( cancelB, SIGNAL( clicked() ), this, SLOT( reject() ) );
1556 SUPERVGUI_DSGraphParameters::~SUPERVGUI_DSGraphParameters() {
1557 Trace("SUPERVGUI_DSGraphParameters::~SUPERVGUI_DSGraphParameters");
1563 void SUPERVGUI_DSGraphParameters::setData() {
1566 SUPERV::KindOfDataStreamTrace aDataStreamTrace;
1568 // myGraph->StreamParams(aTimeOut, aDataStreamTrace, aDeltaTime);
1569 if (myGraph->IsStreamGraph()) {
1570 SUPERV_StreamGraph aSGraph = myGraph->ToStreamGraph();
1571 if (!SUPERV_isNull(aSGraph))
1572 aSGraph->StreamParams(aTimeOut, aDataStreamTrace, aDeltaTime);
1575 myDeltaTime->setValue(aDeltaTime);
1576 myTimeOut->setText(QString("%1").arg(aTimeOut));
1577 myDataStreamTrace->setCurrentItem((int)aDataStreamTrace);
1583 void SUPERVGUI_DSGraphParameters::accept() {
1584 // myGraph->SetStreamParams( myTimeOut->text().toLong(),
1585 // (SUPERV::KindOfDataStreamTrace) myDataStreamTrace->currentItem(),
1586 // myDeltaTime->value());
1587 if (myGraph->IsStreamGraph()) {
1588 SUPERV_StreamGraph aSGraph = myGraph->ToStreamGraph();
1589 if (!SUPERV_isNull(aSGraph))
1590 aSGraph->SetStreamParams( myTimeOut->text().toLong(),
1591 (SUPERV::KindOfDataStreamTrace) myDataStreamTrace->currentItem(),
1592 myDeltaTime->value());