Chris@0
|
1 /* -*- c-basic-offset: 4 -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@0
|
2
|
Chris@0
|
3 /*
|
Chris@0
|
4 A waveform viewer and audio annotation editor.
|
Chris@2
|
5 Chris Cannam, Queen Mary University of London, 2005-2006
|
Chris@0
|
6
|
Chris@0
|
7 This is experimental software. Not for distribution.
|
Chris@0
|
8 */
|
Chris@0
|
9
|
Chris@0
|
10 #include "Layer.h"
|
Chris@0
|
11 #include "View.h"
|
Chris@0
|
12
|
Chris@0
|
13 #include <iostream>
|
Chris@0
|
14
|
Chris@3
|
15 #include "layer/LayerFactory.h" //!!! shouldn't be including this here -- does that suggest we need to move this into layer/ ?
|
Chris@28
|
16 #include "PlayParameterRepository.h"
|
Chris@3
|
17
|
Chris@29
|
18 Layer::Layer(View *w) :
|
Chris@29
|
19 m_dormant(false)
|
Chris@0
|
20 {
|
Chris@0
|
21 m_view = w;
|
Chris@0
|
22
|
Chris@0
|
23 // Subclass must call this:
|
Chris@0
|
24 // w->addLayer(this);
|
Chris@0
|
25 }
|
Chris@0
|
26
|
Chris@0
|
27 Layer::~Layer()
|
Chris@0
|
28 {
|
Chris@0
|
29 m_view->removeLayer(this);
|
Chris@0
|
30 }
|
Chris@0
|
31
|
Chris@12
|
32 QString
|
Chris@12
|
33 Layer::getPropertyContainerIconName() const
|
Chris@12
|
34 {
|
Chris@12
|
35 return LayerFactory::instance()->getLayerIconName
|
Chris@12
|
36 (LayerFactory::instance()->getLayerType(this));
|
Chris@12
|
37 }
|
Chris@12
|
38
|
Chris@0
|
39 void
|
Chris@0
|
40 Layer::setObjectName(const QString &name)
|
Chris@0
|
41 {
|
Chris@0
|
42 QObject::setObjectName(name);
|
Chris@0
|
43 emit layerNameChanged();
|
Chris@0
|
44 }
|
Chris@0
|
45
|
Chris@15
|
46 int
|
Chris@15
|
47 Layer::getXForFrame(long frame) const
|
Chris@15
|
48 {
|
Chris@15
|
49 if (m_view) return m_view->getXForFrame(frame);
|
Chris@15
|
50 else return 0;
|
Chris@15
|
51 }
|
Chris@15
|
52
|
Chris@15
|
53 long
|
Chris@15
|
54 Layer::getFrameForX(int x) const
|
Chris@15
|
55 {
|
Chris@15
|
56 if (m_view) return m_view->getFrameForX(x);
|
Chris@15
|
57 else return 0;
|
Chris@15
|
58 }
|
Chris@15
|
59
|
Chris@3
|
60 QString
|
Chris@3
|
61 Layer::toXmlString(QString indent, QString extraAttributes) const
|
Chris@3
|
62 {
|
Chris@3
|
63 QString s;
|
Chris@3
|
64
|
Chris@3
|
65 s += indent;
|
Chris@3
|
66
|
Chris@6
|
67 s += QString("<layer id=\"%2\" type=\"%1\" name=\"%3\" model=\"%4\" %5/>\n")
|
Chris@3
|
68 .arg(LayerFactory::instance()->getLayerTypeName
|
Chris@3
|
69 (LayerFactory::instance()->getLayerType(this)))
|
Chris@4
|
70 .arg(getObjectExportId(this))
|
Chris@3
|
71 .arg(objectName())
|
Chris@4
|
72 .arg(getObjectExportId(getModel()))
|
Chris@3
|
73 .arg(extraAttributes);
|
Chris@3
|
74
|
Chris@3
|
75 return s;
|
Chris@3
|
76 }
|
Chris@0
|
77
|
Chris@28
|
78 PlayParameters *
|
Chris@29
|
79 Layer::getPlayParameters()
|
Chris@28
|
80 {
|
Chris@32
|
81 // std::cerr << "Layer (" << this << ", " << objectName().toStdString() << ")::getPlayParameters: model is "<< getModel() << std::endl;
|
Chris@28
|
82 const Model *model = getModel();
|
Chris@28
|
83 if (model) {
|
Chris@28
|
84 return PlayParameterRepository::instance()->getPlayParameters(model);
|
Chris@28
|
85 }
|
Chris@28
|
86 return 0;
|
Chris@28
|
87 }
|
Chris@28
|
88
|
Chris@29
|
89 void
|
Chris@29
|
90 Layer::showLayer(bool show)
|
Chris@29
|
91 {
|
Chris@29
|
92 setLayerDormant(!show);
|
Chris@29
|
93 emit layerParametersChanged();
|
Chris@29
|
94 }
|
Chris@28
|
95
|
Chris@28
|
96
|
Chris@0
|
97 #ifdef INCLUDE_MOCFILES
|
Chris@0
|
98 #include "Layer.moc.cpp"
|
Chris@0
|
99 #endif
|
Chris@0
|
100
|