Salome HOME
Merge branch 'Dev_0.6.1' of newgeom:newgeom into Dev_0.6.1
[modules/shaper.git] / src / GeomAPI / GeomAPI_AISObject.cpp
index 46e67f998650942a785d65f08ba3522a737d3f76..6be05290b1d06ac86d6ad5cc2c7f8c252ea6cc94 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomAPI_AISObject.cpp
 // Created:     25 Jun 2014
 // Author:      Artem ZHIDKOV
 #include <BRepBndLib.hxx>
 
 #include <AIS_InteractiveObject.hxx>
+#include <AIS_InteractiveContext.hxx>
 #include <AIS_LengthDimension.hxx>
 #include <AIS_ParallelRelation.hxx>
 #include <AIS_PerpendicularRelation.hxx>
 #include <AIS_RadiusDimension.hxx>
 #include <AIS_Shape.hxx>
 #include <AIS_FixRelation.hxx>
+#include <Prs3d_PointAspect.hxx>
 
 const double tolerance = 1e-7;
 
@@ -270,6 +274,7 @@ void GeomAPI_AISObject::setWidth(const double& theWidth)
   if (anAIS.IsNull())
     return;
   anAIS->SetWidth(theWidth);
+  anAIS->Redisplay();
 }
 
 void GeomAPI_AISObject::setColor(int theR, int theG, int theB)
@@ -294,3 +299,55 @@ bool GeomAPI_AISObject::empty() const
   return false;
 }
 
+int GeomAPI_AISObject::getShapeType() const
+{
+  Handle(AIS_InteractiveObject) anAIS = const_cast<GeomAPI_AISObject*>(this)
+      ->impl<Handle(AIS_InteractiveObject)>();
+  if (!anAIS.IsNull()) {
+    Handle(AIS_Shape) aAISShape = Handle(AIS_Shape)::DownCast(anAIS);
+    if (!aAISShape.IsNull()) {
+      return aAISShape->Shape().ShapeType();
+    }
+  }
+  return -1;
+}
+
+void GeomAPI_AISObject::setPointMarker(int theType, double theScale)
+{
+  Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
+  if (!anAIS.IsNull()) {
+    Handle(AIS_Drawer) aDrawer = anAIS->Attributes();
+    if (aDrawer->HasPointAspect()) {
+      Handle(Prs3d_PointAspect) aPA = aDrawer->PointAspect();
+      aPA->SetTypeOfMarker((Aspect_TypeOfMarker)theType);
+      aPA->SetScale(theScale);
+    } else {
+      Quantity_NameOfColor aCol = Quantity_NOC_YELLOW;
+      aDrawer->SetPointAspect(new Prs3d_PointAspect((Aspect_TypeOfMarker)theType, aCol, theScale));
+    }
+  }
+}
+
+
+void GeomAPI_AISObject::setLineStyle(int theStyle)
+{
+  Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
+  if (!anAIS.IsNull()) {
+    Handle(AIS_Drawer) aDrawer = anAIS->Attributes();
+    if (aDrawer->HasLineAspect())
+      aDrawer->LineAspect()->SetTypeOfLine((Aspect_TypeOfLine)theStyle);
+    if (aDrawer->HasWireAspect())
+      aDrawer->WireAspect()->SetTypeOfLine((Aspect_TypeOfLine)theStyle);
+  }
+}
+
+
+void GeomAPI_AISObject::setTransparensy(double theVal)
+{
+  Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
+  if (!anAIS.IsNull()) {
+    Handle(AIS_InteractiveContext) aContext = anAIS->GetContext();
+    if (!aContext.IsNull())
+      aContext->SetTransparency(anAIS, theVal, false);
+  }
+}