Merge pull request #8387 from OPM/qtcharts-summary-plots

Closes #8228 

Major refactoring of summary plotting. Now possible to create plots both with Qwt and QtChart as plotting tool.
This commit is contained in:
Kristian Bendiksen 2022-01-17 13:14:21 +01:00 committed by GitHub
parent d9bb82de91
commit 258fbddc10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
145 changed files with 7245 additions and 2932 deletions

View File

@ -21,6 +21,7 @@ set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RiaFeatureCommandContext.h
${CMAKE_CURRENT_LIST_DIR}/RiaStringListSerializer.h
${CMAKE_CURRENT_LIST_DIR}/RiaNncDefines.h
${CMAKE_CURRENT_LIST_DIR}/RiaPlotDefines.h
${CMAKE_CURRENT_LIST_DIR}/RiaStimPlanModelDefines.h
${CMAKE_CURRENT_LIST_DIR}/RiaResultNames.h
${CMAKE_CURRENT_LIST_DIR}/RiaNumberFormat.h
@ -49,6 +50,7 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RiaFeatureCommandContext.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaStringListSerializer.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaNncDefines.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaPlotDefines.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaStimPlanModelDefines.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaResultNames.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaNumberFormat.cpp

View File

@ -70,15 +70,6 @@ void caf::AppEnum<RiaDefines::DepthTypeEnum>::setUp()
setDefault( RiaDefines::DepthTypeEnum::MEASURED_DEPTH );
}
template <>
void caf::AppEnum<RiaDefines::PlotAxis>::setUp()
{
addItem( RiaDefines::PlotAxis::PLOT_AXIS_LEFT, "PLOT_AXIS_LEFT", "Left" );
addItem( RiaDefines::PlotAxis::PLOT_AXIS_RIGHT, "PLOT_AXIS_RIGHT", "Right" );
setDefault( RiaDefines::PlotAxis::PLOT_AXIS_LEFT );
}
template <>
void caf::AppEnum<RiaDefines::PhaseType>::setUp()
{
@ -240,30 +231,6 @@ RiaDefines::EclipseUnitSystem RiaDefines::fromDepthUnit( DepthUnitType depthUnit
return RiaDefines::EclipseUnitSystem::UNITS_UNKNOWN;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RiaDefines::minimumDefaultValuePlot()
{
return -10.0;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RiaDefines::minimumDefaultLogValuePlot()
{
return 1.0;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RiaDefines::maximumDefaultValuePlot()
{
return 100.0;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -107,18 +107,6 @@ enum class DepthTypeEnum
TRUE_VERTICAL_DEPTH_RKB
};
// Defines relate to plotting
enum class PlotAxis
{
PLOT_AXIS_LEFT,
PLOT_AXIS_RIGHT,
PLOT_AXIS_BOTTOM
};
double minimumDefaultValuePlot();
double minimumDefaultLogValuePlot();
double maximumDefaultValuePlot();
enum class PhaseType
{
OIL_PHASE,

View File

@ -0,0 +1,75 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2022- 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 "RiaPlotDefines.h"
#include "cafAppEnum.h"
namespace caf
{
template <>
void caf::AppEnum<RiaDefines::PlotAxis>::setUp()
{
addItem( RiaDefines::PlotAxis::PLOT_AXIS_LEFT, "PLOT_AXIS_LEFT", "Left" );
addItem( RiaDefines::PlotAxis::PLOT_AXIS_RIGHT, "PLOT_AXIS_RIGHT", "Right" );
addItem( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM, "PLOT_AXIS_BOTTOM", "Bottom" );
addItem( RiaDefines::PlotAxis::PLOT_AXIS_TOP, "PLOT_AXIS_TOP", "Top" );
setDefault( RiaDefines::PlotAxis::PLOT_AXIS_LEFT );
}
}; // namespace caf
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RiaDefines::minimumDefaultValuePlot()
{
return -10.0;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RiaDefines::minimumDefaultLogValuePlot()
{
return 1.0;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RiaDefines::maximumDefaultValuePlot()
{
return 100.0;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaDefines::isHorizontal( RiaDefines::PlotAxis axis )
{
return !isVertical( axis );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaDefines::isVertical( RiaDefines::PlotAxis axis )
{
return ( axis == RiaDefines::PlotAxis::PLOT_AXIS_LEFT || axis == RiaDefines::PlotAxis::PLOT_AXIS_RIGHT );
}

View File

@ -0,0 +1,39 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2022- 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
// Defines relate to plotting
namespace RiaDefines
{
enum class PlotAxis
{
PLOT_AXIS_LEFT,
PLOT_AXIS_RIGHT,
PLOT_AXIS_BOTTOM,
PLOT_AXIS_TOP
};
double minimumDefaultValuePlot();
double minimumDefaultLogValuePlot();
double maximumDefaultValuePlot();
bool isHorizontal( PlotAxis axis );
bool isVertical( PlotAxis axis );
}; // namespace RiaDefines

View File

@ -19,7 +19,7 @@
#include "RiuMultiPlotBook.h"
#include "RiuMultiPlotPage.h"
#include "RiuQwtPlotWidget.h"
#include "RiuPlotWidget.h"
#include <QCoreApplication>
#include <QDebug>
@ -61,7 +61,7 @@ void RiaPlotWindowRedrawScheduler::scheduleMultiPlotPageUpdate( RiuMultiPlotPage
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaPlotWindowRedrawScheduler::schedulePlotWidgetReplot( RiuQwtPlotWidget* plotWidget )
void RiaPlotWindowRedrawScheduler::schedulePlotWidgetReplot( RiuPlotWidget* plotWidget )
{
m_plotWidgetsToReplot.push_back( plotWidget );
@ -92,13 +92,13 @@ void RiaPlotWindowRedrawScheduler::performScheduledUpdatesAndReplots()
{
std::vector<QPointer<RiuMultiPlotBook>> plotWindowsToUpdate;
std::vector<QPointer<RiuMultiPlotPage>> plotPagesToUpdate;
std::vector<QPointer<RiuQwtPlotWidget>> plotWidgetsToReplot;
std::vector<QPointer<RiuPlotWidget>> plotWidgetsToReplot;
plotWindowsToUpdate.swap( m_plotWindowsToUpdate );
plotPagesToUpdate.swap( m_plotPagesToUpdate );
plotWidgetsToReplot.swap( m_plotWidgetsToReplot );
std::set<QPointer<RiuQwtPlotWidget>> updatedPlots;
std::set<QPointer<RiuPlotWidget>> updatedPlots;
std::set<QPointer<RiuMultiPlotBook>> updatedPlotWindows;
std::set<QPointer<RiuMultiPlotPage>> updatedPlotPages;
@ -127,7 +127,7 @@ void RiaPlotWindowRedrawScheduler::performScheduledUpdatesAndReplots()
}
// Perform update and replot. Make sure we handle legend update
for ( QPointer<RiuQwtPlotWidget> plot : plotWidgetsToReplot )
for ( QPointer<RiuPlotWidget> plot : plotWidgetsToReplot )
{
if ( !plot.isNull() && !updatedPlots.count( plot ) )
{

View File

@ -28,7 +28,7 @@
class RiuMultiPlotPage;
class RiuMultiPlotBook;
class RiuQwtPlotWidget;
class RiuPlotWidget;
class RiaPlotWindowRedrawScheduler : public QObject
{
@ -38,7 +38,7 @@ public:
static RiaPlotWindowRedrawScheduler* instance();
void scheduleMultiPlotWindowUpdate( RiuMultiPlotBook* plotWindow );
void scheduleMultiPlotPageUpdate( RiuMultiPlotPage* plotWindow );
void schedulePlotWidgetReplot( RiuQwtPlotWidget* plotWidget );
void schedulePlotWidgetReplot( RiuPlotWidget* plotWidget );
void clearAllScheduledUpdates();
void performScheduledUpdatesAndReplots();
@ -46,13 +46,13 @@ private slots:
void slotUpdateAndReplotScheduledItemsWhenReady();
private:
RiaPlotWindowRedrawScheduler() = default;
RiaPlotWindowRedrawScheduler() = default;
~RiaPlotWindowRedrawScheduler() override = default;
void startTimer( int msecs );
private:
std::vector<QPointer<RiuQwtPlotWidget>> m_plotWidgetsToReplot;
std::vector<QPointer<RiuPlotWidget>> m_plotWidgetsToReplot;
std::vector<QPointer<RiuMultiPlotBook>> m_plotWindowsToUpdate;
std::vector<QPointer<RiuMultiPlotPage>> m_plotPagesToUpdate;
QScopedPointer<QTimer> m_plotWindowUpdateTimer;

View File

@ -161,7 +161,7 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RicCreateSurfaceIntersectionCurveFeature.cpp
)
if(Qt5Charts_FOUND)
if(RESINSIGHT_USE_QT_CHARTS)
list(
APPEND SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RicCreateEnsembleFractureStatisticsPlotFeature.h

View File

@ -20,7 +20,7 @@
#include "cafCmdFeature.h"
#include "RiaDefines.h"
#include "RiaPlotDefines.h"
#include "RimFlowDiagSolution.h"
class RimGridSummaryCase;

View File

@ -199,7 +199,7 @@ RicPasteAsciiDataToSummaryPlotFeatureUi::RicPasteAsciiDataToSummaryPlotFeatureUi
"Line Style" );
CAF_PDM_InitField( &m_curveSymbol,
"Symbol",
caf::AppEnum<RiuQwtSymbol::PointSymbolEnum>( RiuQwtSymbol::SYMBOL_ELLIPSE ),
caf::AppEnum<RiuPlotCurveSymbol::PointSymbolEnum>( RiuQwtSymbol::SYMBOL_ELLIPSE ),
"Symbol" );
CAF_PDM_InitField( &m_curveSymbolSkipDistance, "SymbolSkipDinstance", 0.0f, "Symbol Skip Distance" );

View File

@ -60,7 +60,7 @@ public:
bool assumeNumericDataColumns;
RiuQwtPlotCurveDefines::LineStyleEnum curveLineStyle;
RiuQwtSymbol::PointSymbolEnum curveSymbol;
RiuPlotCurveSymbol::PointSymbolEnum curveSymbol;
float curveSymbolSkipDistance;
};
@ -160,7 +160,7 @@ private:
caf::PdmField<QString> m_timeSeriesColumnName;
caf::PdmField<caf::AppEnum<RiuQwtPlotCurveDefines::LineStyleEnum>> m_curveLineStyle;
caf::PdmField<caf::AppEnum<RiuQwtSymbol::PointSymbolEnum>> m_curveSymbol;
caf::PdmField<caf::AppEnum<RiuPlotCurveSymbol::PointSymbolEnum>> m_curveSymbol;
caf::PdmField<float> m_curveSymbolSkipDistance;
bool m_createNewPlot;

View File

@ -67,7 +67,7 @@ void RicSummaryCurveSwitchAxisFeature::onActionTriggered( bool isChecked )
summaryCurve->setLeftOrRightAxisY( RiaDefines::PlotAxis::PLOT_AXIS_LEFT );
}
summaryCurve->updateQwtPlotAxis();
summaryCurve->updatePlotAxis();
summaryCurve->updateConnectedEditors();
RimSummaryPlot* plot = nullptr;

View File

@ -688,7 +688,7 @@ void RicSummaryPlotEditorUi::updateTargetPlot()
copyEnsembleCurveAndAddToCurveSet( editedCurve, editedCurveSet );
}
newCurveSet->setParentQwtPlotNoReplot( m_targetPlot->viewer() );
newCurveSet->setParentPlotNoReplot( m_targetPlot->plotWidget() );
}
m_targetPlot->enableAutoPlotTitle( m_useAutoPlotTitleProxy() );
@ -900,7 +900,7 @@ void RicSummaryPlotEditorUi::updateCurveNames()
curve->updateCurveNameNoLegendUpdate();
}
if ( m_previewPlot && m_previewPlot->viewer() ) m_previewPlot->viewer()->updateLegend();
if ( m_previewPlot && m_previewPlot->plotWidget() ) m_previewPlot->updateLegend();
}
//--------------------------------------------------------------------------------------------------

View File

@ -413,7 +413,7 @@ void RicNewWellBoreStabilityPlotFeature::createAnglesTrack( RimWellBoreStability
curve->loadDataAndUpdate( false );
double actualMinValue = minValue, actualMaxValue = maxValue;
curve->xValueRangeInQwt( &actualMinValue, &actualMaxValue );
curve->xValueRange( &actualMinValue, &actualMaxValue );
while ( maxValue < actualMaxValue )
{
maxValue += angleIncrement;

View File

@ -18,12 +18,15 @@
#include "RimAnalysisPlot.h"
#include "RiaDefines.h"
#include "RiaPlotDefines.h"
#include "RiaPreferences.h"
#include "RiaSummaryCurveDefinition.h"
#include "RiaTextStringTools.h"
#include "RiuGroupedBarChartBuilder.h"
#include "RiuPlotMainWindowTools.h"
#include "RiuQwtPlotTools.h"
#include "RiuSummaryQwtPlot.h"
#include "RiuSummaryVectorSelectionDialog.h"
@ -159,7 +162,7 @@ RimAnalysisPlot::RimAnalysisPlot()
CAF_PDM_InitFieldNoDefault( &m_valueAxisProperties, "ValueAxisProperties", "ValueAxisProperties" );
m_valueAxisProperties.uiCapability()->setUiTreeHidden( true );
m_valueAxisProperties = new RimPlotAxisProperties;
m_valueAxisProperties->setNameAndAxis( "Value-Axis", QwtPlot::yLeft );
m_valueAxisProperties->setNameAndAxis( "Value-Axis", RiuQwtPlotTools::fromQwtPlotAxis( QwtPlot::yLeft ) );
m_valueAxisProperties->enableRangeSettings( false );
CAF_PDM_InitFieldNoDefault( &m_plotDataFilterCollection, "PlotDataFilterCollection", "PlotDataFilterCollection" );
@ -772,26 +775,26 @@ void RimAnalysisPlot::onLoadDataAndUpdate()
if ( m_plotWidget )
{
m_plotWidget->detachItems( QwtPlotItem::Rtti_PlotBarChart );
m_plotWidget->detachItems( QwtPlotItem::Rtti_PlotScale );
m_plotWidget->qwtPlot()->detachItems( QwtPlotItem::Rtti_PlotBarChart );
m_plotWidget->qwtPlot()->detachItems( QwtPlotItem::Rtti_PlotScale );
RiuGroupedBarChartBuilder chartBuilder;
chartBuilder.setLabelFontSize( barTextFontSize() );
// buildTestPlot( chartBuilder );
addDataToChartBuilder( chartBuilder );
chartBuilder.addBarChartToPlot( m_plotWidget,
chartBuilder.addBarChartToPlot( m_plotWidget->qwtPlot(),
m_barOrientation == BARS_HORIZONTAL ? Qt::Horizontal : Qt::Vertical,
m_useTopBarsFilter() ? m_maxBarCount : -1 );
if ( m_showPlotLegends && m_plotWidget->legend() == nullptr )
if ( m_showPlotLegends && m_plotWidget->qwtPlot()->legend() == nullptr )
{
QwtLegend* legend = new QwtLegend( m_plotWidget );
m_plotWidget->insertLegend( legend, QwtPlot::RightLegend );
m_plotWidget->qwtPlot()->insertLegend( legend, QwtPlot::RightLegend );
}
else if ( !m_showPlotLegends )
{
m_plotWidget->insertLegend( nullptr );
m_plotWidget->qwtPlot()->insertLegend( nullptr );
}
m_plotWidget->setLegendFontSize( legendFontSize() );
@ -829,7 +832,7 @@ QString RimAnalysisPlot::description() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuQwtPlotWidget* RimAnalysisPlot::doCreatePlotViewWidget( QWidget* mainWindowParent /*= nullptr */ )
RiuPlotWidget* RimAnalysisPlot::doCreatePlotViewWidget( QWidget* mainWindowParent /*= nullptr */ )
{
if ( !m_plotWidget )
{
@ -847,12 +850,20 @@ RiuQwtPlotWidget* RimAnalysisPlot::viewer()
return m_plotWidget;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuPlotWidget* RimAnalysisPlot::plotWidget()
{
return m_plotWidget;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimAnalysisPlot::detachAllCurves()
{
if ( m_plotWidget ) m_plotWidget->detachItems();
if ( m_plotWidget ) m_plotWidget->qwtPlot()->detachItems();
}
//--------------------------------------------------------------------------------------------------
@ -862,29 +873,29 @@ void RimAnalysisPlot::updateAxes()
{
if ( !m_plotWidget ) return;
QwtPlot::Axis qwtAxis = QwtPlot::yLeft;
RiaDefines::PlotAxis axis = RiaDefines::PlotAxis::PLOT_AXIS_LEFT;
if ( m_barOrientation == BARS_HORIZONTAL )
{
qwtAxis = QwtPlot::xBottom;
m_plotWidget->setAxisTitleEnabled( QwtPlot::yLeft, false );
axis = RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM;
m_plotWidget->setAxisTitleEnabled( RiaDefines::PlotAxis::PLOT_AXIS_LEFT, false );
}
else
{
m_plotWidget->setAxisTitleEnabled( QwtPlot::xBottom, false );
m_plotWidget->setAxisTitleEnabled( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM, false );
}
RimPlotAxisProperties* valAxisProperties = m_valueAxisProperties();
if ( valAxisProperties->isActive() )
{
m_plotWidget->enableAxis( qwtAxis, true );
m_valueAxisProperties->setNameAndAxis( "Value-Axis", qwtAxis );
m_plotWidget->enableAxis( axis, true );
m_valueAxisProperties->setNameAndAxis( "Value-Axis", axis );
RimSummaryPlotAxisFormatter calc( valAxisProperties, {}, curveDefinitions(), {}, {} );
calc.applyAxisPropertiesToPlot( m_plotWidget );
}
else
{
m_plotWidget->enableAxis( qwtAxis, false );
m_plotWidget->enableAxis( axis, false );
}
}

View File

@ -127,22 +127,20 @@ private:
// RimPlot Overrides
RiuQwtPlotWidget* doCreatePlotViewWidget( QWidget* mainWindowParent = nullptr ) override;
RiuQwtPlotWidget* viewer() override;
RiuPlotWidget* doCreatePlotViewWidget( QWidget* mainWindowParent = nullptr ) override;
RiuQwtPlotWidget* viewer();
RiuPlotWidget* plotWidget() override;
void detachAllCurves() override;
void reattachAllCurves() override {}
void updateAxes() override;
void onAxisSelected( int axis, bool toggle ) override;
void updateZoomInQwt() override {}
void updateZoomFromQwt() override {}
void setAutoScaleXEnabled( bool enabled ) override {}
void setAutoScaleYEnabled( bool enabled ) override {}
void updateLegend() override{};
QString asciiDataForPlotExport() const override { return ""; }
caf::PdmObject* findPdmObjectFromQwtCurve( const QwtPlotCurve* curve ) const override { return nullptr; }
QString asciiDataForPlotExport() const override { return ""; }
// Private methods

View File

@ -93,6 +93,7 @@ set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RimPlotAxisPropertiesInterface.h
${CMAKE_CURRENT_LIST_DIR}/RimPlotAxisProperties.h
${CMAKE_CURRENT_LIST_DIR}/RimPlotAxisAnnotation.h
${CMAKE_CURRENT_LIST_DIR}/RimPlotAxisLogRangeCalculator.h
${CMAKE_CURRENT_LIST_DIR}/RimObservedDataCollection.h
${CMAKE_CURRENT_LIST_DIR}/RimObservedFmuRftData.h
${CMAKE_CURRENT_LIST_DIR}/RimMultiPlotCollection.h
@ -213,6 +214,7 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RimPlotAxisPropertiesInterface.cpp
${CMAKE_CURRENT_LIST_DIR}/RimPlotAxisProperties.cpp
${CMAKE_CURRENT_LIST_DIR}/RimPlotAxisAnnotation.cpp
${CMAKE_CURRENT_LIST_DIR}/RimPlotAxisLogRangeCalculator.cpp
${CMAKE_CURRENT_LIST_DIR}/RimObservedDataCollection.cpp
${CMAKE_CURRENT_LIST_DIR}/RimObservedFmuRftData.cpp
${CMAKE_CURRENT_LIST_DIR}/RimMultiPlotCollection.cpp
@ -235,7 +237,7 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RimSurfaceIntersectionCollection.cpp
)
if(Qt5Charts_FOUND)
if(RESINSIGHT_USE_QT_CHARTS)
list(
APPEND
SOURCE_GROUP_HEADER_FILES

View File

@ -42,6 +42,8 @@
#include "cafPdmUiPushButtonEditor.h"
#include "cafPdmUiToolButtonEditor.h"
#include "qwt_plot.h"
CAF_PDM_ABSTRACT_SOURCE_INIT( RimAbstractCorrelationPlot, "AbstractCorrelationPlot" );
//--------------------------------------------------------------------------------------------------
@ -557,7 +559,7 @@ QString RimAbstractCorrelationPlot::description() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuQwtPlotWidget* RimAbstractCorrelationPlot::doCreatePlotViewWidget( QWidget* mainWindowParent /*= nullptr */ )
RiuPlotWidget* RimAbstractCorrelationPlot::doCreatePlotViewWidget( QWidget* mainWindowParent /*= nullptr */ )
{
if ( !m_plotWidget )
{
@ -576,12 +578,20 @@ RiuQwtPlotWidget* RimAbstractCorrelationPlot::viewer()
return m_plotWidget;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuPlotWidget* RimAbstractCorrelationPlot::plotWidget()
{
return m_plotWidget;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimAbstractCorrelationPlot::detachAllCurves()
{
if ( m_plotWidget ) m_plotWidget->detachItems();
if ( m_plotWidget ) m_plotWidget->qwtPlot()->detachItems();
}
//--------------------------------------------------------------------------------------------------
@ -661,7 +671,7 @@ void RimAbstractCorrelationPlot::updateLegend()
{
if ( m_plotWidget )
{
m_plotWidget->insertLegend( nullptr );
m_plotWidget->qwtPlot()->insertLegend( nullptr );
}
}

View File

@ -61,7 +61,8 @@ public:
RimEnsembleCurveSet* caseFilterDataSource() const;
void setCaseFilterDataSource( RimEnsembleCurveSet* ensemble );
RiuQwtPlotWidget* viewer() override;
RiuQwtPlotWidget* viewer();
RiuPlotWidget* plotWidget() override;
void detachAllCurves() override;
QDateTime timeStep() const;
QString timeStepString() const;
@ -103,17 +104,14 @@ protected:
void doUpdateLayout() override {}
// RimPlot Overrides
RiuQwtPlotWidget* doCreatePlotViewWidget( QWidget* mainWindowParent = nullptr ) override;
RiuPlotWidget* doCreatePlotViewWidget( QWidget* mainWindowParent = nullptr ) override;
void reattachAllCurves() override {}
void updateZoomInQwt() override {}
void updateZoomFromQwt() override {}
void setAutoScaleXEnabled( bool enabled ) override {}
void setAutoScaleYEnabled( bool enabled ) override {}
void updateLegend() override;
QString asciiDataForPlotExport() const override { return ""; }
caf::PdmObject* findPdmObjectFromQwtCurve( const QwtPlotCurve* curve ) const override { return nullptr; }
QString asciiDataForPlotExport() const override { return ""; }
void cleanupBeforeClose();
virtual void updatePlotTitle() = 0;

View File

@ -25,6 +25,7 @@
#include "RiaSummaryCurveDefinition.h"
#include "RiuPlotMainWindowTools.h"
#include "RiuQwtLinearScaleEngine.h"
#include "RiuQwtPlotItem.h"
#include "RiuQwtPlotTools.h"
#include "RiuQwtPlotWidget.h"
@ -369,14 +370,14 @@ void RimCorrelationMatrixPlot::onLoadDataAndUpdate()
if ( m_plotWidget )
{
m_plotWidget->detachItems( QwtPlotItem::Rtti_PlotBarChart );
m_plotWidget->detachItems( QwtPlotItem::Rtti_PlotScale );
m_plotWidget->detachItems( QwtPlotItem::Rtti_PlotItem );
m_plotWidget->qwtPlot()->detachItems( QwtPlotItem::Rtti_PlotBarChart );
m_plotWidget->qwtPlot()->detachItems( QwtPlotItem::Rtti_PlotScale );
m_plotWidget->qwtPlot()->detachItems( QwtPlotItem::Rtti_PlotItem );
updateLegend();
createMatrix();
m_plotWidget->insertLegend( nullptr );
m_plotWidget->qwtPlot()->insertLegend( nullptr );
this->updateAxes();
this->updatePlotTitle();
@ -399,14 +400,18 @@ void RimCorrelationMatrixPlot::updateAxes()
{
if ( !m_plotWidget ) return;
m_plotWidget->setAxisScaleDraw( QwtPlot::yLeft, new TextScaleDraw( m_resultLabels ) );
m_plotWidget->setAxisScaleEngine( QwtPlot::yLeft, new RiuQwtLinearScaleEngine );
m_plotWidget->setAxisTitleText( QwtPlot::yLeft, "Result Vector" );
m_plotWidget->setAxisTitleEnabled( QwtPlot::yLeft, true );
m_plotWidget->setAxisFontsAndAlignment( QwtPlot::yLeft, axisTitleFontSize(), axisValueFontSize(), false, Qt::AlignCenter );
m_plotWidget->setAxisLabelsAndTicksEnabled( QwtPlot::yLeft, true, false );
m_plotWidget->setAxisRange( QwtPlot::yLeft, 0.0, (double)m_resultLabels.size() + 1 );
m_plotWidget->setMajorAndMinorTickIntervalsAndRange( QwtPlot::yLeft,
m_plotWidget->qwtPlot()->setAxisScaleDraw( QwtPlot::yLeft, new TextScaleDraw( m_resultLabels ) );
m_plotWidget->qwtPlot()->setAxisScaleEngine( QwtPlot::yLeft, new RiuQwtLinearScaleEngine );
m_plotWidget->setAxisTitleText( RiaDefines::PlotAxis::PLOT_AXIS_LEFT, "Result Vector" );
m_plotWidget->setAxisTitleEnabled( RiaDefines::PlotAxis::PLOT_AXIS_LEFT, true );
m_plotWidget->setAxisFontsAndAlignment( RiaDefines::PlotAxis::PLOT_AXIS_LEFT,
axisTitleFontSize(),
axisValueFontSize(),
false,
Qt::AlignCenter );
m_plotWidget->setAxisLabelsAndTicksEnabled( RiaDefines::PlotAxis::PLOT_AXIS_LEFT, true, false );
m_plotWidget->setAxisRange( RiaDefines::PlotAxis::PLOT_AXIS_LEFT, 0.0, (double)m_resultLabels.size() + 1 );
m_plotWidget->setMajorAndMinorTickIntervalsAndRange( RiaDefines::PlotAxis::PLOT_AXIS_LEFT,
1.0,
0.0,
0.5,
@ -416,19 +421,18 @@ void RimCorrelationMatrixPlot::updateAxes()
auto scaleDraw = new TextScaleDraw( m_paramLabels );
scaleDraw->setLabelRotation( 30.0 );
m_plotWidget->setAxisScaleDraw( QwtPlot::xBottom, scaleDraw );
m_plotWidget->setAxisScaleEngine( QwtPlot::xBottom, new RiuQwtLinearScaleEngine );
m_plotWidget->setAxisTitleText( QwtPlot::xBottom, "Ensemble Parameter" );
m_plotWidget->setAxisTitleEnabled( QwtPlot::xBottom, true );
m_plotWidget->setAxisFontsAndAlignment( QwtPlot::xBottom,
m_plotWidget->qwtPlot()->setAxisScaleDraw( QwtPlot::xBottom, scaleDraw );
m_plotWidget->qwtPlot()->setAxisScaleEngine( QwtPlot::xBottom, new RiuQwtLinearScaleEngine );
m_plotWidget->setAxisTitleText( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM, "Ensemble Parameter" );
m_plotWidget->setAxisTitleEnabled( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM, true );
m_plotWidget->setAxisFontsAndAlignment( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM,
axisTitleFontSize(),
axisValueFontSize(),
false,
Qt::AlignCenter | Qt::AlignTop );
m_plotWidget->setAxisLabelsAndTicksEnabled( QwtPlot::xBottom, true, false );
m_plotWidget->setAxisRange( QwtPlot::xBottom, 0.0, (double)m_paramLabels.size() + 1 );
m_plotWidget->setMajorAndMinorTickIntervalsAndRange( QwtPlot::xBottom,
m_plotWidget->setAxisLabelsAndTicksEnabled( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM, true, false );
m_plotWidget->setAxisRange( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM, 0.0, (double)m_paramLabels.size() + 1 );
m_plotWidget->setMajorAndMinorTickIntervalsAndRange( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM,
1.0,
0.0,
0.5,
@ -436,7 +440,7 @@ void RimCorrelationMatrixPlot::updateAxes()
0.0,
(double)m_paramLabels.size() );
m_plotWidget->setAxisLabelAlignment( QwtPlot::xBottom, Qt::AlignRight );
m_plotWidget->qwtPlot()->setAxisLabelAlignment( QwtPlot::xBottom, Qt::AlignRight );
}
template <typename KeyType, typename ValueType>
@ -636,8 +640,8 @@ void RimCorrelationMatrixPlot::createMatrix()
marker->setLabel( textLabel );
marker->setXValue( colIdx + 0.5 );
marker->setYValue( rowIdx + 0.5 );
rectangle->attach( m_plotWidget );
marker->attach( m_plotWidget );
rectangle->attach( m_plotWidget->qwtPlot() );
marker->attach( m_plotWidget->qwtPlot() );
m_paramLabels[colIdx] = correlationMatrixRows[rowIdx].m_values[colIdx];
}
@ -682,9 +686,12 @@ void RimCorrelationMatrixPlot::updateLegend()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCorrelationMatrixPlot::onPlotItemSelected( QwtPlotItem* plotItem, bool toggle, int sampleIndex )
void RimCorrelationMatrixPlot::onPlotItemSelected( std::shared_ptr<RiuPlotItem> plotItem, bool toggle, int sampleIndex )
{
CorrelationMatrixShapeItem* matrixItem = dynamic_cast<CorrelationMatrixShapeItem*>( plotItem );
RiuQwtPlotItem* qwtPlotItem = dynamic_cast<RiuQwtPlotItem*>( plotItem.get() );
if ( !qwtPlotItem ) return;
CorrelationMatrixShapeItem* matrixItem = dynamic_cast<CorrelationMatrixShapeItem*>( qwtPlotItem->qwtPlotItem() );
if ( matrixItem )
{
matrixCellSelected.send( std::make_pair( matrixItem->parameter, matrixItem->curveDef ) );

View File

@ -22,11 +22,11 @@
#include "cafAppEnum.h"
#include <QDateTime>
class RimRegularLegendConfig;
class RimSummaryAddress;
class RiuGroupedBarChartBuilder;
class RiuPlotItem;
//==================================================================================================
///
@ -79,7 +79,7 @@ private:
void createMatrix();
void updatePlotTitle() override;
void updateLegend() override;
void onPlotItemSelected( QwtPlotItem* plotItem, bool toggle, int sampleIndex ) override;
void onPlotItemSelected( std::shared_ptr<RiuPlotItem> plotItem, bool toggle, int sampleIndex ) override;
private:
caf::PdmField<bool> m_showAbsoluteValues;

View File

@ -22,6 +22,7 @@
#include "RiaQDateTimeTools.h"
#include "RiuGroupedBarChartBuilder.h"
#include "RiuPlotMainWindowTools.h"
#include "RiuQwtPlotItem.h"
#include "RiuQwtPlotWidget.h"
#include "RifSummaryReaderInterface.h"
@ -40,6 +41,7 @@
#include "cafPdmUiComboBoxEditor.h"
#include "cafPdmUiTreeSelectionEditor.h"
#include "qwt_plot.h"
#include "qwt_plot_barchart.h"
#include <limits>
@ -176,19 +178,19 @@ void RimCorrelationPlot::onLoadDataAndUpdate()
if ( m_plotWidget && m_analyserOfSelectedCurveDefs )
{
m_plotWidget->detachItems( QwtPlotItem::Rtti_PlotBarChart );
m_plotWidget->detachItems( QwtPlotItem::Rtti_PlotScale );
m_plotWidget->qwtPlot()->detachItems( QwtPlotItem::Rtti_PlotBarChart );
m_plotWidget->qwtPlot()->detachItems( QwtPlotItem::Rtti_PlotScale );
RiuGroupedBarChartBuilder chartBuilder;
addDataToChartBuilder( chartBuilder );
chartBuilder.addBarChartToPlot( m_plotWidget,
chartBuilder.addBarChartToPlot( m_plotWidget->qwtPlot(),
Qt::Horizontal,
m_showOnlyTopNCorrelations() ? m_topNFilterCount() : -1 );
chartBuilder.setLabelFontSize( labelFontSize() );
m_plotWidget->insertLegend( nullptr );
m_plotWidget->qwtPlot()->insertLegend( nullptr );
m_plotWidget->updateLegend();
this->updateAxes();
@ -204,22 +206,30 @@ void RimCorrelationPlot::updateAxes()
{
if ( !m_plotWidget ) return;
m_plotWidget->setAxisTitleText( QwtPlot::yLeft, "Parameter" );
m_plotWidget->setAxisTitleEnabled( QwtPlot::yLeft, true );
m_plotWidget->setAxisFontsAndAlignment( QwtPlot::yLeft, axisTitleFontSize(), axisValueFontSize(), false, Qt::AlignCenter );
m_plotWidget->setAxisTitleText( RiaDefines::PlotAxis::PLOT_AXIS_LEFT, "Parameter" );
m_plotWidget->setAxisTitleEnabled( RiaDefines::PlotAxis::PLOT_AXIS_LEFT, true );
m_plotWidget->setAxisFontsAndAlignment( RiaDefines::PlotAxis::PLOT_AXIS_LEFT,
axisTitleFontSize(),
axisValueFontSize(),
false,
Qt::AlignCenter );
m_plotWidget->setAxisTitleText( QwtPlot::xBottom, "Pearson Correlation Coefficient" );
m_plotWidget->setAxisTitleEnabled( QwtPlot::xBottom, true );
m_plotWidget->setAxisFontsAndAlignment( QwtPlot::xBottom, axisTitleFontSize(), axisValueFontSize(), false, Qt::AlignCenter );
m_plotWidget->setAxisTitleText( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM, "Pearson Correlation Coefficient" );
m_plotWidget->setAxisTitleEnabled( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM, true );
m_plotWidget->setAxisFontsAndAlignment( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM,
axisTitleFontSize(),
axisValueFontSize(),
false,
Qt::AlignCenter );
if ( m_showAbsoluteValues )
{
m_plotWidget->setAxisTitleText( QwtPlot::xBottom, "Pearson Correlation Coefficient ABS" );
m_plotWidget->setAxisRange( QwtPlot::xBottom, 0.0, 1.0 );
m_plotWidget->setAxisTitleText( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM, "Pearson Correlation Coefficient ABS" );
m_plotWidget->setAxisRange( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM, 0.0, 1.0 );
}
else
{
m_plotWidget->setAxisTitleText( QwtPlot::xBottom, "Pearson Correlation Coefficient" );
m_plotWidget->setAxisRange( QwtPlot::xBottom, -1.0, 1.0 );
m_plotWidget->setAxisTitleText( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM, "Pearson Correlation Coefficient" );
m_plotWidget->setAxisRange( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM, -1.0, 1.0 );
}
}
@ -273,9 +283,12 @@ void RimCorrelationPlot::updatePlotTitle()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCorrelationPlot::onPlotItemSelected( QwtPlotItem* plotItem, bool toggle, int sampleIndex )
void RimCorrelationPlot::onPlotItemSelected( std::shared_ptr<RiuPlotItem> plotItem, bool toggle, int sampleIndex )
{
QwtPlotBarChart* barChart = dynamic_cast<QwtPlotBarChart*>( plotItem );
RiuQwtPlotItem* qwtPlotItem = dynamic_cast<RiuQwtPlotItem*>( plotItem.get() );
if ( !qwtPlotItem ) return;
QwtPlotBarChart* barChart = dynamic_cast<QwtPlotBarChart*>( qwtPlotItem->qwtPlotItem() );
if ( barChart && !curveDefinitions().empty() )
{
auto curveDef = curveDefinitions().front();

View File

@ -28,6 +28,7 @@
class RimSummaryAddress;
class RiuGroupedBarChartBuilder;
class RiuPlotItem;
//==================================================================================================
///
@ -70,7 +71,7 @@ private:
// Private methods
void addDataToChartBuilder( RiuGroupedBarChartBuilder& chartBuilder );
void updatePlotTitle() override;
void onPlotItemSelected( QwtPlotItem* plotItem, bool toggle, int sampleIndex ) override;
void onPlotItemSelected( std::shared_ptr<RiuPlotItem> plotItem, bool toggle, int sampleIndex ) override;
private:
caf::PdmField<bool> m_showAbsoluteValues;

View File

@ -29,6 +29,8 @@
#include "RimSummaryCaseCollection.h"
#include "RiuMultiPlotPage.h"
#include "RiuPlotWidget.h"
#include "RiuQwtPlotWidget.h"
#include "cafAssert.h"
#include "cafPdmUiOrdering.h"

View File

@ -39,6 +39,7 @@
#include "RimSummaryCaseCollection.h"
#include "RimSummaryPlotAxisFormatter.h"
#include "RiuPlotCurve.h"
#include "RiuPlotMainWindowTools.h"
#include "RiuQwtPlotCurve.h"
#include "RiuSummaryQwtPlot.h"
@ -49,6 +50,7 @@
#include "cafPdmUiPushButtonEditor.h"
#include "qwt_legend.h"
#include "qwt_plot.h"
#include "qwt_plot_curve.h"
#include "qwt_scale_engine.h"
@ -168,7 +170,7 @@ void RimParameterResultCrossPlot::onLoadDataAndUpdate()
if ( m_showPlotLegends && !isSubPlot<RimMultiPlot>() )
{
QwtLegend* legend = new QwtLegend( m_plotWidget );
m_plotWidget->insertLegend( legend, QwtPlot::RightLegend );
m_plotWidget->qwtPlot()->insertLegend( legend, QwtPlot::RightLegend );
m_plotWidget->setLegendFontSize( legendFontSize() );
m_plotWidget->updateLegend();
}
@ -186,19 +188,31 @@ void RimParameterResultCrossPlot::updateAxes()
{
if ( !m_plotWidget ) return;
m_plotWidget->setAxisTitleText( QwtPlot::yLeft, completeAddressText() );
m_plotWidget->setAxisTitleEnabled( QwtPlot::yLeft, true );
m_plotWidget->setAxisFontsAndAlignment( QwtPlot::yLeft, axisTitleFontSize(), axisValueFontSize(), false, Qt::AlignCenter );
m_plotWidget->setAxisTitleText( RiaDefines::PlotAxis::PLOT_AXIS_LEFT, completeAddressText() );
m_plotWidget->setAxisTitleEnabled( RiaDefines::PlotAxis::PLOT_AXIS_LEFT, true );
m_plotWidget->setAxisFontsAndAlignment( RiaDefines::PlotAxis::PLOT_AXIS_LEFT,
axisTitleFontSize(),
axisValueFontSize(),
false,
Qt::AlignCenter );
double yRangeWidth = m_yRange.second - m_yRange.first;
m_plotWidget->setAxisRange( QwtPlot::yLeft, m_yRange.first - yRangeWidth * 0.1, m_yRange.second + yRangeWidth * 0.1 );
m_plotWidget->setAxisRange( RiaDefines::PlotAxis::PLOT_AXIS_LEFT,
m_yRange.first - yRangeWidth * 0.1,
m_yRange.second + yRangeWidth * 0.1 );
m_plotWidget->setAxisTitleText( QwtPlot::xBottom, m_ensembleParameter );
m_plotWidget->setAxisTitleEnabled( QwtPlot::xBottom, true );
m_plotWidget->setAxisFontsAndAlignment( QwtPlot::xBottom, axisTitleFontSize(), axisValueFontSize(), false, Qt::AlignCenter );
m_plotWidget->setAxisTitleText( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM, m_ensembleParameter );
m_plotWidget->setAxisTitleEnabled( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM, true );
m_plotWidget->setAxisFontsAndAlignment( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM,
axisTitleFontSize(),
axisValueFontSize(),
false,
Qt::AlignCenter );
double xRangeWidth = m_xRange.second - m_xRange.first;
m_plotWidget->setAxisRange( QwtPlot::xBottom, m_xRange.first - xRangeWidth * 0.1, m_xRange.second + xRangeWidth * 0.1 );
m_plotWidget->setAxisRange( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM,
m_xRange.first - xRangeWidth * 0.1,
m_xRange.second + xRangeWidth * 0.1 );
}
//--------------------------------------------------------------------------------------------------
@ -295,10 +309,10 @@ void RimParameterResultCrossPlot::createPoints()
m_yRange.second = std::max( m_yRange.second, closestValue );
RiuQwtPlotCurve* plotCurve = new RiuQwtPlotCurve;
plotCurve->setSamples( parameterValues.data(), caseValuesAtTimestep.data(), (int)parameterValues.size() );
plotCurve->setSamplesValues( parameterValues, caseValuesAtTimestep );
plotCurve->setStyle( QwtPlotCurve::NoCurve );
RiuQwtSymbol* symbol =
new RiuQwtSymbol( RiuQwtSymbol::cycledSymbolStyle( ensembleIdx, addressIdx ), "" );
new RiuQwtSymbol( RiuPlotCurveSymbol::cycledSymbolStyle( ensembleIdx, addressIdx ), "" );
symbol->setSize( legendFontSize(), legendFontSize() );
symbol->setColor( colorTable.cycledQColor( caseIdx ) );
plotCurve->setSymbol( symbol );
@ -309,7 +323,7 @@ void RimParameterResultCrossPlot::createPoints()
plotCurve->setTitle( curveName.join( " - " ) );
plotCurve->attach( m_plotWidget );
plotCurve->attach( m_plotWidget->qwtPlot() );
}
}
addressIdx++;

View File

@ -119,7 +119,7 @@ RiaDefines::PhaseType RimWellDistributionPlot::phase() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuQwtPlotWidget* RimWellDistributionPlot::viewer()
RiuPlotWidget* RimWellDistributionPlot::plotWidget()
{
return m_plotWidget;
}
@ -170,28 +170,28 @@ void RimWellDistributionPlot::updateLegend()
if ( doShowLegend )
{
QwtLegend* legend = new QwtLegend( m_plotWidget );
m_plotWidget->insertLegend( legend, QwtPlot::BottomLegend );
m_plotWidget->qwtPlot()->insertLegend( legend, QwtPlot::BottomLegend );
}
else
{
m_plotWidget->insertLegend( nullptr );
m_plotWidget->qwtPlot()->insertLegend( nullptr );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellDistributionPlot::updateZoomInQwt()
void RimWellDistributionPlot::updateZoomInParentPlot()
{
// cvf::Trace::show("RimWellDistributionPlot::updateZoomInQwt()");
// cvf::Trace::show("RimWellDistributionPlot::updateZoomInParentPlot()");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellDistributionPlot::updateZoomFromQwt()
void RimWellDistributionPlot::updateZoomFromParentPlot()
{
// cvf::Trace::show("RimWellDistributionPlot::updateZoomFromQwt()");
// cvf::Trace::show("RimWellDistributionPlot::updateZoomFromParentPlot()");
}
//--------------------------------------------------------------------------------------------------
@ -222,7 +222,7 @@ void RimWellDistributionPlot::detachAllCurves()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmObject* RimWellDistributionPlot::findPdmObjectFromQwtCurve( const QwtPlotCurve* /*curve*/ ) const
caf::PdmObject* RimWellDistributionPlot::findPdmObjectFromPlotCurve( const RiuPlotCurve* /*curve*/ ) const
{
// cvf::Trace::show("RimWellDistributionPlot::findPdmObjectFromQwtCurve()");
return nullptr;
@ -282,7 +282,7 @@ void RimWellDistributionPlot::zoomAll()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuQwtPlotWidget* RimWellDistributionPlot::doCreatePlotViewWidget( QWidget* mainWindowParent )
RiuPlotWidget* RimWellDistributionPlot::doCreatePlotViewWidget( QWidget* mainWindowParent )
{
// cvf::Trace::show("RimWellDistributionPlot::createViewWidget()");
@ -294,7 +294,7 @@ RiuQwtPlotWidget* RimWellDistributionPlot::doCreatePlotViewWidget( QWidget* main
m_plotWidget = new RiuQwtPlotWidget( this, mainWindowParent );
m_plotWidget->setAutoReplot( false );
m_plotWidget->qwtPlot()->setAutoReplot( false );
updateLegend();
onLoadDataAndUpdate();
@ -339,7 +339,7 @@ void RimWellDistributionPlot::onLoadDataAndUpdate()
return;
}
m_plotWidget->detachItems( QwtPlotItem::Rtti_PlotCurve );
m_plotWidget->qwtPlot()->detachItems( QwtPlotItem::Rtti_PlotCurve );
updateLegend();
@ -374,12 +374,12 @@ void RimWellDistributionPlot::onLoadDataAndUpdate()
const QString plotTitleStr =
QString( "%1 Distribution: %2, %3" ).arg( phaseString ).arg( m_wellName ).arg( timeStepName );
m_plotWidget->setTitle( plotTitleStr );
m_plotWidget->setPlotTitle( plotTitleStr );
m_plotWidget->setAxisTitleText( QwtPlot::xBottom, "TOF [years]" );
m_plotWidget->setAxisTitleText( QwtPlot::yLeft, "Reservoir Volume [m3]" );
m_plotWidget->setAxisTitleEnabled( QwtPlot::xBottom, true );
m_plotWidget->setAxisTitleEnabled( QwtPlot::yLeft, true );
m_plotWidget->setAxisTitleText( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM, "TOF [years]" );
m_plotWidget->setAxisTitleText( RiaDefines::PlotAxis::PLOT_AXIS_LEFT, "Reservoir Volume [m3]" );
m_plotWidget->setAxisTitleEnabled( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM, true );
m_plotWidget->setAxisTitleEnabled( RiaDefines::PlotAxis::PLOT_AXIS_LEFT, true );
m_plotWidget->scheduleReplot();
}
@ -397,11 +397,11 @@ void RimWellDistributionPlot::populatePlotWidgetWithCurveData( const RigTofWellD
// Currently select this value so that the grid appears on top of the curves
const double baseCurveZValue = 9.5;
plotWidget->detachItems( QwtPlotItem::Rtti_PlotCurve );
plotWidget->setAxisScale( QwtPlot::xBottom, 0, 1 );
plotWidget->setAxisScale( QwtPlot::yLeft, 0, 1 );
plotWidget->setAxisAutoScale( QwtPlot::xBottom, true );
plotWidget->setAxisAutoScale( QwtPlot::yLeft, true );
plotWidget->qwtPlot()->detachItems( QwtPlotItem::Rtti_PlotCurve );
plotWidget->setAxisScale( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM, 0, 1 );
plotWidget->setAxisScale( RiaDefines::PlotAxis::PLOT_AXIS_LEFT, 0, 1 );
plotWidget->setAxisAutoScale( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM, true );
plotWidget->setAxisAutoScale( RiaDefines::PlotAxis::PLOT_AXIS_LEFT, true );
const std::vector<double>& tofValuesDays = calculator.sortedUniqueTofValues();
if ( tofValuesDays.size() == 0 )
@ -449,7 +449,7 @@ void RimWellDistributionPlot::populatePlotWidgetWithCurveData( const RigTofWellD
curve->setBrush( qtClr );
curve->setZ( baseCurveZValue - i * 0.0001 );
curve->setSamples( tofValuesYears.data(), yVals.data(), static_cast<int>( tofValuesYears.size() ) );
curve->attach( plotWidget );
curve->attach( plotWidget->qwtPlot() );
}
}

View File

@ -49,18 +49,18 @@ public:
RiaDefines::PhaseType phase() const;
// RimPlot implementations
RiuQwtPlotWidget* viewer() override;
void setAutoScaleXEnabled( bool enabled ) override;
void setAutoScaleYEnabled( bool enabled ) override;
void updateAxes() override;
void updateLegend() override;
void updateZoomInQwt() override;
void updateZoomFromQwt() override;
QString asciiDataForPlotExport() const override;
void reattachAllCurves() override;
void detachAllCurves() override;
caf::PdmObject* findPdmObjectFromQwtCurve( const QwtPlotCurve* curve ) const override;
void onAxisSelected( int axis, bool toggle ) override;
RiuPlotWidget* plotWidget() override;
void setAutoScaleXEnabled( bool enabled ) override;
void setAutoScaleYEnabled( bool enabled ) override;
void updateAxes() override;
void updateLegend() override;
void updateZoomInParentPlot() override;
void updateZoomFromParentPlot() override;
QString asciiDataForPlotExport() const override;
void reattachAllCurves() override;
void detachAllCurves() override;
caf::PdmObject* findPdmObjectFromPlotCurve( const RiuPlotCurve* curve ) const override;
void onAxisSelected( int axis, bool toggle ) override;
// RimPlotWindow implementations
QString description() const override;
@ -76,7 +76,7 @@ private:
void onLoadDataAndUpdate() override;
private:
RiuQwtPlotWidget* doCreatePlotViewWidget( QWidget* mainWindowParent ) override;
RiuPlotWidget* doCreatePlotViewWidget( QWidget* mainWindowParent ) override;
void fixupDependentFieldsAfterCaseChange();
static void populatePlotWidgetWithCurveData( const RigTofWellDistributionCalculator& calculator,

View File

@ -30,7 +30,9 @@
#include "RiaColorTools.h"
#include "RiuMultiPlotPage.h"
#include "RiuPlotWidget.h"
#include "RiuQwtPlotTools.h"
#include "RiuQwtPlotWidget.h"
#include "qwt_legend.h"
#include "qwt_plot.h"
@ -217,7 +219,7 @@ void RimWellDistributionPlotCollection::addPlot( RimPlot* plot )
if ( m_viewer )
{
plot->createPlotWidget();
m_viewer->insertPlot( plot->viewer(), index );
m_viewer->insertPlot( plot->plotWidget(), index );
}
plot->setShowWindow( true );
plot->setLegendsVisible( false );
@ -373,7 +375,7 @@ void RimWellDistributionPlotCollection::updatePlots()
for ( RimPlot* plot : m_plots() )
{
plot->loadDataAndUpdate();
plot->updateZoomInQwt();
plot->updateZoomInParentPlot();
}
}
}
@ -407,7 +409,7 @@ void RimWellDistributionPlotCollection::recreatePlotWidgets()
for ( auto plot : m_plots() )
{
plot->createPlotWidget();
m_viewer->addPlot( plot->viewer() );
m_viewer->addPlot( plot->plotWidget() );
}
}

View File

@ -161,7 +161,7 @@ void RimWellFlowRateCurve::onLoadDataAndUpdate( bool updateParentPlot )
{
this->RimPlotCurve::updateCurvePresentation( updateParentPlot );
m_qwtPlotCurve->setTitle( createCurveAutoName() );
m_plotCurve->setTitle( createCurveAutoName() );
if ( updateParentPlot )
{
@ -172,7 +172,7 @@ void RimWellFlowRateCurve::onLoadDataAndUpdate( bool updateParentPlot )
updateZoomInParentPlot();
}
if ( m_parentQwtPlot ) m_parentQwtPlot->replot();
if ( hasParentPlot() ) m_parentPlot->replot();
}
//--------------------------------------------------------------------------------------------------
@ -195,9 +195,11 @@ void RimWellFlowRateCurve::updateCurveAppearance()
}
}
if ( isUsingConnectionNumberDepthType() )
QwtPlotCurve* qwtPlotCurve = dynamic_cast<QwtPlotCurve*>( m_plotCurve );
if ( isUsingConnectionNumberDepthType() && qwtPlotCurve )
{
m_qwtPlotCurve->setStyle( QwtPlotCurve::Steps );
// Steps style only for Qwt.
qwtPlotCurve->setStyle( QwtPlotCurve::Steps );
}
if ( m_doFillCurve || isLastCurveInGroup ) // Fill the last curve in group with a transparent color to "tie" the
@ -222,14 +224,19 @@ void RimWellFlowRateCurve::updateCurveAppearance()
gradient.setColorAt( 0.6, fillColor );
gradient.setColorAt( 0.8, fillColor.darker( 110 ) );
gradient.setColorAt( 1, fillColor );
m_qwtPlotCurve->setBrush( gradient );
m_plotCurve->setBrush( gradient );
QPen curvePen = m_qwtPlotCurve->pen();
curvePen.setColor( lineColor );
m_qwtPlotCurve->setPen( curvePen );
m_qwtPlotCurve->setOrientation( Qt::Horizontal );
m_qwtPlotCurve->setBaseline( 0.0 );
m_qwtPlotCurve->setCurveAttribute( QwtPlotCurve::Inverted, true );
if ( qwtPlotCurve )
{
// Baseline and orientation only available for Qwt.
QPen curvePen = qwtPlotCurve->pen();
curvePen.setColor( lineColor );
qwtPlotCurve->setPen( curvePen );
qwtPlotCurve->setOrientation( Qt::Horizontal );
qwtPlotCurve->setBaseline( 0.0 );
qwtPlotCurve->setCurveAttribute( QwtPlotCurve::Inverted, true );
}
}
}

View File

@ -709,7 +709,7 @@ void RimWellPltPlot::addStackedCurve( const QString& curveName,
if ( curveGroupId == 0 )
{
curve->setDoFillCurve( true );
curve->setSymbol( RiuQwtSymbol::SYMBOL_NONE );
curve->setSymbol( RiuPlotCurveSymbol::SYMBOL_NONE );
}
else
{

View File

@ -156,7 +156,7 @@ void RimWellRftPlot::applyCurveAppearance( RimWellLogCurve* curve )
RiaRftPltCurveDefinition curveDef = RimWellPlotTools::curveDefFromCurve( curve );
RiuQwtPlotCurveDefines::LineStyleEnum lineStyle = RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_SOLID;
RiuQwtSymbol::PointSymbolEnum currentSymbol = RiuQwtSymbol::SYMBOL_NONE;
RiuPlotCurveSymbol::PointSymbolEnum currentSymbol = RiuPlotCurveSymbol::SYMBOL_NONE;
if ( curveDef.address().sourceType() != RifDataSourceForRftPlt::ENSEMBLE_RFT )
{
currentSymbol = m_timeStepSymbols[curveDef.timeStep()];
@ -571,8 +571,8 @@ void RimWellRftPlot::updateCurvesInPlot( const std::set<RiaRftPltCurveDefinition
curve->setZOrder(
RiuQwtPlotCurveDefines::zDepthForIndex( RiuQwtPlotCurveDefines::ZIndex::Z_ENSEMBLE_STAT_CURVE ) );
applyCurveAppearance( curve );
auto symbol = statisticsCurveSymbolFromAddress( rftAddress );
RiuQwtSymbol::LabelPosition labelPos = statisticsLabelPosFromAddress( rftAddress );
auto symbol = statisticsCurveSymbolFromAddress( rftAddress );
RiuPlotCurveSymbol::LabelPosition labelPos = statisticsLabelPosFromAddress( rftAddress );
curve->setSymbol( symbol );
curve->setSymbolLabelPosition( labelPos );
curve->setSymbolSize( curve->symbolSize() + 3 );
@ -1159,39 +1159,39 @@ void RimWellRftPlot::assignWellPathToExtractionCurves()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuQwtSymbol::PointSymbolEnum RimWellRftPlot::statisticsCurveSymbolFromAddress( const RifEclipseRftAddress& address )
RiuPlotCurveSymbol::PointSymbolEnum RimWellRftPlot::statisticsCurveSymbolFromAddress( const RifEclipseRftAddress& address )
{
switch ( address.wellLogChannel() )
{
case RifEclipseRftAddress::PRESSURE_P10:
return RiuQwtSymbol::SYMBOL_TRIANGLE;
return RiuPlotCurveSymbol::SYMBOL_TRIANGLE;
case RifEclipseRftAddress::PRESSURE_P50:
return RiuQwtSymbol::SYMBOL_DOWN_TRIANGLE;
return RiuPlotCurveSymbol::SYMBOL_DOWN_TRIANGLE;
case RifEclipseRftAddress::PRESSURE_P90:
return RiuQwtSymbol::SYMBOL_LEFT_TRIANGLE;
return RiuPlotCurveSymbol::SYMBOL_LEFT_TRIANGLE;
case RifEclipseRftAddress::PRESSURE_MEAN:
return RiuQwtSymbol::SYMBOL_RIGHT_TRIANGLE;
return RiuPlotCurveSymbol::SYMBOL_RIGHT_TRIANGLE;
}
return RiuQwtSymbol::SYMBOL_RIGHT_TRIANGLE;
return RiuPlotCurveSymbol::SYMBOL_RIGHT_TRIANGLE;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuQwtSymbol::LabelPosition RimWellRftPlot::statisticsLabelPosFromAddress( const RifEclipseRftAddress& address )
RiuPlotCurveSymbol::LabelPosition RimWellRftPlot::statisticsLabelPosFromAddress( const RifEclipseRftAddress& address )
{
switch ( address.wellLogChannel() )
{
case RifEclipseRftAddress::PRESSURE_P10:
return RiuQwtSymbol::LabelLeftOfSymbol;
return RiuPlotCurveSymbol::LabelLeftOfSymbol;
case RifEclipseRftAddress::PRESSURE_P50:
return RiuQwtSymbol::LabelAboveSymbol;
return RiuPlotCurveSymbol::LabelAboveSymbol;
case RifEclipseRftAddress::PRESSURE_P90:
return RiuQwtSymbol::LabelRightOfSymbol;
return RiuPlotCurveSymbol::LabelRightOfSymbol;
case RifEclipseRftAddress::PRESSURE_MEAN:
return RiuQwtSymbol::LabelBelowSymbol;
return RiuPlotCurveSymbol::LabelBelowSymbol;
}
return RiuQwtSymbol::LabelAboveSymbol;
return RiuPlotCurveSymbol::LabelAboveSymbol;
}
//--------------------------------------------------------------------------------------------------
@ -1217,10 +1217,10 @@ cvf::Color3f RimWellRftPlot::findCurveColor( RimWellLogCurve* curve )
if ( m_showStatisticsCurves )
{
if ( plotByIndex( 0 ) && plotByIndex( 0 )->viewer() )
if ( plotByIndex( 0 ) && plotByIndex( 0 )->plotWidget() )
{
cvf::Color3f backgroundColor =
RiaColorTools::fromQColorTo3f( plotByIndex( 0 )->viewer()->canvasBackground().color() );
RiaColorTools::fromQColorTo3f( plotByIndex( 0 )->plotWidget()->backgroundColor() );
curveColor = RiaColorTools::blendCvfColors( backgroundColor, curveColor, 1, 2 );
}
}
@ -1272,7 +1272,7 @@ void RimWellRftPlot::defineCurveColorsAndSymbols( const std::set<RiaRftPltCurveD
{
if ( !m_ensembleLegendFrames[curveSet] )
{
auto m = new RiuDraggableOverlayFrame( viewer->canvas(), viewer->overlayMargins() );
auto m = new RiuDraggableOverlayFrame( viewer->getParentForOverlay(), viewer->overlayMargins() );
m->setContentFrame( curveSet->legendConfig()->makeLegendFrame() );
m_ensembleLegendFrames[curveSet] = m;
@ -1286,12 +1286,12 @@ void RimWellRftPlot::defineCurveColorsAndSymbols( const std::set<RiaRftPltCurveD
std::vector<cvf::Color3f> colorTable;
RiaColorTables::summaryCurveDefaultPaletteColors().color3fArray().toStdVector( &colorTable );
std::vector<RiuQwtSymbol::PointSymbolEnum> symbolTable = { RiuQwtSymbol::SYMBOL_ELLIPSE,
RiuQwtSymbol::SYMBOL_RECT,
RiuQwtSymbol::SYMBOL_DIAMOND,
RiuQwtSymbol::SYMBOL_CROSS,
RiuQwtSymbol::SYMBOL_XCROSS,
RiuQwtSymbol::SYMBOL_STAR1 };
std::vector<RiuPlotCurveSymbol::PointSymbolEnum> symbolTable = { RiuPlotCurveSymbol::SYMBOL_ELLIPSE,
RiuPlotCurveSymbol::SYMBOL_RECT,
RiuPlotCurveSymbol::SYMBOL_DIAMOND,
RiuPlotCurveSymbol::SYMBOL_CROSS,
RiuPlotCurveSymbol::SYMBOL_XCROSS,
RiuPlotCurveSymbol::SYMBOL_STAR1 };
// Add new curves
for ( const RiaRftPltCurveDefinition& curveDefToAdd : allCurveDefs )

View File

@ -24,7 +24,7 @@
#include "RimWellRftEnsembleCurveSet.h"
#include "RifDataSourceForRftPltQMetaType.h"
#include "RiuQwtSymbol.h"
#include "RiuPlotCurveSymbol.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
@ -130,8 +130,8 @@ private:
void updateFormationsOnPlot() const;
QString associatedSimWellName() const;
static RiuQwtSymbol::PointSymbolEnum statisticsCurveSymbolFromAddress( const RifEclipseRftAddress& address );
static RiuQwtSymbol::LabelPosition statisticsLabelPosFromAddress( const RifEclipseRftAddress& address );
static RiuPlotCurveSymbol::PointSymbolEnum statisticsCurveSymbolFromAddress( const RifEclipseRftAddress& address );
static RiuPlotCurveSymbol::LabelPosition statisticsLabelPosFromAddress( const RifEclipseRftAddress& address );
cvf::Color3f findCurveColor( RimWellLogCurve* curve );
void defineCurveColorsAndSymbols( const std::set<RiaRftPltCurveDefinition>& allCurveDefs );
@ -158,9 +158,9 @@ private:
caf::PdmChildArrayField<RimWellRftEnsembleCurveSet*> m_ensembleCurveSets;
std::map<RimWellRftEnsembleCurveSet*, QPointer<RiuDraggableOverlayFrame>> m_ensembleLegendFrames;
std::map<RifDataSourceForRftPlt, cvf::Color3f> m_dataSourceColors;
std::map<QDateTime, RiuQwtSymbol::PointSymbolEnum> m_timeStepSymbols;
bool m_isOnLoad;
std::map<RifDataSourceForRftPlt, cvf::Color3f> m_dataSourceColors;
std::map<QDateTime, RiuPlotCurveSymbol::PointSymbolEnum> m_timeStepSymbols;
bool m_isOnLoad;
caf::PdmChildField<RimWellLogPlot*> m_wellLogPlot_OBSOLETE;
};

View File

@ -17,6 +17,7 @@
/////////////////////////////////////////////////////////////////////////////////
#include "RimGridCrossPlot.h"
#include "RiaDefines.h"
#include "RiaFontCache.h"
#include "RiaPreferences.h"
@ -30,6 +31,7 @@
#include "RimGridCrossPlotCurve.h"
#include "RimGridCrossPlotDataSet.h"
#include "RimMultiPlot.h"
#include "RimPlotAxisLogRangeCalculator.h"
#include "RimPlotAxisProperties.h"
#include "cafPdmUiCheckBoxEditor.h"
@ -41,7 +43,6 @@
#include "qwt_legend.h"
#include "qwt_plot.h"
#include "qwt_plot_curve.h"
#include "qwt_scale_engine.h"
#include <QDebug>
@ -64,13 +65,13 @@ RimGridCrossPlot::RimGridCrossPlot()
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->setNameAndAxis( "X-Axis", RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM );
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->setNameAndAxis( "Y-Axis", RiaDefines::PlotAxis::PLOT_AXIS_LEFT );
m_yAxisProperties->setEnableTitleTextSettings( false );
connectAxisSignals( m_xAxisProperties() );
@ -156,7 +157,7 @@ QWidget* RimGridCrossPlot::viewWidget()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuQwtPlotWidget* RimGridCrossPlot::viewer()
RiuPlotWidget* RimGridCrossPlot::plotWidget()
{
return m_plotWidget;
}
@ -185,7 +186,7 @@ void RimGridCrossPlot::zoomAll()
setAutoScaleXEnabled( true );
setAutoScaleYEnabled( true );
updateZoomInQwt();
updateZoomInParentPlot();
}
//--------------------------------------------------------------------------------------------------
@ -211,10 +212,13 @@ void RimGridCrossPlot::reattachAllCurves()
dataSet->detachAllCurves();
if ( dataSet->isChecked() )
{
dataSet->setParentQwtPlotNoReplot( m_plotWidget );
dataSet->setParentPlotNoReplot( m_plotWidget );
dataSet->loadDataAndUpdate( false );
}
}
updateZoomInQwt();
updateCurveNamesAndPlotTitle();
updateLegend();
updateZoomInParentPlot();
}
}
@ -291,7 +295,8 @@ void RimGridCrossPlot::updateInfoBox()
{
if ( !m_infoBox )
{
m_infoBox = new RiuDraggableOverlayFrame( m_plotWidget->canvas(), m_plotWidget->overlayMargins() );
m_infoBox =
new RiuDraggableOverlayFrame( m_plotWidget->getParentForOverlay(), m_plotWidget->overlayMargins() );
m_infoBox->setAnchorCorner( RiuDraggableOverlayFrame::AnchorCorner::TopRight );
RiuTextOverlayContentFrame* textFrame = new RiuTextOverlayContentFrame( m_infoBox );
textFrame->setText( generateInfoBoxText() );
@ -349,13 +354,13 @@ void RimGridCrossPlot::setAutoScaleYEnabled( bool enabled )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmObject* RimGridCrossPlot::findPdmObjectFromQwtCurve( const QwtPlotCurve* qwtCurve ) const
caf::PdmObject* RimGridCrossPlot::findPdmObjectFromPlotCurve( const RiuPlotCurve* plotCurve ) const
{
for ( auto dataSet : m_crossPlotDataSets )
{
for ( auto curve : dataSet->curves() )
{
if ( curve->qwtPlotCurve() == qwtCurve )
if ( curve->isSameCurve( plotCurve ) )
{
return curve;
}
@ -454,13 +459,13 @@ void RimGridCrossPlot::onPlotZoomed()
{
setAutoScaleXEnabled( false );
setAutoScaleYEnabled( false );
updateZoomFromQwt();
updateZoomFromParentPlot();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuQwtPlotWidget* RimGridCrossPlot::doCreatePlotViewWidget( QWidget* mainWindowParent )
RiuPlotWidget* RimGridCrossPlot::doCreatePlotViewWidget( QWidget* mainWindowParent )
{
if ( !m_plotWidget )
{
@ -468,7 +473,7 @@ RiuQwtPlotWidget* RimGridCrossPlot::doCreatePlotViewWidget( QWidget* mainWindowP
for ( auto dataSet : m_crossPlotDataSets )
{
dataSet->setParentQwtPlotNoReplot( m_plotWidget );
dataSet->setParentPlotNoReplot( m_plotWidget );
}
updateCurveNamesAndPlotTitle();
@ -592,15 +597,16 @@ void RimGridCrossPlot::updatePlot()
{
if ( m_plotWidget )
{
RiuQwtPlotTools::setCommonPlotBehaviour( m_plotWidget );
RiuQwtPlotTools::setDefaultAxes( m_plotWidget );
RiuQwtPlotTools::setCommonPlotBehaviour( m_plotWidget->qwtPlot() );
RiuQwtPlotTools::setDefaultAxes( m_plotWidget->qwtPlot() );
updateFonts();
updateAxes();
for ( auto dataSet : m_crossPlotDataSets )
{
dataSet->setParentQwtPlotNoReplot( m_plotWidget );
dataSet->setParentPlotNoReplot( m_plotWidget );
dataSet->loadDataAndUpdate( false );
}
updateLegend();
@ -635,9 +641,9 @@ void RimGridCrossPlot::swapAxes()
RimPlotAxisProperties* xAxisProperties = m_xAxisProperties();
RimPlotAxisProperties* yAxisProperties = m_yAxisProperties();
QString tmpName = xAxisProperties->name();
QwtPlot::Axis tmpAxis = xAxisProperties->qwtPlotAxisType();
xAxisProperties->setNameAndAxis( yAxisProperties->name(), yAxisProperties->qwtPlotAxisType() );
QString tmpName = xAxisProperties->name();
RiaDefines::PlotAxis tmpAxis = xAxisProperties->plotAxisType();
xAxisProperties->setNameAndAxis( yAxisProperties->name(), yAxisProperties->plotAxisType() );
yAxisProperties->setNameAndAxis( tmpName, tmpAxis );
m_xAxisProperties.removeChildObject( xAxisProperties );
@ -760,14 +766,14 @@ void RimGridCrossPlot::updateLegend()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGridCrossPlot::updateZoomInQwt()
void RimGridCrossPlot::updateZoomInParentPlot()
{
if ( m_plotWidget )
{
updateAxisInQwt( RiaDefines::PlotAxis::PLOT_AXIS_LEFT );
updateAxisInQwt( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM );
m_plotWidget->updateAxes();
updateZoomFromQwt();
m_plotWidget->qwtPlot()->updateAxes();
updateZoomFromParentPlot();
m_plotWidget->scheduleReplot();
}
}
@ -775,7 +781,7 @@ void RimGridCrossPlot::updateZoomInQwt()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGridCrossPlot::updateZoomFromQwt()
void RimGridCrossPlot::updateZoomFromParentPlot()
{
updateAxisFromQwt( RiaDefines::PlotAxis::PLOT_AXIS_LEFT );
updateAxisFromQwt( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM );
@ -845,42 +851,39 @@ void RimGridCrossPlot::updateAxisInQwt( RiaDefines::PlotAxis axisType )
axisParameterString = yAxisParameterString();
}
QwtPlot::Axis qwtAxisId = axisProperties->qwtPlotAxisType();
RiaDefines::PlotAxis axis = axisProperties->plotAxisType();
if ( axisProperties->isActive() )
{
m_plotWidget->enableAxis( qwtAxisId, true );
m_plotWidget->enableAxis( axis, true );
Qt::AlignmentFlag alignment = Qt::AlignCenter;
if ( axisProperties->titlePosition() == RimPlotAxisPropertiesInterface::AXIS_TITLE_END )
{
alignment = Qt::AlignRight;
}
m_plotWidget->setAxisFontsAndAlignment( qwtAxisId,
m_plotWidget->setAxisFontsAndAlignment( axis,
caf::FontTools::pointSizeToPixelSize( axisProperties->titleFontSize() ),
caf::FontTools::pointSizeToPixelSize( axisProperties->valuesFontSize() ),
true,
alignment );
m_plotWidget->setAxisTitleText( qwtAxisId, axisParameterString );
m_plotWidget->setAxisTitleEnabled( qwtAxisId, true );
m_plotWidget->setAxisTitleText( axis, axisParameterString );
m_plotWidget->setAxisTitleEnabled( axis, true );
if ( axisProperties->isLogarithmicScaleEnabled )
{
QwtLogScaleEngine* currentScaleEngine =
dynamic_cast<QwtLogScaleEngine*>( m_plotWidget->axisScaleEngine( axisProperties->qwtPlotAxisType() ) );
if ( !currentScaleEngine )
bool isLogScale = m_plotWidget->axisScaleType( axis ) == RiuQwtPlotWidget::AxisScaleType::LOGARITHMIC;
if ( !isLogScale )
{
m_plotWidget->setAxisScaleEngine( axisProperties->qwtPlotAxisType(), new QwtLogScaleEngine );
m_plotWidget->setAxisMaxMinor( axisProperties->qwtPlotAxisType(), 5 );
m_plotWidget->setAxisScaleType( axis, RiuQwtPlotWidget::AxisScaleType::LOGARITHMIC );
m_plotWidget->setAxisMaxMinor( axis, 5 );
}
double min = axisProperties->visibleRangeMin;
double max = axisProperties->visibleRangeMax;
if ( axisProperties->isAutoZoom() )
{
std::vector<const QwtPlotCurve*> plotCurves = visibleQwtCurves();
RimPlotAxisLogRangeCalculator logRangeCalculator( qwtAxisId, plotCurves );
std::vector<const RimPlotCurve*> plotCurves = visibleCurves();
RimPlotAxisLogRangeCalculator logRangeCalculator( axis, plotCurves );
logRangeCalculator.computeAxisRange( &min, &max );
}
@ -888,23 +891,21 @@ void RimGridCrossPlot::updateAxisInQwt( RiaDefines::PlotAxis axisType )
{
std::swap( min, max );
}
m_plotWidget->setAxisScale( qwtAxisId, min, max );
m_plotWidget->setAxisScale( axis, min, max );
}
else
{
QwtLinearScaleEngine* currentScaleEngine =
dynamic_cast<QwtLinearScaleEngine*>( m_plotWidget->axisScaleEngine( axisProperties->qwtPlotAxisType() ) );
if ( !currentScaleEngine )
bool isLinearScale = m_plotWidget->axisScaleType( axis ) == RiuQwtPlotWidget::AxisScaleType::LINEAR;
if ( !isLinearScale )
{
m_plotWidget->setAxisScaleEngine( axisProperties->qwtPlotAxisType(), new QwtLinearScaleEngine );
m_plotWidget->setAxisMaxMinor( axisProperties->qwtPlotAxisType(), 3 );
m_plotWidget->setAxisScaleType( axis, RiuQwtPlotWidget::AxisScaleType::LINEAR );
m_plotWidget->setAxisMaxMinor( axis, 3 );
}
if ( axisProperties->isAutoZoom() )
{
m_plotWidget->setAxisAutoScale( qwtAxisId );
m_plotWidget->axisScaleEngine( axisProperties->qwtPlotAxisType() )
->setAttribute( QwtScaleEngine::Inverted, axisProperties->isAxisInverted() );
m_plotWidget->setAxisAutoScale( axis, true );
m_plotWidget->setAxisInverted( axis, axisProperties->isAxisInverted() );
}
else
{
@ -915,13 +916,13 @@ void RimGridCrossPlot::updateAxisInQwt( RiaDefines::PlotAxis axisType )
std::swap( min, max );
}
m_plotWidget->setAxisScale( qwtAxisId, min, max );
m_plotWidget->setAxisScale( axis, min, max );
}
}
}
else
{
m_plotWidget->enableAxis( qwtAxisId, false );
m_plotWidget->enableAxis( axis, false );
}
}
@ -932,20 +933,23 @@ void RimGridCrossPlot::updateAxisFromQwt( RiaDefines::PlotAxis axisType )
{
if ( !m_plotWidget ) return;
QwtInterval xAxisRange = m_plotWidget->axisRange( QwtPlot::xBottom );
QwtInterval yAxisRange = m_plotWidget->axisRange( QwtPlot::yLeft );
auto [xAxisRangeMin, xAxisRangeMax] = m_plotWidget->axisRange( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM );
RimPlotAxisProperties* axisProperties = m_xAxisProperties();
QwtInterval axisRange = xAxisRange;
double axisRangeMin = xAxisRangeMin;
double axisRangeMax = xAxisRangeMax;
if ( axisType == RiaDefines::PlotAxis::PLOT_AXIS_LEFT )
{
axisProperties = m_yAxisProperties();
axisRange = yAxisRange;
axisProperties = m_yAxisProperties();
auto [yAxisRangeMin, yAxisRangeMax] = m_plotWidget->axisRange( RiaDefines::PlotAxis::PLOT_AXIS_LEFT );
axisRangeMin = yAxisRangeMin;
axisRangeMax = yAxisRangeMax;
}
axisProperties->visibleRangeMin = std::min( axisRange.minValue(), axisRange.maxValue() );
axisProperties->visibleRangeMax = std::max( axisRange.minValue(), axisRange.maxValue() );
axisProperties->visibleRangeMin = std::min( axisRangeMin, axisRangeMax );
axisProperties->visibleRangeMax = std::max( axisRangeMin, axisRangeMax );
axisProperties->updateConnectedEditors();
}
@ -953,9 +957,9 @@ void RimGridCrossPlot::updateAxisFromQwt( RiaDefines::PlotAxis axisType )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<const QwtPlotCurve*> RimGridCrossPlot::visibleQwtCurves() const
std::vector<const RimPlotCurve*> RimGridCrossPlot::visibleCurves() const
{
std::vector<const QwtPlotCurve*> plotCurves;
std::vector<const RimPlotCurve*> plotCurves;
for ( auto dataSet : m_crossPlotDataSets )
{
if ( dataSet->isChecked() )
@ -964,7 +968,7 @@ std::vector<const QwtPlotCurve*> RimGridCrossPlot::visibleQwtCurves() const
{
if ( curve->isCurveVisible() )
{
plotCurves.push_back( curve->qwtPlotCurve() );
plotCurves.push_back( curve );
}
}
}

View File

@ -21,7 +21,7 @@
#include "cafPdmChildField.h"
#include "cafPdmObject.h"
#include "RiaDefines.h"
#include "RiaPlotDefines.h"
#include "RimNameConfig.h"
#include "RimPlot.h"
@ -34,6 +34,7 @@ class RimPlotAxisProperties;
class RimGridCrossPlotDataSet;
class RiuDraggableOverlayFrame;
class RiuGridCrossQwtPlot;
class RimPlotCurve;
class RimGridCrossPlotNameConfig : public RimNameConfig
{
@ -69,8 +70,8 @@ public:
std::vector<RimGridCrossPlotDataSet*> dataSets() const;
QWidget* viewWidget() override;
RiuQwtPlotWidget* viewer() override;
QWidget* viewWidget() override;
RiuPlotWidget* plotWidget() override;
QImage snapshotWindowContent() override;
void zoomAll() override;
@ -98,12 +99,12 @@ public:
void updateLegend() override;
void updateZoomInQwt() override;
void updateZoomFromQwt() override;
void updateZoomInParentPlot() override;
void updateZoomFromParentPlot() override;
void setAutoScaleXEnabled( bool enabled ) override;
void setAutoScaleYEnabled( bool enabled ) override;
caf::PdmObject* findPdmObjectFromQwtCurve( const QwtPlotCurve* curve ) const override;
caf::PdmObject* findPdmObjectFromPlotCurve( const RiuPlotCurve* curve ) const override;
void onAxisSelected( int axis, bool toggle ) override;
bool isDeletable() const override;
@ -124,7 +125,7 @@ protected:
void updateAxisInQwt( RiaDefines::PlotAxis axisType );
void updateAxisFromQwt( RiaDefines::PlotAxis axisType );
std::vector<const QwtPlotCurve*> visibleQwtCurves() const;
std::vector<const RimPlotCurve*> visibleCurves() const;
RimPlotAxisProperties* xAxisProperties();
RimPlotAxisProperties* yAxisProperties();
@ -135,7 +136,7 @@ protected:
std::set<RimPlotAxisPropertiesInterface*> allPlotAxes() const;
private:
RiuQwtPlotWidget* doCreatePlotViewWidget( QWidget* mainWindowParent = nullptr ) override;
RiuPlotWidget* doCreatePlotViewWidget( QWidget* mainWindowParent = nullptr ) override;
void doUpdateLayout() override;
void cleanupBeforeClose();

View File

@ -18,28 +18,10 @@
#include "RimGridCrossPlotCurve.h"
#include "RigCaseCellResultCalculator.h"
#include "RimCase.h"
#include "RimEclipseCase.h"
#include "RimEclipseResultDefinition.h"
#include "RimGridCrossPlot.h"
#include "RimTools.h"
#include "RiuQwtPlotCurve.h"
#include "RiuQwtSymbol.h"
#include "cafPdmUiComboBoxEditor.h"
#include <QDebug>
#include <QPointF>
#include <QVector>
#include "qwt_graphic.h"
#include "qwt_plot.h"
#include "qwt_plot_curve.h"
#include <random>
#include "RiuPlotCurve.h"
#include "RiuPlotWidget.h"
CAF_PDM_SOURCE_INIT( RimGridCrossPlotCurve, "GridCrossPlotCurve" );
@ -53,7 +35,7 @@ RimGridCrossPlotCurve::RimGridCrossPlotCurve()
CAF_PDM_InitObject( "Cross Plot Points", ":/WellLogCurve16x16.png" );
setLineStyle( RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_NONE );
setSymbol( RiuQwtSymbol::SYMBOL_NONE );
setSymbol( RiuPlotCurveSymbol::SYMBOL_NONE );
setSymbolSize( 4 );
}
@ -73,9 +55,9 @@ void RimGridCrossPlotCurve::setSamples( const std::vector<double>& xValues, cons
{
CVF_ASSERT( xValues.size() == yValues.size() );
if ( xValues.empty() || yValues.empty() || !m_qwtPlotCurve ) return;
if ( xValues.empty() || yValues.empty() || !m_plotCurve ) return;
m_qwtPlotCurve->setSamples( &xValues[0], &yValues[0], static_cast<int>( xValues.size() ) );
m_plotCurve->setSamplesFromXValuesAndYValues( xValues, yValues, false );
}
//--------------------------------------------------------------------------------------------------
@ -100,7 +82,7 @@ int RimGridCrossPlotCurve::groupIndex() const
//--------------------------------------------------------------------------------------------------
size_t RimGridCrossPlotCurve::sampleCount() const
{
return m_qwtPlotCurve ? m_qwtPlotCurve->dataSize() : 0;
return m_plotCurve ? m_plotCurve->numSamples() : 0;
}
//--------------------------------------------------------------------------------------------------
@ -108,12 +90,12 @@ size_t RimGridCrossPlotCurve::sampleCount() const
//--------------------------------------------------------------------------------------------------
void RimGridCrossPlotCurve::determineLegendIcon()
{
if ( !m_qwtPlotCurve ) return;
if ( !m_plotCurve ) return;
RimGridCrossPlot* plot = nullptr;
firstAncestorOrThisOfTypeAsserted( plot );
int fontSize = plot->legendFontSize();
m_qwtPlotCurve->setLegendIconSize( QSize( fontSize, fontSize ) );
m_plotCurve->setLegendIconSize( QSize( fontSize, fontSize ) );
}
//--------------------------------------------------------------------------------------------------
@ -121,9 +103,9 @@ void RimGridCrossPlotCurve::determineLegendIcon()
//--------------------------------------------------------------------------------------------------
void RimGridCrossPlotCurve::setBlackAndWhiteLegendIcons( bool blackAndWhite )
{
if ( m_qwtPlotCurve )
if ( m_plotCurve )
{
m_qwtPlotCurve->setBlackAndWhiteLegendIcon( blackAndWhite );
m_plotCurve->setBlackAndWhiteLegendIcon( blackAndWhite );
}
}
@ -132,7 +114,7 @@ void RimGridCrossPlotCurve::setBlackAndWhiteLegendIcons( bool blackAndWhite )
//--------------------------------------------------------------------------------------------------
void RimGridCrossPlotCurve::determineSymbol()
{
RiuQwtSymbol::PointSymbolEnum symbol = RiuQwtSymbol::cycledSymbolStyle( m_dataSetIndex );
RiuPlotCurveSymbol::PointSymbolEnum symbol = RiuPlotCurveSymbol::cycledSymbolStyle( m_dataSetIndex );
setSymbol( symbol );
}
@ -146,20 +128,6 @@ void RimGridCrossPlotCurve::updateZoomInParentPlot()
plot->calculateZoomRangeAndUpdateQwt();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGridCrossPlotCurve::updateLegendsInPlot()
{
RimGridCrossPlot* plot = nullptr;
this->firstAncestorOrThisOfType( plot );
if ( plot )
{
plot->reattachAllCurves();
}
RimPlotCurve::updateLegendsInPlot();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -175,7 +143,7 @@ void RimGridCrossPlotCurve::onLoadDataAndUpdate( bool updateParentPlot )
{
if ( updateParentPlot )
{
m_parentQwtPlot->replot();
m_parentPlot->replot();
}
}

View File

@ -19,16 +19,6 @@
#include "RimPlotCurve.h"
#include "cafPdmChildField.h"
#include "cafPdmPtrField.h"
#include <QPointF>
#include <QVector>
class RimCase;
class RimEclipseResultDefinition;
class QwtPlotCurve;
//==================================================================================================
///
///
@ -52,7 +42,6 @@ public:
protected:
void determineSymbol();
void updateZoomInParentPlot() override;
void updateLegendsInPlot() override;
QString createCurveAutoName() override;
void onLoadDataAndUpdate( bool updateParentPlot ) override;
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;

View File

@ -34,6 +34,7 @@
#include "RiuDraggableOverlayFrame.h"
#include "RiuGridCrossQwtPlot.h"
#include "RiuPlotWidget.h"
#include "RiuScalarMapperLegendFrame.h"
#include "RimCase.h"
@ -62,6 +63,8 @@
#include "cvfScalarMapper.h"
#include "cvfqtUtils.h"
#include "qwt_plot.h"
#include <QString>
CAF_PDM_SOURCE_INIT( RimGridCrossPlotDataSet, "GridCrossPlotCurveSet" );
@ -196,11 +199,11 @@ void RimGridCrossPlotDataSet::loadDataAndUpdate( bool updateParentPlot )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGridCrossPlotDataSet::setParentQwtPlotNoReplot( QwtPlot* parent )
void RimGridCrossPlotDataSet::setParentPlotNoReplot( RiuPlotWidget* parent )
{
for ( auto& curve : m_crossPlotCurves() )
{
curve->setParentQwtPlotNoReplot( m_isChecked() ? parent : nullptr );
curve->setParentPlotNoReplot( m_isChecked() ? parent : nullptr );
}
}
@ -341,7 +344,7 @@ void RimGridCrossPlotDataSet::detachAllCurves()
{
for ( auto curve : m_crossPlotCurves() )
{
curve->detachQwtCurve();
curve->detach();
}
}
@ -652,8 +655,9 @@ void RimGridCrossPlotDataSet::fillCurveDataInExistingCurves( const RigEclipseCro
{
CVF_ASSERT( m_crossPlotCurves.size() == 1u );
RimGridCrossPlotCurve* curve = m_crossPlotCurves[0];
curve->setSamples( result.xValues, result.yValues );
curve->setGroupingInformation( indexInPlot(), 0 );
curve->updateCurveVisibility();
curve->setSamples( result.xValues, result.yValues );
curve->updateCurveAppearance();
curve->updateUiIconFromPlotSymbol();
}
@ -665,8 +669,9 @@ void RimGridCrossPlotDataSet::fillCurveDataInExistingCurves( const RigEclipseCro
for ( ; curveIt != m_crossPlotCurves.end() && groupIt != m_groupedResults.rend(); ++curveIt, ++groupIt )
{
RimGridCrossPlotCurve* curve = *curveIt;
curve->setSamples( groupIt->second.xValues, groupIt->second.yValues );
curve->setGroupingInformation( indexInPlot(), groupIt->first );
curve->updateCurveVisibility();
curve->setSamples( groupIt->second.xValues, groupIt->second.yValues );
curve->updateCurveAppearance();
curve->updateUiIconFromPlotSymbol();
}
@ -1009,7 +1014,7 @@ void RimGridCrossPlotDataSet::updateLegendRange()
RimGridCrossPlot* parent;
this->firstAncestorOrThisOfTypeAsserted( parent );
if ( parent->viewer() )
if ( parent->plotWidget() )
{
if ( groupingEnabled() && m_case() && isChecked() && legendConfig()->showLegend() )
{
@ -1050,17 +1055,17 @@ void RimGridCrossPlotDataSet::updateLegendRange()
}
if ( !m_legendOverlayFrame )
{
m_legendOverlayFrame =
new RiuDraggableOverlayFrame( parent->viewer()->canvas(), parent->viewer()->overlayMargins() );
m_legendOverlayFrame = new RiuDraggableOverlayFrame( parent->plotWidget()->getParentForOverlay(),
parent->plotWidget()->overlayMargins() );
}
m_legendOverlayFrame->setContentFrame( legendConfig()->makeLegendFrame() );
parent->viewer()->addOverlayFrame( m_legendOverlayFrame );
parent->plotWidget()->addOverlayFrame( m_legendOverlayFrame );
}
else
{
if ( m_legendOverlayFrame )
{
parent->viewer()->removeOverlayFrame( m_legendOverlayFrame );
parent->plotWidget()->removeOverlayFrame( m_legendOverlayFrame );
}
}
}

View File

@ -54,6 +54,7 @@ class RiuDraggableOverlayFrame;
class QwtPlot;
class QwtPlotCurve;
class QString;
class RiuPlotWidget;
class RimGridCrossPlotDataSetNameConfig : public RimNameConfig
{
@ -99,7 +100,7 @@ public:
void setCellFilterView( RimGridView* cellFilterView );
void loadDataAndUpdate( bool updateParentPlot );
void setParentQwtPlotNoReplot( QwtPlot* parent );
void setParentPlotNoReplot( RiuPlotWidget* parent );
QString xAxisName() const;
QString yAxisName() const;
QString infoText() const;

View File

@ -294,7 +294,7 @@ void RimDepthTrackPlot::updateZoom()
for ( RimPlot* plot : plots() )
{
static_cast<RimWellLogTrack*>( plot )->setVisibleYRange( m_minVisibleDepth(), m_maxVisibleDepth() );
plot->updateZoomInQwt();
plot->updateZoomInParentPlot();
}
if ( m_viewer )
@ -588,7 +588,7 @@ void RimDepthTrackPlot::recreatePlotWidgets()
for ( size_t tIdx = 0; tIdx < plotVector.size(); ++tIdx )
{
plotVector[tIdx]->createPlotWidget();
m_viewer->addPlot( plotVector[tIdx]->viewer() );
m_viewer->addPlot( plotVector[tIdx]->plotWidget() );
}
}
@ -1029,7 +1029,7 @@ void RimDepthTrackPlot::insertPlot( RimPlot* plot, size_t index )
if ( m_viewer )
{
plot->createPlotWidget();
m_viewer->insertPlot( plot->viewer(), index );
m_viewer->insertPlot( plot->plotWidget(), index );
}
plot->setShowWindow( true );
onPlotAdditionOrRemoval();
@ -1045,7 +1045,7 @@ void RimDepthTrackPlot::removePlot( RimPlot* plot )
{
if ( m_viewer )
{
m_viewer->removePlot( plot->viewer() );
m_viewer->removePlot( plot->plotWidget() );
}
m_plots.removeChildObject( plot );

View File

@ -22,6 +22,7 @@
#include "RiaDefines.h"
#include "RimAbstractPlotCollection.h"
#include "RimEnsembleWellLogStatistics.h"
#include "RimPlot.h"
#include "RimPlotWindow.h"
#include "RimWellLogPlotNameConfig.h"

View File

@ -378,7 +378,7 @@ void RimGridTimeHistoryCurve::updateZoomInParentPlot()
RimSummaryPlot* plot = nullptr;
firstAncestorOrThisOfType( plot );
plot->updateZoomInQwt();
plot->updateZoomInParentPlot();
}
//--------------------------------------------------------------------------------------------------
@ -415,11 +415,11 @@ void RimGridTimeHistoryCurve::onLoadDataAndUpdate( bool updateParentPlot )
std::vector<time_t> dateTimes = timeStepValues();
if ( dateTimes.size() > 0 && dateTimes.size() == values.size() )
{
m_qwtPlotCurve->setSamplesFromTimeTAndYValues( dateTimes, values, isLogCurve );
m_plotCurve->setSamplesFromTimeTAndYValues( dateTimes, values, isLogCurve );
}
else
{
m_qwtPlotCurve->setSamplesFromTimeTAndYValues( std::vector<time_t>(), std::vector<double>(), isLogCurve );
m_plotCurve->setSamplesFromTimeTAndYValues( std::vector<time_t>(), std::vector<double>(), isLogCurve );
}
}
else
@ -435,17 +435,17 @@ void RimGridTimeHistoryCurve::onLoadDataAndUpdate( bool updateParentPlot )
times.push_back( timeScale * day );
}
m_qwtPlotCurve->setSamplesFromXValuesAndYValues( times, values, isLogCurve );
m_plotCurve->setSamplesFromXValuesAndYValues( times, values, isLogCurve );
}
else
{
m_qwtPlotCurve->setSamplesFromTimeTAndYValues( std::vector<time_t>(), std::vector<double>(), isLogCurve );
m_plotCurve->setSamplesFromTimeTAndYValues( std::vector<time_t>(), std::vector<double>(), isLogCurve );
}
}
updateZoomInParentPlot();
if ( m_parentQwtPlot ) m_parentQwtPlot->replot();
if ( m_parentPlot ) m_parentPlot->replot();
updateQwtPlotAxis();
plot->updateAxes();
@ -708,17 +708,7 @@ QString RimGridTimeHistoryCurve::geometrySelectionText() const
//--------------------------------------------------------------------------------------------------
void RimGridTimeHistoryCurve::updateQwtPlotAxis()
{
if ( m_qwtPlotCurve )
{
if ( this->yAxis() == RiaDefines::PlotAxis::PLOT_AXIS_LEFT )
{
m_qwtPlotCurve->setYAxis( QwtPlot::yLeft );
}
else
{
m_qwtPlotCurve->setYAxis( QwtPlot::yRight );
}
}
if ( m_plotCurve ) updateAxisInPlot( yAxis() );
}
//--------------------------------------------------------------------------------------------------

View File

@ -100,6 +100,7 @@ void RimMdiWindowController::removeWindowFromMDI()
if ( mainWin && viewWidget() )
{
mainWin->removeViewer( viewWidget() );
viewPdmObject()->deleteViewWidget();
}
}

View File

@ -197,7 +197,7 @@ void RimMultiPlot::insertPlot( RimPlot* plot, size_t index )
if ( m_viewer )
{
plot->createPlotWidget();
m_viewer->insertPlot( plot->viewer(), index );
m_viewer->insertPlot( plot->plotWidget(), index );
}
plot->setShowWindow( true );
plot->updateAfterInsertingIntoMultiPlot();
@ -215,7 +215,7 @@ void RimMultiPlot::removePlot( RimPlot* plot )
{
if ( m_viewer )
{
m_viewer->removePlot( plot->viewer() );
m_viewer->removePlot( plot->plotWidget() );
}
m_plots.removeChildObject( plot );
@ -273,7 +273,7 @@ void RimMultiPlot::insertPlots( const std::vector<RimPlot*>& plots )
if ( m_viewer )
{
plot->createPlotWidget();
m_viewer->insertPlot( plot->viewer(), -1 );
m_viewer->insertPlot( plot->plotWidget(), -1 );
}
plot->setShowWindow( true );
plot->updateAfterInsertingIntoMultiPlot();
@ -291,7 +291,7 @@ void RimMultiPlot::deleteAllPlots()
{
if ( plot && m_viewer )
{
m_viewer->removePlot( plot->viewer() );
m_viewer->removePlot( plot->plotWidget() );
}
}
@ -391,8 +391,8 @@ void RimMultiPlot::doRenderWindowContent( QPaintDevice* paintDevice )
void RimMultiPlot::updatePlotOrderFromGridWidget()
{
std::sort( m_plots.begin(), m_plots.end(), [this]( RimPlot* lhs, RimPlot* rhs ) {
auto indexLhs = m_viewer->indexOfPlotWidget( lhs->viewer() );
auto indexRhs = m_viewer->indexOfPlotWidget( rhs->viewer() );
auto indexLhs = m_viewer->indexOfPlotWidget( lhs->plotWidget() );
auto indexRhs = m_viewer->indexOfPlotWidget( rhs->plotWidget() );
return indexLhs < indexRhs;
} );
updateSubPlotNames();
@ -877,7 +877,7 @@ void RimMultiPlot::updateZoom()
{
for ( RimPlot* plot : plots() )
{
plot->updateZoomInQwt();
plot->updateZoomInParentPlot();
}
}
@ -895,7 +895,7 @@ void RimMultiPlot::recreatePlotWidgets()
for ( size_t tIdx = 0; tIdx < plotVector.size(); ++tIdx )
{
plotVector[tIdx]->createPlotWidget();
m_viewer->addPlot( plotVector[tIdx]->viewer() );
m_viewer->addPlot( plotVector[tIdx]->plotWidget() );
}
}

View File

@ -19,6 +19,7 @@
#pragma once
#include "RimAbstractPlotCollection.h"
#include "RimPlot.h"
#include "RimPlotAxisPropertiesInterface.h"
#include "RimPlotWindow.h"

View File

@ -26,12 +26,10 @@
#include "RimPlotWindow.h"
#include "RiuPlotMainWindowTools.h"
#include "RiuQwtPlotWidget.h"
#include "RiuPlotWidget.h"
#include "cafPdmObject.h"
#include "qwt_plot_curve.h"
namespace caf
{
template <>
@ -73,9 +71,7 @@ RimPlot::~RimPlot()
//--------------------------------------------------------------------------------------------------
QWidget* RimPlot::createViewWidget( QWidget* parent /*= nullptr */ )
{
RiuQwtPlotWidget* plotWidget = doCreatePlotViewWidget( parent );
RimPlot::attachPlotWidgetSignals( this, plotWidget );
RiuPlotWidget* plotWidget = doCreatePlotViewWidget( parent );
updateWindowVisibility();
plotWidget->scheduleReplot();
@ -88,10 +84,10 @@ QWidget* RimPlot::createViewWidget( QWidget* parent /*= nullptr */ )
//--------------------------------------------------------------------------------------------------
void RimPlot::updateFonts()
{
if ( viewer() )
if ( plotWidget() )
{
viewer()->setPlotTitleFontSize( titleFontSize() );
viewer()->setLegendFontSize( legendFontSize() );
plotWidget()->setPlotTitleFontSize( titleFontSize() );
plotWidget()->setLegendFontSize( legendFontSize() );
}
}
@ -195,30 +191,14 @@ void RimPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const Q
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlot::attachPlotWidgetSignals( RimPlot* plot, RiuQwtPlotWidget* plotWidget )
{
CAF_ASSERT( plot && plotWidget );
plot->connect( plotWidget, SIGNAL( plotSelected( bool ) ), SLOT( onPlotSelected( bool ) ) );
plot->connect( plotWidget, SIGNAL( axisSelected( int, bool ) ), SLOT( onAxisSelected( int, bool ) ) );
plot->connect( plotWidget,
SIGNAL( plotItemSelected( QwtPlotItem*, bool, int ) ),
SLOT( onPlotItemSelected( QwtPlotItem*, bool, int ) ) );
plot->connect( plotWidget, SIGNAL( onKeyPressEvent( QKeyEvent* ) ), SLOT( onKeyPressEvent( QKeyEvent* ) ) );
plot->connect( plotWidget, SIGNAL( onWheelEvent( QWheelEvent* ) ), SLOT( onWheelEvent( QWheelEvent* ) ) );
plot->connect( plotWidget, SIGNAL( destroyed() ), SLOT( onViewerDestroyed() ) );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlot::doRenderWindowContent( QPaintDevice* paintDevice )
{
if ( viewer() )
if ( plotWidget() )
{
viewer()->renderTo( paintDevice, viewer()->frameGeometry() );
plotWidget()->renderTo( paintDevice, plotWidget()->frameGeometry() );
}
}
@ -237,29 +217,6 @@ void RimPlot::onPlotSelected( bool toggle )
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlot::onPlotItemSelected( QwtPlotItem* plotItem, bool toggle, int sampleIndex )
{
QwtPlotCurve* curve = dynamic_cast<QwtPlotCurve*>( plotItem );
if ( curve )
{
RimPlotCurve* selectedCurve = dynamic_cast<RimPlotCurve*>( this->findPdmObjectFromQwtCurve( curve ) );
if ( selectedCurve )
{
if ( toggle )
{
RiuPlotMainWindowTools::toggleItemInSelection( selectedCurve );
}
else
{
RiuPlotMainWindowTools::selectAsCurrentItem( selectedCurve );
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -302,3 +259,45 @@ void RimPlot::onChildDeleted( caf::PdmChildArrayFieldHandle* childArray,
{
loadDataAndUpdate();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlot::updateZoomInParentPlot()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlot::updateZoomFromParentPlot()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlot::handleKeyPressEvent( QKeyEvent* event )
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlot::handleWheelEvent( QWheelEvent* event )
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlot::onPlotItemSelected( std::shared_ptr<RiuPlotItem>, bool, int )
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlot::onAxisSelected( int axis, bool toggle )
{
}

View File

@ -30,13 +30,11 @@
#include <QObject>
#include <QPointer>
class RiuQwtPlotWidget;
class RimPlotCurve;
class QwtPlotCurve;
class QwtPlotItem;
class QPaintDevice;
class QWheelEvent;
class RiuPlotWidget;
class RiuPlotCurve;
class RiuPlotItem;
//==================================================================================================
///
@ -73,21 +71,16 @@ public:
void updateAfterInsertingIntoMultiPlot();
// Pure virtual interface methods
virtual RiuQwtPlotWidget* viewer() = 0;
virtual void setAutoScaleXEnabled( bool enabled ) = 0;
virtual void setAutoScaleYEnabled( bool enabled ) = 0;
virtual void updateAxes() = 0;
virtual void updateLegend() = 0;
virtual void updateZoomInQwt() = 0;
virtual void updateZoomFromQwt() = 0;
virtual void updateLegend() = 0;
virtual QString asciiDataForPlotExport() const = 0;
virtual void reattachAllCurves() = 0;
virtual void detachAllCurves() = 0;
virtual caf::PdmObject* findPdmObjectFromQwtCurve( const QwtPlotCurve* curve ) const = 0;
virtual void reattachAllCurves() = 0;
virtual void detachAllCurves() = 0;
void onChildDeleted( caf::PdmChildArrayFieldHandle* childArray,
std::vector<caf::PdmObjectHandle*>& referringObjects ) override;
@ -100,25 +93,31 @@ public:
return parentPlotWindow != nullptr;
}
virtual RiuPlotWidget* plotWidget() = 0;
virtual void updateZoomInParentPlot();
virtual void updateZoomFromParentPlot();
virtual caf::PdmObject* findPdmObjectFromPlotCurve( const RiuPlotCurve* curve ) const { return nullptr; };
protected:
virtual RiuPlotWidget* doCreatePlotViewWidget( QWidget* parent ) = 0;
QWidget* createViewWidget( QWidget* parent = nullptr ) override;
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
static void attachPlotWidgetSignals( RimPlot* plot, RiuQwtPlotWidget* plotWidget );
QWidget* createViewWidget( QWidget* parent = nullptr ) final;
void updateFonts() override;
void doRenderWindowContent( QPaintDevice* paintDevice ) override;
private:
void doRenderWindowContent( QPaintDevice* paintDevice ) override;
virtual void handleKeyPressEvent( QKeyEvent* event ) {}
virtual void handleWheelEvent( QWheelEvent* event ) {}
virtual RiuQwtPlotWidget* doCreatePlotViewWidget( QWidget* parent ) = 0;
virtual void handleKeyPressEvent( QKeyEvent* event );
virtual void handleWheelEvent( QWheelEvent* event );
private slots:
virtual void onAxisSelected( int axis, bool toggle );
virtual void onPlotItemSelected( std::shared_ptr<RiuPlotItem> selectedItem, bool toggleItem, int sampleIndex );
void onPlotSelected( bool toggle );
virtual void onAxisSelected( int axis, bool toggle ) {}
virtual void onPlotItemSelected( QwtPlotItem* plotItem, bool toggle, int sampleIndex );
void onViewerDestroyed();
void onKeyPressEvent( QKeyEvent* event );
void onWheelEvent( QWheelEvent* event );

View File

@ -0,0 +1,116 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2022- 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 "RimPlotAxisLogRangeCalculator.h"
#include "RiaPlotDefines.h"
#include "RimPlotCurve.h"
#include "cvfVector2.h"
#include <cmath>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimPlotAxisLogRangeCalculator::RimPlotAxisLogRangeCalculator( RiaDefines::PlotAxis axis,
const std::vector<const RimPlotCurve*>& curves )
: m_axis( axis )
, m_curves( curves )
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotAxisLogRangeCalculator::computeAxisRange( double* minPositive, double* max ) const
{
double minPosValue = HUGE_VAL;
double maxValue = -HUGE_VAL;
for ( const RimPlotCurve* curve : m_curves )
{
double minPosCurveValue = HUGE_VAL;
double maxCurveValue = -HUGE_VAL;
if ( curveValueRange( curve, &minPosCurveValue, &maxCurveValue ) )
{
if ( minPosCurveValue < minPosValue )
{
CVF_ASSERT( minPosCurveValue > 0.0 );
minPosValue = minPosCurveValue;
}
if ( maxCurveValue > maxValue )
{
maxValue = maxCurveValue;
}
}
}
if ( minPosValue == HUGE_VAL )
{
minPosValue = RiaDefines::minimumDefaultLogValuePlot();
maxValue = RiaDefines::maximumDefaultValuePlot();
}
*minPositive = minPosValue;
*max = maxValue;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimPlotAxisLogRangeCalculator::curveValueRange( const RimPlotCurve* curve, double* minPositive, double* max ) const
{
if ( !curve ) return false;
if ( curve->dataSize() < 1 )
{
return false;
}
float minPosF = std::numeric_limits<float>::infinity();
float maxF = -std::numeric_limits<float>::infinity();
int axisValueIndex = 0;
if ( RiaDefines::isVertical( m_axis ) )
{
axisValueIndex = 1;
}
for ( int i = 0; i < curve->dataSize(); ++i )
{
auto [x, y] = curve->sample( i );
cvf::Vec2f vec( x, y );
float value = vec[axisValueIndex];
if ( value == HUGE_VALF ) continue;
maxF = std::max( maxF, value );
if ( value > 0.0f && value < minPosF )
{
minPosF = value;
}
}
*minPositive = minPosF;
*max = maxF;
return true;
}

View File

@ -0,0 +1,44 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2022- 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 "RiaPlotDefines.h"
#include <vector>
class RimPlotCurve;
//==================================================================================================
///
///
//==================================================================================================
class RimPlotAxisLogRangeCalculator
{
public:
RimPlotAxisLogRangeCalculator( RiaDefines::PlotAxis axis, const std::vector<const RimPlotCurve*>& curves );
void computeAxisRange( double* minPositive, double* max ) const;
private:
bool curveValueRange( const RimPlotCurve* curve, double* minPositive, double* max ) const;
private:
RiaDefines::PlotAxis m_axis;
const std::vector<const RimPlotCurve*> m_curves;
};

View File

@ -19,13 +19,9 @@
#include "RimPlotAxisProperties.h"
#include "RiaApplication.h"
#include "RiaDefines.h"
#include "RiaFontCache.h"
#include "RiaPreferences.h"
#include "RigStatisticsCalculator.h"
#include "RimPlot.h"
#include "RimPlotAxisAnnotation.h"
#include "cafPdmUiSliderEditor.h"
@ -34,74 +30,67 @@
#include <cmath>
#include <qwt_plot_curve.h>
// clang-format off
namespace caf
{
template<>
template <>
void caf::AppEnum<RimPlotAxisProperties::NumberFormatType>::setUp()
{
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");
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(RimPlotAxisProperties::NUMBER_FORMAT_AUTO);
setDefault( RimPlotAxisProperties::NUMBER_FORMAT_AUTO );
}
} // namespace caf
CAF_PDM_SOURCE_INIT(RimPlotAxisProperties, "SummaryYAxisProperties");
CAF_PDM_SOURCE_INIT( RimPlotAxisProperties, "SummaryYAxisProperties" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimPlotAxisProperties::RimPlotAxisProperties()
: settingsChanged(this)
, logarithmicChanged(this)
, m_enableTitleTextSettings(true)
, m_isRangeSettingsEnabled(true)
: settingsChanged( this )
, logarithmicChanged( this )
, m_enableTitleTextSettings( true )
, m_isRangeSettingsEnabled( true )
{
CAF_PDM_InitObject("Axis Properties", ":/LeftAxis16x16.png");
CAF_PDM_InitObject( "Axis Properties", ":/LeftAxis16x16.png" );
CAF_PDM_InitField(&m_isActive, "Active", true, "Active");
m_isActive.uiCapability()->setUiHidden(true);
CAF_PDM_InitField( &m_isActive, "Active", true, "Active" );
m_isActive.uiCapability()->setUiHidden( true );
CAF_PDM_InitFieldNoDefault(&m_name, "Name", "Name");
m_name.uiCapability()->setUiHidden(true);
CAF_PDM_InitFieldNoDefault( &m_name, "Name", "Name" );
m_name.uiCapability()->setUiHidden( true );
CAF_PDM_InitField(&isAutoTitle, "AutoTitle", true, "Auto Title");
CAF_PDM_InitField( &isAutoTitle, "AutoTitle", true, "Auto Title" );
CAF_PDM_InitField(&m_displayLongName, "DisplayLongName", true, " Names");
CAF_PDM_InitField(&m_displayShortName, "DisplayShortName", false, " Acronyms");
CAF_PDM_InitField(&m_displayUnitText, "DisplayUnitText", true, " Units");
CAF_PDM_InitField( &m_displayLongName, "DisplayLongName", true, " Names" );
CAF_PDM_InitField( &m_displayShortName, "DisplayShortName", false, " Acronyms" );
CAF_PDM_InitField( &m_displayUnitText, "DisplayUnitText", true, " Units" );
CAF_PDM_InitFieldNoDefault(&customTitle, "CustomTitle", "Title");
CAF_PDM_InitFieldNoDefault( &customTitle, "CustomTitle", "Title" );
CAF_PDM_InitField(&visibleRangeMax, "VisibleRangeMax", RiaDefines::maximumDefaultValuePlot(), "Max");
CAF_PDM_InitField(&visibleRangeMin, "VisibleRangeMin", RiaDefines::minimumDefaultValuePlot(), "Min");
CAF_PDM_InitField( &visibleRangeMax, "VisibleRangeMax", RiaDefines::maximumDefaultValuePlot(), "Max" );
CAF_PDM_InitField( &visibleRangeMin, "VisibleRangeMin", RiaDefines::minimumDefaultValuePlot(), "Min" );
CAF_PDM_InitFieldNoDefault(&numberFormat, "NumberFormat", "Number Format");
CAF_PDM_InitField(&numberOfDecimals, "Decimals", 2, "Number of Decimals");
CAF_PDM_InitField(&scaleFactor, "ScaleFactor", 1.0, "Scale Factor");
CAF_PDM_InitFieldNoDefault( &numberFormat, "NumberFormat", "Number Format" );
CAF_PDM_InitField( &numberOfDecimals, "Decimals", 2, "Number of Decimals" );
CAF_PDM_InitField( &scaleFactor, "ScaleFactor", 1.0, "Scale Factor" );
numberOfDecimals.uiCapability()->setUiEditorTypeName(caf::PdmUiSliderEditor::uiEditorTypeName());
CAF_PDM_InitField( &m_isAutoZoom, "AutoZoom", true, "Set Range Automatically" );
CAF_PDM_InitField( &isLogarithmicScaleEnabled, "LogarithmicScale", false, "Logarithmic Scale" );
CAF_PDM_InitField( &m_isAxisInverted, "AxisInverted", false, "Invert Axis" );
CAF_PDM_InitField(&m_isAutoZoom, "AutoZoom", true, "Set Range Automatically");
CAF_PDM_InitField(&isLogarithmicScaleEnabled, "LogarithmicScale", false, "Logarithmic Scale");
CAF_PDM_InitField(&m_isAxisInverted, "AxisInverted", false, "Invert Axis");
CAF_PDM_InitFieldNoDefault( &m_titlePositionEnum, "TitlePosition", "Title Position" );
CAF_PDM_InitFieldNoDefault(&m_titlePositionEnum, "TitlePosition", "Title Position");
CAF_PDM_InitFieldNoDefault( &m_titleFontSize, "TitleDeltaFontSize", "Font Size" );
CAF_PDM_InitFieldNoDefault( &m_valuesFontSize, "ValueDeltaFontSize", "Font Size" );
CAF_PDM_InitFieldNoDefault(&m_titleFontSize, "TitleDeltaFontSize", "Font Size");
CAF_PDM_InitFieldNoDefault(&m_valuesFontSize, "ValueDeltaFontSize", "Font Size");
CAF_PDM_InitFieldNoDefault(&m_annotations, "Annotations", "");
m_annotations.uiCapability()->setUiTreeHidden(true);
// m_annotations.uiCapability()->setUiTreeChildrenHidden(true);
CAF_PDM_InitFieldNoDefault( &m_annotations, "Annotations", "" );
m_annotations.uiCapability()->setUiTreeHidden( true );
updateOptionSensitivity();
}
// clang-format on
//--------------------------------------------------------------------------------------------------
///
@ -212,13 +201,13 @@ void RimPlotAxisProperties::defineUiOrdering( QString uiConfigName, caf::PdmUiOr
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotAxisProperties::setNameAndAxis( const QString& name, QwtPlot::Axis axis )
void RimPlotAxisProperties::setNameAndAxis( const QString& name, RiaDefines::PlotAxis axis )
{
m_name = name;
m_axis = axis;
if ( axis == QwtPlot::yRight ) this->setUiIconFromResourceString( ":/RightAxis16x16.png" );
if ( axis == QwtPlot::xBottom ) this->setUiIconFromResourceString( ":/BottomAxis16x16.png" );
if ( axis == RiaDefines::PlotAxis::PLOT_AXIS_RIGHT ) this->setUiIconFromResourceString( ":/RightAxis16x16.png" );
if ( axis == RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM ) this->setUiIconFromResourceString( ":/BottomAxis16x16.png" );
}
//--------------------------------------------------------------------------------------------------
@ -245,14 +234,6 @@ int RimPlotAxisProperties::valuesFontSize() const
return caf::FontTools::absolutePointSize( plotFontSize(), m_valuesFontSize() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QwtPlot::Axis RimPlotAxisProperties::qwtPlotAxisType() const
{
return m_axis;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -266,10 +247,7 @@ QString RimPlotAxisProperties::name() const
//--------------------------------------------------------------------------------------------------
RiaDefines::PlotAxis RimPlotAxisProperties::plotAxisType() const
{
if ( m_axis == QwtPlot::yRight ) return RiaDefines::PlotAxis::PLOT_AXIS_RIGHT;
if ( m_axis == QwtPlot::xBottom ) return RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM;
return RiaDefines::PlotAxis::PLOT_AXIS_LEFT;
return m_axis;
}
//--------------------------------------------------------------------------------------------------
@ -449,92 +427,3 @@ caf::PdmFieldHandle* RimPlotAxisProperties::objectToggleField()
{
return &m_isActive;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimPlotAxisLogRangeCalculator::RimPlotAxisLogRangeCalculator( QwtPlot::Axis axis,
const std::vector<const QwtPlotCurve*>& qwtCurves )
: m_axis( axis )
, m_curves( qwtCurves )
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotAxisLogRangeCalculator::computeAxisRange( double* minPositive, double* max ) const
{
double minPosValue = HUGE_VAL;
double maxValue = -HUGE_VAL;
for ( const QwtPlotCurve* curve : m_curves )
{
double minPosCurveValue = HUGE_VAL;
double maxCurveValue = -HUGE_VAL;
if ( curveValueRange( curve, &minPosCurveValue, &maxCurveValue ) )
{
if ( minPosCurveValue < minPosValue )
{
CVF_ASSERT( minPosCurveValue > 0.0 );
minPosValue = minPosCurveValue;
}
if ( maxCurveValue > maxValue )
{
maxValue = maxCurveValue;
}
}
}
if ( minPosValue == HUGE_VAL )
{
minPosValue = RiaDefines::minimumDefaultLogValuePlot();
maxValue = RiaDefines::maximumDefaultValuePlot();
}
*minPositive = minPosValue;
*max = maxValue;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimPlotAxisLogRangeCalculator::curveValueRange( const QwtPlotCurve* qwtCurve, double* minPositive, double* max ) const
{
if ( !qwtCurve ) return false;
if ( qwtCurve->data()->size() < 1 )
{
return false;
}
float minPosF = std::numeric_limits<float>::infinity();
float maxF = -std::numeric_limits<float>::infinity();
int axisValueIndex = 0;
if ( m_axis == QwtPlot::yLeft || m_axis == QwtPlot::yRight )
{
axisValueIndex = 1;
}
for ( size_t i = 0; i < qwtCurve->dataSize(); ++i )
{
QPointF sample = qwtCurve->sample( (int)i );
cvf::Vec2f vec( sample.x(), sample.y() );
float value = vec[axisValueIndex];
if ( value == HUGE_VALF ) continue;
maxF = std::max( maxF, value );
if ( value > 0.0f && value < minPosF )
{
minPosF = value;
}
}
*minPositive = minPosF;
*max = maxF;
return true;
}

View File

@ -28,8 +28,6 @@
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "qwt_plot.h"
#include <QString>
class RimPlotAxisAnnotation;
@ -59,13 +57,12 @@ public:
void setEnableTitleTextSettings( bool enable );
void enableRangeSettings( bool enable );
void setNameAndAxis( const QString& name, QwtPlot::Axis axis );
void setNameAndAxis( const QString& name, RiaDefines::PlotAxis axis );
AxisTitlePositionType titlePosition() const override;
int titleFontSize() const override;
int valuesFontSize() const override;
QwtPlot::Axis qwtPlotAxisType() const;
QString name() const;
RiaDefines::PlotAxis plotAxisType() const override;
bool useAutoTitle() const;
@ -121,7 +118,7 @@ private:
caf::PdmField<bool> m_isAxisInverted;
caf::PdmField<QString> m_name;
QwtPlot::Axis m_axis;
RiaDefines::PlotAxis m_axis;
bool m_enableTitleTextSettings;
bool m_isRangeSettingsEnabled;
@ -131,24 +128,3 @@ private:
caf::PdmField<caf::FontTools::RelativeSizeEnum> m_valuesFontSize;
caf::PdmChildArrayField<RimPlotAxisAnnotation*> m_annotations;
};
class QwtPlotCurve;
//==================================================================================================
///
///
//==================================================================================================
class RimPlotAxisLogRangeCalculator
{
public:
RimPlotAxisLogRangeCalculator( QwtPlot::Axis axis, const std::vector<const QwtPlotCurve*>& qwtCurves );
void computeAxisRange( double* minPositive, double* max ) const;
private:
bool curveValueRange( const QwtPlotCurve* qwtCurve, double* minPositive, double* max ) const;
private:
QwtPlot::Axis m_axis;
const std::vector<const QwtPlotCurve*> m_curves;
};

View File

@ -18,7 +18,7 @@
#pragma once
#include "RiaDefines.h"
#include "RiaPlotDefines.h"
#include "cafAppEnum.h"

View File

@ -18,7 +18,6 @@
#include "RimPlotCurve.h"
#include "RiaColorTables.h"
#include "RiaColorTools.h"
#include "RiaCurveDataTools.h"
#include "RiaGuiApplication.h"
@ -33,23 +32,19 @@
#include "RimSummaryCurveCollection.h"
#include "RimSummaryPlot.h"
#include "RiuPlotCurve.h"
#include "RiuPlotCurveSymbol.h"
#include "RiuPlotMainWindowTools.h"
#include "RiuRimQwtPlotCurve.h"
#include "RiuPlotWidget.h"
#include "cafAssert.h"
#include "cafPdmUiComboBoxEditor.h"
#include "cvfAssert.h"
#include "qwt_date.h"
#include "qwt_interval_symbol.h"
#include "qwt_plot.h"
#include "qwt_symbol.h"
#include <QPen>
// NB! Special macro for pure virtual class
CAF_PDM_XML_ABSTRACT_SOURCE_INIT( RimPlotCurve, "PlotCurve" );
#define DOUBLE_INF std::numeric_limits<double>::infinity()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -125,14 +120,8 @@ RimPlotCurve::RimPlotCurve()
m_curveAppearance->appearanceChanged.connect( this, &RimPlotCurve::onCurveAppearanceChanged );
m_curveAppearance->appearanceChanged.connect( this, &RimPlotCurve::onFillColorChanged );
m_qwtPlotCurve = new RiuRimQwtPlotCurve( this );
m_qwtCurveErrorBars = new QwtPlotIntervalCurve();
m_qwtCurveErrorBars->setStyle( QwtPlotIntervalCurve::CurveStyle::NoCurve );
m_qwtCurveErrorBars->setSymbol( new QwtIntervalSymbol( QwtIntervalSymbol::Bar ) );
m_qwtCurveErrorBars->setItemAttribute( QwtPlotItem::Legend, false );
m_qwtCurveErrorBars->setZ( RiuQwtPlotCurveDefines::zDepthForIndex( RiuQwtPlotCurveDefines::ZIndex::Z_ERROR_BARS ) );
m_parentQwtPlot = nullptr;
m_plotCurve = nullptr;
m_parentPlot = nullptr;
}
//--------------------------------------------------------------------------------------------------
@ -140,18 +129,11 @@ RimPlotCurve::RimPlotCurve()
//--------------------------------------------------------------------------------------------------
RimPlotCurve::~RimPlotCurve()
{
if ( m_qwtPlotCurve )
if ( m_plotCurve )
{
m_qwtPlotCurve->detach();
delete m_qwtPlotCurve;
m_qwtPlotCurve = nullptr;
}
if ( m_qwtCurveErrorBars )
{
m_qwtCurveErrorBars->detach();
delete m_qwtCurveErrorBars;
m_qwtCurveErrorBars = nullptr;
detach();
delete m_plotCurve;
m_plotCurve = nullptr;
}
}
@ -191,7 +173,7 @@ void RimPlotCurve::fieldChangedByUi( const caf::PdmFieldHandle* changedField, co
}
RiuPlotMainWindowTools::refreshToolbars();
if ( m_parentQwtPlot ) m_parentQwtPlot->replot();
replotParentPlot();
}
//--------------------------------------------------------------------------------------------------
@ -237,22 +219,7 @@ void RimPlotCurve::setLegendEntryText( const QString& legendEntryText )
void RimPlotCurve::setErrorBarsVisible( bool isVisible )
{
m_showErrorBars = isVisible;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotCurve::updateCurveVisibility()
{
if ( canCurveBeAttached() )
{
attachCurveAndErrorBars();
}
else
{
m_qwtPlotCurve->detach();
m_qwtCurveErrorBars->detach();
}
updateCurveAppearance();
}
//--------------------------------------------------------------------------------------------------
@ -286,37 +253,6 @@ void RimPlotCurve::updateCurvePresentation( bool updatePlotLegendAndTitle )
updateCurveAppearance();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotCurve::setParentQwtPlotAndReplot( QwtPlot* plot )
{
m_parentQwtPlot = plot;
if ( canCurveBeAttached() )
{
attachCurveAndErrorBars();
m_parentQwtPlot->replot();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotCurve::setParentQwtPlotNoReplot( QwtPlot* plot )
{
m_parentQwtPlot = plot;
if ( canCurveBeAttached() )
{
attachCurveAndErrorBars();
}
else
{
m_qwtPlotCurve->detach();
m_qwtCurveErrorBars->detach();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -342,35 +278,6 @@ cvf::Color3f RimPlotCurve::color() const
return m_curveAppearance->color();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotCurve::detachQwtCurve()
{
m_qwtPlotCurve->detach();
m_qwtCurveErrorBars->detach();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotCurve::reattachQwtCurve()
{
detachQwtCurve();
if ( canCurveBeAttached() )
{
attachCurveAndErrorBars();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QwtPlotCurve* RimPlotCurve::qwtPlotCurve() const
{
return m_qwtPlotCurve;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -401,16 +308,13 @@ void RimPlotCurve::updateCurveName()
m_curveName = m_customCurveName;
}
if ( m_qwtPlotCurve )
if ( !m_legendEntryText().isEmpty() )
{
if ( !m_legendEntryText().isEmpty() )
{
m_qwtPlotCurve->setTitle( m_legendEntryText );
}
else
{
m_qwtPlotCurve->setTitle( m_curveName );
}
setTitle( m_legendEntryText );
}
else
{
setTitle( m_curveName );
}
}
@ -453,126 +357,6 @@ void RimPlotCurve::updatePlotTitle()
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotCurve::updateLegendsInPlot()
{
nameChanged.send( curveName() );
if ( m_parentQwtPlot != nullptr )
{
m_parentQwtPlot->updateLegend();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotCurve::setSamplesFromXYErrorValues(
const std::vector<double>& xValues,
const std::vector<double>& yValues,
const std::vector<double>& errorValues,
bool keepOnlyPositiveValues,
RiaCurveDataTools::ErrorAxis errorAxis /*= RiuQwtPlotCurve::ERROR_ALONG_Y_AXIS */ )
{
CVF_ASSERT( xValues.size() == yValues.size() );
CVF_ASSERT( xValues.size() == errorValues.size() );
auto intervalsOfValidValues = RiaCurveDataTools::calculateIntervalsOfValidValues( yValues, keepOnlyPositiveValues );
std::vector<double> filteredYValues;
std::vector<double> filteredXValues;
RiaCurveDataTools::getValuesByIntervals( yValues, intervalsOfValidValues, &filteredYValues );
RiaCurveDataTools::getValuesByIntervals( xValues, intervalsOfValidValues, &filteredXValues );
std::vector<double> filteredErrorValues;
RiaCurveDataTools::getValuesByIntervals( errorValues, intervalsOfValidValues, &filteredErrorValues );
QVector<QwtIntervalSample> errorIntervals;
errorIntervals.reserve( static_cast<int>( filteredXValues.size() ) );
for ( size_t i = 0; i < filteredXValues.size(); i++ )
{
if ( filteredYValues[i] != DOUBLE_INF && filteredErrorValues[i] != DOUBLE_INF )
{
if ( errorAxis == RiaCurveDataTools::ErrorAxis::ERROR_ALONG_Y_AXIS )
{
errorIntervals << QwtIntervalSample( filteredXValues[i],
filteredYValues[i] - filteredErrorValues[i],
filteredYValues[i] + filteredErrorValues[i] );
}
else
{
errorIntervals << QwtIntervalSample( filteredYValues[i],
filteredXValues[i] - filteredErrorValues[i],
filteredXValues[i] + filteredErrorValues[i] );
}
}
}
if ( m_qwtPlotCurve )
{
m_qwtPlotCurve->setSamples( filteredXValues.data(),
filteredYValues.data(),
static_cast<int>( filteredXValues.size() ) );
m_qwtPlotCurve->setLineSegmentStartStopIndices( intervalsOfValidValues );
}
if ( m_qwtCurveErrorBars )
{
m_qwtCurveErrorBars->setSamples( errorIntervals );
if ( errorAxis == RiaCurveDataTools::ErrorAxis::ERROR_ALONG_Y_AXIS )
{
m_qwtCurveErrorBars->setOrientation( Qt::Vertical );
}
else
{
m_qwtCurveErrorBars->setOrientation( Qt::Horizontal );
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotCurve::setSamplesFromXYValues( const std::vector<double>& xValues,
const std::vector<double>& yValues,
bool keepOnlyPositiveValues )
{
if ( m_qwtPlotCurve )
{
m_qwtPlotCurve->setSamplesFromXValuesAndYValues( xValues, yValues, keepOnlyPositiveValues );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotCurve::setSamplesFromDatesAndYValues( const std::vector<QDateTime>& dateTimes,
const std::vector<double>& yValues,
bool keepOnlyPositiveValues )
{
if ( m_qwtPlotCurve )
{
m_qwtPlotCurve->setSamplesFromDatesAndYValues( dateTimes, yValues, keepOnlyPositiveValues );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotCurve::setSamplesFromTimeTAndYValues( const std::vector<time_t>& dateTimes,
const std::vector<double>& yValues,
bool keepOnlyPositiveValues )
{
if ( m_qwtPlotCurve )
{
m_qwtPlotCurve->setSamplesFromTimeTAndYValues( dateTimes, yValues, keepOnlyPositiveValues );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -591,21 +375,6 @@ void RimPlotCurve::curveNameUiOrdering( caf::PdmUiOrdering& uiOrdering )
uiOrdering.add( &m_curveName );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotCurve::updateUiIconFromPlotSymbol()
{
if ( m_curveAppearance->symbol() != RiuQwtSymbol::SYMBOL_NONE && m_qwtPlotCurve )
{
CVF_ASSERT( RiaGuiApplication::isRunning() );
QSizeF iconSize( 24, 24 );
QwtGraphic graphic = m_qwtPlotCurve->legendIcon( 0, iconSize );
QPixmap pixmap = graphic.toPixmap();
setUiIcon( caf::IconProvider( pixmap ) );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -631,7 +400,7 @@ void RimPlotCurve::updateCurveAppearanceForFilesOlderThan_2021_06()
//--------------------------------------------------------------------------------------------------
bool RimPlotCurve::canCurveBeAttached() const
{
if ( !m_parentQwtPlot )
if ( !hasParentPlot() )
{
return false;
}
@ -656,19 +425,6 @@ bool RimPlotCurve::canCurveBeAttached() const
return isVisibleInPossibleParent;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotCurve::attachCurveAndErrorBars()
{
m_qwtPlotCurve->attach( m_parentQwtPlot );
if ( m_showErrorBars )
{
m_qwtCurveErrorBars->attach( m_parentQwtPlot );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -680,88 +436,6 @@ void RimPlotCurve::checkAndApplyDefaultFillColor()
// }
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotCurve::updateCurveAppearance()
{
QColor curveColor = RiaColorTools::toQColor( m_curveAppearance->color() );
QwtSymbol* symbol = nullptr;
if ( m_curveAppearance->symbol() != RiuQwtSymbol::SYMBOL_NONE )
{
int legendFontSize = caf::FontTools::absolutePointSize( RiaPreferences::current()->defaultPlotFontSize(),
caf::FontTools::RelativeSize::Small );
RimPlotWindow* plotWindow = nullptr;
this->firstAncestorOrThisOfType( plotWindow );
if ( plotWindow )
{
legendFontSize = plotWindow->legendFontSize();
}
// QwtPlotCurve will take ownership of the symbol
symbol = new RiuQwtSymbol( m_curveAppearance->symbol(),
m_curveAppearance->symbolLabel(),
m_curveAppearance->symbolLabelPosition(),
legendFontSize );
symbol->setSize( m_curveAppearance->symbolSize(), m_curveAppearance->symbolSize() );
symbol->setColor( curveColor );
// If the symbol is a "filled" symbol, we can have a different edge color
// Otherwise we'll have to use the curve color.
if ( RiuQwtSymbol::isFilledSymbol( m_curveAppearance->symbol() ) )
{
QColor symbolEdgeColor = RiaColorTools::toQColor( m_curveAppearance->symbolEdgeColor() );
symbol->setPen( symbolEdgeColor );
}
else
{
symbol->setPen( curveColor );
}
}
if ( m_qwtCurveErrorBars )
{
QwtIntervalSymbol* newSymbol = new QwtIntervalSymbol( QwtIntervalSymbol::Bar );
newSymbol->setPen( QPen( curveColor ) );
m_qwtCurveErrorBars->setSymbol( newSymbol );
}
if ( m_qwtPlotCurve )
{
QColor fillColor = RiaColorTools::toQColor( m_curveAppearance->fillColor() );
fillColor = RiaColorTools::blendQColors( fillColor, QColor( Qt::white ), 3, 1 );
QBrush fillBrush( fillColor, m_curveAppearance->fillStyle() );
m_qwtPlotCurve->setAppearance( m_curveAppearance->lineStyle(),
m_curveAppearance->interpolation(),
m_curveAppearance->lineThickness(),
curveColor,
fillBrush );
m_qwtPlotCurve->setSymbol( symbol );
m_qwtPlotCurve->setSymbolSkipPixelDistance( m_curveAppearance->symbolSkipDistance() );
// Make sure the legend lines are long enough to distinguish between line types.
// Standard width in Qwt is 8 which is too short.
// Use 10 and scale this by curve thickness + add space for displaying symbol.
if ( m_curveAppearance->lineStyle() != RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_NONE )
{
QSize legendIconSize = m_qwtPlotCurve->legendIconSize();
int symbolWidth = 0;
if ( symbol )
{
symbolWidth = symbol->boundingRect().size().width() + 2;
}
int width = std::max( 10 * m_curveAppearance->lineThickness(), ( symbolWidth * 3 ) / 2 );
legendIconSize.setWidth( width );
m_qwtPlotCurve->setLegendIconSize( legendIconSize );
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -786,44 +460,6 @@ void RimPlotCurve::loadDataAndUpdate( bool updateParentPlot )
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimPlotCurve::xValueRangeInQwt( double* minimumValue, double* maximumValue ) const
{
CVF_ASSERT( minimumValue && maximumValue );
CVF_ASSERT( m_qwtPlotCurve );
if ( m_qwtPlotCurve->data()->size() < 1 )
{
return false;
}
*minimumValue = m_qwtPlotCurve->minXValue();
*maximumValue = m_qwtPlotCurve->maxXValue();
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimPlotCurve::yValueRangeInQwt( double* minimumValue, double* maximumValue ) const
{
CVF_ASSERT( minimumValue && maximumValue );
CVF_ASSERT( m_qwtPlotCurve );
if ( m_qwtPlotCurve->data()->size() < 1 )
{
return false;
}
*minimumValue = m_qwtPlotCurve->minYValue();
*maximumValue = m_qwtPlotCurve->maxYValue();
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -835,7 +471,7 @@ void RimPlotCurve::setLineStyle( RiuQwtPlotCurveDefines::LineStyleEnum lineStyle
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotCurve::setSymbol( RiuQwtSymbol::PointSymbolEnum symbolStyle )
void RimPlotCurve::setSymbol( RiuPlotCurveSymbol::PointSymbolEnum symbolStyle )
{
m_curveAppearance->setSymbol( symbolStyle );
}
@ -851,7 +487,7 @@ void RimPlotCurve::setInterpolation( RiuQwtPlotCurveDefines::CurveInterpolationE
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuQwtSymbol::PointSymbolEnum RimPlotCurve::symbol()
RiuPlotCurveSymbol::PointSymbolEnum RimPlotCurve::symbol()
{
return m_curveAppearance->symbol();
}
@ -899,7 +535,7 @@ void RimPlotCurve::setSymbolLabel( const QString& label )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotCurve::setSymbolLabelPosition( RiuQwtSymbol::LabelPosition labelPosition )
void RimPlotCurve::setSymbolLabelPosition( RiuPlotCurveSymbol::LabelPosition labelPosition )
{
m_curveAppearance->setSymbolLabelPosition( labelPosition );
}
@ -929,7 +565,7 @@ void RimPlotCurve::resetAppearance()
setSymbolEdgeColor( RiaColorTools::textColor3f() );
setLineThickness( 2 );
setLineStyle( RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_SOLID );
setSymbol( RiuQwtSymbol::SYMBOL_NONE );
setSymbol( RiuPlotCurveSymbol::SYMBOL_NONE );
setSymbolSkipDistance( 10 );
}
@ -979,18 +615,9 @@ bool RimPlotCurve::errorBarsVisible() const
void RimPlotCurve::setShowInLegend( bool show )
{
m_showLegend = show;
updateLegendEntryVisibilityNoPlotUpdate();
}
if ( m_plotCurve ) m_plotCurve->setVisibleInLegend( show );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotCurve::setZOrder( double z )
{
if ( m_qwtPlotCurve != nullptr )
{
m_qwtPlotCurve->setZ( z );
}
updateLegendEntryVisibilityNoPlotUpdate();
}
//--------------------------------------------------------------------------------------------------
@ -1002,12 +629,124 @@ void RimPlotCurve::updateLegendEntryVisibilityAndPlotLegend()
updateLegendsInPlot();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotCurve::onCurveAppearanceChanged( const caf::SignalEmitter* emitter )
{
checkAndApplyDefaultFillColor();
updateCurveAppearance();
appearanceChanged.send();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotCurve::onFillColorChanged( const caf::SignalEmitter* emitter )
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotCurve::updateLegendsInPlot()
{
nameChanged.send( curveName() );
if ( m_parentPlot != nullptr )
{
m_parentPlot->updateLegend();
}
}
void RimPlotCurve::setTitle( const QString& title )
{
if ( m_plotCurve ) m_plotCurve->setTitle( title );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotCurve::replotParentPlot()
{
if ( m_parentPlot ) m_parentPlot->replot();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimPlotCurve::hasParentPlot() const
{
return ( m_parentPlot != nullptr );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotCurve::setSamplesFromXYValues( const std::vector<double>& xValues,
const std::vector<double>& yValues,
bool keepOnlyPositiveValues )
{
if ( m_plotCurve )
{
m_plotCurve->setSamplesFromXValuesAndYValues( xValues, yValues, keepOnlyPositiveValues );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotCurve::setSamplesFromDatesAndYValues( const std::vector<QDateTime>& dateTimes,
const std::vector<double>& yValues,
bool keepOnlyPositiveValues )
{
if ( m_plotCurve )
{
m_plotCurve->setSamplesFromDatesAndYValues( dateTimes, yValues, keepOnlyPositiveValues );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotCurve::setSamplesFromTimeTAndYValues( const std::vector<time_t>& dateTimes,
const std::vector<double>& yValues,
bool keepOnlyPositiveValues )
{
if ( m_plotCurve )
{
m_plotCurve->setSamplesFromTimeTAndYValues( dateTimes, yValues, keepOnlyPositiveValues );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotCurve::setSamplesFromXYErrorValues( const std::vector<double>& xValues,
const std::vector<double>& yValues,
const std::vector<double>& errorValues,
bool keepOnlyPositiveValues,
RiaCurveDataTools::ErrorAxis errorAxis )
{
if ( m_plotCurve )
{
m_plotCurve->setSamplesFromXYErrorValues( xValues, yValues, errorValues, keepOnlyPositiveValues, errorAxis );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotCurve::updateAxisInPlot( RiaDefines::PlotAxis plotAxis )
{
if ( m_plotCurve ) m_plotCurve->setYAxis( plotAxis );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotCurve::updateLegendEntryVisibilityNoPlotUpdate()
{
if ( !m_qwtPlotCurve ) return;
if ( !m_plotCurve ) return;
RimEnsembleCurveSet* ensembleCurveSet = nullptr;
this->firstAncestorOrThisOfType( ensembleCurveSet );
@ -1016,7 +755,7 @@ void RimPlotCurve::updateLegendEntryVisibilityNoPlotUpdate()
return;
}
bool showLegendInQwt = m_showLegend();
bool showLegendInPlot = m_showLegend();
RimSummaryPlot* summaryPlot = nullptr;
this->firstAncestorOrThisOfType( summaryPlot );
@ -1037,25 +776,279 @@ void RimPlotCurve::updateLegendEntryVisibilityNoPlotUpdate()
summaryPlot->curveCount() == 1 )
{
// Disable display of legend if the summary plot has only one single curve
showLegendInQwt = false;
showLegendInPlot = false;
}
}
m_qwtPlotCurve->setItemAttribute( QwtPlotItem::Legend, showLegendInQwt );
m_plotCurve->setVisibleInLegend( showLegendInPlot );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotCurve::onCurveAppearanceChanged( const caf::SignalEmitter* emitter )
bool RimPlotCurve::xValueRange( double* minimumValue, double* maximumValue ) const
{
checkAndApplyDefaultFillColor();
updateCurveAppearance();
appearanceChanged.send();
CAF_ASSERT( minimumValue && maximumValue );
CAF_ASSERT( m_plotCurve );
if ( m_plotCurve->numSamples() < 1 )
{
return false;
}
auto [min, max] = m_plotCurve->xDataRange();
*minimumValue = min;
*maximumValue = max;
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotCurve::onFillColorChanged( const caf::SignalEmitter* emitter )
bool RimPlotCurve::yValueRange( double* minimumValue, double* maximumValue ) const
{
CAF_ASSERT( minimumValue && maximumValue );
CAF_ASSERT( m_plotCurve );
if ( m_plotCurve->numSamples() < 1 )
{
return false;
}
auto [min, max] = m_plotCurve->yDataRange();
*minimumValue = min;
*maximumValue = max;
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotCurve::setZOrder( double z )
{
if ( m_plotCurve != nullptr )
{
m_plotCurve->setZ( z );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotCurve::updateCurveAppearance()
{
QColor curveColor = RiaColorTools::toQColor( m_curveAppearance->color() );
if ( !m_plotCurve ) return;
RiuPlotCurveSymbol* symbol = nullptr;
if ( m_curveAppearance->symbol() != RiuPlotCurveSymbol::SYMBOL_NONE )
{
int legendFontSize = caf::FontTools::absolutePointSize( RiaPreferences::current()->defaultPlotFontSize(),
caf::FontTools::RelativeSize::Small );
RimPlotWindow* plotWindow = nullptr;
this->firstAncestorOrThisOfType( plotWindow );
if ( plotWindow )
{
legendFontSize = plotWindow->legendFontSize();
}
// Plot curve will take ownership of the symbol
symbol = m_plotCurve->createSymbol( m_curveAppearance->symbol() );
if ( symbol )
{
symbol->setLabelPosition( m_curveAppearance->symbolLabelPosition() );
symbol->setGlobalLabel( m_curveAppearance->symbolLabel() );
symbol->setSize( m_curveAppearance->symbolSize(), m_curveAppearance->symbolSize() );
symbol->setColor( curveColor );
symbol->setLabelFontSize( legendFontSize );
// If the symbol is a "filled" symbol, we can have a different edge color
// Otherwise we'll have to use the curve color.
if ( RiuPlotCurveSymbol::isFilledSymbol( m_curveAppearance->symbol() ) )
{
QColor symbolEdgeColor = RiaColorTools::toQColor( m_curveAppearance->symbolEdgeColor() );
symbol->setPen( symbolEdgeColor );
}
else
{
symbol->setPen( curveColor );
}
}
}
m_plotCurve->updateErrorBarsAppearance( m_showErrorBars, curveColor );
QColor fillColor = RiaColorTools::toQColor( m_curveAppearance->fillColor() );
fillColor = RiaColorTools::blendQColors( fillColor, QColor( Qt::white ), 3, 1 );
QBrush fillBrush( fillColor, m_curveAppearance->fillStyle() );
m_plotCurve->setAppearance( m_curveAppearance->lineStyle(),
m_curveAppearance->interpolation(),
m_curveAppearance->lineThickness(),
curveColor,
fillBrush );
m_plotCurve->setSymbol( symbol );
m_plotCurve->setSymbolSkipPixelDistance( m_curveAppearance->symbolSkipDistance() );
// Make sure the legend lines are long enough to distinguish between line types.
// Standard width in Qwt is 8 which is too short.
// Use 10 and scale this by curve thickness + add space for displaying symbol.
if ( m_curveAppearance->lineStyle() != RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_NONE )
{
QSize legendIconSize = m_plotCurve->legendIconSize();
int symbolWidth = 0;
if ( symbol )
{
symbolWidth = symbol->boundingRect().size().width() + 2;
}
int width = std::max( 10 * m_curveAppearance->lineThickness(), ( symbolWidth * 3 ) / 2 );
legendIconSize.setWidth( width );
m_plotCurve->setLegendIconSize( legendIconSize );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotCurve::clearErrorBars()
{
if ( m_plotCurve ) m_plotCurve->clearErrorBars();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotCurve::updateUiIconFromPlotSymbol()
{
if ( m_curveAppearance->symbol() != RiuPlotCurveSymbol::SYMBOL_NONE && m_plotCurve )
{
CAF_ASSERT( RiaGuiApplication::isRunning() );
QSizeF iconSize( 24, 24 );
QPixmap pixmap = m_plotCurve->legendIcon( iconSize );
setUiIcon( caf::IconProvider( pixmap ) );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotCurve::updateCurveVisibility()
{
if ( canCurveBeAttached() )
{
reattach();
}
else
{
detach();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RimPlotCurve::dataSize() const
{
if ( m_plotCurve )
return m_plotCurve->numSamples();
else
return 0;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::pair<double, double> RimPlotCurve::sample( int index ) const
{
CAF_ASSERT( m_plotCurve );
CAF_ASSERT( index >= 0 && index <= dataSize() );
return m_plotCurve->sample( index );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotCurve::setParentPlotNoReplot( RiuPlotWidget* plotWidget )
{
if ( !plotWidget ) return;
m_parentPlot = plotWidget;
if ( !m_plotCurve )
{
m_plotCurve = m_parentPlot->createPlotCurve( this, "", RiaColorTools::toQColor( m_curveAppearance->color() ) );
}
m_plotCurve->attachToPlot( plotWidget );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotCurve::setParentPlotAndReplot( RiuPlotWidget* plotWidget )
{
CAF_ASSERT( plotWidget );
setParentPlotNoReplot( plotWidget );
plotWidget->replot();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotCurve::attach( RiuPlotWidget* plotWidget )
{
setParentPlotAndReplot( plotWidget );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotCurve::detach()
{
if ( m_plotCurve )
{
m_plotCurve->detach();
}
replotParentPlot();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotCurve::reattach()
{
if ( m_parentPlot ) attach( m_parentPlot );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimPlotCurve::isSameCurve( const RiuPlotCurve* plotCurve ) const
{
return m_plotCurve == plotCurve;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimPlotCurve::curveName() const
{
return m_curveName;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimPlotCurve::curveExportDescription( const RifEclipseSummaryAddress& address ) const
{
return m_curveName;
}

View File

@ -22,7 +22,7 @@
#include "RimPlotCurveAppearance.h"
#include "RiaCurveDataTools.h"
#include "RiaDefines.h"
#include "RiaPlotDefines.h"
#include "RiuQwtPlotCurveDefines.h"
#include "RiuQwtSymbol.h"
@ -35,10 +35,8 @@
#include <QPointer>
#include <Qt>
class QwtPlot;
class QwtPlotCurve;
class QwtPlotIntervalCurve;
class RiuQwtPlotCurve;
class RiuPlotCurve;
class RiuPlotWidget;
//==================================================================================================
///
@ -60,33 +58,24 @@ public:
void loadDataAndUpdate( bool updateParentPlot );
virtual bool xValueRangeInQwt( double* minimumValue, double* maximumValue ) const;
virtual bool yValueRangeInQwt( double* minimumValue, double* maximumValue ) const;
void setParentQwtPlotAndReplot( QwtPlot* plot );
void setParentQwtPlotNoReplot( QwtPlot* plot );
void detachQwtCurve();
void reattachQwtCurve();
QwtPlotCurve* qwtPlotCurve() const;
void setColor( const cvf::Color3f& color );
cvf::Color3f color() const;
void setLineStyle( RiuQwtPlotCurveDefines::LineStyleEnum lineStyle );
void setSymbol( RiuQwtSymbol::PointSymbolEnum symbolStyle );
void setInterpolation( RiuQwtPlotCurveDefines::CurveInterpolationEnum );
RiuQwtSymbol::PointSymbolEnum symbol();
int symbolSize() const;
cvf::Color3f symbolEdgeColor() const;
void setSymbolEdgeColor( const cvf::Color3f& edgeColor );
void setSymbolSkipDistance( float distance );
void setSymbolLabel( const QString& label );
void setSymbolLabelPosition( RiuQwtSymbol::LabelPosition labelPosition );
void setSymbolSize( int sizeInPixels );
void setLineThickness( int thickness );
void resetAppearance();
Qt::BrushStyle fillStyle() const;
void setFillStyle( Qt::BrushStyle brushStyle );
void setFillColor( const cvf::Color3f& fillColor );
void setColor( const cvf::Color3f& color );
cvf::Color3f color() const;
void setLineStyle( RiuQwtPlotCurveDefines::LineStyleEnum lineStyle );
void setSymbol( RiuPlotCurveSymbol::PointSymbolEnum symbolStyle );
void setInterpolation( RiuQwtPlotCurveDefines::CurveInterpolationEnum );
RiuPlotCurveSymbol::PointSymbolEnum symbol();
int symbolSize() const;
cvf::Color3f symbolEdgeColor() const;
void setSymbolEdgeColor( const cvf::Color3f& edgeColor );
void setSymbolSkipDistance( float distance );
void setSymbolLabel( const QString& label );
void setSymbolLabelPosition( RiuPlotCurveSymbol::LabelPosition labelPosition );
void setSymbolSize( int sizeInPixels );
void setLineThickness( int thickness );
void resetAppearance();
Qt::BrushStyle fillStyle() const;
void setFillStyle( Qt::BrushStyle brushStyle );
void setFillColor( const cvf::Color3f& fillColor );
bool isCurveVisible() const;
void setCurveVisibility( bool visible );
@ -95,32 +84,48 @@ public:
void updateCurveNameAndUpdatePlotLegendAndTitle();
void updateCurveNameNoLegendUpdate();
QString curveName() const { return m_curveName; }
virtual QString curveExportDescription( const RifEclipseSummaryAddress& address = RifEclipseSummaryAddress() ) const
{
return m_curveName;
}
QString curveName() const;
virtual QString curveExportDescription( const RifEclipseSummaryAddress& address = RifEclipseSummaryAddress() ) const;
void setCustomName( const QString& customName );
QString legendEntryText() const;
void setLegendEntryText( const QString& legendEntryText );
void updateCurveVisibility();
void updateLegendEntryVisibilityAndPlotLegend();
void updateLegendEntryVisibilityNoPlotUpdate();
virtual void updateCurveVisibility();
void updateLegendEntryVisibilityAndPlotLegend();
void updateLegendEntryVisibilityNoPlotUpdate();
virtual void replotParentPlot();
bool showInLegend() const;
bool errorBarsVisible() const;
void setShowInLegend( bool show );
void setZOrder( double z );
void setErrorBarsVisible( bool isVisible );
void setShowInLegend( bool show );
virtual void setZOrder( double z );
void setErrorBarsVisible( bool isVisible );
virtual void updateCurveAppearance();
bool isCrossPlotCurve() const;
void updateUiIconFromPlotSymbol();
virtual void updateUiIconFromPlotSymbol();
virtual bool hasParentPlot() const;
void updateCurveAppearanceForFilesOlderThan_2021_06();
virtual bool xValueRange( double* minimumValue, double* maximumValue ) const;
virtual bool yValueRange( double* minimumValue, double* maximumValue ) const;
virtual void setTitle( const QString& title );
int dataSize() const;
std::pair<double, double> sample( int index ) const;
void setParentPlotNoReplot( RiuPlotWidget* );
void setParentPlotAndReplot( RiuPlotWidget* );
void attach( RiuPlotWidget* );
void detach();
void reattach();
bool isSameCurve( const RiuPlotCurve* plotCurve ) const;
protected:
virtual QString createCurveAutoName() = 0;
virtual void updateZoomInParentPlot() = 0;
@ -137,9 +142,11 @@ protected:
const std::vector<double>& errorValues,
bool keepOnlyPositiveValues,
RiaCurveDataTools::ErrorAxis errorAxis = RiaCurveDataTools::ErrorAxis::ERROR_ALONG_Y_AXIS );
void setSamplesFromXYValues( const std::vector<double>& xValues,
const std::vector<double>& yValues,
bool keepOnlyPositiveValues );
void setSamplesFromDatesAndYValues( const std::vector<QDateTime>& dateTimes,
const std::vector<double>& yValues,
bool keepOnlyPositiveValues );
@ -156,20 +163,16 @@ protected:
void appearanceUiOrdering( caf::PdmUiOrdering& uiOrdering );
void curveNameUiOrdering( caf::PdmUiOrdering& uiOrdering );
virtual void onCurveAppearanceChanged( const caf::SignalEmitter* emitter );
void onCurveAppearanceChanged( const caf::SignalEmitter* emitter );
virtual void onFillColorChanged( const caf::SignalEmitter* emitter );
private:
bool canCurveBeAttached() const;
void attachCurveAndErrorBars();
void checkAndApplyDefaultFillColor();
bool canCurveBeAttached() const;
virtual void clearErrorBars();
void checkAndApplyDefaultFillColor();
virtual void updateAxisInPlot( RiaDefines::PlotAxis plotAxis );
protected:
QPointer<QwtPlot> m_parentQwtPlot;
RiuQwtPlotCurve* m_qwtPlotCurve;
QwtPlotIntervalCurve* m_qwtCurveErrorBars;
caf::PdmField<bool> m_showCurve;
caf::PdmField<QString> m_curveName;
caf::PdmField<QString> m_customCurveName;
@ -180,6 +183,9 @@ protected:
caf::PdmChildField<RimPlotCurveAppearance*> m_curveAppearance;
QPointer<RiuPlotWidget> m_parentPlot;
RiuPlotCurve* m_plotCurve;
caf::PdmField<QString> m_symbolLabel_OBSOLETE;
caf::PdmField<int> m_symbolSize_OBSOLETE;
caf::PdmField<cvf::Color3f> m_curveColor_OBSOLETE;

View File

@ -31,30 +31,30 @@ namespace caf
template <>
void RimPlotCurveAppearance::PointSymbol::setUp()
{
addItem( RiuQwtSymbol::SYMBOL_NONE, "SYMBOL_NONE", "None" );
addItem( RiuQwtSymbol::SYMBOL_ELLIPSE, "SYMBOL_ELLIPSE", "Ellipse" );
addItem( RiuQwtSymbol::SYMBOL_RECT, "SYMBOL_RECT", "Rect" );
addItem( RiuQwtSymbol::SYMBOL_DIAMOND, "SYMBOL_DIAMOND", "Diamond" );
addItem( RiuQwtSymbol::SYMBOL_TRIANGLE, "SYMBOL_TRIANGLE", "Triangle" );
addItem( RiuQwtSymbol::SYMBOL_DOWN_TRIANGLE, "SYMBOL_DOWN_TRIANGLE", "Down Triangle" );
addItem( RiuQwtSymbol::SYMBOL_CROSS, "SYMBOL_CROSS", "Cross" );
addItem( RiuQwtSymbol::SYMBOL_XCROSS, "SYMBOL_XCROSS", "X Cross" );
addItem( RiuQwtSymbol::SYMBOL_STAR1, "SYMBOL_STAR1", "Star 1" );
addItem( RiuQwtSymbol::SYMBOL_STAR2, "SYMBOL_STAR2", "Star 2" );
addItem( RiuQwtSymbol::SYMBOL_HEXAGON, "SYMBOL_HEXAGON", "Hexagon" );
addItem( RiuQwtSymbol::SYMBOL_LEFT_TRIANGLE, "SYMBOL_LEFT_TRIANGLE", "Left Triangle" );
addItem( RiuQwtSymbol::SYMBOL_RIGHT_TRIANGLE, "SYMBOL_RIGHT_TRIANGLE", "Right Triangle" );
setDefault( RiuQwtSymbol::SYMBOL_NONE );
addItem( RiuPlotCurveSymbol::SYMBOL_NONE, "SYMBOL_NONE", "None" );
addItem( RiuPlotCurveSymbol::SYMBOL_ELLIPSE, "SYMBOL_ELLIPSE", "Ellipse" );
addItem( RiuPlotCurveSymbol::SYMBOL_RECT, "SYMBOL_RECT", "Rect" );
addItem( RiuPlotCurveSymbol::SYMBOL_DIAMOND, "SYMBOL_DIAMOND", "Diamond" );
addItem( RiuPlotCurveSymbol::SYMBOL_TRIANGLE, "SYMBOL_TRIANGLE", "Triangle" );
addItem( RiuPlotCurveSymbol::SYMBOL_DOWN_TRIANGLE, "SYMBOL_DOWN_TRIANGLE", "Down Triangle" );
addItem( RiuPlotCurveSymbol::SYMBOL_CROSS, "SYMBOL_CROSS", "Cross" );
addItem( RiuPlotCurveSymbol::SYMBOL_XCROSS, "SYMBOL_XCROSS", "X Cross" );
addItem( RiuPlotCurveSymbol::SYMBOL_STAR1, "SYMBOL_STAR1", "Star 1" );
addItem( RiuPlotCurveSymbol::SYMBOL_STAR2, "SYMBOL_STAR2", "Star 2" );
addItem( RiuPlotCurveSymbol::SYMBOL_HEXAGON, "SYMBOL_HEXAGON", "Hexagon" );
addItem( RiuPlotCurveSymbol::SYMBOL_LEFT_TRIANGLE, "SYMBOL_LEFT_TRIANGLE", "Left Triangle" );
addItem( RiuPlotCurveSymbol::SYMBOL_RIGHT_TRIANGLE, "SYMBOL_RIGHT_TRIANGLE", "Right Triangle" );
setDefault( RiuPlotCurveSymbol::SYMBOL_NONE );
}
template <>
void RimPlotCurveAppearance::LabelPosition::setUp()
{
addItem( RiuQwtSymbol::LabelAboveSymbol, "LABEL_ABOVE_SYMBOL", "Label above Symbol" );
addItem( RiuQwtSymbol::LabelBelowSymbol, "LABEL_BELOW_SYMBOL", "Label below Symbol" );
addItem( RiuQwtSymbol::LabelLeftOfSymbol, "LABEL_LEFT_OF_SYMBOL", "Label left of Symbol" );
addItem( RiuQwtSymbol::LabelRightOfSymbol, "LABEL_RIGHT_OF_SYMBOL", "Label right of Symbol" );
setDefault( RiuQwtSymbol::LabelAboveSymbol );
addItem( RiuPlotCurveSymbol::LabelAboveSymbol, "LABEL_ABOVE_SYMBOL", "Label above Symbol" );
addItem( RiuPlotCurveSymbol::LabelBelowSymbol, "LABEL_BELOW_SYMBOL", "Label below Symbol" );
addItem( RiuPlotCurveSymbol::LabelLeftOfSymbol, "LABEL_LEFT_OF_SYMBOL", "Label left of Symbol" );
addItem( RiuPlotCurveSymbol::LabelRightOfSymbol, "LABEL_RIGHT_OF_SYMBOL", "Label right of Symbol" );
setDefault( RiuPlotCurveSymbol::LabelAboveSymbol );
}
template <>
@ -132,8 +132,8 @@ void RimPlotCurveAppearance::fieldChangedByUi( const caf::PdmFieldHandle* change
{
if ( &m_pointSymbol == changedField )
{
m_symbolSize.uiCapability()->setUiReadOnly( m_pointSymbol() == RiuQwtSymbol::SYMBOL_NONE );
m_symbolSkipPixelDistance.uiCapability()->setUiReadOnly( m_pointSymbol() == RiuQwtSymbol::SYMBOL_NONE );
m_symbolSize.uiCapability()->setUiReadOnly( m_pointSymbol() == RiuPlotCurveSymbol::SYMBOL_NONE );
m_symbolSkipPixelDistance.uiCapability()->setUiReadOnly( m_pointSymbol() == RiuPlotCurveSymbol::SYMBOL_NONE );
}
else if ( &m_lineStyle == changedField )
{
@ -156,8 +156,8 @@ void RimPlotCurveAppearance::fieldChangedByUi( const caf::PdmFieldHandle* change
//--------------------------------------------------------------------------------------------------
void RimPlotCurveAppearance::initAfterRead()
{
m_symbolSize.uiCapability()->setUiReadOnly( m_pointSymbol() == RiuQwtSymbol::SYMBOL_NONE );
m_symbolSkipPixelDistance.uiCapability()->setUiReadOnly( m_pointSymbol() == RiuQwtSymbol::SYMBOL_NONE );
m_symbolSize.uiCapability()->setUiReadOnly( m_pointSymbol() == RiuPlotCurveSymbol::SYMBOL_NONE );
m_symbolSkipPixelDistance.uiCapability()->setUiReadOnly( m_pointSymbol() == RiuPlotCurveSymbol::SYMBOL_NONE );
m_curveThickness.uiCapability()->setUiReadOnly( m_lineStyle() == RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_NONE );
m_curveInterpolation.uiCapability()->setUiReadOnly( m_lineStyle() == RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_NONE );
}
@ -188,7 +188,7 @@ void RimPlotCurveAppearance::defineUiOrdering( QString uiConfigName, caf::PdmUiO
m_curveColor.uiCapability()->setUiHidden( !m_colorVisible );
uiOrdering.add( &m_pointSymbol );
if ( RiuQwtSymbol::isFilledSymbol( m_pointSymbol() ) )
if ( RiuPlotCurveSymbol::isFilledSymbol( m_pointSymbol() ) )
{
uiOrdering.add( &m_symbolEdgeColor );
}
@ -242,7 +242,7 @@ void RimPlotCurveAppearance::setLineStyle( RiuQwtPlotCurveDefines::LineStyleEnum
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotCurveAppearance::setSymbol( RiuQwtSymbol::PointSymbolEnum symbolStyle )
void RimPlotCurveAppearance::setSymbol( RiuPlotCurveSymbol::PointSymbolEnum symbolStyle )
{
m_pointSymbol = symbolStyle;
}
@ -274,7 +274,7 @@ RiuQwtPlotCurveDefines::LineStyleEnum RimPlotCurveAppearance::lineStyle() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuQwtSymbol::PointSymbolEnum RimPlotCurveAppearance::symbol() const
RiuPlotCurveSymbol::PointSymbolEnum RimPlotCurveAppearance::symbol() const
{
return m_pointSymbol();
}
@ -338,7 +338,7 @@ QString RimPlotCurveAppearance::symbolLabel() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotCurveAppearance::setSymbolLabelPosition( RiuQwtSymbol::LabelPosition labelPosition )
void RimPlotCurveAppearance::setSymbolLabelPosition( RiuPlotCurveSymbol::LabelPosition labelPosition )
{
m_symbolLabelPosition = labelPosition;
}
@ -346,7 +346,7 @@ void RimPlotCurveAppearance::setSymbolLabelPosition( RiuQwtSymbol::LabelPosition
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuQwtSymbol::LabelPosition RimPlotCurveAppearance::symbolLabelPosition() const
RiuPlotCurveSymbol::LabelPosition RimPlotCurveAppearance::symbolLabelPosition() const
{
return m_symbolLabelPosition.value();
}
@ -384,7 +384,7 @@ void RimPlotCurveAppearance::resetAppearance()
setSymbolEdgeColor( RiaColorTools::textColor3f() );
setLineThickness( 2 );
setLineStyle( RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_SOLID );
setSymbol( RiuQwtSymbol::SYMBOL_NONE );
setSymbol( RiuPlotCurveSymbol::SYMBOL_NONE );
setSymbolSkipDistance( 10 );
}

View File

@ -20,8 +20,8 @@
#include "RiaCurveDataTools.h"
#include "RiaDefines.h"
#include "RiuPlotCurveSymbol.h"
#include "RiuQwtPlotCurveDefines.h"
#include "RiuQwtSymbol.h"
#include "cafPdmField.h"
#include "cafPdmFieldCvfColor.h"
@ -42,8 +42,8 @@ public:
public:
typedef caf::AppEnum<RiuQwtPlotCurveDefines::CurveInterpolationEnum> CurveInterpolation;
typedef caf::AppEnum<RiuQwtPlotCurveDefines::LineStyleEnum> LineStyle;
typedef caf::AppEnum<RiuQwtSymbol::PointSymbolEnum> PointSymbol;
typedef caf::AppEnum<RiuQwtSymbol::LabelPosition> LabelPosition;
typedef caf::AppEnum<RiuPlotCurveSymbol::PointSymbolEnum> PointSymbol;
typedef caf::AppEnum<RiuPlotCurveSymbol::LabelPosition> LabelPosition;
typedef caf::AppEnum<Qt::BrushStyle> FillStyle;
public:
@ -59,8 +59,8 @@ public:
void setLineThickness( int thickness );
int lineThickness() const;
void setSymbol( RiuQwtSymbol::PointSymbolEnum symbolStyle );
RiuQwtSymbol::PointSymbolEnum symbol() const;
void setSymbol( RiuPlotCurveSymbol::PointSymbolEnum symbolStyle );
RiuPlotCurveSymbol::PointSymbolEnum symbol() const;
void setSymbolSize( int sizeInPixels );
int symbolSize() const;
@ -74,8 +74,8 @@ public:
void setSymbolLabel( const QString& label );
QString symbolLabel() const;
void setSymbolLabelPosition( RiuQwtSymbol::LabelPosition labelPosition );
RiuQwtSymbol::LabelPosition symbolLabelPosition() const;
void setSymbolLabelPosition( RiuPlotCurveSymbol::LabelPosition labelPosition );
RiuPlotCurveSymbol::LabelPosition symbolLabelPosition() const;
void resetAppearance();
Qt::BrushStyle fillStyle() const;

View File

@ -34,6 +34,13 @@ RimStackablePlotCurve::RimStackablePlotCurve()
CAF_PDM_InitField( &m_isStackedWithPhaseColors, "StackPhaseColors", false, " with Phase Colors" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimStackablePlotCurve::~RimStackablePlotCurve()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -27,6 +27,7 @@ public:
public:
RimStackablePlotCurve();
~RimStackablePlotCurve() override;
virtual RiaDefines::PhaseType phaseType() const;
void assignStackColor( size_t index, size_t count );

View File

@ -18,6 +18,7 @@
#include "RimVfpPlot.h"
#include "RiaDefines.h"
#include "RimVfpDefines.h"
#include "RimVfpTableExtractor.h"
@ -25,18 +26,15 @@
#include "RiaEclipseUnitTools.h"
#include "RiuContextMenuLauncher.h"
#include "RiuQwtPlotTools.h"
#include "RiuPlotCurve.h"
#include "RiuPlotWidget.h"
#include "RiuQwtPlotCurveDefines.h"
#include "RiuQwtPlotWidget.h"
#include "RiuQwtSymbol.h"
#include "cafCmdFeatureMenuBuilder.h"
#include "cafPdmUiComboBoxEditor.h"
#include "qwt_legend.h"
#include "qwt_legend_label.h"
#include "qwt_plot.h"
#include "qwt_plot_curve.h"
#include "qwt_symbol.h"
#include <QFileInfo>
#include <memory>
@ -169,7 +167,7 @@ void RimVfpPlot::setFileName( const QString& filename )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuQwtPlotWidget* RimVfpPlot::viewer()
RiuPlotWidget* RimVfpPlot::plotWidget()
{
return m_plotWidget;
}
@ -214,29 +212,14 @@ void RimVfpPlot::updateLegend()
if ( doShowLegend )
{
QwtLegend* legend = new QwtLegend( m_plotWidget );
m_plotWidget->insertLegend( legend, QwtPlot::BottomLegend );
m_plotWidget->insertLegend( RiuPlotWidget::Legend::BOTTOM );
}
else
{
m_plotWidget->insertLegend( nullptr );
m_plotWidget->clearLegend();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimVfpPlot::updateZoomInQwt()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimVfpPlot::updateZoomFromQwt()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -328,21 +311,6 @@ void RimVfpPlot::detachAllCurves()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmObject* RimVfpPlot::findPdmObjectFromQwtCurve( const QwtPlotCurve* /*curve*/ ) const
{
return nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimVfpPlot::onAxisSelected( int /*axis*/, bool /*toggle*/ )
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -392,7 +360,7 @@ void RimVfpPlot::doRemoveFromCollection()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuQwtPlotWidget* RimVfpPlot::doCreatePlotViewWidget( QWidget* mainWindowParent )
RiuPlotWidget* RimVfpPlot::doCreatePlotViewWidget( QWidget* mainWindowParent )
{
// It seems we risk being called multiple times
if ( m_plotWidget )
@ -401,13 +369,10 @@ RiuQwtPlotWidget* RimVfpPlot::doCreatePlotViewWidget( QWidget* mainWindowParent
}
{
auto plotWidget = new RiuQwtPlotWidget( this, mainWindowParent );
RiuPlotWidget* plotWidget = new RiuQwtPlotWidget( this, mainWindowParent );
// Remove event filter to disable unwanted highlighting on left click in plot.
plotWidget->removeEventFilter( plotWidget );
plotWidget->canvas()->removeEventFilter( plotWidget );
RiuQwtPlotTools::setCommonPlotBehaviour( plotWidget );
plotWidget->removeEventFilter();
caf::CmdFeatureMenuBuilder menuBuilder;
menuBuilder << "RicShowPlotDataFeature";
@ -454,7 +419,7 @@ void RimVfpPlot::onLoadDataAndUpdate()
return;
}
m_plotWidget->detachItems( QwtPlotItem::Rtti_PlotCurve );
m_plotWidget->detachItems( RiuPlotWidget::PlotItemType::CURVE );
updateLegend();
@ -500,8 +465,8 @@ void RimVfpPlot::onLoadDataAndUpdate()
m_primaryVariable(),
m_familyVariable() ) );
m_plotWidget->setAxisTitleEnabled( QwtPlot::xBottom, true );
m_plotWidget->setAxisTitleEnabled( QwtPlot::yLeft, true );
m_plotWidget->setAxisTitleEnabled( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM, true );
m_plotWidget->setAxisTitleEnabled( RiaDefines::PlotAxis::PLOT_AXIS_LEFT, true );
}
m_plotWidget->scheduleReplot();
@ -510,7 +475,7 @@ void RimVfpPlot::onLoadDataAndUpdate()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimVfpPlot::populatePlotWidgetWithCurveData( RiuQwtPlotWidget* plotWidget, const Opm::VFPInjTable& table )
void RimVfpPlot::populatePlotWidgetWithCurveData( RiuPlotWidget* plotWidget, const Opm::VFPInjTable& table )
{
VfpPlotData plotData;
populatePlotData( table, m_interpolatedVariable(), plotData );
@ -570,7 +535,7 @@ void RimVfpPlot::populatePlotData( const Opm::VFPInjTable& table
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimVfpPlot::populatePlotWidgetWithCurveData( RiuQwtPlotWidget* plotWidget,
void RimVfpPlot::populatePlotWidgetWithCurveData( RiuPlotWidget* plotWidget,
const Opm::VFPProdTable& table,
RimVfpDefines::ProductionVariableType primaryVariable,
RimVfpDefines::ProductionVariableType familyVariable )
@ -583,25 +548,36 @@ void RimVfpPlot::populatePlotWidgetWithCurveData( RiuQwtPlotWidget*
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimVfpPlot::populatePlotWidgetWithPlotData( RiuQwtPlotWidget* plotWidget, const VfpPlotData& plotData )
void RimVfpPlot::populatePlotWidgetWithPlotData( RiuPlotWidget* plotWidget, const VfpPlotData& plotData )
{
plotWidget->detachItems( QwtPlotItem::Rtti_PlotCurve );
plotWidget->setAxisScale( QwtPlot::xBottom, 0, 1 );
plotWidget->setAxisScale( QwtPlot::yLeft, 0, 1 );
plotWidget->setAxisAutoScale( QwtPlot::xBottom, true );
plotWidget->setAxisAutoScale( QwtPlot::yLeft, true );
plotWidget->setAxisTitleText( QwtPlot::xBottom, plotData.xAxisTitle() );
plotWidget->setAxisTitleText( QwtPlot::yLeft, plotData.yAxisTitle() );
plotWidget->detachItems( RiuPlotWidget::PlotItemType::CURVE );
plotWidget->setAxisScale( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM, 0, 1 );
plotWidget->setAxisScale( RiaDefines::PlotAxis::PLOT_AXIS_LEFT, 0, 1 );
plotWidget->setAxisAutoScale( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM, true );
plotWidget->setAxisAutoScale( RiaDefines::PlotAxis::PLOT_AXIS_LEFT, true );
plotWidget->setAxisTitleText( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM, plotData.xAxisTitle() );
plotWidget->setAxisTitleText( RiaDefines::PlotAxis::PLOT_AXIS_LEFT, plotData.yAxisTitle() );
for ( auto idx = 0u; idx < plotData.size(); idx++ )
{
QColor qtClr = RiaColorTables::summaryCurveDefaultPaletteColors().cycledQColor( idx );
QwtPlotCurve* curve = createPlotCurve( plotData.curveTitle( idx ), qtClr );
curve->setSamples( plotData.xData( idx ).data(),
plotData.yData( idx ).data(),
static_cast<int>( plotData.curveSize( idx ) ) );
curve->attach( plotWidget );
curve->show();
RiuPlotCurve* curve = m_plotWidget->createPlotCurve( nullptr, plotData.curveTitle( idx ), qtClr );
curve->setAppearance( RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_SOLID,
RiuQwtPlotCurveDefines::CurveInterpolationEnum::INTERPOLATION_POINT_TO_POINT,
2,
qtClr );
RiuPlotCurveSymbol* symbol = curve->createSymbol( RiuPlotCurveSymbol::PointSymbolEnum::SYMBOL_ELLIPSE );
symbol->setColor( qtClr );
symbol->setSize( 6, 6 );
curve->setSymbol( symbol );
curve->setSamplesFromXValuesAndYValues( plotData.xData( idx ),
plotData.yData( idx ),
static_cast<int>( plotData.curveSize( idx ) ) );
curve->attachToPlot( plotWidget );
curve->showInPlot();
}
}
@ -687,27 +663,6 @@ void RimVfpPlot::populatePlotData( const Opm::VFPProdTable& table
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QwtPlotCurve* RimVfpPlot::createPlotCurve( const QString title, const QColor& color )
{
QwtPlotCurve* curve = new QwtPlotCurve;
curve->setTitle( title );
curve->setPen( QPen( color, 2 ) );
curve->setLegendAttribute( QwtPlotCurve::LegendShowLine, true );
curve->setLegendAttribute( QwtPlotCurve::LegendShowSymbol, true );
curve->setLegendAttribute( QwtPlotCurve::LegendShowBrush, true );
curve->setRenderHint( QwtPlotItem::RenderAntialiased, true );
QwtSymbol* symbol = new QwtSymbol( QwtSymbol::Ellipse );
symbol->setSize( 6 );
symbol->setColor( color );
curve->setSymbol( symbol );
return curve;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -1036,7 +991,7 @@ void RimVfpPlot::updatePlotTitle( const QString& plotTitle )
if ( m_plotWidget )
{
m_plotWidget->setTitle( plotTitle );
m_plotWidget->setPlotTitle( plotTitle );
}
}

View File

@ -29,7 +29,7 @@
#include "opm/parser/eclipse/EclipseState/Schedule/VFPInjTable.hpp"
#include "opm/parser/eclipse/EclipseState/Schedule/VFPProdTable.hpp"
class RiuQwtPlotWidget;
class RiuPlotWidget;
class VfpPlotData;
//--------------------------------------------------------------------------------------------------
@ -46,18 +46,15 @@ public:
void setFileName( const QString& filename );
// RimPlot implementations
RiuQwtPlotWidget* viewer() override;
void setAutoScaleXEnabled( bool enabled ) override;
void setAutoScaleYEnabled( bool enabled ) override;
void updateAxes() override;
void updateLegend() override;
void updateZoomInQwt() override;
void updateZoomFromQwt() override;
QString asciiDataForPlotExport() const override;
void reattachAllCurves() override;
void detachAllCurves() override;
caf::PdmObject* findPdmObjectFromQwtCurve( const QwtPlotCurve* curve ) const override;
void onAxisSelected( int axis, bool toggle ) override;
RiuPlotWidget* plotWidget() override;
void setAutoScaleXEnabled( bool enabled ) override;
void setAutoScaleYEnabled( bool enabled ) override;
void updateAxes() override;
void updateLegend() override;
QString asciiDataForPlotExport() const override;
void reattachAllCurves() override;
void detachAllCurves() override;
// RimPlotWindow implementations
QString description() const override;
@ -79,10 +76,10 @@ private:
caf::PdmFieldHandle* userDescriptionField() override;
private:
RiuQwtPlotWidget* doCreatePlotViewWidget( QWidget* mainWindowParent ) override;
RiuPlotWidget* doCreatePlotViewWidget( QWidget* mainWindowParent ) override;
void populatePlotWidgetWithCurveData( RiuQwtPlotWidget* plotWidget, const Opm::VFPInjTable& table );
void populatePlotWidgetWithCurveData( RiuQwtPlotWidget* plotWidget,
void populatePlotWidgetWithCurveData( RiuPlotWidget* plotWidget, const Opm::VFPInjTable& table );
void populatePlotWidgetWithCurveData( RiuPlotWidget* plotWidget,
const Opm::VFPProdTable& table,
RimVfpDefines::ProductionVariableType primaryVariable,
RimVfpDefines::ProductionVariableType familyVariable );
@ -114,8 +111,7 @@ private:
RimVfpDefines::ProductionVariableType primaryVariable,
RimVfpDefines::ProductionVariableType familyVariable );
static QwtPlotCurve* createPlotCurve( const QString title, const QColor& color );
static double convertToDisplayUnit( double value, RimVfpDefines::ProductionVariableType variableType );
static double convertToDisplayUnit( double value, RimVfpDefines::ProductionVariableType variableType );
static void convertToDisplayUnit( std::vector<double>& values, RimVfpDefines::ProductionVariableType variableType );
static QString getDisplayUnit( RimVfpDefines::ProductionVariableType variableType );
@ -137,7 +133,7 @@ private:
RimVfpDefines::InterpolatedVariableType interpolatedVariable,
VfpPlotData& plotData ) const;
void populatePlotWidgetWithPlotData( RiuQwtPlotWidget* plotWidget, const VfpPlotData& plotData );
void populatePlotWidgetWithPlotData( RiuPlotWidget* plotWidget, const VfpPlotData& plotData );
private:
caf::PdmField<QString> m_plotTitle;
@ -159,7 +155,7 @@ private:
caf::PdmField<int> m_waterCutIdx;
caf::PdmField<int> m_gasLiquidRatioIdx;
QPointer<RiuQwtPlotWidget> m_plotWidget;
QPointer<RiuPlotWidget> m_plotWidget;
std::unique_ptr<Opm::VFPProdTable> m_prodTable;
std::unique_ptr<Opm::VFPInjTable> m_injectionTable;
};

View File

@ -117,7 +117,7 @@ void RimAsciiDataCurve::updateZoomInParentPlot()
RimSummaryPlot* plot = nullptr;
firstAncestorOrThisOfType( plot );
plot->updateZoomInQwt();
plot->updateZoomInParentPlot();
}
//--------------------------------------------------------------------------------------------------
@ -140,7 +140,7 @@ void RimAsciiDataCurve::onLoadDataAndUpdate( bool updateParentPlot )
{
if ( plot->timeAxisProperties()->timeMode() == RimSummaryTimeAxisProperties::DATE )
{
m_qwtPlotCurve->setSamplesFromTimeTAndYValues( dateTimes, values, isLogCurve );
m_plotCurve->setSamplesFromTimeTAndYValues( dateTimes, values, isLogCurve );
}
else
{
@ -156,17 +156,17 @@ void RimAsciiDataCurve::onLoadDataAndUpdate( bool updateParentPlot )
}
}
m_qwtPlotCurve->setSamplesFromXValuesAndYValues( times, values, isLogCurve );
m_plotCurve->setSamplesFromXValuesAndYValues( times, values, isLogCurve );
}
}
else
{
m_qwtPlotCurve->setSamplesFromTimeTAndYValues( std::vector<time_t>(), std::vector<double>(), isLogCurve );
m_plotCurve->setSamplesFromTimeTAndYValues( std::vector<time_t>(), std::vector<double>(), isLogCurve );
}
updateZoomInParentPlot();
if ( m_parentQwtPlot ) m_parentQwtPlot->replot();
if ( m_parentPlot ) m_parentPlot->replot();
}
updateQwtPlotAxis();
@ -197,17 +197,7 @@ void RimAsciiDataCurve::defineUiOrdering( QString uiConfigName, caf::PdmUiOrderi
//--------------------------------------------------------------------------------------------------
void RimAsciiDataCurve::updateQwtPlotAxis()
{
if ( m_qwtPlotCurve )
{
if ( this->yAxis() == RiaDefines::PlotAxis::PLOT_AXIS_LEFT )
{
m_qwtPlotCurve->setYAxis( QwtPlot::yLeft );
}
else
{
m_qwtPlotCurve->setYAxis( QwtPlot::yRight );
}
}
if ( m_plotCurve ) updateAxisInPlot( this->yAxis() );
}
//--------------------------------------------------------------------------------------------------

View File

@ -58,7 +58,7 @@ public:
void setTimeSteps( const std::vector<QDateTime>& timeSteps );
void setValues( const std::vector<double>& values );
void setTitle( const QString& title );
void setTitle( const QString& title ) override;
protected:
// RimPlotCurve overrides

View File

@ -53,9 +53,9 @@
#include "RiuAbstractLegendFrame.h"
#include "RiuDraggableOverlayFrame.h"
#include "RiuPlotCurve.h"
#include "RiuPlotCurveSymbol.h"
#include "RiuPlotMainWindow.h"
#include "RiuQwtPlotCurve.h"
#include "RiuSummaryQwtPlot.h"
#include "RiuSummaryVectorSelectionDialog.h"
#include "RiuTextContentFrame.h"
@ -70,23 +70,13 @@
#include "cafPdmUiTreeSelectionEditor.h"
#include "cafTitledOverlayFrame.h"
#include "cvfScalarMapper.h"
#include "qwt_plot_curve.h"
#include "qwt_symbol.h"
#include <algorithm>
//--------------------------------------------------------------------------------------------------
/// Internal constants
//--------------------------------------------------------------------------------------------------
#define DOUBLE_INF std::numeric_limits<double>::infinity()
//--------------------------------------------------------------------------------------------------
/// Internal functions
//--------------------------------------------------------------------------------------------------
RiuQwtSymbol::PointSymbolEnum statisticsCurveSymbolFromAddress( const RifEclipseSummaryAddress& address );
int statisticsCurveSymbolSize( RiuQwtSymbol::PointSymbolEnum symbol );
RiuPlotCurveSymbol::PointSymbolEnum statisticsCurveSymbolFromAddress( const RifEclipseSummaryAddress& address );
int statisticsCurveSymbolSize( RiuPlotCurveSymbol::PointSymbolEnum symbol );
CAF_PDM_SOURCE_INIT( RimEnsembleCurveSet, "RimEnsembleCurveSet" );
@ -210,8 +200,7 @@ RimEnsembleCurveSet::RimEnsembleCurveSet()
m_summaryAddressNameTools = new RimSummaryCurveAutoName;
m_qwtPlotCurveForLegendText = new QwtPlotCurve;
m_qwtPlotCurveForLegendText->setLegendAttribute( QwtPlotCurve::LegendShowSymbol, true );
m_plotCurveForLegendText = nullptr;
m_ensembleStatCase.reset( new RimEnsembleStatisticsCase( this ) );
m_ensembleStatCase->createSummaryReaderInterface();
@ -232,12 +221,12 @@ RimEnsembleCurveSet::~RimEnsembleCurveSet()
RimSummaryPlot* parentPlot;
firstAncestorOrThisOfType( parentPlot );
if ( parentPlot && parentPlot->viewer() )
if ( parentPlot && parentPlot->plotWidget() )
{
m_qwtPlotCurveForLegendText->detach();
if ( m_plotCurveForLegendText ) m_plotCurveForLegendText->detach();
if ( m_legendOverlayFrame )
{
parentPlot->viewer()->removeOverlayFrame( m_legendOverlayFrame );
parentPlot->plotWidget()->removeOverlayFrame( m_legendOverlayFrame );
}
}
if ( m_legendOverlayFrame )
@ -256,7 +245,7 @@ RimEnsembleCurveSet::~RimEnsembleCurveSet()
delete m_objectiveFunctionOverlayFrame;
}
delete m_qwtPlotCurveForLegendText;
delete m_plotCurveForLegendText;
}
//--------------------------------------------------------------------------------------------------
@ -304,44 +293,55 @@ void RimEnsembleCurveSet::loadDataAndUpdate( bool updateParentPlot )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEnsembleCurveSet::setParentQwtPlotNoReplot( QwtPlot* plot )
void RimEnsembleCurveSet::setParentPlotNoReplot( RiuPlotWidget* plot )
{
for ( RimSummaryCurve* curve : m_curves )
{
curve->setParentQwtPlotNoReplot( plot );
// TODO: attach without replotting
curve->attach( plot );
}
if ( !m_plotCurveForLegendText )
{
m_plotCurveForLegendText = plot->createPlotCurve( nullptr, "", Qt::black );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEnsembleCurveSet::detachQwtCurves()
void RimEnsembleCurveSet::detachPlotCurves()
{
for ( RimSummaryCurve* curve : m_curves )
{
curve->detachQwtCurve();
curve->detach();
}
m_qwtPlotCurveForLegendText->detach();
if ( m_plotCurveForLegendText )
{
m_plotCurveForLegendText->detach();
delete m_plotCurveForLegendText;
m_plotCurveForLegendText = nullptr;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEnsembleCurveSet::reattachQwtCurves()
void RimEnsembleCurveSet::reattachPlotCurves()
{
for ( RimSummaryCurve* curve : m_curves )
{
curve->reattachQwtCurve();
curve->reattach();
}
m_qwtPlotCurveForLegendText->detach();
RimSummaryPlot* plot = nullptr;
firstAncestorOrThisOfType( plot );
if ( plot )
if ( m_plotCurveForLegendText )
{
m_qwtPlotCurveForLegendText->attach( plot->viewer() );
m_plotCurveForLegendText->detach();
RimSummaryPlot* plot = nullptr;
firstAncestorOrThisOfType( plot );
if ( plot && plot->plotWidget() ) m_plotCurveForLegendText->attachToPlot( plot->plotWidget() );
}
}
@ -354,7 +354,7 @@ void RimEnsembleCurveSet::addCurve( RimSummaryCurve* curve )
{
RimSummaryPlot* plot;
firstAncestorOrThisOfType( plot );
if ( plot ) curve->setParentQwtPlotNoReplot( plot->viewer() );
if ( plot && plot->plotWidget() ) curve->setParentPlotNoReplot( plot->plotWidget() );
curve->setColor( m_color );
m_curves.push_back( curve );
@ -619,6 +619,15 @@ void RimEnsembleCurveSet::fieldChangedByUi( const caf::PdmFieldHandle* changedFi
if ( changedField == &m_showCurves )
{
if ( !m_showCurves() )
{
// Need to detach the legend since the plot type might change from Qwt to QtCharts.
// The plot curve for legend text needs to be recreated when curves are shown next time.
m_plotCurveForLegendText->detach();
delete m_plotCurveForLegendText;
m_plotCurveForLegendText = nullptr;
}
loadDataAndUpdate( true );
updateConnectedEditors();
@ -738,7 +747,7 @@ void RimEnsembleCurveSet::fieldChangedByUi( const caf::PdmFieldHandle* changedFi
curve->setLeftOrRightAxisY( m_plotAxis() );
}
updateQwtPlotAxis();
updatePlotAxis();
plot->updateAxes();
updateTextInPlot = true;
@ -1315,26 +1324,26 @@ void RimEnsembleCurveSet::updateFilterLegend()
{
RimSummaryPlot* plot;
firstAncestorOrThisOfType( plot );
if ( plot && plot->viewer() )
if ( plot && plot->plotWidget() )
{
if ( m_curveFilters()->isActive() && m_curveFilters()->countActiveFilters() > 0 )
{
if ( !m_filterOverlayFrame )
{
m_filterOverlayFrame =
new RiuDraggableOverlayFrame( plot->viewer()->canvas(), plot->viewer()->overlayMargins() );
new RiuDraggableOverlayFrame( plot->plotWidget(), plot->plotWidget()->overlayMargins() );
}
m_filterOverlayFrame->setContentFrame( m_curveFilters()->makeFilterDescriptionFrame() );
plot->viewer()->addOverlayFrame( m_filterOverlayFrame );
plot->plotWidget()->addOverlayFrame( m_filterOverlayFrame );
}
else
{
if ( m_filterOverlayFrame )
{
plot->viewer()->removeOverlayFrame( m_filterOverlayFrame );
plot->plotWidget()->removeOverlayFrame( m_filterOverlayFrame );
}
}
plot->viewer()->scheduleReplot();
plot->plotWidget()->scheduleReplot();
}
}
@ -1345,7 +1354,7 @@ void RimEnsembleCurveSet::updateObjectiveFunctionLegend()
{
RimSummaryPlot* plot;
firstAncestorOrThisOfType( plot );
if ( plot && plot->viewer() )
if ( plot && plot->plotWidget() )
{
if ( ( m_colorMode == ColorMode::BY_OBJECTIVE_FUNCTION || m_colorMode == ColorMode::BY_CUSTOM_OBJECTIVE_FUNCTION ) &&
m_showObjectiveFunctionFormula() )
@ -1353,7 +1362,7 @@ void RimEnsembleCurveSet::updateObjectiveFunctionLegend()
if ( !m_objectiveFunctionOverlayFrame )
{
m_objectiveFunctionOverlayFrame =
new RiuDraggableOverlayFrame( plot->viewer()->canvas(), plot->viewer()->overlayMargins() );
new RiuDraggableOverlayFrame( plot->plotWidget(), plot->plotWidget()->overlayMargins() );
}
QString title;
QString description;
@ -1385,18 +1394,18 @@ void RimEnsembleCurveSet::updateObjectiveFunctionLegend()
{
m_objectiveFunctionOverlayFrame->setContentFrame( new RiuTextContentFrame( nullptr, title, description ) );
m_objectiveFunctionOverlayFrame->setMaximumWidth( 10000 );
plot->viewer()->addOverlayFrame( m_objectiveFunctionOverlayFrame );
plot->plotWidget()->addOverlayFrame( m_objectiveFunctionOverlayFrame );
}
}
else
{
if ( m_objectiveFunctionOverlayFrame )
{
plot->viewer()->removeOverlayFrame( m_objectiveFunctionOverlayFrame );
plot->plotWidget()->removeOverlayFrame( m_objectiveFunctionOverlayFrame );
}
}
}
plot->viewer()->scheduleReplot();
plot->plotWidget()->scheduleReplot();
}
//--------------------------------------------------------------------------------------------------
@ -1565,27 +1574,27 @@ void RimEnsembleCurveSet::updateCurveColors()
RimSummaryPlot* plot;
firstAncestorOrThisOfType( plot );
if ( plot && plot->viewer() )
if ( plot && plot->plotWidget() )
{
if ( m_yValuesSummaryCaseCollection() && isCurvesVisible() && m_colorMode != ColorMode::SINGLE_COLOR &&
m_legendConfig->showLegend() )
{
if ( !m_legendOverlayFrame )
{
m_legendOverlayFrame =
new RiuDraggableOverlayFrame( plot->viewer()->canvas(), plot->viewer()->overlayMargins() );
m_legendOverlayFrame = new RiuDraggableOverlayFrame( plot->plotWidget()->getParentForOverlay(),
plot->plotWidget()->overlayMargins() );
}
m_legendOverlayFrame->setContentFrame( m_legendConfig->makeLegendFrame() );
plot->viewer()->addOverlayFrame( m_legendOverlayFrame );
plot->plotWidget()->addOverlayFrame( m_legendOverlayFrame );
}
else
{
if ( m_legendOverlayFrame )
{
plot->viewer()->removeOverlayFrame( m_legendOverlayFrame );
plot->plotWidget()->removeOverlayFrame( m_legendOverlayFrame );
}
}
plot->viewer()->scheduleReplot();
plot->plotWidget()->scheduleReplot();
}
}
@ -1638,11 +1647,11 @@ void RimEnsembleCurveSet::updateAddressesUiField()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEnsembleCurveSet::updateQwtPlotAxis()
void RimEnsembleCurveSet::updatePlotAxis()
{
for ( RimSummaryCurve* curve : curves() )
{
curve->updateQwtPlotAxis();
curve->updatePlotAxis();
}
}
@ -1656,7 +1665,7 @@ void RimEnsembleCurveSet::updateEnsembleCurves( const std::vector<RimSummaryCase
CVF_ASSERT( plot );
deleteEnsembleCurves();
m_qwtPlotCurveForLegendText->detach();
if ( m_plotCurveForLegendText ) m_plotCurveForLegendText->detach();
deleteStatisticsCurves();
if ( m_statistics->hideEnsembleCurves() ) return;
@ -1692,20 +1701,18 @@ void RimEnsembleCurveSet::updateEnsembleCurves( const std::vector<RimSummaryCase
for ( int i = 0; i < (int)newSummaryCurves.size(); ++i )
{
newSummaryCurves[i]->loadDataAndUpdate( false );
newSummaryCurves[i]->updateQwtPlotAxis();
if ( newSummaryCurves[i]->qwtPlotCurve() )
{
newSummaryCurves[i]->qwtPlotCurve()->setItemAttribute( QwtPlotItem::Legend, false );
}
newSummaryCurves[i]->updatePlotAxis();
newSummaryCurves[i]->setShowInLegend( false );
}
if ( plot->viewer() ) m_qwtPlotCurveForLegendText->attach( plot->viewer() );
if ( plot->plotWidget() && m_plotCurveForLegendText )
m_plotCurveForLegendText->attachToPlot( plot->plotWidget() );
}
if ( plot->viewer() )
if ( plot->plotWidget() )
{
if ( plot->legendsVisible() ) plot->viewer()->updateLegend();
plot->viewer()->scheduleReplot();
if ( plot->legendsVisible() ) plot->plotWidget()->updateLegend();
plot->plotWidget()->scheduleReplot();
plot->updateAxes();
plot->updatePlotInfoLabel();
}
@ -1764,35 +1771,36 @@ void RimEnsembleCurveSet::updateStatisticsCurves( const std::vector<RimSummaryCa
}
deleteStatisticsCurves();
for ( auto address : addresses )
{
auto curve = new RimSummaryCurve();
curve->setParentQwtPlotNoReplot( plot->viewer() );
m_curves.push_back( curve );
curve->setColor( m_statistics->color() );
curve->setResampling( m_resampling() );
auto symbol = statisticsCurveSymbolFromAddress( address );
curve->setSymbol( symbol );
curve->setSymbolSize( statisticsCurveSymbolSize( symbol ) );
curve->setSymbolSkipDistance( 150 );
if ( m_statistics->showCurveLabels() )
if ( plot->plotWidget() )
{
for ( auto address : addresses )
{
curve->setSymbolLabel( QString::fromStdString( address.ensembleStatisticsQuantityName() ) );
auto curve = new RimSummaryCurve();
curve->setParentPlotNoReplot( plot->plotWidget() );
m_curves.push_back( curve );
curve->setColor( m_statistics->color() );
curve->setResampling( m_resampling() );
auto symbol = statisticsCurveSymbolFromAddress( address );
curve->setSymbol( symbol );
curve->setSymbolSize( statisticsCurveSymbolSize( symbol ) );
curve->setSymbolSkipDistance( 150 );
if ( m_statistics->showCurveLabels() )
{
curve->setSymbolLabel( QString::fromStdString( address.ensembleStatisticsQuantityName() ) );
}
curve->setLineStyle( RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_SOLID );
curve->setSummaryCaseY( m_ensembleStatCase.get() );
curve->setSummaryAddressYAndApplyInterpolation( address );
curve->setLeftOrRightAxisY( m_plotAxis() );
curve->updateCurveVisibility();
curve->loadDataAndUpdate( false );
curve->updatePlotAxis();
}
curve->setLineStyle( RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_SOLID );
curve->setSummaryCaseY( m_ensembleStatCase.get() );
curve->setSummaryAddressYAndApplyInterpolation( address );
curve->setLeftOrRightAxisY( m_plotAxis() );
curve->updateCurveVisibility();
curve->loadDataAndUpdate( false );
curve->updateQwtPlotAxis();
}
if ( plot->viewer() )
{
plot->viewer()->updateLegend();
plot->plotWidget()->updateLegend();
plot->updateAxes();
}
}
@ -1839,7 +1847,7 @@ void RimEnsembleCurveSet::updateAllTextInPlot()
RimSummaryPlot* summaryPlot = nullptr;
this->firstAncestorOrThisOfTypeAsserted( summaryPlot );
if ( summaryPlot->viewer() )
if ( summaryPlot->plotWidget() )
{
summaryPlot->updatePlotTitle();
}
@ -1944,16 +1952,16 @@ bool RimEnsembleCurveSet::hasMeanData() const
//--------------------------------------------------------------------------------------------------
void RimEnsembleCurveSet::updateEnsembleLegendItem()
{
m_qwtPlotCurveForLegendText->setTitle( name() );
if ( !m_plotCurveForLegendText ) return;
m_plotCurveForLegendText->setTitle( name() );
{
QwtSymbol* symbol = nullptr;
RiuPlotCurveSymbol* symbol = m_plotCurveForLegendText->createSymbol( RiuPlotCurveSymbol::SYMBOL_CROSS );
if ( m_colorMode == ColorMode::SINGLE_COLOR )
{
symbol = new QwtSymbol( QwtSymbol::HLine );
QColor curveColor( m_color.value().rByte(), m_color.value().gByte(), m_color.value().bByte() );
QColor curveColor = RiaColorTools::toQColor( m_color );
QPen curvePen( curveColor );
curvePen.setWidth( 2 );
@ -1963,17 +1971,15 @@ void RimEnsembleCurveSet::updateEnsembleLegendItem()
else if ( m_colorMode == ColorMode::BY_ENSEMBLE_PARAM )
{
QPixmap p = QPixmap( ":/Legend.png" );
symbol = new QwtSymbol;
symbol->setPixmap( p );
symbol->setSize( 8, 8 );
}
m_qwtPlotCurveForLegendText->setSymbol( symbol );
m_plotCurveForLegendText->setSymbol( symbol );
}
bool showLegendItem = isCurvesVisible();
m_qwtPlotCurveForLegendText->setItemAttribute( QwtPlotItem::Legend, showLegendItem );
m_plotCurveForLegendText->setVisibleInLegend( showLegendItem );
}
//--------------------------------------------------------------------------------------------------
@ -2039,23 +2045,23 @@ void RimEnsembleCurveSet::updateLegendMappingMode()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuQwtSymbol::PointSymbolEnum statisticsCurveSymbolFromAddress( const RifEclipseSummaryAddress& address )
RiuPlotCurveSymbol::PointSymbolEnum statisticsCurveSymbolFromAddress( const RifEclipseSummaryAddress& address )
{
auto qName = QString::fromStdString( address.quantityName() );
if ( qName.contains( ENSEMBLE_STAT_P10_QUANTITY_NAME ) ) return RiuQwtSymbol::SYMBOL_TRIANGLE;
if ( qName.contains( ENSEMBLE_STAT_P90_QUANTITY_NAME ) ) return RiuQwtSymbol::SYMBOL_DOWN_TRIANGLE;
if ( qName.contains( ENSEMBLE_STAT_P50_QUANTITY_NAME ) ) return RiuQwtSymbol::SYMBOL_DIAMOND;
return RiuQwtSymbol::SYMBOL_ELLIPSE;
if ( qName.contains( ENSEMBLE_STAT_P10_QUANTITY_NAME ) ) return RiuPlotCurveSymbol::SYMBOL_TRIANGLE;
if ( qName.contains( ENSEMBLE_STAT_P90_QUANTITY_NAME ) ) return RiuPlotCurveSymbol::SYMBOL_DOWN_TRIANGLE;
if ( qName.contains( ENSEMBLE_STAT_P50_QUANTITY_NAME ) ) return RiuPlotCurveSymbol::SYMBOL_DIAMOND;
return RiuPlotCurveSymbol::SYMBOL_ELLIPSE;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int statisticsCurveSymbolSize( RiuQwtSymbol::PointSymbolEnum symbol )
int statisticsCurveSymbolSize( RiuPlotCurveSymbol::PointSymbolEnum symbol )
{
if ( symbol == RiuQwtSymbol::SYMBOL_DIAMOND ) return 8;
if ( symbol == RiuQwtSymbol::SYMBOL_TRIANGLE ) return 7;
if ( symbol == RiuQwtSymbol::SYMBOL_DOWN_TRIANGLE ) return 7;
if ( symbol == RiuPlotCurveSymbol::SYMBOL_DIAMOND ) return 8;
if ( symbol == RiuPlotCurveSymbol::SYMBOL_TRIANGLE ) return 7;
if ( symbol == RiuPlotCurveSymbol::SYMBOL_DOWN_TRIANGLE ) return 7;
return 6;
}

View File

@ -22,7 +22,7 @@
#include "RifEclipseSummaryAddressQMetaType.h"
#include "RifSummaryReaderInterface.h"
#include "RiaDefines.h"
#include "RiaPlotDefines.h"
#include "RiaQDateTimeTools.h"
#include "RimEnsembleCurveSetColorManager.h"
@ -61,6 +61,8 @@ class RiuDraggableOverlayFrame;
class RiaSummaryCurveDefinitionAnalyser;
class RiaSummaryCurveDefinition;
class RiuSummaryVectorSelectionDialog;
class RiuPlotWidget;
class RiuPlotCurve;
class QwtPlot;
class QwtPlotCurve;
@ -92,9 +94,9 @@ public:
void setColor( cvf::Color3f color );
void loadDataAndUpdate( bool updateParentPlot );
void setParentQwtPlotNoReplot( QwtPlot* plot );
void detachQwtCurves();
void reattachQwtCurves();
void setParentPlotNoReplot( RiuPlotWidget* plot );
void detachPlotCurves();
void reattachPlotCurves();
void addCurve( RimSummaryCurve* curve );
void deleteCurve( RimSummaryCurve* curve );
@ -184,7 +186,7 @@ private:
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
void updateQwtPlotAxis();
void updatePlotAxis();
QString createAutoName() const;
@ -241,7 +243,7 @@ private:
caf::PdmProxyValueField<QString> m_autoGeneratedName;
caf::PdmChildField<RimSummaryCurveAutoName*> m_summaryAddressNameTools;
QwtPlotCurve* m_qwtPlotCurveForLegendText;
RiuPlotCurve* m_plotCurveForLegendText;
QPointer<RiuDraggableOverlayFrame> m_legendOverlayFrame;
QPointer<RiuDraggableOverlayFrame> m_filterOverlayFrame;
QPointer<RiuDraggableOverlayFrame> m_objectiveFunctionOverlayFrame;

View File

@ -29,9 +29,7 @@
#include "RimSummaryPlot.h"
#include "RimSummaryPlotSourceStepping.h"
#include "RiuQwtPlotCurve.h"
#include "qwt_plot.h"
#include "RiuPlotCurve.h"
CAF_PDM_SOURCE_INIT( RimEnsembleCurveSetCollection, "RimEnsembleCurveSetCollection" );
@ -94,11 +92,11 @@ void RimEnsembleCurveSetCollection::loadDataAndUpdate( bool updateParentPlot )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEnsembleCurveSetCollection::setParentQwtPlotAndReplot( QwtPlot* plot )
void RimEnsembleCurveSetCollection::setParentPlotAndReplot( RiuPlotWidget* plot )
{
for ( RimEnsembleCurveSet* curveSet : m_curveSets )
{
curveSet->setParentQwtPlotNoReplot( plot );
curveSet->setParentPlotNoReplot( plot );
}
if ( plot ) plot->replot();
@ -107,35 +105,35 @@ void RimEnsembleCurveSetCollection::setParentQwtPlotAndReplot( QwtPlot* plot )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEnsembleCurveSetCollection::detachQwtCurves()
void RimEnsembleCurveSetCollection::detachPlotCurves()
{
for ( const auto& curveSet : m_curveSets )
{
curveSet->detachQwtCurves();
curveSet->detachPlotCurves();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEnsembleCurveSetCollection::reattachQwtCurves()
void RimEnsembleCurveSetCollection::reattachPlotCurves()
{
for ( const auto& curveSet : m_curveSets )
{
curveSet->reattachQwtCurves();
curveSet->reattachPlotCurves();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimSummaryCurve* RimEnsembleCurveSetCollection::findRimCurveFromQwtCurve( const QwtPlotCurve* qwtCurve ) const
RimSummaryCurve* RimEnsembleCurveSetCollection::findRimCurveFromPlotCurve( const RiuPlotCurve* curve ) const
{
for ( RimEnsembleCurveSet* curveSet : m_curveSets )
{
for ( RimSummaryCurve* rimCurve : curveSet->curves() )
{
if ( rimCurve->qwtPlotCurve() == qwtCurve )
if ( rimCurve->isSameCurve( curve ) )
{
return rimCurve;
}
@ -148,13 +146,13 @@ RimSummaryCurve* RimEnsembleCurveSetCollection::findRimCurveFromQwtCurve( const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimEnsembleCurveSet* RimEnsembleCurveSetCollection::findRimCurveSetFromQwtCurve( const QwtPlotCurve* qwtCurve ) const
RimEnsembleCurveSet* RimEnsembleCurveSetCollection::findCurveSetFromPlotCurve( const RiuPlotCurve* curve ) const
{
for ( RimEnsembleCurveSet* curveSet : m_curveSets )
{
for ( RimSummaryCurve* rimCurve : curveSet->curves() )
{
if ( rimCurve->qwtPlotCurve() == qwtCurve )
if ( rimCurve->isSameCurve( curve ) )
{
return curveSet;
}

View File

@ -18,6 +18,7 @@
#pragma once
#include "RiuPlotWidget.h"
#include "cafPdmChildArrayField.h"
#include "cafPdmChildField.h"
#include "cafPdmField.h"
@ -26,8 +27,7 @@
class RimEnsembleCurveSet;
class RimSummaryPlotSourceStepping;
class RimSummaryCurve;
class QwtPlot;
class QwtPlotCurve;
class RiuPlotCurve;
//==================================================================================================
///
@ -43,12 +43,12 @@ public:
bool isCurveSetsVisible();
void loadDataAndUpdate( bool updateParentPlot );
void setParentQwtPlotAndReplot( QwtPlot* plot );
void detachQwtCurves();
void reattachQwtCurves();
void setParentPlotAndReplot( RiuPlotWidget* plot );
void detachPlotCurves();
void reattachPlotCurves();
RimSummaryCurve* findRimCurveFromQwtCurve( const QwtPlotCurve* qwtCurve ) const;
RimEnsembleCurveSet* findRimCurveSetFromQwtCurve( const QwtPlotCurve* qwtCurve ) const;
RimSummaryCurve* findRimCurveFromPlotCurve( const RiuPlotCurve* qwtCurve ) const;
RimEnsembleCurveSet* findCurveSetFromPlotCurve( const RiuPlotCurve* qwtCurve ) const;
void addCurveSet( RimEnsembleCurveSet* curveSet );
void deleteCurveSet( RimEnsembleCurveSet* curveSet );

View File

@ -55,9 +55,6 @@
#include "cafPdmUiPushButtonEditor.h"
#include "cafPdmUiTreeOrdering.h"
#include "qwt_date.h"
#include "qwt_plot.h"
CAF_PDM_SOURCE_INIT( RimSummaryCurve, "SummaryCurve" );
//--------------------------------------------------------------------------------------------------
@ -153,7 +150,7 @@ void RimSummaryCurve::setSummaryCaseY( RimSummaryCase* sumCase )
{
if ( m_yValuesSummaryCase != sumCase )
{
m_qwtCurveErrorBars->setSamples( nullptr );
clearErrorBars();
}
bool isEnsembleCurve = false;
@ -215,7 +212,7 @@ void RimSummaryCurve::setSummaryAddressY( const RifEclipseSummaryAddress& addres
{
if ( m_yValuesSummaryAddress->address() != address )
{
m_qwtCurveErrorBars->setSamples( nullptr );
clearErrorBars();
}
m_yValuesSummaryAddress->setAddress( address );
@ -392,10 +389,7 @@ double RimSummaryCurve::yValueAtTimeT( time_t time ) const
//--------------------------------------------------------------------------------------------------
void RimSummaryCurve::setOverrideCurveDataY( const std::vector<time_t>& dateTimes, const std::vector<double>& yValues )
{
if ( m_qwtPlotCurve )
{
m_qwtPlotCurve->setSamplesFromTimeTAndYValues( dateTimes, yValues, true );
}
setSamplesFromTimeTAndYValues( dateTimes, yValues, true );
}
//--------------------------------------------------------------------------------------------------
@ -558,7 +552,7 @@ void RimSummaryCurve::updateZoomInParentPlot()
RimSummaryPlot* plot = nullptr;
firstAncestorOrThisOfTypeAsserted( plot );
plot->updateZoomInQwt();
plot->updateZoomInParentPlot();
}
//--------------------------------------------------------------------------------------------------
@ -699,14 +693,14 @@ void RimSummaryCurve::onLoadDataAndUpdate( bool updateParentPlot )
this->setSamplesFromXYValues( std::vector<double>(), std::vector<double>(), isLogCurve );
}
if ( updateParentPlot && m_parentQwtPlot )
if ( updateParentPlot && hasParentPlot() )
{
updateZoomInParentPlot();
m_parentQwtPlot->replot();
replotParentPlot();
}
}
if ( updateParentPlot ) updateQwtPlotAxis();
if ( updateParentPlot ) updateAxisInPlot( axisY() );
}
//--------------------------------------------------------------------------------------------------
@ -909,19 +903,9 @@ RiaDefines::PhaseType RimSummaryCurve::phaseType() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryCurve::updateQwtPlotAxis()
void RimSummaryCurve::updatePlotAxis()
{
if ( m_qwtPlotCurve )
{
if ( this->axisY() == RiaDefines::PlotAxis::PLOT_AXIS_LEFT )
{
m_qwtPlotCurve->setYAxis( QwtPlot::yLeft );
}
else
{
m_qwtPlotCurve->setYAxis( QwtPlot::yRight );
}
}
updateAxisInPlot( axisY() );
}
//--------------------------------------------------------------------------------------------------
@ -942,7 +926,7 @@ QString RimSummaryCurve::curveExportDescription( const RifEclipseSummaryAddress&
RimEnsembleCurveSetCollection* coll;
firstAncestorOrThisOfType( coll );
auto curveSet = coll ? coll->findRimCurveSetFromQwtCurve( m_qwtPlotCurve ) : nullptr;
auto curveSet = coll ? coll->findCurveSetFromPlotCurve( m_plotCurve ) : nullptr;
auto group = curveSet ? curveSet->summaryCaseCollection() : nullptr;
auto addressUiText = addr.uiText();
@ -970,7 +954,7 @@ void RimSummaryCurve::setCurveAppearanceFromCaseType()
if ( m_yValuesSummaryCase->isObservedData() )
{
setLineStyle( RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_NONE );
setSymbol( RiuQwtSymbol::SYMBOL_XCROSS );
setSymbol( RiuPlotCurveSymbol::SYMBOL_XCROSS );
return;
}
@ -984,7 +968,7 @@ void RimSummaryCurve::setCurveAppearanceFromCaseType()
{
setSymbolEdgeColor( m_curveAppearance->color() );
setSymbol( RiuQwtSymbol::SYMBOL_XCROSS );
setSymbol( RiuPlotCurveSymbol::SYMBOL_XCROSS );
setLineStyle( RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_NONE );
}
else if ( prefs->defaultSummaryHistoryCurveStyle() ==
@ -992,12 +976,12 @@ void RimSummaryCurve::setCurveAppearanceFromCaseType()
{
setSymbolEdgeColor( m_curveAppearance->color() );
setSymbol( RiuQwtSymbol::SYMBOL_XCROSS );
setSymbol( RiuPlotCurveSymbol::SYMBOL_XCROSS );
setLineStyle( RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_SOLID );
}
else if ( prefs->defaultSummaryHistoryCurveStyle() == RiaPreferencesSummary::SummaryHistoryCurveStyleMode::LINES )
{
setSymbol( RiuQwtSymbol::SYMBOL_NONE );
setSymbol( RiuPlotCurveSymbol::SYMBOL_NONE );
setLineStyle( RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_SOLID );
}
@ -1063,8 +1047,7 @@ void RimSummaryCurve::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
}
else if ( changedField == &m_plotAxis )
{
updateQwtPlotAxis();
updateAxisInPlot( axisY() );
plot->updateAxes();
dataChanged.send();
}
@ -1075,7 +1058,7 @@ void RimSummaryCurve::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
{
// If no previous case selected and observed data, use symbols to indicate observed data curve
setLineStyle( RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_NONE );
setSymbol( RiuQwtSymbol::SYMBOL_XCROSS );
setSymbol( RiuPlotCurveSymbol::SYMBOL_XCROSS );
}
plot->updateCaseNameHasChanged();

View File

@ -87,7 +87,7 @@ public:
bool isEnsembleCurve() const;
void setIsEnsembleCurve( bool isEnsembleCurve );
void updateQwtPlotAxis();
void updatePlotAxis();
void applyCurveAutoNameSettings( const RimSummaryCurveAutoName& autoNameSettings );
QString curveExportDescription( const RifEclipseSummaryAddress& address = RifEclipseSummaryAddress() ) const override;

View File

@ -245,8 +245,8 @@ std::map<std::string, size_t>
}
else if ( appearance == CurveAppearanceType::SYMBOL )
{
numOptions = caf::AppEnum<RiuQwtSymbol::PointSymbolEnum>::size() - 1; // -1 since the No symbol option is not
// counted see cycledSymbol()
numOptions = caf::AppEnum<RiuPlotCurveSymbol::PointSymbolEnum>::size() - 1; // -1 since the No symbol option is
// not counted see cycledSymbol()
}
else if ( appearance == CurveAppearanceType::LINE_STYLE )
{
@ -524,12 +524,12 @@ RiuQwtPlotCurveDefines::LineStyleEnum RimSummaryCurveAppearanceCalculator::cycle
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuQwtSymbol::PointSymbolEnum RimSummaryCurveAppearanceCalculator::cycledSymbol( int index )
RiuPlotCurveSymbol::PointSymbolEnum RimSummaryCurveAppearanceCalculator::cycledSymbol( int index )
{
if ( index < 0 ) return RiuQwtSymbol::SYMBOL_NONE;
if ( index < 0 ) return RiuPlotCurveSymbol::SYMBOL_NONE;
return caf::AppEnum<RiuQwtSymbol::PointSymbolEnum>::fromIndex(
1 + ( index % ( caf::AppEnum<RiuQwtSymbol::PointSymbolEnum>::size() - 1 ) ) );
return caf::AppEnum<RiuPlotCurveSymbol::PointSymbolEnum>::fromIndex(
1 + ( index % ( caf::AppEnum<RiuPlotCurveSymbol::PointSymbolEnum>::size() - 1 ) ) );
}
//--------------------------------------------------------------------------------------------------

View File

@ -17,8 +17,8 @@
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RiuPlotCurveSymbol.h"
#include "RiuQwtPlotCurveDefines.h"
#include "RiuQwtSymbol.h"
#include "cvfColor3.h"
@ -57,13 +57,13 @@ public:
void setupCurveLook( RimSummaryCurve* curve );
static cvf::Color3f cycledPaletteColor( int colorIndex );
static cvf::Color3f cycledNoneRGBBrColor( int colorIndex );
static cvf::Color3f cycledGreenColor( int colorIndex );
static cvf::Color3f cycledBlueColor( int colorIndex );
static cvf::Color3f cycledRedColor( int colorIndex );
static cvf::Color3f cycledBrownColor( int colorIndex );
static RiuQwtSymbol::PointSymbolEnum cycledSymbol( int index );
static cvf::Color3f cycledPaletteColor( int colorIndex );
static cvf::Color3f cycledNoneRGBBrColor( int colorIndex );
static cvf::Color3f cycledGreenColor( int colorIndex );
static cvf::Color3f cycledBlueColor( int colorIndex );
static cvf::Color3f cycledRedColor( int colorIndex );
static cvf::Color3f cycledBrownColor( int colorIndex );
static RiuPlotCurveSymbol::PointSymbolEnum cycledSymbol( int index );
private:
void setOneCurveAppearance( CurveAppearanceType appeaType, size_t totalCount, int appeaIdx, RimSummaryCurve* curve );

View File

@ -109,7 +109,7 @@ void RimSummaryCurveCollection::loadDataAndUpdate( bool updateParentPlot )
for ( RimSummaryCurve* curve : m_curves )
{
curve->loadDataAndUpdate( false );
curve->updateQwtPlotAxis();
curve->updatePlotAxis();
}
if ( updateParentPlot )
@ -123,11 +123,11 @@ void RimSummaryCurveCollection::loadDataAndUpdate( bool updateParentPlot )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryCurveCollection::setParentQwtPlotAndReplot( QwtPlot* plot )
void RimSummaryCurveCollection::setParentPlotAndReplot( RiuPlotWidget* plot )
{
for ( RimSummaryCurve* curve : m_curves )
{
curve->setParentQwtPlotNoReplot( plot );
curve->setParentPlotNoReplot( plot );
}
if ( plot ) plot->replot();
@ -136,33 +136,33 @@ void RimSummaryCurveCollection::setParentQwtPlotAndReplot( QwtPlot* plot )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryCurveCollection::detachQwtCurves()
void RimSummaryCurveCollection::detachPlotCurves()
{
for ( RimSummaryCurve* curve : m_curves )
{
curve->detachQwtCurve();
curve->detach();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryCurveCollection::reattachQwtCurves()
void RimSummaryCurveCollection::reattachPlotCurves()
{
for ( RimSummaryCurve* curve : m_curves )
{
curve->reattachQwtCurve();
curve->reattach();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimSummaryCurve* RimSummaryCurveCollection::findRimCurveFromQwtCurve( const QwtPlotCurve* qwtCurve ) const
RimSummaryCurve* RimSummaryCurveCollection::findRimCurveFromPlotCurve( const RiuPlotCurve* curve ) const
{
for ( RimSummaryCurve* rimCurve : m_curves )
{
if ( rimCurve->qwtPlotCurve() == qwtCurve )
if ( rimCurve->isSameCurve( curve ) )
{
return rimCurve;
}
@ -342,7 +342,7 @@ void RimSummaryCurveCollection::updateCaseNameHasChanged()
firstAncestorOrThisOfTypeAsserted( parentPlot );
parentPlot->updatePlotTitle();
if ( parentPlot->viewer() ) parentPlot->viewer()->updateLegend();
if ( parentPlot->plotWidget() ) parentPlot->plotWidget()->updateLegend();
}
//--------------------------------------------------------------------------------------------------

View File

@ -26,12 +26,12 @@
#include "cafPdmObject.h"
#include "cafPdmPtrArrayField.h"
class QwtPlot;
class QwtPlotCurve;
class RimSummaryCase;
class RimSummaryCurve;
class RimSummaryCrossPlot;
class RimSummaryPlot;
class RiuPlotWidget;
class RiuPlotCurve;
class QKeyEvent;
//==================================================================================================
@ -63,11 +63,11 @@ public:
void loadDataAndUpdate( bool updateParentPlot );
private:
void setParentQwtPlotAndReplot( QwtPlot* plot );
void detachQwtCurves();
void reattachQwtCurves();
void setParentPlotAndReplot( RiuPlotWidget* plot );
void detachPlotCurves();
void reattachPlotCurves();
RimSummaryCurve* findRimCurveFromQwtCurve( const QwtPlotCurve* qwtCurve ) const;
RimSummaryCurve* findRimCurveFromPlotCurve( const RiuPlotCurve* curve ) const;
void addCurve( RimSummaryCurve* curve );
void insertCurve( RimSummaryCurve* curve, size_t index );

View File

@ -19,11 +19,14 @@
#include "RimSummaryPlot.h"
#include "RiaColorTables.h"
#include "RiaDefines.h"
#include "RiaFieldHandleTools.h"
#include "RiaPlotDefines.h"
#include "RiaSummaryAddressAnalyzer.h"
#include "RiaSummaryCurveDefinition.h"
#include "RiaSummaryTools.h"
#include "RiaTimeHistoryCurveResampler.h"
#include "RicfCommandObject.h"
#include "SummaryPlotCommands/RicSummaryPlotEditorUi.h"
@ -35,6 +38,7 @@
#include "RimEnsembleCurveSetCollection.h"
#include "RimGridTimeHistoryCurve.h"
#include "RimMultiPlot.h"
#include "RimPlotAxisLogRangeCalculator.h"
#include "RimPlotAxisProperties.h"
#include "RimProject.h"
#include "RimSummaryCase.h"
@ -50,6 +54,10 @@
#include "RiuSummaryQwtPlot.h"
#include "RiuTreeViewEventFilter.h"
#ifdef USE_QTCHARTS
#include "RiuSummaryQtChartsPlot.h"
#endif
#include "cvfColor3.h"
#include "cafPdmFieldScriptingCapability.h"
@ -57,12 +65,9 @@
#include "cafPdmUiTreeOrdering.h"
#include "cafSelectionManager.h"
#include "qwt_abstract_legend.h"
#include "qwt_legend.h"
#include "qwt_plot.h"
#include "qwt_plot_curve.h"
#include "qwt_plot_renderer.h"
#include "qwt_plot_textlabel.h"
#include "qwt_scale_engine.h"
#include <QDateTime>
#include <QDebug>
@ -203,7 +208,9 @@ RimSummaryPlot::RimSummaryPlot()
CAF_PDM_InitScriptableField( &m_useAutoPlotTitle, "IsUsingAutoName", true, "Auto Title" );
CAF_PDM_InitScriptableField( &m_description, "PlotDescription", QString( "Summary Plot" ), "Name" );
CAF_PDM_InitScriptableField( &m_normalizeCurveYValues, "normalizeCurveYValues", false, "Normalize all curves" );
#ifdef USE_QTCHARTS
CAF_PDM_InitScriptableField( &m_useQtChartsPlot, "useQtChartsPlot", false, "Use Qt Charts" );
#endif
CAF_PDM_InitFieldNoDefault( &m_summaryCurveCollection, "SummaryCurveCollection", "" );
m_summaryCurveCollection.uiCapability()->setUiTreeHidden( true );
m_summaryCurveCollection = new RimSummaryCurveCollection;
@ -222,17 +229,17 @@ RimSummaryPlot::RimSummaryPlot()
CAF_PDM_InitFieldNoDefault( &m_leftYAxisProperties, "LeftYAxisProperties", "Left Y Axis" );
m_leftYAxisProperties.uiCapability()->setUiTreeHidden( true );
m_leftYAxisProperties = new RimPlotAxisProperties;
m_leftYAxisProperties->setNameAndAxis( "Left Y-Axis", QwtPlot::yLeft );
m_leftYAxisProperties->setNameAndAxis( "Left Y-Axis", RiaDefines::PlotAxis::PLOT_AXIS_LEFT );
CAF_PDM_InitFieldNoDefault( &m_rightYAxisProperties, "RightYAxisProperties", "Right Y Axis" );
m_rightYAxisProperties.uiCapability()->setUiTreeHidden( true );
m_rightYAxisProperties = new RimPlotAxisProperties;
m_rightYAxisProperties->setNameAndAxis( "Right Y-Axis", QwtPlot::yRight );
m_rightYAxisProperties->setNameAndAxis( "Right Y-Axis", RiaDefines::PlotAxis::PLOT_AXIS_RIGHT );
CAF_PDM_InitFieldNoDefault( &m_bottomAxisProperties, "BottomAxisProperties", "Bottom X Axis" );
m_bottomAxisProperties.uiCapability()->setUiTreeHidden( true );
m_bottomAxisProperties = new RimPlotAxisProperties;
m_bottomAxisProperties->setNameAndAxis( "Bottom X-Axis", QwtPlot::xBottom );
m_bottomAxisProperties->setNameAndAxis( "Bottom X-Axis", RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM );
connectAxisSignals( m_leftYAxisProperties() );
connectAxisSignals( m_rightYAxisProperties() );
@ -282,13 +289,13 @@ void RimSummaryPlot::updateAxes()
updateYAxis( RiaDefines::PlotAxis::PLOT_AXIS_LEFT );
updateYAxis( RiaDefines::PlotAxis::PLOT_AXIS_RIGHT );
if ( m_timeAxisProperties() && m_plotWidget )
if ( m_timeAxisProperties() && plotWidget() )
{
m_plotWidget->updateAnnotationObjects( m_timeAxisProperties() );
m_summaryPlot->updateAnnotationObjects( m_timeAxisProperties() );
}
if ( m_leftYAxisProperties() && m_plotWidget )
if ( m_leftYAxisProperties() && plotWidget() )
{
m_plotWidget->updateAnnotationObjects( m_leftYAxisProperties() );
m_summaryPlot->updateAnnotationObjects( m_leftYAxisProperties() );
}
if ( m_isCrossPlot )
@ -300,9 +307,9 @@ void RimSummaryPlot::updateAxes()
updateTimeAxis();
}
m_plotWidget->scheduleReplot();
plotWidget()->scheduleReplot();
updateZoomInQwt();
updateZoomInParentPlot();
}
//--------------------------------------------------------------------------------------------------
@ -352,15 +359,17 @@ time_t RimSummaryPlot::firstTimeStepOfFirstCurve()
//--------------------------------------------------------------------------------------------------
QWidget* RimSummaryPlot::viewWidget()
{
return m_plotWidget;
return plotWidget();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuQwtPlotWidget* RimSummaryPlot::viewer()
RiuPlotWidget* RimSummaryPlot::plotWidget()
{
return m_plotWidget;
if ( !m_summaryPlot ) return nullptr;
return m_summaryPlot->plotWidget();
}
//--------------------------------------------------------------------------------------------------
@ -421,11 +430,11 @@ QString RimSummaryPlot::asciiDataForSummaryPlotExport( RiaQDateTimeTools::DateTi
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmObject* RimSummaryPlot::findPdmObjectFromQwtCurve( const QwtPlotCurve* qwtCurve ) const
caf::PdmObject* RimSummaryPlot::findPdmObjectFromPlotCurve( const RiuPlotCurve* plotCurve ) const
{
for ( RimGridTimeHistoryCurve* curve : m_gridTimeHistoryCurves )
{
if ( curve->qwtPlotCurve() == qwtCurve )
if ( curve->isSameCurve( plotCurve ) )
{
return curve;
}
@ -433,7 +442,7 @@ caf::PdmObject* RimSummaryPlot::findPdmObjectFromQwtCurve( const QwtPlotCurve* q
for ( RimAsciiDataCurve* curve : m_asciiDataCurves )
{
if ( curve->qwtPlotCurve() == qwtCurve )
if ( curve->isSameCurve( plotCurve ) )
{
return curve;
}
@ -441,7 +450,7 @@ caf::PdmObject* RimSummaryPlot::findPdmObjectFromQwtCurve( const QwtPlotCurve* q
if ( m_summaryCurveCollection )
{
RimSummaryCurve* foundCurve = m_summaryCurveCollection->findRimCurveFromQwtCurve( qwtCurve );
RimSummaryCurve* foundCurve = m_summaryCurveCollection->findRimCurveFromPlotCurve( plotCurve );
if ( foundCurve )
{
@ -453,7 +462,7 @@ caf::PdmObject* RimSummaryPlot::findPdmObjectFromQwtCurve( const QwtPlotCurve* q
if ( m_ensembleCurveSetCollection )
{
RimSummaryCurve* foundCurve = m_ensembleCurveSetCollection->findRimCurveFromQwtCurve( qwtCurve );
RimSummaryCurve* foundCurve = m_ensembleCurveSetCollection->findRimCurveFromPlotCurve( plotCurve );
if ( foundCurve )
{
@ -671,12 +680,12 @@ void RimSummaryPlot::updatePlotTitle()
updateCurveNames();
updateMdiWindowTitle();
if ( m_plotWidget )
if ( plotWidget() )
{
QString plotTitle = description();
m_plotWidget->setPlotTitle( plotTitle );
m_plotWidget->setPlotTitleEnabled( m_showPlotTitle && !isSubPlot() );
m_plotWidget->scheduleReplot();
plotWidget()->setPlotTitle( plotTitle );
plotWidget()->setPlotTitleEnabled( m_showPlotTitle && !isSubPlot() );
plotWidget()->scheduleReplot();
}
}
@ -736,10 +745,10 @@ void RimSummaryPlot::copyAxisPropertiesFromOther( const RimSummaryPlot& sourceSu
//--------------------------------------------------------------------------------------------------
void RimSummaryPlot::updateAll()
{
if ( m_plotWidget )
if ( plotWidget() )
{
updatePlotTitle();
m_plotWidget->updateLegend();
plotWidget()->updateLegend();
updateAxes();
}
}
@ -749,15 +758,15 @@ void RimSummaryPlot::updateAll()
//--------------------------------------------------------------------------------------------------
void RimSummaryPlot::updateLegend()
{
if ( m_plotWidget )
if ( plotWidget() )
{
m_plotWidget->setInternalLegendVisible( m_showPlotLegends && !isSubPlot() );
plotWidget()->setInternalLegendVisible( m_showPlotLegends && !isSubPlot() );
}
reattachAllCurves();
if ( m_plotWidget )
if ( plotWidget() )
{
m_plotWidget->updateLegend();
plotWidget()->updateLegend();
}
}
@ -783,8 +792,11 @@ void RimSummaryPlot::setPlotInfoLabel( const QString& label )
//--------------------------------------------------------------------------------------------------
void RimSummaryPlot::showPlotInfoLabel( bool show )
{
RiuQwtPlotWidget* qwtPlotWidget = dynamic_cast<RiuQwtPlotWidget*>( plotWidget() );
if ( !qwtPlotWidget ) return;
if ( show )
m_plotInfoLabel->attach( m_plotWidget );
m_plotInfoLabel->attach( qwtPlotWidget->qwtPlot() );
else
m_plotInfoLabel->detach();
}
@ -881,22 +893,12 @@ bool RimSummaryPlot::isNormalizationEnabled()
//--------------------------------------------------------------------------------------------------
void RimSummaryPlot::updateYAxis( RiaDefines::PlotAxis plotAxis )
{
if ( !m_plotWidget ) return;
QwtPlot::Axis qwtAxis = QwtPlot::yLeft;
if ( plotAxis == RiaDefines::PlotAxis::PLOT_AXIS_LEFT )
{
qwtAxis = QwtPlot::yLeft;
}
else
{
qwtAxis = QwtPlot::yRight;
}
if ( !plotWidget() ) return;
RimPlotAxisProperties* yAxisProperties = yAxisPropertiesLeftOrRight( plotAxis );
if ( yAxisProperties->isActive() && hasVisibleCurvesForAxis( plotAxis ) )
{
m_plotWidget->enableAxis( qwtAxis, true );
plotWidget()->enableAxis( plotAxis, true );
std::set<QString> timeHistoryQuantities;
@ -910,11 +912,11 @@ void RimSummaryPlot::updateYAxis( RiaDefines::PlotAxis plotAxis )
{},
visibleAsciiDataCurvesForAxis( plotAxis ),
timeHistoryQuantities );
calc.applyAxisPropertiesToPlot( m_plotWidget );
calc.applyAxisPropertiesToPlot( plotWidget() );
}
else
{
m_plotWidget->enableAxis( qwtAxis, false );
plotWidget()->enableAxis( plotAxis, false );
}
}
@ -929,11 +931,11 @@ void RimSummaryPlot::updateZoomForAxis( RiaDefines::PlotAxis plotAxis )
{
if ( m_bottomAxisProperties->isAutoZoom() )
{
m_plotWidget->setAxisAutoScale( QwtPlot::xBottom, true );
plotWidget()->setAxisAutoScale( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM, true );
}
else
{
m_plotWidget->setAxisScale( QwtPlot::xBottom,
plotWidget()->setAxisScale( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM,
m_bottomAxisProperties->visibleRangeMin(),
m_bottomAxisProperties->visibleRangeMax() );
}
@ -942,11 +944,11 @@ void RimSummaryPlot::updateZoomForAxis( RiaDefines::PlotAxis plotAxis )
{
if ( m_timeAxisProperties->isAutoZoom() )
{
m_plotWidget->setAxisAutoScale( QwtPlot::xBottom, true );
plotWidget()->setAxisAutoScale( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM, true );
}
else
{
m_plotWidget->setAxisScale( QwtPlot::xBottom,
plotWidget()->setAxisScale( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM,
m_timeAxisProperties->visibleRangeMin(),
m_timeAxisProperties->visibleRangeMax() );
}
@ -958,29 +960,29 @@ void RimSummaryPlot::updateZoomForAxis( RiaDefines::PlotAxis plotAxis )
if ( yAxisProps->isAutoZoom() )
{
m_plotWidget->setAxisIsLogarithmic( yAxisProps->qwtPlotAxisType(), yAxisProps->isLogarithmicScaleEnabled );
if ( yAxisProps->isLogarithmicScaleEnabled )
{
std::vector<const QwtPlotCurve*> plotCurves;
plotWidget()->setAxisScaleType( yAxisProps->plotAxisType(), RiuQwtPlotWidget::AxisScaleType::LOGARITHMIC );
std::vector<const RimPlotCurve*> plotCurves;
for ( RimSummaryCurve* c : visibleSummaryCurvesForAxis( plotAxis ) )
{
plotCurves.push_back( c->qwtPlotCurve() );
plotCurves.push_back( c );
}
for ( RimGridTimeHistoryCurve* c : visibleTimeHistoryCurvesForAxis( plotAxis ) )
{
plotCurves.push_back( c->qwtPlotCurve() );
plotCurves.push_back( c );
}
for ( RimAsciiDataCurve* c : visibleAsciiDataCurvesForAxis( plotAxis ) )
{
plotCurves.push_back( c->qwtPlotCurve() );
plotCurves.push_back( c );
}
double min, max;
RimPlotAxisLogRangeCalculator calc( QwtPlot::yLeft, plotCurves );
RimPlotAxisLogRangeCalculator calc( RiaDefines::PlotAxis::PLOT_AXIS_LEFT, plotCurves );
calc.computeAxisRange( &min, &max );
if ( yAxisProps->isAxisInverted() )
@ -988,22 +990,21 @@ void RimSummaryPlot::updateZoomForAxis( RiaDefines::PlotAxis plotAxis )
std::swap( min, max );
}
m_plotWidget->setAxisScale( yAxisProps->qwtPlotAxisType(), min, max );
plotWidget()->setAxisScale( yAxisProps->plotAxisType(), min, max );
}
else
{
m_plotWidget->setAxisAutoScale( yAxisProps->qwtPlotAxisType(), true );
plotWidget()->setAxisAutoScale( yAxisProps->plotAxisType(), true );
}
}
else
{
m_plotWidget->setAxisScale( yAxisProps->qwtPlotAxisType(),
plotWidget()->setAxisScale( yAxisProps->plotAxisType(),
yAxisProps->visibleRangeMin(),
yAxisProps->visibleRangeMax() );
}
m_plotWidget->axisScaleEngine( yAxisProps->qwtPlotAxisType() )
->setAttribute( QwtScaleEngine::Inverted, yAxisProps->isAxisInverted() );
plotWidget()->setAxisInverted( yAxisProps->plotAxisType(), yAxisProps->isAxisInverted() );
}
}
@ -1149,11 +1150,11 @@ std::vector<RimAsciiDataCurve*> RimSummaryPlot::visibleAsciiDataCurvesForAxis( R
//--------------------------------------------------------------------------------------------------
void RimSummaryPlot::updateTimeAxis()
{
if ( !m_plotWidget ) return;
if ( !plotWidget() ) return;
if ( !m_timeAxisProperties->isActive() )
{
m_plotWidget->enableAxis( QwtPlot::xBottom, false );
plotWidget()->enableAxis( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM, false );
return;
}
@ -1166,14 +1167,14 @@ void RimSummaryPlot::updateTimeAxis()
QString dateFormat = m_timeAxisProperties->dateFormat();
QString timeFormat = m_timeAxisProperties->timeFormat();
m_plotWidget->useDateBasedTimeAxis( dateFormat, timeFormat, dateComponents, timeComponents );
m_summaryPlot->useDateBasedTimeAxis( dateFormat, timeFormat, dateComponents, timeComponents );
}
else
{
m_plotWidget->useTimeBasedTimeAxis();
m_summaryPlot->useTimeBasedTimeAxis();
}
m_plotWidget->enableAxis( QwtPlot::xBottom, true );
plotWidget()->enableAxis( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM, true );
{
Qt::AlignmentFlag alignment = Qt::AlignCenter;
@ -1182,13 +1183,13 @@ void RimSummaryPlot::updateTimeAxis()
alignment = Qt::AlignRight;
}
m_plotWidget->setAxisFontsAndAlignment( QwtPlot::xBottom,
plotWidget()->setAxisFontsAndAlignment( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM,
m_timeAxisProperties->titleFontSize(),
m_timeAxisProperties->valuesFontSize(),
true,
alignment );
m_plotWidget->setAxisTitleText( QwtPlot::xBottom, m_timeAxisProperties->title() );
m_plotWidget->setAxisTitleEnabled( QwtPlot::xBottom, m_timeAxisProperties->showTitle );
plotWidget()->setAxisTitleText( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM, m_timeAxisProperties->title() );
plotWidget()->setAxisTitleEnabled( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM, m_timeAxisProperties->showTitle );
{
RimSummaryTimeAxisProperties::LegendTickmarkCount tickmarkCountEnum =
@ -1214,7 +1215,7 @@ void RimSummaryPlot::updateTimeAxis()
break;
}
m_plotWidget->setAxisMaxMajor( QwtPlot::xBottom, maxTickmarkCount );
plotWidget()->setAxisMaxMajor( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM, maxTickmarkCount );
}
}
}
@ -1224,15 +1225,13 @@ void RimSummaryPlot::updateTimeAxis()
//--------------------------------------------------------------------------------------------------
void RimSummaryPlot::updateBottomXAxis()
{
if ( !m_plotWidget ) return;
QwtPlot::Axis qwtAxis = QwtPlot::xBottom;
if ( !plotWidget() ) return;
RimPlotAxisProperties* bottomAxisProperties = m_bottomAxisProperties();
if ( bottomAxisProperties->isActive() )
{
m_plotWidget->enableAxis( qwtAxis, true );
plotWidget()->enableAxis( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM, true );
std::set<QString> timeHistoryQuantities;
@ -1241,11 +1240,11 @@ void RimSummaryPlot::updateBottomXAxis()
{},
visibleAsciiDataCurvesForAxis( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM ),
timeHistoryQuantities );
calc.applyAxisPropertiesToPlot( m_plotWidget );
calc.applyAxisPropertiesToPlot( plotWidget() );
}
else
{
m_plotWidget->enableAxis( qwtAxis, false );
plotWidget()->enableAxis( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM, false );
}
}
@ -1306,7 +1305,7 @@ void RimSummaryPlot::zoomAll()
{
setAutoScaleXEnabled( true );
setAutoScaleYEnabled( true );
updateZoomInQwt();
updateZoomInParentPlot();
}
//--------------------------------------------------------------------------------------------------
@ -1318,9 +1317,9 @@ void RimSummaryPlot::addCurveAndUpdate( RimSummaryCurve* curve )
{
m_summaryCurveCollection->addCurve( curve );
connectCurveSignals( curve );
if ( m_plotWidget )
if ( plotWidget() )
{
curve->setParentQwtPlotAndReplot( m_plotWidget );
curve->setParentPlotAndReplot( plotWidget() );
this->updateAxes();
}
}
@ -1335,9 +1334,9 @@ void RimSummaryPlot::addCurveNoUpdate( RimSummaryCurve* curve )
{
m_summaryCurveCollection->addCurve( curve );
connectCurveSignals( curve );
if ( m_plotWidget )
if ( plotWidget() )
{
curve->setParentQwtPlotNoReplot( m_plotWidget );
curve->setParentPlotNoReplot( plotWidget() );
}
}
}
@ -1351,9 +1350,9 @@ void RimSummaryPlot::insertCurve( RimSummaryCurve* curve, size_t insertAtPositio
{
m_summaryCurveCollection->insertCurve( curve, insertAtPosition );
connectCurveSignals( curve );
if ( m_plotWidget )
if ( plotWidget() )
{
curve->setParentQwtPlotNoReplot( m_plotWidget );
curve->setParentPlotNoReplot( plotWidget() );
}
}
}
@ -1405,9 +1404,9 @@ void RimSummaryPlot::deleteCurves( const std::vector<RimSummaryCurve*>& curves )
if ( curveSet->curves().empty() )
{
if ( curveSet->colorMode() == RimEnsembleCurveSet::ColorMode::BY_ENSEMBLE_PARAM &&
m_plotWidget && curveSet->legendFrame() )
plotWidget() && curveSet->legendFrame() )
{
m_plotWidget->removeOverlayFrame( curveSet->legendFrame() );
plotWidget()->removeOverlayFrame( curveSet->legendFrame() );
}
m_ensembleCurveSetCollection->deleteCurveSet( curveSet );
}
@ -1450,9 +1449,9 @@ void RimSummaryPlot::addGridTimeHistoryCurve( RimGridTimeHistoryCurve* curve )
CVF_ASSERT( curve );
m_gridTimeHistoryCurves.push_back( curve );
if ( m_plotWidget )
if ( plotWidget() )
{
curve->setParentQwtPlotAndReplot( m_plotWidget );
curve->setParentPlotAndReplot( plotWidget() );
this->updateAxes();
}
}
@ -1465,9 +1464,9 @@ void RimSummaryPlot::addGridTimeHistoryCurveNoUpdate( RimGridTimeHistoryCurve* c
CVF_ASSERT( curve );
m_gridTimeHistoryCurves.push_back( curve );
if ( m_plotWidget )
if ( plotWidget() )
{
curve->setParentQwtPlotNoReplot( m_plotWidget );
curve->setParentPlotNoReplot( plotWidget() );
}
}
@ -1487,10 +1486,9 @@ void RimSummaryPlot::addAsciiDataCruve( RimAsciiDataCurve* curve )
CVF_ASSERT( curve );
m_asciiDataCurves.push_back( curve );
if ( m_plotWidget )
if ( plotWidget() )
{
curve->setParentQwtPlotAndReplot( m_plotWidget );
this->updateAxes();
curve->setParentPlotAndReplot( plotWidget() );
}
}
@ -1549,10 +1547,10 @@ void RimSummaryPlot::updateStackedCurveData()
updateStackedCurveDataForAxis( RiaDefines::PlotAxis::PLOT_AXIS_LEFT );
updateStackedCurveDataForAxis( RiaDefines::PlotAxis::PLOT_AXIS_RIGHT );
if ( m_plotWidget )
if ( plotWidget() )
{
reattachAllCurves();
m_plotWidget->scheduleReplot();
plotWidget()->scheduleReplot();
}
}
@ -1622,9 +1620,9 @@ QImage RimSummaryPlot::snapshotWindowContent()
{
QImage image;
if ( m_plotWidget )
if ( plotWidget() )
{
QPixmap pix = m_plotWidget->grab();
QPixmap pix = plotWidget()->grab();
image = pix.toImage();
}
@ -1696,11 +1694,11 @@ void RimSummaryPlot::onLoadDataAndUpdate()
curve->loadDataAndUpdate( false );
}
if ( m_plotWidget )
if ( plotWidget() )
{
m_plotWidget->setInternalLegendVisible( m_showPlotLegends && !isSubPlot() );
m_plotWidget->setLegendFontSize( legendFontSize() );
m_plotWidget->updateLegend();
plotWidget()->setInternalLegendVisible( m_showPlotLegends && !isSubPlot() );
plotWidget()->setLegendFontSize( legendFontSize() );
plotWidget()->updateLegend();
}
this->updateAxes();
@ -1712,49 +1710,49 @@ void RimSummaryPlot::onLoadDataAndUpdate()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryPlot::updateZoomInQwt()
void RimSummaryPlot::updateZoomInParentPlot()
{
if ( m_plotWidget )
if ( plotWidget() )
{
updateZoomForAxis( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM );
updateZoomForAxis( RiaDefines::PlotAxis::PLOT_AXIS_LEFT );
updateZoomForAxis( RiaDefines::PlotAxis::PLOT_AXIS_RIGHT );
m_plotWidget->updateAxes();
updateZoomFromQwt();
m_plotWidget->scheduleReplot();
plotWidget()->updateAxes();
updateZoomFromParentPlot();
plotWidget()->scheduleReplot();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryPlot::updateZoomFromQwt()
void RimSummaryPlot::updateZoomFromParentPlot()
{
if ( !m_plotWidget ) return;
if ( !plotWidget() ) return;
QwtInterval leftAxis = m_plotWidget->axisRange( QwtPlot::yLeft );
QwtInterval rightAxis = m_plotWidget->axisRange( QwtPlot::yRight );
QwtInterval timeAxis = m_plotWidget->axisRange( QwtPlot::xBottom );
auto [leftAxisMin, leftAxisMax] = plotWidget()->axisRange( RiaDefines::PlotAxis::PLOT_AXIS_LEFT );
auto [rightAxisMin, rightAxisMax] = plotWidget()->axisRange( RiaDefines::PlotAxis::PLOT_AXIS_RIGHT );
auto [timeAxisMin, timeAxisMax] = plotWidget()->axisRange( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM );
m_leftYAxisProperties->visibleRangeMax = leftAxis.maxValue();
m_leftYAxisProperties->visibleRangeMin = leftAxis.minValue();
m_leftYAxisProperties->visibleRangeMax = leftAxisMax;
m_leftYAxisProperties->visibleRangeMin = leftAxisMin;
m_leftYAxisProperties->updateConnectedEditors();
m_rightYAxisProperties->visibleRangeMax = rightAxis.maxValue();
m_rightYAxisProperties->visibleRangeMin = rightAxis.minValue();
m_rightYAxisProperties->visibleRangeMax = rightAxisMax;
m_rightYAxisProperties->visibleRangeMin = rightAxisMin;
m_rightYAxisProperties->updateConnectedEditors();
if ( m_isCrossPlot )
{
m_bottomAxisProperties->visibleRangeMax = timeAxis.maxValue();
m_bottomAxisProperties->visibleRangeMin = timeAxis.minValue();
m_bottomAxisProperties->visibleRangeMax = timeAxisMax;
m_bottomAxisProperties->visibleRangeMin = timeAxisMin;
m_bottomAxisProperties->updateConnectedEditors();
}
else
{
m_timeAxisProperties->setVisibleRangeMin( timeAxis.minValue() );
m_timeAxisProperties->setVisibleRangeMax( timeAxis.maxValue() );
m_timeAxisProperties->setVisibleRangeMin( timeAxisMin );
m_timeAxisProperties->setVisibleRangeMax( timeAxisMax );
m_timeAxisProperties->updateConnectedEditors();
}
}
@ -1772,13 +1770,19 @@ std::set<RimPlotAxisPropertiesInterface*> RimSummaryPlot::allPlotAxes() const
//--------------------------------------------------------------------------------------------------
void RimSummaryPlot::cleanupBeforeClose()
{
detachAllPlotItems();
if ( m_plotWidget )
if ( isDeletable() )
{
m_plotWidget->setParent( nullptr );
delete m_plotWidget;
m_plotWidget = nullptr;
detachAllPlotItems();
if ( plotWidget() )
{
plotWidget()->setParent( nullptr );
}
if ( m_summaryPlot )
{
m_summaryPlot.reset();
}
}
}
@ -1827,9 +1831,9 @@ void RimSummaryPlot::curveVisibilityChanged( const caf::SignalEmitter* emitter,
//--------------------------------------------------------------------------------------------------
void RimSummaryPlot::curveAppearanceChanged( const caf::SignalEmitter* emitter )
{
if ( m_plotWidget )
if ( plotWidget() )
{
m_plotWidget->scheduleReplot();
plotWidget()->scheduleReplot();
}
}
@ -1929,7 +1933,7 @@ void RimSummaryPlot::onPlotZoomed()
{
setAutoScaleXEnabled( false );
setAutoScaleYEnabled( false );
updateZoomFromQwt();
updateZoomFromParentPlot();
}
//--------------------------------------------------------------------------------------------------
@ -1944,7 +1948,9 @@ void RimSummaryPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering&
caf::PdmUiGroup* mainOptions = uiOrdering.addNewGroup( "General Plot Options" );
mainOptions->setCollapsedByDefault( true );
#ifdef USE_QTCHARTS
mainOptions->add( &m_useQtChartsPlot );
#endif
if ( isMdiWindow() )
{
mainOptions->add( &m_showPlotTitle );
@ -1976,38 +1982,49 @@ void RimSummaryPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering&
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuQwtPlotWidget* RimSummaryPlot::doCreatePlotViewWidget( QWidget* mainWindowParent )
RiuPlotWidget* RimSummaryPlot::doCreatePlotViewWidget( QWidget* mainWindowParent )
{
if ( !m_plotWidget )
if ( !plotWidget() )
{
m_plotWidget = new RiuSummaryQwtPlot( this, mainWindowParent );
#ifdef USE_QTCHARTS
if ( m_useQtChartsPlot )
{
m_summaryPlot = std::make_unique<RiuSummaryQtChartsPlot>( this, mainWindowParent );
}
else
{
m_summaryPlot = std::make_unique<RiuSummaryQwtPlot>( this, mainWindowParent );
}
#else
m_summaryPlot = std::make_unique<RiuSummaryQwtPlot>( this, mainWindowParent );
#endif
for ( RimGridTimeHistoryCurve* curve : m_gridTimeHistoryCurves )
{
curve->setParentQwtPlotNoReplot( m_plotWidget );
curve->setParentPlotNoReplot( plotWidget() );
}
for ( RimAsciiDataCurve* curve : m_asciiDataCurves )
{
curve->setParentQwtPlotNoReplot( m_plotWidget );
curve->setParentPlotNoReplot( plotWidget() );
}
if ( m_summaryCurveCollection )
{
m_summaryCurveCollection->setParentQwtPlotAndReplot( m_plotWidget );
m_summaryCurveCollection->setParentPlotAndReplot( plotWidget() );
}
if ( m_ensembleCurveSetCollection )
{
m_ensembleCurveSetCollection->setParentQwtPlotAndReplot( m_plotWidget );
m_ensembleCurveSetCollection->setParentPlotAndReplot( plotWidget() );
}
this->connect( m_plotWidget, SIGNAL( plotZoomed() ), SLOT( onPlotZoomed() ) );
this->connect( plotWidget(), SIGNAL( plotZoomed() ), SLOT( onPlotZoomed() ) );
updatePlotTitle();
}
return m_plotWidget;
return plotWidget();
}
//--------------------------------------------------------------------------------------------------
@ -2102,19 +2119,22 @@ void RimSummaryPlot::detachAllPlotItems()
{
if ( m_summaryCurveCollection )
{
m_summaryCurveCollection->detachQwtCurves();
m_summaryCurveCollection->detachPlotCurves();
}
m_ensembleCurveSetCollection->detachQwtCurves();
if ( m_ensembleCurveSetCollection )
{
m_ensembleCurveSetCollection->detachPlotCurves();
}
for ( RimGridTimeHistoryCurve* curve : m_gridTimeHistoryCurves )
{
curve->detachQwtCurve();
curve->detach();
}
for ( RimAsciiDataCurve* curve : m_asciiDataCurves )
{
curve->detachQwtCurve();
curve->detach();
}
m_plotInfoLabel->detach();
@ -2154,19 +2174,19 @@ void RimSummaryPlot::reattachAllCurves()
{
if ( m_summaryCurveCollection )
{
m_summaryCurveCollection->reattachQwtCurves();
m_summaryCurveCollection->reattachPlotCurves();
}
m_ensembleCurveSetCollection->reattachQwtCurves();
m_ensembleCurveSetCollection->reattachPlotCurves();
for ( RimGridTimeHistoryCurve* curve : m_gridTimeHistoryCurves )
{
curve->reattachQwtCurve();
curve->reattach();
}
for ( RimAsciiDataCurve* curve : m_asciiDataCurves )
{
curve->reattachQwtCurve();
curve->reattach();
}
}

View File

@ -18,7 +18,7 @@
#pragma once
#include "RiaDefines.h"
#include "RiaPlotDefines.h"
#include "RiaQDateTimeTools.h"
#include "RifEclipseSummaryAddress.h"
@ -26,7 +26,8 @@
#include "RimPlot.h"
#include "RimSummaryDataSourceStepping.h"
#include "qwt_plot_textlabel.h"
#include "RiuQwtPlotWidget.h"
#include "RiuSummaryPlot.h"
#include "cafPdmChildArrayField.h"
#include "cafPdmPtrArrayField.h"
@ -59,6 +60,7 @@ class RiaSummaryCurveDefinition;
class QwtInterval;
class QwtPlotCurve;
class QwtPlotTextLabel;
class QKeyEvent;
@ -120,8 +122,7 @@ public:
RimSummaryTimeAxisProperties* timeAxisProperties();
time_t firstTimeStepOfFirstCurve();
QWidget* viewWidget() override;
RiuQwtPlotWidget* viewer() override;
QWidget* viewWidget() override;
QString asciiDataForPlotExport() const override;
QString asciiDataForSummaryPlotExport( RiaQDateTimeTools::DateTimePeriod resamplingPeriod,
@ -160,14 +161,14 @@ public:
virtual RimSummaryPlotSourceStepping* sourceSteppingObjectForKeyEventHandling() const;
virtual std::vector<caf::PdmFieldHandle*> fieldsToShowInToolbar();
void setAutoScaleXEnabled( bool enabled ) override;
void setAutoScaleYEnabled( bool enabled ) override;
void setAutoScaleXEnabled( bool enabled ) override;
void setAutoScaleYEnabled( bool enabled ) override;
RiuPlotWidget* plotWidget() override;
void zoomAll() override;
void updateZoomInParentPlot() override;
void updateZoomFromParentPlot() override;
void zoomAll() override;
void updateZoomInQwt() override;
void updateZoomFromQwt() override;
caf::PdmObject* findPdmObjectFromQwtCurve( const QwtPlotCurve* curve ) const override;
caf::PdmObject* findPdmObjectFromPlotCurve( const RiuPlotCurve* curve ) const override;
void onAxisSelected( int axis, bool toggle ) override;
@ -192,7 +193,7 @@ public:
bool isDeletable() const override;
private:
RiuQwtPlotWidget* doCreatePlotViewWidget( QWidget* mainWindowParent = nullptr ) override;
RiuPlotWidget* doCreatePlotViewWidget( QWidget* mainWindowParent = nullptr ) override;
void updateNameHelperWithCurveData( RimSummaryPlotNameHelper* nameHelper ) const;
@ -256,6 +257,9 @@ private:
void axisLogarithmicChanged( const caf::SignalEmitter* emitter, bool isLogarithmic );
private:
#ifdef USE_QTCHARTS
caf::PdmField<bool> m_useQtChartsPlot;
#endif
caf::PdmField<bool> m_normalizeCurveYValues;
caf::PdmField<bool> m_useAutoPlotTitle;
@ -275,7 +279,7 @@ private:
caf::PdmChildField<RimSummaryPlotFilterTextCurveSetEditor*> m_textCurveSetEditor;
QPointer<RiuSummaryQwtPlot> m_plotWidget;
std::unique_ptr<RiuSummaryPlot> m_summaryPlot;
std::unique_ptr<QwtPlotTextLabel> m_plotInfoLabel;
bool m_isCrossPlot;

View File

@ -19,6 +19,7 @@
#include "RimSummaryPlotAxisFormatter.h"
#include "RiaDefines.h"
#include "RiaNumberFormat.h"
#include "RiaSummaryCurveDefinition.h"
#include "RifSummaryReaderInterface.h"
@ -29,13 +30,15 @@
#include "RimSummaryCaseCollection.h"
#include "RimSummaryCurve.h"
#include "RiuQtChartsPlotWidget.h"
#include "RiuQwtPlotTools.h"
#include "RiuSummaryQuantityNameInfoProvider.h"
#include "RiuSummaryQwtPlot.h"
#include "qwt_date_scale_engine.h"
#include "qwt_plot.h"
#include "qwt_plot_curve.h"
#include "qwt_scale_draw.h"
#include "qwt_scale_engine.h"
#include <cmath>
#include <set>
@ -111,10 +114,11 @@ RimSummaryPlotAxisFormatter::RimSummaryPlotAxisFormatter( RimPlotAxisProperties*
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryPlotAxisFormatter::applyAxisPropertiesToPlot( RiuQwtPlotWidget* qwtPlot )
void RimSummaryPlotAxisFormatter::applyAxisPropertiesToPlot( RiuPlotWidget* plotWidget )
{
if ( !qwtPlot ) return;
if ( !plotWidget ) return;
RiaDefines::PlotAxis axis = m_axisProperties->plotAxisType();
{
QString axisTitle = m_axisProperties->customTitle;
if ( m_axisProperties->useAutoTitle() ) axisTitle = autoAxisTitle();
@ -124,51 +128,72 @@ void RimSummaryPlotAxisFormatter::applyAxisPropertiesToPlot( RiuQwtPlotWidget* q
{
titleAlignment = Qt::AlignRight;
}
qwtPlot->setAxisTitleText( m_axisProperties->qwtPlotAxisType(), axisTitle );
qwtPlot->setAxisFontsAndAlignment( m_axisProperties->qwtPlotAxisType(),
m_axisProperties->titleFontSize(),
m_axisProperties->valuesFontSize(),
true,
titleAlignment );
qwtPlot->setAxisTitleEnabled( m_axisProperties->qwtPlotAxisType(), true );
plotWidget->setAxisTitleText( axis, axisTitle );
plotWidget->setAxisFontsAndAlignment( axis,
m_axisProperties->titleFontSize(),
m_axisProperties->valuesFontSize(),
true,
titleAlignment );
plotWidget->setAxisTitleEnabled( axis, true );
}
auto qwtPlotWidget = dynamic_cast<RiuQwtPlotWidget*>( plotWidget );
if ( qwtPlotWidget )
{
QwtPlot::Axis qwtAxisId = RiuQwtPlotTools::toQwtPlotAxis( axis );
if ( m_axisProperties->numberFormat == RimPlotAxisProperties::NUMBER_FORMAT_AUTO &&
m_axisProperties->scaleFactor() == 1.0 )
{
// Default to Qwt's own scale draw to avoid changing too much for default values
qwtPlot->setAxisScaleDraw( m_axisProperties->qwtPlotAxisType(), new QwtScaleDraw );
qwtPlotWidget->qwtPlot()->setAxisScaleDraw( qwtAxisId, new QwtScaleDraw );
}
else
{
qwtPlot->setAxisScaleDraw( m_axisProperties->qwtPlotAxisType(),
new SummaryScaleDraw( m_axisProperties->scaleFactor(),
m_axisProperties->numberOfDecimals(),
m_axisProperties->numberFormat() ) );
qwtPlotWidget->qwtPlot()->setAxisScaleDraw( qwtAxisId,
new SummaryScaleDraw( m_axisProperties->scaleFactor(),
m_axisProperties->numberOfDecimals(),
m_axisProperties->numberFormat() ) );
}
}
#ifdef USE_QTCHARTS
auto qtChartsPlotWidget = dynamic_cast<RiuQtChartsPlotWidget*>( plotWidget );
if ( qtChartsPlotWidget )
{
auto mapToRiaNumberFormatType = []( RimPlotAxisProperties::NumberFormatType formatType ) {
if ( formatType == RimPlotAxisProperties::NumberFormatType::NUMBER_FORMAT_DECIMAL )
return RiaNumberFormat::NumberFormatType::FIXED;
if ( formatType == RimPlotAxisProperties::NumberFormatType::NUMBER_FORMAT_SCIENTIFIC )
return RiaNumberFormat::NumberFormatType::SCIENTIFIC;
return RiaNumberFormat::NumberFormatType::AUTO;
};
auto formatType = mapToRiaNumberFormatType( m_axisProperties->numberFormat() );
QString format = RiaNumberFormat::sprintfFormat( formatType, m_axisProperties->numberOfDecimals() );
qtChartsPlotWidget->setAxisFormat( axis, format );
}
#endif
{
if ( m_axisProperties->isLogarithmicScaleEnabled )
{
QwtLogScaleEngine* currentScaleEngine =
dynamic_cast<QwtLogScaleEngine*>( qwtPlot->axisScaleEngine( m_axisProperties->qwtPlotAxisType() ) );
if ( !currentScaleEngine )
bool isLogScale = plotWidget->axisScaleType( axis ) == RiuQwtPlotWidget::AxisScaleType::LOGARITHMIC;
if ( !isLogScale )
{
qwtPlot->setAxisScaleEngine( m_axisProperties->qwtPlotAxisType(), new QwtLogScaleEngine );
qwtPlot->setAxisMaxMinor( m_axisProperties->qwtPlotAxisType(), 5 );
plotWidget->setAxisScaleType( axis, RiuQwtPlotWidget::AxisScaleType::LOGARITHMIC );
plotWidget->setAxisMaxMinor( axis, 5 );
}
}
else
{
QwtLinearScaleEngine* currentScaleEngine =
dynamic_cast<QwtLinearScaleEngine*>( qwtPlot->axisScaleEngine( m_axisProperties->qwtPlotAxisType() ) );
QwtDateScaleEngine* dateScaleEngine = dynamic_cast<QwtDateScaleEngine*>( currentScaleEngine );
if ( !currentScaleEngine || dateScaleEngine )
bool isLinearScale = plotWidget->axisScaleType( axis ) == RiuQwtPlotWidget::AxisScaleType::LINEAR;
if ( !isLinearScale )
{
qwtPlot->setAxisScaleEngine( m_axisProperties->qwtPlotAxisType(), new QwtLinearScaleEngine );
qwtPlot->setAxisMaxMinor( m_axisProperties->qwtPlotAxisType(), 3 );
plotWidget->setAxisScaleType( axis, RiuQwtPlotWidget::AxisScaleType::LINEAR );
plotWidget->setAxisMaxMinor( axis, 3 );
}
}
}

View File

@ -22,16 +22,12 @@
#include <set>
#include <vector>
#include <qwt_plot.h>
class RimAsciiDataCurve;
class RimSummaryCurve;
class RimPlotAxisProperties;
class RiaSummaryCurveDefinition;
class RiuQwtPlotWidget;
class QwtPlotCurve;
class RiuPlotWidget;
class RimSummaryPlotAxisFormatter
{
@ -42,7 +38,7 @@ public:
const std::vector<RimAsciiDataCurve*>& asciiCurves,
const std::set<QString>& timeHistoryCurveQuantities );
void applyAxisPropertiesToPlot( RiuQwtPlotWidget* qwtPlot );
void applyAxisPropertiesToPlot( RiuPlotWidget* qwtPlot );
private:
QString autoAxisTitle() const;

View File

@ -61,6 +61,7 @@
#include "cvfObject.h"
#include "qwt_plot.h"
#include "qwt_plot_curve.h"
#include "qwt_symbol.h"
@ -70,7 +71,7 @@
//--------------------------------------------------------------------------------------------------
/// Internal functions
//--------------------------------------------------------------------------------------------------
int statisticsCurveSymbolSize( RiuQwtSymbol::PointSymbolEnum symbol );
int statisticsCurveSymbolSize( RiuPlotCurveSymbol::PointSymbolEnum symbol );
namespace caf
{
@ -135,7 +136,7 @@ RimEnsembleWellLogCurveSet::RimEnsembleWellLogCurveSet()
m_curveAppearance->setColorVisible( false );
m_curveAppearance->setFillOptionsVisible( false );
m_curveAppearance->setSymbol( RiuQwtSymbol::PointSymbolEnum::SYMBOL_ELLIPSE );
m_curveAppearance->setSymbol( RiuPlotCurveSymbol::PointSymbolEnum::SYMBOL_ELLIPSE );
m_curveAppearance->setSymbolSize( 5 );
m_curveAppearance->setLineStyle( RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_NONE );
m_curveAppearance->setSymbolEdgeColor( cvf::Color3f::BLACK );
@ -218,22 +219,22 @@ void RimEnsembleWellLogCurveSet::loadDataAndUpdate( bool updateParentPlot )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEnsembleWellLogCurveSet::setParentQwtPlotNoReplot( QwtPlot* plot )
void RimEnsembleWellLogCurveSet::setParentPlotNoReplot( RiuPlotWidget* plot )
{
for ( RimWellLogCurve* curve : m_curves )
{
curve->setParentQwtPlotNoReplot( plot );
curve->setParentPlotNoReplot( plot );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEnsembleWellLogCurveSet::detachQwtCurves()
void RimEnsembleWellLogCurveSet::detachPlotCurves()
{
for ( RimWellLogCurve* curve : m_curves )
{
curve->detachQwtCurve();
curve->detach();
}
m_qwtPlotCurveForLegendText->detach();
@ -242,11 +243,11 @@ void RimEnsembleWellLogCurveSet::detachQwtCurves()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEnsembleWellLogCurveSet::reattachQwtCurves()
void RimEnsembleWellLogCurveSet::reattachPlotCurves()
{
for ( RimWellLogCurve* curve : m_curves )
{
curve->reattachQwtCurve();
curve->reattach();
}
m_qwtPlotCurveForLegendText->detach();
@ -255,7 +256,7 @@ void RimEnsembleWellLogCurveSet::reattachQwtCurves()
firstAncestorOrThisOfType( plot );
if ( plot )
{
m_qwtPlotCurveForLegendText->attach( plot->viewer() );
m_qwtPlotCurveForLegendText->attach( plot->viewer()->qwtPlot() );
}
}
@ -637,8 +638,8 @@ void RimEnsembleWellLogCurveSet::updateFilterLegend()
{
if ( !m_filterOverlayFrame )
{
m_filterOverlayFrame =
new RiuDraggableOverlayFrame( plotTrack->viewer()->canvas(), plotTrack->viewer()->overlayMargins() );
m_filterOverlayFrame = new RiuDraggableOverlayFrame( plotTrack->viewer()->qwtPlot()->canvas(),
plotTrack->viewer()->overlayMargins() );
}
m_filterOverlayFrame->setContentFrame( m_ensembleCurveSet->curveFilters()->makeFilterDescriptionFrame() );
plotTrack->viewer()->addOverlayFrame( m_filterOverlayFrame );
@ -735,8 +736,8 @@ void RimEnsembleWellLogCurveSet::updateCurveColors()
{
if ( !m_legendOverlayFrame )
{
m_legendOverlayFrame =
new RiuDraggableOverlayFrame( plotTrack->viewer()->canvas(), plotTrack->viewer()->overlayMargins() );
m_legendOverlayFrame = new RiuDraggableOverlayFrame( plotTrack->viewer()->getParentForOverlay(),
plotTrack->viewer()->overlayMargins() );
}
m_legendOverlayFrame->setContentFrame( m_ensembleCurveSet->legendConfig()->makeLegendFrame() );
plotTrack->viewer()->addOverlayFrame( m_legendOverlayFrame );
@ -780,7 +781,7 @@ void RimEnsembleWellLogCurveSet::updateEnsembleCurves( const std::vector<RimWell
wellPathFormations = createWellPathFormations( offsets );
}
m_qwtPlotCurveForLegendText->attach( plotTrack->viewer() );
m_qwtPlotCurveForLegendText->attach( plotTrack->viewer()->qwtPlot() );
QString wellLogChannelName = m_wellLogChannelName();
if ( plotTrack && wellLogChannelName != "None" )
@ -920,11 +921,13 @@ void RimEnsembleWellLogCurveSet::updateStatisticsCurves( const std::vector<RimWe
}
auto statisticsCurveSymbolFromStatistics = []( RimEnsembleWellLogStatistics::StatisticsType statisticsType ) {
if ( statisticsType == RimEnsembleWellLogStatistics::StatisticsType::P10 ) return RiuQwtSymbol::SYMBOL_TRIANGLE;
if ( statisticsType == RimEnsembleWellLogStatistics::StatisticsType::P10 )
return RiuPlotCurveSymbol::SYMBOL_TRIANGLE;
if ( statisticsType == RimEnsembleWellLogStatistics::StatisticsType::P90 )
return RiuQwtSymbol::SYMBOL_DOWN_TRIANGLE;
if ( statisticsType == RimEnsembleWellLogStatistics::StatisticsType::P50 ) return RiuQwtSymbol::SYMBOL_DIAMOND;
return RiuQwtSymbol::SYMBOL_ELLIPSE;
return RiuPlotCurveSymbol::SYMBOL_DOWN_TRIANGLE;
if ( statisticsType == RimEnsembleWellLogStatistics::StatisticsType::P50 )
return RiuPlotCurveSymbol::SYMBOL_DIAMOND;
return RiuPlotCurveSymbol::SYMBOL_ELLIPSE;
};
RimWellLogTrack* plotTrack = nullptr;

View File

@ -51,6 +51,7 @@ class RimPlotCurveAppearance;
class RigWellPathFormations;
class RiuDraggableOverlayFrame;
class RiuPlotWidget;
class QwtPlot;
class QwtPlotCurve;
@ -80,9 +81,9 @@ public:
void setColor( cvf::Color3f color );
void loadDataAndUpdate( bool updateParentPlot );
void setParentQwtPlotNoReplot( QwtPlot* plot );
void detachQwtCurves();
void reattachQwtCurves();
void setParentPlotNoReplot( RiuPlotWidget* plot );
void detachPlotCurves();
void reattachPlotCurves();
std::vector<RimWellLogCurve*> curves() const;

View File

@ -20,6 +20,7 @@
#include "RimWellLogCurve.h"
#include "RiaCurveDataTools.h"
#include "RiaPlotDefines.h"
#include "RigWellLogCurveData.h"
#include "RimDepthTrackPlot.h"
@ -46,10 +47,6 @@ RimWellLogCurve::RimWellLogCurve()
{
CAF_PDM_InitObject( "WellLogCurve", ":/WellLogCurve16x16.png" );
m_qwtPlotCurve->setXAxis( QwtPlot::xTop );
m_qwtCurveErrorBars->setXAxis( QwtPlot::xTop );
m_qwtPlotCurve->setYAxis( QwtPlot::yLeft );
m_curveData = new RigWellLogCurveData;
m_curveDataXRange = std::make_pair( std::numeric_limits<double>::infinity(), -std::numeric_limits<double>::infinity() );
@ -179,11 +176,22 @@ const RigWellLogCurveData* RimWellLogCurve::curveData() const
void RimWellLogCurve::updateCurveAppearance()
{
RimPlotCurve::updateCurveAppearance();
if ( m_plotCurve )
{
m_plotCurve->setXAxis( RiaDefines::PlotAxis::PLOT_AXIS_TOP );
m_plotCurve->setYAxis( RiaDefines::PlotAxis::PLOT_AXIS_LEFT );
}
if ( fillStyle() != Qt::BrushStyle::NoBrush )
{
m_qwtPlotCurve->setOrientation( Qt::Horizontal );
m_qwtPlotCurve->setBaseline( -std::numeric_limits<double>::infinity() );
m_qwtPlotCurve->setCurveAttribute( QwtPlotCurve::Inverted, true );
RiuQwtPlotCurve* qwtPlotCurve = dynamic_cast<RiuQwtPlotCurve*>( m_plotCurve );
if ( qwtPlotCurve )
{
qwtPlotCurve->setOrientation( Qt::Horizontal );
qwtPlotCurve->setBaseline( -std::numeric_limits<double>::infinity() );
qwtPlotCurve->setCurveAttribute( QwtPlotCurve::Inverted, true );
}
}
}
@ -212,10 +220,10 @@ void RimWellLogCurve::setOverrideCurveData( const std::vector<double>&
{
auto minmax_it = std::minmax_element( xValues.begin(), xValues.end() );
this->setOverrideCurveDataXRange( *( minmax_it.first ), *( minmax_it.second ) );
if ( m_qwtPlotCurve )
if ( m_plotCurve )
{
m_qwtPlotCurve->setSamples( xValues.data(), depthValues.data(), static_cast<int>( depthValues.size() ) );
m_qwtPlotCurve->setLineSegmentStartStopIndices( curveIntervals );
m_plotCurve->setSamplesValues( xValues, depthValues );
m_plotCurve->setLineSegmentStartStopIndices( curveIntervals );
}
}

View File

@ -340,7 +340,7 @@ void RimWellLogExtractionCurve::fieldChangedByUi( const caf::PdmFieldHandle* cha
//--------------------------------------------------------------------------------------------------
void RimWellLogExtractionCurve::onLoadDataAndUpdate( bool updateParentPlot )
{
if ( isCurveVisible() )
if ( isCurveVisible() && m_plotCurve )
{
bool isUsingPseudoLength = false;
performDataExtraction( &isUsingPseudoLength );
@ -360,9 +360,9 @@ void RimWellLogExtractionCurve::onLoadDataAndUpdate( bool updateParentPlot )
std::vector<double> xPlotValues = curveData()->xPlotValues();
std::vector<double> depthPlotValues = curveData()->depthPlotValues( depthType, displayUnit );
CAF_ASSERT( xPlotValues.size() == depthPlotValues.size() );
m_qwtPlotCurve->setSamples( xPlotValues.data(), depthPlotValues.data(), static_cast<int>( xPlotValues.size() ) );
m_plotCurve->setSamplesFromXValuesAndYValues( xPlotValues, depthPlotValues, static_cast<int>( xPlotValues.size() ) );
m_qwtPlotCurve->setLineSegmentStartStopIndices( curveData()->polylineStartStopIndices() );
m_plotCurve->setLineSegmentStartStopIndices( curveData()->polylineStartStopIndices() );
this->RimPlotCurve::updateCurvePresentation( updateParentPlot );
@ -375,7 +375,7 @@ void RimWellLogExtractionCurve::onLoadDataAndUpdate( bool updateParentPlot )
RiuQwtPlotWidget* viewer = wellLogTrack->viewer();
if ( viewer )
{
viewer->setAxisTitleText( QwtPlot::yLeft, "PL/" + wellLogPlot->depthAxisTitle() );
viewer->setAxisTitleText( RiaDefines::PlotAxis::PLOT_AXIS_LEFT, "PL/" + wellLogPlot->depthAxisTitle() );
}
}
@ -386,9 +386,9 @@ void RimWellLogExtractionCurve::onLoadDataAndUpdate( bool updateParentPlot )
setLogScaleFromSelectedResult();
if ( m_parentQwtPlot )
if ( m_parentPlot )
{
m_parentQwtPlot->replot();
m_parentPlot->replot();
}
}
}

View File

@ -172,7 +172,7 @@ void RimWellLogFileCurve::onLoadDataAndUpdate( bool updateParentPlot )
if ( m_isUsingAutoName )
{
m_qwtPlotCurve->setTitle( createCurveAutoName() );
m_plotCurve->setTitle( createCurveAutoName() );
}
}
@ -188,19 +188,18 @@ void RimWellLogFileCurve::onLoadDataAndUpdate( bool updateParentPlot )
depthType = wellLogPlot->depthType();
}
m_qwtPlotCurve->setSamples( this->curveData()->xPlotValues().data(),
this->curveData()->depthPlotValues( depthType, displayUnit ).data(),
static_cast<int>( this->curveData()->xPlotValues().size() ) );
m_qwtPlotCurve->setLineSegmentStartStopIndices( this->curveData()->polylineStartStopIndices() );
m_plotCurve->setSamplesValues( this->curveData()->xPlotValues(),
this->curveData()->depthPlotValues( depthType, displayUnit ) );
m_plotCurve->setLineSegmentStartStopIndices( this->curveData()->polylineStartStopIndices() );
if ( updateParentPlot )
{
updateZoomInParentPlot();
}
if ( m_parentQwtPlot )
if ( m_parentPlot )
{
m_parentQwtPlot->replot();
m_parentPlot->replot();
}
}
}
@ -315,7 +314,7 @@ void RimWellLogFileCurve::fieldChangedByUi( const caf::PdmFieldHandle* changedFi
{
this->loadDataAndUpdate( true );
}
if ( m_parentQwtPlot ) m_parentQwtPlot->replot();
if ( m_parentPlot ) m_parentPlot->replot();
}
//--------------------------------------------------------------------------------------------------

View File

@ -396,7 +396,7 @@ void RimWellLogRftCurve::onLoadDataAndUpdate( bool updateParentPlot )
if ( values.empty() || values.size() != tvDepthVector.size() )
{
this->detachQwtCurve();
this->detach();
return;
}
@ -466,7 +466,7 @@ void RimWellLogRftCurve::onLoadDataAndUpdate( bool updateParentPlot )
if ( wellLogPlot->depthType() == RiaDefines::DepthTypeEnum::MEASURED_DEPTH )
{
m_qwtPlotCurve->setPerPointLabels( perPointLabels );
m_plotCurve->setPerPointLabels( perPointLabels );
auto xValues = this->curveData()->xPlotValues();
auto yValues = this->curveData()->depthPlotValues( RiaDefines::DepthTypeEnum::MEASURED_DEPTH, displayUnit );
@ -482,7 +482,7 @@ void RimWellLogRftCurve::onLoadDataAndUpdate( bool updateParentPlot )
}
else
{
m_qwtPlotCurve->setSamplesFromXValuesAndYValues( xValues, yValues, keepOnlyPositiveValues );
m_plotCurve->setSamplesFromXValuesAndYValues( xValues, yValues, keepOnlyPositiveValues );
}
RimWellLogTrack* wellLogTrack;
@ -496,22 +496,24 @@ void RimWellLogRftCurve::onLoadDataAndUpdate( bool updateParentPlot )
{
if ( derivedMDSource == WELL_PATH )
{
viewer->setAxisTitleText( QwtPlot::yLeft, "WELL/" + wellLogPlot->depthAxisTitle() );
viewer->setAxisTitleText( RiaDefines::PlotAxis::PLOT_AXIS_LEFT,
"WELL/" + wellLogPlot->depthAxisTitle() );
}
else
{
viewer->setAxisTitleText( QwtPlot::yLeft, "OBS/" + wellLogPlot->depthAxisTitle() );
viewer->setAxisTitleText( RiaDefines::PlotAxis::PLOT_AXIS_LEFT,
"OBS/" + wellLogPlot->depthAxisTitle() );
}
}
else // Standard depth title set from plot
{
viewer->setAxisTitleText( QwtPlot::yLeft, wellLogPlot->depthAxisTitle() );
viewer->setAxisTitleText( RiaDefines::PlotAxis::PLOT_AXIS_LEFT, wellLogPlot->depthAxisTitle() );
}
}
}
else
{
m_qwtPlotCurve->setPerPointLabels( perPointLabels );
m_plotCurve->setPerPointLabels( perPointLabels );
auto xValues = this->curveData()->xPlotValues();
auto yValues =
@ -528,20 +530,20 @@ void RimWellLogRftCurve::onLoadDataAndUpdate( bool updateParentPlot )
}
else
{
m_qwtPlotCurve->setSamplesFromXValuesAndYValues( xValues, yValues, isLogCurve );
m_plotCurve->setSamplesFromXValuesAndYValues( xValues, yValues, isLogCurve );
}
}
m_qwtPlotCurve->setLineSegmentStartStopIndices( this->curveData()->polylineStartStopIndices() );
m_plotCurve->setLineSegmentStartStopIndices( this->curveData()->polylineStartStopIndices() );
if ( updateParentPlot )
{
updateZoomInParentPlot();
}
if ( m_parentQwtPlot )
if ( m_parentPlot )
{
m_parentQwtPlot->replot();
m_parentPlot->replot();
}
}
}

View File

@ -344,7 +344,7 @@ void RimWellLogTrack::detachAllPlotItems()
{
for ( RimPlotCurve* curve : m_curves )
{
curve->detachQwtCurve();
curve->detach();
}
for ( auto& plotObjects : m_wellPathAttributePlotObjects )
{
@ -493,7 +493,7 @@ void RimWellLogTrack::updateXZoom()
componentRangeMax *= 1.5;
}
m_plotWidget->setAxisRange( QwtPlot::xBottom, componentRangeMin, componentRangeMax );
m_plotWidget->setAxisRange( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM, componentRangeMin, componentRangeMax );
}
//--------------------------------------------------------------------------------------------------
@ -503,7 +503,7 @@ void RimWellLogTrack::updateYZoom()
{
if ( !m_plotWidget ) return;
m_plotWidget->setAxisRange( QwtPlot::yLeft, m_visibleDepthRangeMin(), m_visibleDepthRangeMax() );
m_plotWidget->setAxisRange( RiaDefines::PlotAxis::PLOT_AXIS_LEFT, m_visibleDepthRangeMin(), m_visibleDepthRangeMax() );
}
//--------------------------------------------------------------------------------------------------
@ -540,8 +540,8 @@ void RimWellLogTrack::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
{
if ( m_plotWidget )
{
m_majorTickInterval = m_plotWidget->majorTickInterval( QwtPlot::xTop );
m_minorTickInterval = m_plotWidget->minorTickInterval( QwtPlot::xTop );
m_majorTickInterval = m_plotWidget->majorTickInterval( RiaDefines::PlotAxis::PLOT_AXIS_TOP );
m_minorTickInterval = m_plotWidget->minorTickInterval( RiaDefines::PlotAxis::PLOT_AXIS_TOP );
}
m_majorTickInterval.uiCapability()->setUiHidden( !m_explicitTickIntervals() );
m_minorTickInterval.uiCapability()->setUiHidden( !m_explicitTickIntervals() );
@ -762,13 +762,13 @@ void RimWellLogTrack::updateXAxisAndGridTickIntervals()
bool emptyRange = isEmptyVisibleXRange();
if ( emptyRange )
{
m_plotWidget->enableGridLines( QwtPlot::xTop, false, false );
m_plotWidget->setAxisRange( QwtPlot::xTop, 0.0, 1.0 );
m_plotWidget->setAxisLabelsAndTicksEnabled( QwtPlot::xTop, false, false );
m_plotWidget->enableGridLines( RiaDefines::PlotAxis::PLOT_AXIS_TOP, false, false );
m_plotWidget->setAxisRange( RiaDefines::PlotAxis::PLOT_AXIS_TOP, 0.0, 1.0 );
m_plotWidget->setAxisLabelsAndTicksEnabled( RiaDefines::PlotAxis::PLOT_AXIS_TOP, false, false );
}
else
{
m_plotWidget->setAxisLabelsAndTicksEnabled( QwtPlot::xTop, true, true );
m_plotWidget->setAxisLabelsAndTicksEnabled( RiaDefines::PlotAxis::PLOT_AXIS_TOP, true, true );
if ( m_minAndMaxTicksOnly )
{
auto roundToDigits = []( double value, int numberOfDigits, bool useFloor ) {
@ -803,11 +803,11 @@ void RimWellLogTrack::updateXAxisAndGridTickIntervals()
div.setTicks( QwtScaleDiv::TickType::MajorTick, majorTicks );
m_plotWidget->setAxisScaleDiv( QwtPlot::xTop, div );
m_plotWidget->qwtPlot()->setAxisScaleDiv( QwtPlot::xTop, div );
}
else if ( m_explicitTickIntervals )
{
m_plotWidget->setMajorAndMinorTickIntervals( QwtPlot::xTop,
m_plotWidget->setMajorAndMinorTickIntervals( RiaDefines::PlotAxis::PLOT_AXIS_TOP,
m_majorTickInterval(),
m_minorTickInterval(),
m_visibleXRangeMin(),
@ -817,11 +817,13 @@ void RimWellLogTrack::updateXAxisAndGridTickIntervals()
{
int majorTickIntervals = 5;
int minorTickIntervals = 10;
m_plotWidget->setAutoTickIntervalCounts( QwtPlot::xTop, majorTickIntervals, minorTickIntervals );
m_plotWidget->setAxisRange( QwtPlot::xTop, m_visibleXRangeMin, m_visibleXRangeMax );
m_plotWidget->setAutoTickIntervalCounts( RiaDefines::PlotAxis::PLOT_AXIS_TOP,
majorTickIntervals,
minorTickIntervals );
m_plotWidget->setAxisRange( RiaDefines::PlotAxis::PLOT_AXIS_TOP, m_visibleXRangeMin, m_visibleXRangeMax );
}
m_plotWidget->enableGridLines( QwtPlot::xTop,
m_plotWidget->enableGridLines( RiaDefines::PlotAxis::PLOT_AXIS_TOP,
m_xAxisGridVisibility() & RimWellLogPlot::AXIS_GRID_MAJOR,
m_xAxisGridVisibility() & RimWellLogPlot::AXIS_GRID_MINOR );
}
@ -830,7 +832,7 @@ void RimWellLogTrack::updateXAxisAndGridTickIntervals()
this->firstAncestorOrThisOfType( wellLogPlot );
if ( wellLogPlot )
{
m_plotWidget->enableGridLines( QwtPlot::yLeft,
m_plotWidget->enableGridLines( RiaDefines::PlotAxis::PLOT_AXIS_LEFT,
wellLogPlot->depthAxisGridLinesEnabled() & RimWellLogPlot::AXIS_GRID_MAJOR,
wellLogPlot->depthAxisGridLinesEnabled() & RimWellLogPlot::AXIS_GRID_MINOR );
}
@ -1004,15 +1006,15 @@ QString RimWellLogTrack::asciiDataForPlotExport() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::updateZoomFromQwt()
void RimWellLogTrack::updateZoomFromParentPlot()
{
QwtInterval xInterval = m_plotWidget->axisRange( QwtPlot::xTop );
QwtInterval depthInterval = m_plotWidget->axisRange( QwtPlot::yLeft );
auto [xIntervalMin, xIntervalMax] = m_plotWidget->axisRange( RiaDefines::PlotAxis::PLOT_AXIS_TOP );
auto [depthIntervalMin, depthIntervalMax] = m_plotWidget->axisRange( RiaDefines::PlotAxis::PLOT_AXIS_LEFT );
m_visibleXRangeMin = xInterval.minValue();
m_visibleXRangeMax = xInterval.maxValue();
m_visibleDepthRangeMin = depthInterval.minValue();
m_visibleDepthRangeMax = depthInterval.maxValue();
m_visibleXRangeMin = xIntervalMin;
m_visibleXRangeMax = xIntervalMax;
m_visibleDepthRangeMin = depthIntervalMin;
m_visibleDepthRangeMax = depthIntervalMax;
}
//--------------------------------------------------------------------------------------------------
@ -1120,7 +1122,7 @@ void RimWellLogTrack::addCurve( RimWellLogCurve* curve )
if ( m_plotWidget )
{
curve->setParentQwtPlotAndReplot( m_plotWidget );
curve->setParentPlotAndReplot( m_plotWidget );
}
}
@ -1141,7 +1143,7 @@ void RimWellLogTrack::insertCurve( RimWellLogCurve* curve, size_t index )
if ( m_plotWidget )
{
curve->setParentQwtPlotAndReplot( m_plotWidget );
curve->setParentPlotAndReplot( m_plotWidget );
}
}
}
@ -1154,7 +1156,7 @@ void RimWellLogTrack::removeCurve( RimWellLogCurve* curve )
size_t index = m_curves.index( curve );
if ( index < m_curves.size() )
{
m_curves[index]->detachQwtCurve();
m_curves[index]->detach();
m_curves.removeChildObject( curve );
}
}
@ -1226,8 +1228,8 @@ void RimWellLogTrack::onLoadDataAndUpdate()
if ( wellLogPlot && m_plotWidget )
{
m_plotWidget->setAxisTitleText( QwtPlot::xTop, m_xAxisTitle );
m_plotWidget->setAxisTitleText( QwtPlot::yLeft, wellLogPlot->depthAxisTitle() );
m_plotWidget->setAxisTitleText( RiaDefines::PlotAxis::PLOT_AXIS_TOP, m_xAxisTitle );
m_plotWidget->setAxisTitleText( RiaDefines::PlotAxis::PLOT_AXIS_LEFT, wellLogPlot->depthAxisTitle() );
}
for ( size_t cIdx = 0; cIdx < m_curves.size(); ++cIdx )
@ -1500,17 +1502,17 @@ RimWellLogTrack::TrajectoryType RimWellLogTrack::formationTrajectoryType() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuQwtPlotWidget* RimWellLogTrack::doCreatePlotViewWidget( QWidget* mainWindowParent )
RiuPlotWidget* RimWellLogTrack::doCreatePlotViewWidget( QWidget* mainWindowParent )
{
if ( m_plotWidget == nullptr )
{
m_plotWidget = new RiuWellLogTrack( this, mainWindowParent );
m_plotWidget->setAxisInverted( QwtPlot::yLeft );
m_plotWidget->setAxisInverted( RiaDefines::PlotAxis::PLOT_AXIS_LEFT, true );
updateAxisScaleEngine();
for ( size_t cIdx = 0; cIdx < m_curves.size(); ++cIdx )
{
m_curves[cIdx]->setParentQwtPlotNoReplot( this->m_plotWidget );
m_curves[cIdx]->setParentPlotNoReplot( m_plotWidget );
}
}
return m_plotWidget;
@ -1539,8 +1541,9 @@ void RimWellLogTrack::reattachAllCurves()
{
for ( RimPlotCurve* curve : m_curves )
{
curve->reattachQwtCurve();
curve->reattach();
}
for ( auto& plotObjects : m_wellPathAttributePlotObjects )
{
plotObjects->reattachToQwt();
@ -1597,7 +1600,7 @@ void RimWellLogTrack::setVisibleYRange( double minValue, double maxValue )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::updateZoomInQwt()
void RimWellLogTrack::updateZoomInParentPlot()
{
updateXZoom();
updateYZoom();
@ -1767,6 +1770,14 @@ RiuQwtPlotWidget* RimWellLogTrack::viewer()
return m_plotWidget;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuPlotWidget* RimWellLogTrack::plotWidget()
{
return m_plotWidget;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -1790,17 +1801,17 @@ void RimWellLogTrack::zoomAll()
{
setAutoScaleXEnabled( true );
setAutoScaleYEnabled( true );
updateZoomInQwt();
updateZoomInParentPlot();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmObject* RimWellLogTrack::findPdmObjectFromQwtCurve( const QwtPlotCurve* curve ) const
caf::PdmObject* RimWellLogTrack::findPdmObjectFromPlotCurve( const RiuPlotCurve* curve ) const
{
for ( size_t idx = 0; idx < m_curves.size(); idx++ )
{
if ( m_curves[idx]->qwtPlotCurve() == curve )
if ( m_curves[idx]->isSameCurve( curve ) )
{
return m_curves[idx];
}
@ -1965,17 +1976,17 @@ void RimWellLogTrack::updateAxisScaleEngine()
if ( m_isLogarithmicScaleEnabled )
{
m_plotWidget->setAxisScaleEngine( QwtPlot::xTop, new QwtLogScaleEngine );
m_plotWidget->qwtPlot()->setAxisScaleEngine( QwtPlot::xTop, new QwtLogScaleEngine );
// NB! Must assign scale engine to bottom in order to make QwtPlotGrid work
m_plotWidget->setAxisScaleEngine( QwtPlot::xBottom, new QwtLogScaleEngine );
m_plotWidget->qwtPlot()->setAxisScaleEngine( QwtPlot::xBottom, new QwtLogScaleEngine );
}
else
{
m_plotWidget->setAxisScaleEngine( QwtPlot::xTop, new RiuQwtLinearScaleEngine );
m_plotWidget->qwtPlot()->setAxisScaleEngine( QwtPlot::xTop, new RiuQwtLinearScaleEngine );
// NB! Must assign scale engine to bottom in order to make QwtPlotGrid work
m_plotWidget->setAxisScaleEngine( QwtPlot::xBottom, new RiuQwtLinearScaleEngine );
m_plotWidget->qwtPlot()->setAxisScaleEngine( QwtPlot::xBottom, new RiuQwtLinearScaleEngine );
}
}
@ -2030,7 +2041,7 @@ void RimWellLogTrack::handleWheelEvent( QWheelEvent* event )
{
if ( event->modifiers() & Qt::ControlModifier )
{
QwtScaleMap scaleMap = m_plotWidget->canvasMap( QwtPlot::yLeft );
QwtScaleMap scaleMap = m_plotWidget->qwtPlot()->canvasMap( QwtPlot::yLeft );
double zoomCenter = scaleMap.invTransform( event->pos().y() );
if ( event->delta() > 0 )
@ -2606,7 +2617,7 @@ void RimWellLogTrack::updateFormationNamesOnPlot()
std::vector<double> convertedYValues =
RiaWellLogUnitTools<double>::convertDepths( yValues, fromDepthUnit, toDepthUnit );
m_annotationTool->attachWellPicks( m_plotWidget, formationNamesToPlot, convertedYValues );
m_annotationTool->attachWellPicks( m_plotWidget->qwtPlot(), formationNamesToPlot, convertedYValues );
}
else
{
@ -2674,7 +2685,7 @@ void RimWellLogTrack::updateFormationNamesOnPlot()
const std::vector<std::pair<double, double>> convertedYValues =
RiaWellLogUnitTools<double>::convertDepths( waterAndRockIntervals, fromDepthUnit, toDepthUnit );
m_annotationTool->attachNamedRegions( m_plotWidget,
m_annotationTool->attachNamedRegions( m_plotWidget->qwtPlot(),
{ "Sea Level", "" },
xRange,
convertedYValues,
@ -2686,7 +2697,7 @@ void RimWellLogTrack::updateFormationNamesOnPlot()
{ Qt::SolidPattern, Qt::Dense6Pattern } );
}
if ( m_formationSource == CASE )
if ( m_formationSource == CASE && m_plotWidget )
{
if ( ( m_formationSimWellName == QString( "None" ) && m_formationWellPathForSourceCase == nullptr ) ||
m_formationCase == nullptr )
@ -2719,7 +2730,7 @@ void RimWellLogTrack::updateFormationNamesOnPlot()
RiaWellLogUnitTools<double>::convertDepths( yValues, fromDepthUnit, toDepthUnit );
caf::ColorTable colorTable( m_colorShadingLegend->colorArray() );
m_annotationTool->attachNamedRegions( m_plotWidget,
m_annotationTool->attachNamedRegions( m_plotWidget->qwtPlot(),
formationNamesToPlot,
xRange,
convertedYValues,
@ -2847,7 +2858,7 @@ void RimWellLogTrack::updateResultPropertyNamesOnPlot()
int fontSize = caf::FontTools::absolutePointSize( RiaPreferences::current()->defaultPlotFontSize(),
m_regionLabelFontSize() );
m_annotationTool->attachNamedRegions( m_plotWidget,
m_annotationTool->attachNamedRegions( m_plotWidget->qwtPlot(),
namesToPlot,
xRange,
convertedYValues,
@ -2924,7 +2935,7 @@ void RimWellLogTrack::updateCurveDataRegionsOnPlot()
std::vector<std::pair<double, double>> convertedYValues =
RiaWellLogUnitTools<double>::convertDepths( yValues, fromDepthUnit, toDepthUnit );
m_annotationTool->attachNamedRegions( m_plotWidget,
m_annotationTool->attachNamedRegions( m_plotWidget->qwtPlot(),
sourceNamesToPlot,
xRange,
convertedYValues,
@ -2955,7 +2966,7 @@ void RimWellLogTrack::updateCurveDataRegionsOnPlot()
std::vector<std::pair<double, double>> convertedYValues =
RiaWellLogUnitTools<double>::convertDepths( yValues, fromDepthUnit, toDepthUnit );
m_annotationTool->attachNamedRegions( m_plotWidget,
m_annotationTool->attachNamedRegions( m_plotWidget->qwtPlot(),
sourceNamesToPlot,
xRange,
convertedYValues,
@ -2985,7 +2996,7 @@ void RimWellLogTrack::updateCurveDataRegionsOnPlot()
std::vector<std::pair<double, double>> convertedYValues =
RiaWellLogUnitTools<double>::convertDepths( yValues, fromDepthUnit, toDepthUnit );
m_annotationTool->attachNamedRegions( m_plotWidget,
m_annotationTool->attachNamedRegions( m_plotWidget->qwtPlot(),
sourceNamesToPlot,
xRange,
convertedYValues,
@ -3084,7 +3095,7 @@ void RimWellLogTrack::updateWellPathAttributesOnPlot()
attributePlotObject->setDepthType( depthType );
attributePlotObject->setShowLabel( m_showWellPathComponentLabels() );
attributePlotObject->loadDataAndUpdate( false );
attributePlotObject->setParentQwtPlotNoReplot( m_plotWidget );
attributePlotObject->setParentPlotNoReplot( m_plotWidget->qwtPlot() );
}
}
updateXZoom();
@ -3117,7 +3128,7 @@ void RimWellLogTrack::onChildDeleted( caf::PdmChildArrayFieldHandle* childA
std::vector<caf::PdmObjectHandle*>& referringObjects )
{
setAutoScaleXEnabled( true );
updateZoomInQwt();
updateZoomInParentPlot();
RiuPlotMainWindow* mainPlotWindow = RiaGuiApplication::instance()->mainPlotWindow();
mainPlotWindow->updateWellLogPlotToolBar();
}

View File

@ -31,8 +31,6 @@
#include "cafPdmObject.h"
#include "cafPdmPtrField.h"
#include "qwt_plot.h"
#include <QPointer>
#include <map>
@ -58,8 +56,6 @@ class RimEclipseResultDefinition;
class RimColorLegend;
class RimEnsembleWellLogCurveSet;
class QwtPlotCurve;
struct CurveSamplingPointData
{
std::vector<double> data;
@ -97,7 +93,8 @@ public:
~RimWellLogTrack() override;
QWidget* viewWidget() override;
RiuQwtPlotWidget* viewer() override;
RiuQwtPlotWidget* viewer();
RiuPlotWidget* plotWidget() override;
QImage snapshotWindowContent() override;
void zoomAll() override;
@ -153,8 +150,8 @@ public:
void setVisibleXRange( double minValue, double maxValue );
void setVisibleYRange( double minValue, double maxValue );
void updateZoomInQwt() override;
void updateZoomFromQwt() override;
void updateZoomInParentPlot() override;
void updateZoomFromParentPlot() override;
void updateParentPlotZoom();
@ -188,7 +185,7 @@ public:
RimWellPath* wellPathAttributeSource() const;
caf::PdmObject* findPdmObjectFromQwtCurve( const QwtPlotCurve* curve ) const override;
caf::PdmObject* findPdmObjectFromPlotCurve( const RiuPlotCurve* curve ) const override;
void setLogarithmicScale( bool enable );
bool isLogarithmicScale() const;
@ -241,7 +238,7 @@ protected:
void onLoadDataAndUpdate() override;
private:
RiuQwtPlotWidget* doCreatePlotViewWidget( QWidget* mainWindowParent = nullptr ) override;
RiuPlotWidget* doCreatePlotViewWidget( QWidget* mainWindowParent = nullptr ) override;
void cleanupBeforeClose();
void detachAllPlotItems();

View File

@ -136,7 +136,7 @@ void RimWellMeasurementCurve::onLoadDataAndUpdate( bool updateParentPlot )
if ( m_isUsingAutoName )
{
m_qwtPlotCurve->setTitle( createCurveAutoName() );
m_plotCurve->setTitle( createCurveAutoName() );
}
setSymbol( getSymbolForMeasurementKind( m_measurementKind() ) );
@ -156,10 +156,10 @@ void RimWellMeasurementCurve::onLoadDataAndUpdate( bool updateParentPlot )
depthType = wellLogPlot->depthType();
}
m_qwtPlotCurve->setSamples( this->curveData()->xPlotValues().data(),
this->curveData()->depthPlotValues( depthType, displayUnit ).data(),
static_cast<int>( this->curveData()->xPlotValues().size() ) );
m_qwtPlotCurve->setLineSegmentStartStopIndices( this->curveData()->polylineStartStopIndices() );
m_plotCurve->setSamplesFromXValuesAndYValues( this->curveData()->xPlotValues(),
this->curveData()->depthPlotValues( depthType, displayUnit ),
static_cast<int>( this->curveData()->xPlotValues().size() ) );
m_plotCurve->setLineSegmentStartStopIndices( this->curveData()->polylineStartStopIndices() );
}
this->RimPlotCurve::updateCurvePresentation( updateParentPlot );
@ -169,9 +169,9 @@ void RimWellMeasurementCurve::onLoadDataAndUpdate( bool updateParentPlot )
updateZoomInParentPlot();
}
if ( m_parentQwtPlot )
if ( m_parentPlot )
{
m_parentQwtPlot->replot();
m_parentPlot->replot();
}
}
@ -205,7 +205,7 @@ void RimWellMeasurementCurve::fieldChangedByUi( const caf::PdmFieldHandle* chang
this->loadDataAndUpdate( true );
}
if ( m_parentQwtPlot ) m_parentQwtPlot->replot();
if ( m_parentPlot ) m_parentPlot->replot();
}
//--------------------------------------------------------------------------------------------------
@ -350,25 +350,25 @@ void RimWellMeasurementCurve::setMeasurementKind( const QString& measurementKind
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuQwtSymbol::PointSymbolEnum RimWellMeasurementCurve::getSymbolForMeasurementKind( const QString& measurementKind )
RiuPlotCurveSymbol::PointSymbolEnum RimWellMeasurementCurve::getSymbolForMeasurementKind( const QString& measurementKind )
{
std::map<QString, RiuQwtSymbol::PointSymbolEnum> symbolTable;
symbolTable["XLOT"] = RiuQwtSymbol::SYMBOL_RECT;
symbolTable["LOT"] = RiuQwtSymbol::SYMBOL_TRIANGLE;
symbolTable["FIT"] = RiuQwtSymbol::SYMBOL_DIAMOND;
symbolTable["MCF"] = RiuQwtSymbol::SYMBOL_ELLIPSE;
symbolTable["MNF"] = RiuQwtSymbol::SYMBOL_ELLIPSE;
symbolTable["TH"] = RiuQwtSymbol::SYMBOL_STAR1;
symbolTable["LE"] = RiuQwtSymbol::SYMBOL_STAR2;
symbolTable["BA"] = RiuQwtSymbol::SYMBOL_STAR1;
symbolTable["CORE"] = RiuQwtSymbol::SYMBOL_RECT;
symbolTable["PPG"] = RiuQwtSymbol::SYMBOL_RECT;
std::map<QString, RiuPlotCurveSymbol::PointSymbolEnum> symbolTable;
symbolTable["XLOT"] = RiuPlotCurveSymbol::SYMBOL_RECT;
symbolTable["LOT"] = RiuPlotCurveSymbol::SYMBOL_TRIANGLE;
symbolTable["FIT"] = RiuPlotCurveSymbol::SYMBOL_DIAMOND;
symbolTable["MCF"] = RiuPlotCurveSymbol::SYMBOL_ELLIPSE;
symbolTable["MNF"] = RiuPlotCurveSymbol::SYMBOL_ELLIPSE;
symbolTable["TH"] = RiuPlotCurveSymbol::SYMBOL_STAR1;
symbolTable["LE"] = RiuPlotCurveSymbol::SYMBOL_STAR2;
symbolTable["BA"] = RiuPlotCurveSymbol::SYMBOL_STAR1;
symbolTable["CORE"] = RiuPlotCurveSymbol::SYMBOL_RECT;
symbolTable["PPG"] = RiuPlotCurveSymbol::SYMBOL_RECT;
auto it = symbolTable.find( measurementKind );
if ( it != symbolTable.end() )
return it->second;
else
return RiuQwtSymbol::SYMBOL_CROSS;
return RiuPlotCurveSymbol::SYMBOL_CROSS;
}
//--------------------------------------------------------------------------------------------------

View File

@ -63,8 +63,8 @@ protected:
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
bool* useOptionsOnly ) override;
RiuQwtSymbol::PointSymbolEnum getSymbolForMeasurementKind( const QString& measurementKind );
cvf::Color3f getColorForMeasurementKind( const QString& measurementKind );
RiuPlotCurveSymbol::PointSymbolEnum getSymbolForMeasurementKind( const QString& measurementKind );
cvf::Color3f getColorForMeasurementKind( const QString& measurementKind );
protected:
caf::PdmPtrField<RimWellPath*> m_wellPath;

View File

@ -5,10 +5,13 @@ set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RiuFemResultTextBuilder.h
${CMAKE_CURRENT_LIST_DIR}/RiuGeoQuestNavigation.h
${CMAKE_CURRENT_LIST_DIR}/RiuInterfaceToViewWindow.h
${CMAKE_CURRENT_LIST_DIR}/RiuPlotCurveSymbol.h
${CMAKE_CURRENT_LIST_DIR}/RiuQwtSymbol.h
${CMAKE_CURRENT_LIST_DIR}/RiuPlotCurve.h
${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotCurve.h
${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotCurveDefines.h
${CMAKE_CURRENT_LIST_DIR}/RiuRimQwtPlotCurve.h
${CMAKE_CURRENT_LIST_DIR}/RiuPlotItem.h
${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotItem.h
${CMAKE_CURRENT_LIST_DIR}/RiuPlotMainWindow.h
${CMAKE_CURRENT_LIST_DIR}/RiuMainWindow.h
${CMAKE_CURRENT_LIST_DIR}/RiuMainWindowBase.h
@ -38,6 +41,7 @@ set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RiuDockedQwtPlot.h
${CMAKE_CURRENT_LIST_DIR}/RiuGridCrossQwtPlot.h
${CMAKE_CURRENT_LIST_DIR}/RiuSummaryQwtPlot.h
${CMAKE_CURRENT_LIST_DIR}/RiuSummaryPlot.h
${CMAKE_CURRENT_LIST_DIR}/RiuTextDialog.h
${CMAKE_CURRENT_LIST_DIR}/RiuTimeStepChangedHandler.h
${CMAKE_CURRENT_LIST_DIR}/RiuTofAccumulatedPhaseFractionsPlot.h
@ -52,6 +56,7 @@ set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RiuWellLogTrack.h
${CMAKE_CURRENT_LIST_DIR}/RiuMultiPlotPage.h
${CMAKE_CURRENT_LIST_DIR}/RiuMultiPlotBook.h
${CMAKE_CURRENT_LIST_DIR}/RiuPlotWidget.h
${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotWidget.h
${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotLegend.h
${CMAKE_CURRENT_LIST_DIR}/RiuPlotAnnotationTool.h
@ -102,10 +107,12 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RiuFemResultTextBuilder.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuGeoQuestNavigation.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuInterfaceToViewWindow.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuPlotCurveSymbol.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuQwtSymbol.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuPlotCurve.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotCurve.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotCurveDefines.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuRimQwtPlotCurve.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotItem.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuPlotMainWindow.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuMainWindow.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuMainWindowBase.cpp
@ -134,6 +141,7 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RiuDockedQwtPlot.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuGridCrossQwtPlot.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuSummaryQwtPlot.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuSummaryPlot.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuTextDialog.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuTimeStepChangedHandler.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuTofAccumulatedPhaseFractionsPlot.cpp
@ -147,6 +155,7 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RiuWellLogPlot.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuMultiPlotPage.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuMultiPlotBook.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuPlotWidget.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotWidget.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotLegend.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuPlotAnnotationTool.cpp
@ -190,12 +199,32 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RiuTextContentFrame.cpp
)
if(Qt5Charts_FOUND)
list(APPEND CODE_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RiuQtChartView.h)
if(RESINSIGHT_USE_QT_CHARTS)
list(
APPEND
CODE_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RiuQtChartView.h
${CMAKE_CURRENT_LIST_DIR}/RiuQtChartsPlotCurve.h
${CMAKE_CURRENT_LIST_DIR}/RiuQtChartsPlotWidget.h
${CMAKE_CURRENT_LIST_DIR}/RiuQtChartsPlotTools.h
${CMAKE_CURRENT_LIST_DIR}/RiuQtChartsPlotCurveSymbol.h
${CMAKE_CURRENT_LIST_DIR}/RiuSummaryQtChartsPlot.h
)
list(APPEND CODE_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RiuQtChartView.cpp)
list(
APPEND
CODE_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RiuQtChartView.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuQtChartsPlotCurve.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuQtChartsPlotWidget.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuQtChartsPlotTools.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuQtChartsPlotCurveSymbol.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuSummaryQtChartsPlot.cpp
)
# list(APPEND QT_MOC_HEADERS ${CMAKE_CURRENT_LIST_DIR}/RiuQtChartView.h)
list(APPEND QT_MOC_HEADERS ${CMAKE_CURRENT_LIST_DIR}/RiuQtChartsPlotWidget.h
${CMAKE_CURRENT_LIST_DIR}/RiuSummaryQtChartsPlot.h
)
endif()
list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})
@ -224,11 +253,13 @@ list(
${CMAKE_CURRENT_LIST_DIR}/RiuMultiPlotPage.h
${CMAKE_CURRENT_LIST_DIR}/RiuMultiPlotBook.h
${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotWidget.h
${CMAKE_CURRENT_LIST_DIR}/RiuPlotWidget.h
${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotLegend.h
${CMAKE_CURRENT_LIST_DIR}/RiuRecentFileActionProvider.h
${CMAKE_CURRENT_LIST_DIR}/RiuDockedQwtPlot.h
${CMAKE_CURRENT_LIST_DIR}/RiuGridCrossQwtPlot.h
${CMAKE_CURRENT_LIST_DIR}/RiuSummaryQwtPlot.h
${CMAKE_CURRENT_LIST_DIR}/RiuSummaryPlot.h
${CMAKE_CURRENT_LIST_DIR}/RiuTofAccumulatedPhaseFractionsPlot.h
${CMAKE_CURRENT_LIST_DIR}/RiuQwtScalePicker.h
${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotWheelZoomer.h

View File

@ -25,10 +25,12 @@
#include "RimFlowCharacteristicsPlot.h"
#include "RiuPlotCurveSymbol.h"
#include "RiuQwtPlotCurve.h"
#include "RiuQwtPlotTools.h"
#include "RiuQwtPlotWheelZoomer.h"
#include "RiuQwtPlotZoomer.h"
#include "RiuQwtSymbol.h"
#include "RiuResultQwtPlot.h"
#include "cvfColor3.h"
@ -39,7 +41,6 @@
#include "qwt_legend.h"
#include "qwt_plot.h"
#include "qwt_plot_zoomer.h"
#include "qwt_symbol.h"
#include <QBoxLayout>
#include <QContextMenuEvent>
@ -194,9 +195,7 @@ void RiuFlowCharacteristicsPlot::addCurveWithLargeSymbol( QwtPlot* plot,
{
auto curve = createEmptyCurve( plot, curveName, color );
QwtSymbol::Style style = QwtSymbol::Diamond;
QwtSymbol* symbol = new QwtSymbol( style );
RiuPlotCurveSymbol* symbol = new RiuQwtSymbol( RiuPlotCurveSymbol::PointSymbolEnum::SYMBOL_DIAMOND );
symbol->setSize( 15, 15 );
symbol->setColor( color );
@ -221,7 +220,7 @@ void RiuFlowCharacteristicsPlot::addCurveWithLargeSymbol( QwtPlot* plot,
RiuQwtPlotCurve*
RiuFlowCharacteristicsPlot::createEmptyCurve( QwtPlot* plot, const QString& curveName, const QColor& curveColor )
{
RiuQwtPlotCurve* plotCurve = new RiuQwtPlotCurve( curveName );
RiuQwtPlotCurve* plotCurve = new RiuQwtPlotCurve( nullptr, curveName );
plotCurve->setTitle( curveName );
plotCurve->setPen( QPen( curveColor ) );

View File

@ -22,8 +22,6 @@
#include "cafPdmPointer.h"
#include "qwt_plot.h"
#include <QFrame>
#include <QPointer>
@ -33,6 +31,7 @@ class RiuResultQwtPlot;
class RiuQwtPlotCurve;
class QLabel;
class QwtPlot;
namespace cvf
{

View File

@ -30,11 +30,12 @@
#include "RiuContextMenuLauncher.h"
#include "RiuGuiTheme.h"
#include "RiuPlotAnnotationTool.h"
#include "RiuPlotCurve.h"
#include "RiuQwtCurvePointTracker.h"
#include "RiuQwtPlotItem.h"
#include "RiuQwtPlotTools.h"
#include "RiuQwtPlotWheelZoomer.h"
#include "RiuQwtPlotZoomer.h"
#include "RiuRimQwtPlotCurve.h"
#include "RiuWidgetDragger.h"
#include "cafCmdFeatureMenuBuilder.h"
@ -44,6 +45,7 @@
#include "qwt_legend.h"
#include "qwt_legend_label.h"
#include "qwt_plot_curve.h"
#include "qwt_plot_panner.h"
#include "qwt_scale_draw.h"
#include "qwt_scale_widget.h"
@ -62,29 +64,29 @@ RiuGridCrossQwtPlot::RiuGridCrossQwtPlot( RimGridCrossPlot* plot, QWidget* paren
: RiuQwtPlotWidget( plot, parent )
{
// LeftButton for the zooming
m_zoomerLeft = new RiuQwtPlotZoomer( canvas() );
m_zoomerLeft = new RiuQwtPlotZoomer( qwtPlot()->canvas() );
m_zoomerLeft->setTrackerMode( QwtPicker::AlwaysOff );
m_zoomerLeft->initMousePattern( 1 );
// Attach a zoomer for the right axis
m_zoomerRight = new RiuQwtPlotZoomer( canvas() );
m_zoomerRight->setAxis( xTop, yRight );
m_zoomerRight = new RiuQwtPlotZoomer( qwtPlot()->canvas() );
m_zoomerRight->setAxis( QwtPlot::xTop, QwtPlot::yRight );
m_zoomerRight->setTrackerMode( QwtPicker::AlwaysOff );
m_zoomerRight->initMousePattern( 1 );
// MidButton for the panning
QwtPlotPanner* panner = new QwtPlotPanner( canvas() );
QwtPlotPanner* panner = new QwtPlotPanner( qwtPlot()->canvas() );
panner->setMouseButton( Qt::MidButton );
auto wheelZoomer = new RiuQwtPlotWheelZoomer( this );
auto wheelZoomer = new RiuQwtPlotWheelZoomer( qwtPlot() );
connect( wheelZoomer, SIGNAL( zoomUpdated() ), SLOT( onZoomedSlot() ) );
connect( m_zoomerLeft, SIGNAL( zoomed( const QRectF& ) ), SLOT( onZoomedSlot() ) );
connect( m_zoomerRight, SIGNAL( zoomed( const QRectF& ) ), SLOT( onZoomedSlot() ) );
connect( panner, SIGNAL( panned( int, int ) ), SLOT( onZoomedSlot() ) );
connect( this,
SIGNAL( plotItemSelected( QwtPlotItem*, bool, int ) ),
SLOT( onPlotItemSelected( QwtPlotItem*, bool, int ) ) );
SIGNAL( plotItemSelected( std::shared_ptr<RiuPlotItem>, bool, int ) ),
SLOT( onPlotItemSelected( std::shared_ptr<RiuPlotItem>, bool, int ) ) );
m_annotationTool = std::unique_ptr<RiuPlotAnnotationTool>( new RiuPlotAnnotationTool() );
m_selectedPointMarker = new QwtPlotMarker;
@ -99,11 +101,11 @@ RiuGridCrossQwtPlot::RiuGridCrossQwtPlot( RimGridCrossPlot* plot, QWidget* paren
m_selectedPointMarker->setSpacing( 3 );
m_selectedPointMarker->setZ( 1000.0 ); // Make sure it ends up in front of highlighted curves.
RiuQwtPlotTools::setCommonPlotBehaviour( this );
RiuQwtPlotTools::setDefaultAxes( this );
RiuQwtPlotTools::setCommonPlotBehaviour( qwtPlot() );
RiuQwtPlotTools::setDefaultAxes( qwtPlot() );
this->installEventFilter( this );
this->canvas()->installEventFilter( this );
this->qwtPlot()->canvas()->installEventFilter( this );
setInternalQwtLegendVisible( true );
@ -139,7 +141,7 @@ void RiuGridCrossQwtPlot::updateAnnotationObjects( RimPlotAxisPropertiesInterfac
for ( auto annotation : axisProperties->annotations() )
{
m_annotationTool->attachAnnotationLine( this,
m_annotationTool->attachAnnotationLine( qwtPlot(),
annotation->color(),
annotation->name(),
annotation->value(),
@ -152,13 +154,13 @@ void RiuGridCrossQwtPlot::updateAnnotationObjects( RimPlotAxisPropertiesInterfac
//--------------------------------------------------------------------------------------------------
void RiuGridCrossQwtPlot::setLegendFontSize( int fontSize )
{
if ( legend() )
if ( qwtPlot()->legend() )
{
QFont font = legend()->font();
QFont font = qwtPlot()->legend()->font();
font.setPixelSize( caf::FontTools::pointSizeToPixelSize( fontSize ) );
legend()->setFont( font );
qwtPlot()->legend()->setFont( font );
// Set font size for all existing labels
QList<QwtLegendLabel*> labels = legend()->findChildren<QwtLegendLabel*>();
QList<QwtLegendLabel*> labels = qwtPlot()->legend()->findChildren<QwtLegendLabel*>();
for ( QwtLegendLabel* label : labels )
{
label->setFont( font );
@ -174,29 +176,32 @@ void RiuGridCrossQwtPlot::setInternalQwtLegendVisible( bool visible )
if ( visible )
{
QwtLegend* legend = new QwtLegend( this );
this->insertLegend( legend, BottomLegend );
this->qwtPlot()->insertLegend( legend, QwtPlot::BottomLegend );
}
else
{
this->insertLegend( nullptr );
this->qwtPlot()->insertLegend( nullptr );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuGridCrossQwtPlot::onPlotItemSelected( QwtPlotItem* plotItem, bool toggle, int pointNumber )
void RiuGridCrossQwtPlot::onPlotItemSelected( std::shared_ptr<RiuPlotItem> plotItem, bool toggle, int pointNumber )
{
if ( pointNumber == -1 )
m_selectedPointMarker->detach();
else
{
QwtPlotCurve* curve = dynamic_cast<QwtPlotCurve*>( plotItem );
RiuQwtPlotItem* qwtPlotItem = dynamic_cast<RiuQwtPlotItem*>( plotItem.get() );
if ( !qwtPlotItem ) return;
QwtPlotCurve* curve = dynamic_cast<QwtPlotCurve*>( qwtPlotItem->qwtPlotItem() );
if ( curve )
{
QPointF sample = curve->sample( pointNumber );
m_selectedPointMarker->setValue( sample );
m_selectedPointMarker->setAxes( QwtPlot::xBottom, QwtPlot::yLeft );
m_selectedPointMarker->attach( this );
m_selectedPointMarker->attach( qwtPlot() );
QString curveName, xAxisName, yAxisName;
if ( curveText( curve, &curveName, &xAxisName, &yAxisName ) )
{
@ -224,7 +229,7 @@ bool RiuGridCrossQwtPlot::curveText( const QwtPlotCurve* curve, QString* curveTi
{
CVF_ASSERT( curveTitle && xParamName && yParamName );
auto riuCurve = dynamic_cast<const RiuRimQwtPlotCurve*>( curve );
auto riuCurve = dynamic_cast<const RiuPlotCurve*>( curve );
if ( riuCurve )
{
auto crossPlotCurve = dynamic_cast<const RimGridCrossPlotCurve*>( riuCurve->ownerRimCurve() );

View File

@ -17,7 +17,6 @@
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RiuInterfaceToViewWindow.h"
#include "RiuPlotAnnotationTool.h"
#include "RiuQwtPlotWidget.h"
@ -58,7 +57,7 @@ public:
void updateAnnotationObjects( RimPlotAxisPropertiesInterface* axisProperties );
void setLegendFontSize( int fontSize );
void setLegendFontSize( int fontSize ) override;
void setInternalQwtLegendVisible( bool visible );
protected:
@ -68,7 +67,7 @@ protected:
private slots:
void onZoomedSlot();
void onPlotItemSelected( QwtPlotItem* selectedItem, bool toggleItem, int sampleIndex );
void onPlotItemSelected( std::shared_ptr<RiuPlotItem> selectedItem, bool toggleItem, int sampleIndex );
private:
std::unique_ptr<RiuPlotAnnotationTool> m_annotationTool;

View File

@ -20,9 +20,6 @@
#include "RiaColorTables.h"
#include "Riu3dSelectionManager.h"
#include "RiuQwtPlotTools.h"
#include "RigFemPart.h"
#include "RigFemPartCollection.h"
#include "RigFemPartGrid.h"
@ -37,12 +34,14 @@
#include "RimGeoMechResultDefinition.h"
#include "RimGeoMechView.h"
#include "Riu3dSelectionManager.h"
#include "RiuQwtPlotTools.h"
#include "cvfAssert.h"
#include <QPainterPath>
#include <QTimer>
#include <QWidget>
#include <qevent.h>
#include "qwt_legend.h"
#include "qwt_plot_curve.h"

View File

@ -20,12 +20,7 @@
#include "RiuDockedQwtPlot.h"
#include "qwt_plot.h"
#include "qwt_plot_curve.h"
#include "qwt_plot_item.h"
#include "cafTensor3.h"
#include "cvfColor3.h"
#include <array>
@ -38,6 +33,7 @@ class RiuSelectionItem;
class RimGeoMechCase;
class RimGeoMechResultDefinition;
class RiuGeoMechSelectionItem;
class QwtPlotCurve;
//==================================================================================================
//

View File

@ -29,19 +29,13 @@
#include "RiuMultiPlotPage.h"
#include "RiuPlotMainWindow.h"
#include "RiuPlotObjectPicker.h"
#include "RiuQwtPlotLegend.h"
#include "RiuQwtPlotWidget.h"
#include "RiuPlotWidget.h"
#include "cafCmdFeatureMenuBuilder.h"
#include "cafSelectionManager.h"
#include "cvfAssert.h"
#include "qwt_legend.h"
#include "qwt_plot_layout.h"
#include "qwt_plot_renderer.h"
#include "qwt_scale_draw.h"
#include <QDebug>
#include <QFocusEvent>
#include <QFontMetrics>
@ -156,7 +150,7 @@ RimViewWindow* RiuMultiPlotBook::ownerViewWindow() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotBook::addPlot( RiuQwtPlotWidget* plotWidget )
void RiuMultiPlotBook::addPlot( RiuPlotWidget* plotWidget )
{
// Push the plot to the back of the list
insertPlot( plotWidget, m_plotWidgets.size() );
@ -165,7 +159,7 @@ void RiuMultiPlotBook::addPlot( RiuQwtPlotWidget* plotWidget )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotBook::insertPlot( RiuQwtPlotWidget* plotWidget, size_t index )
void RiuMultiPlotBook::insertPlot( RiuPlotWidget* plotWidget, size_t index )
{
m_plotWidgets.insert( static_cast<int>( index ), plotWidget );
scheduleUpdate();
@ -174,7 +168,7 @@ void RiuMultiPlotBook::insertPlot( RiuQwtPlotWidget* plotWidget, size_t index )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotBook::removePlot( RiuQwtPlotWidget* plotWidget )
void RiuMultiPlotBook::removePlot( RiuPlotWidget* plotWidget )
{
if ( !plotWidget ) return;
@ -277,7 +271,7 @@ void RiuMultiPlotBook::setAxisFontSizes( int axisTitleFontSize, int axisValueFon
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RiuMultiPlotBook::indexOfPlotWidget( RiuQwtPlotWidget* plotWidget )
int RiuMultiPlotBook::indexOfPlotWidget( RiuPlotWidget* plotWidget )
{
return m_plotWidgets.indexOf( plotWidget );
}
@ -316,7 +310,7 @@ void RiuMultiPlotBook::scheduleUpdate()
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotBook::scheduleReplotOfAllPlots()
{
for ( RiuQwtPlotWidget* plotWidget : visiblePlotWidgets() )
for ( RiuPlotWidget* plotWidget : visiblePlotWidgets() )
{
plotWidget->scheduleReplot();
}
@ -466,10 +460,10 @@ void RiuMultiPlotBook::performUpdate()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<QPointer<RiuQwtPlotWidget>> RiuMultiPlotBook::visiblePlotWidgets() const
QList<QPointer<RiuPlotWidget>> RiuMultiPlotBook::visiblePlotWidgets() const
{
QList<QPointer<RiuQwtPlotWidget>> plotWidgets;
for ( QPointer<RiuQwtPlotWidget> plotWidget : m_plotWidgets )
QList<QPointer<RiuPlotWidget>> plotWidgets;
for ( QPointer<RiuPlotWidget> plotWidget : m_plotWidgets )
{
CAF_ASSERT( plotWidget );
if ( plotWidget->isChecked() )
@ -501,8 +495,8 @@ void RiuMultiPlotBook::createPages()
{
CAF_ASSERT( m_plotDefinition );
QList<QPointer<RiuQwtPlotWidget>> plotWidgets = this->visiblePlotWidgets();
auto rowAndColumnCount = this->rowAndColumnCount( plotWidgets.size() );
QList<QPointer<RiuPlotWidget>> plotWidgets = this->visiblePlotWidgets();
auto rowAndColumnCount = this->rowAndColumnCount( plotWidgets.size() );
int rowsPerPage = m_plotDefinition->rowsPerPage();
int row = 0;

View File

@ -17,7 +17,6 @@
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RiuInterfaceToViewWindow.h"
#include "RiuMultiPlotPage.h"
#include "cafPdmPointer.h"
@ -35,7 +34,7 @@
class RiaPlotWindowRedrawScheduler;
class RimMultiPlot;
class RiuMultiPlotPage;
class RiuQwtPlotWidget;
class RiuPlotWidget;
class BookFrame;
class QFocusEvent;
@ -63,9 +62,9 @@ public:
RimViewWindow* ownerViewWindow() const override;
void addPlot( RiuQwtPlotWidget* plotWidget );
void insertPlot( RiuQwtPlotWidget* plotWidget, size_t index );
void removePlot( RiuQwtPlotWidget* plotWidget );
void addPlot( RiuPlotWidget* plotWidget );
void insertPlot( RiuPlotWidget* plotWidget, size_t index );
void removePlot( RiuPlotWidget* plotWidget );
void removeAllPlots();
void setPlotTitle( const QString& plotTitle );
@ -77,7 +76,7 @@ public:
void setLegendFontSize( int legendFontSize );
void setAxisFontSizes( int axisTitleFontSize, int axisValueFontSize );
int indexOfPlotWidget( RiuQwtPlotWidget* plotWidget );
int indexOfPlotWidget( RiuPlotWidget* plotWidget );
bool pagePreviewModeEnabled() const;
void setPagePreviewModeEnabled( bool previewMode );
@ -100,7 +99,7 @@ protected:
virtual bool showYAxis( int row, int column ) const;
QList<QPointer<RiuQwtPlotWidget>> visiblePlotWidgets() const;
QList<QPointer<RiuPlotWidget>> visiblePlotWidgets() const;
private:
void deleteAllPages();
@ -120,7 +119,7 @@ protected:
QPointer<QVBoxLayout> m_bookLayout;
QList<QPointer<RiuMultiPlotPage>> m_pages;
QList<QPointer<RiuQwtPlotWidget>> m_plotWidgets;
QList<QPointer<RiuPlotWidget>> m_plotWidgets;
caf::PdmPointer<RimMultiPlot> m_plotDefinition;
QString m_plotTitle;
bool m_titleVisible;

View File

@ -34,6 +34,7 @@
#include "RiuMainWindow.h"
#include "RiuPlotMainWindow.h"
#include "RiuPlotObjectPicker.h"
#include "RiuPlotWidget.h"
#include "RiuQwtPlotLegend.h"
#include "RiuQwtPlotWidget.h"
@ -133,7 +134,7 @@ RimPlotWindow* RiuMultiPlotPage::ownerPlotDefinition()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotPage::addPlot( RiuQwtPlotWidget* plotWidget )
void RiuMultiPlotPage::addPlot( RiuPlotWidget* plotWidget )
{
// Insert the plot to the left of the scroll bar
insertPlot( plotWidget, m_plotWidgets.size() );
@ -142,7 +143,7 @@ void RiuMultiPlotPage::addPlot( RiuQwtPlotWidget* plotWidget )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotPage::insertPlot( RiuQwtPlotWidget* plotWidget, size_t index )
void RiuMultiPlotPage::insertPlot( RiuPlotWidget* plotWidget, size_t index )
{
m_plotWidgets.insert( static_cast<int>( index ), plotWidget );
plotWidget->setVisible( false );
@ -166,9 +167,13 @@ void RiuMultiPlotPage::insertPlot( RiuQwtPlotWidget* plotWidget, size_t index )
legend->setMaxColumns( legendColumns );
legend->horizontalScrollBar()->setVisible( false );
legend->verticalScrollBar()->setVisible( false );
legend->connect( plotWidget,
SIGNAL( legendDataChanged( const QVariant&, const QList<QwtLegendData>& ) ),
SLOT( updateLegend( const QVariant&, const QList<QwtLegendData>& ) ) );
RiuQwtPlotWidget* qwtPlotWidget = dynamic_cast<RiuQwtPlotWidget*>( plotWidget );
if ( qwtPlotWidget )
{
legend->connect( qwtPlotWidget->qwtPlot(),
SIGNAL( legendDataChanged( const QVariant&, const QList<QwtLegendData>& ) ),
SLOT( updateLegend( const QVariant&, const QList<QwtLegendData>& ) ) );
}
QObject::connect( legend, SIGNAL( legendUpdated() ), this, SLOT( onLegendUpdated() ) );
legend->contentsWidget()->layout()->setAlignment( Qt::AlignBottom | Qt::AlignHCenter );
@ -183,7 +188,7 @@ void RiuMultiPlotPage::insertPlot( RiuQwtPlotWidget* plotWidget, size_t index )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotPage::removePlot( RiuQwtPlotWidget* plotWidget )
void RiuMultiPlotPage::removePlot( RiuPlotWidget* plotWidget )
{
if ( !plotWidget ) return;
@ -215,7 +220,7 @@ void RiuMultiPlotPage::removePlot( RiuQwtPlotWidget* plotWidget )
void RiuMultiPlotPage::removeAllPlots()
{
auto plotWidgets = m_plotWidgets;
for ( RiuQwtPlotWidget* plotWidget : plotWidgets )
for ( RiuPlotWidget* plotWidget : plotWidgets )
{
removePlot( plotWidget );
}
@ -296,7 +301,7 @@ void RiuMultiPlotPage::setPagePreviewModeEnabled( bool previewMode )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RiuMultiPlotPage::indexOfPlotWidget( RiuQwtPlotWidget* plotWidget )
int RiuMultiPlotPage::indexOfPlotWidget( RiuPlotWidget* plotWidget )
{
return m_plotWidgets.indexOf( plotWidget );
}
@ -315,7 +320,7 @@ void RiuMultiPlotPage::scheduleUpdate()
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotPage::scheduleReplotOfAllPlots()
{
for ( RiuQwtPlotWidget* plotWidget : visiblePlotWidgets() )
for ( RiuPlotWidget* plotWidget : visiblePlotWidgets() )
{
plotWidget->scheduleReplot();
}
@ -517,7 +522,7 @@ void RiuMultiPlotPage::onSelectionManagerSelectionChanged( const std::set<int>&
{
if ( !m_plotDefinition ) return;
for ( RiuQwtPlotWidget* plotWidget : m_plotWidgets )
for ( RiuPlotWidget* plotWidget : m_plotWidgets )
{
CAF_ASSERT( plotWidget );
RimPlot* plot = plotWidget->plotDefinition();
@ -587,7 +592,7 @@ void RiuMultiPlotPage::reinsertPlotWidgets()
QList<QPointer<QLabel>> subTitles = this->subTitlesForVisiblePlots();
QList<QPointer<RiuQwtPlotLegend>> legends = this->legendsForVisiblePlots();
QList<QPointer<RiuQwtPlotWidget>> plotWidgets = this->visiblePlotWidgets();
QList<QPointer<RiuPlotWidget>> plotWidgets = this->visiblePlotWidgets();
if ( !plotWidgets.empty() )
{
@ -615,10 +620,10 @@ void RiuMultiPlotPage::reinsertPlotWidgets()
subTitleFont.setPixelSize( m_subTitleFontPixelSize );
subTitles[visibleIndex]->setFont( subTitleFont );
plotWidgets[visibleIndex]->setAxisLabelsAndTicksEnabled( QwtPlot::yLeft,
plotWidgets[visibleIndex]->setAxisLabelsAndTicksEnabled( RiaDefines::PlotAxis::PLOT_AXIS_LEFT,
showYAxis( row, column ),
showYAxis( row, column ) );
plotWidgets[visibleIndex]->setAxisTitleEnabled( QwtPlot::yLeft, showYAxis( row, column ) );
plotWidgets[visibleIndex]->setAxisTitleEnabled( RiaDefines::PlotAxis::PLOT_AXIS_LEFT, showYAxis( row, column ) );
plotWidgets[visibleIndex]->setAxesFontsAndAlignment( m_axisTitleFontSize, m_axisValueFontSize );
{
@ -679,7 +684,7 @@ int RiuMultiPlotPage::alignCanvasTops()
{
CVF_ASSERT( m_legends.size() == m_plotWidgets.size() );
QList<QPointer<RiuQwtPlotWidget>> plotWidgets = visiblePlotWidgets();
QList<QPointer<RiuPlotWidget>> plotWidgets = visiblePlotWidgets();
QList<QPointer<RiuQwtPlotLegend>> legends = legendsForVisiblePlots();
if ( plotWidgets.empty() ) return 0;
@ -689,22 +694,30 @@ int RiuMultiPlotPage::alignCanvasTops()
for ( int visibleIndex = 0; visibleIndex < plotWidgets.size(); ++visibleIndex )
{
int row = visibleIndex / rowAndColumnCount.second;
if ( plotWidgets[visibleIndex]->axisEnabled( QwtPlot::xTop ) )
RiuQwtPlotWidget* qwtPlotWidget = dynamic_cast<RiuQwtPlotWidget*>( plotWidgets[visibleIndex].data() );
if ( qwtPlotWidget )
{
QFont font = m_plotWidgets[visibleIndex]->axisFont( QwtPlot::xTop );
maxExtents[row] =
std::max( maxExtents[row], plotWidgets[visibleIndex]->axisScaleDraw( QwtPlot::xTop )->extent( font ) );
int row = visibleIndex / rowAndColumnCount.second;
if ( plotWidgets[visibleIndex]->axisEnabled( RiaDefines::PlotAxis::PLOT_AXIS_TOP ) )
{
QFont font = qwtPlotWidget->qwtPlot()->axisFont( QwtPlot::xTop );
maxExtents[row] = std::max( maxExtents[row],
qwtPlotWidget->qwtPlot()->axisScaleDraw( QwtPlot::xTop )->extent( font ) );
}
}
}
for ( int visibleIndex = 0; visibleIndex < plotWidgets.size(); ++visibleIndex )
{
int row = visibleIndex / rowAndColumnCount.second;
plotWidgets[visibleIndex]->axisScaleDraw( QwtPlot::xTop )->setMinimumExtent( maxExtents[row] );
if ( legends[visibleIndex] )
RiuQwtPlotWidget* qwtPlotWidget = dynamic_cast<RiuQwtPlotWidget*>( plotWidgets[visibleIndex].data() );
if ( qwtPlotWidget )
{
legends[visibleIndex]->adjustSize();
int row = visibleIndex / rowAndColumnCount.second;
qwtPlotWidget->qwtPlot()->axisScaleDraw( QwtPlot::xTop )->setMinimumExtent( maxExtents[row] );
if ( legends[visibleIndex] )
{
legends[visibleIndex]->adjustSize();
}
}
}
return maxExtents[0];
@ -740,10 +753,10 @@ void RiuMultiPlotPage::clearGridLayout()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<QPointer<RiuQwtPlotWidget>> RiuMultiPlotPage::visiblePlotWidgets() const
QList<QPointer<RiuPlotWidget>> RiuMultiPlotPage::visiblePlotWidgets() const
{
QList<QPointer<RiuQwtPlotWidget>> plotWidgets;
for ( QPointer<RiuQwtPlotWidget> plotWidget : m_plotWidgets )
QList<QPointer<RiuPlotWidget>> plotWidgets;
for ( QPointer<RiuPlotWidget> plotWidget : m_plotWidgets )
{
if ( plotWidget->isChecked() )
{

View File

@ -34,7 +34,7 @@
class RiaPlotWindowRedrawScheduler;
class RimPlotWindow;
class RiuQwtPlotLegend;
class RiuQwtPlotWidget;
class RiuPlotWidget;
class QFocusEvent;
class QLabel;
@ -70,11 +70,11 @@ public:
RimViewWindow* ownerViewWindow() const override;
RimPlotWindow* ownerPlotDefinition();
void addPlot( RiuQwtPlotWidget* plotWidget );
void insertPlot( RiuQwtPlotWidget* plotWidget, size_t index );
void removePlot( RiuQwtPlotWidget* plotWidget );
void addPlot( RiuPlotWidget* plotWidget );
void insertPlot( RiuPlotWidget* plotWidget, size_t index );
void removePlot( RiuPlotWidget* plotWidget );
void removeAllPlots();
int indexOfPlotWidget( RiuQwtPlotWidget* plotWidget );
int indexOfPlotWidget( RiuPlotWidget* plotWidget );
void setPlotTitle( const QString& plotTitle );
void setTitleVisible( bool visible );
@ -117,7 +117,7 @@ protected:
void clearGridLayout();
QList<QPointer<RiuQwtPlotWidget>> visiblePlotWidgets() const;
QList<QPointer<RiuPlotWidget>> visiblePlotWidgets() const;
QList<QPointer<RiuQwtPlotLegend>> legendsForVisiblePlots() const;
QList<QPointer<QLabel>> subTitlesForVisiblePlots() const;
@ -138,7 +138,7 @@ protected:
QPointer<QLabel> m_plotTitle;
QList<QPointer<QLabel>> m_subTitles;
QList<QPointer<RiuQwtPlotLegend>> m_legends;
QList<QPointer<RiuQwtPlotWidget>> m_plotWidgets;
QList<QPointer<RiuPlotWidget>> m_plotWidgets;
caf::PdmPointer<RimPlotWindow> m_plotDefinition;
int m_titleFontPixelSize;

View File

@ -0,0 +1,206 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2021- 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 "RiuPlotCurve.h"
#include "RiaCurveDataTools.h"
#include "RiaTimeTTools.h"
#include "RimPlotCurve.h"
#include "qwt_date.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuPlotCurve::RiuPlotCurve( RimPlotCurve* ownerRimCurve, const QString& title )
{
m_ownerRimCurve = ownerRimCurve;
m_symbolSkipPixelDistance = 10.0f;
m_blackAndWhiteLegendIcon = false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuPlotCurve::~RiuPlotCurve()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuPlotCurve::setSamplesValues( const std::vector<double>& xValues, const std::vector<double>& yValues )
{
setSamplesInPlot( xValues, yValues, static_cast<int>( xValues.size() ) );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuPlotCurve::setSamplesFromXValuesAndYValues( const std::vector<double>& xValues,
const std::vector<double>& yValues,
bool keepOnlyPositiveValues )
{
computeValidIntervalsAndSetCurveData( xValues, yValues, keepOnlyPositiveValues );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuPlotCurve::setSamplesFromDatesAndYValues( const std::vector<QDateTime>& dateTimes,
const std::vector<double>& yValues,
bool keepOnlyPositiveValues )
{
auto xValues = RiuPlotCurve::fromQDateTime( dateTimes );
computeValidIntervalsAndSetCurveData( xValues, yValues, keepOnlyPositiveValues );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuPlotCurve::setSamplesFromTimeTAndYValues( const std::vector<time_t>& dateTimes,
const std::vector<double>& yValues,
bool keepOnlyPositiveValues )
{
auto xValues = RiuPlotCurve::fromTime_t( dateTimes );
computeValidIntervalsAndSetCurveData( xValues, yValues, keepOnlyPositiveValues );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuPlotCurve::setLineSegmentStartStopIndices( const std::vector<std::pair<size_t, size_t>>& lineSegmentStartStopIndices )
{
m_polyLineStartStopIndices = lineSegmentStartStopIndices;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuPlotCurve::setSymbolSkipPixelDistance( float distance )
{
m_symbolSkipPixelDistance = distance >= 0.0f ? distance : 0.0f;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuPlotCurve::setPerPointLabels( const std::vector<QString>& labels )
{
m_perPointLabels = labels;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuPlotCurve::setBlackAndWhiteLegendIcon( bool blackAndWhite )
{
m_blackAndWhiteLegendIcon = blackAndWhite;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuPlotCurve::computeValidIntervalsAndSetCurveData( const std::vector<double>& xValues,
const std::vector<double>& yValues,
bool keepOnlyPositiveValues )
{
auto intervalsOfValidValues = RiaCurveDataTools::calculateIntervalsOfValidValues( yValues, keepOnlyPositiveValues );
std::vector<double> validYValues;
std::vector<double> validXValues;
RiaCurveDataTools::getValuesByIntervals( yValues, intervalsOfValidValues, &validYValues );
RiaCurveDataTools::getValuesByIntervals( xValues, intervalsOfValidValues, &validXValues );
setSamplesInPlot( validXValues, validYValues, static_cast<int>( validXValues.size() ) );
setLineSegmentStartStopIndices( RiaCurveDataTools::computePolyLineStartStopIndices( intervalsOfValidValues ) );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<double> RiuPlotCurve::fromQDateTime( const std::vector<QDateTime>& dateTimes )
{
std::vector<double> doubleValues;
if ( !dateTimes.empty() )
{
doubleValues.reserve( dateTimes.size() );
for ( const auto& dt : dateTimes )
{
// TODO: remove Qwt usage here..
doubleValues.push_back( QwtDate::toDouble( dt ) );
}
}
return doubleValues;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<double> RiuPlotCurve::fromTime_t( const std::vector<time_t>& timeSteps )
{
std::vector<double> doubleValues;
if ( !timeSteps.empty() )
{
doubleValues.reserve( timeSteps.size() );
for ( const auto& time : timeSteps )
{
doubleValues.push_back( RiaTimeTTools::toDouble( time ) );
}
}
return doubleValues;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuPlotCurve::setSamplesFromXYErrorValues( const std::vector<double>& xValues,
const std::vector<double>& yValues,
const std::vector<double>& errorValues,
bool keepOnlyPositiveValues,
RiaCurveDataTools::ErrorAxis errorAxis )
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimPlotCurve* RiuPlotCurve::ownerRimCurve()
{
return m_ownerRimCurve;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const RimPlotCurve* RiuPlotCurve::ownerRimCurve() const
{
return m_ownerRimCurve;
}

View File

@ -0,0 +1,150 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2021- 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 "RiaCurveDataTools.h"
#include "RiuPlotCurveSymbol.h"
#include "RiuPlotWidget.h"
#include "RiuQwtPlotCurveDefines.h"
#include <QBrush>
#include <QColor>
#include <QDateTime>
#include <QString>
class RimPlotCurve;
//==================================================================================================
//
// If infinite data is present in the curve data, Qwt is not able to draw a nice curve.
// This class assumes that inf data is removed, and segments to be draw are indicated by start/stop indices into curve
// data.
//
// Single values in the curve are drawn using a CrossX symbol
//
// Here you can see the curve segments visualized. Curve segments are drawn between vector indices.
//
// 0 - 1
// 5 - 7
// 9 -10
//
// * *
// * * *
// Curve * * * ----- X
//
// Values 1.0|2.0|inf|inf|inf|1.0|2.0|1.0|inf|1.0|1.0|inf|1.0|inf
// Vec index 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10| 11| 12| 13
//==================================================================================================
class RiuPlotCurve
{
public:
explicit RiuPlotCurve( RimPlotCurve* ownerRimCurve, const QString& title = QString() );
explicit RiuPlotCurve();
virtual ~RiuPlotCurve();
virtual void setTitle( const QString& title ) = 0;
virtual void setSamplesValues( const std::vector<double>& xValues, const std::vector<double>& yValues );
void setSamplesFromXValuesAndYValues( const std::vector<double>& xValues,
const std::vector<double>& yValues,
bool keepOnlyPositiveValues );
void setSamplesFromDatesAndYValues( const std::vector<QDateTime>& dateTimes,
const std::vector<double>& yValues,
bool keepOnlyPositiveValues );
void setSamplesFromTimeTAndYValues( const std::vector<time_t>& dateTimes,
const std::vector<double>& yValues,
bool keepOnlyPositiveValues );
virtual void setSamplesFromXYErrorValues(
const std::vector<double>& xValues,
const std::vector<double>& yValues,
const std::vector<double>& errorValues,
bool keepOnlyPositiveValues,
RiaCurveDataTools::ErrorAxis errorAxis = RiaCurveDataTools::ErrorAxis::ERROR_ALONG_Y_AXIS );
void setLineSegmentStartStopIndices( const std::vector<std::pair<size_t, size_t>>& lineSegmentStartStopIndices );
void setSymbolSkipPixelDistance( float distance );
void setPerPointLabels( const std::vector<QString>& labels );
virtual void setAppearance( RiuQwtPlotCurveDefines::LineStyleEnum lineStyle,
RiuQwtPlotCurveDefines::CurveInterpolationEnum interpolationType,
int curveThickness,
const QColor& curveColor,
const QBrush& fillBrush = QBrush( Qt::NoBrush ) ) = 0;
virtual void setBrush( const QBrush& brush ) = 0;
void setBlackAndWhiteLegendIcon( bool blackAndWhite );
virtual void setVisibleInLegend( bool isVisibleInLegend ) = 0;
virtual void setLegendIconSize( const QSize& iconSize ) = 0;
virtual QSize legendIconSize() const = 0;
virtual QPixmap legendIcon( const QSizeF& size ) const = 0;
virtual void attachToPlot( RiuPlotWidget* plotWidget ) = 0;
virtual void showInPlot() = 0;
virtual void detach() = 0;
static std::vector<double> fromQDateTime( const std::vector<QDateTime>& dateTimes );
static std::vector<double> fromTime_t( const std::vector<time_t>& timeSteps );
virtual void setZ( int z ) = 0;
virtual void updateErrorBarsAppearance( bool showErrorBars, const QColor& curveColor ) = 0;
virtual void clearErrorBars() = 0;
virtual int numSamples() const = 0;
virtual std::pair<double, double> sample( int index ) const = 0;
RimPlotCurve* ownerRimCurve();
const RimPlotCurve* ownerRimCurve() const;
virtual std::pair<double, double> xDataRange() const = 0;
virtual std::pair<double, double> yDataRange() const = 0;
virtual void setXAxis( RiaDefines::PlotAxis axis ) = 0;
virtual void setYAxis( RiaDefines::PlotAxis axis ) = 0;
virtual void setSymbol( RiuPlotCurveSymbol* symbol ) = 0;
virtual RiuPlotCurveSymbol* createSymbol( RiuPlotCurveSymbol::PointSymbolEnum symbol ) const = 0;
protected:
virtual void
setSamplesInPlot( const std::vector<double>& xValues, const std::vector<double>& yValues, int numSamples ) = 0;
private:
void computeValidIntervalsAndSetCurveData( const std::vector<double>& xValues,
const std::vector<double>& yValues,
bool keepOnlyPositiveValues );
protected:
float m_symbolSkipPixelDistance;
bool m_blackAndWhiteLegendIcon;
std::vector<QString> m_perPointLabels;
std::vector<std::pair<size_t, size_t>> m_polyLineStartStopIndices;
caf::PdmPointer<RimPlotCurve> m_ownerRimCurve;
};

View File

@ -0,0 +1,153 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Equinor ASA
// Copyright (C) 2015- Ceetron Solutions AS
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RiuPlotCurveSymbol.h"
#include "cafFontTools.h"
#include "cvfAssert.h"
#include <QPainter>
#include <QRect>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuPlotCurveSymbol::RiuPlotCurveSymbol( PointSymbolEnum riuStyle,
const QString& label,
LabelPosition labelPosition,
int labelFontSizePt )
: m_style( riuStyle )
, m_globalLabel( label )
, m_labelPosition( labelPosition )
, m_labelFontSizePx( caf::FontTools::pointSizeToPixelSize( labelFontSizePt ) )
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiuPlotCurveSymbol::globalLabel() const
{
return m_globalLabel;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuPlotCurveSymbol::setGlobalLabel( const QString& label )
{
m_globalLabel = label;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuPlotCurveSymbol::setLabelPosition( LabelPosition labelPosition )
{
m_labelPosition = labelPosition;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuPlotCurveSymbol::setLabelFontSize( int labelFontSizePt )
{
m_labelFontSizePx = caf::FontTools::pointSizeToPixelSize( labelFontSizePt );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuPlotCurveSymbol::PointSymbolEnum RiuPlotCurveSymbol::cycledSymbolStyle( int indexLevel1, int indexLevel2 )
{
std::vector<std::vector<PointSymbolEnum>> categorisedStyles = {
{ SYMBOL_ELLIPSE, SYMBOL_RECT, SYMBOL_DIAMOND },
{ SYMBOL_DOWN_TRIANGLE, SYMBOL_UP_TRIANGLE },
{ SYMBOL_LEFT_TRIANGLE, SYMBOL_RIGHT_TRIANGLE },
{ SYMBOL_CROSS, SYMBOL_XCROSS },
{ SYMBOL_STAR1, SYMBOL_STAR2 },
};
int level1Category = indexLevel1 % int( categorisedStyles.size() );
int level2Category = indexLevel2 % int( categorisedStyles[level1Category].size() );
return categorisedStyles[level1Category][level2Category];
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuPlotCurveSymbol::PointSymbolEnum RiuPlotCurveSymbol::cycledSymbolStyle( int indexLevel )
{
std::vector<PointSymbolEnum> contrastingSymbols = { SYMBOL_ELLIPSE,
SYMBOL_CROSS,
SYMBOL_RECT,
SYMBOL_DOWN_TRIANGLE,
SYMBOL_UP_TRIANGLE,
SYMBOL_LEFT_TRIANGLE,
SYMBOL_RIGHT_TRIANGLE,
SYMBOL_STAR2,
SYMBOL_DIAMOND,
SYMBOL_STAR1 };
return contrastingSymbols[indexLevel % (int)contrastingSymbols.size()];
}
//--------------------------------------------------------------------------------------------------
/// Is this a symbol with an interior and a border? If false, it is just lines.
//--------------------------------------------------------------------------------------------------
bool RiuPlotCurveSymbol::isFilledSymbol( PointSymbolEnum symbol )
{
return symbol != SYMBOL_NONE && symbol != SYMBOL_CROSS && symbol != SYMBOL_XCROSS && symbol != SYMBOL_STAR1;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QRect RiuPlotCurveSymbol::labelBoundingRect( const QPainter* painter, const QRect& symbolRect, const QString& label ) const
{
CVF_ASSERT( painter );
QPoint symbolPosition = symbolRect.topLeft();
int symbolWidth = symbolRect.width();
int symbolHeight = symbolRect.height();
int labelWidth = painter->fontMetrics().width( label );
int labelHeight = painter->fontMetrics().height();
QPoint labelPosition;
if ( m_labelPosition == LabelAboveSymbol )
{
labelPosition = QPoint( symbolPosition.x() - labelWidth / 2, symbolPosition.y() - 5 );
}
else if ( m_labelPosition == LabelBelowSymbol )
{
labelPosition = QPoint( symbolPosition.x() - labelWidth / 2, symbolPosition.y() + symbolHeight + 5 );
}
else if ( m_labelPosition == LabelLeftOfSymbol )
{
labelPosition = QPoint( symbolPosition.x() - labelWidth - symbolWidth, symbolPosition.y() );
}
else if ( m_labelPosition == LabelRightOfSymbol )
{
labelPosition = QPoint( symbolPosition.x() + symbolWidth + 3, symbolPosition.y() );
}
return QRect( labelPosition.x(), labelPosition.y(), labelWidth, labelHeight );
}

View File

@ -0,0 +1,101 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Equinor ASA
// Copyright (C) 2015- Ceetron Solutions AS
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include <QString>
class QColor;
class QPen;
class QPainter;
class QRect;
class QPixmap;
//--------------------------------------------------------------------------------------------------
/// Interface for plot curve symbol
//--------------------------------------------------------------------------------------------------
class RiuPlotCurveSymbol
{
public:
enum LabelPosition
{
LabelAboveSymbol,
LabelBelowSymbol,
LabelLeftOfSymbol,
LabelRightOfSymbol
};
enum PointSymbolEnum
{
SYMBOL_NONE,
SYMBOL_ELLIPSE,
SYMBOL_RECT,
SYMBOL_DIAMOND,
SYMBOL_TRIANGLE,
SYMBOL_DOWN_TRIANGLE,
SYMBOL_CROSS,
SYMBOL_XCROSS,
SYMBOL_LEFT_ALIGNED_TRIANGLE, // Aligned so pin point is at lower right corner
SYMBOL_RIGHT_ALIGNED_TRIANGLE, // Aligned so pin point is at lower left corner
SYMBOL_LEFT_ANGLED_TRIANGLE,
SYMBOL_RIGHT_ANGLED_TRIANGLE,
SYMBOL_UP_TRIANGLE,
SYMBOL_STAR1,
SYMBOL_STAR2,
SYMBOL_HEXAGON,
SYMBOL_LEFT_TRIANGLE,
SYMBOL_RIGHT_TRIANGLE
};
RiuPlotCurveSymbol( PointSymbolEnum riuStyle,
const QString& label,
LabelPosition labelPosition = LabelAboveSymbol,
int labelFontSizePt = 8 );
QString globalLabel() const;
void setGlobalLabel( const QString& label );
void setLabelPosition( LabelPosition labelPosition );
void setLabelFontSize( int labelFontSizePt );
virtual void setPixmap( const QPixmap& pixmap ) = 0;
virtual void setSize( int width, int height ) = 0;
virtual void setColor( const QColor& color ) = 0;
virtual void setPen( const QPen& pen ) = 0;
virtual QRect boundingRect() const = 0;
static PointSymbolEnum cycledSymbolStyle( int indexLevel1, int indexLevel2 );
static PointSymbolEnum cycledSymbolStyle( int indexLevel );
static bool isFilledSymbol( PointSymbolEnum symbol );
QRect labelBoundingRect( const QPainter* painter, const QRect& symbolRect, const QString& label ) const;
protected:
PointSymbolEnum m_style;
QString m_globalLabel;
int m_labelFontSizePx;
LabelPosition m_labelPosition;
};

Some files were not shown because too many files have changed in this diff Show More