OpenCurves  0.9
PlotSource Class Reference

Provides details about a source from which PlotInstance objects have been generated. More...

#include <plotsource.h>

Inheritance diagram for PlotSource:
plotutil::RefCountObject< PlotSource >

Public Types

enum  Type {
  None, File, Expression, RealTime,
  User = 64
}
 Defines where the plot was loaded from. More...
 
typedef plotutil::RefCountPtr< PlotSourcePtr
 Reference counted pointer reference.
 

Public Member Functions

 PlotSource (int sourceType, const QString &fullName, unsigned curveCount=0)
 Create a PlotSource of the given type and full name. More...
 
 ~PlotSource ()
 Simple destructor.
 
unsigned type () const
 Identify the source type. More...
 
QString name () const
 Access the short name. More...
 
void setName (QString name)
 Set the short name. More...
 
QString fullName () const
 Access the full source name. More...
 
void setFullName (QString name)
 Set the full source name (e.g., file name). More...
 
unsigned timeColumn () const
 Returns the index of the curve used to generate timestamps for all other columns. More...
 
void setTimeColumn (unsigned index)
 Set the 1-based time column index or zero for none. More...
 
double timeScale () const
 Returns the time scaling applied to curves using this source. More...
 
void setTimeScale (double scale)
 Returns the time scaling applied to curves using this source. More...
 
double timeBase () const
 Returns the time base for the source. More...
 
void setTimeBase (double time)
 Sets the time base for the source. More...
 
double firstTime () const
 Request the first time value from the time column. More...
 
unsigned curveCount () const
 Returns the number of curves associated with the source.
 
PlotInstancecurve (unsigned index) const
 Request a curve at the given index. More...
 
PlotInstancetimeColumnCurve () const
 Returns the time column curve (if any). More...
 
void addCurve (PlotInstance *curve)
 Add a curve to this source. More...
 
void removeCurve (const PlotInstance *curve)
 Remove a curve to this source. More...
 
void deriveName ()
 Set the name() based on the current fullName(). More...
 
bool lengthenName ()
 Lengthen the short name() to attempt to disambiguate. More...
 
- Public Member Functions inherited from plotutil::RefCountObject< PlotSource >
 RefCountObject ()
 Constructor, setting a zero reference count.
 
 RefCountObject (int initialCount)
 Constructor, setting the given initial reference count. More...
 
int referenceCount () const
 Access the current reference count. More...
 
int addReference ()
 Increment and return the reference count. More...
 
int decReference ()
 Decrement the reference count. More...
 

Detailed Description

Provides details about a source from which PlotInstance objects have been generated.

The source is shared among PlotInstance objects generated from the same source and the source knows of its plots. The source is reference counted because of its shared nature and should always be wrapped in a Ptr.

The source also holds shared timing details such as time scale and column for the curves.

Member Enumeration Documentation

Defines where the plot was loaded from.

This lists the built-in sources.

Enumerator
None 

No source: invalid.

File 

Loaded from a file.

Expression 

A generated expression with no other source.

Expressions generally share their source with the original plot referenced by the expression.

RealTime 

A real time plot over a serial, TCP or UDP connection.

User 

User type values should start here.

Constructor & Destructor Documentation

PlotSource::PlotSource ( int  sourceType,
const QString &  fullName,
unsigned  curveCount = 0 
)

Create a PlotSource of the given type and full name.

The name() is set to match fullName. Use deriveName() to create a shorter name().

Parameters
sourceTypeThe source type. Nominally a value from Type, though user types may be specified.
fullNameThe full name for the source. E.g., the generating file name or expression.
See also
lengthenName().
Parameters
curveCountOptional specification for the expected number of curves associated with this source. Used in array reservations.

Member Function Documentation

void PlotSource::addCurve ( PlotInstance curve)

Add a curve to this source.

Internal use only.

Parameters
curveThe curve to add.
PlotInstance* PlotSource::curve ( unsigned  index) const

Request a curve at the given index.

Parameters
indexThe curve index. Should be [0, curveCount()), but out of range returns null.
Returns
The curve at index, or null when out of bounds.
void PlotSource::deriveName ( )

Set the name() based on the current fullName().

This treats fullName() as a file name, and extracts the file name without path or extension. Both slashes are accepted as delimiters.

double PlotSource::firstTime ( ) const

Request the first time value from the time column.

Returns
The first value in the time column. Zero with no such column.
QString PlotSource::fullName ( ) const
inline

Access the full source name.

Returns
The long source name.
bool PlotSource::lengthenName ( )

Lengthen the short name() to attempt to disambiguate.

This method is designed to help distinguish situations where a source files share a name, but lie in different directories. Normally, the short name for both will be the same. By calling lengthenName(), the parent directory is added to the name().

Successfull name lengthening requires that the fullName() is delimited by a directory separator character: either '/' or '\' (both are accepted on all platforms). The name is lengthened by adding more delimited tokens to the short name. The following example continuing lengthens an example source name until it can no longer be lengthened.

Initial name() Lengthened name() fullName()
data dir-a/data C:\temp\dir-a\data.txt
dir-a/data temp/dir-a/data C:\temp\dir-a\data.txt
temp/dir-a/data C:/temp/dir-a/data C:\temp\dir-a\data.txt
NYI:C:/temp/dir-a/data C:/temp/dir-a/data.txt C:\temp\dir-a\data.txt

This function was intended for use when there were sources with the same name(), This may be revisited in future.

Returns
True if the name() has been successfully lengthened. Otherwise it is unchanged.
QString PlotSource::name ( ) const
inline

Access the short name.

Used in short display context.

Returns
The short name.

Referenced by setFullName(), and setName().

void PlotSource::removeCurve ( const PlotInstance curve)

Remove a curve to this source.

Internal use only.

Parameters
curveThe curve to remove.
void PlotSource::setFullName ( QString  name)
inline

Set the full source name (e.g., file name).

Should be unique. Does not affect the short name().

Follow with a call to deriveName() to set the name() based on the full name.

Parameters
nameThe new name.

References name().

void PlotSource::setName ( QString  name)
inline

Set the short name.

Parameters
nameThe new name.

References name().

void PlotSource::setTimeBase ( double  time)
inline

Sets the time base for the source.

Parameters
timeThe base time (origin).
void PlotSource::setTimeColumn ( unsigned  index)
inline

Set the 1-based time column index or zero for none.

Parameters
indexThe new column index.
void PlotSource::setTimeScale ( double  scale)
inline

Returns the time scaling applied to curves using this source.

Parameters
scaleThe new time scale multiplier. Must not be zero.
double PlotSource::timeBase ( ) const
inline

Returns the time base for the source.

This is considered time zero. Scaling is applied afterwards.

Returns
The time base.
unsigned PlotSource::timeColumn ( ) const
inline

Returns the index of the curve used to generate timestamps for all other columns.

This is a 1 based index.

A zero indicates no time column.

PlotInstance* PlotSource::timeColumnCurve ( ) const

Returns the time column curve (if any).

Returns
The time column curve, or null if there is no such curve.
double PlotSource::timeScale ( ) const
inline

Returns the time scaling applied to curves using this source.

Returns
The time scale multiplier.
unsigned PlotSource::type ( ) const
inline

Identify the source type.

Returns
The source Type.

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