OpenCurves  0.9
plotbindingtracker.h
1 //
2 // author Kazys Stepanas
3 //
4 // Copyright (c) CSIRO 2015
5 //
6 #ifndef PLOTBINDINGTRACKER_H_
7 #define PLOTBINDINGTRACKER_H_
8 
9 #include "plotsconfig.h"
10 
11 #include <QHash>
12 
13 class PlotExpression;
14 class PlotInstance;
15 
35 {
36 public:
38  inline PlotBindingTracker() : _firstPlot(nullptr) {}
39 
42  inline PlotInstance *firstPlot() const { return _firstPlot; }
43 
46  inline void setFirstPlot(PlotInstance *plot) { _firstPlot = plot; }
47 
50  inline void setFirstPlotIf(PlotInstance *plot) { if (!_firstPlot) { _firstPlot = plot; } }
51 
53  inline void clearFirstPlot() { _firstPlot = nullptr; }
54 
58  void setMarker(const PlotExpression *expr, unsigned marker);
59 
64  bool markerFor(const PlotExpression *expr, unsigned &marker) const;
65 
69  bool contains(const PlotExpression *expr) const;
70 
74  void setHold(const PlotExpression *expr, bool hold = true);
75 
79  bool isHeld(const PlotExpression *expr) const;
80 
83  bool clear(const PlotExpression *expr);
84 
85 private:
86  PlotInstance *_firstPlot;
87  QHash<const PlotExpression *, unsigned> _markers;
88  QHash<const PlotExpression *, bool> _hold;
89 };
90 
91 #endif // PLOTBINDINGTRACKER_H_
bool isHeld(const PlotExpression *expr) const
Is expr being held?
bool markerFor(const PlotExpression *expr, unsigned &marker) const
Request the marker value for expr.
PlotInstance * firstPlot() const
Request the first bound PlotInstance in the tree.
Definition: plotbindingtracker.h:42
Supports multiple bindings of the same expression to different curves.
Definition: plotbindingtracker.h:34
void setFirstPlotIf(PlotInstance *plot)
Set the first bound PlotInstance so long as it is not already set.
Definition: plotbindingtracker.h:50
PlotBindingTracker()
Create an empty biding.
Definition: plotbindingtracker.h:38
Holds data for a single curve.
Definition: plotinstance.h:43
bool contains(const PlotExpression *expr) const
Checks if a marker is present for expr.
void setHold(const PlotExpression *expr, bool hold=true)
Set the flag indicating expr should not progress its marker.
void clearFirstPlot()
Clear firstPlot().
Definition: plotbindingtracker.h:53
void setFirstPlot(PlotInstance *plot)
Set the first bound PlotInstance in the tree.
Definition: plotbindingtracker.h:46
A PlotExpression represents an operation in a plot equation.
Definition: plotexpression.h:91
bool clear(const PlotExpression *expr)
Clear marker and hold flag for expr.
void setMarker(const PlotExpression *expr, unsigned marker)
Set the arbitrary marker value for expr.