Skip to content

Commit

Permalink
REC: added browse button for selecting the root folder of the measure…
Browse files Browse the repository at this point in the history
…ment(s) (eclipse-ecal#849)

Co-authored-by: Florian Reimold <[email protected]>
  • Loading branch information
MihaiIMuraru and FlorianReimold authored Nov 14, 2022
1 parent 21f9f70 commit 9205adc
Show file tree
Hide file tree
Showing 3 changed files with 150 additions and 83 deletions.
34 changes: 34 additions & 0 deletions app/rec/rec_gui/src/widgets/config_widget/config_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "config_widget.h"

#include <QDir>
#include <QFileDialog>
#include "qecalrec.h"

#include <EcalParser/EcalParser.h>
Expand All @@ -35,6 +36,7 @@ ConfigWidget::ConfigWidget(QWidget *parent)
connect(ui_.description_textedit, &QTextEdit::textChanged, QEcalRec::instance(), [this]() {QEcalRec::instance()->setDescription(ui_.description_textedit->toPlainText().toStdString()); });
connect(ui_.max_file_size_spinbox, static_cast<void (QSpinBox:: *)(int)>(&QSpinBox::valueChanged), QEcalRec::instance(), [](int megabytes) {QEcalRec::instance()->setMaxFileSizeMib(megabytes); });
connect(ui_.one_file_per_topic_checkbox, &QCheckBox::stateChanged, QEcalRec::instance(), [this]() {QEcalRec::instance()->setOneFilePerTopicEnabled(ui_.one_file_per_topic_checkbox->isChecked()); });
connect(ui_.user_meass_rec_path_toolButton, &QToolButton::clicked, this, &ConfigWidget::userRecPathButtonPressed);

connect(ui_.refresh_path_preview_button, &QAbstractButton::clicked, QEcalRec::instance(), [this]() { updatePathPreviewAndWarningLabel(); });

Expand All @@ -44,6 +46,7 @@ ConfigWidget::ConfigWidget(QWidget *parent)
connect(QEcalRec::instance(), &QEcalRec::descriptionChangedSignal, this, &ConfigWidget::descriptionChanged);
connect(QEcalRec::instance(), &QEcalRec::oneFilePerTopicEnabledChangedSignal, this, &ConfigWidget::oneFilePerTopicEnabledChanged);


measurementRootDirectoryChanged (QEcalRec::instance()->measRootDir());
measurementNameChanged (QEcalRec::instance()->measName());
descriptionChanged (QEcalRec::instance()->description());
Expand Down Expand Up @@ -133,6 +136,37 @@ void ConfigWidget::descriptionChanged(const std::string& description)
}
}

void ConfigWidget::userRecPathButtonPressed()
{
auto parsed_meas_root = QString::fromStdString(EcalParser::Evaluate(ui_.measurement_directory_lineedit->text().toStdString(), true, std::chrono::system_clock::now()));
QString root_path;
QDir root(parsed_meas_root);

if (root.exists() && !parsed_meas_root.isEmpty())
{
if (parsed_meas_root[parsed_meas_root.size() - 1] != "\\" && parsed_meas_root[parsed_meas_root.size() - 1] != "/")
root_path = parsed_meas_root + "/";
else
root_path = parsed_meas_root;
}
else
{
auto current_dir = QDir::currentPath().split("/");
#ifdef __linux__
current_dir.removeAll("");
root_path = "/" + current_dir[0];
#else //linux
root_path = current_dir[0].append("/");
#endif
}
QString user_path = QFileDialog::getExistingDirectory(this, "Choose root recording folder...", root_path, QFileDialog::ShowDirsOnly);
if (!user_path.isEmpty())
{
ui_.measurement_directory_lineedit->setText(user_path);
measurementRootDirectoryChanged(user_path.toStdString());
}
}

void ConfigWidget::showEvent(QShowEvent* /*event*/)
{
if (first_show_event_)
Expand Down
1 change: 1 addition & 0 deletions app/rec/rec_gui/src/widgets/config_widget/config_widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ private slots:
void maxFileSizeChanged (unsigned int megabytes);
void oneFilePerTopicEnabledChanged (bool enabled);
void descriptionChanged (const std::string& description);
void userRecPathButtonPressed ();

protected:
void showEvent(QShowEvent *event) override;
Expand Down
198 changes: 115 additions & 83 deletions app/rec/rec_gui/src/widgets/config_widget/config_widget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>515</width>
<height>305</height>
<width>810</width>
<height>501</height>
</rect>
</property>
<property name="windowTitle">
Expand All @@ -26,6 +26,60 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item row="4" column="3">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QSpinBox" name="max_file_size_spinbox">
<property name="minimumSize">
<size>
<width>10</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Maximum HDF-5 file size (will cause the recorder to split the measurement into multiple files)</string>
</property>
<property name="keyboardTracking">
<bool>false</bool>
</property>
<property name="suffix">
<string> MiB</string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>2147483647</number>
</property>
<property name="singleStep">
<number>10</number>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="one_file_per_topic_checkbox">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>10</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Create a separate HDF5 file for each eCAL topic</string>
</property>
<property name="text">
<string>1 File per topic</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="0">
<widget class="QLabel" name="measurement_directory_label">
<property name="minimumSize">
Expand All @@ -39,33 +93,36 @@
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QEcalParserLineEdit" name="measurement_directory_lineedit">
<item row="8" column="0" colspan="4">
<widget class="QEcalParserTextEdit" name="description_textedit">
<property name="minimumSize">
<size>
<width>10</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Measurement root directory</string>
<string>Description saved to the doc/description.txt file</string>
</property>
<property name="acceptRichText">
<bool>false</bool>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="max_file_size_label">
<item row="2" column="0">
<widget class="QLabel" name="measurement_name_label">
<property name="minimumSize">
<size>
<width>10</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Max file size:</string>
<string>Meas name:</string>
</property>
</widget>
</item>
<item row="6" column="0" colspan="3">
<item row="7" column="0" colspan="4">
<widget class="QLabel" name="description_label">
<property name="minimumSize">
<size>
Expand All @@ -78,34 +135,7 @@
</property>
</widget>
</item>
<item row="1" column="2">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="measurement_name_warning">
<property name="toolTip">
<string>The measurement name on this PC is empty. This will cause measurements to not be uploadable.</string>
</property>
<property name="text">
<string>Warning label</string>
</property>
</widget>
</item>
<item>
<widget class="QEcalParserLineEdit" name="measurement_name_lineedit">
<property name="minimumSize">
<size>
<width>10</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Measurement name (will create a directory inside the measurement root directory)</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="2">
<item row="3" column="3">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>1</number>
Expand Down Expand Up @@ -151,84 +181,83 @@
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QLabel" name="measurement_name_label">
<item row="2" column="3">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="measurement_name_warning">
<property name="toolTip">
<string>The measurement name on this PC is empty. This will cause measurements to not be uploadable.</string>
</property>
<property name="text">
<string>Warning label</string>
</property>
</widget>
</item>
<item>
<widget class="QEcalParserLineEdit" name="measurement_name_lineedit">
<property name="minimumSize">
<size>
<width>10</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Measurement name (will create a directory inside the measurement root directory)</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="0">
<widget class="QLabel" name="max_file_size_label">
<property name="minimumSize">
<size>
<width>10</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Meas name:</string>
<string>Max file size:</string>
</property>
</widget>
</item>
<item row="7" column="0" colspan="3">
<widget class="QEcalParserTextEdit" name="description_textedit">
<property name="minimumSize">
<size>
<width>10</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Description saved to the doc/description.txt file</string>
</property>
<property name="acceptRichText">
<bool>false</bool>
<item row="0" column="3">
<layout class="QHBoxLayout" name="horizontalLayout_6" stretch="0,0">
<property name="spacing">
<number>6</number>
</property>
</widget>
</item>
<item row="3" column="2">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QSpinBox" name="max_file_size_spinbox">
<widget class="QEcalParserLineEdit" name="measurement_directory_lineedit">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>10</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Maximum HDF-5 file size (will cause the recorder to split the measurement into multiple files)</string>
</property>
<property name="keyboardTracking">
<bool>false</bool>
</property>
<property name="suffix">
<string> MiB</string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>2147483647</number>
</property>
<property name="singleStep">
<number>10</number>
<string>Measurement root directory</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="one_file_per_topic_checkbox">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<widget class="QToolButton" name="user_meass_rec_path_toolButton">
<property name="minimumSize">
<size>
<width>10</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Create a separate HDF5 file for each eCAL topic</string>
<string>Select root path </string>
</property>
<property name="text">
<string>1 File per topic</string>
<string>...</string>
</property>
</widget>
</item>
Expand All @@ -251,8 +280,11 @@
</customwidgets>
<tabstops>
<tabstop>measurement_directory_lineedit</tabstop>
<tabstop>user_meass_rec_path_toolButton</tabstop>
<tabstop>measurement_name_lineedit</tabstop>
<tabstop>refresh_path_preview_button</tabstop>
<tabstop>max_file_size_spinbox</tabstop>
<tabstop>one_file_per_topic_checkbox</tabstop>
<tabstop>description_textedit</tabstop>
</tabstops>
<resources>
Expand Down

0 comments on commit 9205adc

Please sign in to comment.