SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
scaleengine.h
Go to the documentation of this file.
1 // Copyright (C) 2012 maintech GmbH, Otto-Hahn-Str. 15, 97204 Hoechberg, Germany //
3 // written by Christian Daniel //
4 // //
5 // This program is free software; you can redistribute it and/or modify //
6 // it under the terms of the GNU General Public License as published by //
7 // the Free Software Foundation as version 3 of the License, or //
8 // (at your option) any later version. //
9 // //
10 // This program is distributed in the hope that it will be useful, //
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
13 // GNU General Public License V3 for more details. //
14 // //
15 // You should have received a copy of the GNU General Public License //
16 // along with this program. If not, see <http://www.gnu.org/licenses/>. //
18 
19 #ifndef INCLUDE_SCALEENGINE_H
20 #define INCLUDE_SCALEENGINE_H
21 
22 #include <QFont>
23 #include <QString>
24 #include <QList>
25 #include "physicalunit.h"
26 #include "export.h"
27 
29 public:
30  struct Tick {
31  float pos;
32  bool major;
33  float textPos;
34  float textSize;
35  QString text;
36  };
37  typedef QList<Tick> TickList;
38 
39 private:
40  // base configuration
41  Qt::Orientation m_orientation;
42  QFont m_font;
43  float m_charSize;
44 
45  // graph configuration
46  float m_size;
48  float m_rangeMin;
49  float m_rangeMax;
50 
51  // calculated values
52  bool m_recalc;
53  double m_scale;
54  QString m_unitStr;
55  TickList m_tickList;
61  bool m_makeOpposite; // will show -value instead of value
62 
63  QString formatTick(double value, int decimalPlaces);
64  void calcCharSize();
65  void calcScaleFactor();
66  double calcMajorTickUnits(double distance, int* retDecimalPlaces);
67  int calcTickTextSize(double distance);
68  void forceTwoTicks();
69  void reCalc();
70 
71  double majorTickValue(int tick);
72  double minorTickValue(int tick);
73 
74 public:
75  ScaleEngine();
76 
77  void setOrientation(Qt::Orientation orientation);
78  void setFont(const QFont& font);
79  void setSize(float size);
80  float getSize() { return m_size; }
81  void setRange(Unit::Physical physicalUnit, float rangeMin, float rangeMax);
82  void setMakeOpposite(bool makeOpposite) { m_makeOpposite = makeOpposite; }
83  void setFixedDecimalPlaces(int decimalPlaces) { m_fixedDecimalPlaces =decimalPlaces; }
84 
85  float getPosFromValue(double value);
86  float getValueFromPos(double pos);
87  const TickList& getTickList();
88 
89  QString getRangeMinStr();
90  QString getRangeMaxStr();
91 
92  float getScaleWidth();
93 };
94 
95 #endif // INCLUDE_SCALEENGINE_H
float m_size
Definition: scaleengine.h:46
Qt::Orientation m_orientation
Definition: scaleengine.h:41
int m_fixedDecimalPlaces
Definition: scaleengine.h:60
QString m_unitStr
Definition: scaleengine.h:54
double m_scale
Definition: scaleengine.h:53
float m_rangeMax
Definition: scaleengine.h:49
bool m_makeOpposite
Definition: scaleengine.h:61
#define SDRGUI_API
Definition: export.h:52
double m_majorTickValueDistance
Definition: scaleengine.h:56
float getSize()
Definition: scaleengine.h:80
float m_charSize
Definition: scaleengine.h:43
void setFixedDecimalPlaces(int decimalPlaces)
Definition: scaleengine.h:83
int m_decimalPlaces
Definition: scaleengine.h:59
int m_numMinorTicks
Definition: scaleengine.h:58
double m_firstMajorTickValue
Definition: scaleengine.h:57
float m_rangeMin
Definition: scaleengine.h:48
QFont m_font
Definition: scaleengine.h:42
QList< Tick > TickList
Definition: scaleengine.h:37
Unit::Physical m_physicalUnit
Definition: scaleengine.h:47
void setMakeOpposite(bool makeOpposite)
Definition: scaleengine.h:82
TickList m_tickList
Definition: scaleengine.h:55
bool m_recalc
Definition: scaleengine.h:52