2018-05-09 08:47:04 +00:00
|
|
|
#ifndef slic3r_GLCanvas3DManager_hpp_
|
|
|
|
#define slic3r_GLCanvas3DManager_hpp_
|
|
|
|
|
2018-05-18 09:05:48 +00:00
|
|
|
#include "../../slic3r/GUI/GLCanvas3D.hpp"
|
2018-05-09 08:47:04 +00:00
|
|
|
|
|
|
|
#include <map>
|
|
|
|
|
|
|
|
namespace Slic3r {
|
|
|
|
namespace GUI {
|
|
|
|
|
|
|
|
class GLCanvas3DManager
|
|
|
|
{
|
|
|
|
struct GLVersion
|
|
|
|
{
|
|
|
|
unsigned int vn_major;
|
|
|
|
unsigned int vn_minor;
|
|
|
|
|
|
|
|
GLVersion();
|
|
|
|
bool detect();
|
|
|
|
|
|
|
|
bool is_greater_or_equal_to(unsigned int major, unsigned int minor) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct LayerEditing
|
|
|
|
{
|
|
|
|
bool allowed;
|
|
|
|
|
|
|
|
LayerEditing();
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::map<wxGLCanvas*, GLCanvas3D*> CanvasesMap;
|
|
|
|
|
|
|
|
CanvasesMap m_canvases;
|
|
|
|
GLVersion m_gl_version;
|
|
|
|
LayerEditing m_layer_editing;
|
|
|
|
bool m_gl_initialized;
|
|
|
|
bool m_use_legacy_opengl;
|
|
|
|
bool m_use_VBOs;
|
|
|
|
|
|
|
|
public:
|
|
|
|
GLCanvas3DManager();
|
|
|
|
|
|
|
|
bool add(wxGLCanvas* canvas, wxGLContext* context);
|
|
|
|
bool remove(wxGLCanvas* canvas);
|
|
|
|
|
|
|
|
void remove_all();
|
|
|
|
|
|
|
|
unsigned int count() const;
|
|
|
|
|
|
|
|
void init_gl();
|
|
|
|
|
|
|
|
bool use_VBOs() const;
|
|
|
|
bool layer_editing_allowed() const;
|
|
|
|
|
2018-05-23 07:57:44 +00:00
|
|
|
bool init(wxGLCanvas* canvas, bool useVBOs);
|
|
|
|
|
2018-05-15 13:38:25 +00:00
|
|
|
bool is_dirty(wxGLCanvas* canvas) const;
|
|
|
|
void set_dirty(wxGLCanvas* canvas, bool dirty);
|
|
|
|
|
2018-05-14 12:14:19 +00:00
|
|
|
bool is_shown_on_screen(wxGLCanvas* canvas) const;
|
|
|
|
|
|
|
|
void resize(wxGLCanvas* canvas, unsigned int w, unsigned int h);
|
|
|
|
|
|
|
|
GLVolumeCollection* get_volumes(wxGLCanvas* canvas);
|
|
|
|
void set_volumes(wxGLCanvas* canvas, GLVolumeCollection* volumes);
|
2018-05-18 12:08:59 +00:00
|
|
|
void reset_volumes(wxGLCanvas* canvas);
|
|
|
|
|
2018-05-23 09:14:49 +00:00
|
|
|
DynamicPrintConfig* get_config(wxGLCanvas* canvas);
|
|
|
|
void set_config(wxGLCanvas* canvas, DynamicPrintConfig* config);
|
|
|
|
|
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_bed_bounding_box(wxGLCanvas* canvas);
|
|
|
|
BoundingBoxf3 get_volumes_bounding_box(wxGLCanvas* canvas);
|
2018-05-14 12:14:19 +00:00
|
|
|
BoundingBoxf3 get_max_bounding_box(wxGLCanvas* canvas);
|
|
|
|
|
2018-05-18 11:02:47 +00:00
|
|
|
Pointf3 get_axes_origin(wxGLCanvas* canvas) const;
|
|
|
|
void set_axes_origin(wxGLCanvas* canvas, const Pointf3& origin);
|
|
|
|
|
|
|
|
float get_axes_length(wxGLCanvas* canvas) const;
|
|
|
|
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-05-09 08:47:04 +00:00
|
|
|
unsigned int get_camera_type(wxGLCanvas* canvas) const;
|
|
|
|
void set_camera_type(wxGLCanvas* canvas, unsigned int type);
|
2018-05-14 09:31:58 +00:00
|
|
|
std::string get_camera_type_as_string(wxGLCanvas* canvas) const;
|
|
|
|
|
2018-05-09 08:47:04 +00:00
|
|
|
float get_camera_zoom(wxGLCanvas* canvas) const;
|
|
|
|
void set_camera_zoom(wxGLCanvas* canvas, float zoom);
|
|
|
|
|
|
|
|
float get_camera_phi(wxGLCanvas* canvas) const;
|
|
|
|
void set_camera_phi(wxGLCanvas* canvas, float phi);
|
|
|
|
|
|
|
|
float get_camera_theta(wxGLCanvas* canvas) const;
|
|
|
|
void set_camera_theta(wxGLCanvas* canvas, float theta);
|
|
|
|
|
|
|
|
float get_camera_distance(wxGLCanvas* canvas) const;
|
|
|
|
void set_camera_distance(wxGLCanvas* canvas, float distance);
|
|
|
|
|
|
|
|
Pointf3 get_camera_target(wxGLCanvas* canvas) const;
|
2018-05-23 11:56:54 +00:00
|
|
|
void set_camera_target(wxGLCanvas* canvas, const Pointf3& target);
|
2018-05-09 08:47:04 +00:00
|
|
|
|
2018-05-18 12:08:59 +00:00
|
|
|
bool is_layers_editing_enabled(wxGLCanvas* canvas) const;
|
2018-05-22 07:02:42 +00:00
|
|
|
bool is_picking_enabled(wxGLCanvas* canvas) const;
|
2018-05-23 07:57:44 +00:00
|
|
|
bool is_shader_enabled(wxGLCanvas* canvas) const;
|
2018-05-23 13:35:11 +00:00
|
|
|
bool is_multisample_allowed(wxGLCanvas* canvas) const;
|
2018-05-18 12:08:59 +00:00
|
|
|
|
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);
|
2018-05-22 07:02:42 +00:00
|
|
|
void enable_picking(wxGLCanvas* canvas, bool enable);
|
2018-05-23 07:57:44 +00:00
|
|
|
void enable_shader(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-05-23 11:56:54 +00:00
|
|
|
bool is_mouse_dragging(wxGLCanvas* canvas) const;
|
|
|
|
void set_mouse_dragging(wxGLCanvas* canvas, bool dragging);
|
|
|
|
|
|
|
|
Pointf get_mouse_position(wxGLCanvas* canvas) const;
|
|
|
|
void set_mouse_position(wxGLCanvas* canvas, const Pointf& position);
|
|
|
|
|
2018-05-23 13:35:11 +00:00
|
|
|
int get_hover_volume_id(wxGLCanvas* canvas) const;
|
|
|
|
void set_hover_volume_id(wxGLCanvas* canvas, int id);
|
|
|
|
|
2018-05-15 08:32:38 +00:00
|
|
|
void zoom_to_bed(wxGLCanvas* canvas);
|
|
|
|
void zoom_to_volumes(wxGLCanvas* canvas);
|
2018-05-15 09:30:11 +00:00
|
|
|
void select_view(wxGLCanvas* canvas, const std::string& direction);
|
2018-05-15 08:32:38 +00:00
|
|
|
|
2018-05-23 07:57:44 +00:00
|
|
|
bool start_using_shader(wxGLCanvas* canvas) const;
|
|
|
|
void stop_using_shader(wxGLCanvas* canvas) const;
|
|
|
|
|
2018-05-23 13:35:11 +00:00
|
|
|
void picking_pass(wxGLCanvas* canvas);
|
|
|
|
|
2018-05-21 13:57:03 +00:00
|
|
|
void render_background(wxGLCanvas* canvas) const;
|
|
|
|
void render_bed(wxGLCanvas* canvas) const;
|
|
|
|
void render_axes(wxGLCanvas* canvas) const;
|
|
|
|
void render_volumes(wxGLCanvas* canvas, bool fake_colors) const;
|
2018-05-23 09:14:49 +00:00
|
|
|
void render_objects(wxGLCanvas* canvas, bool useVBOs);
|
2018-05-21 13:57:03 +00:00
|
|
|
void render_cutting_plane(wxGLCanvas* canvas) const;
|
|
|
|
void render_warning_texture(wxGLCanvas* canvas) const;
|
|
|
|
void render_legend_texture(wxGLCanvas* canvas) const;
|
2018-05-24 11:46:17 +00:00
|
|
|
void render_layer_editing_textures(wxGLCanvas* canvas) const;
|
2018-05-21 13:57:03 +00:00
|
|
|
|
|
|
|
void render_texture(wxGLCanvas* canvas, unsigned int tex_id, float left, float right, float bottom, float top) const;
|
2018-05-15 13:38:25 +00:00
|
|
|
|
2018-05-15 07:50:01 +00:00
|
|
|
void register_on_viewport_changed_callback(wxGLCanvas* canvas, void* callback);
|
2018-05-23 11:56:54 +00:00
|
|
|
void register_on_mark_volumes_for_layer_height_callback(wxGLCanvas* canvas, void* callback);
|
2018-05-15 07:50:01 +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;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace GUI
|
|
|
|
} // namespace Slic3r
|
|
|
|
|
|
|
|
#endif // slic3r_GLCanvas3DManager_hpp_
|