diff --git a/src/Gui/Document.cpp b/src/Gui/Document.cpp index 7d91936bd..a3d439003 100644 --- a/src/Gui/Document.cpp +++ b/src/Gui/Document.cpp @@ -676,7 +676,7 @@ void Document::slotStartRestoreDocument(const App::Document& doc) { if (d->_pcDocument != &doc) return; - // disable this singal while loading a document + // disable this signal while loading a document d->connectActObject.block(); } diff --git a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp index 5511166a8..484883f60 100644 --- a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp +++ b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp @@ -64,6 +64,7 @@ # include # include # include +# include #endif #include @@ -207,6 +208,8 @@ const Part::Geometry* GeoById(const std::vector GeoList, int Id //************************************************************************** // Construction/Destruction +/* TRANSLATOR SketcherGui::ViewProviderSketch */ + PROPERTY_SOURCE(SketcherGui::ViewProviderSketch, PartGui::ViewProvider2DObject) @@ -2851,6 +2854,42 @@ bool ViewProviderSketch::setEdit(int ModNum) return true; } +QString ViewProviderSketch::appendConflictMsg(const std::vector &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 &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) { // set up the sketch and diagnose possible conflicts @@ -2858,47 +2897,46 @@ void ViewProviderSketch::solveSketch(void) getSketchObject()->Constraints.getValues(), getSketchObject()->getExternalGeometryCount()); if (getSketchObject()->Geometry.getSize() == 0) { - signalSetUp(QString::fromLatin1("Empty sketch")); + signalSetUp(tr("Empty sketch")); signalSolved(QString()); } else if (dofs < 0) { // over-constrained sketch std::string msg; SketchObject::appendConflictMsg(edit->ActSketch.getConflicting(), msg); - signalSetUp(QString::fromLatin1("Over-constrained sketch
%1
") + signalSetUp(QString::fromLatin1("%1
%2
") + .arg(tr("Over-constrained sketch")) .arg(QString::fromStdString(msg))); signalSolved(QString()); } else if (edit->ActSketch.hasConflicts()) { // conflicting constraints - std::string msg; - SketchObject::appendConflictMsg(edit->ActSketch.getConflicting(), msg); - signalSetUp(QString::fromLatin1("Sketch contains conflicting constraints
%1
") - .arg(QString::fromStdString(msg))); + signalSetUp(QString::fromLatin1("%1
%2
") + .arg(tr("Sketch contains conflicting constraints")) + .arg(appendConflictMsg(edit->ActSketch.getConflicting()))); signalSolved(QString()); } else { if (edit->ActSketch.hasRedundancies()) { // redundant constraints - std::string msg; - SketchObject::appendRedundantMsg(edit->ActSketch.getRedundant(), msg); - signalSetUp(QString::fromLatin1("Sketch contains redundant constraints
%1
") - .arg(QString::fromStdString(msg))); + signalSetUp(QString::fromLatin1("%1
%2
") + .arg(tr("Sketch contains redundant constraints")) + .arg(appendRedundantMsg(edit->ActSketch.getRedundant()))); } if (edit->ActSketch.solve() == 0) { // solving the sketch if (dofs == 0) { // color the sketch as fully constrained edit->FullyConstrained = true; if (!edit->ActSketch.hasRedundancies()) - signalSetUp(QString::fromLatin1("Fully constrained sketch ")); + signalSetUp(QString::fromLatin1("%1").arg(tr("Fully constrained sketch"))); } else if (!edit->ActSketch.hasRedundancies()) { 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 - 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 { - signalSolved(QString::fromLatin1("Unsolved (%1 sec)").arg(edit->ActSketch.SolveTime)); + signalSolved(tr("Unsolved (%1 sec)").arg(edit->ActSketch.SolveTime)); } } } diff --git a/src/Mod/Sketcher/Gui/ViewProviderSketch.h b/src/Mod/Sketcher/Gui/ViewProviderSketch.h index d281ce597..5749873a2 100644 --- a/src/Mod/Sketcher/Gui/ViewProviderSketch.h +++ b/src/Mod/Sketcher/Gui/ViewProviderSketch.h @@ -29,6 +29,7 @@ #include #include #include +#include class TopoDS_Shape; @@ -70,7 +71,13 @@ class DrawSketchHandler; */ 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 &conflicting); + /// generates a warning message about redundant constraints and appends it to the given message + static QString appendRedundantMsg(const std::vector &redundant); + + PROPERTY_HEADER(SketcherGui::ViewProviderSketch); public: /// constructor