1
/***************************************************************************
2
* Copyright (c) 2016 Victor Titov (DeepSOIC) <vv.titov@gmail.com> *
4
* This file is part of the FreeCAD CAx development system. *
6
* This library is free software; you can redistribute it and/or *
7
* modify it under the terms of the GNU Library General Public *
8
* License as published by the Free Software Foundation; either *
9
* version 2 of the License, or (at your option) any later version. *
11
* This library is distributed in the hope that it will be useful, *
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14
* GNU Library General Public License for more details. *
16
* You should have received a copy of the GNU Library General Public *
17
* License along with this library; see the file COPYING.LIB. If not, *
18
* write to the Free Software Foundation, Inc., 59 Temple Place, *
19
* Suite 330, Boston, MA 02111-1307, USA *
21
***************************************************************************/
23
#include "PreCompiled.h"
25
# include <QApplication>
28
#include <Base/Console.h>
30
#include "AttacherTexts.h"
33
using namespace Attacher;
35
namespace AttacherGui {
37
TextSet TwoStrings(QString str1, QString str2)
39
std::vector<QString> v;
46
TextSet getUIStrings(Base::Type attacherType, eMapMode mmode)
48
if (attacherType.isDerivedFrom(AttachEngine3D::getClassTypeId())){
49
//---- coordinate system attacher ----
52
return TwoStrings(qApp->translate("Attacher3D", "Deactivated","Attachment3D mode caption"),
53
qApp->translate("Attacher3D", "Attachment is disabled. Object can be moved by editing Placement property.","Attachment3D mode tooltip"));
55
return TwoStrings(qApp->translate("Attacher3D", "Translate origin","Attachment3D mode caption"),
56
qApp->translate("Attacher3D", "Origin is aligned to match Vertex. Orientation is controlled by Placement property.","Attachment3D mode tooltip"));
58
return TwoStrings(qApp->translate("Attacher3D", "Object's X Y Z","Attachment3D mode caption"),
59
qApp->translate("Attacher3D", "Placement is made equal to Placement of linked object.","Attachment3D mode tooltip"));
61
return TwoStrings(qApp->translate("Attacher3D", "Object's X Z Y","Attachment3D mode caption"),
62
qApp->translate("Attacher3D", "X', Y', Z' axes are matched with object's local X, Z, -Y, respectively.","Attachment3D mode tooltip"));
64
return TwoStrings(qApp->translate("Attacher3D", "Object's Y Z X","Attachment3D mode caption"),
65
qApp->translate("Attacher3D", "X', Y', Z' axes are matched with object's local Y, Z, X, respectively.","Attachment3D mode tooltip"));
67
return TwoStrings(qApp->translate("Attacher3D", "XY parallel to plane","Attachment3D mode caption"),
68
qApp->translate("Attacher3D", "X' Y' plane is parallel to the plane (object's XY) and passes through the vertex.","Attachment3D mode tooltip"));
70
return TwoStrings(qApp->translate("Attacher3D", "XY on plane","Attachment3D mode caption"),
71
qApp->translate("Attacher3D", "X' Y' plane is aligned to coincide planar face.","Attachment3D mode tooltip"));
73
return TwoStrings(qApp->translate("Attacher3D", "XY tangent to surface","Attachment3D mode caption"),
74
qApp->translate("Attacher3D", "X' Y' plane is made tangent to surface at vertex.","Attachment3D mode tooltip"));
76
return TwoStrings(qApp->translate("Attacher3D", "Z tangent to edge","Attachment3D mode caption"),
77
qApp->translate("Attacher3D", "Z' axis is aligned to be tangent to edge. Optional vertex link defines where.","Attachment3D mode tooltip"));
79
return TwoStrings(qApp->translate("Attacher3D", "Frenet NBT","Attachment3D mode caption"),
80
qApp->translate("Attacher3D", "Align to Frenet-Serret coordinate system of curved edge. Optional vertex link defines where.","Attachment3D mode tooltip"));
82
return TwoStrings(qApp->translate("Attacher3D", "Frenet TNB","Attachment3D mode caption"),
83
qApp->translate("Attacher3D", "Align to Frenet-Serret coordinate system of curved edge. Optional vertex link defines where.","Attachment3D mode tooltip"));
85
return TwoStrings(qApp->translate("Attacher3D", "Frenet TBN","Attachment3D mode caption"),
86
qApp->translate("Attacher3D", "Align to Frenet-Serret coordinate system of curved edge. Optional vertex link defines where.","Attachment3D mode tooltip"));
88
return TwoStrings(qApp->translate("Attacher3D", "Concentric","Attachment3D mode caption"),
89
qApp->translate("Attacher3D", "Align XY plane to osculating circle of an edge. Optional vertex link defines where.","Attachment3D mode tooltip"));
90
case mmRevolutionSection:
91
return TwoStrings(qApp->translate("Attacher3D", "Revolution Section","Attachment3D mode caption"),
92
qApp->translate("Attacher3D", "Align Y' axis to match axis of osculating circle of an edge. Optional vertex link defines where.","Attachment3D mode tooltip"));
93
case mmThreePointsPlane:
94
return TwoStrings(qApp->translate("Attacher3D", "XY plane by 3 points","Attachment3D mode caption"),
95
qApp->translate("Attacher3D", "Align XY plane to pass through three vertices.","Attachment3D mode tooltip"));
96
case mmThreePointsNormal:
97
return TwoStrings(qApp->translate("Attacher3D", "XZ plane by 3 points","Attachment3D mode caption"),
98
qApp->translate("Attacher3D", "Align XZ plane to pass through 3 points; X axis will pass through two first points.","Attachment3D mode tooltip"));
100
return TwoStrings(qApp->translate("Attacher3D", "Folding","Attachment3D mode caption"),
101
qApp->translate("Attacher3D", "Specialty mode for folding polyhedra. Select 4 edges in order: foldable edge, fold line, other fold line, other foldable edge. XY plane will be aligned to folding the first edge.","Attachment3D mode tooltip"));
103
return TwoStrings(qApp->translate("Attacher3D", "Inertial CS","Attachment3D mode caption"),
104
qApp->translate("Attacher3D", "Inertial coordinate system, constructed on principal axes of inertia and center of mass.","Attachment3D mode tooltip"));
106
return TwoStrings(qApp->translate("Attacher3D", "Align O-Z-X","Attachment3D mode caption"),
107
qApp->translate("Attacher3D", "Match origin with first Vertex. Align Z' and X' axes towards vertex/along line.","Attachment3D mode tooltip"));
109
return TwoStrings(qApp->translate("Attacher3D", "Align O-Z-Y","Attachment3D mode caption"),
110
qApp->translate("Attacher3D", "Match origin with first Vertex. Align Z' and Y' axes towards vertex/along line.","Attachment3D mode tooltip"));
112
return TwoStrings(qApp->translate("Attacher3D", "Align O-X-Y","Attachment3D mode caption"),
113
qApp->translate("Attacher3D", "Match origin with first Vertex. Align X' and Y' axes towards vertex/along line.","Attachment3D mode tooltip"));
115
return TwoStrings(qApp->translate("Attacher3D", "Align O-X-Z","Attachment3D mode caption"),
116
qApp->translate("Attacher3D", "Match origin with first Vertex. Align X' and Z' axes towards vertex/along line.","Attachment3D mode tooltip"));
118
return TwoStrings(qApp->translate("Attacher3D", "Align O-Y-Z","Attachment3D mode caption"),
119
qApp->translate("Attacher3D", "Match origin with first Vertex. Align Y' and Z' axes towards vertex/along line.","Attachment3D mode tooltip"));
121
return TwoStrings(qApp->translate("Attacher3D", "Align O-Y-X","Attachment3D mode caption"),
122
qApp->translate("Attacher3D", "Match origin with first Vertex. Align Y' and X' axes towards vertex/along line.","Attachment3D mode tooltip"));
126
} else if (attacherType.isDerivedFrom(AttachEnginePlane::getClassTypeId())){
127
//---- Plane/sketch attacher ----
130
return TwoStrings(qApp->translate("Attacher2D", "Deactivated","AttachmentPlane mode caption"),
131
qApp->translate("Attacher2D", "Attachment is disabled. Object can be moved by editing Placement property.","AttachmentPlane mode tooltip"));
133
return TwoStrings(qApp->translate("Attacher2D", "Translate origin","AttachmentPlane mode caption"),
134
qApp->translate("Attacher2D", "Origin is aligned to match Vertex. Orientation is controlled by Placement property.","AttachmentPlane mode tooltip"));
136
return TwoStrings(qApp->translate("Attacher2D", "Object's XY","AttachmentPlane mode caption"),
137
qApp->translate("Attacher2D", "Plane is aligned to XY local plane of linked object.","AttachmentPlane mode tooltip"));
139
return TwoStrings(qApp->translate("Attacher2D", "Object's XZ","AttachmentPlane mode caption"),
140
qApp->translate("Attacher2D", "Plane is aligned to XZ local plane of linked object.","AttachmentPlane mode tooltip"));
142
return TwoStrings(qApp->translate("Attacher2D", "Object's YZ","AttachmentPlane mode caption"),
143
qApp->translate("Attacher2D", "Plane is aligned to YZ local plane of linked object.","AttachmentPlane mode tooltip"));
144
case mmParallelPlane:
145
return TwoStrings(qApp->translate("Attacher2D", "XY parallel to plane","AttachmentPlane mode caption"),
146
qApp->translate("Attacher2D", "X' Y' plane is parallel to the plane (object's XY) and passes through the vertex","AttachmentPlane mode tooltip"));
148
return TwoStrings(qApp->translate("Attacher2D", "Plane face","AttachmentPlane mode caption"),
149
qApp->translate("Attacher2D", "Plane is aligned to coincide planar face.","AttachmentPlane mode tooltip"));
151
return TwoStrings(qApp->translate("Attacher2D", "Tangent to surface","AttachmentPlane mode caption"),
152
qApp->translate("Attacher2D", "Plane is made tangent to surface at vertex.","AttachmentPlane mode tooltip"));
154
return TwoStrings(qApp->translate("Attacher2D", "Normal to edge","AttachmentPlane mode caption"),
155
qApp->translate("Attacher2D", "Plane is made tangent to edge. Optional vertex link defines where.","AttachmentPlane mode tooltip"));
157
return TwoStrings(qApp->translate("Attacher2D", "Frenet NB","AttachmentPlane mode caption"),
158
qApp->translate("Attacher2D", "Align to Frenet-Serret coordinate system of curved edge. Optional vertex link defines where.","AttachmentPlane mode tooltip"));
160
return TwoStrings(qApp->translate("Attacher2D", "Frenet TN","AttachmentPlane mode caption"),
161
qApp->translate("Attacher2D", "Align to Frenet-Serret coordinate system of curved edge. Optional vertex link defines where.","AttachmentPlane mode tooltip"));
163
return TwoStrings(qApp->translate("Attacher2D", "Frenet TB","AttachmentPlane mode caption"),
164
qApp->translate("Attacher2D", "Align to Frenet-Serret coordinate system of curved edge. Optional vertex link defines where.","AttachmentPlane mode tooltip"));
166
return TwoStrings(qApp->translate("Attacher2D", "Concentric","AttachmentPlane mode caption"),
167
qApp->translate("Attacher2D", "Align to plane to osculating circle of an edge. Origin is aligned to point of curvature. Optional vertex link defines where.","AttachmentPlane mode tooltip"));
168
case mmRevolutionSection:
169
return TwoStrings(qApp->translate("Attacher2D", "Revolution Section","AttachmentPlane mode caption"),
170
qApp->translate("Attacher2D", "Plane is perpendicular to edge, and Y axis is matched with axis of osculating circle. Optional vertex link defines where.","AttachmentPlane mode tooltip"));
171
case mmThreePointsPlane:
172
return TwoStrings(qApp->translate("Attacher2D", "Plane by 3 points","AttachmentPlane mode caption"),
173
qApp->translate("Attacher2D", "Align plane to pass through three vertices.","AttachmentPlane mode tooltip"));
174
case mmThreePointsNormal:
175
return TwoStrings(qApp->translate("Attacher2D", "Normal to 3 points","AttachmentPlane mode caption"),
176
qApp->translate("Attacher2D", "Plane will pass through first two vertices, and perpendicular to plane that passes through three vertices.","AttachmentPlane mode tooltip"));
178
return TwoStrings(qApp->translate("Attacher2D", "Folding","AttachmentPlane mode caption"),
179
qApp->translate("Attacher2D", "Specialty mode for folding polyhedra. Select 4 edges in order: foldable edge, fold line, other fold line, other foldable edge. Plane will be aligned to folding the first edge.","AttachmentPlane mode tooltip"));
181
return TwoStrings(qApp->translate("Attacher2D", "Inertia 2-3","AttachmentPlane mode caption"),
182
qApp->translate("Attacher2D", "Plane constructed on second and third principal axes of inertia (passes through center of mass).","AttachmentPlane mode tooltip"));
184
return TwoStrings(qApp->translate("Attacher3D", "Align O-N-X","Attachment3D mode caption"),
185
qApp->translate("Attacher3D", "Match origin with first Vertex. Align normal and horizontal plane axis towards vertex/along line.","Attachment3D mode tooltip"));
187
return TwoStrings(qApp->translate("Attacher3D", "Align O-N-Y","Attachment3D mode caption"),
188
qApp->translate("Attacher3D", "Match origin with first Vertex. Align normal and vertical plane axis towards vertex/along line.","Attachment3D mode tooltip"));
190
return TwoStrings(qApp->translate("Attacher3D", "Align O-X-Y","Attachment3D mode caption"),
191
qApp->translate("Attacher3D", "Match origin with first Vertex. Align horizontal and vertical plane axes towards vertex/along line.","Attachment3D mode tooltip"));
193
return TwoStrings(qApp->translate("Attacher3D", "Align O-X-N","Attachment3D mode caption"),
194
qApp->translate("Attacher3D", "Match origin with first Vertex. Align horizontal plane axis and normal towards vertex/along line.","Attachment3D mode tooltip"));
196
return TwoStrings(qApp->translate("Attacher3D", "Align O-Y-N","Attachment3D mode caption"),
197
qApp->translate("Attacher3D", "Match origin with first Vertex. Align vertical plane axis and normal towards vertex/along line.","Attachment3D mode tooltip"));
199
return TwoStrings(qApp->translate("Attacher3D", "Align O-Y-X","Attachment3D mode caption"),
200
qApp->translate("Attacher3D", "Match origin with first Vertex. Align vertical and horizontal plane axes towards vertex/along line.","Attachment3D mode tooltip"));
204
} else if (attacherType.isDerivedFrom(AttachEngineLine::getClassTypeId())){
205
//---- Line attacher ----
208
return TwoStrings(qApp->translate("Attacher1D", "Deactivated","AttachmentLine mode caption"),
209
qApp->translate("Attacher1D", "Attachment is disabled. Line can be moved by editing Placement property.","AttachmentLine mode tooltip"));
211
return TwoStrings(qApp->translate("Attacher1D", "Object's X","AttachmentLine mode caption"),
212
qApp->translate("Attacher1D", "Line is aligned along local X axis of object. Works on objects with placements, and ellipse/parabola/hyperbola edges.","AttachmentLine mode tooltip"));
214
return TwoStrings(qApp->translate("Attacher1D", "Object's Y","AttachmentLine mode caption"),
215
qApp->translate("Attacher1D", "Line is aligned along local Y axis of object. Works on objects with placements, and ellipse/parabola/hyperbola edges.","AttachmentLine mode tooltip"));
217
return TwoStrings(qApp->translate("Attacher1D", "Object's Z","AttachmentLine mode caption"),
218
qApp->translate("Attacher1D", "Line is aligned along local X axis of object. Works on objects with placements, and ellipse/parabola/hyperbola edges.","AttachmentLine mode tooltip"));
220
return TwoStrings(qApp->translate("Attacher1D", "Axis of curvature","AttachmentLine mode caption"),
221
qApp->translate("Attacher1D", "Line that is an axis of osculating circle of curved edge. Optional vertex defines where.","AttachmentLine mode tooltip"));
223
return TwoStrings(qApp->translate("Attacher1D", "Directrix1","AttachmentLine mode caption"),
224
qApp->translate("Attacher1D", "Directrix line for ellipse, parabola, hyperbola.","AttachmentLine mode tooltip"));
226
return TwoStrings(qApp->translate("Attacher1D", "Directrix2","AttachmentLine mode caption"),
227
qApp->translate("Attacher1D", "Second directrix line for ellipse and hyperbola.","AttachmentLine mode tooltip"));
229
return TwoStrings(qApp->translate("Attacher1D", "Asymptote1","AttachmentLine mode caption"),
230
qApp->translate("Attacher1D", "Asymptote of a hyperbola.","AttachmentLine mode tooltip"));
232
return TwoStrings(qApp->translate("Attacher1D", "Asymptote2","AttachmentLine mode caption"),
233
qApp->translate("Attacher1D", "Second asymptote of hyperbola.","AttachmentLine mode tooltip"));
235
return TwoStrings(qApp->translate("Attacher1D", "Tangent","AttachmentLine mode caption"),
236
qApp->translate("Attacher1D", "Line tangent to an edge. Optional vertex link defines where.","AttachmentLine mode tooltip"));
238
return TwoStrings(qApp->translate("Attacher1D", "Normal to edge","AttachmentLine mode caption"),
239
qApp->translate("Attacher1D", "Align to N vector of Frenet-Serret coordinate system of curved edge. Optional vertex link defines where.","AttachmentLine mode tooltip"));
241
return TwoStrings(qApp->translate("Attacher1D", "Binormal","AttachmentLine mode caption"),
242
qApp->translate("Attacher1D", "Align to B vector of Frenet-Serret coordinate system of curved edge. Optional vertex link defines where.","AttachmentLine mode tooltip"));
244
return TwoStrings(qApp->translate("Attacher1D", "Tangent to surface (U)","AttachmentLine mode caption"),
245
qApp->translate("Attacher1D", "Tangent to surface, along U parameter. Vertex link defines where.","AttachmentLine mode tooltip"));
247
return TwoStrings(qApp->translate("Attacher1D", "Tangent to surface (V)","AttachmentLine mode caption"),
248
qApp->translate("Attacher1D", "Tangent to surface, along U parameter. Vertex link defines where.","AttachmentLine mode tooltip"));
250
return TwoStrings(qApp->translate("Attacher1D", "Through two points","AttachmentLine mode caption"),
251
qApp->translate("Attacher1D", "Line that passes through two vertices.","AttachmentLine mode tooltip"));
252
case mm1Intersection:
253
return TwoStrings(qApp->translate("Attacher1D", "Intersection","AttachmentLine mode caption"),
254
qApp->translate("Attacher1D", "Intersection of two faces.","AttachmentLine mode tooltip"));
256
return TwoStrings(qApp->translate("Attacher1D", "Proximity line","AttachmentLine mode caption"),
257
qApp->translate("Attacher1D", "Line that spans the shortest distance between shapes.","AttachmentLine mode tooltip"));
258
case mm1AxisInertia1:
259
return TwoStrings(qApp->translate("Attacher1D", "1st principal axis","AttachmentLine mode caption"),
260
qApp->translate("Attacher1D", "Line follows first principal axis of inertia.","AttachmentLine mode tooltip"));
261
case mm1AxisInertia2:
262
return TwoStrings(qApp->translate("Attacher1D", "2nd principal axis","AttachmentLine mode caption"),
263
qApp->translate("Attacher1D", "Line follows second principal axis of inertia.","AttachmentLine mode tooltip"));
264
case mm1AxisInertia3:
265
return TwoStrings(qApp->translate("Attacher1D", "3rd principal axis","AttachmentLine mode caption"),
266
qApp->translate("Attacher1D", "Line follows third principal axis of inertia.","AttachmentLine mode tooltip"));
268
return TwoStrings(qApp->translate("Attacher1D", "Normal to surface","AttachmentLine mode caption"),
269
qApp->translate("Attacher1D", "Line perpendicular to surface at point set by vertex.","AttachmentLine mode tooltip"));
273
} else if (attacherType.isDerivedFrom(AttachEnginePoint::getClassTypeId())){
274
//---- Point attacher ----
277
return TwoStrings(qApp->translate("Attacher0D", "Deactivated","AttachmentPoint mode caption"),
278
qApp->translate("Attacher0D", "Attachment is disabled. Point can be moved by editing Placement property.","AttachmentPoint mode tooltip"));
280
return TwoStrings(qApp->translate("Attacher0D", "Object's origin","AttachmentPoint mode caption"),
281
qApp->translate("Attacher0D", "Point is put at object's placement position. Works on objects with placements, and ellipse/parabola/hyperbola edges.","AttachmentPoint mode tooltip"));
283
return TwoStrings(qApp->translate("Attacher0D", "Focus1","AttachmentPoint mode caption"),
284
qApp->translate("Attacher0D", "Focus of ellipse, parabola, hyperbola.","AttachmentPoint mode tooltip"));
286
return TwoStrings(qApp->translate("Attacher0D", "Focus2","AttachmentPoint mode caption"),
287
qApp->translate("Attacher0D", "Second focus of ellipse and hyperbola.","AttachmentPoint mode tooltip"));
289
return TwoStrings(qApp->translate("Attacher0D", "On edge","AttachmentPoint mode caption"),
290
qApp->translate("Attacher0D", "Point is put on edge, MapPathParameter controls where. Additionally, vertex can be linked in for making a projection.","AttachmentPoint mode tooltip"));
291
case mm0CenterOfCurvature:
292
return TwoStrings(qApp->translate("Attacher0D", "Center of curvature","AttachmentPoint mode caption"),
293
qApp->translate("Attacher0D", "Center of osculating circle of an edge. Optional vertex link defines where.","AttachmentPoint mode tooltip"));
294
case mm0CenterOfMass:
295
return TwoStrings(qApp->translate("Attacher0D", "Center of mass","AttachmentPoint mode caption"),
296
qApp->translate("Attacher0D", "Center of mass of all references (equal densities are assumed).","AttachmentPoint mode tooltip"));
297
case mm0Intersection:
298
return TwoStrings(qApp->translate("Attacher0D", "Intersection","AttachmentPoint mode caption"),
299
qApp->translate("Attacher0D", "Not implemented","AttachmentPoint mode tooltip"));
301
return TwoStrings(qApp->translate("Attacher0D", "Vertex","AttachmentPoint mode caption"),
302
qApp->translate("Attacher0D", "Put Datum point coincident with another vertex.","AttachmentPoint mode tooltip"));
303
case mm0ProximityPoint1:
304
return TwoStrings(qApp->translate("Attacher0D", "Proximity point 1","AttachmentPoint mode caption"),
305
qApp->translate("Attacher0D", "Point on first reference that is closest to second reference.","AttachmentPoint mode tooltip"));
306
case mm0ProximityPoint2:
307
return TwoStrings(qApp->translate("Attacher0D", "Proximity point 2","AttachmentPoint mode caption"),
308
qApp->translate("Attacher0D", "Point on second reference that is closest to first reference.","AttachmentPoint mode tooltip"));
314
Base::Console().Warning("No user-friendly string defined for this attachment mode and attacher type: %s %s \n",AttachEngine::getModeName(mmode).c_str(), attacherType.getName());
315
return TwoStrings(QString::fromStdString(AttachEngine::getModeName(mmode)), QString());
318
//Note: this list must be in sync with eRefType enum
319
static struct { const char *txt; const char *comment; } eRefTypeStrings[] = {
320
QT_TRANSLATE_NOOP3("Attacher", "Any", "Attacher reference type"),
321
QT_TRANSLATE_NOOP3("Attacher", "Vertex", "Attacher reference type"),
322
QT_TRANSLATE_NOOP3("Attacher", "Edge", "Attacher reference type"),
323
QT_TRANSLATE_NOOP3("Attacher", "Face", "Attacher reference type"),
325
QT_TRANSLATE_NOOP3("Attacher", "Line", "Attacher reference type"),
326
QT_TRANSLATE_NOOP3("Attacher", "Curve", "Attacher reference type"),
327
QT_TRANSLATE_NOOP3("Attacher", "Circle", "Attacher reference type"),
328
QT_TRANSLATE_NOOP3("Attacher", "Conic", "Attacher reference type"),
329
QT_TRANSLATE_NOOP3("Attacher", "Ellipse", "Attacher reference type"),
330
QT_TRANSLATE_NOOP3("Attacher", "Parabola", "Attacher reference type"),
331
QT_TRANSLATE_NOOP3("Attacher", "Hyperbola", "Attacher reference type"),
333
QT_TRANSLATE_NOOP3("Attacher", "Plane", "Attacher reference type"),
334
QT_TRANSLATE_NOOP3("Attacher", "Sphere", "Attacher reference type"),
335
QT_TRANSLATE_NOOP3("Attacher", "Revolve", "Attacher reference type"),
336
QT_TRANSLATE_NOOP3("Attacher", "Cylinder", "Attacher reference type"),
337
QT_TRANSLATE_NOOP3("Attacher", "Torus", "Attacher reference type"),
338
QT_TRANSLATE_NOOP3("Attacher", "Cone", "Attacher reference type"),
340
QT_TRANSLATE_NOOP3("Attacher", "Object", "Attacher reference type"),
341
QT_TRANSLATE_NOOP3("Attacher", "Solid", "Attacher reference type"),
342
QT_TRANSLATE_NOOP3("Attacher", "Wire", "Attacher reference type"),
349
QString getShapeTypeText(eRefType type)
351
//get rid of flags in type
352
type = eRefType(type & (rtFlagHasPlacement - 1));
354
if (type >= 0 && type < rtDummy_numberOfShapeTypes){
355
if (eRefTypeStrings[int(type)].txt){
356
return qApp->translate("Attacher", eRefTypeStrings[int(type)].txt, eRefTypeStrings[int(type)].comment);
360
throw Base::TypeError("getShTypeText: type value is wrong, or a string is missing in the list");
363
QStringList getRefListForMode(AttachEngine &attacher, eMapMode mmode)
365
refTypeStringList list = attacher.modeRefTypes[mmode];
367
for(refTypeString &rts : list){
369
for(eRefType rt : rts){
370
buf.append(getShapeTypeText(rt));
372
strlist.append(buf.join(QString::fromLatin1(", ")));
378
// --------------------Py interface---------------------
380
PyObject* AttacherGuiPy::sGetModeStrings(PyObject * /*self*/, PyObject *args)
384
if (!PyArg_ParseTuple(args, "si", &attacherType, &modeIndex))
388
Base::Type t = Base::Type::fromName(attacherType);
389
if (! t.isDerivedFrom(AttachEngine::getClassTypeId())){
390
std::stringstream ss;
391
ss << "Object of this type is not derived from AttachEngine: ";
393
throw Py::TypeError(ss.str());
395
TextSet strs = getUIStrings(t,eMapMode(modeIndex));
397
for(QString &s : strs){
398
QByteArray ba_utf8 = s.toUtf8();
399
result.append(Py::String(ba_utf8.data(), "utf-8"));
402
return Py::new_reference_to(result);
403
} catch (const Py::Exception&) {
405
} catch (const Base::Exception& e) {
411
PyObject* AttacherGuiPy::sGetRefTypeUserFriendlyName(PyObject * /*self*/, PyObject *args)
413
int refTypeIndex = 0;
414
if (!PyArg_ParseTuple(args, "i", &refTypeIndex))
418
QByteArray ba_utf8 = getShapeTypeText(eRefType(refTypeIndex)).toUtf8();
419
return Py::new_reference_to(Py::String(ba_utf8.data(), "utf-8"));
420
} catch (const Py::Exception&) {
422
} catch (const Base::Exception& e) {
429
PyMethodDef AttacherGuiPy::Methods[] = {
430
{"getModeStrings", (PyCFunction) AttacherGuiPy::sGetModeStrings, METH_VARARGS,
431
"getModeStrings(attacher_type, mode_index) - gets mode user-friendly name and brief description."},
432
{"getRefTypeUserFriendlyName", (PyCFunction) AttacherGuiPy::sGetRefTypeUserFriendlyName, METH_VARARGS,
433
"getRefTypeUserFriendlyName(type_index) - gets user-friendly name of AttachEngine's shape type."},
434
{nullptr, nullptr, 0, nullptr} /* Sentinel */
438
} //namespace AttacherGui