- **Clipping parameters** - specifies the default clipping plane parameters.
- - **Color** - allows to change the color of the clipped region.
+ - **Use color of clipped object** - allows to use the color of the clipped object in its clipped region.
+ - **Color** - allows to change the color of the entire clipped region (only used, if "Use color of clipped object" is switched off).
+
+ .. note::
+ Any of the above colors is only used, if "Modulate" is switched on and either "Use default texture" is checked or any texture with "non-black" pixels is given.
+
- **Use default texture** - if this option is switched on, the default texture will be used for clipping texture, otherwise - the texture specified in "Texture" field.
- **Texture** - allows to change the texture of the clipped region (enable if "Use default texture" is switched off).
+
+ .. note::
+ If "Use default texture" is switched off and no texture is given, the clipping region will be black. If you want the clipping region to be colored, provide a small white texture image, e.g. 8x8 pixels, and check the "Modulate" option.
+
- **Modulate** - controls if "Texture" should be mixed with "Color" parameter or not.
- **Scale factor** - sets the scale factor for default and custom textures.
resMgr->stringValue( "OCCViewer", "clipping_texture", vm->clippingTexture() ),
resMgr->booleanValue( "OCCViewer", "clipping_modulate", vm->isTextureModulated() ),
resMgr->doubleValue( "OCCViewer", "clipping_scale", vm->clippingTextureScale() ) );
-
+ vm->setClippingUseObjColor( resMgr->booleanValue( "OCCViewer", "clipping_use_object_color", vm->isClippingObjColorUsed() ) );
viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface
new LightApp_OCCSelector( (OCCViewer_Viewer*)viewMgr->getViewModel(), mySelMgr );
// ... "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 object color
+ pref->addPreference( tr( "PREF_CLIPPING_USE_OBJECT_COLOR" ), texturePref,
+ LightApp_Preferences::Bool, "OCCViewer", "clipping_use_object_color" );
+ // .... -> clipping color
+ pref->addPreference( tr( "PREF_CLIPPING_COLOR" ), texturePref,
+ LightApp_Preferences::Color, "OCCViewer", "clipping_color" );
+
// .... -> use default texture
pref->addPreference( tr( "PREF_CLIPPING_DEFAULT_TEXTURE" ), texturePref,
LightApp_Preferences::Bool, "OCCViewer", "clipping_use_default_texture" );
}
#endif
+#ifndef DISABLE_OCCVIEWER
+ if ( sec == QString( "OCCViewer" ) && param == QString( "clipping_use_object_color" ) )
+ {
+ bool useObjColor = resMgr->booleanValue( "OCCViewer", "clipping_use_object_color" );
+ 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->setClippingUseObjColor( useObjColor );
+ }
+ }
+#endif
+
#ifndef DISABLE_OCCVIEWER
if ( sec == QString( "OCCViewer" ) && param == QString( "projection_mode" ) )
{
<parameter name="enable_quad_buffer_support" value="false"/>
<parameter name="enable_preselection" value="true"/>
<parameter name="enable_selection" value="true"/>
+ <parameter name="clipping_use_object_color" value="true"/>
<parameter name="clipping_color" value="50, 50, 50"/>
<parameter name="clipping_use_default_texture" value="true"/>
<parameter name="clipping_modulate" value="true"/>
<source>PREF_GROUP_CLIPPING</source>
<translation>Clipping parameters</translation>
</message>
+ <message>
+ <source>PREF_CLIPPING_USE_OBJECT_COLOR</source>
+ <translation>Use color of clipped object</translation>
+ </message>
<message>
<source>PREF_CLIPPING_COLOR</source>
<translation>Color</translation>
<source>PREF_GROUP_CLIPPING</source>
<translation>Plan de coupe</translation>
</message>
+ <message>
+ <source>PREF_CLIPPING_USE_OBJECT_COLOR</source>
+ <translation>Utiliser la couleur de l'objet découpé</translation>
+ </message>
<message>
<source>PREF_CLIPPING_COLOR</source>
<translation>Couleur</translation>
<source>PREF_GROUP_CLIPPING</source>
<translation>クリッピングパラメータ</translation>
</message>
+ <message>
+ <source>PREF_CLIPPING_USE_OBJECT_COLOR</source>
+ <translation>切り取られたオブジェクトの色を使用する</translation>
+ </message>
<message>
<source>PREF_CLIPPING_COLOR</source>
<translation>色</translation>
double aDistance = aZmax;
double aRelativeDistance = aLength > 0.01 ? aDistance / aLength : 0.0;
- aRelativeDistance = qMin( aRelativeDistance, aLength );
+ aRelativeDistance = qMin( aRelativeDistance, 1.0 );
aRelativeDistance = qMax( aRelativeDistance, 0.0 );
theDistance = aRelativeDistance;
}
}
}
myPreviewPlaneVector.clear();
+ myModel->updateTrihedron();
myModel->update();
myInteractor->setEnabled( false );
}
myClippingTexture = QString();
myTextureModulated = true;
myClippingTextureScale = 1.0;
+ // By default, use the object color in the clipping plane
+ myClippingUseObjColor = true;
}
}
}
+/*!
+ Sets whether to use the color of the clipped object for the clipped region
+ \param theUseObjColor - whether to use color of clipped object
+*/
+void OCCViewer_Viewer::setClippingUseObjColor( bool theUseObjColor )
+{
+ myClippingUseObjColor = theUseObjColor;
+
+ if( myInternalClipPlanes.IsEmpty() )
+ return;
+
+ for ( Graphic3d_SequenceOfHClipPlane::Iterator aPlaneIt ( myInternalClipPlanes ); aPlaneIt.More(); aPlaneIt.Next() )
+ aPlaneIt.Value()->SetUseObjectMaterial(theUseObjColor);
+
+ update();
+}
+
+/*!
+ \return whether object color is used for clipping region
+*/
+bool OCCViewer_Viewer::isClippingObjColorUsed() const
+{
+ return myClippingUseObjColor;
+}
+
/*!
Sets a color of the clipped region
\param theColor - a new color of the clipped region
return myClippingColor;
}
+/*!
+ Set the texture's scale factor
+*/
+inline void setTextureScale(Handle(Graphic3d_TextureMap) aTexture, double theScale)
+{
+ aTexture->GetParams()->SetScale( Graphic3d_Vec2( 1/( theScale*100 ), -1 / ( theScale*100 ) ) );
+}
+
// initialize a texture for clipped region
Handle(Graphic3d_Texture2Dmanual) initClippingTexture( const bool isDefault, const QString& theTexture,
const bool isModulate, const double theScale )
if( aTexture->IsDone() ) {
aTexture->EnableRepeat();
isModulate ? aTexture->EnableModulate() : aTexture->DisableModulate();
- aTexture->GetParams()->SetScale( Graphic3d_Vec2( 1/( theScale*100 ), -1 / ( theScale*100 ) ) );
+ setTextureScale( aTexture, theScale );
}
return aTexture;
}
if( myInternalClipPlanes.IsEmpty() )
return;
+ double hatchScale = computeHatchScale();
Handle(Graphic3d_Texture2Dmanual) aTexture =
initClippingTexture( myDefaultTextureUsed, myClippingTexture,
- myTextureModulated, myClippingTextureScale );
+ myTextureModulated, hatchScale);
for ( Graphic3d_SequenceOfHClipPlane::Iterator aPlaneIt ( myInternalClipPlanes ); aPlaneIt.More(); aPlaneIt.Next() )
aPlaneIt.Value()->SetCappingTexture( aTexture );
return false;
double aMaxSide = computeSceneSize( view3d );
+ setClippingTextureParams(myDefaultTextureUsed, myClippingTexture, myTextureModulated, myClippingTextureScale);
// IPAL21687
// The boundary box of the view may be initialized but nullified
/*!
* Update the size of the trihedron
*/
-void OCCViewer_Viewer::updateTrihedron() {
+void OCCViewer_Viewer::updateTrihedron()
+{
if ( myTrihedron.IsNull() )
return;
setCappingColor( aGraphic3dPlane, myClippingColor );
// set capping texture
+ double hatchScale = computeHatchScale();
aGraphic3dPlane->SetCappingTexture( initClippingTexture( myDefaultTextureUsed, myClippingTexture,
- myTextureModulated, myClippingTextureScale ) );
+ myTextureModulated, hatchScale ) );
+ aGraphic3dPlane->SetUseObjectMaterial(myClippingUseObjColor);
return aGraphic3dPlane;
}
myClipPlanes.push_back( aPlane );
}
- // 3. Apply clipping planes
- AIS_ListOfInteractive aList;
- myAISContext->DisplayedObjects (aList);
- for ( AIS_ListIteratorOfListOfInteractive anIter (aList); anIter.More(); anIter.Next() ) {
- Handle(AIS_InteractiveObject) anObj = anIter.Value();
- Handle(ViewerData_AISShape) aShape = Handle(ViewerData_AISShape)::DownCast (anObj);
- if (!aShape.IsNull() && aShape->IsClippable()) {
- aShape->SetClipPlanes(new Graphic3d_SequenceOfHClipPlane(myInternalClipPlanes)); // todo: store clipping planes in a handle?
- }
- }
+ applyClippingPlanes(false);
}
/*!
}
}
+/*!
+ Applies clipping planes to all visible (and clippable) objects
+*/
+void OCCViewer_Viewer::applyClippingPlanes(bool theUpdateHatch)
+{
+ if (myInternalClipPlanes.IsEmpty()) {
+ return; // Nothing to do
+ }
+
+ if (theUpdateHatch) {
+ double hatchScale = computeHatchScale();
+ for ( Graphic3d_SequenceOfHClipPlane::Iterator aPlaneIt ( myInternalClipPlanes ); aPlaneIt.More(); aPlaneIt.Next() ) {
+ Handle(Graphic3d_TextureMap) aTexture = aPlaneIt.Value()->CappingTexture();
+ setTextureScale(aTexture, hatchScale);
+ }
+ }
+
+ AIS_ListOfInteractive aList;
+ myAISContext->DisplayedObjects (aList);
+ for ( AIS_ListIteratorOfListOfInteractive anIter (aList); anIter.More(); anIter.Next() ) {
+ Handle(AIS_InteractiveObject) anObj = anIter.Value();
+ Handle(ViewerData_AISShape) aShape = Handle(ViewerData_AISShape)::DownCast (anObj);
+ if (!aShape.IsNull() && aShape->IsClippable()) {
+ aShape->SetClipPlanes(new Graphic3d_SequenceOfHClipPlane(myInternalClipPlanes));
+ }
+ }
+}
+
/*!
Returns the pointer to the clipping dialog box.
*/
}
return prev;
}
+
+ double OCCViewer_Viewer::computeHatchScale() const
+ {
+ // bos#40617:
+ // Update the hatch scale of the clipping texture based on the total size of all visible objects
+ double hatchScale = myClippingTextureScale;
+ Handle(V3d_Viewer) viewer = getViewer3d();
+ viewer->InitActiveViews();
+ if (viewer->MoreActiveViews())
+ {
+ Handle(V3d_View) view3d = viewer->ActiveView();
+ if ( !view3d.IsNull() )
+ {
+ double aMaxSide = computeSceneSize( view3d );
+ hatchScale = aMaxSide * myClippingTextureScale * 0.01;
+ }
+ }
+ return hatchScale;
+ }
virtual QString getType() const { return Type(); }
virtual void contextMenuPopup(QMenu*);
-
+ virtual void applyClippingPlanes(bool theUpdateHatch);
+
void getSelectedObjects(AIS_ListOfInteractive& theList);
void setObjectsSelected(const AIS_ListOfInteractive& theList);
void setSelected(const Handle(AIS_InteractiveObject)& theIO) { myAISContext->SetSelected(theIO,Standard_True);}
bool enableDrawMode( bool on );
+ void setClippingUseObjColor( bool use );
+ bool isClippingObjColorUsed() const;
+
void setClippingColor( const QColor& );
QColor clippingColor() const;
protected:
+ double computeHatchScale() const;
+
+
Handle(V3d_Viewer) myV3dViewer;
Handle(AIS_ColorScale) myColorScale;
Handle(AIS_Trihedron) myTrihedron;
ClipPlanesList myClipPlanes;
Graphic3d_SequenceOfHClipPlane myInternalClipPlanes;
+ bool myClippingUseObjColor;
QColor myClippingColor;
bool myDefaultTextureUsed;
QString myClippingTexture;
Handle(Graphic3d_ClipPlane) aClipPlane = anIter.Value();
aClipPlane->SetEquation(pln);
aClipPlane->SetOn(Standard_True);
+ aClipPlane->SetUseObjectMaterial(true);
} else {
view->AddClipPlane( myModel->createClipPlane( pln, Standard_True ) );
}
virtual QString getType() const { return "SUIT_ViewModel"; }
virtual void contextMenuPopup( QMenu* ) {}
+ virtual void applyClippingPlanes( bool theUpdateHatch ) {}
static void setHotButton( InteractionStyle theInteractionStyle, HotOperation theOper,
Qt::KeyboardModifiers theState, Qt::MouseButtons theButton );