]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
0022781: [CEA 1281] Preferences of colors and textures of clipping planes (improved)
authormpa <mpa@opencascade.com>
Tue, 10 Feb 2015 08:46:40 +0000 (11:46 +0300)
committermpa <mpa@opencascade.com>
Tue, 10 Feb 2015 08:46:40 +0000 (11:46 +0300)
src/LightApp/LightApp_Application.cxx
src/LightApp/resources/LightApp.xml
src/LightApp/resources/LightApp_msg_en.ts
src/LightApp/resources/LightApp_msg_fr.ts
src/LightApp/resources/LightApp_msg_ja.ts
src/OCCViewer/OCCViewer_ViewModel.cxx
src/OCCViewer/OCCViewer_ViewModel.h

index 64bb76918566b5d06d011bb17b22d4d7ab685e80..43838b3eb4aa817765d5bd5481257686337ce894 100644 (file)
@@ -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 <<end>>
 
   // ... -> empty frame (for layout) <<start>>
@@ -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<SUIT_ViewManager*> lst;
-    viewManagers( OCCViewer_Viewer::Type(), lst );
-    QListIterator<SUIT_ViewManager*> 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<SUIT_ViewManager*> lst;
     viewManagers( OCCViewer_Viewer::Type(), lst );
     QListIterator<SUIT_ViewManager*> 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
index 8807cf544128e858d608c9ecd427f32223f79c9d..6525ae3fdd2e83b3636473f5a146aa20390a0f98 100644 (file)
     <parameter name="enable_selection"    value="true"/>
     <parameter name="clipping_color"      value="50, 50, 50"/>
     <parameter name="clipping_use_default_texture" value="true"/>
+    <parameter name="clipping_modulate"   value="true"/>
+    <parameter name="clipping_scale"      value="1.0"/>
     <parameter name="background"      value="bt=2;fn=;tm=0;ts=false;c1=#cddbff;c2=#698fff;gt=1;gr=" />
     <parameter name="xz_background"   value="bt=2;fn=;tm=0;ts=false;c1=#cddbff;c2=#698fff;gt=1;gr=" />
     <parameter name="yz_background"   value="bt=2;fn=;tm=0;ts=false;c1=#cddbff;c2=#698fff;gt=1;gr=" />
index 15612a4e57051d520124fae3a7f79250f664f6ed..5b6705b0e4af8ae6b96745c2d8635f31efa872ac 100644 (file)
@@ -779,6 +779,14 @@ The changes will be applied on the next application session.</translation>
         <source>OCC_TEXTURE_FILES</source>
         <translation>Image files (*.jpeg *jpg *.jpe *.png *.bmp *.gif *.ppm *.tif *.tiff* .tga *.exr)</translation>
     </message>
+    <message>
+        <source>PREF_CLIPPING_MODULATE</source>
+        <translation>Modulate</translation>
+    </message>
+    <message>
+        <source>PREF_CLIPPING_SCALE</source>
+        <translation>Scale factor</translation>
+    </message>
     <message>
         <source>TOT_CLOSE</source>
         <translation>Close</translation>
index fa7d33352681fe8610ac49ad8d3eeec09526e86c..26e533bd03672652f92022cb8b48fa483aad3b65 100755 (executable)
@@ -779,6 +779,14 @@ Les modifications seront appliquées à la prochaine session.</translation>
         <source>OCC_TEXTURE_FILES</source>
         <translation>Fichiers images (*.jpeg *jpg *.jpe *.png *.bmp *.gif *.ppm *.tif *.tiff* .tga *.exr)</translation>
     </message>
+    <message>
+        <source>PREF_CLIPPING_MODULATE</source>
+        <translation type="unfinished">Modulate</translation>
+    </message>
+    <message>
+        <source>PREF_CLIPPING_SCALE</source>
+        <translation type="unfinished">Scale factor</translation>
+    </message>
     <message>
         <source>TOT_CLOSE</source>
         <translation>Fermer</translation>
index f95bfd79e8ca262e39e32c84a9c9256db8b6e9c9..48b70d9c156fbe20542df38ac6805d3b64e5923b 100644 (file)
@@ -779,6 +779,14 @@ session. It has to be closed before working with another study.</translation>
         <source>OCC_TEXTURE_FILES</source>
         <translation>イメージファイル (*.jpeg *jpg *.jpe *.png *.bmp *.gif *.ppm *.tif *.tiff* .tga *.exr)</translation>
     </message>
+    <message>
+        <source>PREF_CLIPPING_MODULATE</source>
+        <translation type="unfinished">Modulate</translation>
+    </message>
+    <message>
+        <source>PREF_CLIPPING_SCALE</source>
+        <translation type="unfinished">Scale factor</translation>
+    </message>
     <message>
       <source>TOT_CLOSE</source>
       <translation>閉じる</translation>
index 9f4e6f761ab68b6dbda58443861dcd6be61daf78..83cb5fb83cffabd0f07aa4027dc5f121a2bf566d 100755 (executable)
@@ -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;
 }
index 4564da1fa47f7de5ec2d22112eb7e78a14020b5c..4104651d5eb2b79ef4603e5e450b83d92287a630 100755 (executable)
@@ -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;
 
 };