mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 08:47:52 -06:00
New selection set as default
This commit is contained in:
parent
0d282896d0
commit
a15bf7cc25
16 changed files with 20 additions and 2149 deletions
|
@ -754,18 +754,6 @@ std::vector<PresetComboBox*>& Sidebar::combos_filament()
|
|||
return p->combos_filament;
|
||||
}
|
||||
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
// Plater::Object
|
||||
|
||||
struct PlaterObject
|
||||
{
|
||||
std::string name;
|
||||
bool selected;
|
||||
|
||||
PlaterObject(std::string name) : name(std::move(name)), selected(false) {}
|
||||
};
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
|
||||
// Plater::DropTarget
|
||||
|
||||
class PlaterDropTarget : public wxFileDropTarget
|
||||
|
@ -817,9 +805,6 @@ struct Plater::priv
|
|||
Slic3r::Print print;
|
||||
Slic3r::Model model;
|
||||
Slic3r::GCodePreviewData gcode_preview_data;
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
std::vector<PlaterObject> objects;
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
|
||||
// GUI elements
|
||||
wxNotebook *notebook;
|
||||
|
@ -835,9 +820,6 @@ struct Plater::priv
|
|||
|
||||
priv(Plater *q, MainFrame *main_frame);
|
||||
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
std::vector<int> collect_selections();
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
void update(bool force_autocenter = false);
|
||||
void select_view(const std::string& direction);
|
||||
void update_ui_from_settings();
|
||||
|
@ -849,30 +831,15 @@ struct Plater::priv
|
|||
std::vector<size_t> load_model_objects(const ModelObjectPtrs &model_objects);
|
||||
std::unique_ptr<CheckboxFileDialog> get_export_file(GUI::FileType file_type);
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
const GLCanvas3D::Selection& get_selection() const;
|
||||
GLCanvas3D::Selection& get_selection();
|
||||
int get_selected_object_idx() const;
|
||||
#else
|
||||
void select_object(optional<size_t> obj_idx);
|
||||
void select_object_from_cpp();
|
||||
optional<size_t> selected_object() const;
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
void selection_changed();
|
||||
void object_list_changed();
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
void select_view();
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
|
||||
void remove(size_t obj_idx);
|
||||
void reset();
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
void rotate();
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
void mirror(Axis axis);
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
void scale();
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
void arrange();
|
||||
void split_object();
|
||||
void split_volume();
|
||||
|
@ -896,25 +863,12 @@ struct Plater::priv
|
|||
void on_action_split_objects(SimpleEvent&);
|
||||
void on_action_split_volumes(SimpleEvent&);
|
||||
void on_action_cut(SimpleEvent&);
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
void on_action_settings(SimpleEvent&);
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
void on_action_layersediting(SimpleEvent&);
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
void on_action_selectbyparts(SimpleEvent&);
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
void on_object_select(SimpleEvent&);
|
||||
#else
|
||||
void on_object_select(ObjectSelectEvent&);
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
void on_viewport_changed(SimpleEvent&);
|
||||
void on_right_click(Vec2dEvent&);
|
||||
void on_model_update(SimpleEvent&);
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
void on_scale_uniformly(SimpleEvent&);
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
void on_wipetower_moved(Vec3dEvent&);
|
||||
void on_enable_action_buttons(Event<bool>&);
|
||||
void on_update_geometry(Vec3dsEvent<2>&);
|
||||
|
@ -922,7 +876,6 @@ struct Plater::priv
|
|||
private:
|
||||
bool init_object_menu();
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
bool can_delete_object() const;
|
||||
bool can_increase_instances() const;
|
||||
bool can_decrease_instances() const;
|
||||
|
@ -933,7 +886,6 @@ private:
|
|||
bool can_delete_all() const;
|
||||
bool can_arrange() const;
|
||||
bool can_mirror() const;
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
};
|
||||
|
||||
const std::regex Plater::priv::pattern_bundle(".*[.](amf|amf[.]xml|zip[.]amf|3mf|prusa)", std::regex::icase);
|
||||
|
@ -976,10 +928,6 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame) :
|
|||
_3DScene::enable_picking(canvas3D, true);
|
||||
_3DScene::enable_moving(canvas3D, true);
|
||||
// XXX: more config from 3D.pm
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
_3DScene::set_select_by(canvas3D, "object");
|
||||
_3DScene::set_drag_by(canvas3D, "instance");
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
_3DScene::set_model(canvas3D, &model);
|
||||
_3DScene::set_print(canvas3D, &print);
|
||||
_3DScene::set_config(canvas3D, config);
|
||||
|
@ -1017,17 +965,10 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame) :
|
|||
canvas3D->Bind(EVT_GLCANVAS_SCHEDULE_BACKGROUND_PROCESS, &priv::on_schedule_background_process, this);
|
||||
canvas3D->Bind(EVT_GLCANVAS_OBJECT_SELECT, &priv::on_object_select, this);
|
||||
canvas3D->Bind(EVT_GLCANVAS_VIEWPORT_CHANGED, &priv::on_viewport_changed, this);
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
canvas3D->Bind(EVT_GLCANVAS_DOUBLE_CLICK, [](SimpleEvent&) {}); // XXX: remove?
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
canvas3D->Bind(EVT_GLCANVAS_RIGHT_CLICK, &priv::on_right_click, this);
|
||||
canvas3D->Bind(EVT_GLCANVAS_MODEL_UPDATE, &priv::on_model_update, this);
|
||||
canvas3D->Bind(EVT_GLCANVAS_REMOVE_OBJECT, [q](SimpleEvent&) { q->remove_selected(); });
|
||||
canvas3D->Bind(EVT_GLCANVAS_ARRANGE, [this](SimpleEvent&) { arrange(); });
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
canvas3D->Bind(EVT_GLCANVAS_ROTATE_OBJECT, [this](Event<int> &evt) { /*TODO: call rotate */ });
|
||||
canvas3D->Bind(EVT_GLCANVAS_SCALE_UNIFORMLY, [this](SimpleEvent&) { this->scale(); });
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
canvas3D->Bind(EVT_GLCANVAS_INCREASE_INSTANCES, [q](Event<int> &evt) { evt.data == 1 ? q->increase_instances() : q->decrease_instances(); });
|
||||
canvas3D->Bind(EVT_GLCANVAS_INSTANCE_MOVED, [this](SimpleEvent&) { update(); });
|
||||
canvas3D->Bind(EVT_GLCANVAS_WIPETOWER_MOVED, &priv::on_wipetower_moved, this);
|
||||
|
@ -1043,13 +984,7 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame) :
|
|||
canvas3D->Bind(EVT_GLTOOLBAR_SPLIT_OBJECTS, &priv::on_action_split_objects, this);
|
||||
canvas3D->Bind(EVT_GLTOOLBAR_SPLIT_VOLUMES, &priv::on_action_split_volumes, this);
|
||||
canvas3D->Bind(EVT_GLTOOLBAR_CUT, &priv::on_action_cut, this);
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
canvas3D->Bind(EVT_GLTOOLBAR_SETTINGS, &priv::on_action_settings, this);
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
canvas3D->Bind(EVT_GLTOOLBAR_LAYERSEDITING, &priv::on_action_layersediting, this);
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
canvas3D->Bind(EVT_GLTOOLBAR_SELECTBYPARTS, &priv::on_action_selectbyparts, this);
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
|
||||
// Preview events:
|
||||
preview->get_wxglcanvas()->Bind(EVT_GLCANVAS_VIEWPORT_CHANGED, &priv::on_viewport_changed, this);
|
||||
|
@ -1064,17 +999,6 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame) :
|
|||
q->Layout();
|
||||
}
|
||||
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
std::vector<int> Plater::priv::collect_selections()
|
||||
{
|
||||
std::vector<int> res;
|
||||
for (const auto &obj : objects) {
|
||||
res.push_back(obj.selected);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
|
||||
void Plater::priv::update(bool force_autocenter)
|
||||
{
|
||||
wxWindowUpdateLocker freeze_guard(q);
|
||||
|
@ -1086,10 +1010,6 @@ void Plater::priv::update(bool force_autocenter)
|
|||
model.center_instances_around_point(bed_center);
|
||||
}
|
||||
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
const auto selections = collect_selections();
|
||||
_3DScene::set_objects_selections(canvas3D, selections);
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
_3DScene::reload_scene(canvas3D, false);
|
||||
preview->reset_gcode_preview_data();
|
||||
preview->reload_print();
|
||||
|
@ -1261,19 +1181,12 @@ std::vector<size_t> Plater::priv::load_model_objects(const ModelObjectPtrs &mode
|
|||
bool need_arrange = false;
|
||||
bool scaled_down = false;
|
||||
std::vector<size_t> obj_idxs;
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
unsigned int obj_count = model.objects.size();
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
for (ModelObject *model_object : model_objects) {
|
||||
auto *object = model.add_object(*model_object);
|
||||
std::string object_name = object->name.empty() ? fs::path(object->input_file).filename().string() : object->name;
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
obj_idxs.push_back(obj_count++);
|
||||
#else
|
||||
objects.emplace_back(std::move(object_name));
|
||||
obj_idxs.push_back(objects.size() - 1);
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
if (model_object->instances.empty()) {
|
||||
// if object has no defined position(s) we need to rearrange everything after loading
|
||||
|
@ -1385,7 +1298,6 @@ std::unique_ptr<CheckboxFileDialog> Plater::priv::get_export_file(GUI::FileType
|
|||
return dlg;
|
||||
}
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
const GLCanvas3D::Selection& Plater::priv::get_selection() const
|
||||
{
|
||||
return _3DScene::get_canvas(canvas3D)->get_selection();
|
||||
|
@ -1401,43 +1313,9 @@ int Plater::priv::get_selected_object_idx() const
|
|||
int idx = get_selection().get_object_idx();
|
||||
return ((0 <= idx) && (idx < 1000)) ? idx : -1;
|
||||
}
|
||||
#else
|
||||
void Plater::priv::select_object(optional<size_t> obj_idx)
|
||||
{
|
||||
for (auto &obj : objects) {
|
||||
obj.selected = false;
|
||||
}
|
||||
|
||||
if (obj_idx) {
|
||||
objects[*obj_idx].selected = true;
|
||||
}
|
||||
|
||||
selection_changed();
|
||||
}
|
||||
|
||||
void Plater::priv::select_object_from_cpp()
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
optional<size_t> Plater::priv::selected_object() const
|
||||
{
|
||||
for (size_t i = 0; i < objects.size(); i++) {
|
||||
if (objects[i].selected) { return i; }
|
||||
}
|
||||
|
||||
return boost::none;
|
||||
}
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
void Plater::priv::selection_changed()
|
||||
{
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
const auto obj_idx = selected_object();
|
||||
const bool have_sel = !!obj_idx;
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
_3DScene::enable_toolbar_item(canvas3D, "delete", can_delete_object());
|
||||
_3DScene::enable_toolbar_item(canvas3D, "more", can_increase_instances());
|
||||
_3DScene::enable_toolbar_item(canvas3D, "fewer", can_decrease_instances());
|
||||
|
@ -1447,45 +1325,13 @@ void Plater::priv::selection_changed()
|
|||
_3DScene::enable_toolbar_item(canvas3D, "layersediting", layers_height_allowed());
|
||||
// forces a frame render to update the view (to avoid a missed update if, for example, the context menu appears)
|
||||
_3DScene::render(canvas3D);
|
||||
#else
|
||||
_3DScene::enable_toolbar_item(canvas3D, "fewer", have_sel);
|
||||
_3DScene::enable_toolbar_item(canvas3D, "splitobjects", have_sel);
|
||||
_3DScene::enable_toolbar_item(canvas3D, "splitvolumes", have_sel);
|
||||
_3DScene::enable_toolbar_item(canvas3D, "cut", have_sel);
|
||||
_3DScene::enable_toolbar_item(canvas3D, "settings", have_sel);
|
||||
_3DScene::enable_toolbar_item(canvas3D, "layersediting", have_sel && config->opt_bool("variable_layer_height") && _3DScene::is_layers_editing_allowed(canvas3D));
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
int obj_idx = get_selected_object_idx();
|
||||
bool have_sel = (obj_idx != -1);
|
||||
#else
|
||||
bool can_select_by_parts = false;
|
||||
|
||||
if (have_sel) {
|
||||
const auto *model_object = model.objects[*obj_idx];
|
||||
// XXX: ?
|
||||
can_select_by_parts = *obj_idx < 1000 && model_object->volumes.size() > 1;
|
||||
_3DScene::enable_toolbar_item(canvas3D, "fewer", model_object->instances.size() > 1);
|
||||
}
|
||||
|
||||
if (can_select_by_parts) {
|
||||
// first disable to let the item in the toolbar to switch to the unpressed state // XXX: ?
|
||||
_3DScene::enable_toolbar_item(canvas3D, "selectbyparts", false);
|
||||
_3DScene::enable_toolbar_item(canvas3D, "selectbyparts", true);
|
||||
} else {
|
||||
_3DScene::enable_toolbar_item(canvas3D, "selectbyparts", false);
|
||||
_3DScene::set_select_by(canvas3D, "object");
|
||||
}
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
wxWindowUpdateLocker freeze_guard(sidebar);
|
||||
if (have_sel) {
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
const ModelObject* model_object = model.objects[obj_idx];
|
||||
#else
|
||||
const auto *model_object = model.objects[*obj_idx];
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
// FIXME print_info runs model fixing in two rounds, it is very slow, it should not be performed here!
|
||||
// # $model_object->print_info;
|
||||
|
||||
|
@ -1531,33 +1377,16 @@ void Plater::priv::selection_changed()
|
|||
void Plater::priv::object_list_changed()
|
||||
{
|
||||
// Enable/disable buttons depending on whether there are any objects on the platter.
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
_3DScene::enable_toolbar_item(canvas3D, "deleteall", can_delete_all());
|
||||
_3DScene::enable_toolbar_item(canvas3D, "arrange", can_arrange());
|
||||
#else
|
||||
const bool have_objects = !objects.empty();
|
||||
_3DScene::enable_toolbar_item(canvas3D, "deleteall", have_objects);
|
||||
_3DScene::enable_toolbar_item(canvas3D, "arrange", have_objects);
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
const bool export_in_progress = this->background_process.is_export_scheduled(); // || ! send_gcode_file.empty());
|
||||
// XXX: is this right?
|
||||
const bool model_fits = _3DScene::check_volumes_outside_state(canvas3D, config) == ModelInstance::PVS_Inside;
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
sidebar->enable_buttons(!model.objects.empty() && !export_in_progress && model_fits);
|
||||
#else
|
||||
sidebar->enable_buttons(have_objects && !export_in_progress && model_fits);
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
}
|
||||
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
void Plater::priv::select_view()
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
|
||||
void Plater::priv::remove(size_t obj_idx)
|
||||
{
|
||||
// Prevent toolpaths preview from rendering while we modify the Print object
|
||||
|
@ -1566,19 +1395,12 @@ void Plater::priv::remove(size_t obj_idx)
|
|||
if (_3DScene::is_layers_editing_enabled(canvas3D))
|
||||
_3DScene::enable_layers_editing(canvas3D, false);
|
||||
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
objects.erase(objects.begin() + obj_idx);
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
model.delete_object(obj_idx);
|
||||
// print.delete_object(obj_idx);
|
||||
// Delete object from Sidebar list
|
||||
sidebar->obj_list()->delete_object_from_list(obj_idx);
|
||||
|
||||
object_list_changed();
|
||||
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
select_object(boost::none);
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
update();
|
||||
}
|
||||
|
||||
|
@ -1590,43 +1412,20 @@ void Plater::priv::reset()
|
|||
if (_3DScene::is_layers_editing_enabled(canvas3D))
|
||||
_3DScene::enable_layers_editing(canvas3D, false);
|
||||
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
objects.clear();
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
model.clear_objects();
|
||||
// print.clear_objects();
|
||||
|
||||
// Delete all objects from list on c++ side
|
||||
sidebar->obj_list()->delete_all_objects_from_list();
|
||||
object_list_changed();
|
||||
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
select_object(boost::none);
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
update();
|
||||
}
|
||||
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
void Plater::priv::rotate()
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
|
||||
void Plater::priv::mirror(Axis axis)
|
||||
{
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
_3DScene::mirror_selection(canvas3D, axis);
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
}
|
||||
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
void Plater::priv::scale()
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
|
||||
void Plater::priv::arrange()
|
||||
{
|
||||
main_frame->app_controller()->arrange_model();
|
||||
|
@ -1639,7 +1438,6 @@ void Plater::priv::arrange()
|
|||
|
||||
void Plater::priv::split_object()
|
||||
{
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
int obj_idx = get_selected_object_idx();
|
||||
if (obj_idx == -1)
|
||||
return;
|
||||
|
@ -1683,7 +1481,6 @@ void Plater::priv::split_object()
|
|||
get_selection().add_object((unsigned int)idx, false);
|
||||
}
|
||||
}
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
}
|
||||
|
||||
void Plater::priv::split_volume()
|
||||
|
@ -1723,11 +1520,9 @@ void Plater::priv::async_apply_config()
|
|||
this->preview->reload_print();
|
||||
// We also need to reload 3D scene because of the wipe tower preview box
|
||||
if (this->config->opt_bool("wipe_tower")) {
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
std::vector<int> selections = this->collect_selections();
|
||||
Slic3r::_3DScene::set_objects_selections(this->canvas3D, selections);
|
||||
Slic3r::_3DScene::reload_scene(this->canvas3D, 1);
|
||||
#endif /* !ENABLE_EXTENDED_SELECTION */
|
||||
// std::vector<int> selections = this->collect_selections();
|
||||
// Slic3r::_3DScene::set_objects_selections(this->canvas3D, selections);
|
||||
// Slic3r::_3DScene::reload_scene(this->canvas3D, 1);
|
||||
}
|
||||
}
|
||||
if (invalidated != Print::APPLY_STATUS_UNCHANGED && this->get_config("background_processing") == "1" &&
|
||||
|
@ -1801,9 +1596,6 @@ void Plater::priv::on_notebook_changed(wxBookCtrlEvent&)
|
|||
const auto current_id = notebook->GetCurrentPage()->GetId();
|
||||
if (current_id == canvas3D->GetId()) {
|
||||
if (_3DScene::is_reload_delayed(canvas3D)) {
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
_3DScene::set_objects_selections(canvas3D, collect_selections());
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
_3DScene::reload_scene(canvas3D, true);
|
||||
}
|
||||
// sets the canvas as dirty to force a render at the 1st idle event (wxWidgets IsShownOnScreen() is buggy and cannot be used reliably)
|
||||
|
@ -1865,12 +1657,10 @@ void Plater::priv::on_update_print_preview(wxCommandEvent &)
|
|||
if (this->preview != nullptr)
|
||||
this->preview->reload_print();
|
||||
// in case this was MM print, wipe tower bounding box on 3D tab might need redrawing with exact depth:
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
auto selections = collect_selections();
|
||||
_3DScene::set_objects_selections(canvas3D, selections);
|
||||
if (canvas3D)
|
||||
_3DScene::reload_scene(canvas3D, true);
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
// auto selections = collect_selections();
|
||||
// _3DScene::set_objects_selections(canvas3D, selections);
|
||||
// if (canvas3D)
|
||||
// _3DScene::reload_scene(canvas3D, true);
|
||||
}
|
||||
|
||||
void Plater::priv::on_process_completed(wxCommandEvent &evt)
|
||||
|
@ -1942,13 +1732,6 @@ void Plater::priv::on_action_cut(SimpleEvent&)
|
|||
// TODO
|
||||
}
|
||||
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
void Plater::priv::on_action_settings(SimpleEvent&)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
|
||||
void Plater::priv::on_action_layersediting(SimpleEvent&)
|
||||
{
|
||||
bool enable = !_3DScene::is_layers_editing_enabled(canvas3D);
|
||||
|
@ -1957,31 +1740,11 @@ void Plater::priv::on_action_layersediting(SimpleEvent&)
|
|||
_3DScene::enable_toolbar_item(canvas3D, "layersediting", false);
|
||||
}
|
||||
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
void Plater::priv::on_action_selectbyparts(SimpleEvent&)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
void Plater::priv::on_object_select(SimpleEvent& evt)
|
||||
{
|
||||
selection_changed();
|
||||
wxGetApp().obj_list()->update_selections();
|
||||
}
|
||||
#else
|
||||
void Plater::priv::on_object_select(ObjectSelectEvent &evt)
|
||||
{
|
||||
const auto obj_idx = evt.object_id();
|
||||
const auto vol_idx = evt.volume_id();
|
||||
|
||||
if (obj_idx >= 0 && obj_idx < 1000 && vol_idx == -1) {
|
||||
// Ignore the special objects (the wipe tower proxy and such).
|
||||
select_object(obj_idx);
|
||||
}
|
||||
}
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
void Plater::priv::on_viewport_changed(SimpleEvent& evt)
|
||||
{
|
||||
|
@ -1994,16 +1757,12 @@ void Plater::priv::on_viewport_changed(SimpleEvent& evt)
|
|||
|
||||
void Plater::priv::on_right_click(Vec2dEvent& evt)
|
||||
{
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
int obj_idx = get_selected_object_idx();
|
||||
if (obj_idx == -1)
|
||||
return;
|
||||
|
||||
if (q != nullptr)
|
||||
q->PopupMenu(&object_menu, (int)evt.data.x(), (int)evt.data.y());
|
||||
#else
|
||||
// TODO
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
}
|
||||
|
||||
void Plater::priv::on_model_update(SimpleEvent&)
|
||||
|
@ -2011,42 +1770,6 @@ void Plater::priv::on_model_update(SimpleEvent&)
|
|||
// TODO
|
||||
}
|
||||
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
void Plater::priv::on_scale_uniformly(SimpleEvent&)
|
||||
{
|
||||
// my ($scale) = @_;
|
||||
|
||||
// my ($obj_idx, $object) = $self->selected_object;
|
||||
const auto obj_idx = selected_object();
|
||||
if (! obj_idx) { return; }
|
||||
// return if !defined $obj_idx;
|
||||
|
||||
// my $model_object = $self->{model}->objects->[$obj_idx];
|
||||
// my $model_instance = $model_object->instances->[0];
|
||||
|
||||
// my $variation = $scale / $model_instance->scaling_factor;
|
||||
// #FIXME Scale the layer height profile?
|
||||
// foreach my $range (@{ $model_object->layer_height_ranges }) {
|
||||
// $range->[0] *= $variation;
|
||||
// $range->[1] *= $variation;
|
||||
// }
|
||||
// $_->set_scaling_factor($scale) for @{ $model_object->instances };
|
||||
|
||||
// # Set object scale on c++ side
|
||||
// # Slic3r::GUI::set_object_scale($obj_idx, $model_object->instances->[0]->scaling_factor * 100);
|
||||
|
||||
// # $object->transform_thumbnail($self->{model}, $obj_idx);
|
||||
|
||||
// #update print and start background processing
|
||||
// $self->{print}->add_model_object($model_object, $obj_idx);
|
||||
|
||||
// $self->selection_changed(1); # refresh info (size, volume etc.)
|
||||
// $self->update;
|
||||
|
||||
this->schedule_background_process();
|
||||
}
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
|
||||
void Plater::priv::on_wipetower_moved(Vec3dEvent &evt)
|
||||
{
|
||||
DynamicPrintConfig cfg;
|
||||
|
@ -2102,7 +1825,6 @@ bool Plater::priv::init_object_menu()
|
|||
|
||||
wxMenuItem* item_split = append_submenu(&object_menu, split_menu, wxID_ANY, _(L("Split")), _(L("Split the selected object")), "shape_ungroup.png");
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
// ui updates needs to be binded to the parent panel
|
||||
if (q != nullptr)
|
||||
{
|
||||
|
@ -2115,12 +1837,10 @@ bool Plater::priv::init_object_menu()
|
|||
q->Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable(can_split_to_objects()); }, item_split_objects->GetId());
|
||||
q->Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable(can_split_to_volumes()); }, item_split_volumes->GetId());
|
||||
}
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
bool Plater::priv::can_delete_object() const
|
||||
{
|
||||
int obj_idx = get_selected_object_idx();
|
||||
|
@ -2177,7 +1897,6 @@ bool Plater::priv::can_mirror() const
|
|||
{
|
||||
return get_selection().is_from_single_instance();
|
||||
}
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
// Plater / Public
|
||||
|
||||
|
@ -2218,51 +1937,28 @@ void Plater::remove(size_t obj_idx) { p->remove(obj_idx); }
|
|||
|
||||
void Plater::remove_selected()
|
||||
{
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
int obj_idx = p->get_selected_object_idx();
|
||||
if (obj_idx != -1)
|
||||
remove((size_t)obj_idx);
|
||||
#else
|
||||
const auto selected = p->selected_object();
|
||||
if (selected) {
|
||||
remove(*selected);
|
||||
}
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
}
|
||||
|
||||
void Plater::increase_instances(size_t num)
|
||||
{
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
int obj_idx = p->get_selected_object_idx();
|
||||
if (obj_idx == -1)
|
||||
return;
|
||||
|
||||
ModelObject* model_object = p->model.objects[obj_idx];
|
||||
ModelInstance* model_instance = model_object->instances.back();
|
||||
#else
|
||||
const auto obj_idx = p->selected_object();
|
||||
if (! obj_idx) { return; }
|
||||
|
||||
auto *model_object = p->model.objects[*obj_idx];
|
||||
auto *model_instance = model_object->instances[model_object->instances.size() - 1];
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
float offset = 10.0;
|
||||
for (size_t i = 0; i < num; i++, offset += 10.0) {
|
||||
Vec3d offset_vec = model_instance->get_offset() + Vec3d(offset, offset, 0.0);
|
||||
model_object->add_instance(offset_vec, model_instance->get_scaling_factor(), model_instance->get_rotation());
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
// p->print.get_object(obj_idx)->add_copy(Slic3r::to_2d(offset_vec));
|
||||
#else
|
||||
// p->print.get_object(*obj_idx)->add_copy(Slic3r::to_2d(offset_vec));
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
}
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
sidebar().obj_list()->increase_object_instances(obj_idx, num);
|
||||
#else
|
||||
sidebar().obj_list()->increase_object_instances(*obj_idx, num);
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
if (p->get_config("autocenter") == "1") {
|
||||
p->arrange();
|
||||
|
@ -2270,9 +1966,7 @@ void Plater::increase_instances(size_t num)
|
|||
p->update();
|
||||
}
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
p->get_selection().add_instance(obj_idx, (int)model_object->instances.size() - 1);
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
p->selection_changed();
|
||||
|
||||
|
@ -2281,47 +1975,26 @@ void Plater::increase_instances(size_t num)
|
|||
|
||||
void Plater::decrease_instances(size_t num)
|
||||
{
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
int obj_idx = p->get_selected_object_idx();
|
||||
if (obj_idx == -1)
|
||||
return;
|
||||
|
||||
ModelObject* model_object = p->model.objects[obj_idx];
|
||||
#else
|
||||
const auto obj_idx = p->selected_object();
|
||||
if (! obj_idx) { return; }
|
||||
|
||||
auto *model_object = p->model.objects[*obj_idx];
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
if (model_object->instances.size() > num) {
|
||||
for (size_t i = 0; i < num; i++) {
|
||||
model_object->delete_last_instance();
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
// p->print.get_object(obj_idx)->delete_last_copy();
|
||||
#else
|
||||
// p->print.get_object(*obj_idx)->delete_last_copy();
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
}
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
sidebar().obj_list()->decrease_object_instances(obj_idx, num);
|
||||
#else
|
||||
sidebar().obj_list()->decrease_object_instances(*obj_idx, num);
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
}
|
||||
else {
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
remove(obj_idx);
|
||||
#else
|
||||
remove(*obj_idx);
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
}
|
||||
|
||||
p->update();
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
if (!model_object->instances.empty())
|
||||
p->get_selection().add_instance(obj_idx, (int)model_object->instances.size() - 1);
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
p->selection_changed();
|
||||
this->p->schedule_background_process();
|
||||
|
@ -2329,18 +2002,11 @@ void Plater::decrease_instances(size_t num)
|
|||
|
||||
void Plater::set_number_of_copies(/*size_t num*/)
|
||||
{
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
int obj_idx = p->get_selected_object_idx();
|
||||
if (obj_idx == -1)
|
||||
return;
|
||||
|
||||
ModelObject* model_object = p->model.objects[obj_idx];
|
||||
#else
|
||||
const auto obj_idx = p->selected_object();
|
||||
if (! obj_idx) { return; }
|
||||
|
||||
auto *model_object = p->model.objects[*obj_idx];
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
const auto num = wxGetNumberFromUser( " ", _("Enter the number of copies:"),
|
||||
_("Copies of the selected object"), model_object->instances.size(), 0, 1000, this );
|
||||
|
@ -2356,13 +2022,8 @@ void Plater::set_number_of_copies(/*size_t num*/)
|
|||
|
||||
void Plater::export_gcode(fs::path output_path)
|
||||
{
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
if (p->model.objects.empty())
|
||||
return;
|
||||
#else
|
||||
if (p->objects.empty())
|
||||
return;
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
if (this->p->background_process.is_export_scheduled()) {
|
||||
GUI::show_error(this, _(L("Another export job is currently running.")));
|
||||
|
@ -2414,11 +2075,7 @@ void Plater::export_gcode(fs::path output_path)
|
|||
|
||||
void Plater::export_stl()
|
||||
{
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
if (p->model.objects.empty()) { return; }
|
||||
#else
|
||||
if (p->objects.empty()) { return; }
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
auto dialog = p->get_export_file(FT_STL);
|
||||
if (! dialog) { return; }
|
||||
|
@ -2433,11 +2090,7 @@ void Plater::export_stl()
|
|||
|
||||
void Plater::export_amf()
|
||||
{
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
if (p->model.objects.empty()) { return; }
|
||||
#else
|
||||
if (p->objects.empty()) { return; }
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
auto dialog = p->get_export_file(FT_AMF);
|
||||
if (! dialog) { return; }
|
||||
|
@ -2456,11 +2109,7 @@ void Plater::export_amf()
|
|||
|
||||
void Plater::export_3mf()
|
||||
{
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
if (p->model.objects.empty()) { return; }
|
||||
#else
|
||||
if (p->objects.empty()) { return; }
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
auto dialog = p->get_export_file(FT_3MF);
|
||||
if (! dialog) { return; }
|
||||
|
@ -2600,11 +2249,6 @@ void Plater::changed_object(int obj_idx)
|
|||
// update print
|
||||
if (list->is_parts_changed() || list->is_part_settings_changed()) {
|
||||
this->p->schedule_background_process();
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
if (p->canvas3D) _3DScene::reload_scene(p->canvas3D, true);
|
||||
auto selections = p->collect_selections();
|
||||
_3DScene::set_objects_selections(p->canvas3D, selections);
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
#if !ENABLE_MODIFIED_CAMERA_TARGET
|
||||
_3DScene::zoom_to_volumes(p->canvas3D);
|
||||
#endif // !ENABLE_MODIFIED_CAMERA_TARGET
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue