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