]> git.cworth.org Git - apitrace/blobdiff - gui/graphwidget.h
Combine timeline and histogram tabs.
[apitrace] / gui / graphwidget.h
index 266f6945a3ca6d3fb64e0bce1231abbb9fc79940..7ab17c65490001a59ce7ecb73427a54c8c91b0b5 100644 (file)
@@ -12,6 +12,12 @@ enum GraphType {
     GraphCpu
 };
 
+enum SelectType {
+    SelectNone,
+    SelectTime,
+    SelectProgram
+};
+
 class GraphWidget : public QWidget
 {
     Q_OBJECT
@@ -22,18 +28,28 @@ public:
     void setProfile(trace::Profile* profile, GraphType type);
     const trace::Profile::Call* callAtPosition(const QPoint& pos);
 
+    void selectNone(bool notify = false);
+    void selectTime(int64_t start, int64_t end, bool notify = false);
+    void selectProgram(unsigned program, bool notify = false);
+
 protected:
-    virtual void mousePressEvent(QMouseEvent *e);
     virtual void paintEvent(QPaintEvent *e);
-    virtual void mouseMoveEvent(QMouseEvent *e);
+    virtual void resizeEvent(QResizeEvent *e);
+
     virtual void wheelEvent(QWheelEvent *e);
+    virtual void mouseMoveEvent(QMouseEvent *e);
+    virtual void mousePressEvent(QMouseEvent *e);
+    virtual void mouseReleaseEvent(QMouseEvent *e);
     virtual void mouseDoubleClickEvent(QMouseEvent *e);
-    virtual void resizeEvent(QResizeEvent *e);
 
 signals:
     void jumpToCall(int no);
     void viewChanged(int call, int width);
 
+    void selectedNone();
+    void selectedProgram(unsigned program);
+    void selectedTime(int64_t start, int64_t end);
+
 public slots:
     void changeView(int call, int width);
 
@@ -44,34 +60,46 @@ private:
     void paintHorizontalAxis(QPainter& painter);
 
 private:
+    /* Data */
     trace::Profile* m_profile;
     GraphType m_type;
 
-    int64_t m_maxTime;
-
-    int m_minCall;
-    int m_maxCall;
-
-    int m_minCallWidth;
-    int m_maxCallWidth;
+    /* Vertical Axis */
+    int64_t m_timeMax;
 
+    /* Horizontal axis */
     int m_call;
+    int m_callMin;
+    int m_callMax;
     int m_callWidth;
+    int m_callWidthMin;
+    int m_callWidthMax;
 
-    QPoint m_mousePressPosition;
+    /* Viewport */
+    int m_graphWidth;
+    int m_graphHeight;
+
+    /* Mouse track data */
     int m_mousePressCall;
+    QPoint m_mousePressPosition;
 
+    /* Style */
     int m_axisWidth;
     int m_axisHeight;
-
-    int m_graphWidth;
-    int m_graphHeight;
-
     QPen m_axisForeground;
     QBrush m_axisBackground;
-
     QLinearGradient m_graphGradientGpu;
     QLinearGradient m_graphGradientCpu;
+    QLinearGradient m_graphGradientDeselected;
+
+    struct {
+        SelectType type;
+
+        unsigned program;
+
+        int64_t timeStart;
+        int64_t timeEnd;
+    } m_selection;
 };
 
 #endif // GRAPHWIDGET_H