mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-27 10:41:15 -06:00
Code cleaning
This commit is contained in:
parent
496e09302f
commit
901a20b3b1
9 changed files with 11 additions and 266 deletions
|
|
@ -836,59 +836,6 @@ GLCanvas3D::LegendTexture::LegendTexture()
|
|||
{
|
||||
}
|
||||
|
||||
void GLCanvas3D::LegendTexture::fill_color_print_legend_values(const GCodePreviewData& preview_data, const GLCanvas3D& canvas,
|
||||
std::vector<std::pair<double, double>>& cp_legend_values)
|
||||
{
|
||||
if (preview_data.extrusion.view_type == GCodePreviewData::Extrusion::ColorPrint /*&&
|
||||
wxGetApp().extruders_edited_cnt() == 1*/) // show color change legend only for single-material presets
|
||||
{
|
||||
/*
|
||||
// #ys_FIXME_COLOR
|
||||
auto& config = wxGetApp().preset_bundle->project_config;
|
||||
const std::vector<double>& color_print_values = config.option<ConfigOptionFloats>("colorprint_heights")->values;
|
||||
|
||||
if (!color_print_values.empty()) {
|
||||
std::vector<double> print_zs = canvas.get_current_print_zs(true);
|
||||
for (auto cp_value : color_print_values)
|
||||
{
|
||||
auto lower_b = std::lower_bound(print_zs.begin(), print_zs.end(), cp_value - DoubleSlider::epsilon());
|
||||
|
||||
if (lower_b == print_zs.end())
|
||||
continue;
|
||||
|
||||
double current_z = *lower_b;
|
||||
double previous_z = lower_b == print_zs.begin() ? 0.0 : *(--lower_b);
|
||||
|
||||
// to avoid duplicate values, check adding values
|
||||
if (cp_legend_values.empty() ||
|
||||
!(cp_legend_values.back().first == previous_z && cp_legend_values.back().second == current_z) )
|
||||
cp_legend_values.push_back(std::pair<double, double>(previous_z, current_z));
|
||||
}
|
||||
}
|
||||
*/
|
||||
std::vector<Model::CustomGCode> custom_gcode_per_height = wxGetApp().plater()->model().custom_gcode_per_height;
|
||||
|
||||
if (!custom_gcode_per_height.empty()) {
|
||||
std::vector<double> print_zs = canvas.get_current_print_zs(true);
|
||||
for (auto custom_code : custom_gcode_per_height)
|
||||
{
|
||||
auto lower_b = std::lower_bound(print_zs.begin(), print_zs.end(), custom_code.height - DoubleSlider::epsilon());
|
||||
|
||||
if (lower_b == print_zs.end())
|
||||
continue;
|
||||
|
||||
double current_z = *lower_b;
|
||||
double previous_z = lower_b == print_zs.begin() ? 0.0 : *(--lower_b);
|
||||
|
||||
// to avoid duplicate values, check adding values
|
||||
if (cp_legend_values.empty() ||
|
||||
!(cp_legend_values.back().first == previous_z && cp_legend_values.back().second == current_z) )
|
||||
cp_legend_values.push_back(std::pair<double, double>(previous_z, current_z));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GLCanvas3D::LegendTexture::fill_color_print_legend_items( const GLCanvas3D& canvas,
|
||||
const std::vector<float>& colors_in,
|
||||
std::vector<float>& colors,
|
||||
|
|
@ -997,12 +944,6 @@ bool GLCanvas3D::LegendTexture::generate(const GCodePreviewData& preview_data, c
|
|||
// collects items to render
|
||||
auto title = _(preview_data.get_legend_title());
|
||||
|
||||
// #ys_FIXME_COLOR
|
||||
// std::vector<std::pair<double, double>> cp_legend_values;
|
||||
// fill_color_print_legend_values(preview_data, canvas, cp_legend_values);
|
||||
|
||||
// const GCodePreviewData::LegendItemsList& items = preview_data.get_legend_items(tool_colors, cp_legend_values);
|
||||
|
||||
std::vector<std::string> cp_legend_items;
|
||||
std::vector<float> cp_colors;
|
||||
|
||||
|
|
@ -2380,8 +2321,6 @@ void GLCanvas3D::load_sla_preview()
|
|||
}
|
||||
}
|
||||
|
||||
// #ys_FIXME_COLOR
|
||||
// void GLCanvas3D::load_preview(const std::vector<std::string>& str_tool_colors, const std::vector<double>& color_print_values)
|
||||
void GLCanvas3D::load_preview(const std::vector<std::string>& str_tool_colors, const std::vector<Model::CustomGCode>& color_print_values)
|
||||
{
|
||||
const Print *print = this->fff_print();
|
||||
|
|
@ -5159,8 +5098,6 @@ void GLCanvas3D::_load_print_toolpaths()
|
|||
volume->indexed_vertex_array.finalize_geometry(m_initialized);
|
||||
}
|
||||
|
||||
// #ys_FIXME_COLOR
|
||||
// void GLCanvas3D::_load_print_object_toolpaths(const PrintObject& print_object, const std::vector<std::string>& str_tool_colors, const std::vector<double>& color_print_values)
|
||||
void GLCanvas3D::_load_print_object_toolpaths(const PrintObject& print_object, const std::vector<std::string>& str_tool_colors, const std::vector<Model::CustomGCode>& color_print_values)
|
||||
{
|
||||
std::vector<float> tool_colors = _parse_colors(str_tool_colors);
|
||||
|
|
@ -5173,8 +5110,6 @@ void GLCanvas3D::_load_print_object_toolpaths(const PrintObject& print_object, c
|
|||
bool has_infill;
|
||||
bool has_support;
|
||||
const std::vector<float>* tool_colors;
|
||||
// #ys_FIXME_COLOR
|
||||
// const std::vector<double>* color_print_values;
|
||||
bool is_single_material_print;
|
||||
int extruders_cnt;
|
||||
const std::vector<Model::CustomGCode>* color_print_values;
|
||||
|
|
@ -5192,8 +5127,6 @@ void GLCanvas3D::_load_print_object_toolpaths(const PrintObject& print_object, c
|
|||
// For coloring by a color_print(M600), return a parsed color.
|
||||
bool color_by_color_print() const { return color_print_values!=nullptr; }
|
||||
const size_t color_print_color_idx_by_layer_idx(const size_t layer_idx) const {
|
||||
// #ys_FIXME_COLOR
|
||||
// auto it = std::lower_bound(color_print_values->begin(), color_print_values->end(), layers[layer_idx]->print_z + EPSILON);
|
||||
const Model::CustomGCode value(layers[layer_idx]->print_z + EPSILON, "", 0, "");
|
||||
auto it = std::lower_bound(color_print_values->begin(), color_print_values->end(), value);
|
||||
return (it - color_print_values->begin()) % number_tools();
|
||||
|
|
@ -5350,33 +5283,13 @@ void GLCanvas3D::_load_print_object_toolpaths(const PrintObject& print_object, c
|
|||
std::vector<size_t> color_print_layer_to_glvolume;
|
||||
auto volume = [&ctxt, &vols, &color_print_layer_to_glvolume, &range](size_t layer_idx, int extruder, int feature) -> GLVolume& {
|
||||
return *vols[ctxt.color_by_color_print()?
|
||||
//color_print_layer_to_glvolume[layer_idx - range.begin()] :
|
||||
ctxt.color_print_color_idx_by_layer_idx_and_extruder(layer_idx, extruder) :
|
||||
ctxt.color_by_tool() ?
|
||||
std::min<int>(ctxt.number_tools() - 1, std::max<int>(extruder - 1, 0)) :
|
||||
feature
|
||||
];
|
||||
};
|
||||
/*if (ctxt.color_by_color_print()) {
|
||||
// Create a map from the layer index to a GLVolume, which is initialized with the correct layer span color.
|
||||
std::vector<int> color_print_tool_to_glvolume(ctxt.number_tools(), -1);
|
||||
color_print_layer_to_glvolume.reserve(range.end() - range.begin());
|
||||
vols.reserve(ctxt.number_tools());
|
||||
for (size_t idx_layer = range.begin(); idx_layer < range.end(); ++ idx_layer) {
|
||||
int idx_tool = (int)ctxt.color_print_color_idx_by_layer_idx(idx_layer);
|
||||
if (color_print_tool_to_glvolume[idx_tool] == -1) {
|
||||
color_print_tool_to_glvolume[idx_tool] = (int)vols.size();
|
||||
vols.emplace_back(new_volume(ctxt.color_tool(idx_tool)));
|
||||
}
|
||||
color_print_layer_to_glvolume.emplace_back(color_print_tool_to_glvolume[idx_tool]);
|
||||
}
|
||||
vols.emplace_back(new_volume(ctxt.color_pause_or_custom_code()));
|
||||
}
|
||||
for (size_t i = 0; i < ctxt.number_tools(); ++i)
|
||||
vols.emplace_back(new_volume(ctxt.color_tool(i)));
|
||||
vols.emplace_back(new_volume(ctxt.color_pause_or_custom_code()));
|
||||
}
|
||||
else */if (ctxt.color_by_color_print() || ctxt.color_by_tool()) {
|
||||
if (ctxt.color_by_color_print() || ctxt.color_by_tool()) {
|
||||
for (size_t i = 0; i < ctxt.number_tools(); ++i)
|
||||
vols.emplace_back(new_volume(ctxt.color_tool(i)));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -352,9 +352,6 @@ private:
|
|||
|
||||
public:
|
||||
LegendTexture();
|
||||
void fill_color_print_legend_values(const GCodePreviewData& preview_data, const GLCanvas3D& canvas,
|
||||
std::vector<std::pair<double, double>>& cp_legend_values);
|
||||
|
||||
void fill_color_print_legend_items(const GLCanvas3D& canvas,
|
||||
const std::vector<float>& colors_in,
|
||||
std::vector<float>& colors,
|
||||
|
|
@ -555,8 +552,6 @@ public:
|
|||
|
||||
void load_gcode_preview(const GCodePreviewData& preview_data, const std::vector<std::string>& str_tool_colors);
|
||||
void load_sla_preview();
|
||||
// #ys_FIXME_COLOR
|
||||
// void load_preview(const std::vector<std::string>& str_tool_colors, const std::vector<double>& color_print_values);
|
||||
void load_preview(const std::vector<std::string>& str_tool_colors, const std::vector<Model::CustomGCode>& color_print_values);
|
||||
void bind_event_handlers();
|
||||
void unbind_event_handlers();
|
||||
|
|
@ -722,9 +717,6 @@ private:
|
|||
// one for perimeters, one for infill and one for supports.
|
||||
void _load_print_object_toolpaths(const PrintObject& print_object, const std::vector<std::string>& str_tool_colors,
|
||||
const std::vector<Model::CustomGCode>& color_print_values);
|
||||
// #ys_FIXME_COLOR
|
||||
// void _load_print_object_toolpaths(const PrintObject& print_object, const std::vector<std::string>& str_tool_colors,
|
||||
// const std::vector<double>& color_print_values);
|
||||
// Create 3D thick extrusion lines for wipe tower extrusions
|
||||
void _load_wipe_tower_toolpaths(const std::vector<std::string>& str_tool_colors);
|
||||
|
||||
|
|
|
|||
|
|
@ -582,16 +582,6 @@ void Preview::update_view_type(bool slice_completed)
|
|||
{
|
||||
const DynamicPrintConfig& config = wxGetApp().preset_bundle->project_config;
|
||||
|
||||
/*
|
||||
// #ys_FIXME_COLOR
|
||||
const wxString& choice = !config.option<ConfigOptionFloats>("colorprint_heights")->values.empty() &&
|
||||
wxGetApp().extruders_edited_cnt()==1 ?
|
||||
_(L("Color Print")) :
|
||||
config.option<ConfigOptionFloats>("wiping_volumes_matrix")->values.size() > 1 ?
|
||||
_(L("Tool")) :
|
||||
_(L("Feature type"));
|
||||
*/
|
||||
|
||||
const wxString& choice = !wxGetApp().plater()->model().custom_gcode_per_height.empty() /*&&
|
||||
(wxGetApp().extruders_edited_cnt()==1 || !slice_completed) */?
|
||||
_(L("Color Print")) :
|
||||
|
|
@ -728,9 +718,6 @@ void Preview::update_double_slider(const std::vector<double>& layers_z, bool kee
|
|||
bool snap_to_min = force_sliders_full_range || m_slider->is_lower_at_min();
|
||||
bool snap_to_max = force_sliders_full_range || m_slider->is_higher_at_max();
|
||||
|
||||
// #ys_FIXME_COLOR
|
||||
// std::vector<double> &ticks_from_config = (wxGetApp().preset_bundle->project_config.option<ConfigOptionFloats>("colorprint_heights"))->values;
|
||||
// check_slider_values(ticks_from_config, layers_z);
|
||||
std::vector<Model::CustomGCode> tmp_ticks_from_model;
|
||||
if (m_selected_extruder != 0)
|
||||
tmp_ticks_from_model = wxGetApp().plater()->model().custom_gcode_per_height;
|
||||
|
|
@ -761,41 +748,15 @@ void Preview::update_double_slider(const std::vector<double>& layers_z, bool kee
|
|||
m_slider->SetTicksValues(ticks_from_model);
|
||||
|
||||
bool color_print_enable = (wxGetApp().plater()->printer_technology() == ptFFF);
|
||||
// #ys_FIXME_COLOR
|
||||
// if (color_print_enable) {
|
||||
// const DynamicPrintConfig& cfg = wxGetApp().preset_bundle->printers.get_edited_preset().config;
|
||||
// if (cfg.opt<ConfigOptionFloats>("nozzle_diameter")->values.size() > 1)
|
||||
// color_print_enable = false;
|
||||
// }
|
||||
// m_slider->EnableTickManipulation(color_print_enable);
|
||||
|
||||
m_slider->EnableTickManipulation(color_print_enable);
|
||||
if (color_print_enable && wxGetApp().extruders_edited_cnt() > 1) {
|
||||
//bool is_detected_full_print = //wxGetApp().plater()->fff_print().extruders().size() == 1;
|
||||
m_slider->SetExtruderID(m_extruder_selector->GetSelection());
|
||||
}
|
||||
else
|
||||
m_slider->SetExtruderID(-1);
|
||||
|
||||
}
|
||||
// #ys_FIXME_COLOR
|
||||
void Preview::check_slider_values(std::vector<double>& ticks_from_config,
|
||||
const std::vector<double> &layers_z)
|
||||
{
|
||||
// All ticks that would end up outside the slider range should be erased.
|
||||
// TODO: this should be placed into more appropriate part of code,
|
||||
// this function is e.g. not called when the last object is deleted
|
||||
unsigned int old_size = ticks_from_config.size();
|
||||
ticks_from_config.erase(std::remove_if(ticks_from_config.begin(), ticks_from_config.end(),
|
||||
[layers_z](double val)
|
||||
{
|
||||
auto it = std::lower_bound(layers_z.begin(), layers_z.end(), val - DoubleSlider::epsilon());
|
||||
return it == layers_z.end();
|
||||
}),
|
||||
ticks_from_config.end());
|
||||
if (ticks_from_config.size() != old_size)
|
||||
m_schedule_background_process();
|
||||
}
|
||||
|
||||
void Preview::reset_double_slider()
|
||||
{
|
||||
|
|
@ -878,51 +839,19 @@ void Preview::load_print_as_fff(bool keep_z_range)
|
|||
bool gcode_preview_data_valid = print->is_step_done(psGCodeExport) && ! m_gcode_preview_data->empty();
|
||||
// Collect colors per extruder.
|
||||
std::vector<std::string> colors;
|
||||
// #ys_FIXME_COLOR
|
||||
// std::vector<double> color_print_values = {};
|
||||
std::vector<Model::CustomGCode> color_print_values = {};
|
||||
// set color print values, if it si selected "ColorPrint" view type
|
||||
if (m_gcode_preview_data->extrusion.view_type == GCodePreviewData::Extrusion::ColorPrint)
|
||||
{
|
||||
color_print_values = wxGetApp().plater()->model().custom_gcode_per_height;
|
||||
/* colors = wxGetApp().plater()->get_extruder_colors_from_plater_config();
|
||||
|
||||
for (const Model::CustomGCode& code : color_print_values)
|
||||
if (code.gcode == ColorChangeCode)
|
||||
colors.push_back(code.color);*/
|
||||
colors = wxGetApp().plater()->get_colors_for_color_print();
|
||||
colors = wxGetApp().plater()->get_colors_for_color_print();
|
||||
colors.push_back("#808080"); // gray color for pause print or custom G-code
|
||||
|
||||
if (gcode_preview_data_valid)
|
||||
color_print_values.clear();
|
||||
/*
|
||||
if (! gcode_preview_data_valid) {
|
||||
// #ys_FIXME_COLOR
|
||||
// const auto& config = wxGetApp().preset_bundle->project_config;
|
||||
// color_print_values = config.option<ConfigOptionFloats>("colorprint_heights")->values;
|
||||
if (!gcode_preview_data_valid)
|
||||
color_print_values = wxGetApp().plater()->model().custom_gcode_per_height;
|
||||
}
|
||||
*/
|
||||
}
|
||||
else if (gcode_preview_data_valid || (m_gcode_preview_data->extrusion.view_type == GCodePreviewData::Extrusion::Tool) )
|
||||
{
|
||||
const ConfigOptionStrings* extruders_opt = dynamic_cast<const ConfigOptionStrings*>(m_config->option("extruder_colour"));
|
||||
const ConfigOptionStrings* filamemts_opt = dynamic_cast<const ConfigOptionStrings*>(m_config->option("filament_colour"));
|
||||
unsigned int colors_count = std::max((unsigned int)extruders_opt->values.size(), (unsigned int)filamemts_opt->values.size());
|
||||
|
||||
unsigned char rgb[3];
|
||||
for (unsigned int i = 0; i < colors_count; ++i)
|
||||
{
|
||||
std::string color = m_config->opt_string("extruder_colour", i);
|
||||
if (!PresetBundle::parse_color(color, rgb))
|
||||
{
|
||||
color = m_config->opt_string("filament_colour", i);
|
||||
if (!PresetBundle::parse_color(color, rgb))
|
||||
color = "#FFFFFF";
|
||||
}
|
||||
|
||||
colors.emplace_back(color);
|
||||
}
|
||||
colors = wxGetApp().plater()->get_extruder_colors_from_plater_config();
|
||||
color_print_values.clear();
|
||||
}
|
||||
|
||||
|
|
@ -934,10 +863,6 @@ void Preview::load_print_as_fff(bool keep_z_range)
|
|||
m_canvas->load_gcode_preview(*m_gcode_preview_data, colors);
|
||||
m_loaded = true;
|
||||
} else {
|
||||
// disable color change information for multi-material presets
|
||||
// if (wxGetApp().extruders_edited_cnt() > 1) // #ys_FIXME_COLOR
|
||||
// color_print_values.clear();
|
||||
|
||||
// Load the initial preview based on slices, not the final G-code.
|
||||
m_canvas->load_preview(colors, color_print_values);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -162,8 +162,6 @@ private:
|
|||
void check_slider_values(std::vector<Model::CustomGCode> &ticks_from_model,
|
||||
const std::vector<double> &layers_z);
|
||||
void update_double_slider(const std::vector<double>& layers_z, bool keep_z_range = false);
|
||||
void check_slider_values(std::vector<double> &ticks_from_config,
|
||||
const std::vector<double> &layers_z); // #ys_FIXME_COLOR
|
||||
void reset_double_slider();
|
||||
// update DoubleSlider after keyDown in canvas
|
||||
void update_double_slider_from_canvas(wxKeyEvent& event);
|
||||
|
|
|
|||
|
|
@ -2725,9 +2725,6 @@ void Plater::priv::reset()
|
|||
// The hiding of the slicing results, if shown, is not taken care by the background process, so we do it here
|
||||
this->sidebar->show_sliced_info_sizer(false);
|
||||
|
||||
// #ys_FIXME_COLOR
|
||||
// auto& config = wxGetApp().preset_bundle->project_config;
|
||||
// config.option<ConfigOptionFloats>("colorprint_heights")->values.clear();
|
||||
model.custom_gcode_per_height.clear();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue