Chris@0: /* -*- c-basic-offset: 4 -*- vi:set ts=8 sts=4 sw=4: */ Chris@0: Chris@0: /* Chris@0: A waveform viewer and audio annotation editor. Chris@2: Chris Cannam, Queen Mary University of London, 2005-2006 Chris@0: Chris@0: This is experimental software. Not for distribution. Chris@0: */ Chris@0: Chris@0: #include "Layer.h" Chris@0: #include "View.h" Chris@0: Chris@0: #include Chris@0: Chris@3: #include "layer/LayerFactory.h" //!!! shouldn't be including this here -- does that suggest we need to move this into layer/ ? Chris@28: #include "PlayParameterRepository.h" Chris@3: Chris@29: Layer::Layer(View *w) : Chris@29: m_dormant(false) Chris@0: { Chris@0: m_view = w; Chris@0: Chris@0: // Subclass must call this: Chris@0: // w->addLayer(this); Chris@0: } Chris@0: Chris@0: Layer::~Layer() Chris@0: { Chris@0: m_view->removeLayer(this); Chris@0: } Chris@0: Chris@12: QString Chris@12: Layer::getPropertyContainerIconName() const Chris@12: { Chris@12: return LayerFactory::instance()->getLayerIconName Chris@12: (LayerFactory::instance()->getLayerType(this)); Chris@12: } Chris@12: Chris@0: void Chris@0: Layer::setObjectName(const QString &name) Chris@0: { Chris@0: QObject::setObjectName(name); Chris@0: emit layerNameChanged(); Chris@0: } Chris@0: Chris@15: int Chris@15: Layer::getXForFrame(long frame) const Chris@15: { Chris@15: if (m_view) return m_view->getXForFrame(frame); Chris@15: else return 0; Chris@15: } Chris@15: Chris@15: long Chris@15: Layer::getFrameForX(int x) const Chris@15: { Chris@15: if (m_view) return m_view->getFrameForX(x); Chris@15: else return 0; Chris@15: } Chris@15: Chris@3: QString Chris@3: Layer::toXmlString(QString indent, QString extraAttributes) const Chris@3: { Chris@3: QString s; Chris@3: Chris@3: s += indent; Chris@3: Chris@6: s += QString("\n") Chris@3: .arg(LayerFactory::instance()->getLayerTypeName Chris@3: (LayerFactory::instance()->getLayerType(this))) Chris@4: .arg(getObjectExportId(this)) Chris@3: .arg(objectName()) Chris@4: .arg(getObjectExportId(getModel())) Chris@3: .arg(extraAttributes); Chris@3: Chris@3: return s; Chris@3: } Chris@0: Chris@28: PlayParameters * Chris@29: Layer::getPlayParameters() Chris@28: { Chris@32: // std::cerr << "Layer (" << this << ", " << objectName().toStdString() << ")::getPlayParameters: model is "<< getModel() << std::endl; Chris@28: const Model *model = getModel(); Chris@28: if (model) { Chris@28: return PlayParameterRepository::instance()->getPlayParameters(model); Chris@28: } Chris@28: return 0; Chris@28: } Chris@28: Chris@29: void Chris@29: Layer::showLayer(bool show) Chris@29: { Chris@29: setLayerDormant(!show); Chris@29: emit layerParametersChanged(); Chris@29: } Chris@28: Chris@28: Chris@0: #ifdef INCLUDE_MOCFILES Chris@0: #include "Layer.moc.cpp" Chris@0: #endif Chris@0: