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

mcallegari / qlcplus / 7252848206

18 Dec 2023 07:26PM UTC coverage: 32.067% (+0.001%) from 32.066%
7252848206

push

github

mcallegari
Code style review #1427

199 of 628 new or added lines in 101 files covered. (31.69%)

8 existing lines in 2 files now uncovered.

15169 of 47304 relevant lines covered (32.07%)

23733.74 hits per line

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

0.0
/ui/src/rgbmatrixeditor.cpp
1
/*
2
  Q Light Controller
3
  rgbmatrixeditor.cpp
4

5
  Copyright (c) Heikki Junnila
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 <QGraphicsEllipseItem>
21
#include <QGraphicsRectItem>
22
#include <QGraphicsEffect>
23
#include <QGraphicsScene>
24
#include <QGraphicsView>
25
#include <QColorDialog>
26
#include <QFileDialog>
27
#include <QFontDialog>
28
#include <QGradient>
29
#include <QSettings>
30
#include <QComboBox>
31
#include <QSpinBox>
32
#include <QLabel>
33
#include <QTimer>
34
#include <QDebug>
35
#include <QMutex>
36

37
#include "fixtureselection.h"
38
#include "speeddialwidget.h"
39
#include "rgbmatrixeditor.h"
40
#include "qlcfixturehead.h"
41
#include "qlcmacros.h"
42
#include "rgbimage.h"
43
#include "sequence.h"
44
#include "rgbitem.h"
45
#include "rgbtext.h"
46
#include "scene.h"
47

48
#define SETTINGS_GEOMETRY "rgbmatrixeditor/geometry"
49
#define RECT_SIZE 30
50
#define RECT_PADDING 0
51
#define ITEM_SIZE 28
52
#define ITEM_PADDING 2
53

54
/****************************************************************************
55
 * Initialization
56
 ****************************************************************************/
57

58
RGBMatrixEditor::RGBMatrixEditor(QWidget* parent, RGBMatrix* mtx, Doc* doc)
×
59
    : QWidget(parent)
60
    , m_doc(doc)
61
    , m_matrix(mtx)
62
    , m_previewHandler(new RGBMatrixStep())
×
63
    , m_speedDials(NULL)
64
    , m_scene(new QGraphicsScene(this))
×
65
    , m_previewTimer(new QTimer(this))
×
66
    , m_previewIterator(0)
×
67
{
68
    Q_ASSERT(doc != NULL);
×
69
    Q_ASSERT(mtx != NULL);
×
70

71
    setupUi(this);
×
72

73
    // Set a nice gradient backdrop
74
    m_scene->setBackgroundBrush(Qt::darkGray);
×
75
    QLinearGradient gradient(200, 200, 200, 2000);
×
76
    gradient.setSpread(QGradient::ReflectSpread);
×
77
    m_scene->setBackgroundBrush(gradient);
×
78

79
    connect(m_previewTimer, SIGNAL(timeout()), this, SLOT(slotPreviewTimeout()));
×
80
    connect(m_doc, SIGNAL(modeChanged(Doc::Mode)), this, SLOT(slotModeChanged(Doc::Mode)));
×
81
    connect(m_doc, SIGNAL(fixtureGroupAdded(quint32)), this, SLOT(slotFixtureGroupAdded()));
×
82
    connect(m_doc, SIGNAL(fixtureGroupRemoved(quint32)), this, SLOT(slotFixtureGroupRemoved()));
×
83
    connect(m_doc, SIGNAL(fixtureGroupChanged(quint32)), this, SLOT(slotFixtureGroupChanged(quint32)));
×
84

85
    init();
×
86

87
    slotModeChanged(m_doc->mode());
×
88

89
    // Set focus to the editor
90
    m_nameEdit->setFocus();
×
91
}
×
92

93
RGBMatrixEditor::~RGBMatrixEditor()
×
94
{
95
    m_previewTimer->stop();
×
96

97
    if (m_testButton->isChecked() == true)
×
98
        m_matrix->stopAndWait();
×
99

100
    delete m_previewHandler;
×
101
}
×
102

103
void RGBMatrixEditor::stopTest()
×
104
{
105
    if (m_testButton->isChecked() == true)
×
106
        m_testButton->click();
×
107
}
×
108

109
void RGBMatrixEditor::slotFunctionManagerActive(bool active)
×
110
{
111
    if (active == true)
×
112
    {
113
        if (m_speedDials == NULL)
×
114
            updateSpeedDials();
×
115
    }
116
    else
117
    {
118
        if (m_speedDials != NULL)
×
119
            m_speedDials->deleteLater();
×
120
        m_speedDials = NULL;
×
121
    }
122
}
×
123

124
void RGBMatrixEditor::init()
×
125
{
126
    /* Name */
127
    m_nameEdit->setText(m_matrix->name());
×
128
    m_nameEdit->setSelection(0, m_matrix->name().length());
×
129

130
    /* Running order */
131
    switch (m_matrix->runOrder())
×
132
    {
133
        default:
×
134
        case Function::Loop:
135
            m_loop->setChecked(true);
×
136
        break;
×
137
        case Function::PingPong:
×
138
            m_pingPong->setChecked(true);
×
139
        break;
×
140
        case Function::SingleShot:
×
141
            m_singleShot->setChecked(true);
×
142
        break;
×
143
    }
144

145
    /* Running direction */
146
    switch (m_matrix->direction())
×
147
    {
148
        default:
×
149
        case Function::Forward:
150
            m_forward->setChecked(true);
×
151
        break;
×
152
        case Function::Backward:
×
153
            m_backward->setChecked(true);
×
154
        break;
×
155
    }
156

157

158
    /* Blend mode */
159
    m_blendModeCombo->setCurrentIndex(m_matrix->blendMode());
×
160

161
    /* Color mode */
162
    m_controlModeCombo->setCurrentIndex(m_matrix->controlMode());
×
163

164
    /* Dimmer control */
165
    if (m_matrix->dimmerControl())
×
166
        m_dimmerControlCb->setChecked(m_matrix->dimmerControl());
×
167
    else
168
        m_intensityGroup->hide();
×
169

170
    fillPatternCombo();
×
171
    fillFixtureGroupCombo();
×
172
    fillAnimationCombo();
×
173
    fillImageAnimationCombo();
×
174

175
    QPixmap pm(50, 26);
×
176
    pm.fill(m_matrix->startColor());
×
177
    m_startColorButton->setIcon(QIcon(pm));
×
178

179
    if (m_matrix->endColor().isValid())
×
180
        pm.fill(m_matrix->endColor());
×
181
    else
182
        pm.fill(Qt::transparent);
×
183
    m_endColorButton->setIcon(QIcon(pm));
×
184

185
    updateExtraOptions();
×
186
    updateSpeedDials();
×
187

188
    connect(m_nameEdit, SIGNAL(textEdited(const QString&)),
×
189
            this, SLOT(slotNameEdited(const QString&)));
190
    connect(m_speedDialButton, SIGNAL(toggled(bool)),
×
191
            this, SLOT(slotSpeedDialToggle(bool)));
192
    connect(m_saveToSequenceButton, SIGNAL(clicked()),
×
193
            this, SLOT(slotSaveToSequenceClicked()));
194
    connect(m_shapeButton, SIGNAL(toggled(bool)),
×
195
            this, SLOT(slotShapeToggle(bool)));
196
    connect(m_patternCombo, SIGNAL(activated(const QString&)),
×
197
            this, SLOT(slotPatternActivated(const QString&)));
198
    connect(m_fixtureGroupCombo, SIGNAL(activated(int)),
×
199
            this, SLOT(slotFixtureGroupActivated(int)));
200
    connect(m_blendModeCombo, SIGNAL(activated(int)),
×
201
            this, SLOT(slotBlendModeChanged(int)));
202
    connect(m_controlModeCombo, SIGNAL(activated(int)),
×
203
            this, SLOT(slotControlModeChanged(int)));
204
    connect(m_startColorButton, SIGNAL(clicked()),
×
205
            this, SLOT(slotStartColorButtonClicked()));
206
    connect(m_endColorButton, SIGNAL(clicked()),
×
207
            this, SLOT(slotEndColorButtonClicked()));
208
    connect(m_resetEndColorButton, SIGNAL(clicked()),
×
209
            this, SLOT(slotResetEndColorButtonClicked()));
210
    connect(m_textEdit, SIGNAL(textEdited(const QString&)),
×
211
            this, SLOT(slotTextEdited(const QString&)));
212
    connect(m_fontButton, SIGNAL(clicked()),
×
213
            this, SLOT(slotFontButtonClicked()));
214
    connect(m_animationCombo, SIGNAL(activated(const QString&)),
×
215
            this, SLOT(slotAnimationActivated(const QString&)));
216
    connect(m_imageEdit, SIGNAL(editingFinished()),
×
217
            this, SLOT(slotImageEdited()));
218
    connect(m_imageButton, SIGNAL(clicked()),
×
219
            this, SLOT(slotImageButtonClicked()));
220
    connect(m_imageAnimationCombo, SIGNAL(activated(const QString&)),
×
221
            this, SLOT(slotImageAnimationActivated(const QString&)));
222
    connect(m_xOffsetSpin, SIGNAL(valueChanged(int)),
×
223
            this, SLOT(slotOffsetSpinChanged()));
224
    connect(m_yOffsetSpin, SIGNAL(valueChanged(int)),
×
225
            this, SLOT(slotOffsetSpinChanged()));
226

227
    connect(m_loop, SIGNAL(clicked()), this, SLOT(slotLoopClicked()));
×
228
    connect(m_pingPong, SIGNAL(clicked()), this, SLOT(slotPingPongClicked()));
×
229
    connect(m_singleShot, SIGNAL(clicked()), this, SLOT(slotSingleShotClicked()));
×
230
    connect(m_forward, SIGNAL(clicked()), this, SLOT(slotForwardClicked()));
×
231
    connect(m_backward, SIGNAL(clicked()), this, SLOT(slotBackwardClicked()));
×
232
    connect(m_dimmerControlCb, SIGNAL(clicked()), this, SLOT(slotDimmerControlClicked()));
×
233

234
    // Test slots
235
    connect(m_testButton, SIGNAL(clicked(bool)),
×
236
            this, SLOT(slotTestClicked()));
237

238
    m_preview->setScene(m_scene);
×
239
    if (createPreviewItems() == true)
×
240
        m_previewTimer->start(MasterTimer::tick());
×
241
}
×
242

243
void RGBMatrixEditor::updateSpeedDials()
×
244
{
245
    if (m_speedDialButton->isChecked() == false)
×
246
        return;
×
247

248
    if (m_speedDials != NULL)
×
249
        return;
×
250

251
    m_speedDials = new SpeedDialWidget(this);
×
252
    m_speedDials->setAttribute(Qt::WA_DeleteOnClose);
×
253
    m_speedDials->setWindowTitle(m_matrix->name());
×
254
    m_speedDials->show();
×
255
    m_speedDials->setFadeInSpeed(m_matrix->fadeInSpeed());
×
256
    m_speedDials->setFadeOutSpeed(m_matrix->fadeOutSpeed());
×
257
    if ((int)m_matrix->duration() < 0)
×
258
        m_speedDials->setDuration(m_matrix->duration());
×
259
    else
260
        m_speedDials->setDuration(m_matrix->duration() - m_matrix->fadeInSpeed());
×
261
    connect(m_speedDials, SIGNAL(fadeInChanged(int)), this, SLOT(slotFadeInChanged(int)));
×
262
    connect(m_speedDials, SIGNAL(fadeOutChanged(int)), this, SLOT(slotFadeOutChanged(int)));
×
263
    connect(m_speedDials, SIGNAL(holdChanged(int)), this, SLOT(slotHoldChanged(int)));
×
264
    connect(m_speedDials, SIGNAL(holdTapped()), this, SLOT(slotDurationTapped()));
×
265
    connect(m_speedDials, SIGNAL(destroyed(QObject*)), this, SLOT(slotDialDestroyed(QObject*)));
×
266
}
267

268
void RGBMatrixEditor::fillPatternCombo()
×
269
{
270
    m_patternCombo->addItems(RGBAlgorithm::algorithms(m_doc));
×
271
    if (m_matrix->algorithm() != NULL)
×
272
    {
273
        int index = m_patternCombo->findText(m_matrix->algorithm()->name());
×
274
        if (index >= 0)
×
275
            m_patternCombo->setCurrentIndex(index);
×
276
    }
277
}
×
278

279
void RGBMatrixEditor::fillFixtureGroupCombo()
×
280
{
281
    m_fixtureGroupCombo->clear();
×
282
    m_fixtureGroupCombo->addItem(tr("None"));
×
283

284
    QListIterator <FixtureGroup*> it(m_doc->fixtureGroups());
×
285
    while (it.hasNext() == true)
×
286
    {
287
        FixtureGroup* grp(it.next());
×
288
        Q_ASSERT(grp != NULL);
×
289
        m_fixtureGroupCombo->addItem(grp->name(), grp->id());
×
290
        if (m_matrix->fixtureGroup() == grp->id())
×
291
            m_fixtureGroupCombo->setCurrentIndex(m_fixtureGroupCombo->count() - 1);
×
292
    }
293
}
×
294

295
void RGBMatrixEditor::fillAnimationCombo()
×
296
{
297
    m_animationCombo->addItems(RGBText::animationStyles());
×
298
}
×
299

300
void RGBMatrixEditor::fillImageAnimationCombo()
×
301
{
302
    m_imageAnimationCombo->addItems(RGBImage::animationStyles());
×
303
}
×
304

305
void RGBMatrixEditor::updateExtraOptions()
×
306
{
307

308
    resetProperties(m_propertiesLayout->layout());
×
309
    m_propertiesGroup->hide();
×
310

311
    if (m_matrix->algorithm() == NULL ||
×
312
        m_matrix->algorithm()->type() == RGBAlgorithm::Script ||
×
313
        m_matrix->algorithm()->type() == RGBAlgorithm::Audio)
×
314
    {
315
        m_textGroup->hide();
×
316
        m_imageGroup->hide();
×
317
        m_offsetGroup->hide();
×
318

319
        if (m_matrix->algorithm() != NULL && m_matrix->algorithm()->type() == RGBAlgorithm::Script)
×
320
        {
321
            RGBScript *script = static_cast<RGBScript*> (m_matrix->algorithm());
×
322
            displayProperties(script);
×
323
        }
324
    }
325
    else if (m_matrix->algorithm()->type() == RGBAlgorithm::Plain)
×
326
    {
327
        m_textGroup->hide();
×
328
        m_imageGroup->hide();
×
329
        m_offsetGroup->hide();
×
330
    }
331
    else if (m_matrix->algorithm()->type() == RGBAlgorithm::Image)
×
332
    {
333
        m_textGroup->hide();
×
334
        m_imageGroup->show();
×
335
        m_offsetGroup->show();
×
336

337
        RGBImage* image = static_cast<RGBImage*> (m_matrix->algorithm());
×
338
        Q_ASSERT(image != NULL);
×
339
        m_imageEdit->setText(image->filename());
×
340

341
        int index = m_imageAnimationCombo->findText(RGBImage::animationStyleToString(image->animationStyle()));
×
342
        if (index != -1)
×
343
            m_imageAnimationCombo->setCurrentIndex(index);
×
344

345
        m_xOffsetSpin->setValue(image->xOffset());
×
346
        m_yOffsetSpin->setValue(image->yOffset());
×
347

348
    }
349
    else if (m_matrix->algorithm()->type() == RGBAlgorithm::Text)
×
350
    {
351
        m_textGroup->show();
×
352
        m_offsetGroup->show();
×
353
        m_imageGroup->hide();
×
354

355
        RGBText* text = static_cast<RGBText*> (m_matrix->algorithm());
×
356
        Q_ASSERT(text != NULL);
×
357
        m_textEdit->setText(text->text());
×
358

359
        int index = m_animationCombo->findText(RGBText::animationStyleToString(text->animationStyle()));
×
360
        if (index != -1)
×
361
            m_animationCombo->setCurrentIndex(index);
×
362

363
        m_xOffsetSpin->setValue(text->xOffset());
×
364
        m_yOffsetSpin->setValue(text->yOffset());
×
365
    }
366

367
    if (m_matrix->algorithm() != NULL)
×
368
    {
369
        int accColors = m_matrix->algorithm()->acceptColors();
×
370
        if (accColors == 0)
×
371
        {
372
            m_startColorButton->hide();
×
373
            m_endColorButton->hide();
×
374
            m_resetEndColorButton->hide();
×
375
            m_blendModeLabel->hide();
×
376
            m_blendModeCombo->hide();
×
377
        }
378
        else
379
        {
380
            m_startColorButton->show();
×
381

382
            if (accColors == 1 || m_blendModeCombo->currentIndex() == Universe::MaskBlend)
×
383
            {
384
                m_endColorButton->hide();
×
385
                m_resetEndColorButton->hide();
×
386
            }
387
            else // accColors > 1
388
            {
389
                m_endColorButton->show();
×
390
                m_resetEndColorButton->show();
×
391
            }
392
            m_blendModeLabel->show();
×
393
            m_blendModeCombo->show();
×
394
        }
395
    }
396
}
×
397

398
void RGBMatrixEditor::updateColors()
×
399
{
400
    if (m_matrix->algorithm() != NULL)
×
401
    {
402
        int accColors = m_matrix->algorithm()->acceptColors();
×
403
        if (accColors > 0)
×
404
        {
405
            if (m_matrix->blendMode() == Universe::MaskBlend)
×
406
            {
407
                m_matrix->setStartColor(Qt::white);
×
408
                m_matrix->setEndColor(QColor());
×
409

410
                m_previewHandler->calculateColorDelta(m_matrix->startColor(), m_matrix->endColor());
×
411

412
                QPixmap pm(50, 26);
×
413
                pm.fill(Qt::white);
×
414
                m_startColorButton->setIcon(QIcon(pm));
×
415
            }
416
            else if (m_controlModeCombo->currentIndex() != RGBMatrix::ControlModeRgb)
×
417
            {
418
                // Convert startColor to grayscale for single color modes
419
                uchar gray = qGray(m_matrix->startColor().rgb());
×
420
                QPixmap pm(50, 26);
×
421
                pm.fill(QColor(gray, gray, gray));
×
422
                m_startColorButton->setIcon(QIcon(pm));
×
423
                m_matrix->setStartColor(QColor(gray, gray, gray));
×
424

425
                if (accColors > 1)
×
426
                {
427
                    // Convert endColor to grayscale for single color modes
428
                    gray = qGray(m_matrix->endColor().rgb());
×
429
                    m_matrix->setEndColor(QColor(gray, gray, gray));
×
430

431
                    if (m_matrix->endColor() == QColor())
×
432
                        pm.fill(Qt::transparent);
×
433
                    else
434
                        pm.fill(QColor(gray, gray, gray));
×
435

436
                    m_endColorButton->setIcon(QIcon(pm));
×
437
                }
438
                m_previewHandler->calculateColorDelta(m_matrix->startColor(), m_matrix->endColor());
×
439
            }
440
            else 
441
            {
442
                QPixmap pm(50, 26);
×
443
                pm.fill(m_matrix->startColor());
×
444
                m_startColorButton->setIcon(QIcon(pm));
×
445

446
                if (accColors > 1)
×
447
                {
448
                    m_previewHandler->calculateColorDelta(m_matrix->startColor(), m_matrix->endColor());
×
449

450
                    if (m_matrix->endColor() == QColor())
×
451
                        pm.fill(Qt::transparent);
×
452
                    else
453
                        pm.fill(m_matrix->endColor());
×
454

455
                    m_endColorButton->setIcon(QIcon(pm));
×
456
                }
457
            }
458
        }
459
    }
460
}
×
461

462
/**
463
 * Helper function. Deletes all child widgets of the given layout @a item.
464
 */
465
void RGBMatrixEditor::resetProperties(QLayoutItem *item)
×
466
{
467
    if (item->layout()) 
×
468
    {
469
        // Process all child items recursively.
470
        for (int i = item->layout()->count() - 1; i >= 0; i--)
×
471
            resetProperties(item->layout()->itemAt(i));
×
472
    }
473
    delete item->widget();
×
474
}
×
475

476
void RGBMatrixEditor::displayProperties(RGBScript *script)
×
477
{
478
    if (script == NULL)
×
479
        return;
×
480

481
    int gridRowIdx = 0;
×
482

483
    QList<RGBScriptProperty> properties = script->properties();
×
484
    if (properties.count() > 0)
×
485
        m_propertiesGroup->show();
×
486

NEW
487
    foreach (RGBScriptProperty prop, properties)
×
488
    {
489
        switch(prop.m_type)
×
490
        {
491
            case RGBScriptProperty::List:
×
492
            {
493
                QLabel *propLabel = new QLabel(prop.m_displayName);
×
494
                m_propertiesLayout->addWidget(propLabel, gridRowIdx, 0);
×
495
                QComboBox *propCombo = new QComboBox(this);
×
496
                propCombo->addItems(prop.m_listValues);
×
497
                propCombo->setProperty("pName", prop.m_name);
×
498
                connect(propCombo, SIGNAL(currentIndexChanged(QString)),
×
499
                        this, SLOT(slotPropertyComboChanged(QString)));
500
                m_propertiesLayout->addWidget(propCombo, gridRowIdx, 1);
×
501
                if (m_matrix != NULL)
×
502
                {
503
                    QString pValue = m_matrix->property(prop.m_name);
×
504
                    if (!pValue.isEmpty())
×
505
                    {
506
                        propCombo->setCurrentText(pValue);
×
507
                    }
508
                    else
509
                    {
510
                        pValue = script->property(prop.m_name);
×
511
                        if (!pValue.isEmpty())
×
512
                        {
513
                            propCombo->setCurrentText(pValue);
×
514
                        }
515
                    }
516
                }
517
                gridRowIdx++;
×
518
            }
519
            break;
×
520
            case RGBScriptProperty::Range:
×
521
            {
522
                QLabel *propLabel = new QLabel(prop.m_displayName);
×
523
                m_propertiesLayout->addWidget(propLabel, gridRowIdx, 0);
×
524
                QSpinBox *propSpin = new QSpinBox(this);
×
525
                propSpin->setRange(prop.m_rangeMinValue, prop.m_rangeMaxValue);
×
526
                propSpin->setProperty("pName", prop.m_name);
×
527
                connect(propSpin, SIGNAL(valueChanged(int)),
×
528
                        this, SLOT(slotPropertySpinChanged(int)));
529
                m_propertiesLayout->addWidget(propSpin, gridRowIdx, 1);
×
530
                if (m_matrix != NULL)
×
531
                {
532
                    QString pValue = m_matrix->property(prop.m_name);
×
533
                    if (!pValue.isEmpty())
×
534
                        propSpin->setValue(pValue.toInt());
×
535
                    else
536
                    {
537
                        pValue = script->property(prop.m_name);
×
538
                        if (!pValue.isEmpty())
×
539
                            propSpin->setValue(pValue.toInt());
×
540
                    }
541
                }
542
                gridRowIdx++;
×
543
            }
544
            break;
×
545
            default:
×
546
                qWarning() << "Type" << prop.m_type << "not handled yet";
×
547
            break;
×
548
        }
549
    }
550
}
551

552
bool RGBMatrixEditor::createPreviewItems()
×
553
{
554
    m_previewHash.clear();
×
555
    m_scene->clear();
×
556

557
    FixtureGroup* grp = m_doc->fixtureGroup(m_matrix->fixtureGroup());
×
558
    if (grp == NULL)
×
559
    {
560
        QGraphicsTextItem* text = new QGraphicsTextItem(tr("No fixture group to control"));
×
561
        text->setDefaultTextColor(Qt::white);
×
562
        m_scene->addItem(text);
×
563
        return false;
×
564
    }
565

566
    m_previewHandler->initializeDirection(m_matrix->direction(), m_matrix->startColor(),
×
567
                                          m_matrix->endColor(), m_matrix->stepsCount());
×
568

569
    m_matrix->previewMap(m_previewHandler->currentStepIndex(), m_previewHandler);
×
570

571
    if (m_previewHandler->m_map.isEmpty())
×
572
        return false;
×
573

574
    for (int x = 0; x < grp->size().width(); x++)
×
575
    {
576
        for (int y = 0; y < grp->size().height(); y++)
×
577
        {
578
            QLCPoint pt(x, y);
×
579

580
            if (grp->headsMap().contains(pt) == true)
×
581
            {
582
                RGBItem *item;
583
                if (m_shapeButton->isChecked() == false)
×
584
                {
585
                    QGraphicsEllipseItem* circleItem = new QGraphicsEllipseItem();
×
586
                    circleItem->setRect(
×
587
                            x * RECT_SIZE + RECT_PADDING + ITEM_PADDING,
×
588
                            y * RECT_SIZE + RECT_PADDING + ITEM_PADDING,
×
589
                            ITEM_SIZE - (2 * ITEM_PADDING),
590
                            ITEM_SIZE - (2 * ITEM_PADDING));
591
                    item = new RGBItem(circleItem);
×
592
                }
593
                else
594
                {
595
                    QGraphicsRectItem *rectItem = new QGraphicsRectItem();
×
596
                    rectItem->setRect(
×
597
                            x * RECT_SIZE + RECT_PADDING + ITEM_PADDING,
×
598
                            y * RECT_SIZE + RECT_PADDING + ITEM_PADDING,
×
599
                            ITEM_SIZE - (2 * ITEM_PADDING),
600
                            ITEM_SIZE - (2 * ITEM_PADDING));
601
                    item = new RGBItem(rectItem);
×
602
                }
603

604
                item->setColor(m_previewHandler->m_map[y][x]);
×
605
                item->draw(0, 0);
×
606
                m_scene->addItem(item->graphicsItem());
×
607
                m_previewHash[pt] = item;
×
608
            }
609
        }
610
    }
611
    return true;
×
612
}
613

614
void RGBMatrixEditor::slotPreviewTimeout()
×
615
{
616
    if (m_matrix->duration() <= 0)
×
617
        return;
×
618

619
    m_previewIterator += MasterTimer::tick();
×
620
    uint elapsed = 0;
×
621
    while (m_previewIterator >= MAX(m_matrix->duration(), MasterTimer::tick()))
×
622
    {
623
        m_previewHandler->checkNextStep(m_matrix->runOrder(), m_matrix->startColor(),
×
624
                                        m_matrix->endColor(), m_matrix->stepsCount());
×
625

626
        m_matrix->previewMap(m_previewHandler->currentStepIndex(), m_previewHandler);
×
627

628
        m_previewIterator -= MAX(m_matrix->duration(), MasterTimer::tick());
×
629
        elapsed += MAX(m_matrix->duration(), MasterTimer::tick());
×
630
    }
631
    for (int y = 0; y < m_previewHandler->m_map.size(); y++)
×
632
    {
633
        for (int x = 0; x < m_previewHandler->m_map[y].size(); x++)
×
634
        {
635
            QLCPoint pt(x, y);
×
636
            if (m_previewHash.contains(pt) == true)
×
637
            {
638
                RGBItem* shape = m_previewHash[pt];
×
639
                if (shape->color() != QColor(m_previewHandler->m_map[y][x]).rgb())
×
640
                    shape->setColor(m_previewHandler->m_map[y][x]);
×
641

642
                if (shape->color() == QColor(Qt::black).rgb())
×
643
                    shape->draw(elapsed, m_matrix->fadeOutSpeed());
×
644
                else
645
                    shape->draw(elapsed, m_matrix->fadeInSpeed());
×
646
            }
647
        }
648
    }
649
}
650

651
void RGBMatrixEditor::slotNameEdited(const QString& text)
×
652
{
653
    m_matrix->setName(text);
×
654
    if (m_speedDials != NULL)
×
655
        m_speedDials->setWindowTitle(text);
×
656
}
×
657

658
void RGBMatrixEditor::slotSpeedDialToggle(bool state)
×
659
{
660
    if (state == true)
×
661
        updateSpeedDials();
×
662
    else
663
    {
664
        if (m_speedDials != NULL)
×
665
            m_speedDials->deleteLater();
×
666
        m_speedDials = NULL;
×
667
    }
668
}
×
669

670
void RGBMatrixEditor::slotDialDestroyed(QObject *)
×
671
{
672
    m_speedDialButton->setChecked(false);
×
673
}
×
674

675
void RGBMatrixEditor::slotPatternActivated(const QString& text)
×
676
{
677
    RGBAlgorithm* algo = RGBAlgorithm::algorithm(m_doc, text);
×
678
    if (algo != NULL)
×
679
        algo->setColors(m_matrix->startColor(), m_matrix->endColor());
×
680
    m_matrix->setAlgorithm(algo);
×
681
    m_previewHandler->calculateColorDelta(m_matrix->startColor(), m_matrix->endColor());
×
682
    updateExtraOptions();
×
683

684
    slotRestartTest();
×
685
}
×
686

687
void RGBMatrixEditor::slotFixtureGroupActivated(int index)
×
688
{
689
    QVariant var = m_fixtureGroupCombo->itemData(index);
×
690
    if (var.isValid() == true)
×
691
    {
692
        m_matrix->setFixtureGroup(var.toUInt());
×
693
        slotRestartTest();
×
694
    }
695
    else
696
    {
697
        m_matrix->setFixtureGroup(FixtureGroup::invalidId());
×
698
        m_previewTimer->stop();
×
699
        m_scene->clear();
×
700
    }
701
}
×
702

703
void RGBMatrixEditor::slotBlendModeChanged(int index)
×
704
{
705
    m_matrix->setBlendMode(Universe::BlendMode(index));
×
706

707
    if (index == Universe::MaskBlend)
×
708
    {
709
        m_startColorButton->setEnabled(false);
×
710
    }
711
    else
712
    {
713
        m_startColorButton->setEnabled(true);
×
714
    }
715
    updateExtraOptions();
×
716
    updateColors();
×
717
    slotRestartTest();
×
718
}
×
719

720
void RGBMatrixEditor::slotControlModeChanged(int index)
×
721
{
722
    RGBMatrix::ControlMode mode = RGBMatrix::ControlMode(index);
×
723
    m_matrix->setControlMode(mode);
×
724
    updateColors();
×
725
    slotRestartTest();
×
726
}
×
727

728
void RGBMatrixEditor::slotStartColorButtonClicked()
×
729
{
730
    QColor col = QColorDialog::getColor(m_matrix->startColor());
×
731
    if (col.isValid() == true)
×
732
    {
733
        m_matrix->setStartColor(col);
×
734
        updateColors();
×
735
        slotRestartTest();
×
736
    }
737
}
×
738

739
void RGBMatrixEditor::slotEndColorButtonClicked()
×
740
{
741
    QColor col = QColorDialog::getColor(m_matrix->endColor());
×
742
    if (col.isValid() == true)
×
743
    {
744
        m_matrix->setEndColor(col);
×
745
        updateColors();
×
746
        slotRestartTest();
×
747
    }
748
}
×
749

750
void RGBMatrixEditor::slotResetEndColorButtonClicked()
×
751
{
752
    m_matrix->setEndColor(QColor());
×
753
    m_previewHandler->calculateColorDelta(m_matrix->startColor(), m_matrix->endColor());
×
754
    updateColors();
×
755
    slotRestartTest();
×
756
}
×
757

758
void RGBMatrixEditor::slotTextEdited(const QString& text)
×
759
{
760
    if (m_matrix->algorithm() != NULL && m_matrix->algorithm()->type() == RGBAlgorithm::Text)
×
761
    {
762
        RGBText* algo = static_cast<RGBText*> (m_matrix->algorithm());
×
763
        Q_ASSERT(algo != NULL);
×
764
        {
765
            QMutexLocker algorithmLocker(&m_matrix->algorithmMutex());
×
766
            algo->setText(text);
×
767
        }
768
        slotRestartTest();
×
769
    }
770
}
×
771

772
void RGBMatrixEditor::slotFontButtonClicked()
×
773
{
774
    if (m_matrix->algorithm() != NULL && m_matrix->algorithm()->type() == RGBAlgorithm::Text)
×
775
    {
776
        RGBText* algo = static_cast<RGBText*> (m_matrix->algorithm());
×
777
        Q_ASSERT(algo != NULL);
×
778

779
        bool ok = false;
×
780
        QFont font = QFontDialog::getFont(&ok, algo->font(), this);
×
781
        if (ok == true)
×
782
        {
783
            {
784
                QMutexLocker algorithmLocker(&m_matrix->algorithmMutex());
×
785
                algo->setFont(font);
×
786
            }
787
            slotRestartTest();
×
788
        }
789
    }
790
}
×
791

792
void RGBMatrixEditor::slotAnimationActivated(const QString& text)
×
793
{
794
    if (m_matrix->algorithm() != NULL && m_matrix->algorithm()->type() == RGBAlgorithm::Text)
×
795
    {
796
        RGBText* algo = static_cast<RGBText*> (m_matrix->algorithm());
×
797
        Q_ASSERT(algo != NULL);
×
798
        {
799
            QMutexLocker algorithmLocker(&m_matrix->algorithmMutex());
×
800
            algo->setAnimationStyle(RGBText::stringToAnimationStyle(text));
×
801
        }
802
        slotRestartTest();
×
803
    }
804
}
×
805

806
void RGBMatrixEditor::slotImageEdited()
×
807
{
808
    if (m_matrix->algorithm() != NULL && m_matrix->algorithm()->type() == RGBAlgorithm::Image)
×
809
    {
810
        RGBImage* algo = static_cast<RGBImage*> (m_matrix->algorithm());
×
811
        Q_ASSERT(algo != NULL);
×
812
        {
813
            QMutexLocker algorithmLocker(&m_matrix->algorithmMutex());
×
814
            algo->setFilename(m_imageEdit->text());
×
815
        }
816
        slotRestartTest();
×
817
    }
818
}
×
819

820
void RGBMatrixEditor::slotImageButtonClicked()
×
821
{
822
    if (m_matrix->algorithm() != NULL && m_matrix->algorithm()->type() == RGBAlgorithm::Image)
×
823
    {
824
        RGBImage* algo = static_cast<RGBImage*> (m_matrix->algorithm());
×
825
        Q_ASSERT(algo != NULL);
×
826

827
        QString path = algo->filename();
×
828
        path = QFileDialog::getOpenFileName(this,
×
829
                                            tr("Select image"),
×
830
                                            path,
831
                                            QString("%1 (*.png *.bmp *.jpg *.jpeg *.gif)").arg(tr("Images")));
×
832
        if (path.isEmpty() == false)
×
833
        {
834
            {
835
                QMutexLocker algorithmLocker(&m_matrix->algorithmMutex());
×
836
                algo->setFilename(path);
×
837
            }
838
            m_imageEdit->setText(path);
×
839
            slotRestartTest();
×
840
        }
841
    }
842
}
×
843

844
void RGBMatrixEditor::slotImageAnimationActivated(const QString& text)
×
845
{
846
    if (m_matrix->algorithm() != NULL && m_matrix->algorithm()->type() == RGBAlgorithm::Image)
×
847
    {
848
        RGBImage* algo = static_cast<RGBImage*> (m_matrix->algorithm());
×
849
        Q_ASSERT(algo != NULL);
×
850
        {
851
            QMutexLocker algorithmLocker(&m_matrix->algorithmMutex());
×
852
            algo->setAnimationStyle(RGBImage::stringToAnimationStyle(text));
×
853
        }
854
        slotRestartTest();
×
855
    }
856
}
×
857

858
void RGBMatrixEditor::slotOffsetSpinChanged()
×
859
{
860
    if (m_matrix->algorithm() != NULL && m_matrix->algorithm()->type() == RGBAlgorithm::Text)
×
861
    {
862
        RGBText* algo = static_cast<RGBText*> (m_matrix->algorithm());
×
863
        Q_ASSERT(algo != NULL);
×
864
        {
865
            QMutexLocker algorithmLocker(&m_matrix->algorithmMutex());
×
866
            algo->setXOffset(m_xOffsetSpin->value());
×
867
            algo->setYOffset(m_yOffsetSpin->value());
×
868
        }
869
        slotRestartTest();
×
870
    }
871

872
    if (m_matrix->algorithm() != NULL && m_matrix->algorithm()->type() == RGBAlgorithm::Image)
×
873
    {
874
        RGBImage* algo = static_cast<RGBImage*> (m_matrix->algorithm());
×
875
        Q_ASSERT(algo != NULL);
×
876
        {
877
            QMutexLocker algorithmLocker(&m_matrix->algorithmMutex());
×
878
            algo->setXOffset(m_xOffsetSpin->value());
×
879
            algo->setYOffset(m_yOffsetSpin->value());
×
880
        }
881
        slotRestartTest();
×
882
    }
883
}
×
884

885
void RGBMatrixEditor::slotLoopClicked()
×
886
{
887
    m_matrix->setRunOrder(Function::Loop);
×
888
    m_previewHandler->calculateColorDelta(m_matrix->startColor(), m_matrix->endColor());
×
889
    slotRestartTest();
×
890
}
×
891

892
void RGBMatrixEditor::slotPingPongClicked()
×
893
{
894
    m_matrix->setRunOrder(Function::PingPong);
×
895
    m_previewHandler->calculateColorDelta(m_matrix->startColor(), m_matrix->endColor());
×
896
    slotRestartTest();
×
897
}
×
898

899
void RGBMatrixEditor::slotSingleShotClicked()
×
900
{
901
    m_matrix->setRunOrder(Function::SingleShot);
×
902
    m_previewHandler->calculateColorDelta(m_matrix->startColor(), m_matrix->endColor());
×
903
    slotRestartTest();
×
904
}
×
905

906
void RGBMatrixEditor::slotForwardClicked()
×
907
{
908
    m_matrix->setDirection(Function::Forward);
×
909
    m_previewHandler->calculateColorDelta(m_matrix->startColor(), m_matrix->endColor());
×
910
    slotRestartTest();
×
911
}
×
912

913
void RGBMatrixEditor::slotBackwardClicked()
×
914
{
915
    m_matrix->setDirection(Function::Backward);
×
916
    m_previewHandler->calculateColorDelta(m_matrix->startColor(), m_matrix->endColor());
×
917
    slotRestartTest();
×
918
}
×
919

920
void RGBMatrixEditor::slotDimmerControlClicked()
×
921
{
922
    m_matrix->setDimmerControl(m_dimmerControlCb->isChecked());
×
923
    if (m_dimmerControlCb->isChecked() == false)
×
924
        m_dimmerControlCb->setEnabled(false);
×
925
}
×
926

927
void RGBMatrixEditor::slotFadeInChanged(int ms)
×
928
{
929
    m_matrix->setFadeInSpeed(ms);
×
930
    uint duration = Function::speedAdd(ms, m_speedDials->duration());
×
931
    m_matrix->setDuration(duration);
×
932
}
×
933

934
void RGBMatrixEditor::slotFadeOutChanged(int ms)
×
935
{
936
    m_matrix->setFadeOutSpeed(ms);
×
937
}
×
938

939
void RGBMatrixEditor::slotHoldChanged(int ms)
×
940
{
941
    uint duration = Function::speedAdd(m_matrix->fadeInSpeed(), ms);
×
942
    m_matrix->setDuration(duration);
×
943
}
×
944

945
void RGBMatrixEditor::slotDurationTapped()
×
946
{
947
    m_matrix->tap();
×
948
}
×
949

950
void RGBMatrixEditor::slotTestClicked()
×
951
{
952
    if (m_testButton->isChecked() == true)
×
953
        m_matrix->start(m_doc->masterTimer(), functionParent());
×
954
    else
955
        m_matrix->stopAndWait();
×
956
}
×
957

958
void RGBMatrixEditor::slotRestartTest()
×
959
{
960
    m_previewTimer->stop();
×
961

962
    if (m_testButton->isChecked() == true)
×
963
    {
964
        // Toggle off, toggle on. Duh.
965
        m_testButton->click();
×
966
        m_testButton->click();
×
967
    }
968

969
    if (createPreviewItems() == true)
×
970
        m_previewTimer->start(MasterTimer::tick());
×
971

972
}
×
973

974
void RGBMatrixEditor::slotModeChanged(Doc::Mode mode)
×
975
{
976
    if (mode == Doc::Operate)
×
977
    {
978
        if (m_testButton->isChecked() == true)
×
979
            m_matrix->stopAndWait();
×
980
        m_testButton->setChecked(false);
×
981
        m_testButton->setEnabled(false);
×
982
    }
983
    else
984
    {
985
        m_testButton->setEnabled(true);
×
986
    }
987
}
×
988

989
void RGBMatrixEditor::slotFixtureGroupAdded()
×
990
{
991
    fillFixtureGroupCombo();
×
992
}
×
993

994
void RGBMatrixEditor::slotFixtureGroupRemoved()
×
995
{
996
    fillFixtureGroupCombo();
×
997
    slotFixtureGroupActivated(m_fixtureGroupCombo->currentIndex());
×
998
}
×
999

1000
void RGBMatrixEditor::slotFixtureGroupChanged(quint32 id)
×
1001
{
1002
    if (id == m_matrix->fixtureGroup())
×
1003
    {
1004
        // Update the whole chain -> maybe the fixture layout has changed
1005
        fillFixtureGroupCombo();
×
1006
        slotFixtureGroupActivated(m_fixtureGroupCombo->currentIndex());
×
1007
    }
1008
    else
1009
    {
1010
        // Just change the name of the group, nothing else is interesting at this point
1011
        int index = m_fixtureGroupCombo->findData(id);
×
1012
        if (index != -1)
×
1013
        {
1014
            FixtureGroup* grp = m_doc->fixtureGroup(id);
×
1015
            m_fixtureGroupCombo->setItemText(index, grp->name());
×
1016
        }
1017
    }
1018
}
×
1019

1020
void RGBMatrixEditor::slotSaveToSequenceClicked()
×
1021
{
1022
    if (m_matrix == NULL || m_matrix->fixtureGroup() == FixtureGroup::invalidId())
×
1023
        return;
×
1024

1025
    FixtureGroup* grp = m_doc->fixtureGroup(m_matrix->fixtureGroup());
×
1026
    if (grp != NULL && m_matrix->algorithm() != NULL)
×
1027
    {
1028
        bool testRunning = false;
×
1029

1030
        if (m_testButton->isChecked() == true)
×
1031
        {
1032
            m_testButton->click();
×
1033
            testRunning = true;
×
1034
        }
1035
        else
1036
            m_previewTimer->stop();
×
1037

1038
        Scene *grpScene = new Scene(m_doc);
×
1039
        grpScene->setName(grp->name());
×
1040
        grpScene->setVisible(false);
×
1041

1042
        QList<GroupHead> headList = grp->headList();
×
1043
        foreach (GroupHead head, headList)
×
1044
        {
1045
            Fixture *fxi = m_doc->fixture(head.fxi);
×
1046
            if (fxi == NULL)
×
1047
                continue;
×
1048

1049
            if (m_controlModeCombo->currentIndex() == RGBMatrix::ControlModeRgb)
×
1050
            {
1051

1052
                    QVector <quint32> rgb = fxi->rgbChannels(head.head);
×
1053

1054
                    // in case of CMY, dump those channels
1055
                    if (rgb.count() == 0)
×
1056
                        rgb = fxi->cmyChannels(head.head);
×
1057

1058
                    if (rgb.count() == 3)
×
1059
                    {
1060
                        grpScene->setValue(head.fxi, rgb.at(0), 0);
×
1061
                        grpScene->setValue(head.fxi, rgb.at(1), 0);
×
1062
                        grpScene->setValue(head.fxi, rgb.at(2), 0);
×
1063
                    }
1064
            }
1065
            else if (m_controlModeCombo->currentIndex() == RGBMatrix::ControlModeDimmer)
×
1066
            {
1067
                quint32 channel = fxi->masterIntensityChannel();
×
1068

1069
                if (channel == QLCChannel::invalid())
×
1070
                    channel = fxi->channelNumber(QLCChannel::Intensity, QLCChannel::MSB, head.head);
×
1071

1072
                if (channel != QLCChannel::invalid())
×
1073
                    grpScene->setValue(head.fxi, channel, 0);
×
1074
            }
1075
            else
1076
            {
1077
                quint32 channel = QLCChannel::invalid();
×
1078
                if (m_controlModeCombo->currentIndex() == RGBMatrix::ControlModeWhite)
×
1079
                    channel = fxi->channelNumber(QLCChannel::White, QLCChannel::MSB, head.head);
×
1080
                else if (m_controlModeCombo->currentIndex() == RGBMatrix::ControlModeAmber)
×
1081
                    channel = fxi->channelNumber(QLCChannel::Amber, QLCChannel::MSB, head.head);
×
1082
                else if (m_controlModeCombo->currentIndex() == RGBMatrix::ControlModeUV)
×
1083
                    channel = fxi->channelNumber(QLCChannel::UV, QLCChannel::MSB, head.head);
×
1084
                else if (m_controlModeCombo->currentIndex() == RGBMatrix::ControlModeShutter)
×
1085
                {
1086
                    QLCFixtureHead fHead = fxi->head(head.head);
×
1087
                    QVector <quint32> shutters = fHead.shutterChannels();
×
1088
                    if (shutters.count())
×
1089
                        channel = shutters.first();
×
1090
                }
1091

1092
                if (channel != QLCChannel::invalid())
×
1093
                    grpScene->setValue(head.fxi, channel, 0);
×
1094
            }
1095
        }
1096
        m_doc->addFunction(grpScene);
×
1097

1098
        int totalSteps = m_matrix->stepsCount();
×
1099
        int increment = 1;
×
1100
        int currentStep = 0;
×
1101
        m_previewHandler->setStepColor(m_matrix->startColor());
×
1102

1103
        if (m_matrix->direction() == Function::Backward)
×
1104
        {
1105
            currentStep = totalSteps - 1;
×
1106
            increment = -1;
×
1107
            if (m_matrix->endColor().isValid())
×
1108
                m_previewHandler->setStepColor(m_matrix->endColor());
×
1109
        }
1110
        m_previewHandler->calculateColorDelta(m_matrix->startColor(), m_matrix->endColor());
×
1111

1112
        if (m_matrix->runOrder() == RGBMatrix::PingPong)
×
1113
            totalSteps = (totalSteps * 2) - 1;
×
1114

1115
        Sequence *sequence = new Sequence(m_doc);
×
1116
        sequence->setName(QString("%1 %2").arg(m_matrix->name()).arg(tr("Sequence")));
×
1117
        sequence->setBoundSceneID(grpScene->id());
×
1118
        sequence->setDurationMode(Chaser::PerStep);
×
1119
        sequence->setDuration(m_matrix->duration());
×
1120

1121
        if (m_matrix->fadeInSpeed() != 0)
×
1122
        {
1123
            sequence->setFadeInMode(Chaser::PerStep);
×
1124
            sequence->setFadeInSpeed(m_matrix->fadeInSpeed());
×
1125
        }
1126
        if (m_matrix->fadeOutSpeed() != 0)
×
1127
        {
1128
            sequence->setFadeOutMode(Chaser::PerStep);
×
1129
            sequence->setFadeOutSpeed(m_matrix->fadeOutSpeed());
×
1130
        }
1131

1132
        for (int i = 0; i < totalSteps; i++)
×
1133
        {
1134
            m_matrix->previewMap(currentStep, m_previewHandler);
×
1135
            ChaserStep step;
×
1136
            step.fid = grpScene->id();
×
1137
            step.hold = m_matrix->duration() - m_matrix->fadeInSpeed();
×
1138
            step.duration = m_matrix->duration();
×
1139
            step.fadeIn = m_matrix->fadeInSpeed();
×
1140
            step.fadeOut = m_matrix->fadeOutSpeed();
×
1141

1142
            for (int y = 0; y < m_previewHandler->m_map.size(); y++)
×
1143
            {
1144
                for (int x = 0; x < m_previewHandler->m_map[y].size(); x++)
×
1145
                {
1146
                    uint col = m_previewHandler->m_map[y][x];
×
1147
                    GroupHead head = grp->head(QLCPoint(x, y));
×
1148

1149
                    Fixture *fxi = m_doc->fixture(head.fxi);
×
1150
                    if (fxi == NULL)
×
1151
                        continue;
×
1152

1153
                    if (m_controlModeCombo->currentIndex() == RGBMatrix::ControlModeRgb)
×
1154
                    {
1155
                        QVector <quint32> rgb = fxi->rgbChannels(head.head);
×
1156
                        QVector <quint32> cmy = fxi->cmyChannels(head.head);
×
1157

1158
                        if (rgb.count() == 3)
×
1159
                        {
1160
                            step.values.append(SceneValue(head.fxi, rgb.at(0), qRed(col)));
×
1161
                            step.values.append(SceneValue(head.fxi, rgb.at(1), qGreen(col)));
×
1162
                            step.values.append(SceneValue(head.fxi, rgb.at(2), qBlue(col)));
×
1163
                        }
1164

1165
                        if (cmy.count() == 3)
×
1166
                        {
1167
                            QColor cmyCol(col);
×
1168

1169
                            step.values.append(SceneValue(head.fxi, cmy.at(0), cmyCol.cyan()));
×
1170
                            step.values.append(SceneValue(head.fxi, cmy.at(1), cmyCol.magenta()));
×
1171
                            step.values.append(SceneValue(head.fxi, cmy.at(2), cmyCol.yellow()));
×
1172
                        }
1173
                    }
1174
                    else if (m_controlModeCombo->currentIndex() == RGBMatrix::ControlModeDimmer)
×
1175
                    {
1176
                        quint32 channel = fxi->masterIntensityChannel();
×
1177

1178
                        if (channel == QLCChannel::invalid())
×
1179
                            channel = fxi->channelNumber(QLCChannel::Intensity, QLCChannel::MSB, head.head);
×
1180

1181
                        if (channel != QLCChannel::invalid())
×
1182
                            step.values.append(SceneValue(head.fxi, channel, RGBMatrix::rgbToGrey(col)));
×
1183
                    }
1184
                    else
1185
                    {
1186
                        quint32 channel = QLCChannel::invalid();
×
1187
                        if (m_controlModeCombo->currentIndex() == RGBMatrix::ControlModeWhite)
×
1188
                            channel = fxi->channelNumber(QLCChannel::White, QLCChannel::MSB, head.head);
×
1189
                        else if (m_controlModeCombo->currentIndex() == RGBMatrix::ControlModeAmber)
×
1190
                            channel = fxi->channelNumber(QLCChannel::Amber, QLCChannel::MSB, head.head);
×
1191
                        else if (m_controlModeCombo->currentIndex() == RGBMatrix::ControlModeUV)
×
1192
                            channel = fxi->channelNumber(QLCChannel::UV, QLCChannel::MSB, head.head);
×
1193
                        else if (m_controlModeCombo->currentIndex() == RGBMatrix::ControlModeShutter)
×
1194
                        {
1195
                            QLCFixtureHead fHead = fxi->head(head.head);
×
1196
                            QVector <quint32> shutters = fHead.shutterChannels();
×
1197
                            if (shutters.count())
×
1198
                                channel = shutters.first();
×
1199
                        }
1200

1201
                        if (channel != QLCChannel::invalid())
×
1202
                            step.values.append(SceneValue(head.fxi, channel, RGBMatrix::rgbToGrey(col)));
×
1203
                    }
1204
                }
1205
            }
1206
            // !! Important !! matrix's heads can be displaced randomly but in a sequence
1207
            // we absolutely need ordered values. So do it now !
1208
            std::sort(step.values.begin(), step.values.end());
×
1209

1210
            sequence->addStep(step);
×
1211
            currentStep += increment;
×
1212
            if (currentStep == totalSteps && m_matrix->runOrder() == RGBMatrix::PingPong)
×
1213
            {
1214
                currentStep = totalSteps - 2;
×
1215
                increment = -1;
×
1216
            }
1217
            m_previewHandler->updateStepColor(currentStep, m_matrix->startColor(), m_matrix->stepsCount());
×
1218
        }
1219

1220
        m_doc->addFunction(sequence);
×
1221

1222
        if (testRunning == true)
×
1223
            m_testButton->click();
×
1224
        else if (createPreviewItems() == true)
×
1225
            m_previewTimer->start(MasterTimer::tick());
×
1226
    }
1227
}
1228

NEW
1229
void RGBMatrixEditor::slotShapeToggle(bool)
×
1230
{
1231
    createPreviewItems();
×
1232
}
×
1233

1234
void RGBMatrixEditor::slotPropertyComboChanged(QString value)
×
1235
{
1236
    qDebug() << "Property combo changed to" << value;
×
1237
    if (m_matrix->algorithm() == NULL ||
×
1238
        m_matrix->algorithm()->type() == RGBAlgorithm::Script)
×
1239
    {
1240
        QComboBox *combo = (QComboBox *)sender();
×
1241
        QString pName = combo->property("pName").toString();
×
1242
        m_matrix->setProperty(pName, value);
×
1243
    }
1244
}
×
1245

1246
void RGBMatrixEditor::slotPropertySpinChanged(int value)
×
1247
{
1248
    qDebug() << "Property spin changed to" << value;
×
1249
    if (m_matrix->algorithm() == NULL ||
×
1250
        m_matrix->algorithm()->type() == RGBAlgorithm::Script)
×
1251
    {
1252
        QSpinBox *spin = (QSpinBox *)sender();
×
1253
        QString pName = spin->property("pName").toString();
×
1254
        m_matrix->setProperty(pName, QString::number(value));
×
1255
    }
1256
}
×
1257

1258
FunctionParent RGBMatrixEditor::functionParent() const
×
1259
{
1260
    return FunctionParent::master();
×
1261
}
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