Loading...
Searching...
No Matches
QGraphicsPathGeneratorXY.hpp
1#pragma once
2#include <score/graphics/widgets/Constants.hpp>
3
4#include <ossia-qt/value_metatypes.hpp>
5
6#include <QGraphicsItem>
7#include <QObject>
8#include <QPainterPath>
9
10#include <score_lib_base_export.h>
11
12#include <verdigris>
13
14#include <halp/value_types.hpp>
15#include <halp/custom_widgets.hpp>
16
17namespace ossia
18{
19
20struct domain;
21}
22namespace score
23{
24template <typename T>
25struct GridWidget;
26struct RightClickImpl;
27class SCORE_LIB_BASE_EXPORT QGraphicsPathGeneratorXY final
28 : public QObject
29 , public QGraphicsItem
30{
32 SCORE_GRAPHICS_ITEM_TYPE(110)
33public:
34 template <typename T>
35 friend struct GridWidget;
36
38 enum Path
39 {
40 Linear,
41 Circle,
42 Spiral,
43 Lissajous,
44 Rose,
45 Polygon
46 };
47
48 std::vector<ossia::value> tab;
49
53 static constexpr QSizeF defaultSize{400., 400.};
54 static constexpr QSizeF minimumSize{60., 60.};
55
56 double width() const noexcept { return m_size.width(); }
57 double height() const noexcept { return m_size.height(); }
58 void setSize(QSizeF sz);
59
60 halp::xy_type<float> cursorSize{0.04, 0.04};
61
62 int selectedCursor{-1};
63 int selectedSource{-1};
64 bool isSelected{};
65
66 double min{0.}, max{1.};
67
68 bool m_grab{};
69 ossia::value m_value{};
70 ossia::value m_execValue{};
71 bool m_hasExec{};
72 bool moving = false;
73 RightClickImpl* impl{};
74
75 QGraphicsPathGeneratorXY(QGraphicsItem* parent);
76
77 void setPoint(const QPointF& r);
78 void setValue(ossia::value v);
79 ossia::value value() const;
80 void setExecutionValue(const ossia::value& v);
81 void setExecutionProgress(double v);
84 void setExecutionPosition(double pos);
85 void resetExecution();
86
89 void setPathMode(int mode);
90 void setRadii(float x, float y);
91 void setRatioX(int r);
92 void setRatioY(int r);
93 void setPhase(float p);
94 void setSpeed(float s);
95 void setPingPong(bool b);
96
97 void setRange(const ossia::value& min, const ossia::value& max);
98 void setRange(const ossia::domain& dom);
99
100public:
101 void sliderMoved() E_SIGNAL(SCORE_LIB_BASE_EXPORT, sliderMoved)
102 void sliderReleased() E_SIGNAL(SCORE_LIB_BASE_EXPORT, sliderReleased)
103
104private:
105 void mousePressEvent(QGraphicsSceneMouseEvent* event) override;
106 void mouseMoveEvent(QGraphicsSceneMouseEvent* event) override;
107 void mouseReleaseEvent(QGraphicsSceneMouseEvent* event) override;
108 bool sceneEvent(QEvent* event) override;
109 QRectF boundingRect() const override;
110 void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
111 override;
112
113 const std::vector<ossia::value>& sources() const noexcept;
114
115public:
118 QPointF pathPoint(const std::vector<ossia::value>& nodes, double u) const noexcept;
119
120private:
121 QRectF progressRect() const noexcept;
122 void recomputePaths();
123 void commitTab();
124
125 QSizeF m_size{defaultSize};
126 std::vector<QPainterPath> m_paths;
127 double m_progress{};
128 double m_position{};
129 bool m_hasProgress{};
130
131 int m_pathMode{Linear};
133 float m_radiusX{1.f}, m_radiusY{1.f};
134 int m_ratioX{3}, m_ratioY{2};
135 float m_phase{};
136 float m_speed{1.f};
137 bool m_pingPong{};
138};
139}
The Path class is a typesafe wrapper around ObjectPath.
Definition Path.hpp:52
Definition QGraphicsPathGeneratorXY.hpp:30
Base toolkit upon which the software is built.
Definition Application.cpp:83
STL namespace.
Definition QGraphicsMultiSliderXY.hpp:24