• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mcallegari / qlcplus / 40373018628

26 Oct 2026 05:54PM UTC coverage: 36.706% (+0.6%) from 36.13%
40373018628

push

github

web-flow
Merge pull request #2203 from mjcmatrix/up-fix-showrunner-shared-functions

engine: fix Show items sharing a Function and beat items on mid-way start

29 of 30 new or added lines in 1 file covered. (96.67%)

451 existing lines in 4 files now uncovered.

19161 of 52201 relevant lines covered (36.71%)

42040.24 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

39.22
/engine/src/monitorproperties.cpp
1
/*
2
  Q Light Controller Plus
3
  monitorproperties.cpp
4

5
  Copyright (c) Massimo Callegari
6

7
  Licensed under the Apache License, Version 2.0 (the "License");
8
  you may not use this file except in compliance with the License.
9
  You may obtain a copy of the License at
10

11
      http://www.apache.org/licenses/LICENSE-2.0.txt
12

13
  Unless required by applicable law or agreed to in writing, software
14
  distributed under the License is distributed on an "AS IS" BASIS,
15
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
  See the License for the specific language governing permissions and
17
  limitations under the License.
18
*/
19

20
#include <QXmlStreamReader>
21
#include <QXmlStreamWriter>
22
#include <QQuaternion>
23
#include <QDebug>
24
#include <QFont>
25

26
#include "monitorproperties.h"
27
#include "qlcfixturedef.h"
28
#include "qlcconfig.h"
29
#include "qlcfile.h"
30
#include "fixture.h"
31
#include "doc.h"
32

33
#define KXMLQLCMonitorDisplay       QStringLiteral("DisplayMode")
34
#define KXMLQLCMonitorChannels      QStringLiteral("ChannelStyle")
35
#define KXMLQLCMonitorValues        QStringLiteral("ValueStyle")
36
#define KXMLQLCMonitorFont          QStringLiteral("Font")
37
#define KXMLQLCMonitorGrid          QStringLiteral("Grid")
38
#define KXMLQLCMonitorGridWidth     QStringLiteral("Width")
39
#define KXMLQLCMonitorGridHeight    QStringLiteral("Height")
40
#define KXMLQLCMonitorGridDepth     QStringLiteral("Depth")
41
#define KXMLQLCMonitorGridUnits     QStringLiteral("Units")
42
#define KXMLQLCMonitorPointOfView   QStringLiteral("POV")
43
#define KXMLQLCMonitorItemID        QStringLiteral("ID")
44
#define KXMLQLCMonitorShowLabels    QStringLiteral("ShowLabels")
45

46
#define KXMLQLCMonitorCommonBackground  QStringLiteral("Background")
47
#define KXMLQLCMonitorCustomBgItem      QStringLiteral("BackgroundItem")
48

49
#define KXMLQLCMonitorFixtureItem   QStringLiteral("FxItem")
50
#define KXMLQLCMonitorLightEmitter  QStringLiteral("LightEmitter")
51
#define KXMLQLCMonitorStageItem     QStringLiteral("StageItem")
52
#define KXMLQLCMonitorMeshItem      QStringLiteral("MeshItem")
53
#define KXMLQLCMonitorItemName      QStringLiteral("Name")
54
#define KXMLQLCMonitorItemRes       QStringLiteral("Res")
55
#define KXMLQLCMonitorItemColor     QStringLiteral("Color")
56

57
#define KXMLQLCMonitorItemXPosition     QStringLiteral("XPos")
58
#define KXMLQLCMonitorItemYPosition     QStringLiteral("YPos")
59
#define KXMLQLCMonitorItemZPosition     QStringLiteral("ZPos")
60
#define KXMLQLCMonitorItemXRotation     QStringLiteral("XRot")
61
#define KXMLQLCMonitorItemYRotation     QStringLiteral("YRot")
62
#define KXMLQLCMonitorItemZRotation     QStringLiteral("ZRot")
63
#define KXMLQLCMonitorFixtureRotation   QStringLiteral("Rotation") // LEGACY
64
#define KXMLQLCMonitorItemXScale        QStringLiteral("XScale")
65
#define KXMLQLCMonitorItemYScale        QStringLiteral("YScale")
66
#define KXMLQLCMonitorItemZScale        QStringLiteral("ZScale")
67

68
#define KXMLQLCMonitorFixtureHeadIndex      QStringLiteral("Head")
69
#define KXMLQLCMonitorFixtureLinkedIndex    QStringLiteral("Linked")
70

71
#define KXMLQLCMonitorFixtureGelColor   QStringLiteral("GelColor")
72
#define KXMLQLCMonitorFixtureFixedZoom  QStringLiteral("FixedZoom")
73

74
#define KXMLQLCMonitorFixtureHiddenFlag     QStringLiteral("Hidden")
75
#define KXMLQLCMonitorFixtureInvPanFlag     QStringLiteral("InvertedPan")
76
#define KXMLQLCMonitorFixtureInvTiltFlag    QStringLiteral("InvertedTilt")
77
#define KXMLQLCMonitorFixtureLockedFlag     QStringLiteral("Locked")
78

79
#define GRID_DEFAULT_WIDTH  5
80
#define GRID_DEFAULT_HEIGHT 3
81
#define GRID_DEFAULT_DEPTH  5
82

83
MonitorProperties::MonitorProperties()
9 ✔
84
    : m_font(QFont("Arial", 12))
9 ✔
85
    , m_displayMode(DMX)
9 ✔
86
    , m_channelStyle(DMXChannels)
9 ✔
87
    , m_valueStyle(DMXValues)
9 ✔
88
    , m_gridSize(QVector3D(GRID_DEFAULT_WIDTH, GRID_DEFAULT_HEIGHT, GRID_DEFAULT_DEPTH))
9 ✔
89
    , m_gridUnits(Meters)
9 ✔
90
    , m_pointOfView(Undefined)
9 ✔
91
    , m_stageType(StageSimple)
9 ✔
92
    , m_showLabels(false)
18 ✔
93
{
94
}
9 ✔
95

96
void MonitorProperties::reset()
16 ✔
97
{
98
    m_gridSize = QVector3D(GRID_DEFAULT_WIDTH, GRID_DEFAULT_HEIGHT, GRID_DEFAULT_DEPTH);
16 ✔
99
    m_gridUnits = Meters;
16 ✔
100
    m_pointOfView = Undefined;
16 ✔
101
    m_stageType = StageSimple;
16 ✔
102
    m_showLabels = false;
16 ✔
103
    m_fixtureItems.clear();
16 ✔
104
    m_lightItems.clear();
16 ✔
105
    m_genericItems.clear();
16 ✔
106
    m_commonBackgroundImage = QString();
16 ✔
107
}
16 ✔
108

109
/********************************************************************
110
 * Environment
111
 ********************************************************************/
112

113
void MonitorProperties::setPointOfView(MonitorProperties::PointOfView pov)
2 ✔
114
{
115
    if (pov == m_pointOfView)
2 ✔
116
        return;
1 ✔
117

118
    if (m_pointOfView == Undefined)
1 ✔
119
    {
120
        QVector3D gSize = gridSize();
1 ✔
121
        float units = gridUnits() == MonitorProperties::Meters ? 1000.0 : 304.8;
1 ✔
122

123
        if (gSize.z() == 0)
1 ✔
124
        {
125
            // convert the grid size first
UNCOV
126
            switch (pov)
×
127
            {
128
                case TopView:
×
129
                    setGridSize(QVector3D(gSize.x(), GRID_DEFAULT_HEIGHT, gSize.y()));
×
130
                break;
×
UNCOV
131
                case RightSideView:
×
132
                case LeftSideView:
133
                    setGridSize(QVector3D(GRID_DEFAULT_WIDTH, gSize.x(), gSize.x()));
×
134
                break;
×
135
                default:
×
UNCOV
136
                break;
×
137
            }
138
        }
139

140
        foreach (quint32 fid, fixtureItemsID())
2 ✔
141
        {
UNCOV
142
            foreach (quint32 subID, fixtureIDList(fid))
×
143
            {
144
                QVector3D pos = fixturePosition(fid, fixtureHeadIndex(subID), fixtureLinkedIndex(subID));
×
UNCOV
145
                QVector3D newPos;
×
146

UNCOV
147
                switch (pov)
×
148
                {
UNCOV
149
                    case TopView:
×
150
                    {
UNCOV
151
                        newPos = QVector3D(pos.x(), 1000, pos.y());
×
152
                    }
153
                    break;
×
UNCOV
154
                    case RightSideView:
×
155
                    {
UNCOV
156
                        newPos = QVector3D(0, pos.y(), (gridSize().z() * units) - pos.x());
×
157
                    }
158
                    break;
×
UNCOV
159
                    case LeftSideView:
×
160
                    {
UNCOV
161
                        newPos = QVector3D(0, pos.y(), pos.x());
×
162
                    }
163
                    break;
×
164
                    default:
×
165
                        newPos = QVector3D(pos.x(), (gridSize().y() * units) - pos.y(), 1000);
×
UNCOV
166
                    break;
×
167
                }
168
                setFixturePosition(fid, fixtureHeadIndex(subID), fixtureLinkedIndex(subID), newPos);
×
UNCOV
169
            }
×
170
        }
1 ✔
171
    }
172
    m_pointOfView = pov;
1 ✔
173
}
174

175
/********************************************************************
176
 * Fixture items
177
 ********************************************************************/
178

179
void MonitorProperties::removeFixture(quint32 fid)
2 ✔
180
{
181
    if (m_fixtureItems.contains(fid))
2 ✔
182
        m_fixtureItems.take(fid);
2 ✔
183
}
2 ✔
184

UNCOV
185
void MonitorProperties::removeFixture(quint32 fid, quint16 head, quint16 linked)
×
186
{
187
    if (m_fixtureItems.contains(fid) == false)
×
UNCOV
188
        return;
×
189

190
    // if no sub items are present,
191
    // the fixture can be removed completely
UNCOV
192
    if (m_fixtureItems[fid].m_subItems.count() == 0)
×
193
    {
194
        m_fixtureItems.take(fid);
×
UNCOV
195
        return;
×
196
    }
197

198
    quint32 subID = fixtureSubID(head, linked);
×
UNCOV
199
    m_fixtureItems[fid].m_subItems.remove(subID);
×
200
}
201

UNCOV
202
quint32 MonitorProperties::fixtureSubID(quint32 headIndex, quint32 linkedIndex) const
×
203
{
UNCOV
204
    return ((headIndex << 16) | linkedIndex);
×
205
}
206

UNCOV
207
quint16 MonitorProperties::fixtureHeadIndex(quint32 mapID) const
×
208
{
UNCOV
209
    return (quint16)(mapID >> 16);
×
210
}
211

UNCOV
212
quint16 MonitorProperties::fixtureLinkedIndex(quint32 mapID) const
×
213
{
UNCOV
214
    return (quint16)(mapID & 0x0000FFFF);
×
215
}
216

UNCOV
217
bool MonitorProperties::containsItem(quint32 fid, quint16 head, quint16 linked)
×
218
{
219
    if (m_fixtureItems.contains(fid) == false)
×
UNCOV
220
        return false;
×
221

222
    if (head == 0 && linked == 0)
×
UNCOV
223
        return true;
×
224

225
    quint32 subID = fixtureSubID(head, linked);
×
UNCOV
226
    return m_fixtureItems[fid].m_subItems.contains(subID);
×
227
}
228

229
void MonitorProperties::setFixturePosition(quint32 fid, quint16 head, quint16 linked, QVector3D pos)
5 ✔
230
{
231
    //qDebug() << Q_FUNC_INFO << "X:" << pos.x() << "Y:" << pos.y();
232
    if (head == 0 && linked == 0)
5 ✔
233
    {
234
        m_fixtureItems[fid].m_baseItem.m_position = pos;
5 ✔
235
    }
236
    else
237
    {
238
        quint32 subID = fixtureSubID(head, linked);
×
UNCOV
239
        m_fixtureItems[fid].m_subItems[subID].m_position = pos;
×
240
    }
241
}
5 ✔
242

243
QVector3D MonitorProperties::fixturePosition(quint32 fid, quint16 head, quint16 linked) const
1 ✔
244
{
245
    if (head == 0 && linked == 0)
1 ✔
246
    {
247
        return m_fixtureItems[fid].m_baseItem.m_position;
1 ✔
248
    }
249
    else
250
    {
251
        quint32 subID = fixtureSubID(head, linked);
×
UNCOV
252
        return m_fixtureItems[fid].m_subItems[subID].m_position;
×
253
    }
254
}
255

256
void MonitorProperties::setFixtureRotation(quint32 fid, quint16 head, quint16 linked, QVector3D degrees)
1 ✔
257
{
258
    if (head == 0 && linked == 0)
1 ✔
259
    {
260
        m_fixtureItems[fid].m_baseItem.m_rotation = degrees;
1 ✔
261
    }
262
    else
263
    {
264
        quint32 subID = fixtureSubID(head, linked);
×
UNCOV
265
        m_fixtureItems[fid].m_subItems[subID].m_rotation = degrees;
×
266
    }
267
}
1 ✔
268

269
QVector3D MonitorProperties::fixtureRotation(quint32 fid, quint16 head, quint16 linked) const
1 ✔
270
{
271
    if (head == 0 && linked == 0)
1 ✔
272
    {
273
        return m_fixtureItems[fid].m_baseItem.m_rotation;
1 ✔
274
    }
275
    else
276
    {
277
        quint32 subID = fixtureSubID(head, linked);
×
UNCOV
278
        return m_fixtureItems[fid].m_subItems[subID].m_rotation;
×
279
    }
280
}
281

282
void MonitorProperties::setFixtureGelColor(quint32 fid, quint16 head, quint16 linked, QColor col)
1 ✔
283
{
284
    //qDebug() << Q_FUNC_INFO << "Gel color:" << col;
285
    if (head == 0 && linked == 0)
1 ✔
286
    {
287
        m_fixtureItems[fid].m_baseItem.m_color = col;
1 ✔
288
    }
289
    else
290
    {
291
        quint32 subID = fixtureSubID(head, linked);
×
UNCOV
292
        m_fixtureItems[fid].m_subItems[subID].m_color = col;
×
293
    }
294
}
1 ✔
295

296
QColor MonitorProperties::fixtureGelColor(quint32 fid, quint16 head, quint16 linked) const
1 ✔
297
{
298
    if (head == 0 && linked == 0)
1 ✔
299
    {
300
        return m_fixtureItems[fid].m_baseItem.m_color;
1 ✔
301
    }
302
    else
303
    {
304
        quint32 subID = fixtureSubID(head, linked);
×
UNCOV
305
        return m_fixtureItems[fid].m_subItems[subID].m_color;
×
306
    }
307
}
308

UNCOV
309
void MonitorProperties::setFixtureFixedZoom(quint32 fid, quint16 head, quint16 linked, int degrees)
×
310
{
UNCOV
311
    if (head == 0 && linked == 0)
×
312
    {
UNCOV
313
        m_fixtureItems[fid].m_baseItem.m_zoom = degrees;
×
314
    }
315
    else
316
    {
317
        quint32 subID = fixtureSubID(head, linked);
×
UNCOV
318
        m_fixtureItems[fid].m_subItems[subID].m_zoom = degrees;
×
319
    }
UNCOV
320
}
×
321

UNCOV
322
int MonitorProperties::fixtureFixedZoom(quint32 fid, quint16 head, quint16 linked) const
×
323
{
UNCOV
324
    if (head == 0 && linked == 0)
×
325
    {
UNCOV
326
        return m_fixtureItems[fid].m_baseItem.m_zoom;
×
327
    }
328
    else
329
    {
330
        quint32 subID = fixtureSubID(head, linked);
×
UNCOV
331
        return m_fixtureItems[fid].m_subItems[subID].m_zoom;
×
332
    }
333
}
334

335
void MonitorProperties::setFixtureName(quint32 fid, quint16 head, quint16 linked, QString name)
1 ✔
336
{
337
    if (head == 0 && linked == 0)
1 ✔
338
    {
339
        m_fixtureItems[fid].m_baseItem.m_name = name;
1 ✔
340
    }
341
    else
342
    {
343
        quint32 subID = fixtureSubID(head, linked);
×
UNCOV
344
        m_fixtureItems[fid].m_subItems[subID].m_name = name;
×
345
    }
346
}
1 ✔
347

348
QString MonitorProperties::fixtureName(quint32 fid, quint16 head, quint16 linked) const
1 ✔
349
{
350
    if (head == 0 && linked == 0)
1 ✔
351
    {
352
        return m_fixtureItems[fid].m_baseItem.m_name;
1 ✔
353
    }
354
    else
355
    {
356
        quint32 subID = fixtureSubID(head, linked);
×
UNCOV
357
        return m_fixtureItems[fid].m_subItems[subID].m_name;
×
358
    }
359
}
360

361
void MonitorProperties::setFixtureFlags(quint32 fid, quint16 head, quint16 linked, quint32 flags)
1 ✔
362
{
363
    if (head == 0 && linked == 0)
1 ✔
364
    {
365
        m_fixtureItems[fid].m_baseItem.m_flags = flags;
1 ✔
366
    }
367
    else
368
    {
369
        quint32 subID = fixtureSubID(head, linked);
×
UNCOV
370
        m_fixtureItems[fid].m_subItems[subID].m_flags = flags;
×
371
    }
372
}
1 ✔
373

374
quint32 MonitorProperties::fixtureFlags(quint32 fid, quint16 head, quint16 linked) const
1 ✔
375
{
376
    if (head == 0 && linked == 0)
1 ✔
377
    {
378
        return m_fixtureItems[fid].m_baseItem.m_flags;
1 ✔
379
    }
380
    else
381
    {
382
        quint32 subID = fixtureSubID(head, linked);
×
UNCOV
383
        return m_fixtureItems[fid].m_subItems[subID].m_flags;
×
384
    }
385
}
386

UNCOV
387
PreviewItem MonitorProperties::fixtureItem(quint32 fid, quint16 head, quint16 linked) const
×
388
{
UNCOV
389
    if (head == 0 && linked == 0)
×
390
    {
UNCOV
391
        return m_fixtureItems[fid].m_baseItem;
×
392
    }
393
    else
394
    {
395
        quint32 subID = fixtureSubID(head, linked);
×
UNCOV
396
        return m_fixtureItems[fid].m_subItems[subID];
×
397
    }
398
}
399

UNCOV
400
void MonitorProperties::setFixtureItem(quint32 fid, quint16 head, quint16 linked, PreviewItem props)
×
401
{
UNCOV
402
    if (head == 0 && linked == 0)
×
403
    {
UNCOV
404
        m_fixtureItems[fid].m_baseItem = props;
×
405
    }
406
    else
407
    {
408
        quint32 subID = fixtureSubID(head, linked);
×
UNCOV
409
        m_fixtureItems[fid].m_subItems[subID] = props;
×
410
    }
UNCOV
411
}
×
412

UNCOV
413
QList<quint32> MonitorProperties::fixtureIDList(quint32 fid) const
×
414
{
UNCOV
415
    QList<quint32> list;
×
416

417
    // always add the basic fixture item ID
UNCOV
418
    list.append(0);
×
419

420
    if (m_fixtureItems.contains(fid) == false)
×
UNCOV
421
        return list;
×
422

423
    FixturePreviewItem fxItem = m_fixtureItems[fid];
×
UNCOV
424
    list.append(fxItem.m_subItems.keys());
×
425

426
    return list;
×
UNCOV
427
}
×
428

429
/********************************************************************
430
 * Fixture lights
431
 ********************************************************************/
432

433
void MonitorProperties::removeLight(QString resource)
1 ✔
434
{
435
    if (m_lightItems.contains(resource))
1 ✔
436
        m_lightItems.take(resource);
1 ✔
437
}
1 ✔
438

UNCOV
439
void MonitorProperties::removeLight(QString resource, quint16 head)
×
440
{
441
    if (m_lightItems.contains(resource) == false)
×
UNCOV
442
        return;
×
443

444
    m_lightItems[resource].remove(head);
×
UNCOV
445
    if (m_lightItems[resource].isEmpty())
×
446
    {
UNCOV
447
        m_lightItems.take(resource);
×
448
    }
449
}
450

451
bool MonitorProperties::containsLightEmitter(QString resource, quint16 head) const
3 ✔
452
{
453
    if (m_lightItems.contains(resource) == false)
3 ✔
454
        return false;
1 ✔
455

456
    return m_lightItems[resource].contains(head);
2 ✔
457
}
458

459
void MonitorProperties::setLightPosition(QString resource, quint16 head, QVector3D position)
2 ✔
460
{
461
    m_lightItems[resource][head].m_position = position;
2 ✔
462
}
2 ✔
463

464
QVector3D MonitorProperties::lightPosition(QString resource, quint16 head) const
2 ✔
465
{
466
    return m_lightItems[resource][head].m_position;
2 ✔
467
}
468

