mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-20 03:43:52 +00: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:
@@ -1257,12 +1257,10 @@ void AmsMapingPopup::update(MachineObject* obj, const std::vector<FilamentInfo>&
|
|||||||
Refresh();
|
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::vector<TrayData> m_tray_data;
|
||||||
std::map<std::string, DevAms *>::iterator ams_iter;
|
for (auto ams_iter = amsList.begin(); ams_iter != amsList.end(); ams_iter++) {
|
||||||
|
|
||||||
for (ams_iter = amsList.begin(); ams_iter != amsList.end(); ams_iter++) {
|
|
||||||
|
|
||||||
BOOST_LOG_TRIVIAL(trace) << "ams_mapping ams id " << ams_iter->first.c_str();
|
BOOST_LOG_TRIVIAL(trace) << "ams_mapping ams id " << ams_iter->first.c_str();
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,8 @@
|
|||||||
#include <wx/simplebook.h>
|
#include <wx/simplebook.h>
|
||||||
#include <wx/hashmap.h>
|
#include <wx/hashmap.h>
|
||||||
|
|
||||||
|
#include "slic3r/GUI/DeviceCore/DevUtil.h"
|
||||||
|
|
||||||
#define MAPPING_ITEM_INVALID_REMAIN -1
|
#define MAPPING_ITEM_INVALID_REMAIN -1
|
||||||
|
|
||||||
namespace Slic3r { namespace GUI {
|
namespace Slic3r { namespace GUI {
|
||||||
@@ -277,7 +279,7 @@ public:
|
|||||||
void paintEvent(wxPaintEvent &evt);
|
void paintEvent(wxPaintEvent &evt);
|
||||||
void set_parent_item(MaterialItem* item) {m_parent_item = item;};
|
void set_parent_item(MaterialItem* item) {m_parent_item = item;};
|
||||||
void set_show_type(ShowType type) { m_show_type = type; };
|
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&)>;
|
using ResetCallback = std::function<void(const std::string&)>;
|
||||||
void reset_ams_info();
|
void reset_ams_info();
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include "DevDefs.h"
|
#include "DevDefs.h"
|
||||||
#include "DevFilaAmsSetting.h"
|
#include "DevFilaAmsSetting.h"
|
||||||
|
#include "DevUtil.h"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@@ -158,7 +159,7 @@ public:
|
|||||||
|
|
||||||
/* ams */
|
/* ams */
|
||||||
DevAms* GetAmsById(const std::string& ams_id) const;
|
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(); }
|
int GetAmsCount() const { return amsList.size(); }
|
||||||
|
|
||||||
/* tray*/
|
/* tray*/
|
||||||
@@ -190,7 +191,7 @@ private:
|
|||||||
/* ams properties */
|
/* ams properties */
|
||||||
int m_ams_cali_stat = 0;
|
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 };
|
DevAmsSystemSetting m_ams_system_setting{ this };
|
||||||
std::shared_ptr<DevAmsSystemFirmwareSwitch> m_ams_firmware_switch = DevAmsSystemFirmwareSwitch::Create(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);
|
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
|
}; // namespace Slic3r
|
||||||
Reference in New Issue
Block a user