X-Git-Url: http://git.dev.opencascade.org/gitweb/?p=occt.git;a=blobdiff_plain;f=src%2FAIS%2FAIS_InteractiveObject.hxx;h=17f7b07530686c89946016d8c19de6ab8472ed2f;hp=3719cd0474466b57860013b61fe776f258062bcc;hb=87432b82788a53706060abffdb4591d1f0757822;hpb=c3282ec17059ca78d3a85a74db5bfce2125566e2 diff --git a/src/AIS/AIS_InteractiveObject.hxx b/src/AIS/AIS_InteractiveObject.hxx index 3719cd0474..17f7b07530 100644 --- a/src/AIS/AIS_InteractiveObject.hxx +++ b/src/AIS/AIS_InteractiveObject.hxx @@ -17,36 +17,21 @@ #ifndef _AIS_InteractiveObject_HeaderFile #define _AIS_InteractiveObject_HeaderFile -#include -#include - -#include -#include -#include -#include -#include -#include -#include #include -#include -#include -#include #include -#include -#include -class Standard_Transient; +#include +#include +#include +#include +#include +#include + class AIS_InteractiveContext; -class Quantity_Color; class Graphic3d_MaterialAspect; class Prs3d_Presentation; class Prs3d_BasicAspect; class Bnd_Box; - -class AIS_InteractiveObject; -DEFINE_STANDARD_HANDLE(AIS_InteractiveObject, SelectMgr_SelectableObject) - - //! Defines a class of objects with display and selection services. //! Entities which are visualized and selected are //! Interactive Objects. You can make use of classes of @@ -74,11 +59,10 @@ DEFINE_STANDARD_HANDLE(AIS_InteractiveObject, SelectMgr_SelectableObject) //! affect the same attributes in the Drawer. class AIS_InteractiveObject : public SelectMgr_SelectableObject { - + friend class AIS_InteractiveContext; + DEFINE_STANDARD_RTTIEXT(AIS_InteractiveObject, SelectMgr_SelectableObject) public: - - //! Returns the kind of Interactive Object: //! - None //! - Datum @@ -125,8 +109,8 @@ public: //! Mode 2 : Selection Of Edges //! Mode 3 : Selection Of Wires //! Mode 4 : Selection Of Faces ... - virtual Standard_Boolean AcceptShapeDecomposition() const; - + 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 @@ -135,17 +119,12 @@ public: //! Returns the current facing model which is in effect. Standard_EXPORT Aspect_TypeOfFacingModel CurrentFacingModel() const; - - Standard_EXPORT virtual void SetColor (const Quantity_Color& aColor); - - //! only the interactive obj knowns which Drawer attribute - //! is affected by the color (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 myOwnColor) - Standard_EXPORT virtual void SetColor (const Quantity_NameOfColor aColor); - + + //! 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 @@ -185,17 +164,15 @@ public: //! 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; - - //! Indicates whether the Interactive Object has a pointer - //! to an interactive context. - Standard_EXPORT Standard_Boolean HasInteractiveContext() const; - + Standard_Boolean IsInfinite() const { return myInfiniteState; } + + //! Indicates whether the Interactive Object has a pointer to an interactive context. + Standard_Boolean HasInteractiveContext() const { return myCTXPtr != NULL; } + //! Returns the context pointer to the interactive context. Standard_EXPORT Handle(AIS_InteractiveContext) GetContext() const; @@ -218,32 +195,23 @@ public: //! edges, wires, and faces. //! - Users, presentable objects connecting to sensitive //! primitives, or a shape which has been decomposed. - const Handle(Standard_Transient)& GetOwner() const; - - //! Allows you to attribute the owner ApplicativeEntity to + const Handle(Standard_Transient)& GetOwner() const { return myOwner; } + + //! Allows you to attribute the owner theApplicativeEntity to //! an Interactive Object. This can be a shape for a set of //! sub-shapes or a sub-shape for sub-shapes which it //! is composed of. The owner takes the form of a transient. - void SetOwner (const Handle(Standard_Transient)& ApplicativeEntity); - + void SetOwner (const Handle(Standard_Transient)& theApplicativeEntity) { myOwner = theApplicativeEntity; } + //! Each Interactive Object has methods which allow us //! to attribute an Owner to it in the form of a Transient. //! This method removes the owner from the graphic entity. Standard_EXPORT void ClearOwner(); - - Standard_EXPORT Standard_Boolean HasUsers() const; - - const TColStd_ListOfTransient& Users() const; - - Standard_EXPORT void AddUser (const Handle(Standard_Transient)& aUser); - - Standard_EXPORT void ClearUsers(); - //! Returns true if the Interactive Object has a display //! mode setting. Otherwise, it is displayed in Neutral Point. - Standard_Boolean HasDisplayMode() const; - + Standard_Boolean HasDisplayMode() const { return myDrawer->DisplayMode() != -1; } + //! Sets the display mode aMode for the interactive object. //! An object can have its own temporary display mode, //! which is different from that proposed by the interactive context. @@ -252,108 +220,77 @@ public: //! - 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. - void UnsetDisplayMode(); - + 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; - - //! Returns the selection priority setting. -1 indicates that there is none. - //! You can modify the selection priority of an owner to - //! make one entity more selectionable than another one. - //! The default selection priority for an owner is 5, for - //! example. To increase selection priority, choose a - //! setting between 5 and 10. An entity with priority 7 will - //! take priority over one with a setting of 6 if both - //! objects are selected at the same time. - //! You could give vertices priority 8, edges priority 7, - //! faces priority 6, and shapes priority 5. If a vertex, an - //! edge and a face are simultaneously detected during - //! selection, only the vertex will then be highlighted. - //! For trihedra, for example, the default priorities are the following four: - //! - priority 1 - a trihedron - //! - priority 5 - its origin - //! - priority 3 - its axes - //! - priority 2 - its planes - Standard_Integer SelectionPriority() const; - - //! Allows you to provide a setting aPriority for selection priority. - //! You can modify selection priority of an owner to make - //! one entity more selectionable than another one. The - //! default selection priority for an owner is 5, for - //! example. To increase selection priority, choose a - //! setting between 5 and 10. An entity with priority 7 will - //! take priority over one with a setting of 6. - void SetSelectionPriority (const Standard_Integer aPriority); - - //! Removes the setting for selection priority. SelectionPriority then returns -1. - void UnsetSelectionPriority(); - - //! Returns true if there is a setting for selection priority. - //! You can modify selection priority of an owner to make - //! one entity more selectionable than another one. The - //! default selection priority for an owner is 5, for - //! example. To increase selection priority, choose a - //! setting between 5 and 10. An entity with priority 7 will - //! take priority over one with a setting of 6. - Standard_Boolean HasSelectionPriority() const; - + Standard_Integer DisplayMode() const { return myDrawer->DisplayMode(); } + //! Returns true if the Interactive Object is in highlight mode. - Standard_Boolean HasHilightMode() const; - - //! Returns the setting for highlight mode. - //! At dynamic detection, the presentation echoed by the - //! Interactive Context, is by default the presentation - //! already on the screen. You can specify a Highlight - //! presentation mode which is valid no matter what the - //! active representation of the object. It makes no - //! difference whether this choice is temporary or - //! definitive. To do this, we use the following functions: - //! - SetHilightMode - //! - UnSetHilightMode - //! In the case of a shape, whether it is visualized in - //! wireframe presentation or with shading, we want to - //! systematically highlight the wireframe presentation. - //! Consequently, we set the highlight mode to 0. - Standard_Integer HilightMode() const; - - //! Sets the highlight mode anIndex for the interactive object. - //! If, for example, you want to systematically highlight - //! the wireframe presentation of a shape - whether - //! visualized in wireframe presentation or with shading - - //! you set the highlight mode to 0. - void SetHilightMode (const Standard_Integer anIndex); - - //! Allows the user to take a given Prs for hilight - //! ex : for a shape which would be displayed in shading mode - //! the hilight Prs is the wireframe mode. - //! if No specific hilight mode is defined, the displayed Prs - //! will be the hilighted one. - void UnsetHilightMode(); - + 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; - + Standard_Boolean HasColor() const { return hasOwnColor; } + //! Returns the color setting of the Interactive Object. - virtual Quantity_NameOfColor Color() const; - - virtual void Color (Quantity_Color& aColor) const; - + virtual void Color (Quantity_Color& theColor) const { theColor = myDrawer->Color(); } + //! Returns true if the Interactive Object has width. - Standard_Boolean HasWidth() const; - + Standard_Boolean HasWidth() const { return myOwnWidth != 0.0; } + //! Returns the width setting of the Interactive Object. - Standard_EXPORT Standard_Real Width() const; - + Standard_Real Width() const { return myOwnWidth; } + //! Returns true if the Interactive Object has a setting for material. - Standard_EXPORT Standard_Boolean HasMaterial() const; - + Standard_Boolean HasMaterial() const { return hasOwnMaterial; } + //! Returns the current material setting. //! This will be on of the following materials: //! - Brass @@ -363,13 +300,7 @@ public: //! - Silver //! - Stone. Standard_EXPORT virtual Graphic3d_NameOfMaterial Material() const; - - //! Sets the name aName for material 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_NameOfMaterial aName); - + //! Sets the material aMat defining this display attribute //! for the interactive object. //! Material aspect determines shading aspect, color and @@ -386,8 +317,8 @@ public: Standard_EXPORT virtual void SetTransparency (const Standard_Real aValue = 0.6); //! Returns true if there is a transparency setting. - Standard_Boolean IsTransparent() const; - + 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. @@ -398,11 +329,7 @@ public: //! Clears settings provided by the drawing tool aDrawer. Standard_EXPORT virtual void UnsetAttributes() Standard_OVERRIDE; - - void State (const Standard_Integer theState); - - Standard_Integer State() const; - + //! Returns TRUE when this object has a presentation //! in the current DisplayMode() Standard_EXPORT Standard_Boolean HasPresentation() const; @@ -410,13 +337,9 @@ public: //! Returns the current presentation of this object //! according to the current DisplayMode() Standard_EXPORT Handle(Prs3d_Presentation) Presentation() const; - + //! Sets the graphic basic aspect to the current presentation. - //! When is TRUE , the full object presentation - //! is changed. - //! When is FALSE , only the current group - //! of the object presentation is changed. - Standard_EXPORT void SetAspect (const Handle(Prs3d_BasicAspect)& anAspect, const Standard_Boolean globalChange = Standard_True); + Standard_EXPORT void SetAspect (const Handle(Prs3d_BasicAspect)& anAspect); //! Sets up polygon offsets for this object. //! It modifies all existing presentations of (if any), @@ -454,58 +377,48 @@ public: //! 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); -friend class AIS_InteractiveContext; + //! 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(); +private: - DEFINE_STANDARD_RTTI(AIS_InteractiveObject,SelectMgr_SelectableObject) + Standard_EXPORT virtual Standard_Boolean RecomputeEveryPrs() const; + + Standard_EXPORT void MustRecomputePrs (const Standard_Integer aMode) const; + + Standard_EXPORT const TColStd_ListOfInteger& ListOfRecomputeModes() const; + + Standard_EXPORT void SetRecomputeOk(); protected: - //! The TypeOfPresention3d means that the interactive object //! may have a presentation dependant of the view of Display. Standard_EXPORT AIS_InteractiveObject(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d = PrsMgr_TOP_AllView); - Standard_Real myTransparency; - Quantity_Color myOwnColor; - Graphic3d_NameOfMaterial myOwnMaterial; - Standard_Integer myHilightMode; +private: + + AIS_InteractiveContext* myCTXPtr; + Handle(Standard_Transient) myOwner; + +protected: + + TColStd_ListOfInteger myToRecomputeModes; Standard_Real myOwnWidth; + Aspect_TypeOfFacingModel myCurrentFacingModel; Standard_Boolean myInfiniteState; Standard_Boolean hasOwnColor; Standard_Boolean hasOwnMaterial; - Aspect_TypeOfFacingModel myCurrentFacingModel; Standard_Boolean myRecomputeEveryPrs; - TColStd_ListOfInteger myToRecomputeModes; - - -private: - - - Standard_EXPORT virtual Standard_Boolean RecomputeEveryPrs() const; - - Standard_EXPORT void MustRecomputePrs (const Standard_Integer aMode) const; - - Standard_EXPORT const TColStd_ListOfInteger& ListOfRecomputeModes() const; - - Standard_EXPORT void SetRecomputeOk(); - - AIS_PToContext myCTXPtr; - Handle(Standard_Transient) myOwner; - TColStd_ListOfTransient myUsers; - Standard_Integer mySelPriority; - Standard_Integer myDisplayMode; - Standard_Integer mystate; - }; - -#include - - - - +DEFINE_STANDARD_HANDLE(AIS_InteractiveObject, SelectMgr_SelectableObject) #endif // _AIS_InteractiveObject_HeaderFile