ConstraintModel& ScenarioCreate<ConstraintModel>::redo( const id_type<ConstraintModel>& id, const id_type<AbstractConstraintViewModel>& fullviewid, StateModel& sst, StateModel& est, double ypos, ScenarioModel& s) { auto constraint = new ConstraintModel { id, fullviewid, ypos, &s}; constraint->setStartState(sst.id()); constraint->setEndState(est.id()); s.addConstraint(constraint); sst.setNextConstraint(id); est.setPreviousConstraint(id); const auto& sev = s.event(sst.eventId()); const auto& eev = s.event(est.eventId()); ConstraintModel::Algorithms::changeAllDurations(*constraint, eev.date() - sev.date()); constraint->setStartDate(sev.date()); return *constraint; }
void DuplicateInterval::redo(const score::DocumentContext& ctx) const { m_cmdStart.redo(ctx); m_cmdEnd.redo(ctx); auto& root = m_path.find(ctx); auto scenar = safe_cast<Scenario::ProcessModel*>(root.parent()); auto obj = score::marshall<DataStream>(root); auto interval = new Scenario::IntervalModel{DataStream::Deserializer{obj}, scenar}; score::IDocument::changeObjectId(*interval, m_createdId); interval->setStartState(m_cmdStart.createdState()); interval->setEndState(m_cmdEnd.createdState()); SetPreviousInterval(scenar->states.at(m_cmdEnd.createdState()), *interval); SetNextInterval(scenar->states.at(m_cmdStart.createdState()), *interval); interval->setHeightPercentage(root.heightPercentage() + 0.1); scenar->intervals.add(interval); }
ConstraintModel& ScenarioCreate<ConstraintModel>::redo( const Id<ConstraintModel>& id, const Id<ConstraintViewModel>& fullviewid, StateModel& sst, StateModel& est, double ypos, ScenarioModel& s) { auto constraint = new ConstraintModel { id, fullviewid, ypos, &s}; constraint->setStartState(sst.id()); constraint->setEndState(est.id()); s.constraints.add(constraint); sst.setNextConstraint(id); est.setPreviousConstraint(id); const auto& sev = s.event(sst.eventId()); const auto& eev = s.event(est.eventId()); const auto& tn = s.timeNode(eev.timeNode()); ConstraintDurations::Algorithms::changeAllDurations(*constraint, eev.date() - sev.date()); constraint->setStartDate(sev.date()); if(tn.trigger()->active()) { constraint->duration.setRigid(false); const auto& dur = constraint->duration.defaultDuration(); constraint->duration.setMinDuration( TimeValue::fromMsecs(0.8 * dur.msec())); constraint->duration.setMaxDuration( TimeValue::fromMsecs(1.2 * dur.msec())); } return *constraint; }