Commit 43c2b837 authored by twanvl's avatar twanvl

fixed vector subscript out of range error in the Graph control: stacked bar...

fixed vector subscript out of range error in the Graph control: stacked bar charts ::findItem used incorrect bound
parent 98552d7b
This diff is collapsed.
...@@ -143,7 +143,7 @@ class Graph : public IntrusivePtrVirtualBase { ...@@ -143,7 +143,7 @@ class Graph : public IntrusivePtrVirtualBase {
/// Draw this graph, filling the internalRect() of the dc. /// Draw this graph, filling the internalRect() of the dc.
virtual void draw(RotatedDC& dc, const vector<int>& current, DrawLayer layer) const = 0; virtual void draw(RotatedDC& dc, const vector<int>& current, DrawLayer layer) const = 0;
/// Find the item at the given position, the rectangle gives the screen size /// Find the item at the given position, the rectangle gives the screen size
virtual bool findItem(const RealPoint& pos, const RealRect& rect, bool tight, vector<int>& out) const { return false; } virtual bool findItem(const RealPoint& pos, const RealRect& screen_rect, bool tight, vector<int>& out) const { return false; }
/// Change the data /// Change the data
virtual void setData(const GraphDataP& d) { data = d; } virtual void setData(const GraphDataP& d) { data = d; }
/// Get the data /// Get the data
...@@ -159,12 +159,12 @@ class Graph1D : public Graph { ...@@ -159,12 +159,12 @@ class Graph1D : public Graph {
public: public:
inline Graph1D(size_t axis) : axis(axis) {} inline Graph1D(size_t axis) : axis(axis) {}
virtual void draw(RotatedDC& dc, const vector<int>& current, DrawLayer layer) const; virtual void draw(RotatedDC& dc, const vector<int>& current, DrawLayer layer) const;
virtual bool findItem(const RealPoint& pos, const RealRect& rect, bool tight, vector<int>& out) const; virtual bool findItem(const RealPoint& pos, const RealRect& screen_rect, bool tight, vector<int>& out) const;
virtual void setData(const GraphDataP& d); virtual void setData(const GraphDataP& d);
protected: protected:
size_t axis; size_t axis;
/// Find an item, return the position along the axis, or -1 if not found /// Find an item, return the position along the axis, or -1 if not found
virtual int findItem(const RealPoint& pos, const RealRect& rect, bool tight) const { return -1; } virtual int findItem(const RealPoint& pos, const RealRect& screen_rect, bool tight) const { return -1; }
virtual void draw(RotatedDC& dc, int current, DrawLayer layer) const = 0; virtual void draw(RotatedDC& dc, int current, DrawLayer layer) const = 0;
inline GraphAxis& axis_data() const { return *data->axes.at(axis); } inline GraphAxis& axis_data() const { return *data->axes.at(axis); }
}; };
...@@ -186,7 +186,7 @@ class BarGraph : public Graph1D { ...@@ -186,7 +186,7 @@ class BarGraph : public Graph1D {
public: public:
inline BarGraph(size_t axis) : Graph1D(axis) {} inline BarGraph(size_t axis) : Graph1D(axis) {}
virtual void draw(RotatedDC& dc, int current, DrawLayer layer) const; virtual void draw(RotatedDC& dc, int current, DrawLayer layer) const;
virtual int findItem(const RealPoint& pos, const RealRect& rect, bool tight) const; virtual int findItem(const RealPoint& pos, const RealRect& screen_rect, bool tight) const;
}; };
// A bar graph with stacked bars // A bar graph with stacked bars
...@@ -194,7 +194,7 @@ class BarGraph2D : public Graph2D { ...@@ -194,7 +194,7 @@ class BarGraph2D : public Graph2D {
public: public:
inline BarGraph2D(size_t axis_h, size_t axis_v) : Graph2D(axis_h, axis_v) {} inline BarGraph2D(size_t axis_h, size_t axis_v) : Graph2D(axis_h, axis_v) {}
virtual void draw(RotatedDC& dc, const vector<int>& current, DrawLayer layer) const; virtual void draw(RotatedDC& dc, const vector<int>& current, DrawLayer layer) const;
virtual bool findItem(const RealPoint& pos, const RealRect& rect, bool tight, vector<int>& out) const; virtual bool findItem(const RealPoint& pos, const RealRect& screen_rect, bool tight, vector<int>& out) const;
}; };
/// A pie graph /// A pie graph
...@@ -202,7 +202,7 @@ class PieGraph : public Graph1D { ...@@ -202,7 +202,7 @@ class PieGraph : public Graph1D {
public: public:
inline PieGraph(size_t axis) : Graph1D(axis) {} inline PieGraph(size_t axis) : Graph1D(axis) {}
virtual void draw(RotatedDC& dc, int current, DrawLayer layer) const; virtual void draw(RotatedDC& dc, int current, DrawLayer layer) const;
virtual int findItem(const RealPoint& pos, const RealRect& rect, bool tight) const; virtual int findItem(const RealPoint& pos, const RealRect& screen_rect, bool tight) const;
}; };
/// A scatter plot /// A scatter plot
...@@ -210,7 +210,7 @@ class ScatterGraph : public Graph2D { ...@@ -210,7 +210,7 @@ class ScatterGraph : public Graph2D {
public: public:
inline ScatterGraph(size_t axis1, size_t axis2) : Graph2D(axis1, axis2) {} inline ScatterGraph(size_t axis1, size_t axis2) : Graph2D(axis1, axis2) {}
virtual void draw(RotatedDC& dc, const vector<int>& current, DrawLayer layer) const; virtual void draw(RotatedDC& dc, const vector<int>& current, DrawLayer layer) const;
virtual bool findItem(const RealPoint& pos, const RealRect& rect, bool tight, vector<int>& out) const; virtual bool findItem(const RealPoint& pos, const RealRect& screen_rect, bool tight, vector<int>& out) const;
virtual void setData(const GraphDataP& d); virtual void setData(const GraphDataP& d);
protected: protected:
UInt max_value; UInt max_value;
...@@ -244,7 +244,7 @@ class GraphLegend : public Graph1D { ...@@ -244,7 +244,7 @@ class GraphLegend : public Graph1D {
{} {}
virtual RealSize determineSize(RotatedDC& dc) const; virtual RealSize determineSize(RotatedDC& dc) const;
virtual void draw(RotatedDC& dc, int current, DrawLayer layer) const; virtual void draw(RotatedDC& dc, int current, DrawLayer layer) const;
virtual int findItem(const RealPoint& pos, const RealRect& rect, bool tight) const; virtual int findItem(const RealPoint& pos, const RealRect& screen_rect, bool tight) const;
private: private:
mutable RealSize size, item_size; mutable RealSize size, item_size;
Alignment alignment; Alignment alignment;
...@@ -283,7 +283,7 @@ class GraphLabelAxis : public Graph1D { ...@@ -283,7 +283,7 @@ class GraphLabelAxis : public Graph1D {
: Graph1D(axis), direction(direction), rotate(rotate), draw_lines(draw_lines), label(label) : Graph1D(axis), direction(direction), rotate(rotate), draw_lines(draw_lines), label(label)
{} {}
virtual void draw(RotatedDC& dc, int current, DrawLayer layer) const; virtual void draw(RotatedDC& dc, int current, DrawLayer layer) const;
virtual int findItem(const RealPoint& pos, const RealRect& rect, bool tight) const; virtual int findItem(const RealPoint& pos, const RealRect& screen_rect, bool tight) const;
private: private:
Direction direction; Direction direction;
int levels; int levels;
...@@ -312,7 +312,7 @@ class GraphWithMargins : public Graph { ...@@ -312,7 +312,7 @@ class GraphWithMargins : public Graph {
, upside_down(upside_down) , upside_down(upside_down)
{} {}
virtual void draw(RotatedDC& dc, const vector<int>& current, DrawLayer layer) const; virtual void draw(RotatedDC& dc, const vector<int>& current, DrawLayer layer) const;
virtual bool findItem(const RealPoint& pos, const RealRect& rect, bool tight, vector<int>& out) const; virtual bool findItem(const RealPoint& pos, const RealRect& screen_rect, bool tight, vector<int>& out) const;
virtual void setData(const GraphDataP& d); virtual void setData(const GraphDataP& d);
private: private:
const GraphP graph; const GraphP graph;
...@@ -324,7 +324,7 @@ class GraphWithMargins : public Graph { ...@@ -324,7 +324,7 @@ class GraphWithMargins : public Graph {
class GraphContainer : public Graph { class GraphContainer : public Graph {
public: public:
virtual void draw(RotatedDC& dc, const vector<int>& current, DrawLayer layer) const; virtual void draw(RotatedDC& dc, const vector<int>& current, DrawLayer layer) const;
virtual bool findItem(const RealPoint& pos, const RealRect& rect, bool tight, vector<int>& out) const; virtual bool findItem(const RealPoint& pos, const RealRect& screen_rect, bool tight, vector<int>& out) const;
virtual void setData(const GraphDataP& d); virtual void setData(const GraphDataP& d);
void add(const GraphP& graph); void add(const GraphP& graph);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment