diff --git a/ApplicationCode/UserInterface/RiuCvfOverlayItemWidget.cpp b/ApplicationCode/UserInterface/RiuCvfOverlayItemWidget.cpp index 2d2f2407dd..03ef42752b 100644 --- a/ApplicationCode/UserInterface/RiuCvfOverlayItemWidget.cpp +++ b/ApplicationCode/UserInterface/RiuCvfOverlayItemWidget.cpp @@ -20,6 +20,7 @@ #include "RiaApplication.h" +#include "cafTitledOverlayFrame.h" #include "cafViewer.h" #include "cvfqtUtils.h" @@ -59,16 +60,17 @@ RiuCvfOverlayItemWidget::~RiuCvfOverlayItemWidget() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuCvfOverlayItemWidget::updateFromOverlayItem( cvf::OverlayItem * item) +void RiuCvfOverlayItemWidget::updateFromOverlayItem( caf::TitledOverlayFrame * item) { - // Use the render size of the overlayItem (sizeHint should be renamed) - - unsigned int width = item->sizeHint().x(); - unsigned int height = item->sizeHint().y(); + unsigned int width = item->renderSize().x(); + unsigned int height = item->renderSize().y(); QGLFormat glFormat; glFormat.setDirectRendering(RiaApplication::instance()->useShaders()); + // Enforce no border to avoid + item->setBackgroundFrameColor(cvf::Color4f(0, 0, 0, 0)); + caf::Viewer* viewer = new caf::Viewer(glFormat, nullptr); cvf::OpenGLContext* cvfOglContext = viewer->cvfOpenGLContext(); viewer->resize(width, height); diff --git a/ApplicationCode/UserInterface/RiuCvfOverlayItemWidget.h b/ApplicationCode/UserInterface/RiuCvfOverlayItemWidget.h index f635f95e56..75b0013a23 100644 --- a/ApplicationCode/UserInterface/RiuCvfOverlayItemWidget.h +++ b/ApplicationCode/UserInterface/RiuCvfOverlayItemWidget.h @@ -23,9 +23,9 @@ #include class QLabel; -namespace cvf +namespace caf { - class OverlayItem; +class TitledOverlayFrame; } //================================================================================================== @@ -40,7 +40,7 @@ public: explicit RiuCvfOverlayItemWidget(QWidget* parent = nullptr, QWidget* widgetToSnapTo = nullptr); ~RiuCvfOverlayItemWidget() override; - void updateFromOverlayItem( cvf::OverlayItem * item); + void updateFromOverlayItem( caf::TitledOverlayFrame* item); // virtual QSize sizeHint() const override; // virtual QSize minimumSizeHint() const override; diff --git a/ApplicationCode/UserInterface/RiuGridCrossQwtPlot.cpp b/ApplicationCode/UserInterface/RiuGridCrossQwtPlot.cpp index 84057e0dac..8a5f516603 100644 --- a/ApplicationCode/UserInterface/RiuGridCrossQwtPlot.cpp +++ b/ApplicationCode/UserInterface/RiuGridCrossQwtPlot.cpp @@ -134,14 +134,11 @@ void RiuGridCrossQwtPlot::updateLegendSizesToMatchPlot() if (pairIt != m_legendWidgets.end()) { RiuCvfOverlayItemWidget* overlayWidget = pairIt->second; - if (overlayWidget->isVisible()) + caf::TitledOverlayFrame* overlayItem = curveSet->legendConfig()->titledOverlayFrame(); + if (resizeOverlayItemToFitPlot(overlayItem)) { - caf::TitledOverlayFrame* overlayItem = curveSet->legendConfig()->titledOverlayFrame(); - if (resizeOverlayItemToFitPlot(overlayItem)) - { - anyLegendResized = true; - overlayWidget->updateFromOverlayItem(overlayItem); - } + anyLegendResized = true; + overlayWidget->updateFromOverlayItem(overlayItem); } } } @@ -257,6 +254,7 @@ void RiuGridCrossQwtPlot::updateLegendLayout() if (pairIt != m_legendWidgets.end()) { RiuCvfOverlayItemWidget* overlayWidget = pairIt->second; + // Show only one copy of each legend type if (!legendTypes.count(curveSet->groupParameter())) { @@ -293,6 +291,7 @@ void RiuGridCrossQwtPlot::resizeEvent(QResizeEvent* e) bool RiuGridCrossQwtPlot::resizeOverlayItemToFitPlot(caf::TitledOverlayFrame* overlayItem) { QSize plotSize = this->canvas()->contentsRect().size(); + cvf::Vec2ui existingRenderSize = overlayItem->renderSize(); cvf::Vec2ui legendSize = overlayItem->preferredSize(); bool sizeAltered = false; @@ -308,6 +307,12 @@ bool RiuGridCrossQwtPlot::resizeOverlayItemToFitPlot(caf::TitledOverlayFrame* ov sizeAltered = true; } overlayItem->setRenderSize(legendSize); + + if (legendSize.x() != existingRenderSize.x() || legendSize.y() != existingRenderSize.y()) + { + sizeAltered = true; + } + return sizeAltered; }