X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGeomAPI%2FGeomAPI_AISObject.cpp;h=7f2fd801116d550a4a2752e46ab45659a217ef85;hb=8f060aedd5949990421a96e3b4086f43efa13d24;hp=10d720c835520e431bc0583e1e7e6215c5049639;hpb=3a9418e989aabf61341c20e01628e43ca030c491;p=modules%2Fshaper.git diff --git a/src/GeomAPI/GeomAPI_AISObject.cpp b/src/GeomAPI/GeomAPI_AISObject.cpp index 10d720c83..7f2fd8011 100644 --- a/src/GeomAPI/GeomAPI_AISObject.cpp +++ b/src/GeomAPI/GeomAPI_AISObject.cpp @@ -44,7 +44,7 @@ GeomAPI_AISObject::GeomAPI_AISObject() GeomAPI_AISObject::~GeomAPI_AISObject() { if (!empty()) { - // This is necessary for correct deletion of Handle entity. + // This is necessary for correct deletion of Handle entity. // Without this Handle does not decremented counter to 0 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) @@ -142,7 +181,7 @@ void GeomAPI_AISObject::createRadius(std::shared_ptr theCircle, // TODO: a bug in AIS_RadiusDimension: // The anchor point can't be myCirc.Location() - an exception is raised. // But we need exactly this case... - // We want to show a radius dimension starting from the circle centre and + // We want to show a radius dimension starting from the circle centre and // ending at the user-defined point. // Also, if anchor point coincides with myP2, the radius dimension is not displayed at all. std::shared_ptr anAnchor = theCircle->project(theFlyoutPoint); @@ -280,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; @@ -325,6 +374,41 @@ void GeomAPI_AISObject::getColor(int& theR, int& theG, int& theB) theB = (int)(aColor.Blue()*255.); } +bool GeomAPI_AISObject::setDeflection(const double theDeflection) +{ + bool isModified = false; + Handle(AIS_InteractiveObject) anAIS = impl(); + if (!anAIS.IsNull()) { + Handle(AIS_Shape) anAISShape = Handle(AIS_Shape)::DownCast(anAIS); + if (!anAISShape.IsNull()) { + Standard_Real aCoefficient, aPreviousCoefficient; + anAISShape->OwnDeviationCoefficient(aCoefficient, aPreviousCoefficient); + if (fabs(aCoefficient-theDeflection) > Precision::Confusion()) { + isModified = true; + anAISShape->SetOwnDeviationCoefficient(theDeflection); + // redisplay is necessary here to update presentation in all modes + // Standard True flag. Displayer uses Standard False flag. If it will be changed in + // displayer, redisplay here will not be necessary. But performance should be checked. + anAISShape->Redisplay(Standard_True); + } + } + } + return isModified; +} + +double GeomAPI_AISObject::getDeflection() const +{ + double aDeflection = -1; + + Handle(AIS_InteractiveObject) anAIS = impl(); + if (!anAIS.IsNull()) { + Handle(Prs3d_Drawer) aDrawer = anAIS->Attributes(); + aDeflection = aDrawer->DeviationCoefficient(); + } + return aDeflection; +} + + bool GeomAPI_AISObject::empty() const { Handle(AIS_InteractiveObject) anAIS = const_cast(this) @@ -403,6 +487,8 @@ bool GeomAPI_AISObject::setTransparensy(double theVal) isChanged = aCurrentValue != theVal; if (isChanged) aContext->SetTransparency(anAIS, theVal, false); + } else { + anAIS->SetTransparency(theVal); } } return isChanged;