labplot  2.8.2
About: LabPlot is an application for plotting and analysis of 2D and 3D functions and data. It is a complete rewrite of LabPlot1 and lacks in the first release a lot of features available in the predecessor. On the other hand, the GUI and the usability is more superior.
  Fossies Dox: labplot-2.8.2.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

CartesianCoordinateSystem.h
Go to the documentation of this file.
1 /***************************************************************************
2  File : CartesianCoordinateSystem.h
3  Project : LabPlot
4  Description : Cartesian coordinate system for plots.
5  --------------------------------------------------------------------
6  Copyright : (C) 2012-2016 by Alexander Semke (alexander.semke@web.de)
7 
8  ***************************************************************************/
9 
10 /***************************************************************************
11  * *
12  * This program is free software; you can redistribute it and/or modify *
13  * it under the terms of the GNU General Public License as published by *
14  * the Free Software Foundation; either version 2 of the License, or *
15  * (at your option) any later version. *
16  * *
17  * This program is distributed in the hope that it will be useful, *
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
20  * GNU General Public License for more details. *
21  * *
22  * You should have received a copy of the GNU General Public License *
23  * along with this program; if not, write to the Free Software *
24  * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
25  * Boston, MA 02110-1301 USA *
26  * *
27  ***************************************************************************/
28 
29 #ifndef CARTESIANCOORDINATESYSTEM_H
30 #define CARTESIANCOORDINATESYSTEM_H
31 
34 #include "backend/lib/Interval.h"
35 
36 #include <vector>
37 
39 class CartesianCoordinateSystemSetScalePropertiesCmd;
40 
42 public:
43  virtual ~CartesianScale();
44 
45  //TODO: remove "Scale"
47 
48  static CartesianScale* createLinearScale(const Interval<double> &interval, double sceneStart, double sceneEnd,
49  double logicalStart, double logicalEnd);
50  static CartesianScale* createLogScale(const Interval<double> &interval, double sceneStart, double sceneEnd,
51  double logicalStart, double logicalEnd, CartesianPlot::Scale);
52 
53  virtual void getProperties(ScaleType *type = nullptr, Interval<double> *interval = nullptr,
54  double *a = nullptr, double *b = nullptr, double *c = nullptr) const;
55 
56  inline double start() const;
57  inline double end() const;
58  inline bool contains(double) const;
59  virtual bool map(double*) const = 0;
60  virtual bool inverseMap(double*) const = 0;
61  virtual int direction() const = 0;
62 
63 protected:
64  CartesianScale(ScaleType type, const Interval<double> &interval, double a, double b, double c);
67  //TODO: what are these?
68  double m_a;
69  double m_b;
70  double m_c;
71 };
72 
74 public:
76  ~CartesianCoordinateSystem() override;
77 
78  //TODO: document the 5 versions
79  QVector<QPointF> mapLogicalToScene(const QVector<QPointF>&, MappingFlags flags = MappingFlag::DefaultMapping) const override;
80  void mapLogicalToScene(const QVector<QPointF>& logicalPoints, QVector<QPointF>& scenePoints, std::vector<bool>& visiblePoints, MappingFlags flags = MappingFlag::DefaultMapping) const;
81  void mapLogicalToScene(int startIndex, int endIndex, const QVector<QPointF>& logicalPoints, QVector<QPointF>& scenePoints, QVector<bool>& visiblePoints, QVector<QVector<bool>>& scenePointsUsed, double minLogicalDiffX, double minLogicalDiffY, MappingFlags flags = MappingFlag::DefaultMapping) const;
82  QPointF mapLogicalToScene(QPointF, MappingFlags flags = MappingFlag::DefaultMapping) const override;
83  QVector<QLineF> mapLogicalToScene(const QVector<QLineF>&, MappingFlags flags = MappingFlag::DefaultMapping) const override;
84 
85  QVector<QPointF> mapSceneToLogical(const QVector<QPointF>&, MappingFlags flags = MappingFlag::DefaultMapping) const override;
86  QPointF mapSceneToLogical(QPointF, MappingFlags flags = MappingFlag::DefaultMapping) const override;
87 
88  int xDirection() const;
89  int yDirection() const;
94 
95 private:
96  void init();
97  bool rectContainsPoint(const QRectF&, QPointF) const;
99 };
100 
101 #endif
Base class of all worksheet coordinate systems.
Cartesian coordinate system for plots.
bool setYScales(const QVector< CartesianScale * > &)
bool setXScales(const QVector< CartesianScale * > &)
QVector< QPointF > mapLogicalToScene(const QVector< QPointF > &, MappingFlags flags=MappingFlag::DefaultMapping) const override
bool rectContainsPoint(const QRectF &, QPointF) const
int yDirection() const
Determine the vertical direction relative to the page.
QVector< CartesianScale * > xScales() const
int xDirection() const
Determine the horizontal direction relative to the page.
QVector< CartesianScale * > yScales() const
CartesianCoordinateSystemPrivate * d
QVector< QPointF > mapSceneToLogical(const QVector< QPointF > &, MappingFlags flags=MappingFlag::DefaultMapping) const override
A xy-plot.
Definition: CartesianPlot.h:58
Base class for cartesian coordinate system scales.
static CartesianScale * createLogScale(const Interval< double > &interval, double sceneStart, double sceneEnd, double logicalStart, double logicalEnd, CartesianPlot::Scale)
virtual int direction() const =0
virtual ~CartesianScale()
virtual void getProperties(ScaleType *type=nullptr, Interval< double > *interval=nullptr, double *a=nullptr, double *b=nullptr, double *c=nullptr) const
CartesianScale(ScaleType type, const Interval< double > &interval, double a, double b, double c)
virtual bool inverseMap(double *) const =0
virtual bool map(double *) const =0
static CartesianScale * createLinearScale(const Interval< double > &interval, double sceneStart, double sceneEnd, double logicalStart, double logicalEnd)
Interval< double > m_interval
bool contains(double) const