diff options
Diffstat (limited to 'src/slic3r/GUI/GUI_Preview.hpp')
-rw-r--r-- | src/slic3r/GUI/GUI_Preview.hpp | 122 |
1 files changed, 73 insertions, 49 deletions
diff --git a/src/slic3r/GUI/GUI_Preview.hpp b/src/slic3r/GUI/GUI_Preview.hpp index cc8f15325..0060bfcff 100644 --- a/src/slic3r/GUI/GUI_Preview.hpp +++ b/src/slic3r/GUI/GUI_Preview.hpp @@ -2,10 +2,12 @@ #define slic3r_GUI_Preview_hpp_ #include <wx/panel.h> + #include "libslic3r/Point.hpp" +#include "libslic3r/CustomGCode.hpp" #include <string> -#include "libslic3r/Model.hpp" +#include "libslic3r/GCode/GCodeProcessor.hpp" class wxNotebook; class wxGLCanvas; @@ -21,7 +23,6 @@ namespace Slic3r { class DynamicPrintConfig; class Print; class BackgroundSlicingProcess; -class GCodePreviewData; class Model; namespace DoubleSlider { @@ -34,6 +35,7 @@ class GLCanvas3D; class GLToolbar; class Bed3D; struct Camera; +class Plater; class View3D : public wxPanel { @@ -41,7 +43,7 @@ class View3D : public wxPanel GLCanvas3D* m_canvas; public: - View3D(wxWindow* parent, Bed3D& bed, Camera& camera, GLToolbar& view_toolbar, Model* model, DynamicPrintConfig* config, BackgroundSlicingProcess* process); + View3D(wxWindow* parent, Model* model, DynamicPrintConfig* config, BackgroundSlicingProcess* process); virtual ~View3D(); wxGLCanvas* get_wxglcanvas() { return m_canvas_widget; } @@ -69,48 +71,66 @@ public: void render(); private: - bool init(wxWindow* parent, Bed3D& bed, Camera& camera, GLToolbar& view_toolbar, Model* model, DynamicPrintConfig* config, BackgroundSlicingProcess* process); + bool init(wxWindow* parent, Model* model, DynamicPrintConfig* config, BackgroundSlicingProcess* process); }; class Preview : public wxPanel { - wxGLCanvas* m_canvas_widget; - GLCanvas3D* m_canvas; - wxBoxSizer* m_double_slider_sizer; - wxStaticText* m_label_view_type; - wxChoice* m_choice_view_type; - wxStaticText* m_label_show_features; - wxComboCtrl* m_combochecklist_features; - wxCheckBox* m_checkbox_travel; - wxCheckBox* m_checkbox_retractions; - wxCheckBox* m_checkbox_unretractions; - wxCheckBox* m_checkbox_shells; - wxCheckBox* m_checkbox_legend; + wxGLCanvas* m_canvas_widget { nullptr }; + GLCanvas3D* m_canvas { nullptr }; + wxBoxSizer* m_left_sizer { nullptr }; + wxBoxSizer* m_layers_slider_sizer { nullptr }; + wxPanel* m_bottom_toolbar_panel { nullptr }; + wxStaticText* m_label_view_type { nullptr }; + wxChoice* m_choice_view_type { nullptr }; + wxStaticText* m_label_show { nullptr }; + wxComboCtrl* m_combochecklist_features { nullptr }; + size_t m_combochecklist_features_pos { 0 }; + wxComboCtrl* m_combochecklist_options { nullptr }; DynamicPrintConfig* m_config; BackgroundSlicingProcess* m_process; - GCodePreviewData* m_gcode_preview_data; + GCodeProcessor::Result* m_gcode_result; #ifdef __linux__ // We are getting mysterious crashes on Linux in gtk due to OpenGL context activation GH #1874 #1955. // So we are applying a workaround here. - bool m_volumes_cleanup_required; + bool m_volumes_cleanup_required { false }; #endif /* __linux__ */ // 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 { 1 }; +#if ENABLE_PREVIEW_TYPE_CHANGE + bool m_keep_current_preview_type{ false }; +#else std::string m_preferred_color_mode; +#endif // ENABLE_PREVIEW_TYPE_CHANGE - bool m_loaded; - bool m_enabled; + bool m_loaded { false }; - DoubleSlider::Control* m_slider {nullptr}; + DoubleSlider::Control* m_layers_slider{ nullptr }; + DoubleSlider::Control* m_moves_slider{ nullptr }; public: - Preview(wxWindow* parent, Bed3D& bed, Camera& camera, GLToolbar& view_toolbar, Model* model, DynamicPrintConfig* config, - BackgroundSlicingProcess* process, GCodePreviewData* gcode_preview_data, std::function<void()> schedule_background_process = [](){}); + enum class OptionType : unsigned int + { + Travel, + Wipe, + Retractions, + Unretractions, + ToolChanges, + ColorChanges, + PausePrints, + CustomGCodes, + Shells, + ToolMarker, + Legend + }; + + Preview(wxWindow* parent, Model* model, DynamicPrintConfig* config, BackgroundSlicingProcess* process, + GCodeProcessor::Result* gcode_result, std::function<void()> schedule_background_process = []() {}); virtual ~Preview(); wxGLCanvas* get_wxglcanvas() { return m_canvas_widget; } @@ -118,8 +138,9 @@ public: void set_as_dirty(); +#if !ENABLE_PREVIEW_TYPE_CHANGE void set_number_extruders(unsigned int number_extruders); - void set_enabled(bool enabled); +#endif // !ENABLE_PREVIEW_TYPE_CHANGE void bed_shape_changed(); void select_view(const std::string& direction); void set_drop_target(wxDropTarget* target); @@ -129,48 +150,51 @@ public: void refresh_print(); void msw_rescale(); - void move_double_slider(wxKeyEvent& evt); - void edit_double_slider(wxKeyEvent& evt); + void jump_layers_slider(wxKeyEvent& evt); + void move_layers_slider(wxKeyEvent& evt); + void edit_layers_slider(wxKeyEvent& evt); - void update_view_type(bool slice_completed); +#if !ENABLE_PREVIEW_TYPE_CHANGE + void update_view_type(bool keep_volumes); +#endif // !ENABLE_PREVIEW_TYPE_CHANGE bool is_loaded() const { return m_loaded; } + void update_bottom_toolbar(); + void update_moves_slider(); + void enable_moves_slider(bool enable); +#if ENABLE_ARROW_KEYS_WITH_SLIDERS + void move_moves_slider(wxKeyEvent& evt); +#endif // ENABLE_ARROW_KEYS_WITH_SLIDERS + void hide_layers_slider(); + private: - bool init(wxWindow* parent, Bed3D& bed, Camera& camera, GLToolbar& view_toolbar, Model* model); + bool init(wxWindow* parent, Model* model); void bind_event_handlers(); void unbind_event_handlers(); - void show_hide_ui_elements(const std::string& what); - - void reset_sliders(bool reset_all); - void update_sliders(const std::vector<double>& layers_z, bool keep_z_range = false); - void on_size(wxSizeEvent& evt); void on_choice_view_type(wxCommandEvent& evt); void on_combochecklist_features(wxCommandEvent& evt); - void on_checkbox_travel(wxCommandEvent& evt); - void on_checkbox_retractions(wxCommandEvent& evt); - void on_checkbox_unretractions(wxCommandEvent& evt); - void on_checkbox_shells(wxCommandEvent& evt); - void on_checkbox_legend(wxCommandEvent& evt); + void on_combochecklist_options(wxCommandEvent& evt); // Create/Update/Reset double slider on 3dPreview - void create_double_slider(); - void check_slider_values(std::vector<CustomGCode::Item> &ticks_from_model, - const std::vector<double> &layers_z); - void reset_double_slider(); - void update_double_slider(const std::vector<double>& layers_z, bool keep_z_range = false); - void update_double_slider_mode(); - // update DoubleSlider after keyDown in canvas - void update_double_slider_from_canvas(wxKeyEvent& event); + 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(); + // update vertical DoubleSlider after keyDown in canvas + 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_sliders_scroll_changed(wxCommandEvent& event); - + void on_layers_slider_scroll_changed(wxCommandEvent& event); + void on_moves_slider_scroll_changed(wxCommandEvent& event); + wxString get_option_type_string(OptionType type) const; }; } // namespace GUI |