• 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

89.47
/engine/src/efx.cpp
1
/*
2
  Q Light Controller Plus
3
  efx.cpp
4

5
  Copyright (C) Heikki Junnila
6
                Massimo Callegari
7

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

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

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

21
#include <QVector>
22
#include <QDebug>
23
#include <QList>
24
#include <QXmlStreamReader>
25
#include <QXmlStreamWriter>
26

27
#include <math.h>
28

29
#include "genericfader.h"
30
#include "mastertimer.h"
31
#include "qlcmacros.h"
32
#include "doc.h"
33
#include "efx.h"
34
#include "bus.h"
35

36
/*****************************************************************************
37
 * Initialization
38
 *****************************************************************************/
39

40
EFX::EFX(Doc* doc)
78 ✔
41
    : Function(doc, Function::EFXType)
42
    , m_algorithm(EFX::Circle)
78 ✔
43
    , m_dimmerControl(false)
78 ✔
44
    , m_isRelative(false)
78 ✔
45
    , m_xFrequency(2)
78 ✔
46
    , m_yFrequency(3)
78 ✔
47
    , m_xPhase(M_PI / 2.0)
78 ✔
48
    , m_yPhase(0)
78 ✔
49
    , m_propagationMode(Parallel)
78 ✔
50
    , m_legacyFadeBus(Bus::invalid())
78 ✔
51
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
52
    , m_fixturesMutex(QMutex::Recursive)
53
#endif
54
    , m_legacyHoldBus(Bus::invalid())
156 ✔
55
{
56
    updateRotationCache();
78 ✔
57
    setName(tr("New EFX"));
78 ✔
58
    setDuration(20000); // 20s
78 ✔
59

60
    registerAttribute(tr("Width"), Function::LastWins, 0.0, 127.0, 127.0);
78 ✔
61
    registerAttribute(tr("Height"), Function::LastWins, 0.0, 127.0, 127.0);
78 ✔
62
    registerAttribute(tr("Rotation"), Function::LastWins, 0.0, 359.0, 0.0);
78 ✔
63
    registerAttribute(tr("X Offset"), Function::LastWins, 0.0, 255.0, 127.0);
78 ✔
64
    registerAttribute(tr("Y Offset"), Function::LastWins, 0.0, 255.0, 127.0);
78 ✔
65
    registerAttribute(tr("Start Offset"), Function::LastWins, 0.0, 359.0, 0.0);
78 ✔
66
}
78 ✔
67

68
EFX::~EFX()
90 ✔
69
{
70
    while (m_fixtures.isEmpty() == false)
112 ✔
71
        delete m_fixtures.takeFirst();
34 ✔
72
}
90 ✔
73

UNCOV
74
QIcon EFX::getIcon() const
×
75
{
UNCOV
76
    return QIcon(":/efx.png");
×
77
}
78

79
/*****************************************************************************
80
 * Copying
81
 *****************************************************************************/
82

83
Function* EFX::createCopy(Doc* doc, bool addToDoc)
1 ✔
84
{
85
    Q_ASSERT(doc != NULL);
1 ✔
86

87
    Function* copy = new EFX(doc);
1 ✔
88
    if (copy->copyFrom(this) == false)
1 ✔
89
    {
UNCOV
90
        delete copy;
×
UNCOV
91
        copy = NULL;
×
92
    }
93
    if (addToDoc == true && doc->addFunction(copy) == false)
1 ✔
94
    {
UNCOV
95
        delete copy;
×
UNCOV
96
        copy = NULL;
×
97
    }
98

99
    return copy;
1 ✔
100
}
101

102
bool EFX::copyFrom(const Function* function)
4 ✔
103
{
104
    const EFX* efx = qobject_cast<const EFX*> (function);
4 ✔
105
    if (efx == NULL)
4 ✔
106
        return false;
1 ✔
107

108
    while (m_fixtures.isEmpty() == false)
5 ✔
109
        delete m_fixtures.takeFirst();
2 ✔
110

111
    QListIterator <EFXFixture*> it(efx->m_fixtures);
3 ✔
112
    while (it.hasNext() == true)
9 ✔
113
    {
114
        EFXFixture* ef = new EFXFixture(this);
6 ✔
115
        ef->copyFrom(it.next());
6 ✔
116
        m_fixtures.append(ef);
6 ✔
117
    }
118

119
    m_propagationMode = efx->m_propagationMode;
3 ✔
120

121
    for (int i = 0; i < efx->attributes().count(); i++)
24 ✔
122
        adjustAttribute(efx->attributes().at(i).m_value, i);
21 ✔
123

124
    m_isRelative = efx->m_isRelative;
3 ✔
125

126
    updateRotationCache();
3 ✔
127

128
    m_xFrequency = efx->m_xFrequency;
3 ✔
129
    m_yFrequency = efx->m_yFrequency;
3 ✔
130
    m_xPhase = efx->m_xPhase;
3 ✔
131
    m_yPhase = efx->m_yPhase;
3 ✔
132

133
    m_algorithm = efx->m_algorithm;
3 ✔
134
    m_dimmerControl = efx->m_dimmerControl;
3 ✔
135

136
    return Function::copyFrom(function);
3 ✔
137
}
3 ✔
138

139
void EFX::setDuration(uint ms)
87 ✔
140
{
141
    Function::setDuration(ms);
87 ✔
142

143
    for (int i = 0; i < m_fixtures.size(); ++i)
90 ✔
144
        m_fixtures[i]->durationChanged();
3 ✔
145

146
    emit durationChanged(ms);
87 ✔
147
}
87 ✔
148

149
uint EFX::loopDuration() const
863 ✔
150
{
151
    uint fadeIn = overrideFadeInSpeed() == defaultSpeed() ? fadeInSpeed() : overrideFadeInSpeed();
863 ✔
152

153
    // With a fade in not shorter than the duration, the subtraction would
154
    // wrap around to a huge loop and the EFX would look frozen: use the
155
    // whole duration for the loop instead
156
    if (fadeIn >= duration())
863 ✔
157
        return duration();
52 ✔
158

159
    return duration() - fadeIn;
811 ✔
160
}
161

162
/*****************************************************************************
163
 * Algorithm
164
 *****************************************************************************/
165

166
EFX::Algorithm EFX::algorithm() const
22,708 ✔
167
{
168
    return m_algorithm;
22,708 ✔
169
}
170

171
void EFX::setAlgorithm(EFX::Algorithm algo)
37 ✔
172
{
173
    if (algo == m_algorithm)
37 ✔
UNCOV
174
        return;
×
175

176
    if (algo >= EFX::Circle && algo <= EFX::Lissajous)
37 ✔
177
        m_algorithm = algo;
36 ✔
178
    else
179
        m_algorithm = EFX::Circle;
1 ✔
180

181
    emit changed(this->id());
37 ✔
182
}
183

184
QStringList EFX::algorithmList()
1 ✔
185
{
186
    QStringList list;
1 ✔
187
    list << algorithmToString(EFX::Circle);
1 ✔
188
    list << algorithmToString(EFX::Eight);
1 ✔
189
    list << algorithmToString(EFX::Line);
1 ✔
190
    list << algorithmToString(EFX::Line2);
1 ✔
191
    list << algorithmToString(EFX::Diamond);
1 ✔
192
    list << algorithmToString(EFX::Square);
1 ✔
193
    list << algorithmToString(EFX::SquareChoppy);
1 ✔
194
    list << algorithmToString(EFX::SquareTrue);
1 ✔
195
    list << algorithmToString(EFX::Leaf);
1 ✔
196
    list << algorithmToString(EFX::Lissajous);
1 ✔
197
    return list;
1 ✔
UNCOV
198
}
×
199

200
QString EFX::algorithmToString(EFX::Algorithm algo)
12 ✔
201
{
202
    switch (algo)
12 ✔
203
    {
204
        default:
2 ✔
205
        case EFX::Circle:
206
            return QString(KXMLQLCEFXCircleAlgorithmName);
2 ✔
207
        case EFX::Eight:
1 ✔
208
            return QString(KXMLQLCEFXEightAlgorithmName);
1 ✔
209
        case EFX::Line:
1 ✔
210
            return QString(KXMLQLCEFXLineAlgorithmName);
1 ✔
211
        case EFX::Line2:
1 ✔
212
            return QString(KXMLQLCEFXLine2AlgorithmName);
1 ✔
213
        case EFX::Diamond:
1 ✔
214
            return QString(KXMLQLCEFXDiamondAlgorithmName);
1 ✔
215
        case EFX::Square:
1 ✔
216
            return QString(KXMLQLCEFXSquareAlgorithmName);
1 ✔
217
        case EFX::SquareChoppy:
1 ✔
218
            return QString(KXMLQLCEFXSquareChoppyAlgorithmName);
1 ✔
219
        case EFX::SquareTrue:
1 ✔
220
            return QString(KXMLQLCEFXSquareTrueAlgorithmName);
1 ✔
221
        case EFX::Leaf:
1 ✔
222
            return QString(KXMLQLCEFXLeafAlgorithmName);
1 ✔
223
        case EFX::Lissajous:
2 ✔
224
            return QString(KXMLQLCEFXLissajousAlgorithmName);
2 ✔
225
    }
226
}
227

228
EFX::Algorithm EFX::stringToAlgorithm(const QString& str)
14 ✔
229
{
230
    if (str == QString(KXMLQLCEFXEightAlgorithmName))
14 ✔
231
        return EFX::Eight;
1 ✔
232
    else if (str == QString(KXMLQLCEFXLineAlgorithmName))
13 ✔
233
        return EFX::Line;
1 ✔
234
    else if (str == QString(KXMLQLCEFXLine2AlgorithmName))
12 ✔
235
        return EFX::Line2;
1 ✔
236
    else if (str == QString(KXMLQLCEFXDiamondAlgorithmName))
11 ✔
237
        return EFX::Diamond;
4 ✔
238
    else if (str == QString(KXMLQLCEFXSquareAlgorithmName))
7 ✔
239
        return EFX::Square;
1 ✔
240
    else if (str == QString(KXMLQLCEFXSquareChoppyAlgorithmName))
6 ✔
241
        return EFX::SquareChoppy;
1 ✔
242
    else if (str == QString(KXMLQLCEFXSquareTrueAlgorithmName))
5 ✔
243
        return EFX::SquareTrue;
1 ✔
244
    else if (str == QString(KXMLQLCEFXLeafAlgorithmName))
4 ✔
245
        return EFX::Leaf;
1 ✔
246
    else if (str == QString(KXMLQLCEFXLissajousAlgorithmName))
3 ✔
247
        return EFX::Lissajous;
1 ✔
248
    else
249
        return EFX::Circle;
2 ✔
250
}
251

252
bool EFX::dimmerControlEnabled() const
174 ✔
253
{
254
    return m_dimmerControl;
174 ✔
255
}
256

257
void EFX::setDimmerControlEnabled(bool enable)
1 ✔
258
{
259
    m_dimmerControl = enable;
1 ✔
260
}
1 ✔
261

262
void EFX::preview(QPolygonF &polygon) const
35 ✔
263
{
264
    preview(polygon, Function::Forward, 0);
35 ✔
265
}
35 ✔
266

267
void EFX::previewFixtures(QVector <QPolygonF>& polygons) const
×
268
{
UNCOV
269
    polygons.resize(m_fixtures.size());
×
270
    for (int i = 0; i < m_fixtures.size(); ++i)
×
271
    {
272
        int propagationOffset =
UNCOV
273
            (m_propagationMode == EFX::Asymmetric || m_propagationMode == EFX::Serial)
×
274
                ? 360 / m_fixtures.size() * i
×
275
                : 0;
×
276

277
        preview(polygons[i], m_fixtures[i]->m_direction,
×
UNCOV
278
                m_fixtures[i]->m_startOffset + propagationOffset);
×
279
    }
UNCOV
280
}
×
281

282
void EFX::preview(QPolygonF &polygon, Function::Direction direction, int startOffset) const
35 ✔
283
{
284
    float stepCount = 512.0;
35 ✔
285
    int step = 0;
35 ✔
286
    float stepSize = 1.0 / (stepCount / (M_PI * 2.0));
35 ✔
287

288
    float i = 0;
35 ✔
289
    float x = 0;
35 ✔
290
    float y = 0;
35 ✔
291

292
    /* Reset the polygon to fill it with new values */
293
    polygon.clear();
35 ✔
294

295
    /* Draw a preview of the effect */
296
    for (step = 0; step < stepCount; step++)
17,955 ✔
297
    {
298
        calculatePoint(direction, startOffset, i, &x, &y);
17,920 ✔
299
        polygon << QPointF(x, y);
17,920 ✔
300
        i += stepSize;
17,920 ✔
301
    }
302
}
35 ✔
303

304
void EFX::calculatePoint(Function::Direction direction, int startOffset, float iterator, float *x, float *y) const
18,082 ✔
305
{
306
    iterator = calculateDirection(direction, iterator);
18,082 ✔
307
    iterator += convertOffset(startOffset + getAttributeValue(StartOffset));
18,082 ✔
308

309
    if (iterator >= M_PI * 2.0)
18,082 ✔
310
        iterator -= M_PI * 2.0;
8 ✔
311

312
    calculatePoint(iterator, x, y);
18,082 ✔
313
}
18,082 ✔
314

