From 797dde0837a3016ec8624f0fd3345ab32e5eff07 Mon Sep 17 00:00:00 2001 From: Ronny Standtke Date: Wed, 19 Apr 2023 14:43:45 +0200 Subject: [PATCH] added i18n for axes and planes --- src/App/Origin.cpp | 19 ++++++++++--------- src/App/Origin.h | 18 ++++++++++-------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/App/Origin.cpp b/src/App/Origin.cpp index 0105d39dd2..f276bfb38b 100644 --- a/src/App/Origin.cpp +++ b/src/App/Origin.cpp @@ -44,9 +44,6 @@ using namespace App; PROPERTY_SOURCE(App::Origin, App::DocumentObject) -const char* Origin::AxisRoles[3] = {"X_Axis", "Y_Axis", "Z_Axis"}; -const char* Origin::PlaneRoles[3] = {"XY_Plane", "XZ_Plane", "YZ_Plane"}; - Origin::Origin() : extension(this) { ADD_PROPERTY_TYPE ( OriginFeatures, (nullptr), 0, App::Prop_Hidden, "Axis and baseplanes controlled by the origin" ); @@ -137,14 +134,15 @@ void Origin::setupObject () { const static struct { const Base::Type type; const char *role; + const QString label; Base::Rotation rot; } setupData [] = { - {App::Line::getClassTypeId(), "X_Axis", Base::Rotation () }, - {App::Line::getClassTypeId(), "Y_Axis", Base::Rotation ( Base::Vector3d (1,1,1), M_PI*2/3 ) }, - {App::Line::getClassTypeId(), "Z_Axis", Base::Rotation ( Base::Vector3d (1,1,1), M_PI*4/3 ) }, - {App::Plane::getClassTypeId (), "XY_Plane", Base::Rotation () }, - {App::Plane::getClassTypeId (), "XZ_Plane", Base::Rotation ( 1.0, 0.0, 0.0, 1.0 ), }, - {App::Plane::getClassTypeId (), "YZ_Plane", Base::Rotation ( Base::Vector3d (1,1,1), M_PI*2/3 ) }, + {App::Line::getClassTypeId(), AxisRoles[0], tr("X-axis"), Base::Rotation()}, + {App::Line::getClassTypeId(), AxisRoles[1], tr("Y-axis"), Base::Rotation(Base::Vector3d(1,1,1), M_PI*2/3)}, + {App::Line::getClassTypeId(), AxisRoles[2], tr("Z-axis"), Base::Rotation(Base::Vector3d(1,1,1), M_PI*4/3)}, + {App::Plane::getClassTypeId(), PlaneRoles[0], tr("XY-plane"), Base::Rotation()}, + {App::Plane::getClassTypeId(), PlaneRoles[1], tr("XZ-plane"), Base::Rotation(1.0, 0.0, 0.0, 1.0 )}, + {App::Plane::getClassTypeId(), PlaneRoles[2], tr("YZ-plane"), Base::Rotation(Base::Vector3d(1,1,1), M_PI*2/3)} }; App::Document *doc = getDocument (); @@ -156,6 +154,9 @@ void Origin::setupObject () { assert ( featureObj && featureObj->isDerivedFrom ( App::OriginFeature::getClassTypeId () ) ); + QByteArray byteArray = data.label.toUtf8(); + featureObj->Label.setValue(byteArray.constData()); + App::OriginFeature *feature = static_cast ( featureObj ); feature->Placement.setValue ( Base::Placement ( Base::Vector3d (), data.rot ) ); feature->Role.setValue ( data.role ); diff --git a/src/App/Origin.h b/src/App/Origin.h index 8deabce0b7..3098fa68f1 100644 --- a/src/App/Origin.h +++ b/src/App/Origin.h @@ -28,6 +28,7 @@ #include "GeoFeatureGroupExtension.h" #include "OriginFeature.h" +#include "QCoreApplication" namespace App { @@ -37,6 +38,7 @@ namespace App class AppExport Origin : public App::DocumentObject { PROPERTY_HEADER_WITH_OVERRIDE(App::Origin); + Q_DECLARE_TR_FUNCTIONS(App::Origin) public: /// Constructor @@ -55,28 +57,28 @@ public: ///@{ // returns X axis App::Line *getX () const { - return getAxis ("X_Axis"); + return getAxis (AxisRoles[0]); } // returns Y axis App::Line *getY () const { - return getAxis ("Y_Axis"); + return getAxis (AxisRoles[1]); } // returns Z axis App::Line *getZ () const { - return getAxis ("Z_Axis"); + return getAxis (AxisRoles[2]); } // returns XY plane App::Plane *getXY () const { - return getPlane ("XY_Plane"); + return getPlane (PlaneRoles[0]); } // returns XZ plane App::Plane *getXZ () const { - return getPlane ("XZ_Plane"); + return getPlane (PlaneRoles[1]); } // returns YZ plane App::Plane *getYZ () const { - return getPlane ("YZ_Plane"); + return getPlane (PlaneRoles[2]); } /// Returns all axis objects to iterate on them @@ -115,9 +117,9 @@ public: short mustExecute() const override; /// Axis types - static const char* AxisRoles[3]; + static constexpr char* AxisRoles[3] = {"X_Axis", "Y_Axis", "Z_Axis"}; /// Baseplane types - static const char* PlaneRoles[3]; + static constexpr char* PlaneRoles[3] = {"XY_Plane", "XZ_Plane", "YZ_Plane"}; // Axis links PropertyLinkList OriginFeatures;