Skip to content

Commit

Permalink
Sketcher: encapsulate Sketch::SolveTime and RecalculateInitialSolutio…
Browse files Browse the repository at this point in the history
…nWhileMovingPoint members
  • Loading branch information
abdullahtahiriyo committed Dec 27, 2020
1 parent 18ecd17 commit 733b7bd
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
13 changes: 13 additions & 0 deletions src/Mod/Sketcher/App/Sketch.h
Expand Up @@ -104,6 +104,8 @@ class SketcherExport Sketch :public Base::Persistence
inline bool hasRedundancies(void) const { return !Redundant.empty(); }
inline const std::vector<int> &getRedundant(void) const { return Redundant; }

inline float getSolveTime() const { return SolveTime; }

inline bool hasMalformedConstraints(void) const { return malformedConstraints; }
public:
std::set < std::pair< int, Sketcher::PointPos>> getDependencyGroup(int geoId, PointPos pos) const;
Expand Down Expand Up @@ -132,6 +134,16 @@ class SketcherExport Sketch :public Base::Persistence
*/
int movePoint(int geoId, PointPos pos, Base::Vector3d toPoint, bool relative=false);

/**
* Sets whether the initial solution should be recalculated while dragging after a certain distance from the previous drag point
* for smoother dragging operation.
*/
bool getRecalculateInitialSolutionWhileMovingPoint() const
{return RecalculateInitialSolutionWhileMovingPoint;}

void setRecalculateInitialSolutionWhileMovingPoint(bool recalculateInitialSolutionWhileMovingPoint)
{RecalculateInitialSolutionWhileMovingPoint = recalculateInitialSolutionWhileMovingPoint;}

/// add dedicated geometry
//@{
/// add a point
Expand Down Expand Up @@ -378,6 +390,7 @@ class SketcherExport Sketch :public Base::Persistence
BSpline = 9
};

protected:
float SolveTime;
bool RecalculateInitialSolutionWhileMovingPoint;

Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Sketcher/App/SketchObject.cpp
Expand Up @@ -294,7 +294,7 @@ int SketchObject::solve(bool updateGeoAfterSolving/*=true*/)
Base::Console().Error("Sketch %s has malformed constraints!\n",this->getNameInDocument());
}

lastSolveTime=solvedSketch.SolveTime;
lastSolveTime=solvedSketch.getSolveTime();

if (err == 0 && updateGeoAfterSolving) {
// set the newly solved geometry
Expand Down
10 changes: 5 additions & 5 deletions src/Mod/Sketcher/Gui/ViewProviderSketch.cpp
Expand Up @@ -1276,9 +1276,9 @@ bool ViewProviderSketch::mouseMove(const SbVec2s &cursorPos, Gui::View3DInventor
if (getSketchObject()->getSolvedSketch().movePoint(GeoId, PosId, vec, false) == 0) {
setPositionText(Base::Vector2d(x,y));
draw(true,false);
signalSolved(QString::fromLatin1("Solved in %1 sec").arg(getSketchObject()->getSolvedSketch().SolveTime));
signalSolved(QString::fromLatin1("Solved in %1 sec").arg(getSketchObject()->getSolvedSketch().getSolveTime()));
} else {
signalSolved(QString::fromLatin1("Unsolved (%1 sec)").arg(getSketchObject()->getSolvedSketch().SolveTime));
signalSolved(QString::fromLatin1("Unsolved (%1 sec)").arg(getSketchObject()->getSolvedSketch().getSolveTime()));
//Base::Console().Log("Error solving:%d\n",ret);
}
}
Expand Down Expand Up @@ -1317,9 +1317,9 @@ bool ViewProviderSketch::mouseMove(const SbVec2s &cursorPos, Gui::View3DInventor
if (getSketchObject()->getSolvedSketch().movePoint(edit->DragCurve, Sketcher::none, vec, relative) == 0) {
setPositionText(Base::Vector2d(x,y));
draw(true,false);
signalSolved(QString::fromLatin1("Solved in %1 sec").arg(getSketchObject()->getSolvedSketch().SolveTime));
signalSolved(QString::fromLatin1("Solved in %1 sec").arg(getSketchObject()->getSolvedSketch().getSolveTime()));
} else {
signalSolved(QString::fromLatin1("Unsolved (%1 sec)").arg(getSketchObject()->getSolvedSketch().SolveTime));
signalSolved(QString::fromLatin1("Unsolved (%1 sec)").arg(getSketchObject()->getSolvedSketch().getSolveTime()));
}
}
return true;
Expand Down Expand Up @@ -6255,7 +6255,7 @@ bool ViewProviderSketch::setEdit(int ModNum)
// Enable solver initial solution update while dragging.
ParameterGrp::handle hGrp2 = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");

getSketchObject()->getSolvedSketch().RecalculateInitialSolutionWhileMovingPoint = hGrp2->GetBool("RecalculateInitialSolutionWhileDragging",true);
getSketchObject()->getSolvedSketch().setRecalculateInitialSolutionWhileMovingPoint(hGrp2->GetBool("RecalculateInitialSolutionWhileDragging",true));


// intercept del key press from main app
Expand Down

0 comments on commit 733b7bd

Please sign in to comment.