Logo Search packages:      
Sourcecode: qtiplot version File versions  Download package

Graph Class Reference

#include <Graph.h>

List of all members.


Detailed Description

A 2D-plotting widget.

Graphs are managed by a MultiLayer, where they are sometimes referred to as "graphs" and sometimes as "layers". Other parts of the code also call them "plots", regardless of the fact that there's also a class Plot. Within the user interface, they are quite consistently called "layers".

Each graph owns a Plot called d_plot, which handles parts of the curve, axis and marker management (similarly to QwtPlot), as well as the pickers d_zoomer (a QwtPlotZoomer), titlePicker (a TitlePicker), scalePicker (a ScalePicker) and cp (a CanvasPicker), which handle various parts of the user interaction.

Graph contains support for various curve types (see CurveType), some of them relying on Qtiplot-specific QwtPlotCurve subclasses for parts of the functionality.

Note that some of Graph's methods are implemented in analysis.cpp.

Future Plans

Merge with Plot and CanvasPicker. Think about merging in TitlePicker and ScalePicker. On the other hand, things like range selection, peak selection or (re)moving data points could be split out into tool classes like QwtPlotZoomer or SelectionMoveResizer.

What definitely should be split out are plot types like histograms and pie charts (TODO: which others?). We need a generic framework for this in any case so that new plot types can be implemented in plugins, and Graph could do with a little diet. Especially after merging in Plot and CanvasPicker. [ Framework needs to support plug-ins; assigned to ion ]

Definition at line 113 of file Graph.h.


Public Types

enum  Axis { Left, Right, Bottom, Top }
enum  AxisType {
  Numeric = 0, Txt = 1, Day = 2, Month = 3,
  Time = 4, Date = 5, ColHeader = 6
}
enum  CurveType {
  Line, Scatter, LineSymbols, VerticalBars,
  Area, Pie, VerticalDropLines, Spline,
  HorizontalSteps, Histogram, HorizontalBars, VectXYXY,
  ErrorBars, Box, VectXYAM, VerticalSteps,
  ColorMap, GrayScale, Contour, Function,
  ImagePlot
}
enum  MarkerType { None = -1, Text = 0, Arrow = 1, Image = 2 }
enum  ScaleType { Linear, Log10 }
enum  Ticks { NoTicks = 0, Out = 1, InOut = 2, In = 3 }

Public Slots

void activateGraph ()
bool addCurves (Table *w, const QStringList &names, int style=0, int lWidth=1, int sSize=3, int startRow=0, int endRow=-1)
void addFitCurve (QwtPlotCurve *c)
void addHistogram (Matrix *m)
 Add a matrix histogram to the graph.
QStringList analysableCurvesList ()
 Returns the names of all the curves suitable for data analysis, as a string list. The list excludes error bars and spectrograms.
bool antialiasing ()
bool autoscaleFonts ()
double axisStep (int axis)
void copy (Graph *g)
void copyAxisTitle ()
void copyTitle ()
void createTable (const QwtPlotCurve *curve)
void createTable (const QString &curveName)
 Provided for convenience in scripts.
QwtPlotCurve * curve (const QString &title)
 get curve by name
QwtPlotCurve * curve (int index)
 get curve by index
int curveIndex (const QString &title)
 map curve title to index
int curveIndex (QwtPlotCurve *c) const
 Map curve pointer to index.
int curveIndex (long key)
long curveKey (int curve)
int curves ()
QStringList curvesList ()
 Returns the names of all the QwtPlotCurve items on the plot, as a string list.
int curveType (int curveIndex)
void cutAxisTitle ()
void cutTitle ()
void deleteFitCurves ()
void disableTools ()
void enableAutoscaling (bool yes)
bool enableRangeSelectors (const QObject *status_target=NULL, const char *status_slot="")
void enableTextEditor ()
QList< QwtPlotCurve * > fitCurvesList ()
static Qt::BrushStyle getBrushStyle (int style)
static Qt::PenStyle getPenStyle (int style)
static Qt::PenStyle getPenStyle (const QString &s)
void hideSelectedAxis ()
bool insertCurve (Table *w, const QString &xColName, const QString &yColName, int style, int startRow=0, int endRow=-1)
bool insertCurve (Table *w, int xcol, const QString &name, int style)
bool insertCurve (Table *w, const QString &name, int style, int startRow=0, int endRow=-1)
void insertPlotItem (QwtPlotItem *i, int type)
void invertScale (int axis)
 Set axis scale.
