0031687: Draw Harness, ViewerTest - extend command vrenderparams with option updating...
[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
42cf5bc1 20#include <AIS_InteractiveObject.hxx>
42cf5bc1 21#include <AIS_KindOfInteractive.hxx>
1f7f5a90 22#include <TopoDS_Shape.hxx>
42cf5bc1 23
24//! Creates an arbitrary located instance of another Interactive Object,
25//! which serves as a reference.
26//! This allows you to use the Connected Interactive
27//! Object without having to recalculate presentation,
28//! selection or graphic structure. These are deduced
29//! from your reference object.
30//! The relation between the connected interactive object
31//! and its source is generally one of geometric transformation.
32//! AIS_ConnectedInteractive class supports selection mode 0 for any InteractiveObject and
33//! all standard modes if its reference based on AIS_Shape.
34//! Descendants may redefine ComputeSelection() though.
35//! Also ConnectedInteractive will handle HLR if its reference based on AIS_Shape.
36class AIS_ConnectedInteractive : public AIS_InteractiveObject
37{
1f7f5a90 38 DEFINE_STANDARD_RTTIEXT(AIS_ConnectedInteractive, AIS_InteractiveObject)
42cf5bc1 39public:
40
42cf5bc1 41 //! Disconnects the previous view and sets highlight
42 //! mode to 0. This highlights the wireframe presentation
43 //! aTypeOfPresentation3d.
44 //! Top_AllView deactivates hidden line removal.
45 Standard_EXPORT AIS_ConnectedInteractive(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d = PrsMgr_TOP_AllView);
46
47 //! Returns KOI_Object
60adbe67 48 virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE { return AIS_KOI_Object; }
49
50 //! Returns 0
51 virtual Standard_Integer Signature() const Standard_OVERRIDE { return 0; }
42cf5bc1 52
53 //! Establishes the connection between the Connected
54 //! Interactive Object, anotherIobj, and its reference.
7f24b768 55 void Connect (const Handle(AIS_InteractiveObject)& theAnotherObj) { connect (theAnotherObj, Handle(TopLoc_Datum3D)()); }
60adbe67 56
42cf5bc1 57 //! Establishes the connection between the Connected
58 //! Interactive Object, anotherIobj, and its reference.
59 //! Locates instance in aLocation.
0f57ab75 60 void Connect (const Handle(AIS_InteractiveObject)& theAnotherObj,
7f24b768 61 const gp_Trsf& theLocation) { connect (theAnotherObj, new TopLoc_Datum3D (theLocation)); }
1f7f5a90 62
63 //! Establishes the connection between the Connected
64 //! Interactive Object, anotherIobj, and its reference.
65 //! Locates instance in aLocation.
0f57ab75 66 void Connect (const Handle(AIS_InteractiveObject)& theAnotherObj,
7f24b768 67 const Handle(TopLoc_Datum3D)& theLocation) { connect (theAnotherObj, theLocation); }
42cf5bc1 68
69 //! Returns true if there is a connection established
70 //! between the presentation and its source reference.
60adbe67 71 Standard_Boolean HasConnection() const { return !myReference.IsNull(); }
42cf5bc1 72
73 //! Returns the connection with the reference Interactive Object.
60adbe67 74 const Handle(AIS_InteractiveObject)& ConnectedTo() const { return myReference; }
75
42cf5bc1 76 //! Clears the connection with a source reference. The
77 //! presentation will no longer be displayed.
78 //! Warning Must be done before deleting the presentation.
79 Standard_EXPORT void Disconnect();
60adbe67 80
42cf5bc1 81 //! Informs the graphic context that the interactive Object
82 //! may be decomposed into sub-shapes for dynamic selection.
60adbe67 83 virtual Standard_Boolean AcceptShapeDecomposition() const Standard_OVERRIDE
84 {
85 return !myReference.IsNull() && myReference->AcceptShapeDecomposition();
86 }
87
88 //! Return true if reference presentation accepts specified display mode.
89 virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE
90 {
91 return myReference.IsNull()
92 || myReference->AcceptDisplayMode (theMode);
93 }
42cf5bc1 94
42cf5bc1 95protected:
96
42cf5bc1 97 //! Calculates the view aPresentation and its updates.
98 //! The latter are managed by aPresentationManager.
99 //! The display mode aMode is 0 by default.
100 //! this method is redefined virtual;
101 //! when the instance is connected to another
102 //! InteractiveObject,this method doesn't
103 //! compute anything, but just uses the
104 //! presentation of this last object, with
105 //! a transformation if there's one stored.
60adbe67 106 Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, const Handle(Prs3d_Presentation)& aPresentation, const Standard_Integer aMode) Standard_OVERRIDE;
107
b5163d2f 108 //! Computes the presentation according to a point of view.
109 Standard_EXPORT virtual void computeHLR (const Handle(Graphic3d_Camera)& theProjector,
7f24b768 110 const Handle(TopLoc_Datum3D)& theTrsf,
b5163d2f 111 const Handle(Prs3d_Presentation)& thePrs) Standard_OVERRIDE;
60adbe67 112
42cf5bc1 113 //! Generates sensitive entities by copying
114 //! them from myReference selection, creates and sets an entity
115 //! owner for this entities and adds them to theSelection
116 Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection, const Standard_Integer theMode) Standard_OVERRIDE;
60adbe67 117
42cf5bc1 118 //! Generates sensitive entities by copying
119 //! them from myReference sub shapes selection, creates and sets an entity
120 //! owner for this entities and adds them to theSelection
121 Standard_EXPORT void computeSubShapeSelection (const Handle(SelectMgr_Selection)& theSelection, const Standard_Integer theMode);
60adbe67 122
42cf5bc1 123 Standard_EXPORT void updateShape (const Standard_Boolean WithLocation = Standard_True);
60adbe67 124
1f7f5a90 125 Standard_EXPORT void connect (const Handle(AIS_InteractiveObject)& theAnotherObj,
7f24b768 126 const Handle(TopLoc_Datum3D)& theLocation);
1f7f5a90 127
60adbe67 128protected:
42cf5bc1 129
60adbe67 130 Handle(AIS_InteractiveObject) myReference;
131 TopoDS_Shape myShape;
42cf5bc1 132
133};
134
1f7f5a90 135DEFINE_STANDARD_HANDLE(AIS_ConnectedInteractive, AIS_InteractiveObject)
136
42cf5bc1 137#endif // _AIS_ConnectedInteractive_HeaderFile