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::syncAsync() {
248 Trace("SUPERVGUI_Main::syncAsync");
249 QTimer::singleShot(1, this, SLOT(sync()));
254 * Called by thread when dataflow is executing
256 void SUPERVGUI_Main::execute( char * theNodeName, SUPERV::GraphState theNodeState ) {
257 if (myCurrentView == CANVAS || myCurrentView == CONTROLFLOW) {
258 SUPERVGUI_CanvasNode* aNode = (SUPERVGUI_CanvasNode*) myCanvas->child(theNodeName, "SUPERVGUI_CanvasNode");
262 else if (myCurrentView == CANVASTABLE) {
263 SUPERVGUI_CanvasCellNode* aNode = (SUPERVGUI_CanvasCellNode*) myArray->child(theNodeName, "SUPERVGUI_CanvasCellNode");
268 // asv : 26.01.05 : Bug PAL7164 : puting out-value to study if the "put_to_Study" flag is set on a
269 // CanvasPort the functionality was moved from SUPERVGUI_CanvasPortOut::sync() method please, see
270 // comment in that method for details.
271 if ( theNodeState == SUPERV::DoneState ) {
272 SUPERVGUI_CanvasNode* aNode = (SUPERVGUI_CanvasNode*) myCanvas->child(theNodeName, "SUPERVGUI_CanvasNode");
274 //cout << " *** theNode " << theNodeName << " received DONE_STATE *** " << endl;
275 SUPERVGUI_CanvasPortOut* aPortOut;
276 QObjectList* aPortList = aNode->queryList("SUPERVGUI_CanvasPortOut");
277 QObjectListIt aPortIt(*aPortList);
278 while ((aPortOut=(SUPERVGUI_CanvasPortOut*)aPortIt.current()) != 0) {
280 if ( aPortOut->isInStudy() && aPortOut->getEngine()->State() == SUPERV::ReadyState ) {
281 //cout << " *** " << theNodeName << "[" << aPortOut->name() << "]--> goes into study *** " << endl;
282 putDataStudy( aPortOut->getEngine(), STUDY_PORT_OUT );
287 //else //normal case if Node is not found is when node is a graph! it can receive DoneState as well!
288 // MESSAGE( "ERROR in SUPERVGUI_Main::execute() : CanvasNode \"" << theNodeName << "\" NOT FOUND in myCanvas" );
293 void SUPERVGUI_Main::sync() {
294 Trace("SUPERVGUI_Main::sync");
295 if ((SUPERV_isNull(dataflow)))
297 QString t = tr("GRAPH_TITLE");
299 t += dataflow->Name();
302 //study->updateObjBrowser();
303 //mkr: we have to update object browser only if there are some ports datas in the study
304 //or if dataflow is in the study itself. It is done in the
305 //1) putDataStudy(...) method (it called when we put in study data of port
306 // or if port is in study and execution is finished)
307 //2) addDataflowToStudy() method (it is called as a slot when we add in study dataflow itself).
308 //So, we commented updateObjBrowser function here!
309 //SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
310 //if ( aSupMod ) aSupMod->updateObjBrowser();
311 //else MESSAGE("NULL Supervision module!");
313 if (myCurrentView == CANVASTABLE) {
322 void SUPERVGUI_Main::showCanvasTable() {
323 if (myCurrentView == CANVASTABLE)
326 if (myArray->create()) {
327 myCanvasView->hide();
329 myCurrentView = CANVASTABLE;
334 void SUPERVGUI_Main::showContolFlow() {
336 if (myCurrentView == CANVASTABLE) {
341 myCurrentView = CONTROLFLOW;
342 myCanvas->setControlView();
345 myCanvasView->show();
349 void SUPERVGUI_Main::showCanvas() {
350 if (myCurrentView == CANVAS)
354 if (myCurrentView == CANVASTABLE) {
359 myCurrentView = CANVAS;
360 myCanvas->setFullView();
363 myCanvasView->show();
367 void SUPERVGUI_Main::insertFile() {
368 Trace("SUPERVGUI_Main::insertFile");
370 if ( !ReadyToModify() ) // null dataflow or executing, ..
373 QString f = SUIT_FileDlg::getFileName(SUIT_Session::session()->activeApplication()->desktop(),
376 tr("MSG_GRAPH_INSERT"),
378 if ( !f.isEmpty() ) { // not Cancel, but "OK" was pressed with valid file name
380 Editing(); // PAL6170: GUI->Engine: setting "Editing" flag, why here? -> see 7960
382 if (dataflow->Import(f.latin1())) {
383 if (myCurrentView == CANVASTABLE) {
387 else { // (myCurrentView == CANVAS || myCurrentView == CONTROLFLOW) {
392 QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("ERROR"), tr("MSG_BAD_FILE").arg(f));
397 void SUPERVGUI_Main::copy() {
398 Trace("SUPERVGUI_Main::copy");
399 if (dataflow->ThreadsMax() == 0) {
400 QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("WARNING"), tr("MSG_NOTHING_COPY"));
404 SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
406 MESSAGE("NULL Supervision module!");
410 SUPERVGraph_ViewFrame* aViewFrame = dynamic_cast<SUPERVGraph_ViewFrame*>( aSupMod->createGraph() );
412 SUPERV_Graph aNewGraph; // = dataflow->StreamCopy();
413 if ( dataflow->IsStreamGraph() ) {
414 SUPERV_StreamGraph aSGraph = dataflow->ToStreamGraph();
415 if ( SUPERV_isNull(aSGraph) ) {
416 QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("WARNING"), tr("MSG_CANT_COPY"));
419 aNewGraph = aSGraph->StreamCopy();
422 aNewGraph = dataflow->Copy();
424 QString aNewName(tr("MSG_COPY_PREFIX").arg(++myCopyNum));
425 aNewName += dataflow->Name();
426 aNewGraph->SetName(aNewName);
427 /*SUPERVGUI_Main* m = */new SUPERVGUI_Main(aViewFrame,
428 aSupMod->application()->desktop(),//getDesktop(),
434 void SUPERVGUI_Main::openSubGraph(SUPERV_CNode theNode, bool correct)
436 if (theNode->IsMacro()) {
437 // get SubGraph from MacroNode
438 SUPERV_Graph aMacro = SUPERV::Graph::_narrow(theNode);
440 if (aMacro->IsStreamMacro())
441 aGraph = aMacro->StreamObjRef();
443 aGraph = aMacro->FlowObjRef();
446 if (SUPERV_isNull(aGraph)) {
447 QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("WARNING"), tr("MSG_NOACCESS"));
451 QString aGraphName = aGraph->Name();
452 SUIT_ViewWindow* aStudyFrame;
453 if (mySubGraphs.contains(aGraphName)) {
454 aStudyFrame = mySubGraphs[aGraphName];
455 aStudyFrame->setActiveWindow();
456 aStudyFrame->setFocus();
459 SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
461 MESSAGE("NULL Supervision module!");
465 aStudyFrame = aSupMod->createGraph();
467 SUPERVGraph_ViewFrame* aViewFrame = dynamic_cast<SUPERVGraph_ViewFrame*>( aStudyFrame );
469 /*SUPERVGUI_Main* m = */new SUPERVGUI_Main(aViewFrame,
470 aSupMod->application()->desktop(),//getDesktop(),
472 // connect(aStudyFrame, SIGNAL(sfStudyFrameClosing(QAD_StudyFrame*)),
473 // this, SLOT(onSubGraphClosed(QAD_StudyFrame*)));
474 connect(aSupMod->application()->desktop(), SIGNAL(windowActivated( SUIT_ViewWindow* )),
475 this, SLOT(onSubGraphActivated( SUIT_ViewWindow* )));
476 aStudyFrame->installEventFilter(this);
478 mySubGraphs.insert(aGraphName, aStudyFrame);
479 mySubGraphMap.insert(aGraphName, theNode->Name());
485 if (!correct) myLastGraph = aStudyFrame;
490 bool SUPERVGUI_Main::eventFilter( QObject* o, QEvent* e)
492 // workaround to get close event
493 if (o->inherits("SUIT_ViewWindow"/*"QAD_StudyFrame"*/) && e->type() == QEvent::Close) {
494 SUIT_ViewWindow* aFrame = (SUIT_ViewWindow*) o;
495 onSubGraphClosed(aFrame);
497 return SUPERVGraph_View::eventFilter(o, e);
500 // workaround to fix PAL6255 -> opened SubGraph is not on top
501 void SUPERVGUI_Main::onSubGraphActivated(SUIT_ViewWindow* theStudyFrame)
504 SUIT_ViewWindow* aFrame = myLastGraph;
506 aFrame->setActiveWindow();
511 void SUPERVGUI_Main::onSubGraphClosed(SUIT_ViewWindow* theStudyFrame)
513 if ( SUPERVGraph_ViewFrame* supervFrame = dynamic_cast<SUPERVGraph_ViewFrame*>( theStudyFrame ) ) {
514 theStudyFrame->removeEventFilter(this);
515 disconnect(theStudyFrame, 0, this, 0);
517 SUPERVGraph_View* view = supervFrame->getViewWidget();
518 SUPERVGUI_Main* aGraph = dynamic_cast<SUPERVGUI_Main*>(view);
520 QString aGraphName = aGraph->getDataflow()->Name();
521 QMap<QString, QString>::iterator it = mySubGraphMap.find(aGraphName);
522 if (it != mySubGraphMap.end()) {
523 QString aNodeName = it.data();
524 SUPERVGUI_CanvasNode* aNode = (SUPERVGUI_CanvasNode*)
525 myCanvas->child(aNodeName, "SUPERVGUI_CanvasNode");
530 mySubGraphMap.remove(it);
532 mySubGraphs.remove(aGraphName);
537 void SUPERVGUI_Main::run( const bool andSuspend ) {
538 Trace("SUPERVGUI_Main::run");
539 if ( SUPERV_isNull(dataflow) )
542 if ( dataflow->IsEditing() ) { // not currently Executing
544 // asv 31.01.05 : fix for PAL7854, Editing moved from SUPERVGUI.cxx runDataflow(), stepByStep() to here..
545 Editing(); // remove old executor, update GUI (all nodes to "No Status")
547 if ( !dataflow->IsValid() ) {
548 QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("ERROR"), tr("MSG_DF_NOTVALID"));
550 else if (!dataflow->IsExecutable()) {
551 QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("ERROR"), tr("MSG_DF_NOTEXECUTABLE"));
553 else if (myCanvasView->isAnyLinkCreating()) {
554 QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("ERROR"), tr("MSG_CRL_NOTCOMPLETE"));
557 myRunTime = QDateTime::currentDateTime();
558 const bool result = andSuspend ? dataflow->Start() : dataflow->Run();
560 QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("ERROR"), tr("MSG_DF_BADEXECUTE"));
561 if ( dataflow->State() == SUPERV::ErrorState ) {
566 //myExecuted = true; // set to true on first execution. for correct publishing in Study
567 myThread->startThread(tr("MSG_GRAPH_STARTED"));
572 QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("ERROR"), tr("MSG_DF_RUNNING"));
577 void SUPERVGUI_Main::kill() {
578 Trace("SUPERVGUI_Main::kill");
579 if ((SUPERV_isNull(dataflow)))
582 if (dataflow->IsEditing()) {
583 QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("ERROR"), tr("MSG_DF_NOTRUNNING"));
585 else if (dataflow->Kill()) {
586 getMessage()->putMessage( tr("MSG_GRAPH_KILLED") );
590 QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("ERROR"), tr("MSG_CANTKILL_DF"));
594 void SUPERVGUI_Main::suspendResume() {
595 Trace("SUPERVGUI_Main::suspendResume");
596 if ((SUPERV_isNull(dataflow))) return;
598 if (dataflow->IsEditing()) {
599 QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("ERROR"), tr("MSG_DF_NOTRUNNING"));
600 } else if (dataflow->State() == SUPERV_Suspend) {
601 if (dataflow->Resume()) {
602 myThread->startThread(tr("MSG_DF_RESUMED"));
604 QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("ERROR"), tr("MSG_CANT_RESUME"));
607 if (dataflow->Suspend()) {
609 getMessage()->putMessage( tr("MSG_GRAPH_SUSPENDED") );
611 QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("ERROR"), tr("MSG_CANT_SUSPEND"));
615 /* asv : 15.12.04 : commented out stopRestart() in Main and CanvasNode because it's not called from anywhere,
616 the comment from kloss below may be explaining it, but it's in French and I do not understand it..
617 It also calls deprecated method of Engine: ReStart().
618 void SUPERVGUI_Main::stopRestart() { // kloss : a reviser et a connecter dans le popup du dataflow (pas de creation de bouton)
619 Trace("SUPERVGUI_Main::stopRestart");
620 if ((SUPERV_isNull(dataflow))) return;
622 if (dataflow->IsEditing()) {
623 QMessageBox::warning(0, tr("ERROR"), tr("MSG_DF_NOTRUNNING"));
624 } else if (dataflow->State() == SUPERV_Stop) {
625 if (dataflow->ReStart()) {
626 message->setMessage(tr("MSG_DF_RESTARTED"));
629 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_RESTART"));
632 if (dataflow->Stop()) {
635 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_STOP"));
640 void SUPERVGUI_Main::addNode() {
641 Trace("SUPERVGUI_Main::addNode");
643 if ( !ReadyToModify() ) // null dataflow or executing, ..
646 SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
648 MESSAGE("NULL Supervision module!");
652 //Editing(); // PAL6170: GUI->Engine: setting "Editing" flag, commented: PAL7960
653 aSupMod->getBrowser()->choose();
657 * Add Computation node
659 void SUPERVGUI_Main::addComputeNode(SUPERV_CNode theNode) {
660 switch (myCurrentView) {
668 SUPERVGUI_CanvasNode* aNode = new SUPERVGUI_CanvasComputeNode(myCanvas, this, theNode);
669 aNode->move(theNode->X(), theNode->Y());
670 if (myCurrentView == CONTROLFLOW) aNode->hideAll();
681 void SUPERVGUI_Main::addGOTONode(SUPERV_CNode theNode) {
682 switch (myCurrentView) {
690 SUPERVGUI_CanvasNode* aNode = new SUPERVGUI_CanvasGotoNode(myCanvas, this, theNode);
691 aNode->move(theNode->X(), theNode->Y());
692 if (myCurrentView == CONTROLFLOW) aNode->hideAll();
703 void SUPERVGUI_Main::addControlNode(SUPERV_CNode theStartNode, SUPERV_CNode theEndNode, bool Update) {
704 switch (myCurrentView) {
712 SUPERVGUI_CanvasStartNode* aStartNode = new SUPERVGUI_CanvasStartNode(myCanvas, this, theStartNode);
713 aStartNode->move(theStartNode->X(), theStartNode->Y());
714 if (myCurrentView == CONTROLFLOW) aStartNode->hideAll();
716 SUPERVGUI_CanvasEndNode* aEndNode = new SUPERVGUI_CanvasEndNode(myCanvas, this, theEndNode, aStartNode);
717 aEndNode->move(theEndNode->X(), theEndNode->Y());
718 if (myCurrentView == CONTROLFLOW) aEndNode->hideAll();
732 void SUPERVGUI_Main::addMacroNode(SUPERV_CNode theNode) {
733 switch (myCurrentView) {
741 SUPERVGUI_CanvasNode* aNode = new SUPERVGUI_CanvasMacroNode(myCanvas, this, theNode);
742 aNode->move(theNode->X(), theNode->Y());
743 if (myCurrentView == CONTROLFLOW) aNode->hideAll();
751 SUPERVGUI_CanvasArray* SUPERVGUI_Main::getCanvasArray() {
752 Trace("SUPERVGUI_Main::getCanvasArray");
756 SUPERVGUI_ArrayView* SUPERVGUI_Main::getArrayView() {
757 Trace("SUPERVGUI_Main::getArrayView");
761 SUPERVGUI_Canvas* SUPERVGUI_Main::getCanvas() {
762 Trace("SUPERVGUI_Main::getCanvas");
766 SUPERVGUI_CanvasView* SUPERVGUI_Main::getCanvasView() {
767 Trace("SUPERVGUI_Main::getCanvasView");
768 return(myCanvasView);
771 SUPERV_Graph SUPERVGUI_Main::getDataflow() {
772 Trace("SUPERVGUI_Main::getDataflow");
776 LogWindow* SUPERVGUI_Main::getMessage() {
777 Trace("SUPERVGUI_Main::getMessage");
781 SUIT_Study* SUPERVGUI_Main::getStudy() {
782 Trace("SUPERVGUI_Main::getStudy");
786 bool SUPERVGUI_Main::isArrayShown() {
787 Trace("SUPERVGUI_Main::isArrayShown");
788 return(myCurrentView == CANVASTABLE);
791 void SUPERVGUI_Main::showPopup(QPopupMenu* p, QMouseEvent* e) {
792 Trace("SUPERVGUI_Main::showPopup");
793 // To check is Supervision active?
794 if (myIsLocked) return;
795 //if (dataflow->IsExecuting()) return;
797 CAM_Application* anApp = ( CAM_Application* )(SUIT_Session::session()->activeApplication());
798 if ( anApp->activeModule()->moduleName().compare( anApp->moduleTitle( "SUPERV" ) ) !=0 ) return;
800 if (e->button() == RightButton) {
801 p->exec(e->globalPos());
805 void SUPERVGUI_Main::changeInformation() {
806 SUPERVGUI_Information* aDlg = new SUPERVGUI_Information(SUPERV::CNode::_narrow(dataflow), dataflow->IsReadOnly());
812 void SUPERVGUI_Main::chooseData(QListViewItem* item) {
813 Trace("SUPERVGUI_Main::chooseData");
815 QString id = ((OB_ListItem*)item)->text(2);// <=> get entry
817 _PTR(SObject) object ( (( SalomeApp_Study* )study)->studyDS()->FindObjectID(id.latin1()) );
818 _PTR(GenericAttribute) anAttr;
819 if (object->FindAttribute(anAttr, "AttributeIOR")) {
820 _PTR(AttributeIOR) anIOR ( anAttr );
822 // asv : 13.12.04 : commented out use of portIn field, but it seems that it
823 // should be replaced with some analogious code... selection of IOR was done -
824 // put its value into port.
825 //portIn->setValue(ior);
827 SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
829 MESSAGE("NULL Supervision module!");
835 setCursor(aSupMod->getCursor());
836 objectBrowser->setCursor(aSupMod->getCursor());
837 aSupMod->putInfo("");
843 _PTR(SObject) SearchOrCreateSOWithName( _PTR(Study) const theStudy,
844 _PTR(StudyBuilder) const theBuilder,
845 _PTR(SObject) const theSO,
847 bool* theDoneSomething ) {
848 _PTR(SObject) aResult;
849 _PTR(AttributeName) aName;
850 _PTR(GenericAttribute) anAttr;
851 _PTR(ChildIterator) anIterator ( theStudy->NewChildIterator(theSO) );
852 for (; anIterator->More(); anIterator->Next()) {
853 if (anIterator->Value()->FindAttribute(anAttr, "AttributeName")) {
855 if (strcmp(aName->Value().c_str(), theName) == 0) {
856 aResult = anIterator->Value();
862 // if aResule was found then theDoneSomething=false and we return
863 *theDoneSomething = !aResult ? 1 : 0;//->_is_nil();
864 if ( !*theDoneSomething )
868 aResult = theBuilder->NewObject( theSO );
869 anAttr = theBuilder->FindOrCreateAttribute(aResult, "AttributeName");
871 aName->SetValue(theName);
876 * Return true if dataflow is already in the study
878 bool SUPERVGUI_Main::isDataflowInStudy() const {
879 _PTR(Study) aStudy = (( SalomeApp_Study* )study)->studyDS();
880 _PTR(SObject) aSO ( aStudy->FindObjectIOR( dataflow->getIOR() ) );
881 return ( aSO ? true : false );
885 * Create a "Supervision" object in the Study and a "dataflow" object under it
886 * aDoneSomething will be true if "Supervision" or "dataflow" object were created (not found).
888 _PTR(SObject) createDataflowSObj( SUIT_Study* study,
889 SUPERV::Graph_var dataflow,
890 _PTR(StudyBuilder) aBuilder,
891 bool& aDoneSomething ) {
892 _PTR(Study) aStudy = (( SalomeApp_Study* )study)->studyDS();
893 _PTR(GenericAttribute) anAttr;
894 _PTR(AttributeName) aName;
896 // Find or create "Supervisor -> aNewDataflow_1" SObjects in the study
897 _PTR(SObject) aSO = aStudy->FindObjectIOR( dataflow->getIOR() );
898 if ( !aSO ) { // dataflow SObject not found in the study
899 aDoneSomething = true;
900 _PTR(SComponent) aComponent = aStudy->FindComponent(STUDY_SUPERVISION);
901 if ( aComponent ) { // if component found, create name and icon for it to display it in object browser
902 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributeName");
904 aName->SetValue( (( CAM_Application* )(study->application()))->moduleTitle( "SUPERV" ).latin1() );
906 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributePixMap");
907 _PTR(AttributePixMap) aPixmap ( anAttr );
908 aPixmap->SetPixMap( "ICON_OBJBROWSER_Supervision" );
910 SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
912 aBuilder->DefineComponentInstance(aComponent, SalomeApp_Application::orb()->object_to_string(aSupMod->getEngine()));
913 //dynamic_cast<SALOMEDS_Study*>( aStudy )->ConvertObjectToIOR(aSupMod->getEngine()));
914 else MESSAGE("NULL Supervision module!");
917 // create dataflow SObject ("aNewDataflow_1")
918 aSO = aBuilder->NewObject(aComponent);
919 anAttr = aBuilder->FindOrCreateAttribute(aSO, "AttributeName");
921 aName->SetValue(dataflow->Name());
922 anAttr = aBuilder->FindOrCreateAttribute(aSO, "AttributeIOR");
923 _PTR(AttributeIOR) anIORAttr ( anAttr );
924 anIORAttr->SetValue(dataflow->getIOR());
930 void SUPERVGUI_Main::addDataflowToStudy() {
932 _PTR(StudyBuilder) aBuilder ( (( SalomeApp_Study* )study)->studyDS()->NewBuilder() );
933 aBuilder->NewCommand();
934 _PTR(SObject) aDF ( createDataflowSObj( study, dataflow, aBuilder, isCreated ) );
936 aBuilder->CommitCommand();
937 // what is this register/unregister?? don't know..
938 SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
940 MESSAGE("NULL Supervision module!");
943 aSupMod->unregisterGraph(this);
944 aSupMod->registerGraph(dataflow->getIOR(), this);
946 if ( !myThread->running() )
947 aSupMod->updateObjBrowser();
950 MESSAGE( "ERROR: failed to find or create dataflow SObject" );
951 aBuilder->AbortCommand();
955 bool SUPERVGUI_Main::putDataStudy( SUPERV_Port p, const char* inout ) {
956 Trace("SUPERVGUI_Main::putDataStudy");
958 // static variable to ensure that only one instance (thread) is executing this function
959 static bool isIn = false;
960 if (isIn) return true;
963 _PTR(Study) aStudy = (( SalomeApp_Study* )study)->studyDS();
964 const bool aLocked = aStudy->GetProperties()->IsLocked();
965 _PTR(StudyBuilder) aBuilder ( aStudy->NewBuilder() );
966 bool aDoneSomething = false;
968 // asv 23.11.04 : fix for PAL6852 if the study is locked -- then we can't put anything in it.
970 MESSAGE( "The study is locked and can not be modified!" );
975 // check if the port and its node are good
976 if ( CORBA::is_nil( p ) || CORBA::is_nil( p->Node() ) ) {
977 MESSAGE( "putInStudy ERROR: port or node are NULL!" );
982 // open new command. Commit or Abort it depending on aDoneSomething variable or error
983 aBuilder->NewCommand();
985 // Find or create "Supervisor -> aNewDataflow_1" SObjects in the study
986 _PTR(SObject) aSO = createDataflowSObj( study, dataflow, aBuilder, aDoneSomething );
989 MESSAGE( "ERROR: putDataStudy() could not find or create dataflow SObject" );
990 aBuilder->AbortCommand();
995 // Create "Run -> Time and date, etc." SObjects
996 if ( p->State() == SUPERV::ReadyState ) { // if port contains valid computed value
998 aSO = SearchOrCreateSOWithName( aStudy, aBuilder, aSO, QString("Run ") + myRunTime.toString(), &aDoneSomething ); // get run time SO
999 aSO = SearchOrCreateSOWithName( aStudy, aBuilder, aSO, p->Node()->Name(), &aDoneSomething ); // get node SO
1000 aSO = SearchOrCreateSOWithName( aStudy, aBuilder, aSO, inout, &aDoneSomething ); // get in/out SO
1001 aSO = SearchOrCreateSOWithName( aStudy, aBuilder, aSO, p->Name(), &aDoneSomething ); // get port SO
1003 // create IOR attribute for port SObject (usually with "return" name)
1004 _PTR(GenericAttribute) anAttr ( aBuilder->FindOrCreateAttribute(aSO, "AttributeIOR") );
1005 _PTR(AttributeIOR) anIORAttr ( anAttr );
1007 // if we have not created anything (all SObject already existed) and we have the same IORAttribute
1008 // on the needed SObject -> then don't do anything! it's already there!
1009 if ( !aDoneSomething && strcmp(anIORAttr->Value().c_str(), p->ToString()) == 0 ) {
1010 aBuilder->AbortCommand();
1015 aDoneSomething = true; // going to set some value to anIORAttr any way from this point..
1017 // set object value to the study: if object is external, then put it with
1018 // help of the specific component - owner
1020 // get according component driver for result object
1021 SALOME_LifeCycleCORBA aLCC( myNService );
1022 SUPERV_FNode aFNode = SUPERV::FNode::_narrow( p->Node() );
1023 if ( !aFNode->_is_nil() ) {
1024 Engines::Component_var aComponent = aLCC.FindOrLoad_Component( aFNode->GetContainer(), aFNode->GetComponentName() );
1025 SALOMEDS::Driver_var aDriver = SALOMEDS::Driver::_narrow( aComponent );
1026 if ( !CORBA::is_nil( aDriver ) ) { // if driver was found, publish object
1027 CORBA::Object_ptr anObject = new CORBA::Object();
1028 CORBA::Any* anAny = p->ToAny();
1029 (*anAny) >>= anObject;
1031 if ( aDriver->CanPublishInStudy( anObject ) ) {
1032 SALOMEDS::SObject_var aTmpSO;// = aSO;
1033 SALOMEDS_Study* aSStudy = dynamic_cast<SALOMEDS_Study*>( aStudy.get() );
1034 if ( !aSStudy ) return false;
1035 aTmpSO = aDriver->PublishInStudy( aSStudy->GetStudy(), aTmpSO, anObject, "" );
1036 aBuilder->Addreference(aSO, _PTR(SObject)(new SALOMEDS_SObject( aTmpSO )) );
1038 else { // can't publish object: abort transaction
1039 MESSAGE( "CanPublishInStudy() returned FALSE. ok, AbortCommand.." );
1040 aBuilder->AbortCommand();
1045 else { // component has no driver, but could store IORs (like Calculator)
1046 _PTR(SObject) anIORSO ( aStudy->FindObjectIOR( p->ToString() ) );
1048 aBuilder->Addreference(aSO, anIORSO);
1049 else { // Hm... the object (==port value) was not found, so we don't publish it.
1050 MESSAGE( "The object (==port value) was not found, so we don't publish it" );
1051 aBuilder->AbortCommand();
1057 else { // FNode is NULL -> bad
1058 MESSAGE( "FNode is NULL. Not good at all. Aborting command." );
1059 aBuilder->AbortCommand();
1065 anIORAttr->SetValue( p->ToString() ); // ior attribute already set for the prevoius condition
1069 if ( aDoneSomething )
1070 aBuilder->CommitCommand();
1072 aBuilder->AbortCommand();
1074 if ( !myThread->running() ) {
1075 SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
1077 aSupMod->updateObjBrowser();
1078 else MESSAGE("NULL Supervision module!");
1086 void SUPERVGUI_Main::ActivatePanning()
1088 if (myCanvasView->isVisible()) {
1089 myCanvasView->ActivatePanning();
1090 } else if (myArrayView->isVisible()) {
1091 myArrayView->ActivatePanning();
1096 void SUPERVGUI_Main::ResetView()
1098 if (myCanvasView->isVisible()) {
1099 myCanvasView->ResetView();
1100 } else if (myArrayView->isVisible()) {
1101 myArrayView->ResetView();
1105 void SUPERVGUI_Main::syncNotification() {
1115 while (notification->Receive(&graph, &node, &type, &message, &sender, &counter, &date, &stamp)) {
1116 if (isFiltered(graph, node, type, message, sender, counter, date, stamp)) {
1118 mess += "NOTIF: "; mess += graph;
1119 mess += " / " ; mess += node;
1120 mess += " / " ; mess += type;
1121 mess += " / " ; mess += message;
1122 getMessage()->putMessage(mess.latin1());
1127 bool SUPERVGUI_Main::isFiltered(char* graph, char* node, char* type, char* message,
1128 char* sender, long counter, char* date, long stamp) {
1129 Trace("SUPERVGUI_Main::isFiltered");
1131 if (strcmp(getDataflow()->Name(), graph) == 0) {
1132 SUPERVGUI_CanvasNode* n;
1133 QObjectList* nodes = queryList("SUPERVGUI_CanvasNode");
1134 QObjectListIt i(*nodes);
1135 while ((n=(SUPERVGUI_CanvasNode*)i.current()) != 0) {
1137 if (strcmp(n->name(), node) == 0) {
1138 if (strcmp(type, NOTIF_WARNING) == 0) {
1140 } else if (strcmp(type, NOTIF_STEP) == 0) {
1142 } else if (strcmp(type, NOTIF_TRACE) == 0) {
1144 } else if (strcmp(type, NOTIF_VERBOSE) == 0) {
1151 if ( myLogged && myLogFile && ( ( !myFiltered ) || b ) ) {
1152 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 );
1153 fflush( myLogFile );
1159 void SUPERVGUI_Main::closeEvent(QCloseEvent* e) {
1164 void SUPERVGUI_Main::setPaletteBackgroundColor(const QColor& color) {
1166 myCanvas->setBackgroundColor(color);
1167 myCanvasView->setPaletteBackgroundColor(color.light());
1168 myArray->setBackgroundColor(color);
1169 myArrayView->setPaletteBackgroundColor(color.light());
1171 SUPERVGraph_View::setPaletteBackgroundColor(color);
1174 QPtrList< char * > SUPERVGUI_Main::getEventNodes() {
1175 return myEventNodes;
1178 void SUPERVGUI_Main::setEventNodes(QPtrList< char * > theEventNodes) {
1179 myEventNodes = theEventNodes;
1182 QPtrList< SUPERV::GraphState > SUPERVGUI_Main::getStates() {
1186 void SUPERVGUI_Main::setStates(QPtrList< SUPERV::GraphState > theStates) {
1187 myStates = theStates;
1190 int SUPERVGUI_Main::getNodesNumber() {
1191 //create a list of nodes of the graph
1192 SUPERV_Nodes nodes = getDataflow()->Nodes();
1193 int RetVal = nodes->CNodes.length() + nodes->FNodes.length() +
1194 nodes->INodes.length() + nodes->GNodes.length() +
1195 nodes->LNodes.length() + nodes->SNodes.length();
1199 SUPERVGUI_Thread* SUPERVGUI_Main::getMyThread() {
1203 void SUPERVGUI_Main::startTimer() {
1204 myTimer->start(500);
1207 void SUPERVGUI_Main::executionFinished() {
1208 SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
1210 aSupMod->updateObjBrowser();
1211 else MESSAGE("NULL Supervision module!");
1217 void SUPERVGUI_Main::checkExecution() {
1218 if (myThread->finished()) {
1220 executionFinished();
1225 * Editing() is to be called by any operation in GUI before modification of a datamodel
1226 * (add/remove ports or nodes, etc.). It is used to resolve inconsistancies between 2 data models
1227 * in Engine: Editor and Executor. During and after execution, the values of ports and statuses of nodes
1228 * are taken from Executor data model. But when user starts editing the graph - these changes must
1229 * be applied to Editor data model. This function destroys Executor data model and moves to Editor.
1231 void SUPERVGUI_Main::Editing() {
1232 if ( !SUPERV_isNull( dataflow ) )
1233 dataflow->Editing();
1235 // updata GUI, Nodes' statuses and Ports' values could change.
1239 void SUPERVGUI_Main::removeArrayChild(SUPERV::CNode_ptr theNode)
1241 // mkr: since the deletion of the node allow only in CANVAS view,
1242 // it is necessary to remove the CanvasArray's children, which
1243 // have the same CNode engine as deleting node. This CNode is given
1246 const QObjectList* aChList = myArray->children();
1247 if ( aChList ) { // asv 27.01.05 : fix for 7817
1248 QObjectListIt aItChList(*aChList);
1249 SUPERVGUI_CanvasNode* anObjNode;
1250 while ((anObjNode = (SUPERVGUI_CanvasNode*)aItChList.current()) != 0) {
1252 if ((QString(anObjNode->getEngine()->Name())).compare(QString(theNode->Name())) == 0) {
1253 myArray->removeChild(anObjNode);
1257 } // end of if ( ChList )
1262 * ReadyToModify() must be called before any modification
1263 * operation - asks to kill execution of dataflow. If returns false -
1264 * modification (==Editing() ) is not allowed.
1266 bool SUPERVGUI_Main::ReadyToModify() {
1267 if ( CORBA::is_nil( dataflow ) )
1269 if ( dataflow->IsExecuting() ) {
1270 bool quit = SUIT_MessageBox::warn2( SUIT_Session::session()->activeApplication()->desktop(), // 0=Yes, 1=No
1271 tr("WARNING"), tr("MSG_GRAPH_ISRUN"), tr( "BUT_YES" ), tr( "BUT_CANCEL" ), 0, 1, 0 );
1272 if ( quit ) // user selected NOT to kill dataflow and NOT to add new node
1274 else if ( dataflow->IsExecuting() ) // user selected to kill the dataflow and add new node after that
1275 kill(); // checking again for IsExecuting to be sure that it was not finished while MB was up
1280 /******************************* SUPERVGUI_Thread class ****************************************/
1281 SUPERVGUI_Thread::SUPERVGUI_Thread()
1287 SUPERVGUI_Thread::~SUPERVGUI_Thread()
1289 //it is a virtual destructor and needs to be determine here
1292 void SUPERVGUI_Thread::startThread(const char* m)
1297 myMain->getMessage()->putMessage(m);
1304 void SUPERVGUI_Thread::setMain( SUPERVGUI_Main* theMain )
1309 void SUPERVGUI_Thread::KillThread( bool theValue )
1312 myIsActive = !(theValue);
1316 typedef TVoidMemFun2ArgEvent<SUPERVGUI_Main, char*, SUPERV::GraphState> TNodeSyncEvent;
1318 void SUPERVGUI_Thread::run()
1320 myMain->startTimer();
1322 // GUI cycle to handle events coming for Engine
1323 while ( myIsActive ) {
1325 SUPERV_CNode aNode = NULL;
1326 SUPERV::GraphEvent aEvent = SUPERV::UndefinedEvent ;
1327 SUPERV::GraphState aState = SUPERV::UndefinedState ;
1329 // blocking function of Engine. Return from there only after anEvent happens on node aNode
1330 myMain->getDataflow()->Event(aNode, aEvent, aState);
1332 // "kill" or undefined event came
1333 if (( aEvent == SUPERV::UndefinedEvent && aState == SUPERV::UndefinedState ) ||
1334 ( aEvent == SUPERV::NoEvent && aState == SUPERV::NoState ) ||
1335 ( aEvent == SUPERV::KillEvent && aState == SUPERV::KillState )) {
1339 else { // a "normal" execution event came
1341 if ( aNode != NULL && !CORBA::is_nil( aNode ) )
1342 aName = aNode->Name();
1344 // this function is asynchronious. The call does NOT wait when SUPERVGUI_Main::execute finishes
1345 // handling the event. So: SUPERVGUI_Main::execute must be fast, in order we don't get here again
1346 // on the next loop iteration, BEFORE previous SUPERVGUI_Main::execute finished.
1347 ProcessVoidEvent( new TNodeSyncEvent( myMain, &SUPERVGUI_Main::execute, aName, aState ) );
1350 // execution is finished. just set a "finished" message(s)
1351 if ( !myIsActive ) {
1352 switch ( myMain->getDataflow()->State() ) {
1353 case SUPERV_Editing :
1354 myMain->getMessage()->putMessage( myMain->getDataflow()->IsReadOnly()?
1355 tr("MSG_GRAPH_READONLY"): tr("MSG_GRAPH_EDITING") );
1357 case SUPERV_Suspend :
1358 myMain->getMessage()->putMessage( tr("MSG_GRAPH_SUSPENDED") );
1361 myMain->getMessage()->putMessage( tr("MSG_GRAPH_FINISHED") );
1364 myMain->getMessage()->putMessage( tr("MSG_GRAPH_ABORTED") );
1367 myMain->getMessage()->putMessage( tr("MSG_GRAPH_KILLED") );
1371 // asv 03.02.05 : fix for PAL6859, not very good, but works..
1373 } // end of if !myIsActive
1374 } // end of while( myIsActive )
1379 /******************************* SUPERVGUI_DSGraphParameters class ****************************************/
1383 SUPERVGUI_DSGraphParameters::SUPERVGUI_DSGraphParameters(SUPERV_Graph theGraph, bool isReadOnly)
1384 : QDialog( SUIT_Session::session()->activeApplication()->desktop(), "", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
1386 Trace("SUPERVGUI_DSGraphParameters::SUPERVGUI_DSGraphParameters");
1387 setCaption( tr( "TLT_DSGRAPHPARAMS" ) );
1388 setSizeGripEnabled( true );
1391 QGridLayout* TopLayout = new QGridLayout( this );
1392 TopLayout->setSpacing( 6 );
1393 TopLayout->setMargin( 11 );
1395 QGroupBox* TopGroup = new QGroupBox( this, "TopGroup" );
1396 TopGroup->setColumnLayout(0, Qt::Vertical );
1397 TopGroup->layout()->setSpacing( 0 );
1398 TopGroup->layout()->setMargin( 0 );
1399 QGridLayout* TopGroupLayout = new QGridLayout( TopGroup->layout() );
1400 TopGroupLayout->setAlignment( Qt::AlignTop );
1401 TopGroupLayout->setSpacing( 6 );
1402 TopGroupLayout->setMargin( 11 );
1405 QLabel* DeltaTimeL = new QLabel( tr( "DELTATIME_LBL" ), TopGroup );
1406 TopGroupLayout->addWidget( DeltaTimeL, 0, 0 );
1408 myDeltaTime = new QtxDblSpinBox( 0.0, 1.0, 0.1, TopGroup );
1409 myDeltaTime->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
1410 TopGroupLayout->addWidget( myDeltaTime, 0, 1 );
1413 QLabel* TimeOutL = new QLabel( tr( "TIMEOUT_LBL" ), TopGroup);
1414 TopGroupLayout->addWidget( TimeOutL, 1, 0 );
1416 myTimeOut = new QLineEdit( TopGroup );
1417 myTimeOut->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
1418 myTimeOut->setValidator( new QIntValidator(this) );
1419 myTimeOut->setMinimumSize( 100, 0 );
1420 myTimeOut->setReadOnly( isReadOnly );
1421 TopGroupLayout->addWidget( myTimeOut, 1, 1 );
1424 QLabel* DataStreamTraceL = new QLabel( tr( "DATASTREAMTRACE_LBL" ), TopGroup);
1425 TopGroupLayout->addWidget( DataStreamTraceL, 2, 0 );
1427 myDataStreamTrace = new QComboBox( TopGroup );
1428 myDataStreamTrace->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
1429 myDataStreamTrace->insertItem("WithoutTrace");
1430 myDataStreamTrace->insertItem("SummaryTrace");
1431 myDataStreamTrace->insertItem("DetailedTrace");
1432 TopGroupLayout->addWidget( myDataStreamTrace, 2, 1 );
1434 QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
1435 GroupButtons->setColumnLayout(0, Qt::Vertical );
1436 GroupButtons->layout()->setSpacing( 0 );
1437 GroupButtons->layout()->setMargin( 0 );
1438 QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
1439 GroupButtonsLayout->setAlignment( Qt::AlignTop );
1440 GroupButtonsLayout->setSpacing( 6 );
1441 GroupButtonsLayout->setMargin( 11 );
1443 QPushButton* okB = new QPushButton( tr( "BUT_OK" ), GroupButtons );
1444 QPushButton* cancelB = new QPushButton( tr( "BUT_CANCEL" ), GroupButtons );
1446 GroupButtonsLayout->addWidget( okB, 0, 0 );
1447 GroupButtonsLayout->addItem ( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
1448 GroupButtonsLayout->addWidget( cancelB, 0, 2 );
1450 TopLayout->addWidget( TopGroup, 0, 0 );
1451 TopLayout->addWidget( GroupButtons, 1, 0 );
1453 connect( okB, SIGNAL( clicked() ), this, SLOT( accept() ) );
1454 connect( cancelB, SIGNAL( clicked() ), this, SLOT( reject() ) );
1462 SUPERVGUI_DSGraphParameters::~SUPERVGUI_DSGraphParameters() {
1463 Trace("SUPERVGUI_DSGraphParameters::~SUPERVGUI_DSGraphParameters");
1469 void SUPERVGUI_DSGraphParameters::setData() {
1472 SUPERV::KindOfDataStreamTrace aDataStreamTrace;
1474 // myGraph->StreamParams(aTimeOut, aDataStreamTrace, aDeltaTime);
1475 if (myGraph->IsStreamGraph()) {
1476 SUPERV_StreamGraph aSGraph = myGraph->ToStreamGraph();
1477 if (!SUPERV_isNull(aSGraph))
1478 aSGraph->StreamParams(aTimeOut, aDataStreamTrace, aDeltaTime);
1481 myDeltaTime->setValue(aDeltaTime);
1482 myTimeOut->setText(QString("%1").arg(aTimeOut));
1483 myDataStreamTrace->setCurrentItem((int)aDataStreamTrace);
1489 void SUPERVGUI_DSGraphParameters::accept() {
1490 // myGraph->SetStreamParams( myTimeOut->text().toLong(),
1491 // (SUPERV::KindOfDataStreamTrace) myDataStreamTrace->currentItem(),
1492 // myDeltaTime->value());
1493 if (myGraph->IsStreamGraph()) {
1494 SUPERV_StreamGraph aSGraph = myGraph->ToStreamGraph();
1495 if (!SUPERV_isNull(aSGraph))
1496 aSGraph->SetStreamParams( myTimeOut->text().toLong(),
1497 (SUPERV::KindOfDataStreamTrace) myDataStreamTrace->currentItem(),
1498 myDeltaTime->value());