OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GUI::anonymous_namespace{PublishSettingsDialog.cpp} Namespace Reference

Enumerations

enum  {
  kPublishSelectAll = wxID_HIGHEST + 1 , kPublishDeselectAll , kPublishSelectVisible , kPublishDeselectVisible ,
  kPublishFilterSelected , kPublishFilterNonSelected
}

Functions

wxStaticText * add_checkbox_label (wxWindow *parent, wxBoxSizer *sizer, ::CheckBox *check, const wxString &label, const wxString &tooltip, int label_width=0)
std::string filament_color_hex (const DynamicPrintConfig &full, size_t slot)
PublishMaterialIdentity material_identity (size_t slot, const DynamicPrintConfig &full)
std::string material_display_name (const std::string &preset_name)
wxString material_title (size_t slot, const PresetBundle *bundle, const DynamicPrintConfig &full)
std::vector< unsigned int > mixed_slot_components (const DynamicPrintConfig &full, size_t slot)
wxString mixed_filament_label (const DynamicPrintConfig &full, size_t slot)
wxColour mixed_filament_blend_color (const DynamicPrintConfig &full, size_t slot)
wxBitmap mixed_filament_chip_bitmap (const DynamicPrintConfig &full, size_t slot, int swatch_sz)
wxBitmap mixed_filament_tab_bitmap (const DynamicPrintConfig &full, size_t slot, int swatch_sz, const wxColour &tab_bg)
std::set< size_t > project_used_filament_slots (const PresetBundle &bundle, const DynamicPrintConfig &full, const Model &model)
void add_sentence_with_chips (wxWindow *parent, wxSizer *row, const wxString &sentence, const std::vector< wxWindow * > &chips)

Variables

constexpr long s_tab_style

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
kPublishSelectAll 
kPublishDeselectAll 
kPublishSelectVisible 
kPublishDeselectVisible 
kPublishFilterSelected 
kPublishFilterNonSelected 
109 {
110 kPublishSelectAll = wxID_HIGHEST + 1,
116};
@ kPublishSelectAll
Definition PublishSettingsDialog.cpp:110
@ kPublishDeselectAll
Definition PublishSettingsDialog.cpp:111
@ kPublishFilterNonSelected
Definition PublishSettingsDialog.cpp:115
@ kPublishFilterSelected
Definition PublishSettingsDialog.cpp:114
@ kPublishDeselectVisible
Definition PublishSettingsDialog.cpp:113
@ kPublishSelectVisible
Definition PublishSettingsDialog.cpp:112

Function Documentation

◆ add_checkbox_label()

wxStaticText * Slic3r::GUI::anonymous_namespace{PublishSettingsDialog.cpp}::add_checkbox_label ( wxWindow * parent,
wxBoxSizer * sizer,
::CheckBox * check,
const wxString & label,
const wxString & tooltip,
int label_width = 0 )
74{
75 check->SetToolTip(tooltip);
76 sizer->Add(check, 0, wxALIGN_CENTER_VERTICAL | wxTOP | wxBOTTOM, parent->FromDIP(2));
77
78 auto* text = new wxStaticText(parent, wxID_ANY, label);
79 text->SetFont(Label::Body_14);
80 text->SetForegroundColour(StateColor::darkModeColorFor(wxColour("#363636")));
81 if (label_width > 0) {
82 text->SetMinSize(wxSize(label_width, -1));
83 text->SetMaxSize(wxSize(label_width, -1));
84 text->Wrap(label_width);
85 }
86 text->SetToolTip(tooltip);
87 text->SetCursor(wxCURSOR_HAND);
88 const auto toggle = [check]() {
89 if (!check->IsEnabled())
90 return;
91 check->SetValue(!check->GetValue());
92 wxCommandEvent event(wxEVT_TOGGLEBUTTON, check->GetId());
93 event.SetEventObject(check);
94 check->GetEventHandler()->ProcessEvent(event);
95 };
96 text->Bind(wxEVT_LEFT_DOWN, [toggle](wxMouseEvent& event) {
97 if (!event.LeftDClick())
98 toggle();
99 });
100 text->Bind(wxEVT_LEFT_DCLICK, [toggle](wxMouseEvent&) {
101 toggle();
102 });
103 sizer->Add(text, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, parent->FromDIP(5));
104 return text;
105}
class WXDLLIMPEXP_FWD_CORE wxStaticText
Definition ProgressDialog.hpp:30
static wxFont Body_14
Definition Label.hpp:53
static wxColour darkModeColorFor(wxColour const &color)
Definition StateColor.cpp:219
wxMouseEvent
Definition CameraPopup.cpp:47

