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>
|
2020-03-17 13:35:56 +00:00
|
|
|
#include <chrono>
|
2018-05-09 08:47:04 +00:00
|
|
|
|
2018-09-17 10:15:11 +00:00
|
|
|
#include "GLToolbar.hpp"
|
2018-10-03 09:34:39 +00:00
|
|
|
#include "Event.hpp"
|
2019-03-19 12:30:21 +00:00
|
|
|
#include "Selection.hpp"
|
2019-03-20 12:51:25 +00:00
|
|
|
#include "Gizmos/GLGizmosManager.hpp"
|
2019-06-26 11:30:20 +00:00
|
|
|
#include "GUI_ObjectLayers.hpp"
|
2020-02-28 13:29:53 +00:00
|
|
|
#include "GLSelectionRectangle.hpp"
|
2019-09-13 09:30:50 +00:00
|
|
|
#include "MeshUtils.hpp"
|
2020-03-02 14:13:23 +00:00
|
|
|
#include "libslic3r/GCode/GCodeProcessor.hpp"
|
2020-04-14 08:02:08 +00:00
|
|
|
#include "GCodeViewer.hpp"
|
2018-05-09 08:47:04 +00:00
|
|
|
|
2020-05-23 22:01:34 +00:00
|
|
|
#include "libslic3r/Slicing.hpp"
|
|
|
|
|
2018-11-29 14:10:11 +00:00
|
|
|
#include <float.h>
|
|
|
|
|
2018-10-25 07:35:08 +00:00
|
|
|
#include <wx/timer.h>
|
|
|
|
|
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;
|
2020-03-02 09:58:46 +00:00
|
|
|
class wxGLContext;
|
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-05-09 08:47:04 +00:00
|
|
|
namespace Slic3r {
|
2018-05-14 12:14:19 +00:00
|
|
|
|
2020-02-28 13:29:53 +00:00
|
|
|
struct Camera;
|
2018-11-22 14:29:59 +00:00
|
|
|
class BackgroundSlicingProcess;
|
2019-10-24 10:09:09 +00:00
|
|
|
struct ThumbnailData;
|
2020-05-23 22:01:34 +00:00
|
|
|
class ModelObject;
|
|
|
|
class ModelInstance;
|
|
|
|
class PrintObject;
|
2020-05-26 09:48:09 +00:00
|
|
|
class Print;
|
|
|
|
class SLAPrint;
|
|
|
|
namespace CustomGCode { struct Item; }
|
2018-05-14 12:14:19 +00:00
|
|
|
|
2018-05-09 08:47:04 +00:00
|
|
|
namespace GUI {
|
|
|
|
|
2019-01-24 10:30:29 +00:00
|
|
|
#if ENABLE_RETINA_GL
|
|
|
|
class RetinaHelper;
|
|
|
|
#endif
|
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2019-04-08 08:50:10 +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>;
|
2019-09-20 07:57:27 +00:00
|
|
|
// _bool_ value is used as a indicator of selection in the 3DScene
|
|
|
|
using RBtnEvent = Event<std::pair<Vec2d, bool>>;
|
2018-10-03 09:34:39 +00:00
|
|
|
template <size_t N> using Vec2dsEvent = ArrayEvent<Vec2d, N>;
|
|
|
|
|
|
|
|
using Vec3dEvent = Event<Vec3d>;
|
|
|
|
template <size_t N> using Vec3dsEvent = ArrayEvent<Vec3d, N>;
|
|
|
|
|
2019-11-20 13:06:30 +00:00
|
|
|
using HeightProfileSmoothEvent = Event<HeightProfileSmoothingParams>;
|
|
|
|
|
2018-10-25 10:10:35 +00:00
|
|
|
wxDECLARE_EVENT(EVT_GLCANVAS_SCHEDULE_BACKGROUND_PROCESS, SimpleEvent);
|
2019-09-20 07:57:27 +00:00
|
|
|
wxDECLARE_EVENT(EVT_GLCANVAS_RIGHT_CLICK, RBtnEvent);
|
2018-10-03 09:34:39 +00:00
|
|
|
wxDECLARE_EVENT(EVT_GLCANVAS_REMOVE_OBJECT, SimpleEvent);
|
|
|
|
wxDECLARE_EVENT(EVT_GLCANVAS_ARRANGE, SimpleEvent);
|
2019-02-03 13:06:13 +00:00
|
|
|
wxDECLARE_EVENT(EVT_GLCANVAS_SELECT_ALL, 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);
|
2020-02-04 12:03:28 +00:00
|
|
|
wxDECLARE_EVENT(EVT_GLCANVAS_FORCE_UPDATE, 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);
|
2019-04-26 13:34:26 +00:00
|
|
|
wxDECLARE_EVENT(EVT_GLCANVAS_WIPETOWER_ROTATED, Vec3dEvent);
|
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);
|
2019-02-19 14:15:27 +00:00
|
|
|
wxDECLARE_EVENT(EVT_GLCANVAS_UPDATE_BED_SHAPE, SimpleEvent);
|
2019-02-21 10:54:18 +00:00
|
|
|
wxDECLARE_EVENT(EVT_GLCANVAS_TAB, SimpleEvent);
|
2019-03-27 13:16:38 +00:00
|
|
|
wxDECLARE_EVENT(EVT_GLCANVAS_RESETGIZMOS, SimpleEvent);
|
2020-12-01 07:33:06 +00:00
|
|
|
#if ENABLE_ARROW_KEYS_WITH_SLIDERS
|
|
|
|
wxDECLARE_EVENT(EVT_GLCANVAS_MOVE_SLIDERS, wxKeyEvent);
|
|
|
|
#else
|
2020-05-15 10:25:38 +00:00
|
|
|
wxDECLARE_EVENT(EVT_GLCANVAS_MOVE_LAYERS_SLIDER, wxKeyEvent);
|
2020-12-01 07:33:06 +00:00
|
|
|
#endif // ENABLE_ARROW_KEYS_WITH_SLIDERS
|
2019-06-18 09:40:26 +00:00
|
|
|
wxDECLARE_EVENT(EVT_GLCANVAS_EDIT_COLOR_CHANGE, wxKeyEvent);
|
2020-11-04 15:26:25 +00:00
|
|
|
wxDECLARE_EVENT(EVT_GLCANVAS_JUMP_TO, wxKeyEvent);
|
2019-07-04 08:45:41 +00:00
|
|
|
wxDECLARE_EVENT(EVT_GLCANVAS_UNDO, SimpleEvent);
|
|
|
|
wxDECLARE_EVENT(EVT_GLCANVAS_REDO, SimpleEvent);
|
2020-03-28 18:39:24 +00:00
|
|
|
wxDECLARE_EVENT(EVT_GLCANVAS_COLLAPSE_SIDEBAR, SimpleEvent);
|
2019-11-07 14:55:45 +00:00
|
|
|
wxDECLARE_EVENT(EVT_GLCANVAS_RESET_LAYER_HEIGHT_PROFILE, SimpleEvent);
|
2019-11-14 09:22:48 +00:00
|
|
|
wxDECLARE_EVENT(EVT_GLCANVAS_ADAPTIVE_LAYER_HEIGHT_PROFILE, Event<float>);
|
2019-11-20 13:06:30 +00:00
|
|
|
wxDECLARE_EVENT(EVT_GLCANVAS_SMOOTH_LAYER_HEIGHT_PROFILE, HeightProfileSmoothEvent);
|
2020-01-31 11:15:04 +00:00
|
|
|
wxDECLARE_EVENT(EVT_GLCANVAS_RELOAD_FROM_DISK, SimpleEvent);
|
2018-10-03 09:34:39 +00:00
|
|
|
|
2018-05-09 08:47:04 +00:00
|
|
|
class GLCanvas3D
|
|
|
|
{
|
2019-10-31 15:40:38 +00:00
|
|
|
static const double DefaultCameraZoomToBoxMarginFactor;
|
|
|
|
|
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
|
|
|
|
};
|
|
|
|
|
2019-01-24 10:30:29 +00:00
|
|
|
static const float THICKNESS_BAR_WIDTH;
|
2020-04-23 10:41:38 +00:00
|
|
|
private:
|
2019-01-24 10:30:29 +00:00
|
|
|
|
2019-01-21 09:06:51 +00:00
|
|
|
bool m_enabled;
|
|
|
|
unsigned int m_z_texture_id;
|
|
|
|
// 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;
|
2019-11-27 10:08:10 +00:00
|
|
|
std::vector<double> m_layer_height_profile;
|
2019-01-21 09:06:51 +00:00
|
|
|
bool m_layer_height_profile_modified;
|
|
|
|
|
2019-12-13 12:43:16 +00:00
|
|
|
mutable float m_adaptive_quality;
|
2019-11-20 13:06:30 +00:00
|
|
|
mutable HeightProfileSmoothingParams m_smooth_params;
|
2020-10-02 08:26:11 +00:00
|
|
|
|
|
|
|
static float s_overelay_window_width;
|
2019-11-14 09:22:48 +00:00
|
|
|
|
2019-01-21 09:06:51 +00:00
|
|
|
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
|
|
|
|
2020-05-20 12:11:22 +00:00
|
|
|
void init();
|
2020-05-22 14:08:02 +00:00
|
|
|
|
2020-05-20 12:11:22 +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-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);
|
2019-12-13 12:43:16 +00:00
|
|
|
void adaptive_layer_height_profile(GLCanvas3D& canvas, float quality_factor);
|
|
|
|
void smooth_layer_height_profile(GLCanvas3D& canvas, const HeightProfileSmoothingParams& smoothing_params);
|
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);
|
2018-05-30 13:18:45 +00:00
|
|
|
static Rect get_bar_rect_screen(const GLCanvas3D& canvas);
|
|
|
|
static Rect get_bar_rect_viewport(const GLCanvas3D& canvas);
|
2020-10-14 15:17:14 +00:00
|
|
|
static float get_overlay_window_width() { return LayersEditing::s_overelay_window_width; }
|
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; }
|
|
|
|
|
2019-11-26 13:44:14 +00:00
|
|
|
std::string get_tooltip(const GLCanvas3D& canvas) const;
|
|
|
|
|
2018-05-24 11:46:17 +00:00
|
|
|
private:
|
2019-11-07 14:55:45 +00:00
|
|
|
bool is_initialized() const;
|
2019-01-22 11:14:26 +00:00
|
|
|
void generate_layer_height_texture();
|
2019-11-07 14:55:45 +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);
|
2020-10-02 08:26:11 +00:00
|
|
|
|
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
|
|
|
static const int MoveThresholdPx;
|
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
|
|
|
bool move_requires_threshold;
|
|
|
|
Point move_start_threshold_position_2D;
|
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-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;
|
2019-04-26 12:07:46 +00:00
|
|
|
bool ignore_left_up;
|
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; }
|
|
|
|
void set_move_start_threshold_position_2D_as_invalid() { drag.move_start_threshold_position_2D = Drag::Invalid_2D_Point; }
|
|
|
|
|
|
|
|
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); }
|
|
|
|
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);
|
|
|
|
}
|
2018-05-31 11:51:50 +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
|
|
|
|
{
|
2019-02-20 11:09:45 +00:00
|
|
|
public:
|
|
|
|
WarningTexture();
|
|
|
|
|
|
|
|
enum Warning {
|
|
|
|
ObjectOutside,
|
|
|
|
ToolpathOutside,
|
2019-05-07 10:29:48 +00:00
|
|
|
SlaSupportsOutside,
|
2019-03-01 10:00:34 +00:00
|
|
|
SomethingNotShown,
|
|
|
|
ObjectClashed
|
2019-02-20 11:09:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Sets a warning of the given type to be active/inactive. If several warnings are active simultaneously,
|
|
|
|
// only the last one is shown (decided by the order in the enum above).
|
|
|
|
void activate(WarningTexture::Warning warning, bool state, const GLCanvas3D& canvas);
|
|
|
|
void render(const GLCanvas3D& canvas) const;
|
|
|
|
|
2019-04-16 10:11:48 +00:00
|
|
|
// function used to get an information for rescaling of the warning
|
2019-04-26 11:07:31 +00:00
|
|
|
void msw_rescale(const GLCanvas3D& canvas);
|
2019-04-16 10:11:48 +00:00
|
|
|
|
2019-02-20 11:09:45 +00:00
|
|
|
private:
|
2018-07-19 11:18:19 +00:00
|
|
|
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;
|
|
|
|
|
2019-04-16 10:11:48 +00:00
|
|
|
// information for rescaling of the warning legend
|
|
|
|
std::string m_msg_text = "";
|
|
|
|
bool m_is_colored_red{false};
|
|
|
|
|
2019-02-20 11:09:45 +00:00
|
|
|
// Information about which warnings are currently active.
|
|
|
|
std::vector<Warning> m_warnings;
|
2018-07-31 12:20:16 +00:00
|
|
|
|
2019-02-20 11:09:45 +00:00
|
|
|
// Generates the texture with given text.
|
2019-05-28 10:53:16 +00:00
|
|
|
bool generate(const std::string& msg, const GLCanvas3D& canvas, bool compress, bool red_colored = false);
|
2018-07-19 11:18:19 +00:00
|
|
|
};
|
|
|
|
|
2019-04-25 09:10:01 +00:00
|
|
|
#if ENABLE_RENDER_STATISTICS
|
2020-12-08 10:43:00 +00:00
|
|
|
class RenderStats
|
2019-04-25 09:10:01 +00:00
|
|
|
{
|
2020-12-08 10:43:00 +00:00
|
|
|
std::queue<std::pair<long long, long long>> m_frames;
|
|
|
|
long long m_curr_total{ 0 };
|
2019-04-25 09:10:01 +00:00
|
|
|
|
2020-12-08 10:43:00 +00:00
|
|
|
public:
|
|
|
|
void add_frame(long long frame) {
|
|
|
|
long long now = wxGetLocalTimeMillis().GetValue();
|
|
|
|
if (!m_frames.empty() && now - m_frames.front().first > 1000) {
|
|
|
|
m_curr_total -= m_frames.front().second;
|
|
|
|
m_frames.pop();
|
|
|
|
}
|
|
|
|
m_curr_total += frame;
|
|
|
|
m_frames.push({ now, frame });
|
|
|
|
}
|
|
|
|
long long get_average() const { return m_frames.empty() ? 0 : m_curr_total / m_frames.size(); }
|
2019-04-25 09:10:01 +00:00
|
|
|
};
|
|
|
|
#endif // ENABLE_RENDER_STATISTICS
|
|
|
|
|
2020-01-28 12:15:21 +00:00
|
|
|
class Labels
|
|
|
|
{
|
|
|
|
bool m_enabled{ false };
|
2020-02-04 13:42:26 +00:00
|
|
|
bool m_shown{ false };
|
2020-01-28 14:57:02 +00:00
|
|
|
GLCanvas3D& m_canvas;
|
2020-01-28 12:15:21 +00:00
|
|
|
|
|
|
|
public:
|
2020-01-28 14:57:02 +00:00
|
|
|
explicit Labels(GLCanvas3D& canvas) : m_canvas(canvas) {}
|
2020-01-28 12:15:21 +00:00
|
|
|
void enable(bool enable) { m_enabled = enable; }
|
2020-02-04 13:42:26 +00:00
|
|
|
void show(bool show) { m_shown = m_enabled ? show : false; }
|
|
|
|
bool is_shown() const { return m_shown; }
|
2020-02-06 14:19:53 +00:00
|
|
|
void render(const std::vector<const ModelInstance*>& sorted_instances) const;
|
2020-01-28 12:15:21 +00:00
|
|
|
};
|
|
|
|
|
2020-03-17 12:01:38 +00:00
|
|
|
class Tooltip
|
|
|
|
{
|
|
|
|
std::string m_text;
|
2020-03-17 13:35:56 +00:00
|
|
|
std::chrono::steady_clock::time_point m_start_time;
|
2020-03-18 12:23:07 +00:00
|
|
|
// Indicator that the mouse is inside an ImGUI dialog, therefore the tooltip should be suppressed.
|
2020-03-25 07:43:18 +00:00
|
|
|
bool m_in_imgui = false;
|
2020-03-17 12:01:38 +00:00
|
|
|
|
|
|
|
public:
|
2020-03-18 09:46:46 +00:00
|
|
|
bool is_empty() const { return m_text.empty(); }
|
2020-03-17 13:35:56 +00:00
|
|
|
void set_text(const std::string& text);
|
|
|
|
void render(const Vec2d& mouse_position, GLCanvas3D& canvas) const;
|
2020-03-18 12:23:07 +00:00
|
|
|
// Indicates that the mouse is inside an ImGUI dialog, therefore the tooltip should be suppressed.
|
|
|
|
void set_in_imgui(bool b) { m_in_imgui = b; }
|
2020-03-24 11:26:30 +00:00
|
|
|
bool is_in_imgui() const { return m_in_imgui; }
|
2020-03-17 12:01:38 +00:00
|
|
|
};
|
|
|
|
|
2020-03-13 14:09:07 +00:00
|
|
|
class Slope
|
|
|
|
{
|
|
|
|
bool m_enabled{ false };
|
2020-05-06 06:16:44 +00:00
|
|
|
bool m_dialog_shown{ false };
|
2020-03-13 14:09:07 +00:00
|
|
|
GLCanvas3D& m_canvas;
|
|
|
|
GLVolumeCollection& m_volumes;
|
2020-10-02 08:26:11 +00:00
|
|
|
static float s_window_width;
|
2020-03-13 14:09:07 +00:00
|
|
|
public:
|
|
|
|
Slope(GLCanvas3D& canvas, GLVolumeCollection& volumes) : m_canvas(canvas), m_volumes(volumes) {}
|
|
|
|
|
|
|
|
void enable(bool enable) { m_enabled = enable; }
|
|
|
|
bool is_enabled() const { return m_enabled; }
|
2020-05-06 06:16:44 +00:00
|
|
|
void use(bool use) { m_volumes.set_slope_active(m_enabled ? use : false); }
|
|
|
|
bool is_used() const { return m_volumes.is_slope_active(); }
|
2020-10-02 13:43:39 +00:00
|
|
|
void set_normal_angle(float angle_in_deg) const {
|
|
|
|
m_volumes.set_slope_normal_z(-::cos(Geometry::deg2rad(90.0f - angle_in_deg)));
|
2020-05-06 06:16:44 +00:00
|
|
|
}
|
2020-10-02 08:26:11 +00:00
|
|
|
static float get_window_width() { return s_window_width; };
|
2020-03-13 14:09:07 +00:00
|
|
|
};
|
|
|
|
|
2019-04-24 13:43:52 +00:00
|
|
|
public:
|
|
|
|
enum ECursorType : unsigned char
|
|
|
|
{
|
|
|
|
Standard,
|
|
|
|
Cross
|
|
|
|
};
|
|
|
|
|
2020-11-17 23:06:34 +00:00
|
|
|
struct ArrangeSettings
|
|
|
|
{
|
2020-12-01 13:07:34 +00:00
|
|
|
float distance = 6.;
|
2020-12-02 13:04:39 +00:00
|
|
|
// float distance_seq_print = 6.; // Used when sequential print is ON
|
|
|
|
// float distance_sla = 6.;
|
2020-12-01 13:07:34 +00:00
|
|
|
float accuracy = 0.65f; // Unused currently
|
|
|
|
bool enable_rotation = false;
|
2020-11-17 23:06:34 +00:00
|
|
|
};
|
|
|
|
|
2019-04-24 13:43:52 +00:00
|
|
|
private:
|
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
|
|
|
WarningTexture m_warning_texture;
|
2018-10-25 07:35:08 +00:00
|
|
|
wxTimer m_timer;
|
2018-05-18 12:08:59 +00:00
|
|
|
LayersEditing m_layers_editing;
|
2018-05-23 11:56:54 +00:00
|
|
|
Mouse m_mouse;
|
2019-03-20 12:51:25 +00:00
|
|
|
mutable GLGizmosManager m_gizmos;
|
2019-07-19 13:36:55 +00:00
|
|
|
mutable GLToolbar m_main_toolbar;
|
|
|
|
mutable GLToolbar m_undoredo_toolbar;
|
2018-11-27 13:50:57 +00:00
|
|
|
ClippingPlane m_clipping_planes[2];
|
2019-03-25 11:01:02 +00:00
|
|
|
mutable ClippingPlane m_camera_clipping_plane;
|
2018-11-27 13:50:57 +00:00
|
|
|
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;
|
2019-12-12 12:38:08 +00:00
|
|
|
// when true renders an extra frame by not resetting m_dirty to false
|
|
|
|
// see request_extra_frame()
|
|
|
|
bool m_extra_frame_requested;
|
2020-10-19 10:34:33 +00:00
|
|
|
bool m_event_handlers_bound{ false };
|
2018-05-14 12:14:19 +00:00
|
|
|
|
2018-06-11 13:13:13 +00:00
|
|
|
mutable GLVolumeCollection m_volumes;
|
2020-04-14 08:02:08 +00:00
|
|
|
GCodeViewer m_gcode_viewer;
|
|
|
|
|
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-05-14 12:14:19 +00:00
|
|
|
bool m_apply_zoom_to_volumes_filter;
|
2019-04-24 13:07:28 +00:00
|
|
|
mutable std::vector<int> m_hover_volume_idxs;
|
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-11-26 09:41:16 +00:00
|
|
|
bool m_moving;
|
2019-02-21 17:31:01 +00:00
|
|
|
bool m_tab_down;
|
2019-04-24 13:43:52 +00:00
|
|
|
ECursorType m_cursor_type;
|
2019-04-25 07:10:03 +00:00
|
|
|
GLSelectionRectangle m_rectangle_selection;
|
2019-03-24 12:35:09 +00:00
|
|
|
|
|
|
|
// Following variable is obsolete and it should be safe to remove it.
|
|
|
|
// I just don't want to do it now before a release (Lukas Matena 24.3.2019)
|
2019-02-01 15:12:00 +00:00
|
|
|
bool m_render_sla_auxiliaries;
|
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;
|
|
|
|
|
2019-06-27 09:25:04 +00:00
|
|
|
#if ENABLE_RENDER_PICKING_PASS
|
|
|
|
bool m_show_picking_texture;
|
|
|
|
#endif // ENABLE_RENDER_PICKING_PASS
|
|
|
|
|
2019-04-25 09:10:01 +00:00
|
|
|
#if ENABLE_RENDER_STATISTICS
|
|
|
|
RenderStats m_render_stats;
|
|
|
|
#endif // ENABLE_RENDER_STATISTICS
|
|
|
|
|
2019-12-10 11:57:55 +00:00
|
|
|
mutable int m_imgui_undo_redo_hovered_pos{ -1 };
|
2020-04-27 14:00:54 +00:00
|
|
|
mutable int m_mouse_wheel {0};
|
2019-10-24 06:43:27 +00:00
|
|
|
int m_selected_extruder;
|
2019-07-10 12:08:14 +00:00
|
|
|
|
2020-01-28 12:15:21 +00:00
|
|
|
Labels m_labels;
|
2020-03-17 12:01:38 +00:00
|
|
|
mutable Tooltip m_tooltip;
|
2020-05-07 14:47:15 +00:00
|
|
|
mutable bool m_tooltip_enabled{ true };
|
2020-03-13 14:09:07 +00:00
|
|
|
Slope m_slope;
|
2020-01-28 12:15:21 +00:00
|
|
|
|
2020-12-02 13:04:39 +00:00
|
|
|
ArrangeSettings m_arrange_settings_fff, m_arrange_settings_sla,
|
|
|
|
m_arrange_settings_fff_seq_print;
|
|
|
|
|
|
|
|
PrinterTechnology current_printer_technology() const;
|
|
|
|
|
|
|
|
template<class Self>
|
|
|
|
static auto & get_arrange_settings(Self *self)
|
|
|
|
{
|
|
|
|
PrinterTechnology ptech = self->current_printer_technology();
|
|
|
|
|
|
|
|
auto *ptr = &self->m_arrange_settings_fff;
|
|
|
|
|
|
|
|
if (ptech == ptSLA) {
|
|
|
|
ptr = &self->m_arrange_settings_sla;
|
|
|
|
} else if (ptech == ptFFF) {
|
|
|
|
auto co_opt = self->m_config->template option<ConfigOptionBool>("complete_objects");
|
|
|
|
if (co_opt && co_opt->value) {
|
|
|
|
ptr = &self->m_arrange_settings_fff_seq_print;
|
|
|
|
} else {
|
|
|
|
ptr = &self->m_arrange_settings_fff;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return *ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
ArrangeSettings &get_arrange_settings() { return get_arrange_settings(this); }
|
|
|
|
|
|
|
|
void load_arrange_settings();
|
2020-11-17 23:06:34 +00:00
|
|
|
|
2018-05-09 08:47:04 +00:00
|
|
|
public:
|
2020-03-02 09:58:46 +00:00
|
|
|
explicit GLCanvas3D(wxGLCanvas* canvas);
|
2018-05-15 07:50:01 +00:00
|
|
|
~GLCanvas3D();
|
2018-05-09 08:47:04 +00:00
|
|
|
|
2020-03-02 09:58:46 +00:00
|
|
|
bool is_initialized() const { return m_initialized; }
|
|
|
|
|
2018-10-04 08:41:11 +00:00
|
|
|
void set_context(wxGLContext* context) { m_context = context; }
|
|
|
|
|
|
|
|
wxGLCanvas* get_wxglcanvas() { return m_canvas; }
|
2019-02-04 20:41:10 +00:00
|
|
|
const wxGLCanvas* get_wxglcanvas() const { return m_canvas; }
|
2018-09-17 10:15:11 +00:00
|
|
|
|
2019-07-01 10:28:16 +00:00
|
|
|
bool init();
|
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;
|
2020-01-28 12:15:21 +00:00
|
|
|
const GLVolumeCollection& get_volumes() const { return m_volumes; }
|
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
|
|
|
|
2020-04-14 14:40:08 +00:00
|
|
|
void reset_gcode_toolpaths() { m_gcode_viewer.reset(); }
|
2020-05-15 07:22:51 +00:00
|
|
|
const GCodeViewer::SequentialView& get_gcode_sequential_view() const { return m_gcode_viewer.get_sequential_view(); }
|
2020-05-15 15:57:47 +00:00
|
|
|
void update_gcode_sequential_view_current(unsigned int first, unsigned int last) { m_gcode_viewer.update_sequential_view_current(first, last); }
|
2020-04-14 14:40:08 +00:00
|
|
|
|
2020-01-16 11:43:42 +00:00
|
|
|
void toggle_sla_auxiliaries_visibility(bool visible, const ModelObject* mo = nullptr, int instance_idx = -1);
|
2019-02-06 14:16:25 +00:00
|
|
|
void toggle_model_objects_visibility(bool visible, const ModelObject* mo = nullptr, int instance_idx = -1);
|
2019-08-16 11:14:51 +00:00
|
|
|
void update_instance_printable_state_for_object(size_t obj_idx);
|
2019-08-05 12:57:30 +00:00
|
|
|
void update_instance_printable_state_for_objects(std::vector<size_t>& object_idxs);
|
2019-02-01 15:12: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);
|
2020-01-28 12:15:21 +00:00
|
|
|
const Model* get_model() const { return m_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
|
|
|
|
2019-07-17 06:38:48 +00:00
|
|
|
const GLGizmosManager& get_gizmos_manager() const { return m_gizmos; }
|
|
|
|
GLGizmosManager& get_gizmos_manager() { return m_gizmos; }
|
|
|
|
|
2019-02-19 14:15:27 +00:00
|
|
|
void bed_shape_changed();
|
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
|
|
|
}
|
2019-04-02 11:47:49 +00:00
|
|
|
void reset_clipping_planes_cache() { m_sla_caps[0].triangles.clear(); m_sla_caps[1].triangles.clear(); }
|
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
|
|
|
|
2020-03-02 09:58:46 +00:00
|
|
|
void refresh_camera_scene_box();
|
2018-05-09 08:47:04 +00:00
|
|
|
|
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;
|
2020-05-11 20:00:26 +00:00
|
|
|
bool is_search_pressed() const;
|
2018-05-18 12:08:59 +00:00
|
|
|
|
2019-11-07 14:55:45 +00:00
|
|
|
void reset_layer_height_profile();
|
2019-12-13 12:43:16 +00:00
|
|
|
void adaptive_layer_height_profile(float quality_factor);
|
2019-11-20 13:06:30 +00:00
|
|
|
void smooth_layer_height_profile(const HeightProfileSmoothingParams& smoothing_params);
|
2019-11-07 14:55:45 +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: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);
|
2019-03-28 07:44:46 +00:00
|
|
|
void enable_selection(bool enable);
|
2019-07-19 13:36:55 +00:00
|
|
|
void enable_main_toolbar(bool enable);
|
|
|
|
void enable_undoredo_toolbar(bool enable);
|
2018-07-27 07:38:39 +00:00
|
|
|
void enable_dynamic_background(bool enable);
|
2020-01-28 12:15:21 +00:00
|
|
|
void enable_labels(bool enable) { m_labels.enable(enable); }
|
2020-03-13 14:09:07 +00:00
|
|
|
void enable_slope(bool enable) { m_slope.enable(enable); }
|
2018-05-23 13:35:11 +00:00
|
|
|
void allow_multisample(bool allow);
|
2018-05-21 12:40:09 +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();
|
2020-06-08 10:27:32 +00:00
|
|
|
void zoom_to_gcode();
|
2018-05-15 09:30:11 +00:00
|
|
|
void select_view(const std::string& direction);
|
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-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();
|
2019-10-24 13:56:10 +00:00
|
|
|
// printable_only == false -> render also non printable volumes as grayed
|
|
|
|
// parts_only == false -> render also sla support and pad
|
2019-12-10 11:57:55 +00:00
|
|
|
void render_thumbnail(ThumbnailData& thumbnail_data, unsigned int w, unsigned int h, bool printable_only, bool parts_only, bool show_bed, bool transparent_background) const;
|
2018-05-15 13:38:25 +00:00
|
|
|
|
2018-11-21 14:28:35 +00:00
|
|
|
void select_all();
|
2019-05-14 09:57:39 +00:00
|
|
|
void deselect_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
|
|
|
|
2020-04-28 07:09:24 +00:00
|
|
|
bool is_gcode_legend_enabled() const { return m_gcode_viewer.is_legend_enabled(); }
|
2020-04-28 06:50:52 +00:00
|
|
|
GCodeViewer::EViewType get_gcode_view_type() const { return m_gcode_viewer.get_view_type(); }
|
2020-04-29 08:18:29 +00:00
|
|
|
const std::vector<double>& get_gcode_layers_zs() const;
|
|
|
|
std::vector<double> get_volumes_print_zs(bool active_only) const;
|
2020-04-28 06:50:52 +00:00
|
|
|
unsigned int get_gcode_options_visibility_flags() const { return m_gcode_viewer.get_options_visibility_flags(); }
|
2020-04-24 14:12:38 +00:00
|
|
|
void set_gcode_options_visibility_from_flags(unsigned int flags);
|
2020-04-28 06:50:52 +00:00
|
|
|
unsigned int get_toolpath_role_visibility_flags() const { return m_gcode_viewer.get_toolpath_role_visibility_flags(); }
|
2020-04-17 08:43:29 +00:00
|
|
|
void set_toolpath_role_visibility_flags(unsigned int flags);
|
2020-04-16 13:59:36 +00:00
|
|
|
void set_toolpath_view_type(GCodeViewer::EViewType type);
|
2020-11-13 10:50:52 +00:00
|
|
|
void set_volumes_z_range(const std::array<double, 2>& range);
|
|
|
|
void set_toolpaths_z_range(const std::array<unsigned int, 2>& range);
|
2018-06-04 13:42:34 +00:00
|
|
|
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
|
|
|
|
2020-04-22 14:29:07 +00:00
|
|
|
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(); }
|
2018-11-26 14:16:35 +00:00
|
|
|
void load_sla_preview();
|
2020-01-23 11:49:39 +00:00
|
|
|
void load_preview(const std::vector<std::string>& str_tool_colors, const std::vector<CustomGCode::Item>& 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);
|
2019-02-15 14:35:32 +00:00
|
|
|
void on_key(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);
|
2020-05-07 14:47:15 +00:00
|
|
|
void on_set_focus(wxFocusEvent& evt);
|
2018-05-14 12:47:13 +00:00
|
|
|
|
2018-05-24 11:46:17 +00:00
|
|
|
Size get_canvas_size() const;
|
2019-04-01 09:08:26 +00:00
|
|
|
Vec2d get_local_mouse_position() const;
|
2018-05-24 11:46:17 +00:00
|
|
|
|
2018-10-25 07:35:08 +00:00
|
|
|
void set_tooltip(const std::string& tooltip) const;
|
2018-07-25 08:01:17 +00:00
|
|
|
|
2019-07-09 08:18:57 +00:00
|
|
|
// the following methods add a snapshot to the undo/redo stack, unless the given string is empty
|
|
|
|
void do_move(const std::string& snapshot_type);
|
|
|
|
void do_rotate(const std::string& snapshot_type);
|
|
|
|
void do_scale(const std::string& snapshot_type);
|
|
|
|
void do_flatten(const Vec3d& normal, const std::string& snapshot_type);
|
|
|
|
void do_mirror(const std::string& snapshot_type);
|
2018-11-21 09:36:09 +00:00
|
|
|
|
2018-12-03 12:29:07 +00:00
|
|
|
void update_gizmos_on_off_state();
|
2019-03-27 13:16:38 +00:00
|
|
|
void reset_all_gizmos() { m_gizmos.reset_all_states(); }
|
2018-12-03 12:29:07 +00:00
|
|
|
|
2018-12-18 09:40:53 +00:00
|
|
|
void handle_sidebar_focus_event(const std::string& opt_key, bool focus_on);
|
2019-06-26 11:30:20 +00:00
|
|
|
void handle_layers_data_focus_event(const t_layer_height_range range, const EditorType type);
|
2018-12-11 12:57:50 +00:00
|
|
|
|
2019-01-24 12:16:46 +00:00
|
|
|
void update_ui_from_settings();
|
|
|
|
|
2019-03-26 11:30:17 +00:00
|
|
|
int get_move_volume_id() const { return m_mouse.drag.move_volume_idx; }
|
2019-04-24 13:07:28 +00:00
|
|
|
int get_first_hover_volume_idx() const { return m_hover_volume_idxs.empty() ? -1 : m_hover_volume_idxs.front(); }
|
2019-10-24 06:43:27 +00:00
|
|
|
void set_selected_extruder(int extruder) { m_selected_extruder = extruder;}
|
2019-06-27 19:13:44 +00:00
|
|
|
|
2019-07-12 19:03:49 +00:00
|
|
|
class WipeTowerInfo {
|
2019-07-16 16:33:42 +00:00
|
|
|
protected:
|
2019-06-28 15:03:50 +00:00
|
|
|
Vec2d m_pos = {std::nan(""), std::nan("")};
|
2019-07-16 16:33:42 +00:00
|
|
|
double m_rotation = 0.;
|
2020-12-07 17:00:10 +00:00
|
|
|
BoundingBoxf m_bb;
|
2019-06-27 19:13:44 +00:00
|
|
|
friend class GLCanvas3D;
|
|
|
|
public:
|
|
|
|
|
|
|
|
inline operator bool() const
|
|
|
|
{
|
2019-06-28 15:03:50 +00:00
|
|
|
return !std::isnan(m_pos.x()) && !std::isnan(m_pos.y());
|
2019-06-27 19:13:44 +00:00
|
|
|
}
|
2019-07-12 19:03:49 +00:00
|
|
|
|
2019-07-16 16:33:42 +00:00
|
|
|
inline const Vec2d& pos() const { return m_pos; }
|
|
|
|
inline double rotation() const { return m_rotation; }
|
2020-12-07 17:00:10 +00:00
|
|
|
inline const Vec2d bb_size() const { return m_bb.size(); }
|
2019-07-16 16:33:42 +00:00
|
|
|
|
|
|
|
void apply_wipe_tower() const;
|
2019-06-27 19:13:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
WipeTowerInfo get_wipe_tower_info() const;
|
2019-04-29 12:32:02 +00:00
|
|
|
|
2019-03-26 11:30:17 +00:00
|
|
|
// Returns the view ray line, in world coordinate, at the given mouse position.
|
|
|
|
Linef3 mouse_ray(const Point& mouse_pos);
|
|
|
|
|
|
|
|
void set_mouse_as_dragging() { m_mouse.dragging = true; }
|
|
|
|
bool is_mouse_dragging() const { return m_mouse.dragging; }
|
|
|
|
|
2019-04-12 13:31:33 +00:00
|
|
|
double get_size_proportional_to_max_bed_size(double factor) const;
|
|
|
|
|
2019-04-24 13:43:52 +00:00
|
|
|
void set_cursor(ECursorType type);
|
2019-04-24 23:45:00 +00:00
|
|
|
void msw_rescale();
|
2019-04-24 13:43:52 +00:00
|
|
|
|
2019-12-12 12:38:08 +00:00
|
|
|
void request_extra_frame() { m_extra_frame_requested = true; }
|
2019-06-05 08:07:59 +00:00
|
|
|
|
2019-09-04 07:47:00 +00:00
|
|
|
int get_main_toolbar_item_id(const std::string& name) const { return m_main_toolbar.get_item_id(name); }
|
|
|
|
void force_main_toolbar_left_action(int item_id) { m_main_toolbar.force_left_action(item_id, *this); }
|
|
|
|
void force_main_toolbar_right_action(int item_id) { m_main_toolbar.force_right_action(item_id, *this); }
|
2020-05-05 15:23:58 +00:00
|
|
|
void update_tooltip_for_settings_item_in_main_toolbar();
|
2019-07-19 13:36:55 +00:00
|
|
|
|
2019-08-20 09:33:58 +00:00
|
|
|
bool has_toolpaths_to_export() const;
|
2019-08-20 07:01:09 +00:00
|
|
|
void export_toolpaths_to_obj(const char* filename) const;
|
|
|
|
|
2019-10-09 11:39:24 +00:00
|
|
|
void mouse_up_cleanup();
|
|
|
|
|
2020-02-04 13:42:26 +00:00
|
|
|
bool are_labels_shown() const { return m_labels.is_shown(); }
|
|
|
|
void show_labels(bool show) { m_labels.show(show); }
|
|
|
|
|
2020-10-02 13:43:39 +00:00
|
|
|
bool is_using_slope() const { return m_slope.is_used(); }
|
2020-05-06 06:16:44 +00:00
|
|
|
void use_slope(bool use) { m_slope.use(use); }
|
2020-10-02 13:43:39 +00:00
|
|
|
void set_slope_normal_angle(float angle_in_deg) { m_slope.set_normal_angle(angle_in_deg); }
|
2020-10-02 08:26:11 +00:00
|
|
|
|
2020-12-02 13:04:39 +00:00
|
|
|
ArrangeSettings get_arrange_settings() const
|
|
|
|
{
|
|
|
|
const ArrangeSettings &settings = get_arrange_settings(this);
|
|
|
|
ArrangeSettings ret = settings;
|
|
|
|
if (&settings == &m_arrange_settings_fff_seq_print) {
|
|
|
|
ret.distance = std::max(ret.distance,
|
|
|
|
float(min_object_distance(*m_config)));
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2020-11-17 23:06:34 +00:00
|
|
|
|
2018-05-14 12:14:19 +00:00
|
|
|
private:
|
2018-06-12 07:18:25 +00:00
|
|
|
bool _is_shown_on_screen() const;
|
2018-06-04 10:26:39 +00:00
|
|
|
|
2019-07-19 13:36:55 +00:00
|
|
|
bool _init_toolbars();
|
|
|
|
bool _init_main_toolbar();
|
|
|
|
bool _init_undoredo_toolbar();
|
2019-12-10 09:56:21 +00:00
|
|
|
bool _init_view_toolbar();
|
2020-04-23 10:41:38 +00:00
|
|
|
bool _init_collapse_toolbar();
|
2018-07-23 11:49:48 +00:00
|
|
|
|
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);
|
|
|
|
|
2019-08-02 13:30:37 +00:00
|
|
|
BoundingBoxf3 _max_bounding_box(bool include_gizmos, bool include_bed_model) const;
|
2018-06-01 13:54:41 +00:00
|
|
|
|
2019-10-31 15:40:38 +00:00
|
|
|
void _zoom_to_box(const BoundingBoxf3& box, double margin_factor = DefaultCameraZoomToBoxMarginFactor);
|
2019-10-03 09:38:31 +00:00
|
|
|
void _update_camera_zoom(double zoom);
|
2018-05-15 07:50:01 +00:00
|
|
|
|
2018-05-28 13:23:01 +00:00
|
|
|
void _refresh_if_shown_on_screen();
|
2018-05-29 11:54:34 +00:00
|
|
|
|
|
|
|
void _picking_pass() const;
|
2019-04-25 07:46:26 +00:00
|
|
|
void _rectangular_selection_picking_pass() const;
|
2018-05-29 11:54:34 +00:00
|
|
|
void _render_background() const;
|
2020-04-14 11:18:08 +00:00
|
|
|
void _render_bed(bool bottom, bool show_axes) const;
|
2018-06-04 10:26:39 +00:00
|
|
|
void _render_objects() const;
|
2020-04-14 08:02:08 +00:00
|
|
|
void _render_gcode() 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
|
2020-05-12 21:07:06 +00:00
|
|
|
void _check_and_update_toolbar_icon_scale() const;
|
2019-06-14 08:38:09 +00:00
|
|
|
void _render_overlays() const;
|
2018-05-29 11:54:34 +00:00
|
|
|
void _render_warning_texture() const;
|
2019-04-10 09:20:09 +00:00
|
|
|
void _render_volumes_for_picking() const;
|
2018-08-21 12:27:36 +00:00
|
|
|
void _render_current_gizmo() const;
|
|
|
|
void _render_gizmos_overlay() const;
|
2019-07-19 13:36:55 +00:00
|
|
|
void _render_main_toolbar() const;
|
|
|
|
void _render_undoredo_toolbar() const;
|
2020-04-23 10:41:38 +00:00
|
|
|
void _render_collapse_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;
|
2020-03-23 15:00:56 +00:00
|
|
|
bool _render_undo_redo_stack(const bool is_undo, float pos_x) const;
|
2020-03-28 18:39:24 +00:00
|
|
|
bool _render_search_list(float pos_x) const;
|
2020-11-20 16:50:10 +00:00
|
|
|
bool _render_arrange_menu(float pos_x);
|
2019-12-10 11:57:55 +00:00
|
|
|
void _render_thumbnail_internal(ThumbnailData& thumbnail_data, bool printable_only, bool parts_only, bool show_bed, bool transparent_background) const;
|
2019-10-29 09:27:51 +00:00
|
|
|
// render thumbnail using an off-screen framebuffer
|
2019-12-10 11:57:55 +00:00
|
|
|
void _render_thumbnail_framebuffer(ThumbnailData& thumbnail_data, unsigned int w, unsigned int h, bool printable_only, bool parts_only, bool show_bed, bool transparent_background) const;
|
2019-11-05 13:50:58 +00:00
|
|
|
// render thumbnail using an off-screen framebuffer when GLEW_EXT_framebuffer_object is supported
|
2019-12-10 11:57:55 +00:00
|
|
|
void _render_thumbnail_framebuffer_ext(ThumbnailData& thumbnail_data, unsigned int w, unsigned int h, bool printable_only, bool parts_only, bool show_bed, bool transparent_background) const;
|
2019-11-05 13:50:58 +00:00
|
|
|
// render thumbnail using the default framebuffer
|
2019-12-10 11:57:55 +00:00
|
|
|
void _render_thumbnail_legacy(ThumbnailData& thumbnail_data, unsigned int w, unsigned int h, bool printable_only, bool parts_only, bool show_bed, bool transparent_background) const;
|
2018-05-30 13:18:45 +00:00
|
|
|
|
2018-10-08 12:02:12 +00:00
|
|
|
void _update_volumes_hover_state() const;
|
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-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,
|
2020-01-23 11:49:39 +00:00
|
|
|
const std::vector<CustomGCode::Item>& 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
|
|
|
|
2019-08-08 16:26:41 +00:00
|
|
|
// Load SLA objects and support structures for objects, for which the slaposSliceSupports step has been finished.
|
|
|
|
void _load_sla_shells();
|
2018-07-24 11:39:17 +00:00
|
|
|
void _update_toolpath_volumes_outside_state();
|
2019-05-07 10:29:48 +00:00
|
|
|
void _update_sla_shells_outside_state();
|
|
|
|
void _show_warning_texture_if_needed(WarningTexture::Warning warning);
|
2018-11-21 09:36:09 +00:00
|
|
|
|
2018-07-19 11:18:19 +00:00
|
|
|
// generates a warning texture containing the given message
|
2019-02-20 11:09:45 +00:00
|
|
|
void _set_warning_texture(WarningTexture::Warning warning, bool state);
|
2018-07-19 11:18:19 +00:00
|
|
|
|
2018-07-27 07:38:39 +00:00
|
|
|
bool _is_any_volume_outside() const;
|
|
|
|
|
2019-04-25 10:31:55 +00:00
|
|
|
// updates the selection from the content of m_hover_volume_idxs
|
|
|
|
void _update_selection_from_hover();
|
|
|
|
|
2019-07-11 05:46:40 +00:00
|
|
|
bool _deactivate_undo_redo_toolbar_items();
|
2020-04-01 09:51:44 +00:00
|
|
|
bool _deactivate_search_toolbar_item();
|
2020-04-08 07:47:33 +00:00
|
|
|
bool _activate_search_toolbar_item();
|
2020-04-23 10:41:38 +00:00
|
|
|
bool _deactivate_collapse_toolbar_items();
|
2020-11-20 16:50:10 +00:00
|
|
|
bool _deactivate_arrange_menu();
|
2019-07-11 05:46:40 +00:00
|
|
|
|
2020-10-14 15:17:14 +00:00
|
|
|
float get_overlay_window_width() { return LayersEditing::get_overlay_window_width(); }
|
2020-10-02 08:26:11 +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_
|