mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-15 09:06:02 +08:00
Implemented increase/decrease for instances.
This commit is contained in:
parent
035ce47c4e
commit
50345c3412
@ -677,12 +677,51 @@ void Plater::reset(bool dont_push) {
|
|||||||
this->on_model_change();
|
this->on_model_change();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Plater::increase() {
|
void Plater::increase(size_t copies, bool dont_push) {
|
||||||
//TODO
|
auto obj {this->selected_object()};
|
||||||
|
if (obj == this->objects.end()) return; // do nothing; nothing is selected.
|
||||||
|
|
||||||
|
this->stop_background_process();
|
||||||
|
|
||||||
|
auto* model_object {this->model->objects.at(obj->identifier)};
|
||||||
|
ModelInstance* instance {model_object->instances.back()};
|
||||||
|
|
||||||
|
for (size_t i = 1; i <= copies; i++) {
|
||||||
|
instance = model_object->add_instance(*instance);
|
||||||
|
instance->offset.x += 10;
|
||||||
|
instance->offset.y += 10;
|
||||||
|
this->print->objects.at(obj->identifier)->add_copy(instance->offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!dont_push) {
|
||||||
|
this->add_undo_operation(UndoCmd::Increase, obj->identifier, copies);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(settings->autocenter) {
|
||||||
|
this->arrange();
|
||||||
|
} else {
|
||||||
|
this->on_model_change();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Plater::decrease() {
|
void Plater::decrease(size_t copies, bool dont_push) {
|
||||||
//TODO
|
auto obj {this->selected_object()};
|
||||||
|
if (obj == this->objects.end()) return; // do nothing; nothing is selected.
|
||||||
|
|
||||||
|
this->stop_background_process();
|
||||||
|
auto* model_object {this->model->objects.at(obj->identifier)};
|
||||||
|
if (model_object->instances.size() > copies) {
|
||||||
|
for (size_t i = 1; i <= copies; i++) {
|
||||||
|
model_object->delete_last_instance();
|
||||||
|
this->print->objects.at(obj->identifier)->delete_last_copy();
|
||||||
|
}
|
||||||
|
if (!dont_push) {
|
||||||
|
this->add_undo_operation(UndoCmd::Decrease, obj->identifier, copies);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this->remove();
|
||||||
|
}
|
||||||
|
this->on_model_change();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Plater::rotate(double angle) {
|
void Plater::rotate(double angle) {
|
||||||
@ -714,9 +753,27 @@ void Plater::add_undo_operation(UndoCmd cmd, int obj_id, Slic3r::Model& model) {
|
|||||||
add_undo_operation(cmd, tmp, model);
|
add_undo_operation(cmd, tmp, model);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Plater::add_undo_operation(UndoCmd cmd, int obj_id, size_t copies) {
|
||||||
|
}
|
||||||
|
|
||||||
void Plater::object_list_changed() {
|
void Plater::object_list_changed() {
|
||||||
//TODO
|
//TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Plater::stop_background_process() {
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
void Plater::start_background_process() {
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
void Plater::pause_background_process() {
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
void Plater::resume_background_process() {
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
|
||||||
}} // Namespace Slic3r::GUI
|
}} // Namespace Slic3r::GUI
|
||||||
|
|
||||||
|
@ -165,10 +165,10 @@ private:
|
|||||||
void reset(bool dont_push = false);
|
void reset(bool dont_push = false);
|
||||||
|
|
||||||
/// Make instances of the currently selected model.
|
/// Make instances of the currently selected model.
|
||||||
void increase();
|
void increase(size_t copies = 1, bool dont_push = false);
|
||||||
|
|
||||||
/// Remove instances of the currently selected model.
|
/// Remove instances of the currently selected model.
|
||||||
void decrease();
|
void decrease(size_t copies = 1, bool dont_push = false);
|
||||||
|
|
||||||
/// Rotate the currently selected model.
|
/// Rotate the currently selected model.
|
||||||
void rotate(double angle);
|
void rotate(double angle);
|
||||||
@ -188,6 +188,13 @@ private:
|
|||||||
/// Process a change in the object list.
|
/// Process a change in the object list.
|
||||||
void object_list_changed();
|
void object_list_changed();
|
||||||
|
|
||||||
|
/// Halt ongoing background processes.
|
||||||
|
void stop_background_process();
|
||||||
|
|
||||||
|
void start_background_process();
|
||||||
|
|
||||||
|
void pause_background_process();
|
||||||
|
void resume_background_process();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user