Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
Slic3r::GUI::Preview Class Reference

#include <src/slic3r/GUI/GUI_Preview.hpp>

+ Inheritance diagram for Slic3r::GUI::Preview:
+ Collaboration diagram for Slic3r::GUI::Preview:

Public Types

enum class  OptionType : unsigned int {
  Travel , Wipe , Retractions , Unretractions ,
  Seams , ToolChanges , ColorChanges , PausePrints ,
  CustomGCodes , CenterOfGravity , Shells , ToolMarker
}
 

Public Member Functions

 Preview (wxWindow *parent, Bed3D &bed, Model *model, DynamicPrintConfig *config, BackgroundSlicingProcess *process, GCodeProcessorResult *gcode_result, std::function< void()> schedule_background_process=[]() {})
 
virtual ~Preview ()
 
wxGLCanvas * get_wxglcanvas ()
 
GLCanvas3Dget_canvas3d ()
 
void set_as_dirty ()
 
void bed_shape_changed ()
 
void select_view (const std::string &direction)
 
void set_drop_target (wxDropTarget *target)
 
void load_print (bool keep_z_range=false)
 
void reload_print (bool keep_volumes=false)
 
void refresh_print ()
 
void msw_rescale ()
 
void sys_color_changed ()
 
void jump_layers_slider (wxKeyEvent &evt)
 
void move_layers_slider (wxKeyEvent &evt)
 
void edit_layers_slider (wxKeyEvent &evt)
 
bool is_loaded () const
 
void update_moves_slider ()
 
void enable_moves_slider (bool enable)
 
void move_moves_slider (wxKeyEvent &evt)
 
void hide_layers_slider ()
 
void set_keep_current_preview_type (bool value)
 
void set_layers_slider_values_range (int bottom, int top)
 

Private Member Functions

bool init (wxWindow *parent, Bed3D &bed, Model *model)
 
void bind_event_handlers ()
 
void unbind_event_handlers ()
 
void on_size (wxSizeEvent &evt)
 
wxBoxSizer * create_layers_slider_sizer ()
 
void check_layers_slider_values (std::vector< CustomGCode::Item > &ticks_from_model, const std::vector< double > &layers_z)
 
void reset_layers_slider ()
 
void update_layers_slider (const std::vector< double > &layers_z, bool keep_z_range=false)
 
void update_layers_slider_mode ()
 
void update_layers_slider_from_canvas (wxKeyEvent &event)
 
void load_print_as_fff (bool keep_z_range=false)
 
void load_print_as_sla ()
 
void on_layers_slider_scroll_changed (wxCommandEvent &event)
 
void on_moves_slider_scroll_changed (wxCommandEvent &event)
 

Private Attributes

wxGLCanvas * m_canvas_widget { nullptr }
 
GLCanvas3Dm_canvas { nullptr }
 
wxBoxSizer * m_left_sizer { nullptr }
 
wxBoxSizer * m_layers_slider_sizer { nullptr }
 
wxPanel * m_bottom_toolbar_panel { nullptr }
 
DynamicPrintConfigm_config
 
BackgroundSlicingProcessm_process
 
GCodeProcessorResultm_gcode_result
 
std::function< void()> m_schedule_background_process
 
unsigned int m_number_extruders { 1 }
 
bool m_keep_current_preview_type { false }
 
bool m_loaded { false }
 
DoubleSlider::Controlm_layers_slider { nullptr }
 
DoubleSlider::Controlm_moves_slider { nullptr }
 

Detailed Description

Member Enumeration Documentation

◆ OptionType

Constructor & Destructor Documentation

◆ Preview()

Slic3r::GUI::Preview::Preview ( wxWindow *  parent,
Bed3D bed,
Model model,
DynamicPrintConfig config,
BackgroundSlicingProcess process,
GCodeProcessorResult gcode_result,
std::function< void()>  schedule_background_process = []() {} 
)
175 : m_config(config)
176 , m_process(process)
177 , m_gcode_result(gcode_result)
178 , m_schedule_background_process(schedule_background_process_func)
179{
180 if (init(parent, bed, model))
181 load_print();
182}
GCodeProcessorResult * m_gcode_result
Definition GUI_Preview.hpp:86
std::function< void()> m_schedule_background_process
Definition GUI_Preview.hpp:95
void load_print(bool keep_z_range=false)
Definition GUI_Preview.cpp:282
DynamicPrintConfig * m_config
Definition GUI_Preview.hpp:84
BackgroundSlicingProcess * m_process
Definition GUI_Preview.hpp:85
bool init(wxWindow *parent, Bed3D &bed, Model *model)
Definition GUI_Preview.cpp:190

References init(), and load_print().

+ Here is the call graph for this function:

◆ ~Preview()

Slic3r::GUI::Preview::~Preview ( )
virtual
249{
251
252 if (m_canvas != nullptr)
253 delete m_canvas;
254
255 if (m_canvas_widget != nullptr)
256 delete m_canvas_widget;
257}
wxGLCanvas * m_canvas_widget
Definition GUI_Preview.hpp:78
void unbind_event_handlers()
Definition GUI_Preview.cpp:375
GLCanvas3D * m_canvas
Definition GUI_Preview.hpp:79

References m_canvas, m_canvas_widget, and unbind_event_handlers().

+ Here is the call graph for this function:

Member Function Documentation

◆ bed_shape_changed()

void Slic3r::GUI::Preview::bed_shape_changed ( )
266{
267 if (m_canvas != nullptr)
269}
void bed_shape_changed()
Definition GLCanvas3D.cpp:1718

References Slic3r::GUI::GLCanvas3D::bed_shape_changed(), and m_canvas.

+ Here is the call graph for this function:

◆ bind_event_handlers()

void Slic3r::GUI::Preview::bind_event_handlers ( )
private
370{
371 Bind(wxEVT_SIZE, &Preview::on_size, this);
372 m_moves_slider->Bind(wxEVT_SCROLL_CHANGED, &Preview::on_moves_slider_scroll_changed, this);
373}
DoubleSlider::Control * m_moves_slider
Definition GUI_Preview.hpp:103
void on_moves_slider_scroll_changed(wxCommandEvent &event)
Definition GUI_Preview.cpp:916
void on_size(wxSizeEvent &evt)
Definition GUI_Preview.cpp:392

References m_moves_slider, on_moves_slider_scroll_changed(), and on_size().

Referenced by init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ check_layers_slider_values()

void Slic3r::GUI::Preview::check_layers_slider_values ( std::vector< CustomGCode::Item > &  ticks_from_model,
const std::vector< double > &  layers_z 
)
private
459{
460 // All ticks that would end up outside the slider range should be erased.
461 // TODO: this should be placed into more appropriate part of code,
462 // this function is e.g. not called when the last object is deleted
463 unsigned int old_size = ticks_from_model.size();
464 ticks_from_model.erase(std::remove_if(ticks_from_model.begin(), ticks_from_model.end(),
465 [layers_z](CustomGCode::Item val)
466 {
467 auto it = std::lower_bound(layers_z.begin(), layers_z.end(), val.print_z - DoubleSlider::epsilon());
468 return it == layers_z.end();
469 }),
470 ticks_from_model.end());
471 if (ticks_from_model.size() != old_size)
473}

References m_schedule_background_process.

Referenced by update_layers_slider().

+ Here is the caller graph for this function:

◆ create_layers_slider_sizer()

wxBoxSizer * Slic3r::GUI::Preview::create_layers_slider_sizer ( )
private
399{
400 wxBoxSizer* sizer = new wxBoxSizer(wxHORIZONTAL);
401 m_layers_slider = new DoubleSlider::Control(this, wxID_ANY, 0, 0, 0, 100);
402
403 m_layers_slider->SetDrawMode(wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology() == ptSLA,
404 wxGetApp().preset_bundle->prints.get_edited_preset().config.opt_bool("complete_objects"));
405 m_layers_slider->enable_action_icon(wxGetApp().is_editor());
406
407 sizer->Add(m_layers_slider, 0, wxEXPAND, 0);
408
409 // sizer, m_canvas_widget
411 m_canvas_widget->Bind(wxEVT_KEY_UP, [this](wxKeyEvent& event) {
412 if (event.GetKeyCode() == WXK_SHIFT)
414 event.Skip();
415 });
416
417 m_layers_slider->Bind(wxEVT_SCROLL_CHANGED, &Preview::on_layers_slider_scroll_changed, this);
418
419 Bind(DoubleSlider::wxCUSTOMEVT_TICKSCHANGED, [this](wxEvent&) {
420 Model& model = wxGetApp().plater()->model();
421 model.custom_gcode_per_print_z = m_layers_slider->GetTicksValues();
423
425 reload_print(false);
426 });
427
428 return sizer;
429}
Info GetTicksValues() const
Definition DoubleSlider.cpp:353
void UseDefaultColors(bool def_colors_on)
Definition DoubleSlider.hpp:276
void SetDrawMode(bool is_sla_print, bool is_sequential_print)
Definition DoubleSlider.cpp:443
void enable_action_icon(bool enable)
Definition DoubleSlider.hpp:295
void on_layers_slider_scroll_changed(wxCommandEvent &event)
Definition GUI_Preview.cpp:899
void reload_print(bool keep_volumes=false)
Definition GUI_Preview.cpp:293
DoubleSlider::Control * m_layers_slider
Definition GUI_Preview.hpp:102
void update_layers_slider_from_canvas(wxKeyEvent &event)
Definition GUI_Preview.cpp:668
bool m_keep_current_preview_type
Definition GUI_Preview.hpp:98
@ ptSLA
Definition Config.hpp:209

References Slic3r::Model::custom_gcode_per_print_z, Slic3r::DoubleSlider::Control::enable_action_icon(), Slic3r::DoubleSlider::Control::GetTicksValues(), m_canvas_widget, m_keep_current_preview_type, m_layers_slider, m_schedule_background_process, on_layers_slider_scroll_changed(), Slic3r::ptSLA, reload_print(), Slic3r::DoubleSlider::Control::SetDrawMode(), update_layers_slider_from_canvas(), and Slic3r::DoubleSlider::Control::UseDefaultColors().

Referenced by init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ edit_layers_slider()

void Slic3r::GUI::Preview::edit_layers_slider ( wxKeyEvent &  evt)
365{
366 if (m_layers_slider != nullptr) m_layers_slider->OnChar(evt);
367}
void OnChar(wxKeyEvent &event)
Definition DoubleSlider.cpp:1892

References m_layers_slider, and Slic3r::DoubleSlider::Control::OnChar().

+ Here is the call graph for this function:

◆ enable_moves_slider()

void Slic3r::GUI::Preview::enable_moves_slider ( bool  enable)
733{
734 bool render_as_disabled = !enable;
735 if (m_moves_slider != nullptr && m_moves_slider->is_rendering_as_disabled() != render_as_disabled) {
736 m_moves_slider->set_render_as_disabled(render_as_disabled);
737 m_moves_slider->Refresh();
738 }
739}
bool is_rendering_as_disabled() const
Definition DoubleSlider.hpp:262
void set_render_as_disabled(bool value)
Definition DoubleSlider.hpp:261

References Slic3r::DoubleSlider::Control::is_rendering_as_disabled(), m_moves_slider, and Slic3r::DoubleSlider::Control::set_render_as_disabled().

+ Here is the call graph for this function:

◆ get_canvas3d()

GLCanvas3D * Slic3r::GUI::Preview::get_canvas3d ( )
inline
127{ return m_canvas; }

References m_canvas.

Referenced by Slic3r::GUI::Plater::priv::is_legend_shown(), msw_rescale(), and Slic3r::GUI::Plater::priv::show_legend().

+ Here is the caller graph for this function:

◆ get_wxglcanvas()

wxGLCanvas * Slic3r::GUI::Preview::get_wxglcanvas ( )
inline
126{ return m_canvas_widget; }

References m_canvas_widget.

◆ hide_layers_slider()

void Slic3r::GUI::Preview::hide_layers_slider ( )
387{
388 m_layers_slider_sizer->Hide((size_t)0);
389 Layout();
390}
wxBoxSizer * m_layers_slider_sizer
Definition GUI_Preview.hpp:81

References m_layers_slider_sizer.

Referenced by load_print_as_fff(), and load_print_as_sla().

+ Here is the caller graph for this function:

◆ init()

bool Slic3r::GUI::Preview::init ( wxWindow *  parent,
Bed3D bed,
Model model 
)
private
191{
192 if (!Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 /* disable wxTAB_TRAVERSAL */))
193 return false;
194
195 // to match the background of the sliders
196#ifdef _WIN32
197 wxGetApp().UpdateDarkUI(this);
198#else
199 SetBackgroundColour(GetParent()->GetBackgroundColour());
200#endif // _WIN32
201
203 if (m_canvas_widget == nullptr)
204 return false;
205
206 m_canvas = new GLCanvas3D(m_canvas_widget, bed);
207 m_canvas->set_context(wxGetApp().init_glcontext(*m_canvas_widget));
210 m_canvas->set_model(model);
214
216
217 wxGetApp().UpdateDarkUI(m_bottom_toolbar_panel = new wxPanel(this));
218
219 m_left_sizer = new wxBoxSizer(wxVERTICAL);
220 m_left_sizer->Add(m_canvas_widget, 1, wxALL | wxEXPAND, 0);
221
222 wxBoxSizer* right_sizer = new wxBoxSizer(wxVERTICAL);
223 right_sizer->Add(m_layers_slider_sizer, 1, wxEXPAND, 0);
224
225 m_moves_slider = new DoubleSlider::Control(m_bottom_toolbar_panel, wxID_ANY, 0, 0, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL);
227
228 wxBoxSizer* bottom_toolbar_sizer = new wxBoxSizer(wxHORIZONTAL);
229 bottom_toolbar_sizer->Add(m_moves_slider, 1, wxALL | wxEXPAND, 0);
230 m_bottom_toolbar_panel->SetSizer(bottom_toolbar_sizer);
231
232 m_left_sizer->Add(m_bottom_toolbar_panel, 0, wxALL | wxEXPAND, 0);
234
235 wxBoxSizer* main_sizer = new wxBoxSizer(wxHORIZONTAL);
236 main_sizer->Add(m_left_sizer, 1, wxALL | wxEXPAND, 0);
237 main_sizer->Add(right_sizer, 0, wxALL | wxEXPAND, 0);
238
239 SetSizer(main_sizer);
240 SetMinSize(GetSize());
241 GetSizer()->SetSizeHints(this);
242
244
245 return true;
246}
void set_process(BackgroundSlicingProcess *process)
Definition GLCanvas3D.cpp:1707
void enable_legend_texture(bool enable)
Definition GLCanvas3D.cpp:1796
void enable_dynamic_background(bool enable)
Definition GLCanvas3D.cpp:1831
void set_config(const DynamicPrintConfig *config)
Definition GLCanvas3D.cpp:1701
void set_context(wxGLContext *context)
Definition GLCanvas3D.hpp:708
void allow_multisample(bool allow)
Definition GLCanvas3D.cpp:1836
void set_model(Model *model)
Definition GLCanvas3D.cpp:1712
static bool can_multisample()
Definition OpenGLManager.hpp:137
static wxGLCanvas * create_wxglcanvas(wxWindow &parent)
Definition OpenGLManager.cpp:539
wxPanel * m_bottom_toolbar_panel
Definition GUI_Preview.hpp:82
wxBoxSizer * create_layers_slider_sizer()
Definition GUI_Preview.cpp:398
wxBoxSizer * m_left_sizer
Definition GUI_Preview.hpp:80
void bind_event_handlers()
Definition GUI_Preview.cpp:369
@ dmSequentialGCodeView
Definition DoubleSlider.hpp:89

