mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#6941 Add Grid Statistics plot using QtCharts.
The feature is only enabled if QtCharts is installed.
This commit is contained in:
@@ -42,18 +42,17 @@ find_package(
|
||||
if(Qt5Core_FOUND)
|
||||
find_package(
|
||||
Qt5
|
||||
CONFIG
|
||||
REQUIRED
|
||||
Core
|
||||
Gui
|
||||
OpenGL
|
||||
Network
|
||||
Script
|
||||
Widgets
|
||||
Xml
|
||||
Concurrent
|
||||
PrintSupport
|
||||
Svg)
|
||||
COMPONENTS Core
|
||||
Gui
|
||||
OpenGL
|
||||
Network
|
||||
Script
|
||||
Widgets
|
||||
Xml
|
||||
Concurrent
|
||||
PrintSupport
|
||||
Svg
|
||||
OPTIONAL_COMPONENTS Charts)
|
||||
set(QT_LIBRARIES
|
||||
Qt5::Core
|
||||
Qt5::Gui
|
||||
@@ -65,6 +64,9 @@ if(Qt5Core_FOUND)
|
||||
Qt5::Concurrent
|
||||
Qt5::PrintSupport
|
||||
Qt5::Svg)
|
||||
if(Qt5Charts_FOUND)
|
||||
list(APPEND QT_LIBRARIES Qt5::Charts)
|
||||
endif(Qt5Charts_FOUND)
|
||||
endif(Qt5Core_FOUND)
|
||||
|
||||
# NB: The generated file is written to Cmake binary folder to avoid source tree
|
||||
|
||||
@@ -192,6 +192,13 @@ ${CMAKE_CURRENT_LIST_DIR}/RicThemeColorEditorFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicNewVfpPlotFeature.cpp
|
||||
)
|
||||
|
||||
if(Qt5Charts_FOUND)
|
||||
list(APPEND SOURCE_GROUP_HEADER_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicCreateGridStatisticsPlotFeature.h)
|
||||
list(APPEND SOURCE_GROUP_SOURCE_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicCreateGridStatisticsPlotFeature.cpp)
|
||||
endif()
|
||||
|
||||
|
||||
list(APPEND COMMAND_CODE_HEADER_FILES
|
||||
${SOURCE_GROUP_HEADER_FILES}
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2020- 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 "RicCreateGridStatisticsPlotFeature.h"
|
||||
//#include "RicGridStatisticsUi.h"
|
||||
|
||||
#include "RiaGuiApplication.h"
|
||||
// #include "RiaLogging.h"
|
||||
// #include "RiaPorosityModel.h"
|
||||
|
||||
// #include "RigCaseCellResultsData.h"
|
||||
// #include "RigEclipseCaseData.h"
|
||||
// #include "RigEclipseResultAddress.h"
|
||||
// #include "RigEquil.h"
|
||||
|
||||
// #include "RimEclipseResultCase.h"
|
||||
#include "RimGridStatisticsPlot.h"
|
||||
#include "RimGridStatisticsPlotCollection.h"
|
||||
#include "RimMainPlotCollection.h"
|
||||
#include "RimProject.h"
|
||||
|
||||
#include "RiuPlotMainWindow.h"
|
||||
#include "RiuPlotMainWindowTools.h"
|
||||
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include <QAction>
|
||||
|
||||
CAF_CMD_SOURCE_INIT( RicCreateGridStatisticsPlotFeature, "RicCreateGridStatisticsPlotFeature" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicCreateGridStatisticsPlotFeature::isCommandEnabled()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicCreateGridStatisticsPlotFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
RimProject* project = RimProject::current();
|
||||
|
||||
RimGridStatisticsPlotCollection* collection = project->mainPlotCollection()->gridStatisticsPlotCollection();
|
||||
|
||||
RimGridStatisticsPlot* plot = new RimGridStatisticsPlot();
|
||||
plot->loadDataAndUpdate();
|
||||
plot->zoomAll();
|
||||
plot->updateConnectedEditors();
|
||||
plot->setAsPlotMdiWindow();
|
||||
|
||||
collection->addGridStatisticsPlot( plot );
|
||||
collection->updateAllRequiredEditors();
|
||||
RiaGuiApplication::instance()->getOrCreateAndShowMainPlotWindow();
|
||||
RiuPlotMainWindowTools::selectAsCurrentItem( plot );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicCreateGridStatisticsPlotFeature::setupActionLook( QAction* actionToSetup )
|
||||
{
|
||||
actionToSetup->setText( "Create Grid Statistics Plot" );
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2020- 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 "cafCmdFeature.h"
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicCreateGridStatisticsPlotFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
protected:
|
||||
bool isCommandEnabled() override;
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
};
|
||||
@@ -314,6 +314,18 @@ ${CMAKE_CURRENT_LIST_DIR}/RimVfpTableExtractor.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimCaseDisplayNameTools.cpp
|
||||
)
|
||||
|
||||
if(Qt5Charts_FOUND)
|
||||
list(APPEND SOURCE_GROUP_HEADER_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimGridStatisticsPlotCollection.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimGridStatisticsPlot.h)
|
||||
|
||||
|
||||
list(APPEND SOURCE_GROUP_SOURCE_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimGridStatisticsPlotCollection.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimGridStatisticsPlot.cpp)
|
||||
endif()
|
||||
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
${SOURCE_GROUP_HEADER_FILES}
|
||||
)
|
||||
|
||||
@@ -148,6 +148,10 @@
|
||||
#include "RimWellPltPlot.h"
|
||||
#include "RimWellRftPlot.h"
|
||||
|
||||
#ifdef USE_QTCHARTS
|
||||
#include "RimGridStatisticsPlotCollection.h"
|
||||
#endif
|
||||
|
||||
#include "RiuMainWindow.h"
|
||||
|
||||
#include "OctaveScriptCommands/RicExecuteScriptForCasesFeature.h"
|
||||
@@ -623,6 +627,12 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
|
||||
{
|
||||
menuBuilder << "RicCreateSaturationPressurePlotsFeature";
|
||||
}
|
||||
#ifdef USE_QTCHARTS
|
||||
else if ( dynamic_cast<RimGridStatisticsPlotCollection*>( firstUiItem ) )
|
||||
{
|
||||
menuBuilder << "RicCreateGridStatisticsPlotFeature";
|
||||
}
|
||||
#endif
|
||||
else if ( dynamic_cast<RimGridCrossPlot*>( firstUiItem ) )
|
||||
{
|
||||
menuBuilder << "RicPasteGridCrossPlotDataSetFeature";
|
||||
|
||||
374
ApplicationCode/ProjectDataModel/RimGridStatisticsPlot.cpp
Normal file
374
ApplicationCode/ProjectDataModel/RimGridStatisticsPlot.cpp
Normal file
@@ -0,0 +1,374 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2020- 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 "RimGridStatisticsPlot.h"
|
||||
|
||||
#include "RiaGuiApplication.h"
|
||||
#include "RiaPreferences.h"
|
||||
|
||||
#include "RimEclipseCase.h"
|
||||
#include "RimEclipseCaseCollection.h"
|
||||
#include "RimEclipseResultCase.h"
|
||||
#include "RimGeoMechCase.h"
|
||||
#include "RimOilField.h"
|
||||
#include "RimPlot.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimWellAllocationPlot.h"
|
||||
|
||||
// #include "RiuMultiPlotPage.h"
|
||||
#include "RiuPlotMainWindow.h"
|
||||
// #include "RiuPlotMainWindowTools.h"
|
||||
// //#include "RiuQwtPlotWidget.h"
|
||||
// #include "RiuWellLogPlot.h"
|
||||
|
||||
#include "cafPdmFieldReorderCapability.h"
|
||||
#include "cafPdmFieldScriptingCapability.h"
|
||||
#include "cafPdmObjectScriptingCapability.h"
|
||||
#include "cafPdmUiComboBoxEditor.h"
|
||||
#include "cafPdmUiDoubleValueEditor.h"
|
||||
#include "cvfAssert.h"
|
||||
|
||||
#include <QKeyEvent>
|
||||
|
||||
#include <QtCharts/QCategoryAxis>
|
||||
#include <QtCharts/QSplineSeries>
|
||||
#include <QtCharts/QValueAxis>
|
||||
|
||||
#include <cmath>
|
||||
|
||||
CAF_PDM_SOURCE_INIT( RimGridStatisticsPlot, "GridStatisticsPlot" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimGridStatisticsPlot::RimGridStatisticsPlot()
|
||||
{
|
||||
CAF_PDM_InitObject( "Grid Statistics Plot", "", "", "A Plot of Grid Statistics" );
|
||||
|
||||
CAF_PDM_InitField( &m_plotWindowTitle, "PlotDescription", QString( "" ), "Name", "", "", "" );
|
||||
m_plotWindowTitle.xmlCapability()->setIOWritable( false );
|
||||
|
||||
CAF_PDM_InitScriptableFieldNoDefault( &m_subTitleFontSize, "SubTitleFontSize", "Track Title Font Size", "", "", "" );
|
||||
CAF_PDM_InitScriptableFieldNoDefault( &m_axisTitleFontSize, "AxisTitleFontSize", "Axis Title Font Size", "", "", "" );
|
||||
CAF_PDM_InitScriptableFieldNoDefault( &m_axisValueFontSize, "AxisValueFontSize", "Axis Value Font Size", "", "", "" );
|
||||
|
||||
// m_plotLegendsHorizontal = false;
|
||||
// setPlotTitleVisible( false );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimGridStatisticsPlot::~RimGridStatisticsPlot()
|
||||
{
|
||||
removeMdiWindowFromMdiArea();
|
||||
cleanupBeforeClose();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QWidget* RimGridStatisticsPlot::viewWidget()
|
||||
{
|
||||
return m_viewer;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QWidget* RimGridStatisticsPlot::createPlotWidget( QWidget* mainWindowParent /*= nullptr */ )
|
||||
{
|
||||
return createViewWidget( mainWindowParent );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimGridStatisticsPlot::description() const
|
||||
{
|
||||
return m_plotWindowTitle;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridStatisticsPlot::zoomAll()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QImage RimGridStatisticsPlot::snapshotWindowContent()
|
||||
{
|
||||
QImage image;
|
||||
|
||||
// if ( m_viewer )
|
||||
// {
|
||||
// QPixmap pix( m_viewer->size() );
|
||||
// m_viewer->renderTo( &pix );
|
||||
// image = pix.toImage();
|
||||
// }
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QWidget* RimGridStatisticsPlot::createViewWidget( QWidget* mainWindowParent )
|
||||
{
|
||||
std::cout << "Creating view widget!!" << std::endl;
|
||||
|
||||
using namespace QtCharts;
|
||||
|
||||
//
|
||||
QChart* chart = new QChart();
|
||||
chart->setTitle( "Multiaxis chart example" );
|
||||
|
||||
QValueAxis* axisX = new QValueAxis;
|
||||
axisX->setTickCount( 10 );
|
||||
chart->addAxis( axisX, Qt::AlignBottom );
|
||||
|
||||
QSplineSeries* series = new QSplineSeries;
|
||||
*series << QPointF( 1, 5 ) << QPointF( 3.5, 18 ) << QPointF( 4.8, 7.5 ) << QPointF( 10, 2.5 );
|
||||
chart->addSeries( series );
|
||||
|
||||
QValueAxis* axisY = new QValueAxis;
|
||||
axisY->setLinePenColor( series->pen().color() );
|
||||
|
||||
chart->addAxis( axisY, Qt::AlignLeft );
|
||||
series->attachAxis( axisX );
|
||||
series->attachAxis( axisY );
|
||||
|
||||
series = new QSplineSeries;
|
||||
*series << QPointF( 1, 0.5 ) << QPointF( 1.5, 4.5 ) << QPointF( 2.4, 2.5 ) << QPointF( 4.3, 12.5 )
|
||||
<< QPointF( 5.2, 3.5 ) << QPointF( 7.4, 16.5 ) << QPointF( 8.3, 7.5 ) << QPointF( 10, 17 );
|
||||
chart->addSeries( series );
|
||||
|
||||
QCategoryAxis* axisY3 = new QCategoryAxis;
|
||||
axisY3->append( "Low", 5 );
|
||||
axisY3->append( "Medium", 12 );
|
||||
axisY3->append( "High", 17 );
|
||||
axisY3->setLinePenColor( series->pen().color() );
|
||||
axisY3->setGridLinePen( ( series->pen() ) );
|
||||
|
||||
chart->addAxis( axisY3, Qt::AlignRight );
|
||||
series->attachAxis( axisX );
|
||||
series->attachAxis( axisY3 );
|
||||
|
||||
m_viewer = new QChartView( chart );
|
||||
recreatePlotWidgets();
|
||||
return m_viewer;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridStatisticsPlot::deleteViewWidget()
|
||||
{
|
||||
cleanupBeforeClose();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridStatisticsPlot::recreatePlotWidgets()
|
||||
{
|
||||
// CVF_ASSERT( m_viewer );
|
||||
|
||||
// auto plotVector = plots();
|
||||
|
||||
// m_viewer->removeAllPlots();
|
||||
|
||||
// for ( size_t tIdx = 0; tIdx < plotVector.size(); ++tIdx )
|
||||
// {
|
||||
// plotVector[tIdx]->createPlotWidget();
|
||||
// m_viewer->addPlot( plotVector[tIdx]->viewer() );
|
||||
// }
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridStatisticsPlot::onPlotAdditionOrRemoval()
|
||||
{
|
||||
updateAllRequiredEditors();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridStatisticsPlot::doRenderWindowContent( QPaintDevice* paintDevice )
|
||||
{
|
||||
// if ( m_viewer )
|
||||
// {
|
||||
// m_viewer->renderTo( paintDevice );
|
||||
// }
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridStatisticsPlot::doUpdateLayout()
|
||||
{
|
||||
if ( m_viewer )
|
||||
{
|
||||
// m_viewer->setTitleFontSizes( titleFontSize(), subTitleFontSize() );
|
||||
// m_viewer->setLegendFontSize( legendFontSize() );
|
||||
// m_viewer->setAxisFontSizes( axisTitleFontSize(), axisValueFontSize() );
|
||||
// m_viewer->scheduleUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridStatisticsPlot::cleanupBeforeClose()
|
||||
{
|
||||
if ( m_viewer )
|
||||
{
|
||||
m_viewer->setParent( nullptr );
|
||||
delete m_viewer;
|
||||
m_viewer = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridStatisticsPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
|
||||
const QVariant& oldValue,
|
||||
const QVariant& newValue )
|
||||
{
|
||||
RimPlotWindow::fieldChangedByUi( changedField, oldValue, newValue );
|
||||
updateConnectedEditors();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridStatisticsPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
|
||||
{
|
||||
// caf::PdmUiGroup* titleGroup = uiOrdering.addNewGroup( "Plot Title" );
|
||||
// uiOrderingForAutoName( uiConfigName, *titleGroup );
|
||||
|
||||
caf::PdmUiGroup* plotLayoutGroup = uiOrdering.addNewGroup( "Plot Layout" );
|
||||
RimPlotWindow::uiOrderingForPlotLayout( uiConfigName, *plotLayoutGroup );
|
||||
plotLayoutGroup->add( &m_subTitleFontSize );
|
||||
plotLayoutGroup->add( &m_axisTitleFontSize );
|
||||
plotLayoutGroup->add( &m_axisValueFontSize );
|
||||
|
||||
uiOrdering.skipRemainingFields( true );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QList<caf::PdmOptionItemInfo>
|
||||
RimGridStatisticsPlot::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly )
|
||||
{
|
||||
QList<caf::PdmOptionItemInfo> options = RimPlotWindow::calculateValueOptions( fieldNeedingOptions, useOptionsOnly );
|
||||
|
||||
if ( fieldNeedingOptions == &m_subTitleFontSize || fieldNeedingOptions == &m_axisTitleFontSize ||
|
||||
fieldNeedingOptions == &m_axisValueFontSize )
|
||||
{
|
||||
options = caf::FontTools::relativeSizeValueOptions( RiaPreferences::current()->defaultPlotFontSize() );
|
||||
}
|
||||
|
||||
( *useOptionsOnly ) = true;
|
||||
return options;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridStatisticsPlot::initAfterRead()
|
||||
{
|
||||
RimPlotWindow::initAfterRead();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridStatisticsPlot::onLoadDataAndUpdate()
|
||||
{
|
||||
updateMdiWindowVisibility();
|
||||
// performAutoNameUpdate();
|
||||
updatePlots();
|
||||
updateLayout();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridStatisticsPlot::updatePlots()
|
||||
{
|
||||
// if ( m_showWindow )
|
||||
// {
|
||||
// for ( RimPlot* plot : plots() )
|
||||
// {
|
||||
// plot->loadDataAndUpdate();
|
||||
// }
|
||||
// this->updateZoom();
|
||||
// }
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::PdmFieldHandle* RimGridStatisticsPlot::userDescriptionField()
|
||||
{
|
||||
return &m_plotWindowTitle;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridStatisticsPlot::onChildDeleted( caf::PdmChildArrayFieldHandle* childArray,
|
||||
std::vector<caf::PdmObjectHandle*>& referringObjects )
|
||||
{
|
||||
// calculateAvailableDepthRange();
|
||||
// updateZoom();
|
||||
// RiuPlotMainWindow* mainPlotWindow = RiaGuiApplication::instance()->mainPlotWindow();
|
||||
// mainPlotWindow->updateWellLogPlotToolBar();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int RimGridStatisticsPlot::subTitleFontSize() const
|
||||
{
|
||||
return caf::FontTools::absolutePointSize( RiaPreferences::current()->defaultPlotFontSize(), m_subTitleFontSize() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int RimGridStatisticsPlot::axisTitleFontSize() const
|
||||
{
|
||||
return caf::FontTools::absolutePointSize( RiaPreferences::current()->defaultPlotFontSize(), m_axisTitleFontSize() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int RimGridStatisticsPlot::axisValueFontSize() const
|
||||
{
|
||||
return caf::FontTools::absolutePointSize( RiaPreferences::current()->defaultPlotFontSize(), m_axisValueFontSize() );
|
||||
}
|
||||
92
ApplicationCode/ProjectDataModel/RimGridStatisticsPlot.h
Normal file
92
ApplicationCode/ProjectDataModel/RimGridStatisticsPlot.h
Normal file
@@ -0,0 +1,92 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2020- 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 "RiaDefines.h"
|
||||
#include "RimPlotWindow.h"
|
||||
|
||||
#include "cafPdmChildArrayField.h"
|
||||
#include "cafPdmChildField.h"
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmFieldHandle.h"
|
||||
#include "cafPdmObject.h"
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
#include <QtCharts/QChartView>
|
||||
|
||||
class RimPlot;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
class RimGridStatisticsPlot : public RimPlotWindow
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RimGridStatisticsPlot();
|
||||
~RimGridStatisticsPlot() override;
|
||||
|
||||
QWidget* viewWidget() override;
|
||||
QWidget* createPlotWidget( QWidget* mainWindowParent = nullptr );
|
||||
QString description() const override;
|
||||
|
||||
void zoomAll() override;
|
||||
|
||||
void onChildDeleted( caf::PdmChildArrayFieldHandle* childArray,
|
||||
std::vector<caf::PdmObjectHandle*>& referringObjects ) override;
|
||||
|
||||
int subTitleFontSize() const;
|
||||
int axisTitleFontSize() const;
|
||||
int axisValueFontSize() const;
|
||||
|
||||
protected:
|
||||
QImage snapshotWindowContent() override;
|
||||
|
||||
QWidget* createViewWidget( QWidget* mainWindowParent ) override;
|
||||
void deleteViewWidget() override;
|
||||
void recreatePlotWidgets();
|
||||
|
||||
// Overridden PDM methods
|
||||
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
|
||||
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
|
||||
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
|
||||
bool* useOptionsOnly ) override;
|
||||
|
||||
void initAfterRead() override;
|
||||
void onLoadDataAndUpdate() override;
|
||||
void updatePlots();
|
||||
caf::PdmFieldHandle* userDescriptionField() override;
|
||||
|
||||
private:
|
||||
void cleanupBeforeClose();
|
||||
void onPlotAdditionOrRemoval();
|
||||
void doRenderWindowContent( QPaintDevice* paintDevice ) override;
|
||||
void doUpdateLayout() override;
|
||||
|
||||
protected:
|
||||
QPointer<QtCharts::QChartView> m_viewer;
|
||||
|
||||
caf::PdmField<QString> m_plotWindowTitle;
|
||||
caf::PdmField<caf::FontTools::RelativeSizeEnum> m_subTitleFontSize;
|
||||
caf::PdmField<caf::FontTools::RelativeSizeEnum> m_axisTitleFontSize;
|
||||
caf::PdmField<caf::FontTools::RelativeSizeEnum> m_axisValueFontSize;
|
||||
};
|
||||
@@ -0,0 +1,80 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2020- 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 "RimGridStatisticsPlotCollection.h"
|
||||
|
||||
#include "RimGridStatisticsPlot.h"
|
||||
|
||||
#include "cafPdmFieldScriptingCapability.h"
|
||||
#include "cafPdmObjectScriptingCapability.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT( RimGridStatisticsPlotCollection, "GridStatisticsPlotCollection" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimGridStatisticsPlotCollection::RimGridStatisticsPlotCollection()
|
||||
{
|
||||
CAF_PDM_InitScriptableObject( "Grid Statistics Plots", ":/WellLogPlots16x16.png", "", "" );
|
||||
|
||||
CAF_PDM_InitScriptableFieldNoDefault( &m_gridStatisticsPlots, "GridStatisticsPlots", "", "", "", "" );
|
||||
m_gridStatisticsPlots.uiCapability()->setUiHidden( true );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimGridStatisticsPlotCollection::~RimGridStatisticsPlotCollection()
|
||||
{
|
||||
m_gridStatisticsPlots.deleteAllChildObjects();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridStatisticsPlotCollection::reloadAllPlots()
|
||||
{
|
||||
for ( const auto& w : m_gridStatisticsPlots() )
|
||||
{
|
||||
w->loadDataAndUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridStatisticsPlotCollection::addGridStatisticsPlot( RimGridStatisticsPlot* newPlot )
|
||||
{
|
||||
m_gridStatisticsPlots.push_back( newPlot );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimGridStatisticsPlot*> RimGridStatisticsPlotCollection::gridStatisticsPlots() const
|
||||
{
|
||||
return m_gridStatisticsPlots.childObjects();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridStatisticsPlotCollection::deleteAllPlots()
|
||||
{
|
||||
m_gridStatisticsPlots.deleteAllChildObjects();
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2020- 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 "cafPdmChildArrayField.h"
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
|
||||
class RimGridStatisticsPlot;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
class RimGridStatisticsPlotCollection : public caf::PdmObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RimGridStatisticsPlotCollection();
|
||||
~RimGridStatisticsPlotCollection() override;
|
||||
|
||||
void addGridStatisticsPlot( RimGridStatisticsPlot* newPlot );
|
||||
|
||||
std::vector<RimGridStatisticsPlot*> gridStatisticsPlots() const;
|
||||
|
||||
void reloadAllPlots();
|
||||
|
||||
void deleteAllPlots();
|
||||
|
||||
private:
|
||||
caf::PdmChildArrayField<RimGridStatisticsPlot*> m_gridStatisticsPlots;
|
||||
};
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#include "RimMainPlotCollection.h"
|
||||
|
||||
#include "RimAnalysisPlotCollection.h"
|
||||
#include "RimCorrelationPlotCollection.h"
|
||||
#include "RimFlowCharacteristicsPlot.h"
|
||||
#include "RimFlowPlotCollection.h"
|
||||
@@ -42,7 +43,11 @@
|
||||
#include "RimWellPltPlot.h"
|
||||
#include "RimWellRftPlot.h"
|
||||
|
||||
#include "RimAnalysisPlotCollection.h"
|
||||
#ifdef USE_QTCHARTS
|
||||
#include "RimGridStatisticsPlot.h"
|
||||
#include "RimGridStatisticsPlotCollection.h"
|
||||
#endif
|
||||
|
||||
#include "RiuMainWindow.h"
|
||||
#include "RiuProjectPropertyView.h"
|
||||
|
||||
@@ -101,6 +106,10 @@ RimMainPlotCollection::RimMainPlotCollection()
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_vfpPlotCollection, "VfpPlotCollection", "", "", "", "" );
|
||||
m_vfpPlotCollection.uiCapability()->setUiHidden( true );
|
||||
#ifdef USE_QTCHARTS
|
||||
CAF_PDM_InitFieldNoDefault( &m_gridStatisticsPlotCollection, "GridStatisticsPlotCollection", "", "", "", "" );
|
||||
m_gridStatisticsPlotCollection.uiCapability()->setUiHidden( true );
|
||||
#endif
|
||||
|
||||
m_wellLogPlotCollection = new RimWellLogPlotCollection();
|
||||
m_rftPlotCollection = new RimRftPlotCollection();
|
||||
@@ -115,6 +124,9 @@ RimMainPlotCollection::RimMainPlotCollection()
|
||||
m_correlationPlotCollection = new RimCorrelationPlotCollection;
|
||||
m_stimPlanModelPlotCollection = new RimStimPlanModelPlotCollection;
|
||||
m_vfpPlotCollection = new RimVfpPlotCollection();
|
||||
#ifdef USE_QTCHARTS
|
||||
m_gridStatisticsPlotCollection = new RimGridStatisticsPlotCollection;
|
||||
#endif
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -245,6 +257,16 @@ RimStimPlanModelPlotCollection* RimMainPlotCollection::stimPlanModelPlotCollecti
|
||||
return m_stimPlanModelPlotCollection();
|
||||
}
|
||||
|
||||
#ifdef USE_QTCHARTS
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimGridStatisticsPlotCollection* RimMainPlotCollection::gridStatisticsPlotCollection()
|
||||
{
|
||||
return m_gridStatisticsPlotCollection();
|
||||
}
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -263,6 +285,9 @@ void RimMainPlotCollection::deleteAllContainedObjects()
|
||||
m_analysisPlotCollection()->deleteAllPlots();
|
||||
m_correlationPlotCollection()->deleteAllPlots();
|
||||
m_stimPlanModelPlotCollection()->deleteAllPlots();
|
||||
#ifdef USE_QTCHARTS
|
||||
m_gridStatisticsPlotCollection()->deleteAllPlots();
|
||||
#endif
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -330,6 +355,16 @@ void RimMainPlotCollection::updatePlotsWithFormations()
|
||||
stimPlanModelPlot->loadDataAndUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef USE_QTCHARTS
|
||||
if ( m_gridStatisticsPlotCollection )
|
||||
{
|
||||
for ( RimGridStatisticsPlot* gridStatisticsPlot : m_gridStatisticsPlotCollection->gridStatisticsPlots() )
|
||||
{
|
||||
gridStatisticsPlot->loadDataAndUpdate();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -43,6 +43,10 @@ class RimSaturationPressurePlotCollection;
|
||||
class RimStimPlanModelPlotCollection;
|
||||
class RimVfpPlotCollection;
|
||||
|
||||
#ifdef USE_QTCHARTS
|
||||
class RimGridStatisticsPlotCollection;
|
||||
#endif
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
@@ -69,6 +73,10 @@ public:
|
||||
RimStimPlanModelPlotCollection* stimPlanModelPlotCollection();
|
||||
RimVfpPlotCollection* vfpPlotCollection();
|
||||
|
||||
#ifdef USE_QTCHARTS
|
||||
RimGridStatisticsPlotCollection* gridStatisticsPlotCollection();
|
||||
#endif
|
||||
|
||||
void deleteAllContainedObjects();
|
||||
void updateCurrentTimeStepInPlots();
|
||||
void updatePlotsWithFormations();
|
||||
@@ -96,6 +104,9 @@ private:
|
||||
caf::PdmChildField<RimMultiPlotCollection*> m_multiPlotCollection;
|
||||
caf::PdmChildField<RimStimPlanModelPlotCollection*> m_stimPlanModelPlotCollection;
|
||||
caf::PdmChildField<RimVfpPlotCollection*> m_vfpPlotCollection;
|
||||
#ifdef USE_QTCHARTS
|
||||
caf::PdmChildField<RimGridStatisticsPlotCollection*> m_gridStatisticsPlotCollection;
|
||||
#endif
|
||||
|
||||
caf::PdmField<bool> m_show;
|
||||
};
|
||||
|
||||
@@ -90,6 +90,11 @@
|
||||
#include "RimWellPath.h"
|
||||
#include "RimWellPathCollection.h"
|
||||
|
||||
#ifdef USE_QTCHARTS
|
||||
#include "RimGridStatisticsPlot.h"
|
||||
#include "RimGridStatisticsPlotCollection.h"
|
||||
#endif
|
||||
|
||||
#include "SsiHubImportCommands/RimWellPathImport.h"
|
||||
|
||||
#include "RiuMainWindow.h"
|
||||
@@ -1459,6 +1464,12 @@ void RimProject::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, Q
|
||||
{
|
||||
itemCollection->add( mainPlotCollection->vfpPlotCollection() );
|
||||
}
|
||||
#ifdef USE_QTCHARTS
|
||||
if ( mainPlotCollection->gridStatisticsPlotCollection() )
|
||||
{
|
||||
itemCollection->add( mainPlotCollection->gridStatisticsPlotCollection() );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
uiTreeOrdering.add( scriptCollection() );
|
||||
|
||||
@@ -310,7 +310,13 @@ list(APPEND THIRD_PARTY_LIBRARIES
|
||||
################################################################################
|
||||
# Qt
|
||||
################################################################################
|
||||
find_package(Qt5 COMPONENTS REQUIRED Core Gui OpenGL Network Script ScriptTools Widgets)
|
||||
find_package(Qt5 COMPONENTS Core Gui OpenGL Network Script ScriptTools Widgets OPTIONAL_COMPONENTS Charts)
|
||||
if (Qt5Charts_FOUND)
|
||||
message(STATUS "QtCharts found: ${Qt5Charts_LIBRARIES}")
|
||||
add_definitions(-DUSE_QTCHARTS)
|
||||
else()
|
||||
message(STATUS "QtCharts missing.")
|
||||
endif()
|
||||
|
||||
# Open GL
|
||||
find_package( OpenGL )
|
||||
|
||||
Reference in New Issue
Block a user