コード例 #1
0
void ScenarioCreate<EventModel>::undo(
    const Id<EventModel>& id,
    ScenarioModel& s)
{
    auto& ev = s.event(id);
    s.timeNode(ev.timeNode()).removeEvent(id);
    s.events.remove(&ev);
}
コード例 #2
0
void ScenarioCreate<StateModel>::undo(
    const Id<StateModel> &id,
    ScenarioModel &s)
{
    auto& state = s.state(id);
    auto& ev = s.event(state.eventId());

    ev.removeState(id);

    s.states.remove(&state);
}
コード例 #3
0
    void updatePositions(
            ScenarioModel& scenario,
            const QVector<id_type<TimeNodeModel> >& translatedTimeNodes,
            const TimeValue& deltaTime,
            ProcessScaleMethod&& scaleMethod)
    {
        for (const auto& timeNode_id : translatedTimeNodes)
        {
            auto& timeNode = scenario.timeNode(timeNode_id);
            timeNode.setDate(timeNode.date() + deltaTime);
            for (const auto& event : timeNode.events())
            {
                scenario.event(event).setDate(timeNode.date());
            }
        }

        for(const auto& constraint : scenario.constraints())
        {
            const auto& startDate = scenario.event(scenario.state(constraint->startState()).eventId()).date();
            const auto& endDate = scenario.event(scenario.state(constraint->endState()).eventId()).date();

            TimeValue newDuration = endDate - startDate;

            if (!(constraint->startDate() - startDate).isZero())
            {
                constraint->setStartDate(startDate);
            }

            if(!(constraint->defaultDuration() - newDuration).isZero())
            {
                ConstraintModel::Algorithms::setDurationInBounds(*constraint, newDuration);
                for(const auto& process : constraint->processes())
                {
                    scaleMethod(process, newDuration);
                }
            }

            emit scenario.constraintMoved(constraint->id());
        }
    }