From 30eaa9dffd8ba8a355cad33b0248bafb6748e81e Mon Sep 17 00:00:00 2001 From: stv Date: Wed, 22 Jun 2005 09:57:17 +0000 Subject: [PATCH] Preferences --- src/OCCViewer/OCCViewer_ViewModel.cxx | 14 ++--- src/Qtx/QtxResourceEdit.cxx | 11 ++++ src/SVTK/SVTK_ViewModel.cxx | 29 ++++++++- src/SVTK/SVTK_ViewModel.h | 4 ++ src/SVTK/SVTK_ViewWindow.cxx | 24 ++++---- src/SVTK/SVTK_ViewWindow.h | 9 ++- src/SalomeApp/SalomeApp_Application.cxx | 65 ++++++++++++++++++--- src/SalomeApp/resources/SalomeApp_msg_en.po | 6 ++ src/VTKViewer/VTKViewer_ViewWindow.cxx | 10 ---- 9 files changed, 134 insertions(+), 38 deletions(-) diff --git a/src/OCCViewer/OCCViewer_ViewModel.cxx b/src/OCCViewer/OCCViewer_ViewModel.cxx index a1fb001b3..d81715444 100755 --- a/src/OCCViewer/OCCViewer_ViewModel.cxx +++ b/src/OCCViewer/OCCViewer_ViewModel.cxx @@ -416,7 +416,7 @@ int OCCViewer_Viewer::trihedronSize() const { int sz = 0; if ( !myTrihedron.IsNull() ) - sz = myTrihedron->Size(); + sz = (int)myTrihedron->Size(); return sz; } @@ -429,14 +429,14 @@ void OCCViewer_Viewer::setTrihedronSize( const int sz ) void OCCViewer_Viewer::setIsos( const int u, const int v ) { Handle(AIS_InteractiveContext) ic = getAISContext(); - if ( !ic.IsNull() ) - { - ic->SetIsoNumber( u, AIS_TOI_IsoU ); - ic->SetIsoNumber( u, AIS_TOI_IsoV ); - } + if ( ic.IsNull() ) + return; + + ic->SetIsoNumber( u, AIS_TOI_IsoU ); + ic->SetIsoNumber( u, AIS_TOI_IsoV ); } -void OCCViewer_Viewer::isos( int& u, int& v ) const +void OCCViewer_Viewer::isos( int& u, int& v ) const { Handle(AIS_InteractiveContext) ic = getAISContext(); if ( !ic.IsNull() ) diff --git a/src/Qtx/QtxResourceEdit.cxx b/src/Qtx/QtxResourceEdit.cxx index 1ee772a30..b368eb61a 100644 --- a/src/Qtx/QtxResourceEdit.cxx +++ b/src/Qtx/QtxResourceEdit.cxx @@ -95,7 +95,18 @@ void QtxResourceEdit::toBackup() void QtxResourceEdit::fromBackup() { + QMap before; + resourceValues( before ); + setResourceValues( myBackup ); + + QMap after; + resourceValues( after ); + + QMap changed; + differentValues( before, after, changed ); + + changedResources( changed ); } void QtxResourceEdit::update() diff --git a/src/SVTK/SVTK_ViewModel.cxx b/src/SVTK/SVTK_ViewModel.cxx index 5ff086950..17f0ac85c 100644 --- a/src/SVTK/SVTK_ViewModel.cxx +++ b/src/SVTK/SVTK_ViewModel.cxx @@ -51,6 +51,7 @@ static _PTR(Study) getStudyDS() //========================================================== SVTK_Viewer::SVTK_Viewer() { + myTrihedronSize = 100; } //========================================================== @@ -74,15 +75,41 @@ SUIT_ViewWindow* SVTK_Viewer::createView( SUIT_Desktop* theDesktop ) { SVTK_ViewWindow* vw = new SVTK_ViewWindow( theDesktop, this ); vw->setBackgroundColor( backgroundColor() ); + vw->SetTrihedronSize( trihedronSize() ); return vw; } +int SVTK_Viewer::trihedronSize() const +{ + return myTrihedronSize; +} + +void SVTK_Viewer::setTrihedronSize( const int sz ) +{ + myTrihedronSize = sz; + + SUIT_ViewManager* vm = getViewManager(); + if ( !vm ) + return; + + QPtrVector vec = vm->getViews(); + for ( int i = 0; i < vec.count(); i++ ) + { + SUIT_ViewWindow* win = vec.at( i ); + if ( !win || !win->inherits( "SVTK_ViewWindow" ) ) + continue; + + SVTK_ViewWindow* vw = (SVTK_ViewWindow*)win; + vw->SetTrihedronSize( sz ); + } +} + //========================================================== void SVTK_Viewer::setViewManager(SUIT_ViewManager* theViewManager) { SUIT_ViewModel::setViewManager(theViewManager); - if(!theViewManager) + if ( !theViewManager ) return; connect(theViewManager, SIGNAL(mousePress(SUIT_ViewWindow*, QMouseEvent*)), diff --git a/src/SVTK/SVTK_ViewModel.h b/src/SVTK/SVTK_ViewModel.h index fbf1c14b3..912e31f3d 100644 --- a/src/SVTK/SVTK_ViewModel.h +++ b/src/SVTK/SVTK_ViewModel.h @@ -28,6 +28,9 @@ public: QColor backgroundColor() const; void setBackgroundColor( const QColor& ); + int trihedronSize() const; + void setTrihedronSize( const int ); + public: void enableSelection(bool isEnabled); bool isSelectionEnabled() const { return mySelectionEnabled; } @@ -68,6 +71,7 @@ protected slots: private: QColor myBgColor; + int myTrihedronSize; bool mySelectionEnabled; bool myMultiSelectionEnabled; }; diff --git a/src/SVTK/SVTK_ViewWindow.cxx b/src/SVTK/SVTK_ViewWindow.cxx index cd140f5fa..db5549067 100755 --- a/src/SVTK/SVTK_ViewWindow.cxx +++ b/src/SVTK/SVTK_ViewWindow.cxx @@ -37,7 +37,8 @@ SVTK_ViewWindow ::SVTK_ViewWindow( SUIT_Desktop* theDesktop, SVTK_Viewer* theModel) - : SUIT_ViewWindow(theDesktop) + : SUIT_ViewWindow( theDesktop ), + myTrihedronSize( 100 ) { myModel = theModel; mySelector = new SVTK_SelectorDef(); @@ -611,10 +612,7 @@ SVTK_ViewWindow aLength = max( ( aBndBox[ 5 ] - aBndBox[ 4 ] ),aLength ); } - static float aSizeInPercents = 105; - //QString aSetting = QAD_CONFIG->getSetting( "Viewer:TrihedronSize" ); - //if ( !aSetting.isEmpty() ) - // aSizeInPercents = aSetting.toFloat(); + float aSizeInPercents = myTrihedronSize; static float EPS_SIZE = 5.0E-3; theSize = myTrihedron->GetSize(); @@ -626,14 +624,20 @@ SVTK_ViewWindow } //---------------------------------------------------------------------------- -double -SVTK_ViewWindow -::GetTrihedronSize() const +int SVTK_ViewWindow::GetTrihedronSize() const { - return myTrihedron->GetSize(); + return myTrihedronSize; +} + +void SVTK_ViewWindow::SetTrihedronSize( const int sz ) +{ + if ( myTrihedronSize == sz ) + return; + + myTrihedronSize = sz; + AdjustTrihedrons( true ); } -//---------------------------------------------------------------------------- void SVTK_ViewWindow ::AdjustTrihedrons( const bool theIsForcedUpdate ) diff --git a/src/SVTK/SVTK_ViewWindow.h b/src/SVTK/SVTK_ViewWindow.h index a2f70efa4..c2ebd3b23 100755 --- a/src/SVTK/SVTK_ViewWindow.h +++ b/src/SVTK/SVTK_ViewWindow.h @@ -80,7 +80,9 @@ public: void AdjustTrihedrons( const bool forced ); bool ComputeTrihedronSize( double& theNewSize, double& theOldSize ); - double GetTrihedronSize() const; + + int GetTrihedronSize() const; + void SetTrihedronSize( const int ); public slots: void onSelectionChanged(); @@ -151,9 +153,10 @@ private: SVTK_RenderWindow* myRenderWindow; SVTK_RenderWindowInteractor* myRWInteractor; - - VTKViewer_Trihedron* myTrihedron; + VTKViewer_Transform* myTransform; + VTKViewer_Trihedron* myTrihedron; + int myTrihedronSize; QToolBar* myToolBar; ActionsMap myActionsMap; diff --git a/src/SalomeApp/SalomeApp_Application.cxx b/src/SalomeApp/SalomeApp_Application.cxx index 317093a38..a3eb99fea 100644 --- a/src/SalomeApp/SalomeApp_Application.cxx +++ b/src/SalomeApp/SalomeApp_Application.cxx @@ -847,6 +847,11 @@ SUIT_ViewManager* SalomeApp_Application::createViewManager( const QString& vmTyp 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 ); } @@ -855,6 +860,7 @@ SUIT_ViewManager* SalomeApp_Application::createViewManager( const QString& vmTyp 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); } @@ -934,10 +940,10 @@ void SalomeApp_Application::onDumpStudy( ) _PTR(Study) aStudy = appStudy->studyDS(); QStringList aFilters; - aFilters.append(tr("PYTHON_FILES_FILTER")); + 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->setCaption( tr( "TOT_DESK_FILE_DUMP_STUDY" ) ); fd->setFilters( aFilters ); fd->SetChecked(true); fd->exec(); @@ -947,7 +953,7 @@ void SalomeApp_Application::onDumpStudy( ) if(!aFileName.isEmpty()) { QFileInfo aFileInfo(aFileName); - aStudy->DumpStudy(aFileInfo.dirPath(true), aFileInfo.baseName(), toPublish); + aStudy->DumpStudy( aFileInfo.dirPath( true ).latin1(), aFileInfo.baseName().latin1(), toPublish ); } } @@ -1183,15 +1189,32 @@ void SalomeApp_Application::createPreferences( SalomeApp_Preferences* pref ) pref->setProperty( occGroup, "columns", 1 ); pref->setProperty( vtkGroup, "columns", 1 ); - pref->addPreference( tr( "PREF_TRIHEDRON_SIZE" ), occGroup, - SalomeApp_Preferences::IntSpin, "OCCViewer", "trihedron_size" ); + 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->addPreference( tr( "PREF_TRIHEDRON_SIZE" ), vtkGroup, - SalomeApp_Preferences::IntSpin, "VTKViewer", "trihedron_size" ); + 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 ) @@ -1216,6 +1239,34 @@ void SalomeApp_Application::preferencesChanged( const QString& sec, const QStrin occVM->getAISContext()->UpdateCurrentViewer(); } } + + if ( sec == QString( "VTKViewer" ) && param == QString( "trihedron_size" ) ) + { + int sz = resMgr->integerValue( sec, param, -1 ); + QPtrList lst; + viewManagers( SVTK_Viewer::Type(), lst ); + for ( QPtrListIterator 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 ( sec == QString( "OCCViewer" ) && ( param == QString( "iso_number_u" ) || param == QString( "iso_number_v" ) ) ) + { + QPtrList lst; + viewManagers( OCCViewer_Viewer::Type(), lst ); + int u = resMgr->integerValue( sec, "iso_number_u" ); + int v = resMgr->integerValue( sec, "iso_number_v" ); + for ( QPtrListIterator it( lst ); it.current(); ++it ) + ((OCCViewer_Viewer*)it.current())->setIsos( u, v ); + } + */ } void SalomeApp_Application::afterCloseDoc() diff --git a/src/SalomeApp/resources/SalomeApp_msg_en.po b/src/SalomeApp/resources/SalomeApp_msg_en.po index 43ed605f8..aeabfcaa3 100644 --- a/src/SalomeApp/resources/SalomeApp_msg_en.po +++ b/src/SalomeApp/resources/SalomeApp_msg_en.po @@ -168,6 +168,12 @@ msgstr "Background color" msgid "SalomeApp_Application::PREF_TRIHEDRON_SIZE" msgstr "Trihedron size" +msgid "SalomeApp_Application::PREF_ISOS_U" +msgstr "Number of isolines along U" + +msgid "SalomeApp_Application::PREF_ISOS_V" +msgstr "Number of isolines along V" + msgid "SalomeApp_Application::PREF_TRIHEDRON_SHOW" msgstr "Show trihedron" diff --git a/src/VTKViewer/VTKViewer_ViewWindow.cxx b/src/VTKViewer/VTKViewer_ViewWindow.cxx index 78b400430..f179eb92b 100755 --- a/src/VTKViewer/VTKViewer_ViewWindow.cxx +++ b/src/VTKViewer/VTKViewer_ViewWindow.cxx @@ -409,26 +409,22 @@ QColor VTKViewer_ViewWindow::backgroundColor() const return SUIT_ViewWindow::backgroundColor(); } -//**************************************************************** void VTKViewer_ViewWindow::Repaint(bool theUpdateTrihedron) { if (theUpdateTrihedron) onAdjustTrihedron(); myRenderWindow->update(); } -//**************************************************************** void VTKViewer_ViewWindow::GetScale( double theScale[3] ) { myTransform->GetScale( theScale ); } -//**************************************************************** void VTKViewer_ViewWindow::SetScale( double theScale[3] ) { myTransform->SetScale( theScale[0], theScale[1], theScale[2] ); myRWInteractor->Render(); Repaint(); } -//**************************************************************** void VTKViewer_ViewWindow::onAdjustTrihedron(){ if( !isTrihedronDisplayed() ) return; @@ -466,37 +462,31 @@ void VTKViewer_ViewWindow::onAdjustTrihedron(){ ::ResetCameraClippingRange(myRenderer); } -//**************************************************************** void VTKViewer_ViewWindow::onKeyPressed(QKeyEvent* event) { emit keyPressed( this, event ); } -//**************************************************************** void VTKViewer_ViewWindow::onKeyReleased(QKeyEvent* event) { emit keyReleased( this, event ); } -//**************************************************************** void VTKViewer_ViewWindow::onMousePressed(QMouseEvent* event) { emit mousePressed(this, event); } -//**************************************************************** void VTKViewer_ViewWindow::onMouseReleased(QMouseEvent* event) { emit mouseReleased( this, event ); } -//**************************************************************** void VTKViewer_ViewWindow::onMouseMoving(QMouseEvent* event) { emit mouseMoving( this, event ); } -//**************************************************************** void VTKViewer_ViewWindow::onMouseDoubleClicked( QMouseEvent* event ) { emit mouseDoubleClicked( this, event ); -- 2.39.2