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 objectBrowser = dynamic_cast<SalomeApp_Application*>( study->application() )->objectBrowser();
144 myArray = new SUPERVGUI_CanvasArray(this);
145 myArrayView = new SUPERVGUI_ArrayView(myArray, this);
147 myCanvas = new SUPERVGUI_Canvas(this);
148 myCanvasView = new SUPERVGUI_CanvasView(myCanvas, this);
150 message = dynamic_cast<SalomeApp_Application*>( study->application() )->logWindow();
151 notification = new NOTIFICATION_Consumer();
153 QBoxLayout * layout = new QVBoxLayout(this);
154 layout->setMargin(0);
155 layout->setSpacing(0);
156 layout->addWidget(myCanvasView);
157 layout->addWidget(myArrayView);
159 if (myCurrentView == CANVAS || myCurrentView == CONTROLFLOW) {
165 if ( myLogged && !myLogFileName.isEmpty() && QFile::exists( myLogFileName ) ) {
166 myLogFile = fopen( myLogFileName.latin1(), "a" );
167 if ( myLogFile == NULL )
170 myTimer = new QTimer( this );
171 connect( myTimer, SIGNAL(timeout()), this, SLOT(checkExecution()) );
174 SUPERVGUI_Main::~SUPERVGUI_Main() {
175 Trace("SUPERVGUI_Main::~SUPERVGUI_Main");
177 // close all opened SubGraphs
178 QMap<QString, SUIT_ViewWindow*/*QAD_StudyFrame**/>::iterator it;
179 for (it = mySubGraphs.begin(); it != mySubGraphs.end(); ++it) {
180 it.data()->removeEventFilter(this);
181 it.data()->disconnect();
182 //it.data()->close();
184 //QAD_Study* aStudy = it.data()->getStudy();
185 //aStudy->removeStudyFrame(it.data());
186 //remove view from internal view manager's list of views
187 //it.data()->getViewManager()->removeView(it.data());
188 SUIT_ViewManager* aVM = it.data()->getViewManager();
189 STD_Application* anApp = dynamic_cast<STD_Application*>( SUIT_Session::session()->activeApplication() );
190 if ( anApp ) anApp->removeViewManager(aVM);
191 if ( aVM ) delete aVM;
195 mySubGraphMap.clear();
197 QAD_StudyFrame* aSubGraph;
198 for (aSubGraph = mySubGraphs.first(); aSubGraph; aSubGraph = mySubGraphs.next()) {
199 aSubGraph->removeEventFilter(this);
204 if ( myLogFile != NULL) {
208 // delete notification; // kloss : nota bene : quand un datalow est detruit : verifier que les canaux de notification sont aussi detruit
209 notification->_remove_ref(); // kloss : nota bene : quand un datalow est detruit : verifier que les canaux de notification sont aussi detruit
215 void SUPERVGUI_Main::filterNotification() {
216 Trace("SUPERVGUI_Main::filterNotification");
217 SUPERVGUI_Notification* dlg = new SUPERVGUI_Notification(this);
218 dlg->setFiltered( myFiltered );
219 dlg->setLogged( myLogged, myLogFileName );
220 dlg->setWarning( myWarning );
221 dlg->setStep( myStep );
222 dlg->setTrace( myTrace );
223 dlg->setVerbose( myVerbose );
224 if ( dlg->exec() == QDialog::Accepted ) {
225 myLogged = dlg->getLogged();
226 myLogFileName = dlg->getLogFile();
227 myFiltered = dlg->getFiltered();
228 myWarning = dlg->getWarning();
229 myStep = dlg->getStep();
230 myTrace = dlg->getTrace();
231 myVerbose = dlg->getVerbose();
233 if ( myLogFile != NULL) {
237 if ( myLogged && !myLogFileName.isEmpty() && QFile::exists( myLogFileName ) ) {
238 myLogFile = fopen( myLogFileName.latin1(), "a" );
239 if ( myLogFile == NULL ) {
241 QMessageBox::warning( SUIT_Session::session()->activeApplication()->desktop(), tr("ERROR"), tr( "ERR_CANT_OPEN_LOG_FILE" ) );
247 void SUPERVGUI_Main::changeDSGraphParameters() {
248 SUPERVGUI_DSGraphParameters* aDlg = new SUPERVGUI_DSGraphParameters(dataflow, dataflow->IsReadOnly());
254 void SUPERVGUI_Main::syncAsync() {
255 Trace("SUPERVGUI_Main::syncAsync");
256 QTimer::singleShot(1, this, SLOT(sync()));
261 * Called by thread when dataflow is executing
263 void SUPERVGUI_Main::execute( char * theNodeName, SUPERV::GraphState theNodeState ) {
264 if (myCurrentView == CANVAS || myCurrentView == CONTROLFLOW) {
265 SUPERVGUI_CanvasNode* aNode = (SUPERVGUI_CanvasNode*) myCanvas->child(theNodeName, "SUPERVGUI_CanvasNode");
269 else if (myCurrentView == CANVASTABLE) {
270 SUPERVGUI_CanvasCellNode* aNode = (SUPERVGUI_CanvasCellNode*) myArray->child(theNodeName, "SUPERVGUI_CanvasCellNode");
275 // asv : 26.01.05 : Bug PAL7164 : puting out-value to study if the "put_to_Study" flag is set on a
276 // CanvasPort the functionality was moved from SUPERVGUI_CanvasPortOut::sync() method please, see
277 // comment in that method for details.
278 if ( theNodeState == SUPERV::DoneState ) {
279 SUPERVGUI_CanvasNode* aNode = (SUPERVGUI_CanvasNode*) myCanvas->child(theNodeName, "SUPERVGUI_CanvasNode");
281 //cout << " *** theNode " << theNodeName << " received DONE_STATE *** " << endl;
282 SUPERVGUI_CanvasPortOut* aPortOut;
283 QObjectList* aPortList = aNode->queryList("SUPERVGUI_CanvasPortOut");
284 QObjectListIt aPortIt(*aPortList);
285 while ((aPortOut=(SUPERVGUI_CanvasPortOut*)aPortIt.current()) != 0) {
287 if ( aPortOut->isInStudy() && aPortOut->getEngine()->State() == SUPERV::ReadyState ) {
288 //cout << " *** " << theNodeName << "[" << aPortOut->name() << "]--> goes into study *** " << endl;
289 putDataStudy( aPortOut->getEngine(), STUDY_PORT_OUT );
294 //else //normal case if Node is not found is when node is a graph! it can receive DoneState as well!
295 // MESSAGE( "ERROR in SUPERVGUI_Main::execute() : CanvasNode \"" << theNodeName << "\" NOT FOUND in myCanvas" );
300 void SUPERVGUI_Main::sync() {
301 Trace("SUPERVGUI_Main::sync");
302 if ((SUPERV_isNull(dataflow)))
304 QString t = tr("GRAPH_TITLE");
306 t += dataflow->Name();
309 //study->updateObjBrowser();
310 //mkr: we have to update object browser only if there are some ports datas in the study
311 //or if dataflow is in the study itself. It is done in the
312 //1) putDataStudy(...) method (it called when we put in study data of port
313 // or if port is in study and execution is finished)
314 //2) addDataflowToStudy() method (it is called as a slot when we add in study dataflow itself).
315 //So, we commented updateObjBrowser function here!
316 //SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
317 //if ( aSupMod ) aSupMod->updateObjBrowser();
318 //else MESSAGE("NULL Supervision module!");
320 if (myCurrentView == CANVASTABLE) {
329 void SUPERVGUI_Main::showCanvasTable() {
330 if (myCurrentView == CANVASTABLE)
333 if (myArray->create()) {
334 myCanvasView->hide();
336 myCurrentView = CANVASTABLE;
341 void SUPERVGUI_Main::showContolFlow() {
343 if (myCurrentView == CANVASTABLE) {
348 myCurrentView = CONTROLFLOW;
349 myCanvas->setControlView();
352 myCanvasView->show();
356 void SUPERVGUI_Main::showCanvas() {
357 if (myCurrentView == CANVAS)
361 if (myCurrentView == CANVASTABLE) {
366 myCurrentView = CANVAS;
367 myCanvas->setFullView();
370 myCanvasView->show();
374 void SUPERVGUI_Main::insertFile() {
375 Trace("SUPERVGUI_Main::insertFile");
377 if ( !ReadyToModify() ) // null dataflow or executing, ..
380 QString f = SUIT_FileDlg::getFileName(SUIT_Session::session()->activeApplication()->desktop(),
383 tr("MSG_GRAPH_INSERT"),
385 if ( !f.isEmpty() ) { // not Cancel, but "OK" was pressed with valid file name
387 Editing(); // PAL6170: GUI->Engine: setting "Editing" flag, why here? -> see 7960
389 if (dataflow->Import(f.latin1())) {
390 if (myCurrentView == CANVASTABLE) {
394 else { // (myCurrentView == CANVAS || myCurrentView == CONTROLFLOW) {
399 QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("ERROR"), tr("MSG_BAD_FILE").arg(f));
404 void SUPERVGUI_Main::copy() {
405 Trace("SUPERVGUI_Main::copy");
406 if (dataflow->ThreadsMax() == 0) {
407 QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("WARNING"), tr("MSG_NOTHING_COPY"));
411 SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
413 MESSAGE("NULL Supervision module!");
417 SUPERVGraph_ViewFrame* aViewFrame = dynamic_cast<SUPERVGraph_ViewFrame*>( aSupMod->createGraph() );
419 SUPERV_Graph aNewGraph; // = dataflow->StreamCopy();
420 if ( dataflow->IsStreamGraph() ) {
421 SUPERV_StreamGraph aSGraph = dataflow->ToStreamGraph();
422 if ( SUPERV_isNull(aSGraph) ) {
423 QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("WARNING"), tr("MSG_CANT_COPY"));
426 aNewGraph = aSGraph->StreamCopy();
429 aNewGraph = dataflow->Copy();
431 QString aNewName(tr("MSG_COPY_PREFIX").arg(++myCopyNum));
432 aNewName += dataflow->Name();
433 aNewGraph->SetName(aNewName);
434 /*SUPERVGUI_Main* m = */new SUPERVGUI_Main(aViewFrame,
435 aSupMod->application()->desktop(),//getDesktop(),
441 void SUPERVGUI_Main::openSubGraph(SUPERV_CNode theNode, bool correct)
443 if (theNode->IsMacro()) {
444 // get SubGraph from MacroNode
445 SUPERV_Graph aMacro = SUPERV::Graph::_narrow(theNode);
447 if (aMacro->IsStreamMacro())
448 aGraph = aMacro->StreamObjRef();
450 aGraph = aMacro->FlowObjRef();
453 if (SUPERV_isNull(aGraph)) {
454 QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("WARNING"), tr("MSG_NOACCESS"));
458 QString aGraphName = aGraph->Name();
459 SUIT_ViewWindow* aStudyFrame;
460 if (mySubGraphs.contains(aGraphName)) {
461 aStudyFrame = mySubGraphs[aGraphName];
462 aStudyFrame->setActiveWindow();
463 aStudyFrame->setFocus();
466 SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
468 MESSAGE("NULL Supervision module!");
472 aStudyFrame = aSupMod->createGraph();
474 SUPERVGraph_ViewFrame* aViewFrame = dynamic_cast<SUPERVGraph_ViewFrame*>( aStudyFrame );
476 /*SUPERVGUI_Main* m = */new SUPERVGUI_Main(aViewFrame,
477 aSupMod->application()->desktop(),//getDesktop(),
479 // connect(aStudyFrame, SIGNAL(sfStudyFrameClosing(QAD_StudyFrame*)),
480 // this, SLOT(onSubGraphClosed(QAD_StudyFrame*)));
481 connect(aSupMod->application()->desktop(), SIGNAL(windowActivated( SUIT_ViewWindow* )),
482 this, SLOT(onSubGraphActivated( SUIT_ViewWindow* )));
483 aStudyFrame->installEventFilter(this);
485 mySubGraphs.insert(aGraphName, aStudyFrame);
486 mySubGraphMap.insert(aGraphName, theNode->Name());
492 if (!correct) myLastGraph = aStudyFrame;
497 bool SUPERVGUI_Main::eventFilter( QObject* o, QEvent* e)
499 // workaround to get close event
500 if (o->inherits("SUIT_ViewWindow"/*"QAD_StudyFrame"*/) && e->type() == QEvent::Close) {
501 SUIT_ViewWindow* aFrame = (SUIT_ViewWindow*) o;
502 onSubGraphClosed(aFrame);
504 return SUPERVGraph_View::eventFilter(o, e);
507 // workaround to fix PAL6255 -> opened SubGraph is not on top
508 void SUPERVGUI_Main::onSubGraphActivated(SUIT_ViewWindow* theStudyFrame)
511 SUIT_ViewWindow* aFrame = myLastGraph;
513 aFrame->setActiveWindow();
518 void SUPERVGUI_Main::onSubGraphClosed(SUIT_ViewWindow* theStudyFrame)
520 if ( SUPERVGraph_ViewFrame* supervFrame = dynamic_cast<SUPERVGraph_ViewFrame*>( theStudyFrame ) ) {
521 theStudyFrame->removeEventFilter(this);
522 disconnect(theStudyFrame, 0, this, 0);
524 SUPERVGraph_View* view = supervFrame->getViewWidget();
525 SUPERVGUI_Main* aGraph = dynamic_cast<SUPERVGUI_Main*>(view);
527 QString aGraphName = aGraph->getDataflow()->Name();
528 QMap<QString, QString>::iterator it = mySubGraphMap.find(aGraphName);
529 if (it != mySubGraphMap.end()) {
530 QString aNodeName = it.data();
531 SUPERVGUI_CanvasNode* aNode = (SUPERVGUI_CanvasNode*)
532 myCanvas->child(aNodeName, "SUPERVGUI_CanvasNode");
537 mySubGraphMap.remove(it);
539 mySubGraphs.remove(aGraphName);
544 void SUPERVGUI_Main::run( const bool andSuspend ) {
545 Trace("SUPERVGUI_Main::run");
546 if ( SUPERV_isNull(dataflow) )
549 if ( dataflow->IsEditing() ) { // not currently Executing
551 // asv 31.01.05 : fix for PAL7854, Editing moved from SUPERVGUI.cxx runDataflow(), stepByStep() to here..
552 Editing(); // remove old executor, update GUI (all nodes to "No Status")
554 if ( !dataflow->IsValid() ) {
555 QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("ERROR"), tr("MSG_DF_NOTVALID"));
557 else if (!dataflow->IsExecutable()) {
558 QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("ERROR"), tr("MSG_DF_NOTEXECUTABLE"));
560 else if (myCanvasView->isAnyLinkCreating()) {
561 QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("ERROR"), tr("MSG_CRL_NOTCOMPLETE"));
564 myRunTime = QDateTime::currentDateTime();
565 const bool result = andSuspend ? dataflow->Start() : dataflow->Run();
567 QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("ERROR"), tr("MSG_DF_BADEXECUTE"));
568 if ( dataflow->State() == SUPERV::ErrorState ) {
573 //myExecuted = true; // set to true on first execution. for correct publishing in Study
574 myThread->startThread(tr("MSG_GRAPH_STARTED"));
579 QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("ERROR"), tr("MSG_DF_RUNNING"));
584 void SUPERVGUI_Main::kill() {
585 Trace("SUPERVGUI_Main::kill");
586 if ((SUPERV_isNull(dataflow)))
589 if (dataflow->IsEditing()) {
590 QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("ERROR"), tr("MSG_DF_NOTRUNNING"));
592 else if (dataflow->Kill()) {
593 getMessage()->putMessage( tr("MSG_GRAPH_KILLED") );
597 QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("ERROR"), tr("MSG_CANTKILL_DF"));
601 void SUPERVGUI_Main::suspendResume() {
602 Trace("SUPERVGUI_Main::suspendResume");
603 if ((SUPERV_isNull(dataflow))) return;
605 if (dataflow->IsEditing()) {
606 QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("ERROR"), tr("MSG_DF_NOTRUNNING"));
607 } else if (dataflow->State() == SUPERV_Suspend) {
608 if (dataflow->Resume()) {
609 myThread->startThread(tr("MSG_DF_RESUMED"));
611 QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("ERROR"), tr("MSG_CANT_RESUME"));
614 if (dataflow->Suspend()) {
616 getMessage()->putMessage( tr("MSG_GRAPH_SUSPENDED") );
618 QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("ERROR"), tr("MSG_CANT_SUSPEND"));
622 /* asv : 15.12.04 : commented out stopRestart() in Main and CanvasNode because it's not called from anywhere,
623 the comment from kloss below may be explaining it, but it's in French and I do not understand it..
624 It also calls deprecated method of Engine: ReStart().
625 void SUPERVGUI_Main::stopRestart() { // kloss : a reviser et a connecter dans le popup du dataflow (pas de creation de bouton)
626 Trace("SUPERVGUI_Main::stopRestart");
627 if ((SUPERV_isNull(dataflow))) return;
629 if (dataflow->IsEditing()) {
630 QMessageBox::warning(0, tr("ERROR"), tr("MSG_DF_NOTRUNNING"));
631 } else if (dataflow->State() == SUPERV_Stop) {
632 if (dataflow->ReStart()) {
633 message->setMessage(tr("MSG_DF_RESTARTED"));
636 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_RESTART"));
639 if (dataflow->Stop()) {
642 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_STOP"));
647 void SUPERVGUI_Main::addNode() {
648 Trace("SUPERVGUI_Main::addNode");
650 if ( !ReadyToModify() ) // null dataflow or executing, ..
653 SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
655 MESSAGE("NULL Supervision module!");
659 //Editing(); // PAL6170: GUI->Engine: setting "Editing" flag, commented: PAL7960
660 aSupMod->getBrowser()->choose();
664 * Add Computation node
666 void SUPERVGUI_Main::addComputeNode(SUPERV_CNode theNode) {
667 switch (myCurrentView) {
675 SUPERVGUI_CanvasNode* aNode = new SUPERVGUI_CanvasComputeNode(myCanvas, this, theNode);
676 aNode->move(theNode->X(), theNode->Y());
677 if (myCurrentView == CONTROLFLOW) aNode->hideAll();
688 void SUPERVGUI_Main::addGOTONode(SUPERV_CNode theNode) {
689 switch (myCurrentView) {
697 SUPERVGUI_CanvasNode* aNode = new SUPERVGUI_CanvasGotoNode(myCanvas, this, theNode);
698 aNode->move(theNode->X(), theNode->Y());
699 if (myCurrentView == CONTROLFLOW) aNode->hideAll();
710 void SUPERVGUI_Main::addControlNode(SUPERV_CNode theStartNode, SUPERV_CNode theEndNode, bool Update) {
711 switch (myCurrentView) {
719 SUPERVGUI_CanvasStartNode* aStartNode = new SUPERVGUI_CanvasStartNode(myCanvas, this, theStartNode);
720 aStartNode->move(theStartNode->X(), theStartNode->Y());
721 if (myCurrentView == CONTROLFLOW) aStartNode->hideAll();
723 SUPERVGUI_CanvasEndNode* aEndNode = new SUPERVGUI_CanvasEndNode(myCanvas, this, theEndNode, aStartNode);
724 aEndNode->move(theEndNode->X(), theEndNode->Y());
725 if (myCurrentView == CONTROLFLOW) aEndNode->hideAll();
739 void SUPERVGUI_Main::addMacroNode(SUPERV_CNode theNode) {
740 switch (myCurrentView) {
748 SUPERVGUI_CanvasNode* aNode = new SUPERVGUI_CanvasMacroNode(myCanvas, this, theNode);
749 aNode->move(theNode->X(), theNode->Y());
750 if (myCurrentView == CONTROLFLOW) aNode->hideAll();
758 SUPERVGUI_CanvasArray* SUPERVGUI_Main::getCanvasArray() {
759 Trace("SUPERVGUI_Main::getCanvasArray");
763 SUPERVGUI_ArrayView* SUPERVGUI_Main::getArrayView() {
764 Trace("SUPERVGUI_Main::getArrayView");
768 SUPERVGUI_Canvas* SUPERVGUI_Main::getCanvas() {
769 Trace("SUPERVGUI_Main::getCanvas");
773 SUPERVGUI_CanvasView* SUPERVGUI_Main::getCanvasView() {
774 Trace("SUPERVGUI_Main::getCanvasView");
775 return(myCanvasView);
778 SUPERV_Graph SUPERVGUI_Main::getDataflow() {
779 Trace("SUPERVGUI_Main::getDataflow");
783 LogWindow* SUPERVGUI_Main::getMessage() {
784 Trace("SUPERVGUI_Main::getMessage");
788 SUIT_Study* SUPERVGUI_Main::getStudy() {
789 Trace("SUPERVGUI_Main::getStudy");
793 bool SUPERVGUI_Main::isArrayShown() {
794 Trace("SUPERVGUI_Main::isArrayShown");
795 return(myCurrentView == CANVASTABLE);
798 void SUPERVGUI_Main::showPopup(QPopupMenu* p, QMouseEvent* e) {
799 Trace("SUPERVGUI_Main::showPopup");
800 // To check is Supervision active?
801 if (myIsLocked) return;
802 //if (dataflow->IsExecuting()) return;
804 CAM_Application* anApp = ( CAM_Application* )(SUIT_Session::session()->activeApplication());
805 if ( anApp->activeModule()->moduleName().compare( anApp->moduleTitle( "SUPERV" ) ) !=0 ) return;
807 if (e->button() == RightButton) {
808 p->exec(e->globalPos());
812 void SUPERVGUI_Main::changeInformation() {
813 SUPERVGUI_Information* aDlg = new SUPERVGUI_Information(SUPERV::CNode::_narrow(dataflow), dataflow->IsReadOnly());
819 void SUPERVGUI_Main::chooseData(QListViewItem* item) {
820 Trace("SUPERVGUI_Main::chooseData");
822 QString id = ((OB_ListItem*)item)->text(2);// <=> get entry
824 _PTR(SObject) object ( (( SalomeApp_Study* )study)->studyDS()->FindObjectID(id.latin1()) );
825 _PTR(GenericAttribute) anAttr;
826 if (object->FindAttribute(anAttr, "AttributeIOR")) {
827 _PTR(AttributeIOR) anIOR ( anAttr );
829 // asv : 13.12.04 : commented out use of portIn field, but it seems that it
830 // should be replaced with some analogious code... selection of IOR was done -
831 // put its value into port.
832 //portIn->setValue(ior);
834 SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
836 MESSAGE("NULL Supervision module!");
842 setCursor(aSupMod->getCursor());
843 objectBrowser->setCursor(aSupMod->getCursor());
844 aSupMod->putInfo("");
850 _PTR(SObject) SearchOrCreateSOWithName( _PTR(Study) const theStudy,
851 _PTR(StudyBuilder) const theBuilder,
852 _PTR(SObject) const theSO,
854 bool* theDoneSomething ) {
855 _PTR(SObject) aResult;
856 _PTR(AttributeName) aName;
857 _PTR(GenericAttribute) anAttr;
858 _PTR(ChildIterator) anIterator ( theStudy->NewChildIterator(theSO) );
859 for (; anIterator->More(); anIterator->Next()) {
860 if (anIterator->Value()->FindAttribute(anAttr, "AttributeName")) {
862 if (strcmp(aName->Value().c_str(), theName) == 0) {
863 aResult = anIterator->Value();
869 // if aResule was found then theDoneSomething=false and we return
870 *theDoneSomething = !aResult ? 1 : 0;//->_is_nil();
871 if ( !*theDoneSomething )
875 aResult = theBuilder->NewObject( theSO );
876 anAttr = theBuilder->FindOrCreateAttribute(aResult, "AttributeName");
878 aName->SetValue(theName);
883 * Return true if dataflow is already in the study
885 bool SUPERVGUI_Main::isDataflowInStudy() const {
886 _PTR(Study) aStudy = (( SalomeApp_Study* )study)->studyDS();
887 _PTR(SObject) aSO ( aStudy->FindObjectIOR( dataflow->getIOR() ) );
888 return ( aSO ? true : false );
892 * Create a "Supervision" object in the Study and a "dataflow" object under it
893 * aDoneSomething will be true if "Supervision" or "dataflow" object were created (not found).
895 _PTR(SObject) createDataflowSObj( SUIT_Study* study,
896 SUPERV::Graph_var dataflow,
897 _PTR(StudyBuilder) aBuilder,
898 bool& aDoneSomething ) {
899 _PTR(Study) aStudy = (( SalomeApp_Study* )study)->studyDS();
900 _PTR(GenericAttribute) anAttr;
901 _PTR(AttributeName) aName;
903 // Find or create "Supervisor -> aNewDataflow_1" SObjects in the study
904 _PTR(SObject) aSO = aStudy->FindObjectIOR( dataflow->getIOR() );
905 if ( !aSO ) { // dataflow SObject not found in the study
906 aDoneSomething = true;
907 _PTR(SComponent) aComponent = aStudy->FindComponent(STUDY_SUPERVISION);
908 if ( !aComponent ) { // is supervision component not found, then create it
909 aComponent = aBuilder->NewComponent(STUDY_SUPERVISION);
910 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributeName");
912 aName->SetValue( (( CAM_Application* )(study->application()))->moduleTitle( "SUPERV" ).latin1() );
914 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributePixMap");
915 _PTR(AttributePixMap) aPixmap ( anAttr );
916 aPixmap->SetPixMap( "ICON_OBJBROWSER_Supervision" );
918 SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
920 aBuilder->DefineComponentInstance(aComponent, SalomeApp_Application::orb()->object_to_string(aSupMod->getEngine()));
921 //dynamic_cast<SALOMEDS_Study*>( aStudy )->ConvertObjectToIOR(aSupMod->getEngine()));
922 else MESSAGE("NULL Supervision module!");
925 // create dataflow SObject ("aNewDataflow_1")
926 aSO = aBuilder->NewObject(aComponent);
927 anAttr = aBuilder->FindOrCreateAttribute(aSO, "AttributeName");
929 aName->SetValue(dataflow->Name());
930 anAttr = aBuilder->FindOrCreateAttribute(aSO, "AttributeIOR");
931 _PTR(AttributeIOR) anIORAttr ( anAttr );
932 anIORAttr->SetValue(dataflow->getIOR());
938 void SUPERVGUI_Main::addDataflowToStudy() {
940 _PTR(StudyBuilder) aBuilder ( (( SalomeApp_Study* )study)->studyDS()->NewBuilder() );
941 aBuilder->NewCommand();
942 _PTR(SObject) aDF ( createDataflowSObj( study, dataflow, aBuilder, isCreated ) );
944 aBuilder->CommitCommand();
945 // what is this register/unregister?? don't know..
946 SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
948 MESSAGE("NULL Supervision module!");
951 aSupMod->unregisterGraph(this);
952 aSupMod->registerGraph(dataflow->getIOR(), this);
954 if ( !myThread->running() )
955 aSupMod->updateObjBrowser();
958 MESSAGE( "ERROR: failed to find or create dataflow SObject" );
959 aBuilder->AbortCommand();
963 bool SUPERVGUI_Main::putDataStudy( SUPERV_Port p, const char* inout ) {
964 Trace("SUPERVGUI_Main::putDataStudy");
966 // static variable to ensure that only one instance (thread) is executing this function
967 static bool isIn = false;
968 if (isIn) return true;
971 _PTR(Study) aStudy = (( SalomeApp_Study* )study)->studyDS();
972 const bool aLocked = aStudy->GetProperties()->IsLocked();
973 _PTR(StudyBuilder) aBuilder ( aStudy->NewBuilder() );
974 bool aDoneSomething = false;
976 // asv 23.11.04 : fix for PAL6852 if the study is locked -- then we can't put anything in it.
978 MESSAGE( "The study is locked and can not be modified!" );
983 // check if the port and its node are good
984 if ( CORBA::is_nil( p ) || CORBA::is_nil( p->Node() ) ) {
985 MESSAGE( "putInStudy ERROR: port or node are NULL!" );
990 // open new command. Commit or Abort it depending on aDoneSomething variable or error
991 aBuilder->NewCommand();
993 // Find or create "Supervisor -> aNewDataflow_1" SObjects in the study
994 _PTR(SObject) aSO = createDataflowSObj( study, dataflow, aBuilder, aDoneSomething );
997 MESSAGE( "ERROR: putDataStudy() could not find or create dataflow SObject" );
998 aBuilder->AbortCommand();
1003 // Create "Run -> Time and date, etc." SObjects
1004 if ( p->State() == SUPERV::ReadyState ) { // if port contains valid computed value
1006 aSO = SearchOrCreateSOWithName( aStudy, aBuilder, aSO, QString("Run ") + myRunTime.toString(), &aDoneSomething ); // get run time SO
1007 aSO = SearchOrCreateSOWithName( aStudy, aBuilder, aSO, p->Node()->Name(), &aDoneSomething ); // get node SO
1008 aSO = SearchOrCreateSOWithName( aStudy, aBuilder, aSO, inout, &aDoneSomething ); // get in/out SO
1009 aSO = SearchOrCreateSOWithName( aStudy, aBuilder, aSO, p->Name(), &aDoneSomething ); // get port SO
1011 // create IOR attribute for port SObject (usually with "return" name)
1012 _PTR(GenericAttribute) anAttr ( aBuilder->FindOrCreateAttribute(aSO, "AttributeIOR") );
1013 _PTR(AttributeIOR) anIORAttr ( anAttr );
1015 // if we have not created anything (all SObject already existed) and we have the same IORAttribute
1016 // on the needed SObject -> then don't do anything! it's already there!
1017 if ( !aDoneSomething && strcmp(anIORAttr->Value().c_str(), p->ToString()) == 0 ) {
1018 aBuilder->AbortCommand();
1023 aDoneSomething = true; // going to set some value to anIORAttr any way from this point..
1025 // set object value to the study: if object is external, then put it with
1026 // help of the specific component - owner
1028 // get according component driver for result object
1029 SALOME_LifeCycleCORBA aLCC( myNService );
1030 SUPERV_FNode aFNode = SUPERV::FNode::_narrow( p->Node() );
1031 if ( !aFNode->_is_nil() ) {
1032 Engines::Component_var aComponent = aLCC.FindOrLoad_Component( aFNode->GetContainer(), aFNode->GetComponentName() );
1033 SALOMEDS::Driver_var aDriver = SALOMEDS::Driver::_narrow( aComponent );
1034 if ( !CORBA::is_nil( aDriver ) ) { // if driver was found, publish object
1035 CORBA::Object_ptr anObject = new CORBA::Object();
1036 CORBA::Any* anAny = p->ToAny();
1037 (*anAny) >>= anObject;
1039 if ( aDriver->CanPublishInStudy( anObject ) ) {
1040 SALOMEDS::SObject_var aTmpSO;// = aSO;
1041 SALOMEDS_Study* aSStudy = dynamic_cast<SALOMEDS_Study*>( aStudy.get() );
1042 if ( !aSStudy ) return false;
1043 aTmpSO = aDriver->PublishInStudy( aSStudy->GetStudy(), aTmpSO, anObject, "" );
1044 aBuilder->Addreference(aSO, _PTR(SObject)(new SALOMEDS_SObject( aTmpSO )) );
1046 else { // can't publish object: abort transaction
1047 MESSAGE( "CanPublishInStudy() returned FALSE. ok, AbortCommand.." );
1048 aBuilder->AbortCommand();
1053 else { // component has no driver, but could store IORs (like Calculator)
1054 _PTR(SObject) anIORSO ( aStudy->FindObjectIOR( p->ToString() ) );
1056 aBuilder->Addreference(aSO, anIORSO);
1057 else { // Hm... the object (==port value) was not found, so we don't publish it.
1058 MESSAGE( "The object (==port value) was not found, so we don't publish it" );
1059 aBuilder->AbortCommand();
1065 else { // FNode is NULL -> bad
1066 MESSAGE( "FNode is NULL. Not good at all. Aborting command." );
1067 aBuilder->AbortCommand();
1073 anIORAttr->SetValue( p->ToString() ); // ior attribute already set for the prevoius condition
1077 if ( aDoneSomething )
1078 aBuilder->CommitCommand();
1080 aBuilder->AbortCommand();
1082 if ( !myThread->running() ) {
1083 SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
1085 aSupMod->updateObjBrowser();
1086 else MESSAGE("NULL Supervision module!");
1094 void SUPERVGUI_Main::ActivatePanning()
1096 if (myCanvasView->isVisible()) {
1097 myCanvasView->ActivatePanning();
1098 } else if (myArrayView->isVisible()) {
1099 myArrayView->ActivatePanning();
1104 void SUPERVGUI_Main::ResetView()
1106 if (myCanvasView->isVisible()) {
1107 myCanvasView->ResetView();
1108 } else if (myArrayView->isVisible()) {
1109 myArrayView->ResetView();
1113 void SUPERVGUI_Main::syncNotification() {
1123 while (notification->Receive(&graph, &node, &type, &message, &sender, &counter, &date, &stamp)) {
1124 if (isFiltered(graph, node, type, message, sender, counter, date, stamp)) {
1126 mess += "NOTIF: "; mess += graph;
1127 mess += " / " ; mess += node;
1128 mess += " / " ; mess += type;
1129 mess += " / " ; mess += message;
1130 getMessage()->putMessage(mess.latin1());
1135 bool SUPERVGUI_Main::isFiltered(char* graph, char* node, char* type, char* message,
1136 char* sender, long counter, char* date, long stamp) {
1137 Trace("SUPERVGUI_Main::isFiltered");
1139 if (strcmp(getDataflow()->Name(), graph) == 0) {
1140 SUPERVGUI_CanvasNode* n;
1141 QObjectList* nodes = queryList("SUPERVGUI_CanvasNode");
1142 QObjectListIt i(*nodes);
1143 while ((n=(SUPERVGUI_CanvasNode*)i.current()) != 0) {
1145 if (strcmp(n->name(), node) == 0) {
1146 if (strcmp(type, NOTIF_WARNING) == 0) {
1148 } else if (strcmp(type, NOTIF_STEP) == 0) {
1150 } else if (strcmp(type, NOTIF_TRACE) == 0) {
1152 } else if (strcmp(type, NOTIF_VERBOSE) == 0) {
1159 if ( myLogged && myLogFile && ( ( !myFiltered ) || b ) ) {
1160 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 );
1161 fflush( myLogFile );
1167 void SUPERVGUI_Main::closeEvent(QCloseEvent* e) {
1172 void SUPERVGUI_Main::setPaletteBackgroundColor(const QColor& color) {
1174 myCanvas->setBackgroundColor(color);
1175 myCanvasView->setPaletteBackgroundColor(color.light());
1176 myArray->setBackgroundColor(color);
1177 myArrayView->setPaletteBackgroundColor(color.light());
1179 SUPERVGraph_View::setPaletteBackgroundColor(color);
1182 QPtrList< char * > SUPERVGUI_Main::getEventNodes() {
1183 return myEventNodes;
1186 void SUPERVGUI_Main::setEventNodes(QPtrList< char * > theEventNodes) {
1187 myEventNodes = theEventNodes;
1190 QPtrList< SUPERV::GraphState > SUPERVGUI_Main::getStates() {
1194 void SUPERVGUI_Main::setStates(QPtrList< SUPERV::GraphState > theStates) {
1195 myStates = theStates;
1198 int SUPERVGUI_Main::getNodesNumber() {
1199 //create a list of nodes of the graph
1200 SUPERV_Nodes nodes = getDataflow()->Nodes();
1201 int RetVal = nodes->CNodes.length() + nodes->FNodes.length() +
1202 nodes->INodes.length() + nodes->GNodes.length() +
1203 nodes->LNodes.length() + nodes->SNodes.length();
1207 SUPERVGUI_Thread* SUPERVGUI_Main::getMyThread() {
1211 void SUPERVGUI_Main::startTimer() {
1212 myTimer->start(500);
1215 void SUPERVGUI_Main::executionFinished() {
1216 SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
1218 aSupMod->updateObjBrowser();
1219 else MESSAGE("NULL Supervision module!");
1225 void SUPERVGUI_Main::checkExecution() {
1226 if (myThread->finished()) {
1228 executionFinished();
1233 * Editing() is to be called by any operation in GUI before modification of a datamodel
1234 * (add/remove ports or nodes, etc.). It is used to resolve inconsistancies between 2 data models
1235 * in Engine: Editor and Executor. During and after execution, the values of ports and statuses of nodes
1236 * are taken from Executor data model. But when user starts editing the graph - these changes must
1237 * be applied to Editor data model. This function destroys Executor data model and moves to Editor.
1239 void SUPERVGUI_Main::Editing() {
1240 if ( !SUPERV_isNull( dataflow ) )
1241 dataflow->Editing();
1243 // updata GUI, Nodes' statuses and Ports' values could change.
1247 void SUPERVGUI_Main::removeArrayChild(SUPERV::CNode_ptr theNode)
1249 // mkr: since the deletion of the node allow only in CANVAS view,
1250 // it is necessary to remove the CanvasArray's children, which
1251 // have the same CNode engine as deleting node. This CNode is given
1254 const QObjectList* aChList = myArray->children();
1255 if ( aChList ) { // asv 27.01.05 : fix for 7817
1256 QObjectListIt aItChList(*aChList);
1257 SUPERVGUI_CanvasNode* anObjNode;
1258 while ((anObjNode = (SUPERVGUI_CanvasNode*)aItChList.current()) != 0) {
1260 if ((QString(anObjNode->getEngine()->Name())).compare(QString(theNode->Name())) == 0) {
1261 myArray->removeChild(anObjNode);
1265 } // end of if ( ChList )
1270 * ReadyToModify() must be called before any modification
1271 * operation - asks to kill execution of dataflow. If returns false -
1272 * modification (==Editing() ) is not allowed.
1274 bool SUPERVGUI_Main::ReadyToModify() {
1275 if ( CORBA::is_nil( dataflow ) )
1277 if ( dataflow->IsExecuting() ) {
1278 bool quit = SUIT_MessageBox::warn2( SUIT_Session::session()->activeApplication()->desktop(), // 0=Yes, 1=No
1279 tr("WARNING"), tr("MSG_GRAPH_ISRUN"), tr( "BUT_YES" ), tr( "BUT_CANCEL" ), 0, 1, 0 );
1280 if ( quit ) // user selected NOT to kill dataflow and NOT to add new node
1282 else if ( dataflow->IsExecuting() ) // user selected to kill the dataflow and add new node after that
1283 kill(); // checking again for IsExecuting to be sure that it was not finished while MB was up
1288 /******************************* SUPERVGUI_Thread class ****************************************/
1289 SUPERVGUI_Thread::SUPERVGUI_Thread()
1295 SUPERVGUI_Thread::~SUPERVGUI_Thread()
1297 //it is a virtual destructor and needs to be determine here
1300 void SUPERVGUI_Thread::startThread(const char* m)
1305 myMain->getMessage()->putMessage(m);
1312 void SUPERVGUI_Thread::setMain( SUPERVGUI_Main* theMain )
1317 void SUPERVGUI_Thread::KillThread( bool theValue )
1320 myIsActive = !(theValue);
1324 typedef TVoidMemFun2ArgEvent<SUPERVGUI_Main, char*, SUPERV::GraphState> TNodeSyncEvent;
1326 void SUPERVGUI_Thread::run()
1328 myMain->startTimer();
1330 // GUI cycle to handle events coming for Engine
1331 while ( myIsActive ) {
1333 SUPERV_CNode aNode = NULL;
1334 SUPERV::GraphEvent aEvent = SUPERV::UndefinedEvent ;
1335 SUPERV::GraphState aState = SUPERV::UndefinedState ;
1337 // blocking function of Engine. Return from there only after anEvent happens on node aNode
1338 myMain->getDataflow()->Event(aNode, aEvent, aState);
1340 // "kill" or undefined event came
1341 if (( aEvent == SUPERV::UndefinedEvent && aState == SUPERV::UndefinedState ) ||
1342 ( aEvent == SUPERV::NoEvent && aState == SUPERV::NoState ) ||
1343 ( aEvent == SUPERV::KillEvent && aState == SUPERV::KillState )) {
1347 else { // a "normal" execution event came
1349 if ( aNode != NULL && !CORBA::is_nil( aNode ) )
1350 aName = aNode->Name();
1352 // this function is asynchronious. The call does NOT wait when SUPERVGUI_Main::execute finishes
1353 // handling the event. So: SUPERVGUI_Main::execute must be fast, in order we don't get here again
1354 // on the next loop iteration, BEFORE previous SUPERVGUI_Main::execute finished.
1355 ProcessVoidEvent( new TNodeSyncEvent( myMain, &SUPERVGUI_Main::execute, aName, aState ) );
1358 // execution is finished. just set a "finished" message(s)
1359 if ( !myIsActive ) {
1360 switch ( myMain->getDataflow()->State() ) {
1361 case SUPERV_Editing :
1362 myMain->getMessage()->putMessage( myMain->getDataflow()->IsReadOnly()?
1363 tr("MSG_GRAPH_READONLY"): tr("MSG_GRAPH_EDITING") );
1365 case SUPERV_Suspend :
1366 myMain->getMessage()->putMessage( tr("MSG_GRAPH_SUSPENDED") );
1369 myMain->getMessage()->putMessage( tr("MSG_GRAPH_FINISHED") );
1372 myMain->getMessage()->putMessage( tr("MSG_GRAPH_ABORTED") );
1375 myMain->getMessage()->putMessage( tr("MSG_GRAPH_KILLED") );
1379 // asv 03.02.05 : fix for PAL6859, not very good, but works..
1381 } // end of if !myIsActive
1382 } // end of while( myIsActive )
1387 /******************************* SUPERVGUI_DSGraphParameters class ****************************************/
1391 SUPERVGUI_DSGraphParameters::SUPERVGUI_DSGraphParameters(SUPERV_Graph theGraph, bool isReadOnly)
1392 : QDialog( SUIT_Session::session()->activeApplication()->desktop(), "", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
1394 Trace("SUPERVGUI_DSGraphParameters::SUPERVGUI_DSGraphParameters");
1395 setCaption( tr( "TLT_DSGRAPHPARAMS" ) );
1396 setSizeGripEnabled( true );
1399 QGridLayout* TopLayout = new QGridLayout( this );
1400 TopLayout->setSpacing( 6 );
1401 TopLayout->setMargin( 11 );
1403 QGroupBox* TopGroup = new QGroupBox( this, "TopGroup" );
1404 TopGroup->setColumnLayout(0, Qt::Vertical );
1405 TopGroup->layout()->setSpacing( 0 );
1406 TopGroup->layout()->setMargin( 0 );
1407 QGridLayout* TopGroupLayout = new QGridLayout( TopGroup->layout() );
1408 TopGroupLayout->setAlignment( Qt::AlignTop );
1409 TopGroupLayout->setSpacing( 6 );
1410 TopGroupLayout->setMargin( 11 );
1413 QLabel* DeltaTimeL = new QLabel( tr( "DELTATIME_LBL" ), TopGroup );
1414 TopGroupLayout->addWidget( DeltaTimeL, 0, 0 );
1416 myDeltaTime = new QtxDblSpinBox( 0.0, 1.0, 0.1, TopGroup );
1417 myDeltaTime->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
1418 TopGroupLayout->addWidget( myDeltaTime, 0, 1 );
1421 QLabel* TimeOutL = new QLabel( tr( "TIMEOUT_LBL" ), TopGroup);
1422 TopGroupLayout->addWidget( TimeOutL, 1, 0 );
1424 myTimeOut = new QLineEdit( TopGroup );
1425 myTimeOut->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
1426 myTimeOut->setValidator( new QIntValidator(this) );
1427 myTimeOut->setMinimumSize( 100, 0 );
1428 myTimeOut->setReadOnly( isReadOnly );
1429 TopGroupLayout->addWidget( myTimeOut, 1, 1 );
1432 QLabel* DataStreamTraceL = new QLabel( tr( "DATASTREAMTRACE_LBL" ), TopGroup);
1433 TopGroupLayout->addWidget( DataStreamTraceL, 2, 0 );
1435 myDataStreamTrace = new QComboBox( TopGroup );
1436 myDataStreamTrace->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
1437 myDataStreamTrace->insertItem("WithoutTrace");
1438 myDataStreamTrace->insertItem("SummaryTrace");
1439 myDataStreamTrace->insertItem("DetailedTrace");
1440 TopGroupLayout->addWidget( myDataStreamTrace, 2, 1 );
1442 QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
1443 GroupButtons->setColumnLayout(0, Qt::Vertical );
1444 GroupButtons->layout()->setSpacing( 0 );
1445 GroupButtons->layout()->setMargin( 0 );
1446 QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
1447 GroupButtonsLayout->setAlignment( Qt::AlignTop );
1448 GroupButtonsLayout->setSpacing( 6 );
1449 GroupButtonsLayout->setMargin( 11 );
1451 QPushButton* okB = new QPushButton( tr( "BUT_OK" ), GroupButtons );
1452 QPushButton* cancelB = new QPushButton( tr( "BUT_CANCEL" ), GroupButtons );
1454 GroupButtonsLayout->addWidget( okB, 0, 0 );
1455 GroupButtonsLayout->addItem ( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
1456 GroupButtonsLayout->addWidget( cancelB, 0, 2 );
1458 TopLayout->addWidget( TopGroup, 0, 0 );
1459 TopLayout->addWidget( GroupButtons, 1, 0 );
1461 connect( okB, SIGNAL( clicked() ), this, SLOT( accept() ) );
1462 connect( cancelB, SIGNAL( clicked() ), this, SLOT( reject() ) );
1470 SUPERVGUI_DSGraphParameters::~SUPERVGUI_DSGraphParameters() {
1471 Trace("SUPERVGUI_DSGraphParameters::~SUPERVGUI_DSGraphParameters");
1477 void SUPERVGUI_DSGraphParameters::setData() {
1480 SUPERV::KindOfDataStreamTrace aDataStreamTrace;
1482 // myGraph->StreamParams(aTimeOut, aDataStreamTrace, aDeltaTime);
1483 if (myGraph->IsStreamGraph()) {
1484 SUPERV_StreamGraph aSGraph = myGraph->ToStreamGraph();
1485 if (!SUPERV_isNull(aSGraph))
1486 aSGraph->StreamParams(aTimeOut, aDataStreamTrace, aDeltaTime);
1489 myDeltaTime->setValue(aDeltaTime);
1490 myTimeOut->setText(QString("%1").arg(aTimeOut));
1491 myDataStreamTrace->setCurrentItem((int)aDataStreamTrace);
1497 void SUPERVGUI_DSGraphParameters::accept() {
1498 // myGraph->SetStreamParams( myTimeOut->text().toLong(),
1499 // (SUPERV::KindOfDataStreamTrace) myDataStreamTrace->currentItem(),
1500 // myDeltaTime->value());
1501 if (myGraph->IsStreamGraph()) {
1502 SUPERV_StreamGraph aSGraph = myGraph->ToStreamGraph();
1503 if (!SUPERV_isNull(aSGraph))
1504 aSGraph->SetStreamParams( myTimeOut->text().toLong(),
1505 (SUPERV::KindOfDataStreamTrace) myDataStreamTrace->currentItem(),
1506 myDeltaTime->value());