2016-10-07 03:51:08 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2016 Statoil 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 "RimSummaryYAxisProperties.h"
|
|
|
|
|
2016-10-07 08:36:52 -05:00
|
|
|
#include "RimSummaryPlot.h"
|
2016-10-10 04:05:45 -05:00
|
|
|
#include "RimDefines.h"
|
2016-10-07 03:51:08 -05:00
|
|
|
|
|
|
|
|
|
|
|
namespace caf
|
|
|
|
{
|
|
|
|
template<>
|
|
|
|
void caf::AppEnum< RimSummaryYAxisProperties::NumberFormatType >::setUp()
|
|
|
|
{
|
|
|
|
addItem(RimSummaryYAxisProperties::NUMBER_FORMAT_AUTO, "NUMBER_FORMAT_AUTO", "Auto");
|
|
|
|
addItem(RimSummaryYAxisProperties::NUMBER_FORMAT_DECIMAL, "NUMBER_FORMAT_DECIMAL", "Decimal");
|
|
|
|
addItem(RimSummaryYAxisProperties::NUMBER_FORMAT_SCIENTIFIC,"NUMBER_FORMAT_SCIENTIFIC", "Scientific");
|
|
|
|
|
|
|
|
setDefault(RimSummaryYAxisProperties::NUMBER_FORMAT_AUTO);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-07 08:36:52 -05:00
|
|
|
CAF_PDM_SOURCE_INIT(RimSummaryYAxisProperties, "SummaryYAxisProperties");
|
2016-10-07 03:51:08 -05:00
|
|
|
|
2016-10-10 04:05:45 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimSummaryYAxisProperties::RimSummaryYAxisProperties()
|
|
|
|
{
|
|
|
|
CAF_PDM_InitObject("Y-Axis Properties", ":/SummaryPlot16x16.png", "", "");
|
|
|
|
|
|
|
|
CAF_PDM_InitFieldNoDefault(&m_name, "Name", "Name", "", "", "");
|
|
|
|
m_name.uiCapability()->setUiHidden(true);
|
|
|
|
|
|
|
|
CAF_PDM_InitField(&isAutoTitle, "AutoTitle", true, "Auto Title", "", "", "");
|
|
|
|
CAF_PDM_InitFieldNoDefault(&customTitle, "CustomTitle", "Title", "", "", "");
|
|
|
|
CAF_PDM_InitField(&fontSize, "FontSize", 11, "Font Size", "", "", "");
|
|
|
|
|
|
|
|
CAF_PDM_InitField(&visibleRangeMax, "VisibleRangeMax", RimDefines::maximumDefaultValuePlot(), "Max", "", "", "");
|
2016-10-10 08:52:18 -05:00
|
|
|
CAF_PDM_InitField(&visibleRangeMin, "VisibleRangeMin", RimDefines::minimumDefaultValuePlot(), "Min", "", "", "");
|
2016-10-10 04:05:45 -05:00
|
|
|
|
|
|
|
CAF_PDM_InitFieldNoDefault(&numberFormat, "NumberFormat", "Number Format", "", "", "");
|
|
|
|
|
|
|
|
CAF_PDM_InitField(&isLogarithmicScaleEnabled, "LogarithmicScale", false, "Logarithmic Scale", "", "", "");
|
2016-10-10 08:52:18 -05:00
|
|
|
isLogarithmicScaleEnabled.uiCapability()->setUiHidden(true);
|
2016-10-10 04:05:45 -05:00
|
|
|
|
|
|
|
updateOptionSensitivity();
|
|
|
|
}
|
|
|
|
|
2016-10-07 03:51:08 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
caf::PdmFieldHandle* RimSummaryYAxisProperties::userDescriptionField()
|
|
|
|
{
|
|
|
|
return &m_name;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
QList<caf::PdmOptionItemInfo> RimSummaryYAxisProperties::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly)
|
|
|
|
{
|
|
|
|
QList<caf::PdmOptionItemInfo> options;
|
|
|
|
*useOptionsOnly = true;
|
|
|
|
|
|
|
|
if (&fontSize == fieldNeedingOptions)
|
|
|
|
{
|
|
|
|
std::vector<int> fontSizes;
|
|
|
|
fontSizes.push_back(8);
|
|
|
|
fontSizes.push_back(10);
|
|
|
|
fontSizes.push_back(12);
|
|
|
|
fontSizes.push_back(16);
|
|
|
|
fontSizes.push_back(24);
|
|
|
|
|
|
|
|
for (int value : fontSizes)
|
|
|
|
{
|
|
|
|
QString text = QString("%1").arg(value);
|
|
|
|
options.push_back(caf::PdmOptionItemInfo(text, value));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return options;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2016-10-10 04:05:45 -05:00
|
|
|
void RimSummaryYAxisProperties::setNameAndAxis(const QString& name, QwtPlot::Axis axis)
|
2016-10-07 03:51:08 -05:00
|
|
|
{
|
2016-10-10 04:05:45 -05:00
|
|
|
m_name = name;
|
|
|
|
m_axis = axis;
|
2016-10-07 03:51:08 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2016-10-10 04:05:45 -05:00
|
|
|
QwtPlot::Axis RimSummaryYAxisProperties::axis() const
|
2016-10-07 03:51:08 -05:00
|
|
|
{
|
2016-10-10 04:05:45 -05:00
|
|
|
return m_axis;
|
2016-10-07 03:51:08 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimSummaryYAxisProperties::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
|
|
|
|
{
|
2016-10-11 12:40:45 -05:00
|
|
|
RimSummaryPlot* rimSummaryPlot = nullptr;
|
|
|
|
this->firstAncestorOrThisOfType(rimSummaryPlot);
|
|
|
|
|
2016-10-10 08:52:18 -05:00
|
|
|
if (changedField == &isAutoTitle)
|
2016-10-07 03:51:08 -05:00
|
|
|
{
|
|
|
|
updateOptionSensitivity();
|
|
|
|
}
|
2016-10-11 12:40:45 -05:00
|
|
|
else if (changedField == &visibleRangeMax)
|
|
|
|
{
|
|
|
|
if (visibleRangeMin > visibleRangeMax) visibleRangeMax = oldValue.toDouble();
|
|
|
|
|
|
|
|
rimSummaryPlot->disableAutoZoom();
|
|
|
|
}
|
|
|
|
else if (changedField == &visibleRangeMin)
|
|
|
|
{
|
|
|
|
if (visibleRangeMin > visibleRangeMax) visibleRangeMin = oldValue.toDouble();
|
|
|
|
|
|
|
|
rimSummaryPlot->disableAutoZoom();
|
|
|
|
}
|
2016-10-07 08:36:52 -05:00
|
|
|
|
2016-10-11 12:40:45 -05:00
|
|
|
rimSummaryPlot->updateAxes();
|
2016-10-07 03:51:08 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimSummaryYAxisProperties::updateOptionSensitivity()
|
|
|
|
{
|
|
|
|
customTitle.uiCapability()->setUiReadOnly(isAutoTitle);
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimSummaryYAxisProperties::initAfterRead()
|
|
|
|
{
|
|
|
|
updateOptionSensitivity();
|
|
|
|
}
|
|
|
|
|