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

mcallegari / qlcplus / 13633248611

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

push

github

web-flow
actions: add chrpath to profile

14689 of 46089 relevant lines covered (31.87%)

26426.11 hits per line

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

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 */
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

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

267
    m_graphicsView->showFixturesLabels(m_props->labelsVisible());
×
268
}
×
269

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

364
/****************************************************************************
365
 * Menu
366
 ****************************************************************************/
367

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

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

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

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

388
    m_DMXToolBar->addSeparator();
×
389

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

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

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

416
    m_DMXToolBar->addSeparator();
×
417

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

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

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

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

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

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

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

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

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

483
    m_graphicsToolBar = new QToolBar(this);
×
484

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

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

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

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

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

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

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

527
    m_graphicsToolBar->addSeparator();
×
528

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

534
    m_graphicsToolBar->addSeparator();
×
535

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

681
    fillDMXView();
×
682
}
×
683

684
/********************************************************************
685
 * Graphics View
686
 ********************************************************************/
687

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

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

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

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

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

708
    MonitorProperties::GridUnits units = MonitorProperties::Meters;
709

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

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

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

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

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

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

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

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

761
    MonitorBackgroundSelection mbgs(this, m_doc);
×
762

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

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

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

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

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

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

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

795
    hideFixtureItemEditor();
×
796
}
×
797

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

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

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