From eb0d840b3fbc9f832eeb5bd400236e3ce9c57e0b Mon Sep 17 00:00:00 2001 From: Filip Sykala - NTB T15p Date: Wed, 12 Jul 2023 13:44:32 +0200 Subject: [PATCH] Fix: ../src/slic3r/GUI/SurfaceDrag.cpp:60:21: warning: unused function 'collect_allowed_volumes_id' [-Wunused-function] ../src/slic3r/GUI/SurfaceDrag.cpp:72:14: warning: unused function 'calc_screen_offset_to_volume_center' [-Wunused-function] ../src/slic3r/GUI/Jobs/EmbossJob.cpp:976:6: warning: unused function 'update_volume_name' [-Wunused-function] --- src/slic3r/GUI/Jobs/EmbossJob.cpp | 34 ---------------------- src/slic3r/GUI/SurfaceDrag.cpp | 48 ------------------------------- 2 files changed, 82 deletions(-) diff --git a/src/slic3r/GUI/Jobs/EmbossJob.cpp b/src/slic3r/GUI/Jobs/EmbossJob.cpp index 0fd0d8a945..64640b991e 100644 --- a/src/slic3r/GUI/Jobs/EmbossJob.cpp +++ b/src/slic3r/GUI/Jobs/EmbossJob.cpp @@ -973,40 +973,6 @@ TriangleMesh create_default_mesh() return triangle_mesh; } -void update_volume_name(const ModelVolume &volume, const ObjectList *obj_list) -{ - if (obj_list == nullptr) - return; - - const std::vector* objects = obj_list->objects(); - if (objects == nullptr) - return; - - int object_idx = -1; - int volume_idx = -1; - for (size_t oi = 0; oi < objects->size(); ++oi) { - const ModelObject *mo = objects->at(oi); - if (mo == nullptr) - continue; - if (volume.get_object()->id() != mo->id()) - continue; - const ModelVolumePtrs& volumes = mo->volumes; - for (size_t vi = 0; vi < volumes.size(); ++vi) { - const ModelVolume *mv = volumes[vi]; - if (mv == nullptr) - continue; - if (mv->id() == volume.id()){ - object_idx = static_cast(oi); - volume_idx = static_cast(vi); - break; - } - } - if (volume_idx > 0) - break; - } - obj_list->update_name_in_list(object_idx, volume_idx); -} - void update_name_in_list(const ObjectList& object_list, const ModelVolume& volume) { const ModelObjectPtrs *objects_ptr = object_list.objects(); diff --git a/src/slic3r/GUI/SurfaceDrag.cpp b/src/slic3r/GUI/SurfaceDrag.cpp index b53976b312..575ae9a67f 100644 --- a/src/slic3r/GUI/SurfaceDrag.cpp +++ b/src/slic3r/GUI/SurfaceDrag.cpp @@ -56,57 +56,9 @@ bool dragging(const Vec2d &mouse_pos, GLCanvas3D &canvas, const RaycastManager &raycast_manager, const std::optional &up_limit); - -std::vector collect_allowed_volumes_id(const ModelVolumePtrs &volumes, const ObjectID &selected_volume_id); } namespace Slic3r::GUI { - -/// -/// Calculate offset from mouse position to center of text -/// -/// Position on screen[in Px] e.g. mouse position -/// Selected volume(text) -/// Actual position and view direction of camera -/// Offset in screen coordinate -static Vec2d calc_screen_offset_to_volume_center(const Vec2d &screen_coor, const ModelVolume &volume, const Camera &camera) -{ - const Transform3d &volume_tr = volume.get_matrix(); - assert(volume.emboss_shape.has_value()); - - auto calc_offset = [&screen_coor, &volume_tr, &camera, &volume](const Transform3d &instrance_tr) -> Vec2d { - Transform3d to_world = instrance_tr * volume_tr; - - // Use fix of .3mf loaded tranformation when exist - if (std::optional fix = volume.emboss_shape->fix_3mf_tr; - fix.has_value()) - to_world = to_world * (*fix); - // zero point of volume in world coordinate system - Vec3d volume_center = to_world.translation(); - // screen coordinate of volume center - Vec2i coor = CameraUtils::project(camera, volume_center); - return coor.cast() - screen_coor; - }; - - auto object = volume.get_object(); - assert(!object->instances.empty()); - // Speed up for one instance - if (object->instances.size() == 1) - return calc_offset(object->instances.front()->get_matrix()); - - Vec2d nearest_offset; - double nearest_offset_size = std::numeric_limits::max(); - for (const ModelInstance *instance : object->instances) { - Vec2d offset = calc_offset(instance->get_matrix()); - double offset_size = offset.norm(); - if (nearest_offset_size < offset_size) - continue; - nearest_offset_size = offset_size; - nearest_offset = offset; - } - return nearest_offset; -} - // Calculate scale in world for check in debug [[maybe_unused]] static std::optional calc_scale(const Matrix3d &from, const Matrix3d &to, const Vec3d &dir) {