annotate base/Layer.cpp @ 84:97e085895524

* Compile fix in DSSIPluginInstance, add origin notes to icons and samples
author Chris Cannam
date Wed, 26 Apr 2006 16:27:34 +0000
parents 2beca8ddcdc3
children c30728d5625c
rev   line source
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@52 4 Sonic Visualiser
Chris@52 5 An audio file viewer and annotation editor.
Chris@52 6 Centre for Digital Music, Queen Mary, University of London.
Chris@52 7 This file copyright 2006 Chris Cannam.
Chris@0 8
Chris@52 9 This program is free software; you can redistribute it and/or
Chris@52 10 modify it under the terms of the GNU General Public License as
Chris@52 11 published by the Free Software Foundation; either version 2 of the
Chris@52 12 License, or (at your option) any later version. See the file
Chris@52 13 COPYING included with this distribution for more information.
Chris@0 14 */
Chris@0 15
Chris@0 16 #include "Layer.h"
Chris@0 17 #include "View.h"
Chris@47 18 #include "Model.h"
Chris@0 19
Chris@0 20 #include <iostream>
Chris@0 21
Chris@3 22 #include "layer/LayerFactory.h" //!!! shouldn't be including this here -- does that suggest we need to move this into layer/ ?
Chris@28 23 #include "PlayParameterRepository.h"
Chris@3 24
Chris@39 25 Layer::Layer()
Chris@0 26 {
Chris@0 27 }
Chris@0 28
Chris@0 29 Layer::~Layer()
Chris@0 30 {
Chris@43 31 std::cerr << "Layer::~Layer(" << this << ")" << std::endl;
Chris@0 32 }
Chris@0 33
Chris@12 34 QString
Chris@12 35 Layer::getPropertyContainerIconName() const
Chris@12 36 {
Chris@12 37 return LayerFactory::instance()->getLayerIconName
Chris@12 38 (LayerFactory::instance()->getLayerType(this));
Chris@12 39 }
Chris@12 40
Chris@47 41 QString
Chris@47 42 Layer::getLayerPresentationName() const
Chris@47 43 {
Chris@47 44 QString layerName = objectName();
Chris@47 45 QString modelName;
Chris@47 46 if (getModel()) modelName = getModel()->objectName();
Chris@47 47
Chris@47 48 QString text;
Chris@47 49 if (modelName != "") {
Chris@47 50 text = QString("%1: %2").arg(modelName).arg(layerName);
Chris@47 51 } else {
Chris@47 52 text = layerName;
Chris@47 53 }
Chris@47 54
Chris@47 55 return text;
Chris@47 56 }
Chris@47 57
Chris@0 58 void
Chris@0 59 Layer::setObjectName(const QString &name)
Chris@0 60 {
Chris@0 61 QObject::setObjectName(name);
Chris@0 62 emit layerNameChanged();
Chris@0 63 }
Chris@15 64
Chris@3 65 QString
Chris@3 66 Layer::toXmlString(QString indent, QString extraAttributes) const
Chris@3 67 {
Chris@3 68 QString s;
Chris@3 69
Chris@3 70 s += indent;
Chris@3 71
Chris@6 72 s += QString("<layer id=\"%2\" type=\"%1\" name=\"%3\" model=\"%4\" %5/>\n")
Chris@77 73 .arg(encodeEntities(LayerFactory::instance()->getLayerTypeName
Chris@77 74 (LayerFactory::instance()->getLayerType(this))))
Chris@4 75 .arg(getObjectExportId(this))
Chris@77 76 .arg(encodeEntities(objectName()))
Chris@4 77 .arg(getObjectExportId(getModel()))
Chris@3 78 .arg(extraAttributes);
Chris@3 79
Chris@3 80 return s;
Chris@3 81 }
Chris@0 82
Chris@28 83 PlayParameters *
Chris@29 84 Layer::getPlayParameters()
Chris@28 85 {
Chris@32 86 // std::cerr << "Layer (" << this << ", " << objectName().toStdString() << ")::getPlayParameters: model is "<< getModel() << std::endl;
Chris@28 87 const Model *model = getModel();
Chris@28 88 if (model) {
Chris@28 89 return PlayParameterRepository::instance()->getPlayParameters(model);
Chris@28 90 }
Chris@28 91 return 0;
Chris@28 92 }
Chris@28 93
Chris@29 94 void
Chris@36 95 Layer::showLayer(View *view, bool show)
Chris@29 96 {
Chris@36 97 setLayerDormant(view, !show);
Chris@29 98 emit layerParametersChanged();
Chris@29 99 }
Chris@28 100
Chris@28 101
Chris@0 102 #ifdef INCLUDE_MOCFILES
Chris@0 103 #include "Layer.moc.cpp"
Chris@0 104 #endif
Chris@0 105