29 const ToolPalette_T& stateMachine,
const Scenario_T& scenarioPath,
32 stateMachine, stack, std::move(scenarioPath), parent}
34 using namespace Scenario::Command;
35 auto finalState =
new QFinalState{
this};
36 QObject::connect(finalState, &QState::entered, [&]() { this->clearCreatedIds(); });
38 auto mainState =
new QState{
this};
40 auto pressed =
new QState{mainState};
41 auto released =
new QState{mainState};
48 mainState->setInitialState(pressed);
49 released->addTransition(finalState);
52 score::make_transition<ReleaseOnAnything_Transition>(mainState, released);
55 score::make_transition<MoveOnNothing_Transition<Scenario_T>>(
56 pressed, move_state, *
this);
57 score::make_transition<MoveOnNothing_Transition<Scenario_T>>(
58 pressed, move_nothing, *
this);
62 score::make_transition<MoveOnNothing_Transition<Scenario_T>>(
63 move_nothing, move_nothing, *
this);
66 this->add_transition(move_nothing, move_state, [&]() {
72 this->add_transition(move_nothing, move_event, [&]() {
78 this->add_transition(move_nothing, move_timesync, [&]() {
85 this->add_transition(move_state, move_nothing, [&]() {
94 this->add_transition(move_state, move_event, [&]() {
100 this->add_transition(move_state, move_timesync, [&]() {
107 this->add_transition(move_event, move_nothing, [&]() {
113 this->add_transition(move_event, move_state, [&]() {
114 if(this->clickedState && this->hoveredState)
116 if(this->m_parentSM.model().state(*this->clickedState).eventId()
117 != this->m_parentSM.model().state(*this->hoveredState).eventId())
126 score::make_transition<MoveOnEvent_Transition<Scenario_T>>(
127 move_event, move_event, *
this);
130 this->add_transition(move_event, move_timesync, [&]() {
137 this->add_transition(move_timesync, move_nothing, [&]() {
143 this->add_transition(move_timesync, move_state, [&]() {
149 this->add_transition(move_timesync, move_event, [&]() {
155 score::make_transition<MoveOnTimeSync_Transition<Scenario_T>>(
156 move_timesync, move_timesync, *
this);
159 QObject::connect(pressed, &QState::entered, [&]() {
160 this->m_clickedPoint = this->currentPoint;
164 QObject::connect(move_nothing, &QState::entered, [&]() {
165 if(this->createdIntervals.empty() || this->createdEvents.empty())
173 if(settings.tool() == Scenario::Tool::CreateGraph)
175 this->m_dispatcher.template submit<MoveNewEvent>(
176 this->m_scenario, this->createdIntervals.last(),
177 this->createdEvents.last(), this->currentPoint.date, this->currentPoint.y,
182 this->currentPoint.date = stateMachine.magnetic().getPosition(
183 &stateMachine.model(), this->currentPoint.date);
185 if(this->currentPoint.date <= this->m_clickedPoint.date)
187 this->currentPoint.date = this->m_clickedPoint.date + TimeVal::fromMsecs(10);
191 auto sequence = settings.tool() == Tool::CreateSequence;
194 if(this->clickedState)
196 const auto& st = this->m_parentSM.model().state(*this->clickedState);
197 this->currentPoint.y = st.heightPercentage();
201 this->m_dispatcher.template submit<MoveNewEvent>(
202 this->m_scenario, this->createdIntervals.last(), this->createdEvents.last(),
203 this->currentPoint.date, this->currentPoint.y, sequence);
206 QObject::connect(move_event, &QState::entered, [&]() {
207 if(this->createdStates.empty())
214 if(this->currentPoint.date <= this->m_clickedPoint.date)
219 this->m_dispatcher.template submit<MoveNewState>(
220 this->m_scenario, this->createdStates.last(), this->currentPoint.y);
223 QObject::connect(move_timesync, &QState::entered, [&]() {
224 if(this->createdStates.empty())
231 if(this->currentPoint.date <= this->m_clickedPoint.date)
236 this->m_dispatcher.template submit<MoveNewState>(
237 this->m_scenario, this->createdStates.last(), this->currentPoint.y);
240 QObject::connect(released, &QState::entered,
this, &Creation_FromState::commit);
243 auto rollbackState =
new QState{
this};
244 score::make_transition<score::Cancel_Transition>(mainState, rollbackState);
245 rollbackState->addTransition(finalState);
248 rollbackState, &QState::entered,
this, &Creation_FromState::rollback);
249 this->setInitialState(mainState);