Loading...
Searching...
No Matches
CurveView.hpp
1#pragma once
2
3#include <QGraphicsItem>
4#include <QPoint>
5#include <QRect>
6
7#include <score_plugin_curve_export.h>
8
9#include <Curve/Envelope.hpp>
10
11#include <verdigris>
12
13class QGraphicsSceneContextMenuEvent;
14class QGraphicsSimpleTextItem;
15class QGraphicsSceneMouseEvent;
16class QKeyEvent;
17class QPainter;
18class QStyleOptionGraphicsItem;
19class QWidget;
20
21namespace Curve
22{
23class Presenter;
24class Model;
25class SCORE_PLUGIN_CURVE_EXPORT View final
26 : public QObject
27 , public QGraphicsItem
28{
29 W_OBJECT(View)
30 Q_INTERFACES(QGraphicsItem)
31public:
32 explicit View(QGraphicsItem* parent) noexcept;
33 ~View() override;
34
35 void setModel(const Curve::Presenter* p, const Curve::Model* m) noexcept;
36 void setDirectDraw(bool) noexcept;
37 bool directDraw() const noexcept { return m_directDraw; }
38 void setDefaultWidth(double w) noexcept;
39 void setRect(const QRectF& theRect) noexcept;
40 QRectF boundingRect() const override;
41
42 void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
43 override;
44
45 void setSelectionArea(const QRectF&) noexcept;
46 QPixmap pixmap() noexcept;
47
48 void setValueTooltip(QPointF pos, const QString&) noexcept;
49
50public:
51 void pressed(QPointF arg_1) E_SIGNAL(SCORE_PLUGIN_CURVE_EXPORT, pressed, arg_1)
52 void moved(QPointF arg_1) E_SIGNAL(SCORE_PLUGIN_CURVE_EXPORT, moved, arg_1)
53 void released(QPointF arg_1) E_SIGNAL(SCORE_PLUGIN_CURVE_EXPORT, released, arg_1)
54 void doubleClick(QPointF arg_1) E_SIGNAL(SCORE_PLUGIN_CURVE_EXPORT, doubleClick, arg_1)
55
56 void escPressed() E_SIGNAL(SCORE_PLUGIN_CURVE_EXPORT, escPressed)
57
58 void keyPressed(int arg_1) E_SIGNAL(SCORE_PLUGIN_CURVE_EXPORT, keyPressed, arg_1)
59 void keyReleased(int arg_1) E_SIGNAL(SCORE_PLUGIN_CURVE_EXPORT, keyReleased, arg_1)
60
61 void contextMenuRequested(const QPoint& arg_1, const QPointF& arg_2)
62 E_SIGNAL(SCORE_PLUGIN_CURVE_EXPORT, contextMenuRequested, arg_1, arg_2)
63
64private:
65 void mousePressEvent(QGraphicsSceneMouseEvent* event) override;
66 void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event) override;
67 void mouseMoveEvent(QGraphicsSceneMouseEvent* event) override;
68 void mouseReleaseEvent(QGraphicsSceneMouseEvent* event) override;
69 bool sceneEvent(QEvent* event) override;
70
71 void keyPressEvent(QKeyEvent* ev) override;
72 void keyReleaseEvent(QKeyEvent* ev) override;
73
74 void contextMenuEvent(QGraphicsSceneContextMenuEvent*) override;
75
76 void drawEnvelope(QPainter& painter, QRectF exposed);
77
78 const Curve::Presenter* m_presenter{};
79 const Curve::Model* m_model{};
80 // Of the model's points, rebuilt on the next paint after a change.
81 MinMaxPyramid m_pyramid;
82 // Their abscissas, contiguous: searched on every paint.
83 ossia::pod_vector<double> m_xs;
84 bool m_pyramidDirty{true};
85 QRectF m_rect; // The rect in which the whole curve must fit.
86 QRectF m_selectArea;
87 QPointF m_tooltipPos;
88 QString m_tooltip;
89 QGraphicsSimpleTextItem* m_tooltipItem{};
90 double m_defaultW{};
91 bool m_directDraw{false};
92 bool m_pressed{false};
93 QPointF m_lastScenePos;
94};
95}
Definition score-plugin-curve/Curve/Envelope.hpp:21
Definition CurveModel.hpp:26
Definition CurvePresenter.hpp:34
Definition CurveView.hpp:28
Utilities and base classes for 1D curves.
Definition FocusDispatcher.hpp:12