25 const ToolPalette_T& stateMachine,
const Scenario_T& scenarioPath,
28 stateMachine, stack, std::move(scenarioPath), parent}
30 using namespace Scenario::Command;
31 auto finalState =
new QFinalState{
this};
32 QObject::connect(finalState, &QState::entered, [&]() { this->clearCreatedIds(); });
34 auto mainState =
new QState{
this};
35 mainState->setObjectName(
"Main state");
37 auto pressed =
new QState{mainState};
38 auto released =
new QState{mainState};
44 pressed->setObjectName(
"Pressed");
45 released->setObjectName(
"Released");
46 move_nothing->setObjectName(
"Move on Nothing");
47 move_state->setObjectName(
"Move on State");
48 move_event->setObjectName(
"Move on Event");
49 move_timesync->setObjectName(
"Move on Sync");
52 mainState->setInitialState(pressed);
53 released->addTransition(finalState);
56 score::make_transition<ReleaseOnAnything_Transition>(mainState, released);
59 score::make_transition<MoveOnNothing_Transition<Scenario_T>>(
60 pressed, move_nothing, *
this);
64 score::make_transition<MoveOnNothing_Transition<Scenario_T>>(
65 move_nothing, move_nothing, *
this);
68 this->add_transition(move_nothing, move_state, [&]() {
74 this->add_transition(move_nothing, move_event, [&]() {
80 this->add_transition(move_nothing, move_timesync, [&]() {
87 this->add_transition(move_state, move_nothing, [&]() {
96 this->add_transition(move_state, move_event, [&]() {
102 this->add_transition(move_state, move_timesync, [&]() {
109 this->add_transition(move_event, move_nothing, [&]() {
115 this->add_transition(move_event, move_state, [&]() {
121 score::make_transition<MoveOnEvent_Transition<Scenario_T>>(
122 move_event, move_event, *
this);
125 this->add_transition(move_event, move_timesync, [&]() {
132 this->add_transition(move_timesync, move_nothing, [&]() {
138 this->add_transition(move_timesync, move_state, [&]() {
144 this->add_transition(move_timesync, move_event, [&]() {
150 score::make_transition<MoveOnTimeSync_Transition<Scenario_T>>(
151 move_timesync, move_timesync, *
this);
154 QObject::connect(pressed, &QState::entered, [&]() {
155 this->m_clickedPoint = this->currentPoint;
158 createInitialState();
162 QObject::connect(move_nothing, &QState::entered, [&]() {
163 if(this->createdIntervals.empty() || this->createdEvents.empty())
169 if(this->currentPoint.date <= this->m_clickedPoint.date)
171 this->currentPoint.date = this->m_clickedPoint.date + TimeVal::fromMsecs(10);
175 this->currentPoint.date = stateMachine.magnetic().getPosition(
176 &stateMachine.model(), this->currentPoint.date);
178 this->m_dispatcher.template submit<MoveNewEvent>(
179 this->m_scenario, this->createdIntervals.last(), this->createdEvents.last(),
180 this->currentPoint.date, this->currentPoint.y,
181 stateMachine.editionSettings().tool() == Tool::CreateSequence);
184 QObject::connect(move_timesync, &QState::entered, [&]() {
185 if(this->createdStates.empty())
191 if(this->currentPoint.date <= this->m_clickedPoint.date)
196 this->m_dispatcher.template submit<MoveNewState>(
197 this->m_scenario, this->createdStates.last(), this->currentPoint.y);
200 QObject::connect(move_event, &QState::entered, [&]() {
201 if(this->createdStates.empty())
207 if(this->currentPoint.date <= this->m_clickedPoint.date)
212 this->m_dispatcher.template submit<MoveNewState>(
213 this->m_scenario, this->createdStates.last(), this->currentPoint.y);
216 QObject::connect(released, &QState::entered,
this, &Creation_FromEvent::commit);
219 auto rollbackState =
new QState{
this};
220 rollbackState->setObjectName(
"Rollback");
221 score::make_transition<score::Cancel_Transition>(mainState, rollbackState);
222 rollbackState->addTransition(finalState);
224 rollbackState, &QState::entered,
this, &Creation_FromEvent::rollback);
226 this->setInitialState(mainState);