1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-04 18:06:22 +03:00

0030674: Visualization, AIS_InteractiveObject - fix accessibility of several properties

AIS_InteractiveObject/SelectMgr_SelectableObject/PrsMgr_PresentableObject
- added missing getters;
- removed redundant private sections;
- improved documentation;
- AIS_InteractiveObject::Compute() marked as pure interface;
- methods within this hierarchy have been moved to the base class, when reasonable.

Removed redundant typedefs to pointers (PrsMgr_PresentationPointer, PrsMgr_PresentableObjectPointer).
This commit is contained in:
kgv 2019-04-04 09:44:16 +03:00 committed by bugmaster
parent 2506cf29b3
commit 2b88626548
16 changed files with 943 additions and 1285 deletions

View File

@ -17,21 +17,14 @@
#ifndef _AIS_IdenticRelation_HeaderFile
#define _AIS_IdenticRelation_HeaderFile
#include <Standard.hxx>
#include <Standard_Type.hxx>
#include <Standard_Boolean.hxx>
#include <gp_Pnt.hxx>
#include <AIS_Relation.hxx>
#include <gp_Pnt.hxx>
#include <PrsMgr_PresentationManager3d.hxx>
#include <Standard_Integer.hxx>
#include <SelectMgr_Selection.hxx>
#include <Standard_Real.hxx>
#include <TColStd_ListOfTransient.hxx>
class TopoDS_Shape;
class Geom_Plane;
class Prs3d_Presentation;
class Prs3d_Projector;
class Geom_Transformation;
class Geom_Line;
class gp_Pnt;
class Geom_Circle;
@ -40,8 +33,6 @@ class TopoDS_Wire;
class TopoDS_Vertex;
class gp_Dir;
class AIS_IdenticRelation;
DEFINE_STANDARD_HANDLE(AIS_IdenticRelation, AIS_Relation)
//! Constructs a constraint by a relation of identity

View File

@ -1807,6 +1807,7 @@ void AIS_InteractiveContext::UnsetTransparency (const Handle(AIS_InteractiveObje
void AIS_InteractiveContext::SetSelectedAspect (const Handle(Prs3d_BasicAspect)& theAspect,
const Standard_Boolean theToUpdateViewer)
{
Standard_DISABLE_DEPRECATION_WARNINGS
Standard_Boolean isFound = Standard_False;
for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
{
@ -1814,6 +1815,7 @@ void AIS_InteractiveContext::SetSelectedAspect (const Handle(Prs3d_BasicAspect)&
Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (aSelIter.Value()->Selectable());
anObj->SetAspect (theAspect);
}
Standard_ENABLE_DEPRECATION_WARNINGS
if (isFound && theToUpdateViewer)
{

View File

@ -454,6 +454,7 @@ public: //! @name iteration through detected entities
public: //! @name Selection management
//! Sets the graphic basic aspect to the current presentation of ALL selected objects.
Standard_DEPRECATED ("Deprecated method - presentation attributes should be assigned directly to object")
Standard_EXPORT void SetSelectedAspect (const Handle(Prs3d_BasicAspect)& theAspect,
const Standard_Boolean theToUpdateViewer);

View File

@ -16,32 +16,21 @@
#include <AIS_InteractiveObject.hxx>
#include <AIS_GraphicTool.hxx>
#include <AIS_InteractiveContext.hxx>
#include <Aspect_PolygonOffsetMode.hxx>
#include <Bnd_Box.hxx>
#include <Graphic3d_AspectFillArea3d.hxx>
#include <Graphic3d_AspectLine3d.hxx>
#include <Graphic3d_AspectMarker3d.hxx>
#include <Graphic3d_AspectText3d.hxx>
#include <Graphic3d_BndBox4f.hxx>
#include <Graphic3d_CStructure.hxx>
#include <Graphic3d_Group.hxx>
#include <Graphic3d_MaterialAspect.hxx>
#include <Graphic3d_Structure.hxx>
#include <Prs3d_BasicAspect.hxx>
#include <Prs3d_LineAspect.hxx>
#include <Prs3d_PointAspect.hxx>
#include <Prs3d_Presentation.hxx>
#include <Prs3d_Root.hxx>
#include <Prs3d_ShadingAspect.hxx>
#include <Prs3d_TextAspect.hxx>
#include <PrsMgr_ModedPresentation.hxx>
#include <PrsMgr_PresentationManager3d.hxx>
#include <Quantity_Color.hxx>
#include <Standard_Transient.hxx>
#include <Standard_Type.hxx>
#include <TColStd_ListIteratorOfListOfInteger.hxx>
#include <PrsMgr_PresentationManager.hxx>
IMPLEMENT_STANDARD_RTTIEXT(AIS_InteractiveObject,SelectMgr_SelectableObject)
@ -51,14 +40,9 @@ IMPLEMENT_STANDARD_RTTIEXT(AIS_InteractiveObject,SelectMgr_SelectableObject)
//=======================================================================
AIS_InteractiveObject::AIS_InteractiveObject (const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d)
: SelectMgr_SelectableObject (aTypeOfPresentation3d),
myCTXPtr (NULL),
myOwnWidth (0.0f),
myCurrentFacingModel (Aspect_TOFM_BOTH_SIDE),
myInfiniteState (Standard_False),
hasOwnColor (Standard_False),
hasOwnMaterial (Standard_False)
myCTXPtr (NULL)
{
SetCurrentFacingModel();
//
}
//=======================================================================
@ -73,22 +57,6 @@ void AIS_InteractiveObject::Redisplay (const Standard_Boolean AllModes)
myCTXPtr->Redisplay (this, Standard_False, AllModes);
}
//=======================================================================
//function : Type
//purpose :
//=======================================================================
AIS_KindOfInteractive AIS_InteractiveObject::Type() const
{return AIS_KOI_None;}
//=======================================================================
//function : Signature
//purpose :
//=======================================================================
Standard_Integer AIS_InteractiveObject::Signature() const
{return -1;}
//=======================================================================
//function :
//purpose :
@ -116,252 +84,6 @@ void AIS_InteractiveObject::SetContext (const Handle(AIS_InteractiveContext)& th
}
}
//=======================================================================
//function :
//purpose :
//=======================================================================
Standard_Boolean AIS_InteractiveObject::HasOwner() const
{
return (!myOwner.IsNull());
}
//=======================================================================
//function :
//purpose :
//=======================================================================
void AIS_InteractiveObject::ClearOwner()
{
myOwner.Nullify();
}
//=======================================================================
//function : SetDisplayMode
//purpose :
//=======================================================================
void AIS_InteractiveObject::SetDisplayMode (const Standard_Integer theMode)
{
if (AcceptDisplayMode (theMode))
{
myDrawer->SetDisplayMode (theMode);
}
}
//=======================================================================
//function :
//purpose :
//=======================================================================
void AIS_InteractiveObject::SetCurrentFacingModel(const Aspect_TypeOfFacingModel aModel) {
myCurrentFacingModel = aModel;
}
//=======================================================================
//function : CurrentFacingModel
//purpose :
//=======================================================================
Aspect_TypeOfFacingModel AIS_InteractiveObject::CurrentFacingModel() const {
return myCurrentFacingModel;
}
//=======================================================================
//function : SetColor
//purpose :
//=======================================================================
void AIS_InteractiveObject::SetColor(const Quantity_Color& theColor)
{
myDrawer->SetColor (theColor);
hasOwnColor = Standard_True;
}
//=======================================================================
//function : UnsetColor
//purpose :
//=======================================================================
void AIS_InteractiveObject::UnsetColor()
{
hasOwnColor = Standard_False;
}
//=======================================================================
//function :
//purpose :
//=======================================================================
void AIS_InteractiveObject::SetWidth(const Standard_Real aValue)
{
myOwnWidth = (Standard_ShortReal )aValue;
}
//=======================================================================
//function :
//purpose :
//=======================================================================
void AIS_InteractiveObject::UnsetWidth()
{
myOwnWidth = 0.0f;
}
//=======================================================================
//function : Material
//purpose :
//=======================================================================
Graphic3d_NameOfMaterial AIS_InteractiveObject::Material() const
{
return myDrawer->ShadingAspect()->Material().Name();
}
//=======================================================================
//function : SetMaterial
//purpose :
//=======================================================================
void AIS_InteractiveObject::SetMaterial (const Graphic3d_MaterialAspect& theMaterial)
{
if (!myDrawer->HasOwnShadingAspect())
{
myDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
if (myDrawer->HasLink())
{
*myDrawer->ShadingAspect()->Aspect() = *myDrawer->Link()->ShadingAspect()->Aspect();
}
}
myDrawer->ShadingAspect()->SetMaterial (theMaterial);
hasOwnMaterial = Standard_True;
}
//=======================================================================
//function : UnsetMaterial
//purpose :
//=======================================================================
void AIS_InteractiveObject::UnsetMaterial()
{
if (!HasMaterial())
{
return;
}
if (HasColor() || IsTransparent())
{
if(myDrawer->HasLink())
{
myDrawer->ShadingAspect()->SetMaterial (AIS_GraphicTool::GetMaterial (myDrawer->Link()));
}
if (HasColor())
{
SetColor (myDrawer->Color());
}
if (IsTransparent())
{
SetTransparency (myDrawer->Transparency());
}
}
else
{
Handle(Prs3d_ShadingAspect) anAspect;
myDrawer->SetShadingAspect (anAspect);
}
hasOwnMaterial = Standard_False;
}
//=======================================================================
//function : SetTransparency
//purpose :
//=======================================================================
void AIS_InteractiveObject::SetTransparency (const Standard_Real theValue)
{
if (!myDrawer->HasOwnShadingAspect())
{
myDrawer->SetShadingAspect(new Prs3d_ShadingAspect());
if(myDrawer->HasLink())
myDrawer->ShadingAspect()->SetMaterial(AIS_GraphicTool::GetMaterial(myDrawer->Link()));
}
myDrawer->ShadingAspect()->Aspect()->ChangeFrontMaterial().SetTransparency (Standard_ShortReal(theValue));
myDrawer->ShadingAspect()->Aspect()->ChangeBackMaterial() .SetTransparency (Standard_ShortReal(theValue));
myDrawer->SetTransparency (Standard_ShortReal(theValue));
}
//=======================================================================
//function : UnsetTransparency
//purpose :
//=======================================================================
void AIS_InteractiveObject::UnsetTransparency()
{
if(HasColor() || HasMaterial() )
{
myDrawer->ShadingAspect()->Aspect()->ChangeFrontMaterial().SetTransparency (0.0f);
myDrawer->ShadingAspect()->Aspect()->ChangeBackMaterial() .SetTransparency (0.0f);
}
else{
Handle (Prs3d_ShadingAspect) SA;
myDrawer->SetShadingAspect(SA);
}
myDrawer->SetTransparency (0.0f);
}
//=======================================================================
//function : Transparency
//purpose :
//=======================================================================
Standard_Real AIS_InteractiveObject::Transparency() const
{
return (myDrawer->Transparency() <= 0.005f ? 0.0 : myDrawer->Transparency());
// Graphic3d_MaterialAspect Mat = myDrawer->ShadingAspect()->Aspect()->FrontMaterial();
// return Mat.Transparency();
}
//=======================================================================
//function : UnsetAttributes
//purpose :
//=======================================================================
void AIS_InteractiveObject::UnsetAttributes()
{
SelectMgr_SelectableObject::UnsetAttributes();
hasOwnColor = Standard_False;
hasOwnMaterial = Standard_False;
myOwnWidth = 0.0f;
myDrawer->SetTransparency (0.0f);
}
//=======================================================================
//function : AcceptDisplayMode
//purpose :
//=======================================================================
Standard_Boolean AIS_InteractiveObject::AcceptDisplayMode(const Standard_Integer ) const
{return Standard_True;}
//=======================================================================
//function : DefaultDisplayMode
//purpose :
//=======================================================================
Standard_Integer AIS_InteractiveObject::DefaultDisplayMode() const
{return 0;}
//=======================================================================
//function : SetInfiniteState
//purpose :
//=======================================================================
void AIS_InteractiveObject::SetInfiniteState(const Standard_Boolean aFlag)
{
myInfiniteState = aFlag;
Handle(Prs3d_Presentation) P;
for(Standard_Integer i =1; i<=myPresentations.Length();i++)
{
P = myPresentations(i).Presentation()->Presentation();
if(!P.IsNull())
P->SetInfiniteState(myInfiniteState);
}
}
//=======================================================================
//function : HasPresentation
//purpose :
@ -393,205 +115,34 @@ Handle(Prs3d_Presentation) AIS_InteractiveObject::Presentation() const
//function : SetAspect
//purpose :
//=======================================================================
void AIS_InteractiveObject::SetAspect(const Handle(Prs3d_BasicAspect)& anAspect)
void AIS_InteractiveObject::SetAspect(const Handle(Prs3d_BasicAspect)& theAspect)
{
if( HasPresentation() ) {
Handle(Prs3d_Presentation) prs = Presentation();
{ Handle(Prs3d_ShadingAspect) aspect =
Handle(Prs3d_ShadingAspect)::DownCast(anAspect);
if( !aspect.IsNull() ) {
Prs3d_Root::CurrentGroup(prs)->SetGroupPrimitivesAspect(aspect->Aspect());
return;
}
}
{ Handle(Prs3d_LineAspect) aspect =
Handle(Prs3d_LineAspect)::DownCast(anAspect);
if( !aspect.IsNull() ) {
Prs3d_Root::CurrentGroup(prs)->SetGroupPrimitivesAspect(aspect->Aspect());
return;
}
}
{ Handle(Prs3d_PointAspect) aspect =
Handle(Prs3d_PointAspect)::DownCast(anAspect);
if( !aspect.IsNull() ) {
Prs3d_Root::CurrentGroup(prs)->SetGroupPrimitivesAspect(aspect->Aspect());
return;
}
}
{ Handle(Prs3d_TextAspect) aspect =
Handle(Prs3d_TextAspect)::DownCast(anAspect);
if( !aspect.IsNull() ) {
Prs3d_Root::CurrentGroup(prs)->SetGroupPrimitivesAspect(aspect->Aspect());
return;
}
}
}
}
//=======================================================================
//function : SetPolygonOffsets
//purpose :
//=======================================================================
void AIS_InteractiveObject::SetPolygonOffsets(const Standard_Integer aMode,
const Standard_ShortReal aFactor,
const Standard_ShortReal aUnits)
{
if ( !HasPolygonOffsets() )
myDrawer->SetShadingAspect(new Prs3d_ShadingAspect());
myDrawer->ShadingAspect()->Aspect()->SetPolygonOffsets( aMode, aFactor, aUnits );
SynchronizeAspects();
}
//=======================================================================
//function : HasPolygonOffsets
//purpose :
//=======================================================================
Standard_Boolean AIS_InteractiveObject::HasPolygonOffsets() const
{
return !( myDrawer->ShadingAspect().IsNull() ||
( myDrawer->HasLink() &&
myDrawer->ShadingAspect() == myDrawer->Link()->ShadingAspect() ) );
}
//=======================================================================
//function : PolygonOffsets
//purpose :
//=======================================================================
void AIS_InteractiveObject::PolygonOffsets(Standard_Integer& aMode,
Standard_ShortReal& aFactor,
Standard_ShortReal& aUnits) const
{
if( HasPolygonOffsets() )
myDrawer->ShadingAspect()->Aspect()->PolygonOffsets( aMode, aFactor, aUnits );
}
//=======================================================================
//function : BoundingBox
//purpose : Returns bounding box of object correspondingly to its
// current display mode
//=======================================================================
void AIS_InteractiveObject::BoundingBox (Bnd_Box& theBndBox)
{
if (myDrawer->DisplayMode() == -1)
{
if (!myPresentations.IsEmpty())
{
const Handle(PrsMgr_Presentation)& aPrs3d = myPresentations.First().Presentation();
const Handle(Graphic3d_Structure)& aStruct = aPrs3d->Presentation();
const Graphic3d_BndBox3d& aBndBox = aStruct->CStructure()->BoundingBox();
if (!aBndBox.IsValid())
{
theBndBox.SetVoid();
return;
}
theBndBox.Update (aBndBox.CornerMin().x(), aBndBox.CornerMin().y(), aBndBox.CornerMin().z(),
aBndBox.CornerMax().x(), aBndBox.CornerMax().y(), aBndBox.CornerMax().z());
return;
}
else
{
for (PrsMgr_ListOfPresentableObjectsIter aPrsIter (Children()); aPrsIter.More(); aPrsIter.Next())
{
Handle(AIS_InteractiveObject) aChild (Handle(AIS_InteractiveObject)::DownCast (aPrsIter.Value()));
if (aChild.IsNull())
{
continue;
}
Bnd_Box aBox;
aChild->BoundingBox (aBox);
theBndBox.Add (aBox);
}
return;
}
}
else
{
for (Standard_Integer aPrsIter = 1; aPrsIter <= myPresentations.Length(); ++aPrsIter)
{
if (myPresentations (aPrsIter).Mode() == myDrawer->DisplayMode())
{
const Handle(PrsMgr_Presentation)& aPrs3d = myPresentations (aPrsIter).Presentation();
const Handle(Graphic3d_Structure)& aStruct = aPrs3d->Presentation();
const Graphic3d_BndBox3d& aBndBox = aStruct->CStructure()->BoundingBox();
if (!aBndBox.IsValid())
{
theBndBox.SetVoid();
return;
}
theBndBox.Update (aBndBox.CornerMin().x(), aBndBox.CornerMin().y(), aBndBox.CornerMin().z(),
aBndBox.CornerMax().x(), aBndBox.CornerMax().y(), aBndBox.CornerMax().z());
return;
}
}
}
}
//=======================================================================
//function : SetIsoOnTriangulation
//purpose : Enables or disables isoline on triangulation building
//=======================================================================
void AIS_InteractiveObject::SetIsoOnTriangulation (const Standard_Boolean theIsEnabled)
{
myDrawer->SetIsoOnTriangulation (theIsEnabled);
}
//=======================================================================
//function : SynchronizeAspects
//purpose :
//=======================================================================
void AIS_InteractiveObject::SynchronizeAspects()
{
for (PrsMgr_Presentations::Iterator aPrsIter (myPresentations); aPrsIter.More(); aPrsIter.Next())
{
const Handle(PrsMgr_Presentation)& aPrs3d = aPrsIter.ChangeValue().Presentation();
if (aPrs3d.IsNull()
|| aPrs3d->Presentation().IsNull())
{
continue;
}
for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (aPrs3d->Presentation()->Groups()); aGroupIter.More(); aGroupIter.Next())
{
if (!aGroupIter.Value().IsNull())
{
aGroupIter.ChangeValue()->SynchronizeAspects();
}
}
}
}
//=======================================================================
//function : replaceAspects
//purpose :
//=======================================================================
void AIS_InteractiveObject::replaceAspects (const Graphic3d_MapOfAspectsToAspects& theMap)
{
if (theMap.IsEmpty())
if (!HasPresentation())
{
return;
}
for (PrsMgr_Presentations::Iterator aPrsIter (myPresentations); aPrsIter.More(); aPrsIter.Next())
Handle(Prs3d_Presentation) aPrs = Presentation();
if (aPrs->Groups().IsEmpty())
{
const Handle(PrsMgr_Presentation)& aPrs3d = aPrsIter.ChangeValue().Presentation();
if (aPrs3d.IsNull()
|| aPrs3d->Presentation().IsNull())
{
continue;
}
for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (aPrs3d->Presentation()->Groups()); aGroupIter.More(); aGroupIter.Next())
{
if (!aGroupIter.Value().IsNull())
{
aGroupIter.ChangeValue()->ReplaceAspects (theMap);
}
}
return;
}
const Handle(Graphic3d_Group)& aGroup = aPrs->Groups().Last();
if (Handle(Prs3d_ShadingAspect) aShadingAspect = Handle(Prs3d_ShadingAspect)::DownCast(theAspect))
{
aGroup->SetGroupPrimitivesAspect (aShadingAspect->Aspect());
}
else if (Handle(Prs3d_LineAspect) aLineAspect = Handle(Prs3d_LineAspect)::DownCast(theAspect))
{
aGroup->SetGroupPrimitivesAspect (aLineAspect->Aspect());
}
else if (Handle(Prs3d_PointAspect) aPointAspect = Handle(Prs3d_PointAspect)::DownCast(theAspect))
{
aGroup->SetGroupPrimitivesAspect (aPointAspect->Aspect());
}
else if (Handle(Prs3d_TextAspect) aTextAspect = Handle(Prs3d_TextAspect)::DownCast(theAspect))
{
aGroup->SetGroupPrimitivesAspect (aTextAspect->Aspect());
}
}

View File

@ -17,14 +17,8 @@
#ifndef _AIS_InteractiveObject_HeaderFile
#define _AIS_InteractiveObject_HeaderFile
#include <Aspect_TypeOfFacingModel.hxx>
#include <AIS_KindOfInteractive.hxx>
#include <Graphic3d_NameOfMaterial.hxx>
#include <PrsMgr_TypeOfPresentation3d.hxx>
#include <SelectMgr_SelectableObject.hxx>
#include <TColStd_ListOfInteger.hxx>
#include <TColStd_ListOfTransient.hxx>
#include <Quantity_Color.hxx>
class AIS_InteractiveContext;
class Graphic3d_MaterialAspect;
@ -33,123 +27,39 @@ class Prs3d_BasicAspect;
class Bnd_Box;
//! Defines a class of objects with display and selection services.
//! Entities which are visualized and selected are
//! Interactive Objects. You can make use of classes of
//! standard Interactive Objects for which all necessary
//! methods have already been programmed, or you can
//! implement your own classes of Interactive Objects.
//! Specific attributes of entities such as arrow aspect for
//! dimensions must be loaded in a Drawer. This Drawer
//! is then applied to the Interactive Object in view.
//! There are four types of Interactive Object in AIS: the
//! construction element or Datum, the Relation, which
//! includes both dimensions and constraints, the Object,
//! and finally, when the object is of an unknown type, the None type.
//! Inside these categories, a signature, or index,
//! provides the possibility of additional characterization.
//! By default, the Interactive Object has a None type
//! and a signature of 0. If you want to give a particular
//! type and signature to your interactive object, you must
//! redefine the methods, Signature and Type.
//! Warning
//! In the case of attribute methods, methods for
//! standard attributes are virtual. They must be
//! redefined by the inheriting classes. Setcolor for a
//! point and Setcolor for a plane, for example, do not
//! affect the same attributes in the Drawer.
//! Entities which are visualized and selected are Interactive Objects.
//! Specific attributes of entities such as arrow aspect for dimensions must be loaded in a Prs3d_Drawer.
//!
//! You can make use of classes of standard Interactive Objects for which all necessary methods have already been programmed,
//! or you can implement your own classes of Interactive Objects.
//! Key interface methods to be implemented by every Interactive Object:
//! * Presentable Object (PrsMgr_PresentableObject)
//! Consider defining an enumeration of supported Display Mode indexes for particular Interactive Object or class of Interactive Objects.
//! - AcceptDisplayMode() accepting display modes implemented by this object;
//! - Compute() computing presentation for the given display mode index;
//! * Selectable Object (SelectMgr_SelectableObject)
//! Consider defining an enumeration of supported Selection Mode indexes for particular Interactive Object or class of Interactive Objects.
//! - ComputeSelection() computing selectable entities for the given selection mode index.
class AIS_InteractiveObject : public SelectMgr_SelectableObject
{
friend class AIS_InteractiveContext;
DEFINE_STANDARD_RTTIEXT(AIS_InteractiveObject, SelectMgr_SelectableObject)
public:
//! Returns the kind of Interactive Object:
//! - None
//! - Datum
//! - Relation
//! - Object
//! By default, the interactive object has a None type.
//! Because specific shapes entail different behavior
//! according to their sub-shapes, you may need to
//! create a Local Context. This will allow you to
//! specify the additional characteristics which you
//! need to handle these shapes.
Standard_EXPORT virtual AIS_KindOfInteractive Type() const;
//! Specifies additional characteristics of Interactive
//! Objects. A signature is, in fact, an index with integer
//! values assigned different properties.
//! This method is frequently used in conjuction with
//! Type to give a particular type and signature to an
//! Interactive Object. By default, the Interactive Object
//! has a None type and a signature of 0. Among the
//! datums, this signature is attributed to the shape
//! Returns the kind of Interactive Object; AIS_KOI_None by default.
virtual AIS_KindOfInteractive Type() const { return AIS_KOI_None; }
//! Specifies additional characteristics of Interactive Object of Type(); -1 by default.
//! Among the datums, this signature is attributed to the shape.
//! The remaining datums have the following default signatures:
//! - Point signature 1
//! - Axis signature 2
//! - Trihedron signature 3
//! - PlaneTrihedron signature 4
//! - Line signature 5
//! - Circle signature 6
//! - Plane signature 7.
Standard_EXPORT virtual Standard_Integer Signature() const;
//! Informs the graphic context that the interactive Object
//! may be decomposed into sub-shapes for dynamic selection.
//! The most used Interactive Object is AIS_Shape.
//! Activation methods for standard selection modes are
//! proposed in the Interactive Context. These include
//! selection by vertex or by edges. For datums with the
//! same behavior as AIS_Shape, such as vetices and
//! edges, we must redefine the virtual method so that
//! AcceptShapeDecomposition returns false.
//! Rule for selection :
//! Mode 0 : Selection of the interactive Object itself
//! Mode 1 : Selection of vertices
//! Mode 2 : Selection Of Edges
//! Mode 3 : Selection Of Wires
//! Mode 4 : Selection Of Faces ...
virtual Standard_Boolean AcceptShapeDecomposition() const { return Standard_False; }
//! change the current facing model apply on polygons for
//! SetColor(), SetTransparency(), SetMaterial() methods
//! default facing model is Aspect_TOFM_TWO_SIDE. This mean that attributes is
//! applying both on the front and back face.
Standard_EXPORT void SetCurrentFacingModel (const Aspect_TypeOfFacingModel aModel = Aspect_TOFM_BOTH_SIDE);
//! Returns the current facing model which is in effect.
Standard_EXPORT Aspect_TypeOfFacingModel CurrentFacingModel() const;
//! Only the interactive object knowns which Drawer attribute is affected by the color, if any
//! (ex: for a wire,it's the wireaspect field of the drawer, but for a vertex, only the point aspect field is affected by the color).
//! WARNING : Do not forget to set the corresponding fields here (hasOwnColor and myDrawer->SetColor())
Standard_EXPORT virtual void SetColor (const Quantity_Color& theColor);
//! Removes color settings. Only the Interactive Object
//! knows which Drawer attribute is affected by the color
//! setting. For a wire, for example, wire aspect is the
//! attribute affected. For a vertex, however, only point
//! aspect is affected by the color setting.
Standard_EXPORT virtual void UnsetColor();
//! Allows you to provide the setting aValue for width.
//! Only the Interactive Object knows which Drawer
//! attribute is affected by the width setting.
Standard_EXPORT virtual void SetWidth (const Standard_Real aValue);
Standard_EXPORT virtual void UnsetWidth();
//! Returns true if the class of objects accepts the display mode aMode.
//! The interactive context can have a default mode of
//! representation for the set of Interactive Objects. This
//! mode may not be accepted by a given class of
//! objects. Consequently, this virtual method allowing us
//! to get information about the class in question must be implemented.
Standard_EXPORT virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer aMode) const;
//! Returns the default display mode. This method is to
//! be implemented when the main mode is not mode 0.
Standard_EXPORT virtual Standard_Integer DefaultDisplayMode() const;
//! - Point signature 1
//! - Axis signature 2
//! - Trihedron signature 3
//! - PlaneTrihedron signature 4
//! - Line signature 5
//! - Circle signature 6
//! - Plane signature 7.
virtual Standard_Integer Signature() const { return -1; }
//! Updates the active presentation; if <AllModes> = Standard_True
//! all the presentations inside are recomputed.
@ -158,33 +68,20 @@ public:
//! is accessible. This method just redirects call to myCTXPtr,
//! so this class field must be up to date for proper result.
Standard_EXPORT void Redisplay (const Standard_Boolean AllModes = Standard_False);
//! Sets the infinite state flag aFlage.
//! if <aFlag> = True , the interactiveObject is
//! considered as infinite, i.e. its graphic presentations
//! are not taken in account for View FitAll...
Standard_EXPORT void SetInfiniteState (const Standard_Boolean aFlag = Standard_True);
//! Returns true if the interactive object is infinite. In this
//! case, its graphic presentations are not taken into
//! account in the fit-all view.
Standard_Boolean IsInfinite() const { return myInfiniteState; }
//! Indicates whether the Interactive Object has a pointer to an interactive context.
Standard_Boolean HasInteractiveContext() const { return myCTXPtr != NULL; }
//! Returns the context pointer to the interactive context.
Standard_EXPORT Handle(AIS_InteractiveContext) GetContext() const;
AIS_InteractiveContext* InteractiveContext() const { return myCTXPtr; }
//! Sets the interactive context aCtx and provides a link
//! to the default drawing tool or "Drawer" if there is none.
Standard_EXPORT virtual void SetContext (const Handle(AIS_InteractiveContext)& aCtx);
//! Returns true if the object has an owner attributed to it.
//! The owner can be a shape for a set of sub-shapes or
//! a sub-shape for sub-shapes which it is composed of,
//! and takes the form of a transient.
Standard_EXPORT Standard_Boolean HasOwner() const;
//! The owner can be a shape for a set of sub-shapes or a sub-shape for sub-shapes which it is composed of, and takes the form of a transient.
Standard_Boolean HasOwner() const { return !myOwner.IsNull(); }
//! Returns the owner of the Interactive Object.
//! The owner can be a shape for a set of sub-shapes or
@ -203,211 +100,35 @@ public:
//! is composed of. The owner takes the form of a transient.
void SetOwner (const Handle(Standard_Transient)& theApplicativeEntity) { myOwner = theApplicativeEntity; }
//! Each Interactive Object has methods which allow us
//! to attribute an Owner to it in the form of a Transient.
//! Each Interactive Object has methods which allow us to attribute an Owner to it in the form of a Transient.
//! This method removes the owner from the graphic entity.
Standard_EXPORT void ClearOwner();
void ClearOwner() { myOwner.Nullify(); }
//! Returns true if the Interactive Object has a display
//! mode setting. Otherwise, it is displayed in Neutral Point.
Standard_Boolean HasDisplayMode() const { return myDrawer->DisplayMode() != -1; }
public:
//! Sets the display mode aMode for the interactive object.
//! An object can have its own temporary display mode,
//! which is different from that proposed by the interactive context.
//! The range of possibilities currently proposed is the following:
//! - AIS_WireFrame
//! - AIS_Shaded
//! This range can, however, be extended through the creation of new display modes.
Standard_EXPORT void SetDisplayMode (const Standard_Integer aMode);
//! Returns the context pointer to the interactive context.
Standard_EXPORT Handle(AIS_InteractiveContext) GetContext() const;
//! Removes display mode settings from the interactive object.
void UnsetDisplayMode() { myDrawer->SetDisplayMode (-1); }
//! Returns the display mode setting of the Interactive Object.
//! The range of possibilities is the following:
//! - AIS_WireFrame
//! - AIS_Shaded
//! This range can, however, be extended through the
//! creation of new display modes.
Standard_Integer DisplayMode() const { return myDrawer->DisplayMode(); }
//! Returns true if the Interactive Object is in highlight mode.
Standard_Boolean HasHilightMode() const { return !myHilightDrawer.IsNull() && myHilightDrawer->DisplayMode() != -1; }
//! Returns highlight display mode.
//! This is obsolete method for backward compatibility - use ::HilightAttributes() and ::DynamicHilightAttributes() instead.
Standard_Integer HilightMode() const { return !myHilightDrawer.IsNull() ? myHilightDrawer->DisplayMode() : -1; }
//! Sets highlight display mode.
//! This is obsolete method for backward compatibility - use ::HilightAttributes() and ::DynamicHilightAttributes() instead.
void SetHilightMode (const Standard_Integer theMode)
{
if (myHilightDrawer.IsNull())
{
myHilightDrawer = new Prs3d_Drawer();
myHilightDrawer->Link (myDrawer);
myHilightDrawer->SetAutoTriangulation (Standard_False);
myHilightDrawer->SetColor (Quantity_NOC_GRAY80);
myHilightDrawer->SetZLayer(Graphic3d_ZLayerId_UNKNOWN);
}
if (myDynHilightDrawer.IsNull())
{
myDynHilightDrawer = new Prs3d_Drawer();
myDynHilightDrawer->Link (myDrawer);
myDynHilightDrawer->SetColor (Quantity_NOC_CYAN1);
myDynHilightDrawer->SetAutoTriangulation (Standard_False);
myDynHilightDrawer->SetZLayer(Graphic3d_ZLayerId_Top);
}
myHilightDrawer ->SetDisplayMode (theMode);
myDynHilightDrawer->SetDisplayMode (theMode);
}
//! Unsets highlight display mode.
void UnsetHilightMode()
{
if (!myHilightDrawer.IsNull())
{
myHilightDrawer->SetDisplayMode (-1);
}
if (!myDynHilightDrawer.IsNull())
{
myDynHilightDrawer->SetDisplayMode (-1);
}
}
//! Returns true if the Interactive Object has color.
Standard_Boolean HasColor() const { return hasOwnColor; }
//! Returns the color setting of the Interactive Object.
virtual void Color (Quantity_Color& theColor) const { theColor = myDrawer->Color(); }
//! Returns true if the Interactive Object has width.
Standard_Boolean HasWidth() const { return myOwnWidth != 0.0f; }
//! Returns the width setting of the Interactive Object.
Standard_Real Width() const { return myOwnWidth; }
//! Returns true if the Interactive Object has a setting for material.
Standard_Boolean HasMaterial() const { return hasOwnMaterial; }
//! Returns the current material setting.
//! This will be on of the following materials:
//! - Brass
//! - Bronze
//! - Gold
//! - Pewter
//! - Silver
//! - Stone.
Standard_EXPORT virtual Graphic3d_NameOfMaterial Material() const;
//! Sets the material aMat defining this display attribute
//! for the interactive object.
//! Material aspect determines shading aspect, color and
//! transparency of visible entities.
Standard_EXPORT virtual void SetMaterial (const Graphic3d_MaterialAspect& aName);
//! Removes the setting for material.
Standard_EXPORT virtual void UnsetMaterial();
//! Attributes a setting aValue for transparency.
//! The transparency value should be between 0.0 and 1.0.
//! At 0.0 an object will be totally opaque, and at 1.0, fully transparent.
//! Warning At a value of 1.0, there may be nothing visible.
Standard_EXPORT virtual void SetTransparency (const Standard_Real aValue = 0.6);
//! Returns true if there is a transparency setting.
Standard_Boolean IsTransparent() const { return myDrawer->Transparency() > 0.005f; }
//! Returns the transparency setting.
//! This will be between 0.0 and 1.0.
//! At 0.0 an object will be totally opaque, and at 1.0, fully transparent.
Standard_EXPORT virtual Standard_Real Transparency() const;
//! Removes the transparency setting. The object is opaque by default.
Standard_EXPORT virtual void UnsetTransparency();
//! Clears settings provided by the drawing tool aDrawer.
Standard_EXPORT virtual void UnsetAttributes() Standard_OVERRIDE;
//! Returns TRUE when this object has a presentation
//! in the current DisplayMode()
//! Returns TRUE when this object has a presentation in the current DisplayMode()
Standard_EXPORT Standard_Boolean HasPresentation() const;
//! Returns the current presentation of this object
//! according to the current DisplayMode()
//! Returns the current presentation of this object according to the current DisplayMode()
Standard_EXPORT Handle(Prs3d_Presentation) Presentation() const;
//! Sets the graphic basic aspect to the current presentation.
Standard_DEPRECATED("Deprecated method, results might be undefined")
Standard_EXPORT void SetAspect (const Handle(Prs3d_BasicAspect)& anAspect);
//! Sets up polygon offsets for this object.
//! It modifies all existing presentations of <anObj> (if any),
//! so it is reasonable to call this method after <anObj> has been displayed.
//! Otherwise, Compute() method should pass Graphic3d_AspectFillArea3d
//! aspect from <myDrawer> to Graphic3d_Group to make polygon offsets work.
//!
//! <aMode> parameter can contain various combinations of
//! Aspect_PolygonOffsetMode enumeration elements (Aspect_POM_None means
//! that polygon offsets are not changed).
//! If <aMode> is different from Aspect_POM_Off and Aspect_POM_None, then <aFactor> and <aUnits>
//! arguments are used by graphic renderer to calculate a depth offset value:
//!
//! offset = <aFactor> * m + <aUnits> * r, where
//! m - maximum depth slope for the polygon currently being displayed,
//! r - minimum window coordinates depth resolution (implementation-specific).
//!
//! Deafult settings for OCC 3D viewer: mode = Aspect_POM_Fill, factor = 1., units = 0.
//!
//! Negative offset values move polygons closer to the viewport,
//! while positive values shift polygons away.
//! Consult OpenGL reference for details (glPolygonOffset function description).
//!
//! NOTE: This method has a side effect - it creates own shading aspect
//! if not yet created, so it is better to set up object material,
//! color, etc. first.
Standard_EXPORT virtual void SetPolygonOffsets (const Standard_Integer aMode, const Standard_ShortReal aFactor = 1.0, const Standard_ShortReal aUnits = 0.0);
//! Returns Standard_True if <myDrawer> has non-null shading aspect
Standard_EXPORT virtual Standard_Boolean HasPolygonOffsets() const;
//! Retrieves current polygon offsets settings from <myDrawer>.
Standard_EXPORT virtual void PolygonOffsets (Standard_Integer& aMode, Standard_ShortReal& aFactor, Standard_ShortReal& aUnits) const;
//! Returns bounding box of object correspondingly to its current display mode.
Standard_EXPORT virtual void BoundingBox (Bnd_Box& theBndBox) Standard_OVERRIDE;
//! Enables or disables on-triangulation build of isolines according to the flag given.
Standard_EXPORT void SetIsoOnTriangulation (const Standard_Boolean theIsEnabled);
//! Synchronize presentation aspects after their modification.
//!
//! This method should be called after modifying primitive aspect properties (material, texture, shader)
//! so that modifications will take effect on already computed presentation groups (thus avoiding re-displaying the object).
Standard_EXPORT void SynchronizeAspects();
protected:
//! Replace aspects of existing (computed) presentation groups,
//! so that the new aspects can be applied without recomputing presentation.
//! It is NOT recommended approach, because user has to fill such map and then search for each occurrence in computed groups.
//! The recommended approach is computing presentation with necessary customized aspects,
//! and then modify them directly followed by SynchronizeAspects() call.
Standard_EXPORT void replaceAspects (const Graphic3d_MapOfAspectsToAspects& theMap);
//! The TypeOfPresention3d means that the interactive object
//! may have a presentation dependant of the view of Display.
Standard_EXPORT AIS_InteractiveObject(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d = PrsMgr_TOP_AllView);
protected:
AIS_InteractiveContext* myCTXPtr;
Handle(Standard_Transient) myOwner;
Standard_ShortReal myOwnWidth;
Aspect_TypeOfFacingModel myCurrentFacingModel;
Standard_Boolean myInfiniteState;
Standard_Boolean hasOwnColor;
Standard_Boolean hasOwnMaterial;
AIS_InteractiveContext* myCTXPtr; //!< pointer to Interactive Context, where object is currently displayed; @sa SetContext()
Handle(Standard_Transient) myOwner; //!< application-specific owner object
};

View File

@ -60,11 +60,17 @@ private:
//! Inspired by AIS_Shape::ComputeSelection() from OCCT 6.5.1
//! @param [in] selection container for sensitive primitives
//! @param [in] mode Selection mode
void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer theMode) Standard_OVERRIDE;
virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer theMode) Standard_OVERRIDE;
//! Dummy.
virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& ,
const Handle(Prs3d_Presentation)& ,
const Standard_Integer ) Standard_OVERRIDE {}
const Bnd_Box& BoundingBox();
private:
IVtkOCC_Shape::Handle myShape;
Bnd_Box myBndBox;
Handle(Prs3d_Drawer) myOCCTDrawer;

View File

@ -4,14 +4,12 @@ PrsMgr_ModedPresentation.cxx
PrsMgr_ModedPresentation.hxx
PrsMgr_PresentableObject.cxx
PrsMgr_PresentableObject.hxx
PrsMgr_PresentableObjectPointer.hxx
PrsMgr_Presentation.cxx
PrsMgr_Presentation.hxx
PrsMgr_Presentation3d.hxx
PrsMgr_PresentationManager.cxx
PrsMgr_PresentationManager.hxx
PrsMgr_PresentationManager3d.hxx
PrsMgr_PresentationPointer.hxx
PrsMgr_Presentations.hxx
PrsMgr_Prs.cxx
PrsMgr_Prs.hxx

View File

