Merge branch 'master' of https://github.com/prusa3d/Slic3r into objects_centering
This commit is contained in:
commit
348aa48121
@ -297,9 +297,16 @@ std::string GLCanvas3D::Camera::get_type_as_string() const
|
||||
};
|
||||
}
|
||||
|
||||
void GLCanvas3D::Camera::set_theta(float theta)
|
||||
void GLCanvas3D::Camera::set_theta(float theta, bool apply_limit)
|
||||
{
|
||||
m_theta = clamp(0.0f, GIMBALL_LOCK_THETA_MAX, theta);
|
||||
if (apply_limit)
|
||||
m_theta = clamp(0.0f, GIMBALL_LOCK_THETA_MAX, theta);
|
||||
else
|
||||
{
|
||||
m_theta = fmod(theta, 360.0f);
|
||||
if (m_theta < 0.0f)
|
||||
m_theta += 360.0f;
|
||||
}
|
||||
}
|
||||
|
||||
void GLCanvas3D::Camera::set_target(const Vec3d& target, GLCanvas3D& canvas)
|
||||
@ -4215,7 +4222,7 @@ void GLCanvas3D::select_view(const std::string& direction)
|
||||
if (dir_vec != nullptr)
|
||||
{
|
||||
m_camera.phi = dir_vec[0];
|
||||
m_camera.set_theta(dir_vec[1]);
|
||||
m_camera.set_theta(dir_vec[1], false);
|
||||
|
||||
viewport_changed();
|
||||
|
||||
@ -4227,7 +4234,7 @@ void GLCanvas3D::select_view(const std::string& direction)
|
||||
void GLCanvas3D::set_viewport_from_scene(const GLCanvas3D& other)
|
||||
{
|
||||
m_camera.phi = other.m_camera.phi;
|
||||
m_camera.set_theta(other.m_camera.get_theta());
|
||||
m_camera.set_theta(other.m_camera.get_theta(), false);
|
||||
m_camera.set_scene_box(other.m_camera.get_scene_box(), *this);
|
||||
m_camera.set_target(other.m_camera.get_target(), *this);
|
||||
m_camera.zoom = other.m_camera.zoom;
|
||||
@ -4303,6 +4310,10 @@ void GLCanvas3D::render()
|
||||
::glLightfv(GL_LIGHT0, GL_POSITION, position_top);
|
||||
|
||||
float theta = m_camera.get_theta();
|
||||
if (theta > 180.f)
|
||||
// absolute value of the rotation
|
||||
theta = 360.f - theta;
|
||||
|
||||
bool is_custom_bed = m_bed.is_custom();
|
||||
|
||||
#if ENABLE_IMGUI
|
||||
@ -5308,7 +5319,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
||||
{
|
||||
const Vec3d& orig = m_mouse.drag.start_position_3D;
|
||||
m_camera.phi += (((float)pos(0) - (float)orig(0)) * TRACKBALLSIZE);
|
||||
m_camera.set_theta(m_camera.get_theta() - ((float)pos(1) - (float)orig(1)) * TRACKBALLSIZE);
|
||||
m_camera.set_theta(m_camera.get_theta() - ((float)pos(1) - (float)orig(1)) * TRACKBALLSIZE, wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology() != ptSLA);
|
||||
|
||||
viewport_changed();
|
||||
|
||||
@ -6453,7 +6464,11 @@ public:
|
||||
#ifdef _MSC_VER
|
||||
typedef void (__stdcall *_GLUfuncptr)(void);
|
||||
#else /* _MSC_VER */
|
||||
typedef void (GLAPIENTRYP _GLUfuncptr)(void);
|
||||
#ifdef GLAPIENTRYP
|
||||
typedef void (GLAPIENTRYP _GLUfuncptr)(void);
|
||||
#else /* GLAPIENTRYP */
|
||||
typedef void (*_GLUfuncptr)(void);
|
||||
#endif
|
||||
#endif /* _MSC_VER */
|
||||
#endif /* _GLUfuncptr */
|
||||
gluTessCallback(tess, GLU_TESS_BEGIN, (_GLUfuncptr)tessBeginCB);
|
||||
|
@ -175,7 +175,7 @@ class GLCanvas3D
|
||||
std::string get_type_as_string() const;
|
||||
|
||||
float get_theta() const { return m_theta; }
|
||||
void set_theta(float theta);
|
||||
void set_theta(float theta, bool apply_limit);
|
||||
|
||||
const Vec3d& get_target() const { return m_target; }
|
||||
void set_target(const Vec3d& target, GLCanvas3D& canvas);
|
||||
|
@ -159,7 +159,7 @@ bool GUI_App::OnInit()
|
||||
|
||||
// ! Temporary workaround for the correct behavior of the Scrolled sidebar panel
|
||||
// Do this "manipulations" only once ( after (re)create of the application )
|
||||
if (sidebar().obj_list()->GetMinHeight() > 200)
|
||||
if (plater_ && sidebar().obj_list()->GetMinHeight() > 200)
|
||||
{
|
||||
wxWindowUpdateLocker noUpdates_sidebar(&sidebar());
|
||||
sidebar().obj_list()->SetMinSize(wxSize(-1, 200));
|
||||
@ -273,6 +273,11 @@ void GUI_App::recreate_GUI()
|
||||
std::cerr << "recreate_GUI" << std::endl;
|
||||
|
||||
clear_tabs_list();
|
||||
if (plater_) {
|
||||
// before creating a new plater let's delete old one
|
||||
plater_->Destroy();
|
||||
plater_ = nullptr;
|
||||
}
|
||||
|
||||
MainFrame* topwindow = dynamic_cast<MainFrame*>(GetTopWindow());
|
||||
mainframe = new MainFrame();
|
||||
@ -531,10 +536,11 @@ void GUI_App::update_mode()
|
||||
|
||||
const ConfigOptionMode mode = wxGetApp().get_mode();
|
||||
|
||||
obj_list()->get_sizer()->Show(mode == comExpert);
|
||||
obj_list()->get_sizer()->Show(mode > comSimple);
|
||||
sidebar().set_mode_value(mode);
|
||||
// sidebar().show_buttons(mode == comExpert);
|
||||
obj_list()->update_selections();
|
||||
obj_list()->update_object_menu();
|
||||
|
||||
sidebar().update_mode_sizer(mode);
|
||||
|
||||
|
@ -696,9 +696,11 @@ void ObjectList::get_settings_choice(const wxString& category_name)
|
||||
void ObjectList::append_menu_item_add_generic(wxMenuItem* menu, const int type) {
|
||||
auto sub_menu = new wxMenu;
|
||||
|
||||
if (wxGetApp().get_mode() == comExpert) {
|
||||
append_menu_item(sub_menu, wxID_ANY, _(L("Load")) + " " + dots, "",
|
||||
[this, type](wxCommandEvent&) { load_subobject(type); }, "", menu->GetMenu());
|
||||
sub_menu->AppendSeparator();
|
||||
}
|
||||
|
||||
std::vector<std::string> menu_items = { L("Box"), L("Cylinder"), L("Sphere"), L("Slab") };
|
||||
for (auto& item : menu_items) {
|
||||
@ -709,7 +711,7 @@ void ObjectList::append_menu_item_add_generic(wxMenuItem* menu, const int type)
|
||||
menu->SetSubMenu(sub_menu);
|
||||
}
|
||||
|
||||
void ObjectList::append_menu_items_add_volume(wxMenu* menu)
|
||||
void ObjectList::append_menu_items_add_volume(wxMenu* menu, wxMenuItem* *item_separator)
|
||||
{
|
||||
// Note: id accords to type of the sub-object, so sequence of the menu items is important
|
||||
std::vector<std::string> menu_object_types_items = {L("Add part"), // ~ModelVolume::MODEL_PART
|
||||
@ -723,11 +725,17 @@ void ObjectList::append_menu_items_add_volume(wxMenu* menu)
|
||||
if (settings_id != wxNOT_FOUND)
|
||||
menu->Destroy(settings_id);
|
||||
}
|
||||
if (*item_separator)
|
||||
menu->Destroy(*item_separator);
|
||||
|
||||
if (wxGetApp().get_mode() == comSimple)
|
||||
const ConfigOptionMode mode = wxGetApp().get_mode();
|
||||
|
||||
if (mode < comExpert)
|
||||
{
|
||||
append_menu_item(menu, wxID_ANY, _(L("Add part")), "",
|
||||
[this](wxCommandEvent&) { load_subobject(ModelVolume::MODEL_PART); }, *m_bmp_vector[ModelVolume::MODEL_PART]);
|
||||
}
|
||||
if (mode == comSimple) {
|
||||
append_menu_item(menu, wxID_ANY, _(L("Add support enforcer")), "",
|
||||
[this](wxCommandEvent&) { load_generic_subobject(_(L("Box")).ToUTF8().data(), ModelVolume::SUPPORT_ENFORCER); },
|
||||
*m_bmp_vector[ModelVolume::SUPPORT_ENFORCER]);
|
||||
@ -735,10 +743,12 @@ void ObjectList::append_menu_items_add_volume(wxMenu* menu)
|
||||
[this](wxCommandEvent&) { load_generic_subobject(_(L("Box")).ToUTF8().data(), ModelVolume::SUPPORT_BLOCKER); },
|
||||
*m_bmp_vector[ModelVolume::SUPPORT_BLOCKER]);
|
||||
|
||||
*item_separator = nullptr;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
for (int type = 0; type < menu_object_types_items.size(); type++)
|
||||
for (int type = mode == comExpert ? 0 : 1 ; type < menu_object_types_items.size(); type++)
|
||||
{
|
||||
auto& item = menu_object_types_items[type];
|
||||
|
||||
@ -748,6 +758,8 @@ void ObjectList::append_menu_items_add_volume(wxMenu* menu)
|
||||
|
||||
menu->Append(menu_item);
|
||||
}
|
||||
|
||||
*item_separator = menu->AppendSeparator();
|
||||
}
|
||||
|
||||
wxMenuItem* ObjectList::append_menu_item_split(wxMenu* menu)
|
||||
@ -793,18 +805,19 @@ wxMenuItem* ObjectList::append_menu_item_instance_to_object(wxMenu* menu)
|
||||
|
||||
void ObjectList::create_object_popupmenu(wxMenu *menu)
|
||||
{
|
||||
append_menu_items_add_volume(menu);
|
||||
|
||||
// Split object to parts
|
||||
menu->AppendSeparator();
|
||||
m_menu_item_split = append_menu_item_split(menu);
|
||||
|
||||
// Settings
|
||||
menu->AppendSeparator();
|
||||
|
||||
// rest of a object_menu will be added later in:
|
||||
// - append_menu_items_add_volume() -> for "Add (volumes)"
|
||||
// - append_menu_item_settings() -> for "Add (settings)"
|
||||
}
|
||||
|
||||
void ObjectList::create_sla_object_popupmenu(wxMenu *menu)
|
||||
{
|
||||
// rest of a object_sla_menu will be added later in:
|
||||
// - append_menu_item_settings() -> for "Add (settings)"
|
||||
}
|
||||
|
||||
void ObjectList::create_part_popupmenu(wxMenu *menu)
|
||||
@ -1809,6 +1822,11 @@ void ObjectList::update_settings_items()
|
||||
UnselectAll();
|
||||
}
|
||||
|
||||
void ObjectList::update_object_menu()
|
||||
{
|
||||
append_menu_items_add_volume(&m_menu_object, &m_mi_volumes_settings_separator);
|
||||
}
|
||||
|
||||
void ObjectList::instances_to_separated_object(const int obj_idx, const std::set<int>& inst_idxs)
|
||||
{
|
||||
// create new object from selected instance
|
||||
|
@ -112,6 +112,7 @@ class ObjectList : public wxDataViewCtrl
|
||||
wxMenuItem* m_menu_item_split_part { nullptr };
|
||||
wxMenuItem* m_menu_item_settings { nullptr };
|
||||
wxMenuItem* m_menu_item_split_instances { nullptr };
|
||||
wxMenuItem* m_mi_volumes_settings_separator { nullptr };
|
||||
|
||||
std::vector<wxBitmap*> m_bmp_vector;
|
||||
|
||||
@ -162,7 +163,7 @@ public:
|
||||
|
||||
void get_settings_choice(const wxString& category_name);
|
||||
void append_menu_item_add_generic(wxMenuItem* menu, const int type);
|
||||
void append_menu_items_add_volume(wxMenu* menu);
|
||||
void append_menu_items_add_volume(wxMenu* menu, wxMenuItem* *item_separator);
|
||||
wxMenuItem* append_menu_item_split(wxMenu* menu);
|
||||
wxMenuItem* append_menu_item_settings(wxMenu* menu);
|
||||
wxMenuItem* append_menu_item_change_type(wxMenu* menu);
|
||||
@ -243,6 +244,7 @@ public:
|
||||
void last_volume_is_deleted(const int obj_idx);
|
||||
bool has_multi_part_objects();
|
||||
void update_settings_items();
|
||||
void update_object_menu();
|
||||
|
||||
void instances_to_separated_object(const int obj_idx, const std::set<int>& inst_idx);
|
||||
void split_instances();
|
||||
|
@ -121,11 +121,6 @@ void MainFrame::init_tabpanel()
|
||||
}
|
||||
});
|
||||
|
||||
if (wxGetApp().plater_) {
|
||||
// before creating a new plater let's delete old one
|
||||
wxGetApp().plater_->Destroy();
|
||||
wxGetApp().plater_ = nullptr;
|
||||
}
|
||||
m_plater = new Slic3r::GUI::Plater(m_tabpanel, this);
|
||||
wxGetApp().plater_ = m_plater;
|
||||
m_tabpanel->AddPage(m_plater, _(L("Plater")));
|
||||
|
@ -940,6 +940,8 @@ struct Plater::priv
|
||||
// SLA-Object popup menu
|
||||
wxMenu sla_object_menu;
|
||||
|
||||
wxMenuItem* separator_volumes_settings{ nullptr };
|
||||
|
||||
// Data
|
||||
Slic3r::DynamicPrintConfig *config; // FIXME: leak?
|
||||
Slic3r::Print fff_print;
|
||||
@ -2331,7 +2333,7 @@ void Plater::priv::on_right_click(Vec2dEvent& evt)
|
||||
return;
|
||||
|
||||
wxMenu* menu = printer_technology == ptSLA ? &sla_object_menu :
|
||||
get_selection().is_single_full_instance/*object*/() ? // show "Object menu" for each FullInstance instead of FullObject
|
||||
get_selection().is_single_full_instance() ? // show "Object menu" for each FullInstance instead of FullObject
|
||||
&object_menu : &part_menu;
|
||||
|
||||
sidebar->obj_list()->append_menu_item_settings(menu);
|
||||
@ -2444,18 +2446,9 @@ bool Plater::priv::complit_init_object_menu()
|
||||
[this](wxCommandEvent&) { split_volume(); }, "shape_ungroup_p.png", &object_menu);
|
||||
|
||||
wxMenuItem* item_split = append_submenu(&object_menu, split_menu, wxID_ANY, _(L("Split")), _(L("Split the selected object")), "shape_ungroup.png");
|
||||
|
||||
// append_menu_item(&object_menu, wxID_ANY, _(L("Reload from Disk")), _(L("Reload the selected file from Disk")),
|
||||
// [this](wxCommandEvent&) { reload_from_disk(); });
|
||||
//
|
||||
// append_menu_item(&object_menu, wxID_ANY, _(L("Export object as STL")) + dots, _(L("Export this single object as STL file")),
|
||||
// [this](wxCommandEvent&) { q->export_stl(true); });
|
||||
|
||||
// Append "Add..." popupmenu
|
||||
object_menu.AppendSeparator();
|
||||
sidebar->obj_list()->append_menu_items_add_volume(&object_menu);
|
||||
|
||||
// object_menu.AppendSeparator();
|
||||
// "Add (volumes)" popupmenu will be added later in append_menu_items_add_volume()
|
||||
|
||||
// ui updates needs to be binded to the parent panel
|
||||
if (q != nullptr)
|
||||
@ -2472,11 +2465,13 @@ bool Plater::priv::complit_init_sla_object_menu()
|
||||
wxMenuItem* item_split = append_menu_item(&sla_object_menu, wxID_ANY, _(L("Split")), _(L("Split the selected object into individual objects")),
|
||||
[this](wxCommandEvent&) { split_object(); }, "shape_ungroup_o.png");
|
||||
|
||||
sla_object_menu.AppendSeparator();
|
||||
|
||||
// Add the automatic rotation sub-menu
|
||||
append_menu_item(&sla_object_menu, wxID_ANY, _(L("Optimize orientation")), _(L("Optimize the rotation of the object for better print results.")),
|
||||
[this](wxCommandEvent&) { sla_optimize_rotation(); });
|
||||
|
||||
// sla_object_menu.AppendSeparator();
|
||||
sla_object_menu.AppendSeparator();
|
||||
|
||||
// ui updates needs to be binded to the parent panel
|
||||
if (q != nullptr)
|
||||
@ -2492,10 +2487,12 @@ bool Plater::priv::complit_init_part_menu()
|
||||
wxMenuItem* item_split = append_menu_item(&part_menu, wxID_ANY, _(L("Split")), _(L("Split the selected object into individual sub-parts")),
|
||||
[this](wxCommandEvent&) { split_volume(); }, "shape_ungroup_p.png");
|
||||
|
||||
part_menu.AppendSeparator();
|
||||
|
||||
auto obj_list = sidebar->obj_list();
|
||||
obj_list->append_menu_item_change_type(&part_menu);
|
||||
|
||||
// part_menu.AppendSeparator();
|
||||
part_menu.AppendSeparator();
|
||||
|
||||
// ui updates needs to be binded to the parent panel
|
||||
if (q != nullptr)
|
||||
@ -2597,8 +2594,6 @@ bool Plater::priv::can_split_to_volumes() const
|
||||
|
||||
bool Plater::priv::can_split() const
|
||||
{
|
||||
if (printer_technology == ptSLA)
|
||||
return false;
|
||||
return sidebar->obj_list()->is_splittable();
|
||||
}
|
||||
|
||||
@ -2625,7 +2620,7 @@ bool Plater::priv::can_mirror() const
|
||||
|
||||
void Plater::priv::update_object_menu()
|
||||
{
|
||||
sidebar->obj_list()->append_menu_items_add_volume(&object_menu);
|
||||
sidebar->obj_list()->append_menu_items_add_volume(&object_menu, &separator_volumes_settings);
|
||||
}
|
||||
|
||||
// Plater / Public
|
||||
|
Loading…
Reference in New Issue
Block a user