315
void EFX::rotateAndScale(float *x, float *y) const
18,097 ✔
316
{
317
    float xx = *x;
18,097 ✔
318
    float yy = *y;
18,097 ✔
319
    float w = getAttributeValue(Width);
18,097 ✔
320
    float h = getAttributeValue(Height);
18,097 ✔
321
    float fadeScale = 1.0;
18,097 ✔
322

323
    if (isRunning())
18,097 ✔
324
    {
325
        uint fadeIn = overrideFadeInSpeed() == defaultSpeed() ? fadeInSpeed() : overrideFadeInSpeed();
162 ✔
326
        if (fadeIn > 0 && elapsed() <= fadeIn)
162 ✔
327
        {
UNCOV
328
            fadeScale = SCALE(float(elapsed()),
×
329
                              float(0), float(fadeIn),
330
                              float(0), float(1.0));
331
        }
332
    }
333

334
    *x = (getAttributeValue(XOffset)) + xx * m_cosR * (w * fadeScale) + yy * m_sinR * (h * fadeScale);
18,097 ✔
335
    *y = (getAttributeValue(YOffset)) + -xx * m_sinR * (w * fadeScale) + yy * m_cosR * (h * fadeScale);
18,097 ✔
336
}
18,097 ✔
337

338
float EFX::calculateDirection(Function::Direction direction, float iterator) const
18,082 ✔
339
{
340
    if (direction == this->direction())
18,082 ✔
341
        return iterator;
13,474 ✔
342

343
    switch (algorithm())
4,608 ✔
344
    {
345
    default:
4,096 ✔
346
    case Circle:
347
    case Eight:
348
    case Line2:
349
    case Diamond:
350
    case Square:
351
    case SquareChoppy:
352
    case SquareTrue:
353
    case Leaf:
354
    case Lissajous:
355
        return (M_PI * 2.0) - iterator;
4,096 ✔
356
    case Line:
512 ✔
357
        return (iterator > M_PI) ? (iterator - M_PI) : (iterator + M_PI);
512 ✔
358
    }
359
}
360

361
float EFX::dimmerLevel(float startOffset, float iterator) const
8 ✔
362
{
363
    /* The dimmer follows the tilt itself, so it fades at the same RATE as the
364
       movement (not linearly), reaching full/0 exactly when the tilt reaches its
365
       extremes. The angle is phased per fixture by its StartOffset (both in
366
       radians). Over the first half [0, PI) the tilt goes from its +1 extreme to
367
       its -1 extreme; the second half [PI, 2PI) (the return stroke) stays black.
368
       The EFX Direction is handled by the movement itself, so it is not applied
369
       here. */
370
    const float PI = float(M_PI);
8 ✔
371
    const float TWO_PI = float(M_PI * 2.0);
8 ✔
372

373
    float angle = iterator + startOffset;
8 ✔
374
    angle = fmodf(angle, TWO_PI);
8 ✔
375
    if (angle < 0.0f)
8 ✔
UNCOV
376
        angle += TWO_PI;
×
377

378
    if (angle >= PI)
8 ✔
379
        return 0.0f; // return stroke: black
4 ✔
380

381
    /* cos(angle): +1 at angle 0 (tilt extreme) -> -1 at angle PI (other extreme).
382
       Map to 0..1 so brightness tracks the tilt curve: full at +1, dark at -1. */
383
    return (cosf(angle) + 1.0f) * 0.5f;
4 ✔
384
}
385

386
// this function should map from 0..M_PI * 2 -> -1..1
387
void EFX::calculatePoint(float iterator, float *x, float *y) const
18,082 ✔
388
{
389
    switch (algorithm())
18,082 ✔
390
    {
391
    default:
5,282 ✔
392
    case Circle:
393
        *x = cos(iterator + M_PI_2);
5,282 ✔
394
        *y = cos(iterator);
5,282 ✔
395
        break;
5,282 ✔
396

397
    case Eight:
1,536 ✔
398
        *x = cos((iterator * 2) + M_PI_2);
1,536 ✔
399
        *y = cos(iterator);
1,536 ✔
400
        break;
1,536 ✔
401

402
    case Line:
1,536 ✔
403
        *x = cos(iterator);
1,536 ✔
404
        *y = cos(iterator);
1,536 ✔
405
        break;
1,536 ✔
406

407
    case Line2:
1,536 ✔
408
        *x = iterator / M_PI - 1;
1,536 ✔
409
        *y = iterator / M_PI - 1;
1,536 ✔
410
        break;
1,536 ✔
411

412
    case Diamond:
1,536 ✔
413
        *x = pow(cos(iterator - M_PI_2), 3);
1,536 ✔
414
        *y = pow(cos(iterator), 3);
1,536 ✔
415
        break;
1,536 ✔
416

417
    case Square:
1,536 ✔
418
        if (iterator < M_PI / 2)
1,536 ✔
419
        {
420
            *x = (iterator * 2 / M_PI) * 2 - 1;
385 ✔
421
            *y = 1;
385 ✔
422
        }
423
        else if (M_PI / 2 <= iterator && iterator < M_PI)
1,151 ✔
424
        {
425
            *x = 1;
384 ✔
426
            *y = (1 - (iterator - M_PI / 2) * 2 / M_PI) * 2 - 1;
384 ✔
427
        }
428
        else if (M_PI <= iterator && iterator < M_PI * 3 / 2)
767 ✔
429
        {
430
            *x = (1 - (iterator - M_PI) * 2 / M_PI) * 2 - 1;
384 ✔
431
            *y = -1;
384 ✔
432
        }
433
        else // M_PI * 3 / 2 <= iterator
434
        {
435
            *x = -1;
383 ✔
436
            *y = ((iterator - M_PI * 3 / 2) * 2 / M_PI) * 2 - 1;
383 ✔
437
        }
438
        break;
1,536 ✔
439

440
    case SquareChoppy:
1,536 ✔
441
        *x = round(cos(iterator));
1,536 ✔
442
        *y = round(sin(iterator));
1,536 ✔
443
        break;
1,536 ✔
444

445
    case SquareTrue:
512 ✔
446
        if (iterator < M_PI / 2)
512 ✔
447
        {
448
            *x = 1;
128 ✔
449
            *y = 1;
128 ✔
450
        }
451
        else if (M_PI / 2 <= iterator && iterator < M_PI)
384 ✔
452
        {
453
            *x = 1;
128 ✔
454
            *y = -1;
128 ✔
455
        }
456
        else if (M_PI <= iterator && iterator < M_PI * 3 / 2)
256 ✔
457
        {
458
            *x = -1;
128 ✔
459
            *y = -1;
128 ✔
460
        }
461
        else // M_PI * 3 / 2 <= iterator
462
        {
463
            *x = -1;
128 ✔
464
            *y = 1;
128 ✔
465
        }
466
        break;
512 ✔
467

468
    case Leaf:
1,536 ✔
469
        *x = pow(cos(iterator + M_PI_2), 5);
1,536 ✔
470
        *y = cos(iterator);
1,536 ✔
471
        break;
1,536 ✔
472

473
    case Lissajous:
1,536 ✔
474
        {
475
            if (m_xFrequency > 0)
1,536 ✔
476
                *x = cos((m_xFrequency * iterator) - m_xPhase);
1,536 ✔
477
            else
478
            {
479
                float iterator0 = ((iterator + m_xPhase) / M_PI);
×
480
                int fff = iterator0;
×
481
                iterator0 -= (fff - fff % 2);
×
482
                float forward = 1 - floor(iterator0); // 1 when forward
×
UNCOV
483
                float backward = 1 - forward; // 1 when backward
×
UNCOV
484
                iterator0 = iterator0 - floor(iterator0);
×
UNCOV
485
                *x = (forward * iterator0 + backward * (1 - iterator0)) * 2 - 1;
×
486
            }
487
            if (m_yFrequency > 0)
1,536 ✔
488
                *y = cos((m_yFrequency * iterator) - m_yPhase);
1,536 ✔
489
            else
490
            {
491
                float iterator0 = ((iterator + m_yPhase) / M_PI);
×
492
                int fff = iterator0;
×
493
                iterator0 -= (fff - fff % 2);
×
494
                float forward = 1 - floor(iterator0); // 1 when forward
×
UNCOV
495
                float backward = 1 - forward; // 1 when backward
×
UNCOV
496
                iterator0 = iterator0 - floor(iterator0);
×
UNCOV
497
                *y = (forward * iterator0 + backward * (1 - iterator0)) * 2 - 1;
×
498
            }
499
        }
500
        break;
1,536 ✔
501
    }
502

503
    rotateAndScale(x, y);
18,082 ✔
504
}
18,082 ✔
505

506
/*****************************************************************************
507
 * Width
508
 *****************************************************************************/
509

510
void EFX::setWidth(int width)
28 ✔
511
{
512
    adjustAttribute(static_cast<double> (CLAMP(width, 0, 127)), Width);
28 ✔
513
    emit changed(this->id());
28 ✔
514
}
28 ✔
515

516
int EFX::width() const
13 ✔
517
{
518
    return static_cast<int> (attributes().at(Width).m_value);
13 ✔
519
}
520

521
/*****************************************************************************
522
 * Height
523
 *****************************************************************************/
524

525
void EFX::setHeight(int height)
28 ✔
526
{
527
    adjustAttribute(static_cast<double> (CLAMP(height, 0, 127)), Height);
28 ✔
528
    emit changed(this->id());
28 ✔
529
}
28 ✔
530

531
int EFX::height() const
13 ✔
532
{
533
    return static_cast<int> (attributes().at(Height).m_value);
13 ✔
534
}
535

536
/*****************************************************************************
537
 * Rotation
538
 *****************************************************************************/
539

540
void EFX::setRotation(int rot)
27 ✔
541
{
542
    adjustAttribute(CLAMP(rot, 0, 359), Rotation);
27 ✔
543
    updateRotationCache();
27 ✔
544
    emit changed(this->id());
27 ✔
545
}
27 ✔
546

547
int EFX::rotation() const
13 ✔
548
{
549
    return static_cast<int> (attributes().at(Rotation).m_value);
13 ✔
550
}
551

552
void EFX::updateRotationCache()
210 ✔
553
{
554
    double r = M_PI/180 * getAttributeValue(Rotation);
210 ✔
555
    m_cosR = cos(r);
210 ✔
556
    m_sinR = sin(r);
210 ✔
557
}
210 ✔
558

559
/*****************************************************************************
560
 * Start Offset
561
 *****************************************************************************/
562

563
void EFX::setStartOffset(int startOffset)
1 ✔
564
{
565
    adjustAttribute(CLAMP(startOffset, 0, 359), StartOffset);
1 ✔
566
    emit changed(this->id());
1 ✔
567
}
1 ✔
568

569
int EFX::startOffset() const
2 ✔
570
{
571
    return static_cast<int> (attributes().at(StartOffset).m_value);
2 ✔
572
}
573

574
float EFX::convertOffset(int offset) const
18,082 ✔
575
{
576
    return M_PI/180 * (offset % 360);
18,082 ✔
577
}
578

579
/*****************************************************************************
580
 * Is Relative
581
 *****************************************************************************/
582

583
void EFX::setIsRelative(bool isRelative)
1 ✔
584
{
585
    m_isRelative = isRelative;
1 ✔
586
    emit changed(this->id());
1 ✔
587
}
1 ✔
588

589
bool EFX::isRelative() const
333 ✔
590
{
591
    return m_isRelative;
333 ✔
592
}
593

594
/*****************************************************************************
595
 * Offset
596
 *****************************************************************************/
597

598
void EFX::setXOffset(int offset)
29 ✔
599
{
600
    adjustAttribute(static_cast<double> (CLAMP(offset, 0, (int)UCHAR_MAX)), XOffset);
29 ✔
601
    emit changed(this->id());
29 ✔
602
}
29 ✔
603

604
int EFX::xOffset() const
14 ✔
605
{
606
    return static_cast<int> (attributes().at(XOffset).m_value);
14 ✔
607
}
608

609
void EFX::setYOffset(int offset)
29 ✔
610
{
611
    adjustAttribute(static_cast<double> (CLAMP(offset, 0, (int)UCHAR_MAX)), YOffset);
29 ✔
612
    emit changed(this->id());
29 ✔
613
}
29 ✔
614

615
int EFX::yOffset() const
13 ✔
616
{
617
    return static_cast<int> (attributes().at(YOffset).m_value);
13 ✔
618
}
619

620
/*****************************************************************************
621
 * Frequency
622
 *****************************************************************************/
623

624
void EFX::setXFrequency(int freq)
18 ✔
625
{
626
    m_xFrequency = static_cast<float> (CLAMP(freq, 0, 32));
18 ✔
627
    emit changed(this->id());
18 ✔
628
}
18 ✔
629

630
int EFX::xFrequency() const
19 ✔
631
{
632
    return static_cast<int> (m_xFrequency);
19 ✔
633
}
634

635
void EFX::setYFrequency(int freq)
18 ✔
636
{
637
    m_yFrequency = static_cast<float> (CLAMP(freq, 0, 32));
18 ✔
638
    emit changed(this->id());
18 ✔
639
}
18 ✔
640

641
int EFX::yFrequency() const
18 ✔
642
{
643
    return static_cast<int> (m_yFrequency);
18 ✔
644
}
645

646
bool EFX::isFrequencyEnabled() const
5 ✔
647
{
648
    if (m_algorithm == EFX::Lissajous)
5 ✔
649
        return true;
2 ✔
650
    else
651
        return false;
3 ✔
652
}
653

654
/*****************************************************************************
655
 * Phase
656
 *****************************************************************************/
657

658
void EFX::setXPhase(int phase)
20 ✔
659
{
660
    m_xPhase = static_cast<float> (CLAMP(phase, 0, 359)) * M_PI / 180.0;
20 ✔
661
    emit changed(this->id());
20 ✔
662
}
20 ✔
663

664
int EFX::xPhase() const
21 ✔
665
{
666
    return static_cast<int> (floor((m_xPhase * 180.0 / M_PI) + 0.5));
21 ✔
667
}
668

669
void EFX::setYPhase(int phase)
20 ✔
670
{
671
    m_yPhase = static_cast<float> (CLAMP(phase, 0, 359)) * M_PI / 180.0;
20 ✔
672
    emit changed(this->id());
20 ✔
673
}
20 ✔
674

675
int EFX::yPhase() const
20 ✔
676
{
677
    return static_cast<int> (floor((m_yPhase * 180.0 / M_PI) + 0.5));
20 ✔
678
}
679

680
bool EFX::isPhaseEnabled() const
5 ✔
681
{
682
    if (m_algorithm == EFX::Lissajous)
5 ✔
683
        return true;
2 ✔
684
    else
685
        return false;
3 ✔
686
}
687

688
/*****************************************************************************
689
 * Fixtures
690
 *****************************************************************************/
691

692
bool EFX::addFixture(EFXFixture* ef)
38 ✔
693
{
694
    Q_ASSERT(ef != NULL);
38 ✔
695

696
    /* Search for an existing fixture with the same ID and append at last but do
697
     * not prevent multiple entries because a fixture can have multiple efx. */
698
    //! @todo Prevent multiple entries using head & mode
699
    {
700
        QMutexLocker locker(&m_fixturesMutex);
38 ✔
701
        int i;
702
        for (i = 0; i < m_fixtures.size(); i++)
73 ✔
703
        {
704
            if (m_fixtures[i]->head() == ef->head())
35 ✔
705
            {
UNCOV
706
                m_fixtures.insert(i, ef);
×
UNCOV
707
                break;
×
708
            }
709
        }
710

711
        /* If not inserted, put the EFXFixture object into our list */
712
        if (i >= m_fixtures.size())
38 ✔
713
            m_fixtures.append(ef);
38 ✔
714
    }
38 ✔
715

716
    emit changed(this->id());
38 ✔
717

718
    return true;
38 ✔
719
}
720

721
bool EFX::addFixture(quint32 fxi, int head)
×
722
{
UNCOV
723
    EFXFixture *ef = new EFXFixture(this);
×
UNCOV
724
    GroupHead gHead(fxi, head);
×
UNCOV
725
    ef->setHead(gHead);
×
726

UNCOV
727
    return addFixture(ef);
×
UNCOV
728
}
×
729

730
bool EFX::removeFixture(EFXFixture* ef)
2 ✔
731
{
732
    Q_ASSERT(ef != NULL);
2 ✔
733

734
    int removed = 0;
2 ✔
735
    {
736
        QMutexLocker locker(&m_fixturesMutex);
2 ✔
737
        removed = m_fixtures.removeAll(ef);
2 ✔
738
    }
2 ✔
739

740
    if (removed > 0)
2 ✔
741
    {
742
        emit changed(this->id());
1 ✔
743
        return true;
1 ✔
744
    }
745
    else
746
    {
747
        return false;
1 ✔
748
    }
749
}
750

751
bool EFX::removeFixture(quint32 fxi, int head)
2 ✔
752
{
753
    QMutexLocker locker(&m_fixturesMutex);
2 ✔
754
    for (int i = 0; i < m_fixtures.count(); i++)
2 ✔
755
    {
756
        EFXFixture *ef = m_fixtures.at(i);
1 ✔
757
        if (ef->head().fxi == fxi && ef->head().head == head)
1 ✔
758
        {
759
            m_fixtures.removeAt(i);
1 ✔
760
            return true;
1 ✔
761
        }
762
    }
763

764
    return false;
1 ✔
765
}
2 ✔
766

UNCOV
767
void EFX::removeAllFixtures()
×
768
{
769
    {
UNCOV
770
        QMutexLocker locker(&m_fixturesMutex);
×
UNCOV
771
        m_fixtures.clear();
×
UNCOV
772
    }
×
UNCOV
773
    emit changed(this->id());
×
UNCOV
774
}
×
775

776
bool EFX::raiseFixture(EFXFixture* ef)
3 ✔
777
{
778
    Q_ASSERT(ef != NULL);
3 ✔
779

780
    QMutexLocker locker(&m_fixturesMutex);
3 ✔
781
    int index = m_fixtures.indexOf(ef);
3 ✔
782
    if (index > 0)
3 ✔
783
    {
784
        m_fixtures.move(index, index - 1);
1 ✔
785
        locker.unlock();
1 ✔
786
        emit changed(this->id());
1 ✔
787
        return true;
1 ✔
788
    }
789
    else
790
    {
791
        return false;
2 ✔
792
    }
793
}
3 ✔
794

795
bool EFX::lowerFixture(EFXFixture* ef)
3 ✔
796
{
797
    QMutexLocker locker(&m_fixturesMutex);
3 ✔
798
    int index = m_fixtures.indexOf(ef);
3 ✔
799
    if (index < (m_fixtures.count() - 1))
3 ✔
800
    {
801
        m_fixtures.move(index, index + 1);
1 ✔
802
        locker.unlock();
1 ✔
803
        emit changed(this->id());
1 ✔
804
        return true;
1 ✔
805
    }
806
    else
807
    {
808
        return false;
2 ✔
809
    }
810
}
3 ✔
811

812
const QList <EFXFixture*> EFX::fixtures() const
80 ✔
813
{
814
    return m_fixtures;
80 ✔
815
}
816

817
EFXFixture *EFX::fixture(quint32 id, int headIndex)
4 ✔
818
{
819
    foreach (EFXFixture *ef, m_fixtures)
10 ✔
820
    {
821
        if (ef->head().fxi == id && ef->head().head == headIndex)
9 ✔
822
            return ef;
3 ✔
823
    }
4 ✔
824

825
    return NULL;
1 ✔
826
}
827

UNCOV
828
QList<quint32> EFX::components() const
×
829
{
UNCOV
830
    QList<quint32> ids;
×
831

UNCOV
832
    foreach (EFXFixture *ef, m_fixtures)
×
833
    {
UNCOV
834
        if (ids.contains(ef->head().fxi) == false)
×
UNCOV
835
            ids.append(ef->head().fxi);
×
UNCOV
836
    }
×
837

UNCOV
838
    return ids;
×
UNCOV
839
}
×
840

841
void EFX::slotFixtureRemoved(quint32 fxi_id)
6 ✔
842
{
843
    bool removed = false;
6 ✔
844

845
    {
846
        QMutexLocker locker(&m_fixturesMutex);
6 ✔
847

848
        /* Remove the destroyed fixture from our list. A fixture with
849
         * more than one head has an entry for each of them */
850
        QMutableListIterator <EFXFixture*> it(m_fixtures);
6 ✔
851
        while (it.hasNext() == true)
21 ✔
852
        {
853
            it.next();
15 ✔
854

855
            if (it.value()->head().fxi == fxi_id)
15 ✔
856
            {
857
                delete it.value();
6 ✔
858
                it.remove();
6 ✔
859
                removed = true;
6 ✔
860
            }
861
        }
862
    }
6 ✔
863

864
    if (removed)
6 ✔
865
        emit changed(this->id());
4 ✔
866
}
6 ✔
867

868
/*****************************************************************************
869
 * Fixture propagation mode
870
 *****************************************************************************/
871

872
void EFX::setPropagationMode(PropagationMode mode)
9 ✔
873
{
874
    m_propagationMode = mode;
9 ✔
875
    emit changed(this->id());
9 ✔
876
}
9 ✔
877

878
EFX::PropagationMode EFX::propagationMode() const
495 ✔
879
{
880
    return m_propagationMode;
495 ✔
881
}
882

883
QString EFX::propagationModeToString(PropagationMode mode)
6 ✔
884
{
885
    if (mode == Serial)
6 ✔
886
        return QString(KXMLQLCEFXPropagationModeSerial);
2 ✔
887
    else if (mode == Asymmetric)
4 ✔
888
        return QString(KXMLQLCEFXPropagationModeAsymmetric);
1 ✔
889
    else
890
        return QString(KXMLQLCEFXPropagationModeParallel);
3 ✔
891
}
892

893
EFX::PropagationMode EFX::stringToPropagationMode(const QString& str)
7 ✔
894
{
895
    if (str == QString(KXMLQLCEFXPropagationModeSerial))
7 ✔
896
        return Serial;
4 ✔
897
    else if (str == QString(KXMLQLCEFXPropagationModeAsymmetric))
3 ✔
898
        return Asymmetric;
1 ✔
899
    else
900
        return Parallel;
2 ✔
901
}
902

903
/*****************************************************************************
904
 * Load & Save
905
 *****************************************************************************/
906

907
bool EFX::saveXML(QXmlStreamWriter *doc) const
2 ✔
908
{
909
    Q_ASSERT(doc != NULL);
2 ✔
910

911
    /* Function tag */
912
    doc->writeStartElement(KXMLQLCFunction);
4 ✔
913

914
    /* Common attributes */
915
    saveXMLCommon(doc);
2 ✔
916

917
    /* Fixtures */
918
    QListIterator <EFXFixture*> it(m_fixtures);
2 ✔
919
    while (it.hasNext() == true)
5 ✔
920
        it.next()->saveXML(doc);
3 ✔
921

922
    /* Propagation mode */
923
    doc->writeTextElement(KXMLQLCEFXPropagationMode, propagationModeToString(m_propagationMode));
4 ✔
924

925
    /* Tempo type */
926
    saveXMLTempoType(doc);
2 ✔
927
    /* Speeds */
928
    saveXMLSpeed(doc);
2 ✔
929
    /* Direction */
930
    saveXMLDirection(doc);
2 ✔
931
    /* Run order */
932
    saveXMLRunOrder(doc);
2 ✔
933

934
    /* Algorithm */
935
    doc->writeTextElement(KXMLQLCEFXAlgorithm, algorithmToString(algorithm()));
4 ✔
936
    /* Width */
937
    doc->writeTextElement(KXMLQLCEFXWidth, QString::number(width()));
4 ✔
938
    /* Height */
939
    doc->writeTextElement(KXMLQLCEFXHeight, QString::number(height()));
4 ✔
940
    /* Rotation */
941
    doc->writeTextElement(KXMLQLCEFXRotation, QString::number(rotation()));
4 ✔
942
    /* StartOffset */
943
    doc->writeTextElement(KXMLQLCEFXStartOffset, QString::number(startOffset()));
4 ✔
944
    /* IsRelative */
945
    doc->writeTextElement(KXMLQLCEFXIsRelative, QString::number(isRelative() ? 1 : 0));
4 ✔
946
    /* DimmerControl */
947
    doc->writeTextElement(KXMLQLCEFXDimmerControl, QString::number(dimmerControlEnabled() ? 1 : 0));
4 ✔
948

949
    /********************************************
950
     * X-Axis
951
     ********************************************/
952
    doc->writeStartElement(KXMLQLCEFXAxis);
4 ✔
953
    doc->writeAttribute(KXMLQLCFunctionName, KXMLQLCEFXX);
6 ✔
954

955
    /* Offset */
956
    doc->writeTextElement(KXMLQLCEFXOffset, QString::number(xOffset()));
4 ✔
957
    /* Frequency */
958
    doc->writeTextElement(KXMLQLCEFXFrequency, QString::number(xFrequency()));
4 ✔
959
    /* Phase */
960
    doc->writeTextElement(KXMLQLCEFXPhase, QString::number(xPhase()));
4 ✔
961

962
    /* End the (X) <Axis> tag */
963
    doc->writeEndElement();
2 ✔
964

965
    /********************************************
966
     * Y-Axis
967
     ********************************************/
968
    doc->writeStartElement(KXMLQLCEFXAxis);
4 ✔
969
    doc->writeAttribute(KXMLQLCFunctionName, KXMLQLCEFXY);
6 ✔
970

971
    /* Offset */
972
    doc->writeTextElement(KXMLQLCEFXOffset, QString::number(yOffset()));
4 ✔
973
    /* Frequency */
974
    doc->writeTextElement(KXMLQLCEFXFrequency, QString::number(yFrequency()));
4 ✔
975
    /* Phase */
976
    doc->writeTextElement(KXMLQLCEFXPhase, QString::number(yPhase()));
4 ✔
977

978
    /* End the (Y) <Axis> tag */
979
    doc->writeEndElement();
2 ✔
980

981
    /* End the <Function> tag */
982
    doc->writeEndElement();
2 ✔
983

984
    return true;
2 ✔
985
}
2 ✔
986

987
bool EFX::loadXML(QXmlStreamReader &root)
5 ✔
988
{
989
    if (root.name() != KXMLQLCFunction)
5 ✔
990
    {
991
        qWarning() << "Function node not found!";
1 ✔
992
        return false;
1 ✔
993
    }
994

995
    if (root.attributes().value(KXMLQLCFunctionType).toString() != typeToString(Function::EFXType))
8 ✔
996
    {
997
        qWarning("Function is not an EFX!");
1 ✔
998
        return false;
1 ✔
999
    }
1000

1001
    /* Load EFX contents */
1002
    while (root.readNextStartElement())
45 ✔
1003
    {
1004
        if (root.name() == KXMLQLCBus)
42 ✔
1005
        {
1006
            /* Bus */
1007
            QString str = root.attributes().value(KXMLQLCBusRole).toString();
6 ✔
1008
            if (str == KXMLQLCBusFade)
3 ✔
1009
                m_legacyFadeBus = root.readElementText().toUInt();
2 ✔
1010
            else if (str == KXMLQLCBusHold)
1 ✔
1011
                m_legacyHoldBus = root.readElementText().toUInt();
1 ✔
1012
        }
3 ✔
1013
        else if (root.name() == KXMLQLCFunctionSpeed)
39 ✔
1014
        {
1015
            loadXMLSpeed(root);
1 ✔
1016
        }
1017
        else if (root.name() == KXMLQLCFunctionTempoType)
38 ✔
1018
        {
UNCOV
1019
            loadXMLTempoType(root);
×
1020
        }
1021
        else if (root.name() == KXMLQLCEFXFixture)
38 ✔
1022
        {
1023
            EFXFixture* ef = new EFXFixture(this);
9 ✔
1024
            ef->loadXML(root);
9 ✔
1025
            if (ef->head().isValid())
9 ✔
1026
            {
1027
                if (addFixture(ef) == false)
9 ✔
UNCOV
1028
                    delete ef;
×
1029
            }
1030
        }
1031
        else if (root.name() == KXMLQLCEFXPropagationMode)
29 ✔
1032
        {
1033
            /* Propagation mode */
1034
            setPropagationMode(stringToPropagationMode(root.readElementText()));
3 ✔
1035
        }
1036
        else if (root.name() == KXMLQLCEFXAlgorithm)
26 ✔
1037
        {
1038
            /* Algorithm */
1039
            setAlgorithm(stringToAlgorithm(root.readElementText()));
3 ✔
1040
        }
1041
        else if (root.name() == KXMLQLCFunctionDirection)
23 ✔
1042
        {
1043
            loadXMLDirection(root);
3 ✔
1044
        }
1045
        else if (root.name() == KXMLQLCFunctionRunOrder)
20 ✔
1046
        {
1047
            loadXMLRunOrder(root);
3 ✔
1048
        }
1049
        else if (root.name() == KXMLQLCEFXWidth)
17 ✔
1050
        {
1051
            /* Width */
1052
            setWidth(root.readElementText().toInt());
3 ✔
1053
        }
1054
        else if (root.name() == KXMLQLCEFXHeight)
14 ✔
1055
        {
1056
            /* Height */
1057
            setHeight(root.readElementText().toInt());
3 ✔
1058
        }
1059
        else if (root.name() == KXMLQLCEFXRotation)
11 ✔
1060
        {
1061
            /* Rotation */
1062
            setRotation(root.readElementText().toInt());
3 ✔
1063
        }
1064
        else if (root.name() == KXMLQLCEFXStartOffset)
8 ✔
1065
        {
1066
            /* StartOffset */
UNCOV
1067
            setStartOffset(root.readElementText().toInt());
×
1068
        }
1069
        else if (root.name() == KXMLQLCEFXIsRelative)
8 ✔
1070
        {
1071
            /* IsRelative */
UNCOV
1072
            setIsRelative(root.readElementText().toInt() != 0);
×
1073
        }
1074
        else if (root.name() == KXMLQLCEFXDimmerControl)
8 ✔
1075
        {
1076
            /* DimmerControl */
UNCOV
1077
            setDimmerControlEnabled(root.readElementText().toInt() != 0);
×
1078
        }
1079
        else if (root.name() == QStringLiteral("DimmerWidth") ||
24 ✔
1080
                 root.name() == QStringLiteral("DimmerAttack") ||
24 ✔
1081
                 root.name() == QStringLiteral("DimmerDecay") ||
24 ✔
1082
                 root.name() == QStringLiteral("DimmerShape") ||
40 ✔
1083
                 root.name() == QStringLiteral("DimmerOrder"))
16 ✔
1084
        {
1085
            /* LEGACY: dimmer sub-parameters that no longer exist. Skip silently. */
UNCOV
1086
            root.skipCurrentElement();
×
1087
        }
1088
        else if (root.name() == KXMLQLCEFXAxis)
8 ✔
1089
        {
1090
            /* Axes */
1091
            loadXMLAxis(root);
6 ✔
1092
        }
1093
        else
1094
        {
1095
            qWarning() << "Unknown EFX tag:" << root.name();
2 ✔
1096
            root.skipCurrentElement();
2 ✔
1097
        }
1098
    }
1099

1100
    return true;
3 ✔
1101
}
1102

1103
bool EFX::loadXMLAxis(QXmlStreamReader &root)
10 ✔
1104
{
1105
    int frequency = 0;
10 ✔
1106
    int offset = 0;
10 ✔
1107
    int phase = 0;
10 ✔
1108
    QString axis;
10 ✔
1109

1110
    if (root.name() != KXMLQLCEFXAxis)
10 ✔
1111
    {
1112
        qWarning() << "EFX axis node not found!";
1 ✔
1113
        return false;
1 ✔
1114
    }
1115

1116
    /* Get the axis name */
1117
    axis = root.attributes().value(KXMLQLCFunctionName).toString();
18 ✔
1118

1119
    /* Load axis contents */
1120
    while (root.readNextStartElement())
37 ✔
1121
    {
1122
        if (root.name() == KXMLQLCEFXOffset)
28 ✔
1123
            offset = root.readElementText().toInt();
9 ✔
1124
        else if (root.name() == KXMLQLCEFXFrequency)
19 ✔
1125
            frequency = root.readElementText().toInt();
9 ✔
1126
        else if (root.name() == KXMLQLCEFXPhase)
10 ✔
1127
            phase = root.readElementText().toInt();
9 ✔
1128
        else
1129
        {
1130
            qWarning() << "Unknown EFX axis tag:" << root.name();
1 ✔
1131
            root.skipCurrentElement();
1 ✔
1132
        }
1133
    }
1134

1135
    if (axis == KXMLQLCEFXY)
9 ✔
1136
    {
1137
        setYOffset(offset);
4 ✔
1138
        setYFrequency(frequency);
4 ✔
1139
        setYPhase(phase);
4 ✔
1140
        return true;
4 ✔
1141
    }
1142
    else if (axis == KXMLQLCEFXX)
5 ✔
1143
    {
1144
        setXOffset(offset);
4 ✔
1145
        setXFrequency(frequency);
4 ✔
1146
        setXPhase(phase);
4 ✔
1147
        return true;
4 ✔
1148
    }
1149
    else
1150
    {
1151
        qWarning() << "Unknown EFX axis:" << axis;
1 ✔
1152
        return false;
1 ✔
1153
    }
1154
}
10 ✔
1155

1156
void EFX::postLoad()
1 ✔
1157
{
1158
    // Map legacy bus speeds to fixed speed values
1159
    if (m_legacyFadeBus != Bus::invalid())
1 ✔
1160
    {
1161
        quint32 value = Bus::instance()->value(m_legacyFadeBus);
1 ✔
1162
        setFadeInSpeed((value / MasterTimer::frequency()) * 1000);
1 ✔
1163
        setFadeOutSpeed((value / MasterTimer::frequency()) * 1000);
1 ✔
1164
    }
1165

1166
    if (m_legacyHoldBus != Bus::invalid())
1 ✔
1167
    {
1168
        quint32 value = Bus::instance()->value(m_legacyHoldBus);
1 ✔
1169
        setDuration((value / MasterTimer::frequency()) * 1000);
1 ✔
1170
    }
1171
}
1 ✔
1172

1173
/*****************************************************************************
1174
 * Running
1175
 *****************************************************************************/
1176
QSharedPointer<GenericFader> EFX::getFader(QList<Universe *> universes, quint32 universeID)
10 ✔
1177
{
1178
    // get the universe Fader first. If doesn't exist, create it
1179
    QSharedPointer<GenericFader> fader = m_fadersMap.value(universeID, QSharedPointer<GenericFader>());
10 ✔
1180
    if (fader.isNull())
10 ✔
1181
    {
1182
        fader = universes[universeID]->requestFader(isRelative() ? Universe::Override : Universe::Auto);
1 ✔
1183
        fader->adjustIntensity(getAttributeValue(Intensity));
1 ✔
1184
        fader->setBlendMode(blendMode());
1 ✔
1185
        fader->setName(name());
1 ✔
1186
        fader->setParentFunctionID(id());
1 ✔
1187
        fader->setHandleSecondary(true);
1 ✔
1188
        m_fadersMap[universeID] = fader;
1 ✔
1189
    }
1190

1191
    return fader;
10 ✔
1192
}
×
1193

1194
void EFX::preRun(MasterTimer* timer)
6 ✔
1195
{
1196
    int serialNumber = 0;
6 ✔
1197

1198
    QMutexLocker locker(&m_fixturesMutex);
6 ✔
1199
    QListIterator <EFXFixture*> it(m_fixtures);
6 ✔
1200
    while (it.hasNext() == true)
13 ✔
1201
    {
1202
        EFXFixture *ef = it.next();
7 ✔
1203
        Q_ASSERT(ef != NULL);
7 ✔
1204
        ef->setSerialNumber(serialNumber++);
7 ✔
1205
    }
1206

1207
    locker.unlock();
6 ✔
1208

1209
    Function::preRun(timer);
6 ✔
1210
}
6 ✔
1211

1212
void EFX::write(MasterTimer *timer, QList<Universe*> universes)
10 ✔
1213
{
1214
    Q_UNUSED(timer);
1215

1216
    if (isPaused())
10 ✔
UNCOV
1217
        return;
×
1218

1219
    int done = 0;
10 ✔
1220
    int count = 0;
10 ✔
1221

1222
    {
1223
        QMutexLocker locker(&m_fixturesMutex);
10 ✔
1224
        count = m_fixtures.count();
10 ✔
1225

1226
        QListIterator <EFXFixture*> it(m_fixtures);
10 ✔
1227
        while (it.hasNext() == true)
30 ✔
1228
        {
1229
            EFXFixture *ef = it.next();
20 ✔
1230
            if (ef->isDone() == false)
20 ✔
1231
            {
1232
                // an entry whose fixture doesn't exist (e.g. it couldn't be
1233
                // loaded) has no universe
1234
                if (ef->universe() >= quint32(universes.count()))
20 ✔
1235
                    continue;
10 ✔
1236

1237
                QSharedPointer<GenericFader> fader = getFader(universes, ef->universe());
10 ✔
1238
                ef->nextStep(universes, fader);
10 ✔
1239
            }
10 ✔
1240
            else
1241
            {
UNCOV
1242
                done++;
×
1243
            }
1244
        }
1245
    }
10 ✔
1246

1247
    incrementElapsed();
10 ✔
1248

1249
    /* Check for stop condition */
1250
    if (done == count)
10 ✔
UNCOV
1251
        stop(FunctionParent::master());
×
1252
}
1253

1254
void EFX::postRun(MasterTimer *timer, QList<Universe *> universes)
6 ✔
1255
{
1256
    /* Reset all fixtures */
1257
    {
1258
        QMutexLocker locker(&m_fixturesMutex);
6 ✔
1259
        QListIterator <EFXFixture*> it(m_fixtures);
6 ✔
1260
        while (it.hasNext() == true)
13 ✔
1261
        {
1262
            EFXFixture* ef(it.next());
7 ✔
1263

1264
            /* Run the EFX's stop scene for Loop & PingPong modes */
1265
            if (runOrder() != SingleShot)
7 ✔
1266
                ef->stop();
6 ✔
1267
            ef->reset();
7 ✔
1268
        }
1269
    }
6 ✔
1270

1271
    dismissAllFaders();
6 ✔
1272

1273
    Function::postRun(timer, universes);
6 ✔
1274
}
6 ✔
1275

1276
/*****************************************************************************
1277
 * Intensity
1278
 *****************************************************************************/
1279

1280
int EFX::adjustAttribute(qreal fraction, int attributeId)
165 ✔
1281
{
1282
    int attrIndex = Function::adjustAttribute(fraction, attributeId);
165 ✔
1283

1284
    switch (attrIndex)
165 ✔
1285
    {
1286
        case Intensity:
2 ✔
1287
        {
1288
            foreach (QSharedPointer<GenericFader> fader, m_fadersMap)
2 ✔
1289
            {
UNCOV
1290
                if (!fader.isNull())
×
UNCOV
1291
                    fader->adjustIntensity(getAttributeValue(Function::Intensity));
×
1292
            }
2 ✔
1293
        }
1294
        break;
2 ✔
1295

1296
        case Height:
102 ✔
1297
        case Width:
1298
        case XOffset:
1299
        case YOffset:
1300
        case Rotation:
1301
            updateRotationCache();
102 ✔
1302
        break;
102 ✔
1303
    }
1304

1305
    return attrIndex;
165 ✔
1306
}
1307

1308
/*************************************************************************
1309
 * Blend mode
1310
 *************************************************************************/
1311

1312
void EFX::setBlendMode(Universe::BlendMode mode)
1 ✔
1313
{
1314
    if (mode == blendMode())
1 ✔
1315
        return;
1 ✔
1316

UNCOV
1317
    foreach (QSharedPointer<GenericFader> fader, m_fadersMap)
×
1318
    {
UNCOV
1319
        if (!fader.isNull())
×
UNCOV
1320
            fader->setBlendMode(mode);
×
UNCOV
1321
    }
×
1322

UNCOV
1323
    Function::setBlendMode(mode);
×
1324
}
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