Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members

Worksheet.h

Go to the documentation of this file.
00001 #ifndef WORKSHEET_H
00002 #define WORKSHEET_H
00003 
00004 #include <qwidget.h>
00005 #include <qpainter.h>
00006 #include <qstring.h>
00007 #include <qfont.h>
00008 #include <qcolor.h>
00009 #include <qtextstream.h>
00010 #include <qdatetime.h>
00011 #include <kprinter.h>
00012 #include "MainWin.h"
00013 #include "Plot.h"
00014 #include "Label.h"
00015 #include "Line.h"
00016 #include "Rect.h"
00017 #include "Ellipse.h"
00018 #include "LImage.h"
00019 #include "widgettype.h"
00020 #include "scale.h"
00021 
00022 #define NR_PLOTS 16
00023 #define NR_OBJECTS 10
00024 
00025 class MainWin;
00026 class Plot;
00027 class Plot2DSimple;
00028 class Plot2DSurface;
00029 class Plot3D;
00030 class PlotQWT3D;
00031 class PlotPie;
00032 class PlotPolar;
00033 class PlotTernary;
00034 
00035 class Worksheet: public QWidget
00036 {
00037         Q_OBJECT
00038         Q_PROPERTY(QString title READ Title WRITE setTitle)
00039         Q_PROPERTY(bool title_enabled READ TitleEnabled WRITE setTitleEnabled)
00040         Q_PROPERTY(bool timestamp_enabled READ TimeStampEnabled WRITE setTimeStampEnabled)
00041         Q_PROPERTY(QDateTime timestamp READ TimeStamp WRITE setTimeStamp)
00042         Q_PROPERTY(QColor background READ Background WRITE setBackground)
00043 private:
00044         MainWin *mw;                                    // reference to the main window (for plotlist & messages)
00045         WidgetType widgettype;
00046         Plot *plot[NR_PLOTS];                   // list of plots
00047         KPrinter *printer;                              // printer for printing
00048         QPixmap *pixmap;                                // pixmap for drawing
00049         QString title;                                  
00050         bool title_enabled;                             
00051         QDateTime timestamp;                    
00052         bool timestamp_enabled;         
00053         QColor background;
00054         
00055         Label *label[NR_OBJECTS];
00056         Line *line[NR_OBJECTS];
00057         Rect *rect[NR_OBJECTS];
00058         Ellipse *ellipse[NR_OBJECTS];
00059         LImage *image[NR_OBJECTS];
00060         
00061         int X, Y;                                               // window dimension
00062         int lx, ly;                                             // temp. legend position
00063         int ax, ay, anumber;                            // temp. axis position and axis number
00064         int tx, ty;                                             // temp. title position
00065         int bx, by;                                             // temp. border position
00066         int tlx, tly;                                           // temp. tic label position
00067         int tmagx, tmagy,tmagx2,tmagy2; // temp. maglens position
00068         int tmaskx, tmasky,tmaskx2,tmasky2;     // temp. mask position
00069         double tpanx, tpany;                    // temp. pan zoom value (real data point)
00070         int tdatamodex;                         // temp. x value for datamode
00071         int linesx,linesy,lineex,lineey,labelx,labely,rectx,recty;
00072         int ellipsex,ellipsey,imagex,imagey;
00073         bool moving_cornerF1, moving_cornerF2;
00074         bool moving_cornerB1, moving_cornerB2;
00075         bool moving_borderx1, moving_borderx2;
00076         bool moving_bordery1, moving_bordery2;
00077         bool moving_center;
00078         int object_index;       // index of moving object
00079         int tmp_object_index;   // index when defining object
00080         unsigned int api, nr_plots;     // active plot index and number of plots
00081 public:
00082         Worksheet(QWidget *parent, MainWin *mw, const char *name);
00083         WidgetType getWidgetType() { return widgettype; }
00084         QStringList Info();
00085         MainWin *getMainWin() { return mw; }    // for project dialog
00086         Plot *getPlot(int i) { return plot[i]; }        
00087         void updatePixmap();
00088         void New();
00089         void save(QTextStream *t);
00090         void open(QTextStream *t,int version, PType oldtype);
00091 
00092         // TODO : add to which plot ? -> check this
00093         void addGraph2D(Graph2D *g,PType type=P2D);
00094         void addGraph3D(Graph3D *g,PType type=P3D);
00095         void addGraphM(GraphM *g,PType type=PSURFACE);
00096         void addGraph4D(Graph4D *g);
00097         void addGraphIMAGE(GraphIMAGE *g);
00098         
00099         void resetRanges();
00100         void checkRanges(TScale scale, double *min, double *max);
00101         double partRanges(TScale scale, double min, double max);
00102 public slots:
00103         void Export(QString filename, QString format);                                                          
00104         void ExportPS(QString filename);                                                                                        
00105         void ExportEPS(QString filename);                                                                                       
00106         void ExportPDF(QString filename);                                                                                       
00107         void ExportSVG(QString filename);                                                                                       
00108         void ExportPIC(QString filename);                                                                                       
00109         void Print(QString filename);                                                                                           
00110 
00111         // needed wrapper for QSA
00112         Plot2DSimple* get2DPlot(int i);                                 
00113         Plot2DSimple* get2DSimplePlot(int i) { return get2DPlot(i);}    
00114         Plot2DSurface* get2DSurfacePlot(int i);                         
00115         Plot3D* get3DPlot(int i);                                       
00116         PlotQWT3D* getQWT3DPlot(int i);                                 
00117         PlotPie* getPiePlot(int i);                                     
00118         PlotPolar* getPolarPlot(int i);                                 
00119         PlotTernary* getTernaryPlot(int i);                             
00120 
00121         Plot* newPlot(PType type=P2D);                  // TODO
00122         void deletePlot(int i);                         
00123         void deleteActivePlot();                                // TODO
00124         
00125         int getX() { return X; }                        
00126         int getY() { return Y; }                        
00127         void redraw() {updatePixmap();}                 
00128         int API() { return api; }                       
00129         unsigned int NrPlots() { return nr_plots; }     
00130         
00131         int NrObjects() { return NR_OBJECTS; }          
00132         Line* getLine(int i) { return line[i]; }        
00133         void setLine(int i, Line *l) { line[i]=l; }     
00134         Label* getLabel(int i) { return label[i]; }     
00135         void setLabel(int i, Label *l) { label[i]=l; }  
00136         Rect* getRect(int i) { return rect[i]; }                
00137         void setRect(int i, Rect *r) { rect[i]=r; }     
00138         Ellipse* getEllipse(int i) { return ellipse[i]; }       
00139         void setEllipse(int i, Ellipse* e) { ellipse[i]=e; }    
00140         LImage* getImage(int i) { return image[i]; }            
00141         void setImage(int i, LImage* im) { image[i]=im; }       
00142 
00143 
00144         QString Title() const { return title; }                                                                         
00145         void setTitle(QString t) { title = t.remove(QChar('&')); setCaption(title); updatePixmap(); }                           
00146         bool TitleEnabled() const { return title_enabled; }                                                     
00147         void setTitleEnabled(bool e=true) { title_enabled = e; updatePixmap(); }                        
00148         QDateTime TimeStamp() const { return timestamp; }                                                               
00149         void setTimeStamp(QDateTime ts) { timestamp = ts; updatePixmap(); }                     
00150         bool TimeStampEnabled() const { return timestamp_enabled; }                                     
00151         void setTimeStampEnabled(bool e=true) { timestamp_enabled = e;updatePixmap(); } 
00152         QColor Background() const { return background; }                                                        
00153         void setBackground(QColor c) { background = c; updatePixmap(); }                                
00154         void setBackground(QString c) { setBackground(QColor(c)); }                             
00155 protected:
00156         void resizeEvent( QResizeEvent * );
00157         void paintEvent( QPaintEvent * );
00158         void mousePressEvent( QMouseEvent *);
00159         void mouseReleaseEvent( QMouseEvent *);
00160         void mouseDoubleClickEvent( QMouseEvent * );
00161         void mouseMoveEvent( QMouseEvent * );
00162         void keyPressEvent(QKeyEvent *);
00163         void closeEvent(QCloseEvent *);
00164         void Draw(QPainter *,int w, int h);
00165         void setupPrinter(KPrinter *pr, QString fn);
00166         double XCoordinate(double x, double xmin, double xmax);
00167         double YCoordinate(double y, double ymin, double ymax);
00168 };
00169 
00170 #endif //WORKSHEET

Generated on Fri Aug 19 21:34:45 2005 for LabPlot by doxygen 1.3.6