mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-08 23:23:01 -06:00
#5577 Multi Plot : Add attribute for setting tick mark count along x-axis
This commit is contained in:
parent
34d3785709
commit
610e7d6391
@ -15,11 +15,13 @@
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RimMultiPlot.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RimPlot.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimSummaryTimeAxisProperties.h"
|
||||
|
||||
#include "RiuMultiPlotBook.h"
|
||||
#include "RiuPlotMainWindow.h"
|
||||
@ -73,6 +75,7 @@ RimMultiPlot::RimMultiPlot()
|
||||
CAF_PDM_InitFieldNoDefault( &m_rowsPerPage, "RowsPerPage", "Rows per Page", "", "", "" );
|
||||
|
||||
CAF_PDM_InitField( &m_showIndividualPlotTitles, "ShowPlotTitles", true, "Show Sub Plot Titles", "", "", "" );
|
||||
CAF_PDM_InitFieldNoDefault( &m_majorTickmarkCount, "MajorTickmarkCount", "Major Tickmark Count", "", "", "" );
|
||||
|
||||
m_viewer = nullptr;
|
||||
}
|
||||
@ -529,6 +532,20 @@ void RimMultiPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField, co
|
||||
updateLayout();
|
||||
RiuPlotMainWindowTools::refreshToolbars();
|
||||
}
|
||||
else if ( changedField = &m_majorTickmarkCount )
|
||||
{
|
||||
for ( RimPlot* plot : plots() )
|
||||
{
|
||||
std::vector<RimSummaryTimeAxisProperties*> timeAxisProps;
|
||||
plot->descendantsIncludingThisOfType( timeAxisProps );
|
||||
for ( auto tap : timeAxisProps )
|
||||
{
|
||||
tap->setMajorTickmarkCount( m_majorTickmarkCount() );
|
||||
}
|
||||
}
|
||||
|
||||
updatePlots();
|
||||
}
|
||||
updateConnectedEditors();
|
||||
}
|
||||
|
||||
@ -552,6 +569,7 @@ void RimMultiPlot::uiOrderingForMultiPlotLayout( QString uiConfigName, caf::PdmU
|
||||
RimPlotWindow::uiOrderingForPlotLayout( uiConfigName, uiOrdering );
|
||||
uiOrdering.add( &m_columnCount );
|
||||
uiOrdering.add( &m_rowsPerPage );
|
||||
uiOrdering.add( &m_majorTickmarkCount );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -15,9 +15,12 @@
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RimPlotAxisPropertiesInterface.h"
|
||||
#include "RimPlotWindow.h"
|
||||
|
||||
#include "RiuMultiPlotBook.h"
|
||||
|
||||
#include "cafAppEnum.h"
|
||||
@ -139,6 +142,8 @@ protected:
|
||||
caf::PdmField<RowCountEnum> m_rowsPerPage;
|
||||
caf::PdmField<bool> m_showIndividualPlotTitles;
|
||||
|
||||
caf::PdmField<RimPlotAxisPropertiesInterface::LegendTickmarkCountEnum> m_majorTickmarkCount;
|
||||
|
||||
friend class RiuMultiPlotBook;
|
||||
QPointer<RiuMultiPlotBook> m_viewer;
|
||||
|
||||
|
@ -30,6 +30,15 @@ void caf::AppEnum<RimPlotAxisPropertiesInterface::AxisTitlePositionType>::setUp(
|
||||
|
||||
setDefault(RimPlotAxisPropertiesInterface::AXIS_TITLE_CENTER);
|
||||
}
|
||||
|
||||
template <>
|
||||
void RimPlotAxisPropertiesInterface::LegendTickmarkCountEnum::setUp()
|
||||
{
|
||||
addItem( RimPlotAxisPropertiesInterface::LegendTickmarkCount::TICKMARK_FEW, "Few", "Few" );
|
||||
addItem( RimPlotAxisPropertiesInterface::LegendTickmarkCount::TICKMARK_DEFAULT, "Default", "Default" );
|
||||
addItem( RimPlotAxisPropertiesInterface::LegendTickmarkCount::TICKMARK_MANY, "Many", "Many" );
|
||||
setDefault( RimPlotAxisPropertiesInterface::LegendTickmarkCount::TICKMARK_DEFAULT );
|
||||
}
|
||||
} // namespace caf
|
||||
|
||||
|
||||
|
@ -15,8 +15,11 @@
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafAppEnum.h"
|
||||
|
||||
class RimPlotAxisPropertiesInterface
|
||||
{
|
||||
public:
|
||||
@ -26,6 +29,14 @@ public:
|
||||
AXIS_TITLE_END
|
||||
};
|
||||
|
||||
enum class LegendTickmarkCount
|
||||
{
|
||||
TICKMARK_FEW,
|
||||
TICKMARK_DEFAULT,
|
||||
TICKMARK_MANY,
|
||||
};
|
||||
using LegendTickmarkCountEnum = caf::AppEnum<LegendTickmarkCount>;
|
||||
|
||||
public:
|
||||
virtual AxisTitlePositionType titlePosition() const = 0;
|
||||
virtual int titleFontSize() const = 0;
|
||||
|
@ -1107,6 +1107,30 @@ void RimSummaryPlot::updateTimeAxis()
|
||||
alignment );
|
||||
m_plotWidget->setAxisTitleText( QwtPlot::xBottom, m_timeAxisProperties->title() );
|
||||
m_plotWidget->setAxisTitleEnabled( QwtPlot::xBottom, m_timeAxisProperties->showTitle );
|
||||
|
||||
{
|
||||
RimSummaryTimeAxisProperties::LegendTickmarkCount tickmarkCountEnum =
|
||||
m_timeAxisProperties->majorTickmarkCount();
|
||||
|
||||
int maxTickmarkCount = 8;
|
||||
|
||||
switch ( tickmarkCountEnum )
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
m_plotWidget->setAxisMaxMajor( QwtPlot::xBottom, maxTickmarkCount );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -115,6 +115,8 @@ RimSummaryTimeAxisProperties::RimSummaryTimeAxisProperties()
|
||||
m_timeFormat.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() );
|
||||
m_timeFormat = RiaApplication::instance()->preferences()->timeFormat();
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_majorTickmarkCount, "MajorTickmarkCount", "Major Tickmark Count", "", "", "" );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_visibleDateTimeRangeMax_OBSOLETE, "VisibleRangeMax", "Max", "", "", "" );
|
||||
m_visibleDateTimeRangeMax_OBSOLETE.uiCapability()->setUiEditorTypeName( caf::PdmUiLineEditor::uiEditorTypeName() );
|
||||
|
||||
@ -332,6 +334,22 @@ void RimSummaryTimeAxisProperties::setVisibleDateTimeMax( const QDateTime& dateT
|
||||
m_visibleTimeRangeMax = dateTime.time();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSummaryTimeAxisProperties::LegendTickmarkCount RimSummaryTimeAxisProperties::majorTickmarkCount() const
|
||||
{
|
||||
return m_majorTickmarkCount();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryTimeAxisProperties::setMajorTickmarkCount( LegendTickmarkCount count )
|
||||
{
|
||||
m_majorTickmarkCount = count;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -98,6 +98,9 @@ public:
|
||||
void setVisibleDateTimeMin( const QDateTime& dateTime );
|
||||
void setVisibleDateTimeMax( const QDateTime& dateTime );
|
||||
|
||||
LegendTickmarkCount majorTickmarkCount() const;
|
||||
void setMajorTickmarkCount( LegendTickmarkCount count );
|
||||
|
||||
protected:
|
||||
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
|
||||
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
|
||||
@ -136,6 +139,7 @@ private:
|
||||
caf::PdmField<TimeFormatEnum> m_timeComponents;
|
||||
caf::PdmField<QString> m_dateFormat;
|
||||
caf::PdmField<QString> m_timeFormat;
|
||||
caf::PdmField<LegendTickmarkCountEnum> m_majorTickmarkCount;
|
||||
|
||||
caf::PdmField<QDateTime> m_visibleDateTimeRangeMin_OBSOLETE;
|
||||
caf::PdmField<QDateTime> m_visibleDateTimeRangeMax_OBSOLETE;
|
||||
|
Loading…
Reference in New Issue
Block a user