References Slic3r::GUI::GLCanvas3D::allow_multisample(), bind_event_handlers(), Slic3r::GUI::OpenGLManager::can_multisample(), create_layers_slider_sizer(), Slic3r::GUI::OpenGLManager::create_wxglcanvas(), Slic3r::DoubleSlider::dmSequentialGCodeView, Slic3r::GUI::GLCanvas3D::enable_dynamic_background(), Slic3r::GUI::GLCanvas3D::enable_legend_texture(), m_bottom_toolbar_panel, m_canvas, m_canvas_widget, m_config, m_layers_slider_sizer, m_left_sizer, m_moves_slider, m_process, Slic3r::GUI::GLCanvas3D::set_config(), Slic3r::GUI::GLCanvas3D::set_context(), Slic3r::GUI::GLCanvas3D::set_model(), Slic3r::GUI::GLCanvas3D::set_process(), and Slic3r::DoubleSlider::Control::SetDrawMode().

Referenced by Preview().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ is_loaded()

bool Slic3r::GUI::Preview::is_loaded ( ) const
inline
145{ return m_loaded; }
bool m_loaded
Definition GUI_Preview.hpp:100

References m_loaded.

Referenced by Slic3r::GUI::Plater::priv::is_preview_loaded().

+ Here is the caller graph for this function:

◆ jump_layers_slider()

void Slic3r::GUI::Preview::jump_layers_slider ( wxKeyEvent &  evt)
355{
357}

References m_layers_slider, and Slic3r::DoubleSlider::Control::OnChar().

+ Here is the call graph for this function:

◆ load_print()

void Slic3r::GUI::Preview::load_print ( bool  keep_z_range = false)
283{
285 if (tech == ptFFF)
286 load_print_as_fff(keep_z_range);
287 else if (tech == ptSLA)
289
290 Layout();
291}
PrinterTechnology current_printer_technology() const
Definition BackgroundSlicingProcess.cpp:129
void load_print_as_sla()
Definition GUI_Preview.cpp:859
void load_print_as_fff(bool keep_z_range=false)
Definition GUI_Preview.cpp:741
PrinterTechnology
Definition Config.hpp:205
@ ptFFF
Definition Config.hpp:207

References Slic3r::BackgroundSlicingProcess::current_printer_technology(), load_print_as_fff(), load_print_as_sla(), m_process, Slic3r::ptFFF, and Slic3r::ptSLA.

Referenced by Preview(), refresh_print(), and reload_print().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ load_print_as_fff()

void Slic3r::GUI::Preview::load_print_as_fff ( bool  keep_z_range = false)
private
742{
743 if (wxGetApp().mainframe == nullptr || wxGetApp().is_recreating_gui())
744 // avoid processing while mainframe is being constructed
745 return;
746
748 return;
749
750 // we require that there's at least one object and the posSlice step
751 // is performed on all of them(this ensures that _shifted_copies was
752 // populated and we know the number of layers)
753 bool has_layers = false;
754 const Print *print = m_process->fff_print();
755 if (print->is_step_done(posSlice)) {
756 for (const PrintObject* print_object : print->objects())
757 if (! print_object->layers().empty()) {
758 has_layers = true;
759 break;
760 }
761 }
762 if (print->is_step_done(posSupportMaterial)) {
763 for (const PrintObject* print_object : print->objects())
764 if (! print_object->support_layers().empty()) {
765 has_layers = true;
766 break;
767 }
768 }
769
770 if (wxGetApp().is_editor() && !has_layers) {
773 m_left_sizer->Layout();
774 Refresh();
775 m_canvas_widget->Refresh();
776 return;
777 }
778
780 bool gcode_preview_data_valid = !m_gcode_result->moves.empty();
781
782 // Collect colors per extruder.
783 std::vector<std::string> colors;
784 std::vector<CustomGCode::Item> color_print_values = {};
785 // set color print values, if it si selected "ColorPrint" view type
786 if (gcode_view_type == GCodeViewer::EViewType::ColorPrint) {
787 colors = wxGetApp().plater()->get_colors_for_color_print(m_gcode_result);
788
789 if (!gcode_preview_data_valid) {
790 if (wxGetApp().is_editor())
791 color_print_values = wxGetApp().plater()->model().custom_gcode_per_print_z.gcodes;
792 else
793 color_print_values = m_canvas->get_custom_gcode_per_print_z();
794 colors.push_back("#808080"); // gray color for pause print or custom G-code
795 }
796 }
797 else if (gcode_preview_data_valid || gcode_view_type == GCodeViewer::EViewType::Tool) {
798 colors = wxGetApp().plater()->get_extruder_colors_from_plater_config(m_gcode_result);
799 color_print_values.clear();
800 }
801
802 std::vector<double> zs;
803
804 if (IsShown()) {
806 if (gcode_preview_data_valid) {
807 // Load the real G-code preview.
809 m_left_sizer->Layout();
810 Refresh();
812 if (!zs.empty())
814 m_loaded = true;
815 }
816 else if (wxGetApp().is_editor()) {
817 // Load the initial preview based on slices, not the final G-code.
818 m_canvas->load_preview(colors, color_print_values);
820 m_left_sizer->Layout();
821 Refresh();
822 zs = m_canvas->get_volumes_print_zs(true);
823 }
824 else {
826 m_left_sizer->Layout();
827 Refresh();
828 }
829
830 if (!zs.empty() && !m_keep_current_preview_type) {
831 unsigned int number_extruders = wxGetApp().is_editor() ?
832 (unsigned int)print->extruders().size() :
834 std::vector<Item> gcodes = wxGetApp().is_editor() ?
835 wxGetApp().plater()->model().custom_gcode_per_print_z.gcodes :
837 const bool contains_color_gcodes = std::any_of(std::begin(gcodes), std::end(gcodes),
838 [] (auto const& item) { return item.type == CustomGCode::Type::ColorChange; });
839 const GCodeViewer::EViewType choice = contains_color_gcodes ?
841 (number_extruders > 1) ? GCodeViewer::EViewType::Tool : GCodeViewer::EViewType::FeatureType;
842 if (choice != gcode_view_type) {
844 if (wxGetApp().is_gcode_viewer())
847 }
848 }
849
850 if (zs.empty()) {
851 // all layers filtered out
853 m_canvas_widget->Refresh();
854 } else
855 update_layers_slider(zs, keep_z_range);
856 }
857}
const Print * fff_print() const
Definition BackgroundSlicingProcess.hpp:110
EViewType
Definition GCodeViewer.hpp:732
void load_preview(const std::vector< std::string > &str_tool_colors, const std::vector< CustomGCode::Item > &color_print_values)
Definition GLCanvas3D.cpp:2730
GCodeViewer::EViewType get_gcode_view_preview_type() const
Definition GLCanvas3D.hpp:860
size_t get_gcode_extruders_count()
Definition GLCanvas3D.hpp:848
void set_selected_extruder(int extruder)
Definition GLCanvas3D.hpp:905
void set_gcode_view_preview_type(GCodeViewer::EViewType type)
Definition GLCanvas3D.hpp:859
void load_gcode_preview(const GCodeProcessorResult &gcode_result, const std::vector< std::string > &str_tool_colors)
Definition GLCanvas3D.cpp:2694
std::vector< CustomGCode::Item > & get_custom_gcode_per_print_z()
Definition GLCanvas3D.hpp:847
const std::vector< double > & get_gcode_layers_zs() const
Definition GLCanvas3D.cpp:2166
std::vector< double > get_volumes_print_zs(bool active_only) const
Definition GLCanvas3D.cpp:2171
void hide_layers_slider()
Definition GUI_Preview.cpp:386
void update_layers_slider(const std::vector< double > &layers_z, bool keep_z_range=false)
Definition GUI_Preview.cpp:475
void refresh_print()
Definition GUI_Preview.cpp:320
if(!(yy_init))
Definition lexer.c:1190
@ ColorChange
Definition CustomGCode.hpp:15
@ posSlice
Definition Print.hpp:69
@ posSupportMaterial
Definition Print.hpp:70
bool empty(const BoundingBoxBase< PointType, PointsType > &bb)
Definition BoundingBox.hpp:229
std::vector< MoveVertex > moves
Definition GCodeProcessor.hpp:139

