#8822 Summary Axis: Add tick mark count to y-axis

This commit is contained in:
Magne Sjaastad 2022-04-22 09:58:51 +02:00
parent b6f7dd931e
commit 853b4a26d5
20 changed files with 157 additions and 38 deletions

View File

@ -18,6 +18,9 @@
#include "RiaPlotDefines.h" #include "RiaPlotDefines.h"
#include "RiaGuiApplication.h"
#include "RiaPreferencesSystem.h"
#include "cafAppEnum.h" #include "cafAppEnum.h"
namespace caf 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 ); 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;
}

View File

@ -18,6 +18,8 @@
#pragma once #pragma once
class QPaintDevice;
// Defines relate to plotting // Defines relate to plotting
namespace RiaDefines namespace RiaDefines
{ {
@ -36,4 +38,6 @@ double maximumDefaultValuePlot();
bool isHorizontal( PlotAxis axis ); bool isHorizontal( PlotAxis axis );
bool isVertical( PlotAxis axis ); bool isVertical( PlotAxis axis );
double scalingFactor( QPaintDevice* paintDevice );
}; // namespace RiaDefines }; // namespace RiaDefines

View File

@ -85,6 +85,7 @@ RiaPreferencesSystem::RiaPreferencesSystem()
caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_showPdfExportDialog ); caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_showPdfExportDialog );
CAF_PDM_InitField( &m_gtestFilter, "gtestFilter", QString(), "Unit Test Filter (gtest)" ); 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, CAF_PDM_InitField( &m_eclipseReaderMode,
"eclipseReaderMode", "eclipseReaderMode",
@ -206,6 +207,14 @@ bool RiaPreferencesSystem::showPdfExportDialog() const
return m_showPdfExportDialog(); 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_includeFractureDebugInfoFile );
uiOrdering.add( &m_holoLensExportFolder ); uiOrdering.add( &m_holoLensExportFolder );
uiOrdering.add( &m_showProgressBar ); uiOrdering.add( &m_showProgressBar );
uiOrdering.add( &m_showPdfExportDialog ); uiOrdering.add( &m_showPdfExportDialog );
uiOrdering.add( &m_exportScalingFactor );
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -54,6 +54,7 @@ public:
QString gtestFilter() const; QString gtestFilter() const;
bool showProgressBar() const; bool showProgressBar() const;
bool showPdfExportDialog() const; bool showPdfExportDialog() const;
double exportPdfScalingFactor() const;
EclipseTextFileReaderMode eclipseTextFileReaderMode() const; EclipseTextFileReaderMode eclipseTextFileReaderMode() const;
@ -78,7 +79,9 @@ private:
caf::PdmField<bool> m_includeFractureDebugInfoFile; caf::PdmField<bool> m_includeFractureDebugInfoFile;
caf::PdmField<QString> m_holoLensExportFolder; 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<bool> m_showProgressBar;
caf::PdmField<QString> m_gtestFilter; caf::PdmField<QString> m_gtestFilter;

View File

@ -72,12 +72,12 @@ void RicSnapshotViewToPdfFeature::onActionTriggered( bool isChecked )
} }
else else
{ {
fileName = defaultFileName + ".pdf"; fileName = defaultFileName + "." + fileExtension;
} }
if ( !fileName.isEmpty() ) if ( !fileName.isEmpty() )
{ {
if ( plotWindow && fileName.endsWith( "PDF", Qt::CaseInsensitive ) ) if ( plotWindow && fileName.endsWith( fileExtension, Qt::CaseInsensitive ) )
{ {
RicSnapshotViewToFileFeature::savePlotPdfReportAs( fileName, plotWindow ); RicSnapshotViewToFileFeature::savePlotPdfReportAs( fileName, plotWindow );

View File

@ -34,7 +34,7 @@ CAF_PDM_SOURCE_INIT( RicLinkVisibleViewsFeatureUi, "RicLinkVisibleViewsFeatureUi
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RicLinkVisibleViewsFeatureUi::RicLinkVisibleViewsFeatureUi( void ) 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" ); CAF_PDM_InitFieldNoDefault( &m_masterView, "MasterView", "Primary View" );
} }

View File

@ -96,6 +96,8 @@ RimPlotAxisProperties::RimPlotAxisProperties()
CAF_PDM_InitFieldNoDefault( &m_annotations, "Annotations", "" ); CAF_PDM_InitFieldNoDefault( &m_annotations, "Annotations", "" );
m_annotations.uiCapability()->setUiTreeHidden( true ); m_annotations.uiCapability()->setUiTreeHidden( true );
CAF_PDM_InitFieldNoDefault( &m_majorTickmarkCount, "MajorTickmarkCount", "Major Tickmark Count" );
updateOptionSensitivity(); updateOptionSensitivity();
} }
@ -231,6 +233,7 @@ void RimPlotAxisProperties::defineUiOrdering( QString uiConfigName, caf::PdmUiOr
scaleGroup.add( &m_visibleRangeMax ); scaleGroup.add( &m_visibleRangeMax );
} }
scaleGroup.add( &m_valuesFontSize ); scaleGroup.add( &m_valuesFontSize );
scaleGroup.add( &m_majorTickmarkCount );
scaleGroup.add( &m_plotAxis ); scaleGroup.add( &m_plotAxis );
m_plotAxis.uiCapability()->setUiReadOnly( m_isAlwaysRequired ); m_plotAxis.uiCapability()->setUiReadOnly( m_isAlwaysRequired );
@ -437,6 +440,22 @@ void RimPlotAxisProperties::setVisibleRangeMax( double value )
m_visibleRangeMax = value; m_visibleRangeMax = value;
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimPlotAxisPropertiesInterface::LegendTickmarkCount RimPlotAxisProperties::majorTickmarkCount() const
{
return m_majorTickmarkCount();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotAxisProperties::setMajorTickmarkCount( LegendTickmarkCount count )
{
m_majorTickmarkCount = count;
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -103,6 +103,9 @@ public:
void setVisibleRangeMin( double value ) override; void setVisibleRangeMin( double value ) override;
void setVisibleRangeMax( double value ) override; void setVisibleRangeMax( double value ) override;
LegendTickmarkCount majorTickmarkCount() const override;
void setMajorTickmarkCount( LegendTickmarkCount count ) override;
protected: protected:
void initAfterRead() override; void initAfterRead() override;
caf::PdmFieldHandle* userDescriptionField() override; caf::PdmFieldHandle* userDescriptionField() override;
@ -134,6 +137,7 @@ private:
caf::PdmField<QString> m_name; caf::PdmField<QString> m_name;
caf::PdmField<caf::AppEnum<RiaDefines::PlotAxis>> m_plotAxis; caf::PdmField<caf::AppEnum<RiaDefines::PlotAxis>> m_plotAxis;
caf::PdmField<int> m_plotAxisIndex; caf::PdmField<int> m_plotAxisIndex;
caf::PdmField<LegendTickmarkCountEnum> m_majorTickmarkCount;
caf::PdmField<bool> m_isLogarithmicScaleEnabled; caf::PdmField<bool> m_isLogarithmicScaleEnabled;

View File

@ -15,9 +15,13 @@
// for more details. // for more details.
// //
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
#include "RimPlotAxisPropertiesInterface.h" #include "RimPlotAxisPropertiesInterface.h"
#include "RimSummaryMultiPlot.h"
#include "cafAppEnum.h" #include "cafAppEnum.h"
#include "cafPdmUiTreeAttributes.h"
CAF_PDM_XML_ABSTRACT_SOURCE_INIT( RimPlotAxisPropertiesInterface, CAF_PDM_XML_ABSTRACT_SOURCE_INIT( RimPlotAxisPropertiesInterface,
"PlotAxisPropertiesInterface", "PlotAxisPropertiesInterface",
@ -68,3 +72,53 @@ bool RimPlotAxisPropertiesInterface::isLogarithmicScaleEnabled() const
{ {
return false; 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 ) );
}
}
}

View File

@ -74,8 +74,16 @@ public:
virtual bool isLogarithmicScaleEnabled() const; virtual bool isLogarithmicScaleEnabled() const;
virtual LegendTickmarkCount majorTickmarkCount() const = 0;
virtual void setMajorTickmarkCount( LegendTickmarkCount count ) = 0;
static int tickmarkCountFromEnum( LegendTickmarkCount count );
public: public:
virtual AxisTitlePositionType titlePosition() const = 0; virtual AxisTitlePositionType titlePosition() const = 0;
virtual int titleFontSize() const = 0; virtual int titleFontSize() const = 0;
virtual int valuesFontSize() const = 0; virtual int valuesFontSize() const = 0;
private:
void defineObjectEditorAttribute( QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override;
}; };

View File

@ -157,10 +157,7 @@ RimProject::RimProject( void )
CAF_PDM_InitFieldNoDefault( &mainPlotCollection, "MainPlotCollection", "Plots" ); CAF_PDM_InitFieldNoDefault( &mainPlotCollection, "MainPlotCollection", "Plots" );
mainPlotCollection.uiCapability()->setUiTreeHidden( true ); mainPlotCollection.uiCapability()->setUiTreeHidden( true );
CAF_PDM_InitFieldNoDefault( &viewLinkerCollection, CAF_PDM_InitFieldNoDefault( &viewLinkerCollection, "LinkedViews", "Linked Views", ":/LinkView.svg" );
"LinkedViews",
"Linked Views (field in RimProject",
":/LinkView16x16.png" );
viewLinkerCollection.uiCapability()->setUiTreeHidden( true ); viewLinkerCollection.uiCapability()->setUiTreeHidden( true );
viewLinkerCollection = new RimViewLinkerCollection; viewLinkerCollection = new RimViewLinkerCollection;

View File

@ -31,7 +31,7 @@ CAF_PDM_SOURCE_INIT( RimViewLinkerCollection, "RimViewLinkerCollection" );
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RimViewLinkerCollection::RimViewLinkerCollection( void ) RimViewLinkerCollection::RimViewLinkerCollection( void )
{ {
CAF_PDM_InitObject( "Linked Views", ":/LinkView16x16.png" ); CAF_PDM_InitObject( "Linked Views", ":/LinkView.svg" );
CAF_PDM_InitField( &isActive, "Active", true, "Active" ); CAF_PDM_InitField( &isActive, "Active", true, "Active" );
isActive.uiCapability()->setUiHidden( true ); isActive.uiCapability()->setUiHidden( true );

View File

@ -307,7 +307,6 @@ void RimSummaryMultiPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrde
auto layoutGroup = uiOrdering.addNewGroup( "Layout" ); auto layoutGroup = uiOrdering.addNewGroup( "Layout" );
layoutGroup->add( &m_columnCount ); layoutGroup->add( &m_columnCount );
layoutGroup->add( &m_rowsPerPage ); layoutGroup->add( &m_rowsPerPage );
layoutGroup->add( &m_majorTickmarkCount );
auto axesGroup = uiOrdering.addNewGroup( "Axes" ); auto axesGroup = uiOrdering.addNewGroup( "Axes" );
axesGroup->add( &m_axisRangeAggregation ); axesGroup->add( &m_axisRangeAggregation );
@ -787,6 +786,14 @@ void RimSummaryMultiPlot::makeSureIsVisible( RimSummaryPlot* summaryPlot )
if ( summaryPlot->plotWidget() && !m_viewer.isNull() ) m_viewer->scrollToPlot( summaryPlot->plotWidget() ); if ( summaryPlot->plotWidget() && !m_viewer.isNull() ) m_viewer->scrollToPlot( summaryPlot->plotWidget() );
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimSummaryMultiPlot::isSubPlotAxesLinked() const
{
return m_linkSubPlotAxes();
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -90,6 +90,8 @@ public:
void makeSureIsVisible( RimSummaryPlot* plot ); void makeSureIsVisible( RimSummaryPlot* plot );
bool isSubPlotAxesLinked() const;
void zoomAll() override; void zoomAll() override;
protected: protected:

View File

@ -849,6 +849,11 @@ void RimSummaryPlot::updateAxis( RiaDefines::PlotAxis plotAxis )
} }
plotWidget()->enableAxisNumberLabels( riuPlotAxis, axisProperties->showNumbers() ); 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(); RimSummaryTimeAxisProperties::LegendTickmarkCount tickmarkCountEnum = timeAxisProperties->majorTickmarkCount();
int maxTickmarkCount = RimPlotAxisPropertiesInterface::tickmarkCountFromEnum( tickmarkCountEnum );
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;
}
plotWidget()->setAxisMaxMajor( RiuPlotAxis::defaultBottom(), maxTickmarkCount ); plotWidget()->setAxisMaxMajor( RiuPlotAxis::defaultBottom(), maxTickmarkCount );
} }

View File

@ -573,7 +573,10 @@ void RimSummaryTimeAxisProperties::defineUiOrdering( QString uiConfigName, caf::
timeGroup->add( &m_visibleTimeSinceStartRangeMax ); timeGroup->add( &m_visibleTimeSinceStartRangeMax );
timeGroup->add( &m_visibleTimeSinceStartRangeMin ); timeGroup->add( &m_visibleTimeSinceStartRangeMin );
} }
timeGroup->add( &m_valuesFontSize ); timeGroup->add( &m_valuesFontSize );
timeGroup->add( &m_majorTickmarkCount );
if ( m_timeMode() == DATE ) if ( m_timeMode() == DATE )
{ {
caf::PdmUiGroup* advancedGroup = timeGroup->addNewGroup( "Date/Time Label Format" ); caf::PdmUiGroup* advancedGroup = timeGroup->addNewGroup( "Date/Time Label Format" );

View File

@ -104,8 +104,8 @@ public:
void setVisibleDateTimeMin( const QDateTime& dateTime ); void setVisibleDateTimeMin( const QDateTime& dateTime );
void setVisibleDateTimeMax( const QDateTime& dateTime ); void setVisibleDateTimeMax( const QDateTime& dateTime );
LegendTickmarkCount majorTickmarkCount() const; LegendTickmarkCount majorTickmarkCount() const override;
void setMajorTickmarkCount( LegendTickmarkCount count ); void setMajorTickmarkCount( LegendTickmarkCount count ) override;
const QString& name() const override; const QString& name() const override;

View File

@ -18,6 +18,7 @@
#include "RiuMultiPlotBook.h" #include "RiuMultiPlotBook.h"
#include "RiaGuiApplication.h" #include "RiaGuiApplication.h"
#include "RiaPlotDefines.h"
#include "RiaPlotWindowRedrawScheduler.h" #include "RiaPlotWindowRedrawScheduler.h"
#include "RiaPreferences.h" #include "RiaPreferences.h"
@ -342,8 +343,7 @@ void RiuMultiPlotBook::scheduleReplotOfAllPlots()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RiuMultiPlotBook::renderTo( QPaintDevice* paintDevice ) void RiuMultiPlotBook::renderTo( QPaintDevice* paintDevice )
{ {
int resolution = paintDevice->logicalDpiX(); auto scaling = RiaDefines::scalingFactor( paintDevice );
double scaling = resolution / static_cast<double>( RiaGuiApplication::applicationResolution() );
QPainter painter( paintDevice ); QPainter painter( paintDevice );

View File

@ -26,6 +26,7 @@
#include "WellLogCommands/RicWellLogPlotTrackFeatureImpl.h" #include "WellLogCommands/RicWellLogPlotTrackFeatureImpl.h"
#include "RiaGuiApplication.h" #include "RiaGuiApplication.h"
#include "RiaPlotDefines.h"
#include "RimContextCommandBuilder.h" #include "RimContextCommandBuilder.h"
#include "RimMultiPlot.h" #include "RimMultiPlot.h"
@ -359,8 +360,7 @@ void RiuMultiPlotPage::updateSubTitles()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RiuMultiPlotPage::renderTo( QPaintDevice* paintDevice ) void RiuMultiPlotPage::renderTo( QPaintDevice* paintDevice )
{ {
int resolution = paintDevice->logicalDpiX(); auto scaling = RiaDefines::scalingFactor( paintDevice );
double scaling = resolution / static_cast<double>( RiaGuiApplication::applicationResolution() );
QPainter painter( paintDevice ); QPainter painter( paintDevice );
renderTo( &painter, scaling ); renderTo( &painter, scaling );

View File

@ -24,6 +24,7 @@
#include "RiaGuiApplication.h" #include "RiaGuiApplication.h"
#include "RiaPlotDefines.h" #include "RiaPlotDefines.h"
#include "RiaPlotWindowRedrawScheduler.h" #include "RiaPlotWindowRedrawScheduler.h"
#include "RimPlot.h" #include "RimPlot.h"
#include "RiuDraggableOverlayFrame.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 ) void RiuQwtPlotWidget::renderTo( QPaintDevice* paintDevice, const QRect& targetRect )
{ {
int resolution = paintDevice->logicalDpiX(); auto scaling = RiaDefines::scalingFactor( paintDevice );
double scaling = resolution / static_cast<double>( RiaGuiApplication::applicationResolution() );
QPainter painter( paintDevice ); QPainter painter( paintDevice );
renderTo( &painter, targetRect, scaling ); renderTo( &painter, targetRect, scaling );
} }