Sketcher: Update solver partially redundant constraint information in the solver messages

This commit is contained in:
Abdullah Tahiri
2021-01-19 11:27:42 +01:00
committed by abdullahtahiriyo
parent 436a807c87
commit 57a4f3e47c
3 changed files with 33 additions and 2 deletions

View File

@@ -116,6 +116,10 @@ void TaskSketcherMessages::on_labelConstrainStatus_linkActivated(const QString &
else
if( str == QString::fromLatin1("#malformed"))
Gui::Application::Instance->commandManager().runCommandByName("Sketcher_SelectMalformedConstraints");
else
if( str == QString::fromLatin1("#partiallyredundant"))
Gui::Application::Instance->commandManager().runCommandByName("Sketcher_SelectPartiallyRedundantConstraints");
}
void TaskSketcherMessages::on_autoUpdate_stateChanged(int state)

View File

@@ -6395,6 +6395,13 @@ QString ViewProviderSketch::appendRedundantMsg(const std::vector<int> &redundant
redundant);
}
QString ViewProviderSketch::appendPartiallyRedundantMsg(const std::vector<int> &partiallyredundant)
{
return appendConstraintMsg(tr("The following constraint is partially redundant:"),
tr("The following constraints are partially redundant:"),
partiallyredundant);
}
QString ViewProviderSketch::appendMalformedMsg(const std::vector<int> &malformed)
{
return appendConstraintMsg(tr("Please remove the following malformed constraint:"),
@@ -6429,6 +6436,7 @@ void ViewProviderSketch::UpdateSolverInformation()
int dofs = getSketchObject()->getLastDoF();
bool hasConflicts = getSketchObject()->getLastHasConflicts();
bool hasRedundancies = getSketchObject()->getLastHasRedundancies();
bool hasPartiallyRedundant = getSketchObject()->getLastHasPartialRedundancies();
bool hasMalformed = getSketchObject()->getLastHasMalformedConstraints();
if (getSketchObject()->Geometry.getSize() == 0) {
@@ -6476,10 +6484,27 @@ void ViewProviderSketch::UpdateSolverInformation()
}
}
else if (!hasRedundancies) {
QString infoString;
if (dofs == 1)
signalSetUp(tr("Under-constrained sketch with <a href=\"#dofs\"><span style=\" text-decoration: underline; color:#0000ff; background-color: #F8F8FF;\">1 degree</span></a> of freedom"));
infoString = tr("Under-constrained sketch with <a href=\"#dofs\"><span style=\" text-decoration: underline; color:#0000ff; background-color: #F8F8FF;\">1 degree</span></a> of freedom. %1")
.arg(hasPartiallyRedundant?
QString::fromLatin1("<br/><font color='orangered'>%1<a href=\"#partiallyredundant\"><span style=\" text-decoration: underline; color:#0000ff; background-color: #F8F8FF;\">%2</span></a><br/>%3</font><br/>")
.arg(tr("Sketch contains partially redundant constraints "))
.arg(tr("(click to select)"))
.arg(appendPartiallyRedundantMsg(getSketchObject()->getLastPartiallyRedundant()))
: QString());
else
signalSetUp(tr("Under-constrained sketch with <a href=\"#dofs\"><span style=\" text-decoration: underline; color:#0000ff; background-color: #F8F8FF;\">%1 degrees</span></a> of freedom").arg(dofs));
infoString = tr("Under-constrained sketch with <a href=\"#dofs\"><span style=\" text-decoration: underline; color:#0000ff; background-color: #F8F8FF;\">%1 degrees</span></a> of freedom. %2")
.arg(dofs)
.arg(hasPartiallyRedundant?
QString::fromLatin1("<br/><font color='orangered'>%1<a href=\"#partiallyredundant\"><span style=\" text-decoration: underline; color:#0000ff; background-color: #F8F8FF;\">%2</span></a><br/>%3</font><br/>")
.arg(tr("Sketch contains partially redundant constraints "))
.arg(tr("(click to select)"))
.arg(appendPartiallyRedundantMsg(getSketchObject()->getLastPartiallyRedundant()))
: QString());
signalSetUp(infoString);
}
signalSolved(QString::fromLatin1("<font color='green'><span style=\"color:#008000; background-color: #ececec;\">%1</font></span>").arg(tr("Solved in %1 sec").arg(getSketchObject()->getLastSolveTime())));

View File

@@ -94,6 +94,8 @@ class SketcherGuiExport ViewProviderSketch : public PartGui::ViewProvider2DObjec
static QString appendConflictMsg(const std::vector<int> &conflicting);
/// generates a warning message about redundant constraints and appends it to the given message
static QString appendRedundantMsg(const std::vector<int> &redundant);
/// generates a warning message about partially redundant constraints and appends it to the given message
static QString appendPartiallyRedundantMsg(const std::vector<int> &partiallyredundant);
/// generates a warning message about redundant constraints and appends it to the given message
static QString appendMalformedMsg(const std::vector<int> &redundant);