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.cxx
25 // Author : Francis KLOSS
29 #include "SUPERVGUI.h"
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"
48 #include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
51 int SUPERVGUI::factory = 0;
52 SUPERVGUI Supervision("");
55 SUPERVGUI::SUPERVGUI(const QString& theName, QObject* theParent)
56 : SALOMEGUI( theName, theParent ),
62 Trace("SUPERVGUI::SUPERVGUI")
65 MESSAGE("SUPERVGUI Info : factory build");
67 MESSAGE("SUPERVGUI Error : another call to factory constructor");
71 SUPERVGUI::~SUPERVGUI() {
72 Trace("SUPERVGUI::~SUPERVGUI")
75 //if (!engine->_is_nil()) CORBA::release(engine);
78 if (browser->isVisible())
82 MESSAGE("SUPERVGUI Info : factory destroy");
84 MESSAGE("SUPERVGUI Error : another call to factory destructor");
88 void SUPERVGUI::init(QAD_Desktop* parent) {
89 Trace("SUPERVGUI::init")
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*)));
101 parent->menuBar()->changeItem(anId,parent->getComponentUserName("SUPERV"));
107 QAD_StudyFrame* SUPERVGUI::createGraph() {
108 QAD_StudyFrame* aStudyFrame = study->newWindow3d(study->getNextStudyFrameName(),
109 VIEW_GRAPHSUPERV, false);
112 SIGNAL(supervStudyFrameClosing(QAD_ViewFrame*)),
114 SLOT(onGraphClosed(QAD_ViewFrame*)));
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"));
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"));
137 // engine = new SUPERV::SuperG_var;
138 engine = aSuperVisionComponent;
141 bool SUPERVGUI::information(SUPERV_CNode node, bool isReadOnly) {
142 Trace("SUPERVGUI::information")
143 return(info->run(node, isReadOnly));
146 void SUPERVGUI::putInfo(const char* mess) {
147 Trace("SUPERVGUI::putInfo")
148 desktop->putInfo(mess);
151 QAD_Desktop* SUPERVGUI::getDesktop() {
152 Trace("SUPERVGUI::getDesktop")
156 SUPERV_Engine SUPERVGUI::getEngine() {
157 Trace("SUPERVGUI::getEngine")
161 SUPERVGUI_Service* SUPERVGUI::getBrowser() {
162 Trace("SUPERVGUI::getBrowser")
166 QCursor SUPERVGUI::getCursor() {
167 Trace("SUPERVGUI::getCursor")
171 SUPERVGUI_Main* SUPERVGUI::getMain() {
172 Trace("SUPERVGUI::getMain")
177 void SUPERVGUI::registerGraph(QString theName, SUPERVGUI_Main* theGraph){
178 theGraph->setHashCode(theName);
179 myGraphList.append(theGraph);
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);
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))
202 void SUPERVGUI::onGraphClosed(QAD_ViewFrame* theViewFrame) {
203 if(SUPERVGraph_ViewFrame* supervFrame = dynamic_cast<SUPERVGraph_ViewFrame*>(theViewFrame)){
204 disconnect(study, 0 , this, 0);
205 SUPERVGraph_View* view = supervFrame->getViewWidget();
206 SUPERVGUI_Main* aGraph = dynamic_cast<SUPERVGUI_Main*>(view);
208 unregisterGraph(aGraph);
209 SUPERV_Graph aDataFlow = aGraph->getDataflow();
210 if ( !SUPERV_isNull( aDataFlow ) ) {
211 if ( aDataFlow->IsExecuting() ) {
212 const int aMsgResult = QMessageBox::warning(QAD_Application::getDesktop(),
214 tr("MSG_DF_RUNNING"),
215 tr("MSG_DF_EXECUTION"),
217 if ( aMsgResult == 1 ) {
219 if ( aDataFlow->Kill() ) {
220 // Kill() sends KillEvent and KillState to SUPERVGUI_Thread
221 // while sets myIsActive flag to false when it receives such event/state
222 // after myIsActive is false it calls QThread::exit() to terminate.
224 // why while() { qApp->processEvents() } ?
225 // because: SUPERVGUI_Thread::run() receives events, and calls myMain->execute()
226 // method using SALOME_Event paradigm, ProcessVoidEvent() function -
227 // it puts this event to the main application event loop, in which we are being now.
228 // So if we block main GUI application thread (by calling aGraph->getMyThread()->wait() here)
229 // then we will have a deadlock of 2 threads waiting for one another
230 while (aGraph->getMyThread()->running())
231 qApp->processEvents();
234 else { // BACKGROUND EXECUTION
235 emit KillMainThread(true); // set SUPERVGUI_Thread::myIsActive to false
236 while ( aGraph->getMyThread()->running() )
237 qApp->processEvents();
240 else { // EXECUTION IS FINISHED, JUST DESTROY THE SUPERVGUI_Thread object and return.
241 emit KillMainThread(true);
242 while ( aGraph->getMyThread()->running() )
243 qApp->processEvents();
250 void SUPERVGUI::setMain(QWidget* w) {
252 QAD_StudyFrame* aStudyFrame = dynamic_cast<QAD_StudyFrame*>(w);
253 if (!aStudyFrame) return;
255 study = aStudyFrame->getStudy();
258 QAD_ViewFrame* viewFrame = aStudyFrame->getRightFrame()->getViewFrame();
259 if(SUPERVGraph_ViewFrame* supervFrame = dynamic_cast<SUPERVGraph_ViewFrame*>(viewFrame)){
260 SUPERVGraph_View* view = supervFrame->getViewWidget();
262 main = dynamic_cast<SUPERVGUI_Main*>(view);
263 connect(&Supervision, SIGNAL(KillMainThread(bool)), main->getMyThread(), SLOT(KillThread(bool)));
266 Trace("SUPERVGUI::setMain - main: "<<main);
270 void SUPERVGUI::importDataflow() {
271 Trace("SUPERVGUI::importDataflow");
272 QString f = QAD_FileDlg::getFileName(QAD_Application::getDesktop(),
279 if (isContains(study, f)) {
280 if (QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"),
281 tr("MSG_GRAPH_DISPLAYED").arg(f),
282 QMessageBox::Yes, QMessageBox::No) == QMessageBox::No)
286 SUPERV_Graph aGraph = engine->StreamGraphE(f);
287 //QFileInfo aFile(f);
288 //aGraph->SetName(aFile.baseName());
289 if (SUPERV_isNull(aGraph)) {
290 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_BAD_FILE").arg(f));
294 QAD_StudyFrame* aStudyFrame = createGraph();
295 SUPERVGraph_ViewFrame* aViewFrame = dynamic_cast<SUPERVGraph_ViewFrame*>
296 (aStudyFrame->getRightFrame()->getViewFrame());
298 main = new SUPERVGUI_Main(aViewFrame, desktop, aGraph);
299 registerGraph(f, main);
300 study->showFrame(aStudyFrame);
305 void SUPERVGUI::displayDataflow() {
306 Trace("SUPERVGUI::displayDataflow");
307 QAD_ObjectBrowser* aBrowser = ((QAD_StudyFrame*)(desktop->getMainFrame()->activeWindow()))->getLeftFrame()->getObjectBrowser();
308 SUPERV_Graph aDataFlow;
311 QAD_ObjectBrowserItem* item = (QAD_ObjectBrowserItem*)(aBrowser->getListView()->currentItem());
312 SALOMEDS::SObject_var aObj = desktop->getActiveStudy()->getStudyDocument()->FindObjectID(item->getEntry().latin1());
313 SALOMEDS::GenericAttribute_var anAttr;
314 if (aObj->FindAttribute(anAttr, "AttributeIOR")) {
315 SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
316 Standard_CString ior = anIOR->Value();
318 if (isContains(study, aIORName)) {
319 if (QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"),
320 tr("MSG_GRAPH_DISPLAYED").arg(""),
321 QMessageBox::Yes, QMessageBox::No) == QMessageBox::No)
324 //aDataFlow = engine->getStreamGraph(ior);
325 aDataFlow = engine->getGraph(ior);
326 if (SUPERV_isNull(aDataFlow)) {
327 QMessageBox::warning(0, tr("ERROR"), tr("MSG_ACCESS_BAD_IOR"));
330 /* ASV: 20.10.04: fix for 6896
331 if (aDataFlow->IsStreamGraph()) {
332 SUPERV_StreamGraph aDataFlowStream = aDataFlow->ToStreamGraph();
333 if (SUPERV_isNull(aDataFlowStream)) {
334 QMessageBox::warning(0, tr("ERROR"), tr("MSG_ACCESS_BAD_IOR"));
337 aDataFlow = aDataFlowStream;
341 QAD_StudyFrame* aStudyFrame = createGraph();
342 SUPERVGraph_ViewFrame* aViewFrame = dynamic_cast<SUPERVGraph_ViewFrame*>
343 (aStudyFrame->getRightFrame()->getViewFrame());
345 main = new SUPERVGUI_Main(aViewFrame, desktop, aDataFlow);
346 main->setAsFromStudy(true);
347 registerGraph(aIORName, main);
348 study->showFrame(aStudyFrame);
353 void SUPERVGUI::renameDataflow() {
354 SALOME_Selection* Sel = SALOME_Selection::Selection( study->getSelection() );
355 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
356 for ( ; It.More(); It.Next() ) {
357 Handle(SALOME_InteractiveObject) IObject = It.Value();
359 SALOMEDS::Study_var aStudy = study->getStudyDocument();
360 SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() );
361 SALOMEDS::GenericAttribute_var anAttr;
362 SALOMEDS::AttributeName_var aName;
363 if ( !obj->_is_nil() ) {
364 if (obj->FindAttribute(anAttr, "AttributeName")) {
365 aName = SALOMEDS::AttributeName::_narrow(anAttr);
366 QString nm = QString( aName->Value() );
367 nm = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), nm );
368 if ( !nm.isEmpty() ) {
369 QApplication::setOverrideCursor( Qt::waitCursor );
370 study->renameIObject( IObject, nm );
371 QApplication::restoreOverrideCursor();
378 void SUPERVGUI::exportDataflow() {
379 Trace("SUPERVGUI::exportDataflow")
381 QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NOWINDOW_TO_EXPORT"));
383 else if ( SUPERV_isNull( main->getDataflow() ) ) { // should not normally happen..
384 QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NOWINDOW_TO_EXPORT"));
387 QString f = QAD_FileDlg::getFileName(QAD_Application::getDesktop(),
390 tr("TTL_EXPORT_DATAFLOW"),
392 if ( !f.isEmpty() ) {
394 // asv : bug [VSR Bugs and Improvements in Supervisor] 1.8 : when exporting a file,
395 // a backup copy of an existing file must be created (in case Export fails..)
396 QString aBackupFile = SUPERVGUI::createBackupFile( f );
398 if ( main->getDataflow()->Export(f.latin1()) ) {
399 unregisterGraph(main);
400 registerGraph(f, main);
402 // remove a backup file if export was successfull
403 if ( !aBackupFile.isNull() && !aBackupFile.isEmpty() )
404 QFile::remove( aBackupFile );
407 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_BAD_WRITING").arg(aBackupFile));
414 *If a file with theOriginalFileName exists, then the function tries to create
415 * its backup copy of it (the_name + ".bakX", X = 0,1,2,..,99). Returns backup file's name
416 * If a file with theOriginalFileName does not exist, or creation fails - Return empty string.
418 QString SUPERVGUI::createBackupFile( const QString& theOriginalFileName ) {
419 QString theBackupFileName("");
420 if ( QFile::exists( theOriginalFileName ) ) {
421 // 1. construct a backup file name
424 theBackupFileName = theOriginalFileName;
425 theBackupFileName += ".bak";
426 theBackupFileName += QString::number(i++);
428 while ( QFile::exists( theBackupFileName ) && i < 100 ); // max 99 backup files
429 // if *.bak99 exists -- it will be overwritten
431 // 2. copy the original file to theBackupFileName
432 QString cmd( "cp \"");
433 cmd += theOriginalFileName;
435 cmd += theBackupFileName;
437 bool res = system( cmd.latin1() );
439 theBackupFileName = QString("");
441 return theBackupFileName;
444 void SUPERVGUI::newDataflow() {
445 Trace("SUPERVGUI::editDataflow");
447 //asv 20.10.04: removed 2 SUPERVGUI_Main constructors. there is only ONE way
448 //to create a Main object now: with a non-null DataFlow as a 3d parameter
449 //1. create a Graph object
450 SUPERV_Graph aNewDataFlow = engine->StreamGraph( MAIN_NEW );
451 if (SUPERV_isNull( aNewDataFlow )) {
452 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_CREATE_DF"));
455 //2. create a ViewFrame object
456 QAD_StudyFrame* aStudyFrame = createGraph();
457 SUPERVGraph_ViewFrame* aViewFrame = dynamic_cast<SUPERVGraph_ViewFrame*>
458 (aStudyFrame->getRightFrame()->getViewFrame());
460 //3. bind Graph and ViewFrame -> create Main
461 main = new SUPERVGUI_Main(aViewFrame, desktop, aNewDataFlow );
463 study->showFrame(aStudyFrame);
467 void SUPERVGUI::modifyDataflow() {
468 Trace("SUPERVGUI::modifyDataflow")
469 QString f = QAD_FileDlg::getFileName(QAD_Application::getDesktop(),
472 tr("Modify Dataflow"),
475 if (isContains(study, f)) {
476 if (QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"),
477 tr("MSG_GRAPH_DISPLAYED").arg(f),
478 QMessageBox::Yes, QMessageBox::No) == QMessageBox::No)
482 SUPERV_Graph aGraph = engine->StreamGraph(f);
484 //aGraph->SetName(aFile.name());
485 if (SUPERV_isNull(aGraph)) {
486 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_BAD_FILE").arg(f));
490 QAD_StudyFrame* aStudyFrame = createGraph();
491 SUPERVGraph_ViewFrame* aViewFrame = dynamic_cast<SUPERVGraph_ViewFrame*>
492 (aStudyFrame->getRightFrame()->getViewFrame());
494 main = new SUPERVGUI_Main(aViewFrame, desktop, aGraph);
495 registerGraph(f, main);
496 study->showFrame(aStudyFrame);
501 void SUPERVGUI::reloadDataflow() {
502 Trace("SUPERVGUI::reloadDataflow")
504 QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NOWINDOW_TO_RELOAD"));
510 void SUPERVGUI::runDataflow() {
511 Trace("SUPERVGUI::runDataflow")
513 QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NOWINDOW_TO_RUN"));
519 void SUPERVGUI::stepByStep() {
520 Trace("SUPERVGUI::stepByStep")
522 QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NOWINDOW_TO_RUN"));
524 main->startExecute();
528 void SUPERVGUI::killDataflow() {
529 Trace("SUPERVGUI::killDataflow")
531 QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NOWINDOW_TO_KILL"));
537 void SUPERVGUI::suspendResumeDataflow() {
538 Trace("SUPERVGUI::suspendResumeDataflow")
540 QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NOWINDOW_TO_SUSPEND"));
542 main->suspendResume();
546 void SUPERVGUI::showComponents() {
547 Trace("SUPERVGUI::showComponents");
549 QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NOWINDOW_TO_ADD"));
551 if (main->isEditable())
554 QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NOTEDITABLE"));
559 bool SUPERVGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* popup, const QString& theContext, const QString& theParent, const QString& theObject) {
560 Trace("SUPERVGUI::customPopup");
561 Supervision.init(parent);
562 if(popup->count() > 3) {
563 // Temporary code: is to be deleted soon
564 popup->removeItem(QAD_Display_Popup_ID);
565 popup->removeItem(QAD_DisplayOnly_Popup_ID);
566 popup->removeItem(QAD_Erase_Popup_ID);
567 int id = popup->idAt(popup->count() - 1);
568 if (id < 0 && id != -1) popup->removeItem(id); // separator
569 // Temporary code end
571 SALOME_Selection* Sel = SALOME_Selection::Selection(study->getSelection() );
572 if ((Sel==NULL) || (Sel->IObjectCount() == 0)) return false;
574 if (Sel->IObjectCount() == 1) {
575 Handle(SALOME_InteractiveObject) anIObj = Sel->firstIObject();
577 // insert SUPERV-specific popup items here
579 bool isDataflow, ownObj;
580 whatIsSelected(anIObj, ownObj, isDataflow);
583 popup->insertItem(tr( "MSG_RENAME" ), this, SLOT(renameDataflow()));
584 popup->insertItem("Display", this, SLOT(displayDataflow()));
585 popup->insertSeparator();
588 popup->insertItem(tr("MSG_DELETE"), this, SLOT(deleteObject()));
590 if (Sel->IObjectCount() > 1) {
592 SALOME_ListIteratorOfListIO It_forCheckOwner(Sel->StoredIObjects());
593 for(;It_forCheckOwner.More();It_forCheckOwner.Next()) {
594 Handle(SALOME_InteractiveObject) anIObj = It_forCheckOwner.Value();
595 bool aIsOwner, aIsDataflow;
596 whatIsSelected(anIObj, aIsOwner, aIsDataflow);
598 if (aIsOwner) aIObjCount++;
600 if (aIObjCount == Sel->IObjectCount()) //all selected objects belong to Supervision
601 popup->insertItem(tr("MSG_DELETE"), this, SLOT(deleteObject()));
609 theIsOwner = true if Selected object belongs to Suipervision.
610 theIsDataflow = true if Selected object is Dataflow
612 void SUPERVGUI::whatIsSelected(const Handle(SALOME_InteractiveObject)& theObj, bool& theIsOwner, bool& theIsDataflow) {
614 theIsDataflow = false;
616 if (theObj.IsNull()) return;
618 SALOMEDS::Study_var aStudy = study->getStudyDocument();
619 SALOMEDS::SObject_var obj = aStudy->FindObjectID( theObj->getEntry() );
621 if ( !obj->_is_nil() ) {
622 SALOMEDS::SComponent_var comp = obj->GetFatherComponent();
623 if ( !comp->_is_nil() ) {
624 SALOMEDS::GenericAttribute_var anAttr;
625 SALOMEDS::AttributeName_var aName;
626 if (comp->FindAttribute(anAttr, "AttributeName")) {
627 aName = SALOMEDS::AttributeName::_narrow(anAttr);
628 QString compName(aName->Value());
629 //if (compName.compare(STUDY_SUPERVISION) == 0) {
630 if (compName.compare(QAD_Application::getDesktop()->getComponentUserName("SUPERV")) == 0) {
631 SALOMEDS::GenericAttribute_var anAttr;
632 if (obj->FindAttribute(anAttr, "AttributeIOR")) {
633 SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
634 //SUPERV_Graph aDataFlow = engine->getStreamGraph(anIOR->Value());
635 SUPERV_Graph aDataFlow = engine->getGraph(anIOR->Value());
636 if (!SUPERV_isNull(aDataFlow)) {
637 if (aDataFlow->IsStreamGraph()) {
638 if (!SUPERV_isNull(aDataFlow->ToStreamGraph()))
639 theIsDataflow = true;
642 theIsDataflow = true;
645 CORBA::String_var anObjectID = obj->GetID();
646 CORBA::String_var aComponentID = comp->GetID();
647 if (strcmp(anObjectID, aComponentID)) theIsOwner = true;
655 void SUPERVGUI::deleteObject() {
656 SALOME_Selection* Sel = SALOME_Selection::Selection(study->getSelection() );
657 if ((Sel==NULL) || (Sel->IObjectCount() == 0)) return;
659 if (QMessageBox::warning(QAD_Application::getDesktop(),
661 tr("MSG_ASK_DELETE"),
663 QMessageBox::Yes) == QMessageBox::No)
666 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
667 for(;It.More();It.Next()) {
668 Handle(SALOME_InteractiveObject) anIObj = It.Value();
669 bool aIsOwner, aIsDataflow;
670 whatIsSelected(anIObj, aIsOwner, aIsDataflow);
672 SALOMEDS::Study_var aStudy = study->getStudyDocument();
673 SALOMEDS::SObject_var aObj = aStudy->FindObjectID( anIObj->getEntry() );
674 if (!aObj->_is_nil()) {
676 SALOMEDS::GenericAttribute_var anAttr;
677 if (aObj->FindAttribute(anAttr, "AttributeIOR")) {
678 SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
679 QString ior = anIOR->Value();
681 SUPERVGUI_Main* aMain;
682 for (aMain = myGraphList.first(); aMain; aMain = myGraphList.next()) {
683 if ((aMain->getStudy() == study) && (aMain->getHashCode() == ior)) {
684 aMain->setAsFromStudy(false);
690 QAD_Operation* op = new SALOMEGUI_ImportOperation( study );
691 SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
693 aBuilder->RemoveObjectWithChildren(aObj);
697 Sel->ClearIObjects() ;
700 bool SUPERVGUI::OnGUIEvent(int command, QAD_Desktop* parent) {
701 Supervision.init(parent);
704 Supervision.importDataflow();
708 Supervision.exportDataflow();
712 Supervision.newDataflow();
716 Supervision.modifyDataflow();
720 Supervision.reloadDataflow();
724 Supervision.runDataflow();
728 Supervision.killDataflow();
732 Supervision.suspendResumeDataflow();
736 Supervision.showComponents();
740 Supervision.stepByStep();
744 QMessageBox::warning(QAD_Application::getDesktop(), "Supervision Error", "Unknown Command From Salome");
749 bool SUPERVGUI::SetSettings(QAD_Desktop* parent) {
750 Trace("SUPERVGUI::SetSettings");
751 Supervision.init(parent);
755 void SUPERVGUI::DefinePopup(QString& theContext, QString& theParent, QString& theObject) {
760 bool SUPERVGUI::ActiveStudyChanged(QAD_Desktop* parent) {
761 Trace("SUPERVGUI::activeStudyChanged");
762 study = desktop->getActiveStudy();
766 void SUPERVGUI::SupportedViewType (int* buffer, int bufferSize)
768 if (!buffer || !bufferSize) return;
769 buffer[0] = (int)VIEW_GRAPHSUPERV;
774 Standard_EXPORT SALOMEGUI* GetComponentGUI() {