Merge remote-tracking branch 'origin/dev_native' into ys_dev_native
This commit is contained in:
commit
7ed9ba5437
@ -1004,6 +1004,11 @@ const TriangleMesh& ModelVolume::get_convex_hull() const
|
|||||||
return m_convex_hull;
|
return m_convex_hull;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TriangleMesh& ModelVolume::get_convex_hull()
|
||||||
|
{
|
||||||
|
return m_convex_hull;
|
||||||
|
}
|
||||||
|
|
||||||
ModelVolume::Type ModelVolume::type_from_string(const std::string &s)
|
ModelVolume::Type ModelVolume::type_from_string(const std::string &s)
|
||||||
{
|
{
|
||||||
// Legacy support
|
// Legacy support
|
||||||
|
@ -198,6 +198,7 @@ public:
|
|||||||
|
|
||||||
void calculate_convex_hull();
|
void calculate_convex_hull();
|
||||||
const TriangleMesh& get_convex_hull() const;
|
const TriangleMesh& get_convex_hull() const;
|
||||||
|
TriangleMesh& get_convex_hull();
|
||||||
|
|
||||||
// Helpers for loading / storing into AMF / 3MF files.
|
// Helpers for loading / storing into AMF / 3MF files.
|
||||||
static Type type_from_string(const std::string &s);
|
static Type type_from_string(const std::string &s);
|
||||||
|
@ -2045,192 +2045,6 @@ void _3DScene::set_toolpaths_range(wxGLCanvas* canvas, double low, double high)
|
|||||||
s_canvas_mgr.set_toolpaths_range(canvas, low, high);
|
s_canvas_mgr.set_toolpaths_range(canvas, low, high);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _3DScene::register_on_viewport_changed_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
s_canvas_mgr.register_on_viewport_changed_callback(canvas, callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _3DScene::register_on_double_click_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
s_canvas_mgr.register_on_double_click_callback(canvas, callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _3DScene::register_on_right_click_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
s_canvas_mgr.register_on_right_click_callback(canvas, callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _3DScene::register_on_select_object_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
s_canvas_mgr.register_on_select_object_callback(canvas, callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _3DScene::register_on_model_update_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
s_canvas_mgr.register_on_model_update_callback(canvas, callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _3DScene::register_on_remove_object_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
s_canvas_mgr.register_on_remove_object_callback(canvas, callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _3DScene::register_on_arrange_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
s_canvas_mgr.register_on_arrange_callback(canvas, callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _3DScene::register_on_rotate_object_left_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
s_canvas_mgr.register_on_rotate_object_left_callback(canvas, callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _3DScene::register_on_rotate_object_right_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
s_canvas_mgr.register_on_rotate_object_right_callback(canvas, callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _3DScene::register_on_scale_object_uniformly_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
s_canvas_mgr.register_on_scale_object_uniformly_callback(canvas, callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _3DScene::register_on_increase_objects_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
s_canvas_mgr.register_on_increase_objects_callback(canvas, callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _3DScene::register_on_decrease_objects_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
s_canvas_mgr.register_on_decrease_objects_callback(canvas, callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _3DScene::register_on_instance_moved_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
s_canvas_mgr.register_on_instance_moved_callback(canvas, callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _3DScene::register_on_wipe_tower_moved_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
s_canvas_mgr.register_on_wipe_tower_moved_callback(canvas, callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _3DScene::register_on_enable_action_buttons_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
s_canvas_mgr.register_on_enable_action_buttons_callback(canvas, callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _3DScene::register_on_gizmo_scale_uniformly_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
#if !ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
|
||||||
s_canvas_mgr.register_on_gizmo_scale_uniformly_callback(canvas, callback);
|
|
||||||
#endif // !ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
|
||||||
}
|
|
||||||
|
|
||||||
void _3DScene::register_on_gizmo_scale_3D_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
|
||||||
s_canvas_mgr.register_on_gizmo_scale_3D_callback(canvas, callback);
|
|
||||||
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
|
||||||
}
|
|
||||||
|
|
||||||
void _3DScene::register_on_gizmo_rotate_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
#if !ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
|
||||||
s_canvas_mgr.register_on_gizmo_rotate_callback(canvas, callback);
|
|
||||||
#endif // !ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
|
||||||
}
|
|
||||||
|
|
||||||
void _3DScene::register_on_gizmo_rotate_3D_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
|
||||||
s_canvas_mgr.register_on_gizmo_rotate_3D_callback(canvas, callback);
|
|
||||||
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
|
||||||
}
|
|
||||||
|
|
||||||
void _3DScene::register_on_gizmo_flatten_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
#if !ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
|
||||||
s_canvas_mgr.register_on_gizmo_flatten_callback(canvas, callback);
|
|
||||||
#endif // !ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
|
||||||
}
|
|
||||||
|
|
||||||
void _3DScene::register_on_gizmo_flatten_3D_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
|
||||||
s_canvas_mgr.register_on_gizmo_flatten_3D_callback(canvas, callback);
|
|
||||||
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
|
||||||
}
|
|
||||||
|
|
||||||
void _3DScene::register_on_update_geometry_info_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
#if !ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
|
||||||
s_canvas_mgr.register_on_update_geometry_info_callback(canvas, callback);
|
|
||||||
#endif // !ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
|
||||||
}
|
|
||||||
|
|
||||||
void _3DScene::register_on_update_geometry_3D_info_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
|
||||||
s_canvas_mgr.register_on_update_geometry_3D_info_callback(canvas, callback);
|
|
||||||
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
|
||||||
}
|
|
||||||
|
|
||||||
void _3DScene::register_action_add_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
s_canvas_mgr.register_action_add_callback(canvas, callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _3DScene::register_action_delete_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
s_canvas_mgr.register_action_delete_callback(canvas, callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _3DScene::register_action_deleteall_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
s_canvas_mgr.register_action_deleteall_callback(canvas, callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _3DScene::register_action_arrange_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
s_canvas_mgr.register_action_arrange_callback(canvas, callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _3DScene::register_action_more_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
s_canvas_mgr.register_action_more_callback(canvas, callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _3DScene::register_action_fewer_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
s_canvas_mgr.register_action_fewer_callback(canvas, callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _3DScene::register_action_split_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
s_canvas_mgr.register_action_split_callback(canvas, callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _3DScene::register_action_cut_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
s_canvas_mgr.register_action_cut_callback(canvas, callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _3DScene::register_action_settings_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
s_canvas_mgr.register_action_settings_callback(canvas, callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _3DScene::register_action_layersediting_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
s_canvas_mgr.register_action_layersediting_callback(canvas, callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _3DScene::register_action_selectbyparts_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
s_canvas_mgr.register_action_selectbyparts_callback(canvas, callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int hex_digit_to_int(const char c)
|
static inline int hex_digit_to_int(const char c)
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
@ -2293,9 +2107,9 @@ void _3DScene::load_preview(wxGLCanvas* canvas, const std::vector<std::string>&
|
|||||||
s_canvas_mgr.load_preview(canvas, str_tool_colors);
|
s_canvas_mgr.load_preview(canvas, str_tool_colors);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _3DScene::reset_legend_texture()
|
void _3DScene::reset_legend_texture(wxGLCanvas* canvas)
|
||||||
{
|
{
|
||||||
s_canvas_mgr.reset_legend_texture();
|
s_canvas_mgr.reset_legend_texture(canvas);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Slic3r
|
} // namespace Slic3r
|
||||||
|
@ -555,42 +555,6 @@ public:
|
|||||||
static std::vector<double> get_current_print_zs(wxGLCanvas* canvas, bool active_only);
|
static std::vector<double> get_current_print_zs(wxGLCanvas* canvas, bool active_only);
|
||||||
static void set_toolpaths_range(wxGLCanvas* canvas, double low, double high);
|
static void set_toolpaths_range(wxGLCanvas* canvas, double low, double high);
|
||||||
|
|
||||||
static void register_on_viewport_changed_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
static void register_on_double_click_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
static void register_on_right_click_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
static void register_on_select_object_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
static void register_on_model_update_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
static void register_on_remove_object_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
static void register_on_arrange_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
static void register_on_rotate_object_left_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
static void register_on_rotate_object_right_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
static void register_on_scale_object_uniformly_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
static void register_on_increase_objects_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
static void register_on_decrease_objects_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
static void register_on_instance_moved_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
static void register_on_wipe_tower_moved_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
static void register_on_enable_action_buttons_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
static void register_on_gizmo_scale_uniformly_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
static void register_on_gizmo_scale_3D_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
static void register_on_gizmo_rotate_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
static void register_on_gizmo_rotate_3D_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
static void register_on_gizmo_flatten_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
static void register_on_gizmo_flatten_3D_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
static void register_on_update_geometry_info_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
static void register_on_update_geometry_3D_info_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
|
|
||||||
static void register_action_add_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
static void register_action_delete_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
static void register_action_deleteall_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
static void register_action_arrange_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
static void register_action_more_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
static void register_action_fewer_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
static void register_action_split_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
static void register_action_cut_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
static void register_action_settings_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
static void register_action_layersediting_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
static void register_action_selectbyparts_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
|
|
||||||
static std::vector<int> load_object(wxGLCanvas* canvas, const ModelObject* model_object, int obj_idx, std::vector<int> instance_idxs);
|
static std::vector<int> load_object(wxGLCanvas* canvas, const ModelObject* model_object, int obj_idx, std::vector<int> instance_idxs);
|
||||||
static std::vector<int> load_object(wxGLCanvas* canvas, const Model* model, int obj_idx);
|
static std::vector<int> load_object(wxGLCanvas* canvas, const Model* model, int obj_idx);
|
||||||
|
|
||||||
@ -602,7 +566,7 @@ public:
|
|||||||
static void load_gcode_preview(wxGLCanvas* canvas, const GCodePreviewData* preview_data, const std::vector<std::string>& str_tool_colors);
|
static void load_gcode_preview(wxGLCanvas* canvas, const GCodePreviewData* preview_data, const std::vector<std::string>& str_tool_colors);
|
||||||
static void load_preview(wxGLCanvas* canvas, const std::vector<std::string>& str_tool_colors);
|
static void load_preview(wxGLCanvas* canvas, const std::vector<std::string>& str_tool_colors);
|
||||||
|
|
||||||
static void reset_legend_texture();
|
static void reset_legend_texture(wxGLCanvas* canvas);
|
||||||
|
|
||||||
static void thick_lines_to_verts(const Lines& lines, const std::vector<double>& widths, const std::vector<double>& heights, bool closed, double top_z, GLVolume& volume);
|
static void thick_lines_to_verts(const Lines& lines, const std::vector<double>& widths, const std::vector<double>& heights, bool closed, double top_z, GLVolume& volume);
|
||||||
static void thick_lines_to_verts(const Lines3& lines, const std::vector<double>& widths, const std::vector<double>& heights, bool closed, GLVolume& volume);
|
static void thick_lines_to_verts(const Lines3& lines, const std::vector<double>& widths, const std::vector<double>& heights, bool closed, GLVolume& volume);
|
||||||
|
63
src/slic3r/GUI/Event.hpp
Normal file
63
src/slic3r/GUI/Event.hpp
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
#ifndef slic3r_Events_hpp_
|
||||||
|
#define slic3r_Events_hpp_
|
||||||
|
|
||||||
|
|
||||||
|
#include <wx/event.h>
|
||||||
|
|
||||||
|
|
||||||
|
namespace Slic3r {
|
||||||
|
|
||||||
|
namespace GUI {
|
||||||
|
|
||||||
|
|
||||||
|
struct SimpleEvent : public wxEvent
|
||||||
|
{
|
||||||
|
SimpleEvent(wxEventType type, wxObject* origin = nullptr) : wxEvent(0, type)
|
||||||
|
{
|
||||||
|
SetEventObject(origin);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual wxEvent* Clone() const
|
||||||
|
{
|
||||||
|
return new SimpleEvent(GetEventType(), GetEventObject());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T, size_t N> struct ArrayEvent : public wxEvent
|
||||||
|
{
|
||||||
|
std::array<T, N> data;
|
||||||
|
|
||||||
|
ArrayEvent(wxEventType type, std::array<T, N> data, wxObject* origin = nullptr)
|
||||||
|
: wxEvent(0, type), data(std::move(data))
|
||||||
|
{
|
||||||
|
SetEventObject(origin);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual wxEvent* Clone() const
|
||||||
|
{
|
||||||
|
return new ArrayEvent<T, N>(GetEventType(), data, GetEventObject());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
template<class T> struct ArrayEvent<T, 1> : public wxEvent
|
||||||
|
{
|
||||||
|
T data;
|
||||||
|
|
||||||
|
ArrayEvent(wxEventType type, T data, wxObject* origin = nullptr)
|
||||||
|
: wxEvent(0, type), data(std::move(data))
|
||||||
|
{
|
||||||
|
SetEventObject(origin);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual wxEvent* Clone() const
|
||||||
|
{
|
||||||
|
return new ArrayEvent<T, 1>(GetEventType(), data, GetEventObject());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class T> using Event = ArrayEvent<T, 1>;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // slic3r_Events_hpp_
|
@ -1936,6 +1936,26 @@ GLGizmoBase* GLCanvas3D::Gizmos::_get_current() const
|
|||||||
return (it != m_gizmos.end()) ? it->second : nullptr;
|
return (it != m_gizmos.end()) ? it->second : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxDEFINE_EVENT(EVT_GLCANVAS_OBJECT_SELECT, ObjectSelectEvent);
|
||||||
|
wxDEFINE_EVENT(EVT_GLCANVAS_VIEWPORT_CHANGED, SimpleEvent);
|
||||||
|
wxDEFINE_EVENT(EVT_GLCANVAS_DOUBLE_CLICK, SimpleEvent);
|
||||||
|
wxDEFINE_EVENT(EVT_GLCANVAS_RIGHT_CLICK, Vec2dEvent);
|
||||||
|
wxDEFINE_EVENT(EVT_GLCANVAS_MODEL_UPDATE, SimpleEvent);
|
||||||
|
wxDEFINE_EVENT(EVT_GLCANVAS_REMOVE_OBJECT, SimpleEvent);
|
||||||
|
wxDEFINE_EVENT(EVT_GLCANVAS_ARRANGE, SimpleEvent);
|
||||||
|
wxDEFINE_EVENT(EVT_GLCANVAS_ROTATE_OBJECT, Event<int>);
|
||||||
|
wxDEFINE_EVENT(EVT_GLCANVAS_SCALE_UNIFORMLY, SimpleEvent);
|
||||||
|
wxDEFINE_EVENT(EVT_GLCANVAS_INCREASE_OBJECTS, Event<int>);
|
||||||
|
wxDEFINE_EVENT(EVT_GLCANVAS_INSTANCE_MOVES, SimpleEvent);
|
||||||
|
wxDEFINE_EVENT(EVT_GLCANVAS_WIPETOWER_MOVED, Vec3dEvent);
|
||||||
|
wxDEFINE_EVENT(EVT_GLCANVAS_ENABLE_ACTION_BUTTONS, Event<bool>);
|
||||||
|
wxDEFINE_EVENT(EVT_GLCANVAS_UPDATE_GEOMETRY, Vec3dsEvent<2>);
|
||||||
|
|
||||||
|
wxDEFINE_EVENT(EVT_GIZMO_SCALE, Vec3dEvent);
|
||||||
|
wxDEFINE_EVENT(EVT_GIZMO_ROTATE, Vec3dEvent);
|
||||||
|
wxDEFINE_EVENT(EVT_GIZMO_FLATTEN, Vec3dEvent);
|
||||||
|
|
||||||
|
|
||||||
GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas)
|
GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas)
|
||||||
: m_canvas(canvas)
|
: m_canvas(canvas)
|
||||||
, m_context(nullptr)
|
, m_context(nullptr)
|
||||||
@ -1985,8 +2005,17 @@ GLCanvas3D::~GLCanvas3D()
|
|||||||
delete m_context;
|
delete m_context;
|
||||||
m_context = nullptr;
|
m_context = nullptr;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_deregister_callbacks();
|
void GLCanvas3D::post_event(wxEvent &&event)
|
||||||
|
{
|
||||||
|
event.SetEventObject(m_canvas);
|
||||||
|
wxPostEvent(m_canvas, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLCanvas3D::viewport_changed()
|
||||||
|
{
|
||||||
|
post_event(SimpleEvent(EVT_GLCANVAS_VIEWPORT_CHANGED));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GLCanvas3D::init(bool useVBOs, bool use_legacy_opengl)
|
bool GLCanvas3D::init(bool useVBOs, bool use_legacy_opengl)
|
||||||
@ -2412,7 +2441,7 @@ void GLCanvas3D::select_view(const std::string& direction)
|
|||||||
m_camera.phi = dir_vec[0];
|
m_camera.phi = dir_vec[0];
|
||||||
m_camera.set_theta(dir_vec[1]);
|
m_camera.set_theta(dir_vec[1]);
|
||||||
|
|
||||||
m_on_viewport_changed_callback.call();
|
viewport_changed();
|
||||||
|
|
||||||
if (m_canvas != nullptr)
|
if (m_canvas != nullptr)
|
||||||
m_canvas->Refresh();
|
m_canvas->Refresh();
|
||||||
@ -2657,21 +2686,21 @@ void GLCanvas3D::reload_scene(bool force)
|
|||||||
{
|
{
|
||||||
enable_warning_texture(true);
|
enable_warning_texture(true);
|
||||||
_generate_warning_texture(L("Detected object outside print volume"));
|
_generate_warning_texture(L("Detected object outside print volume"));
|
||||||
m_on_enable_action_buttons_callback.call(state == ModelInstance::PVS_Fully_Outside);
|
post_event(Event<bool>(EVT_GLCANVAS_ENABLE_ACTION_BUTTONS, state == ModelInstance::PVS_Fully_Outside));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
enable_warning_texture(false);
|
enable_warning_texture(false);
|
||||||
m_volumes.reset_outside_state();
|
m_volumes.reset_outside_state();
|
||||||
_reset_warning_texture();
|
_reset_warning_texture();
|
||||||
m_on_enable_action_buttons_callback.call(!m_model->objects.empty());
|
post_event(Event<bool>(EVT_GLCANVAS_ENABLE_ACTION_BUTTONS, !m_model->objects.empty()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
enable_warning_texture(false);
|
enable_warning_texture(false);
|
||||||
_reset_warning_texture();
|
_reset_warning_texture();
|
||||||
m_on_enable_action_buttons_callback.call(false);
|
post_event(Event<bool>(EVT_GLCANVAS_ENABLE_ACTION_BUTTONS, false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2737,215 +2766,6 @@ void GLCanvas3D::load_preview(const std::vector<std::string>& str_tool_colors)
|
|||||||
reset_legend_texture();
|
reset_legend_texture();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLCanvas3D::register_on_viewport_changed_callback(void* callback)
|
|
||||||
{
|
|
||||||
if (callback != nullptr)
|
|
||||||
m_on_viewport_changed_callback.register_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas3D::register_on_double_click_callback(void* callback)
|
|
||||||
{
|
|
||||||
if (callback != nullptr)
|
|
||||||
m_on_double_click_callback.register_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas3D::register_on_right_click_callback(void* callback)
|
|
||||||
{
|
|
||||||
if (callback != nullptr)
|
|
||||||
m_on_right_click_callback.register_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas3D::register_on_select_object_callback(void* callback)
|
|
||||||
{
|
|
||||||
if (callback != nullptr)
|
|
||||||
m_on_select_object_callback.register_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas3D::register_on_model_update_callback(void* callback)
|
|
||||||
{
|
|
||||||
if (callback != nullptr)
|
|
||||||
m_on_model_update_callback.register_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas3D::register_on_remove_object_callback(void* callback)
|
|
||||||
{
|
|
||||||
if (callback != nullptr)
|
|
||||||
m_on_remove_object_callback.register_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas3D::register_on_arrange_callback(void* callback)
|
|
||||||
{
|
|
||||||
if (callback != nullptr)
|
|
||||||
m_on_arrange_callback.register_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas3D::register_on_rotate_object_left_callback(void* callback)
|
|
||||||
{
|
|
||||||
if (callback != nullptr)
|
|
||||||
m_on_rotate_object_left_callback.register_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas3D::register_on_rotate_object_right_callback(void* callback)
|
|
||||||
{
|
|
||||||
if (callback != nullptr)
|
|
||||||
m_on_rotate_object_right_callback.register_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas3D::register_on_scale_object_uniformly_callback(void* callback)
|
|
||||||
{
|
|
||||||
if (callback != nullptr)
|
|
||||||
m_on_scale_object_uniformly_callback.register_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas3D::register_on_increase_objects_callback(void* callback)
|
|
||||||
{
|
|
||||||
if (callback != nullptr)
|
|
||||||
m_on_increase_objects_callback.register_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas3D::register_on_decrease_objects_callback(void* callback)
|
|
||||||
{
|
|
||||||
if (callback != nullptr)
|
|
||||||
m_on_decrease_objects_callback.register_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas3D::register_on_instance_moved_callback(void* callback)
|
|
||||||
{
|
|
||||||
if (callback != nullptr)
|
|
||||||
m_on_instance_moved_callback.register_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas3D::register_on_wipe_tower_moved_callback(void* callback)
|
|
||||||
{
|
|
||||||
if (callback != nullptr)
|
|
||||||
m_on_wipe_tower_moved_callback.register_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas3D::register_on_enable_action_buttons_callback(void* callback)
|
|
||||||
{
|
|
||||||
if (callback != nullptr)
|
|
||||||
m_on_enable_action_buttons_callback.register_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
|
||||||
void GLCanvas3D::register_on_gizmo_scale_3D_callback(void* callback)
|
|
||||||
{
|
|
||||||
if (callback != nullptr)
|
|
||||||
m_on_gizmo_scale_3D_callback.register_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas3D::register_on_gizmo_rotate_3D_callback(void* callback)
|
|
||||||
{
|
|
||||||
if (callback != nullptr)
|
|
||||||
m_on_gizmo_rotate_3D_callback.register_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas3D::register_on_gizmo_flatten_3D_callback(void* callback)
|
|
||||||
{
|
|
||||||
if (callback != nullptr)
|
|
||||||
m_on_gizmo_flatten_3D_callback.register_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas3D::register_on_update_geometry_3D_info_callback(void* callback)
|
|
||||||
{
|
|
||||||
if (callback != nullptr)
|
|
||||||
m_on_update_geometry_3D_info_callback.register_callback(callback);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
void GLCanvas3D::register_on_gizmo_scale_uniformly_callback(void* callback)
|
|
||||||
{
|
|
||||||
if (callback != nullptr)
|
|
||||||
m_on_gizmo_scale_uniformly_callback.register_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas3D::register_on_gizmo_rotate_callback(void* callback)
|
|
||||||
{
|
|
||||||
if (callback != nullptr)
|
|
||||||
m_on_gizmo_rotate_callback.register_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas3D::register_on_gizmo_flatten_callback(void* callback)
|
|
||||||
{
|
|
||||||
if (callback != nullptr)
|
|
||||||
m_on_gizmo_flatten_callback.register_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas3D::register_on_update_geometry_info_callback(void* callback)
|
|
||||||
{
|
|
||||||
if (callback != nullptr)
|
|
||||||
m_on_update_geometry_info_callback.register_callback(callback);
|
|
||||||
}
|
|
||||||
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
|
||||||
|
|
||||||
// void GLCanvas3D::register_action_add_callback(GLToolbarItem::Callback callback)
|
|
||||||
void GLCanvas3D::register_action_add_callback(void* callback)
|
|
||||||
{
|
|
||||||
if (callback != nullptr)
|
|
||||||
m_action_add_callback.register_callback(callback);
|
|
||||||
// if (callback)
|
|
||||||
// m_action_add_callback = std::move(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas3D::register_action_delete_callback(void* callback)
|
|
||||||
{
|
|
||||||
if (callback != nullptr)
|
|
||||||
m_action_delete_callback.register_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas3D::register_action_deleteall_callback(void* callback)
|
|
||||||
{
|
|
||||||
if (callback != nullptr)
|
|
||||||
m_action_deleteall_callback.register_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas3D::register_action_arrange_callback(void* callback)
|
|
||||||
{
|
|
||||||
if (callback != nullptr)
|
|
||||||
m_action_arrange_callback.register_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas3D::register_action_more_callback(void* callback)
|
|
||||||
{
|
|
||||||
if (callback != nullptr)
|
|
||||||
m_action_more_callback.register_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas3D::register_action_fewer_callback(void* callback)
|
|
||||||
{
|
|
||||||
if (callback != nullptr)
|
|
||||||
m_action_fewer_callback.register_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas3D::register_action_split_callback(void* callback)
|
|
||||||
{
|
|
||||||
if (callback != nullptr)
|
|
||||||
m_action_split_callback.register_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas3D::register_action_cut_callback(void* callback)
|
|
||||||
{
|
|
||||||
if (callback != nullptr)
|
|
||||||
m_action_cut_callback.register_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas3D::register_action_settings_callback(void* callback)
|
|
||||||
{
|
|
||||||
if (callback != nullptr)
|
|
||||||
m_action_settings_callback.register_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas3D::register_action_layersediting_callback(void* callback)
|
|
||||||
{
|
|
||||||
if (callback != nullptr)
|
|
||||||
m_action_layersediting_callback.register_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas3D::register_action_selectbyparts_callback(void* callback)
|
|
||||||
{
|
|
||||||
if (callback != nullptr)
|
|
||||||
m_action_selectbyparts_callback.register_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas3D::bind_event_handlers()
|
void GLCanvas3D::bind_event_handlers()
|
||||||
{
|
{
|
||||||
if (m_canvas != nullptr)
|
if (m_canvas != nullptr)
|
||||||
@ -3034,24 +2854,24 @@ void GLCanvas3D::on_char(wxKeyEvent& evt)
|
|||||||
switch (keyCode)
|
switch (keyCode)
|
||||||
{
|
{
|
||||||
// key +
|
// key +
|
||||||
case 43: { m_on_increase_objects_callback.call(); break; }
|
case 43: { post_event(Event<int>(EVT_GLCANVAS_INCREASE_OBJECTS, +1)); break; }
|
||||||
// key -
|
// key -
|
||||||
case 45: { m_on_decrease_objects_callback.call(); break; }
|
case 45: { post_event(Event<int>(EVT_GLCANVAS_INCREASE_OBJECTS, -1)); break; }
|
||||||
// key A/a
|
// key A/a
|
||||||
case 65:
|
case 65:
|
||||||
case 97: { m_on_arrange_callback.call(); break; }
|
case 97: { post_event(SimpleEvent(EVT_GLCANVAS_ARRANGE)); break; }
|
||||||
// key B/b
|
// key B/b
|
||||||
case 66:
|
case 66:
|
||||||
case 98: { zoom_to_bed(); break; }
|
case 98: { zoom_to_bed(); break; }
|
||||||
// key L/l
|
// key L/l
|
||||||
case 76:
|
case 76:
|
||||||
case 108: { m_on_rotate_object_left_callback.call(); break; }
|
case 108: { post_event(Event<int>(EVT_GLCANVAS_ROTATE_OBJECT, -1)); break; }
|
||||||
// key R/r
|
// key R/r
|
||||||
case 82:
|
case 82:
|
||||||
case 114: { m_on_rotate_object_right_callback.call(); break; }
|
case 114: { post_event(Event<int>(EVT_GLCANVAS_ROTATE_OBJECT, +1)); break; }
|
||||||
// key S/s
|
// key S/s
|
||||||
case 83:
|
case 83:
|
||||||
case 115: { m_on_scale_object_uniformly_callback.call(); break; }
|
case 115: { post_event(SimpleEvent(EVT_GLCANVAS_SCALE_UNIFORMLY)); break; }
|
||||||
// key Z/z
|
// key Z/z
|
||||||
case 90:
|
case 90:
|
||||||
case 122: { zoom_to_volumes(); break; }
|
case 122: { zoom_to_volumes(); break; }
|
||||||
@ -3102,7 +2922,7 @@ void GLCanvas3D::on_mouse_wheel(wxMouseEvent& evt)
|
|||||||
zoom = std::max(zoom, zoom_min * 0.8f);
|
zoom = std::max(zoom, zoom_min * 0.8f);
|
||||||
|
|
||||||
m_camera.zoom = zoom;
|
m_camera.zoom = zoom;
|
||||||
m_on_viewport_changed_callback.call();
|
viewport_changed();
|
||||||
|
|
||||||
_refresh_if_shown_on_screen();
|
_refresh_if_shown_on_screen();
|
||||||
}
|
}
|
||||||
@ -3142,7 +2962,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||||||
m_dirty = true;
|
m_dirty = true;
|
||||||
}
|
}
|
||||||
else if (evt.LeftDClick() && (m_hover_volume_id != -1) && !gizmos_overlay_contains_mouse && (toolbar_contains_mouse == -1))
|
else if (evt.LeftDClick() && (m_hover_volume_id != -1) && !gizmos_overlay_contains_mouse && (toolbar_contains_mouse == -1))
|
||||||
m_on_double_click_callback.call();
|
post_event(SimpleEvent(EVT_GLCANVAS_DOUBLE_CLICK));
|
||||||
else if (evt.LeftDClick() && (toolbar_contains_mouse != -1))
|
else if (evt.LeftDClick() && (toolbar_contains_mouse != -1))
|
||||||
{
|
{
|
||||||
m_toolbar_action_running = true;
|
m_toolbar_action_running = true;
|
||||||
@ -3158,8 +2978,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||||||
case Gizmos::Scale:
|
case Gizmos::Scale:
|
||||||
{
|
{
|
||||||
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
||||||
const Vec3d& scale = m_gizmos.get_scale();
|
post_event(Vec3dEvent(EVT_GIZMO_SCALE, m_gizmos.get_scale()));
|
||||||
m_on_gizmo_scale_3D_callback.call(scale(0), scale(1), scale(2));
|
|
||||||
#else
|
#else
|
||||||
m_on_gizmo_scale_uniformly_callback.call((double)m_gizmos.get_scale());
|
m_on_gizmo_scale_uniformly_callback.call((double)m_gizmos.get_scale());
|
||||||
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
||||||
@ -3170,8 +2989,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||||||
case Gizmos::Rotate:
|
case Gizmos::Rotate:
|
||||||
{
|
{
|
||||||
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
||||||
const Vec3d& rotation = m_gizmos.get_rotation();
|
post_event(Vec3dEvent(EVT_GIZMO_ROTATE, std::move(m_gizmos.get_rotation())));
|
||||||
m_on_gizmo_rotate_3D_callback.call(rotation(0), rotation(1), rotation(2));
|
|
||||||
#else
|
#else
|
||||||
m_on_gizmo_rotate_callback.call((double)m_gizmos.get_angle_z());
|
m_on_gizmo_rotate_callback.call((double)m_gizmos.get_angle_z());
|
||||||
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
||||||
@ -3228,8 +3046,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||||||
if (m_gizmos.get_current_type() == Gizmos::Flatten) {
|
if (m_gizmos.get_current_type() == Gizmos::Flatten) {
|
||||||
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
||||||
// Rotate the object so the normal points downward:
|
// Rotate the object so the normal points downward:
|
||||||
const Vec3d& rotation = m_gizmos.get_flattening_rotation();
|
post_event(Vec3dEvent(EVT_GIZMO_FLATTEN, m_gizmos.get_flattening_rotation()));
|
||||||
m_on_gizmo_flatten_3D_callback.call(rotation(0), rotation(1), rotation(2));
|
|
||||||
#else
|
#else
|
||||||
// Rotate the object so the normal points downward:
|
// Rotate the object so the normal points downward:
|
||||||
Vec3d normal = m_gizmos.get_flattening_normal();
|
Vec3d normal = m_gizmos.get_flattening_normal();
|
||||||
@ -3311,7 +3128,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||||||
{
|
{
|
||||||
// if right clicking on volume, propagate event through callback (shows context menu)
|
// if right clicking on volume, propagate event through callback (shows context menu)
|
||||||
if (m_volumes.volumes[volume_idx]->hover)
|
if (m_volumes.volumes[volume_idx]->hover)
|
||||||
m_on_right_click_callback.call(pos(0), pos(1));
|
post_event(Vec2dEvent(EVT_GLCANVAS_RIGHT_CLICK, pos.cast<double>()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3464,7 +3281,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||||||
const Vec3d& size = bb.size();
|
const Vec3d& size = bb.size();
|
||||||
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
||||||
const Vec3d& scale = m_gizmos.get_scale();
|
const Vec3d& scale = m_gizmos.get_scale();
|
||||||
m_on_update_geometry_3D_info_callback.call(size(0), size(1), size(2), scale(0), scale(1), scale(2));
|
post_event(Vec3dsEvent<2>(EVT_GLCANVAS_UPDATE_GEOMETRY, {size, scale}));
|
||||||
#else
|
#else
|
||||||
m_on_update_geometry_info_callback.call(size(0), size(1), size(2), m_gizmos.get_scale());
|
m_on_update_geometry_info_callback.call(size(0), size(1), size(2), m_gizmos.get_scale());
|
||||||
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
||||||
@ -3490,7 +3307,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||||||
m_camera.phi += (((float)pos(0) - (float)orig(0)) * TRACKBALLSIZE);
|
m_camera.phi += (((float)pos(0) - (float)orig(0)) * TRACKBALLSIZE);
|
||||||
m_camera.set_theta(m_camera.get_theta() - ((float)pos(1) - (float)orig(1)) * TRACKBALLSIZE);
|
m_camera.set_theta(m_camera.get_theta() - ((float)pos(1) - (float)orig(1)) * TRACKBALLSIZE);
|
||||||
|
|
||||||
m_on_viewport_changed_callback.call();
|
viewport_changed();
|
||||||
|
|
||||||
m_dirty = true;
|
m_dirty = true;
|
||||||
}
|
}
|
||||||
@ -3507,7 +3324,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||||||
Vec3d orig = _mouse_to_3d(m_mouse.drag.start_position_2D, &z);
|
Vec3d orig = _mouse_to_3d(m_mouse.drag.start_position_2D, &z);
|
||||||
m_camera.target += orig - cur_pos;
|
m_camera.target += orig - cur_pos;
|
||||||
|
|
||||||
m_on_viewport_changed_callback.call();
|
viewport_changed();
|
||||||
|
|
||||||
m_dirty = true;
|
m_dirty = true;
|
||||||
}
|
}
|
||||||
@ -3523,7 +3340,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||||||
_stop_timer();
|
_stop_timer();
|
||||||
|
|
||||||
if (layer_editing_object_idx != -1)
|
if (layer_editing_object_idx != -1)
|
||||||
m_on_model_update_callback.call();
|
post_event(SimpleEvent(EVT_GLCANVAS_MODEL_UPDATE));
|
||||||
}
|
}
|
||||||
else if ((m_mouse.drag.move_volume_idx != -1) && m_mouse.dragging)
|
else if ((m_mouse.drag.move_volume_idx != -1) && m_mouse.dragging)
|
||||||
{
|
{
|
||||||
@ -3594,8 +3411,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||||||
case Gizmos::Scale:
|
case Gizmos::Scale:
|
||||||
{
|
{
|
||||||
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
||||||
const Vec3d& scale = m_gizmos.get_scale();
|
post_event(Vec3dEvent(EVT_GIZMO_SCALE, m_gizmos.get_scale()));
|
||||||
m_on_gizmo_scale_3D_callback.call(scale(0), scale(1), scale(2));
|
|
||||||
#else
|
#else
|
||||||
m_on_gizmo_scale_uniformly_callback.call((double)m_gizmos.get_scale());
|
m_on_gizmo_scale_uniformly_callback.call((double)m_gizmos.get_scale());
|
||||||
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
||||||
@ -3604,8 +3420,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||||||
case Gizmos::Rotate:
|
case Gizmos::Rotate:
|
||||||
{
|
{
|
||||||
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
||||||
const Vec3d& rotation = m_gizmos.get_rotation();
|
post_event(Vec3dEvent(EVT_GIZMO_ROTATE, m_gizmos.get_rotation()));
|
||||||
m_on_gizmo_rotate_3D_callback.call(rotation(0), rotation(1), rotation(2));
|
|
||||||
#else
|
#else
|
||||||
m_on_gizmo_rotate_callback.call((double)m_gizmos.get_angle_z());
|
m_on_gizmo_rotate_callback.call((double)m_gizmos.get_angle_z());
|
||||||
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
||||||
@ -3653,12 +3468,12 @@ void GLCanvas3D::on_key_down(wxKeyEvent& evt)
|
|||||||
{
|
{
|
||||||
int key = evt.GetKeyCode();
|
int key = evt.GetKeyCode();
|
||||||
if (key == WXK_DELETE)
|
if (key == WXK_DELETE)
|
||||||
m_on_remove_object_callback.call();
|
post_event(SimpleEvent(EVT_GLCANVAS_REMOVE_OBJECT));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifdef __WXOSX__
|
#ifdef __WXOSX__
|
||||||
if (key == WXK_BACK)
|
if (key == WXK_BACK)
|
||||||
m_on_remove_object_callback.call();
|
post_event(SimpleEvent(EVT_GLCANVAS_REMOVE_OBJECT));
|
||||||
#endif
|
#endif
|
||||||
evt.Skip();
|
evt.Skip();
|
||||||
}
|
}
|
||||||
@ -3733,7 +3548,6 @@ bool GLCanvas3D::_init_toolbar()
|
|||||||
item.tooltip = GUI::L_str("Add...");
|
item.tooltip = GUI::L_str("Add...");
|
||||||
item.sprite_id = 0;
|
item.sprite_id = 0;
|
||||||
item.is_toggable = false;
|
item.is_toggable = false;
|
||||||
// item.action_callback = &m_action_add_callback;
|
|
||||||
item.action_event = EVT_GLTOOLBAR_ADD;
|
item.action_event = EVT_GLTOOLBAR_ADD;
|
||||||
if (!m_toolbar.add_item(item))
|
if (!m_toolbar.add_item(item))
|
||||||
return false;
|
return false;
|
||||||
@ -3742,7 +3556,6 @@ bool GLCanvas3D::_init_toolbar()
|
|||||||
item.tooltip = GUI::L_str("Delete");
|
item.tooltip = GUI::L_str("Delete");
|
||||||
item.sprite_id = 1;
|
item.sprite_id = 1;
|
||||||
item.is_toggable = false;
|
item.is_toggable = false;
|
||||||
// item.action_callback = &m_action_delete_callback;
|
|
||||||
item.action_event = EVT_GLTOOLBAR_DELETE;
|
item.action_event = EVT_GLTOOLBAR_DELETE;
|
||||||
if (!m_toolbar.add_item(item))
|
if (!m_toolbar.add_item(item))
|
||||||
return false;
|
return false;
|
||||||
@ -3751,8 +3564,7 @@ bool GLCanvas3D::_init_toolbar()
|
|||||||
item.tooltip = GUI::L_str("Delete all");
|
item.tooltip = GUI::L_str("Delete all");
|
||||||
item.sprite_id = 2;
|
item.sprite_id = 2;
|
||||||
item.is_toggable = false;
|
item.is_toggable = false;
|
||||||
// item.action_callback = &m_action_deleteall_callback;
|
item.action_event = EVT_GLTOOLBAR_DELETE_ALL;
|
||||||
item.action_event = EVT_GLTOOLBAR_TODO_MORE;
|
|
||||||
if (!m_toolbar.add_item(item))
|
if (!m_toolbar.add_item(item))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -3760,8 +3572,7 @@ bool GLCanvas3D::_init_toolbar()
|
|||||||
item.tooltip = GUI::L_str("Arrange");
|
item.tooltip = GUI::L_str("Arrange");
|
||||||
item.sprite_id = 3;
|
item.sprite_id = 3;
|
||||||
item.is_toggable = false;
|
item.is_toggable = false;
|
||||||
// item.action_callback = &m_action_arrange_callback;
|
item.action_event = EVT_GLTOOLBAR_ARRANGE;
|
||||||
item.action_event = EVT_GLTOOLBAR_TODO_MORE;
|
|
||||||
if (!m_toolbar.add_item(item))
|
if (!m_toolbar.add_item(item))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -3772,8 +3583,7 @@ bool GLCanvas3D::_init_toolbar()
|
|||||||
item.tooltip = GUI::L_str("Add instance");
|
item.tooltip = GUI::L_str("Add instance");
|
||||||
item.sprite_id = 4;
|
item.sprite_id = 4;
|
||||||
item.is_toggable = false;
|
item.is_toggable = false;
|
||||||
// item.action_callback = &m_action_more_callback;
|
item.action_event = EVT_GLTOOLBAR_MORE;
|
||||||
item.action_event = EVT_GLTOOLBAR_TODO_MORE;
|
|
||||||
if (!m_toolbar.add_item(item))
|
if (!m_toolbar.add_item(item))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -3781,8 +3591,7 @@ bool GLCanvas3D::_init_toolbar()
|
|||||||
item.tooltip = GUI::L_str("Remove instance");
|
item.tooltip = GUI::L_str("Remove instance");
|
||||||
item.sprite_id = 5;
|
item.sprite_id = 5;
|
||||||
item.is_toggable = false;
|
item.is_toggable = false;
|
||||||
// item.action_callback = &m_action_fewer_callback;
|
item.action_event = EVT_GLTOOLBAR_FEWER;
|
||||||
item.action_event = EVT_GLTOOLBAR_TODO_MORE;
|
|
||||||
if (!m_toolbar.add_item(item))
|
if (!m_toolbar.add_item(item))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -3793,8 +3602,7 @@ bool GLCanvas3D::_init_toolbar()
|
|||||||
item.tooltip = GUI::L_str("Split");
|
item.tooltip = GUI::L_str("Split");
|
||||||
item.sprite_id = 6;
|
item.sprite_id = 6;
|
||||||
item.is_toggable = false;
|
item.is_toggable = false;
|
||||||
// item.action_callback = &m_action_split_callback;
|
item.action_event = EVT_GLTOOLBAR_SPLIT;
|
||||||
item.action_event = EVT_GLTOOLBAR_TODO_MORE;
|
|
||||||
if (!m_toolbar.add_item(item))
|
if (!m_toolbar.add_item(item))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -3802,8 +3610,7 @@ bool GLCanvas3D::_init_toolbar()
|
|||||||
item.tooltip = GUI::L_str("Cut...");
|
item.tooltip = GUI::L_str("Cut...");
|
||||||
item.sprite_id = 7;
|
item.sprite_id = 7;
|
||||||
item.is_toggable = false;
|
item.is_toggable = false;
|
||||||
// item.action_callback = &m_action_cut_callback;
|
item.action_event = EVT_GLTOOLBAR_CUT;
|
||||||
item.action_event = EVT_GLTOOLBAR_TODO_MORE;
|
|
||||||
if (!m_toolbar.add_item(item))
|
if (!m_toolbar.add_item(item))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -3814,8 +3621,7 @@ bool GLCanvas3D::_init_toolbar()
|
|||||||
item.tooltip = GUI::L_str("Settings...");
|
item.tooltip = GUI::L_str("Settings...");
|
||||||
item.sprite_id = 8;
|
item.sprite_id = 8;
|
||||||
item.is_toggable = false;
|
item.is_toggable = false;
|
||||||
// item.action_callback = &m_action_settings_callback;
|
item.action_event = EVT_GLTOOLBAR_SETTINGS;
|
||||||
item.action_event = EVT_GLTOOLBAR_TODO_MORE;
|
|
||||||
if (!m_toolbar.add_item(item))
|
if (!m_toolbar.add_item(item))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -3823,8 +3629,7 @@ bool GLCanvas3D::_init_toolbar()
|
|||||||
item.tooltip = GUI::L_str("Layers editing");
|
item.tooltip = GUI::L_str("Layers editing");
|
||||||
item.sprite_id = 9;
|
item.sprite_id = 9;
|
||||||
item.is_toggable = true;
|
item.is_toggable = true;
|
||||||
// item.action_callback = &m_action_layersediting_callback;
|
item.action_event = EVT_GLTOOLBAR_LAYERSEDITING;
|
||||||
item.action_event = EVT_GLTOOLBAR_TODO_MORE;
|
|
||||||
if (!m_toolbar.add_item(item))
|
if (!m_toolbar.add_item(item))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -3835,8 +3640,7 @@ bool GLCanvas3D::_init_toolbar()
|
|||||||
item.tooltip = GUI::L_str("Select by parts");
|
item.tooltip = GUI::L_str("Select by parts");
|
||||||
item.sprite_id = 10;
|
item.sprite_id = 10;
|
||||||
item.is_toggable = true;
|
item.is_toggable = true;
|
||||||
// item.action_callback = &m_action_selectbyparts_callback;
|
item.action_event = EVT_GLTOOLBAR_SELECTBYPARTS;
|
||||||
item.action_event = EVT_GLTOOLBAR_TODO_MORE;
|
|
||||||
if (!m_toolbar.add_item(item))
|
if (!m_toolbar.add_item(item))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -3975,7 +3779,7 @@ void GLCanvas3D::_zoom_to_bounding_box(const BoundingBoxf3& bbox)
|
|||||||
// center view around bounding box center
|
// center view around bounding box center
|
||||||
m_camera.target = bbox.center();
|
m_camera.target = bbox.center();
|
||||||
|
|
||||||
m_on_viewport_changed_callback.call();
|
viewport_changed();
|
||||||
|
|
||||||
_refresh_if_shown_on_screen();
|
_refresh_if_shown_on_screen();
|
||||||
}
|
}
|
||||||
@ -4048,48 +3852,6 @@ float GLCanvas3D::_get_zoom_to_bounding_box_factor(const BoundingBoxf3& bbox) co
|
|||||||
return (float)std::min((double)cnv_size.get_width() / max_x, (double)cnv_size.get_height() / max_y);
|
return (float)std::min((double)cnv_size.get_width() / max_x, (double)cnv_size.get_height() / max_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLCanvas3D::_deregister_callbacks()
|
|
||||||
{
|
|
||||||
m_on_viewport_changed_callback.deregister_callback();
|
|
||||||
m_on_double_click_callback.deregister_callback();
|
|
||||||
m_on_right_click_callback.deregister_callback();
|
|
||||||
m_on_select_object_callback.deregister_callback();
|
|
||||||
m_on_model_update_callback.deregister_callback();
|
|
||||||
m_on_remove_object_callback.deregister_callback();
|
|
||||||
m_on_arrange_callback.deregister_callback();
|
|
||||||
m_on_rotate_object_left_callback.deregister_callback();
|
|
||||||
m_on_rotate_object_right_callback.deregister_callback();
|
|
||||||
m_on_scale_object_uniformly_callback.deregister_callback();
|
|
||||||
m_on_increase_objects_callback.deregister_callback();
|
|
||||||
m_on_decrease_objects_callback.deregister_callback();
|
|
||||||
m_on_instance_moved_callback.deregister_callback();
|
|
||||||
m_on_wipe_tower_moved_callback.deregister_callback();
|
|
||||||
m_on_enable_action_buttons_callback.deregister_callback();
|
|
||||||
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
|
||||||
m_on_gizmo_scale_3D_callback.deregister_callback();
|
|
||||||
m_on_gizmo_rotate_3D_callback.deregister_callback();
|
|
||||||
m_on_gizmo_flatten_3D_callback.deregister_callback();
|
|
||||||
m_on_update_geometry_3D_info_callback.deregister_callback();
|
|
||||||
#else
|
|
||||||
m_on_gizmo_scale_uniformly_callback.deregister_callback();
|
|
||||||
m_on_gizmo_rotate_callback.deregister_callback();
|
|
||||||
m_on_gizmo_flatten_callback.deregister_callback();
|
|
||||||
m_on_update_geometry_info_callback.deregister_callback();
|
|
||||||
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
|
||||||
|
|
||||||
m_action_add_callback.deregister_callback();
|
|
||||||
m_action_delete_callback.deregister_callback();
|
|
||||||
m_action_deleteall_callback.deregister_callback();
|
|
||||||
m_action_arrange_callback.deregister_callback();
|
|
||||||
m_action_more_callback.deregister_callback();
|
|
||||||
m_action_fewer_callback.deregister_callback();
|
|
||||||
m_action_split_callback.deregister_callback();
|
|
||||||
m_action_cut_callback.deregister_callback();
|
|
||||||
m_action_settings_callback.deregister_callback();
|
|
||||||
m_action_layersediting_callback.deregister_callback();
|
|
||||||
m_action_selectbyparts_callback.deregister_callback();
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas3D::_mark_volumes_for_layer_height() const
|
void GLCanvas3D::_mark_volumes_for_layer_height() const
|
||||||
{
|
{
|
||||||
if (m_print == nullptr)
|
if (m_print == nullptr)
|
||||||
@ -5599,10 +5361,10 @@ void GLCanvas3D::_on_move(const std::vector<int>& volume_idxs)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (object_moved)
|
if (object_moved)
|
||||||
m_on_instance_moved_callback.call();
|
post_event(SimpleEvent(EVT_GLCANVAS_WIPETOWER_MOVED));
|
||||||
|
|
||||||
if (wipe_tower_origin != Vec3d::Zero())
|
if (wipe_tower_origin != Vec3d::Zero())
|
||||||
m_on_wipe_tower_moved_callback.call(wipe_tower_origin(0), wipe_tower_origin(1));
|
post_event(Vec3dEvent(EVT_GLCANVAS_WIPETOWER_MOVED, std::move(wipe_tower_origin)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLCanvas3D::_on_select(int volume_idx, int object_idx)
|
void GLCanvas3D::_on_select(int volume_idx, int object_idx)
|
||||||
@ -5633,7 +5395,7 @@ void GLCanvas3D::_on_select(int volume_idx, int object_idx)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_on_select_object_callback.call(obj_id, vol_id);
|
post_event(ObjectSelectEvent(obj_id, vol_id));
|
||||||
Slic3r::GUI::select_current_volume(obj_id, vol_id);
|
Slic3r::GUI::select_current_volume(obj_id, vol_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
#ifndef slic3r_GLCanvas3D_hpp_
|
#ifndef slic3r_GLCanvas3D_hpp_
|
||||||
#define slic3r_GLCanvas3D_hpp_
|
#define slic3r_GLCanvas3D_hpp_
|
||||||
|
|
||||||
#include <functional>
|
#include <stddef.h>
|
||||||
|
|
||||||
#include "3DScene.hpp"
|
#include "3DScene.hpp"
|
||||||
#include "GLToolbar.hpp"
|
#include "GLToolbar.hpp"
|
||||||
#include "callback.hpp"
|
#include "Event.hpp"
|
||||||
|
|
||||||
class wxWindow;
|
class wxWindow;
|
||||||
class wxTimer;
|
class wxTimer;
|
||||||
@ -16,6 +16,7 @@ class wxMouseEvent;
|
|||||||
class wxTimerEvent;
|
class wxTimerEvent;
|
||||||
class wxPaintEvent;
|
class wxPaintEvent;
|
||||||
|
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
|
|
||||||
class GLShader;
|
class GLShader;
|
||||||
@ -80,6 +81,45 @@ public:
|
|||||||
void set_bottom(float bottom);
|
void set_bottom(float bottom);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct ObjectSelectEvent;
|
||||||
|
wxDECLARE_EVENT(EVT_GLCANVAS_OBJECT_SELECT, ObjectSelectEvent);
|
||||||
|
struct ObjectSelectEvent : public ArrayEvent<ptrdiff_t, 2>
|
||||||
|
{
|
||||||
|
ObjectSelectEvent(ptrdiff_t object_id, ptrdiff_t volume_id, wxObject *origin = nullptr)
|
||||||
|
: ArrayEvent(EVT_GLCANVAS_OBJECT_SELECT, {object_id, volume_id}, origin)
|
||||||
|
{}
|
||||||
|
|
||||||
|
ptrdiff_t object_id() const { return data[0]; }
|
||||||
|
ptrdiff_t volume_id() const { return data[1]; }
|
||||||
|
};
|
||||||
|
|
||||||
|
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>;
|
||||||
|
|
||||||
|
|
||||||
|
wxDECLARE_EVENT(EVT_GLCANVAS_VIEWPORT_CHANGED, SimpleEvent);
|
||||||
|
wxDECLARE_EVENT(EVT_GLCANVAS_DOUBLE_CLICK, SimpleEvent);
|
||||||
|
wxDECLARE_EVENT(EVT_GLCANVAS_RIGHT_CLICK, Vec2dEvent);
|
||||||
|
wxDECLARE_EVENT(EVT_GLCANVAS_MODEL_UPDATE, SimpleEvent);
|
||||||
|
wxDECLARE_EVENT(EVT_GLCANVAS_REMOVE_OBJECT, SimpleEvent);
|
||||||
|
wxDECLARE_EVENT(EVT_GLCANVAS_ARRANGE, SimpleEvent);
|
||||||
|
wxDECLARE_EVENT(EVT_GLCANVAS_ROTATE_OBJECT, Event<int>); // data: -1 => rotate left, +1 => rotate right
|
||||||
|
wxDECLARE_EVENT(EVT_GLCANVAS_SCALE_UNIFORMLY, SimpleEvent);
|
||||||
|
wxDECLARE_EVENT(EVT_GLCANVAS_INCREASE_OBJECTS, Event<int>); // data: +1 => increase, -1 => decrease
|
||||||
|
wxDECLARE_EVENT(EVT_GLCANVAS_INSTANCE_MOVES, SimpleEvent);
|
||||||
|
wxDECLARE_EVENT(EVT_GLCANVAS_WIPETOWER_MOVED, Vec3dEvent);
|
||||||
|
wxDECLARE_EVENT(EVT_GLCANVAS_ENABLE_ACTION_BUTTONS, Event<bool>);
|
||||||
|
wxDECLARE_EVENT(EVT_GLCANVAS_UPDATE_GEOMETRY, Vec3dsEvent<2>);
|
||||||
|
|
||||||
|
wxDECLARE_EVENT(EVT_GIZMO_SCALE, Vec3dEvent);
|
||||||
|
wxDECLARE_EVENT(EVT_GIZMO_ROTATE, Vec3dEvent);
|
||||||
|
wxDECLARE_EVENT(EVT_GIZMO_FLATTEN, Vec3dEvent);
|
||||||
|
|
||||||
|
|
||||||
class GLCanvas3D
|
class GLCanvas3D
|
||||||
{
|
{
|
||||||
struct GCodePreviewVolumeIndex
|
struct GCodePreviewVolumeIndex
|
||||||
@ -506,46 +546,8 @@ class GLCanvas3D
|
|||||||
|
|
||||||
GCodePreviewVolumeIndex m_gcode_preview_volume_index;
|
GCodePreviewVolumeIndex m_gcode_preview_volume_index;
|
||||||
|
|
||||||
PerlCallback m_on_viewport_changed_callback;
|
void post_event(wxEvent &&event);
|
||||||
PerlCallback m_on_double_click_callback;
|
void viewport_changed();
|
||||||
PerlCallback m_on_right_click_callback;
|
|
||||||
PerlCallback m_on_select_object_callback;
|
|
||||||
PerlCallback m_on_model_update_callback;
|
|
||||||
PerlCallback m_on_remove_object_callback;
|
|
||||||
PerlCallback m_on_arrange_callback;
|
|
||||||
PerlCallback m_on_rotate_object_left_callback;
|
|
||||||
PerlCallback m_on_rotate_object_right_callback;
|
|
||||||
PerlCallback m_on_scale_object_uniformly_callback;
|
|
||||||
PerlCallback m_on_increase_objects_callback;
|
|
||||||
PerlCallback m_on_decrease_objects_callback;
|
|
||||||
PerlCallback m_on_instance_moved_callback;
|
|
||||||
PerlCallback m_on_wipe_tower_moved_callback;
|
|
||||||
PerlCallback m_on_enable_action_buttons_callback;
|
|
||||||
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
|
||||||
PerlCallback m_on_gizmo_rotate_3D_callback;
|
|
||||||
PerlCallback m_on_gizmo_flatten_3D_callback;
|
|
||||||
PerlCallback m_on_gizmo_scale_3D_callback;
|
|
||||||
PerlCallback m_on_update_geometry_3D_info_callback;
|
|
||||||
#else
|
|
||||||
PerlCallback m_on_gizmo_scale_uniformly_callback;
|
|
||||||
PerlCallback m_on_gizmo_rotate_callback;
|
|
||||||
PerlCallback m_on_gizmo_flatten_callback;
|
|
||||||
PerlCallback m_on_update_geometry_info_callback;
|
|
||||||
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
|
||||||
|
|
||||||
// TODO: Remove these
|
|
||||||
PerlCallback m_action_add_callback;
|
|
||||||
PerlCallback m_action_delete_callback;
|
|
||||||
PerlCallback m_action_deleteall_callback;
|
|
||||||
PerlCallback m_action_arrange_callback;
|
|
||||||
PerlCallback m_action_more_callback;
|
|
||||||
PerlCallback m_action_fewer_callback;
|
|
||||||
PerlCallback m_action_split_callback;
|
|
||||||
PerlCallback m_action_cut_callback;
|
|
||||||
PerlCallback m_action_settings_callback;
|
|
||||||
PerlCallback m_action_layersediting_callback;
|
|
||||||
PerlCallback m_action_selectbyparts_callback;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GLCanvas3D(wxGLCanvas* canvas);
|
GLCanvas3D(wxGLCanvas* canvas);
|
||||||
~GLCanvas3D();
|
~GLCanvas3D();
|
||||||
@ -641,46 +643,6 @@ public:
|
|||||||
void load_gcode_preview(const GCodePreviewData& preview_data, const std::vector<std::string>& str_tool_colors);
|
void load_gcode_preview(const GCodePreviewData& preview_data, const std::vector<std::string>& str_tool_colors);
|
||||||
void load_preview(const std::vector<std::string>& str_tool_colors);
|
void load_preview(const std::vector<std::string>& str_tool_colors);
|
||||||
|
|
||||||
void register_on_viewport_changed_callback(void* callback);
|
|
||||||
void register_on_double_click_callback(void* callback);
|
|
||||||
void register_on_right_click_callback(void* callback);
|
|
||||||
void register_on_select_object_callback(void* callback);
|
|
||||||
void register_on_model_update_callback(void* callback);
|
|
||||||
void register_on_remove_object_callback(void* callback);
|
|
||||||
void register_on_arrange_callback(void* callback);
|
|
||||||
void register_on_rotate_object_left_callback(void* callback);
|
|
||||||
void register_on_rotate_object_right_callback(void* callback);
|
|
||||||
void register_on_scale_object_uniformly_callback(void* callback);
|
|
||||||
void register_on_increase_objects_callback(void* callback);
|
|
||||||
void register_on_decrease_objects_callback(void* callback);
|
|
||||||
void register_on_instance_moved_callback(void* callback);
|
|
||||||
void register_on_wipe_tower_moved_callback(void* callback);
|
|
||||||
void register_on_enable_action_buttons_callback(void* callback);
|
|
||||||
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
|
||||||
void register_on_gizmo_scale_3D_callback(void* callback);
|
|
||||||
void register_on_gizmo_rotate_3D_callback(void* callback);
|
|
||||||
void register_on_gizmo_flatten_3D_callback(void* callback);
|
|
||||||
void register_on_update_geometry_3D_info_callback(void* callback);
|
|
||||||
#else
|
|
||||||
void register_on_gizmo_scale_uniformly_callback(void* callback);
|
|
||||||
void register_on_gizmo_rotate_callback(void* callback);
|
|
||||||
void register_on_gizmo_flatten_callback(void* callback);
|
|
||||||
void register_on_update_geometry_info_callback(void* callback);
|
|
||||||
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
|
||||||
|
|
||||||
// void register_action_add_callback(GLToolbarItem::Callback);
|
|
||||||
void register_action_add_callback(void* callback);
|
|
||||||
void register_action_delete_callback(void* callback);
|
|
||||||
void register_action_deleteall_callback(void* callback);
|
|
||||||
void register_action_arrange_callback(void* callback);
|
|
||||||
void register_action_more_callback(void* callback);
|
|
||||||
void register_action_fewer_callback(void* callback);
|
|
||||||
void register_action_split_callback(void* callback);
|
|
||||||
void register_action_cut_callback(void* callback);
|
|
||||||
void register_action_settings_callback(void* callback);
|
|
||||||
void register_action_layersediting_callback(void* callback);
|
|
||||||
void register_action_selectbyparts_callback(void* callback);
|
|
||||||
|
|
||||||
void bind_event_handlers();
|
void bind_event_handlers();
|
||||||
void unbind_event_handlers();
|
void unbind_event_handlers();
|
||||||
|
|
||||||
@ -714,8 +676,6 @@ private:
|
|||||||
void _zoom_to_bounding_box(const BoundingBoxf3& bbox);
|
void _zoom_to_bounding_box(const BoundingBoxf3& bbox);
|
||||||
float _get_zoom_to_bounding_box_factor(const BoundingBoxf3& bbox) const;
|
float _get_zoom_to_bounding_box_factor(const BoundingBoxf3& bbox) const;
|
||||||
|
|
||||||
void _deregister_callbacks();
|
|
||||||
|
|
||||||
void _mark_volumes_for_layer_height() const;
|
void _mark_volumes_for_layer_height() const;
|
||||||
void _refresh_if_shown_on_screen();
|
void _refresh_if_shown_on_screen();
|
||||||
|
|
||||||
|
@ -110,6 +110,8 @@ std::string GLCanvas3DManager::GLInfo::to_string(bool format_as_html, bool exten
|
|||||||
return out.str();
|
return out.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GLCanvas3DManager::EMultisampleState GLCanvas3DManager::s_multisample = GLCanvas3DManager::MS_Unknown;
|
||||||
|
|
||||||
GLCanvas3DManager::GLCanvas3DManager()
|
GLCanvas3DManager::GLCanvas3DManager()
|
||||||
: m_current(nullptr)
|
: m_current(nullptr)
|
||||||
, m_gl_initialized(false)
|
, m_gl_initialized(false)
|
||||||
@ -578,273 +580,24 @@ void GLCanvas3DManager::load_preview(wxGLCanvas* canvas, const std::vector<std::
|
|||||||
it->second->load_preview(str_tool_colors);
|
it->second->load_preview(str_tool_colors);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLCanvas3DManager::reset_legend_texture()
|
void GLCanvas3DManager::reset_legend_texture(wxGLCanvas* canvas)
|
||||||
{
|
|
||||||
for (CanvasesMap::value_type& canvas : m_canvases)
|
|
||||||
{
|
|
||||||
if (canvas.second != nullptr)
|
|
||||||
canvas.second->reset_legend_texture();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas3DManager::register_on_viewport_changed_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
{
|
||||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
CanvasesMap::iterator it = _get_canvas(canvas);
|
||||||
if (it != m_canvases.end())
|
if (it != m_canvases.end())
|
||||||
it->second->register_on_viewport_changed_callback(callback);
|
it->second->reset_legend_texture();
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas3DManager::register_on_double_click_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
|
||||||
if (it != m_canvases.end())
|
|
||||||
it->second->register_on_double_click_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas3DManager::register_on_right_click_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
|
||||||
if (it != m_canvases.end())
|
|
||||||
it->second->register_on_right_click_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas3DManager::register_on_select_object_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
|
||||||
if (it != m_canvases.end())
|
|
||||||
it->second->register_on_select_object_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas3DManager::register_on_model_update_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
|
||||||
if (it != m_canvases.end())
|
|
||||||
it->second->register_on_model_update_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas3DManager::register_on_remove_object_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
|
||||||
if (it != m_canvases.end())
|
|
||||||
it->second->register_on_remove_object_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas3DManager::register_on_arrange_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
|
||||||
if (it != m_canvases.end())
|
|
||||||
it->second->register_on_arrange_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas3DManager::register_on_rotate_object_left_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
|
||||||
if (it != m_canvases.end())
|
|
||||||
it->second->register_on_rotate_object_left_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas3DManager::register_on_rotate_object_right_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
|
||||||
if (it != m_canvases.end())
|
|
||||||
it->second->register_on_rotate_object_right_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas3DManager::register_on_scale_object_uniformly_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
|
||||||
if (it != m_canvases.end())
|
|
||||||
it->second->register_on_scale_object_uniformly_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas3DManager::register_on_increase_objects_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
|
||||||
if (it != m_canvases.end())
|
|
||||||
it->second->register_on_increase_objects_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas3DManager::register_on_decrease_objects_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
|
||||||
if (it != m_canvases.end())
|
|
||||||
it->second->register_on_decrease_objects_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas3DManager::register_on_instance_moved_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
|
||||||
if (it != m_canvases.end())
|
|
||||||
it->second->register_on_instance_moved_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas3DManager::register_on_wipe_tower_moved_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
|
||||||
if (it != m_canvases.end())
|
|
||||||
it->second->register_on_wipe_tower_moved_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas3DManager::register_on_enable_action_buttons_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
|
||||||
if (it != m_canvases.end())
|
|
||||||
it->second->register_on_enable_action_buttons_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
|
||||||
void GLCanvas3DManager::register_on_gizmo_scale_3D_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
|
||||||
if (it != m_canvases.end())
|
|
||||||
it->second->register_on_gizmo_scale_3D_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas3DManager::register_on_gizmo_rotate_3D_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
|
||||||
if (it != m_canvases.end())
|
|
||||||
it->second->register_on_gizmo_rotate_3D_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas3DManager::register_on_gizmo_flatten_3D_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
|
||||||
if (it != m_canvases.end())
|
|
||||||
it->second->register_on_gizmo_flatten_3D_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas3DManager::register_on_update_geometry_3D_info_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
|
||||||
if (it != m_canvases.end())
|
|
||||||
it->second->register_on_update_geometry_3D_info_callback(callback);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
void GLCanvas3DManager::register_on_gizmo_scale_uniformly_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
|
||||||
if (it != m_canvases.end())
|
|
||||||
it->second->register_on_gizmo_scale_uniformly_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas3DManager::register_on_gizmo_rotate_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
|
||||||
if (it != m_canvases.end())
|
|
||||||
it->second->register_on_gizmo_rotate_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas3DManager::register_on_gizmo_flatten_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
|
||||||
if (it != m_canvases.end())
|
|
||||||
it->second->register_on_gizmo_flatten_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas3DManager::register_on_update_geometry_info_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
|
||||||
if (it != m_canvases.end())
|
|
||||||
it->second->register_on_update_geometry_info_callback(callback);
|
|
||||||
}
|
|
||||||
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
|
||||||
|
|
||||||
void GLCanvas3DManager::register_action_add_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
|
||||||
if (it != m_canvases.end())
|
|
||||||
it->second->register_action_add_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas3DManager::register_action_delete_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
|
||||||
if (it != m_canvases.end())
|
|
||||||
it->second->register_action_delete_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas3DManager::register_action_deleteall_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
|
||||||
if (it != m_canvases.end())
|
|
||||||
it->second->register_action_deleteall_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas3DManager::register_action_arrange_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
|
||||||
if (it != m_canvases.end())
|
|
||||||
it->second->register_action_arrange_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas3DManager::register_action_more_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
|
||||||
if (it != m_canvases.end())
|
|
||||||
it->second->register_action_more_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas3DManager::register_action_fewer_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
|
||||||
if (it != m_canvases.end())
|
|
||||||
it->second->register_action_fewer_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas3DManager::register_action_split_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
|
||||||
if (it != m_canvases.end())
|
|
||||||
it->second->register_action_split_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas3DManager::register_action_cut_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
|
||||||
if (it != m_canvases.end())
|
|
||||||
it->second->register_action_cut_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas3DManager::register_action_settings_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
|
||||||
if (it != m_canvases.end())
|
|
||||||
it->second->register_action_settings_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas3DManager::register_action_layersediting_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
|
||||||
if (it != m_canvases.end())
|
|
||||||
it->second->register_action_layersediting_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas3DManager::register_action_selectbyparts_callback(wxGLCanvas* canvas, void* callback)
|
|
||||||
{
|
|
||||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
|
||||||
if (it != m_canvases.end())
|
|
||||||
it->second->register_action_selectbyparts_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GLCanvas3DManager::can_multisample()
|
|
||||||
{
|
|
||||||
int wxVersion = wxMAJOR_VERSION * 10000 + wxMINOR_VERSION * 100 + wxRELEASE_NUMBER;
|
|
||||||
const AppConfig* app_config = GUI::get_app_config();
|
|
||||||
bool enable_multisample = app_config != nullptr
|
|
||||||
&& app_config->get("use_legacy_opengl") != "1"
|
|
||||||
&& wxVersion >= 30003;
|
|
||||||
|
|
||||||
// if multisample is not enabled or supported by the graphic card, remove it from the attributes list
|
|
||||||
return enable_multisample && wxGLCanvas::IsExtensionSupported("WGL_ARB_multisample");
|
|
||||||
// <<< Alternative method: but IsDisplaySupported() seems not to work
|
|
||||||
// bool return enable_multisample && wxGLCanvas::IsDisplaySupported(attribList);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxGLCanvas* GLCanvas3DManager::create_wxglcanvas(wxWindow *parent)
|
wxGLCanvas* GLCanvas3DManager::create_wxglcanvas(wxWindow *parent)
|
||||||
{
|
{
|
||||||
int attribList[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_DEPTH_SIZE, 24, WX_GL_SAMPLE_BUFFERS, GL_TRUE, WX_GL_SAMPLES, 4, 0 };
|
int attribList[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_DEPTH_SIZE, 24, WX_GL_SAMPLE_BUFFERS, GL_TRUE, WX_GL_SAMPLES, 4, 0 };
|
||||||
|
|
||||||
|
if (s_multisample == MS_Unknown)
|
||||||
|
{
|
||||||
|
_detect_multisample(attribList);
|
||||||
|
// debug output
|
||||||
|
std::cout << "Multisample " << (can_multisample() ? "enabled" : "disabled") << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
if (! can_multisample()) {
|
if (! can_multisample()) {
|
||||||
attribList[4] = 0;
|
attribList[4] = 0;
|
||||||
}
|
}
|
||||||
@ -870,5 +623,18 @@ bool GLCanvas3DManager::_init(GLCanvas3D& canvas)
|
|||||||
return canvas.init(m_use_VBOs, m_use_legacy_opengl);
|
return canvas.init(m_use_VBOs, m_use_legacy_opengl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GLCanvas3DManager::_detect_multisample(int* attribList)
|
||||||
|
{
|
||||||
|
int wxVersion = wxMAJOR_VERSION * 10000 + wxMINOR_VERSION * 100 + wxRELEASE_NUMBER;
|
||||||
|
const AppConfig* app_config = GUI::get_app_config();
|
||||||
|
bool enable_multisample = app_config != nullptr
|
||||||
|
&& app_config->get("use_legacy_opengl") != "1"
|
||||||
|
&& wxVersion >= 30003;
|
||||||
|
|
||||||
|
s_multisample = (enable_multisample && wxGLCanvas::IsDisplaySupported(attribList)) ? MS_Enabled : MS_Disabled;
|
||||||
|
// Alternative method: it was working on previous version of wxWidgets but not with the latest, at least on Windows
|
||||||
|
// s_multisample = enable_multisample && wxGLCanvas::IsExtensionSupported("WGL_ARB_multisample");
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace GUI
|
} // namespace GUI
|
||||||
} // namespace Slic3r
|
} // namespace Slic3r
|
||||||
|
@ -20,7 +20,7 @@ typedef std::vector<ExPolygon> ExPolygons;
|
|||||||
class ModelObject;
|
class ModelObject;
|
||||||
class PrintObject;
|
class PrintObject;
|
||||||
class GCodePreviewData;
|
class GCodePreviewData;
|
||||||
|
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
|
|
||||||
class GLCanvas3D;
|
class GLCanvas3D;
|
||||||
@ -42,6 +42,13 @@ class GLCanvas3DManager
|
|||||||
std::string to_string(bool format_as_html, bool extensions) const;
|
std::string to_string(bool format_as_html, bool extensions) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum EMultisampleState : unsigned char
|
||||||
|
{
|
||||||
|
MS_Unknown,
|
||||||
|
MS_Enabled,
|
||||||
|
MS_Disabled
|
||||||
|
};
|
||||||
|
|
||||||
typedef std::map<wxGLCanvas*, GLCanvas3D*> CanvasesMap;
|
typedef std::map<wxGLCanvas*, GLCanvas3D*> CanvasesMap;
|
||||||
|
|
||||||
CanvasesMap m_canvases;
|
CanvasesMap m_canvases;
|
||||||
@ -50,6 +57,7 @@ class GLCanvas3DManager
|
|||||||
bool m_gl_initialized;
|
bool m_gl_initialized;
|
||||||
bool m_use_legacy_opengl;
|
bool m_use_legacy_opengl;
|
||||||
bool m_use_VBOs;
|
bool m_use_VBOs;
|
||||||
|
static EMultisampleState s_multisample;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GLCanvas3DManager();
|
GLCanvas3DManager();
|
||||||
@ -146,54 +154,17 @@ public:
|
|||||||
void load_gcode_preview(wxGLCanvas* canvas, const GCodePreviewData* preview_data, const std::vector<std::string>& str_tool_colors);
|
void load_gcode_preview(wxGLCanvas* canvas, const GCodePreviewData* preview_data, const std::vector<std::string>& str_tool_colors);
|
||||||
void load_preview(wxGLCanvas* canvas, const std::vector<std::string>& str_tool_colors);
|
void load_preview(wxGLCanvas* canvas, const std::vector<std::string>& str_tool_colors);
|
||||||
|
|
||||||
void reset_legend_texture();
|
void reset_legend_texture(wxGLCanvas* canvas);
|
||||||
|
|
||||||
void register_on_viewport_changed_callback(wxGLCanvas* canvas, void* callback);
|
static bool can_multisample() { return s_multisample == MS_Enabled; }
|
||||||
void register_on_double_click_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
void register_on_right_click_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
void register_on_select_object_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
void register_on_model_update_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
void register_on_remove_object_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
void register_on_arrange_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
void register_on_rotate_object_left_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
void register_on_rotate_object_right_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
void register_on_scale_object_uniformly_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
void register_on_increase_objects_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
void register_on_decrease_objects_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
void register_on_instance_moved_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
void register_on_wipe_tower_moved_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
void register_on_enable_action_buttons_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
|
||||||
void register_on_gizmo_scale_3D_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
void register_on_gizmo_rotate_3D_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
void register_on_gizmo_flatten_3D_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
void register_on_update_geometry_3D_info_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
#else
|
|
||||||
void register_on_gizmo_scale_uniformly_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
void register_on_gizmo_rotate_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
void register_on_gizmo_flatten_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
void register_on_update_geometry_info_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
|
||||||
|
|
||||||
void register_action_add_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
void register_action_delete_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
void register_action_deleteall_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
void register_action_arrange_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
void register_action_more_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
void register_action_fewer_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
void register_action_split_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
void register_action_cut_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
void register_action_settings_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
void register_action_layersediting_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
void register_action_selectbyparts_callback(wxGLCanvas* canvas, void* callback);
|
|
||||||
|
|
||||||
static bool can_multisample();
|
|
||||||
static wxGLCanvas* create_wxglcanvas(wxWindow *parent);
|
static wxGLCanvas* create_wxglcanvas(wxWindow *parent);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CanvasesMap::iterator _get_canvas(wxGLCanvas* canvas);
|
CanvasesMap::iterator _get_canvas(wxGLCanvas* canvas);
|
||||||
CanvasesMap::const_iterator _get_canvas(wxGLCanvas* canvas) const;
|
CanvasesMap::const_iterator _get_canvas(wxGLCanvas* canvas) const;
|
||||||
|
|
||||||
bool _init(GLCanvas3D& canvas);
|
bool _init(GLCanvas3D& canvas);
|
||||||
|
static void _detect_multisample(int* attribList);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace GUI
|
} // namespace GUI
|
||||||
|
@ -16,9 +16,18 @@ namespace Slic3r {
|
|||||||
namespace GUI {
|
namespace GUI {
|
||||||
|
|
||||||
|
|
||||||
wxDEFINE_EVENT(EVT_GLTOOLBAR_ADD, wxCommandEvent);
|
wxDEFINE_EVENT(EVT_GLTOOLBAR_ADD, SimpleEvent);
|
||||||
wxDEFINE_EVENT(EVT_GLTOOLBAR_DELETE, wxCommandEvent);
|
wxDEFINE_EVENT(EVT_GLTOOLBAR_DELETE, SimpleEvent);
|
||||||
wxDEFINE_EVENT(EVT_GLTOOLBAR_TODO_MORE, wxCommandEvent);
|
wxDEFINE_EVENT(EVT_GLTOOLBAR_DELETE_ALL, SimpleEvent);
|
||||||
|
wxDEFINE_EVENT(EVT_GLTOOLBAR_ARRANGE, SimpleEvent);
|
||||||
|
wxDEFINE_EVENT(EVT_GLTOOLBAR_MORE, SimpleEvent);
|
||||||
|
wxDEFINE_EVENT(EVT_GLTOOLBAR_FEWER, SimpleEvent);
|
||||||
|
wxDEFINE_EVENT(EVT_GLTOOLBAR_SPLIT, SimpleEvent);
|
||||||
|
wxDEFINE_EVENT(EVT_GLTOOLBAR_CUT, SimpleEvent);
|
||||||
|
wxDEFINE_EVENT(EVT_GLTOOLBAR_SETTINGS, SimpleEvent);
|
||||||
|
wxDEFINE_EVENT(EVT_GLTOOLBAR_LAYERSEDITING, SimpleEvent);
|
||||||
|
wxDEFINE_EVENT(EVT_GLTOOLBAR_SELECTBYPARTS, SimpleEvent);
|
||||||
|
|
||||||
|
|
||||||
GLToolbarItem::Data::Data()
|
GLToolbarItem::Data::Data()
|
||||||
: name("")
|
: name("")
|
||||||
@ -57,10 +66,7 @@ const std::string& GLToolbarItem::get_tooltip() const
|
|||||||
|
|
||||||
void GLToolbarItem::do_action(wxEvtHandler *target)
|
void GLToolbarItem::do_action(wxEvtHandler *target)
|
||||||
{
|
{
|
||||||
// if (m_data.action_callback != nullptr)
|
wxPostEvent(target, SimpleEvent(m_data.action_event));
|
||||||
// m_data.action_callback->call();
|
|
||||||
|
|
||||||
wxPostEvent(target, wxCommandEvent(m_data.action_event));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GLToolbarItem::is_enabled() const
|
bool GLToolbarItem::is_enabled() const
|
||||||
|
@ -5,10 +5,9 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <wx/event.h>
|
#include "GLTexture.hpp"
|
||||||
|
#include "Event.hpp"
|
||||||
|
|
||||||
#include "../../slic3r/GUI/GLTexture.hpp"
|
|
||||||
// #include "callback.hpp"
|
|
||||||
|
|
||||||
class wxEvtHandler;
|
class wxEvtHandler;
|
||||||
|
|
||||||
@ -17,9 +16,17 @@ namespace GUI {
|
|||||||
|
|
||||||
class GLCanvas3D;
|
class GLCanvas3D;
|
||||||
|
|
||||||
wxDECLARE_EVENT(EVT_GLTOOLBAR_ADD, wxCommandEvent);
|
wxDECLARE_EVENT(EVT_GLTOOLBAR_ADD, SimpleEvent);
|
||||||
wxDECLARE_EVENT(EVT_GLTOOLBAR_DELETE, wxCommandEvent);
|
wxDECLARE_EVENT(EVT_GLTOOLBAR_DELETE, SimpleEvent);
|
||||||
wxDECLARE_EVENT(EVT_GLTOOLBAR_TODO_MORE, wxCommandEvent);
|
wxDECLARE_EVENT(EVT_GLTOOLBAR_DELETE_ALL, SimpleEvent);
|
||||||
|
wxDECLARE_EVENT(EVT_GLTOOLBAR_ARRANGE, SimpleEvent);
|
||||||
|
wxDECLARE_EVENT(EVT_GLTOOLBAR_MORE, SimpleEvent);
|
||||||
|
wxDECLARE_EVENT(EVT_GLTOOLBAR_FEWER, SimpleEvent);
|
||||||
|
wxDECLARE_EVENT(EVT_GLTOOLBAR_SPLIT, SimpleEvent);
|
||||||
|
wxDECLARE_EVENT(EVT_GLTOOLBAR_CUT, SimpleEvent);
|
||||||
|
wxDECLARE_EVENT(EVT_GLTOOLBAR_SETTINGS, SimpleEvent);
|
||||||
|
wxDECLARE_EVENT(EVT_GLTOOLBAR_LAYERSEDITING, SimpleEvent);
|
||||||
|
wxDECLARE_EVENT(EVT_GLTOOLBAR_SELECTBYPARTS, SimpleEvent);
|
||||||
|
|
||||||
class GLToolbarItem
|
class GLToolbarItem
|
||||||
{
|
{
|
||||||
@ -41,16 +48,12 @@ public:
|
|||||||
Num_States
|
Num_States
|
||||||
};
|
};
|
||||||
|
|
||||||
// typedef std::function<void()> Callback;
|
|
||||||
// typedef PerlCallback Callback;
|
|
||||||
|
|
||||||
struct Data
|
struct Data
|
||||||
{
|
{
|
||||||
std::string name;
|
std::string name;
|
||||||
std::string tooltip;
|
std::string tooltip;
|
||||||
unsigned int sprite_id;
|
unsigned int sprite_id;
|
||||||
bool is_toggable;
|
bool is_toggable;
|
||||||
// Callback *action_callback;
|
|
||||||
wxEventType action_event;
|
wxEventType action_event;
|
||||||
|
|
||||||
Data();
|
Data();
|
||||||
|
@ -1153,7 +1153,10 @@ void load_part( ModelObject* model_object,
|
|||||||
part_names.Add(new_volume->name);
|
part_names.Add(new_volume->name);
|
||||||
|
|
||||||
if (delta != Vec3d::Zero())
|
if (delta != Vec3d::Zero())
|
||||||
|
{
|
||||||
new_volume->mesh.translate((float)delta(0), (float)delta(1), (float)delta(2));
|
new_volume->mesh.translate((float)delta(0), (float)delta(1), (float)delta(2));
|
||||||
|
new_volume->get_convex_hull().translate((float)delta(0), (float)delta(1), (float)delta(2));
|
||||||
|
}
|
||||||
|
|
||||||
// set a default extruder value, since user can't add it manually
|
// set a default extruder value, since user can't add it manually
|
||||||
new_volume->config.set_key_value("extruder", new ConfigOptionInt(0));
|
new_volume->config.set_key_value("extruder", new ConfigOptionInt(0));
|
||||||
|
@ -58,22 +58,6 @@ bool Preview::init(wxNotebook* notebook, DynamicPrintConfig* config, Print* prin
|
|||||||
if (!Create(notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize))
|
if (!Create(notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// int attribList[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_DEPTH_SIZE, 24, WX_GL_SAMPLE_BUFFERS, GL_TRUE, WX_GL_SAMPLES, 4, 0 };
|
|
||||||
|
|
||||||
// int wxVersion = wxMAJOR_VERSION * 10000 + wxMINOR_VERSION * 100 + wxRELEASE_NUMBER;
|
|
||||||
// const AppConfig* app_config = GUI::get_app_config();
|
|
||||||
// bool enable_multisample = (app_config != nullptr) && (app_config->get("use_legacy_opengl") != "1") && (wxVersion >= 30003);
|
|
||||||
|
|
||||||
// // if multisample is not enabled or supported by the graphic card, remove it from the attributes list
|
|
||||||
// bool can_multisample = enable_multisample && wxGLCanvas::IsExtensionSupported("WGL_ARB_multisample");
|
|
||||||
// // bool can_multisample = enable_multisample && wxGLCanvas::IsDisplaySupported(attribList); // <<< Alternative method: but IsDisplaySupported() seems not to work
|
|
||||||
// if (!can_multisample)
|
|
||||||
// attribList[4] = 0;
|
|
||||||
|
|
||||||
// m_canvas = new wxGLCanvas(this, wxID_ANY, attribList);
|
|
||||||
// if (m_canvas == nullptr)
|
|
||||||
// return false;
|
|
||||||
|
|
||||||
m_canvas = GLCanvas3DManager::create_wxglcanvas(this);
|
m_canvas = GLCanvas3DManager::create_wxglcanvas(this);
|
||||||
|
|
||||||
_3DScene::add_canvas(m_canvas);
|
_3DScene::add_canvas(m_canvas);
|
||||||
@ -131,18 +115,18 @@ bool Preview::init(wxNotebook* notebook, DynamicPrintConfig* config, Print* prin
|
|||||||
|
|
||||||
wxBoxSizer* bottom_sizer = new wxBoxSizer(wxHORIZONTAL);
|
wxBoxSizer* bottom_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
bottom_sizer->Add(m_label_view_type, 0, wxALIGN_CENTER_VERTICAL, 5);
|
bottom_sizer->Add(m_label_view_type, 0, wxALIGN_CENTER_VERTICAL, 5);
|
||||||
bottom_sizer->Add(m_choice_view_type, 0, wxEXPAND | wxALL | wxALIGN_CENTER_VERTICAL, 5);
|
bottom_sizer->Add(m_choice_view_type, 0, wxEXPAND | wxALL, 5);
|
||||||
bottom_sizer->AddSpacer(10);
|
bottom_sizer->AddSpacer(10);
|
||||||
bottom_sizer->Add(m_label_show_features, 0, wxALIGN_CENTER_VERTICAL, 5);
|
bottom_sizer->Add(m_label_show_features, 0, wxALIGN_CENTER_VERTICAL, 5);
|
||||||
bottom_sizer->Add(m_combochecklist_features, 0, wxEXPAND | wxALL | wxALIGN_CENTER_VERTICAL, 5);
|
bottom_sizer->Add(m_combochecklist_features, 0, wxEXPAND | wxALL, 5);
|
||||||
bottom_sizer->AddSpacer(20);
|
bottom_sizer->AddSpacer(20);
|
||||||
bottom_sizer->Add(m_checkbox_travel, 0, wxEXPAND | wxALL | wxALIGN_CENTER_VERTICAL, 5);
|
bottom_sizer->Add(m_checkbox_travel, 0, wxEXPAND | wxALL, 5);
|
||||||
bottom_sizer->AddSpacer(10);
|
bottom_sizer->AddSpacer(10);
|
||||||
bottom_sizer->Add(m_checkbox_retractions, 0, wxEXPAND | wxALL | wxALIGN_CENTER_VERTICAL, 5);
|
bottom_sizer->Add(m_checkbox_retractions, 0, wxEXPAND | wxALL, 5);
|
||||||
bottom_sizer->AddSpacer(10);
|
bottom_sizer->AddSpacer(10);
|
||||||
bottom_sizer->Add(m_checkbox_unretractions, 0, wxEXPAND | wxALL | wxALIGN_CENTER_VERTICAL, 5);
|
bottom_sizer->Add(m_checkbox_unretractions, 0, wxEXPAND | wxALL, 5);
|
||||||
bottom_sizer->AddSpacer(10);
|
bottom_sizer->AddSpacer(10);
|
||||||
bottom_sizer->Add(m_checkbox_shells, 0, wxEXPAND | wxALL | wxALIGN_CENTER_VERTICAL, 5);
|
bottom_sizer->Add(m_checkbox_shells, 0, wxEXPAND | wxALL, 5);
|
||||||
|
|
||||||
wxBoxSizer* main_sizer = new wxBoxSizer(wxVERTICAL);
|
wxBoxSizer* main_sizer = new wxBoxSizer(wxVERTICAL);
|
||||||
main_sizer->Add(top_sizer, 1, wxALL | wxEXPAND, 0);
|
main_sizer->Add(top_sizer, 1, wxALL | wxEXPAND, 0);
|
||||||
@ -186,12 +170,6 @@ Preview::~Preview()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preview::register_on_viewport_changed_callback(void* callback)
|
|
||||||
{
|
|
||||||
if ((m_canvas != nullptr) && (callback != nullptr))
|
|
||||||
_3DScene::register_on_viewport_changed_callback(m_canvas, callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Preview::set_number_extruders(unsigned int number_extruders)
|
void Preview::set_number_extruders(unsigned int number_extruders)
|
||||||
{
|
{
|
||||||
if (m_number_extruders != number_extruders)
|
if (m_number_extruders != number_extruders)
|
||||||
@ -214,7 +192,8 @@ void Preview::set_number_extruders(unsigned int number_extruders)
|
|||||||
void Preview::reset_gcode_preview_data()
|
void Preview::reset_gcode_preview_data()
|
||||||
{
|
{
|
||||||
m_gcode_preview_data->reset();
|
m_gcode_preview_data->reset();
|
||||||
_3DScene::reset_legend_texture();
|
if (m_canvas != nullptr)
|
||||||
|
_3DScene::reset_legend_texture(m_canvas);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preview::set_canvas_as_dirty()
|
void Preview::set_canvas_as_dirty()
|
||||||
@ -290,10 +269,11 @@ void Preview::load_print()
|
|||||||
if (n_layers == 0)
|
if (n_layers == 0)
|
||||||
{
|
{
|
||||||
reset_sliders();
|
reset_sliders();
|
||||||
_3DScene::reset_legend_texture();
|
if (m_canvas != nullptr)
|
||||||
if (m_canvas)
|
{
|
||||||
|
_3DScene::reset_legend_texture(m_canvas);
|
||||||
m_canvas->Refresh();
|
m_canvas->Refresh();
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,8 @@ public:
|
|||||||
Preview(wxNotebook* notebook, DynamicPrintConfig* config, Print* print, GCodePreviewData* gcode_preview_data);
|
Preview(wxNotebook* notebook, DynamicPrintConfig* config, Print* print, GCodePreviewData* gcode_preview_data);
|
||||||
virtual ~Preview();
|
virtual ~Preview();
|
||||||
|
|
||||||
void register_on_viewport_changed_callback(void* callback);
|
wxGLCanvas* get_canvas() { return m_canvas; }
|
||||||
|
|
||||||
void set_number_extruders(unsigned int number_extruders);
|
void set_number_extruders(unsigned int number_extruders);
|
||||||
void reset_gcode_preview_data();
|
void reset_gcode_preview_data();
|
||||||
void set_canvas_as_dirty();
|
void set_canvas_as_dirty();
|
||||||
@ -64,7 +65,7 @@ public:
|
|||||||
void load_print();
|
void load_print();
|
||||||
void reload_print(bool force = false);
|
void reload_print(bool force = false);
|
||||||
void refresh_print();
|
void refresh_print();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool init(wxNotebook* notebook, DynamicPrintConfig* config, Print* print, GCodePreviewData* gcode_preview_data);
|
bool init(wxNotebook* notebook, DynamicPrintConfig* config, Print* print, GCodePreviewData* gcode_preview_data);
|
||||||
|
|
||||||
|
@ -4,11 +4,6 @@
|
|||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
|
|
||||||
void PreviewIface::register_on_viewport_changed_callback(void* callback)
|
|
||||||
{
|
|
||||||
m_preview->register_on_viewport_changed_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void PreviewIface::set_number_extruders(unsigned int number_extruders)
|
void PreviewIface::set_number_extruders(unsigned int number_extruders)
|
||||||
{
|
{
|
||||||
m_preview->set_number_extruders(number_extruders);
|
m_preview->set_number_extruders(number_extruders);
|
||||||
|
@ -19,7 +19,6 @@ class PreviewIface
|
|||||||
public:
|
public:
|
||||||
explicit PreviewIface(GUI::Preview* preview) : m_preview(preview) {}
|
explicit PreviewIface(GUI::Preview* preview) : m_preview(preview) {}
|
||||||
|
|
||||||
void register_on_viewport_changed_callback(void* callback);
|
|
||||||
void set_number_extruders(unsigned int number_extruders);
|
void set_number_extruders(unsigned int number_extruders);
|
||||||
void reset_gcode_preview_data();
|
void reset_gcode_preview_data();
|
||||||
void reload_print(bool force = false);
|
void reload_print(bool force = false);
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#include "Plater.hpp"
|
#include "Plater.hpp"
|
||||||
|
|
||||||
#include <iostream> // XXX
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@ -30,6 +29,7 @@
|
|||||||
#include "GUI_App.hpp"
|
#include "GUI_App.hpp"
|
||||||
#include "MainFrame.hpp"
|
#include "MainFrame.hpp"
|
||||||
#include "3DScene.hpp"
|
#include "3DScene.hpp"
|
||||||
|
#include "GLCanvas3D.hpp"
|
||||||
#include "GUI_ObjectParts.hpp"
|
#include "GUI_ObjectParts.hpp"
|
||||||
#include "GLToolbar.hpp"
|
#include "GLToolbar.hpp"
|
||||||
#include "GUI_Preview.hpp"
|
#include "GUI_Preview.hpp"
|
||||||
@ -285,7 +285,6 @@ Sidebar::Sidebar(wxWindow *parent)
|
|||||||
p->btn_send_gcode->SetBitmap(arrow_up);
|
p->btn_send_gcode->SetBitmap(arrow_up);
|
||||||
p->btn_send_gcode->Hide();
|
p->btn_send_gcode->Hide();
|
||||||
auto *btns_sizer_scrolled = new wxBoxSizer(wxHORIZONTAL);
|
auto *btns_sizer_scrolled = new wxBoxSizer(wxHORIZONTAL);
|
||||||
std::cerr << "btns_sizer_scrolled: " << btns_sizer_scrolled << std::endl;
|
|
||||||
btns_sizer_scrolled->Add(p->btn_send_gcode);
|
btns_sizer_scrolled->Add(p->btn_send_gcode);
|
||||||
|
|
||||||
// Info boxes
|
// Info boxes
|
||||||
@ -297,7 +296,6 @@ Sidebar::Sidebar(wxWindow *parent)
|
|||||||
scrolled_sizer->SetMinSize(320, -1);
|
scrolled_sizer->SetMinSize(320, -1);
|
||||||
p->scrolled->SetSizer(scrolled_sizer);
|
p->scrolled->SetSizer(scrolled_sizer);
|
||||||
p->scrolled->SetScrollbars(0, 1, 1, 1);
|
p->scrolled->SetScrollbars(0, 1, 1, 1);
|
||||||
std::cerr << "scrolled_sizer: " << scrolled_sizer << std::endl;
|
|
||||||
scrolled_sizer->Add(p->sizer_presets, 0, wxEXPAND | wxLEFT, 2);
|
scrolled_sizer->Add(p->sizer_presets, 0, wxEXPAND | wxLEFT, 2);
|
||||||
scrolled_sizer->Add(p->sizer_params, 1, wxEXPAND);
|
scrolled_sizer->Add(p->sizer_params, 1, wxEXPAND);
|
||||||
scrolled_sizer->Add(p->object_info, 0, wxEXPAND | wxTOP | wxLEFT, 20);
|
scrolled_sizer->Add(p->object_info, 0, wxEXPAND | wxTOP | wxLEFT, 20);
|
||||||
@ -311,12 +309,10 @@ Sidebar::Sidebar(wxWindow *parent)
|
|||||||
p->btn_reslice->SetFont(wxGetApp().bold_font());
|
p->btn_reslice->SetFont(wxGetApp().bold_font());
|
||||||
|
|
||||||
auto *btns_sizer = new wxBoxSizer(wxVERTICAL);
|
auto *btns_sizer = new wxBoxSizer(wxVERTICAL);
|
||||||
std::cerr << "btns_sizer: " << btns_sizer << std::endl;
|
|
||||||
btns_sizer->Add(p->btn_reslice, 0, wxEXPAND | wxTOP, 5);
|
btns_sizer->Add(p->btn_reslice, 0, wxEXPAND | wxTOP, 5);
|
||||||
btns_sizer->Add(p->btn_export_gcode, 0, wxEXPAND | wxTOP, 5);
|
btns_sizer->Add(p->btn_export_gcode, 0, wxEXPAND | wxTOP, 5);
|
||||||
|
|
||||||
auto *sizer = new wxBoxSizer(wxVERTICAL);
|
auto *sizer = new wxBoxSizer(wxVERTICAL);
|
||||||
std::cerr << "sizer: " << sizer << std::endl;
|
|
||||||
sizer->Add(p->scrolled, 1, wxEXPAND | wxTOP, 5);
|
sizer->Add(p->scrolled, 1, wxEXPAND | wxTOP, 5);
|
||||||
sizer->Add(btns_sizer, 0, wxEXPAND | wxLEFT, 20);
|
sizer->Add(btns_sizer, 0, wxEXPAND | wxLEFT, 20);
|
||||||
SetSizer(sizer);
|
SetSizer(sizer);
|
||||||
@ -459,7 +455,9 @@ struct Plater::priv
|
|||||||
void on_update_print_preview(wxCommandEvent &);
|
void on_update_print_preview(wxCommandEvent &);
|
||||||
void on_process_completed(wxCommandEvent &);
|
void on_process_completed(wxCommandEvent &);
|
||||||
void on_layer_editing_toggled(bool enable);
|
void on_layer_editing_toggled(bool enable);
|
||||||
void on_action_add(const wxCommandEvent&);
|
void on_action_add(SimpleEvent&);
|
||||||
|
|
||||||
|
void on_viewport_changed(SimpleEvent& evt);
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: multisample, see 3DScene.pm
|
// TODO: multisample, see 3DScene.pm
|
||||||
@ -523,8 +521,6 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame) :
|
|||||||
|
|
||||||
update();
|
update();
|
||||||
|
|
||||||
// TODO: Preview::register_on_viewport_changed_callback is Perl-only
|
|
||||||
|
|
||||||
auto *hsizer = new wxBoxSizer(wxHORIZONTAL);
|
auto *hsizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
hsizer->Add(notebook, 1, wxEXPAND | wxTOP, 1);
|
hsizer->Add(notebook, 1, wxEXPAND | wxTOP, 1);
|
||||||
hsizer->Add(sidebar, 0, wxEXPAND | wxLEFT | wxRIGHT, 0);
|
hsizer->Add(sidebar, 0, wxEXPAND | wxLEFT | wxRIGHT, 0);
|
||||||
@ -546,10 +542,11 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame) :
|
|||||||
});
|
});
|
||||||
|
|
||||||
// 3DScene events:
|
// 3DScene events:
|
||||||
// TODO: (?)
|
// TODO: more
|
||||||
// on_layer_editing_toggled
|
|
||||||
// on_action_add
|
|
||||||
canvas3D->Bind(EVT_GLTOOLBAR_ADD, &priv::on_action_add, this);
|
canvas3D->Bind(EVT_GLTOOLBAR_ADD, &priv::on_action_add, this);
|
||||||
|
canvas3D->Bind(EVT_GLCANVAS_VIEWPORT_CHANGED, &priv::on_viewport_changed, this);
|
||||||
|
|
||||||
|
preview->get_canvas()->Bind(EVT_GLCANVAS_VIEWPORT_CHANGED, &priv::on_viewport_changed, this);
|
||||||
|
|
||||||
q->Bind(EVT_SLICING_COMPLETED, &priv::on_update_print_preview, this);
|
q->Bind(EVT_SLICING_COMPLETED, &priv::on_update_print_preview, this);
|
||||||
q->Bind(EVT_PROCESS_COMPLETED, &priv::on_process_completed, this);
|
q->Bind(EVT_PROCESS_COMPLETED, &priv::on_process_completed, this);
|
||||||
@ -593,7 +590,6 @@ std::vector<int> Plater::priv::collect_selections()
|
|||||||
|
|
||||||
void Plater::priv::update(bool force_autocenter)
|
void Plater::priv::update(bool force_autocenter)
|
||||||
{
|
{
|
||||||
|
|
||||||
wxWindowUpdateLocker freeze_guard(q);
|
wxWindowUpdateLocker freeze_guard(q);
|
||||||
if (get_config("autocenter") == "1" || force_autocenter) {
|
if (get_config("autocenter") == "1" || force_autocenter) {
|
||||||
// auto *bed_shape_opt = config->opt<ConfigOptionPoints>("bed_shape");
|
// auto *bed_shape_opt = config->opt<ConfigOptionPoints>("bed_shape");
|
||||||
@ -902,7 +898,7 @@ void Plater::priv::on_layer_editing_toggled(bool enable)
|
|||||||
canvas3D->Update();
|
canvas3D->Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Plater::priv::on_action_add(const wxCommandEvent&)
|
void Plater::priv::on_action_add(SimpleEvent&)
|
||||||
{
|
{
|
||||||
wxArrayString input_files;
|
wxArrayString input_files;
|
||||||
wxGetApp().open_model(q, input_files);
|
wxGetApp().open_model(q, input_files);
|
||||||
@ -914,6 +910,15 @@ void Plater::priv::on_action_add(const wxCommandEvent&)
|
|||||||
load_files(input_paths);
|
load_files(input_paths);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Plater::priv::on_viewport_changed(SimpleEvent& evt)
|
||||||
|
{
|
||||||
|
wxObject* o = evt.GetEventObject();
|
||||||
|
if (o == preview->get_canvas())
|
||||||
|
preview->set_viewport_into_scene(canvas3D);
|
||||||
|
else if (o == canvas3D)
|
||||||
|
preview->set_viewport_from_scene(canvas3D);
|
||||||
|
}
|
||||||
|
|
||||||
// Plater / Public
|
// Plater / Public
|
||||||
|
|
||||||
Plater::Plater(wxWindow *parent, MainFrame *main_frame)
|
Plater::Plater(wxWindow *parent, MainFrame *main_frame)
|
||||||
|
Loading…
Reference in New Issue
Block a user