File indexing completed on 2025-01-26 03:34:10
0001 /* 0002 File : CartesianScale.h 0003 Project : LabPlot 0004 Description : Cartesian coordinate system for plots. 0005 -------------------------------------------------------------------- 0006 SPDX-FileCopyrightText: 2012-2016 Alexander Semke <alexander.semke@web.de> 0007 SPDX-FileCopyrightText: 2020-2021 Stefan Gerlach <stefan.gerlach@uni.kn> 0008 0009 SPDX-License-Identifier: GPL-2.0-or-later 0010 */ 0011 0012 #ifndef CARTESIANSCALE_H 0013 #define CARTESIANSCALE_H 0014 0015 #include "backend/lib/Range.h" 0016 0017 class CartesianScale { 0018 public: 0019 virtual ~CartesianScale(); 0020 0021 static CartesianScale* createLinearScale(const Range<double>& range, const Range<double>& sceneRange, const Range<double>& logicalRange); 0022 static CartesianScale* createLogScale(const Range<double>& range, const Range<double>& sceneRange, const Range<double>& logicalRange, RangeT::Scale); 0023 static CartesianScale* createSqrtScale(const Range<double>& range, const Range<double>& sceneRange, const Range<double>& logicalRange); 0024 static CartesianScale* createSquareScale(const Range<double>& range, const Range<double>& sceneRange, const Range<double>& logicalRange); 0025 static CartesianScale* createInverseScale(const Range<double>& range, const Range<double>& sceneRange, const Range<double>& logicalRange); 0026 0027 virtual void getProperties(Range<double>* range = nullptr, double* a = nullptr, double* b = nullptr, double* c = nullptr) const; 0028 0029 inline double start() const { 0030 return m_range.start(); 0031 } 0032 inline double end() const { 0033 return m_range.end(); 0034 } 0035 inline Range<double> range() const { 0036 return m_range; 0037 } 0038 inline bool contains(double value) const { 0039 return m_range.contains(value); 0040 } 0041 0042 virtual bool map(double*) const = 0; 0043 virtual bool inverseMap(double*) const = 0; 0044 virtual int direction() const = 0; 0045 0046 protected: 0047 CartesianScale(const Range<double>& range, double a, double b, double c); 0048 Range<double> m_range; 0049 /// Those parameters define the scaling 0050 /// They will be set by the linear, log, sqrt, ... scales 0051 /// See the definition of the different scales for their meaning 0052 double m_a; 0053 double m_b; 0054 double m_c; 0055 }; 0056 0057 #endif