QtiPlot 0.9.8.2
|
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 ImageProfilesTool; 00066 class DataCurve; 00067 class PlotCurve; 00068 class ErrorBarsCurve; 00069 class MultiLayer; 00070 class Spectrogram; 00071 class FunctionCurve; 00072 class VectorCurve; 00073 class BoxCurve; 00074 class QwtHistogram; 00075 class Grid; 00076 class TexWidget; 00077 class LegendWidget; 00078 00080 typedef struct{ 00081 QColor lCol; 00082 float lWidth; 00083 int lStyle; 00084 double filledArea; 00085 QColor aCol; 00086 int aStyle; 00087 QColor symCol; 00088 QColor fillCol; 00089 float penWidth; 00090 int sSize; 00091 int sType; 00092 int connectType; 00093 } CurveLayout; 00094 00123 class Graph: public QwtPlot 00124 { 00125 Q_OBJECT 00126 00127 public: 00128 Graph (int x = 0, int y = 0, int width = 500, int height = 400, QWidget* parent=0, Qt::WFlags f=0); 00129 ~Graph(); 00130 00131 enum Axis{Left, Right, Bottom, Top}; 00132 enum Scale{Linear, Log10, Ln, Log2, Reciprocal, Probability, Logit}; 00133 enum Ticks{NoTicks = 0, Out = 1, InOut = 2, In = 3}; 00134 enum MarkerType{None = -1, Text = 0, Arrow = 1, Image = 2}; 00135 enum CurveType{Line, Scatter, LineSymbols, VerticalBars, Area, Pie, VerticalDropLines, 00136 Spline, HorizontalSteps, Histogram, HorizontalBars, VectXYXY, ErrorBars, 00137 Box, VectXYAM, VerticalSteps, ColorMap, GrayScale, Contour, Function, ImagePlot, 00138 StackBar, StackColumn}; 00139 enum LegendDisplayMode{Auto, ColumnName, ColumnComment, TableName, TableLegend}; 00140 enum AxisTitlePolicy{Default, ColName, ColComment, NameAndComment}; 00141 00143 MultiLayer *multiLayer() const; 00144 00146 void setActiveTool(PlotToolInterface *tool); 00148 PlotToolInterface* activeTool() const { return d_active_tool; } 00150 bool hasActiveTool(); 00151 00152 QList <LegendWidget *> textsList(); 00153 LegendWidget *activeText(); 00154 void setActiveText(LegendWidget *l){d_active_enrichment = (FrameWidget *)l;}; 00155 void select(QWidget *l, bool add = false); 00156 00157 FrameWidget *activeEnrichment(){return d_active_enrichment;}; 00158 QList <FrameWidget *> enrichmentsList(){return d_enrichments;}; 00159 QList <FrameWidget *> increasingAreaEnrichmentsList(); 00160 00161 bool hasSeletedItems(); 00162 void deselect(); 00163 void deselect(QWidget *); 00164 void selectCanvas(); 00165 00166 QPointer<SelectionMoveResizer> selectionMoveResizer(){return d_markers_selector;}; 00167 00168 QwtPlotItem* selectedCurveLabels(); 00170 void restoreCurveLabels(int curveID, const QStringList& lst); 00171 00172 Grid *grid(){return (Grid *)d_grid;}; 00173 QList<QwtPlotItem *> curvesList(){return d_curves;}; 00174 void setCurvesList(QList<QwtPlotItem *> lst){d_curves = lst;}; 00175 00176 QwtPlotItem* closestCurve(int xpos, int ypos, int &dist, int &point); 00177 00178 void insertMarker(QwtPlotMarker *m); 00179 00180 QList<int> getMajorTicksType(); 00181 void setMajorTicksType(int axis, int type); 00182 00183 QList<int> getMinorTicksType(); 00184 void setMinorTicksType(int axis, int type); 00185 00186 int minorTickLength() const; 00187 int majorTickLength() const; 00188 void setTickLength (int minLength, int majLength); 00189 00190 int axesLinewidth() const; 00191 void setAxesLinewidth(int width); 00192 00193 void axisLabelFormat(int axis, char &f, int &prec) const; 00194 00195 int axisLabelFormat(int axis); 00196 int axisLabelPrecision(int axis); 00197 00198 QColor frameColor(); 00199 const QColor & paletteBackgroundColor() const; 00200 00201 void print(QPainter *, const QRect &rect, const QwtPlotPrintFilter & = QwtPlotPrintFilter()); 00202 void updateLayout(); 00203 void setCanvasGeometry(const QRect &canvasRect); 00205 void setCanvasGeometry(int x, int y, int w, int h){setCanvasGeometry(QRect(x, y, w, h));}; 00206 void setCanvasSize(const QSize &size); 00208 void setCanvasSize(int w, int h){setCanvasSize(QSize(w, h));}; 00209 00210 void updateCurveLabels(); 00211 00212 TexWidget* addTexFormula(const QString& s, const QPixmap& pix); 00213 00214 FrameWidget* add(FrameWidget* fw, bool copy = true); 00215 void remove(FrameWidget*); 00216 00217 QRect boundingRect(); 00218 void raiseEnrichements(); 00219 void addLegendItem(); 00220 bool isPrinting(){return d_is_printing;}; 00221 00222 void enablePanningMagnifier(bool on = true, int mode = 0); 00223 bool hasPanningMagnifierEnabled(){if (d_magnifier && d_panner) return true; return false;}; 00224 QwtPlotMagnifier* magnifyTool(){return d_magnifier;}; 00225 00226 #ifdef TEX_OUTPUT 00227 static QString escapeTeXSpecialCharacters(const QString &); 00228 static QString texSuperscripts(const QString &); 00229 #endif 00230 void changeCurveIndex(int fromIndex, int toIndex); 00231 void enableDouglasPeukerSpeedMode(double tolerance, int maxPoints = 3000); 00232 00233 int speedModeMaxPoints(){return d_speed_mode_points;}; 00234 double getDouglasPeukerTolerance(){return d_Douglas_Peuker_tolerance;}; 00235 00236 AxisTitlePolicy axisTitlePolicy(){return d_axis_title_policy;}; 00237 void setAxisTitlePolicy(const AxisTitlePolicy& policy){d_axis_title_policy = policy;}; 00238 00239 bool hasSynchronizedScaleDivisions(){return d_synchronize_scales;}; 00240 void setSynchronizedScaleDivisions(bool on){d_synchronize_scales = on;}; 00241 00242 QRectF pageGeometry(){return d_page_rect;} 00243 void setPageGeometry(const QRectF& r){d_page_rect = r;} 00244 00245 public slots: 00246 void copy(Graph* g); 00247 void copyCurves(Graph* g); 00248 void copyEnrichments(Graph* g); 00249 void copyScaleWidget(Graph* g, int i); 00250 void copyScaleDraw(Graph* g, int i); 00251 00253 00254 00255 bool isPiePlot(); 00257 PieCurve* plotPie(Table* w,const QString& name, int startRow = 0, int endRow = -1); 00259 PieCurve* plotPie(Table* w, const QString& name, const QPen& pen, int brush, int size, 00260 int firstColor, int startRow = 0, int endRow = -1, bool visible = true, 00261 double d_start_azimuth = 270, double d_view_angle = 90, double d_thickness = 33, 00262 double d_horizontal_offset = 0.0, double d_edge_dist = 25, bool d_counter_clockwise = false, 00263 bool d_auto_labeling = true, bool d_values = false, bool d_percentages = true, 00264 bool d_categories = false, bool d_fixed_labels_pos = true); 00265 00266 void removePie(); 00267 QString pieLegendText(); 00268 QString savePieCurveLayout(); 00270 00271 bool addCurves(Table* w, const QStringList& names, int style = 0, double lWidth = 1, int sSize = 3, int startRow = 0, int endRow = -1); 00272 DataCurve* insertCurve(Table* w, const QString& name, int style, int startRow = 0, int endRow = -1); 00273 DataCurve* insertCurve(Table* w, int xcol, const QString& name, int style); 00274 DataCurve* insertCurve(Table* w, const QString& xColName, const QString& yColName, int style, int startRow = 0, int endRow = -1); 00275 DataCurve* insertCurve(Table* xt, const QString& xColName, Table* yt, const QString& yColName, int style, int startRow = 0, int endRow = -1); 00276 void insertPlotItem(QwtPlotItem *i, int type); 00277 void insertCurve(QwtPlotItem *c); 00278 00280 void showCurve(int index, bool visible = true); 00281 int visibleCurves(); 00282 00283 void removeCurve(QwtPlotItem *it); 00285 void removeCurve(int index); 00289 void removeCurve(const QString& s); 00293 void removeCurves(const QString& s); 00294 00295 void updateCurvesData(Table* w, const QString& yColName); 00296 void reloadCurvesData(); 00297 00298 int curveCount(){return d_curves.size();}; 00299 bool validCurvesDataSize(); 00300 double selectedXStartValue(); 00301 double selectedXEndValue(); 00302 00304 int curveIndex(QwtPlotItem *c){return d_curves.indexOf(c);}; 00306 int curveIndex(const QString &title){return plotItemsList().indexOf(title);} 00307 DataCurve* dataCurve(int index); 00308 FunctionCurve* functionCurve(int index); 00310 PlotCurve* curve(int index); 00312 PlotCurve* curve(const QString &title){return curve(curveIndex(title));}; 00314 QString curveTitle(int index); 00316 QString curveRange(QwtPlotCurve *c); 00317 00319 QStringList analysableCurvesList(); 00321 QStringList curveNamesList(); 00323 QStringList plotItemsList(); 00325 QwtPlotItem* plotItem(int index); 00326 00327 void updateCurveNames(const QString& oldName, const QString& newName, bool updateTableName = true); 00328 00330 00331 void setCurveStyle(int index, int s); 00332 void setCurveFullRange(int curveIndex); 00333 void setCurveLineColor(int curveIndex, int colorIndex); 00334 void setCurveLineColor(int curveIndex, QColor qColor); 00335 void setCurveLineStyle(int curveIndex, Qt::PenStyle style); 00336 void setCurveLineWidth(int curveIndex, double width); 00337 void setGrayScale(); 00338 void setIndexedColors(); 00340 00342 00343 void print(); 00344 void copyImage(); 00345 QPixmap graphPixmap(const QSize& size = QSize(), double scaleFontsFactor = 1.0, bool transparent = false); 00347 void exportToFile(const QString& fileName); 00348 void exportSVG(const QString& fname, const QSizeF& customSize = QSizeF(), int unit = FrameWidget::Pixel, double fontsFactor = 1.0); 00349 void exportEMF(const QString& fname, const QSizeF& customSize = QSizeF(), int unit = FrameWidget::Pixel, double fontsFactor = 1.0); 00350 void exportTeX(const QString& fname, bool color = true, bool escapeStrings = true, bool fontSizes = true, 00351 const QSizeF& customSize = QSizeF(), int unit = FrameWidget::Pixel, double fontsFactor = 1.0); 00352 #ifdef TEX_OUTPUT 00353 bool isExportingTeX(){return d_is_exporting_tex;}; 00354 void setTeXExportingMode(bool on = true){d_is_exporting_tex = on;}; 00355 bool escapeTeXStrings(){return d_tex_escape_strings;}; 00356 void setEscapeTeXStringsMode(bool on = true){d_tex_escape_strings = on;}; 00357 #endif 00358 void exportVector(const QString& fileName, int res = 0, bool color = true, 00359 const QSizeF& customSize = QSizeF (), int unit = FrameWidget::Pixel, double fontsFactor = 1.0); 00360 void exportVector(QPrinter *printer, int res = 0, bool color = true, 00361 const QSizeF& customSize = QSizeF (), int unit = FrameWidget::Pixel, double fontsFactor = 1.0); 00362 void exportImage(const QString& fileName, int quality = 100, bool transparent = false, 00363 int dpi = 0, const QSizeF& customSize = QSizeF (), 00364 int unit = FrameWidget::Pixel, double fontsFactor = 1.0, int compression = 0); 00365 00366 void draw(QPaintDevice *, const QSize& size, double fontsFactor = 1.0); 00367 static QSize customPrintSize(const QSizeF& customSize, int unit, int dpi); 00369 00370 void updatePlot(); 00371 00373 00374 ErrorBarsCurve* addErrorBars(const QString& xColName, const QString& yColName, Table *errTable, 00375 const QString& errColName, int type = 1, double width = 1, int cap = 8, const QColor& color = QColor(Qt::black), 00376 bool through = true, bool minus = true, bool plus = true); 00377 00378 ErrorBarsCurve* addErrorBars(const QString& yColName, Table *errTable, const QString& errColName, 00379 int type = 1, double width = 1, int cap = 8, const QColor& color = QColor(Qt::black), 00380 bool through = true, bool minus = true, bool plus = true); 00381 00382 ErrorBarsCurve* addErrorBars(DataCurve *c, Table *errTable, const QString& errColName, 00383 int type = 1, double width = 1, int cap = 8, const QColor& color = QColor(Qt::black), 00384 bool through = true, bool minus = true, bool plus = true); 00385 00386 void updateErrorBars(ErrorBarsCurve *er, bool xErr, double width, int cap, const QColor& c, bool plus, bool minus, bool through); 00387 00389 DataCurve* masterCurve(ErrorBarsCurve *er); 00391 DataCurve* masterCurve(const QString& xColName, const QString& yColName); 00393 00395 00396 bool mousePressed(QEvent *); 00397 void contextMenuEvent(QContextMenuEvent *); 00398 void closeEvent(QCloseEvent *e); 00399 bool focusNextPrevChild ( bool next ); 00401 00403 void invertScale(int axis); 00404 void setScale(int axis, double start, double end, double step = 0.0, 00405 int majorTicks = 5, int minorTicks = 5, int type = 0, bool inverted = false, 00406 double left_break = -DBL_MAX, double right_break = DBL_MAX, int pos = 50, 00407 double stepBeforeBreak = 0.0, double stepAfterBreak = 0.0, int minTicksBeforeBreak = 4, 00408 int minTicksAfterBreak = 4, bool log10AfterBreak = false, int breakWidth = 4, bool breakDecoration = true); 00409 double axisStep(int axis){return d_user_step[axis];}; 00410 void setAxisStep(int axis, double step){d_user_step[axis] = step;}; 00411 void setCanvasCoordinates(const QRectF&); 00412 00414 00415 CurveLayout initCurveLayout(int style, int curves = 0, bool guessLayout = true); 00416 static CurveLayout initCurveLayout(); 00417 void updateCurveLayout(PlotCurve* c, const CurveLayout *cL); 00419 void guessUniqueCurveLayout(int& colorIndex, int& symbolIndex); 00421 00423 00424 void zoomed (const QwtDoubleRect &); 00425 void zoom(bool on); 00426 void zoomOut(); 00427 bool zoomOn(); 00429 00430 void setAutoScale(); 00431 void updateScale(); 00432 00434 00435 QString saveToString(bool saveAsTemplate = false); 00436 QString saveScale(); 00437 QString saveScaleTitles(); 00438 QString saveFonts(); 00439 QString saveMarkers(); 00440 QString saveCurveLayout(int index); 00441 QString saveAxesTitleColors(); 00442 QString saveAxesColors(); 00443 QString saveEnabledAxes(); 00444 QString saveCanvas(); 00445 QString saveTitle(); 00446 QString saveAxesTitleAlignement(); 00447 QString saveEnabledTickLabels(); 00448 QString saveTicksType(); 00449 QString saveCurves(); 00450 QString saveLabelsFormat(); 00451 QString saveLabelsRotation(); 00452 QString saveAxesLabelsType(); 00453 QString saveAxesBaseline(); 00454 QString saveAxesFormulas(); 00455 QString saveAxesBackbones(); 00456 QString saveTickLabelsSpace(); 00457 QString saveLabelsPrefixAndSuffix(); 00458 QString saveBackgroundImage(); 00459 void restoreBackgroundImage(const QStringList& lst); 00460 void restoreSymbolImage(int index, const QStringList& lst); 00461 static QString rgbaName(const QColor& color); 00463 00465 00466 LegendWidget* addText(LegendWidget*); 00468 LegendWidget* insertText(const QStringList& list, int fileVersion); 00469 00470 LegendWidget* addTimeStamp(); 00471 void removeLegendItem(int index); 00472 void insertLegend(const QStringList& lst, int fileVersion); 00473 00474 LegendWidget* newLegend(const QString& text = QString()); 00476 QString legendText(bool layerSpec = false, int fromIndex = 0); 00478 00480 00481 LegendWidget* legend(); 00482 void setLegend(const QString&); 00483 void removeLegend(); 00485 00487 00488 ArrowMarker* addArrow(ArrowMarker* mrk); 00489 void remove(ArrowMarker* arrow); 00490 00492 void addArrow(QStringList list, int fileVersion); 00493 QList<ArrowMarker *> arrowsList(){return d_lines;}; 00494 int numArrows(){return d_lines.count();}; 00495 00497 void drawLine(bool on, bool arrow = false); 00498 bool drawArrow(){return drawArrowOn;}; 00499 bool drawLineActive(){return drawLineOn;}; 00500 bool arrowMarkerSelected(); 00502 00504 00505 ImageWidget* addImage(ImageWidget* i); 00506 ImageWidget* addImage(const QString& fileName); 00507 ImageWidget* addImage(const QImage& image); 00508 00509 void insertImageMarker(const QStringList& lst, int fileVersion); 00510 bool imageMarkerSelected(); 00512 00514 00515 void removeMarker(); 00517 void updateMarkersBoundingRect(bool rescaleEvent = true); 00518 00525 void setSelectedArrow(ArrowMarker* mrk, bool add = false); 00526 ArrowMarker* selectedArrow(){return d_selected_arrow;}; 00527 bool markerSelected(); 00529 void deselectMarker(); 00531 00533 00534 QwtScaleWidget* currentScale(); 00535 QwtScaleWidget* selectedScale(); 00536 QRect axisTitleRect(const QwtScaleWidget *scale); 00537 bool axisTitleSelected(); 00538 00539 ScaleDraw::ScaleType axisType(int axis); 00540 00541 void setXAxisTitle(const QString& text); 00542 void setYAxisTitle(const QString& text); 00543 void setRightAxisTitle(const QString& text); 00544 void setTopAxisTitle(const QString& text); 00545 00546 QString axisTitleString(int axis); 00547 void setAxisTitleString(int axis, const QString& text); 00548 void setAxisTitle(int axis, const QString& text); 00549 void updateAxesTitles(); 00550 void updateAxisTitle(int axis); 00552 void setScaleTitle(int axis, const QString& text); 00553 00554 QFont axisTitleFont(int axis); 00555 void setAxisTitleFont(int axis,const QFont &fnt); 00556 00557 void setAxisFont(int axis, const QFont &fnt); 00558 void initFonts(const QFont &scaleTitleFnt,const QFont &numbersFnt); 00559 00560 QColor axisTitleColor(int axis); 00561 void setAxisTitleColor(int axis, const QColor& c); 00562 00563 int axisTitleAlignment (int axis); 00564 void setAxisTitleAlignment(int axis, int align); 00565 00566 int axisTitleDistance(int axis); 00567 void setAxisTitleDistance(int axis, int dist); 00568 00569 QColor axisColor(int axis); 00570 void setAxisColor(int axis, const QColor& color); 00571 00572 QColor axisLabelsColor(int axis); 00573 void setAxisLabelsColor(int axis, const QColor& color); 00574 00575 void showAxis(int axis, int type, const QString& formatInfo, Table *table, bool axisOn, 00576 int majTicksType, int minTicksType, bool labelsOn, const QColor& c, int format, 00577 int prec, int rotation, int baselineDist, const QString& formula, const QColor& labelsColor, 00578 int spacing = 4, bool backbone = true, const ScaleDraw::ShowTicksPolicy& showTicks = ScaleDraw::ShowAll, 00579 const QString& prefix = QString::null, const QString& suffix = QString::null); 00580 00581 void enableAxis(int axis, bool on = true); 00582 void enableAxisLabels(int axis, bool on = true); 00583 00584 int labelsRotation(int axis); 00585 void setAxisLabelRotation(int axis, int rotation); 00586 00588 void loadAxesLinewidth(int width); 00589 00590 void drawAxesBackbones(bool yes); 00591 bool axesBackbones(){return drawAxesBackbone;}; 00593 void loadAxesOptions(const QStringList& lst); 00594 00595 void setAxisMargin(int axis, int margin); 00596 00597 void setMajorTicksType(const QList<int>& lst); 00598 void setMajorTicksType(const QStringList& lst); 00599 00600 void setMinorTicksType(const QList<int>& lst); 00601 void setMinorTicksType(const QStringList& lst); 00602 00603 void setAxisTicksLength(int axis, int majTicksType, int minTicksType, int minLength, int majLength); 00604 void setTicksLength(int minLength, int majLength); 00605 void changeTicksLength(int minLength, int majLength); 00607 void setLabelsNumericFormat(const QStringList& l); 00608 void setLabelsNumericFormat(int axis, int format, int prec = 6, const QString& formula = QString()); 00609 void setLabelsDateTimeFormat(int axis, int type, const QString& formatInfo); 00610 void setLabelsDayFormat(int axis, int format); 00611 void setLabelsMonthFormat(int axis, int format); 00612 void recoverObsoleteDateTimeScale(int axis, int type, const QString& origin, const QString& format); 00613 00614 QString axisFormatInfo(int axis); 00615 00616 void setLabelsTextFormat(int axis, int type, const QString& name, const QStringList& lst); 00617 void setLabelsTextFormat(int axis, int type, const QString& labelsColName, Table *table); 00618 00619 QString axisFormula(int axis); 00620 void setAxisFormula(int axis, const QString &); 00622 00624 00625 void setCanvasFrame(int width = 1, const QColor& color = QColor(Qt::black)); 00626 QColor canvasFrameColor(); 00627 int canvasFrameWidth(); 00629 00631 00632 QString canvasBackgroundFileName(){return d_canvas_bkg_path;}; 00633 void setCanvasBackgroundImage (const QString & fn = QString(), bool update = true); 00634 QPixmap backgroundPixmap(){return d_canvas_bkg_pix;}; 00636 00638 00639 void setTitleFont(const QFont &fnt); 00640 void setTitleColor(const QColor &c); 00641 void setTitleAlignment(int align); 00642 00643 bool titleSelected(); 00644 void selectTitle(bool select = true); 00646 void clearTitle(); 00648 void removeTitle(); 00649 void initTitle( bool on, const QFont& fnt); 00651 00652 void disableTools(); 00653 void disableImageProfilesTool(); 00654 QPointer<ImageProfilesTool> imageProfilesTool(){return d_image_profiles_tool;} 00655 00662 bool enableRangeSelectors(const QObject *status_target=NULL, const char *status_slot=""); 00663 bool rangeSelectorsEnabled(); 00664 QPointer<RangeSelectorTool> rangeSelectorTool(){return d_range_selector;}; 00666 00667 void setFrame(int width = 1, const QColor& color = Qt::black); 00668 void setBackgroundColor(const QColor& color); 00670 00671 void addFitCurve(QwtPlotCurve *c); 00672 void deleteFitCurves(); 00673 QList<QwtPlotCurve *> fitCurvesList(){return d_fit_curves;}; 00678 int range(const QString& curveTitle, double *start, double *end); 00683 int range(QwtPlotCurve *c, double *start, double *end); 00684 00686 void setBarsGap(int curve, int gapPercent, int offset); 00687 00689 00690 void modifyFunctionCurve(int curve, int type, const QStringList &formulas, const QString &var, 00691 double start, double end, int points, const QMap<QString, double>& constants); 00692 FunctionCurve* addFunction(const QStringList &formulas, double start, double end, int points = 100, const QString &var = "x", int type = 0, const QString& title = QString::null); 00694 FunctionCurve* insertFunctionCurve(const QString& formula, int points, int fileVersion); 00695 00697 QString generateFunctionName(const QString& name = tr("F")); 00699 00701 void createTable(const QString& curveName); 00702 void createTable(const QwtPlotCurve* curve); 00703 void activateGraph(); 00704 00706 00707 VectorCurve* plotVectors(Table* w, const QStringList& colList, int style, int startRow = 0, int endRow = -1); 00708 void updateVectorsLayout(int curve, const QColor& color, double width, int arrowLength, int arrowAngle, bool filled, int position, 00709 const QString& xEndColName = QString(), const QString& yEndColName = QString()); 00711 00713 00714 BoxCurve* openBoxDiagram(Table *w, const QStringList& l, int fileVersion); 00715 void plotBox(Table *w, const QStringList& names, int startRow = 0, int endRow = -1); 00716 BoxCurve * boxCurve(int index); 00718 00720 00721 void resizeEvent(QResizeEvent *e); 00722 void scaleFonts(double factor); 00724 00725 void notifyChanges(); 00726 00727 void updateSecondaryAxis(int axis, bool changeFormat = false); 00728 int oppositeAxis(int axis); 00729 void updateOppositeScaleDiv(int axis); 00730 00731 bool isAutoscalingEnabled(){return d_auto_scale;}; 00732 void enableAutoscaling(bool on = true){d_auto_scale = on;}; 00733 00734 bool autoscaleFonts(){return autoScaleFonts;}; 00735 void setAutoscaleFonts(bool on = true){autoScaleFonts = on;}; 00736 00737 static int obsoleteSymbolStyle(int type); 00738 static QString penStyleName(Qt::PenStyle style); 00739 static Qt::PenStyle getPenStyle(const QString& s); 00740 static Qt::PenStyle getPenStyle(int style); 00741 static void showPlotErrorMessage(QWidget *parent, const QStringList& emptyColumns); 00742 00743 void showTitleContextMenu(); 00744 void copyTitle(); 00745 void cutTitle(); 00746 00747 void clearAxisTitle(); 00748 void removeAxisTitle(); 00749 void cutAxisTitle(); 00750 void copyAxisTitle(); 00751 void showAxisTitleMenu(); 00752 void showAxisContextMenu(int axis); 00753 void hideSelectedAxis(); 00754 void showGrids(); 00755 00757 void showGrid(); 00759 void showGrid(int axis); 00760 void setGridOnTop(bool on = true, bool update = true); 00761 bool hasGridOnTop(){return d_grid_on_top;} 00762 00763 void showAxisDialog(); 00764 void showScaleDialog(); 00765 00767 Spectrogram* spectrogram(Matrix *m); 00769 Spectrogram* plotSpectrogram(Matrix *m, CurveType type); 00771 void restoreSpectrogram(ApplicationWindow *app, const QStringList& lst); 00773 QwtHistogram* addHistogram(Matrix *m); 00775 QwtHistogram* restoreHistogram(Matrix *m, const QStringList& l); 00776 00777 bool antialiasing(){return d_antialiasing;}; 00779 void setAntialiasing(bool on = true, bool update = true); 00780 00781 void disableCurveAntialiasing(bool disable, int maxPoints); 00782 bool isCurveAntialiasingEnabled(QwtPlotItem *it); 00783 bool isCurveAntialiasingDisabled(){return d_disable_curve_antialiasing;}; 00784 int maxAntialisingSize(){return d_max_antialising_size;}; 00785 00786 void setCurrentColor(const QColor& c); 00787 void notifyColorChange(const QColor& c){emit currentColorChanged(c);}; 00788 void setCurrentFont(const QFont& f); 00789 void notifyFontChange(const QFont& f){emit currentFontChanged(f);}; 00790 void enableTextEditor(); 00791 00792 void showMissingDataGap(bool on = true, bool update = true); 00793 bool isMissingDataGapEnabled(){return d_missing_data_gap;} 00794 00796 00797 bool isWaterfallPlot(){return d_waterfall_offset_x != 0 || d_waterfall_offset_y != 0;}; 00798 int waterfallXOffset(){return d_waterfall_offset_x;}; 00799 int waterfallYOffset(){return d_waterfall_offset_y;}; 00800 void setWaterfallOffset(int x, int y, bool update = false); 00801 void setWaterfallXOffset(int); 00802 void setWaterfallYOffset(int); 00803 void setWaterfallSideLines(bool on = true); 00804 void setWaterfallFillColor(const QColor&); 00805 void updateWaterfallFill(bool on); 00807 void updateDataCurves(); 00808 void reverseCurveOrder(); 00809 00810 signals: 00811 void selectedGraph(Graph*); 00812 void selectedCanvas(Graph*); 00813 void closedGraph(); 00814 void drawLineEnded(bool); 00815 void cursorInfo(const QString&); 00816 void showPlotDialog(int); 00817 00818 void viewLineDialog(); 00819 void viewTitleDialog(); 00820 void modifiedGraph(); 00821 void hiddenPlot(QWidget*); 00822 00823 void showContextMenu(); 00824 void showCurveContextMenu(QwtPlotItem *); 00825 void showMarkerPopupMenu(); 00826 00827 void showAxisDialog(int); 00828 void axisDblClicked(int); 00829 00830 void showAxisTitleDialog(); 00831 00832 void dataRangeChanged(); 00833 void showFitResults(const QString&); 00834 void currentFontChanged(const QFont&); 00835 void currentColorChanged(const QColor&); 00836 void enableTextEditor(Graph *); 00837 void axisDivChanged(Graph *, int); 00838 void updatedLayout(Graph *); 00839 void selectionChanged(SelectionMoveResizer *); 00840 00841 private slots: 00842 void selectorDeleted(); 00843 00844 private: 00845 QString parseAxisTitle(int axis); 00846 QList<FrameWidget*> stackingOrderEnrichmentsList() const; 00848 QwtDoubleInterval axisBoundingInterval(int axis); 00849 void deselectCurves(); 00850 00851 void dropEvent(QDropEvent*); 00852 void dragEnterEvent(QDragEnterEvent*); 00853 void showEvent (QShowEvent * event); 00854 void printFrame(QPainter *painter, const QRect &rect) const; 00855 void printCanvas(QPainter *painter, const QRect &canvasRect, 00856 const QwtScaleMap map[axisCnt], const QwtPlotPrintFilter &pfilter) const; 00857 virtual void printScale (QPainter *, int axisId, int startDist, int endDist, 00858 int baseDist, const QRect &) const; 00859 virtual void drawItems (QPainter *painter, const QRect &rect, 00860 const QwtScaleMap map[axisCnt], const QwtPlotPrintFilter &pfilter) const; 00861 00862 void drawInwardTicks(QPainter *painter, const QRect &rect, 00863 const QwtScaleMap&map, int axis, bool min, bool maj) const; 00864 void drawBreak(QPainter *painter, const QRect &rect, const QwtScaleMap &map, int axis) const; 00865 00866 QwtPlotZoomer *d_zoomer[2]; 00867 TitlePicker *titlePicker; 00868 ScalePicker *scalePicker; 00869 CanvasPicker* cp; 00871 Grid *d_grid; 00873 QList<QwtPlotItem*> d_curves; 00875 QList<QwtPlotCurve *>d_fit_curves; 00877 bool d_antialiasing; 00878 bool d_disable_curve_antialiasing; 00879 int d_max_antialising_size; 00880 bool autoScaleFonts; 00881 bool drawLineOn, drawArrowOn, drawAxesBackbone; 00883 bool d_is_printing; 00885 bool d_grid_on_top; 00887 bool d_missing_data_gap; 00889 QVector<double> d_user_step; 00891 QList<ArrowMarker*> d_lines; 00893 ArrowMarker* d_selected_arrow; 00895 QPointer<SelectionMoveResizer> d_markers_selector; 00897 QPointer<RangeSelectorTool> d_range_selector; 00898 QPointer<ImageProfilesTool> d_image_profiles_tool; 00900 PlotToolInterface *d_active_tool, *d_peak_fit_tool; 00902 FrameWidget *d_active_enrichment; 00904 bool d_auto_scale; 00906 int d_min_tick_length, d_maj_tick_length; 00907 #ifdef TEX_OUTPUT 00908 bool d_is_exporting_tex; 00909 bool d_tex_escape_strings; 00910 #endif 00911 QList<FrameWidget*> d_enrichments; 00912 QwtPlotMagnifier *d_magnifier; 00913 QwtPlotPanner *d_panner; 00914 00915 double d_Douglas_Peuker_tolerance; 00916 int d_speed_mode_points; 00917 AxisTitlePolicy d_axis_title_policy; 00918 bool d_synchronize_scales; 00919 QStringList d_axis_titles; 00920 00921 QString d_canvas_bkg_path; 00922 QPixmap d_canvas_bkg_pix; 00923 00924 int d_waterfall_offset_x, d_waterfall_offset_y; 00925 QRectF d_page_rect; 00926 }; 00927 00928 class ScaledFontsPrintFilter: public QwtPlotPrintFilter 00929 { 00930 00931 public: 00932 ScaledFontsPrintFilter(double factor){d_factor = factor;}; 00933 virtual QFont font(const QFont &f, Item item) const 00934 { 00935 if (d_factor == 1.0 || d_factor <= 0.0) 00936 return f; 00937 00938 if (item == Title || item == AxisScale || item == AxisTitle || item == Marker){ 00939 QFont fnt(f); 00940 fnt.setPointSizeF(d_factor*f.pointSizeF()); 00941 return fnt; 00942 } 00943 return f; 00944 } 00945 00946 double scaleFontsFactor(){return d_factor;} 00947 00948 private: 00949 double d_factor; 00950 }; 00951 #endif // GRAPH_H