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