Whitepace

This commit is contained in:
Magne Sjaastad 2017-12-12 07:42:16 +01:00
parent e7c08223b6
commit 96b1fc9160
2 changed files with 86 additions and 93 deletions

View File

@ -1,61 +1,58 @@
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2016 Statoil ASA // Copyright (C) 2016 Statoil ASA
// //
// ResInsight is free software: you can redistribute it and/or modify // ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY // ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or // WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. // FITNESS FOR A PARTICULAR PURPOSE.
// //
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html> // See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details. // for more details.
// //
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
#include "RimSummaryAxisProperties.h" #include "RimSummaryAxisProperties.h"
#include "RimSummaryPlot.h"
#include "RiaDefines.h" #include "RiaDefines.h"
#include "RimSummaryPlot.h"
#include "cafPdmUiSliderEditor.h" #include "cafPdmUiSliderEditor.h"
#include <cmath> #include <cmath>
namespace caf namespace caf
{ {
template<> // clang-format off
void caf::AppEnum< RimSummaryAxisProperties::NumberFormatType >::setUp() template<>
{ void caf::AppEnum<RimSummaryAxisProperties::NumberFormatType>::setUp()
addItem(RimSummaryAxisProperties::NUMBER_FORMAT_AUTO, "NUMBER_FORMAT_AUTO", "Auto"); {
addItem(RimSummaryAxisProperties::NUMBER_FORMAT_DECIMAL, "NUMBER_FORMAT_DECIMAL", "Decimal"); addItem(RimSummaryAxisProperties::NUMBER_FORMAT_AUTO, "NUMBER_FORMAT_AUTO", "Auto");
addItem(RimSummaryAxisProperties::NUMBER_FORMAT_SCIENTIFIC,"NUMBER_FORMAT_SCIENTIFIC", "Scientific"); addItem(RimSummaryAxisProperties::NUMBER_FORMAT_DECIMAL, "NUMBER_FORMAT_DECIMAL", "Decimal");
addItem(RimSummaryAxisProperties::NUMBER_FORMAT_SCIENTIFIC, "NUMBER_FORMAT_SCIENTIFIC", "Scientific");
setDefault(RimSummaryAxisProperties::NUMBER_FORMAT_AUTO); setDefault(RimSummaryAxisProperties::NUMBER_FORMAT_AUTO);
}
} }
namespace caf
{
template<> template<>
void caf::AppEnum< RimSummaryAxisProperties::AxisTitlePositionType >::setUp() void caf::AppEnum<RimSummaryAxisProperties::AxisTitlePositionType>::setUp()
{ {
addItem(RimSummaryAxisProperties::AXIS_TITLE_CENTER, "AXIS_TITLE_CENTER", "Center"); addItem(RimSummaryAxisProperties::AXIS_TITLE_CENTER, "AXIS_TITLE_CENTER", "Center");
addItem(RimSummaryAxisProperties::AXIS_TITLE_END, "AXIS_TITLE_END", "At End"); addItem(RimSummaryAxisProperties::AXIS_TITLE_END, "AXIS_TITLE_END", "At End");
setDefault(RimSummaryAxisProperties::AXIS_TITLE_CENTER); setDefault(RimSummaryAxisProperties::AXIS_TITLE_CENTER);
} }
} // clang-format on
} // namespace caf
CAF_PDM_SOURCE_INIT(RimSummaryAxisProperties, "SummaryYAxisProperties"); CAF_PDM_SOURCE_INIT(RimSummaryAxisProperties, "SummaryYAxisProperties");
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RimSummaryAxisProperties::RimSummaryAxisProperties() RimSummaryAxisProperties::RimSummaryAxisProperties()
{ {
@ -98,7 +95,7 @@ RimSummaryAxisProperties::RimSummaryAxisProperties()
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
caf::PdmFieldHandle* RimSummaryAxisProperties::userDescriptionField() caf::PdmFieldHandle* RimSummaryAxisProperties::userDescriptionField()
{ {
@ -106,15 +103,15 @@ caf::PdmFieldHandle* RimSummaryAxisProperties::userDescriptionField()
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo> RimSummaryAxisProperties::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) QList<caf::PdmOptionItemInfo> RimSummaryAxisProperties::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions,
bool* useOptionsOnly)
{ {
QList<caf::PdmOptionItemInfo> options; QList<caf::PdmOptionItemInfo> options;
*useOptionsOnly = true; *useOptionsOnly = true;
if (&titleFontSize == fieldNeedingOptions || if (&titleFontSize == fieldNeedingOptions || &valuesFontSize == fieldNeedingOptions)
&valuesFontSize == fieldNeedingOptions)
{ {
std::vector<int> fontSizes; std::vector<int> fontSizes;
fontSizes.push_back(8); fontSizes.push_back(8);
@ -137,10 +134,8 @@ QList<caf::PdmOptionItemInfo> RimSummaryAxisProperties::calculateValueOptions(co
{ {
for (int exp = -12; exp <= 12; exp += 3) for (int exp = -12; exp <= 12; exp += 3)
{ {
QString uiText = QString uiText = exp == 0 ? "1" : QString("10 ^ %1").arg(exp);
exp == 0 ? "1" : double value = std::pow(10, exp);
QString("10 ^ %1").arg(exp);
double value = std::pow(10, exp);
options.push_back(caf::PdmOptionItemInfo(uiText, value)); options.push_back(caf::PdmOptionItemInfo(uiText, value));
} }
@ -150,7 +145,7 @@ QList<caf::PdmOptionItemInfo> RimSummaryAxisProperties::calculateValueOptions(co
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimSummaryAxisProperties::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) void RimSummaryAxisProperties::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
{ {
@ -163,7 +158,7 @@ void RimSummaryAxisProperties::defineUiOrdering(QString uiConfigName, caf::PdmUi
titleGroup.add(&m_displayShortName); titleGroup.add(&m_displayShortName);
titleGroup.add(&m_displayLongName); titleGroup.add(&m_displayLongName);
titleGroup.add(&m_displayUnitText); titleGroup.add(&m_displayUnitText);
customTitle.uiCapability()->setUiReadOnly(true); customTitle.uiCapability()->setUiReadOnly(true);
} }
else else
@ -174,10 +169,10 @@ void RimSummaryAxisProperties::defineUiOrdering(QString uiConfigName, caf::PdmUi
titleGroup.add(&titlePositionEnum); titleGroup.add(&titlePositionEnum);
titleGroup.add(&titleFontSize); titleGroup.add(&titleFontSize);
caf::PdmUiGroup& scaleGroup = *(uiOrdering.addNewGroup("Axis Values")); caf::PdmUiGroup& scaleGroup = *(uiOrdering.addNewGroup("Axis Values"));
scaleGroup.add(&isLogarithmicScaleEnabled); scaleGroup.add(&isLogarithmicScaleEnabled);
scaleGroup.add(&numberFormat); scaleGroup.add(&numberFormat);
if (numberFormat() != NUMBER_FORMAT_AUTO) if (numberFormat() != NUMBER_FORMAT_AUTO)
{ {
scaleGroup.add(&numberOfDecimals); scaleGroup.add(&numberOfDecimals);
@ -192,7 +187,7 @@ void RimSummaryAxisProperties::defineUiOrdering(QString uiConfigName, caf::PdmUi
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimSummaryAxisProperties::setNameAndAxis(const QString& name, QwtPlot::Axis axis) void RimSummaryAxisProperties::setNameAndAxis(const QString& name, QwtPlot::Axis axis)
{ {
@ -204,7 +199,7 @@ void RimSummaryAxisProperties::setNameAndAxis(const QString& name, QwtPlot::Axis
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
QwtPlot::Axis RimSummaryAxisProperties::qwtPlotAxisType() const QwtPlot::Axis RimSummaryAxisProperties::qwtPlotAxisType() const
{ {
@ -212,7 +207,7 @@ QwtPlot::Axis RimSummaryAxisProperties::qwtPlotAxisType() const
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RiaDefines::PlotAxis RimSummaryAxisProperties::plotAxisType() const RiaDefines::PlotAxis RimSummaryAxisProperties::plotAxisType() const
{ {
@ -223,7 +218,7 @@ RiaDefines::PlotAxis RimSummaryAxisProperties::plotAxisType() const
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
bool RimSummaryAxisProperties::useAutoTitle() const bool RimSummaryAxisProperties::useAutoTitle() const
{ {
@ -231,7 +226,7 @@ bool RimSummaryAxisProperties::useAutoTitle() const
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
bool RimSummaryAxisProperties::showDescription() const bool RimSummaryAxisProperties::showDescription() const
{ {
@ -239,7 +234,7 @@ bool RimSummaryAxisProperties::showDescription() const
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
bool RimSummaryAxisProperties::showAcronym() const bool RimSummaryAxisProperties::showAcronym() const
{ {
@ -247,7 +242,7 @@ bool RimSummaryAxisProperties::showAcronym() const
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
bool RimSummaryAxisProperties::showUnitText() const bool RimSummaryAxisProperties::showUnitText() const
{ {
@ -255,7 +250,7 @@ bool RimSummaryAxisProperties::showUnitText() const
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
bool RimSummaryAxisProperties::isActive() const bool RimSummaryAxisProperties::isActive() const
{ {
@ -263,11 +258,11 @@ bool RimSummaryAxisProperties::isActive() const
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimSummaryAxisProperties::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) void RimSummaryAxisProperties::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue,
const QVariant& newValue)
{ {
if (changedField == &isAutoTitle) if (changedField == &isAutoTitle)
{ {
updateOptionSensitivity(); updateOptionSensitivity();
@ -280,13 +275,13 @@ void RimSummaryAxisProperties::fieldChangedByUi(const caf::PdmFieldHandle* chang
if (changedField == &visibleRangeMax) if (changedField == &visibleRangeMax)
{ {
if (visibleRangeMin > visibleRangeMax) visibleRangeMax = oldValue.toDouble(); if (visibleRangeMin > visibleRangeMax) visibleRangeMax = oldValue.toDouble();
rimSummaryPlot->disableAutoZoom(); rimSummaryPlot->disableAutoZoom();
} }
else if (changedField == &visibleRangeMin) else if (changedField == &visibleRangeMin)
{ {
if (visibleRangeMin > visibleRangeMax) visibleRangeMin = oldValue.toDouble(); if (visibleRangeMin > visibleRangeMax) visibleRangeMin = oldValue.toDouble();
rimSummaryPlot->disableAutoZoom(); rimSummaryPlot->disableAutoZoom();
} }
@ -302,7 +297,7 @@ void RimSummaryAxisProperties::fieldChangedByUi(const caf::PdmFieldHandle* chang
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimSummaryAxisProperties::updateOptionSensitivity() void RimSummaryAxisProperties::updateOptionSensitivity()
{ {
@ -310,7 +305,7 @@ void RimSummaryAxisProperties::updateOptionSensitivity()
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimSummaryAxisProperties::initAfterRead() void RimSummaryAxisProperties::initAfterRead()
{ {
@ -318,10 +313,9 @@ void RimSummaryAxisProperties::initAfterRead()
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
caf::PdmFieldHandle* RimSummaryAxisProperties::objectToggleField() caf::PdmFieldHandle* RimSummaryAxisProperties::objectToggleField()
{ {
return &m_isActive; return &m_isActive;
} }

View File

@ -1,40 +1,37 @@
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2016 Statoil ASA // Copyright (C) 2016 Statoil ASA
// //
// ResInsight is free software: you can redistribute it and/or modify // ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY // ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or // WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. // FITNESS FOR A PARTICULAR PURPOSE.
// //
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html> // See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details. // for more details.
// //
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
#pragma once #pragma once
#include "RiaDefines.h" #include "RiaDefines.h"
#include "cafPdmObject.h"
#include "cafPdmField.h"
#include "cafPdmChildArrayField.h"
#include "cafAppEnum.h" #include "cafAppEnum.h"
#include "cafPdmChildArrayField.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "qwt_plot.h" #include "qwt_plot.h"
#include <QString> #include <QString>
//================================================================================================== //==================================================================================================
/// ///
/// ///
//================================================================================================== //==================================================================================================
class RimSummaryAxisProperties : public caf::PdmObject class RimSummaryAxisProperties : public caf::PdmObject
{ {
@ -57,49 +54,51 @@ public:
public: public:
RimSummaryAxisProperties(); RimSummaryAxisProperties();
void setNameAndAxis(const QString& name, QwtPlot::Axis axis); void setNameAndAxis(const QString& name, QwtPlot::Axis axis);
QwtPlot::Axis qwtPlotAxisType() const; QwtPlot::Axis qwtPlotAxisType() const;
RiaDefines::PlotAxis plotAxisType() const; RiaDefines::PlotAxis plotAxisType() const;
bool useAutoTitle() const;
bool showDescription() const;
bool showAcronym() const;
bool showUnitText() const;
bool useAutoTitle() const; caf::PdmField<QString> customTitle;
bool showDescription() const; caf::PdmField<int> titleFontSize;
bool showAcronym() const; caf::PdmField<caf::AppEnum<AxisTitlePositionType>> titlePositionEnum;
bool showUnitText() const;
caf::PdmField<QString> customTitle; caf::PdmField<double> visibleRangeMin;
caf::PdmField<int> titleFontSize; caf::PdmField<double> visibleRangeMax;
caf::PdmField< caf::AppEnum< AxisTitlePositionType > > titlePositionEnum;
caf::PdmField<double> visibleRangeMin; caf::PdmField<caf::AppEnum<NumberFormatType>> numberFormat;
caf::PdmField<double> visibleRangeMax; caf::PdmField<int> numberOfDecimals;
caf::PdmField<double> scaleFactor;
caf::PdmField<bool> isLogarithmicScaleEnabled;
caf::PdmField<int> valuesFontSize;
caf::PdmField< caf::AppEnum< NumberFormatType > > numberFormat; bool isActive() const;
caf::PdmField<int> numberOfDecimals;
caf::PdmField<double> scaleFactor;
caf::PdmField<bool> isLogarithmicScaleEnabled;
caf::PdmField<int> valuesFontSize;
bool isActive() const;
protected: protected:
virtual void initAfterRead() override; virtual void initAfterRead() override;
virtual caf::PdmFieldHandle* userDescriptionField() override; virtual caf::PdmFieldHandle* userDescriptionField() override;
virtual caf::PdmFieldHandle* objectToggleField() override; virtual caf::PdmFieldHandle* objectToggleField() override;
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue,
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override; const QVariant& newValue) override;
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions,
bool* useOptionsOnly) override;
private: private:
void updateOptionSensitivity(); void updateOptionSensitivity();
private: private:
caf::PdmField<bool> m_isActive; caf::PdmField<bool> m_isActive;
caf::PdmField<bool> isAutoTitle; caf::PdmField<bool> isAutoTitle;
caf::PdmField<bool> m_displayShortName; caf::PdmField<bool> m_displayShortName;
caf::PdmField<bool> m_displayLongName; caf::PdmField<bool> m_displayLongName;
caf::PdmField<bool> m_displayUnitText; caf::PdmField<bool> m_displayUnitText;
caf::PdmField<QString> m_name; caf::PdmField<QString> m_name;
QwtPlot::Axis m_axis; QwtPlot::Axis m_axis;
}; };