From 7f926a5a4d65899ea8d38573793ee71d6c0e0fe4 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Sun, 7 Apr 2019 18:16:31 +0200 Subject: [PATCH] Unify look of frames in 3d View using stylesheets --- .../UserInterface/RiuSimpleHistogramWidget.cpp | 8 +++++--- .../UserInterface/RiuSimpleHistogramWidget.h | 4 ++-- ApplicationCode/UserInterface/RiuViewer.cpp | 15 +++++++++------ ApplicationCode/UserInterface/RiuViewer.h | 2 +- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/ApplicationCode/UserInterface/RiuSimpleHistogramWidget.cpp b/ApplicationCode/UserInterface/RiuSimpleHistogramWidget.cpp index 112de9e693..13aceb22a0 100644 --- a/ApplicationCode/UserInterface/RiuSimpleHistogramWidget.cpp +++ b/ApplicationCode/UserInterface/RiuSimpleHistogramWidget.cpp @@ -27,8 +27,8 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuSimpleHistogramWidget::RiuSimpleHistogramWidget(QWidget * parent /*= 0*/, Qt::WindowFlags f /*= 0*/): -QWidget(parent, f) +RiuSimpleHistogramWidget::RiuSimpleHistogramWidget(const QString& objectName, QWidget * parent /*= 0*/, Qt::WindowFlags f /*= 0*/) + : QWidget(parent, f) { m_minPercentile = HUGE_VAL; m_maxPercentile = HUGE_VAL; @@ -41,6 +41,8 @@ QWidget(parent, f) m_height = 0; m_x = 0; m_y = 0; + + setObjectName(objectName); } //-------------------------------------------------------------------------------------------------- @@ -48,7 +50,7 @@ QWidget(parent, f) //-------------------------------------------------------------------------------------------------- void RiuSimpleHistogramWidget::paintEvent(QPaintEvent* event) { - QPainter painter(this); + QPainter painter(this); this->draw(&painter, 0, 0, this->width()-1, this->height()-1); } diff --git a/ApplicationCode/UserInterface/RiuSimpleHistogramWidget.h b/ApplicationCode/UserInterface/RiuSimpleHistogramWidget.h index 19230f2e57..9522a85b2b 100644 --- a/ApplicationCode/UserInterface/RiuSimpleHistogramWidget.h +++ b/ApplicationCode/UserInterface/RiuSimpleHistogramWidget.h @@ -30,14 +30,14 @@ class QStringList; class RiuSimpleHistogramWidget : public QWidget { public: - RiuSimpleHistogramWidget( QWidget * parent = nullptr, Qt::WindowFlags f = nullptr); + RiuSimpleHistogramWidget(const QString& objectName, QWidget * parent = nullptr, Qt::WindowFlags f = nullptr); void setHistogramData(double min, double max, const std::vector& histogram); void setPercentiles(double pmin, double pmax); void setMean(double mean) {m_mean = mean;} protected: - void paintEvent(QPaintEvent* event) override; + void paintEvent(QPaintEvent* event) override; private: void draw(QPainter *painter,int x, int y, int width, int height ); diff --git a/ApplicationCode/UserInterface/RiuViewer.cpp b/ApplicationCode/UserInterface/RiuViewer.cpp index 7f78135983..e24ac50f4b 100644 --- a/ApplicationCode/UserInterface/RiuViewer.cpp +++ b/ApplicationCode/UserInterface/RiuViewer.cpp @@ -53,6 +53,7 @@ #include "cafOverlayScaleLegend.h" #include "cafTitledOverlayFrame.h" #include "cafQStyledProgressBar.h" +#include "cafStyleSheetTools.h" #include "cvfCamera.h" #include "cvfFont.h" @@ -142,7 +143,7 @@ RiuViewer::RiuViewer(const QGLFormat& format, QWidget* parent) m_showAnimProgress = false; // Histogram - m_histogramWidget = new RiuSimpleHistogramWidget(); + m_histogramWidget = new RiuSimpleHistogramWidget("HistogramWidget"); m_showHistogram = false; m_viewerCommands = new RiuViewerCommands(this); @@ -1102,7 +1103,7 @@ void RiuViewer::updateTextAndTickMarkColorForOverlayItems() updateAxisCrossTextColor(); - updateOverlayItemsPalette(); + updateOverlayItemsStyle(); } //-------------------------------------------------------------------------------------------------- @@ -1118,14 +1119,14 @@ void RiuViewer::updateAxisCrossTextColor() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuViewer::updateOverlayItemsPalette() +void RiuViewer::updateOverlayItemsStyle() { QColor backgroundColor; QColor backgroundFrameColor; QColor contrastColor; { cvf::Color4f cvf_backgroundColor = mainCamera()->viewport()->clearColor(); - cvf_backgroundColor.a() = 0.8f; + cvf_backgroundColor.a() = 0.65f; cvf::Color4f cvf_backgroundFrameColor = cvf::Color4f(RiaColorTools::computeOffsetColor(cvf_backgroundColor.toColor3f(), 0.3f), 0.9f); @@ -1150,12 +1151,14 @@ void RiuViewer::updateOverlayItemsPalette() p.setColor(QPalette::Dark, backgroundFrameColor); p.setColor(QPalette::Mid, backgroundFrameColor); - m_infoLabel->setPalette(p); - m_histogramWidget->setPalette(p); + m_infoLabel->setStyleSheet(caf::StyleSheetTools::createFrameStyleSheet("QLabel", "InfoLabel", contrastColor, backgroundColor, backgroundFrameColor)); + m_histogramWidget->setStyleSheet(caf::StyleSheetTools::createFrameStyleSheet("", "HistogramWidget", contrastColor, backgroundColor, backgroundFrameColor)); + m_versionInfoLabel->setPalette(p); m_zScaleLabel->setPalette(p); QColor progressColor(Qt::green); progressColor.setAlphaF(0.8f); + backgroundColor.setAlphaF(0.8f); m_animationProgress->setTextBackgroundAndProgressColor(contrastColor, backgroundColor, backgroundFrameColor, progressColor); } diff --git a/ApplicationCode/UserInterface/RiuViewer.h b/ApplicationCode/UserInterface/RiuViewer.h index 91210746a2..7879dfd717 100644 --- a/ApplicationCode/UserInterface/RiuViewer.h +++ b/ApplicationCode/UserInterface/RiuViewer.h @@ -151,7 +151,7 @@ private: cvf::Color3f computeContrastColor() const; void updateAxisCrossTextColor(); - void updateOverlayItemsPalette(); + void updateOverlayItemsStyle(); void paintOverlayItems(QPainter* painter) override;