MultiLayer.h

Go to the documentation of this file.
00001 /***************************************************************************
00002     File                 : MultiLayer.h
00003     Project              : QtiPlot
00004     --------------------------------------------------------------------
00005     Copyright            : (C) 2006 by Ion Vasilief,
00006                            Tilman Hoener zu Siederdissen,
00007                            Knut Franke
00008     Email (use @ for *)  : ion_vasilief*yahoo.fr, thzs*gmx.net,
00009                            knut.franke*gmx.de
00010     Description          : Multi layer widget
00011 
00012  ***************************************************************************/
00013 
00014 /***************************************************************************
00015  *                                                                         *
00016  *  This program is free software; you can redistribute it and/or modify   *
00017  *  it under the terms of the GNU General Public License as published by   *
00018  *  the Free Software Foundation; either version 2 of the License, or      *
00019  *  (at your option) any later version.                                    *
00020  *                                                                         *
00021  *  This program is distributed in the hope that it will be useful,        *
00022  *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
00023  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
00024  *  GNU General Public License for more details.                           *
00025  *                                                                         *
00026  *   You should have received a copy of the GNU General Public License     *
00027  *   along with this program; if not, write to the Free Software           *
00028  *   Foundation, Inc., 51 Franklin Street, Fifth Floor,                    *
00029  *   Boston, MA  02110-1301  USA                                           *
00030  *                                                                         *
00031  ***************************************************************************/
00032 #ifndef MULTILAYER_H
00033 #define MULTILAYER_H
00034 
00035 #include "../MdiSubWindow.h"
00036 #include "Graph.h"
00037 #include <QPushButton>
00038 #include <QLayout>
00039 #include <QPointer>
00040 
00041 class QLabel;
00042 class LayerButton;
00043 class SelectionMoveResizer;
00044 class LegendWidget;
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 public slots:
00098     Graph* addLayer(int x = 0, int y = 0, int width = 0, int height = 0);
00099 
00100     bool isEmpty();
00101     bool removeLayer(Graph *g);
00102     bool removeActiveLayer();
00103     void confirmRemoveLayer();
00104 
00105     Graph* activeLayer(){return active_graph;};
00106     void setActiveLayer(Graph* g);
00107     void activateGraph(LayerButton* button);
00108 
00110     Graph* layerAt(const QPoint& pos);
00111     void setGraphGeometry(int x, int y, int w, int h);
00112 
00113     void findBestLayout(int &rows, int &cols);
00114 
00115     QSize arrangeLayers(bool userSize);
00116     void arrangeLayers(bool fit, bool userSize);
00117     bool swapLayers(int src, int dest);
00118     void adjustSize();
00119 
00120     int getRows(){return d_rows;};
00121     void setRows(int r);
00122 
00123     int getCols(){return d_cols;};
00124     void setCols(int c);
00125 
00126     int colsSpacing(){return colsSpace;};
00127     int rowsSpacing(){return rowsSpace;};
00128     void setSpacing (int rgap, int cgap);
00129 
00130     int leftMargin(){return left_margin;};
00131     int rightMargin(){return right_margin;};
00132     int topMargin(){return top_margin;};
00133     int bottomMargin(){return bottom_margin;};
00134     void setMargins (int lm, int rm, int tm, int bm);
00135 
00136     QSize layerCanvasSize(){return QSize(l_canvas_width, l_canvas_height);};
00137     void setLayerCanvasSize (int w, int h);
00138 
00139     int horizontalAlignement(){return hor_align;};
00140     int verticalAlignement(){return vert_align;};
00141     void setAlignement (int ha, int va);
00142 
00144 
00145     QPixmap canvasPixmap();
00146     void exportToFile(const QString& fileName);
00147     void exportImage(const QString& fileName, int quality = 100, bool transparent = false);
00148     void exportSVG(const QString& fname);
00149     void exportPDF(const QString& fname);
00150     void exportVector(const QString& fileName, int res = 0, bool color = true);
00151 
00152     void copyAllLayers();
00153     void print();
00154     void printAllLayers(QPainter *painter);
00155     void printActiveLayer();
00157 
00158     void setFonts(const QFont& titleFnt, const QFont& scaleFnt,
00159                             const QFont& numbersFnt, const QFont& legendFnt);
00160 
00161     void connectLayer(Graph *g);
00162 
00163     void save(const QString& fn, const QString& geometry, bool = false);
00164 
00165     bool hasSelectedLayers();
00166 
00167 signals:
00168     void showEnrichementDialog();
00169     void showPlotDialog(int);
00170     void showAxisDialog(int);
00171     void showScaleDialog(int);
00172     void showGraphContextMenu();
00173     void showCurveContextMenu(QwtPlotCurve *);
00174     void showCurvesDialog();
00175     void drawLineEnded(bool);
00176     void showAxisTitleDialog();
00177     void showMarkerPopupMenu();
00178     void modifiedPlot();
00179     void cursorInfo(const QString&);
00180     void showLineDialog();
00181     void viewTitleDialog();
00182     void createTable(const QString&,int,int,const QString&);
00183     void pasteMarker();
00184     void setPointerCursor();
00185     void currentFontChanged(const QFont&);
00186     void enableTextEditor(Graph *);
00187 
00188 private:
00190 
00191     void wheelEvent(QWheelEvent *);
00192     void keyPressEvent(QKeyEvent *);
00193     bool eventFilter(QObject *object, QEvent *);
00194     void releaseLayer();
00195     void resizeLayers(QResizeEvent *);
00197 
00198     LayerButton* addLayerButton();
00199 
00200     Graph* active_graph;
00202     int d_cols, d_rows, graph_width, graph_height, colsSpace, rowsSpace;
00203     int left_margin, right_margin, top_margin, bottom_margin;
00204     int l_canvas_width, l_canvas_height, hor_align, vert_align;
00205     bool d_scale_on_print, d_print_cropmarks;
00207     bool d_scale_layers;
00208 
00209     QList<LayerButton *> buttonsList;
00210     QList<Graph *> graphsList;
00211     QHBoxLayout *layerButtonsBox;
00212     QWidget *d_canvas;
00213 
00214     QPointer<SelectionMoveResizer> d_layers_selector;
00215 };
00216 
00218 class LayerButton: public QPushButton
00219 {
00220     Q_OBJECT
00221 
00222 public:
00223     LayerButton (const QString& text = QString::null, QWidget* parent = 0);
00224     static int btnSize(){return 20;};
00225 
00226 protected:
00227     void mousePressEvent( QMouseEvent * );
00228     void mouseDoubleClickEvent ( QMouseEvent * );
00229 
00230 signals:
00231     void showCurvesDialog();
00232     void clicked(LayerButton*);
00233 };
00234 
00235 #endif

Generated on Fri Nov 7 03:36:52 2008 for QtiPlot by  doxygen 1.5.6