469
LightEmitter MonitorProperties::lightEmitter(QString resource, quint16 head) const
1 ✔
470
{
471
    return m_lightItems[resource][head];
1 ✔
472
}
473

474
void MonitorProperties::setLightEmitter(QString resource, quint16 head, LightEmitter props)
1 ✔
475
{
476
    m_lightItems[resource][head] = props;
1 ✔
477
}
1 ✔
478

479
QList<quint32> MonitorProperties::lightHeadList(QString resource) const
1 ✔
480
{
481
    return m_lightItems.value(resource).keys();
2 ✔
482
}
483

UNCOV
484
QMatrix4x4 MonitorProperties::fixtureRotationMatrix(QVector3D rot)
×
485
{
486
    // Matches Qt3DCore::QTransform::fromAxesAndAngles(X,-rx, Y,-ry, Z,-rz):
487
    // individual axis rotations composed as qZ * qY * qX (X applied first)
488
    QQuaternion qX = QQuaternion::fromAxisAndAngle(QVector3D(1, 0, 0), -rot.x());
×
489
    QQuaternion qY = QQuaternion::fromAxisAndAngle(QVector3D(0, 1, 0), -rot.y());
×
490
    QQuaternion qZ = QQuaternion::fromAxisAndAngle(QVector3D(0, 0, 1), -rot.z());
×
491
    QMatrix4x4 m;
×
492
    m.rotate(qZ * qY * qX);
×
UNCOV
493
    return m;
×
494
}
495

UNCOV
496
bool MonitorProperties::fixtureBeamPosition(const MonitorProperties *monProps,
×
497
                                            const Fixture *fixture, int headIndex,
498
                                            QVector3D &beamPos, QMatrix4x4 &rotMatrix)
499
{
500
    if (monProps == nullptr || fixture == nullptr)
×
UNCOV
501
        return false;
×
502

503
    QString resource;
×
504
    if (fixture->type() == QLCFixtureDef::MovingHead)
×
UNCOV
505
        resource = QStringLiteral("moving_head.dae");
×
506

507
    int lightHead = headIndex;
×
UNCOV
508
    if (!resource.isEmpty())
×
509
    {
UNCOV
510
        if (!monProps->containsLightEmitter(resource, lightHead))
×
511
        {
512
            if (lightHead != 0 && monProps->containsLightEmitter(resource, 0))
×
UNCOV
513
                lightHead = 0;
×
514
            else
UNCOV
515
                resource.clear();
×
516
        }
517
    }
518

519
    QVector3D fixturePos = monProps->fixturePosition(fixture->id(), headIndex, 0);
×
UNCOV
520
    QVector3D fixtureRot = monProps->fixtureRotation(fixture->id(), headIndex, 0);
×
521

522
    float unitScale = monProps->gridUnits() == MonitorProperties::Meters ? 1.0f : 0.3048f;
×
523
    QVector3D gridMeters = monProps->gridSize() * unitScale;
×
524
    QVector3D rootPos((fixturePos.x() / 1000.0f) - (gridMeters.x() / 2.0f),
×
525
                       fixturePos.y() / 1000.0f,
×
UNCOV
526
                      (fixturePos.z() / 1000.0f) - (gridMeters.z() / 2.0f));
×
527

UNCOV
528
    rotMatrix = fixtureRotationMatrix(fixtureRot);
×
529

UNCOV
530
    if (!resource.isEmpty())
×
531
    {
532
        QVector3D localOffset = monProps->lightPosition(resource, lightHead);
×
533
        QVector4D worldOffset = rotMatrix * QVector4D(localOffset, 0.0f);
×
534
        beamPos = rootPos + QVector3D(worldOffset.x(), worldOffset.y(), worldOffset.z());
×
UNCOV
535
        return true;
×
536
    }
537

538
    beamPos = rootPos;
×
539
    return false;
×
UNCOV
540
}
×
541

542
/********************************************************************
543
 * Generic items
544
 ********************************************************************/
545

546
QList<quint32> MonitorProperties::genericItemsID() const
2 ✔
547
{
548
    return m_genericItems.keys();
2 ✔
549
}
550

551
QString MonitorProperties::itemName(quint32 itemID) const
1 ✔
552
{
553
    if (m_genericItems[itemID].m_name.isEmpty())
1 ✔
554
    {
555
        QFileInfo rName(m_genericItems[itemID].m_resource);
×
556
        return rName.baseName();
×
UNCOV
557
    }
×
558

559
    return m_genericItems[itemID].m_name;
1 ✔
560
}
561

562
void MonitorProperties::setItemName(quint32 itemID, QString name)
2 ✔
563
{
564
    m_genericItems[itemID].m_name = name;
2 ✔
565
}
2 ✔
566

567
QString MonitorProperties::itemResource(quint32 itemID) const
1 ✔
568
{
569
    return m_genericItems[itemID].m_resource;
1 ✔
570
}
571

572
void MonitorProperties::setItemResource(quint32 itemID, QString resource)
1 ✔
573
{
574
    m_genericItems[itemID].m_resource = resource;
1 ✔
575
}
1 ✔
576

577
QVector3D MonitorProperties::itemPosition(quint32 itemID) const
1 ✔
578
{
579
    return m_genericItems[itemID].m_position;
1 ✔
580
}
581

582
void MonitorProperties::setItemPosition(quint32 itemID, QVector3D pos)
1 ✔
583
{
584
    m_genericItems[itemID].m_position = pos;
1 ✔
585
}
1 ✔
586

587
QVector3D MonitorProperties::itemRotation(quint32 itemID) const
1 ✔
588
{
589
    return m_genericItems[itemID].m_rotation;
1 ✔
590
}
591

592
void MonitorProperties::setItemRotation(quint32 itemID, QVector3D rot)
1 ✔
593
{
594
    m_genericItems[itemID].m_rotation = rot;
1 ✔
595
}
1 ✔
596

597
QVector3D MonitorProperties::itemScale(quint32 itemID) const
1 ✔
598
{
599
    if (m_genericItems[itemID].m_scale.isNull())
1 ✔
UNCOV
600
        return QVector3D(1.0, 1.0, 1.0);
×
601

602
    return m_genericItems[itemID].m_scale;
1 ✔
603
}
604

605
void MonitorProperties::setItemScale(quint32 itemID, QVector3D scale)
1 ✔
606
{
607
    m_genericItems[itemID].m_scale = scale;
1 ✔
608
}
1 ✔
609

UNCOV
610
QColor MonitorProperties::itemColor(quint32 itemID) const
×
611
{
UNCOV
612
    return m_genericItems[itemID].m_color;
×
613
}
614

UNCOV
615
void MonitorProperties::setItemColor(quint32 itemID, QColor color)
×
616
{
UNCOV
617
    m_genericItems[itemID].m_color = color;
×
UNCOV
618
}
×
619

620
quint32 MonitorProperties::itemFlags(quint32 itemID) const
1 ✔
621
{
622
    return m_genericItems[itemID].m_flags;
1 ✔
623
}
624

625
void MonitorProperties::setItemFlags(quint32 itemID, quint32 flags)
1 ✔
626
{
627
    m_genericItems[itemID].m_flags = flags;
1 ✔
628
}
1 ✔
629

630
/********************************************************************
631
 * 2D view background
632
 ********************************************************************/
633

UNCOV
634
QString MonitorProperties::customBackground(quint32 fid) const
×
635
{
636
    return m_customBackgroundImages.value(fid, QString());
×
637
}
638

639
/*********************************************************************
640
 * Load & Save
641
 *********************************************************************/
642

643
bool MonitorProperties::loadXML(QXmlStreamReader &root, const Doc *mainDocument)
1 ✔
644
{
645
    if (root.name() != KXMLQLCMonitorProperties)
1 ✔
646
    {
UNCOV
647
        qWarning() << Q_FUNC_INFO << "Monitor node not found";
×
UNCOV
648
        return false;
×
649
    }
650

651
    QXmlStreamAttributes attrs = root.attributes();
1 ✔
652

653
    if (attrs.hasAttribute(KXMLQLCMonitorDisplay) == false)
1 ✔
654
    {
UNCOV
655
        qWarning() << Q_FUNC_INFO << "Cannot determine Monitor display mode !";
×
UNCOV
656
        return false;
×
657
    }
658

659
    setDisplayMode(DisplayMode(attrs.value(KXMLQLCMonitorDisplay).toString().toInt()));
1 ✔
660
    if (attrs.hasAttribute(KXMLQLCMonitorShowLabels))
1 ✔
661
    {
662
        if (attrs.value(KXMLQLCMonitorShowLabels).toString() == "1")
2 ✔
UNCOV
663
            setLabelsVisible(true);
×
664
        else
665
            setLabelsVisible(false);
1 ✔
666
    }
667

668
    while (root.readNextStartElement())
6 ✔
669
    {
670
        QXmlStreamAttributes tAttrs = root.attributes();
5 ✔
671
        if (root.name() == KXMLQLCMonitorFont)
5 ✔
672
        {
673
            QFont fn;
1 ✔
674
            fn.fromString(root.readElementText());
1 ✔
675
            setFont(fn);
1 ✔
676
        }
1 ✔
677
        else if (root.name() == KXMLQLCMonitorChannels)
4 ✔
678
            setChannelStyle(ChannelStyle(root.readElementText().toInt()));
1 ✔
679
        else if (root.name() == KXMLQLCMonitorValues)
3 ✔
680
            setValueStyle(ValueStyle(root.readElementText().toInt()));
1 ✔
681
        else if (root.name() == KXMLQLCMonitorCommonBackground)
2 ✔
UNCOV
682
            setCommonBackgroundImage(mainDocument->denormalizeComponentPath(root.readElementText()));
×
683
        else if (root.name() == KXMLQLCMonitorCustomBgItem)
2 ✔
684
        {
UNCOV
685
            if (tAttrs.hasAttribute(KXMLQLCMonitorItemID))
×
686
            {
UNCOV
687
                quint32 fid = tAttrs.value(KXMLQLCMonitorItemID).toString().toUInt();
×
UNCOV
688
                setCustomBackgroundItem(fid, mainDocument->denormalizeComponentPath(root.readElementText()));
×
689
            }
690
        }
691
        else if (root.name() == KXMLQLCMonitorGrid)
2 ✔
692
        {
693
            int w = 5, h = 3, d = 5;
1 ✔
694
            if (tAttrs.hasAttribute(KXMLQLCMonitorGridWidth))
1 ✔
695
                w = tAttrs.value(KXMLQLCMonitorGridWidth).toString().toInt();
1 ✔
696
            if (tAttrs.hasAttribute(KXMLQLCMonitorGridHeight))
1 ✔
697
                h = tAttrs.value(KXMLQLCMonitorGridHeight).toString().toInt();
1 ✔
698
            if (tAttrs.hasAttribute(KXMLQLCMonitorGridDepth))
1 ✔
699
                d = tAttrs.value(KXMLQLCMonitorGridDepth).toString().toInt();
1 ✔
700
            else
UNCOV
701
                d = h; // backward compatibility
×
702

703
            if (tAttrs.hasAttribute(KXMLQLCMonitorGridUnits))
1 ✔
704
                setGridUnits(GridUnits(tAttrs.value(KXMLQLCMonitorGridUnits).toString().toInt()));
1 ✔
705

706
            if (tAttrs.hasAttribute(KXMLQLCMonitorPointOfView))
1 ✔
UNCOV
707
                setPointOfView(PointOfView(tAttrs.value(KXMLQLCMonitorPointOfView).toString().toInt()));
×
708
            else
709
                setPointOfView(Undefined);
1 ✔
710

711
            setGridSize(QVector3D(w, h, d));
1 ✔
712
            root.skipCurrentElement();
1 ✔
713
        }
714
        else if (root.name() == KXMLQLCMonitorStageItem)
1 ✔
715
        {
716
            setStageType(StageType(root.readElementText().toInt()));
×
717
        }
718
        else if (root.name() == KXMLQLCMonitorFixtureItem)
1 ✔
719
        {
720
            // Fixture ID is mandatory. Skip the whole entry if not found.
721
            if (tAttrs.hasAttribute(KXMLQLCMonitorItemID) == false)
×
722
            {
723
                root.skipCurrentElement();
×
724
                continue;
×
725
            }
726

727
            PreviewItem item;
×
UNCOV
728
            quint32 fid = tAttrs.value(KXMLQLCMonitorItemID).toString().toUInt();
×
729
            quint16 headIndex = 0;
×
UNCOV
730
            quint16 linkedIndex = 0;
×
731
            QVector3D pos(0, 0, 0);
×
UNCOV
732
            QVector3D rot(0, 0, 0);
×
733

734
            item.m_flags = 0;
×
UNCOV
735
            item.m_zoom = 0;
×
736

737
            if (tAttrs.hasAttribute(KXMLQLCMonitorFixtureHeadIndex))
×
738
                headIndex = tAttrs.value(KXMLQLCMonitorFixtureHeadIndex).toString().toUInt();
×
739

740
            if (tAttrs.hasAttribute(KXMLQLCMonitorFixtureLinkedIndex))
×
741
            {
742
                linkedIndex = tAttrs.value(KXMLQLCMonitorFixtureLinkedIndex).toString().toUInt();
×
743

UNCOV
744
                if (tAttrs.hasAttribute(KXMLQLCMonitorItemName))
×
745
                    item.m_name = tAttrs.value(KXMLQLCMonitorItemName).toString();
×
746
            }
747

UNCOV
748
            if (tAttrs.hasAttribute(KXMLQLCMonitorItemXPosition))
×
UNCOV
749
                pos.setX(tAttrs.value(KXMLQLCMonitorItemXPosition).toString().toDouble());
×
UNCOV
750
            if (tAttrs.hasAttribute(KXMLQLCMonitorItemYPosition))
×
751
                pos.setY(tAttrs.value(KXMLQLCMonitorItemYPosition).toString().toDouble());
×
752
            if (tAttrs.hasAttribute(KXMLQLCMonitorItemZPosition))
×
753
                pos.setZ(tAttrs.value(KXMLQLCMonitorItemZPosition).toString().toDouble());
×
754
            item.m_position = pos;
×
755

756
            if (tAttrs.hasAttribute(KXMLQLCMonitorFixtureRotation)) // check legacy first
×
757
            {
758
                rot.setY(tAttrs.value(KXMLQLCMonitorFixtureRotation).toString().toDouble());
×
759
            }
760
            else
761
            {
UNCOV
762
                if (tAttrs.hasAttribute(KXMLQLCMonitorItemXRotation))
×
763
                    rot.setX(tAttrs.value(KXMLQLCMonitorItemXRotation).toString().toDouble());
×
764
                if (tAttrs.hasAttribute(KXMLQLCMonitorItemYRotation))
×
UNCOV
765
                    rot.setY(tAttrs.value(KXMLQLCMonitorItemYRotation).toString().toDouble());
×
766
                if (tAttrs.hasAttribute(KXMLQLCMonitorItemZRotation))
×
767
                    rot.setZ(tAttrs.value(KXMLQLCMonitorItemZRotation).toString().toDouble());
×
768
            }
769
            item.m_rotation = rot;
×
770

771
            if (tAttrs.hasAttribute(KXMLQLCMonitorFixtureGelColor))
×
772
                item.m_color = QColor(tAttrs.value(KXMLQLCMonitorFixtureGelColor).toString());
×
773

UNCOV
774
            if (tAttrs.hasAttribute(KXMLQLCMonitorFixtureFixedZoom))
×
775
                item.m_zoom = tAttrs.value(KXMLQLCMonitorFixtureFixedZoom).toString().toInt();
×
776

UNCOV
777
            if (tAttrs.hasAttribute(KXMLQLCMonitorFixtureHiddenFlag))
×
778
                item.m_flags |= HiddenFlag;
×
UNCOV
779
            if (tAttrs.hasAttribute(KXMLQLCMonitorFixtureInvPanFlag))
×
UNCOV
780
                item.m_flags |= InvertedPanFlag;
×
UNCOV
781
            if (tAttrs.hasAttribute(KXMLQLCMonitorFixtureInvTiltFlag))
×
UNCOV
782
                item.m_flags |= InvertedTiltFlag;
×
783
            if (tAttrs.hasAttribute(KXMLQLCMonitorFixtureLockedFlag))
×
784
                item.m_flags |= LockedFlag;
×
785

UNCOV
786
            setFixtureItem(fid, headIndex, linkedIndex, item);
×
UNCOV
787
            root.skipCurrentElement();
×
788

UNCOV
789
        }
×
790
        else if (root.name() == KXMLQLCMonitorLightEmitter)
1 ✔
791
        {
792
            if (tAttrs.hasAttribute(KXMLQLCMonitorItemRes) == false)
1 ✔
793
            {
UNCOV
794
                root.skipCurrentElement();
×
UNCOV
795
                continue;
×
796
            }
797

798
            LightEmitter item;
1 ✔
799
            QString resource = tAttrs.value(KXMLQLCMonitorItemRes).toString();
1 ✔
800
            quint16 headIndex = 0;
1 ✔
801
            QVector3D position(0, 0, 0);
1 ✔
802

803
            if (tAttrs.hasAttribute(KXMLQLCMonitorFixtureHeadIndex))
1 ✔
UNCOV
804
                headIndex = tAttrs.value(KXMLQLCMonitorFixtureHeadIndex).toString().toUInt();
×
805

806
            if (tAttrs.hasAttribute(KXMLQLCMonitorItemXPosition))
1 ✔
807
                position.setX(tAttrs.value(KXMLQLCMonitorItemXPosition).toString().toDouble());
1 ✔
808
            if (tAttrs.hasAttribute(KXMLQLCMonitorItemYPosition))
1 ✔
809
                position.setY(tAttrs.value(KXMLQLCMonitorItemYPosition).toString().toDouble());
1 ✔
810
            if (tAttrs.hasAttribute(KXMLQLCMonitorItemZPosition))
1 ✔
811
                position.setZ(tAttrs.value(KXMLQLCMonitorItemZPosition).toString().toDouble());
1 ✔
812

813
            item.m_position = position;
1 ✔
814
            setLightEmitter(resource, headIndex, item);
1 ✔
815
            root.skipCurrentElement();
1 ✔
816
        }
1 ✔
817
        else if (root.name() == KXMLQLCMonitorMeshItem)
×
818
        {
819
            // Item ID is mandatory. Skip the whole entry if not found.
UNCOV
820
            if (tAttrs.hasAttribute(KXMLQLCMonitorItemID) == false)
×
821
            {
UNCOV
822
                root.skipCurrentElement();
×
823
                continue;
×
824
            }
825

826
            PreviewItem item;
×
827
            quint32 itemID = tAttrs.value(KXMLQLCMonitorItemID).toString().toUInt();
×
828
            QVector3D pos(0, 0, 0);
×
829
            QVector3D rot(0, 0, 0);
×
UNCOV
830
            QVector3D scale(1.0, 1.0, 1.0);
×
831

832
            item.m_flags = 0;
×
833

834
            if (tAttrs.hasAttribute(KXMLQLCMonitorItemXPosition))
×
835
                pos.setX(tAttrs.value(KXMLQLCMonitorItemXPosition).toString().toDouble());
×
836
            if (tAttrs.hasAttribute(KXMLQLCMonitorItemYPosition))
×
837
                pos.setY(tAttrs.value(KXMLQLCMonitorItemYPosition).toString().toDouble());
×
UNCOV
838
            if (tAttrs.hasAttribute(KXMLQLCMonitorItemZPosition))
×
839
                pos.setZ(tAttrs.value(KXMLQLCMonitorItemZPosition).toString().toDouble());
×
840
            item.m_position = pos;
×
841

842
            if (tAttrs.hasAttribute(KXMLQLCMonitorItemXRotation))
×
843
                rot.setX(tAttrs.value(KXMLQLCMonitorItemXRotation).toString().toDouble());
×
844
            if (tAttrs.hasAttribute(KXMLQLCMonitorItemYRotation))
×
845
                rot.setY(tAttrs.value(KXMLQLCMonitorItemYRotation).toString().toDouble());
×
UNCOV
846
            if (tAttrs.hasAttribute(KXMLQLCMonitorItemZRotation))
×
847
                rot.setZ(tAttrs.value(KXMLQLCMonitorItemZRotation).toString().toDouble());
×
848
            item.m_rotation = rot;
×
849

850
            if (tAttrs.hasAttribute(KXMLQLCMonitorItemXScale))
×
UNCOV
851
                scale.setX(tAttrs.value(KXMLQLCMonitorItemXScale).toString().toDouble());
×
852
            if (tAttrs.hasAttribute(KXMLQLCMonitorItemYScale))
×
853
                scale.setY(tAttrs.value(KXMLQLCMonitorItemYScale).toString().toDouble());
×
UNCOV
854
            if (tAttrs.hasAttribute(KXMLQLCMonitorItemZScale))
×
855
                scale.setZ(tAttrs.value(KXMLQLCMonitorItemZScale).toString().toDouble());
×
856
            item.m_scale = scale;
×
857

858
            if (tAttrs.hasAttribute(KXMLQLCMonitorFixtureHiddenFlag))
×
859
                item.m_flags |= HiddenFlag;
×
860
            if (tAttrs.hasAttribute(KXMLQLCMonitorFixtureLockedFlag))
×
UNCOV
861
                item.m_flags |= LockedFlag;
×
862

863
            if (tAttrs.hasAttribute(KXMLQLCMonitorItemRes))
×
864
                item.m_resource = tAttrs.value(KXMLQLCMonitorItemRes).toString();
×
865

UNCOV
866
            if (tAttrs.hasAttribute(KXMLQLCMonitorItemName))
×
UNCOV
867
                item.m_name = tAttrs.value(KXMLQLCMonitorItemName).toString();
×
868

UNCOV
869
            if (tAttrs.hasAttribute(KXMLQLCMonitorItemColor))
×
UNCOV
870
                item.m_color = QColor(tAttrs.value(KXMLQLCMonitorItemColor).toString());
×
871

UNCOV
872
            m_genericItems[itemID] = item;
×
UNCOV
873
            root.skipCurrentElement();
×
UNCOV
874
        }
×
875
        else
876
        {
UNCOV
877
            qWarning() << Q_FUNC_INFO << "Unknown MonitorProperties tag:" << root.name();
×
UNCOV
878
            root.skipCurrentElement();
×
879
        }
880
    }
5 ✔
881
    return true;
1 ✔
882
}
1 ✔
883

884
bool MonitorProperties::saveXML(QXmlStreamWriter *doc, const Doc *mainDocument) const
2 ✔
885
{
886
    Q_ASSERT(doc != NULL);
2 ✔
887

888
    /* Create the master Monitor node */
889
    doc->writeStartElement(KXMLQLCMonitorProperties);
4 ✔
890
    doc->writeAttribute(KXMLQLCMonitorDisplay, QString::number(displayMode()));
4 ✔
891
    doc->writeAttribute(KXMLQLCMonitorShowLabels, QString::number(labelsVisible()));
4 ✔
892

893
    /* Font */
894
    doc->writeTextElement(KXMLQLCMonitorFont, font().toString());
4 ✔
895
    /* Channels style */
896
    doc->writeTextElement(KXMLQLCMonitorChannels, QString::number(channelStyle()));
4 ✔
897
    /* Values style */
898
    doc->writeTextElement(KXMLQLCMonitorValues, QString::number(valueStyle()));
4 ✔
899

900
    /* Background */
901
    if (commonBackgroundImage().isEmpty() == false)
2 ✔
902
    {
UNCOV
903
        doc->writeTextElement(KXMLQLCMonitorCommonBackground,
×
904
                              mainDocument->normalizeComponentPath(commonBackgroundImage()));
×
905
    }
906
    else if (customBackgroundList().isEmpty() == false)
2 ✔
907
    {
UNCOV
908
        QMapIterator <quint32, QString> it(customBackgroundList());
×
UNCOV
909
        while (it.hasNext() == true)
×
910
        {
UNCOV
911
            it.next();
×
912
            doc->writeStartElement(KXMLQLCMonitorCustomBgItem);
×
UNCOV
913
            quint32 fid = it.key();
×
UNCOV
914
            doc->writeAttribute(KXMLQLCMonitorItemID, QString::number(fid));
×
UNCOV
915
            doc->writeCharacters(mainDocument->normalizeComponentPath(it.value()));
×
UNCOV
916
            doc->writeEndElement();
×
917
        }
UNCOV
918
    }
×
919

920
    doc->writeStartElement(KXMLQLCMonitorGrid);
4 ✔
921
    doc->writeAttribute(KXMLQLCMonitorGridWidth, QString::number(gridSize().x()));
4 ✔
922
    doc->writeAttribute(KXMLQLCMonitorGridHeight, QString::number(gridSize().y()));
4 ✔
923
    doc->writeAttribute(KXMLQLCMonitorGridDepth, QString::number(gridSize().z()));
4 ✔
924
    doc->writeAttribute(KXMLQLCMonitorGridUnits, QString::number(gridUnits()));
4 ✔
925
    if (m_pointOfView != Undefined)
2 ✔
926
        doc->writeAttribute(KXMLQLCMonitorPointOfView, QString::number(pointOfView()));
×
927

928
    doc->writeEndElement();
2 ✔
929

930
#ifdef QMLUI
931
    doc->writeTextElement(KXMLQLCMonitorStageItem, QString::number(stageType()));
932
#endif
933

934
    // ***********************************************************
935
    // *                write fixtures information               *
936
    // ***********************************************************
937

938
    foreach (quint32 fid, fixtureItemsID())
4 ✔
939
    {
940
        foreach (quint32 subID, fixtureIDList(fid))
×
941
        {
942
            quint16 headIndex = fixtureHeadIndex(subID);
×
UNCOV
943
            quint16 linkedIndex = fixtureLinkedIndex(subID);
×
UNCOV
944
            PreviewItem item = fixtureItem(fid, headIndex, linkedIndex);
×
945

946
            doc->writeStartElement(KXMLQLCMonitorFixtureItem);
×
947
            doc->writeAttribute(KXMLQLCMonitorItemID, QString::number(fid));
×
948

949
            if (headIndex)
×
950
                doc->writeAttribute(KXMLQLCMonitorFixtureHeadIndex, QString::number(headIndex));
×
951

952
            if (linkedIndex)
×
953
            {
UNCOV
954
                doc->writeAttribute(KXMLQLCMonitorFixtureLinkedIndex, QString::number(linkedIndex));
×
UNCOV
955
                if (item.m_name.isEmpty() == false)
×
956
                    doc->writeAttribute(KXMLQLCMonitorItemName, item.m_name);
×
957
            }
958

959
            // write flags, if present
UNCOV
960
            if (item.m_flags & HiddenFlag)
×
UNCOV
961
                doc->writeAttribute(KXMLQLCMonitorFixtureHiddenFlag, KXMLQLCTrue);
×
UNCOV
962
            if (item.m_flags & InvertedPanFlag)
×
UNCOV
963
                doc->writeAttribute(KXMLQLCMonitorFixtureInvPanFlag, KXMLQLCTrue);
×
UNCOV
964
            if (item.m_flags & InvertedTiltFlag)
×
UNCOV
965
                doc->writeAttribute(KXMLQLCMonitorFixtureInvTiltFlag, KXMLQLCTrue);
×
UNCOV
966
            if (item.m_flags & LockedFlag)
×
UNCOV
967
                doc->writeAttribute(KXMLQLCMonitorFixtureLockedFlag, KXMLQLCTrue);
×
968

969
            // always write position
970
            doc->writeAttribute(KXMLQLCMonitorItemXPosition, QString::number(item.m_position.x()));
×
971
            doc->writeAttribute(KXMLQLCMonitorItemYPosition, QString::number(item.m_position.y()));
×
972

973
#ifdef QMLUI
974
            doc->writeAttribute(KXMLQLCMonitorItemZPosition, QString::number(item.m_position.z()));
975

976
            // write rotation, if set
977
            if (item.m_rotation.x() != 0)
978
                doc->writeAttribute(KXMLQLCMonitorItemXRotation, QString::number(item.m_rotation.x()));
979
            if (item.m_rotation.y() != 0)
980
                doc->writeAttribute(KXMLQLCMonitorItemYRotation, QString::number(item.m_rotation.y()));
981
            if (item.m_rotation.z() != 0)
982
                doc->writeAttribute(KXMLQLCMonitorItemZRotation, QString::number(item.m_rotation.z()));
983
#else
UNCOV
984
            if (item.m_rotation != QVector3D(0, 0, 0))
×
UNCOV
985
                doc->writeAttribute(KXMLQLCMonitorFixtureRotation, QString::number(item.m_rotation.y()));
×
986
#endif
UNCOV
987
            if (item.m_color.isValid())
×
988
                doc->writeAttribute(KXMLQLCMonitorFixtureGelColor, item.m_color.name());
×
989

UNCOV
990
            if (item.m_zoom > 0)
×
UNCOV
991
                doc->writeAttribute(KXMLQLCMonitorFixtureFixedZoom, QString::number(item.m_zoom));
×
992

993
            doc->writeEndElement();
×
UNCOV
994
        }
×
995
    }
2 ✔
996

997
    foreach (QString resource, lightResources())
5 ✔
998
    {
999
        foreach (quint32 headIndex, lightHeadList(resource))
3 ✔
1000
        {
1001
            if (containsLightEmitter(resource, headIndex) == false)
1 ✔
UNCOV
1002
                continue;
×
1003

1004
            LightEmitter item = lightEmitter(resource, headIndex);
1 ✔
1005

1006
            if (resource.isEmpty())
1 ✔
UNCOV
1007
                continue;
×
1008

1009
            doc->writeStartElement(KXMLQLCMonitorLightEmitter);
2 ✔
1010
            doc->writeAttribute(KXMLQLCMonitorItemRes, resource);
2 ✔
1011

1012
            if (headIndex)
1 ✔
UNCOV
1013
                doc->writeAttribute(KXMLQLCMonitorFixtureHeadIndex, QString::number(headIndex));
×
1014

1015
            doc->writeAttribute(KXMLQLCMonitorItemXPosition, QString::number(item.m_position.x()));
2 ✔
1016
            doc->writeAttribute(KXMLQLCMonitorItemYPosition, QString::number(item.m_position.y()));
2 ✔
1017
            doc->writeAttribute(KXMLQLCMonitorItemZPosition, QString::number(item.m_position.z()));
2 ✔
1018

1019
            doc->writeEndElement();
1 ✔
1020
        }
1 ✔
1021
    }
3 ✔
1022
#ifdef QMLUI
1023
    QDir dir = QDir::cleanPath(QLCFile::systemDirectory(MESHESDIR).path());
1024
    QString meshDirAbsPath = dir.absolutePath() + QDir::separator();
1025
#endif
1026

1027
    // ***********************************************************
1028
    // *             write generic items information             *
1029
    // ***********************************************************
1030
    QMapIterator<quint32, PreviewItem> it(m_genericItems);
2 ✔
1031
    while (it.hasNext())
2 ✔
1032
    {
1033
        it.next();
×
1034
        quint32 itemID = it.key();
×
1035
        PreviewItem item = it.value();
×
1036

UNCOV
1037
        doc->writeStartElement(KXMLQLCMonitorMeshItem);
×
1038
        doc->writeAttribute(KXMLQLCMonitorItemID, QString::number(itemID));
×
1039

1040
        // write flags, if present
1041
        if (item.m_flags & HiddenFlag)
×
1042
            doc->writeAttribute(KXMLQLCMonitorFixtureHiddenFlag, KXMLQLCTrue);
×
1043
        if (item.m_flags & LockedFlag)
×
UNCOV
1044
            doc->writeAttribute(KXMLQLCMonitorFixtureLockedFlag, KXMLQLCTrue);
×
1045

1046
        // always write position
1047
        doc->writeAttribute(KXMLQLCMonitorItemXPosition, QString::number(item.m_position.x()));
×
1048
        doc->writeAttribute(KXMLQLCMonitorItemYPosition, QString::number(item.m_position.y()));
×
1049
        doc->writeAttribute(KXMLQLCMonitorItemZPosition, QString::number(item.m_position.z()));
×
1050

1051
        // write rotation, if set
UNCOV
1052
        if (item.m_rotation.x() != 0)
×
1053
            doc->writeAttribute(KXMLQLCMonitorItemXRotation, QString::number(item.m_rotation.x()));
×
UNCOV
1054
        if (item.m_rotation.y() != 0)
×
UNCOV
1055
            doc->writeAttribute(KXMLQLCMonitorItemYRotation, QString::number(item.m_rotation.y()));
×
UNCOV
1056
        if (item.m_rotation.z() != 0)
×
1057
            doc->writeAttribute(KXMLQLCMonitorItemZRotation, QString::number(item.m_rotation.z()));
×
1058

1059
        // write scale, if set
UNCOV
1060
        if (item.m_scale.x() != 1.0)
×
1061
            doc->writeAttribute(KXMLQLCMonitorItemXScale, QString::number(item.m_scale.x()));
×
UNCOV
1062
        if (item.m_scale.y() != 1.0)
×
UNCOV
1063
            doc->writeAttribute(KXMLQLCMonitorItemYScale, QString::number(item.m_scale.y()));
×
UNCOV
1064
        if (item.m_scale.z() != 1.0)
×
UNCOV
1065
            doc->writeAttribute(KXMLQLCMonitorItemZScale, QString::number(item.m_scale.z()));
×
1066

UNCOV
1067
        if (item.m_resource.isEmpty() == false)
×
1068
        {
1069
            // perform normalization depending on the mesh location
1070
            // (mesh folder, project path, absolute path)
UNCOV
1071
            QFileInfo res(item.m_resource);
×
1072

UNCOV
1073
            if (res.isRelative())
×
1074
            {
UNCOV
1075
                doc->writeAttribute(KXMLQLCMonitorItemRes, item.m_resource);
×
1076
            }
1077
#ifdef QMLUI
1078
            else if (item.m_resource.startsWith(meshDirAbsPath))
1079
            {
1080
                item.m_resource.remove(meshDirAbsPath);
1081
                doc->writeAttribute(KXMLQLCMonitorItemRes, item.m_resource);
1082
            }
1083
#endif
1084
            else
1085
            {
UNCOV
1086
                doc->writeAttribute(KXMLQLCMonitorItemRes, mainDocument->normalizeComponentPath(item.m_resource));
×
1087
            }
UNCOV
1088
        }
×
1089

UNCOV
1090
        if (item.m_name.isEmpty() == false)
×
UNCOV
1091
            doc->writeAttribute(KXMLQLCMonitorItemName, item.m_name);
×
1092

UNCOV
1093
        if (item.m_color.isValid())
×
UNCOV
1094
            doc->writeAttribute(KXMLQLCMonitorItemColor, item.m_color.name());
×
1095

UNCOV
1096
        doc->writeEndElement();
×
UNCOV
1097
    }
×
1098

1099
    doc->writeEndElement();
2 ✔
1100

1101
    return true;
2 ✔
1102
}
2 ✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc