Sketcher: restric ViewProviderSketch access to the solver
========================================================= -> Split read and read/write operations New interface to access the solver object (Sketch) of SketchObject is now read only (const): const Sketcher::Sketch &getSolvedSketch(void) const; -> Encapsulate solver r/w access in SketchObject Rationale: - r/w access (access to non-const functions of the solver) leads to unsynchronised solver status. - Before this commit there was a non-enforceable shared responsibility between ViewProviderSketch and SketchObject. - This commit centralises r/w access in SketchObject and SketchObject takes responsibility for doing whatever necessary so that the solver is synchronised as appropriate. - For read-only access (const functions) it is possible to use at ViewProviderSketch getSolvedSketch() returning a const reference to the solver object. - As it regards the advanced solver configuration dialog, it has been modified to configure by const-casting that reference. This is not optimal, but it is deemed acceptable, because it should be rewritten sooner or later to include only useful information and the configuration probably centralised in an individual configuration object, possibly compatible with several solvers (e.g. DeepSOIC's ConstraintSolver too).
This commit is contained in:
committed by
abdullahtahiriyo
parent
5c8e65728f
commit
04bbae80cf
@@ -353,9 +353,23 @@ public:
|
||||
inline const std::vector<int> &getLastConflicting(void) const { return lastConflicting; }
|
||||
/// gets the redundant constraints of last solver execution
|
||||
inline const std::vector<int> &getLastRedundant(void) const { return lastRedundant; }
|
||||
/// gets the solved sketch as a reference
|
||||
inline Sketch &getSolvedSketch(void) {return solvedSketch;}
|
||||
|
||||
public: /* Solver exposed interface */
|
||||
/// gets the solved sketch as a reference
|
||||
inline const Sketch &getSolvedSketch(void) const {return solvedSketch;}
|
||||
/// enables/disables solver initial solution recalculation when moving point mode (useful for dragging)
|
||||
inline void setRecalculateInitialSolutionWhileMovingPoint(bool recalculateInitialSolutionWhileMovingPoint)
|
||||
{solvedSketch.setRecalculateInitialSolutionWhileMovingPoint(recalculateInitialSolutionWhileMovingPoint);}
|
||||
/// Forwards a request for a temporary initMove to the solver using the current sketch state as a reference (enables dragging)
|
||||
inline int initTemporaryMove(int geoId, PointPos pos, bool fine=true)
|
||||
{ return solvedSketch.initMove(geoId,pos,fine);}
|
||||
/// Forwards a request for point or curve temporary movement to the solver using the current state as a reference (enables dragging)
|
||||
inline int moveTemporaryPoint(int geoId, PointPos pos, Base::Vector3d toPoint, bool relative=false)
|
||||
{ return solvedSketch.movePoint(geoId, pos, toPoint, relative);}
|
||||
inline void updateSolverExtension(int geoId, std::unique_ptr<Part::GeometryExtension> && ext)
|
||||
{ return solvedSketch.updateExtension(geoId, std::move(ext));}
|
||||
|
||||
public:
|
||||
/// returns the geometric elements/vertex which the solver detects as having dependent parameters.
|
||||
/// these parameters relate to not fully constraint edges/vertices.
|
||||
void getGeometryWithDependentParameters(std::vector<std::pair<int,PointPos>>& geometrymap);
|
||||
|
||||
Reference in New Issue
Block a user