/// Event ID that the problem in solver disappeared
static const char * EVENT_SOLVER_REPAIRED = "SolverRepaired";
+/// Event Id that sketch has DoF = 0
+static const char * EVENT_SKETCH_FULLY_CONSTRAINED = "SketchFullyConstrainted";
+/// Event Id that sketch has DoF > 0
+static const char * EVENT_SKETCH_UNDER_CONSTRAINED = "SketchUnderConstrainted";
+/// Event Id that sketch has DoF < 0
+static const char * EVENT_SKETCH_OVER_CONSTRAINED = "SketchOverConstrainted";
+
/// Event ID that informs that some object has changed the stability
static const char * EVENT_STABILITY_CHANGED = "StabilityChanged";
Events_Loop::loop()->send(aMessage);
}
+static void sendMessage(const char* theMessageName, const CompositeFeaturePtr& theSketch, const int theDOF)
+{
+ std::shared_ptr<ModelAPI_SolverFailedMessage> aMessage =
+ std::shared_ptr<ModelAPI_SolverFailedMessage>(
+ new ModelAPI_SolverFailedMessage(Events_Loop::eventByName(theMessageName)));
+
+ std::set<ObjectPtr> anObjects;
+ anObjects.insert(theSketch);
+ aMessage->setObjects(anObjects);
+ aMessage->dof(theDOF);
+
+ Events_Loop::loop()->send(aMessage);
+}
+
// ========================================================
SketchSolver_Group::SketchSolver_Group(const CompositeFeaturePtr& theWorkplane)
: mySketch(theWorkplane),
myPrevResult(PlaneGCSSolver_Solver::STATUS_UNKNOWN),
+ myDOF(0),
myIsEventsBlocked(false)
{
mySketchSolver = SolverPtr(new PlaneGCSSolver_Solver);
bool SketchSolver_Group::moveFeature(FeaturePtr theFeature)
{
+ if (myDOF == 0) {
+ // avoid moving elements of fully constrained sketch
+ myStorage->refresh();
+ return true;
+ }
+
// Create temporary Fixed constraint
SolverConstraintPtr aConstraint = PlaneGCSSolver_Tools::createMovementConstraint(theFeature);
if (!aConstraint)
// Class: SketchSolver_Group
// Purpose: compute DoF of the sketch and set corresponding field
// ============================================================================
-void SketchSolver_Group::computeDoF() const
+void SketchSolver_Group::computeDoF()
{
std::ostringstream aDoFMsg;
- int aDoF = /*isEmpty() ? myStorage->numberOfParameters() :*/ mySketchSolver->dof();
+ int aDoF = mySketchSolver->dof();
if (aDoF == 0)
aDoFMsg << "Sketch is fully fixed (DoF = 0)";
else
aDoFMsg << "DoF (degrees of freedom) = " << aDoF;
mySketch->string(SketchPlugin_Sketch::SOLVER_DOF())->setValue(aDoFMsg.str());
+
+ if (aDoF > 0 && myDOF == 0)
+ sendMessage(EVENT_SKETCH_UNDER_CONSTRAINED, mySketch, aDoF);
+ else if (aDoF == 0 && myDOF > 0)
+ sendMessage(EVENT_SKETCH_FULLY_CONSTRAINED, mySketch, aDoF);
+ else if (aDoF < 0)
+ sendMessage(EVENT_SKETCH_OVER_CONSTRAINED, mySketch, aDoF);
+
+ myDOF = aDoF;
}
// ============================================================================
void setTemporary(SolverConstraintPtr theConstraint);
/// \brief Compute DoF of the sketch and set corresponding field
- void computeDoF() const;
+ void computeDoF();
private:
CompositeFeaturePtr mySketch; ///< Sketch for this group
PlaneGCSSolver_Solver::SolveStatus myPrevResult;
std::set<ObjectPtr> myConflictingConstraints; ///< List of conflicting constraints
+ int myDOF; ///< degrees of freedom of the current sketch
+
bool myIsEventsBlocked; ///< shows the events are blocked for this group
};