fix crash in gcdode viewer

fix color.ui hook
fix thin wall extrusion type
move some colors from orange to blue
This commit is contained in:
supermerill 2020-10-26 02:08:16 +01:00
parent c3073c4422
commit 3346658047
8 changed files with 101 additions and 54 deletions

View File

@ -1,15 +1,18 @@
Unknown = C0C0C0
Perimeter = FFFF66
External perimeter = FFA500
Overhang perimeter = 0000FF
Internal infill = B1302A
Solid infill = D732D7
Top solid infill = FF1A1A
Ironing = FF6868
Bridge infill = 9999FF
Thin wall = FFB000
Thin wall = FFC000
Gap fill = FFFFFF
Skirt = 845321
Support material = 00FF00
Support material interface = 008000
Wipe tower = B3E3AB
Mill = B3B3B3
Custom = 28CC94
Custom = 28CC94
Mixed = 000000

View File

@ -314,6 +314,8 @@ ExtrusionRole ExtrusionEntity::string_to_role(const std::string& role)
return erIroning;
else if (role == L("Bridge infill"))
return erBridgeInfill;
else if (role == L("Thin wall"))
return erThinWall;
else if (role == L("Gap fill"))
return erGapFill;
else if (role == L("Skirt"))
@ -324,13 +326,16 @@ ExtrusionRole ExtrusionEntity::string_to_role(const std::string& role)
return erSupportMaterialInterface;
else if (role == L("Wipe tower"))
return erWipeTower;
else if (role == L("Mill"))
return erMilling;
else if (role == L("Custom"))
return erCustom;
else if (role == L("Mixed"))
return erMixed;
else
return erNone;
}void ExtrusionPrinter::use(const ExtrusionPath &path) {
}
void ExtrusionPrinter::use(const ExtrusionPath &path) {
ss << "ExtrusionPath:" << (uint16_t)path.role() << "{";
for (int i = 0; i < path.polyline.points.size(); i++) {
if (i != 0) ss << ",";

View File

@ -240,7 +240,7 @@ void GCodeViewer::SequentialView::Marker::render() const
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
ImGui::SetNextWindowBgAlpha(0.25f);
imgui.begin(std::string("ToolPosition"), ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoMove);
imgui.text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, _u8L("Tool position") + ":");
imgui.text_colored(ImGuiWrapper::COL_BLUE_LIGHT, _u8L("Tool position") + ":");
ImGui::SameLine();
char buf[1024];
sprintf(buf, "X: %.2f, Y: %.2f, Z: %.2f", m_world_position(0), m_world_position(1), m_world_position(2));
@ -260,27 +260,6 @@ void GCodeViewer::SequentialView::Marker::render() const
ImGui::PopStyleVar();
}
const std::vector<GCodeViewer::Color> GCodeViewer::Extrusion_Role_Colors {{
{ 0.75f, 0.75f, 0.75f }, // erNone
{ 1.00f, 0.90f, 0.30f }, // erPerimeter
{ 1.00f, 0.49f, 0.22f }, // erExternalPerimeter
{ 0.12f, 0.12f, 1.00f }, // erOverhangPerimeter
{ 0.69f, 0.19f, 0.16f }, // erInternalInfill
{ 0.59f, 0.33f, 0.80f }, // erSolidInfill
{ 0.94f, 0.25f, 0.25f }, // erTopSolidInfill
{ 1.00f, 0.55f, 0.41f }, // erIroning
{ 0.30f, 0.50f, 0.73f }, // erBridgeInfill
{ 0.00f, 1.00f, 0.40f }, // erThinWall
{ 1.00f, 1.00f, 1.00f }, // erGapFill
{ 0.00f, 0.53f, 0.43f }, // erSkirt
{ 0.00f, 1.00f, 0.00f }, // erSupportMaterial
{ 0.00f, 0.50f, 0.00f }, // erSupportMaterialInterface
{ 0.70f, 0.89f, 0.67f }, // erWipeTower
{ 0.70f, 0.70f, 0.70f }, // erMilling
{ 0.37f, 0.82f, 0.58f }, // erCustom
{ 0.00f, 0.00f, 0.00f } // erMixed
}};
const std::vector<GCodeViewer::Color> GCodeViewer::Options_Colors {{
{ 0.803f, 0.135f, 0.839f }, // Retractions
{ 0.287f, 0.679f, 0.810f }, // Unretractions
@ -899,6 +878,58 @@ void GCodeViewer::init()
if (m_initialized)
return;
//load Extrusion colors
{
this->Extrusion_Role_Colors = {
{ 0.75f, 0.75f, 0.75f }, // erNone
{ 1.00f, 0.90f, 0.30f }, // erPerimeter
{ 1.00f, 0.49f, 0.22f }, // erExternalPerimeter
{ 0.12f, 0.12f, 1.00f }, // erOverhangPerimeter
{ 0.69f, 0.19f, 0.16f }, // erInternalInfill
{ 0.59f, 0.33f, 0.80f }, // erSolidInfill
{ 0.94f, 0.25f, 0.25f }, // erTopSolidInfill
{ 1.00f, 0.55f, 0.41f }, // erIroning
{ 0.30f, 0.50f, 0.73f }, // erBridgeInfill
{ 0.00f, 1.00f, 0.40f }, // erThinWall
{ 1.00f, 1.00f, 1.00f }, // erGapFill
{ 0.00f, 0.53f, 0.43f }, // erSkirt
{ 0.00f, 1.00f, 0.00f }, // erSupportMaterial
{ 0.00f, 0.50f, 0.00f }, // erSupportMaterialInterface
{ 0.70f, 0.89f, 0.67f }, // erWipeTower
{ 0.70f, 0.70f, 0.70f }, // erMilling
{ 0.37f, 0.82f, 0.58f }, // erCustom
{ 0.00f, 0.00f, 0.00f } // erMixed
};
//try to load colors from ui file
boost::property_tree::ptree tree_colors;
boost::filesystem::path path_colors = boost::filesystem::path(resources_dir()) / "ui_layout" / "colors.ini";
try {
boost::nowide::ifstream ifs;
ifs.imbue(boost::locale::generator()("en_US.UTF-8"));
ifs.open(path_colors.string());
boost::property_tree::read_ini(ifs, tree_colors);
for (int i = 0; i < Extrusion_Role_Colors.size(); i++) {
std::string color_code = tree_colors.get<std::string>(ExtrusionEntity::role_to_string((ExtrusionRole)i));
if (color_code.length() > 5) {
wxColour color;
color.Set((color_code[0] == '#') ? color_code : ("#" + color_code));
Extrusion_Role_Colors[i][0] = color.Red() / 256.f;
Extrusion_Role_Colors[i][1] = color.Green() / 256.f;
Extrusion_Role_Colors[i][2] = color.Blue() / 256.f;
}
}
}
catch (const std::ifstream::failure & err) {
trace(1, (std::string("The color file cannot be loaded. Reason: ") + err.what(), path_colors.string()).c_str());
}
catch (const std::runtime_error & err) {
trace(1, (std::string("Failed loading the color file. Reason: ") + err.what(), path_colors.string()).c_str());
}
}
for (size_t i = 0; i < m_buffers.size(); ++i) {
TBuffer& buffer = m_buffers[i];
switch (buffer_type(i))
@ -1742,6 +1773,10 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool
}
}
}
if (global_endpoints.first > global_endpoints.last) {
global_endpoints = { 0 , m_moves_count };
top_layer_endpoints = global_endpoints;
}
// update current sequential position
m_sequential_view.current.first = !top_layer_only && keep_sequential_current_first ? std::clamp(m_sequential_view.current.first, global_endpoints.first, global_endpoints.last) : global_endpoints.first;
@ -2117,7 +2152,7 @@ void GCodeViewer::render_legend() const
pos = ImGui::GetCursorScreenPos();
float width = std::max(1.0f, percent_bar_size * percent / max_percent);
draw_list->AddRectFilled({ pos.x, pos.y + 2.0f }, { pos.x + width, pos.y + icon_size - 2.0f },
ImGui::GetColorU32(ImGuiWrapper::COL_ORANGE_LIGHT));
ImGui::GetColorU32(ImGuiWrapper::COL_BLUE_LIGHT));
ImGui::Dummy({ percent_bar_size, icon_size });
ImGui::SameLine();
char buf[64];
@ -2647,7 +2682,7 @@ void GCodeViewer::render_statistics() const
auto add_time = [this, &imgui](const std::string& label, long long time) {
char buf[1024];
sprintf(buf, "%lld ms (%s)", time, get_time_dhms(static_cast<float>(time) * 0.001f).c_str());
imgui.text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, label);
imgui.text_colored(ImGuiWrapper::COL_BLUE_LIGHT, label);
ImGui::SameLine(offset);
imgui.text(buf);
};
@ -2662,7 +2697,7 @@ void GCodeViewer::render_statistics() const
sprintf(buf, "%lld bytes (%.3f MB)", memory, static_cast<float>(memory) * inv_mb);
else
sprintf(buf, "%lld bytes (%.3f GB)", memory, static_cast<float>(memory) * inv_gb);
imgui.text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, label);
imgui.text_colored(ImGuiWrapper::COL_BLUE_LIGHT, label);
ImGui::SameLine(offset);
imgui.text(buf);
};
@ -2670,7 +2705,7 @@ void GCodeViewer::render_statistics() const
auto add_counter = [this, &imgui](const std::string& label, long long counter) {
char buf[1024];
sprintf(buf, "%lld", counter);
imgui.text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, label);
imgui.text_colored(ImGuiWrapper::COL_BLUE_LIGHT, label);
ImGui::SameLine(offset);
imgui.text(buf);
};

