ResInsight/ApplicationLibCode/ProjectDataModel/RimPlotAxisProperties.h

155 lines
5.4 KiB
C
Raw Normal View History

/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2016-2018 Statoil ASA
// Copyright (C) 2019- Equinor ASA
2017-12-12 00:42:16 -06:00
//
// 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.
2017-12-12 00:42:16 -06:00
//
// 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.
2017-12-12 00:42:16 -06:00
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RiaDefines.h"
#include "RimPlotAxisPropertiesInterface.h"
2016-11-24 03:14:26 -06:00
#include "cafAppEnum.h"
2020-05-09 04:23:58 -05:00
#include "cafFontTools.h"
2017-12-12 00:42:16 -06:00
#include "cafPdmChildArrayField.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
2016-10-10 04:05:45 -05:00
#include "qwt_plot.h"
#include <QString>
class RimPlotAxisAnnotation;
//==================================================================================================
2017-12-12 00:42:16 -06:00
///
///
//==================================================================================================
class RimPlotAxisProperties : public caf::PdmObject, public RimPlotAxisPropertiesInterface
{
CAF_PDM_HEADER_INIT;
public:
enum NumberFormatType
{
NUMBER_FORMAT_AUTO,
NUMBER_FORMAT_DECIMAL,
NUMBER_FORMAT_SCIENTIFIC
};
2020-07-02 06:06:31 -05:00
public:
caf::Signal<> settingsChanged;
caf::Signal<bool> logarithmicChanged;
public:
RimPlotAxisProperties();
void setEnableTitleTextSettings( bool enable );
2020-02-28 07:51:21 -06:00
void enableRangeSettings( bool enable );
void setNameAndAxis( const QString& name, QwtPlot::Axis axis );
AxisTitlePositionType titlePosition() const override;
2020-05-09 04:23:58 -05:00
int titleFontSize() const override;
int valuesFontSize() const override;
2017-12-12 00:42:16 -06:00
QwtPlot::Axis qwtPlotAxisType() const;
QString name() const;
RiaDefines::PlotAxis plotAxisType() const override;
2017-12-12 00:42:16 -06:00
bool useAutoTitle() const;
bool showDescription() const;
bool showAcronym() const;
bool showUnitText() const;
bool isAutoZoom() const;
void setAutoZoom( bool enableAutoZoom );
bool isAxisInverted() const;
void setAxisInverted( bool inverted );
2020-12-15 01:19:36 -06:00
std::vector<RimPlotAxisAnnotation*> annotations() const override;
void appendAnnotation( RimPlotAxisAnnotation* annotation ) override;
void removeAllAnnotations() override;
caf::PdmField<QString> customTitle;
2017-12-12 00:42:16 -06:00
caf::PdmField<double> visibleRangeMin;
caf::PdmField<double> visibleRangeMax;
2017-12-12 00:42:16 -06:00
caf::PdmField<caf::AppEnum<NumberFormatType>> numberFormat;
caf::PdmField<int> numberOfDecimals;
caf::PdmField<double> scaleFactor;
caf::PdmField<bool> isLogarithmicScaleEnabled;
2017-12-12 00:42:16 -06:00
bool isActive() const;
void setInvertedAxis( bool enable );
void showAnnotationObjectsInProjectTree();
protected:
void initAfterRead() override;
caf::PdmFieldHandle* userDescriptionField() override;
caf::PdmFieldHandle* objectToggleField() override;
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
2017-12-12 00:42:16 -06:00
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
bool* useOptionsOnly ) override;
private:
2020-05-09 04:23:58 -05:00
void updateOptionSensitivity();
caf::FontTools::FontSize plotFontSize() const;
private:
caf::PdmField<bool> m_isActive;
2017-12-12 00:42:16 -06:00
caf::PdmField<bool> isAutoTitle;
caf::PdmField<bool> m_displayShortName;
caf::PdmField<bool> m_displayLongName;
caf::PdmField<bool> m_displayUnitText;
caf::PdmField<bool> m_isAutoZoom;
caf::PdmField<bool> m_isAxisInverted;
2017-12-12 00:42:16 -06:00
caf::PdmField<QString> m_name;
QwtPlot::Axis m_axis;
bool m_enableTitleTextSettings;
2020-02-28 07:51:21 -06:00
bool m_isRangeSettingsEnabled;
2020-05-09 04:23:58 -05:00
caf::PdmField<caf::FontTools::RelativeSizeEnum> m_titleFontSize;
caf::PdmField<caf::AppEnum<AxisTitlePositionType>> m_titlePositionEnum;
2020-05-09 04:23:58 -05:00
caf::PdmField<caf::FontTools::RelativeSizeEnum> m_valuesFontSize;
caf::PdmChildArrayField<RimPlotAxisAnnotation*> m_annotations;
};
class QwtPlotCurve;
//==================================================================================================
///
///
//==================================================================================================
class RimPlotAxisLogRangeCalculator
{
public:
RimPlotAxisLogRangeCalculator( QwtPlot::Axis axis, const std::vector<const QwtPlotCurve*>& qwtCurves );
void computeAxisRange( double* minPositive, double* max ) const;
private:
bool curveValueRange( const QwtPlotCurve* qwtCurve, double* minPositive, double* max ) const;
private:
QwtPlot::Axis m_axis;
const std::vector<const QwtPlotCurve*> m_curves;
};