mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4134 #4124 Refactor RiuSummaryQwtPlot on top of a base RiuQwtPlot class and use this for Cross Plots
* Get a lot of functionality included: zoom, panning, etc.
This commit is contained in:
parent
2582e98961
commit
4c026952a1
@ -49,8 +49,9 @@ void RicCreateGridCrossPlotFeature::onActionTriggered(bool isChecked)
|
||||
RimGridCrossPlotCollection* collection = project->mainPlotCollection()->gridCrossPlotCollection();
|
||||
RimGridCrossPlot* plot = collection->createGridCrossPlot();
|
||||
|
||||
plot->createCurveSet();
|
||||
plot->createCurveSet();
|
||||
plot->loadDataAndUpdate();
|
||||
plot->zoomAll();
|
||||
plot->updateConnectedEditors();
|
||||
|
||||
RiaApplication::instance()->project()->updateConnectedEditors();
|
||||
|
@ -28,7 +28,6 @@
|
||||
#include "Rim3dOverlayInfoConfig.h"
|
||||
|
||||
#include "RiuPlotMainWindow.h"
|
||||
#include "RiuSummaryQwtPlot.h"
|
||||
#include "RiuTools.h"
|
||||
|
||||
#include <QVBoxLayout>
|
||||
|
@ -28,6 +28,7 @@
|
||||
|
||||
#include "RiuPlotMainWindow.h"
|
||||
#include "RiuSummaryQwtPlot.h"
|
||||
#include "RiuQwtPlotTools.h"
|
||||
#include "RiuTools.h"
|
||||
|
||||
#include <QVBoxLayout>
|
||||
@ -69,8 +70,8 @@ RicGridStatisticsDialog::RicGridStatisticsDialog(QWidget* parent)
|
||||
|
||||
// Set widget properties
|
||||
m_textEdit->setReadOnly(true);
|
||||
RiuSummaryQwtPlot::setCommonPlotBehaviour(m_historgramPlot);
|
||||
RiuSummaryQwtPlot::setCommonPlotBehaviour(m_aggregatedPlot);
|
||||
RiuQwtPlotTools::setCommonPlotBehaviour(m_historgramPlot);
|
||||
RiuQwtPlotTools::setCommonPlotBehaviour(m_aggregatedPlot);
|
||||
|
||||
// Define layout
|
||||
QVBoxLayout* dialogLayout = new QVBoxLayout();
|
||||
|
@ -33,7 +33,6 @@
|
||||
#include "RimTools.h"
|
||||
|
||||
#include "RiuPlotMainWindow.h"
|
||||
#include "RiuSummaryQwtPlot.h"
|
||||
#include "RiuTools.h"
|
||||
|
||||
#include <QVBoxLayout>
|
||||
|
@ -127,6 +127,8 @@ ${CMAKE_CURRENT_LIST_DIR}/RimGeoMechContourMapViewCollection.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimViewNameConfig.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimScaleLegendConfig.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimReloadCaseTools.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimRiuQwtPlotOwnerInterface.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimPlotAxisProperties.h
|
||||
)
|
||||
|
||||
|
||||
@ -258,6 +260,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimGeoMechContourMapViewCollection.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimViewNameConfig.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimScaleLegendConfig.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimReloadCaseTools.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimPlotAxisProperties.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
|
@ -17,15 +17,21 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
#include "RimGridCrossPlot.h"
|
||||
|
||||
#include "RiuGridCrossQwtPlot.h"
|
||||
#include "RiuSummaryQwtPlot.h"
|
||||
#include "RiuPlotMainWindowTools.h"
|
||||
#include "RiuQwtPlotTools.h"
|
||||
|
||||
#include "RimGridCrossPlotCurve.h"
|
||||
#include "RimGridCrossPlotCurveSet.h"
|
||||
#include "RimPlotAxisProperties.h"
|
||||
|
||||
#include "cafPdmUiCheckBoxEditor.h"
|
||||
#include "cafPdmUiTreeOrdering.h"
|
||||
|
||||
#include "cvfAssert.h"
|
||||
|
||||
#include "qwt_legend.h"
|
||||
#include "qwt_scale_engine.h"
|
||||
#include "qwt_plot.h"
|
||||
#include "qwt_plot_curve.h"
|
||||
|
||||
@ -46,6 +52,18 @@ RimGridCrossPlot::RimGridCrossPlot()
|
||||
m_nameConfig.uiCapability()->setUiTreeHidden(true);
|
||||
m_nameConfig.uiCapability()->setUiTreeChildrenHidden(true);
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_xAxisProperties, "xAxisProperties", "X Axis", "", "", "");
|
||||
m_xAxisProperties.uiCapability()->setUiTreeHidden(true);
|
||||
m_xAxisProperties = new RimPlotAxisProperties;
|
||||
m_xAxisProperties->setNameAndAxis("X-Axis", QwtPlot::xBottom);
|
||||
m_xAxisProperties->setEnableTitleTextSettings(false);
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_yAxisProperties, "yAxisProperties", "Y Axis", "", "", "");
|
||||
m_yAxisProperties.uiCapability()->setUiTreeHidden(true);
|
||||
m_yAxisProperties = new RimPlotAxisProperties;
|
||||
m_yAxisProperties->setNameAndAxis("Y-Axis", QwtPlot::yLeft);
|
||||
m_yAxisProperties->setEnableTitleTextSettings(false);
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_crossPlotCurveSets, "CrossPlotCurve", "Cross Plot Data Set", "", "", "");
|
||||
m_crossPlotCurveSets.uiCapability()->setUiHidden(true);
|
||||
|
||||
@ -115,6 +133,11 @@ QImage RimGridCrossPlot::snapshotWindowContent()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridCrossPlot::zoomAll()
|
||||
{
|
||||
setAutoZoomForAllAxes(true);
|
||||
updateAxisInQwt(RiaDefines::PLOT_AXIS_LEFT);
|
||||
updateAxisInQwt(RiaDefines::PLOT_AXIS_BOTTOM);
|
||||
updateZoomWindowFromQwt();
|
||||
m_qwtPlot->replot();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -177,6 +200,91 @@ caf::PdmFieldHandle* RimGridCrossPlot::userDescriptionField()
|
||||
return m_nameConfig->nameField();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridCrossPlot::detachAllCurves()
|
||||
{
|
||||
for (auto curveSet : m_crossPlotCurveSets())
|
||||
{
|
||||
curveSet->detachAllCurves();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridCrossPlot::updateAxisScaling()
|
||||
{
|
||||
updateAxisDisplay();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridCrossPlot::updateAxisDisplay()
|
||||
{
|
||||
updateAxisInQwt(RiaDefines::PLOT_AXIS_BOTTOM);
|
||||
updateAxisInQwt(RiaDefines::PLOT_AXIS_LEFT);
|
||||
m_qwtPlot->replot();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridCrossPlot::updateZoomWindowFromQwt()
|
||||
{
|
||||
if (!m_qwtPlot) return;
|
||||
|
||||
updateAxisFromQwt(RiaDefines::PLOT_AXIS_LEFT);
|
||||
updateAxisFromQwt(RiaDefines::PLOT_AXIS_BOTTOM);
|
||||
|
||||
setAutoZoomForAllAxes(false);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridCrossPlot::selectAxisInPropertyEditor(int axis)
|
||||
{
|
||||
RiuPlotMainWindowTools::showPlotMainWindow();
|
||||
if (axis == QwtPlot::yLeft)
|
||||
{
|
||||
RiuPlotMainWindowTools::selectAsCurrentItem(m_yAxisProperties);
|
||||
}
|
||||
else if (axis == QwtPlot::xBottom)
|
||||
{
|
||||
RiuPlotMainWindowTools::selectAsCurrentItem(m_xAxisProperties);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridCrossPlot::setAutoZoomForAllAxes(bool enableAutoZoom)
|
||||
{
|
||||
m_xAxisProperties->setAutoZoom(enableAutoZoom);
|
||||
m_yAxisProperties->setAutoZoom(enableAutoZoom);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::PdmObject* RimGridCrossPlot::findRimPlotObjectFromQwtCurve(const QwtPlotCurve* qwtCurve) const
|
||||
{
|
||||
for (auto curveSet : m_crossPlotCurveSets)
|
||||
{
|
||||
for (auto curve : curveSet->curves())
|
||||
{
|
||||
if (curve->qwtPlotCurve() == qwtCurve)
|
||||
{
|
||||
return curve;
|
||||
}
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -184,7 +292,7 @@ QWidget* RimGridCrossPlot::createViewWidget(QWidget* mainWindowParent)
|
||||
{
|
||||
if (!m_qwtPlot)
|
||||
{
|
||||
m_qwtPlot = new RiuGridCrossQwtPlot(this, mainWindowParent);
|
||||
m_qwtPlot = new RiuQwtPlot(this, mainWindowParent);
|
||||
|
||||
for (auto curveSet : m_crossPlotCurveSets)
|
||||
{
|
||||
@ -223,6 +331,7 @@ void RimGridCrossPlot::onLoadDataAndUpdate()
|
||||
|
||||
performAutoNameUpdate();
|
||||
updateAllRequiredEditors();
|
||||
|
||||
updatePlot();
|
||||
|
||||
}
|
||||
@ -245,6 +354,21 @@ void RimGridCrossPlot::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering
|
||||
uiOrdering.skipRemainingFields(true);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridCrossPlot::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/)
|
||||
{
|
||||
caf::PdmUiTreeOrdering* axisFolder = uiTreeOrdering.add("Axes", ":/Axes16x16.png");
|
||||
|
||||
axisFolder->add(&m_xAxisProperties);
|
||||
axisFolder->add(&m_yAxisProperties);
|
||||
|
||||
uiTreeOrdering.add(&m_crossPlotCurveSets);
|
||||
|
||||
uiTreeOrdering.skipRemainingChildren(true);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -300,14 +424,11 @@ 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);
|
||||
|
||||
updateAxisDisplay();
|
||||
|
||||
for (auto curveSet : m_crossPlotCurveSets)
|
||||
{
|
||||
curveSet->setParentQwtPlotNoReplot(m_qwtPlot);
|
||||
@ -376,12 +497,101 @@ QString RimGridCrossPlot::yAxisParameterString() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridCrossPlot::detachAllCurves()
|
||||
void RimGridCrossPlot::updateAxisInQwt(RiaDefines::PlotAxis axisType)
|
||||
{
|
||||
for (auto curveSet : m_crossPlotCurveSets())
|
||||
RimPlotAxisProperties* axisProperties = m_xAxisProperties();
|
||||
QString axisParameterString = xAxisParameterString();
|
||||
|
||||
if (axisType == RiaDefines::PLOT_AXIS_LEFT)
|
||||
{
|
||||
curveSet->detachAllCurves();
|
||||
axisProperties = m_yAxisProperties();
|
||||
axisParameterString = yAxisParameterString();
|
||||
}
|
||||
|
||||
QwtPlot::Axis qwtAxisId = axisProperties->qwtPlotAxisType();
|
||||
|
||||
if (axisProperties->isActive())
|
||||
{
|
||||
m_qwtPlot->enableAxis(qwtAxisId, true);
|
||||
|
||||
if (axisProperties->isAutoZoom())
|
||||
{
|
||||
m_qwtPlot->setAxisAutoScale(qwtAxisId);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_qwtPlot->setAxisScale(qwtAxisId, axisProperties->visibleRangeMin, axisProperties->visibleRangeMax);
|
||||
}
|
||||
|
||||
QwtText axisTitle(axisParameterString);
|
||||
QFont font = m_qwtPlot->axisFont(qwtAxisId);
|
||||
font.setBold(true);
|
||||
font.setPixelSize(axisProperties->titleFontSize);
|
||||
axisTitle.setFont(font);
|
||||
|
||||
switch (axisProperties->titlePositionEnum())
|
||||
{
|
||||
case RimPlotAxisProperties::AXIS_TITLE_CENTER:
|
||||
axisTitle.setRenderFlags(Qt::AlignCenter);
|
||||
break;
|
||||
case RimPlotAxisProperties::AXIS_TITLE_END:
|
||||
axisTitle.setRenderFlags(Qt::AlignRight);
|
||||
break;
|
||||
}
|
||||
|
||||
m_qwtPlot->setAxisTitle(qwtAxisId, axisTitle);
|
||||
|
||||
if (axisProperties->isLogarithmicScaleEnabled)
|
||||
{
|
||||
QwtLogScaleEngine* currentScaleEngine =
|
||||
dynamic_cast<QwtLogScaleEngine*>(m_qwtPlot->axisScaleEngine(axisProperties->qwtPlotAxisType()));
|
||||
if (!currentScaleEngine)
|
||||
{
|
||||
m_qwtPlot->setAxisScaleEngine(axisProperties->qwtPlotAxisType(), new QwtLogScaleEngine);
|
||||
m_qwtPlot->setAxisMaxMinor(axisProperties->qwtPlotAxisType(), 5);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QwtLinearScaleEngine* currentScaleEngine =
|
||||
dynamic_cast<QwtLinearScaleEngine*>(m_qwtPlot->axisScaleEngine(axisProperties->qwtPlotAxisType()));
|
||||
if (!currentScaleEngine)
|
||||
{
|
||||
m_qwtPlot->setAxisScaleEngine(axisProperties->qwtPlotAxisType(), new QwtLinearScaleEngine);
|
||||
m_qwtPlot->setAxisMaxMinor(axisProperties->qwtPlotAxisType(), 3);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
m_qwtPlot->enableAxis(qwtAxisId, false);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridCrossPlot::updateAxisFromQwt(RiaDefines::PlotAxis axisType)
|
||||
{
|
||||
CVF_ASSERT(m_qwtPlot);
|
||||
|
||||
QwtInterval xAxisRange = m_qwtPlot->currentAxisRange(QwtPlot::xBottom);
|
||||
QwtInterval yAxisRange = m_qwtPlot->currentAxisRange(QwtPlot::yLeft);
|
||||
|
||||
RimPlotAxisProperties* axisProperties = m_xAxisProperties();
|
||||
QwtInterval axisRange = xAxisRange;
|
||||
|
||||
if (axisType == RiaDefines::PLOT_AXIS_LEFT)
|
||||
{
|
||||
axisProperties = m_yAxisProperties();
|
||||
axisRange = yAxisRange;
|
||||
}
|
||||
|
||||
axisProperties->visibleRangeMin = axisRange.minValue();
|
||||
axisProperties->visibleRangeMax = axisRange.maxValue();
|
||||
|
||||
axisProperties->updateConnectedEditors();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -21,13 +21,16 @@
|
||||
#include "cafPdmChildField.h"
|
||||
#include "cafPdmObject.h"
|
||||
|
||||
#include "RiaDefines.h"
|
||||
#include "RimRiuQwtPlotOwnerInterface.h"
|
||||
#include "RimNameConfig.h"
|
||||
#include "RimViewWindow.h"
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
class RimPlotAxisProperties;
|
||||
class RimGridCrossPlotCurveSet;
|
||||
class RiuGridCrossQwtPlot;
|
||||
class RiuQwtPlot;
|
||||
|
||||
class RimGridCrossPlotNameConfig : public RimNameConfig
|
||||
{
|
||||
@ -42,9 +45,10 @@ protected:
|
||||
|
||||
};
|
||||
|
||||
class RimGridCrossPlot : public RimViewWindow, public RimNameConfigHolderInterface
|
||||
class RimGridCrossPlot : public RimViewWindow, public RimRiuQwtPlotOwnerInterface, public RimNameConfigHolderInterface
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RimGridCrossPlot();
|
||||
~RimGridCrossPlot();
|
||||
@ -61,12 +65,22 @@ public:
|
||||
|
||||
caf::PdmFieldHandle* userDescriptionField() override;
|
||||
void detachAllCurves();
|
||||
public:
|
||||
// Rim2dPlotInterface overrides
|
||||
void updateAxisScaling() override;
|
||||
void updateAxisDisplay() override;
|
||||
void updateZoomWindowFromQwt() override;
|
||||
void selectAxisInPropertyEditor(int axis) override;
|
||||
void setAutoZoomForAllAxes(bool enableAutoZoom) override;
|
||||
caf::PdmObject* findRimPlotObjectFromQwtCurve(const QwtPlotCurve* curve) const override;
|
||||
|
||||
protected:
|
||||
QWidget* createViewWidget(QWidget* mainWindowParent) override;
|
||||
void deleteViewWidget() override;
|
||||
void onLoadDataAndUpdate() override;
|
||||
void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
|
||||
void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "") override;
|
||||
|
||||
void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
|
||||
QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions,
|
||||
bool* useOptionsOnly) override;
|
||||
@ -76,14 +90,20 @@ protected:
|
||||
QString xAxisParameterString() const;
|
||||
QString yAxisParameterString() const;
|
||||
|
||||
void updateAxisInQwt(RiaDefines::PlotAxis axisType);
|
||||
void updateAxisFromQwt(RiaDefines::PlotAxis axisType);
|
||||
|
||||
private:
|
||||
caf::PdmField<bool> m_showLegend;
|
||||
caf::PdmField<int> m_legendFontSize;
|
||||
caf::PdmChildField<RimGridCrossPlotNameConfig*> m_nameConfig;
|
||||
|
||||
caf::PdmChildField<RimPlotAxisProperties*> m_yAxisProperties;
|
||||
caf::PdmChildField<RimPlotAxisProperties*> m_xAxisProperties;
|
||||
|
||||
caf::PdmChildArrayField<RimGridCrossPlotCurveSet*> m_crossPlotCurveSets;
|
||||
|
||||
QPointer<RiuGridCrossQwtPlot> m_qwtPlot;
|
||||
QPointer<RiuQwtPlot> m_qwtPlot;
|
||||
|
||||
};
|
||||
|
||||
|
@ -168,6 +168,14 @@ void RimGridCrossPlotCurveSet::detachAllCurves()
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimGridCrossPlotCurve*> RimGridCrossPlotCurveSet::curves() const
|
||||
{
|
||||
return m_crossPlotCurves.childObjects();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -67,6 +67,9 @@ public:
|
||||
int indexInPlot() const;
|
||||
QString createAutoName() const override;
|
||||
void detachAllCurves();
|
||||
|
||||
std::vector< RimGridCrossPlotCurve*> curves() const;
|
||||
|
||||
protected:
|
||||
void initAfterRead() override;
|
||||
void onLoadDataAndUpdate(bool updateParentPlot);
|
||||
|
@ -1,6 +1,7 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2016 Statoil ASA
|
||||
// Copyright (C) 2016-2018 Statoil ASA
|
||||
// Copyright (C) 2019- Equinor 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
|
||||
@ -16,10 +17,11 @@
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RimSummaryAxisProperties.h"
|
||||
#include "RimPlotAxisProperties.h"
|
||||
|
||||
#include "RiaDefines.h"
|
||||
#include "RimSummaryPlot.h"
|
||||
|
||||
#include "RimRiuQwtPlotOwnerInterface.h"
|
||||
|
||||
#include "cafPdmUiSliderEditor.h"
|
||||
|
||||
@ -29,33 +31,34 @@
|
||||
namespace caf
|
||||
{
|
||||
template<>
|
||||
void caf::AppEnum<RimSummaryAxisProperties::NumberFormatType>::setUp()
|
||||
void caf::AppEnum<RimPlotAxisProperties::NumberFormatType>::setUp()
|
||||
{
|
||||
addItem(RimSummaryAxisProperties::NUMBER_FORMAT_AUTO, "NUMBER_FORMAT_AUTO", "Auto");
|
||||
addItem(RimSummaryAxisProperties::NUMBER_FORMAT_DECIMAL, "NUMBER_FORMAT_DECIMAL", "Decimal");
|
||||
addItem(RimSummaryAxisProperties::NUMBER_FORMAT_SCIENTIFIC, "NUMBER_FORMAT_SCIENTIFIC", "Scientific");
|
||||
addItem(RimPlotAxisProperties::NUMBER_FORMAT_AUTO, "NUMBER_FORMAT_AUTO", "Auto");
|
||||
addItem(RimPlotAxisProperties::NUMBER_FORMAT_DECIMAL, "NUMBER_FORMAT_DECIMAL", "Decimal");
|
||||
addItem(RimPlotAxisProperties::NUMBER_FORMAT_SCIENTIFIC, "NUMBER_FORMAT_SCIENTIFIC", "Scientific");
|
||||
|
||||
setDefault(RimSummaryAxisProperties::NUMBER_FORMAT_AUTO);
|
||||
setDefault(RimPlotAxisProperties::NUMBER_FORMAT_AUTO);
|
||||
}
|
||||
|
||||
template<>
|
||||
void caf::AppEnum<RimSummaryAxisProperties::AxisTitlePositionType>::setUp()
|
||||
void caf::AppEnum<RimPlotAxisProperties::AxisTitlePositionType>::setUp()
|
||||
{
|
||||
addItem(RimSummaryAxisProperties::AXIS_TITLE_CENTER, "AXIS_TITLE_CENTER", "Center");
|
||||
addItem(RimSummaryAxisProperties::AXIS_TITLE_END, "AXIS_TITLE_END", "At End");
|
||||
addItem(RimPlotAxisProperties::AXIS_TITLE_CENTER, "AXIS_TITLE_CENTER", "Center");
|
||||
addItem(RimPlotAxisProperties::AXIS_TITLE_END, "AXIS_TITLE_END", "At End");
|
||||
|
||||
setDefault(RimSummaryAxisProperties::AXIS_TITLE_CENTER);
|
||||
setDefault(RimPlotAxisProperties::AXIS_TITLE_CENTER);
|
||||
}
|
||||
} // namespace caf
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimSummaryAxisProperties, "SummaryYAxisProperties");
|
||||
CAF_PDM_SOURCE_INIT(RimPlotAxisProperties, "SummaryYAxisProperties");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSummaryAxisProperties::RimSummaryAxisProperties()
|
||||
RimPlotAxisProperties::RimPlotAxisProperties()
|
||||
: m_enableTitleTextSettings(true)
|
||||
{
|
||||
CAF_PDM_InitObject("Y-Axis Properties", ":/LeftAxis16x16.png", "", "");
|
||||
CAF_PDM_InitObject("Axis Properties", ":/LeftAxis16x16.png", "", "");
|
||||
|
||||
CAF_PDM_InitField(&m_isActive, "Active", true, "Active", "", "", "");
|
||||
m_isActive.uiCapability()->setUiHidden(true);
|
||||
@ -88,13 +91,20 @@ RimSummaryAxisProperties::RimSummaryAxisProperties()
|
||||
|
||||
updateOptionSensitivity();
|
||||
}
|
||||
|
||||
// clang-format on
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::PdmFieldHandle* RimSummaryAxisProperties::userDescriptionField()
|
||||
void RimPlotAxisProperties::setEnableTitleTextSettings(bool enable)
|
||||
{
|
||||
m_enableTitleTextSettings = enable;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::PdmFieldHandle* RimPlotAxisProperties::userDescriptionField()
|
||||
{
|
||||
return &m_name;
|
||||
}
|
||||
@ -102,7 +112,7 @@ caf::PdmFieldHandle* RimSummaryAxisProperties::userDescriptionField()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QList<caf::PdmOptionItemInfo> RimSummaryAxisProperties::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions,
|
||||
QList<caf::PdmOptionItemInfo> RimPlotAxisProperties::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions,
|
||||
bool* useOptionsOnly)
|
||||
{
|
||||
QList<caf::PdmOptionItemInfo> options;
|
||||
@ -144,8 +154,9 @@ QList<caf::PdmOptionItemInfo> RimSummaryAxisProperties::calculateValueOptions(co
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryAxisProperties::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
|
||||
void RimPlotAxisProperties::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
|
||||
{
|
||||
if (m_enableTitleTextSettings)
|
||||
{
|
||||
caf::PdmUiGroup* titleTextGroup = uiOrdering.addNewGroup("Title Text");
|
||||
|
||||
@ -192,7 +203,7 @@ void RimSummaryAxisProperties::defineUiOrdering(QString uiConfigName, caf::PdmUi
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryAxisProperties::setNameAndAxis(const QString& name, QwtPlot::Axis axis)
|
||||
void RimPlotAxisProperties::setNameAndAxis(const QString& name, QwtPlot::Axis axis)
|
||||
{
|
||||
m_name = name;
|
||||
m_axis = axis;
|
||||
@ -204,7 +215,7 @@ void RimSummaryAxisProperties::setNameAndAxis(const QString& name, QwtPlot::Axis
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QwtPlot::Axis RimSummaryAxisProperties::qwtPlotAxisType() const
|
||||
QwtPlot::Axis RimPlotAxisProperties::qwtPlotAxisType() const
|
||||
{
|
||||
return m_axis;
|
||||
}
|
||||
@ -212,7 +223,7 @@ QwtPlot::Axis RimSummaryAxisProperties::qwtPlotAxisType() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiaDefines::PlotAxis RimSummaryAxisProperties::plotAxisType() const
|
||||
RiaDefines::PlotAxis RimPlotAxisProperties::plotAxisType() const
|
||||
{
|
||||
if (m_axis == QwtPlot::yRight) return RiaDefines::PLOT_AXIS_RIGHT;
|
||||
if (m_axis == QwtPlot::xBottom) return RiaDefines::PLOT_AXIS_BOTTOM;
|
||||
@ -223,7 +234,7 @@ RiaDefines::PlotAxis RimSummaryAxisProperties::plotAxisType() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimSummaryAxisProperties::useAutoTitle() const
|
||||
bool RimPlotAxisProperties::useAutoTitle() const
|
||||
{
|
||||
return isAutoTitle();
|
||||
}
|
||||
@ -231,7 +242,7 @@ bool RimSummaryAxisProperties::useAutoTitle() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimSummaryAxisProperties::showDescription() const
|
||||
bool RimPlotAxisProperties::showDescription() const
|
||||
{
|
||||
return m_displayLongName();
|
||||
}
|
||||
@ -239,7 +250,7 @@ bool RimSummaryAxisProperties::showDescription() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimSummaryAxisProperties::showAcronym() const
|
||||
bool RimPlotAxisProperties::showAcronym() const
|
||||
{
|
||||
return m_displayShortName();
|
||||
}
|
||||
@ -247,7 +258,7 @@ bool RimSummaryAxisProperties::showAcronym() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimSummaryAxisProperties::showUnitText() const
|
||||
bool RimPlotAxisProperties::showUnitText() const
|
||||
{
|
||||
return m_displayUnitText();
|
||||
}
|
||||
@ -255,7 +266,7 @@ bool RimSummaryAxisProperties::showUnitText() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimSummaryAxisProperties::isAutoZoom() const
|
||||
bool RimPlotAxisProperties::isAutoZoom() const
|
||||
{
|
||||
return m_isAutoZoom();
|
||||
}
|
||||
@ -263,7 +274,7 @@ bool RimSummaryAxisProperties::isAutoZoom() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryAxisProperties::setAutoZoom(bool enableAutoZoom)
|
||||
void RimPlotAxisProperties::setAutoZoom(bool enableAutoZoom)
|
||||
{
|
||||
m_isAutoZoom = enableAutoZoom;
|
||||
}
|
||||
@ -271,7 +282,7 @@ void RimSummaryAxisProperties::setAutoZoom(bool enableAutoZoom)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimSummaryAxisProperties::isActive() const
|
||||
bool RimPlotAxisProperties::isActive() const
|
||||
{
|
||||
return m_isActive;
|
||||
}
|
||||
@ -279,38 +290,37 @@ bool RimSummaryAxisProperties::isActive() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryAxisProperties::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue,
|
||||
void RimPlotAxisProperties::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue,
|
||||
const QVariant& newValue)
|
||||
{
|
||||
if (changedField == &isAutoTitle)
|
||||
{
|
||||
updateOptionSensitivity();
|
||||
}
|
||||
|
||||
RimSummaryPlot* rimSummaryPlot = nullptr;
|
||||
this->firstAncestorOrThisOfType(rimSummaryPlot);
|
||||
if (rimSummaryPlot)
|
||||
else if (changedField == &visibleRangeMax)
|
||||
{
|
||||
if (changedField == &visibleRangeMax)
|
||||
{
|
||||
if (visibleRangeMin > visibleRangeMax) visibleRangeMax = oldValue.toDouble();
|
||||
if (visibleRangeMin > visibleRangeMax) visibleRangeMax = oldValue.toDouble();
|
||||
|
||||
m_isAutoZoom = false;
|
||||
}
|
||||
else if (changedField == &visibleRangeMin)
|
||||
{
|
||||
if (visibleRangeMin > visibleRangeMax) visibleRangeMin = oldValue.toDouble();
|
||||
m_isAutoZoom = false;
|
||||
}
|
||||
else if (changedField == &visibleRangeMin)
|
||||
{
|
||||
if (visibleRangeMin > visibleRangeMax) visibleRangeMin = oldValue.toDouble();
|
||||
|
||||
m_isAutoZoom = false;
|
||||
}
|
||||
m_isAutoZoom = false;
|
||||
}
|
||||
|
||||
RimRiuQwtPlotOwnerInterface* parentPlot = nullptr;
|
||||
this->firstAncestorOrThisOfType(parentPlot);
|
||||
if (parentPlot)
|
||||
{
|
||||
if (changedField == &isLogarithmicScaleEnabled)
|
||||
{
|
||||
rimSummaryPlot->loadDataAndUpdate();
|
||||
parentPlot->updateAxisScaling();
|
||||
}
|
||||
else
|
||||
{
|
||||
rimSummaryPlot->updateAxes();
|
||||
parentPlot->updateAxisDisplay();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -318,7 +328,7 @@ void RimSummaryAxisProperties::fieldChangedByUi(const caf::PdmFieldHandle* chang
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryAxisProperties::updateOptionSensitivity()
|
||||
void RimPlotAxisProperties::updateOptionSensitivity()
|
||||
{
|
||||
customTitle.uiCapability()->setUiReadOnly(isAutoTitle);
|
||||
}
|
||||
@ -326,7 +336,7 @@ void RimSummaryAxisProperties::updateOptionSensitivity()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryAxisProperties::initAfterRead()
|
||||
void RimPlotAxisProperties::initAfterRead()
|
||||
{
|
||||
updateOptionSensitivity();
|
||||
}
|
||||
@ -334,7 +344,7 @@ void RimSummaryAxisProperties::initAfterRead()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::PdmFieldHandle* RimSummaryAxisProperties::objectToggleField()
|
||||
caf::PdmFieldHandle* RimPlotAxisProperties::objectToggleField()
|
||||
{
|
||||
return &m_isActive;
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2016 Statoil ASA
|
||||
// Copyright (C) 2016-2018 Statoil ASA
|
||||
// Copyright (C) 2019- Equinor 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
|
||||
@ -33,7 +34,7 @@
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
class RimSummaryAxisProperties : public caf::PdmObject
|
||||
class RimPlotAxisProperties : public caf::PdmObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
@ -52,8 +53,9 @@ public:
|
||||
};
|
||||
|
||||
public:
|
||||
RimSummaryAxisProperties();
|
||||
RimPlotAxisProperties();
|
||||
|
||||
void setEnableTitleTextSettings(bool enable);
|
||||
void setNameAndAxis(const QString& name, QwtPlot::Axis axis);
|
||||
QwtPlot::Axis qwtPlotAxisType() const;
|
||||
RiaDefines::PlotAxis plotAxisType() const;
|
||||
@ -104,4 +106,6 @@ private:
|
||||
|
||||
caf::PdmField<QString> m_name;
|
||||
QwtPlot::Axis m_axis;
|
||||
|
||||
bool m_enableTitleTextSettings;
|
||||
};
|
@ -0,0 +1,42 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2019- Equinor 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"
|
||||
|
||||
namespace caf
|
||||
{
|
||||
class PdmObject;
|
||||
}
|
||||
|
||||
class QwtPlotCurve;
|
||||
|
||||
class RimRiuQwtPlotOwnerInterface
|
||||
{
|
||||
public:
|
||||
virtual void detachAllCurves() = 0;
|
||||
virtual void updateAxisScaling() = 0;
|
||||
virtual void updateAxisDisplay() = 0;
|
||||
virtual void updateZoomWindowFromQwt() = 0;
|
||||
virtual void selectAxisInPropertyEditor(int axis) = 0;
|
||||
virtual void setAutoZoomForAllAxes(bool enableAutoZoom) = 0;
|
||||
|
||||
virtual caf::PdmObject* findRimPlotObjectFromQwtCurve(const QwtPlotCurve* curve) const = 0;
|
||||
|
||||
|
||||
};
|
@ -17,7 +17,6 @@ ${CMAKE_CURRENT_LIST_DIR}/RimSummaryPlot.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimSummaryPlotCollection.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimSummaryCrossPlotCollection.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimSummaryTimeAxisProperties.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimSummaryAxisProperties.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimObservedData.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimObservedDataCollection.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimSummaryObservedDataFile.h
|
||||
@ -58,7 +57,6 @@ ${CMAKE_CURRENT_LIST_DIR}/RimSummaryPlot.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimSummaryPlotCollection.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimSummaryCrossPlotCollection.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimSummaryTimeAxisProperties.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimSummaryAxisProperties.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimObservedData.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimObservedDataCollection.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimSummaryObservedDataFile.cpp
|
||||
|
@ -31,13 +31,13 @@
|
||||
#include "RimSummaryTimeAxisProperties.h"
|
||||
|
||||
#include "RiuQwtPlotCurve.h"
|
||||
#include "RiuSummaryQwtPlot.h"
|
||||
|
||||
#include "cafPdmUiComboBoxEditor.h"
|
||||
#include "cafPdmUiListEditor.h"
|
||||
#include "cafPdmUiTreeOrdering.h"
|
||||
|
||||
#include "qwt_date.h"
|
||||
#include "qwt_plot.h"
|
||||
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimAsciiDataCurve, "AsciiDataCurve");
|
||||
|
@ -49,8 +49,8 @@
|
||||
|
||||
#include "RiuQwtPlotCurve.h"
|
||||
#include "RiuPlotMainWindow.h"
|
||||
#include "RiuSummaryQwtPlot.h"
|
||||
#include "RiuSummaryCurveDefSelectionDialog.h"
|
||||
#include "RiuSummaryQwtPlot.h"
|
||||
|
||||
#include "cafPdmUiTreeOrdering.h"
|
||||
#include "cafPdmUiListEditor.h"
|
||||
|
@ -34,7 +34,8 @@
|
||||
#include "RimSummaryPlotSourceStepping.h"
|
||||
|
||||
#include "RiuQwtPlotCurve.h"
|
||||
#include "RiuSummaryQwtPlot.h"
|
||||
|
||||
#include "qwt_plot.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimEnsembleCurveSetCollection, "RimEnsembleCurveSetCollection");
|
||||
|
||||
|
@ -45,7 +45,6 @@
|
||||
#include "RiuQwtPlotCurve.h"
|
||||
#include "RiuPlotMainWindow.h"
|
||||
#include "RiuSummaryCurveDefSelectionDialog.h"
|
||||
#include "RiuSummaryQwtPlot.h"
|
||||
|
||||
#include "cafPdmUiComboBoxEditor.h"
|
||||
#include "cafPdmUiListEditor.h"
|
||||
@ -53,6 +52,7 @@
|
||||
#include "cafPdmUiTreeOrdering.h"
|
||||
|
||||
#include "qwt_date.h"
|
||||
#include "qwt_plot.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
|
@ -30,11 +30,13 @@
|
||||
#include "RimSummaryPlot.h"
|
||||
#include "RimSummaryPlotSourceStepping.h"
|
||||
|
||||
#include "RiuQwtPlotCurve.h"
|
||||
#include "RiuSummaryQwtPlot.h"
|
||||
#include "RiuQwtPlotCurve.h"
|
||||
|
||||
#include "cafPdmUiTreeViewEditor.h"
|
||||
|
||||
#include "qwt_plot.h"
|
||||
|
||||
#include <QKeyEvent>
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimSummaryCurveCollection, "RimSummaryCurveCollection");
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
#include "RiaDefines.h"
|
||||
#include "RimSummaryCurve.h"
|
||||
#include "RimSummaryAxisProperties.h"
|
||||
#include "RimPlotAxisProperties.h"
|
||||
#include "RimAsciiDataCurve.h"
|
||||
|
||||
#include "RiuSummaryQwtPlot.h"
|
||||
@ -105,7 +105,7 @@ private:
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSummaryPlotYAxisFormatter::RimSummaryPlotYAxisFormatter(RimSummaryAxisProperties* axisProperties,
|
||||
RimSummaryPlotYAxisFormatter::RimSummaryPlotYAxisFormatter(RimPlotAxisProperties* axisProperties,
|
||||
const std::vector<RimSummaryCurve*>& summaryCurves,
|
||||
const std::vector<RimAsciiDataCurve*>& asciiCurves,
|
||||
const std::set<QString>& timeHistoryCurveQuantities)
|
||||
@ -138,10 +138,10 @@ void RimSummaryPlotYAxisFormatter::applyYAxisPropertiesToPlot(RiuSummaryQwtPlot*
|
||||
|
||||
switch (m_axisProperties->titlePositionEnum())
|
||||
{
|
||||
case RimSummaryAxisProperties::AXIS_TITLE_CENTER:
|
||||
case RimPlotAxisProperties::AXIS_TITLE_CENTER:
|
||||
axisTitleY.setRenderFlags(Qt::AlignCenter);
|
||||
break;
|
||||
case RimSummaryAxisProperties::AXIS_TITLE_END:
|
||||
case RimPlotAxisProperties::AXIS_TITLE_END:
|
||||
axisTitleY.setRenderFlags(Qt::AlignRight);
|
||||
break;
|
||||
}
|
||||
@ -157,16 +157,16 @@ void RimSummaryPlotYAxisFormatter::applyYAxisPropertiesToPlot(RiuSummaryQwtPlot*
|
||||
}
|
||||
|
||||
{
|
||||
if (m_axisProperties->numberFormat == RimSummaryAxisProperties::NUMBER_FORMAT_AUTO)
|
||||
if (m_axisProperties->numberFormat == RimPlotAxisProperties::NUMBER_FORMAT_AUTO)
|
||||
{
|
||||
qwtPlot->setAxisScaleDraw(m_axisProperties->qwtPlotAxisType(), new QwtScaleDraw);
|
||||
}
|
||||
else if (m_axisProperties->numberFormat == RimSummaryAxisProperties::NUMBER_FORMAT_DECIMAL)
|
||||
else if (m_axisProperties->numberFormat == RimPlotAxisProperties::NUMBER_FORMAT_DECIMAL)
|
||||
{
|
||||
qwtPlot->setAxisScaleDraw(m_axisProperties->qwtPlotAxisType(),
|
||||
new DecimalScaleDraw(m_axisProperties->scaleFactor(), m_axisProperties->numberOfDecimals()));
|
||||
}
|
||||
else if (m_axisProperties->numberFormat == RimSummaryAxisProperties::NUMBER_FORMAT_SCIENTIFIC)
|
||||
else if (m_axisProperties->numberFormat == RimPlotAxisProperties::NUMBER_FORMAT_SCIENTIFIC)
|
||||
{
|
||||
qwtPlot->setAxisScaleDraw(m_axisProperties->qwtPlotAxisType(),
|
||||
new ScientificScaleDraw(m_axisProperties->scaleFactor(), m_axisProperties->numberOfDecimals()));
|
||||
@ -265,7 +265,7 @@ QString RimSummaryPlotYAxisFormatter::autoAxisTitle() const
|
||||
QString assembledYAxisText;
|
||||
QString scaleFactorText = "";
|
||||
|
||||
if (m_axisProperties->numberFormat() != RimSummaryAxisProperties::NUMBER_FORMAT_AUTO)
|
||||
if (m_axisProperties->numberFormat() != RimPlotAxisProperties::NUMBER_FORMAT_AUTO)
|
||||
{
|
||||
if (m_axisProperties->scaleFactor() != 1.0)
|
||||
{
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
class RimAsciiDataCurve;
|
||||
class RimSummaryCurve;
|
||||
class RimSummaryAxisProperties;
|
||||
class RimPlotAxisProperties;
|
||||
|
||||
class RiuSummaryQwtPlot;
|
||||
|
||||
@ -33,7 +33,7 @@ class QwtPlotCurve;
|
||||
class RimSummaryPlotYAxisFormatter
|
||||
{
|
||||
public:
|
||||
RimSummaryPlotYAxisFormatter(RimSummaryAxisProperties* axisProperties,
|
||||
RimSummaryPlotYAxisFormatter(RimPlotAxisProperties* axisProperties,
|
||||
const std::vector<RimSummaryCurve*>& summaryCurves,
|
||||
const std::vector<RimAsciiDataCurve*>& asciiCurves,
|
||||
const std::set<QString>& timeHistoryCurveQuantities);
|
||||
@ -46,7 +46,7 @@ private:
|
||||
static std::string shortCalculationName(const std::string& calculationName);
|
||||
|
||||
private:
|
||||
RimSummaryAxisProperties* m_axisProperties;
|
||||
RimPlotAxisProperties* m_axisProperties;
|
||||
const std::vector<RimSummaryCurve*> m_summaryCurves;
|
||||
const std::vector<RimAsciiDataCurve*> m_asciiDataCurves;
|
||||
const std::set<QString> m_timeHistoryCurveQuantities;
|
||||
|
@ -29,7 +29,7 @@
|
||||
#include "RimEnsembleCurveSet.h"
|
||||
#include "RimGridTimeHistoryCurve.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimSummaryAxisProperties.h"
|
||||
#include "RimPlotAxisProperties.h"
|
||||
#include "RimSummaryCase.h"
|
||||
#include "RimSummaryCurve.h"
|
||||
#include "RimSummaryCurveCollection.h"
|
||||
@ -160,17 +160,17 @@ RimSummaryPlot::RimSummaryPlot()
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_leftYAxisProperties, "LeftYAxisProperties", "Left Y Axis", "", "", "");
|
||||
m_leftYAxisProperties.uiCapability()->setUiTreeHidden(true);
|
||||
m_leftYAxisProperties = new RimSummaryAxisProperties;
|
||||
m_leftYAxisProperties = new RimPlotAxisProperties;
|
||||
m_leftYAxisProperties->setNameAndAxis("Left Y-Axis", QwtPlot::yLeft);
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_rightYAxisProperties, "RightYAxisProperties", "Right Y Axis", "", "", "");
|
||||
m_rightYAxisProperties.uiCapability()->setUiTreeHidden(true);
|
||||
m_rightYAxisProperties = new RimSummaryAxisProperties;
|
||||
m_rightYAxisProperties = new RimPlotAxisProperties;
|
||||
m_rightYAxisProperties->setNameAndAxis("Right Y-Axis", QwtPlot::yRight);
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_bottomAxisProperties, "BottomAxisProperties", "Bottom X Axis", "", "", "");
|
||||
m_bottomAxisProperties.uiCapability()->setUiTreeHidden(true);
|
||||
m_bottomAxisProperties = new RimSummaryAxisProperties;
|
||||
m_bottomAxisProperties = new RimPlotAxisProperties;
|
||||
m_bottomAxisProperties->setNameAndAxis("Bottom X-Axis", QwtPlot::xBottom);
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_timeAxisProperties, "TimeAxisProperties", "Time Axis", "", "", "");
|
||||
@ -238,33 +238,6 @@ RimSummaryTimeAxisProperties* RimSummaryPlot::timeAxisProperties()
|
||||
return m_timeAxisProperties();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlot::selectAxisInPropertyEditor(int axis)
|
||||
{
|
||||
RiuPlotMainWindowTools::showPlotMainWindow();
|
||||
if (axis == QwtPlot::yLeft)
|
||||
{
|
||||
RiuPlotMainWindowTools::selectAsCurrentItem(m_leftYAxisProperties);
|
||||
}
|
||||
else if (axis == QwtPlot::yRight)
|
||||
{
|
||||
RiuPlotMainWindowTools::selectAsCurrentItem(m_rightYAxisProperties);
|
||||
}
|
||||
else if (axis == QwtPlot::xBottom)
|
||||
{
|
||||
if (m_isCrossPlot)
|
||||
{
|
||||
RiuPlotMainWindowTools::selectAsCurrentItem(m_bottomAxisProperties);
|
||||
}
|
||||
else
|
||||
{
|
||||
RiuPlotMainWindowTools::selectAsCurrentItem(m_timeAxisProperties);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -565,6 +538,22 @@ size_t RimSummaryPlot::singleColorCurveCount() const
|
||||
return colorIndex;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlot::updateAxisScaling()
|
||||
{
|
||||
loadDataAndUpdate();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlot::updateAxisDisplay()
|
||||
{
|
||||
updateAxes();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -582,7 +571,7 @@ void RimSummaryPlot::updateAxis(RiaDefines::PlotAxis plotAxis)
|
||||
qwtAxis = QwtPlot::yRight;
|
||||
}
|
||||
|
||||
RimSummaryAxisProperties* yAxisProperties = yAxisPropertiesLeftOrRight(plotAxis);
|
||||
RimPlotAxisProperties* yAxisProperties = yAxisPropertiesLeftOrRight(plotAxis);
|
||||
if (yAxisProperties->isActive() && hasVisibleCurvesForAxis(plotAxis))
|
||||
{
|
||||
m_qwtPlot->enableAxis(qwtAxis, true);
|
||||
@ -639,7 +628,7 @@ void RimSummaryPlot::updateZoomForAxis(RiaDefines::PlotAxis plotAxis)
|
||||
}
|
||||
else
|
||||
{
|
||||
RimSummaryAxisProperties* yAxisProps = yAxisPropertiesLeftOrRight(plotAxis);
|
||||
RimPlotAxisProperties* yAxisProps = yAxisPropertiesLeftOrRight(plotAxis);
|
||||
|
||||
if (yAxisProps->isAutoZoom())
|
||||
{
|
||||
@ -764,9 +753,9 @@ bool RimSummaryPlot::hasVisibleCurvesForAxis(RiaDefines::PlotAxis plotAxis) cons
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSummaryAxisProperties* RimSummaryPlot::yAxisPropertiesLeftOrRight(RiaDefines::PlotAxis leftOrRightPlotAxis) const
|
||||
RimPlotAxisProperties* RimSummaryPlot::yAxisPropertiesLeftOrRight(RiaDefines::PlotAxis leftOrRightPlotAxis) const
|
||||
{
|
||||
RimSummaryAxisProperties* yAxisProps = nullptr;
|
||||
RimPlotAxisProperties* yAxisProps = nullptr;
|
||||
|
||||
if (leftOrRightPlotAxis == RiaDefines::PLOT_AXIS_LEFT)
|
||||
{
|
||||
@ -892,7 +881,7 @@ void RimSummaryPlot::updateBottomXAxis()
|
||||
|
||||
QwtPlot::Axis qwtAxis = QwtPlot::xBottom;
|
||||
|
||||
RimSummaryAxisProperties* bottomAxisProperties = m_bottomAxisProperties();
|
||||
RimPlotAxisProperties* bottomAxisProperties = m_bottomAxisProperties();
|
||||
|
||||
if (bottomAxisProperties->isActive())
|
||||
{
|
||||
@ -1267,6 +1256,51 @@ void RimSummaryPlot::updateZoomWindowFromQwt()
|
||||
setAutoZoomForAllAxes(false);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlot::selectAxisInPropertyEditor(int axis)
|
||||
{
|
||||
RiuPlotMainWindowTools::showPlotMainWindow();
|
||||
if (axis == QwtPlot::yLeft)
|
||||
{
|
||||
RiuPlotMainWindowTools::selectAsCurrentItem(m_leftYAxisProperties);
|
||||
}
|
||||
else if (axis == QwtPlot::yRight)
|
||||
{
|
||||
RiuPlotMainWindowTools::selectAsCurrentItem(m_rightYAxisProperties);
|
||||
}
|
||||
else if (axis == QwtPlot::xBottom)
|
||||
{
|
||||
if (m_isCrossPlot)
|
||||
{
|
||||
RiuPlotMainWindowTools::selectAsCurrentItem(m_bottomAxisProperties);
|
||||
}
|
||||
else
|
||||
{
|
||||
RiuPlotMainWindowTools::selectAsCurrentItem(m_timeAxisProperties);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlot::setAutoZoomForAllAxes(bool enableAutoZoom)
|
||||
{
|
||||
m_leftYAxisProperties->setAutoZoom(enableAutoZoom);
|
||||
m_rightYAxisProperties->setAutoZoom(enableAutoZoom);
|
||||
|
||||
if (m_isCrossPlot)
|
||||
{
|
||||
m_bottomAxisProperties->setAutoZoom(enableAutoZoom);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_timeAxisProperties->setAutoZoom(enableAutoZoom);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -1274,8 +1308,9 @@ void RimSummaryPlot::updateAxisRangesFromQwt()
|
||||
{
|
||||
if (!m_qwtPlot) return;
|
||||
|
||||
QwtInterval leftAxis, rightAxis, timeAxis;
|
||||
m_qwtPlot->currentVisibleWindow(&leftAxis, &rightAxis, &timeAxis);
|
||||
QwtInterval leftAxis = m_qwtPlot->currentAxisRange(QwtPlot::yLeft);
|
||||
QwtInterval rightAxis = m_qwtPlot->currentAxisRange(QwtPlot::yRight);
|
||||
QwtInterval timeAxis = m_qwtPlot->currentAxisRange(QwtPlot::xBottom);
|
||||
|
||||
m_leftYAxisProperties->visibleRangeMax = leftAxis.maxValue();
|
||||
m_leftYAxisProperties->visibleRangeMin = leftAxis.minValue();
|
||||
@ -1300,24 +1335,6 @@ void RimSummaryPlot::updateAxisRangesFromQwt()
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlot::setAutoZoomForAllAxes(bool enableAutoZoom)
|
||||
{
|
||||
m_leftYAxisProperties->setAutoZoom(enableAutoZoom);
|
||||
m_rightYAxisProperties->setAutoZoom(enableAutoZoom);
|
||||
|
||||
if (m_isCrossPlot)
|
||||
{
|
||||
m_bottomAxisProperties->setAutoZoom(enableAutoZoom);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_timeAxisProperties->setAutoZoom(enableAutoZoom);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
#include "RifEclipseSummaryAddress.h"
|
||||
|
||||
#include "RimRiuQwtPlotOwnerInterface.h"
|
||||
#include "RimViewWindow.h"
|
||||
|
||||
#include "qwt_plot_textlabel.h"
|
||||
@ -44,7 +45,7 @@ class RimEnsembleCurveSet;
|
||||
class RimEnsembleCurveSetCollection;
|
||||
class RimSummaryCurveFilter_OBSOLETE;
|
||||
class RimSummaryTimeAxisProperties;
|
||||
class RimSummaryAxisProperties;
|
||||
class RimPlotAxisProperties;
|
||||
class RiuSummaryQwtPlot;
|
||||
class RimSummaryPlotNameHelper;
|
||||
|
||||
@ -55,7 +56,7 @@ class QwtPlotCurve;
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
class RimSummaryPlot : public RimViewWindow
|
||||
class RimSummaryPlot : public RimViewWindow, public RimRiuQwtPlotOwnerInterface
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
@ -84,7 +85,6 @@ public:
|
||||
|
||||
void addAsciiDataCruve(RimAsciiDataCurve* curve);
|
||||
|
||||
caf::PdmObject* findRimPlotObjectFromQwtCurve(const QwtPlotCurve* curve) const;
|
||||
size_t curveCount() const;
|
||||
|
||||
void detachAllCurves();
|
||||
@ -92,19 +92,16 @@ public:
|
||||
void updateCaseNameHasChanged();
|
||||
|
||||
void updateAxes();
|
||||
void zoomAll() override;
|
||||
void zoomAll() override;
|
||||
|
||||
void updateZoomInQwt();
|
||||
void updateZoomWindowFromQwt();
|
||||
|
||||
bool isLogarithmicScaleEnabled(RiaDefines::PlotAxis plotAxis) const;
|
||||
|
||||
RimSummaryTimeAxisProperties* timeAxisProperties();
|
||||
time_t firstTimeStepOfFirstCurve();
|
||||
|
||||
void selectAxisInPropertyEditor(int axis);
|
||||
|
||||
QWidget* viewWidget() override;
|
||||
QWidget* viewWidget() override;
|
||||
|
||||
QString asciiDataForPlotExport(DateTimePeriod resamplingPeriod = DateTimePeriod::NONE) const;
|
||||
|
||||
@ -134,8 +131,18 @@ public:
|
||||
bool containsResamplableCurves() const;
|
||||
|
||||
size_t singleColorCurveCount() const;
|
||||
// RimViewWindow overrides
|
||||
|
||||
public:
|
||||
// Rim2dPlotInterface overrides
|
||||
void updateAxisScaling() override;
|
||||
void updateAxisDisplay() override;
|
||||
void updateZoomWindowFromQwt() override;
|
||||
void selectAxisInPropertyEditor(int axis) override;
|
||||
void setAutoZoomForAllAxes(bool enableAutoZoom) override;
|
||||
caf::PdmObject* findRimPlotObjectFromQwtCurve(const QwtPlotCurve* curve) const override;
|
||||
|
||||
public:
|
||||
// RimViewWindow overrides
|
||||
QWidget* createViewWidget(QWidget* mainWindowParent) override;
|
||||
void deleteViewWidget() override;
|
||||
void initAfterRead() override;
|
||||
@ -164,7 +171,7 @@ private:
|
||||
std::vector<RimAsciiDataCurve*> visibleAsciiDataCurvesForAxis(RiaDefines::PlotAxis plotAxis) const;
|
||||
bool hasVisibleCurvesForAxis(RiaDefines::PlotAxis plotAxis) const;
|
||||
|
||||
RimSummaryAxisProperties* yAxisPropertiesLeftOrRight(RiaDefines::PlotAxis leftOrRightPlotAxis) const;
|
||||
RimPlotAxisProperties* yAxisPropertiesLeftOrRight(RiaDefines::PlotAxis leftOrRightPlotAxis) const;
|
||||
void updateAxis(RiaDefines::PlotAxis plotAxis);
|
||||
|
||||
void updateZoomForAxis(RiaDefines::PlotAxis plotAxis);
|
||||
@ -173,7 +180,6 @@ private:
|
||||
void updateBottomXAxis();
|
||||
|
||||
void updateAxisRangesFromQwt();
|
||||
void setAutoZoomForAllAxes(bool enableAutoZoom);
|
||||
|
||||
private:
|
||||
caf::PdmField<bool> m_showPlotTitle;
|
||||
@ -189,10 +195,10 @@ private:
|
||||
|
||||
caf::PdmChildArrayField<RimAsciiDataCurve*> m_asciiDataCurves;
|
||||
|
||||
caf::PdmChildField<RimSummaryAxisProperties*> m_leftYAxisProperties;
|
||||
caf::PdmChildField<RimSummaryAxisProperties*> m_rightYAxisProperties;
|
||||
caf::PdmChildField<RimPlotAxisProperties*> m_leftYAxisProperties;
|
||||
caf::PdmChildField<RimPlotAxisProperties*> m_rightYAxisProperties;
|
||||
|
||||
caf::PdmChildField<RimSummaryAxisProperties*> m_bottomAxisProperties;
|
||||
caf::PdmChildField<RimPlotAxisProperties*> m_bottomAxisProperties;
|
||||
caf::PdmChildField<RimSummaryTimeAxisProperties*> m_timeAxisProperties;
|
||||
|
||||
QPointer<RiuSummaryQwtPlot> m_qwtPlot;
|
||||
|
@ -36,7 +36,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RiuRmsNavigation.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuSelectionChangedHandler.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/Riu3dSelectionManager.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuSimpleHistogramWidget.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuGridCrossQwtPlot.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlot.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuSummaryQwtPlot.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuTextDialog.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuTimeStepChangedHandler.h
|
||||
@ -117,7 +117,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RiuRmsNavigation.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuSelectionChangedHandler.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/Riu3dSelectionManager.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuSimpleHistogramWidget.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuGridCrossQwtPlot.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlot.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuSummaryQwtPlot.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuTextDialog.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuTimeStepChangedHandler.cpp
|
||||
@ -184,7 +184,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RiuTreeViewEventFilter.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuWellLogPlot.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuWellLogTrack.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuRecentFileActionProvider.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuGridCrossQwtPlot.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlot.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuSummaryQwtPlot.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuTofAccumulatedPhaseFractionsPlot.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuQwtScalePicker.h
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include "RiuQwtPlotWheelZoomer.h"
|
||||
#include "RiuQwtPlotZoomer.h"
|
||||
#include "RiuResultQwtPlot.h"
|
||||
#include "RiuSummaryQwtPlot.h"
|
||||
#include "RiuQwtPlotTools.h"
|
||||
|
||||
#include "cvfBase.h"
|
||||
#include "cvfColor3.h"
|
||||
@ -73,18 +73,18 @@ RiuFlowCharacteristicsPlot::RiuFlowCharacteristicsPlot(RimFlowCharacteristicsPlo
|
||||
mainLayout->addWidget(m_flowCapVsStorageCapPlot, 1, 0);
|
||||
mainLayout->addWidget(m_sweepEffPlot, 1, 1);
|
||||
|
||||
RiuSummaryQwtPlot::setCommonPlotBehaviour(m_lorenzPlot);
|
||||
RiuQwtPlotTools::setCommonPlotBehaviour(m_lorenzPlot);
|
||||
new RiuQwtPlotWheelZoomer(m_lorenzPlot);
|
||||
addWindowZoom(m_lorenzPlot);
|
||||
RiuSummaryQwtPlot::enableDateBasedBottomXAxis(m_lorenzPlot);
|
||||
RiuQwtPlotTools::enableDateBasedBottomXAxis(m_lorenzPlot);
|
||||
m_lorenzPlot->setTitle("Lorenz Coefficient");
|
||||
|
||||
RiuSummaryQwtPlot::setCommonPlotBehaviour(m_sweepEffPlot);
|
||||
RiuQwtPlotTools::setCommonPlotBehaviour(m_sweepEffPlot);
|
||||
new RiuQwtPlotWheelZoomer(m_sweepEffPlot);
|
||||
addWindowZoom(m_sweepEffPlot);
|
||||
m_sweepEffPlot->setTitle("Sweep Efficiency");
|
||||
|
||||
RiuSummaryQwtPlot::setCommonPlotBehaviour(m_flowCapVsStorageCapPlot);
|
||||
RiuQwtPlotTools::setCommonPlotBehaviour(m_flowCapVsStorageCapPlot);
|
||||
new RiuQwtPlotWheelZoomer(m_flowCapVsStorageCapPlot);
|
||||
addWindowZoom(m_flowCapVsStorageCapPlot);
|
||||
m_flowCapVsStorageCapPlot->setTitle("Flow Capacity vs Storage Capacity");
|
||||
|
@ -1,73 +0,0 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2019- Equinor 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 "RiuGridCrossQwtPlot.h"
|
||||
|
||||
#include "RimGridCrossPlot.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuGridCrossQwtPlot::RiuGridCrossQwtPlot(RimGridCrossPlot* plotDefinition, QWidget* parent /*= nullptr*/)
|
||||
{
|
||||
Q_ASSERT(plotDefinition);
|
||||
m_plotDefinition = plotDefinition;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuGridCrossQwtPlot::~RiuGridCrossQwtPlot()
|
||||
{
|
||||
if (m_plotDefinition)
|
||||
{
|
||||
m_plotDefinition->detachAllCurves();
|
||||
m_plotDefinition->handleMdiWindowClosed();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimGridCrossPlot* RiuGridCrossQwtPlot::ownerPlotDefinition()
|
||||
{
|
||||
return m_plotDefinition;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimViewWindow* RiuGridCrossQwtPlot::ownerViewWindow() const
|
||||
{
|
||||
return m_plotDefinition;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QSize RiuGridCrossQwtPlot::sizeHint() const
|
||||
{
|
||||
return QSize(0, 0);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QSize RiuGridCrossQwtPlot::minimumSizeHint() const
|
||||
{
|
||||
return QSize(0, 100);
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2019- Equinor 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 "RiuInterfaceToViewWindow.h"
|
||||
|
||||
#include "cafPdmPointer.h"
|
||||
|
||||
#include "qwt_plot.h"
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
class RimGridCrossPlot;
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==================================================================================================
|
||||
class RiuGridCrossQwtPlot : public QwtPlot, public RiuInterfaceToViewWindow
|
||||
{
|
||||
Q_OBJECT;
|
||||
|
||||
public:
|
||||
RiuGridCrossQwtPlot(RimGridCrossPlot* plotDefinition, QWidget* parent = nullptr);
|
||||
~RiuGridCrossQwtPlot() override;
|
||||
|
||||
RimGridCrossPlot* ownerPlotDefinition();
|
||||
RimViewWindow* ownerViewWindow() const override;
|
||||
|
||||
protected:
|
||||
QSize sizeHint() const override;
|
||||
QSize minimumSizeHint() const override;
|
||||
private:
|
||||
caf::PdmPointer<RimGridCrossPlot> m_plotDefinition;
|
||||
|
||||
};
|
@ -26,7 +26,6 @@
|
||||
|
||||
#include "RiuPlotMainWindow.h"
|
||||
#include "RiuMainWindow.h"
|
||||
#include "RiuSummaryQwtPlot.h"
|
||||
#include "RiuViewer.h"
|
||||
#include "RiuWellLogPlot.h"
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include "RiaColorTables.h"
|
||||
|
||||
#include "Riu3dSelectionManager.h"
|
||||
#include "RiuSummaryQwtPlot.h"
|
||||
#include "RiuQwtPlotTools.h"
|
||||
|
||||
#include "RigFemPart.h"
|
||||
#include "RigFemPartCollection.h"
|
||||
@ -66,7 +66,7 @@ RiuMohrsCirclePlot::RiuMohrsCirclePlot(QWidget* parent)
|
||||
, m_sourceGeoMechViewOfLastPlot(nullptr)
|
||||
, m_scheduleUpdateAxisScaleTimer(nullptr)
|
||||
{
|
||||
RiuSummaryQwtPlot::setCommonPlotBehaviour(this);
|
||||
RiuQwtPlotTools::setCommonPlotBehaviour(this);
|
||||
|
||||
enableAxis(QwtPlot::xBottom, true);
|
||||
enableAxis(QwtPlot::yLeft, true);
|
||||
|
@ -36,7 +36,6 @@
|
||||
|
||||
#include "RiuDragDrop.h"
|
||||
#include "RiuMdiSubWindow.h"
|
||||
#include "RiuSummaryQwtPlot.h"
|
||||
#include "RiuToolTipMenu.h"
|
||||
#include "RiuTreeViewEventFilter.h"
|
||||
#include "RiuWellAllocationPlot.h"
|
||||
|
@ -18,7 +18,6 @@
|
||||
|
||||
#include "RiuPvtPlotPanel.h"
|
||||
#include "RiuPvtPlotUpdater.h"
|
||||
#include "RiuSummaryQwtPlot.h"
|
||||
|
||||
#include "RigFlowDiagSolverInterface.h"
|
||||
|
||||
|
217
ApplicationCode/UserInterface/RiuQwtPlot.cpp
Normal file
217
ApplicationCode/UserInterface/RiuQwtPlot.cpp
Normal file
@ -0,0 +1,217 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2016- 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 "RiuQwtPlot.h"
|
||||
|
||||
#include "RimProject.h"
|
||||
|
||||
#include "RiuPlotMainWindowTools.h"
|
||||
#include "RiuQwtCurvePointTracker.h"
|
||||
#include "RiuQwtPlotTools.h"
|
||||
#include "RiuQwtPlotWheelZoomer.h"
|
||||
#include "RiuQwtPlotZoomer.h"
|
||||
#include "RiuQwtScalePicker.h"
|
||||
|
||||
#include "qwt_date_scale_draw.h"
|
||||
#include "qwt_date_scale_engine.h"
|
||||
#include "qwt_legend.h"
|
||||
#include "qwt_plot_curve.h"
|
||||
#include "qwt_plot_grid.h"
|
||||
#include "qwt_plot_layout.h"
|
||||
#include "qwt_plot_magnifier.h"
|
||||
#include "qwt_plot_panner.h"
|
||||
#include "qwt_plot_zoomer.h"
|
||||
#include "qwt_scale_engine.h"
|
||||
|
||||
#include <QEvent>
|
||||
#include <QMenu>
|
||||
#include <QWheelEvent>
|
||||
|
||||
#include <cfloat>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuQwtPlot::RiuQwtPlot(RimViewWindow* viewWindow, QWidget* parent) : QwtPlot(parent)
|
||||
{
|
||||
Q_ASSERT(viewWindow);
|
||||
m_ownerViewWindow = viewWindow;
|
||||
|
||||
// LeftButton for the zooming
|
||||
m_zoomerLeft = new RiuQwtPlotZoomer(canvas());
|
||||
m_zoomerLeft->setRubberBandPen(QColor(Qt::black));
|
||||
m_zoomerLeft->setTrackerMode(QwtPicker::AlwaysOff);
|
||||
m_zoomerLeft->setTrackerPen(QColor(Qt::black));
|
||||
m_zoomerLeft->initMousePattern(1);
|
||||
|
||||
// Attach a zoomer for the right axis
|
||||
m_zoomerRight = new RiuQwtPlotZoomer(canvas());
|
||||
m_zoomerRight->setAxis(xTop, yRight);
|
||||
m_zoomerRight->setTrackerMode(QwtPicker::AlwaysOff);
|
||||
m_zoomerRight->initMousePattern(1);
|
||||
|
||||
// MidButton for the panning
|
||||
QwtPlotPanner* panner = new QwtPlotPanner(canvas());
|
||||
panner->setMouseButton(Qt::MidButton);
|
||||
|
||||
auto wheelZoomer = new RiuQwtPlotWheelZoomer(this);
|
||||
|
||||
connect(wheelZoomer, SIGNAL(zoomUpdated()), SLOT(onZoomedSlot()));
|
||||
connect(m_zoomerLeft, SIGNAL(zoomed( const QRectF & )), SLOT(onZoomedSlot()));
|
||||
connect(panner, SIGNAL(panned( int , int )), SLOT(onZoomedSlot()));
|
||||
|
||||
RiuQwtScalePicker* scalePicker = new RiuQwtScalePicker(this);
|
||||
connect(scalePicker, SIGNAL(clicked(int, double)), this, SLOT(onAxisClicked(int, double)));
|
||||
|
||||
RiuQwtPlotTools::setCommonPlotBehaviour(this);
|
||||
RiuQwtPlotTools::setDefaultAxes(this);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuQwtPlot::~RiuQwtPlot()
|
||||
{
|
||||
if (ownerPlotDefinition())
|
||||
{
|
||||
ownerPlotDefinition()->detachAllCurves();
|
||||
}
|
||||
if (ownerViewWindow())
|
||||
{
|
||||
ownerViewWindow()->handleMdiWindowClosed();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimRiuQwtPlotOwnerInterface* RiuQwtPlot::ownerPlotDefinition() const
|
||||
{
|
||||
RimRiuQwtPlotOwnerInterface* plotDefinition = dynamic_cast<RimRiuQwtPlotOwnerInterface*>(ownerViewWindow());
|
||||
return plotDefinition;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimViewWindow* RiuQwtPlot::ownerViewWindow() const
|
||||
{
|
||||
return m_ownerViewWindow;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QSize RiuQwtPlot::minimumSizeHint() const
|
||||
{
|
||||
return QSize(0, 100);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QSize RiuQwtPlot::sizeHint() const
|
||||
{
|
||||
return QSize(0, 0);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QwtInterval RiuQwtPlot::currentAxisRange(QwtPlot::Axis axis)
|
||||
{
|
||||
return axisScaleDiv(axis).interval();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RiuQwtPlot::eventFilter(QObject* watched, QEvent* event)
|
||||
{
|
||||
if(watched == canvas())
|
||||
{
|
||||
QMouseEvent* mouseEvent = dynamic_cast<QMouseEvent*>(event);
|
||||
if(mouseEvent)
|
||||
{
|
||||
if(mouseEvent->button() == Qt::LeftButton && mouseEvent->type() == QMouseEvent::MouseButtonRelease)
|
||||
{
|
||||
selectClosestCurve(mouseEvent->pos());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return QwtPlot::eventFilter(watched, event);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuQwtPlot::selectClosestCurve(const QPoint& pos)
|
||||
{
|
||||
QwtPlotCurve* closestCurve = nullptr;
|
||||
double distMin = DBL_MAX;
|
||||
|
||||
const QwtPlotItemList& itmList = itemList();
|
||||
for(QwtPlotItemIterator it = itmList.begin(); it != itmList.end(); it++)
|
||||
{
|
||||
if((*it)->rtti() == QwtPlotItem::Rtti_PlotCurve)
|
||||
{
|
||||
QwtPlotCurve* candidateCurve = static_cast<QwtPlotCurve*>(*it);
|
||||
double dist = DBL_MAX;
|
||||
candidateCurve->closestPoint(pos, &dist);
|
||||
if(dist < distMin)
|
||||
{
|
||||
closestCurve = candidateCurve;
|
||||
distMin = dist;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (closestCurve && distMin < 20)
|
||||
{
|
||||
caf::PdmObject* selectedPlotObject = ownerPlotDefinition()->findRimPlotObjectFromQwtCurve(closestCurve);
|
||||
|
||||
if (selectedPlotObject)
|
||||
{
|
||||
RimProject* proj = nullptr;
|
||||
selectedPlotObject->firstAncestorOrThisOfType(proj);
|
||||
|
||||
if (proj)
|
||||
{
|
||||
RiuPlotMainWindowTools::showPlotMainWindow();
|
||||
RiuPlotMainWindowTools::selectAsCurrentItem(selectedPlotObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuQwtPlot::onZoomedSlot()
|
||||
{
|
||||
ownerPlotDefinition()->updateZoomWindowFromQwt();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuQwtPlot::onAxisClicked(int axis, double value)
|
||||
{
|
||||
ownerPlotDefinition()->selectAxisInPropertyEditor(axis);
|
||||
}
|
76
ApplicationCode/UserInterface/RiuQwtPlot.h
Normal file
76
ApplicationCode/UserInterface/RiuQwtPlot.h
Normal file
@ -0,0 +1,76 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2016- 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 "RiuInterfaceToViewWindow.h"
|
||||
|
||||
#include "RimRiuQwtPlotOwnerInterface.h"
|
||||
|
||||
#include "cafPdmPointer.h"
|
||||
|
||||
#include "qwt_plot.h"
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
class QwtPlotCurve;
|
||||
class QwtPlotGrid;
|
||||
class QwtPlotZoomer;
|
||||
class QwtInterval;
|
||||
class QwtPicker;
|
||||
class QwtPlotMarker;
|
||||
class QwtScaleWidget;
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==================================================================================================
|
||||
class RiuQwtPlot : public QwtPlot, public RiuInterfaceToViewWindow
|
||||
{
|
||||
Q_OBJECT;
|
||||
public:
|
||||
RiuQwtPlot(RimViewWindow* viewWindow, QWidget* parent = nullptr);
|
||||
~RiuQwtPlot() override;
|
||||
|
||||
RimRiuQwtPlotOwnerInterface* ownerPlotDefinition() const;
|
||||
RimViewWindow* ownerViewWindow() const override;
|
||||
|
||||
QwtInterval currentAxisRange(QwtPlot::Axis axis);
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject* watched, QEvent* event) override;
|
||||
|
||||
QSize sizeHint() const override;
|
||||
QSize minimumSizeHint() const override;
|
||||
|
||||
private:
|
||||
void selectClosestCurve(const QPoint& pos);
|
||||
|
||||
private slots:
|
||||
void onZoomedSlot( );
|
||||
void onAxisClicked(int axis, double value);
|
||||
|
||||
private:
|
||||
caf::PdmPointer<RimViewWindow> m_ownerViewWindow;
|
||||
|
||||
QPointer<QwtPlotZoomer> m_zoomerLeft;
|
||||
QPointer<QwtPlotZoomer> m_zoomerRight;
|
||||
|
||||
};
|
||||
|
@ -17,6 +17,8 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
#include "RiuQwtPlotTools.h"
|
||||
|
||||
#include "qwt_date_scale_draw.h"
|
||||
#include "qwt_date_scale_engine.h"
|
||||
#include "qwt_plot.h"
|
||||
#include "qwt_plot_grid.h"
|
||||
#include "qwt_plot_layout.h"
|
||||
@ -100,3 +102,16 @@ void RiuQwtPlotTools::setDefaultAxes(QwtPlot* plot)
|
||||
plot->setAxisMaxMinor(QwtPlot::xBottom, 2);
|
||||
plot->setAxisMaxMinor(QwtPlot::yLeft, 3);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuQwtPlotTools::enableDateBasedBottomXAxis(QwtPlot* plot)
|
||||
{
|
||||
QwtDateScaleDraw* scaleDraw = new QwtDateScaleDraw(Qt::UTC);
|
||||
scaleDraw->setDateFormat(QwtDate::Year, QString("dd-MM-yyyy"));
|
||||
|
||||
QwtDateScaleEngine* scaleEngine = new QwtDateScaleEngine(Qt::UTC);
|
||||
plot->setAxisScaleEngine(QwtPlot::xBottom, scaleEngine);
|
||||
plot->setAxisScaleDraw(QwtPlot::xBottom, scaleDraw);
|
||||
}
|
@ -24,5 +24,6 @@ class RiuQwtPlotTools
|
||||
public:
|
||||
static void setCommonPlotBehaviour(QwtPlot* plot);
|
||||
static void setDefaultAxes(QwtPlot* plot);
|
||||
static void enableDateBasedBottomXAxis(QwtPlot* plot);
|
||||
};
|
||||
|
||||
|
@ -18,8 +18,8 @@
|
||||
|
||||
#include "RiuRelativePermeabilityPlotPanel.h"
|
||||
#include "RiuRelativePermeabilityPlotUpdater.h"
|
||||
#include "RiuSummaryQwtPlot.h"
|
||||
#include "RiuQwtPlotCurve.h"
|
||||
#include "RiuQwtPlotTools.h"
|
||||
#include "RiuTextDialog.h"
|
||||
|
||||
#include "RiaCurveDataTools.h"
|
||||
@ -154,7 +154,7 @@ RiuRelativePermeabilityPlotPanel::~RiuRelativePermeabilityPlotPanel()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuRelativePermeabilityPlotPanel::setPlotDefaults(QwtPlot* plot)
|
||||
{
|
||||
RiuSummaryQwtPlot::setCommonPlotBehaviour(plot);
|
||||
RiuQwtPlotTools::setCommonPlotBehaviour(plot);
|
||||
|
||||
{
|
||||
QwtText plotTitle = plot->title();
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include "RimCase.h"
|
||||
|
||||
#include "RiuQwtPlotCurve.h"
|
||||
#include "RiuSummaryQwtPlot.h"
|
||||
#include "RiuQwtPlotTools.h"
|
||||
#include "RiuTextDialog.h"
|
||||
|
||||
#include "cafCmdFeatureMenuBuilder.h"
|
||||
@ -173,14 +173,14 @@ void RiuResultQwtPlot::contextMenuEvent(QContextMenuEvent* event)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuResultQwtPlot::setDefaults()
|
||||
{
|
||||
RiuSummaryQwtPlot::setCommonPlotBehaviour(this);
|
||||
RiuQwtPlotTools::setCommonPlotBehaviour(this);
|
||||
|
||||
enableAxis(QwtPlot::xBottom, true);
|
||||
enableAxis(QwtPlot::yLeft, true);
|
||||
enableAxis(QwtPlot::xTop, false);
|
||||
enableAxis(QwtPlot::yRight, false);
|
||||
|
||||
RiuSummaryQwtPlot::enableDateBasedBottomXAxis(this);
|
||||
RiuQwtPlotTools::enableDateBasedBottomXAxis(this);
|
||||
|
||||
setAxisMaxMinor(QwtPlot::xBottom, 2);
|
||||
setAxisMaxMinor(QwtPlot::yLeft, 3);
|
||||
|
@ -1,85 +1,80 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2016- Statoil ASA
|
||||
//
|
||||
// Copyright (C) 2019- Equinor 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>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RiuSummaryQwtPlot.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
|
||||
#include "RimContextCommandBuilder.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimEnsembleCurveSet.h"
|
||||
#include "RimEnsembleCurveSetCollection.h"
|
||||
#include "RimMainPlotCollection.h"
|
||||
#include "RimRegularLegendConfig.h"
|
||||
#include "RimSummaryCase.h"
|
||||
#include "RimSummaryCurve.h"
|
||||
#include "RimSummaryCurveCollection.h"
|
||||
#include "RimSummaryPlot.h"
|
||||
#include "RimSummaryPlotCollection.h"
|
||||
|
||||
#include "RiuPlotMainWindowTools.h"
|
||||
#include "RiuCvfOverlayItemWidget.h"
|
||||
#include "RiuQwtCurvePointTracker.h"
|
||||
#include "RiuRimQwtPlotCurve.h"
|
||||
#include "RiuWidgetDragger.h"
|
||||
|
||||
#include "RiuPlotMainWindowTools.h"
|
||||
#include "RiuQwtPlotZoomer.h"
|
||||
#include "RiuQwtPlotTools.h"
|
||||
#include "RiuQwtPlotWheelZoomer.h"
|
||||
#include "RiuQwtPlotZoomer.h"
|
||||
#include "RiuQwtScalePicker.h"
|
||||
|
||||
#include "cafSelectionManager.h"
|
||||
#include "cafCmdFeatureMenuBuilder.h"
|
||||
#include "RimProject.h"
|
||||
|
||||
#include "qwt_date_scale_draw.h"
|
||||
#include "qwt_date_scale_engine.h"
|
||||
#include "cafCmdFeatureMenuBuilder.h"
|
||||
#include "cafSelectionManager.h"
|
||||
#include "cafTitledOverlayFrame.h"
|
||||
|
||||
#include "qwt_interval.h"
|
||||
#include "qwt_legend.h"
|
||||
#include "qwt_plot_curve.h"
|
||||
#include "qwt_plot_grid.h"
|
||||
#include "qwt_plot_layout.h"
|
||||
#include "qwt_plot_magnifier.h"
|
||||
#include "qwt_plot_panner.h"
|
||||
#include "qwt_plot_zoomer.h"
|
||||
#include "qwt_date_scale_draw.h"
|
||||
#include "qwt_date_scale_engine.h"
|
||||
#include "qwt_scale_div.h"
|
||||
#include "qwt_scale_draw.h"
|
||||
#include "qwt_scale_engine.h"
|
||||
|
||||
#include <QEvent>
|
||||
#include <QMenu>
|
||||
#include <QMouseEvent>
|
||||
#include <QWheelEvent>
|
||||
|
||||
|
||||
#include "RiuWidgetDragger.h"
|
||||
#include "RiuCvfOverlayItemWidget.h"
|
||||
#include "RimEnsembleCurveSet.h"
|
||||
#include "RimRegularLegendConfig.h"
|
||||
#include "cafTitledOverlayFrame.h"
|
||||
#include "RimEnsembleCurveSetCollection.h"
|
||||
#include "RimMainPlotCollection.h"
|
||||
#include "RimSummaryPlotCollection.h"
|
||||
#include "RimSummaryCase.h"
|
||||
#include "RiuRimQwtPlotCurve.h"
|
||||
#include "RimSummaryCurve.h"
|
||||
|
||||
#include <cfloat>
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class EnsembleCurveInfoTextProvider : public IPlotCurveInfoTextProvider
|
||||
{
|
||||
public:
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString curveInfoText(QwtPlotCurve* curve) override
|
||||
{
|
||||
RiuRimQwtPlotCurve* riuCurve = dynamic_cast<RiuRimQwtPlotCurve*>(curve);
|
||||
RimSummaryCurve* sumCurve = nullptr;
|
||||
RiuRimQwtPlotCurve* riuCurve = dynamic_cast<RiuRimQwtPlotCurve*>(curve);
|
||||
RimSummaryCurve* sumCurve = nullptr;
|
||||
if (riuCurve)
|
||||
{
|
||||
sumCurve = dynamic_cast<RimSummaryCurve*>(riuCurve->ownerRimCurve());
|
||||
@ -91,161 +86,76 @@ public:
|
||||
static EnsembleCurveInfoTextProvider ensembleCurveInfoTextProvider;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuSummaryQwtPlot::RiuSummaryQwtPlot(RimSummaryPlot* plotDefinition, QWidget* parent) : QwtPlot(parent)
|
||||
RiuSummaryQwtPlot::RiuSummaryQwtPlot(RimViewWindow* viewWindow, QWidget* parent /*= nullptr*/)
|
||||
: RiuQwtPlot(viewWindow, parent)
|
||||
{
|
||||
Q_ASSERT(plotDefinition);
|
||||
m_plotDefinition = plotDefinition;
|
||||
|
||||
setDefaults();
|
||||
|
||||
// LeftButton for the zooming
|
||||
m_zoomerLeft = new RiuQwtPlotZoomer(canvas());
|
||||
m_zoomerLeft->setRubberBandPen(QColor(Qt::black));
|
||||
m_zoomerLeft->setTrackerMode(QwtPicker::AlwaysOff);
|
||||
m_zoomerLeft->setTrackerPen(QColor(Qt::black));
|
||||
m_zoomerLeft->initMousePattern(1);
|
||||
|
||||
// Attach a zoomer for the right axis
|
||||
m_zoomerRight = new RiuQwtPlotZoomer(canvas());
|
||||
m_zoomerRight->setAxis(xTop, yRight);
|
||||
m_zoomerRight->setTrackerMode(QwtPicker::AlwaysOff);
|
||||
m_zoomerRight->initMousePattern(1);
|
||||
|
||||
// MidButton for the panning
|
||||
QwtPlotPanner* panner = new QwtPlotPanner(canvas());
|
||||
panner->setMouseButton(Qt::MidButton);
|
||||
|
||||
auto wheelZoomer = new RiuQwtPlotWheelZoomer(this);
|
||||
|
||||
connect(wheelZoomer, SIGNAL(zoomUpdated()), SLOT(onZoomedSlot()));
|
||||
connect(m_zoomerLeft, SIGNAL(zoomed( const QRectF & )), SLOT(onZoomedSlot()));
|
||||
connect(panner, SIGNAL(panned( int , int )), SLOT(onZoomedSlot()));
|
||||
|
||||
RiuQwtScalePicker* scalePicker = new RiuQwtScalePicker(this);
|
||||
connect(scalePicker, SIGNAL(clicked(int, double)), this, SLOT(onAxisClicked(int, double)));
|
||||
|
||||
new RiuQwtCurvePointTracker(this, true, &ensembleCurveInfoTextProvider);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuSummaryQwtPlot::~RiuSummaryQwtPlot()
|
||||
void RiuSummaryQwtPlot::useDateBasedTimeAxis()
|
||||
{
|
||||
if (m_plotDefinition)
|
||||
RiuQwtPlotTools::enableDateBasedBottomXAxis(this);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuSummaryQwtPlot::useTimeBasedTimeAxis()
|
||||
{
|
||||
setAxisScaleEngine(QwtPlot::xBottom, new QwtLinearScaleEngine());
|
||||
setAxisScaleDraw(QwtPlot::xBottom, new QwtScaleDraw());
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuSummaryQwtPlot::addOrUpdateEnsembleCurveSetLegend(RimEnsembleCurveSet* curveSetToShowLegendFor)
|
||||
{
|
||||
RiuCvfOverlayItemWidget* overlayWidget = nullptr;
|
||||
|
||||
auto it = m_ensembleLegendWidgets.find(curveSetToShowLegendFor);
|
||||
if (it == m_ensembleLegendWidgets.end() || it->second == nullptr)
|
||||
{
|
||||
m_plotDefinition->detachAllCurves();
|
||||
m_plotDefinition->handleMdiWindowClosed();
|
||||
overlayWidget = new RiuCvfOverlayItemWidget(this);
|
||||
|
||||
new RiuWidgetDragger(overlayWidget);
|
||||
|
||||
m_ensembleLegendWidgets[curveSetToShowLegendFor] = overlayWidget;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSummaryPlot* RiuSummaryQwtPlot::ownerPlotDefinition()
|
||||
{
|
||||
return m_plotDefinition;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimViewWindow* RiuSummaryQwtPlot::ownerViewWindow() const
|
||||
{
|
||||
return m_plotDefinition;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuSummaryQwtPlot::currentVisibleWindow(QwtInterval* leftAxis, QwtInterval* rightAxis, QwtInterval* timeAxis) const
|
||||
{
|
||||
*leftAxis = axisScaleDiv(yLeft).interval();
|
||||
*rightAxis = axisScaleDiv(yRight).interval();
|
||||
*timeAxis = axisScaleDiv(xBottom).interval();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuSummaryQwtPlot::updateEnsembleLegendLayout()
|
||||
{
|
||||
const int spacing = 5;
|
||||
int startMarginX = this->canvas()->pos().x() + spacing;
|
||||
int startMarginY = this->canvas()->pos().y() + spacing;
|
||||
|
||||
int xpos = startMarginX;
|
||||
int ypos = startMarginY;
|
||||
int maxColumnWidth = 0;
|
||||
|
||||
if (!ownerPlotDefinition() || !ownerPlotDefinition()->ensembleCurveSetCollection()) return;
|
||||
|
||||
for (RimEnsembleCurveSet * curveSet : ownerPlotDefinition()->ensembleCurveSetCollection()->curveSets())
|
||||
else
|
||||
{
|
||||
auto pairIt = m_ensembleLegendWidgets.find(curveSet);
|
||||
if (pairIt != m_ensembleLegendWidgets.end())
|
||||
{
|
||||
if (ypos + pairIt->second->height() + spacing > this->canvas()->height())
|
||||
{
|
||||
xpos += spacing + maxColumnWidth;
|
||||
ypos = startMarginY;
|
||||
maxColumnWidth = 0;
|
||||
}
|
||||
|
||||
RiuCvfOverlayItemWidget* overlayWidget = pairIt->second;
|
||||
overlayWidget->move(xpos, ypos);
|
||||
|
||||
ypos += pairIt->second->height() + spacing;
|
||||
maxColumnWidth = std::max(maxColumnWidth, pairIt->second->width());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuSummaryQwtPlot::addOrUpdateEnsembleCurveSetLegend(RimEnsembleCurveSet * curveSetToShowLegendFor)
|
||||
{
|
||||
RiuCvfOverlayItemWidget* overlayWidget = nullptr;
|
||||
|
||||
auto it = m_ensembleLegendWidgets.find(curveSetToShowLegendFor);
|
||||
if (it == m_ensembleLegendWidgets.end() || it->second == nullptr)
|
||||
{
|
||||
overlayWidget = new RiuCvfOverlayItemWidget(this);
|
||||
|
||||
new RiuWidgetDragger(overlayWidget);
|
||||
|
||||
m_ensembleLegendWidgets[curveSetToShowLegendFor] = overlayWidget;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
overlayWidget = it->second;
|
||||
}
|
||||
}
|
||||
|
||||
if ( overlayWidget )
|
||||
{
|
||||
caf::TitledOverlayFrame* overlyItem = curveSetToShowLegendFor->legendConfig()->titledOverlayFrame();
|
||||
overlyItem->setRenderSize(overlyItem->preferredSize());
|
||||
if (overlayWidget)
|
||||
{
|
||||
caf::TitledOverlayFrame* overlyItem = curveSetToShowLegendFor->legendConfig()->titledOverlayFrame();
|
||||
overlyItem->setRenderSize(overlyItem->preferredSize());
|
||||
|
||||
overlayWidget->updateFromOverlyItem(curveSetToShowLegendFor->legendConfig()->titledOverlayFrame());
|
||||
overlayWidget->show();
|
||||
}
|
||||
overlayWidget->updateFromOverlyItem(curveSetToShowLegendFor->legendConfig()->titledOverlayFrame());
|
||||
overlayWidget->show();
|
||||
}
|
||||
|
||||
this->updateEnsembleLegendLayout();
|
||||
this->updateEnsembleLegendLayout();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuSummaryQwtPlot::removeEnsembleCurveSetLegend(RimEnsembleCurveSet * curveSetToShowLegendFor)
|
||||
void RiuSummaryQwtPlot::removeEnsembleCurveSetLegend(RimEnsembleCurveSet* curveSetToShowLegendFor)
|
||||
{
|
||||
auto it = m_ensembleLegendWidgets.find(curveSetToShowLegendFor);
|
||||
if ( it != m_ensembleLegendWidgets.end() )
|
||||
if (it != m_ensembleLegendWidgets.end())
|
||||
{
|
||||
if ( it->second != nullptr ) it->second->deleteLater();
|
||||
|
||||
if (it->second != nullptr) it->second->deleteLater();
|
||||
|
||||
m_ensembleLegendWidgets.erase(it);
|
||||
}
|
||||
|
||||
@ -253,22 +163,28 @@ void RiuSummaryQwtPlot::removeEnsembleCurveSetLegend(RimEnsembleCurveSet * curve
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QSize RiuSummaryQwtPlot::minimumSizeHint() const
|
||||
void RiuSummaryQwtPlot::keyPressEvent(QKeyEvent* keyEvent)
|
||||
{
|
||||
return QSize(0, 100);
|
||||
RimSummaryPlot* summaryPlot = dynamic_cast<RimSummaryPlot*>(ownerPlotDefinition());
|
||||
|
||||
if (summaryPlot && summaryPlot->summaryCurveCollection())
|
||||
{
|
||||
RimSummaryCurveCollection* curveColl = summaryPlot->summaryCurveCollection();
|
||||
curveColl->handleKeyPressEvent(keyEvent);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuSummaryQwtPlot::contextMenuEvent(QContextMenuEvent* event)
|
||||
{
|
||||
QMenu menu;
|
||||
QMenu menu;
|
||||
caf::CmdFeatureMenuBuilder menuBuilder;
|
||||
|
||||
caf::SelectionManager::instance()->setSelectedItem(ownerPlotDefinition());
|
||||
caf::SelectionManager::instance()->setSelectedItem(ownerViewWindow());
|
||||
|
||||
menuBuilder << "RicShowPlotDataFeature";
|
||||
|
||||
@ -281,71 +197,20 @@ void RiuSummaryQwtPlot::contextMenuEvent(QContextMenuEvent* event)
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuSummaryQwtPlot::keyPressEvent(QKeyEvent* keyEvent)
|
||||
{
|
||||
if (m_plotDefinition && m_plotDefinition->summaryCurveCollection())
|
||||
{
|
||||
RimSummaryCurveCollection* curveColl = m_plotDefinition->summaryCurveCollection();
|
||||
curveColl->handleKeyPressEvent(keyEvent);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QSize RiuSummaryQwtPlot::sizeHint() const
|
||||
{
|
||||
return QSize(0, 0);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuSummaryQwtPlot::setDefaults()
|
||||
{
|
||||
setCommonPlotBehaviour(this);
|
||||
RiuQwtPlotTools::setDefaultAxes(this);
|
||||
|
||||
useDateBasedTimeAxis();
|
||||
|
||||
// The legend will be deleted in the destructor of the plot or when
|
||||
// The legend will be deleted in the destructor of the plot or when
|
||||
// another legend is inserted.
|
||||
QwtLegend* legend = new QwtLegend(this);
|
||||
this->insertLegend(legend, BottomLegend);
|
||||
}
|
||||
|
||||
void RiuSummaryQwtPlot::setCommonPlotBehaviour(QwtPlot* plot)
|
||||
{
|
||||
RiuQwtPlotTools::setCommonPlotBehaviour(plot);
|
||||
|
||||
new RiuQwtCurvePointTracker(plot, true, &ensembleCurveInfoTextProvider);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuSummaryQwtPlot::useDateBasedTimeAxis()
|
||||
{
|
||||
enableDateBasedBottomXAxis(this);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuSummaryQwtPlot::enableDateBasedBottomXAxis(QwtPlot* plot)
|
||||
{
|
||||
QwtDateScaleDraw* scaleDraw = new QwtDateScaleDraw(Qt::UTC);
|
||||
scaleDraw->setDateFormat(QwtDate::Year, QString("dd-MM-yyyy"));
|
||||
|
||||
QwtDateScaleEngine* scaleEngine = new QwtDateScaleEngine(Qt::UTC);
|
||||
plot->setAxisScaleEngine(QwtPlot::xBottom, scaleEngine);
|
||||
plot->setAxisScaleDraw(QwtPlot::xBottom, scaleDraw);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuSummaryQwtPlot::updateLayout()
|
||||
{
|
||||
@ -353,91 +218,40 @@ void RiuSummaryQwtPlot::updateLayout()
|
||||
updateEnsembleLegendLayout();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuSummaryQwtPlot::useTimeBasedTimeAxis()
|
||||
{
|
||||
setAxisScaleEngine(QwtPlot::xBottom, new QwtLinearScaleEngine());
|
||||
setAxisScaleDraw(QwtPlot::xBottom, new QwtScaleDraw());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RiuSummaryQwtPlot::eventFilter(QObject* watched, QEvent* event)
|
||||
{
|
||||
if(watched == canvas())
|
||||
{
|
||||
QMouseEvent* mouseEvent = dynamic_cast<QMouseEvent*>(event);
|
||||
if(mouseEvent)
|
||||
{
|
||||
if(mouseEvent->button() == Qt::LeftButton && mouseEvent->type() == QMouseEvent::MouseButtonRelease)
|
||||
{
|
||||
selectClosestCurve(mouseEvent->pos());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return QwtPlot::eventFilter(watched, event);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuSummaryQwtPlot::selectClosestCurve(const QPoint& pos)
|
||||
{
|
||||
QwtPlotCurve* closestCurve = nullptr;
|
||||
double distMin = DBL_MAX;
|
||||
|
||||
const QwtPlotItemList& itmList = itemList();
|
||||
for(QwtPlotItemIterator it = itmList.begin(); it != itmList.end(); it++)
|
||||
{
|
||||
if((*it)->rtti() == QwtPlotItem::Rtti_PlotCurve)
|
||||
{
|
||||
QwtPlotCurve* candidateCurve = static_cast<QwtPlotCurve*>(*it);
|
||||
double dist = DBL_MAX;
|
||||
candidateCurve->closestPoint(pos, &dist);
|
||||
if(dist < distMin)
|
||||
{
|
||||
closestCurve = candidateCurve;
|
||||
distMin = dist;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (closestCurve && distMin < 20)
|
||||
{
|
||||
caf::PdmObject* selectedPlotObject = m_plotDefinition->findRimPlotObjectFromQwtCurve(closestCurve);
|
||||
|
||||
if (selectedPlotObject)
|
||||
{
|
||||
RimProject* proj = nullptr;
|
||||
selectedPlotObject->firstAncestorOrThisOfType(proj);
|
||||
|
||||
if (proj)
|
||||
{
|
||||
RiuPlotMainWindowTools::showPlotMainWindow();
|
||||
RiuPlotMainWindowTools::selectAsCurrentItem(selectedPlotObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuSummaryQwtPlot::onZoomedSlot()
|
||||
void RiuSummaryQwtPlot::updateEnsembleLegendLayout()
|
||||
{
|
||||
m_plotDefinition->updateZoomWindowFromQwt();
|
||||
}
|
||||
const int spacing = 5;
|
||||
int startMarginX = this->canvas()->pos().x() + spacing;
|
||||
int startMarginY = this->canvas()->pos().y() + spacing;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuSummaryQwtPlot::onAxisClicked(int axis, double value)
|
||||
{
|
||||
if (!m_plotDefinition) return;
|
||||
int xpos = startMarginX;
|
||||
int ypos = startMarginY;
|
||||
int maxColumnWidth = 0;
|
||||
|
||||
m_plotDefinition->selectAxisInPropertyEditor(axis);
|
||||
RimSummaryPlot* summaryPlot = dynamic_cast<RimSummaryPlot*>(ownerPlotDefinition());
|
||||
|
||||
if (!summaryPlot || !summaryPlot->ensembleCurveSetCollection()) return;
|
||||
|
||||
for (RimEnsembleCurveSet* curveSet : summaryPlot->ensembleCurveSetCollection()->curveSets())
|
||||
{
|
||||
auto pairIt = m_ensembleLegendWidgets.find(curveSet);
|
||||
if (pairIt != m_ensembleLegendWidgets.end())
|
||||
{
|
||||
if (ypos + pairIt->second->height() + spacing > this->canvas()->height())
|
||||
{
|
||||
xpos += spacing + maxColumnWidth;
|
||||
ypos = startMarginY;
|
||||
maxColumnWidth = 0;
|
||||
}
|
||||
|
||||
RiuCvfOverlayItemWidget* overlayWidget = pairIt->second;
|
||||
overlayWidget->move(xpos, ypos);
|
||||
|
||||
ypos += pairIt->second->height() + spacing;
|
||||
maxColumnWidth = std::max(maxColumnWidth, pairIt->second->width());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,17 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2016- Statoil ASA
|
||||
//
|
||||
// Copyright (C) 2019- Equinor 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>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
@ -19,6 +19,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "RiuInterfaceToViewWindow.h"
|
||||
#include "RiuQwtPlot.h"
|
||||
|
||||
#include "cafPdmPointer.h"
|
||||
|
||||
@ -26,72 +27,39 @@
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
class QwtPlotCurve;
|
||||
class QwtPlotGrid;
|
||||
class QwtPlotZoomer;
|
||||
class QwtInterval;
|
||||
class QwtPicker;
|
||||
class QwtPlotMarker;
|
||||
class QwtScaleWidget;
|
||||
|
||||
class RiuCvfOverlayItemWidget;
|
||||
class QwtPlotZoomer;
|
||||
|
||||
class RimGridCrossPlot;
|
||||
class RimSummaryPlot;
|
||||
class RimEnsembleCurveSet;
|
||||
class RiuCvfOverlayItemWidget;
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==================================================================================================
|
||||
class RiuSummaryQwtPlot : public QwtPlot, public RiuInterfaceToViewWindow
|
||||
class RiuSummaryQwtPlot : public RiuQwtPlot
|
||||
{
|
||||
Q_OBJECT;
|
||||
|
||||
public:
|
||||
RiuSummaryQwtPlot(RimSummaryPlot* plotDefinition, QWidget* parent = nullptr);
|
||||
~RiuSummaryQwtPlot() override;
|
||||
RiuSummaryQwtPlot(RimViewWindow* ownerViewWindow, QWidget* parent = nullptr);
|
||||
|
||||
RimSummaryPlot* ownerPlotDefinition();
|
||||
RimViewWindow* ownerViewWindow() const override;
|
||||
void useDateBasedTimeAxis();
|
||||
void useTimeBasedTimeAxis();
|
||||
|
||||
void useDateBasedTimeAxis();
|
||||
void useTimeBasedTimeAxis();
|
||||
|
||||
void currentVisibleWindow(QwtInterval* leftAxis,
|
||||
QwtInterval* rightAxis,
|
||||
QwtInterval* timeAxis) const;
|
||||
|
||||
void addOrUpdateEnsembleCurveSetLegend(RimEnsembleCurveSet * curveSetToShowLegendFor);
|
||||
void removeEnsembleCurveSetLegend(RimEnsembleCurveSet * curveSetToShowLegendFor);
|
||||
|
||||
static void setCommonPlotBehaviour(QwtPlot* plot);
|
||||
static void enableDateBasedBottomXAxis(QwtPlot* plot);
|
||||
void addOrUpdateEnsembleCurveSetLegend(RimEnsembleCurveSet* curveSetToShowLegendFor);
|
||||
void removeEnsembleCurveSetLegend(RimEnsembleCurveSet* curveSetToShowLegendFor);
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject* watched, QEvent* event) override;
|
||||
void keyPressEvent(QKeyEvent *) override;
|
||||
|
||||
QSize sizeHint() const override;
|
||||
QSize minimumSizeHint() const override;
|
||||
void contextMenuEvent(QContextMenuEvent *) override;
|
||||
void updateLayout() override;
|
||||
|
||||
void keyPressEvent(QKeyEvent*) override;
|
||||
void contextMenuEvent(QContextMenuEvent*) override;
|
||||
void setDefaults();
|
||||
void updateLayout() override;
|
||||
private:
|
||||
void setDefaults();
|
||||
void selectClosestCurve(const QPoint& pos);
|
||||
void updateEnsembleLegendLayout();
|
||||
|
||||
private slots:
|
||||
void onZoomedSlot( );
|
||||
void onAxisClicked(int axis, double value);
|
||||
|
||||
private:
|
||||
caf::PdmPointer<RimSummaryPlot> m_plotDefinition;
|
||||
|
||||
QPointer<QwtPlotZoomer> m_zoomerLeft;
|
||||
QPointer<QwtPlotZoomer> m_zoomerRight;
|
||||
|
||||
std::map< caf::PdmPointer<RimEnsembleCurveSet>, QPointer<RiuCvfOverlayItemWidget> > m_ensembleLegendWidgets;
|
||||
void updateEnsembleLegendLayout();
|
||||
std::map<caf::PdmPointer<RimEnsembleCurveSet>, QPointer<RiuCvfOverlayItemWidget>> m_ensembleLegendWidgets;
|
||||
|
||||
};
|
||||
|
||||
|
@ -27,6 +27,7 @@
|
||||
|
||||
#include "RiuPlotMainWindowTools.h"
|
||||
#include "RiuQwtCurvePointTracker.h"
|
||||
#include "RiuQwtPlotTools.h"
|
||||
|
||||
#include "RiuQwtLinearScaleEngine.h"
|
||||
|
||||
@ -46,7 +47,6 @@
|
||||
#include <QWheelEvent>
|
||||
|
||||
#include <cfloat>
|
||||
#include "RiuSummaryQwtPlot.h"
|
||||
|
||||
#define RIU_SCROLLWHEEL_ZOOMFACTOR 1.1
|
||||
#define RIU_SCROLLWHEEL_PANFACTOR 0.1
|
||||
@ -77,7 +77,7 @@ RiuWellLogTrack::~RiuWellLogTrack()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellLogTrack::setDefaults()
|
||||
{
|
||||
RiuSummaryQwtPlot::setCommonPlotBehaviour(this);
|
||||
RiuQwtPlotTools::setCommonPlotBehaviour(this);
|
||||
|
||||
enableAxis(QwtPlot::xTop, true);
|
||||
enableAxis(QwtPlot::yLeft, true);
|
||||
|
25
doc/qwtplot.plantuml
Normal file
25
doc/qwtplot.plantuml
Normal file
@ -0,0 +1,25 @@
|
||||
@startuml
|
||||
package Rim {
|
||||
|
||||
PdmObject <|-- RimViewWindow
|
||||
package plots {
|
||||
RimViewWindow <|-- RimGridCrossPlot
|
||||
RimViewWindow <|-- RimSummaryPlot
|
||||
RimRiuQwtPlotOwnerInterface <|-- RimGridCrossPlot
|
||||
RimRiuQwtPlotOwnerInterface <|-- RimSummaryPlot
|
||||
}
|
||||
|
||||
package Qwt {
|
||||
QWidget <|-- QwtPlot
|
||||
}
|
||||
|
||||
package RiuQwt
|
||||
{
|
||||
QwtPlot <|--- RiuQwtPlot
|
||||
RiuQwtPlot <|--- RiuSummaryQwtPlot
|
||||
RiuQwtPlot -r-> RimRiuQwtPlotOwnerInterface
|
||||
}
|
||||
|
||||
RimSummaryPlot -r-> RiuSummaryQwtPlot
|
||||
RimGridCrossPlot -r-> RiuQwtPlot
|
||||
@enduml
|
Loading…
Reference in New Issue
Block a user