SciFigs/XYPlot.h
Go to the documentation of this file.
00001 /***************************************************************************
00002 **
00003 **  This file is part of SciFigs.
00004 **
00005 **  This library is free software; you can redistribute it and/or
00006 **  modify it under the terms of the GNU Lesser General Public
00007 **  License as published by the Free Software Foundation; either
00008 **  version 2.1 of the License, or (at your option) any later version.
00009 **
00010 **  This file is distributed in the hope that it will be useful, but WITHOUT
00011 **  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 **  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
00013 **  License for more details.
00014 **
00015 **  You should have received a copy of the GNU Lesser General Public
00016 **  License along with this library; if not, write to the Free Software
00017 **  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00018 **
00019 **  See http://www.geopsy.org for more information.
00020 **
00021 **  Created : 2002-05-07
00022 **  Authors :
00023 **    Marc Wathelet
00024 **    Marc Wathelet (ULg, Liège, Belgium)
00025 **    Marc Wathelet (LGIT, Grenoble, France)
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   // Calculate the rectangle that includes all the point
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 } // namespace SciFigs
00110 
00111 #endif // XYPLOT_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines