NDEVR
API Documentation
NDEVRChart.h
1#pragma once
2#include "DLLInfo.h"
3#include <NDEVR/String.h>
4#include <NDEVR/Unit.h>
5#include <NDEVR/Pointer.h>
6#include <NDEVR/Polyline.h>
7#include <QChartView>
8class QValueAxis;
9class QChart;
10class QPolarChart;
11namespace NDEVR
12{
16 class NDEVR_CHARTS_API NDEVRChart : public QChartView
17 {
18 Q_OBJECT
19 public:
20 struct PlotData
21 {
22 TranslatedString value;
23 Polyline<3, fltp08> line_data;
24 Buffer<Vertex<3, fltp08>> point_data;
25 QPen pen;
26
27 bool operator==(const PlotData& plot_data) const
28 {
29 return value == plot_data.value && line_data == plot_data.line_data && point_data == plot_data.point_data;
30 }
31 };
32 NDEVRChart(QWidget* parent = nullptr);
33 NDEVRChart(QChart* chart, QWidget* parent = nullptr);
34 bool event(QEvent* event) override;
35 void setSideAxes(const StringView& x_name, const StringView& y_name);
36 void setDarkThemed(bool dark);
37 void setTitle(const TranslatedString& title);
38 void addData(const PlotData& value);
39 void setData(const PlotData& value);
40 void setData(const Buffer<PlotData>& value);
41 void setLockedAxes(bool locked_axes) { m_locked_axes = locked_axes; }
42 void setPointSize(fltp04 point_size) { m_point_size = point_size; }
43 void setLineSize(fltp04 line_size) { m_line_size = line_size; }
44 void updateAxisScale(Bounds<3, fltp08> override_bounds = Constant<Bounds<3, fltp08>>::Invalid);
45 void clearAll();
46 void redrawPlots();
47 const ConstPointer<Unit>& coordinateUnit() { return m_coordinate_unit; }
48 const ConstPointer<Unit>& hUnit() { return m_unit[X]; }
49 const ConstPointer<Unit>& vUnit() { return m_unit[Y]; }
50 void setUnit(const ConstPointer<Unit>& unit);
51 void setHUnit(const ConstPointer<Unit>& unit);
52 void setVUnit(const ConstPointer<Unit>& unit);
53 void setRelativeVertex(const Vertex<3, fltp08>& relative_vertex);
54 virtual void prepareAxes();
55 virtual Vertex<3, fltp08> positionToWorldSpace(const QPointF& point) const;
56 void mouseMoveEvent(QMouseEvent* event) override;
57 void mousePressEvent(QMouseEvent* event) override;
58 void mouseReleaseEvent(QMouseEvent* event) override;
59 Bounds<3, fltp08> resolvedBounds(Bounds<3, fltp08> override_bounds = Constant<Bounds<3, fltp08>>::Invalid) const;
60 signals:
61 void onHoveredSignal(Vertex<3, fltp08> vertex);
62 void onPressedSignal(Vertex<3, fltp08> vertex);
63 void onReleasedSignal(Vertex<3, fltp08> vertex);
64 void onSeriesHoveredSignal(const PlotData& plot_data, Vertex<3, fltp08> vertex, bool hovered);
65 void onSeriesClickedSignal(const PlotData& plot_data, Vertex<3, fltp08> vertex);
66 protected slots:
67 void onSeriesHoveredSlot(uint04 index, const QPointF& point, bool state);
68 void onSeriesClickedSlot(uint04 index, const QPointF& point);
69 protected:
70 virtual void plotData(uint04 index);
71 void init();
72 void fontChanged();
73 fltp04 getDefaultMarkerSize() const;
74 fltp04 getDefaultLineSize() const;
75 fltp04 getLineSize() const;
76 fltp04 getMarkerSize() const;
77 protected:
78 fltp04 m_point_size;
79 fltp04 m_line_size;
80 QChart* m_base_chart;
81 bool m_is_dark = true;
82 bool m_locked_axes = true;
83 ConstPointer<Unit> m_coordinate_unit;
84 ConstPointer<Unit> m_unit[2];
85 Vertex<3, fltp08> m_relative_vertex;
86 Bounds<3, fltp08> m_bounds;
88 Buffer<PlotData> m_plot_data;
89 };
90
94 class NDEVR_CHARTS_API NDEVRRadialChart : public NDEVRChart
95 {
96 public:
97 NDEVRRadialChart(QWidget* parent = nullptr);
98 protected:
99 Vertex<3, fltp08> positionToWorldSpace(const QPointF& point) const override;
100 void plotData(uint04 index) override;
101 void prepareAxes() override;
102 protected:
103 QValueAxis* m_radial_axis;
104 QValueAxis* m_angular_axis;
105 QPolarChart* m_chart;
106 Matrix<fltp08> m_transform;
107 };
108}
A specification of upper and lower bounds in N-dimensions.
Definition Bounds.hpp:54
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
Provides a constant, unmodifiable pointer that has shared ownership of a dynamically allocated object...
Definition Pointer.hpp:276
Templated logic for doing matrix multiplication.
Definition Matrix.hpp:182
A sequence of connected line segments defined by ordered vertices along a path.
Definition PolyLine.hpp:55
The core String View class for the NDEVR API.
Definition StringView.h:58
Any text displayed to the user should be defined as a TranslatedString which allows the program to lo...
A point in N-dimensional space, used primarily for spatial location information.
Definition Vertex.hpp:44
The primary namespace for the NDEVR SDK.
float fltp04
Defines an alias representing a 4 byte floating-point number Bit layout is as follows: -Sign: 1 bit a...
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Defines for a given type (such as sint04, fltp08, UUID, etc) a maximum, minimum, and reserved 'invali...