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

Generated on Thu Feb 7 13:59:27 2008 for QtiPlot by  doxygen 1.5.4