Vuo 2.4.4
Loading...
Searching...
No Matches
VuoNodeLibrary.hh
Go to the documentation of this file.
1
10#pragma once
11
12#include "VuoHeap.h"
13
14class VuoCompiler;
18class VuoNodeClass;
19class VuoNodePopover;
20
21namespace Ui
22{
23 class VuoNodeLibrary;
24}
25
29class VuoNodeLibrary : public QDockWidget
30{
31 Q_OBJECT
32
33public:
38 {
39 displayByClass,
40 displayByName
41 };
42
47 {
48 nodeLibraryHidden,
49 nodeLibraryDocked,
50 nodeLibraryFloating
51 };
52
53 explicit VuoNodeLibrary(VuoCompiler *compiler, VuoModuleManager *moduleManager, QWidget *parent = 0,
54 VuoNodeLibrary::nodeLibraryDisplayMode displayMode = VuoNodeLibrary::displayByClass);
55 void setCompiler(VuoCompiler *compiler);
56 void setModuleManager(VuoModuleManager *moduleManager);
57 static void cullHiddenNodeClasses(vector<VuoCompilerNodeClass *> &nodeClasses);
59 void fixWidth(bool fix);
61 bool eventFilter(QObject *object, QEvent *event) VuoWarnUnusedResult;
63 static QStringList tokenizeNodeName(QString nodeName, QString className);
64 static bool isStopWord(QString word);
65 bool getHumanReadable();
67 void focusTextFilter();
68 void searchForText(QString text);
69 void insertSearchText(QString text);
70 void getState(QString &filterText, set<string> &selectedNodeClasses, string &documentedNodeClass);
71 void setState(QString filterText, set<string> selectedNodeClasses, string documentedNodeClass);
73 void emitNodeLibraryHiddenOrUnhidden(bool unhidden);
75 void clearNodeClassList();
76 void updateNodeClassList(const vector<string> &nodeClassesToRemove, const vector<VuoCompilerNodeClass *> &nodeClassesToAdd);
77 void highlightNodeClass(string targetNodeClassName, bool highlightAsNewlyInstalled=true, bool resetPreviousSelection=true);
78 void prepareAndDisplayNodePopoverForClass(string nodeClassName);
79
80signals:
81 void componentsAdded(QList<QGraphicsItem *> addedComponents, VuoEditorComposition *target);
82 void changedIsHumanReadable(bool humanReadable);
83 void nodeLibraryHiddenOrUnhidden(bool unhidden);
85 void nodeLibraryMoved(QPoint newPos);
92
93public slots:
94 void clickedNamesButton();
96 void setHumanReadable(bool humanReadable);
98 void displayPopoverInPane(QWidget *panelContentWidget, QString resourceDir="");
99 void updateUI();
100
101protected:
102 void moveEvent(QMoveEvent *event);
103 void resizeEvent(QResizeEvent *event);
104 void showEvent(QShowEvent *event);
105 void closeEvent(QCloseEvent *event);
106 void keyPressEvent(QKeyEvent *event);
107
108private slots:
109 void updateListViewForNewFilterTextOnTimer();
110 void updateListViewForNewFilterTextNow();
111 void emitNodeDocumentationPanelHeightChanged();
112 void updateColor(bool isDark);
113
114private:
115 friend class TestVuoEditor;
116
117 Ui::VuoNodeLibrary *ui;
118 VuoCompiler *compiler;
119 VuoModuleManager *moduleManager;
120 vector<VuoCompilerNodeClass *> loadedNodeClasses;
121 static map<VuoCompilerNodeClass *, int> newlyInstalledNodeClasses;
122 map<string, VuoNodePopover *> popoverForNodeClass;
123 map<string, string> capitalizationForNodeClass;
124 static map<pair<QString, QString>, QStringList> tokensForNodeClass;
125 static map<string, int> nodeClassFrequency;
126 static set<string> stopWords;
127 int preferredNodeDocumentationPanelHeight;
128 int preferredNodeLibraryWidth;
129 bool hasBeenShown;
130 int defaultMinimumWidth;
131 int defaultMaximumWidth;
132 QTimer *updateListViewTimer;
133
134 void populateList(vector<VuoCompilerNodeClass *> nodeClasses, bool resetSelection);
135 static bool nodeHasPortMatchingString(VuoCompilerNodeClass *cnc, string needle, bool isInput);
136 static bool nodeHasSourceType(VuoCompilerNodeClass *cnc, string sourceType);
137 void updateListView(bool resetSelection);
138 vector<VuoCompilerNodeClass *> getMatchingNodeClassesForSearchTerms(QStringList rawTermList);
139 void updateListViewForNewDisplayMode();
140 VuoNodePopover * initializeNodePopoverForClass(VuoNodeClass *nodeClass, VuoCompiler *compiler);
141 VuoNodePopover * getNodePopoverForClass(VuoNodeClass *nodeClass, VuoCompiler *compiler);
142 void updateSplitterPosition();
143 static bool nodeClassLessThan(VuoCompilerNodeClass *nodeClass1, VuoCompilerNodeClass *nodeClass2);
144 QStringList applyFilterTransformations(QStringList filterTokenList);
145 void populateNodeClassFrequencyMap();
146 void populateStopWordList();
147 void recordNodeClassCapitalizations();
148 void releaseNodePopovers();
149
150#ifdef VUO_PRO
151#include "pro/VuoNodeLibrary_Pro.hh"
152#endif
153};