-
Notifications
You must be signed in to change notification settings - Fork 685
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
62990d7
commit b96bc82
Showing
4 changed files
with
146 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/* | ||
------------------------------------------------------------------ | ||
This file is part of the Open Ephys GUI | ||
Copyright (C) 2023 Open Ephys | ||
------------------------------------------------------------------ | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include <stdio.h> | ||
|
||
#include "ChannelMappingNodeActions.h" | ||
|
||
MapChannelsAction::MapChannelsAction(ChannelMappingNode* processor, | ||
DataStream* stream, | ||
Array<int> newMap) : | ||
OpenEphysAction("MapChannels"), | ||
channelMapper(processor), | ||
streamKey(stream->getKey()), | ||
prevChannelOrder(processor->getChannelOrder(stream->getStreamId())), | ||
nextChannelOrder(newMap) | ||
{ | ||
settings = nullptr; | ||
} | ||
|
||
MapChannelsAction::~MapChannelsAction() | ||
{ | ||
if (settings != nullptr) | ||
delete settings; | ||
} | ||
|
||
bool MapChannelsAction::perform() | ||
{ | ||
uint16 streamId = 0; | ||
for (auto stream : channelMapper->getDataStreams()) | ||
{ | ||
if (stream->getKey() == streamKey) | ||
{ | ||
streamId = stream->getStreamId(); | ||
break; | ||
} | ||
} | ||
if (streamId == 0) return false; | ||
|
||
channelMapper->setChannelOrder(streamId, nextChannelOrder); | ||
|
||
channelMapper->registerUndoableAction(channelMapper->getNodeId(), this); | ||
|
||
CoreServices::updateSignalChain(channelMapper); | ||
|
||
return true; | ||
} | ||
|
||
bool MapChannelsAction::undo() | ||
{ | ||
uint16 streamId = 0; | ||
for (auto stream : channelMapper->getDataStreams()) | ||
{ | ||
if (stream->getKey() == streamKey) | ||
{ | ||
streamId = stream->getStreamId(); | ||
break; | ||
} | ||
} | ||
if (streamId == 0) return false; | ||
|
||
channelMapper->setChannelOrder(streamId, prevChannelOrder); | ||
|
||
channelMapper->registerUndoableAction(channelMapper->getNodeId(), this); | ||
|
||
CoreServices::updateSignalChain(channelMapper); | ||
|
||
return true; | ||
} | ||
|
||
void MapChannelsAction::restoreOwner(GenericProcessor* owner) | ||
{ | ||
channelMapper = (ChannelMappingNode*)owner; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Define the actions available for the ChannelMappingNode plugin. | ||
|
||
// ===================================================== | ||
#ifndef ChannelMappingNodeActions_h | ||
#define ChannelMappingNodeActions_h | ||
|
||
#include <ProcessorHeaders.h> | ||
|
||
#include "ChannelMappingNode.h" | ||
#include "ChannelMappingEditor.h" | ||
|
||
class MapChannelsAction : public OpenEphysAction | ||
{ | ||
|
||
public: | ||
|
||
/** Constructor*/ | ||
MapChannelsAction(ChannelMappingNode* processor, | ||
DataStream* stream, | ||
Array<int> nextChannelOrder); | ||
|
||
/** Destructor */ | ||
~MapChannelsAction(); | ||
|
||
void restoreOwner(GenericProcessor* processor) override; | ||
|
||
/** Perform the action*/ | ||
bool perform(); | ||
|
||
/** Undo the action*/ | ||
bool undo(); | ||
|
||
XmlElement* settings; | ||
|
||
private: | ||
|
||
ChannelMappingNode* channelMapper; | ||
String streamKey; | ||
Array<int> prevChannelOrder; | ||
Array<int> nextChannelOrder; | ||
|
||
}; | ||
|
||
#endif /* ChannelMappingNodeActions_h */ |