From d56d0b96e8e6007e76aa6cda0cc3113538bb6daf Mon Sep 17 00:00:00 2001 From: jsiegle <jsiegle@mit.edu> Date: Wed, 19 Mar 2014 11:44:33 -0400 Subject: [PATCH] GraphViewer now displays the fraction of channels within each node that are set to record. Closes #135 --- Source/Processors/Editors/ChannelSelector.cpp | 3 +++ Source/Processors/Editors/GenericEditor.cpp | 15 ++++++++++++ Source/Processors/Editors/GenericEditor.h | 3 +++ Source/Processors/GenericProcessor.cpp | 2 +- Source/UI/GraphViewer.cpp | 24 ++++++++++++++++--- 5 files changed, 43 insertions(+), 4 deletions(-) diff --git a/Source/Processors/Editors/ChannelSelector.cpp b/Source/Processors/Editors/ChannelSelector.cpp index 0b4470e40..c052976e7 100755 --- a/Source/Processors/Editors/ChannelSelector.cpp +++ b/Source/Processors/Editors/ChannelSelector.cpp @@ -27,6 +27,7 @@ #include "../RecordNode.h" #include "../AudioNode.h" #include "../ProcessorGraph.h" +#include "../../UI/GraphViewer.h" ChannelSelector::ChannelSelector(bool createButtons, Font& titleFont_) : eventsOnly(false), paramsToggled(true), paramsActive(true), @@ -594,6 +595,8 @@ void ChannelSelector::buttonClicked(Button* button) ch->setRecordState(status); } + editor->getGraphViewer()->repaint(); + } else // parameter type { diff --git a/Source/Processors/Editors/GenericEditor.cpp b/Source/Processors/Editors/GenericEditor.cpp index 1e555b071..247f4a8e4 100755 --- a/Source/Processors/Editors/GenericEditor.cpp +++ b/Source/Processors/Editors/GenericEditor.cpp @@ -545,6 +545,21 @@ bool GenericEditor::getRecordStatus(int chan) } } +Array<bool> GenericEditor::getRecordStatusArray() +{ + + Array<bool> recordStatuses; + recordStatuses.resize(getProcessor()->getNumOutputs()); + + for (int i = 0; i < getProcessor()->getNumOutputs(); i++) + { + recordStatuses.set(i,channelSelector->getRecordStatus(i)); + } + + return recordStatuses; + +} + bool GenericEditor::getAudioStatus(int chan) { if (!isSplitOrMerge) diff --git a/Source/Processors/Editors/GenericEditor.h b/Source/Processors/Editors/GenericEditor.h index 9b1311075..c905758fb 100755 --- a/Source/Processors/Editors/GenericEditor.h +++ b/Source/Processors/Editors/GenericEditor.h @@ -287,6 +287,9 @@ public: /** Returns the editors a splitter or merger is connected to */ virtual Array<GenericEditor*> getConnectedEditors(){ Array<GenericEditor*> a; return a;} + + /** Returns an array of record statuses for all channels. Used by GraphNode */ + Array<bool> getRecordStatusArray(); protected: diff --git a/Source/Processors/GenericProcessor.cpp b/Source/Processors/GenericProcessor.cpp index 29ad5eb9f..4f6f14aa1 100755 --- a/Source/Processors/GenericProcessor.cpp +++ b/Source/Processors/GenericProcessor.cpp @@ -284,7 +284,7 @@ void GenericProcessor::clearSettings() for (int i = 0; i < channels.size(); i++) { - std::cout << channels[i]->getRecordState() << std::endl; + // std::cout << channels[i]->getRecordState() << std::endl; recordStatus.set(i,channels[i]->getRecordState()); } diff --git a/Source/UI/GraphViewer.cpp b/Source/UI/GraphViewer.cpp index edde3ac6e..fa89261f8 100644 --- a/Source/UI/GraphViewer.cpp +++ b/Source/UI/GraphViewer.cpp @@ -23,6 +23,8 @@ #include "GraphViewer.h" +#define PI 3.14159265359 + GraphViewer::GraphViewer() { @@ -433,16 +435,32 @@ void GraphNode::updateBoundaries() void GraphNode::paint(Graphics& g) { + Array<bool> recordStatuses = editor->getRecordStatusArray(); + + Path recordPath; + + for (int i = 0; i < recordStatuses.size(); i++) + { + float stepSize = 2*PI/recordStatuses.size(); + float startRadians = stepSize*i; + float endRadians = startRadians + stepSize; + if (recordStatuses[i]) + recordPath.addPieSegment(0,0,20,20,startRadians,endRadians,0.5); + } + + g.setColour(Colours::red); + g.fillPath(recordPath); + if (mouseOver) { g.setColour(Colours::yellow); - g.fillEllipse(0,0,20,20); + g.fillEllipse(2,2,16,16); } else { g.setColour(Colours::lightgrey); - g.fillEllipse(1,1,18,18); + g.fillEllipse(2,2,16,16); } - + g.drawText(getName(), 25, 0, getWidth()-25, 20, Justification::left, true); } \ No newline at end of file -- GitLab