Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

plot.h

Go to the documentation of this file.
00001 /*
00002  * MAX : plot.h, Sam Dez 29 20:00:12 CET 2001 -sg
00003  *
00004  * Plot widget to plot measured data for max data acquisition software
00005  * header file
00006  *
00007  * This file is part of Max data acquisition software
00008  * Copyright (C) 1997,98 Christian Rosen
00009  *
00010  * Max is free software; you can redistribute it and/or modify it
00011  * under the terms of the version 2 of GNU General Public License as
00012  * published by the Free Software Foundation.
00013  *
00014  * Max is distributed in the hope that it will be useful, but WITHOUT
00015  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00016  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00017  * for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * (see the file COPYING) in this directory; if not, write to the
00021  * Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00022  */
00023 
00024 //#include "qtincludes.h"
00025 #include "definitions.h"
00026 #include "packet.h"
00027 
00028 //qt includes
00029 #include <qwidget.h>
00030 #include <qpainter.h>
00031 #include <qlist.h>
00032 #include <qlabel.h>
00033 #include <qmenubar.h>
00034 #include <qcolor.h>
00035 #include <qlineedit.h>
00036 #include <qpushbutton.h>
00037 #include <qtoolbar.h>
00038 #include <qprinter.h>
00039 
00040 //Standard template Lib (STL)  includes
00041 #include <vector>
00042 
00043 #ifndef _PLOT_H_
00044 #define _PLOT_H_
00045 /************************************
00046  * Options widget to set y - scales *
00047  ***********************************/
00048 class ScaleW : public QWidget{
00049         Q_OBJECT
00050 public:
00051         ScaleW(char *,double, double/*,QWidget *parent = 0,const char* name = 0*/);
00052 signals :
00053         void SIG_setlimits(double,double);
00054 public slots :
00055         void  okpressed();
00056         void  cancelpressed();
00057 private :
00058   QLineEdit   *limEdit;
00059   QLineEdit   *limEdit2;        
00060   QLabel      *label1;
00061   QLabel      *label2;  
00062   QLabel      *headline;
00063   QPushButton *ok;
00064   QPushButton *cancel;
00065 };
00066 
00067 //defines for the plotwidget
00068 #define PWidget_X    200
00069 #define PWidget_Y    300
00070 
00071 //This structure contains one point to plot
00072 //This class contains a vector of this structure to handle plotdata
00073 typedef struct {
00074   int     x;
00075   double  y;
00076 } point;
00077 
00078 
00079 class Plot : public QMainWindow  {
00080         Q_OBJECT;
00081 public :
00082   Plot(QWidget *parent = 0, const char *name =0,char *devname =0,char *varname =0,int chan=1000 ,int m = FALSE);
00083   ~Plot();
00084   void plotPoint(int ,int );         //plot point at channel x and y
00085   void plotPoint(int, double);       //plot double
00086   void plotPoint(int ,int *,int);    //plot array of channel x
00087   void plotPoint(int, double *,int); //parameters are : channel, array,length
00088   void plotPoint(int/* chan=0*/, vector<int>* ,int );    //store vector of int in local plotbuffer
00089   void plotPoint(int, vector<double> *,int); //store vector of double in local plotbuffer
00090   void setYAxis(int ,int ,int);      //type, lower , upper limit
00091   void setXAxis(int, int, int);      //type , lower , upper limit -> convert channel numbers here
00092   void setXText(char *);
00093   void setYText(char *);
00094   void totalScalingOn();  //graph scales with windowsize
00095   void totalScalingOff(); //graph gets scrollbars
00096   void setLinestyle(int );
00097   void setTitle(char *);
00098   void setColors(QColor, QColor,QColor );
00099   void SetAllOptions(PlotSettings *);
00100   void refresh(void);  //force update of plotwidget -> draw the data
00101 public slots:
00102   void SLOT_set_scales( double, double ); //called from setscales widget
00103   void setscales();
00104   void updateOn();
00105   void updateOff();
00106   void autoscaleOn();
00107   void autoscaleOff();
00108   void toggleAS();
00109   void hgridOff();
00110   void hgridOn();
00111   void vgridOn();
00112   void vgridOff();
00113   //  void setLineStyle(int );
00114 
00115 private slots:  
00116   void save();   //save the data currently visible
00117   void print();//prints the data currently visible
00118   void kill();
00119 
00120 protected:
00121   void resizeEvent( QResizeEvent * );
00122   void paintEvent( QPaintEvent *);
00123   void mouseMoveEvent( QMouseEvent *);
00124   void DrawPlot( QPainter *);
00125   void DrawAxes( QPainter *);
00126 
00127 private slots :
00128   void del();
00129 
00130 private :
00131   //first, Qt stuff :
00132   QPrinter *printer;
00133   QToolBar *fileTools;
00134 
00135   QMenuBar *menu;
00136   QLabel   *Title;
00137   QLabel   *XLabel;
00138   QLabel   *YTitle;
00139   QLabel   *RightSpace;
00140   QLabel   *PlotLabel;  // this label contains the main pixmap
00141   QLabel   *XAxisLabel; //these labels contains the axis pixmaps
00142   QLabel   *YAxisLabel;
00143   QLabel   *xval;       //cursorposition on plotwindow
00144   QLabel   *yval;
00145   QLabel   *as;         //show autoscale status
00146   
00147   // Color settings
00148   QColor  axiscolor;  //color of axis and ticks
00149   QColor  linecolor;  //color of gridlines
00150   QColor  background;
00151   QColor  labelcolor;
00152   QColor  arraylinecolor; //color if dataset is array
00153   QColor  datacolor; //color of datase
00154   ScaleW  *SW;       //Widget to enter scaling
00155   
00156   //regular variables
00157   bool draw_axis;  //for repaint event, don't always redraw the axes
00158   bool autoscale;
00159   bool hgrid;      //draw horizontal gridlines
00160   bool vgrid;      //draw vertical gridlines
00161   int type;           //type of data in database (int or double) for save routine int = 0, double =1
00162   int l_plimit;
00163   int as_interval;
00164   int as_counter;     //counter for number of points to be above upper limit
00165   int las_counter;    //dito below lower limit
00166   int pXsize,pYsize;  //sizes of plotwindow
00167   int pXpos,pYpos;    //upper left corent of plotarea
00168   int xticks;         //number of ticks for the axes
00169   int yticks;
00170   double ylow,yhigh;
00171   double xlow,xhigh;
00172   double xscale,yscale;
00173   double scale;
00174   double offset;
00175   int  PLeftBorder,PUpperBorder;
00176   int ticksize;
00177   int tickpos,tickposx;
00178   int monitor_mode; //if monmode set chan = 1000 + replot after 1000 channels
00179   bool upd;   //this flag indicates wether window should be cleared before next plot
00180   int  arrays;                  //indicator where to take data from
00181   vector<int>    *iVecPtr;      //Pointer to vector of integers
00182   vector<double> *dVecPtr;      //Pointer to vector of doubles
00183   int    array_length;
00184   //variables to specifiy the plot  data
00185   int deviceIndex;
00186   int varIndex;
00187   int linestyle;      //draw points or lines -> see defintions.h
00188   char *devName;
00189   char *varName;
00190   double dmax,dmin;
00191   int  max,min;
00192   int  pminsizex;
00193   int  pminsizey;
00194   int  last_x;        //intervall in x-coordinates data has to be refreshed in
00195   int  new_x;
00196   int  l_plotlim;     //index of database to plot from
00197   char  *va_name;     //name of variable to be plotted
00198   vector<point>  plotVec; //this vector contains all the plot data
00199 };
00200 
00201 #endif

Generated at Mon Sep 2 18:21:04 2002 for MAX by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001