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 GRAPHCONTENT_H
00030 #define GRAPHCONTENT_H
00031
00032 #include "SciFigsDLLExport.h"
00033 #include "Axis.h"
00034 #include "GraphContentOptions.h"
00035 #include "GraphContentLayer.h"
00036 #include "PaintProgress.h"
00037
00038 namespace SciFigs {
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054 class CoordTip;
00055 class LayerMouseTracking;
00056 class MouseTracking;
00057 class LayerPainter;
00058 class PaintProgress;
00059
00060 typedef QMap<GraphContentLayer *, QImage> LayerImages;
00061
00062 class SCIFIGS_EXPORT GraphContent : public QWidget, public PropertyItem, public XMLClass
00063 {
00064 Q_OBJECT
00065
00066 Q_PROPERTY(QString objectName READ objectName WRITE setObjectName STORED true)
00067
00068 Q_PROPERTY(QString name READ dummyPropertyString WRITE setObjectName STORED false)
00069 Q_PROPERTY(double printLineWeight READ dummyPropertyDouble WRITE setLineWeights STORED false)
00070
00071 Q_PROPERTY(bool gridLines READ gridLines WRITE setGridLines SCRIPTABLE true)
00072 Q_PROPERTY(QColor gridLineColor READ gridLineColor WRITE setGridLineColor SCRIPTABLE true)
00073 Q_PROPERTY(bool printBitmap READ printBitmap WRITE setPrintBitmap SCRIPTABLE true)
00074 Q_PROPERTY(bool transparentMask READ transparentMask WRITE setTransparentMask SCRIPTABLE true)
00075 Q_PROPERTY(double gridLineWeight READ gridLineWeight WRITE setGridLineWeight SCRIPTABLE true)
00076 Q_PROPERTY(double contourWeight READ contourWeight WRITE setContourWeight SCRIPTABLE true)
00077 DUMMY_PROPERTIES;
00078 public:
00079 GraphContent(AxisWindow * parent);
00080 ~GraphContent();
00081
00082 virtual const QString& xml_tagName() const {return xmlGraphContentTag;}
00083 static const QString xmlGraphContentTag;
00084
00085 virtual void polish();
00086
00087
00088 void addLayer(GraphContentLayer * layer);
00089 void removeLayer(GraphContentLayer * layer);
00090 void moveLayerUp(GraphContentLayer * layer);
00091 void moveLayerDown(GraphContentLayer * layer);
00092
00093
00094 AxisWindow * graph() const {return reinterpret_cast<AxisWindow *>(parent());}
00095 const GraphContentOptions& options() const {return *_d;}
00096
00097 Scale& scaleX() {return _d->scaleX();}
00098 Scale& scaleY() {return _d->scaleY();}
00099 const Scale& constScaleX() const {return _d->scaleX();}
00100 const Scale& constScaleY() const {return _d->scaleY();}
00101
00102 void paintMask(QPainter& p);
00103 void print (QPainter& p, double dotpercm, int w, int h, bool mask);
00104
00105 bool gridLines() const {return _d->gridLines();}
00106 void setGridLines(bool gl) {_d->setGridLines(gl);}
00107
00108 const QColor& gridLineColor() const {return _d->gridLineColor();}
00109 void setGridLineColor(const QColor& c) {_d->setGridLineColor(c);}
00110
00111 double gridLineWeight() const {return _d->gridLineWeight();}
00112 void setGridLineWeight(double lw) {_d->setGridLineWeight(lw);}
00113
00114 double contourWeight() const {return _d->contourWeight();}
00115 void setContourWeight(double lw) {_d->setContourWeight(lw);}
00116
00117 void setLineWeights(double lw);
00118
00119 bool transparentMask() const {return _d->transparentMask();}
00120 void setTransparentMask(bool tm) {_d->setTransparentMask(tm);}
00121
00122 bool printBitmap() const {return _d->printBitmap();}
00123 void setPrintBitmap(bool sbmp) {_d->setPrintBitmap(sbmp);}
00124
00125 #ifdef GRAPHCONTENT_PIXMAP
00126 QPixmap * pixmap() {if(_pixmap.isNull()) return 0; else return &_pixmap;}
00127 #else
00128 QImage * pixmap() {if(_pixmap.isNull()) return 0; else return &_pixmap;}
00129 #endif
00130 QAction * action(QString actionName);
00131 QAction * addAction(QString actionName);
00132 void zoomIn (const QPoint& c);
00133 Rect boundingRect() const;
00134 void swapAxes() {_d->swapAxes();}
00135
00136 static void init();
00137 static void clear();
00138 QString coordinateTipText(const QPoint& mousePos);
00139 void delayPainting();
00140
00141 inline void setProgressMaximum(int value);
00142 inline void setProgressValue(int value);
00143 void setProgressEnd();
00144
00145 void addProperties(PropertyProxy * pp);
00146 void addProperties(GraphContentLayer * layer);
00147 void removeProperties(PropertyProxy * pp);
00148 virtual void properties(PropertyWidget * w) const;
00149 virtual void setProperty(uint wid, int pid, QVariant val);
00150
00151 int layerCount() {return _layers.count();}
00152 GraphContentLayer * findLayer(QString tagName, QString layerName=QString::null, int startIndex=0);
00153 public slots:
00154 void zoom();
00155 void zoomIn();
00156 void unzoom();
00157 void browse();
00158 void saveLayers(QString fileName=QString::null);
00159 void addLayers(QString fileName=QString::null);
00160 void copyLayers();
00161 void pasteLayers();
00162 void deepUpdate(int fromLayer=0);
00163 private:
00164 friend class GraphContentLayer;
00165 friend class LayerPropertiesItem;
00166 friend class CoordTip;
00167
00168 virtual bool event(QEvent * e);
00169 virtual void keyPressEvent(QKeyEvent * e);
00170 virtual void keyReleaseEvent(QKeyEvent * e);
00171 virtual void mousePressEvent(QMouseEvent * e);
00172 virtual void mouseReleaseEvent(QMouseEvent * e);
00173 virtual void mouseMoveEvent(QMouseEvent * e);
00174 virtual void wheelEvent(QWheelEvent * e);
00175 virtual void leaveEvent(QEvent *);
00176 virtual void enterEvent(QEvent *);
00177 virtual void paintEvent(QPaintEvent * e);
00178 virtual void resizeEvent(QResizeEvent *);
00179
00180 void setDefaultCursor();
00181 void addActions();
00182
00183 enum TrackingModes{Zoom=0, Browse};
00184 void beginMouseTracking(const LayerMouseTracking& layer);
00185 void endMouseTracking(GraphContentLayer * layer, int id);
00186 bool isMouseTracking(GraphContentLayer * layer, int id) const;
00187 MouseTracking * _mouseTracking;
00188
00189
00190 QList<GraphContentLayer *> _layers;
00191
00192 int indexOf(GraphContentLayer * layer) {return _layers.indexOf(layer);}
00193 GraphContentLayer * layer(int index) {return _layers.at(index);}
00194
00195 static CoordTip * _coordTip;
00196
00197
00198 void resizePixmap();
00199 #ifdef GRAPHCONTENT_PIXMAP
00200 QPixmap _pixmap;
00201 #else
00202 QImage _pixmap;
00203 #endif
00204 LayerImages _layerImages;
00205 QTime _paintEventTiming;
00206 QTimer _paintEventDelay;
00207 int _paintDepth;
00208 static LayerPainter * _layerPainter;
00209 PaintProgress * _progress;
00210
00211
00212 QSharedDataPointer<GraphContentOptions> _d;
00213
00214
00215 QPoint _mouseMovePoint;
00216 Qt::MouseButtons _mouseMoveButtons;
00217 Qt::KeyboardModifiers _mouseMoveModifiers;
00218 QTimer _mouseMoveDelay;
00219 static QCursor * _defaultCursor;
00220
00221 static uint _categoryGraphic, _categoryLayers, _tabGraphicFormat, _tabGraphicLayers;
00222 protected:
00223 virtual void xml_writeProperties(XML_WRITEPROPERTIES_ARGS) const;
00224 virtual void xml_writeChildren(XML_WRITECHILDREN_ARGS) const;
00225 virtual XMLMember xml_member(XML_MEMBER_ARGS);
00226 virtual void xml_polishChild(XML_POLISHCHILD_ARGS);
00227 virtual void xml_polish(XML_POLISH_ARGS);
00228 virtual bool xml_setProperty(XML_SETPROPERTY_ARGS) {return qobject_setProperty(this, memberID, tag, attributes, content, context);}
00229 private slots:
00230 void delayedMouseMoveEvent();
00231 void setPixmap(QImage image, LayerImages layerImages);
00232 void paintProgress();
00233 signals:
00234 void zoomIn(double, double, double, double);
00235 void zoomOut();
00236 void browse(QRect& r);
00237 void mouseTrackingBegin();
00238 void mouseTrackingEnd();
00239 void mouseMoved(QPoint, Qt::MouseButtons, Qt::KeyboardModifiers);
00240 void mouseInside(bool);
00241 };
00242
00243 inline void GraphContent::setProgressMaximum(int value)
00244 {
00245 _progress->setMaximum(value);
00246 }
00247
00248 inline void GraphContent::setProgressValue(int value)
00249 {
00250 _progress->setValue(value);
00251 }
00252
00253 }
00254
00255 #endif // GRAPHCONTENT_H