OpenCurves  0.9
plotsource.h
1 //
2 // author Kazys Stepanas
3 //
4 // Copyright (c) CSIRO 2015
5 //
6 #ifndef PLOTSOURCE_H_
7 #define PLOTSOURCE_H_
8 
9 #include "plotsconfig.h"
10 
11 #include "refcountobject.h"
12 #include "refcountptr.h"
13 
14 #include <QString>
15 #include <QVector>
16 
17 class PlotInstance;
18 class QMutex;
19 
28 class PlotSource : public plotutil::RefCountObject<PlotSource>
29 {
33 
34 public:
37 
41  enum Type
42  {
52 
54  User = 64
55  };
56 
67  PlotSource(int sourceType, const QString &fullName, unsigned curveCount = 0);
68 
70  ~PlotSource();
71 
74  inline unsigned type() const { return _type; }
75 
78  inline QString name() const { return _name; }
79 
82  inline void setName(QString name) { _name = name; }
83 
86  inline QString fullName() const { return _fullName; }
87 
93  inline void setFullName(QString name) { _fullName = name; }
94 
99  inline unsigned timeColumn() const { return _timeColumn; }
100 
103  void setTimeColumn(unsigned index) { _timeColumn = index; }
104 
107  inline double timeScale() const { return _timeScale; }
108 
111  inline void setTimeScale(double scale) { _timeScale = scale; }
112 
115  inline double timeBase() const { return _timeBase; }
118  inline void setTimeBase(double time) { _timeBase = time; }
119 
122  double firstTime() const;
123 
125  unsigned curveCount() const;
126 
130  PlotInstance *curve(unsigned index) const;
131 
134  PlotInstance *timeColumnCurve() const;
135 
138  void addCurve(PlotInstance *curve);
139 
142  void removeCurve(const PlotInstance *curve);
143 
149  void deriveName();
150 
174  bool lengthenName();
175 
176 private:
177  QString _name;
178  QString _fullName;
179  int _type;
180  unsigned _timeColumn;
181  double _timeScale;
182  double _timeBase;
183  QMutex *_curvesMutex;
184  QVector<PlotInstance *> _curves;
185 };
186 
187 #endif // PLOTSOURCE_H_
No source: invalid.
Definition: plotsource.h:44
bool lengthenName()
Lengthen the short name() to attempt to disambiguate.
QString fullName() const
Access the full source name.
Definition: plotsource.h:86
Loaded from a file.
Definition: plotsource.h:46
unsigned type() const
Identify the source type.
Definition: plotsource.h:74
void setName(QString name)
Set the short name.
Definition: plotsource.h:82
void addCurve(PlotInstance *curve)
Add a curve to this source.
double timeBase() const
Returns the time base for the source.
Definition: plotsource.h:115
~PlotSource()
Simple destructor.
User type values should start here.
Definition: plotsource.h:54
void deriveName()
Set the name() based on the current fullName().
A generated expression with no other source.
Definition: plotsource.h:49
void removeCurve(const PlotInstance *curve)
Remove a curve to this source.
void setTimeScale(double scale)
Returns the time scaling applied to curves using this source.
Definition: plotsource.h:111
void setFullName(QString name)
Set the full source name (e.g., file name).
Definition: plotsource.h:93
A real time plot over a serial, TCP or UDP connection.
Definition: plotsource.h:51
unsigned curveCount() const
Returns the number of curves associated with the source.
Holds data for a single curve.
Definition: plotinstance.h:43
PlotSource(int sourceType, const QString &fullName, unsigned curveCount=0)
Create a PlotSource of the given type and full name.
A base class for adding reference counting to a class.
Definition: refcountobject.h:30
unsigned timeColumn() const
Returns the index of the curve used to generate timestamps for all other columns. ...
Definition: plotsource.h:99
double firstTime() const
Request the first time value from the time column.
QString name() const
Access the short name.
Definition: plotsource.h:78
void setTimeBase(double time)
Sets the time base for the source.
Definition: plotsource.h:118
Provides details about a source from which PlotInstance objects have been generated.
Definition: plotsource.h:28
double timeScale() const
Returns the time scaling applied to curves using this source.
Definition: plotsource.h:107
void setTimeColumn(unsigned index)
Set the 1-based time column index or zero for none.
Definition: plotsource.h:103
PlotInstance * timeColumnCurve() const
Returns the time column curve (if any).
Type
Defines where the plot was loaded from.
Definition: plotsource.h:41
PlotInstance * curve(unsigned index) const
Request a curve at the given index.
plotutil::RefCountPtr< PlotSource > Ptr
Reference counted pointer reference.
Definition: plotsource.h:36