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

mcallegari / qlcplus / 13633248611

03 Mar 2025 02:31PM UTC coverage: 31.871% (+0.4%) from 31.5%
13633248611

push

github

web-flow
actions: add chrpath to profile

14689 of 46089 relevant lines covered (31.87%)

26426.11 hits per line

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

11.66
/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 <QDebug>
23
#include <QFont>
24

25
#include "monitorproperties.h"
26
#include "qlcconfig.h"
27
#include "qlcfile.h"
28
#include "doc.h"
29

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

43
#define KXMLQLCMonitorCommonBackground  QString("Background")
44
#define KXMLQLCMonitorCustomBgItem      QString("BackgroundItem")
45

46
#define KXMLQLCMonitorFixtureItem   QString("FxItem")
47
#define KXMLQLCMonitorStageItem     QString("StageItem")
48
#define KXMLQLCMonitorMeshItem      QString("MeshItem")
49
#define KXMLQLCMonitorItemName      QString("Name")
50
#define KXMLQLCMonitorItemRes       QString("Res")
51

52
#define KXMLQLCMonitorItemXPosition     QString("XPos")
53
#define KXMLQLCMonitorItemYPosition     QString("YPos")
54
#define KXMLQLCMonitorItemZPosition     QString("ZPos")
55
#define KXMLQLCMonitorItemXRotation     QString("XRot")
56
#define KXMLQLCMonitorItemYRotation     QString("YRot")
57
#define KXMLQLCMonitorItemZRotation     QString("ZRot")
58
#define KXMLQLCMonitorFixtureRotation   QString("Rotation") // LEGACY
59
#define KXMLQLCMonitorItemXScale        QString("XScale")
60
#define KXMLQLCMonitorItemYScale        QString("YScale")
61
#define KXMLQLCMonitorItemZScale        QString("ZScale")
62

63
#define KXMLQLCMonitorFixtureHeadIndex      QString("Head")
64
#define KXMLQLCMonitorFixtureLinkedIndex    QString("Linked")
65

66
#define KXMLQLCMonitorFixtureGelColor QString("GelColor")
67

68
#define KXMLQLCMonitorFixtureHiddenFlag     QString("Hidden")
69
#define KXMLQLCMonitorFixtureInvPanFlag     QString("InvertedPan")
70
#define KXMLQLCMonitorFixtureInvTiltFlag    QString("InvertedTilt")
71

72
#define GRID_DEFAULT_WIDTH  5
73
#define GRID_DEFAULT_HEIGHT 3
74
#define GRID_DEFAULT_DEPTH  5
75

76
MonitorProperties::MonitorProperties()
1✔
77
    : m_displayMode(DMX)
1✔
78
    , m_channelStyle(DMXChannels)
1✔
79
    , m_valueStyle(DMXValues)
1✔
80
    , m_gridSize(QVector3D(GRID_DEFAULT_WIDTH, GRID_DEFAULT_HEIGHT, GRID_DEFAULT_DEPTH))
81
    , m_gridUnits(Meters)
1✔
82
    , m_pointOfView(Undefined)
1✔
83
    , m_stageType(StageSimple)
1✔
84
    , m_showLabels(false)
1✔
85
{
86
    m_font = QFont("Arial", 12);
1✔
87
}
1✔
88

89
void MonitorProperties::reset()
9✔
90
{
91
    m_gridSize = QVector3D(GRID_DEFAULT_WIDTH, GRID_DEFAULT_HEIGHT, GRID_DEFAULT_DEPTH);
9✔
92
    m_gridUnits = Meters;
9✔
93
    m_pointOfView = Undefined;
9✔
94
    m_stageType = StageSimple;
9✔
95
    m_showLabels = false;
9✔
96
    m_fixtureItems.clear();
9✔
97
    m_genericItems.clear();
9✔
98
    m_commonBackgroundImage = QString();
9✔
99
}
9✔
100

101
/********************************************************************
102
 * Environment
103
 ********************************************************************/
104

