Loading...
Searching...
No Matches
ScenarioView.hpp
1#pragma once
2#include <Process/LayerView.hpp>
3
4#include <Scenario/Document/ScenarioDocument/ScenarioDocumentViewConstants.hpp>
5
6#include <score/tools/std/Optional.hpp>
7#include <score/widgets/MimeData.hpp>
8
9#include <QPoint>
10#include <QRect>
11
12#include <score_plugin_scenario_export.h>
13
14#include <verdigris>
15namespace Scenario
16{
17class ProcessModel;
18class ScenarioPresenter;
19
20class ScenarioView final : public Process::LayerView
21{
22public:
23 ScenarioView(QGraphicsItem* parent);
25 static const constexpr int Type = ItemType::ScenarioProcess;
26 int type() const final override { return Type; }
27
28 void init(ScenarioPresenter* p) { m_scenario = p; }
29
30 void paint_impl(QPainter* painter) const override;
31
32 void setSelectionArea(const QRectF& rect)
33 {
34 m_selectArea = rect;
35 update();
36 }
37
38 void drawDragLine(QPointF, QPointF, const QString&);
39 void stopDrawDragLine();
40
41public:
42 void lock()
43 {
44 m_lock = true;
45 update();
46 }
47 void unlock()
48 {
49 m_lock = false;
50 update();
51 }
52
53 void pressedAsked(const QPointF& p)
54 {
55 m_previousPoint = p;
56 pressed(p);
57 }
58 void movedAsked(const QPointF& p);
59
60 void setSnapLine(std::optional<double>);
61
62protected:
63 void mousePressEvent(QGraphicsSceneMouseEvent* event) override;
64 void mouseMoveEvent(QGraphicsSceneMouseEvent* event) override;
65 void mouseReleaseEvent(QGraphicsSceneMouseEvent* event) override;
66 void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event) override;
67
68 void keyPressEvent(QKeyEvent* event) override;
69 void keyReleaseEvent(QKeyEvent* event) override;
70
71 void dragEnterEvent(QGraphicsSceneDragDropEvent* event) override;
72 void dragMoveEvent(QGraphicsSceneDragDropEvent* event) override;
73 void dragLeaveEvent(QGraphicsSceneDragDropEvent* event) override;
74 void dropEvent(QGraphicsSceneDragDropEvent* event) override;
75
76private:
77 ScenarioPresenter* m_scenario{};
78 QRectF m_selectArea{};
79 QPointF m_previousPoint{};
80 std::optional<QRectF> m_dragLine{};
81 std::optional<double> m_snapLine{};
82 QString m_dragText;
83 bool m_lock{};
84 bool m_moving{};
85};
86}
Definition LayerView.hpp:21
Definition ScenarioPresenter.hpp:29
Definition ScenarioView.hpp:21
Main plug-in of score.
Definition score-plugin-dataflow/Dataflow/PortItem.hpp:13