Chris@303: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@303: Chris@303: /* Chris@303: Sonic Visualiser Chris@303: An audio file viewer and annotation editor. Chris@303: Centre for Digital Music, Queen Mary, University of London. Chris@303: This file copyright 2006-2007 Chris Cannam and QMUL. Chris@303: Chris@303: This program is free software; you can redistribute it and/or Chris@303: modify it under the terms of the GNU General Public License as Chris@303: published by the Free Software Foundation; either version 2 of the Chris@303: License, or (at your option) any later version. See the file Chris@303: COPYING included with this distribution for more information. Chris@303: */ Chris@303: Chris@303: #ifndef _IMAGE_LAYER_H_ Chris@303: #define _IMAGE_LAYER_H_ Chris@303: Chris@303: #include "Layer.h" Chris@303: #include "data/model/ImageModel.h" Chris@303: Chris@303: #include Chris@303: #include Chris@303: #include Chris@303: Chris@303: #include Chris@303: Chris@303: class View; Chris@303: class QPainter; Chris@303: Chris@303: class ImageLayer : public Layer Chris@303: { Chris@303: Q_OBJECT Chris@303: Chris@303: public: Chris@303: ImageLayer(); Chris@303: Chris@303: virtual void paint(View *v, QPainter &paint, QRect rect) const; Chris@303: Chris@303: virtual QString getFeatureDescription(View *v, QPoint &) const; Chris@303: Chris@303: virtual bool snapToFeatureFrame(View *v, int &frame, Chris@303: size_t &resolution, Chris@303: SnapType snap) const; Chris@303: Chris@303: virtual void drawStart(View *v, QMouseEvent *); Chris@303: virtual void drawDrag(View *v, QMouseEvent *); Chris@303: virtual void drawEnd(View *v, QMouseEvent *); Chris@303: Chris@303: virtual void editStart(View *v, QMouseEvent *); Chris@303: virtual void editDrag(View *v, QMouseEvent *); Chris@303: virtual void editEnd(View *v, QMouseEvent *); Chris@303: Chris@303: virtual void moveSelection(Selection s, size_t newStartFrame); Chris@303: virtual void resizeSelection(Selection s, Selection newSize); Chris@303: virtual void deleteSelection(Selection s); Chris@303: Chris@303: virtual void copy(Selection s, Clipboard &to); Chris@303: virtual bool paste(const Clipboard &from, int frameOffset, Chris@303: bool interactive); Chris@303: Chris@303: virtual bool editOpen(View *, QMouseEvent *); // on double-click Chris@303: Chris@303: virtual const Model *getModel() const { return m_model; } Chris@303: void setModel(ImageModel *model); Chris@303: Chris@303: virtual PropertyList getProperties() const; Chris@303: virtual QString getPropertyLabel(const PropertyName &) const; Chris@303: virtual PropertyType getPropertyType(const PropertyName &) const; Chris@303: virtual int getPropertyRangeAndValue(const PropertyName &, Chris@303: int *min, int *max, int *deflt) const; Chris@303: virtual QString getPropertyValueLabel(const PropertyName &, Chris@303: int value) const; Chris@303: virtual void setProperty(const PropertyName &, int value); Chris@303: Chris@303: virtual ColourSignificance getLayerColourSignificance() const { Chris@303: return ColourAbsent; Chris@303: } Chris@303: Chris@303: virtual bool isLayerScrollable(const View *v) const; Chris@303: Chris@303: virtual bool isLayerEditable() const { return true; } Chris@303: Chris@303: virtual int getCompletion(View *) const { return m_model->getCompletion(); } Chris@303: Chris@303: virtual bool getValueExtents(float &min, float &max, Chris@303: bool &logarithmic, QString &unit) const; Chris@303: Chris@303: virtual QString toXmlString(QString indent = "", Chris@303: QString extraAttributes = "") const; Chris@303: Chris@303: virtual void setLayerDormant(const View *v, bool dormant); Chris@303: Chris@303: void setProperties(const QXmlAttributes &attributes); Chris@303: Chris@303: protected: Chris@303: ImageModel::PointList getLocalPoints(View *v, int x, int y) const; Chris@303: Chris@303: float getImageAspect(QString name) const; Chris@303: QImage getImage(View *v, QString name, QSize maxSize) const; Chris@303: Chris@303: //!!! how to reap no-longer-used images? Chris@303: Chris@303: typedef std::map ImageMap; Chris@303: typedef std::map ViewImageMap; Chris@303: Chris@303: static ImageMap m_images; Chris@303: mutable ViewImageMap m_scaled; Chris@303: Chris@303: ImageModel *m_model; Chris@303: bool m_editing; Chris@303: QPoint m_editOrigin; Chris@303: ImageModel::Point m_originalPoint; Chris@303: ImageModel::Point m_editingPoint; Chris@303: ImageModel::EditCommand *m_editingCommand; Chris@303: }; Chris@303: Chris@303: #endif Chris@303: