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     QList<Graph *> layersList(){return graphsList;};
00070     Graph *layer(int num);
00071     int layerIndex(Graph *g){return graphsList.indexOf(g);};
00072 
00073     int numLayers(){return graphsList.size();};
00074     void setNumLayers(int n);
00075 
00076     void copy(MultiLayer* ml);
00077 
00078     enum HorAlignement{HCenter, Left, Right};
00079     enum VertAlignement{VCenter, Top, Bottom};
00080 
00081     bool scaleLayersOnPrint(){return d_scale_on_print;};
00082     void setScaleLayersOnPrint(bool on){d_scale_on_print = on;};
00083 
00084     bool printCropmarksEnabled(){return d_print_cropmarks;};
00085     void printCropmarks(bool on){d_print_cropmarks = on;};
00086 
00087     bool scaleLayersOnResize(){return d_scale_layers;};
00088     void setScaleLayersOnResize(bool ok){d_scale_layers = ok;};
00089 
00090     QRect canvasRect(){return canvas->rect();};
00091 
00092 public slots:
00093     Graph* addLayer(int x = 0, int y = 0, int width = 0, int height = 0);
00094 
00095     bool isEmpty();
00096     void removeLayer();
00097     void confirmRemoveLayer();
00098 
00099     Graph* activeLayer(){return active_graph;};
00100     void setActiveLayer(Graph* g);
00101     void activateGraph(LayerButton* button);
00102 
00103     void setGraphGeometry(int x, int y, int w, int h);
00104 
00105     void findBestLayout(int &rows, int &cols);
00106 
00107     QSize arrangeLayers(bool userSize);
00108     void arrangeLayers(bool fit, bool userSize);
00109     bool swapLayers(int src, int dest);
00110     void adjustSize();
00111 
00112     int getRows(){return d_rows;};
00113     void setRows(int r);
00114 
00115     int getCols(){return d_cols;};
00116     void setCols(int c);
00117 
00118     int colsSpacing(){return colsSpace;};
00119     int rowsSpacing(){return rowsSpace;};
00120     void setSpacing (int rgap, int cgap);
00121 
00122     int leftMargin(){return left_margin;};
00123     int rightMargin(){return right_margin;};
00124     int topMargin(){return top_margin;};
00125     int bottomMargin(){return bottom_margin;};
00126     void setMargins (int lm, int rm, int tm, int bm);
00127 
00128     QSize layerCanvasSize(){return QSize(l_canvas_width, l_canvas_height);};
00129     void setLayerCanvasSize (int w, int h);
00130 
00131     int horizontalAlignement(){return hor_align;};
00132     int verticalAlignement(){return vert_align;};
00133     void setAlignement (int ha, int va);
00134 
00136 
00137     QPixmap canvasPixmap();
00138     void exportToFile(const QString& fileName);
00139     void exportImage(const QString& fileName, int quality = 100, bool transparent = false);
00140     void exportSVG(const QString& fname);
00141     void exportPDF(const QString& fname);
00142     void exportVector(const QString& fileName, int res = 0, bool color = true,
00143                     bool keepAspect = true, QPrinter::PageSize pageSize = QPrinter::Custom);
00144 
00145     void copyAllLayers();
00146     void print();
00147     void printAllLayers(QPainter *painter);
00148     void printActiveLayer();
00150 
00151     void setFonts(const QFont& titleFnt, const QFont& scaleFnt,
00152                             const QFont& numbersFnt, const QFont& legendFnt);
00153 
00154     void connectLayer(Graph *g);
00155 
00156     QString saveToString(const QString& geometry, bool = false);
00157     QString saveAsTemplate(const QString& geometryInfo);
00158 
00159 signals:
00160     void showTextDialog();
00161     void showPlotDialog(int);
00162     void showAxisDialog(int);
00163     void showScaleDialog(int);
00164     void showGraphContextMenu();
00165     void showCurveContextMenu(QwtPlotCurve *);
00166     void showCurvesDialog();
00167     void drawTextOff();
00168     void drawLineEnded(bool);
00169     void showAxisTitleDialog();
00170     void showMarkerPopupMenu();
00171     void modifiedPlot();
00172     void cursorInfo(const QString&);
00173     void showImageDialog();
00174     void showLineDialog();
00175     void viewTitleDialog();
00176     void createTable(const QString&,int,int,const QString&);
00177     void pasteMarker();
00178     void setPointerCursor();
00179     void currentFontChanged(const QFont&);
00180     void enableTextEditor(Graph *);
00181 
00182 private:
00184 
00185     void wheelEvent(QWheelEvent *);
00186     void keyPressEvent(QKeyEvent *);
00187     bool eventFilter(QObject *object, QEvent *);
00188     void releaseLayer();
00189     void resizeLayers(QResizeEvent *);
00190     bool focusNextPrevChild(bool next);
00192 
00193     LayerButton* addLayerButton();
00194 
00195     Graph* active_graph;
00197     int d_cols, d_rows, graph_width, graph_height, colsSpace, rowsSpace;
00198     int left_margin, right_margin, top_margin, bottom_margin;
00199     int l_canvas_width, l_canvas_height, hor_align, vert_align;
00200     bool d_scale_on_print, d_print_cropmarks;
00202     bool d_scale_layers;
00203 
00204     QList<LayerButton *> buttonsList;
00205     QList<Graph *> graphsList;
00206     QHBoxLayout *layerButtonsBox;
00207     QWidget *canvas;
00208 
00209     QPointer<SelectionMoveResizer> d_layers_selector;
00210 };
00211 
00213 class LayerButton: public QPushButton
00214 {
00215     Q_OBJECT
00216 
00217 public:
00218     LayerButton (const QString& text = QString::null, QWidget* parent = 0);
00219     static int btnSize(){return 20;};
00220 
00221 protected:
00222     void mousePressEvent( QMouseEvent * );
00223     void mouseDoubleClickEvent ( QMouseEvent * );
00224 
00225 signals:
00226     void showCurvesDialog();
00227     void clicked(LayerButton*);
00228 };
00229 
00230 #endif

Generated on Tue Jun 17 08:36:13 2008 for QtiPlot by  doxygen 1.5.5