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