Salome HOME
Draft of transparency
[modules/shaper.git] / src / GeomAPI / GeomAPI_AISObject.cpp
1 // Copyright (C) 2014-2017  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
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 //
20
21 #include <GeomAPI_AISObject.h>
22
23 #include <GeomAPI_Circ.h>
24 #include <GeomAPI_Dir.h>
25 #include <GeomAPI_Lin.h>
26 #include <GeomAPI_Pln.h>
27 #include <GeomAPI_Pnt.h>
28 #include <GeomAPI_Shape.h>
29 #include <GeomAPI_XYZ.h>
30
31 #include <Geom_Plane.hxx>
32 #include <TopoDS_Shape.hxx>
33 #include <Quantity_NameOfColor.hxx>
34 #include <BRepBndLib.hxx>
35
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     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       std::shared_ptr<GeomAPI_Shape> aResult(new GeomAPI_Shape);
109       aResult->setImpl(new TopoDS_Shape(aShapeAIS->Shape()));
110       return aResult;
111     }
112   }
113   return std::shared_ptr<GeomAPI_Shape>();
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_Dimension) aDimAIS = Handle(AIS_Dimension)::DownCast(anAIS);
374   if (!aDimAIS.IsNull()) {
375     aDimAIS->DimensionAspect()->SetCommonColor(aColor);
376   }
377   Handle(AIS_InteractiveContext) aContext = anAIS->GetContext();
378   if (!aContext.IsNull())
379     aContext->SetColor(anAIS, aColor, false);
380   else
381     anAIS->SetColor(aColor);
382   return true;
383 }
384
385 void GeomAPI_AISObject::getColor(int& theR, int& theG, int& theB)
386 {
387   Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
388   if (anAIS.IsNull())
389     return;
390
391   Quantity_Color aColor = anAIS->Color();
392   theR = (int)(aColor.Red()*255.);
393   theG = (int)(aColor.Green()*255.);
394   theB = (int)(aColor.Blue()*255.);
395 }
396
397 bool GeomAPI_AISObject::setDeflection(const double theDeflection)
398 {
399   bool isModified = false;
400   Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
401   if (!anAIS.IsNull()) {
402     Handle(AIS_Shape) anAISShape = Handle(AIS_Shape)::DownCast(anAIS);
403     if (!anAISShape.IsNull()) {
404       Standard_Real aCoefficient, aPreviousCoefficient;
405       anAISShape->OwnDeviationCoefficient(aCoefficient, aPreviousCoefficient);
406       if (fabs(aCoefficient-theDeflection) > Precision::Confusion()) {
407         isModified = true;
408         anAISShape->SetOwnDeviationCoefficient(theDeflection);
409         // redisplay is necessary here to update presentation in all modes
410         // Standard True flag. Displayer uses Standard False flag. If it will be changed in
411         // displayer, redisplay here will not be necessary. But performance should be checked.
412         anAISShape->Redisplay(Standard_True);
413       }
414     }
415   }
416   return isModified;
417 }
418
419 double GeomAPI_AISObject::getDeflection() const
420 {
421   double aDeflection = -1;
422
423   Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
424   if (!anAIS.IsNull()) {
425     Handle(Prs3d_Drawer) aDrawer = anAIS->Attributes();
426     aDeflection = aDrawer->DeviationCoefficient();
427   }
428   return aDeflection;
429 }
430
431 bool GeomAPI_AISObject::setTransparency(const double theTransparency)
432 {
433   bool isModified = false;
434   Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
435   if (!anAIS.IsNull()) {
436     Handle(AIS_Shape) anAISShape = Handle(AIS_Shape)::DownCast(anAIS);
437     if (!anAISShape.IsNull()) {
438       Standard_Real aPreviousValue = anAISShape->Transparency();
439       if (fabs(aPreviousValue - theTransparency) > Precision::Confusion()) {
440         anAISShape->SetTransparency(theTransparency);
441         //>SetOwnDeviationCoefficient(theTransparency);
442         isModified = true;
443         // redisplay is necessary here to update presentation in all modes
444         // Standard True flag. Displayer uses Standard False flag. If it will be changed in
445         // displayer, redisplay here will not be necessary. But performance should be checked.
446         anAISShape->Redisplay(Standard_True);
447       }
448     }
449   }
450   return isModified;
451 }
452
453 double GeomAPI_AISObject::getTransparency() const
454 {
455   double aTransparency = 0;
456
457   Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
458   if (!anAIS.IsNull()) {
459     aTransparency = anAIS->Transparency();
460   }
461   return aTransparency;
462 }
463
464
465 bool GeomAPI_AISObject::empty() const
466 {
467   Handle(AIS_InteractiveObject) anAIS = const_cast<GeomAPI_AISObject*>(this)
468       ->impl<Handle(AIS_InteractiveObject)>();
469   if (anAIS.IsNull())
470     return true;
471   return false;
472 }
473
474 int GeomAPI_AISObject::getShapeType() const
475 {
476   Handle(AIS_InteractiveObject) anAIS = const_cast<GeomAPI_AISObject*>(this)
477       ->impl<Handle(AIS_InteractiveObject)>();
478   if (!anAIS.IsNull()) {
479     Handle(AIS_Shape) aAISShape = Handle(AIS_Shape)::DownCast(anAIS);
480     if (!aAISShape.IsNull()) {
481       const TopoDS_Shape aShape = aAISShape->Shape();
482       if (!aShape.IsNull())
483         return aShape.ShapeType();
484     }
485   }
486   return -1;
487 }
488
489 void GeomAPI_AISObject::setPointMarker(int theType, double theScale)
490 {
491   Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
492   if (!anAIS.IsNull()) {
493     Handle(Prs3d_Drawer) aDrawer = anAIS->Attributes();
494     if (aDrawer->HasOwnPointAspect()) {
495       Handle(Prs3d_PointAspect) aPA = aDrawer->PointAspect();
496       aPA->SetTypeOfMarker((Aspect_TypeOfMarker)theType);
497       aPA->SetScale(theScale);
498     } else {
499       Quantity_NameOfColor aCol = Quantity_NOC_YELLOW;
500       aDrawer->SetPointAspect(new Prs3d_PointAspect((Aspect_TypeOfMarker)theType, aCol, theScale));
501     }
502   }
503 }
504
505 bool GeomAPI_AISObject::setLineStyle(int theStyle)
506 {
507   bool isChanged = false;
508   Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
509   if (!anAIS.IsNull()) {
510     Handle(Prs3d_Drawer) aDrawer = anAIS->Attributes();
511     Handle(Prs3d_LineAspect) aLineAspect;
512
513     Aspect_TypeOfLine aType = (Aspect_TypeOfLine)theStyle;
514     if (aDrawer->HasOwnLineAspect()) {
515       aLineAspect = aDrawer->LineAspect();
516     }
517     if (aDrawer->HasOwnWireAspect()) {
518       aLineAspect = aDrawer->WireAspect();
519     }
520     if (!aLineAspect.IsNull()) {
521       Handle(Graphic3d_AspectLine3d) aGraphicAspect = aLineAspect->Aspect();
522       Aspect_TypeOfLine aCurrentType = aGraphicAspect->Type();
523       isChanged = aType != aCurrentType;
524       if (isChanged) {
525         aLineAspect->SetTypeOfLine(aType);
526       }
527     }
528   }
529   return isChanged;
530 }
531
532 bool GeomAPI_AISObject::setTransparensy(double theVal)
533 {
534   bool isChanged = false;
535   Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
536   if (!anAIS.IsNull()) {
537     Handle(AIS_InteractiveContext) aContext = anAIS->GetContext();
538     if (!aContext.IsNull()) {
539       double aCurrentValue = anAIS->Transparency();
540       isChanged = aCurrentValue != theVal;
541       if (isChanged)
542         aContext->SetTransparency(anAIS, theVal, false);
543     } else {
544       anAIS->SetTransparency(theVal);
545     }
546   }
547  return isChanged;
548 }