summaryrefslogtreecommitdiffhomepage
path: root/pose-widget
diff options
context:
space:
mode:
Diffstat (limited to 'pose-widget')
-rw-r--r--pose-widget/glwidget.cpp17
-rw-r--r--pose-widget/glwidget.h4
2 files changed, 18 insertions, 3 deletions
diff --git a/pose-widget/glwidget.cpp b/pose-widget/glwidget.cpp
index 5de26eef..b9aec303 100644
--- a/pose-widget/glwidget.cpp
+++ b/pose-widget/glwidget.cpp
@@ -6,13 +6,14 @@
*/
#include "glwidget.h"
+#include "opentrack/is-window-visible.hpp"
+#include "opentrack-compat/pi-constant.hpp"
#include <cmath>
#include <algorithm>
-
#include <QPainter>
#include <QPaintEvent>
-GLWidget::GLWidget(QWidget *parent) : QWidget(parent)
+GLWidget::GLWidget(QWidget *parent) : QWidget(parent), visible(true)
{
Q_INIT_RESOURCE(posewidget);
@@ -25,7 +26,8 @@ GLWidget::~GLWidget()
{
}
-void GLWidget::paintEvent ( QPaintEvent * event ) {
+void GLWidget::paintEvent (QPaintEvent * event)
+{
QPainter p(this);
project_quad_texture();
p.drawImage(event->rect(), image);
@@ -33,6 +35,15 @@ void GLWidget::paintEvent ( QPaintEvent * event ) {
void GLWidget::rotateBy(float xAngle, float yAngle, float zAngle, float x, float y, float z)
{
+ if (visible_timer.elapsed_ms() > 2000)
+ {
+ visible = is_window_visible(this);
+ visible_timer.start();
+ }
+
+ if (!visible)
+ return;
+
using std::sin;
using std::cos;
diff --git a/pose-widget/glwidget.h b/pose-widget/glwidget.h
index 0d48ede9..96187856 100644
--- a/pose-widget/glwidget.h
+++ b/pose-widget/glwidget.h
@@ -12,6 +12,7 @@
#include <QPixmap>
#include "opentrack/plugin-api.hpp"
#include "opentrack/simple-mat.hpp"
+#include "opentrack-compat/timer.hpp"
#ifdef BUILD_pose_widget
# define POSE_WIDGET_EXPORT Q_DECL_EXPORT
@@ -37,9 +38,12 @@ private:
vec3 project2(const vec3& point);
void project_quad_texture();
static inline vec3 normal(const vec3& p1, const vec3& p2, const vec3& p3);
+
rmat rotation;
vec3 translation;
QImage front;
QImage back;
QImage image;
+ Timer visible_timer;
+ bool visible;
};