mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-30 20:21:12 -06:00 
			
		
		
		
	ENABLE_GCODE_VIEWER set as default in:
GLCanvas3D hpp/cpp GUI_Preview hpp/cpp
This commit is contained in:
		
							parent
							
								
									ff199807cd
								
							
						
					
					
						commit
						ef9cea76c2
					
				
					 4 changed files with 70 additions and 1835 deletions
				
			
		
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							|  | @ -12,10 +12,8 @@ | |||
| #include "GUI_ObjectLayers.hpp" | ||||
| #include "GLSelectionRectangle.hpp" | ||||
| #include "MeshUtils.hpp" | ||||
| #if ENABLE_GCODE_VIEWER | ||||
| #include "libslic3r/GCode/GCodeProcessor.hpp" | ||||
| #include "GCodeViewer.hpp" | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
| 
 | ||||
| #include "libslic3r/Slicing.hpp" | ||||
| 
 | ||||
|  | @ -39,9 +37,6 @@ namespace Slic3r { | |||
| 
 | ||||
| struct Camera; | ||||
| class BackgroundSlicingProcess; | ||||
| #if !ENABLE_GCODE_VIEWER | ||||
| class GCodePreviewData; | ||||
| #endif // !ENABLE_GCODE_VIEWER
 | ||||
| struct ThumbnailData; | ||||
| class ModelObject; | ||||
| class ModelInstance; | ||||
|  | @ -108,11 +103,7 @@ wxDECLARE_EVENT(EVT_GLCANVAS_MOUSE_DRAGGING_FINISHED, SimpleEvent); | |||
| wxDECLARE_EVENT(EVT_GLCANVAS_UPDATE_BED_SHAPE, SimpleEvent); | ||||
| wxDECLARE_EVENT(EVT_GLCANVAS_TAB, SimpleEvent); | ||||
| wxDECLARE_EVENT(EVT_GLCANVAS_RESETGIZMOS, SimpleEvent); | ||||
| #if ENABLE_GCODE_VIEWER | ||||
| wxDECLARE_EVENT(EVT_GLCANVAS_MOVE_LAYERS_SLIDER, wxKeyEvent); | ||||
| #else | ||||
| wxDECLARE_EVENT(EVT_GLCANVAS_MOVE_DOUBLE_SLIDER, wxKeyEvent); | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
| wxDECLARE_EVENT(EVT_GLCANVAS_EDIT_COLOR_CHANGE, wxKeyEvent); | ||||
| wxDECLARE_EVENT(EVT_GLCANVAS_JUMP_TO, wxKeyEvent); | ||||
| wxDECLARE_EVENT(EVT_GLCANVAS_UNDO, SimpleEvent); | ||||
|  | @ -127,37 +118,6 @@ class GLCanvas3D | |||
| { | ||||
|     static const double DefaultCameraZoomToBoxMarginFactor; | ||||
| 
 | ||||
| public: | ||||
| #if !ENABLE_GCODE_VIEWER | ||||
|     struct GCodePreviewVolumeIndex | ||||
|     { | ||||
|         enum EType | ||||
|         { | ||||
|             Extrusion, | ||||
|             Travel, | ||||
|             Retraction, | ||||
|             Unretraction, | ||||
|             Shell, | ||||
|             Num_Geometry_Types | ||||
|         }; | ||||
| 
 | ||||
|         struct FirstVolume | ||||
|         { | ||||
|             EType type; | ||||
|             unsigned int flag; | ||||
|             // Index of the first volume in a GLVolumeCollection.
 | ||||
|             unsigned int id; | ||||
| 
 | ||||
|             FirstVolume(EType type, unsigned int flag, unsigned int id) : type(type), flag(flag), id(id) {} | ||||
|         }; | ||||
| 
 | ||||
|         std::vector<FirstVolume> first_volumes; | ||||
| 
 | ||||
|         void reset() { first_volumes.clear(); } | ||||
|     }; | ||||
| #endif // !ENABLE_GCODE_VIEWER
 | ||||
| 
 | ||||
| private: | ||||
|     class LayersEditing | ||||
|     { | ||||
|     public: | ||||
|  | @ -355,35 +315,6 @@ private: | |||
|         bool generate(const std::string& msg, const GLCanvas3D& canvas, bool compress, bool red_colored = false); | ||||
|     }; | ||||
| 
 | ||||
| #if !ENABLE_GCODE_VIEWER | ||||
|     class LegendTexture : public GUI::GLTexture | ||||
|     { | ||||
|         static const int Px_Title_Offset = 5; | ||||
|         static const int Px_Text_Offset = 5; | ||||
|         static const int Px_Square = 20; | ||||
|         static const int Px_Square_Contour = 1; | ||||
|         static const int Px_Border = Px_Square / 2; | ||||
|         static const unsigned char Squares_Border_Color[3]; | ||||
|         static const unsigned char Default_Background_Color[3]; | ||||
|         static const unsigned char Error_Background_Color[3]; | ||||
|         static const unsigned char Opacity; | ||||
| 
 | ||||
|         int m_original_width; | ||||
|         int m_original_height; | ||||
| 
 | ||||
|     public: | ||||
|         LegendTexture(); | ||||
|         void fill_color_print_legend_items(const GLCanvas3D& canvas, | ||||
|                                            const std::vector<float>& colors_in, | ||||
|                                            std::vector<float>& colors, | ||||
|                                            std::vector<std::string>& cp_legend_items); | ||||
| 
 | ||||
|         bool generate(const GCodePreviewData& preview_data, const std::vector<float>& tool_colors, const GLCanvas3D& canvas, bool compress); | ||||
| 
 | ||||
|         void render(const GLCanvas3D& canvas) const; | ||||
|     }; | ||||
| #endif // !ENABLE_GCODE_VIEWER
 | ||||
| 
 | ||||
| #if ENABLE_RENDER_STATISTICS | ||||
|     struct RenderStats | ||||
|     { | ||||
|  | @ -457,9 +388,6 @@ private: | |||
|     std::unique_ptr<RetinaHelper> m_retina_helper; | ||||
| #endif | ||||
|     bool m_in_render; | ||||
| #if !ENABLE_GCODE_VIEWER | ||||
|     LegendTexture m_legend_texture; | ||||
| #endif // !ENABLE_GCODE_VIEWER
 | ||||
|     WarningTexture m_warning_texture; | ||||
|     wxTimer m_timer; | ||||
|     LayersEditing m_layers_editing; | ||||
|  | @ -478,9 +406,7 @@ private: | |||
|     bool m_event_handlers_bound{ false }; | ||||
| 
 | ||||
|     mutable GLVolumeCollection m_volumes; | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|     GCodeViewer m_gcode_viewer; | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
| 
 | ||||
|     Selection m_selection; | ||||
|     const DynamicPrintConfig* m_config; | ||||
|  | @ -492,9 +418,6 @@ private: | |||
|     bool m_initialized; | ||||
|     bool m_apply_zoom_to_volumes_filter; | ||||
|     mutable std::vector<int> m_hover_volume_idxs; | ||||
| #if !ENABLE_GCODE_VIEWER | ||||
|     bool m_legend_texture_enabled; | ||||
| #endif // !ENABLE_GCODE_VIEWER
 | ||||
|     bool m_picking_enabled; | ||||
|     bool m_moving_enabled; | ||||
|     bool m_dynamic_background_enabled; | ||||
|  | @ -512,10 +435,6 @@ private: | |||
| 
 | ||||
|     bool m_reload_delayed; | ||||
| 
 | ||||
| #if !ENABLE_GCODE_VIEWER | ||||
|     GCodePreviewVolumeIndex m_gcode_preview_volume_index; | ||||
| #endif // !ENABLE_GCODE_VIEWER
 | ||||
| 
 | ||||
| #if ENABLE_RENDER_PICKING_PASS | ||||
|     bool m_show_picking_texture; | ||||
| #endif // ENABLE_RENDER_PICKING_PASS
 | ||||
|  | @ -554,11 +473,9 @@ public: | |||
|     void reset_volumes(); | ||||
|     int check_volumes_outside_state() const; | ||||
| 
 | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|     void reset_gcode_toolpaths() { m_gcode_viewer.reset(); } | ||||
|     const GCodeViewer::SequentialView& get_gcode_sequential_view() const { return m_gcode_viewer.get_sequential_view(); } | ||||
|     void update_gcode_sequential_view_current(unsigned int first, unsigned int last) { m_gcode_viewer.update_sequential_view_current(first, last); } | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
| 
 | ||||
|     void toggle_sla_auxiliaries_visibility(bool visible, const ModelObject* mo = nullptr, int instance_idx = -1); | ||||
|     void toggle_model_objects_visibility(bool visible, const ModelObject* mo = nullptr, int instance_idx = -1); | ||||
|  | @ -622,9 +539,7 @@ public: | |||
|     void zoom_to_bed(); | ||||
|     void zoom_to_volumes(); | ||||
|     void zoom_to_selection(); | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|     void zoom_to_gcode(); | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
|     void select_view(const std::string& direction); | ||||
| 
 | ||||
|     void update_volumes_colors_by_extruder(); | ||||
|  | @ -641,7 +556,6 @@ public: | |||
|     void delete_selected(); | ||||
|     void ensure_on_bed(unsigned int object_idx); | ||||
| 
 | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|     bool is_gcode_legend_enabled() const { return m_gcode_viewer.is_legend_enabled(); } | ||||
|     GCodeViewer::EViewType get_gcode_view_type() const { return m_gcode_viewer.get_view_type(); } | ||||
|     const std::vector<double>& get_gcode_layers_zs() const; | ||||
|  | @ -653,9 +567,6 @@ public: | |||
|     void set_toolpath_view_type(GCodeViewer::EViewType type); | ||||
|     void set_volumes_z_range(const std::array<double, 2>& range); | ||||
|     void set_toolpaths_z_range(const std::array<unsigned int, 2>& range); | ||||
| #else | ||||
|     std::vector<double> get_current_print_zs(bool active_only) const; | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
|     void set_toolpaths_range(double low, double high); | ||||
| 
 | ||||
|     std::vector<int> load_object(const ModelObject& model_object, int obj_idx, std::vector<int> instance_idxs); | ||||
|  | @ -665,14 +576,10 @@ public: | |||
| 
 | ||||
|     void reload_scene(bool refresh_immediately, bool force_full_scene_refresh = false); | ||||
| 
 | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|     void load_gcode_preview(const GCodeProcessor::Result& gcode_result); | ||||
|     void refresh_gcode_preview(const GCodeProcessor::Result& gcode_result, const std::vector<std::string>& str_tool_colors); | ||||
|     void set_gcode_view_preview_type(GCodeViewer::EViewType type) { return m_gcode_viewer.set_view_type(type); } | ||||
|     GCodeViewer::EViewType get_gcode_view_preview_type() const { return m_gcode_viewer.get_view_type(); } | ||||
| #else | ||||
|     void load_gcode_preview(const GCodePreviewData& preview_data, const std::vector<std::string>& str_tool_colors); | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
|     void load_sla_preview(); | ||||
|     void load_preview(const std::vector<std::string>& str_tool_colors, const std::vector<CustomGCode::Item>& color_print_values); | ||||
|     void bind_event_handlers(); | ||||
|  | @ -691,10 +598,6 @@ public: | |||
|     Size get_canvas_size() const; | ||||
|     Vec2d get_local_mouse_position() const; | ||||
| 
 | ||||
| #if !ENABLE_GCODE_VIEWER | ||||
|     void reset_legend_texture(); | ||||
| #endif // !ENABLE_GCODE_VIEWER
 | ||||
| 
 | ||||
|     void set_tooltip(const std::string& tooltip) const; | ||||
| 
 | ||||
|     // the following methods add a snapshot to the undo/redo stack, unless the given string is empty
 | ||||
|  | @ -792,9 +695,7 @@ private: | |||
|     void _render_background() const; | ||||
|     void _render_bed(bool bottom, bool show_axes) const; | ||||
|     void _render_objects() const; | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|     void _render_gcode() const; | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
|     void _render_selection() const; | ||||
| #if ENABLE_RENDER_SELECTION_CENTER | ||||
|     void _render_selection_center() const; | ||||
|  | @ -802,9 +703,6 @@ private: | |||
|     void _check_and_update_toolbar_icon_scale() const; | ||||
|     void _render_overlays() const; | ||||
|     void _render_warning_texture() const; | ||||
| #if !ENABLE_GCODE_VIEWER | ||||
|     void _render_legend_texture() const; | ||||
| #endif // !ENABLE_GCODE_VIEWER
 | ||||
|     void _render_volumes_for_picking() const; | ||||
|     void _render_current_gizmo() const; | ||||
|     void _render_gizmos_overlay() const; | ||||
|  | @ -852,29 +750,12 @@ private: | |||
|     // Create 3D thick extrusion lines for wipe tower extrusions
 | ||||
|     void _load_wipe_tower_toolpaths(const std::vector<std::string>& str_tool_colors); | ||||
| 
 | ||||
| #if !ENABLE_GCODE_VIEWER | ||||
|     // generates gcode extrusion paths geometry
 | ||||
|     void _load_gcode_extrusion_paths(const GCodePreviewData& preview_data, const std::vector<float>& tool_colors); | ||||
|     // generates gcode travel paths geometry
 | ||||
|     void _load_gcode_travel_paths(const GCodePreviewData& preview_data, const std::vector<float>& tool_colors); | ||||
|     // generates objects and wipe tower geometry
 | ||||
|     void _load_fff_shells(); | ||||
| #endif // !ENABLE_GCODE_VIEWER
 | ||||
|     // Load SLA objects and support structures for objects, for which the slaposSliceSupports step has been finished.
 | ||||
| 	void _load_sla_shells(); | ||||
| #if !ENABLE_GCODE_VIEWER | ||||
|     // sets gcode geometry visibility according to user selection
 | ||||
|     void _update_gcode_volumes_visibility(const GCodePreviewData& preview_data); | ||||
| #endif // !ENABLE_GCODE_VIEWER
 | ||||
|     void _update_toolpath_volumes_outside_state(); | ||||
|     void _update_sla_shells_outside_state(); | ||||
|     void _show_warning_texture_if_needed(WarningTexture::Warning warning); | ||||
| 
 | ||||
| #if !ENABLE_GCODE_VIEWER | ||||
|     // generates the legend texture in dependence of the current shown view type
 | ||||
|     void _generate_legend_texture(const GCodePreviewData& preview_data, const std::vector<float>& tool_colors); | ||||
| #endif // !ENABLE_GCODE_VIEWER
 | ||||
| 
 | ||||
|     // generates a warning texture containing the given message
 | ||||
|     void _set_warning_texture(WarningTexture::Warning warning, bool state); | ||||
| 
 | ||||
|  |  | |||
|  | @ -10,9 +10,7 @@ | |||
| #include "libslic3r/PresetBundle.hpp" | ||||
| #include "DoubleSlider.hpp" | ||||
| #include "Plater.hpp" | ||||
| #if ENABLE_GCODE_VIEWER | ||||
| #include "MainFrame.hpp" | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
| 
 | ||||
| #include <wx/notebook.h> | ||||
| #include <wx/glcanvas.h> | ||||
|  | @ -168,62 +166,33 @@ void View3D::render() | |||
|         m_canvas->set_as_dirty(); | ||||
| } | ||||
| 
 | ||||
| #if ENABLE_GCODE_VIEWER | ||||
| Preview::Preview( | ||||
|     wxWindow* parent, Model* model, DynamicPrintConfig* config, | ||||
|     BackgroundSlicingProcess* process, GCodeProcessor::Result* gcode_result, std::function<void()> schedule_background_process_func) | ||||
| #else | ||||
| Preview::Preview( | ||||
|     wxWindow* parent, Model* model, DynamicPrintConfig* config, | ||||
|     BackgroundSlicingProcess* process, GCodePreviewData* gcode_preview_data, std::function<void()> schedule_background_process_func) | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
|     : m_canvas_widget(nullptr) | ||||
|     , m_canvas(nullptr) | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|     , m_left_sizer(nullptr) | ||||
|     , m_layers_slider_sizer(nullptr) | ||||
|     , m_bottom_toolbar_panel(nullptr) | ||||
| #else | ||||
|     , m_double_slider_sizer(nullptr) | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
|     , m_label_view_type(nullptr) | ||||
|     , m_choice_view_type(nullptr) | ||||
|     , m_label_show(nullptr) | ||||
|     , m_combochecklist_features(nullptr) | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|     , m_combochecklist_features_pos(0) | ||||
|     , m_combochecklist_options(nullptr) | ||||
| #else | ||||
|     , m_checkbox_travel(nullptr) | ||||
|     , m_checkbox_retractions(nullptr) | ||||
|     , m_checkbox_unretractions(nullptr) | ||||
|     , m_checkbox_shells(nullptr) | ||||
|     , m_checkbox_legend(nullptr) | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
|     , m_config(config) | ||||
|     , m_process(process) | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|     , m_gcode_result(gcode_result) | ||||
| #else | ||||
|     , m_gcode_preview_data(gcode_preview_data) | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
|     , m_number_extruders(1) | ||||
|     , m_preferred_color_mode("feature") | ||||
|     , m_loaded(false) | ||||
| #if !ENABLE_GCODE_VIEWER | ||||
|     , m_enabled(false) | ||||
| #endif // !ENABLE_GCODE_VIEWER
 | ||||
|     , m_schedule_background_process(schedule_background_process_func) | ||||
| #ifdef __linux__ | ||||
|     , m_volumes_cleanup_required(false) | ||||
| #endif // __linux__
 | ||||
| { | ||||
|     if (init(parent, model)) { | ||||
| #if !ENABLE_GCODE_VIEWER | ||||
|         show_hide_ui_elements("none"); | ||||
| #endif // !ENABLE_GCODE_VIEWER
 | ||||
|     if (init(parent, model)) | ||||
|         load_print(); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| bool Preview::init(wxWindow* parent, Model* model) | ||||
|  | @ -231,14 +200,12 @@ bool Preview::init(wxWindow* parent, Model* model) | |||
|     if (!Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 /* disable wxTAB_TRAVERSAL */)) | ||||
|         return false; | ||||
| 
 | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|     // to match the background of the sliders
 | ||||
| #ifdef _WIN32  | ||||
|     SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); | ||||
| #else | ||||
|     SetBackgroundColour(GetParent()->GetBackgroundColour()); | ||||
| #endif // _WIN32 
 | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
| 
 | ||||
|     m_canvas_widget = OpenGLManager::create_wxglcanvas(*this); | ||||
|     if (m_canvas_widget == nullptr) | ||||
|  | @ -253,20 +220,11 @@ bool Preview::init(wxWindow* parent, Model* model) | |||
|     m_canvas->enable_legend_texture(true); | ||||
|     m_canvas->enable_dynamic_background(true); | ||||
| 
 | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|     m_layers_slider_sizer = create_layers_slider_sizer(); | ||||
| 
 | ||||
|     m_bottom_toolbar_panel = new wxPanel(this); | ||||
|     m_label_view_type = new wxStaticText(m_bottom_toolbar_panel, wxID_ANY, _L("View")); | ||||
|     m_choice_view_type = new wxChoice(m_bottom_toolbar_panel, wxID_ANY); | ||||
| #else | ||||
|     m_double_slider_sizer = new wxBoxSizer(wxHORIZONTAL); | ||||
|     create_double_slider(); | ||||
| 
 | ||||
|     m_label_view_type = new wxStaticText(this, wxID_ANY, _L("View")); | ||||
| 
 | ||||
|     m_choice_view_type = new wxChoice(this, wxID_ANY); | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
|     m_choice_view_type->Append(_L("Feature type")); | ||||
|     m_choice_view_type->Append(_L("Height")); | ||||
|     m_choice_view_type->Append(_L("Width")); | ||||
|  | @ -277,22 +235,12 @@ bool Preview::init(wxWindow* parent, Model* model) | |||
|     m_choice_view_type->Append(_L("Color Print")); | ||||
|     m_choice_view_type->SetSelection(0); | ||||
| 
 | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|     m_label_show = new wxStaticText(m_bottom_toolbar_panel, wxID_ANY, _L("Show")); | ||||
| #else | ||||
|     m_label_show = new wxStaticText(this, wxID_ANY, _L("Show")); | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
| 
 | ||||
|     m_combochecklist_features = new wxComboCtrl(); | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|     m_combochecklist_features->Create(m_bottom_toolbar_panel, wxID_ANY, _L("Feature types"), wxDefaultPosition, wxDefaultSize, wxCB_READONLY); | ||||
| #else | ||||
|     m_combochecklist_features->Create(this, wxID_ANY, _L("Feature types"), wxDefaultPosition, wxDefaultSize, wxCB_READONLY); | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
|     std::string feature_items = GUI::into_u8( | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|         _L("Unknown") + "|1|" + | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
|         _L("Perimeter") + "|1|" + | ||||
|         _L("External perimeter") + "|1|" + | ||||
|         _L("Overhang perimeter") + "|1|" + | ||||
|  | @ -310,7 +258,6 @@ bool Preview::init(wxWindow* parent, Model* model) | |||
|     ); | ||||
|     Slic3r::GUI::create_combochecklist(m_combochecklist_features, GUI::into_u8(_L("Feature types")), feature_items); | ||||
| 
 | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|     m_combochecklist_options = new wxComboCtrl(); | ||||
|     m_combochecklist_options->Create(m_bottom_toolbar_panel, wxID_ANY, _L("Options"), wxDefaultPosition, wxDefaultSize, wxCB_READONLY); | ||||
|     std::string options_items = GUI::into_u8( | ||||
|  | @ -324,18 +271,9 @@ bool Preview::init(wxWindow* parent, Model* model) | |||
|         get_option_type_string(OptionType::Shells) + "|0|" + | ||||
|         get_option_type_string(OptionType::ToolMarker) + "|1|" + | ||||
|         get_option_type_string(OptionType::Legend) + "|1" | ||||
| ); | ||||
|     ); | ||||
|     Slic3r::GUI::create_combochecklist(m_combochecklist_options, GUI::into_u8(_L("Options")), options_items); | ||||
| #else | ||||
|     m_checkbox_travel = new wxCheckBox(this, wxID_ANY, _L("Travel")); | ||||
|     m_checkbox_retractions = new wxCheckBox(this, wxID_ANY, _L("Retractions")); | ||||
|     m_checkbox_unretractions = new wxCheckBox(this, wxID_ANY, _L("Deretractions")); | ||||
|     m_checkbox_shells = new wxCheckBox(this, wxID_ANY, _L("Shells")); | ||||
|     m_checkbox_legend = new wxCheckBox(this, wxID_ANY, _L("Legend")); | ||||
|     m_checkbox_legend->SetValue(true); | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
| 
 | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|     m_left_sizer = new wxBoxSizer(wxVERTICAL); | ||||
|     m_left_sizer->Add(m_canvas_widget, 1, wxALL | wxEXPAND, 0); | ||||
| 
 | ||||
|  | @ -366,32 +304,6 @@ bool Preview::init(wxWindow* parent, Model* model) | |||
|     wxBoxSizer* main_sizer = new wxBoxSizer(wxHORIZONTAL); | ||||
|     main_sizer->Add(m_left_sizer, 1, wxALL | wxEXPAND, 0); | ||||
|     main_sizer->Add(right_sizer, 0, wxALL | wxEXPAND, 0); | ||||
| #else | ||||
|     wxBoxSizer* top_sizer = new wxBoxSizer(wxHORIZONTAL); | ||||
|     top_sizer->Add(m_canvas_widget, 1, wxALL | wxEXPAND, 0); | ||||
|     top_sizer->Add(m_double_slider_sizer, 0, wxEXPAND, 0); | ||||
| 
 | ||||
|     wxBoxSizer* bottom_sizer = new wxBoxSizer(wxHORIZONTAL); | ||||
|     bottom_sizer->Add(m_label_view_type, 0, wxALIGN_CENTER_VERTICAL, 5); | ||||
|     bottom_sizer->Add(m_choice_view_type, 0, wxEXPAND | wxALL, 5); | ||||
|     bottom_sizer->AddSpacer(10); | ||||
|     bottom_sizer->Add(m_label_show, 0, wxALIGN_CENTER_VERTICAL, 5); | ||||
|     bottom_sizer->Add(m_combochecklist_features, 0, wxEXPAND | wxALL, 5); | ||||
|     bottom_sizer->AddSpacer(20); | ||||
|     bottom_sizer->Add(m_checkbox_travel, 0, wxEXPAND | wxALL, 5); | ||||
|     bottom_sizer->AddSpacer(10); | ||||
|     bottom_sizer->Add(m_checkbox_retractions, 0, wxEXPAND | wxALL, 5); | ||||
|     bottom_sizer->AddSpacer(10); | ||||
|     bottom_sizer->Add(m_checkbox_unretractions, 0, wxEXPAND | wxALL, 5); | ||||
|     bottom_sizer->AddSpacer(10); | ||||
|     bottom_sizer->Add(m_checkbox_shells, 0, wxEXPAND | wxALL, 5); | ||||
|     bottom_sizer->AddSpacer(20); | ||||
|     bottom_sizer->Add(m_checkbox_legend, 0, wxEXPAND | wxALL, 5); | ||||
| 
 | ||||
|     wxBoxSizer* main_sizer = new wxBoxSizer(wxVERTICAL); | ||||
|     main_sizer->Add(top_sizer, 1, wxALL | wxEXPAND, 0); | ||||
|     main_sizer->Add(bottom_sizer, 0, wxALL | wxEXPAND, 0); | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
| 
 | ||||
|     SetSizer(main_sizer); | ||||
|     SetMinSize(GetSize()); | ||||
|  | @ -399,26 +311,6 @@ bool Preview::init(wxWindow* parent, Model* model) | |||
| 
 | ||||
|     bind_event_handlers(); | ||||
|      | ||||
| #if !ENABLE_GCODE_VIEWER | ||||
|     // sets colors for gcode preview extrusion roles
 | ||||
|     std::vector<std::string> extrusion_roles_colors = { | ||||
|         "Perimeter", "FFFF66", | ||||
|         "External perimeter", "FFA500", | ||||
|         "Overhang perimeter", "0000FF", | ||||
|         "Internal infill", "B1302A", | ||||
|         "Solid infill", "D732D7", | ||||
|         "Top solid infill", "FF1A1A", | ||||
|         "Bridge infill", "9999FF", | ||||
|         "Gap fill", "FFFFFF", | ||||
|         "Skirt", "845321", | ||||
|         "Support material", "00FF00", | ||||
|         "Support material interface", "008000", | ||||
|         "Wipe tower", "B3E3AB", | ||||
|         "Custom", "28CC94" | ||||
|     }; | ||||
|     m_gcode_preview_data->set_extrusion_paths_colors(extrusion_roles_colors); | ||||
| #endif // !ENABLE_GCODE_VIEWER
 | ||||
| 
 | ||||
|     return true; | ||||
| } | ||||
| 
 | ||||
|  | @ -441,31 +333,18 @@ void Preview::set_as_dirty() | |||
| 
 | ||||
| void Preview::set_number_extruders(unsigned int number_extruders) | ||||
| { | ||||
|     if (m_number_extruders != number_extruders) | ||||
|     { | ||||
|     if (m_number_extruders != number_extruders) { | ||||
|         m_number_extruders = number_extruders; | ||||
|         int tool_idx = m_choice_view_type->FindString(_(L("Tool"))); | ||||
|         int type = (number_extruders > 1) ? tool_idx /* color by a tool number */  : 0; // color by a feature type
 | ||||
|         m_choice_view_type->SetSelection(type); | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|         if ((0 <= type) && (type < static_cast<int>(GCodeViewer::EViewType::Count))) | ||||
|         if (0 <= type && (type < static_cast<int>(GCodeViewer::EViewType::Count))) | ||||
|             m_canvas->set_gcode_view_preview_type(static_cast<GCodeViewer::EViewType>(type)); | ||||
| #else | ||||
|         if ((0 <= type) && (type < (int)GCodePreviewData::Extrusion::Num_View_Types)) | ||||
|             m_gcode_preview_data->extrusion.view_type = (GCodePreviewData::Extrusion::EViewType)type; | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
| 
 | ||||
|         m_preferred_color_mode = (type == tool_idx) ? "tool_or_feature" : "feature"; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| #if !ENABLE_GCODE_VIEWER | ||||
| void Preview::set_enabled(bool enabled) | ||||
| { | ||||
|     m_enabled = enabled; | ||||
| } | ||||
| #endif // !ENABLE_GCODE_VIEWER
 | ||||
| 
 | ||||
| void Preview::bed_shape_changed() | ||||
| { | ||||
|     if (m_canvas != nullptr) | ||||
|  | @ -491,9 +370,7 @@ void Preview::load_print(bool keep_z_range) | |||
|     else if (tech == ptSLA) | ||||
|         load_print_as_sla(); | ||||
| 
 | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|     update_bottom_toolbar(); | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
|     Layout(); | ||||
| } | ||||
| 
 | ||||
|  | @ -515,9 +392,6 @@ void Preview::reload_print(bool keep_volumes) | |||
|         !keep_volumes) | ||||
|     { | ||||
|         m_canvas->reset_volumes(); | ||||
| #if !ENABLE_GCODE_VIEWER | ||||
|         m_canvas->reset_legend_texture(); | ||||
| #endif // !ENABLE_GCODE_VIEWER
 | ||||
|         m_loaded = false; | ||||
| #ifdef __linux__ | ||||
|         m_volumes_cleanup_required = false; | ||||
|  | @ -540,12 +414,8 @@ void Preview::refresh_print() | |||
| void Preview::msw_rescale() | ||||
| { | ||||
|     // rescale slider
 | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|     if (m_layers_slider != nullptr) m_layers_slider->msw_rescale(); | ||||
|     if (m_moves_slider != nullptr) m_moves_slider->msw_rescale(); | ||||
| #else | ||||
|     if (m_slider) m_slider->msw_rescale(); | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
| 
 | ||||
|     // rescale warning legend on the canvas
 | ||||
|     get_canvas3d()->msw_rescale(); | ||||
|  | @ -556,55 +426,26 @@ void Preview::msw_rescale() | |||
| 
 | ||||
| void Preview::jump_layers_slider(wxKeyEvent& evt) | ||||
| { | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|     if (m_layers_slider) m_layers_slider->OnChar(evt); | ||||
| #else | ||||
|     if (m_slider) | ||||
|         m_slider->OnKeyDown(evt); | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
| } | ||||
| 
 | ||||
| #if ENABLE_GCODE_VIEWER | ||||
| void Preview::move_layers_slider(wxKeyEvent& evt) | ||||
| { | ||||
|     if (m_layers_slider != nullptr) m_layers_slider->OnKeyDown(evt); | ||||
| } | ||||
| #else | ||||
| void Preview::move_double_slider(wxKeyEvent& evt) | ||||
| { | ||||
|     if (m_slider) | ||||
|         m_slider->OnKeyDown(evt); | ||||
| } | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
| 
 | ||||
| #if ENABLE_GCODE_VIEWER | ||||
| void Preview::edit_layers_slider(wxKeyEvent& evt) | ||||
| { | ||||
|     if (m_layers_slider != nullptr) m_layers_slider->OnChar(evt); | ||||
| } | ||||
| #else | ||||
| void Preview::edit_double_slider(wxKeyEvent& evt) | ||||
| { | ||||
|     if (m_slider) | ||||
|         m_slider->OnChar(evt); | ||||
| } | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
| 
 | ||||
| void Preview::bind_event_handlers() | ||||
| { | ||||
|     this->Bind(wxEVT_SIZE, &Preview::on_size, this); | ||||
|     m_choice_view_type->Bind(wxEVT_CHOICE, &Preview::on_choice_view_type, this); | ||||
|     m_combochecklist_features->Bind(wxEVT_CHECKLISTBOX, &Preview::on_combochecklist_features, this); | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|     m_combochecklist_options->Bind(wxEVT_CHECKLISTBOX, &Preview::on_combochecklist_options, this); | ||||
|     m_moves_slider->Bind(wxEVT_SCROLL_CHANGED, &Preview::on_moves_slider_scroll_changed, this); | ||||
| #else | ||||
|     m_checkbox_travel->Bind(wxEVT_CHECKBOX, &Preview::on_checkbox_travel, this); | ||||
|     m_checkbox_retractions->Bind(wxEVT_CHECKBOX, &Preview::on_checkbox_retractions, this); | ||||
|     m_checkbox_unretractions->Bind(wxEVT_CHECKBOX, &Preview::on_checkbox_unretractions, this); | ||||
|     m_checkbox_shells->Bind(wxEVT_CHECKBOX, &Preview::on_checkbox_shells, this); | ||||
|     m_checkbox_legend->Bind(wxEVT_CHECKBOX, &Preview::on_checkbox_legend, this); | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
| } | ||||
| 
 | ||||
| void Preview::unbind_event_handlers() | ||||
|  | @ -612,76 +453,15 @@ void Preview::unbind_event_handlers() | |||
|     this->Unbind(wxEVT_SIZE, &Preview::on_size, this); | ||||
|     m_choice_view_type->Unbind(wxEVT_CHOICE, &Preview::on_choice_view_type, this); | ||||
|     m_combochecklist_features->Unbind(wxEVT_CHECKLISTBOX, &Preview::on_combochecklist_features, this); | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|     m_combochecklist_options->Unbind(wxEVT_CHECKLISTBOX, &Preview::on_combochecklist_options, this); | ||||
|     m_moves_slider->Unbind(wxEVT_SCROLL_CHANGED, &Preview::on_moves_slider_scroll_changed, this); | ||||
| #else | ||||
|     m_checkbox_travel->Unbind(wxEVT_CHECKBOX, &Preview::on_checkbox_travel, this); | ||||
|     m_checkbox_retractions->Unbind(wxEVT_CHECKBOX, &Preview::on_checkbox_retractions, this); | ||||
|     m_checkbox_unretractions->Unbind(wxEVT_CHECKBOX, &Preview::on_checkbox_unretractions, this); | ||||
|     m_checkbox_shells->Unbind(wxEVT_CHECKBOX, &Preview::on_checkbox_shells, this); | ||||
|     m_checkbox_legend->Unbind(wxEVT_CHECKBOX, &Preview::on_checkbox_legend, this); | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
| } | ||||
| 
 | ||||
| #if !ENABLE_GCODE_VIEWER | ||||
| void Preview::show_hide_ui_elements(const std::string& what) | ||||
| { | ||||
|     bool enable = (what == "full"); | ||||
|     m_label_show->Enable(enable); | ||||
|     m_combochecklist_features->Enable(enable); | ||||
|     m_checkbox_travel->Enable(enable); | ||||
|     m_checkbox_retractions->Enable(enable); | ||||
|     m_checkbox_unretractions->Enable(enable); | ||||
|     m_checkbox_shells->Enable(enable); | ||||
|     m_checkbox_legend->Enable(enable); | ||||
| 
 | ||||
|     enable = (what != "none"); | ||||
|     m_label_view_type->Enable(enable); | ||||
|     m_choice_view_type->Enable(enable); | ||||
| 
 | ||||
|     bool visible = (what != "none"); | ||||
|     m_label_show->Show(visible); | ||||
|     m_combochecklist_features->Show(visible); | ||||
|     m_checkbox_travel->Show(visible); | ||||
|     m_checkbox_retractions->Show(visible); | ||||
|     m_checkbox_unretractions->Show(visible); | ||||
|     m_checkbox_shells->Show(visible); | ||||
|     m_checkbox_legend->Show(visible); | ||||
|     m_label_view_type->Show(visible); | ||||
|     m_choice_view_type->Show(visible); | ||||
| } | ||||
| #endif // !ENABLE_GCODE_VIEWER
 | ||||
| 
 | ||||
| #if ENABLE_GCODE_VIEWER | ||||
| void Preview::hide_layers_slider() | ||||
| { | ||||
|     m_layers_slider_sizer->Hide((size_t)0); | ||||
|     Layout(); | ||||
| } | ||||
| #else | ||||
| void Preview::reset_sliders(bool reset_all) | ||||
| { | ||||
|     m_enabled = false; | ||||
|     //    reset_double_slider();
 | ||||
|     if (reset_all) | ||||
|         m_double_slider_sizer->Hide((size_t)0); | ||||
|     else | ||||
|         m_double_slider_sizer->GetItem(size_t(0))->GetSizer()->Hide(1); | ||||
| } | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
| 
 | ||||
| #if !ENABLE_GCODE_VIEWER | ||||
| void Preview::update_sliders(const std::vector<double>& layers_z, bool keep_z_range) | ||||
| { | ||||
|     m_enabled = true; | ||||
|     update_double_slider(layers_z, keep_z_range); | ||||
| 
 | ||||
|     m_double_slider_sizer->Show((size_t)0); | ||||
| 
 | ||||
|     Layout(); | ||||
| } | ||||
| #endif // !ENABLE_GCODE_VIEWER
 | ||||
| 
 | ||||
| void Preview::on_size(wxSizeEvent& evt) | ||||
| { | ||||
|  | @ -693,31 +473,19 @@ void Preview::on_choice_view_type(wxCommandEvent& evt) | |||
| { | ||||
|     m_preferred_color_mode = (m_choice_view_type->GetStringSelection() == L("Tool")) ? "tool" : "feature"; | ||||
|     int selection = m_choice_view_type->GetCurrentSelection(); | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|     if (0 <= selection && selection < static_cast<int>(GCodeViewer::EViewType::Count)) | ||||
|         m_canvas->set_toolpath_view_type(static_cast<GCodeViewer::EViewType>(selection)); | ||||
| 
 | ||||
|     refresh_print(); | ||||
| #else | ||||
|     if ((0 <= selection) && (selection < (int)GCodePreviewData::Extrusion::Num_View_Types)) | ||||
|         m_gcode_preview_data->extrusion.view_type = (GCodePreviewData::Extrusion::EViewType)selection; | ||||
| 
 | ||||
|     reload_print(); | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
| } | ||||
| 
 | ||||
| void Preview::on_combochecklist_features(wxCommandEvent& evt) | ||||
| { | ||||
|     unsigned int flags = Slic3r::GUI::combochecklist_get_flags(m_combochecklist_features); | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|     m_canvas->set_toolpath_role_visibility_flags(flags); | ||||
| #else | ||||
|     m_gcode_preview_data->extrusion.role_flags = flags; | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
|     refresh_print(); | ||||
| } | ||||
| 
 | ||||
| #if ENABLE_GCODE_VIEWER | ||||
| void Preview::on_combochecklist_options(wxCommandEvent& evt) | ||||
| { | ||||
|     auto xored = [](unsigned int flags1, unsigned int flags2, unsigned int flag) { | ||||
|  | @ -742,39 +510,6 @@ void Preview::on_combochecklist_options(wxCommandEvent& evt) | |||
|     else | ||||
|         m_canvas->set_as_dirty(); | ||||
| } | ||||
| #else | ||||
| void Preview::on_checkbox_travel(wxCommandEvent& evt) | ||||
| { | ||||
|     m_gcode_preview_data->travel.is_visible = m_checkbox_travel->IsChecked(); | ||||
|     m_gcode_preview_data->ranges.feedrate.set_mode(GCodePreviewData::FeedrateKind::TRAVEL, m_gcode_preview_data->travel.is_visible); | ||||
|     // Rather than refresh, reload print so that speed color ranges get recomputed (affected by travel visibility)
 | ||||
|     reload_print(); | ||||
| } | ||||
| 
 | ||||
| void Preview::on_checkbox_retractions(wxCommandEvent& evt) | ||||
| { | ||||
|     m_gcode_preview_data->retraction.is_visible = m_checkbox_retractions->IsChecked(); | ||||
|     refresh_print(); | ||||
| } | ||||
| 
 | ||||
| void Preview::on_checkbox_unretractions(wxCommandEvent& evt) | ||||
| { | ||||
|     m_gcode_preview_data->unretraction.is_visible = m_checkbox_unretractions->IsChecked(); | ||||
|     refresh_print(); | ||||
| } | ||||
| 
 | ||||
| void Preview::on_checkbox_shells(wxCommandEvent& evt) | ||||
| { | ||||
|     m_gcode_preview_data->shell.is_visible = m_checkbox_shells->IsChecked(); | ||||
|     refresh_print(); | ||||
| } | ||||
| 
 | ||||
| void Preview::on_checkbox_legend(wxCommandEvent& evt) | ||||
| { | ||||
|     m_canvas->enable_legend_texture(m_checkbox_legend->IsChecked()); | ||||
|     m_canvas_widget->Refresh(); | ||||
| } | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
| 
 | ||||
| void Preview::update_view_type(bool keep_volumes) | ||||
| { | ||||
|  | @ -790,49 +525,34 @@ void Preview::update_view_type(bool keep_volumes) | |||
|     int type = m_choice_view_type->FindString(choice); | ||||
|     if (m_choice_view_type->GetSelection() != type) { | ||||
|         m_choice_view_type->SetSelection(type); | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|         if ((0 <= type) && (type < static_cast<int>(GCodeViewer::EViewType::Count))) | ||||
|         if (0 <= type && type < static_cast<int>(GCodeViewer::EViewType::Count)) | ||||
|             m_canvas->set_gcode_view_preview_type(static_cast<GCodeViewer::EViewType>(type)); | ||||
| #else | ||||
|         if (0 <= type && type < (int)GCodePreviewData::Extrusion::Num_View_Types) | ||||
|             m_gcode_preview_data->extrusion.view_type = (GCodePreviewData::Extrusion::EViewType)type; | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
|         m_preferred_color_mode = "feature"; | ||||
|     } | ||||
| 
 | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|     reload_print(keep_volumes); | ||||
| #else | ||||
|     reload_print(); | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
| } | ||||
| 
 | ||||
| #if ENABLE_GCODE_VIEWER | ||||
| void Preview::update_bottom_toolbar() | ||||
| { | ||||
|     combochecklist_set_flags(m_combochecklist_features, m_canvas->get_toolpath_role_visibility_flags()); | ||||
|     combochecklist_set_flags(m_combochecklist_options, m_canvas->get_gcode_options_visibility_flags()); | ||||
| 
 | ||||
|     // updates visibility of features combobox
 | ||||
|     if (m_bottom_toolbar_panel->IsShown()) | ||||
|     { | ||||
|     if (m_bottom_toolbar_panel->IsShown()) { | ||||
|         wxSizer* sizer = m_bottom_toolbar_panel->GetSizer(); | ||||
|         bool show = !m_canvas->is_gcode_legend_enabled() || m_canvas->get_gcode_view_type() != GCodeViewer::EViewType::FeatureType; | ||||
| 
 | ||||
|         if (show) | ||||
|         { | ||||
|             if (sizer->GetItem(m_combochecklist_features) == nullptr) | ||||
|             { | ||||
|         if (show) { | ||||
|             if (sizer->GetItem(m_combochecklist_features) == nullptr) { | ||||
|                 sizer->Insert(m_combochecklist_features_pos, m_combochecklist_features, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 5); | ||||
|                 sizer->Show(m_combochecklist_features); | ||||
|                 sizer->Layout(); | ||||
|                 Refresh(); | ||||
|             } | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             if (sizer->GetItem(m_combochecklist_features) != nullptr) | ||||
|             { | ||||
|         else { | ||||
|             if (sizer->GetItem(m_combochecklist_features) != nullptr) { | ||||
|                 sizer->Hide(m_combochecklist_features); | ||||
|                 sizer->Detach(m_combochecklist_features); | ||||
|                 sizer->Layout(); | ||||
|  | @ -841,9 +561,7 @@ void Preview::update_bottom_toolbar() | |||
|         } | ||||
|     } | ||||
| } | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
| 
 | ||||
| #if ENABLE_GCODE_VIEWER | ||||
| wxBoxSizer* Preview::create_layers_slider_sizer() | ||||
| { | ||||
|     wxBoxSizer* sizer = new wxBoxSizer(wxHORIZONTAL); | ||||
|  | @ -875,37 +593,6 @@ wxBoxSizer* Preview::create_layers_slider_sizer() | |||
| 
 | ||||
|     return sizer; | ||||
| } | ||||
| #else | ||||
| void Preview::create_double_slider() | ||||
| { | ||||
|     m_slider = new DoubleSlider::Control(this, wxID_ANY, 0, 0, 0, 100); | ||||
| 
 | ||||
|     bool sla_print_technology = wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology() == ptSLA; | ||||
|     bool sequential_print = wxGetApp().preset_bundle->prints.get_edited_preset().config.opt_bool("complete_objects"); | ||||
|     m_slider->SetDrawMode(sla_print_technology, sequential_print); | ||||
| 
 | ||||
|     m_double_slider_sizer->Add(m_slider, 0, wxEXPAND, 0); | ||||
| 
 | ||||
| 
 | ||||
|     // sizer, m_canvas_widget
 | ||||
|     m_canvas_widget->Bind(wxEVT_KEY_DOWN, &Preview::update_double_slider_from_canvas, this); | ||||
|     m_canvas_widget->Bind(wxEVT_KEY_UP, [this](wxKeyEvent& event) { | ||||
|         if (event.GetKeyCode() == WXK_SHIFT) | ||||
|             m_slider->UseDefaultColors(true); | ||||
|         event.Skip(); | ||||
|         }); | ||||
| 
 | ||||
|     m_slider->Bind(wxEVT_SCROLL_CHANGED, &Preview::on_sliders_scroll_changed, this); | ||||
| 
 | ||||
|     Bind(DoubleSlider::wxCUSTOMEVT_TICKSCHANGED, [this](wxEvent&) { | ||||
|         Model& model = wxGetApp().plater()->model(); | ||||
|         model.custom_gcode_per_print_z = m_slider->GetTicksValues(); | ||||
|         m_schedule_background_process(); | ||||
| 
 | ||||
|         update_view_type(false); | ||||
|     }); | ||||
| } | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
| 
 | ||||
| // Find an index of a value in a sorted vector, which is in <z-eps, z+eps>.
 | ||||
| // Returns -1 if there is no such member.
 | ||||
|  | @ -934,12 +621,7 @@ static int find_close_layer_idx(const std::vector<double>& zs, double &z, double | |||
|     return -1; | ||||
| } | ||||
| 
 | ||||
| #if ENABLE_GCODE_VIEWER | ||||
| void Preview::check_layers_slider_values(std::vector<CustomGCode::Item>& ticks_from_model, const std::vector<double>& layers_z) | ||||
| #else | ||||
| void Preview::check_slider_values(std::vector<CustomGCode::Item>& ticks_from_model, | ||||
|                                   const std::vector<double>& layers_z) | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
| { | ||||
|     // All ticks that would end up outside the slider range should be erased.
 | ||||
|     // TODO: this should be placed into more appropriate part of code,
 | ||||
|  | @ -956,7 +638,6 @@ void Preview::check_slider_values(std::vector<CustomGCode::Item>& ticks_from_mod | |||
|         m_schedule_background_process(); | ||||
| } | ||||
| 
 | ||||
| #if ENABLE_GCODE_VIEWER | ||||
| void Preview::update_layers_slider(const std::vector<double>& layers_z, bool keep_z_range) | ||||
| { | ||||
|     // Save the initial slider span.
 | ||||
|  | @ -1009,64 +690,8 @@ void Preview::update_layers_slider(const std::vector<double>& layers_z, bool kee | |||
|     m_layers_slider_sizer->Show((size_t)0); | ||||
|     Layout(); | ||||
| } | ||||
| #else | ||||
| void Preview::update_double_slider(const std::vector<double> & layers_z, bool keep_z_range) | ||||
| { | ||||
|     // Save the initial slider span.
 | ||||
|     double z_low        = m_slider->GetLowerValueD(); | ||||
|     double z_high       = m_slider->GetHigherValueD(); | ||||
|     bool   was_empty    = m_slider->GetMaxValue() == 0; | ||||
| 
 | ||||
|     bool force_sliders_full_range = was_empty; | ||||
|     if (!keep_z_range) | ||||
|     { | ||||
|         bool span_changed = layers_z.empty() || std::abs(layers_z.back() - m_slider->GetMaxValueD()) > DoubleSlider::epsilon()/*1e-6*/; | ||||
|         force_sliders_full_range |= span_changed; | ||||
|     } | ||||
|     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(); | ||||
| 
 | ||||
|     // Detect and set manipulation mode for double slider
 | ||||
|     update_double_slider_mode(); | ||||
| 
 | ||||
|     CustomGCode::Info& ticks_info_from_model = wxGetApp().plater()->model().custom_gcode_per_print_z; | ||||
|     check_slider_values(ticks_info_from_model.gcodes, layers_z); | ||||
| 
 | ||||
|     m_slider->SetSliderValues(layers_z); | ||||
|     assert(m_slider->GetMinValue() == 0); | ||||
|     m_slider->SetMaxValue(layers_z.empty() ? 0 : layers_z.size() - 1); | ||||
| 
 | ||||
|     int idx_low = 0; | ||||
|     int idx_high = m_slider->GetMaxValue(); | ||||
|     if (!layers_z.empty()) { | ||||
|         if (!snap_to_min) { | ||||
|             int idx_new = find_close_layer_idx(layers_z, z_low, DoubleSlider::epsilon()/*1e-6*/); | ||||
|             if (idx_new != -1) | ||||
|                 idx_low = idx_new; | ||||
|         } | ||||
|         if (!snap_to_max) { | ||||
|             int idx_new = find_close_layer_idx(layers_z, z_high, DoubleSlider::epsilon()/*1e-6*/); | ||||
|             if (idx_new != -1) | ||||
|                 idx_high = idx_new; | ||||
|         } | ||||
|     } | ||||
|     m_slider->SetSelectionSpan(idx_low, idx_high); | ||||
| 
 | ||||
|     m_slider->SetTicksValues(ticks_info_from_model); | ||||
| 
 | ||||
|     bool sla_print_technology = wxGetApp().plater()->printer_technology() == ptSLA; | ||||
|     bool sequential_print = wxGetApp().preset_bundle->prints.get_edited_preset().config.opt_bool("complete_objects"); | ||||
|     m_slider->SetDrawMode(sla_print_technology, sequential_print); | ||||
| 
 | ||||
|     m_slider->SetExtruderColors(wxGetApp().plater()->get_extruder_colors_from_plater_config()); | ||||
| } | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
| 
 | ||||
| #if ENABLE_GCODE_VIEWER | ||||
| void Preview::update_layers_slider_mode() | ||||
| #else | ||||
| void Preview::update_double_slider_mode() | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
| { | ||||
|     //    true  -> single-extruder printer profile OR 
 | ||||
|     //             multi-extruder printer profile , but whole model is printed by only one extruder
 | ||||
|  | @ -1115,28 +740,15 @@ void Preview::update_double_slider_mode() | |||
|         } | ||||
|     } | ||||
| 
 | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|     m_layers_slider->SetModeAndOnlyExtruder(one_extruder_printed_model, only_extruder); | ||||
| #else | ||||
|     m_slider->SetModeAndOnlyExtruder(one_extruder_printed_model, only_extruder); | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
| } | ||||
| 
 | ||||
| #if ENABLE_GCODE_VIEWER | ||||
| void Preview::reset_layers_slider() | ||||
| { | ||||
|     m_layers_slider->SetHigherValue(0); | ||||
|     m_layers_slider->SetLowerValue(0); | ||||
| } | ||||
| #else | ||||
| void Preview::reset_double_slider() | ||||
| { | ||||
|     m_slider->SetHigherValue(0); | ||||
|     m_slider->SetLowerValue(0); | ||||
| } | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
| 
 | ||||
| #if ENABLE_GCODE_VIEWER | ||||
| void Preview::update_layers_slider_from_canvas(wxKeyEvent& event) | ||||
| { | ||||
|     if (event.HasModifiers()) { | ||||
|  | @ -1185,42 +797,12 @@ void Preview::enable_moves_slider(bool enable) | |||
|         m_moves_slider->Refresh(); | ||||
|     } | ||||
| } | ||||
| #else | ||||
| void Preview::update_double_slider_from_canvas(wxKeyEvent & event) | ||||
| { | ||||
|     if (event.HasModifiers()) { | ||||
|         event.Skip(); | ||||
|         return; | ||||
|     } | ||||
| 
 | ||||
|     const auto key = event.GetKeyCode(); | ||||
| 
 | ||||
|     if (key == 'U' || key == 'D') { | ||||
|         const int new_pos = key == 'U' ? m_slider->GetHigherValue() + 1 : m_slider->GetHigherValue() - 1; | ||||
|         m_slider->SetHigherValue(new_pos); | ||||
| 		if (event.ShiftDown() || m_slider->is_one_layer()) m_slider->SetLowerValue(m_slider->GetHigherValue()); | ||||
|     } | ||||
|     else if (key == 'L') { | ||||
|         m_checkbox_legend->SetValue(!m_checkbox_legend->GetValue()); | ||||
|         auto evt = wxCommandEvent(); | ||||
|         on_checkbox_legend(evt); | ||||
|     } | ||||
|     else if (key == 'S') | ||||
|         m_slider->ChangeOneLayerLock(); | ||||
|     else if (key == WXK_SHIFT) | ||||
|         m_slider->UseDefaultColors(false); | ||||
|     else | ||||
|         event.Skip(); | ||||
| } | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
| 
 | ||||
| void Preview::load_print_as_fff(bool keep_z_range) | ||||
| { | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|     if (wxGetApp().mainframe == nullptr || wxGetApp().is_recreating_gui()) | ||||
|         // avoid processing while mainframe is being constructed
 | ||||
|         return; | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
| 
 | ||||
|     if (m_loaded || m_process->current_printer_technology() != ptFFF) | ||||
|         return; | ||||
|  | @ -1245,17 +827,11 @@ void Preview::load_print_as_fff(bool keep_z_range) | |||
|             } | ||||
|     } | ||||
| 
 | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|     if (wxGetApp().is_editor() && !has_layers) { | ||||
|         hide_layers_slider(); | ||||
|         m_left_sizer->Hide(m_bottom_toolbar_panel); | ||||
|         m_left_sizer->Layout(); | ||||
|         Refresh(); | ||||
| #else | ||||
|     if (! has_layers) { | ||||
|         reset_sliders(true); | ||||
|         m_canvas->reset_legend_texture(); | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
|         m_canvas_widget->Refresh(); | ||||
|         return; | ||||
|     } | ||||
|  | @ -1267,100 +843,58 @@ void Preview::load_print_as_fff(bool keep_z_range) | |||
|         int tool_idx = m_choice_view_type->FindString(_L("Tool")); | ||||
|         int type = (number_extruders > 1) ? tool_idx /* color by a tool number */ : 0; // color by a feature type
 | ||||
|         m_choice_view_type->SetSelection(type); | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|         if (0 <= type && type < static_cast<int>(GCodeViewer::EViewType::Count)) | ||||
|             m_canvas->set_gcode_view_preview_type(static_cast<GCodeViewer::EViewType>(type)); | ||||
| #else | ||||
|         if ((0 <= type) && (type < (int)GCodePreviewData::Extrusion::Num_View_Types)) | ||||
|             m_gcode_preview_data->extrusion.view_type = (GCodePreviewData::Extrusion::EViewType)type; | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
|         // If the->SetSelection changed the following line, revert it to "decide yourself".
 | ||||
|         m_preferred_color_mode = "tool_or_feature"; | ||||
|     } | ||||
| 
 | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|     GCodeViewer::EViewType gcode_view_type = m_canvas->get_gcode_view_preview_type(); | ||||
|     bool gcode_preview_data_valid = !m_gcode_result->moves.empty(); | ||||
| #else | ||||
|     bool gcode_preview_data_valid = print->is_step_done(psGCodeExport) && ! m_gcode_preview_data->empty(); | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
|     // Collect colors per extruder.
 | ||||
|     std::vector<std::string> colors; | ||||
|     std::vector<CustomGCode::Item> color_print_values = {}; | ||||
|     // set color print values, if it si selected "ColorPrint" view type
 | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|     if (gcode_view_type == GCodeViewer::EViewType::ColorPrint) { | ||||
|         colors = wxGetApp().plater()->get_colors_for_color_print(m_gcode_result); | ||||
| #else | ||||
|     if (m_gcode_preview_data->extrusion.view_type == GCodePreviewData::Extrusion::ColorPrint) { | ||||
|         colors = wxGetApp().plater()->get_colors_for_color_print(); | ||||
|         colors.push_back("#808080"); // gray color for pause print or custom G-code 
 | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
| 
 | ||||
|         if (!gcode_preview_data_valid) { | ||||
|             color_print_values = wxGetApp().plater()->model().custom_gcode_per_print_z.gcodes; | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|             colors.push_back("#808080"); // gray color for pause print or custom G-code 
 | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
|         } | ||||
|     } | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|     else if (gcode_preview_data_valid || gcode_view_type == GCodeViewer::EViewType::Tool) { | ||||
|         colors = wxGetApp().plater()->get_extruder_colors_from_plater_config(m_gcode_result); | ||||
| #else | ||||
|     else if (gcode_preview_data_valid || (m_gcode_preview_data->extrusion.view_type == GCodePreviewData::Extrusion::Tool) ) { | ||||
|         colors = wxGetApp().plater()->get_extruder_colors_from_plater_config(); | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
|         color_print_values.clear(); | ||||
|     } | ||||
| 
 | ||||
|     if (IsShown()) { | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|         std::vector<double> zs; | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
| 
 | ||||
|         m_canvas->set_selected_extruder(0); | ||||
|         if (gcode_preview_data_valid) { | ||||
|             // Load the real G-code preview.
 | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|             m_canvas->load_gcode_preview(*m_gcode_result); | ||||
|             m_canvas->refresh_gcode_preview(*m_gcode_result, colors); | ||||
|             m_left_sizer->Show(m_bottom_toolbar_panel); | ||||
|             m_left_sizer->Layout(); | ||||
|             Refresh(); | ||||
|             zs = m_canvas->get_gcode_layers_zs(); | ||||
| #else | ||||
|             m_canvas->load_gcode_preview(*m_gcode_preview_data, colors); | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
|             m_loaded = true; | ||||
|         } else { | ||||
|             // Load the initial preview based on slices, not the final G-code.
 | ||||
|             m_canvas->load_preview(colors, color_print_values); | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|             m_left_sizer->Hide(m_bottom_toolbar_panel); | ||||
|             m_left_sizer->Layout(); | ||||
|             Refresh(); | ||||
|             zs = m_canvas->get_volumes_print_zs(true); | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
|         } | ||||
| #if !ENABLE_GCODE_VIEWER | ||||
|         show_hide_ui_elements(gcode_preview_data_valid ? "full" : "simple"); | ||||
|         std::vector<double> zs = m_canvas->get_current_print_zs(true); | ||||
| #endif // !ENABLE_GCODE_VIEWER
 | ||||
|         if (zs.empty()) { | ||||
|             // all layers filtered out
 | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|             hide_layers_slider(); | ||||
| #else | ||||
|             reset_sliders(true); | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
|             m_canvas_widget->Refresh(); | ||||
|         } else | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|             update_layers_slider(zs, keep_z_range); | ||||
| #else | ||||
|             update_sliders(zs, keep_z_range); | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
|     } | ||||
| } | ||||
| 
 | ||||
|  | @ -1375,8 +909,7 @@ void Preview::load_print_as_sla() | |||
|     std::vector<double> zs; | ||||
|     double initial_layer_height = print->material_config().initial_layer_height.value; | ||||
|     for (const SLAPrintObject* obj : print->objects()) | ||||
|         if (obj->is_step_done(slaposSliceSupports) && !obj->get_slice_index().empty()) | ||||
|         { | ||||
|         if (obj->is_step_done(slaposSliceSupports) && !obj->get_slice_index().empty()) { | ||||
|             auto low_coord = obj->get_slice_index().front().print_level(); | ||||
|             for (auto& rec : obj->get_slice_index()) | ||||
|                 zs.emplace_back(initial_layer_height + (rec.print_level() - low_coord) * SCALING_FACTOR); | ||||
|  | @ -1386,74 +919,43 @@ void Preview::load_print_as_sla() | |||
|     m_canvas->reset_clipping_planes_cache(); | ||||
| 
 | ||||
|     n_layers = (unsigned int)zs.size(); | ||||
|     if (n_layers == 0) | ||||
|     { | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|     if (n_layers == 0) { | ||||
|         hide_layers_slider(); | ||||
| #else | ||||
|         reset_sliders(true); | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
|         m_canvas_widget->Refresh(); | ||||
|     } | ||||
| 
 | ||||
|     if (IsShown()) | ||||
|     { | ||||
|     if (IsShown()) { | ||||
|         m_canvas->load_sla_preview(); | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|         m_left_sizer->Hide(m_bottom_toolbar_panel); | ||||
|         m_left_sizer->Hide(m_bottom_toolbar_panel); | ||||
|         m_left_sizer->Layout(); | ||||
|         Refresh(); | ||||
| #else | ||||
|         show_hide_ui_elements("none"); | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
| 
 | ||||
|         if (n_layers > 0) | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|             update_layers_slider(zs); | ||||
| #else | ||||
|             update_sliders(zs); | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
| 
 | ||||
|         m_loaded = true; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| #if ENABLE_GCODE_VIEWER | ||||
| void Preview::on_layers_slider_scroll_changed(wxCommandEvent& event) | ||||
| #else | ||||
| void Preview::on_sliders_scroll_changed(wxCommandEvent& event) | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
| { | ||||
|     if (IsShown()) { | ||||
|         PrinterTechnology tech = m_process->current_printer_technology(); | ||||
|         if (tech == ptFFF) { | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|             m_canvas->set_volumes_z_range({ m_layers_slider->GetLowerValueD(), m_layers_slider->GetHigherValueD() }); | ||||
|             m_canvas->set_toolpaths_z_range({ static_cast<unsigned int>(m_layers_slider->GetLowerValue()), static_cast<unsigned int>(m_layers_slider->GetHigherValue()) }); | ||||
|             m_canvas->set_as_dirty(); | ||||
| #else | ||||
|             m_canvas->set_toolpaths_range(m_slider->GetLowerValueD() - 1e-6, m_slider->GetHigherValueD() + 1e-6); | ||||
|             m_canvas->render(); | ||||
|             m_canvas->set_use_clipping_planes(false); | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
|         } | ||||
|         else if (tech == ptSLA) { | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|             m_canvas->set_clipping_plane(0, ClippingPlane(Vec3d::UnitZ(), -m_layers_slider->GetLowerValueD())); | ||||
|             m_canvas->set_clipping_plane(1, ClippingPlane(-Vec3d::UnitZ(), m_layers_slider->GetHigherValueD())); | ||||
|             m_canvas->set_use_clipping_planes(m_layers_slider->GetHigherValue() != 0); | ||||
| #else | ||||
|             m_canvas->set_clipping_plane(0, ClippingPlane(Vec3d::UnitZ(), -m_slider->GetLowerValueD())); | ||||
|             m_canvas->set_clipping_plane(1, ClippingPlane(-Vec3d::UnitZ(), m_slider->GetHigherValueD())); | ||||
|             m_canvas->set_use_clipping_planes(m_slider->GetHigherValue() != 0); | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
|             m_canvas->render(); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| #if ENABLE_GCODE_VIEWER | ||||
| void Preview::on_moves_slider_scroll_changed(wxCommandEvent& event) | ||||
| { | ||||
|     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)); | ||||
|  | @ -1477,7 +979,6 @@ wxString Preview::get_option_type_string(OptionType type) const | |||
|     default:                        { return ""; } | ||||
|     } | ||||
| } | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
| 
 | ||||
| } // namespace GUI
 | ||||
| } // namespace Slic3r
 | ||||
|  |  | |||
|  | @ -7,9 +7,7 @@ | |||
| #include "libslic3r/CustomGCode.hpp" | ||||
| 
 | ||||
| #include <string> | ||||
| #if ENABLE_GCODE_VIEWER | ||||
| #include "libslic3r/GCode/GCodeProcessor.hpp" | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
| 
 | ||||
| class wxNotebook; | ||||
| class wxGLCanvas; | ||||
|  | @ -25,9 +23,6 @@ namespace Slic3r { | |||
| class DynamicPrintConfig; | ||||
| class Print; | ||||
| class BackgroundSlicingProcess; | ||||
| #if !ENABLE_GCODE_VIEWER | ||||
| class GCodePreviewData; | ||||
| #endif // !ENABLE_GCODE_VIEWER
 | ||||
| class Model; | ||||
| 
 | ||||
| namespace DoubleSlider { | ||||
|  | @ -83,35 +78,19 @@ class Preview : public wxPanel | |||
| { | ||||
|     wxGLCanvas* m_canvas_widget; | ||||
|     GLCanvas3D* m_canvas; | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|     wxBoxSizer* m_left_sizer; | ||||
|     wxBoxSizer* m_layers_slider_sizer; | ||||
|     wxPanel* m_bottom_toolbar_panel; | ||||
| #else | ||||
|     wxBoxSizer* m_double_slider_sizer; | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
|     wxStaticText* m_label_view_type; | ||||
|     wxChoice* m_choice_view_type; | ||||
|     wxStaticText* m_label_show; | ||||
|     wxComboCtrl* m_combochecklist_features; | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|     size_t m_combochecklist_features_pos; | ||||
|     wxComboCtrl* m_combochecklist_options; | ||||
| #else | ||||
|     wxCheckBox* m_checkbox_travel; | ||||
|     wxCheckBox* m_checkbox_retractions; | ||||
|     wxCheckBox* m_checkbox_unretractions; | ||||
|     wxCheckBox* m_checkbox_shells; | ||||
|     wxCheckBox* m_checkbox_legend; | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
| 
 | ||||
|     DynamicPrintConfig* m_config; | ||||
|     BackgroundSlicingProcess* m_process; | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|     GCodeProcessor::Result* m_gcode_result; | ||||
| #else | ||||
|     GCodePreviewData* m_gcode_preview_data; | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
| 
 | ||||
| #ifdef __linux__ | ||||
|     // We are getting mysterious crashes on Linux in gtk due to OpenGL context activation GH #1874 #1955.
 | ||||
|  | @ -126,19 +105,11 @@ class Preview : public wxPanel | |||
|     std::string m_preferred_color_mode; | ||||
| 
 | ||||
|     bool m_loaded; | ||||
| #if !ENABLE_GCODE_VIEWER | ||||
|     bool m_enabled; | ||||
| #endif // !ENABLE_GCODE_VIEWER
 | ||||
| 
 | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|     DoubleSlider::Control* m_layers_slider{ nullptr }; | ||||
|     DoubleSlider::Control* m_moves_slider{ nullptr }; | ||||
| #else | ||||
|     DoubleSlider::Control*       m_slider {nullptr}; | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
| 
 | ||||
| public: | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|     enum class OptionType : unsigned int | ||||
|     { | ||||
|         Travel, | ||||
|  | @ -153,12 +124,8 @@ public: | |||
|         Legend | ||||
|     }; | ||||
| 
 | ||||
| Preview(wxWindow* parent, Model* model, DynamicPrintConfig* config, BackgroundSlicingProcess* process,  | ||||
|     GCodeProcessor::Result* gcode_result, std::function<void()> schedule_background_process = []() {}); | ||||
| #else | ||||
| Preview(wxWindow* parent, Model* model, DynamicPrintConfig* config, | ||||
|         BackgroundSlicingProcess* process, GCodePreviewData* gcode_preview_data, std::function<void()> schedule_background_process = []() {}); | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
|     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; } | ||||
|  | @ -167,9 +134,6 @@ Preview(wxWindow* parent, Model* model, DynamicPrintConfig* config, | |||
|     void set_as_dirty(); | ||||
| 
 | ||||
|     void set_number_extruders(unsigned int number_extruders); | ||||
| #if !ENABLE_GCODE_VIEWER | ||||
|     void set_enabled(bool enabled); | ||||
| #endif // !ENABLE_GCODE_VIEWER
 | ||||
|     void bed_shape_changed(); | ||||
|     void select_view(const std::string& direction); | ||||
|     void set_drop_target(wxDropTarget* target); | ||||
|  | @ -180,24 +144,17 @@ Preview(wxWindow* parent, Model* model, DynamicPrintConfig* config, | |||
| 
 | ||||
|     void msw_rescale(); | ||||
|     void jump_layers_slider(wxKeyEvent& evt); | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|     void move_layers_slider(wxKeyEvent& evt); | ||||
|     void edit_layers_slider(wxKeyEvent& evt); | ||||
| #else | ||||
|     void move_double_slider(wxKeyEvent& evt); | ||||
|     void edit_double_slider(wxKeyEvent& evt); | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
| 
 | ||||
|     void update_view_type(bool keep_volumes); | ||||
| 
 | ||||
|     bool is_loaded() const { return m_loaded; } | ||||
| 
 | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|     void update_bottom_toolbar(); | ||||
|     void update_moves_slider(); | ||||
|     void enable_moves_slider(bool enable); | ||||
|     void hide_layers_slider(); | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
| 
 | ||||
| private: | ||||
|     bool init(wxWindow* parent, Model* model); | ||||
|  | @ -205,27 +162,11 @@ private: | |||
|     void bind_event_handlers(); | ||||
|     void unbind_event_handlers(); | ||||
| 
 | ||||
| #if !ENABLE_GCODE_VIEWER | ||||
|     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); | ||||
| #endif // !ENABLE_GCODE_VIEWER
 | ||||
| 
 | ||||
|     void on_size(wxSizeEvent& evt); | ||||
|     void on_choice_view_type(wxCommandEvent& evt); | ||||
|     void on_combochecklist_features(wxCommandEvent& evt); | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|     void on_combochecklist_options(wxCommandEvent& evt); | ||||
| #else | ||||
|     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); | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
| 
 | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|     // Create/Update/Reset double slider on 3dPreview
 | ||||
|     wxBoxSizer* create_layers_slider_sizer(); | ||||
|     void check_layers_slider_values(std::vector<CustomGCode::Item>& ticks_from_model, | ||||
|  | @ -235,28 +176,13 @@ private: | |||
|     void update_layers_slider_mode(); | ||||
|     // update vertical DoubleSlider after keyDown in canvas
 | ||||
|     void update_layers_slider_from_canvas(wxKeyEvent& event); | ||||
| #else | ||||
|     // 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); | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
| 
 | ||||
|     void load_print_as_fff(bool keep_z_range = false); | ||||
|     void load_print_as_sla(); | ||||
| 
 | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|     void on_layers_slider_scroll_changed(wxCommandEvent& event); | ||||
|     void on_moves_slider_scroll_changed(wxCommandEvent& event); | ||||
|     wxString get_option_type_string(OptionType type) const; | ||||
| #else | ||||
|     void on_sliders_scroll_changed(wxCommandEvent& event); | ||||
| #endif // ENABLE_GCODE_VIEWER
 | ||||
| }; | ||||
| 
 | ||||
| } // namespace GUI
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 enricoturri1966
						enricoturri1966