Logo Search packages:      
Sourcecode: scidavis 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 SciDAVis-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 knut ]

Add support for floating-point line widths of curves and axes (request 2300). [ assigned to thzs ]

Definition at line 114 of file Graph.h.


Public Types

enum  AxisType {
  Numeric = 0, Txt = 1, Day = 2, Month = 3,
  Time = 4, Date = 5, ColHeader = 6, DateTime = 22
}
enum  CurveType {
  Line, Scatter, LineSymbols, VerticalBars,
  Area, Pie, VerticalDropLines, Spline,
  HorizontalSteps, Histogram, HorizontalBars, VectXYXY,
  ErrorBars, Box, VectXYAM, VerticalSteps,
  ColorMap, GrayMap, ContourMap, Function
}
enum  MarkerType { None = -1, Text = 0, Arrow = 1, Image = 2 }

Public Slots

void activateGraph ()
void addFitCurve (QwtPlotCurve *c)
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)
static bool canConvertTo (QwtPlotCurve *curve, CurveType type)
 Test whether curve can be converted to type using setCurveType().
void copy (ApplicationWindow *parent, 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 deselect ()
void disableTools ()
void enableAutoscaling (bool yes)
bool enableRangeSelectors (const QObject *status_target=NULL, const char *status_slot="")
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)
bool insertCurvesList (Table *w, const QStringList &names, int style, int lWidth, int sSize, int startRow=0, int endRow=-1)
void insertPlotItem (QwtPlotItem *i, int type)
static QPrinter::PageSize minPageSize (const QPrinter &printer, const QRect &r)
void notifyChanges ()
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.
void plotSpectrogram (Matrix *m, CurveType type)
 Add a spectrogram to the graph.
PlotplotWidget ()
 Accessor method for d_plot.
void print (QPainter *, const QRect &rect, const QwtPlotPrintFilter &=QwtPlotPrintFilter())
void printCanvas (QPainter *painter, const QRect &canvasRect, const QwtScaleMap map[QwtPlot::axisCnt], const QwtPlotPrintFilter &pfilter) const
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 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 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, CurveType type, bool update=true)
 Change the type of the given curve.
void setScale (int axis, double start, double end, double step=0.0, int majorTicks=5, int minorTicks=5, int type=0, bool inverted=false)
 Set axis scale.
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.
void addArrow (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
bool addFunctionCurve (ApplicationWindow *parent, int type, const QStringList &formulas, const QString &var, QList< double > &ranges, int points, const QString &title=QString::null)
QString generateFunctionName (const QString &name=tr("F"))
 Returns an unique function name.
bool insertFunctionCurve (ApplicationWindow *parent, const QStringList &func_spec, int points, int fileVersion)
 Used when reading from a project file.
bool modifyFunctionCurve (ApplicationWindow *parent, int curve, int type, const QStringList &formulas, const QString &var, QList< double > &ranges, 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 ()
QRect copiedMarkerRect ()
QFont defaultTextMarkerFont ()
void drawText (bool on)
bool drawTextActive ()
bool hasLegend ()
void insertLegend (const QStringList &lst, int fileVersion)
long insertTextMarker (const QStringList &list, int fileVersion)
 Used when opening a project file.
long insertTextMarker (Legend *mrk)
Legendlegend ()
QString legendText ()
 Creates a new legend text using the curves titles.
LegendnewLegend (const QString &text)
LegendnewLegend ()
void removeLegend ()
void removeLegendItem (int index)
void setCopiedArrowOptions (int width, Qt::PenStyle style, const QColor &color, bool start, bool end, int headLength, int headAngle, bool filledHead)
void setCopiedImageName (const QString &fn)
void setCopiedMarkerEnds (const QPoint &start, const QPoint &end)
void setCopiedMarkerType (Graph::MarkerType type)
void setCopiedTextOptions (int bkg, const QString &text, const QFont &font, const QColor &color, const QColor &bkgColor)
void setTextMarkerDefaults (int f, const QFont &font, const QColor &textCol, const QColor &backgroundCol)
LegendtextMarker (long id)
QColor textMarkerDefaultBackground ()
QColor textMarkerDefaultColor ()
int textMarkerDefaultFrame ()
QVector< int > textMarkerKeys ()
void updateTextMarker (const QString &text, int angle, int bkg, const QFont &fnt, const QColor &textColor, const QColor &backgroundColor)
Axes
bool axesBackbones ()
QList< int > axesBaseline ()
QStringList axesColors ()
QStringList axesLabelsFormatInfo ()
QStringList axesNumColors ()
QList< int > axesType ()
QColor axisColor (int axis)
QFont axisFont (int axis)
QString axisFormatInfo (int axis)
QColor axisNumbersColor (int axis)
QString axisTitle (int axis)
int axisTitleAlignment (int axis)
QColor axisTitleColor (int axis)
QFont axisTitleFont (int axis)
void changeTicksLength (int minLength, int majLength)
void drawAxesBackbones (bool yes)
void enableAxes (const QStringList &list)
void enableAxes (QVector< bool > axesOn)
void enableAxis (int axis, bool on=true)
QVector< bool > enabledAxes ()
QStringList enabledTickLabels ()
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 ()
QStringList scalesTitles ()
void setAxesBaseline (QStringList &lst)
void setAxesBaseline (const QList< int > &lst)
void setAxesColors (const QStringList &colors)
void setAxesFormulas (const QStringList &l)
void setAxesLinewidth (int width)
void setAxesNumColors (const QStringList &colors)
void setAxesTitleColor (QStringList l)
void setAxesTitlesAlignment (const QStringList &align)
void setAxisFont (int axis, const QFont &fnt)
void setAxisFormula (int pos, const QString &f)
void setAxisLabelRotation (int axis, int rotation)
void setAxisTicksLength (int axis, int majTicksType, int minTicksType, int minLength, int majLength)
void setAxisTitle (int axis, const QString &text)
void setAxisTitleFont (int axis, const QFont &fnt)
void setEnabledTickLabels (const QStringList &list)
void setLabelsColHeaderFormat (int axis, Table *table)
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, Table *table, const QString &columnName)
void setLabelsTextFormat (int axis, const Column *column, int startRow, int endRow)
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 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 drawCanvasFrame (bool frameOn, int width, const QColor &color)
void drawCanvasFrame (const QStringList &frame)
void drawCanvasFrame (bool frameOn, int width)
bool framed ()
Event Handlers
void closeEvent (QCloseEvent *e)
void contextMenuEvent (QContextMenuEvent *)
bool focusNextPrevChild (bool next)
Common to all Markers
MarkerType copiedMarkerType ()
void copyMarker ()
void cutMarker ()
void deselectMarker ()
 Reset any selection states on markers.
bool markerSelected ()
void pasteMarker ()
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.
Output: Copy/Export/Print
void copyImage ()
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, QPrinter::Orientation orientation=QPrinter::Portrait)
QPixmap graphPixmap ()
void print ()
void printCropmarks (bool on)
void setScaleOnPrint (bool on)
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)
 Set layout parameters of the curve given by index.
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 ()
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)
Image Analysis Tools
void showIntensityTable ()
Zoom
void zoom (bool on)
void zoomed (const QwtDoubleRect &)
bool zoomOn ()
void zoomOut ()

