Loading...
Searching...
No Matches
LayerData.hpp
1#pragma once
2#include <Process/ZoomHelper.hpp>
3
4#include <score/graphics/RectItem.hpp>
5
6#include <QPoint>
7#include <QPointF>
8
9#include <vector>
10
11class QPixmap;
12class QMenu;
13class QGraphicsItem;
14class QObject;
15namespace Process
16{
17struct Context;
18class ProcessModel;
19class LayerPresenter;
20class LayerView;
21class LayerFactory;
22class LayerContextMenuManager;
23class GraphicsShapeItem;
24}
25
26namespace Scenario
27{
29{
30public:
31 LayerRectItem(QGraphicsItem* parent);
32
33 void setSize(const QSizeF& r);
34 void setWidth(qreal r);
35 void setHeight(qreal r);
36 QSizeF size() const noexcept;
37
38private:
39 QRectF boundingRect() const override;
40
41 void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
42 override;
43
44 void hoverEnterEvent(QGraphicsSceneHoverEvent* event) override;
45 void hoverLeaveEvent(QGraphicsSceneHoverEvent* event) override;
46 void mousePressEvent(QGraphicsSceneMouseEvent* event) override;
47 void mouseMoveEvent(QGraphicsSceneMouseEvent* event) override;
48 void mouseReleaseEvent(QGraphicsSceneMouseEvent* event) override;
49
50private:
51 QSizeF m_size{};
52};
53
55{
56public:
57 struct Layer
58 {
59 Process::LayerPresenter* presenter{};
60 Scenario::LayerRectItem* container{};
61 Process::LayerView* view{};
62 };
63 LayerData() noexcept = default;
64 LayerData(const LayerData&) = delete;
65 LayerData(LayerData&&) noexcept = default;
66 LayerData& operator=(const LayerData&) = delete;
67 LayerData& operator=(LayerData&&) noexcept = default;
69
70 Process::LayerPresenter* mainPresenter() const noexcept;
71 Process::LayerView* mainView() const noexcept;
72
73 void cleanup();
74 void addView(
75 Process::LayerFactory& factory, ZoomRatio zoomRatio,
76 const Process::Context& context, QGraphicsItem* parentItem, QObject* parent);
77 void setupView(
78 Layer& layer, int idx, qreal parentWidth, qreal parent_default_width, qreal w,
79 qreal h);
80
81 std::size_t count() const noexcept { return m_layers.size(); }
82 void removeView(int i);
83
84 // Presenter API
85 bool focused() const;
86 void setFocus(bool focus) const;
87 void on_focusChanged() const;
88
89 void setFullView() const;
90
91 void setWidth(qreal width, qreal defaultWidth) const;
92 void setHeight(qreal height) const;
93
94 void putToFront() const;
95 void putBehind() const;
96
97 void on_zoomRatioChanged(
98 const Process::Context& lst, ZoomRatio r, qreal parentWidth,
99 qreal parent_default_width, qreal slot_height, QGraphicsItem* parentItem,
100 QObject* parent);
101
102 void updateLoops(
103 const Process::Context& lst, ZoomRatio r, qreal parentWidth,
104 qreal parent_default_width, qreal slot_height, QGraphicsItem* parentItem,
105 QObject* parent);
106
107 void parentGeometryChanged() const;
108
109 void fillContextMenu(
110 QMenu& m, QPoint pos, QPointF scenepos,
111 const Process::LayerContextMenuManager& mgr) const;
112
113 Process::GraphicsShapeItem* makeSlotHeaderDelegate() const;
114
115 // View API
116 /*
117 void updatePositions(qreal y, qreal instancewidth);
118
119 void updateXPositions(qreal instancewidth) const;
120
121 void updateContainerWidths(qreal w) const;
122*/
123 void updateYPositions(qreal y);
124
125 void updateContainerHeights(qreal h) const;
126
127 void updateStartOffset(double x) const;
128
129 void update() const;
130
131 void setZValue(qreal z) const;
132
133 QPixmap pixmap() const noexcept;
134
135 const Process::ProcessModel& model() const noexcept { return *m_model; }
136
137 const std::vector<Layer>& layers() const noexcept { return m_layers; }
138
139 static void disconnect(const Process::ProcessModel& proc, QObject& intervalPresenter);
140
141private:
142 const Process::ProcessModel* m_model{};
143
144 std::vector<Layer> m_layers;
145 qreal m_slotY{};
146};
147
148}
Definition LayerPresenter.hpp:21
Definition LayerContextMenu.hpp:38
Definition LayerPresenter.hpp:34
Definition LayerView.hpp:21
The Process class.
Definition score-lib-process/Process/Process.hpp:61
Definition LayerData.hpp:55
Definition LayerData.hpp:29
The core hierarchical and temporal process of score.
Definition ScenarioModel.hpp:37
Definition RectItem.hpp:12
Base classes and tools to implement processes and layers.
Definition JSONVisitor.hpp:1324
Main plug-in of score.
Definition score-plugin-dataflow/Dataflow/PortItem.hpp:13
STL namespace.
Definition ProcessContext.hpp:12
Definition LayerData.hpp:58