1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-10 18:51:21 +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 #ifndef _AIS_IdenticRelation_HeaderFile
#define _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 <AIS_Relation.hxx>
#include <gp_Pnt.hxx>
#include <PrsMgr_PresentationManager3d.hxx> #include <PrsMgr_PresentationManager3d.hxx>
#include <Standard_Integer.hxx>
#include <SelectMgr_Selection.hxx> #include <SelectMgr_Selection.hxx>
#include <Standard_Real.hxx> #include <TColStd_ListOfTransient.hxx>
class TopoDS_Shape; class TopoDS_Shape;
class Geom_Plane; class Geom_Plane;
class Prs3d_Presentation;
class Prs3d_Projector;
class Geom_Transformation;
class Geom_Line; class Geom_Line;
class gp_Pnt; class gp_Pnt;
class Geom_Circle; class Geom_Circle;
@ -40,8 +33,6 @@ class TopoDS_Wire;
class TopoDS_Vertex; class TopoDS_Vertex;
class gp_Dir; class gp_Dir;
class AIS_IdenticRelation;
DEFINE_STANDARD_HANDLE(AIS_IdenticRelation, AIS_Relation) DEFINE_STANDARD_HANDLE(AIS_IdenticRelation, AIS_Relation)
//! Constructs a constraint by a relation of identity //! 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, void AIS_InteractiveContext::SetSelectedAspect (const Handle(Prs3d_BasicAspect)& theAspect,
const Standard_Boolean theToUpdateViewer) const Standard_Boolean theToUpdateViewer)
{ {
Standard_DISABLE_DEPRECATION_WARNINGS
Standard_Boolean isFound = Standard_False; Standard_Boolean isFound = Standard_False;
for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next()) 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()); Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (aSelIter.Value()->Selectable());
anObj->SetAspect (theAspect); anObj->SetAspect (theAspect);
} }
Standard_ENABLE_DEPRECATION_WARNINGS
if (isFound && theToUpdateViewer) if (isFound && theToUpdateViewer)
{ {

View File

@ -454,6 +454,7 @@ public: //! @name iteration through detected entities
public: //! @name Selection management public: //! @name Selection management
//! Sets the graphic basic aspect to the current presentation of ALL selected objects. //! 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, Standard_EXPORT void SetSelectedAspect (const Handle(Prs3d_BasicAspect)& theAspect,
const Standard_Boolean theToUpdateViewer); const Standard_Boolean theToUpdateViewer);

View File

@ -16,32 +16,21 @@
#include <AIS_InteractiveObject.hxx> #include <AIS_InteractiveObject.hxx>
#include <AIS_GraphicTool.hxx>
#include <AIS_InteractiveContext.hxx> #include <AIS_InteractiveContext.hxx>
#include <Aspect_PolygonOffsetMode.hxx>
#include <Bnd_Box.hxx>
#include <Graphic3d_AspectFillArea3d.hxx> #include <Graphic3d_AspectFillArea3d.hxx>
#include <Graphic3d_AspectLine3d.hxx> #include <Graphic3d_AspectLine3d.hxx>
#include <Graphic3d_AspectMarker3d.hxx> #include <Graphic3d_AspectMarker3d.hxx>
#include <Graphic3d_AspectText3d.hxx> #include <Graphic3d_AspectText3d.hxx>
#include <Graphic3d_BndBox4f.hxx>
#include <Graphic3d_CStructure.hxx> #include <Graphic3d_CStructure.hxx>
#include <Graphic3d_Group.hxx> #include <Graphic3d_Group.hxx>
#include <Graphic3d_MaterialAspect.hxx>
#include <Graphic3d_Structure.hxx> #include <Graphic3d_Structure.hxx>
#include <Prs3d_BasicAspect.hxx>
#include <Prs3d_LineAspect.hxx> #include <Prs3d_LineAspect.hxx>
#include <Prs3d_PointAspect.hxx> #include <Prs3d_PointAspect.hxx>
#include <Prs3d_Presentation.hxx> #include <Prs3d_Presentation.hxx>
#include <Prs3d_Root.hxx>
#include <Prs3d_ShadingAspect.hxx> #include <Prs3d_ShadingAspect.hxx>
#include <Prs3d_TextAspect.hxx> #include <Prs3d_TextAspect.hxx>
#include <PrsMgr_ModedPresentation.hxx> #include <PrsMgr_ModedPresentation.hxx>
#include <PrsMgr_PresentationManager3d.hxx> #include <PrsMgr_PresentationManager.hxx>
#include <Quantity_Color.hxx>
#include <Standard_Transient.hxx>
#include <Standard_Type.hxx>
#include <TColStd_ListIteratorOfListOfInteger.hxx>
IMPLEMENT_STANDARD_RTTIEXT(AIS_InteractiveObject,SelectMgr_SelectableObject) 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) AIS_InteractiveObject::AIS_InteractiveObject (const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d)
: SelectMgr_SelectableObject (aTypeOfPresentation3d), : SelectMgr_SelectableObject (aTypeOfPresentation3d),
myCTXPtr (NULL), myCTXPtr (NULL)
myOwnWidth (0.0f),
myCurrentFacingModel (Aspect_TOFM_BOTH_SIDE),
myInfiniteState (Standard_False),
hasOwnColor (Standard_False),
hasOwnMaterial (Standard_False)
{ {
SetCurrentFacingModel(); //
} }
//======================================================================= //=======================================================================
@ -73,22 +57,6 @@ void AIS_InteractiveObject::Redisplay (const Standard_Boolean AllModes)
myCTXPtr->Redisplay (this, Standard_False, 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 : //function :
//purpose : //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 //function : HasPresentation
//purpose : //purpose :
@ -393,205 +115,34 @@ Handle(Prs3d_Presentation) AIS_InteractiveObject::Presentation() const
//function : SetAspect //function : SetAspect
//purpose : //purpose :
//======================================================================= //=======================================================================
void AIS_InteractiveObject::SetAspect(const Handle(Prs3d_BasicAspect)& anAspect) void AIS_InteractiveObject::SetAspect(const Handle(Prs3d_BasicAspect)& theAspect)
{ {
if( HasPresentation() ) { 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())
{ {
return; 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(); return;
if (aPrs3d.IsNull() }
|| aPrs3d->Presentation().IsNull()) const Handle(Graphic3d_Group)& aGroup = aPrs->Groups().Last();
{ if (Handle(Prs3d_ShadingAspect) aShadingAspect = Handle(Prs3d_ShadingAspect)::DownCast(theAspect))
continue; {
} aGroup->SetGroupPrimitivesAspect (aShadingAspect->Aspect());
}
for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (aPrs3d->Presentation()->Groups()); aGroupIter.More(); aGroupIter.Next()) else if (Handle(Prs3d_LineAspect) aLineAspect = Handle(Prs3d_LineAspect)::DownCast(theAspect))
{ {
if (!aGroupIter.Value().IsNull()) aGroup->SetGroupPrimitivesAspect (aLineAspect->Aspect());
{ }
aGroupIter.ChangeValue()->ReplaceAspects (theMap); 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 #ifndef _AIS_InteractiveObject_HeaderFile
#define _AIS_InteractiveObject_HeaderFile #define _AIS_InteractiveObject_HeaderFile
#include <Aspect_TypeOfFacingModel.hxx>
#include <AIS_KindOfInteractive.hxx> #include <AIS_KindOfInteractive.hxx>
#include <Graphic3d_NameOfMaterial.hxx>
#include <PrsMgr_TypeOfPresentation3d.hxx>
#include <SelectMgr_SelectableObject.hxx> #include <SelectMgr_SelectableObject.hxx>
#include <TColStd_ListOfInteger.hxx>
#include <TColStd_ListOfTransient.hxx>
#include <Quantity_Color.hxx>
class AIS_InteractiveContext; class AIS_InteractiveContext;
class Graphic3d_MaterialAspect; class Graphic3d_MaterialAspect;
@ -33,123 +27,39 @@ class Prs3d_BasicAspect;
class Bnd_Box; class Bnd_Box;
//! Defines a class of objects with display and selection services. //! Defines a class of objects with display and selection services.
//! Entities which are visualized and selected are //! Entities which are visualized and selected are Interactive Objects.
//! Interactive Objects. You can make use of classes of //! Specific attributes of entities such as arrow aspect for dimensions must be loaded in a Prs3d_Drawer.
//! standard Interactive Objects for which all necessary //!
//! methods have already been programmed, or you can //! You can make use of classes of standard Interactive Objects for which all necessary methods have already been programmed,
//! implement your own classes of Interactive Objects. //! or you can implement your own classes of Interactive Objects.
//! Specific attributes of entities such as arrow aspect for //! Key interface methods to be implemented by every Interactive Object:
//! dimensions must be loaded in a Drawer. This Drawer //! * Presentable Object (PrsMgr_PresentableObject)
//! is then applied to the Interactive Object in view. //! Consider defining an enumeration of supported Display Mode indexes for particular Interactive Object or class of Interactive Objects.
//! There are four types of Interactive Object in AIS: the //! - AcceptDisplayMode() accepting display modes implemented by this object;
//! construction element or Datum, the Relation, which //! - Compute() computing presentation for the given display mode index;
//! includes both dimensions and constraints, the Object, //! * Selectable Object (SelectMgr_SelectableObject)
//! and finally, when the object is of an unknown type, the None type. //! Consider defining an enumeration of supported Selection Mode indexes for particular Interactive Object or class of Interactive Objects.
//! Inside these categories, a signature, or index, //! - ComputeSelection() computing selectable entities for the given selection mode 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.
class AIS_InteractiveObject : public SelectMgr_SelectableObject class AIS_InteractiveObject : public SelectMgr_SelectableObject
{ {
friend class AIS_InteractiveContext; friend class AIS_InteractiveContext;
DEFINE_STANDARD_RTTIEXT(AIS_InteractiveObject, SelectMgr_SelectableObject) DEFINE_STANDARD_RTTIEXT(AIS_InteractiveObject, SelectMgr_SelectableObject)
public: public:
//! Returns the kind of Interactive Object: //! Returns the kind of Interactive Object; AIS_KOI_None by default.
//! - None virtual AIS_KindOfInteractive Type() const { return AIS_KOI_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 //! Specifies additional characteristics of Interactive Object of Type(); -1 by default.
//! Objects. A signature is, in fact, an index with integer //! Among the datums, this signature is attributed to the shape.
//! 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
//! The remaining datums have the following default signatures: //! The remaining datums have the following default signatures:
//! - Point signature 1 //! - Point signature 1
//! - Axis signature 2 //! - Axis signature 2
//! - Trihedron signature 3 //! - Trihedron signature 3
//! - PlaneTrihedron signature 4 //! - PlaneTrihedron signature 4
//! - Line signature 5 //! - Line signature 5
//! - Circle signature 6 //! - Circle signature 6
//! - Plane signature 7. //! - Plane signature 7.
Standard_EXPORT virtual Standard_Integer Signature() const; virtual Standard_Integer Signature() const { return -1; }
//! 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;
//! Updates the active presentation; if <AllModes> = Standard_True //! Updates the active presentation; if <AllModes> = Standard_True
//! all the presentations inside are recomputed. //! all the presentations inside are recomputed.
@ -159,32 +69,19 @@ public:
//! so this class field must be up to date for proper result. //! so this class field must be up to date for proper result.
Standard_EXPORT void Redisplay (const Standard_Boolean AllModes = Standard_False); 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. //! Indicates whether the Interactive Object has a pointer to an interactive context.
Standard_Boolean HasInteractiveContext() const { return myCTXPtr != NULL; } Standard_Boolean HasInteractiveContext() const { return myCTXPtr != NULL; }
//! Returns the context pointer to the interactive context. //! 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 //! Sets the interactive context aCtx and provides a link
//! to the default drawing tool or "Drawer" if there is none. //! to the default drawing tool or "Drawer" if there is none.
Standard_EXPORT virtual void SetContext (const Handle(AIS_InteractiveContext)& aCtx); Standard_EXPORT virtual void SetContext (const Handle(AIS_InteractiveContext)& aCtx);
//! Returns true if the object has an owner attributed to it. //! Returns true if the object has an owner attributed to it.
//! The owner can be a shape for a set of sub-shapes or //! 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.
//! a sub-shape for sub-shapes which it is composed of, Standard_Boolean HasOwner() const { return !myOwner.IsNull(); }
//! and takes the form of a transient.
Standard_EXPORT Standard_Boolean HasOwner() const;
//! Returns the owner of the Interactive Object. //! Returns the owner of the Interactive Object.
//! The owner can be a shape for a set of sub-shapes or //! 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. //! is composed of. The owner takes the form of a transient.
void SetOwner (const Handle(Standard_Transient)& theApplicativeEntity) { myOwner = theApplicativeEntity; } void SetOwner (const Handle(Standard_Transient)& theApplicativeEntity) { myOwner = theApplicativeEntity; }
//! Each Interactive Object has methods which allow us //! Each Interactive Object has methods which allow us to attribute an Owner to it in the form of a Transient.
//! to attribute an Owner to it in the form of a Transient.
//! This method removes the owner from the graphic entity. //! 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 public:
//! mode setting. Otherwise, it is displayed in Neutral Point.
Standard_Boolean HasDisplayMode() const { return myDrawer->DisplayMode() != -1; }
//! Sets the display mode aMode for the interactive object. //! Returns the context pointer to the interactive context.
//! An object can have its own temporary display mode, Standard_EXPORT Handle(AIS_InteractiveContext) GetContext() const;
//! 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);
//! Removes display mode settings from the interactive object. //! Returns TRUE when this object has a presentation in the current DisplayMode()
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()
Standard_EXPORT Standard_Boolean HasPresentation() const; Standard_EXPORT Standard_Boolean HasPresentation() const;
//! Returns the current presentation of this object //! Returns the current presentation of this object according to the current DisplayMode()
//! according to the current DisplayMode()
Standard_EXPORT Handle(Prs3d_Presentation) Presentation() const; Standard_EXPORT Handle(Prs3d_Presentation) Presentation() const;
//! Sets the graphic basic aspect to the current presentation. //! 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); 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: 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 //! The TypeOfPresention3d means that the interactive object
//! may have a presentation dependant of the view of Display. //! may have a presentation dependant of the view of Display.
Standard_EXPORT AIS_InteractiveObject(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d = PrsMgr_TOP_AllView); Standard_EXPORT AIS_InteractiveObject(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d = PrsMgr_TOP_AllView);
protected: protected:
AIS_InteractiveContext* myCTXPtr; AIS_InteractiveContext* myCTXPtr; //!< pointer to Interactive Context, where object is currently displayed; @sa SetContext()
Handle(Standard_Transient) myOwner; Handle(Standard_Transient) myOwner; //!< application-specific owner object
Standard_ShortReal myOwnWidth;
Aspect_TypeOfFacingModel myCurrentFacingModel;
Standard_Boolean myInfiniteState;
Standard_Boolean hasOwnColor;
Standard_Boolean hasOwnMaterial;
}; };

View File

@ -60,11 +60,17 @@ private:
//! Inspired by AIS_Shape::ComputeSelection() from OCCT 6.5.1 //! Inspired by AIS_Shape::ComputeSelection() from OCCT 6.5.1
//! @param [in] selection container for sensitive primitives //! @param [in] selection container for sensitive primitives
//! @param [in] mode Selection mode //! @param [in] mode Selection mode
void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection, virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer theMode) Standard_OVERRIDE; 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(); const Bnd_Box& BoundingBox();
private:
IVtkOCC_Shape::Handle myShape; IVtkOCC_Shape::Handle myShape;
Bnd_Box myBndBox; Bnd_Box myBndBox;
Handle(Prs3d_Drawer) myOCCTDrawer; Handle(Prs3d_Drawer) myOCCTDrawer;

View File

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

View File

@ -16,27 +16,26 @@
#include <PrsMgr_PresentableObject.hxx> #include <PrsMgr_PresentableObject.hxx>
#include <Graphic3d_AspectFillArea3d.hxx>
#include <Prs3d_Drawer.hxx> #include <Prs3d_Drawer.hxx>
#include <Prs3d_LineAspect.hxx>
#include <Prs3d_PointAspect.hxx>
#include <Prs3d_Presentation.hxx> #include <Prs3d_Presentation.hxx>
#include <Prs3d_Projector.hxx> #include <Prs3d_Projector.hxx>
#include <Prs3d_ShadingAspect.hxx>
#include <PrsMgr_ModedPresentation.hxx> #include <PrsMgr_ModedPresentation.hxx>
#include <Standard_NotImplemented.hxx> #include <Standard_NotImplemented.hxx>
#include <TColStd_ListIteratorOfListOfInteger.hxx>
#include <TColStd_MapOfInteger.hxx> #include <TColStd_MapOfInteger.hxx>
IMPLEMENT_STANDARD_RTTIEXT(PrsMgr_PresentableObject, Standard_Transient) IMPLEMENT_STANDARD_RTTIEXT(PrsMgr_PresentableObject, Standard_Transient)
namespace
{
static const gp_Trsf THE_IDENTITY_TRSF;
}
//======================================================================= //=======================================================================
//function : getIdentityTrsf //function : getIdentityTrsf
//purpose : //purpose :
//======================================================================= //=======================================================================
const gp_Trsf& PrsMgr_PresentableObject::getIdentityTrsf() const gp_Trsf& PrsMgr_PresentableObject::getIdentityTrsf()
{ {
static const gp_Trsf THE_IDENTITY_TRSF;
return THE_IDENTITY_TRSF; return THE_IDENTITY_TRSF;
} }
@ -45,11 +44,18 @@ const gp_Trsf& PrsMgr_PresentableObject::getIdentityTrsf()
//purpose : //purpose :
//======================================================================= //=======================================================================
PrsMgr_PresentableObject::PrsMgr_PresentableObject (const PrsMgr_TypeOfPresentation3d theType) PrsMgr_PresentableObject::PrsMgr_PresentableObject (const PrsMgr_TypeOfPresentation3d theType)
: myDrawer (new Prs3d_Drawer()), : myParent (NULL),
myDrawer (new Prs3d_Drawer()),
myTypeOfPresentation3d (theType), myTypeOfPresentation3d (theType),
//
myCurrentFacingModel (Aspect_TOFM_BOTH_SIDE),
myOwnWidth (0.0f),
hasOwnColor (Standard_False),
hasOwnMaterial (Standard_False),
//
myInfiniteState (Standard_False),
myIsMutable (Standard_False), myIsMutable (Standard_False),
myHasOwnPresentations (Standard_True), myHasOwnPresentations (Standard_True)
myParent (NULL)
{ {
myDrawer->SetDisplayMode (-1); myDrawer->SetDisplayMode (-1);
} }
@ -82,17 +88,6 @@ void PrsMgr_PresentableObject::Fill (const Handle(PrsMgr_PresentationManager)& t
aStruct3d->SetTransformPersistence (TransformPersistence()); 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 //function : Compute
//purpose : //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 // function : AddClipPlane
// purpose : // 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 // function : SetMutable
// purpose : // 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 // function : UnsetAttributes
// purpose : // purpose :
@ -576,4 +576,272 @@ void PrsMgr_PresentableObject::UnsetAttributes()
aDrawer->Link(myDrawer->Link()); aDrawer->Link(myDrawer->Link());
} }
myDrawer = aDrawer; 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 #ifndef _PrsMgr_PresentableObject_HeaderFile
#define _PrsMgr_PresentableObject_HeaderFile #define _PrsMgr_PresentableObject_HeaderFile
#include <Aspect_TypeOfFacingModel.hxx>
#include <gp_GTrsf.hxx> #include <gp_GTrsf.hxx>
#include <Graphic3d_ClipPlane.hxx> #include <Graphic3d_ClipPlane.hxx>
#include <Graphic3d_SequenceOfHClipPlane.hxx> #include <Graphic3d_SequenceOfHClipPlane.hxx>
@ -28,25 +29,22 @@
#include <PrsMgr_Presentation.hxx> #include <PrsMgr_Presentation.hxx>
#include <PrsMgr_Presentations.hxx> #include <PrsMgr_Presentations.hxx>
#include <PrsMgr_PresentationManager3d.hxx> #include <PrsMgr_PresentationManager3d.hxx>
#include <PrsMgr_PresentableObjectPointer.hxx>
#include <PrsMgr_TypeOfPresentation3d.hxx> #include <PrsMgr_TypeOfPresentation3d.hxx>
#include <TColStd_ListOfInteger.hxx> #include <TColStd_ListOfInteger.hxx>
//! A framework to supply the Graphic3d //! A framework to supply the Graphic3d structure of the object to be presented.
//! structure of the object to be presented. On the first //! On the first display request, this structure is created by calling the appropriate algorithm and retaining this framework for further display.
//! display request, this structure is created by calling the //! This abstract framework is inherited in Application Interactive Services (AIS), notably by AIS_InteractiveObject.
//! appropriate algorithm and retaining this frameworkfor //! Consequently, 3D presentation should be handled by the relevant daughter classes and their member functions in AIS.
//! further display. //! This is particularly true in the creation of new interactive objects.
//! This abstract framework is inherited in Application //!
//! Interactive Services (AIS), notably in: //! Key interface methods to be implemented by every Selectable Object:
//! - AIS_InteractiveObject //! - AcceptDisplayMode() accepting display modes implemented by this object;
//! - AIS_ConnectedInteractive //! - Compute() computing presentation for the given display mode index.
//! - AIS_MultipleConnectedInteractive //!
//! - AIS_Shape //! Warning! Methods managing standard attributes (SetColor(), SetWidth(), SetMaterial()) have different meaning for objects of different type (or no meaning at all).
//! Consequently, 3D presentation should be handled by //! Sub-classes might override these methods to modify Prs3d_Drawer or class properties providing a convenient short-cut depending on application needs.
//! the relevant daughter classes and their member //! For more sophisticated configuring, Prs3d_Drawer should be modified directly, while short-cuts might be left unimplemented.
//! functions in AIS. This is particularly true in the
//! creation of new interactive objects.
class PrsMgr_PresentableObject : public Standard_Transient class PrsMgr_PresentableObject : public Standard_Transient
{ {
DEFINE_STANDARD_RTTIEXT(PrsMgr_PresentableObject, Standard_Transient) DEFINE_STANDARD_RTTIEXT(PrsMgr_PresentableObject, Standard_Transient)
@ -54,60 +52,85 @@ class PrsMgr_PresentableObject : public Standard_Transient
friend class PrsMgr_PresentationManager; friend class PrsMgr_PresentationManager;
public: public:
//! Return presentations.
PrsMgr_Presentations& Presentations() { return myPresentations; } PrsMgr_Presentations& Presentations() { return myPresentations; }
//! Returns information on whether the object accepts display in HLR mode or not. //! Get ID of Z layer for main presentation.
PrsMgr_TypeOfPresentation3d TypeOfPresentation3d() const { return myTypeOfPresentation3d; } Graphic3d_ZLayerId ZLayer() const { return myDrawer->ZLayer(); }
//! Returns Transformation Persistence defining a special Local Coordinate system where this presentable object is located or NULL handle if not defined. //! Set Z layer ID and update all presentations of the presentable object.
//! Position of the object having Transformation Persistence is mutable and depends on camera position. //! The layers mechanism allows drawing objects in higher layers in overlay of objects in lower layers.
//! The same applies to a bounding box of the object. Standard_EXPORT virtual void SetZLayer (const Graphic3d_ZLayerId theLayerId);
//! @sa Graphic3d_TransformPers class description
const Handle(Graphic3d_TransformPers)& TransformPersistence() const { return myTransformPersistence; }
//! Sets up Transform Persistence defining a special Local Coordinate system where this object should be located. //! Returns true if object has mutable nature (content or location are be changed regularly).
//! Note that management of Transform Persistence object is more expensive than of the normal one, //! Mutable object will be managed in different way than static onces (another optimizations).
//! because it requires its position being recomputed basing on camera position within each draw call / traverse. Standard_Boolean IsMutable() const { return myIsMutable; }
//! @sa Graphic3d_TransformPers class description
Standard_EXPORT virtual void SetTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers);
//! Sets up Transform Persistence Mode for this object. //! Sets if the object has mutable nature (content or location will be changed regularly).
//! This function used to lock in object position, rotation and / or zooming relative to camera position. //! This method should be called before object displaying to take effect.
//! Object will be drawn in the origin setted by thePoint parameter (except Graphic3d_TMF_TriedronPers flag Standard_EXPORT virtual void SetMutable (const Standard_Boolean theIsMutable);
//! - see description later). theMode should be:
//! - Graphic3d_TMF_None - no persistence attributes (reset); //! Returns true if the Interactive Object has display mode setting overriding global setting (within Interactive Context).
//! - Graphic3d_TMF_ZoomPers - object doesn't resize; Standard_Boolean HasDisplayMode() const { return myDrawer->DisplayMode() != -1; }
//! - Graphic3d_TMF_RotatePers - object doesn't rotate;
//! - Graphic3d_TMF_ZoomRotatePers - object doesn't resize and rotate; //! Returns the display mode setting of the Interactive Object.
//! - Graphic3d_TMF_RotatePers - object doesn't rotate; //! The range of supported display mode indexes should be specified within object definition and filtered by AccepDisplayMode().
//! - Graphic3d_TMF_TriedronPers - object behaves like trihedron. //! @sa AcceptDisplayMode()
//! If Graphic3d_TMF_TriedronPers or Graphic3d_TMF_2d persistence mode selected thePoint coordinates X and Y means: Standard_Integer DisplayMode() const { return myDrawer->DisplayMode(); }
//! - X = 0.0, Y = 0.0 - center of view window;
//! - X > 0.0, Y > 0.0 - right upper corner of view window; //! Sets the display mode for the interactive object.
//! - X > 0.0, Y < 0.0 - right lower corner of view window; //! An object can have its own temporary display mode, which is different from that proposed by the interactive context.
//! - X < 0.0, Y > 0.0 - left upper corner of view window; //! @sa AcceptDisplayMode()
//! - X < 0.0, Y < 0.0 - left lower corner of view window. void SetDisplayMode (const Standard_Integer theMode)
//! 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)); if (AcceptDisplayMode (theMode))
{
myDrawer->SetDisplayMode (theMode);
}
} }
//! Gets Transform Persistence Mode for this object //! Removes display mode settings from the interactive object.
Standard_DEPRECATED("This method is deprecated - TransformPersistence() should be called instead") void UnsetDisplayMode() { myDrawer->SetDisplayMode (-1); }
Graphic3d_TransModeFlags GetTransformPersistenceMode() const
//! 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()
{ {
return myTransformPersistence.IsNull() if (!myHilightDrawer.IsNull())
? Graphic3d_TMF_None {
: myTransformPersistence->Mode(); myHilightDrawer->SetDisplayMode (-1);
}
if (!myDynHilightDrawer.IsNull())
{
myDynHilightDrawer->SetDisplayMode (-1);
}
} }
//! Gets point of transform persistence for this object //! Returns true if the class of objects accepts specified display mode index.
Standard_DEPRECATED("This method is deprecated - TransformPersistence() should be called instead") //! The interactive context can have a default mode of representation for the set of Interactive Objects.
Standard_EXPORT gp_Pnt GetTransformPersistencePoint() const; //! 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;
}
Standard_EXPORT void SetTypeOfPresentation (const PrsMgr_TypeOfPresentation3d aType); //! Returns the default display mode.
virtual Standard_Integer DefaultDisplayMode() const { return 0; }
//! Returns TRUE if any active presentation has invalidation flag. //! Returns TRUE if any active presentation has invalidation flag.
//! @param theToIncludeHidden when TRUE, also checks hidden presentations //! @param theToIncludeHidden when TRUE, also checks hidden presentations
@ -120,9 +143,66 @@ public:
//! flags all the Presentations to be Updated. //! flags all the Presentations to be Updated.
void SetToUpdate() { SetToUpdate (-1); } void SetToUpdate() { SetToUpdate (-1); }
//! gives the list of modes which are flagged "to be updated". //! Returns true if the interactive object is infinite; FALSE by default.
Standard_DEPRECATED("This method is deprecated - UpdatePresentations() should be called instead") //! This flag affects various operations operating on bounding box of graphic presentations of this object.
Standard_EXPORT void ToBeUpdated (TColStd_ListOfInteger& ListOfMode) const; //! 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.
//! @sa Graphic3d_TransformPers class description
const Handle(Graphic3d_TransformPers)& TransformPersistence() const { return myTransformPersistence; }
//! Sets up Transform Persistence defining a special Local Coordinate system where this object should be located.
//! Note that management of Transform Persistence object is more expensive than of the normal one,
//! 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);
//! Return the local transformation. //! Return the local transformation.
//! Note that the local transformation of the object having Transformation Persistence //! Note that the local transformation of the object having Transformation Persistence
@ -161,34 +241,23 @@ public:
? myTransformation->Trsf() ? myTransformation->Trsf()
: getIdentityTrsf(); } : getIdentityTrsf(); }
//! Return inversed transformation.
const gp_GTrsf& InversedTransformation() const { return myInvTransformation; } const gp_GTrsf& InversedTransformation() const { return myInvTransformation; }
//! Return combined parent transformation.
const Handle(Geom_Transformation)& CombinedParentTransformation() const { return myCombinedParentTransform; }
//! resets local transformation to identity. //! resets local transformation to identity.
Standard_EXPORT virtual void ResetTransformation(); Standard_EXPORT virtual void ResetTransformation();
//! Updates final transformation (parent + local) of presentable object and its presentations. //! Updates final transformation (parent + local) of presentable object and its presentations.
Standard_EXPORT virtual void UpdateTransformation(); Standard_EXPORT virtual void UpdateTransformation();
//! Set Z layer ID and update all presentations of the presentable object. public: //! @name clipping planes
//! 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. //! Get clip planes.
Standard_EXPORT Graphic3d_ZLayerId ZLayer() const; //! @return set of previously added clip planes for all display mode presentations.
const Handle(Graphic3d_SequenceOfHClipPlane)& ClipPlanes() const { return myClipPlanes; }
//! 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);
//! Set clip planes for graphical clipping for all display mode presentations. //! Set clip planes for graphical clipping for all display mode presentations.
//! The composition of clip planes truncates the rendering space to convex volume. //! The composition of clip planes truncates the rendering space to convex volume.
@ -199,24 +268,27 @@ public:
//! possible number of object clipping planes. //! possible number of object clipping planes.
Standard_EXPORT virtual void SetClipPlanes (const Handle(Graphic3d_SequenceOfHClipPlane)& thePlanes); Standard_EXPORT virtual void SetClipPlanes (const Handle(Graphic3d_SequenceOfHClipPlane)& thePlanes);
Standard_DEPRECATED("This method is deprecated - overload taking Handle should be used instead") //! Adds clip plane for graphical clipping for all display mode
void SetClipPlanes (const Graphic3d_SequenceOfHClipPlane& thePlanes) //! presentations. The composition of clip planes truncates the rendering
{ //! space to convex volume. Please be aware that number of supported
Handle(Graphic3d_SequenceOfHClipPlane) aPlanes = new Graphic3d_SequenceOfHClipPlane (thePlanes); //! clip plane is limited. The planes which exceed the limit are ignored.
SetClipPlanes (aPlanes); //! 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);
//! Get clip planes. //! Removes previously added clip plane.
//! @return set of previously added clip planes for all display mode presentations. //! @param thePlane [in] the clip plane to be removed from map of clip planes.
const Handle(Graphic3d_SequenceOfHClipPlane)& ClipPlanes() const { return myClipPlanes; } Standard_EXPORT virtual void RemoveClipPlane (const Handle(Graphic3d_ClipPlane)& thePlane);
//! Sets if the object has mutable nature (content or location will be changed regularly). public: //! @name parent/children properties
//! 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). //! Returns parent of current object in scene hierarchy.
//! Mutable object will be managed in different way than static onces (another optimizations). PrsMgr_PresentableObject* Parent() const { return myParent; }
Standard_Boolean IsMutable() const { return myIsMutable; }
//! Returns children of the current object.
const PrsMgr_ListOfPresentableObjects& Children() const { return myChildren; }
//! Makes theObject child of current object in scene hierarchy. //! Makes theObject child of current object in scene hierarchy.
Standard_EXPORT virtual void AddChild (const Handle(PrsMgr_PresentableObject)& theObject); Standard_EXPORT virtual void AddChild (const Handle(PrsMgr_PresentableObject)& theObject);
@ -224,89 +296,230 @@ public:
//! Removes theObject from children of current object in scene hierarchy. //! Removes theObject from children of current object in scene hierarchy.
Standard_EXPORT virtual void RemoveChild (const Handle(PrsMgr_PresentableObject)& theObject); 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. //! Returns true if object should have own presentations.
Standard_Boolean HasOwnPresentations() const { return myHasOwnPresentations; } Standard_Boolean HasOwnPresentations() const { return myHasOwnPresentations; }
//! Returns parent of current object in scene hierarchy. //! Returns bounding box of object correspondingly to its current display mode.
PrsMgr_PresentableObjectPointer Parent() const { return myParent; } //! 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.
//! Initializes the drawing tool theDrawer. Standard_EXPORT virtual void BoundingBox (Bnd_Box& theBndBox);
Standard_EXPORT virtual void SetAttributes(const Handle(Prs3d_Drawer)& theDrawer);
//! Returns the attributes settings.
const Handle(Prs3d_Drawer)& Attributes() const
{
return myDrawer;
}
//! Clears settings provided by the drawing tool theDrawer.
Standard_EXPORT virtual void UnsetAttributes();
//! 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(); }
protected:
protected: //! @name interface methods
//! Protected empty constructor.
Standard_EXPORT PrsMgr_PresentableObject(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d = PrsMgr_TOP_AllView); Standard_EXPORT PrsMgr_PresentableObject(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d = PrsMgr_TOP_AllView);
Standard_EXPORT virtual ~PrsMgr_PresentableObject();
//! Calculates the 3D view aPresentation and its //! Destructor.
//! updates. The latter are managed by aPresentationManager. Standard_EXPORT virtual ~PrsMgr_PresentableObject();
//! 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 //! Fills the given 3D view presentation for specified display mode using Compute() method.
//! updates. The latter are managed by //! In addition, configures other properties of presentation (transformation, clipping planes).
//! aPresentationManager. Each of the views in the //! @param thePrsMgr presentation manager where presentation has been created
//! viewer and every modification such as rotation, for //! @param thePrs presentation to fill
//! example, entails recalculation. //! @param theMode display mode to compute; can be any number accepted by AcceptDisplayMode() method
//! It must be redefined to implement hidden line removal Standard_EXPORT virtual void Fill (const Handle(PrsMgr_PresentationManager)& thePrsMgr,
//! for the object. The user never calls this method const Handle(PrsMgr_Presentation)& thePrs,
//! himself. This is done via the InteractiveContext object const Standard_Integer theMode);
//! 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 //! Calculates the 3D view presentation for specified display mode.
//! updates. The latter are managed by //! This is a key interface for implementing Presentable Object interface.
//! aPresentationManager. A point of view is provided //! @param thePrsMgr presentation manager where presentation has been created
//! by the projector aProjector, and the geometric //! @param thePrs presentation to fill
//! transformation which has transformed associated //! @param theMode display mode to compute; can be any number accepted by AcceptDisplayMode() method
//! presentable objects is specified by aTrsf. //! @sa AcceptDisplayMode()
//! This function is to be used in case where a hidden Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager)& thePrsMgr,
//! line removal display cannot be calculated const Handle(Prs3d_Presentation)& thePrs,
//! automatically. This occurs when associated const Standard_Integer theMode) = 0;
//! presentable objects have been transformed
//! geometrically, but not translated. //! Calculates the 3D view presentation.
//! Warning //! Each of the views in the viewer and every modification such as rotation, for example, entails recalculation.
//! The transformation aTrsf must be applied to the //! It must be redefined to implement hidden line removal for the object. The user never calls this method himself.
//! object before computation. //! 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(Geom_Transformation)& aTrsf, const Handle(Prs3d_Presentation)& aPresentation); 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. //! Recomputes invalidated presentations of the object.
//! @param theToIncludeHidden if TRUE, then even hidden invalidated presentations will be updated //! @param theToIncludeHidden if TRUE, then even hidden invalidated presentations will be updated
//! @return TRUE if some presentations were recomputed //! @return TRUE if some presentations were recomputed
Standard_EXPORT Standard_Boolean UpdatePresentations (Standard_Boolean theToIncludeHidden = Standard_False); 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)
{
Handle(Graphic3d_SequenceOfHClipPlane) aPlanes = new Graphic3d_SequenceOfHClipPlane (thePlanes);
SetClipPlanes (aPlanes);
}
//! 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;
protected:
//! Recomputes all presentations of the object. //! Recomputes all presentations of the object.
Standard_DEPRECATED("This method is deprecated - SetToUpdate() + UpdatePresentations() should be called instead") Standard_DEPRECATED("This method is deprecated - SetToUpdate() + UpdatePresentations() should be called instead")
void Update (Standard_Boolean theToIncludeHidden = Standard_False) void Update (Standard_Boolean theToIncludeHidden = Standard_False)
@ -321,49 +534,30 @@ Standard_EXPORT virtual ~PrsMgr_PresentableObject();
Standard_DEPRECATED("This method is deprecated - SetToUpdate() + UpdatePresentations() should be called instead") Standard_DEPRECATED("This method is deprecated - SetToUpdate() + UpdatePresentations() should be called instead")
Standard_EXPORT void Update (Standard_Integer theMode, Standard_Boolean theToClearOther); 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: protected:
PrsMgr_Presentations myPresentations; PrsMgr_PresentableObject* myParent; //!< pointer to the parent object
Handle(Graphic3d_SequenceOfHClipPlane) myClipPlanes; PrsMgr_Presentations myPresentations; //!< list of presentations
Handle(Prs3d_Drawer) myDrawer; Handle(Graphic3d_SequenceOfHClipPlane) myClipPlanes; //!< sequence of object-specific clipping planes
Handle(Prs3d_Drawer) myHilightDrawer; Handle(Prs3d_Drawer) myDrawer; //!< main presentation attributes
Handle(Prs3d_Drawer) myDynHilightDrawer; Handle(Prs3d_Drawer) myHilightDrawer; //!< (optional) custom presentation attributes for highlighting selected object
PrsMgr_TypeOfPresentation3d myTypeOfPresentation3d; Handle(Prs3d_Drawer) myDynHilightDrawer; //!< (optional) custom presentation attributes for highlighting detected object
Standard_Boolean myIsMutable; Handle(Graphic3d_TransformPers) myTransformPersistence; //!< transformation persistence
Standard_Boolean myHasOwnPresentations; 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; Standard_Boolean myInfiniteState; //!< infinite flag
PrsMgr_PresentableObjectPointer myParent; Standard_Boolean myIsMutable; //!< mutable flag
Handle(Geom_Transformation) myLocalTransformation; Standard_Boolean myHasOwnPresentations; //!< flag indicating if object should have own presentations
Handle(Geom_Transformation) myTransformation;
Handle(Geom_Transformation) myCombinedParentTransform;
gp_GTrsf myInvTransformation;
PrsMgr_ListOfPresentableObjects myChildren;
}; };

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 #define _PrsMgr_Presentation_HeaderFile
#include <Graphic3d_ZLayerId.hxx> #include <Graphic3d_ZLayerId.hxx>
#include <PrsMgr_PresentableObjectPointer.hxx>
#include <Standard.hxx> #include <Standard.hxx>
#include <Standard_Boolean.hxx> #include <Standard_Boolean.hxx>
#include <Standard_Integer.hxx> #include <Standard_Integer.hxx>
@ -114,7 +113,7 @@ protected:
Handle(PrsMgr_PresentationManager) myPresentationManager; Handle(PrsMgr_PresentationManager) myPresentationManager;
Handle(Prs3d_Presentation) myStructure; Handle(Prs3d_Presentation) myStructure;
PrsMgr_PresentableObjectPointer myPresentableObject; PrsMgr_PresentableObject* myPresentableObject;
Standard_Boolean myMustBeUpdated; Standard_Boolean myMustBeUpdated;
Standard_Integer myBeforeHighlightState; 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) IMPLEMENT_STANDARD_RTTIEXT(PrsMgr_Prs,Prs3d_Presentation)
PrsMgr_Prs::PrsMgr_Prs (const Handle(Graphic3d_StructureManager)& theStructManager, PrsMgr_Prs::PrsMgr_Prs (const Handle(Graphic3d_StructureManager)& theStructManager,
const PrsMgr_PresentationPointer& thePrs, PrsMgr_Presentation* thePrs,
const PrsMgr_TypeOfPresentation3d theTypeOfPresentation) PrsMgr_TypeOfPresentation3d theTypeOfPresentation)
: Prs3d_Presentation (theStructManager), : Prs3d_Presentation (theStructManager),
myPresentation3d (thePrs) myPresentation3d (thePrs)
{ {

View File

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

View File

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

View File

@ -18,8 +18,6 @@
#define _SelectMgr_SelectableObject_HeaderFile #define _SelectMgr_SelectableObject_HeaderFile
#include <PrsMgr_PresentableObject.hxx> #include <PrsMgr_PresentableObject.hxx>
#include <PrsMgr_PresentationManager3d.hxx>
#include <PrsMgr_TypeOfPresentation3d.hxx>
#include <SelectMgr_IndexedMapOfOwner.hxx> #include <SelectMgr_IndexedMapOfOwner.hxx>
#include <SelectMgr_SequenceOfSelection.hxx> #include <SelectMgr_SequenceOfSelection.hxx>
#include <SelectMgr_Selection.hxx> #include <SelectMgr_Selection.hxx>
@ -30,15 +28,20 @@ class Prs3d_Presentation;
class Standard_NotImplemented; class Standard_NotImplemented;
class SelectMgr_SelectionManager; class SelectMgr_SelectionManager;
//! A framework to supply the structure of the object to be //! A framework to supply the structure of the object to be selected.
//! selected. At the first pick, this structure is created by //! At the first pick, this structure is created by calling the appropriate algorithm and retaining this framework for further picking.
//! calling the appropriate algorithm and retaining this //! This abstract framework is inherited in Application Interactive Services (AIS), notably in AIS_InteractiveObject.
//! framework for further picking. //! Consequently, 3D selection should be handled by the relevant daughter classes and their member functions in AIS.
//! This abstract framework is inherited in Application //! This is particularly true in the creation of new interactive objects.
//! Interactive Services (AIS), notably in AIS_InteractiveObject. //!
//! Consequently, 3D selection should be handled by the //! Key interface methods to be implemented by every Selectable Object:
//! relevant daughter classes and their member functions //! * Presentable Object (PrsMgr_PresentableObject)
//! in AIS. This is particularly true in the creation of new interactive objects. //! 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 class SelectMgr_SelectableObject : public PrsMgr_PresentableObject
{ {
DEFINE_STANDARD_RTTIEXT(SelectMgr_SelectableObject, PrsMgr_PresentableObject) DEFINE_STANDARD_RTTIEXT(SelectMgr_SelectableObject, PrsMgr_PresentableObject)
@ -48,15 +51,15 @@ public:
//! Clears all selections of the object //! Clears all selections of the object
Standard_EXPORT virtual ~SelectMgr_SelectableObject(); Standard_EXPORT virtual ~SelectMgr_SelectableObject();
//! Recovers and calculates any sensitive primitive, //! Computes sensitive primitives for the given selection mode - key interface method of Selectable Object.
//! aSelection, available in Shape mode, specified by //! @param theSelection selection to fill
//! aMode. As a rule, these are sensitive faces. //! @param theMode selection mode to create sensitive primitives
//! This method is defined as virtual. This enables you to virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
//! implement it in the creation of a new class of AIS const Standard_Integer theMode) = 0;
//! Interactive Object. You need to do this and in so
//! doing, redefine this method, if you create a class //! Informs the graphic context that the interactive Object may be decomposed into sub-shapes for dynamic selection.
//! which enriches the list of signatures and types. //! The most used Interactive Object is AIS_Shape.
Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& aSelection, const Standard_Integer aMode) = 0; virtual Standard_Boolean AcceptShapeDecomposition() const { return Standard_False; }
//! Re-computes the sensitive primitives for all modes. IMPORTANT: Do not use //! 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 to update selection primitives except implementing custom selection manager!
@ -91,6 +94,84 @@ public:
//! Return the sequence of selections. //! Return the sequence of selections.
const SelectMgr_SequenceOfSelection& Selections() const { return myselections; } 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. //! Begins the iteration scanning for sensitive primitives.
Standard_DEPRECATED("Deprecated method, Selections() should be used instead") Standard_DEPRECATED("Deprecated method, Selections() should be used instead")
void Init() { mycurrent = 1; } void Init() { mycurrent = 1; }
@ -107,92 +188,12 @@ public:
Standard_DEPRECATED("Deprecated method, Selections() should be used instead") Standard_DEPRECATED("Deprecated method, Selections() should be used instead")
const Handle(SelectMgr_Selection)& CurrentSelection() const { return myselections (mycurrent); } 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:
//! Protected empty constructor.
Standard_EXPORT SelectMgr_SelectableObject(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d = PrsMgr_TOP_AllView); Standard_EXPORT SelectMgr_SelectableObject(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d = PrsMgr_TOP_AllView);
//! Override global selection mode.
void setGlobalSelMode (const Standard_Integer theMode) void setGlobalSelMode (const Standard_Integer theMode)
{ {
myGlobalSelMode = theMode > 0 ? theMode : 0; myGlobalSelMode = theMode > 0 ? theMode : 0;
@ -201,19 +202,18 @@ protected:
//! Update clipping planes state. //! Update clipping planes state.
Standard_EXPORT virtual void UpdateClipping() Standard_OVERRIDE; 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); Standard_EXPORT virtual void updateSelection (const Standard_Integer theMode);
protected: protected:
SelectMgr_SequenceOfSelection myselections; SelectMgr_SequenceOfSelection myselections; //!< list of selections
Handle(Prs3d_Presentation) mySelectionPrs; Handle(Prs3d_Presentation) mySelectionPrs; //!< optional presentation for highlighting selected object
Handle(Prs3d_Presentation) myHilightPrs; Handle(Prs3d_Presentation) myHilightPrs; //!< optional presentation for highlighting detected object
Standard_Boolean myAutoHilight; Standard_Integer myGlobalSelMode; //!< global selection mode
Standard_Integer mycurrent; //!< [deprecated] iterator value
private: Standard_Boolean myAutoHilight; //!< auto-highlighting flag defining
Standard_Integer mycurrent;
Standard_Integer myGlobalSelMode;
}; };