From: mpa Date: Tue, 10 Feb 2015 08:46:40 +0000 (+0300) Subject: 0022781: [CEA 1281] Preferences of colors and textures of clipping planes (improved) X-Git-Tag: V7_6_0a1~22 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f7c76ac64018352f0d9ef40e9282c7900864cee9;p=modules%2Fgui.git 0022781: [CEA 1281] Preferences of colors and textures of clipping planes (improved) --- diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index 64bb76918..43838b3eb 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -1493,8 +1493,10 @@ SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType vm->enablePreselection( resMgr->booleanValue( "OCCViewer", "enable_preselection", vm->isPreselectionEnabled() ) ); vm->enableSelection( resMgr->booleanValue( "OCCViewer", "enable_selection", vm->isSelectionEnabled() ) ); vm->setClippingColor( resMgr->colorValue( "OCCViewer", "clipping_color", vm->clippingColor() ) ); - vm->useDefaultTexture( resMgr->booleanValue( "OCCViewer", "clipping_use_default_texture", vm->isDefaultTextureUsed() ) ); - vm->setClippingTexture( resMgr->stringValue( "OCCViewer", "clipping_texture", vm->clippingTexture() ) ); + vm->setClippingTextureParams( resMgr->booleanValue( "OCCViewer", "clipping_use_default_texture", vm->isDefaultTextureUsed() ), + resMgr->stringValue( "OCCViewer", "clipping_texture", vm->clippingTexture() ), + resMgr->booleanValue( "OCCViewer", "clipping_modulate", vm->isTextureModulated() ), + resMgr->doubleValue( "OCCViewer", "clipping_scale", vm->clippingTextureScale() ) ); viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface @@ -2321,6 +2323,16 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) int filePref = pref->addPreference( tr( "PREF_CLIPPING_TEXTURE" ), texturePref, LightApp_Preferences::File, "OCCViewer", "clipping_texture" ); pref->setItemProperty( "path_filter", tr( "OCC_TEXTURE_FILES" ), filePref ); + // .... -> modulate + pref->addPreference( tr( "PREF_CLIPPING_MODULATE" ), texturePref, + LightApp_Preferences::Bool, "OCCViewer", "clipping_modulate" ); + // .... -> scale factor + int scaleFactor = pref->addPreference( tr( "PREF_CLIPPING_SCALE" ), texturePref, + LightApp_Preferences::DblSpin, "OCCViewer", "clipping_scale" ); + pref->setItemProperty( "precision", 3, scaleFactor ); + pref->setItemProperty( "min", 1.0E-03, scaleFactor ); + pref->setItemProperty( "max", 1.0E03, scaleFactor ); + pref->setItemProperty( "step", 0.1, scaleFactor ); // ... "Clipping" group <> // ... -> empty frame (for layout) <> @@ -2816,28 +2828,15 @@ void LightApp_Application::preferencesChanged( const QString& sec, const QString #endif #ifndef DISABLE_OCCVIEWER - if ( sec == QString( "OCCViewer" ) && param == QString( "clipping_use_default_texture" ) ) + if ( sec == QString( "OCCViewer" ) && ( param == QString( "clipping_use_default_texture" ) || + param == QString( "clipping_texture" ) || + param == QString( "clipping_modulate" ) || + param == QString( "clipping_scale" ) ) ) { bool isDefaultTextureUsed = resMgr->booleanValue( "OCCViewer", "clipping_use_default_texture" ); - QList lst; - viewManagers( OCCViewer_Viewer::Type(), lst ); - QListIterator it( lst ); - while ( it.hasNext() ) - { - SUIT_ViewModel* vm = it.next()->getViewModel(); - if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) ) - continue; - - OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm; - occVM->useDefaultTexture( isDefaultTextureUsed ); - } - } -#endif - -#ifndef DISABLE_OCCVIEWER - if ( sec == QString( "OCCViewer" ) && param == QString( "clipping_texture" ) ) - { QString aTexture = resMgr->stringValue( "OCCViewer", "clipping_texture" ); + bool isModulated = resMgr->booleanValue( "OCCViewer", "clipping_modulate" ); + double aScale = resMgr->doubleValue( "OCCViewer", "clipping_scale" ); QList lst; viewManagers( OCCViewer_Viewer::Type(), lst ); QListIterator it( lst ); @@ -2848,7 +2847,7 @@ void LightApp_Application::preferencesChanged( const QString& sec, const QString continue; OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm; - occVM->setClippingTexture( aTexture ); + occVM->setClippingTextureParams( isDefaultTextureUsed, aTexture, isModulated, aScale ); } } #endif diff --git a/src/LightApp/resources/LightApp.xml b/src/LightApp/resources/LightApp.xml index 8807cf544..6525ae3fd 100644 --- a/src/LightApp/resources/LightApp.xml +++ b/src/LightApp/resources/LightApp.xml @@ -146,6 +146,8 @@ + + diff --git a/src/LightApp/resources/LightApp_msg_en.ts b/src/LightApp/resources/LightApp_msg_en.ts index 15612a4e5..5b6705b0e 100644 --- a/src/LightApp/resources/LightApp_msg_en.ts +++ b/src/LightApp/resources/LightApp_msg_en.ts @@ -779,6 +779,14 @@ The changes will be applied on the next application session. OCC_TEXTURE_FILES Image files (*.jpeg *jpg *.jpe *.png *.bmp *.gif *.ppm *.tif *.tiff* .tga *.exr) + + PREF_CLIPPING_MODULATE + Modulate + + + PREF_CLIPPING_SCALE + Scale factor + TOT_CLOSE Close diff --git a/src/LightApp/resources/LightApp_msg_fr.ts b/src/LightApp/resources/LightApp_msg_fr.ts index fa7d33352..26e533bd0 100755 --- a/src/LightApp/resources/LightApp_msg_fr.ts +++ b/src/LightApp/resources/LightApp_msg_fr.ts @@ -779,6 +779,14 @@ Les modifications seront appliquées à la prochaine session. OCC_TEXTURE_FILES Fichiers images (*.jpeg *jpg *.jpe *.png *.bmp *.gif *.ppm *.tif *.tiff* .tga *.exr) + + PREF_CLIPPING_MODULATE + Modulate + + + PREF_CLIPPING_SCALE + Scale factor + TOT_CLOSE Fermer diff --git a/src/LightApp/resources/LightApp_msg_ja.ts b/src/LightApp/resources/LightApp_msg_ja.ts index f95bfd79e..48b70d9c1 100644 --- a/src/LightApp/resources/LightApp_msg_ja.ts +++ b/src/LightApp/resources/LightApp_msg_ja.ts @@ -779,6 +779,14 @@ session. It has to be closed before working with another study. OCC_TEXTURE_FILES イメージファイル (*.jpeg *jpg *.jpe *.png *.bmp *.gif *.ppm *.tif *.tiff* .tga *.exr) + + PREF_CLIPPING_MODULATE + Modulate + + + PREF_CLIPPING_SCALE + Scale factor + TOT_CLOSE 閉じる diff --git a/src/OCCViewer/OCCViewer_ViewModel.cxx b/src/OCCViewer/OCCViewer_ViewModel.cxx index 9f4e6f761..83cb5fb83 100755 --- a/src/OCCViewer/OCCViewer_ViewModel.cxx +++ b/src/OCCViewer/OCCViewer_ViewModel.cxx @@ -147,6 +147,8 @@ OCCViewer_Viewer::OCCViewer_Viewer( bool DisplayTrihedron) myClippingColor = QColor( 50, 50, 50 ); myDefaultTextureUsed = true; myClippingTexture = QString(); + myTextureModulated = true; + myClippingTextureScale = 1.0; } @@ -609,7 +611,8 @@ QColor OCCViewer_Viewer::clippingColor() const } // initialize a texture for clipped region -Handle(Graphic3d_Texture2Dmanual) initClippingTexture( const bool isDefault, const QString& theTexture) +Handle(Graphic3d_Texture2Dmanual) initClippingTexture( const bool isDefault, const QString& theTexture, + const bool isModulate, const double theScale ) { QString aTextureFile = isDefault ? ":images/hatch.png" : theTexture; QPixmap px( aTextureFile ); @@ -617,31 +620,33 @@ Handle(Graphic3d_Texture2Dmanual) initClippingTexture( const bool isDefault, con Handle(Graphic3d_Texture2Dmanual) aTexture = new Graphic3d_Texture2Dmanual( aPixmap ); if( aTexture->IsDone() ) { aTexture->EnableRepeat(); - if( isDefault ) { - aTexture->EnableModulate(); - aTexture->GetParams()->SetScale( Graphic3d_Vec2( 0.01, 0.01 ) ); - } - else { - aTexture->DisableModulate(); - aTexture->GetParams()->SetScale( Graphic3d_Vec2( 0.005, 0.005 ) ); - } + isModulate ? aTexture->EnableModulate() : aTexture->DisableModulate(); + aTexture->GetParams()->SetScale( Graphic3d_Vec2( 1/( theScale*100 ), -1 / ( theScale*100 ) ) ); } return aTexture; } /*! - Sets default texture enabled status - \param isUsed - new status + Sets default texture parameters + \param isDefault - use/non-use default texture + \param theTexture - new texture of the clipped region + \param isModulate - enable/disable texture modulate mode + \param theScale - scale factor. */ -void OCCViewer_Viewer::useDefaultTexture( const bool isUsed ) +void OCCViewer_Viewer::setClippingTextureParams( const bool isDefault, const QString& theTexture, + const bool isModulate, const double theScale ) { - myDefaultTextureUsed = isUsed; + myDefaultTextureUsed = isDefault; + myClippingTexture = theTexture; + myTextureModulated = isModulate; + myClippingTextureScale = theScale; if( myInternalClipPlanes.IsEmpty() ) return; Handle(Graphic3d_Texture2Dmanual) aTexture = - initClippingTexture( myDefaultTextureUsed, myClippingTexture ); + initClippingTexture( myDefaultTextureUsed, myClippingTexture, + myTextureModulated, myClippingTextureScale ); for( int i = 1; i <= myInternalClipPlanes.Size(); i++ ) myInternalClipPlanes.Value(i)->SetCappingTexture( aTexture ); @@ -658,31 +663,27 @@ bool OCCViewer_Viewer::isDefaultTextureUsed() const } /*! - Sets a texture of the clipped region - \param theTexture - a new texture of the clipped region + \return clipping texture */ -void OCCViewer_Viewer::setClippingTexture( const QString& theTexture ) +QString OCCViewer_Viewer::clippingTexture() const { - myClippingTexture = theTexture; - - if( myInternalClipPlanes.IsEmpty() || myDefaultTextureUsed ) - return; - - Handle(Graphic3d_Texture2Dmanual) aTexture = - initClippingTexture( myDefaultTextureUsed, myClippingTexture ); - - for( int i = 1; i <= myInternalClipPlanes.Size(); i++ ) - myInternalClipPlanes.Value(i)->SetCappingTexture( aTexture ); + return myClippingTexture; +} - update(); +/*! + \return true if texture is modulated +*/ +bool OCCViewer_Viewer::isTextureModulated() const +{ + return myTextureModulated; } /*! - \return clipping texture + \return scale factor of texture */ -QString OCCViewer_Viewer::clippingTexture() const +double OCCViewer_Viewer::clippingTextureScale() const { - return myClippingTexture; + return myClippingTextureScale; } /*! @@ -1171,7 +1172,8 @@ Handle(Graphic3d_ClipPlane) OCCViewer_Viewer::createClipPlane(const gp_Pln& theP aGraphic3dPlane->SetCappingMaterial( aMaterialAspect ); // set capping texture - aGraphic3dPlane->SetCappingTexture( initClippingTexture( myDefaultTextureUsed, myClippingTexture) ); + aGraphic3dPlane->SetCappingTexture( initClippingTexture( myDefaultTextureUsed, myClippingTexture, + myTextureModulated, myClippingTextureScale ) ); return aGraphic3dPlane; } diff --git a/src/OCCViewer/OCCViewer_ViewModel.h b/src/OCCViewer/OCCViewer_ViewModel.h index 4564da1fa..4104651d5 100755 --- a/src/OCCViewer/OCCViewer_ViewModel.h +++ b/src/OCCViewer/OCCViewer_ViewModel.h @@ -150,11 +150,11 @@ public: void setClippingColor( const QColor& ); QColor clippingColor() const; - void useDefaultTexture( const bool ); + void setClippingTextureParams( const bool, const QString&, const bool, const double ); bool isDefaultTextureUsed() const; - - void setClippingTexture( const QString& ); QString clippingTexture() const; + bool isTextureModulated() const; + double clippingTextureScale() const; int getSelectionCount() const { return (!myAISContext.IsNull())? myAISContext->NbSelected():0; } @@ -231,6 +231,8 @@ protected: QColor myClippingColor; bool myDefaultTextureUsed; QString myClippingTexture; + bool myTextureModulated; + double myClippingTextureScale; };