Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 10:20:38

0001 // Created on: 1996-12-11
0002 // Created by: Robert COUBLANC
0003 // Copyright (c) 1996-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _AIS_InteractiveObject_HeaderFile
0018 #define _AIS_InteractiveObject_HeaderFile
0019 
0020 #include <AIS_KindOfInteractive.hxx>
0021 #include <AIS_DragAction.hxx>
0022 #include <SelectMgr_SelectableObject.hxx>
0023 
0024 class AIS_InteractiveContext;
0025 class Prs3d_BasicAspect;
0026 class V3d_View;
0027 
0028 //! Defines a class of objects with display and selection services.
0029 //! Entities which are visualized and selected are Interactive Objects.
0030 //! Specific attributes of entities such as arrow aspect for dimensions must be loaded in a Prs3d_Drawer.
0031 //!
0032 //! You can make use of classes of standard Interactive Objects for which all necessary methods have already been programmed,
0033 //! or you can implement your own classes of Interactive Objects.
0034 //! Key interface methods to be implemented by every Interactive Object:
0035 //! * Presentable Object (PrsMgr_PresentableObject)
0036 //!   Consider defining an enumeration of supported Display Mode indexes for particular Interactive Object or class of Interactive Objects.
0037 //!   - AcceptDisplayMode() accepting display modes implemented by this object;
0038 //!   - Compute() computing presentation for the given display mode index;
0039 //! * Selectable Object (SelectMgr_SelectableObject)
0040 //!   Consider defining an enumeration of supported Selection Mode indexes for particular Interactive Object or class of Interactive Objects.
0041 //!   - ComputeSelection() computing selectable entities for the given selection mode index.
0042 class AIS_InteractiveObject : public SelectMgr_SelectableObject
0043 {
0044   friend class AIS_InteractiveContext;
0045   DEFINE_STANDARD_RTTIEXT(AIS_InteractiveObject, SelectMgr_SelectableObject)
0046 public:
0047 
0048   //! Returns the kind of Interactive Object; AIS_KindOfInteractive_None by default.
0049   virtual AIS_KindOfInteractive Type() const { return AIS_KindOfInteractive_None; }
0050 
0051   //! Specifies additional characteristics of Interactive Object of Type(); -1 by default.
0052   //! Among the datums, this signature is attributed to the shape.
0053   //! The remaining datums have the following default signatures:
0054   //! - Point          signature 1
0055   //! - Axis           signature 2
0056   //! - Trihedron      signature 3
0057   //! - PlaneTrihedron signature 4
0058   //! - Line           signature 5
0059   //! - Circle         signature 6
0060   //! - Plane          signature 7.
0061   virtual Standard_Integer Signature() const { return -1; }
0062   
0063   //! Updates the active presentation; if <AllModes> = Standard_True
0064   //! all the presentations inside are recomputed.
0065   //! IMPORTANT: It is preferable to call Redisplay method of
0066   //! corresponding AIS_InteractiveContext instance for cases when it
0067   //! is accessible. This method just redirects call to myCTXPtr,
0068   //! so this class field must be up to date for proper result.
0069   Standard_EXPORT void Redisplay (const Standard_Boolean AllModes = Standard_False);
0070 
0071   //! Indicates whether the Interactive Object has a pointer to an interactive context.
0072   Standard_Boolean HasInteractiveContext() const { return myCTXPtr != NULL; }
0073 
0074   //! Returns the context pointer to the interactive context.
0075   AIS_InteractiveContext* InteractiveContext() const { return myCTXPtr; }
0076   
0077   //! Sets the interactive context aCtx and provides a link
0078   //! to the default drawing tool or "Drawer" if there is none.
0079   Standard_EXPORT virtual void SetContext (const Handle(AIS_InteractiveContext)& aCtx);
0080   
0081   //! Returns true if the object has an owner attributed to it.
0082   //! 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.
0083   Standard_Boolean HasOwner() const { return !myOwner.IsNull(); }
0084   
0085   //! Returns the owner of the Interactive Object.
0086   //! The owner can be a shape for a set of sub-shapes or
0087   //! a sub-shape for sub-shapes which it is composed of,
0088   //! and takes the form of a transient.
0089   //! There are two types of owners:
0090   //! -   Direct owners, decomposition shapes such as
0091   //! edges, wires, and faces.
0092   //! -   Users, presentable objects connecting to sensitive
0093   //! primitives, or a shape which has been decomposed.
0094   const Handle(Standard_Transient)& GetOwner() const { return myOwner; }
0095 
0096   //! Allows you to attribute the owner theApplicativeEntity to
0097   //! an Interactive Object. This can be a shape for a set of
0098   //! sub-shapes or a sub-shape for sub-shapes which it
0099   //! is composed of. The owner takes the form of a transient.
0100   void SetOwner (const Handle(Standard_Transient)& theApplicativeEntity) { myOwner = theApplicativeEntity; }
0101 
0102   //! Each Interactive Object has methods which allow us to attribute an Owner to it in the form of a Transient.
0103   //! This method removes the owner from the graphic entity.
0104   void ClearOwner() { myOwner.Nullify(); }
0105 
0106   //! Drag object in the viewer.
0107   //! @param theCtx      [in] interactive context
0108   //! @param theView     [in] active View
0109   //! @param theOwner    [in] the owner of detected entity
0110   //! @param theDragFrom [in] drag start point
0111   //! @param theDragTo   [in] drag end point
0112   //! @param theAction   [in] drag action
0113   //! @return FALSE if object rejects dragging action (e.g. AIS_DragAction_Start)
0114   Standard_EXPORT virtual Standard_Boolean ProcessDragging (const Handle(AIS_InteractiveContext)& theCtx,
0115                                                             const Handle(V3d_View)& theView,
0116                                                             const Handle(SelectMgr_EntityOwner)& theOwner,
0117                                                             const Graphic3d_Vec2i& theDragFrom,
0118                                                             const Graphic3d_Vec2i& theDragTo,
0119                                                             const AIS_DragAction theAction);
0120 
0121 public:
0122 
0123   //! Returns the context pointer to the interactive context.
0124   Standard_EXPORT Handle(AIS_InteractiveContext) GetContext() const;
0125 
0126   //! Returns TRUE when this object has a presentation in the current DisplayMode()
0127   Standard_EXPORT Standard_Boolean HasPresentation() const;
0128 
0129   //! Returns the current presentation of this object according to the current DisplayMode()
0130   Standard_EXPORT Handle(Prs3d_Presentation) Presentation() const;
0131 
0132   //! Sets the graphic basic aspect to the current presentation.
0133   Standard_DEPRECATED("Deprecated method, results might be undefined")
0134   Standard_EXPORT void SetAspect (const Handle(Prs3d_BasicAspect)& anAspect);
0135 
0136   //! Dumps the content of me into the stream
0137   Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
0138 protected:
0139 
0140   //! The TypeOfPresention3d means that the interactive object
0141   //! may have a presentation dependent on the view of Display.
0142   Standard_EXPORT AIS_InteractiveObject(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d = PrsMgr_TOP_AllView);
0143 
0144   //! Set presentation display status.
0145   Standard_EXPORT void SetDisplayStatus (PrsMgr_DisplayStatus theStatus);
0146 
0147 protected:
0148 
0149   AIS_InteractiveContext*    myCTXPtr; //!< pointer to Interactive Context, where object is currently displayed; @sa SetContext()
0150   Handle(Standard_Transient) myOwner;  //!< application-specific owner object
0151 
0152 };
0153 
0154 DEFINE_STANDARD_HANDLE(AIS_InteractiveObject, SelectMgr_SelectableObject)
0155 
0156 #endif // _AIS_InteractiveObject_HeaderFile