View File

@ -21,7 +21,7 @@ class GCodeViewer
using IndexBuffer = std::vector<unsigned int>;
using MultiIndexBuffer = std::vector<IndexBuffer>;
static const std::vector<Color> Extrusion_Role_Colors;
std::vector<Color> Extrusion_Role_Colors;
static const std::vector<Color> Options_Colors;
static const std::vector<Color> Travel_Colors;
static const std::vector<Color> Range_Colors;

View File

@ -230,23 +230,23 @@ void GLCanvas3D::LayersEditing::render_overlay(const GLCanvas3D& canvas) const
imgui.begin(_L("Variable layer height"), ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoCollapse);
imgui.text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, _L("Left mouse button:"));
imgui.text_colored(ImGuiWrapper::COL_BLUE_LIGHT, _L("Left mouse button:"));
ImGui::SameLine();
imgui.text(_L("Add detail"));
imgui.text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, _L("Right mouse button:"));
imgui.text_colored(ImGuiWrapper::COL_BLUE_LIGHT, _L("Right mouse button:"));
ImGui::SameLine();
imgui.text(_L("Remove detail"));
imgui.text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, _L("Shift + Left mouse button:"));
imgui.text_colored(ImGuiWrapper::COL_BLUE_LIGHT, _L("Shift + Left mouse button:"));
ImGui::SameLine();
imgui.text(_L("Reset to base"));
imgui.text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, _L("Shift + Right mouse button:"));
imgui.text_colored(ImGuiWrapper::COL_BLUE_LIGHT, _L("Shift + Right mouse button:"));
ImGui::SameLine();
imgui.text(_L("Smoothing"));
imgui.text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, _L("Mouse wheel:"));
imgui.text_colored(ImGuiWrapper::COL_BLUE_LIGHT, _L("Mouse wheel:"));
ImGui::SameLine();
imgui.text(_L("Increase/decrease edit area"));

