Skip to content

Commit

Permalink
Sketcher: ViewProvider fix Weight length when dragging
Browse files Browse the repository at this point in the history
  • Loading branch information
abdullahtahiriyo committed Dec 12, 2020
1 parent a9605dc commit c210891
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/Mod/Sketcher/Gui/ViewProviderSketch.cpp
Expand Up @@ -1401,10 +1401,28 @@ void ViewProviderSketch::moveConstraint(int constNum, const Base::Vector2d &toPo
Base::Vector3d tmpDir = Base::Vector3d(toPos.x, toPos.y, 0) - p1;
double angle = atan2(tmpDir.y, tmpDir.x);

Base::Vector3d dir = radius * Base::Vector3d(cos(angle),sin(angle),0.);

if(Constr->Type == Sketcher::Diameter)
p1 = center - radius * Base::Vector3d(cos(angle),sin(angle),0.);
p1 = center - dir;

p2 = center + radius * Base::Vector3d(cos(angle),sin(angle),0.);
if(Constr->Type == Sketcher::Weight) {

double scalefactor = 1.0;

if(circle->hasExtension(SketcherGui::ViewProviderSketchGeometryExtension::getClassTypeId()))
{
auto vpext = std::static_pointer_cast<const SketcherGui::ViewProviderSketchGeometryExtension>(
circle->getExtension(SketcherGui::ViewProviderSketchGeometryExtension::getClassTypeId()).lock());

scalefactor = vpext->getRepresentationFactor();
}

p2 = center + dir * scalefactor;

}
else
p2 = center + dir;
}
else
return;
Expand Down

0 comments on commit c210891

Please sign in to comment.