• 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/monitor/monitor.cpp
1
/*
2
  Q Light Controller Plus
3
  monitor.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 <QApplication>
22
#include <QActionGroup>
23
#include <QFontDialog>
24
#include <QScrollArea>
25
#include <QSpacerItem>
26
#include <QByteArray>
27
#include <QComboBox>
28
#include <QSplitter>
29
#include <QSettings>
30
#include <QToolBar>
31
#include <QSpinBox>
32
#include <QAction>
33
#include <QScreen>
34
#include <QLabel>
35
#include <QDebug>
36
#include <QFont>
37
#include <QIcon>
38

39
#include "monitorfixturepropertieseditor.h"
40
#include "monitorbackgroundselection.h"
41
#include "monitorgraphicsview.h"
42
#include "fixtureselection.h"
43
#include "monitorfixture.h"
44
#include "monitorlayout.h"
45
#include "universe.h"
46
#include "monitor.h"
47
#include "apputil.h"
48
#include "doc.h"
49

50
#include "qlcfile.h"
51

52
#define SETTINGS_GEOMETRY "monitor/geometry"
53
#define SETTINGS_VSPLITTER "monitor/vsplitter"
54

55
Monitor* Monitor::s_instance = NULL;
56

57
/*****************************************************************************
58
 * Initialization
59
 *****************************************************************************/
60

61
Monitor::Monitor(QWidget* parent, Doc* doc, Qt::WindowFlags f)
×
62
    : QWidget(parent, f)
63
    , m_doc(doc)
64
    , m_props(NULL)
65
    , m_DMXToolBar(NULL)
66
    , m_scrollArea(NULL)
67
    , m_monitorWidget(NULL)
68
    , m_monitorLayout(NULL)
69
    , m_currentUniverse(Universe::invalid())
×
70
    , m_graphicsToolBar(NULL)
71
    , m_splitter(NULL)
72
    , m_graphicsView(NULL)
73
    , m_fixtureItemEditor(NULL)
74
    , m_gridWSpin(NULL)
75
    , m_gridHSpin(NULL)
76
    , m_unitsCombo(NULL)
77
    , m_labelsAction(NULL)
×
78
{
79
    Q_ASSERT(doc != NULL);
×
80

81
    m_props = m_doc->monitorProperties();
×
82

83
    /* Master layout for toolbar and scroll area */
84
    new QVBoxLayout(this);
×
85

86
    initView();
×
87

88
    /* Listen to fixture additions and changes from Doc */
89
    connect(m_doc, SIGNAL(fixtureAdded(quint32)),
×
90
            this, SLOT(slotFixtureAdded(quint32)));
91
    connect(m_doc, SIGNAL(fixtureChanged(quint32)),
×
92
            this, SLOT(slotFixtureChanged(quint32)));
93
    connect(m_doc, SIGNAL(fixtureRemoved(quint32)),
×
94
            this, SLOT(slotFixtureRemoved(quint32)));
95
    connect(m_doc->masterTimer(), SIGNAL(functionStarted(quint32)),
×
96
            this, SLOT(slotFunctionStarted(quint32)));
97
}
×
98

99
void Monitor::slotFunctionStarted(quint32 id)
×
100
{
101
    if (m_props->displayMode() == MonitorProperties::Graphics)
×
102
    {
103
        QString bgImage = m_props->customBackground(id);
×
104
        if (m_graphicsView != NULL && bgImage.isEmpty() == false)
×
105
            m_graphicsView->setBackgroundImage(bgImage);
×
106
    }
107
}
×
108

109
Monitor::~Monitor()
×
110
{
111
    while (m_monitorFixtures.isEmpty() == false)
×
112
        delete m_monitorFixtures.takeFirst();
×
113

114
    saveSettings();
×
115

116
    /* Reset the singleton instance */
117
    Monitor::s_instance = NULL;
×
118
}
×
119

120
void Monitor::initView()
×
121
{
122
    qDebug() << Q_FUNC_INFO;
×
123

124
    initDMXToolbar();
×
125
    initDMXView();
×
126
    initGraphicsToolbar();
×
127
    initGraphicsView();
×
128

129
    showCurrentView();
×
130
}
×
131

132
void Monitor::initDMXView()
×
133
{
134
    /* Scroll area that contains the monitor widget */
135
    m_scrollArea = new QScrollArea(this);
×
136
    m_scrollArea->setWidgetResizable(true);
×
137
    layout()->addWidget(m_scrollArea);
×
138

139
    /* Monitor widget that contains all MonitorFixtures */
140
    m_monitorWidget = new QWidget(m_scrollArea);
×
141
    m_monitorWidget->setBackgroundRole(QPalette::Dark);
×
142
    m_monitorLayout = new MonitorLayout(m_monitorWidget);
×
143
    m_monitorLayout->setSpacing(1);
×
144
    m_monitorLayout->setContentsMargins(1, 1, 1, 1);
×
145

146
    m_scrollArea->setWidget(m_monitorWidget);
×
147

148
    fillDMXView();
×
149
}
×
150

151
void Monitor::fillDMXView()
×
152
{
153
    while (m_monitorFixtures.isEmpty() == false)
×
154
        delete m_monitorFixtures.takeFirst();
×
155

156
    m_monitorWidget->setFont(m_props->font());
×
157

158
    /* Create a bunch of MonitorFixtures for each fixture */
NEW
159
    foreach (Fixture* fxi, m_doc->fixtures())
×
160
    {
161
        Q_ASSERT(fxi != NULL);
×
162
        if (m_currentUniverse == Universe::invalid() ||
×
163
            m_currentUniverse == fxi->universe())
×
164
                createMonitorFixture(fxi);
×
165
    }
166
}
×
167

168
void Monitor::showDMXView()
×
169
{
170
    qDebug() << Q_FUNC_INFO;
×
171

172
    hideFixtureItemEditor();
×
173

174
    m_graphicsView->hide();
×
175
    m_graphicsToolBar->hide();
×
176

177
    layout()->setMenuBar(m_DMXToolBar);
×
178
    m_DMXToolBar->show();
×
179
    m_scrollArea->show();
×
180

181
    for (quint32 i = 0; i < m_doc->inputOutputMap()->universesCount(); i++)
×
182
    {
183
        quint32 uniID = m_doc->inputOutputMap()->getUniverseID(i);
×
184
        if (m_currentUniverse == Universe::invalid() || uniID == m_currentUniverse)
×
185
            m_doc->inputOutputMap()->setUniverseMonitor(i, true);
×
186
        else
187
            m_doc->inputOutputMap()->setUniverseMonitor(i, false);
×
188
    }
189
}
×
190

191
void Monitor::initGraphicsView()
×
192
{
193
    m_splitter = new QSplitter(Qt::Horizontal, this);
×
194
    layout()->addWidget(m_splitter);
×
195
    QWidget* gcontainer = new QWidget(this);
×
196
    m_splitter->addWidget(gcontainer);
×
197
    gcontainer->setLayout(new QVBoxLayout);
×
198
    gcontainer->layout()->setContentsMargins(0, 0, 0, 0);
×
199

200
    m_graphicsView = new MonitorGraphicsView(m_doc, this);
×
201
    m_graphicsView->setRenderHint(QPainter::Antialiasing);
×
202
    m_graphicsView->setAcceptDrops(true);
×
203
    m_graphicsView->setAlignment(Qt::AlignLeft | Qt::AlignTop);
×
204
    m_graphicsView->setBackgroundBrush(QBrush(QColor(11, 11, 11, 255), Qt::SolidPattern));
×
205
    m_splitter->widget(0)->layout()->addWidget(m_graphicsView);
×
206

207
    connect(m_graphicsView, SIGNAL(fixtureMoved(quint32,QPointF)),
×
208
            this, SLOT(slotFixtureMoved(quint32,QPointF)));
209
    connect(m_graphicsView, SIGNAL(viewClicked(QMouseEvent*)),
×
210
            this, SLOT(slotViewClicked()));
211

212
    // add container for chaser editor
213
    QWidget* econtainer = new QWidget(this);
×
214
    m_splitter->addWidget(econtainer);
×
215
    econtainer->setLayout(new QVBoxLayout);
×
216
    econtainer->layout()->setContentsMargins(0, 0, 0, 0);
×
217
    m_splitter->widget(1)->hide();
×
218

219
    QSettings settings;
×
220
    QVariant var2 = settings.value(SETTINGS_VSPLITTER);
×
221
    if (var2.isValid() == true)
×
222
        m_splitter->restoreState(var2.toByteArray());
×
223

224
    fillGraphicsView();
×
225
}
×
226

227
void Monitor::fillGraphicsView()
×
228
{
229
    m_graphicsView->clearFixtures();
×
230

231
    m_gridWSpin->blockSignals(true);
×
232
    m_gridHSpin->blockSignals(true);
×
233
    m_unitsCombo->blockSignals(true);
×
234

235
    if (m_props->gridUnits() == MonitorProperties::Meters)
×
236
    {
237
        m_graphicsView->setGridMetrics(1000.0);
×
238
        m_unitsCombo->setCurrentIndex(0);
×
239
    }
240
    else // m_props->gridUnits() == MonitorProperties::Feet
241
    {
242
        m_graphicsView->setGridMetrics(304.8);
×
243
        m_unitsCombo->setCurrentIndex(1);
×
244
    }
245

246
    m_gridWSpin->setValue(m_props->gridSize().x());
×
247
    m_gridHSpin->setValue(m_props->gridSize().z());
×
248
    m_gridWSpin->blockSignals(false);
×
249
    m_gridHSpin->blockSignals(false);
×
250
    m_unitsCombo->blockSignals(false);
×
251

252
    m_graphicsView->setGridSize(QSize(m_props->gridSize().x(), m_props->gridSize().z()));
×
253
    m_graphicsView->setBackgroundImage(m_props->commonBackgroundImage());
×
254
    m_graphicsView->showFixturesLabels(m_props->labelsVisible());
×
255

256
    foreach (quint32 fid, m_props->fixtureItemsID())
×
257
    {
258
        if (m_doc->fixture(fid) != NULL)
×
259
        {
260
            PreviewItem item = m_props->fixtureItem(fid, 0, 0);
×
261
            m_graphicsView->addFixture(fid, QPointF(item.m_position.x(), item.m_position.y()));
×
262
            qDebug() << "Gel color:" << item.m_color;
×
263
            m_graphicsView->setFixtureGelColor(fid, item.m_color);
×
264
            m_graphicsView->setFixtureRotation(fid, item.m_rotation.y());
×
265
        }
266
    }
267
}
×
268

269
void Monitor::showGraphicsView()
×
270
{
271
    qDebug() << Q_FUNC_INFO;
×
272

273
    m_DMXToolBar->hide();
×
274
    m_scrollArea->hide();
×
275

276
    layout()->setMenuBar(m_graphicsToolBar);
×
277
    m_graphicsToolBar->show();
×
278
    m_graphicsView->show();
×
279

280
    // Graphics view needs to monitor all the universes
281
    for (quint32 i = 0; i < m_doc->inputOutputMap()->universesCount(); i++)
×
282
    {
283
        m_doc->inputOutputMap()->setUniverseMonitor(i, true);
×
284
    }
285
}
×
286

287
void Monitor::showCurrentView()
×
288
{
289
    if (m_props->displayMode() == MonitorProperties::DMX)
×
290
        showDMXView();
×
291
    else
292
        showGraphicsView();
×
293
}
×
294

295
void Monitor::updateView()
×
296
{
297
    fillDMXView();
×
298
    fillGraphicsView();
×
299
    showCurrentView();
×
300
}
×
301

302
Monitor* Monitor::instance()
×
303
{
304
    return s_instance;
×
305
}
306

307
void Monitor::saveSettings()
×
308
{
309
    QSettings settings;
×
310
    settings.setValue(SETTINGS_GEOMETRY, saveGeometry());
×
311

312
    if (m_splitter != NULL)
×
313
    {
314
        QSettings settings;
×
315
        settings.setValue(SETTINGS_VSPLITTER, m_splitter->saveState());
×
316
    }
317

318
    if (m_monitorWidget != NULL)
×
319
        m_props->setFont(m_monitorWidget->font());
×
320
}
×
321

322
void Monitor::createAndShow(QWidget* parent, Doc* doc)
×
323
{
324
    QWidget* window = NULL;
×
325

326
    /* Must not create more than one instance */
327
    if (s_instance == NULL)
×
328
    {
329
        /* Create a separate window for OSX */
330
        s_instance = new Monitor(parent, doc, Qt::Window);
×
331
        window = s_instance;
×
332

333
        /* Set some common properties for the window and show it */
334
        window->setAttribute(Qt::WA_DeleteOnClose);
×
335
        window->setWindowIcon(QIcon(":/monitor.png"));
×
336
        window->setWindowTitle(tr("Fixture Monitor"));
×
337
        window->setContextMenuPolicy(Qt::CustomContextMenu);
×
338

339
        QSettings settings;
×
340
        QVariant var = settings.value(SETTINGS_GEOMETRY);
×
341
        if (var.isValid() == true)
×
342
            window->restoreGeometry(var.toByteArray());
×
343
        else
344
        {
345
            QScreen *screen = QGuiApplication::screens().first();
×
346
            QRect rect = screen->availableGeometry();
×
347
            int rWd = rect.width() / 4;
×
348
            int rHd = rect.height() / 4;
×
349
            window->resize(rWd * 3, rHd * 3);
×
350
            window->move(rWd / 2, rHd / 2);
×
351
        }
352
        AppUtil::ensureWidgetIsVisible(window);
×
353
    }
354
    else
355
    {
356
        window = s_instance;
×
357
    }
358

359
    window->show();
×
360
    window->raise();
×
361
}
×
362

363
/****************************************************************************
364
 * Menu
365
 ****************************************************************************/
366

367
void Monitor::initDMXToolbar()
×
368
{
369
    QActionGroup* group;
370
    QAction* action;
371
    m_DMXToolBar = new QToolBar(this);
×
372

373
    /* Menu bar */
374
    Q_ASSERT(layout() != NULL);
×
375
    layout()->setMenuBar(m_DMXToolBar);
×
376

377
    action = m_DMXToolBar->addAction(tr("2D View"));
×
378
    m_DMXToolBar->addSeparator();
×
379
    action->setData(MonitorProperties::Graphics);
×
380
    connect(action, SIGNAL(triggered(bool)),
×
381
            this, SLOT(slotSwitchMode()));
382

383
    /* Font */
384
    m_DMXToolBar->addAction(QIcon(":/fonts.png"), tr("Font"),
×
385
                       this, SLOT(slotChooseFont()));
386

387
    m_DMXToolBar->addSeparator();
×
388

389
    /* Channel style */
390
    group = new QActionGroup(this);
×
391
    group->setExclusive(true);
×
392

393
    action = m_DMXToolBar->addAction(tr("DMX Channels"));
×
394
    action->setToolTip(tr("Show absolute DMX channel numbers"));
×
395
    action->setCheckable(true);
×
396
    action->setData(MonitorProperties::DMXChannels);
×
397
    connect(action, SIGNAL(triggered(bool)),
×
398
            this, SLOT(slotChannelStyleTriggered()));
399
    m_DMXToolBar->addAction(action);
×
400
    group->addAction(action);
×
401
    if (m_props->channelStyle() == MonitorProperties::DMXChannels)
×
402
        action->setChecked(true);
×
403

404
    action = m_DMXToolBar->addAction(tr("Relative Channels"));
×
405
    action->setToolTip(tr("Show channel numbers relative to fixture"));
×
406
    action->setCheckable(true);
×
407
    action->setData(MonitorProperties::RelativeChannels);
×
408
    connect(action, SIGNAL(triggered(bool)),
×
409
            this, SLOT(slotChannelStyleTriggered()));
410
    m_DMXToolBar->addAction(action);
×
411
    group->addAction(action);
×
412
    if (m_props->channelStyle() == MonitorProperties::RelativeChannels)
×
413
        action->setChecked(true);
×
414

415
    m_DMXToolBar->addSeparator();
×
416

417
    /* Value display style */
418
    group = new QActionGroup(this);
×
419
    group->setExclusive(true);
×
420

421
    action = m_DMXToolBar->addAction(tr("DMX Values"));
×
422
    action->setToolTip(tr("Show DMX values 0-255"));
×
423
    action->setCheckable(true);
×
424
    action->setData(MonitorProperties::DMXValues);
×
425
    connect(action, SIGNAL(triggered(bool)),
×
426
            this, SLOT(slotValueStyleTriggered()));
427
    m_DMXToolBar->addAction(action);
×
428
    group->addAction(action);
×
429
    action->setChecked(true);
×
430
    if (m_props->valueStyle() == MonitorProperties::DMXValues)
×
431
        action->setChecked(true);
×
432

433
    action = m_DMXToolBar->addAction(tr("Percent Values"));
×
434
    action->setToolTip(tr("Show percentage values 0-100%"));
×
435
    action->setCheckable(true);
×
436
    action->setData(MonitorProperties::PercentageValues);
×
437
    connect(action, SIGNAL(triggered(bool)),
×
438
            this, SLOT(slotValueStyleTriggered()));
439
    m_DMXToolBar->addAction(action);
×
440
    group->addAction(action);
×
441
    if (m_props->valueStyle() == MonitorProperties::PercentageValues)
×
442
        action->setChecked(true);
×
443

444
    /* Universe combo box */
445
    m_DMXToolBar->addSeparator();
×
446

447
    QLabel *uniLabel = new QLabel(tr("Universe"));
×
448
    uniLabel->setMargin(5);
×
449
    m_DMXToolBar->addWidget(uniLabel);
×
450

451
    QComboBox *uniCombo = new QComboBox(this);
×
452
    uniCombo->addItem(tr("All universes"), Universe::invalid());
×
453
    for (quint32 i = 0; i < m_doc->inputOutputMap()->universesCount(); i++)
×
454
    {
455
        quint32 uniID = m_doc->inputOutputMap()->getUniverseID(i);
×
456
        uniCombo->addItem(m_doc->inputOutputMap()->getUniverseNameByIndex(i), uniID);
×
457
    }
458
    connect(uniCombo, SIGNAL(currentIndexChanged(int)),
×
459
            this, SLOT(slotUniverseSelected(int)));
460
    m_DMXToolBar->addWidget(uniCombo);
×
461

462
    if (QLCFile::hasWindowManager() == false)
×
463
    {
464
        QWidget* widget = new QWidget(this);
×
465
        widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
×
466
        m_DMXToolBar->addWidget(widget);
×
467

468
        action = m_DMXToolBar->addAction(tr("Close"));
×
469
        action->setToolTip(tr("Close this window"));
×
470
        action->setIcon(QIcon(":/delete.png"));
×
471
        connect(action, SIGNAL(triggered(bool)),
×
472
                this, SLOT(close()));
473
        m_DMXToolBar->addAction(action);
×
474
        group->addAction(action);
×
475
    }
476
}
×
477

478
void Monitor::initGraphicsToolbar()
×
479
{
480
    QAction* action;
481

482
    m_graphicsToolBar = new QToolBar(this);
×
483

484
    /* Menu bar */
485
    Q_ASSERT(layout() != NULL);
×
486
    layout()->setMenuBar(m_graphicsToolBar);
×
487

488
    action = m_graphicsToolBar->addAction(tr("DMX View"));
×
489
    m_graphicsToolBar->addSeparator();
×
490
    action->setData(MonitorProperties::DMX);
×
491
    connect(action, SIGNAL(triggered(bool)),
×
492
            this, SLOT(slotSwitchMode()));
493

494
    QLabel *label = new QLabel(tr("Size"));
×
495
    label->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
×
496
    m_graphicsToolBar->addWidget(label);
×
497

498
    QVector3D gridSize = m_props->gridSize();
×
499

500
    m_gridWSpin = new QSpinBox();
×
501
    m_gridWSpin->setMinimum(1);
×
502
    m_gridWSpin->setValue(gridSize.x());
×
503
    m_graphicsToolBar->addWidget(m_gridWSpin);
×
504
    connect(m_gridWSpin, SIGNAL(valueChanged(int)),
×
505
            this, SLOT(slotGridWidthChanged(int)));
506

507
    QLabel *xlabel = new QLabel("x");
×
508
    label->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
×
509
    m_graphicsToolBar->addWidget(xlabel);
×
510
    m_gridHSpin = new QSpinBox();
×
511
    m_gridHSpin->setMinimum(1);
×
512
    m_gridHSpin->setValue(gridSize.z());
×
513
    m_graphicsToolBar->addWidget(m_gridHSpin);
×
514
    connect(m_gridHSpin, SIGNAL(valueChanged(int)),
×
515
            this, SLOT(slotGridHeightChanged(int)));
516

517
    m_unitsCombo = new QComboBox();
×
518
    m_unitsCombo->addItem(tr("Meters"), MonitorProperties::Meters);
×
519
    m_unitsCombo->addItem(tr("Feet"), MonitorProperties::Feet);
×
520
    if (m_props->gridUnits() == MonitorProperties::Feet)
×
521
        m_unitsCombo->setCurrentIndex(1);
×
522
    m_graphicsToolBar->addWidget(m_unitsCombo);
×
523
    connect(m_unitsCombo, SIGNAL(currentIndexChanged(int)),
×
524
            this, SLOT(slotGridUnitsChanged(int)));
525

526
    m_graphicsToolBar->addSeparator();
×
527

528
    m_graphicsToolBar->addAction(QIcon(":/edit_add.png"), tr("Add fixture"),
×
529
                       this, SLOT(slotAddFixture()));
530
    m_graphicsToolBar->addAction(QIcon(":/edit_remove.png"), tr("Remove fixture"),
×
531
                       this, SLOT(slotRemoveFixture()));
532

533
    m_graphicsToolBar->addSeparator();
×
534

535
    m_graphicsToolBar->addAction(QIcon(":/image.png"), tr("Set a background picture"),
×
536
                       this, SLOT(slotSetBackground()));
537

538
    m_labelsAction = m_graphicsToolBar->addAction(QIcon(":/label.png"), tr("Show/hide labels"));
×
539
    m_labelsAction->setCheckable(true);
×
540
    m_labelsAction->setChecked(m_props->labelsVisible());
×
541
    connect(m_labelsAction, SIGNAL(triggered(bool)), this, SLOT(slotShowLabels(bool)));
×
542

543
    if (QLCFile::hasWindowManager() == false)
×
544
    {
545
        QWidget* widget = new QWidget(this);
×
546
        widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
×
547
        m_graphicsToolBar->addWidget(widget);
×
548

549
        action = m_graphicsToolBar->addAction(tr("Close"));
×
550
        action->setToolTip(tr("Close this window"));
×
551
        action->setIcon(QIcon(":/delete.png"));
×
552
        connect(action, SIGNAL(triggered(bool)),
×
553
                this, SLOT(close()));
554
        m_graphicsToolBar->addAction(action);
×
555
    }
556
}
×
557

558
void Monitor::slotChooseFont()
×
559
{
560
    bool ok = false;
×
561
    QFont f = QFontDialog::getFont(&ok, m_monitorWidget->font(), this);
×
562
    if (ok == true)
×
563
    {
564
        m_monitorWidget->setFont(f);
×
565
        m_props->setFont(f);
×
566
    }
567
}
×
568

569
void Monitor::slotChannelStyleTriggered()
×
570
{
571
    QAction* action = qobject_cast<QAction*> (QObject::sender());
×
572
    Q_ASSERT(action != NULL);
×
573

574
    action->setChecked(true);
×
575
    m_props->setChannelStyle(MonitorProperties::ChannelStyle(action->data().toInt()));
×
576
    emit channelStyleChanged(m_props->channelStyle());
×
577
}
×
578

579
void Monitor::slotValueStyleTriggered()
×
580
{
581
    QAction* action = qobject_cast<QAction*> (QObject::sender());
×
582
    Q_ASSERT(action != NULL);
×
583

584
    action->setChecked(true);
×
585
    m_props->setValueStyle(MonitorProperties::ValueStyle(action->data().toInt()));
×
586
    emit valueStyleChanged(m_props->valueStyle());
×
587
}
×
588

589
void Monitor::slotSwitchMode()
×
590
{
591
    QAction* action = qobject_cast<QAction*> (QObject::sender());
×
592
    Q_ASSERT(action != NULL);
×
593

594
    m_props->setDisplayMode(MonitorProperties::DisplayMode(action->data().toInt()));
×
595
    showCurrentView();
×
596
}
×
597

598
/****************************************************************************
599
 * Fixture added/removed stuff
600
 ****************************************************************************/
601

602
void Monitor::updateFixtureLabelStyles()
×
603
{
604
    QListIterator <MonitorFixture*> it(m_monitorFixtures);
×
605
    while (it.hasNext() == true)
×
606
        it.next()->updateLabelStyles();
×
607
}
×
608

609
void Monitor::createMonitorFixture(Fixture* fxi)
×
610
{
611
    MonitorFixture* mof = new MonitorFixture(m_monitorWidget, m_doc);
×
612
    mof->setFixture(fxi->id());
×
613
    mof->slotChannelStyleChanged(m_props->channelStyle());
×
614
    mof->slotValueStyleChanged(m_props->valueStyle());
×
615
    mof->show();
×
616

617
    /* Make mof listen to value & channel style changes */
618
    connect(this, SIGNAL(valueStyleChanged(MonitorProperties::ValueStyle)),
×
619
            mof, SLOT(slotValueStyleChanged(MonitorProperties::ValueStyle)));
620
    connect(this, SIGNAL(channelStyleChanged(MonitorProperties::ChannelStyle)),
×
621
            mof, SLOT(slotChannelStyleChanged(MonitorProperties::ChannelStyle)));
622

623
    m_monitorLayout->addItem(new MonitorLayoutItem(mof));
×
624
    m_monitorFixtures.append(mof);
×
625
}
×
626

627
void Monitor::slotFixtureAdded(quint32 fxi_id)
×
628
{
629
    Fixture* fxi = m_doc->fixture(fxi_id);
×
630
    if (fxi != NULL)
×
631
        createMonitorFixture(fxi);
×
632
}
×
633

634
void Monitor::slotFixtureChanged(quint32 fxi_id)
×
635
{
636
    QListIterator <MonitorFixture*> it(m_monitorFixtures);
×
637
    while (it.hasNext() == true)
×
638
    {
639
        MonitorFixture* mof = it.next();
×
640
        if (mof->fixture() == fxi_id)
×
641
            mof->setFixture(fxi_id);
×
642
    }
643

644
    m_monitorLayout->sort();
×
645
    m_monitorWidget->updateGeometry();
×
646

647
    m_graphicsView->updateFixture(fxi_id);
×
648
}
×
649

650
void Monitor::slotFixtureRemoved(quint32 fxi_id)
×
651
{
652
    QMutableListIterator <MonitorFixture*> it(m_monitorFixtures);
×
653
    while (it.hasNext() == true)
×
654
    {
655
        MonitorFixture* mof = it.next();
×
656
        if (mof->fixture() == fxi_id)
×
657
        {
658
            it.remove();
×
659
            delete mof;
×
660
        }
661
    }
662

663
    m_graphicsView->removeFixture(fxi_id);
×
664
}
×
665

666
void Monitor::slotUniverseSelected(int index)
×
667
{
668
    QComboBox *combo = qobject_cast<QComboBox *>(sender());
×
669
    m_currentUniverse = combo->itemData(index).toUInt();
×
670

671
    for (quint32 i = 0; i < m_doc->inputOutputMap()->universesCount(); i++)
×
672
    {
673
        quint32 uniID = m_doc->inputOutputMap()->getUniverseID(i);
×
674
        if (m_currentUniverse == Universe::invalid() || uniID == m_currentUniverse)
×
675
            m_doc->inputOutputMap()->setUniverseMonitor(i, true);
×
676
        else
677
            m_doc->inputOutputMap()->setUniverseMonitor(i, false);
×
678
    }
679

680
    fillDMXView();
×
681
}
×
682

683
/********************************************************************
684
 * Graphics View
685
 ********************************************************************/
686

687
void Monitor::slotGridWidthChanged(int value)
×
688
{
689
    Q_ASSERT(m_graphicsView != NULL);
×
690

691
    m_graphicsView->setGridSize(QSize(value, m_gridHSpin->value()));
×
692
    m_props->setGridSize(QVector3D(value, m_props->gridSize().y(), m_gridHSpin->value()));
×
693
}
×
694

695
void Monitor::slotGridHeightChanged(int value)
×
696
{
697
    Q_ASSERT(m_graphicsView != NULL);
×
698

699
    m_graphicsView->setGridSize(QSize(m_gridWSpin->value(), value));
×
700
    m_props->setGridSize(QVector3D(m_gridWSpin->value(), m_props->gridSize().y(), value));
×
701
}
×
702

703
void Monitor::slotGridUnitsChanged(int index)
×
704
{
705
    Q_ASSERT(m_graphicsView != NULL);
×
706

707
    MonitorProperties::GridUnits units = MonitorProperties::Meters;
×
708

709
    QVariant var = m_unitsCombo->itemData(index);
×
710
    if (var.isValid())
×
711
        units = MonitorProperties::GridUnits(var.toInt());
×
712

713
    if (units == MonitorProperties::Meters)
×
714
        m_graphicsView->setGridMetrics(1000.0);
×
715
    else if (units == MonitorProperties::Feet)
×
716
        m_graphicsView->setGridMetrics(304.8);
×
717

718
    m_props->setGridUnits(units);
×
719
}
×
720

721
void Monitor::slotAddFixture()
×
722
{
723
    Q_ASSERT(m_graphicsView != NULL);
×
724

725
    QList <quint32> disabled = m_graphicsView->fixturesID();
×
726
    /* Get a list of new fixtures to add to the scene */
727
    FixtureSelection fs(this, m_doc);
×
728
    fs.setMultiSelection(true);
×
729
    fs.setDisabledFixtures(disabled);
×
730
    if (fs.exec() == QDialog::Accepted)
×
731
    {
732
        QListIterator <quint32> it(fs.selection());
×
733
        // TODO position fixtures one after the other
734
        while (it.hasNext() == true)
×
735
        {
736
            quint32 fid = it.next();
×
737
            m_graphicsView->addFixture(fid);
×
738
            m_props->setFixturePosition(fid, 0, 0, QVector3D(0, 0, 0));
×
739
            m_props->setFixtureFlags(fid, 0, 0, 0);
×
740
            m_doc->setModified();
×
741
        }
742
    }
743
    if (m_labelsAction->isChecked())
×
744
        slotShowLabels(true);
×
745
}
×
746

747
void Monitor::slotRemoveFixture()
×
748
{
749
    Q_ASSERT(m_graphicsView != NULL);
×
750

751
    hideFixtureItemEditor();
×
752
    if (m_graphicsView->removeFixture() == true)
×
753
        m_doc->setModified();
×
754
}
×
755

756
void Monitor::slotSetBackground()
×
757
{
758
    Q_ASSERT(m_graphicsView != NULL);
×
759

760
    MonitorBackgroundSelection mbgs(this, m_doc);
×
761

762
    if (mbgs.exec() == QDialog::Accepted)
×
763
    {
764
        if (m_props->commonBackgroundImage().isEmpty() == false)
×
765
            m_graphicsView->setBackgroundImage(m_props->commonBackgroundImage());
×
766
        else
767
            m_graphicsView->setBackgroundImage(QString());
×
768

769
        m_doc->setModified();
×
770
    }
771
}
×
772

773
void Monitor::slotShowLabels(bool visible)
×
774
{
775
    Q_ASSERT(m_graphicsView != NULL);
×
776

777
    m_props->setLabelsVisible(visible);
×
778
    m_graphicsView->showFixturesLabels(visible);
×
779
}
×
780

781
void Monitor::slotFixtureMoved(quint32 fid, QPointF pos)
×
782
{
783
    Q_ASSERT(m_graphicsView != NULL);
×
784

785
    showFixtureItemEditor();
×
786
    m_props->setFixturePosition(fid, 0, 0, QVector3D(pos.x(), pos.y(), 0));
×
787
    m_doc->setModified();
×
788
}
×
789

790
void Monitor::slotViewClicked()
×
791
{
792
    Q_ASSERT(m_graphicsView != NULL);
×
793

794
    hideFixtureItemEditor();
×
795
}
×
796

797
void Monitor::hideFixtureItemEditor()
×
798
{
799
    if (m_fixtureItemEditor != NULL)
×
800
    {
801
        m_splitter->widget(1)->layout()->removeWidget(m_fixtureItemEditor);
×
802
        m_splitter->widget(1)->hide();
×
803
        m_fixtureItemEditor->deleteLater();
×
804
        m_fixtureItemEditor = NULL;
×
805
    }
806
}
×
807

808
void Monitor::showFixtureItemEditor()
×
809
{
810
    MonitorFixtureItem *item = m_graphicsView->getSelectedItem();
×
811
    hideFixtureItemEditor();
×
812

813
    if (item != NULL)
×
814
    {
815
        m_fixtureItemEditor = new MonitorFixturePropertiesEditor(
×
816
                    item, m_graphicsView,
817
                    m_props, m_splitter->widget(1));
×
818
        m_splitter->widget(1)->layout()->addWidget(m_fixtureItemEditor);
×
819
        m_splitter->widget(1)->show();
×
820
        m_fixtureItemEditor->show();
×
821
    }
822
}
×
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