b311480e |
1 | // Created on: 1995-08-09 |
2 | // Created by: Arnaud BOUZY/Odile Olivier |
3 | // Copyright (c) 1995-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 | |
7fd59977 |
17 | #include <AIS_Point.ixx> |
18 | #include <Aspect_TypeOfLine.hxx> |
19 | #include <Prs3d_Drawer.hxx> |
20 | #include <Prs3d_PointAspect.hxx> |
21 | #include <Graphic3d_Structure.hxx> |
22 | #include <Graphic3d_Group.hxx> |
23 | #include <Quantity_Color.hxx> |
a577aaab |
24 | #include <Graphic3d_ArrayOfPoints.hxx> |
7fd59977 |
25 | #include <Graphic3d_AspectMarker3d.hxx> |
26 | #include <SelectMgr_EntityOwner.hxx> |
27 | #include <SelectBasics_EntityOwner.hxx> |
28 | #include <Select3D_SensitivePoint.hxx> |
29 | #include <StdPrs_Point.hxx> |
30 | #include <Geom_Point.hxx> |
31 | #include <BRepBuilderAPI_MakeVertex.hxx> |
32 | #include <AIS_Drawer.hxx> |
33 | |
34 | #include <AIS_InteractiveContext.hxx> |
35 | //======================================================================= |
36 | //function : AIS_Point |
37 | //purpose : |
38 | //======================================================================= |
39 | AIS_Point::AIS_Point(const Handle(Geom_Point)& aComponent): |
40 | myComponent(aComponent), |
41 | myHasTOM(Standard_False), |
42 | myTOM(Aspect_TOM_PLUS) |
43 | { |
44 | myHilightMode=-99; |
45 | } |
46 | |
47 | //======================================================================= |
48 | //function : Component |
49 | //purpose : |
50 | //======================================================================= |
51 | |
52 | Handle(Geom_Point) AIS_Point::Component() |
53 | { |
54 | return myComponent; |
55 | } |
56 | |
57 | //======================================================================= |
58 | //function : SetComponent |
59 | //purpose : |
60 | //======================================================================= |
61 | |
62 | void AIS_Point::SetComponent(const Handle(Geom_Point)& aComponent) |
63 | { |
64 | myComponent = aComponent; |
65 | } |
66 | |
67 | //======================================================================= |
68 | //function : Compute |
69 | //purpose : |
70 | //======================================================================= |
71 | void AIS_Point::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/, |
72 | const Handle(Prs3d_Presentation)& aPresentation, |
73 | const Standard_Integer aMode) |
74 | { |
75 | aPresentation->Clear(); |
76 | |
77 | aPresentation->SetInfiniteState(myInfiniteState); |
78 | |
79 | if (aMode==0) |
80 | StdPrs_Point::Add(aPresentation,myComponent,myDrawer); |
81 | else if (aMode== -99) |
82 | { |
83 | // Beeurk.. a revoir - rob-25/04/97 |
84 | static Handle(Graphic3d_AspectMarker3d) PtA = |
85 | new Graphic3d_AspectMarker3d (); |
86 | PtA->SetType(Aspect_TOM_PLUS); |
87 | PtA->SetScale(3.); |
88 | Handle(Graphic3d_Group) TheGroup = Prs3d_Root::CurrentGroup(aPresentation); |
89 | TheGroup->SetPrimitivesAspect(PtA); |
a577aaab |
90 | Handle(Graphic3d_ArrayOfPoints) aPoint = new Graphic3d_ArrayOfPoints (1); |
91 | aPoint->AddVertex (myComponent->X(),myComponent->Y(),myComponent->Z()); |
92 | TheGroup->AddPrimitiveArray (aPoint); |
7fd59977 |
93 | } |
94 | |
95 | } |
96 | |
97 | //======================================================================= |
98 | //function : Compute |
99 | //purpose : |
100 | //======================================================================= |
101 | |
857ffd5e |
102 | void AIS_Point::Compute(const Handle(Prs3d_Projector)& aProjector, |
103 | const Handle(Geom_Transformation)& aTransformation, |
104 | const Handle(Prs3d_Presentation)& aPresentation) |
7fd59977 |
105 | { |
857ffd5e |
106 | // Standard_NotImplemented::Raise("AIS_Point::Compute(const Handle(Prs3d_Projector)&, const Handle(Geom_Transformation)&, const Handle(Prs3d_Presentation)&)"); |
7fd59977 |
107 | PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation) ; |
108 | } |
109 | |
110 | //======================================================================= |
111 | //function : ComputeSelection |
112 | //purpose : |
113 | //======================================================================= |
114 | void AIS_Point::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection, |
115 | const Standard_Integer /*aMode*/) |
116 | { |
117 | Handle(SelectMgr_EntityOwner) eown = new SelectMgr_EntityOwner(this,10); |
118 | // eown -> SelectBasics_EntityOwner::Set(5); |
119 | Handle(Select3D_SensitivePoint) sp = new Select3D_SensitivePoint(eown, |
120 | myComponent->Pnt()); |
121 | aSelection->Add(sp); |
122 | } |
123 | |
124 | //======================================================================= |
125 | //function : SetColor |
126 | //purpose : |
127 | //======================================================================= |
128 | |
129 | void AIS_Point::SetColor(const Quantity_NameOfColor aCol) |
7fd59977 |
130 | { |
131 | SetColor(Quantity_Color(aCol)); |
132 | } |
133 | |
134 | void AIS_Point::SetColor(const Quantity_Color &aCol) |
7fd59977 |
135 | { |
136 | hasOwnColor=Standard_True; |
137 | myOwnColor=aCol; |
138 | UpdatePointValues(); |
139 | } |
140 | |
141 | //======================================================================= |
142 | //function : UnsetColor |
143 | //purpose : |
144 | //======================================================================= |
145 | void AIS_Point::UnsetColor() |
146 | { |
147 | hasOwnColor=Standard_False; |
148 | UpdatePointValues(); |
149 | } |
150 | |
151 | |
152 | //======================================================================= |
153 | //function : Vertex |
154 | //purpose : |
155 | //======================================================================= |
156 | TopoDS_Vertex AIS_Point::Vertex() const |
157 | { |
158 | gp_Pnt P = myComponent->Pnt(); |
159 | return BRepBuilderAPI_MakeVertex(P); |
160 | } |
161 | |
128cc8df |
162 | |
7fd59977 |
163 | //======================================================================= |
164 | //function : Compute |
165 | //purpose : to avoid warning |
166 | //======================================================================= |
167 | void AIS_Point::Compute(const Handle(Prs3d_Projector)&, |
168 | const Handle(Prs3d_Presentation)&) |
169 | { |
170 | } |
171 | |
172 | //======================================================================= |
173 | //function : SetMarker |
174 | //purpose : |
175 | //======================================================================= |
176 | |
177 | void AIS_Point::SetMarker(const Aspect_TypeOfMarker aTOM) |
178 | { |
179 | myTOM = aTOM; |
180 | myHasTOM = Standard_True; |
181 | UpdatePointValues(); |
182 | } |
183 | |
184 | //======================================================================= |
185 | //function : UnsetMarker |
186 | //purpose : |
187 | //======================================================================= |
188 | void AIS_Point::UnsetMarker() |
189 | { |
190 | myHasTOM = Standard_False; |
191 | UpdatePointValues(); |
192 | } |
193 | |
194 | //======================================================================= |
195 | //function : AcceptDisplayMode |
196 | //purpose : |
197 | //======================================================================= |
198 | |
199 | Standard_Boolean AIS_Point:: |
200 | AcceptDisplayMode(const Standard_Integer aMode) const |
201 | {return aMode == 0;} |
202 | |
203 | |
204 | //======================================================================= |
205 | //function : UpdatePointValues |
206 | //purpose : |
207 | //======================================================================= |
208 | |
209 | void AIS_Point::UpdatePointValues() |
210 | { |
211 | |
212 | if(!hasOwnColor && myOwnWidth==0.0 && !myHasTOM){ |
213 | myDrawer->PointAspect().Nullify(); |
214 | return; |
215 | } |
7fd59977 |
216 | Quantity_Color aCol; |
7fd59977 |
217 | Quantity_Color QCO; |
218 | Aspect_TypeOfMarker aTOM; |
219 | Standard_Real aScale; |
220 | |
221 | if(myDrawer->HasLink()){ |
222 | myDrawer->Link()->PointAspect()->Aspect()->Values(QCO,aTOM,aScale); |
223 | aCol = QCO.Name(); |
224 | } |
225 | else{ |
226 | aCol = Quantity_NOC_YELLOW; |
227 | aTOM = Aspect_TOM_PLUS; |
228 | aScale = 1; |
229 | } |
230 | if(hasOwnColor) aCol = myOwnColor; |
231 | if(myOwnWidth!=0.0) aScale = myOwnWidth; |
232 | if(myHasTOM) aTOM = myTOM; |
233 | |
234 | |
235 | if(myDrawer->HasPointAspect()){ |
236 | // CLE |
237 | // const Handle(Prs3d_PointAspect) PA = myDrawer->PointAspect(); |
238 | Handle(Prs3d_PointAspect) PA = myDrawer->PointAspect(); |
239 | // ENDCLE |
240 | PA->SetColor(aCol); |
241 | PA->SetTypeOfMarker(aTOM); |
242 | PA->SetScale(aScale); |
243 | } |
244 | else |
245 | myDrawer->SetPointAspect(new Prs3d_PointAspect(aTOM,aCol,aScale)); |
246 | } |
247 | |