16
16
***************************************************************************/
17
17
18
18
#include " qgsmeshrenderersettings.h"
19
-
20
19
#include " qgssymbollayerutils.h"
21
20
22
21
@@ -52,18 +51,18 @@ void QgsMeshRendererMeshSettings::setColor( const QColor &color )
52
51
53
52
QDomElement QgsMeshRendererMeshSettings::writeXml ( QDomDocument &doc ) const
54
53
{
55
- QDomElement elem = doc.createElement ( " mesh-settings" );
56
- elem.setAttribute ( " enabled" , mEnabled ? " 1" : " 0" );
57
- elem.setAttribute ( " line-width" , mLineWidth );
58
- elem.setAttribute ( " color" , QgsSymbolLayerUtils::encodeColor ( mColor ) );
54
+ QDomElement elem = doc.createElement ( QStringLiteral ( " mesh-settings" ) );
55
+ elem.setAttribute ( QStringLiteral ( " enabled" ) , mEnabled ? QStringLiteral ( " 1" ) : QStringLiteral ( " 0" ) );
56
+ elem.setAttribute ( QStringLiteral ( " line-width" ) , mLineWidth );
57
+ elem.setAttribute ( QStringLiteral ( " color" ) , QgsSymbolLayerUtils::encodeColor ( mColor ) );
59
58
return elem;
60
59
}
61
60
62
61
void QgsMeshRendererMeshSettings::readXml ( const QDomElement &elem )
63
62
{
64
- mEnabled = elem.attribute ( " enabled" ).toInt ();
65
- mLineWidth = elem.attribute ( " line-width" ).toDouble ();
66
- mColor = QgsSymbolLayerUtils::decodeColor ( elem.attribute ( " color" ) );
63
+ mEnabled = elem.attribute ( QStringLiteral ( " enabled" ) ).toInt ();
64
+ mLineWidth = elem.attribute ( QStringLiteral ( " line-width" ) ).toDouble ();
65
+ mColor = QgsSymbolLayerUtils::decodeColor ( elem.attribute ( QStringLiteral ( " color" ) ) );
67
66
}
68
67
69
68
// ---------------------------------------------------------------------
@@ -94,20 +93,20 @@ void QgsMeshRendererScalarSettings::setOpacity( double opacity ) { mOpacity = op
94
93
95
94
QDomElement QgsMeshRendererScalarSettings::writeXml ( QDomDocument &doc ) const
96
95
{
97
- QDomElement elem = doc.createElement ( " scalar-settings" );
98
- elem.setAttribute ( " min-val" , mClassificationMinimum );
99
- elem.setAttribute ( " max-val" , mClassificationMaximum );
100
- elem.setAttribute ( " opacity" , mOpacity );
96
+ QDomElement elem = doc.createElement ( QStringLiteral ( " scalar-settings" ) );
97
+ elem.setAttribute ( QStringLiteral ( " min-val" ) , mClassificationMinimum );
98
+ elem.setAttribute ( QStringLiteral ( " max-val" ) , mClassificationMaximum );
99
+ elem.setAttribute ( QStringLiteral ( " opacity" ) , mOpacity );
101
100
QDomElement elemShader = mColorRampShader .writeXml ( doc );
102
101
elem.appendChild ( elemShader );
103
102
return elem;
104
103
}
105
104
106
105
void QgsMeshRendererScalarSettings::readXml ( const QDomElement &elem )
107
106
{
108
- mClassificationMinimum = elem.attribute ( " min-val" ).toDouble ();
109
- mClassificationMaximum = elem.attribute ( " max-val" ).toDouble ();
110
- mOpacity = elem.attribute ( " opacity" ).toDouble ();
107
+ mClassificationMinimum = elem.attribute ( QStringLiteral ( " min-val" ) ).toDouble ();
108
+ mClassificationMaximum = elem.attribute ( QStringLiteral ( " max-val" ) ).toDouble ();
109
+ mOpacity = elem.attribute ( QStringLiteral ( " opacity" ) ).toDouble ();
111
110
QDomElement elemShader = elem.firstChildElement ( QStringLiteral ( " colorrampshader" ) );
112
111
mColorRampShader .readXml ( elemShader );
113
112
}
@@ -256,107 +255,107 @@ void QgsMeshRendererVectorSettings::setUserGridCellHeight( int height )
256
255
257
256
QDomElement QgsMeshRendererVectorSettings::writeXml ( QDomDocument &doc ) const
258
257
{
259
- QDomElement elem = doc.createElement ( " vector-settings" );
260
- elem.setAttribute ( " line-width" , mLineWidth );
261
- elem.setAttribute ( " color" , QgsSymbolLayerUtils::encodeColor ( mColor ) );
262
- elem.setAttribute ( " filter-min" , mFilterMin );
263
- elem.setAttribute ( " filter-max" , mFilterMax );
264
- elem.setAttribute ( " arrow-head-width-ratio" , mArrowHeadWidthRatio );
265
- elem.setAttribute ( " arrow-head-length-ratio" , mArrowHeadLengthRatio );
266
- elem.setAttribute ( " user-grid-enabled" , mOnUserDefinedGrid ? " 1" : " 0" );
267
- elem.setAttribute ( " user-grid-width" , mUserGridCellWidth );
268
- elem.setAttribute ( " user-grid-height" , mUserGridCellHeight );
269
-
270
- QDomElement elemShaft = doc.createElement ( " shaft-length" );
258
+ QDomElement elem = doc.createElement ( QStringLiteral ( " vector-settings" ) );
259
+ elem.setAttribute ( QStringLiteral ( " line-width" ) , mLineWidth );
260
+ elem.setAttribute ( QStringLiteral ( " color" ) , QgsSymbolLayerUtils::encodeColor ( mColor ) );
261
+ elem.setAttribute ( QStringLiteral ( " filter-min" ) , mFilterMin );
262
+ elem.setAttribute ( QStringLiteral ( " filter-max" ) , mFilterMax );
263
+ elem.setAttribute ( QStringLiteral ( " arrow-head-width-ratio" ) , mArrowHeadWidthRatio );
264
+ elem.setAttribute ( QStringLiteral ( " arrow-head-length-ratio" ) , mArrowHeadLengthRatio );
265
+ elem.setAttribute ( QStringLiteral ( " user-grid-enabled" ) , mOnUserDefinedGrid ? QStringLiteral ( " 1" ) : QStringLiteral ( " 0" ) );
266
+ elem.setAttribute ( QStringLiteral ( " user-grid-width" ) , mUserGridCellWidth );
267
+ elem.setAttribute ( QStringLiteral ( " user-grid-height" ) , mUserGridCellHeight );
268
+
269
+ QDomElement elemShaft = doc.createElement ( QStringLiteral ( " shaft-length" ) );
271
270
QString methodTxt;
272
271
switch ( mShaftLengthMethod )
273
272
{
274
273
case MinMax:
275
- methodTxt = " minmax" ;
276
- elemShaft.setAttribute ( " min" , mMinShaftLength );
277
- elemShaft.setAttribute ( " max" , mMaxShaftLength );
274
+ methodTxt = QStringLiteral ( " minmax" ) ;
275
+ elemShaft.setAttribute ( QStringLiteral ( " min" ) , mMinShaftLength );
276
+ elemShaft.setAttribute ( QStringLiteral ( " max" ) , mMaxShaftLength );
278
277
break ;
279
278
case Scaled:
280
- methodTxt = " scaled" ;
281
- elemShaft.setAttribute ( " scale-factor" , mScaleFactor );
279
+ methodTxt = QStringLiteral ( " scaled" ) ;
280
+ elemShaft.setAttribute ( QStringLiteral ( " scale-factor" ) , mScaleFactor );
282
281
break ;
283
282
case Fixed:
284
- methodTxt = " fixed" ;
285
- elemShaft.setAttribute ( " fixed-length" , mFixedShaftLength );
283
+ methodTxt = QStringLiteral ( " fixed" ) ;
284
+ elemShaft.setAttribute ( QStringLiteral ( " fixed-length" ) , mFixedShaftLength );
286
285
break ;
287
286
}
288
- elemShaft.setAttribute ( " method" , methodTxt );
287
+ elemShaft.setAttribute ( QStringLiteral ( " method" ) , methodTxt );
289
288
elem.appendChild ( elemShaft );
290
289
return elem;
291
290
}
292
291
293
292
void QgsMeshRendererVectorSettings::readXml ( const QDomElement &elem )
294
293
{
295
- mLineWidth = elem.attribute ( " line-width" ).toDouble ();
296
- mColor = QgsSymbolLayerUtils::decodeColor ( elem.attribute ( " color" ) );
297
- mFilterMin = elem.attribute ( " filter-min" ).toDouble ();
298
- mFilterMax = elem.attribute ( " filter-max" ).toDouble ();
299
- mArrowHeadWidthRatio = elem.attribute ( " arrow-head-width-ratio" ).toDouble ();
300
- mArrowHeadLengthRatio = elem.attribute ( " arrow-head-length-ratio" ).toDouble ();
301
- mOnUserDefinedGrid = elem.attribute ( " user-grid-enabled" ).toInt (); // bool
302
- mUserGridCellWidth = elem.attribute ( " user-grid-width" ).toInt ();
303
- mUserGridCellHeight = elem.attribute ( " user-grid-height" ).toInt ();
304
-
305
- QDomElement elemShaft = elem.firstChildElement ( " shaft-length" );
306
- QString methodTxt = elemShaft.attribute ( " method" );
307
- if ( methodTxt == " minmax" )
294
+ mLineWidth = elem.attribute ( QStringLiteral ( " line-width" ) ).toDouble ();
295
+ mColor = QgsSymbolLayerUtils::decodeColor ( elem.attribute ( QStringLiteral ( " color" ) ) );
296
+ mFilterMin = elem.attribute ( QStringLiteral ( " filter-min" ) ).toDouble ();
297
+ mFilterMax = elem.attribute ( QStringLiteral ( " filter-max" ) ).toDouble ();
298
+ mArrowHeadWidthRatio = elem.attribute ( QStringLiteral ( " arrow-head-width-ratio" ) ).toDouble ();
299
+ mArrowHeadLengthRatio = elem.attribute ( QStringLiteral ( " arrow-head-length-ratio" ) ).toDouble ();
300
+ mOnUserDefinedGrid = elem.attribute ( QStringLiteral ( " user-grid-enabled" ) ).toInt (); // bool
301
+ mUserGridCellWidth = elem.attribute ( QStringLiteral ( " user-grid-width" ) ).toInt ();
302
+ mUserGridCellHeight = elem.attribute ( QStringLiteral ( " user-grid-height" ) ).toInt ();
303
+
304
+ QDomElement elemShaft = elem.firstChildElement ( QStringLiteral ( " shaft-length" ) );
305
+ QString methodTxt = elemShaft.attribute ( QStringLiteral ( " method" ) );
306
+ if ( QStringLiteral ( " minmax" ) == methodTxt )
308
307
{
309
308
mShaftLengthMethod = MinMax;
310
- mMinShaftLength = elemShaft.attribute ( " min" ).toDouble ();
311
- mMaxShaftLength = elemShaft.attribute ( " max" ).toDouble ();
309
+ mMinShaftLength = elemShaft.attribute ( QStringLiteral ( " min" ) ).toDouble ();
310
+ mMaxShaftLength = elemShaft.attribute ( QStringLiteral ( " max" ) ).toDouble ();
312
311
}
313
- else if ( methodTxt == " scaled" )
312
+ else if ( QStringLiteral ( " scaled" ) == methodTxt )
314
313
{
315
314
mShaftLengthMethod = Scaled;
316
- mScaleFactor = elemShaft.attribute ( " scale-factor" ).toDouble ();
315
+ mScaleFactor = elemShaft.attribute ( QStringLiteral ( " scale-factor" ) ).toDouble ();
317
316
}
318
317
else // fixed
319
318
{
320
319
mShaftLengthMethod = Fixed;
321
- mFixedShaftLength = elemShaft.attribute ( " fixed-length" ).toDouble ();
320
+ mFixedShaftLength = elemShaft.attribute ( QStringLiteral ( " fixed-length" ) ).toDouble ();
322
321
}
323
322
}
324
323
325
324
// ---------------------------------------------------------------------
326
325
327
326
QDomElement QgsMeshRendererSettings::writeXml ( QDomDocument &doc ) const
328
327
{
329
- QDomElement elem = doc.createElement ( " mesh-renderer-settings" );
328
+ QDomElement elem = doc.createElement ( QStringLiteral ( " mesh-renderer-settings" ) );
330
329
331
- QDomElement elemActiveDataset = doc.createElement ( " active-dataset" );
330
+ QDomElement elemActiveDataset = doc.createElement ( QStringLiteral ( " active-dataset" ) );
332
331
if ( mActiveScalarDataset .isValid () )
333
- elemActiveDataset.setAttribute ( " scalar" , QString ( " %1,%2" ).arg ( mActiveScalarDataset .group () ).arg ( mActiveScalarDataset .dataset () ) );
332
+ elemActiveDataset.setAttribute ( QStringLiteral ( " scalar" ), QStringLiteral ( " %1,%2" ).arg ( mActiveScalarDataset .group () ).arg ( mActiveScalarDataset .dataset () ) );
334
333
if ( mActiveVectorDataset .isValid () )
335
- elemActiveDataset.setAttribute ( " vector" , QString ( " %1,%2" ).arg ( mActiveVectorDataset .group () ).arg ( mActiveVectorDataset .dataset () ) );
334
+ elemActiveDataset.setAttribute ( QStringLiteral ( " vector" ), QStringLiteral ( " %1,%2" ).arg ( mActiveVectorDataset .group () ).arg ( mActiveVectorDataset .dataset () ) );
336
335
elem.appendChild ( elemActiveDataset );
337
336
338
337
for ( int groupIndex : mRendererScalarSettings .keys () )
339
338
{
340
339
const QgsMeshRendererScalarSettings &scalarSettings = mRendererScalarSettings [groupIndex];
341
340
QDomElement elemScalar = scalarSettings.writeXml ( doc );
342
- elemScalar.setAttribute ( " group" , groupIndex );
341
+ elemScalar.setAttribute ( QStringLiteral ( " group" ) , groupIndex );
343
342
elem.appendChild ( elemScalar );
344
343
}
345
344
346
345
for ( int groupIndex : mRendererVectorSettings .keys () )
347
346
{
348
347
const QgsMeshRendererVectorSettings &vectorSettings = mRendererVectorSettings [groupIndex];
349
348
QDomElement elemVector = vectorSettings.writeXml ( doc );
350
- elemVector.setAttribute ( " group" , groupIndex );
349
+ elemVector.setAttribute ( QStringLiteral ( " group" ) , groupIndex );
351
350
elem.appendChild ( elemVector );
352
351
}
353
352
354
353
QDomElement elemNativeMesh = mRendererNativeMeshSettings .writeXml ( doc );
355
- elemNativeMesh.setTagName ( " mesh-settings-native" );
354
+ elemNativeMesh.setTagName ( QStringLiteral ( " mesh-settings-native" ) );
356
355
elem.appendChild ( elemNativeMesh );
357
356
358
357
QDomElement elemTriangularMesh = mRendererTriangularMeshSettings .writeXml ( doc );
359
- elemTriangularMesh.setTagName ( " mesh-settings-triangular" );
358
+ elemTriangularMesh.setTagName ( QStringLiteral ( " mesh-settings-triangular" ) );
360
359
elem.appendChild ( elemTriangularMesh );
361
360
362
361
return elem;
@@ -367,45 +366,45 @@ void QgsMeshRendererSettings::readXml( const QDomElement &elem )
367
366
mRendererScalarSettings .clear ();
368
367
mRendererVectorSettings .clear ();
369
368
370
- QDomElement elemActiveDataset = elem.firstChildElement ( " active-dataset" );
371
- if ( elemActiveDataset.hasAttribute ( " scalar" ) )
369
+ QDomElement elemActiveDataset = elem.firstChildElement ( QStringLiteral ( " active-dataset" ) );
370
+ if ( elemActiveDataset.hasAttribute ( QStringLiteral ( " scalar" ) ) )
372
371
{
373
- QStringList lst = elemActiveDataset.attribute ( " scalar" ).split ( QChar ( ' ,' ) );
372
+ QStringList lst = elemActiveDataset.attribute ( QStringLiteral ( " scalar" ) ).split ( QChar ( ' ,' ) );
374
373
if ( lst.count () == 2 )
375
374
mActiveScalarDataset = QgsMeshDatasetIndex ( lst[0 ].toInt (), lst[1 ].toInt () );
376
375
}
377
- if ( elemActiveDataset.hasAttribute ( " vector" ) )
376
+ if ( elemActiveDataset.hasAttribute ( QStringLiteral ( " vector" ) ) )
378
377
{
379
- QStringList lst = elemActiveDataset.attribute ( " vector" ).split ( QChar ( ' ,' ) );
378
+ QStringList lst = elemActiveDataset.attribute ( QStringLiteral ( " vector" ) ).split ( QChar ( ' ,' ) );
380
379
if ( lst.count () == 2 )
381
380
mActiveVectorDataset = QgsMeshDatasetIndex ( lst[0 ].toInt (), lst[1 ].toInt () );
382
381
}
383
382
384
- QDomElement elemScalar = elem.firstChildElement ( " scalar-settings" );
383
+ QDomElement elemScalar = elem.firstChildElement ( QStringLiteral ( " scalar-settings" ) );
385
384
while ( !elemScalar.isNull () )
386
385
{
387
- int groupIndex = elemScalar.attribute ( " group" ).toInt ();
386
+ int groupIndex = elemScalar.attribute ( QStringLiteral ( " group" ) ).toInt ();
388
387
QgsMeshRendererScalarSettings scalarSettings;
389
388
scalarSettings.readXml ( elemScalar );
390
389
mRendererScalarSettings .insert ( groupIndex, scalarSettings );
391
390
392
- elemScalar = elemScalar.nextSiblingElement ( " scalar-settings" );
391
+ elemScalar = elemScalar.nextSiblingElement ( QStringLiteral ( " scalar-settings" ) );
393
392
}
394
393
395
- QDomElement elemVector = elem.firstChildElement ( " vector-settings" );
394
+ QDomElement elemVector = elem.firstChildElement ( QStringLiteral ( " vector-settings" ) );
396
395
while ( !elemVector.isNull () )
397
396
{
398
- int groupIndex = elemVector.attribute ( " group" ).toInt ();
397
+ int groupIndex = elemVector.attribute ( QStringLiteral ( " group" ) ).toInt ();
399
398
QgsMeshRendererVectorSettings vectorSettings;
400
399
vectorSettings.readXml ( elemVector );
401
400
mRendererVectorSettings .insert ( groupIndex, vectorSettings );
402
401
403
- elemVector = elemVector.nextSiblingElement ( " vector-settings" );
402
+ elemVector = elemVector.nextSiblingElement ( QStringLiteral ( " vector-settings" ) );
404
403
}
405
404
406
- QDomElement elemNativeMesh = elem.firstChildElement ( " mesh-settings-native" );
405
+ QDomElement elemNativeMesh = elem.firstChildElement ( QStringLiteral ( " mesh-settings-native" ) );
407
406
mRendererNativeMeshSettings .readXml ( elemNativeMesh );
408
407
409
- QDomElement elemTriangularMesh = elem.firstChildElement ( " mesh-settings-triangular" );
408
+ QDomElement elemTriangularMesh = elem.firstChildElement ( QStringLiteral ( " mesh-settings-triangular" ) );
410
409
mRendererTriangularMeshSettings .readXml ( elemTriangularMesh );
411
410
}
0 commit comments