@ -16,27 +16,26 @@
#include <PrsMgr_PresentableObject.hxx>
#include <Graphic3d_AspectFillArea3d.hxx>
#include <Prs3d_Drawer.hxx>
#include <Prs3d_LineAspect.hxx>
#include <Prs3d_PointAspect.hxx>
#include <Prs3d_Presentation.hxx>
#include <Prs3d_Projector.hxx>
#include <Prs3d_ShadingAspect.hxx>
#include <PrsMgr_ModedPresentation.hxx>
#include <Standard_NotImplemented.hxx>
#include <TColStd_ListIteratorOfListOfInteger.hxx>
#include <TColStd_MapOfInteger.hxx>
IMPLEMENT_STANDARD_RTTIEXT(PrsMgr_PresentableObject, Standard_Transient)
namespace
{
static const gp_Trsf THE_IDENTITY_TRSF;
}
//=======================================================================
//function : getIdentityTrsf
//purpose :
//=======================================================================
const gp_Trsf& PrsMgr_PresentableObject::getIdentityTrsf()
{
static const gp_Trsf THE_IDENTITY_TRSF;
return THE_IDENTITY_TRSF;
}
@ -45,11 +44,18 @@ const gp_Trsf& PrsMgr_PresentableObject::getIdentityTrsf()
//purpose :
//=======================================================================
PrsMgr_PresentableObject::PrsMgr_PresentableObject (const PrsMgr_TypeOfPresentation3d theType)
: myDrawer (new Prs3d_Drawer()),
: myParent (NULL),
myDrawer (new Prs3d_Drawer()),
myTypeOfPresentation3d (theType),
//
myCurrentFacingModel (Aspect_TOFM_BOTH_SIDE),
myOwnWidth (0.0f),
hasOwnColor (Standard_False),
hasOwnMaterial (Standard_False),
//
myInfiniteState (Standard_False),
myIsMutable (Standard_False),
myHasOwnPresentations (Standard_True),
myParent (NULL)
myHasOwnPresentations (Standard_True)
{
myDrawer->SetDisplayMode (-1);
}
@ -82,17 +88,6 @@ void PrsMgr_PresentableObject::Fill (const Handle(PrsMgr_PresentationManager)& t
aStruct3d->SetTransformPersistence (TransformPersistence());
}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
void PrsMgr_PresentableObject::Compute (const Handle(PrsMgr_PresentationManager)& /*aPresentationManager*/,
const Handle(Prs3d_Presentation)& /*aPresentation*/,
const Standard_Integer /*aMode*/)
{
throw Standard_NotImplemented("cannot compute in a 3d visualizer");
}
//=======================================================================
//function : Compute
//purpose :
@ -455,15 +450,6 @@ void PrsMgr_PresentableObject::SetZLayer (const Graphic3d_ZLayerId theLayerId)
}
}
//=======================================================================
//function : ZLayer
//purpose :
//=======================================================================
Graphic3d_ZLayerId PrsMgr_PresentableObject::ZLayer() const
{
return myDrawer->ZLayer();
}
// =======================================================================
// function : AddClipPlane
// purpose :
@ -532,6 +518,29 @@ void PrsMgr_PresentableObject::UpdateClipping()
}
}
//=======================================================================
//function : SetInfiniteState
//purpose :
//=======================================================================
void PrsMgr_PresentableObject::SetInfiniteState (const Standard_Boolean theFlag)
{
if (myInfiniteState == theFlag)
{
return;
}
myInfiniteState = theFlag;
for (PrsMgr_Presentations::Iterator aPrsIter (myPresentations); aPrsIter.More(); aPrsIter.Next())
{
const PrsMgr_ModedPresentation& aModedPrs = aPrsIter.Value();
if (!aModedPrs.Presentation().IsNull()
&& !aModedPrs.Presentation()->Presentation().IsNull())
{
aModedPrs.Presentation()->Presentation()->SetInfiniteState (theFlag);
}
}
}
// =======================================================================
// function : SetMutable
// purpose :
@ -555,15 +564,6 @@ void PrsMgr_PresentableObject::SetMutable (const Standard_Boolean theIsMutable)
}
}
// =======================================================================
// function : SetAttributes
// purpose :
// =======================================================================
void PrsMgr_PresentableObject::SetAttributes (const Handle(Prs3d_Drawer)& theDrawer)
{
myDrawer = theDrawer;
}
// =======================================================================
// function : UnsetAttributes
// purpose :
@ -576,4 +576,272 @@ void PrsMgr_PresentableObject::UnsetAttributes()
aDrawer->Link(myDrawer->Link());
}
myDrawer = aDrawer;
hasOwnColor = Standard_False;
hasOwnMaterial = Standard_False;
myOwnWidth = 0.0f;
myDrawer->SetTransparency (0.0f);
}
//=======================================================================
//function : SetHilightMode
//purpose :
//=======================================================================
void PrsMgr_PresentableObject::SetHilightMode (const Standard_Integer theMode)
{
if (myHilightDrawer.IsNull())
{
myHilightDrawer = new Prs3d_Drawer();
myHilightDrawer->Link (myDrawer);
myHilightDrawer->SetAutoTriangulation (Standard_False);
myHilightDrawer->SetColor (Quantity_NOC_GRAY80);
myHilightDrawer->SetZLayer(Graphic3d_ZLayerId_UNKNOWN);
}
if (myDynHilightDrawer.IsNull())
{
myDynHilightDrawer = new Prs3d_Drawer();
myDynHilightDrawer->Link (myDrawer);
myDynHilightDrawer->SetColor (Quantity_NOC_CYAN1);
myDynHilightDrawer->SetAutoTriangulation (Standard_False);
myDynHilightDrawer->SetZLayer(Graphic3d_ZLayerId_Top);
}
myHilightDrawer ->SetDisplayMode (theMode);
myDynHilightDrawer->SetDisplayMode (theMode);
}
//=======================================================================
//function : SynchronizeAspects
//purpose :
//=======================================================================
void PrsMgr_PresentableObject::SynchronizeAspects()
{
for (PrsMgr_Presentations::Iterator aPrsIter (myPresentations); aPrsIter.More(); aPrsIter.Next())
{
const Handle(PrsMgr_Presentation)& aPrs3d = aPrsIter.ChangeValue().Presentation();
if (aPrs3d.IsNull()
|| aPrs3d->Presentation().IsNull())
{
continue;
}
for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (aPrs3d->Presentation()->Groups()); aGroupIter.More(); aGroupIter.Next())
{
if (!aGroupIter.Value().IsNull())
{
aGroupIter.ChangeValue()->SynchronizeAspects();
}
}
}
}
//=======================================================================
//function : replaceAspects
//purpose :
//=======================================================================
void PrsMgr_PresentableObject::replaceAspects (const Graphic3d_MapOfAspectsToAspects& theMap)
{
if (theMap.IsEmpty())
{
return;
}
for (PrsMgr_Presentations::Iterator aPrsIter (myPresentations); aPrsIter.More(); aPrsIter.Next())
{
const Handle(PrsMgr_Presentation)& aPrs3d = aPrsIter.ChangeValue().Presentation();
if (aPrs3d.IsNull()
|| aPrs3d->Presentation().IsNull())
{
continue;
}
for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (aPrs3d->Presentation()->Groups()); aGroupIter.More(); aGroupIter.Next())
{
if (!aGroupIter.Value().IsNull())
{
aGroupIter.ChangeValue()->ReplaceAspects (theMap);
}
}
}
}
//=======================================================================
//function : BoundingBox
//purpose :
//=======================================================================
void PrsMgr_PresentableObject::BoundingBox (Bnd_Box& theBndBox)
{
if (myDrawer->DisplayMode() == -1)
{
if (!myPresentations.IsEmpty())
{
const Handle(PrsMgr_Presentation)& aPrs3d = myPresentations.First().Presentation();
const Handle(Graphic3d_Structure)& aStruct = aPrs3d->Presentation();
const Graphic3d_BndBox3d& aBndBox = aStruct->CStructure()->BoundingBox();
if (aBndBox.IsValid())
{
theBndBox.Update (aBndBox.CornerMin().x(), aBndBox.CornerMin().y(), aBndBox.CornerMin().z(),
aBndBox.CornerMax().x(), aBndBox.CornerMax().y(), aBndBox.CornerMax().z());
}
else
{
theBndBox.SetVoid();
}
return;
}
for (PrsMgr_ListOfPresentableObjectsIter aPrsIter (myChildren); aPrsIter.More(); aPrsIter.Next())
{
if (const Handle(PrsMgr_PresentableObject)& aChild = aPrsIter.Value())
{
Bnd_Box aBox;
aChild->BoundingBox (aBox);
theBndBox.Add (aBox);
}
}
return;
}
for (Standard_Integer aPrsIter = 1; aPrsIter <= myPresentations.Length(); ++aPrsIter)
{
if (myPresentations (aPrsIter).Mode() == myDrawer->DisplayMode())
{
const Handle(PrsMgr_Presentation)& aPrs3d = myPresentations (aPrsIter).Presentation();
const Handle(Graphic3d_Structure)& aStruct = aPrs3d->Presentation();
const Graphic3d_BndBox3d& aBndBox = aStruct->CStructure()->BoundingBox();
if (aBndBox.IsValid())
{
theBndBox.Update (aBndBox.CornerMin().x(), aBndBox.CornerMin().y(), aBndBox.CornerMin().z(),
aBndBox.CornerMax().x(), aBndBox.CornerMax().y(), aBndBox.CornerMax().z());
}
else
{
theBndBox.SetVoid();
}
return;
}
}
}
//=======================================================================
//function : Material
//purpose :
//=======================================================================
Graphic3d_NameOfMaterial PrsMgr_PresentableObject::Material() const
{
return myDrawer->ShadingAspect()->Material().Name();
}
//=======================================================================
//function : SetMaterial
//purpose :
//=======================================================================
void PrsMgr_PresentableObject::SetMaterial (const Graphic3d_MaterialAspect& theMaterial)
{
myDrawer->SetupOwnShadingAspect();
myDrawer->ShadingAspect()->SetMaterial (theMaterial);
hasOwnMaterial = Standard_True;
}
//=======================================================================
//function : UnsetMaterial
//purpose :
//=======================================================================
void PrsMgr_PresentableObject::UnsetMaterial()
{
if (!HasMaterial())
{
return;
}
if (HasColor() || IsTransparent())
{
if (myDrawer->HasLink())
{
myDrawer->ShadingAspect()->SetMaterial (myDrawer->Link()->ShadingAspect()->Aspect()->BackMaterial());
}
if (HasColor())
{
SetColor (myDrawer->Color());
}
if (IsTransparent())
{
SetTransparency (myDrawer->Transparency());
}
}
else
{
myDrawer->SetShadingAspect (Handle(Prs3d_ShadingAspect)());
}
hasOwnMaterial = Standard_False;
}
//=======================================================================
//function : SetTransparency
//purpose :
//=======================================================================
void PrsMgr_PresentableObject::SetTransparency (const Standard_Real theValue)
{
myDrawer->SetupOwnShadingAspect();
myDrawer->ShadingAspect()->Aspect()->ChangeFrontMaterial().SetTransparency (Standard_ShortReal(theValue));
myDrawer->ShadingAspect()->Aspect()->ChangeBackMaterial() .SetTransparency (Standard_ShortReal(theValue));
myDrawer->SetTransparency (Standard_ShortReal(theValue));
}
//=======================================================================
//function : UnsetTransparency
//purpose :
//=======================================================================
void PrsMgr_PresentableObject::UnsetTransparency()
{
if (HasColor() || HasMaterial())
{
myDrawer->ShadingAspect()->Aspect()->ChangeFrontMaterial().SetTransparency (0.0f);
myDrawer->ShadingAspect()->Aspect()->ChangeBackMaterial() .SetTransparency (0.0f);
}
else
{
myDrawer->SetShadingAspect (Handle(Prs3d_ShadingAspect)());
}
myDrawer->SetTransparency (0.0f);
}
//=======================================================================
//function : SetPolygonOffsets
//purpose :
//=======================================================================
void PrsMgr_PresentableObject::SetPolygonOffsets (const Standard_Integer theMode,
const Standard_ShortReal theFactor,
const Standard_ShortReal theUnits)
{
myDrawer->SetupOwnShadingAspect();
myDrawer->ShadingAspect()->Aspect()->SetPolygonOffsets (theMode, theFactor, theUnits);
SynchronizeAspects();
}
//=======================================================================
//function : HasPolygonOffsets
//purpose :
//=======================================================================
Standard_Boolean PrsMgr_PresentableObject::HasPolygonOffsets() const
{
return !(myDrawer->HasOwnShadingAspect()
|| (myDrawer->HasLink()
&& myDrawer->ShadingAspect() == myDrawer->Link()->ShadingAspect()));
}
//=======================================================================
//function : PolygonOffsets
//purpose :
//=======================================================================
void PrsMgr_PresentableObject::PolygonOffsets (Standard_Integer& theMode,
Standard_ShortReal& theFactor,
Standard_ShortReal& theUnits) const
{
if (HasPolygonOffsets())
{
myDrawer->ShadingAspect()->Aspect()->PolygonOffsets (theMode, theFactor, theUnits);
}
}

View File

@ -17,6 +17,7 @@
#ifndef _PrsMgr_PresentableObject_HeaderFile
#define _PrsMgr_PresentableObject_HeaderFile
#include <Aspect_TypeOfFacingModel.hxx>
#include <gp_GTrsf.hxx>
#include <Graphic3d_ClipPlane.hxx>
#include <Graphic3d_SequenceOfHClipPlane.hxx>
@ -28,25 +29,22 @@
#include <PrsMgr_Presentation.hxx>
#include <PrsMgr_Presentations.hxx>
#include <PrsMgr_PresentationManager3d.hxx>
#include <PrsMgr_PresentableObjectPointer.hxx>
#include <PrsMgr_TypeOfPresentation3d.hxx>
#include <TColStd_ListOfInteger.hxx>
//! A framework to supply the Graphic3d
//! structure of the object to be presented. On the first
//! display request, this structure is created by calling the
//! appropriate algorithm and retaining this frameworkfor
//! further display.
//! This abstract framework is inherited in Application
//! Interactive Services (AIS), notably in:
//! - AIS_InteractiveObject
//! - AIS_ConnectedInteractive
//! - AIS_MultipleConnectedInteractive
//! - AIS_Shape
//! Consequently, 3D presentation should be handled by
//! the relevant daughter classes and their member
//! functions in AIS. This is particularly true in the
//! creation of new interactive objects.
//! A framework to supply the Graphic3d structure of the object to be presented.
//! On the first display request, this structure is created by calling the appropriate algorithm and retaining this framework for further display.
//! This abstract framework is inherited in Application Interactive Services (AIS), notably by AIS_InteractiveObject.
//! Consequently, 3D presentation should be handled by the relevant daughter classes and their member functions in AIS.
//! This is particularly true in the creation of new interactive objects.
//!
//! Key interface methods to be implemented by every Selectable Object:
//! - AcceptDisplayMode() accepting display modes implemented by this object;
//! - Compute() computing presentation for the given display mode index.
//!
//! Warning! Methods managing standard attributes (SetColor(), SetWidth(), SetMaterial()) have different meaning for objects of different type (or no meaning at all).
//! Sub-classes might override these methods to modify Prs3d_Drawer or class properties providing a convenient short-cut depending on application needs.
//! For more sophisticated configuring, Prs3d_Drawer should be modified directly, while short-cuts might be left unimplemented.
class PrsMgr_PresentableObject : public Standard_Transient
{
DEFINE_STANDARD_RTTIEXT(PrsMgr_PresentableObject, Standard_Transient)
@ -54,11 +52,146 @@ class PrsMgr_PresentableObject : public Standard_Transient
friend class PrsMgr_PresentationManager;
public:
//! Return presentations.
PrsMgr_Presentations& Presentations() { return myPresentations; }
//! Get ID of Z layer for main presentation.
Graphic3d_ZLayerId ZLayer() const { return myDrawer->ZLayer(); }
//! Set Z layer ID and update all presentations of the presentable object.
//! The layers mechanism allows drawing objects in higher layers in overlay of objects in lower layers.
Standard_EXPORT virtual void SetZLayer (const Graphic3d_ZLayerId theLayerId);
//! Returns true if object has mutable nature (content or location are be changed regularly).
//! Mutable object will be managed in different way than static onces (another optimizations).
Standard_Boolean IsMutable() const { return myIsMutable; }
//! Sets if the object has mutable nature (content or location will be changed regularly).
//! This method should be called before object displaying to take effect.
Standard_EXPORT virtual void SetMutable (const Standard_Boolean theIsMutable);
//! Returns true if the Interactive Object has display mode setting overriding global setting (within Interactive Context).
Standard_Boolean HasDisplayMode() const { return myDrawer->DisplayMode() != -1; }
//! Returns the display mode setting of the Interactive Object.
//! The range of supported display mode indexes should be specified within object definition and filtered by AccepDisplayMode().
//! @sa AcceptDisplayMode()
Standard_Integer DisplayMode() const { return myDrawer->DisplayMode(); }
//! Sets the display mode for the interactive object.
//! An object can have its own temporary display mode, which is different from that proposed by the interactive context.
//! @sa AcceptDisplayMode()
void SetDisplayMode (const Standard_Integer theMode)
{
if (AcceptDisplayMode (theMode))
{
myDrawer->SetDisplayMode (theMode);
}
}
//! Removes display mode settings from the interactive object.
void UnsetDisplayMode() { myDrawer->SetDisplayMode (-1); }
//! Returns true if the Interactive Object is in highlight mode.
Standard_Boolean HasHilightMode() const { return !myHilightDrawer.IsNull() && myHilightDrawer->DisplayMode() != -1; }
//! Returns highlight display mode.
//! This is obsolete method for backward compatibility - use ::HilightAttributes() and ::DynamicHilightAttributes() instead.
Standard_Integer HilightMode() const { return !myHilightDrawer.IsNull() ? myHilightDrawer->DisplayMode() : -1; }
//! Sets highlight display mode.
//! This is obsolete method for backward compatibility - use ::HilightAttributes() and ::DynamicHilightAttributes() instead.
Standard_EXPORT void SetHilightMode (const Standard_Integer theMode);
//! Unsets highlight display mode.
void UnsetHilightMode()
{
if (!myHilightDrawer.IsNull())
{
myHilightDrawer->SetDisplayMode (-1);
}
if (!myDynHilightDrawer.IsNull())
{
myDynHilightDrawer->SetDisplayMode (-1);
}
}
//! Returns true if the class of objects accepts specified display mode index.
//! The interactive context can have a default mode of representation for the set of Interactive Objects.
//! This mode may not be accepted by a given class of objects.
//! Consequently, this virtual method allowing us to get information about the class in question must be implemented.
//! At least one display mode index should be accepted by this method.
//! Although subclass can leave default implementation, it is highly desired defining exact list of supported modes instead,
//! which is usually an enumeration for one object or objects class sharing similar list of display modes.
virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const
{
(void )theMode;
return Standard_True;
}
//! Returns the default display mode.
virtual Standard_Integer DefaultDisplayMode() const { return 0; }
//! Returns TRUE if any active presentation has invalidation flag.
//! @param theToIncludeHidden when TRUE, also checks hidden presentations
Standard_EXPORT Standard_Boolean ToBeUpdated (Standard_Boolean theToIncludeHidden = Standard_False) const;
//! Flags presentation to be updated; UpdatePresentations() will recompute these presentations.
//! @param theMode presentation (display mode) to invalidate, or -1 to invalidate them all
Standard_EXPORT void SetToUpdate (Standard_Integer theMode);
//! flags all the Presentations to be Updated.
void SetToUpdate() { SetToUpdate (-1); }
//! Returns true if the interactive object is infinite; FALSE by default.
//! This flag affects various operations operating on bounding box of graphic presentations of this object.
//! For instance, infinite objects are not taken in account for View FitAll.
//! This does not necessarily means that object is actually infinite,
//! auxiliary objects might be also marked with this flag to achieve desired behavior.
Standard_Boolean IsInfinite() const { return myInfiniteState; }
//! Sets if object should be considered as infinite.
Standard_EXPORT void SetInfiniteState (const Standard_Boolean theFlag = Standard_True);
//! Returns information on whether the object accepts display in HLR mode or not.
PrsMgr_TypeOfPresentation3d TypeOfPresentation3d() const { return myTypeOfPresentation3d; }
//! Set type of presentation.
Standard_EXPORT void SetTypeOfPresentation (const PrsMgr_TypeOfPresentation3d theType);
public: //! @name presentation attributes
//! Returns the attributes settings.
const Handle(Prs3d_Drawer)& Attributes() const { return myDrawer; }
//! Initializes the drawing tool theDrawer.
virtual void SetAttributes(const Handle(Prs3d_Drawer)& theDrawer) { myDrawer = theDrawer; }
//! Returns the hilight attributes settings.
//! When not NULL, overrides both Prs3d_TypeOfHighlight_LocalSelected and Prs3d_TypeOfHighlight_Selected defined within AIS_InteractiveContext.
const Handle(Prs3d_Drawer)& HilightAttributes() const { return myHilightDrawer; }
//! Initializes the hilight drawing tool theDrawer.
virtual void SetHilightAttributes(const Handle(Prs3d_Drawer)& theDrawer) { myHilightDrawer = theDrawer; }
//! Returns the hilight attributes settings.
//! When not NULL, overrides both Prs3d_TypeOfHighlight_LocalDynamic and Prs3d_TypeOfHighlight_Dynamic defined within AIS_InteractiveContext.
const Handle(Prs3d_Drawer)& DynamicHilightAttributes() const { return myDynHilightDrawer; }
//! Initializes the dynamic hilight drawing tool.
virtual void SetDynamicHilightAttributes (const Handle(Prs3d_Drawer)& theDrawer) { myDynHilightDrawer = theDrawer; }
//! Clears settings provided by the hilight drawing tool theDrawer.
virtual void UnsetHilightAttributes() { myHilightDrawer.Nullify(); }
//! Synchronize presentation aspects after their modification.
//!
//! This method should be called after modifying primitive aspect properties (material, texture, shader)
//! so that modifications will take effect on already computed presentation groups (thus avoiding re-displaying the object).
Standard_EXPORT void SynchronizeAspects();
public: //! @name object transformation
//! Returns Transformation Persistence defining a special Local Coordinate system where this presentable object is located or NULL handle if not defined.
//! Position of the object having Transformation Persistence is mutable and depends on camera position.
//! The same applies to a bounding box of the object.
@ -70,59 +203,6 @@ public:
//! because it requires its position being recomputed basing on camera position within each draw call / traverse.
//! @sa Graphic3d_TransformPers class description
Standard_EXPORT virtual void SetTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers);
//! Sets up Transform Persistence Mode for this object.
//! This function used to lock in object position, rotation and / or zooming relative to camera position.
//! Object will be drawn in the origin setted by thePoint parameter (except Graphic3d_TMF_TriedronPers flag
//! - see description later). theMode should be:
//! - Graphic3d_TMF_None - no persistence attributes (reset);
//! - Graphic3d_TMF_ZoomPers - object doesn't resize;
//! - Graphic3d_TMF_RotatePers - object doesn't rotate;
//! - Graphic3d_TMF_ZoomRotatePers - object doesn't resize and rotate;
//! - Graphic3d_TMF_RotatePers - object doesn't rotate;
//! - Graphic3d_TMF_TriedronPers - object behaves like trihedron.
//! If Graphic3d_TMF_TriedronPers or Graphic3d_TMF_2d persistence mode selected thePoint coordinates X and Y means:
//! - X = 0.0, Y = 0.0 - center of view window;
//! - X > 0.0, Y > 0.0 - right upper corner of view window;
//! - X > 0.0, Y < 0.0 - right lower corner of view window;
//! - X < 0.0, Y > 0.0 - left upper corner of view window;
//! - X < 0.0, Y < 0.0 - left lower corner of view window.
//! And Z coordinate defines the gap from border of view window (except center position).
Standard_DEPRECATED("This method is deprecated - SetTransformPersistence() taking Graphic3d_TransformPers should be called instead")
void SetTransformPersistence (const Graphic3d_TransModeFlags theMode, const gp_Pnt& thePoint = gp_Pnt (0.0, 0.0, 0.0))
{
SetTransformPersistence (Graphic3d_TransformPers::FromDeprecatedParams (theMode, thePoint));
}
//! Gets Transform Persistence Mode for this object
Standard_DEPRECATED("This method is deprecated - TransformPersistence() should be called instead")
Graphic3d_TransModeFlags GetTransformPersistenceMode() const
{
return myTransformPersistence.IsNull()
? Graphic3d_TMF_None
: myTransformPersistence->Mode();
}
//! Gets point of transform persistence for this object
Standard_DEPRECATED("This method is deprecated - TransformPersistence() should be called instead")
Standard_EXPORT gp_Pnt GetTransformPersistencePoint() const;
Standard_EXPORT void SetTypeOfPresentation (const PrsMgr_TypeOfPresentation3d aType);
//! Returns TRUE if any active presentation has invalidation flag.
//! @param theToIncludeHidden when TRUE, also checks hidden presentations
Standard_EXPORT Standard_Boolean ToBeUpdated (Standard_Boolean theToIncludeHidden = Standard_False) const;
//! Flags presentation to be updated; UpdatePresentations() will recompute these presentations.
//! @param theMode presentation (display mode) to invalidate, or -1 to invalidate them all
Standard_EXPORT void SetToUpdate (Standard_Integer theMode);
//! flags all the Presentations to be Updated.
void SetToUpdate() { SetToUpdate (-1); }
//! gives the list of modes which are flagged "to be updated".
Standard_DEPRECATED("This method is deprecated - UpdatePresentations() should be called instead")
Standard_EXPORT void ToBeUpdated (TColStd_ListOfInteger& ListOfMode) const;
//! Return the local transformation.
//! Note that the local transformation of the object having Transformation Persistence
@ -161,35 +241,24 @@ public:
? myTransformation->Trsf()
: getIdentityTrsf(); }
//! Return inversed transformation.
const gp_GTrsf& InversedTransformation() const { return myInvTransformation; }
//! Return combined parent transformation.
const Handle(Geom_Transformation)& CombinedParentTransformation() const { return myCombinedParentTransform; }
//! resets local transformation to identity.
Standard_EXPORT virtual void ResetTransformation();
//! Updates final transformation (parent + local) of presentable object and its presentations.
Standard_EXPORT virtual void UpdateTransformation();
//! Set Z layer ID and update all presentations of the presentable object.
//! The layers mechanism allows drawing objects in higher layers in overlay of objects in lower layers.
Standard_EXPORT virtual void SetZLayer (const Graphic3d_ZLayerId theLayerId);
//! Get ID of Z layer.
Standard_EXPORT Graphic3d_ZLayerId ZLayer() const;
//! Adds clip plane for graphical clipping for all display mode
//! presentations. The composition of clip planes truncates the rendering
//! space to convex volume. Please be aware that number of supported
//! clip plane is limited. The planes which exceed the limit are ignored.
//! Besides of this, some planes can be already set in view where the object
//! is shown: the number of these planes should be substracted from limit
//! to predict the maximum possible number of object clipping planes.
//! @param thePlane [in] the clip plane to be appended to map of clip planes.
Standard_EXPORT virtual void AddClipPlane (const Handle(Graphic3d_ClipPlane)& thePlane);
//! Removes previously added clip plane.
//! @param thePlane [in] the clip plane to be removed from map of clip planes.
Standard_EXPORT virtual void RemoveClipPlane (const Handle(Graphic3d_ClipPlane)& thePlane);
public: //! @name clipping planes
//! Get clip planes.
//! @return set of previously added clip planes for all display mode presentations.
const Handle(Graphic3d_SequenceOfHClipPlane)& ClipPlanes() const { return myClipPlanes; }
//! Set clip planes for graphical clipping for all display mode presentations.
//! The composition of clip planes truncates the rendering space to convex volume.
//! Please be aware that number of supported clip plane is limited.
@ -199,6 +268,213 @@ public:
//! possible number of object clipping planes.
Standard_EXPORT virtual void SetClipPlanes (const Handle(Graphic3d_SequenceOfHClipPlane)& thePlanes);
//! Adds clip plane for graphical clipping for all display mode
//! presentations. The composition of clip planes truncates the rendering
//! space to convex volume. Please be aware that number of supported
//! clip plane is limited. The planes which exceed the limit are ignored.
//! Besides of this, some planes can be already set in view where the object
//! is shown: the number of these planes should be subtracted from limit
//! to predict the maximum possible number of object clipping planes.
//! @param thePlane [in] the clip plane to be appended to map of clip planes.
Standard_EXPORT virtual void AddClipPlane (const Handle(Graphic3d_ClipPlane)& thePlane);
//! Removes previously added clip plane.
//! @param thePlane [in] the clip plane to be removed from map of clip planes.
Standard_EXPORT virtual void RemoveClipPlane (const Handle(Graphic3d_ClipPlane)& thePlane);
public: //! @name parent/children properties
//! Returns parent of current object in scene hierarchy.
PrsMgr_PresentableObject* Parent() const { return myParent; }
//! Returns children of the current object.
const PrsMgr_ListOfPresentableObjects& Children() const { return myChildren; }
//! Makes theObject child of current object in scene hierarchy.
Standard_EXPORT virtual void AddChild (const Handle(PrsMgr_PresentableObject)& theObject);
//! Removes theObject from children of current object in scene hierarchy.
Standard_EXPORT virtual void RemoveChild (const Handle(PrsMgr_PresentableObject)& theObject);
//! Returns true if object should have own presentations.
Standard_Boolean HasOwnPresentations() const { return myHasOwnPresentations; }
//! Returns bounding box of object correspondingly to its current display mode.
//! This method requires presentation to be already computed, since it relies on bounding box of presentation structures,
//! which are supposed to be same/close amongst different display modes of this object.
Standard_EXPORT virtual void BoundingBox (Bnd_Box& theBndBox);
protected: //! @name interface methods
//! Protected empty constructor.
Standard_EXPORT PrsMgr_PresentableObject(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d = PrsMgr_TOP_AllView);
//! Destructor.
Standard_EXPORT virtual ~PrsMgr_PresentableObject();
//! Fills the given 3D view presentation for specified display mode using Compute() method.
//! In addition, configures other properties of presentation (transformation, clipping planes).
//! @param thePrsMgr presentation manager where presentation has been created
//! @param thePrs presentation to fill
//! @param theMode display mode to compute; can be any number accepted by AcceptDisplayMode() method
Standard_EXPORT virtual void Fill (const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Handle(PrsMgr_Presentation)& thePrs,
const Standard_Integer theMode);
//! Calculates the 3D view presentation for specified display mode.
//! This is a key interface for implementing Presentable Object interface.
//! @param thePrsMgr presentation manager where presentation has been created
//! @param thePrs presentation to fill
//! @param theMode display mode to compute; can be any number accepted by AcceptDisplayMode() method
//! @sa AcceptDisplayMode()
Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode) = 0;
//! Calculates the 3D view presentation.
//! Each of the views in the viewer and every modification such as rotation, for example, entails recalculation.
//! It must be redefined to implement hidden line removal for the object. The user never calls this method himself.
//! This is done via the InteractiveContext object and is dependent on the point of view from which the object is displayed.
Standard_EXPORT virtual void Compute (const Handle(Prs3d_Projector)& theProjector,
const Handle(Prs3d_Presentation)& thePrs);
//! Calculates the 3D view presentation.
//! A point of view is provided by the projector, and the geometric transformation which has transformed associated presentable objects is specified by transformation.
//! This function is to be used in case where a hidden line removal display cannot be calculated automatically.
//! This occurs when associated presentable objects have been transformed geometrically, but not translated.
//! Warning! The transformation must be applied to the object before computation.
Standard_EXPORT virtual void Compute (const Handle(Prs3d_Projector)& theProjector,
const Handle(Geom_Transformation)& theTrsf,
const Handle(Prs3d_Presentation)& thePrs);
//! Recomputes invalidated presentations of the object.
//! @param theToIncludeHidden if TRUE, then even hidden invalidated presentations will be updated
//! @return TRUE if some presentations were recomputed
Standard_EXPORT Standard_Boolean UpdatePresentations (Standard_Boolean theToIncludeHidden = Standard_False);
//! General virtual method for internal update of presentation state
//! when some modifications on list of clip planes occurs. Base
//! implementation propagate clip planes to every presentation.
Standard_EXPORT virtual void UpdateClipping();
//! Sets myCombinedParentTransform to theTransformation. Thus object receives transformation
//! from parent node and able to derive its own.
Standard_EXPORT virtual void SetCombinedParentTransform (const Handle(Geom_Transformation)& theTrsf);
//! Sets local transformation to theTransformation.
Standard_EXPORT virtual void setLocalTransformation (const Handle(Geom_Transformation)& theTransformation);
//! Return the identity transformation.
Standard_EXPORT static const gp_Trsf& getIdentityTrsf();
//! Recompute computed (HLR) presentations (when view is in computed mode).
Standard_EXPORT void recomputeComputed() const;
//! Replace aspects of existing (computed) presentation groups,
//! so that the new aspects can be applied without recomputing presentation.
//! It is NOT recommended approach, because user has to fill such map and then search for each occurrence in computed groups.
//! The recommended approach is computing presentation with necessary customized aspects,
//! and then modify them directly followed by SynchronizeAspects() call.
Standard_EXPORT void replaceAspects (const Graphic3d_MapOfAspectsToAspects& theMap);
public: //! @name simplified presentation properties API
//! Enables or disables on-triangulation build of isolines according to the flag given.
void SetIsoOnTriangulation (const Standard_Boolean theIsEnabled) { myDrawer->SetIsoOnTriangulation (theIsEnabled); }
//! Returns the current facing model which is in effect.
Aspect_TypeOfFacingModel CurrentFacingModel() const { return myCurrentFacingModel; }
//! change the current facing model apply on polygons for SetColor(), SetTransparency(), SetMaterial() methods default facing model is Aspect_TOFM_TWO_SIDE.
//! This mean that attributes is applying both on the front and back face.
void SetCurrentFacingModel (const Aspect_TypeOfFacingModel theModel = Aspect_TOFM_BOTH_SIDE) { myCurrentFacingModel = theModel; }
//! Returns true if the Interactive Object has color.
Standard_Boolean HasColor() const { return hasOwnColor; }
//! Returns the color setting of the Interactive Object.
virtual void Color (Quantity_Color& theColor) const { theColor = myDrawer->Color(); }
//! Only the interactive object knowns which Drawer attribute is affected by the color, if any
//! (ex: for a wire,it's the wireaspect field of the drawer, but for a vertex, only the point aspect field is affected by the color).
//! WARNING : Do not forget to set the corresponding fields here (hasOwnColor and myDrawer->SetColor())
virtual void SetColor (const Quantity_Color& theColor)
{
myDrawer->SetColor (theColor);
hasOwnColor = Standard_True;
}
//! Removes color settings. Only the Interactive Object
//! knows which Drawer attribute is affected by the color
//! setting. For a wire, for example, wire aspect is the
//! attribute affected. For a vertex, however, only point
//! aspect is affected by the color setting.
virtual void UnsetColor() { hasOwnColor = Standard_False; }
//! Returns true if the Interactive Object has width.
Standard_Boolean HasWidth() const { return myOwnWidth != 0.0f; }
//! Returns the width setting of the Interactive Object.
Standard_Real Width() const { return myOwnWidth; }
//! Allows you to provide the setting aValue for width.
//! Only the Interactive Object knows which Drawer attribute is affected by the width setting.
virtual void SetWidth (const Standard_Real theWidth) { myOwnWidth = (Standard_ShortReal )theWidth; }
//! Reset width to default value.
virtual void UnsetWidth() { myOwnWidth = 0.0f; }
//! Returns true if the Interactive Object has a setting for material.
Standard_Boolean HasMaterial() const { return hasOwnMaterial; }
//! Returns the current material setting as enumeration value.
Standard_EXPORT virtual Graphic3d_NameOfMaterial Material() const;
//! Sets the material aMat defining this display attribute
//! for the interactive object.
//! Material aspect determines shading aspect, color and
//! transparency of visible entities.
Standard_EXPORT virtual void SetMaterial (const Graphic3d_MaterialAspect& aName);
//! Removes the setting for material.
Standard_EXPORT virtual void UnsetMaterial();
//! Returns true if there is a transparency setting.
Standard_Boolean IsTransparent() const { return myDrawer->Transparency() > 0.005f; }
//! Returns the transparency setting.
//! This will be between 0.0 and 1.0.
//! At 0.0 an object will be totally opaque, and at 1.0, fully transparent.
virtual Standard_Real Transparency() const { return (myDrawer->Transparency() <= 0.005f ? 0.0 : myDrawer->Transparency()); }
//! Attributes a setting aValue for transparency.
//! The transparency value should be between 0.0 and 1.0.
//! At 0.0 an object will be totally opaque, and at 1.0, fully transparent.
//! Warning At a value of 1.0, there may be nothing visible.
Standard_EXPORT virtual void SetTransparency (const Standard_Real aValue = 0.6);
//! Removes the transparency setting. The object is opaque by default.
Standard_EXPORT virtual void UnsetTransparency();
//! Returns Standard_True if <myDrawer> has non-null shading aspect
Standard_EXPORT virtual Standard_Boolean HasPolygonOffsets() const;
//! Retrieves current polygon offsets settings from <myDrawer>.
Standard_EXPORT virtual void PolygonOffsets (Standard_Integer& aMode, Standard_ShortReal& aFactor, Standard_ShortReal& aUnits) const;
//! Sets up polygon offsets for this object.
//! @sa Graphic3d_Aspects::SetPolygonOffsets()
Standard_EXPORT virtual void SetPolygonOffsets (const Standard_Integer aMode, const Standard_ShortReal aFactor = 1.0, const Standard_ShortReal aUnits = 0.0);
//! Clears settings provided by the drawing tool aDrawer.
Standard_EXPORT virtual void UnsetAttributes();
public: //! @name deprecated methods
//! gives the list of modes which are flagged "to be updated".
Standard_DEPRECATED("This method is deprecated - UpdatePresentations() should be called instead")
Standard_EXPORT void ToBeUpdated (TColStd_ListOfInteger& ListOfMode) const;
Standard_DEPRECATED("This method is deprecated - overload taking Handle should be used instead")
void SetClipPlanes (const Graphic3d_SequenceOfHClipPlane& thePlanes)
{
@ -206,107 +482,44 @@ public:
SetClipPlanes (aPlanes);
}
//! Get clip planes.
//! @return set of previously added clip planes for all display mode presentations.
const Handle(Graphic3d_SequenceOfHClipPlane)& ClipPlanes() const { return myClipPlanes; }
//! Sets if the object has mutable nature (content or location will be changed regularly).
//! This method should be called before object displaying to take effect.
Standard_EXPORT virtual void SetMutable (const Standard_Boolean theIsMutable);
//! Returns true if object has mutable nature (content or location are be changed regularly).
//! Mutable object will be managed in different way than static onces (another optimizations).
Standard_Boolean IsMutable() const { return myIsMutable; }
//! Makes theObject child of current object in scene hierarchy.
Standard_EXPORT virtual void AddChild (const Handle(PrsMgr_PresentableObject)& theObject);
//! Removes theObject from children of current object in scene hierarchy.
Standard_EXPORT virtual void RemoveChild (const Handle(PrsMgr_PresentableObject)& theObject);
//! Returns children of the current object.
const PrsMgr_ListOfPresentableObjects& Children() const { return myChildren; }
//! Returns true if object should have own presentations.
Standard_Boolean HasOwnPresentations() const { return myHasOwnPresentations; }
//! Returns parent of current object in scene hierarchy.
PrsMgr_PresentableObjectPointer Parent() const { return myParent; }
//! Initializes the drawing tool theDrawer.
Standard_EXPORT virtual void SetAttributes(const Handle(Prs3d_Drawer)& theDrawer);
//! Returns the attributes settings.
const Handle(Prs3d_Drawer)& Attributes() const
//! Sets up Transform Persistence Mode for this object.
//! This function used to lock in object position, rotation and / or zooming relative to camera position.
//! Object will be drawn in the origin setted by thePoint parameter (except Graphic3d_TMF_TriedronPers flag
//! - see description later). theMode should be:
//! - Graphic3d_TMF_None - no persistence attributes (reset);
//! - Graphic3d_TMF_ZoomPers - object doesn't resize;
//! - Graphic3d_TMF_RotatePers - object doesn't rotate;
//! - Graphic3d_TMF_ZoomRotatePers - object doesn't resize and rotate;
//! - Graphic3d_TMF_RotatePers - object doesn't rotate;
//! - Graphic3d_TMF_TriedronPers - object behaves like trihedron.
//! If Graphic3d_TMF_TriedronPers or Graphic3d_TMF_2d persistence mode selected thePoint coordinates X and Y means:
//! - X = 0.0, Y = 0.0 - center of view window;
//! - X > 0.0, Y > 0.0 - right upper corner of view window;
//! - X > 0.0, Y < 0.0 - right lower corner of view window;
//! - X < 0.0, Y > 0.0 - left upper corner of view window;
//! - X < 0.0, Y < 0.0 - left lower corner of view window.
//! And Z coordinate defines the gap from border of view window (except center position).
Standard_DEPRECATED("This method is deprecated - SetTransformPersistence() taking Graphic3d_TransformPers should be called instead")
void SetTransformPersistence (const Graphic3d_TransModeFlags theMode, const gp_Pnt& thePoint = gp_Pnt (0.0, 0.0, 0.0))
{
return myDrawer;
SetTransformPersistence (Graphic3d_TransformPers::FromDeprecatedParams (theMode, thePoint));
}
//! Clears settings provided by the drawing tool theDrawer.
Standard_EXPORT virtual void UnsetAttributes();
//! Gets Transform Persistence Mode for this object
Standard_DEPRECATED("This method is deprecated - TransformPersistence() should be called instead")
Graphic3d_TransModeFlags GetTransformPersistenceMode() const
{
return myTransformPersistence.IsNull()
? Graphic3d_TMF_None
: myTransformPersistence->Mode();
}
//! Returns the hilight attributes settings.
//! When not NULL, overrides both Prs3d_TypeOfHighlight_LocalSelected and Prs3d_TypeOfHighlight_Selected defined within AIS_InteractiveContext.
const Handle(Prs3d_Drawer)& HilightAttributes() const { return myHilightDrawer; }
//! Initializes the hilight drawing tool theDrawer.
virtual void SetHilightAttributes(const Handle(Prs3d_Drawer)& theDrawer) { myHilightDrawer = theDrawer; }
//! Returns the hilight attributes settings.
//! When not NULL, overrides both Prs3d_TypeOfHighlight_LocalDynamic and Prs3d_TypeOfHighlight_Dynamic defined within AIS_InteractiveContext.
const Handle(Prs3d_Drawer)& DynamicHilightAttributes() const { return myDynHilightDrawer; }
//! Initializes the dynamic hilight drawing tool.
virtual void SetDynamicHilightAttributes (const Handle(Prs3d_Drawer)& theDrawer) { myDynHilightDrawer = theDrawer; }
//! Clears settings provided by the hilight drawing tool theDrawer.
virtual void UnsetHilightAttributes() { myHilightDrawer.Nullify(); }
//! Gets point of transform persistence for this object
Standard_DEPRECATED("This method is deprecated - TransformPersistence() should be called instead")
Standard_EXPORT gp_Pnt GetTransformPersistencePoint() const;
protected:
Standard_EXPORT PrsMgr_PresentableObject(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d = PrsMgr_TOP_AllView);
Standard_EXPORT virtual ~PrsMgr_PresentableObject();
//! Calculates the 3D view aPresentation and its
//! updates. The latter are managed by aPresentationManager.
//! aPresentableObject has the display mode aMode;
//! this has the default value of 0, that is, the wireframe display mode.
Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, const Handle(Prs3d_Presentation)& aPresentation, const Standard_Integer aMode);
//! Calculates the 3D view aPresentation and its
//! updates. The latter are managed by
//! aPresentationManager. Each of the views in the
//! viewer and every modification such as rotation, for
//! example, entails recalculation.
//! It must be redefined to implement hidden line removal
//! for the object. The user never calls this method
//! himself. This is done via the InteractiveContext object
//! and is dependent on the point of view from which the
//! object is displayed.
Standard_EXPORT virtual void Compute (const Handle(Prs3d_Projector)& aProjector, const Handle(Prs3d_Presentation)& aPresentation);
//! Calculates the 3D view aPresentation and its
//! updates. The latter are managed by
//! aPresentationManager. A point of view is provided
//! by the projector aProjector, and the geometric
//! transformation which has transformed associated
//! presentable objects is specified by aTrsf.
//! This function is to be used in case where a hidden
//! line removal display cannot be calculated
//! automatically. This occurs when associated
//! presentable objects have been transformed
//! geometrically, but not translated.
//! Warning
//! The transformation aTrsf must be applied to the
//! object before computation.
Standard_EXPORT virtual void Compute (const Handle(Prs3d_Projector)& aProjector, const Handle(Geom_Transformation)& aTrsf, const Handle(Prs3d_Presentation)& aPresentation);
//! Recomputes invalidated presentations of the object.
//! @param theToIncludeHidden if TRUE, then even hidden invalidated presentations will be updated
//! @return TRUE if some presentations were recomputed
Standard_EXPORT Standard_Boolean UpdatePresentations (Standard_Boolean theToIncludeHidden = Standard_False);
//! Recomputes all presentations of the object.
Standard_DEPRECATED("This method is deprecated - SetToUpdate() + UpdatePresentations() should be called instead")
void Update (Standard_Boolean theToIncludeHidden = Standard_False)
@ -320,50 +533,31 @@ Standard_EXPORT virtual ~PrsMgr_PresentableObject();
//! @param theToClearOther when TRUE, other presentations (display modes) will be removed
Standard_DEPRECATED("This method is deprecated - SetToUpdate() + UpdatePresentations() should be called instead")
Standard_EXPORT void Update (Standard_Integer theMode, Standard_Boolean theToClearOther);
//! High-level interface for controlling polygon offsets
Standard_EXPORT virtual void Fill (const Handle(PrsMgr_PresentationManager)& aPresentationManager, const Handle(PrsMgr_Presentation)& aPresentation, const Standard_Integer aMode);
//! Sets myCombinedParentTransform to theTransformation. Thus object receives transformation
//! from parent node and able to derive its own.
Standard_EXPORT virtual void SetCombinedParentTransform (const Handle(Geom_Transformation)& theTrsf);
//! General virtual method for internal update of presentation state
//! when some modifications on list of clip planes occurs. Base
//! implementation propagate clip planes to every presentation.
Standard_EXPORT virtual void UpdateClipping();
//! Sets local transformation to theTransformation.
Standard_EXPORT virtual void setLocalTransformation (const Handle(Geom_Transformation)& theTransformation);
//! Recompute computed (HLR) presentations (when view is in computed mode).
Standard_EXPORT void recomputeComputed() const;
private:
//! Return the identity transformation.
Standard_EXPORT static const gp_Trsf& getIdentityTrsf();
protected:
PrsMgr_Presentations myPresentations;
Handle(Graphic3d_SequenceOfHClipPlane) myClipPlanes;
Handle(Prs3d_Drawer) myDrawer;
Handle(Prs3d_Drawer) myHilightDrawer;
Handle(Prs3d_Drawer) myDynHilightDrawer;
PrsMgr_TypeOfPresentation3d myTypeOfPresentation3d;
Standard_Boolean myIsMutable;
Standard_Boolean myHasOwnPresentations;
PrsMgr_PresentableObject* myParent; //!< pointer to the parent object
PrsMgr_Presentations myPresentations; //!< list of presentations
Handle(Graphic3d_SequenceOfHClipPlane) myClipPlanes; //!< sequence of object-specific clipping planes
Handle(Prs3d_Drawer) myDrawer; //!< main presentation attributes
Handle(Prs3d_Drawer) myHilightDrawer; //!< (optional) custom presentation attributes for highlighting selected object
Handle(Prs3d_Drawer) myDynHilightDrawer; //!< (optional) custom presentation attributes for highlighting detected object
Handle(Graphic3d_TransformPers) myTransformPersistence; //!< transformation persistence
Handle(Geom_Transformation) myLocalTransformation; //!< local transformation relative to parent object
Handle(Geom_Transformation) myTransformation; //!< absolute transformation of this object (combined parents + local transformations)
Handle(Geom_Transformation) myCombinedParentTransform; //!< transformation of parent object (combined for all parents)
PrsMgr_ListOfPresentableObjects myChildren; //!< list of children
gp_GTrsf myInvTransformation; //!< inversion of absolute transformation (combined parents + local transformations)
PrsMgr_TypeOfPresentation3d myTypeOfPresentation3d; //!< presentation type
private:
Aspect_TypeOfFacingModel myCurrentFacingModel; //!< current facing model
Standard_ShortReal myOwnWidth; //!< custom width value
Standard_Boolean hasOwnColor; //!< own color flag
Standard_Boolean hasOwnMaterial; //!< own material flag
Handle(Graphic3d_TransformPers) myTransformPersistence;
PrsMgr_PresentableObjectPointer myParent;
Handle(Geom_Transformation) myLocalTransformation;
Handle(Geom_Transformation) myTransformation;
Handle(Geom_Transformation) myCombinedParentTransform;
gp_GTrsf myInvTransformation;
PrsMgr_ListOfPresentableObjects myChildren;
Standard_Boolean myInfiniteState; //!< infinite flag
Standard_Boolean myIsMutable; //!< mutable flag
Standard_Boolean myHasOwnPresentations; //!< flag indicating if object should have own presentations
};

View File

@ -1,23 +0,0 @@
// Created on: 1995-01-25
// Created by: Jean-Louis Frenkel
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _PrsMgr_PresentableObjectPointer_HeaderFile
#define _PrsMgr_PresentableObjectPointer_HeaderFile
class PrsMgr_PresentableObject;
typedef PrsMgr_PresentableObject* PrsMgr_PresentableObjectPointer;
#endif // _PrsMgr_PresentableObjectPointer_HeaderFile

View File

@ -18,7 +18,6 @@
#define _PrsMgr_Presentation_HeaderFile
#include <Graphic3d_ZLayerId.hxx>
#include <PrsMgr_PresentableObjectPointer.hxx>
#include <Standard.hxx>
#include <Standard_Boolean.hxx>
#include <Standard_Integer.hxx>
@ -114,7 +113,7 @@ protected:
Handle(PrsMgr_PresentationManager) myPresentationManager;
Handle(Prs3d_Presentation) myStructure;
PrsMgr_PresentableObjectPointer myPresentableObject;
PrsMgr_PresentableObject* myPresentableObject;
Standard_Boolean myMustBeUpdated;
Standard_Integer myBeforeHighlightState;

View File

@ -1,23 +0,0 @@
// Created on: 1995-01-25
// Created by: Jean-Louis Frenkel
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _PrsMgr_PresentationPointer_HeaderFile
#define _PrsMgr_PresentationPointer_HeaderFile
class PrsMgr_Presentation;
typedef PrsMgr_Presentation* PrsMgr_PresentationPointer;
#endif // _PrsMgr_PresentationPointer_HeaderFile

