mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-04-06 00:32:05 +02:00
Fix: GCodeViewer displaying inconsistent data in title and body (#12014)
* Fix: GCodeViewer displaying inconsistent data in title and body * Fix: remove actual flow info from GCodeViewer title * Refactor: reduce repetition of N/A and headers
This commit is contained in:
@@ -295,6 +295,9 @@ void GCodeViewer::SequentialView::Marker::render_position_window(const libvgcode
|
|||||||
static float last_window_width = 0.0f;
|
static float last_window_width = 0.0f;
|
||||||
static size_t last_text_length = 0;
|
static size_t last_text_length = 0;
|
||||||
static bool properties_shown = false;
|
static bool properties_shown = false;
|
||||||
|
|
||||||
|
const std::string NA_TXT = _u8L("N/A");
|
||||||
|
const char* NA_CSTR = NA_TXT.c_str();
|
||||||
|
|
||||||
if (viewer != nullptr) {
|
if (viewer != nullptr) {
|
||||||
ImGuiWrapper& imgui = *wxGetApp().imgui();
|
ImGuiWrapper& imgui = *wxGetApp().imgui();
|
||||||
@@ -316,19 +319,32 @@ void GCodeViewer::SequentialView::Marker::render_position_window(const libvgcode
|
|||||||
vertex = viewer->get_vertex_at(vertex_id);
|
vertex = viewer->get_vertex_at(vertex_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
char buf[1024];
|
const bool is_extrusion = vertex.is_extrusion();
|
||||||
|
char buf[1024]; char valBuf[32];
|
||||||
sprintf(buf, "X: %.3f, Y: %.3f, Z: %.3f Speed: %.0f ", vertex.position[0], vertex.position[1], vertex.position[2], vertex.feedrate);
|
sprintf(buf, "X: %.3f, Y: %.3f, Z: %.3f Speed: %.0f ", vertex.position[0], vertex.position[1], vertex.position[2], vertex.feedrate);
|
||||||
switch (view_type) {
|
switch (view_type) {
|
||||||
case libvgcode::EViewType::Height: {
|
case libvgcode::EViewType::Height: {
|
||||||
sprintf(buf, "%s %s%.2f", buf, _u8L("Height: ").c_str(), vertex.height);
|
if (is_extrusion)
|
||||||
|
sprintf(valBuf, "%.2f", vertex.height);
|
||||||
|
else
|
||||||
|
sprintf(valBuf, "%s", NA_CSTR);
|
||||||
|
sprintf(buf, "%s %s%s", buf, _u8L("Height: ").c_str(), valBuf);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case libvgcode::EViewType::Width: {
|
case libvgcode::EViewType::Width: {
|
||||||
sprintf(buf, "%s %s%.2f", buf, _u8L("Width: ").c_str(), vertex.width);
|
if (is_extrusion)
|
||||||
|
sprintf(valBuf, "%.2f", vertex.width);
|
||||||
|
else
|
||||||
|
sprintf(valBuf, "%s", NA_CSTR);
|
||||||
|
sprintf(buf, "%s %s%s", buf, _u8L("Width: ").c_str(), valBuf);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case libvgcode::EViewType::VolumetricFlowRate: {
|
case libvgcode::EViewType::VolumetricFlowRate: {
|
||||||
sprintf(buf, "%s %s%.2f", buf, _u8L("Flow: ").c_str(), vertex.volumetric_rate());
|
if (is_extrusion)
|
||||||
|
sprintf(valBuf, "%.2f", vertex.volumetric_rate());
|
||||||
|
else
|
||||||
|
sprintf(valBuf, "%s", NA_CSTR);
|
||||||
|
sprintf(buf, "%s %s%s", buf, _u8L("Flow: ").c_str(), valBuf);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case libvgcode::EViewType::FanSpeed: {
|
case libvgcode::EViewType::FanSpeed: {
|
||||||
@@ -353,7 +369,8 @@ void GCodeViewer::SequentialView::Marker::render_position_window(const libvgcode
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case libvgcode::EViewType::ActualVolumetricFlowRate: {
|
case libvgcode::EViewType::ActualVolumetricFlowRate: {
|
||||||
sprintf(buf, "%s %s%.2f", buf, _u8L("Actual Flow: ").c_str(), vertex.actual_volumetric_rate());
|
// Don't display the actual flow, since it only gives data for the end of a segment
|
||||||
|
// sprintf(buf, "%s %s%.2f", buf, _u8L("Actual Flow: ").c_str(), vertex.actual_volumetric_rate());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case libvgcode::EViewType::ActualSpeed: {
|
case libvgcode::EViewType::ActualSpeed: {
|
||||||
@@ -367,7 +384,7 @@ void GCodeViewer::SequentialView::Marker::render_position_window(const libvgcode
|
|||||||
ImGuiWrapper::text(std::string(buf));
|
ImGuiWrapper::text(std::string(buf));
|
||||||
if (view_type == libvgcode::EViewType::FeatureType) {
|
if (view_type == libvgcode::EViewType::FeatureType) {
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGuiWrapper::text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, to_string(vertex.role).c_str());
|
ImGuiWrapper::text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, vertex.is_extrusion() ? to_string(vertex.role).c_str() : NA_CSTR);
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if (imgui.image_button(properties_shown ? ImGui::HorizontalHide : ImGui::HorizontalShow, properties_shown ? _u8L("Hide properties") : _u8L("Show properties"))) {
|
if (imgui.image_button(properties_shown ? ImGui::HorizontalHide : ImGui::HorizontalShow, properties_shown ? _u8L("Hide properties") : _u8L("Show properties"))) {
|
||||||
@@ -390,32 +407,32 @@ void GCodeViewer::SequentialView::Marker::render_position_window(const libvgcode
|
|||||||
append_table_row(_u8L("Type"), [&vertex]() {
|
append_table_row(_u8L("Type"), [&vertex]() {
|
||||||
ImGuiWrapper::text(_u8L(to_string(vertex.type)));
|
ImGuiWrapper::text(_u8L(to_string(vertex.type)));
|
||||||
});
|
});
|
||||||
append_table_row(_u8L("Feature type"), [&vertex]() {
|
append_table_row(_u8L("Feature type"), [&vertex, NA_TXT]() {
|
||||||
std::string text;
|
std::string text;
|
||||||
if (vertex.is_extrusion())
|
if (vertex.is_extrusion())
|
||||||
text = _u8L(to_string(vertex.role));
|
text = _u8L(to_string(vertex.role));
|
||||||
else
|
else
|
||||||
text = _u8L("N/A");
|
text = NA_TXT;
|
||||||
ImGuiWrapper::text(text);
|
ImGuiWrapper::text(text);
|
||||||
});
|
});
|
||||||
append_table_row(_u8L("Width") + " (" + _u8L("mm") + ")", [&vertex, &buff]() {
|
append_table_row(_u8L("Width") + " (" + _u8L("mm") + ")", [&vertex, &buff, NA_TXT]() {
|
||||||
std::string text;
|
std::string text;
|
||||||
if (vertex.is_extrusion()) {
|
if (vertex.is_extrusion()) {
|
||||||
sprintf(buff, "%.3f", vertex.width);
|
sprintf(buff, "%.3f", vertex.width);
|
||||||
text = std::string(buff);
|
text = std::string(buff);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
text = _u8L("N/A");
|
text = NA_TXT;
|
||||||
ImGuiWrapper::text(text);
|
ImGuiWrapper::text(text);
|
||||||
});
|
});
|
||||||
append_table_row(_u8L("Height") + " (" + _u8L("mm") + ")", [&vertex, &buff]() {
|
append_table_row(_u8L("Height") + " (" + _u8L("mm") + ")", [&vertex, &buff, NA_TXT]() {
|
||||||
std::string text;
|
std::string text;
|
||||||
if (vertex.is_extrusion()) {
|
if (vertex.is_extrusion()) {
|
||||||
sprintf(buff, "%.3f", vertex.height);
|
sprintf(buff, "%.3f", vertex.height);
|
||||||
text = std::string(buff);
|
text = std::string(buff);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
text = _u8L("N/A");
|
text = NA_TXT;
|
||||||
ImGuiWrapper::text(text);
|
ImGuiWrapper::text(text);
|
||||||
});
|
});
|
||||||
append_table_row(_u8L("Layer"), [&vertex, &buff]() {
|
append_table_row(_u8L("Layer"), [&vertex, &buff]() {
|
||||||
@@ -428,14 +445,14 @@ void GCodeViewer::SequentialView::Marker::render_position_window(const libvgcode
|
|||||||
const std::string text = std::string(buff);
|
const std::string text = std::string(buff);
|
||||||
ImGuiWrapper::text(text);
|
ImGuiWrapper::text(text);
|
||||||
});
|
});
|
||||||
append_table_row(_u8L("Volumetric flow rate") + " (" + _u8L("mm³/s") + ")", [&vertex, &buff]() {
|
append_table_row(_u8L("Volumetric flow rate") + " (" + _u8L("mm³/s") + ")", [&vertex, &buff, NA_TXT]() {
|
||||||
std::string text;
|
std::string text;
|
||||||
if (vertex.is_extrusion()) {
|
if (vertex.is_extrusion()) {
|
||||||
sprintf(buff, "%.3f", vertex.volumetric_rate());
|
sprintf(buff, "%.3f", vertex.volumetric_rate());
|
||||||
text = std::string(buff);
|
text = std::string(buff);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
text = _u8L("N/A");
|
text = NA_TXT;
|
||||||
ImGuiWrapper::text(text);
|
ImGuiWrapper::text(text);
|
||||||
});
|
});
|
||||||
append_table_row(_u8L("Fan speed") + " (" + _u8L("%") + ")", [&vertex, &buff]() {
|
append_table_row(_u8L("Fan speed") + " (" + _u8L("%") + ")", [&vertex, &buff]() {
|
||||||
|
|||||||
Reference in New Issue
Block a user