mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-18 00:49:19 +02:00
tie camera preview to training report
This commit is contained in:
@@ -63,7 +63,6 @@ void driver_ui::render_menu_contents() {
|
|||||||
ImGui::MenuItem(m_mappanel.name().c_str(), "Tab", &m_mappanel.is_open);
|
ImGui::MenuItem(m_mappanel.name().c_str(), "Tab", &m_mappanel.is_open);
|
||||||
ImGui::MenuItem(m_vehiclelist.name().c_str(), nullptr, &m_vehiclelist.is_open);
|
ImGui::MenuItem(m_vehiclelist.name().c_str(), nullptr, &m_vehiclelist.is_open);
|
||||||
ImGui::MenuItem(m_trainingcardpanel.name().c_str(), nullptr, &m_trainingcardpanel.is_open);
|
ImGui::MenuItem(m_trainingcardpanel.name().c_str(), nullptr, &m_trainingcardpanel.is_open);
|
||||||
ImGui::MenuItem(m_cameraviewpanel.name().c_str(), nullptr, &m_cameraviewpanel.is_open);
|
|
||||||
if (DebugModeFlag)
|
if (DebugModeFlag)
|
||||||
ImGui::MenuItem(m_perfgraphpanel.name().c_str(), nullptr, &m_perfgraphpanel.is_open);
|
ImGui::MenuItem(m_perfgraphpanel.name().c_str(), nullptr, &m_perfgraphpanel.is_open);
|
||||||
|
|
||||||
@@ -226,6 +225,11 @@ driver_ui::set_cursor( bool const Visible ) {
|
|||||||
// render() subclass details
|
// render() subclass details
|
||||||
void
|
void
|
||||||
driver_ui::render_() {
|
driver_ui::render_() {
|
||||||
|
const std::string *rec_name = m_trainingcardpanel.is_recording();
|
||||||
|
if (rec_name && !m_cameraviewpanel.is_open)
|
||||||
|
m_cameraviewpanel.rec_name = *rec_name;
|
||||||
|
m_cameraviewpanel.is_open = !!rec_name;
|
||||||
|
|
||||||
// pause/quit modal
|
// pause/quit modal
|
||||||
auto const popupheader { STR_C("Simulation Paused") };
|
auto const popupheader { STR_C("Simulation Paused") };
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ drivingaid_panel::update() {
|
|||||||
|
|
||||||
if( false == is_open ) { return; }
|
if( false == is_open ) { return; }
|
||||||
|
|
||||||
text_lines.clear();
|
text_lines.clear();
|
||||||
|
|
||||||
auto const *train { simulation::Train };
|
auto const *train { simulation::Train };
|
||||||
auto const *controlled { ( train ? train->Dynamic() : nullptr ) };
|
auto const *controlled { ( train ? train->Dynamic() : nullptr ) };
|
||||||
|
|||||||
@@ -27,13 +27,19 @@ ui::cameraview_panel::~cameraview_panel() {
|
|||||||
|
|
||||||
void ui::cameraview_panel::render()
|
void ui::cameraview_panel::render()
|
||||||
{
|
{
|
||||||
if (!is_open)
|
if (!is_open) {
|
||||||
exit_thread = true;
|
exit_thread = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (is_open)
|
ImGui::SetNextWindowSizeConstraints(ImVec2(200, 200), ImVec2(2500, 2500), cameraview_window_callback);
|
||||||
ImGui::SetNextWindowSizeConstraints(ImVec2(200, 200), ImVec2(2500, 2500), cameraview_window_callback);
|
|
||||||
|
|
||||||
ui_panel::render();
|
auto const panelname{(title.empty() ? m_name : title) + "###" + m_name};
|
||||||
|
if (ImGui::Begin(panelname.c_str())) {
|
||||||
|
render_contents();
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ui::cameraview_panel::render_contents()
|
void ui::cameraview_panel::render_contents()
|
||||||
@@ -82,7 +88,16 @@ void ui::cameraview_panel::render_contents()
|
|||||||
|
|
||||||
void ui::cameraview_panel::workthread_func()
|
void ui::cameraview_panel::workthread_func()
|
||||||
{
|
{
|
||||||
piped_proc proc(Global.extcam_cmd);
|
std::string cmdline = Global.extcam_cmd;
|
||||||
|
|
||||||
|
if (!rec_name.empty()) {
|
||||||
|
const std::string magic{"{RECORD}"};
|
||||||
|
size_t pos = cmdline.find(magic);
|
||||||
|
if (pos != -1)
|
||||||
|
cmdline.replace(pos, magic.size(), rec_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
piped_proc proc(cmdline);
|
||||||
|
|
||||||
size_t frame_size = Global.extcam_res.x * Global.extcam_res.y * 3;
|
size_t frame_size = Global.extcam_res.x * Global.extcam_res.y * 3;
|
||||||
uint8_t *read_buffer = new uint8_t[frame_size];
|
uint8_t *read_buffer = new uint8_t[frame_size];
|
||||||
|
|||||||
@@ -27,5 +27,7 @@ class cameraview_panel : public ui_panel
|
|||||||
|
|
||||||
void render() override;
|
void render() override;
|
||||||
void render_contents() override;
|
void render_contents() override;
|
||||||
|
|
||||||
|
std::string rec_name;
|
||||||
};
|
};
|
||||||
} // namespace ui
|
} // namespace ui
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ void trainingcard_panel::clear()
|
|||||||
{
|
{
|
||||||
start_time_wall.reset();
|
start_time_wall.reset();
|
||||||
state.store(0);
|
state.store(0);
|
||||||
|
recording_timestamp.clear();
|
||||||
|
|
||||||
place.clear();
|
place.clear();
|
||||||
trainee_name.clear();
|
trainee_name.clear();
|
||||||
@@ -53,10 +54,7 @@ void trainingcard_panel::save_thread_func()
|
|||||||
tm = std::localtime(&now);
|
tm = std::localtime(&now);
|
||||||
std::string to = std::to_string(tm->tm_hour) + ":" + std::to_string(tm->tm_min);
|
std::string to = std::to_string(tm->tm_hour) + ":" + std::to_string(tm->tm_min);
|
||||||
|
|
||||||
std::string rep = std::to_string(tm->tm_year + 1900) + std::to_string(tm->tm_mon + 1) + std::to_string(tm->tm_mday)
|
std::fstream temp("reports/" + recording_timestamp + ".html", std::ios_base::out | std::ios_base::binary);
|
||||||
+ std::to_string(tm->tm_hour) + std::to_string(tm->tm_min) + "_" + std::string(trainee_name.c_str()) + "_" + std::string(instructor_name.c_str());
|
|
||||||
|
|
||||||
std::fstream temp("reports/" + rep + ".html", std::ios_base::out | std::ios_base::binary);
|
|
||||||
std::fstream input("report_template.html", std::ios_base::in | std::ios_base::binary);
|
std::fstream input("report_template.html", std::ios_base::in | std::ios_base::binary);
|
||||||
|
|
||||||
std::string in_line;
|
std::string in_line;
|
||||||
@@ -82,7 +80,7 @@ void trainingcard_panel::save_thread_func()
|
|||||||
input.close();
|
input.close();
|
||||||
temp.close();
|
temp.close();
|
||||||
|
|
||||||
state.store(EndRecording(rep));
|
state.store(EndRecording(recording_timestamp));
|
||||||
}
|
}
|
||||||
|
|
||||||
void trainingcard_panel::render_contents()
|
void trainingcard_panel::render_contents()
|
||||||
@@ -151,6 +149,9 @@ void trainingcard_panel::render_contents()
|
|||||||
if (!start_time_wall) {
|
if (!start_time_wall) {
|
||||||
if (ImGui::Button("Rozpocznij szkolenie")) {
|
if (ImGui::Button("Rozpocznij szkolenie")) {
|
||||||
start_time_wall = std::time(nullptr);
|
start_time_wall = std::time(nullptr);
|
||||||
|
std::tm *tm = std::localtime(&(*start_time_wall));
|
||||||
|
recording_timestamp = std::to_string(tm->tm_year + 1900) + std::to_string(tm->tm_mon + 1) + std::to_string(tm->tm_mday)
|
||||||
|
+ std::to_string(tm->tm_hour) + std::to_string(tm->tm_min) + "_" + std::string(trainee_name.c_str()) + "_" + std::string(instructor_name.c_str());
|
||||||
|
|
||||||
int ret = StartRecording();
|
int ret = StartRecording();
|
||||||
if (ret != 1) {
|
if (ret != 1) {
|
||||||
@@ -172,3 +173,11 @@ void trainingcard_panel::render_contents()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::string *trainingcard_panel::is_recording()
|
||||||
|
{
|
||||||
|
if (!start_time_wall)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
return &recording_timestamp;
|
||||||
|
}
|
||||||
|
|||||||
@@ -31,4 +31,7 @@ class trainingcard_panel : public ui_panel
|
|||||||
~trainingcard_panel();
|
~trainingcard_panel();
|
||||||
|
|
||||||
void render_contents() override;
|
void render_contents() override;
|
||||||
|
const std::string *is_recording();
|
||||||
|
|
||||||
|
std::string recording_timestamp;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user