Vuo  2.0.3
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 replacingDictionaryValueList;
68  set<VuoCable *> incomingCables;
69  set<VuoCable *> outgoingCables;
70  vector<VuoRendererNode *> collapsedTypecasts;
71  map<VuoRendererNode *, set<VuoCable *> > incomingCablesForTypecast;
72  map<VuoRendererNode *, VuoPort *> hostPortForTypecast;
73  vector<pair<VuoPort *, VuoPublishedPort *> > revertedPublishedInternalExternalPortCombinations;
74  vector<pair<VuoPort *, VuoPublishedPort *> > updatedPublishedInternalExternalPortCombinations;
75  map<VuoRendererNode *, vector<pair<VuoPort *, VuoPublishedPort *> > > publishedInternalExternalPortCombinationsForTypecast;
76  map<pair<VuoPort *, VuoPublishedPort *>, bool> publishedConnectionCarriedData;
77  map<VuoCable *, VuoPort *> originalFromPortForCable;
78  map<VuoCable *, VuoPort *> originalToPortForCable;
79  map<VuoPort *, string> constantValueForOriginalPort;
80 
81  void createPortMappings();
82  VuoPort * getEquivalentInputPortInNewNode(VuoPort *oldInputPort, VuoRendererNode *oldNode, VuoRendererNode *newNode);
83  bool valueShouldCarryOver(VuoPort *oldInputPort, VuoPort *newInputPort);
84  };
85 };