Manipulation with colorprint ticks now calls Plater::schedule_background_process()
This commit is contained in:
parent
a4e1ab2281
commit
70fdb48c12
3 changed files with 13 additions and 5 deletions
|
@ -24,7 +24,7 @@ namespace Slic3r {
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
|
|
||||||
|
|
||||||
Preview::Preview(wxNotebook* notebook, DynamicPrintConfig* config, Print* print, GCodePreviewData* gcode_preview_data)
|
Preview::Preview(wxNotebook* notebook, DynamicPrintConfig* config, Print* print, GCodePreviewData* gcode_preview_data, std::function<void()> schedule_background_process_func)
|
||||||
: m_canvas(nullptr)
|
: m_canvas(nullptr)
|
||||||
, m_double_slider_sizer(nullptr)
|
, m_double_slider_sizer(nullptr)
|
||||||
, m_label_view_type(nullptr)
|
, m_label_view_type(nullptr)
|
||||||
|
@ -43,6 +43,7 @@ Preview::Preview(wxNotebook* notebook, DynamicPrintConfig* config, Print* print,
|
||||||
, m_loaded(false)
|
, m_loaded(false)
|
||||||
, m_enabled(false)
|
, m_enabled(false)
|
||||||
, m_force_sliders_full_range(false)
|
, m_force_sliders_full_range(false)
|
||||||
|
, m_schedule_background_process(schedule_background_process_func)
|
||||||
{
|
{
|
||||||
if (init(notebook, config, print, gcode_preview_data))
|
if (init(notebook, config, print, gcode_preview_data))
|
||||||
{
|
{
|
||||||
|
@ -488,6 +489,7 @@ void Preview::create_double_slider()
|
||||||
Bind(wxCUSTOMEVT_TICKSCHANGED, [this](wxEvent&) {
|
Bind(wxCUSTOMEVT_TICKSCHANGED, [this](wxEvent&) {
|
||||||
auto& config = wxGetApp().preset_bundle->project_config;
|
auto& config = wxGetApp().preset_bundle->project_config;
|
||||||
((config.option<ConfigOptionFloats>("colorprint_heights"))->values) = (m_slider->GetTicksValues());
|
((config.option<ConfigOptionFloats>("colorprint_heights"))->values) = (m_slider->GetTicksValues());
|
||||||
|
m_schedule_background_process();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -529,13 +531,16 @@ void Preview::fill_slider_values(std::vector<std::pair<int, double>> &values,
|
||||||
}
|
}
|
||||||
|
|
||||||
// All ticks that would end up outside the slider range should be erased.
|
// All ticks that would end up outside the slider range should be erased.
|
||||||
// TODO: this should probably be placed into more appropriate part of code,
|
// TODO: this should be placed into more appropriate part of code,
|
||||||
// this way it relies on the Preview tab being active.
|
// this function is e.g. not called when the last object is deleted
|
||||||
auto& config = wxGetApp().preset_bundle->project_config;
|
auto& config = wxGetApp().preset_bundle->project_config;
|
||||||
std::vector<double> &ticks_from_config = (config.option<ConfigOptionFloats>("colorprint_heights"))->values;
|
std::vector<double> &ticks_from_config = (config.option<ConfigOptionFloats>("colorprint_heights"))->values;
|
||||||
|
unsigned int old_size = ticks_from_config.size();
|
||||||
ticks_from_config.erase(std::remove_if(ticks_from_config.begin(), ticks_from_config.end(),
|
ticks_from_config.erase(std::remove_if(ticks_from_config.begin(), ticks_from_config.end(),
|
||||||
[values](double val) { return values.back().second < val; }),
|
[values](double val) { return values.back().second < val; }),
|
||||||
ticks_from_config.end());
|
ticks_from_config.end());
|
||||||
|
if (ticks_from_config.size() != old_size)
|
||||||
|
m_schedule_background_process();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preview::set_double_slider_thumbs(const bool force_sliders_full_range,
|
void Preview::set_double_slider_thumbs(const bool force_sliders_full_range,
|
||||||
|
|
|
@ -40,6 +40,9 @@ class Preview : public wxPanel
|
||||||
Print* m_print;
|
Print* m_print;
|
||||||
GCodePreviewData* m_gcode_preview_data;
|
GCodePreviewData* m_gcode_preview_data;
|
||||||
|
|
||||||
|
// Calling this function object forces Plater::schedule_background_process.
|
||||||
|
std::function<void()> m_schedule_background_process;
|
||||||
|
|
||||||
unsigned int m_number_extruders;
|
unsigned int m_number_extruders;
|
||||||
std::string m_preferred_color_mode;
|
std::string m_preferred_color_mode;
|
||||||
|
|
||||||
|
@ -50,7 +53,7 @@ class Preview : public wxPanel
|
||||||
PrusaDoubleSlider* m_slider {nullptr};
|
PrusaDoubleSlider* m_slider {nullptr};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Preview(wxNotebook* notebook, DynamicPrintConfig* config, Print* print, GCodePreviewData* gcode_preview_data);
|
Preview(wxNotebook* notebook, DynamicPrintConfig* config, Print* print, GCodePreviewData* gcode_preview_data, std::function<void()> schedule_background_process = [](){});
|
||||||
virtual ~Preview();
|
virtual ~Preview();
|
||||||
|
|
||||||
wxGLCanvas* get_wxglcanvas() { return m_canvas; }
|
wxGLCanvas* get_wxglcanvas() { return m_canvas; }
|
||||||
|
|
|
@ -1002,7 +1002,7 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame) :
|
||||||
_3DScene::add_canvas(canvas3D);
|
_3DScene::add_canvas(canvas3D);
|
||||||
_3DScene::allow_multisample(canvas3D, GLCanvas3DManager::can_multisample());
|
_3DScene::allow_multisample(canvas3D, GLCanvas3DManager::can_multisample());
|
||||||
notebook->AddPage(canvas3D, _(L("3D")));
|
notebook->AddPage(canvas3D, _(L("3D")));
|
||||||
preview = new GUI::Preview(notebook, config, &print, &gcode_preview_data);
|
preview = new GUI::Preview(notebook, config, &print, &gcode_preview_data, [this](){ schedule_background_process(); });
|
||||||
|
|
||||||
// XXX: If have OpenGL
|
// XXX: If have OpenGL
|
||||||
_3DScene::enable_picking(canvas3D, true);
|
_3DScene::enable_picking(canvas3D, true);
|
||||||
|
|
Loading…
Reference in a new issue