static QPrinter::PageSize minPageSize (const QPrinter &printer, const QRect &r)
void notifyChanges ()
void notifyFontChange (const QFont &f)
static int obsoleteSymbolStyle (int type)
static QString penStyleName (Qt::PenStyle style)
QwtPlotItem * plotItem (int index)
 get plotted item by index
int plotItemIndex (QwtPlotItem *it) const
 get plot item by index
QStringList plotItemsList ()
 Returns the names of all plot items, including spectrograms, as a string list.
Spectrogram * plotSpectrogram (Matrix *m, CurveType type)
 Add a spectrogram to the graph.
PlotplotWidget ()
 Accessor method for d_plot.
int range (int index, double *start, double *end)
void removeAxisTitle ()
void removeCurve (const QString &s)
 Removes a curve defined by its title string s.
void removeCurve (int index)
 Removes a curve defined by its index.
void removeCurves (const QString &s)
 Removes all curves defined by the title/plot association string s.
void replot ()
void restoreHistogram (Matrix *m, const QStringList &l)
 Restores a histogram from a project file.
void restoreSpectrogram (ApplicationWindow *app, const QStringList &lst)
 Restores a spectrogram. Used when opening a project file.
double selectedXEndValue ()
double selectedXStartValue ()
void setAntialiasing (bool on=true, bool update=true)
 Enables/Disables antialiasing of plot items.
void setAutoScale ()
void setAutoscaleFonts (bool yes)
void setBarsGap (int curve, int gapPercent, int offset)
 Used for VerticalBars, HorizontalBars and Histograms.
void setCurrentFont (const QFont &f)
void setCurveBrush (int index, const QBrush &b)
void setCurveFullRange (int curveIndex)
void setCurvePen (int index, const QPen &p)
void setCurveStyle (int index, int s)
void setCurveSymbol (int index, const QwtSymbol &s)
void setCurveType (int curve, int style)
void setScale (int axis, double start, double end, double step=0.0, int majorTicks=5, int minorTicks=5, int type=0, bool inverted=false)
void showAxisContextMenu (int axis)
void showAxisDialog ()
void showAxisTitleMenu (int axis)
void showCurve (int index, bool visible=true)
 Shows/Hides a curve defined by its index.
void showGrid (int axis)
 Convenience function enabling the grid for a user defined axis.
void showGrid ()
 Convenience function enabling the grid for QwtScaleDraw::Left and Bottom Scales.
void showGrids ()
static void showPlotErrorMessage (QWidget *parent, const QStringList &emptyColumns)
void showScaleDialog ()
void showTitleContextMenu ()
void updateCurveNames (const QString &oldName, const QString &newName, bool updateTableName=true)
void updateCurvesData (Table *w, const QString &yColName)
void updatePlot ()
void updateScale ()
void updateSecondaryAxis (int axis)
bool validCurvesDataSize ()
int visibleCurves ()
Line Markers
void addArrow (QStringList list, int fileVersion)
 Used when opening a project file.
ArrowMarkeraddArrow (ArrowMarker *mrk)
ArrowMarkerarrow (long id)
QColor arrowDefaultColor ()
int arrowDefaultWidth ()
int arrowHeadDefaultAngle ()
bool arrowHeadDefaultFill ()
int arrowHeadDefaultLength ()
Qt::PenStyle arrowLineDefaultStyle ()
bool arrowMarkerSelected ()
bool drawArrow ()
void drawLine (bool on, bool arrow=FALSE)
 Draws a line/arrow depending on the value of "arrow".
bool drawLineActive ()
QVector< int > lineMarkerKeys ()
void setArrowDefaults (int lineWidth, const QColor &c, Qt::PenStyle style, int headLength, int headAngle, bool fillHead)
Error Bars
bool addErrorBars (const QString &yColName, Table *errTable, const QString &errColName, int type=1, int width=1, int cap=8, const QColor &color=QColor(Qt::black), bool through=true, bool minus=true, bool plus=true)
bool addErrorBars (const QString &xColName, const QString &yColName, Table *errTable, const QString &errColName, int type=1, int width=1, int cap=8, const QColor &color=QColor(Qt::black), bool through=true, bool minus=true, bool plus=true)
DataCurve * masterCurve (const QString &xColName, const QString &yColName)
 Returns a valid master curve for a plot association.
DataCurve * masterCurve (QwtErrorPlotCurve *er)
 Returns a valid master curve for the error bars curve.
