1 // File: SalomeApp_Application.cxx
2 // Created: 10/22/2004 3:23:45 PM
3 // Author: Sergey LITONIN
4 // Copyright (C) CEA 2004
6 #include "SalomeApp_PyInterp.h" // WARNING! This include must be the first!
8 #include "SalomeApp_Application.h"
10 #include "SalomeApp_Study.h"
11 #include "SalomeApp_DataModel.h"
12 #include "SalomeApp_DataObject.h"
13 #include "SalomeApp_EventFilter.h"
15 #include "SalomeApp_StudyPropertiesDlg.h"
17 #include "SalomeApp_CheckFileDlg.h"
19 #include "LightApp_Application.h"
20 #include "LightApp_Preferences.h"
21 #include "LightApp_WidgetContainer.h"
22 #include "LightApp_SelectionMgr.h"
24 #include "STD_LoadStudiesDlg.h"
26 #include <SUIT_Tools.h>
27 #include <SUIT_Session.h>
29 #include <QtxMRUAction.h>
31 #include <OB_Browser.h>
32 #include <OB_ListItem.h>
34 #include <PythonConsole_PyConsole.h>
36 #include <SUIT_FileDlg.h>
37 #include <SUIT_MessageBox.h>
38 #include <SUIT_ResourceMgr.h>
39 #include <SUIT_ActionOperation.h>
41 #include <Utils_ORB_INIT.hxx>
42 #include <Utils_SINGLETON.hxx>
43 #include <SALOME_ModuleCatalog_impl.hxx>
44 #include <SALOME_LifeCycleCORBA.hxx>
48 #include <qcombobox.h>
52 #include "SALOMEDS_StudyManager.hxx"
53 #include "SALOMEDS_SObject.hxx"
55 #include "SALOME_ListIteratorOfListIO.hxx"
56 #include "SALOME_ListIO.hxx"
58 #include "ToolsGUI_CatalogGeneratorDlg.h"
59 #include "ToolsGUI_RegWidget.h"
61 /*!Create new instance of SalomeApp_Application.*/
62 extern "C" SALOMEAPP_EXPORT SUIT_Application* createApplication()
64 return new SalomeApp_Application();
68 Class : SalomeApp_Application
69 Description : Application containing SalomeApp module or LightApp module
73 SalomeApp_Application::SalomeApp_Application()
74 : LightApp_Application()
79 *\li Destroy event filter.
81 SalomeApp_Application::~SalomeApp_Application()
83 SalomeApp_EventFilter::Destroy();
86 /*!Start application.*/
87 void SalomeApp_Application::start()
89 LightApp_Application::start();
91 SalomeApp_EventFilter::Init();
95 void SalomeApp_Application::createActions()
97 LightApp_Application::createActions();
99 SUIT_Desktop* desk = desktop();
102 createAction( DumpStudyId, tr( "TOT_DESK_FILE_DUMP_STUDY" ), QIconSet(),
103 tr( "MEN_DESK_FILE_DUMP_STUDY" ), tr( "PRP_DESK_FILE_DUMP_STUDY" ),
104 0, desk, false, this, SLOT( onDumpStudy() ) );
107 createAction( LoadScriptId, tr( "TOT_DESK_FILE_LOAD_SCRIPT" ), QIconSet(),
108 tr( "MEN_DESK_FILE_LOAD_SCRIPT" ), tr( "PRP_DESK_FILE_LOAD_SCRIPT" ),
109 0, desk, false, this, SLOT( onLoadScript() ) );
112 createAction( PropertiesId, tr( "TOT_DESK_PROPERTIES" ), QIconSet(),
113 tr( "MEN_DESK_PROPERTIES" ), tr( "PRP_DESK_PROPERTIES" ),
114 0, desk, false, this, SLOT( onProperties() ) );
116 //! Catalog Generator
117 createAction( CatalogGenId, tr( "TOT_DESK_CATALOG_GENERATOR" ), QIconSet(),
118 tr( "MEN_DESK_CATALOG_GENERATOR" ), tr( "PRP_DESK_CATALOG_GENERATOR" ),
119 0, desk, false, this, SLOT( onCatalogGen() ) );
122 createAction( RegDisplayId, tr( "TOT_DESK_REGISTRY_DISPLAY" ), QIconSet(),
123 tr( "MEN_DESK_REGISTRY_DISPLAY" ), tr( "PRP_DESK_REGISTRY_DISPLAY" ),
124 0, desk, false, this, SLOT( onRegDisplay() ) );
126 int fileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1 );
128 createMenu( DumpStudyId, fileMenu, 10, -1 );
129 createMenu( separator(), fileMenu, -1, 15, -1 );
130 createMenu( LoadScriptId, fileMenu, 10, -1 );
131 createMenu( separator(), fileMenu, -1, 15, -1 );
132 createMenu( PropertiesId, fileMenu, 10, -1 );
133 createMenu( separator(), fileMenu, -1, 15, -1 );
135 int toolsMenu = createMenu( tr( "MEN_DESK_TOOLS" ), -1, -1, 50 );
136 createMenu( CatalogGenId, toolsMenu, 10, -1 );
137 createMenu( RegDisplayId, toolsMenu, 10, -1 );
138 createMenu( separator(), toolsMenu, -1, 15, -1 );
141 /*! Purpose : SLOT. Open new document with \a aName.*/
142 bool SalomeApp_Application::onOpenDoc( const QString& aName )
144 bool res = false, toOpen = true, isAlreadyOpen = false;
146 // Look among opened studies
147 if (activeStudy()) { // at least one study is opened
148 SUIT_Session* aSession = SUIT_Session::session();
149 QPtrList<SUIT_Application> aAppList = aSession->applications();
150 QPtrListIterator<SUIT_Application> it (aAppList);
151 SUIT_Application* aApp = 0;
152 // iterate on all applications
153 for (; (aApp = it.current()) && !isAlreadyOpen; ++it) {
154 if (aApp->activeStudy()->studyName() == aName) {
155 isAlreadyOpen = true; // Already opened, ask user what to do
157 // The document ... is already open.
158 // Do you want to reload it?
159 int aAnswer = SUIT_MessageBox::warn2(desktop(), tr("WRN_WARNING"),
160 tr("QUE_DOC_ALREADYOPEN").arg(aName),
161 tr("BUT_YES"), tr("BUT_NO"), 1, 2, 2);
162 if (aAnswer == 1) { // reload
163 if (activeStudy()->studyName() == aName && aAppList.count() > 1) {
164 // Opened in THIS (active) application.
165 STD_Application* app1 = (STD_Application*)aAppList.at(0);
166 STD_Application* app2 = (STD_Application*)aAppList.at(1);
167 if (!app1 || !app2) {
171 if (app1->activeStudy()->studyName() == aName) {
172 // app1 is this application, we need another one
175 // Close document of this application. This application will be destroyed.
176 onCloseDoc(/*ask = */false);
177 // Open the file with another application, as this one will be destroyed.
178 return app1->onOpenDoc(aName);
180 // Opened in another application.
181 STD_Application* app = (STD_Application*)aApp;
183 app->onCloseDoc(/*ask = */false);
185 } else { // do not reload
186 // OK, the study will not be reloaded, but we call
187 // CAM_Application::onOpenDoc( aName ) all the same.
188 // It will activate a desktop of the study <aName>.
194 // Look among unloaded studies
195 if (!isAlreadyOpen) {
196 std::vector<std::string> List = studyMgr()->GetOpenStudies();
199 for (unsigned int ind = 0; ind < List.size() && !isAlreadyOpen; ind++) {
200 studyName = List[ind].c_str();
201 if (aName == studyName) {
202 // Already exists unloaded, ask user what to do
203 isAlreadyOpen = true;
205 // The document ... already exists in the study manager.
206 // Do you want to reload it?
207 int aAnswer = SUIT_MessageBox::warn2(desktop(), tr("WRN_WARNING"),
208 tr("QUE_DOC_ALREADYEXIST").arg(aName),
209 tr("BUT_YES"), tr("BUT_NO"), 1, 2, 2);
211 _PTR(Study) aStudy = studyMgr()->GetStudyByName(aName.latin1());
213 studyMgr()->Close(aStudy);
222 res = CAM_Application::onOpenDoc( aName );
224 QAction* a = action( MRUId );
225 if ( a && a->inherits( "QtxMRUAction" ) )
227 QtxMRUAction* mru = (QtxMRUAction*)a;
229 mru->insert( aName );
231 mru->remove( aName );
236 /*!SLOT. Load document.*/
237 void SalomeApp_Application::onLoadDoc()
239 QString name, studyname, ext;
241 STD_LoadStudiesDlg aDlg( desktop(), TRUE);
243 std::vector<std::string> List = studyMgr()->GetOpenStudies();
245 SUIT_Session* aSession = SUIT_Session::session();
246 QPtrList<SUIT_Application> aAppList = aSession->applications();
247 SUIT_Application* aApp = 0;
249 for (unsigned int ind = 0; ind < List.size(); ind++) {
250 studyname = List[ind].c_str();
251 //Add to list only unloaded studies
252 bool isAlreadyOpen = false;
253 for ( QPtrListIterator<SUIT_Application> it( aAppList ); it.current() && !isAlreadyOpen; ++it )
256 if(!aApp || !aApp->activeStudy()) continue;
257 if ( aApp->activeStudy()->studyName() == studyname ) isAlreadyOpen = true;
260 if ( !isAlreadyOpen ) aDlg.ListComponent->insertItem( studyname );
263 int retVal = aDlg.exec();
264 studyname = aDlg.ListComponent->currentText();
266 if (retVal == QDialog::Rejected)
269 if ( studyname.isNull() || studyname.isEmpty() )
273 name.replace( QRegExp(":"), "/" );
275 if( LightApp_Application::onLoadDoc( name ) )
278 updateViewManagers();
279 updateObjectBrowser(true);
284 /*!SLOT. Load document with \a aName.*/
285 bool SalomeApp_Application::onLoadDoc( const QString& aName )
287 return LightApp_Application::onLoadDoc( aName );
290 /*!SLOT. Copy objects to study maneger from selection maneger..*/
291 void SalomeApp_Application::onCopy()
294 LightApp_SelectionMgr* mgr = selectionMgr();
295 mgr->selectedObjects(list);
297 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(activeStudy());
298 if(study == NULL) return;
300 _PTR(Study) stdDS = study->studyDS();
303 SALOME_ListIteratorOfListIO it( list );
306 _PTR(SObject) so = stdDS->FindObjectID(it.Value()->getEntry());
308 studyMgr()->Copy(so);
309 onSelectionChanged();
316 /*!SLOT. Paste objects to study maneger from selection manager.*/
317 void SalomeApp_Application::onPaste()
320 LightApp_SelectionMgr* mgr = selectionMgr();
321 mgr->selectedObjects(list);
323 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(activeStudy());
324 if(study == NULL) return;
326 _PTR(Study) stdDS = study->studyDS();
329 SALOME_ListIteratorOfListIO it( list );
332 _PTR(SObject) so = stdDS->FindObjectID(it.Value()->getEntry());
334 studyMgr()->Paste(so);
335 updateObjectBrowser( true );
336 updateActions(); //SRN: BugID IPAL9377, case 3
343 /*!Sets enable or disable some actions on selection changed.*/
344 void SalomeApp_Application::onSelectionChanged()
347 LightApp_SelectionMgr* mgr = selectionMgr();
348 mgr->selectedObjects(list);
350 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(activeStudy());
351 if(study == NULL) return;
353 _PTR(Study) stdDS = study->studyDS();
358 SALOME_ListIteratorOfListIO it( list );
359 if(it.More() && list.Extent() == 1)
361 _PTR(SObject) so = stdDS->FindObjectID(it.Value()->getEntry());
363 qaction = action(EditCopyId);
365 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(so.get());
366 if ( aSO && studyMgr()->CanCopy(so) ) qaction->setEnabled(true);
367 else qaction->setEnabled(false);
369 else qaction->setEnabled(false);
371 qaction = action(EditPasteId);
373 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(so.get());
374 if( aSO && studyMgr()->CanPaste(so) ) qaction->setEnabled(true);
375 qaction->setEnabled(false);
377 else qaction->setEnabled(false);
380 qaction = action(EditCopyId);
381 qaction->setEnabled(false);
382 qaction = action(EditPasteId);
383 qaction->setEnabled(false);
387 /*!Delete references.*/
388 void SalomeApp_Application::onDeleteReferences()
391 LightApp_SelectionMgr* mgr = selectionMgr();
392 mgr->selectedObjects(aList);
394 if (aList.Extent() < 1) return;
396 SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(activeStudy());
397 _PTR(Study) aStudyDS = aStudy->studyDS();
398 _PTR(StudyBuilder) aStudyBuilder = aStudyDS->NewBuilder();
401 for ( SALOME_ListIteratorOfListIO it( aList ); it.More(); it.Next() )
403 if ( it.Value()->hasEntry() )
405 _PTR(SObject) aSObject = aStudyDS->FindObjectID( it.Value()->getEntry() );
406 if ( aSObject->ReferencedObject(anObj) )
407 aStudyBuilder->RemoveReference(aSObject);
411 updateObjectBrowser();
415 void SalomeApp_Application::onOpenWith()
417 QApplication::setOverrideCursor( Qt::waitCursor );
419 LightApp_SelectionMgr* mgr = selectionMgr();
420 mgr->selectedObjects(aList);
421 if (aList.Extent() != 1)
423 QApplication::restoreOverrideCursor();
426 Handle(SALOME_InteractiveObject) aIObj = aList.First();
427 QString aModuleName(aIObj->getComponentDataType());
428 QString aModuleTitle = moduleTitle(aModuleName);
429 activateModule(aModuleTitle);
430 QApplication::restoreOverrideCursor();
433 //=======================================================================
434 // name : createNewStudy
435 /*! Purpose : Create new study*/
436 //=======================================================================
437 SUIT_Study* SalomeApp_Application::createNewStudy()
439 SalomeApp_Study* aStudy = new SalomeApp_Study( this );
441 // Set up processing of major study-related events
442 connect( aStudy, SIGNAL( created( SUIT_Study* ) ), this, SLOT( onStudyCreated( SUIT_Study* ) ) );
443 connect( aStudy, SIGNAL( opened ( SUIT_Study* ) ), this, SLOT( onStudyOpened ( SUIT_Study* ) ) );
444 connect( aStudy, SIGNAL( saved ( SUIT_Study* ) ), this, SLOT( onStudySaved ( SUIT_Study* ) ) );
445 connect( aStudy, SIGNAL( closed ( SUIT_Study* ) ), this, SLOT( onStudyClosed ( SUIT_Study* ) ) );
450 //=======================================================================
451 // name : updateCommandsStatus
452 /*! Purpose : Enable/Disable menu items and toolbar buttons. Rebuild menu*/
453 //=======================================================================
454 void SalomeApp_Application::updateCommandsStatus()
456 LightApp_Application::updateCommandsStatus();
459 QAction* a = action( DumpStudyId );
461 a->setEnabled( activeStudy() );
464 a = action( LoadScriptId );
466 a->setEnabled( activeStudy() );
468 a = action( PropertiesId );
470 a->setEnabled( activeStudy() );
472 a = action(EditCopyId);
473 a->setEnabled(false);
474 a = action(EditPasteId);
475 a->setEnabled(false);
478 /*!Private SLOT. On dump study.*/
479 void SalomeApp_Application::onDumpStudy( )
481 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( activeStudy() );
482 if ( !appStudy ) return;
483 _PTR(Study) aStudy = appStudy->studyDS();
485 QStringList aFilters;
486 aFilters.append( tr( "PYTHON_FILES_FILTER" ) );
488 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg( desktop(), false, tr("PUBLISH_IN_STUDY"), true, true);
489 fd->setCaption( tr( "TOT_DESK_FILE_DUMP_STUDY" ) );
490 fd->setFilters( aFilters );
491 fd->SetChecked(true);
493 QString aFileName = fd->selectedFile();
494 bool toPublish = fd->IsChecked();
497 if(!aFileName.isEmpty()) {
498 QFileInfo aFileInfo(aFileName);
499 aStudy->DumpStudy( aFileInfo.dirPath( true ).latin1(), aFileInfo.baseName().latin1(), toPublish );
503 /*!Private SLOT. On load script.*/
504 void SalomeApp_Application::onLoadScript( )
506 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( activeStudy() );
507 if ( !appStudy ) return;
508 _PTR(Study) aStudy = appStudy->studyDS();
510 if ( aStudy->GetProperties()->IsLocked() ) {
511 SUIT_MessageBox::warn1 ( desktop(),
512 QObject::tr("WRN_WARNING"),
513 QObject::tr("WRN_STUDY_LOCKED"),
514 QObject::tr("BUT_OK") );
518 QStringList filtersList;
519 filtersList.append(tr("PYTHON_FILES_FILTER"));
520 filtersList.append(tr("ALL_FILES_FILTER"));
522 QString aFile = SUIT_FileDlg::getFileName( desktop(), "", filtersList, tr( "TOT_DESK_FILE_LOAD_SCRIPT" ), true, true );
524 if ( !aFile.isEmpty() )
526 QString command = QString("execfile(\"%1\")").arg(aFile);
528 PythonConsole* pyConsole = pythonConsole();
531 pyConsole->exec( command );
536 *\retval QString "(*.hdf)"
538 QString SalomeApp_Application::getFileFilter() const
544 QWidget* SalomeApp_Application::createWindow( const int flag )
546 QWidget* wid = LightApp_Application::createWindow(flag);
548 SUIT_ResourceMgr* resMgr = resourceMgr();
550 if ( flag == WT_ObjectBrowser )
552 OB_Browser* ob = (OB_Browser*)wid;
553 connect( ob->listView(), SIGNAL( doubleClicked( QListViewItem* ) ), this, SLOT( onDblClick( QListViewItem* ) ) );
554 bool autoSize = resMgr->booleanValue( "ObjectBrowser", "auto_size", false );
555 for ( int i = SalomeApp_DataObject::CT_Value; i <= SalomeApp_DataObject::CT_RefEntry; i++ )
557 ob->addColumn( tr( QString().sprintf( "OBJ_BROWSER_COLUMN_%d", i ) ), i );
558 ob->setColumnShown( i, resMgr->booleanValue( "ObjectBrowser",
559 QString().sprintf( "visibility_column_%d", i ), true ) );
561 ob->setWidthMode( autoSize ? QListView::Maximum : QListView::Manual );
563 else if ( flag == WT_PyConsole )
567 PythonConsole* pyCons = new PythonConsole( desktop(), new SalomeApp_PyInterp() );
568 pyCons->setCaption( tr( "PYTHON_CONSOLE" ) );
570 // pyCons->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
575 /*!Create preferences.*/
576 void SalomeApp_Application::createPreferences( LightApp_Preferences* pref )
578 LightApp_Application::createPreferences(pref);
583 int salomeCat = pref->addPreference( tr( "PREF_CATEGORY_SALOME" ) );
584 int obTab = pref->addPreference( tr( "PREF_TAB_OBJBROWSER" ), salomeCat );
585 int defCols = pref->addPreference( tr( "PREF_GROUP_DEF_COLUMNS" ), obTab );
586 for ( int i = SalomeApp_DataObject::CT_Value; i <= SalomeApp_DataObject::CT_RefEntry; i++ )
588 pref->addPreference( tr( QString().sprintf( "OBJ_BROWSER_COLUMN_%d", i ) ), defCols,
589 LightApp_Preferences::Bool, "ObjectBrowser", QString().sprintf( "visibility_column_%d", i ) );
591 pref->setItemProperty( defCols, "columns", 1 );
593 int objSetGroup = pref->addPreference( tr( "PREF_OBJ_BROWSER_SETTINGS" ), obTab );
594 pref->addPreference( tr( "PREF_AUTO_SIZE" ), objSetGroup, LightApp_Preferences::Bool, "ObjectBrowser", "auto_size" );
597 /*!Update desktop title.*/
598 void SalomeApp_Application::updateDesktopTitle() {
599 QString aTitle = applicationName();
600 QString aVer = applicationVersion();
601 if ( !aVer.isEmpty() )
602 aTitle += QString( " " ) + aVer;
606 QString sName = SUIT_Tools::file( activeStudy()->studyName().stripWhiteSpace(), false );
607 if ( !sName.isEmpty() ) {
608 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(activeStudy());
610 _PTR(Study) stdDS = study->studyDS();
612 if ( stdDS->GetProperties()->IsLocked() ) {
613 aTitle += QString( " - [%1 (%2)]").arg( sName ).arg( tr( "STUDY_LOCKED" ) );
615 aTitle += QString( " - [%1]" ).arg( sName );
622 desktop()->setCaption( aTitle );
625 /*!Gets CORBA::ORB_var*/
626 CORBA::ORB_var SalomeApp_Application::orb()
628 ORB_INIT& init = *SINGLETON_<ORB_INIT>::Instance();
629 static CORBA::ORB_var _orb = init( qApp->argc(), qApp->argv() );
633 /*!Create and return SALOMEDS_StudyManager.*/
634 SALOMEDSClient_StudyManager* SalomeApp_Application::studyMgr()
636 static SALOMEDSClient_StudyManager* _sm = new SALOMEDS_StudyManager();
640 /*!Create and return SALOME_NamingService.*/
641 SALOME_NamingService* SalomeApp_Application::namingService()
643 static SALOME_NamingService* _ns = new SALOME_NamingService( orb() );
647 /*!Create and return SALOME_LifeCycleCORBA.*/
648 SALOME_LifeCycleCORBA* SalomeApp_Application::lcc()
650 static SALOME_LifeCycleCORBA* _lcc = new SALOME_LifeCycleCORBA( namingService() );
654 /*!Return default engine IOR for light modules*/
655 QString SalomeApp_Application::defaultEngineIOR()
657 /// Look for a default module engine (needed for CORBAless modules to use SALOMEDS persistence)
659 CORBA::Object_ptr anEngine = namingService()->Resolve( "/SalomeAppEngine" );
660 if ( !CORBA::is_nil( anEngine ) )
661 anIOR = orb()->object_to_string( anEngine );
665 /*!Private SLOT. On preferences.*/
666 void SalomeApp_Application::onProperties()
668 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( activeStudy() );
672 _PTR(StudyBuilder) SB = study->studyDS()->NewBuilder();
675 SalomeApp_StudyPropertiesDlg aDlg( desktop() );
676 int res = aDlg.exec();
677 if( res==QDialog::Accepted && aDlg.isChanged() )
682 //study->updateCaptions();
683 updateDesktopTitle();
687 /*!Insert items in popup, which necessary for current application*/
688 void SalomeApp_Application::contextMenuPopup( const QString& type, QPopupMenu* thePopup, QString& title )
690 LightApp_Application::contextMenuPopup( type, thePopup, title );
692 OB_Browser* ob = objectBrowser();
693 if ( !ob || type != ob->popupClientType() )
696 // Get selected objects
698 LightApp_SelectionMgr* mgr = selectionMgr();
699 mgr->selectedObjects(aList);
701 // "Delete reference" item should appear only for invalid references
703 // Check if selected objects is invalid references
704 bool isInvalidRefs = true;
706 if ( aList.Extent() < 1 )
707 isInvalidRefs = false;
711 SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(activeStudy());
712 _PTR(Study) aStudyDS = aStudy->studyDS();
715 for ( SALOME_ListIteratorOfListIO it( aList ); it.More() && isInvalidRefs; it.Next() )
717 if ( it.Value()->hasEntry() )
719 _PTR(SObject) aSObject = aStudyDS->FindObjectID( it.Value()->getEntry() );
720 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(aSObject.get());
722 if ( aSObject->ReferencedObject(anObj) == false || !QString(anObj->GetName().c_str()).isEmpty() )
723 isInvalidRefs = false;
728 // Add "Delete refrence" item to popup
731 thePopup->insertSeparator();
732 thePopup->insertItem( tr( "MEN_DELETE_REFERENCE" ), this, SLOT( onDeleteReferences() ) );
736 // "Activate module" item should appear only if it's necessary
737 if (aList.Extent() != 1)
739 Handle(SALOME_InteractiveObject) aIObj = aList.First();
740 QString aModuleName(aIObj->getComponentDataType());
741 QString aModuleTitle = moduleTitle(aModuleName);
742 CAM_Module* currentModule = activeModule();
743 if (currentModule && currentModule->moduleName() == aModuleTitle)
745 thePopup->insertItem( tr( "MEN_OPENWITH" ), this, SLOT( onOpenWith() ) );
749 /*!Update obect browser:
750 1.if 'updateModels' true, update existing data models;
751 2. update "non-existing" (not loaded yet) data models;
752 3. update object browser if it existing */
753 void SalomeApp_Application::updateObjectBrowser( const bool updateModels )
755 // update existing data models (already loaded SComponents)
756 LightApp_Application::updateObjectBrowser(updateModels);
758 // update "non-existing" (not loaded yet) data models
759 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(activeStudy());
762 _PTR(Study) stdDS = study->studyDS();
765 for ( _PTR(SComponentIterator) it ( stdDS->NewComponentIterator() ); it->More(); it->Next() )
767 _PTR(SComponent) aComponent ( it->Value() );
769 if ( aComponent->ComponentDataType() == "Interface Applicative" )
770 continue; // skip the magic "Interface Applicative" component
772 SalomeApp_DataModel::BuildTree( aComponent, study->root(), study, /*skipExisitng=*/true );
777 if ( objectBrowser() )
779 objectBrowser()->updateGeometry();
780 objectBrowser()->updateTree();
784 /*!Display Catalog Genenerator dialog */
785 void SalomeApp_Application::onCatalogGen()
787 ToolsGUI_CatalogGeneratorDlg aDlg( desktop() );
791 /*!Display Registry Display dialog */
792 void SalomeApp_Application::onRegDisplay()
794 CORBA::ORB_var anOrb = orb();
795 ToolsGUI_RegWidget* regWnd = ToolsGUI_RegWidget::GetRegWidget( anOrb, desktop(), "Registry" );
798 regWnd->setActiveWindow();
801 /*!find original object by double click on item */
802 void SalomeApp_Application::onDblClick( QListViewItem* it )
804 OB_ListItem* item = dynamic_cast<OB_ListItem*>( it );
805 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( activeStudy() );
809 SalomeApp_DataObject* obj = dynamic_cast<SalomeApp_DataObject*>( item->dataObject() );
813 QString entry = obj->entry();
814 _PTR(SObject) sobj = study->studyDS()->FindObjectID( entry.latin1() ), ref;
816 if( sobj && sobj->ReferencedObject( ref ) )
818 entry = ref->GetID();
819 QListViewItemIterator anIt( item->listView() );
820 for( ; anIt.current(); anIt++ )
822 OB_ListItem* item = dynamic_cast<OB_ListItem*>( anIt.current() );
826 SalomeApp_DataObject* original = dynamic_cast<SalomeApp_DataObject*>( item->dataObject() );
827 if( original->entry()!=entry )
830 OB_Browser* br = objectBrowser();
831 br->setSelected( original );
832 SUIT_DataObject* p = original->parent();