-// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2023 CEA, EDF
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
int theSketchDOF,
bool theEventsBlocked,
Type theFeatureOrPoint,
+ const EntityWrapperPtr& theSolverEntity,
const std::shared_ptr<GeomAPI_Pnt2d>& theFrom,
const std::shared_ptr<GeomAPI_Pnt2d>& theTo)
{
- bool isEntityExists = (theStorage->entity(theFeatureOrPoint).get() != 0);
+ bool isEntityExists = (theSolverEntity.get() != 0);
if (theSketchDOF == 0 && isEntityExists) {
// avoid moving elements of fully constrained sketch
theStorage->refresh();
const std::shared_ptr<GeomAPI_Pnt2d>& theFrom,
const std::shared_ptr<GeomAPI_Pnt2d>& theTo)
{
- SolverConstraintPtr aConstraint =
- move(myStorage, mySketchSolver, myDOF, myIsEventsBlocked, theFeature, theFrom, theTo);
+ EntityWrapperPtr anEntity = myStorage->entity(theFeature);
+ SolverConstraintPtr aConstraint = move(myStorage, mySketchSolver, myDOF, myIsEventsBlocked,
+ theFeature, anEntity, theFrom, theTo);
setTemporary(aConstraint);
return true;
}
bool SketchSolver_Group::movePoint(AttributePtr theAttribute,
+ const int thePointIndex,
const std::shared_ptr<GeomAPI_Pnt2d>& theFrom,
const std::shared_ptr<GeomAPI_Pnt2d>& theTo)
{
- SolverConstraintPtr aConstraint =
- move(myStorage, mySketchSolver, myDOF, myIsEventsBlocked, theAttribute, theFrom, theTo);
+ EntityWrapperPtr anEntity = myStorage->entity(theAttribute);
+ SolverConstraintPtr aConstraint;
+ if (thePointIndex < 0) {
+ aConstraint = move(myStorage, mySketchSolver, myDOF, myIsEventsBlocked,
+ theAttribute, anEntity, theFrom, theTo);
+ }
+ else {
+ aConstraint = move(myStorage, mySketchSolver, myDOF, myIsEventsBlocked,
+ std::pair<AttributePtr, int>(theAttribute, thePointIndex), anEntity,
+ theFrom, theTo);
+ }
setTemporary(aConstraint);
return true;
}
}
}
- // show degrees of freedom only if the degenerated geometry appears
- if (aResult == PlaneGCSSolver_Solver::STATUS_DEGENERATED)
+ // show degrees of freedom only if the degenerated geometry appears,
+ // or if DoF is not computed yet
+ if (aResult == PlaneGCSSolver_Solver::STATUS_DEGENERATED || myDOF < 0)
computeDoF();
}
// ============================================================================
void SketchSolver_Group::computeDoF()
{
- std::ostringstream aDoFMsg;
+ std::string aDoFMsg;
static const std::string aMsgContext("Sketch");
int aDoF = mySketchSolver->dof();
/// "DoF = 0" content of string value is used in PartSet by Sketch edit
/// If it is changed, it should be corrected also there
- if (aDoF == 0) {
- static const std::string aMsgDoF("Sketch is fully fixed (DoF = 0)");
- aDoFMsg << Config_Translator::translate(aMsgContext, aMsgDoF).c_str();
- } else {
- static const std::string aMsgDoF("DoF (degrees of freedom) = %1");
- Events_InfoMessage aMsg(aMsgContext, aMsgDoF);
- aMsg.arg(aDoF);
- aDoFMsg << Config_Translator::translate(aMsg).c_str();
- }
- mySketch->string(SketchPlugin_Sketch::SOLVER_DOF())->setValue(aDoFMsg.str());
+ //if (aDoF == 0) {
+ // static const std::string aMsgDoF("Sketch is fully fixed (DoF = 0)");
+ // aDoFMsg = Config_Translator::translate(aMsgContext, aMsgDoF);
+ //} else {
+ // static const std::string aMsgDoF("DoF (degrees of freedom) = %1");
+ // Events_InfoMessage aMsg(aMsgContext, aMsgDoF);
+ // aMsg.addParameter(aDoF);
+ // aDoFMsg = Config_Translator::translate(aMsg);
+ //}
+ //// store Unicode value for translated message about DoF
+ //size_t aLen = aDoFMsg.size();
+ //std::wstring aWStr(aLen, L'#');
+ //mbstowcs(&aWStr[0], aDoFMsg.c_str(), aLen);
+ //mySketch->string(SketchPlugin_Sketch::SOLVER_DOF())->setValue(aWStr);
+
+ std::ostringstream aStr;
+ aStr << aDoF;
+ mySketch->string(SketchPlugin_Sketch::SOLVER_DOF())->setValue(aStr.str());
if (aDoF > 0 && myDOF <= 0)
sendMessage(EVENT_SKETCH_UNDER_CONSTRAINED, mySketch, aDoF);
return false;
return true;
}
+
+void SketchSolver_Group::underconstrainedFeatures(std::set<ObjectPtr>& theFeatures) const
+{
+ myStorage->getUnderconstrainedGeometry(theFeatures);
+}