-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmainwindow.cpp
executable file
·72 lines (62 loc) · 2.11 KB
/
mainwindow.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/** @file
@brief Header
@date 2015
@author
Russell Taylor
<http://sensics.com>
*/
// Copyright 2015 Sensics, Inc.
//
// (Licensed under the Apache License, Version 2.0)
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDesktopWidget>
MainWindow::MainWindow(bool fullscreen
, int numQuads
, QString buttonName, int whichButton
, QString analogName, int whichAnalog, double anaThresh
, QString trackerName, int whichSensor, double transThresh, double rotThresh
, bool doTrackerRotation, int rotateAxis
, QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
// Make the central widget have no margins, so we fill the whole region.
QMainWindow::centralWidget()->layout()->setContentsMargins(0, 0, 0, 0);
// Render in full screen if we've been asked to.
if (fullscreen) {
// Find out where the last screen lives.
int last_screen = QApplication::desktop()->numScreens() - 1;
QRect screenres = QApplication::desktop()->screenGeometry(last_screen);
// Display full resolution on the last screen.
// On Qt4, the showFullScreen() should come after the move/resize.
// On Qt5, it comes before.
this->showFullScreen();
this->move(QPoint(screenres.x(), screenres.y()));
this->resize(screenres.width(), screenres.height());
}
// Set up the VRPN devices if we've been asked to.
if (buttonName.length() > 0) {
ui->widget->useVRPNButton(buttonName, whichButton);
}
if (analogName.length() > 0) {
ui->widget->useVRPNAnalog(analogName, whichAnalog, anaThresh);
}
if (trackerName.length() > 0) {
if (doTrackerRotation) {
ui->widget->useVRPNTrackerRotate(trackerName, whichSensor, rotateAxis);
}
else {
ui->widget->useVRPNTracker(trackerName, whichSensor, transThresh, rotThresh);
}
}
if (numQuads > 0) {
ui->widget->setNumQuads(numQuads);
}
}
MainWindow::~MainWindow()
{
delete ui;
}