Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 1995-10-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 | |
1f7f5a90 | 17 | #include <AIS_Trihedron.hxx> |
42cf5bc1 | 18 | |
42cf5bc1 | 19 | #include <AIS_InteractiveContext.hxx> |
bc001a40 | 20 | #include <AIS_TrihedronOwner.hxx> |
f32cb549 | 21 | #include <AIS_TrihedronSelectionMode.hxx> |
7fd59977 | 22 | #include <Geom_Axis2Placement.hxx> |
7fd59977 | 23 | #include <gp_Pnt.hxx> |
42cf5bc1 | 24 | #include <Graphic3d_AspectLine3d.hxx> |
bc001a40 | 25 | #include <Graphic3d_ArrayOfPoints.hxx> |
26 | #include <Graphic3d_ArrayOfPolylines.hxx> | |
27 | ||
28 | #include <Prs3d_Arrow.hxx> | |
42cf5bc1 | 29 | #include <Prs3d_ArrowAspect.hxx> |
30 | #include <Prs3d_DatumAspect.hxx> | |
7fd59977 | 31 | #include <Prs3d_Drawer.hxx> |
32 | #include <Prs3d_LineAspect.hxx> | |
df8c7e3e | 33 | #include <Prs3d_PointAspect.hxx> |
42cf5bc1 | 34 | #include <Prs3d_Presentation.hxx> |
bc001a40 | 35 | #include <Prs3d_ShadingAspect.hxx> |
36 | #include <Prs3d_Text.hxx> | |
7fd59977 | 37 | #include <Prs3d_TextAspect.hxx> |
bc001a40 | 38 | #include <Prs3d_ToolSphere.hxx> |
39 | ||
42cf5bc1 | 40 | #include <Select3D_SensitivePoint.hxx> |
bc001a40 | 41 | #include <Select3D_SensitivePrimitiveArray.hxx> |
42cf5bc1 | 42 | #include <Select3D_SensitiveSegment.hxx> |
7fd59977 | 43 | #include <Select3D_SensitiveTriangle.hxx> |
42cf5bc1 | 44 | #include <SelectMgr_EntityOwner.hxx> |
45 | #include <Standard_Type.hxx> | |
7fd59977 | 46 | |
bc001a40 | 47 | IMPLEMENT_STANDARD_RTTIEXT(AIS_Trihedron, AIS_InteractiveObject) |
92efcf78 | 48 | |
7fd59977 | 49 | //======================================================================= |
50 | //function : AIS_Trihedron | |
bc001a40 | 51 | //purpose : |
7fd59977 | 52 | //======================================================================= |
bc001a40 | 53 | AIS_Trihedron::AIS_Trihedron (const Handle(Geom_Axis2Placement)& theComponent) |
24f9d04c | 54 | : myComponent (theComponent), |
bc001a40 | 55 | myTrihDispMode (Prs3d_DM_WireFrame), |
24f9d04c | 56 | myHasOwnSize (Standard_False), |
57 | myHasOwnTextColor (Standard_False), | |
58 | myHasOwnArrowColor (Standard_False) | |
046a1c9d | 59 | { |
df8c7e3e | 60 | myAutoHilight = Standard_False; |
61 | ||
bc001a40 | 62 | // selection priorities |
24f9d04c | 63 | memset (mySelectionPriority, 0, sizeof(mySelectionPriority)); |
64 | mySelectionPriority[Prs3d_DatumParts_None] = 5; // complete trihedron: priority 5 (same as faces) | |
65 | mySelectionPriority[Prs3d_DatumParts_Origin] = 8; // origin: priority 8 | |
66 | for (int aPartIter = Prs3d_DatumParts_XAxis; aPartIter <= Prs3d_DatumParts_ZAxis; ++aPartIter) | |
bc001a40 | 67 | { |
24f9d04c | 68 | mySelectionPriority[aPartIter] = 7; // axes: priority: 7 |
bc001a40 | 69 | } |
24f9d04c | 70 | for (int aPartIter = Prs3d_DatumParts_XOYAxis; aPartIter <= Prs3d_DatumParts_XOZAxis; ++aPartIter) |
bc001a40 | 71 | { |
24f9d04c | 72 | mySelectionPriority[aPartIter] = 5; // planes: priority: 5 |
bc001a40 | 73 | } |
df8c7e3e | 74 | myHiddenLineAspect = new Graphic3d_AspectLine3d (Quantity_NOC_WHITE, Aspect_TOL_EMPTY, 1.0f); |
bc001a40 | 75 | |
76 | // trihedron labels | |
24f9d04c | 77 | myLabels[Prs3d_DatumParts_XAxis] = "X"; |
78 | myLabels[Prs3d_DatumParts_YAxis] = "Y"; | |
79 | myLabels[Prs3d_DatumParts_ZAxis] = "Z"; | |
046a1c9d | 80 | } |
7fd59977 | 81 | |
82 | //======================================================================= | |
83 | //function : SetComponent | |
bc001a40 | 84 | //purpose : |
7fd59977 | 85 | //======================================================================= |
bc001a40 | 86 | void AIS_Trihedron::SetComponent (const Handle(Geom_Axis2Placement)& theComponent) |
7fd59977 | 87 | { |
bc001a40 | 88 | myComponent = theComponent; |
226fce20 | 89 | SetToUpdate(); |
7fd59977 | 90 | } |
91 | ||
29d43f9c | 92 | //======================================================================= |
bc001a40 | 93 | //function : setOwnDatumAspect |
1f7f5a90 | 94 | //purpose : |
29d43f9c | 95 | //======================================================================= |
bc001a40 | 96 | void AIS_Trihedron::setOwnDatumAspect() |
29d43f9c | 97 | { |
bc001a40 | 98 | if (myDrawer->HasOwnDatumAspect()) |
24f9d04c | 99 | { |
bc001a40 | 100 | return; |
24f9d04c | 101 | } |
bc001a40 | 102 | |
103 | Handle(Prs3d_DatumAspect) aNewAspect = new Prs3d_DatumAspect(); | |
24f9d04c | 104 | myDrawer->SetDatumAspect (aNewAspect); |
0aeb8984 | 105 | if (!myDrawer->Link().IsNull()) |
24f9d04c | 106 | { |
0aeb8984 | 107 | aNewAspect->CopyAspectsFrom (myDrawer->Link()->DatumAspect()); |
bc001a40 | 108 | } |
29d43f9c | 109 | } |
7fd59977 | 110 | |
111 | //======================================================================= | |
112 | //function : SetSize | |
bc001a40 | 113 | //purpose : |
7fd59977 | 114 | //======================================================================= |
24f9d04c | 115 | void AIS_Trihedron::SetSize(const Standard_Real theValue) |
7fd59977 | 116 | { |
117 | myHasOwnSize = Standard_True; | |
bc001a40 | 118 | |
119 | setOwnDatumAspect(); | |
24f9d04c | 120 | myDrawer->DatumAspect()->SetAxisLength (theValue, theValue, theValue); |
7fd59977 | 121 | |
226fce20 | 122 | SetToUpdate(); |
7fd59977 | 123 | UpdateSelection(); |
124 | } | |
125 | ||
7fd59977 | 126 | //======================================================================= |
127 | //function : UnsetSize | |
bc001a40 | 128 | //purpose : |
7fd59977 | 129 | //======================================================================= |
7fd59977 | 130 | void AIS_Trihedron::UnsetSize() |
131 | { | |
bc001a40 | 132 | if (!myHasOwnSize) |
133 | { | |
134 | return; | |
135 | } | |
136 | ||
7fd59977 | 137 | myHasOwnSize = Standard_False; |
bc001a40 | 138 | if (hasOwnColor) |
139 | { | |
140 | const Handle(Prs3d_DatumAspect) DA = myDrawer->HasLink() | |
141 | ? myDrawer->Link()->DatumAspect() | |
142 | : new Prs3d_DatumAspect(); | |
24f9d04c | 143 | myDrawer->DatumAspect()->SetAxisLength (DA->AxisLength (Prs3d_DatumParts_XAxis), |
144 | DA->AxisLength (Prs3d_DatumParts_YAxis), | |
145 | DA->AxisLength (Prs3d_DatumParts_ZAxis)); | |
7fd59977 | 146 | } |
147 | else | |
6262338c | 148 | { |
226fce20 | 149 | SetToUpdate(); |
6262338c | 150 | } |
7fd59977 | 151 | UpdateSelection(); |
7fd59977 | 152 | } |
153 | ||
154 | //======================================================================= | |
155 | //function : Size | |
bc001a40 | 156 | //purpose : |
7fd59977 | 157 | //======================================================================= |
7fd59977 | 158 | Standard_Real AIS_Trihedron::Size() const |
159 | { | |
24f9d04c | 160 | return myDrawer->DatumAspect()->AxisLength(Prs3d_DatumParts_XAxis); |
7fd59977 | 161 | } |
162 | ||
163 | //======================================================================= | |
bc001a40 | 164 | //function : Compute |
165 | //purpose : | |
7fd59977 | 166 | //======================================================================= |
decbff0d | 167 | void AIS_Trihedron::Compute (const Handle(PrsMgr_PresentationManager)& thePrsMgr, |
bc001a40 | 168 | const Handle(Prs3d_Presentation)& thePrs, |
169 | const Standard_Integer theMode) | |
7fd59977 | 170 | { |
bc001a40 | 171 | if (theMode != 0) |
046a1c9d | 172 | { |
bc001a40 | 173 | return; |
046a1c9d | 174 | } |
bc001a40 | 175 | |
176 | thePrs->SetInfiniteState (Standard_True); | |
177 | ||
178 | gp_Ax2 anAxis (myComponent->Ax2()); | |
179 | updatePrimitives (myDrawer->DatumAspect(), myTrihDispMode, anAxis.Location(), | |
180 | anAxis.XDirection(), anAxis.YDirection(), anAxis.Direction()); | |
181 | computePresentation (thePrsMgr, thePrs); | |
7fd59977 | 182 | } |
183 | ||
7fd59977 | 184 | //======================================================================= |
bc001a40 | 185 | //function : ComputeSelection |
186 | //purpose : | |
7fd59977 | 187 | //======================================================================= |
bc001a40 | 188 | void AIS_Trihedron::ComputeSelection (const Handle(SelectMgr_Selection)& theSelection, |
189 | const Standard_Integer theMode) | |
7fd59977 | 190 | { |
bc001a40 | 191 | Handle(Prs3d_DatumAspect) anAspect = myDrawer->DatumAspect(); |
192 | switch (theMode) | |
046a1c9d | 193 | { |
bc001a40 | 194 | case AIS_TrihedronSelectionMode_EntireObject: |
195 | { | |
24f9d04c | 196 | Handle(SelectMgr_EntityOwner) anOwner = new SelectMgr_EntityOwner (this, mySelectionPriority[Prs3d_DatumParts_None]); |
bc001a40 | 197 | const bool isShadingMode = myTrihDispMode == Prs3d_DM_Shaded; |
24f9d04c | 198 | for (int aPartIter = isShadingMode ? Prs3d_DatumParts_Origin : Prs3d_DatumParts_XAxis; aPartIter <= Prs3d_DatumParts_ZAxis; |
bc001a40 | 199 | ++aPartIter) |
200 | { | |
201 | const Prs3d_DatumParts aPart = (Prs3d_DatumParts )aPartIter; | |
202 | if (!anAspect->DrawDatumPart (aPart)) | |
203 | { | |
204 | continue; | |
205 | } | |
206 | theSelection->Add (createSensitiveEntity (aPart, anOwner)); | |
207 | } | |
208 | break; | |
209 | } | |
210 | case AIS_TrihedronSelectionMode_Origin: | |
211 | { | |
24f9d04c | 212 | const Prs3d_DatumParts aPart = Prs3d_DatumParts_Origin; |
bc001a40 | 213 | if (anAspect->DrawDatumPart (aPart)) |
214 | { | |
24f9d04c | 215 | Handle(SelectMgr_EntityOwner) anOwner = new AIS_TrihedronOwner (this, aPart, mySelectionPriority[aPart]); |
bc001a40 | 216 | Handle(Graphic3d_ArrayOfPrimitives) aPrimitives = arrayOfPrimitives(aPart); |
217 | theSelection->Add (createSensitiveEntity (aPart, anOwner)); | |
218 | } | |
219 | break; | |
220 | } | |
221 | case AIS_TrihedronSelectionMode_Axes: | |
222 | { | |
24f9d04c | 223 | for (int aPartIter = Prs3d_DatumParts_XAxis; aPartIter <= Prs3d_DatumParts_ZAxis; ++aPartIter) |
bc001a40 | 224 | { |
225 | const Prs3d_DatumParts aPart = (Prs3d_DatumParts )aPartIter; | |
226 | if (!anAspect->DrawDatumPart (aPart)) | |
227 | { | |
228 | continue; | |
229 | } | |
24f9d04c | 230 | Handle(SelectMgr_EntityOwner) anOwner = new AIS_TrihedronOwner (this, aPart, mySelectionPriority[aPart]); |
bc001a40 | 231 | theSelection->Add (createSensitiveEntity (aPart, anOwner)); |
232 | } | |
233 | break; | |
234 | } | |
235 | case AIS_TrihedronSelectionMode_MainPlanes: | |
236 | { | |
237 | // create owner for each trihedron plane | |
238 | { | |
24f9d04c | 239 | for (int aPartIter = Prs3d_DatumParts_XOYAxis; aPartIter <= Prs3d_DatumParts_XOZAxis; ++aPartIter) |
bc001a40 | 240 | { |
241 | const Prs3d_DatumParts aPart = (Prs3d_DatumParts )aPartIter; | |
242 | if (!anAspect->DrawDatumPart (aPart)) | |
243 | { | |
244 | continue; | |
245 | } | |
24f9d04c | 246 | Handle(SelectMgr_EntityOwner) anOwner = new AIS_TrihedronOwner (this, aPart, mySelectionPriority[aPart]); |
bc001a40 | 247 | theSelection->Add (createSensitiveEntity (aPart, anOwner)); |
248 | } | |
249 | } | |
250 | break; | |
251 | } | |
046a1c9d | 252 | } |
7fd59977 | 253 | } |
254 | ||
255 | //======================================================================= | |
bc001a40 | 256 | //function : HilightOwnerWithColor |
257 | //purpose : | |
7fd59977 | 258 | //======================================================================= |
decbff0d | 259 | void AIS_Trihedron::HilightOwnerWithColor (const Handle(PrsMgr_PresentationManager)& thePM, |
bc001a40 | 260 | const Handle(Prs3d_Drawer)& theStyle, |
261 | const Handle(SelectMgr_EntityOwner)& theOwner) | |
7fd59977 | 262 | { |
bc001a40 | 263 | Handle(AIS_TrihedronOwner) anOwner = Handle(AIS_TrihedronOwner)::DownCast (theOwner); |
264 | if (anOwner.IsNull()) | |
265 | { | |
24f9d04c | 266 | // default 0 selection mode |
bc001a40 | 267 | Standard_Integer aHiMode = HasHilightMode() ? HilightMode() : 0; |
268 | thePM->Color (this, theStyle, aHiMode, NULL, Graphic3d_ZLayerId_Top); | |
269 | return; | |
7fd59977 | 270 | } |
7fd59977 | 271 | |
bc001a40 | 272 | Handle(Prs3d_Presentation) aPresentation = GetHilightPresentation (thePM); |
273 | if (aPresentation.IsNull()) | |
274 | { | |
275 | return; | |
276 | } | |
7fd59977 | 277 | |
bc001a40 | 278 | aPresentation->Clear(); |
279 | const Prs3d_DatumParts aPart = anOwner->DatumPart(); | |
d6c48921 | 280 | Handle(Graphic3d_Group) aGroup = aPresentation->CurrentGroup(); |
24f9d04c | 281 | if (aPart >= Prs3d_DatumParts_XOYAxis && aPart <= Prs3d_DatumParts_XOZAxis) |
bc001a40 | 282 | { |
283 | // planes selection is equal in both shading and wireframe mode | |
df8c7e3e | 284 | aGroup->SetGroupPrimitivesAspect (theStyle->LineAspect()->Aspect()); |
bc001a40 | 285 | } |
286 | else | |
287 | { | |
288 | if (myTrihDispMode == Prs3d_DM_Shaded) | |
289 | { | |
df8c7e3e | 290 | aGroup->SetGroupPrimitivesAspect (theStyle->ShadingAspect()->Aspect()); |
bc001a40 | 291 | } |
292 | else | |
293 | { | |
24f9d04c | 294 | if (aPart == Prs3d_DatumParts_Origin) |
bc001a40 | 295 | { |
df8c7e3e | 296 | aGroup->SetGroupPrimitivesAspect (theStyle->PointAspect()->Aspect()); |
bc001a40 | 297 | } |
298 | else | |
299 | { | |
df8c7e3e | 300 | aGroup->SetGroupPrimitivesAspect(theStyle->LineAspect()->Aspect()); |
bc001a40 | 301 | } |
302 | } | |
303 | } | |
304 | aGroup->AddPrimitiveArray (arrayOfPrimitives(aPart)); | |
7fd59977 | 305 | |
df8c7e3e | 306 | const Graphic3d_ZLayerId aLayer = theStyle->ZLayer() != Graphic3d_ZLayerId_UNKNOWN ? theStyle->ZLayer() : myDrawer->ZLayer(); |
307 | if (aPresentation->GetZLayer() != aLayer) | |
c29c0ad0 | 308 | { |
df8c7e3e | 309 | aPresentation->SetZLayer (aLayer); |
c29c0ad0 | 310 | } |
df8c7e3e | 311 | |
bc001a40 | 312 | aPresentation->Highlight (theStyle); |
313 | thePM->AddToImmediateList (aPresentation); | |
7fd59977 | 314 | } |
315 | ||
bc001a40 | 316 | //======================================================================== |
317 | //function : HilightSelected | |
318 | //purpose : | |
319 | //======================================================================== | |
decbff0d | 320 | void AIS_Trihedron::HilightSelected (const Handle(PrsMgr_PresentationManager)& thePM, |
bc001a40 | 321 | const SelectMgr_SequenceOfOwner& theOwners) |
7fd59977 | 322 | { |
bc001a40 | 323 | if (theOwners.IsEmpty() || !HasInteractiveContext()) |
324 | { | |
325 | return; | |
326 | } | |
327 | ||
bc001a40 | 328 | const bool isShadingMode = myTrihDispMode == Prs3d_DM_Shaded; |
329 | ||
df8c7e3e | 330 | Handle(Prs3d_Drawer) anAspect = !myHilightDrawer.IsNull() ? myHilightDrawer : GetContext()->SelectionStyle(); |
bc001a40 | 331 | for (SelectMgr_SequenceOfOwner::Iterator anIterator (theOwners); anIterator.More(); anIterator.Next()) |
332 | { | |
333 | const Handle(SelectMgr_EntityOwner)& anOwner = anIterator.Value(); | |
334 | Handle(AIS_TrihedronOwner) aTrihedronOwner = Handle(AIS_TrihedronOwner)::DownCast(anOwner); | |
335 | if (aTrihedronOwner.IsNull()) | |
336 | { | |
df8c7e3e | 337 | thePM->Color (this, anAspect, 0); |
bc001a40 | 338 | continue; |
339 | } | |
340 | ||
341 | const Prs3d_DatumParts aPart = aTrihedronOwner->DatumPart(); | |
24f9d04c | 342 | if (myPartToGroup[aPart].IsNull() |
343 | || mySelectedParts.Contains (aPart)) | |
bc001a40 | 344 | { |
345 | continue; | |
346 | } | |
347 | ||
24f9d04c | 348 | const Handle(Graphic3d_Group)& aGroup = myPartToGroup[aPart]; |
349 | if (aPart >= Prs3d_DatumParts_XOYAxis | |
350 | && aPart <= Prs3d_DatumParts_XOZAxis) | |
bc001a40 | 351 | { |
df8c7e3e | 352 | aGroup->SetGroupPrimitivesAspect (anAspect->LineAspect()->Aspect()); |
bc001a40 | 353 | } |
354 | else | |
355 | { | |
356 | if (isShadingMode) | |
357 | { | |
df8c7e3e | 358 | aGroup->SetGroupPrimitivesAspect (anAspect->ShadingAspect()->Aspect()); |
bc001a40 | 359 | } |
360 | else | |
361 | { | |
24f9d04c | 362 | if (aPart == Prs3d_DatumParts_Origin) |
bc001a40 | 363 | { |
df8c7e3e | 364 | aGroup->SetGroupPrimitivesAspect (anAspect->PointAspect()->Aspect()); |
bc001a40 | 365 | } |
366 | else | |
367 | { | |
df8c7e3e | 368 | aGroup->SetGroupPrimitivesAspect (anAspect->LineAspect()->Aspect()); |
bc001a40 | 369 | } |
370 | } | |
371 | } | |
372 | mySelectedParts.Append (aPart); | |
7fd59977 | 373 | } |
374 | } | |
375 | ||
376 | //======================================================================= | |
bc001a40 | 377 | //function : ClearSelected |
378 | //purpose : | |
7fd59977 | 379 | //======================================================================= |
bc001a40 | 380 | void AIS_Trihedron::ClearSelected() |
7fd59977 | 381 | { |
bc001a40 | 382 | Handle(Prs3d_DatumAspect) anAspect = myDrawer->DatumAspect(); |
383 | const bool isShadingMode = myTrihDispMode == Prs3d_DM_Shaded; | |
384 | for (NCollection_List<Prs3d_DatumParts>::Iterator anIterator (mySelectedParts); anIterator.More(); | |
385 | anIterator.Next()) | |
386 | { | |
387 | const Prs3d_DatumParts aPart = anIterator.Value(); | |
24f9d04c | 388 | const Handle(Graphic3d_Group)& aGroup = myPartToGroup[aPart]; |
389 | if (aPart >= Prs3d_DatumParts_XOYAxis | |
390 | && aPart <= Prs3d_DatumParts_XOZAxis) | |
bc001a40 | 391 | { |
df8c7e3e | 392 | aGroup->SetGroupPrimitivesAspect (myHiddenLineAspect); |
bc001a40 | 393 | } |
df8c7e3e | 394 | else if (isShadingMode) |
bc001a40 | 395 | { |
396 | aGroup->SetGroupPrimitivesAspect (anAspect->ShadingAspect (aPart)->Aspect()); | |
397 | } | |
398 | else | |
399 | { | |
24f9d04c | 400 | if (aPart == Prs3d_DatumParts_Origin) |
bc001a40 | 401 | { |
402 | aGroup->SetGroupPrimitivesAspect (anAspect->PointAspect()->Aspect()); | |
403 | } | |
404 | else | |
405 | { | |
406 | aGroup->SetGroupPrimitivesAspect (anAspect->LineAspect (aPart)->Aspect()); | |
407 | } | |
408 | } | |
409 | } | |
410 | mySelectedParts.Clear(); | |
7fd59977 | 411 | } |
412 | ||
413 | //======================================================================= | |
bc001a40 | 414 | //function : computePresentation |
415 | //purpose : | |
7fd59977 | 416 | //======================================================================= |
decbff0d | 417 | void AIS_Trihedron::computePresentation (const Handle(PrsMgr_PresentationManager)& /*thePrsMgr*/, |
bc001a40 | 418 | const Handle(Prs3d_Presentation)& thePrs) |
7fd59977 | 419 | { |
24f9d04c | 420 | for (Standard_Integer aPartIter = 0; aPartIter < Prs3d_DatumParts_NB; ++aPartIter) |
421 | { | |
422 | myPartToGroup[aPartIter].Nullify(); | |
423 | } | |
424 | ||
bc001a40 | 425 | Handle(Prs3d_DatumAspect) anAspect = myDrawer->DatumAspect(); |
426 | const bool isShadingMode = myTrihDispMode == Prs3d_DM_Shaded; | |
427 | // display origin | |
428 | { | |
429 | // Origin is visualized only in shading mode | |
d6c48921 | 430 | Handle(Graphic3d_Group) aGroup = thePrs->NewGroup(); |
24f9d04c | 431 | const Prs3d_DatumParts aPart = Prs3d_DatumParts_Origin; |
bc001a40 | 432 | if (anAspect->DrawDatumPart(aPart)) |
433 | { | |
24f9d04c | 434 | myPartToGroup[aPart] = aGroup; |
bc001a40 | 435 | if (isShadingMode) |
436 | { | |
437 | aGroup->SetGroupPrimitivesAspect (anAspect->ShadingAspect (aPart)->Aspect()); | |
438 | } | |
439 | else | |
440 | { | |
441 | aGroup->SetGroupPrimitivesAspect (anAspect->PointAspect()->Aspect()); | |
442 | } | |
443 | aGroup->AddPrimitiveArray (arrayOfPrimitives (aPart)); | |
444 | } | |
445 | } | |
29d43f9c | 446 | |
bc001a40 | 447 | // display axes |
448 | { | |
24f9d04c | 449 | for (Standard_Integer anAxisIter = Prs3d_DatumParts_XAxis; anAxisIter <= Prs3d_DatumParts_ZAxis; ++anAxisIter) |
29d43f9c | 450 | { |
bc001a40 | 451 | Prs3d_DatumParts aPart = (Prs3d_DatumParts )anAxisIter; |
452 | if (!anAspect->DrawDatumPart (aPart)) | |
453 | { | |
454 | continue; | |
455 | } | |
29d43f9c | 456 | |
d6c48921 | 457 | Handle(Graphic3d_Group) anAxisGroup = thePrs->NewGroup(); |
24f9d04c | 458 | myPartToGroup[aPart] = anAxisGroup; |
bc001a40 | 459 | if (isShadingMode) |
29d43f9c | 460 | { |
bc001a40 | 461 | anAxisGroup->SetGroupPrimitivesAspect (anAspect->ShadingAspect (aPart)->Aspect()); |
29d43f9c | 462 | } |
bc001a40 | 463 | else |
464 | { | |
465 | anAxisGroup->SetGroupPrimitivesAspect (anAspect->LineAspect (aPart)->Aspect()); | |
466 | } | |
467 | anAxisGroup->AddPrimitiveArray (arrayOfPrimitives (aPart)); | |
468 | ||
469 | // draw arrow | |
0aeb8984 | 470 | const Prs3d_DatumParts anArrowPart = Prs3d_DatumAspect::ArrowPartForAxis (aPart); |
bc001a40 | 471 | if (!anAspect->DrawDatumPart (anArrowPart)) |
472 | { | |
473 | continue; | |
474 | } | |
fae1ae11 | 475 | |
d6c48921 | 476 | Handle(Graphic3d_Group) anArrowGroup = thePrs->NewGroup(); |
0aeb8984 | 477 | if (isShadingMode) |
478 | { | |
479 | anArrowGroup->SetGroupPrimitivesAspect (anAspect->ShadingAspect (anArrowPart)->Aspect()); | |
480 | } | |
481 | else | |
482 | { | |
483 | anArrowGroup->SetGroupPrimitivesAspect (anAspect->LineAspect (anArrowPart)->Aspect()); | |
484 | } | |
bc001a40 | 485 | anArrowGroup->AddPrimitiveArray (arrayOfPrimitives (anArrowPart)); |
7fd59977 | 486 | } |
bc001a40 | 487 | } |
7fd59977 | 488 | |
bc001a40 | 489 | // display labels |
490 | if (anAspect->ToDrawLabels()) | |
491 | { | |
492 | Handle(Geom_Axis2Placement) aComponent = myComponent; | |
493 | const gp_Pnt anOrigin = aComponent->Location(); | |
24f9d04c | 494 | for (Standard_Integer anAxisIter = Prs3d_DatumParts_XAxis; anAxisIter <= Prs3d_DatumParts_ZAxis; ++anAxisIter) |
bc001a40 | 495 | { |
496 | const Prs3d_DatumParts aPart = (Prs3d_DatumParts )anAxisIter; | |
497 | if (!anAspect->DrawDatumPart (aPart)) | |
498 | { | |
499 | continue; | |
7fd59977 | 500 | } |
29d43f9c | 501 | |
bc001a40 | 502 | const Standard_Real anAxisLength = anAspect->AxisLength (aPart); |
24f9d04c | 503 | const TCollection_ExtendedString& aLabel = myLabels[aPart]; |
bc001a40 | 504 | gp_Dir aDir; |
505 | switch (aPart) | |
506 | { | |
24f9d04c | 507 | case Prs3d_DatumParts_XAxis: aDir = aComponent->XDirection(); break; |
508 | case Prs3d_DatumParts_YAxis: aDir = aComponent->YDirection(); break; | |
509 | case Prs3d_DatumParts_ZAxis: aDir = aComponent->Direction(); break; | |
bc001a40 | 510 | default: break; |
511 | } | |
d6c48921 | 512 | Handle(Graphic3d_Group) aLabelGroup = thePrs->NewGroup(); |
bc001a40 | 513 | const gp_Pnt aPoint = anOrigin.XYZ() + aDir.XYZ() * anAxisLength; |
0aeb8984 | 514 | Prs3d_Text::Draw (aLabelGroup, anAspect->TextAspect (aPart), aLabel, aPoint); |
7fd59977 | 515 | } |
bc001a40 | 516 | } |
517 | ||
518 | // planes invisible group for planes selection | |
24f9d04c | 519 | for (Standard_Integer anAxisIter = Prs3d_DatumParts_XOYAxis; anAxisIter <= Prs3d_DatumParts_XOZAxis; ++anAxisIter) |
bc001a40 | 520 | { |
521 | Prs3d_DatumParts aPart = (Prs3d_DatumParts)anAxisIter; | |
522 | if (!anAspect->DrawDatumPart(aPart)) | |
523 | { | |
524 | continue; | |
7fd59977 | 525 | } |
bc001a40 | 526 | |
d6c48921 | 527 | Handle(Graphic3d_Group) aGroup = thePrs->NewGroup(); |
24f9d04c | 528 | myPartToGroup[aPart] = aGroup; |
bc001a40 | 529 | |
bc001a40 | 530 | aGroup->AddPrimitiveArray (arrayOfPrimitives (aPart)); |
df8c7e3e | 531 | aGroup->SetGroupPrimitivesAspect (myHiddenLineAspect); |
7fd59977 | 532 | } |
7fd59977 | 533 | } |
534 | ||
bc001a40 | 535 | //======================================================================= |
536 | //function : SetColor | |
537 | //purpose : | |
538 | //======================================================================= | |
539 | void AIS_Trihedron::SetDatumPartColor (const Prs3d_DatumParts thePart, | |
540 | const Quantity_Color& theColor) | |
7fd59977 | 541 | { |
bc001a40 | 542 | setOwnDatumAspect(); |
7fd59977 | 543 | |
bc001a40 | 544 | myDrawer->DatumAspect()->ShadingAspect (thePart)->SetColor (theColor); |
24f9d04c | 545 | if (thePart != Prs3d_DatumParts_Origin) |
bc001a40 | 546 | { |
547 | myDrawer->DatumAspect()->LineAspect (thePart)->SetColor (theColor); | |
548 | } | |
7fd59977 | 549 | } |
550 | ||
0aeb8984 | 551 | //======================================================================= |
552 | //function : SetTextColor | |
553 | //purpose : | |
554 | //======================================================================= | |
555 | void AIS_Trihedron::SetTextColor (const Prs3d_DatumParts thePart, | |
556 | const Quantity_Color& theColor) | |
557 | { | |
558 | setOwnDatumAspect(); | |
559 | myDrawer->DatumAspect()->TextAspect (thePart)->SetColor (theColor); | |
560 | } | |
561 | ||
7fd59977 | 562 | //======================================================================= |
563 | //function : SetTextColor | |
bc001a40 | 564 | //purpose : |
7fd59977 | 565 | //======================================================================= |
bc001a40 | 566 | void AIS_Trihedron::SetTextColor (const Quantity_Color& theColor) |
7fd59977 | 567 | { |
bc001a40 | 568 | setOwnDatumAspect(); |
0aeb8984 | 569 | myDrawer->DatumAspect()->TextAspect (Prs3d_DatumParts_XAxis)->SetColor (theColor); |
570 | myDrawer->DatumAspect()->TextAspect (Prs3d_DatumParts_YAxis)->SetColor (theColor); | |
571 | myDrawer->DatumAspect()->TextAspect (Prs3d_DatumParts_ZAxis)->SetColor (theColor); | |
7fd59977 | 572 | } |
573 | ||
bc001a40 | 574 | //======================================================================= |
575 | //function : Color | |
576 | //purpose : | |
577 | //======================================================================= | |
578 | Quantity_Color AIS_Trihedron::DatumPartColor (Prs3d_DatumParts thePart) | |
7fd59977 | 579 | { |
bc001a40 | 580 | if (myTrihDispMode == Prs3d_DM_Shaded) |
581 | { | |
582 | return myDrawer->DatumAspect()->ShadingAspect (thePart)->Color(); | |
583 | } | |
584 | else | |
585 | { | |
586 | return myDrawer->DatumAspect()->LineAspect (thePart)->Aspect()->Color(); | |
7fd59977 | 587 | } |
7fd59977 | 588 | } |
589 | ||
590 | //======================================================================= | |
bc001a40 | 591 | //function : SetOriginColor |
592 | //purpose : | |
7fd59977 | 593 | //======================================================================= |
bc001a40 | 594 | void AIS_Trihedron::SetOriginColor (const Quantity_Color& theColor) |
595 | { | |
596 | if (myTrihDispMode == Prs3d_DM_Shaded) | |
597 | { | |
24f9d04c | 598 | SetDatumPartColor (Prs3d_DatumParts_Origin, theColor); |
bc001a40 | 599 | } |
7fd59977 | 600 | } |
601 | ||
602 | //======================================================================= | |
bc001a40 | 603 | //function : SetXAxisColor |
604 | //purpose : | |
605 | //======================================================================= | |
606 | void AIS_Trihedron::SetXAxisColor (const Quantity_Color& theColor) | |
607 | { | |
24f9d04c | 608 | SetDatumPartColor (Prs3d_DatumParts_XAxis, theColor); |
7fd59977 | 609 | } |
610 | ||
611 | //======================================================================= | |
bc001a40 | 612 | //function : SetYAxisColor |
613 | //purpose : | |
614 | //======================================================================= | |
615 | void AIS_Trihedron::SetYAxisColor (const Quantity_Color& theColor) | |
616 | { | |
24f9d04c | 617 | SetDatumPartColor (Prs3d_DatumParts_YAxis, theColor); |
7fd59977 | 618 | } |
7fd59977 | 619 | |
7fd59977 | 620 | //======================================================================= |
bc001a40 | 621 | //function : SetAxisColor |
622 | //purpose : | |
7fd59977 | 623 | //======================================================================= |
bc001a40 | 624 | void AIS_Trihedron::SetAxisColor (const Quantity_Color& theColor) |
7fd59977 | 625 | { |
24f9d04c | 626 | SetDatumPartColor (Prs3d_DatumParts_ZAxis, theColor); |
7fd59977 | 627 | } |
bc001a40 | 628 | |
7fd59977 | 629 | //======================================================================= |
bc001a40 | 630 | //function : SetColor |
631 | //purpose : | |
7fd59977 | 632 | //======================================================================= |
bc001a40 | 633 | void AIS_Trihedron::SetColor (const Quantity_Color& theColor) |
634 | { | |
635 | hasOwnColor = Standard_True; | |
636 | myDrawer->SetColor (theColor); | |
7fd59977 | 637 | |
24f9d04c | 638 | SetDatumPartColor (Prs3d_DatumParts_Origin, theColor); |
639 | SetDatumPartColor (Prs3d_DatumParts_XAxis, theColor); | |
640 | SetDatumPartColor (Prs3d_DatumParts_YAxis, theColor); | |
641 | SetDatumPartColor (Prs3d_DatumParts_ZAxis, theColor); | |
bc001a40 | 642 | } |
7fd59977 | 643 | |
0aeb8984 | 644 | //======================================================================= |
645 | //function : SetArrowColor | |
646 | //purpose : | |
647 | //======================================================================= | |
648 | void AIS_Trihedron::SetArrowColor (const Prs3d_DatumParts thePart, | |
649 | const Quantity_Color& theColor) | |
650 | { | |
651 | setOwnDatumAspect(); | |
652 | myHasOwnArrowColor = Standard_True; | |
653 | const Prs3d_DatumParts anArrowPart = Prs3d_DatumAspect::ArrowPartForAxis (thePart); | |
654 | myDrawer->DatumAspect()->ShadingAspect(anArrowPart)->SetColor (theColor); | |
655 | myDrawer->DatumAspect()->LineAspect (anArrowPart)->SetColor (theColor); | |
656 | } | |
657 | ||
7fd59977 | 658 | //======================================================================= |
bc001a40 | 659 | //function : SetArrowColor |
660 | //purpose : | |
7fd59977 | 661 | //======================================================================= |
bc001a40 | 662 | void AIS_Trihedron::SetArrowColor (const Quantity_Color& theColor) |
663 | { | |
664 | setOwnDatumAspect(); | |
7fd59977 | 665 | |
bc001a40 | 666 | myHasOwnArrowColor = Standard_True; |
667 | myDrawer->DatumAspect()->ArrowAspect()->SetColor (theColor); | |
0aeb8984 | 668 | for (Standard_Integer anAxisIter = Prs3d_DatumParts_XArrow; anAxisIter <= Prs3d_DatumParts_ZArrow; ++anAxisIter) |
669 | { | |
670 | myDrawer->DatumAspect()->ShadingAspect((Prs3d_DatumParts )anAxisIter)->SetColor (theColor); | |
671 | myDrawer->DatumAspect()->LineAspect ((Prs3d_DatumParts )anAxisIter)->SetColor (theColor); | |
672 | } | |
bc001a40 | 673 | } |
7fd59977 | 674 | |
675 | //======================================================================= | |
bc001a40 | 676 | //function : TextColor |
677 | //purpose : | |
7fd59977 | 678 | //======================================================================= |
bc001a40 | 679 | Quantity_Color AIS_Trihedron::TextColor() const |
7fd59977 | 680 | { |
0aeb8984 | 681 | return myDrawer->DatumAspect()->TextAspect (Prs3d_DatumParts_XAxis)->Aspect()->Color(); |
7fd59977 | 682 | } |
683 | ||
684 | //======================================================================= | |
bc001a40 | 685 | //function : ArrowColor |
686 | //purpose : | |
7fd59977 | 687 | //======================================================================= |
bc001a40 | 688 | Quantity_Color AIS_Trihedron::ArrowColor() const |
689 | { | |
690 | return myDrawer->DatumAspect()->ArrowAspect()->Aspect()->Color(); | |
691 | } | |
7fd59977 | 692 | |
693 | //======================================================================= | |
694 | //function : UnsetColor | |
695 | //purpose : | |
696 | //======================================================================= | |
7fd59977 | 697 | void AIS_Trihedron::UnsetColor() |
698 | { | |
bc001a40 | 699 | hasOwnColor = Standard_False; |
700 | Quantity_Color aDefaultColor (Quantity_NOC_LIGHTSTEELBLUE4); | |
701 | SetColor (aDefaultColor); | |
702 | if (HasTextColor()) | |
703 | { | |
704 | SetTextColor (aDefaultColor); | |
7fd59977 | 705 | myHasOwnTextColor = Standard_False; |
706 | } | |
bc001a40 | 707 | if (HasArrowColor()) |
708 | { | |
709 | SetArrowColor (aDefaultColor); | |
7fd59977 | 710 | myHasOwnArrowColor = Standard_False; |
711 | } | |
7fd59977 | 712 | } |
713 | ||
fae1ae11 ZA |
714 | //======================================================================= |
715 | //function : ToDrawArrows | |
716 | //purpose : | |
717 | //======================================================================= | |
718 | Standard_Boolean AIS_Trihedron::ToDrawArrows() const | |
719 | { | |
720 | return myDrawer->DatumAspect()->ToDrawArrows(); | |
721 | } | |
722 | ||
723 | //======================================================================= | |
724 | //function : SetDrawArrows | |
725 | //purpose : | |
726 | //======================================================================= | |
727 | void AIS_Trihedron::SetDrawArrows (const Standard_Boolean theToDraw) | |
728 | { | |
729 | setOwnDatumAspect(); | |
730 | myDrawer->DatumAspect()->SetDrawArrows (theToDraw); | |
731 | } | |
732 | ||
7fd59977 | 733 | //======================================================================= |
bc001a40 | 734 | //function : createSensitiveEntity |
735 | //purpose : | |
7fd59977 | 736 | //======================================================================= |
0ef04197 | 737 | Handle(Select3D_SensitiveEntity) AIS_Trihedron::createSensitiveEntity (const Prs3d_DatumParts thePart, |
738 | const Handle(SelectMgr_EntityOwner)& theOwner) const | |
7fd59977 | 739 | { |
bc001a40 | 740 | Handle(Prs3d_DatumAspect) anAspect = myDrawer->DatumAspect(); |
741 | Handle(Graphic3d_ArrayOfPrimitives) aPrimitives = arrayOfPrimitives (thePart); | |
742 | if (aPrimitives.IsNull()) | |
743 | { | |
0ef04197 | 744 | return Handle(Select3D_SensitiveEntity)(); |
bc001a40 | 745 | } |
7fd59977 | 746 | |
24f9d04c | 747 | if (thePart >= Prs3d_DatumParts_XOYAxis |
748 | && thePart <= Prs3d_DatumParts_XOZAxis) | |
bc001a40 | 749 | { // plane |
750 | const gp_Pnt anXYZ1 = aPrimitives->Vertice (1); | |
751 | const gp_Pnt anXYZ2 = aPrimitives->Vertice (2); | |
752 | const gp_Pnt anXYZ3 = aPrimitives->Vertice (3); | |
753 | return new Select3D_SensitiveTriangle (theOwner, anXYZ1, anXYZ2, anXYZ3); | |
754 | } | |
755 | ||
756 | if (myTrihDispMode == Prs3d_DM_Shaded) | |
757 | { | |
758 | Handle(Select3D_SensitivePrimitiveArray) aSelArray = new Select3D_SensitivePrimitiveArray (theOwner); | |
759 | aSelArray->InitTriangulation (aPrimitives->Attributes(), aPrimitives->Indices(), TopLoc_Location()); | |
760 | return aSelArray; | |
761 | } | |
762 | ||
763 | if (Handle(Graphic3d_ArrayOfPoints) aPoints = Handle(Graphic3d_ArrayOfPoints)::DownCast(aPrimitives)) | |
764 | { | |
765 | const gp_Pnt anXYZ1 = aPoints->Vertice (1); | |
766 | return new Select3D_SensitivePoint (theOwner, anXYZ1); | |
767 | } | |
768 | else if (Handle(Graphic3d_ArrayOfSegments) aSegments = Handle(Graphic3d_ArrayOfSegments)::DownCast(aPrimitives)) | |
769 | { | |
770 | const gp_Pnt anXYZ1 = aSegments->Vertice (1); | |
771 | const gp_Pnt anXYZ2 = aSegments->Vertice (2); | |
772 | return new Select3D_SensitiveSegment (theOwner, anXYZ1, anXYZ2); | |
773 | } | |
0ef04197 | 774 | return Handle(Select3D_SensitiveEntity)(); |
7fd59977 | 775 | } |
bc001a40 | 776 | |
bc001a40 | 777 | // ======================================================================= |
778 | // function : updatePrimitives | |
779 | // purpose : | |
780 | // ======================================================================= | |
781 | void AIS_Trihedron::updatePrimitives(const Handle(Prs3d_DatumAspect)& theAspect, | |
782 | Prs3d_DatumMode theMode, | |
783 | const gp_Pnt& theOrigin, | |
784 | const gp_Dir& theXDirection, | |
785 | const gp_Dir& theYDirection, | |
786 | const gp_Dir& theZDirection) | |
7fd59977 | 787 | { |
24f9d04c | 788 | for (Standard_Integer aPartIter = 0; aPartIter < Prs3d_DatumParts_NB; ++aPartIter) |
789 | { | |
790 | myPrimitives[aPartIter].Nullify(); | |
791 | } | |
bc001a40 | 792 | |
793 | NCollection_DataMap<Prs3d_DatumParts, gp_Dir> anAxisDirs; | |
24f9d04c | 794 | anAxisDirs.Bind(Prs3d_DatumParts_XAxis, theXDirection); |
795 | anAxisDirs.Bind(Prs3d_DatumParts_YAxis, theYDirection); | |
796 | anAxisDirs.Bind(Prs3d_DatumParts_ZAxis, theZDirection); | |
bc001a40 | 797 | |
798 | NCollection_DataMap<Prs3d_DatumParts, gp_Pnt> anAxisPoints; | |
799 | gp_XYZ anXYZOrigin = theOrigin.XYZ(); | |
24f9d04c | 800 | for (int anAxisIter = Prs3d_DatumParts_XAxis; anAxisIter <= Prs3d_DatumParts_ZAxis; ++anAxisIter) |
bc001a40 | 801 | { |
802 | Prs3d_DatumParts aPart = (Prs3d_DatumParts)anAxisIter; | |
803 | anAxisPoints.Bind(aPart, gp_Pnt(anXYZOrigin + anAxisDirs.Find(aPart).XYZ() * | |
804 | theAspect->AxisLength(aPart))); | |
805 | } | |
806 | ||
807 | if (theMode == Prs3d_DM_WireFrame) | |
808 | { | |
809 | // origin | |
24f9d04c | 810 | if (theAspect->DrawDatumPart(Prs3d_DatumParts_Origin)) |
bc001a40 | 811 | { |
812 | Handle(Graphic3d_ArrayOfPrimitives) aPrims = new Graphic3d_ArrayOfPoints(1); | |
813 | aPrims->AddVertex(theOrigin); | |
24f9d04c | 814 | myPrimitives[Prs3d_DatumParts_Origin] = aPrims; |
bc001a40 | 815 | } |
816 | // axes | |
24f9d04c | 817 | for (int aPartIter = Prs3d_DatumParts_XAxis; aPartIter <= Prs3d_DatumParts_ZAxis; ++aPartIter) |
bc001a40 | 818 | { |
819 | const Prs3d_DatumParts aPart = (Prs3d_DatumParts)aPartIter; | |
820 | if (theAspect->DrawDatumPart(aPart)) | |
821 | { | |
822 | Handle(Graphic3d_ArrayOfPrimitives) aPrims = new Graphic3d_ArrayOfSegments(2); | |
823 | aPrims->AddVertex(theOrigin); | |
824 | aPrims->AddVertex(anAxisPoints.Find(aPart)); | |
24f9d04c | 825 | myPrimitives[aPart] = aPrims; |
bc001a40 | 826 | } |
827 | ||
0aeb8984 | 828 | const Prs3d_DatumParts anArrowPart = Prs3d_DatumAspect::ArrowPartForAxis (aPart); |
bc001a40 | 829 | if (theAspect->DrawDatumPart(anArrowPart)) |
830 | { | |
24f9d04c | 831 | myPrimitives[anArrowPart] = Prs3d_Arrow::DrawSegments (anAxisPoints.Find(aPart), anAxisDirs.Find(aPart), |
832 | theAspect->ArrowAspect()->Angle(), | |
833 | theAspect->AxisLength(aPart) * theAspect->Attribute(Prs3d_DatumAttribute_ShadingConeLengthPercent), | |
834 | (Standard_Integer) theAspect->Attribute(Prs3d_DatumAttribute_ShadingNumberOfFacettes)); | |
bc001a40 | 835 | } |
836 | } | |
837 | } | |
838 | else | |
839 | { | |
840 | // shading mode | |
841 | // origin | |
24f9d04c | 842 | if (theAspect->DrawDatumPart(Prs3d_DatumParts_Origin)) |
bc001a40 | 843 | { |
24f9d04c | 844 | const Standard_Real aSphereRadius = theAspect->AxisLength(Prs3d_DatumParts_XAxis) * |
845 | theAspect->Attribute(Prs3d_DatumAttribute_ShadingOriginRadiusPercent); | |
bc001a40 | 846 | const Standard_Integer aNbOfFacettes = |
24f9d04c | 847 | (Standard_Integer)theAspect->Attribute(Prs3d_DatumAttribute_ShadingNumberOfFacettes); |
bc001a40 | 848 | gp_Trsf aSphereTransform; |
849 | aSphereTransform.SetTranslationPart(gp_Vec(gp::Origin(), theOrigin)); | |
24f9d04c | 850 | myPrimitives[Prs3d_DatumParts_Origin] = Prs3d_ToolSphere::Create (aSphereRadius, aNbOfFacettes, aNbOfFacettes, aSphereTransform); |
bc001a40 | 851 | } |
852 | // axes | |
853 | { | |
854 | const Standard_Integer aNbOfFacettes = | |
24f9d04c | 855 | (Standard_Integer)theAspect->Attribute(Prs3d_DatumAttribute_ShadingNumberOfFacettes); |
856 | const Standard_Real aTubeRadiusPercent = theAspect->Attribute(Prs3d_DatumAttribute_ShadingTubeRadiusPercent); | |
857 | const Standard_Real aConeLengthPercent = theAspect->Attribute(Prs3d_DatumAttribute_ShadingConeLengthPercent); | |
858 | const Standard_Real aConeRadiusPercent = theAspect->Attribute(Prs3d_DatumAttribute_ShadingConeRadiusPercent); | |
859 | for (Standard_Integer anAxisIter = Prs3d_DatumParts_XAxis; anAxisIter <= Prs3d_DatumParts_ZAxis; ++anAxisIter) | |
da0e82aa | 860 | { |
bc001a40 | 861 | const Prs3d_DatumParts aPart = (Prs3d_DatumParts)anAxisIter; |
0aeb8984 | 862 | const Prs3d_DatumParts anArrowPart = Prs3d_DatumAspect::ArrowPartForAxis (aPart); |
bc001a40 | 863 | const bool aDrawArrow = theAspect->DrawDatumPart(anArrowPart); |
864 | const Standard_Real anAxisLength = theAspect->AxisLength(aPart); | |
865 | const gp_Ax1 anAxis(theOrigin, anAxisDirs.Find(aPart)); | |
866 | ||
867 | if (theAspect->DrawDatumPart(aPart)) | |
868 | { | |
869 | // draw cylinder | |
24f9d04c | 870 | myPrimitives[aPart] = Prs3d_Arrow::DrawShaded (anAxis, anAxisLength * aTubeRadiusPercent, |
871 | aDrawArrow ? (anAxisLength - anAxisLength * aConeLengthPercent) : anAxisLength, | |
872 | 0.0, 0.0, aNbOfFacettes); | |
bc001a40 | 873 | } |
874 | ||
875 | // draw arrow | |
876 | if (aDrawArrow) | |
877 | { | |
24f9d04c | 878 | myPrimitives[anArrowPart] = Prs3d_Arrow::DrawShaded (anAxis, 0.0, anAxisLength, |
879 | anAxisLength * aConeRadiusPercent, | |
880 | anAxisLength * aConeLengthPercent, aNbOfFacettes); | |
bc001a40 | 881 | } |
da0e82aa | 882 | } |
bc001a40 | 883 | } |
884 | } | |
885 | // planes | |
24f9d04c | 886 | for (Standard_Integer aPlaneIter = Prs3d_DatumParts_XOYAxis; aPlaneIter <= Prs3d_DatumParts_XOZAxis; ++aPlaneIter) |
bc001a40 | 887 | { |
888 | const Prs3d_DatumParts aPart = (Prs3d_DatumParts)aPlaneIter; | |
889 | if (!theAspect->DrawDatumPart(aPart)) | |
29d43f9c | 890 | { |
bc001a40 | 891 | continue; |
892 | } | |
893 | ||
894 | Handle(Graphic3d_ArrayOfPrimitives) aPrims = new Graphic3d_ArrayOfPolylines(4); | |
895 | aPrims->AddVertex(theOrigin); | |
896 | ||
24f9d04c | 897 | Prs3d_DatumParts aPart1 = Prs3d_DatumParts_XAxis, aPart2 = Prs3d_DatumParts_XAxis; |
bc001a40 | 898 | switch(aPart) |
899 | { | |
24f9d04c | 900 | case Prs3d_DatumParts_XOYAxis: |
bc001a40 | 901 | { |
24f9d04c | 902 | aPart1 = Prs3d_DatumParts_XAxis; |
903 | aPart2 = Prs3d_DatumParts_YAxis; | |
bc001a40 | 904 | break; |
905 | } | |
24f9d04c | 906 | case Prs3d_DatumParts_YOZAxis: |
bc001a40 | 907 | { |
24f9d04c | 908 | aPart1 = Prs3d_DatumParts_YAxis; |
909 | aPart2 = Prs3d_DatumParts_ZAxis; | |
bc001a40 | 910 | break; |
911 | } | |
24f9d04c | 912 | case Prs3d_DatumParts_XOZAxis: |
bc001a40 | 913 | { |
24f9d04c | 914 | aPart1 = Prs3d_DatumParts_XAxis; |
915 | aPart2 = Prs3d_DatumParts_ZAxis; | |
bc001a40 | 916 | break; |
917 | } | |
918 | default: break; | |
29d43f9c | 919 | } |
bc001a40 | 920 | aPrims->AddVertex(anAxisPoints.Find(aPart1)); |
921 | aPrims->AddVertex(anAxisPoints.Find(aPart2)); | |
922 | ||
923 | aPrims->AddVertex(theOrigin); | |
24f9d04c | 924 | myPrimitives[aPart] = aPrims; |
bc001a40 | 925 | } |
926 | } | |
bc73b006 | 927 | |
928 | //======================================================================= | |
929 | //function : DumpJson | |
930 | //purpose : | |
931 | //======================================================================= | |
932 | void AIS_Trihedron::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const | |
933 | { | |
934 | OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream) | |
935 | ||
936 | OCCT_DUMP_BASE_CLASS (theOStream, theDepth, AIS_InteractiveObject) | |
937 | ||
938 | OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHasOwnSize) | |
939 | OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHasOwnTextColor) | |
940 | OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHasOwnArrowColor) | |
bc73b006 | 941 | OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myTrihDispMode) |
942 | } |