References add_checkbox_label(), Label::Body_14, StateColor::darkModeColorFor(), Slic3r::GUI::wxMouseEvent, and wxStaticText.

Referenced by add_checkbox_label().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_sentence_with_chips()

void Slic3r::GUI::anonymous_namespace{PublishSettingsDialog.cpp}::add_sentence_with_chips ( wxWindow * parent,
wxSizer * row,
const wxString & sentence,
const std::vector< wxWindow * > & chips )
489{
490 std::vector<bool> placed(chips.size(), false);
491 auto add_text = [&](wxString text) {
492 text.Replace("%%", "%"); // the sentence is a format string
493 if (text.IsEmpty())
494 return;
495 auto* label = new wxStaticText(parent, wxID_ANY, text);
496 label->SetFont(Label::Body_12);
497 label->SetForegroundColour(StateColor::darkModeColorFor(wxColour("#6B6B6B")));
498 row->Add(label, 0, wxALIGN_CENTER_VERTICAL);
499 };
500 auto add_chip = [&](size_t i) {
501 if (i < chips.size() && chips[i] != nullptr && !placed[i]) {
502 placed[i] = true;
503 row->Add(chips[i], 0, wxALIGN_CENTER_VERTICAL);
504 }
505 };
506
507 size_t literal = 0, pos = 0;
508 while ((pos = sentence.find('%', pos)) != wxString::npos) {
509 size_t end = pos + 1;
510 while (end < sentence.length() && sentence[end] >= '0' && sentence[end] <= '9')
511 ++end;
512 if (end == pos + 1 || end >= sentence.length() || sentence[end] != '%') {
513 ++pos; // a bare '%'
514 continue;
515 }
516 long index = 0;
517 sentence.Mid(pos + 1, end - pos - 1).ToLong(&index);
518 add_text(sentence.Mid(literal, pos - literal));
519 add_chip(size_t(index - 1));
520 literal = pos = end + 1;
521 }
522 add_text(sentence.Mid(literal));
523 for (size_t i = 0; i < chips.size(); ++i) // whatever the translation left out
524 add_chip(i);
525}
static wxFont Body_12
Definition Label.hpp:55
T * end(Slic3r::Mat< N, M, T > &mat)
Definition Point.hpp:841
Vec3d pos(const Pt &p)
Definition ReprojectPointsOnMesh.hpp:16

References add_sentence_with_chips(), Label::Body_12, StateColor::darkModeColorFor(), and wxStaticText.

Referenced by add_sentence_with_chips().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ filament_color_hex()

std::string Slic3r::GUI::anonymous_namespace{PublishSettingsDialog.cpp}::filament_color_hex ( const DynamicPrintConfig & full,
size_t slot )
125{
126 if (const auto* colours = full.opt<ConfigOptionStrings>("filament_colour"))
127 if (slot < colours->size())
128 return colours->get_at(slot);
129 return std::string();
130}
Definition Config.hpp:1190
T * opt(const t_config_option_key &opt_key, bool create=false)
Definition Config.hpp:3007

References filament_color_hex(), and Slic3r::DynamicConfig::opt().

Referenced by filament_color_hex(), and mixed_filament_chip_bitmap().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ material_display_name()

std::string Slic3r::GUI::anonymous_namespace{PublishSettingsDialog.cpp}::material_display_name ( const std::string & preset_name)
149{
150 const size_t at = preset_name.find_first_of('@');
151 if (at == std::string::npos)
152 return preset_name;
153 std::string bare = preset_name.substr(0, at);
154 boost::trim_right(bare);
155 return bare.empty() ? preset_name : bare;
156}

References material_display_name().

Referenced by material_display_name(), and material_title().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ material_identity()

PublishMaterialIdentity Slic3r::GUI::anonymous_namespace{PublishSettingsDialog.cpp}::material_identity ( size_t slot,
const DynamicPrintConfig & full )
133{
135 if (const auto* types = full.opt<ConfigOptionStrings>("filament_type"))
136 if (slot < types->size())
137 identity.type = types->get_at(slot);
138 if (const auto* vendors = full.opt<ConfigOptionStrings>("filament_vendor"))
139 if (slot < vendors->size())
140 identity.vendor = vendors->get_at(slot);
141 if (const auto* ids = full.opt<ConfigOptionStrings>("filament_ids"))
142 if (slot < ids->size())
143 identity.id = ids->get_at(slot);
144 return identity;
145}
Definition PublishSettingsDialog.hpp:45
Transform< N, T > identity()
Definition Point.hpp:106

References Slic3r::identity(), material_identity(), and Slic3r::DynamicConfig::opt().

Referenced by material_identity(), and material_title().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ material_title()

wxString Slic3r::GUI::anonymous_namespace{PublishSettingsDialog.cpp}::material_title ( size_t slot,
const PresetBundle * bundle,
const DynamicPrintConfig & full )
161{
162 if (slot < bundle->filament_presets.size()) {
163 const Preset* preset = bundle->filaments.find_preset(bundle->filament_presets[slot]);
164 if (preset != nullptr && !preset->name.empty()) {
165 // Display the name the sidebar does: the alias (already bare-name + variant-tail
166 // stripped for root filament presets).
167 const std::string& display = preset->alias.empty() ? get_preset_bare_name(preset->name) : preset->alias;
168 return from_u8(material_display_name(display));
169 }
170 }
171 const PublishMaterialIdentity identity = material_identity(slot, full);
172 if (!identity.type.empty())
173 return from_u8(identity.type);
174 return _L("Material");
175}
#define _L(s)
Definition OBJ.cpp:34
PresetCollection filaments
Definition PresetBundle.hpp:499
std::vector< std::string > filament_presets
Definition PresetBundle.hpp:507
Preset * find_preset(const std::string &name, bool first_visible_if_not_found=false, bool real=false, bool only_from_library=false)
Definition Preset.cpp:3772
Definition Preset.hpp:241
std::string name
Definition Preset.hpp:288
std::string alias
Definition Preset.hpp:303
PublishMaterialIdentity material_identity(size_t slot, const DynamicPrintConfig &full)
Definition PublishSettingsDialog.cpp:132
std::string material_display_name(const std::string &preset_name)
Definition PublishSettingsDialog.cpp:148
wxString from_u8(const std::string &str)
Definition GUI.cpp:544
std::string get_preset_bare_name(const std::string &canonical_name)
Definition Preset.cpp:172

References _L, Slic3r::Preset::alias, Slic3r::PresetBundle::filament_presets, Slic3r::PresetBundle::filaments, Slic3r::PresetCollection::find_preset(), Slic3r::GUI::from_u8(), Slic3r::get_preset_bare_name(), Slic3r::identity(), material_display_name(), material_identity(), material_title(), and Slic3r::Preset::name.

Referenced by material_title().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mixed_filament_blend_color()

wxColour Slic3r::GUI::anonymous_namespace{PublishSettingsDialog.cpp}::mixed_filament_blend_color ( const DynamicPrintConfig & full,
size_t slot )
219{
220 std::vector<wxColour> colors;
221 if (const auto* colours = full.opt<ConfigOptionStrings>("filament_colour")) {
222 colors.reserve(colours->values.size());
223 for (const std::string& hex : colours->values) {
224 const wxColour c(hex);
225 colors.push_back(c.IsOk() ? c : wxColour(0, 0, 0));
226 }
227 }
228 while (colors.size() <= slot)
229 colors.push_back(wxColour("#D9D9D9"));
230 recompute_mixed_slot_colors(colors, full);
231 return slot < colors.size() ? colors[slot] : wxColour("#D9D9D9");
232}
void recompute_mixed_slot_colors(std::vector< wxColour > &colors, const Slic3r::DynamicPrintConfig &cfg)
Definition FilamentBitmapUtils.cpp:432

References mixed_filament_blend_color(), Slic3r::DynamicConfig::opt(), and Slic3r::GUI::recompute_mixed_slot_colors().

Referenced by mixed_filament_blend_color(), and mixed_filament_chip_bitmap().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mixed_filament_chip_bitmap()

wxBitmap Slic3r::GUI::anonymous_namespace{PublishSettingsDialog.cpp}::mixed_filament_chip_bitmap ( const DynamicPrintConfig & full,
size_t slot,
int swatch_sz )
238{
239 const std::string label = std::to_string(slot + 1);
240 const auto* grad_opt = full.opt<ConfigOptionBools>("filament_mixed_gradient");
241 const bool is_gradient = grad_opt != nullptr && slot < grad_opt->size() && grad_opt->values[slot];
242 wxBitmap* icon = nullptr;
243 if (is_gradient) {
244 // The same curve-sampled ramp the sidebar chips use; an empty ramp (broken definition)
245 // degrades to a plain fade between the slot's two component colours.
246 const std::vector<wxColour> ramp = mixed_gradient_ramp(full, slot, swatch_sz);
247 if (!ramp.empty()) {
248 icon = get_extruder_color_icon(std::vector<std::string>(), true, label, swatch_sz, swatch_sz, &ramp);
249 } else {
250 std::vector<std::string> hexes;
251 for (const unsigned int comp : mixed_slot_components(full, slot)) {
252 std::string hex = filament_color_hex(full, size_t(comp) - 1);
253 if (hex.empty())
254 hex = "#D9D9D9";
255 hexes.push_back(std::move(hex));
256 }
257 if (hexes.size() >= 2)
258 icon = get_extruder_color_icon(std::move(hexes), true, label, swatch_sz, swatch_sz);
259 }
260 }
261 if (icon == nullptr) {
262 const wxColour blend = mixed_filament_blend_color(full, slot);
263 const std::string blend_hex = blend.IsOk() ?
264 std::string(wxString::Format("#%02X%02X%02X", blend.Red(), blend.Green(), blend.Blue()).ToUTF8()) :
265 std::string("#808080");
266 icon = get_extruder_color_icon(blend_hex, label, swatch_sz, swatch_sz);
267 }
268 return icon != nullptr ? *icon : wxNullBitmap;
269}
std::vector< unsigned int > mixed_slot_components(const DynamicPrintConfig &full, size_t slot)
Definition PublishSettingsDialog.cpp:178
wxColour mixed_filament_blend_color(const DynamicPrintConfig &full, size_t slot)
Definition PublishSettingsDialog.cpp:218
std::string filament_color_hex(const DynamicPrintConfig &full, size_t slot)
Definition PublishSettingsDialog.cpp:124
std::vector< wxColour > mixed_gradient_ramp(const Slic3r::DynamicPrintConfig &cfg, size_t slot, int steps)
Definition FilamentBitmapUtils.cpp:163
ConfigOptionBoolsTempl< false > ConfigOptionBools
Definition Config.hpp:2066
wxBitmap * get_extruder_color_icon(std::vector< std::string > colors, bool is_gradient, std::string label, int icon_width, int icon_height, const std::vector< wxColour > *ramp)
Definition wxExtensions.cpp:633

References filament_color_hex(), get_extruder_color_icon(), mixed_filament_blend_color(), mixed_filament_chip_bitmap(), Slic3r::GUI::mixed_gradient_ramp(), mixed_slot_components(), and Slic3r::DynamicConfig::opt().

Referenced by mixed_filament_chip_bitmap(), and mixed_filament_tab_bitmap().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mixed_filament_label()

wxString Slic3r::GUI::anonymous_namespace{PublishSettingsDialog.cpp}::mixed_filament_label ( const DynamicPrintConfig & full,
size_t slot )
190{
191 const std::vector<unsigned int> comps = mixed_slot_components(full, slot);
192 if (comps.empty())
193 return _L("Mixed filament");
194 const auto* grad_opt = full.opt<ConfigOptionBools>("filament_mixed_gradient");
195 const bool is_gradient = grad_opt != nullptr && slot < grad_opt->size() && grad_opt->values[slot];
196 const auto* ratios_opt = full.opt<ConfigOptionStrings>("filament_mixed_sublayer_ratios");
197 wxString label;
198 for (size_t i = 0; i < comps.size(); ++i) {
199 if (i > 0)
200 label += is_gradient ? wxString::FromUTF8(" \u2192 ") : wxString::FromUTF8(" + ");
201 label += wxString::Format("%u", comps[i]);
202 if (!is_gradient) {
203 double ratio = 100.0 / comps.size();
204 if (ratios_opt != nullptr && slot < ratios_opt->size()) {
205 const std::vector<double> rs = parse_mixed_ratios(ratios_opt->values[slot], comps.size());
206 if (i < rs.size())
207 ratio = rs[i] * 100.0;
208 }
209 label += wxString::Format(" (%d%%)", int(ratio + 0.5));
210 }
211 }
212 return label;
213}
std::vector< double > parse_mixed_ratios(const std::string &str, size_t n_components)
Definition FilamentMixer.cpp:404

References _L, mixed_filament_label(), mixed_slot_components(), Slic3r::DynamicConfig::opt(), and Slic3r::parse_mixed_ratios().

Referenced by mixed_filament_label().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mixed_filament_tab_bitmap()