void updateErrorBars (QwtErrorPlotCurve *er, bool xErr, int width, int cap, const QColor &c, bool plus, bool minus, bool through)
User-defined Functions
void addFunction (const QStringList &formulas, double start, double end, int points=100, const QString &var="x", int type=0, const QString &title=QString::null)
QString generateFunctionName (const QString &name=tr("F"))
 Returns an unique function name.
void insertFunctionCurve (const QString &formula, int points, int fileVersion)
 Used when reading from a project file.
void modifyFunctionCurve (int curve, int type, const QStringList &formulas, const QString &var, double start, double end, int points)
Image Markers
ImageMarkeraddImage (const QString &fileName)
ImageMarkeraddImage (ImageMarker *mrk)
ImageMarkerimageMarker (long id)
QVector< int > imageMarkerKeys ()
bool imageMarkerSelected ()
void insertImageMarker (const QStringList &lst, int fileVersion)
void updateImageMarker (int x, int y, int width, int height)
Text Markers
void addLegendItem (const QString &colName)
void addTimeStamp ()
QFont defaultTextMarkerFont ()
void drawText (bool on)
bool drawTextActive ()
void insertLegend (const QStringList &lst, int fileVersion)
LegendWidget * insertText (const QStringList &list, int fileVersion)
 Used when opening a project file.
LegendWidget * insertText (LegendWidget *)
LegendWidget * legend ()
QString legendText ()
 Creates a new legend text using the curves titles.
LegendWidget * newLegend (const QString &text=QString())
void removeLegend ()
void removeLegendItem (int index)
void setTextMarkerDefaults (int f, const QFont &font, const QColor &textCol, const QColor &backgroundCol)
QColor textMarkerDefaultBackground ()
QColor textMarkerDefaultColor ()
int textMarkerDefaultFrame ()
Axes
bool axesBackbones ()
QStringList axesLabelsFormatInfo ()
QList< int > axesType ()
QColor axisColor (int axis)
QFont axisFont (int axis)
QString axisFormatInfo (int axis)
QColor axisLabelsColor (int axis)
QString axisTitle (int axis)
int axisTitleAlignment (int axis)
QColor axisTitleColor (int axis)
QFont axisTitleFont (int axis)
QRect axisTitleRect (const QwtScaleWidget *scale)
void changeTicksLength (int minLength, int majLength)
void drawAxesBackbones (bool yes)
void enableAxis (int axis, bool on=true)
void enableAxisLabels (int axis, bool on=true)
QStringList getAxesFormulas ()
void initFonts (const QFont &scaleTitleFnt, const QFont &numbersFnt)
int labelsRotation (int axis)
void loadAxesLinewidth (int width)
 used when opening a project file
void loadAxesOptions (const QString &s)
 used when opening a project file
int majorTickLength ()
int minorTickLength ()
QwtScaleWidget * selectedScale ()
void setAxesFormulas (const QStringList &l)
void setAxesLinewidth (int width)
void setAxisColor (int axis, const QColor &color)
void setAxisFont (int axis, const QFont &fnt)
void setAxisFormula (int pos, const QString &f)
void setAxisLabelRotation (int axis, int rotation)
void setAxisLabelsColor (int axis, const QColor &color)
void setAxisMargin (int axis, int margin)
void setAxisTicksLength (int axis, int majTicksType, int minTicksType, int minLength, int majLength)
void setAxisTitle (int axis, const QString &text)
void setAxisTitleAlignment (int axis, int align)
void setAxisTitleColor (int axis, const QColor &c)
void setAxisTitleFont (int axis, const QFont &fnt)
void setLabelsDateTimeFormat (int axis, int type, const QString &formatInfo)
void setLabelsDayFormat (int axis, int format)
void setLabelsMonthFormat (int axis, int format)
void setLabelsNumericFormat (int axis, int format, int prec=6, const QString &formula=QString())
void setLabelsNumericFormat (int axis, const QStringList &l)
void setLabelsNumericFormat (const QStringList &l)
void setLabelsTextFormat (int axis, int type, const QString &labelsColName, Table *table)
void setLabelsTextFormat (int axis, int type, const QString &name, const QStringList &lst)
void setMajorTicksType (const QStringList &lst)
void setMajorTicksType (const QList< int > &lst)
void setMinorTicksType (const QStringList &lst)
void setMinorTicksType (const QList< int > &lst)
void setRightAxisTitle (const QString &text)
void setRightAxisTitleAlignment (int align)
void setRightAxisTitleColor (const QColor &c)
void setRightAxisTitleFont (const QFont &fnt)
void setScaleTitle (int axis, const QString &text)
 TODO: eliminate this function in version 0.9.1 (used only when restoring project files).
