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