QtiPlot 0.9.8.2
Graph.h
Go to the documentation of this file.
00001 /***************************************************************************
00002     File                 : Graph.h
00003     Project              : QtiPlot
00004     --------------------------------------------------------------------
00005     Copyright            : (C) 2004-2008 by Ion Vasilief
00006     Email (use @ for *)  : ion_vasilief*yahoo.fr
00007     Description          : Graph widget
00008 
00009  ***************************************************************************/
00010 
00011 /***************************************************************************
00012  *                                                                         *
00013  *  This program is free software; you can redistribute it and/or modify   *
00014  *  it under the terms of the GNU General Public License as published by   *
00015  *  the Free Software Foundation; either version 2 of the License, or      *
00016  *  (at your option) any later version.                                    *
00017  *                                                                         *
00018  *  This program is distributed in the hope that it will be useful,        *
00019  *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
00020  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
00021  *  GNU General Public License for more details.                           *
00022  *                                                                         *
00023  *   You should have received a copy of the GNU General Public License     *
00024  *   along with this program; if not, write to the Free Software           *
00025  *   Foundation, Inc., 51 Franklin Street, Fifth Floor,                    *
00026  *   Boston, MA  02110-1301  USA                                           *
00027  *                                                                         *
00028  ***************************************************************************/
00029 #ifndef GRAPH_H
00030 #define GRAPH_H
00031 
00032 #include <QList>
00033 #include <QPointer>
00034 #include <QPrinter>
00035 #include <QVector>
00036 #include <QEvent>
00037 #include <QMap>
00038 
00039 #include <qwt_text.h>
00040 #include <qwt_plot.h>
00041 #include <qwt_plot_marker.h>
00042 #include <qwt_plot_curve.h>
00043 
00044 #include <AxesDialog.h>
00045 #include <PlotToolInterface.h>
00046 #include <ScaleDraw.h>
00047 #include <FrameWidget.h>
00048 #include <float.h>
00049 
00050 class QwtPlotPanner;
00051 class QwtPlotMagnifier;
00052 class QwtPlotCurve;
00053 class QwtPlotZoomer;
00054 class PieCurve;
00055 class Table;
00056 class ArrowMarker;
00057 class ImageWidget;
00058 class TitlePicker;
00059 class ScalePicker;
00060 class CanvasPicker;
00061 class ApplicationWindow;
00062 class Matrix;
00063 class SelectionMoveResizer;
00064 class RangeSelectorTool;
00065 class DataCurve;
00066 class PlotCurve;
00067 class ErrorBarsCurve;
00068 class MultiLayer;
00069 class Spectrogram;
00070 class FunctionCurve;
00071 class VectorCurve;
00072 class BoxCurve;
00073 class QwtHistogram;
00074 class Grid;
00075 class TexWidget;
00076 class LegendWidget;
00077 
00079 typedef struct{
00080   QColor lCol;     
00081   float lWidth;    
00082   int lStyle;      
00083   double filledArea;  
00084   QColor aCol;     
00085   int aStyle;      
00086   QColor symCol;   
00087   QColor fillCol;  
00088   float penWidth;  
00089   int sSize;       
00090   int sType;       
00091   int connectType; 
00092 }  CurveLayout;
00093 
00122 class Graph: public QwtPlot
00123 {
00124     Q_OBJECT
00125 
00126     public:
00127         Graph (int x = 0, int y = 0, int width = 500, int height = 400, QWidget* parent=0, Qt::WFlags f=0);
00128         ~Graph();
00129 
00130         enum Axis{Left, Right, Bottom, Top};
00131         enum Scale{Linear, Log10, Ln, Log2, Reciprocal, Probability, Logit};
00132         enum Ticks{NoTicks = 0, Out = 1, InOut = 2, In = 3};
00133         enum MarkerType{None = -1, Text = 0, Arrow = 1, Image = 2};
00134         enum CurveType{Line, Scatter, LineSymbols, VerticalBars, Area, Pie, VerticalDropLines,
00135             Spline, HorizontalSteps, Histogram, HorizontalBars, VectXYXY, ErrorBars,
00136             Box, VectXYAM, VerticalSteps, ColorMap, GrayScale, Contour, Function, ImagePlot,
00137             StackBar, StackColumn};
00138         enum LegendDisplayMode{ColumnName, ColumnComment, TableName, TableLegend};
00139         enum AxisTitlePolicy{Default, ColName, ColComment, NameAndComment};
00140 
00142         MultiLayer *multiLayer() const;
00143 
00145         void setActiveTool(PlotToolInterface *tool);
00147         PlotToolInterface* activeTool() const { return d_active_tool; }
00149         bool hasActiveTool();
00150 
00151         QList <LegendWidget *> textsList();
00152         LegendWidget *activeText();
00153         void setActiveText(LegendWidget *l){d_active_enrichment = (FrameWidget *)l;};
00154         void select(QWidget *l, bool add = false);
00155 
00156         FrameWidget *activeEnrichment(){return d_active_enrichment;};
00157         QList <FrameWidget *> enrichmentsList(){return d_enrichments;};
00158         QList <FrameWidget *> increasingAreaEnrichmentsList();
00159 
00160         bool hasSeletedItems();
00161         void deselect();
00162         void deselect(QWidget *);
00163         void selectCanvas();
00164 
00165         QPointer<SelectionMoveResizer> selectionMoveResizer(){return d_markers_selector;};
00166 
00167         QwtPlotItem* selectedCurveLabels();
00169         void restoreCurveLabels(int curveID, const QStringList& lst);
00170 
00171         Grid *grid(){return (Grid *)d_grid;};
00172         QList<QwtPlotItem *> curvesList(){return d_curves;};
00173 
00174         QwtPlotItem* closestCurve(int xpos, int ypos, int &dist, int &point);
00175 
00176         void insertMarker(QwtPlotMarker *m);
00177 
00178         QList<int> getMajorTicksType();
00179         void setMajorTicksType(int axis, int type);
00180 
00181         QList<int> getMinorTicksType();
00182         void setMinorTicksType(int axis, int type);
00183 
00184         int minorTickLength() const;
00185         int majorTickLength() const;
00186         void setTickLength (int minLength, int majLength);
00187 
00188         int axesLinewidth() const;
00189         void setAxesLinewidth(int width);
00190 
00191         void axisLabelFormat(int axis, char &f, int &prec) const;
00192 
00193         int axisLabelFormat(int axis);
00194         int axisLabelPrecision(int axis);
00195 
00196         QColor frameColor();
00197         const QColor & paletteBackgroundColor() const;
00198 
00199         void print(QPainter *, const QRect &rect, const QwtPlotPrintFilter & = QwtPlotPrintFilter());
00200         void updateLayout();
00201         void setCanvasGeometry(const QRect &canvasRect);
00203         void setCanvasGeometry(int x, int y, int w, int h){setCanvasGeometry(QRect(x, y, w, h));};
00204         void setCanvasSize(const QSize &size);
00206         void setCanvasSize(int w, int h){setCanvasSize(QSize(w, h));};
00207 
00208         void updateCurveLabels();
00209 
00210         TexWidget* addTexFormula(const QString& s, const QPixmap& pix);
00211 
00212         FrameWidget* add(FrameWidget* fw, bool copy = true);
00213         void remove(FrameWidget*);
00214 
00215         QRect boundingRect();
00216         void raiseEnrichements();
00217         void addLegendItem();
00218         bool isPrinting(){return d_is_printing;};
00219 
00220         void enablePanningMagnifier(bool on = true, int mode = 0);
00221         bool hasPanningMagnifierEnabled(){if (d_magnifier && d_panner) return true; return false;};
00222         QwtPlotMagnifier* magnifyTool(){return d_magnifier;};
00223 
00224 #ifdef TEX_OUTPUT
00225         static QString escapeTeXSpecialCharacters(const QString &);
00226         static QString texSuperscripts(const QString &);
00227 #endif
00228         void changeCurveIndex(int fromIndex, int toIndex);
00229         void enableDouglasPeukerSpeedMode(double tolerance, int maxPoints);
00230 
00231         int speedModeMaxPoints(){return d_speed_mode_points;};
00232         double getDouglasPeukerTolerance(){return d_Douglas_Peuker_tolerance;};
00233 
00234         AxisTitlePolicy axisTitlePolicy(){return d_axis_title_policy;};
00235         void setAxisTitlePolicy(const AxisTitlePolicy& policy){d_axis_title_policy = policy;};
00236         void setSynchronizedScaleDivisions(bool on){d_synchronize_scales = on;};
00237 
00238     public slots:
00239         void copy(Graph* g);
00240         void copyCurves(Graph* g);
00241         void copyScaleWidget(Graph* g, int i);
00242         void copyScaleDraw(Graph* g, int i);
00243 
00245 
00246 
00247         bool isPiePlot();
00249         PieCurve* plotPie(Table* w,const QString& name, int startRow = 0, int endRow = -1);
00251         PieCurve* plotPie(Table* w, const QString& name, const QPen& pen, int brush, int size,
00252             int firstColor, int startRow = 0, int endRow = -1, bool visible = true,
00253             double d_start_azimuth = 270, double d_view_angle = 90, double d_thickness = 33,
00254             double d_horizontal_offset = 0.0, double d_edge_dist = 25, bool d_counter_clockwise = false,
00255             bool d_auto_labeling = true, bool d_values = false, bool d_percentages = true,
00256             bool d_categories = false, bool d_fixed_labels_pos = true);
00257 
00258         void removePie();
00259         QString pieLegendText();
00260         QString savePieCurveLayout();
00262 
00263         bool addCurves(Table* w, const QStringList& names, int style = 0, double lWidth = 1, int sSize = 3, int startRow = 0, int endRow = -1);
00264         DataCurve* insertCurve(Table* w, const QString& name, int style, int startRow = 0, int endRow = -1);
00265         DataCurve* insertCurve(Table* w, int xcol, const QString& name, int style);
00266         DataCurve* insertCurve(Table* w, const QString& xColName, const QString& yColName, int style, int startRow = 0, int endRow = -1);
00267         void insertPlotItem(QwtPlotItem *i, int type);
00268         void insertCurve(QwtPlotItem *c);
00269 
00271         void showCurve(int index, bool visible = true);
00272         int visibleCurves();
00273 
00274         void removeCurve(QwtPlotItem *it);
00276         void removeCurve(int index);
00280         void removeCurve(const QString& s);
00284         void removeCurves(const QString& s);
00285 
00286         void updateCurvesData(Table* w, const QString& yColName);
00287         void reloadCurvesData();
00288 
00289         int curveCount(){return d_curves.size();};
00290         bool validCurvesDataSize();
00291         double selectedXStartValue();
00292         double selectedXEndValue();
00293 
00295         int curveIndex(QwtPlotItem *c){return d_curves.indexOf(c);};
00297         int curveIndex(const QString &title){return plotItemsList().indexOf(title);}
00298         DataCurve* dataCurve(int index);
00299         FunctionCurve* functionCurve(int index);
00301         PlotCurve* curve(int index);
00303         PlotCurve* curve(const QString &title){return curve(curveIndex(title));};
00305         QString curveTitle(int index);
00306 
00308         QStringList analysableCurvesList();
00310         QStringList curveNamesList();
00312         QStringList plotItemsList();
00314         QwtPlotItem* plotItem(int index);
00315 
00316         void updateCurveNames(const QString& oldName, const QString& newName, bool updateTableName = true);
00317 
00319 
00320         void setCurveStyle(int index, int s);
00321         void setCurveFullRange(int curveIndex);
00322         void setCurveLineColor(int curveIndex, int colorIndex);
00323         void setCurveLineColor(int curveIndex, QColor qColor);
00324         void setCurveLineStyle(int curveIndex, Qt::PenStyle style);
00325         void setCurveLineWidth(int curveIndex, double width);
00326         void setGrayScale();
00327         void setIndexedColors();
00329 
00331 
00332         void print();
00333         void copyImage();
00334         QPixmap graphPixmap(const QSize& size = QSize(), double scaleFontsFactor = 1.0, bool transparent = false);
00336         void exportToFile(const QString& fileName);
00337         void exportSVG(const QString& fname, const QSizeF& customSize = QSizeF(), int unit = FrameWidget::Pixel, double fontsFactor = 1.0);
00338         void exportEMF(const QString& fname, const QSizeF& customSize = QSizeF(), int unit = FrameWidget::Pixel, double fontsFactor = 1.0);
00339         void exportTeX(const QString& fname, bool color = true, bool escapeStrings = true, bool fontSizes = true,
00340                         const QSizeF& customSize = QSizeF(), int unit = FrameWidget::Pixel, double fontsFactor = 1.0);
00341 #ifdef TEX_OUTPUT
00342         bool isExportingTeX(){return d_is_exporting_tex;};
00343         void setTeXExportingMode(bool on = true){d_is_exporting_tex = on;};
00344         bool escapeTeXStrings(){return d_tex_escape_strings;};
00345         void setEscapeTeXStringsMode(bool on = true){d_tex_escape_strings = on;};
00346 #endif
00347         void exportVector(const QString& fileName, int res = 0, bool color = true,
00348                         const QSizeF& customSize = QSizeF (), int unit = FrameWidget::Pixel, double fontsFactor = 1.0);
00349         void exportImage(const QString& fileName, int quality = 100, bool transparent = false,
00350                          int dpi = 0, const QSizeF& customSize = QSizeF (),
00351                          int unit = FrameWidget::Pixel, double fontsFactor = 1.0);
00352 
00353         void draw(QPaintDevice *, const QSize& size, double fontsFactor = 1.0);
00354         static QSize customPrintSize(const QSizeF& customSize, int unit, int dpi);
00356 
00357         void updatePlot();
00358 
00360 
00361         ErrorBarsCurve* addErrorBars(const QString& xColName, const QString& yColName, Table *errTable,
00362                 const QString& errColName, int type = 1, double width = 1, int cap = 8, const QColor& color = QColor(Qt::black),
00363                 bool through = true, bool minus = true, bool plus = true);
00364 
00365         ErrorBarsCurve* addErrorBars(const QString& yColName, Table *errTable, const QString& errColName,
00366                 int type = 1, double width = 1, int cap = 8, const QColor& color = QColor(Qt::black),
00367                 bool through = true, bool minus = true, bool plus = true);
00368 
00369         ErrorBarsCurve* addErrorBars(DataCurve *c, Table *errTable, const QString& errColName,
00370                 int type = 1, double width = 1, int cap = 8, const QColor& color = QColor(Qt::black),
00371                 bool through = true, bool minus = true, bool plus = true);
00372 
00373         void updateErrorBars(ErrorBarsCurve *er, bool xErr, double width, int cap, const QColor& c, bool plus, bool minus, bool through);
00374 
00376         DataCurve* masterCurve(ErrorBarsCurve *er);
00378         DataCurve* masterCurve(const QString& xColName, const QString& yColName);
00380 
00382 
00383         bool mousePressed(QEvent *);
00384         void contextMenuEvent(QContextMenuEvent *);
00385         void closeEvent(QCloseEvent *e);
00386         bool focusNextPrevChild ( bool next );
00388 
00390         void invertScale(int axis);
00391         void setScale(int axis, double start, double end, double step = 0.0,
00392                 int majorTicks = 5, int minorTicks = 5, int type = 0, bool inverted = false,
00393                 double left_break = -DBL_MAX, double right_break = DBL_MAX, int pos = 50,
00394                 double stepBeforeBreak = 0.0, double stepAfterBreak = 0.0, int minTicksBeforeBreak = 4,
00395                 int minTicksAfterBreak = 4, bool log10AfterBreak = false, int breakWidth = 4, bool breakDecoration = true);
00396         double axisStep(int axis){return d_user_step[axis];};
00397         void setAxisStep(int axis, double step){d_user_step[axis] = step;};
00398         void setCanvasCoordinates(const QRectF&);
00399 
00401 
00402         CurveLayout initCurveLayout(int style, int curves = 0, bool guessLayout = true);
00403         static CurveLayout initCurveLayout();
00404         void updateCurveLayout(PlotCurve* c, const CurveLayout *cL);
00406         void guessUniqueCurveLayout(int& colorIndex, int& symbolIndex);
00408 
00410 
00411         void zoomed (const QwtDoubleRect &);
00412         void zoom(bool on);
00413         void zoomOut();
00414         bool zoomOn();
00416 
00417         void setAutoScale();
00418         void updateScale();
00419 
00421 
00422         QString saveToString(bool saveAsTemplate = false);
00423         QString saveScale();
00424         QString saveScaleTitles();
00425         QString saveFonts();
00426         QString saveMarkers();
00427         QString saveCurveLayout(int index);
00428         QString saveAxesTitleColors();
00429         QString saveAxesColors();
00430         QString saveEnabledAxes();
00431         QString saveCanvas();
00432         QString saveTitle();
00433         QString saveAxesTitleAlignement();
00434         QString saveEnabledTickLabels();
00435         QString saveTicksType();
00436         QString saveCurves();
00437         QString saveLabelsFormat();
00438         QString saveLabelsRotation();
00439         QString saveAxesLabelsType();
00440         QString saveAxesBaseline();
00441         QString saveAxesFormulas();
00442         QString saveAxesBackbones();
00443         QString saveTickLabelsSpace();
00444         QString saveLabelsPrefixAndSuffix();
00445         QString saveBackgroundImage();
00446         void restoreBackgroundImage(const QStringList& lst);
00447         void restoreSymbolImage(int index, const QStringList& lst);
00448         static QString rgbaName(const QColor& color);
00450 
00452 
00453         LegendWidget* addText(LegendWidget*);
00455         LegendWidget* insertText(const QStringList& list, int fileVersion);
00456 
00457         LegendWidget* addTimeStamp();
00458         void removeLegendItem(int index);
00459         void insertLegend(const QStringList& lst, int fileVersion);
00460 
00461         LegendWidget* newLegend(const QString& text = QString());
00463         QString legendText(bool layerSpec = false, int fromIndex = 0);
00465 
00467 
00468         LegendWidget* legend();
00469         void setLegend(const QString&);
00470         void removeLegend();
00472 
00474 
00475         ArrowMarker* addArrow(ArrowMarker* mrk);
00476         void remove(ArrowMarker* arrow);
00477 
00479         void addArrow(QStringList list, int fileVersion);
00480         QList<ArrowMarker *> arrowsList(){return d_lines;};
00481         int numArrows(){return d_lines.count();};
00482 
00484         void drawLine(bool on, bool arrow = false);
00485         bool drawArrow(){return drawArrowOn;};
00486         bool drawLineActive(){return drawLineOn;};
00487         bool arrowMarkerSelected();
00489 
00491 
00492         ImageWidget* addImage(ImageWidget* i);
00493         ImageWidget* addImage(const QString& fileName);
00494         ImageWidget* addImage(const QImage& image);
00495 
00496         void insertImageMarker(const QStringList& lst, int fileVersion);
00497         bool imageMarkerSelected();
00499 
00501 
00502         void removeMarker();
00504         void updateMarkersBoundingRect(bool rescaleEvent = true);
00505 
00512         void setSelectedArrow(ArrowMarker* mrk, bool add = false);
00513         ArrowMarker* selectedArrow(){return d_selected_arrow;};
00514         bool markerSelected();
00516         void deselectMarker();
00518 
00520 
00521         QwtScaleWidget* currentScale();
00522         QwtScaleWidget* selectedScale();
00523         QRect axisTitleRect(const QwtScaleWidget *scale);
00524         bool axisTitleSelected();
00525 
00526         ScaleDraw::ScaleType axisType(int axis);
00527 
00528         void setXAxisTitle(const QString& text);
00529         void setYAxisTitle(const QString& text);
00530         void setRightAxisTitle(const QString& text);
00531         void setTopAxisTitle(const QString& text);
00532 
00533         QString axisTitleString(int axis);
00534         void setAxisTitleString(int axis, const QString& text);
00535         void setAxisTitle(int axis, const QString& text);
00536         void updateAxesTitles();
00538         void setScaleTitle(int axis, const QString& text);
00539 
00540         QFont axisTitleFont(int axis);
00541         void setAxisTitleFont(int axis,const QFont &fnt);
00542 
00543         void setAxisFont(int axis, const QFont &fnt);
00544         void initFonts(const QFont &scaleTitleFnt,const QFont &numbersFnt);
00545 
00546         QColor axisTitleColor(int axis);
00547         void setAxisTitleColor(int axis, const QColor& c);
00548 
00549         int axisTitleAlignment (int axis);
00550         void setAxisTitleAlignment(int axis, int align);
00551 
00552         int axisTitleDistance(int axis);
00553         void setAxisTitleDistance(int axis, int dist);
00554 
00555         QColor axisColor(int axis);
00556         void setAxisColor(int axis, const QColor& color);
00557 
00558         QColor axisLabelsColor(int axis);
00559         void setAxisLabelsColor(int axis, const QColor& color);
00560 
00561         void showAxis(int axis, int type, const QString& formatInfo, Table *table, bool axisOn,
00562                 int majTicksType, int minTicksType, bool labelsOn, const QColor& c, int format,
00563                 int prec, int rotation, int baselineDist, const QString& formula, const QColor& labelsColor,
00564                 int spacing = 4, bool backbone = true, const ScaleDraw::ShowTicksPolicy& showTicks = ScaleDraw::ShowAll,
00565                 const QString& prefix = QString::null, const QString& suffix = QString::null);
00566 
00567         void enableAxis(int axis, bool on = true);
00568         void enableAxisLabels(int axis, bool on = true);
00569 
00570         int labelsRotation(int axis);
00571         void setAxisLabelRotation(int axis, int rotation);
00572 
00574         void loadAxesLinewidth(int width);
00575 
00576         void drawAxesBackbones(bool yes);
00577         bool axesBackbones(){return drawAxesBackbone;};
00579         void loadAxesOptions(const QStringList& lst);
00580 
00581         void setAxisMargin(int axis, int margin);
00582 
00583         void setMajorTicksType(const QList<int>& lst);
00584         void setMajorTicksType(const QStringList& lst);
00585 
00586         void setMinorTicksType(const QList<int>& lst);
00587         void setMinorTicksType(const QStringList& lst);
00588 
00589         void setAxisTicksLength(int axis, int majTicksType, int minTicksType, int minLength, int majLength);
00590         void setTicksLength(int minLength, int majLength);
00591         void changeTicksLength(int minLength, int majLength);
00593         void setLabelsNumericFormat(const QStringList& l);
00594         void setLabelsNumericFormat(int axis, int format, int prec = 6, const QString& formula = QString());
00595         void setLabelsDateTimeFormat(int axis, int type, const QString& formatInfo);
00596         void setLabelsDayFormat(int axis, int format);
00597         void setLabelsMonthFormat(int axis, int format);
00598 
00599         QString axisFormatInfo(int axis);
00600 
00601         void setLabelsTextFormat(int axis, int type, const QString& name, const QStringList& lst);
00602         void setLabelsTextFormat(int axis, int type, const QString& labelsColName, Table *table);
00603 
00604         QString axisFormula(int axis);
00605         void setAxisFormula(int axis, const QString &);
00607 
00609 
00610         void setCanvasFrame(int width = 1, const QColor& color =  QColor(Qt::black));
00611         QColor canvasFrameColor();
00612         int canvasFrameWidth();
00614 
00616 
00617         QString canvasBackgroundFileName(){return d_canvas_bkg_path;};
00618         void setCanvasBackgroundImage (const QString & fn = QString(), bool update = true);
00619         QPixmap backgroundPixmap(){return d_canvas_bkg_pix;};
00621 
00623 
00624         void setTitleFont(const QFont &fnt);
00625         void setTitleColor(const QColor &c);
00626         void setTitleAlignment(int align);
00627 
00628         bool titleSelected();
00629         void selectTitle(bool select = true);
00631         void clearTitle();
00633         void removeTitle();
00634         void initTitle( bool on, const QFont& fnt);
00636 
00637         void disableTools();
00638 
00645         bool enableRangeSelectors(const QObject *status_target=NULL, const char *status_slot="");
00646         bool rangeSelectorsEnabled();
00647         QPointer<RangeSelectorTool> rangeSelectorTool(){return d_range_selector;};
00649 
00650         void setFrame(int width = 1, const QColor& color = Qt::black);
00651         void setBackgroundColor(const QColor& color);
00653 
00654         void addFitCurve(QwtPlotCurve *c);
00655         void deleteFitCurves();
00656         QList<QwtPlotCurve *> fitCurvesList(){return d_fit_curves;};
00661         int range(const QString& curveTitle, double *start, double *end);
00666         int range(QwtPlotCurve *c, double *start, double *end);
00667 
00669         void setBarsGap(int curve, int gapPercent, int offset);
00670 
00672 
00673         void modifyFunctionCurve(int curve, int type, const QStringList &formulas, const QString &var,
00674             double start, double end, int points, const QMap<QString, double>& constants);
00675         FunctionCurve* addFunction(const QStringList &formulas, double start, double end, int points = 100, const QString &var = "x", int type = 0, const QString& title = QString::null);
00677         FunctionCurve* insertFunctionCurve(const QString& formula, int points, int fileVersion);
00678 
00680         QString generateFunctionName(const QString& name = tr("F"));
00682 
00684         void createTable(const QString& curveName);
00685         void createTable(const QwtPlotCurve* curve);
00686         void activateGraph();
00687 
00689 
00690         VectorCurve* plotVectors(Table* w, const QStringList& colList, int style, int startRow = 0, int endRow = -1);
00691         void updateVectorsLayout(int curve, const QColor& color, double width, int arrowLength, int arrowAngle, bool filled, int position,
00692                 const QString& xEndColName = QString(), const QString& yEndColName = QString());
00694 
00696 
00697         BoxCurve* openBoxDiagram(Table *w, const QStringList& l, int fileVersion);
00698         void plotBox(Table *w, const QStringList& names, int startRow = 0, int endRow = -1);
00699         BoxCurve * boxCurve(int index);
00701 
00703 
00704         void resizeEvent(QResizeEvent *e);
00705         void scaleFonts(double factor);
00707 
00708         void notifyChanges();
00709 
00710         void updateSecondaryAxis(int axis, bool changeFormat = false);
00711 
00712         bool isAutoscalingEnabled(){return d_auto_scale;};
00713         void enableAutoscaling(bool on = true){d_auto_scale = on;};
00714 
00715         bool autoscaleFonts(){return autoScaleFonts;};
00716         void setAutoscaleFonts(bool on = true){autoScaleFonts = on;};
00717 
00718         static int obsoleteSymbolStyle(int type);
00719         static QString penStyleName(Qt::PenStyle style);
00720         static Qt::PenStyle getPenStyle(const QString& s);
00721         static Qt::PenStyle getPenStyle(int style);
00722         static void showPlotErrorMessage(QWidget *parent, const QStringList& emptyColumns);
00723 
00724         void showTitleContextMenu();
00725         void copyTitle();
00726         void cutTitle();
00727 
00728         void clearAxisTitle();
00729         void removeAxisTitle();
00730         void cutAxisTitle();
00731         void copyAxisTitle();
00732         void showAxisTitleMenu();
00733         void showAxisContextMenu(int axis);
00734         void hideSelectedAxis();
00735         void showGrids();
00736 
00738         void showGrid();
00740         void showGrid(int axis);
00741 
00742         void showAxisDialog();
00743         void showScaleDialog();
00744 
00746         Spectrogram* spectrogram(Matrix *m);
00748         Spectrogram* plotSpectrogram(Matrix *m, CurveType type);
00750         void restoreSpectrogram(ApplicationWindow *app, const QStringList& lst);
00752         QwtHistogram* addHistogram(Matrix *m);
00754         QwtHistogram* restoreHistogram(Matrix *m, const QStringList& l);
00755 
00756         bool antialiasing(){return d_antialiasing;};
00758         void setAntialiasing(bool on = true, bool update = true);
00759 
00760         void disableCurveAntialiasing(bool disable, int maxPoints);
00761         bool isCurveAntialiasingEnabled(QwtPlotItem *it);
00762         bool isCurveAntialiasingDisabled(){return d_disable_curve_antialiasing;};
00763         int maxAntialisingSize(){return d_max_antialising_size;};
00764 
00765         void setCurrentColor(const QColor& c);
00766         void notifyColorChange(const QColor& c){emit currentColorChanged(c);};
00767         void setCurrentFont(const QFont& f);
00768         void notifyFontChange(const QFont& f){emit currentFontChanged(f);};
00769         void enableTextEditor();
00770 
00771 signals:
00772         void selectedGraph(Graph*);
00773         void selectedCanvas(Graph*);
00774         void closedGraph();
00775         void drawLineEnded(bool);
00776         void cursorInfo(const QString&);
00777         void showPlotDialog(int);
00778 
00779         void viewLineDialog();
00780         void viewTitleDialog();
00781         void modifiedGraph();
00782         void hiddenPlot(QWidget*);
00783 
00784         void showContextMenu();
00785         void showCurveContextMenu(QwtPlotItem *);
00786         void showMarkerPopupMenu();
00787 
00788         void showAxisDialog(int);
00789         void axisDblClicked(int);
00790 
00791         void showAxisTitleDialog();
00792 
00793         void dataRangeChanged();
00794         void showFitResults(const QString&);
00795         void currentFontChanged(const QFont&);
00796         void currentColorChanged(const QColor&);
00797         void enableTextEditor(Graph *);
00798         void axisDivChanged(Graph *, int);
00799         void updatedLayout(Graph *);
00800         void selectionChanged(SelectionMoveResizer *);
00801 
00802     private slots:
00803         void selectorDeleted();
00804 
00805     private:
00806         QString parseAxisTitle(int axis);
00807         QList<FrameWidget*> stackingOrderEnrichmentsList() const;
00809         QwtDoubleInterval axisBoundingInterval(int axis);
00810         void deselectCurves();
00811 
00812         void dropEvent(QDropEvent*);
00813         void dragEnterEvent(QDragEnterEvent*);
00814         void showEvent (QShowEvent * event);
00815         void printFrame(QPainter *painter, const QRect &rect) const;
00816         void printCanvas(QPainter *painter, const QRect &canvasRect,
00817              const QwtScaleMap map[axisCnt], const QwtPlotPrintFilter &pfilter) const;
00818         virtual void printScale (QPainter *, int axisId, int startDist, int endDist,
00819             int baseDist, const QRect &) const;
00820         virtual void drawItems (QPainter *painter, const QRect &rect,
00821             const QwtScaleMap map[axisCnt], const QwtPlotPrintFilter &pfilter) const;
00822 
00823         void drawInwardTicks(QPainter *painter, const QRect &rect,
00824                             const QwtScaleMap&map, int axis, bool min, bool maj) const;
00825         void drawBreak(QPainter *painter, const QRect &rect, const QwtScaleMap &map, int axis) const;
00826 
00827         QwtPlotZoomer *d_zoomer[2];
00828         TitlePicker *titlePicker;
00829         ScalePicker *scalePicker;
00830         CanvasPicker* cp;
00832         Grid *d_grid;
00834         QList<QwtPlotItem*> d_curves;
00836         QList<QwtPlotCurve *>d_fit_curves;
00838         bool d_antialiasing;
00839         bool d_disable_curve_antialiasing;
00840         int d_max_antialising_size;
00841         bool autoScaleFonts;
00842         bool drawLineOn, drawArrowOn, drawAxesBackbone;
00844         bool d_is_printing;
00846         QVector<double> d_user_step;
00848         QList<ArrowMarker*> d_lines;
00850         ArrowMarker* d_selected_arrow;
00852         QPointer<SelectionMoveResizer> d_markers_selector;
00854         QPointer<RangeSelectorTool> d_range_selector;
00856         PlotToolInterface *d_active_tool, *d_peak_fit_tool;
00858         FrameWidget *d_active_enrichment;
00860         bool d_auto_scale;
00862         int d_min_tick_length, d_maj_tick_length;
00863 #ifdef TEX_OUTPUT
00864         bool d_is_exporting_tex;
00865         bool d_tex_escape_strings;
00866 #endif
00867         QList<FrameWidget*> d_enrichments;
00868         QwtPlotMagnifier *d_magnifier;
00869         QwtPlotPanner *d_panner;
00870 
00871         double d_Douglas_Peuker_tolerance;
00872         int d_speed_mode_points;
00873         AxisTitlePolicy d_axis_title_policy;
00874         bool d_synchronize_scales;
00875         QStringList d_axis_titles;
00876 
00877         QString d_canvas_bkg_path;
00878         QPixmap d_canvas_bkg_pix;
00879 };
00880 #endif // GRAPH_H