QGraphicsXYZChooser.hpp
1 #pragma once
2 #include <score/graphics/widgets/Constants.hpp>
3 #include <score/graphics/widgets/QGraphicsSpinbox.hpp>
4 
5 #include <ossia-qt/value_metatypes.hpp>
6 
7 #include <QGraphicsItem>
8 #include <QObject>
9 
10 #include <score_lib_base_export.h>
11 
12 #include <verdigris>
13 
14 namespace score
15 {
16 class SCORE_LIB_BASE_EXPORT QGraphicsXYZChooser final
17  : public QObject
18  , public QGraphicsItem
19 {
20  W_OBJECT(QGraphicsXYZChooser)
21  SCORE_GRAPHICS_ITEM_TYPE(280)
22  QRectF m_rect{0., 0., 140., 100.};
23 
24 private:
25  ossia::vec3f m_value{}, m_min{}, m_max{}, m_init{};
26  float prev_v[3]{};
27  bool m_grab{};
28 
29 public:
30  explicit QGraphicsXYZChooser(QGraphicsItem* parent);
32 
33  void setPoint(const QPointF& r);
34  void setValue(ossia::vec3f v);
35  void setRange(
36  ossia::vec3f min = {0.f, 0.f, 0.f}, ossia::vec3f max = {1.f, 1.f, 1.f},
37  ossia::vec3f init = {});
38  ossia::vec3f value() const;
39 
40  bool moving = false;
41 
42 public:
43  void sliderMoved() E_SIGNAL(SCORE_LIB_BASE_EXPORT, sliderMoved)
44  void sliderReleased() E_SIGNAL(SCORE_LIB_BASE_EXPORT, sliderReleased)
45 
46 private:
47  ossia::vec3f scaledValue(float x, float y, float z) const noexcept;
48  void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event) override;
49  void mousePressEvent(QGraphicsSceneMouseEvent* event) override;
50  void mouseMoveEvent(QGraphicsSceneMouseEvent* event) override;
51  void mouseReleaseEvent(QGraphicsSceneMouseEvent* event) override;
52  QRectF boundingRect() const override;
53  void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
54  override;
55 };
56 }
Definition: QGraphicsXYZChooser.hpp:19
Base toolkit upon which the software is built.
Definition: Application.cpp:90