2018-05-09 08:47:04 +00:00
|
|
|
#ifndef slic3r_GLCanvas3D_hpp_
|
|
|
|
#define slic3r_GLCanvas3D_hpp_
|
|
|
|
|
2018-10-03 09:34:39 +00:00
|
|
|
#include <stddef.h>
|
2019-01-24 10:30:29 +00:00
|
|
|
#include <memory>
|
2018-05-09 08:47:04 +00:00
|
|
|
|
2019-01-24 10:30:29 +00:00
|
|
|
#include "libslic3r/Technologies.hpp"
|
2018-09-17 10:15:11 +00:00
|
|
|
#include "3DScene.hpp"
|
|
|
|
#include "GLToolbar.hpp"
|
2018-10-03 09:34:39 +00:00
|
|
|
#include "Event.hpp"
|
2018-05-09 08:47:04 +00:00
|
|
|
|
2018-11-29 14:10:11 +00:00
|
|
|
#include <float.h>
|
|
|
|
|
2018-10-25 07:35:08 +00:00
|
|
|
#include <wx/timer.h>
|
|
|
|
|
2018-10-01 14:48:08 +00:00
|
|
|
class wxWindow;
|
2018-05-09 08:47:04 +00:00
|
|
|
class wxSizeEvent;
|
2018-05-14 12:47:13 +00:00
|
|
|
class wxIdleEvent;
|
2018-05-15 14:09:04 +00:00
|
|
|
class wxKeyEvent;
|
2018-05-28 13:23:01 +00:00
|
|
|
class wxMouseEvent;
|
2018-05-30 13:18:45 +00:00
|
|
|
class wxTimerEvent;
|
2018-06-04 10:26:39 +00:00
|
|
|
class wxPaintEvent;
|
2018-10-18 13:13:38 +00:00
|
|
|
class wxGLCanvas;
|
2018-05-09 08:47:04 +00:00
|
|
|
|
2019-01-24 10:30:29 +00:00
|
|
|
// Support for Retina OpenGL on Mac OS
|
|
|
|
#define ENABLE_RETINA_GL __APPLE__
|
|
|
|
|
2018-12-17 13:09:35 +00:00
|
|
|
class GLUquadric;
|
|
|
|
typedef class GLUquadric GLUquadricObj;
|
2018-10-03 09:34:39 +00:00
|
|
|
|
2018-05-09 08:47:04 +00:00
|
|
|
namespace Slic3r {
|
2018-05-14 12:14:19 +00:00
|
|
|
|
2018-05-23 07:57:44 +00:00
|
|
|
class GLShader;
|
2018-05-15 13:38:25 +00:00
|
|
|
class ExPolygon;
|
2018-11-22 14:29:59 +00:00
|
|
|
class BackgroundSlicingProcess;
|
2018-12-19 13:47:16 +00:00
|
|
|
class GCodePreviewData;
|
2019-01-21 09:06:51 +00:00
|
|
|
struct SlicingParameters;
|
|
|
|
enum LayerHeightEditActionType : unsigned int;
|
2018-05-14 12:14:19 +00:00
|
|
|
|
2018-05-09 08:47:04 +00:00
|
|
|
namespace GUI {
|
|
|
|
|
2018-06-13 07:12:16 +00:00
|
|
|
class GLGizmoBase;
|
|
|
|
|
2019-01-24 10:30:29 +00:00
|
|
|
#if ENABLE_RETINA_GL
|
|
|
|
class RetinaHelper;
|
|
|
|
#endif
|
|
|
|
|
2018-05-15 13:38:25 +00:00
|
|
|
class GeometryBuffer
|
|
|
|
{
|
2018-06-11 08:46:32 +00:00
|
|
|
std::vector<float> m_vertices;
|
|
|
|
std::vector<float> m_tex_coords;
|
2018-05-15 13:38:25 +00:00
|
|
|
|
|
|
|
public:
|
2018-06-11 08:46:32 +00:00
|
|
|
bool set_from_triangles(const Polygons& triangles, float z, bool generate_tex_coords);
|
2018-05-15 13:38:25 +00:00
|
|
|
bool set_from_lines(const Lines& lines, float z);
|
|
|
|
|
2018-06-11 08:46:32 +00:00
|
|
|
const float* get_vertices() const;
|
|
|
|
const float* get_tex_coords() const;
|
|
|
|
|
|
|
|
unsigned int get_vertices_count() const;
|
2018-05-15 13:38:25 +00:00
|
|
|
};
|
|
|
|
|
2018-05-24 11:46:17 +00:00
|
|
|
class Size
|
|
|
|
{
|
|
|
|
int m_width;
|
|
|
|
int m_height;
|
2019-01-24 10:30:29 +00:00
|
|
|
float m_scale_factor;
|
2018-05-24 11:46:17 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
Size();
|
2019-01-24 10:30:29 +00:00
|
|
|
Size(int width, int height, float scale_factor = 1.0);
|
2018-05-24 11:46:17 +00:00
|
|
|
|
|
|
|
int get_width() const;
|
|
|
|
void set_width(int width);
|
|
|
|
|
|
|
|
int get_height() const;
|
|
|
|
void set_height(int height);
|
2019-01-24 10:30:29 +00:00
|
|
|
|
|
|
|
int get_scale_factor() const;
|
|
|
|
void set_scale_factor(int height);
|
2018-05-24 11:46:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class Rect
|
|
|
|
{
|
|
|
|
float m_left;
|
|
|
|
float m_top;
|
|
|
|
float m_right;
|
|
|
|
float m_bottom;
|
|
|
|
|
|
|
|
public:
|
|
|
|
Rect();
|
|
|
|
Rect(float left, float top, float right, float bottom);
|
|
|
|
|
|
|
|
float get_left() const;
|
|
|
|
void set_left(float left);
|
|
|
|
|
|
|
|
float get_top() const;
|
|
|
|
void set_top(float top);
|
|
|
|
|
|
|
|
float get_right() const;
|
|
|
|
void set_right(float right);
|
|
|
|
|
|
|
|
float get_bottom() const;
|
|
|
|
void set_bottom(float bottom);
|
2019-01-21 16:02:16 +00:00
|
|
|
|
|
|
|
float get_width() const { return m_right - m_left; }
|
|
|
|
float get_height() const { return m_top - m_bottom; }
|
2018-05-24 11:46:17 +00:00
|
|
|
};
|
|
|
|
|
2018-10-16 14:04:19 +00:00
|
|
|
wxDECLARE_EVENT(EVT_GLCANVAS_OBJECT_SELECT, SimpleEvent);
|
2018-10-03 09:34:39 +00:00
|
|
|
|
|
|
|
using Vec2dEvent = Event<Vec2d>;
|
|
|
|
template <size_t N> using Vec2dsEvent = ArrayEvent<Vec2d, N>;
|
|
|
|
|
|
|
|
using Vec3dEvent = Event<Vec3d>;
|
|
|
|
template <size_t N> using Vec3dsEvent = ArrayEvent<Vec3d, N>;
|
|
|
|
|
2018-12-06 09:38:19 +00:00
|
|
|
wxDECLARE_EVENT(EVT_GLCANVAS_INIT, SimpleEvent);
|
2018-10-25 10:10:35 +00:00
|
|
|
wxDECLARE_EVENT(EVT_GLCANVAS_SCHEDULE_BACKGROUND_PROCESS, SimpleEvent);
|
2018-10-03 09:34:39 +00:00
|
|
|
wxDECLARE_EVENT(EVT_GLCANVAS_VIEWPORT_CHANGED, SimpleEvent);
|
|
|
|
wxDECLARE_EVENT(EVT_GLCANVAS_RIGHT_CLICK, Vec2dEvent);
|
|
|
|
wxDECLARE_EVENT(EVT_GLCANVAS_REMOVE_OBJECT, SimpleEvent);
|
|
|
|
wxDECLARE_EVENT(EVT_GLCANVAS_ARRANGE, SimpleEvent);
|
2018-12-19 13:01:13 +00:00
|
|
|
wxDECLARE_EVENT(EVT_GLCANVAS_QUESTION_MARK, SimpleEvent);
|
2018-10-18 13:09:41 +00:00
|
|
|
wxDECLARE_EVENT(EVT_GLCANVAS_INCREASE_INSTANCES, Event<int>); // data: +1 => increase, -1 => decrease
|
2018-10-09 15:14:59 +00:00
|
|
|
wxDECLARE_EVENT(EVT_GLCANVAS_INSTANCE_MOVED, SimpleEvent);
|
2018-10-03 09:34:39 +00:00
|
|
|
wxDECLARE_EVENT(EVT_GLCANVAS_WIPETOWER_MOVED, Vec3dEvent);
|
2019-01-03 10:24:03 +00:00
|
|
|
wxDECLARE_EVENT(EVT_GLCANVAS_INSTANCE_ROTATED, SimpleEvent);
|
|
|
|
wxDECLARE_EVENT(EVT_GLCANVAS_INSTANCE_SCALED, SimpleEvent);
|
2018-10-03 09:34:39 +00:00
|
|
|
wxDECLARE_EVENT(EVT_GLCANVAS_ENABLE_ACTION_BUTTONS, Event<bool>);
|
|
|
|
wxDECLARE_EVENT(EVT_GLCANVAS_UPDATE_GEOMETRY, Vec3dsEvent<2>);
|
2018-11-23 11:47:32 +00:00
|
|
|
wxDECLARE_EVENT(EVT_GLCANVAS_MOUSE_DRAGGING_FINISHED, SimpleEvent);
|
2018-10-03 09:34:39 +00:00
|
|
|
|
2018-05-09 08:47:04 +00:00
|
|
|
class GLCanvas3D
|
|
|
|
{
|
2018-06-05 08:56:55 +00:00
|
|
|
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(); }
|
|
|
|
};
|
|
|
|
|
2018-06-01 13:54:41 +00:00
|
|
|
struct Camera
|
2018-05-09 08:47:04 +00:00
|
|
|
{
|
|
|
|
enum EType : unsigned char
|
|
|
|
{
|
2018-06-01 13:54:41 +00:00
|
|
|
Unknown,
|
2018-06-04 10:26:39 +00:00
|
|
|
// Perspective,
|
2018-06-01 13:54:41 +00:00
|
|
|
Ortho,
|
|
|
|
Num_types
|
2018-05-09 08:47:04 +00:00
|
|
|
};
|
|
|
|
|
2018-06-01 13:54:41 +00:00
|
|
|
EType type;
|
|
|
|
float zoom;
|
|
|
|
float phi;
|
2018-06-04 10:26:39 +00:00
|
|
|
// float distance;
|
2018-06-01 13:54:41 +00:00
|
|
|
|
2018-05-14 10:08:23 +00:00
|
|
|
private:
|
2018-12-07 15:23:04 +00:00
|
|
|
Vec3d m_target;
|
|
|
|
BoundingBoxf3 m_scene_box;
|
2018-05-14 10:08:23 +00:00
|
|
|
float m_theta;
|
2018-05-09 08:47:04 +00:00
|
|
|
|
2018-05-14 10:08:23 +00:00
|
|
|
public:
|
2018-05-09 08:47:04 +00:00
|
|
|
Camera();
|
2018-05-14 09:31:58 +00:00
|
|
|
|
|
|
|
std::string get_type_as_string() const;
|
2018-05-14 10:08:23 +00:00
|
|
|
|
2018-12-07 15:23:04 +00:00
|
|
|
float get_theta() const { return m_theta; }
|
2019-01-25 10:35:28 +00:00
|
|
|
void set_theta(float theta, bool apply_limit);
|
2018-12-07 15:23:04 +00:00
|
|
|
|
|
|
|
const Vec3d& get_target() const { return m_target; }
|
|
|
|
void set_target(const Vec3d& target, GLCanvas3D& canvas);
|
|
|
|
|
|
|
|
const BoundingBoxf3& get_scene_box() const { return m_scene_box; }
|
|
|
|
void set_scene_box(const BoundingBoxf3& box, GLCanvas3D& canvas);
|
2018-05-09 08:47:04 +00:00
|
|
|
};
|
|
|
|
|
2018-05-14 12:14:19 +00:00
|
|
|
class Bed
|
|
|
|
{
|
2018-06-11 08:46:32 +00:00
|
|
|
public:
|
|
|
|
enum EType : unsigned char
|
|
|
|
{
|
|
|
|
MK2,
|
|
|
|
MK3,
|
2018-11-30 14:31:47 +00:00
|
|
|
SL1,
|
2018-06-11 08:46:32 +00:00
|
|
|
Custom,
|
|
|
|
Num_Types
|
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
|
|
|
EType m_type;
|
2018-05-14 12:14:19 +00:00
|
|
|
Pointfs m_shape;
|
|
|
|
BoundingBoxf3 m_bounding_box;
|
2018-05-15 13:38:25 +00:00
|
|
|
Polygon m_polygon;
|
|
|
|
GeometryBuffer m_triangles;
|
|
|
|
GeometryBuffer m_gridlines;
|
2018-06-13 07:12:16 +00:00
|
|
|
mutable GLTexture m_top_texture;
|
|
|
|
mutable GLTexture m_bottom_texture;
|
2019-01-04 11:56:48 +00:00
|
|
|
#if ENABLE_PRINT_BED_MODELS
|
|
|
|
mutable GLBed m_model;
|
|
|
|
#endif // ENABLE_PRINT_BED_MODELS
|
2018-05-14 12:14:19 +00:00
|
|
|
|
2019-01-24 14:44:00 +00:00
|
|
|
mutable float m_scale_factor;
|
|
|
|
|
2018-05-14 12:14:19 +00:00
|
|
|
public:
|
2018-06-11 08:46:32 +00:00
|
|
|
Bed();
|
|
|
|
|
2018-06-11 09:40:11 +00:00
|
|
|
bool is_prusa() const;
|
|
|
|
bool is_custom() const;
|
|
|
|
|
2018-05-14 12:14:19 +00:00
|
|
|
const Pointfs& get_shape() const;
|
2018-08-05 20:52:38 +00:00
|
|
|
// Return true if the bed shape changed, so the calee will update the UI.
|
|
|
|
bool set_shape(const Pointfs& shape);
|
2018-05-14 12:14:19 +00:00
|
|
|
|
|
|
|
const BoundingBoxf3& get_bounding_box() const;
|
2018-05-31 14:04:59 +00:00
|
|
|
bool contains(const Point& point) const;
|
|
|
|
Point point_projection(const Point& point) const;
|
2018-05-14 12:14:19 +00:00
|
|
|
|
2019-01-04 11:56:48 +00:00
|
|
|
#if ENABLE_PRINT_BED_MODELS
|
2019-01-24 14:44:00 +00:00
|
|
|
void render(float theta, bool useVBOs, float scale_factor) const;
|
2019-01-04 11:56:48 +00:00
|
|
|
#else
|
2019-01-24 14:44:00 +00:00
|
|
|
void render(float theta, float scale_factor) const;
|
2019-01-04 11:56:48 +00:00
|
|
|
#endif // ENABLE_PRINT_BED_MODELS
|
2018-05-15 13:38:25 +00:00
|
|
|
|
2018-05-14 12:14:19 +00:00
|
|
|
private:
|
|
|
|
void _calc_bounding_box();
|
2018-05-15 13:38:25 +00:00
|
|
|
void _calc_triangles(const ExPolygon& poly);
|
|
|
|
void _calc_gridlines(const ExPolygon& poly, const BoundingBox& bed_bbox);
|
2018-06-11 08:46:32 +00:00
|
|
|
EType _detect_type() const;
|
2019-01-04 11:56:48 +00:00
|
|
|
#if ENABLE_PRINT_BED_MODELS
|
|
|
|
void _render_prusa(const std::string &key, float theta, bool useVBOs) const;
|
|
|
|
#else
|
2018-11-30 14:31:47 +00:00
|
|
|
void _render_prusa(const std::string &key, float theta) const;
|
2019-01-04 11:56:48 +00:00
|
|
|
#endif // ENABLE_PRINT_BED_MODELS
|
2018-06-11 08:46:32 +00:00
|
|
|
void _render_custom() const;
|
|
|
|
static bool _are_equal(const Pointfs& bed_1, const Pointfs& bed_2);
|
2018-05-14 12:14:19 +00:00
|
|
|
};
|
|
|
|
|
2018-06-01 13:54:41 +00:00
|
|
|
struct Axes
|
2018-05-18 11:02:47 +00:00
|
|
|
{
|
2018-12-17 13:09:35 +00:00
|
|
|
static const double Radius;
|
|
|
|
static const double ArrowBaseRadius;
|
|
|
|
static const double ArrowLength;
|
2018-08-21 15:43:05 +00:00
|
|
|
Vec3d origin;
|
2018-12-17 13:09:35 +00:00
|
|
|
Vec3d length;
|
|
|
|
GLUquadricObj* m_quadric;
|
2018-05-18 11:02:47 +00:00
|
|
|
|
|
|
|
Axes();
|
2018-12-17 13:09:35 +00:00
|
|
|
~Axes();
|
2018-05-18 11:02:47 +00:00
|
|
|
|
2018-12-17 13:09:35 +00:00
|
|
|
void render() const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void render_axis(double length) const;
|
2018-05-18 11:02:47 +00:00
|
|
|
};
|
|
|
|
|
2018-05-25 12:05:08 +00:00
|
|
|
class Shader
|
|
|
|
{
|
|
|
|
GLShader* m_shader;
|
|
|
|
|
|
|
|
public:
|
|
|
|
Shader();
|
|
|
|
~Shader();
|
|
|
|
|
|
|
|
bool init(const std::string& vertex_shader_filename, const std::string& fragment_shader_filename);
|
|
|
|
|
|
|
|
bool is_initialized() const;
|
|
|
|
|
|
|
|
bool start_using() const;
|
|
|
|
void stop_using() const;
|
|
|
|
|
2018-05-25 13:56:14 +00:00
|
|
|
void set_uniform(const std::string& name, float value) const;
|
2018-06-21 06:37:04 +00:00
|
|
|
void set_uniform(const std::string& name, const float* matrix) const;
|
2018-05-25 13:56:14 +00:00
|
|
|
|
2018-05-29 12:34:45 +00:00
|
|
|
const GLShader* get_shader() const;
|
2018-05-25 12:05:08 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
void _reset();
|
|
|
|
};
|
|
|
|
|
2018-05-18 12:08:59 +00:00
|
|
|
class LayersEditing
|
|
|
|
{
|
2018-05-30 13:18:45 +00:00
|
|
|
public:
|
|
|
|
enum EState : unsigned char
|
|
|
|
{
|
|
|
|
Unknown,
|
|
|
|
Editing,
|
|
|
|
Completed,
|
|
|
|
Num_States
|
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
2019-01-24 10:30:29 +00:00
|
|
|
static const float THICKNESS_BAR_WIDTH;
|
|
|
|
static const float THICKNESS_RESET_BUTTON_HEIGHT;
|
|
|
|
|
2019-01-21 09:06:51 +00:00
|
|
|
bool m_use_legacy_opengl;
|
|
|
|
bool m_enabled;
|
|
|
|
Shader m_shader;
|
|
|
|
unsigned int m_z_texture_id;
|
|
|
|
mutable GLTexture m_tooltip_texture;
|
|
|
|
mutable GLTexture m_reset_texture;
|
|
|
|
// Not owned by LayersEditing.
|
|
|
|
const DynamicPrintConfig *m_config;
|
|
|
|
// ModelObject for the currently selected object (Model::objects[last_object_id]).
|
|
|
|
const ModelObject *m_model_object;
|
|
|
|
// Maximum z of the currently selected object (Model::objects[last_object_id]).
|
|
|
|
float m_object_max_z;
|
|
|
|
// Owned by LayersEditing.
|
|
|
|
SlicingParameters *m_slicing_parameters;
|
|
|
|
std::vector<coordf_t> m_layer_height_profile;
|
|
|
|
bool m_layer_height_profile_modified;
|
|
|
|
|
|
|
|
class LayersTexture
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
LayersTexture() : width(0), height(0), levels(0), cells(0), valid(false) {}
|
|
|
|
|
|
|
|
// Texture data
|
|
|
|
std::vector<char> data;
|
|
|
|
// Width of the texture, top level.
|
|
|
|
size_t width;
|
|
|
|
// Height of the texture, top level.
|
|
|
|
size_t height;
|
|
|
|
// For how many levels of detail is the data allocated?
|
|
|
|
size_t levels;
|
|
|
|
// Number of texture cells allocated for the height texture.
|
|
|
|
size_t cells;
|
|
|
|
// Does it need to be refreshed?
|
|
|
|
bool valid;
|
|
|
|
};
|
|
|
|
LayersTexture m_layers_texture;
|
2018-05-18 12:08:59 +00:00
|
|
|
|
|
|
|
public:
|
2018-06-01 13:54:41 +00:00
|
|
|
EState state;
|
|
|
|
float band_width;
|
|
|
|
float strength;
|
|
|
|
int last_object_id;
|
|
|
|
float last_z;
|
2019-01-21 09:06:51 +00:00
|
|
|
LayerHeightEditActionType last_action;
|
2018-06-01 13:54:41 +00:00
|
|
|
|
2018-05-18 12:08:59 +00:00
|
|
|
LayersEditing();
|
2018-05-24 11:46:17 +00:00
|
|
|
~LayersEditing();
|
2018-05-18 12:08:59 +00:00
|
|
|
|
2018-05-25 12:05:08 +00:00
|
|
|
bool init(const std::string& vertex_shader_filename, const std::string& fragment_shader_filename);
|
2019-01-22 11:14:26 +00:00
|
|
|
void set_config(const DynamicPrintConfig* config);
|
2019-01-21 09:06:51 +00:00
|
|
|
void select_object(const Model &model, int object_id);
|
2018-05-25 12:05:08 +00:00
|
|
|
|
|
|
|
bool is_allowed() const;
|
2018-05-25 14:28:24 +00:00
|
|
|
void set_use_legacy_opengl(bool use_legacy_opengl);
|
2018-05-25 12:05:08 +00:00
|
|
|
|
2018-05-18 12:08:59 +00:00
|
|
|
bool is_enabled() const;
|
2018-05-25 12:05:08 +00:00
|
|
|
void set_enabled(bool enabled);
|
|
|
|
|
2019-01-21 09:06:51 +00:00
|
|
|
void render_overlay(const GLCanvas3D& canvas) const;
|
|
|
|
void render_volumes(const GLCanvas3D& canvas, const GLVolumeCollection& volumes) const;
|
2018-05-24 11:46:17 +00:00
|
|
|
|
2019-01-21 09:06:51 +00:00
|
|
|
void adjust_layer_height_profile();
|
|
|
|
void accept_changes(GLCanvas3D& canvas);
|
2019-01-23 13:00:03 +00:00
|
|
|
void reset_layer_height_profile(GLCanvas3D& canvas);
|
2018-05-25 12:05:08 +00:00
|
|
|
|
2018-05-28 12:10:02 +00:00
|
|
|
static float get_cursor_z_relative(const GLCanvas3D& canvas);
|
2018-05-28 12:39:59 +00:00
|
|
|
static bool bar_rect_contains(const GLCanvas3D& canvas, float x, float y);
|
|
|
|
static bool reset_rect_contains(const GLCanvas3D& canvas, float x, float y);
|
2018-05-30 13:18:45 +00:00
|
|
|
static Rect get_bar_rect_screen(const GLCanvas3D& canvas);
|
|
|
|
static Rect get_reset_rect_screen(const GLCanvas3D& canvas);
|
|
|
|
static Rect get_bar_rect_viewport(const GLCanvas3D& canvas);
|
|
|
|
static Rect get_reset_rect_viewport(const GLCanvas3D& canvas);
|
2018-05-28 11:43:29 +00:00
|
|
|
|
2019-01-21 09:06:51 +00:00
|
|
|
float object_max_z() const { return m_object_max_z; }
|
|
|
|
|
2018-05-24 11:46:17 +00:00
|
|
|
private:
|
2018-05-25 12:05:08 +00:00
|
|
|
bool _is_initialized() const;
|
2019-01-22 11:14:26 +00:00
|
|
|
void generate_layer_height_texture();
|
2018-05-24 11:46:17 +00:00
|
|
|
void _render_tooltip_texture(const GLCanvas3D& canvas, const Rect& bar_rect, const Rect& reset_rect) const;
|
2018-06-13 07:12:16 +00:00
|
|
|
void _render_reset_texture(const Rect& reset_rect) const;
|
2019-01-21 09:06:51 +00:00
|
|
|
void _render_active_object_annotations(const GLCanvas3D& canvas, const Rect& bar_rect) const;
|
|
|
|
void _render_profile(const Rect& bar_rect) const;
|
2019-01-21 16:02:16 +00:00
|
|
|
void update_slicing_parameters();
|
2019-01-24 10:30:29 +00:00
|
|
|
|
|
|
|
static float thickness_bar_width(const GLCanvas3D &canvas);
|
|
|
|
static float reset_button_height(const GLCanvas3D &canvas);
|
2018-05-18 12:08:59 +00:00
|
|
|
};
|
|
|
|
|
2018-06-01 13:54:41 +00:00
|
|
|
struct Mouse
|
2018-05-23 11:56:54 +00:00
|
|
|
{
|
2018-06-01 13:54:41 +00:00
|
|
|
struct Drag
|
|
|
|
{
|
|
|
|
static const Point Invalid_2D_Point;
|
2018-08-21 15:43:05 +00:00
|
|
|
static const Vec3d Invalid_3D_Point;
|
2019-01-14 08:29:17 +00:00
|
|
|
#if ENABLE_MOVE_MIN_THRESHOLD
|
|
|
|
static const int MoveThresholdPx;
|
|
|
|
#endif // ENABLE_MOVE_MIN_THRESHOLD
|
2018-05-23 11:56:54 +00:00
|
|
|
|
2018-06-01 13:54:41 +00:00
|
|
|
Point start_position_2D;
|
2018-08-21 15:43:05 +00:00
|
|
|
Vec3d start_position_3D;
|
2018-06-21 06:37:04 +00:00
|
|
|
int move_volume_idx;
|
2019-01-14 08:29:17 +00:00
|
|
|
#if ENABLE_MOVE_MIN_THRESHOLD
|
|
|
|
bool move_requires_threshold;
|
|
|
|
Point move_start_threshold_position_2D;
|
|
|
|
#endif // ENABLE_MOVE_MIN_THRESHOLD
|
2018-05-23 11:56:54 +00:00
|
|
|
|
2018-06-01 13:54:41 +00:00
|
|
|
public:
|
|
|
|
Drag();
|
|
|
|
};
|
2018-05-23 11:56:54 +00:00
|
|
|
|
2018-06-01 13:54:41 +00:00
|
|
|
bool dragging;
|
2018-11-30 11:49:31 +00:00
|
|
|
bool left_down;
|
2018-08-21 19:05:24 +00:00
|
|
|
Vec2d position;
|
2018-11-15 10:38:40 +00:00
|
|
|
Vec3d scene_position;
|
2018-06-01 13:54:41 +00:00
|
|
|
Drag drag;
|
2018-12-06 13:26:13 +00:00
|
|
|
bool ignore_up_event;
|
2018-05-31 11:51:50 +00:00
|
|
|
|
2018-06-01 13:54:41 +00:00
|
|
|
Mouse();
|
2018-05-31 11:51:50 +00:00
|
|
|
|
2019-01-14 08:29:17 +00:00
|
|
|
void set_start_position_2D_as_invalid() { drag.start_position_2D = Drag::Invalid_2D_Point; }
|
|
|
|
void set_start_position_3D_as_invalid() { drag.start_position_3D = Drag::Invalid_3D_Point; }
|
|
|
|
#if ENABLE_MOVE_MIN_THRESHOLD
|
|
|
|
void set_move_start_threshold_position_2D_as_invalid() { drag.move_start_threshold_position_2D = Drag::Invalid_2D_Point; }
|
|
|
|
#endif // ENABLE_MOVE_MIN_THRESHOLD
|
|
|
|
|
|
|
|
bool is_start_position_2D_defined() const { return (drag.start_position_2D != Drag::Invalid_2D_Point); }
|
|
|
|
bool is_start_position_3D_defined() const { return (drag.start_position_3D != Drag::Invalid_3D_Point); }
|
|
|
|
#if ENABLE_MOVE_MIN_THRESHOLD
|
|
|
|
bool is_move_start_threshold_position_2D_defined() const { return (drag.move_start_threshold_position_2D != Drag::Invalid_2D_Point); }
|
|
|
|
bool is_move_threshold_met(const Point& mouse_pos) const {
|
|
|
|
return (std::abs(mouse_pos(0) - drag.move_start_threshold_position_2D(0)) > Drag::MoveThresholdPx)
|
|
|
|
|| (std::abs(mouse_pos(1) - drag.move_start_threshold_position_2D(1)) > Drag::MoveThresholdPx);
|
|
|
|
}
|
|
|
|
#endif // ENABLE_MOVE_MIN_THRESHOLD
|
2018-05-31 11:51:50 +00:00
|
|
|
};
|
|
|
|
|
2018-10-08 12:02:12 +00:00
|
|
|
public:
|
|
|
|
class Selection
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef std::set<unsigned int> IndicesList;
|
|
|
|
|
|
|
|
enum EMode : unsigned char
|
|
|
|
{
|
2018-11-02 11:11:28 +00:00
|
|
|
Volume,
|
|
|
|
Instance
|
2018-10-08 12:02:12 +00:00
|
|
|
};
|
|
|
|
|
2018-10-09 13:56:34 +00:00
|
|
|
enum EType : unsigned char
|
|
|
|
{
|
|
|
|
Invalid,
|
|
|
|
Empty,
|
|
|
|
WipeTower,
|
2018-11-06 14:51:33 +00:00
|
|
|
SingleModifier,
|
|
|
|
MultipleModifier,
|
2018-11-07 09:34:44 +00:00
|
|
|
SingleVolume,
|
|
|
|
MultipleVolume,
|
2018-10-09 13:56:34 +00:00
|
|
|
SingleFullObject,
|
2018-11-08 14:45:55 +00:00
|
|
|
MultipleFullObject,
|
2018-10-09 13:56:34 +00:00
|
|
|
SingleFullInstance,
|
2018-11-07 09:34:44 +00:00
|
|
|
MultipleFullInstance,
|
2018-10-09 13:56:34 +00:00
|
|
|
Mixed
|
|
|
|
};
|
|
|
|
|
2018-10-08 12:02:12 +00:00
|
|
|
private:
|
|
|
|
struct VolumeCache
|
|
|
|
{
|
|
|
|
private:
|
2018-11-02 11:11:28 +00:00
|
|
|
struct TransformCache
|
|
|
|
{
|
|
|
|
Vec3d position;
|
|
|
|
Vec3d rotation;
|
|
|
|
Vec3d scaling_factor;
|
2018-12-10 08:46:01 +00:00
|
|
|
Vec3d mirror;
|
2018-11-02 11:11:28 +00:00
|
|
|
Transform3d rotation_matrix;
|
|
|
|
Transform3d scale_matrix;
|
2018-12-10 08:46:01 +00:00
|
|
|
Transform3d mirror_matrix;
|
2018-11-02 11:11:28 +00:00
|
|
|
|
|
|
|
TransformCache();
|
|
|
|
explicit TransformCache(const Geometry::Transformation& transform);
|
|
|
|
};
|
|
|
|
|
|
|
|
TransformCache m_volume;
|
|
|
|
TransformCache m_instance;
|
2018-10-08 12:02:12 +00:00
|
|
|
|
|
|
|
public:
|
2018-11-02 11:11:28 +00:00
|
|
|
VolumeCache() {}
|
|
|
|
VolumeCache(const Geometry::Transformation& volume_transform, const Geometry::Transformation& instance_transform);
|
|
|
|
|
|
|
|
const Vec3d& get_volume_position() const { return m_volume.position; }
|
|
|
|
const Vec3d& get_volume_rotation() const { return m_volume.rotation; }
|
|
|
|
const Vec3d& get_volume_scaling_factor() const { return m_volume.scaling_factor; }
|
2018-12-10 08:46:01 +00:00
|
|
|
const Vec3d& get_volume_mirror() const { return m_volume.mirror; }
|
2018-11-02 11:11:28 +00:00
|
|
|
const Transform3d& get_volume_rotation_matrix() const { return m_volume.rotation_matrix; }
|
|
|
|
const Transform3d& get_volume_scale_matrix() const { return m_volume.scale_matrix; }
|
2018-12-10 08:46:01 +00:00
|
|
|
const Transform3d& get_volume_mirror_matrix() const { return m_volume.mirror_matrix; }
|
2018-11-02 11:11:28 +00:00
|
|
|
|
|
|
|
const Vec3d& get_instance_position() const { return m_instance.position; }
|
|
|
|
const Vec3d& get_instance_rotation() const { return m_instance.rotation; }
|
|
|
|
const Vec3d& get_instance_scaling_factor() const { return m_instance.scaling_factor; }
|
2018-12-10 08:46:01 +00:00
|
|
|
const Vec3d& get_instance_mirror() const { return m_instance.mirror; }
|
2018-11-02 11:11:28 +00:00
|
|
|
const Transform3d& get_instance_rotation_matrix() const { return m_instance.rotation_matrix; }
|
|
|
|
const Transform3d& get_instance_scale_matrix() const { return m_instance.scale_matrix; }
|
2018-12-10 08:46:01 +00:00
|
|
|
const Transform3d& get_instance_mirror_matrix() const { return m_instance.mirror_matrix; }
|
2018-10-08 12:02:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::map<unsigned int, VolumeCache> VolumesCache;
|
2018-10-09 13:56:34 +00:00
|
|
|
typedef std::set<int> InstanceIdxsList;
|
|
|
|
typedef std::map<int, InstanceIdxsList> ObjectIdxsToInstanceIdxsMap;
|
2018-10-08 12:02:12 +00:00
|
|
|
|
|
|
|
struct Cache
|
|
|
|
{
|
2018-11-13 16:45:44 +00:00
|
|
|
// Cache of GLVolume derived transformation matrices, valid during mouse dragging.
|
2018-10-08 12:02:12 +00:00
|
|
|
VolumesCache volumes_data;
|
2018-11-13 16:45:44 +00:00
|
|
|
// Center of the dragged selection, valid during mouse dragging.
|
2018-10-08 12:02:12 +00:00
|
|
|
Vec3d dragging_center;
|
2018-11-13 16:45:44 +00:00
|
|
|
// Map from indices of ModelObject instances in Model::objects
|
|
|
|
// to a set of indices of ModelVolume instances in ModelObject::instances
|
|
|
|
// Here the index means a position inside the respective std::vector, not ModelID.
|
2018-10-09 13:56:34 +00:00
|
|
|
ObjectIdxsToInstanceIdxsMap content;
|
2018-10-08 12:02:12 +00:00
|
|
|
};
|
|
|
|
|
2018-11-13 16:45:44 +00:00
|
|
|
// Volumes owned by GLCanvas3D.
|
2018-10-08 12:02:12 +00:00
|
|
|
GLVolumePtrs* m_volumes;
|
2018-11-13 16:45:44 +00:00
|
|
|
// Model, not owned.
|
2018-10-08 12:02:12 +00:00
|
|
|
Model* m_model;
|
|
|
|
|
|
|
|
bool m_valid;
|
|
|
|
EMode m_mode;
|
2018-10-09 13:56:34 +00:00
|
|
|
EType m_type;
|
2018-11-13 16:45:44 +00:00
|
|
|
// set of indices to m_volumes
|
2018-10-08 12:02:12 +00:00
|
|
|
IndicesList m_list;
|
|
|
|
Cache m_cache;
|
|
|
|
mutable BoundingBoxf3 m_bounding_box;
|
|
|
|
mutable bool m_bounding_box_dirty;
|
|
|
|
|
2018-12-18 11:35:49 +00:00
|
|
|
#if ENABLE_RENDER_SELECTION_CENTER
|
|
|
|
GLUquadricObj* m_quadric;
|
|
|
|
#endif // ENABLE_RENDER_SELECTION_CENTER
|
2018-12-19 13:44:37 +00:00
|
|
|
mutable GLArrow m_arrow;
|
2018-12-20 10:14:53 +00:00
|
|
|
mutable GLCurvedArrow m_curved_arrow;
|
2018-12-18 11:35:49 +00:00
|
|
|
|
2019-01-24 14:44:00 +00:00
|
|
|
mutable float m_scale_factor;
|
|
|
|
|
2018-10-08 12:02:12 +00:00
|
|
|
public:
|
|
|
|
Selection();
|
2018-12-18 11:35:49 +00:00
|
|
|
#if ENABLE_RENDER_SELECTION_CENTER
|
|
|
|
~Selection();
|
|
|
|
#endif // ENABLE_RENDER_SELECTION_CENTER
|
2018-10-08 12:02:12 +00:00
|
|
|
|
|
|
|
void set_volumes(GLVolumePtrs* volumes);
|
2018-12-19 13:44:37 +00:00
|
|
|
bool init(bool useVBOs);
|
2018-10-18 13:13:38 +00:00
|
|
|
|
|
|
|
Model* get_model() const { return m_model; }
|
2018-10-08 12:02:12 +00:00
|
|
|
void set_model(Model* model);
|
|
|
|
|
|
|
|
EMode get_mode() const { return m_mode; }
|
|
|
|
void set_mode(EMode mode) { m_mode = mode; }
|
|
|
|
|
|
|
|
void add(unsigned int volume_idx, bool as_single_selection = true);
|
|
|
|
void remove(unsigned int volume_idx);
|
2018-10-11 06:26:12 +00:00
|
|
|
|
|
|
|
void add_object(unsigned int object_idx, bool as_single_selection = true);
|
|
|
|
void remove_object(unsigned int object_idx);
|
|
|
|
|
|
|
|
void add_instance(unsigned int object_idx, unsigned int instance_idx, bool as_single_selection = true);
|
|
|
|
void remove_instance(unsigned int object_idx, unsigned int instance_idx);
|
|
|
|
|
2018-11-07 09:34:44 +00:00
|
|
|
void add_volume(unsigned int object_idx, unsigned int volume_idx, int instance_idx, bool as_single_selection = true);
|
2018-10-11 06:26:12 +00:00
|
|
|
void remove_volume(unsigned int object_idx, unsigned int volume_idx);
|
|
|
|
|
2018-11-21 14:28:35 +00:00
|
|
|
void add_all();
|
|
|
|
|
2018-11-16 17:28:50 +00:00
|
|
|
// Update the selection based on the map from old indices to new indices after m_volumes changed.
|
|
|
|
// If the current selection is by instance, this call may select newly added volumes, if they belong to already selected instances.
|
|
|
|
void volumes_changed(const std::vector<size_t> &map_volume_old_to_new);
|
2018-10-08 12:02:12 +00:00
|
|
|
void clear();
|
|
|
|
|
2018-10-09 13:56:34 +00:00
|
|
|
bool is_empty() const { return m_type == Empty; }
|
|
|
|
bool is_wipe_tower() const { return m_type == WipeTower; }
|
2018-11-06 14:51:33 +00:00
|
|
|
bool is_modifier() const { return (m_type == SingleModifier) || (m_type == MultipleModifier); }
|
2018-11-12 07:54:22 +00:00
|
|
|
bool is_single_modifier() const { return m_type == SingleModifier; }
|
2018-12-18 13:08:46 +00:00
|
|
|
bool is_multiple_modifier() const { return m_type == MultipleModifier; }
|
2018-10-09 13:56:34 +00:00
|
|
|
bool is_single_full_instance() const;
|
2018-11-08 11:23:07 +00:00
|
|
|
bool is_multiple_full_instance() const { return m_type == MultipleFullInstance; }
|
2018-10-09 13:56:34 +00:00
|
|
|
bool is_single_full_object() const { return m_type == SingleFullObject; }
|
2018-11-08 14:45:55 +00:00
|
|
|
bool is_multiple_full_object() const { return m_type == MultipleFullObject; }
|
2018-11-08 11:23:07 +00:00
|
|
|
bool is_single_volume() const { return m_type == SingleVolume; }
|
|
|
|
bool is_multiple_volume() const { return m_type == MultipleVolume; }
|
2018-10-10 11:51:11 +00:00
|
|
|
bool is_mixed() const { return m_type == Mixed; }
|
2018-10-09 13:56:34 +00:00
|
|
|
bool is_from_single_instance() const { return get_instance_idx() != -1; }
|
2018-11-23 10:47:18 +00:00
|
|
|
bool is_from_single_object() const;
|
2018-10-09 13:56:34 +00:00
|
|
|
|
2018-10-22 06:54:04 +00:00
|
|
|
bool contains_volume(unsigned int volume_idx) const { return std::find(m_list.begin(), m_list.end(), volume_idx) != m_list.end(); }
|
2018-12-18 13:08:46 +00:00
|
|
|
bool requires_uniform_scale() const;
|
2018-10-22 06:54:04 +00:00
|
|
|
|
2018-10-09 13:56:34 +00:00
|
|
|
// Returns the the object id if the selection is from a single object, otherwise is -1
|
|
|
|
int get_object_idx() const;
|
|
|
|
// Returns the instance id if the selection is from a single object and from a single instance, otherwise is -1
|
|
|
|
int get_instance_idx() const;
|
2018-11-03 07:46:51 +00:00
|
|
|
// Returns the indices of selected instances.
|
|
|
|
// Can only be called if selection is from a single object.
|
2018-11-02 14:20:26 +00:00
|
|
|
const InstanceIdxsList& get_instance_idxs() const;
|
2018-10-08 12:02:12 +00:00
|
|
|
|
|
|
|
const IndicesList& get_volume_idxs() const { return m_list; }
|
|
|
|
const GLVolume* get_volume(unsigned int volume_idx) const;
|
|
|
|
|
2018-11-30 10:21:25 +00:00
|
|
|
const ObjectIdxsToInstanceIdxsMap& get_content() const { return m_cache.content; }
|
|
|
|
|
2018-10-08 12:02:12 +00:00
|
|
|
unsigned int volumes_count() const { return (unsigned int)m_list.size(); }
|
|
|
|
const BoundingBoxf3& get_bounding_box() const;
|
|
|
|
|
|
|
|
void start_dragging();
|
|
|
|
|
2018-12-19 14:03:49 +00:00
|
|
|
void translate(const Vec3d& displacement, bool local = false);
|
2018-11-20 10:57:01 +00:00
|
|
|
void rotate(const Vec3d& rotation, bool local);
|
2018-11-02 14:20:26 +00:00
|
|
|
void flattening_rotate(const Vec3d& normal);
|
2018-11-20 14:39:36 +00:00
|
|
|
void scale(const Vec3d& scale, bool local);
|
2018-10-18 13:50:51 +00:00
|
|
|
void mirror(Axis axis);
|
2018-10-08 12:02:12 +00:00
|
|
|
|
2018-10-30 15:03:03 +00:00
|
|
|
void translate(unsigned int object_idx, const Vec3d& displacement);
|
|
|
|
void translate(unsigned int object_idx, unsigned int instance_idx, const Vec3d& displacement);
|
|
|
|
|
2018-11-14 07:53:56 +00:00
|
|
|
void erase();
|
|
|
|
|
2019-01-24 14:44:00 +00:00
|
|
|
void render(float scale_factor = 1.0) const;
|
2018-12-18 11:35:49 +00:00
|
|
|
#if ENABLE_RENDER_SELECTION_CENTER
|
|
|
|
void render_center() const;
|
|
|
|
#endif // ENABLE_RENDER_SELECTION_CENTER
|
2018-12-19 13:44:37 +00:00
|
|
|
void render_sidebar_hints(const std::string& sidebar_field) const;
|
2018-10-08 12:02:12 +00:00
|
|
|
|
2018-12-19 14:03:49 +00:00
|
|
|
bool requires_local_axes() const;
|
|
|
|
|
2018-10-08 12:02:12 +00:00
|
|
|
private:
|
2018-10-11 06:26:12 +00:00
|
|
|
void _update_valid();
|
|
|
|
void _update_type();
|
|
|
|
void _set_caches();
|
|
|
|
void _add_volume(unsigned int volume_idx);
|
|
|
|
void _add_instance(unsigned int object_idx, unsigned int instance_idx);
|
|
|
|
void _add_object(unsigned int object_idx);
|
|
|
|
void _remove_volume(unsigned int volume_idx);
|
|
|
|
void _remove_instance(unsigned int object_idx, unsigned int instance_idx);
|
|
|
|
void _remove_object(unsigned int object_idx);
|
|
|
|
void _calc_bounding_box() const;
|
|
|
|
void _render_selected_volumes() const;
|
2018-11-07 11:11:34 +00:00
|
|
|
void _render_synchronized_volumes() const;
|
2018-10-11 06:26:12 +00:00
|
|
|
void _render_bounding_box(const BoundingBoxf3& box, float* color) const;
|
2018-12-19 13:44:37 +00:00
|
|
|
void _render_sidebar_position_hints(const std::string& sidebar_field) const;
|
|
|
|
void _render_sidebar_rotation_hints(const std::string& sidebar_field) const;
|
|
|
|
void _render_sidebar_scale_hints(const std::string& sidebar_field) const;
|
|
|
|
void _render_sidebar_size_hints(const std::string& sidebar_field) const;
|
|
|
|
void _render_sidebar_position_hint(Axis axis) const;
|
2018-12-20 10:14:53 +00:00
|
|
|
void _render_sidebar_rotation_hint(Axis axis) const;
|
2018-12-19 13:44:37 +00:00
|
|
|
void _render_sidebar_scale_hint(Axis axis) const;
|
|
|
|
void _render_sidebar_size_hint(Axis axis, double length) const;
|
2019-01-28 07:52:22 +00:00
|
|
|
enum SyncRotationType {
|
|
|
|
// Do not synchronize rotation. Either not rotating at all, or rotating by world Z axis.
|
|
|
|
SYNC_ROTATION_NONE = 0,
|
|
|
|
// Synchronize fully. Used from "place on bed" feature.
|
|
|
|
SYNC_ROTATION_FULL = 1,
|
|
|
|
// Synchronize after rotation by an axis not parallel with Z.
|
|
|
|
SYNC_ROTATION_GENERAL = 2,
|
|
|
|
};
|
|
|
|
void _synchronize_unselected_instances(SyncRotationType sync_rotation_type);
|
2018-11-06 14:51:33 +00:00
|
|
|
void _synchronize_unselected_volumes();
|
2018-11-16 10:30:36 +00:00
|
|
|
void _ensure_on_bed();
|
2018-10-08 12:02:12 +00:00
|
|
|
};
|
|
|
|
|
2018-11-27 13:50:57 +00:00
|
|
|
class ClippingPlane
|
|
|
|
{
|
|
|
|
double m_data[4];
|
|
|
|
|
|
|
|
public:
|
|
|
|
ClippingPlane()
|
|
|
|
{
|
|
|
|
m_data[0] = 0.0;
|
|
|
|
m_data[1] = 0.0;
|
|
|
|
m_data[2] = 1.0;
|
|
|
|
m_data[3] = 0.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
ClippingPlane(const Vec3d& direction, double offset)
|
|
|
|
{
|
|
|
|
Vec3d norm_dir = direction.normalized();
|
|
|
|
m_data[0] = norm_dir(0);
|
|
|
|
m_data[1] = norm_dir(1);
|
|
|
|
m_data[2] = norm_dir(2);
|
|
|
|
m_data[3] = offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
const double* get_data() const { return m_data; }
|
|
|
|
};
|
|
|
|
|
2018-10-08 12:02:12 +00:00
|
|
|
private:
|
2018-06-13 07:12:16 +00:00
|
|
|
class Gizmos
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum EType : unsigned char
|
|
|
|
{
|
2018-06-13 07:26:58 +00:00
|
|
|
Undefined,
|
2018-09-11 07:00:28 +00:00
|
|
|
Move,
|
2018-06-13 07:12:16 +00:00
|
|
|
Scale,
|
|
|
|
Rotate,
|
2018-08-09 14:55:43 +00:00
|
|
|
Flatten,
|
2018-10-18 13:13:38 +00:00
|
|
|
Cut,
|
2018-11-19 13:46:37 +00:00
|
|
|
SlaSupports,
|
2018-06-13 07:12:16 +00:00
|
|
|
Num_Types
|
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool m_enabled;
|
|
|
|
typedef std::map<EType, GLGizmoBase*> GizmosMap;
|
|
|
|
GizmosMap m_gizmos;
|
2018-12-17 12:20:57 +00:00
|
|
|
BackgroundTexture m_background_texture;
|
2018-06-13 07:12:16 +00:00
|
|
|
EType m_current;
|
|
|
|
|
2019-01-24 10:30:29 +00:00
|
|
|
float m_overlay_icons_scale;
|
|
|
|
float m_overlay_border;
|
|
|
|
float m_overlay_gap_y;
|
|
|
|
|
2018-06-13 07:12:16 +00:00
|
|
|
public:
|
|
|
|
Gizmos();
|
|
|
|
~Gizmos();
|
|
|
|
|
2018-08-24 12:11:41 +00:00
|
|
|
bool init(GLCanvas3D& parent);
|
2018-06-13 07:12:16 +00:00
|
|
|
|
|
|
|
bool is_enabled() const;
|
|
|
|
void set_enabled(bool enable);
|
|
|
|
|
2019-01-24 10:30:29 +00:00
|
|
|
void set_overlay_scale(float scale);
|
|
|
|
|
2018-10-25 07:35:08 +00:00
|
|
|
std::string update_hover_state(const GLCanvas3D& canvas, const Vec2d& mouse_pos, const Selection& selection);
|
2018-10-08 12:02:12 +00:00
|
|
|
void update_on_off_state(const GLCanvas3D& canvas, const Vec2d& mouse_pos, const Selection& selection);
|
2018-10-16 12:56:35 +00:00
|
|
|
void update_on_off_state(const Selection& selection);
|
2018-06-13 11:14:17 +00:00
|
|
|
void reset_all_states();
|
|
|
|
|
2018-06-14 13:32:26 +00:00
|
|
|
void set_hover_id(int id);
|
2018-10-09 13:56:34 +00:00
|
|
|
void enable_grabber(EType type, unsigned int id, bool enable);
|
2018-06-14 13:32:26 +00:00
|
|
|
|
2018-08-21 19:05:24 +00:00
|
|
|
bool overlay_contains_mouse(const GLCanvas3D& canvas, const Vec2d& mouse_pos) const;
|
2018-06-15 12:10:28 +00:00
|
|
|
bool grabber_contains_mouse() const;
|
2019-01-10 12:13:11 +00:00
|
|
|
void update(const Linef3& mouse_ray, const Selection& selection, bool shift_down, const Point* mouse_pos = nullptr);
|
2018-09-19 12:59:57 +00:00
|
|
|
Rect get_reset_rect_viewport(const GLCanvas3D& canvas) const;
|
2018-06-19 07:46:26 +00:00
|
|
|
EType get_current_type() const;
|
2018-06-15 12:10:28 +00:00
|
|
|
|
2018-06-18 13:07:17 +00:00
|
|
|
bool is_running() const;
|
2018-11-22 09:14:31 +00:00
|
|
|
bool handle_shortcut(int key, const Selection& selection);
|
2018-06-19 07:46:26 +00:00
|
|
|
|
2018-06-15 12:10:28 +00:00
|
|
|
bool is_dragging() const;
|
2018-10-15 09:30:50 +00:00
|
|
|
void start_dragging(const Selection& selection);
|
2018-06-15 12:10:28 +00:00
|
|
|
void stop_dragging();
|
2018-06-13 08:49:59 +00:00
|
|
|
|
2018-10-08 12:02:12 +00:00
|
|
|
Vec3d get_displacement() const;
|
2018-09-11 07:00:28 +00:00
|
|
|
|
2018-09-24 13:54:09 +00:00
|
|
|
Vec3d get_scale() const;
|
|
|
|
void set_scale(const Vec3d& scale);
|
2018-06-19 07:46:26 +00:00
|
|
|
|
2018-09-20 13:00:40 +00:00
|
|
|
Vec3d get_rotation() const;
|
|
|
|
void set_rotation(const Vec3d& rotation);
|
2018-09-25 08:42:11 +00:00
|
|
|
|
2018-11-02 14:20:26 +00:00
|
|
|
Vec3d get_flattening_normal() const;
|
2018-09-25 08:42:11 +00:00
|
|
|
|
2018-09-20 13:00:40 +00:00
|
|
|
void set_flattening_data(const ModelObject* model_object);
|
2018-12-03 13:02:58 +00:00
|
|
|
|
|
|
|
#if ENABLE_SLA_SUPPORT_GIZMO_MOD
|
|
|
|
void set_sla_support_data(ModelObject* model_object, const GLCanvas3D::Selection& selection);
|
|
|
|
#else
|
2018-09-24 11:39:44 +00:00
|
|
|
void set_model_object_ptr(ModelObject* model_object);
|
2018-12-03 13:02:58 +00:00
|
|
|
#endif // ENABLE_SLA_SUPPORT_GIZMO_MOD
|
2018-09-19 12:59:57 +00:00
|
|
|
void clicked_on_object(const Vec2d& mouse_position);
|
|
|
|
void delete_current_grabber(bool delete_all = false);
|
2018-09-12 10:14:20 +00:00
|
|
|
|
2018-10-15 09:30:50 +00:00
|
|
|
void render_current_gizmo(const Selection& selection) const;
|
|
|
|
void render_current_gizmo_for_picking_pass(const Selection& selection) const;
|
|
|
|
|
2018-11-26 09:56:07 +00:00
|
|
|
void render_overlay(const GLCanvas3D& canvas, const Selection& selection) const;
|
2018-06-13 07:12:16 +00:00
|
|
|
|
2018-11-27 11:18:43 +00:00
|
|
|
#if !ENABLE_IMGUI
|
2018-10-18 13:13:38 +00:00
|
|
|
void create_external_gizmo_widgets(wxWindow *parent);
|
2018-11-26 09:56:07 +00:00
|
|
|
#endif // not ENABLE_IMGUI
|
2018-10-18 13:13:38 +00:00
|
|
|
|
2018-06-13 07:12:16 +00:00
|
|
|
private:
|
|
|
|
void _reset();
|
|
|
|
|
2018-11-26 09:56:07 +00:00
|
|
|
void _render_overlay(const GLCanvas3D& canvas, const Selection& selection) const;
|
2018-10-15 09:30:50 +00:00
|
|
|
void _render_current_gizmo(const Selection& selection) const;
|
2018-06-13 08:49:59 +00:00
|
|
|
|
|
|
|
float _get_total_overlay_height() const;
|
2018-12-17 12:20:57 +00:00
|
|
|
float _get_total_overlay_width() const;
|
2019-01-02 15:26:22 +00:00
|
|
|
|
2018-06-15 12:10:28 +00:00
|
|
|
GLGizmoBase* _get_current() const;
|
2018-06-13 07:12:16 +00:00
|
|
|
};
|
|
|
|
|
2018-11-29 10:11:39 +00:00
|
|
|
struct SlaCap
|
|
|
|
{
|
2018-12-10 11:59:49 +00:00
|
|
|
struct Triangles
|
|
|
|
{
|
|
|
|
Pointf3s object;
|
2019-01-24 18:08:58 +00:00
|
|
|
Pointf3s supports;
|
2018-12-10 11:59:49 +00:00
|
|
|
};
|
|
|
|
typedef std::map<unsigned int, Triangles> ObjectIdToTrianglesMap;
|
2018-11-29 10:11:39 +00:00
|
|
|
double z;
|
2018-12-10 11:59:49 +00:00
|
|
|
ObjectIdToTrianglesMap triangles;
|
2018-11-29 10:11:39 +00:00
|
|
|
|
|
|
|
SlaCap() { reset(); }
|
|
|
|
void reset() { z = DBL_MAX; triangles.clear(); }
|
|
|
|
bool matches(double z) const { return this->z == z; }
|
|
|
|
};
|
|
|
|
|
2018-07-19 11:18:19 +00:00
|
|
|
class WarningTexture : public GUI::GLTexture
|
|
|
|
{
|
|
|
|
static const unsigned char Background_Color[3];
|
|
|
|
static const unsigned char Opacity;
|
|
|
|
|
2018-07-31 12:20:16 +00:00
|
|
|
int m_original_width;
|
|
|
|
int m_original_height;
|
|
|
|
|
2018-07-19 11:18:19 +00:00
|
|
|
public:
|
2018-07-31 12:20:16 +00:00
|
|
|
WarningTexture();
|
|
|
|
|
2019-01-24 10:30:29 +00:00
|
|
|
bool generate(const std::string& msg, const GLCanvas3D& canvas);
|
2018-07-31 12:20:16 +00:00
|
|
|
|
|
|
|
void render(const GLCanvas3D& canvas) const;
|
2018-07-19 11:18:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
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];
|
2018-12-13 10:13:58 +00:00
|
|
|
static const unsigned char Default_Background_Color[3];
|
|
|
|
static const unsigned char Error_Background_Color[3];
|
2018-07-19 11:18:19 +00:00
|
|
|
static const unsigned char Opacity;
|
|
|
|
|
2018-07-31 12:32:59 +00:00
|
|
|
int m_original_width;
|
|
|
|
int m_original_height;
|
|
|
|
|
2018-07-19 11:18:19 +00:00
|
|
|
public:
|
2018-07-31 12:32:59 +00:00
|
|
|
LegendTexture();
|
2019-01-29 14:11:29 +00:00
|
|
|
void fill_color_print_legend_values(const GCodePreviewData& preview_data, const GLCanvas3D& canvas,
|
|
|
|
std::vector<std::pair<double, double>>& cp_legend_values);
|
2018-07-31 12:32:59 +00:00
|
|
|
|
2018-12-13 10:13:58 +00:00
|
|
|
bool generate(const GCodePreviewData& preview_data, const std::vector<float>& tool_colors, const GLCanvas3D& canvas, bool use_error_colors);
|
2018-07-31 12:32:59 +00:00
|
|
|
|
|
|
|
void render(const GLCanvas3D& canvas) const;
|
2018-07-19 11:18:19 +00:00
|
|
|
};
|
|
|
|
|
2018-05-09 08:47:04 +00:00
|
|
|
wxGLCanvas* m_canvas;
|
|
|
|
wxGLContext* m_context;
|
2019-01-24 10:30:29 +00:00
|
|
|
#if ENABLE_RETINA_GL
|
|
|
|
std::unique_ptr<RetinaHelper> m_retina_helper;
|
|
|
|
#endif
|
2018-11-27 15:55:54 +00:00
|
|
|
bool m_in_render;
|
2018-07-19 11:18:19 +00:00
|
|
|
LegendTexture m_legend_texture;
|
|
|
|
WarningTexture m_warning_texture;
|
2018-10-25 07:35:08 +00:00
|
|
|
wxTimer m_timer;
|
2018-05-09 08:47:04 +00:00
|
|
|
Camera m_camera;
|
2018-05-14 12:14:19 +00:00
|
|
|
Bed m_bed;
|
2018-05-18 11:02:47 +00:00
|
|
|
Axes m_axes;
|
2018-05-18 12:08:59 +00:00
|
|
|
LayersEditing m_layers_editing;
|
2018-05-23 07:57:44 +00:00
|
|
|
Shader m_shader;
|
2018-05-23 11:56:54 +00:00
|
|
|
Mouse m_mouse;
|
2018-06-13 08:49:59 +00:00
|
|
|
mutable Gizmos m_gizmos;
|
2018-07-23 11:49:48 +00:00
|
|
|
mutable GLToolbar m_toolbar;
|
2018-12-17 09:55:14 +00:00
|
|
|
GLToolbar* m_view_toolbar;
|
2018-11-27 13:50:57 +00:00
|
|
|
ClippingPlane m_clipping_planes[2];
|
|
|
|
bool m_use_clipping_planes;
|
2018-11-29 10:11:39 +00:00
|
|
|
mutable SlaCap m_sla_caps[2];
|
2018-12-18 09:40:53 +00:00
|
|
|
std::string m_sidebar_field;
|
2018-05-14 12:14:19 +00:00
|
|
|
|
2018-06-11 13:13:13 +00:00
|
|
|
mutable GLVolumeCollection m_volumes;
|
2018-10-08 12:02:12 +00:00
|
|
|
Selection m_selection;
|
2019-01-21 09:06:51 +00:00
|
|
|
const DynamicPrintConfig* m_config;
|
2018-06-07 09:18:28 +00:00
|
|
|
Model* m_model;
|
2018-11-22 14:29:59 +00:00
|
|
|
BackgroundSlicingProcess *m_process;
|
2018-05-09 08:47:04 +00:00
|
|
|
|
2018-11-16 17:28:50 +00:00
|
|
|
// Screen is only refreshed from the OnIdle handler if it is dirty.
|
2018-05-09 08:47:04 +00:00
|
|
|
bool m_dirty;
|
2018-06-05 10:24:26 +00:00
|
|
|
bool m_initialized;
|
2018-06-04 10:26:39 +00:00
|
|
|
bool m_use_VBOs;
|
2019-01-17 12:21:33 +00:00
|
|
|
#if ENABLE_REWORKED_BED_SHAPE_CHANGE
|
|
|
|
bool m_requires_zoom_to_bed;
|
|
|
|
#else
|
2018-06-05 08:56:55 +00:00
|
|
|
bool m_force_zoom_to_bed_enabled;
|
2019-01-17 12:21:33 +00:00
|
|
|
#endif // ENABLE_REWORKED_BED_SHAPE_CHANGE
|
2018-05-14 12:14:19 +00:00
|
|
|
bool m_apply_zoom_to_volumes_filter;
|
2018-05-29 11:54:34 +00:00
|
|
|
mutable int m_hover_volume_id;
|
2018-07-27 10:08:33 +00:00
|
|
|
bool m_toolbar_action_running;
|
2018-05-21 12:40:09 +00:00
|
|
|
bool m_warning_texture_enabled;
|
2018-05-21 12:57:43 +00:00
|
|
|
bool m_legend_texture_enabled;
|
2018-05-22 07:02:42 +00:00
|
|
|
bool m_picking_enabled;
|
2018-05-31 11:51:50 +00:00
|
|
|
bool m_moving_enabled;
|
2018-07-27 07:38:39 +00:00
|
|
|
bool m_dynamic_background_enabled;
|
2018-05-23 13:35:11 +00:00
|
|
|
bool m_multisample_allowed;
|
2018-10-08 12:02:12 +00:00
|
|
|
bool m_regenerate_volumes;
|
2018-11-26 09:41:16 +00:00
|
|
|
bool m_moving;
|
2018-05-09 08:47:04 +00:00
|
|
|
|
2018-06-06 08:16:58 +00:00
|
|
|
std::string m_color_by;
|
|
|
|
|
2018-06-08 07:40:00 +00:00
|
|
|
bool m_reload_delayed;
|
|
|
|
|
2018-06-05 08:56:55 +00:00
|
|
|
GCodePreviewVolumeIndex m_gcode_preview_volume_index;
|
|
|
|
|
2018-11-27 11:18:43 +00:00
|
|
|
#if !ENABLE_IMGUI
|
2018-10-18 13:13:38 +00:00
|
|
|
wxWindow *m_external_gizmo_widgets_parent;
|
2018-11-26 09:56:07 +00:00
|
|
|
#endif // not ENABLE_IMGUI
|
2018-10-18 13:13:38 +00:00
|
|
|
|
2018-05-09 08:47:04 +00:00
|
|
|
public:
|
2018-06-27 09:31:11 +00:00
|
|
|
GLCanvas3D(wxGLCanvas* canvas);
|
2018-05-15 07:50:01 +00:00
|
|
|
~GLCanvas3D();
|
2018-05-09 08:47:04 +00:00
|
|
|
|
2018-10-04 08:41:11 +00:00
|
|
|
void set_context(wxGLContext* context) { m_context = context; }
|
|
|
|
|
|
|
|
wxGLCanvas* get_wxglcanvas() { return m_canvas; }
|
2018-09-17 10:15:11 +00:00
|
|
|
|
2018-12-17 09:55:14 +00:00
|
|
|
void set_view_toolbar(GLToolbar* toolbar) { m_view_toolbar = toolbar; }
|
2018-12-06 09:38:19 +00:00
|
|
|
|
2018-05-25 12:05:08 +00:00
|
|
|
bool init(bool useVBOs, bool use_legacy_opengl);
|
2018-11-26 09:49:25 +00:00
|
|
|
void post_event(wxEvent &&event);
|
2018-05-23 07:57:44 +00:00
|
|
|
|
2018-06-22 14:06:37 +00:00
|
|
|
void set_as_dirty();
|
2018-05-14 12:14:19 +00:00
|
|
|
|
2018-06-11 11:48:02 +00:00
|
|
|
unsigned int get_volumes_count() const;
|
2018-05-18 12:08:59 +00:00
|
|
|
void reset_volumes();
|
2018-12-04 12:55:25 +00:00
|
|
|
int check_volumes_outside_state() const;
|
2018-06-08 07:40:00 +00:00
|
|
|
|
2019-01-21 09:06:51 +00:00
|
|
|
void set_config(const DynamicPrintConfig* config);
|
2018-11-22 14:29:59 +00:00
|
|
|
void set_process(BackgroundSlicingProcess* process);
|
2018-06-07 09:18:28 +00:00
|
|
|
void set_model(Model* model);
|
2018-05-23 09:14:49 +00:00
|
|
|
|
2018-10-08 12:02:12 +00:00
|
|
|
const Selection& get_selection() const { return m_selection; }
|
2018-10-10 14:22:20 +00:00
|
|
|
Selection& get_selection() { return m_selection; }
|
2018-10-08 12:02:12 +00:00
|
|
|
|
2018-05-15 13:38:25 +00:00
|
|
|
// Set the bed shape to a single closed 2D polygon(array of two element arrays),
|
|
|
|
// triangulate the bed and store the triangles into m_bed.m_triangles,
|
|
|
|
// fills the m_bed.m_grid_lines and sets m_bed.m_origin.
|
|
|
|
// Sets m_bed.m_polygon to limit the object placement.
|
2018-05-14 12:14:19 +00:00
|
|
|
void set_bed_shape(const Pointfs& shape);
|
2018-12-17 13:09:35 +00:00
|
|
|
void set_bed_axes_length(double length);
|
2018-05-15 09:07:32 +00:00
|
|
|
|
2018-11-27 13:50:57 +00:00
|
|
|
void set_clipping_plane(unsigned int id, const ClippingPlane& plane)
|
|
|
|
{
|
|
|
|
if (id < 2)
|
2018-11-29 10:11:39 +00:00
|
|
|
{
|
2018-11-27 13:50:57 +00:00
|
|
|
m_clipping_planes[id] = plane;
|
2018-11-29 10:11:39 +00:00
|
|
|
m_sla_caps[id].reset();
|
|
|
|
}
|
2018-11-27 13:50:57 +00:00
|
|
|
}
|
|
|
|
void set_use_clipping_planes(bool use) { m_use_clipping_planes = use; }
|
|
|
|
|
2018-06-06 10:36:52 +00:00
|
|
|
void set_color_by(const std::string& value);
|
2018-09-06 14:10:31 +00:00
|
|
|
|
2018-05-09 08:47:04 +00:00
|
|
|
float get_camera_zoom() const;
|
|
|
|
|
2018-05-14 12:14:19 +00:00
|
|
|
BoundingBoxf3 volumes_bounding_box() const;
|
2018-12-07 15:23:04 +00:00
|
|
|
BoundingBoxf3 scene_bounding_box() const;
|
2018-05-14 12:14:19 +00:00
|
|
|
|
2018-05-18 12:08:59 +00:00
|
|
|
bool is_layers_editing_enabled() const;
|
2018-05-25 14:28:24 +00:00
|
|
|
bool is_layers_editing_allowed() const;
|
2018-05-18 12:08:59 +00:00
|
|
|
|
2018-06-08 07:40:00 +00:00
|
|
|
bool is_reload_delayed() const;
|
|
|
|
|
2018-05-25 12:05:08 +00:00
|
|
|
void enable_layers_editing(bool enable);
|
2018-05-21 12:40:09 +00:00
|
|
|
void enable_warning_texture(bool enable);
|
2018-05-21 12:57:43 +00:00
|
|
|
void enable_legend_texture(bool enable);
|
2018-05-22 07:02:42 +00:00
|
|
|
void enable_picking(bool enable);
|
2018-05-31 11:51:50 +00:00
|
|
|
void enable_moving(bool enable);
|
2018-06-13 07:12:16 +00:00
|
|
|
void enable_gizmos(bool enable);
|
2018-07-23 11:49:48 +00:00
|
|
|
void enable_toolbar(bool enable);
|
2019-01-17 12:21:33 +00:00
|
|
|
#if !ENABLE_REWORKED_BED_SHAPE_CHANGE
|
2018-06-05 08:56:55 +00:00
|
|
|
void enable_force_zoom_to_bed(bool enable);
|
2019-01-17 12:21:33 +00:00
|
|
|
#endif // !ENABLE_REWORKED_BED_SHAPE_CHANGE
|
2018-07-27 07:38:39 +00:00
|
|
|
void enable_dynamic_background(bool enable);
|
2018-05-23 13:35:11 +00:00
|
|
|
void allow_multisample(bool allow);
|
2018-05-21 12:40:09 +00:00
|
|
|
|
2018-07-23 11:49:48 +00:00
|
|
|
void enable_toolbar_item(const std::string& name, bool enable);
|
2018-07-27 10:08:33 +00:00
|
|
|
bool is_toolbar_item_pressed(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();
|
|
|
|
void zoom_to_volumes();
|
2018-10-26 07:50:28 +00:00
|
|
|
void zoom_to_selection();
|
2018-05-15 09:30:11 +00:00
|
|
|
void select_view(const std::string& direction);
|
2018-05-29 13:36:09 +00:00
|
|
|
void set_viewport_from_scene(const GLCanvas3D& other);
|
2018-05-15 08:32:38 +00:00
|
|
|
|
2018-05-29 13:07:06 +00:00
|
|
|
void update_volumes_colors_by_extruder();
|
2018-11-01 14:08:39 +00:00
|
|
|
|
2018-11-27 11:18:43 +00:00
|
|
|
#if !ENABLE_IMGUI
|
2018-09-19 12:59:57 +00:00
|
|
|
Rect get_gizmo_reset_rect(const GLCanvas3D& canvas, bool viewport) const;
|
|
|
|
bool gizmo_reset_rect_contains(const GLCanvas3D& canvas, float x, float y) const;
|
2018-11-26 14:54:12 +00:00
|
|
|
#endif // not ENABLE_IMGUI
|
|
|
|
|
2018-11-26 09:41:16 +00:00
|
|
|
bool is_dragging() const { return m_gizmos.is_dragging() || m_moving; }
|
2018-05-29 13:07:06 +00:00
|
|
|
|
2018-06-04 10:26:39 +00:00
|
|
|
void render();
|
2018-05-15 13:38:25 +00:00
|
|
|
|
2018-11-21 14:28:35 +00:00
|
|
|
void select_all();
|
2018-11-14 07:53:56 +00:00
|
|
|
void delete_selected();
|
2018-11-21 11:27:20 +00:00
|
|
|
void ensure_on_bed(unsigned int object_idx);
|
2018-11-14 07:53:56 +00:00
|
|
|
|
2018-06-04 13:42:34 +00:00
|
|
|
std::vector<double> get_current_print_zs(bool active_only) const;
|
|
|
|
void set_toolpaths_range(double low, double high);
|
|
|
|
|
2018-06-06 08:16:58 +00:00
|
|
|
std::vector<int> load_object(const ModelObject& model_object, int obj_idx, std::vector<int> instance_idxs);
|
2018-06-07 07:22:19 +00:00
|
|
|
std::vector<int> load_object(const Model& model, int obj_idx);
|
2018-06-06 08:16:58 +00:00
|
|
|
|
2018-10-18 13:50:51 +00:00
|
|
|
void mirror_selection(Axis axis);
|
|
|
|
|
2018-11-23 11:47:32 +00:00
|
|
|
void reload_scene(bool refresh_immediately, bool force_full_scene_refresh = false);
|
2018-06-08 07:40:00 +00:00
|
|
|
|
2018-06-05 08:56:55 +00:00
|
|
|
void load_gcode_preview(const GCodePreviewData& preview_data, const std::vector<std::string>& str_tool_colors);
|
2018-11-26 14:16:35 +00:00
|
|
|
void load_sla_preview();
|
2019-01-29 14:11:29 +00:00
|
|
|
void load_preview(const std::vector<std::string>& str_tool_colors, const std::vector<double>& color_print_values);
|
2018-06-06 12:19:28 +00:00
|
|
|
void bind_event_handlers();
|
|
|
|
void unbind_event_handlers();
|
|
|
|
|
2018-05-14 12:47:13 +00:00
|
|
|
void on_size(wxSizeEvent& evt);
|
|
|
|
void on_idle(wxIdleEvent& evt);
|
2018-05-15 14:09:04 +00:00
|
|
|
void on_char(wxKeyEvent& evt);
|
2018-05-28 13:23:01 +00:00
|
|
|
void on_mouse_wheel(wxMouseEvent& evt);
|
2018-05-30 13:18:45 +00:00
|
|
|
void on_timer(wxTimerEvent& evt);
|
2018-05-31 11:51:50 +00:00
|
|
|
void on_mouse(wxMouseEvent& evt);
|
2018-06-04 10:26:39 +00:00
|
|
|
void on_paint(wxPaintEvent& evt);
|
2018-06-07 07:22:19 +00:00
|
|
|
void on_key_down(wxKeyEvent& evt);
|
2018-05-14 12:47:13 +00:00
|
|
|
|
2018-05-24 11:46:17 +00:00
|
|
|
Size get_canvas_size() const;
|
2018-05-25 13:56:14 +00:00
|
|
|
Point get_local_mouse_position() const;
|
2018-05-24 11:46:17 +00:00
|
|
|
|
2018-07-19 11:18:19 +00:00
|
|
|
void reset_legend_texture();
|
|
|
|
|
2018-10-25 07:35:08 +00:00
|
|
|
void set_tooltip(const std::string& tooltip) const;
|
2018-07-25 08:01:17 +00:00
|
|
|
|
2018-11-27 11:18:43 +00:00
|
|
|
#if !ENABLE_IMGUI
|
2018-10-18 13:13:38 +00:00
|
|
|
void set_external_gizmo_widgets_parent(wxWindow *parent);
|
2018-11-26 09:56:07 +00:00
|
|
|
#endif // not ENABLE_IMGUI
|
2018-10-18 13:13:38 +00:00
|
|
|
|
2018-11-21 09:36:09 +00:00
|
|
|
void do_move();
|
|
|
|
void do_rotate();
|
|
|
|
void do_scale();
|
|
|
|
void do_flatten();
|
|
|
|
void do_mirror();
|
|
|
|
|
2018-11-29 08:03:38 +00:00
|
|
|
void set_camera_zoom(float zoom);
|
|
|
|
|
2018-12-03 12:29:07 +00:00
|
|
|
void update_gizmos_on_off_state();
|
|
|
|
|
2018-12-07 15:23:04 +00:00
|
|
|
void viewport_changed();
|
|
|
|
|
2018-12-18 09:40:53 +00:00
|
|
|
void handle_sidebar_focus_event(const std::string& opt_key, bool focus_on);
|
2018-12-11 12:57:50 +00:00
|
|
|
|
2019-01-24 12:16:46 +00:00
|
|
|
void update_ui_from_settings();
|
|
|
|
|
2018-05-14 12:14:19 +00:00
|
|
|
private:
|
2018-06-12 07:18:25 +00:00
|
|
|
bool _is_shown_on_screen() const;
|
2019-01-17 12:21:33 +00:00
|
|
|
#if !ENABLE_REWORKED_BED_SHAPE_CHANGE
|
2018-06-05 08:56:55 +00:00
|
|
|
void _force_zoom_to_bed();
|
2019-01-17 12:21:33 +00:00
|
|
|
#endif // !ENABLE_REWORKED_BED_SHAPE_CHANGE
|
2018-06-04 10:26:39 +00:00
|
|
|
|
2018-07-23 11:49:48 +00:00
|
|
|
bool _init_toolbar();
|
|
|
|
|
2018-10-04 08:41:11 +00:00
|
|
|
bool _set_current();
|
2018-06-01 13:54:41 +00:00
|
|
|
void _resize(unsigned int w, unsigned int h);
|
|
|
|
|
|
|
|
BoundingBoxf3 _max_bounding_box() const;
|
|
|
|
|
2018-05-14 12:14:19 +00:00
|
|
|
void _zoom_to_bounding_box(const BoundingBoxf3& bbox);
|
2018-05-15 07:50:01 +00:00
|
|
|
float _get_zoom_to_bounding_box_factor(const BoundingBoxf3& bbox) const;
|
|
|
|
|
2018-05-28 13:23:01 +00:00
|
|
|
void _refresh_if_shown_on_screen();
|
2018-05-29 11:54:34 +00:00
|
|
|
|
2018-05-31 06:44:39 +00:00
|
|
|
void _camera_tranform() const;
|
2018-05-29 11:54:34 +00:00
|
|
|
void _picking_pass() const;
|
|
|
|
void _render_background() const;
|
2018-06-11 08:46:32 +00:00
|
|
|
void _render_bed(float theta) const;
|
2018-12-17 13:09:35 +00:00
|
|
|
void _render_axes() const;
|
2018-06-04 10:26:39 +00:00
|
|
|
void _render_objects() const;
|
2018-10-08 12:02:12 +00:00
|
|
|
void _render_selection() const;
|
2018-12-18 11:35:49 +00:00
|
|
|
#if ENABLE_RENDER_SELECTION_CENTER
|
|
|
|
void _render_selection_center() const;
|
|
|
|
#endif // ENABLE_RENDER_SELECTION_CENTER
|
2018-05-29 11:54:34 +00:00
|
|
|
void _render_warning_texture() const;
|
|
|
|
void _render_legend_texture() const;
|
2018-06-01 13:54:41 +00:00
|
|
|
void _render_volumes(bool fake_colors) const;
|
2018-08-21 12:27:36 +00:00
|
|
|
void _render_current_gizmo() const;
|
|
|
|
void _render_gizmos_overlay() const;
|
2018-07-23 11:49:48 +00:00
|
|
|
void _render_toolbar() const;
|
2018-12-06 09:38:19 +00:00
|
|
|
void _render_view_toolbar() const;
|
2018-10-26 07:50:28 +00:00
|
|
|
#if ENABLE_SHOW_CAMERA_TARGET
|
|
|
|
void _render_camera_target() const;
|
|
|
|
#endif // ENABLE_SHOW_CAMERA_TARGET
|
2018-11-28 14:13:25 +00:00
|
|
|
void _render_sla_slices() const;
|
2018-12-19 13:44:37 +00:00
|
|
|
void _render_selection_sidebar_hints() const;
|
2018-05-30 13:18:45 +00:00
|
|
|
|
2018-10-08 12:02:12 +00:00
|
|
|
void _update_volumes_hover_state() const;
|
2018-11-01 14:08:39 +00:00
|
|
|
void _update_gizmos_data();
|
2018-05-30 13:18:45 +00:00
|
|
|
|
|
|
|
void _perform_layer_editing_action(wxMouseEvent* evt = nullptr);
|
2018-05-31 11:51:50 +00:00
|
|
|
|
|
|
|
// Convert the screen space coordinate to an object space coordinate.
|
|
|
|
// If the Z screen space coordinate is not provided, a depth buffer value is substituted.
|
2018-08-21 15:43:05 +00:00
|
|
|
Vec3d _mouse_to_3d(const Point& mouse_pos, float* z = nullptr);
|
2018-06-01 13:54:41 +00:00
|
|
|
|
2018-06-15 12:10:28 +00:00
|
|
|
// Convert the screen space coordinate to world coordinate on the bed.
|
2018-08-21 15:43:05 +00:00
|
|
|
Vec3d _mouse_to_bed_3d(const Point& mouse_pos);
|
2018-06-15 12:10:28 +00:00
|
|
|
|
2018-08-20 08:23:17 +00:00
|
|
|
// Returns the view ray line, in world coordinate, at the given mouse position.
|
|
|
|
Linef3 mouse_ray(const Point& mouse_pos);
|
|
|
|
|
2018-06-01 13:54:41 +00:00
|
|
|
void _start_timer();
|
|
|
|
void _stop_timer();
|
2018-06-05 08:56:55 +00:00
|
|
|
|
2018-07-24 11:39:17 +00:00
|
|
|
// Create 3D thick extrusion lines for a skirt and brim.
|
|
|
|
// Adds a new Slic3r::GUI::3DScene::Volume to volumes.
|
|
|
|
void _load_print_toolpaths();
|
|
|
|
// Create 3D thick extrusion lines for object forming extrusions.
|
|
|
|
// Adds a new Slic3r::GUI::3DScene::Volume to $self->volumes,
|
|
|
|
// one for perimeters, one for infill and one for supports.
|
2019-01-29 14:11:29 +00:00
|
|
|
void _load_print_object_toolpaths(const PrintObject& print_object, const std::vector<std::string>& str_tool_colors,
|
|
|
|
const std::vector<double>& color_print_values);
|
2018-07-24 11:39:17 +00:00
|
|
|
// Create 3D thick extrusion lines for wipe tower extrusions
|
|
|
|
void _load_wipe_tower_toolpaths(const std::vector<std::string>& str_tool_colors);
|
2018-06-13 11:14:17 +00:00
|
|
|
|
2018-06-05 08:56:55 +00:00
|
|
|
// 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);
|
|
|
|
bool _travel_paths_by_type(const GCodePreviewData& preview_data);
|
|
|
|
bool _travel_paths_by_feedrate(const GCodePreviewData& preview_data);
|
|
|
|
bool _travel_paths_by_tool(const GCodePreviewData& preview_data, const std::vector<float>& tool_colors);
|
|
|
|
// generates gcode retractions geometry
|
|
|
|
void _load_gcode_retractions(const GCodePreviewData& preview_data);
|
|
|
|
// generates gcode unretractions geometry
|
|
|
|
void _load_gcode_unretractions(const GCodePreviewData& preview_data);
|
|
|
|
// generates objects and wipe tower geometry
|
2018-11-26 14:16:35 +00:00
|
|
|
void _load_shells_fff();
|
2018-11-28 14:13:25 +00:00
|
|
|
// generates objects geometry for sla
|
2018-11-26 14:16:35 +00:00
|
|
|
void _load_shells_sla();
|
2018-06-05 08:56:55 +00:00
|
|
|
// sets gcode geometry visibility according to user selection
|
|
|
|
void _update_gcode_volumes_visibility(const GCodePreviewData& preview_data);
|
2018-07-24 11:39:17 +00:00
|
|
|
void _update_toolpath_volumes_outside_state();
|
|
|
|
void _show_warning_texture_if_needed();
|
2018-11-21 09:36:09 +00:00
|
|
|
|
2018-07-19 11:18:19 +00:00
|
|
|
// 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);
|
|
|
|
|
|
|
|
// generates a warning texture containing the given message
|
|
|
|
void _generate_warning_texture(const std::string& msg);
|
|
|
|
void _reset_warning_texture();
|
|
|
|
|
2018-07-27 07:38:39 +00:00
|
|
|
bool _is_any_volume_outside() const;
|
|
|
|
|
2018-12-06 09:38:19 +00:00
|
|
|
void _resize_toolbars() const;
|
2018-07-31 10:25:00 +00:00
|
|
|
|
2018-06-05 12:09:36 +00:00
|
|
|
static std::vector<float> _parse_colors(const std::vector<std::string>& colors);
|
2018-11-22 14:29:59 +00:00
|
|
|
|
2018-12-21 11:35:20 +00:00
|
|
|
public:
|
2018-11-22 14:29:59 +00:00
|
|
|
const Print* fff_print() const;
|
|
|
|
const SLAPrint* sla_print() const;
|
2018-05-09 08:47:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace GUI
|
|
|
|
} // namespace Slic3r
|
|
|
|
|
|
|
|
#endif // slic3r_GLCanvas3D_hpp_
|