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