Sketcher: simplify sketch solver messages
This commit is contained in:
parent
1e60d45dd4
commit
d92f627a8d
|
@ -1393,10 +1393,14 @@ void SketchObject::appendConflictMsg(const std::vector<int> &conflicting, std::s
|
|||
if (msg.length() > 0)
|
||||
ss << msg;
|
||||
if (conflicting.size() > 0) {
|
||||
ss << "Please remove at least one of the constraints (" << conflicting[0];
|
||||
if (conflicting.size() == 1)
|
||||
ss << "Please remove the following constraint:\n";
|
||||
else
|
||||
ss << "Please remove at least one of the following constraints:\n";
|
||||
ss << conflicting[0];
|
||||
for (unsigned int i=1; i < conflicting.size(); i++)
|
||||
ss << ", " << conflicting[i];
|
||||
ss << ")\n";
|
||||
ss << "\n";
|
||||
}
|
||||
msg = ss.str();
|
||||
}
|
||||
|
@ -1407,7 +1411,11 @@ void SketchObject::appendRedundantMsg(const std::vector<int> &redundant, std::st
|
|||
if (msg.length() > 0)
|
||||
ss << msg;
|
||||
if (redundant.size() > 0) {
|
||||
ss << "The following constraints were identified as redundant and should be removed:\n" << redundant[0];
|
||||
if (redundant.size() == 1)
|
||||
ss << "Please remove the following redundant constraint:\n";
|
||||
else
|
||||
ss << "Please remove the following redundant constraints:\n";
|
||||
ss << redundant[0];
|
||||
for (unsigned int i=1; i < redundant.size(); i++)
|
||||
ss << ", " << redundant[i];
|
||||
ss << "\n";
|
||||
|
|
|
@ -54,8 +54,8 @@ TaskSketcherMessages::TaskSketcherMessages(ViewProviderSketch *sketchView)
|
|||
|
||||
this->groupLayout()->addWidget(proxy);
|
||||
|
||||
connectionSetUp = sketchView->signalSetUp.connect(boost::bind(&SketcherGui::TaskSketcherMessages::slotSetUp, this,_1,_2,_3));
|
||||
connectionSolved = sketchView->signalSolved.connect(boost::bind(&SketcherGui::TaskSketcherMessages::slotSolved, this,_1,_2));
|
||||
connectionSetUp = sketchView->signalSetUp.connect(boost::bind(&SketcherGui::TaskSketcherMessages::slotSetUp, this,_1));
|
||||
connectionSolved = sketchView->signalSolved.connect(boost::bind(&SketcherGui::TaskSketcherMessages::slotSolved, this,_1));
|
||||
}
|
||||
|
||||
TaskSketcherMessages::~TaskSketcherMessages()
|
||||
|
@ -65,46 +65,14 @@ TaskSketcherMessages::~TaskSketcherMessages()
|
|||
delete ui;
|
||||
}
|
||||
|
||||
void TaskSketcherMessages::slotSetUp(int type, int dofs, const std::string &msg)
|
||||
void TaskSketcherMessages::slotSetUp(QString msg)
|
||||
{
|
||||
switch(type){
|
||||
case -1:
|
||||
ui->labelConstrainStatus->setText(QString::fromLatin1("Empty sketch"));
|
||||
break;
|
||||
case 0:
|
||||
ui->labelConstrainStatus->setText(QString::fromLatin1("<font color='green'>Fully constrained sketch </font>"));
|
||||
break;
|
||||
case 1:
|
||||
if (dofs==1)
|
||||
ui->labelConstrainStatus->setText(QString::fromLatin1("Under-constrained sketch with 1 degree of freedom"));
|
||||
else
|
||||
ui->labelConstrainStatus->setText(QString::fromLatin1("Under-constrained sketch with %1 degrees of freedom").arg(dofs));
|
||||
break;
|
||||
case 2:
|
||||
ui->labelConstrainStatus->setText(QString::fromLatin1("<font color='red'>Sketch contains conflicting constraints<br/>%1</font>").arg(QString::fromStdString(msg)));
|
||||
break;
|
||||
case 3:
|
||||
ui->labelConstrainStatus->setText(QString::fromLatin1("<font color='red'>Over-constrained sketch<br/>%1</font>").arg(QString::fromStdString(msg)));
|
||||
break;
|
||||
case 4:
|
||||
ui->labelConstrainStatus->setText(QString::fromLatin1("Sketch contains redundant constraints<br/>%1").arg(QString::fromStdString(msg)));
|
||||
break;
|
||||
}
|
||||
ui->labelConstrainStatus->setText(msg);
|
||||
}
|
||||
|
||||
void TaskSketcherMessages::slotSolved(int type, float time)
|
||||
void TaskSketcherMessages::slotSolved(QString msg)
|
||||
{
|
||||
switch(type){
|
||||
case -1:
|
||||
ui->labelSolverStatus->setText(QString());
|
||||
break;
|
||||
case 0:
|
||||
ui->labelSolverStatus->setText(QString::fromLatin1("Solved in %1 sec").arg(time));
|
||||
break;
|
||||
case 1:
|
||||
ui->labelSolverStatus->setText(QString::fromLatin1("Unsolved (%1)").arg(time));
|
||||
break;
|
||||
}
|
||||
ui->labelSolverStatus->setText(msg);
|
||||
}
|
||||
|
||||
#include "moc_TaskSketcherMessages.cpp"
|
||||
|
|
|
@ -47,8 +47,8 @@ public:
|
|||
TaskSketcherMessages(ViewProviderSketch *sketchView);
|
||||
~TaskSketcherMessages();
|
||||
|
||||
void slotSetUp(int type, int dofs, const std::string &msg);
|
||||
void slotSolved(int type, float time);
|
||||
void slotSetUp(QString msg);
|
||||
void slotSolved(QString msg);
|
||||
|
||||
private Q_SLOTS:
|
||||
|
||||
|
|
|
@ -822,9 +822,9 @@ bool ViewProviderSketch::mouseMove(const SbVec3f &point, const SbVec3f &normal,
|
|||
if (edit->ActSketch.movePoint(GeoId, PosId, vec, relative) == 0) {
|
||||
setPositionText(Base::Vector2D(x,y));
|
||||
draw(true);
|
||||
signalSolved(0, edit->ActSketch.SolveTime);
|
||||
signalSolved(QString::fromLatin1("Solved in %1 sec").arg(edit->ActSketch.SolveTime));
|
||||
} else {
|
||||
signalSolved(1, edit->ActSketch.SolveTime);
|
||||
signalSolved(QString::fromLatin1("Unsolved (%1 sec)").arg(edit->ActSketch.SolveTime));
|
||||
//Base::Console().Log("Error solving:%d\n",ret);
|
||||
}
|
||||
}
|
||||
|
@ -835,9 +835,9 @@ bool ViewProviderSketch::mouseMove(const SbVec3f &point, const SbVec3f &normal,
|
|||
if (edit->ActSketch.movePoint(edit->DragCurve, Sketcher::none, vec, relative) == 0) {
|
||||
setPositionText(Base::Vector2D(x,y));
|
||||
draw(true);
|
||||
signalSolved(0, edit->ActSketch.SolveTime);
|
||||
signalSolved(QString::fromLatin1("Solved in %1 sec").arg(edit->ActSketch.SolveTime));
|
||||
} else {
|
||||
signalSolved(1, edit->ActSketch.SolveTime);
|
||||
signalSolved(QString::fromLatin1("Unsolved (%1 sec)").arg(edit->ActSketch.SolveTime));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -2808,46 +2808,48 @@ void ViewProviderSketch::solveSketch(void)
|
|||
int dofs = edit->ActSketch.setUpSketch(getSketchObject()->getCompleteGeometry(),
|
||||
getSketchObject()->Constraints.getValues(),
|
||||
getSketchObject()->getExternalGeometryCount());
|
||||
std::string msg;
|
||||
if (getSketchObject()->Geometry.getSize() == 0) {
|
||||
signalSetUp(-1, 0, msg);
|
||||
signalSolved(-1, 0);
|
||||
signalSetUp(QString::fromLatin1("Empty sketch"));
|
||||
signalSolved(QString());
|
||||
}
|
||||
else if (dofs < 0) { // over-constrained sketch
|
||||
std::string msg;
|
||||
SketchObject::appendConflictMsg(edit->ActSketch.getConflicting(), msg);
|
||||
//Base::Console().Warning("Over-constrained sketch\n%s",msg.c_str());
|
||||
signalSetUp(3, 0, msg);
|
||||
signalSolved(-1, 0);
|
||||
signalSetUp(QString::fromLatin1("<font color='red'>Over-constrained sketch<br/>%1</font>")
|
||||
.arg(QString::fromStdString(msg)));
|
||||
signalSolved(QString());
|
||||
}
|
||||
else if (edit->ActSketch.hasConflicts()) { // conflicting constraints
|
||||
std::string msg;
|
||||
SketchObject::appendConflictMsg(edit->ActSketch.getConflicting(), msg);
|
||||
//Base::Console().Warning("Sketch with conflicting constraints\n%s",msg.c_str());
|
||||
signalSetUp(2, dofs, msg);
|
||||
signalSolved(-1, 0);
|
||||
signalSetUp(QString::fromLatin1("<font color='red'>Sketch contains conflicting constraints<br/>%1</font>")
|
||||
.arg(QString::fromStdString(msg)));
|
||||
signalSolved(QString());
|
||||
}
|
||||
else {
|
||||
if (edit->ActSketch.hasRedundancies()) { // redundant constraints
|
||||
std::string msg;
|
||||
SketchObject::appendRedundantMsg(edit->ActSketch.getRedundant(), msg);
|
||||
//Base::Console().Warning("Sketch with redundant constraints\n%s",msg.c_str());
|
||||
signalSetUp(4, dofs, msg);
|
||||
signalSetUp(QString::fromLatin1("<font color='orange'>Sketch contains redundant constraints<br/>%1</font>")
|
||||
.arg(QString::fromStdString(msg)));
|
||||
}
|
||||
if (edit->ActSketch.solve() == 0) { // solving the sketch
|
||||
if (dofs == 0) {
|
||||
// color the sketch as fully constrained
|
||||
edit->FullyConstrained = true;
|
||||
if (!edit->ActSketch.hasRedundancies()) {
|
||||
//Base::Console().Message("Fully constrained sketch\n");
|
||||
signalSetUp(0, 0, msg);
|
||||
}
|
||||
if (!edit->ActSketch.hasRedundancies())
|
||||
signalSetUp(QString::fromLatin1("<font color='green'>Fully constrained sketch </font>"));
|
||||
}
|
||||
else if (!edit->ActSketch.hasRedundancies()) {
|
||||
//Base::Console().Message("Under-constrained sketch with %d degrees of freedom\n", dofs);
|
||||
signalSetUp(1, dofs, msg);
|
||||
if (dofs == 1)
|
||||
signalSetUp(QString::fromLatin1("Under-constrained sketch with 1 degree of freedom"));
|
||||
else
|
||||
signalSetUp(QString::fromLatin1("Under-constrained sketch with %1 degrees of freedom").arg(dofs));
|
||||
}
|
||||
signalSolved(0, edit->ActSketch.SolveTime);
|
||||
signalSolved(QString::fromLatin1("Solved in %1 sec").arg(edit->ActSketch.SolveTime));
|
||||
}
|
||||
else {
|
||||
signalSolved(1, edit->ActSketch.SolveTime);
|
||||
signalSolved(QString::fromLatin1("Unsolved (%1 sec)").arg(edit->ActSketch.SolveTime));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -174,9 +174,9 @@ public:
|
|||
/// signals if the constraints list has changed
|
||||
boost::signal<void ()> signalConstraintsChanged;
|
||||
/// signals if the sketch has been set up
|
||||
boost::signal<void (int type, int dofs, std::string &msg)> signalSetUp;
|
||||
boost::signal<void (QString msg)> signalSetUp;
|
||||
/// signals if the sketch has been solved
|
||||
boost::signal<void (int type, float time)> signalSolved;
|
||||
boost::signal<void (QString msg)> signalSolved;
|
||||
|
||||
protected:
|
||||
virtual bool setEdit(int ModNum);
|
||||
|
|
Loading…
Reference in New Issue
Block a user