Vuo 2.4.4
Loading...
Searching...
No Matches
VuoEditorWindow.hh
Go to the documentation of this file.
1
10#pragma once
11
13#include "VuoMainWindow.hh"
14#include "VuoNode.hh"
15#include "VuoNodeLibrary.hh"
16#include "VuoPortClass.hh"
17class VuoCompiler;
20class VuoExampleMenu;
21class VuoExportMovieDialog;
25class VuoPort;
26class VuoProtocol;
33class VuoRendererNode;
34class VuoRendererPort;
36class VuoSearchBox;
37
38namespace Ui
39{
40 class VuoEditorWindow;
41}
42
47{
48 Q_OBJECT
49
50public:
51 explicit VuoEditorWindow(QString documentIdentifier="", QString compositionPath="",
52 const string &compositionAsString="",
53 VuoNodeLibrary::nodeLibraryDisplayMode nodeLibraryDisplayMode=VuoNodeLibrary::displayByClass,
54 VuoNodeLibrary::nodeLibraryState nodeLibraryState=VuoNodeLibrary::nodeLibraryHidden,
55 VuoNodeLibrary *floater=NULL,
56 VuoProtocol *activeProtocol=NULL,
57 string nodeClassToHighlight="");
59
61 bool isScrollInProgress();
63 double getLatestDragTime();
64 void highlightNodeClass(string nodeClass);
65 static bool containsLikelyVuoComposition(QString text);
67 static QString getNodeClassNameForDisplayNameAndCategory(QString compositionName, QString category, QString defaultCompositionName, QString defaultCategory);
71 void releaseSurrogateNodeLibrary(bool previousFloaterDestroyed);
72 QMenu * getFileMenu();
74 void setIncludeInRecentFileMenu(bool include);
76 QPointF getCursorScenePos();
78 QPointF getFittedScenePos(QPointF origPos, int leftMargin=50, int topMargin=50, int rightMargin=175, int bottomMargin=75);
80 void resetCompositionWithSnapshot(string snapshot);
81 void zoomOutToFit();
82
83 static QString untitledComposition;
85
86public slots:
88 void updateUI();
89 void itemsMoved(set<VuoRendererNode *> nodes, set<VuoRendererComment *> comments, qreal dx, qreal dy, bool movedByDragging);
90 void commentResized(VuoRendererComment *comment, qreal dx, qreal dy);
91 void connectionCompleted(VuoRendererCable *cableInProgress, VuoRendererPort *targetPort, pair<VuoRendererCable *, VuoRendererCable *> cableArgs, VuoRendererNode *typecastNodeToDelete, pair<string, string> typeArgs, pair<VuoRendererPort *, VuoRendererPort *> portArgs);
92 void setTriggerThrottling(VuoPort *triggerPort, enum VuoPortClass::EventThrottling eventThrottling);
93 void adjustInputPortCountForNode(VuoRendererNode *node, int inputPortCountDelta, bool adjustmentRequestedByDragging);
94 void swapNodes(VuoRendererNode *node, string newNodeClass);
95 VuoRendererNode * specializePortNetwork(VuoRendererPort *port, string specializedTypeName);
96 VuoRendererNode * specializePortNetwork(VuoRendererPort *port, string specializedTypeName, bool encapsulateInMacro);
98 VuoRendererNode * unspecializePortNetwork(VuoRendererPort *port, bool encapsulateInMacro);
99 VuoRendererNode * respecializePortNetwork(VuoRendererPort *port, string specializedTypeName);
100 VuoRendererNode * respecializePortNetwork(VuoRendererPort *port, string specializedTypeName, bool encapsulateInMacro);
102 void internalExternalPortPairPublished(VuoPort *internalPort, VuoPublishedPort *externalPort, bool forceEventOnlyPublication, VuoPort *portToSpecialize=NULL, string specializedTypeName="", string typecastToInsert="", bool useUndoStackMacro=true);
103 void internalPortPublishedViaDropBox(VuoPort *port, bool forceEventOnlyPublication, bool useUndoStackMacro);
104 void internalPortPublished(VuoPort *port, bool forceEventOnlyPublication, string name="", bool merge=false, VuoPort *portToSpecialize=NULL, string specializedTypeName="", string typecastToInsert="", bool useUndoStackMacro=true);
107 void makeProtocolPortChanges(map<VuoPublishedPort *, string> publishedPortsToRename, set<VuoPublishedPort *> publishedPortsToRemove, vector<VuoPublishedPort *> publishedPortsToAdd, bool beginUndoStackMacro, bool endUndoStackMacro);
108 void componentsRemoved(QList<QGraphicsItem *> components, string commandDescription);
109 void componentsAdded(QList<QGraphicsItem *> components, VuoEditorComposition *target);
115 void conformToGlobalNodeLibraryVisibility(VuoNodeLibrary::nodeLibraryState visibility, VuoNodeLibrary *floater, bool previousFloaterDestroyed);
117 QAction *getRaiseDocumentAction() const;
118 QAction *getShowEventsAction() const;
119 QAction *getZoomOutAction() const;
120 QAction *getZoom11Action() const;
121 QAction *getZoomToFitAction() const;
122 QAction *getZoomInAction() const;
124 void setAsActiveWindow();
131 void on_find_triggered();
134 void coalesceSnapshots(string oldCompositionSnapshot, string newCompositionSnapshot, VuoCompilerCompositionDiff *diffInfo=nullptr);
135 void coalesceInternalPortConstantsToSync(string portID);
136 void coalescePublishedPortConstantsToSync(string portID);
137 void coalesceNodesToUnlink(string nodeID);
138 void coalesceNodesToRelink(string nodeID);
139 void beginUndoStackMacro(QString commandName);
140 void endUndoStackMacro();
141 static string deriveBaseNodeClassNameFromDisplayName(string displayName);
142
143signals:
146
147protected:
148 bool event(QEvent *event) VuoWarnUnusedResult;
149 bool eventFilter(QObject *object, QEvent *event) VuoWarnUnusedResult;
150 void keyPressEvent(QKeyEvent *event);
151 void keyReleaseEvent(QKeyEvent *event);
152 void mouseMoveEvent(QMouseEvent *event);
153 void closeEvent(QCloseEvent *event);
154 void moveEvent(QMoveEvent *event);
155 void resizeEvent(QResizeEvent *event);
156
157private slots:
158 void showUpdateHelpDialog();
159
160 void toggleNodeLibraryDockedState();
161 void on_zoom11_triggered();
162 void on_zoomIn_triggered();
163 void on_zoomOut_triggered();
164 void viewportFitReset();
165
166 void on_saveComposition_triggered();
167 bool saveFile(const QString &file);
168 void changeActiveProtocol(void);
169 void updateActiveProtocolDisplay(void);
170 void evaluateCompositionForProtocolPromotion(void);
171 void on_saveCompositionAs_triggered();
172 void on_insertComment_triggered();
173 void on_insertSubcomposition_triggered();
174 string on_installSubcomposition_triggered();
175 void on_compositionInformation_triggered();
176 void editMetadata(int dialogResult);
177 void undoStackCleanStateChanged(bool clean);
178
179 void duplicateSelectedCompositionComponentsByMenuItem();
180
181 void showBuildActivityIndicator();
182 void hideBuildActivityIndicator(QString buildError);
183 void hideStopActivityIndicator();
184
185 void on_openUserModulesFolder_triggered();
186 void on_openSystemModulesFolder_triggered();
187 void on_showConsole_triggered();
188
189 void on_showPublishedPorts_triggered();
190 void on_showHiddenCables_triggered();
191 void on_showEvents_triggered();
192 void closePublishedPortSidebars();
193 void conditionallyShowPublishedPortSidebars(bool visible);
194 void updatePublishedCableGeometry();
195 void updatePublishedPortOrder(vector<VuoPublishedPort *> ports, bool isInput);
196 void updateWindowForNewCableDrag();
197 void displayDockedNodeLibrary();
198
199 void resetUndoStackMacros();
200 void updateSelectedComponentMenuItems();
201 void updateChangeNodeMenu();
202 void updateSceneRect();
203 void ensureSceneRectContainsRegion(const QList<QRectF> &region);
204 void updateRubberBandSelectionMode(QRect rubberBandRect, QPointF fromScenePoint, QPointF toScenePoint);
205
206 void setPortConstant(VuoRendererPort *port, string value);
207 void showInputEditor(VuoRendererPort *port);
208 void showInputEditor(VuoRendererPort *port, bool forwardTabTraversal);
209 void showNodeTitleEditor(VuoRendererNode *node);
210 void showCommentEditor(VuoRendererComment *comment);
211 void showPublishedPortNameEditor(VuoRendererPublishedPort *port, bool useUndoStack);
212 void zoomToFitComment(VuoRendererComment *comment);
213 void createIsolatedExternalPublishedPort(string typeName, bool isInput);
214 void changePublishedPortName(VuoRendererPublishedPort *port, string newName, bool useUndoStack);
215 void changePublishedPortDetails(VuoRendererPublishedPort *port, json_object *newDetails);
216 void openEditableSourceForNode(VuoRendererNode *node);
217 void insertCommentAtPos(QPointF targetScenePos);
218 void insertSubcompositionAtPos(QPointF targetScenePos);
219 void refactorSelectedItems();
220 void restoreDefaultLeftDockedWidgetWidths();
221 void hideSelectedInternalCables();
222 void hideCables(set<VuoRendererCable *> cables);
223 void unhideCables(set<VuoRendererCable *> cables);
224 void updateGrid();
225 void updateCanvasOpacity();
226 void updateColor(bool isDark);
227 void coalescedUpdateRunningComposition();
228 void handlePendingProtocolComplianceReevaluationRequests();
229
230private:
231 friend class TestVuoEditor;
232 friend class TestEditorCommands;
233
234 static const qreal viewportStepRate;
235 static const qreal viewportStepRateMultiplier;
236 static const qreal zoomRate;
237 static const qreal pastedComponentOffset;
238 static const qreal compositionMargin;
239 VuoCompiler *compiler;
240
241 // The node library owned by this window, which will be the library docked into this window
242 // when in docked-library mode, and which may also at times function as the floating node library.
243 VuoNodeLibrary *ownedNodeLibrary;
244
245 // The node library currently active in association with this window, which may be the library owned
246 // by this window or a floating library associated with a different window or the top-level application.
247 VuoNodeLibrary *nl;
248
249 string coalescedOldCompositionSnapshot;
250 string coalescedNewCompositionSnapshot;
251 vector<string> coalescedInternalPortConstantsToSync;
252 vector<string> coalescedPublishedPortConstantsToSync;
253 vector<string> coalescedNodesToUnlink;
254 vector<string> coalescedNodesToRelink;
255 VuoCompilerCompositionDiff *coalescedDiffInfo;
256
257 VuoCompositionMetadataPanel *metadataPanel;
258 VuoPublishedPortSidebar *inputPortSidebar;
259 VuoPublishedPortSidebar *outputPortSidebar;
260 VuoInputEditorManager *inputEditorManager;
261 VuoInputEditorSession *inputEditorSession;
262 QMenu *menuNewCompositionWithTemplate;
263 QMenu *menuProtocols;
264 VuoRecentFileMenu *menuOpenRecent;
265 VuoExampleMenu *menuOpenExample;
266 QMenu *contextMenuTints;
267 QMenu *menuChangeNode;
268 QAction *raiseDocumentAction;
269 QAction *undoAction;
270 QAction *redoAction;
271 QAction *quitAction;
272 QUndoStack *undoStack;
273 QUndoView *undoView;
274 VuoMetadataEditor *metadataEditor;
275 VuoSearchBox *searchBox;
276 bool zoomOutToFitOnNextShowEvent;
277 bool compositionUpgradedSinceLastSave;
278 bool canvasDragEnabled;
279 bool canvasDragInProgress;
280 bool scrollInProgress;
281 double timeOfLastScroll;
282 bool consumeNextMouseReleaseToCanvas;
283 bool lastLeftMousePressHadOptionModifier;
284 bool rubberBandSelectionInProgress;
285 QPointF cursorPosAtLastComponentCopy;
286 QPoint canvasDragMinCursorPos;
287 QPoint canvasDragMaxCursorPos;
288 QPoint lastCursorLocationDuringCanvasDrag;
289 bool previousDragMoveWasOverSidebar;
290 bool itemDragMacroInProgress;
291 vector<QGraphicsItem *> itemsBeingDragged;
292 VuoRendererComment *commentBeingResized;
293 int itemDragDx;
294 int itemDragDy;
295 double latestDragTime;
296 bool commentResizeMacroInProgress;
297 int commentResizeDx;
298 int commentResizeDy;
299 bool duplicationMacroInProgress;
300 VuoEditorWindowToolbar *toolbar;
301 bool isZoomedToFit;
302 bool doneInitializing;
303 bool containedPrepopulatedContent;
304 bool includeInRecentFileMenu;
305 bool publishedPortNearCursorPreviously;
306
307 bool forwardingEventsToCanvas;
308
309 Ui::VuoEditorWindow *ui;
310 VuoEditorComposition *composition;
311
312 int nodeLibraryMinimumWidth;
313 int nodeLibraryMaximumWidth;
314
315 bool protocolComplianceReevaluationPending;
316 bool ignoreItemMoveSignals;
317 bool closing;
318
319 bool saveFile(const QString & savePath, QString & existingPath);
320 bool saveFileAs(const QString & savePath);
321 QString saveCompositionAs();
322 void acceptCloseEvent();
323 string installSubcomposition(string parentCompositionPath);
324 bool ensureThisParentCompositionSaved();
325 string sanitizeSubcompositionName(string name);
326 void updateToolbarElementUI();
327 void populateProtocolsMenu(QMenu *m);
328 void updateProtocolsMenu(QMenu *m);
329 void toggleActiveStatusForProtocol(VuoProtocol *protocol);
330 void setPublishedPortSidebarVisibility(bool visible);
331 void registerProtocolComplianceEvaluationRequest();
332 void setCompositionModified(bool modified);
333 void initializeNodeLibrary(VuoCompiler *nodeLibraryCompiler, VuoNodeLibrary::nodeLibraryDisplayMode nodeLibraryDisplayMode, VuoNodeLibrary::nodeLibraryState nodeLibraryState, VuoNodeLibrary *floater=NULL);
334 void pasteCompositionComponents();
335 void componentsPasted(QList<QGraphicsItem *> components, string commandDescription="Paste");
336 string getMaximumSubcompositionFromSelection(bool includePublishedPorts, bool includeHeader);
337 bool isStrandedAttachment(VuoRendererInputAttachment *attachment, QList<QGraphicsItem *> selectedItems);
338 void instantiateNewCompositionComponentsFromString(string compositionText);
339 QList<QGraphicsItem *> mergeCompositionComponentsFromString(string compositionText, bool pasteAtCursorLoc, bool pasteWithOffset, string commandDescription="Paste");
340 void transitionNodeLibraryConnections(VuoNodeLibrary *oldLibrary, VuoNodeLibrary *newLibrary);
341 QList<QGraphicsItem *> createAnyNecessaryMakeListComponents(VuoPort *port);
342 VuoRendererNode * specializeSinglePort(VuoRendererPort *port, string specializedTypeName);
343 VuoRendererNode * unspecializeSingleNode(VuoRendererNode *node, string revertedNodeClassName);
344 void enableCanvasDrag();
345 void disableCanvasDrag();
346 void initiateCanvasDrag();
347 void concludeCanvasDrag();
348 void updateRefireAction();
349 void updateCursor();
350 string generateCurrentDefaultCopyright();
351 bool confirmReplacingFile(string path);
352 bool arePublishedPortSidebarsVisible();
353
354#ifdef VUO_PRO
355#include "pro/VuoEditorWindow_Pro.hh"
356#endif
357};