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 /barchart.h | |
parent | bedf6936885694688ddb8bd3452f6bd68ef8d29c (diff) |
Massive changes in initial port away from Qt.
Diffstat (limited to 'barchart.h')
-rw-r--r-- | barchart.h | 75 |
1 files changed, 38 insertions, 37 deletions
@@ -1,80 +1,81 @@ #ifndef BARCHART_H #define BARCHART_H +#include <memory> #include <vector> -#include <QtQuick> - #include <armadillo> +#include <nod.hpp> #include "colorscale.h" #include "scale.h" class BarChart - : public QQuickItem { - Q_OBJECT public: - BarChart(QQuickItem *parent = 0); - ~BarChart(); - -signals: - void valuesChanged(const arma::vec &values) const; - void colorScaleChanged(const ColorScale *scale) const; - void selectionChanged(const std::vector<bool> &selection) const; - void selectionInteractivelyChanged(const std::vector<bool> &selection) const; - void itemBrushed(int item, float value) const; - void itemInteractivelyBrushed(int item) const; - -public slots: + BarChart(); + + size_t width() const { return m_width; } + size_t height() const { return m_height; } + + nod::signal<void(const arma::vec &)> valuesChanged; + nod::signal<void(std::shared_ptr<const ColorScale>)> colorScaleChanged; + nod::signal<void(const std::vector<bool> &)> selectionChanged; + nod::signal<void(const std::vector<bool> &)> selectionInteractivelyChanged; + nod::signal<void(int, float)> itemBrushed; + nod::signal<void(int)> itemInteractivelyBrushed; + void setValues(const arma::vec &values); void updateValues(const arma::vec &values); - void setColorScale(const ColorScale *scale); + void setColorScale(std::shared_ptr<const ColorScale> scale); void setSelection(const std::vector<bool> &selection); void brushItem(int item); + void update(); + protected: - QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *); + // QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *); - void hoverEnterEvent(QHoverEvent *event); - void hoverMoveEvent(QHoverEvent *event); - void hoverLeaveEvent(QHoverEvent *event); + // void hoverEnterEvent(QHoverEvent *event); + // void hoverMoveEvent(QHoverEvent *event); + // void hoverLeaveEvent(QHoverEvent *event); - void mousePressEvent(QMouseEvent *event); - void mouseMoveEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); + // void mousePressEvent(QMouseEvent *event); + // void mouseMoveEvent(QMouseEvent *event); + // void mouseReleaseEvent(QMouseEvent *event); private: - QSGNode *newSceneGraph() const; - QSGNode *newBarNode() const; - QSGNode *newSelectionBarNode() const; - - void updateViewport(QSGNode *root) const; - void updateBarNodeGeom(QSGNode *barNode, float x, float width, float height) const; - void updateBarNodeColor(QSGNode *barNode, const QColor &color) const; - void updateBars(QSGNode *node) const; + // QSGNode *newSceneGraph() const; + // QSGNode *newBarNode() const; + // QSGNode *newSelectionBarNode() const; + + // void updateViewport(QSGNode *root) const; + // void updateBarNodeGeom(QSGNode *barNode, float x, float width, float height) const; + // void updateBarNodeColor(QSGNode *barNode, const QColor &color) const; + // void updateBars(QSGNode *node) const; bool m_shouldUpdateBars; - void updatePreSelection(QSGNode *node) const; + // void updatePreSelection(QSGNode *node) const; bool m_shouldUpdatePreSelection; float m_dragStartPos, m_dragLastPos; - void updateSelectionBar(QSGNode *node, float x, float barWidth, const QColor &color) const; - void updateSelectionBars(QSGNode *node) const; + // void updateSelectionBar(QSGNode *node, float x, float barWidth, const QColor &color) const; + // void updateSelectionBars(QSGNode *node) const; bool m_shouldUpdateSelection; void interactiveSelection(float start, float end); std::vector<bool> m_selection; - void updateBrush(QSGNode *node) const; + // void updateBrush(QSGNode *node) const; int m_brushedItem; int itemAt(float x, bool includeSelectorWidth = false) const; arma::vec m_values; - const ColorScale *m_colorScale; + std::shared_ptr<const ColorScale> m_colorScale; std::vector<int> m_originalIndices, m_currentIndices; LinearScale<float> m_scale; + size_t m_width, m_height; }; #endif // BARCHART_H |