From c147262d8e6bbb5cc616ada2e51341e9b7767ee1 Mon Sep 17 00:00:00 2001 From: stv Date: Fri, 17 Jun 2005 12:38:56 +0000 Subject: [PATCH] Preferences edition. --- src/OCCViewer/OCCViewer_ViewModel.cxx | 59 +++- src/OCCViewer/OCCViewer_ViewModel.h | 30 +- src/STD/STD_Application.h | 2 +- src/SVTK/SVTK_ViewModel.cxx | 29 +- src/SVTK/SVTK_ViewModel.h | 10 +- src/SalomeApp/SalomeApp_Application.cxx | 318 ++++++++++++++++---- src/SalomeApp/SalomeApp_Application.h | 31 +- src/SalomeApp/SalomeApp_Module.cxx | 58 +++- src/SalomeApp/SalomeApp_Module.h | 14 + src/SalomeApp/SalomeApp_PreferencesDlg.cxx | 68 ++--- src/SalomeApp/SalomeApp_PreferencesDlg.h | 40 +-- src/SalomeApp/resources/SalomeApp_msg_en.po | 126 +++++--- src/VTKViewer/VTKViewer_ViewModel.cxx | 20 +- src/VTKViewer/VTKViewer_ViewModel.h | 10 +- src/VTKViewer/VTKViewer_ViewWindow.cxx | 6 +- 15 files changed, 586 insertions(+), 235 deletions(-) diff --git a/src/OCCViewer/OCCViewer_ViewModel.cxx b/src/OCCViewer/OCCViewer_ViewModel.cxx index c2dce07d2..407de6013 100755 --- a/src/OCCViewer/OCCViewer_ViewModel.cxx +++ b/src/OCCViewer/OCCViewer_ViewModel.cxx @@ -23,9 +23,10 @@ #include OCCViewer_Viewer::OCCViewer_Viewer( bool DisplayTrihedron ) -:SUIT_ViewModel() +: SUIT_ViewModel(), +myBgColor( Qt::black ) { - // init CasCade viewers + // init CasCade viewers myV3dViewer = OCCViewer_VService::Viewer3d( "", (short*) "Viewer3d", "", 1000., V3d_XposYnegZpos, true, true ); @@ -73,11 +74,26 @@ OCCViewer_Viewer::~OCCViewer_Viewer() { } +QColor OCCViewer_Viewer::backgroundColor() const +{ + return myBgColor; +} + +void OCCViewer_Viewer::setBackgroundColor( const QColor& c ) +{ + if ( c.isValid() ) + myBgColor = c; +} -SUIT_ViewWindow* OCCViewer_Viewer::createView(SUIT_Desktop* theDesktop) +SUIT_ViewWindow* OCCViewer_Viewer::createView( SUIT_Desktop* theDesktop ) { OCCViewer_ViewWindow* res = new OCCViewer_ViewWindow(theDesktop, this); res->initLayout(); + + OCCViewer_ViewPort3d* vp3d = res->getViewPort(); + if ( vp3d ) + vp3d->setBackgroundColor( myBgColor ); + return res; } @@ -377,10 +393,35 @@ void OCCViewer_Viewer::setTransparency( const Handle(AIS_InteractiveObject)& obj //**************************************************************** void OCCViewer_Viewer::toggleTrihedron() { - if (myTrihedron.IsNull()) return; - if (myAISContext->IsDisplayed(myTrihedron)) { - myAISContext->Erase(myTrihedron); - } else { - myAISContext->Display(myTrihedron); - } + setTrihedronShown( !isTrihedronVisible() ); +} + +bool OCCViewer_Viewer::isTrihedronVisible() const +{ + return !myTrihedron.IsNull() && !myAISContext.IsNull() && myAISContext->IsDisplayed( myTrihedron ); +} + +void OCCViewer_Viewer::setTrihedronShown( const bool on ) +{ + if ( myTrihedron.IsNull() ) + return; + + if ( on ) + myAISContext->Erase( myTrihedron ); + else + myAISContext->Display( myTrihedron ); +} + +int OCCViewer_Viewer::trihedronSize() const +{ + int sz = 0; + if ( !myTrihedron.IsNull() ) + sz = myTrihedron->Size(); + return sz; +} + +void OCCViewer_Viewer::setTrihedronSize( const int sz ) +{ + if ( !myTrihedron.IsNull() ) + myTrihedron->SetSize( sz ); } diff --git a/src/OCCViewer/OCCViewer_ViewModel.h b/src/OCCViewer/OCCViewer_ViewModel.h index 537215f2f..08bf29f06 100755 --- a/src/OCCViewer/OCCViewer_ViewModel.h +++ b/src/OCCViewer/OCCViewer_ViewModel.h @@ -1,6 +1,7 @@ #ifndef OCCVIEWER_VIEWMODEL_H #define OCCVIEWER_VIEWMODEL_H +#include #include #include "OCCViewer.h" @@ -48,7 +49,7 @@ public: static QString Type() { return "OCCViewer"; } OCCViewer_Viewer( bool DisplayTrihedron = true ); - virtual ~OCCViewer_Viewer(); + virtual ~OCCViewer_Viewer(); void update(); @@ -72,13 +73,22 @@ public: virtual void updateViewAspects( const viewAspectList& ); virtual void clearViewAspects(); + QColor backgroundColor() const; + void setBackgroundColor( const QColor& ); + //! returns true if 3d Trihedron in viewer was created - bool trihedronActivated() const { return !myTrihedron.IsNull(); } - virtual void toggleTrihedron(); + bool trihedronActivated() const { return !myTrihedron.IsNull(); } -public slots: - void onClearViewAspects(); + void toggleTrihedron(); + bool isTrihedronVisible() const; + virtual void setTrihedronShown( const bool ); + int trihedronSize() const; + virtual void setTrihedronSize( const int ); + +public slots: + void onClearViewAspects(); + public: Handle(V3d_Viewer) getViewer3d() const { return myV3dViewer;} Handle(V3d_Viewer) getCollector3d() const { return myV3dCollector; } @@ -121,15 +131,17 @@ protected slots: private: Handle(V3d_Viewer) myV3dViewer; Handle(V3d_Viewer) myV3dCollector; - Handle(AIS_InteractiveContext) myAISContext; + Handle(AIS_Trihedron) myTrihedron; + Handle(AIS_InteractiveContext) myAISContext; viewAspectList myViewAspects; - bool mySelectionEnabled; - bool myMultiSelectionEnabled; + bool mySelectionEnabled; + bool myMultiSelectionEnabled; - QPoint myStartPnt, myEndPnt; + QColor myBgColor; + QPoint myStartPnt, myEndPnt; }; #ifdef WIN32 diff --git a/src/STD/STD_Application.h b/src/STD/STD_Application.h index 3740d4d79..1aec6c5d1 100755 --- a/src/STD/STD_Application.h +++ b/src/STD/STD_Application.h @@ -56,7 +56,7 @@ public: void viewManagers( const QString&, ViewManagerList& ) const; virtual QString getFileFilter() const { return QString::null; } - QString getFileName( bool open, const QString& initial, const QString& filters, + virtual QString getFileName( bool open, const QString& initial, const QString& filters, const QString& caption, QWidget* parent ); virtual void start(); diff --git a/src/SVTK/SVTK_ViewModel.cxx b/src/SVTK/SVTK_ViewModel.cxx index a9faa92cf..5ff086950 100644 --- a/src/SVTK/SVTK_ViewModel.cxx +++ b/src/SVTK/SVTK_ViewModel.cxx @@ -49,29 +49,36 @@ static _PTR(Study) getStudyDS() } //========================================================== -SVTK_Viewer -::SVTK_Viewer() +SVTK_Viewer::SVTK_Viewer() { } //========================================================== -SVTK_Viewer -::~SVTK_Viewer() +SVTK_Viewer::~SVTK_Viewer() +{ +} + +QColor SVTK_Viewer::backgroundColor() const { + return myBgColor; +} + +void SVTK_Viewer::setBackgroundColor( const QColor& c ) +{ + if ( c.isValid() ) + myBgColor = c; } //========================================================== -SUIT_ViewWindow* -SVTK_Viewer -::createView( SUIT_Desktop* theDesktop ) +SUIT_ViewWindow* SVTK_Viewer::createView( SUIT_Desktop* theDesktop ) { - return new SVTK_ViewWindow( theDesktop, this ); + SVTK_ViewWindow* vw = new SVTK_ViewWindow( theDesktop, this ); + vw->setBackgroundColor( backgroundColor() ); + return vw; } //========================================================== -void -SVTK_Viewer -::setViewManager(SUIT_ViewManager* theViewManager) +void SVTK_Viewer::setViewManager(SUIT_ViewManager* theViewManager) { SUIT_ViewModel::setViewManager(theViewManager); diff --git a/src/SVTK/SVTK_ViewModel.h b/src/SVTK/SVTK_ViewModel.h index e780757c5..fbf1c14b3 100644 --- a/src/SVTK/SVTK_ViewModel.h +++ b/src/SVTK/SVTK_ViewModel.h @@ -7,6 +7,8 @@ #include "SALOME_Prs.h" #include "SALOME_InteractiveObject.hxx" +#include + class SVTK_EXPORT SVTK_Viewer : public SUIT_ViewModel, public SALOME_View { Q_OBJECT; @@ -23,6 +25,9 @@ public: virtual void contextMenuPopup( QPopupMenu* ); virtual QString getType() const { return Type(); } + QColor backgroundColor() const; + void setBackgroundColor( const QColor& ); + public: void enableSelection(bool isEnabled); bool isSelectionEnabled() const { return mySelectionEnabled; } @@ -62,8 +67,9 @@ protected slots: void onChangeBgColor(); private: - bool mySelectionEnabled; - bool myMultiSelectionEnabled; + QColor myBgColor; + bool mySelectionEnabled; + bool myMultiSelectionEnabled; }; #endif diff --git a/src/SalomeApp/SalomeApp_Application.cxx b/src/SalomeApp/SalomeApp_Application.cxx index 817bc404b..29c44c9b3 100644 --- a/src/SalomeApp/SalomeApp_Application.cxx +++ b/src/SalomeApp/SalomeApp_Application.cxx @@ -17,6 +17,7 @@ #include "SalomeApp_AboutDlg.h" #include "SalomeApp_ModuleDlg.h" +#include "SalomeApp_Preferences.h" #include "SalomeApp_PreferencesDlg.h" #include "SalomeApp_StudyPropertiesDlg.h" @@ -46,7 +47,9 @@ #include #include +#include #include +#include #include @@ -108,6 +111,8 @@ extern "C" SALOMEAPP_EXPORT SUIT_Application* createApplication() return new SalomeApp_Application(); } +SalomeApp_Preferences* SalomeApp_Application::_prefs_ = 0; + /* Class : SalomeApp_Application Description : Application containing SalomeApp module @@ -115,7 +120,7 @@ extern "C" SALOMEAPP_EXPORT SUIT_Application* createApplication() SalomeApp_Application::SalomeApp_Application() : CAM_Application( false ), -myPrefDlg( 0 ) +myPrefs( 0 ) { STD_TabDesktop* desk = new STD_TabDesktop(); @@ -173,8 +178,8 @@ void SalomeApp_Application::start() putInfo( "" ); } -QString SalomeApp_Application::applicationName() const -{ +QString SalomeApp_Application::applicationName() const +{ return tr( "APP_NAME" ); } @@ -188,7 +193,7 @@ QString SalomeApp_Application::applicationVersion() const if ( !path.isEmpty() ) path += QDir::separator(); path += QString( "bin/salome/VERSION" ); - + QFile vf( path ); if ( vf.open( IO_ReadOnly ) ) { @@ -260,20 +265,27 @@ void SalomeApp_Application::createActions() SUIT_Desktop* desk = desktop(); SUIT_ResourceMgr* resMgr = resourceMgr(); - + // Load script - createAction( LoadScriptId, tr( "TOT_DESK_FILE_LOAD_SCRIPT" ), QIconSet(), - tr( "MEN_DESK_FILE_LOAD_SCRIPT" ), tr( "PRP_DESK_FILE_LOAD_SCRIPT" ), + createAction( LoadScriptId, tr( "TOT_DESK_LOADSCRIPT" ), QIconSet(), + tr( "MEN_DESK_LOADSCRIPT" ), tr( "PRP_DESK_LOADSCRIPT" ), 0, desk, false, this, SLOT( onLoadScript() ) ); - int fileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1 ); - createMenu( LoadScriptId, fileMenu, 10, -1 ); - createAction( PropertiesId, tr( "TOT_DESK_FILE_PROPERTIES" ), QIconSet(), - tr( "MEN_DESK_FILE_PROPERTIES" ), tr( "PRP_DESK_FILE_PROPERTIES" ), + // Properties + createAction( PropertiesId, tr( "TOT_DESK_PROPERTIES" ), QIconSet(), + tr( "MEN_DESK_PROPERTIES" ), tr( "PRP_DESK_PROPERTIES" ), 0, desk, false, this, SLOT( onProperties() ) ); - createMenu( PropertiesId, fileMenu, 10, -1 ); - + // 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" ) ); if ( defIcon.isNull() ) @@ -332,7 +344,7 @@ void SalomeApp_Application::createActions() } SUIT_Tools::simplifySeparators( modTBar ); - + // New window int windowMenu = createMenu( tr( "MEN_DESK_WINDOW" ), -1, 100 ); @@ -347,14 +359,31 @@ void SalomeApp_Application::createActions() for ( int id = NewGLViewId; id <= NewVTKViewId; id++ ) { - QAction* a = createAction( id, tr( QString( "NEW_WINDOW_%1" ).arg( id - NewGLViewId ) ), QIconSet(), + 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( separator(), fileMenu, -1, 15, -1 ); + createMenu( LoadScriptId, fileMenu, 15, -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 ) @@ -446,7 +475,7 @@ void SalomeApp_Application::onNewDoc() saveWindowsGeometry(); CAM_Application::onNewDoc(); - + if ( !study ) // new study will be create in THIS application { updateWindows(); @@ -464,7 +493,7 @@ void SalomeApp_Application::onOpenDoc() saveWindowsGeometry(); CAM_Application::onOpenDoc(); - + if ( !study ) // new study will be create in THIS application { updateWindows(); @@ -472,6 +501,22 @@ void SalomeApp_Application::onOpenDoc() } } +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; +} + void SalomeApp_Application::onSelection() { onSelectionChanged(); @@ -542,7 +587,7 @@ void SalomeApp_Application::onRefresh() void SalomeApp_Application::setActiveStudy( SUIT_Study* study ) { CAM_Application::setActiveStudy( study ); - + activateWindows(); } @@ -550,17 +595,17 @@ void SalomeApp_Application::setActiveStudy( SUIT_Study* study ) // 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; } //======================================================================= @@ -736,29 +781,9 @@ PythonConsole* SalomeApp_Application::pythonConsole() return console; } -QtxResourceEdit* SalomeApp_Application::resourceEdit() const +SalomeApp_Preferences* SalomeApp_Application::preferences() const { - return 0; - /* - QtxResourceEdit* edit = 0; - if ( !myPrefDlg ) - { - SalomeApp_Application* that = (SalomeApp_Application*)this; - that->myPrefDlg = new SalomeApp_PreferencesDlg( that->desktop() ); - - edit = myPrefDlg->resourceEdit(); - - QStringList modList; - modules( modList, false ); - for ( QStringList::const_iterator it = modList.begin(); it != modList.end(); ++it ) - { - int id = edit->addItem( *it ); - edit->setProperty( id, "info", tr( "PREFERENCES_NOT_LOADED" ).arg( *it ) ); - } - } - else - edit = myPrefDlg->resourceEdit(); - */ + return preferences( false ); } SUIT_ViewManager* SalomeApp_Application::getViewManager( const QString& vmType, const bool create ) @@ -784,6 +809,8 @@ SUIT_ViewManager* SalomeApp_Application::getViewManager( const QString& vmType, SUIT_ViewManager* SalomeApp_Application::createViewManager( const QString& vmType ) { + SUIT_ResourceMgr* resMgr = resourceMgr(); + SUIT_ViewManager* viewMgr = 0; if ( vmType == GLViewer_Viewer::Type() ) { @@ -798,12 +825,17 @@ SUIT_ViewManager* SalomeApp_Application::createViewManager( const QString& vmTyp 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() ) ); + 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() ) ); new SalomeApp_VTKSelector((SVTK_Viewer*)viewMgr->getViewModel(),mySelMgr); } @@ -881,30 +913,66 @@ void SalomeApp_Application::onLoadScript( ) SalomeApp_Study* appStudy = dynamic_cast( activeStudy() ); if ( !appStudy ) return; _PTR(Study) aStudy = appStudy->studyDS(); - + if ( aStudy->GetProperties()->IsLocked() ) { SUIT_MessageBox::warn1 ( desktop(), - QObject::tr("WRN_WARNING"), + 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()) { + + QString aFile = SUIT_FileDlg::getFileName( desktop(), "", filtersList, tr( "TOT_DESK_LOADSCRIPT" ), true, true ); + + if ( !aFile.isEmpty() ) + { QString command = QString("execfile(\"%1\")").arg(aFile); - + PythonConsole* pyConsole = pythonConsole(); - - if(pyConsole) - pyConsole->exec(command); + + if ( pyConsole ) + pyConsole->exec( command ); } } +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)"; @@ -927,6 +995,8 @@ QWidget* SalomeApp_Application::createWindow( const int flag ) { QWidget* wid = 0; + SUIT_ResourceMgr* resMgr = resourceMgr(); + if ( flag == WT_ObjectBrowser ) { OB_Browser* ob = new OB_Browser( desktop() ); @@ -937,8 +1007,13 @@ QWidget* SalomeApp_Application::createWindow( const int flag ) 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 ); @@ -971,13 +1046,135 @@ void SalomeApp_Application::defaultWindows( QMap& aMap ) const { aMap.insert( WT_ObjectBrowser, Qt::DockLeft ); aMap.insert( WT_PyConsole, Qt::DockBottom ); - aMap.insert( WT_LogWindow, Qt::DockBottom ); + // aMap.insert( WT_LogWindow, Qt::DockBottom ); } void SalomeApp_Application::defaultViewManagers( QStringList& ) const { } +SalomeApp_Preferences* SalomeApp_Application::preferences( const bool crt ) const +{ + 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 appList = SUIT_Session::session()->applications(); + for ( QPtrListIterator 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 ) ); + } + + 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; +} + +void SalomeApp_Application::moduleAdded( CAM_Module* mod ) +{ + 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 ); + + 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->addPreference( tr( "PREF_TRIHEDRON_SIZE" ), vtkGroup, + SalomeApp_Preferences::IntSpin, "VTKViewer", "trihedron_size" ); + pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), vtkGroup, + SalomeApp_Preferences::Color, "VTKViewer", "background" ); +} + +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 lst; + viewManagers( OCCViewer_Viewer::Type(), lst ); + for ( QPtrListIterator 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(); + } + } +} + void SalomeApp_Application::afterCloseDoc() { updateWindows(); @@ -1118,7 +1315,7 @@ void SalomeApp_Application::loadWindowsGeometry() QString modName; if ( activeModule() ) modName = moduleLibrary( activeModule()->moduleName(), false ); - + QString section = QString( "windows_geometry" ); if ( !modName.isEmpty() ) section += QString( "." ) + modName; @@ -1141,7 +1338,7 @@ void SalomeApp_Application::saveWindowsGeometry() QString modName; if ( activeModule() ) modName = moduleLibrary( activeModule()->moduleName(), false ); - + QString section = QString( "windows_geometry" ); if ( !modName.isEmpty() ) section += QString( "." ) + modName; @@ -1184,6 +1381,7 @@ QString SalomeApp_Application::getFileName( bool open, const QString& initial, c if ( !parent ) parent = desktop(); QStringList fls = QStringList::split( ";", filters, false ); + return SUIT_FileDlg::getFileName( parent, initial, fls, caption, open, true ); } diff --git a/src/SalomeApp/SalomeApp_Application.h b/src/SalomeApp/SalomeApp_Application.h index 66f10f1d8..cb7ea6c72 100644 --- a/src/SalomeApp/SalomeApp_Application.h +++ b/src/SalomeApp/SalomeApp_Application.h @@ -28,10 +28,9 @@ class QDockWindow; class LogWindow; class OB_Browser; class PythonConsole; -class QtxResourceEdit; class SalomeApp_Module; +class SalomeApp_Preferences; class SalomeApp_SelectionMgr; -class SalomeApp_PreferencesDlg; class SalomeApp_WidgetContainer; class SALOME_LifeCycleCORBA; @@ -53,7 +52,8 @@ public: typedef enum { WT_ObjectBrowser, WT_PyConsole, WT_LogWindow, WT_User } WindowTypes; enum { ModulesListId = STD_Application::UserID, NewGLViewId, - NewPlot2dId, NewOCCViewId, NewVTKViewId, LoadScriptId, PropertiesId, UserID }; + NewPlot2dId, NewOCCViewId, NewVTKViewId, LoadScriptId, + PropertiesId, PreferencesId, MRUId, UserID }; public: SalomeApp_Application(); @@ -71,10 +71,10 @@ public: OB_Browser* objectBrowser(); PythonConsole* pythonConsole(); - QtxResourceEdit* resourceEdit() const; + SalomeApp_Preferences* preferences() const; virtual QString getFileFilter() const; - QString getFileName( bool open, const QString& initial, const QString& filters, + virtual QString getFileName( bool open, const QString& initial, const QString& filters, const QString& caption, QWidget* parent ); SUIT_ViewManager* getViewManager( const QString&, const bool ); @@ -109,6 +109,7 @@ public slots: virtual void onNewDoc(); virtual void onOpenDoc(); virtual void onHelpAbout(); + virtual bool onOpenDoc( const QString& ); private slots: void onSelection(); @@ -130,6 +131,13 @@ protected: virtual void beforeCloseDoc( SUIT_Study* ); virtual void afterCloseDoc(); + virtual void moduleAdded( CAM_Module* ); + + SalomeApp_Preferences* preferences( const bool ) const; + + virtual void createPreferences( SalomeApp_Preferences* ); + virtual void preferencesChanged( const QString&, const QString& ); + private slots: void onNewWindow(); void onModuleActivation( QAction* ); @@ -140,8 +148,13 @@ private slots: void onStudySaved( SUIT_Study* ); void onStudyClosed( SUIT_Study* ); - void onLoadScript(); void onProperties(); + void onLoadScript(); + + void onPreferences(); + void onMRUActivated( QString ); + + void onPreferenceChanged( QString&, QString&, QString& ); private: void updateWindows(); @@ -151,6 +164,8 @@ private: void loadWindowsGeometry(); void saveWindowsGeometry(); + void updatePreference( const QString&, const QString&, const QString& ); + QString defaultModule() const; void currentWindows( QMap& ) const; void currentViewManagers( QStringList& ) const; @@ -164,10 +179,12 @@ private: typedef QMap WindowMap; private: + SalomeApp_Preferences* myPrefs; SalomeApp_SelectionMgr* mySelMgr; - SalomeApp_PreferencesDlg* myPrefDlg; ActionMap myActions; WindowMap myWindows; + + static SalomeApp_Preferences* _prefs_; }; #ifdef WIN32 diff --git a/src/SalomeApp/SalomeApp_Module.cxx b/src/SalomeApp/SalomeApp_Module.cxx index f131285ab..75e3a8491 100644 --- a/src/SalomeApp/SalomeApp_Module.cxx +++ b/src/SalomeApp/SalomeApp_Module.cxx @@ -5,9 +5,10 @@ #include "SalomeApp_Module.h" +#include "SalomeApp_Study.h" #include "SalomeApp_DataModel.h" #include "SalomeApp_Application.h" -#include "SalomeApp_Study.h" +#include "SalomeApp_Preferences.h" #include @@ -68,6 +69,14 @@ void SalomeApp_Module::viewManagers( QStringList& ) const { } +void SalomeApp_Module::createPreferences() +{ +} + +void SalomeApp_Module::preferencesChanged( const QString&, const QString& ) +{ +} + SalomeApp_Application* SalomeApp_Module::getApp() const { return (SalomeApp_Application*)application(); @@ -92,6 +101,14 @@ QtxPopupMgr* SalomeApp_Module::popupMgr() return myPopupMgr; } +SalomeApp_Preferences* SalomeApp_Module::preferences() const +{ + SalomeApp_Preferences* pref = 0; + if ( getApp() ) + pref = getApp()->preferences(); + return pref; +} + CAM_DataModel* SalomeApp_Module::createDataModel() { return new SalomeApp_DataModel(this); @@ -118,3 +135,42 @@ SalomeApp_Selection* SalomeApp_Module::createSelection() const { return new SalomeApp_Selection(); } + +int SalomeApp_Module::addPreference( const QString& label ) +{ + SalomeApp_Preferences* pref = preferences(); + if ( !pref ) + return -1; + + int catId = pref->addPreference( moduleName(), -1 ); + if ( catId == -1 ) + return -1; + + return pref->addPreference( label, catId ); +} + +int SalomeApp_Module::addPreference( const QString& label, const int pId, const int type, + const QString& section, const QString& param ) +{ + SalomeApp_Preferences* pref = preferences(); + if ( !pref ) + return -1; + + return pref->addPreference( moduleName(), label, pId, type, section, param ); +} + +QVariant SalomeApp_Module::preferenceProperty( const int id, const QString& prop ) const +{ + QVariant var; + SalomeApp_Preferences* pref = preferences(); + if ( pref ) + var = pref->property( id, prop ); + return var; +} + +void SalomeApp_Module::setPreferenceProperty( const int id, const QString& prop, const QVariant& var ) +{ + SalomeApp_Preferences* pref = preferences(); + if ( pref ) + pref->setProperty( id, prop, var ); +} diff --git a/src/SalomeApp/SalomeApp_Module.h b/src/SalomeApp/SalomeApp_Module.h index d2ac7699d..8fe9ba985 100644 --- a/src/SalomeApp/SalomeApp_Module.h +++ b/src/SalomeApp/SalomeApp_Module.h @@ -26,6 +26,7 @@ class SUIT_DataObject; class SalomeApp_DataModel; class SalomeApp_Application; +class SalomeApp_Preferences; class SalomeApp_SelectionManager; /* @@ -56,16 +57,20 @@ public: virtual void contextMenuPopup( const QString&, QPopupMenu*, QString& ); + virtual void createPreferences(); + // Convenient shortcuts SalomeApp_Application* getApp() const; void updateObjBrowser( bool = true, SUIT_DataObject* = 0 ); virtual void selectionChanged(); + virtual void preferencesChanged( const QString&, const QString& ); public slots: virtual bool activateModule( SUIT_Study* ); virtual bool deactivateModule( SUIT_Study* ); + void MenuItem(); protected slots: @@ -75,9 +80,18 @@ protected slots: protected: QtxPopupMgr* popupMgr(); + SalomeApp_Preferences* preferences() const; + virtual CAM_DataModel* createDataModel(); virtual SalomeApp_Selection* createSelection() const; + int addPreference( const QString& label ); + int addPreference( const QString& label, const int pId, const int = -1, + const QString& section = QString::null, + const QString& param = QString::null ); + QVariant preferenceProperty( const int, const QString& ) const; + void setPreferenceProperty( const int, const QString&, const QVariant& ); + private: QtxPopupMgr* myPopupMgr; }; diff --git a/src/SalomeApp/SalomeApp_PreferencesDlg.cxx b/src/SalomeApp/SalomeApp_PreferencesDlg.cxx index 189fe1082..374c451ff 100755 --- a/src/SalomeApp/SalomeApp_PreferencesDlg.cxx +++ b/src/SalomeApp/SalomeApp_PreferencesDlg.cxx @@ -3,48 +3,45 @@ #include "SalomeApp_PreferencesDlg.h" -#include +#include "SalomeApp_Preferences.h" +#include #include -SalomeApp_PreferencesDlg::SalomeApp_PreferencesDlg( QtxResourceMgr* resMgr, QWidget* parent ) -: QtxDialog( parent, 0, true, false, Standard | Apply ) +SalomeApp_PreferencesDlg::SalomeApp_PreferencesDlg( SalomeApp_Preferences* prefs, QWidget* parent ) +: QtxDialog( parent, 0, true, false, Standard | Apply ), +myPrefs( prefs ) { setCaption( tr( "CAPTION" ) ); QVBoxLayout* main = new QVBoxLayout( mainFrame(), 5 ); - myEdit = new QtxListResourceEdit( resMgr, mainFrame() ); - main->addWidget( myEdit ); + QVBox* base = new QVBox( mainFrame() ); + main->addWidget( base ); - setFocusProxy( myEdit ); + myPrefs->reparent( base, QPoint( 0, 0 ), true ); + + setFocusProxy( myPrefs ); setDialogFlags( AlignOnce ); connect( this, SIGNAL( dlgHelp() ), this, SLOT( onHelp() ) ); connect( this, SIGNAL( dlgApply() ), this, SLOT( onApply() ) ); - connect( myEdit, SIGNAL( resourceChanged( QString&, QString& ) ), - this, SIGNAL( resourceChanged( QString&, QString& ) ) ); } SalomeApp_PreferencesDlg::~SalomeApp_PreferencesDlg() { -} + if ( !myPrefs ) + return; -void SalomeApp_PreferencesDlg::store() -{ - myEdit->store(); -} - -void SalomeApp_PreferencesDlg::retrieve() -{ - myEdit->retrieve(); + myPrefs->reparent( 0, QPoint( 0, 0 ), false ); + myPrefs = 0; } void SalomeApp_PreferencesDlg::show() { - retrieve(); - myEdit->toBackup(); + myPrefs->retrieve(); + myPrefs->toBackup(); QtxDialog::show(); } @@ -53,33 +50,14 @@ void SalomeApp_PreferencesDlg::accept() { QtxDialog::accept(); - store(); + myPrefs->store(); } void SalomeApp_PreferencesDlg::reject() { QtxDialog::reject(); - myEdit->fromBackup(); -} - -int SalomeApp_PreferencesDlg::addPreference( const QString& label, const int pId, const int type, - const QString& section, const QString& param, SalomeApp_Module* mod ) -{ - int id = myEdit->addItem( label, pId, type, section, param ); - if ( id != -1 && mod ) - myPrefMod.insert( id, mod ); - return id; -} - -QVariant SalomeApp_PreferencesDlg::property( const int id, const QString& param ) const -{ - return myEdit->QtxResourceEdit::property( id, param ); -} - -void SalomeApp_PreferencesDlg::setProperty( const int id, const QString& param, const QVariant& prop ) -{ - myEdit->QtxResourceEdit::setProperty( id, param, prop ); + myPrefs->fromBackup(); } void SalomeApp_PreferencesDlg::onHelp() @@ -88,13 +66,5 @@ void SalomeApp_PreferencesDlg::onHelp() void SalomeApp_PreferencesDlg::onApply() { - myEdit->store(); -} - -SalomeApp_Module* SalomeApp_PreferencesDlg::module( const int id ) const -{ - SalomeApp_Module* mod = 0; - if ( myPrefMod.contains( id ) ) - mod = myPrefMod[id]; - return mod; + myPrefs->store(); } diff --git a/src/SalomeApp/SalomeApp_PreferencesDlg.h b/src/SalomeApp/SalomeApp_PreferencesDlg.h index 5888e7693..68ae7ab08 100755 --- a/src/SalomeApp/SalomeApp_PreferencesDlg.h +++ b/src/SalomeApp/SalomeApp_PreferencesDlg.h @@ -8,50 +8,26 @@ #include -#include - -class QtxResourceMgr; -class SalomeApp_Module; -class QtxListResourceEdit; +class SalomeApp_Preferences; class SALOMEAPP_EXPORT SalomeApp_PreferencesDlg : public QtxDialog { Q_OBJECT public: - SalomeApp_PreferencesDlg( QtxResourceMgr*, QWidget* = 0 ); + SalomeApp_PreferencesDlg( SalomeApp_Preferences*, QWidget* = 0 ); virtual ~SalomeApp_PreferencesDlg(); - virtual void show(); - virtual void accept(); - virtual void reject(); - - void store(); - void retrieve(); - - int addPreference( const QString& label, const int pId = -1, const int = -1, - const QString& section = QString::null, - const QString& param = QString::null, SalomeApp_Module* = 0 ); - - QVariant property( const int, const QString& ) const; - void setProperty( const int, const QString&, const QVariant& ); - -signals: - void resourceChanged( QString&, QString& ); + virtual void show(); + virtual void accept(); + virtual void reject(); private slots: - void onHelp(); - void onApply(); - -private: - SalomeApp_Module* module( const int ) const; - -private: - typedef QMap PrefModuleMap; + void onHelp(); + void onApply(); private: - QtxListResourceEdit* myEdit; - PrefModuleMap myPrefMod; + SalomeApp_Preferences* myPrefs; }; #endif diff --git a/src/SalomeApp/resources/SalomeApp_msg_en.po b/src/SalomeApp/resources/SalomeApp_msg_en.po index 8a349ab71..64cbcf469 100644 --- a/src/SalomeApp/resources/SalomeApp_msg_en.po +++ b/src/SalomeApp/resources/SalomeApp_msg_en.po @@ -71,11 +71,41 @@ msgstr "OCC view" msgid "SalomeApp_Application::NEW_WINDOW_3" msgstr "VTK view" -msgid "SalomeApp_Application::ABOUT" -msgstr "About" +msgid "SalomeApp_Application::TOT_DESK_LOADSCRIPT" +msgstr "Load python script" + +msgid "SalomeApp_Application::MEN_DESK_LOADSCRIPT" +msgstr "Load script..." + +msgid "SalomeApp_Application::PRP_DESK_LOADSCRIPT" +msgstr "Loads python script from file" + +msgid "SalomeApp_Application::TOT_DESK_PREFERENCES" +msgstr "Preferences" + +msgid "SalomeApp_Application::MEN_DESK_PREFERENCES" +msgstr "Preferences..." + +msgid "SalomeApp_Application::PRP_DESK_PREFERENCES" +msgstr "Allow to change the preferences" + +msgid "SalomeApp_Application::TOT_DESK_MRU" +msgstr "Most recently used" + +msgid "SalomeApp_Application::MEN_DESK_MRU" +msgstr "Most recently used" + +msgid "SalomeApp_Application::TOT_DESK_PROPERTIES" +msgstr "Study properties" + +msgid "SalomeApp_Application::MEN_DESK_PROPERTIES" +msgstr "Properties..." + +msgid "SalomeApp_Application::PRP_DESK_PROPERTIES" +msgstr "Edits study properties" -msgid "SalomeApp_Application::APP_NAME_LONG" -msgstr "GUI for SALOME platform v %1\nCopyright (c) CEA 2004" +msgid "SalomeApp_Application::MEN_REFRESH" +msgstr "Refresh" //======================================================================================= @@ -97,9 +127,38 @@ msgstr "Modules" msgid "SalomeApp_Application::INF_CANCELLED" msgstr "Module activation cancelled" +//======================================================================================= + msgid "SalomeApp_Application::PREFERENCES_NOT_LOADED" msgstr "Preferences for module \"%1\" will be available when the module will be loaded" +msgid "SalomeApp_Application::PREF_CATEGORY_SALOME" +msgstr "SALOME" + +msgid "SalomeApp_Application::PREF_TAB_GENERAL" +msgstr "General" + +msgid "SalomeApp_Application::PREF_GROUP_OBJBROWSER" +msgstr "Object browser" + +msgid "SalomeApp_Application::PREF_TAB_VIEWERS" +msgstr "Viewers" + +msgid "SalomeApp_Application::PREF_GROUP_OCCVIEWER" +msgstr "OCC Viewer 3d" + +msgid "SalomeApp_Application::PREF_GROUP_VTKVIEWER" +msgstr "VTK Viewer 3d" + +msgid "SalomeApp_Application::PREF_VIEWER_BACKGROUND" +msgstr "Background color" + +msgid "SalomeApp_Application::PREF_TRIHEDRON_SIZE" +msgstr "Trihedron size" + +msgid "SalomeApp_Application::PREF_TRIHEDRON_SHOW" +msgstr "Show trihedron" + //======================================================================================= msgid "SalomeApp_Application::OBJ_BROWSER_NAME" @@ -117,6 +176,12 @@ msgstr "IOR" msgid "SalomeApp_Application::OBJ_BROWSER_COLUMN_3" msgstr "Reference entry" +msgid "SalomeApp_Application::ALL_FILES_FILTER" +msgstr "All files (*.*)" + +msgid "SalomeApp_Application::PYTHON_FILES_FILTER" +msgstr "PYTHON Files (*.py)" + //======================================================================================= msgid "SalomeApp_ModuleDlg::CAPTION" @@ -139,67 +204,40 @@ msgstr "Create, open or load study." //======================================================================================= -msgid "SalomeApp_Application::ALL_FILES_FILTER" -msgstr "All files ( * )" - -msgid "SalomeApp_Application::PYTHON_FILES_FILTER" -msgstr "PYTHON Files ( *.py )" +msgid "SalomeApp_PreferencesDlg::CAPTION" +msgstr "Preferences" //======================================================================================= -msgid "TOT_DESK_FILE_LOAD_SCRIPT" -msgstr "Load python script" - -msgid "MEN_DESK_FILE_LOAD_SCRIPT" -msgstr "Load script..." - -msgid "PRP_DESK_FILE_LOAD_SCRIPT" -msgstr "Loads python script from file" - -msgid "TOT_DESK_FILE_PROPERTIES" -msgstr "Study properties" - -msgid "MEN_DESK_FILE_PROPERTIES" -msgstr "Properties..." - -msgid "PRP_DESK_FILE_PROPERTIES" -msgstr "Edits study properties" - - - -## SalomeApp_StudyPropertiesDlg -msgid "PRP_MODE_FROM_SCRATCH" +msgid "SalomeApp_StudyPropertiesDlg::PRP_MODE_FROM_SCRATCH" msgstr "from scratch" -msgid "PRP_MODE_FROM_COPYFROM" +msgid "SalomeApp_StudyPropertiesDlg::PRP_MODE_FROM_COPYFROM" msgstr "copy from" -msgid "PRP_NO" +msgid "SalomeApp_StudyPropertiesDlg::PRP_NO" msgstr "No" -msgid "PRP_YES" +msgid "SalomeApp_StudyPropertiesDlg::PRP_YES" msgstr "Yes" -msgid "TLT_STUDY_PROPERTIES" +msgid "SalomeApp_StudyPropertiesDlg::TLT_STUDY_PROPERTIES" msgstr "Study Properties" -msgid "PRP_AUTHOR" +msgid "SalomeApp_StudyPropertiesDlg::PRP_AUTHOR" msgstr "Author" -msgid "PRP_DATE" +msgid "SalomeApp_StudyPropertiesDlg::PRP_DATE" msgstr "Date" -msgid "PRP_MODE" +msgid "SalomeApp_StudyPropertiesDlg::PRP_MODE" msgstr "Mode" -msgid "PRP_LOCKED" +msgid "SalomeApp_StudyPropertiesDlg::PRP_LOCKED" msgstr "LOCKED" -msgid "PRP_MODIFIED" +msgid "SalomeApp_StudyPropertiesDlg::PRP_MODIFIED" msgstr "MODIFIED" -msgid "PRP_MODIFICATIONS" +msgid "SalomeApp_StudyPropertiesDlg::PRP_MODIFICATIONS" msgstr "Modifications" - -msgid "MEN_REFRESH" -msgstr "Refresh" diff --git a/src/VTKViewer/VTKViewer_ViewModel.cxx b/src/VTKViewer/VTKViewer_ViewModel.cxx index 9ff5f3231..084a200c6 100755 --- a/src/VTKViewer/VTKViewer_ViewModel.cxx +++ b/src/VTKViewer/VTKViewer_ViewModel.cxx @@ -15,7 +15,8 @@ //**************************************************************** VTKViewer_Viewer::VTKViewer_Viewer() -:SUIT_ViewModel() +: SUIT_ViewModel(), +myBgColor( Qt::black ) { } @@ -24,10 +25,23 @@ VTKViewer_Viewer::~VTKViewer_Viewer() { } +QColor VTKViewer_Viewer::backgroundColor() const +{ + return myBgColor; +} + +void VTKViewer_Viewer::setBackgroundColor( const QColor& c ) +{ + if ( c.isValid() ) + myBgColor = c; +} + //**************************************************************** -SUIT_ViewWindow* VTKViewer_Viewer::createView(SUIT_Desktop* theDesktop) +SUIT_ViewWindow* VTKViewer_Viewer::createView( SUIT_Desktop* theDesktop ) { - return new VTKViewer_ViewWindow(theDesktop, this); + VTKViewer_ViewWindow* vw = new VTKViewer_ViewWindow( theDesktop, this ); + vw->setBackgroundColor( myBgColor ); + return vw; } //********************************************************************* diff --git a/src/VTKViewer/VTKViewer_ViewModel.h b/src/VTKViewer/VTKViewer_ViewModel.h index fe54aa291..db2a93d0b 100755 --- a/src/VTKViewer/VTKViewer_ViewModel.h +++ b/src/VTKViewer/VTKViewer_ViewModel.h @@ -4,6 +4,8 @@ #include "VTKViewer.h" #include "SUIT_ViewModel.h" +#include + class SUIT_ViewWindow; class SUIT_Desktop; @@ -32,6 +34,9 @@ public: int getSelectionCount() const; + QColor backgroundColor() const; + void setBackgroundColor( const QColor& ); + signals: void selectionChanged(); @@ -45,8 +50,9 @@ protected slots: void onChangeBgColor(); private: - bool mySelectionEnabled; - bool myMultiSelectionEnabled; + QColor myBgColor; + bool mySelectionEnabled; + bool myMultiSelectionEnabled; }; #endif diff --git a/src/VTKViewer/VTKViewer_ViewWindow.cxx b/src/VTKViewer/VTKViewer_ViewWindow.cxx index 0d7e7fc19..014608d68 100755 --- a/src/VTKViewer/VTKViewer_ViewWindow.cxx +++ b/src/VTKViewer/VTKViewer_ViewWindow.cxx @@ -19,7 +19,6 @@ #include #include -//**************************************************************** ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// @@ -27,7 +26,7 @@ VTKViewer_ViewWindow::VTKViewer_ViewWindow( SUIT_Desktop* theDesktop, VTKViewer_Viewer* theModel, VTKViewer_InteractorStyle* iStyle, VTKViewer_RenderWindowInteractor* rw ) -: SUIT_ViewWindow(theDesktop) +: SUIT_ViewWindow( theDesktop ) { myModel = theModel; @@ -104,7 +103,6 @@ VTKViewer_ViewWindow::VTKViewer_ViewWindow( SUIT_Desktop* theDesktop, onResetView(); } -//**************************************************************** VTKViewer_ViewWindow::~VTKViewer_ViewWindow() { myTransform->Delete(); @@ -120,12 +118,10 @@ VTKViewer_ViewWindow::~VTKViewer_ViewWindow() myTrihedron->Delete(); } -//**************************************************************** bool VTKViewer_ViewWindow::isTrihedronDisplayed(){ return myTrihedron->GetVisibility() == VTKViewer_Trihedron::eOn; } -//**************************************************************** /*! Activates 'zooming' transformation */ -- 2.39.2