From 484a705e0daf95c95679ad7599278f102f1fe558 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 26 Jan 2023 22:15:16 +0100 Subject: pose-widget: add grid lines --- pose-widget/images/grid-dark.png | Bin 0 -> 26862 bytes pose-widget/images/grid-light.png | Bin 0 -> 29026 bytes pose-widget/pose-widget.cpp | 11 +++++++++++ pose-widget/pose-widget.hpp | 3 +++ pose-widget/posewidget.qrc | 2 ++ 5 files changed, 16 insertions(+) create mode 100644 pose-widget/images/grid-dark.png create mode 100644 pose-widget/images/grid-light.png (limited to 'pose-widget') diff --git a/pose-widget/images/grid-dark.png b/pose-widget/images/grid-dark.png new file mode 100644 index 00000000..8665fc30 Binary files /dev/null and b/pose-widget/images/grid-dark.png differ diff --git a/pose-widget/images/grid-light.png b/pose-widget/images/grid-light.png new file mode 100644 index 00000000..83b844c0 Binary files /dev/null and b/pose-widget/images/grid-light.png differ diff --git a/pose-widget/pose-widget.cpp b/pose-widget/pose-widget.cpp index 7c1f19c0..51d86609 100644 --- a/pose-widget/pose-widget.cpp +++ b/pose-widget/pose-widget.cpp @@ -22,6 +22,7 @@ namespace pose_widget_impl { pose_widget::pose_widget(QWidget* parent) : QWidget(parent) { QPainter p; + p.setRenderHint(QPainter::SmoothPixmapTransform); #ifdef TEST //draw rectangle frame around of Octopus, only if TEST defined p.begin(&front); @@ -56,6 +57,14 @@ pose_widget::pose_widget(QWidget* parent) : QWidget(parent) #endif } +void pose_widget::set_grid_background(bool dark_theme) +{ + if (dark_theme) + background = QImage(":/images/grid-dark.png"); + else + background = QImage(":/images/grid-light.png"); +} + void pose_widget::present(double yaw, double pitch, double roll, double x, double y, double z) { T = { x, y, z }; @@ -94,6 +103,8 @@ void pose_widget::paintEvent(QPaintEvent*) { p.fillRect(rect(), palette().brush(backgroundRole())); + if (!background.isNull()) + p.drawImage(rect(), background); // draw axes p.save(); p.setPen(QPen(Qt::gray, 1, Qt::SolidLine)); diff --git a/pose-widget/pose-widget.hpp b/pose-widget/pose-widget.hpp index 9152e960..53ecc644 100644 --- a/pose-widget/pose-widget.hpp +++ b/pose-widget/pose-widget.hpp @@ -27,6 +27,7 @@ public: explicit pose_widget(QWidget *parent = nullptr); void present(double xAngle, double yAngle, double zAngle, double x, double y, double z); QCheckBox mirror{"Mirror", this}; + void set_grid_background(bool dark_theme); private: void resizeEvent(QResizeEvent *event) override; void paintEvent(QPaintEvent*) override; @@ -35,6 +36,8 @@ private: QImage front{QImage{":/images/side1.png"}.convertToFormat(QImage::Format_ARGB32)}; QImage back {QImage{":/images/side6.png"}.convertToFormat(QImage::Format_ARGB32) .mirrored(true,false)}; + QImage background; + QImage shine {QImage{front.width(), front.height(), QImage::Format_ARGB32}}; QImage shadow{QImage{front.width(), front.height(), QImage::Format_ARGB32}}; }; diff --git a/pose-widget/posewidget.qrc b/pose-widget/posewidget.qrc index e799432f..636151e0 100644 --- a/pose-widget/posewidget.qrc +++ b/pose-widget/posewidget.qrc @@ -2,5 +2,7 @@ images/side1.png images/side6.png + images/grid-light.png + images/grid-dark.png -- cgit v1.2.3