Signals

void axisDblClicked (int)
void closedGraph ()
void createIntensityTable (const QString &)
void createTable (const QString &, const QString &, QList< Column * >)
void cursorInfo (const QString &)
void dataRangeChanged ()
void drawLineEnded (bool)
void drawTextOff ()
void hiddenPlot (QWidget *)
void modifiedGraph ()
void rightAxisTitleDblClicked ()
void selectedGraph (Graph *)
void showAxisDialog (int)
void showContextMenu ()
void showCurveContextMenu (int)
void showFitResults (const QString &)
void showLayerButtonContextMenu ()
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.
 Graph (QWidget *parent=0, const char *name=0, Qt::WFlags f=0)
Gridgrid ()
QString parentPlotName ()
 Returns the name of the parent MultiLayer object.
void setActiveTool (PlotToolInterface *tool)
 Change the active tool, deleting the old one if it exists.

Static Public Member Functions

static int mapToQwtAxis (int axis)

Public Attributes

CanvasPickercp
Plotd_plot
QwtPlotZoomer * d_zoomer [2]
ScalePickerscalePicker
TitlePicker * titlePicker

Private Attributes

bool autoScaleFonts
int auxArrowHeadAngle
int auxArrowHeadLength
bool auxFilledArrowHead
int auxMrkAngle
int auxMrkBkg
QColor auxMrkBkgColor
QColor auxMrkColor
QPoint auxMrkEnd
QString auxMrkFileName
QFont auxMrkFont
QPoint auxMrkStart
Qt::PenStyle auxMrkStyle
QString auxMrkText
int auxMrkWidth
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.
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.
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.
bool d_print_cropmarks
QPointer< RangeSelectorToold_range_selector
 The current curve selection, or NULL if none is active.
bool d_scale_on_print
QVector< int > d_texts
 Stores the identifiers (keys) of 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.
QColor defaultArrowColor
int defaultArrowHeadAngle
bool defaultArrowHeadFill
int defaultArrowHeadLength
Qt::PenStyle defaultArrowLineStyle
int defaultArrowLineWidth
QFont defaultMarkerFont
int defaultMarkerFrame
QColor defaultTextMarkerBackground
QColor defaultTextMarkerColor
bool drawArrowOn
bool drawAxesBackbone
bool drawLineOn
bool drawTextOn
bool endArrowOn
bool ignoreResize
long legendMarkerID
bool m_autoscale
QPen mrkLinePen
QwtPlotMarker::LineStyle mrklStyle
int n_curves
int selectedAxis
long selectedMarker
MarkerType selectedMarkerType
bool startArrowOn
int widthLine

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

Generated by  Doxygen 1.6.0   Back to index