Prepare sketch solver messages to be translated
This commit is contained in:
parent
8d1ea0801a
commit
c71b753730
|
@ -676,7 +676,7 @@ void Document::slotStartRestoreDocument(const App::Document& doc)
|
||||||
{
|
{
|
||||||
if (d->_pcDocument != &doc)
|
if (d->_pcDocument != &doc)
|
||||||
return;
|
return;
|
||||||
// disable this singal while loading a document
|
// disable this signal while loading a document
|
||||||
d->connectActObject.block();
|
d->connectActObject.block();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,6 +64,7 @@
|
||||||
# include <QMenu>
|
# include <QMenu>
|
||||||
# include <QMessageBox>
|
# include <QMessageBox>
|
||||||
# include <QPainter>
|
# include <QPainter>
|
||||||
|
# include <QTextStream>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <Inventor/SbTime.h>
|
#include <Inventor/SbTime.h>
|
||||||
|
@ -207,6 +208,8 @@ const Part::Geometry* GeoById(const std::vector<Part::Geometry*> GeoList, int Id
|
||||||
//**************************************************************************
|
//**************************************************************************
|
||||||
// Construction/Destruction
|
// Construction/Destruction
|
||||||
|
|
||||||
|
/* TRANSLATOR SketcherGui::ViewProviderSketch */
|
||||||
|
|
||||||
PROPERTY_SOURCE(SketcherGui::ViewProviderSketch, PartGui::ViewProvider2DObject)
|
PROPERTY_SOURCE(SketcherGui::ViewProviderSketch, PartGui::ViewProvider2DObject)
|
||||||
|
|
||||||
|
|
||||||
|
@ -2851,6 +2854,42 @@ bool ViewProviderSketch::setEdit(int ModNum)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString ViewProviderSketch::appendConflictMsg(const std::vector<int> &conflicting)
|
||||||
|
{
|
||||||
|
QString msg;
|
||||||
|
QTextStream ss(&msg);
|
||||||
|
if (conflicting.size() > 0) {
|
||||||
|
if (conflicting.size() == 1)
|
||||||
|
ss << tr("Please remove the following constraint:");
|
||||||
|
else
|
||||||
|
ss << tr("Please remove at least one of the following constraints:");
|
||||||
|
ss << "\n";
|
||||||
|
ss << conflicting[0];
|
||||||
|
for (unsigned int i=1; i < conflicting.size(); i++)
|
||||||
|
ss << ", " << conflicting[i];
|
||||||
|
ss << "\n";
|
||||||
|
}
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString ViewProviderSketch::appendRedundantMsg(const std::vector<int> &redundant)
|
||||||
|
{
|
||||||
|
QString msg;
|
||||||
|
QTextStream ss(&msg);
|
||||||
|
if (redundant.size() > 0) {
|
||||||
|
if (redundant.size() == 1)
|
||||||
|
ss << tr("Please remove the following redundant constraint:");
|
||||||
|
else
|
||||||
|
ss << tr("Please remove the following redundant constraints:");
|
||||||
|
ss << "\n";
|
||||||
|
ss << redundant[0];
|
||||||
|
for (unsigned int i=1; i < redundant.size(); i++)
|
||||||
|
ss << ", " << redundant[i];
|
||||||
|
ss << "\n";
|
||||||
|
}
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
void ViewProviderSketch::solveSketch(void)
|
void ViewProviderSketch::solveSketch(void)
|
||||||
{
|
{
|
||||||
// set up the sketch and diagnose possible conflicts
|
// set up the sketch and diagnose possible conflicts
|
||||||
|
@ -2858,47 +2897,46 @@ void ViewProviderSketch::solveSketch(void)
|
||||||
getSketchObject()->Constraints.getValues(),
|
getSketchObject()->Constraints.getValues(),
|
||||||
getSketchObject()->getExternalGeometryCount());
|
getSketchObject()->getExternalGeometryCount());
|
||||||
if (getSketchObject()->Geometry.getSize() == 0) {
|
if (getSketchObject()->Geometry.getSize() == 0) {
|
||||||
signalSetUp(QString::fromLatin1("Empty sketch"));
|
signalSetUp(tr("Empty sketch"));
|
||||||
signalSolved(QString());
|
signalSolved(QString());
|
||||||
}
|
}
|
||||||
else if (dofs < 0) { // over-constrained sketch
|
else if (dofs < 0) { // over-constrained sketch
|
||||||
std::string msg;
|
std::string msg;
|
||||||
SketchObject::appendConflictMsg(edit->ActSketch.getConflicting(), msg);
|
SketchObject::appendConflictMsg(edit->ActSketch.getConflicting(), msg);
|
||||||
signalSetUp(QString::fromLatin1("<font color='red'>Over-constrained sketch<br/>%1</font>")
|
signalSetUp(QString::fromLatin1("<font color='red'>%1<br/>%2</font>")
|
||||||
|
.arg(tr("Over-constrained sketch"))
|
||||||
.arg(QString::fromStdString(msg)));
|
.arg(QString::fromStdString(msg)));
|
||||||
signalSolved(QString());
|
signalSolved(QString());
|
||||||
}
|
}
|
||||||
else if (edit->ActSketch.hasConflicts()) { // conflicting constraints
|
else if (edit->ActSketch.hasConflicts()) { // conflicting constraints
|
||||||
std::string msg;
|
signalSetUp(QString::fromLatin1("<font color='red'>%1<br/>%2</font>")
|
||||||
SketchObject::appendConflictMsg(edit->ActSketch.getConflicting(), msg);
|
.arg(tr("Sketch contains conflicting constraints"))
|
||||||
signalSetUp(QString::fromLatin1("<font color='red'>Sketch contains conflicting constraints<br/>%1</font>")
|
.arg(appendConflictMsg(edit->ActSketch.getConflicting())));
|
||||||
.arg(QString::fromStdString(msg)));
|
|
||||||
signalSolved(QString());
|
signalSolved(QString());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (edit->ActSketch.hasRedundancies()) { // redundant constraints
|
if (edit->ActSketch.hasRedundancies()) { // redundant constraints
|
||||||
std::string msg;
|
signalSetUp(QString::fromLatin1("<font color='orange'>%1<br/>%2</font>")
|
||||||
SketchObject::appendRedundantMsg(edit->ActSketch.getRedundant(), msg);
|
.arg(tr("Sketch contains redundant constraints"))
|
||||||
signalSetUp(QString::fromLatin1("<font color='orange'>Sketch contains redundant constraints<br/>%1</font>")
|
.arg(appendRedundantMsg(edit->ActSketch.getRedundant())));
|
||||||
.arg(QString::fromStdString(msg)));
|
|
||||||
}
|
}
|
||||||
if (edit->ActSketch.solve() == 0) { // solving the sketch
|
if (edit->ActSketch.solve() == 0) { // solving the sketch
|
||||||
if (dofs == 0) {
|
if (dofs == 0) {
|
||||||
// color the sketch as fully constrained
|
// color the sketch as fully constrained
|
||||||
edit->FullyConstrained = true;
|
edit->FullyConstrained = true;
|
||||||
if (!edit->ActSketch.hasRedundancies())
|
if (!edit->ActSketch.hasRedundancies())
|
||||||
signalSetUp(QString::fromLatin1("<font color='green'>Fully constrained sketch </font>"));
|
signalSetUp(QString::fromLatin1("<font color='green'>%1</font>").arg(tr("Fully constrained sketch")));
|
||||||
}
|
}
|
||||||
else if (!edit->ActSketch.hasRedundancies()) {
|
else if (!edit->ActSketch.hasRedundancies()) {
|
||||||
if (dofs == 1)
|
if (dofs == 1)
|
||||||
signalSetUp(QString::fromLatin1("Under-constrained sketch with 1 degree of freedom"));
|
signalSetUp(tr("Under-constrained sketch with 1 degree of freedom"));
|
||||||
else
|
else
|
||||||
signalSetUp(QString::fromLatin1("Under-constrained sketch with %1 degrees of freedom").arg(dofs));
|
signalSetUp(tr("Under-constrained sketch with %1 degrees of freedom").arg(dofs));
|
||||||
}
|
}
|
||||||
signalSolved(QString::fromLatin1("Solved in %1 sec").arg(edit->ActSketch.SolveTime));
|
signalSolved(tr("Solved in %1 sec").arg(edit->ActSketch.SolveTime));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
signalSolved(QString::fromLatin1("Unsolved (%1 sec)").arg(edit->ActSketch.SolveTime));
|
signalSolved(tr("Unsolved (%1 sec)").arg(edit->ActSketch.SolveTime));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include <Base/Tools2D.h>
|
#include <Base/Tools2D.h>
|
||||||
#include <Gui/Selection.h>
|
#include <Gui/Selection.h>
|
||||||
#include <boost/signals.hpp>
|
#include <boost/signals.hpp>
|
||||||
|
#include <QCoreApplication>
|
||||||
|
|
||||||
|
|
||||||
class TopoDS_Shape;
|
class TopoDS_Shape;
|
||||||
|
@ -70,7 +71,13 @@ class DrawSketchHandler;
|
||||||
*/
|
*/
|
||||||
class SketcherGuiExport ViewProviderSketch : public PartGui::ViewProvider2DObject, public Gui::SelectionObserver
|
class SketcherGuiExport ViewProviderSketch : public PartGui::ViewProvider2DObject, public Gui::SelectionObserver
|
||||||
{
|
{
|
||||||
PROPERTY_HEADER(PartGui::ViewProviderSketch);
|
Q_DECLARE_TR_FUNCTIONS(SketcherGui::ViewProviderSketch)
|
||||||
|
/// generates a warning message about constraint conflicts and appends it to the given message
|
||||||
|
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);
|
||||||
|
|
||||||
|
PROPERTY_HEADER(SketcherGui::ViewProviderSketch);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// constructor
|
/// constructor
|
||||||
|
|
Loading…
Reference in New Issue
Block a user