References Slic3r::CustomGCode::ColorChange, Slic3r::GUI::GCodeViewer::ColorPrint, Slic3r::BackgroundSlicingProcess::current_printer_technology(), Slic3r::Print::extruders(), Slic3r::GUI::GCodeViewer::FeatureType, Slic3r::BackgroundSlicingProcess::fff_print(), Slic3r::GUI::GLCanvas3D::get_custom_gcode_per_print_z(), Slic3r::GUI::GLCanvas3D::get_gcode_extruders_count(), Slic3r::GUI::GLCanvas3D::get_gcode_layers_zs(), Slic3r::GUI::GLCanvas3D::get_gcode_view_preview_type(), Slic3r::GUI::GLCanvas3D::get_volumes_print_zs(), hide_layers_slider(), Slic3r::Print::is_step_done(), Slic3r::GUI::GLCanvas3D::load_gcode_preview(), Slic3r::GUI::GLCanvas3D::load_preview(), m_bottom_toolbar_panel, m_canvas, m_canvas_widget, m_gcode_result, m_keep_current_preview_type, m_left_sizer, m_loaded, m_process, Slic3r::GCodeProcessorResult::moves, Slic3r::Print::objects(), Slic3r::posSlice, Slic3r::posSupportMaterial, Slic3r::ptFFF, refresh_print(), Slic3r::GUI::GLCanvas3D::set_gcode_view_preview_type(), Slic3r::GUI::GLCanvas3D::set_selected_extruder(), Slic3r::GUI::GCodeViewer::Tool, and update_layers_slider().

Referenced by load_print().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ load_print_as_sla()

void Slic3r::GUI::Preview::load_print_as_sla ( )
private
860{
862 return;
863
864 unsigned int n_layers = 0;
865 const SLAPrint* print = m_process->sla_print();
866
867 std::vector<double> zs;
868 double initial_layer_height = print->material_config().initial_layer_height.value;
869 for (const SLAPrintObject* obj : print->objects())
870 if (obj->is_step_done(slaposSliceSupports) && !obj->get_slice_index().empty()) {
871 auto low_coord = obj->get_slice_index().front().print_level();
872 for (auto& rec : obj->get_slice_index())
873 zs.emplace_back(initial_layer_height + (rec.print_level() - low_coord) * SCALING_FACTOR);
874 }
876
879
880 n_layers = (unsigned int)zs.size();
881 if (n_layers == 0) {
883 m_canvas_widget->Refresh();
884 }
885
886 if (IsShown()) {
889 m_left_sizer->Layout();
890 Refresh();
891
892 if (n_layers > 0)
894
895 m_loaded = true;
896 }
897}
const SLAPrint * sla_print() const
Definition BackgroundSlicingProcess.hpp:111
void set_use_clipping_planes(bool use)
Definition GLCanvas3D.hpp:776
void reset_clipping_planes_cache()
Definition GLCanvas3D.hpp:775
void load_sla_preview()
Definition GLCanvas3D.cpp:2716
const SLAMaterialConfig & material_config() const
Definition SLAPrint.hpp:484
static constexpr double SCALING_FACTOR
Definition libslic3r.h:57
@ slaposSliceSupports
Definition SLAPrint.hpp:35
void sort_remove_duplicates(std::vector< T > &vec)
Definition libslic3r.h:188

References Slic3r::BackgroundSlicingProcess::current_printer_technology(), hide_layers_slider(), Slic3r::GUI::GLCanvas3D::load_sla_preview(), m_bottom_toolbar_panel, m_canvas, m_canvas_widget, m_left_sizer, m_loaded, m_process, Slic3r::SLAPrint::material_config(), Slic3r::SLAPrint::objects(), Slic3r::ptSLA, Slic3r::GUI::GLCanvas3D::reset_clipping_planes_cache(), SCALING_FACTOR, Slic3r::GUI::GLCanvas3D::set_use_clipping_planes(), Slic3r::BackgroundSlicingProcess::sla_print(), Slic3r::slaposSliceSupports, Slic3r::sort_remove_duplicates(), and update_layers_slider().

Referenced by load_print().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ move_layers_slider()

void Slic3r::GUI::Preview::move_layers_slider ( wxKeyEvent &  evt)
360{
361 if (m_layers_slider != nullptr) m_layers_slider->OnKeyDown(evt);
362}
void OnKeyDown(wxKeyEvent &event)
Definition DoubleSlider.cpp:1825

References m_layers_slider, and Slic3r::DoubleSlider::Control::OnKeyDown().

+ Here is the call graph for this function:

◆ move_moves_slider()

void Slic3r::GUI::Preview::move_moves_slider ( wxKeyEvent &  evt)
382{
383 if (m_moves_slider != nullptr) m_moves_slider->OnKeyDown(evt);
384}

References m_moves_slider, and Slic3r::DoubleSlider::Control::OnKeyDown().

+ Here is the call graph for this function:

◆ msw_rescale()

void Slic3r::GUI::Preview::msw_rescale ( )
331{
332 // rescale slider
334 if (m_moves_slider != nullptr) m_moves_slider->msw_rescale();
335
336 // rescale warning legend on the canvas
338
339 // rescale legend
341}
void msw_rescale()
Definition DoubleSlider.cpp:154
void msw_rescale()
Definition GLCanvas3D.cpp:4499
GLCanvas3D * get_canvas3d()
Definition GUI_Preview.hpp:127

References get_canvas3d(), m_layers_slider, m_moves_slider, Slic3r::DoubleSlider::Control::msw_rescale(), Slic3r::GUI::GLCanvas3D::msw_rescale(), and refresh_print().

+ Here is the call graph for this function:

◆ on_layers_slider_scroll_changed()

void Slic3r::GUI::Preview::on_layers_slider_scroll_changed ( wxCommandEvent &  event)
private
900{
901 if (IsShown()) {
903 if (tech == ptFFF) {
905 m_canvas->set_toolpaths_z_range({ static_cast<unsigned int>(m_layers_slider->GetLowerValue()), static_cast<unsigned int>(m_layers_slider->GetHigherValue()) });
907 }
908 else if (tech == ptSLA) {
909 m_canvas->set_clipping_plane(0, ClippingPlane(Vec3d::UnitZ(), -m_layers_slider->GetLowerValueD()));
910 m_canvas->set_clipping_plane(1, ClippingPlane(-Vec3d::UnitZ(), m_layers_slider->GetHigherValueD()));
911 m_canvas->render();
912 }
913 }
914}
double GetLowerValueD()
Definition DoubleSlider.hpp:230
int GetHigherValue() const
Definition DoubleSlider.hpp:228
int GetLowerValue() const
Definition DoubleSlider.hpp:227
double GetHigherValueD()
Definition DoubleSlider.hpp:231
void set_clipping_plane(unsigned int id, const ClippingPlane &plane)
Definition GLCanvas3D.hpp:769
void set_toolpaths_z_range(const std::array< unsigned int, 2 > &range)
Definition GLCanvas3D.cpp:2196
void set_as_dirty()
Definition GLCanvas3D.cpp:1494
void set_volumes_z_range(const std::array< double, 2 > &range)
Definition GLCanvas3D.cpp:2191
void render()
Definition GLCanvas3D.cpp:1880

References Slic3r::BackgroundSlicingProcess::current_printer_technology(), Slic3r::DoubleSlider::Control::GetHigherValue(), Slic3r::DoubleSlider::Control::GetHigherValueD(), Slic3r::DoubleSlider::Control::GetLowerValue(), Slic3r::DoubleSlider::Control::GetLowerValueD(), m_canvas, m_layers_slider, m_process, Slic3r::ptFFF, Slic3r::ptSLA, Slic3r::GUI::GLCanvas3D::render(), Slic3r::GUI::GLCanvas3D::set_as_dirty(), Slic3r::GUI::GLCanvas3D::set_clipping_plane(), Slic3r::GUI::GLCanvas3D::set_toolpaths_z_range(), and Slic3r::GUI::GLCanvas3D::set_volumes_z_range().

Referenced by create_layers_slider_sizer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ on_moves_slider_scroll_changed()

void Slic3r::GUI::Preview::on_moves_slider_scroll_changed ( wxCommandEvent &  event)
private
917{
918 m_canvas->update_gcode_sequential_view_current(static_cast<unsigned int>(m_moves_slider->GetLowerValueD() - 1.0), static_cast<unsigned int>(m_moves_slider->GetHigherValueD() - 1.0));
919 m_canvas->render();
920}
void update_gcode_sequential_view_current(unsigned int first, unsigned int last)
Definition GLCanvas3D.hpp:749

References Slic3r::DoubleSlider::Control::GetHigherValueD(), Slic3r::DoubleSlider::Control::GetLowerValueD(), m_canvas, m_moves_slider, Slic3r::GUI::GLCanvas3D::render(), and Slic3r::GUI::GLCanvas3D::update_gcode_sequential_view_current().

Referenced by bind_event_handlers(), and unbind_event_handlers().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ on_size()

void Slic3r::GUI::Preview::on_size ( wxSizeEvent &  evt)
private
393{
394 evt.Skip();
395 Refresh();
396}

Referenced by bind_event_handlers(), and unbind_event_handlers().

+ Here is the caller graph for this function:

◆ refresh_print()

void Slic3r::GUI::Preview::refresh_print ( )
321{
322 m_loaded = false;
323
324 if (!IsShown())
325 return;
326
327 load_print(true);
328}

References load_print(), and m_loaded.

Referenced by load_print_as_fff(), and msw_rescale().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ reload_print()

void Slic3r::GUI::Preview::reload_print ( bool  keep_volumes = false)
294{
295#ifdef __linux__
296 // We are getting mysterious crashes on Linux in gtk due to OpenGL context activation GH #1874 #1955.
297 // So we are applying a workaround here: a delayed release of OpenGL vertex buffers.
298 if (!IsShown())
299 {
300 m_volumes_cleanup_required = !keep_volumes;
301 return;
302 }
303#endif /* __linux__ */
304 if (
305#ifdef __linux__
306 m_volumes_cleanup_required ||
307#endif /* __linux__ */
308 !keep_volumes)
309 {
311 m_loaded = false;
312#ifdef __linux__
313 m_volumes_cleanup_required = false;
314#endif /* __linux__ */
315 }
316
317 load_print();
318}
void reset_volumes()
Definition GLCanvas3D.cpp:1504

References load_print(), m_canvas, m_loaded, and Slic3r::GUI::GLCanvas3D::reset_volumes().

Referenced by create_layers_slider_sizer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ reset_layers_slider()

void Slic3r::GUI::Preview::reset_layers_slider ( )
private
663{
666}
void SetLowerValue(const int lower_val)
Definition DoubleSlider.cpp:212
void SetHigherValue(const int higher_val)
Definition DoubleSlider.cpp:225

References m_layers_slider, Slic3r::DoubleSlider::Control::SetHigherValue(), and Slic3r::DoubleSlider::Control::SetLowerValue().

+ Here is the call graph for this function:

◆ select_view()

void Slic3r::GUI::Preview::select_view ( const std::string &  direction)
272{
273 m_canvas->select_view(direction);
274}
void select_view(const std::string &direction)
Definition GLCanvas3D.cpp:1867

References m_canvas, and Slic3r::GUI::GLCanvas3D::select_view().

+ Here is the call graph for this function:

◆ set_as_dirty()

void Slic3r::GUI::Preview::set_as_dirty ( )
260{
261 if (m_canvas != nullptr)
263}

References m_canvas, and Slic3r::GUI::GLCanvas3D::set_as_dirty().

+ Here is the call graph for this function:

◆ set_drop_target()

void Slic3r::GUI::Preview::set_drop_target ( wxDropTarget *  target)
277{
278 if (target != nullptr)
279 SetDropTarget(target);
280}

◆ set_keep_current_preview_type()

void Slic3r::GUI::Preview::set_keep_current_preview_type ( bool  value)
inline

◆ set_layers_slider_values_range()

void Slic3r::GUI::Preview::set_layers_slider_values_range ( int  bottom,
int  top 
)
185{
188}
int GetMinValue() const
Definition DoubleSlider.hpp:223
int GetMaxValue() const
Definition DoubleSlider.hpp:224

References Slic3r::DoubleSlider::Control::GetMaxValue(), Slic3r::DoubleSlider::Control::GetMinValue(), m_layers_slider, Slic3r::DoubleSlider::Control::SetHigherValue(), and Slic3r::DoubleSlider::Control::SetLowerValue().

+ Here is the call graph for this function:

◆ sys_color_changed()

void Slic3r::GUI::Preview::sys_color_changed ( )
344{
345#ifdef _WIN32
346 wxWindowUpdateLocker noUpdates(this);
347 wxGetApp().UpdateAllStaticTextDarkUI(m_bottom_toolbar_panel);
348#endif // _WIN32
349
350 if (m_layers_slider != nullptr)
352}
void sys_color_changed()
Definition DoubleSlider.cpp:173

References m_bottom_toolbar_panel, m_layers_slider, and Slic3r::DoubleSlider::Control::sys_color_changed().

+ Here is the call graph for this function:

◆ unbind_event_handlers()

void Slic3r::GUI::Preview::unbind_event_handlers ( )
private
376{
377 Unbind(wxEVT_SIZE, &Preview::on_size, this);
378 m_moves_slider->Unbind(wxEVT_SCROLL_CHANGED, &Preview::on_moves_slider_scroll_changed, this);
379}

References m_moves_slider, on_moves_slider_scroll_changed(), and on_size().

Referenced by ~Preview().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ update_layers_slider()

