Vuo  2.0.3
VuoCommandAddPublishedPort.cc
Go to the documentation of this file.
1 
11 #include "VuoCommandCommon.hh"
14 #include "VuoCompilerInputData.hh"
16 #include "VuoEditorComposition.hh"
17 #include "VuoEditorWindow.hh"
18 
24  : VuoCommandCommon(window)
25 {
26  setText(QApplication::translate("VuoEditorWindow", "Add Published Port"));
27  this->window = window;
28  this->revertedSnapshot = window->getComposition()->takeSnapshot();
29 
30  // Start of command content.
31  {
32  bool isPublishedInput = !publishedPort->getInput();
33  window->getComposition()->addPublishedPort(dynamic_cast<VuoPublishedPort *>(publishedPort->getBase()), isPublishedInput);
34 
35  string typeName = "event";
36  VuoType *vuoType = dynamic_cast<VuoCompilerPublishedPortClass *>(publishedPort->getBase()->getClass()->getCompiler())->getDataVuoType();
37  if (vuoType)
38  typeName = vuoType->getModuleKey();
39  setDescription("Add published %s port %s %s",
40  isPublishedInput ? "input" : "output",
41  typeName.c_str(),
42  publishedPort->getBase()->getClass()->getName().c_str());
43  }
44  // End of command content.
45 
46  this->updatedSnapshot = window->getComposition()->takeSnapshot();
47 }
48 
53 {
55 }
56 
61 {
63 
64  window->resetCompositionWithSnapshot(revertedSnapshot);
65  window->coalesceSnapshots(updatedSnapshot, revertedSnapshot);
66 }
67 
72 {
74 
75  window->resetCompositionWithSnapshot(updatedSnapshot);
76  window->coalesceSnapshots(revertedSnapshot, updatedSnapshot);
77 }