annotate base/Command.cpp @ 19:a7ed14263fe4

* Add Chromagram plugin, and make a number of fixes to the dense 3d model and colour 3d plot class to accommodate it * Add pitch-conversion methods in base/Pitch * Commit previously overlooked Command.cpp
author Chris Cannam
date Wed, 01 Feb 2006 14:49:49 +0000
parents
children bac8b14ab355
rev   line source
Chris@19 1 /* -*- c-basic-offset: 4 -*- vi:set ts=8 sts=4 sw=4: */
Chris@19 2
Chris@19 3 /*
Chris@19 4 A waveform viewer and audio annotation editor.
Chris@19 5 Chris Cannam, Queen Mary University of London, 2005-2006
Chris@19 6
Chris@19 7 This is experimental software. Not for distribution.
Chris@19 8 */
Chris@19 9
Chris@19 10 #include "Command.h"
Chris@19 11
Chris@19 12 MacroCommand::MacroCommand(QString name) :
Chris@19 13 m_name(name)
Chris@19 14 {
Chris@19 15 }
Chris@19 16
Chris@19 17 MacroCommand::~MacroCommand()
Chris@19 18 {
Chris@19 19 for (size_t i = 0; i < m_commands.size(); ++i) {
Chris@19 20 delete m_commands[i];
Chris@19 21 }
Chris@19 22 }
Chris@19 23
Chris@19 24 void
Chris@19 25 MacroCommand::addCommand(Command *command)
Chris@19 26 {
Chris@19 27 m_commands.push_back(command);
Chris@19 28 }
Chris@19 29
Chris@19 30 void
Chris@19 31 MacroCommand::deleteCommand(Command *command)
Chris@19 32 {
Chris@19 33 for (std::vector<Command *>::iterator i = m_commands.begin();
Chris@19 34 i != m_commands.end(); ++i) {
Chris@19 35
Chris@19 36 if (*i == command) {
Chris@19 37 m_commands.erase(i);
Chris@19 38 delete command;
Chris@19 39 return;
Chris@19 40 }
Chris@19 41 }
Chris@19 42 }
Chris@19 43
Chris@19 44 void
Chris@19 45 MacroCommand::execute()
Chris@19 46 {
Chris@19 47 for (size_t i = 0; i < m_commands.size(); ++i) {
Chris@19 48 m_commands[i]->execute();
Chris@19 49 }
Chris@19 50 }
Chris@19 51
Chris@19 52 void
Chris@19 53 MacroCommand::unexecute()
Chris@19 54 {
Chris@19 55 for (size_t i = 0; i < m_commands.size(); ++i) {
Chris@19 56 m_commands[m_commands.size() - i - 1]->unexecute();
Chris@19 57 }
Chris@19 58 }
Chris@19 59