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
00023
00024
00025
00026
00027
00028 #define NR_PLOTS 16
00029 #define NR_OBJECTS 100
00030
00031 class MainWin;
00032 class Plot;
00033 class Plot2DSimple;
00034 class Plot2DSurface;
00035 class Plot3D;
00036 class PlotQWT3D;
00037 class PlotPie;
00038 class PlotPolar;
00039 class PlotTernary;
00040
00041 class Worksheet: public QWidget
00042 {
00043 Q_OBJECT
00044
00045
00046 Q_PROPERTY(bool title_enabled READ TitleEnabled WRITE setTitleEnabled)
00047 Q_PROPERTY(bool timestamp_enabled READ TimeStampEnabled WRITE setTimeStampEnabled)
00048 Q_PROPERTY(QDateTime timestamp READ TimeStamp WRITE setTimeStamp)
00049 Q_PROPERTY(QBrush background READ Background WRITE setBackground)
00050 private:
00051 MainWin *mw;
00052 WidgetType widgettype;
00053 Plot *plot[NR_PLOTS];
00054 KPrinter *printer;
00055 QPixmap *pixmap;
00056 QString title;
00057 bool title_enabled;
00058 QDateTime timestamp;
00059 bool timestamp_enabled;
00060 QBrush background;
00061
00062 Label *label[NR_OBJECTS];
00063 Line *line[NR_OBJECTS];
00064 Rect *rect[NR_OBJECTS];
00065 Ellipse *ellipse[NR_OBJECTS];
00066 LImage *image[NR_OBJECTS];
00067
00068 int X, Y;
00069 int lx, ly;
00070 int ax, ay, anumber;
00071 int tx, ty;
00072 int bx, by;
00073 int tlx, tly;
00074 int tmagx, tmagy,tmagx2,tmagy2;
00075 int tmaskx, tmasky,tmaskx2,tmasky2;
00076 double tpanx, tpany;
00077 int tdatamodex;
00078 int linesx,linesy,lineex,lineey,labelx,labely,rectx,recty;
00079 int ellipsex,ellipsey,imagex,imagey;
00080 bool moving_cornerF1, moving_cornerF2;
00081 bool moving_cornerB1, moving_cornerB2;
00082 bool moving_borderx1, moving_borderx2;
00083 bool moving_bordery1, moving_bordery2;
00084 bool moving_center;
00085 int object_index;
00086 int tmp_object_index;
00087 unsigned int api, nr_plots;
00088 bool draw_objects_first;
00089 public:
00090 Worksheet(QWidget *parent, MainWin *mw, const char *name);
00091 ~Worksheet();
00092
00093
00094 void closeNow();
00095 WidgetType getWidgetType() { return widgettype; }
00096 QStringList Info();
00097 MainWin *getMainWin() { return mw; }
00098 Plot *getPlot(int i) { return plot[i]; }
00099 void setPlot(int i,Plot *p) { plot[i] = p; }
00100
00101
00102
00103
00104 void updatePixmap();
00105 void New();
00106 void save(QTextStream *t);
00107 void open(QTextStream *t,int version, PType oldtype);
00108 QDomElement saveXML(QDomDocument doc);
00109 void openXML(QDomNode node);
00110
00111
00112 void addGraph2D(Graph2D *g,PType type=P2D);
00113 void addGraph3D(Graph3D *g,PType type=P3D);
00114 void addGraphM(GraphM *g,PType type=PSURFACE);
00115 void addGraph4D(Graph4D *g);
00116 void addGraphIMAGE(GraphIMAGE *g);
00117 void addGraphL(GraphL *g,PType type=PPIE);
00118
00119 void resetRanges();
00120 void checkRanges(TScale scale, double *min, double *max);
00121 double partRanges(TScale scale, double min, double max);
00122 public slots:
00123 void Export(QString filename, QString format, int quality=-1);
00124 void ExportPS(QString filename);
00125 void ExportEPS(QString filename);
00126 void ExportPDF(QString filename);
00127 void ExportSVG(QString filename);
00128 void ExportPIC(QString filename);
00129 void Print(QString filename);
00130
00131
00132 Plot2DSimple* get2DPlot(int i);
00133 Plot2DSimple* get2DSimplePlot(int i) { return get2DPlot(i);}
00134 Plot2DSurface* get2DSurfacePlot(int i);
00135 Plot3D* get3DPlot(int i);
00136 PlotQWT3D* getQWT3DPlot(int i);
00137 PlotPie* getPiePlot(int i);
00138 PlotPolar* getPolarPlot(int i);
00139 PlotTernary* getTernaryPlot(int i);
00140
00141 Plot* newPlot(PType type=P2D, bool insert=true);
00142 Plot* clonePlot(int item, bool insert=true);
00143 void deletePlot(int i);
00144 void deleteActivePlot();
00145
00146 int getX() { return X; }
00147 int getY() { return Y; }
00148 void redraw() {updatePixmap();}
00149 int API() { return api; }
00150 unsigned int NrPlots() { return nr_plots; }
00151 void setNrPlots(unsigned int i) { nr_plots=i; }
00152
00153 int NrObjects() { return NR_OBJECTS; }
00154 Line* getLine(int i) { return line[i]; }
00155 void setLine(int i, Line *l) { line[i]=l; }
00156 Label* getLabel(int i) { return label[i]; }
00157 void setLabel(int i, Label *l) { label[i]=l; }
00158 Rect* getRect(int i) { return rect[i]; }
00159 void setRect(int i, Rect *r) { rect[i]=r; }
00160 Ellipse* getEllipse(int i) { return ellipse[i]; }
00161 void setEllipse(int i, Ellipse* e) { ellipse[i]=e; }
00162 LImage* getImage(int i) { return image[i]; }
00163 void setImage(int i, LImage* im) { image[i]=im; }
00164
00165 QString Title() const { return title; }
00166 void setTitle(QString t) { title = t.remove(QChar('&')); setCaption(title); updatePixmap(); }
00167 bool TitleEnabled() const { return title_enabled; }
00168 void enableTitle(bool e=true) { title_enabled = e; updatePixmap(); }
00169 void setTitleEnabled(bool e=true) { enableTitle(e); }
00170 QDateTime TimeStamp() const { return timestamp; }
00171 void setTimeStamp(QDateTime ts) { timestamp = ts; updatePixmap(); }
00172 bool TimeStampEnabled() const { return timestamp_enabled; }
00173 void enableTimeStamp(bool e=true) { timestamp_enabled = e;updatePixmap(); }
00174 void setTimeStampEnabled(bool e=true) { enableTimeStamp(e); }
00175 QBrush Background() const { return background; }
00176 void setBackground(QBrush c) { background = c; updatePixmap(); }
00177 void setBackground(QString c) { setBackground(QBrush(QColor(c))); }
00178 void setDrawObjectsFirst(bool v=true) { draw_objects_first = v; }
00179 bool DrawObjectsFirst() { return draw_objects_first; }
00180 protected:
00181 void resizeEvent( QResizeEvent * );
00182 void paintEvent( QPaintEvent * );
00183 void mousePressEvent( QMouseEvent *);
00184 void mouseReleaseEvent( QMouseEvent *);
00185 void mouseDoubleClickEvent( QMouseEvent * );
00186 void mouseMoveEvent( QMouseEvent * );
00187 void keyPressEvent(QKeyEvent *);
00188 void closeEvent(QCloseEvent *);
00189 void Draw(QPainter *, int w, int h);
00190 void DrawObjects(QPainter *, int w, int h);
00191 void setupPrinter(KPrinter *pr, QString fn);
00192 double XCoordinate(double x, double xmin, double xmax);
00193 double YCoordinate(double y, double ymin, double ymax);
00194 };
00195
00196 #endif //WORKSHEET