tolinechart.h

Ir a la documentación de este archivo.
00001 //***************************************************************************
00002 /*
00003  * TOra - An Oracle Toolkit for DBA's and developers
00004  * Copyright (C) 2000-2001,2001 Underscore AB
00005  * 
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation;  only version 2 of
00009  * the License is valid for this program.
00010  * 
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  * 
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00019  *
00020  *      As a special exception, you have permission to link this program
00021  *      with the Oracle Client libraries and distribute executables, as long
00022  *      as you follow the requirements of the GNU GPL in regard to all of the
00023  *      software in the executable aside from Oracle client libraries.
00024  *
00025  *      Specifically you are not permitted to link this program with the
00026  *      Qt/UNIX, Qt/Windows or Qt Non Commercial products of TrollTech.
00027  *      And you are not permitted to distribute binaries compiled against
00028  *      these libraries without written consent from Underscore AB. Observe
00029  *      that this does not disallow linking to the Qt Free Edition.
00030  *
00031  * All trademarks belong to their respective owners.
00032  *
00033  ****************************************************************************/
00034 
00035 #ifndef __TOLINECHART_H
00036 #define __TOLINECHART_H
00037 
00038 #include <list>
00039 #include <qwidget.h>
00040 
00041 class QPopupMenu;
00042 
00045 class toLineChart : public QWidget {
00046   Q_OBJECT
00047 
00048   QPopupMenu *Menu;
00049 
00050 protected:
00051   std::list<std::list<double> > Values;
00052   std::list<QString> XValues;
00053   std::list<QString> Labels;
00054   bool Legend;
00055   bool Last;
00056   int Grid;
00057   bool AxisText;
00058   double MinValue;
00059   bool MinAuto;
00060   double MaxValue;
00061   bool MaxAuto;
00062   QString YPostfix;
00063   int Samples;
00064   QString Title;
00065 
00066   QRect Chart;
00067   QPoint MousePoint[2];
00068   int SkipSamples;
00069   int UseSamples;
00070   bool Zooming;
00071   double zMinValue;
00072   double zMaxValue;
00073 
00074   static double round(double round,bool up);
00075   QRect fixRect(QPoint p1,QPoint p2);
00076   virtual void mouseReleaseEvent(QMouseEvent *e);
00077   virtual void mouseMoveEvent(QMouseEvent *e);
00078   virtual void mouseDoubleClickEvent(QMouseEvent *e);
00079   virtual void mousePressEvent(QMouseEvent *e);
00080 
00081   int countSamples(void);
00082   void clearZoom(void);
00083 
00084   virtual void paintLegend(QPainter *p,QRect &rect);
00085   virtual void paintTitle(QPainter *p,QRect &rect);
00086   virtual void paintAxis(QPainter *p,QRect &rect);
00087   virtual void paintChart(QPainter *p,QRect &rect);
00088 public:
00094   toLineChart(QWidget *parent=NULL,const char *name=NULL,WFlags f=0);
00095 
00102   toLineChart(toLineChart *chart,QWidget *parent=NULL,const char *name=NULL,WFlags f=0);
00103 
00107   void showLegend(bool on)
00108   { Legend=on; update(); }
00112   bool legend(void) const
00113   { return Legend; }
00114 
00118   void showLast(bool on)
00119   { Last=on; update(); }
00123   bool last(void) const
00124   { return Last; }
00125 
00129   void setTitle(const QString &title=QString::null)
00130   { Title=title; update(); }
00134   const QString &title(void)
00135   { return Title; }
00136 
00140   void showGrid(int div=0)
00141   { Grid=div; update(); }
00145   int grid(void) const
00146   { return Grid; }
00147 
00151   void showAxisLegend(bool on)
00152   { AxisText=on; update(); }
00156   bool axisLegend(void) const
00157   { return AxisText; }
00158 
00162   void setYPostfix(const QString &postfix)
00163   { YPostfix=postfix; update(); }
00166   void setMaxValueAuto(void)
00167   { MaxAuto=true; update(); }
00170   void setMinValueAuto(void)
00171   { MinAuto=true; update(); }
00175   void setMaxValue(double maxVal)
00176   { MaxAuto=false; MaxValue=maxVal; update(); }
00180   void setMinValue(double minVal)
00181   { MinAuto=false; MinValue=minVal; update(); }
00185   double minValue(void) const
00186   { return MinValue; }
00190   double maxValue(void) const
00191   { return MaxValue; }
00192 
00196   void setSamples(int samples=-1);
00200   int samples(void) const
00201   { return Samples; }
00202 
00206   void setLabels(const std::list<QString> &labels)
00207   { Labels=labels; update(); }
00211   std::list<QString> &labels(void)
00212   { return Labels; }
00213 
00218   virtual void addValues(std::list<double> &value,const QString &xValues);
00219 
00223   std::list<QString> &xValues(void)
00224   { return XValues; }
00225 
00229   std::list<std::list<double> > &values(void)
00230   { return Values; }
00231 
00232 public slots:
00235   virtual void clear(void)
00236   { Values.clear(); XValues.clear(); update(); }
00237 
00240   virtual void setup(void);
00241 
00244   virtual void editPrint(void);
00245 
00248   virtual void openCopy(void);
00249 protected:
00252   virtual void paintEvent(QPaintEvent *e);
00253 };
00254 
00255 
00259 template <class T>
00260 T max(T a, T b)
00261 {
00262     return a > b ? a : b ;
00263 }
00264 
00268 template <class T>
00269 T min(T a, T b)
00270 {
00271     return a < b ? a : b ;
00272 }
00273 
00274 #endif

Generado el Sat May 21 00:04:45 2005 para BulmaGes por  doxygen 1.4.2