mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-23 23:13:39 -06:00
#8822 Summary Axis: Add tick mark count to y-axis
This commit is contained in:
parent
b6f7dd931e
commit
853b4a26d5
@ -18,6 +18,9 @@
|
||||
|
||||
#include "RiaPlotDefines.h"
|
||||
|
||||
#include "RiaGuiApplication.h"
|
||||
#include "RiaPreferencesSystem.h"
|
||||
|
||||
#include "cafAppEnum.h"
|
||||
|
||||
namespace caf
|
||||
@ -73,3 +76,20 @@ bool RiaDefines::isVertical( RiaDefines::PlotAxis axis )
|
||||
{
|
||||
return ( axis == RiaDefines::PlotAxis::PLOT_AXIS_LEFT || axis == RiaDefines::PlotAxis::PLOT_AXIS_RIGHT );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
double RiaDefines::scalingFactor( QPaintDevice* paintDevice )
|
||||
{
|
||||
auto scalingFactor = RiaPreferencesSystem::current()->exportPdfScalingFactor();
|
||||
|
||||
if ( scalingFactor > 0.0 ) return scalingFactor;
|
||||
|
||||
if ( !paintDevice ) return 1.0;
|
||||
|
||||
int resolution = paintDevice->logicalDpiX();
|
||||
double scaling = resolution / static_cast<double>( RiaGuiApplication::applicationResolution() );
|
||||
|
||||
return scaling;
|
||||
}
|
||||
|
@ -18,6 +18,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
class QPaintDevice;
|
||||
|
||||
// Defines relate to plotting
|
||||
namespace RiaDefines
|
||||
{
|
||||
@ -36,4 +38,6 @@ double maximumDefaultValuePlot();
|
||||
bool isHorizontal( PlotAxis axis );
|
||||
bool isVertical( PlotAxis axis );
|
||||
|
||||
double scalingFactor( QPaintDevice* paintDevice );
|
||||
|
||||
}; // namespace RiaDefines
|
||||
|
@ -85,6 +85,7 @@ RiaPreferencesSystem::RiaPreferencesSystem()
|
||||
caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_showPdfExportDialog );
|
||||
|
||||
CAF_PDM_InitField( &m_gtestFilter, "gtestFilter", QString(), "Unit Test Filter (gtest)" );
|
||||
CAF_PDM_InitField( &m_exportScalingFactor, "exportScalingFactor", -1.0, "Export Scaling Factor (<0 disable)" );
|
||||
|
||||
CAF_PDM_InitField( &m_eclipseReaderMode,
|
||||
"eclipseReaderMode",
|
||||
@ -206,6 +207,14 @@ bool RiaPreferencesSystem::showPdfExportDialog() const
|
||||
return m_showPdfExportDialog();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
double RiaPreferencesSystem::exportPdfScalingFactor() const
|
||||
{
|
||||
return m_exportScalingFactor();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -238,7 +247,9 @@ void RiaPreferencesSystem::defineUiOrdering( QString uiConfigName, caf::PdmUiOrd
|
||||
uiOrdering.add( &m_includeFractureDebugInfoFile );
|
||||
uiOrdering.add( &m_holoLensExportFolder );
|
||||
uiOrdering.add( &m_showProgressBar );
|
||||
|
||||
uiOrdering.add( &m_showPdfExportDialog );
|
||||
uiOrdering.add( &m_exportScalingFactor );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -54,6 +54,7 @@ public:
|
||||
QString gtestFilter() const;
|
||||
bool showProgressBar() const;
|
||||
bool showPdfExportDialog() const;
|
||||
double exportPdfScalingFactor() const;
|
||||
|
||||
EclipseTextFileReaderMode eclipseTextFileReaderMode() const;
|
||||
|
||||
@ -78,7 +79,9 @@ private:
|
||||
caf::PdmField<bool> m_includeFractureDebugInfoFile;
|
||||
caf::PdmField<QString> m_holoLensExportFolder;
|
||||
|
||||
caf::PdmField<bool> m_showPdfExportDialog;
|
||||
caf::PdmField<bool> m_showPdfExportDialog;
|
||||
caf::PdmField<double> m_exportScalingFactor;
|
||||
|
||||
caf::PdmField<bool> m_showProgressBar;
|
||||
caf::PdmField<QString> m_gtestFilter;
|
||||
|
||||
|
@ -72,12 +72,12 @@ void RicSnapshotViewToPdfFeature::onActionTriggered( bool isChecked )
|
||||
}
|
||||
else
|
||||
{
|
||||
fileName = defaultFileName + ".pdf";
|
||||
fileName = defaultFileName + "." + fileExtension;
|
||||
}
|
||||
|
||||
if ( !fileName.isEmpty() )
|
||||
{
|
||||
if ( plotWindow && fileName.endsWith( "PDF", Qt::CaseInsensitive ) )
|
||||
if ( plotWindow && fileName.endsWith( fileExtension, Qt::CaseInsensitive ) )
|
||||
{
|
||||
RicSnapshotViewToFileFeature::savePlotPdfReportAs( fileName, plotWindow );
|
||||
|
||||
|
@ -34,7 +34,7 @@ CAF_PDM_SOURCE_INIT( RicLinkVisibleViewsFeatureUi, "RicLinkVisibleViewsFeatureUi
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicLinkVisibleViewsFeatureUi::RicLinkVisibleViewsFeatureUi( void )
|
||||
{
|
||||
CAF_PDM_InitObject( "Link Visible Views Feature UI", ":/LinkView16x16.png" );
|
||||
CAF_PDM_InitObject( "Link Visible Views Feature UI", ":/LinkView.svg" );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_masterView, "MasterView", "Primary View" );
|
||||
}
|
||||
|
@ -96,6 +96,8 @@ RimPlotAxisProperties::RimPlotAxisProperties()
|
||||
CAF_PDM_InitFieldNoDefault( &m_annotations, "Annotations", "" );
|
||||
m_annotations.uiCapability()->setUiTreeHidden( true );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_majorTickmarkCount, "MajorTickmarkCount", "Major Tickmark Count" );
|
||||
|
||||
updateOptionSensitivity();
|
||||
}
|
||||
|
||||
@ -231,6 +233,7 @@ void RimPlotAxisProperties::defineUiOrdering( QString uiConfigName, caf::PdmUiOr
|
||||
scaleGroup.add( &m_visibleRangeMax );
|
||||
}
|
||||
scaleGroup.add( &m_valuesFontSize );
|
||||
scaleGroup.add( &m_majorTickmarkCount );
|
||||
|
||||
scaleGroup.add( &m_plotAxis );
|
||||
m_plotAxis.uiCapability()->setUiReadOnly( m_isAlwaysRequired );
|
||||
@ -437,6 +440,22 @@ void RimPlotAxisProperties::setVisibleRangeMax( double value )
|
||||
m_visibleRangeMax = value;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimPlotAxisPropertiesInterface::LegendTickmarkCount RimPlotAxisProperties::majorTickmarkCount() const
|
||||
{
|
||||
return m_majorTickmarkCount();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimPlotAxisProperties::setMajorTickmarkCount( LegendTickmarkCount count )
|
||||
{
|
||||
m_majorTickmarkCount = count;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -103,6 +103,9 @@ public:
|
||||
void setVisibleRangeMin( double value ) override;
|
||||
void setVisibleRangeMax( double value ) override;
|
||||
|
||||
LegendTickmarkCount majorTickmarkCount() const override;
|
||||
void setMajorTickmarkCount( LegendTickmarkCount count ) override;
|
||||
|
||||
protected:
|
||||
void initAfterRead() override;
|
||||
caf::PdmFieldHandle* userDescriptionField() override;
|
||||
@ -134,6 +137,7 @@ private:
|
||||
caf::PdmField<QString> m_name;
|
||||
caf::PdmField<caf::AppEnum<RiaDefines::PlotAxis>> m_plotAxis;
|
||||
caf::PdmField<int> m_plotAxisIndex;
|
||||
caf::PdmField<LegendTickmarkCountEnum> m_majorTickmarkCount;
|
||||
|
||||
caf::PdmField<bool> m_isLogarithmicScaleEnabled;
|
||||
|
||||
|
@ -15,9 +15,13 @@
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RimPlotAxisPropertiesInterface.h"
|
||||
|
||||
#include "RimSummaryMultiPlot.h"
|
||||
|
||||
#include "cafAppEnum.h"
|
||||
#include "cafPdmUiTreeAttributes.h"
|
||||
|
||||
CAF_PDM_XML_ABSTRACT_SOURCE_INIT( RimPlotAxisPropertiesInterface,
|
||||
"PlotAxisPropertiesInterface",
|
||||
@ -68,3 +72,53 @@ bool RimPlotAxisPropertiesInterface::isLogarithmicScaleEnabled() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int RimPlotAxisPropertiesInterface::tickmarkCountFromEnum( LegendTickmarkCount count )
|
||||
{
|
||||
int maxTickmarkCount = 8;
|
||||
|
||||
switch ( count )
|
||||
{
|
||||
case LegendTickmarkCount::TICKMARK_VERY_FEW:
|
||||
maxTickmarkCount = 2;
|
||||
break;
|
||||
case LegendTickmarkCount::TICKMARK_FEW:
|
||||
maxTickmarkCount = 4;
|
||||
break;
|
||||
case LegendTickmarkCount::TICKMARK_DEFAULT:
|
||||
maxTickmarkCount = 8; // Taken from QwtPlot::initAxesData()
|
||||
break;
|
||||
case LegendTickmarkCount::TICKMARK_MANY:
|
||||
maxTickmarkCount = 10;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return maxTickmarkCount;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimPlotAxisPropertiesInterface::defineObjectEditorAttribute( QString uiConfigName, caf::PdmUiEditorAttribute* attribute )
|
||||
{
|
||||
RimSummaryMultiPlot* summaryMultiPlot = nullptr;
|
||||
firstAncestorOfType( summaryMultiPlot );
|
||||
|
||||
if ( summaryMultiPlot && summaryMultiPlot->isSubPlotAxesLinked() )
|
||||
{
|
||||
auto* treeItemAttribute = dynamic_cast<caf::PdmUiTreeViewItemAttribute*>( attribute );
|
||||
if ( treeItemAttribute )
|
||||
{
|
||||
treeItemAttribute->tags.clear();
|
||||
auto tag = caf::PdmUiTreeViewItemAttribute::Tag::create();
|
||||
tag->icon = caf::IconProvider( ":/chain.png" );
|
||||
|
||||
treeItemAttribute->tags.push_back( std::move( tag ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -74,8 +74,16 @@ public:
|
||||
|
||||
virtual bool isLogarithmicScaleEnabled() const;
|
||||
|
||||
virtual LegendTickmarkCount majorTickmarkCount() const = 0;
|
||||
virtual void setMajorTickmarkCount( LegendTickmarkCount count ) = 0;
|
||||
|
||||
static int tickmarkCountFromEnum( LegendTickmarkCount count );
|
||||
|
||||
public:
|
||||
virtual AxisTitlePositionType titlePosition() const = 0;
|
||||
virtual int titleFontSize() const = 0;
|
||||
virtual int valuesFontSize() const = 0;
|
||||
|
||||
private:
|
||||
void defineObjectEditorAttribute( QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override;
|
||||
};
|
||||
|
@ -157,10 +157,7 @@ RimProject::RimProject( void )
|
||||
CAF_PDM_InitFieldNoDefault( &mainPlotCollection, "MainPlotCollection", "Plots" );
|
||||
mainPlotCollection.uiCapability()->setUiTreeHidden( true );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &viewLinkerCollection,
|
||||
"LinkedViews",
|
||||
"Linked Views (field in RimProject",
|
||||
":/LinkView16x16.png" );
|
||||
CAF_PDM_InitFieldNoDefault( &viewLinkerCollection, "LinkedViews", "Linked Views", ":/LinkView.svg" );
|
||||
viewLinkerCollection.uiCapability()->setUiTreeHidden( true );
|
||||
viewLinkerCollection = new RimViewLinkerCollection;
|
||||
|
||||
|
@ -31,7 +31,7 @@ CAF_PDM_SOURCE_INIT( RimViewLinkerCollection, "RimViewLinkerCollection" );
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimViewLinkerCollection::RimViewLinkerCollection( void )
|
||||
{
|
||||
CAF_PDM_InitObject( "Linked Views", ":/LinkView16x16.png" );
|
||||
CAF_PDM_InitObject( "Linked Views", ":/LinkView.svg" );
|
||||
|
||||
CAF_PDM_InitField( &isActive, "Active", true, "Active" );
|
||||
isActive.uiCapability()->setUiHidden( true );
|
||||
|
@ -307,7 +307,6 @@ void RimSummaryMultiPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrde
|
||||
auto layoutGroup = uiOrdering.addNewGroup( "Layout" );
|
||||
layoutGroup->add( &m_columnCount );
|
||||
layoutGroup->add( &m_rowsPerPage );
|
||||
layoutGroup->add( &m_majorTickmarkCount );
|
||||
|
||||
auto axesGroup = uiOrdering.addNewGroup( "Axes" );
|
||||
axesGroup->add( &m_axisRangeAggregation );
|
||||
@ -787,6 +786,14 @@ void RimSummaryMultiPlot::makeSureIsVisible( RimSummaryPlot* summaryPlot )
|
||||
if ( summaryPlot->plotWidget() && !m_viewer.isNull() ) m_viewer->scrollToPlot( summaryPlot->plotWidget() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimSummaryMultiPlot::isSubPlotAxesLinked() const
|
||||
{
|
||||
return m_linkSubPlotAxes();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -90,6 +90,8 @@ public:
|
||||
|
||||
void makeSureIsVisible( RimSummaryPlot* plot );
|
||||
|
||||
bool isSubPlotAxesLinked() const;
|
||||
|
||||
void zoomAll() override;
|
||||
|
||||
protected:
|
||||
|
@ -849,6 +849,11 @@ void RimSummaryPlot::updateAxis( RiaDefines::PlotAxis plotAxis )
|
||||
}
|
||||
|
||||
plotWidget()->enableAxisNumberLabels( riuPlotAxis, axisProperties->showNumbers() );
|
||||
|
||||
RimSummaryTimeAxisProperties::LegendTickmarkCount tickmarkCountEnum = axisProperties->majorTickmarkCount();
|
||||
int maxTickmarkCount = RimPlotAxisPropertiesInterface::tickmarkCountFromEnum( tickmarkCountEnum );
|
||||
|
||||
plotWidget()->setAutoTickIntervalCounts( riuPlotAxis, maxTickmarkCount, maxTickmarkCount );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1110,26 +1115,7 @@ void RimSummaryPlot::updateTimeAxis( RimSummaryTimeAxisProperties* timeAxisPrope
|
||||
|
||||
{
|
||||
RimSummaryTimeAxisProperties::LegendTickmarkCount tickmarkCountEnum = timeAxisProperties->majorTickmarkCount();
|
||||
|
||||
int maxTickmarkCount = 8;
|
||||
|
||||
switch ( tickmarkCountEnum )
|
||||
{
|
||||
case RimSummaryTimeAxisProperties::LegendTickmarkCount::TICKMARK_VERY_FEW:
|
||||
maxTickmarkCount = 2;
|
||||
break;
|
||||
case RimSummaryTimeAxisProperties::LegendTickmarkCount::TICKMARK_FEW:
|
||||
maxTickmarkCount = 4;
|
||||
break;
|
||||
case RimSummaryTimeAxisProperties::LegendTickmarkCount::TICKMARK_DEFAULT:
|
||||
maxTickmarkCount = 8; // Taken from QwtPlot::initAxesData()
|
||||
break;
|
||||
case RimSummaryTimeAxisProperties::LegendTickmarkCount::TICKMARK_MANY:
|
||||
maxTickmarkCount = 10;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
int maxTickmarkCount = RimPlotAxisPropertiesInterface::tickmarkCountFromEnum( tickmarkCountEnum );
|
||||
|
||||
plotWidget()->setAxisMaxMajor( RiuPlotAxis::defaultBottom(), maxTickmarkCount );
|
||||
}
|
||||
|
@ -573,7 +573,10 @@ void RimSummaryTimeAxisProperties::defineUiOrdering( QString uiConfigName, caf::
|
||||
timeGroup->add( &m_visibleTimeSinceStartRangeMax );
|
||||
timeGroup->add( &m_visibleTimeSinceStartRangeMin );
|
||||
}
|
||||
|
||||
timeGroup->add( &m_valuesFontSize );
|
||||
timeGroup->add( &m_majorTickmarkCount );
|
||||
|
||||
if ( m_timeMode() == DATE )
|
||||
{
|
||||
caf::PdmUiGroup* advancedGroup = timeGroup->addNewGroup( "Date/Time Label Format" );
|
||||
|
@ -104,8 +104,8 @@ public:
|
||||
void setVisibleDateTimeMin( const QDateTime& dateTime );
|
||||
void setVisibleDateTimeMax( const QDateTime& dateTime );
|
||||
|
||||
LegendTickmarkCount majorTickmarkCount() const;
|
||||
void setMajorTickmarkCount( LegendTickmarkCount count );
|
||||
LegendTickmarkCount majorTickmarkCount() const override;
|
||||
void setMajorTickmarkCount( LegendTickmarkCount count ) override;
|
||||
|
||||
const QString& name() const override;
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "RiuMultiPlotBook.h"
|
||||
|
||||
#include "RiaGuiApplication.h"
|
||||
#include "RiaPlotDefines.h"
|
||||
#include "RiaPlotWindowRedrawScheduler.h"
|
||||
#include "RiaPreferences.h"
|
||||
|
||||
@ -342,8 +343,7 @@ void RiuMultiPlotBook::scheduleReplotOfAllPlots()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMultiPlotBook::renderTo( QPaintDevice* paintDevice )
|
||||
{
|
||||
int resolution = paintDevice->logicalDpiX();
|
||||
double scaling = resolution / static_cast<double>( RiaGuiApplication::applicationResolution() );
|
||||
auto scaling = RiaDefines::scalingFactor( paintDevice );
|
||||
|
||||
QPainter painter( paintDevice );
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "WellLogCommands/RicWellLogPlotTrackFeatureImpl.h"
|
||||
|
||||
#include "RiaGuiApplication.h"
|
||||
#include "RiaPlotDefines.h"
|
||||
|
||||
#include "RimContextCommandBuilder.h"
|
||||
#include "RimMultiPlot.h"
|
||||
@ -359,8 +360,7 @@ void RiuMultiPlotPage::updateSubTitles()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMultiPlotPage::renderTo( QPaintDevice* paintDevice )
|
||||
{
|
||||
int resolution = paintDevice->logicalDpiX();
|
||||
double scaling = resolution / static_cast<double>( RiaGuiApplication::applicationResolution() );
|
||||
auto scaling = RiaDefines::scalingFactor( paintDevice );
|
||||
|
||||
QPainter painter( paintDevice );
|
||||
renderTo( &painter, scaling );
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "RiaGuiApplication.h"
|
||||
#include "RiaPlotDefines.h"
|
||||
#include "RiaPlotWindowRedrawScheduler.h"
|
||||
|
||||
#include "RimPlot.h"
|
||||
|
||||
#include "RiuDraggableOverlayFrame.h"
|
||||
@ -757,8 +758,8 @@ void RiuQwtPlotWidget::renderTo( QPainter* painter, const QRect& targetRect, dou
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuQwtPlotWidget::renderTo( QPaintDevice* paintDevice, const QRect& targetRect )
|
||||
{
|
||||
int resolution = paintDevice->logicalDpiX();
|
||||
double scaling = resolution / static_cast<double>( RiaGuiApplication::applicationResolution() );
|
||||
auto scaling = RiaDefines::scalingFactor( paintDevice );
|
||||
|
||||
QPainter painter( paintDevice );
|
||||
renderTo( &painter, targetRect, scaling );
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user