Salome HOME
DCQ : Merge with Ecole_Ete_a6.
[modules/superv.git] / src / SUPERVGUI / SUPERVGUI.cxx
1 //  SUPERV SUPERVGUI : GUI for Supervisor component
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
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. 
10 // 
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. 
15 // 
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 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : SUPERVGUI.cxx
25 //  Author : Francis KLOSS
26 //  Module : SUPERV
27
28 using namespace std;
29 #include "SUPERVGUI.h"
30
31 #include "QAD_Resource.h"
32 #include "QAD_FileDlg.h"
33 #include "QAD_Application.h"
34 #include "QAD_StudyFrame.h"
35 #include "QAD_RightFrame.h"
36 #include "QAD_LeftFrame.h"
37 #include "QAD_ViewFrame.h"
38 #include "QAD_ObjectBrowser.h"
39 #include "QAD_ObjectBrowserItem.h"
40 #include "SALOME_Selection.h"
41 #include "SALOMEGUI_NameDlg.h"            
42 #include "Utils_ORB_INIT.hxx"
43 #include "SALOME_ListIteratorOfListIO.hxx"
44 #include "SALOME_InteractiveObject.hxx"
45 #include <qapplication.h>
46 #include "SALOMEGUI_ImportOperation.h"
47
48 #include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
49
50
51 int SUPERVGUI::factory = 0;
52 SUPERVGUI Supervision("");
53
54
55 SUPERVGUI::SUPERVGUI(const QString& theName, QObject* theParent)
56      : SALOMEGUI( theName, theParent ),
57        desktop(0),
58        study(0),
59        browser(0)
60   //info(0)
61 {
62     Trace("SUPERVGUI::SUPERVGUI")
63     if (factory==0) {
64         factory = 1;
65         MESSAGE("SUPERVGUI Info : factory build");
66     } else {
67         MESSAGE("SUPERVGUI Error : another call to factory constructor");
68     };
69 }
70
71 SUPERVGUI::~SUPERVGUI() {
72     Trace("SUPERVGUI::~SUPERVGUI")
73     if (factory==1) {
74         factory = 0;
75         //if (!engine->_is_nil()) CORBA::release(engine);         
76         //info->close();
77         if (browser) browser->close();
78         MESSAGE("SUPERVGUI Info : factory destroy");
79     } else {
80         MESSAGE("SUPERVGUI Error : another call to factory destructor");
81     };
82 }
83
84 void SUPERVGUI::init(QAD_Desktop* parent) {
85     Trace("SUPERVGUI::init")
86     if (desktop==0) {
87         desktop = parent;
88         study = desktop->getActiveStudy();
89         SALOME_NamingService* namingService = desktop->getNameService();
90         loadEngine(namingService);
91         browser = new SUPERVGUI_Service(namingService);
92         //info    = new SUPERVGUI_Information();
93         cursor  = desktop->cursor();
94         connect(desktop->getMainFrame(), SIGNAL(windowActivated(QWidget*)), this, SLOT(setMain(QWidget*)));
95
96         int anId = 300;
97         parent->menuBar()->changeItem(anId,parent->getComponentUserName("SUPERV"));
98         
99     };
100 }
101
102
103 QAD_StudyFrame* SUPERVGUI::createGraph() {
104   QAD_StudyFrame* aStudyFrame = study->newWindow3d(study->getNextStudyFrameName(),
105                                                    VIEW_GRAPHSUPERV, false);
106   if (aStudyFrame) {
107     connect(aStudyFrame, 
108             SIGNAL(sfStudyFrameClosing(QAD_StudyFrame*)), 
109             &Supervision, 
110             SLOT(onGraphClosed(QAD_StudyFrame*)));
111   }
112   return aStudyFrame;
113 }
114
115
116
117 void SUPERVGUI::loadEngine(SALOME_NamingService* namingService) {
118     Trace("SUPERVGUI::loadEngine")
119     SALOME_LifeCycleCORBA LCC(namingService);
120     Engines::Component_var objComponent = LCC.FindOrLoad_Component("SuperVisionContainer", "SUPERV");
121     if (CORBA::is_nil(objComponent)) {
122         QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_LOAD_SUPERV"));
123         return;
124     };
125
126     SUPERV::SuperG_var aSuperVisionComponent;
127     aSuperVisionComponent = SUPERV::SuperG::_narrow(objComponent);
128     if (CORBA::is_nil(aSuperVisionComponent)) {
129         QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_NARROW_SUPERV"));
130         return;
131     };
132
133     //    engine  = new SUPERV::SuperG_var;
134     engine = aSuperVisionComponent;
135 }
136 /*
137 bool SUPERVGUI::information(SUPERV_CNode node, bool isReadOnly) {
138     Trace("SUPERVGUI::information")
139     return(info->run(node, isReadOnly));
140 }
141 */
142 void SUPERVGUI::putInfo(const char* mess) {
143     Trace("SUPERVGUI::putInfo")
144     desktop->putInfo(mess);
145 }
146
147 QAD_Desktop* SUPERVGUI::getDesktop() {
148     Trace("SUPERVGUI::getDesktop")
149     return(desktop);
150 }
151
152 SUPERV_Engine SUPERVGUI::getEngine() {
153     Trace("SUPERVGUI::getEngine")
154     return(engine);
155 }
156
157 SUPERVGUI_Service* SUPERVGUI::getBrowser() {
158     Trace("SUPERVGUI::getBrowser")
159     return(browser);
160 }
161
162 QCursor SUPERVGUI::getCursor() {
163     Trace("SUPERVGUI::getCursor")
164     return(cursor);
165 }
166
167 SUPERVGUI_Main* SUPERVGUI::getMain() {
168     Trace("SUPERVGUI::getMain")
169     return main;
170 }
171
172
173 void SUPERVGUI::registerGraph(QString theName, SUPERVGUI_Main* theGraph){
174   theGraph->setHashCode(theName);
175   myGraphList.append(theGraph);
176 }
177
178
179 void SUPERVGUI::unregisterGraph(SUPERVGUI_Main* theGraph) {
180   SUPERVGUI_Main* aMain;
181   for (aMain = myGraphList.first(); aMain; aMain = myGraphList.next()) {
182     if (aMain == theGraph)
183       myGraphList.remove(aMain);
184   }
185 }
186
187
188 bool SUPERVGUI::isContains(QAD_Study* theStudy, const QString theKey) {
189   SUPERVGUI_Main* aMain;
190   for (aMain = myGraphList.first(); aMain; aMain = myGraphList.next()) {
191     if ((aMain->getStudy() == theStudy) && (aMain->getHashCode() == theKey))
192       return true;
193   }
194   return false;
195 }
196
197
198 void SUPERVGUI::onGraphClosed(QAD_StudyFrame* theStudyFrame) {
199   QAD_ViewFrame* viewFrame = theStudyFrame->getRightFrame()->getViewFrame();
200   if(SUPERVGraph_ViewFrame* supervFrame = dynamic_cast<SUPERVGraph_ViewFrame*>(viewFrame)){
201     disconnect(theStudyFrame, 0 , this, 0);
202     SUPERVGraph_View* view = supervFrame->getViewWidget();
203     SUPERVGUI_Main* aGraph = dynamic_cast<SUPERVGUI_Main*>(view);
204     if (aGraph) {
205       unregisterGraph(aGraph);
206     }
207   }
208 }
209
210 void SUPERVGUI::setMain(QWidget* w) {
211   main = 0;
212   QAD_StudyFrame* aStudyFrame = dynamic_cast<QAD_StudyFrame*>(w);
213   if (!aStudyFrame) return;
214
215   study = aStudyFrame->getStudy();
216   if (!study) return;
217
218   QAD_ViewFrame* viewFrame = aStudyFrame->getRightFrame()->getViewFrame();
219   if(SUPERVGraph_ViewFrame* supervFrame = dynamic_cast<SUPERVGraph_ViewFrame*>(viewFrame)){
220     SUPERVGraph_View* view = supervFrame->getViewWidget();
221     if (view)
222       main = dynamic_cast<SUPERVGUI_Main*>(view);
223   }
224   Trace("SUPERVGUI::setMain - main: "<<main);
225 }
226
227
228 void SUPERVGUI::importDataflow() {
229   Trace("SUPERVGUI::importDataflow");
230   QString f = QAD_FileDlg::getFileName(QAD_Application::getDesktop(),
231                                        "",
232                                        "*.xml",
233                                        tr("MSG_IMPORT"),
234                                        true);
235   
236   if (!f.isEmpty()) {
237     if (isContains(study, f)) {
238       if (QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), 
239                                tr("MSG_GRAPH_DISPLAYED").arg(f), 
240                                QMessageBox::Yes, QMessageBox::No) == QMessageBox::No)
241         return;
242     }
243
244     SUPERV_Graph aGraph = engine->StreamGraphE(f);
245     //QFileInfo aFile(f);
246     //aGraph->SetName(aFile.baseName());
247     if (SUPERV_isNull(aGraph)) {
248       QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_BAD_FILE").arg(f));
249       return;
250     }
251
252     QAD_StudyFrame* aStudyFrame = createGraph();
253     SUPERVGraph_ViewFrame* aViewFrame = dynamic_cast<SUPERVGraph_ViewFrame*>
254       (aStudyFrame->getRightFrame()->getViewFrame());
255     if(aViewFrame) {
256       main = new SUPERVGUI_Main(aViewFrame, desktop, aGraph);
257       registerGraph(f, main);
258       study->showFrame(aStudyFrame);
259     }   
260   }
261 }
262
263 void SUPERVGUI::displayDataflow() {
264     Trace("SUPERVGUI::displayDataflow");
265     QAD_ObjectBrowser* aBrowser = ((QAD_StudyFrame*)(desktop->getMainFrame()->activeWindow()))->getLeftFrame()->getObjectBrowser();
266     SUPERV_Graph aDataFlow;
267     QString aIORName;
268
269     QAD_ObjectBrowserItem* item = (QAD_ObjectBrowserItem*)(aBrowser->getListView()->currentItem());
270     SALOMEDS::SObject_var aObj = desktop->getActiveStudy()->getStudyDocument()->FindObjectID(item->getEntry().latin1());
271     SALOMEDS::GenericAttribute_var anAttr;
272     if (aObj->FindAttribute(anAttr, "AttributeIOR")) {
273       SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
274       Standard_CString ior = anIOR->Value();
275       aIORName = ior;
276       if (isContains(study, aIORName)) {
277         if (QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), 
278                                  tr("MSG_GRAPH_DISPLAYED").arg(""), 
279                                  QMessageBox::Yes, QMessageBox::No) == QMessageBox::No)
280           return;
281       }
282       aDataFlow = engine->getStreamGraph(ior);
283       if (SUPERV_isNull(aDataFlow)) {
284         QMessageBox::warning(0, tr("ERROR"), tr("MSG_ACCESS_BAD_IOR"));
285         return;
286       }
287     }
288     QAD_StudyFrame* aStudyFrame = createGraph();
289     SUPERVGraph_ViewFrame* aViewFrame = dynamic_cast<SUPERVGraph_ViewFrame*>
290       (aStudyFrame->getRightFrame()->getViewFrame());
291     if(aViewFrame) {
292       main = new SUPERVGUI_Main(aViewFrame, desktop, aDataFlow);
293       main->setAsFromStudy(true);
294       registerGraph(aIORName, main);
295       study->showFrame(aStudyFrame);
296     }
297 }
298
299
300 void SUPERVGUI::renameDataflow() {
301   SALOME_Selection* Sel = SALOME_Selection::Selection( study->getSelection() );
302   SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
303   for ( ; It.More(); It.Next() ) {
304     Handle(SALOME_InteractiveObject) IObject = It.Value();
305     
306     SALOMEDS::Study_var aStudy = study->getStudyDocument();
307     SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() );
308     SALOMEDS::GenericAttribute_var anAttr;
309     SALOMEDS::AttributeName_var    aName;
310     if ( !obj->_is_nil() ) {
311       if (obj->FindAttribute(anAttr, "AttributeName")) {
312         aName = SALOMEDS::AttributeName::_narrow(anAttr);
313         QString nm = QString( aName->Value() );
314         bool ok = FALSE;
315         nm = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), nm );
316         if ( !nm.isEmpty() ) {
317           QApplication::setOverrideCursor( Qt::waitCursor );
318           study->renameIObject( IObject, nm );
319           QApplication::restoreOverrideCursor();
320         }
321       }
322     }
323   }
324 }
325
326
327 void SUPERVGUI::exportDataflow() {
328     Trace("SUPERVGUI::exportDataflow")
329     if (main==0) {
330         QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NOWINDOW_TO_EXPORT"));
331     } else {
332       QString f = QAD_FileDlg::getFileName(QAD_Application::getDesktop(),
333                                            "",
334                                            "*.xml",
335                                            tr("TTL_EXPORT_DATAFLOW"),
336                                            false);
337       if (!f.isEmpty()) {
338         if (main->exportDataflow(f)) {
339           unregisterGraph(main);
340           registerGraph(f, main);
341         }
342       }
343     }
344 }
345
346 void SUPERVGUI::newDataflow() {
347     Trace("SUPERVGUI::editDataflow");
348     QAD_StudyFrame* aStudyFrame = createGraph();
349     SUPERVGraph_ViewFrame* aViewFrame = dynamic_cast<SUPERVGraph_ViewFrame*>
350       (aStudyFrame->getRightFrame()->getViewFrame());
351     if(aViewFrame){
352       main = new SUPERVGUI_Main(aViewFrame, desktop, false);
353       main->addNode();
354       study->showFrame(aStudyFrame);
355     }
356 }
357
358 void SUPERVGUI::modifyDataflow() {
359     Trace("SUPERVGUI::modifyDataflow")
360     QString f = QAD_FileDlg::getFileName(QAD_Application::getDesktop(),
361                                          "",
362                                          "*.xml",
363                                          tr("Modify Dataflow"),
364                                          true);
365     if (!f.isEmpty()){
366       if (isContains(study, f)) {
367       if (QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), 
368                                tr("MSG_GRAPH_DISPLAYED").arg(f), 
369                                QMessageBox::Yes, QMessageBox::No) == QMessageBox::No)
370         return;
371       }
372       
373       SUPERV_Graph aGraph = engine->StreamGraph(f);
374       //QFile aFile(f);
375       //aGraph->SetName(aFile.name());
376       if (SUPERV_isNull(aGraph)) {
377         QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_BAD_FILE").arg(f));
378         return;
379       }
380
381       QAD_StudyFrame* aStudyFrame = createGraph();
382       SUPERVGraph_ViewFrame* aViewFrame = dynamic_cast<SUPERVGraph_ViewFrame*>
383         (aStudyFrame->getRightFrame()->getViewFrame());
384       if(aViewFrame) {
385         main = new SUPERVGUI_Main(aViewFrame, desktop, aGraph);
386         registerGraph(f, main);
387         study->showFrame(aStudyFrame);
388       }
389     }
390 }
391
392 void SUPERVGUI::reloadDataflow() {
393     Trace("SUPERVGUI::reloadDataflow")
394     if (main==0) {
395         QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NOWINDOW_TO_RELOAD"));
396     } else {
397         main->sync();
398     };
399 }
400
401 void SUPERVGUI::runDataflow() {
402     Trace("SUPERVGUI::runDataflow")
403     if (main==0) {
404         QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NOWINDOW_TO_RUN"));
405     } else {
406         main->run();
407     };
408 }
409
410 void SUPERVGUI::stepByStep() {
411     Trace("SUPERVGUI::stepByStep")
412     if (main==0) {
413         QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NOWINDOW_TO_RUN"));
414     } else {
415         main->startExecute();
416     }
417 }
418
419 void SUPERVGUI::killDataflow() {
420     Trace("SUPERVGUI::killDataflow")
421     if (main==0) {
422         QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NOWINDOW_TO_KILL"));
423     } else {
424         main->kill();
425     };
426 }
427
428 void SUPERVGUI::suspendResumeDataflow() {
429     Trace("SUPERVGUI::suspendResumeDataflow")
430     if (main==0) {
431         QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NOWINDOW_TO_SUSPEND"));
432     } else {
433         main->suspendResume();
434     };
435 }
436
437 void SUPERVGUI::showComponents() {
438   Trace("SUPERVGUI::showComponents");
439   if (main==0) {
440     QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NOWINDOW_TO_ADD"));
441   } else {
442     if (main->isEditable())
443       main->addNode();
444     else
445       QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NOTEDITABLE"));
446   }
447 }
448
449
450 bool SUPERVGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* popup, const QString& theContext, const QString& theParent, const QString& theObject) {
451   Trace("SUPERVGUI::customPopup");
452   Supervision.init(parent);
453   if(popup->count() > 3) {
454     // Temporary code: is to be deleted soon
455     popup->removeItem(QAD_Display_Popup_ID);
456     popup->removeItem(QAD_DisplayOnly_Popup_ID);
457     popup->removeItem(QAD_Erase_Popup_ID);
458     int id = popup->idAt(popup->count() - 1);
459     if (id < 0 && id != -1) popup->removeItem(id); // separator
460     // Temporary code end
461   }
462     SALOME_Selection* Sel = SALOME_Selection::Selection(study->getSelection() );
463     if ((Sel==NULL) || (Sel->IObjectCount() == 0)) return false;
464
465     if (Sel->IObjectCount() == 1) {
466       Handle(SALOME_InteractiveObject) anIObj = Sel->firstIObject();
467
468       // insert SUPERV-specific popup items here
469
470       bool isDataflow, ownObj;
471       whatIsSelected(anIObj, ownObj, isDataflow);
472       
473       if (isDataflow) {
474         popup->insertItem(tr( "MSG_RENAME" ), this, SLOT(renameDataflow()));
475         popup->insertItem("Display", this, SLOT(displayDataflow()));
476         popup->insertSeparator();
477       }
478       if (ownObj)
479         popup->insertItem(tr("MSG_DELETE"), this, SLOT(deleteObject()));
480     }
481     if (Sel->IObjectCount() > 1) {
482       int aIObjCount = 0;
483       SALOME_ListIteratorOfListIO It_forCheckOwner(Sel->StoredIObjects());
484       for(;It_forCheckOwner.More();It_forCheckOwner.Next()) {
485         Handle(SALOME_InteractiveObject) anIObj = It_forCheckOwner.Value();
486         bool aIsOwner, aIsDataflow;
487         whatIsSelected(anIObj, aIsOwner, aIsDataflow);
488         
489         if (aIsOwner) aIObjCount++;
490       }
491       if (aIObjCount == Sel->IObjectCount())  //all selected objects belong to Supervision
492         popup->insertItem(tr("MSG_DELETE"), this, SLOT(deleteObject()));
493     }
494   return(true);
495 }
496
497  
498
499 /** Returns:
500     theIsOwner = true if Selected object belongs to Suipervision.
501     theIsDataflow = true if Selected object is Dataflow
502 */
503 void SUPERVGUI::whatIsSelected(const Handle(SALOME_InteractiveObject)& theObj, bool& theIsOwner, bool& theIsDataflow) {
504   theIsOwner = false;
505   theIsDataflow = false;
506
507   if (theObj.IsNull()) return;
508   
509   SALOMEDS::Study_var aStudy = study->getStudyDocument();
510   SALOMEDS::SObject_var  obj = aStudy->FindObjectID( theObj->getEntry() );
511
512   if ( !obj->_is_nil() ) {
513     SALOMEDS::SComponent_var comp = obj->GetFatherComponent();
514     if ( !comp->_is_nil() ) {
515       SALOMEDS::GenericAttribute_var anAttr;
516       SALOMEDS::AttributeName_var    aName;
517       if (comp->FindAttribute(anAttr, "AttributeName")) {
518         aName = SALOMEDS::AttributeName::_narrow(anAttr);
519         QString compName(aName->Value());
520         //if (compName.compare(STUDY_SUPERVISION) == 0) {
521         if (compName.compare(QAD_Application::getDesktop()->getComponentUserName("SUPERV")) == 0) {
522           SALOMEDS::GenericAttribute_var anAttr;
523           if (obj->FindAttribute(anAttr, "AttributeIOR")) {
524             SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
525             SUPERV_Graph aDataFlow = engine->getStreamGraph(anIOR->Value());
526             if (!SUPERV_isNull(aDataFlow)) 
527               theIsDataflow = true;
528           }
529           CORBA::String_var anObjectID = obj->GetID();
530           CORBA::String_var aComponentID = comp->GetID();
531           if (strcmp(anObjectID, aComponentID)) theIsOwner = true;          
532         }
533       }
534     }
535   }
536 }
537
538
539 void SUPERVGUI::deleteObject() {
540   SALOME_Selection* Sel = SALOME_Selection::Selection(study->getSelection() );
541   if ((Sel==NULL) || (Sel->IObjectCount() == 0)) return;
542    
543   if (QMessageBox::warning(QAD_Application::getDesktop(),
544                            tr("WARNING"),
545                            tr("MSG_ASK_DELETE"),
546                            QMessageBox::No,
547                            QMessageBox::Yes) == QMessageBox::No)
548     return;
549    
550   SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
551   for(;It.More();It.Next()) {
552     Handle(SALOME_InteractiveObject) anIObj = It.Value();
553     bool aIsOwner, aIsDataflow;
554     whatIsSelected(anIObj, aIsOwner, aIsDataflow);
555     
556     SALOMEDS::Study_var aStudy = study->getStudyDocument();
557     SALOMEDS::SObject_var  aObj = aStudy->FindObjectID( anIObj->getEntry() );
558     if (!aObj->_is_nil()) {
559       if (aIsDataflow) {
560         SALOMEDS::GenericAttribute_var anAttr;
561         if (aObj->FindAttribute(anAttr, "AttributeIOR")) {
562           SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
563           QString ior = anIOR->Value();
564             
565           SUPERVGUI_Main* aMain;
566           for (aMain = myGraphList.first(); aMain; aMain = myGraphList.next()) {
567             if ((aMain->getStudy() == study) && (aMain->getHashCode() == ior)) {
568               aMain->setAsFromStudy(false);
569               break;
570             }
571           }
572         }
573       }
574       QAD_Operation* op = new SALOMEGUI_ImportOperation( study );
575       SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
576       op->start();
577       aBuilder->RemoveObjectWithChildren(aObj);
578       op->finish();
579     }
580   }
581   Sel->ClearIObjects() ; 
582 }
583
584 bool SUPERVGUI::OnGUIEvent(int command, QAD_Desktop* parent) {
585   Supervision.init(parent);
586   switch (command) {
587   case 301: 
588     Supervision.importDataflow();
589     return(false);
590     
591   case 302: 
592     Supervision.exportDataflow();
593     return(false);
594     
595   case 303: 
596     Supervision.newDataflow();
597     return(false);
598     
599   case 304: 
600     Supervision.modifyDataflow();
601     return(false);
602     
603   case 305:
604     Supervision.reloadDataflow();
605     return(false);
606     
607   case 306:
608     Supervision.runDataflow();
609     return(false);
610     
611   case 307: 
612     Supervision.killDataflow();
613     return(false);
614     
615   case 308:
616     Supervision.suspendResumeDataflow();
617     return(false);
618     
619   case 309: 
620     Supervision.showComponents();
621     return(false);
622     
623   case 310: 
624     Supervision.stepByStep();
625     return(false);
626     
627   default: 
628     QMessageBox::warning(QAD_Application::getDesktop(), "Supervision Error", "Unknown Command From Salome");
629     return(false);
630   }
631 }
632
633 bool SUPERVGUI::SetSettings(QAD_Desktop* parent) {
634   Trace("SUPERVGUI::SetSettings");
635   Supervision.init(parent);
636   return(true);
637 }
638
639 void SUPERVGUI::DefinePopup(QString& theContext, QString& theParent, QString& theObject) {
640   theObject  = "";
641   theContext = "";
642 }
643
644 bool SUPERVGUI::ActiveStudyChanged(QAD_Desktop* parent) {
645   Trace("SUPERVGUI::activeStudyChanged");
646   study = desktop->getActiveStudy();
647   return true;
648 }
649
650 void SUPERVGUI::SupportedViewType (int* buffer, int bufferSize)
651 {
652   if (!buffer || !bufferSize) return;
653   buffer[0] = (int)VIEW_GRAPHSUPERV;
654 }
655
656 extern "C"
657 {
658   Standard_EXPORT SALOMEGUI* GetComponentGUI() {
659     return &Supervision;
660   }
661 }