View File

@ -116,7 +116,7 @@ void GLGizmoFdmSupports::on_render_input_window(float x, float y, float bottom_l
window_width = std::max(window_width, cursor_type_radio_left + cursor_type_radio_width1 + cursor_type_radio_width2);
auto draw_text_with_caption = [this, &caption_max](const wxString& caption, const wxString& text) {
m_imgui->text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, caption);
m_imgui->text_colored(ImGuiWrapper::COL_BLUE_LIGHT, caption);
ImGui::SameLine(caption_max);
m_imgui->text(text);
};

View File

@ -54,11 +54,13 @@ static const std::map<const char, std::string> font_icons = {
const ImVec4 ImGuiWrapper::COL_GREY_DARK = { 0.333f, 0.333f, 0.333f, 1.0f };
const ImVec4 ImGuiWrapper::COL_GREY_LIGHT = { 0.4f, 0.4f, 0.4f, 1.0f };
const ImVec4 ImGuiWrapper::COL_ORANGE_DARK = { 0.757f, 0.404f, 0.216f, 1.0f };
const ImVec4 ImGuiWrapper::COL_ORANGE_LIGHT = { 1.0f, 0.49f, 0.216f, 1.0f };
//const ImVec4 ImGuiWrapper::COL_BLUE_DARK = { 0.757f, 0.404f, 0.216f, 1.0f };
//const ImVec4 ImGuiWrapper::COL_BLUE_LIGHT = { 1.0f, 0.49f, 0.216f, 1.0f };
const ImVec4 ImGuiWrapper::COL_BLUE_DARK = { 0.0f, 0.28f, 0.78f, 1.0f };
const ImVec4 ImGuiWrapper::COL_BLUE_LIGHT = { 0.0f, 0.4f, 1.0f, 1.0f };
const ImVec4 ImGuiWrapper::COL_WINDOW_BACKGROUND = { 0.133f, 0.133f, 0.133f, 0.8f };
const ImVec4 ImGuiWrapper::COL_BUTTON_BACKGROUND = COL_ORANGE_DARK;
const ImVec4 ImGuiWrapper::COL_BUTTON_HOVERED = COL_ORANGE_LIGHT;
const ImVec4 ImGuiWrapper::COL_BUTTON_BACKGROUND = COL_BLUE_DARK;
const ImVec4 ImGuiWrapper::COL_BUTTON_HOVERED = COL_BLUE_LIGHT;
const ImVec4 ImGuiWrapper::COL_BUTTON_ACTIVE = ImGuiWrapper::COL_BUTTON_HOVERED;
ImGuiWrapper::ImGuiWrapper()
@ -1035,7 +1037,7 @@ void ImGuiWrapper::init_style()
// Window
style.WindowRounding = 4.0f;
set_color(ImGuiCol_WindowBg, COL_WINDOW_BACKGROUND);
set_color(ImGuiCol_TitleBgActive, COL_ORANGE_DARK);
set_color(ImGuiCol_TitleBgActive, COL_BLUE_DARK);
// Generics
set_color(ImGuiCol_FrameBg, COL_GREY_DARK);
@ -1043,7 +1045,7 @@ void ImGuiWrapper::init_style()
set_color(ImGuiCol_FrameBgActive, COL_GREY_LIGHT);
// Text selection
set_color(ImGuiCol_TextSelectedBg, COL_ORANGE_DARK);
set_color(ImGuiCol_TextSelectedBg, COL_BLUE_DARK);
// Buttons
set_color(ImGuiCol_Button, COL_BUTTON_BACKGROUND);
@ -1051,24 +1053,24 @@ void ImGuiWrapper::init_style()
set_color(ImGuiCol_ButtonActive, COL_BUTTON_ACTIVE);
// Checkbox
set_color(ImGuiCol_CheckMark, COL_ORANGE_LIGHT);
set_color(ImGuiCol_CheckMark, COL_BLUE_LIGHT);
// ComboBox items
set_color(ImGuiCol_Header, COL_ORANGE_DARK);
set_color(ImGuiCol_HeaderHovered, COL_ORANGE_LIGHT);
set_color(ImGuiCol_HeaderActive, COL_ORANGE_LIGHT);
set_color(ImGuiCol_Header, COL_BLUE_DARK);
set_color(ImGuiCol_HeaderHovered, COL_BLUE_LIGHT);
set_color(ImGuiCol_HeaderActive, COL_BLUE_LIGHT);
// Slider
set_color(ImGuiCol_SliderGrab, COL_ORANGE_DARK);
set_color(ImGuiCol_SliderGrabActive, COL_ORANGE_LIGHT);
set_color(ImGuiCol_SliderGrab, COL_BLUE_DARK);
set_color(ImGuiCol_SliderGrabActive, COL_BLUE_LIGHT);
// Separator
set_color(ImGuiCol_Separator, COL_ORANGE_LIGHT);
set_color(ImGuiCol_Separator, COL_BLUE_LIGHT);
// Tabs
set_color(ImGuiCol_Tab, COL_ORANGE_DARK);
set_color(ImGuiCol_TabHovered, COL_ORANGE_LIGHT);
set_color(ImGuiCol_TabActive, COL_ORANGE_LIGHT);
set_color(ImGuiCol_Tab, COL_BLUE_DARK);
set_color(ImGuiCol_TabHovered, COL_BLUE_LIGHT);
set_color(ImGuiCol_TabActive, COL_BLUE_LIGHT);
set_color(ImGuiCol_TabUnfocused, COL_GREY_DARK);
set_color(ImGuiCol_TabUnfocusedActive, COL_GREY_LIGHT);
}

View File

@ -98,8 +98,10 @@ public:
static const ImVec4 COL_GREY_DARK;
static const ImVec4 COL_GREY_LIGHT;
static const ImVec4 COL_ORANGE_DARK;
static const ImVec4 COL_ORANGE_LIGHT;
//static const ImVec4 COL_ORANGE_DARK;
//static const ImVec4 COL_ORANGE_LIGHT;
static const ImVec4 COL_BLUE_DARK;
static const ImVec4 COL_BLUE_LIGHT;
static const ImVec4 COL_WINDOW_BACKGROUND;
static const ImVec4 COL_BUTTON_BACKGROUND;
static const ImVec4 COL_BUTTON_HOVERED;