Skip to content

Commit f422bbc

Browse files
authored
Merge pull request #661 from joschaschmiedt/main
Allow overriding of InteractivePlot elements
2 parents cd27fa7 + dc03409 commit f422bbc

File tree

1 file changed

+21
-20
lines changed

1 file changed

+21
-20
lines changed

Source/Processors/Visualization/InteractivePlot.h

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ class XYLine
7474
public:
7575
/** Creates a line from vectors of x and y values */
7676
XYLine (std::vector<float> x, std::vector<float> y);
77+
virtual ~XYLine() = default;
7778

7879
/** Sets the colour of the line*/
7980
void setColour (Colour c);
@@ -92,15 +93,15 @@ class XYLine
9293

9394
/** Renders the line. Stretches Y such that ymin->0 and ymax->plotHeight
9495
and only display points between [xmin and xmax] */
95-
void draw (Graphics& g, XYRange& range, int width, int height);
96+
virtual void draw (Graphics& g, XYRange& range, int width, int height);
9697

9798
/** The x values */
9899
std::vector<float> x;
99100

100101
/** The x values */
101102
std::vector<float> y;
102103

103-
private:
104+
protected:
104105
/** The parameters of this line */
105106
Colour colour;
106107
float width;
@@ -121,7 +122,7 @@ class Axis : public Component
121122
Axis();
122123

123124
/** Destructor */
124-
~Axis() {}
125+
~Axis() override {}
125126

126127
/** Sets the min / max range, and number of ticks between them */
127128
void setRange (float minvalue, float maxvalue, int numTicks = 10);
@@ -179,7 +180,7 @@ class XAxis : public Axis
179180
XAxis() {}
180181

181182
/** Renders the axis */
182-
void paint (Graphics& g);
183+
void paint (Graphics& g) override;
183184
};
184185

185186
/**
@@ -194,7 +195,7 @@ class YAxis : public Axis
194195
YAxis() {}
195196

196197
/** Renders the axis */
197-
void paint (Graphics& g);
198+
void paint (Graphics& g) override;
198199
};
199200

200201
/**
@@ -210,7 +211,7 @@ class PLUGIN_API DrawComponent : public Component
210211
DrawComponent (Axis* x, Axis* y);
211212

212213
/** Destructor */
213-
~DrawComponent() {}
214+
~DrawComponent() override {}
214215

215216
/** Adds a line to be drawn */
216217
void add (XYLine* line);
@@ -250,9 +251,9 @@ class PLUGIN_API DrawComponent : public Component
250251
OwnedArray<XYLine> lines;
251252

252253
/** Mouse listeners */
253-
void mouseDown (const juce::MouseEvent& event);
254-
void mouseDrag (const juce::MouseEvent& event);
255-
void mouseWheelMove (const MouseEvent& event, const MouseWheelDetails& wheel);
254+
void mouseDown (const juce::MouseEvent& event) override;
255+
void mouseDrag (const juce::MouseEvent& event) override;
256+
void mouseWheelMove (const MouseEvent& event, const MouseWheelDetails& wheel) override;
256257

257258
//std::vector<float> computeSamplePositions(int subsample);
258259
std::list<XYRange> rangeMemory;
@@ -263,7 +264,7 @@ class PLUGIN_API DrawComponent : public Component
263264

264265
void drawGrid (Graphics& g);
265266

266-
void paint (Graphics& g);
267+
void paint (Graphics& g) override;
267268

268269
XYRange range, limit, originalRange;
269270

@@ -292,15 +293,15 @@ class PLUGIN_API InteractivePlot : public Component,
292293
InteractivePlot();
293294

294295
/** Destructor */
295-
~InteractivePlot() {}
296+
~InteractivePlot() override {}
296297

297298
/** Adds a line based on X and Y values */
298-
void plot (std::vector<float> x,
299-
std::vector<float> y,
300-
Colour c = Colours::white,
301-
float width = 1.0f,
302-
float opacity = 1.0f,
303-
PlotType type = PlotType::LINE);
299+
virtual void plot (std::vector<float> x,
300+
std::vector<float> y,
301+
Colour c = Colours::white,
302+
float width = 1.0f,
303+
float opacity = 1.0f,
304+
PlotType type = PlotType::LINE);
304305

305306
/** Clears all lines from the plot */
306307
void clear();
@@ -345,11 +346,11 @@ class PLUGIN_API InteractivePlot : public Component,
345346
void getRange (XYRange& range);
346347

347348
/** Called when size of plot is changed */
348-
void resized();
349+
void resized() override;
349350

350-
private:
351+
protected:
351352
/** Respond to button clicks */
352-
void buttonClicked (Button* btn);
353+
void buttonClicked (Button* btn) override;
353354

354355
FontOptions font;
355356
juce::Colour backgroundColour;

0 commit comments

Comments
 (0)