Vuo  2.0.2
VuoCommandReorderPublishedPorts.cc
Go to the documentation of this file.
1 
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() :
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 
54 {
56 }
57 
62 {
64 
65  window->resetCompositionWithSnapshot(revertedSnapshot);
66  window->coalesceSnapshots(updatedSnapshot, revertedSnapshot);
67 }
68 
73 {
75 
76  window->resetCompositionWithSnapshot(updatedSnapshot);
77  window->coalesceSnapshots(revertedSnapshot, updatedSnapshot);
78 }