2018-09-18 13:35:05 +02:00
|
|
|
#ifndef slic3r_GUI_Preview_hpp_
|
|
|
|
#define slic3r_GUI_Preview_hpp_
|
|
|
|
|
|
|
|
#include <wx/panel.h>
|
2018-12-06 12:52:28 +01:00
|
|
|
#include "libslic3r/Point.hpp"
|
2018-09-18 13:35:05 +02:00
|
|
|
|
|
|
|
#include <string>
|
2019-10-10 16:03:58 +02:00
|
|
|
#include "libslic3r/Model.hpp"
|
2020-03-02 15:13:23 +01:00
|
|
|
#if ENABLE_GCODE_VIEWER
|
|
|
|
#include "libslic3r/GCode/GCodeProcessor.hpp"
|
|
|
|
#endif // ENABLE_GCODE_VIEWER
|
2018-09-18 13:35:05 +02:00
|
|
|
|
|
|
|
class wxNotebook;
|
|
|
|
class wxGLCanvas;
|
|
|
|
class wxBoxSizer;
|
|
|
|
class wxStaticText;
|
|
|
|
class wxChoice;
|
|
|
|
class wxComboCtrl;
|
2019-10-18 12:35:35 +02:00
|
|
|
class wxBitmapComboBox;
|
2018-09-18 13:35:05 +02:00
|
|
|
class wxCheckBox;
|
|
|
|
|
|
|
|
namespace Slic3r {
|
|
|
|
|
|
|
|
class DynamicPrintConfig;
|
|
|
|
class Print;
|
2018-11-22 15:29:59 +01:00
|
|
|
class BackgroundSlicingProcess;
|
2018-09-18 13:35:05 +02:00
|
|
|
class GCodePreviewData;
|
2018-12-04 13:55:25 +01:00
|
|
|
class Model;
|
2018-09-18 13:35:05 +02:00
|
|
|
|
2020-01-23 15:07:31 +01:00
|
|
|
namespace DoubleSlider {
|
|
|
|
class Control;
|
|
|
|
};
|
|
|
|
|
2018-09-18 13:35:05 +02:00
|
|
|
namespace GUI {
|
|
|
|
|
2018-11-23 12:47:32 +01:00
|
|
|
class GLCanvas3D;
|
2018-12-17 10:55:14 +01:00
|
|
|
class GLToolbar;
|
2019-02-19 15:15:27 +01:00
|
|
|
class Bed3D;
|
2019-03-07 11:49:00 +01:00
|
|
|
struct Camera;
|
2020-03-02 10:58:46 +01:00
|
|
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
|
|
|
class Plater;
|
|
|
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
2018-11-23 12:47:32 +01:00
|
|
|
|
2018-12-04 13:55:25 +01:00
|
|
|
class View3D : public wxPanel
|
|
|
|
{
|
|
|
|
wxGLCanvas* m_canvas_widget;
|
|
|
|
GLCanvas3D* m_canvas;
|
|
|
|
|
|
|
|
public:
|
2020-03-02 10:58:46 +01:00
|
|
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
|
|
|
View3D(wxWindow* parent, Model* model, DynamicPrintConfig* config, BackgroundSlicingProcess* process);
|
|
|
|
#else
|
2019-03-07 11:49:00 +01:00
|
|
|
View3D(wxWindow* parent, Bed3D& bed, Camera& camera, GLToolbar& view_toolbar, Model* model, DynamicPrintConfig* config, BackgroundSlicingProcess* process);
|
2020-03-02 10:58:46 +01:00
|
|
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
2018-12-04 13:55:25 +01:00
|
|
|
virtual ~View3D();
|
|
|
|
|
|
|
|
wxGLCanvas* get_wxglcanvas() { return m_canvas_widget; }
|
|
|
|
GLCanvas3D* get_canvas3d() { return m_canvas; }
|
|
|
|
|
|
|
|
void set_as_dirty();
|
2019-02-19 15:15:27 +01:00
|
|
|
void bed_shape_changed();
|
2018-12-04 13:55:25 +01:00
|
|
|
|
|
|
|
void select_view(const std::string& direction);
|
|
|
|
void select_all();
|
2019-05-14 11:57:39 +02:00
|
|
|
void deselect_all();
|
2018-12-04 13:55:25 +01:00
|
|
|
void delete_selected();
|
|
|
|
void mirror_selection(Axis axis);
|
|
|
|
|
|
|
|
int check_volumes_outside_state() const;
|
|
|
|
|
|
|
|
bool is_layers_editing_enabled() const;
|
|
|
|
bool is_layers_editing_allowed() const;
|
|
|
|
void enable_layers_editing(bool enable);
|
|
|
|
|
|
|
|
bool is_dragging() const;
|
|
|
|
bool is_reload_delayed() const;
|
|
|
|
|
|
|
|
void reload_scene(bool refresh_immediately, bool force_full_scene_refresh = false);
|
|
|
|
void render();
|
|
|
|
|
|
|
|
private:
|
2020-03-02 10:58:46 +01:00
|
|
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
|
|
|
bool init(wxWindow* parent, Model* model, DynamicPrintConfig* config, BackgroundSlicingProcess* process);
|
|
|
|
#else
|
2019-03-07 11:49:00 +01:00
|
|
|
bool init(wxWindow* parent, Bed3D& bed, Camera& camera, GLToolbar& view_toolbar, Model* model, DynamicPrintConfig* config, BackgroundSlicingProcess* process);
|
2020-03-02 10:58:46 +01:00
|
|
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
2018-12-04 13:55:25 +01:00
|
|
|
};
|
|
|
|
|
2018-09-18 13:35:05 +02:00
|
|
|
class Preview : public wxPanel
|
|
|
|
{
|
2018-11-23 12:47:32 +01:00
|
|
|
wxGLCanvas* m_canvas_widget;
|
|
|
|
GLCanvas3D* m_canvas;
|
2018-09-18 13:35:05 +02:00
|
|
|
wxBoxSizer* m_double_slider_sizer;
|
2020-04-28 08:50:52 +02:00
|
|
|
#if ENABLE_GCODE_VIEWER
|
|
|
|
wxBoxSizer* m_bottom_toolbar_sizer;
|
|
|
|
#endif // ENABLE_GCODE_VIEWER
|
2018-09-18 13:35:05 +02:00
|
|
|
wxStaticText* m_label_view_type;
|
|
|
|
wxChoice* m_choice_view_type;
|
2020-04-24 16:12:38 +02:00
|
|
|
wxStaticText* m_label_show;
|
2018-09-18 13:35:05 +02:00
|
|
|
wxComboCtrl* m_combochecklist_features;
|
2020-04-24 16:12:38 +02:00
|
|
|
#if ENABLE_GCODE_VIEWER
|
|
|
|
wxComboCtrl* m_combochecklist_options;
|
|
|
|
#else
|
2018-09-18 13:35:05 +02:00
|
|
|
wxCheckBox* m_checkbox_travel;
|
|
|
|
wxCheckBox* m_checkbox_retractions;
|
|
|
|
wxCheckBox* m_checkbox_unretractions;
|
|
|
|
wxCheckBox* m_checkbox_shells;
|
2019-06-22 17:38:14 +02:00
|
|
|
wxCheckBox* m_checkbox_legend;
|
2020-04-24 16:12:38 +02:00
|
|
|
#endif // ENABLE_GCODE_VIEWER
|
2018-09-18 13:35:05 +02:00
|
|
|
|
|
|
|
DynamicPrintConfig* m_config;
|
2018-11-22 15:29:59 +01:00
|
|
|
BackgroundSlicingProcess* m_process;
|
2018-09-18 13:35:05 +02:00
|
|
|
GCodePreviewData* m_gcode_preview_data;
|
2020-03-02 15:13:23 +01:00
|
|
|
#if ENABLE_GCODE_VIEWER
|
|
|
|
GCodeProcessor::Result* m_gcode_result;
|
|
|
|
#endif // ENABLE_GCODE_VIEWER
|
2018-09-18 13:35:05 +02:00
|
|
|
|
2019-03-21 11:44:39 +01:00
|
|
|
#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.
|
2019-03-18 14:07:55 +01:00
|
|
|
bool m_volumes_cleanup_required;
|
2019-03-21 11:44:39 +01:00
|
|
|
#endif /* __linux__ */
|
2019-03-18 14:07:55 +01:00
|
|
|
|
2018-11-12 15:35:58 +01:00
|
|
|
// Calling this function object forces Plater::schedule_background_process.
|
|
|
|
std::function<void()> m_schedule_background_process;
|
|
|
|
|
2018-09-18 13:35:05 +02:00
|
|
|
unsigned int m_number_extruders;
|
|
|
|
std::string m_preferred_color_mode;
|
|
|
|
|
|
|
|
bool m_loaded;
|
|
|
|
bool m_enabled;
|
|
|
|
|
2020-01-23 15:07:31 +01:00
|
|
|
DoubleSlider::Control* m_slider {nullptr};
|
2018-10-05 23:29:15 +02:00
|
|
|
|
2018-09-18 13:35:05 +02:00
|
|
|
public:
|
2020-03-02 10:58:46 +01:00
|
|
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
2020-03-30 09:36:37 +02:00
|
|
|
#if ENABLE_GCODE_VIEWER
|
|
|
|
Preview(wxWindow* parent, Model* model, DynamicPrintConfig* config,
|
|
|
|
BackgroundSlicingProcess* process, GCodePreviewData* gcode_preview_data, GCodeProcessor::Result* gcode_result, std::function<void()> schedule_background_process = []() {});
|
|
|
|
#else
|
2020-03-02 10:58:46 +01:00
|
|
|
Preview(wxWindow* parent, Model* model, DynamicPrintConfig* config,
|
|
|
|
BackgroundSlicingProcess* process, GCodePreviewData* gcode_preview_data, std::function<void()> schedule_background_process = []() {});
|
2020-03-30 09:36:37 +02:00
|
|
|
#endif // ENABLE_GCODE_VIEWER
|
2020-03-02 10:58:46 +01:00
|
|
|
#else
|
2020-03-02 15:13:23 +01:00
|
|
|
#if ENABLE_GCODE_VIEWER
|
|
|
|
Preview(wxWindow* parent, Bed3D& bed, Camera& camera, GLToolbar& view_toolbar, Model* model, DynamicPrintConfig* config,
|
|
|
|
BackgroundSlicingProcess* process, GCodePreviewData* gcode_preview_data, GCodeProcessor::Result* gcode_result, std::function<void()> schedule_background_process = []() {});
|
|
|
|
#else
|
|
|
|
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 = []() {});
|
|
|
|
#endif // ENABLE_GCODE_VIEWER
|
2020-03-02 10:58:46 +01:00
|
|
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
2018-09-18 13:35:05 +02:00
|
|
|
virtual ~Preview();
|
|
|
|
|
2018-11-23 12:47:32 +01:00
|
|
|
wxGLCanvas* get_wxglcanvas() { return m_canvas_widget; }
|
2019-01-24 13:16:46 +01:00
|
|
|
GLCanvas3D* get_canvas3d() { return m_canvas; }
|
2018-10-03 14:25:35 +02:00
|
|
|
|
2019-06-24 15:55:14 +02:00
|
|
|
void set_as_dirty();
|
|
|
|
|
2018-09-18 13:35:05 +02:00
|
|
|
void set_number_extruders(unsigned int number_extruders);
|
|
|
|
void set_enabled(bool enabled);
|
2019-02-19 15:15:27 +01:00
|
|
|
void bed_shape_changed();
|
2018-09-18 13:35:05 +02:00
|
|
|
void select_view(const std::string& direction);
|
|
|
|
void set_drop_target(wxDropTarget* target);
|
|
|
|
|
2019-03-19 10:48:20 +01:00
|
|
|
void load_print(bool keep_z_range = false);
|
2019-03-18 14:07:55 +01:00
|
|
|
void reload_print(bool keep_volumes = false);
|
2018-09-18 13:35:05 +02:00
|
|
|
void refresh_print();
|
2018-10-03 11:34:39 +02:00
|
|
|
|
2019-04-25 01:45:00 +02:00
|
|
|
void msw_rescale();
|
2019-06-13 16:10:33 +02:00
|
|
|
void move_double_slider(wxKeyEvent& evt);
|
2019-06-18 11:40:26 +02:00
|
|
|
void edit_double_slider(wxKeyEvent& evt);
|
2019-04-16 10:05:45 +02:00
|
|
|
|
2019-10-16 09:45:11 +02:00
|
|
|
void update_view_type(bool slice_completed);
|
2019-07-02 13:13:17 +02:00
|
|
|
|
2019-08-20 09:01:09 +02:00
|
|
|
bool is_loaded() const { return m_loaded; }
|
|
|
|
|
2020-04-28 08:50:52 +02:00
|
|
|
#if ENABLE_GCODE_VIEWER
|
|
|
|
void update_bottom_toolbar();
|
|
|
|
#endif // ENABLE_GCODE_VIEWER
|
|
|
|
|
2018-09-18 13:35:05 +02:00
|
|
|
private:
|
2020-03-02 10:58:46 +01:00
|
|
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
|
|
|
bool init(wxWindow* parent, Model* model);
|
|
|
|
#else
|
2019-04-02 13:47:49 +02:00
|
|
|
bool init(wxWindow* parent, Bed3D& bed, Camera& camera, GLToolbar& view_toolbar, Model* model);
|
2020-03-02 10:58:46 +01:00
|
|
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
2018-09-18 13:35:05 +02:00
|
|
|
|
|
|
|
void bind_event_handlers();
|
|
|
|
void unbind_event_handlers();
|
|
|
|
|
2020-04-28 08:50:52 +02:00
|
|
|
#if !ENABLE_GCODE_VIEWER
|
2018-09-18 13:35:05 +02:00
|
|
|
void show_hide_ui_elements(const std::string& what);
|
2020-04-28 08:50:52 +02:00
|
|
|
#endif // !ENABLE_GCODE_VIEWER
|
2018-09-18 13:35:05 +02:00
|
|
|
|
2019-10-24 08:43:27 +02:00
|
|
|
void reset_sliders(bool reset_all);
|
2019-03-19 10:48:20 +01:00
|
|
|
void update_sliders(const std::vector<double>& layers_z, bool keep_z_range = false);
|
2018-09-18 13:35:05 +02:00
|
|
|
|
|
|
|
void on_size(wxSizeEvent& evt);
|
|
|
|
void on_choice_view_type(wxCommandEvent& evt);
|
|
|
|
void on_combochecklist_features(wxCommandEvent& evt);
|
2020-04-24 16:12:38 +02:00
|
|
|
#if ENABLE_GCODE_VIEWER
|
|
|
|
void on_combochecklist_options(wxCommandEvent& evt);
|
|
|
|
#else
|
2018-09-18 13:35:05 +02:00
|
|
|
void on_checkbox_travel(wxCommandEvent& evt);
|
|
|
|
void on_checkbox_retractions(wxCommandEvent& evt);
|
|
|
|
void on_checkbox_unretractions(wxCommandEvent& evt);
|
|
|
|
void on_checkbox_shells(wxCommandEvent& evt);
|
2019-06-22 17:38:14 +02:00
|
|
|
void on_checkbox_legend(wxCommandEvent& evt);
|
2020-04-24 16:12:38 +02:00
|
|
|
#endif // ENABLE_GCODE_VIEWER
|
2018-10-05 23:29:15 +02:00
|
|
|
|
|
|
|
// Create/Update/Reset double slider on 3dPreview
|
|
|
|
void create_double_slider();
|
2020-01-23 12:49:39 +01:00
|
|
|
void check_slider_values(std::vector<CustomGCode::Item> &ticks_from_model,
|
2019-10-10 16:03:58 +02:00
|
|
|
const std::vector<double> &layers_z);
|
2018-10-05 23:29:15 +02:00
|
|
|
void reset_double_slider();
|
2020-01-10 16:49:07 +01:00
|
|
|
void update_double_slider(const std::vector<double>& layers_z, bool keep_z_range = false);
|
|
|
|
void update_double_slider_mode();
|
2018-10-05 23:29:15 +02:00
|
|
|
// update DoubleSlider after keyDown in canvas
|
|
|
|
void update_double_slider_from_canvas(wxKeyEvent& event);
|
2018-11-26 15:16:35 +01:00
|
|
|
|
2019-03-19 10:48:20 +01:00
|
|
|
void load_print_as_fff(bool keep_z_range = false);
|
2018-11-26 15:16:35 +01:00
|
|
|
void load_print_as_sla();
|
2018-11-27 14:50:57 +01:00
|
|
|
|
2019-05-17 15:04:06 +02:00
|
|
|
void on_sliders_scroll_changed(wxCommandEvent& event);
|
2018-09-18 13:35:05 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace GUI
|
|
|
|
} // namespace Slic3r
|
|
|
|
|
|
|
|
#endif // slic3r_GUI_Preview_hpp_
|