mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-18 00:55:53 +08:00
change in platter changed object:
call with object itself(do not use index to object list) add recalculate object bounding box add check whether object is not outside the bed
This commit is contained in:
parent
9c054b05c1
commit
7b93b5e512
@ -716,21 +716,7 @@ void GLGizmoEmboss::volume_transformation_changed()
|
|||||||
// inform slicing process that model changed
|
// inform slicing process that model changed
|
||||||
// SLA supports, processing
|
// SLA supports, processing
|
||||||
// ensure on bed
|
// ensure on bed
|
||||||
const ModelObjectPtrs objects = m_parent.get_model()->objects;
|
wxGetApp().plater()->changed_object(*m_volume->get_object());
|
||||||
ModelObject *object = m_volume->get_object();
|
|
||||||
object->invalidate_bounding_box();
|
|
||||||
object->ensure_on_bed();
|
|
||||||
|
|
||||||
int obj_idx = -1;
|
|
||||||
for (int i = 0; i < objects.size(); i++)
|
|
||||||
if (objects[i]->id() == object->id()) {
|
|
||||||
obj_idx = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
wxGetApp().plater()->changed_object(obj_idx);
|
|
||||||
|
|
||||||
// Check outside bed
|
|
||||||
m_parent.requires_check_outside_state();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show correct value of height & depth inside of inputs
|
// Show correct value of height & depth inside of inputs
|
||||||
|
@ -339,21 +339,7 @@ void GLGizmoSVG::volume_transformation_changed()
|
|||||||
// inform slicing process that model changed
|
// inform slicing process that model changed
|
||||||
// SLA supports, processing
|
// SLA supports, processing
|
||||||
// ensure on bed
|
// ensure on bed
|
||||||
const ModelObjectPtrs objects = m_parent.get_model()->objects;
|
wxGetApp().plater()->changed_object(*m_volume->get_object());
|
||||||
ModelObject *object = m_volume->get_object();
|
|
||||||
object->invalidate_bounding_box();
|
|
||||||
object->ensure_on_bed();
|
|
||||||
|
|
||||||
int obj_idx = -1;
|
|
||||||
for (int i = 0; i < objects.size(); i++)
|
|
||||||
if (objects[i]->id() == object->id()) {
|
|
||||||
obj_idx = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
wxGetApp().plater()->changed_object(obj_idx);
|
|
||||||
|
|
||||||
// Check outside bed
|
|
||||||
m_parent.requires_check_outside_state();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show correct value of height & depth inside of inputs
|
// Show correct value of height & depth inside of inputs
|
||||||
@ -716,6 +702,7 @@ void wu_draw_line_side(Linef line,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef MORE_DRAWING
|
||||||
// Wu's line algorithm - https://en.wikipedia.org/wiki/Xiaolin_Wu's_line_algorithm
|
// Wu's line algorithm - https://en.wikipedia.org/wiki/Xiaolin_Wu's_line_algorithm
|
||||||
void wu_draw_line(Linef line,
|
void wu_draw_line(Linef line,
|
||||||
const std::function<void(int x, int y, float brightess)>& plot) {
|
const std::function<void(int x, int y, float brightess)>& plot) {
|
||||||
@ -786,6 +773,36 @@ void wu_draw_line(Linef line,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void draw(const ExPolygonsWithIds &shapes_with_ids, unsigned max_size)
|
||||||
|
{
|
||||||
|
ImVec2 actual_pos = ImGui::GetCursorPos();
|
||||||
|
// draw shapes
|
||||||
|
BoundingBox bb;
|
||||||
|
for (const ExPolygonsWithId &shape : shapes_with_ids)
|
||||||
|
bb.merge(get_extents(shape.expoly));
|
||||||
|
|
||||||
|
Point bb_size = bb.size();
|
||||||
|
double scale = max_size / (double) std::max(bb_size.x(), bb_size.y());
|
||||||
|
ImVec2 win_offset = ImGui::GetWindowPos();
|
||||||
|
Point offset(win_offset.x + actual_pos.x, win_offset.y + actual_pos.y);
|
||||||
|
offset += bb_size / 2 * scale;
|
||||||
|
auto draw_polygon = [&scale, offset](Slic3r::Polygon p) {
|
||||||
|
p.scale(scale, -scale); // Y mirror
|
||||||
|
p.translate(offset);
|
||||||
|
ImGuiWrapper::draw(p);
|
||||||
|
};
|
||||||
|
|
||||||
|
for (const ExPolygonsWithId &shape : shapes_with_ids) {
|
||||||
|
for (const ExPolygon &expoly : shape.expoly) {
|
||||||
|
draw_polygon(expoly.contour);
|
||||||
|
for (const Slic3r::Polygon &hole : expoly.holes)
|
||||||
|
draw_polygon(hole);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // MORE_DRAWING
|
||||||
|
|
||||||
template<unsigned int N> // N .. count of channels per pixel
|
template<unsigned int N> // N .. count of channels per pixel
|
||||||
void draw_side_outline(const ExPolygons &shape, const std::array<unsigned char, N> &color, std::vector<unsigned char> &data, size_t data_width, double scale)
|
void draw_side_outline(const ExPolygons &shape, const std::array<unsigned char, N> &color, std::vector<unsigned char> &data, size_t data_width, double scale)
|
||||||
{
|
{
|
||||||
@ -878,7 +895,7 @@ void draw_filled(const ExPolygons &shape, const std::array<unsigned char, N>& co
|
|||||||
size_t offset = get_offset(x, y);
|
size_t offset = get_offset(x, y);
|
||||||
if (data[offset + N - 1] != 0)
|
if (data[offset + N - 1] != 0)
|
||||||
return; // already setted by line
|
return; // already setted by line
|
||||||
for (size_t i = 0; i < N; ++i)
|
for (int i = 0; i < N; ++i)
|
||||||
data[offset + i] = color[i];
|
data[offset + i] = color[i];
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1372,35 +1389,6 @@ void GLGizmoSVG::draw_window()
|
|||||||
draw_model_type();
|
draw_model_type();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
namespace {
|
|
||||||
void draw(const ExPolygonsWithIds& shapes_with_ids, unsigned max_size)
|
|
||||||
{
|
|
||||||
ImVec2 actual_pos = ImGui::GetCursorPos();
|
|
||||||
// draw shapes
|
|
||||||
BoundingBox bb;
|
|
||||||
for (const ExPolygonsWithId &shape : shapes_with_ids)
|
|
||||||
bb.merge(get_extents(shape.expoly));
|
|
||||||
|
|
||||||
Point bb_size = bb.size();
|
|
||||||
double scale = max_size / (double) std::max(bb_size.x(), bb_size.y());
|
|
||||||
ImVec2 win_offset = ImGui::GetWindowPos();
|
|
||||||
Point offset(win_offset.x + actual_pos.x, win_offset.y + actual_pos.y);
|
|
||||||
offset += bb_size / 2 * scale;
|
|
||||||
auto draw_polygon = [&scale, offset](Slic3r::Polygon p) {
|
|
||||||
p.scale(scale, -scale); // Y mirror
|
|
||||||
p.translate(offset);
|
|
||||||
ImGuiWrapper::draw(p);
|
|
||||||
};
|
|
||||||
|
|
||||||
for (const ExPolygonsWithId &shape : shapes_with_ids) {
|
|
||||||
for (const ExPolygon &expoly : shape.expoly) {
|
|
||||||
draw_polygon(expoly.contour);
|
|
||||||
for (const Slic3r::Polygon &hole : expoly.holes)
|
|
||||||
draw_polygon(hole);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLGizmoSVG::draw_preview(){
|
void GLGizmoSVG::draw_preview(){
|
||||||
// init texture when not initialized yet.
|
// init texture when not initialized yet.
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include <libslic3r/Format/OBJ.hpp> // load_obj for default mesh
|
#include <libslic3r/Format/OBJ.hpp> // load_obj for default mesh
|
||||||
#include <libslic3r/CutSurface.hpp> // use surface cuts
|
#include <libslic3r/CutSurface.hpp> // use surface cuts
|
||||||
#include <libslic3r/BuildVolume.hpp> // create object
|
#include <libslic3r/BuildVolume.hpp> // create object
|
||||||
|
#include <libslic3r/SLA/ReprojectPointsOnMesh.hpp>
|
||||||
|
|
||||||
#include "slic3r/GUI/Plater.hpp"
|
#include "slic3r/GUI/Plater.hpp"
|
||||||
#include "slic3r/GUI/NotificationManager.hpp"
|
#include "slic3r/GUI/NotificationManager.hpp"
|
||||||
@ -419,8 +420,6 @@ void UpdateJob::update_volume(ModelVolume *volume, TriangleMesh &&mesh, const Da
|
|||||||
volume->set_mesh(std::move(mesh));
|
volume->set_mesh(std::move(mesh));
|
||||||
volume->set_new_unique_id();
|
volume->set_new_unique_id();
|
||||||
volume->calculate_convex_hull();
|
volume->calculate_convex_hull();
|
||||||
ModelObject *object = volume->get_object();
|
|
||||||
object->invalidate_bounding_box();
|
|
||||||
|
|
||||||
// write data from base into volume
|
// write data from base into volume
|
||||||
base.write(*volume);
|
base.write(*volume);
|
||||||
@ -434,17 +433,15 @@ void UpdateJob::update_volume(ModelVolume *volume, TriangleMesh &&mesh, const Da
|
|||||||
update_name_in_list(*obj_list, *volume);
|
update_name_in_list(*obj_list, *volume);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get object id to set object as changed
|
ModelObject *object = volume->get_object();
|
||||||
Plater* plater = app.plater();
|
assert(object != nullptr);
|
||||||
ModelObjectPtrs objects = plater->model().objects;
|
if (object == nullptr)
|
||||||
int obj_idx = -1;
|
return;
|
||||||
for (int i = 0; i < objects.size(); ++i)
|
|
||||||
if (objects[i]->id() == object->id()) {
|
Plater *plater = app.plater();
|
||||||
obj_idx = i;
|
if (plater->printer_technology() == ptSLA)
|
||||||
break;
|
sla::reproject_points_and_holes(object);
|
||||||
}
|
plater->changed_object(*object);
|
||||||
assert(obj_idx >= 0);
|
|
||||||
plater->changed_object(obj_idx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////
|
/////////////////
|
||||||
|
@ -7815,22 +7815,35 @@ void Plater::changed_mesh(int obj_idx)
|
|||||||
p->schedule_background_process();
|
p->schedule_background_process();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Plater::changed_object(ModelObject &object){
|
||||||
|
assert(object.get_model() == &p->model); // is object from same model?
|
||||||
|
object.invalidate_bounding_box();
|
||||||
|
|
||||||
|
// recenter and re - align to Z = 0
|
||||||
|
object.ensure_on_bed(p->printer_technology != ptSLA);
|
||||||
|
|
||||||
|
if (p->printer_technology == ptSLA) {
|
||||||
|
// Update the SLAPrint from the current Model, so that the reload_scene()
|
||||||
|
// pulls the correct data, update the 3D scene.
|
||||||
|
p->update_restart_background_process(true, false);
|
||||||
|
} else
|
||||||
|
p->view3D->reload_scene(false);
|
||||||
|
|
||||||
|
// update print
|
||||||
|
p->schedule_background_process();
|
||||||
|
|
||||||
|
// Check outside bed
|
||||||
|
get_current_canvas3D()->requires_check_outside_state();
|
||||||
|
}
|
||||||
|
|
||||||
void Plater::changed_object(int obj_idx)
|
void Plater::changed_object(int obj_idx)
|
||||||
{
|
{
|
||||||
if (obj_idx < 0)
|
if (obj_idx < 0)
|
||||||
return;
|
return;
|
||||||
// recenter and re - align to Z = 0
|
ModelObject *object = p->model.objects[obj_idx];
|
||||||
p->model.objects[obj_idx]->ensure_on_bed(p->printer_technology != ptSLA);
|
if (object == nullptr)
|
||||||
if (this->p->printer_technology == ptSLA) {
|
return;
|
||||||
// Update the SLAPrint from the current Model, so that the reload_scene()
|
changed_object(*object);
|
||||||
// pulls the correct data, update the 3D scene.
|
|
||||||
this->p->update_restart_background_process(true, false);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
p->view3D->reload_scene(false);
|
|
||||||
|
|
||||||
// update print
|
|
||||||
this->p->schedule_background_process();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Plater::changed_objects(const std::vector<size_t>& object_idxs)
|
void Plater::changed_objects(const std::vector<size_t>& object_idxs)
|
||||||
|
@ -298,6 +298,7 @@ public:
|
|||||||
void clear_before_change_mesh(int obj_idx, const std::string ¬ification_msg);
|
void clear_before_change_mesh(int obj_idx, const std::string ¬ification_msg);
|
||||||
void changed_mesh(int obj_idx);
|
void changed_mesh(int obj_idx);
|
||||||
|
|
||||||
|
void changed_object(ModelObject &object);
|
||||||
void changed_object(int obj_idx);
|
void changed_object(int obj_idx);
|
||||||
void changed_objects(const std::vector<size_t>& object_idxs);
|
void changed_objects(const std::vector<size_t>& object_idxs);
|
||||||
void schedule_background_process(bool schedule = true);
|
void schedule_background_process(bool schedule = true);
|
||||||
|
@ -359,16 +359,6 @@ bool face_selected_volume_to_camera(const Camera &camera, GLCanvas3D &canvas, co
|
|||||||
|
|
||||||
if (volume.type() == ModelVolumeType::MODEL_PART)
|
if (volume.type() == ModelVolumeType::MODEL_PART)
|
||||||
object.ensure_on_bed();
|
object.ensure_on_bed();
|
||||||
|
|
||||||
//int obj_idx = -1;
|
|
||||||
//for (int i = 0; i < objects.size(); i++)
|
|
||||||
// if (objects[i]->id() == object.id()) {
|
|
||||||
// obj_idx = i;
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// object change !!!
|
|
||||||
// Plater::changed_object(obj_idx);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user