protected:
-
-
-
-private:
-
-
Standard_EXPORT void GetDefModes (const Handle(AIS_InteractiveObject)& anIobj, Standard_Integer& Dmode, Standard_Integer& HiMod, Standard_Integer& SelMode) const;
Standard_EXPORT void EraseGlobal (const Handle(AIS_InteractiveObject)& anObj, const Standard_Boolean updateviewer = Standard_True);
Standard_EXPORT void redisplayPrsRecModes (const Handle(AIS_InteractiveObject)& theIObj, const Standard_Boolean theToUpdateViewer = Standard_True);
//! Helper function to unhighlight all entity owners currently highlighted with seleciton color.
- void unhighlightOwners (const Handle(AIS_InteractiveObject)& theObject);
+ Standard_EXPORT void unhighlightOwners (const Handle(AIS_InteractiveObject)& theObject);
//! Helper function that highlights the owner given with <theColor> without
//! performing AutoHighlight checks, e.g. is used for dynamic highlight.
//! If the parameter <theViewer> is set and <theIsImmediate> is true, highlight will be synchronized
//! automatically in all views of the viewer.
- void highlightWithColor (const Handle(SelectMgr_EntityOwner)& theOwner,
- const Quantity_NameOfColor theColor,
- const Handle(V3d_Viewer)& theViewer = NULL);
+ Standard_EXPORT void highlightWithColor (const Handle(SelectMgr_EntityOwner)& theOwner,
+ const Quantity_NameOfColor theColor,
+ const Handle(V3d_Viewer)& theViewer = NULL);
//! Helper function that highlights the owner given with <theColor> with check
//! for AutoHighlight, e.g. is used for selection.
//! If the parameter <theViewer> is set and <theIsImmediate> is true, selection color will be synchronized
//! automatically in all views of the viewer.
- void highlightSelected (const Handle(SelectMgr_EntityOwner)& theOwner,
- const Quantity_NameOfColor theSelColor);
+ Standard_EXPORT void highlightSelected (const Handle(SelectMgr_EntityOwner)& theOwner,
+ const Quantity_NameOfColor theSelColor);
//! Helper function that unhighlights all owners that are stored in current AIS_Selection.
//! The function updates global status and selection state of owner and interactive object.
//! If the parameter <theIsToHilightSubIntensity> is set to true, interactive objects with sub-intensity
//! switched on in AIS_GlobalStatus will be highlighted with context's sub-intensity color.
- void unhighlightSelected (const Standard_Boolean theIsToHilightSubIntensity = Standard_False);
+ Standard_EXPORT void unhighlightSelected (const Standard_Boolean theIsToHilightSubIntensity = Standard_False);
+
+protected:
AIS_DataMapOfIOStatus myObjects;
Handle(SelectMgr_SelectionManager) mgrSelector;
//=======================================================================
XCAFPrs_AISObject::XCAFPrs_AISObject (const TDF_Label& theLabel)
-: AIS_ColoredShape(TopoDS_Shape())
+: AIS_ColoredShape(TopoDS_Shape()),
+ myToSyncStyles (Standard_True)
{
// define plastic material by default for proper color reproduction
- SetMaterial (Graphic3d_NOM_PLASTIC);
+ setMaterial (myDrawer, Graphic3d_NOM_PLASTIC, Standard_False, Standard_False);
+ hasOwnMaterial = Standard_True;
+
myLabel = theLabel;
}
}
//=======================================================================
-//function : Compute
-//purpose :
+//function : DispatchStyles
+//purpose :
//=======================================================================
-void XCAFPrs_AISObject::Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
- const Handle(Prs3d_Presentation)& thePrs,
- const Standard_Integer theMode)
+void XCAFPrs_AISObject::DispatchStyles (const Standard_Boolean theToSyncStyles)
{
- TopoDS_Shape aShape;
- if (!XCAFDoc_ShapeTool::GetShape (myLabel, aShape) || aShape.IsNull()) return;
+ myToSyncStyles = theToSyncStyles;
+ myShapeColors.Clear();
- // Shape vide -> Assemblage vide.
- if (aShape.ShapeType() == TopAbs_COMPOUND)
+ TopoDS_Shape aShape;
+ if (!XCAFDoc_ShapeTool::GetShape (myLabel, aShape) || aShape.IsNull())
{
- TopoDS_Iterator anExplor (aShape);
- if (!anExplor.More())
- {
- return;
- }
+ Set (TopoDS_Shape());
+ return;
}
-
Set (aShape);
- ClearCustomAspects();
// Collecting information on colored subshapes
TopLoc_Location aLoc;
XCAFPrs_DataMapOfShapeStyle aSettings;
- XCAFPrs::CollectStyleSettings ( myLabel, aLoc, aSettings );
+ XCAFPrs::CollectStyleSettings (myLabel, aLoc, aSettings);
// Getting default colors
XCAFPrs_Style aDefStyle;
SetColors (aDrawer, aColorCurv, aColorSurf);
}
aStyleGroups.Clear();
+}
+
+//=======================================================================
+//function : Compute
+//purpose :
+//=======================================================================
+void XCAFPrs_AISObject::Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
+ const Handle(Prs3d_Presentation)& thePrs,
+ const Standard_Integer theMode)
+{
+ // update shape and sub-shapes styles only on first compute, or on first recompute
+ if (myToSyncStyles)
+ {
+ Standard_Boolean toMapStyles = myToSyncStyles;
+ for (PrsMgr_Presentations::Iterator aPrsIter (myPresentations); aPrsIter.More(); aPrsIter.Next())
+ {
+ if (aPrsIter.Value().Presentation()->Presentation() != thePrs
+ && !aPrsIter.Value().Presentation()->MustBeUpdated())
+ {
+ toMapStyles = Standard_False;
+ break;
+ }
+ }
+ if (toMapStyles)
+ {
+ DispatchStyles (Standard_True);
+ }
+ }
+ if (myshape.IsNull())
+ {
+ return;
+ }
+
+ if (myshape.ShapeType() == TopAbs_COMPOUND)
+ {
+ TopoDS_Iterator anExplor (myshape);
+ if (!anExplor.More())
+ {
+ return;
+ }
+ }
AIS_ColoredShape::Compute (thePresentationManager, thePrs, theMode);
theStyle.SetColorSurf (Quantity_NOC_WHITE);
theStyle.SetColorCurv (Quantity_NOC_WHITE);
}
+
+// =======================================================================
+// function : SetMaterial
+// purpose :
+// =======================================================================
+void XCAFPrs_AISObject::SetMaterial (const Graphic3d_MaterialAspect& theMaterial)
+{
+ XCAFPrs_Style aDefStyle;
+ DefaultStyle (aDefStyle);
+ setMaterial (myDrawer, theMaterial, HasColor(), IsTransparent());
+ SetColors (myDrawer, aDefStyle.GetColorCurv(), aDefStyle.GetColorSurf());
+ for (AIS_DataMapOfShapeDrawer::Iterator anIter (myShapeColors); anIter.More(); anIter.Next())
+ {
+ const Handle(AIS_ColoredDrawer)& aDrawer = anIter.Value();
+
+ // take current color
+ const Quantity_Color aColorCurv = aDrawer->WireAspect()->Aspect()->Color();
+ const Quantity_Color aSurfColor = aDrawer->ShadingAspect()->Aspect()->InteriorColor();
+
+ // SetColors() will take the material from myDrawer
+ SetColors (aDrawer, aColorCurv, aSurfColor);
+ }
+ SynchronizeAspects();
+}
myLabel = theLabel;
}
+ //! Fetch the Shape from associated Label and fill the map of sub-shapes styles.
+ //! By default, this method is called implicitly within first ::Compute().
+ //! Application might call this method explicitly to manipulate styles afterwards.
+ //! @param theToSyncStyles flag indicating if method ::Compute() should call this method again
+ //! on first compute or re-compute
+ Standard_EXPORT virtual void DispatchStyles (const Standard_Boolean theToSyncStyles = Standard_False);
+
+ //! Sets the material aspect.
+ //! This method assigns the new default material without overriding XDE styles.
+ //! Re-computation of existing presentation is not required after calling this method.
+ Standard_EXPORT virtual void SetMaterial (const Graphic3d_MaterialAspect& theMaterial) Standard_OVERRIDE;
+
protected:
//! Redefined method to compute presentation.
protected:
- TDF_Label myLabel;
+ TDF_Label myLabel; //!< label pointing onto the shape
+ Standard_Boolean myToSyncStyles; //!< flag indicating that shape and sub-shapes should be updates within Compute()
public: