mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#6941 Improve font handling in in GridStatisticsPlot.
This commit is contained in:
parent
a707ff213e
commit
e02fb1135e
@ -65,10 +65,6 @@ RimGridStatisticsPlot::RimGridStatisticsPlot()
|
||||
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", "", "", "" );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_case, "Case", "Case", "", "", "" );
|
||||
m_case.uiCapability()->setUiTreeChildrenHidden( true );
|
||||
CAF_PDM_InitField( &m_timeStep, "TimeStep", -1, "Time Step", "", "", "" );
|
||||
@ -84,8 +80,9 @@ RimGridStatisticsPlot::RimGridStatisticsPlot()
|
||||
m_property.uiCapability()->setUiTreeChildrenHidden( true );
|
||||
m_property->setTernaryEnabled( false );
|
||||
|
||||
// m_plotLegendsHorizontal = false;
|
||||
// setPlotTitleVisible( false );
|
||||
m_plotLegendsHorizontal.uiCapability()->setUiHidden( true );
|
||||
|
||||
setDeletable( true );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -177,7 +174,7 @@ QImage RimGridStatisticsPlot::snapshotWindowContent()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QWidget* RimGridStatisticsPlot::createViewWidget( QWidget* mainWindowParent )
|
||||
{
|
||||
m_viewer = new QChartView();
|
||||
m_viewer = new RiuQtChartView( this, mainWindowParent );
|
||||
recreatePlotWidgets();
|
||||
return m_viewer;
|
||||
}
|
||||
@ -221,10 +218,11 @@ void RimGridStatisticsPlot::onPlotAdditionOrRemoval()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridStatisticsPlot::doRenderWindowContent( QPaintDevice* paintDevice )
|
||||
{
|
||||
// if ( m_viewer )
|
||||
// {
|
||||
// m_viewer->renderTo( paintDevice );
|
||||
// }
|
||||
if ( m_viewer )
|
||||
{
|
||||
QPainter painter( paintDevice );
|
||||
m_viewer->render( &painter );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -291,9 +289,11 @@ void RimGridStatisticsPlot::fieldChangedByUi( const caf::PdmFieldHandle* changed
|
||||
// }
|
||||
|
||||
// destroyCurves();
|
||||
}
|
||||
else
|
||||
{
|
||||
loadDataAndUpdate();
|
||||
}
|
||||
|
||||
updateConnectedEditors();
|
||||
}
|
||||
|
||||
@ -314,9 +314,6 @@ void RimGridStatisticsPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOr
|
||||
|
||||
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 );
|
||||
}
|
||||
@ -329,12 +326,7 @@ QList<caf::PdmOptionItemInfo>
|
||||
{
|
||||
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() );
|
||||
}
|
||||
else if ( fieldNeedingOptions == &m_case )
|
||||
if ( fieldNeedingOptions == &m_case )
|
||||
{
|
||||
RimTools::eclipseCaseOptionItems( &options );
|
||||
if ( options.empty() )
|
||||
@ -387,7 +379,7 @@ void RimGridStatisticsPlot::initAfterRead()
|
||||
void RimGridStatisticsPlot::onLoadDataAndUpdate()
|
||||
{
|
||||
updateMdiWindowVisibility();
|
||||
// performAutoNameUpdate();
|
||||
performAutoNameUpdate();
|
||||
updatePlots();
|
||||
updateLayout();
|
||||
}
|
||||
@ -397,8 +389,6 @@ void RimGridStatisticsPlot::onLoadDataAndUpdate()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridStatisticsPlot::updatePlots()
|
||||
{
|
||||
std::cout << "Update plots!" << std::endl;
|
||||
|
||||
if ( m_viewer )
|
||||
{
|
||||
if ( m_cellFilterView.value() )
|
||||
@ -430,8 +420,7 @@ void RimGridStatisticsPlot::updatePlots()
|
||||
|
||||
QChart* chart = new QChart();
|
||||
chart->addSeries( series );
|
||||
chart->setTitle( "Simple barchart example" );
|
||||
chart->setAnimationOptions( QChart::SeriesAnimations );
|
||||
chart->setTitle( uiName() );
|
||||
|
||||
// Axis
|
||||
double xAxisSize = histogramData.max - histogramData.min;
|
||||
@ -469,6 +458,20 @@ void RimGridStatisticsPlot::updatePlots()
|
||||
meanSeries->attachAxis( axisX );
|
||||
meanSeries->attachAxis( axisY );
|
||||
|
||||
// Set font sizes
|
||||
QFont titleFont = chart->titleFont();
|
||||
titleFont.setPixelSize( titleFontSize() );
|
||||
chart->setTitleFont( titleFont );
|
||||
|
||||
QLegend* legend = chart->legend();
|
||||
if ( legend )
|
||||
{
|
||||
QFont legendFont = legend->font();
|
||||
legendFont.setPixelSize( legendFontSize() );
|
||||
legend->setFont( legendFont );
|
||||
legend->setVisible( legendsVisible() );
|
||||
}
|
||||
|
||||
m_viewer->setChart( chart );
|
||||
}
|
||||
}
|
||||
@ -486,35 +489,48 @@ caf::PdmFieldHandle* RimGridStatisticsPlot::userDescriptionField()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridStatisticsPlot::onChildDeleted( caf::PdmChildArrayFieldHandle* childArray,
|
||||
std::vector<caf::PdmObjectHandle*>& referringObjects )
|
||||
QString RimGridStatisticsPlot::createAutoName() const
|
||||
{
|
||||
// calculateAvailableDepthRange();
|
||||
// updateZoom();
|
||||
// RiuPlotMainWindow* mainPlotWindow = RiaGuiApplication::instance()->mainPlotWindow();
|
||||
// mainPlotWindow->updateWellLogPlotToolBar();
|
||||
if ( m_case() == nullptr )
|
||||
{
|
||||
return "Undefined";
|
||||
}
|
||||
|
||||
QStringList nameTags;
|
||||
nameTags += m_case()->caseUserDescription();
|
||||
|
||||
QString timeStepStr = timeStepString();
|
||||
if ( !timeStepStr.isEmpty() )
|
||||
{
|
||||
nameTags += timeStepStr;
|
||||
}
|
||||
|
||||
return nameTags.join( "," );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int RimGridStatisticsPlot::subTitleFontSize() const
|
||||
void RimGridStatisticsPlot::performAutoNameUpdate()
|
||||
{
|
||||
return caf::FontTools::absolutePointSize( RiaPreferences::current()->defaultPlotFontSize(), m_subTitleFontSize() );
|
||||
QString name = createAutoName();
|
||||
m_plotWindowTitle = name;
|
||||
setUiName( name );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int RimGridStatisticsPlot::axisTitleFontSize() const
|
||||
QString RimGridStatisticsPlot::timeStepString() const
|
||||
{
|
||||
return caf::FontTools::absolutePointSize( RiaPreferences::current()->defaultPlotFontSize(), m_axisTitleFontSize() );
|
||||
}
|
||||
if ( m_case() && m_property->hasDynamicResult() )
|
||||
{
|
||||
if ( m_timeStep == -1 )
|
||||
{
|
||||
return "All Time Steps";
|
||||
}
|
||||
return m_case->timeStepStrings()[m_timeStep];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int RimGridStatisticsPlot::axisValueFontSize() const
|
||||
{
|
||||
return caf::FontTools::absolutePointSize( RiaPreferences::current()->defaultPlotFontSize(), m_axisValueFontSize() );
|
||||
return "";
|
||||
}
|
||||
|
@ -21,12 +21,14 @@
|
||||
#include "RiaDefines.h"
|
||||
#include "RimPlotWindow.h"
|
||||
|
||||
#include "RiuQtChartView.h"
|
||||
|
||||
#include "cafPdmChildArrayField.h"
|
||||
#include "cafPdmChildField.h"
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmPtrField.h"
|
||||
#include "cafPdmFieldHandle.h"
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafPdmPtrField.h"
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
@ -55,13 +57,6 @@ public:
|
||||
|
||||
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;
|
||||
|
||||
@ -80,6 +75,10 @@ protected:
|
||||
void updatePlots();
|
||||
caf::PdmFieldHandle* userDescriptionField() override;
|
||||
|
||||
void performAutoNameUpdate();
|
||||
QString createAutoName() const;
|
||||
QString timeStepString() const;
|
||||
|
||||
void setDefaults();
|
||||
|
||||
private:
|
||||
@ -89,12 +88,9 @@ private:
|
||||
void doUpdateLayout() override;
|
||||
|
||||
protected:
|
||||
QPointer<QtCharts::QChartView> m_viewer;
|
||||
QPointer<RiuQtChartView> 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;
|
||||
caf::PdmField<QString> m_plotWindowTitle;
|
||||
|
||||
caf::PdmPtrField<RimCase*> m_case;
|
||||
caf::PdmField<int> m_timeStep;
|
||||
|
@ -192,6 +192,20 @@ ${CMAKE_CURRENT_LIST_DIR}/RiuQssSyntaxHighlighter.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuTextEditWithCompletion.cpp
|
||||
)
|
||||
|
||||
|
||||
if(Qt5Charts_FOUND)
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuQtChartView.h)
|
||||
|
||||
list(APPEND CODE_SOURCE_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuQtChartView.cpp)
|
||||
|
||||
# list(APPEND QT_MOC_HEADERS
|
||||
# ${CMAKE_CURRENT_LIST_DIR}/RiuQtChartView.h)
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
${SOURCE_GROUP_HEADER_FILES}
|
||||
)
|
||||
@ -200,6 +214,7 @@ list(APPEND CODE_SOURCE_FILES
|
||||
${SOURCE_GROUP_SOURCE_FILES}
|
||||
)
|
||||
|
||||
|
||||
list(APPEND QT_MOC_HEADERS
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuMainWindowBase.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuMainWindow.h
|
||||
@ -252,4 +267,8 @@ list(APPEND QT_UI_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuMultiCaseImportDialog.ui
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
source_group( "UserInterface" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake )
|
||||
|
46
ApplicationCode/UserInterface/RiuQtChartView.cpp
Normal file
46
ApplicationCode/UserInterface/RiuQtChartView.cpp
Normal file
@ -0,0 +1,46 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "RiuQtChartView.h"
|
||||
|
||||
#include "RimPlotWindow.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuQtChartView::RiuQtChartView( RimPlotWindow* plotWindow, QWidget* parent )
|
||||
: QtCharts::QChartView( parent )
|
||||
, m_plotWindow( plotWindow )
|
||||
{
|
||||
CAF_ASSERT( m_plotWindow );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuQtChartView::~RiuQtChartView()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimViewWindow* RiuQtChartView::ownerViewWindow() const
|
||||
{
|
||||
return m_plotWindow;
|
||||
}
|
42
ApplicationCode/UserInterface/RiuQtChartView.h
Normal file
42
ApplicationCode/UserInterface/RiuQtChartView.h
Normal file
@ -0,0 +1,42 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "RiuInterfaceToViewWindow.h"
|
||||
|
||||
#include "cafPdmPointer.h"
|
||||
|
||||
#include <QtCharts/QChartView>
|
||||
|
||||
class RimPlotWindow;
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
//==================================================================================================
|
||||
class RiuQtChartView : public QtCharts::QChartView, public RiuInterfaceToViewWindow
|
||||
{
|
||||
public:
|
||||
RiuQtChartView( RimPlotWindow* plotWindow, QWidget* parent = nullptr );
|
||||
virtual ~RiuQtChartView();
|
||||
|
||||
RimViewWindow* ownerViewWindow() const override;
|
||||
|
||||
private:
|
||||
caf::PdmPointer<RimPlotWindow> m_plotWindow;
|
||||
};
|
Loading…
Reference in New Issue
Block a user