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