Vuo
2.0.3
editor
VuoCommandReorderPublishedPorts.cc
Go to the documentation of this file.
1
10
#include "
VuoCommandReorderPublishedPorts.hh
"
11
#include "
VuoCommandCommon.hh
"
12
#include "
VuoComposition.hh
"
13
#include "
VuoEditorComposition.hh
"
14
#include "
VuoEditorWindow.hh
"
15
#include "
VuoStringUtilities.hh
"
16
20
VuoCommandReorderPublishedPorts::VuoCommandReorderPublishedPorts
(vector<VuoPublishedPort *> ports,
bool
isInput,
VuoEditorWindow
*window)
21
:
VuoCommandCommon
(window)
22
{
23
setText(QApplication::translate(
"VuoEditorWindow"
,
"Reorder Published Ports"
));
24
this->window = window;
25
this->revertedSnapshot = window->
getComposition
()->
takeSnapshot
();
26
vector<string> portNames;
27
28
// Start of command content.
29
{
30
vector<VuoPublishedPort *> existingPortList = (isInput? window->
getComposition
()->
getBase
()->
getPublishedInputPorts
() :
31
window->
getComposition
()->
getBase
()->
getPublishedOutputPorts
());
32
foreach
(
VuoPublishedPort
*port, existingPortList)
33
window->
getComposition
()->
removePublishedPort
(port, isInput,
false
);
34
35
foreach
(
VuoPublishedPort
*port, ports)
36
{
37
window->
getComposition
()->
addPublishedPort
(port, isInput,
false
);
38
portNames.push_back(port->
getClass
()->
getName
());
39
}
40
}
41
// End of command content.
42
43
this->updatedSnapshot = window->
getComposition
()->
takeSnapshot
();
44
45
setDescription
(
"Reorder published %s ports to %s"
,
46
isInput ?
"input"
:
"output"
,
47
VuoStringUtilities::join
(portNames,
", "
).c_str());
48
}
49
53
int
VuoCommandReorderPublishedPorts::id
()
const
54
{
55
return
VuoCommandCommon::reorderPublishedPortsCommandID
;
56
}
57
61
void
VuoCommandReorderPublishedPorts::undo
()
62
{
63
VuoCommandCommon_undo
;
64
65
window->
resetCompositionWithSnapshot
(revertedSnapshot);
66
window->
coalesceSnapshots
(updatedSnapshot, revertedSnapshot);
67
}
68
72
void
VuoCommandReorderPublishedPorts::redo
()
73
{
74
VuoCommandCommon_redo
;
75
76
window->
resetCompositionWithSnapshot
(updatedSnapshot);
77
window->
coalesceSnapshots
(revertedSnapshot, updatedSnapshot);
78
}
Generated on Tue Apr 28 2020 16:53:59 for Vuo by
1.8.17