mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#1173 Made the legend a separate hide/show entity, and changed the overall layout of the well allocation plot
This commit is contained in:
parent
30ea467f0e
commit
321b9e2d62
@ -10,6 +10,7 @@ ${CEE_CURRENT_LIST_DIR}RimFlowPlotCollection.h
|
||||
${CEE_CURRENT_LIST_DIR}RimWellAllocationPlot.h
|
||||
${CEE_CURRENT_LIST_DIR}RimTotalWellAllocationPlot.h
|
||||
${CEE_CURRENT_LIST_DIR}RimWellFlowRateCurve.h
|
||||
${CEE_CURRENT_LIST_DIR}RimWellAllocationPlotLegend.h
|
||||
)
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
@ -18,6 +19,7 @@ ${CEE_CURRENT_LIST_DIR}RimFlowPlotCollection.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RimWellAllocationPlot.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RimTotalWellAllocationPlot.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RimWellFlowRateCurve.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RimWellAllocationPlotLegend.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
|
@ -180,6 +180,7 @@ void RimTotalWellAllocationPlot::loadDataAndUpdate()
|
||||
QWidget* RimTotalWellAllocationPlot::createViewWidget(QWidget* mainWindowParent)
|
||||
{
|
||||
m_wellTotalAllocationPlotWidget = new RiuNightchartsWidget(mainWindowParent);
|
||||
m_wellTotalAllocationPlotWidget->showLegend(false);
|
||||
return m_wellTotalAllocationPlotWidget;
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,110 +1,114 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2017 Statoil ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "RimViewWindow.h"
|
||||
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafPdmPtrField.h"
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
class RimEclipseResultCase;
|
||||
class RimEclipseWell;
|
||||
class RimFlowDiagSolution;
|
||||
class RimTotalWellAllocationPlot;
|
||||
class RimWellLogPlot;
|
||||
class RiuWellAllocationPlot;
|
||||
class RimWellLogTrack;
|
||||
|
||||
namespace caf {
|
||||
class PdmOptionItemInfo;
|
||||
}
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
class RimWellAllocationPlot : public RimViewWindow
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RimWellAllocationPlot();
|
||||
virtual ~RimWellAllocationPlot();
|
||||
|
||||
void setFromSimulationWell(RimEclipseWell* simWell);
|
||||
|
||||
void setDescription(const QString& description);
|
||||
QString description() const;
|
||||
|
||||
void loadDataAndUpdate();
|
||||
|
||||
virtual QWidget* viewWidget() override;
|
||||
virtual void zoomAll() override;
|
||||
|
||||
RimWellLogPlot* accumulatedWellFlowPlot();
|
||||
RimTotalWellAllocationPlot* totalWellFlowPlot();
|
||||
|
||||
|
||||
QString wellName() const;
|
||||
|
||||
void removeFromMdiAreaAndDeleteViewWidget();
|
||||
|
||||
protected:
|
||||
// Overridden PDM methods
|
||||
virtual caf::PdmFieldHandle* userDescriptionField() { return &m_userName; }
|
||||
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
|
||||
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override;
|
||||
|
||||
virtual QImage snapshotWindowContent() override;
|
||||
|
||||
private:
|
||||
void updateFromWell();
|
||||
|
||||
void addStackedCurve(const QString& tracerName,
|
||||
const std::vector<double>& connNumbers,
|
||||
const std::vector<double>& accFlow,
|
||||
RimWellLogTrack* plotTrack);
|
||||
|
||||
void updateWidgetTitleWindowTitle();
|
||||
static QString wellStatusTextForTimeStep(const QString& wellName, const RimEclipseResultCase* eclipseResultCase, size_t timeStep);
|
||||
|
||||
// RimViewWindow overrides
|
||||
|
||||
virtual QWidget* createViewWidget(QWidget* mainWindowParent) override;
|
||||
virtual void deleteViewWidget() override;
|
||||
|
||||
private:
|
||||
caf::PdmField<bool> m_showPlotTitle;
|
||||
caf::PdmField<QString> m_userName;
|
||||
|
||||
caf::PdmPtrField<RimEclipseResultCase*> m_case;
|
||||
caf::PdmField<QString> m_wellName;
|
||||
caf::PdmField<int> m_timeStep;
|
||||
caf::PdmPtrField<RimFlowDiagSolution*> m_flowDiagSolution;
|
||||
|
||||
QPointer<RiuWellAllocationPlot> m_wellAllocationPlotWidget;
|
||||
|
||||
caf::PdmChildField<RimWellLogPlot*> m_accumulatedWellFlowPlot;
|
||||
caf::PdmChildField<RimTotalWellAllocationPlot*> m_totalWellAllocationPlot;
|
||||
};
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2017 Statoil ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "RimViewWindow.h"
|
||||
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafPdmPtrField.h"
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
class RimEclipseResultCase;
|
||||
class RimEclipseWell;
|
||||
class RimFlowDiagSolution;
|
||||
class RimTotalWellAllocationPlot;
|
||||
class RimWellAllocationPlotLegend;
|
||||
class RimWellLogPlot;
|
||||
class RiuWellAllocationPlot;
|
||||
class RimWellLogTrack;
|
||||
|
||||
namespace caf {
|
||||
class PdmOptionItemInfo;
|
||||
}
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
class RimWellAllocationPlot : public RimViewWindow
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RimWellAllocationPlot();
|
||||
virtual ~RimWellAllocationPlot();
|
||||
|
||||
void setFromSimulationWell(RimEclipseWell* simWell);
|
||||
|
||||
void setDescription(const QString& description);
|
||||
QString description() const;
|
||||
|
||||
void loadDataAndUpdate();
|
||||
|
||||
virtual QWidget* viewWidget() override;
|
||||
virtual void zoomAll() override;
|
||||
|
||||
RimWellLogPlot* accumulatedWellFlowPlot();
|
||||
RimTotalWellAllocationPlot* totalWellFlowPlot();
|
||||
|
||||
|
||||
QString wellName() const;
|
||||
|
||||
void removeFromMdiAreaAndDeleteViewWidget();
|
||||
|
||||
void showPlotLegend(bool doShow);
|
||||
protected:
|
||||
// Overridden PDM methods
|
||||
virtual caf::PdmFieldHandle* userDescriptionField() { return &m_userName; }
|
||||
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
|
||||
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override;
|
||||
|
||||
virtual QImage snapshotWindowContent() override;
|
||||
|
||||
private:
|
||||
void updateFromWell();
|
||||
|
||||
void addStackedCurve(const QString& tracerName,
|
||||
const std::vector<double>& connNumbers,
|
||||
const std::vector<double>& accFlow,
|
||||
RimWellLogTrack* plotTrack);
|
||||
|
||||
void updateWidgetTitleWindowTitle();
|
||||
static QString wellStatusTextForTimeStep(const QString& wellName, const RimEclipseResultCase* eclipseResultCase, size_t timeStep);
|
||||
|
||||
// RimViewWindow overrides
|
||||
|
||||
virtual QWidget* createViewWidget(QWidget* mainWindowParent) override;
|
||||
virtual void deleteViewWidget() override;
|
||||
|
||||
private:
|
||||
caf::PdmField<bool> m_showPlotTitle;
|
||||
caf::PdmField<QString> m_userName;
|
||||
|
||||
caf::PdmPtrField<RimEclipseResultCase*> m_case;
|
||||
caf::PdmField<QString> m_wellName;
|
||||
caf::PdmField<int> m_timeStep;
|
||||
caf::PdmPtrField<RimFlowDiagSolution*> m_flowDiagSolution;
|
||||
|
||||
QPointer<RiuWellAllocationPlot> m_wellAllocationPlotWidget;
|
||||
|
||||
caf::PdmChildField<RimWellLogPlot*> m_accumulatedWellFlowPlot;
|
||||
caf::PdmChildField<RimTotalWellAllocationPlot*> m_totalWellAllocationPlot;
|
||||
caf::PdmChildField<RimWellAllocationPlotLegend*> m_wellAllocationPlotLegend;
|
||||
|
||||
};
|
||||
|
@ -0,0 +1,63 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2017 Statoil ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RimWellAllocationPlotLegend.h"
|
||||
#include "RimWellAllocationPlot.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimWellAllocationPlotLegend, "WellAllocationPlotLegend");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimWellAllocationPlotLegend::RimWellAllocationPlotLegend()
|
||||
{
|
||||
CAF_PDM_InitObject("Well Allocation Plot Legend", ":/newIcon16x16.png", "", "");
|
||||
CAF_PDM_InitField(&m_showLegend, "ShowPlotLegend", true, "Show Plot Legend", "", "", "");
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimWellAllocationPlotLegend::~RimWellAllocationPlotLegend()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::PdmFieldHandle* RimWellAllocationPlotLegend::objectToggleField()
|
||||
{
|
||||
return &m_showLegend;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellAllocationPlotLegend::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
|
||||
{
|
||||
if (changedField == &m_showLegend)
|
||||
{
|
||||
RimWellAllocationPlot* walp;
|
||||
firstAncestorOrThisOfType(walp);
|
||||
|
||||
if (walp) walp->showPlotLegend(m_showLegend());
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,47 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2017 Statoil ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
|
||||
class RimWellAllocationPlotLegend : public caf::PdmObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RimWellAllocationPlotLegend();
|
||||
virtual ~RimWellAllocationPlotLegend();
|
||||
|
||||
bool isShowingLegend() { return m_showLegend();}
|
||||
|
||||
protected:
|
||||
|
||||
virtual caf::PdmFieldHandle* objectToggleField() override;
|
||||
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
|
||||
|
||||
private:
|
||||
caf::PdmField<bool> m_showLegend;
|
||||
|
||||
};
|
||||
|
@ -25,6 +25,9 @@
|
||||
RiuNightchartsWidget::RiuNightchartsWidget(QWidget* parent) :
|
||||
QWidget(parent)
|
||||
{
|
||||
m_showLegend = true;
|
||||
m_showPie = true;
|
||||
updateSizePolicy();
|
||||
clear();
|
||||
}
|
||||
|
||||
@ -36,6 +39,51 @@ void RiuNightchartsWidget::setType(Nightcharts::type t)
|
||||
m_chart.setType(t);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuNightchartsWidget::showLegend(bool doShow)
|
||||
{
|
||||
m_showLegend = doShow;
|
||||
updateSizePolicy();
|
||||
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuNightchartsWidget::showPie(bool doShow)
|
||||
{
|
||||
m_showPie = doShow;
|
||||
updateSizePolicy();
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuNightchartsWidget::updateSizePolicy()
|
||||
{
|
||||
if (m_showPie && m_showLegend)
|
||||
{
|
||||
this->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
||||
}
|
||||
else if (m_showPie && !m_showLegend )
|
||||
{
|
||||
this->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
|
||||
}
|
||||
else if (!m_showPie && m_showLegend )
|
||||
{
|
||||
this->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -45,8 +93,49 @@ void RiuNightchartsWidget::clear()
|
||||
m_chart.setType(Nightcharts::Pie);
|
||||
m_chart.setLegendType(Nightcharts::Vertical);
|
||||
|
||||
m_marginLeft = 16;
|
||||
m_marginTop = 16;
|
||||
m_marginLeft = 10;
|
||||
m_marginTop = 10;
|
||||
m_maxNameWidth = 0;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QSize RiuNightchartsWidget::sizeHint() const
|
||||
{
|
||||
int widthHint = 0;
|
||||
int heightHint = 0;
|
||||
int maxPieSize = 180;
|
||||
|
||||
if ( m_showLegend )
|
||||
{
|
||||
QPainter painter;
|
||||
int lineHeight = painter.fontMetrics().height();
|
||||
int lineCount = m_chart.pieceCount();
|
||||
|
||||
int exactLegendHeight = (lineCount + lineCount-1) * lineHeight;
|
||||
|
||||
widthHint = m_maxNameWidth + 5 + lineHeight;
|
||||
heightHint = exactLegendHeight;
|
||||
}
|
||||
|
||||
if (m_showPie)
|
||||
{
|
||||
widthHint = widthHint + maxPieSize;
|
||||
heightHint = heightHint > maxPieSize ? heightHint : maxPieSize;
|
||||
}
|
||||
|
||||
if ( m_showPie || m_showLegend )
|
||||
{
|
||||
widthHint += 2*m_marginLeft;
|
||||
heightHint += 2*m_marginTop;
|
||||
return QSize(widthHint, heightHint);
|
||||
}
|
||||
else
|
||||
{
|
||||
return QSize();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -59,21 +148,45 @@ void RiuNightchartsWidget::paintEvent(QPaintEvent* e)
|
||||
if(!m_chart.pieceCount()) return ;
|
||||
|
||||
QPainter painter;
|
||||
QFont font;
|
||||
painter.begin(this);
|
||||
int w = (this->width() - m_marginLeft - 150);
|
||||
int h = (this->height() - m_marginTop - 100);
|
||||
int size = (w<h)?w:h;
|
||||
m_chart.setCords(m_marginLeft, m_marginTop,size, size);
|
||||
|
||||
int legendWidth = 170;
|
||||
int legendMargin = 20;
|
||||
|
||||
m_chart.draw(&painter);
|
||||
m_chart.drawLegend(&painter);
|
||||
if (!m_showLegend)
|
||||
{
|
||||
legendWidth = 0;
|
||||
legendMargin = 0;
|
||||
}
|
||||
|
||||
int w = (this->width() - 2* m_marginLeft - legendWidth - legendMargin);
|
||||
int h = (this->height() - 2* m_marginTop );
|
||||
|
||||
int size = ( w < h ) ? w : h;
|
||||
|
||||
if ( m_showPie )
|
||||
{
|
||||
m_chart.setCords(m_marginLeft, m_marginTop, size, size);
|
||||
m_chart.setLegendCords(m_marginLeft + size + legendMargin, m_marginTop);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_chart.setLegendCords(m_marginLeft, m_marginTop);
|
||||
}
|
||||
|
||||
if (m_showPie) m_chart.draw(&painter);
|
||||
|
||||
if ( m_showLegend) m_chart.drawLegend(&painter);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuNightchartsWidget::addItem(QString name, QColor color, float value)
|
||||
void RiuNightchartsWidget::addItem(const QString& name, const QColor& color, float value)
|
||||
{
|
||||
m_chart.addPiece(name,color,value);
|
||||
m_chart.addPiece(name, color, value);
|
||||
QPainter painter;
|
||||
int textWidth = painter.fontMetrics().width(name + " (00 %)");
|
||||
|
||||
m_maxNameWidth = textWidth > m_maxNameWidth ? textWidth: m_maxNameWidth;
|
||||
}
|
||||
|
@ -33,16 +33,27 @@ class RiuNightchartsWidget : public QWidget
|
||||
public:
|
||||
explicit RiuNightchartsWidget(QWidget* parent = 0);
|
||||
|
||||
void addItem(QString name, QColor color, float value);
|
||||
void addItem(const QString& name, const QColor& color, float value);
|
||||
void setType(Nightcharts::type type);
|
||||
void showLegend(bool doShow);
|
||||
void showPie(bool doShow);
|
||||
|
||||
void clear();
|
||||
|
||||
|
||||
virtual QSize sizeHint() const override;
|
||||
|
||||
protected:
|
||||
virtual void paintEvent(QPaintEvent* e);
|
||||
|
||||
private:
|
||||
void updateSizePolicy();
|
||||
|
||||
Nightcharts m_chart;
|
||||
int m_marginLeft;
|
||||
int m_marginTop;
|
||||
int m_marginLeft;
|
||||
int m_marginTop;
|
||||
bool m_showLegend;
|
||||
bool m_showPie;
|
||||
int m_maxNameWidth;
|
||||
};
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -26,9 +26,14 @@
|
||||
#include <QFrame>
|
||||
|
||||
class RimWellAllocationPlot;
|
||||
class RiuNightchartsWidget;
|
||||
|
||||
class QLabel;
|
||||
|
||||
namespace cvf {
|
||||
class Color3f;
|
||||
}
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
//
|
||||
@ -45,7 +50,9 @@ public:
|
||||
|
||||
void showTitle(const QString& title);
|
||||
void hideTitle();
|
||||
|
||||
void showLegend(bool doShow);
|
||||
void addLegendItem(const QString& name, const cvf::Color3f& color, float value);
|
||||
void clearLegend();
|
||||
protected:
|
||||
virtual QSize sizeHint() const override;
|
||||
virtual QSize minimumSizeHint() const override;
|
||||
@ -55,6 +62,7 @@ private:
|
||||
|
||||
private:
|
||||
caf::PdmPointer<RimWellAllocationPlot> m_plotDefinition;
|
||||
QPointer<RiuNightchartsWidget> m_legendWidget;
|
||||
QPointer<QLabel> m_titleLabel;
|
||||
};
|
||||
|
||||
|
@ -1,371 +1,381 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2015- Statoil ASA
|
||||
// Copyright (C) 2015- Ceetron Solutions AS
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RiuWellLogPlot.h"
|
||||
|
||||
#include "RimWellLogPlot.h"
|
||||
#include "RimWellLogTrack.h"
|
||||
#include "RiuMainWindow.h"
|
||||
#include "RiuWellLogTrack.h"
|
||||
|
||||
#include "qwt_legend.h"
|
||||
|
||||
#include "cvfAssert.h"
|
||||
|
||||
#include <QFocusEvent>
|
||||
#include <QHBoxLayout>
|
||||
#include <QMdiSubWindow>
|
||||
#include <QScrollBar>
|
||||
#include <QTimer>
|
||||
|
||||
#include <math.h>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuWellLogPlot::RiuWellLogPlot(RimWellLogPlot* plotDefinition, QWidget* parent)
|
||||
: QWidget(parent), m_scheduleUpdateChildrenLayoutTimer(NULL)
|
||||
{
|
||||
Q_ASSERT(plotDefinition);
|
||||
m_plotDefinition = plotDefinition;
|
||||
|
||||
QPalette newPalette(palette());
|
||||
newPalette.setColor(QPalette::Background, Qt::white);
|
||||
setPalette(newPalette);
|
||||
|
||||
setAutoFillBackground(true);
|
||||
|
||||
m_scrollBar = new QScrollBar(this);
|
||||
m_scrollBar->setOrientation(Qt::Vertical);
|
||||
m_scrollBar->setVisible(true);
|
||||
|
||||
connect(m_scrollBar, SIGNAL(valueChanged(int)), this, SLOT(slotSetMinDepth(int)));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuWellLogPlot::~RiuWellLogPlot()
|
||||
{
|
||||
if (m_plotDefinition)
|
||||
{
|
||||
m_plotDefinition->detachAllCurves();
|
||||
m_plotDefinition->handleMdiWindowClosed();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellLogPlot::addTrackPlot(RiuWellLogTrack* trackPlot)
|
||||
{
|
||||
// Insert the plot to the left of the scroll bar
|
||||
insertTrackPlot(trackPlot, m_trackPlots.size());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellLogPlot::insertTrackPlot(RiuWellLogTrack* trackPlot, size_t index)
|
||||
{
|
||||
trackPlot->setParent(this);
|
||||
|
||||
m_trackPlots.insert(static_cast<int>(index), trackPlot);
|
||||
|
||||
QwtLegend* legend = new QwtLegend(this);
|
||||
legend->setMaxColumns(1);
|
||||
legend->connect(trackPlot, SIGNAL(legendDataChanged(const QVariant &, const QList< QwtLegendData > &)), SLOT(updateLegend(const QVariant &, const QList< QwtLegendData > &)));
|
||||
legend->contentsWidget()->layout()->setAlignment(Qt::AlignBottom | Qt::AlignHCenter);
|
||||
m_legends.insert(static_cast<int>(index), legend);
|
||||
|
||||
this->connect(trackPlot, SIGNAL(legendDataChanged(const QVariant &, const QList< QwtLegendData > &)), SLOT(scheduleUpdateChildrenLayout()));
|
||||
|
||||
if (!m_plotDefinition->isTrackLegendsVisible())
|
||||
{
|
||||
legend->hide();
|
||||
}
|
||||
|
||||
trackPlot->updateLegend();
|
||||
|
||||
if (trackPlot->isRimTrackVisible())
|
||||
{
|
||||
trackPlot->show();
|
||||
}
|
||||
else
|
||||
{
|
||||
trackPlot->hide();
|
||||
}
|
||||
|
||||
modifyWidthOfContainingMdiWindow(trackPlot->width());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellLogPlot::removeTrackPlot(RiuWellLogTrack* trackPlot)
|
||||
{
|
||||
if (!trackPlot) return;
|
||||
|
||||
int windowWidthChange = - trackPlot->width();
|
||||
|
||||
int trackIdx = m_trackPlots.indexOf(trackPlot);
|
||||
CVF_ASSERT(trackIdx >= 0);
|
||||
|
||||
m_trackPlots.removeAt(trackIdx);
|
||||
trackPlot->setParent(NULL);
|
||||
|
||||
QwtLegend* legend = m_legends[trackIdx];
|
||||
m_legends.removeAt(trackIdx);
|
||||
delete legend;
|
||||
|
||||
modifyWidthOfContainingMdiWindow(windowWidthChange);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellLogPlot::modifyWidthOfContainingMdiWindow(int widthChange)
|
||||
{
|
||||
QMdiSubWindow* mdiWindow = RiuMainWindow::instance()->findMdiSubWindow(this);
|
||||
if (mdiWindow)
|
||||
{
|
||||
if (m_trackPlots.size() == 0 && widthChange <= 0) return; // Last track removed. Leave be
|
||||
|
||||
QSize subWindowSize = mdiWindow->size();
|
||||
int newWidth = 0;
|
||||
|
||||
if (m_trackPlots.size() == 1 && widthChange > 0) // First track added
|
||||
{
|
||||
newWidth = widthChange;
|
||||
}
|
||||
else
|
||||
{
|
||||
newWidth = subWindowSize.width() + widthChange;
|
||||
}
|
||||
|
||||
if (newWidth < 0) newWidth = 100;
|
||||
|
||||
subWindowSize.setWidth(newWidth);
|
||||
mdiWindow->resize(subWindowSize);
|
||||
|
||||
if (mdiWindow->isMaximized())
|
||||
{
|
||||
// Set window temporarily to normal state and back to maximized
|
||||
// to redo layout so the whole window canvas is filled
|
||||
// Tried to activate layout, did not work as expected
|
||||
// Tested code:
|
||||
// m_layout->activate();
|
||||
// mdiWindow->layout()->activate();
|
||||
|
||||
mdiWindow->showNormal();
|
||||
mdiWindow->showMaximized();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellLogPlot::setDepthZoomAndReplot(double minDepth, double maxDepth)
|
||||
{
|
||||
for (int tpIdx = 0; tpIdx < m_trackPlots.count(); tpIdx++)
|
||||
{
|
||||
m_trackPlots[tpIdx]->setDepthZoom(minDepth, maxDepth);
|
||||
m_trackPlots[tpIdx]->replot();
|
||||
}
|
||||
|
||||
updateScrollBar(minDepth, maxDepth);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellLogPlot::updateScrollBar(double minDepth, double maxDepth)
|
||||
{
|
||||
double availableMinDepth;
|
||||
double availableMaxDepth;
|
||||
m_plotDefinition->availableDepthRange(&availableMinDepth, &availableMaxDepth);
|
||||
availableMaxDepth += 0.01*(availableMaxDepth-availableMinDepth);
|
||||
|
||||
double visibleDepth = maxDepth - minDepth;
|
||||
|
||||
m_scrollBar->blockSignals(true);
|
||||
{
|
||||
m_scrollBar->setRange((int) availableMinDepth, (int) ((availableMaxDepth - visibleDepth)));
|
||||
m_scrollBar->setPageStep((int) visibleDepth);
|
||||
m_scrollBar->setValue((int) minDepth);
|
||||
|
||||
m_scrollBar->setVisible(true);
|
||||
}
|
||||
m_scrollBar->blockSignals(false);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellLogPlot::slotSetMinDepth(int value)
|
||||
{
|
||||
double minimumDepth;
|
||||
double maximumDepth;
|
||||
m_plotDefinition->depthZoomMinMax(&minimumDepth, &maximumDepth);
|
||||
|
||||
double delta = value - minimumDepth;
|
||||
m_plotDefinition->setDepthZoomMinMax(minimumDepth + delta, maximumDepth + delta);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimWellLogPlot* RiuWellLogPlot::ownerPlotDefinition()
|
||||
{
|
||||
return m_plotDefinition;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellLogPlot::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
int height = event->size().height();
|
||||
int width = event->size().width();
|
||||
|
||||
placeChildWidgets(height, width);
|
||||
QWidget::resizeEvent(event);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellLogPlot::placeChildWidgets(int height, int width)
|
||||
{
|
||||
int trackCount = m_trackPlots.size();
|
||||
CVF_ASSERT(m_legends.size() == trackCount);
|
||||
|
||||
int visibleTrackCount = 0;
|
||||
for (int tIdx = 0; tIdx < trackCount; ++tIdx)
|
||||
{
|
||||
if (m_trackPlots[tIdx]->isVisible()) ++visibleTrackCount;
|
||||
}
|
||||
|
||||
int scrollBarWidth = 0;
|
||||
if (m_scrollBar->isVisible()) scrollBarWidth = m_scrollBar->sizeHint().width();
|
||||
|
||||
int maxLegendHeight = 0;
|
||||
|
||||
if (m_plotDefinition->isTrackLegendsVisible())
|
||||
{
|
||||
for ( int tIdx = 0; tIdx < trackCount; ++tIdx )
|
||||
{
|
||||
if ( m_trackPlots[tIdx]->isVisible() )
|
||||
{
|
||||
int legendHeight = m_legends[tIdx]->sizeHint().height();
|
||||
if ( legendHeight > maxLegendHeight ) maxLegendHeight = legendHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int trackHeight = height - maxLegendHeight;
|
||||
int trackX = 0;
|
||||
|
||||
if (visibleTrackCount)
|
||||
{
|
||||
int trackWidth = (width - scrollBarWidth)/visibleTrackCount;
|
||||
int trackWidthExtra = (width-scrollBarWidth)%visibleTrackCount;
|
||||
|
||||
for (int tIdx = 0; tIdx < trackCount; ++tIdx)
|
||||
{
|
||||
if (m_trackPlots[tIdx]->isVisible())
|
||||
{
|
||||
int realTrackWidth = trackWidth;
|
||||
if (trackWidthExtra > 0)
|
||||
{
|
||||
realTrackWidth += 1;
|
||||
--trackWidthExtra;
|
||||
}
|
||||
int realLegendWidth = std::max(realTrackWidth, m_legends[tIdx]->sizeHint().width());
|
||||
m_legends[tIdx]->setGeometry(trackX, 0, realLegendWidth, maxLegendHeight);
|
||||
m_trackPlots[tIdx]->setGeometry(trackX, maxLegendHeight, realTrackWidth, trackHeight);
|
||||
|
||||
trackX += realTrackWidth;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (m_scrollBar->isVisible()) m_scrollBar->setGeometry(trackX, maxLegendHeight, scrollBarWidth, trackHeight);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellLogPlot::updateChildrenLayout()
|
||||
{
|
||||
int trackCount = m_trackPlots.size();
|
||||
for (int tIdx = 0; tIdx < trackCount; ++tIdx)
|
||||
{
|
||||
if (m_trackPlots[tIdx]->isVisible())
|
||||
{
|
||||
m_legends[tIdx]->show();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_legends[tIdx]->hide();
|
||||
}
|
||||
}
|
||||
|
||||
placeChildWidgets(this->height(), this->width());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellLogPlot::showEvent(QShowEvent *)
|
||||
{
|
||||
updateChildrenLayout();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellLogPlot::changeEvent(QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::WindowStateChange)
|
||||
{
|
||||
updateChildrenLayout();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Schedule an update of the widget positions
|
||||
/// Will happen just a bit after the event loop is entered
|
||||
/// Used to delay the positioning to after the legend widgets is actually updated.
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellLogPlot::scheduleUpdateChildrenLayout()
|
||||
{
|
||||
if (!m_scheduleUpdateChildrenLayoutTimer)
|
||||
{
|
||||
m_scheduleUpdateChildrenLayoutTimer = new QTimer(this);
|
||||
connect(m_scheduleUpdateChildrenLayoutTimer, SIGNAL(timeout()), this, SLOT(updateChildrenLayout()));
|
||||
}
|
||||
|
||||
if (!m_scheduleUpdateChildrenLayoutTimer->isActive())
|
||||
{
|
||||
m_scheduleUpdateChildrenLayoutTimer->setSingleShot(true);
|
||||
m_scheduleUpdateChildrenLayoutTimer->start(10);
|
||||
}
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2015- Statoil ASA
|
||||
// Copyright (C) 2015- Ceetron Solutions AS
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RiuWellLogPlot.h"
|
||||
|
||||
#include "RimWellLogPlot.h"
|
||||
#include "RimWellLogTrack.h"
|
||||
#include "RiuMainWindow.h"
|
||||
#include "RiuWellLogTrack.h"
|
||||
|
||||
#include "qwt_legend.h"
|
||||
|
||||
#include "cvfAssert.h"
|
||||
|
||||
#include <QFocusEvent>
|
||||
#include <QHBoxLayout>
|
||||
#include <QMdiSubWindow>
|
||||
#include <QScrollBar>
|
||||
#include <QTimer>
|
||||
|
||||
#include <math.h>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuWellLogPlot::RiuWellLogPlot(RimWellLogPlot* plotDefinition, QWidget* parent)
|
||||
: QWidget(parent), m_scheduleUpdateChildrenLayoutTimer(NULL)
|
||||
{
|
||||
Q_ASSERT(plotDefinition);
|
||||
m_plotDefinition = plotDefinition;
|
||||
|
||||
QPalette newPalette(palette());
|
||||
newPalette.setColor(QPalette::Background, Qt::white);
|
||||
setPalette(newPalette);
|
||||
|
||||
setAutoFillBackground(true);
|
||||
|
||||
m_scrollBar = new QScrollBar(this);
|
||||
m_scrollBar->setOrientation(Qt::Vertical);
|
||||
m_scrollBar->setVisible(true);
|
||||
|
||||
this->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
||||
|
||||
connect(m_scrollBar, SIGNAL(valueChanged(int)), this, SLOT(slotSetMinDepth(int)));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuWellLogPlot::~RiuWellLogPlot()
|
||||
{
|
||||
if (m_plotDefinition)
|
||||
{
|
||||
m_plotDefinition->detachAllCurves();
|
||||
m_plotDefinition->handleMdiWindowClosed();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellLogPlot::addTrackPlot(RiuWellLogTrack* trackPlot)
|
||||
{
|
||||
// Insert the plot to the left of the scroll bar
|
||||
insertTrackPlot(trackPlot, m_trackPlots.size());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellLogPlot::insertTrackPlot(RiuWellLogTrack* trackPlot, size_t index)
|
||||
{
|
||||
trackPlot->setParent(this);
|
||||
|
||||
m_trackPlots.insert(static_cast<int>(index), trackPlot);
|
||||
|
||||
QwtLegend* legend = new QwtLegend(this);
|
||||
legend->setMaxColumns(1);
|
||||
legend->connect(trackPlot, SIGNAL(legendDataChanged(const QVariant &, const QList< QwtLegendData > &)), SLOT(updateLegend(const QVariant &, const QList< QwtLegendData > &)));
|
||||
legend->contentsWidget()->layout()->setAlignment(Qt::AlignBottom | Qt::AlignHCenter);
|
||||
m_legends.insert(static_cast<int>(index), legend);
|
||||
|
||||
this->connect(trackPlot, SIGNAL(legendDataChanged(const QVariant &, const QList< QwtLegendData > &)), SLOT(scheduleUpdateChildrenLayout()));
|
||||
|
||||
if (!m_plotDefinition->isTrackLegendsVisible())
|
||||
{
|
||||
legend->hide();
|
||||
}
|
||||
|
||||
trackPlot->updateLegend();
|
||||
|
||||
if (trackPlot->isRimTrackVisible())
|
||||
{
|
||||
trackPlot->show();
|
||||
}
|
||||
else
|
||||
{
|
||||
trackPlot->hide();
|
||||
}
|
||||
|
||||
modifyWidthOfContainingMdiWindow(trackPlot->width());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellLogPlot::removeTrackPlot(RiuWellLogTrack* trackPlot)
|
||||
{
|
||||
if (!trackPlot) return;
|
||||
|
||||
int windowWidthChange = - trackPlot->width();
|
||||
|
||||
int trackIdx = m_trackPlots.indexOf(trackPlot);
|
||||
CVF_ASSERT(trackIdx >= 0);
|
||||
|
||||
m_trackPlots.removeAt(trackIdx);
|
||||
trackPlot->setParent(NULL);
|
||||
|
||||
QwtLegend* legend = m_legends[trackIdx];
|
||||
m_legends.removeAt(trackIdx);
|
||||
delete legend;
|
||||
|
||||
modifyWidthOfContainingMdiWindow(windowWidthChange);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellLogPlot::modifyWidthOfContainingMdiWindow(int widthChange)
|
||||
{
|
||||
QMdiSubWindow* mdiWindow = RiuMainWindow::instance()->findMdiSubWindow(this);
|
||||
if (mdiWindow)
|
||||
{
|
||||
if (m_trackPlots.size() == 0 && widthChange <= 0) return; // Last track removed. Leave be
|
||||
|
||||
QSize subWindowSize = mdiWindow->size();
|
||||
int newWidth = 0;
|
||||
|
||||
if (m_trackPlots.size() == 1 && widthChange > 0) // First track added
|
||||
{
|
||||
newWidth = widthChange;
|
||||
}
|
||||
else
|
||||
{
|
||||
newWidth = subWindowSize.width() + widthChange;
|
||||
}
|
||||
|
||||
if (newWidth < 0) newWidth = 100;
|
||||
|
||||
subWindowSize.setWidth(newWidth);
|
||||
mdiWindow->resize(subWindowSize);
|
||||
|
||||
if (mdiWindow->isMaximized())
|
||||
{
|
||||
// Set window temporarily to normal state and back to maximized
|
||||
// to redo layout so the whole window canvas is filled
|
||||
// Tried to activate layout, did not work as expected
|
||||
// Tested code:
|
||||
// m_layout->activate();
|
||||
// mdiWindow->layout()->activate();
|
||||
|
||||
mdiWindow->showNormal();
|
||||
mdiWindow->showMaximized();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellLogPlot::setDepthZoomAndReplot(double minDepth, double maxDepth)
|
||||
{
|
||||
for (int tpIdx = 0; tpIdx < m_trackPlots.count(); tpIdx++)
|
||||
{
|
||||
m_trackPlots[tpIdx]->setDepthZoom(minDepth, maxDepth);
|
||||
m_trackPlots[tpIdx]->replot();
|
||||
}
|
||||
|
||||
updateScrollBar(minDepth, maxDepth);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QSize RiuWellLogPlot::sizeHint() const
|
||||
{
|
||||
return QSize(1,1);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellLogPlot::updateScrollBar(double minDepth, double maxDepth)
|
||||
{
|
||||
double availableMinDepth;
|
||||
double availableMaxDepth;
|
||||
m_plotDefinition->availableDepthRange(&availableMinDepth, &availableMaxDepth);
|
||||
availableMaxDepth += 0.01*(availableMaxDepth-availableMinDepth);
|
||||
|
||||
double visibleDepth = maxDepth - minDepth;
|
||||
|
||||
m_scrollBar->blockSignals(true);
|
||||
{
|
||||
m_scrollBar->setRange((int) availableMinDepth, (int) ((availableMaxDepth - visibleDepth)));
|
||||
m_scrollBar->setPageStep((int) visibleDepth);
|
||||
m_scrollBar->setValue((int) minDepth);
|
||||
|
||||
m_scrollBar->setVisible(true);
|
||||
}
|
||||
m_scrollBar->blockSignals(false);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellLogPlot::slotSetMinDepth(int value)
|
||||
{
|
||||
double minimumDepth;
|
||||
double maximumDepth;
|
||||
m_plotDefinition->depthZoomMinMax(&minimumDepth, &maximumDepth);
|
||||
|
||||
double delta = value - minimumDepth;
|
||||
m_plotDefinition->setDepthZoomMinMax(minimumDepth + delta, maximumDepth + delta);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimWellLogPlot* RiuWellLogPlot::ownerPlotDefinition()
|
||||
{
|
||||
return m_plotDefinition;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellLogPlot::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
int height = event->size().height();
|
||||
int width = event->size().width();
|
||||
|
||||
placeChildWidgets(height, width);
|
||||
QWidget::resizeEvent(event);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellLogPlot::placeChildWidgets(int height, int width)
|
||||
{
|
||||
int trackCount = m_trackPlots.size();
|
||||
CVF_ASSERT(m_legends.size() == trackCount);
|
||||
|
||||
int visibleTrackCount = 0;
|
||||
for (int tIdx = 0; tIdx < trackCount; ++tIdx)
|
||||
{
|
||||
if (m_trackPlots[tIdx]->isVisible()) ++visibleTrackCount;
|
||||
}
|
||||
|
||||
int scrollBarWidth = 0;
|
||||
if (m_scrollBar->isVisible()) scrollBarWidth = m_scrollBar->sizeHint().width();
|
||||
|
||||
int maxLegendHeight = 0;
|
||||
|
||||
if (m_plotDefinition && m_plotDefinition->isTrackLegendsVisible())
|
||||
{
|
||||
for ( int tIdx = 0; tIdx < trackCount; ++tIdx )
|
||||
{
|
||||
if ( m_trackPlots[tIdx]->isVisible() )
|
||||
{
|
||||
int legendHeight = m_legends[tIdx]->sizeHint().height();
|
||||
if ( legendHeight > maxLegendHeight ) maxLegendHeight = legendHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int trackHeight = height - maxLegendHeight;
|
||||
int trackX = 0;
|
||||
|
||||
if (visibleTrackCount)
|
||||
{
|
||||
int trackWidth = (width - scrollBarWidth)/visibleTrackCount;
|
||||
int trackWidthExtra = (width-scrollBarWidth)%visibleTrackCount;
|
||||
|
||||
for (int tIdx = 0; tIdx < trackCount; ++tIdx)
|
||||
{
|
||||
if (m_trackPlots[tIdx]->isVisible())
|
||||
{
|
||||
int realTrackWidth = trackWidth;
|
||||
if (trackWidthExtra > 0)
|
||||
{
|
||||
realTrackWidth += 1;
|
||||
--trackWidthExtra;
|
||||
}
|
||||
int realLegendWidth = std::max(realTrackWidth, m_legends[tIdx]->sizeHint().width());
|
||||
m_legends[tIdx]->setGeometry(trackX, 0, realLegendWidth, maxLegendHeight);
|
||||
m_trackPlots[tIdx]->setGeometry(trackX, maxLegendHeight, realTrackWidth, trackHeight);
|
||||
|
||||
trackX += realTrackWidth;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (m_scrollBar->isVisible()) m_scrollBar->setGeometry(trackX, maxLegendHeight, scrollBarWidth, trackHeight);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellLogPlot::updateChildrenLayout()
|
||||
{
|
||||
int trackCount = m_trackPlots.size();
|
||||
for (int tIdx = 0; tIdx < trackCount; ++tIdx)
|
||||
{
|
||||
if (m_trackPlots[tIdx]->isVisible())
|
||||
{
|
||||
m_legends[tIdx]->show();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_legends[tIdx]->hide();
|
||||
}
|
||||
}
|
||||
|
||||
placeChildWidgets(this->height(), this->width());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellLogPlot::showEvent(QShowEvent *)
|
||||
{
|
||||
updateChildrenLayout();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellLogPlot::changeEvent(QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::WindowStateChange)
|
||||
{
|
||||
updateChildrenLayout();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Schedule an update of the widget positions
|
||||
/// Will happen just a bit after the event loop is entered
|
||||
/// Used to delay the positioning to after the legend widgets is actually updated.
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellLogPlot::scheduleUpdateChildrenLayout()
|
||||
{
|
||||
if (!m_scheduleUpdateChildrenLayoutTimer)
|
||||
{
|
||||
m_scheduleUpdateChildrenLayoutTimer = new QTimer(this);
|
||||
connect(m_scheduleUpdateChildrenLayoutTimer, SIGNAL(timeout()), this, SLOT(updateChildrenLayout()));
|
||||
}
|
||||
|
||||
if (!m_scheduleUpdateChildrenLayoutTimer->isActive())
|
||||
{
|
||||
m_scheduleUpdateChildrenLayoutTimer->setSingleShot(true);
|
||||
m_scheduleUpdateChildrenLayoutTimer->start(10);
|
||||
}
|
||||
}
|
||||
|
@ -1,82 +1,83 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2015- Statoil ASA
|
||||
// Copyright (C) 2015- Ceetron Solutions AS
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafPdmPointer.h"
|
||||
|
||||
#include <QList>
|
||||
#include <QPointer>
|
||||
#include <QWidget>
|
||||
|
||||
class RimWellLogPlot;
|
||||
class RiuWellLogTrack;
|
||||
|
||||
class QHBoxLayout;
|
||||
class QScrollBar;
|
||||
class QFocusEvent;
|
||||
class QwtLegend;
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
// RiuWellLogPlot
|
||||
//
|
||||
//==================================================================================================
|
||||
class RiuWellLogPlot : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
RiuWellLogPlot(RimWellLogPlot* plotDefinition, QWidget* parent = NULL);
|
||||
virtual ~RiuWellLogPlot();
|
||||
|
||||
RimWellLogPlot* ownerPlotDefinition();
|
||||
|
||||
void addTrackPlot(RiuWellLogTrack* trackPlot);
|
||||
void insertTrackPlot(RiuWellLogTrack* trackPlot, size_t index);
|
||||
void removeTrackPlot(RiuWellLogTrack* trackPlot);
|
||||
|
||||
void setDepthZoomAndReplot(double minDepth, double maxDepth);
|
||||
|
||||
public slots:
|
||||
void updateChildrenLayout();
|
||||
|
||||
protected:
|
||||
virtual void resizeEvent(QResizeEvent *event);
|
||||
virtual void showEvent(QShowEvent *);
|
||||
virtual void changeEvent(QEvent *);
|
||||
|
||||
private:
|
||||
void updateScrollBar(double minDepth, double maxDepth);
|
||||
void modifyWidthOfContainingMdiWindow(int widthChange);
|
||||
void placeChildWidgets(int height, int width);
|
||||
|
||||
private slots:
|
||||
void slotSetMinDepth(int value);
|
||||
void scheduleUpdateChildrenLayout();
|
||||
|
||||
private:
|
||||
QHBoxLayout* m_layout;
|
||||
QScrollBar* m_scrollBar;
|
||||
QList<QPointer<QwtLegend> > m_legends;
|
||||
QList<QPointer<RiuWellLogTrack> > m_trackPlots;
|
||||
caf::PdmPointer<RimWellLogPlot> m_plotDefinition;
|
||||
QTimer* m_scheduleUpdateChildrenLayoutTimer;
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2015- Statoil ASA
|
||||
// Copyright (C) 2015- Ceetron Solutions AS
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafPdmPointer.h"
|
||||
|
||||
#include <QList>
|
||||
#include <QPointer>
|
||||
#include <QWidget>
|
||||
|
||||
class RimWellLogPlot;
|
||||
class RiuWellLogTrack;
|
||||
|
||||
class QHBoxLayout;
|
||||
class QScrollBar;
|
||||
class QFocusEvent;
|
||||
class QwtLegend;
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
// RiuWellLogPlot
|
||||
//
|
||||
//==================================================================================================
|
||||
class RiuWellLogPlot : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
RiuWellLogPlot(RimWellLogPlot* plotDefinition, QWidget* parent = NULL);
|
||||
virtual ~RiuWellLogPlot();
|
||||
|
||||
RimWellLogPlot* ownerPlotDefinition();
|
||||
|
||||
void addTrackPlot(RiuWellLogTrack* trackPlot);
|
||||
void insertTrackPlot(RiuWellLogTrack* trackPlot, size_t index);
|
||||
void removeTrackPlot(RiuWellLogTrack* trackPlot);
|
||||
|
||||
void setDepthZoomAndReplot(double minDepth, double maxDepth);
|
||||
|
||||
public slots:
|
||||
void updateChildrenLayout();
|
||||
|
||||
protected:
|
||||
virtual void resizeEvent(QResizeEvent *event);
|
||||
virtual void showEvent(QShowEvent *);
|
||||
virtual void changeEvent(QEvent *);
|
||||
virtual QSize sizeHint() const override;
|
||||
|
||||
private:
|
||||
void updateScrollBar(double minDepth, double maxDepth);
|
||||
void modifyWidthOfContainingMdiWindow(int widthChange);
|
||||
void placeChildWidgets(int height, int width);
|
||||
|
||||
private slots:
|
||||
void slotSetMinDepth(int value);
|
||||
void scheduleUpdateChildrenLayout();
|
||||
|
||||
private:
|
||||
QHBoxLayout* m_layout;
|
||||
QScrollBar* m_scrollBar;
|
||||
QList<QPointer<QwtLegend> > m_legends;
|
||||
QList<QPointer<RiuWellLogTrack> > m_trackPlots;
|
||||
caf::PdmPointer<RimWellLogPlot> m_plotDefinition;
|
||||
QTimer* m_scheduleUpdateChildrenLayoutTimer;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user