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
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>>
#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 );
continue;
OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
- occVM->setClippingTexture( aTexture );
+ occVM->setClippingTextureParams( isDefaultTextureUsed, aTexture, isModulated, aScale );
}
}
#endif
<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=" />
<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>
<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>
<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>
myClippingColor = QColor( 50, 50, 50 );
myDefaultTextureUsed = true;
myClippingTexture = QString();
+ myTextureModulated = true;
+ myClippingTextureScale = 1.0;
}
}
// 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 );
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 );
}
/*!
- 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;
}
/*!
aGraphic3dPlane->SetCappingMaterial( aMaterialAspect );
// set capping texture
- aGraphic3dPlane->SetCappingTexture( initClippingTexture( myDefaultTextureUsed, myClippingTexture) );
+ aGraphic3dPlane->SetCappingTexture( initClippingTexture( myDefaultTextureUsed, myClippingTexture,
+ myTextureModulated, myClippingTextureScale ) );
return aGraphic3dPlane;
}
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; }
QColor myClippingColor;
bool myDefaultTextureUsed;
QString myClippingTexture;
+ bool myTextureModulated;
+ double myClippingTextureScale;
};