b311480e |
1 | // Created on: 1996-12-18 |
2 | // Created by: Robert COUBLANC |
3 | // Copyright (c) 1996-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
7fd59977 |
16 | |
f838dac4 |
17 | #include <AIS_InteractiveObject.hxx> |
7fd59977 |
18 | |
42cf5bc1 |
19 | #include <AIS_InteractiveContext.hxx> |
f751596e |
20 | #include <Graphic3d_CStructure.hxx> |
7fd59977 |
21 | #include <Graphic3d_Group.hxx> |
22 | #include <Graphic3d_Structure.hxx> |
42cf5bc1 |
23 | #include <Prs3d_LineAspect.hxx> |
24 | #include <Prs3d_PointAspect.hxx> |
25 | #include <Prs3d_Presentation.hxx> |
42cf5bc1 |
26 | #include <Prs3d_ShadingAspect.hxx> |
27 | #include <Prs3d_TextAspect.hxx> |
2b886265 |
28 | #include <PrsMgr_PresentationManager.hxx> |
7fd59977 |
29 | |
92efcf78 |
30 | IMPLEMENT_STANDARD_RTTIEXT(AIS_InteractiveObject,SelectMgr_SelectableObject) |
31 | |
7fd59977 |
32 | //======================================================================= |
33 | //function : AIS_InteractiveObject |
34 | //purpose : |
35 | //======================================================================= |
f838dac4 |
36 | AIS_InteractiveObject::AIS_InteractiveObject (const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d) |
37 | : SelectMgr_SelectableObject (aTypeOfPresentation3d), |
2b886265 |
38 | myCTXPtr (NULL) |
7fd59977 |
39 | { |
2b886265 |
40 | // |
7fd59977 |
41 | } |
42 | |
43 | //======================================================================= |
44 | //function : Redisplay |
36132a2e |
45 | //purpose : |
7fd59977 |
46 | //======================================================================= |
36132a2e |
47 | void AIS_InteractiveObject::Redisplay (const Standard_Boolean AllModes) |
7fd59977 |
48 | { |
36132a2e |
49 | if (myCTXPtr == NULL) |
50 | return; |
51 | |
52 | myCTXPtr->Redisplay (this, Standard_False, AllModes); |
7fd59977 |
53 | } |
54 | |
630ab538 |
55 | //======================================================================= |
56 | //function : ProcessDragging |
57 | //purpose : |
58 | //======================================================================= |
59 | Standard_Boolean AIS_InteractiveObject::ProcessDragging (const Handle(AIS_InteractiveContext)&, |
60 | const Handle(V3d_View)&, |
61 | const Handle(SelectMgr_EntityOwner)&, |
62 | const Graphic3d_Vec2i&, |
63 | const Graphic3d_Vec2i&, |
64 | const AIS_DragAction) |
65 | { |
66 | return Standard_False; |
67 | } |
68 | |
7fd59977 |
69 | //======================================================================= |
70 | //function : |
71 | //purpose : |
72 | //======================================================================= |
73 | Handle(AIS_InteractiveContext) AIS_InteractiveObject::GetContext() const |
74 | { |
75 | return myCTXPtr; |
76 | } |
77 | |
78 | //======================================================================= |
2ec85268 |
79 | //function : SetContext |
80 | //purpose : |
7fd59977 |
81 | //======================================================================= |
2ec85268 |
82 | void AIS_InteractiveObject::SetContext (const Handle(AIS_InteractiveContext)& theCtx) |
7fd59977 |
83 | { |
2ec85268 |
84 | if (myCTXPtr == theCtx.get()) |
85 | { |
da0e82aa |
86 | return; |
2ec85268 |
87 | } |
88 | |
89 | myCTXPtr = theCtx.get(); |
90 | if (!theCtx.IsNull()) |
91 | { |
92 | myDrawer->Link (theCtx->DefaultDrawer()); |
93 | } |
7fd59977 |
94 | } |
95 | |
39e6123e |
96 | //======================================================================= |
97 | //function : SetDisplayStatus |
98 | //purpose : |
99 | //======================================================================= |
100 | void AIS_InteractiveObject::SetDisplayStatus (PrsMgr_DisplayStatus theStatus) |
101 | { |
102 | myDisplayStatus = theStatus; |
103 | } |
104 | |
7fd59977 |
105 | //======================================================================= |
106 | //function : HasPresentation |
af324faa |
107 | //purpose : |
7fd59977 |
108 | //======================================================================= |
af324faa |
109 | Standard_Boolean AIS_InteractiveObject::HasPresentation() const |
110 | { |
f838dac4 |
111 | return HasInteractiveContext() |
112 | && myCTXPtr->MainPrsMgr()->HasPresentation (this, myDrawer->DisplayMode()); |
7fd59977 |
113 | } |
114 | |
115 | //======================================================================= |
116 | //function : Presentation |
af324faa |
117 | //purpose : |
7fd59977 |
118 | //======================================================================= |
af324faa |
119 | Handle(Prs3d_Presentation) AIS_InteractiveObject::Presentation() const |
120 | { |
f838dac4 |
121 | if (!HasInteractiveContext()) |
122 | { |
123 | return Handle(Prs3d_Presentation)(); |
124 | } |
125 | |
126 | Handle(PrsMgr_Presentation) aPrs = myCTXPtr->MainPrsMgr()->Presentation (this, myDrawer->DisplayMode(), false); |
7dd7c146 |
127 | return aPrs; |
7fd59977 |
128 | } |
129 | |
130 | //======================================================================= |
131 | //function : SetAspect |
132 | //purpose : |
133 | //======================================================================= |
2b886265 |
134 | void AIS_InteractiveObject::SetAspect(const Handle(Prs3d_BasicAspect)& theAspect) |
2831708b |
135 | { |
7fd59977 |
136 | |
2b886265 |
137 | if (!HasPresentation()) |
138 | { |
139 | return; |
7fd59977 |
140 | } |
7fd59977 |
141 | |
2b886265 |
142 | Handle(Prs3d_Presentation) aPrs = Presentation(); |
143 | if (aPrs->Groups().IsEmpty()) |
f751596e |
144 | { |
2b886265 |
145 | return; |
f751596e |
146 | } |
2b886265 |
147 | const Handle(Graphic3d_Group)& aGroup = aPrs->Groups().Last(); |
148 | if (Handle(Prs3d_ShadingAspect) aShadingAspect = Handle(Prs3d_ShadingAspect)::DownCast(theAspect)) |
f751596e |
149 | { |
2b886265 |
150 | aGroup->SetGroupPrimitivesAspect (aShadingAspect->Aspect()); |
f751596e |
151 | } |
2b886265 |
152 | else if (Handle(Prs3d_LineAspect) aLineAspect = Handle(Prs3d_LineAspect)::DownCast(theAspect)) |
fb66bb28 |
153 | { |
2b886265 |
154 | aGroup->SetGroupPrimitivesAspect (aLineAspect->Aspect()); |
fb66bb28 |
155 | } |
2b886265 |
156 | else if (Handle(Prs3d_PointAspect) aPointAspect = Handle(Prs3d_PointAspect)::DownCast(theAspect)) |
bf5f0ca2 |
157 | { |
2b886265 |
158 | aGroup->SetGroupPrimitivesAspect (aPointAspect->Aspect()); |
bf5f0ca2 |
159 | } |
2b886265 |
160 | else if (Handle(Prs3d_TextAspect) aTextAspect = Handle(Prs3d_TextAspect)::DownCast(theAspect)) |
bf5f0ca2 |
161 | { |
2b886265 |
162 | aGroup->SetGroupPrimitivesAspect (aTextAspect->Aspect()); |
bf5f0ca2 |
163 | } |
164 | } |
0904aa63 |
165 | |
166 | //======================================================================= |
167 | //function : DumpJson |
168 | //purpose : |
169 | //======================================================================= |
bc73b006 |
170 | void AIS_InteractiveObject::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const |
0904aa63 |
171 | { |
bc73b006 |
172 | OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream) |
0904aa63 |
173 | |
bc73b006 |
174 | OCCT_DUMP_BASE_CLASS (theOStream, theDepth, SelectMgr_SelectableObject) |
175 | OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myCTXPtr) |
176 | OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myOwner) |
0904aa63 |
177 | } |