- <b>XZ View</b>
- <b>YZ View</b>
- <b>XY View</b>
+
+- <b>Clipping parameters</b> - specifies the default clipping plane parameters.
+ - <b>Color</b> - allows to change the color of the clipped region.
+ - <b>Use default texture</b> - if this option is switched on, the default texture
+ will be used for clipping texture, otherwise - the texture specified in "Texture" field.
+ - <b>Texture</b> - allows to change the texture of the clipped region
+ (enable if "Use default texture" is switched off).
\anchor vtk_preferences
<h2>VTK 3D Viewer Preferences</h2>
vm->setZoomingStyle( resMgr->integerValue( "3DViewer", "zooming_mode", vm->zoomingStyle() ) );
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() ) );
+
viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface
new LightApp_OCCSelector( (OCCViewer_Viewer*)viewMgr->getViewModel(), mySelMgr );
LightApp_Preferences::Bool, "OCCViewer", "enable_selection" );
// ... "Selection" group <<end>>
+ // ... "Clipping" group <<start>>
+ int occClippingGroup = pref->addPreference( tr( "PREF_GROUP_CLIPPING" ), occGroup );
+ // .... -> clipping color
+ pref->addPreference( tr( "PREF_CLIPPING_COLOR" ), occClippingGroup,
+ LightApp_Preferences::Color, "OCCViewer", "clipping_color" );
+ int texturePref = pref->addPreference( "", occClippingGroup, LightApp_Preferences::Frame );
+ pref->setItemProperty( "columns", 2, texturePref );
+ // .... -> use default texture
+ pref->addPreference( tr( "PREF_CLIPPING_DEFAULT_TEXTURE" ), texturePref,
+ LightApp_Preferences::Bool, "OCCViewer", "clipping_use_default_texture" );
+ // .... -> clipping texture
+ int filePref = pref->addPreference( tr( "PREF_CLIPPING_TEXTURE" ), texturePref,
+ LightApp_Preferences::File, "OCCViewer", "clipping_texture" );
+ pref->setItemProperty( "path_filter", tr( "OCC_TEXTURE_FILES" ), filePref );
+ // ... "Clipping" group <<end>>
+
// ... -> empty frame (for layout) <<start>>
int occGen = pref->addPreference( "", occGroup, LightApp_Preferences::Frame );
pref->setItemProperty( "margin", 0, occGen );
}
#endif
+#ifndef DISABLE_OCCVIEWER
+ if ( sec == QString( "OCCViewer" ) && param == QString( "clipping_color" ) )
+ {
+ QColor aColor = resMgr->colorValue( "OCCViewer", "clipping_color", QColor( 50, 50, 50 ) );
+ 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->setClippingColor( aColor );
+ }
+ }
+#endif
+
+#ifndef DISABLE_OCCVIEWER
+ if ( sec == QString( "OCCViewer" ) && param == QString( "clipping_use_default_texture" ) )
+ {
+ 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" );
+ 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->setClippingTexture( aTexture );
+ }
+ }
+#endif
+
if ( sec == QString( "3DViewer" ) && param == QString( "zooming_mode" ) )
{
int mode = resMgr->integerValue( "3DViewer", "zooming_mode", 0 );
<!-- OCC viewer preferences -->
<parameter name="enable_preselection" value="true"/>
<parameter name="enable_selection" value="true"/>
+ <parameter name="clipping_color" value="50, 50, 50"/>
+ <parameter name="clipping_use_default_texture" value="true"/>
<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>PREF_PRESELECTION_DISABLED</source>
<translation>Disabled</translation>
</message>
+ <message>
+ <source>PREF_GROUP_CLIPPING</source>
+ <translation>Clipping parameters</translation>
+ </message>
+ <message>
+ <source>PREF_CLIPPING_COLOR</source>
+ <translation>Color</translation>
+ </message>
+ <message>
+ <source>PREF_CLIPPING_DEFAULT_TEXTURE</source>
+ <translation>Use default texture</translation>
+ </message>
+ <message>
+ <source>PREF_CLIPPING_TEXTURE</source>
+ <translation>Texture</translation>
+ </message>
+ <message>
+ <source>OCC_TEXTURE_FILES</source>
+ <translation>Image files (*.jpeg *jpg *.jpe *.png *.bmp *.gif *.ppm *.tif *.tiff* .tga *.exr)</translation>
+ </message>
<message>
<source>TOT_CLOSE</source>
<translation>Close</translation>
<source>PREF_PRESELECTION_DISABLED</source>
<translation>Désactivée</translation>
</message>
+ <message>
+ <source>PREF_GROUP_CLIPPING</source>
+ <translation>Plan de coupe</translation>
+ </message>
+ <message>
+ <source>PREF_CLIPPING_COLOR</source>
+ <translation>Couleur</translation>
+ </message>
+ <message>
+ <source>PREF_CLIPPING_DEFAULT_TEXTURE</source>
+ <translation type="unfinished">Use default texture</translation>
+ </message>
+ <message>
+ <source>PREF_CLIPPING_TEXTURE</source>
+ <translation>Texture</translation>
+ </message>
+ <message>
+ <source>OCC_TEXTURE_FILES</source>
+ <translation>Fichiers images (*.jpeg *jpg *.jpe *.png *.bmp *.gif *.ppm *.tif *.tiff* .tga *.exr)</translation>
+ </message>
<message>
<source>TOT_CLOSE</source>
<translation>Fermer</translation>
<source>PREF_PRESELECTION_DISABLED</source>
<translation>無効になっています。</translation>
</message>
+ <message>
+ <source>PREF_GROUP_CLIPPING</source>
+ <translation type="unfinished">Clipping</translation>
+ </message>
+ <message>
+ <source>PREF_CLIPPING_COLOR</source>
+ <translation type="unfinished">Color</translation>
+ </message>
+ <message>
+ <source>PREF_CLIPPING_DEFAULT_TEXTURE</source>
+ <translation type="unfinished">Use default texture</translation>
+ </message>
+ <message>
+ <source>PREF_CLIPPING_TEXTURE</source>
+ <translation type="unfinished">Texture</translation>
+ </message>
+ <message>
+ <source>OCC_TEXTURE_FILES</source>
+ <translation>イメージファイル (*.jpeg *jpg *.jpe *.png *.bmp *.gif *.ppm *.tif *.tiff* .tga *.exr)</translation>
+ </message>
<message>
<source>TOT_CLOSE</source>
<translation>閉じる</translation>
#include <AIS_ListIteratorOfListOfInteractive.hxx>
#include <Graphic3d_Texture2Dmanual.hxx>
+#include <Graphic3d_MaterialAspect.hxx>
#include <Graphic3d_TextureParams.hxx>
#include <Geom_Axis2Placement.hxx>
// selection
mySelectionEnabled = true;
myMultiSelectionEnabled = true;
+
+ //set clipping color and texture to standard
+ myClippingColor = QColor( 50, 50, 50 );
+ myDefaultTextureUsed = true;
+ myClippingTexture = QString();
+
}
/*!
}
}
+/*!
+ Sets a color of the clipped region
+ \param theColor - a new color of the clipped region
+*/
+void OCCViewer_Viewer::setClippingColor( const QColor& theColor )
+{
+ myClippingColor = theColor;
+
+ if( myInternalClipPlanes.IsEmpty() )
+ return;
+
+ Graphic3d_MaterialAspect aMaterialAspect = Graphic3d_MaterialAspect();
+ aMaterialAspect.SetColor( Quantity_Color( theColor.redF(), theColor.greenF(),
+ theColor.blueF(), Quantity_TOC_RGB ) );
+
+ for( int i = 1; i <= myInternalClipPlanes.Size(); i++ )
+ myInternalClipPlanes.Value(i)->SetCappingMaterial( aMaterialAspect );
+
+ update();
+}
+
+/*!
+ \return clipping color
+*/
+QColor OCCViewer_Viewer::clippingColor() const
+{
+ return myClippingColor;
+}
+
+// initialize a texture for clipped region
+Handle(Graphic3d_Texture2Dmanual) initClippingTexture( const bool isDefault, const QString& theTexture)
+{
+ QString aTextureFile = isDefault ? ":images/hatch.png" : theTexture;
+ QPixmap px( aTextureFile );
+ const Handle(Image_PixMap) aPixmap = OCCViewer_Utilities::imageToPixmap( px.toImage() );
+ 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 ) );
+ }
+ }
+ return aTexture;
+}
+
+/*!
+ Sets default texture enabled status
+ \param isUsed - new status
+*/
+void OCCViewer_Viewer::useDefaultTexture( const bool isUsed )
+{
+ myDefaultTextureUsed = isUsed;
+
+ if( myInternalClipPlanes.IsEmpty() )
+ return;
+
+ Handle(Graphic3d_Texture2Dmanual) aTexture =
+ initClippingTexture( myDefaultTextureUsed, myClippingTexture );
+
+ for( int i = 1; i <= myInternalClipPlanes.Size(); i++ )
+ myInternalClipPlanes.Value(i)->SetCappingTexture( aTexture );
+
+ update();
+}
+
+/*!
+ \return true if default texture is used
+*/
+bool OCCViewer_Viewer::isDefaultTextureUsed() const
+{
+ return myDefaultTextureUsed;
+}
+
+/*!
+ Sets a texture of the clipped region
+ \param theTexture - a new texture of the clipped region
+*/
+void OCCViewer_Viewer::setClippingTexture( const QString& theTexture )
+{
+ 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 );
+
+ update();
+}
+
+/*!
+ \return clipping texture
+*/
+QString OCCViewer_Viewer::clippingTexture() const
+{
+ return myClippingTexture;
+}
+
/*!
Builds popup for occ viewer
*/
aGraphic3dPlane->SetOn( theIsOn );
aGraphic3dPlane->SetCapping( Standard_True );
- // load capping texture
- QPixmap px( ":images/hatch.png" );
- if( !px.isNull() ) {
- const Handle(Image_PixMap) aPixmap = OCCViewer_Utilities::imageToPixmap( px.toImage() );
- Handle(Graphic3d_Texture2Dmanual) aTexture = new Graphic3d_Texture2Dmanual( aPixmap );
- if( aTexture->IsDone() ) {
- aTexture->EnableModulate();
- aTexture->EnableRepeat();
- aTexture->GetParams()->SetScale( Graphic3d_Vec2( 0.01, 0.01 ) );
- aGraphic3dPlane->SetCappingTexture( aTexture );
- }
- }
+ // set capping color
+ Graphic3d_MaterialAspect aMaterialAspect = Graphic3d_MaterialAspect();
+ aMaterialAspect.SetColor( Quantity_Color( myClippingColor.redF(), myClippingColor.greenF(),
+ myClippingColor.blueF(), Quantity_TOC_RGB ) );
+ aGraphic3dPlane->SetCappingMaterial( aMaterialAspect );
+
+ // set capping texture
+ aGraphic3dPlane->SetCappingTexture( initClippingTexture( myDefaultTextureUsed, myClippingTexture) );
+
return aGraphic3dPlane;
}
/*!
void enableMultiselection(bool isEnable);
bool isMultiSelectionEnabled() const { return myMultiSelectionEnabled; }
+ void setClippingColor( const QColor& );
+ QColor clippingColor() const;
+
+ void useDefaultTexture( const bool );
+ bool isDefaultTextureUsed() const;
+
+ void setClippingTexture( const QString& );
+ QString clippingTexture() const;
+
int getSelectionCount() const { return (!myAISContext.IsNull())? myAISContext->NbSelected():0; }
void setStaticTrihedronDisplayed(const bool on);
void onChangeBackground();
protected:
+
Handle(V3d_Viewer) myV3dViewer;
Handle(AIS_Trihedron) myTrihedron;
ClipPlanesList myClipPlanes;
Graphic3d_SequenceOfHClipPlane myInternalClipPlanes;
+
+ QColor myClippingColor;
+ bool myDefaultTextureUsed;
+ QString myClippingTexture;
+
};
#ifdef WIN32