Loading...
Searching...
No Matches
ScenarioPresenter.hpp
1#pragma once
2#include <Process/Focus/FocusDispatcher.hpp>
3#include <Process/LayerPresenter.hpp>
4#include <Process/ProcessContext.hpp>
5#include <Process/ZoomHelper.hpp>
6
7#include <Scenario/Palette/ScenarioPalette.hpp>
8#include <Scenario/PresenterInstantiations.hpp>
9#include <Scenario/Process/ScenarioModel.hpp>
10#include <Scenario/Process/ScenarioViewInterface.hpp>
11
12#include <score/command/Dispatchers/OngoingCommandDispatcher.hpp>
13#include <score/graphics/GraphicsItem.hpp>
14#include <score/model/IdentifiedObjectMap.hpp>
15#include <score/model/Identifier.hpp>
16#include <score/tools/std/Optional.hpp>
17
18#include <verdigris>
19
20namespace Scenario
21{
22
23class EditionSettings;
24class ScenarioView;
25
26class SCORE_PLUGIN_SCENARIO_EXPORT ScenarioPresenter final
28 , public Nano::Observer
29{
30 W_OBJECT(ScenarioPresenter)
31
32 friend class Scenario::ToolPalette;
33 friend class ScenarioViewInterface;
34
35public:
38 Process::LayerView* view, const Process::Context& context, QObject* parent);
40
41 const Scenario::ProcessModel& model() const noexcept;
42
49 Scenario::Point toScenarioPoint(QPointF pt) const noexcept;
50 QPointF fromScenarioPoint(const Scenario::Point& pt) const noexcept;
51
52 void setWidth(qreal width, qreal defaultWidth) override;
53 void setHeight(qreal height) override;
54 void putToFront() override;
55 void putBehind() override;
56
57 void parentGeometryChanged() override;
58
59 void on_zoomRatioChanged(ZoomRatio val) override;
60
61 EventPresenter& event(const Id<EventModel>& id) const;
62 TimeSyncPresenter& timeSync(const Id<TimeSyncModel>& id) const;
63 IntervalPresenter& interval(const Id<IntervalModel>& id) const;
64 StatePresenter& state(const Id<StateModel>& id) const;
65 const auto& comment(const Id<CommentBlockModel>& id) const
66 {
67 return m_comments.at(id);
68 }
69 const auto& getEvents() const { return m_events; }
70 const auto& getTimeSyncs() const { return m_timeSyncs; }
71 const auto& getIntervals() const { return m_intervals; }
72 const auto& getGraphIntervals() const { return m_graphIntervals; }
73 const auto& getStates() const { return m_states; }
74 const auto& getComments() const { return m_comments; }
75
76 ScenarioView& view() const { return *m_view; }
77 const ZoomRatio& zoomRatio() const { return m_zoomRatio; }
78
79 Scenario::ToolPalette& stateMachine() { return m_sm; }
80 Scenario::EditionSettings& editionSettings() const { return m_editionSettings; }
81
82 void setSnapLine(TimeVal t, bool enabled);
83
84 void fillContextMenu(
85 QMenu&, QPoint pos, QPointF scenepos,
86 const Process::LayerContextMenuManager&) override;
87
88 bool event(QEvent* e) override { return QObject::event(e); }
89
90 void drawDragLine(const Scenario::StateModel&, Scenario::Point) const;
91 void stopDrawDragLine() const;
92
93public:
94 void linesExtremityScaled(int arg_1, int arg_2)
95 E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, linesExtremityScaled, arg_1, arg_2)
96
97 void keyPressed(int arg_1) E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, keyPressed, arg_1)
98 void keyReleased(int arg_1) E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, keyReleased, arg_1)
99
100public:
101 // Model -> view
102 void on_stateCreated(const StateModel&);
103 void on_stateRemoved(const StateModel&);
104
105 void on_eventCreated(const EventModel&);
106 void on_eventRemoved(const EventModel&);
107
108 void on_timeSyncCreated(const TimeSyncModel&);
109 void on_timeSyncRemoved(const TimeSyncModel&);
110
111 void on_intervalCreated(const IntervalModel&);
112 void on_intervalRemoved(const IntervalModel&);
113
114 void on_commentCreated(const CommentBlockModel&);
115 void on_commentRemoved(const CommentBlockModel&);
116
117 void on_askUpdate();
118
119 void on_intervalExecutionTimer();
120
121private:
122 void selectLeft();
123 void selectRight();
124 void selectUp();
125 void selectDown();
126
127 void doubleClick(QPointF);
128 void on_focusChanged() override;
129
130 template <typename Map, typename Id>
131 void removeElement(Map& map, const Id& id);
132
133 void updateAllElements();
134
135 ZoomRatio m_zoomRatio{1};
136
137 // The order of deletion matters!
138 // m_view has to be deleted after the other elements.
140
147
148 ScenarioViewInterface m_viewInterface;
149
150 Scenario::EditionSettings& m_editionSettings;
151
152 score::SelectionDispatcher m_selectionDispatcher;
154
155 QMetaObject::Connection m_con;
156};
157
158const StateModel* furthestSelectedState(const Scenario::ProcessModel& scenario);
159const EventModel* furthestSelectedEvent(const Scenario::ScenarioPresenter& scenario);
160const TimeSyncModel* furthestSelectedSync(const Scenario::ScenarioPresenter& scenario);
161
162const StateModel*
163furthestSelectedStateWithoutFollowingInterval(const Scenario::ProcessModel& scenario);
164
165// furthest selected state or event are taken into account
166const TimeSyncModel*
167furthestHierarchicallySelectedTimeSync(const Scenario::ScenarioPresenter& scenario);
168}
A map to access child objects through their id.
Definition IdentifiedObjectMap.hpp:16
Definition LayerContextMenu.hpp:38
Definition LayerPresenter.hpp:34
Definition LayerView.hpp:21
Definition CommentBlockModel.hpp:25
Definition ScenarioEditionSettings.hpp:14
Definition EventModel.hpp:36
Definition EventPresenter.hpp:24
Definition IntervalModel.hpp:50
Definition IntervalPresenter.hpp:30
The core hierarchical and temporal process of score.
Definition ScenarioModel.hpp:37
Definition ScenarioPresenter.hpp:29
Definition ScenarioView.hpp:21
Definition ScenarioViewInterface.hpp:15
Definition StateModel.hpp:63
Definition StatePresenter.hpp:23
Definition TimeSyncModel.hpp:34
Definition TimeSyncPresenter.hpp:29
Definition ScenarioPalette.hpp:38
The id_base_t class.
Definition Identifier.hpp:57
The SelectionDispatcher class.
Definition SelectionDispatcher.hpp:15
Main plug-in of score.
Definition score-plugin-dataflow/Dataflow/PortItem.hpp:13
Definition ProcessContext.hpp:12
Definition ScenarioPoint.hpp:13
Definition TimeValue.hpp:21
Definition GraphicsItem.hpp:47