Vuo  2.3.2
VuoRendererComposition.hh
Go to the documentation of this file.
1 
10 #pragma once
11 
12 #include "VuoBaseDetail.hh"
13 #include "VuoCable.hh"
15 
16 class VuoCompiler;
17 class VuoCompilerDriver;
18 class VuoCompilerNode;
19 class VuoComposition;
20 class VuoComment;
21 class VuoRendererComment;
22 class VuoRendererNode;
24 class VuoRendererCable;
27 
31 class VuoRendererComposition : public QGraphicsScene, public VuoBaseDetail<VuoComposition>
32 {
33 public:
34  VuoRendererComposition(VuoComposition *baseComposition, bool renderMissingAsPresent = false, bool enableCaching = false);
35 
37  void setBackgroundTransparent(bool transparent);
40  void addNode(VuoNode *node, bool nodeShouldBeRendered=true, bool nodeShouldBeGivenUniqueIdentifier=true);
41  void addCable(VuoCable *cable);
42  void addComment(VuoComment *comment);
43  void removeNode(VuoRendererNode *rn);
44  void removeCable(VuoRendererCable *rc);
45  void removeComment(VuoRendererComment *rcomment);
46  QList<QGraphicsItem *> createAndConnectInputAttachments(VuoRendererNode *node, VuoCompiler *compiler, bool createButDoNotAdd=false);
47  VuoRendererNode * createAndConnectMakeListNode(VuoNode *toNode, VuoPort *toPort, VuoCompiler *compiler, VuoRendererCable *&rendererCable);
48  void createAndConnectDictionaryAttachmentsForNode(VuoNode *node, VuoCompiler *compiler, set<VuoRendererNode *> &createdNodes, set<VuoRendererCable *> &createdCables);
49  vector<string> extractInputVariableListFromExpressionsConstant(string constant, string nodeClassName);
50  void addPublishedPort(VuoPublishedPort *publishedPort, bool isPublishedInput, VuoCompiler *compiler);
51  int removePublishedPort(VuoPublishedPort *publishedPort, bool isPublishedInput, VuoCompiler *compiler);
53  void setPublishedPortName(VuoRendererPublishedPort *publishedPort, string name, VuoCompiler *compiler);
54  string getUniquePublishedPortName(string baseName);
55  vector<VuoRendererNode *> collapseTypecastNodes(void);
58  void uncollapseTypecastNode(VuoRendererNode *typecastNode);
63  bool getRenderNodeActivity(void);
64  bool getRenderPortActivity(void);
65  bool getRenderHiddenCables(void);
66  void setRenderHiddenCables(bool render);
67  QGraphicsItem::CacheMode getCurrentDefaultCacheMode();
68  map<VuoPort *, string> getPortConstantResourcePathsRelativeToDir(QDir newDir);
69  string getAppIconResourcePathRelativeToDir(QDir newDir);
70  void bundleResourceFiles(string targetResourceDir, bool tmpFilesOnly=false, QString bundledIconPath="");
72  static bool isTmpFile(string filePath);
73 
74  static void setGridOpacity(int opacity);
75  static int getGridOpacity();
76 
78  enum GridType
79  {
80  NoGrid,
81  LineGrid,
82  PointGrid
83  };
84  static void setGridType(GridType type);
85  static QPoint quantizeToNearestGridLine(QPointF point, int gridSpacing);
86  static void createAutoreleasePool(void);
87 
88  // Drawing configuration
89  static const int majorGridLineSpacing;
90  static const int minorGridLineSpacing;
91 
92  static const string deprecatedDefaultDescription;
93 
94 protected:
95  void drawBackground(QPainter *painter, const QRectF &rect);
96  void setRenderActivity(bool render, bool includePortActivity=true);
97  void setComponentCaching(QGraphicsItem::CacheMode);
99  bool isPortPublished(VuoRendererPort *port);
100  static bool isDirectory(string path);
101 
108 
109 private:
110  void addNodeInCompositionToCanvas(VuoNode *n);
111  void addCableInCompositionToCanvas(VuoCable *c);
112  void addCommentInCompositionToCanvas(VuoComment *c);
113  QList<QGraphicsItem *> createAndConnectDrawersToListInputPorts(VuoRendererNode *node, VuoCompiler *compiler, bool createButDoNotAdd=false);
114  QList<QGraphicsItem *> createAndConnectDrawersToReadOnlyDictionaryInputPorts(VuoRendererNode *node, VuoCompiler *compiler, bool createButDoNotAdd=false);
115  VuoNode * createPublishedInputNode();
116  VuoNode * createPublishedOutputNode();
117 
118  void bundleAuxiliaryFilesForSceneFile(QString sourceFilePath, QString targetFilePath);
119  string modifyResourcePathForBundle(string path);
120  string modifyResourcePathForNewDir(string path, QDir newDir);
121 
122  static int gridOpacity;
123  static GridType gridType;
124  bool renderMissingAsPresent;
125  bool renderNodeActivity;
126  bool renderPortActivity;
127 };