Plot1d.h

Classes

Plot1d -- Generic plotting interface; allows control of linestyles, axes, etc. (full description)

class Plot1d

Types

enum DataStyles

lines
points
linespoints
histogram

enum LineStyles

noLine
solid
dashed
dotted
shortDashed
mixedDashed
dashDot

enum PointStyles

noPoint
dot
box
triangle
diamond
star
verticalLine
horizontalLine
cross
circle
square

enum AxisPlacementStrategy

axisAutomaticPlacement
axisAtMinimum
axisAtMaximum
axisAtExplicitPosition

enum AxisType

AXIS_TYPE_UNDEFINED
RAW_AXIS
TIME_AXIS
SKYPOSITION_AXIS

enum LegendGeometry

legendNorth
legendSouth
legendEast
legendWest
legendVertical
legendHorizontal
legendHidden
legendVisible
legendDefault

enum SelectableObjects

selectOnXAxis
selectOnYAxis
selectBoxOfData

enum DragModes

zoom
selectData

Interface

Public Members
Plot1d ()
virtual ~Plot1d ()
Int addDataSet (Vector <Double> &y, const String &name, DataStyles style = linespoints, const char *xLabel = "", const char *yLabel = "", Plot1d::AxisType xAxisType = RAW_AXIS, Plot1d::AxisType yAxisType = RAW_AXIS, Plot1dData::AssociatedYAxis whichYAxis = Plot1dData::Y1Axis)
Int addDataSet (Vector <Double> &x, Vector <Double> &y, const String &name, DataStyles style = linespoints, const char *xLabel = "", const char *yLabel = "", Plot1d::AxisType xAxisType = RAW_AXIS, Plot1d::AxisType yAxisType = RAW_AXIS, Plot1dData::AssociatedYAxis whichYAxis = Plot1dData::Y1Axis)
Private Members
virtual Int addDataSet (Plot1dData * data, Plot1d::DataStyles) = 0
Public Members
virtual Int appendData (Int dataSet, Double x, Double y) = 0
virtual Int appendData (Int dataSet, Vector <Double> x, Vector <Double> y) = 0
Bool findDataSet(Int dataSetId)
virtual Int removeDataPoint (Int dataSetId, Int index)
virtual void setDataStyle (Int dataSetId, DataStyles dataStyle) = 0
Plot1dData::AssociatedYAxis assignAxis(AxisType newXAxisType, AxisType newYAxisType, Plot1dData::AssociatedYAxis whichYAxis)
void setAxisType (Int axis, AxisType axisType)
void setXAxisType (AxisType axisType)
void setYAxisType (AxisType axisType)
void setY1AxisType (AxisType axisType)
void setY2AxisType (AxisType axisType)
virtual void setTopXAxis(Bool onOff)
virtual void setLeftY2Axis(Bool onOff)
virtual void setRightY1Axis(Bool onOff)
void setRightYAxis(Bool onOff)
virtual void setXAxisGrid(Bool onOff)
void setYAxisGrid(Bool onOff)
virtual void setY1AxisGrid(Bool onOff)
virtual void setY2AxisGrid(Bool onOff)
AxisType xAxisType() const
AxisType yAxisType() const
AxisType y1AxisType() const
AxisType y2AxisType() const
virtual void setPlotTitle (const String &newLabel)
virtual void setPlotTitleColor(const String& color)
virtual void setCursorColor(const String& color)
virtual void setXAxisLineWidth(const Int newSize)
virtual void setY1AxisLineWidth(const Int newSize)
virtual void setY2XAxisLineWidth(const Int newSize)
virtual void setXAxisGridLineWidth(const Int newSize)
virtual void setY1AxisGridLineWidth(const Int newSize)
virtual void setY2XAxisGridLineWidth(const Int newSize)
virtual void setXAxisLabel (const String &newLabel)
void setYAxisLabel (const String &newLabel)
virtual void setY1AxisLabel (const String &newLabel)
virtual void setY2AxisLabel (const String &newLabel)
virtual void setXAxisColor (const String& color)
void setYAxisColor (const String& color)
virtual void setY1AxisColor (const String& color)
virtual void setY2AxisColor (const String& color)
virtual void setXAxisLabelColor (const String& color)
void setYAxisLabelColor (const String& color)
virtual void setY1AxisLabelColor (const String& color)
virtual void setY2AxisLabelColor (const String& color)
virtual void setXAxisGridColor (const String& color)
void setYAxisGridColor (const String& color)
virtual void setY1AxisGridColor (const String& color)
virtual void setY2AxisGridColor (const String& color)
virtual void setLineColor (Int dataSetId, const String &color) = 0
virtual void setLineStyle (Int dataSetId, Plot1d::LineStyles lineStyle) = 0
virtual void setLineWidth (Int dataSetId, Int newSize) = 0
virtual void setPointColor (Int dataSet, const String &newColor) = 0
virtual void setPointStyle (Int dataSet, Plot1d::PointStyles pointStyle) = 0
virtual void setPointSize (Int dataSet, Int newSize) = 0
virtual void setXAxisPosition (AxisPlacementStrategy strategy, Double where = 0.0)
void setYAxisPosition (AxisPlacementStrategy strategy, Double where = 0.0)
virtual void setY1AxisPosition (AxisPlacementStrategy strategy, Double where = 0.0)
virtual void setY2AxisPosition (AxisPlacementStrategy strategy, Double where = 0.0)
virtual void reverseXAxis ()
void reverseYAxis ()
virtual void reverseY1Axis ()
virtual void reverseY2Axis ()
virtual void swapY1Y2()
Protected Members
void swapY1Y2_()
Public Members
virtual void setLegendGeometry (LegendGeometry newGeometry)
virtual Bool printGraphToPrinter () = 0
virtual Bool printGraphToFile (String filename) = 0
Int nDataSets ()
Int nextDataSetId()
Int nSelections () const
Int numberOfSelections () const
Vector <Double> getXValues (Int dataSetId)
Vector <Double> getYValues (Int dataSetId)
String describeDataSets ()
String describeDataSelections ()
virtual String describeDataDisplayStyles () = 0
virtual void redraw () = 0
virtual void clear () = 0
virtual Bool deleteDataSet (Int dataSetId)
void clearData()
void deleteAllDataSets ()
void clearSelections()
void deleteSelections ()
virtual void showSelections(Bool /*onOff*/)
virtual void setSelectionColor(const String& color)
Bool getSelectedData (Vector <Double> &x, Vector <Double> &y)
Bool getDataAndSelectionMask (Vector <Double> &x, Vector <Double> &y, Vector <Bool> &selectionMask)
Bool getDataAndSelectionMask (int dataSetId, Vector <Double> &x, Vector <Double> &y, Vector <Bool> &selectionMask)
virtual void placeXMarker (Double mappedX) = 0
virtual void placeYMarker (Double mappedY) = 0
virtual void enableXMarker (int onOrOff) = 0
virtual void enableYMarker (int onOrOff) = 0
virtual void setLegendAndAxisTitles (const String &title)
virtual void setLegendAndAxisTitles (const String &title1, const String &title2)
Double xAxisMin ()
Double xAxisMax ()
Double yAxisMin ()
Double yAxisMax ()
Double y1AxisMin ()
Double y1AxisMax ()
Double y2AxisMin ()
Double y2AxisMax ()
virtual void setXScale (Double x0, Double x1)
void setYScale (Double y0, Double y1)
virtual void setY1Scale (Double y0, Double y1)
virtual void setY2Scale (Double y0, Double y1)
Bool fullScale()
virtual void setFullScale()
SelectableObjects currentSelectable ()
void setSelectable (const SelectableObjects &newValue)
DragModes currentDragMode ()
DragModes dragMode ()
void setDragMode (const DragModes &newValue)
Double dataXMin () const
Double dataXMax () const
Double dataYMin () const
Double dataYMax () const
Double dataY1Min() const
Double dataY1Max() const
Double dataY2Min() const
Double dataY2Max() const
Double plotXMin () const
Double plotXMax () const
Double plotYMin () const
Double plotYMax () const
Double plotY1Min() const
Double plotY1Max() const
Double plotY2Min() const
Double plotY2Max() const
Double plotXLeft() const
Double plotXRight() const
Double plotYBottom() const
Double plotYTop() const
Double plotY1Bottom() const
Double plotY1Top() const
Double plotY2Bottom() const
Double plotY2Top() const
const char * plotTitleChars() const
const char * xAxisLabelChars() const
const char * yAxisLabelChars() const
const char * y1AxisLabelChars() const
const char * y2AxisLabelChars() const
Plot1dSelection getSelection (Int selectIndex)
Bool xAxisReversed() const
Bool yAxisReversed() const
Bool y1AxisReversed() const
Bool y2AxisReversed() const
void setPrintCommand(const String & s)
const String & printCommand() const
const String & queryPrintCommand() const
void setPrinter (const String &printerName)
void drawBlockEnter()
void drawBlockExit()
Protected Members
void redrawEnter()
void redrawExit()
void redrawExitNoRedraw()
void resetAllRanges()
void adjustDataRanges(Plot1dData * pd)
void recomputeDataRanges()
void adjustDataMinAndMax (const Vector <Double> &x, const Vector <Double> &y)
void initializeDataBounds ()
Int recordDataSet (Vector <Double> &x, Vector <Double> &y, const String &name, Plot1dData::AssociatedYAxis yAxis)
Int recordDataSelection (Double x0, Double y0, Double x1, Double y1)
void clearDataSelections ()
Bool legalAxisType (AxisType newXAxisType, AxisType newYAxisType)
Int nY1DataSets() const
Int nY2DataSets() const
ListIter <Plot1dData *> * dataSetIterator()
Int nextDataSetId() const
Private Members
Int nsigfigs(Double v)
void minMaxFromValue(Double v, Double & min, Double & max)
Plot1d (const Plot1d &)
const Plot1d& operator = (const Plot1d &)

