Skip to content
Snippets Groups Projects
Commit ddb0bfbf authored by jsiegle's avatar jsiegle
Browse files

Update ChannelMappingNode from spikesorting version

parent 810680f7
No related branches found
No related tags found
No related merge requests found
...@@ -64,17 +64,34 @@ AudioProcessorEditor* ChannelMappingNode::createEditor() ...@@ -64,17 +64,34 @@ AudioProcessorEditor* ChannelMappingNode::createEditor()
void ChannelMappingNode::updateSettings() void ChannelMappingNode::updateSettings()
{ {
int j;
if (getNumInputs() > 0) if (getNumInputs() > 0)
channelBuffer.setSize(getNumInputs(), 10000); channelBuffer.setSize(getNumInputs(), 10000);
if (getNumInputs() != previousChannelCount) if (getNumInputs() != previousChannelCount)
{ {
previousChannelCount = getNumInputs(); previousChannelCount = getNumInputs();
if (editorIsConfigured)
{
j = 0;
for (int i = 0; i < getNumInputs(); i++)
{
if (enabledChannelArray[i])
{
j++;
}
else
{
channels.remove(j);
}
}
settings.numOutputs = j;
}
} }
else else
{ {
int j=0; j = 0;
for (int i=0; i < getNumInputs(); i++) for (int i = 0; i < getNumInputs(); i++)
{ {
if (enabledChannelArray[i]) if (enabledChannelArray[i])
{ {
...@@ -106,6 +123,10 @@ void ChannelMappingNode::setParameter(int parameterIndex, float newValue) ...@@ -106,6 +123,10 @@ void ChannelMappingNode::setParameter(int parameterIndex, float newValue)
{ {
enabledChannelArray.set(currentChannel, (newValue != 0) ? true : false); enabledChannelArray.set(currentChannel, (newValue != 0) ? true : false);
} }
else if (parameterIndex == 4)
{
editorIsConfigured = (newValue != 0) ? true : false;
}
else else
{ {
channelArray.set(currentChannel, (int) newValue); channelArray.set(currentChannel, (int) newValue);
...@@ -118,40 +139,33 @@ void ChannelMappingNode::process(AudioSampleBuffer& buffer, ...@@ -118,40 +139,33 @@ void ChannelMappingNode::process(AudioSampleBuffer& buffer,
int& nSamples) int& nSamples)
{ {
int j=0; int j=0;
int i=0;
int realChan;
// use copy constructor to set the data to refer to // use copy constructor to set the data to refer to
channelBuffer = buffer; channelBuffer = buffer;
// copy it back into the buffer according to the channel mapping
buffer.clear(); buffer.clear();
for (int i = 0; i < buffer.getNumChannels(); i++) while (j < settings.numOutputs)
{ {
if (enabledChannelArray[channelArray[i]]) realChan = channelArray[i];
if ((realChan < channelBuffer.getNumChannels()) && (enabledChannelArray[realChan]))
{ {
// copy it back into the buffer according to the channel mapping
buffer.addFrom(j, // destChannel buffer.addFrom(j, // destChannel
0, // destStartSample 0, // destStartSample
channelBuffer, // source channelBuffer, // source
channelArray[i], // sourceChannel realChan, // sourceChannel
0, // sourceStartSample 0, // sourceStartSample
nSamples, // numSamples nSamples, // numSamples
1.0f // gain to apply to source (positive for original signal) 1.0f // gain to apply to source (positive for original signal)
); );
j++;
}
}
j=0; // now do the referencing
// now do the referencing if ((referenceArray[realChan] > -1) && (referenceChannels[referenceArray[realChan]] > -1)
for (int i = 0; i < buffer.getNumChannels(); i++) && (referenceChannels[referenceArray[realChan]] < channelBuffer.getNumChannels()))
{
int realChan = channelArray[i];
if (enabledChannelArray[realChan])
{
if ((referenceArray[realChan] > -1) && referenceChannels[referenceArray[realChan]] > -1)
{ {
buffer.addFrom(j, // destChannel buffer.addFrom(j, // destChannel
0, // destStartSample 0, // destStartSample
channelBuffer, // source channelBuffer, // source
...@@ -163,6 +177,8 @@ void ChannelMappingNode::process(AudioSampleBuffer& buffer, ...@@ -163,6 +177,8 @@ void ChannelMappingNode::process(AudioSampleBuffer& buffer,
} }
j++; j++;
} }
i++;
} }
} }
......
...@@ -70,6 +70,7 @@ private: ...@@ -70,6 +70,7 @@ private:
Array<bool> enabledChannelArray; Array<bool> enabledChannelArray;
int previousChannelCount; int previousChannelCount;
bool editorIsConfigured;
AudioSampleBuffer channelBuffer; AudioSampleBuffer channelBuffer;
......
...@@ -30,24 +30,34 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. ...@@ -30,24 +30,34 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
ChannelMappingEditor::ChannelMappingEditor(GenericProcessor* parentNode, bool useDefaultParameterEditors=true) ChannelMappingEditor::ChannelMappingEditor(GenericProcessor* parentNode, bool useDefaultParameterEditors=true)
: GenericEditor(parentNode, useDefaultParameterEditors), previousChannelCount(0) : GenericEditor(parentNode, useDefaultParameterEditors), previousChannelCount(0), isConfigured(false)
{ {
desiredWidth = 340; desiredWidth = 340;
scrollDistance = 0;
selectAllButton = new ElectrodeEditorButton("Select All",Font("Small Text",14,Font::plain)); selectAllButton = new ElectrodeEditorButton("Select All",Font("Small Text",14,Font::plain));
selectAllButton->addListener(this); selectAllButton->addListener(this);
addAndMakeVisible(selectAllButton); addAndMakeVisible(selectAllButton);
selectAllButton->setBounds(140,110,110,10); selectAllButton->setBounds(125,110,110,10);
selectAllButton->setToggleState(false, false); selectAllButton->setToggleState(false, false);
modifyButton = new ElectrodeEditorButton("Remap",Font("Small Text",14,Font::plain)); modifyButton = new ElectrodeEditorButton("Remap",Font("Small Text",14,Font::plain));
modifyButton->addListener(this); modifyButton->addListener(this);
addAndMakeVisible(modifyButton); addAndMakeVisible(modifyButton);
modifyButton->setBounds(250,110,60,10); modifyButton->setBounds(220,110,60,10);
modifyButton->setToggleState(false, false); modifyButton->setToggleState(false, false);
modifyButton->setClickingTogglesState(true); modifyButton->setClickingTogglesState(true);
resetButton = new ElectrodeEditorButton("Reset", Font("Small Text",14,Font::plain));
resetButton->addListener(this);
addAndMakeVisible(resetButton);
resetButton->setBounds(285,110,60,10);
resetButton->setToggleState(true,false);
resetButton->setClickingTogglesState(false);
resetButton->setEnabled(false);
// channelSelector->setRadioStatus(true); // channelSelector->setRadioStatus(true);
for (int i = 0 ; i < NUM_REFERENCES; i++) for (int i = 0 ; i < NUM_REFERENCES; i++)
...@@ -77,46 +87,80 @@ ChannelMappingEditor::~ChannelMappingEditor() ...@@ -77,46 +87,80 @@ ChannelMappingEditor::~ChannelMappingEditor()
void ChannelMappingEditor::updateSettings() void ChannelMappingEditor::updateSettings()
{ {
if (isConfigured)
{
if (getProcessor()->getNumInputs() > previousChannelCount)
{
createElectrodeButtons(getProcessor()->getNumInputs(),false);
previousChannelCount = getProcessor()->getNumInputs();
}
else if (!reorderActive)
{
checkUnusedChannels();
}
if (getProcessor()->getNumInputs() != previousChannelCount) } else if (getProcessor()->getNumInputs() != previousChannelCount)
{ {
createElectrodeButtons(getProcessor()->getNumInputs()); createElectrodeButtons(getProcessor()->getNumInputs());
previousChannelCount = getProcessor()->getNumInputs(); previousChannelCount = getProcessor()->getNumInputs();
} }
} }
void ChannelMappingEditor::createElectrodeButtons(int numNeeded) void ChannelMappingEditor::createElectrodeButtons(int numNeeded, bool clearPrevious)
{ {
int startButton;
electrodeButtons.clear(); if (clearPrevious)
{
referenceArray.clear(); electrodeButtons.clear();
channelArray.clear();
referenceChannels.clear();
enabledChannelArray.clear();
int width = 20; referenceArray.clear();
int height = 15; channelArray.clear();
referenceChannels.clear();
enabledChannelArray.clear();
startButton=0;
previousClickedChan = -1;
previousShiftClickedChan = -1;
referenceButtons[0]->setToggleState(true,false);
selectedReference = 0;
modifyButton->setToggleState(false,false);
reorderActive = false;
channelSelector->activateButtons();
int row = 0; }
int column = 0; else
{
startButton = previousChannelCount;
if (startButton > numNeeded) return;
//row = startButton/16;
//column = startButton % 16;
}
for (int i = 0; i < numNeeded; i++) for (int i = startButton; i < numNeeded; i++)
{ {
ElectrodeButton* button = new ElectrodeButton(i+1); ElectrodeButton* button = new ElectrodeButton(i+1);
electrodeButtons.add(button); electrodeButtons.add(button);
button->setBounds(10+(column++)*(width), 30+row*(height), width, 15);
button->setToggleState(false,false);
button->setRadioGroupId(0); button->setRadioGroupId(0);
// if (!getCollapsedState())
// addAndMakeVisible(button);
// else
addChildComponent(button); // determine visibility in refreshButtonLocations()
addAndMakeVisible(button);
button->addListener(this); button->addListener(this);
if (reorderActive)
{
button->setToggleState(true,false);
electrodeButtons[i]->setClickingTogglesState(false);
electrodeButtons[i]->addMouseListener(this,false);
}
else
{
button->setToggleState(false,false);
electrodeButtons[i]->setClickingTogglesState(true);
}
referenceArray.add(-1); referenceArray.add(-1);
getProcessor()->setCurrentChannel(i); getProcessor()->setCurrentChannel(i);
...@@ -127,33 +171,55 @@ void ChannelMappingEditor::createElectrodeButtons(int numNeeded) ...@@ -127,33 +171,55 @@ void ChannelMappingEditor::createElectrodeButtons(int numNeeded)
channelArray.add(i+1); channelArray.add(i+1);
enabledChannelArray.add(true); enabledChannelArray.add(true);
if (column % 16 == 0)
{
column = 0;
row++;
}
} }
getProcessor()->setCurrentChannel(-1);
for (int i = 0; i < NUM_REFERENCES; i++) if (clearPrevious)
{ {
getProcessor()->setCurrentChannel(-1);
for (int i = 0; i < NUM_REFERENCES; i++)
{
getProcessor()->setParameter(2,i); //Clear reference getProcessor()->setParameter(2,i); //Clear reference
referenceChannels.add(-1); referenceChannels.add(-1);
referenceButtons[i]->setEnabled(true);
}
} }
channelSelector->setRadioStatus(true);
referenceButtons[0]->setToggleState(true,false); refreshButtonLocations();
selectedReference = 0; }
modifyButton->setToggleState(false,false); void ChannelMappingEditor::refreshButtonLocations()
reorderActive = false; {
previousClickedChan = -1; int width = 19;
previousShiftClickedChan = -1; int height = 15;
int row = (int) -scrollDistance;
int column = 0;
for (int i = 0; i < electrodeButtons.size(); i++)
{
channelSelector->setRadioStatus(true); ElectrodeButton* button = electrodeButtons[i];
button->setBounds(10+(column++)*(width), 30+row*(height), width, 15);
if (row <= 4 && row >= 0 && !getCollapsedState())
button->setVisible(true);
else
button->setVisible(false);
if (column % 16 == 0)
{
column = 0;
row++;
}
}
} }
void ChannelMappingEditor::collapsedStateChanged()
{
refreshButtonLocations();
}
void ChannelMappingEditor::buttonEvent(Button* button) void ChannelMappingEditor::buttonEvent(Button* button)
{ {
...@@ -166,6 +232,14 @@ void ChannelMappingEditor::buttonEvent(Button* button) ...@@ -166,6 +232,14 @@ void ChannelMappingEditor::buttonEvent(Button* button)
setChannelReference(electrodeButtons[i]); setChannelReference(electrodeButtons[i]);
} }
previousClickedChan = -1; previousClickedChan = -1;
setConfigured(true);
}
else if (button == resetButton)
{
createElectrodeButtons(getProcessor()->getNumInputs());
previousChannelCount = getProcessor()->getNumInputs();
setConfigured(false);
getEditorViewport()->makeEditorVisible(this, false, true);
} }
else if (button == modifyButton) else if (button == modifyButton)
{ {
...@@ -174,7 +248,7 @@ void ChannelMappingEditor::buttonEvent(Button* button) ...@@ -174,7 +248,7 @@ void ChannelMappingEditor::buttonEvent(Button* button)
channelSelector->activateButtons(); channelSelector->activateButtons();
reorderActive = false; reorderActive = false;
selectedReference = 0; selectedReference = 0;
for (int i=0; i < referenceButtons.size(); i++) for (int i = 0; i < referenceButtons.size(); i++)
{ {
referenceButtons[i]->setEnabled(true); referenceButtons[i]->setEnabled(true);
} }
...@@ -199,7 +273,7 @@ void ChannelMappingEditor::buttonEvent(Button* button) ...@@ -199,7 +273,7 @@ void ChannelMappingEditor::buttonEvent(Button* button)
{ {
electrodeButtons[i]->setToggleState(false,false); electrodeButtons[i]->setToggleState(false,false);
} }
if (enabledChannelArray[electrodeButtons[i]->getChannelNum()-1]) if ((enabledChannelArray[electrodeButtons[i]->getChannelNum()-1]) && (electrodeButtons[i]->getChannelNum() <= getProcessor()->getNumInputs()))
{ {
electrodeButtons[i]->setEnabled(true); electrodeButtons[i]->setEnabled(true);
} }
...@@ -234,7 +308,7 @@ void ChannelMappingEditor::buttonEvent(Button* button) ...@@ -234,7 +308,7 @@ void ChannelMappingEditor::buttonEvent(Button* button)
electrodeButtons[i]->setToggleState(false,false); electrodeButtons[i]->setToggleState(false,false);
} }
electrodeButtons[i]->addMouseListener(this,false); electrodeButtons[i]->addMouseListener(this,false);
} }
selectAllButton->setEnabled(false); selectAllButton->setEnabled(false);
} }
...@@ -245,7 +319,8 @@ void ChannelMappingEditor::buttonEvent(Button* button) ...@@ -245,7 +319,8 @@ void ChannelMappingEditor::buttonEvent(Button* button)
Array<int> a; Array<int> a;
if (referenceChannels[selectedReference] >= 0 ) if ((referenceChannels[selectedReference] >= 0 )
&& (referenceChannels[selectedReference] < channelSelector->getNumChannels() ))
{ {
a.add(referenceChannels[selectedReference]); a.add(referenceChannels[selectedReference]);
} }
...@@ -269,6 +344,7 @@ void ChannelMappingEditor::buttonEvent(Button* button) ...@@ -269,6 +344,7 @@ void ChannelMappingEditor::buttonEvent(Button* button)
{ {
if (!reorderActive) if (!reorderActive)
{ {
setConfigured(true);
int clickedChan = electrodeButtons.indexOf((ElectrodeButton*)button); int clickedChan = electrodeButtons.indexOf((ElectrodeButton*)button);
if (ModifierKeys::getCurrentModifiers().isShiftDown() && (previousClickedChan >= 0)) if (ModifierKeys::getCurrentModifiers().isShiftDown() && (previousClickedChan >= 0))
...@@ -419,16 +495,21 @@ void ChannelMappingEditor::channelChanged(int chan) ...@@ -419,16 +495,21 @@ void ChannelMappingEditor::channelChanged(int chan)
{ {
if (!reorderActive) if (!reorderActive)
{ {
setConfigured(true);
getProcessor()->setCurrentChannel(chan-1); getProcessor()->setCurrentChannel(chan-1);
getProcessor()->setParameter(2,selectedReference); getProcessor()->setParameter(2,selectedReference);
referenceChannels.set(selectedReference,chan-1); referenceChannels.set(selectedReference,chan-1);
} }
} }
void ChannelMappingEditor::saveEditorParameters(XmlElement* xml) void ChannelMappingEditor::saveCustomParameters(XmlElement* xml)
{ {
xml->setAttribute("Type", "ChannelMappingEditor"); xml->setAttribute("Type", "ChannelMappingEditor");
//Made a bit generic in case future expansions need more settings
XmlElement* settingsXml = xml->createNewChildElement("SETTING");
settingsXml->setAttribute("Type","visibleChannels");
settingsXml->setAttribute("Value",previousChannelCount);
for (int i = 0; i < channelArray.size(); i++) for (int i = 0; i < channelArray.size(); i++)
{ {
XmlElement* channelXml = xml->createNewChildElement("CHANNEL"); XmlElement* channelXml = xml->createNewChildElement("CHANNEL");
...@@ -446,9 +527,20 @@ void ChannelMappingEditor::saveEditorParameters(XmlElement* xml) ...@@ -446,9 +527,20 @@ void ChannelMappingEditor::saveEditorParameters(XmlElement* xml)
} }
void ChannelMappingEditor::loadEditorParameters(XmlElement* xml) void ChannelMappingEditor::loadCustomParameters(XmlElement* xml)
{ {
setConfigured(true);
forEachXmlChildElementWithTagName(*xml, settingXml, "SETTING")
{
if (settingXml->getStringAttribute("Type").equalsIgnoreCase("visibleChannels"))
{
int nChans = settingXml->getIntAttribute("Value");
if (nChans > getProcessor()->getNumInputs())
{
createElectrodeButtons(nChans,false);
}
}
}
forEachXmlChildElementWithTagName(*xml, channelXml, "CHANNEL") forEachXmlChildElementWithTagName(*xml, channelXml, "CHANNEL")
{ {
int i = channelXml->getIntAttribute("Number"); int i = channelXml->getIntAttribute("Number");
...@@ -467,7 +559,7 @@ void ChannelMappingEditor::loadEditorParameters(XmlElement* xml) ...@@ -467,7 +559,7 @@ void ChannelMappingEditor::loadEditorParameters(XmlElement* xml)
electrodeButtons[i]->setChannelNum(mapping); electrodeButtons[i]->setChannelNum(mapping);
electrodeButtons[i]->setEnabled(enabled); electrodeButtons[i]->setEnabled(enabled);
electrodeButtons[i]->repaint(); electrodeButtons[i]->repaint();
getProcessor()->setCurrentChannel(i); getProcessor()->setCurrentChannel(i);
...@@ -499,16 +591,18 @@ void ChannelMappingEditor::loadEditorParameters(XmlElement* xml) ...@@ -499,16 +591,18 @@ void ChannelMappingEditor::loadEditorParameters(XmlElement* xml)
} }
for (int i = 0; i < electrodeButtons.size(); i++) for (int i = 0; i < electrodeButtons.size(); i++)
{
if (referenceArray[electrodeButtons[i]->getChannelNum()-1] == selectedReference)
{ {
if (referenceArray[electrodeButtons[i]->getChannelNum()-1] == selectedReference) electrodeButtons[i]->setToggleState(true,false);
{
electrodeButtons[i]->setToggleState(true,false);
}
else
{
electrodeButtons[i]->setToggleState(false,false);
}
} }
else
{
electrodeButtons[i]->setToggleState(false,false);
}
}
refreshButtonLocations();
} }
...@@ -569,7 +663,7 @@ void ChannelMappingEditor::mouseDrag(const MouseEvent &e) ...@@ -569,7 +663,7 @@ void ChannelMappingEditor::mouseDrag(const MouseEvent &e)
if (hoverButton != lastHoverButton) if (hoverButton != lastHoverButton)
{ {
electrodeButtons[lastHoverButton]->setVisible(true); electrodeButtons[lastHoverButton]->setVisible(true);
electrodeButtons[hoverButton]->setVisible(false); electrodeButtons[hoverButton]->setVisible(false);
...@@ -605,7 +699,7 @@ void ChannelMappingEditor::mouseDrag(const MouseEvent &e) ...@@ -605,7 +699,7 @@ void ChannelMappingEditor::mouseDrag(const MouseEvent &e)
} }
electrodeButtons[hoverButton]->setChannelNum(draggingChannel); electrodeButtons[hoverButton]->setChannelNum(draggingChannel);
electrodeButtons[hoverButton]->setToggleState(enabledChannelArray[draggingChannel-1],false); electrodeButtons[hoverButton]->setToggleState(enabledChannelArray[draggingChannel-1],false);
lastHoverButton = hoverButton; lastHoverButton = hoverButton;
repaint(); repaint();
} }
...@@ -622,7 +716,11 @@ void ChannelMappingEditor::mouseUp(const MouseEvent &e) ...@@ -622,7 +716,11 @@ void ChannelMappingEditor::mouseUp(const MouseEvent &e)
isDragging = false; isDragging = false;
electrodeButtons[lastHoverButton]->setVisible(true); electrodeButtons[lastHoverButton]->setVisible(true);
int from, to; int from, to;
if (lastHoverButton < initialDraggedButton) if (lastHoverButton == initialDraggedButton)
{
return;
}
else if (lastHoverButton < initialDraggedButton)
{ {
from = lastHoverButton; from = lastHoverButton;
to = initialDraggedButton; to = initialDraggedButton;
...@@ -637,6 +735,7 @@ void ChannelMappingEditor::mouseUp(const MouseEvent &e) ...@@ -637,6 +735,7 @@ void ChannelMappingEditor::mouseUp(const MouseEvent &e)
{ {
setChannelPosition(i,electrodeButtons[i]->getChannelNum()); setChannelPosition(i,electrodeButtons[i]->getChannelNum());
} }
setConfigured(true);
} }
} }
...@@ -651,6 +750,7 @@ void ChannelMappingEditor::mouseDoubleClick(const MouseEvent &e) ...@@ -651,6 +750,7 @@ void ChannelMappingEditor::mouseDoubleClick(const MouseEvent &e)
{ {
if ((reorderActive) && electrodeButtons.contains((ElectrodeButton*)e.originalComponent)) if ((reorderActive) && electrodeButtons.contains((ElectrodeButton*)e.originalComponent))
{ {
setConfigured(true);
ElectrodeButton *button = (ElectrodeButton*)e.originalComponent; ElectrodeButton *button = (ElectrodeButton*)e.originalComponent;
if (button->getToggleState()) if (button->getToggleState())
...@@ -669,4 +769,53 @@ void ChannelMappingEditor::mouseDoubleClick(const MouseEvent &e) ...@@ -669,4 +769,53 @@ void ChannelMappingEditor::mouseDoubleClick(const MouseEvent &e)
} }
getEditorViewport()->makeEditorVisible(this, false, true); getEditorViewport()->makeEditorVisible(this, false, true);
} }
} }
\ No newline at end of file
void ChannelMappingEditor::mouseWheelMove(const MouseEvent& event,
const MouseWheelDetails& wheel)
{
float maxScrollDistance = ceil(float(electrodeButtons.size() - 80) / 16.0f);
// std::cout << "Got wheel move: " << wheel.deltaY << std::endl;
// channelSelector->shiftChannelsVertical(-wheel.deltaY);
scrollDistance -= wheel.deltaY*2;
if (scrollDistance > maxScrollDistance)
scrollDistance = maxScrollDistance;
if (scrollDistance < 0)
scrollDistance = 0;
refreshButtonLocations();
}
void ChannelMappingEditor::checkUnusedChannels()
{
for (int i = 0; i < electrodeButtons.size(); i++)
{
if (electrodeButtons[i]->getChannelNum() > getProcessor()->getNumInputs())
{
electrodeButtons[i]->setEnabled(false);
}
else
{
if (enabledChannelArray[electrodeButtons[i]->getChannelNum()-1])
{
electrodeButtons[i]->setEnabled(true);
}
else
{
electrodeButtons[i]->setEnabled(false);
}
}
}
}
void ChannelMappingEditor::setConfigured(bool state)
{
isConfigured = state;
resetButton->setEnabled(state);
resetButton->setToggleState(!state,false);
getProcessor()->setParameter(4,state?1:0);
}
...@@ -52,10 +52,10 @@ public: ...@@ -52,10 +52,10 @@ public:
void updateSettings(); void updateSettings();
void createElectrodeButtons(int numNeeded); void createElectrodeButtons(int numNeeded, bool clearPrevious = true);
void saveEditorParameters(XmlElement* xml); void saveCustomParameters(XmlElement* xml);
void loadEditorParameters(XmlElement* xml); void loadCustomParameters(XmlElement* xml);
void channelChanged(int chan); void channelChanged(int chan);
...@@ -65,16 +65,24 @@ public: ...@@ -65,16 +65,24 @@ public:
void mouseDoubleClick(const MouseEvent &e); void mouseDoubleClick(const MouseEvent &e);
void mouseWheelMove(const MouseEvent& event, const MouseWheelDetails& wheel);
void collapsedStateChanged();
private: private:
void setChannelReference(ElectrodeButton *button); void setChannelReference(ElectrodeButton *button);
void setChannelPosition(int position, int channel); void setChannelPosition(int position, int channel);
void checkUnusedChannels();
void setConfigured(bool state);
void refreshButtonLocations();
OwnedArray<ElectrodeButton> electrodeButtons; OwnedArray<ElectrodeButton> electrodeButtons;
OwnedArray<ElectrodeButton> referenceButtons; OwnedArray<ElectrodeButton> referenceButtons;
ScopedPointer<ElectrodeEditorButton> selectAllButton; ScopedPointer<ElectrodeEditorButton> selectAllButton;
ScopedPointer<ElectrodeEditorButton> modifyButton; ScopedPointer<ElectrodeEditorButton> modifyButton;
ScopedPointer<ElectrodeEditorButton> resetButton;
Array<int> channelArray; Array<int> channelArray;
Array<int> referenceArray; Array<int> referenceArray;
...@@ -92,6 +100,9 @@ private: ...@@ -92,6 +100,9 @@ private:
int initialDraggedButton; int initialDraggedButton;
int draggingChannel; int draggingChannel;
int lastHoverButton; int lastHoverButton;
bool isConfigured;
float scrollDistance;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ChannelMappingEditor); JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ChannelMappingEditor);
......
...@@ -143,7 +143,7 @@ void ChannelSelector::shiftChannelsVertical(float amount) ...@@ -143,7 +143,7 @@ void ChannelSelector::shiftChannelsVertical(float amount)
offsetUD = jmax(offsetUD, float(parameterButtons.size())/8*-10.68f); offsetUD = jmax(offsetUD, float(parameterButtons.size())/8*-10.68f);
} }
std::cout << "offsetUD = " << offsetUD << std::endl; //std::cout << "offsetUD = " << offsetUD << std::endl;
refreshButtonBoundaries(); refreshButtonBoundaries();
...@@ -432,7 +432,11 @@ void ChannelSelector::setAudioStatus(int chan, bool b) ...@@ -432,7 +432,11 @@ void ChannelSelector::setAudioStatus(int chan, bool b)
} }
void ChannelSelector::clearAudio()
{
for (int chan = 0; chan < audioButtons.size(); chan++)
audioButtons[chan]->setToggleState(false, true);
}
int ChannelSelector::getDesiredWidth() int ChannelSelector::getDesiredWidth()
{ {
...@@ -555,11 +559,12 @@ void ChannelSelector::buttonClicked(Button* button) ...@@ -555,11 +559,12 @@ void ChannelSelector::buttonClicked(Button* button)
//int channelNum = editor->getStartChannel() + b->getChannel() - 1; //int channelNum = editor->getStartChannel() + b->getChannel() - 1;
bool status = b->getToggleState(); bool status = b->getToggleState();
std::cout << "Requesting audio monitor for channel " << ch->num << std::endl;
if (acquisitionIsActive) // use setParameter to change parameter safely if (acquisitionIsActive) // use setParameter to change parameter safely
{ {
editor->getProcessorGraph()-> editor->getProcessorGraph()->
getAudioNode()-> getAudioNode()->setChannelStatus(ch, status);
setChannelStatus(ch, status);
} }
else // change parameter directly else // change parameter directly
{ {
...@@ -590,8 +595,12 @@ void ChannelSelector::buttonClicked(Button* button) ...@@ -590,8 +595,12 @@ void ChannelSelector::buttonClicked(Button* button)
} }
} }
else else // parameter type
{ {
GenericEditor* editor = (GenericEditor*) getParentComponent();
editor->channelChanged(b->getChannel()-1);
// do nothing // do nothing
if (radioStatus) // if radio buttons are active if (radioStatus) // if radio buttons are active
{ {
...@@ -832,8 +841,8 @@ void ChannelSelectorRegion::mouseWheelMove(const MouseEvent& event, ...@@ -832,8 +841,8 @@ void ChannelSelectorRegion::mouseWheelMove(const MouseEvent& event,
const MouseWheelDetails& wheel) const MouseWheelDetails& wheel)
{ {
std::cout << "Got wheel move: " << wheel.deltaY << std::endl; // std::cout << "Got wheel move: " << wheel.deltaY << std::endl;
channelSelector->shiftChannelsVertical(wheel.deltaY); channelSelector->shiftChannelsVertical(-wheel.deltaY);
} }
void ChannelSelectorRegion::paint(Graphics& g) void ChannelSelectorRegion::paint(Graphics& g)
......
...@@ -94,6 +94,9 @@ public: ...@@ -94,6 +94,9 @@ public:
/** Set whether a particular channel should be monitored. */ /** Set whether a particular channel should be monitored. */
void setAudioStatus(int, bool); void setAudioStatus(int, bool);
/** Sets all audio monitors to 'false' */
void clearAudio();
/** Set whether a particular channel is selected for editing parameters. */ /** Set whether a particular channel is selected for editing parameters. */
void setParamStatus(int, bool); void setParamStatus(int, bool);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment