mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-31 04:31:15 -06:00 
			
		
		
		
	Tech ENABLE_SVG_ICONS set as default
This commit is contained in:
		
							parent
							
								
									5cbaa7b081
								
							
						
					
					
						commit
						cc70c8dff9
					
				
					 22 changed files with 2 additions and 608 deletions
				
			
		|  | @ -132,18 +132,12 @@ void GLGizmoBase::Grabber::render_face(float half_size) const | |||
|     glsafe(::glEnd()); | ||||
| } | ||||
| 
 | ||||
| #if ENABLE_SVG_ICONS | ||||
| GLGizmoBase::GLGizmoBase(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id) | ||||
| #else | ||||
| GLGizmoBase::GLGizmoBase(GLCanvas3D& parent, unsigned int sprite_id) | ||||
| #endif // ENABLE_SVG_ICONS
 | ||||
|     : m_parent(parent) | ||||
|     , m_group_id(-1) | ||||
|     , m_state(Off) | ||||
|     , m_shortcut_key(0) | ||||
| #if ENABLE_SVG_ICONS | ||||
|     , m_icon_filename(icon_filename) | ||||
| #endif // ENABLE_SVG_ICONS
 | ||||
|     , m_sprite_id(sprite_id) | ||||
|     , m_hover_id(-1) | ||||
|     , m_dragging(false) | ||||
|  |  | |||
|  | @ -89,9 +89,7 @@ protected: | |||
|     int m_group_id; | ||||
|     EState m_state; | ||||
|     int m_shortcut_key; | ||||
| #if ENABLE_SVG_ICONS | ||||
|     std::string m_icon_filename; | ||||
| #endif // ENABLE_SVG_ICONS
 | ||||
|     unsigned int m_sprite_id; | ||||
|     int m_hover_id; | ||||
|     bool m_dragging; | ||||
|  | @ -102,11 +100,7 @@ protected: | |||
|     ImGuiWrapper* m_imgui; | ||||
| 
 | ||||
| public: | ||||
| #if ENABLE_SVG_ICONS | ||||
|     GLGizmoBase(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id); | ||||
| #else | ||||
|     GLGizmoBase(GLCanvas3D& parent, unsigned int sprite_id); | ||||
| #endif // ENABLE_SVG_ICONS
 | ||||
|     virtual ~GLGizmoBase() {} | ||||
| 
 | ||||
|     bool init() { return on_init(); } | ||||
|  | @ -122,9 +116,7 @@ public: | |||
|     int get_shortcut_key() const { return m_shortcut_key; } | ||||
|     void set_shortcut_key(int key) { m_shortcut_key = key; } | ||||
| 
 | ||||
| #if ENABLE_SVG_ICONS | ||||
|     const std::string& get_icon_filename() const { return m_icon_filename; } | ||||
| #endif // ENABLE_SVG_ICONS
 | ||||
| 
 | ||||
|     bool is_activable(const Selection& selection) const { return on_is_activable(selection); } | ||||
|     bool is_selectable() const { return on_is_selectable(); } | ||||
|  |  | |||
|  | @ -19,13 +19,8 @@ const double GLGizmoCut::Offset = 10.0; | |||
| const double GLGizmoCut::Margin = 20.0; | ||||
| const std::array<float, 3> GLGizmoCut::GrabberColor = { 1.0, 0.5, 0.0 }; | ||||
| 
 | ||||
| #if ENABLE_SVG_ICONS | ||||
| GLGizmoCut::GLGizmoCut(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id) | ||||
|     : GLGizmoBase(parent, icon_filename, sprite_id) | ||||
| #else | ||||
| GLGizmoCut::GLGizmoCut(GLCanvas3D& parent, unsigned int sprite_id) | ||||
|     : GLGizmoBase(parent, sprite_id) | ||||
| #endif // ENABLE_SVG_ICONS
 | ||||
|     , m_cut_z(0.0) | ||||
|     , m_max_z(0.0) | ||||
|     , m_keep_upper(true) | ||||
|  |  | |||
|  | @ -23,11 +23,7 @@ class GLGizmoCut : public GLGizmoBase | |||
|     bool m_rotate_lower; | ||||
| 
 | ||||
| public: | ||||
| #if ENABLE_SVG_ICONS | ||||
|     GLGizmoCut(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id); | ||||
| #else | ||||
|     GLGizmoCut(GLCanvas3D& parent, unsigned int sprite_id); | ||||
| #endif // ENABLE_SVG_ICONS
 | ||||
| 
 | ||||
| protected: | ||||
|     virtual bool on_init(); | ||||
|  |  | |||
|  | @ -9,13 +9,8 @@ namespace Slic3r { | |||
| namespace GUI { | ||||
| 
 | ||||
| 
 | ||||
| #if ENABLE_SVG_ICONS | ||||
| GLGizmoFlatten::GLGizmoFlatten(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id) | ||||
|     : GLGizmoBase(parent, icon_filename, sprite_id) | ||||
| #else | ||||
| GLGizmoFlatten::GLGizmoFlatten(GLCanvas3D& parent, unsigned int sprite_id) | ||||
|     : GLGizmoBase(parent, sprite_id) | ||||
| #endif // ENABLE_SVG_ICONS
 | ||||
|     , m_normal(Vec3d::Zero()) | ||||
|     , m_starting_center(Vec3d::Zero()) | ||||
| { | ||||
|  |  | |||
|  | @ -37,11 +37,7 @@ private: | |||
|     bool is_plane_update_necessary() const; | ||||
| 
 | ||||
| public: | ||||
| #if ENABLE_SVG_ICONS | ||||
|     GLGizmoFlatten(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id); | ||||
| #else | ||||
|     GLGizmoFlatten(GLCanvas3D& parent, unsigned int sprite_id); | ||||
| #endif // ENABLE_SVG_ICONS
 | ||||
| 
 | ||||
|     void set_flattening_data(const ModelObject* model_object); | ||||
|     Vec3d get_flattening_normal() const; | ||||
|  |  | |||
|  | @ -10,13 +10,8 @@ namespace GUI { | |||
| 
 | ||||
| const double GLGizmoMove3D::Offset = 10.0; | ||||
| 
 | ||||
| #if ENABLE_SVG_ICONS | ||||
| GLGizmoMove3D::GLGizmoMove3D(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id) | ||||
|     : GLGizmoBase(parent, icon_filename, sprite_id) | ||||
| #else | ||||
| GLGizmoMove3D::GLGizmoMove3D(GLCanvas3D& parent, unsigned int sprite_id) | ||||
|     : GLGizmoBase(parent, sprite_id) | ||||
| #endif // ENABLE_SVG_ICONS
 | ||||
|     , m_displacement(Vec3d::Zero()) | ||||
|     , m_snap_step(1.0) | ||||
|     , m_starting_drag_position(Vec3d::Zero()) | ||||
|  |  | |||
|  | @ -22,11 +22,7 @@ class GLGizmoMove3D : public GLGizmoBase | |||
|     GLUquadricObj* m_quadric; | ||||
| 
 | ||||
| public: | ||||
| #if ENABLE_SVG_ICONS | ||||
|     GLGizmoMove3D(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id); | ||||
| #else | ||||
|     GLGizmoMove3D(GLCanvas3D& parent, unsigned int sprite_id); | ||||
| #endif // ENABLE_SVG_ICONS
 | ||||
|     virtual ~GLGizmoMove3D(); | ||||
| 
 | ||||
|     double get_snap_step(double step) const { return m_snap_step; } | ||||
|  |  | |||
|  | @ -19,11 +19,7 @@ const unsigned int GLGizmoRotate::SnapRegionsCount = 8; | |||
| const float GLGizmoRotate::GrabberOffset = 0.15f; // in percent of radius
 | ||||
| 
 | ||||
| GLGizmoRotate::GLGizmoRotate(GLCanvas3D& parent, GLGizmoRotate::Axis axis) | ||||
| #if ENABLE_SVG_ICONS | ||||
|     : GLGizmoBase(parent, "", -1) | ||||
| #else | ||||
|     : GLGizmoBase(parent, -1) | ||||
| #endif // ENABLE_SVG_ICONS
 | ||||
|     , m_axis(axis) | ||||
|     , m_angle(0.0) | ||||
|     , m_quadric(nullptr) | ||||
|  | @ -40,11 +36,7 @@ GLGizmoRotate::GLGizmoRotate(GLCanvas3D& parent, GLGizmoRotate::Axis axis) | |||
| } | ||||
| 
 | ||||
| GLGizmoRotate::GLGizmoRotate(const GLGizmoRotate& other) | ||||
| #if ENABLE_SVG_ICONS | ||||
|     : GLGizmoBase(other.m_parent, other.m_icon_filename, other.m_sprite_id) | ||||
| #else | ||||
|     : GLGizmoBase(other.m_parent, other.m_sprite_id) | ||||
| #endif // ENABLE_SVG_ICONS
 | ||||
|     , m_axis(other.m_axis) | ||||
|     , m_angle(other.m_angle) | ||||
|     , m_quadric(nullptr) | ||||
|  | @ -417,13 +409,8 @@ Vec3d GLGizmoRotate::mouse_position_in_local_plane(const Linef3& mouse_ray, cons | |||
|     return transform(mouse_ray, m).intersect_plane(0.0); | ||||
| } | ||||
| 
 | ||||
| #if ENABLE_SVG_ICONS | ||||
| GLGizmoRotate3D::GLGizmoRotate3D(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id) | ||||
|     : GLGizmoBase(parent, icon_filename, sprite_id) | ||||
| #else | ||||
| GLGizmoRotate3D::GLGizmoRotate3D(GLCanvas3D& parent, unsigned int sprite_id) | ||||
|     : GLGizmoBase(parent, sprite_id) | ||||
| #endif // ENABLE_SVG_ICONS
 | ||||
| { | ||||
|     m_gizmos.emplace_back(parent, GLGizmoRotate::X); | ||||
|     m_gizmos.emplace_back(parent, GLGizmoRotate::Y); | ||||
|  |  | |||
|  | @ -76,11 +76,7 @@ class GLGizmoRotate3D : public GLGizmoBase | |||
|     std::vector<GLGizmoRotate> m_gizmos; | ||||
| 
 | ||||
| public: | ||||
| #if ENABLE_SVG_ICONS | ||||
|     GLGizmoRotate3D(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id); | ||||
| #else | ||||
|     GLGizmoRotate3D(GLCanvas3D& parent, unsigned int sprite_id); | ||||
| #endif // ENABLE_SVG_ICONS
 | ||||
| 
 | ||||
|     Vec3d get_rotation() const { return Vec3d(m_gizmos[X].get_angle(), m_gizmos[Y].get_angle(), m_gizmos[Z].get_angle()); } | ||||
|     void set_rotation(const Vec3d& rotation) { m_gizmos[X].set_angle(rotation(0)); m_gizmos[Y].set_angle(rotation(1)); m_gizmos[Z].set_angle(rotation(2)); } | ||||
|  |  | |||
|  | @ -13,13 +13,8 @@ namespace GUI { | |||
| 
 | ||||
| const float GLGizmoScale3D::Offset = 5.0f; | ||||
| 
 | ||||
| #if ENABLE_SVG_ICONS | ||||
| GLGizmoScale3D::GLGizmoScale3D(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id) | ||||
|     : GLGizmoBase(parent, icon_filename, sprite_id) | ||||
| #else | ||||
| GLGizmoScale3D::GLGizmoScale3D(GLCanvas3D& parent, unsigned int sprite_id) | ||||
|     : GLGizmoBase(parent, sprite_id) | ||||
| #endif // ENABLE_SVG_ICONS
 | ||||
|     , m_scale(Vec3d::Ones()) | ||||
|     , m_offset(Vec3d::Zero()) | ||||
|     , m_snap_step(0.05) | ||||
|  |  | |||
|  | @ -32,11 +32,7 @@ class GLGizmoScale3D : public GLGizmoBase | |||
|     StartingData m_starting; | ||||
| 
 | ||||
| public: | ||||
| #if ENABLE_SVG_ICONS | ||||
|     GLGizmoScale3D(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id); | ||||
| #else | ||||
|     GLGizmoScale3D(GLCanvas3D& parent, unsigned int sprite_id); | ||||
| #endif // ENABLE_SVG_ICONS
 | ||||
| 
 | ||||
|     double get_snap_step(double step) const { return m_snap_step; } | ||||
|     void set_snap_step(double step) { m_snap_step = step; } | ||||
|  |  | |||
|  | @ -19,13 +19,8 @@ | |||
| namespace Slic3r { | ||||
| namespace GUI { | ||||
| 
 | ||||
| #if ENABLE_SVG_ICONS | ||||
| GLGizmoSlaSupports::GLGizmoSlaSupports(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id) | ||||
|     : GLGizmoBase(parent, icon_filename, sprite_id) | ||||
| #else | ||||
| GLGizmoSlaSupports::GLGizmoSlaSupports(GLCanvas3D& parent, unsigned int sprite_id) | ||||
|     : GLGizmoBase(parent, sprite_id) | ||||
| #endif // ENABLE_SVG_ICONS
 | ||||
|     , m_quadric(nullptr) | ||||
|     , m_its(nullptr) | ||||
| { | ||||
|  |  | |||
|  | @ -58,11 +58,7 @@ private: | |||
|     }; | ||||
| 
 | ||||
| public: | ||||
| #if ENABLE_SVG_ICONS | ||||
|     GLGizmoSlaSupports(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id); | ||||
| #else | ||||
|     GLGizmoSlaSupports(GLCanvas3D& parent, unsigned int sprite_id); | ||||
| #endif // ENABLE_SVG_ICONS
 | ||||
|     virtual ~GLGizmoSlaSupports(); | ||||
|     void set_sla_support_data(ModelObject* model_object, const Selection& selection); | ||||
|     bool gizmo_event(SLAGizmoEventType action, const Vec2d& mouse_position, bool shift_down, bool alt_down, bool control_down); | ||||
|  |  | |||
|  | @ -12,17 +12,12 @@ | |||
| namespace Slic3r { | ||||
| namespace GUI { | ||||
| 
 | ||||
| #if ENABLE_SVG_ICONS | ||||
|     const float GLGizmosManager::Default_Icons_Size = 64; | ||||
| #endif // ENABLE_SVG_ICONS
 | ||||
| const float GLGizmosManager::Default_Icons_Size = 64; | ||||
| 
 | ||||
| GLGizmosManager::GLGizmosManager() | ||||
|     : m_enabled(false) | ||||
| #if ENABLE_SVG_ICONS | ||||
|     , m_icons_texture_dirty(true) | ||||
| #endif // ENABLE_SVG_ICONS
 | ||||
|     , m_current(Undefined) | ||||
| #if ENABLE_SVG_ICONS | ||||
|     , m_overlay_icons_size(Default_Icons_Size) | ||||
|     , m_overlay_scale(1.0f) | ||||
|     , m_overlay_border(5.0f) | ||||
|  | @ -30,11 +25,6 @@ GLGizmosManager::GLGizmosManager() | |||
|     , m_tooltip("") | ||||
| { | ||||
| } | ||||
| #else | ||||
| { | ||||
|     set_overlay_scale(1.0); | ||||
| } | ||||
| #endif // ENABLE_SVG_ICONS
 | ||||
| 
 | ||||
| GLGizmosManager::~GLGizmosManager() | ||||
| { | ||||
|  | @ -43,20 +33,6 @@ GLGizmosManager::~GLGizmosManager() | |||
| 
 | ||||
| bool GLGizmosManager::init(GLCanvas3D& parent) | ||||
| { | ||||
| #if !ENABLE_SVG_ICONS | ||||
|     m_icons_texture.metadata.filename = "gizmos.png"; | ||||
|     m_icons_texture.metadata.icon_size = 64; | ||||
| 
 | ||||
|     if (!m_icons_texture.metadata.filename.empty()) | ||||
|     { | ||||
|         if (!m_icons_texture.texture.load_from_file(resources_dir() + "/icons/" + m_icons_texture.metadata.filename, false, true)) | ||||
|         { | ||||
|             reset(); | ||||
|             return false; | ||||
|         } | ||||
|     } | ||||
| #endif // !ENABLE_SVG_ICONS
 | ||||
| 
 | ||||
|     m_background_texture.metadata.filename = "toolbar_background.png"; | ||||
|     m_background_texture.metadata.left = 16; | ||||
|     m_background_texture.metadata.top = 16; | ||||
|  | @ -72,11 +48,7 @@ bool GLGizmosManager::init(GLCanvas3D& parent) | |||
|         } | ||||
|     } | ||||
| 
 | ||||
| #if ENABLE_SVG_ICONS | ||||
|     GLGizmoBase* gizmo = new GLGizmoMove3D(parent, "move.svg", 0); | ||||
| #else | ||||
|     GLGizmoBase* gizmo = new GLGizmoMove3D(parent, 0); | ||||
| #endif // ENABLE_SVG_ICONS
 | ||||
|     if (gizmo == nullptr) | ||||
|         return false; | ||||
| 
 | ||||
|  | @ -85,11 +57,7 @@ bool GLGizmosManager::init(GLCanvas3D& parent) | |||
| 
 | ||||
|     m_gizmos.insert(GizmosMap::value_type(Move, gizmo)); | ||||
| 
 | ||||
| #if ENABLE_SVG_ICONS | ||||
|     gizmo = new GLGizmoScale3D(parent, "scale.svg", 1); | ||||
| #else | ||||
|     gizmo = new GLGizmoScale3D(parent, 1); | ||||
| #endif // ENABLE_SVG_ICONS
 | ||||
|     if (gizmo == nullptr) | ||||
|         return false; | ||||
| 
 | ||||
|  | @ -98,11 +66,7 @@ bool GLGizmosManager::init(GLCanvas3D& parent) | |||
| 
 | ||||
|     m_gizmos.insert(GizmosMap::value_type(Scale, gizmo)); | ||||
| 
 | ||||
| #if ENABLE_SVG_ICONS | ||||
|     gizmo = new GLGizmoRotate3D(parent, "rotate.svg", 2); | ||||
| #else | ||||
|     gizmo = new GLGizmoRotate3D(parent, 2); | ||||
| #endif // ENABLE_SVG_ICONS
 | ||||
|     if (gizmo == nullptr) | ||||
|     { | ||||
|         reset(); | ||||
|  | @ -117,11 +81,7 @@ bool GLGizmosManager::init(GLCanvas3D& parent) | |||
| 
 | ||||
|     m_gizmos.insert(GizmosMap::value_type(Rotate, gizmo)); | ||||
| 
 | ||||
| #if ENABLE_SVG_ICONS | ||||
|     gizmo = new GLGizmoFlatten(parent, "place.svg", 3); | ||||
| #else | ||||
|     gizmo = new GLGizmoFlatten(parent, 3); | ||||
| #endif // ENABLE_SVG_ICONS
 | ||||
|     if (gizmo == nullptr) | ||||
|         return false; | ||||
| 
 | ||||
|  | @ -132,11 +92,7 @@ bool GLGizmosManager::init(GLCanvas3D& parent) | |||
| 
 | ||||
|     m_gizmos.insert(GizmosMap::value_type(Flatten, gizmo)); | ||||
| 
 | ||||
| #if ENABLE_SVG_ICONS | ||||
|     gizmo = new GLGizmoCut(parent, "cut.svg", 4); | ||||
| #else | ||||
|     gizmo = new GLGizmoCut(parent, 4); | ||||
| #endif // ENABLE_SVG_ICONS
 | ||||
|     if (gizmo == nullptr) | ||||
|         return false; | ||||
| 
 | ||||
|  | @ -147,11 +103,7 @@ bool GLGizmosManager::init(GLCanvas3D& parent) | |||
| 
 | ||||
|     m_gizmos.insert(GizmosMap::value_type(Cut, gizmo)); | ||||
| 
 | ||||
| #if ENABLE_SVG_ICONS | ||||
|     gizmo = new GLGizmoSlaSupports(parent, "sla_supports.svg", 5); | ||||
| #else | ||||
|     gizmo = new GLGizmoSlaSupports(parent, 5); | ||||
| #endif // ENABLE_SVG_ICONS
 | ||||
|     if (gizmo == nullptr) | ||||
|         return false; | ||||
| 
 | ||||
|  | @ -165,7 +117,6 @@ bool GLGizmosManager::init(GLCanvas3D& parent) | |||
|     return true; | ||||
| } | ||||
| 
 | ||||
| #if ENABLE_SVG_ICONS | ||||
| void GLGizmosManager::set_overlay_icon_size(float size) | ||||
| { | ||||
|     if (m_overlay_icons_size != size) | ||||
|  | @ -174,21 +125,14 @@ void GLGizmosManager::set_overlay_icon_size(float size) | |||
|         m_icons_texture_dirty = true; | ||||
|     } | ||||
| } | ||||
| #endif // ENABLE_SVG_ICONS
 | ||||
| 
 | ||||
| void GLGizmosManager::set_overlay_scale(float scale) | ||||
| { | ||||
| #if ENABLE_SVG_ICONS | ||||
|     if (m_overlay_scale != scale) | ||||
|     { | ||||
|         m_overlay_scale = scale; | ||||
|         m_icons_texture_dirty = true; | ||||
|     } | ||||
| #else | ||||
|     m_overlay_icons_scale = scale; | ||||
|     m_overlay_border = 5.0f * scale; | ||||
|     m_overlay_gap_y = 5.0f * scale; | ||||
| #endif // ENABLE_SVG_ICONS
 | ||||
| } | ||||
| 
 | ||||
| void GLGizmosManager::refresh_on_off_state(const Selection& selection) | ||||
|  | @ -526,10 +470,8 @@ void GLGizmosManager::render_overlay(const GLCanvas3D& canvas, const Selection& | |||
|     if (!m_enabled) | ||||
|         return; | ||||
| 
 | ||||
| #if ENABLE_SVG_ICONS | ||||
|     if (m_icons_texture_dirty) | ||||
|         generate_icons_texture(); | ||||
| #endif // ENABLE_SVG_ICONS
 | ||||
| 
 | ||||
|     do_render_overlay(canvas, selection); | ||||
| } | ||||
|  | @ -935,11 +877,7 @@ void GLGizmosManager::do_render_overlay(const GLCanvas3D& canvas, const Selectio | |||
| 
 | ||||
|     float height = get_total_overlay_height(); | ||||
|     float width = get_total_overlay_width(); | ||||
| #if ENABLE_SVG_ICONS | ||||
|     float scaled_border = m_overlay_border * m_overlay_scale * inv_zoom; | ||||
| #else | ||||
|     float scaled_border = m_overlay_border * inv_zoom; | ||||
| #endif // ENABLE_SVG_ICONS
 | ||||
| 
 | ||||
|     float top_x = (-0.5f * cnv_w) * inv_zoom; | ||||
|     float top_y = (0.5f * height) * inv_zoom; | ||||
|  | @ -1015,7 +953,6 @@ void GLGizmosManager::do_render_overlay(const GLCanvas3D& canvas, const Selectio | |||
|         } | ||||
|     } | ||||
| 
 | ||||
| #if ENABLE_SVG_ICONS | ||||
|     top_x += scaled_border; | ||||
|     top_y -= scaled_border; | ||||
|     float scaled_gap_y = m_overlay_gap_y * m_overlay_scale * inv_zoom; | ||||
|  | @ -1027,21 +964,9 @@ void GLGizmosManager::do_render_overlay(const GLCanvas3D& canvas, const Selectio | |||
|     unsigned int tex_height = m_icons_texture.get_height(); | ||||
|     float inv_tex_width = (tex_width != 0) ? 1.0f / (float)tex_width : 0.0f; | ||||
|     float inv_tex_height = (tex_height != 0) ? 1.0f / (float)tex_height : 0.0f; | ||||
| #else | ||||
|     top_x += m_overlay_border * inv_zoom; | ||||
|     top_y -= m_overlay_border * inv_zoom; | ||||
|     float scaled_gap_y = m_overlay_gap_y * inv_zoom; | ||||
| 
 | ||||
|     float scaled_icons_size = (float)m_icons_texture.metadata.icon_size * m_overlay_icons_scale * inv_zoom; | ||||
|     unsigned int icons_texture_id = m_icons_texture.texture.get_id(); | ||||
|     unsigned int texture_size = m_icons_texture.texture.get_width(); | ||||
|     float inv_texture_size = (texture_size != 0) ? 1.0f / (float)texture_size : 0.0f; | ||||
| #endif // ENABLE_SVG_ICONS
 | ||||
| 
 | ||||
| #if ENABLE_SVG_ICONS | ||||
|     if ((icons_texture_id == 0) || (tex_width <= 0) || (tex_height <= 0)) | ||||
|         return; | ||||
| #endif // ENABLE_SVG_ICONS
 | ||||
| 
 | ||||
|     for (GizmosMap::const_iterator it = m_gizmos.begin(); it != m_gizmos.end(); ++it) | ||||
|     { | ||||
|  | @ -1051,78 +976,44 @@ void GLGizmosManager::do_render_overlay(const GLCanvas3D& canvas, const Selectio | |||
|         unsigned int sprite_id = it->second->get_sprite_id(); | ||||
|         GLGizmoBase::EState state = it->second->get_state(); | ||||
| 
 | ||||
| #if ENABLE_SVG_ICONS | ||||
|         float u_icon_size = m_overlay_icons_size * m_overlay_scale * inv_tex_width; | ||||
|         float v_icon_size = m_overlay_icons_size * m_overlay_scale * inv_tex_height; | ||||
|         float v_top = sprite_id * v_icon_size; | ||||
|         float u_left = state * u_icon_size; | ||||
|         float v_bottom = v_top + v_icon_size; | ||||
|         float u_right = u_left + u_icon_size; | ||||
| #else | ||||
|         float uv_icon_size = (float)m_icons_texture.metadata.icon_size * inv_texture_size; | ||||
|         float v_top = sprite_id * uv_icon_size; | ||||
|         float u_left = state * uv_icon_size; | ||||
|         float v_bottom = v_top + uv_icon_size; | ||||
|         float u_right = u_left + uv_icon_size; | ||||
| #endif // ENABLE_SVG_ICONS
 | ||||
| 
 | ||||
|         GLTexture::render_sub_texture(icons_texture_id, top_x, top_x + scaled_icons_size, top_y - scaled_icons_size, top_y, { { u_left, v_bottom }, { u_right, v_bottom }, { u_right, v_top }, { u_left, v_top } }); | ||||
|         if (it->second->get_state() == GLGizmoBase::On) { | ||||
|             float toolbar_top = (float)cnv_h - canvas.get_view_toolbar_height(); | ||||
| #if ENABLE_SVG_ICONS | ||||
|             it->second->render_input_window(width, 0.5f * cnv_h - top_y * zoom, toolbar_top, selection); | ||||
| #else | ||||
|             it->second->render_input_window(2.0f * m_overlay_border + scaled_icons_size * zoom, 0.5f * cnv_h - top_y * zoom, toolbar_top, selection); | ||||
| #endif // ENABLE_SVG_ICONS
 | ||||
|         } | ||||
| #if ENABLE_SVG_ICONS | ||||
|         top_y -= scaled_stride_y; | ||||
| #else | ||||
|         top_y -= (scaled_icons_size + scaled_gap_y); | ||||
| #endif // ENABLE_SVG_ICONS
 | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| float GLGizmosManager::get_total_overlay_height() const | ||||
| { | ||||
| #if ENABLE_SVG_ICONS | ||||
|     float scaled_icons_size = m_overlay_icons_size * m_overlay_scale; | ||||
|     float scaled_border = m_overlay_border * m_overlay_scale; | ||||
|     float scaled_gap_y = m_overlay_gap_y * m_overlay_scale; | ||||
|     float scaled_stride_y = scaled_icons_size + scaled_gap_y; | ||||
|     float height = 2.0f * scaled_border; | ||||
| #else | ||||
|     float height = 2.0f * m_overlay_border; | ||||
| 
 | ||||
|     float scaled_icons_size = (float)m_icons_texture.metadata.icon_size * m_overlay_icons_scale; | ||||
| #endif // ENABLE_SVG_ICONS
 | ||||
| 
 | ||||
|     for (GizmosMap::const_iterator it = m_gizmos.begin(); it != m_gizmos.end(); ++it) | ||||
|     { | ||||
|         if ((it->second == nullptr) || !it->second->is_selectable()) | ||||
|             continue; | ||||
| 
 | ||||
| #if ENABLE_SVG_ICONS | ||||
|         height += scaled_stride_y; | ||||
| #else | ||||
|         height += (scaled_icons_size + m_overlay_gap_y); | ||||
| #endif // ENABLE_SVG_ICONS
 | ||||
|     } | ||||
| 
 | ||||
| #if ENABLE_SVG_ICONS | ||||
|     return height - scaled_gap_y; | ||||
| #else | ||||
|     return height - m_overlay_gap_y; | ||||
| #endif // ENABLE_SVG_ICONS
 | ||||
| } | ||||
| 
 | ||||
| float GLGizmosManager::get_total_overlay_width() const | ||||
| { | ||||
| #if ENABLE_SVG_ICONS | ||||
|     return (2.0f * m_overlay_border + m_overlay_icons_size) * m_overlay_scale; | ||||
| #else | ||||
|     return (float)m_icons_texture.metadata.icon_size * m_overlay_icons_scale + 2.0f * m_overlay_border; | ||||
| #endif // ENABLE_SVG_ICONS
 | ||||
| } | ||||
| 
 | ||||
| GLGizmoBase* GLGizmosManager::get_current() const | ||||
|  | @ -1131,7 +1022,6 @@ GLGizmoBase* GLGizmosManager::get_current() const | |||
|     return (it != m_gizmos.end()) ? it->second : nullptr; | ||||
| } | ||||
| 
 | ||||
| #if ENABLE_SVG_ICONS | ||||
| bool GLGizmosManager::generate_icons_texture() const | ||||
| { | ||||
|     std::string path = resources_dir() + "/icons/"; | ||||
|  | @ -1157,7 +1047,6 @@ bool GLGizmosManager::generate_icons_texture() const | |||
| 
 | ||||
|     return res; | ||||
| } | ||||
| #endif // ENABLE_SVG_ICONS
 | ||||
| 
 | ||||
| void GLGizmosManager::update_on_off_state(const GLCanvas3D& canvas, const Vec2d& mouse_pos, const Selection& selection) | ||||
| { | ||||
|  | @ -1167,27 +1056,18 @@ void GLGizmosManager::update_on_off_state(const GLCanvas3D& canvas, const Vec2d& | |||
|     float cnv_h = (float)canvas.get_canvas_size().get_height(); | ||||
|     float height = get_total_overlay_height(); | ||||
| 
 | ||||
| #if ENABLE_SVG_ICONS | ||||
|     float scaled_icons_size = m_overlay_icons_size * m_overlay_scale; | ||||
|     float scaled_border = m_overlay_border * m_overlay_scale; | ||||
|     float scaled_gap_y = m_overlay_gap_y * m_overlay_scale; | ||||
|     float scaled_stride_y = scaled_icons_size + scaled_gap_y; | ||||
|     float top_y = 0.5f * (cnv_h - height) + scaled_border; | ||||
| #else | ||||
|     float top_y = 0.5f * (cnv_h - height) + m_overlay_border; | ||||
|     float scaled_icons_size = (float)m_icons_texture.metadata.icon_size * m_overlay_icons_scale; | ||||
| #endif // ENABLE_SVG_ICONS
 | ||||
| 
 | ||||
|     for (GizmosMap::iterator it = m_gizmos.begin(); it != m_gizmos.end(); ++it) | ||||
|     { | ||||
|         if ((it->second == nullptr) || !it->second->is_selectable()) | ||||
|             continue; | ||||
| 
 | ||||
| #if ENABLE_SVG_ICONS | ||||
|         bool inside = (scaled_border <= (float)mouse_pos(0)) && ((float)mouse_pos(0) <= scaled_border + scaled_icons_size) && (top_y <= (float)mouse_pos(1)) && ((float)mouse_pos(1) <= top_y + scaled_icons_size); | ||||
| #else | ||||
|         bool inside = (m_overlay_border <= (float)mouse_pos(0)) && ((float)mouse_pos(0) <= m_overlay_border + scaled_icons_size) && (top_y <= (float)mouse_pos(1)) && ((float)mouse_pos(1) <= top_y + scaled_icons_size); | ||||
| #endif // ENABLE_SVG_ICONS
 | ||||
|         if (it->second->is_activable(selection) && inside) | ||||
|         { | ||||
|             if ((it->second->get_state() == GLGizmoBase::On)) | ||||
|  | @ -1204,11 +1084,7 @@ void GLGizmosManager::update_on_off_state(const GLCanvas3D& canvas, const Vec2d& | |||
|         else | ||||
|             it->second->set_state(GLGizmoBase::Off); | ||||
| 
 | ||||
| #if ENABLE_SVG_ICONS | ||||
|         top_y += scaled_stride_y; | ||||
| #else | ||||
|         top_y += (scaled_icons_size + m_overlay_gap_y); | ||||
| #endif // ENABLE_SVG_ICONS
 | ||||
|     } | ||||
| 
 | ||||
|     GizmosMap::iterator it = m_gizmos.find(m_current); | ||||
|  | @ -1227,38 +1103,25 @@ std::string GLGizmosManager::update_hover_state(const GLCanvas3D& canvas, const | |||
| 
 | ||||
|     float cnv_h = (float)canvas.get_canvas_size().get_height(); | ||||
|     float height = get_total_overlay_height(); | ||||
| #if ENABLE_SVG_ICONS | ||||
|     float scaled_icons_size = m_overlay_icons_size * m_overlay_scale; | ||||
|     float scaled_border = m_overlay_border * m_overlay_scale; | ||||
|     float scaled_gap_y = m_overlay_gap_y * m_overlay_scale; | ||||
|     float scaled_stride_y = scaled_icons_size + scaled_gap_y; | ||||
|     float top_y = 0.5f * (cnv_h - height) + scaled_border; | ||||
| #else | ||||
|     float top_y = 0.5f * (cnv_h - height) + m_overlay_border; | ||||
|     float scaled_icons_size = (float)m_icons_texture.metadata.icon_size * m_overlay_icons_scale; | ||||
| #endif // ENABLE_SVG_ICONS
 | ||||
| 
 | ||||
|     for (GizmosMap::iterator it = m_gizmos.begin(); it != m_gizmos.end(); ++it) | ||||
|     { | ||||
|         if ((it->second == nullptr) || !it->second->is_selectable()) | ||||
|             continue; | ||||
| 
 | ||||
| #if ENABLE_SVG_ICONS | ||||
|         bool inside = (scaled_border <= (float)mouse_pos(0)) && ((float)mouse_pos(0) <= scaled_border + scaled_icons_size) && (top_y <= (float)mouse_pos(1)) && ((float)mouse_pos(1) <= top_y + scaled_icons_size); | ||||
| #else | ||||
|         bool inside = (m_overlay_border <= (float)mouse_pos(0)) && ((float)mouse_pos(0) <= m_overlay_border + scaled_icons_size) && (top_y <= (float)mouse_pos(1)) && ((float)mouse_pos(1) <= top_y + scaled_icons_size); | ||||
| #endif // ENABLE_SVG_ICONS
 | ||||
|         if (inside) | ||||
|             name = it->second->get_name(); | ||||
| 
 | ||||
|         if (it->second->is_activable(selection) && (it->second->get_state() != GLGizmoBase::On)) | ||||
|             it->second->set_state(inside ? GLGizmoBase::Hover : GLGizmoBase::Off); | ||||
| 
 | ||||
| #if ENABLE_SVG_ICONS | ||||
|         top_y += scaled_stride_y; | ||||
| #else | ||||
|         top_y += (scaled_icons_size + m_overlay_gap_y); | ||||
| #endif // ENABLE_SVG_ICONS
 | ||||
|     } | ||||
| 
 | ||||
|     return name; | ||||
|  | @ -1272,34 +1135,21 @@ bool GLGizmosManager::overlay_contains_mouse(const GLCanvas3D& canvas, const Vec | |||
|     float cnv_h = (float)canvas.get_canvas_size().get_height(); | ||||
|     float height = get_total_overlay_height(); | ||||
| 
 | ||||
| #if ENABLE_SVG_ICONS | ||||
|     float scaled_icons_size = m_overlay_icons_size * m_overlay_scale; | ||||
|     float scaled_border = m_overlay_border * m_overlay_scale; | ||||
|     float scaled_gap_y = m_overlay_gap_y * m_overlay_scale; | ||||
|     float scaled_stride_y = scaled_icons_size + scaled_gap_y; | ||||
|     float top_y = 0.5f * (cnv_h - height) + scaled_border; | ||||
| #else | ||||
|     float top_y = 0.5f * (cnv_h - height) + m_overlay_border; | ||||
|     float scaled_icons_size = (float)m_icons_texture.metadata.icon_size * m_overlay_icons_scale; | ||||
| #endif // ENABLE_SVG_ICONS
 | ||||
| 
 | ||||
|     for (GizmosMap::const_iterator it = m_gizmos.begin(); it != m_gizmos.end(); ++it) | ||||
|     { | ||||
|         if ((it->second == nullptr) || !it->second->is_selectable()) | ||||
|             continue; | ||||
| 
 | ||||
| #if ENABLE_SVG_ICONS | ||||
|         if ((scaled_border <= (float)mouse_pos(0)) && ((float)mouse_pos(0) <= scaled_border + scaled_icons_size) && (top_y <= (float)mouse_pos(1)) && ((float)mouse_pos(1) <= top_y + scaled_icons_size)) | ||||
| #else | ||||
|         if ((m_overlay_border <= (float)mouse_pos(0)) && ((float)mouse_pos(0) <= m_overlay_border + scaled_icons_size) && (top_y <= (float)mouse_pos(1)) && ((float)mouse_pos(1) <= top_y + scaled_icons_size)) | ||||
| #endif // ENABLE_SVG_ICONS
 | ||||
|             return true; | ||||
| 
 | ||||
| #if ENABLE_SVG_ICONS | ||||
|         top_y += scaled_stride_y; | ||||
| #else | ||||
|         top_y += (scaled_icons_size + m_overlay_gap_y); | ||||
| #endif // ENABLE_SVG_ICONS
 | ||||
|     } | ||||
| 
 | ||||
|     return false; | ||||
|  |  | |||
|  | @ -46,9 +46,7 @@ public: | |||
| class GLGizmosManager | ||||
| { | ||||
| public: | ||||
| #if ENABLE_SVG_ICONS | ||||
|     static const float Default_Icons_Size; | ||||
| #endif // ENABLE_SVG_ICONS
 | ||||
| 
 | ||||
|     enum EType : unsigned char | ||||
|     { | ||||
|  | @ -66,21 +64,13 @@ private: | |||
|     bool m_enabled; | ||||
|     typedef std::map<EType, GLGizmoBase*> GizmosMap; | ||||
|     GizmosMap m_gizmos; | ||||
| #if ENABLE_SVG_ICONS | ||||
|     mutable GLTexture m_icons_texture; | ||||
|     mutable bool m_icons_texture_dirty; | ||||
| #else | ||||
|     ItemsIconsTexture m_icons_texture; | ||||
| #endif // ENABLE_SVG_ICONS
 | ||||
|     BackgroundTexture m_background_texture; | ||||
|     EType m_current; | ||||
| 
 | ||||
| #if ENABLE_SVG_ICONS | ||||
|     float m_overlay_icons_size; | ||||
|     float m_overlay_scale; | ||||
| #else | ||||
|     float m_overlay_icons_scale; | ||||
| #endif // ENABLE_SVG_ICONS
 | ||||
|     float m_overlay_border; | ||||
|     float m_overlay_gap_y; | ||||
| 
 | ||||
|  | @ -109,9 +99,7 @@ public: | |||
|     bool is_enabled() const { return m_enabled; } | ||||
|     void set_enabled(bool enable) { m_enabled = enable; } | ||||
| 
 | ||||
| #if ENABLE_SVG_ICONS | ||||
|     void set_overlay_icon_size(float size); | ||||
| #endif // ENABLE_SVG_ICONS
 | ||||
|     void set_overlay_scale(float scale); | ||||
| 
 | ||||
|     void refresh_on_off_state(const Selection& selection); | ||||
|  | @ -173,9 +161,7 @@ private: | |||
| 
 | ||||
|     GLGizmoBase* get_current() const; | ||||
| 
 | ||||
| #if ENABLE_SVG_ICONS | ||||
|     bool generate_icons_texture() const; | ||||
| #endif // ENABLE_SVG_ICONS
 | ||||
| 
 | ||||
|     void update_on_off_state(const GLCanvas3D& canvas, const Vec2d& mouse_pos, const Selection& selection); | ||||
|     std::string update_hover_state(const GLCanvas3D& canvas, const Vec2d& mouse_pos); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Enrico Turri
						Enrico Turri