Description

Synopsis

General plotting class supporting 1-d/spectral line graphics. This class is utilized in PGPlot1d which presents these methods using familiar PGPLOT nomenclature. Interface provides means of specifying plot parameters of line style, font, axes, legends, etc.

Member Description

enum DataStyles

enum LineStyles

enum PointStyles

enum AxisPlacementStrategy

enum AxisType

enum LegendGeometry

datasets are usually plotted against a single y axis, even if there are multiple datasets. but it is sometimes helpful to plot datasets with very different y values on the same graph, and using the same x axis. for example, you might wish to plot temperature and pressure for a single block of time; the temperature scale would be on the first y axis (usually on the left) and the pressure scale could be on the second y axis (usually on the right), with time on the x axis.

Plot1d ()

virtual ~Plot1d ()

Int addDataSet (Vector <Double> &y, const String &name, DataStyles style = linespoints, const char *xLabel = "", const char *yLabel = "", Plot1d::AxisType xAxisType = RAW_AXIS, Plot1d::AxisType yAxisType = RAW_AXIS, Plot1dData::AssociatedYAxis whichYAxis = Plot1dData::Y1Axis)

Fill in X vector and relay to function below

Int addDataSet (Vector <Double> &x, Vector <Double> &y, const String &name, DataStyles style = linespoints, const char *xLabel = "", const char *yLabel = "", Plot1d::AxisType xAxisType = RAW_AXIS, Plot1d::AxisType yAxisType = RAW_AXIS, Plot1dData::AssociatedYAxis whichYAxis = Plot1dData::Y1Axis)

