ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ecvWaveformDialog.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 // Local
11 #include "ecvPickingListener.h"
12 
13 // Qt
14 #include <QDialog>
15 
16 // QCustomPlot
17 #include <qcustomplot.h>
18 
19 class QCPArrow;
20 class QCPBarsWithText;
21 class QCPColoredBars;
22 class QCPHiddenArea;
23 class QCPTextElement;
24 
25 class Ui_WaveDialog;
26 class ccPointCloud;
27 class ccPickingHub;
28 
30 class ccWaveWidget : public QCustomPlot {
31  Q_OBJECT
32 
33 public:
35  explicit ccWaveWidget(QWidget* parent = nullptr);
36 
38  ~ccWaveWidget() override;
39 
41  void setTitle(const QString& str);
43  void setAxisLabels(const QString& xLabel, const QString& yLabel);
44 
46  void init(ccPointCloud* cloud,
47  unsigned pointIndex,
48  bool logScale,
49  double maxValue = 0.0);
50 
52  void clear();
54  void refresh();
55 
56 protected: // methods
57  // mouse events handling
58  void mousePressEvent(QMouseEvent* event) override;
59  void mouseMoveEvent(QMouseEvent* event) override;
60  void resizeEvent(QResizeEvent* event) override;
61 
63  void clearInternal();
64 
66  void updateCurveWidth(int w, int h);
67 
68 protected: // attributes
69  // Title
70  QString m_titleStr;
71  QCPTextElement* m_titlePlot;
72 
74  QCPGraph* m_curve;
75  std::vector<double> m_curveValues;
76  double m_dt;
77  double m_minA, m_maxA;
78  double m_echoPos;
79 
80  // vertical indicator
84 
85  // Peak marker
87 
90 
93 };
94 
96 class ccWaveDialog : public QDialog, public ccPickingListener {
97  Q_OBJECT
98 
99 public:
101  explicit ccWaveDialog(ccPointCloud* cloud,
102  ccPickingHub* pickingHub,
103  QWidget* parent = nullptr);
105  ~ccWaveDialog() override;
106 
108  inline ccWaveWidget* waveWidget() { return m_widget; }
109 
110  // inherited from ccPickingListener
111  virtual void onItemPicked(const PickedItem& pi) override;
112 
113 protected:
114  void onPointIndexChanged(int);
115  void updateCurrentWaveform();
116  void onPointPickingButtonToggled(bool);
117  void onExportWaveAsCSV();
118 
119 protected: // members
122 
125 
128 
130  Ui_WaveDialog* m_gui;
131 
133  double m_waveMax;
134 };
MouseEvent event
QCustomPlot: small arrows at the bottom.
QCustomPlot: vertical bar with text along side.
QCustomPlot: colored histogram.
QCustomPlot: greyed areas.
Point/triangle picking hub.
Definition: ecvPickingHub.h:29
Point/triangle picking listener interface.
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
Waveform dialog.
ccPickingHub * m_pickingHub
Picking hub.
double m_waveMax
Maximum wave amplitude (for all points)
ccWaveWidget * m_widget
Wave widget.
ccWaveDialog(ccPointCloud *cloud, ccPickingHub *pickingHub, QWidget *parent=nullptr)
Default constructor.
~ccWaveDialog() override
Destructor.
void updateCurrentWaveform()
ccPointCloud * m_cloud
Associated point cloud.
void onPointPickingButtonToggled(bool)
Ui_WaveDialog * m_gui
GUI.
virtual void onItemPicked(const PickedItem &pi) override
Method called whenever an item is picked.
void onPointIndexChanged(int)
ccWaveWidget * waveWidget()
Returns the encapsulated widget.
Waveform widget.
void updateCurveWidth(int w, int h)
Updates overlay curve width depending on the widget display size.
QFont m_renderingFont
Rendering font.
std::vector< double > m_curveValues
void setAxisLabels(const QString &xLabel, const QString &yLabel)
Sets axis labels.
~ccWaveWidget() override
Destructor.
QCPBarsWithText * m_vertBar
QCPBarsWithText * m_peakBar
QCPTextElement * m_titlePlot
ccWaveWidget(QWidget *parent=nullptr)
Default constructor.
void init(ccPointCloud *cloud, unsigned pointIndex, bool logScale, double maxValue=0.0)
Computes the wave (curve) from a given point waveform.
bool m_drawVerticalIndicator
void resizeEvent(QResizeEvent *event) override
void mousePressEvent(QMouseEvent *event) override
QCPGraph * m_curve
Wave curve.
double m_verticalIndicatorPositionPercent
void clear()
Clears the display.
void setTitle(const QString &str)
Sets title.
void mouseMoveEvent(QMouseEvent *event) override
QPoint m_lastMouseClick
Last mouse click.
void refresh()
Updates the display.