0027860: Visualization - clean up Transformation Persistence API
[occt.git] / src / AIS / AIS_ConnectedInteractive.hxx
CommitLineData
42cf5bc1 1// Created on: 1997-01-08
2// Created by: Robert COUBLANC
3// Copyright (c) 1997-1999 Matra Datavision
4// Copyright (c) 1999-2014 OPEN CASCADE SAS
5//
6// This file is part of Open CASCADE Technology software library.
7//
8// This library is free software; you can redistribute it and/or modify it under
9// the terms of the GNU Lesser General Public License version 2.1 as published
10// by the Free Software Foundation, with special exception defined in the file
11// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12// distribution for complete text of the license and disclaimer of any warranty.
13//
14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
16
17#ifndef _AIS_ConnectedInteractive_HeaderFile
18#define _AIS_ConnectedInteractive_HeaderFile
19
20#include <Standard.hxx>
21#include <Standard_Type.hxx>
22
23#include <TopoDS_Shape.hxx>
24#include <AIS_InteractiveObject.hxx>
25#include <PrsMgr_TypeOfPresentation3d.hxx>
26#include <AIS_KindOfInteractive.hxx>
27#include <Standard_Integer.hxx>
28#include <Standard_Boolean.hxx>
29#include <PrsMgr_PresentationManager3d.hxx>
30#include <SelectMgr_Selection.hxx>
31class AIS_InteractiveObject;
32class Standard_NotImplemented;
33class gp_Trsf;
34class Prs3d_Presentation;
35class Prs3d_Projector;
36class Geom_Transformation;
37class TopoDS_Shape;
38
39
40class AIS_ConnectedInteractive;
41DEFINE_STANDARD_HANDLE(AIS_ConnectedInteractive, AIS_InteractiveObject)
42
43//! Creates an arbitrary located instance of another Interactive Object,
44//! which serves as a reference.
45//! This allows you to use the Connected Interactive
46//! Object without having to recalculate presentation,
47//! selection or graphic structure. These are deduced
48//! from your reference object.
49//! The relation between the connected interactive object
50//! and its source is generally one of geometric transformation.
51//! AIS_ConnectedInteractive class supports selection mode 0 for any InteractiveObject and
52//! all standard modes if its reference based on AIS_Shape.
53//! Descendants may redefine ComputeSelection() though.
54//! Also ConnectedInteractive will handle HLR if its reference based on AIS_Shape.
55class AIS_ConnectedInteractive : public AIS_InteractiveObject
56{
57
58public:
59
42cf5bc1 60 //! Disconnects the previous view and sets highlight
61 //! mode to 0. This highlights the wireframe presentation
62 //! aTypeOfPresentation3d.
63 //! Top_AllView deactivates hidden line removal.
64 Standard_EXPORT AIS_ConnectedInteractive(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d = PrsMgr_TOP_AllView);
65
66 //! Returns KOI_Object
60adbe67 67 virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE { return AIS_KOI_Object; }
68
69 //! Returns 0
70 virtual Standard_Integer Signature() const Standard_OVERRIDE { return 0; }
42cf5bc1 71
72 //! Establishes the connection between the Connected
73 //! Interactive Object, anotherIobj, and its reference.
74 Standard_EXPORT virtual void Connect (const Handle(AIS_InteractiveObject)& anotherIObj);
60adbe67 75
42cf5bc1 76 //! Establishes the connection between the Connected
77 //! Interactive Object, anotherIobj, and its reference.
78 //! Locates instance in aLocation.
79 Standard_EXPORT virtual void Connect (const Handle(AIS_InteractiveObject)& anotherIobj, const gp_Trsf& aLocation);
42cf5bc1 80
81 //! Returns true if there is a connection established
82 //! between the presentation and its source reference.
60adbe67 83 Standard_Boolean HasConnection() const { return !myReference.IsNull(); }
42cf5bc1 84
85 //! Returns the connection with the reference Interactive Object.
60adbe67 86 const Handle(AIS_InteractiveObject)& ConnectedTo() const { return myReference; }
87
42cf5bc1 88 //! Clears the connection with a source reference. The
89 //! presentation will no longer be displayed.
90 //! Warning Must be done before deleting the presentation.
91 Standard_EXPORT void Disconnect();
60adbe67 92
42cf5bc1 93 //! Informs the graphic context that the interactive Object
94 //! may be decomposed into sub-shapes for dynamic selection.
60adbe67 95 virtual Standard_Boolean AcceptShapeDecomposition() const Standard_OVERRIDE
96 {
97 return !myReference.IsNull() && myReference->AcceptShapeDecomposition();
98 }
99
100 //! Return true if reference presentation accepts specified display mode.
101 virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE
102 {
103 return myReference.IsNull()
104 || myReference->AcceptDisplayMode (theMode);
105 }
42cf5bc1 106
92efcf78 107 DEFINE_STANDARD_RTTIEXT(AIS_ConnectedInteractive,AIS_InteractiveObject)
42cf5bc1 108
109protected:
110
42cf5bc1 111 //! Calculates the view aPresentation and its updates.
112 //! The latter are managed by aPresentationManager.
113 //! The display mode aMode is 0 by default.
114 //! this method is redefined virtual;
115 //! when the instance is connected to another
116 //! InteractiveObject,this method doesn't
117 //! compute anything, but just uses the
118 //! presentation of this last object, with
119 //! a transformation if there's one stored.
60adbe67 120 Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, const Handle(Prs3d_Presentation)& aPresentation, const Standard_Integer aMode) Standard_OVERRIDE;
121
42cf5bc1 122 //! Computes the presentation according to a point of view
123 //! given by <aProjector>.
124 //! To be Used when the associated degenerated Presentations
125 //! have been transformed by <aTrsf> which is not a Pure
126 //! Translation. The HLR Prs can't be deducted automatically
127 //! WARNING :<aTrsf> must be applied
128 //! to the object to display before computation !!!
129 Standard_EXPORT virtual void Compute (const Handle(Prs3d_Projector)& aProjector, const Handle(Geom_Transformation)& aTrsf, const Handle(Prs3d_Presentation)& aPresentation) Standard_OVERRIDE;
60adbe67 130
42cf5bc1 131 //! Computes the presentation according to a point of view
132 //! given by <aProjector>.
133 Standard_EXPORT virtual void Compute (const Handle(Prs3d_Projector)& aProjector, const Handle(Prs3d_Presentation)& aPresentation) Standard_OVERRIDE;
60adbe67 134
42cf5bc1 135 //! Generates sensitive entities by copying
136 //! them from myReference selection, creates and sets an entity
137 //! owner for this entities and adds them to theSelection
138 Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection, const Standard_Integer theMode) Standard_OVERRIDE;
60adbe67 139
42cf5bc1 140 //! Generates sensitive entities by copying
141 //! them from myReference sub shapes selection, creates and sets an entity
142 //! owner for this entities and adds them to theSelection
143 Standard_EXPORT void computeSubShapeSelection (const Handle(SelectMgr_Selection)& theSelection, const Standard_Integer theMode);
60adbe67 144
42cf5bc1 145 Standard_EXPORT void updateShape (const Standard_Boolean WithLocation = Standard_True);
60adbe67 146
42cf5bc1 147 //! Computes the presentation according to a point of view
148 //! given by <aProjector>.
149 Standard_EXPORT void Compute (const Handle(Prs3d_Projector)& aProjector, const Handle(Prs3d_Presentation)& aPresentation, const TopoDS_Shape& aShape);
150
60adbe67 151protected:
42cf5bc1 152
60adbe67 153 Handle(AIS_InteractiveObject) myReference;
154 TopoDS_Shape myShape;
42cf5bc1 155
156};
157
42cf5bc1 158#endif // _AIS_ConnectedInteractive_HeaderFile