Make this concrete, do error checking. Then relay to derived via addDataSet(Plot1dData, ...)

The number returned is the id to use or -1

Set the axis type and labels, log the addition in DS accounting, and call the derived class's version

virtual Int addDataSet (Plot1dData * data, Plot1d::DataStyles) = 0

If it gets to this point, then we know the dataset must be valid and compatible with the axis types.

virtual Int appendData (Int dataSet, Double x, Double y) = 0
virtual Int appendData (Int dataSet, Vector <Double> x, Vector <Double> y) = 0

neither of the following are (yet) designed to record the data in this object's non-graphical data store. the pros & cons of this need to be assessed.

Bool findDataSet(Int dataSetId)

NEW - findDataSet takes a (public) dataSetId and sets the dataSetIterator to point to the found id and returns True or returns False

virtual Int removeDataPoint (Int dataSetId, Int index)

remove a datapoint from a dataSet. This should not be pure virtual.

virtual void setDataStyle (Int dataSetId, DataStyles dataStyle) = 0

How is the data to be displayed

Plot1dData::AssociatedYAxis assignAxis(AxisType newXAxisType, AxisType newYAxisType, Plot1dData::AssociatedYAxis whichYAxis)

Fit data to axis typ. Try to use specified axis, else use other axis,else give up

void setAxisType (Int axis, AxisType axisType)

x axis: 0 y axis:1 z axis: 2

void setXAxisType (AxisType axisType)

Simplified interface

void setYAxisType (AxisType axisType)

void setY1AxisType (AxisType axisType)

void setY2AxisType (AxisType axisType)

virtual void setTopXAxis(Bool onOff)

virtual void setLeftY2Axis(Bool onOff)

virtual void setRightY1Axis(Bool onOff)

void setRightYAxis(Bool onOff)

virtual void setXAxisGrid(Bool onOff)

void setYAxisGrid(Bool onOff)

virtual void setY1AxisGrid(Bool onOff)

virtual void setY2AxisGrid(Bool onOff)

AxisType xAxisType() const

AxisType yAxisType() const

AxisType y1AxisType() const

AxisType y2AxisType() const

virtual void setPlotTitle (const String &newLabel)

virtual void setPlotTitleColor(const String& color)

virtual void setCursorColor(const String& color)

virtual void setXAxisLineWidth(const Int newSize)

virtual void setY1AxisLineWidth(const Int newSize)

virtual void setY2XAxisLineWidth(const Int newSize)

virtual void setXAxisGridLineWidth(const Int newSize)

virtual void setY1AxisGridLineWidth(const Int newSize)

virtual void setY2XAxisGridLineWidth(const Int newSize)

virtual void setXAxisLabel (const String &newLabel)
void setYAxisLabel (const String &newLabel)
virtual void setY1AxisLabel (const String &newLabel)
virtual void setY2AxisLabel (const String &newLabel)

Set the label for the axes

virtual void setXAxisColor (const String& color)
void setYAxisColor (const String& color)
virtual void setY1AxisColor (const String& color)
virtual void setY2AxisColor (const String& color)

Set the color of the axes

virtual void setXAxisLabelColor (const String& color)
void setYAxisLabelColor (const String& color)
virtual void setY1AxisLabelColor (const String& color)
virtual void setY2AxisLabelColor (const String& color)

Set the color of the axis labels

virtual void setXAxisGridColor (const String& color)

Set the color of the axis grid

void setYAxisGridColor (const String& color)

virtual void setY1AxisGridColor (const String& color)

virtual void setY2AxisGridColor (const String& color)

virtual void setLineColor (Int dataSetId, const String &color) = 0
virtual void setLineStyle (Int dataSetId, Plot1d::LineStyles lineStyle) = 0
virtual void setLineWidth (Int dataSetId, Int newSize) = 0

Set the line color, style, and width for given dataSet id

virtual void setPointColor (Int dataSet, const String &newColor) = 0
virtual void setPointStyle (Int dataSet, Plot1d::PointStyles pointStyle) = 0
virtual void setPointSize (Int dataSet, Int newSize) = 0

Set the point color, style, and size for given dataSet id

virtual void setXAxisPosition (AxisPlacementStrategy strategy, Double where = 0.0)
void setYAxisPosition (AxisPlacementStrategy strategy, Double where = 0.0)
virtual void setY1AxisPosition (AxisPlacementStrategy strategy, Double where = 0.0)
virtual void setY2AxisPosition (AxisPlacementStrategy strategy, Double where = 0.0)

set the position of the axes By default axis positioning not available

virtual void reverseXAxis ()

void reverseYAxis ()

virtual void reverseY1Axis ()

virtual void reverseY2Axis ()

virtual void swapY1Y2()

Default is to disable swapping

void swapY1Y2_()

... but provide implementation if derived wants to enable and use it in a derived version of swapY1Y2().

virtual void setLegendGeometry (LegendGeometry newGeometry)

virtual Bool printGraphToPrinter () = 0

virtual Bool printGraphToFile (String filename) = 0

Int nDataSets ()

nDataSets returns the number of datasets in the list

Int nextDataSetId()

nextDataSetId() returns the next available id for data sets

Int nSelections () const

#selections is internally maintained ==> Read Only

Int numberOfSelections () const

Vector <Double> getXValues (Int dataSetId)
Vector <Double> getYValues (Int dataSetId)

Return a COPY of the X or Y values in the given dataSetId

String describeDataSets ()

Return a String that describes the contents of the datasets.

String describeDataSelections ()

Return a String that describes the contents of the selection list.

virtual String describeDataDisplayStyles () = 0

Return a String that describes the display styles available.

virtual void redraw () = 0

Redraw the screen

virtual void clear () = 0

remove data, selections, initialize ancillary data, clear the plot window

virtual Bool deleteDataSet (Int dataSetId)

Remove the dataset identified by its index

void clearData()

Remove all datasets from the internal list

void deleteAllDataSets ()

void clearSelections()

Remove all selections from the internal list

void deleteSelections ()

virtual void showSelections(Bool /*onOff*/)

Draw the selections along with the points

virtual void setSelectionColor(const String& color)

Bool getSelectedData (Vector <Double> &x, Vector <Double> &y)

returns true if successful. all of the current selections are combined. if more than one dataset is on display, then the 'frontmost' or otherwise primary dataset is used.

Bool getDataAndSelectionMask (Vector <Double> &x, Vector <Double> &y, Vector <Bool> &selectionMask)

The full dataset is returned, both x and y vectors, plus a logical mask indicating elements have been selected.

This one chooses one from the first dataset available

Bool getDataAndSelectionMask (int dataSetId, Vector <Double> &x, Vector <Double> &y, Vector <Bool> &selectionMask)

The full dataset is returned, both x and y vectors, plus a logical mask indicating elements have been selected.

This one applies the selections to the specified dataset

