OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GUI::DynamicFilamentList Struct Reference
Inheritance diagram for Slic3r::GUI::DynamicFilamentList:
Collaboration diagram for Slic3r::GUI::DynamicFilamentList:

Public Member Functions

 DynamicFilamentList (bool physical_only=false)
void apply_on (Choice *c) override
wxString get_value (int index) override
int index_of (wxString value) override
void update (bool force=false)

Public Attributes

bool physical_only
std::vector< std::pair< wxString, wxBitmap * > > items
std::vector< int > slot_map {0}

Protected Member Functions

void update ()

Protected Attributes

std::vector< Choice * > m_choices

Private Member Functions

void add_choice (Choice *choice)
void remove_choice (Choice *choice)

Detailed Description

Constructor & Destructor Documentation

◆ DynamicFilamentList()

Slic3r::GUI::DynamicFilamentList::DynamicFilamentList ( bool physical_only = false)
inlineexplicit
bool physical_only
Definition Plater.cpp:1320

References physical_only.

Member Function Documentation

◆ add_choice()

void Slic3r::GUI::DynamicList::add_choice ( Choice * choice)
privateinherited
1542{
1543 auto iter = std::find(m_choices.begin(), m_choices.end(), choice);
1544 if (iter != m_choices.end()) return;
1545 apply_on(choice);
1546 m_choices.push_back(choice);
1547}
virtual void apply_on(Choice *choice)=0
std::vector< Choice * > m_choices
Definition Field.hpp:437

References apply_on(), Choice, and m_choices.

Here is the call graph for this function:

◆ apply_on()

void Slic3r::GUI::DynamicFilamentList::apply_on ( Choice * c)
inlineoverridevirtual

Implements Slic3r::GUI::DynamicList.

1325 {
1326 if (!c)
1327 return;
1328 if (items.empty())
1329 update(true);
1330 auto cb = dynamic_cast<ComboBox *>(c->window);
1331 if (!cb)
1332 return;
1333 wxString old_selection = cb->GetStringSelection();
1334 int old_index = cb->GetSelection();
1335 // slot_map is already rebuilt here: restoring through it keeps the index of every slot
1336 // still listed and sends a vanished slot to the fallback below.
1337 int old_slot = old_index >= 0 && old_index < int(slot_map.size()) ? slot_map[old_index] : -1;
1338 cb->Clear();
1339 cb->Append(_L("Default"));
1340 for (auto i : items) {
1341 cb->Append(i.first, i.second ? *i.second : wxNullBitmap);
1342 }
1343
1344 int restored = index_of(wxString::Format("%d", old_slot));
1345 if (restored > 0 || old_slot == 0) {
1346 cb->SetSelection(restored);
1347 return;
1348 }
1349
1350 int new_index = cb->FindString(old_selection);
1351 if (old_index == cb->GetCount()) {
1352 cb->SetSelection(old_index - 1);
1353 } else if (new_index != wxNOT_FOUND) {
1354 cb->SetSelection(new_index);
1355 } else {
1356 cb->SetSelection(0);
1357 }
1358 }
#define _L(s)
Definition OBJ.cpp:34
void update()
Definition Field.cpp:1536
std::vector< int > slot_map
Definition Plater.cpp:1322
std::vector< std::pair< wxString, wxBitmap * > > items
Definition Plater.cpp:1321
int index_of(wxString value) override
Definition Plater.cpp:1365

References _L, Slic3r::GUI::DynamicList::Choice, ComboBox::GetSelection(), index_of(), items, slot_map, update(), and Slic3r::GUI::Choice::window.

Here is the call graph for this function:

◆ get_value()

wxString Slic3r::GUI::DynamicFilamentList::get_value ( int index)
inlineoverridevirtual

Implements Slic3r::GUI::DynamicList.

1360 {
1361 wxString str;
1362 str << (index >= 0 && index < int(slot_map.size()) ? slot_map[index] : 0);
1363 return str;
1364 }

References slot_map.

◆ index_of()

int Slic3r::GUI::DynamicFilamentList::index_of ( wxString value)
inlineoverridevirtual

Implements Slic3r::GUI::DynamicList.

1366 {
1367 long n = 0;
1368 if (!value.ToLong(&n))
1369 return -1;
1370 for (int i = 0; i < int(slot_map.size()); ++i)
1371 if (slot_map[i] == int(n))
1372 return i;
1373 return 0;
1374 }

References slot_map.

Referenced by apply_on().

Here is the caller graph for this function:

◆ remove_choice()

void Slic3r::GUI::DynamicList::remove_choice ( Choice * choice)
privateinherited
1550{
1551 auto iter = std::find(m_choices.begin(), m_choices.end(), choice);
1552 if (iter != m_choices.end()) m_choices.erase(iter);
1553}

References Choice, and m_choices.

Here is the call graph for this function:

◆ update() [1/2]

void Slic3r::GUI::DynamicFilamentList::update ( bool force = false)
inline
1376 {
1377 items.clear();
1378 slot_map.assign(1, 0);
1379 if (!force && m_choices.empty())
1380 return;
1381 auto icons = get_extruder_color_icons(true);
1382 auto presets = wxGetApp().preset_bundle->filament_presets;
1383 for (int i = 0; i < presets.size(); ++i) {
1384 if (physical_only && wxGetApp().preset_bundle->is_mixed_filament(i))
1385 continue;
1386 wxString str;
1387 std::string type;
1388 wxGetApp().preset_bundle->filaments.find_preset(presets[i])->get_filament_type(type);
1389 str << type;
1390 items.push_back({str, i < icons.size() ? icons[i] : nullptr});
1391 slot_map.push_back(i + 1);
1392 }
1394 }
std::vector< wxBitmap * > get_extruder_color_icons(bool thin_icon)
Definition wxExtensions.cpp:572

References get_extruder_color_icons(), items, Slic3r::GUI::DynamicList::m_choices, physical_only, slot_map, and Slic3r::GUI::DynamicList::update().

Referenced by apply_on().

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

◆ update() [2/2]

void Slic3r::GUI::DynamicList::update ( )
protectedinherited
1537{
1538 for (auto c : m_choices) apply_on(c);
1539}

References apply_on(), and m_choices.

Referenced by Slic3r::GUI::DynamicFilamentList::update().

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

Member Data Documentation

◆ items

std::vector<std::pair<wxString, wxBitmap *> > Slic3r::GUI::DynamicFilamentList::items

Referenced by apply_on(), and update().

◆ m_choices

std::vector<Choice*> Slic3r::GUI::DynamicList::m_choices
protectedinherited

◆ physical_only

bool Slic3r::GUI::DynamicFilamentList::physical_only

Referenced by DynamicFilamentList(), and update().

◆ slot_map

std::vector<int> Slic3r::GUI::DynamicFilamentList::slot_map {0}
1322{0}; // combo index -> 1-based filament slot; slot_map[0] = 0 is "Default"

Referenced by apply_on(), get_value(), index_of(), and update().


The documentation for this struct was generated from the following file:
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/Plater.cpp