FreeCAD

Форк
0
/
AttacherTexts.cpp 
438 строк · 31.3 Кб
1
/***************************************************************************
2
 *   Copyright (c) 2016 Victor Titov (DeepSOIC) <vv.titov@gmail.com>       *
3
 *                                                                         *
4
 *   This file is part of the FreeCAD CAx development system.              *
5
 *                                                                         *
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.      *
10
 *                                                                         *
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.                  *
15
 *                                                                         *
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                                *
20
 *                                                                         *
21
 ***************************************************************************/
22

23
#include "PreCompiled.h"
24
#ifndef _PreComp_
25
# include <QApplication>
26
#endif
27

28
#include <Base/Console.h>
29

30
#include "AttacherTexts.h"
31

32

33
using namespace Attacher;
34

35
namespace AttacherGui {
36

37
TextSet TwoStrings(QString str1, QString str2)
38
{
39
    std::vector<QString> v;
40
    v.resize(2);
41
    v[0] = str1;
42
    v[1] = str2;
43
    return v;
44
}
45

46
TextSet getUIStrings(Base::Type attacherType, eMapMode mmode)
47
{
48
    if (attacherType.isDerivedFrom(AttachEngine3D::getClassTypeId())){
49
        //---- coordinate system attacher ----
50
        switch (mmode){
51
        case mmDeactivated:
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"));
54
        case mmTranslate:
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"));
57
        case mmObjectXY:
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"));
60
        case mmObjectXZ:
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"));
63
        case mmObjectYZ:
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"));
66
        case mmParallelPlane:
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"));
69
        case mmFlatFace:
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"));
72
        case mmTangentPlane:
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"));
75
        case mmNormalToPath:
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"));
78
        case mmFrenetNB:
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"));
81
        case mmFrenetTN:
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"));
84
        case mmFrenetTB:
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"));
87
        case mmConcentric:
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"));
99
        case mmFolding:
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"));
102
        case mmInertialCS:
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"));
105
        case mmOZX:
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"));
108
        case mmOZY:
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"));
111
        case mmOXY:
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"));
114
        case mmOXZ:
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"));
117
        case mmOYZ:
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"));
120
        case mmOYX:
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"));
123
        default:
124
            break;
125
        }
126
    } else if (attacherType.isDerivedFrom(AttachEnginePlane::getClassTypeId())){
127
        //---- Plane/sketch attacher ----
128
        switch (mmode){
129
        case mmDeactivated:
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"));
132
        case mmTranslate:
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"));
135
        case mmObjectXY:
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"));
138
        case mmObjectXZ:
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"));
141
        case mmObjectYZ:
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"));
147
        case mmFlatFace:
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"));
150
        case mmTangentPlane:
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"));
153
        case mmNormalToPath:
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"));
156
        case mmFrenetNB:
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"));
159
        case mmFrenetTN:
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"));
162
        case mmFrenetTB:
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"));
165
        case mmConcentric:
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"));
177
        case mmFolding:
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"));
180
        case mmInertialCS:
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"));
183
        case mmOZX:
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"));
186
        case mmOZY:
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"));
189
        case mmOXY:
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"));
192
        case mmOXZ:
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"));
195
        case mmOYZ:
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"));
198
        case mmOYX:
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"));
201
        default:
202
            break;
203
        }
204
    } else if (attacherType.isDerivedFrom(AttachEngineLine::getClassTypeId())){
205
        //---- Line attacher ----
206
        switch (mmode){
207
        case mmDeactivated:
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"));
210
        case mm1AxisX:
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"));
213
        case mm1AxisY:
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"));
216
        case mm1AxisZ:
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"));
219
        case mm1AxisCurv:
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"));
222
        case mm1Directrix1:
223
            return TwoStrings(qApp->translate("Attacher1D", "Directrix1","AttachmentLine mode caption"),
224
                              qApp->translate("Attacher1D", "Directrix line for ellipse, parabola, hyperbola.","AttachmentLine mode tooltip"));
225
        case mm1Directrix2:
226
            return TwoStrings(qApp->translate("Attacher1D", "Directrix2","AttachmentLine mode caption"),
227
                              qApp->translate("Attacher1D", "Second directrix line for ellipse and hyperbola.","AttachmentLine mode tooltip"));
228
        case mm1Asymptote1:
229
            return TwoStrings(qApp->translate("Attacher1D", "Asymptote1","AttachmentLine mode caption"),
230
                              qApp->translate("Attacher1D", "Asymptote of a hyperbola.","AttachmentLine mode tooltip"));
231
        case mm1Asymptote2:
232
            return TwoStrings(qApp->translate("Attacher1D", "Asymptote2","AttachmentLine mode caption"),
233
                              qApp->translate("Attacher1D", "Second asymptote of hyperbola.","AttachmentLine mode tooltip"));
234
        case mm1Tangent:
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"));
237
        case mm1Normal:
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"));
240
        case mm1Binormal:
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"));
243
        case mm1TangentU:
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"));
246
        case mm1TangentV:
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"));
249
        case mm1TwoPoints:
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"));
255
        case mm1Proximity:
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"));
267
        case mm1FaceNormal:
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"));
270
        default:
271
            break;
272
        }
273
    } else if (attacherType.isDerivedFrom(AttachEnginePoint::getClassTypeId())){
274
        //---- Point attacher ----
275
        switch (mmode){
276
        case mmDeactivated:
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"));
279
        case mm0Origin:
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"));
282
        case mm0Focus1:
283
            return TwoStrings(qApp->translate("Attacher0D", "Focus1","AttachmentPoint mode caption"),
284
                              qApp->translate("Attacher0D", "Focus of ellipse, parabola, hyperbola.","AttachmentPoint mode tooltip"));
285
        case mm0Focus2:
286
            return TwoStrings(qApp->translate("Attacher0D", "Focus2","AttachmentPoint mode caption"),
287
                              qApp->translate("Attacher0D", "Second focus of ellipse and hyperbola.","AttachmentPoint mode tooltip"));
288
        case mm0OnEdge:
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"));
300
        case mm0Vertex:
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"));
309
        default:
310
            break;
311
        }
312
    }
313

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());
316
}
317

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"),
324

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"),
332

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"),
339

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"),
343
    {nullptr, nullptr},
344
    {nullptr, nullptr},
345
    {nullptr, nullptr}
346
};
347

348

349
QString getShapeTypeText(eRefType type)
350
{
351
    //get rid of flags in type
352
    type = eRefType(type & (rtFlagHasPlacement - 1));
353

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);
357
        }
358
    }
359

360
    throw Base::TypeError("getShTypeText: type value is wrong, or a string is missing in the list");
361
}
362

363
QStringList getRefListForMode(AttachEngine &attacher, eMapMode mmode)
364
{
365
    refTypeStringList list = attacher.modeRefTypes[mmode];
366
    QStringList strlist;
367
    for(refTypeString &rts : list){
368
        QStringList buf;
369
        for(eRefType rt : rts){
370
            buf.append(getShapeTypeText(rt));
371
        }
372
        strlist.append(buf.join(QString::fromLatin1(", ")));
373
    }
374
    return strlist;
375
}
376

377

378
// --------------------Py interface---------------------
379

380
PyObject* AttacherGuiPy::sGetModeStrings(PyObject * /*self*/, PyObject *args)
381
{
382
    int modeIndex = 0;
383
    char* attacherType;
384
    if (!PyArg_ParseTuple(args, "si", &attacherType, &modeIndex))
385
        return nullptr;
386

387
    try {
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: ";
392
            ss << attacherType;
393
            throw Py::TypeError(ss.str());
394
        }
395
        TextSet strs = getUIStrings(t,eMapMode(modeIndex));
396
        Py::List result;
397
        for(QString &s : strs){
398
            QByteArray ba_utf8 = s.toUtf8();
399
            result.append(Py::String(ba_utf8.data(), "utf-8"));
400
        }
401

402
        return Py::new_reference_to(result);
403
    } catch (const Py::Exception&) {
404
        return nullptr;
405
    } catch (const Base::Exception& e) {
406
        e.setPyException();
407
        return nullptr;
408
    }
409
}
410

411
PyObject* AttacherGuiPy::sGetRefTypeUserFriendlyName(PyObject * /*self*/, PyObject *args)
412
{
413
    int refTypeIndex = 0;
414
    if (!PyArg_ParseTuple(args, "i", &refTypeIndex))
415
        return nullptr;
416

417
    try {
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&) {
421
        return nullptr;
422
    } catch (const Base::Exception& e) {
423
        e.setPyException();
424
        return nullptr;
425
    }
426
}
427

428

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 */
435
};
436

437

438
} //namespace AttacherGui
439

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.