Vuo  2.3.2
VuoCommandReplaceNode.hh
Go to the documentation of this file.
1 
10 #pragma once
11 
12 #include "VuoCommandCommon.hh"
13 
14 class VuoCable;
17 class VuoEditorWindow;
18 class VuoPort;
19 class VuoRendererNode;
20 
25 {
26 public:
27  VuoCommandReplaceNode(VuoRendererNode *oldNode, VuoRendererNode *newNode, VuoEditorWindow *window, string commandDescription, bool preserveDanglingCables=false, bool resetConstantValues=false);
28  VuoCommandReplaceNode(map<VuoRendererNode *, VuoRendererNode *> newNodeForOldNode, VuoEditorWindow *window, string commandDescription, bool preserveDanglingCables=false, bool resetConstantValues=false);
29 
30  int id() const;
31  void undo();
32  void redo();
33 
34 private:
35  static const int commandID;
36  VuoEditorWindow *window;
37  string revertedSnapshot;
38  string updatedSnapshot;
39 
41 
42  bool operationInvolvesGenericPort;
43 
44  class SingleNodeReplacement;
45  void initialize(VuoEditorWindow *window, string commandDescription, map<VuoRendererNode *, VuoRendererNode *> newNodeForOldNode, bool preserveDanglingCables, bool resetConstantValues);
46 
50  class SingleNodeReplacement
51  {
52  public:
53  SingleNodeReplacement(VuoRendererNode *oldNode, VuoRendererNode *newNode, VuoEditorComposition *composition, bool preserveDanglingCables=false, bool resetConstantValues=false);
54 
55  void createAllMappings();
56  void redo();
57 
58  VuoRendererNode *oldNode;
59  VuoRendererNode *newNode;
60  map<VuoPort *, VuoPort *> updatedPortForOriginalPort;
61 
62  private:
63  VuoEditorComposition *composition;
64  bool preserveDanglingCables;
65  bool resetConstantValues;
66 
67  bool replacingDictionaryKeyList;
68  bool replacingDictionaryValueList;
69  set<VuoCable *> incomingCables;
70  set<VuoCable *> outgoingCables;
71  vector<VuoRendererNode *> collapsedTypecasts;
72  map<VuoRendererNode *, set<VuoCable *> > incomingCablesForTypecast;
73  map<VuoRendererNode *, VuoPort *> hostPortForTypecast;
74  vector<pair<VuoPort *, VuoPublishedPort *> > revertedPublishedInternalExternalPortCombinations;
75  vector<pair<VuoPort *, VuoPublishedPort *> > updatedPublishedInternalExternalPortCombinations;
76  map<VuoRendererNode *, vector<pair<VuoPort *, VuoPublishedPort *> > > publishedInternalExternalPortCombinationsForTypecast;
77  map<pair<VuoPort *, VuoPublishedPort *>, bool> publishedConnectionCarriedData;
78  map<VuoCable *, VuoPort *> originalFromPortForCable;
79  map<VuoCable *, VuoPort *> originalToPortForCable;
80  map<VuoPort *, string> constantValueForOriginalPort;
81 
82  void createPortMappings();
83  VuoPort * getEquivalentInputPortInNewNode(VuoPort *oldInputPort, VuoRendererNode *oldNode, VuoRendererNode *newNode);
84  bool valueShouldCarryOver(VuoPort *oldInputPort, VuoPort *newInputPort);
85  };
86 };