void setTicksLength (int minLength, int majLength)
void setTopAxisTitle (const QString &text)
void setTopAxisTitleAlignment (int align)
void setTopAxisTitleColor (const QColor &c)
void setTopAxisTitleFont (const QFont &fnt)
void setXAxisTitle (const QString &text)
void setXAxisTitleAlignment (int align)
void setXAxisTitleColor (const QColor &c)
void setXAxisTitleFont (const QFont &fnt)
void setYAxisTitle (const QString &text)
void setYAxisTitleAlignment (int align)
void setYAxisTitleColor (const QColor &c)
void setYAxisTitleFont (const QFont &fnt)
void showAxis (int axis, int type, const QString &formatInfo, Table *table, bool axisOn, int majTicksType, int minTicksType, bool labelsOn, const QColor &c, int format, int prec, int rotation, int baselineDist, const QString &formula, const QColor &labelsColor)
Canvas Frame
QColor canvasFrameColor ()
int canvasFrameWidth ()
void setCanvasFrame (int width=1, const QColor &color=QColor(Qt::black))
Event Handlers
void closeEvent (QCloseEvent *e)
void contextMenuEvent (QContextMenuEvent *)
bool focusNextPrevChild (bool next)
Output: Copy/Export/Print
void copyImage ()
void exportEMF (const QString &fname)
void exportImage (const QString &fileName, int quality=100, bool transparent=false)
void exportSVG (const QString &fname)
void exportToFile (const QString &fileName)
 Provided for convenience in scripts.
void exportVector (const QString &fileName, int res=0, bool color=true, bool keepAspect=true, QPrinter::PageSize pageSize=QPrinter::Custom)
QPixmap graphPixmap ()
void print ()
void printCropmarks (bool on)
void setScaleOnPrint (bool on)
Common to all Markers
void deselectMarker ()
 Reset any selection states on markers.
bool markerSelected ()
void removeMarker ()
long selectedMarkerKey ()
QwtPlotMarker * selectedMarkerPtr ()
void setSelectedMarker (long mrk, bool add=false)
 Set the selected marker.
void updateMarkersBoundingRect ()
 Keep the markers on screen each time the scales are modified by adding/removing curves.
Curves Layout
void guessUniqueCurveLayout (int &colorIndex, int &symbolIndex)
 Tries to guess not already used curve color and symbol style.
static CurveLayout initCurveLayout ()
CurveLayout initCurveLayout (int style, int curves=0)
void updateCurveLayout (int index, const CurveLayout *cL)
Resizing
bool ignoresResizeEvents ()
void resizeEvent (QResizeEvent *e)
void scaleFonts (double factor)
void setIgnoreResizeEvents (bool ok)
Plot Title
void initTitle (bool on, const QFont &fnt)
void removeTitle ()
void selectTitle (bool select=true)
void setTitle (const QString &t)
void setTitleAlignment (int align)
void setTitleColor (const QColor &c)
void setTitleFont (const QFont &fnt)
bool titleSelected ()
Pie Curves
bool isPiePlot ()
 Returns true if this Graph is a pie plot, false otherwise.
QString pieLegendText ()
void plotPie (Table *w, const QString &name, const QPen &pen, int brush, int size, int firstColor, int startRow=0, int endRow=-1, bool visible=true)
 Used when restoring a pie plot from a project file.
void plotPie (Table *w, const QString &name, int startRow=0, int endRow=-1)
void removePie ()
QString savePieCurveLayout ()
Box Plots
void openBoxDiagram (Table *w, const QStringList &l, int fileVersion)
void plotBoxDiagram (Table *w, const QStringList &names, int startRow=0, int endRow=-1)
Vector Curves
void plotVectorCurve (Table *w, const QStringList &colList, int style, int startRow=0, int endRow=-1)
void updateVectorsLayout (int curve, const QColor &color, int width, int arrowLength, int arrowAngle, bool filled, int position, const QString &xEndColName=QString(), const QString &yEndColName=QString())
Saving to File
QString saveAxesBaseline ()
QString saveAxesColors ()
QString saveAxesFormulas ()
QString saveAxesLabelsType ()
QString saveAxesTitleAlignement ()
QString saveAxesTitleColors ()
QString saveCanvas ()
QString saveCurveLayout (int index)
QString saveCurves ()
QString saveEnabledAxes ()
QString saveEnabledTickLabels ()
QString saveFonts ()
QString saveLabelsFormat ()
QString saveLabelsRotation ()
QString saveMarkers ()
QString saveScale ()
QString saveScaleTitles ()
QString saveTicksType ()
QString saveTitle ()
QString saveToString (bool saveAsTemplate=false)
Modifing insertCurve Data
int selectedCurveID ()
int selectedCurveIndex ()
QString selectedCurveTitle ()
Border and Margin
void setBackgroundColor (const QColor &color)
void setCanvasBackground (const QColor &color)
void setFrame (int width=1, const QColor &color=QColor(Qt::black))
void setMargin (int d)
Zoom
void zoom (bool on)
void zoomed (const QwtDoubleRect &)
bool zoomOn ()
void zoomOut ()

