OpenCurves
0.9
|
A plot generator which loads data from CSV style text files. More...
#include <plotfileloader.h>
Public Member Functions | |
PlotFileLoader (Curves *curves, const QStringList &plotFiles, QVector< TimeSampling > *timing=nullptr) | |
Creates a loader for the given file set. More... | |
bool | append (const QStringList &plotFiles, QVector< TimeSampling > *timing=nullptr) |
Append a list of files to the currently loading list of files. More... | |
void | setTargetSampleCount (uint target) |
Set the target maximum number of sample points in a curve. More... | |
uint | targetSampleCount () const |
Access the target sample count. More... | |
virtual bool | isFileLoad () const override |
True. More... | |
![]() | |
PlotGenerator (Curves *curves) | |
Instantiate the generator thread to load data into curves . More... | |
virtual | ~PlotGenerator () |
Destructor. The thread should generally be stopped before destructing. | |
const Curves * | curves () const |
Access the curves model to load data into. | |
void | setTimeColumn (uint number) |
Set the expected time column for all curves created by this generator. More... | |
uint | timeColumn () const |
The time column value in used. More... | |
void | setTimeScale (double scale) |
Set the scale factor applied to all curves created by this generator. More... | |
double | timeScale () const |
Access the time scale used by this generator. More... | |
void | setControlFlags (uint flags) |
Sets ControlFlag values for this generator. More... | |
void | setControlFlags (uint flags, bool on) |
Set the state of subset of ControlFlag values without affecting other flags. More... | |
uint | controlFlags () const |
Access the current ControlFlag values. | |
void | quit () |
Call to request the generator terminate operation. | |
Protected Member Functions | |
void | run () override |
File loading implementation. | |
Additional Inherited Members | |
![]() | |
enum | ControlFlag { None = 0, RelativeTime = (1 << 0) } |
Plot generation control flags. Must be set before execution. More... | |
![]() | |
void | abortLoad () |
Request loading abort. | |
![]() | |
void | itemName (const QString &name) |
Signal the current item name. More... | |
void | itemProgress (int current) |
Update progress through the current item. More... | |
void | overallProgress (int current, int total) |
This signal reports overall progress. More... | |
void | beginNewCurves () |
Begin the addition of new curves via Curves::newCurve() Block notification occurs at a per PlotSource level. More... | |
void | endNewCurves () |
End notification of new curves via Curves::newCurve() . More... | |
void | loadComplete (int curveCount) |
Notify completion of curve generation. More... | |
![]() | |
Curves * | _curves |
Curves data model. | |
QMutex * | _dataMutex |
Data mutex. | |
uint | _controlFlags |
ControlFlag values affecting generation. | |
uint | _timeColumn |
Index of the time column, zero for none. | |
double | _timeScale |
Time scaling factor. | |
bool | _abortFlag |
Abort requested? | |
A plot generator which loads data from CSV style text files.
Data loading is supported by the PlotFile
class. See that class for more details of how data are loaded.
The file loader may optionally down-sample the data file by skipping data lines. This is controlled by the targetSampleCount()
. A crude estimate is made of the number of lines in the data file and lines are skipped to attempt to meet the target. The line count estimate is made by determining the length of the first data line and dividing the file by this value. All samples are loaded if the estimate does not exceed the target.
The first and last data lines are always preserved.
General usage is to construct the generator with the files to load, the start()
the thread. Additional files may be queued using append()
, but a new loader is required if this call fails.
Each file may optionally be given its own TimeSampling
to set the time column, time scale and base time.
PlotFileLoader::PlotFileLoader | ( | Curves * | curves, |
const QStringList & | plotFiles, | ||
QVector< TimeSampling > * | timing = nullptr |
||
) |
Creates a loader for the given file set.
curves | The Curves model to add curves to. |
plotFiles | The list of files to load. |
timing | Optionally specifying timing data for each file. Uses as many as it can, attempting to match 1-to-1 with plotFiles , but supports element count mismatches. Falls back to the generator's general time settings. |
bool PlotFileLoader::append | ( | const QStringList & | plotFiles, |
QVector< TimeSampling > * | timing = nullptr |
||
) |
Append a list of files to the currently loading list of files.
This extends the files to load as if originally given to the constructor. The call is thread-safe and extends the list before or during loading, but fails if the loading thread has progressed beyond the load loop.
plotFiles | The additional files to load. |
timing | Optional timing data for the plot files. See constructor. |
|
inlineoverridevirtual |
|
inline |
Set the target maximum number of sample points in a curve.
This limits the number of loaded samples for large files.
target | The target sample count. |
|
inline |
Access the target sample count.
PlotInstance
.