mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-17 04:36:02 +08:00
#161 allow user-defined colours for the preview.
This commit is contained in:
parent
d145c715ca
commit
47e817a9a3
15
resources/ui_layout/colors.ini
Normal file
15
resources/ui_layout/colors.ini
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
Perimeter = FFFF66
|
||||||
|
External perimeter = FFA500
|
||||||
|
Overhang perimeter = 0000FF
|
||||||
|
Internal infill = B1302A
|
||||||
|
Solid infill = D732D7
|
||||||
|
Top solid infill = FF1A1A
|
||||||
|
Bridge infill = 9999FF
|
||||||
|
Thin wall = FFB000
|
||||||
|
Gap fill = FFFFFF
|
||||||
|
Skirt = 845321
|
||||||
|
Support material = 00FF00
|
||||||
|
Support material interface = 008000
|
||||||
|
Wipe tower = B3E3AB
|
||||||
|
Mill = B3B3B3
|
||||||
|
Custom = 28CC94
|
@ -21,9 +21,13 @@
|
|||||||
#include <wx/checkbox.h>
|
#include <wx/checkbox.h>
|
||||||
#include <wx/display.h>
|
#include <wx/display.h>
|
||||||
|
|
||||||
|
#include <boost/filesystem.hpp>
|
||||||
|
#include <boost/filesystem/path.hpp>
|
||||||
|
|
||||||
// this include must follow the wxWidgets ones or it won't compile on Windows -> see http://trac.wxwidgets.org/ticket/2421
|
// this include must follow the wxWidgets ones or it won't compile on Windows -> see http://trac.wxwidgets.org/ticket/2421
|
||||||
#include "libslic3r/Print.hpp"
|
#include "libslic3r/Print.hpp"
|
||||||
#include "libslic3r/SLAPrint.hpp"
|
#include "libslic3r/SLAPrint.hpp"
|
||||||
|
#include "libslic3r/FileParserError.hpp"
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
@ -330,6 +334,26 @@ bool Preview::init(wxWindow* parent, Bed3D& bed, Camera& camera, GLToolbar& view
|
|||||||
"Mill", "B3B3B3",
|
"Mill", "B3B3B3",
|
||||||
"Custom", "28CC94"
|
"Custom", "28CC94"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//try to laod 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);
|
||||||
|
} catch (const std::ifstream::failure &err) {
|
||||||
|
throw file_parser_error(std::string("The color file cannot be loaded. Reason: ") + err.what(), path_colors.string());
|
||||||
|
} catch (const std::runtime_error &err) {
|
||||||
|
throw file_parser_error(std::string("Failed loading the color file. Reason: ") + err.what(), path_colors.string());
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < extrusion_roles_colors.size(); i += 2) {
|
||||||
|
std::string color_code = tree_colors.get<std::string>(extrusion_roles_colors[i]);
|
||||||
|
extrusion_roles_colors[i + 1] = color_code;
|
||||||
|
}
|
||||||
|
|
||||||
m_gcode_preview_data->set_extrusion_paths_colors(extrusion_roles_colors);
|
m_gcode_preview_data->set_extrusion_paths_colors(extrusion_roles_colors);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user