#968 Added checkboxes used to show/hide plot axis

This commit is contained in:
Magne Sjaastad 2016-11-11 15:38:02 +01:00
parent 0828b3b64c
commit e98fc23787
5 changed files with 84 additions and 23 deletions

View File

@ -178,17 +178,6 @@ void RimSummaryPlot::updateAxis(RimDefines::PlotAxis plotAxis)
{
if (!m_qwtPlot) return;
std::vector<RimSummaryCurve*> curves = curvesForAxis(plotAxis);
std::vector<RimSummaryCurveFilter*> curveFiltersForAxis;
for (RimSummaryCurveFilter* cs : m_curveFilters)
{
if (cs->associatedPlotAxis() == plotAxis)
{
curveFiltersForAxis.push_back(cs);
}
}
QwtPlot::Axis qwtAxis = QwtPlot::yLeft;
RimSummaryYAxisProperties* yAxisProperties = nullptr;
if (plotAxis == RimDefines::PLOT_AXIS_LEFT)
@ -202,16 +191,34 @@ void RimSummaryPlot::updateAxis(RimDefines::PlotAxis plotAxis)
yAxisProperties = m_rightYAxisProperties();
}
if (curves.size() > 0)
if (!yAxisProperties->isActive())
{
m_qwtPlot->enableAxis(qwtAxis, true);
RimSummaryCurvesCalculator calc(yAxisProperties, curves, curveFiltersForAxis);
calc.applyPropertiesToPlot(m_qwtPlot);
m_qwtPlot->enableAxis(qwtAxis, false);
}
else
{
m_qwtPlot->enableAxis(qwtAxis, false);
std::vector<RimSummaryCurve*> curves = curvesForAxis(plotAxis);
std::vector<RimSummaryCurveFilter*> curveFiltersForAxis;
for (RimSummaryCurveFilter* cs : m_curveFilters)
{
if (cs->associatedPlotAxis() == plotAxis)
{
curveFiltersForAxis.push_back(cs);
}
}
if (curves.size() > 0)
{
m_qwtPlot->enableAxis(qwtAxis, true);
RimSummaryCurvesCalculator calc(yAxisProperties, curves, curveFiltersForAxis);
calc.applyPropertiesToPlot(m_qwtPlot);
}
else
{
m_qwtPlot->enableAxis(qwtAxis, false);
}
}
}
@ -243,6 +250,15 @@ void RimSummaryPlot::updateTimeAxis()
{
if (!m_qwtPlot) return;
if (!m_timeAxisProperties->isActive())
{
m_qwtPlot->enableAxis(QwtPlot::xBottom, false);
return;
}
m_qwtPlot->enableAxis(QwtPlot::xBottom, true);
{
QString axisTitle;
if (m_timeAxisProperties->showTitle) axisTitle = m_timeAxisProperties->title();

View File

@ -34,6 +34,9 @@ RimSummaryTimeAxisProperties::RimSummaryTimeAxisProperties()
{
CAF_PDM_InitObject("Time Axis", ":/SummaryPlot16x16.png", "", "");
CAF_PDM_InitField(&m_isActive, "Active", true, "Active", "", "", "");
m_isActive.uiCapability()->setUiHidden(true);
CAF_PDM_InitField(&showTitle, "ShowTitle", false, "Show Title", "", "", "");
CAF_PDM_InitField(&title, "Title", QString("Time"), "Title", "", "", "");
CAF_PDM_InitField(&fontSize, "FontSize", 11, "Font Size", "", "", "");
@ -77,6 +80,14 @@ void RimSummaryTimeAxisProperties::setVisibleRangeMax(double value)
m_visibleRangeMax = QwtDate::toDateTime(value);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimSummaryTimeAxisProperties::isActive() const
{
return m_isActive;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -105,6 +116,14 @@ QList<caf::PdmOptionItemInfo> RimSummaryTimeAxisProperties::calculateValueOption
return options;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmFieldHandle* RimSummaryTimeAxisProperties::objectToggleField()
{
return &m_isActive;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -48,11 +48,15 @@ public:
void setVisibleRangeMin(double value);
void setVisibleRangeMax(double value);
bool isActive() const;
protected:
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
//virtual caf::PdmFieldHandle* userDescriptionField() override;
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override;
virtual caf::PdmFieldHandle* objectToggleField() override;
private:
caf::PdmField<QDateTime> m_visibleRangeMin;
caf::PdmField<QDateTime> m_visibleRangeMax;
caf::PdmField<bool> m_isActive;
caf::PdmField<QDateTime> m_visibleRangeMin;
caf::PdmField<QDateTime> m_visibleRangeMax;
};

View File

@ -44,6 +44,9 @@ RimSummaryYAxisProperties::RimSummaryYAxisProperties()
{
CAF_PDM_InitObject("Y-Axis Properties", ":/SummaryPlot16x16.png", "", "");
CAF_PDM_InitField(&m_isActive, "Active", true, "Active", "", "", "");
m_isActive.uiCapability()->setUiHidden(true);
CAF_PDM_InitFieldNoDefault(&m_name, "Name", "Name", "", "", "");
m_name.uiCapability()->setUiHidden(true);
@ -113,6 +116,14 @@ QwtPlot::Axis RimSummaryYAxisProperties::axis() const
return m_axis;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimSummaryYAxisProperties::isActive() const
{
return m_isActive;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -164,3 +175,11 @@ void RimSummaryYAxisProperties::initAfterRead()
updateOptionSensitivity();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmFieldHandle* RimSummaryYAxisProperties::objectToggleField()
{
return &m_isActive;
}

View File

@ -61,17 +61,20 @@ public:
caf::PdmField<bool> isLogarithmicScaleEnabled;
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
virtual caf::PdmFieldHandle* userDescriptionField() override;
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override;
bool isActive() const;
protected:
virtual void initAfterRead() override;
virtual caf::PdmFieldHandle* userDescriptionField() override;
virtual caf::PdmFieldHandle* objectToggleField() override;
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override;
private:
void updateOptionSensitivity();
private:
caf::PdmField<bool> m_isActive;
caf::PdmField<QString> m_name;
QwtPlot::Axis m_axis;
};