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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
|
/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
/*
Rosegarden
A MIDI and audio sequencer and musical notation editor.
This program is Copyright 2000-2008
Guillaume Laurent <[email protected]>,
Chris Cannam <[email protected]>,
Richard Bown <[email protected]>
The moral rights of Guillaume Laurent, Chris Cannam, and Richard
Bown to claim authorship of this work have been asserted.
Other copyrights also apply to some parts of this work. Please
see the AUTHORS file and individual file headers for details.
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 2 of the
License, or (at your option) any later version. See the file
COPYING included with this distribution for more information.
*/
#ifndef _RG_COMPOSITIONMODELIMPL_H_
#define _RG_COMPOSITIONMODELIMPL_H_
#include "base/Selection.h"
#include "base/SnapGrid.h"
#include "CompositionModel.h"
#include "CompositionRect.h"
#include <map>
#include "SegmentOrderer.h"
#include <set>
#include <qcolor.h>
#include <qpoint.h>
#include <qptrdict.h>
#include <qrect.h>
#include <vector>
#include "base/Event.h"
class RectRanges;
class CompositionItem;
class AudioPreviewDrawData;
class AudioPreviewData;
namespace Rosegarden
{
class Studio;
class Segment;
class RulerScale;
class Event;
class Composition;
class AudioPreviewUpdater;
class AudioPreviewThread;
class CompositionModelImpl : public CompositionModel
{
Q_OBJECT
public:
CompositionModelImpl(Composition& compo,
Studio& studio,
RulerScale *rulerScale,
int vStep);
virtual ~CompositionModelImpl();
virtual unsigned int getNbRows();
virtual const rectcontainer& getRectanglesIn(const QRect& rect,
RectRanges* notationRects, AudioPreviewDrawData* audioRects);
virtual heightlist getTrackDividersIn(const QRect& rect);
virtual itemcontainer getItemsAt (const QPoint&);
virtual timeT getRepeatTimeAt (const QPoint&, const CompositionItem&);
virtual SnapGrid& grid() { return m_grid; }
virtual void setPointerPos(int xPos);
virtual void setSelected(const CompositionItem&, bool selected = true);
virtual bool isSelected(const CompositionItem&) const;
virtual void setSelected(const itemcontainer&);
virtual void clearSelected();
virtual bool haveSelection() const { return !m_selectedSegments.empty(); }
virtual bool haveMultipleSelection() const { return m_selectedSegments.size() > 1; }
virtual void signalSelection();
virtual void setSelectionRect(const QRect&);
virtual void finalizeSelectionRect();
virtual QRect getSelectionContentsRect();
virtual void signalContentChange();
virtual void addRecordingItem(const CompositionItem&);
virtual void removeRecordingItem(const CompositionItem &);
virtual void clearRecordingItems();
virtual bool haveRecordingItems() { return m_recordingSegments.size() > 0; }
virtual void startChange(const CompositionItem&, ChangeType change);
virtual void startChangeSelection(ChangeType change);
virtual itemcontainer& getChangingItems() { return m_changingItems; }
virtual void endChange();
virtual ChangeType getChangeType() { return m_changeType; }
virtual void setLength(int width);
virtual int getLength();
void setAudioPreviewThread(AudioPreviewThread *thread);
AudioPreviewThread* getAudioPreviewThread() { return m_audioPreviewThread; }
void clearPreviewCache();
void clearSegmentRectsCache(bool clearPreviews = false) { clearInCache(0, clearPreviews); }
rectlist* makeNotationPreviewDataCache(const Segment *s);
AudioPreviewData* makeAudioPreviewDataCache(const Segment *s);
CompositionRect computeSegmentRect(const Segment&, bool computeZ = false);
QColor computeSegmentPreviewColor(const Segment*);
QPoint computeSegmentOrigin(const Segment&);
void computeRepeatMarks(CompositionItem&);
SegmentSelection getSelectedSegments() { return m_selectedSegments; }
Composition& getComposition() { return m_composition; }
Studio& getStudio() { return m_studio; }
// CompositionObserver
virtual void segmentAdded(const Composition *, Segment *);
virtual void segmentRemoved(const Composition *, Segment *);
virtual void segmentRepeatChanged(const Composition *, Segment *, bool);
virtual void segmentStartChanged(const Composition *, Segment *, timeT);
virtual void segmentEndMarkerChanged(const Composition *, Segment *, bool);
virtual void segmentTrackChanged(const Composition *, Segment *, TrackId);
virtual void endMarkerTimeChanged(const Composition *, bool /*shorten*/);
// SegmentObserver
virtual void eventAdded(const Segment *, Event *);
virtual void eventRemoved(const Segment *, Event *);
virtual void appearanceChanged(const Segment *);
virtual void endMarkerTimeChanged(const Segment *, bool /*shorten*/);
virtual void segmentDeleted(const Segment*) { /* nothing to do - handled by CompositionObserver::segmentRemoved() */ };
signals:
void selectedSegments(const SegmentSelection &);
void needSizeUpdate();
public slots:
void slotAudioFileFinalized(Segment*);
void slotInstrumentParametersChanged(InstrumentId);
protected slots:
void slotAudioPreviewComplete(AudioPreviewUpdater*);
protected:
bool setTrackHeights(Segment *changed = 0); // true if something changed
void setSelected(const Segment*, bool selected = true);
bool isSelected(const Segment*) const;
bool isTmpSelected(const Segment*) const;
bool wasTmpSelected(const Segment*) const;
bool isMoving(const Segment*) const;
bool isRecording(const Segment*) const;
void computeRepeatMarks(CompositionRect& sr, const Segment* s);
unsigned int computeZForSegment(const Segment* s);
// segment preview stuff
void updatePreviewCacheForNotationSegment(const Segment* s, rectlist*);
void updatePreviewCacheForAudioSegment(const Segment* s, AudioPreviewData*);
rectlist* getNotationPreviewData(const Segment* s);
AudioPreviewData* getAudioPreviewData(const Segment* s);
PixmapArray getAudioPreviewPixmap(const Segment* s);
QRect postProcessAudioPreview(AudioPreviewData*, const Segment*);
void makePreviewCache(const Segment* s);
void removePreviewCache(const Segment* s);
void makeNotationPreviewRects(RectRanges* npData, QPoint basePoint, const Segment*, const QRect&);
void makeNotationPreviewRectsMovingSegment(RectRanges* npData, QPoint basePoint, const Segment*,
const QRect&);
void makeAudioPreviewRects(AudioPreviewDrawData* apRects, const Segment*,
const CompositionRect& segRect, const QRect& clipRect);
void clearInCache(const Segment*, bool clearPreviewCache = false);
void putInCache(const Segment*, const CompositionRect&);
const CompositionRect& getFromCache(const Segment*, timeT& endTime);
bool isCachedRectCurrent(const Segment& s, const CompositionRect& r,
QPoint segmentOrigin, timeT segmentEndTime);
//--------------- Data members ---------------------------------
Composition& m_composition;
Studio& m_studio;
SnapGrid m_grid;
SegmentSelection m_selectedSegments;
SegmentSelection m_tmpSelectedSegments;
SegmentSelection m_previousTmpSelectedSegments;
timeT m_pointerTimePos;
typedef std::set<Segment *> recordingsegmentset;
recordingsegmentset m_recordingSegments;
typedef std::vector<CompositionItem> itemgc;
AudioPreviewThread* m_audioPreviewThread;
typedef QPtrDict<rectlist> NotationPreviewDataCache;
typedef QPtrDict<AudioPreviewData> AudioPreviewDataCache;
NotationPreviewDataCache m_notationPreviewDataCache;
AudioPreviewDataCache m_audioPreviewDataCache;
rectcontainer m_res;
itemcontainer m_changingItems;
ChangeType m_changeType;
itemgc m_itemGC;
QRect m_selectionRect;
QRect m_previousSelectionUpdateRect;
std::map<const Segment*, CompositionRect> m_segmentRectMap;
std::map<const Segment*, timeT> m_segmentEndTimeMap;
std::map<const Segment*, PixmapArray> m_audioSegmentPreviewMap;
std::map<TrackId, int> m_trackHeights;
typedef std::map<const Segment*, AudioPreviewUpdater *>
AudioPreviewUpdaterMap;
AudioPreviewUpdaterMap m_audioPreviewUpdaterMap;
SegmentOrderer m_segmentOrderer;
};
}
#endif
|