$(QTNATIVELIBS) -lbqplot_native -lbanner -lbrttutil -lbumapdata $(DBLIBS) $(TRLIBS) #include "BQ.h"
BQGlyphs(BQViewport *master, BQGlyphsGraphicsContext *ggc = NULL);
Where "master" is the bqplot BQViewport item that acts as the master for the BQGlyph object and ggc is an optional BQGlyphsGraphicsContext object that can be associated with this BQGlyphs object and can be used to configure its BQGlyph objects.
typedef int (BQ_glyphCallback) (BQGlyph *glyph, BQEvent *event, BQ_ClientData client_data);
% cat Makefile BIN= bqplot_test_glyphs fflags= ldflags= cflags = -g cxxflags = -g -I$(QTINCLUDE) ldlibs = -lbqplot_native $(QTNATIVELIBS) -lbanner -lbrttutil $(DBLIBS) include $(ANTELOPEMAKE) OBJS= bqplot_test_glyphs.o $(BIN) : $(OBJS) $(CXX) $(CXXFLAGS) -g -o $(BIN) $(OBJS) $(LDFLAGS) $(LDLIBS) % % cat bqplot_test_glyphs.cc #include "BQ.h" int main (int argc, char **argv) { QApplication qapp(argc, argv); qapp.setApplicationName("bqplot_test_glyphs"); QWidget *widget = new QWidget(); widget->setWindowTitle("bqplot_test_glyphs"); widget->show(); widget->resize (800, 800); BQViewport *myvp = new BQViewport(widget); myvp->configure ( "xleft", "-1.0", "xright", "5.0", "ybottom", "-1.1", "ytop", "1.1", "mleft", "80", "mright", "20", "mbottom", "50", "mtop", "30", "fill_frame", "lightblue", "fill", "#e0e0e0", NULL); BQAxes *myax = new BQAxes(myvp); myax->configure ( "xlabel", "My X-stuff", "ylabel", "My Y-stuff", "xformat", "%.1f", "yformat", "%.1f", "linewidth_box", "0", "linewidth_tics", "2", "linewidth_tics_small", "0", "axis_style", "sw", "tic_style", "siwinoeo", "linewidth_grids", "2", "linewidth_grids_small","0", "color_grids", "black", "color_grids_small", "#c0c0c0", NULL); BQ_XY points[] = { {1.2, 0.4}, {-0.5, -0.7}, {3.7, 0.3}, {2.1, 0.9}, {4.1, -0.5} }; int n = sizeof(points) / sizeof(BQ_XY); int symbols[] = { BQ_GRAPHICS_CONTEXT_SYMBOL_TYPE_CIRCLE, BQ_GRAPHICS_CONTEXT_SYMBOL_TYPE_SQUARE, BQ_GRAPHICS_CONTEXT_SYMBOL_TYPE_TRIANGLE, BQ_GRAPHICS_CONTEXT_SYMBOL_TYPE_DIAMOND, BQ_GRAPHICS_CONTEXT_SYMBOL_TYPE_STAR, }; BQGraphicsContext *gc = new BQGraphicsContext (); gc->setGcItem ("symbol:outline_color", BQ_GRAPHICS_CONTEXT_TYPE_COLOR_PEN, QColor("#80000000")); gc->setGcItem ("symbol:outline_width", BQ_GRAPHICS_CONTEXT_TYPE_LINEWIDTHF, 0.5); gc->setGcItem ("symbol:fill_color", BQ_GRAPHICS_CONTEXT_TYPE_COLOR_BRUSH, QColor("#a0ffff00")); gc->setGcItem ("symbol:size", BQ_GRAPHICS_CONTEXT_TYPE_SIZE, 20.0); gc->setGcItem ("symbol:opacity", BQ_GRAPHICS_CONTEXT_TYPE_OPACITY, 0.8); BqGraphicsContextCoding *coding_color = new BqGraphicsContextCoding[3]; BQGraphicsContext::setGcCoding (&(coding_color[0]), 0.0, 0.0, 240.0, 240.0); BQGraphicsContext::setGcCoding (&(coding_color[1]), 0.0, 1.0, 10.0, 1.0); BQGraphicsContext::setGcCoding (&(coding_color[2]), 0.0, 0.6, 10.0, 0.6); gc->setGcItemCoding ("symbol:fill_color", BQ_GRAPHICS_CONTEXT_CODING_TYPE_COLOR_HSL, coding_color); coding_color = new BqGraphicsContextCoding[1]; BQGraphicsContext::setGcCoding (&(coding_color[0]), 10.0, 10.0, 20.0, 20.0, 10.0, 50.0); gc->setGcItemCoding ("symbol:size", BQ_GRAPHICS_CONTEXT_CODING_TYPE_SCALAR, coding_color); BqGraphicsContext *gc_symbol = gc->getGc ("symbol"); BQGlyphs *glyphs = new BQGlyphs(myvp); glyphs->setInteractionMode(BQ_INTERACTION_MODE_MOVE); QList<BQGlyph *> glyph_list; for (int i=0; i<n; i++) { BQGlyph *glyph = new BQGlyph(myvp, glyphs); glyph->setPosition (points[i].x, points[i].y); glyph->setGlyph (symbols[i], NULL, gc_symbol); glyph->setCodingValue ("symbol:fill_color", i*(360.0/n)); glyph->setCodingValue ("symbol:size", 10.0+i*(40.0/n)); glyph_list.append (glyph); } double t0 = now(); QTimer *timer = new QTimer (widget); widget->connect (timer, &QTimer::timeout, [widget, glyph_list, t0]() { foreach (BQGlyph *glyph, glyph_list) { double hue_increment = 5.0; double size_increment = 0.5 - sin((now() - t0)*0.3); double hue = glyph->getCodingValue ("symbol:fill_color"); hue += hue_increment; glyph->setCodingValue ("symbol:fill_color", hue); double size = glyph->getCodingValue ("symbol:size"); size += size_increment; glyph->setCodingValue ("symbol:size", size); double xwalk = ((double)qrand()/RAND_MAX) - 0.5; double ywalk = ((double)qrand()/RAND_MAX) - 0.5; double xw, yw; glyph->getPosition (&xw, &yw); xw += xwalk*0.02; yw += ywalk*0.02; glyph->setPosition (xw, yw); } widget->update(); }); timer->start (100); qapp.exec(); exit (0); }