#ifndef SCATTERPLOT_H #define SCATTERPLOT_H #include #include #include #include #include #include "colorscale.h" #include "quadtree.h" #include "geometry.h" #include "scale.h" #include "shader.h" class Scatterplot { public: static const int PADDING = 20; Scatterplot(); ~Scatterplot(); arma::mat XY() const; void setColormap(GLuint texture); void setAutoScale(bool autoScale); size_t width() const { return m_width; } size_t height() const { return m_height; } void setSize(size_t, size_t); float glyphSize() const { return m_glyphSize; } void setGlyphSize(float glyphSize); void setDragEnabled(bool enabled) { m_dragEnabled = enabled; } bool isDragEnabled() const { return m_dragEnabled; } GLuint texture() const { return m_outTex; } nod::signal xyChanged, xyInteractivelyChanged; nod::signal colorDataChanged, opacityDataChanged; nod::signal &)> selectionChanged, selectionInteractivelyChanged; nod::signal itemBrushed, itemInteractivelyBrushed; nod::signal &, const LinearScale &)> scaleChanged; nod::signal glyphSizeChanged; void setXY(const arma::mat &xy); void setColorData(const arma::vec &colorData); void setOpacityData(const arma::vec &opacityData); void setScale(const LinearScale &sx, const LinearScale &sy); void setSelection(const std::vector &selection); void brushItem(int item); void update(); void draw(); protected: // QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *); // void mousePressEvent(QMouseEvent *event); // void mouseMoveEvent(QMouseEvent *event); // void mouseReleaseEvent(QMouseEvent *event); // void hoverEnterEvent(QHoverEvent *event); // void hoverMoveEvent(QHoverEvent *event); // void hoverLeaveEvent(QHoverEvent *event); private: // QSGNode *newSceneGraph(); // QSGNode *newGlyphTree(); void applyManipulation(); void updateGeometry(); void updateMaterials(); void updateTransform(); // void updateGlyphs(QSGNode *node); // void updateBrush(QSGNode *node); // Data arma::mat m_xy; arma::vec m_colorData; arma::vec m_opacityData; // Visuals size_t m_width, m_height; float m_glyphSize; std::shared_ptr m_colorScale; void autoScale(); bool m_autoScale; LinearScale m_sx, m_sy; // Internal state void interactiveSelection(bool mergeSelection); std::vector m_selection; bool m_anySelected; int m_brushedItem; enum State { StateNone, StateBrushing, StateSelecting, StateSelected, StateMoving } m_interactionState; bool m_dragEnabled; std::unique_ptr m_shader, m_shaderOutline; GLuint m_VAO, m_pointsVBO, m_valuesVBO; GLuint m_FBO, m_outFBO, m_colormapTex, m_depthTex, m_tex, m_outTex; GLfloat m_transform[4][4]; std::vector m_points; vec2 m_dragOriginPos, m_dragCurrentPos; bool m_redraw, m_shouldUpdateGeometry, m_shouldUpdateMaterials; std::unique_ptr m_quadtree; void updateQuadTree(); }; #endif // SCATTERPLOT_H