00001 #ifndef WORKSHEET_H
00002 #define WORKSHEET_H
00003
00004 #include <qwidget.h>
00005 #include <qpainter.h>
00006 #include <qprinter.h>
00007 #include <qstring.h>
00008 #include <qfont.h>
00009 #include <qcolor.h>
00010 #include <qtextstream.h>
00011 #include <qdatetime.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 "Image.h"
00019
00020 #define NR_PLOTS 16
00021 #define NR_OBJECTS 10
00022
00023 class MainWin;
00024
00025 class Worksheet: public QWidget
00026 {
00027 Q_OBJECT
00028 private:
00029 MainWin *mw;
00030 class Plot *plot[NR_PLOTS];
00031 QPrinter *qprinter;
00032 QString title;
00033 bool title_enabled;
00034 QDateTime timestamp;
00035 bool timestamp_enabled;
00036 QColor bgcolor;
00037 Label *label[NR_OBJECTS];
00038 Line line[NR_OBJECTS];
00039 Rect rect[NR_OBJECTS];
00040 Ellipse ellipse[NR_OBJECTS];
00041 Image image[NR_OBJECTS];
00042 int X, Y;
00043 int lx, ly;
00044 int ax, ay, anumber;
00045 int tx, ty;
00046 int bx, by;
00047 int tlx, tly;
00048 int tmagx, tmagy,tmagx2,tmagy2;
00049 double tpanx, tpany;
00050 int linesx,linesy,lineex,lineey,labelx,labely,rectx,recty;
00051 int ellipsex,ellipsey,imagex,imagey;
00052 bool moving_cornerF1, moving_cornerF2;
00053 bool moving_cornerB1, moving_cornerB2;
00054 bool moving_borderx1, moving_borderx2;
00055 bool moving_bordery1, moving_bordery2;
00056 bool moving_center;
00057 int object_index;
00058 int tmp_object_index;
00059 unsigned int api, nr_plots;
00060 public:
00061 Worksheet(QWidget *parent, MainWin *mw, const char *name);
00062 MainWin *getMainWin() { return mw; }
00063 void New();
00064 class Plot *getPlot(int i) { return plot[i]; }
00065 void newPlot(PType type);
00066 void deleteActivePlot();
00067 void updateWorksheetList();
00068 void Print(QString filename);
00069 void save(QTextStream *t);
00070 void open(QTextStream *t,int version, PType oldtype);
00071 void Export(QString filename, QString format);
00072 void ExportSVG();
00073 void ExportPIC();
00074
00075 int getNrObjects() { return NR_OBJECTS; }
00076 Line getLine(int i) { return line[i]; }
00077 void setLine(int i, Line l) { line[i]=l; }
00078 Label *getLabel(int i) { return label[i]; }
00079 void setLabel(int i, Label *l) { label[i]=l; }
00080 Rect getRect(int i) { return rect[i]; }
00081 void setRect(int i, Rect r) { rect[i]=r; }
00082 Ellipse getEllipse(int i) { return ellipse[i]; }
00083 void setEllipse(int i, Ellipse e) { ellipse[i]=e; }
00084 Image getImage(int i) { return image[i]; }
00085 void setImage(int i, Image im) { image[i]=im; }
00086
00087
00088 void addGraph2D(Graph2D *g,PType type=P2D);
00089 void addGraph3D(Graph3D *g);
00090 void addGraphM(GraphM *g);
00091 void addGraphGRASS(GraphGRASS *g);
00092 void addGraphVTK(GraphVTK *g);
00093 void addGraph4D(Graph4D *g);
00094
00095 int getAPI() { return api; }
00096 unsigned int getNrPlots() { return nr_plots; }
00097
00098 QString getTitle() { return title; }
00099 void setTitle(QString t) { title = t; }
00100 bool getTitleEnabled() { return title_enabled; }
00101 void setTitleEnabled(bool e) { title_enabled = e; }
00102 void setBackground(QColor c) { bgcolor = c; }
00103 QColor Background() { return bgcolor; }
00104 QDateTime getTimeStamp() { return timestamp; }
00105 void setTimeStamp(QDateTime ts) { timestamp = ts; }
00106 bool getTimeStampEnabled() { return timestamp_enabled; }
00107 void setTimeStampEnabled(bool e) { timestamp_enabled = e; }
00108
00109 void resetRanges();
00110 protected:
00111 void resizeEvent( QResizeEvent * );
00112 void paintEvent( QPaintEvent * );
00113 void mousePressEvent( QMouseEvent *);
00114 void mouseReleaseEvent( QMouseEvent *);
00115 void mouseDoubleClickEvent( QMouseEvent * );
00116 void mouseMoveEvent( QMouseEvent * );
00117 void closeEvent(QCloseEvent *);
00118 void Draw(QPainter *,int w, int h);
00119 double getXCoordinate(double x, double xmin, double xmax);
00120 double getYCoordinate(double y, double ymin, double ymax);
00121 };
00122
00123 #endif //WORKSHEET