mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-14 06:26:05 +08:00
Moved assignable methods to std::function objects.
This commit is contained in:
parent
27e4e4b8b5
commit
ac7c93850a
@ -23,31 +23,22 @@ Plater::Plater(wxWindow* parent, const wxString& title, std::shared_ptr<Settings
|
|||||||
wxPostEvent(this, new wxPlThreadEvent(-1, PROGRESS_BAR_EVENT,
|
wxPostEvent(this, new wxPlThreadEvent(-1, PROGRESS_BAR_EVENT,
|
||||||
});
|
});
|
||||||
*/
|
*/
|
||||||
auto on_select_object { [=](size_t& obj_idx) {
|
|
||||||
this->select_object(obj_idx);
|
// Initialize handlers for canvases
|
||||||
|
auto on_select_object {[this](ObjIdx obj_idx) { this->select_object(obj_idx); }};
|
||||||
|
auto on_double_click {[this]() { if (this->selected_object() != this->objects.end()) this->object_settings_dialog(); }};
|
||||||
|
auto on_right_click {[this](wxPanel* canvas, const wxPoint& pos)
|
||||||
|
{
|
||||||
|
auto obj = this->selected_object();
|
||||||
|
if (obj == this->objects.end()) return;
|
||||||
|
|
||||||
|
auto menu = this->object_menu();
|
||||||
|
canvas->PopupMenu(menu, pos);
|
||||||
|
delete menu;
|
||||||
}};
|
}};
|
||||||
|
auto on_instances_moved {[this]() { this->on_model_change(); }};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
# Initialize handlers for canvases
|
|
||||||
my $on_select_object = sub {
|
|
||||||
my ($obj_idx) = @_;
|
|
||||||
$self->select_object($obj_idx);
|
|
||||||
};
|
|
||||||
my $on_double_click = sub {
|
|
||||||
$self->object_settings_dialog if $self->selected_object;
|
|
||||||
};
|
|
||||||
my $on_right_click = sub {
|
|
||||||
my ($canvas, $click_pos) = @_;
|
|
||||||
|
|
||||||
my ($obj_idx, $object) = $self->selected_object;
|
|
||||||
return if !defined $obj_idx;
|
|
||||||
|
|
||||||
my $menu = $self->object_menu;
|
|
||||||
$canvas->PopupMenu($menu, $click_pos);
|
|
||||||
$menu->Destroy;
|
|
||||||
};
|
|
||||||
my $on_instances_moved = sub {
|
|
||||||
$self->on_model_change;
|
|
||||||
};
|
|
||||||
# Initialize 3D plater
|
# Initialize 3D plater
|
||||||
if ($Slic3r::GUI::have_OpenGL) {
|
if ($Slic3r::GUI::have_OpenGL) {
|
||||||
$self->{canvas3D} = Slic3r::GUI::Plater::3D->new($self->{preview_notebook}, $self->{objects}, $self->{model}, $self->{config});
|
$self->{canvas3D} = Slic3r::GUI::Plater::3D->new($self->{preview_notebook}, $self->{objects}, $self->{model}, $self->{config});
|
||||||
@ -61,9 +52,15 @@ Plater::Plater(wxWindow* parent, const wxString& title, std::shared_ptr<Settings
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// initialize 2D Preview Canvas
|
||||||
canvas2D = new Plate2D(preview_notebook, wxDefaultSize, objects, model, config, settings);
|
canvas2D = new Plate2D(preview_notebook, wxDefaultSize, objects, model, config, settings);
|
||||||
preview_notebook->AddPage(canvas2D, _("2D"));
|
preview_notebook->AddPage(canvas2D, _("2D"));
|
||||||
|
|
||||||
|
canvas2D->on_select_object = std::function<void (ObjIdx obj_idx)>(on_select_object);
|
||||||
|
canvas2D->on_double_click = std::function<void ()>(on_double_click);
|
||||||
|
canvas2D->on_right_click = std::function<void (const wxPoint& pos)>([=](const wxPoint& pos){ on_right_click(canvas2D, pos); });
|
||||||
|
|
||||||
canvas3D = new Plate3D(preview_notebook, wxDefaultSize, objects, model, config, settings);
|
canvas3D = new Plate3D(preview_notebook, wxDefaultSize, objects, model, config, settings);
|
||||||
preview_notebook->AddPage(canvas3D, _("3D"));
|
preview_notebook->AddPage(canvas3D, _("3D"));
|
||||||
|
|
||||||
|
@ -202,8 +202,6 @@ void Plate2D::mouse_down(wxMouseEvent& e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
void Plate2D::on_select_object(int i) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void Plate2D::mouse_up(wxMouseEvent& e) {
|
void Plate2D::mouse_up(wxMouseEvent& e) {
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,17 @@ public:
|
|||||||
|
|
||||||
/// Read print bed size from config and calculate the scaled rendition of the bed given the draw canvas.
|
/// Read print bed size from config and calculate the scaled rendition of the bed given the draw canvas.
|
||||||
void update_bed_size();
|
void update_bed_size();
|
||||||
// std::function<> on_select_object {};
|
|
||||||
|
std::function<void (const unsigned int obj_idx)> on_select_object {};
|
||||||
|
std::function<void ()> on_double_click {};
|
||||||
|
|
||||||
|
/// Do something on right-clicks.
|
||||||
|
std::function<void (const wxPoint& pos)> on_right_click {};
|
||||||
|
std::function<void ()> on_instances_moved {};
|
||||||
|
|
||||||
|
|
||||||
|
void set_selected (long obj, long inst) { this->selected_instance = {obj, inst}; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<PlaterObject>& objects; //< reference to parent vector
|
std::vector<PlaterObject>& objects; //< reference to parent vector
|
||||||
std::shared_ptr<Slic3r::Model> model;
|
std::shared_ptr<Slic3r::Model> model;
|
||||||
@ -77,8 +87,6 @@ private:
|
|||||||
|
|
||||||
wxPoint drag_start_pos {};
|
wxPoint drag_start_pos {};
|
||||||
|
|
||||||
/// Do something on right-clicks.
|
|
||||||
void on_right_click(const wxPoint& pos) { }
|
|
||||||
|
|
||||||
/// Handle repaint events
|
/// Handle repaint events
|
||||||
void repaint(wxPaintEvent& e);
|
void repaint(wxPaintEvent& e);
|
||||||
@ -132,8 +140,6 @@ private:
|
|||||||
|
|
||||||
/// Remove all instance thumbnails.
|
/// Remove all instance thumbnails.
|
||||||
void clean_instance_thumbnails();
|
void clean_instance_thumbnails();
|
||||||
|
|
||||||
void on_select_object(int);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} } // Namespace Slic3r::GUI
|
} } // Namespace Slic3r::GUI
|
||||||
|
Loading…
x
Reference in New Issue
Block a user