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 XYPLOT_H
00030 #define XYPLOT_H
00031
00032 #include "GraphicObject.h"
00033 #include "GraphContentLayer.h"
00034 #include "Symbol.h"
00035
00036 namespace SciFigs {
00037
00038 class XYPlotProperties;
00039
00040 class SCIFIGS_EXPORT XYPlot : public GraphContentLayer
00041 {
00042 Q_OBJECT
00043 Q_PROPERTY(double dotDiameter READ dotDiameter WRITE setDotDiameter SCRIPTABLE true)
00044 Q_PROPERTY(int count READ count STORED false SCRIPTABLE true)
00045 Q_PROPERTY(QString symbol READ symbolString WRITE setSymbol)
00046 public:
00047 XYPlot(AxisWindow * parent=0);
00048 ~XYPlot();
00049
00050 virtual const QString& xml_tagName() const {return xmlXYPlotTag;}
00051 static const QString xmlXYPlotTag;
00052
00053 int count() const {if(_xData) return _xData->count(); else return 0;}
00054
00055 void setXData(QVector<double> * x);
00056 void setYData(QVector<double> * y);
00057
00058 double dotDiameter() const {return _size;}
00059 void setDotDiameter (double d) {_size=d;}
00060
00061 Symbol::Type symbol() const {return _symbol;}
00062 QString symbolString() const {return Symbol::symbolName(_symbol);}
00063 void setSymbol(Symbol::Type s) {_symbol=s;}
00064 void setSymbol(const QString& s) {_symbol=Symbol::symbolValue(s);}
00065
00066 virtual bool trackRectangle(int, double rx1, double ry1, double rx2, double ry2,
00067 Qt::KeyboardModifiers eventState);
00068 virtual void select(QVector<int> * indexList);
00069
00070 virtual Rect boundingRect() const;
00071
00072 virtual bool hasProperties() {return true;}
00073 virtual void addProperties(PropertyProxy * pp);
00074 virtual void removeProperties(PropertyProxy * pp);
00075 virtual void properties(PropertyWidget * w) const;
00076 virtual void setProperty(uint wid, int pid, QVariant val);
00077 public slots:
00078 void swapXY();
00079 protected:
00080 virtual void paintData(const LayerPainterRequest& lp, QPainter& p, double dotpercm) const;
00081 inline void getPaintParam(int& count, double& pointSize,
00082 double& halfPointSize, double dotpercm) const;
00083
00084 QVector<double> * _xData;
00085 QVector<double> * _yData;
00086
00087 double _size;
00088 Symbol::Type _symbol;
00089
00090 static uint _tab;
00091
00092 virtual void xml_writeProperties(XML_WRITEPROPERTIES_ARGS) const;
00093 virtual void xml_writeBinaryData(XML_WRITEBINARYDATA_ARGS) const;
00094 virtual bool xml_setBinaryData(XML_SETBINARYDATA_ARGS);
00095 };
00096
00097 inline void XYPlot::getPaintParam(int& count, double& pointSize,
00098 double& halfPointSize, double dotpercm) const
00099 {
00100 TRACE;
00101 count=_xData->size();
00102 if(count>_yData->size()) {
00103 count=_yData->size();
00104 }
00105 pointSize=_size*dotpercm;
00106 halfPointSize=0.5*pointSize;
00107 }
00108
00109 }
00110
00111 #endif // XYPLOT_H