Chris@49
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- 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@47
|
12 #include "Model.h"
|
Chris@0
|
13
|
Chris@0
|
14 #include <iostream>
|
Chris@0
|
15
|
Chris@3
|
16 #include "layer/LayerFactory.h" //!!! shouldn't be including this here -- does that suggest we need to move this into layer/ ?
|
Chris@28
|
17 #include "PlayParameterRepository.h"
|
Chris@3
|
18
|
Chris@39
|
19 Layer::Layer()
|
Chris@0
|
20 {
|
Chris@0
|
21 }
|
Chris@0
|
22
|
Chris@0
|
23 Layer::~Layer()
|
Chris@0
|
24 {
|
Chris@43
|
25 std::cerr << "Layer::~Layer(" << this << ")" << std::endl;
|
Chris@0
|
26 }
|
Chris@0
|
27
|
Chris@12
|
28 QString
|
Chris@12
|
29 Layer::getPropertyContainerIconName() const
|
Chris@12
|
30 {
|
Chris@12
|
31 return LayerFactory::instance()->getLayerIconName
|
Chris@12
|
32 (LayerFactory::instance()->getLayerType(this));
|
Chris@12
|
33 }
|
Chris@12
|
34
|
Chris@47
|
35 QString
|
Chris@47
|
36 Layer::getLayerPresentationName() const
|
Chris@47
|
37 {
|
Chris@47
|
38 QString layerName = objectName();
|
Chris@47
|
39 QString modelName;
|
Chris@47
|
40 if (getModel()) modelName = getModel()->objectName();
|
Chris@47
|
41
|
Chris@47
|
42 QString text;
|
Chris@47
|
43 if (modelName != "") {
|
Chris@47
|
44 text = QString("%1: %2").arg(modelName).arg(layerName);
|
Chris@47
|
45 } else {
|
Chris@47
|
46 text = layerName;
|
Chris@47
|
47 }
|
Chris@47
|
48
|
Chris@47
|
49 return text;
|
Chris@47
|
50 }
|
Chris@47
|
51
|
Chris@0
|
52 void
|
Chris@0
|
53 Layer::setObjectName(const QString &name)
|
Chris@0
|
54 {
|
Chris@0
|
55 QObject::setObjectName(name);
|
Chris@0
|
56 emit layerNameChanged();
|
Chris@0
|
57 }
|
Chris@15
|
58
|
Chris@3
|
59 QString
|
Chris@3
|
60 Layer::toXmlString(QString indent, QString extraAttributes) const
|
Chris@3
|
61 {
|
Chris@3
|
62 QString s;
|
Chris@3
|
63
|
Chris@3
|
64 s += indent;
|
Chris@3
|
65
|
Chris@6
|
66 s += QString("<layer id=\"%2\" type=\"%1\" name=\"%3\" model=\"%4\" %5/>\n")
|
Chris@3
|
67 .arg(LayerFactory::instance()->getLayerTypeName
|
Chris@3
|
68 (LayerFactory::instance()->getLayerType(this)))
|
Chris@4
|
69 .arg(getObjectExportId(this))
|
Chris@3
|
70 .arg(objectName())
|
Chris@4
|
71 .arg(getObjectExportId(getModel()))
|
Chris@3
|
72 .arg(extraAttributes);
|
Chris@3
|
73
|
Chris@3
|
74 return s;
|
Chris@3
|
75 }
|
Chris@0
|
76
|
Chris@28
|
77 PlayParameters *
|
Chris@29
|
78 Layer::getPlayParameters()
|
Chris@28
|
79 {
|
Chris@32
|
80 // std::cerr << "Layer (" << this << ", " << objectName().toStdString() << ")::getPlayParameters: model is "<< getModel() << std::endl;
|
Chris@28
|
81 const Model *model = getModel();
|
Chris@28
|
82 if (model) {
|
Chris@28
|
83 return PlayParameterRepository::instance()->getPlayParameters(model);
|
Chris@28
|
84 }
|
Chris@28
|
85 return 0;
|
Chris@28
|
86 }
|
Chris@28
|
87
|
Chris@29
|
88 void
|
Chris@36
|
89 Layer::showLayer(View *view, bool show)
|
Chris@29
|
90 {
|
Chris@36
|
91 setLayerDormant(view, !show);
|
Chris@29
|
92 emit layerParametersChanged();
|
Chris@29
|
93 }
|
Chris@28
|
94
|
Chris@28
|
95
|
Chris@0
|
96 #ifdef INCLUDE_MOCFILES
|
Chris@0
|
97 #include "Layer.moc.cpp"
|
Chris@0
|
98 #endif
|
Chris@0
|
99
|