Salome HOME
Issue #555 - Make a number of shifted/rotated copies - selected object does not appea...
[modules/shaper.git] / src / GeomAPI / GeomAPI_AISObject.cpp
index fb90ceccb6d06672058670f36bc40dc4b5d9a287..681926a68d3439c3235d0657e34e8bfa949167aa 100644 (file)
@@ -41,6 +41,17 @@ GeomAPI_AISObject::GeomAPI_AISObject()
 {
 }
 
+GeomAPI_AISObject::~GeomAPI_AISObject()
+{
+  if (myImpl) {
+    // This is necessary for correct deletion of Handle entity. 
+    // Without this Handle does not decremented counter to 0
+    Handle(AIS_InteractiveObject) *anAIS = (Handle(AIS_InteractiveObject)*)myImpl;
+    anAIS->Nullify();
+  }
+}
+
+
 void GeomAPI_AISObject::createShape(std::shared_ptr<GeomAPI_Shape> theShape)
 {
   const TopoDS_Shape& aTDS =
@@ -98,9 +109,9 @@ void GeomAPI_AISObject::createDistance(std::shared_ptr<GeomAPI_Pnt> theStartPoin
 
     Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect();
     anAspect->MakeArrows3d(Standard_False);
-    anAspect->MakeText3d(false);
+    anAspect->MakeText3d(Standard_False);
     anAspect->TextAspect()->SetHeight(CONSTRAINT_TEXT_HEIGHT);
-    anAspect->MakeTextShaded(false);
+    anAspect->MakeTextShaded(Standard_True);
     anAspect->ArrowAspect()->SetLength(theDistance / 10.);
     aDimAIS->DimensionAspect()->MakeUnitsDisplayed(false);
     aDimAIS->SetDimensionAspect(anAspect);
@@ -311,9 +322,9 @@ void GeomAPI_AISObject::getColor(int& theR, int& theG, int& theB)
     return;
 
   Quantity_Color aColor = anAIS->Color();
-  theR = aColor.Red()*255.;
-  theG = aColor.Green()*255.;
-  theB = aColor.Blue()*255.;
+  theR = (int)(aColor.Red()*255.);
+  theG = (int)(aColor.Green()*255.);
+  theB = (int)(aColor.Blue()*255.);
 }
 
 bool GeomAPI_AISObject::empty() const
@@ -342,8 +353,8 @@ 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_Drawer) aDrawer = anAIS->Attributes();
+    if (aDrawer->HasOwnPointAspect()) {
       Handle(Prs3d_PointAspect) aPA = aDrawer->PointAspect();
       aPA->SetTypeOfMarker((Aspect_TypeOfMarker)theType);
       aPA->SetScale(theScale);
@@ -359,14 +370,14 @@ bool GeomAPI_AISObject::setLineStyle(int theStyle)
   bool isChanged = false;
   Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
   if (!anAIS.IsNull()) {
-    Handle(AIS_Drawer) aDrawer = anAIS->Attributes();
+    Handle(Prs3d_Drawer) aDrawer = anAIS->Attributes();
     Handle(Prs3d_LineAspect) aLineAspect;
 
     Aspect_TypeOfLine aType = (Aspect_TypeOfLine)theStyle;
-    if (aDrawer->HasLineAspect()) {
+    if (aDrawer->HasOwnLineAspect()) {
       aLineAspect = aDrawer->LineAspect();
     }
-    if (aDrawer->HasWireAspect()) {
+    if (aDrawer->HasOwnWireAspect()) {
       aLineAspect = aDrawer->WireAspect();
     }
     Quantity_Color aCurrentColor;
@@ -381,7 +392,6 @@ bool GeomAPI_AISObject::setLineStyle(int theStyle)
   return isChanged;
 }
 
-
 bool GeomAPI_AISObject::setTransparensy(double theVal)
 {
   bool isChanged = false;