mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2026-02-15 17:09:43 -07:00
FIX: the sorting of AMS list
JIRA: [STUDIO-14738] [STUDIO-14651] Change-Id: I6d4b89edc77383be8afacf9823567bc756c8e2ed (cherry picked from commit 8defa1f50b4b556c6ebaf2ad533ba09ad3f23e38)
This commit is contained in:
parent
2234b227c4
commit
8d3da67254
4 changed files with 27 additions and 7 deletions
|
|
@ -1257,12 +1257,10 @@ void AmsMapingPopup::update(MachineObject* obj, const std::vector<FilamentInfo>&
|
|||
Refresh();
|
||||
}
|
||||
|
||||
std::vector<TrayData> AmsMapingPopup::parse_ams_mapping(std::map<std::string, DevAms*> amsList)
|
||||
std::vector<TrayData> AmsMapingPopup::parse_ams_mapping(const std::map<std::string, DevAms*, NumericStrCompare>& amsList)
|
||||
{
|
||||
std::vector<TrayData> m_tray_data;
|
||||
std::map<std::string, DevAms *>::iterator ams_iter;
|
||||
|
||||
for (ams_iter = amsList.begin(); ams_iter != amsList.end(); ams_iter++) {
|
||||
for (auto ams_iter = amsList.begin(); ams_iter != amsList.end(); ams_iter++) {
|
||||
|
||||
BOOST_LOG_TRIVIAL(trace) << "ams_mapping ams id " << ams_iter->first.c_str();
|
||||
|
||||
|
|
|
|||
|
|
@ -39,6 +39,8 @@
|
|||
#include <wx/simplebook.h>
|
||||
#include <wx/hashmap.h>
|
||||
|
||||
#include "slic3r/GUI/DeviceCore/DevUtil.h"
|
||||
|
||||
#define MAPPING_ITEM_INVALID_REMAIN -1
|
||||
|
||||
namespace Slic3r { namespace GUI {
|
||||
|
|
@ -277,7 +279,7 @@ public:
|
|||
void paintEvent(wxPaintEvent &evt);
|
||||
void set_parent_item(MaterialItem* item) {m_parent_item = item;};
|
||||
void set_show_type(ShowType type) { m_show_type = type; };
|
||||
std::vector<TrayData> parse_ams_mapping(std::map<std::string, DevAms*> amsList);
|
||||
std::vector<TrayData> parse_ams_mapping(const std::map<std::string, DevAms*, NumericStrCompare>& amsList);
|
||||
|
||||
using ResetCallback = std::function<void(const std::string&)>;
|
||||
void reset_ams_info();
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include "DevDefs.h"
|
||||
#include "DevFilaAmsSetting.h"
|
||||
#include "DevUtil.h"
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
|
|
@ -158,7 +159,7 @@ public:
|
|||
|
||||
/* ams */
|
||||
DevAms* GetAmsById(const std::string& ams_id) const;
|
||||
std::map<std::string, DevAms*>& GetAmsList() { return amsList; }
|
||||
std::map<std::string, DevAms*, NumericStrCompare>& GetAmsList() { return amsList; }
|
||||
int GetAmsCount() const { return amsList.size(); }
|
||||
|
||||
/* tray*/
|
||||
|
|
@ -190,7 +191,7 @@ private:
|
|||
/* ams properties */
|
||||
int m_ams_cali_stat = 0;
|
||||
|
||||
std::map<std::string, DevAms*> amsList; // key: ams[id], start with 0
|
||||
std::map<std::string, DevAms*, NumericStrCompare> amsList;// key: ams[id], start with 0
|
||||
|
||||
DevAmsSystemSetting m_ams_system_setting{ this };
|
||||
std::shared_ptr<DevAmsSystemFirmwareSwitch> m_ams_firmware_switch = DevAmsSystemFirmwareSwitch::Create(this);
|
||||
|
|
|
|||
|
|
@ -85,4 +85,23 @@ public:
|
|||
static std::string get_longlong_val(const nlohmann::json& j);
|
||||
};
|
||||
|
||||
|
||||
struct NumericStrCompare
|
||||
{
|
||||
bool operator()(const std::string& a, const std::string& b) const noexcept
|
||||
{
|
||||
int ai = -1;
|
||||
try {
|
||||
ai = std::stoi(a);
|
||||
} catch (...) { };
|
||||
|
||||
int bi = -1;
|
||||
try {
|
||||
bi = std::stoi(b);
|
||||
} catch (...) { };
|
||||
|
||||
return ai < bi;
|
||||
}
|
||||
};
|
||||
|
||||
}; // namespace Slic3r
|
||||
Loading…
Add table
Add a link
Reference in a new issue