wxBitmap Slic3r::GUI::anonymous_namespace{PublishSettingsDialog.cpp}::mixed_filament_tab_bitmap ( const DynamicPrintConfig & full,
size_t slot,
int swatch_sz,
const wxColour & tab_bg )
281{
282 const std::vector<unsigned int> comps = mixed_slot_components(full, slot);
283 if (comps.empty())
284 return wxNullBitmap;
285 const auto* grad_opt = full.opt<ConfigOptionBools>("filament_mixed_gradient");
286 const bool is_gradient = grad_opt != nullptr && slot < grad_opt->size() && grad_opt->values[slot];
287 const auto* ratios_opt = full.opt<ConfigOptionStrings>("filament_mixed_sublayer_ratios");
288 std::vector<double> ratio_pct(comps.size(), 100.0 / comps.size());
289 if (!is_gradient && ratios_opt != nullptr && slot < ratios_opt->size()) {
290 const std::vector<double> rs = parse_mixed_ratios(ratios_opt->values[slot], comps.size());
291 for (size_t i = 0; i < rs.size() && i < comps.size(); ++i)
292 ratio_pct[i] = rs[i] * 100.0;
293 }
294
295 const auto* colours = full.opt<ConfigOptionStrings>("filament_colour");
296 const wxString lead_sep = wxString::FromUTF8(":");
297 const wxString comp_sep = is_gradient ? wxString::FromUTF8("\u2192") : wxString::FromUTF8("+");
298
299 // Phase 1 (layout): render every swatch and measure every text piece so the composite
300 // width is known before drawing; the dummy bitmap keeps GetTextExtent reliable.
301 struct Piece
302 {
303 enum Kind { Swatch, Text } kind{Text};
304 wxBitmap bmp;
305 wxString text;
306 };
307 std::vector<Piece> pieces;
308 bool has_lead = false;
309 wxBitmap dummy(1, 1);
310 wxMemoryDC measure_dc;
311 measure_dc.SelectObject(dummy);
312 measure_dc.SetFont(::Label::Body_12);
313 const int gap = wxWindow::FromDIP(4, nullptr);
314
315 auto push_swatch = [&](const std::string& hex, const std::string& label) {
316 wxBitmap* icon = get_extruder_color_icon(hex, label, swatch_sz, swatch_sz);
317 if (icon == nullptr)
318 return;
319 pieces.push_back({Piece::Swatch, *icon, wxString()});
320 };
321 auto push_text = [&](const wxString& text) { pieces.push_back({Piece::Text, wxNullBitmap, text}); };
322
323 {
324 const wxBitmap chip = mixed_filament_chip_bitmap(full, slot, swatch_sz);
325 has_lead = chip.IsOk();
326 if (has_lead)
327 pieces.push_back({Piece::Swatch, chip, wxString()});
328 }
329 for (size_t ci = 0; ci < comps.size(); ++ci) {
330 if (pieces.empty())
331 break;
332 push_text(has_lead && pieces.size() == 1 ? lead_sep : comp_sep); // lead chip may have failed to render
333 std::string hex = "#D9D9D9";
334 if (colours != nullptr && comps[ci] >= 1 && comps[ci] <= colours->size())
335 hex = colours->values[comps[ci] - 1];
336 const size_t before = pieces.size();
337 push_swatch(hex, std::to_string(comps[ci]));
338 if (pieces.size() == before)
339 break; // swatch failed: stop cleanly before an orphaned separator/percent pair
340 if (!is_gradient) {
341 push_text(wxString::Format("%d%%", int(ratio_pct[ci] + 0.5)));
342 }
343 }
344 if (pieces.empty())
345 return wxNullBitmap;
346
347 int width = 0;
348 for (const Piece& p : pieces)
349 width += (p.kind == Piece::Swatch ? swatch_sz : measure_dc.GetTextExtent(p.text).x + gap);
350
351 // Phase 2 (draw): opaque, filled with the tab strip's background colour. Text goes through
352 // the plain DC on every platform (see the function comment for why the alpha route is
353 // avoided); chip bitmaps keep their own alpha and composite cleanly onto the fill.
354 wxBitmap composite(width, swatch_sz);
355 wxMemoryDC memdc;
356 memdc.SelectObject(composite);
357 memdc.SetBackground(wxBrush(tab_bg));
358 memdc.Clear();
359 memdc.SetBackgroundMode(wxTRANSPARENT);
360 memdc.SetFont(::Label::Body_12);
361 memdc.SetTextForeground(StateColor::darkModeColorFor(wxColour("#262E30")));
362 int x = 0;
363 for (const Piece& p : pieces) {
364 if (p.kind == Piece::Swatch) {
365 memdc.DrawBitmap(p.bmp, x, 0, true);
366 x += swatch_sz;
367 } else {
368 const wxSize tsz = measure_dc.GetTextExtent(p.text);
369 memdc.DrawText(p.text, x + gap / 2, (swatch_sz - tsz.y) / 2);
370 x += tsz.x + gap;
371 }
372 }
373 memdc.SelectObject(wxNullBitmap);
374 return composite;
375}
wxBitmap mixed_filament_chip_bitmap(const DynamicPrintConfig &full, size_t slot, int swatch_sz)
Definition PublishSettingsDialog.cpp:237
coord_t width(const BoundingBox &box)
Definition Arrange.cpp:1184

References Label::Body_12, StateColor::darkModeColorFor(), get_extruder_color_icon(), mixed_filament_chip_bitmap(), mixed_filament_tab_bitmap(), mixed_slot_components(), Slic3r::DynamicConfig::opt(), and Slic3r::parse_mixed_ratios().

Referenced by mixed_filament_tab_bitmap().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mixed_slot_components()

std::vector< unsigned int > Slic3r::GUI::anonymous_namespace{PublishSettingsDialog.cpp}::mixed_slot_components ( const DynamicPrintConfig & full,
size_t slot )
179{
180 const auto* comp_opt = full.opt<ConfigOptionStrings>("filament_mixed_components");
181 if (comp_opt == nullptr || slot >= comp_opt->size())
182 return {};
183 return parse_mixed_components(comp_opt->values[slot]);
184}
std::vector< unsigned int > parse_mixed_components(const std::string &str)
Definition FilamentMixer.cpp:172

References mixed_slot_components(), Slic3r::DynamicConfig::opt(), and Slic3r::parse_mixed_components().

Referenced by mixed_filament_chip_bitmap(), mixed_filament_label(), mixed_filament_tab_bitmap(), and mixed_slot_components().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ project_used_filament_slots()

std::set< size_t > Slic3r::GUI::anonymous_namespace{PublishSettingsDialog.cpp}::project_used_filament_slots ( const PresetBundle & bundle,
const DynamicPrintConfig & full,
const Model & model )
383{
384 std::set<size_t> used; // 0-based used slots, mixed slots not yet expanded
385 if (model.objects.empty())
386 return used;
387
388 auto add_1based = [&used](int id) {
389 if (id > 0)
390 used.insert(size_t(id - 1));
391 };
392
393 const DynamicPrintConfig& print_cfg = bundle.prints.get_edited_preset().config;
394 const int glb_support_intf = print_cfg.opt_int("support_interface_filament");
395 const int glb_support = print_cfg.opt_int("support_filament");
396 const int glb_outer_wall = print_cfg.opt_int("outer_wall_filament_id");
397 const int glb_inner_wall = print_cfg.opt_int("inner_wall_filament_id");
398 const int glb_sparse_infill = print_cfg.opt_int("sparse_infill_filament_id");
399 const int glb_internal_solid = print_cfg.opt_int("internal_solid_filament_id");
400 const int glb_top_surface = print_cfg.opt_int("top_surface_filament_id");
401 const int glb_bottom_surface = print_cfg.opt_int("bottom_surface_filament_id");
402 const bool glb_support_on = print_cfg.opt_bool("enable_support") || print_cfg.opt_int("raft_layers") > 0;
403
404 for (ModelObject* mo : model.objects) {
405 for (ModelVolume* mv : mo->volumes)
406 for (int e : mv->get_extruders())
407 add_1based(e);
408
409 for (const auto& range_entry : mo->layer_config_ranges)
410 if (const ConfigOption* ext_opt = range_entry.second.option("extruder"))
411 add_1based(ext_opt->getInt());
412
413 bool obj_support = glb_support_on;
414 if (const ConfigOption* s_opt = mo->config.option("enable_support"); s_opt != nullptr)
415 obj_support = s_opt->getBool();
416 else if (const ConfigOption* r_opt = mo->config.option("raft_layers"); r_opt != nullptr)
417 obj_support = r_opt->getInt() > 0;
418
419 if (obj_support) {
420 if (const ConfigOption* opt = mo->config.option("support_interface_filament"); opt != nullptr && opt->getInt() != 0)
421 add_1based(opt->getInt());
422 else
423 add_1based(glb_support_intf);
424
425 if (const ConfigOption* opt = mo->config.option("support_filament"); opt != nullptr && opt->getInt() != 0)
426 add_1based(opt->getInt());
427 else
428 add_1based(glb_support);
429 }
430
431 auto obj_id = [&mo](const char* key) {
432 const ConfigOption* opt = mo->config.option(key);
433 return (opt != nullptr) ? opt->getInt() : 0;
434 };
435
436 int obj_outer_wall = obj_id("outer_wall_filament_id");
437 if (obj_outer_wall == 0)
438 obj_outer_wall = obj_id("inner_wall_filament_id");
439 add_1based(obj_outer_wall != 0 ? obj_outer_wall : glb_outer_wall);
440
441 int obj_inner_wall = obj_id("inner_wall_filament_id");
442 if (obj_inner_wall == 0)
443 obj_inner_wall = obj_id("outer_wall_filament_id");
444 add_1based(obj_inner_wall != 0 ? obj_inner_wall : glb_inner_wall);
445
446 const int obj_sparse = obj_id("sparse_infill_filament_id");
447 add_1based(obj_sparse != 0 ? obj_sparse : glb_sparse_infill);
448
449 const int obj_internal_solid = obj_id("internal_solid_filament_id");
450 add_1based(obj_internal_solid != 0 ? obj_internal_solid : glb_internal_solid);
451
452 int obj_top = obj_id("top_surface_filament_id");
453 if (obj_top == 0)
454 obj_top = obj_internal_solid;
455 add_1based(obj_top != 0 ? obj_top : glb_top_surface);
456
457 int obj_bottom = obj_id("bottom_surface_filament_id");
458 if (obj_bottom == 0)
459 obj_bottom = obj_internal_solid;
460 add_1based(obj_bottom != 0 ? obj_bottom : glb_bottom_surface);
461 }
462
463 for (const auto& plate_entry : model.plates_custom_gcodes)
464 for (const CustomGCode::Item& item : plate_entry.second.gcodes)
465 if (item.type == CustomGCode::Type::ToolChange)
466 add_1based(item.extruder);
467
468 // Expand used mixed slots to their physical components and keep each mixed slot itself so the
469 // dialog shows the mix. A component both used directly and pulled in via a mix is deduped.
470 const auto* is_mixed_opt = full.opt<ConfigOptionBools>("filament_is_mixed");
471 const auto* comp_opt = full.opt<ConfigOptionStrings>("filament_mixed_components");
472 if (is_mixed_opt != nullptr && comp_opt != nullptr && has_any_mixed_filament(is_mixed_opt->values)) {
473 const std::vector<unsigned int> raw(used.begin(), used.end());
474 const std::vector<unsigned int> expanded = expand_mixed_filaments(raw, is_mixed_opt->values, comp_opt->values);
475 std::set<size_t> result(expanded.begin(), expanded.end());
476 for (unsigned int s : raw)
477 if (s < is_mixed_opt->values.size() && is_mixed_opt->values[s])
478 result.insert(s);
479 return result;
480 }
481
482 return used;
483}
Definition Config.hpp:284
bool opt_bool(const t_config_option_key &opt_key) const
Definition Config.hpp:3072
int & opt_int(const t_config_option_key &opt_key)
Definition Config.hpp:3056
Definition PrintConfig.hpp:915
const ConfigOption * option(const t_config_option_key &opt_key) const
Definition PrintConfig.hpp:2652
Definition Model.hpp:382
ModelConfigObject config
Definition Model.hpp:395
t_layer_config_ranges layer_config_ranges
Definition Model.hpp:397
ModelVolumePtrs volumes
Definition Model.hpp:393
Definition Model.hpp:832
std::vector< int > get_extruders() const
Definition Model.cpp:2713
ModelObjectPtrs objects
Definition Model.hpp:1702
std::map< int, CustomGCode::Info > plates_custom_gcodes
Definition Model.hpp:1743
PresetCollection prints
Definition PresetBundle.hpp:497
Preset & get_edited_preset()
Definition Preset.hpp:756
DynamicPrintConfig config
Definition Preset.hpp:300
@ ToolChange
Definition CustomGCode.hpp:21
Definition BruteforceOptimizer.hpp:11
bool has_any_mixed_filament(const std::vector< unsigned char > &is_mixed)
Definition FilamentMixer.cpp:486
std::vector< unsigned int > expand_mixed_filaments(const std::vector< unsigned int > &extruders_0based, const std::vector< unsigned char > &is_mixed, const std::vector< std::string > &comp_strs)
Definition FilamentMixer.cpp:520

References Slic3r::ModelObject::config, Slic3r::Preset::config, Slic3r::expand_mixed_filaments(), Slic3r::CustomGCode::Item::extruder, Slic3r::PresetCollection::get_edited_preset(), Slic3r::ModelVolume::get_extruders(), Slic3r::has_any_mixed_filament(), Slic3r::ModelObject::layer_config_ranges, Slic3r::Model::objects, Slic3r::DynamicConfig::opt(), Slic3r::DynamicConfig::opt_bool(), Slic3r::DynamicConfig::opt_int(), Slic3r::ModelConfig::option(), Slic3r::Model::plates_custom_gcodes, Slic3r::PresetBundle::prints, project_used_filament_slots(), Slic3r::CustomGCode::ToolChange, Slic3r::CustomGCode::Item::type, Slic3r::ConfigOptionVector< unsigned char >::values, and Slic3r::ModelObject::volumes.

Referenced by project_used_filament_slots().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ s_tab_style

long Slic3r::GUI::anonymous_namespace{PublishSettingsDialog.cpp}::s_tab_style
constexpr
Initial value:
= wxTR_NO_BUTTONS | wxTR_HIDE_ROOT | wxTR_SINGLE | wxTR_NO_LINES | wxBORDER_NONE | wxWANTS_CHARS |
wxTR_FULL_ROW_HIGHLIGHT