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
00021 #define NR_PLOTS 16
00022 #define NR_OBJECTS 10
00023
00024 class MainWin;
00025
00026 class Worksheet: public QWidget
00027 {
00028 Q_OBJECT
00029 Q_PROPERTY(QString title READ Title WRITE setTitle)
00030 Q_PROPERTY(bool title_enabled READ TitleEnabled WRITE setTitleEnabled)
00031 Q_PROPERTY(bool timestamp_enabled READ TimeStampEnabled WRITE setTimeStampEnabled)
00032 Q_PROPERTY(QDateTime timestamp READ TimeStamp WRITE setTimeStamp)
00033 Q_PROPERTY(QColor background READ Background WRITE setBackground)
00034 private:
00035 MainWin *mw;
00036 WidgetType widgettype;
00037 class Plot *plot[NR_PLOTS];
00038 KPrinter *printer;
00039 QPixmap *pixmap;
00040 QString title;
00041 bool title_enabled;
00042 QDateTime timestamp;
00043 bool timestamp_enabled;
00044 QColor background;
00045 Label *label[NR_OBJECTS];
00046 Line line[NR_OBJECTS];
00047 Rect rect[NR_OBJECTS];
00048 Ellipse ellipse[NR_OBJECTS];
00049 LImage image[NR_OBJECTS];
00050 int X, Y;
00051 int lx, ly;
00052 int ax, ay, anumber;
00053 int tx, ty;
00054 int bx, by;
00055 int tlx, tly;
00056 int tmagx, tmagy,tmagx2,tmagy2;
00057 int tmaskx, tmasky,tmaskx2,tmasky2;
00058 double tpanx, tpany;
00059 int tdatamodex;
00060 int linesx,linesy,lineex,lineey,labelx,labely,rectx,recty;
00061 int ellipsex,ellipsey,imagex,imagey;
00062 bool moving_cornerF1, moving_cornerF2;
00063 bool moving_cornerB1, moving_cornerB2;
00064 bool moving_borderx1, moving_borderx2;
00065 bool moving_bordery1, moving_bordery2;
00066 bool moving_center;
00067 int object_index;
00068 int tmp_object_index;
00069 unsigned int api, nr_plots;
00070 public:
00071 Worksheet(QWidget *parent, MainWin *mw, const char *name);
00072 WidgetType getWidgetType() { return widgettype; }
00073 QStringList Info();
00074 MainWin *getMainWin() { return mw; }
00075 void updatePixmap();
00076 void New();
00077 class Plot *getPlot(int i) { return plot[i]; }
00078 void deletePlot(int i);
00079 void save(QTextStream *t);
00080 void open(QTextStream *t,int version, PType oldtype);
00081
00082 int NrObjects() { return NR_OBJECTS; }
00083 Line getLine(int i) { return line[i]; }
00084 void setLine(int i, Line l) { line[i]=l; }
00085 Label *getLabel(int i) { return label[i]; }
00086 void setLabel(int i, Label *l) { label[i]=l; }
00087 Rect getRect(int i) { return rect[i]; }
00088 void setRect(int i, Rect r) { rect[i]=r; }
00089 Ellipse getEllipse(int i) { return ellipse[i]; }
00090 void setEllipse(int i, Ellipse e) { ellipse[i]=e; }
00091 LImage getImage(int i) { return image[i]; }
00092 void setImage(int i, LImage im) { image[i]=im; }
00093
00094
00095 void addGraph2D(Graph2D *g,PType type=P2D);
00096 void addGraph3D(Graph3D *g,PType type=P3D);
00097 void addGraphM(GraphM *g,PType type=PSURFACE);
00098 void addGraphGRASS(GraphGRASS *g);
00099 void addGraphVTK(GraphVTK *g);
00100 void addGraph4D(Graph4D *g);
00101 void addGraphIMAGE(GraphIMAGE *g);
00102
00103 int API() { return api; }
00104 unsigned int NrPlots() { return nr_plots; }
00105
00106 void resetRanges();
00107 public slots:
00108 void Export(QString filename, QString format);
00109 void ExportPS(QString filename);
00110 void ExportEPS(QString filename);
00111 void ExportPDF(QString filename);
00112 void ExportSVG(QString filename);
00113 void ExportPIC(QString filename);
00114 void Print(QString filename);
00115
00116 void newPlot(PType type);
00117 void deleteActivePlot();
00118
00119 QString Title() const { return title; }
00120 void setTitle(QString t) { title = t;updatePixmap(); }
00121 bool TitleEnabled() const { return title_enabled; }
00122 void setTitleEnabled(bool e) { title_enabled = e; updatePixmap(); }
00123 QDateTime TimeStamp() const { return timestamp; }
00124 void setTimeStamp(QDateTime ts) { timestamp = ts; updatePixmap(); }
00125 bool TimeStampEnabled() const { return timestamp_enabled; }
00126 void setTimeStampEnabled(bool e) { timestamp_enabled = e;updatePixmap(); }
00127 QColor Background() const { return background; }
00128 void setBackground(QColor c) { background = c; updatePixmap(); }
00129 protected:
00130 void resizeEvent( QResizeEvent * );
00131 void paintEvent( QPaintEvent * );
00132 void mousePressEvent( QMouseEvent *);
00133 void mouseReleaseEvent( QMouseEvent *);
00134 void mouseDoubleClickEvent( QMouseEvent * );
00135 void mouseMoveEvent( QMouseEvent * );
00136 void closeEvent(QCloseEvent *);
00137 void Draw(QPainter *,int w, int h);
00138 void setupPrinter(KPrinter *pr, QString fn);
00139 double XCoordinate(double x, double xmin, double xmax);
00140 double YCoordinate(double y, double ymin, double ymax);
00141 };
00142
00143 #endif //WORKSHEET