Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(tier4_screen_capture_rviz_plugin): apply clang-tidy #1649

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ using std::placeholders::_2;
void setFormatDate(QLabel * line, double time)
{
char buffer[128];
time_t seconds = static_cast<time_t>(time);
auto seconds = static_cast<time_t>(time);
strftime(buffer, sizeof(buffer), "%Y-%m-%d-%H-%M-%S", localtime(&seconds));
line->setText(QString(buffer));
}
Expand Down Expand Up @@ -71,7 +71,7 @@ AutowareScreenCapturePanel::AutowareScreenCapturePanel(QWidget * parent)
v_layout->addLayout(video_cap_layout);
setLayout(v_layout);
}
QTimer * timer = new QTimer(this);
auto * timer = new QTimer(this);
connect(timer, &QTimer::timeout, this, &AutowareScreenCapturePanel::update);
timer->start(1000);
capture_timer_ = new QTimer(this);
Expand All @@ -80,8 +80,8 @@ AutowareScreenCapturePanel::AutowareScreenCapturePanel(QWidget * parent)
}

void AutowareScreenCapturePanel::onCaptureTrigger(
[[maybe_unused]] const std::shared_ptr<std_srvs::srv::Trigger::Request> req,
const std::shared_ptr<std_srvs::srv::Trigger::Response> res)
[[maybe_unused]] const std_srvs::srv::Trigger::Request::SharedPtr req,
const std_srvs::srv::Trigger::Response::SharedPtr res)
{
onClickVideoCapture();
res->success = true;
Expand All @@ -103,7 +103,6 @@ void AutowareScreenCapturePanel::onClickScreenCapture()
const std::string time_text = "capture/" + ros_time_label_->text().toStdString();
getDisplayContext()->getViewManager()->getRenderPanel()->getRenderWindow()->captureScreenShot(
time_text + ".png");
return;
}

void AutowareScreenCapturePanel::onClickVideoCapture()
Expand All @@ -112,7 +111,7 @@ void AutowareScreenCapturePanel::onClickVideoCapture()
try {
const QWidgetList top_level_widgets = QApplication::topLevelWidgets();
for (QWidget * widget : top_level_widgets) {
QMainWindow * main_window_candidate = qobject_cast<QMainWindow *>(widget);
auto * main_window_candidate = qobject_cast<QMainWindow *>(widget);
if (main_window_candidate) {
main_window_ = main_window_candidate;
}
Expand Down Expand Up @@ -153,7 +152,6 @@ void AutowareScreenCapturePanel::onClickVideoCapture()
state_ = State::WAITING_FOR_CAPTURE;
break;
}
return;
}

void AutowareScreenCapturePanel::onTimer()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,16 @@ class AutowareScreenCapturePanel : public rviz_common::Panel

public:
explicit AutowareScreenCapturePanel(QWidget * parent = nullptr);
~AutowareScreenCapturePanel();
~AutowareScreenCapturePanel() override;
void update();
void onInitialize() override;
void createWallTimer();
void onTimer();
void save(rviz_common::Config config) const override;
void load(const rviz_common::Config & config) override;
void onCaptureTrigger(
const std::shared_ptr<std_srvs::srv::Trigger::Request> req,
const std::shared_ptr<std_srvs::srv::Trigger::Response> res);
const std_srvs::srv::Trigger::Request::SharedPtr req,
const std_srvs::srv::Trigger::Response::SharedPtr res);

public Q_SLOTS:
void onClickScreenCapture();
Expand All @@ -75,16 +75,16 @@ public Q_SLOTS:
QPushButton * capture_to_mp4_button_ptr_;
QSpinBox * capture_hz_;
QTimer * capture_timer_;
QMainWindow * main_window_;
QMainWindow * main_window_{nullptr};
enum class State { WAITING_FOR_CAPTURE, CAPTURING };
State state_;
std::string capture_file_name_;
bool is_capture_;
bool is_capture_{false};
cv::VideoWriter writer_;
cv::Size current_movie_size_;
std::vector<cv::Mat> image_vec_;

std::string stateToString(const State & state)
static std::string stateToString(const State & state)
{
if (state == State::WAITING_FOR_CAPTURE) {
return "waiting for capture";
Expand Down