Skip to content

Commit

Permalink
Merge pull request #1 from palaeoware/fullscreentest
Browse files Browse the repository at this point in the history
Full screen mode
  • Loading branch information
alanspencer committed Oct 19, 2018
2 parents 6916fad + b9ac355 commit b6a190d
Show file tree
Hide file tree
Showing 7 changed files with 155 additions and 24 deletions.
7 changes: 4 additions & 3 deletions SPIERSview.pro
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ SOURCES += src/main.cpp \
src/vaxmlgroup.cpp \
src/vaxmlobject.cpp \
src/isosurface.cpp \
src/scalarfieldlayer.cpp

src/scalarfieldlayer.cpp \
src/fullscreenwindow.cpp

HEADERS += src/mainwindow.h \
src/darkstyletheme.h \
Expand All @@ -66,7 +66,8 @@ HEADERS += src/mainwindow.h \
src/vaxmlgroup.h \
src/vaxmlobject.h \
src/isosurface.h \
src/scalarfieldlayer.h
src/scalarfieldlayer.h \
src/fullscreenwindow.h

LIBS += -L$$PWD/../../../../msys64/mingw64/lib \
# VTK - Libary
Expand Down
31 changes: 31 additions & 0 deletions src/fullscreenwindow.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include <QHBoxLayout>
#include <QApplication>
#include <QDebug>
#include <QShortcut>

#include "fullscreenwindow.h"
#include "globals.h"

FullScreenWindow::FullScreenWindow(QWidget *parent, GlWidget *gl3widget)
: QDialog(parent)
{
glwidget = gl3widget;

// Included gere for testing in a windowed mode
/*
int nWidth = 1200;
int nHeight = 800;
if (parent != nullptr)
setGeometry(parent->x() + parent->width() / 2 - nWidth / 2,
parent->y() + parent->height() / 2 - nHeight / 2,
nWidth, nHeight);
else
resize(nWidth, nHeight);
*/

QHBoxLayout *fullScreenLayout = new QHBoxLayout(this);
fullScreenLayout->setContentsMargins(0, 0, 0, 0);
fullScreenLayout->addWidget(glwidget);
setLayout(fullScreenLayout);
glwidget->update();
}
15 changes: 15 additions & 0 deletions src/fullscreenwindow.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#ifndef FULLSCREENWINDOW_H
#define FULLSCREENWINDOW_H

#include <QDialog>

#include "gl3widget.h"

class FullScreenWindow : public QDialog
{
public:
FullScreenWindow(QWidget *parent, GlWidget *gl3widget);
GlWidget *glwidget;
};

#endif // FULLSCREENWINDOW_H
3 changes: 3 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ int main(int argc, char *argv[])
// This has the app draw at HiDPI scaling on HiDPI displays, usually two pixels for every one logical pixel
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);

// Set to allow the OpenGL context (ie. the same threads) to be shared between normal and full screen mode
QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts);

// This has QPixmap images use the @2x images when available
// See this bug for more details on how to get this right: https://bugreports.qt.io/browse/QTBUG-44486#comment-327410
#if (QT_VERSION >= 0x050600)
Expand Down
57 changes: 51 additions & 6 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3508,14 +3508,14 @@ bool MainWindow::eventFilter(QObject *object, QEvent *event)
ui->actionSave_Image_and_Apply_Step->activate(QAction::Trigger);
return true;
}
if (kevent->key() == Qt::Key_O && kevent->modifiers() == Qt::ControlModifier && ui->actionShow_All->isEnabled())
if (kevent->key() == Qt::Key_H && kevent->modifiers() == Qt::ControlModifier && ui->actionHide_All->isEnabled())
{
ui->actionShow_All->activate(QAction::Trigger);
ui->actionHide_All->activate(QAction::Trigger);
return true;
}
if (kevent->key() == Qt::Key_H && kevent->modifiers() == Qt::ControlModifier && ui->actionHide_All->isEnabled())
if (kevent->key() == Qt::Key_H && kevent->modifiers() == Qt::ShiftModifier && ui->actionShow_All->isEnabled())
{
ui->actionHide_All->activate(QAction::Trigger);
ui->actionShow_All->activate(QAction::Trigger);
return true;
}
if (kevent->key() == Qt::Key_I && kevent->modifiers() == Qt::ControlModifier && ui->actionInvert_Show->isEnabled())
Expand Down Expand Up @@ -3668,8 +3668,6 @@ bool MainWindow::eventFilter(QObject *object, QEvent *event)
ui->actionReset_to_default_position->activate(QAction::Trigger);
return true;
}

//More complex ones - same code works fine
if (kevent->key() == Qt::Key_A && kevent->modifiers() == Qt::ControlModifier && ui->actionAnaglyph_Stereo->isEnabled())
{
ui->actionAnaglyph_Stereo->activate(QAction::Trigger);
Expand All @@ -3680,6 +3678,21 @@ bool MainWindow::eventFilter(QObject *object, QEvent *event)
ui->actionSplit_Stereo->activate(QAction::Trigger);
return true;
}
if (kevent->key() == Qt::Key_P && kevent->modifiers() == Qt::ControlModifier && ui->actionNo_Stereo->isEnabled())
{
ui->actionNo_Stereo->activate(QAction::Trigger);
return true;
}
if (kevent->key() == Qt::Key_O && kevent->modifiers() == Qt::ControlModifier && ui->actionOrthographic_View->isEnabled())
{
ui->actionOrthographic_View->activate(QAction::Trigger);
return true;
}
if (kevent->key() == Qt::Key_Q && kevent->modifiers() == Qt::ControlModifier && ui->actionQuadBuffer_Stereo->isEnabled())
{
ui->actionQuadBuffer_Stereo->activate(QAction::Trigger);
return true;
}
if (kevent->key() == Qt::Key_M && kevent->modifiers() == Qt::ControlModifier && ui->actionMute_Colours->isEnabled())
{
ui->actionMute_Colours->activate(QAction::Trigger);
Expand Down Expand Up @@ -3730,6 +3743,11 @@ bool MainWindow::eventFilter(QObject *object, QEvent *event)
ui->actionAnimation_Panel->activate(QAction::Trigger);
return true;
}
if (kevent->key() == Qt::Key_F && kevent->modifiers() == Qt::ControlModifier)
{
on_actionFull_Screen_triggered();
return true;
}

//Now the object keys
if ( kevent->modifiers() == Qt::NoModifier)
Expand Down Expand Up @@ -3852,3 +3870,30 @@ void MainWindow::updateScreenRatio()

//qDebug() << "[SCREEN UPDATE] Current Screen = " << currentScreen << "Current Ratio = " << ratio;
}

/**
* @brief MainWindow::on_actionFull_Screen_triggered
*/
void MainWindow::on_actionFull_Screen_triggered()
{
if (isGLFullScreen == false)
{
fullScreenDialog = new FullScreenWindow(this, gl3widget);
fullScreenDialog->showFullScreen();
//fullScreenDialog->show();

isGLFullScreen = true;

//qDebug() << "[Full Screen Mode] Opening full screen mode";
}
else
{
gl3widget = fullScreenDialog->glwidget;
ui->frameVTK->layout()->addWidget(gl3widget);
fullScreenDialog->close();
gl3widget->update();
isGLFullScreen = false;

//qDebug() << "[Full Screen Mode] Closing full screen mode";
}
}
22 changes: 14 additions & 8 deletions src/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
#define MAINWINDOW_H

#include <QtWidgets/QMainWindow>
//#include "SVGlwidget.h"
#include "gl3widget.h"
#include <QtWidgets/QLabel>
#include <QTimer>
#include <QtWidgets/QListWidgetItem>
#include <QHBoxLayout>
#include <QtWidgets/QShortcut>

#include "gl3widget.h"
#include "fullscreenwindow.h"

class QTreeWidgetItem;

class vtkObject;
Expand Down Expand Up @@ -50,6 +51,7 @@ public slots:
private:

bool mainWindowReady = false;
bool isGLFullScreen = false;

int specificprogress;
QString specificlabel;
Expand All @@ -59,13 +61,16 @@ public slots:
void StripDownForVoxml();
void closeEvent(QCloseEvent *event);

QLabel *scalelabel, *ktrlabel;
FullScreenWindow *fullScreenDialog;

QTimer *StartTimer; //bodgy timer to get open working
QTimer *SpinTimer; //bodgy timer to get open working
QTimer *PBtimer; //update to progress bar
QLabel *scalelabel;
QLabel *ktrlabel;

QTime *time; //used by spin timer
QTimer *StartTimer;
QTimer *SpinTimer;
QTimer *PBtimer;

QTime *time;
void UnsetAllStereo();
void DrawChildObjects(QList <bool> selflags, int parent);
void RefreshOneItem(QTreeWidgetItem *item, int i);
Expand All @@ -84,8 +89,8 @@ public slots:
QString TransConvert(float trans);

void SetShininess(int s);
private slots:

private slots:
void on_actionSet_Resampling_triggered();
void on_actionZoom_In_triggered();
void on_actionZoom_Out_triggered();
Expand Down Expand Up @@ -216,6 +221,7 @@ private slots:
void on_actionIsland_Removal_Custom_triggered();
void on_actionBounding_Box_triggered();
void on_MultipleStepButton_pressed();
void on_actionFull_Screen_triggered();
};

extern MainWindow *MainWin;
Expand Down
44 changes: 37 additions & 7 deletions ui/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,7 @@
<property name="title">
<string>View</string>
</property>
<addaction name="actionObject_Panel"/>
<addaction name="actionPieces_Panel"/>
<addaction name="actionProgress_Bars"/>
<addaction name="actionInfo"/>
<addaction name="actionClip_Controls"/>
<addaction name="actionAnimation_Panel"/>
<addaction name="actionFull_Screen"/>
<addaction name="separator"/>
<addaction name="actionZoom_In"/>
<addaction name="actionZoom_Out"/>
Expand Down Expand Up @@ -323,12 +318,24 @@
<addaction name="separator"/>
<addaction name="actionAuto_Spin"/>
</widget>
<widget class="QMenu" name="menuWindow">
<property name="title">
<string>Window</string>
</property>
<addaction name="actionAnimation_Panel"/>
<addaction name="actionClip_Controls"/>
<addaction name="actionInfo"/>
<addaction name="actionPieces_Panel"/>
<addaction name="actionProgress_Bars"/>
<addaction name="actionObject_Panel"/>
</widget>
<addaction name="menuSPIERSview"/>
<addaction name="menuAnimation"/>
<addaction name="menuMode"/>
<addaction name="menuObjects"/>
<addaction name="menuScale"/>
<addaction name="menuView"/>
<addaction name="menuWindow"/>
<addaction name="menuHelp"/>
</widget>
<widget class="QToolBar" name="mainToolBar">
Expand Down Expand Up @@ -1219,11 +1226,14 @@
<string>Show All</string>
</property>
<property name="shortcut">
<string>Ctrl+O</string>
<string>Shift+H</string>
</property>
<property name="shortcutContext">
<enum>Qt::ApplicationShortcut</enum>
</property>
<property name="visible">
<bool>true</bool>
</property>
</action>
<action name="actionHide_All">
<property name="text">
Expand Down Expand Up @@ -1833,6 +1843,9 @@
<property name="text">
<string>QuadBuffer Stereo</string>
</property>
<property name="shortcut">
<string>Ctrl+Q</string>
</property>
</action>
<action name="actionNo_Stereo">
<property name="checkable">
Expand All @@ -1844,6 +1857,9 @@
<property name="text">
<string>Perspective</string>
</property>
<property name="shortcut">
<string>Ctrl+P</string>
</property>
</action>
<action name="actionInfo">
<property name="checkable">
Expand Down Expand Up @@ -2013,6 +2029,9 @@
<property name="text">
<string>Orthographic</string>
</property>
<property name="shortcut">
<string>Ctrl+O</string>
</property>
</action>
<action name="actionLarge_Move_Closer">
<property name="text">
Expand Down Expand Up @@ -2293,6 +2312,17 @@
<string>Report Bug/Issue/Feature Request</string>
</property>
</action>
<action name="actionFull_Screen">
<property name="text">
<string>Full Screen</string>
</property>
<property name="shortcut">
<string>Ctrl+F</string>
</property>
<property name="shortcutContext">
<enum>Qt::WindowShortcut</enum>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
Expand Down

0 comments on commit b6a190d

Please sign in to comment.