From 0f34fd437efb936ef29ac91186321aa7251fbfb1 Mon Sep 17 00:00:00 2001 From: Samuel Fadel Date: Tue, 23 May 2023 11:22:33 +0200 Subject: Massive changes in initial port away from Qt. --- scatterplot.h | 72 +++++++++++++++++++++++++++++------------------------------ 1 file changed, 35 insertions(+), 37 deletions(-) (limited to 'scatterplot.h') diff --git a/scatterplot.h b/scatterplot.h index 468ef13..8286b7d 100644 --- a/scatterplot.h +++ b/scatterplot.h @@ -1,74 +1,71 @@ #ifndef SCATTERPLOT_H #define SCATTERPLOT_H +#include #include -#include - #include +#include #include "colorscale.h" +#include "quadtree.h" +#include "geometry.h" #include "scale.h" -class QuadTree; - class Scatterplot - : public QQuickItem { - Q_OBJECT - Q_PROPERTY(float glyphSize READ glyphSize WRITE setGlyphSize NOTIFY glyphSizeChanged) public: static const int PADDING = 20; - Scatterplot(QQuickItem *parent = 0); - virtual ~Scatterplot(); + Scatterplot(); arma::mat XY() const; - void setColorScale(const ColorScale *colorScale); + 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; } -signals: - void xyChanged(const arma::mat &XY) const; - void xyInteractivelyChanged(const arma::mat &XY) const; - void colorDataChanged(const arma::vec &colorData) const; - void opacityDataChanged(const arma::vec &opacityData) const; - void selectionChanged(const std::vector &selection) const; - void selectionInteractivelyChanged(const std::vector &selection) const; - void itemBrushed(int item) const; - void itemInteractivelyBrushed(int item) const; - void scaleChanged(const LinearScale &sx, const LinearScale &sy) const; - void glyphSizeChanged(float glyphSize) const; - -public slots: + 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); + // 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); + // void hoverEnterEvent(QHoverEvent *event); + // void hoverMoveEvent(QHoverEvent *event); + // void hoverLeaveEvent(QHoverEvent *event); private: - QSGNode *newSceneGraph(); - QSGNode *newGlyphTree(); + // QSGNode *newSceneGraph(); + // QSGNode *newGlyphTree(); void applyManipulation(); - void updateGlyphs(QSGNode *node); - void updateBrush(QSGNode *node); + // void updateGlyphs(QSGNode *node); + // void updateBrush(QSGNode *node); // Data arma::mat m_xy; @@ -76,8 +73,9 @@ private: arma::vec m_opacityData; // Visuals + float m_x, m_y, m_width, m_height; float m_glyphSize; - const ColorScale *m_colorScale; + std::shared_ptr m_colorScale; void autoScale(); bool m_autoScale; @@ -98,11 +96,11 @@ private: } m_interactionState; bool m_dragEnabled; - QPointF m_dragOriginPos, m_dragCurrentPos; + Point2D m_dragOriginPos, m_dragCurrentPos; bool m_shouldUpdateGeometry, m_shouldUpdateMaterials; - QuadTree *m_quadtree; + std::unique_ptr m_quadtree; void updateQuadTree(); }; -- cgit v1.2.3