2 #include <Process/ProcessList.hpp>
3 #include <Process/TimeValue.hpp>
5 #include <Scenario/Commands/Scenario/Deletions/ClearInterval.hpp>
6 #include <Scenario/Document/Event/EventModel.hpp>
7 #include <Scenario/Document/Interval/IntervalModel.hpp>
8 #include <Scenario/Document/Interval/Slot.hpp>
9 #include <Scenario/Document/TimeSync/TimeSyncModel.hpp>
10 #include <Scenario/Process/Algorithms/Accessors.hpp>
11 #include <Scenario/Process/Algorithms/ProcessPolicy.hpp>
12 #include <Scenario/Process/Algorithms/StandardCreationPolicy.hpp>
13 #include <Scenario/Process/ScenarioModel.hpp>
14 #include <Scenario/Tools/dataStructures.hpp>
16 #include <score/document/DocumentInterface.hpp>
17 #include <score/model/Identifier.hpp>
18 #include <score/tools/MapCopy.hpp>
30 template <
typename ProcessScaleMethod>
31 static void updatePositions(
36 for(
auto it = propsToUpdate.timesyncs.cbegin(); it != propsToUpdate.timesyncs.cend();
39 auto& curTimenodeToUpdate = scenario.timeSync(it->first);
40 auto& curTimenodePropertiesToUpdate = it->second;
42 curTimenodeToUpdate.setDate(curTimenodePropertiesToUpdate.newDate);
45 for(
const auto& event : curTimenodeToUpdate.events())
47 scenario.events.at(event).setDate(curTimenodePropertiesToUpdate.newDate);
52 for(
auto& e : propsToUpdate.intervals)
54 auto curIntervalPropertiesToUpdate_id = e.first;
56 auto& curInterval = scenario.intervals.at(curIntervalPropertiesToUpdate_id);
57 auto& curIntervalPropertiesToUpdate = e.second;
60 const auto& date = Scenario::startEvent(curInterval, scenario).date();
61 const auto& endDate = Scenario::endEvent(curInterval, scenario).date();
63 TimeVal defaultDuration = endDate - date;
66 using namespace ossia;
67 if(curInterval.date() != date)
69 curInterval.setStartDate(date);
71 curInterval.duration.setDefaultDuration(defaultDuration);
73 curInterval.duration.setMinDuration(curIntervalPropertiesToUpdate.newMin);
74 curInterval.duration.setMaxDuration(curIntervalPropertiesToUpdate.newMax);
76 for(
auto& process : curInterval.processes)
78 scaleMethod(process, defaultDuration);
81 scenario.intervalMoved(&curInterval);
85 template <
typename ProcessScaleMethod>
86 static void revertPositions(
91 for(
auto it = propsToUpdate.timesyncs.cbegin(); it != propsToUpdate.timesyncs.cend();
94 auto& curTimenodeToUpdate = scenario.timeSync(it->first);
95 auto& curTimenodePropertiesToUpdate = it->second;
97 curTimenodeToUpdate.setDate(curTimenodePropertiesToUpdate.oldDate);
100 for(
const auto& event : curTimenodeToUpdate.events())
102 scenario.events.at(event).setDate(curTimenodePropertiesToUpdate.oldDate);
107 for(
auto& e : propsToUpdate.intervals)
109 auto curIntervalPropertiesToUpdate_id = e.first;
111 auto& curInterval = scenario.intervals.at(curIntervalPropertiesToUpdate_id);
115 const auto& date = Scenario::startEvent(curInterval, scenario).date();
116 const auto& endDate = Scenario::endEvent(curInterval, scenario).date();
118 TimeVal defaultDuration = endDate - date;
120 SCORE_ASSERT(defaultDuration == curIntervalPropertiesToUpdate.oldDefault);
123 using namespace ossia;
124 if(curInterval.date() != curIntervalPropertiesToUpdate.oldDate)
126 curInterval.setStartDate(curIntervalPropertiesToUpdate.oldDate);
128 curInterval.duration.setDefaultDuration(curIntervalPropertiesToUpdate.oldDefault);
131 curInterval.duration.setMinDuration(curIntervalPropertiesToUpdate.oldMin);
132 curInterval.duration.setMaxDuration(curIntervalPropertiesToUpdate.oldMax);
140 curInterval.clearSmallView();
144 auto processes = shallow_copy(curInterval.processes);
145 for(
auto process : processes)
147 if(!(process->flags() & Process::ProcessFlags::TimeIndependent))
148 RemoveProcess(curInterval, process->id());
155 curIntervalPropertiesToUpdate.reload(curInterval);
157 scenario.intervalMoved(&curInterval);
The displacementPolicy class This class allows to implement multiple displacement behaviors.
Definition: StandardDisplacementPolicy.hpp:28
The core hierarchical and temporal process of score.
Definition: ScenarioModel.hpp:37
Main plug-in of score.
Definition: score-plugin-dataflow/Dataflow/PortItem.hpp:14
Definition: dataStructures.hpp:65
Definition: dataStructures.hpp:52
Definition: TimeValue.hpp:21
Definition: DocumentContext.hpp:18