105
void MonitorProperties::setPointOfView(MonitorProperties::PointOfView pov)
×
106
{
107
    if (pov == m_pointOfView)
×
108
        return;
109

110
    if (m_pointOfView == Undefined)
×
111
    {
112
        QVector3D gSize = gridSize();
113
        float units = gridUnits() == MonitorProperties::Meters ? 1000.0 : 304.8;
×
114

115
        if (gSize.z() == 0)
×
116
        {
117
            // convert the grid size first
118
            switch (pov)
×
119
            {
120
                case TopView:
121
                    setGridSize(QVector3D(gSize.x(), GRID_DEFAULT_HEIGHT, gSize.y()));
122
                break;
×
123
                case RightSideView:
124
                case LeftSideView:
125
                    setGridSize(QVector3D(GRID_DEFAULT_WIDTH, gSize.x(), gSize.x()));
126
                break;
×
127
                default:
128
                break;
129
            }
130
        }
131

132
        foreach (quint32 fid, fixtureItemsID())
×
133
        {
134
            foreach (quint32 subID, fixtureIDList(fid))
×
135
            {
136
                QVector3D pos = fixturePosition(fid, fixtureHeadIndex(subID), fixtureLinkedIndex(subID));
×
137
                QVector3D newPos;
×
138

139
                switch (pov)
×
140
                {
141
                    case TopView:
142
                    {
143
                        newPos = QVector3D(pos.x(), 1000, pos.y());
×
144
                    }
145
                    break;
×
146
                    case RightSideView:
147
                    {
148
                        newPos = QVector3D(0, pos.y(), (gridSize().z() * units) - pos.x());
×
149
                    }
150
                    break;
×
151
                    case LeftSideView:
152
                    {
153
                        newPos = QVector3D(0, pos.y(), pos.x());
×
154
                    }
155
                    break;
×
156
                    default:
157
                        newPos = QVector3D(pos.x(), (gridSize().y() * units) - pos.y(), 1000);
×
158
                    break;
×
159
                }
160
                setFixturePosition(fid, fixtureHeadIndex(subID), fixtureLinkedIndex(subID), newPos);
×
161
            }
162
        }
163
    }
164
    m_pointOfView = pov;
×
165
}
166

167
/********************************************************************
168
 * Fixture items
169
 ********************************************************************/
170

171
void MonitorProperties::removeFixture(quint32 fid)
×
172
{
173
    if (m_fixtureItems.contains(fid))
×
174
        m_fixtureItems.take(fid);
×
175
}
×
176

177
void MonitorProperties::removeFixture(quint32 fid, quint16 head, quint16 linked)
×
178
{
179
    if (m_fixtureItems.contains(fid) == false)
×
180
        return;
×
181

182
    // if no sub items are present,
183
    // the fixture can be removed completely
184
    if (m_fixtureItems[fid].m_subItems.count() == 0)
×
185
    {
186
        m_fixtureItems.take(fid);
×
187
        return;
×
188
    }
189

190
    quint32 subID = fixtureSubID(head, linked);
×
191
    m_fixtureItems[fid].m_subItems.remove(subID);
×
192
}
193

194
quint32 MonitorProperties::fixtureSubID(quint32 headIndex, quint32 linkedIndex) const
×
195
{
196
    return ((headIndex << 16) | linkedIndex);
×
197
}
198

199
quint16 MonitorProperties::fixtureHeadIndex(quint32 mapID) const
×
200
{
201
    return (quint16)(mapID >> 16);
×
202
}
203

204
quint16 MonitorProperties::fixtureLinkedIndex(quint32 mapID) const
×
205
{
206
    return (quint16)(mapID & 0x0000FFFF);
×
207
}
208

209
bool MonitorProperties::containsItem(quint32 fid, quint16 head, quint16 linked)
×
210
{
211
    if (m_fixtureItems.contains(fid) == false)
×
212
        return false;
213

214
    if (head == 0 && linked == 0)
×
215
        return true;
216

217
    quint32 subID = fixtureSubID(head, linked);
×
218
    return m_fixtureItems[fid].m_subItems.contains(subID);
×
219
}
220

221
void MonitorProperties::setFixturePosition(quint32 fid, quint16 head, quint16 linked, QVector3D pos)
3✔
222
{
223
    //qDebug() << Q_FUNC_INFO << "X:" << pos.x() << "Y:" << pos.y();
224
    if (head == 0 && linked == 0)
3✔
225
    {
226
        m_fixtureItems[fid].m_baseItem.m_position = pos;
3✔
227
    }
228
    else
229
    {
230
        quint32 subID = fixtureSubID(head, linked);
×
231
        m_fixtureItems[fid].m_subItems[subID].m_position = pos;
×
232
    }
233
}
3✔
234

235
QVector3D MonitorProperties::fixturePosition(quint32 fid, quint16 head, quint16 linked) const
×
236
{
237
    if (head == 0 && linked == 0)
×
238
    {
239
        return m_fixtureItems[fid].m_baseItem.m_position;
×
240
    }
241
    else
242
    {
243
        quint32 subID = fixtureSubID(head, linked);
×
244
        return m_fixtureItems[fid].m_subItems[subID].m_position;
×
245
    }
246
}
247

248
void MonitorProperties::setFixtureRotation(quint32 fid, quint16 head, quint16 linked, QVector3D degrees)
×
249
{
250
    if (head == 0 && linked == 0)
×
251
    {
252
        m_fixtureItems[fid].m_baseItem.m_rotation = degrees;
×
253
    }
254
    else
255
    {
256
        quint32 subID = fixtureSubID(head, linked);
×
257
        m_fixtureItems[fid].m_subItems[subID].m_rotation = degrees;
×
258
    }
259
}
×
260

261
QVector3D MonitorProperties::fixtureRotation(quint32 fid, quint16 head, quint16 linked) const
×
262
{
263
    if (head == 0 && linked == 0)
×
264
    {
265
        return m_fixtureItems[fid].m_baseItem.m_rotation;
×
266
    }
267
    else
268
    {
269
        quint32 subID = fixtureSubID(head, linked);
×
270
        return m_fixtureItems[fid].m_subItems[subID].m_rotation;
×
271
    }
272
}
273

274
void MonitorProperties::setFixtureGelColor(quint32 fid, quint16 head, quint16 linked, QColor col)
×
275
{
276
    //qDebug() << Q_FUNC_INFO << "Gel color:" << col;
277
    if (head == 0 && linked == 0)
×
278
    {
279
        m_fixtureItems[fid].m_baseItem.m_color = col;
×
280
    }
281
    else
282
    {
283
        quint32 subID = fixtureSubID(head, linked);
×
284
        m_fixtureItems[fid].m_subItems[subID].m_color = col;
×
285
    }
286
}
×
287

288
QColor MonitorProperties::fixtureGelColor(quint32 fid, quint16 head, quint16 linked) const
×
289
{
290
    if (head == 0 && linked == 0)
×
291
    {
292
        return m_fixtureItems[fid].m_baseItem.m_color;
×
293
    }
294
    else
295
    {
296
        quint32 subID = fixtureSubID(head, linked);
×
297
        return m_fixtureItems[fid].m_subItems[subID].m_color;
×
298
    }
299
}
300

301
void MonitorProperties::setFixtureName(quint32 fid, quint16 head, quint16 linked, QString name)
×
302
{
303
    if (head == 0 && linked == 0)
×
304
    {
305
        m_fixtureItems[fid].m_baseItem.m_name = name;
×
306
    }
307
    else
308
    {
309
        quint32 subID = fixtureSubID(head, linked);
×
310
        m_fixtureItems[fid].m_subItems[subID].m_name = name;
×
311
    }
312
}
×
313

314
QString MonitorProperties::fixtureName(quint32 fid, quint16 head, quint16 linked) const
×
315
{
316
    if (head == 0 && linked == 0)
×
317
    {
318
        return m_fixtureItems[fid].m_baseItem.m_name;
×
319
    }
320
    else
321
    {
322
        quint32 subID = fixtureSubID(head, linked);
×
323
        return m_fixtureItems[fid].m_subItems[subID].m_name;
×
324
    }
325
}
326

327
void MonitorProperties::setFixtureFlags(quint32 fid, quint16 head, quint16 linked, quint32 flags)
×
328
{
329
    if (head == 0 && linked == 0)
×
330
    {
331
        m_fixtureItems[fid].m_baseItem.m_flags = flags;
×
332
    }
333
    else
334
    {
335
        quint32 subID = fixtureSubID(head, linked);
×
336
        m_fixtureItems[fid].m_subItems[subID].m_flags = flags;
×
337
    }
338
}
×
339

340
quint32 MonitorProperties::fixtureFlags(quint32 fid, quint16 head, quint16 linked) const
×
341
{
342
    if (head == 0 && linked == 0)
×
343
    {
344
        return m_fixtureItems[fid].m_baseItem.m_flags;
×
345
    }
346
    else
347
    {
348
        quint32 subID = fixtureSubID(head, linked);
×
349
        return m_fixtureItems[fid].m_subItems[subID].m_flags;
×
350
    }
351
}
352

353
PreviewItem MonitorProperties::fixtureItem(quint32 fid, quint16 head, quint16 linked) const
×
354
{
355
    if (head == 0 && linked == 0)
×
356
    {
357
        return m_fixtureItems[fid].m_baseItem;
×
358
    }
359
    else
360
    {
361
        quint32 subID = fixtureSubID(head, linked);
×
362
        return m_fixtureItems[fid].m_subItems[subID];
×
363
    }
364
}
365

366
void MonitorProperties::setFixtureItem(quint32 fid, quint16 head, quint16 linked, PreviewItem props)
×
367
{
368
    if (head == 0 && linked == 0)
×
369
    {
370
        m_fixtureItems[fid].m_baseItem = props;
×
371
    }
372
    else
373
    {
374
        quint32 subID = fixtureSubID(head, linked);
×
375
        m_fixtureItems[fid].m_subItems[subID] = props;
×
376
    }
377
}
×
378

379
QList<quint32> MonitorProperties::fixtureIDList(quint32 fid) const
×
380
{
381
    QList<quint32> list;
382
    if (m_fixtureItems.contains(fid) == false)
×
383
        return list;
384

385
    // add the basic fixture item ID
386
    list.append(0);
×
387

388
    FixturePreviewItem fxItem = m_fixtureItems[fid];
×
389
    list.append(fxItem.m_subItems.keys());
×
390

391
    return list;
392
}
×
393

394
/********************************************************************
395
 * Generic items
396
 ********************************************************************/
397

398
QList<quint32> MonitorProperties::genericItemsID()
×
399
{
400
    return m_genericItems.keys();
×
401
}
402

403
QString MonitorProperties::itemName(quint32 itemID)
×
404
{
405
    if (m_genericItems[itemID].m_name.isEmpty())
×
406
    {
407
        QFileInfo rName(m_genericItems[itemID].m_resource);
×
408
        return rName.baseName();
×
409
    }
×
410

411
    return m_genericItems[itemID].m_name;
×
412
}
413

414
void MonitorProperties::setItemName(quint32 itemID, QString name)
×
415
{
416
    m_genericItems[itemID].m_name = name;
×
417
}
×
418

419
QString MonitorProperties::itemResource(quint32 itemID)
×
420
{
421
    return m_genericItems[itemID].m_resource;
×
422
}
423

424
void MonitorProperties::setItemResource(quint32 itemID, QString resource)
×
425
{
426
    m_genericItems[itemID].m_resource = resource;
×
427
}
×
428

429
QVector3D MonitorProperties::itemPosition(quint32 itemID)
×
430
{
431
    return m_genericItems[itemID].m_position;
×
432
}
433

434
void MonitorProperties::setItemPosition(quint32 itemID, QVector3D pos)
×
435
{
436
    m_genericItems[itemID].m_position = pos;
×
437
}
×
438

439
QVector3D MonitorProperties::itemRotation(quint32 itemID)
×
440
{
441
    return m_genericItems[itemID].m_rotation;
×
442
}
443

444
void MonitorProperties::setItemRotation(quint32 itemID, QVector3D rot)
×
445
{
446
    m_genericItems[itemID].m_rotation = rot;
×
447
}
×
448

449
QVector3D MonitorProperties::itemScale(quint32 itemID)
×
450
{
451
    if (m_genericItems[itemID].m_scale.isNull())
×
452
        return QVector3D(1.0, 1.0, 1.0);
×
453

454
    return m_genericItems[itemID].m_scale;
×
455
}
456

457
void MonitorProperties::setItemScale(quint32 itemID, QVector3D scale)
×
458
{
459
    m_genericItems[itemID].m_scale = scale;
×
460
}
×
461

462
quint32 MonitorProperties::itemFlags(quint32 itemID)
×
463
{
464
    return m_genericItems[itemID].m_flags;
×
465
}
466

467
void MonitorProperties::setItemFlags(quint32 itemID, quint32 flags)
×
468
{
469
    m_genericItems[itemID].m_flags = flags;
×
470
}
×
471

472
/********************************************************************
473
 * 2D view background
474
 ********************************************************************/
475

476
QString MonitorProperties::customBackground(quint32 fid)
×
477
{
478
    return m_customBackgroundImages.value(fid, QString());
×
479
}
480

481
/*********************************************************************
482
 * Load & Save
483
 *********************************************************************/
484

485
bool MonitorProperties::loadXML(QXmlStreamReader &root, const Doc *mainDocument)
×
486
{
487
    if (root.name() != KXMLQLCMonitorProperties)
×
488
    {
489
        qWarning() << Q_FUNC_INFO << "Monitor node not found";
×
490
        return false;
×
491
    }
492

493
    QXmlStreamAttributes attrs = root.attributes();
×
494

495
    if (attrs.hasAttribute(KXMLQLCMonitorDisplay) == false)
×
496
    {
497
        qWarning() << Q_FUNC_INFO << "Cannot determine Monitor display mode !";
×
498
        return false;
×
499
    }
500

501
    setDisplayMode(DisplayMode(attrs.value(KXMLQLCMonitorDisplay).toString().toInt()));
×
502
    if (attrs.hasAttribute(KXMLQLCMonitorShowLabels))
×
503
    {
504
        if (attrs.value(KXMLQLCMonitorShowLabels).toString() == "1")
×
505
            setLabelsVisible(true);
506
        else
507
            setLabelsVisible(false);
508
    }
509

510
    while (root.readNextStartElement())
×
511
    {
512
        QXmlStreamAttributes tAttrs = root.attributes();
×
513
        if (root.name() == KXMLQLCMonitorFont)
×
514
        {
515
            QFont fn;
×
516
            fn.fromString(root.readElementText());
×
517
            setFont(fn);
×
518
        }
×
519
        else if (root.name() == KXMLQLCMonitorChannels)
×
520
            setChannelStyle(ChannelStyle(root.readElementText().toInt()));
×
521
        else if (root.name() == KXMLQLCMonitorValues)
×
522
            setValueStyle(ValueStyle(root.readElementText().toInt()));
×
523
        else if (root.name() == KXMLQLCMonitorCommonBackground)
×
524
            setCommonBackgroundImage(mainDocument->denormalizeComponentPath(root.readElementText()));
×
525
        else if (root.name() == KXMLQLCMonitorCustomBgItem)
×
526
        {
527
            if (tAttrs.hasAttribute(KXMLQLCMonitorItemID))
×
528
            {
529
                quint32 fid = tAttrs.value(KXMLQLCMonitorItemID).toString().toUInt();
×
530
                setCustomBackgroundItem(fid, mainDocument->denormalizeComponentPath(root.readElementText()));
×
531
            }
532
        }
533
        else if (root.name() == KXMLQLCMonitorGrid)
×
534
        {
535
            int w = 5, h = 3, d = 5;
536
            if (tAttrs.hasAttribute(KXMLQLCMonitorGridWidth))
×
537
                w = tAttrs.value(KXMLQLCMonitorGridWidth).toString().toInt();
×
538
            if (tAttrs.hasAttribute(KXMLQLCMonitorGridHeight))
×
539
                h = tAttrs.value(KXMLQLCMonitorGridHeight).toString().toInt();
×
540
            if (tAttrs.hasAttribute(KXMLQLCMonitorGridDepth))
×
541
                d = tAttrs.value(KXMLQLCMonitorGridDepth).toString().toInt();
×
542
            else
543
                d = h; // backward compatibility
544

545
            if (tAttrs.hasAttribute(KXMLQLCMonitorGridUnits))
×
546
                setGridUnits(GridUnits(tAttrs.value(KXMLQLCMonitorGridUnits).toString().toInt()));
×
547

548
            if (tAttrs.hasAttribute(KXMLQLCMonitorPointOfView))
×
549
                setPointOfView(PointOfView(tAttrs.value(KXMLQLCMonitorPointOfView).toString().toInt()));
×
550
            else
551
                setPointOfView(Undefined);
×
552

553
            setGridSize(QVector3D(w, h, d));
×
554
            root.skipCurrentElement();
×
555
        }
556
        else if (root.name() == KXMLQLCMonitorStageItem)
×
557
        {
558
            setStageType(StageType(root.readElementText().toInt()));
×
559
        }
560
        else if (root.name() == KXMLQLCMonitorFixtureItem)
×
561
        {
562
            // Fixture ID is mandatory. Skip the whole entry if not found.
563
            if (tAttrs.hasAttribute(KXMLQLCMonitorItemID) == false)
×
564
            {
565
                root.skipCurrentElement();
×
566
                continue;
×
567
            }
568

569
            PreviewItem item;
×
570
            quint32 fid = tAttrs.value(KXMLQLCMonitorItemID).toString().toUInt();
×
571
            quint16 headIndex = 0;
572
            quint16 linkedIndex = 0;
573
            QVector3D pos(0, 0, 0);
574
            QVector3D rot(0, 0, 0);
575

576
            item.m_flags = 0;
×
577

578
            if (tAttrs.hasAttribute(KXMLQLCMonitorFixtureHeadIndex))
×
579
                headIndex = tAttrs.value(KXMLQLCMonitorFixtureHeadIndex).toString().toUInt();
×
580

581
            if (tAttrs.hasAttribute(KXMLQLCMonitorFixtureLinkedIndex))
×
582
            {
583
                linkedIndex = tAttrs.value(KXMLQLCMonitorFixtureLinkedIndex).toString().toUInt();
×
584

585
                if (tAttrs.hasAttribute(KXMLQLCMonitorItemName))
×
586
                    item.m_name = tAttrs.value(KXMLQLCMonitorItemName).toString();
×
587
            }
588

589
            if (tAttrs.hasAttribute(KXMLQLCMonitorItemXPosition))
×
590
                pos.setX(tAttrs.value(KXMLQLCMonitorItemXPosition).toString().toDouble());
×
591
            if (tAttrs.hasAttribute(KXMLQLCMonitorItemYPosition))
×
592
                pos.setY(tAttrs.value(KXMLQLCMonitorItemYPosition).toString().toDouble());
×
593
            if (tAttrs.hasAttribute(KXMLQLCMonitorItemZPosition))
×
594
                pos.setZ(tAttrs.value(KXMLQLCMonitorItemZPosition).toString().toDouble());
×
595
            item.m_position = pos;
×
596

597
            if (tAttrs.hasAttribute(KXMLQLCMonitorFixtureRotation)) // check legacy first
×
598
            {
599
                rot.setY(tAttrs.value(KXMLQLCMonitorFixtureRotation).toString().toDouble());
×
600
            }
601
            else
602
            {
603
                if (tAttrs.hasAttribute(KXMLQLCMonitorItemXRotation))
×
604
                    rot.setX(tAttrs.value(KXMLQLCMonitorItemXRotation).toString().toDouble());
×
605
                if (tAttrs.hasAttribute(KXMLQLCMonitorItemYRotation))
×
606
                    rot.setY(tAttrs.value(KXMLQLCMonitorItemYRotation).toString().toDouble());
×
607
                if (tAttrs.hasAttribute(KXMLQLCMonitorItemZRotation))
×
608
                    rot.setZ(tAttrs.value(KXMLQLCMonitorItemZRotation).toString().toDouble());
×
609
            }
610
            item.m_rotation = rot;
×
611

612
            if (tAttrs.hasAttribute(KXMLQLCMonitorFixtureGelColor))
×
613
                item.m_color = QColor(tAttrs.value(KXMLQLCMonitorFixtureGelColor).toString());
×
614

615
            if (tAttrs.hasAttribute(KXMLQLCMonitorFixtureHiddenFlag))
×
616
                item.m_flags |= HiddenFlag;
×
617
            if (tAttrs.hasAttribute(KXMLQLCMonitorFixtureInvPanFlag))
×
618
                item.m_flags |= InvertedPanFlag;
×
619
            if (tAttrs.hasAttribute(KXMLQLCMonitorFixtureInvTiltFlag))
×
620
                item.m_flags |= InvertedTiltFlag;
×
621

622
            setFixtureItem(fid, headIndex, linkedIndex, item);
×
623
            root.skipCurrentElement();
×
624

625
        }
626
        else if (root.name() == KXMLQLCMonitorMeshItem)
×
627
        {
628
            // Item ID is mandatory. Skip the whole entry if not found.
629
            if (tAttrs.hasAttribute(KXMLQLCMonitorItemID) == false)
×
630
            {
631
                root.skipCurrentElement();
×
632
                continue;
×
633
            }
634

635
            PreviewItem item;
×
636
            quint32 itemID = tAttrs.value(KXMLQLCMonitorItemID).toString().toUInt();
×
637
            QVector3D pos(0, 0, 0);
638
            QVector3D rot(0, 0, 0);
639
            QVector3D scale(1.0, 1.0, 1.0);
640

641
            item.m_flags = 0;
×
642

643
            if (tAttrs.hasAttribute(KXMLQLCMonitorItemXPosition))
×
644
                pos.setX(tAttrs.value(KXMLQLCMonitorItemXPosition).toString().toDouble());
×
645
            if (tAttrs.hasAttribute(KXMLQLCMonitorItemYPosition))
×
646
                pos.setY(tAttrs.value(KXMLQLCMonitorItemYPosition).toString().toDouble());
×
647
            if (tAttrs.hasAttribute(KXMLQLCMonitorItemZPosition))
×
648
                pos.setZ(tAttrs.value(KXMLQLCMonitorItemZPosition).toString().toDouble());
×
649
            item.m_position = pos;
×
650

651
            if (tAttrs.hasAttribute(KXMLQLCMonitorItemXRotation))
×
652
                rot.setX(tAttrs.value(KXMLQLCMonitorItemXRotation).toString().toDouble());
×
653
            if (tAttrs.hasAttribute(KXMLQLCMonitorItemYRotation))
×
654
                rot.setY(tAttrs.value(KXMLQLCMonitorItemYRotation).toString().toDouble());
×
655
            if (tAttrs.hasAttribute(KXMLQLCMonitorItemZRotation))
×
656
                rot.setZ(tAttrs.value(KXMLQLCMonitorItemZRotation).toString().toDouble());
×
657
            item.m_rotation = rot;
×
658

659
            if (tAttrs.hasAttribute(KXMLQLCMonitorItemXScale))
×
660
                scale.setX(tAttrs.value(KXMLQLCMonitorItemXScale).toString().toDouble());
×
661
            if (tAttrs.hasAttribute(KXMLQLCMonitorItemYScale))
×
662
                scale.setY(tAttrs.value(KXMLQLCMonitorItemYScale).toString().toDouble());
×
663
            if (tAttrs.hasAttribute(KXMLQLCMonitorItemZScale))
×
664
                scale.setZ(tAttrs.value(KXMLQLCMonitorItemZScale).toString().toDouble());
×
665
            item.m_scale = scale;
×
666

667
            if (tAttrs.hasAttribute(KXMLQLCMonitorFixtureHiddenFlag))
×
668
                item.m_flags |= HiddenFlag;
×
669

670
            if (tAttrs.hasAttribute(KXMLQLCMonitorItemRes))
×
671
                item.m_resource = tAttrs.value(KXMLQLCMonitorItemRes).toString();
×
672

673
            if (tAttrs.hasAttribute(KXMLQLCMonitorItemName))
×
674
                item.m_name = tAttrs.value(KXMLQLCMonitorItemName).toString();
×
675

676
            m_genericItems[itemID] = item;
×
677
            root.skipCurrentElement();
×
678
        }
679
        else
680
        {
681
            qWarning() << Q_FUNC_INFO << "Unknown MonitorProperties tag:" << root.name();
×
682
            root.skipCurrentElement();
×
683
        }
684
    }
685
    return true;
686
}
687

688
bool MonitorProperties::saveXML(QXmlStreamWriter *doc, const Doc *mainDocument) const
1✔
689
{
690
    Q_ASSERT(doc != NULL);
691

692
    /* Create the master Monitor node */
693
    doc->writeStartElement(KXMLQLCMonitorProperties);
1✔
694
    doc->writeAttribute(KXMLQLCMonitorDisplay, QString::number(displayMode()));
1✔
695
    doc->writeAttribute(KXMLQLCMonitorShowLabels, QString::number(labelsVisible()));
1✔
696

697
    /* Font */
698
    doc->writeTextElement(KXMLQLCMonitorFont, font().toString());
1✔
699
    /* Channels style */
700
    doc->writeTextElement(KXMLQLCMonitorChannels, QString::number(channelStyle()));
1✔
701
    /* Values style */
702
    doc->writeTextElement(KXMLQLCMonitorValues, QString::number(valueStyle()));
1✔
703

704
    /* Background */
705
    if (commonBackgroundImage().isEmpty() == false)
1✔
706
    {
707
        doc->writeTextElement(KXMLQLCMonitorCommonBackground,
×
708
                              mainDocument->normalizeComponentPath(commonBackgroundImage()));
×
709
    }
710
    else if (customBackgroundList().isEmpty() == false)
1✔
711
    {
712
        QMapIterator <quint32, QString> it(customBackgroundList());
×
713
        while (it.hasNext() == true)
×
714
        {
715
            it.next();
×
716
            doc->writeStartElement(KXMLQLCMonitorCustomBgItem);
×
717
            quint32 fid = it.key();
×
718
            doc->writeAttribute(KXMLQLCMonitorItemID, QString::number(fid));
×
719
            doc->writeCharacters(mainDocument->normalizeComponentPath(it.value()));
×
720
            doc->writeEndElement();
×
721
        }
722
    }
723

724
    doc->writeStartElement(KXMLQLCMonitorGrid);
1✔
725
    doc->writeAttribute(KXMLQLCMonitorGridWidth, QString::number(gridSize().x()));
1✔
726
    doc->writeAttribute(KXMLQLCMonitorGridHeight, QString::number(gridSize().y()));
1✔
727
    doc->writeAttribute(KXMLQLCMonitorGridDepth, QString::number(gridSize().z()));
1✔
728
    doc->writeAttribute(KXMLQLCMonitorGridUnits, QString::number(gridUnits()));
1✔
729
    if (m_pointOfView != Undefined)
1✔
730
        doc->writeAttribute(KXMLQLCMonitorPointOfView, QString::number(pointOfView()));
×
731

732
    doc->writeEndElement();
1✔
733

734
#ifdef QMLUI
735
    doc->writeTextElement(KXMLQLCMonitorStageItem, QString::number(stageType()));
736
#endif
737

738
    // ***********************************************************
739
    // *                write fixtures information               *
740
    // ***********************************************************
741

742
    foreach (quint32 fid, fixtureItemsID())
1✔
743
    {
744
        foreach (quint32 subID, fixtureIDList(fid))
×
745
        {
746
            quint16 headIndex = fixtureHeadIndex(subID);
×
747
            quint16 linkedIndex = fixtureLinkedIndex(subID);
×
748
            PreviewItem item = fixtureItem(fid, headIndex, linkedIndex);
×
749

750
            doc->writeStartElement(KXMLQLCMonitorFixtureItem);
×
751
            doc->writeAttribute(KXMLQLCMonitorItemID, QString::number(fid));
×
752

753
            if (headIndex)
×
754
                doc->writeAttribute(KXMLQLCMonitorFixtureHeadIndex, QString::number(headIndex));
×
755

756
            if (linkedIndex)
×
757
            {
758
                doc->writeAttribute(KXMLQLCMonitorFixtureLinkedIndex, QString::number(linkedIndex));
×
759
                if (item.m_name.isEmpty() == false)
×
760
                    doc->writeAttribute(KXMLQLCMonitorItemName, item.m_name);
×
761
            }
762

763
            // write flags, if present
764
            if (item.m_flags & HiddenFlag)
×
765
                doc->writeAttribute(KXMLQLCMonitorFixtureHiddenFlag, KXMLQLCTrue);
×
766
            if (item.m_flags & InvertedPanFlag)
×
767
                doc->writeAttribute(KXMLQLCMonitorFixtureInvPanFlag, KXMLQLCTrue);
×
768
            if (item.m_flags & InvertedTiltFlag)
×
769
                doc->writeAttribute(KXMLQLCMonitorFixtureInvTiltFlag, KXMLQLCTrue);
×
770

771
            // always write position
772
            doc->writeAttribute(KXMLQLCMonitorItemXPosition, QString::number(item.m_position.x()));
×
773
            doc->writeAttribute(KXMLQLCMonitorItemYPosition, QString::number(item.m_position.y()));
×
774

775
#ifdef QMLUI
776
            doc->writeAttribute(KXMLQLCMonitorItemZPosition, QString::number(item.m_position.z()));
777

778
            // write rotation, if set
779
            if (item.m_rotation.x() != 0)
780
                doc->writeAttribute(KXMLQLCMonitorItemXRotation, QString::number(item.m_rotation.x()));
781
            if (item.m_rotation.y() != 0)
782
                doc->writeAttribute(KXMLQLCMonitorItemYRotation, QString::number(item.m_rotation.y()));
783
            if (item.m_rotation.z() != 0)
784
                doc->writeAttribute(KXMLQLCMonitorItemZRotation, QString::number(item.m_rotation.z()));
785
#else
786
            if (item.m_rotation != QVector3D(0, 0, 0))
787
                doc->writeAttribute(KXMLQLCMonitorFixtureRotation, QString::number(item.m_rotation.y()));
×
788
#endif
789
            if (item.m_color.isValid())
×
790
                doc->writeAttribute(KXMLQLCMonitorFixtureGelColor, item.m_color.name());
×
791

792
            doc->writeEndElement();
×
793
        }
794
    }
795
#ifdef QMLUI
796
    QDir dir = QDir::cleanPath(QLCFile::systemDirectory(MESHESDIR).path());
797
    QString meshDirAbsPath = dir.absolutePath() + QDir::separator();
798
#endif
799

800
    // ***********************************************************
801
    // *             write generic items information             *
802
    // ***********************************************************
803
    QMapIterator<quint32, PreviewItem> it(m_genericItems);
1✔
804
    while (it.hasNext())
1✔
805
    {
806
        it.next();
×
807
        quint32 itemID = it.key();
×
808
        PreviewItem item = it.value();
×
809

810
        doc->writeStartElement(KXMLQLCMonitorMeshItem);
×
811
        doc->writeAttribute(KXMLQLCMonitorItemID, QString::number(itemID));
×
812

813
        // write flags, if present
814
        if (item.m_flags & HiddenFlag)
×
815
            doc->writeAttribute(KXMLQLCMonitorFixtureHiddenFlag, KXMLQLCTrue);
×
816

817
        // always write position
818
        doc->writeAttribute(KXMLQLCMonitorItemXPosition, QString::number(item.m_position.x()));
×
819
        doc->writeAttribute(KXMLQLCMonitorItemYPosition, QString::number(item.m_position.y()));
×
820
        doc->writeAttribute(KXMLQLCMonitorItemZPosition, QString::number(item.m_position.z()));
×
821

822
        // write rotation, if set
823
        if (item.m_rotation.x() != 0)
×
824
            doc->writeAttribute(KXMLQLCMonitorItemXRotation, QString::number(item.m_rotation.x()));
×
825
        if (item.m_rotation.y() != 0)
×
826
            doc->writeAttribute(KXMLQLCMonitorItemYRotation, QString::number(item.m_rotation.y()));
×
827
        if (item.m_rotation.z() != 0)
×
828
            doc->writeAttribute(KXMLQLCMonitorItemZRotation, QString::number(item.m_rotation.z()));
×
829

830
        // write scale, if set
831
        if (item.m_scale.x() != 1.0)
×
832
            doc->writeAttribute(KXMLQLCMonitorItemXScale, QString::number(item.m_scale.x()));
×
833
        if (item.m_scale.y() != 1.0)
×
834
            doc->writeAttribute(KXMLQLCMonitorItemYScale, QString::number(item.m_scale.y()));
×
835
        if (item.m_scale.z() != 1.0)
×
836
            doc->writeAttribute(KXMLQLCMonitorItemZScale, QString::number(item.m_scale.z()));
×
837

838
        if (item.m_resource.isEmpty() == false)
×
839
        {
840
            // perform normalization depending on the mesh location
841
            // (mesh folder, project path, absolute path)
842
            QFileInfo res(item.m_resource);
×
843

844
            if (res.isRelative())
×
845
            {
846
                doc->writeAttribute(KXMLQLCMonitorItemRes, item.m_resource);
×
847
            }
848
#ifdef QMLUI
849
            else if (item.m_resource.startsWith(meshDirAbsPath))
850
            {
851
                item.m_resource.remove(meshDirAbsPath);
852
                doc->writeAttribute(KXMLQLCMonitorItemRes, item.m_resource);
853
            }
854
#endif
855
            else
856
            {
857
                doc->writeAttribute(KXMLQLCMonitorItemRes, mainDocument->normalizeComponentPath(item.m_resource));
×
858
            }
859
        }
×
860

861
        if (item.m_name.isEmpty() == false)
×
862
            doc->writeAttribute(KXMLQLCMonitorItemName, item.m_name);
×
863

864
        doc->writeEndElement();
×
865
    }
866

867
    doc->writeEndElement();
1✔
868

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

© 2025 Coveralls, Inc