Salome HOME
Issue #1015: The validate icon must be greyed and inactive instead of red and active
[modules/shaper.git] / src / GeomAPI / GeomAPI_AISObject.cpp
index b8b5a7b2252bbbf4b6a4736f9ebf9ccadf371144..3f7646688b80eab7f6c9736522d5c8b05eec0de3 100644 (file)
@@ -83,6 +83,22 @@ void GeomAPI_AISObject::createShape(std::shared_ptr<GeomAPI_Shape> theShape)
   }
 }
 
+std::shared_ptr<GeomAPI_Shape> GeomAPI_AISObject::getShape() const
+{
+  std::shared_ptr<GeomAPI_Shape> aResult;
+
+  Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
+  if (!anAIS.IsNull()) {
+    Handle(AIS_Shape) aShapeAIS = Handle(AIS_Shape)::DownCast(anAIS);
+    if (aShapeAIS) {
+      std::shared_ptr<GeomAPI_Shape> aResult(new GeomAPI_Shape);
+      aResult->setImpl(new TopoDS_Shape(aShapeAIS->Shape()));
+      return aResult;
+    }
+  }
+  return std::shared_ptr<GeomAPI_Shape>();
+}
+
 void GeomAPI_AISObject::createDistance(std::shared_ptr<GeomAPI_Pnt> theStartPoint,
                                        std::shared_ptr<GeomAPI_Pnt> theEndPoint,
                                        std::shared_ptr<GeomAPI_Pnt> theFlyoutPoint,
@@ -141,6 +157,21 @@ void GeomAPI_AISObject::createDistance(std::shared_ptr<GeomAPI_Pnt> theStartPoin
   }
 }
 
+bool GeomAPI_AISObject::isEmptyDistanceGeometry()
+{
+  bool anEmpty = false;
+
+  Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
+  if (!anAIS.IsNull()) {
+    Handle(AIS_LengthDimension) aDimAIS = Handle(AIS_LengthDimension)::DownCast(anAIS);
+    if (!aDimAIS.IsNull()) {
+      anEmpty = !aDimAIS->IsValid();
+    }
+  }
+
+  return anEmpty;
+}
+
 void GeomAPI_AISObject::createRadius(std::shared_ptr<GeomAPI_Circ> theCircle,
                                      std::shared_ptr<GeomAPI_Pnt> theFlyoutPoint,
                                      double theRadius)
@@ -288,6 +319,16 @@ void GeomAPI_AISObject::setColor(const int& theColor)
   aContext->SetColor(anAIS, aColor, false);
 }
 
+double GeomAPI_AISObject::width()
+{
+  double aWidth = 0.0;
+  Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
+  if (!anAIS.IsNull()) {
+    aWidth = anAIS->Width();
+  }
+  return aWidth;
+}
+
 bool GeomAPI_AISObject::setWidth(const double& theWidth)
 {
   bool isChanged = false;
@@ -411,6 +452,8 @@ bool GeomAPI_AISObject::setTransparensy(double theVal)
       isChanged = aCurrentValue != theVal;
       if (isChanged)
         aContext->SetTransparency(anAIS, theVal, false);
+    } else {
+      anAIS->SetTransparency(theVal);
     }
   }
  return isChanged;