mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-10 16:27:54 -06:00
Updated draw_colored_band() according to the new colors.
+ some code refactoring
This commit is contained in:
parent
7957675a97
commit
5a28693ff4
5 changed files with 14 additions and 23 deletions
|
@ -3753,7 +3753,7 @@ void GLCanvas3D::LegendTexture::fill_color_print_legend_values(const GCodePrevie
|
|||
{
|
||||
if (preview_data.extrusion.view_type == GCodePreviewData::Extrusion::ColorPrint)
|
||||
{
|
||||
const auto& config = wxGetApp().preset_bundle->full_config();
|
||||
auto& config = wxGetApp().preset_bundle->project_config;
|
||||
const std::vector<double>& color_print_values = config.option<ConfigOptionFloats>("colorprint_heights")->values;
|
||||
const int values_cnt = color_print_values.size();
|
||||
if (values_cnt > 0) {
|
||||
|
@ -7295,7 +7295,7 @@ void GLCanvas3D::_load_print_object_toolpaths(const PrintObject& print_object, c
|
|||
bool color_by_color_print() const { return color_print_values!=nullptr; }
|
||||
const float* color_print_by_layer_idx(const size_t layer_idx) const
|
||||
{
|
||||
auto it = std::lower_bound(color_print_values->begin(), color_print_values->end(), layers[layer_idx]->print_z - EPSILON);
|
||||
auto it = std::lower_bound(color_print_values->begin(), color_print_values->end(), layers[layer_idx]->print_z + EPSILON);
|
||||
return color_tool((it - color_print_values->begin()) % number_tools());
|
||||
}
|
||||
} ctxt;
|
||||
|
|
|
@ -100,8 +100,6 @@ ObjectList::ObjectList(wxWindow* parent) :
|
|||
|
||||
ObjectList::~ObjectList()
|
||||
{
|
||||
if (m_default_config)
|
||||
delete m_default_config;
|
||||
}
|
||||
|
||||
void ObjectList::create_objects_ctrl()
|
||||
|
@ -749,10 +747,8 @@ void ObjectList::get_settings_choice(const wxString& category_name)
|
|||
const ConfigOption* option = from_config.option(opt_key);
|
||||
if (!option) {
|
||||
// if current option doesn't exist in prints.get_edited_preset(),
|
||||
// get it from m_default_config
|
||||
if (m_default_config) delete m_default_config;
|
||||
m_default_config = DynamicPrintConfig::new_from_defaults_keys(get_options(false));
|
||||
option = m_default_config->option(opt_key);
|
||||
// get it from default config values
|
||||
option = DynamicPrintConfig::new_from_defaults_keys({ opt_key })->option(opt_key);
|
||||
}
|
||||
m_config->set_key_value(opt_key, option->clone());
|
||||
}
|
||||
|
@ -776,10 +772,8 @@ void ObjectList::get_freq_settings_choice(const wxString& bundle_name)
|
|||
const ConfigOption* option = from_config.option(opt_key);
|
||||
if (!option) {
|
||||
// if current option doesn't exist in prints.get_edited_preset(),
|
||||
// get it from m_default_config
|
||||
if (m_default_config) delete m_default_config;
|
||||
m_default_config = DynamicPrintConfig::new_from_defaults_keys(get_options(false));
|
||||
option = m_default_config->option(opt_key);
|
||||
// get it from default config values
|
||||
option = DynamicPrintConfig::new_from_defaults_keys({ opt_key })->option(opt_key);
|
||||
}
|
||||
m_config->set_key_value(opt_key, option->clone());
|
||||
}
|
||||
|
|
|
@ -97,9 +97,6 @@ class ObjectList : public wxDataViewCtrl
|
|||
} m_dragged_data;
|
||||
|
||||
wxBoxSizer *m_sizer {nullptr};
|
||||
|
||||
DynamicPrintConfig *m_default_config {nullptr};
|
||||
|
||||
wxWindow *m_parent {nullptr};
|
||||
|
||||
wxBitmap m_bmp_modifiermesh;
|
||||
|
|
|
@ -740,7 +740,7 @@ void Preview::load_print_as_fff()
|
|||
if (! gcode_preview_data_valid) {
|
||||
//FIXME accessing full_config() is pretty expensive.
|
||||
// Only initialize color_print_values for the initial preview, not for the full preview where the color_print_values is extracted from the G-code.
|
||||
const auto& config = wxGetApp().preset_bundle->full_config();
|
||||
const auto& config = wxGetApp().preset_bundle->project_config;
|
||||
color_print_values = config.option<ConfigOptionFloats>("colorprint_heights")->values;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1668,7 +1668,7 @@ void PrusaDoubleSlider::render()
|
|||
|
||||
// draw colored band on the background of a scroll line
|
||||
// and only in a case of no-empty m_values
|
||||
// draw_colored_band(dc);
|
||||
draw_colored_band(dc);
|
||||
|
||||
// draw line
|
||||
draw_scroll_line(dc, lower_pos, higher_pos);
|
||||
|
@ -1867,8 +1867,10 @@ void PrusaDoubleSlider::draw_colored_band(wxDC& dc)
|
|||
return;
|
||||
}
|
||||
|
||||
const std::vector<unsigned char>& clr_bytes = Slic3r::GCodePreviewData::Range::Default_Colors[0].as_bytes();
|
||||
wxColour clr = wxColour(clr_bytes[0], clr_bytes[1], clr_bytes[2], clr_bytes[3]);
|
||||
const std::vector<std::string>& colors = Slic3r::GCodePreviewData::ColorPrintColors();
|
||||
const size_t colors_cnt = colors.size();
|
||||
|
||||
wxColour clr(colors[0]);
|
||||
dc.SetPen(clr);
|
||||
dc.SetBrush(clr);
|
||||
dc.DrawRectangle(main_band);
|
||||
|
@ -1876,15 +1878,13 @@ void PrusaDoubleSlider::draw_colored_band(wxDC& dc)
|
|||
int i = 1;
|
||||
for (auto tick : m_ticks)
|
||||
{
|
||||
if (i == Slic3r::GCodePreviewData::Range::Colors_Count)
|
||||
if (i == colors_cnt)
|
||||
i = 0;
|
||||
const wxCoord pos = get_position_from_value(tick);
|
||||
is_horizontal() ? main_band.SetLeft(SLIDER_MARGIN + pos) :
|
||||
main_band.SetBottom(pos-1);
|
||||
|
||||
const std::vector<unsigned char>& clr_b = Slic3r::GCodePreviewData::Range::Default_Colors[i].as_bytes();
|
||||
|
||||
clr = wxColour(clr_b[0], clr_b[1], clr_b[2], clr_b[3]);
|
||||
clr = wxColour(colors[i]);
|
||||
dc.SetPen(clr);
|
||||
dc.SetBrush(clr);
|
||||
dc.DrawRectangle(main_band);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue