#include "SalomeApp_Application.h"
#include "SalomeApp_Study.h"
-#include "SalomeApp_Module.h"
-#include "SalomeApp_GLSelector.h"
-#include "SalomeApp_OBSelector.h"
-#include "SalomeApp_OCCSelector.h"
-#include "SalomeApp_VTKSelector.h"
+#include "SalomeApp_DataModel.h"
+#include "SalomeApp_DataObject.h"
#include "SalomeApp_EventFilter.h"
-#include "SalomeApp_SelectionMgr.h"
-#include "SalomeApp_EventFilter.h"
-#include "SalomeApp_WidgetContainer.h"
-#include "SalomeApp_ModuleDlg.h"
-#include "SalomeApp_OBFilter.h"
-
-#include <LogWindow.h>
-
-#include <GLViewer_Viewer.h>
-#include <GLViewer_ViewManager.h>
-#include <Plot2d_ViewManager.h>
+#include "SalomeApp_StudyPropertiesDlg.h"
-#include <OCCViewer_ViewManager.h>
-#include <SOCC_ViewModel.h>
+#include "SalomeApp_CheckFileDlg.h"
-#include <SVTK_ViewModel.h>
-#include <SVTK_ViewManager.h>
+#include "LightApp_Application.h"
+#include "LightApp_Preferences.h"
+#include "LightApp_WidgetContainer.h"
+#include "LightApp_SelectionMgr.h"
-#include <STD_TabDesktop.h>
+#include "STD_LoadStudiesDlg.h"
#include <SUIT_Tools.h>
#include <SUIT_Session.h>
-#include <QtxToolBar.h>
-#include <QtxDockAction.h>
+#include <QtxMRUAction.h>
#include <OB_Browser.h>
+#include <OB_ListItem.h>
#include <PythonConsole_PyConsole.h>
+#include <SUIT_FileDlg.h>
#include <SUIT_MessageBox.h>
#include <SUIT_ResourceMgr.h>
#include <SUIT_ActionOperation.h>
#include <Utils_ORB_INIT.hxx>
#include <Utils_SINGLETON.hxx>
#include <SALOME_ModuleCatalog_impl.hxx>
+#include <SALOME_LifeCycleCORBA.hxx>
#include <qmap.h>
-#include <qlabel.h>
-#include <qimage.h>
#include <qaction.h>
-#include <qmenubar.h>
#include <qcombobox.h>
-#include <qmessagebox.h>
-#include <qapplication.h>
+#include <qlistbox.h>
+#include <qregexp.h>
#include "SALOMEDS_StudyManager.hxx"
+#include "SALOMEDS_SObject.hxx"
-#define OBJECT_BROWSER_WIDTH 300
-
-static const char* imageEmptyIcon[] = {
-"20 20 1 1",
-". c None",
-"....................",
-"....................",
-"....................",
-"....................",
-"....................",
-"....................",
-"....................",
-"....................",
-"....................",
-"....................",
-"....................",
-"....................",
-"....................",
-"....................",
-"....................",
-"....................",
-"....................",
-"....................",
-"....................",
-"...................."};
+#include "SALOME_ListIteratorOfListIO.hxx"
+#include "SALOME_ListIO.hxx"
+#include "ToolsGUI_CatalogGeneratorDlg.h"
+#include "ToolsGUI_RegWidget.h"
+
+/*!Create new instance of SalomeApp_Application.*/
extern "C" SALOMEAPP_EXPORT SUIT_Application* createApplication()
{
return new SalomeApp_Application();
/*
Class : SalomeApp_Application
- Description : Application containing SalomeApp module
+ Description : Application containing SalomeApp module or LightApp module
*/
+/*!Constructor.*/
SalomeApp_Application::SalomeApp_Application()
-: CAM_Application( false )
+: LightApp_Application()
{
- STD_TabDesktop* desk = new STD_TabDesktop();
-
- setDesktop( desk );
-
- SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
- QPixmap aLogo = aResMgr->loadPixmap( "SalomeApp", tr( "APP_DEFAULT_ICO" ) );
-
- desktop()->setIcon( aLogo );
- desktop()->setDockableMenuBar( true );
- desktop()->setDockableStatusBar( false );
-
- clearViewManagers();
-
- mySelMgr = new SalomeApp_SelectionMgr( this );
-
- connect( desk, SIGNAL( closing( SUIT_Desktop*, QCloseEvent* ) ),
- this, SLOT( onDesktopClosing( SUIT_Desktop*, QCloseEvent* ) ) );
-
- connect( mySelMgr, SIGNAL( selectionChanged() ), this, SLOT( onSelection() ) );
}
+/*!Destructor.
+ *\li Destroy event filter.
+ */
SalomeApp_Application::~SalomeApp_Application()
{
- saveWindowsGeometry();
-
- if ( resourceMgr() )
- {
- if ( desktop() )
- desktop()->saveGeometry( resourceMgr(), "desktop" );
- resourceMgr()->save();
- }
-
- delete mySelMgr;
-
- SalomeApp_EventFilter::Destroy();
+ // Do not destroy. It's a singleton !
+ //SalomeApp_EventFilter::Destroy();
}
+/*!Start application.*/
void SalomeApp_Application::start()
{
- if ( desktop() )
- desktop()->loadGeometry( resourceMgr(), "desktop" );
-
- CAM_Application::start();
-
- QAction* a = action( ViewWindowsId );
- if ( a && a->inherits( "QtxDockAction" ) )
- ((QtxDockAction*)a)->setAutoPlace( true );
+ LightApp_Application::start();
SalomeApp_EventFilter::Init();
-
- updateWindows();
- updateViewManagers();
-
- putInfo( "" );
-}
-
-QString SalomeApp_Application::applicationName() const
-{
- return "SalomeApp";
-}
-
-CAM_Module* SalomeApp_Application::loadModule( const QString& name )
-{
- CAM_Module* mod = CAM_Application::loadModule( name );
- if ( mod )
- {
- connect( this, SIGNAL( studyOpened() ), mod, SLOT( onModelOpened() ) );
- connect( this, SIGNAL( studySaved() ), mod, SLOT( onModelSaved() ) );
- connect( this, SIGNAL( studyClosed() ), mod, SLOT( onModelClosed() ) );
- }
- return mod;
-}
-
-bool SalomeApp_Application::activateModule( const QString& modName )
-{
- QString actName;
- CAM_Module* prevMod = activeModule();
-
- if ( prevMod )
- actName = prevMod->moduleName();
-
- if ( actName == modName )
- return true;
-
- saveWindowsGeometry();
-
- bool status = CAM_Application::activateModule( modName );
-
- updateModuleActions();
-
- if ( !status )
- return false;
-
- updateWindows();
- updateViewManagers();
-
- return true;
-}
-
-SalomeApp_SelectionMgr* SalomeApp_Application::selectionMgr() const
-{
- return mySelMgr;
}
+/*!Create actions:*/
void SalomeApp_Application::createActions()
{
- STD_Application::createActions();
+ LightApp_Application::createActions();
SUIT_Desktop* desk = desktop();
- SUIT_ResourceMgr* resMgr = resourceMgr();
-
- // default icon for neutral point ('SALOME' module)
- QPixmap defIcon = resMgr->loadPixmap( "SalomeApp", tr( "APP_DEFAULT_ICO" ) );
- if ( defIcon.isNull() )
- defIcon = QPixmap( imageEmptyIcon );
-
- // default icon for any module
- QPixmap modIcon = resMgr->loadPixmap( "SalomeApp", tr( "APP_MODULE_ICO" ) );
- if ( modIcon.isNull() )
- modIcon = QPixmap( imageEmptyIcon );
-
- QToolBar* modTBar = new QtxToolBar( true, desk );
- modTBar->setLabel( tr( "INF_TOOLBAR_MODULES" ) );
-
- QActionGroup* modGroup = new QActionGroup( this );
- modGroup->setExclusive( true );
- modGroup->setUsesDropDown( true );
-
- QAction* a = createAction( -1, tr( "APP_NAME" ), defIcon, tr( "APP_NAME" ),
- tr( "PRP_APP_MODULE" ), 0, desk, true );
- modGroup->add( a );
- myActions.insert( QString(), a );
-
- QMap<QString, QString> iconMap;
- moduleIconNames( iconMap );
-
- const int iconSize = 20;
+
+ //! Dump study
+ createAction( DumpStudyId, tr( "TOT_DESK_FILE_DUMP_STUDY" ), QIconSet(),
+ tr( "MEN_DESK_FILE_DUMP_STUDY" ), tr( "PRP_DESK_FILE_DUMP_STUDY" ),
+ CTRL+Key_D, desk, false, this, SLOT( onDumpStudy() ) );
+
+ //! Load script
+ createAction( LoadScriptId, tr( "TOT_DESK_FILE_LOAD_SCRIPT" ), QIconSet(),
+ tr( "MEN_DESK_FILE_LOAD_SCRIPT" ), tr( "PRP_DESK_FILE_LOAD_SCRIPT" ),
+ CTRL+Key_T, desk, false, this, SLOT( onLoadScript() ) );
+
+ //! Properties
+ createAction( PropertiesId, tr( "TOT_DESK_PROPERTIES" ), QIconSet(),
+ tr( "MEN_DESK_PROPERTIES" ), tr( "PRP_DESK_PROPERTIES" ),
+ CTRL+Key_P, desk, false, this, SLOT( onProperties() ) );
+
+ //! Catalog Generator
+ createAction( CatalogGenId, tr( "TOT_DESK_CATALOG_GENERATOR" ), QIconSet(),
+ tr( "MEN_DESK_CATALOG_GENERATOR" ), tr( "PRP_DESK_CATALOG_GENERATOR" ),
+ SHIFT+Key_G, desk, false, this, SLOT( onCatalogGen() ) );
+
+ //! Registry Display
+ createAction( RegDisplayId, tr( "TOT_DESK_REGISTRY_DISPLAY" ), QIconSet(),
+ tr( "MEN_DESK_REGISTRY_DISPLAY" ), tr( "PRP_DESK_REGISTRY_DISPLAY" ),
+ SHIFT+Key_D, desk, false, this, SLOT( onRegDisplay() ) );
+
+ int fileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1 );
+
+ createMenu( DumpStudyId, fileMenu, 10, -1 );
+ createMenu( separator(), fileMenu, -1, 15, -1 );
+ createMenu( LoadScriptId, fileMenu, 10, -1 );
+ createMenu( separator(), fileMenu, -1, 15, -1 );
+ createMenu( PropertiesId, fileMenu, 10, -1 );
+ createMenu( separator(), fileMenu, -1, 15, -1 );
+
+ int toolsMenu = createMenu( tr( "MEN_DESK_TOOLS" ), -1, -1, 50 );
+ createMenu( CatalogGenId, toolsMenu, 10, -1 );
+ createMenu( RegDisplayId, toolsMenu, 10, -1 );
+ createMenu( separator(), toolsMenu, -1, 15, -1 );
+}
+
+/*! Purpose : SLOT. Open new document with \a aName.*/
+bool SalomeApp_Application::onOpenDoc( const QString& aName )
+{
+ bool res = false, toOpen = true, isAlreadyOpen = false;
+
+ // Look among opened studies
+ if (activeStudy()) { // at least one study is opened
+ SUIT_Session* aSession = SUIT_Session::session();
+ QPtrList<SUIT_Application> aAppList = aSession->applications();
+ QPtrListIterator<SUIT_Application> it (aAppList);
+ SUIT_Application* aApp = 0;
+ // iterate on all applications
+ for (; (aApp = it.current()) && !isAlreadyOpen; ++it) {
+ if (aApp->activeStudy()->studyName() == aName) {
+ isAlreadyOpen = true; // Already opened, ask user what to do
+
+ // The document ... is already open.
+ // Do you want to reload it?
+ int aAnswer = SUIT_MessageBox::warn2(desktop(), tr("WRN_WARNING"),
+ tr("QUE_DOC_ALREADYOPEN").arg(aName),
+ tr("BUT_YES"), tr("BUT_NO"), 1, 2, 2);
+ if (aAnswer == 1) { // reload
+ if (activeStudy()->studyName() == aName && aAppList.count() > 1) {
+ // Opened in THIS (active) application.
+ STD_Application* app1 = (STD_Application*)aAppList.at(0);
+ STD_Application* app2 = (STD_Application*)aAppList.at(1);
+ if (!app1 || !app2) {
+ // Error
+ return false;
+ }
+ if (app1->activeStudy()->studyName() == aName) {
+ // app1 is this application, we need another one
+ app1 = app2;
+ }
+ // Close document of this application. This application will be destroyed.
+ onCloseDoc(/*ask = */false);
+ // Open the file with another application, as this one will be destroyed.
+ return app1->onOpenDoc(aName);
+ } else {
+ // Opened in another application.
+ STD_Application* app = (STD_Application*)aApp;
+ if (app)
+ app->onCloseDoc(/*ask = */false);
+ }
+ } else { // do not reload
+ // OK, the study will not be reloaded, but we call
+ // CAM_Application::onOpenDoc( aName ) all the same.
+ // It will activate a desktop of the study <aName>.
+ }
+ }
+ }
+ }
- modGroup->addTo( modTBar );
- modTBar->addSeparator();
+ // Look among unloaded studies
+ if (!isAlreadyOpen) {
+ std::vector<std::string> List = studyMgr()->GetOpenStudies();
+
+ QString studyName;
+ for (unsigned int ind = 0; ind < List.size() && !isAlreadyOpen; ind++) {
+ studyName = List[ind].c_str();
+ if (aName == studyName) {
+ // Already exists unloaded, ask user what to do
+ isAlreadyOpen = true;
+
+ // The document ... already exists in the study manager.
+ // Do you want to reload it?
+ int aAnswer = SUIT_MessageBox::warn2(desktop(), tr("WRN_WARNING"),
+ tr("QUE_DOC_ALREADYEXIST").arg(aName),
+ tr("BUT_YES"), tr("BUT_NO"), 1, 2, 2);
+ if (aAnswer == 1) {
+ _PTR(Study) aStudy = studyMgr()->GetStudyByName(aName.latin1());
+ if (aStudy)
+ studyMgr()->Close(aStudy);
+ } else {
+ toOpen = false;
+ }
+ }
+ }
+ }
- QStringList modList;
- modules( modList, false );
+ if (toOpen)
+ res = CAM_Application::onOpenDoc( aName );
- for ( QStringList::Iterator it = modList.begin(); it != modList.end(); ++it )
+ QAction* a = action( MRUId );
+ if ( a && a->inherits( "QtxMRUAction" ) )
{
- if ( (*it).isEmpty() )
- continue;
+ QtxMRUAction* mru = (QtxMRUAction*)a;
+ if ( res )
+ mru->insert( aName );
+ else
+ mru->remove( aName );
+ }
+ return res;
+}
- QString iconName;
- if ( iconMap.contains( *it ) )
- iconName = iconMap[*it];
+/*!SLOT. Load document.*/
+void SalomeApp_Application::onLoadDoc()
+{
+ QString name, studyname, ext;
- QString modName = moduleName( *it );
+ STD_LoadStudiesDlg aDlg( desktop(), TRUE);
- QPixmap icon = resMgr->loadPixmap( modName, iconName );
- if ( icon.isNull() )
- icon = modIcon;
+ std::vector<std::string> List = studyMgr()->GetOpenStudies();
- icon.convertFromImage( icon.convertToImage().smoothScale( iconSize, iconSize, QImage::ScaleMin ) );
+ SUIT_Session* aSession = SUIT_Session::session();
+ QPtrList<SUIT_Application> aAppList = aSession->applications();
+ SUIT_Application* aApp = 0;
- QAction* a = createAction( -1, *it, icon, *it, tr( "PRP_MODULE" ).arg( *it ), 0, desk, true );
- a->addTo( modTBar );
- modGroup->add( a );
+ for (unsigned int ind = 0; ind < List.size(); ind++) {
+ studyname = List[ind].c_str();
+ //Add to list only unloaded studies
+ bool isAlreadyOpen = false;
+ for ( QPtrListIterator<SUIT_Application> it( aAppList ); it.current() && !isAlreadyOpen; ++it )
+ {
+ aApp = it.current();
+ if(!aApp || !aApp->activeStudy()) continue;
+ if ( aApp->activeStudy()->studyName() == studyname ) isAlreadyOpen = true;
+ }
- myActions.insert( *it, a );
+ if ( !isAlreadyOpen ) aDlg.ListComponent->insertItem( studyname );
}
- SUIT_Tools::simplifySeparators( modTBar );
+ int retVal = aDlg.exec();
+ studyname = aDlg.ListComponent->currentText();
- // New window
+ if (retVal == QDialog::Rejected)
+ return;
- int windowMenu = createMenu( tr( "MEN_DESK_WINDOW" ), -1, 100 );
- int newWinMenu = createMenu( tr( "MEN_DESK_NEWWINDOW" ), windowMenu, -1, 0 );
- createMenu( separator(), windowMenu, -1, 1 );
+ if ( studyname.isNull() || studyname.isEmpty() )
+ return;
- QMap<int, int> accelMap;
- accelMap[NewGLViewId] = ALT+Key_G;
- accelMap[NewPlot2dId] = ALT+Key_P;
- accelMap[NewOCCViewId] = ALT+Key_O;
- accelMap[NewVTKViewId] = ALT+Key_K;
+ name = studyname;
+ name.replace( QRegExp(":"), "/" );
- for ( int id = NewGLViewId; id <= NewVTKViewId; id++ )
+ if( LightApp_Application::onLoadDoc( name ) )
{
- QAction* a = createAction( id, tr( QString( "NEW_WINDOW_%1" ).arg( id - NewGLViewId ) ), QIconSet(),
- tr( QString( "NEW_WINDOW_%1" ).arg( id - NewGLViewId ) ),
- tr( QString( "NEW_WINDOW_%1" ).arg( id - NewGLViewId ) ),
- accelMap.contains( id ) ? accelMap[id] : 0, desk, false, this, SLOT( onNewWindow() ) );
- createMenu( a, newWinMenu, -1 );
+ updateWindows();
+ updateViewManagers();
+ updateObjectBrowser(true);
}
-
- connect( modGroup, SIGNAL( selected( QAction* ) ), this, SLOT( onModuleActivation( QAction* ) ) );
}
-void SalomeApp_Application::onModuleActivation( QAction* a )
-{
- if ( !a )
- return;
-
- QString modName = a->menuText();
- if ( modName == tr( "APP_NAME" ) )
- modName = QString::null;
-
- // Force user to create/open a study before module activation
- QMap<QString, QString> iconMap;
- moduleIconNames( iconMap );
- QPixmap icon = resourceMgr()->loadPixmap( moduleName( modName ), iconMap[ modName ] );
-
- bool cancelled = false;
- while ( !modName.isEmpty() && !activeStudy() && !cancelled ){
- SalomeApp_ModuleDlg aDlg( desktop(), modName, icon );
- int res = aDlg.exec();
-
- switch ( res ){
- case 1:
- onNewDoc();
- break;
- case 2:
- onOpenDoc();
- break;
- case 3:
- //onLoadStudy();
- //break;
- case 0:
- default:
- putInfo( tr("INF_CANCELLED") );
- myActions[QString()]->setOn( true );
- cancelled = true;
- }
- }
- if ( !cancelled )
- activateModule( modName );
+/*!SLOT. Load document with \a aName.*/
+bool SalomeApp_Application::onLoadDoc( const QString& aName )
+{
+ return LightApp_Application::onLoadDoc( aName );
}
-QString SalomeApp_Application::defaultModule() const
+/*!SLOT. Copy objects to study maneger from selection maneger..*/
+void SalomeApp_Application::onCopy()
{
- QStringList aModuleNames;
- modules( aModuleNames, false ); // obtain a complete list of module names for the current configuration
- // If there's the one and only module --> activate it automatically
- // TODO: Possible improvement - default module can be taken from preferences
- return aModuleNames.count() > 1 ? "" : ( aModuleNames.count() ? aModuleNames.first() : "" );
+ SALOME_ListIO list;
+ LightApp_SelectionMgr* mgr = selectionMgr();
+ mgr->selectedObjects(list);
+
+ SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(activeStudy());
+ if(study == NULL) return;
+
+ _PTR(Study) stdDS = study->studyDS();
+ if(!stdDS) return;
+
+ SALOME_ListIteratorOfListIO it( list );
+ if(it.More())
+ {
+ _PTR(SObject) so = stdDS->FindObjectID(it.Value()->getEntry());
+ try {
+ studyMgr()->Copy(so);
+ onSelectionChanged();
+ }
+ catch(...) {
+ }
+ }
}
-void SalomeApp_Application::onNewWindow()
+/*!SLOT. Paste objects to study maneger from selection manager.*/
+void SalomeApp_Application::onPaste()
{
- const QObject* obj = sender();
- if ( !obj || !obj->inherits( "QAction" ) )
- return;
+ SALOME_ListIO list;
+ LightApp_SelectionMgr* mgr = selectionMgr();
+ mgr->selectedObjects(list);
- QString type;
- int id = actionId( (QAction*)obj );
- switch ( id )
- {
- case NewGLViewId:
- type = GLViewer_Viewer::Type();
- break;
- case NewPlot2dId:
- type = Plot2d_Viewer::Type();
- break;
- case NewOCCViewId:
- type = OCCViewer_Viewer::Type();
- break;
- case NewVTKViewId:
- type = VTKViewer_Viewer::Type();
- break;
- }
+ SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(activeStudy());
+ if(study == NULL) return;
+
+ _PTR(Study) stdDS = study->studyDS();
+ if(!stdDS) return;
- if ( !type.isEmpty() )
- createViewManager( type );
+ SALOME_ListIteratorOfListIO it( list );
+ if(it.More())
+ {
+ _PTR(SObject) so = stdDS->FindObjectID(it.Value()->getEntry());
+ try {
+ studyMgr()->Paste(so);
+ updateObjectBrowser( true );
+ updateActions(); //SRN: BugID IPAL9377, case 3
+ }
+ catch(...) {
+ }
+ }
}
-//=======================================================================
-// name : onNewDoc
-// Purpose : SLOT. Create new document
-//=======================================================================
-void SalomeApp_Application::onNewDoc()
+/*!Sets enable or disable some actions on selection changed.*/
+void SalomeApp_Application::onSelectionChanged()
{
- SUIT_Study* study = activeStudy();
+ SALOME_ListIO list;
+ LightApp_SelectionMgr* mgr = selectionMgr();
+ mgr->selectedObjects(list);
- saveWindowsGeometry();
+ bool canCopy = false;
+ bool canPaste = false;
- CAM_Application::onNewDoc();
-
- if ( !study ) // new study will be create in THIS application
- {
- updateWindows();
- updateViewManagers();
- }
-}
+ SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(activeStudy());
+ if (study != NULL) {
+ _PTR(Study) stdDS = study->studyDS();
-//=======================================================================
-// name : onOpenDoc
-// Purpose : SLOT. Open new document
-//=======================================================================
-void SalomeApp_Application::onOpenDoc()
-{
- SUIT_Study* study = activeStudy();
- saveWindowsGeometry();
+ if (stdDS) {
+ SALOME_ListIteratorOfListIO it ( list );
- CAM_Application::onOpenDoc();
-
- if ( !study ) // new study will be create in THIS application
- {
- updateWindows();
- updateViewManagers();
- }
-}
+ if (it.More() && list.Extent() == 1) {
+ _PTR(SObject) so = stdDS->FindObjectID(it.Value()->getEntry());
-void SalomeApp_Application::onSelection()
-{
- onSelectionChanged();
+ if ( so ) {
+ SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(so.get());
+
+ if ( aSO ) {
+ canCopy = studyMgr()->CanCopy(so);
+ canPaste = studyMgr()->CanPaste(so);
+ }
+ }
+ }
+ }
+ }
- if ( activeModule() && activeModule()->inherits( "SalomeApp_Module" ) )
- ((SalomeApp_Module*)activeModule())->selectionChanged();
+ action(EditCopyId)->setEnabled(canCopy);
+ action(EditPasteId)->setEnabled(canPaste);
}
-void SalomeApp_Application::onSelectionChanged()
+/*!Delete references.*/
+void SalomeApp_Application::onDeleteInvalidReferences()
{
+ SALOME_ListIO aList;
+ LightApp_SelectionMgr* mgr = selectionMgr();
+ mgr->selectedObjects( aList, QString::null, false );
+
+ if( aList.IsEmpty() )
+ return;
+
+ SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(activeStudy());
+ _PTR(Study) aStudyDS = aStudy->studyDS();
+ _PTR(StudyBuilder) aStudyBuilder = aStudyDS->NewBuilder();
+ _PTR(SObject) anObj;
+
+ for( SALOME_ListIteratorOfListIO it( aList ); it.More(); it.Next() )
+ if ( it.Value()->hasEntry() )
+ {
+ _PTR(SObject) aSObject = aStudyDS->FindObjectID( it.Value()->getEntry() ), aRefObj = aSObject;
+ while( aRefObj && aRefObj->ReferencedObject( anObj ) )
+ aRefObj = anObj;
+
+ if( aRefObj && aRefObj!=aSObject && QString( aRefObj->GetName().c_str() ).isEmpty() )
+ aStudyBuilder->RemoveReference( aSObject );
+ }
+ updateObjectBrowser();
}
-void SalomeApp_Application::setActiveStudy( SUIT_Study* study )
+/*!Private SLOT. */
+void SalomeApp_Application::onOpenWith()
{
- CAM_Application::setActiveStudy( study );
-
- activateWindows();
+ QApplication::setOverrideCursor( Qt::waitCursor );
+ SALOME_ListIO aList;
+ LightApp_SelectionMgr* mgr = selectionMgr();
+ mgr->selectedObjects(aList);
+ if (aList.Extent() != 1)
+ {
+ QApplication::restoreOverrideCursor();
+ return;
+ }
+ Handle(SALOME_InteractiveObject) aIObj = aList.First();
+ QString aModuleName(aIObj->getComponentDataType());
+ QString aModuleTitle = moduleTitle(aModuleName);
+ activateModule(aModuleTitle);
+ QApplication::restoreOverrideCursor();
}
//=======================================================================
// name : createNewStudy
-// Purpose : Create new study
+/*! Purpose : Create new study*/
//=======================================================================
-SUIT_Study* SalomeApp_Application::createNewStudy()
-{
- SalomeApp_Study* aStudy = new SalomeApp_Study( this );
-
+SUIT_Study* SalomeApp_Application::createNewStudy()
+{
+ SalomeApp_Study* aStudy = new SalomeApp_Study( this );
+
// Set up processing of major study-related events
connect( aStudy, SIGNAL( created( SUIT_Study* ) ), this, SLOT( onStudyCreated( SUIT_Study* ) ) );
connect( aStudy, SIGNAL( opened ( SUIT_Study* ) ), this, SLOT( onStudyOpened ( SUIT_Study* ) ) );
connect( aStudy, SIGNAL( saved ( SUIT_Study* ) ), this, SLOT( onStudySaved ( SUIT_Study* ) ) );
connect( aStudy, SIGNAL( closed ( SUIT_Study* ) ), this, SLOT( onStudyClosed ( SUIT_Study* ) ) );
- return aStudy;
+ return aStudy;
}
//=======================================================================
-// name : createNewStudy
-// Purpose : Enable/Disable menu items and toolbar buttons. Rebuild menu
+// name : updateCommandsStatus
+/*! Purpose : Enable/Disable menu items and toolbar buttons. Rebuild menu*/
//=======================================================================
void SalomeApp_Application::updateCommandsStatus()
{
- CAM_Application::updateCommandsStatus();
+ LightApp_Application::updateCommandsStatus();
- for ( int id = NewGLViewId; id <= NewVTKViewId; id++ )
- {
- QAction* a = action( id );
- if ( a )
- a->setEnabled( activeStudy() );
- }
-}
-
-//=======================================================================
-// name : onHelpAbout
-// Purpose : SLOT. Display "About" message box
-//=======================================================================
-void SalomeApp_Application::onHelpAbout()
-{
- QMessageBox aDlg( desktop(), "AboutDlg" );
+ // Dump study menu
+ QAction* a = action( DumpStudyId );
+ if ( a )
+ a->setEnabled( activeStudy() );
- SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
- QPixmap aPixmap = aResMgr->loadPixmap( "SalomeApp", tr( "ABOUT_ICO" ) );
+ // Load script menu
+ a = action( LoadScriptId );
+ if ( a )
+ a->setEnabled( activeStudy() );
- QFontMetrics m( aDlg.font() );
- QImage anImage = aPixmap.convertToImage();
- int w = m.height() * 5;
- anImage = anImage.scale( w, w );
- aPixmap.convertFromImage( anImage );
+ a = action( PropertiesId );
+ if( a )
+ a->setEnabled( activeStudy() );
- aDlg.setCaption( tr( "ABOUT" ) );
- aDlg.setText( tr( "APP_NAME_LONG" ).arg( APP_VERSION ) );
- aDlg.setIconPixmap( aPixmap );
- aDlg.exec();
+ // update state of Copy/Paste menu items
+ onSelectionChanged();
}
-QWidget* SalomeApp_Application::window( const int flag, const int studyId ) const
-{
- QWidget* wid = 0;
-
- int sId = studyId;
- if ( sId < 0 )
- {
- if ( !activeStudy() )
- return 0;
- else
- sId = activeStudy()->id();
+/*!Private SLOT. On dump study.*/
+void SalomeApp_Application::onDumpStudy( )
+{
+ SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( activeStudy() );
+ if ( !appStudy ) return;
+ _PTR(Study) aStudy = appStudy->studyDS();
+
+ QStringList aFilters;
+ aFilters.append( tr( "PYTHON_FILES_FILTER" ) );
+
+ SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg( desktop(), false, tr("PUBLISH_IN_STUDY"), true, true);
+ fd->setCaption( tr( "TOT_DESK_FILE_DUMP_STUDY" ) );
+ fd->setFilters( aFilters );
+ fd->SetChecked(true);
+ fd->exec();
+ QString aFileName = fd->selectedFile();
+ bool toPublish = fd->IsChecked();
+ delete fd;
+
+ if(!aFileName.isEmpty()) {
+ QFileInfo aFileInfo(aFileName);
+ bool res = aStudy->DumpStudy( aFileInfo.dirPath( true ).latin1(), aFileInfo.baseName().latin1(), toPublish );
+ if ( !res )
+ SUIT_MessageBox::warn1 ( desktop(),
+ QObject::tr("WRN_WARNING"),
+ tr("WRN_DUMP_STUDY_FAILED"),
+ QObject::tr("BUT_OK") );
}
-
- if ( myWindows.contains( flag ) )
- wid = myWindows[flag]->widget( sId );
-
- return wid;
}
-void SalomeApp_Application::addWindow( QWidget* wid, const int flag, const int studyId )
+/*!Private SLOT. On load script.*/
+void SalomeApp_Application::onLoadScript( )
{
- if ( !wid )
- return;
-
- int sId = studyId;
- if ( sId < 0 )
- {
- if ( !activeStudy() )
- return;
- else
- sId = activeStudy()->id();
- }
-
- if ( !myWindows.contains( flag ) )
- {
- QMap<int, int> winMap;
- currentWindows( winMap );
-
- myWindows.insert( flag, new SalomeApp_WidgetContainer( flag, desktop() ) );
- if ( winMap.contains( flag ) )
- desktop()->moveDockWindow( myWindows[flag], (Dock)winMap[flag] );
-
- myWindows[flag]->setResizeEnabled( true );
- myWindows[flag]->setCloseMode( QDockWindow::Always );
- myWindows[flag]->setName( QString( "dock_window_%1" ).arg( flag ) );
- }
-
- myWindows[flag]->insert( sId, wid );
+ SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( activeStudy() );
+ if ( !appStudy ) return;
+ _PTR(Study) aStudy = appStudy->studyDS();
- setWindowShown( flag, !myWindows[flag]->isEmpty() );
-}
-
-void SalomeApp_Application::removeWindow( const int flag, const int studyId )
-{
- if ( !myWindows.contains( flag ) )
+ if ( aStudy->GetProperties()->IsLocked() ) {
+ SUIT_MessageBox::warn1 ( desktop(),
+ QObject::tr("WRN_WARNING"),
+ QObject::tr("WRN_STUDY_LOCKED"),
+ QObject::tr("BUT_OK") );
return;
-
- int sId = studyId;
- if ( sId < 0 )
- {
- if ( !activeStudy() )
- return;
- else
- sId = activeStudy()->id();
}
- QWidget* wid = myWindows[flag]->widget( sId );
- myWindows[flag]->remove( sId );
- delete wid;
+ QStringList filtersList;
+ filtersList.append(tr("PYTHON_FILES_FILTER"));
+ filtersList.append(tr("ALL_FILES_FILTER"));
- setWindowShown( flag, !myWindows[flag]->isEmpty() );
-}
+ QString aFile = SUIT_FileDlg::getFileName( desktop(), "", filtersList, tr( "TOT_DESK_FILE_LOAD_SCRIPT" ), true, true );
-QWidget* SalomeApp_Application::getWindow( const int flag, const int studyId )
-{
- QWidget* wid = window( flag, studyId );
- if ( !wid )
- addWindow( wid = createWindow( flag ), flag, studyId );
-
- return wid;
-}
-
-bool SalomeApp_Application::isWindowVisible( const int type ) const
-{
- bool res = false;
- if ( myWindows.contains( type ) )
+ if ( !aFile.isEmpty() )
{
- SUIT_Desktop* desk = ((SalomeApp_Application*)this)->desktop();
- res = desk && desk->appropriate( myWindows[type] );
- }
- return res;
-}
+ QString command = QString("execfile(\"%1\")").arg(aFile);
-void SalomeApp_Application::setWindowShown( const int type, const bool on )
-{
- if ( !desktop() || !myWindows.contains( type ) )
- return;
+ PythonConsole* pyConsole = pythonConsole();
- QDockWindow* dw = myWindows[type];
- desktop()->setAppropriate( dw, on );
- on ? dw->show() : dw->hide();
-}
-
-OB_Browser* SalomeApp_Application::objectBrowser()
-{
- OB_Browser* ob = 0;
- QWidget* wid = getWindow( WT_ObjectBrowser );
- if ( wid->inherits( "OB_Browser" ) )
- ob = (OB_Browser*)wid;
- return ob;
-}
-
-LogWindow* SalomeApp_Application::logWindow()
-{
- LogWindow* lw = 0;
- QWidget* wid = getWindow( WT_LogWindow );
- if ( wid->inherits( "LogWindow" ) )
- lw = (LogWindow*)wid;
- return lw;
-}
-
-SUIT_ViewManager* SalomeApp_Application::getViewManager( const QString& vmType, const bool create )
-{
- SUIT_ViewManager* aVM = viewManager( vmType );
- SUIT_ViewManager* anActiveVM = CAM_Application::activeViewManager();
- if ( anActiveVM && anActiveVM->getType() == vmType )
- aVM = anActiveVM;
- else if ( aVM )
- {
- if ( !aVM->getActiveView() )
- aVM->createView();
- }
- else if ( create )
- aVM = createViewManager( vmType );
- return aVM;
-}
-
-SUIT_ViewManager* SalomeApp_Application::createViewManager( const QString& vmType )
-{
- SUIT_ViewManager* viewMgr = 0;
- if ( vmType == GLViewer_Viewer::Type() )
- {
- viewMgr = new GLViewer_ViewManager( activeStudy(), desktop() );
- new SalomeApp_GLSelector( (GLViewer_Viewer2d*)viewMgr->getViewModel(), mySelMgr );
- }
- else if ( vmType == Plot2d_Viewer::Type() )
- viewMgr = new Plot2d_ViewManager( activeStudy(), desktop() );
- else if ( vmType == OCCViewer_Viewer::Type() )
- {
- viewMgr = new OCCViewer_ViewManager( activeStudy(), desktop() );
- viewMgr->setViewModel( new SOCC_Viewer() );// custom view model, which extends SALOME_View interface
- new SalomeApp_OCCSelector( (OCCViewer_Viewer*)viewMgr->getViewModel(), mySelMgr );
- }
- else if ( vmType == SVTK_Viewer::Type() )
- {
- viewMgr = new SVTK_ViewManager( activeStudy(), desktop() );
- new SalomeApp_VTKSelector((SVTK_Viewer*)viewMgr->getViewModel(),mySelMgr);
+ if ( pyConsole )
+ pyConsole->exec( command );
}
-
- if ( !viewMgr )
- return 0;
-
- addViewManager( viewMgr );
- SUIT_ViewWindow* viewWin = viewMgr->createViewWindow();
-
- if ( viewWin && desktop() )
- viewWin->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) );
-
- connect( viewMgr, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
- this, SLOT( onCloseView( SUIT_ViewManager* ) ) );
-
- return viewMgr;
-}
-
-void SalomeApp_Application::onCloseView( SUIT_ViewManager* theVM )
-{
- removeViewManager( theVM );
-}
-
-void SalomeApp_Application::onStudyCreated( SUIT_Study* theStudy )
-{
- SUIT_DataObject* aRoot = 0;
- if ( theStudy && theStudy->root() )
- {
- aRoot = theStudy->root();
- //aRoot->setName( tr( "DATA_MODELS" ) );
- }
- if ( objectBrowser() != 0 )
- objectBrowser()->setRootObject( aRoot );
-
- activateModule( defaultModule() );
-}
-
-void SalomeApp_Application::onStudyOpened( SUIT_Study* theStudy )
-{
- SUIT_DataObject* aRoot = 0;
- if ( theStudy && theStudy->root() )
- {
- aRoot = theStudy->root();
- //aRoot->dump();
- }
- if ( objectBrowser() != 0 ) {
- objectBrowser()->setRootObject( aRoot );
- }
-
- activateWindows();
-
- activateModule( defaultModule() );
-
- emit studyOpened();
-}
-
-void SalomeApp_Application::onStudySaved( SUIT_Study* )
-{
- emit studySaved();
-}
-
-void SalomeApp_Application::onStudyClosed( SUIT_Study* )
-{
- emit studyClosed();
-
- activateModule( "" );
-
- saveWindowsGeometry();
}
+/*!Gets file filter.
+ *\retval QString "(*.hdf)"
+ */
QString SalomeApp_Application::getFileFilter() const
{
return "(*.hdf)";
}
-void SalomeApp_Application::beforeCloseDoc( SUIT_Study* s )
-{
- CAM_Application::beforeCloseDoc( s );
-
- for ( WindowMap::ConstIterator itr = myWindows.begin(); s && itr != myWindows.end(); ++itr )
- removeWindow( itr.key(), s->id() );
-}
-
-void SalomeApp_Application::updateActions()
-{
- updateCommandsStatus();
-}
-
+/*!Create window.*/
QWidget* SalomeApp_Application::createWindow( const int flag )
{
QWidget* wid = 0;
+ if ( flag != WT_PyConsole ) wid = LightApp_Application::createWindow(flag);
+
+ SUIT_ResourceMgr* resMgr = resourceMgr();
if ( flag == WT_ObjectBrowser )
{
- OB_Browser* ob = new OB_Browser( desktop() );
- ob->setAutoUpdate( true );
- ob->setAutoOpenLevel( 1 );
- ob->setCaption( tr( "OBJECT_BROWSER" ) );
- ob->resize( OBJECT_BROWSER_WIDTH, ob->height() );
- ob->setFilter( new SalomeApp_OBFilter( selectionMgr() ) );
-
- // Create OBSelector
- new SalomeApp_OBSelector( ob, mySelMgr );
-
- wid = ob;
-
- ob->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
+ OB_Browser* ob = (OB_Browser*)wid;
+ connect( ob->listView(), SIGNAL( doubleClicked( QListViewItem* ) ), this, SLOT( onDblClick( QListViewItem* ) ) );
+ bool autoSize = resMgr->booleanValue( "ObjectBrowser", "auto_size", false ),
+ autoSizeFirst = resMgr->booleanValue( "ObjectBrowser", "auto_size_first", true );
+ for ( int i = SalomeApp_DataObject::CT_Value; i <= SalomeApp_DataObject::CT_RefEntry; i++ )
+ {
+ ob->addColumn( tr( QString().sprintf( "OBJ_BROWSER_COLUMN_%d", i ) ), i );
+ ob->setColumnShown( i, resMgr->booleanValue( "ObjectBrowser",
+ QString().sprintf( "visibility_column_%d", i ), true ) );
+ }
+ ob->setWidthMode( autoSize ? QListView::Maximum : QListView::Manual );
+ ob->listView()->setColumnWidthMode( 0, autoSizeFirst ? QListView::Maximum : QListView::Manual );
+ ob->resize( desktop()->width()/3, ob->height() );
}
else if ( flag == WT_PyConsole )
{
PythonConsole* pyCons = new PythonConsole( desktop(), new SalomeApp_PyInterp() );
pyCons->setCaption( tr( "PYTHON_CONSOLE" ) );
wid = pyCons;
-
- // pyCons->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
+ pyCons->resize( pyCons->width(), desktop()->height()/4 );
+ //pyCons->connectPopupRequest(this, SLOT(onConnectPopupRequest(SUIT_PopupClient*, QContextMenuEvent*)));
}
- else if ( flag == WT_LogWindow )
- {
- LogWindow* logWin = new LogWindow( desktop() );
- logWin->setCaption( tr( "LOG_WINDOW" ) );
- wid = logWin;
-
- logWin->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
- }
-
return wid;
}
-void SalomeApp_Application::defaultWindows( QMap<int, int>& aMap ) const
+/*!Create preferences.*/
+void SalomeApp_Application::createPreferences( LightApp_Preferences* pref )
{
- aMap.insert( WT_ObjectBrowser, Qt::DockLeft );
- aMap.insert( WT_PyConsole, Qt::DockBottom );
-}
+ LightApp_Application::createPreferences(pref);
-void SalomeApp_Application::defaultViewManagers( QStringList& ) const
-{
+ if ( !pref )
+ return;
+
+ int salomeCat = pref->addPreference( tr( "PREF_CATEGORY_SALOME" ) );
+ int obTab = pref->addPreference( tr( "PREF_TAB_OBJBROWSER" ), salomeCat );
+ int defCols = pref->addPreference( tr( "PREF_GROUP_DEF_COLUMNS" ), obTab );
+ for ( int i = SalomeApp_DataObject::CT_Value; i <= SalomeApp_DataObject::CT_RefEntry; i++ )
+ {
+ pref->addPreference( tr( QString().sprintf( "OBJ_BROWSER_COLUMN_%d", i ) ), defCols,
+ LightApp_Preferences::Bool, "ObjectBrowser", QString().sprintf( "visibility_column_%d", i ) );
+ }
+ pref->setItemProperty( defCols, "columns", 1 );
}
-void SalomeApp_Application::afterCloseDoc()
-{
- updateWindows();
+/*!Update desktop title.*/
+void SalomeApp_Application::updateDesktopTitle() {
+ QString aTitle = applicationName();
+ QString aVer = applicationVersion();
+ if ( !aVer.isEmpty() )
+ aTitle += QString( " " ) + aVer;
- CAM_Application::afterCloseDoc();
+ if ( activeStudy() )
+ {
+ QString sName = SUIT_Tools::file( activeStudy()->studyName().stripWhiteSpace(), false );
+ if ( !sName.isEmpty() ) {
+ SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(activeStudy());
+ if ( study ) {
+ _PTR(Study) stdDS = study->studyDS();
+ if(stdDS) {
+ if ( stdDS->GetProperties()->IsLocked() ) {
+ aTitle += QString( " - [%1 (%2)]").arg( sName ).arg( tr( "STUDY_LOCKED" ) );
+ } else {
+ aTitle += QString( " - [%1]" ).arg( sName );
+ }
+ }
+ }
+ }
+ }
+
+ desktop()->setCaption( aTitle );
}
+/*!Gets CORBA::ORB_var*/
CORBA::ORB_var SalomeApp_Application::orb()
{
ORB_INIT& init = *SINGLETON_<ORB_INIT>::Instance();
- CORBA::ORB_var& orb = init( qApp->argc(), qApp->argv() );
-
- return orb;
+ static CORBA::ORB_var _orb = init( qApp->argc(), qApp->argv() );
+ return _orb;
}
+/*!Create and return SALOMEDS_StudyManager.*/
SALOMEDSClient_StudyManager* SalomeApp_Application::studyMgr()
{
- static SALOMEDSClient_StudyManager* aStudyManager = NULL;
-
- if(!aStudyManager) {
- aStudyManager = new SALOMEDS_StudyManager();
- }
- return aStudyManager;
+ static SALOMEDSClient_StudyManager* _sm = new SALOMEDS_StudyManager();
+ return _sm;
}
+/*!Create and return SALOME_NamingService.*/
SALOME_NamingService* SalomeApp_Application::namingService()
{
- return new SALOME_NamingService( orb() );
+ static SALOME_NamingService* _ns = new SALOME_NamingService( orb() );
+ return _ns;
+}
+
+/*!Create and return SALOME_LifeCycleCORBA.*/
+SALOME_LifeCycleCORBA* SalomeApp_Application::lcc()
+{
+ static SALOME_LifeCycleCORBA* _lcc = new SALOME_LifeCycleCORBA( namingService() );
+ return _lcc;
}
+/*!Return default engine IOR for light modules*/
QString SalomeApp_Application::defaultEngineIOR()
{
- // Look for a default module engine (needed for CORBAless modules to use SALOMEDS persistence)
+ /// Look for a default module engine (needed for CORBAless modules to use SALOMEDS persistence)
QString anIOR( "" );
CORBA::Object_ptr anEngine = namingService()->Resolve( "/SalomeAppEngine" );
if ( !CORBA::is_nil( anEngine ) )
return anIOR;
}
-void SalomeApp_Application::moduleIconNames( QMap<QString, QString>& iconMap ) const
+/*!Private SLOT. On preferences.*/
+void SalomeApp_Application::onProperties()
{
- iconMap.clear();
-
- SUIT_ResourceMgr* resMgr = resourceMgr();
- if ( !resMgr )
+ SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( activeStudy() );
+ if( !study )
return;
- QStringList modList;
- modules( modList, false );
-
- for ( QStringList::const_iterator it = modList.begin(); it != modList.end(); ++it )
- {
- QString modName = *it;
- QString modIntr = moduleName( modName );
- QString modIcon = resMgr->stringValue( modIntr, "icon", QString::null );
-
- if ( modIcon.isEmpty() )
- continue;
+ _PTR(StudyBuilder) SB = study->studyDS()->NewBuilder();
+ SB->NewCommand();
- if ( SUIT_Tools::extension( modIcon ).isEmpty() )
- modIcon += QString( ".png" );
+ SalomeApp_StudyPropertiesDlg aDlg( desktop() );
+ int res = aDlg.exec();
+ if( res==QDialog::Accepted && aDlg.isChanged() )
+ SB->CommitCommand();
+ else
+ SB->AbortCommand();
- iconMap.insert( modName, modIcon );
- }
+ //study->updateCaptions();
+ updateDesktopTitle();
+ updateActions();
}
-void SalomeApp_Application::updateModuleActions()
+/*!Insert items in popup, which necessary for current application*/
+void SalomeApp_Application::contextMenuPopup( const QString& type, QPopupMenu* thePopup, QString& title )
{
- QString modName;
- if ( activeModule() )
- modName = activeModule()->moduleName();
-
- if ( myActions.contains( modName ) )
- myActions[modName]->setOn( true );
-}
+ LightApp_Application::contextMenuPopup( type, thePopup, title );
-void SalomeApp_Application::currentWindows( QMap<int, int>& winMap ) const
-{
- winMap.clear();
- if ( !activeStudy() )
+ OB_Browser* ob = objectBrowser();
+ if ( !ob || type != ob->popupClientType() )
return;
- if ( activeModule() && activeModule()->inherits( "SalomeApp_Module" ) )
- ((SalomeApp_Module*)activeModule())->windows( winMap );
- else
- defaultWindows( winMap );
-}
-
-void SalomeApp_Application::currentViewManagers( QStringList& lst ) const
-{
- lst.clear();
- if ( !activeStudy() )
- return;
+ // Get selected objects
+ SALOME_ListIO aList;
+ LightApp_SelectionMgr* mgr = selectionMgr();
+ mgr->selectedObjects( aList, QString::null, false );
- if ( activeModule() && activeModule()->inherits( "SalomeApp_Module" ) )
- ((SalomeApp_Module*)activeModule())->viewManagers( lst );
- else
- defaultViewManagers( lst );
-}
+ // "Delete reference" item should appear only for invalid references
-void SalomeApp_Application::updateWindows()
-{
- QMap<int, int> winMap;
- currentWindows( winMap );
+ // isInvalidRefs will be true, if at least one of selected objects is invalid reference
+ bool isInvalidRefs = false;
+ SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(activeStudy());
+ _PTR(Study) aStudyDS = aStudy->studyDS();
+ _PTR(SObject) anObj;
- for ( QMap<int, int>::ConstIterator it = winMap.begin(); it != winMap.end(); ++it )
- getWindow( it.key() );
+ for( SALOME_ListIteratorOfListIO it( aList ); it.More() && !isInvalidRefs; it.Next() )
+ if( it.Value()->hasEntry() )
+ {
+ _PTR(SObject) aSObject = aStudyDS->FindObjectID( it.Value()->getEntry() ), aRefObj = aSObject;
+ while( aRefObj && aRefObj->ReferencedObject( anObj ) )
+ aRefObj = anObj;
- loadWindowsGeometry();
+ if( aRefObj && aRefObj!=aSObject && QString( aRefObj->GetName().c_str() ).isEmpty() )
+ isInvalidRefs = true;
+ }
- for ( WindowMap::ConstIterator itr = myWindows.begin(); itr != myWindows.end(); ++itr )
- setWindowShown( itr.key(), !itr.data()->isEmpty() && winMap.contains( itr.key() ) );
-}
+ // Add "Delete reference" item to popup
+ if ( isInvalidRefs )
+ {
+ thePopup->insertSeparator();
+ thePopup->insertItem( tr( "MEN_DELETE_INVALID_REFERENCE" ), this, SLOT( onDeleteInvalidReferences() ) );
+ return;
+ }
-void SalomeApp_Application::updateViewManagers()
-{
- QStringList lst;
- currentViewManagers( lst );
+ aList.Clear();
+ mgr->selectedObjects( aList );
- for ( QStringList::const_iterator it = lst.begin(); it != lst.end(); ++it )
- getViewManager( *it, true );
+ // "Activate module" item should appear only if it's necessary
+ if (aList.Extent() != 1)
+ return;
+ Handle(SALOME_InteractiveObject) aIObj = aList.First();
+ QString aModuleName(aIObj->getComponentDataType());
+ QString aModuleTitle = moduleTitle(aModuleName);
+ CAM_Module* currentModule = activeModule();
+ if (currentModule && currentModule->moduleName() == aModuleTitle)
+ return;
+ thePopup->insertItem( tr( "MEN_OPENWITH" ), this, SLOT( onOpenWith() ) );
}
-void SalomeApp_Application::loadWindowsGeometry()
+/*!Update obect browser:
+ 1.if 'updateModels' true, update existing data models;
+ 2. update "non-existing" (not loaded yet) data models;
+ 3. update object browser if it existing */
+void SalomeApp_Application::updateObjectBrowser( const bool updateModels )
{
- QtxDockAction* dockMgr = 0;
-
- QAction* a = action( ViewWindowsId );
- if ( a && a->inherits( "QtxDockAction" ) )
- dockMgr = (QtxDockAction*)a;
-
- if ( !dockMgr )
- return;
-
- QString modName;
- if ( activeModule() )
- modName = moduleLibrary( activeModule()->moduleName(), false );
-
- QString section = QString( "windows_geometry" );
- if ( !modName.isEmpty() )
- section += QString( "." ) + modName;
+ // update existing data models (already loaded SComponents)
+ LightApp_Application::updateObjectBrowser(updateModels);
+ // update "non-existing" (not loaded yet) data models
+ SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(activeStudy());
+ if ( study )
+ {
+ _PTR(Study) stdDS = study->studyDS();
+ if( stdDS )
+ {
+ for ( _PTR(SComponentIterator) it ( stdDS->NewComponentIterator() ); it->More(); it->Next() )
+ {
+ _PTR(SComponent) aComponent ( it->Value() );
+
+ if ( aComponent->ComponentDataType() == "Interface Applicative" )
+ continue; // skip the magic "Interface Applicative" component
+
+ SalomeApp_DataModel::BuildTree( aComponent, study->root(), study, /*skipExisitng=*/true );
+ }
+ }
+ }
- dockMgr->loadGeometry( resourceMgr(), section, false );
- dockMgr->restoreGeometry();
+ if ( objectBrowser() )
+ {
+ objectBrowser()->updateGeometry();
+ objectBrowser()->updateTree( 0, false );
+ }
}
-void SalomeApp_Application::saveWindowsGeometry()
+/*!Display Catalog Genenerator dialog */
+void SalomeApp_Application::onCatalogGen()
{
- QtxDockAction* dockMgr = 0;
-
- QAction* a = action( ViewWindowsId );
- if ( a && a->inherits( "QtxDockAction" ) )
- dockMgr = (QtxDockAction*)a;
-
- if ( !dockMgr )
- return;
-
- QString modName;
- if ( activeModule() )
- modName = moduleLibrary( activeModule()->moduleName(), false );
-
- QString section = QString( "windows_geometry" );
- if ( !modName.isEmpty() )
- section += QString( "." ) + modName;
+ ToolsGUI_CatalogGeneratorDlg aDlg( desktop() );
+ aDlg.exec();
+}
- dockMgr->storeGeometry();
- dockMgr->saveGeometry( resourceMgr(), section, false );
+/*!Display Registry Display dialog */
+void SalomeApp_Application::onRegDisplay()
+{
+ CORBA::ORB_var anOrb = orb();
+ ToolsGUI_RegWidget* regWnd = ToolsGUI_RegWidget::GetRegWidget( anOrb, desktop(), "Registry" );
+ regWnd->show();
+ regWnd->raise();
+ regWnd->setActiveWindow();
}
-void SalomeApp_Application::activateWindows()
+/*!find original object by double click on item */
+void SalomeApp_Application::onDblClick( QListViewItem* it )
{
- if ( activeStudy() )
+ OB_ListItem* item = dynamic_cast<OB_ListItem*>( it );
+ SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( activeStudy() );
+
+ if( study && item )
{
- for ( WindowMap::Iterator itr = myWindows.begin(); itr != myWindows.end(); ++itr )
- itr.data()->activate( activeStudy()->id() );
+ SalomeApp_DataObject* obj = dynamic_cast<SalomeApp_DataObject*>( item->dataObject() );
+ if( !obj )
+ return;
+
+ QString entry = obj->entry();
+ _PTR(SObject) sobj = study->studyDS()->FindObjectID( entry.latin1() ), ref;
+
+ if( sobj && sobj->ReferencedObject( ref ) )
+ {
+ entry = ref->GetID().c_str();
+ QListViewItemIterator anIt( item->listView() );
+ for( ; anIt.current(); anIt++ )
+ {
+ OB_ListItem* item = dynamic_cast<OB_ListItem*>( anIt.current() );
+ if( !item )
+ continue;
+
+ SalomeApp_DataObject* original = dynamic_cast<SalomeApp_DataObject*>( item->dataObject() );
+ if( original->entry()!=entry )
+ continue;
+
+ OB_Browser* br = objectBrowser();
+ br->setSelected( original );
+ SUIT_DataObject* p = original->parent();
+ while( p )
+ {
+ br->setOpen( p );
+ p = p->parent();
+ }
+ break;
+ }
+ }
}
}