virtual void placeXMarker (Double mappedX) = 0

  • only temporarily present here, to sidestep (glish?) bug for june 20 demo

    virtual void placeYMarker (Double mappedY) = 0

    virtual void enableXMarker (int onOrOff) = 0

    virtual void enableYMarker (int onOrOff) = 0

    virtual void setLegendAndAxisTitles (const String &title)

    virtual void setLegendAndAxisTitles (const String &title1, const String &title2)

    Double xAxisMin ()

    Double xAxisMax ()

    Double yAxisMin ()

    Double yAxisMax ()

    Double y1AxisMin ()

    Double y1AxisMax ()

    Double y2AxisMin ()

    Double y2AxisMax ()

    virtual void setXScale (Double x0, Double x1)

    Derived Functions should call Plot1d's version, then do specific work.

    void setYScale (Double y0, Double y1)

    virtual void setY1Scale (Double y0, Double y1)

    virtual void setY2Scale (Double y0, Double y1)

    Bool fullScale()

    NEW - Return true if all plot range meets or exceeds data range.

    virtual void setFullScale()

    NEW - Set plot range = data range Plot1d's version calls the setScale's above with the data ranges

    enum SelectableObjects

    OBS [ ] Plot1d can call virtual setScale functions for XRT virtual void restoreFullScale () = 0;

    How to select objects

    SelectableObjects currentSelectable ()

    void setSelectable (const SelectableObjects &newValue)

    enum DragModes

    Dragging? Ah... Using the cursor to describe a region...

    DragModes currentDragMode ()

    DragModes dragMode ()

    void setDragMode (const DragModes &newValue)

    Double dataXMin () const

    Read Acces for data limits

    Double dataXMax () const

    Double dataYMin () const

    Double dataYMax () const

    Double dataY1Min() const

    Double dataY1Max() const

    Double dataY2Min() const

    Double dataY2Max() const

    Double plotXMin () const

    Read Access for plot limits (min always less than max)

    Double plotXMax () const

    Double plotYMin () const

    Double plotYMax () const

    Double plotY1Min() const

    Double plotY1Max() const

    Double plotY2Min() const

    Double plotY2Max() const

    Double plotXLeft() const

    Read Access for plot left and right values accounting for reverse flags on each axis

    Double plotXRight() const

    Double plotYBottom() const

    Double plotYTop() const

    Double plotY1Bottom() const

    Double plotY1Top() const

    Double plotY2Bottom() const

    Double plotY2Top() const

    const char * plotTitleChars() const

    const char * xAxisLabelChars() const

    const char * yAxisLabelChars() const

    const char * y1AxisLabelChars() const

    const char * y2AxisLabelChars() const

    Plot1dSelection getSelection (Int selectIndex)

    Return the index'th selection (0-based)

    Bool xAxisReversed() const

    Read Access to axis reversed flags

    Bool yAxisReversed() const

    Bool y1AxisReversed() const

    Bool y2AxisReversed() const

    void setPrintCommand(const String & s)

    set the command string used to print including any options

    const String & printCommand() const

    return the print command string

    const String & queryPrintCommand() const

    void setPrinter (const String &printerName)

    (deprecated) set the command string to "pri -P"+printerName.

    void drawBlockEnter()

    Surround code that makes several changes to the graph with these two functions if you want to avoid having each change trigger a redraw. An underlying counter ensures redraw happens only on drawBlockExit.

    WARNING: This is a hook to an internal mechanism. If these functions are not executed in pairs, you will get strange results.

    void drawBlockExit()

    void redrawEnter()

    void redrawExit()

    void redrawExitNoRedraw()

    void resetAllRanges()

    NEW reset data and plot ranges to default values

    void adjustDataRanges(Plot1dData * pd)

    NEW adjust ranges as needed depending on the axis

    void recomputeDataRanges()

    NEW recalc ranges from scratch(e.g., after a delete)

    void adjustDataMinAndMax (const Vector <Double> &x, const Vector <Double> &y)

    OBS [ ] This is a problem because axis info is lost

    void initializeDataBounds ()

    OBS [ ] add

    Int recordDataSet (Vector <Double> &x, Vector <Double> &y, const String &name, Plot1dData::AssociatedYAxis yAxis)

    OBS [ ] This needs to be made obsolete

    Int recordDataSelection (Double x0, Double y0, Double x1, Double y1)

    A "Data Selection" is a region defined in the coordinate system of the plot data.

    void clearDataSelections ()

    delete all selections

    Bool legalAxisType (AxisType newXAxisType, AxisType newYAxisType)

    once a plot exists, some axis types will not make sense. for instance, if the x axis displays time, neither a raw nor skyposition axis makes any sense.

    Int nY1DataSets() const
    Int nY2DataSets() const

    Return number of data sets currently assigned to the corresponding axes

    ListIter <Plot1dData *> * dataSetIterator()

    Int nextDataSetId() const

    Int nsigfigs(Double v)

    void minMaxFromValue(Double v, Double & min, Double & max)

    Plot1d (const Plot1d &)

    Disable copy and assignment

    const Plot1d& operator = (const Plot1d &)