-
Notifications
You must be signed in to change notification settings - Fork 1
/
TGTrack.cpp
89 lines (78 loc) · 2.07 KB
/
TGTrack.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include "TGTrack.h"
#include "TGChannel.h"
#include "TGMeasure.h"
#include "TGLyric.h"
#include "TGString.h"
TGTrack::TGTrack(TGFactory *factory) {
number = 0;
offset = 0;
solo = false;
mute = false;
channel = factory->newChannel();
color = COLOR_BLACK;
lyrics = factory->newLyric();
song = NULL;
}
TGTrack::~TGTrack()
{
clear();
#ifndef AUTOMATIC_DELETE
delete channel;
delete lyrics;
#endif
}
bool TGTrack::isPercussionTrack(){
return (getChannel()->isPercussionChannel());
}
void TGTrack::addMeasure(TGMeasure *measure){
measure->setTrack(this);
measures.push_back(measure);
}
void TGTrack::addMeasure(int index, TGMeasure* aMeasure){
aMeasure->setTrack(this);
measures.insert(measures.begin() + index, aMeasure);
}
void TGTrack::removeMeasure(int index){
TGMeasureList::iterator i = measures.begin() + index;
if (i != measures.end())
measures.erase( i );
}
TGTrack * TGTrack::clone(TGFactory *factory,TGSong *song){
TGTrack *track = factory->newTrack();
copy(factory, song, track);
return track;
}
void TGTrack::copy(TGFactory *factory,TGSong *song,TGTrack *track){
track->clear();
track->setNumber(getNumber());
track->setName(getName());
track->setOffset(getOffset());
getChannel()->copy(track->getChannel());
color = track->getColor();
getLyrics()->copy(track->getLyrics());
for (TGStringList::iterator i=strings.begin(); i!=strings.end(); ++i)
{
TGString *s = (*i);
track->getStrings().push_back(s->clone(factory));
}
for (int i = 0; i < countMeasures(); i++) {
TGMeasure *measure = getMeasure(i);
track->addMeasure(measure->clone(factory,song->getMeasureHeader(i)));
}
}
void TGTrack::clear(){
#ifndef AUTOMATIC_DELETE
for (TGStringList::iterator i = strings.begin(); i!=strings.end(); ++i)
{
delete (*i);
}
#endif
strings.clear();
#ifndef AUTOMATIC_DELETE
for (TGMeasureList::iterator i = measures.begin(); i!=measures.end(); ++i)
{
delete (*i);
}
#endif
measures.clear();
}