00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef MULTILAYER_H
00033 #define MULTILAYER_H
00034
00035 #include "MyWidget.h"
00036 #include "Graph.h"
00037 #include <QPushButton>
00038 #include <QLayout>
00039 #include <QPointer>
00040
00041 class QWidget;
00042 class QLabel;
00043 class QWidget;
00044 class LayerButton;
00045 class SelectionMoveResizer;
00046
00064 class MultiLayer: public MyWidget
00065 {
00066 Q_OBJECT
00067
00068 public:
00069 MultiLayer (const QString& label, QWidget* parent=0, const char* name=0, Qt::WFlags f=0);
00070 QWidgetList graphPtrs(){return graphsList;};
00071 Graph *layer(int num);
00072 LayerButton* addLayerButton();
00073 void copy(MultiLayer* ml);
00074
00075 enum HorAlignement{HCenter, Left, Right};
00076 enum VertAlignement{VCenter, Top, Bottom};
00077
00079
00080 void mousePressEvent(QMouseEvent *);
00081 void contextMenuEvent(QContextMenuEvent *);
00082 void wheelEvent(QWheelEvent *);
00083 void keyPressEvent(QKeyEvent *);
00084 void changeEvent(QEvent *);
00085 bool eventFilter(QObject *object, QEvent *);
00086 void releaseLayer();
00087
00088 bool focusNextPrevChild ( bool next );
00090
00091 void setOpenMaximized(){d_open_maximized = 1;};
00092
00093 bool scaleLayersOnPrint(){return d_scale_on_print;};
00094 void setScaleLayersOnPrint(bool on){d_scale_on_print = on;};
00095
00096 bool printCropmarksEnabled(){return d_print_cropmarks;};
00097 void printCropmarks(bool on){d_print_cropmarks = on;};
00098
00099 void setHidden();
00100
00101 public slots:
00102 Graph* addLayer(int x = 0, int y = 0, int width = 0, int height = 0);
00103 void setLayersNumber(int n);
00104
00105 bool isEmpty();
00106 void removeLayer();
00107 void confirmRemoveLayer();
00108
00116 void addTextLayer(int f, const QFont& font, const QColor& textCol, const QColor& backgroundCol);
00124 void addTextLayer(const QPoint& pos);
00125
00126 Graph* activeGraph(){return active_graph;};
00127 void setActiveGraph(Graph* g);
00128 void activateGraph(LayerButton* button);
00129
00130 void setGraphGeometry(int x, int y, int w, int h);
00131
00132 void findBestLayout(int &rows, int &cols);
00133
00134 QSize arrangeLayers(bool userSize);
00135 void arrangeLayers(bool fit, bool userSize);
00136 void adjustSize();
00137
00138 int getRows(){return rows;};
00139 void setRows(int r);
00140
00141 int getCols(){return cols;};
00142 void setCols(int c);
00143
00144 int colsSpacing(){return colsSpace;};
00145 int rowsSpacing(){return rowsSpace;};
00146 void setSpacing (int rgap, int cgap);
00147
00148 int leftMargin(){return left_margin;};
00149 int rightMargin(){return right_margin;};
00150 int topMargin(){return top_margin;};
00151 int bottomMargin(){return bottom_margin;};
00152 void setMargins (int lm, int rm, int tm, int bm);
00153
00154 QSize layerCanvasSize(){return QSize(l_canvas_width, l_canvas_height);};
00155 void setLayerCanvasSize (int w, int h);
00156
00157 int horizontalAlignement(){return hor_align;};
00158 int verticalAlignement(){return vert_align;};
00159 void setAlignement (int ha, int va);
00160
00161 int layers(){return graphs;};
00162
00164
00165 QPixmap canvasPixmap();
00166 void exportToFile(const QString& fileName);
00167 void exportImage(const QString& fileName, int quality = 100, bool transparent = false);
00168 void exportSVG(const QString& fname);
00169 void exportPDF(const QString& fname);
00170 void exportVector(const QString& fileName, int res = 0, bool color = true);
00171
00172 void copyAllLayers();
00173 void print();
00174 void printAllLayers(QPainter *painter);
00175 void printActiveLayer();
00177
00178 void setFonts(const QFont& titleFnt, const QFont& scaleFnt,
00179 const QFont& numbersFnt, const QFont& legendFnt);
00180
00181 void connectLayer(Graph *g);
00182
00183 QString saveToString(const QString& geometry);
00184 QString saveAsTemplate(const QString& geometryInfo);
00185
00186 signals:
00187 void showTextDialog();
00188 void showPlotDialog(int);
00189 void showAxisDialog(int);
00190 void showScaleDialog(int);
00191 void showGraphContextMenu();
00192 void showCurveContextMenu(int);
00193 void showWindowContextMenu();
00194 void showCurvesDialog();
00195 void drawTextOff();
00196 void drawLineEnded(bool);
00197 void showXAxisTitleDialog();
00198 void showYAxisTitleDialog();
00199 void showTopAxisTitleDialog();
00200 void showRightAxisTitleDialog();
00201 void showMarkerPopupMenu();
00202 void modifiedPlot();
00203 void cursorInfo(const QString&);
00204 void showImageDialog();
00205 void showLineDialog();
00206 void viewTitleDialog();
00207 void createTable(const QString&,int,int,const QString&);
00208 void showGeometryDialog();
00209 void pasteMarker();
00210 void createIntensityTable(const QString&);
00211 void setPointerCursor();
00212
00213 private:
00214 void resizeLayers (const QResizeEvent *re);
00215 void resizeLayers (const QSize& size, const QSize& oldSize, bool scaleFonts);
00216
00217 Graph* active_graph;
00219 int graphs, cols, rows, graph_width, graph_height, colsSpace, rowsSpace;
00220 int left_margin, right_margin, top_margin, bottom_margin;
00221 int l_canvas_width, l_canvas_height, hor_align, vert_align;
00222 bool addTextOn;
00223 bool d_scale_on_print, d_print_cropmarks;
00224
00226 int defaultTextMarkerFrame;
00227 QFont defaultTextMarkerFont;
00228 QColor defaultTextMarkerColor, defaultTextMarkerBackground;
00229
00230 QWidgetList buttonsList, graphsList;
00231 QHBoxLayout *layerButtonsBox;
00232 QWidget *canvas;
00233
00234 QPointer<SelectionMoveResizer> d_layers_selector;
00235 int d_open_maximized;
00237 QSize d_max_size;
00239 QSize d_normal_size;
00240 };
00241
00242
00244 class LayerButton: public QPushButton
00245 {
00246 Q_OBJECT
00247
00248 public:
00249 LayerButton (const QString& text = QString::null, QWidget* parent = 0);
00250 ~LayerButton(){};
00251
00252 static int btnSize(){return 20;};
00253
00254 protected:
00255 void mousePressEvent( QMouseEvent * );
00256 void mouseDoubleClickEvent ( QMouseEvent * );
00257
00258 signals:
00259 void showCurvesDialog();
00260 void clicked(LayerButton*);
00261 };
00262
00263 #endif