color settings for grid

This commit is contained in:
remi durand 2021-06-02 23:05:31 +02:00
parent d2e1b52275
commit 94d277766b
3 changed files with 41 additions and 1 deletions

View File

@ -24,3 +24,5 @@ Gui_color_light = ffee38
Gui_color_very_light = fef48b
splash_screen_editor = cars.jpg
splash_screen_gcodeviewer = prusa-gcodepreview.jpg
Gui_plater = 3C3C3C
Gui_plater_grid = D0D0D0

View File

@ -170,6 +170,41 @@ Bed3D::Bed3D()
, m_vbo_id(0)
, m_scale_factor(1.0f)
{
{
//try to load splashscreen 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);
std::string color_code = tree_colors.get<std::string>("Gui_plater");
if (color_code.length() > 5) {
wxColour color;
color.Set((color_code[0] == '#') ? color_code : ("#" + color_code));
this->m_model_color[0] = color.Red() / 256.f;
this->m_model_color[1] = color.Green() / 256.f;
this->m_model_color[2] = color.Blue() / 256.f;
}
color_code = tree_colors.get<std::string>("Gui_plater_grid");
if (color_code.length() > 5) {
wxColour color;
color.Set((color_code[0] == '#') ? color_code : ("#" + color_code));
this->m_grid_color[0] = color.Red() / 256.f;
this->m_grid_color[1] = color.Green() / 256.f;
this->m_grid_color[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());
}
}
}
bool Bed3D::set_shape(const Pointfs& shape, const std::string& custom_texture, const std::string& custom_model, bool force_as_custom)
@ -580,8 +615,10 @@ void Bed3D::render_default(bool bottom) const
// draw grid
if (has_model && !bottom)
glsafe(::glColor4f(0.9f, 0.9f, 0.9f, 1.0f));
else
else if (bottom)
glsafe(::glColor4f(0.9f, 0.9f, 0.9f, 0.6f));
else
glsafe(::glColor4fv(m_grid_color.data()));
glsafe(::glLineWidth(0.5f * m_scale_factor));
glsafe(::glVertexPointer(3, GL_FLOAT, m_gridlines_small.get_vertex_data_size(), (GLvoid*)m_gridlines_small.get_vertices_data()));
glsafe(::glDrawArrays(GL_LINES, 0, (GLsizei)m_gridlines_small.get_vertices_count()));

View File

@ -88,6 +88,7 @@ private:
mutable GLModel m_model;
mutable Vec3d m_model_offset{ Vec3d::Zero() };
std::array<float, 4> m_model_color{ 0.235f, 0.235f, 0.235f, 1.0f };
std::array<float, 4> m_grid_color{ 0.9f, 0.9f, 0.9f, 0.6f };
// temporary texture shown until the main texture has still no levels compressed
mutable GLTexture m_temp_texture;
mutable unsigned int m_vbo_id;