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 #ifndef MULTILAYER_H
00030 #define MULTILAYER_H
00031
00032 #include <MdiSubWindow.h>
00033 #include <FrameWidget.h>
00034 #include <QPushButton>
00035 #include <QLayout>
00036 #include <QPointer>
00037
00038 class QTextDocument;
00039 class QLabel;
00040 class LayerButton;
00041 class SelectionMoveResizer;
00042 class LegendWidget;
00043 class Graph;
00044 class QwtPlotCurve;
00045
00063 class MultiLayer: public MdiSubWindow
00064 {
00065 Q_OBJECT
00066
00067 public:
00068 MultiLayer (ApplicationWindow* parent = 0, int layers = 1, int rows = 1, int cols = 1, const QString& label = "", const char* name=0, Qt::WFlags f=0);
00069 ~MultiLayer();
00070
00071 QList<Graph *> layersList(){return graphsList;};
00072 Graph *layer(int num);
00073 int layerIndex(Graph *g){return graphsList.indexOf(g);};
00074
00075 int numLayers(){return graphsList.size();};
00076 void setNumLayers(int n);
00077
00078 void copy(MultiLayer* ml);
00079
00080 enum HorAlignement{HCenter, Left, Right};
00081 enum VertAlignement{VCenter, Top, Bottom};
00082
00083 bool scaleLayersOnPrint(){return d_scale_on_print;};
00084 void setScaleLayersOnPrint(bool on){d_scale_on_print = on;};
00085
00086 bool printCropmarksEnabled(){return d_print_cropmarks;};
00087 void printCropmarks(bool on){d_print_cropmarks = on;};
00088
00089 bool scaleLayersOnResize(){return d_scale_layers;};
00090 void setScaleLayersOnResize(bool ok){d_scale_layers = ok;};
00091
00092 QWidget *canvas(){return d_canvas;};
00093 QRect canvasRect(){return d_canvas->rect();};
00094 QRect canvasChildrenRect();
00095 virtual QString sizeToString();
00096
00097 void setWaterfallLayout(bool on = true);
00098 void createWaterfallBox();
00099 bool isWaterfallPlot(){return d_is_waterfall_plot;};
00100 int waterfallXOffset(){return d_waterfall_offset_x;};
00101 int waterfallYOffset(){return d_waterfall_offset_y;};
00102 void setWaterfallOffset(int x, int y, bool update = false);
00103 bool sideLinesEnabled(){return d_side_lines;};
00104
00105 void setEqualSizedLayers();
00106
00107 public slots:
00108 Graph* addLayer(int x = 0, int y = 0, int width = 0, int height = 0);
00109
00110 bool isEmpty();
00111 bool removeLayer(Graph *g);
00112 bool removeActiveLayer();
00113 void confirmRemoveLayer();
00114
00115 Graph* activeLayer(){return active_graph;};
00116 void setActiveLayer(Graph* g);
00117 void activateGraph(LayerButton* button);
00118
00120 Graph* layerAt(const QPoint& pos);
00121 void setGraphGeometry(int x, int y, int w, int h);
00122
00123 void findBestLayout(int &rows, int &cols);
00124
00125 QSize arrangeLayers(bool userSize);
00126 bool arrangeLayers(bool fit, bool userSize);
00127 bool swapLayers(int src, int dest);
00128 void adjustSize();
00129
00130 int getRows(){return d_rows;};
00131 void setRows(int r);
00132
00133 int getCols(){return d_cols;};
00134 void setCols(int c);
00135
00136 int colsSpacing(){return colsSpace;};
00137 int rowsSpacing(){return rowsSpace;};
00138 void setSpacing (int rgap, int cgap);
00139
00140 int leftMargin(){return left_margin;};
00141 int rightMargin(){return right_margin;};
00142 int topMargin(){return top_margin;};
00143 int bottomMargin(){return bottom_margin;};
00144 void setMargins (int lm, int rm, int tm, int bm);
00145
00146 QSize layerCanvasSize(){return QSize(l_canvas_width, l_canvas_height);};
00147 void setLayerCanvasSize (int w, int h);
00148
00149 int horizontalAlignement(){return hor_align;};
00150 int verticalAlignement(){return vert_align;};
00151 void setAlignement (int ha, int va);
00152
00154
00155 QPixmap canvasPixmap(const QSize& size = QSize(), double scaleFontsFactor = 1.0);
00156 void exportToFile(const QString& fileName);
00157 void exportImage(QTextDocument *document, int quality = 100, bool transparent = false,
00158 int dpi = 0, const QSizeF& customSize = QSizeF (), int unit = FrameWidget::Pixel, double fontsFactor = 1.0);
00159 void exportImage(const QString& fileName, int quality = 100, bool transparent = false,
00160 int dpi = 0, const QSizeF& customSize = QSizeF (), int unit = FrameWidget::Pixel, double fontsFactor = 1.0);
00161 void exportSVG(const QString& fname, const QSizeF& customSize = QSizeF(), int unit = FrameWidget::Pixel, double fontsFactor = 1.0);
00162 void exportPDF(const QString& fname);
00163 void exportVector(const QString& fileName, int res = 0, bool color = true,
00164 const QSizeF& customSize = QSizeF (), int unit = FrameWidget::Pixel, double fontsFactor = 1.0);
00165
00166 void draw(QPaintDevice *, const QSizeF& customSize, int unit, int res, double fontsFactor = 1.0);
00167
00168 #ifdef EMF_OUTPUT
00169 void exportEMF(const QString& fname, const QSizeF& customSize = QSizeF(), int unit = FrameWidget::Pixel, double fontsFactor = 1.0);
00170 #endif
00171 void exportTeX(const QString& fname, bool color = true, bool escapeStrings = true, bool fontSizes = true,
00172 const QSizeF& customSize = QSizeF(), int unit = FrameWidget::Pixel, double fontsFactor = 1.0);
00173
00174 void copyAllLayers();
00175 void print();
00176 void print(QPrinter *);
00177 void printAllLayers(QPainter *painter);
00178 void printActiveLayer();
00180
00181 void setFonts(const QFont& titleFnt, const QFont& scaleFnt,
00182 const QFont& numbersFnt, const QFont& legendFnt);
00183
00184 void connectLayer(Graph *g);
00185
00186 void save(const QString& fn, const QString& geometry, bool = false);
00187
00188 bool hasSelectedLayers();
00189
00191
00192 void showWaterfallOffsetDialog();
00193 void reverseWaterfallOrder();
00194 void showWaterfallFillDialog();
00195 void setWaterfallFillColor(const QColor&);
00196 void updateWaterfallFill(bool on);
00197 void setWaterfallSideLines(bool on = true);
00198 void changeWaterfallXOffset(int);
00199 void changeWaterfallYOffset(int);
00200 void updateWaterfallLayout();
00201 void updateWaterfallScales(Graph *g, int axis);
00203
00204 signals:
00205 void showEnrichementDialog();
00206 void showPlotDialog(int);
00207 void showAxisDialog(int);
00208 void showScaleDialog(int);
00209 void showGraphContextMenu();
00210 void showCurveContextMenu(QwtPlotItem *);
00211 void showCurvesDialog();
00212 void drawLineEnded(bool);
00213 void showAxisTitleDialog();
00214 void showMarkerPopupMenu();
00215 void modifiedPlot();
00216 void cursorInfo(const QString&);
00217 void showLineDialog();
00218 void viewTitleDialog();
00219 void createTable(const QString&,int,int,const QString&);
00220 void pasteMarker();
00221 void setPointerCursor();
00222 void currentFontChanged(const QFont&);
00223 void enableTextEditor(Graph *);
00224
00225 private:
00227
00228 void dropEvent(QDropEvent*);
00229 void dragEnterEvent(QDragEnterEvent*);
00230 void wheelEvent(QWheelEvent *);
00231 void keyPressEvent(QKeyEvent *);
00232 bool eventFilter(QObject *object, QEvent *);
00233 void releaseLayer();
00234 void resizeLayers(QResizeEvent *);
00236
00237 LayerButton* addLayerButton();
00238
00239 Graph* active_graph;
00241 int d_cols, d_rows, graph_width, graph_height, colsSpace, rowsSpace;
00242 int left_margin, right_margin, top_margin, bottom_margin;
00243 int l_canvas_width, l_canvas_height, hor_align, vert_align;
00244 bool d_scale_on_print, d_print_cropmarks;
00246 bool d_scale_layers;
00247
00248 QList<LayerButton *> buttonsList;
00249 QList<Graph *> graphsList;
00250 QHBoxLayout *layerButtonsBox, *waterfallBox, *toolbuttonsBox;
00251 QWidget *d_canvas;
00252
00253 QPointer<SelectionMoveResizer> d_layers_selector;
00254
00255 int d_waterfall_offset_x, d_waterfall_offset_y;
00256 bool d_is_waterfall_plot;
00258 bool d_side_lines;
00259 QColor d_waterfall_fill_color;
00260
00261 QPushButton *d_add_layer_btn, *d_remove_layer_btn;
00262 };
00263
00265 class LayerButton: public QPushButton
00266 {
00267 Q_OBJECT
00268
00269 public:
00270 LayerButton (const QString& text = QString::null, QWidget* parent = 0);
00271 static int btnSize(){return 20;};
00272
00273 protected:
00274 void mousePressEvent( QMouseEvent * );
00275 void mouseDoubleClickEvent ( QMouseEvent * );
00276
00277 signals:
00278 void showCurvesDialog();
00279 void clicked(LayerButton*);
00280 };
00281
00282 #endif