ArffWidgetBase.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. // WindowArffBase.h
  2. #ifndef __ARFFWIDGETBASE_H__
  3. #define __ARFFWIDGETBASE_H__
  4. #include <QtWidgets>
  5. #include <vector>
  6. #include "../arffHelper/Arff.h"
  7. using namespace std;
  8. class ArffWidgetBase : public QWidget
  9. {
  10. Q_OBJECT
  11. signals:
  12. void SendWindowDur(int dur_us);
  13. void SendTime(int curTime_us);
  14. ///< Sends the current time.
  15. void SendUpdate();
  16. ///< Singal to upadte connected widgets including sending object.
  17. public slots:
  18. void HandleWindowDur(int dur_us, QObject *pSender);
  19. void HandleTime(int curTime_us, QObject *pSender);
  20. void HandleUpdate();
  21. void HandleSelectedEyeMovement(int eyeMovement);
  22. virtual void HandleToggleView();
  23. public:
  24. ArffWidgetBase(QWidget *parent=0);
  25. QSize minimumSizeHint() const Q_DECL_OVERRIDE;
  26. ///< Returns the required mimimum size for the widget in order
  27. ///< to render correctly. If no layout is present returns invalid size.
  28. void SetGridInterval(int tickX, int tickY);
  29. ///< Sets the tick of x,y axes. Otherwise uses default.
  30. void SetWindowDuration(int duration);
  31. ///< Sets the duration of the window in us.
  32. void SetTime(int currentTime);
  33. ///< Sets the current time of display. Initially 0.
  34. virtual void SetData(Arff &arff, int attToPaint, double maxValue=-1.0);
  35. ///< Sets the ARFF data and the index of the attribute to paint. \p maxValue
  36. ///< is the normlization on the plotted data.
  37. virtual void SetFovData(Arff &arff, double maxValue);
  38. ///< Sets Field Of View data created from te equirectangular data. This
  39. ///< function is called after data has been set.
  40. void SetIntervalAtt(int intervalAtt);
  41. ///< Sets an attribute that is going to be used as guide for interval
  42. ///< insertion in the painted attribute. This primary useful for secondary
  43. ///< labels.
  44. void Update();
  45. ///< Updates all displayed information and repaints the area.
  46. void MoveToStart();
  47. ///< Moves the time to the time of the first sample point and emits signal in order
  48. ///< to sync all other widgets. If by the time of the call no data are present
  49. ///< it does nothing.
  50. protected:
  51. void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
  52. void PaintBase(QPainter *painter);
  53. void PaintAreas(QPainter *painter);
  54. ///< Paints areas on the background with color.
  55. void PaintVideoTime(QPainter *painter);
  56. ///< Paints the position of the video on window.
  57. virtual void PaintLine(QPainter *painter);
  58. ///< Paints the line on the canvas.
  59. void PaintGrid(QPainter *painter);
  60. ///< Paints grid lines on the canvas.
  61. void PaintText(QPainter *painter);
  62. ///< Paints axes limits on the canvas.
  63. void PaintLegend(QPainter *painter);
  64. ///< Paints legend for colors and values.
  65. void mousePressEvent(QMouseEvent *event);
  66. ///< Handles the press of mouse buttons.
  67. void mouseDoubleClickEvent(QMouseEvent *event);
  68. ///< Handles left mouse double click. It inserts an interval based on the
  69. ///< on the interval and paint attributes. It works with SetIntervalAtt(int)
  70. void mouseReleaseEvent(QMouseEvent *event);
  71. ///< Handles the realese of mouse buttons.
  72. void mouseMoveEvent(QMouseEvent *event);
  73. ///< Mouse tracking is on when a button is clicked.
  74. void wheelEvent(QWheelEvent *event);
  75. ///< Tracks mouse wheel events.
  76. void keyPressEvent(QKeyEvent *event);
  77. ///< Handles keyboard key presses.
  78. void ExpandIntLeft(int intPointer, double newLimit);
  79. void ExpandIntRight(int intPointer, double newLimit);
  80. void DeleteInterval(void);
  81. ///< Sets the selected interval to unassigned.
  82. void InsertInterval(void);
  83. ///< Insert new interval to the selected interval at the click point.
  84. ///< The new interval has duration of 80ms.
  85. void ChangeInterval(int newValue);
  86. ///< If the mouse is clicked and a number is typed then the interval
  87. ///< is changed to the new eye movement.
  88. void CalculateIntervals(void);
  89. ///< Calculates the intervals for the given time window and
  90. ///< sets the interval pointer to the interval of the left click position
  91. ///< if available.
  92. void ClearEventVariables(void);
  93. ///< Clears the state of all local variables.
  94. void InitializeLegend();
  95. void InitializeLegend(int attInd);
  96. int m_gridTickY; // tick on y axis
  97. int m_gridTickX; // tick on x axis
  98. int m_windowDuration; // duration of window in us
  99. int m_windowMaxVal; // max value to display
  100. int m_windowSecMaxVal; // max value to display for secondary data
  101. int m_winStartTime; // start time of the window
  102. int m_currentTime;
  103. Arff *m_pArff; // pointer to Arff
  104. Arff *m_pXYArff; // pointer to Arff only for valid XY
  105. int m_timeInd;
  106. int m_xInd;
  107. int m_yInd;
  108. Arff *m_pXYSecArff; // Arff pointer for secondary data for valid XY
  109. int m_pointerStart; // starting DataPoint for current time
  110. int m_pointerEnd; // end point for end of window
  111. int m_intervalLength; // amount of samples in between
  112. int m_attToPaint; // pointer of the attribute to paint as background
  113. int m_intervalAtt;
  114. // event specific variables
  115. bool m_IsPressedLeft; // indicates if the left button is pressed
  116. double m_LeftPressPosition; // position of the left press relative to widget
  117. double m_DoubleLeftPressPos;
  118. int m_RightPressPosition; // position of the left press relative to widget
  119. vector<int> m_vIntervals; // each element represents the start of interval
  120. vector<string> m_vLegendCaption;
  121. vector<vector<int>> m_vLegendColors;
  122. int m_colorNum;
  123. int m_selectedEyeMovement; // when numbers are pressed a specific eye movement is selected
  124. double m_prevDragPosX;
  125. };
  126. #endif /*__ARFFWIDGETBASE_H__*/