mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-12 22:39:09 -05:00
Completion of changes from initial code review
This commit is contained in:
@@ -46,10 +46,9 @@ class Display : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
Display(std::shared_ptr<MonitorBox> monitorRenderBox,
|
||||
std::vector<QRect>& monitorSizeList, const unsigned int nMaxWindows,
|
||||
const std::array<QString, 4> winColors);
|
||||
~Display();
|
||||
std::vector<WindowControl*> windowControls() const;
|
||||
std::vector<QRect>& monitorSizeList, unsigned int nMaxWindows,
|
||||
const std::array<QColor, 4>& winColors);
|
||||
std::vector<std::shared_ptr<WindowControl>> windowControls() const;
|
||||
unsigned int nWindows() const;
|
||||
void uncheckWebGuiOptions();
|
||||
|
||||
@@ -67,8 +66,8 @@ private:
|
||||
unsigned int _nWindowsAllocated = 0;
|
||||
unsigned int _nWindowsDisplayed = 0;
|
||||
unsigned int _nMaxWindows = 3;
|
||||
const std::array<QString, 4> _winColors;
|
||||
std::vector<WindowControl*> _windowControl;
|
||||
const std::array<QColor, 4>& _winColors;
|
||||
std::vector<std::shared_ptr<WindowControl>> _windowControl;
|
||||
QPushButton* _addWindowButton = nullptr;
|
||||
QPushButton* _removeWindowButton = nullptr;
|
||||
unsigned int _monitorIdx = 0;
|
||||
|
||||
@@ -38,6 +38,17 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
using ProjectionOptions = std::variant<
|
||||
sgct::config::NoProjection,
|
||||
sgct::config::CylindricalProjection,
|
||||
sgct::config::EquirectangularProjection,
|
||||
sgct::config::FisheyeProjection,
|
||||
sgct::config::PlanarProjection,
|
||||
sgct::config::ProjectionPlane,
|
||||
sgct::config::SphericalMirrorProjection,
|
||||
sgct::config::SpoutOutputProjection
|
||||
>;
|
||||
|
||||
class FileSupport : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
@@ -54,20 +65,17 @@ private slots:
|
||||
|
||||
private:
|
||||
bool isWindowFullscreen(unsigned int monitorIdx, sgct::ivec2 wDims);
|
||||
bool findGuiWindow(unsigned int& foundWindowIndex);
|
||||
std::optional<unsigned int> findGuiWindow();
|
||||
void saveCluster();
|
||||
void saveWindows();
|
||||
void saveUser();
|
||||
void saveProjectionInformation(bool isSpoutSelected, int projectionIndex,
|
||||
WindowControl* winControl, sgct::config::Viewport& viewport);
|
||||
void saveProjection_Spout(int projectionIndex, WindowControl* winControl,
|
||||
sgct::config::Viewport& viewport);
|
||||
void saveProjection_NonSpout(int projectionIndex, WindowControl* winControl,
|
||||
sgct::config::Viewport& viewport);
|
||||
void saveWindowsViewports();
|
||||
void saveWindowsDimensions(WindowControl* wCtrl);
|
||||
void saveWindowsWebGui(unsigned int wIdx);
|
||||
void saveWindowsFullScreen(WindowControl* wCtrl);
|
||||
ProjectionOptions saveProjectionInformation(
|
||||
std::shared_ptr<WindowControl> winControl);
|
||||
ProjectionOptions saveProjectionSpout(std::shared_ptr<WindowControl> winControl);
|
||||
ProjectionOptions saveProjectionNoSpout(std::shared_ptr<WindowControl> winControl);
|
||||
sgct::config::Viewport generateViewport();
|
||||
sgct::config::Window saveWindowsDimensions(std::shared_ptr<WindowControl> wCtrl);
|
||||
void saveWindowsWebGui(unsigned int wIdx, sgct::config::Window& win);
|
||||
|
||||
QHBoxLayout* _layoutButtonBox = nullptr;
|
||||
QPushButton* _saveButton = nullptr;
|
||||
|
||||
@@ -43,7 +43,7 @@ class MonitorBox : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
MonitorBox(QRect widgetDims, std::vector<QRect> monitorResolution,
|
||||
unsigned int nWindows, std::array<QString, 4> winColors);
|
||||
unsigned int nWindows, const std::array<QColor, 4>& winColors);
|
||||
void mapMonitorResolutionToWidgetCoordinates();
|
||||
void mapWindowResolutionToWidgetCoordinates(unsigned int mIdx, unsigned int wIdx,
|
||||
const QRectF& w);
|
||||
@@ -55,15 +55,15 @@ protected:
|
||||
void paintEvent(QPaintEvent* event) override;
|
||||
|
||||
private:
|
||||
void paintWidgetBorder(QPainter& painter, const int width, const int height);
|
||||
void paintWidgetBorder(QPainter& painter, int width, int height);
|
||||
void paintMonitorBackgrounds(QPainter& painter);
|
||||
void paintWindow(QPainter& painter, const size_t winIdx);
|
||||
void paintWindowBeyondBounds(QPainter& painter, const unsigned int winIdx);
|
||||
void paintWindowNumber(QPainter& painter, const unsigned int winIdx);
|
||||
void setPenSpecificToWindow(QPainter& painter, const unsigned int windowIdx,
|
||||
void paintWindow(QPainter& painter, size_t winIdx);
|
||||
void paintWindowBeyondBounds(QPainter& painter, unsigned int winIdx);
|
||||
void paintWindowNumber(QPainter& painter, unsigned int winIdx);
|
||||
void setPenSpecificToWindow(QPainter& painter, unsigned int windowIdx,
|
||||
bool visibleBorder);
|
||||
void computeScaledResolution_landscape(const float aspectRatio, const float maxWidth);
|
||||
void computeScaledResolution_portrait(const float aspectRatio, const float maxHeight);
|
||||
void computeScaledResolutionLandscape(float aspectRatio, float maxWidth);
|
||||
void computeScaledResolutionPortrait(float aspectRatio, float maxHeight);
|
||||
|
||||
unsigned int _maxNumMonitors = 2;
|
||||
QRectF _monitorWidgetSize;
|
||||
@@ -79,7 +79,7 @@ private:
|
||||
{0.f, 0.f, 0.f, 0.f}
|
||||
};
|
||||
unsigned int _nWindows = 1;
|
||||
const std::array<QString, 4> _colorsForWindows;
|
||||
const std::array<QColor, 4> _colorsForWindows;
|
||||
int _alphaWindowOpacity = 170;
|
||||
float _monitorScaleFactor = 1.0;
|
||||
bool _showLabel = false;
|
||||
|
||||
@@ -68,11 +68,11 @@ private:
|
||||
std::vector<sgct::config::Window>& _windowList;
|
||||
bool _saveSelected = false;
|
||||
unsigned int _nMaxWindows = 3;
|
||||
const std::array<QString, 4> _colorsForWindows = {
|
||||
"#2B9EC3",
|
||||
"#FCAB10",
|
||||
"#44AF69",
|
||||
"#F8333C"
|
||||
const std::array<QColor, 4> _colorsForWindows = {
|
||||
QColor(0x2B, 0x9E, 0xC3),
|
||||
QColor(0xFC, 0xAB, 0x10),
|
||||
QColor(0x44, 0xAF, 0x69),
|
||||
QColor(0xF8, 0x33, 0x3C)
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -39,49 +39,37 @@ class WindowControl : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
WindowControl(unsigned int monitorIndex, unsigned int windowIndex,
|
||||
std::vector<QRect>& monitorDims, const std::array<QString, 4> winColors,
|
||||
std::vector<QRect>& monitorDims, const QColor& winColor,
|
||||
QWidget *parent);
|
||||
~WindowControl();
|
||||
void setDimensions(const QRectF& dimensions);
|
||||
void setWindowChangeCallback(std::function<void(int, int, const QRectF&)> cb);
|
||||
void setWebGuiChangeCallback(std::function<void(unsigned int)> cb);
|
||||
void showWindowLabel(const bool show);
|
||||
void showWindowLabel(bool show);
|
||||
QVBoxLayout* initializeLayout();
|
||||
QRectF& dimensions();
|
||||
QLineEdit* lineEditSizeWidth();
|
||||
QLineEdit* lineEditSizeHeight();
|
||||
QLineEdit* lineEditSizeOffsetX();
|
||||
QLineEdit* lineEditSizeOffsetY();
|
||||
QCheckBox* checkBoxWindowDecor();
|
||||
QCheckBox* checkBoxWebGui();
|
||||
QCheckBox* checkBoxSpoutOutput();
|
||||
std::string windowName();
|
||||
sgct::ivec2 windowSize();
|
||||
sgct::ivec2 windowPos();
|
||||
bool isDecorated();
|
||||
bool isSpoutSelected();
|
||||
bool isGuiWindow();
|
||||
void enableGuiWindowSelection(bool enabled);
|
||||
std::string windowName() const;
|
||||
sgct::ivec2 windowSize() const;
|
||||
sgct::ivec2 windowPos() const;
|
||||
bool isDecorated() const;
|
||||
bool isSpoutSelected() const;
|
||||
bool isGuiWindow() const;
|
||||
void uncheckWebGuiOption();
|
||||
int projectionSelectedIndex();
|
||||
int qualitySelectedIndex();
|
||||
int qualitySelectedValue();
|
||||
unsigned int monitorNum();
|
||||
float fovH();
|
||||
float fovV();
|
||||
float heightOffset();
|
||||
enum ProjectionIndeces : unsigned int {
|
||||
int qualitySelectedValue() const;
|
||||
unsigned int monitorNum() const;
|
||||
float fovH() const;
|
||||
float fovV() const;
|
||||
float heightOffset() const;
|
||||
enum class ProjectionIndeces {
|
||||
Planar = 0,
|
||||
Fisheye,
|
||||
Spherical_Mirror,
|
||||
SphericalMirror,
|
||||
Cylindrical,
|
||||
Equirectangular
|
||||
};
|
||||
std::string ProjectionTypeNames[5] = {"Planar", "Fisheye", "Spherical Mirror",
|
||||
"Cylindrical", "Equirectangular"};
|
||||
std::string QualityTypeNames[10] = {"Low (256)", "Medium (512)", "High (1K)",
|
||||
"1.5K (1536)", "2K (2048)", "4K (4096)", "8K (8192)", "16K (16384)",
|
||||
"32K (32768)", "64K (65536)"};
|
||||
ProjectionIndeces projectionSelectedIndex() const;
|
||||
int QualityValues[10] = {256, 512, 1024, 1536, 2048, 4096, 8192, 16384,
|
||||
32768, 65536};
|
||||
|
||||
@@ -107,25 +95,6 @@ private:
|
||||
{1200.0, 340.0, 1280.0, 720.0},
|
||||
{50.0, 50.0, 1280.0, 720.0}
|
||||
};
|
||||
QList<QString> _projectionTypes = {
|
||||
QString::fromStdString(ProjectionTypeNames[ProjectionIndeces::Planar]),
|
||||
QString::fromStdString(ProjectionTypeNames[ProjectionIndeces::Fisheye]),
|
||||
QString::fromStdString(ProjectionTypeNames[ProjectionIndeces::Spherical_Mirror]),
|
||||
QString::fromStdString(ProjectionTypeNames[ProjectionIndeces::Cylindrical]),
|
||||
QString::fromStdString(ProjectionTypeNames[ProjectionIndeces::Equirectangular]),
|
||||
};
|
||||
QList<QString> _qualityTypes = {
|
||||
QString::fromStdString(QualityTypeNames[0]),
|
||||
QString::fromStdString(QualityTypeNames[1]),
|
||||
QString::fromStdString(QualityTypeNames[2]),
|
||||
QString::fromStdString(QualityTypeNames[3]),
|
||||
QString::fromStdString(QualityTypeNames[4]),
|
||||
QString::fromStdString(QualityTypeNames[5]),
|
||||
QString::fromStdString(QualityTypeNames[6]),
|
||||
QString::fromStdString(QualityTypeNames[7]),
|
||||
QString::fromStdString(QualityTypeNames[8]),
|
||||
QString::fromStdString(QualityTypeNames[9]),
|
||||
};
|
||||
QList<QString> _monitorNames = { "Monitor 1", "Monitor 2" };
|
||||
int _lineEditWidthFixed = 50;
|
||||
float _marginFractionOfWidgetSize = 0.025;
|
||||
@@ -134,13 +103,13 @@ private:
|
||||
unsigned int _index = 0;
|
||||
std::vector<QRect>& _monitorResolutions;
|
||||
int _maxWindowSizePixels = 10000;
|
||||
const std::array<QString, 4> _colorsForWindows;
|
||||
const QColor& _colorForWindow;
|
||||
QVBoxLayout* _layoutFullWindow = nullptr;
|
||||
QLabel* _labelWinNum = nullptr;
|
||||
QLineEdit* _size_x = nullptr;
|
||||
QLineEdit* _size_y = nullptr;
|
||||
QLineEdit* _offset_x = nullptr;
|
||||
QLineEdit* _offset_y = nullptr;
|
||||
QLineEdit* _sizeX = nullptr;
|
||||
QLineEdit* _sizeY = nullptr;
|
||||
QLineEdit* _offsetX = nullptr;
|
||||
QLineEdit* _offsetY = nullptr;
|
||||
QRectF _windowDims;
|
||||
QPushButton* _fullscreenButton = nullptr;
|
||||
QCheckBox* _checkBoxWindowDecor = nullptr;
|
||||
|
||||
@@ -32,8 +32,8 @@
|
||||
#include <string>
|
||||
|
||||
Display::Display(std::shared_ptr<MonitorBox> monitorRenderBox,
|
||||
std::vector<QRect>& monitorSizeList, const unsigned int nMaxWindows,
|
||||
const std::array<QString, 4> winColors)
|
||||
std::vector<QRect>& monitorSizeList, unsigned int nMaxWindows,
|
||||
const std::array<QColor, 4>& winColors)
|
||||
: _monBox(monitorRenderBox)
|
||||
, _monitorResolutions(monitorSizeList)
|
||||
, _nMaxWindows(nMaxWindows)
|
||||
@@ -50,12 +50,6 @@ Display::Display(std::shared_ptr<MonitorBox> monitorRenderBox,
|
||||
initializeLayout();
|
||||
}
|
||||
|
||||
Display::~Display() {
|
||||
for (WindowControl* w : _windowControl) {
|
||||
delete w;
|
||||
}
|
||||
}
|
||||
|
||||
void Display::initializeLayout() {
|
||||
QVBoxLayout* layout = new QVBoxLayout(this);
|
||||
{
|
||||
@@ -87,7 +81,7 @@ void Display::initializeLayout() {
|
||||
layout->addLayout(layoutWindows);
|
||||
}
|
||||
|
||||
std::vector<WindowControl*> Display::windowControls() const {
|
||||
std::vector<std::shared_ptr<WindowControl>> Display::windowControls() const {
|
||||
return _windowControl;
|
||||
}
|
||||
|
||||
@@ -118,7 +112,7 @@ void Display::showWindows() {
|
||||
}
|
||||
_removeWindowButton->setEnabled(_nWindowsDisplayed > 1);
|
||||
_addWindowButton->setEnabled(_nWindowsDisplayed != _nMaxWindows);
|
||||
for (WindowControl* w : _windowControl) {
|
||||
for (std::shared_ptr<WindowControl> w : _windowControl) {
|
||||
w->showWindowLabel(_nWindowsDisplayed > 1);
|
||||
}
|
||||
_monBox->setNumWindowsDisplayed(_nWindowsDisplayed);
|
||||
@@ -128,11 +122,11 @@ void Display::initializeWindowControl() {
|
||||
if (_nWindowsAllocated < _nMaxWindows) {
|
||||
unsigned int monitorNumForThisWindow = (_nWindowsAllocated >= 3) ? 1 : 0;
|
||||
_windowControl.push_back(
|
||||
new WindowControl(
|
||||
std::make_shared<WindowControl>(
|
||||
monitorNumForThisWindow,
|
||||
_nWindowsAllocated,
|
||||
_monitorResolutions,
|
||||
_winColors,
|
||||
_winColors[_nWindowsAllocated],
|
||||
this
|
||||
)
|
||||
);
|
||||
@@ -160,7 +154,7 @@ void Display::initializeWindowControl() {
|
||||
}
|
||||
|
||||
void Display::uncheckWebGuiOptions() {
|
||||
for (WindowControl* w : _windowControl) {
|
||||
for (std::shared_ptr<WindowControl> w : _windowControl) {
|
||||
w->uncheckWebGuiOption();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,97 +95,88 @@ bool FileSupport::isWindowFullscreen(unsigned int monitorIdx, sgct::ivec2 wDims)
|
||||
_monitors[monitorIdx].height() == wDims.y);
|
||||
}
|
||||
|
||||
bool FileSupport::findGuiWindow(unsigned int& foundWindowIndex) {
|
||||
std::optional<unsigned int> FileSupport::findGuiWindow() {
|
||||
unsigned int windowIndex = 0;
|
||||
for (unsigned int w = 0; w < _displayWidget->nWindows(); ++w) {
|
||||
if (_displayWidget->windowControls()[w]->isGuiWindow()) {
|
||||
foundWindowIndex = windowIndex;
|
||||
return true;
|
||||
return std::optional<unsigned int>(windowIndex);
|
||||
}
|
||||
windowIndex++;
|
||||
}
|
||||
return false;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
void FileSupport::saveWindows() {
|
||||
unsigned int windowIndex = 0;
|
||||
for (unsigned int w = 0; w < _displayWidget->nWindows(); ++w) {
|
||||
WindowControl* wCtrl = _displayWidget->windowControls()[w];
|
||||
_windowList.push_back(sgct::config::Window());
|
||||
saveWindowsViewports();
|
||||
saveProjectionInformation(
|
||||
wCtrl->isSpoutSelected(),
|
||||
wCtrl->projectionSelectedIndex(),
|
||||
wCtrl,
|
||||
_windowList.back().viewports.back()
|
||||
std::shared_ptr<WindowControl> wCtrl = _displayWidget->windowControls()[w];
|
||||
sgct::config::Window tmpWindow = saveWindowsDimensions(wCtrl);
|
||||
tmpWindow.viewports.push_back(generateViewport());
|
||||
tmpWindow.viewports.back().projection = saveProjectionInformation(wCtrl);
|
||||
tmpWindow.isDecorated = wCtrl->isDecorated();
|
||||
tmpWindow.isFullScreen = isWindowFullscreen(
|
||||
wCtrl->monitorNum(),
|
||||
wCtrl->windowSize()
|
||||
);
|
||||
saveWindowsDimensions(wCtrl);
|
||||
_windowList.back().isDecorated = wCtrl->isDecorated();
|
||||
saveWindowsFullScreen(wCtrl);
|
||||
saveWindowsWebGui(windowIndex);
|
||||
saveWindowsWebGui(windowIndex, tmpWindow);
|
||||
if (!wCtrl->windowName().empty()) {
|
||||
_windowList.back().name = wCtrl->windowName();
|
||||
tmpWindow.name = wCtrl->windowName();
|
||||
}
|
||||
_windowList.back().id = windowIndex++;
|
||||
tmpWindow.id = windowIndex++;
|
||||
_windowList.push_back(tmpWindow);
|
||||
}
|
||||
}
|
||||
|
||||
void FileSupport::saveWindowsViewports() {
|
||||
sgct::config::Viewport FileSupport::generateViewport() {
|
||||
sgct::config::Viewport vp;
|
||||
vp.isTracked = true;
|
||||
vp.position = {0.f, 0.f};
|
||||
vp.size = {1.f, 1.f};
|
||||
_windowList.back().viewports.push_back(std::move(vp));
|
||||
return vp;
|
||||
}
|
||||
|
||||
void FileSupport::saveWindowsDimensions(WindowControl* wCtrl) {
|
||||
_windowList.back().size = wCtrl->windowSize();
|
||||
_windowList.back().pos = {
|
||||
sgct::config::Window FileSupport::saveWindowsDimensions(
|
||||
std::shared_ptr<WindowControl> wCtrl)
|
||||
{
|
||||
sgct::config::Window tmpWindow;
|
||||
tmpWindow.size = wCtrl->windowSize();
|
||||
tmpWindow.pos = {
|
||||
_monitors[wCtrl->monitorNum()].x() + wCtrl->windowPos().x,
|
||||
_monitors[wCtrl->monitorNum()].y() + wCtrl->windowPos().y,
|
||||
};
|
||||
return tmpWindow;
|
||||
}
|
||||
|
||||
void FileSupport::saveWindowsWebGui(unsigned int wIdx) {
|
||||
_windowList.back().viewports.back().isTracked = true;
|
||||
unsigned int webGuiWindowIndex;
|
||||
bool isOneOfWindowsSetAsWebGui = findGuiWindow(webGuiWindowIndex);
|
||||
void FileSupport::saveWindowsWebGui(unsigned int wIdx, sgct::config::Window& win) {
|
||||
win.viewports.back().isTracked = true;
|
||||
std::optional<unsigned int> webGuiWindowIndex = findGuiWindow();
|
||||
bool isOneOfWindowsSetAsWebGui = webGuiWindowIndex.has_value();
|
||||
if (isOneOfWindowsSetAsWebGui) {
|
||||
if (wIdx == webGuiWindowIndex) {
|
||||
_windowList.back().viewports.back().isTracked = false;
|
||||
_windowList.back().tags.push_back("GUI");
|
||||
if (wIdx == webGuiWindowIndex.value()) {
|
||||
win.viewports.back().isTracked = false;
|
||||
win.tags.push_back("GUI");
|
||||
}
|
||||
_windowList.back().draw2D = (wIdx == webGuiWindowIndex);
|
||||
_windowList.back().draw3D = !(_windowList.back().draw2D.value());
|
||||
win.draw2D = (wIdx == webGuiWindowIndex.value());
|
||||
win.draw3D = !(win.draw2D.value());
|
||||
}
|
||||
}
|
||||
|
||||
void FileSupport::saveWindowsFullScreen(WindowControl* wCtrl) {
|
||||
bool isFullScreen = isWindowFullscreen(
|
||||
wCtrl->monitorNum(),
|
||||
wCtrl->windowSize()
|
||||
);
|
||||
if (isFullScreen) {
|
||||
_windowList.back().isFullScreen = true;
|
||||
}
|
||||
}
|
||||
|
||||
void FileSupport::saveProjectionInformation(bool isSpoutSelected, int projectionIndex,
|
||||
WindowControl* winControl, sgct::config::Viewport& viewport)
|
||||
ProjectionOptions FileSupport::saveProjectionInformation(
|
||||
std::shared_ptr<WindowControl> winControl)
|
||||
{
|
||||
if (isSpoutSelected) {
|
||||
saveProjection_Spout(projectionIndex, winControl, viewport);
|
||||
if (winControl->isSpoutSelected()) {
|
||||
return saveProjectionSpout(winControl);
|
||||
}
|
||||
else {
|
||||
saveProjection_NonSpout(projectionIndex, winControl, viewport);
|
||||
return saveProjectionNoSpout(winControl);
|
||||
}
|
||||
}
|
||||
|
||||
void FileSupport::saveProjection_Spout(int projectionIndex, WindowControl* winControl,
|
||||
sgct::config::Viewport& viewport)
|
||||
ProjectionOptions FileSupport::saveProjectionSpout(
|
||||
std::shared_ptr<WindowControl> winControl)
|
||||
{
|
||||
sgct::config::SpoutOutputProjection projection;
|
||||
switch(projectionIndex) {
|
||||
switch(winControl->projectionSelectedIndex()) {
|
||||
case WindowControl::ProjectionIndeces::Fisheye:
|
||||
projection.mapping
|
||||
= sgct::config::SpoutOutputProjection::Mapping::Fisheye;
|
||||
@@ -199,28 +190,28 @@ void FileSupport::saveProjection_Spout(int projectionIndex, WindowControl* winCo
|
||||
}
|
||||
projection.quality = winControl->qualitySelectedValue();
|
||||
projection.mappingSpoutName = "OpenSpace";
|
||||
viewport.projection = std::move(projection);
|
||||
return projection;
|
||||
}
|
||||
|
||||
void FileSupport::saveProjection_NonSpout(int projectionIndex, WindowControl* winControl,
|
||||
sgct::config::Viewport& viewport)
|
||||
ProjectionOptions FileSupport::saveProjectionNoSpout(
|
||||
std::shared_ptr<WindowControl> winControl)
|
||||
{
|
||||
switch(projectionIndex) {
|
||||
switch(winControl->projectionSelectedIndex()) {
|
||||
case WindowControl::ProjectionIndeces::Fisheye:
|
||||
{
|
||||
sgct::config::FisheyeProjection projection;
|
||||
projection.quality = winControl->qualitySelectedValue();
|
||||
projection.fov = 180.0;
|
||||
projection.tilt = 0.0;
|
||||
viewport.projection = std::move(projection);
|
||||
projection.fov = 180.f;
|
||||
projection.tilt = 0.f;
|
||||
return projection;
|
||||
}
|
||||
break;
|
||||
|
||||
case WindowControl::ProjectionIndeces::Spherical_Mirror:
|
||||
case WindowControl::ProjectionIndeces::SphericalMirror:
|
||||
{
|
||||
sgct::config::SphericalMirrorProjection projection;
|
||||
projection.quality = winControl->qualitySelectedValue();
|
||||
viewport.projection = std::move(projection);
|
||||
return projection;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -229,7 +220,7 @@ void FileSupport::saveProjection_NonSpout(int projectionIndex, WindowControl* wi
|
||||
sgct::config::CylindricalProjection projection;
|
||||
projection.quality = winControl->qualitySelectedValue();
|
||||
projection.heightOffset = winControl->heightOffset();
|
||||
viewport.projection = std::move(projection);
|
||||
return projection;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -237,7 +228,7 @@ void FileSupport::saveProjection_NonSpout(int projectionIndex, WindowControl* wi
|
||||
{
|
||||
sgct::config::EquirectangularProjection projection;
|
||||
projection.quality = winControl->qualitySelectedValue();
|
||||
viewport.projection = std::move(projection);
|
||||
return projection;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -250,7 +241,7 @@ void FileSupport::saveProjection_NonSpout(int projectionIndex, WindowControl* wi
|
||||
projection.fov.left = -projection.fov.right;
|
||||
projection.fov.up = winControl->fovV() / 2.0;
|
||||
projection.fov.down = -projection.fov.up;
|
||||
viewport.projection = std::move(projection);
|
||||
return projection;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
constexpr float MarginFractionOfWidgetSize = 0.025;
|
||||
|
||||
MonitorBox::MonitorBox(QRect widgetDims, std::vector<QRect> monitorResolution,
|
||||
unsigned int nWindows, std::array<QString, 4> winColors)
|
||||
unsigned int nWindows, const std::array<QColor, 4>& winColors)
|
||||
: _monitorWidgetSize(widgetDims)
|
||||
, _monitorResolution(monitorResolution)
|
||||
, _nWindows(nWindows)
|
||||
@@ -39,7 +39,6 @@ MonitorBox::MonitorBox(QRect widgetDims, std::vector<QRect> monitorResolution,
|
||||
}
|
||||
|
||||
void MonitorBox::paintEvent(QPaintEvent* event) {
|
||||
Q_UNUSED(event);
|
||||
QPainter painter(this);
|
||||
QPen pen = painter.pen();
|
||||
painter.setPen(pen);
|
||||
@@ -56,7 +55,7 @@ void MonitorBox::paintEvent(QPaintEvent* event) {
|
||||
}
|
||||
}
|
||||
|
||||
void MonitorBox::paintWidgetBorder(QPainter& painter, const int width, const int height) {
|
||||
void MonitorBox::paintWidgetBorder(QPainter& painter, int width, int height) {
|
||||
constexpr int Radius = 10;
|
||||
painter.setPen(QPen(Qt::gray, 4));
|
||||
painter.drawRoundedRect(0, 0, width - 1, height - 1, Radius, Radius);
|
||||
@@ -83,7 +82,7 @@ void MonitorBox::paintMonitorBackgrounds(QPainter& painter) {
|
||||
}
|
||||
}
|
||||
|
||||
void MonitorBox::paintWindowBeyondBounds(QPainter& painter, const unsigned int winIdx) {
|
||||
void MonitorBox::paintWindowBeyondBounds(QPainter& painter, unsigned int winIdx) {
|
||||
painter.setBrush(Qt::BDiagPattern);
|
||||
setPenSpecificToWindow(painter, winIdx, false);
|
||||
if (winIdx <= _windowRendering.size()) {
|
||||
@@ -93,11 +92,11 @@ void MonitorBox::paintWindowBeyondBounds(QPainter& painter, const unsigned int w
|
||||
painter.setBrush(Qt::NoBrush);
|
||||
}
|
||||
|
||||
void MonitorBox::paintWindow(QPainter& painter, const size_t winIdx) {
|
||||
void MonitorBox::paintWindow(QPainter& painter, size_t winIdx) {
|
||||
setPenSpecificToWindow(painter, winIdx, true);
|
||||
if (winIdx <= _windowRendering.size()) {
|
||||
painter.drawRect(_windowRendering[winIdx]);
|
||||
QColor fillColor = QColor(_colorsForWindows[winIdx]);
|
||||
QColor fillColor = _colorsForWindows[winIdx];
|
||||
fillColor.setAlpha(_alphaWindowOpacity);
|
||||
QBrush brush(fillColor);
|
||||
brush.setStyle(Qt::SolidPattern);
|
||||
@@ -106,7 +105,7 @@ void MonitorBox::paintWindow(QPainter& painter, const size_t winIdx) {
|
||||
}
|
||||
}
|
||||
|
||||
void MonitorBox::paintWindowNumber(QPainter& painter, const unsigned int winIdx) {
|
||||
void MonitorBox::paintWindowNumber(QPainter& painter, unsigned int winIdx) {
|
||||
QPointF textPos = QPointF(_windowRendering[winIdx].left() + 5,
|
||||
_windowRendering[winIdx].bottom() - 5);
|
||||
textPos.setX(std::clamp(textPos.x(), 0.0, _monitorWidgetSize.width() - 10));
|
||||
@@ -114,11 +113,11 @@ void MonitorBox::paintWindowNumber(QPainter& painter, const unsigned int winIdx)
|
||||
painter.drawText(textPos, QString::fromStdString(std::to_string(winIdx + 1)));
|
||||
}
|
||||
|
||||
void MonitorBox::setPenSpecificToWindow(QPainter& painter, const unsigned int windowIdx,
|
||||
void MonitorBox::setPenSpecificToWindow(QPainter& painter, unsigned int windowIdx,
|
||||
bool visibleBorder)
|
||||
{
|
||||
int penWidth = (visibleBorder) ? 1 : -1;
|
||||
painter.setPen(QPen(QColor(_colorsForWindows[windowIdx]), penWidth));
|
||||
painter.setPen(QPen(_colorsForWindows[windowIdx], penWidth));
|
||||
}
|
||||
|
||||
void MonitorBox::windowDimensionsChanged(unsigned int monitorIdx, unsigned int windowIdx,
|
||||
@@ -141,10 +140,10 @@ void MonitorBox::mapMonitorResolutionToWidgetCoordinates() {
|
||||
}
|
||||
float aspectRatio = maxWidth / maxHeight;
|
||||
if (aspectRatio >= 1.0) {
|
||||
computeScaledResolution_landscape(aspectRatio, maxWidth);
|
||||
computeScaledResolutionLandscape(aspectRatio, maxWidth);
|
||||
}
|
||||
else {
|
||||
computeScaledResolution_portrait(aspectRatio, maxHeight);
|
||||
computeScaledResolutionPortrait(aspectRatio, maxHeight);
|
||||
}
|
||||
for (size_t m = 0; m < _monitorResolution.size(); ++m) {
|
||||
_monitorDimensionsScaled.push_back({
|
||||
@@ -157,9 +156,7 @@ void MonitorBox::mapMonitorResolutionToWidgetCoordinates() {
|
||||
update();
|
||||
}
|
||||
|
||||
void MonitorBox::computeScaledResolution_landscape(const float aspectRatio,
|
||||
const float maxWidth)
|
||||
{
|
||||
void MonitorBox::computeScaledResolutionLandscape(float aspectRatio, float maxWidth) {
|
||||
_marginWidget = _monitorWidgetSize.width() * MarginFractionOfWidgetSize;
|
||||
float virtualWidth = _monitorWidgetSize.width()
|
||||
* (1.0 - MarginFractionOfWidgetSize * 2.0);
|
||||
@@ -174,9 +171,7 @@ void MonitorBox::computeScaledResolution_landscape(const float aspectRatio,
|
||||
}
|
||||
}
|
||||
|
||||
void MonitorBox::computeScaledResolution_portrait(const float aspectRatio,
|
||||
const float maxHeight)
|
||||
{
|
||||
void MonitorBox::computeScaledResolutionPortrait(float aspectRatio, float maxHeight) {
|
||||
_marginWidget = _monitorWidgetSize.height() * MarginFractionOfWidgetSize;
|
||||
float virtualHeight = _monitorWidgetSize.height()
|
||||
* (1.0 - MarginFractionOfWidgetSize * 2.0);
|
||||
|
||||
@@ -22,48 +22,77 @@
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include "sgctedit/display.h"
|
||||
#include "sgctedit/monitorbox.h"
|
||||
#include "sgctedit/windowcontrol.h"
|
||||
|
||||
WindowControl::WindowControl(unsigned int monitorIndex, const unsigned int windowIndex,
|
||||
#include <ghoul/fmt.h>
|
||||
#include "sgctedit/display.h"
|
||||
#include "sgctedit/monitorbox.h"
|
||||
|
||||
const std::string ProjectionTypeNames[5] = {"Planar", "Fisheye", "Spherical Mirror",
|
||||
"Cylindrical", "Equirectangular"};
|
||||
QList<QString> ProjectionTypes = {
|
||||
QString::fromStdString(ProjectionTypeNames[static_cast<int>(
|
||||
WindowControl::ProjectionIndeces::Planar)]),
|
||||
QString::fromStdString(ProjectionTypeNames[static_cast<int>(
|
||||
WindowControl::ProjectionIndeces::Fisheye)]),
|
||||
QString::fromStdString(ProjectionTypeNames[static_cast<int>(
|
||||
WindowControl::ProjectionIndeces::SphericalMirror)]),
|
||||
QString::fromStdString(ProjectionTypeNames[static_cast<int>(
|
||||
WindowControl::ProjectionIndeces::Cylindrical)]),
|
||||
QString::fromStdString(ProjectionTypeNames[static_cast<int>(
|
||||
WindowControl::ProjectionIndeces::Equirectangular)])
|
||||
};
|
||||
const QList<QString> QualityTypes = {
|
||||
"Low (256)",
|
||||
"Medium (512)",
|
||||
"High (1K)",
|
||||
"1.5K (1536)",
|
||||
"2K (2048)",
|
||||
"4K (4096)",
|
||||
"8K (8192)",
|
||||
"16K (16384)",
|
||||
"32K (32768)",
|
||||
"64K (65536)"
|
||||
};
|
||||
|
||||
WindowControl::WindowControl(unsigned int monitorIndex, unsigned int windowIndex,
|
||||
std::vector<QRect>& monitorDims,
|
||||
const std::array<QString, 4> winColors, QWidget *parent)
|
||||
const QColor& winColor, QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, _monIndex(monitorIndex)
|
||||
, _index(windowIndex)
|
||||
, _monitorResolutions(monitorDims)
|
||||
, _colorsForWindows(winColors)
|
||||
, _colorForWindow(winColor)
|
||||
{
|
||||
_nMonitors = _monitorResolutions.size();
|
||||
createWidgets(parent);
|
||||
}
|
||||
|
||||
WindowControl::~WindowControl() {
|
||||
delete _layoutFullWindow;
|
||||
}
|
||||
|
||||
void WindowControl::createWidgets(QWidget* parent) {
|
||||
_windowDims = defaultWindowSizes[_index];
|
||||
_size_x = new QLineEdit(
|
||||
QString::fromUtf8(std::to_string(int(_windowDims.width())).c_str()), parent);
|
||||
_size_y = new QLineEdit(
|
||||
QString::fromUtf8(std::to_string(int(_windowDims.height())).c_str()), parent);
|
||||
_offset_x = new QLineEdit(
|
||||
QString::fromUtf8(std::to_string(int(_windowDims.x())).c_str()), parent);
|
||||
_offset_y = new QLineEdit(
|
||||
QString::fromUtf8(std::to_string(int(_windowDims.y())).c_str()), parent);
|
||||
_sizeX = new QLineEdit(QString::number(_windowDims.width()), parent);
|
||||
_sizeY = new QLineEdit(QString::number(_windowDims.height()), parent);
|
||||
_offsetX = new QLineEdit(QString::number(_windowDims.x()), parent);
|
||||
_offsetY = new QLineEdit(QString::number(_windowDims.y()), parent);
|
||||
{
|
||||
QIntValidator* validatorSize_x = new QIntValidator(10, _maxWindowSizePixels);
|
||||
QIntValidator* validatorSize_y = new QIntValidator(10, _maxWindowSizePixels);
|
||||
QIntValidator* validatorOffset_x = new QIntValidator(
|
||||
QIntValidator* validatorSizeX = new QIntValidator(10, _maxWindowSizePixels);
|
||||
QIntValidator* validatorSizeY = new QIntValidator(10, _maxWindowSizePixels);
|
||||
QIntValidator* validatorOffsetX = new QIntValidator(
|
||||
-_maxWindowSizePixels,
|
||||
_maxWindowSizePixels
|
||||
);
|
||||
QIntValidator* validatorOffset_y = new QIntValidator(
|
||||
QIntValidator* validatorOffsetY = new QIntValidator(
|
||||
-_maxWindowSizePixels,
|
||||
_maxWindowSizePixels
|
||||
);
|
||||
_size_x->setValidator(validatorSize_x);
|
||||
_size_y->setValidator(validatorSize_y);
|
||||
_offset_x->setValidator(validatorOffset_x);
|
||||
_offset_y->setValidator(validatorOffset_y);
|
||||
_sizeX->setValidator(validatorSizeX);
|
||||
_sizeY->setValidator(validatorSizeY);
|
||||
_offsetX->setValidator(validatorOffsetX);
|
||||
_offsetY->setValidator(validatorOffsetY);
|
||||
}
|
||||
if (_nMonitors > 1) {
|
||||
_comboMonitorSelect = new QComboBox(this);
|
||||
@@ -77,10 +106,10 @@ void WindowControl::createWidgets(QWidget* parent) {
|
||||
_checkBoxWebGui = new QCheckBox("WebGUI only this window", this);
|
||||
_checkBoxSpoutOutput = new QCheckBox("Spout Output", this);
|
||||
_comboProjection = new QComboBox(this);
|
||||
_comboProjection->addItems(_projectionTypes);
|
||||
_comboProjection->addItems(ProjectionTypes);
|
||||
|
||||
_comboQuality = new QComboBox(this);
|
||||
_comboQuality->addItems(_qualityTypes);
|
||||
_comboQuality->addItems(QualityTypes);
|
||||
|
||||
{
|
||||
_lineFovH = new QLineEdit("80.0", parent);
|
||||
@@ -94,73 +123,62 @@ void WindowControl::createWidgets(QWidget* parent) {
|
||||
_lineHeightOffset->setValidator(validatorHtOff);
|
||||
}
|
||||
|
||||
connect(
|
||||
_size_x,
|
||||
SIGNAL(textChanged(const QString&)),
|
||||
this,
|
||||
SLOT(onSizeXChanged(const QString&))
|
||||
);
|
||||
connect(
|
||||
_size_y,
|
||||
SIGNAL(textChanged(const QString&)),
|
||||
this,
|
||||
SLOT(onSizeYChanged(const QString&))
|
||||
);
|
||||
connect(
|
||||
_offset_x,
|
||||
SIGNAL(textChanged(const QString&)),
|
||||
this,
|
||||
SLOT(onOffsetXChanged(const QString&))
|
||||
);
|
||||
connect(
|
||||
_offset_y,
|
||||
SIGNAL(textChanged(const QString&)),
|
||||
this,
|
||||
SLOT(onOffsetYChanged(const QString&))
|
||||
);
|
||||
connect(_sizeX, &QLineEdit::textChanged, this, &WindowControl::onSizeXChanged);
|
||||
connect(_sizeY, &QLineEdit::textChanged, this, &WindowControl::onSizeYChanged);
|
||||
connect(_offsetX, &QLineEdit::textChanged, this, &WindowControl::onOffsetXChanged);
|
||||
connect(_offsetY, &QLineEdit::textChanged, this, &WindowControl::onOffsetYChanged);
|
||||
connect(
|
||||
_comboMonitorSelect,
|
||||
SIGNAL(currentIndexChanged(int)),
|
||||
qOverload<int>(&QComboBox::currentIndexChanged),
|
||||
this,
|
||||
SLOT(onMonitorChanged(int))
|
||||
&WindowControl::onMonitorChanged
|
||||
);
|
||||
connect(_comboProjection,
|
||||
SIGNAL(currentIndexChanged(int)),
|
||||
connect(
|
||||
_comboProjection,
|
||||
qOverload<int>(&QComboBox::currentIndexChanged),
|
||||
this,
|
||||
SLOT(onProjectionChanged(int))
|
||||
&WindowControl::onProjectionChanged
|
||||
);
|
||||
connect(_checkBoxSpoutOutput,
|
||||
SIGNAL(stateChanged(int)),
|
||||
connect(
|
||||
_checkBoxSpoutOutput,
|
||||
&QCheckBox::stateChanged,
|
||||
this,
|
||||
SLOT(onSpoutSelection(int))
|
||||
&WindowControl::onSpoutSelection
|
||||
);
|
||||
connect(
|
||||
_checkBoxWebGui,
|
||||
SIGNAL(stateChanged(int)),
|
||||
&QCheckBox::stateChanged,
|
||||
this,
|
||||
SLOT(onWebGuiSelection(int))
|
||||
&WindowControl::onWebGuiSelection
|
||||
);
|
||||
connect(
|
||||
_fullscreenButton,
|
||||
&QPushButton::released,
|
||||
this,
|
||||
&WindowControl::onFullscreenClicked
|
||||
);
|
||||
connect(_fullscreenButton, SIGNAL(released()), this, SLOT(onFullscreenClicked()));
|
||||
}
|
||||
|
||||
QVBoxLayout* WindowControl::initializeLayout() {
|
||||
_layoutFullWindow = new QVBoxLayout();
|
||||
_layoutFullWindow = new QVBoxLayout;
|
||||
//Window size
|
||||
QVBoxLayout* layoutWindowCtrl = new QVBoxLayout();
|
||||
QVBoxLayout* layoutWindowCtrl = new QVBoxLayout;
|
||||
|
||||
_labelWinNum = new QLabel();
|
||||
_labelWinNum = new QLabel;
|
||||
_labelWinNum->setText("Window " + QString::number(_index + 1));
|
||||
QString colorStr = "QLabel { color : " + _colorsForWindows[_index] + "; }";
|
||||
QString colorStr = QString::fromStdString(
|
||||
fmt::format("QLabel {{ color : #{:02x}{:02x}{:02x}; }}",
|
||||
_colorForWindow.red(), _colorForWindow.green(), _colorForWindow.blue()));
|
||||
_labelWinNum->setStyleSheet(colorStr);
|
||||
|
||||
QHBoxLayout* layoutWinNum = new QHBoxLayout();
|
||||
QHBoxLayout* layoutWinNum = new QHBoxLayout;
|
||||
layoutWinNum->addStretch(1);
|
||||
layoutWinNum->addWidget(_labelWinNum);
|
||||
layoutWinNum->addStretch(1);
|
||||
layoutWindowCtrl->addLayout(layoutWinNum);
|
||||
|
||||
{
|
||||
QHBoxLayout* layoutName = new QHBoxLayout();
|
||||
QHBoxLayout* layoutName = new QHBoxLayout;
|
||||
QLabel* labelName = new QLabel(this);
|
||||
labelName->setText("Name: ");
|
||||
_windowName = new QLineEdit(this);
|
||||
@@ -172,63 +190,63 @@ QVBoxLayout* WindowControl::initializeLayout() {
|
||||
}
|
||||
|
||||
if (_nMonitors > 1) {
|
||||
QHBoxLayout* layoutMonitorNum = new QHBoxLayout();
|
||||
QHBoxLayout* layoutMonitorNum = new QHBoxLayout;
|
||||
layoutMonitorNum->addWidget(_comboMonitorSelect);
|
||||
layoutMonitorNum->addStretch(1);
|
||||
layoutWindowCtrl->addLayout(layoutMonitorNum);
|
||||
}
|
||||
_size_x->setFixedWidth(_lineEditWidthFixed);
|
||||
_size_y->setFixedWidth(_lineEditWidthFixed);
|
||||
_sizeX->setFixedWidth(_lineEditWidthFixed);
|
||||
_sizeY->setFixedWidth(_lineEditWidthFixed);
|
||||
{
|
||||
QLabel* labelSize = new QLabel(this);
|
||||
QLabel* labelDelim = new QLabel(this);
|
||||
QHBoxLayout* layoutSize = new QHBoxLayout();
|
||||
QHBoxLayout* layoutSize = new QHBoxLayout;
|
||||
layoutSize->addWidget(labelSize);
|
||||
labelSize->setText("Size:");
|
||||
labelSize->setFixedWidth(55);
|
||||
layoutSize->addWidget(_size_x);
|
||||
layoutSize->addWidget(_sizeX);
|
||||
layoutSize->addWidget(labelDelim);
|
||||
layoutSize->addWidget(_size_y);
|
||||
layoutSize->addWidget(_sizeY);
|
||||
layoutSize->addStretch(1);
|
||||
labelDelim->setText("x");
|
||||
labelDelim->setFixedWidth(9);
|
||||
layoutWindowCtrl->addLayout(layoutSize);
|
||||
}
|
||||
|
||||
_offset_x->setFixedWidth(_lineEditWidthFixed);
|
||||
_offset_y->setFixedWidth(_lineEditWidthFixed);
|
||||
_offsetX->setFixedWidth(_lineEditWidthFixed);
|
||||
_offsetY->setFixedWidth(_lineEditWidthFixed);
|
||||
{
|
||||
QLabel* labelOffset = new QLabel(this);
|
||||
QLabel* labelComma = new QLabel(this);
|
||||
QHBoxLayout* layoutOffset = new QHBoxLayout();
|
||||
QHBoxLayout* layoutOffset = new QHBoxLayout;
|
||||
layoutOffset->addWidget(labelOffset);
|
||||
labelOffset->setText("Offset:");
|
||||
labelOffset->setFixedWidth(55);
|
||||
layoutOffset->addWidget(_offset_x);
|
||||
layoutOffset->addWidget(_offsetX);
|
||||
layoutOffset->addWidget(labelComma);
|
||||
layoutOffset->addWidget(_offset_y);
|
||||
layoutOffset->addWidget(_offsetY);
|
||||
layoutOffset->addStretch(1);
|
||||
labelComma->setText(",");
|
||||
labelComma->setFixedWidth(9);
|
||||
layoutWindowCtrl->addLayout(layoutOffset);
|
||||
}
|
||||
{
|
||||
QHBoxLayout* layoutCheckboxesFull1 = new QHBoxLayout();
|
||||
QVBoxLayout* layoutCheckboxesFull2 = new QVBoxLayout();
|
||||
QHBoxLayout* layoutFullscreenButton = new QHBoxLayout();
|
||||
QHBoxLayout* layoutCheckboxesFull1 = new QHBoxLayout;
|
||||
QVBoxLayout* layoutCheckboxesFull2 = new QVBoxLayout;
|
||||
QHBoxLayout* layoutFullscreenButton = new QHBoxLayout;
|
||||
layoutFullscreenButton->addWidget(_fullscreenButton);
|
||||
layoutFullscreenButton->addStretch(1);
|
||||
layoutCheckboxesFull2->addLayout(layoutFullscreenButton);
|
||||
QHBoxLayout* layoutCBoxWindowDecor = new QHBoxLayout();
|
||||
QHBoxLayout* layoutCBoxWindowDecor = new QHBoxLayout;
|
||||
layoutCBoxWindowDecor->addWidget(_checkBoxWindowDecor);
|
||||
layoutCBoxWindowDecor->addStretch(1);
|
||||
layoutCheckboxesFull2->addLayout(layoutCBoxWindowDecor);
|
||||
QHBoxLayout* _layoutCBoxWebGui= new QHBoxLayout();
|
||||
QHBoxLayout* _layoutCBoxWebGui= new QHBoxLayout;
|
||||
_layoutCBoxWebGui->addWidget(_checkBoxWebGui);
|
||||
_layoutCBoxWebGui->addStretch(1);
|
||||
layoutCheckboxesFull2->addLayout(_layoutCBoxWebGui);
|
||||
QVBoxLayout* layoutProjectionGroup = new QVBoxLayout();
|
||||
QHBoxLayout* layoutComboProjection = new QHBoxLayout();
|
||||
QVBoxLayout* layoutProjectionGroup = new QVBoxLayout;
|
||||
QHBoxLayout* layoutComboProjection = new QHBoxLayout;
|
||||
layoutComboProjection->addWidget(_comboProjection);
|
||||
layoutComboProjection->addStretch(1);
|
||||
layoutProjectionGroup->addLayout(layoutComboProjection);
|
||||
@@ -236,33 +254,33 @@ QVBoxLayout* WindowControl::initializeLayout() {
|
||||
borderProjectionGroup->setFrameStyle(QFrame::StyledPanel | QFrame::Plain);
|
||||
borderProjectionGroup->setLayout(layoutProjectionGroup);
|
||||
borderProjectionGroup->setVisible(true);
|
||||
QHBoxLayout* layoutCBoxSpoutOutput= new QHBoxLayout();
|
||||
QHBoxLayout* layoutCBoxSpoutOutput= new QHBoxLayout;
|
||||
layoutCBoxSpoutOutput->addWidget(_checkBoxSpoutOutput);
|
||||
layoutCBoxSpoutOutput->addStretch(1);
|
||||
layoutProjectionGroup->addLayout(layoutCBoxSpoutOutput);
|
||||
QHBoxLayout* layoutComboQuality = new QHBoxLayout();
|
||||
_labelQuality = new QLabel();
|
||||
QHBoxLayout* layoutComboQuality = new QHBoxLayout;
|
||||
_labelQuality = new QLabel;
|
||||
_labelQuality->setText("Quality:");
|
||||
layoutComboQuality->addWidget(_labelQuality);
|
||||
layoutComboQuality->addWidget(_comboQuality);
|
||||
layoutComboQuality->addStretch(1);
|
||||
layoutProjectionGroup->addLayout(layoutComboQuality);
|
||||
QHBoxLayout* layoutFovH = new QHBoxLayout();
|
||||
_labelFovH = new QLabel();
|
||||
QHBoxLayout* layoutFovH = new QHBoxLayout;
|
||||
_labelFovH = new QLabel;
|
||||
_labelFovH->setText("Horizontal FOV:");
|
||||
layoutFovH->addWidget(_labelFovH);
|
||||
layoutFovH->addWidget(_lineFovH);
|
||||
layoutFovH->addStretch(1);
|
||||
QHBoxLayout* layoutFovV = new QHBoxLayout();
|
||||
_labelFovV = new QLabel();
|
||||
QHBoxLayout* layoutFovV = new QHBoxLayout;
|
||||
_labelFovV = new QLabel;
|
||||
_labelFovV->setText("Vertical FOV:");
|
||||
layoutFovV->addWidget(_labelFovV);
|
||||
layoutFovV->addWidget(_lineFovV);
|
||||
layoutFovV->addStretch(1);
|
||||
layoutProjectionGroup->addLayout(layoutFovH);
|
||||
layoutProjectionGroup->addLayout(layoutFovV);
|
||||
QHBoxLayout* layoutHeightOffset = new QHBoxLayout();
|
||||
_labelHeightOffset = new QLabel();
|
||||
QHBoxLayout* layoutHeightOffset = new QHBoxLayout;
|
||||
_labelHeightOffset = new QLabel;
|
||||
_labelHeightOffset->setText("Height Offset:");
|
||||
layoutHeightOffset->addWidget(_labelHeightOffset);
|
||||
layoutHeightOffset->addWidget(_lineHeightOffset);
|
||||
@@ -277,49 +295,40 @@ QVBoxLayout* WindowControl::initializeLayout() {
|
||||
_layoutFullWindow->addLayout(layoutWindowCtrl);
|
||||
|
||||
_comboProjection->setCurrentIndex(0);
|
||||
onProjectionChanged(0);
|
||||
onProjectionChanged(static_cast<unsigned int>(ProjectionIndeces::Planar));
|
||||
_comboQuality->setCurrentIndex(2);
|
||||
|
||||
return _layoutFullWindow;
|
||||
}
|
||||
|
||||
void WindowControl::showWindowLabel(const bool show) {
|
||||
void WindowControl::showWindowLabel(bool show) {
|
||||
_labelWinNum->setVisible(show);
|
||||
}
|
||||
|
||||
void WindowControl::onSizeXChanged(const QString& newText) {
|
||||
std::string x = newText.toStdString();
|
||||
if (!x.empty()) {
|
||||
_windowDims.setWidth(std::stoi(x));
|
||||
}
|
||||
_windowDims.setWidth(newText.toInt());
|
||||
if (_windowChangeCallback) {
|
||||
_windowChangeCallback(_monIndex, _index, _windowDims);
|
||||
}
|
||||
}
|
||||
|
||||
void WindowControl::onSizeYChanged(const QString& newText) {
|
||||
std::string y = newText.toStdString();
|
||||
if (!y.empty()) {
|
||||
_windowDims.setHeight(std::stoi(y));
|
||||
}
|
||||
_windowDims.setHeight(newText.toInt());
|
||||
if (_windowChangeCallback) {
|
||||
_windowChangeCallback(_monIndex, _index, _windowDims);
|
||||
}
|
||||
}
|
||||
|
||||
void WindowControl::onOffsetXChanged(const QString& newText) {
|
||||
std::string xOffset = newText.toStdString();
|
||||
float prevWidth = _windowDims.width();
|
||||
try {
|
||||
if (!xOffset.empty()) {
|
||||
_windowDims.setX(std::stoi(xOffset));
|
||||
_windowDims.setWidth(prevWidth);
|
||||
}
|
||||
_windowDims.setX(newText.toInt());
|
||||
_windowDims.setWidth(prevWidth);
|
||||
if (_windowChangeCallback) {
|
||||
_windowChangeCallback(_monIndex, _index, _windowDims);
|
||||
}
|
||||
}
|
||||
catch (...) {
|
||||
catch (std::exception &e) {
|
||||
//The QIntValidator ensures that the range is a +/- integer
|
||||
//However, it's possible to enter only a - character which
|
||||
//causes an exception throw, which is ignored here (when user
|
||||
@@ -328,34 +337,27 @@ void WindowControl::onOffsetXChanged(const QString& newText) {
|
||||
}
|
||||
|
||||
void WindowControl::onOffsetYChanged(const QString& newText) {
|
||||
std::string yOffset = newText.toStdString();
|
||||
float prevHeight = _windowDims.height();
|
||||
try {
|
||||
if (!yOffset.empty()) {
|
||||
_windowDims.setY(std::stoi(yOffset));
|
||||
_windowDims.setHeight(prevHeight);
|
||||
}
|
||||
_windowDims.setY(newText.toInt());
|
||||
_windowDims.setHeight(prevHeight);
|
||||
if (_windowChangeCallback) {
|
||||
_windowChangeCallback(_monIndex, _index, _windowDims);
|
||||
}
|
||||
}
|
||||
catch (...) {
|
||||
catch (std::exception &e) {
|
||||
//See comment in onOffsetXChanged
|
||||
}
|
||||
}
|
||||
|
||||
void WindowControl::onFullscreenClicked() {
|
||||
_offset_x->setText("0");
|
||||
_offset_y->setText("0");
|
||||
_size_x->setText(QString::number(_monitorResolutions[_monIndex].width()));
|
||||
_size_y->setText(QString::number(_monitorResolutions[_monIndex].height()));
|
||||
_offsetX->setText("0");
|
||||
_offsetY->setText("0");
|
||||
_sizeX->setText(QString::number(_monitorResolutions[_monIndex].width()));
|
||||
_sizeY->setText(QString::number(_monitorResolutions[_monIndex].height()));
|
||||
_checkBoxWindowDecor->setCheckState(Qt::Unchecked);
|
||||
}
|
||||
|
||||
void WindowControl::enableGuiWindowSelection(bool enabled) {
|
||||
_checkBoxWebGui->setEnabled(enabled);
|
||||
}
|
||||
|
||||
void WindowControl::onWebGuiSelection(int selectionState) {
|
||||
if (_windowGuiCheckCallback && (selectionState == Qt::Checked)) {
|
||||
_windowGuiCheckCallback(_index);
|
||||
@@ -364,11 +366,16 @@ void WindowControl::onWebGuiSelection(int selectionState) {
|
||||
|
||||
void WindowControl::onSpoutSelection(int selectionState) {
|
||||
if (selectionState == Qt::Checked) {
|
||||
int currentProjectionSelection = _comboProjection->currentIndex();
|
||||
WindowControl::ProjectionIndeces currentProjectionSelection;
|
||||
currentProjectionSelection = static_cast<WindowControl::ProjectionIndeces>(
|
||||
_comboProjection->currentIndex()
|
||||
);
|
||||
if ((currentProjectionSelection != ProjectionIndeces::Equirectangular) &&
|
||||
(currentProjectionSelection != ProjectionIndeces::Fisheye))
|
||||
{
|
||||
_comboProjection->setCurrentIndex(ProjectionIndeces::Equirectangular);
|
||||
_comboProjection->setCurrentIndex(
|
||||
static_cast<int>(ProjectionIndeces::Equirectangular)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -381,20 +388,18 @@ void WindowControl::onMonitorChanged(int newSelection) {
|
||||
}
|
||||
|
||||
void WindowControl::onProjectionChanged(int newSelection) {
|
||||
_comboQuality->setVisible(newSelection != ProjectionIndeces::Planar);
|
||||
_labelQuality->setVisible(newSelection != ProjectionIndeces::Planar);
|
||||
_labelFovH->setVisible(newSelection == ProjectionIndeces::Planar);
|
||||
_lineFovH->setVisible(newSelection == ProjectionIndeces::Planar);
|
||||
_labelFovV->setVisible(newSelection == ProjectionIndeces::Planar);
|
||||
_lineFovV->setVisible(newSelection == ProjectionIndeces::Planar);
|
||||
_labelHeightOffset->setVisible(newSelection == ProjectionIndeces::Cylindrical);
|
||||
_lineHeightOffset->setVisible(newSelection == ProjectionIndeces::Cylindrical);
|
||||
_checkBoxSpoutOutput->setVisible(newSelection == ProjectionIndeces::Fisheye
|
||||
|| newSelection == ProjectionIndeces::Equirectangular);
|
||||
}
|
||||
|
||||
void WindowControl::setDimensions(const QRectF& dimensions) {
|
||||
_windowDims = dimensions;
|
||||
WindowControl::ProjectionIndeces selected
|
||||
= static_cast<WindowControl::ProjectionIndeces>(newSelection);
|
||||
_comboQuality->setVisible(selected != ProjectionIndeces::Planar);
|
||||
_labelQuality->setVisible(selected != ProjectionIndeces::Planar);
|
||||
_labelFovH->setVisible(selected == ProjectionIndeces::Planar);
|
||||
_lineFovH->setVisible(selected == ProjectionIndeces::Planar);
|
||||
_labelFovV->setVisible(selected == ProjectionIndeces::Planar);
|
||||
_lineFovV->setVisible(selected == ProjectionIndeces::Planar);
|
||||
_labelHeightOffset->setVisible(selected == ProjectionIndeces::Cylindrical);
|
||||
_lineHeightOffset->setVisible(selected == ProjectionIndeces::Cylindrical);
|
||||
_checkBoxSpoutOutput->setVisible(selected == ProjectionIndeces::Fisheye
|
||||
|| selected == ProjectionIndeces::Equirectangular);
|
||||
}
|
||||
|
||||
void WindowControl::setWindowChangeCallback(
|
||||
@@ -416,22 +421,6 @@ QRectF& WindowControl::dimensions() {
|
||||
return _windowDims;
|
||||
}
|
||||
|
||||
QLineEdit* WindowControl::lineEditSizeWidth() {
|
||||
return _size_x;
|
||||
}
|
||||
|
||||
QLineEdit* WindowControl::lineEditSizeHeight() {
|
||||
return _size_y;
|
||||
}
|
||||
|
||||
QLineEdit* WindowControl::lineEditSizeOffsetX() {
|
||||
return _offset_x;
|
||||
}
|
||||
|
||||
QLineEdit* WindowControl::lineEditSizeOffsetY() {
|
||||
return _offset_y;
|
||||
}
|
||||
|
||||
QCheckBox* WindowControl::checkBoxWindowDecor() {
|
||||
return _checkBoxWindowDecor;
|
||||
}
|
||||
@@ -444,66 +433,58 @@ QCheckBox* WindowControl::checkBoxSpoutOutput() {
|
||||
return _checkBoxSpoutOutput;
|
||||
}
|
||||
|
||||
std::string WindowControl::windowName() {
|
||||
std::string WindowControl::windowName() const {
|
||||
return _windowName->text().toStdString();
|
||||
}
|
||||
|
||||
sgct::ivec2 WindowControl::windowSize() {
|
||||
sgct::ivec2 WindowControl::windowSize() const {
|
||||
return {
|
||||
stoi(_size_x->text().toStdString()),
|
||||
stoi(_size_y->text().toStdString())
|
||||
_sizeX->text().toInt(),
|
||||
_sizeY->text().toInt()
|
||||
};
|
||||
}
|
||||
|
||||
sgct::ivec2 WindowControl::windowPos() {
|
||||
sgct::ivec2 WindowControl::windowPos() const {
|
||||
return {
|
||||
stoi(_offset_x->text().toStdString()),
|
||||
stoi(_offset_y->text().toStdString())
|
||||
_offsetX->text().toInt(),
|
||||
_offsetY->text().toInt()
|
||||
};
|
||||
}
|
||||
|
||||
bool WindowControl::isDecorated() {
|
||||
bool WindowControl::isDecorated() const {
|
||||
return (_checkBoxWindowDecor->checkState() == Qt::Checked);
|
||||
}
|
||||
|
||||
bool WindowControl::isGuiWindow() {
|
||||
bool WindowControl::isGuiWindow() const {
|
||||
return (_checkBoxWebGui->checkState() == Qt::Checked);
|
||||
}
|
||||
|
||||
bool WindowControl::isSpoutSelected() {
|
||||
bool WindowControl::isSpoutSelected() const {
|
||||
return (_checkBoxSpoutOutput->checkState() == Qt::Checked);
|
||||
}
|
||||
|
||||
int WindowControl::projectionSelectedIndex() {
|
||||
return _comboProjection->currentIndex();
|
||||
WindowControl::ProjectionIndeces WindowControl::projectionSelectedIndex() const {
|
||||
return
|
||||
static_cast<WindowControl::ProjectionIndeces>(_comboProjection->currentIndex());
|
||||
}
|
||||
|
||||
int WindowControl::qualitySelectedIndex() {
|
||||
return _comboQuality->currentIndex();
|
||||
}
|
||||
|
||||
int WindowControl::qualitySelectedValue() {
|
||||
int WindowControl::qualitySelectedValue() const {
|
||||
return QualityValues[_comboQuality->currentIndex()];
|
||||
}
|
||||
|
||||
float WindowControl::fovH() {
|
||||
float WindowControl::fovH() const {
|
||||
return _lineFovH->text().toFloat();
|
||||
}
|
||||
|
||||
float WindowControl::fovV() {
|
||||
float WindowControl::fovV() const {
|
||||
return _lineFovV->text().toFloat();
|
||||
}
|
||||
|
||||
float WindowControl::heightOffset() {
|
||||
float WindowControl::heightOffset() const {
|
||||
return _lineHeightOffset->text().toFloat();
|
||||
}
|
||||
|
||||
unsigned int WindowControl::monitorNum() {
|
||||
unsigned int WindowControl::monitorNum() const {
|
||||
return _monIndex;
|
||||
}
|
||||
|
||||
WindowControl::~WindowControl()
|
||||
{
|
||||
delete _layoutFullWindow;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user