Vuo  2.0.3
VuoPortPopover.hh
Go to the documentation of this file.
1 
10 #pragma once
11 
12 #include <dispatch/dispatch.h>
13 #include <VuoImageResize.h>
15 class VuoPort;
16 
20 class VuoPortPopover : public QTextBrowser
21 {
22  Q_OBJECT
23 public:
24  explicit VuoPortPopover(VuoPort *port, VuoEditorComposition *composition, QWidget *parent=0);
26 
27  // Style
28  bool getDetached();
29  void detach();
30 
31 signals:
32  void popoverClosedForPort(string portID);
33  void popoverDetachedFromPort(string portID);
34  void popoverResized();
35 
36 public slots:
37  void setWindowLevel(bool top);
38  void setWindowLevelAndVisibility(bool top);
39  void setCompositionRunning(bool running, bool resetDataValue=true);
40  void updateTextAndResize();
41  void updateCachedDataValue(QString value);
42  void updateLastEventTime();
43  void updateLastEventTimeAndCachedDataValue(QString value);
45 
46 protected:
47  void mousePressEvent(QMouseEvent *event);
48  void mouseMoveEvent(QMouseEvent * event);
49  void mouseReleaseEvent(QMouseEvent * event);
50  void closeEvent(QCloseEvent *event);
51  void resizeEvent(QResizeEvent *event);
52 
53 private slots:
54  void updateStyle();
55  void helpButtonClicked();
56 
57 private:
58  static const int maxPopoverContentWidth;
59  static const int maxPopoverImageWidth;
60  static const int maxPopoverImageHeight;
61  static const qreal minTextUpdateInterval;
62  static const int eventHistoryMaxSize;
63  static const int noEventObserved;
64  static const int noDisplayableEventTime;
65  static const string noDataValueObserved;
66  static const string noDisplayableDataValue;
67 
68  // Port attributes affecting text contents
69  string portID;
70  VuoEditorComposition *composition;
71  string cachedDataValue;
72  qint64 timeOfLastEvent;
73  bool compositionRunning;
74  QQueue<qint64> eventHistory;
75  unsigned int eventCount;
76  unsigned int droppedEventCount;
77  bool allEventsBlocked;
78  bool someEventsBlocked;
79 
80  // Style
81  bool isDetached;
82 
83  QTimer *refreshTextTimer;
84  dispatch_queue_t popoverTextQueue;
85 
86  VuoImageResize imageResize;
87  QString mostRecentImage;
88 
89  void updateTextAndResizeThreadUnsafe();
90  void updateTextThreadUnsafe(bool includeEventIndicator=false);
91  QString generateImageCode();
92  void resetRefreshTextInterval();
93  bool refreshTextTimerFiredSinceLastReset;
94  QString generatePortPopoverText(bool includeEventIndicator=false);
95 
96  static double getEventIntervalMean(QQueue<qint64> timestamps);
97  static double getEventIntervalStdDev(QQueue<qint64> timestamps);
98 
99  // User interaction
100  bool dragInProgress;
101  QPoint positionBeforeDrag;
102 };