mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-15 11:25:53 +08:00
Fix update of model after finish text jobs.
This commit is contained in:
parent
989ca9d8ee
commit
56d15253d4
@ -483,10 +483,46 @@ TriangleMesh priv::create_default_mesh()
|
|||||||
return triangle_mesh;
|
return triangle_mesh;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace{
|
||||||
|
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 UpdateJob::update_volume(ModelVolume *volume,
|
void UpdateJob::update_volume(ModelVolume *volume,
|
||||||
TriangleMesh &&mesh,
|
TriangleMesh &&mesh,
|
||||||
const TextConfiguration &text_configuration,
|
const TextConfiguration &text_configuration,
|
||||||
const std::string &volume_name)
|
std::string_view volume_name)
|
||||||
{
|
{
|
||||||
// check inputs
|
// check inputs
|
||||||
bool is_valid_input =
|
bool is_valid_input =
|
||||||
@ -506,19 +542,12 @@ void UpdateJob::update_volume(ModelVolume *volume,
|
|||||||
// discard information about rotation, should not be stored in volume
|
// discard information about rotation, should not be stored in volume
|
||||||
volume->text_configuration->style.prop.angle.reset();
|
volume->text_configuration->style.prop.angle.reset();
|
||||||
|
|
||||||
GUI_App &app = wxGetApp(); // may be move to input
|
GUI_App &app = wxGetApp(); // may be move ObjectList and Plater to input?
|
||||||
GLCanvas3D *canvas = app.plater()->canvas3D();
|
|
||||||
const Selection &selection = canvas->get_selection();
|
|
||||||
const GLVolume *gl_volume = selection.get_volume(*selection.get_volume_idxs().begin());
|
|
||||||
int object_idx = gl_volume->object_idx();
|
|
||||||
|
|
||||||
if (volume->name != volume_name) {
|
|
||||||
volume->name = volume_name;
|
|
||||||
|
|
||||||
// update volume name in right panel( volume / object name)
|
// update volume name in right panel( volume / object name)
|
||||||
int volume_idx = gl_volume->volume_idx();
|
if (volume->name != volume_name) {
|
||||||
ObjectList *obj_list = app.obj_list();
|
volume->name = volume_name;
|
||||||
obj_list->update_name_in_list(object_idx, volume_idx);
|
update_volume_name(*volume, app.obj_list());
|
||||||
}
|
}
|
||||||
|
|
||||||
// When text is object.
|
// When text is object.
|
||||||
@ -528,11 +557,12 @@ void UpdateJob::update_volume(ModelVolume *volume,
|
|||||||
volume->get_object()->ensure_on_bed();
|
volume->get_object()->ensure_on_bed();
|
||||||
|
|
||||||
// redraw scene
|
// redraw scene
|
||||||
bool refresh_immediately = false;
|
Plater *plater = app.plater();
|
||||||
canvas->reload_scene(refresh_immediately);
|
if (plater == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
// Change buttons "Export G-code" into "Slice now"
|
// Update Model and redraw scene
|
||||||
canvas->post_event(SimpleEvent(EVT_GLCANVAS_SCHEDULE_BACKGROUND_PROCESS));
|
plater->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void priv::update_volume(TriangleMesh &&mesh, const DataUpdate &data, Transform3d* tr)
|
void priv::update_volume(TriangleMesh &&mesh, const DataUpdate &data, Transform3d* tr)
|
||||||
@ -646,8 +676,9 @@ void priv::create_volume(
|
|||||||
if (manager.get_current_type() != GLGizmosManager::Emboss)
|
if (manager.get_current_type() != GLGizmosManager::Emboss)
|
||||||
manager.open_gizmo(GLGizmosManager::Emboss);
|
manager.open_gizmo(GLGizmosManager::Emboss);
|
||||||
|
|
||||||
// redraw scene
|
// update model and redraw scene
|
||||||
canvas->reload_scene(true);
|
//canvas->reload_scene(true);
|
||||||
|
plater->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
ModelVolume *priv::get_volume(ModelObjectPtrs &objects,
|
ModelVolume *priv::get_volume(ModelObjectPtrs &objects,
|
||||||
|
@ -145,7 +145,7 @@ public:
|
|||||||
static void update_volume(ModelVolume *volume,
|
static void update_volume(ModelVolume *volume,
|
||||||
TriangleMesh &&mesh,
|
TriangleMesh &&mesh,
|
||||||
const TextConfiguration &text_configuration,
|
const TextConfiguration &text_configuration,
|
||||||
const std::string &volume_name);
|
std::string_view volume_name);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SurfaceVolumeData
|
struct SurfaceVolumeData
|
||||||
|
Loading…
x
Reference in New Issue
Block a user