#1173 Made the legend a separate hide/show entity, and changed the overall layout of the well allocation plot

This commit is contained in:
Jacob Støren
2017-02-13 08:40:27 +01:00
parent 30ea467f0e
commit 321b9e2d62
12 changed files with 1490 additions and 1171 deletions

View File

@@ -27,6 +27,8 @@
#include <QBoxLayout>
#include <QLabel>
#include "RiuNightchartsWidget.h"
#include "cvfColor3.h"
@@ -52,18 +54,26 @@ RiuWellAllocationPlot::RiuWellAllocationPlot(RimWellAllocationPlot* plotDefiniti
m_titleLabel->setFont(font);
// White background
QPalette pal = this->palette();
pal.setColor(QPalette::Background, Qt::white);
this->setAutoFillBackground(true);
QPalette pal = this->palette();
pal.setColor(QPalette::Background, Qt::white);
this->setAutoFillBackground(true);
this->setPalette(pal);
mainLayout->addWidget(m_titleLabel, 0, Qt::AlignCenter);
QHBoxLayout* plotWidgetsLayout = new QHBoxLayout();
mainLayout->addLayout(plotWidgetsLayout, 10);
auto plotWidgetsLayout = new QHBoxLayout();
auto rightColumnLayout = new QVBoxLayout();
mainLayout->addLayout(plotWidgetsLayout);
plotWidgetsLayout->addLayout(rightColumnLayout);
m_legendWidget = new RiuNightchartsWidget(this);
rightColumnLayout->addWidget(m_legendWidget);
m_legendWidget->showPie(false);
QWidget* totalFlowAllocationWidget = m_plotDefinition->totalWellFlowPlot()->createViewWidget(this);
plotWidgetsLayout->addWidget(totalFlowAllocationWidget);
rightColumnLayout->addWidget(totalFlowAllocationWidget);
rightColumnLayout->addStretch();
QWidget* wellFlowWidget = m_plotDefinition->accumulatedWellFlowPlot()->createViewWidget(this);
plotWidgetsLayout->addWidget(wellFlowWidget);
@@ -106,6 +116,39 @@ void RiuWellAllocationPlot::hideTitle()
m_titleLabel->hide();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuWellAllocationPlot::showLegend(bool doShow)
{
if (doShow)
m_legendWidget->show();
else
m_legendWidget->hide();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuWellAllocationPlot::addLegendItem(const QString& name, const cvf::Color3f& color, float value)
{
QColor sliceColor(color.rByte(), color.gByte(), color.bByte());
m_legendWidget->addItem(name, sliceColor, value);
m_legendWidget->updateGeometry();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuWellAllocationPlot::clearLegend()
{
m_legendWidget->clear();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------