diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2023-01-26 22:15:16 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2023-01-26 22:15:16 +0100 |
commit | 484a705e0daf95c95679ad7599278f102f1fe558 (patch) | |
tree | d3b012d45bce3f1fbb55954f681439c8d5153802 /pose-widget | |
parent | 29ec855c58bd4e8f20f061056626c1060126dc26 (diff) |
pose-widget: add grid lines
Diffstat (limited to 'pose-widget')
-rw-r--r-- | pose-widget/images/grid-dark.png | bin | 0 -> 26862 bytes | |||
-rw-r--r-- | pose-widget/images/grid-light.png | bin | 0 -> 29026 bytes | |||
-rw-r--r-- | pose-widget/pose-widget.cpp | 11 | ||||
-rw-r--r-- | pose-widget/pose-widget.hpp | 3 | ||||
-rw-r--r-- | pose-widget/posewidget.qrc | 2 |
5 files changed, 16 insertions, 0 deletions
diff --git a/pose-widget/images/grid-dark.png b/pose-widget/images/grid-dark.png Binary files differnew file mode 100644 index 00000000..8665fc30 --- /dev/null +++ b/pose-widget/images/grid-dark.png diff --git a/pose-widget/images/grid-light.png b/pose-widget/images/grid-light.png Binary files differnew file mode 100644 index 00000000..83b844c0 --- /dev/null +++ b/pose-widget/images/grid-light.png 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 @@ <qresource prefix="/"> <file>images/side1.png</file> <file>images/side6.png</file> + <file>images/grid-light.png</file> + <file>images/grid-dark.png</file> </qresource> </RCC> |