229 lines
5.1 KiB
C++
229 lines
5.1 KiB
C++
#ifndef SEASET_H
|
|
#define SEASET_H
|
|
|
|
#include <stddef.h>
|
|
#include <qstring.h>
|
|
#include <qlayout.h>
|
|
#include <qdatetime.h>
|
|
#include <qdict.h>
|
|
#include <qwt_plot.h>
|
|
#include <qwt_plot_zoomer.h>
|
|
#include <qptrlist.h>
|
|
#include <qptrcollection.h>
|
|
#include <qsplitter.h>
|
|
#include <qhbox.h>
|
|
#include <qvbox.h>
|
|
#include <qlabel.h>
|
|
#include <qlineedit.h>
|
|
#include <qtimer.h>
|
|
#include <qdatetime.h>
|
|
#include <qpushbutton.h>
|
|
#include <qpixmap.h>
|
|
#include "sicsconn.h"
|
|
#include "seaplot.h"
|
|
|
|
#define SEA_MAX_RANGE (240*3600-60)
|
|
|
|
// values lower or equal than this value are considered as undefined
|
|
#define DATA_UNDEF (-1e33)
|
|
|
|
class SeaPlot;
|
|
class SeaSet;
|
|
class SeaRow;
|
|
class QGrid;
|
|
class LegendButton;
|
|
|
|
class SeaData {
|
|
public:
|
|
SeaData(const QString &name, const QString &label, const QString &plotName, int color=0);
|
|
~SeaData();
|
|
int addValue(double xx, QString value);
|
|
bool update();
|
|
void init(time_t step, int siz);
|
|
void showValueAt(double at);
|
|
bool isActive();
|
|
|
|
QString name;
|
|
QString label;
|
|
QString plotName;
|
|
int size;
|
|
double *x; // x[0..size_m-1]
|
|
double *y; // y[0..size_m-1]
|
|
double step_m;
|
|
double lastx;
|
|
int size_m;
|
|
bool clr;
|
|
bool dirty;
|
|
bool modified;
|
|
bool bold;
|
|
bool exact;
|
|
double period; // update period
|
|
long key;
|
|
SeaPlot *plot;
|
|
SeaRow *row;
|
|
QLabel *shownValue;
|
|
int decipos;
|
|
long style;
|
|
};
|
|
|
|
typedef enum {hiddenRow, shownRow, newRow} RowState;
|
|
|
|
class SeaRow: public QScrollView {
|
|
Q_OBJECT
|
|
public:
|
|
SeaRow(QWidget *parent);
|
|
QHBox *hBox;
|
|
// QScrollView *left;
|
|
SeaPlot *plot;
|
|
QGrid *leg;
|
|
QScrollView *legScroll;
|
|
QVBox *right;
|
|
SeaSet *set;
|
|
QPtrList<LegendButton> legendList;
|
|
uint usedLegend;
|
|
QHBox *bBox;
|
|
RowState state;
|
|
QPushButton *lBut;
|
|
QPixmap pmLin, pmLog;
|
|
QLabel *tagLabel;
|
|
QLabel *timeLabel;
|
|
void setInnerHeights(bool isfirstrow, int rowH);
|
|
void setTag(QString tag);
|
|
|
|
virtual void resizeEvent(QResizeEvent *e);
|
|
virtual QSize minimumSizeHint() const;
|
|
public slots:
|
|
void hideRow();
|
|
void linLog();
|
|
};
|
|
|
|
typedef enum {liveOff, liveAuto, liveOn} LiveState;
|
|
|
|
typedef struct GetArg {
|
|
bool all, append;
|
|
time_t from, to;
|
|
} GetArg;
|
|
|
|
typedef struct AutoArg {
|
|
QString vars;
|
|
} AutoArg;
|
|
|
|
class SeaSet : public QObject {
|
|
Q_OBJECT
|
|
friend class SeaPlot;
|
|
friend class SeaRow;
|
|
public:
|
|
SeaSet( QSplitter *parent, long range, const char *name);
|
|
SeaRow *newPlot(const char *name = "");
|
|
int leftLabelWidth(int in);
|
|
void insertData(const QString &cName, const QString &label, const QString &pName, const int color);
|
|
void clrDataList();
|
|
void finishDataList();
|
|
QString dateLabel(long dayOffset);
|
|
QPtrList<SeaData> dataList;
|
|
void readNewReplot();
|
|
void rescaleRange(time_t range);
|
|
void rescale(time_t from, time_t to);
|
|
void rescale(double from, double to);
|
|
void calcBase(time_t from);
|
|
void saveRange();
|
|
void saveRange(SeaPlot *plot, QwtDoubleRect &old, bool yAuto);
|
|
void hideRow();
|
|
void adjustSizes();
|
|
int sicsCommand(QString &cmd, int graph=0); // blocking
|
|
int sendSicsCommand(QString &cmd, int graph=0); // non-blocking
|
|
void setMarker(double x);
|
|
void setTimeLabel(double x);
|
|
void runningMarkerOff(bool beforeEvent);
|
|
void saveRowHeight(SeaRow *row, int height);
|
|
int getRowHeight(SeaRow *row);
|
|
void saveBoldState(SeaData *data);
|
|
void getBoldState(SeaData *data);
|
|
void setFirstRow();
|
|
void gotoTime(double at, bool silent);
|
|
|
|
SicsConnection *sc, *uc, *gc, *ec;
|
|
int legendWidth, actLegendWidth;
|
|
QString hostport;
|
|
time_t startRange, endRange;
|
|
time_t base;
|
|
double markerPos;
|
|
bool markerWasOn;
|
|
bool markerFix;
|
|
SeaRow *firstRow;
|
|
double lastTime;
|
|
|
|
public slots:
|
|
void autoCurves(const char *vars = 0);
|
|
void setHost(const QString &hostport);
|
|
void setTimeRange(time_t start, long seconds);
|
|
void showAll();
|
|
void liveUpdate();
|
|
//void handleSics(const char *line);
|
|
void shiftLeft();
|
|
void zoomOutX();
|
|
void shiftRight();
|
|
void undoZoom();
|
|
void setLive(bool on);
|
|
void restart(const char *vars);
|
|
void replot();
|
|
void replotAnyway();
|
|
void asyncHandler();
|
|
void setMarker(time_t t);
|
|
|
|
signals:
|
|
void putCurve(const QString &name, const QString &plot);
|
|
void undoEnabled(bool on);
|
|
void updateCurveList();
|
|
void gotoTime(time_t from, time_t at, time_t to, bool silent);
|
|
|
|
private:
|
|
void setBase();
|
|
void setDate();
|
|
void getCurves(bool all, time_t from, time_t to);
|
|
SeaData *findData(const QString &name);
|
|
void calcLeftLabelWidth();
|
|
|
|
bool autoCurvesP1();
|
|
void autoCurvesP2();
|
|
int getCurvesP1();
|
|
void getCurvesP2();
|
|
|
|
QSplitter *split;
|
|
QLayout *layout;
|
|
time_t lastRead; // time of last read on server
|
|
bool compressed;
|
|
QPtrList<SeaRow> rows;
|
|
int nplots;
|
|
QwtPlotZoomer *zoom;
|
|
int labelWidth;
|
|
int labelMode;
|
|
bool reread;
|
|
int refresh;
|
|
LiveState live;
|
|
time_t liveTime;
|
|
SeaPlot *undoPlot;
|
|
QwtDoubleRect undoRect;
|
|
time_t undoStart, undoEnd;
|
|
bool undoAuto;
|
|
bool initSizes;
|
|
int xSize;
|
|
time_t curveStep;
|
|
// asynchronous stuff:
|
|
enum {async_idle, async_auto, async_get} async_mode;
|
|
AutoArg autoArg, autoArgDo;
|
|
GetArg getArg, getArgDo;
|
|
bool autoDo, getDo, getNewData;
|
|
QTimer *asyncTimer;
|
|
QTime meas;
|
|
QTime tmot;
|
|
bool showPlot;
|
|
QDict<int> rowHeightDict;
|
|
QDict<bool> boldDict;
|
|
};
|
|
|
|
void setprintit(int p);
|
|
int printit(void);
|
|
|
|
#endif
|