#ifndef slic3r_GLGizmoSVG_hpp_ #define slic3r_GLGizmoSVG_hpp_ // Include GLGizmoBase.hpp before I18N.hpp as it includes some libigl code, // which overrides our localization "L" macro. #include "GLGizmoBase.hpp" #include "GLGizmoRotate.hpp" #include "slic3r/GUI/SurfaceDrag.hpp" #include "slic3r/Utils/RaycastManager.hpp" #include #include #include #include "libslic3r/Emboss.hpp" #include "libslic3r/Point.hpp" #include "libslic3r/Model.hpp" #include #include namespace Slic3r{ //class AppConfig; class GLVolume; class ModelVolume; enum class ModelVolumeType : int; } namespace Slic3r::GUI { class GLGizmoSVG : public GLGizmoBase { public: GLGizmoSVG(GLCanvas3D &parent); /// /// Create new embossed text volume by type on position of mouse /// /// Object part / Negative volume / Modifier /// Define position of new volume /// True on succesfull start creation otherwise False bool create_volume(ModelVolumeType volume_type, const Vec2d &mouse_pos); // first open file dialog /// /// Create new text without given position /// /// Object part / Negative volume / Modifier /// True on succesfull start creation otherwise False bool create_volume(ModelVolumeType volume_type); // first open file dialog /// /// Check whether volume is object containing only emboss volume /// /// Pointer to volume /// True when object otherwise False static bool is_svg_object(const ModelVolume &volume); /// /// Check whether volume has emboss data /// /// Pointer to volume /// True when constain emboss data otherwise False static bool is_svg(const ModelVolume &volume); protected: bool on_init() override; std::string on_get_name() const override; void on_render() override; void on_register_raycasters_for_picking() override; void on_unregister_raycasters_for_picking() override; void on_render_input_window(float x, float y, float bottom_limit) override; bool on_is_activable() const override { return true; } bool on_is_selectable() const override { return false; } void on_set_state() override; void data_changed(bool is_serializing) override; // selection changed void on_set_hover_id() override{ m_rotate_gizmo.set_hover_id(m_hover_id); } void on_enable_grabber(unsigned int id) override { m_rotate_gizmo.enable_grabber(); } void on_disable_grabber(unsigned int id) override { m_rotate_gizmo.disable_grabber(); } void on_start_dragging() override; void on_stop_dragging() override; void on_dragging(const UpdateData &data) override; /// /// Rotate by text on dragging rotate grabers /// /// Information about mouse /// Propagete normaly return false. bool on_mouse(const wxMouseEvent &mouse_event) override; bool wants_enter_leave_snapshots() const override; std::string get_gizmo_entering_text() const override; std::string get_gizmo_leaving_text() const override; std::string get_action_snapshot_name() const override; private: void set_volume_by_selection(); void reset_volume(); // create volume from text - main functionality bool process(); void close(); void draw_window(); void draw_distance(); void draw_rotation(); void draw_model_type(); // process mouse event bool on_mouse_for_rotation(const wxMouseEvent &mouse_event); bool on_mouse_for_translate(const wxMouseEvent &mouse_event); // This configs holds GUI layout size given by translated texts. // etc. When language changes, GUI is recreated and this class constructed again, // so the change takes effect. (info by GLGizmoFdmSupports.hpp) struct GuiCfg { // Detect invalid config values when change monitor DPI double screen_scale; float main_toolbar_height; // Zero means it is calculated in init function ImVec2 minimal_window_size = ImVec2(0, 0); float input_width = 0.f; float input_offset = 0.f; // Only translations needed for calc GUI size struct Translations { std::string font; }; Translations translations; }; std::optional m_gui_cfg; static GuiCfg create_gui_configuration(); // actual selected only one volume - with emboss data ModelVolume *m_volume; // When work with undo redo stack there could be situation that // m_volume point to unexisting volume so One need also objectID ObjectID m_volume_id; // cancel for previous update of volume to cancel finalize part std::shared_ptr> m_job_cancel; // Rotation gizmo GLGizmoRotate m_rotate_gizmo; std::optional m_angle; std::optional m_distance; // Value is set only when dragging rotation to calculate actual angle std::optional m_rotate_start_angle; // TODO: it should be accessible by other gizmo too. // May be move to plater? RaycastManager m_raycast_manager; // When true keep up vector otherwise relative rotation bool m_keep_up = true; // setted only when wanted to use - not all the time std::optional m_set_window_offset; // Keep data about dragging only during drag&drop std::optional m_surface_drag; // For volume on scaled objects std::optional m_scale_height; std::optional m_scale_depth; void calculate_scale(); // only temporary solution static const std::string M_ICON_FILENAME; }; } // namespace Slic3r::GUI #endif // slic3r_GLGizmoSVG_hpp_