PrusaSlicer-NonPlainar/xs/src/slic3r/GUI/GLCanvas3DManager.hpp

198 lines
7.9 KiB
C++
Raw Normal View History

2018-05-09 08:47:04 +00:00
#ifndef slic3r_GLCanvas3DManager_hpp_
#define slic3r_GLCanvas3DManager_hpp_
2018-06-11 13:13:13 +00:00
#include "../../libslic3r/BoundingBox.hpp"
2018-05-09 08:47:04 +00:00
#include <map>
2018-06-11 13:13:13 +00:00
#include <vector>
class wxGLCanvas;
class wxGLContext;
2018-05-09 08:47:04 +00:00
namespace Slic3r {
2018-06-11 13:13:13 +00:00
class DynamicPrintConfig;
class Print;
class Model;
class ExPolygon;
typedef std::vector<ExPolygon> ExPolygons;
class ModelObject;
class PrintObject;
class GCodePreviewData;
2018-05-09 08:47:04 +00:00
namespace GUI {
2018-06-11 13:13:13 +00:00
class GLCanvas3D;
2018-05-09 08:47:04 +00:00
class GLCanvas3DManager
{
2018-06-04 08:14:09 +00:00
struct GLInfo
2018-05-09 08:47:04 +00:00
{
2018-06-04 08:14:09 +00:00
std::string version;
std::string glsl_version;
std::string vendor;
std::string renderer;
GLInfo();
2018-05-09 08:47:04 +00:00
void detect();
2018-06-04 08:14:09 +00:00
bool is_version_greater_or_equal_to(unsigned int major, unsigned int minor) const;
2018-05-09 08:47:04 +00:00
2018-06-04 08:14:09 +00:00
std::string to_string(bool format_as_html, bool extensions) const;
2018-05-09 08:47:04 +00:00
};
typedef std::map<wxGLCanvas*, GLCanvas3D*> CanvasesMap;
CanvasesMap m_canvases;
wxGLCanvas* m_current;
2018-06-04 08:14:09 +00:00
GLInfo m_gl_info;
2018-05-09 08:47:04 +00:00
bool m_gl_initialized;
bool m_use_legacy_opengl;
bool m_use_VBOs;
public:
GLCanvas3DManager();
2018-06-11 13:49:04 +00:00
bool add(wxGLCanvas* canvas);
2018-05-09 08:47:04 +00:00
bool remove(wxGLCanvas* canvas);
void remove_all();
unsigned int count() const;
void init_gl();
2018-06-04 08:14:09 +00:00
std::string get_gl_info(bool format_as_html, bool extensions) const;
2018-05-09 08:47:04 +00:00
bool use_VBOs() const;
bool layer_editing_allowed() const;
bool init(wxGLCanvas* canvas);
2018-05-23 07:57:44 +00:00
void set_as_dirty(wxGLCanvas* canvas);
2018-05-14 12:14:19 +00:00
2018-06-11 11:48:02 +00:00
unsigned int get_volumes_count(wxGLCanvas* canvas) const;
void reset_volumes(wxGLCanvas* canvas);
void deselect_volumes(wxGLCanvas* canvas);
void select_volume(wxGLCanvas* canvas, unsigned int id);
void update_volumes_selection(wxGLCanvas* canvas, const std::vector<int>& selections);
int check_volumes_outside_state(wxGLCanvas* canvas, const DynamicPrintConfig* config) const;
2018-06-11 11:48:02 +00:00
bool move_volume_up(wxGLCanvas* canvas, unsigned int id);
bool move_volume_down(wxGLCanvas* canvas, unsigned int id);
void set_objects_selections(wxGLCanvas* canvas, const std::vector<int>& selections);
2018-05-23 09:14:49 +00:00
void set_config(wxGLCanvas* canvas, DynamicPrintConfig* config);
2018-05-28 13:23:01 +00:00
void set_print(wxGLCanvas* canvas, Print* print);
2018-06-07 09:18:28 +00:00
void set_model(wxGLCanvas* canvas, Model* model);
2018-05-23 09:14:49 +00:00
2018-05-14 12:14:19 +00:00
void set_bed_shape(wxGLCanvas* canvas, const Pointfs& shape);
2018-05-15 13:38:25 +00:00
void set_auto_bed_shape(wxGLCanvas* canvas);
2018-05-14 12:14:19 +00:00
2018-05-15 08:32:38 +00:00
BoundingBoxf3 get_volumes_bounding_box(wxGLCanvas* canvas);
2018-05-18 11:02:47 +00:00
void set_axes_length(wxGLCanvas* canvas, float length);
2018-05-18 09:05:48 +00:00
void set_cutting_plane(wxGLCanvas* canvas, float z, const ExPolygons& polygons);
2018-06-06 10:36:52 +00:00
void set_color_by(wxGLCanvas* canvas, const std::string& value);
void set_select_by(wxGLCanvas* canvas, const std::string& value);
void set_drag_by(wxGLCanvas* canvas, const std::string& value);
2018-09-06 14:10:31 +00:00
std::string get_select_by(wxGLCanvas* canvas) const;
bool is_layers_editing_enabled(wxGLCanvas* canvas) const;
bool is_layers_editing_allowed(wxGLCanvas* canvas) const;
bool is_shader_enabled(wxGLCanvas* canvas) const;
bool is_reload_delayed(wxGLCanvas* canvas) const;
2018-05-25 12:05:08 +00:00
void enable_layers_editing(wxGLCanvas* canvas, bool enable);
2018-05-21 12:40:09 +00:00
void enable_warning_texture(wxGLCanvas* canvas, bool enable);
2018-05-21 12:57:43 +00:00
void enable_legend_texture(wxGLCanvas* canvas, bool enable);
void enable_picking(wxGLCanvas* canvas, bool enable);
void enable_moving(wxGLCanvas* canvas, bool enable);
2018-06-13 07:12:16 +00:00
void enable_gizmos(wxGLCanvas* canvas, bool enable);
2018-07-23 11:49:48 +00:00
void enable_toolbar(wxGLCanvas* canvas, bool enable);
2018-05-23 07:57:44 +00:00
void enable_shader(wxGLCanvas* canvas, bool enable);
2018-06-05 08:56:55 +00:00
void enable_force_zoom_to_bed(wxGLCanvas* canvas, bool enable);
void enable_dynamic_background(wxGLCanvas* canvas, bool enable);
2018-05-23 13:35:11 +00:00
void allow_multisample(wxGLCanvas* canvas, bool allow);
2018-05-21 12:40:09 +00:00
2018-07-23 11:49:48 +00:00
void enable_toolbar_item(wxGLCanvas* canvas, const std::string& name, bool enable);
2018-07-27 10:08:33 +00:00
bool is_toolbar_item_pressed(wxGLCanvas* canvas, const std::string& name) const;
2018-07-23 11:49:48 +00:00
2018-05-15 08:32:38 +00:00
void zoom_to_bed(wxGLCanvas* canvas);
void zoom_to_volumes(wxGLCanvas* canvas);
void select_view(wxGLCanvas* canvas, const std::string& direction);
void set_viewport_from_scene(wxGLCanvas* canvas, wxGLCanvas* other);
2018-05-15 08:32:38 +00:00
void update_volumes_colors_by_extruder(wxGLCanvas* canvas);
2018-06-19 07:46:26 +00:00
void update_gizmos_data(wxGLCanvas* canvas);
void render(wxGLCanvas* canvas) const;
std::vector<double> get_current_print_zs(wxGLCanvas* canvas, bool active_only) const;
void set_toolpaths_range(wxGLCanvas* canvas, double low, double high);
std::vector<int> load_object(wxGLCanvas* canvas, const ModelObject* model_object, int obj_idx, std::vector<int> instance_idxs);
std::vector<int> load_object(wxGLCanvas* canvas, const Model* model, int obj_idx);
2018-09-06 14:10:31 +00:00
int get_first_volume_id(wxGLCanvas* canvas, int obj_idx) const;
2018-09-17 13:12:13 +00:00
int get_in_object_volume_id(wxGLCanvas* canvas, int scene_vol_idx) const;
2018-09-06 14:10:31 +00:00
void reload_scene(wxGLCanvas* canvas, bool force);
2018-06-05 08:56:55 +00:00
void load_gcode_preview(wxGLCanvas* canvas, const GCodePreviewData* preview_data, const std::vector<std::string>& str_tool_colors);
void load_preview(wxGLCanvas* canvas, const std::vector<std::string>& str_tool_colors);
2018-06-05 08:56:55 +00:00
void reset_legend_texture();
void register_on_viewport_changed_callback(wxGLCanvas* canvas, void* callback);
void register_on_double_click_callback(wxGLCanvas* canvas, void* callback);
void register_on_right_click_callback(wxGLCanvas* canvas, void* callback);
void register_on_select_object_callback(wxGLCanvas* canvas, void* callback);
void register_on_model_update_callback(wxGLCanvas* canvas, void* callback);
void register_on_remove_object_callback(wxGLCanvas* canvas, void* callback);
void register_on_arrange_callback(wxGLCanvas* canvas, void* callback);
void register_on_rotate_object_left_callback(wxGLCanvas* canvas, void* callback);
void register_on_rotate_object_right_callback(wxGLCanvas* canvas, void* callback);
void register_on_scale_object_uniformly_callback(wxGLCanvas* canvas, void* callback);
void register_on_increase_objects_callback(wxGLCanvas* canvas, void* callback);
void register_on_decrease_objects_callback(wxGLCanvas* canvas, void* callback);
2018-06-07 09:18:28 +00:00
void register_on_instance_moved_callback(wxGLCanvas* canvas, void* callback);
void register_on_wipe_tower_moved_callback(wxGLCanvas* canvas, void* callback);
void register_on_enable_action_buttons_callback(wxGLCanvas* canvas, void* callback);
2018-06-18 13:07:17 +00:00
void register_on_gizmo_scale_uniformly_callback(wxGLCanvas* canvas, void* callback);
#if ENABLE_MODELINSTANCE_3D_ROTATION
void register_on_gizmo_rotate_3D_callback(wxGLCanvas* canvas, void* callback);
void register_on_gizmo_flatten_3D_callback(wxGLCanvas* canvas, void* callback);
#else
2018-06-19 07:46:26 +00:00
void register_on_gizmo_rotate_callback(wxGLCanvas* canvas, void* callback);
2018-09-10 12:10:08 +00:00
void register_on_gizmo_flatten_callback(wxGLCanvas* canvas, void* callback);
#endif // ENABLE_MODELINSTANCE_3D_ROTATION
void register_on_update_geometry_info_callback(wxGLCanvas* canvas, void* callback);
2018-07-27 10:08:33 +00:00
void register_action_add_callback(wxGLCanvas* canvas, void* callback);
void register_action_delete_callback(wxGLCanvas* canvas, void* callback);
void register_action_deleteall_callback(wxGLCanvas* canvas, void* callback);
void register_action_arrange_callback(wxGLCanvas* canvas, void* callback);
void register_action_more_callback(wxGLCanvas* canvas, void* callback);
void register_action_fewer_callback(wxGLCanvas* canvas, void* callback);
void register_action_split_callback(wxGLCanvas* canvas, void* callback);
void register_action_cut_callback(wxGLCanvas* canvas, void* callback);
void register_action_settings_callback(wxGLCanvas* canvas, void* callback);
void register_action_layersediting_callback(wxGLCanvas* canvas, void* callback);
2018-09-06 14:10:31 +00:00
void register_action_selectbyparts_callback(wxGLCanvas* canvas, void* callback);
2018-07-27 10:08:33 +00:00
2018-05-09 08:47:04 +00:00
private:
CanvasesMap::iterator _get_canvas(wxGLCanvas* canvas);
CanvasesMap::const_iterator _get_canvas(wxGLCanvas* canvas) const;
bool _init(GLCanvas3D& canvas);
2018-05-09 08:47:04 +00:00
};
} // namespace GUI
} // namespace Slic3r
#endif // slic3r_GLCanvas3DManager_hpp_