Salome HOME
Copyright update 2021
[modules/shaper.git] / src / GeomAPI / GeomAPI_AISObject.cpp
1 // Copyright (C) 2014-2021  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #include <GeomAPI_AISObject.h>
21
22 #include <GeomAPI_Circ.h>
23 #include <GeomAPI_Dir.h>
24 #include <GeomAPI_Lin.h>
25 #include <GeomAPI_Pln.h>
26 #include <GeomAPI_Pnt.h>
27 #include <GeomAPI_Shape.h>
28 #include <GeomAPI_XYZ.h>
29
30 #include <Geom_Plane.hxx>
31 #include <TopoDS_Shape.hxx>
32 #include <Quantity_NameOfColor.hxx>
33 #include <BRepBndLib.hxx>
34
35 #include <AIS_Dimension.hxx>
36 #include <AIS_InteractiveObject.hxx>
37 #include <AIS_InteractiveContext.hxx>
38 #include <AIS_LengthDimension.hxx>
39 #include <AIS_ParallelRelation.hxx>
40 #include <AIS_PerpendicularRelation.hxx>
41 #include <AIS_RadiusDimension.hxx>
42 #include <AIS_Shape.hxx>
43 #include <AIS_FixRelation.hxx>
44 #include <Prs3d_PointAspect.hxx>
45
46 #include <Graphic3d_AspectLine3d.hxx>
47
48 const double tolerance = 1e-7;
49
50 const int CONSTRAINT_TEXT_HEIGHT = 28;  /// the text height of the constraint
51 const int CONSTRAINT_TEXT_SELECTION_TOLERANCE = 20;  /// the text selection tolerance
52
53 GeomAPI_AISObject::GeomAPI_AISObject()
54     : GeomAPI_Interface(new Handle(AIS_InteractiveObject)())
55 {
56 }
57
58 GeomAPI_AISObject::~GeomAPI_AISObject()
59 {
60   if (!empty()) {
61     // This is necessary for correct deletion of Handle entity.
62     // Without this Handle does not decremented counter to 0
63     Handle(AIS_InteractiveObject) *anAIS = implPtr<Handle(AIS_InteractiveObject)>();
64     anAIS->Nullify();
65   }
66 }
67
68
69 void GeomAPI_AISObject::createShape(std::shared_ptr<GeomAPI_Shape> theShape)
70 {
71   const TopoDS_Shape& aTDS =
72       (theShape && theShape->implPtr<TopoDS_Shape>()) ?
73           theShape->impl<TopoDS_Shape>() : TopoDS_Shape();
74
75   Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
76   if (!anAIS.IsNull()) {
77     Handle(AIS_Shape) aShapeAIS = Handle(AIS_Shape)::DownCast(anAIS);
78     if (aShapeAIS) {
79       // if the AIS object is displayed in the opened local context in some mode, additional
80       // AIS sub objects are created there. They should be rebuild for correct selecting.
81       // It is possible to correct it by closing local context before the shape set and opening
82       // after. Another workaround to thrown down the selection and reselecting the AIS.
83       // If there was a problem here, try the first solution with close/open local context.
84
85       aShapeAIS->Set(aTDS);
86       aShapeAIS->Redisplay(Standard_True);
87     }
88   } else {
89     // Set default point as a '+' symbol
90     Handle(AIS_Shape) aShape = new AIS_Shape(aTDS);
91     Handle(Prs3d_Drawer) aDrawer = aShape->Attributes();
92     if (aDrawer->HasOwnPointAspect())
93       aDrawer->PointAspect()->SetTypeOfMarker(Aspect_TOM_PLUS);
94     else
95       aDrawer->SetPointAspect(new Prs3d_PointAspect(Aspect_TOM_PLUS, Quantity_NOC_YELLOW, 1.));
96     aDrawer->SetIsoOnPlane(false);
97     setImpl(new Handle(AIS_InteractiveObject)(aShape));
98   }
99 }
100
101 std::shared_ptr<GeomAPI_Shape> GeomAPI_AISObject::getShape() const
102 {
103   std::shared_ptr<GeomAPI_Shape> aResult;
104
105   Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
106   if (!anAIS.IsNull()) {
107     Handle(AIS_Shape) aShapeAIS = Handle(AIS_Shape)::DownCast(anAIS);
108     if (aShapeAIS) {
109       aResult.reset(new GeomAPI_Shape);
110       aResult->setImpl(new TopoDS_Shape(aShapeAIS->Shape()));
111     }
112   }
113   return aResult;
114 }
115
116 void GeomAPI_AISObject::createDistance(std::shared_ptr<GeomAPI_Pnt> theStartPoint,
117                                        std::shared_ptr<GeomAPI_Pnt> theEndPoint,
118                                        std::shared_ptr<GeomAPI_Pnt> theFlyoutPoint,
119                                        std::shared_ptr<GeomAPI_Pln> thePlane, double theDistance)
120 {
121   double aFlyout = 0;
122   if (theFlyoutPoint) {
123     double aDist = 0.0;
124     if (theStartPoint->distance(theEndPoint) < tolerance)
125       aDist = theStartPoint->distance(theFlyoutPoint);
126     else {
127       std::shared_ptr<GeomAPI_Lin> aLine = std::shared_ptr<GeomAPI_Lin>(
128           new GeomAPI_Lin(theStartPoint, theEndPoint));
129       aDist = aLine->distance(theFlyoutPoint);
130     }
131
132     std::shared_ptr<GeomAPI_XYZ> aLineDir = theEndPoint->xyz()->decreased(theStartPoint->xyz());
133     std::shared_ptr<GeomAPI_XYZ> aFOutDir = theFlyoutPoint->xyz()->decreased(
134         theStartPoint->xyz());
135     std::shared_ptr<GeomAPI_XYZ> aNorm = thePlane->direction()->xyz();
136     if (aLineDir->cross(aFOutDir)->dot(aNorm) < 0)
137       aDist = -aDist;
138     aFlyout = aDist;
139   }
140
141   Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
142   if (anAIS.IsNull()) {
143     Handle(AIS_LengthDimension) aDimAIS = new AIS_LengthDimension(theStartPoint->impl<gp_Pnt>(),
144                                                                   theEndPoint->impl<gp_Pnt>(),
145                                                                   thePlane->impl<gp_Pln>());
146     aDimAIS->SetCustomValue(theDistance);
147
148     Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect();
149     anAspect->MakeArrows3d(Standard_False);
150     anAspect->MakeText3d(Standard_False);
151     anAspect->TextAspect()->SetHeight(CONSTRAINT_TEXT_HEIGHT);
152     anAspect->MakeTextShaded(Standard_True);
153     anAspect->ArrowAspect()->SetLength(theDistance / 10.);
154     aDimAIS->DimensionAspect()->MakeUnitsDisplayed(false);
155     aDimAIS->SetDimensionAspect(anAspect);
156     aDimAIS->SetSelToleranceForText2d(CONSTRAINT_TEXT_SELECTION_TOLERANCE);
157     aDimAIS->SetFlyout(aFlyout);
158
159     setImpl(new Handle(AIS_InteractiveObject)(aDimAIS));
160   } else {
161     // update presentation
162     Handle(AIS_LengthDimension) aDimAIS = Handle(AIS_LengthDimension)::DownCast(anAIS);
163     if (!aDimAIS.IsNull()) {
164       aDimAIS->SetMeasuredGeometry(theStartPoint->impl<gp_Pnt>(), theEndPoint->impl<gp_Pnt>(),
165                                    thePlane->impl<gp_Pln>());
166       aDimAIS->SetCustomValue(theDistance);
167       aDimAIS->SetFlyout(aFlyout);
168
169       aDimAIS->Redisplay(Standard_True);
170     }
171   }
172 }
173
174 bool GeomAPI_AISObject::isEmptyDistanceGeometry()
175 {
176   bool anEmpty = false;
177
178   Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
179   if (!anAIS.IsNull()) {
180     Handle(AIS_LengthDimension) aDimAIS = Handle(AIS_LengthDimension)::DownCast(anAIS);
181     if (!aDimAIS.IsNull()) {
182       anEmpty = !aDimAIS->IsValid();
183     }
184   }
185
186   return anEmpty;
187 }
188
189 void GeomAPI_AISObject::createRadius(std::shared_ptr<GeomAPI_Circ> theCircle,
190                                      std::shared_ptr<GeomAPI_Pnt> theFlyoutPoint,
191                                      double theRadius)
192 {
193   std::shared_ptr<GeomAPI_Pnt> aCenter = theCircle->center();
194
195   // TODO: a bug in AIS_RadiusDimension:
196   // The anchor point can't be myCirc.Location() - an exception is raised.
197   // But we need exactly this case...
198   // We want to show a radius dimension starting from the circle centre and
199   // ending at the user-defined point.
200   // Also, if anchor point coincides with myP2, the radius dimension is not displayed at all.
201   std::shared_ptr<GeomAPI_Pnt> anAnchor = theCircle->project(theFlyoutPoint);
202   std::shared_ptr<GeomAPI_XYZ> anAnchorXYZ = anAnchor->xyz();
203   anAnchorXYZ = anAnchorXYZ->decreased(aCenter->xyz());
204   std::shared_ptr<GeomAPI_Dir> aDeltaDir(new GeomAPI_Dir(anAnchorXYZ));
205   const double aDelta = 1e-3;
206   anAnchor->setX(anAnchor->x() + aDelta * aDeltaDir->x());
207   anAnchor->setY(anAnchor->y() + aDelta * aDeltaDir->y());
208   anAnchor->setZ(anAnchor->z() + aDelta * aDeltaDir->z());
209
210   Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
211   if (anAIS.IsNull()) {
212     Handle(AIS_RadiusDimension) aDimAIS = new AIS_RadiusDimension(theCircle->impl<gp_Circ>(),
213                                                                   anAnchor->impl<gp_Pnt>());
214     aDimAIS->SetCustomValue(theRadius);
215
216     Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect();
217     anAspect->MakeArrows3d(Standard_False);
218     anAspect->MakeText3d(false);
219     anAspect->TextAspect()->SetHeight(CONSTRAINT_TEXT_HEIGHT);
220     anAspect->ArrowAspect()->SetLength(theRadius / 5.);
221     anAspect->MakeTextShaded(false);
222     aDimAIS->DimensionAspect()->MakeUnitsDisplayed(false);
223     aDimAIS->SetDimensionAspect(anAspect);
224     aDimAIS->SetSelToleranceForText2d(CONSTRAINT_TEXT_SELECTION_TOLERANCE);
225
226     setImpl(new Handle(AIS_InteractiveObject)(aDimAIS));
227   } else {
228     // update presentation
229     Handle(AIS_RadiusDimension) aDimAIS = Handle(AIS_RadiusDimension)::DownCast(anAIS);
230     if (!aDimAIS.IsNull()) {
231       aDimAIS->SetMeasuredGeometry(theCircle->impl<gp_Circ>(), anAnchor->impl<gp_Pnt>());
232       aDimAIS->SetCustomValue(theRadius);
233       aDimAIS->Redisplay(Standard_True);
234     }
235   }
236 }
237
238 void GeomAPI_AISObject::createParallel(std::shared_ptr<GeomAPI_Shape> theLine1,
239                                        std::shared_ptr<GeomAPI_Shape> theLine2,
240                                        std::shared_ptr<GeomAPI_Pnt> theFlyoutPoint,
241                                        std::shared_ptr<GeomAPI_Pln> thePlane)
242 {
243   Handle(Geom_Plane) aPlane = new Geom_Plane(thePlane->impl<gp_Pln>());
244   Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
245   if (anAIS.IsNull()) {
246     Handle(AIS_ParallelRelation) aParallel = new AIS_ParallelRelation(
247         theLine1->impl<TopoDS_Shape>(), theLine2->impl<TopoDS_Shape>(), aPlane);
248     if (theFlyoutPoint)
249       aParallel->SetPosition(theFlyoutPoint->impl<gp_Pnt>());
250
251     setImpl(new Handle(AIS_InteractiveObject)(aParallel));
252   } else {
253     Handle(AIS_ParallelRelation) aParallel = Handle(AIS_ParallelRelation)::DownCast(anAIS);
254     if (!aParallel.IsNull()) {
255       aParallel->SetFirstShape(theLine1->impl<TopoDS_Shape>());
256       aParallel->SetSecondShape(theLine2->impl<TopoDS_Shape>());
257       aParallel->SetPlane(aPlane);
258       if (theFlyoutPoint)
259         aParallel->SetPosition(theFlyoutPoint->impl<gp_Pnt>());
260       aParallel->Redisplay(Standard_True);
261     }
262   }
263 }
264
265 void GeomAPI_AISObject::createPerpendicular(std::shared_ptr<GeomAPI_Shape> theLine1,
266                                             std::shared_ptr<GeomAPI_Shape> theLine2,
267                                             std::shared_ptr<GeomAPI_Pln> thePlane)
268 {
269   Handle(Geom_Plane) aPlane = new Geom_Plane(thePlane->impl<gp_Pln>());
270   Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
271   if (anAIS.IsNull()) {
272     Handle(AIS_PerpendicularRelation) aPerpendicular = new AIS_PerpendicularRelation(
273         theLine1->impl<TopoDS_Shape>(), theLine2->impl<TopoDS_Shape>(), aPlane);
274
275     setImpl(new Handle(AIS_InteractiveObject)(aPerpendicular));
276   } else {
277     Handle(AIS_PerpendicularRelation) aPerpendicular = Handle(AIS_PerpendicularRelation)::DownCast(
278         anAIS);
279     if (!aPerpendicular.IsNull()) {
280       aPerpendicular->SetFirstShape(theLine1->impl<TopoDS_Shape>());
281       aPerpendicular->SetSecondShape(theLine2->impl<TopoDS_Shape>());
282       aPerpendicular->SetPlane(aPlane);
283       aPerpendicular->Redisplay(Standard_True);
284     }
285   }
286 }
287
288
289 void GeomAPI_AISObject::createFixed(std::shared_ptr<GeomAPI_Shape> theShape,
290                                     std::shared_ptr<GeomAPI_Pln> thePlane)
291 {
292   Handle(Geom_Plane) aPlane = new Geom_Plane(thePlane->impl<gp_Pln>());
293   Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
294   TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
295   Handle(AIS_FixRelation) aFixPrs;
296   if (anAIS.IsNull()) {
297     aFixPrs = new AIS_FixRelation(aShape, aPlane);
298
299     setImpl(new Handle(AIS_InteractiveObject)(aFixPrs));
300   } else {
301     aFixPrs = Handle(AIS_FixRelation)::DownCast(anAIS);
302     if (!aFixPrs.IsNull()) {
303       aFixPrs->SetFirstShape(aShape);
304       aFixPrs->SetPlane(aPlane);
305       aFixPrs->Redisplay(Standard_True);
306     }
307   }
308   if (!aFixPrs.IsNull()) {
309     Bnd_Box aBox;
310     BRepBndLib::Add(aShape, aBox);
311     double aXmin, aXmax, aYmin, aYmax, aZmin, aZmax;
312     aBox.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
313     gp_Pnt aXYZ1(aXmin, aXmax, aYmin);
314     gp_Pnt aXYZ2(aXmax, aYmax, aZmax);
315     double aDist = aXYZ1.Distance(aXYZ2);
316     if (aDist > Precision::Confusion()) {
317       aFixPrs->SetArrowSize(aDist/8.);
318     }
319   }
320 }
321
322 void GeomAPI_AISObject::setColor(const int& theColor)
323 {
324   Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
325   if (anAIS.IsNull())
326     return;
327   Quantity_Color aColor((Quantity_NameOfColor) theColor);
328   Handle(AIS_Dimension) aDimAIS = Handle(AIS_Dimension)::DownCast(anAIS);
329   if (!aDimAIS.IsNull()) {
330     aDimAIS->DimensionAspect()->SetCommonColor(aColor);
331   }
332   Handle(AIS_InteractiveContext) aContext = anAIS->GetContext();
333   if (!aContext.IsNull())
334     aContext->SetColor(anAIS, aColor, false);
335   else
336     anAIS->SetColor(aColor);
337 }
338
339 double GeomAPI_AISObject::width()
340 {
341   double aWidth = 0.0;
342   Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
343   if (!anAIS.IsNull()) {
344     aWidth = anAIS->Width();
345   }
346   return aWidth;
347 }
348
349 bool GeomAPI_AISObject::setWidth(const double& theWidth)
350 {
351   bool isChanged = false;
352   Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
353   if (!anAIS.IsNull()) {
354     isChanged = anAIS->Width() != theWidth;
355     if (isChanged)
356       anAIS->SetWidth(theWidth);
357   }
358   return isChanged;
359 }
360
361 bool GeomAPI_AISObject::setColor(int theR, int theG, int theB)
362 {
363   Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
364   if (anAIS.IsNull())
365     return false;
366   Quantity_Color aColor(theR / 255., theG / 255., theB / 255., Quantity_TOC_RGB);
367   Quantity_Color aCurrentColor;
368   anAIS->Color(aCurrentColor);
369   // do not set the same color to the presentation
370   if (aColor.IsEqual(aCurrentColor))
371     return false;
372
373   Handle(AIS_InteractiveContext) aContext = anAIS->GetContext();
374   Handle(AIS_Dimension) aDimAIS = Handle(AIS_Dimension)::DownCast(anAIS);
375   if (!aDimAIS.IsNull()) {
376     aDimAIS->DimensionAspect()->SetCommonColor(aColor);
377     if (!aContext.IsNull())
378       aContext->Redisplay(aDimAIS, false);
379   }
380   else {
381     if (!aContext.IsNull())
382       aContext->SetColor(anAIS, aColor, false);
383     else
384       anAIS->SetColor(aColor);
385   }
386   return true;
387 }
388
389 void GeomAPI_AISObject::getColor(int& theR, int& theG, int& theB)
390 {
391   Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
392   if (anAIS.IsNull())
393     return;
394
395   Quantity_Color aColor;
396   anAIS->Color(aColor);
397   theR = (int)(aColor.Red()*255.);
398   theG = (int)(aColor.Green()*255.);
399   theB = (int)(aColor.Blue()*255.);
400 }
401
402 bool GeomAPI_AISObject::setDeflection(const double theDeflection)
403 {
404   bool isModified = false;
405   Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
406   if (!anAIS.IsNull()) {
407     Handle(AIS_Shape) anAISShape = Handle(AIS_Shape)::DownCast(anAIS);
408     if (!anAISShape.IsNull()) {
409       Standard_Real aCoefficient, aPreviousCoefficient;
410       anAISShape->OwnDeviationCoefficient(aCoefficient, aPreviousCoefficient);
411       if (fabs(aCoefficient-theDeflection) > Precision::Confusion()) {
412         isModified = true;
413         anAISShape->SetOwnDeviationCoefficient(theDeflection);
414         Handle(Prs3d_Drawer) aDrawer = anAISShape->DynamicHilightAttributes();
415         if (!aDrawer.IsNull()) {
416           aDrawer->SetDeviationCoefficient(theDeflection);
417         }
418         // redisplay is necessary here to update presentation in all modes
419         // Standard True flag. Displayer uses Standard False flag. If it will be changed in
420         // displayer, redisplay here will not be necessary. But performance should be checked.
421         anAISShape->Redisplay(Standard_True);
422       }
423     }
424   }
425   return isModified;
426 }
427
428 double GeomAPI_AISObject::getDeflection() const
429 {
430   double aDeflection = -1;
431
432   Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
433   if (!anAIS.IsNull()) {
434     Handle(Prs3d_Drawer) aDrawer = anAIS->Attributes();
435     aDeflection = aDrawer->DeviationCoefficient();
436   }
437   return aDeflection;
438 }
439
440 bool GeomAPI_AISObject::setTransparency(const double theTransparency)
441 {
442   bool isModified = false;
443   Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
444   if (!anAIS.IsNull()) {
445     Handle(AIS_Shape) anAISShape = Handle(AIS_Shape)::DownCast(anAIS);
446     if (!anAISShape.IsNull()) {
447       Standard_Real aPreviousValue = anAISShape->Transparency();
448       if (fabs(aPreviousValue - theTransparency) > Precision::Confusion()) {
449         anAISShape->SetTransparency(theTransparency);
450         //>SetOwnDeviationCoefficient(theTransparency);
451         isModified = true;
452         // redisplay is necessary here to update presentation in all modes
453         // Standard True flag. Displayer uses Standard False flag. If it will be changed in
454         // displayer, redisplay here will not be necessary. But performance should be checked.
455         anAISShape->Redisplay(Standard_True);
456       }
457     }
458   }
459   return isModified;
460 }
461
462 double GeomAPI_AISObject::getTransparency() const
463 {
464   double aTransparency = 0;
465
466   Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
467   if (!anAIS.IsNull()) {
468     aTransparency = anAIS->Transparency();
469   }
470   return aTransparency;
471 }
472
473
474 bool GeomAPI_AISObject::empty() const
475 {
476   Handle(AIS_InteractiveObject) anAIS = const_cast<GeomAPI_AISObject*>(this)
477       ->impl<Handle(AIS_InteractiveObject)>();
478   if (anAIS.IsNull())
479     return true;
480   return false;
481 }
482
483 int GeomAPI_AISObject::getShapeType() const
484 {
485   Handle(AIS_InteractiveObject) anAIS = const_cast<GeomAPI_AISObject*>(this)
486       ->impl<Handle(AIS_InteractiveObject)>();
487   if (!anAIS.IsNull()) {
488     Handle(AIS_Shape) aAISShape = Handle(AIS_Shape)::DownCast(anAIS);
489     if (!aAISShape.IsNull()) {
490       const TopoDS_Shape aShape = aAISShape->Shape();
491       if (!aShape.IsNull())
492         return aShape.ShapeType();
493     }
494   }
495   return -1;
496 }
497
498 void GeomAPI_AISObject::setPointMarker(int theType, double theScale)
499 {
500   Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
501   if (!anAIS.IsNull()) {
502     Handle(Prs3d_Drawer) aDrawer = anAIS->Attributes();
503     if (aDrawer->HasOwnPointAspect()) {
504       Handle(Prs3d_PointAspect) aPA = aDrawer->PointAspect();
505       aPA->SetTypeOfMarker((Aspect_TypeOfMarker)theType);
506       aPA->SetScale(theScale);
507     } else {
508       Quantity_NameOfColor aCol = Quantity_NOC_YELLOW;
509       aDrawer->SetPointAspect(new Prs3d_PointAspect((Aspect_TypeOfMarker)theType, aCol, theScale));
510     }
511   }
512 }
513
514 bool GeomAPI_AISObject::setLineStyle(int theStyle)
515 {
516   bool isChanged = false;
517   Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
518   if (!anAIS.IsNull()) {
519     Handle(Prs3d_Drawer) aDrawer = anAIS->Attributes();
520     Handle(Prs3d_LineAspect) aLineAspect;
521
522     Aspect_TypeOfLine aType = (Aspect_TypeOfLine)theStyle;
523     if (aDrawer->HasOwnLineAspect()) {
524       aLineAspect = aDrawer->LineAspect();
525     }
526     if (aDrawer->HasOwnWireAspect()) {
527       aLineAspect = aDrawer->WireAspect();
528     }
529     if (!aLineAspect.IsNull()) {
530       Handle(Graphic3d_AspectLine3d) aGraphicAspect = aLineAspect->Aspect();
531       Aspect_TypeOfLine aCurrentType = aGraphicAspect->Type();
532       isChanged = aType != aCurrentType;
533       if (isChanged) {
534         aLineAspect->SetTypeOfLine(aType);
535       }
536     }
537   }
538   return isChanged;
539 }
540
541 bool GeomAPI_AISObject::setTransparensy(double theVal)
542 {
543   bool isChanged = false;
544   Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
545   if (!anAIS.IsNull()) {
546     Handle(AIS_InteractiveContext) aContext = anAIS->GetContext();
547     if (!aContext.IsNull()) {
548       double aCurrentValue = anAIS->Transparency();
549       isChanged = aCurrentValue != theVal;
550       if (isChanged)
551         aContext->SetTransparency(anAIS, theVal, false);
552     } else {
553       anAIS->SetTransparency(theVal);
554     }
555   }
556  return isChanged;
557 }