#ifndef slic3r_SurfaceDrag_hpp_ #define slic3r_SurfaceDrag_hpp_ #include #include "libslic3r/Point.hpp" // Vec2d, Transform3d #include "slic3r/Utils/RaycastManager.hpp" #include "wx/event.h" // wxMouseEvent namespace Slic3r { class GLVolume; } // namespace Slic3r namespace Slic3r::GUI { class GLCanvas3D; class Selection; struct Camera; // Data for drag&drop over surface with mouse struct SurfaceDrag { // hold screen coor offset of cursor from object center Vec2d mouse_offset; // Start dragging text transformations to world Transform3d world; // Invers transformation of text volume instance // Help convert world transformation to instance space Transform3d instance_inv; // Dragged gl volume GLVolume *gl_volume; // condition for raycaster RaycastManager::AllowVolumes condition; // initial rotation in Z axis of volume std::optional start_angle; // Flag whether coordinate hit some volume bool exist_hit = true; }; // Limit direction of up vector on model // Between side and top surface constexpr double up_limit = 0.9; /// /// Mouse event handler, when move(drag&drop) volume over model surface /// NOTE: Dragged volume has to be selected. And also has to be hovered on start of dragging. /// /// Contain type of event and mouse position /// Actual viewport of camera /// Structure which keep information about dragging /// Contain gl_volumes and selection /// AABB trees for raycast in object /// Refresh state inside of function /// When set than use correction of up vector /// True when event is processed otherwise false bool on_mouse_surface_drag(const wxMouseEvent &mouse_event, const Camera &camera, std::optional &surface_drag, GLCanvas3D &canvas, RaycastManager &raycast_manager, std::optional up_limit = {}); /// /// Calculate translation of volume onto surface of model /// /// Must contain only one selected volume, Transformation of current instance /// AABB trees of object. Actualize object /// Offset of volume in volume coordinate std::optional calc_surface_offset(const Selection &selection, RaycastManager &raycast_manager); /// /// Get transformation to world /// - use fix after store to 3mf when exists /// /// Scene volume /// To identify Model volume with fix transformation /// Fixed Transformation of gl_volume Transform3d world_matrix_fixed(const GLVolume &gl_volume, const ModelObjectPtrs& objects); /// /// Get transformation to world /// - use fix after store to 3mf when exists /// NOTE: when not one volume selected return identity /// /// Selected volume /// Fixed Transformation of selected volume in selection Transform3d world_matrix_fixed(const Selection &selection); /// /// Apply camera direction for emboss direction /// /// Define view vector /// Containe Selected ModelVolume to modify orientation /// True when apply change otherwise false bool face_selected_volume_to_camera(const Camera &camera, GLCanvas3D &canvas); /// /// Rotation around z Axis(emboss direction) /// /// Selected volume for rotation /// Relative angle to rotate around emboss direction void do_local_z_rotate(GLCanvas3D &canvas, double relative_angle); /// /// Translation along local z Axis (emboss direction) /// /// Selected volume for translate /// Relative move along emboss direction void do_local_z_move(GLCanvas3D &canvas, double relative_move); } // namespace Slic3r::GUI #endif // slic3r_SurfaceDrag_hpp_