Loading...
Searching...
No Matches
RemoveMacro.hpp
1#pragma once
2#include <Scenario/Application/Menus/ScenarioCopy.hpp>
3#include <Scenario/Commands/Event/SetCondition.hpp>
4#include <Scenario/Commands/Scenario/Deletions/RemoveSelection.hpp>
5#include <Scenario/Commands/TimeSync/RemoveTrigger.hpp>
6#include <Scenario/Process/ScenarioModel.hpp>
7
8#include <score/command/Dispatchers/MacroCommandDispatcher.hpp>
9
10namespace Scenario
11{
12namespace Command
13{
14template <typename T>
15void setupRemoveMacro(const Scenario::ProcessModel& scenar, Selection sel, T& macro)
16{
17 switch(sel.size())
18 {
19 case 0:
20 return;
21 case 1: {
22 auto obj = sel.at(0);
23 if(auto ts = dynamic_cast<const Scenario::TimeSyncModel*>(obj.data()))
24 {
25 if(ts->active())
26 {
27 macro.submit(new RemoveTrigger<Scenario::ProcessModel>{*ts});
28 }
29 return;
30 /*
31 if (ts->events().size() > 1)
32 {
33 macro.submit(new SplitWholeSync(*ts));
34 return;
35 }
36 else
37 {
38 SCORE_ASSERT(ts->events().size() == 1);
39 auto ev = scenar.event(ts->events()[0]);
40 SCORE_ASSERT()
41 return;
42 }
43 */
44 }
45 else if(auto ev = dynamic_cast<const Scenario::EventModel*>(obj.data()))
46 {
47 if(ev->active())
48 {
49 macro.submit(new SetCondition{*ev, State::Expression{}});
50 }
51 /*
52 if (ev->states().size() > 1)
53 {
54 macro.submit(new SplitWholeEvent(*ev));
55 }
56 */
57 return;
58 }
59 }
60
61 [[fallthrough]];
62 default: {
63 CategorisedScenario cat{sel};
64 for(auto ts : cat.selectedTimeSyncs)
65 {
66 if(ts->events().size() > 1)
67 {
68 auto cmd = new SplitWholeSync{*ts};
69 macro.submit(cmd);
70 }
71 }
72 for(auto ev : cat.selectedEvents)
73 {
74 if(ev->states().size() > 1)
75 {
76 auto cmd = new SplitWholeEvent{*ev};
77 macro.submit(cmd);
78 }
79 }
80
81 sel.clear();
82 for(auto itv : cat.selectedIntervals)
83 sel.append(itv);
84 for(auto st : cat.selectedStates)
85 sel.append(st);
86
87 if(sel.size() > 0)
88 macro.submit(new RemoveSelection{scenar, sel});
89 }
90 }
91}
92}
93}
Definition EventModel.hpp:36
The core hierarchical and temporal process of score.
Definition ScenarioModel.hpp:37
Definition TimeSyncModel.hpp:34
Definition Selection.hpp:12
Main plug-in of score.
Definition score-plugin-dataflow/Dataflow/PortItem.hpp:13