X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGeomAPI%2FGeomAPI_AISObject.cpp;h=3f7646688b80eab7f6c9736522d5c8b05eec0de3;hb=73502ac782ffc45a3acf665ded34f582b07ec4d5;hp=8c98c449c7e00649db5b8d681703c8d9b3db30bb;hpb=5e9152f6da5141e26c07727e26a0ec89255ade87;p=modules%2Fshaper.git diff --git a/src/GeomAPI/GeomAPI_AISObject.cpp b/src/GeomAPI/GeomAPI_AISObject.cpp index 8c98c449c..3f7646688 100644 --- a/src/GeomAPI/GeomAPI_AISObject.cpp +++ b/src/GeomAPI/GeomAPI_AISObject.cpp @@ -43,10 +43,10 @@ GeomAPI_AISObject::GeomAPI_AISObject() GeomAPI_AISObject::~GeomAPI_AISObject() { - if (myImpl) { + if (!empty()) { // 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; + Handle(AIS_InteractiveObject) *anAIS = implPtr(); anAIS->Nullify(); } } @@ -71,8 +71,32 @@ void GeomAPI_AISObject::createShape(std::shared_ptr theShape) aShapeAIS->Set(aTDS); aShapeAIS->Redisplay(Standard_True); } - } else - setImpl(new Handle(AIS_InteractiveObject)(new AIS_Shape(aTDS))); + } else { + // Set default point as a '+' symbol + Handle(AIS_Shape) aShape = new AIS_Shape(aTDS); + Handle(Prs3d_Drawer) aDrawer = aShape->Attributes(); + if (aDrawer->HasOwnPointAspect()) + aDrawer->PointAspect()->SetTypeOfMarker(Aspect_TOM_PLUS); + else + aDrawer->SetPointAspect(new Prs3d_PointAspect(Aspect_TOM_PLUS, Quantity_NOC_YELLOW, 1.)); + setImpl(new Handle(AIS_InteractiveObject)(aShape)); + } +} + +std::shared_ptr GeomAPI_AISObject::getShape() const +{ + std::shared_ptr aResult; + + Handle(AIS_InteractiveObject) anAIS = impl(); + if (!anAIS.IsNull()) { + Handle(AIS_Shape) aShapeAIS = Handle(AIS_Shape)::DownCast(anAIS); + if (aShapeAIS) { + std::shared_ptr aResult(new GeomAPI_Shape); + aResult->setImpl(new TopoDS_Shape(aShapeAIS->Shape())); + return aResult; + } + } + return std::shared_ptr(); } void GeomAPI_AISObject::createDistance(std::shared_ptr theStartPoint, @@ -133,6 +157,21 @@ void GeomAPI_AISObject::createDistance(std::shared_ptr theStartPoin } } +bool GeomAPI_AISObject::isEmptyDistanceGeometry() +{ + bool anEmpty = false; + + Handle(AIS_InteractiveObject) anAIS = impl(); + 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 theCircle, std::shared_ptr theFlyoutPoint, double theRadius) @@ -272,7 +311,6 @@ void GeomAPI_AISObject::setColor(const int& theColor) if (anAIS.IsNull()) return; Quantity_Color aColor((Quantity_NameOfColor) theColor); - anAIS->SetColor(aColor); Handle(AIS_Dimension) aDimAIS = Handle(AIS_Dimension)::DownCast(anAIS); if (!aDimAIS.IsNull()) { aDimAIS->DimensionAspect()->SetCommonColor(aColor); @@ -281,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(); + if (!anAIS.IsNull()) { + aWidth = anAIS->Width(); + } + return aWidth; +} + bool GeomAPI_AISObject::setWidth(const double& theWidth) { bool isChanged = false; @@ -305,7 +353,6 @@ bool GeomAPI_AISObject::setColor(int theR, int theG, int theB) if (aColor.IsEqual(aCurrentColor)) return false; - anAIS->SetColor(aColor); Handle(AIS_Dimension) aDimAIS = Handle(AIS_Dimension)::DownCast(anAIS); if (!aDimAIS.IsNull()) { aDimAIS->DimensionAspect()->SetCommonColor(aColor); @@ -343,7 +390,9 @@ int GeomAPI_AISObject::getShapeType() const if (!anAIS.IsNull()) { Handle(AIS_Shape) aAISShape = Handle(AIS_Shape)::DownCast(anAIS); if (!aAISShape.IsNull()) { - return aAISShape->Shape().ShapeType(); + const TopoDS_Shape aShape = aAISShape->Shape(); + if (!aShape.IsNull()) + return aShape.ShapeType(); } } return -1; @@ -392,21 +441,6 @@ bool GeomAPI_AISObject::setLineStyle(int theStyle) return isChanged; } -bool GeomAPI_AISObject::setInfiniteState(const bool theState) -{ - bool isChanged = false; - Handle(AIS_InteractiveObject) anAIS = impl(); - if (!anAIS.IsNull() && anAIS->IsInfinite() != theState) { - anAIS->SetInfiniteState(theState); - isChanged = true; - - bool isInfinite = anAIS->IsInfinite(); - int aValue = 9; - } - return isChanged; -} - - bool GeomAPI_AISObject::setTransparensy(double theVal) { bool isChanged = false; @@ -418,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;