2 #include "ScenarioToolState.hpp"
4 #include <Scenario/Document/Event/EventModel.hpp>
5 #include <Scenario/Document/Event/EventPresenter.hpp>
6 #include <Scenario/Document/Event/EventView.hpp>
7 #include <Scenario/Document/TimeSync/TimeSyncModel.hpp>
8 #include <Scenario/Document/TimeSync/TimeSyncPresenter.hpp>
9 #include <Scenario/Document/TimeSync/TimeSyncView.hpp>
10 #include <Scenario/Palette/ScenarioPaletteBaseStates.hpp>
11 #include <Scenario/Palette/Tools/ScenarioToolState.hpp>
12 #include <Scenario/Palette/Tools/States/ScenarioCreation_FromEvent.hpp>
13 #include <Scenario/Palette/Tools/States/ScenarioCreation_FromNothing.hpp>
14 #include <Scenario/Palette/Tools/States/ScenarioCreation_FromState.hpp>
15 #include <Scenario/Palette/Tools/States/ScenarioCreation_FromTimeSync.hpp>
16 #include <Scenario/Palette/Transitions/EventTransitions.hpp>
17 #include <Scenario/Palette/Transitions/NothingTransitions.hpp>
18 #include <Scenario/Palette/Transitions/StateTransitions.hpp>
19 #include <Scenario/Palette/Transitions/TimeSyncTransitions.hpp>
21 #include <score/document/DocumentInterface.hpp>
22 #include <score/statemachine/StateMachineTools.hpp>
27 template <
typename Scenario_T,
typename ToolPalette_T>
34 m_waitState =
new QState;
35 this->localSM().addState(m_waitState);
36 this->localSM().setInitialState(m_waitState);
40 this->m_palette, this->m_palette.model(),
41 this->m_palette.context().context.commandStack,
nullptr};
43 score::make_transition<ClickOnNothing_Transition<Scenario_T>>(
44 m_waitState, m_createFromNothingState, *m_createFromNothingState);
45 m_createFromNothingState->addTransition(
46 m_createFromNothingState, finishedState(), m_waitState);
48 this->localSM().addState(m_createFromNothingState);
52 this->m_palette, this->m_palette.model(),
53 this->m_palette.context().context.commandStack,
nullptr};
55 score::make_transition<ClickOnEvent_Transition<Scenario_T>>(
56 m_waitState, m_createFromEventState, *m_createFromEventState);
57 m_createFromEventState->addTransition(
58 m_createFromEventState, finishedState(), m_waitState);
60 this->localSM().addState(m_createFromEventState);
64 this->m_palette, this->m_palette.model(),
65 this->m_palette.context().context.commandStack,
nullptr};
67 score::make_transition<ClickOnTimeSync_Transition<Scenario_T>>(
68 m_waitState, m_createFromTimeSyncState, *m_createFromTimeSyncState);
69 m_createFromTimeSyncState->addTransition(
70 m_createFromTimeSyncState, finishedState(), m_waitState);
72 this->localSM().addState(m_createFromTimeSyncState);
76 this->m_palette, this->m_palette.model(),
77 this->m_palette.context().context.commandStack,
nullptr};
79 score::make_transition<ClickOnState_Transition<Scenario_T>>(
80 m_waitState, m_createFromStateState, *m_createFromStateState);
82 m_createFromStateState->addTransition(
83 m_createFromStateState, finishedState(), m_waitState);
85 this->localSM().addState(m_createFromStateState);
87 this->localSM().start();
93 this->itemUnderMouse(scene),
124 if(
auto state = furthestSelectedState(this->m_palette.model()))
126 if(this->m_palette.model().events.at(state->eventId()).date() < sp.date)
138 if(
auto cs = currentState())
151 cs->createdStates, cs->createdEvents, cs->createdTimeSyncs);
156 if(
auto cs = currentState())
169 cs->createdStates, cs->createdEvents, cs->createdTimeSyncs);
176 QList<Id<StateModel>>
177 getCollidingStates(QPointF point,
const QVector<
Id<StateModel>>& createdStates)
179 return getCollidingModels(
180 this->m_palette.presenter().getStates(), createdStates, point);
182 QList<Id<EventModel>>
183 getCollidingEvents(QPointF point,
const QVector<
Id<EventModel>>& createdEvents)
185 return getCollidingModels(
186 this->m_palette.presenter().getEvents(), createdEvents, point);
188 QList<Id<TimeSyncModel>> getCollidingTimeSyncs(
191 return getCollidingModels(
192 this->m_palette.presenter().getTimeSyncs(), createdTimeSyncs, point);
197 if(isStateActive(m_createFromEventState))
198 return m_createFromEventState;
199 else if(isStateActive(m_createFromNothingState))
200 return m_createFromNothingState;
201 else if(isStateActive(m_createFromStateState))
202 return m_createFromStateState;
203 else if(isStateActive(m_createFromTimeSyncState))
204 return m_createFromTimeSyncState;
210 typename StateFun,
typename EventFun,
typename TimeSyncFun,
typename NothingFun>
211 void mapWithCollision(
212 QPointF point, StateFun st_fun, EventFun ev_fun, TimeSyncFun tn_fun,
213 NothingFun nothing_fun,
const QVector<
Id<StateModel>>& createdStates,
217 auto collidingStates = getCollidingStates(point, createdStates);
218 if(!collidingStates.empty())
220 st_fun(collidingStates.first());
224 auto collidingEvents = getCollidingEvents(point, createdEvents);
225 if(!collidingEvents.empty())
227 ev_fun(collidingEvents.first());
231 auto collidingTimeSyncs = getCollidingTimeSyncs(point, createdTimeSyncs);
232 if(!collidingTimeSyncs.empty())
234 tn_fun(collidingTimeSyncs.first());
245 QState* m_waitState{};
Definition: ScenarioCreation_FromEvent.hpp:22
Definition: ScenarioCreation_FromNothing.hpp:23
Definition: ScenarioCreation_FromState.hpp:26
Definition: ScenarioCreation_FromTimeSync.hpp:22
Definition: ScenarioCreationState.hpp:66
The id_base_t class.
Definition: Identifier.hpp:57
Main plug-in of score.
Definition: score-plugin-dataflow/Dataflow/PortItem.hpp:14
Definition: ScenarioPoint.hpp:13
Definition: ScenarioPaletteBaseEvents.hpp:43
Definition: ScenarioPaletteBaseEvents.hpp:53