Box CreateBox(RecordContext& context) { // Get the clicked point in scenario and create a state + interval + state // there // Create an automation + a rack + a slot + process views for all // automations. auto default_end_date = context.point.date; auto cmd_start = new Scenario::Command::CreateTimeSync_Event_State{ context.scenario, default_end_date, context.point.y}; cmd_start->redo(context.context); context.dispatcher.submit(cmd_start); // TODO what happens if we go past the end of our scenario ? Stop recording // ?? auto cmd_end = new Scenario::Command::CreateInterval_State_Event_TimeSync{ context.scenario, cmd_start->createdState(), default_end_date, context.point.y}; cmd_end->redo(context.context); context.dispatcher.submit(cmd_end); auto& cstr = context.scenario.intervals.at(cmd_end->createdInterval()); auto cmd_move = new Scenario::Command::MoveNewEvent( context.scenario, cstr.id(), cmd_end->createdEvent(), default_end_date, 0, true, ExpandMode::CannotExpand); context.dispatcher.submit(cmd_move); auto cmd_slot = new Scenario::Command::AddSlotToRack{cstr}; cmd_slot->redo(context.context); context.dispatcher.submit(cmd_slot); auto cmd_showrack = new Scenario::Command::ShowRack{cstr}; cmd_showrack->redo(context.context); context.dispatcher.submit(cmd_showrack); return {cstr, *cmd_move, cmd_end->createdEvent()}; }
void CreationState::createToTimeNode_base(const Id<StateModel> & originalState) { // make sure the hovered corresponding timenode dont have a date prior to original state date if(getDate(m_parentSM.model(), originalState) < getDate(m_parentSM.model(), hoveredTimeNode) ) { auto cmd = new CreateConstraint_State_Event{ m_scenarioPath, originalState, hoveredTimeNode, currentPoint.y}; m_dispatcher.submitCommand(cmd); createdStates.append(cmd->createdState()); createdEvents.append(cmd->createdEvent()); createdConstraints.append(cmd->createdConstraint()); } }