View File

@ -26,8 +26,8 @@
IMPLEMENT_STANDARD_RTTIEXT(PrsMgr_Prs,Prs3d_Presentation)
PrsMgr_Prs::PrsMgr_Prs (const Handle(Graphic3d_StructureManager)& theStructManager,
const PrsMgr_PresentationPointer& thePrs,
const PrsMgr_TypeOfPresentation3d theTypeOfPresentation)
PrsMgr_Presentation* thePrs,
PrsMgr_TypeOfPresentation3d theTypeOfPresentation)
: Prs3d_Presentation (theStructManager),
myPresentation3d (thePrs)
{

View File

@ -17,30 +17,29 @@
#ifndef _PrsMgr_Prs_HeaderFile
#define _PrsMgr_Prs_HeaderFile
#include <Standard.hxx>
#include <Standard_Type.hxx>
#include <PrsMgr_PresentationPointer.hxx>
#include <Prs3d_Presentation.hxx>
#include <PrsMgr_TypeOfPresentation3d.hxx>
#include <TColStd_Array2OfReal.hxx>
class Graphic3d_StructureManager;
class Graphic3d_Structure;
class Graphic3d_DataStructureManager;
class PrsMgr_Presentation;
class PrsMgr_Prs;
DEFINE_STANDARD_HANDLE(PrsMgr_Prs, Prs3d_Presentation)
class PrsMgr_Prs : public Prs3d_Presentation
{
DEFINE_STANDARD_RTTIEXT(PrsMgr_Prs, Prs3d_Presentation)
public:
Standard_EXPORT PrsMgr_Prs(const Handle(Graphic3d_StructureManager)& theStructManager, const PrsMgr_PresentationPointer& thePresentation, const PrsMgr_TypeOfPresentation3d theTypeOfPresentation3d);
Standard_EXPORT PrsMgr_Prs (const Handle(Graphic3d_StructureManager)& theStructManager,
PrsMgr_Presentation* thePresentation,
PrsMgr_TypeOfPresentation3d theTypeOfPresentation3d);
Standard_EXPORT virtual void Compute() Standard_OVERRIDE;
Standard_EXPORT void Compute() Standard_OVERRIDE;
Standard_EXPORT Handle(Graphic3d_Structure) Compute (const Handle(Graphic3d_DataStructureManager)& aProjector) Standard_OVERRIDE;
Standard_EXPORT virtual Handle(Graphic3d_Structure) Compute (const Handle(Graphic3d_DataStructureManager)& aProjector) Standard_OVERRIDE;
//! the "degenerated" Structure is displayed with
//! a transformation defined by <AMatrix>
@ -48,25 +47,23 @@ public:
//! We have to take in account this Transformation
//! in the computation of hidden line removal...
//! returns a filled Graphic Structure.
Standard_EXPORT Handle(Graphic3d_Structure) Compute (const Handle(Graphic3d_DataStructureManager)& theProjector,
const Handle(Geom_Transformation)& theTrsf) Standard_OVERRIDE;
Standard_EXPORT virtual Handle(Graphic3d_Structure) Compute (const Handle(Graphic3d_DataStructureManager)& theProjector,
const Handle(Geom_Transformation)& theTrsf) Standard_OVERRIDE;
//! No need to return a structure, just to fill
//! <ComputedStruct> ....
Standard_EXPORT void Compute (const Handle(Graphic3d_DataStructureManager)& aProjector, Handle(Graphic3d_Structure)& ComputedStruct) Standard_OVERRIDE;
Standard_EXPORT virtual void Compute (const Handle(Graphic3d_DataStructureManager)& aProjector, Handle(Graphic3d_Structure)& ComputedStruct) Standard_OVERRIDE;
//! No Need to return a Structure, just to
//! Fill <aStructure>. The Trsf has to be taken in account
//! in the computation (Rotation Part....)
Standard_EXPORT void Compute (const Handle(Graphic3d_DataStructureManager)& theProjector,
const Handle(Geom_Transformation)& theTrsf,
Handle(Graphic3d_Structure)& theStructure) Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(PrsMgr_Prs,Prs3d_Presentation)
Standard_EXPORT virtual void Compute (const Handle(Graphic3d_DataStructureManager)& theProjector,
const Handle(Geom_Transformation)& theTrsf,
Handle(Graphic3d_Structure)& theStructure) Standard_OVERRIDE;
private:
PrsMgr_PresentationPointer myPresentation3d;
PrsMgr_Presentation* myPresentation3d;
};

View File

@ -16,9 +16,6 @@
#include <SelectMgr_SelectableObject.hxx>
#include <Aspect_TypeOfMarker.hxx>
#include <Bnd_Box.hxx>
#include <gp_Pnt.hxx>
#include <Graphic3d_AspectLine3d.hxx>
#include <Graphic3d_AspectMarker3d.hxx>
#include <Prs3d_Drawer.hxx>
@ -26,8 +23,7 @@
#include <Prs3d_PlaneAspect.hxx>
#include <Prs3d_PointAspect.hxx>
#include <Prs3d_Presentation.hxx>
#include <PrsMgr_PresentableObjectPointer.hxx>
#include <PrsMgr_PresentationManager3d.hxx>
#include <PrsMgr_PresentationManager.hxx>
#include <Select3D_SensitiveEntity.hxx>
#include <SelectBasics_EntityOwner.hxx>
#include <SelectMgr_EntityOwner.hxx>
@ -36,15 +32,14 @@
#include <SelectMgr_SelectionManager.hxx>
#include <Standard_NoSuchObject.hxx>
#include <Standard_NotImplemented.hxx>
#include <Standard_Type.hxx>
#include <TopLoc_Location.hxx>
IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_SelectableObject,PrsMgr_PresentableObject)
namespace
{
Handle(SelectMgr_Selection) THE_NULL_SELECTION;
Handle(SelectMgr_EntityOwner) THE_NULL_ENTITYOWNER;
static const Handle(SelectMgr_Selection) THE_NULL_SELECTION;
static const Handle(SelectMgr_EntityOwner) THE_NULL_ENTITYOWNER;
}
//==================================================
@ -54,9 +49,9 @@ namespace
SelectMgr_SelectableObject::SelectMgr_SelectableObject (const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d)
: PrsMgr_PresentableObject (aTypeOfPresentation3d),
myAutoHilight (Standard_True),
myGlobalSelMode (0),
mycurrent (0),
myGlobalSelMode (0)
myAutoHilight (Standard_True)
{
//
}
@ -290,7 +285,7 @@ void SelectMgr_SelectableObject::UpdateTransformations (const Handle(SelectMgr_S
//function : HilightSelected
//purpose :
//=======================================================================
void SelectMgr_SelectableObject::HilightSelected (const Handle(PrsMgr_PresentationManager3d)&,
void SelectMgr_SelectableObject::HilightSelected (const Handle(PrsMgr_PresentationManager)&,
const SelectMgr_SequenceOfOwner&)
{
throw Standard_NotImplemented("SelectMgr_SelectableObject::HilightSelected");
@ -312,7 +307,7 @@ void SelectMgr_SelectableObject::ClearSelected()
//function : ClearDynamicHighlight
//purpose :
//=======================================================================
void SelectMgr_SelectableObject::ClearDynamicHighlight (const Handle(PrsMgr_PresentationManager3d)& theMgr)
void SelectMgr_SelectableObject::ClearDynamicHighlight (const Handle(PrsMgr_PresentationManager)& theMgr)
{
theMgr->ClearImmediateDraw();
}
@ -321,36 +316,18 @@ void SelectMgr_SelectableObject::ClearDynamicHighlight (const Handle(PrsMgr_Pres
//function : HilightOwnerWithColor
//purpose :
//=======================================================================
void SelectMgr_SelectableObject::HilightOwnerWithColor (const Handle(PrsMgr_PresentationManager3d)&,
void SelectMgr_SelectableObject::HilightOwnerWithColor (const Handle(PrsMgr_PresentationManager)&,
const Handle(Prs3d_Drawer)&,
const Handle(SelectMgr_EntityOwner)&)
{
throw Standard_NotImplemented("SelectMgr_SelectableObject::HilightOwnerWithColor");
}
//=======================================================================
//function : IsAutoHilight
//purpose :
//=======================================================================
Standard_Boolean SelectMgr_SelectableObject::IsAutoHilight() const
{
return myAutoHilight;
}
//=======================================================================
//function : SetAutoHilight
//purpose :
//=======================================================================
void SelectMgr_SelectableObject::SetAutoHilight ( const Standard_Boolean newAutoHilight )
{
myAutoHilight = newAutoHilight;
}
//=======================================================================
//function : GetHilightPresentation
//purpose :
//=======================================================================
Handle(Prs3d_Presentation) SelectMgr_SelectableObject::GetHilightPresentation (const Handle(PrsMgr_PresentationManager3d)& theMgr)
Handle(Prs3d_Presentation) SelectMgr_SelectableObject::GetHilightPresentation (const Handle(PrsMgr_PresentationManager)& theMgr)
{
if (myHilightPrs.IsNull() && !theMgr.IsNull())
{
@ -363,12 +340,11 @@ Handle(Prs3d_Presentation) SelectMgr_SelectableObject::GetHilightPresentation (c
return myHilightPrs;
}
//=======================================================================
//function : GetSelectPresentation
//purpose :
//=======================================================================
Handle(Prs3d_Presentation) SelectMgr_SelectableObject::GetSelectPresentation (const Handle(PrsMgr_PresentationManager3d)& theMgr)
Handle(Prs3d_Presentation) SelectMgr_SelectableObject::GetSelectPresentation (const Handle(PrsMgr_PresentationManager)& theMgr)
{
if (mySelectionPrs.IsNull() && !theMgr.IsNull())
{

View File

@ -18,8 +18,6 @@
#define _SelectMgr_SelectableObject_HeaderFile
#include <PrsMgr_PresentableObject.hxx>
#include <PrsMgr_PresentationManager3d.hxx>
#include <PrsMgr_TypeOfPresentation3d.hxx>
#include <SelectMgr_IndexedMapOfOwner.hxx>
#include <SelectMgr_SequenceOfSelection.hxx>
#include <SelectMgr_Selection.hxx>
@ -30,15 +28,20 @@ class Prs3d_Presentation;
class Standard_NotImplemented;
class SelectMgr_SelectionManager;
//! A framework to supply the structure of the object to be
//! selected. At the first pick, this structure is created by
//! calling the appropriate algorithm and retaining this
//! framework for further picking.
//! This abstract framework is inherited in Application
//! Interactive Services (AIS), notably in AIS_InteractiveObject.
//! Consequently, 3D selection should be handled by the
//! relevant daughter classes and their member functions
//! in AIS. This is particularly true in the creation of new interactive objects.
//! A framework to supply the structure of the object to be selected.
//! At the first pick, this structure is created by calling the appropriate algorithm and retaining this framework for further picking.
//! This abstract framework is inherited in Application Interactive Services (AIS), notably in AIS_InteractiveObject.
//! Consequently, 3D selection should be handled by the relevant daughter classes and their member functions in AIS.
//! This is particularly true in the creation of new interactive objects.
//!
//! Key interface methods to be implemented by every Selectable Object:
//! * Presentable Object (PrsMgr_PresentableObject)
//! Consider defining an enumeration of supported Display Mode indexes for particular Interactive Object or class of Interactive Objects.
//! - AcceptDisplayMode() accepting display modes implemented by this object;
//! - Compute() computing presentation for the given display mode index;
//! * Selectable Object (SelectMgr_SelectableObject)
//! Consider defining an enumeration of supported Selection Mode indexes for particular Interactive Object or class of Interactive Objects.
//! - ComputeSelection() computing selectable entities for the given selection mode index.
class SelectMgr_SelectableObject : public PrsMgr_PresentableObject
{
DEFINE_STANDARD_RTTIEXT(SelectMgr_SelectableObject, PrsMgr_PresentableObject)
@ -47,17 +50,17 @@ public:
//! Clears all selections of the object
Standard_EXPORT virtual ~SelectMgr_SelectableObject();
//! Recovers and calculates any sensitive primitive,
//! aSelection, available in Shape mode, specified by
//! aMode. As a rule, these are sensitive faces.
//! This method is defined as virtual. This enables you to
//! implement it in the creation of a new class of AIS
//! Interactive Object. You need to do this and in so
//! doing, redefine this method, if you create a class
//! which enriches the list of signatures and types.
Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& aSelection, const Standard_Integer aMode) = 0;
//! Computes sensitive primitives for the given selection mode - key interface method of Selectable Object.
//! @param theSelection selection to fill
//! @param theMode selection mode to create sensitive primitives
virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer theMode) = 0;
//! Informs the graphic context that the interactive Object may be decomposed into sub-shapes for dynamic selection.
//! The most used Interactive Object is AIS_Shape.
virtual Standard_Boolean AcceptShapeDecomposition() const { return Standard_False; }
//! Re-computes the sensitive primitives for all modes. IMPORTANT: Do not use
//! this method to update selection primitives except implementing custom selection manager!
//! This method does not take into account necessary BVH updates, but may invalidate the pointers
@ -91,6 +94,84 @@ public:
//! Return the sequence of selections.
const SelectMgr_SequenceOfSelection& Selections() const { return myselections; }
Standard_EXPORT void ResetTransformation() Standard_OVERRIDE;
//! Recomputes the location of the selection aSelection.
Standard_EXPORT virtual void UpdateTransformation() Standard_OVERRIDE;
//! Updates locations in all sensitive entities from <aSelection>
//! and in corresponding entity owners.
Standard_EXPORT virtual void UpdateTransformations (const Handle(SelectMgr_Selection)& aSelection);
//! Method which draws selected owners ( for fast presentation draw )
Standard_EXPORT virtual void HilightSelected (const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const SelectMgr_SequenceOfOwner& theSeq);
//! Method which clear all selected owners belonging
//! to this selectable object ( for fast presentation draw )
Standard_EXPORT virtual void ClearSelected();
//! Method that needs to be implemented when the object
//! manages selection and dynamic highlighting on its own.
//! Clears or invalidates dynamic highlight presentation.
//! By default it clears immediate draw of given presentation
//! manager.
Standard_EXPORT virtual void ClearDynamicHighlight (const Handle(PrsMgr_PresentationManager)& theMgr);
//! Method which hilight an owner belonging to
//! this selectable object ( for fast presentation draw )
Standard_EXPORT virtual void HilightOwnerWithColor (const Handle(PrsMgr_PresentationManager)& thePM,
const Handle(Prs3d_Drawer)& theStyle,
const Handle(SelectMgr_EntityOwner)& theOwner);
//! If returns True, the old mechanism for highlighting selected objects is used (HilightSelected Method may be empty).
//! If returns False, the HilightSelected method will be fully responsible for highlighting selected entity owners belonging to this selectable object.
virtual Standard_Boolean IsAutoHilight() const { return myAutoHilight; }
//! Set AutoHilight property to true or false.
virtual void SetAutoHilight (const Standard_Boolean theAutoHilight) { myAutoHilight = theAutoHilight; }
//! Creates or returns existing presentation for highlighting detected object.
//! @param thePrsMgr presentation manager to create new presentation
//! @return existing or newly created presentation (when thePrsMgr is not NULL)
Standard_EXPORT Handle(Prs3d_Presentation) GetHilightPresentation (const Handle(PrsMgr_PresentationManager)& thePrsMgr);
//! Creates or returns existing presentation for highlighting selected object.
//! @param thePrsMgr presentation manager to create new presentation
//! @return existing or newly created presentation (when thePrsMgr is not NULL)
Standard_EXPORT Handle(Prs3d_Presentation) GetSelectPresentation (const Handle(PrsMgr_PresentationManager)& thePrsMgr);
//! Removes presentations returned by GetHilightPresentation() and GetSelectPresentation().
Standard_EXPORT virtual void ErasePresentations (Standard_Boolean theToRemove);
//! Set Z layer ID and update all presentations of the selectable object.
//! The layers mechanism allows drawing objects in higher layers in overlay of objects in lower layers.
Standard_EXPORT virtual void SetZLayer (const Graphic3d_ZLayerId theLayerId) Standard_OVERRIDE;
//! Sets update status FULL to selections of the object. Must be used as the only method of UpdateSelection
//! from outer classes to prevent BVH structures from being outdated.
void UpdateSelection (const Standard_Integer theMode = -1)
{
updateSelection (theMode);
}
//! Sets common entity owner for assembly sensitive object entities
Standard_EXPORT void SetAssemblyOwner (const Handle(SelectMgr_EntityOwner)& theOwner, const Standard_Integer theMode = -1);
//! Returns a bounding box of sensitive entities with the owners given if they are a part of activated selection
Standard_EXPORT Bnd_Box BndBoxOfSelected (const Handle(SelectMgr_IndexedMapOfOwner)& theOwners);
//! Returns the mode for selection of object as a whole; 0 by default.
Standard_Integer GlobalSelectionMode() const { return myGlobalSelMode; }
//! Returns the owner of mode for selection of object as a whole
Standard_EXPORT virtual Handle(SelectMgr_EntityOwner) GlobalSelOwner() const;
//! Returns common entity owner if the object is an assembly
Standard_EXPORT virtual const Handle(SelectMgr_EntityOwner)& GetAssemblyOwner() const;
public:
//! Begins the iteration scanning for sensitive primitives.
Standard_DEPRECATED("Deprecated method, Selections() should be used instead")
void Init() { mycurrent = 1; }
@ -107,92 +188,12 @@ public:
Standard_DEPRECATED("Deprecated method, Selections() should be used instead")
const Handle(SelectMgr_Selection)& CurrentSelection() const { return myselections (mycurrent); }
Standard_EXPORT void ResetTransformation() Standard_OVERRIDE;
//! Recomputes the location of the selection aSelection.
Standard_EXPORT virtual void UpdateTransformation() Standard_OVERRIDE;
//! Updates locations in all sensitive entities from <aSelection>
//! and in corresponding entity owners.
Standard_EXPORT virtual void UpdateTransformations (const Handle(SelectMgr_Selection)& aSelection);
//! Method which draws selected owners ( for fast presentation draw )
Standard_EXPORT virtual void HilightSelected (const Handle(PrsMgr_PresentationManager3d)& PM, const SelectMgr_SequenceOfOwner& Seq);
//! Method which clear all selected owners belonging
//! to this selectable object ( for fast presentation draw )
Standard_EXPORT virtual void ClearSelected();
//! Method that needs to be implemented when the object
//! manages selection and dynamic highlighting on its own.
//! Clears or invalidates dynamic highlight presentation.
//! By default it clears immediate draw of given presentation
//! manager.
Standard_EXPORT virtual void ClearDynamicHighlight (const Handle(PrsMgr_PresentationManager3d)& theMgr);
//! Method which hilight an owner belonging to
//! this selectable object ( for fast presentation draw )
Standard_EXPORT virtual void HilightOwnerWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM,
const Handle(Prs3d_Drawer)& theStyle,
const Handle(SelectMgr_EntityOwner)& theOwner);
//! If returns True, the old mechanism for highlighting
//! selected objects is used (HilightSelected Method may be empty).
//! If returns False, the HilightSelected method will be
//! fully responsible for highlighting selected entity
//! owners belonging to this selectable object.
Standard_EXPORT virtual Standard_Boolean IsAutoHilight() const;
//! Set AutoHilight property to true or false
//! Sets up Transform Persistence Mode for this object
Standard_EXPORT virtual void SetAutoHilight (const Standard_Boolean newAutoHilight);
Standard_EXPORT Handle(Prs3d_Presentation) GetHilightPresentation (const Handle(PrsMgr_PresentationManager3d)& TheMgr);
Standard_EXPORT Handle(Prs3d_Presentation) GetSelectPresentation (const Handle(PrsMgr_PresentationManager3d)& TheMgr);
//! Removes presentations returned by GetHilightPresentation() and GetSelectPresentation().
Standard_EXPORT virtual void ErasePresentations (Standard_Boolean theToRemove);
//! Set Z layer ID and update all presentations of the selectable object.
//! The layers mechanism allows drawing objects in higher layers in overlay of objects in lower layers.
Standard_EXPORT virtual void SetZLayer (const Graphic3d_ZLayerId theLayerId) Standard_OVERRIDE;
//! Sets update status FULL to selections of the object. Must be used as the only method of UpdateSelection
//! from outer classes to prevent BVH structures from being outdated.
void UpdateSelection (const Standard_Integer theMode = -1)
{
updateSelection (theMode);
}
//! Returns bounding box of selectable object
//! by storing its minimum and maximum 3d coordinates
//! to output parameters
Standard_EXPORT virtual void BoundingBox (Bnd_Box& theBndBox) = 0;
//! Sets common entity owner for assembly sensitive object entities
Standard_EXPORT void SetAssemblyOwner (const Handle(SelectMgr_EntityOwner)& theOwner, const Standard_Integer theMode = -1);
//! Returns a bounding box of sensitive entities with the owners given
//! if they are a part of activated selection
Standard_EXPORT Bnd_Box BndBoxOfSelected (const Handle(SelectMgr_IndexedMapOfOwner)& theOwners);
//! Returns the mode for selection of object as a whole
Standard_Integer GlobalSelectionMode() const
{
return myGlobalSelMode;
}
//! Returns the owner of mode for selection of object as a whole
Standard_EXPORT virtual Handle(SelectMgr_EntityOwner) GlobalSelOwner() const;
//! Returns common entity owner if the object is an assembly
Standard_EXPORT virtual const Handle(SelectMgr_EntityOwner)& GetAssemblyOwner() const;
protected:
//! Protected empty constructor.
Standard_EXPORT SelectMgr_SelectableObject(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d = PrsMgr_TOP_AllView);
//! Override global selection mode.
void setGlobalSelMode (const Standard_Integer theMode)
{
myGlobalSelMode = theMode > 0 ? theMode : 0;
@ -201,19 +202,18 @@ protected:
//! Update clipping planes state.
Standard_EXPORT virtual void UpdateClipping() Standard_OVERRIDE;
//! Sets update status FULL to selections of the object.
//! Must be used as the only method of UpdateSelection from outer classes to prevent BVH structures from being outdated.
Standard_EXPORT virtual void updateSelection (const Standard_Integer theMode);
protected:
SelectMgr_SequenceOfSelection myselections;
Handle(Prs3d_Presentation) mySelectionPrs;
Handle(Prs3d_Presentation) myHilightPrs;
Standard_Boolean myAutoHilight;
private:
Standard_Integer mycurrent;
Standard_Integer myGlobalSelMode;
SelectMgr_SequenceOfSelection myselections; //!< list of selections
Handle(Prs3d_Presentation) mySelectionPrs; //!< optional presentation for highlighting selected object
Handle(Prs3d_Presentation) myHilightPrs; //!< optional presentation for highlighting detected object
Standard_Integer myGlobalSelMode; //!< global selection mode
Standard_Integer mycurrent; //!< [deprecated] iterator value
Standard_Boolean myAutoHilight; //!< auto-highlighting flag defining
};