OpenCurves
0.9
|
Provides details about a source from which PlotInstance
objects have been generated.
More...
#include <plotsource.h>
Public Types | |
enum | Type { None, File, Expression, RealTime, User = 64 } |
Defines where the plot was loaded from. More... | |
typedef plotutil::RefCountPtr< PlotSource > | Ptr |
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. | |
PlotInstance * | curve (unsigned index) const |
Request a curve at the given index. More... | |
PlotInstance * | timeColumnCurve () 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... | |
![]() | |
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... | |
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.
enum PlotSource::Type |
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. |
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()
.
sourceType | The source type. Nominally a value from Type , though user types may be specified. |
fullName | The full name for the source. E.g., the generating file name or expression. |
lengthenName()
. curveCount | Optional specification for the expected number of curves associated with this source. Used in array reservations. |
void PlotSource::addCurve | ( | PlotInstance * | curve | ) |
Add a curve to this source.
Internal use only.
curve | The curve to add. |
PlotInstance* PlotSource::curve | ( | unsigned | index | ) | const |
Request a curve at the given index.
index | The curve index. Should be [0, curveCount() ), but out of range returns null. |
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.
|
inline |
Access the full 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.
name()
has been successfully lengthened. Otherwise it is unchanged.
|
inline |
Access the short name.
Used in short display context.
Referenced by setFullName(), and setName().
void PlotSource::removeCurve | ( | const PlotInstance * | curve | ) |
Remove a curve to this source.
Internal use only.
curve | The curve to remove. |
|
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.
name | The new name. |
References name().
|
inline |
|
inline |
Sets the time base for the source.
time | The base time (origin). |
|
inline |
Set the 1-based time column index or zero for none.
index | The new column index. |
|
inline |
Returns the time scaling applied to curves using this source.
scale | The new time scale multiplier. Must not be zero. |
|
inline |
Returns the time base for the source.
This is considered time zero. Scaling is applied afterwards.
|
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).
|
inline |
Returns the time scaling applied to curves using this source.
|
inline |
Identify the source type.
Type
.