mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-08 23:46:24 -06:00
NEW:AMS control supports gradient color filaments display
Change-Id: I38d8a313d84b3acf643b489a1e62ebd073b35c1d
This commit is contained in:
parent
d43c7d5c92
commit
8d6c56e4aa
4 changed files with 57 additions and 3 deletions
|
@ -3149,6 +3149,16 @@ int MachineObject::parse_json(std::string payload)
|
||||||
} else {
|
} else {
|
||||||
curr_tray->color = "";
|
curr_tray->color = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
curr_tray->cols.clear();
|
||||||
|
if (tray_it->contains("cols")) {
|
||||||
|
if ((*tray_it)["cols"].is_array()) {
|
||||||
|
for (auto it = (*tray_it)["cols"].begin(); it != (*tray_it)["cols"].end(); it++) {
|
||||||
|
curr_tray->cols.push_back(it.value().get<std::string>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (tray_it->contains("remain")) {
|
if (tray_it->contains("remain")) {
|
||||||
curr_tray->remain = (*tray_it)["remain"].get<int>();
|
curr_tray->remain = (*tray_it)["remain"].get<int>();
|
||||||
} else {
|
} else {
|
||||||
|
@ -3297,6 +3307,16 @@ int MachineObject::parse_json(std::string payload)
|
||||||
else {
|
else {
|
||||||
vt_tray.color = "";
|
vt_tray.color = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vt_tray.cols.clear();
|
||||||
|
if (jj["vt_tray"].contains("cols")) {
|
||||||
|
if (jj["vt_tray"].is_array()) {
|
||||||
|
for (auto it = jj["vt_tray"].begin(); it != jj["vt_tray"].end(); it++) {
|
||||||
|
vt_tray.cols.push_back(it.value().get<std::string>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (jj["vt_tray"].contains("remain")) {
|
if (jj["vt_tray"].contains("remain")) {
|
||||||
vt_tray.remain = jj["vt_tray"]["remain"].get<int>();
|
vt_tray.remain = jj["vt_tray"]["remain"].get<int>();
|
||||||
}
|
}
|
||||||
|
@ -3371,6 +3391,16 @@ int MachineObject::parse_json(std::string payload)
|
||||||
tray_it->second->nozzle_temp_min = std::to_string(jj["nozzle_temp_min"].get<int>());
|
tray_it->second->nozzle_temp_min = std::to_string(jj["nozzle_temp_min"].get<int>());
|
||||||
tray_it->second->type = jj["tray_type"].get<std::string>();
|
tray_it->second->type = jj["tray_type"].get<std::string>();
|
||||||
tray_it->second->color = jj["tray_color"].get<std::string>();
|
tray_it->second->color = jj["tray_color"].get<std::string>();
|
||||||
|
|
||||||
|
/*tray_it->second->cols.clear();
|
||||||
|
if (jj.contains("cols")) {
|
||||||
|
if (jj["cols"].is_array()) {
|
||||||
|
for (auto it = jj["cols"].begin(); it != jj["cols"].end(); it++) {
|
||||||
|
tray_it->second->cols.push_back(it.value().get<std::string>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
tray_it->second->setting_id = jj["tray_info_idx"].get<std::string>();
|
tray_it->second->setting_id = jj["tray_info_idx"].get<std::string>();
|
||||||
// delay update
|
// delay update
|
||||||
tray_it->second->set_hold_count();
|
tray_it->second->set_hold_count();
|
||||||
|
|
|
@ -193,6 +193,7 @@ public:
|
||||||
std::string type;
|
std::string type;
|
||||||
std::string sub_brands;
|
std::string sub_brands;
|
||||||
std::string color;
|
std::string color;
|
||||||
|
std::vector<std::string> cols;
|
||||||
std::string weight;
|
std::string weight;
|
||||||
std::string diameter;
|
std::string diameter;
|
||||||
std::string temp;
|
std::string temp;
|
||||||
|
|
|
@ -58,6 +58,10 @@ bool AMSinfo::parse_ams_info(Ams *ams, bool remain_flag, bool humidity_flag)
|
||||||
info.material_colour = AMS_TRAY_DEFAULT_COL;
|
info.material_colour = AMS_TRAY_DEFAULT_COL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (std::string cols:it->second->cols) {
|
||||||
|
info.material_cols.push_back(AmsTray::decode_color(cols));
|
||||||
|
}
|
||||||
|
|
||||||
if (MachineObject::is_bbl_filament(it->second->tag_uid)) {
|
if (MachineObject::is_bbl_filament(it->second->tag_uid)) {
|
||||||
info.material_state = AMSCanType::AMS_CAN_TYPE_BRAND;
|
info.material_state = AMSCanType::AMS_CAN_TYPE_BRAND;
|
||||||
} else {
|
} else {
|
||||||
|
@ -840,15 +844,33 @@ void AMSLib::doRender(wxDC &dc)
|
||||||
int height = size.y - FromDIP(8);
|
int height = size.y - FromDIP(8);
|
||||||
int curr_height = height * float(m_info.material_remain * 1.0 / 100.0);
|
int curr_height = height * float(m_info.material_remain * 1.0 / 100.0);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int top = height - curr_height;
|
int top = height - curr_height;
|
||||||
|
|
||||||
if (curr_height >= FromDIP(6)) {
|
if (curr_height >= FromDIP(6)) {
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
dc.DrawRoundedRectangle(FromDIP(4), FromDIP(4) + top, size.x - FromDIP(8), curr_height, m_radius);
|
dc.DrawRoundedRectangle(FromDIP(4), FromDIP(4) + top, size.x - FromDIP(8), curr_height, m_radius);
|
||||||
#else
|
#else
|
||||||
dc.DrawRoundedRectangle(FromDIP(4), FromDIP(4) + top, size.x - FromDIP(8), curr_height, m_radius - 1);
|
//gradient
|
||||||
|
if (m_info.material_cols.size() > 1) {
|
||||||
|
int left = FromDIP(4);
|
||||||
|
float total_width = size.x - FromDIP(8);
|
||||||
|
int gwidth = std::round(total_width / (m_info.material_cols.size() - 1));
|
||||||
|
|
||||||
|
for (int i = 0; i < m_info.material_cols.size() - 1; i++) {
|
||||||
|
|
||||||
|
if ( (left + gwidth) > (size.x - FromDIP(8)) ) {
|
||||||
|
gwidth = (size.x - FromDIP(4)) - left;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto rect = wxRect(left, height - curr_height + FromDIP(4), gwidth, curr_height);
|
||||||
|
dc.GradientFillLinear(rect, m_info.material_cols[i], m_info.material_cols[i+1], wxEAST);
|
||||||
|
left += gwidth;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
dc.DrawRoundedRectangle(FromDIP(4), FromDIP(4) + top, size.x - FromDIP(8), curr_height, m_radius - 1);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -136,6 +136,7 @@ struct Caninfo
|
||||||
int material_remain = 100;
|
int material_remain = 100;
|
||||||
float k = 0.0f;
|
float k = 0.0f;
|
||||||
float n = 0.0f;
|
float n = 0.0f;
|
||||||
|
std::vector<wxColour> material_cols;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct AMSinfo
|
struct AMSinfo
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue