Additional code review changes

This commit is contained in:
Gene Payne
2022-02-08 15:24:23 -07:00
parent 4f40bdb8ca
commit 364f80c831
11 changed files with 57 additions and 101 deletions
@@ -67,7 +67,6 @@ private:
unsigned int _nWindowsAllocated = 0;
unsigned int _nWindowsDisplayed = 0;
unsigned int _nMaxWindows = 3;
unsigned int _nMonitors = 1;
const std::array<QString, 4> _winColors;
std::vector<WindowControl*> _windowControl;
QPushButton* _addWindowButton = nullptr;
@@ -31,19 +31,16 @@
#include <sgct/config.h>
#include <sgct/math.h>
#include <QCheckBox>
#include <QLabel>
#include <QLayout>
#include <QLineEdit>
#include <QPushButton>
class Orientation : public QWidget {
Q_OBJECT
public:
Orientation();
~Orientation();
void addButtonToLayout(QVBoxLayout* parentLayout);
sgct::quat orientationValue();
bool vsyncValue();
sgct::quat orientationValue() const;
bool vsyncValue() const;
private slots:
void orientationDialog();
@@ -25,28 +25,15 @@
#ifndef __OPENSPACE_UI_LAUNCHER___ORIENTATIONDIALOG___H__
#define __OPENSPACE_UI_LAUNCHER___ORIENTATIONDIALOG___H__
#include <QCheckBox>
#include <QDialog>
#include <QFrame>
#include <QIntValidator>
#include <QLabel>
#include <QLayout>
#include <QLineEdit>
#include <QPainter>
#include <QPainterPath>
#include <QPoint>
#include <QPushButton>
#include <QVector>
#include <QWidget>
#include <glm/gtc/constants.hpp>
#include <iostream>
#include <vector>
#include <sgct/config.h>
#include <QLineEdit>
#include <glm/gtc/constants.hpp>
class QWidget;
class OrientationDialog : public QDialog
{
class OrientationDialog : public QDialog {
Q_OBJECT
public:
OrientationDialog(sgct::quat& orientation, QWidget* parent);
@@ -33,26 +33,20 @@
#include <sgctedit/orientation.h>
#include <QApplication>
#include <QColor>
#include <QLabel>
#include <QLayout>
#include <QLineEdit>
#include <QMainWindow>
#include <QComboBox>
#include <QPushButton>
#include <QScreen>
#include <QTextBrowser>
#include <QWidget>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
class QWidget;
class SgctEdit final : public QDialog
{
Q_OBJECT
public:
SgctEdit(QWidget* parent, std::vector<sgct::config::Window>& windowList,
sgct::config::Cluster& cluster, const QList<QScreen*> screenList);
sgct::config::Cluster& cluster, const QList<QScreen*>& screenList);
~SgctEdit();
void addDisplayLayout(QHBoxLayout* layout);
void createWidgets();
@@ -60,7 +54,8 @@ public:
std::string saveFilename();
private:
void systemMonitorConfiguration(const QList<QScreen*> screenList);
void systemMonitorConfiguration(const QList<QScreen*>& screenList);
std::shared_ptr<MonitorBox> _monBox = nullptr;
std::vector<QRect> _monitorSizeList;
QVBoxLayout* _displayLayout = nullptr;
@@ -32,17 +32,15 @@
#include <QLabel>
#include <QLayout>
#include <QLineEdit>
#include <QPainter>
#include <QPushButton>
#include <vector>
class WindowControl : public QWidget
{
class WindowControl : public QWidget {
Q_OBJECT
public:
WindowControl(unsigned int nMonitors, unsigned int monitorIndex,
unsigned int windowIndex, std::vector<QRect>& monitorDims,
const std::array<QString, 4> winColors, QWidget *parent = nullptr);
WindowControl(unsigned int monitorIndex, unsigned int windowIndex,
std::vector<QRect>& monitorDims, const std::array<QString, 4> winColors,
QWidget *parent);
~WindowControl();
void setDimensions(const QRectF& dimensions);
void setWindowChangeCallback(std::function<void(int, int, const QRectF&)> cb);
@@ -100,8 +98,6 @@ private slots:
private:
void createWidgets(QWidget* parent);
template <typename T>
void enableProjectionOption(T* comboModel, int selectionIndex, bool enable);
void updateScaledWindowDimensions();
std::function<void(int, int, const QRectF&)> _windowChangeCallback;
std::function<void(unsigned int)> _windowGuiCheckCallback;
@@ -41,7 +41,6 @@ Display::Display(std::shared_ptr<MonitorBox> monitorRenderBox,
{
_addWindowButton = new QPushButton("Add Window", this);
_removeWindowButton = new QPushButton("Remove Window", this);
_nMonitors = _monitorResolutions.size();
//Add all window controls (some will be hidden from GUI initially)
for (unsigned int i = 0; i < _nMaxWindows; ++i) {
initializeWindowControl();
@@ -70,14 +69,17 @@ void Display::initializeLayout() {
layout->addStretch();
for (unsigned int i = 0; i < _nMaxWindows; ++i) {
_winCtrlLayouts.push_back(_windowControl[i]->initializeLayout());
_layoutWindowWrappers.push_back(new QWidget());
_layoutWindowWrappers.back()->setLayout(_winCtrlLayouts.back());
layoutWindows->addWidget(_layoutWindowWrappers.back());
QVBoxLayout* layoutForNextWindow = _windowControl[i]->initializeLayout();
_winCtrlLayouts.push_back(layoutForNextWindow);
QWidget* layoutWrapper = new QWidget();
layoutWrapper->setLayout(layoutForNextWindow);
_layoutWindowWrappers.push_back(layoutWrapper);
layoutWindows->addWidget(layoutWrapper);
if (i < (_nMaxWindows - 1)) {
_frameBorderLines.push_back(new QFrame());
_frameBorderLines.back()->setFrameShape(QFrame::VLine);
layoutWindows->addWidget(_frameBorderLines.back());
QFrame* frameForNextWindow = new QFrame();
frameForNextWindow->setFrameShape(QFrame::VLine);
_frameBorderLines.push_back(frameForNextWindow);
layoutWindows->addWidget(frameForNextWindow);
}
}
_nWindowsDisplayed = 1;
@@ -127,7 +129,6 @@ void Display::initializeWindowControl() {
unsigned int monitorNumForThisWindow = (_nWindowsAllocated >= 3) ? 1 : 0;
_windowControl.push_back(
new WindowControl(
_nMonitors,
monitorNumForThisWindow,
_nWindowsAllocated,
_monitorResolutions,
@@ -70,12 +70,12 @@ void FileSupport::saveCluster() {
if (_orientationWidget) {
sgct::config::Scene initScene;
initScene.orientation = _orientationWidget->orientationValue();
if (_cluster.nodes.size() == 0) {
_cluster.nodes.push_back(sgct::config::Node());
}
_cluster.nodes.clear();
sgct::config::Node tmpNode;
tmpNode.address = "localhost";
tmpNode.port = 20401;
_cluster.nodes.push_back(tmpNode);
_cluster.masterAddress = "localhost";
_cluster.nodes.back().address = "localhost";
_cluster.nodes.back().port = 20401;
_cluster.scene = std::move(initScene);
_cluster.firmSync = _orientationWidget->vsyncValue();
}
@@ -24,7 +24,6 @@
#include "sgctedit/orientation.h"
#include "sgctedit/display.h"
#include "sgctedit/orientationdialog.h"
Orientation::Orientation()
@@ -57,15 +56,10 @@ void Orientation::orientationDialog() {
_orientationDialog.exec();
}
sgct::quat Orientation::orientationValue() {
sgct::quat Orientation::orientationValue() const {
return _orientationValue;
}
bool Orientation::vsyncValue() {
bool Orientation::vsyncValue() const {
return (_checkBoxVsync->checkState() == Qt::Checked);
}
Orientation::~Orientation()
{
delete _layoutOrientationFull;
}
@@ -33,9 +33,9 @@ OrientationDialog::OrientationDialog(sgct::quat& orientation, QWidget* parent)
setWindowTitle("Global Orientation");
QVBoxLayout* layoutWindow = new QVBoxLayout(this);
_linePitch = new QLineEdit(this);
_lineRoll = new QLineEdit(this);
_lineYaw = new QLineEdit(this);
_linePitch = new QLineEdit;
_lineRoll = new QLineEdit;
_lineYaw = new QLineEdit;
_linePitch->setText(QString::number(_orientationValue.x));
_lineRoll->setText(QString::number(_orientationValue.z));
_lineYaw->setText(QString::number(_orientationValue.y));
@@ -51,21 +51,21 @@ OrientationDialog::OrientationDialog(sgct::quat& orientation, QWidget* parent)
_lineYaw->setValidator(validatorYaw);
}
{
QLabel* labelPitch = new QLabel(this);
QLabel* labelPitch = new QLabel;
labelPitch->setText("Pitch: ");
QHBoxLayout* layoutPitch = new QHBoxLayout;
layoutPitch->addStretch(1);
layoutPitch->addWidget(labelPitch);
layoutPitch->addWidget(_linePitch);
layoutWindow->addLayout(layoutPitch);
QLabel* labelRoll = new QLabel(this);
QLabel* labelRoll = new QLabel;
labelRoll ->setText("Roll: ");
QHBoxLayout* layoutRoll = new QHBoxLayout;
layoutRoll->addStretch(1);
layoutRoll->addWidget(labelRoll);
layoutRoll->addWidget(_lineRoll);
layoutWindow->addLayout(layoutRoll);
QLabel* labelYaw = new QLabel(this);
QLabel* labelYaw = new QLabel;
labelYaw ->setText("Yaw: ");
QHBoxLayout* layoutYaw = new QHBoxLayout;
layoutYaw->addStretch(1);
@@ -25,7 +25,7 @@
#include "sgctedit/sgctedit.h"
SgctEdit::SgctEdit(QWidget* parent, std::vector<sgct::config::Window>& windowList,
sgct::config::Cluster& cluster, const QList<QScreen*> screenList)
sgct::config::Cluster& cluster, const QList<QScreen*>& screenList)
: QDialog(parent)
, _cluster(cluster)
, _windowList(windowList)
@@ -35,13 +35,17 @@ SgctEdit::SgctEdit(QWidget* parent, std::vector<sgct::config::Window>& windowLis
createWidgets();
}
void SgctEdit::systemMonitorConfiguration(const QList<QScreen*> screenList) {
void SgctEdit::systemMonitorConfiguration(const QList<QScreen*>& screenList) {
size_t nScreensManaged = std::min(screenList.length(), 2);
for (size_t s = 0; s < nScreensManaged; ++s) {
int actualWidth = std::max(screenList[s]->size().width(),
screenList[s]->availableGeometry().width());
int actualHeight = std::max(screenList[s]->size().height(),
screenList[s]->availableGeometry().height());
int actualWidth = std::max(
screenList[s]->size().width(),
screenList[s]->availableGeometry().width()
);
int actualHeight = std::max(
screenList[s]->size().height(),
screenList[s]->availableGeometry().height()
);
_monitorSizeList.push_back({
screenList[s]->availableGeometry().x(),
screenList[s]->availableGeometry().y(),
@@ -119,13 +123,7 @@ std::string SgctEdit::saveFilename() {
}
SgctEdit::~SgctEdit() {
if (_orientationWidget) {
delete _orientationWidget;
}
if (_fileSupportWidget) {
delete _fileSupportWidget;
}
if (_displayLayout) {
delete _displayLayout;
}
delete _orientationWidget;
delete _fileSupportWidget;
delete _displayLayout;
}
@@ -26,17 +26,16 @@
#include "sgctedit/monitorbox.h"
#include "sgctedit/windowcontrol.h"
WindowControl::WindowControl(unsigned int nMonitors, unsigned int monitorIndex,
const unsigned int windowIndex,
WindowControl::WindowControl(unsigned int monitorIndex, const unsigned int windowIndex,
std::vector<QRect>& monitorDims,
const std::array<QString, 4> winColors, QWidget *parent)
: QWidget(parent)
, _nMonitors(nMonitors)
, _monIndex(monitorIndex)
, _index(windowIndex)
, _monitorResolutions(monitorDims)
, _colorsForWindows(winColors)
{
_nMonitors = _monitorResolutions.size();
createWidgets(parent);
}
@@ -374,15 +373,6 @@ void WindowControl::onSpoutSelection(int selectionState) {
}
}
template <typename T>
void WindowControl::enableProjectionOption(T* comboModel, int selectionIndex, bool enable)
{
auto* item = comboModel->item(selectionIndex);
if (item) {
item->setEnabled(enable);
}
}
void WindowControl::onMonitorChanged(int newSelection) {
_monIndex = newSelection;
if (_windowChangeCallback) {
@@ -408,15 +398,14 @@ void WindowControl::setDimensions(const QRectF& dimensions) {
}
void WindowControl::setWindowChangeCallback(
std::function<void(int, int, const QRectF&)> cb)
std::function<void(int, int, const QRectF&)> cb)
{
_windowChangeCallback = cb;
_windowChangeCallback = std::move(cb);
}
void WindowControl::setWebGuiChangeCallback(
std::function<void(unsigned int)> cb)
void WindowControl::setWebGuiChangeCallback(std::function<void(unsigned int)> cb)
{
_windowGuiCheckCallback = cb;
_windowGuiCheckCallback = std::move(cb);
}
void WindowControl::uncheckWebGuiOption() {