24 #include <QCloseEvent>
33 #include "ui_waveDlg.h"
36 : QCustomPlot(parent),
44 m_drawVerticalIndicator(false),
45 m_verticalIndicatorPositionPercent(0.0),
47 m_lastMouseClick(0, 0) {
48 setWindowTitle(
"Waveform");
49 setFocusPolicy(Qt::StrongFocus);
51 setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
53 setAutoAddPlottableToLegend(
false);
61 assert(xAxis && yAxis);
62 xAxis->setTickLength(0, 5);
63 xAxis->setSubTickLength(0, 3);
64 yAxis->setTickLength(0, 5);
65 yAxis->setSubTickLength(0, 3);
75 void ccWaveWidget::clearInternal() {
84 if (xLabel.isNull()) {
85 xAxis->setVisible(
false);
88 xAxis->setLabel(xLabel);
89 xAxis->setVisible(
true);
92 if (xLabel.isNull()) {
93 yAxis->setVisible(
false);
96 yAxis->setLabel(yLabel);
97 yAxis->setVisible(
true);
101 static double AbsLog(
double c) {
return (c >= 0 ? log1p(c) : -log1p(-c)); }
109 if (!cloud || !cloud->
hasFWF()) {
125 }
catch (
const std::bad_alloc&) {
163 plotLayout()->insertRow(0);
182 this->clearPlottables();
186 if (curveSize != 0) {
187 QVector<double> x(curveSize);
188 QVector<double> y(curveSize);
190 for (
int i = 0; i < curveSize; ++i) {
218 QVector<double> keyData(1);
219 QVector<double> valueData(1);
222 int curvePos =
static_cast<int>(curveSize *
224 keyData[0] = curvePos *
m_dt;
230 QString valueStr = QString(
"Sample %0").arg(curvePos);
232 valueStr = QString(
"= %0").arg(
247 QVector<double> keyData(1);
248 QVector<double> valueData(1);
269 int penWidth =
std::max(w, h) / 200;
270 if (
m_curve->pen().width() != penWidth) {
272 pen.setWidth(penWidth);
279 QCustomPlot::resizeEvent(
event);
293 if (
event->buttons() & Qt::LeftButton) {
296 if (roi.contains(
event->pos(),
false)) {
299 static_cast<double>(
event->x() - roi.x()) / roi.width();
311 : QDialog(parent, Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint),
314 m_pickingHub(pickingHub),
315 m_gui(new Ui_WaveDialog),
317 m_gui->setupUi(
this);
319 QHBoxLayout* hboxLayout =
new QHBoxLayout(
m_gui->waveFrame);
321 hboxLayout->setContentsMargins(0, 0, 0, 0);
322 m_gui->waveFrame->setLayout(hboxLayout);
324 if (cloud && cloud->
size()) {
325 m_gui->pointIndexSpinBox->setMaximum(
static_cast<int>(cloud->
size()));
326 m_gui->pointIndexSpinBox->setSuffix(
327 QString(
" / %1").arg(cloud->
size() - 1));
334 QString(
"[ccWaveDialog] Cloud '%1': max FWF amplitude = %2")
338 CVLog::Warning(
"[ccWaveDialog] Input cloud has no valid FWF data");
342 connect(
m_gui->pointIndexSpinBox,
343 static_cast<void (QSpinBox::*)(
int)
>(&QSpinBox::valueChanged),
this,
345 connect(
m_gui->logScaleCheckBox, &QCheckBox::toggled,
this,
347 connect(
m_gui->fixedAmplitudeCheckBox, &QCheckBox::toggled,
this,
349 connect(
m_gui->pointPickingToolButton, &QToolButton::toggled,
this,
351 connect(
m_gui->saveWaveToolButton, &QToolButton::clicked,
this,
353 connect(
this, &QDialog::finished, [&]() {
354 m_gui->pointPickingToolButton->setChecked(
false);
374 m_cloud,
static_cast<unsigned>(index),
375 m_gui->logScaleCheckBox->isChecked(),
383 m_gui->pointIndexSpinBox->setValue(
static_cast<int>(pi.
itemIndex));
400 "Another tool is currently using the point picking "
401 "mechanism.\nYou'll have to close it first.");
402 m_gui->pointPickingToolButton->blockSignals(
true);
403 m_gui->pointPickingToolButton->setChecked(
false);
404 m_gui->pointPickingToolButton->blockSignals(
false);
418 int pointIndex =
m_gui->pointIndexSpinBox->value();
437 QString currentPath =
441 currentPath += QString(
"/") + QString(
"waveform_%1.csv").arg(pointIndex);
444 QString
filename = QFileDialog::getSaveFileName(
this,
"Select output file",
445 currentPath,
"*.csv");
static bool Warning(const char *format,...)
Prints out a formatted warning message in console.
static bool Print(const char *format,...)
Prints out a formatted message in console.
static bool Error(const char *format,...)
Display an error dialog with formatted message.
QCustomPlot: vertical bar with text along side.
void setText(QString text)
void setTextAlignment(bool left)
void appendText(QString text)
virtual QString getName() const
Returns object name.
Point/triangle picking hub.
void removeListener(ccPickingListener *listener, bool autoStopPickingIfLast=true)
Removes a listener.
bool addListener(ccPickingListener *listener, bool exclusive=false, bool autoStartPicking=true, ecvDisplayTools::PICKING_MODE mode=ecvDisplayTools::POINT_OR_TRIANGLE_PICKING)
Adds a listener.
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
std::vector< ccWaveform > & waveforms()
Gives access to the associated FWF data.
ccWaveformProxy waveformProxy(unsigned index) const
Returns a proxy on a given waveform.
bool hasFWF() const
Returns whether the cloud has associated Full WaveForm data.
bool computeFWFAmplitude(double &minVal, double &maxVal, ecvProgressDialog *pDlg=nullptr) const
Computes the maximum amplitude of all associated waveforms.
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)
unsigned size() const override
static const ParamStruct & Parameters()
Returns the stored values of each parameter.
static const QString CurrentPath()
static const QString SaveFile()
Graphical progress indicator (thread-safe)
constexpr Rgb red(MAX, 0, 0)
constexpr Rgb blue(0, 0, MAX)
QString defaultDocPath()
Shortcut for getting the documents location path.