Signals

void axisDblClicked (int)
void closedGraph ()
void createTable (const QString &, int, int, const QString &)
void currentFontChanged (const QFont &)
void cursorInfo (const QString &)
void dataRangeChanged ()
void drawLineEnded (bool)
void drawTextOff ()
void enableTextEditor (Graph *)
void hiddenPlot (QWidget *)
void modifiedGraph ()
void rightAxisTitleDblClicked ()
void selectedGraph (Graph *)
void showAxisDialog (int)
void showContextMenu ()
void showCurveContextMenu (int)
void showFitResults (const QString &)
void showMarkerPopupMenu ()
void showPlotDialog (int)
void topAxisTitleDblClicked ()
void viewImageDialog ()
void viewLineDialog ()
void viewTextDialog ()
void viewTitleDialog ()
void xAxisTitleDblClicked ()
void yAxisTitleDblClicked ()

Public Member Functions

PlotToolInterfaceactiveTool () const
 Return the active tool, or NULL if none is active.
void deselect ()
 Graph (QWidget *parent=0, const char *name=0, Qt::WFlags f=0)
Grid * grid ()
MultiLayerparentPlot ()
 Returns a pointer to the parent MultiLayer object.
QString parentPlotName ()
 Returns the name of the parent MultiLayer object.
void restoreCurveLabels (int curveID, const QStringList &lst)
 Used when restoring DataCurve curveID from a project file.
DataCurve * selectedCurveLabels ()
LegendWidget * selectedText ()
void setActiveTool (PlotToolInterface *tool)
 Change the active tool, deleting the old one if it exists.
void setSelectedText (LegendWidget *l)
QList< LegendWidget * > textsList ()

Private Member Functions

void deselectCurves ()

Private Attributes

bool autoscale
bool autoScaleFonts
QStringList axesFormatInfo
 Stores columns used for axes with text labels or time/date format info.
QStringList axesFormulas
QList< int > axisType
QVector< int > c_keys
 Curves on plot keys.
QVector< int > c_type
 Curve types.
CanvasPickercp
PlotToolInterfaced_active_tool
 The currently active tool, or NULL for default (pointer).
bool d_antialiasing
 Render hint for plot items.
QList< QwtPlotCurve * > d_fit_curves
 List storing pointers to the curves resulting after a fit session, in case the user wants to delete them later on.
QVector< int > d_images
 Images on plot keys.
LegendWidget * d_legend
 Pointer to the current legend.
QVector< int > d_lines
 Arrows/lines on plot keys.
QPointer< SelectionMoveResizerd_markers_selector
 The markers selected for move/resize operations or NULL if none are selected.
Plotd_plot
bool d_print_cropmarks
QPointer< RangeSelectorToold_range_selector
 The current curve selection, or NULL if none is active.
bool d_scale_on_print
LegendWidget * d_selected_text
 Pointer to the currently selected text/legend.
QList< LegendWidget * > d_texts_list
 Stores pointers to the text objects on the plot.
QVector< double > d_user_step
 Stores the step the user specified for the four scale. If step = 0.0, the step will be calculated automatically by the Qwt scale engine.
QwtPlotZoomer * d_zoomer [2]
bool drawArrowOn
bool drawAxesBackbone
bool drawLineOn
bool drawTextOn
bool ignoreResize
int n_curves
ScalePickerscalePicker
int selectedAxis
long selectedMarker
TitlePicker * titlePicker
int widthLine
variables used when creating a new marker (text/line/arrow)
QColor defaultArrowColor
int defaultArrowHeadAngle
bool defaultArrowHeadFill
int defaultArrowHeadLength
Qt::PenStyle defaultArrowLineStyle
int defaultArrowLineWidth
QFont defaultMarkerFont
int defaultMarkerFrame
QColor defaultTextMarkerBackground
QColor defaultTextMarkerColor

The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index