mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-14 03:55:56 +08:00
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]
This commit is contained in:
parent
0588c66ce5
commit
eb0d840b3f
@ -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<ModelObject *>* 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<int>(oi);
|
||||
volume_idx = static_cast<int>(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();
|
||||
|
@ -56,57 +56,9 @@ bool dragging(const Vec2d &mouse_pos,
|
||||
GLCanvas3D &canvas,
|
||||
const RaycastManager &raycast_manager,
|
||||
const std::optional<double> &up_limit);
|
||||
|
||||
std::vector<size_t> collect_allowed_volumes_id(const ModelVolumePtrs &volumes, const ObjectID &selected_volume_id);
|
||||
}
|
||||
|
||||
namespace Slic3r::GUI {
|
||||
|
||||
/// <summary>
|
||||
/// Calculate offset from mouse position to center of text
|
||||
/// </summary>
|
||||
/// <param name="screen_coor">Position on screen[in Px] e.g. mouse position</param>
|
||||
/// <param name="volume">Selected volume(text)</param>
|
||||
/// <param name="camera">Actual position and view direction of camera</param>
|
||||
/// <returns>Offset in screen coordinate</returns>
|
||||
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<Transform3d> 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<double>() - 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<double>::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<double> calc_scale(const Matrix3d &from, const Matrix3d &to, const Vec3d &dir)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user