#include "SalomeApp_Study.h"
#include "SalomeApp_Module.h"
+#include "SalomeApp_OBFilter.h"
+#include "SalomeApp_DataModel.h"
+#include "SalomeApp_DataObject.h"
+#include "SalomeApp_EventFilter.h"
+#include "SalomeApp_WidgetContainer.h"
+
+#include "SalomeApp_AboutDlg.h"
+#include "SalomeApp_ModuleDlg.h"
+#include "SalomeApp_Preferences.h"
+#include "SalomeApp_PreferencesDlg.h"
+#include "SalomeApp_StudyPropertiesDlg.h"
+#include "SalomeApp_CheckFileDlg.h"
+
#include "SalomeApp_GLSelector.h"
#include "SalomeApp_OBSelector.h"
#include "SalomeApp_OCCSelector.h"
#include "SalomeApp_VTKSelector.h"
-#include "SalomeApp_EventFilter.h"
#include "SalomeApp_SelectionMgr.h"
-#include "SalomeApp_EventFilter.h"
-#include "SalomeApp_WidgetContainer.h"
-#include "SalomeApp_ModuleDlg.h"
#include <LogWindow.h>
#include <GLViewer_ViewManager.h>
#include <Plot2d_ViewManager.h>
+#include <SPlot2d_ViewModel.h>
#include <OCCViewer_ViewManager.h>
#include <SOCC_ViewModel.h>
-#include "SVTK_ViewManager.h"
-#include "SVTK_ViewModel.h"
+#include <SVTK_ViewModel.h>
+#include <SVTK_ViewManager.h>
#include <STD_TabDesktop.h>
#include <SUIT_Tools.h>
#include <SUIT_Session.h>
+#include <QtxToolBar.h>
+#include <QtxMRUAction.h>
#include <QtxDockAction.h>
+#include <QtxResourceEdit.h>
#include <OB_Browser.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 <qdir.h>
#include <qlabel.h>
#include <qimage.h>
#include <qaction.h>
#include "SALOMEDS_StudyManager.hxx"
+#include "SALOME_ListIteratorOfListIO.hxx"
+#include "SALOME_ListIO.hxx"
+
#define OBJECT_BROWSER_WIDTH 300
static const char* imageEmptyIcon[] = {
return new SalomeApp_Application();
}
+SalomeApp_Preferences* SalomeApp_Application::_prefs_ = 0;
+
/*
Class : SalomeApp_Application
Description : Application containing SalomeApp module
*/
SalomeApp_Application::SalomeApp_Application()
-: CAM_Application( false )
+: CAM_Application( false ),
+myPrefs( 0 )
{
STD_TabDesktop* desk = new STD_TabDesktop();
setDesktop( desk );
SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
- QPixmap aLogo = aResMgr->loadPixmap( "SalomeApp", tr( "APP_DEFAULT_ICO" ) );
+ QPixmap aLogo = aResMgr->loadPixmap( "SalomeApp", tr( "APP_DEFAULT_ICO" ), false );
desktop()->setIcon( aLogo );
desktop()->setDockableMenuBar( true );
putInfo( "" );
}
-QString SalomeApp_Application::applicationName() const
-{
- return "SalomeApp";
+QString SalomeApp_Application::applicationName() const
+{
+ return tr( "APP_NAME" );
+}
+
+QString SalomeApp_Application::applicationVersion() const
+{
+ static QString _app_version;
+
+ if ( _app_version.isEmpty() )
+ {
+ QString path( ::getenv( "GUI_ROOT_DIR" ) );
+ if ( !path.isEmpty() )
+ path += QDir::separator();
+ path += QString( "bin/salome/VERSION" );
+
+ QFile vf( path );
+ if ( vf.open( IO_ReadOnly ) )
+ {
+ QString line;
+ vf.readLine( line, 1024 );
+ vf.close();
+
+ if ( !line.isEmpty() )
+ {
+ while ( !line.isEmpty() && line.at( line.length() - 1 ) == QChar( '\n' ) )
+ line.remove( line.length() - 1, 1 );
+
+ int idx = line.findRev( ":" );
+ if ( idx != -1 )
+ _app_version = line.mid( idx + 1 ).stripWhiteSpace();
+ }
+ }
+ }
+
+ return _app_version;
}
CAM_Module* SalomeApp_Application::loadModule( const QString& name )
SUIT_Desktop* desk = desktop();
SUIT_ResourceMgr* resMgr = resourceMgr();
+
+ // Dump study
+ createAction( DumpStudyId, tr( "TOT_DESK_FILE_DUMP_STUDY" ), QIconSet(),
+ tr( "MEN_DESK_FILE_DUMP_STUDY" ), tr( "PRP_DESK_FILE_DUMP_STUDY" ),
+ 0, 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" ),
+ 0, desk, false, this, SLOT( onLoadScript() ) );
+
+ // Properties
+ createAction( PropertiesId, tr( "TOT_DESK_PROPERTIES" ), QIconSet(),
+ tr( "MEN_DESK_PROPERTIES" ), tr( "PRP_DESK_PROPERTIES" ),
+ 0, desk, false, this, SLOT( onProperties() ) );
+
+ // Preferences
+ createAction( PreferencesId, tr( "TOT_DESK_PREFERENCES" ), QIconSet(),
+ tr( "MEN_DESK_PREFERENCES" ), tr( "PRP_DESK_PREFERENCES" ),
+ CTRL+Key_P, desk, false, this, SLOT( onPreferences() ) );
+
+ // MRU
+ QtxMRUAction* mru = new QtxMRUAction( tr( "TOT_DESK_MRU" ), tr( "MEN_DESK_MRU" ), desk );
+ connect( mru, SIGNAL( activated( QString ) ), this, SLOT( onMRUActivated( QString ) ) );
+ registerAction( MRUId, mru );
// default icon for neutral point ('SALOME' module)
- QPixmap defIcon = resMgr->loadPixmap( "SalomeApp", tr( "APP_DEFAULT_ICO" ) );
+ QPixmap defIcon = resMgr->loadPixmap( "SalomeApp", tr( "APP_DEFAULT_ICO" ), false );
if ( defIcon.isNull() )
defIcon = QPixmap( imageEmptyIcon );
+
// default icon for any module
- QPixmap modIcon = resMgr->loadPixmap( "SalomeApp", tr( "APP_MODULE_ICO" ) );
+ QPixmap modIcon = resMgr->loadPixmap( "SalomeApp", tr( "APP_MODULE_ICO" ), false );
if ( modIcon.isNull() )
modIcon = QPixmap( imageEmptyIcon );
- int modTBar = createTool( tr( "INF_TOOLBAR_MODULES" ) );
+ QToolBar* modTBar = new QtxToolBar( true, desk );
+ modTBar->setLabel( tr( "INF_TOOLBAR_MODULES" ) );
QActionGroup* modGroup = new QActionGroup( this );
modGroup->setExclusive( true );
const int iconSize = 20;
- createTool( modGroup, modTBar );
- createTool( separator(), modTBar );
+ modGroup->addTo( modTBar );
+ modTBar->addSeparator();
QStringList modList;
modules( modList, false );
QString modName = moduleName( *it );
- QPixmap icon = resMgr->loadPixmap( modName, iconName );
+ QPixmap icon = resMgr->loadPixmap( modName, iconName, false );
if ( icon.isNull() )
icon = modIcon;
icon.convertFromImage( icon.convertToImage().smoothScale( iconSize, iconSize, QImage::ScaleMin ) );
QAction* a = createAction( -1, *it, icon, *it, tr( "PRP_MODULE" ).arg( *it ), 0, desk, true );
- createTool( a, modTBar );
+ a->addTo( modTBar );
modGroup->add( a );
myActions.insert( *it, a );
}
+ SUIT_Tools::simplifySeparators( modTBar );
+
+ // New window
+
int windowMenu = createMenu( tr( "MEN_DESK_WINDOW" ), -1, 100 );
int newWinMenu = createMenu( tr( "MEN_DESK_NEWWINDOW" ), windowMenu, -1, 0 );
createMenu( separator(), windowMenu, -1, 1 );
+ QMap<int, int> accelMap;
+ accelMap[NewGLViewId] = ALT+Key_G;
+ accelMap[NewPlot2dId] = ALT+Key_P;
+ accelMap[NewOCCViewId] = ALT+Key_O;
+ accelMap[NewVTKViewId] = ALT+Key_K;
+
for ( int id = NewGLViewId; id <= NewVTKViewId; id++ )
{
- 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 ) ),
- 0, desk, false, this, SLOT( onNewWindow() ) );
+ 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 );
}
-
connect( modGroup, SIGNAL( selected( QAction* ) ), this, SLOT( onModuleActivation( QAction* ) ) );
+
+ 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 );
+ createMenu( PreferencesId, fileMenu, 15, -1 );
+ createMenu( separator(), fileMenu, -1, 15, -1 );
+
+ /*
+ createMenu( separator(), fileMenu, -1, 100, -1 );
+ createMenu( MRUId, fileMenu, 100, -1 );
+ createMenu( separator(), fileMenu, -1, 100, -1 );
+ */
}
void SalomeApp_Application::onModuleActivation( QAction* a )
// Force user to create/open a study before module activation
QMap<QString, QString> iconMap;
moduleIconNames( iconMap );
- QPixmap icon = resourceMgr()->loadPixmap( moduleName( modName ), iconMap[ modName ] );
+ QPixmap icon = resourceMgr()->loadPixmap( moduleName( modName ), iconMap[ modName ], false );
+ if ( icon.isNull() )
+ icon = resourceMgr()->loadPixmap( "SalomeApp", tr( "APP_MODULE_BIG_ICO" ), false ); // default icon for any module
bool cancelled = false;
while ( !modName.isEmpty() && !activeStudy() && !cancelled ){
saveWindowsGeometry();
CAM_Application::onNewDoc();
-
+
if ( !study ) // new study will be create in THIS application
{
updateWindows();
saveWindowsGeometry();
CAM_Application::onOpenDoc();
-
+
if ( !study ) // new study will be create in THIS application
{
updateWindows();
}
}
+bool SalomeApp_Application::onOpenDoc( const QString& aName )
+{
+ bool res = CAM_Application::onOpenDoc( aName );
+
+ QAction* a = action( MRUId );
+ if ( a && a->inherits( "QtxMRUAction" ) )
+ {
+ QtxMRUAction* mru = (QtxMRUAction*)a;
+ if ( res )
+ mru->insert( aName );
+ else
+ mru->remove( aName );
+ }
+ return res;
+}
+
+bool SalomeApp_Application::onLoadDoc( const QString& aName )
+{
+ bool res = CAM_Application::onLoadDoc( aName );
+
+ /*jfa tmp:QAction* a = action( MRUId );
+ if ( a && a->inherits( "QtxMRUAction" ) )
+ {
+ QtxMRUAction* mru = (QtxMRUAction*)a;
+ if ( res )
+ mru->insert( aName );
+ else
+ mru->remove( aName );
+ }*/
+ return res;
+}
+
void SalomeApp_Application::onSelection()
{
onSelectionChanged();
((SalomeApp_Module*)activeModule())->selectionChanged();
}
+void SalomeApp_Application::onCopy()
+{
+ SALOME_ListIO list;
+ SalomeApp_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::onPaste()
+{
+ SALOME_ListIO list;
+ SalomeApp_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()->Paste(so);
+ updateObjectBrowser( true );
+ }
+ catch(...) {
+ }
+ }
+}
+
void SalomeApp_Application::onSelectionChanged()
{
+ SALOME_ListIO list;
+ SalomeApp_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;
+
+ QAction* qaction;
+
+ SALOME_ListIteratorOfListIO it( list );
+ if(it.More() && list.Extent() == 1)
+ {
+ _PTR(SObject) so = stdDS->FindObjectID(it.Value()->getEntry());
+
+ qaction = action(EditCopyId);
+ if(studyMgr()->CanCopy(so) ) qaction->setEnabled(true);
+ else qaction->setEnabled(false);
+
+ qaction = action(EditPasteId);
+ if( studyMgr()->CanPaste(so) ) qaction->setEnabled(true);
+ else qaction->setEnabled(false);
+ }
+ else {
+ qaction = action(EditCopyId);
+ qaction->setEnabled(false);
+ qaction = action(EditPasteId);
+ qaction->setEnabled(false);
+ }
+}
+
+void SalomeApp_Application::onRefresh()
+{
+ updateObjectBrowser( true );
+}
+
+
+void SalomeApp_Application::onOpenWith()
+{
+ QApplication::setOverrideCursor( Qt::waitCursor );
+ SALOME_ListIO aList;
+ SalomeApp_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();
+}
+
+bool SalomeApp_Application::useStudy(const QString& theName)
+{
+ createEmptyStudy();
+ SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(activeStudy());
+ bool res = false;
+ if (aStudy)
+ res = aStudy->loadDocument( theName );
+ updateDesktopTitle();
+ updateCommandsStatus();
+ return res;
}
void SalomeApp_Application::setActiveStudy( SUIT_Study* study )
{
CAM_Application::setActiveStudy( study );
-
+
activateWindows();
}
// name : createNewStudy
// 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;
}
//=======================================================================
if ( a )
a->setEnabled( activeStudy() );
}
+
+ // Dump study menu
+ QAction* a = action( DumpStudyId );
+ if ( a )
+ a->setEnabled( activeStudy() );
+
+ // Load script menu
+ a = action( LoadScriptId );
+ if ( a )
+ a->setEnabled( activeStudy() );
+
+ a = action( PropertiesId );
+ if( a )
+ a->setEnabled( activeStudy() );
+
+ a = action(EditCopyId);
+ a->setEnabled(false);
+ a = action(EditPasteId);
+ a->setEnabled(false);
}
//=======================================================================
//=======================================================================
void SalomeApp_Application::onHelpAbout()
{
- //QAD_MessageBox::info1( myDesktop, tr( "ABOUT" ), tr( "APP_NAME_LONG" ).arg( APP_VERSION ), tr( "BUT_OK" ) );
-
- QMessageBox aDlg( desktop(), "AboutDlg" );
-
- SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
- QPixmap aPixmap = aResMgr->loadPixmap( "SalomeApp", tr( "ABOUT_ICO" ) );
-
- QFontMetrics m( aDlg.font() );
- QImage anImage = aPixmap.convertToImage();
- int w = m.height() * 3;
- anImage = anImage.scale( w, w );
- aPixmap.convertFromImage( anImage );
-
- aDlg.setCaption( tr( "ABOUT" ) );
- aDlg.setText( tr( "APP_NAME_LONG" ).arg( APP_VERSION ) );
- aDlg.setIconPixmap( aPixmap );
- aDlg.exec();
+ SalomeApp_AboutDlg* dlg = new SalomeApp_AboutDlg( applicationName(), applicationVersion(), desktop() );
+ dlg->exec();
+ delete dlg;
}
QWidget* SalomeApp_Application::window( const int flag, const int studyId ) const
sId = activeStudy()->id();
}
+ QWidget* wid = myWindows[flag]->widget( sId );
myWindows[flag]->remove( sId );
+ delete wid;
setWindowShown( flag, !myWindows[flag]->isEmpty() );
}
return lw;
}
+PythonConsole* SalomeApp_Application::pythonConsole()
+{
+ PythonConsole* console = 0;
+ QWidget* wid = getWindow( WT_PyConsole );
+ if ( wid->inherits( "PythonConsole" ) )
+ console = (PythonConsole*)wid;
+ return console;
+}
+
+SalomeApp_Preferences* SalomeApp_Application::preferences() const
+{
+ return preferences( false );
+}
+
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 && create )
{
if ( !aVM->getActiveView() )
aVM->createView();
+ else
+ aVM->getActiveView()->setFocus();
}
else if ( create )
aVM = createViewManager( vmType );
+
return aVM;
}
SUIT_ViewManager* SalomeApp_Application::createViewManager( const QString& vmType )
{
+ SUIT_ResourceMgr* resMgr = resourceMgr();
+
SUIT_ViewManager* viewMgr = 0;
if ( vmType == GLViewer_Viewer::Type() )
{
new SalomeApp_GLSelector( (GLViewer_Viewer2d*)viewMgr->getViewModel(), mySelMgr );
}
else if ( vmType == Plot2d_Viewer::Type() )
+ {
viewMgr = new Plot2d_ViewManager( activeStudy(), desktop() );
+ viewMgr->setViewModel( new SPlot2d_Viewer() );// custom view model, which extends SALOME_View interface
+ }
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
+ SOCC_Viewer* vm = new SOCC_Viewer();
+ vm->setBackgroundColor( resMgr->colorValue( "OCCViewer", "background", vm->backgroundColor() ) );
+ vm->setTrihedronSize( resMgr->integerValue( "OCCViewer", "trihedron_size", vm->trihedronSize() ) );
+ int u( 1 ), v( 1 );
+ vm->isos( u, v );
+ u = resMgr->integerValue( "OCCViewer", "iso_number_u", u );
+ v = resMgr->integerValue( "OCCViewer", "iso_number_v", v );
+ vm->setIsos( u, v );
+ viewMgr->setViewModel( vm );// 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() );
+ SVTK_Viewer* vm = (SVTK_Viewer*)viewMgr->getViewModel();
+ vm->setBackgroundColor( resMgr->colorValue( "VTKViewer", "background", vm->backgroundColor() ) );
+ vm->setTrihedronSize( resMgr->integerValue( "VTKViewer", "trihedron_size", vm->trihedronSize() ) );
new SalomeApp_VTKSelector((SVTK_Viewer*)viewMgr->getViewModel(),mySelMgr);
}
objectBrowser()->setRootObject( aRoot );
activateModule( defaultModule() );
+
+ activateWindows();
}
void SalomeApp_Application::onStudyOpened( SUIT_Study* theStudy )
objectBrowser()->setRootObject( aRoot );
}
- activateWindows();
-
activateModule( defaultModule() );
+ activateWindows();
+
emit studyOpened();
}
emit studyClosed();
activateModule( "" );
- if ( objectBrowser() != 0 )
+
+ saveWindowsGeometry();
+}
+
+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);
+ aStudy->DumpStudy( aFileInfo.dirPath( true ).latin1(), aFileInfo.baseName().latin1(), toPublish );
+ }
+}
+
+void SalomeApp_Application::onLoadScript( )
+{
+ SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( activeStudy() );
+ if ( !appStudy ) return;
+ _PTR(Study) aStudy = appStudy->studyDS();
+
+ if ( aStudy->GetProperties()->IsLocked() ) {
+ SUIT_MessageBox::warn1 ( desktop(),
+ QObject::tr("WRN_WARNING"),
+ QObject::tr("WRN_STUDY_LOCKED"),
+ QObject::tr("BUT_OK") );
+ return;
+ }
+
+ QStringList filtersList;
+ filtersList.append(tr("PYTHON_FILES_FILTER"));
+ filtersList.append(tr("ALL_FILES_FILTER"));
+
+ QString aFile = SUIT_FileDlg::getFileName( desktop(), "", filtersList, tr( "TOT_DESK_FILE_LOAD_SCRIPT" ), true, true );
+
+ if ( !aFile.isEmpty() )
{
- objectBrowser()->setRootObject( 0 );
+ QString command = QString("execfile(\"%1\")").arg(aFile);
+
+ PythonConsole* pyConsole = pythonConsole();
+
+ if ( pyConsole )
+ pyConsole->exec( command );
}
+}
- saveWindowsGeometry();
+void SalomeApp_Application::onPreferences()
+{
+ QApplication::setOverrideCursor( Qt::waitCursor );
+
+ SalomeApp_PreferencesDlg* prefDlg = new SalomeApp_PreferencesDlg( preferences( true ), desktop());
+
+ QApplication::restoreOverrideCursor();
+
+ if ( !prefDlg )
+ return;
+
+ prefDlg->exec();
+
+ delete prefDlg;
+}
+
+void SalomeApp_Application::onMRUActivated( QString aName )
+{
+ onOpenDoc( aName );
+}
+
+void SalomeApp_Application::onPreferenceChanged( QString& modName, QString& section, QString& param )
+{
+ SalomeApp_Module* sMod = 0;
+ CAM_Module* mod = module( modName );
+ if ( mod && mod->inherits( "SalomeApp_Module" ) )
+ sMod = (SalomeApp_Module*)mod;
+
+ if ( sMod )
+ sMod->preferencesChanged( section, param );
+ else
+ preferencesChanged( section, param );
}
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();
{
QWidget* wid = 0;
+ 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->setAutoUpdate( true );
+ ob->setFilter( new SalomeApp_OBFilter( selectionMgr() ) );
+
+ ob->setNameTitle( tr( "OBJ_BROWSER_NAME" ) );
+
+ 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 ) );
+ }
// Create OBSelector
new SalomeApp_OBSelector( ob, mySelMgr );
logWin->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
}
-
+
return wid;
}
{
aMap.insert( WT_ObjectBrowser, Qt::DockLeft );
aMap.insert( WT_PyConsole, Qt::DockBottom );
+ // aMap.insert( WT_LogWindow, Qt::DockBottom );
}
void SalomeApp_Application::defaultViewManagers( QStringList& ) const
{
}
-CORBA::ORB_var SalomeApp_Application::orb()
+SalomeApp_Preferences* SalomeApp_Application::preferences( const bool crt ) const
{
- ORB_INIT& init = *SINGLETON_<ORB_INIT>::Instance();
- CORBA::ORB_var& orb = init( qApp->argc(), qApp->argv() );
+ if ( myPrefs )
+ return myPrefs;
+
+ SalomeApp_Application* that = (SalomeApp_Application*)this;
+
+ if ( !_prefs_ && crt )
+ {
+ _prefs_ = new SalomeApp_Preferences( resourceMgr() );
+ that->createPreferences( _prefs_ );
+ }
+
+ that->myPrefs = _prefs_;
+
+ QPtrList<SUIT_Application> appList = SUIT_Session::session()->applications();
+ for ( QPtrListIterator<SUIT_Application> appIt ( appList ); appIt.current(); ++appIt )
+ {
+ if ( !appIt.current()->inherits( "SalomeApp_Application" ) )
+ continue;
+
+ SalomeApp_Application* app = (SalomeApp_Application*)appIt.current();
+
+ QStringList modNameList;
+ app->modules( modNameList, false );
+ for ( QStringList::const_iterator it = modNameList.begin(); it != modNameList.end(); ++it )
+ {
+ int id = _prefs_->addPreference( *it );
+ _prefs_->setProperty( id, "info", tr( "PREFERENCES_NOT_LOADED" ).arg( *it ) );
+ }
- return orb;
+ ModuleList modList;
+ app->modules( modList );
+ for ( ModuleListIterator itr( modList ); itr.current(); ++itr )
+ {
+ SalomeApp_Module* mod = 0;
+ if ( itr.current()->inherits( "SalomeApp_Module" ) )
+ mod = (SalomeApp_Module*)itr.current();
+
+ if ( mod && !_prefs_->hasModule( mod->moduleName() ) )
+ mod->createPreferences();
+ }
+ }
+
+ connect( myPrefs, SIGNAL( preferenceChanged( QString&, QString&, QString& ) ),
+ this, SLOT( onPreferenceChanged( QString&, QString&, QString& ) ) );
+
+ return myPrefs;
}
-SALOMEDSClient_StudyManager* SalomeApp_Application::studyMgr()
+void SalomeApp_Application::moduleAdded( CAM_Module* mod )
{
- static SALOMEDSClient_StudyManager* aStudyManager = NULL;
+ CAM_Application::moduleAdded( mod );
+
+ SalomeApp_Module* salomeMod = 0;
+ if ( mod && mod->inherits( "SalomeApp_Module" ) )
+ salomeMod = (SalomeApp_Module*)mod;
+
+ if ( myPrefs && salomeMod && !myPrefs->hasModule( salomeMod->moduleName() ))
+ salomeMod->createPreferences();
+}
+
+void SalomeApp_Application::createPreferences( SalomeApp_Preferences* pref )
+{
+ if ( !pref )
+ return;
+
+ int salomeCat = pref->addPreference( tr( "PREF_CATEGORY_SALOME" ) );
+
+ int genTab = pref->addPreference( tr( "PREF_TAB_GENERAL" ), salomeCat );
+
+ int obGroup = pref->addPreference( tr( "PREF_GROUP_OBJBROWSER" ), genTab );
+ for ( int i = SalomeApp_DataObject::CT_Value; i <= SalomeApp_DataObject::CT_RefEntry; i++ )
+ {
+ pref->addPreference( tr( QString().sprintf( "OBJ_BROWSER_COLUMN_%d", i ) ), obGroup,
+ SalomeApp_Preferences::Bool, "ObjectBrowser", QString().sprintf( "visibility_column_%d", i ) );
+ }
+ pref->setProperty( obGroup, "columns", 1 );
+
+ int viewTab = pref->addPreference( tr( "PREF_TAB_VIEWERS" ), salomeCat );
+
+ int occGroup = pref->addPreference( tr( "PREF_GROUP_OCCVIEWER" ), viewTab );
+
+ int vtkGroup = pref->addPreference( tr( "PREF_GROUP_VTKVIEWER" ), viewTab );
+ pref->setProperty( occGroup, "columns", 1 );
+ pref->setProperty( vtkGroup, "columns", 1 );
+
+ int occTS = pref->addPreference( tr( "PREF_TRIHEDRON_SIZE" ), occGroup,
+ SalomeApp_Preferences::IntSpin, "OCCViewer", "trihedron_size" );
+ pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), occGroup,
+ SalomeApp_Preferences::Color, "OCCViewer", "background" );
+
+ pref->setProperty( occTS, "min", 1 );
+ pref->setProperty( occTS, "max", 150 );
+
+ int isoU = pref->addPreference( tr( "PREF_ISOS_U" ), occGroup,
+ SalomeApp_Preferences::IntSpin, "OCCViewer", "iso_number_u" );
+ int isoV = pref->addPreference( tr( "PREF_ISOS_V" ), occGroup,
+ SalomeApp_Preferences::IntSpin, "OCCViewer", "iso_number_v" );
+
+ pref->setProperty( isoU, "min", 0 );
+ pref->setProperty( isoU, "max", 100000 );
+
+ pref->setProperty( isoV, "min", 0 );
+ pref->setProperty( isoV, "max", 100000 );
+
+ int vtkTS = pref->addPreference( tr( "PREF_TRIHEDRON_SIZE" ), vtkGroup,
+ SalomeApp_Preferences::IntSpin, "VTKViewer", "trihedron_size" );
+ pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), vtkGroup,
+ SalomeApp_Preferences::Color, "VTKViewer", "background" );
+
+ pref->setProperty( vtkTS, "min", 1 );
+ pref->setProperty( vtkTS, "max", 150 );
+}
+
+void SalomeApp_Application::preferencesChanged( const QString& sec, const QString& param )
+{
+ SUIT_ResourceMgr* resMgr = resourceMgr();
+ if ( !resMgr )
+ return;
+
+ if ( sec == QString( "OCCViewer" ) && param == QString( "trihedron_size" ) )
+ {
+ int sz = resMgr->integerValue( sec, param, -1 );
+ QPtrList<SUIT_ViewManager> lst;
+ viewManagers( OCCViewer_Viewer::Type(), lst );
+ for ( QPtrListIterator<SUIT_ViewManager> it( lst ); it.current() && sz >= 0; ++it )
+ {
+ SUIT_ViewModel* vm = it.current()->getViewModel();
+ if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
+ continue;
+
+ OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
+ occVM->setTrihedronSize( sz );
+ occVM->getAISContext()->UpdateCurrentViewer();
+ }
+ }
+
+ if ( sec == QString( "VTKViewer" ) && param == QString( "trihedron_size" ) )
+ {
+ int sz = resMgr->integerValue( sec, param, -1 );
+ QPtrList<SUIT_ViewManager> lst;
+ viewManagers( SVTK_Viewer::Type(), lst );
+ for ( QPtrListIterator<SUIT_ViewManager> it( lst ); it.current() && sz >= 0; ++it )
+ {
+ SUIT_ViewModel* vm = it.current()->getViewModel();
+ if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
+ continue;
+
+ SVTK_Viewer* vtkVM = (SVTK_Viewer*)vm;
+ vtkVM->setTrihedronSize( sz );
+ vtkVM->Repaint();
+ }
+ }
- if(!aStudyManager) {
- aStudyManager = new SALOMEDS_StudyManager();
+ if ( sec == QString( "OCCViewer" ) && ( param == QString( "iso_number_u" ) || param == QString( "iso_number_v" ) ) )
+ {
+ QPtrList<SUIT_ViewManager> lst;
+ viewManagers( OCCViewer_Viewer::Type(), lst );
+ int u = resMgr->integerValue( sec, "iso_number_u" );
+ int v = resMgr->integerValue( sec, "iso_number_v" );
+ for ( QPtrListIterator<SUIT_ViewManager> it( lst ); it.current(); ++it )
+ ((OCCViewer_Viewer*)it.current())->setIsos( u, v );
}
- return aStudyManager;
+
+}
+
+void SalomeApp_Application::afterCloseDoc()
+{
+ updateWindows();
+
+ CAM_Application::afterCloseDoc();
+}
+
+CORBA::ORB_var SalomeApp_Application::orb()
+{
+ ORB_INIT& init = *SINGLETON_<ORB_INIT>::Instance();
+ static CORBA::ORB_var _orb = init( qApp->argc(), qApp->argv() );
+ return _orb;
+}
+
+SALOMEDSClient_StudyManager* SalomeApp_Application::studyMgr()
+{
+ static SALOMEDSClient_StudyManager* _sm = new SALOMEDS_StudyManager();
+ return _sm;
}
SALOME_NamingService* SalomeApp_Application::namingService()
{
- return new SALOME_NamingService( orb() );
+ static SALOME_NamingService* _ns = new SALOME_NamingService( orb() );
+ return _ns;
+}
+
+SALOME_LifeCycleCORBA* SalomeApp_Application::lcc()
+{
+ static SALOME_LifeCycleCORBA* _lcc = new SALOME_LifeCycleCORBA( namingService() );
+ return _lcc;
}
QString SalomeApp_Application::defaultEngineIOR()
QString modName;
if ( activeModule() )
modName = moduleLibrary( activeModule()->moduleName(), false );
-
+
QString section = QString( "windows_geometry" );
if ( !modName.isEmpty() )
section += QString( "." ) + modName;
-
dockMgr->loadGeometry( resourceMgr(), section, false );
dockMgr->restoreGeometry();
}
QString modName;
if ( activeModule() )
modName = moduleLibrary( activeModule()->moduleName(), false );
-
+
QString section = QString( "windows_geometry" );
if ( !modName.isEmpty() )
section += QString( "." ) + modName;
itr.data()->activate( activeStudy()->id() );
}
}
+
+void SalomeApp_Application::onProperties()
+{
+ SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( activeStudy() );
+ if( !study )
+ return;
+
+ _PTR(StudyBuilder) SB = study->studyDS()->NewBuilder();
+ SB->NewCommand();
+
+ SalomeApp_StudyPropertiesDlg aDlg( desktop() );
+ int res = aDlg.exec();
+ if( res==QDialog::Accepted && aDlg.isChanged() )
+ SB->CommitCommand();
+ else
+ SB->AbortCommand();
+
+ //study->updateCaptions();
+}
+
+QString SalomeApp_Application::getFileName( bool open, const QString& initial, const QString& filters,
+ const QString& caption, QWidget* parent )
+{
+ if ( !parent )
+ parent = desktop();
+ QStringList fls = QStringList::split( ";;", filters, false );
+ return SUIT_FileDlg::getFileName( parent, initial, fls, caption, open, true );
+}
+
+QString SalomeApp_Application::getDirectory( const QString& initial, const QString& caption, QWidget* parent )
+{
+ if ( !parent )
+ parent = desktop();
+ return SUIT_FileDlg::getExistingDirectory( parent, initial, caption, true );
+}
+
+QStringList SalomeApp_Application::getOpenFileNames( const QString& initial, const QString& filters,
+ const QString& caption, QWidget* parent )
+{
+ if ( !parent )
+ parent = desktop();
+ QStringList fls = QStringList::split( ";;", filters, false );
+ return SUIT_FileDlg::getOpenFileNames( parent, initial, fls, caption, true );
+}
+
+void SalomeApp_Application::contextMenuPopup( const QString& type, QPopupMenu* thePopup, QString& title )
+{
+ CAM_Application::contextMenuPopup( type, thePopup, title );
+ thePopup->insertSeparator();
+ thePopup->insertItem( tr( "MEN_REFRESH" ), this, SLOT( onRefresh() ) );
+
+ // "Activate module" item should appear only if it's necessary
+ OB_Browser* ob = objectBrowser();
+ if ( !ob || type != ob->popupClientType() )
+ return;
+ SALOME_ListIO aList;
+ SalomeApp_SelectionMgr* mgr = selectionMgr();
+ mgr->selectedObjects(aList);
+ 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::updateObjectBrowser( const bool updateModels )
+{
+ if ( updateModels )
+ {
+ for ( ModuleListIterator it = modules(); it.current(); ++it )
+ {
+ CAM_DataModel* camDM = it.current()->dataModel();
+ if ( camDM && camDM->inherits( "SalomeApp_DataModel" ) )
+ ((SalomeApp_DataModel*)camDM)->update();
+ }
+ }
+ if ( objectBrowser() )
+ objectBrowser()->updateTree();
+}
+
+
+//************************************************************
+void SalomeApp_Application::onDesktopActivated()
+{
+ CAM_Application::onDesktopActivated();
+ SalomeApp_Module* aModule = dynamic_cast<SalomeApp_Module*>(activeModule());
+ if(aModule)
+ aModule->studyActivated();
+}