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 b381074b8de85f2a577edd5d618070880ca17a54..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;
 
 const int CONSTRAINT_TEXT_HEIGHT = 28;  /// the text height of the constraint
 const int CONSTRAINT_TEXT_SELECTION_TOLERANCE = 20;  /// the text selection tolerance
 
-// Initialization of color constants
-int Colors::COLOR_BROWN = Quantity_NOC_BROWN;
-int Colors::COLOR_RED = Quantity_NOC_RED;
-int Colors::COLOR_GREEN = Quantity_NOC_GREEN;
-int Colors::COLOR_BLUE = Quantity_NOC_BLUE1;
-
 GeomAPI_AISObject::GeomAPI_AISObject()
     : GeomAPI_Interface(new Handle(AIS_InteractiveObject)())
 {
@@ -276,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)
@@ -300,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);
+  }
+}