Fix Creation of the new text object

This commit is contained in:
Filip Sykala 2021-11-15 09:21:53 +01:00
parent 55d83e6238
commit eaaa59be86
3 changed files with 12 additions and 16 deletions

View File

@ -474,13 +474,8 @@ bool GLGizmoEmboss::process()
data.text_configuration = create_configuration();
data.volume_name = create_volume_name();
data.volume_ptr = m_volume;
data.object_idx = m_parent.get_selection().get_object_idx();
const Selection &selection = m_parent.get_selection();
if (!selection.is_empty() && selection.get_object_idx() >= 0) {
int object_idx = selection.get_object_idx();
Model &model = wxGetApp().plater()->model();
data.object_ptr = model.objects[object_idx];
}
m_job->restart(data);
return true;

View File

@ -92,7 +92,7 @@ void EmbossJob::finalize() {
ModelVolume *volume = m_data->volume_ptr;
if (volume == nullptr) {
// decide to add as volume or new object
if (m_data->object_ptr == nullptr) {
if (m_data->object_idx < 0) {
// create new object
app.obj_list()->load_mesh_object(tm, name, true, &m_data->text_configuration);
app.mainframe->update_title();
@ -106,8 +106,9 @@ void EmbossJob::finalize() {
return;
} else {
// create new volume inside of object
ModelObject *obj = m_data->object_ptr;
volume = obj->add_volume(std::move(tm));
Model & model = wxGetApp().plater()->model();
ModelObject *obj = model.objects[m_data->object_idx];
volume = obj->add_volume(std::move(tm));
// set a default extruder value, since user can't add it manually
volume->config.set_key_value("extruder", new ConfigOptionInt(0));
@ -134,9 +135,6 @@ void EmbossJob::finalize() {
// Job promiss to refresh is not working
canvas->reload_scene(true);
// set data to model
Job::finalize();
}
void EmbossJob::select_volume(ModelVolume *volume)

View File

@ -22,13 +22,16 @@ class EmbossJob : protected Job
public:
struct Data
{
// Pointer on Data of font(glyoh shapes)
std::shared_ptr<Emboss::Font> font;
// font item is not used for create object
TextConfiguration text_configuration;
// new volume name created from text
std::string volume_name;
// when nulltrp new volume will be created
// when volume_ptr == nullptr than new volume will be created
ModelVolume *volume_ptr;
// when nullptr volume is created in new object
ModelObject *object_ptr;
// when volume_ptr == nullptr && object_idx < 0 than new object will be created
int object_idx;
};
EmbossJob();
void restart(const Data &data);