Skip to content

Allow overriding of InteractivePlot elements #661

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 23, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 21 additions & 20 deletions Source/Processors/Visualization/InteractivePlot.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class XYLine
public:
/** Creates a line from vectors of x and y values */
XYLine (std::vector<float> x, std::vector<float> y);
virtual ~XYLine() = default;

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

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

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

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

private:
protected:
/** The parameters of this line */
Colour colour;
float width;
Expand All @@ -121,7 +122,7 @@ class Axis : public Component
Axis();

/** Destructor */
~Axis() {}
~Axis() override {}

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

/** Renders the axis */
void paint (Graphics& g);
void paint (Graphics& g) override;
};

/**
Expand All @@ -194,7 +195,7 @@ class YAxis : public Axis
YAxis() {}

/** Renders the axis */
void paint (Graphics& g);
void paint (Graphics& g) override;
};

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

/** Destructor */
~DrawComponent() {}
~DrawComponent() override {}

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

/** Mouse listeners */
void mouseDown (const juce::MouseEvent& event);
void mouseDrag (const juce::MouseEvent& event);
void mouseWheelMove (const MouseEvent& event, const MouseWheelDetails& wheel);
void mouseDown (const juce::MouseEvent& event) override;
void mouseDrag (const juce::MouseEvent& event) override;
void mouseWheelMove (const MouseEvent& event, const MouseWheelDetails& wheel) override;

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

void drawGrid (Graphics& g);

void paint (Graphics& g);
void paint (Graphics& g) override;

XYRange range, limit, originalRange;

Expand Down Expand Up @@ -292,15 +293,15 @@ class PLUGIN_API InteractivePlot : public Component,
InteractivePlot();

/** Destructor */
~InteractivePlot() {}
~InteractivePlot() override {}

/** Adds a line based on X and Y values */
void plot (std::vector<float> x,
std::vector<float> y,
Colour c = Colours::white,
float width = 1.0f,
float opacity = 1.0f,
PlotType type = PlotType::LINE);
virtual void plot (std::vector<float> x,
std::vector<float> y,
Colour c = Colours::white,
float width = 1.0f,
float opacity = 1.0f,
PlotType type = PlotType::LINE);

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

/** Called when size of plot is changed */
void resized();
void resized() override;

private:
protected:
/** Respond to button clicks */
void buttonClicked (Button* btn);
void buttonClicked (Button* btn) override;

FontOptions font;
juce::Colour backgroundColour;
Expand Down