ccWaveformDialog.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. //##########################################################################
  2. //# #
  3. //# CLOUDCOMPARE #
  4. //# #
  5. //# This program is free software; you can redistribute it and/or modify #
  6. //# it under the terms of the GNU General Public License as published by #
  7. //# the Free Software Foundation; version 2 or later of the License. #
  8. //# #
  9. //# This program is distributed in the hope that it will be useful, #
  10. //# but WITHOUT ANY WARRANTY; without even the implied warranty of #
  11. //# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
  12. //# GNU General Public License for more details. #
  13. //# #
  14. //# COPYRIGHT: CNRS / OSUR #
  15. //# #
  16. //##########################################################################
  17. #ifndef CC_WAVEFORM_DIALOG_HEADER
  18. #define CC_WAVEFORM_DIALOG_HEADER
  19. //Local
  20. #include "ccPickingListener.h"
  21. #include "cc2DLabel.h"
  22. //Qt
  23. #include <QDialog>
  24. //QCustomPlot
  25. #include "ccQCustomPlot.h"
  26. class QCPArrow;
  27. class QCPBarsWithText;
  28. class QCPColoredBars;
  29. class QCPHiddenArea;
  30. class QCPTextElement;
  31. class Ui_WaveDialog;
  32. class ccPointCloud;
  33. class ccPickingHub;
  34. //! Waveform widget
  35. class ccWaveWidget : public QCustomPlot
  36. {
  37. Q_OBJECT
  38. public:
  39. //! Default constructor
  40. explicit ccWaveWidget(QWidget *parent = nullptr);
  41. //! Destructor
  42. ~ccWaveWidget() override;
  43. //! Sets title
  44. void setTitle(const QString& str);
  45. //! Sets axis labels
  46. void setAxisLabels(const QString& xLabel, const QString& yLabel);
  47. //! Computes the wave (curve) from a given point waveform
  48. void init(ccPointCloud* cloud, unsigned pointIndex, bool logScale, double maxValue = 0.0);
  49. //! Clears the display
  50. void clear();
  51. //! Updates the display
  52. void refresh();
  53. protected: //methods
  54. //mouse events handling
  55. void mousePressEvent(QMouseEvent *event) override;
  56. void mouseMoveEvent(QMouseEvent *event) override;
  57. void resizeEvent(QResizeEvent * event) override;
  58. //! Clears internal structures
  59. void clearInternal();
  60. //! Updates overlay curve width depending on the widget display size
  61. void updateCurveWidth(int w, int h);
  62. protected: //attributes
  63. //Title
  64. QString m_titleStr;
  65. QCPTextElement* m_titlePlot;
  66. //! Wave curve
  67. QCPGraph* m_curve;
  68. std::vector<double> m_curveValues;
  69. double m_dt;
  70. double m_minA, m_maxA;
  71. double m_echoPos;
  72. //vertical indicator
  73. QCPBarsWithText* m_vertBar;
  74. bool m_drawVerticalIndicator;
  75. double m_verticalIndicatorPositionPercent;
  76. //Peak marker
  77. QCPBarsWithText* m_peakBar;
  78. //! Rendering font
  79. QFont m_renderingFont;
  80. //! Last mouse click
  81. QPoint m_lastMouseClick;
  82. };
  83. //! Waveform dialog
  84. class ccWaveDialog : public QDialog, public ccPickingListener
  85. {
  86. Q_OBJECT
  87. public:
  88. //! Default constructor
  89. explicit ccWaveDialog(ccPointCloud* cloud, ccPickingHub* pickingHub, QWidget* parent = nullptr);
  90. //! Destructor
  91. ~ccWaveDialog() override;
  92. //! Returns the encapsulated widget
  93. inline ccWaveWidget* waveWidget() { return m_widget; }
  94. //inherited from ccPickingListener
  95. virtual void onItemPicked(const PickedItem& pi) override;
  96. protected:
  97. void onPointIndexChanged(int);
  98. void add2DLabel(ccPointCloud* cloud, unsigned int pointIndex);
  99. void updateCurrentWaveform();
  100. void onPointPickingButtonToggled(bool);
  101. void onExportWaveAsCSV();
  102. protected: //members
  103. //! Associated point cloud
  104. ccPointCloud* m_cloud;
  105. //! Wave widget
  106. ccWaveWidget* m_widget;
  107. //! Picking hub
  108. ccPickingHub* m_pickingHub;
  109. //! GUI
  110. Ui_WaveDialog* m_gui;
  111. //! Maximum wave amplitude (for all points)
  112. double m_waveMax;
  113. //! A 2D label used to visualize the point whose waveform is displayed
  114. std::shared_ptr<cc2DLabel> m_label;
  115. //! The display associated with the cloud whose waveforms are displayed
  116. ccGenericGLDisplay* m_display;
  117. };
  118. #endif //CC_WAVEFORM_DIALOG_HEADER