Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
supermerill committed Jun 5, 2024
2 parents 5c8cc63 + b9697d4 commit 5ae5a01
Show file tree
Hide file tree
Showing 10 changed files with 115 additions and 84 deletions.
2 changes: 1 addition & 1 deletion resources/ui_layout/default/freq_fff.ui
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#logs
page:print:
page:Frequent settings:
group:freq_settings_event:no_title:no_search:
line:
setting:simple:script:enum$none$None$bp$Support on build plate only$se$For support enforcers only$ev$Everywhere:depends$support_material$support_material_auto$support_material_buildplate_only:label$Supports:tooltip$Select what kind of support do you need:full_width:s_support_fff
Expand Down
18 changes: 12 additions & 6 deletions src/libslic3r/GCode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3441,7 +3441,7 @@ LayerResult GCode::process_layer(
//extrude object-only skirt (for sequential)
//TODO: use it also for wiping like the other one (as they are exlusiev)
if (single_object_instance_idx != size_t(-1) && !layers.front().object()->skirt().empty()
&& extruder_id == layer_tools.extruders.front()) {
&& extruder_id == layer_tools.extruders.front() && object_layer) {

const PrintObject *print_object = layers.front().object();
//object skirt & brim use the object settings.
Expand All @@ -3459,7 +3459,7 @@ LayerResult GCode::process_layer(
}
//extrude object-only brim (for sequential)
if (single_object_instance_idx != size_t(-1) && !layers.front().object()->brim().empty()
&& extruder_id == layer_tools.extruders.front()) {
&& extruder_id == layer_tools.extruders.front() && object_layer) {

const PrintObject* print_object = layers.front().object();
//object skirt & brim use the object settings.
Expand Down Expand Up @@ -5114,9 +5114,15 @@ std::string GCode::extrude_multi_path(const ExtrusionMultiPath &multipath, const
//reverse to get a shorter point (hopefully there is still no feature that choose a point that need no perimeter crossing before).
// extrude along the reversedpath
for (size_t idx_path = multipath.paths.size() - 1; idx_path < multipath.paths.size(); --idx_path) {
assert(multipath.paths[idx_path].can_reverse());
//extrude_path will reverse the path by itself, no need to copy it do to it here.
gcode += extrude_path(multipath.paths[idx_path], description, speed);
//it's possible to have un-reverseable paths into a reversable multipath: this means that only the whole thing can be reversed, and not individual apths.
if (multipath.paths[idx_path].can_reverse()) {
// extrude_path will reverse the path by itself, no need to copy it do to it here.
gcode += extrude_path(multipath.paths[idx_path], description, speed);
} else {
ExtrusionPath path = multipath.paths[idx_path];
path.reverse();
gcode += extrude_path(path, description, speed);
}
}
} else {
// extrude along the path
Expand Down Expand Up @@ -6373,7 +6379,7 @@ Polyline GCode::travel_to(std::string &gcode, const Point &point, ExtrusionRole
bool needs_retraction = this->needs_retraction(travel, role);
if (m_config.only_retract_when_crossing_perimeters &&
!(m_config.enforce_retract_first_layer && m_layer_index == 0))
needs_retraction = needs_retraction && this->can_cross_perimeter(travel, false);
needs_retraction = needs_retraction && this->can_cross_perimeter(travel, true);

// Re-allow avoid_crossing_perimeters for the next travel moves
m_avoid_crossing_perimeters.reset_once_modifiers();
Expand Down
4 changes: 2 additions & 2 deletions src/slic3r/GUI/GUI_App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,7 @@ bool GUI_App::init_opengl()
if (boost::contains(gpu_vendor, "Apple") || boost::contains(gpu_vendor, "APPLE")) {
assert(false); // apple gpu are only in _M_ARM64
}
} catch (std::exception &ex) {}
} catch (std::exception &) {}
#endif
app_config->set_hardware_type(AppConfig::HardwareType(hard_cpu + hard_gpu));
}
Expand Down Expand Up @@ -2652,7 +2652,7 @@ void GUI_App::add_config_menu(wxMenuBar *menu)
associate_gcode_files();
}
#endif // _WIN32
} catch (std::exception &e) {}
} catch (std::exception &) {}
}
if (app_layout_changed) {
// hide full main_sizer for mainFrame
Expand Down
71 changes: 32 additions & 39 deletions src/slic3r/GUI/GUI_Preview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ void Preview::check_layers_slider_values(std::vector<CustomGCode::Item>& ticks_f
m_schedule_background_process();
}

void Preview::update_layers_slider(const std::vector<double>& layers_z, bool keep_z_range)
void Preview::update_layers_slider(const std::vector<double>& layers_z, bool show_gcode_data, bool keep_z_range)
{
//lock rendering while updating
{
Expand All @@ -708,7 +708,7 @@ void Preview::update_layers_slider(const std::vector<double>& layers_z, bool kee

// Detect and set manipulation mode for double slider
update_layers_slider_mode();

Plater* plater = wxGetApp().plater();
CustomGCode::Info ticks_info_from_model = plater->model().custom_gcode_per_print_z;
if (wxGetApp().is_editor())
Expand Down Expand Up @@ -742,46 +742,36 @@ void Preview::update_layers_slider(const std::vector<double>& layers_z, bool kee
}
m_layers_slider->SetSelectionSpan(idx_low, idx_high);
m_layers_slider->SetTicksValues(ticks_info_from_model);

bool sla_print_technology = plater->printer_technology() == ptSLA;

bool sequential_print = wxGetApp().preset_bundle->fff_prints.get_edited_preset().config.opt_bool("complete_objects");
bool sla_print_technology = plater->printer_technology() == ptSLA;
m_layers_slider->SetDrawMode(sla_print_technology, sequential_print);
if (sla_print_technology)
m_layers_slider->SetLayersTimes(plater->sla_print().print_statistics().layers_times);
else {
if (plater->fff_print().print_statistics().is_computing_gcode || !plater->fff_print().finished()) {
//do not fetch uncomplete data
m_layers_slider->SetLayersTimes({}, 0);
if (show_gcode_data) {
if (sla_print_technology) {
m_layers_slider->SetLayersTimes(plater->sla_print().print_statistics().layers_times);
} else {
auto print_mode_stat = m_gcode_result->print_statistics.modes.front();
m_layers_slider->SetLayersTimes(print_mode_stat.layers_times, print_mode_stat.time);
if (plater->fff_print().print_statistics().is_computing_gcode || !plater->fff_print().finished()) {
// do not fetch uncomplete data
m_layers_slider->SetLayersTimes({}, 0);
} else {
auto print_mode_stat = m_gcode_result->print_statistics.modes.front();
m_layers_slider->SetLayersTimes(print_mode_stat.layers_times, print_mode_stat.time);
}
}
}
// create area array
//area not computed for sla_print_technology //TODO
if (!sla_print_technology){
if (plater->fff_print().print_statistics().is_computing_gcode || !plater->fff_print().finished()) {
//do not fetch uncomplete data
m_layers_slider->SetLayersAreas({});
} else {
const std::vector<std::pair<coordf_t, float>> &layerz_to_area = plater->fff_print().print_statistics().layer_area_stats;
std::vector<float> areas;
for(auto [z, area] : layerz_to_area)
areas.push_back(area);
m_layers_slider->SetLayersAreas(areas);
assert(areas.size() == m_gcode_result->print_statistics.modes.front().layers_times.size());
//auto objects = plater->fff_print().objects();
//for (auto object : objects) {
// for (auto layer : object->layers()) {
// assert(layer->print_z > 100);
// coord_t layer_z = 100*(coord_t(layer->print_z + 50)/100);
// int32_t area = layerz_to_area[layer_z];
// for (auto poly : layer->lslices) {
// area += poly.area();
// }
// layerz_to_area[layer_z] = area;
// }
//}
// area not computed for sla_print_technology //TODO
if (!sla_print_technology) {
if (plater->fff_print().print_statistics().is_computing_gcode || !plater->fff_print().finished()) {
// do not fetch uncomplete data
m_layers_slider->SetLayersAreas({});
} else {
const std::vector<std::pair<coordf_t, float>> &layerz_to_area =
plater->fff_print().print_statistics().layer_area_stats;
std::vector<float> areas;
for (auto [z, area] : layerz_to_area) areas.push_back(area);
m_layers_slider->SetLayersAreas(areas);
assert(areas.size() == m_gcode_result->print_statistics.modes.front().layers_times.size());
}
}
}

Expand Down Expand Up @@ -1066,6 +1056,7 @@ void Preview::load_print_as_fff(bool keep_z_range)
m_canvas->set_items_show(true, true);

m_canvas->set_selected_extruder(0);
bool gcode_not_extrusions = false;
if (current_force_state == ForceState::ForceGcode || (gcode_preview_data_valid && current_force_state != ForceState::ForceExtrusions)) {
// Load the real G-code preview.
if (current_force_state == ForceState::NoForce)
Expand All @@ -1077,6 +1068,7 @@ void Preview::load_print_as_fff(bool keep_z_range)
Refresh();
zs = m_canvas->get_gcode_layers_zs();
m_loaded = true;
gcode_not_extrusions = true;
}
else if (wxGetApp().is_editor()) {
// Load the initial preview based on slices, not the final G-code.
Expand All @@ -1087,6 +1079,7 @@ void Preview::load_print_as_fff(bool keep_z_range)
m_left_sizer->Layout();
Refresh();
zs = m_canvas->get_volumes_print_zs(true);
gcode_not_extrusions = false;
}

if (!zs.empty() && !m_keep_current_preview_type) {
Expand Down Expand Up @@ -1116,7 +1109,7 @@ void Preview::load_print_as_fff(bool keep_z_range)
hide_layers_slider();
m_canvas_widget->Refresh();
} else {
update_layers_slider(zs, keep_z_range);
update_layers_slider(zs, gcode_not_extrusions, keep_z_range);
}
}
}
Expand Down Expand Up @@ -1163,7 +1156,7 @@ void Preview::load_print_as_sla()
Refresh();

if (n_layers > 0)
update_layers_slider(zs);
update_layers_slider(zs, true);

m_loaded = true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/slic3r/GUI/GUI_Preview.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ Preview(wxWindow* parent, Bed3D& bed, Model* model, DynamicPrintConfig* config,
void check_layers_slider_values(std::vector<CustomGCode::Item>& ticks_from_model,
const std::vector<double>& layers_z);
void reset_layers_slider();
void update_layers_slider(const std::vector<double>& layers_z, bool keep_z_range = false);
void update_layers_slider(const std::vector<double>& layers_z, bool show_gcode_data = false, bool keep_z_range = false);
void update_layers_slider_mode();
// update vertical DoubleSlider after keyDown in canvas
void update_layers_slider_from_canvas(wxKeyEvent& event);
Expand Down
7 changes: 5 additions & 2 deletions src/slic3r/GUI/OptionsGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,14 @@ OptionsGroup::OptionsGroup( wxWindow* _parent, const wxString& title,
m_use_custom_ctrl(is_tab_opt),
staticbox(title!=""), extra_column(extra_clmn)
{
assert(Tab::fake_build || m_parent);
}

wxWindow* OptionsGroup::ctrl_parent() const
{
return this->custom_ctrl && m_use_custom_ctrl_as_parent ? static_cast<wxWindow*>(this->custom_ctrl) : (this->stb ? static_cast<wxWindow*>(this->stb) : this->parent());
wxWindow* ret_val = this->custom_ctrl && m_use_custom_ctrl_as_parent ? static_cast<wxWindow*>(this->custom_ctrl) : (this->stb ? static_cast<wxWindow*>(this->stb) : this->parent());
assert(ret_val);
return ret_val;
}

bool OptionsGroup::is_legend_line()
Expand Down Expand Up @@ -190,7 +193,7 @@ void OptionsGroup::show_field(const t_config_option_key& opt_key, bool show/* =

void OptionsGroup::append_line(const Line& line)
{
m_lines.emplace_back(line);
m_lines.push_back(line);

if (line.full_width && (
line.widget != nullptr ||
Expand Down
2 changes: 1 addition & 1 deletion src/slic3r/GUI/OptionsGroup.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class OptionsGroup {
/// Returns a copy of the pointer of the parent wxWindow.
/// Accessor function is because users are not allowed to change the parent
/// but defining it as const means a lot of const_casts to deal with wx functions.
inline wxWindow* parent() const { return m_parent; }
inline wxWindow* parent() const { assert(m_parent); return m_parent; }

wxWindow* ctrl_parent() const;

Expand Down
30 changes: 16 additions & 14 deletions src/slic3r/GUI/Plater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ class FreqChangedParams : public OG_Settings

void FreqChangedParams::msw_rescale()
{
m_og->msw_rescale();
if(m_og) m_og->msw_rescale();
for(auto& entry : m_og_other)
entry.second->msw_rescale();

Expand All @@ -353,7 +353,7 @@ void FreqChangedParams::msw_rescale()

void FreqChangedParams::sys_color_changed()
{
m_og->sys_color_changed();
if(m_og) m_og->sys_color_changed();
for (auto& entry : m_og_other)
entry.second->sys_color_changed();

Expand Down Expand Up @@ -389,16 +389,17 @@ void FreqChangedParams::init()

assert(tab_freq_fff == nullptr || dynamic_cast<TabFrequent *>(tab_freq_fff));
if (tab_freq_fff && dynamic_cast<TabFrequent *>(tab_freq_fff)) {
// std::vector<PageShp> pages;
static_cast<TabFrequent *>(tab_freq_fff)->set_freq_parent(m_og->parent());
tab_freq_fff->build();
// if(tab_freq_fff != nullptr) pages =
// tab_freq_fff->create_pages(Preset::type_name(tab_freq_fff->type())+".ui", -1, tab_freq_fff->type());
if (tab_freq_fff->get_page_count() > 0) {
assert(tab_freq_fff->get_page_count() == 1);
assert(tab_freq_fff->get_page(0));
assert(tab_freq_fff->get_page(0)->m_optgroups.size() == 1);
m_og = (tab_freq_fff->get_page(0)->m_optgroups[0]);
m_og->set_config(config);
m_og->hide_labels();
m_og->m_on_change =
Tab::set_or_add(m_og->m_on_change, [tab_freq_fff, this](t_config_option_key opt_key, boost::any value)
// m_og->m_on_change = [tab_print, this](t_config_option_key opt_key, boost::any value)
{
const Option *opt_def = this->m_og->get_option_def(opt_key);
if (opt_def && !opt_def->opt.is_script) {
Expand Down Expand Up @@ -470,10 +471,9 @@ void FreqChangedParams::init()
line_for_purge->append_widget(wiping_dialog_btn);
}

for (const Line &l : page->m_optgroups[0]->get_lines()) { m_og->append_line(l); }

// current_group->m_on_change = on_change;
m_og->activate();
assert(m_og->sizer);
m_sizer->Add(m_og->sizer, 0, wxEXPAND);
}
}
Expand All @@ -483,12 +483,14 @@ void FreqChangedParams::init()
Tab* tab_freq_sla = wxGetApp().get_tab(Preset::TYPE_FREQUENT_SLA, false);
assert(tab_freq_sla == nullptr || dynamic_cast<TabFrequent *>(tab_freq_sla));
if (tab_freq_sla && dynamic_cast<TabFrequent *>(tab_freq_sla)) {
static_cast<TabFrequent *>(tab_freq_sla)->set_freq_parent(m_parent);
tab_freq_sla->build();
// if (tab_freq_sla != nullptr) pages =
// tab_freq_sla->create_pages(Preset::type_name(tab_freq_sla->type())+".ui", -1, tab_freq_sla->type());
if (tab_freq_sla->get_page_count() > 0) {
assert(tab_freq_fff->get_page_count() == 1);
assert(tab_freq_fff->get_page(0));
assert(tab_freq_fff->get_page(0)->m_optgroups.size() == 1);
std::shared_ptr<ConfigOptionsGroup> m_og_sla = m_og_other[ptSLA] =
std::make_shared<ConfigOptionsGroup>(m_parent, "");
(tab_freq_sla->get_page(0)->m_optgroups[0]);
m_og_sla->set_config(config);
m_og_sla->hide_labels();
m_og_sla->m_on_change = Tab::set_or_add(m_og_sla->m_on_change, [tab_freq_sla,
Expand All @@ -512,8 +514,8 @@ void FreqChangedParams::init()
l.append_widget(empty_widget);
}
}
for (const Line &l : page->m_optgroups[0]->get_lines()) { m_og_sla->append_line(l); }
m_og_sla->activate();
assert(m_og_sla->sizer);
m_sizer->Add(m_og_sla->sizer, 0, wxEXPAND);
}
}
Expand All @@ -533,7 +535,7 @@ void FreqChangedParams::Show(bool visible) {

void FreqChangedParams::Show(PrinterTechnology tech)
{
m_og->Show( (tech & PrinterTechnology::ptFFF) != 0);
if(m_og) m_og->Show( (tech & PrinterTechnology::ptFFF) != 0);
for (auto& entry : m_og_other)
entry.second->Show( (entry.first & tech) != 0);

Expand Down Expand Up @@ -1155,7 +1157,7 @@ void Sidebar::jump_to_option(size_t selected)
}
}

wxGetApp().get_tab(opt.type)->activate_option(opt.opt_key_with_idx(), boost::nowide::narrow(opt.category));
wxGetApp().get_tab(opt.type, false)->activate_option(opt.opt_key_with_idx(), boost::nowide::narrow(opt.category));

// Switch to the Settings NotePad
// wxGetApp().mainframe->select_tab(MainFrame::ETabType::LastSettings);
Expand Down
Loading

0 comments on commit 5ae5a01

Please sign in to comment.