-lbqplot -lbanner -lbrttutil $(DBLIBS) #include "BQ.h"
This class inherits the BQConfigure class which is itself a subclass of the BUConfigure class with extensions to process Qt colors and fonts. The configure methods are implemented in the BUConfigure parent (see BUConfigure(3)). Note that BQEVOriginsTableview(3) objects can be linked to this object.
This class also inherits the BQTableview(3) class. The virtual BQTableview::callback method is implemented in this class. This class will show the client-side contents of EVEvent tables as returned by the various EVClient class methods. Note that the underlying database being processed by EVServer is not touched. There is no editing support. This class is meant as a simple display for selecting single rows for further processing.
BQEVEventsTableview(QWidget *parent, EVClient *ev_client); BQEVEventsTableview(QWidget *parent, EVServer *ev_server);
Where parent is the QWidget parent for this object, ev_client is the EVClient object to be displayed.
The second constructor syntax allows an EVServer ev_server pointer to be specified. In this case the EVClient object is created internally. Also the EVClient object is sub-classed within BQEVEventsTableview so that a custom responseCallback function (see EV(3)) is specified for servicing EVServer notifications of database changes with automatic refreshing of the tableview displays.
- label label
This is a label string to be used in the column header. If it is not specified, then the label will be set to the column definition name.- source source_expression
This is a semicolon delimited list of EV(3) value expressions that are evaluated on each row to determine the cell display values. Each expression can evaluate to a string or to a number. See EV VALUE EXPRESSIONS below for a definition of syntax.- sort sort_expression
This is a semicolon delimited list of EV(3) value expressions that are evaluated on each row to determine the cell values used for sorting. Each expression can evaluate to a string or to a number. See EV VALUE EXPRESSIONS below for a definition of syntax. Since the sort involves comparing two rows, the events[%index] part of the expression should be omitted and instead is substituted automatically within the sort function. These expressions should evaluate to a number if numerical based sorting is desired.- format format_string
This is a semicolon delimited list of format specifications, ala sprintf(3), for making the cell text. Each format fragment must correspond to the list of source expressions and each format string type must match the type returned from the source expression list. If this is not specified, then a default string conversion will be done.- text_template text_template_string
This is a template string used to set a fixed width for the column. The font metrics of the string using the current font is used to determine the width in pixels. If this can be parsed as an integer, then that value will be used as the width (see BQTableview(3) column_widths configuration parameter).- alignment {w|c|e}
This determines the cell text horizontal alignment, w for a west (left) alignment, c for a center alignment, or e for an east (right) alignment. If this is not specified then a default alignment will be used.- null null_string
This is a string used to define a null value. This string is compared to the final cell text string after all formatting. If the strings are equal, then the cell text is cleared.
events[0].origins[0].record_origin{lat}
This expression refers to a complete list of events (events), with the single event at the 0th index ([0]), with the single origin at the 0th index of all origins for this event (origins[0]), using the Datascope complete row record for that origin (record_origin) and evaluating the Datascope expression lat for that record ({lat}). This particular expression would return the latitude of that origin as a floating point number.
If the first token in the expression is events, then the expression must be evaluated against a list of EVEvent structures, each structure in the list defining a single event. The index values can be substituted using %index from the tableview callbacks by converting row numbers to index numbers using the various sorting tabs (done automatically). The parameter values for a single event (EVEvent structure) are defined as follows.
Whenever a single Datascope complete record string is at the end of the expression it can be follow by {<dbexpr>}. When this is done the regular Datascope expression <dbexpr> is evaluated against the record.
#include "BQ.h" #define EVENT_COLUMN_DEFINITIONS "\ column_definitions &Arr{\n\ evid &Arr{\n\ label evid\n\ text_template XXXXXX\n\ source events[%index].evid\n\ sort evid\n\ alignment e\n\ format %ld\n\ }\n\ time &Arr{\n\ label time\n\ text_template XXXXXXXXXXXXXXXXXXXXXX\n\ source events[%index].origins[pref_origin].record_origin{epoch2str(time, sort origins[pref_origin].time\n\ }\n\ lat &Arr{\n\ label lat\n\ text_template XXXXXXXXXX\n\ source events[%index].origins[pref_origin].record_origin{lat}\n\ sort origins[pref_origin].record_origin{lat}\n\ alignment e\n\ format %.3lf\n\ }\n\ lon &Arr{\n\ label lon\n\ text_template XXXXXXXXXX\n\ source events[%index].origins[pref_origin].record_origin{lon}\n\ sort origins[pref_origin].record_origin{lon}\n\ alignment e\n\ format %.3lf\n\ }\n\ depth &Arr{\n\ label depth\n\ text_template XXXXXXXX\n\ source events[%index].origins[pref_origin].record_origin{depth}\n\ sort origins[pref_origin].record_origin{depth}\n\ alignment e\n\ format %.2lf\n\ }\n\ region &Arr{\n\ label region\n\ text_template XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n\ source events[%index].origins[pref_origin].record_origin{grname(lat,lon)}\n\ sort origins[pref_origin].record_origin{grname(lat,lon)}\n\ alignment e\n\ }\n\ auth &Arr{\n\ label auth\n\ text_template XXXXXXXXXXXXXXXXXX\n\ source events[%index].origins[pref_origin].record_origin{auth}\n\ sort origins[pref_origin].record_origin{auth}\n\ alignment e\n\ }\n\ magnitude &Arr{\n\ label magnitude\n\ text_template XXXXXXXXXX'\n\ source events[%index].magnitude;events[%index].magtype\n\ sort magnitude;magtype\n\ alignment e\n\ format %4.2f;(%s)\n\ null -999.00()\n\ }\n\ }\n" #define EVENT_COLUMN_NAMES " column_names &Tbl{\n\ evid\n\ time\n\ region\n\ depth\n\ magnitude\n\ auth\n\ }\n" #define ORIGIN_COLUMN_DEFINITIONS " column_definitions &Arr{\n\ evid &Arr{\n\ label evid\n\ text_template XXXXXX\n\ source origins[%index].record_origin{evid}\n\ sort record_origin{evid}\n\ alignment e\n\ format %ld\n\ }\n\ orid &Arr{\n\ label orid\n\ text_template XXXXXX\n\ source origins[%index].orid\n\ sort orid\n\ alignment e\n\ format %ld\n\ }\n\ ndef &Arr{\n\ label ndef\n\ text_template XXXXXX\n\ source origins[%index].record_origin{ndef}\n\ sort record_origin{ndef}\n\ alignment e\n\ format %ld\n\ }\n\ nass &Arr{\n\ label nass\n\ text_template XXXXXX\n\ source origins[%index].record_origin{nass}\n\ sort record_origin{nass}\n\ alignment e\n\ format %ld\n\ }\n\ latency &Arr{\n\ label latency\n\ text_template XXXXXX:XX:XX:XX.XXX\n\ source origins[%index].record_origin{strtdelta(lddate-time)}\n\ sort record_origin{lddate-time}\n\ alignment e\n\ }\n\ time &Arr{\n\ label time\n\ text_template XXXXXXXXXXXXXXXXXXXXXX\n\ source origins[%index].record_origin{epoch2str(time, sort time\n\ }\n\ lat &Arr{\n\ label lat\n\ text_template XXXXXXXXXX\n\ source origins[%index].record_origin{lat}\n\ sort record_origin{lat}\n\ alignment e\n\ format %.3lf\n\ }\n\ lon &Arr{\n\ label lon\n\ text_template XXXXXXXXXX\n\ source origins[%index].record_origin{lon}\n\ sort record_origin{lon}\n\ alignment e\n\ format %.3lf\n\ }\n\ depth &Arr{\n\ label depth\n\ text_template XXXXXXXX\n\ source origins[%index].record_origin{depth}\n\ sort record_origin{depth}\n\ alignment e\n\ format %.2lf\n\ }\n\ region &Arr{\n\ label region\n\ text_template XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n\ source origins[%index].record_origin{grname(lat,lon)}\n\ sort record_origin{grname(lat,lon)}\n\ alignment e\n\ }\n\ auth &Arr{\n\ label auth\n\ text_template XXXXXXXXXXXXXXXXXX\n\ source origins[%index].record_origin{auth}\n\ sort record_origin{auth}\n\ alignment e\n\ }\n\ magnitude &Arr{\n\ label magnitude\n\ text_template XXXXXXXXXX'\n\ source origins[%index].magnitude;origins[%index].magtype\n\ sort magnitude;magtype\n\ alignment e\n\ format %4.2f;(%s)\n\ null -999.00()\n\ }\n\ }\n" #define ORIGIN_COLUMN_NAMES " column_names &Tbl{\n\ evid\n\ orid\n\ ndef\n\ nass\n\ time\n\ depth\n\ magnitude\n\ auth\n\ latency\n\ }\n" class MyEventsTableview : public BQEVEventsTableview { public: MyEventsTableview (QWidget *parent, EVServer *ev_server) : BQEVEventsTableview (parent, ev_server) {} int verbose=0; protected: void selectionCallback (int &rec, long evid, long orid) { if (verbose) { EVServer::print (getEvents()->data()+rec); } else qDebug() << rec << evid << orid; } }; class MyOriginTableview : public BQEVOriginsTableview { public: MyOriginTableview (QWidget *parent, BQEVEventsTableview *sync_events_table) : BQEVOriginsTableview (parent, sync_events_table) {} int verbose=0; protected: void selectionCallback (int &rec, long evid, long orid) { if (verbose) { EVServer::print (getOrigins()->data()+rec); } else qDebug() << rec << evid << orid; } }; int main (int argc, char **argv) { int verbose = 0; char *dbname; if (argc != 2 && argc != 3) { fprintf (stderr, "usage: bqplot_test_evtableview [-v] dbname\n"); exit (1); } if (argc == 3 && strcmp(argv[1], "-v")) { fprintf (stderr, "usage: bqplot_test_evtableview [-v] dbname\n"); exit (1); } if (argc == 3) { verbose = 1; dbname = argv[2]; } else { verbose = 0; dbname = argv[1]; } auto evserver = new EVServer (dbname); QApplication qapp(argc, argv); qapp.setApplicationName("bqplot_test_evtableview"); QWidget *widget = new QWidget(); widget->setWindowTitle("bqplot_test_evtableview"); widget->show(); widget->resize (800, 400); QSplitter *splitter = new QSplitter (Qt::Vertical, widget); QGridLayout *layout = new QGridLayout (widget); layout->setSpacing (0); layout->setContentsMargins (0, 0, 0, 0); widget->setLayout (layout); layout->addWidget (splitter, 0, 0, 1, 1); MyEventsTableview *evtb = new MyEventsTableview(widget, evserver); evtb->verbose = verbose; evtb->configure ( "column_definitions", EVENT_COLUMN_DEFINITIONS, "column_names", EVENT_COLUMN_NAMES, "font", "courier,12", "font_header", "courier,12,Normal", "default_hover_interaction", "no", "show_record_numbers", "yes", "default_cell_height", "15", "auto_select_event", "mostrecent", NULL); evtb->sortByColumn ("time", 1); BQ_clear_register (1); splitter->addWidget (evtb); MyOriginTableview *ortb = new MyOriginTableview(widget, evtb); ortb->verbose = verbose; ortb->configure ( "column_definitions", ORIGIN_COLUMN_DEFINITIONS, "column_names", ORIGIN_COLUMN_NAMES, "font", "courier,12", "font_header", "courier,12,Normal", "default_hover_interaction", "no", "show_record_numbers", "yes", "default_cell_height", "15", NULL); ortb->sortByColumn ("latency"); BQ_clear_register (1); splitter->addWidget (ortb); int width, height; evtb->totalSize (width, height); int widthor, heightor; ortb->totalSize (widthor, heightor); if (widthor > width) width = widthor; width += 18; height += 18; if (width > 2000) width = 2000; if (height > 1800) height = 1800; if (height < 500) height = 500; widget->resize (width, height); widget->setMaximumWidth (width); evserver->autoRefreshEvents (1.0); qapp.exec(); exit (0); }