+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<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 ) );
+ }
+
+ 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<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();
+ }
+ }
+}
+