Skip to content

Commit

Permalink
Merge pull request #8387 from OPM/qtcharts-summary-plots
Browse files Browse the repository at this point in the history
Closes #8228 

Major refactoring of summary plotting. Now possible to create plots both with Qwt and QtChart as plotting tool.
  • Loading branch information
kriben authored Jan 17, 2022
1 parent d9bb82d commit 258fbdd
Show file tree
Hide file tree
Showing 145 changed files with 7,234 additions and 2,921 deletions.
2 changes: 2 additions & 0 deletions ApplicationLibCode/Application/CMakeLists_files.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
33 changes: 0 additions & 33 deletions ApplicationLibCode/Application/RiaDefines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down Expand Up @@ -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;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down
12 changes: 0 additions & 12 deletions ApplicationLibCode/Application/RiaDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
75 changes: 75 additions & 0 deletions ApplicationLibCode/Application/RiaPlotDefines.cpp
Original file line number Diff line number Diff line change
@@ -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 );
}
39 changes: 39 additions & 0 deletions ApplicationLibCode/Application/RiaPlotDefines.h
Original file line number Diff line number Diff line change
@@ -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
10 changes: 5 additions & 5 deletions ApplicationLibCode/Application/RiaPlotWindowRedrawScheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#include "RiuMultiPlotBook.h"
#include "RiuMultiPlotPage.h"
#include "RiuQwtPlotWidget.h"
#include "RiuPlotWidget.h"

#include <QCoreApplication>
#include <QDebug>
Expand Down Expand Up @@ -61,7 +61,7 @@ void RiaPlotWindowRedrawScheduler::scheduleMultiPlotPageUpdate( RiuMultiPlotPage
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaPlotWindowRedrawScheduler::schedulePlotWidgetReplot( RiuQwtPlotWidget* plotWidget )
void RiaPlotWindowRedrawScheduler::schedulePlotWidgetReplot( RiuPlotWidget* plotWidget )
{
m_plotWidgetsToReplot.push_back( plotWidget );

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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 ) )
{
Expand Down
8 changes: 4 additions & 4 deletions ApplicationLibCode/Application/RiaPlotWindowRedrawScheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

class RiuMultiPlotPage;
class RiuMultiPlotBook;
class RiuQwtPlotWidget;
class RiuPlotWidget;

class RiaPlotWindowRedrawScheduler : public QObject
{
Expand All @@ -38,21 +38,21 @@ class RiaPlotWindowRedrawScheduler : public QObject
static RiaPlotWindowRedrawScheduler* instance();
void scheduleMultiPlotWindowUpdate( RiuMultiPlotBook* plotWindow );
void scheduleMultiPlotPageUpdate( RiuMultiPlotPage* plotWindow );
void schedulePlotWidgetReplot( RiuQwtPlotWidget* plotWidget );
void schedulePlotWidgetReplot( RiuPlotWidget* plotWidget );
void clearAllScheduledUpdates();
void performScheduledUpdatesAndReplots();

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;
Expand Down
2 changes: 1 addition & 1 deletion ApplicationLibCode/Commands/CMakeLists_files.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#include "cafCmdFeature.h"

#include "RiaDefines.h"
#include "RiaPlotDefines.h"
#include "RimFlowDiagSolution.h"

class RimGridSummaryCase;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class AsciiDataParseOptions
bool assumeNumericDataColumns;

RiuQwtPlotCurveDefines::LineStyleEnum curveLineStyle;
RiuQwtSymbol::PointSymbolEnum curveSymbol;
RiuPlotCurveSymbol::PointSymbolEnum curveSymbol;
float curveSymbolSkipDistance;
};

Expand Down Expand Up @@ -160,7 +160,7 @@ class RicPasteAsciiDataToSummaryPlotFeatureUi : public caf::PdmObject
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() );
Expand Down Expand Up @@ -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();
}

//--------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading

0 comments on commit 258fbdd

Please sign in to comment.