mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-09 23:16:00 -06:00
#4238 Increase the size of grid cross plot legends if window has been decreased and then increased again
This commit is contained in:
parent
11b078c1a9
commit
a168f8a206
@ -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);
|
||||
|
@ -23,9 +23,9 @@
|
||||
#include <QWidget>
|
||||
|
||||
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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user