X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketcherPrs%2FSketcherPrs_Tangent.cpp;h=09fa6810969a7673009619641eac5509701e2d34;hb=c1d1f617a04aacf5f0d6246c1b8dea72dd2d6093;hp=199eb782f8161ff7123909e695805e648292752e;hpb=27395bd5e5213d1c479d87191379515e2e60912c;p=modules%2Fshaper.git diff --git a/src/SketcherPrs/SketcherPrs_Tangent.cpp b/src/SketcherPrs/SketcherPrs_Tangent.cpp index 199eb782f..09fa68109 100644 --- a/src/SketcherPrs/SketcherPrs_Tangent.cpp +++ b/src/SketcherPrs/SketcherPrs_Tangent.cpp @@ -27,20 +27,35 @@ SketcherPrs_Tangent::SketcherPrs_Tangent(ModelAPI_Feature* theConstraint, const std::shared_ptr& thePlane) : SketcherPrs_SymbolPrs(theConstraint, thePlane) { + // Init default points myPntArray = new Graphic3d_ArrayOfPoints(2); myPntArray->AddVertex(0., 0., 0.); myPntArray->AddVertex(0., 0., 0.); } -bool SketcherPrs_Tangent::updatePoints(double theStep) const +bool SketcherPrs_Tangent::IsReadyToDisplay(ModelAPI_Feature* theConstraint, + const std::shared_ptr&/* thePlane*/) { + bool aReadyToDisplay = false; + + ObjectPtr aObj1 = SketcherPrs_Tools::getResult(theConstraint, SketchPlugin_Constraint::ENTITY_A()); + ObjectPtr aObj2 = SketcherPrs_Tools::getResult(theConstraint, SketchPlugin_Constraint::ENTITY_B()); + + aReadyToDisplay = SketcherPrs_Tools::getShape(aObj1).get() != NULL && + SketcherPrs_Tools::getShape(aObj2).get() != NULL; + + return aReadyToDisplay; +} + +bool SketcherPrs_Tangent::updateIfReadyToDisplay(double theStep) const +{ + if (!IsReadyToDisplay(myConstraint, myPlane)) + return false; + ObjectPtr aObj1 = SketcherPrs_Tools::getResult(myConstraint, SketchPlugin_Constraint::ENTITY_A()); ObjectPtr aObj2 = SketcherPrs_Tools::getResult(myConstraint, SketchPlugin_Constraint::ENTITY_B()); - if (SketcherPrs_Tools::getShape(aObj1).get() == NULL) - return false; - if (SketcherPrs_Tools::getShape(aObj2).get() == NULL) - return false; + // Compute points coordinates SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get(); gp_Pnt aP1 = aMgr->getPosition(aObj1, this, theStep); gp_Pnt aP2 = aMgr->getPosition(aObj2, this, theStep);