mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4130 3D Cross Plot: Improve window management
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
#include "RimGridCrossPlot.h"
|
||||
|
||||
#include "RiuGridCrossQwtPlot.h"
|
||||
#include "RiuQwtPlotTools.h"
|
||||
|
||||
#include "RimGridCrossPlotCurveSet.h"
|
||||
@@ -53,6 +54,15 @@ RimGridCrossPlot::RimGridCrossPlot()
|
||||
createCurveSet();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimGridCrossPlot::~RimGridCrossPlot()
|
||||
{
|
||||
removeMdiWindowFromMdiArea();
|
||||
deleteViewWidget();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -172,7 +182,13 @@ QWidget* RimGridCrossPlot::createViewWidget(QWidget* mainWindowParent)
|
||||
{
|
||||
if (!m_qwtPlot)
|
||||
{
|
||||
m_qwtPlot = new QwtPlot(QString("Grid Cross Plot"), mainWindowParent);
|
||||
m_qwtPlot = new RiuGridCrossQwtPlot(this, mainWindowParent);
|
||||
|
||||
for (auto curveSet : m_crossPlotCurveSets)
|
||||
{
|
||||
curveSet->setParentQwtPlotNoReplot(m_qwtPlot);
|
||||
}
|
||||
m_qwtPlot->replot();
|
||||
}
|
||||
|
||||
return m_qwtPlot;
|
||||
@@ -183,6 +199,7 @@ QWidget* RimGridCrossPlot::createViewWidget(QWidget* mainWindowParent)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridCrossPlot::deleteViewWidget()
|
||||
{
|
||||
detachAllCurves();
|
||||
if (m_qwtPlot)
|
||||
{
|
||||
m_qwtPlot->deleteLater();
|
||||
@@ -196,41 +213,17 @@ void RimGridCrossPlot::deleteViewWidget()
|
||||
void RimGridCrossPlot::onLoadDataAndUpdate()
|
||||
{
|
||||
updateMdiWindowVisibility();
|
||||
CVF_ASSERT(m_qwtPlot);
|
||||
|
||||
for (auto curveSet : m_crossPlotCurveSets)
|
||||
{
|
||||
curveSet->loadDataAndUpdate(false);
|
||||
curveSet->setParentQwtPlotNoReplot(m_qwtPlot);
|
||||
}
|
||||
|
||||
performAutoNameUpdate();
|
||||
updateAllRequiredEditors();
|
||||
updatePlot();
|
||||
|
||||
|
||||
m_qwtPlot->setAxisAutoScale(QwtPlot::xBottom);
|
||||
m_qwtPlot->setAxisAutoScale(QwtPlot::yLeft);
|
||||
m_qwtPlot->setAxisTitle(QwtPlot::xBottom, QwtText(xAxisParameterString()));
|
||||
m_qwtPlot->setAxisTitle(QwtPlot::yLeft, QwtText(yAxisParameterString()));
|
||||
|
||||
RiuQwtPlotTools::setCommonPlotBehaviour(m_qwtPlot);
|
||||
RiuQwtPlotTools::setDefaultAxes(m_qwtPlot);
|
||||
if (m_showLegend())
|
||||
{
|
||||
// Will be released in plot destructor or when a new legend is set
|
||||
QwtLegend* legend = new QwtLegend(m_qwtPlot);
|
||||
|
||||
auto font = legend->font();
|
||||
font.setPixelSize(m_legendFontSize());
|
||||
legend->setFont(font);
|
||||
m_qwtPlot->insertLegend(legend, QwtPlot::BottomLegend);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_qwtPlot->insertLegend(nullptr);
|
||||
}
|
||||
|
||||
m_qwtPlot->replot();
|
||||
m_qwtPlot->show();
|
||||
this->updateAllRequiredEditors();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -299,6 +292,44 @@ void RimGridCrossPlot::performAutoNameUpdate()
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridCrossPlot::updatePlot()
|
||||
{
|
||||
if (m_qwtPlot)
|
||||
{
|
||||
m_qwtPlot->setAxisAutoScale(QwtPlot::xBottom);
|
||||
m_qwtPlot->setAxisAutoScale(QwtPlot::yLeft);
|
||||
m_qwtPlot->setAxisTitle(QwtPlot::xBottom, QwtText(xAxisParameterString()));
|
||||
m_qwtPlot->setAxisTitle(QwtPlot::yLeft, QwtText(yAxisParameterString()));
|
||||
|
||||
RiuQwtPlotTools::setCommonPlotBehaviour(m_qwtPlot);
|
||||
RiuQwtPlotTools::setDefaultAxes(m_qwtPlot);
|
||||
|
||||
for (auto curveSet : m_crossPlotCurveSets)
|
||||
{
|
||||
curveSet->setParentQwtPlotNoReplot(m_qwtPlot);
|
||||
}
|
||||
|
||||
if (m_showLegend())
|
||||
{
|
||||
// Will be released in plot destructor or when a new legend is set
|
||||
QwtLegend* legend = new QwtLegend(m_qwtPlot);
|
||||
|
||||
auto font = legend->font();
|
||||
font.setPixelSize(m_legendFontSize());
|
||||
legend->setFont(font);
|
||||
m_qwtPlot->insertLegend(legend, QwtPlot::BottomLegend);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_qwtPlot->insertLegend(nullptr);
|
||||
}
|
||||
m_qwtPlot->replot();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -341,6 +372,17 @@ QString RimGridCrossPlot::yAxisParameterString() const
|
||||
return yAxisParams.join(", ");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridCrossPlot::detachAllCurves()
|
||||
{
|
||||
for (auto curveSet : m_crossPlotCurveSets())
|
||||
{
|
||||
curveSet->detachAllCurves();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Name Configuration
|
||||
///
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#include <QPointer>
|
||||
|
||||
class RimGridCrossPlotCurveSet;
|
||||
class QwtPlot;
|
||||
class RiuGridCrossQwtPlot;
|
||||
|
||||
class RimGridCrossPlotNameConfig : public RimNameConfig
|
||||
{
|
||||
@@ -47,7 +47,7 @@ class RimGridCrossPlot : public RimViewWindow, public RimNameConfigHolderInterfa
|
||||
CAF_PDM_HEADER_INIT;
|
||||
public:
|
||||
RimGridCrossPlot();
|
||||
~RimGridCrossPlot() = default;
|
||||
~RimGridCrossPlot();
|
||||
|
||||
RimGridCrossPlotCurveSet* createCurveSet();
|
||||
int indexOfCurveSet(const RimGridCrossPlotCurveSet* curveSet) const;
|
||||
@@ -60,6 +60,7 @@ public:
|
||||
QString createAutoName() const override;
|
||||
|
||||
caf::PdmFieldHandle* userDescriptionField() override;
|
||||
void detachAllCurves();
|
||||
|
||||
protected:
|
||||
QWidget* createViewWidget(QWidget* mainWindowParent) override;
|
||||
@@ -71,7 +72,7 @@ protected:
|
||||
bool* useOptionsOnly) override;
|
||||
|
||||
void performAutoNameUpdate() override;
|
||||
|
||||
void updatePlot();
|
||||
QString xAxisParameterString() const;
|
||||
QString yAxisParameterString() const;
|
||||
|
||||
@@ -82,7 +83,8 @@ private:
|
||||
|
||||
caf::PdmChildArrayField<RimGridCrossPlotCurveSet*> m_crossPlotCurveSets;
|
||||
|
||||
QPointer<QwtPlot> m_qwtPlot;
|
||||
QPointer<RiuGridCrossQwtPlot> m_qwtPlot;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user