diff options
author | Samuel Fadel <samuel@nihil.ws> | 2023-05-23 11:22:33 +0200 |
---|---|---|
committer | Samuel Fadel <samuel@nihil.ws> | 2023-05-23 11:22:33 +0200 |
commit | 0f34fd437efb936ef29ac91186321aa7251fbfb1 (patch) | |
tree | 271e994828f4bb19c35b2630f2705cb64b8d4552 /scatterplot.h | |
parent | bedf6936885694688ddb8bd3452f6bd68ef8d29c (diff) |
Massive changes in initial port away from Qt.
Diffstat (limited to 'scatterplot.h')
-rw-r--r-- | scatterplot.h | 72 |
1 files changed, 35 insertions, 37 deletions
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 <memory> #include <vector> -#include <QtQuick> - #include <armadillo> +#include <nod.hpp> #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<const ColorScale> 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<bool> &selection) const; - void selectionInteractivelyChanged(const std::vector<bool> &selection) const; - void itemBrushed(int item) const; - void itemInteractivelyBrushed(int item) const; - void scaleChanged(const LinearScale<float> &sx, const LinearScale<float> &sy) const; - void glyphSizeChanged(float glyphSize) const; - -public slots: + nod::signal<void(const arma::mat &)> xyChanged, xyInteractivelyChanged; + nod::signal<void(const arma::vec &)> colorDataChanged, opacityDataChanged; + nod::signal<void(const std::vector<bool> &)> selectionChanged, selectionInteractivelyChanged; + nod::signal<void(int)> itemBrushed, itemInteractivelyBrushed; + nod::signal<void(const LinearScale<float> &, const LinearScale<float> &)> scaleChanged; + nod::signal<void(float)> glyphSizeChanged; + void setXY(const arma::mat &xy); void setColorData(const arma::vec &colorData); void setOpacityData(const arma::vec &opacityData); void setScale(const LinearScale<float> &sx, const LinearScale<float> &sy); void setSelection(const std::vector<bool> &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<const ColorScale> 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<QuadTree> m_quadtree; void updateQuadTree(); }; |