void Slic3r::GUI::Preview::update_layers_slider ( const std::vector< double > &  layers_z,
bool  keep_z_range = false 
)
private
476{
477 // Save the initial slider span.
478 double z_low = m_layers_slider->GetLowerValueD();
479 double z_high = m_layers_slider->GetHigherValueD();
480 bool was_empty = m_layers_slider->GetMaxValue() == 0;
481
482 bool force_sliders_full_range = was_empty;
483 if (!keep_z_range)
484 {
485 bool span_changed = layers_z.empty() || std::abs(layers_z.back() - m_layers_slider->GetMaxValueD()) > DoubleSlider::epsilon()/*1e-6*/;
486 force_sliders_full_range |= span_changed;
487 }
488 bool snap_to_min = force_sliders_full_range || m_layers_slider->is_lower_at_min();
489 bool snap_to_max = force_sliders_full_range || m_layers_slider->is_higher_at_max();
490
491 // Detect and set manipulation mode for double slider
493
494 Plater* plater = wxGetApp().plater();
495 CustomGCode::Info ticks_info_from_model;
496 if (wxGetApp().is_editor())
497 ticks_info_from_model = plater->model().custom_gcode_per_print_z;
498 else {
499 ticks_info_from_model.mode = CustomGCode::Mode::SingleExtruder;
500 ticks_info_from_model.gcodes = m_canvas->get_custom_gcode_per_print_z();
501 }
502 check_layers_slider_values(ticks_info_from_model.gcodes, layers_z);
503
504 //first of all update extruder colors to avoid crash, when we are switching printer preset from MM to SM
507 assert(m_layers_slider->GetMinValue() == 0);
508 m_layers_slider->SetMaxValue(layers_z.empty() ? 0 : layers_z.size() - 1);
509
510 int idx_low = 0;
511 int idx_high = m_layers_slider->GetMaxValue();
512 if (!layers_z.empty()) {
513 if (!snap_to_min) {
514 int idx_new = find_close_layer_idx(layers_z, z_low, DoubleSlider::epsilon()/*1e-6*/);
515 if (idx_new != -1)
516 idx_low = idx_new;
517 }
518 if (!snap_to_max) {
519 int idx_new = find_close_layer_idx(layers_z, z_high, DoubleSlider::epsilon()/*1e-6*/);
520 if (idx_new != -1)
521 idx_high = idx_new;
522 }
523 }
524 m_layers_slider->SetSelectionSpan(idx_low, idx_high);
525 m_layers_slider->SetTicksValues(ticks_info_from_model);
526
527 bool sla_print_technology = plater->printer_technology() == ptSLA;
528 bool sequential_print = wxGetApp().preset_bundle->prints.get_edited_preset().config.opt_bool("complete_objects");
529 m_layers_slider->SetDrawMode(sla_print_technology, sequential_print);
530 if (sla_print_technology)
532 else {
533 auto print_mode_stat = m_gcode_result->print_statistics.modes.front();
534 m_layers_slider->SetLayersTimes(print_mode_stat.layers_times, print_mode_stat.time);
535 }
536
537 // check if ticks_info_from_model contains ColorChange g-code
538 bool color_change_already_exists = false;
539 for (const CustomGCode::Item& gcode: ticks_info_from_model.gcodes)
540 if (gcode.type == CustomGCode::Type::ColorChange) {
541 color_change_already_exists = true;
542 break;
543 }
544
545 // Suggest the auto color change, if model looks like sign
546 if (!color_change_already_exists &&
547 wxGetApp().app_config->get_bool("allow_auto_color_change") &&
549 {
550 const Print& print = wxGetApp().plater()->fff_print();
551
552 //bool is_possible_auto_color_change = false;
553 for (auto object : print.objects()) {
554 double object_x = double(object->size().x());
555 double object_y = double(object->size().y());
556
557 // if it's sign, than object have not to be a too height
558 double height = object->height();
559 coord_t longer_side = std::max(object_x, object_y);
560 auto num_layers = int(object->layers().size());
561 if (height / longer_side > 0.3 || num_layers < 2)
562 continue;
563
564 const ExPolygons& bottom = object->get_layer(0)->lslices;
565 double bottom_area = area(bottom);
566
567 // at least 25% of object's height have to be a solid
568 int i, min_solid_height = int(0.25 * num_layers);
569 for (i = 1; i <= min_solid_height; ++ i) {
570 double cur_area = area(object->get_layer(i)->lslices);
571 if (!DoubleSlider::equivalent_areas(bottom_area, cur_area)) {
572 // but due to the elephant foot compensation, the first layer may be slightly smaller than the others
573 if (i == 1 && fabs(cur_area - bottom_area) / bottom_area < 0.1) {
574 // So, let process this case and use second layer as a bottom
575 bottom_area = cur_area;
576 continue;
577 }
578 break;
579 }
580 }
581 if (i < min_solid_height)
582 continue;
583
584 if (DoubleSlider::check_color_change(object, i, num_layers, true, [this, object](const Layer*) {
585 NotificationManager* notif_mngr = wxGetApp().plater()->get_notification_manager();
586 notif_mngr->push_notification(
588 _u8L("NOTE:") + "\n" +
589 format(_u8L("Sliced object \"%1%\" looks like a logo or a sign"), object->model_object()->name) + "\n",
590 _u8L("Apply color change automatically"),
591 [this](wxEvtHandler*) {
593 return true;
594 });
595
596 notif_mngr->apply_in_preview();
597 return true;
598 }) )
599 // first object with color chnages is found
600 break;
601 }
602 }
603
604 m_layers_slider_sizer->Show((size_t)0);
605 Layout();
606}
#define _u8L(s)
macro used to mark string used at localization, return same string
Definition SLAPrint.cpp:29
void SetExtruderColors(const std::vector< std::string > &extruder_colors)
Definition DoubleSlider.cpp:464
void SetSliderValues(const std::vector< double > &values)
Definition DoubleSlider.cpp:260
bool IsNewPrint()
Definition DoubleSlider.cpp:469
bool is_higher_at_max() const
Definition DoubleSlider.hpp:267
void SetLayersTimes(const std::vector< float > &layers_times, float total_time)
Definition DoubleSlider.cpp:404
void SetTicksValues(const Info &custom_gcode_per_print_z)
Definition DoubleSlider.cpp:372
bool is_lower_at_min() const
Definition DoubleSlider.hpp:266
void auto_color_change()
Definition DoubleSlider.cpp:2152
void SetSelectionSpan(const int lower_val, const int higher_val)
Definition DoubleSlider.cpp:238
void SetMaxValue(const int max_value)
Definition DoubleSlider.cpp:253
double GetMaxValueD()
Definition DoubleSlider.hpp:226
std::vector< std::string > get_extruder_colors_from_plater_config(const GCodeProcessorResult *const result=nullptr) const
Definition Plater.cpp:7149
const Model & model() const
Definition Plater.cpp:5222
PrinterTechnology printer_technology() const
Definition Plater.cpp:7269
const SLAPrint & sla_print() const
Definition Plater.cpp:5226
void update_layers_slider_mode()
Definition GUI_Preview.cpp:608
void check_layers_slider_values(std::vector< CustomGCode::Item > &ticks_from_model, const std::vector< double > &layers_z)
Definition GUI_Preview.cpp:458
CustomGCode::Info custom_gcode_per_print_z
Definition Model.hpp:1259
const SLAPrintStatistics & print_statistics() const
Definition SLAPrint.hpp:495
int32_t coord_t
Definition libslic3r.h:39
@ SingleExtruder
Definition CustomGCode.hpp:50
Type
Definition CustomGCode.hpp:14
constexpr double epsilon()
Definition DoubleSlider.hpp:28
bool check_color_change(const PrintObject *object, size_t frst_layer_id, size_t layers_cnt, bool check_overhangs, std::function< bool(const Layer *)> break_condition)
Definition DoubleSlider.cpp:2126
bool equivalent_areas(const double &bottom_area, const double &top_area)
Definition DoubleSlider.cpp:44
static Plater * plater()
Definition GUI_Factories.cpp:174
static int find_close_layer_idx(const std::vector< double > &zs, double &z, double eps)
Definition GUI_Preview.cpp:433
std::string format(const char *fmt, TArgs &&... args)
Definition format.hpp:56
coord_t height(const BoundingBox &box)
Definition Arrange.cpp:540
std::vector< ExPolygon > ExPolygons
Definition ExPolygon.hpp:13
double area(const ExPolygon &poly)
Definition ExPolygon.hpp:467
constexpr auto size(const C &c) -> decltype(c.size())
Definition span.hpp:183
Mode mode
Definition CustomGCode.hpp:64
PrintEstimatedStatistics print_statistics
Definition GCodeProcessor.hpp:152
std::array< Mode, static_cast< size_t >(ETimeMode::Count)> modes
Definition GCodeProcessor.hpp:70
std::vector< double > layers_times
Definition SLAPrint.hpp:410

References _u8L, Slic3r::GUI::NotificationManager::apply_in_preview(), Slic3r::area(), Slic3r::DoubleSlider::Control::auto_color_change(), Slic3r::DoubleSlider::check_color_change(), check_layers_slider_values(), Slic3r::CustomGCode::ColorChange, Slic3r::Model::custom_gcode_per_print_z, Slic3r::DoubleSlider::epsilon(), Slic3r::DoubleSlider::equivalent_areas(), Slic3r::GUI::find_close_layer_idx(), Slic3r::GUI::format(), Slic3r::CustomGCode::Info::gcodes, Slic3r::GUI::GLCanvas3D::get_custom_gcode_per_print_z(), Slic3r::GUI::Plater::get_extruder_colors_from_plater_config(), Slic3r::DoubleSlider::Control::GetHigherValueD(), Slic3r::DoubleSlider::Control::GetLowerValueD(), Slic3r::DoubleSlider::Control::GetMaxValue(), Slic3r::DoubleSlider::Control::GetMaxValueD(), Slic3r::DoubleSlider::Control::GetMinValue(), Slic3r::DoubleSlider::Control::is_higher_at_max(), Slic3r::DoubleSlider::Control::is_lower_at_min(), Slic3r::DoubleSlider::Control::IsNewPrint(), Slic3r::SLAPrintStatistics::layers_times, m_canvas, m_gcode_result, m_layers_slider, m_layers_slider_sizer, Slic3r::CustomGCode::Info::mode, Slic3r::GUI::Plater::model(), Slic3r::PrintEstimatedStatistics::modes, Slic3r::Print::objects(), Slic3r::GUI::plater(), Slic3r::GCodeProcessorResult::print_statistics, Slic3r::SLAPrint::print_statistics(), Slic3r::GUI::Plater::printer_technology(), Slic3r::GUI::NotificationManager::PrintInfoNotificationLevel, Slic3r::ptSLA, Slic3r::GUI::NotificationManager::push_notification(), Slic3r::DoubleSlider::Control::SetDrawMode(), Slic3r::DoubleSlider::Control::SetExtruderColors(), Slic3r::DoubleSlider::Control::SetLayersTimes(), Slic3r::DoubleSlider::Control::SetMaxValue(), Slic3r::DoubleSlider::Control::SetSelectionSpan(), Slic3r::DoubleSlider::Control::SetSliderValues(), Slic3r::DoubleSlider::Control::SetTicksValues(), Slic3r::GUI::SignDetected, Slic3r::CustomGCode::SingleExtruder, Slic3r::GUI::Plater::sla_print(), and update_layers_slider_mode().

Referenced by load_print_as_fff(), and load_print_as_sla().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ update_layers_slider_from_canvas()

void Slic3r::GUI::Preview::update_layers_slider_from_canvas ( wxKeyEvent &  event)
private
669{
670 if (event.HasModifiers()) {
671 event.Skip();
672 return;
673 }
674
675 const auto key = event.GetKeyCode();
676
677 if (key == 'S' || key == 'W') {
678 const int new_pos = key == 'W' ? m_layers_slider->GetHigherValue() + 1 : m_layers_slider->GetHigherValue() - 1;
681 }
682 else if (key == 'A' || key == 'D') {
683 const int new_pos = key == 'D' ? m_moves_slider->GetHigherValue() + 1 : m_moves_slider->GetHigherValue() - 1;
686 }
687 else if (key == 'X')
689 else if (key == WXK_SHIFT)
691 else
692 event.Skip();
693}
void ChangeOneLayerLock()
Definition DoubleSlider.cpp:1377
bool is_one_layer() const
Definition DoubleSlider.hpp:265

References Slic3r::DoubleSlider::Control::ChangeOneLayerLock(), Slic3r::DoubleSlider::Control::GetHigherValue(), Slic3r::DoubleSlider::Control::is_one_layer(), m_layers_slider, m_moves_slider, Slic3r::DoubleSlider::Control::SetHigherValue(), Slic3r::DoubleSlider::Control::SetLowerValue(), and Slic3r::DoubleSlider::Control::UseDefaultColors().

Referenced by create_layers_slider_sizer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ update_layers_slider_mode()

void Slic3r::GUI::Preview::update_layers_slider_mode ( )
private
609{
610 // true -> single-extruder printer profile OR
611 // multi-extruder printer profile , but whole model is printed by only one extruder
612 // false -> multi-extruder printer profile , and model is printed by several extruders
613 bool one_extruder_printed_model = true;
614
615 // extruder used for whole model for multi-extruder printer profile
616 int only_extruder = -1;
617
618 if (wxGetApp().extruders_edited_cnt() > 1)
619 {
620 const ModelObjectPtrs& objects = wxGetApp().plater()->model().objects;
621
622 // check if whole model uses just only one extruder
623 if (!objects.empty())
624 {
625 const int extruder = objects[0]->config.has("extruder") ?
626 objects[0]->config.option("extruder")->getInt() : 0;
627
628 auto is_one_extruder_printed_model = [objects, extruder]()
629 {
630 for (ModelObject* object : objects)
631 {
632 if (object->config.has("extruder") &&
633 object->config.option("extruder")->getInt() != extruder)
634 return false;
635
636 for (ModelVolume* volume : object->volumes)
637 if ((volume->config.has("extruder") &&
638 volume->config.option("extruder")->getInt() != 0 && // extruder isn't default
639 volume->config.option("extruder")->getInt() != extruder) ||
640 !volume->mmu_segmentation_facets.empty())
641 return false;
642
643 for (const auto& range : object->layer_config_ranges)
644 if (range.second.has("extruder") &&
645 range.second.option("extruder")->getInt() != 0 && // extruder isn't default
646 range.second.option("extruder")->getInt() != extruder)
647 return false;
648 }
649 return true;
650 };
651
652 if (is_one_extruder_printed_model())
653 only_extruder = extruder;
654 else
655 one_extruder_printed_model = false;
656 }
657 }
658
659 m_layers_slider->SetModeAndOnlyExtruder(one_extruder_printed_model, only_extruder);
660}
void SetModeAndOnlyExtruder(const bool is_one_extruder_printed_model, const int only_extruder)
Definition DoubleSlider.cpp:450
Definition getopt.h:102
auto range(Cont &&cont)
Definition libslic3r.h:356
std::vector< ModelObject * > ModelObjectPtrs
Definition Model.hpp:105
IGL_INLINE void volume(const Eigen::MatrixBase< DerivedV > &V, const Eigen::MatrixBase< DerivedT > &T, Eigen::PlainObjectBase< Derivedvol > &vol)
Definition volume.cpp:15

References m_layers_slider, Slic3r::range(), and Slic3r::DoubleSlider::Control::SetModeAndOnlyExtruder().

Referenced by update_layers_slider().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ update_moves_slider()

void Slic3r::GUI::Preview::update_moves_slider ( )
696{
697 const GCodeViewer::SequentialView& view = m_canvas->get_gcode_sequential_view();
698 // this should not be needed, but it is here to try to prevent rambling crashes on Mac Asan
699 if (view.endpoints.last < view.endpoints.first)
700 return;
701
702 assert(view.endpoints.first <= view.current.first && view.current.first <= view.endpoints.last);
703 assert(view.endpoints.first <= view.current.last && view.current.last <= view.endpoints.last);
704
705 std::vector<double> values;
706 values.reserve(view.endpoints.last - view.endpoints.first + 1);
707 std::vector<double> alternate_values;
708 alternate_values.reserve(view.endpoints.last - view.endpoints.first + 1);
709 unsigned int last_gcode_id = view.gcode_ids[view.endpoints.first];
710 for (unsigned int i = view.endpoints.first; i <= view.endpoints.last; ++i) {
711 if (i > view.endpoints.first) {
712 // skip consecutive moves with same gcode id (resulting from processing G2 and G3 lines)
713 if (last_gcode_id == view.gcode_ids[i]) {
714 values.back() = static_cast<double>(i + 1);
715 alternate_values.back() = static_cast<double>(view.gcode_ids[i]);
716 continue;
717 }
718 else
719 last_gcode_id = view.gcode_ids[i];
720 }
721
722 values.emplace_back(static_cast<double>(i + 1));
723 alternate_values.emplace_back(static_cast<double>(view.gcode_ids[i]));
724 }
725
727 m_moves_slider->SetSliderAlternateValues(alternate_values);
728 m_moves_slider->SetMaxValue(int(values.size()) - 1);
729 m_moves_slider->SetSelectionSpan(values.front() - 1 - view.endpoints.first, values.back() - 1 - view.endpoints.first);
730}
void SetSliderAlternateValues(const std::vector< double > &values)
Definition DoubleSlider.hpp:244
const GCodeViewer::SequentialView & get_gcode_sequential_view() const
Definition GLCanvas3D.hpp:748

References Slic3r::GUI::GCodeViewer::SequentialView::current, Slic3r::GUI::GCodeViewer::SequentialView::endpoints, Slic3r::GUI::GCodeViewer::SequentialView::Endpoints::first, Slic3r::GUI::GCodeViewer::SequentialView::gcode_ids, Slic3r::GUI::GLCanvas3D::get_gcode_sequential_view(), Slic3r::GUI::GCodeViewer::SequentialView::Endpoints::last, m_canvas, m_moves_slider, Slic3r::DoubleSlider::Control::SetMaxValue(), Slic3r::DoubleSlider::Control::SetSelectionSpan(), Slic3r::DoubleSlider::Control::SetSliderAlternateValues(), and Slic3r::DoubleSlider::Control::SetSliderValues().

+ Here is the call graph for this function:

Member Data Documentation

◆ m_bottom_toolbar_panel

wxPanel* Slic3r::GUI::Preview::m_bottom_toolbar_panel { nullptr }
private

◆ m_canvas

◆ m_canvas_widget

wxGLCanvas* Slic3r::GUI::Preview::m_canvas_widget { nullptr }
private

◆ m_config

DynamicPrintConfig* Slic3r::GUI::Preview::m_config
private

Referenced by init().

◆ m_gcode_result

GCodeProcessorResult* Slic3r::GUI::Preview::m_gcode_result
private

◆ m_keep_current_preview_type

bool Slic3r::GUI::Preview::m_keep_current_preview_type { false }
private

◆ m_layers_slider

◆ m_layers_slider_sizer

wxBoxSizer* Slic3r::GUI::Preview::m_layers_slider_sizer { nullptr }
private

◆ m_left_sizer

wxBoxSizer* Slic3r::GUI::Preview::m_left_sizer { nullptr }
private

◆ m_loaded

bool Slic3r::GUI::Preview::m_loaded { false }
private

◆ m_moves_slider

◆ m_number_extruders

unsigned int Slic3r::GUI::Preview::m_number_extruders { 1 }
private

◆ m_process

◆ m_schedule_background_process

std::function<void()> Slic3r::GUI::Preview::m_schedule_background_process
private

The documentation for this class was generated from the following files: