Mercurial > hg > svgui
comparison layer/ImageLayer.h @ 303:46faec7aae12
* Phase 1 of an image layer.
author | Chris Cannam |
---|---|
date | Thu, 04 Oct 2007 16:34:11 +0000 |
parents | |
children | 4b7e8da8f069 |
comparison
equal
deleted
inserted
replaced
302:e9549ea3f825 | 303:46faec7aae12 |
---|---|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ | |
2 | |
3 /* | |
4 Sonic Visualiser | |
5 An audio file viewer and annotation editor. | |
6 Centre for Digital Music, Queen Mary, University of London. | |
7 This file copyright 2006-2007 Chris Cannam and QMUL. | |
8 | |
9 This program is free software; you can redistribute it and/or | |
10 modify it under the terms of the GNU General Public License as | |
11 published by the Free Software Foundation; either version 2 of the | |
12 License, or (at your option) any later version. See the file | |
13 COPYING included with this distribution for more information. | |
14 */ | |
15 | |
16 #ifndef _IMAGE_LAYER_H_ | |
17 #define _IMAGE_LAYER_H_ | |
18 | |
19 #include "Layer.h" | |
20 #include "data/model/ImageModel.h" | |
21 | |
22 #include <QObject> | |
23 #include <QColor> | |
24 #include <QImage> | |
25 | |
26 #include <map> | |
27 | |
28 class View; | |
29 class QPainter; | |
30 | |
31 class ImageLayer : public Layer | |
32 { | |
33 Q_OBJECT | |
34 | |
35 public: | |
36 ImageLayer(); | |
37 | |
38 virtual void paint(View *v, QPainter &paint, QRect rect) const; | |
39 | |
40 virtual QString getFeatureDescription(View *v, QPoint &) const; | |
41 | |
42 virtual bool snapToFeatureFrame(View *v, int &frame, | |
43 size_t &resolution, | |
44 SnapType snap) const; | |
45 | |
46 virtual void drawStart(View *v, QMouseEvent *); | |
47 virtual void drawDrag(View *v, QMouseEvent *); | |
48 virtual void drawEnd(View *v, QMouseEvent *); | |
49 | |
50 virtual void editStart(View *v, QMouseEvent *); | |
51 virtual void editDrag(View *v, QMouseEvent *); | |
52 virtual void editEnd(View *v, QMouseEvent *); | |
53 | |
54 virtual void moveSelection(Selection s, size_t newStartFrame); | |
55 virtual void resizeSelection(Selection s, Selection newSize); | |
56 virtual void deleteSelection(Selection s); | |
57 | |
58 virtual void copy(Selection s, Clipboard &to); | |
59 virtual bool paste(const Clipboard &from, int frameOffset, | |
60 bool interactive); | |
61 | |
62 virtual bool editOpen(View *, QMouseEvent *); // on double-click | |
63 | |
64 virtual const Model *getModel() const { return m_model; } | |
65 void setModel(ImageModel *model); | |
66 | |
67 virtual PropertyList getProperties() const; | |
68 virtual QString getPropertyLabel(const PropertyName &) const; | |
69 virtual PropertyType getPropertyType(const PropertyName &) const; | |
70 virtual int getPropertyRangeAndValue(const PropertyName &, | |
71 int *min, int *max, int *deflt) const; | |
72 virtual QString getPropertyValueLabel(const PropertyName &, | |
73 int value) const; | |
74 virtual void setProperty(const PropertyName &, int value); | |
75 | |
76 virtual ColourSignificance getLayerColourSignificance() const { | |
77 return ColourAbsent; | |
78 } | |
79 | |
80 virtual bool isLayerScrollable(const View *v) const; | |
81 | |
82 virtual bool isLayerEditable() const { return true; } | |
83 | |
84 virtual int getCompletion(View *) const { return m_model->getCompletion(); } | |
85 | |
86 virtual bool getValueExtents(float &min, float &max, | |
87 bool &logarithmic, QString &unit) const; | |
88 | |
89 virtual QString toXmlString(QString indent = "", | |
90 QString extraAttributes = "") const; | |
91 | |
92 virtual void setLayerDormant(const View *v, bool dormant); | |
93 | |
94 void setProperties(const QXmlAttributes &attributes); | |
95 | |
96 protected: | |
97 ImageModel::PointList getLocalPoints(View *v, int x, int y) const; | |
98 | |
99 float getImageAspect(QString name) const; | |
100 QImage getImage(View *v, QString name, QSize maxSize) const; | |
101 | |
102 //!!! how to reap no-longer-used images? | |
103 | |
104 typedef std::map<QString, QImage> ImageMap; | |
105 typedef std::map<const View *, ImageMap> ViewImageMap; | |
106 | |
107 static ImageMap m_images; | |
108 mutable ViewImageMap m_scaled; | |
109 | |
110 ImageModel *m_model; | |
111 bool m_editing; | |
112 QPoint m_editOrigin; | |
113 ImageModel::Point m_originalPoint; | |
114 ImageModel::Point m_editingPoint; | |
115 ImageModel::EditCommand *m_editingCommand; | |
116 }; | |
117 | |
118 #endif | |
119 |