From 69d4258f769c5804ff76daab66da922b28642f9c Mon Sep 17 00:00:00 2001 From: luz paz Date: Sat, 28 Nov 2020 11:46:35 -0500 Subject: [PATCH] Mesh: Issue #0004473: Expose openCommand() to translation Continuing the work to expose the undo/redo functionality to translation. This commit does so for the Mesh Wb. Ticket: https://tracker.freecadweb.org/view.php?id=4473 --- src/Mod/Mesh/Gui/Command.cpp | 30 ++++++++++++------------- src/Mod/Mesh/Gui/DlgDecimating.cpp | 2 +- src/Mod/Mesh/Gui/DlgEvaluateMeshImp.cpp | 18 +++++++-------- src/Mod/Mesh/Gui/DlgSmoothing.cpp | 2 +- src/Mod/Mesh/Gui/RemoveComponents.cpp | 2 +- src/Mod/Mesh/Gui/ViewProvider.cpp | 16 ++++++------- 6 files changed, 35 insertions(+), 35 deletions(-) diff --git a/src/Mod/Mesh/Gui/Command.cpp b/src/Mod/Mesh/Gui/Command.cpp index 6c9aaec2a3..7d76808941 100644 --- a/src/Mod/Mesh/Gui/Command.cpp +++ b/src/Mod/Mesh/Gui/Command.cpp @@ -107,7 +107,7 @@ void CmdMeshTransform::activated(int) std::string fName = getUniqueObjectName("Move"); std::vector cSel = getSelection().getSelection(); - openCommand("Mesh Mesh Create"); + openCommand(QT_TRANSLATE_NOOP("Command", "Mesh Mesh Create")); doCommand(Doc,"App.activeDocument().addObject(\"Mesh::Transform\",\"%s\")",fName.c_str()); doCommand(Doc,"App.activeDocument().%s.Source = App.activeDocument().%s",fName.c_str(),cSel[0].FeatName); doCommand(Gui,"Gui.hide(\"%s\")",cSel[0].FeatName); @@ -146,7 +146,7 @@ void CmdMeshDemolding::activated(int) std::string fName = getUniqueObjectName("Demolding"); std::vector cSel = getSelection().getSelection(); - openCommand("Mesh Mesh Create"); + openCommand(QT_TRANSLATE_NOOP("Command", "Mesh Mesh Create")); doCommand(Doc,"App.activeDocument().addObject(\"Mesh::TransformDemolding\",\"%s\")",fName.c_str()); doCommand(Doc,"App.activeDocument().%s.Source = App.activeDocument().%s",fName.c_str(),cSel[0].FeatName); doCommand(Gui,"Gui.hide(\"%s\")",cSel[0].FeatName); @@ -185,7 +185,7 @@ void CmdMeshToolMesh::activated(int) App::DocumentObject* mesh = fea.front(); App::DocumentObject* tool = fea.back(); - openCommand("Segment by tool mesh"); + openCommand(QT_TRANSLATE_NOOP("Command", "Segment by tool mesh")); doCommand(Doc, "import Mesh"); doCommand(Gui, "import MeshGui"); doCommand(Doc, @@ -240,7 +240,7 @@ void CmdMeshUnion::activated(int) std::string name3 = getUniqueObjectName("Union"); try { - openCommand("Mesh union"); + openCommand(QT_TRANSLATE_NOOP("Command", "Mesh union")); doCommand(Doc, "import OpenSCADUtils\n" "mesh = OpenSCADUtils.meshoptempfile('union',(App.ActiveDocument.%s.Mesh,App.ActiveDocument.%s.Mesh))\n" @@ -309,7 +309,7 @@ void CmdMeshDifference::activated(int) std::string name1 = obj.front()->getNameInDocument(); std::string name2 = obj.back()->getNameInDocument(); std::string name3 = getUniqueObjectName("Difference"); - openCommand("Mesh difference"); + openCommand(QT_TRANSLATE_NOOP("Command", "Mesh difference")); try { doCommand(Doc, @@ -380,7 +380,7 @@ void CmdMeshIntersection::activated(int) std::string name1 = obj.front()->getNameInDocument(); std::string name2 = obj.back()->getNameInDocument(); std::string name3 = getUniqueObjectName("Intersection"); - openCommand("Mesh intersection"); + openCommand(QT_TRANSLATE_NOOP("Command", "Mesh intersection")); try { doCommand(Doc, @@ -466,7 +466,7 @@ void CmdMeshImport::activated(int) for (QStringList::Iterator it = fn.begin(); it != fn.end(); ++it) { std::string unicodepath = Base::Tools::escapedUnicodeFromUtf8((*it).toUtf8().data()); unicodepath = Base::Tools::escapeEncodeFilename(unicodepath); - openCommand("Import Mesh"); + openCommand(QT_TRANSLATE_NOOP("Command", "Import Mesh")); doCommand(Doc,"import Mesh"); doCommand(Doc,"Mesh.insert(u\"%s\")", unicodepath.c_str()); @@ -662,7 +662,7 @@ void CmdMeshVertexCurvature::activated(int) fName += "_Curvature"; fName = getUniqueObjectName(fName.c_str()); - openCommand("Mesh VertexCurvature"); + openCommand(QT_TRANSLATE_NOOP("Command", "Mesh VertexCurvature")); App::DocumentObject* grp = App::DocumentObjectGroup::getGroupOfObject( *it ); if (grp) doCommand(Doc,"App.activeDocument().getObject(\"%s\").newObject(\"Mesh::Curvature\",\"%s\")",grp->getNameInDocument(), fName.c_str()); @@ -1411,7 +1411,7 @@ void CmdMeshSmoothing::activated(int) MeshGui::SmoothingDialog dlg(Gui::getMainWindow()); if (dlg.exec() == QDialog::Accepted) { Gui::WaitCursor wc; - openCommand("Mesh Smoothing"); + openCommand(QT_TRANSLATE_NOOP("Command", "Mesh Smoothing")); std::vector meshes = getSelection().getObjectsOfType(Mesh::Feature::getClassTypeId()); for (std::vector::const_iterator it = meshes.begin(); it != meshes.end(); ++it) { Mesh::Feature* mesh = (Mesh::Feature*)*it; @@ -1502,7 +1502,7 @@ CmdMeshHarmonizeNormals::CmdMeshHarmonizeNormals() void CmdMeshHarmonizeNormals::activated(int) { std::vector meshes = getSelection().getObjectsOfType(Mesh::Feature::getClassTypeId()); - openCommand("Harmonize mesh normals"); + openCommand(QT_TRANSLATE_NOOP("Command", "Harmonize mesh normals")); for (std::vector::const_iterator it = meshes.begin(); it != meshes.end(); ++it) { doCommand(Doc,"App.activeDocument().getObject(\"%s\").Mesh.harmonizeNormals()" ,(*it)->getNameInDocument()); @@ -1536,7 +1536,7 @@ CmdMeshFlipNormals::CmdMeshFlipNormals() void CmdMeshFlipNormals::activated(int) { std::vector meshes = getSelection().getObjectsOfType(Mesh::Feature::getClassTypeId()); - openCommand("Flip mesh normals"); + openCommand(QT_TRANSLATE_NOOP("Command", "Flip mesh normals")); for (std::vector::const_iterator it = meshes.begin(); it != meshes.end(); ++it) { doCommand(Doc,"App.activeDocument().getObject(\"%s\").Mesh.flipNormals()" ,(*it)->getNameInDocument()); @@ -1647,7 +1647,7 @@ void CmdMeshFillupHoles::activated(int) int FillupHolesOfLength = QInputDialog::getInt(Gui::getMainWindow(), QObject::tr("Fill holes"), QObject::tr("Fill holes with maximum number of edges:"), 3, 3, 10000, 1, &ok); if (!ok) return; - openCommand("Fill up holes"); + openCommand(QT_TRANSLATE_NOOP("Command", "Fill up holes")); for (std::vector::const_iterator it = meshes.begin(); it != meshes.end(); ++it) { doCommand(Doc,"App.activeDocument().getObject(\"%s\").Mesh.fillupHoles(%d)" ,(*it)->getNameInDocument(), FillupHolesOfLength); @@ -1798,7 +1798,7 @@ void CmdMeshMerge::activated(int) if (!pcDoc) return; - openCommand("Mesh merge"); + openCommand(QT_TRANSLATE_NOOP("Command", "Mesh merge")); Mesh::Feature *pcFeature = static_cast(pcDoc->addObject("Mesh::Feature", "Mesh")); Mesh::MeshObject* newMesh = pcFeature->Mesh.startEditing(); std::vector objs = Gui::Selection().getObjectsOfType(Mesh::Feature::getClassTypeId()); @@ -1841,7 +1841,7 @@ void CmdMeshSplitComponents::activated(int) if (!pcDoc) return; - openCommand("Mesh split"); + openCommand(QT_TRANSLATE_NOOP("Command", "Mesh split")); std::vector objs = Gui::Selection().getObjectsOfType(Mesh::Feature::getClassTypeId()); for (std::vector::const_iterator it = objs.begin(); it != objs.end(); ++it) { const MeshObject& mesh = static_cast(*it)->Mesh.getValue(); @@ -1893,7 +1893,7 @@ void CmdMeshScale::activated(int) if (!ok || factor == 0) return; - openCommand("Mesh scale"); + openCommand(QT_TRANSLATE_NOOP("Command", "Mesh scale")); std::vector objs = Gui::Selection().getObjectsOfType(Mesh::Feature::getClassTypeId()); Base::Matrix4D mat; mat.scale(factor,factor,factor); diff --git a/src/Mod/Mesh/Gui/DlgDecimating.cpp b/src/Mod/Mesh/Gui/DlgDecimating.cpp index 2d1a81e47d..3b05c8f9d6 100644 --- a/src/Mod/Mesh/Gui/DlgDecimating.cpp +++ b/src/Mod/Mesh/Gui/DlgDecimating.cpp @@ -144,7 +144,7 @@ bool TaskDecimating::accept() Gui::Selection().clearSelection(); Gui::WaitCursor wc; - Gui::Command::openCommand("Mesh Decimating"); + Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Mesh Decimating")); float tolerance = widget->tolerance(); float reduction = widget->reduction(); diff --git a/src/Mod/Mesh/Gui/DlgEvaluateMeshImp.cpp b/src/Mod/Mesh/Gui/DlgEvaluateMeshImp.cpp index 1d1e984d1a..cf4ef6631b 100644 --- a/src/Mod/Mesh/Gui/DlgEvaluateMeshImp.cpp +++ b/src/Mod/Mesh/Gui/DlgEvaluateMeshImp.cpp @@ -480,7 +480,7 @@ void DlgEvaluateMeshImp::on_repairOrientationButton_clicked() const char* docName = App::GetApplication().getDocumentName(d->meshFeature->getDocument()); const char* objName = d->meshFeature->getNameInDocument(); Gui::Document* doc = Gui::Application::Instance->getDocument(docName); - doc->openCommand("Harmonize normals"); + doc->openCommand(QT_TRANSLATE_NOOP("Command", "Harmonize normals")); try { Gui::Command::doCommand(Gui::Command::App , "App.getDocument(\"%s\").getObject(\"%s\").harmonizeNormals()" @@ -583,7 +583,7 @@ void DlgEvaluateMeshImp::on_repairNonmanifoldsButton_clicked() const char* docName = App::GetApplication().getDocumentName(d->meshFeature->getDocument()); const char* objName = d->meshFeature->getNameInDocument(); Gui::Document* doc = Gui::Application::Instance->getDocument(docName); - doc->openCommand("Remove non-manifolds"); + doc->openCommand(QT_TRANSLATE_NOOP("Command", "Remove non-manifolds")); try { Gui::Command::doCommand(Gui::Command::App , "App.getDocument(\"%s\").getObject(\"%s\").removeNonManifolds()" @@ -682,7 +682,7 @@ void DlgEvaluateMeshImp::on_repairIndicesButton_clicked() const char* docName = App::GetApplication().getDocumentName(d->meshFeature->getDocument()); const char* objName = d->meshFeature->getNameInDocument(); Gui::Document* doc = Gui::Application::Instance->getDocument(docName); - doc->openCommand("Fix indices"); + doc->openCommand(QT_TRANSLATE_NOOP("Command", "Fix indices")); try { Gui::Command::doCommand(Gui::Command::App , "App.getDocument(\"%s\").getObject(\"%s\").fixIndices()" @@ -748,7 +748,7 @@ void DlgEvaluateMeshImp::on_repairDegeneratedButton_clicked() const char* docName = App::GetApplication().getDocumentName(d->meshFeature->getDocument()); const char* objName = d->meshFeature->getNameInDocument(); Gui::Document* doc = Gui::Application::Instance->getDocument(docName); - doc->openCommand("Remove degenerated faces"); + doc->openCommand(QT_TRANSLATE_NOOP("Command", "Remove degenerated faces")); try { Gui::Command::doCommand(Gui::Command::App , "App.getDocument(\"%s\").getObject(\"%s\").fixDegenerations(%f)" @@ -815,7 +815,7 @@ void DlgEvaluateMeshImp::on_repairDuplicatedFacesButton_clicked() const char* docName = App::GetApplication().getDocumentName(d->meshFeature->getDocument()); const char* objName = d->meshFeature->getNameInDocument(); Gui::Document* doc = Gui::Application::Instance->getDocument(docName); - doc->openCommand("Remove duplicated faces"); + doc->openCommand(QT_TRANSLATE_NOOP("Command", "Remove duplicated faces")); try { Gui::Command::doCommand(Gui::Command::App , "App.getDocument(\"%s\").getObject(\"%s\").removeDuplicatedFacets()" @@ -880,7 +880,7 @@ void DlgEvaluateMeshImp::on_repairDuplicatedPointsButton_clicked() const char* docName = App::GetApplication().getDocumentName(d->meshFeature->getDocument()); const char* objName = d->meshFeature->getNameInDocument(); Gui::Document* doc = Gui::Application::Instance->getDocument(docName); - doc->openCommand("Remove duplicated points"); + doc->openCommand(QT_TRANSLATE_NOOP("Command", "Remove duplicated points")); try { Gui::Command::doCommand(Gui::Command::App , "App.getDocument(\"%s\").getObject(\"%s\").removeDuplicatedPoints()" @@ -964,7 +964,7 @@ void DlgEvaluateMeshImp::on_repairSelfIntersectionButton_clicked() const char* objName = d->meshFeature->getNameInDocument(); #endif Gui::Document* doc = Gui::Application::Instance->getDocument(docName); - doc->openCommand("Fix self-intersections"); + doc->openCommand(QT_TRANSLATE_NOOP("Command", "Fix self-intersections")); #if 0 try { Gui::Application::Instance->runCommand( @@ -1051,7 +1051,7 @@ void DlgEvaluateMeshImp::on_repairFoldsButton_clicked() const char* objName = d->meshFeature->getNameInDocument(); Gui::Document* doc = Gui::Application::Instance->getDocument(docName); qApp->setOverrideCursor(Qt::WaitCursor); - doc->openCommand("Remove folds"); + doc->openCommand(QT_TRANSLATE_NOOP("Command", "Remove folds")); try { Gui::Command::doCommand(Gui::Command::App , "App.getDocument(\"%s\").getObject(\"%s\").removeFoldsOnSurface()" @@ -1091,7 +1091,7 @@ void DlgEvaluateMeshImp::on_repairAllTogether_clicked() const char* docName = App::GetApplication().getDocumentName(d->meshFeature->getDocument()); const char* objName = d->meshFeature->getNameInDocument(); Gui::Document* doc = Gui::Application::Instance->getDocument(docName); - doc->openCommand("Repair mesh"); + doc->openCommand(QT_TRANSLATE_NOOP("Command", "Repair mesh")); bool run = false; bool self = true; diff --git a/src/Mod/Mesh/Gui/DlgSmoothing.cpp b/src/Mod/Mesh/Gui/DlgSmoothing.cpp index 97ff13651e..726afb2d62 100644 --- a/src/Mod/Mesh/Gui/DlgSmoothing.cpp +++ b/src/Mod/Mesh/Gui/DlgSmoothing.cpp @@ -175,7 +175,7 @@ bool TaskSmoothing::accept() return true; Gui::WaitCursor wc; - Gui::Command::openCommand("Mesh Smoothing"); + Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Mesh Smoothing")); bool hasSelection = false; for (std::vector::const_iterator it = meshes.begin(); it != meshes.end(); ++it) { diff --git a/src/Mod/Mesh/Gui/RemoveComponents.cpp b/src/Mod/Mesh/Gui/RemoveComponents.cpp index 1ffc8a2be3..253af04952 100644 --- a/src/Mod/Mesh/Gui/RemoveComponents.cpp +++ b/src/Mod/Mesh/Gui/RemoveComponents.cpp @@ -127,7 +127,7 @@ void RemoveComponents::deleteSelection() Gui::Document* doc = Gui::Application::Instance->activeDocument(); if (!doc) return; // delete all selected faces - doc->openCommand("Delete selection"); + doc->openCommand(QT_TRANSLATE_NOOP("Command", "Delete selection")); bool ok = meshSel.deleteSelection(); if (!ok) doc->abortCommand(); diff --git a/src/Mod/Mesh/Gui/ViewProvider.cpp b/src/Mod/Mesh/Gui/ViewProvider.cpp index 8e7601dd48..08bbb26890 100644 --- a/src/Mod/Mesh/Gui/ViewProvider.cpp +++ b/src/Mod/Mesh/Gui/ViewProvider.cpp @@ -871,7 +871,7 @@ public: } void cutMesh() { Gui::Document* gui = mesh->getDocument(); - gui->openCommand("Cut"); + gui->openCommand(QT_TRANSLATE_NOOP("Command", "Cut")); ViewProviderMesh* copy = makeCopy(); mesh->cutMesh(poly, proj, false); copy->cutMesh(poly, proj, true); @@ -880,7 +880,7 @@ public: } void trimMesh() { Gui::Document* gui = mesh->getDocument(); - gui->openCommand("Trim"); + gui->openCommand(QT_TRANSLATE_NOOP("Command", "Trim")); ViewProviderMesh* copy = makeCopy(); mesh->trimMesh(poly, proj, false); copy->trimMesh(poly, proj, true); @@ -926,7 +926,7 @@ void ViewProviderMesh::clipMeshCallback(void * ud, SoEventCallback * n) std::vector views = view->getDocument()->getViewProvidersOfType(ViewProviderMesh::getClassTypeId()); if (!views.empty()) { - Gui::Application::Instance->activeDocument()->openCommand("Cut"); + Gui::Application::Instance->activeDocument()->openCommand(QT_TRANSLATE_NOOP("Command", "Cut")); bool commitCommand = false; for (std::vector::iterator it = views.begin(); it != views.end(); ++it) { ViewProviderMesh* self = static_cast(*it); @@ -987,7 +987,7 @@ void ViewProviderMesh::trimMeshCallback(void * ud, SoEventCallback * n) std::vector views = view->getDocument()->getViewProvidersOfType(ViewProviderMesh::getClassTypeId()); if (!views.empty()) { - Gui::Application::Instance->activeDocument()->openCommand("Trim"); + Gui::Application::Instance->activeDocument()->openCommand(QT_TRANSLATE_NOOP("Command", "Trim")); bool commitCommand = false; for (std::vector::iterator it = views.begin(); it != views.end(); ++it) { ViewProviderMesh* self = static_cast(*it); @@ -1064,7 +1064,7 @@ void ViewProviderMesh::partMeshCallback(void * ud, SoEventCallback * cb) Base::Sequencer().setLocked(locked); // Open a transaction object for the undo/redo stuff - Gui::Application::Instance->activeDocument()->openCommand("Split"); + Gui::Application::Instance->activeDocument()->openCommand(QT_TRANSLATE_NOOP("Command", "Split")); try { std::vector views = view->getDocument()->getViewProvidersOfType(ViewProviderMesh::getClassTypeId()); @@ -1128,7 +1128,7 @@ void ViewProviderMesh::segmMeshCallback(void * ud, SoEventCallback * cb) Base::Sequencer().setLocked(locked); // Open a transaction object for the undo/redo stuff - Gui::Application::Instance->activeDocument()->openCommand("Segment"); + Gui::Application::Instance->activeDocument()->openCommand(QT_TRANSLATE_NOOP("Command", "Segment")); try { std::vector views = view->getDocument()->getViewProvidersOfType(ViewProviderMesh::getClassTypeId()); @@ -1723,7 +1723,7 @@ void ViewProviderMesh::markPartCallback(void * ud, SoEventCallback * n) } } else if (rm == id) { - Gui::Application::Instance->activeDocument()->openCommand("Delete"); + Gui::Application::Instance->activeDocument()->openCommand(QT_TRANSLATE_NOOP("Command", "Delete")); std::vector views = view->getDocument()->getViewProvidersOfType(ViewProviderMesh::getClassTypeId()); for (std::vector::iterator it = views.begin(); it != views.end(); ++it) { static_cast(*it)->deleteSelection(); @@ -1830,7 +1830,7 @@ void ViewProviderMesh::fillHole(unsigned long uFacet) return; // nothing to do //add the facets to the mesh and open a transaction object for the undo/redo stuff - Gui::Application::Instance->activeDocument()->openCommand("Fill hole"); + Gui::Application::Instance->activeDocument()->openCommand(QT_TRANSLATE_NOOP("Command", "Fill hole")); Mesh::MeshObject* kernel = fea->Mesh.startEditing(); kernel->addFacets(newFacets, newPoints, true); fea->Mesh.finishEditing();