Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef GRAPHCONTENTLAYER_H
00030 #define GRAPHCONTENTLAYER_H
00031
00032 #include <QtGui>
00033 #include <QGpGuiTools.h>
00034 #include "SciFigsDLLExport.h"
00035
00036 namespace SciFigs {
00037
00038 class GraphContent;
00039 class AxisWindow;
00040 class GraphContentProperties;
00041 class LayerMouseTracking;
00042 class LayerPainterRequest;
00043 class GraphContentOptions;
00044
00045
00046
00047 class SCIFIGS_EXPORT GraphContentLayer : public QObject, public PropertyItem, public XMLClass
00048 {
00049 Q_OBJECT
00050
00051 Q_PROPERTY(QString objectName READ objectName WRITE setObjectName STORED true)
00052
00053 Q_PROPERTY(QString name READ dummyPropertyString WRITE setObjectName STORED false)
00054
00055 Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity STORED true)
00056 DUMMY_PROPERTIES;
00057 public:
00058 GraphContentLayer(AxisWindow * parent=0);
00059
00060 virtual const QString& xml_tagName() const {return xmlGraphContentLayerTag;}
00061 static const QString xmlGraphContentLayerTag;
00062
00063 void lock() {_mutex.lock();}
00064 void lockDelayPainting();
00065 void unlock() {_mutex.unlock();}
00066
00067 virtual void setParent(GraphContent * parent);
00068
00069 GraphContent * graphContent() {return reinterpret_cast<GraphContent *>(parent());}
00070 const GraphContent * graphContent() const {return reinterpret_cast<const GraphContent *>(parent());}
00071
00072 AxisWindow * graph() const {return reinterpret_cast<AxisWindow *>(parent()->parent());}
00073
00074
00075 virtual bool mousePressEvent (QMouseEvent * e, int id=-1) {Q_UNUSED(e); Q_UNUSED(id); return true;}
00076 virtual bool mouseReleaseEvent (QMouseEvent * e, int id=-1) {Q_UNUSED(e); Q_UNUSED(id); return true;}
00077 virtual void mouseMoveEvent (const QPoint& pt, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers) {
00078 Q_UNUSED(pt);
00079 Q_UNUSED(buttons);
00080 Q_UNUSED(modifiers);
00081 }
00082 virtual bool wheelEvent(QWheelEvent * e) {Q_UNUSED(e); return true;}
00083 virtual bool keyPressEvent(QKeyEvent* e) {Q_UNUSED(e); return true;}
00084 virtual bool keyReleaseEvent(QKeyEvent* e) {Q_UNUSED(e); return true;}
00085 virtual inline bool trackRectangle(int id, double rx1,double ry1, double rx2, double ry2, Qt::KeyboardModifiers m);
00086 void paint(const LayerPainterRequest& lp, QPainter& p, double dotpercm);
00087 virtual inline void paintText(const LayerPainterRequest& lp, double dotpercm);
00088 virtual Rect boundingRect() const=0;
00089 virtual QString coordinateTipInfo(const Point2D& p) const;
00090
00091 void setOpacity(qreal o);
00092 qreal opacity() const {return _opacity;}
00093
00094 void addReference() {_referenceCount++;}
00095 void removeReference() {_referenceCount--; ASSERT(_referenceCount>=0);}
00096 bool isRemovable() const {return _referenceCount==0;}
00097
00098 void setEditable(bool r) {_isEditable=r;}
00099 bool isEditable() const {return _isEditable;}
00100
00101 void setSelected(bool s) {_isSelected=s;}
00102 bool isSelected() const {return _isSelected;}
00103
00104 QAction * addTrackingAction(QString text, int id=0, QString statusTip=QString::null);
00105 void setTrackingAction(int id, bool checked);
00106 static QString trackingActionCtrlHelp();
00107
00108 virtual bool hasProperties() {return false;}
00109 virtual void addProperties(PropertyProxy * ) {}
00110 virtual void removeProperties(PropertyProxy * ) {}
00111 virtual void properties(PropertyWidget * ) const {}
00112 virtual void setProperty(uint , int , QVariant ) {}
00113
00114 virtual void xml_layerPolish(XML_POLISH_ARGS) {Q_UNUSED(context);}
00115 public slots:
00116 Q_SCRIPTABLE void deepUpdate();
00117 virtual void toggleTrackingAction(bool checked, int id=-1);
00118 signals:
00119 void dataPainted(QPainter& p, double dotpercm, int w, int h) const;
00120 protected:
00121 virtual void xml_writeProperties(XML_WRITEPROPERTIES_ARGS) const;
00122 virtual XMLMember xml_member(XML_MEMBER_ARGS);
00123 virtual bool xml_setProperty(XML_SETPROPERTY_ARGS) {return qobject_setProperty(this, memberID, tag, attributes, content, context);}
00124 #ifdef GRAPHCONTENTLAYER_TESTING
00125 virtual void paintData(const LayerPainterRequest& lp, QPainter& p, double dotpercm) const;
00126 #else
00127 virtual void paintData(const LayerPainterRequest& lp, QPainter& p, double dotpercm) const=0;
00128 #endif
00129 void beginMouseTracking(const LayerMouseTracking& mt);
00130 void endMouseTracking(int id=0);
00131 bool isMouseTracking(int id=0);
00132
00133
00134 qreal _opacity;
00135 int _referenceCount;
00136 uint _isEditable:1;
00137 uint _isSelected:1;
00138
00139
00140 mutable QMutex _mutex;
00141 };
00142
00143 inline bool GraphContentLayer::trackRectangle(int id, double rx1,double ry1, double rx2, double ry2, Qt::KeyboardModifiers m)
00144 {
00145 TRACE;
00146 Q_UNUSED(id);
00147 Q_UNUSED(rx1);
00148 Q_UNUSED(ry1);
00149 Q_UNUSED(rx2);
00150 Q_UNUSED(ry2);
00151 Q_UNUSED(m);
00152 return false;
00153 }
00154
00155 inline void GraphContentLayer::paintText(const LayerPainterRequest& lp, double dotpercm)
00156 {
00157 TRACE;
00158 Q_UNUSED(lp);
00159 Q_UNUSED(dotpercm);
00160 }
00161
00162 }
00163
00164 #endif // GRAPHCONTENTLAYER_H