///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2016-2018 Statoil ASA // Copyright (C) 2019- Equinor 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 // for more details. // ///////////////////////////////////////////////////////////////////////////////// #pragma once #include "RiaDefines.h" #include "RimPlotAxisPropertiesInterface.h" #include "cafAppEnum.h" #include "cafFontTools.h" #include "cafPdmChildArrayField.h" #include "cafPdmField.h" #include "cafPdmObject.h" #include "qwt_plot.h" #include class RimPlotAxisAnnotation; //================================================================================================== /// /// //================================================================================================== class RimPlotAxisProperties : public caf::PdmObject, public RimPlotAxisPropertiesInterface { CAF_PDM_HEADER_INIT; public: enum NumberFormatType { NUMBER_FORMAT_AUTO, NUMBER_FORMAT_DECIMAL, NUMBER_FORMAT_SCIENTIFIC }; public: caf::Signal<> settingsChanged; caf::Signal logarithmicChanged; public: RimPlotAxisProperties(); void setEnableTitleTextSettings( bool enable ); void enableRangeSettings( bool enable ); void setNameAndAxis( const QString& name, QwtPlot::Axis axis ); AxisTitlePositionType titlePosition() const override; int titleFontSize() const override; int valuesFontSize() const override; QwtPlot::Axis qwtPlotAxisType() const; QString name() const; RiaDefines::PlotAxis plotAxisType() const override; 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 ); std::vector annotations() const override; void appendAnnotation( RimPlotAxisAnnotation* annotation ) override; void removeAllAnnotations() override; caf::PdmField customTitle; caf::PdmField visibleRangeMin; caf::PdmField visibleRangeMax; caf::PdmField> numberFormat; caf::PdmField numberOfDecimals; caf::PdmField scaleFactor; caf::PdmField isLogarithmicScaleEnabled; 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; QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly ) override; private: void updateOptionSensitivity(); caf::FontTools::FontSize plotFontSize() const; private: caf::PdmField m_isActive; caf::PdmField isAutoTitle; caf::PdmField m_displayShortName; caf::PdmField m_displayLongName; caf::PdmField m_displayUnitText; caf::PdmField m_isAutoZoom; caf::PdmField m_isAxisInverted; caf::PdmField m_name; QwtPlot::Axis m_axis; bool m_enableTitleTextSettings; bool m_isRangeSettingsEnabled; caf::PdmField m_titleFontSize; caf::PdmField> m_titlePositionEnum; caf::PdmField m_valuesFontSize; caf::PdmChildArrayField m_annotations; }; class QwtPlotCurve; //================================================================================================== /// /// //================================================================================================== class RimPlotAxisLogRangeCalculator { public: RimPlotAxisLogRangeCalculator( QwtPlot::Axis axis, const std::vector& 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 m_curves; };