Merge branch 'master' into tm_sla_png_minz

This commit is contained in:
tamasmeszaros 2019-03-19 13:19:17 +01:00
commit 630d266c4b
6 changed files with 90 additions and 25 deletions

View File

@ -208,7 +208,7 @@ void PrintConfigDef::init_fff_params()
def->tooltip = L("Horizontal width of the brim that will be printed around each object on the first layer.");
def->sidetext = L("mm");
def->min = 0;
def->mode = comAdvanced;
def->mode = comSimple;
def->default_value = new ConfigOptionFloat(0);
def = this->add("clip_multipart_objects", coBool);

View File

@ -1698,8 +1698,11 @@ void GLCanvas3D::Selection::render_sidebar_hints(const std::string& sidebar_fiel
}
else if (is_single_volume() || is_single_modifier())
{
Transform3d orient_matrix = (*m_volumes)[*m_list.begin()]->get_instance_transformation().get_matrix(true, false, true, true) * (*m_volumes)[*m_list.begin()]->get_volume_transformation().get_matrix(true, false, true, true);
::glTranslated(center(0), center(1), center(2));
Transform3d orient_matrix = (*m_volumes)[*m_list.begin()]->get_instance_transformation().get_matrix(true, false, true, true);
if (!boost::starts_with(sidebar_field, "position"))
orient_matrix = orient_matrix * (*m_volumes)[*m_list.begin()]->get_volume_transformation().get_matrix(true, false, true, true);
::glMultMatrixd(orient_matrix.data());
}
else

View File

@ -871,7 +871,7 @@ void ObjectList::append_menu_items_add_volume(wxMenu* menu)
const ConfigOptionMode mode = wxGetApp().get_mode();
if (mode < comExpert)
if (mode == comAdvanced)
{
append_menu_item(menu, wxID_ANY, _(L("Add part")), "",
[this](wxCommandEvent&) { load_subobject(ModelVolumeType::MODEL_PART); }, *m_bmp_vector[int(ModelVolumeType::MODEL_PART)]);
@ -2022,6 +2022,8 @@ void ObjectList::update_selections_on_canvas()
void ObjectList::select_item(const wxDataViewItem& item)
{
if (! item.IsOk()) { return; }
m_prevent_list_events = true;
UnselectAll();

View File

@ -355,23 +355,18 @@ void Preview::set_drop_target(wxDropTarget* target)
SetDropTarget(target);
}
void Preview::load_print()
void Preview::load_print(bool keep_z_range)
{
PrinterTechnology tech = m_process->current_printer_technology();
if (tech == ptFFF)
load_print_as_fff();
load_print_as_fff(keep_z_range);
else if (tech == ptSLA)
load_print_as_sla();
}
void Preview::reload_print(bool keep_volumes)
{
if (!IsShown())
{
m_volumes_cleanup_required = !keep_volumes;
return;
}
#ifndef __linux__
if (m_volumes_cleanup_required || !keep_volumes)
{
m_canvas->reset_volumes();
@ -379,6 +374,23 @@ void Preview::reload_print(bool keep_volumes)
m_loaded = false;
m_volumes_cleanup_required = false;
}
#endif // __linux__
if (!IsShown())
{
m_volumes_cleanup_required = !keep_volumes;
return;
}
#ifdef __linux__
if (m_volumes_cleanup_required || !keep_volumes)
{
m_canvas->reset_volumes();
m_canvas->reset_legend_texture();
m_loaded = false;
m_volumes_cleanup_required = false;
}
#endif // __linux__
load_print();
}
@ -390,7 +402,7 @@ void Preview::refresh_print()
if (!IsShown())
return;
load_print();
load_print(true);
}
void Preview::bind_event_handlers()
@ -447,10 +459,10 @@ void Preview::reset_sliders()
m_double_slider_sizer->Hide((size_t)0);
}
void Preview::update_sliders(const std::vector<double>& layers_z)
void Preview::update_sliders(const std::vector<double>& layers_z, bool keep_z_range)
{
m_enabled = true;
update_double_slider(layers_z);
update_double_slider(layers_z, keep_z_range);
m_double_slider_sizer->Show((size_t)0);
Layout();
}
@ -559,14 +571,18 @@ static int find_close_layer_idx(const std::vector<double>& zs, double &z, double
return -1;
}
void Preview::update_double_slider(const std::vector<double>& layers_z, bool force_sliders_full_range)
void Preview::update_double_slider(const std::vector<double>& layers_z, bool keep_z_range)
{
// Save the initial slider span.
double z_low = m_slider->GetLowerValueD();
double z_high = m_slider->GetHigherValueD();
bool was_empty = m_slider->GetMaxValue() == 0;
bool force_sliders_full_range = was_empty;
if (!keep_z_range)
{
bool span_changed = layers_z.empty() || std::abs(layers_z.back() - m_slider->GetMaxValueD()) > 1e-6;
force_sliders_full_range |= was_empty | span_changed;
force_sliders_full_range |= span_changed;
}
bool snap_to_min = force_sliders_full_range || m_slider->is_lower_at_min();
bool snap_to_max = force_sliders_full_range || m_slider->is_higher_at_max();
@ -653,7 +669,7 @@ void Preview::update_double_slider_from_canvas(wxKeyEvent& event)
event.Skip();
}
void Preview::load_print_as_fff()
void Preview::load_print_as_fff(bool keep_z_range)
{
if (m_loaded || m_process->current_printer_technology() != ptFFF)
return;
@ -754,7 +770,7 @@ void Preview::load_print_as_fff()
reset_sliders();
m_canvas_widget->Refresh();
} else
update_sliders(zs);
update_sliders(zs, keep_z_range);
}
}

View File

@ -113,7 +113,7 @@ public:
void select_view(const std::string& direction);
void set_drop_target(wxDropTarget* target);
void load_print();
void load_print(bool keep_z_range = false);
void reload_print(bool keep_volumes = false);
void refresh_print();
@ -126,7 +126,7 @@ private:
void show_hide_ui_elements(const std::string& what);
void reset_sliders();
void update_sliders(const std::vector<double>& layers_z);
void update_sliders(const std::vector<double>& layers_z, bool keep_z_range = false);
void on_size(wxSizeEvent& evt);
void on_choice_view_type(wxCommandEvent& evt);
@ -138,14 +138,14 @@ private:
// Create/Update/Reset double slider on 3dPreview
void create_double_slider();
void update_double_slider(const std::vector<double>& layers_z, bool force_sliders_full_range = false);
void update_double_slider(const std::vector<double>& layers_z, bool keep_z_range = false);
void fill_slider_values(std::vector<std::pair<int, double>> &values,
const std::vector<double> &layers_z);
void reset_double_slider();
// update DoubleSlider after keyDown in canvas
void update_double_slider_from_canvas(wxKeyEvent& event);
void load_print_as_fff();
void load_print_as_fff(bool keep_z_range = false);
void load_print_as_sla();
void on_sliders_scroll_changed(wxEvent& event);

View File

@ -1089,6 +1089,15 @@ struct Plater::priv
// SLA-Object popup menu
PrusaMenu sla_object_menu;
// Removed/Prepended Items according to the view mode
std::vector<wxMenuItem*> items_increase;
std::vector<wxMenuItem*> items_decrease;
std::vector<wxMenuItem*> items_set_number_of_copies;
enum MenuIdentifier {
miObjectFFF=0,
miObjectSLA
};
// Data
Slic3r::DynamicPrintConfig *config; // FIXME: leak?
Slic3r::Print fff_print;
@ -2582,6 +2591,32 @@ void Plater::priv::on_right_click(Vec2dEvent& evt)
sidebar->obj_list()->append_menu_item_settings(menu);
/* Remove/Prepend "increase/decrease instances" menu items according to the view mode.
* Suppress to show those items for a Simple mode
*/
const MenuIdentifier id = printer_technology == ptSLA ? miObjectSLA : miObjectFFF;
if (wxGetApp().get_mode() == comSimple) {
if (menu->FindItem(_(L("Increase copies"))) != wxNOT_FOUND)
{
/* Detach an items from the menu, but don't delete them
* so that they can be added back later
* (after switching to the Advanced/Expert mode)
*/
menu->Remove(items_increase[id]);
menu->Remove(items_decrease[id]);
menu->Remove(items_set_number_of_copies[id]);
}
}
else {
if (menu->FindItem(_(L("Increase copies"))) == wxNOT_FOUND)
{
// Prepend items to the menu, if those aren't not there
menu->Prepend(items_set_number_of_copies[id]);
menu->Prepend(items_decrease[id]);
menu->Prepend(items_increase[id]);
}
}
if (q != nullptr) {
#ifdef __linux__
// For some reason on Linux the menu isn't displayed if position is specified
@ -2618,6 +2653,10 @@ void Plater::priv::on_3dcanvas_mouse_dragging_finished(SimpleEvent&)
bool Plater::priv::init_object_menu()
{
items_increase.reserve(2);
items_decrease.reserve(2);
items_set_number_of_copies.reserve(2);
init_common_menu(&object_menu);
complit_init_object_menu();
@ -2643,6 +2682,11 @@ bool Plater::priv::init_common_menu(wxMenu* menu, const bool is_part/* = false*/
[this](wxCommandEvent&) { q->decrease_instances(); }, "delete.png");
wxMenuItem* item_set_number_of_copies = append_menu_item(menu, wxID_ANY, _(L("Set number of copies")) + dots, _(L("Change the number of copies of the selected object")),
[this](wxCommandEvent&) { q->set_number_of_copies(); }, "textfield.png");
items_increase.push_back(item_increase);
items_decrease.push_back(item_decrease);
items_set_number_of_copies.push_back(item_set_number_of_copies);
// Delete menu was moved to be after +/- instace to make it more difficult to be selected by mistake.
item_delete = append_menu_item(menu, wxID_ANY, _(L("Delete")) + "\tDel", _(L("Remove the selected object")),
[this](wxCommandEvent&) { q->remove_selected(); }, "brick_delete.png");
@ -2713,7 +2757,7 @@ bool Plater::priv::complit_init_object_menu()
{
q->Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable(can_split()); }, item_split->GetId());
q->Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable(can_split()); }, item_split_objects->GetId());
q->Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable(can_split()); }, item_split_volumes->GetId());
q->Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable(can_split() && wxGetApp().get_mode() > comSimple); }, item_split_volumes->GetId());
}
return true;
}