#ifndef SCATTERPLOT_H #define SCATTERPLOT_H #include #include #include #include #include "colorscale.h" #include "quadtree.h" #include "geometry.h" #include "scale.h" class Scatterplot { public: static const int PADDING = 20; Scatterplot(); arma::mat XY() const; void setColorScale(std::shared_ptr colorScale); void setAutoScale(bool autoScale); float x() const { return m_x; } float y() const { return m_y; } float width() const { return m_width; } float height() const { return m_height; } float glyphSize() const { return m_glyphSize; } void setGlyphSize(float glyphSize); void setDragEnabled(bool enabled) { m_dragEnabled = enabled; } bool isDragEnabled() const { return m_dragEnabled; } 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(); 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 updateGlyphs(QSGNode *node); // void updateBrush(QSGNode *node); // Data arma::mat m_xy; arma::vec m_colorData; arma::vec m_opacityData; // Visuals float m_x, m_y, 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; Point2D m_dragOriginPos, m_dragCurrentPos; bool m_shouldUpdateGeometry, m_shouldUpdateMaterials; std::unique_ptr m_quadtree; void updateQuadTree(); }; #endif // SCATTERPLOT_H