NEW:Adapt to multicolour and gradient colour
JIRA:xxxx Change-Id: I8084cab603d5681cbcaf2d6f5e0d7ad5419cb2af
This commit is contained in:
parent
557d587bfa
commit
cafc1c7148
|
@ -673,6 +673,10 @@ void AMSMaterialsSetting::set_colors(std::vector<wxColour> colors)
|
||||||
m_clr_picker->set_colors(colors);
|
m_clr_picker->set_colors(colors);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AMSMaterialsSetting::set_ctype(int ctype)
|
||||||
|
{
|
||||||
|
m_clr_picker->ctype = ctype;
|
||||||
|
}
|
||||||
|
|
||||||
void AMSMaterialsSetting::on_picker_color(wxCommandEvent& event)
|
void AMSMaterialsSetting::on_picker_color(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
|
@ -1201,23 +1205,39 @@ void ColorPicker::doRender(wxDC& dc)
|
||||||
if (alpha == 0) {
|
if (alpha == 0) {
|
||||||
dc.DrawBitmap(m_bitmap_transparent, 0, 0);
|
dc.DrawBitmap(m_bitmap_transparent, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_cols.size() > 1) {
|
if (m_cols.size() > 1) {
|
||||||
int left = FromDIP(0);
|
if (ctype == 0) {
|
||||||
float total_width = size.x;
|
int left = FromDIP(0);
|
||||||
int gwidth = std::round(total_width / (m_cols.size() - 1));
|
float total_width = size.x;
|
||||||
|
int gwidth = std::round(total_width / (m_cols.size() - 1));
|
||||||
|
|
||||||
for (int i = 0; i < m_cols.size() - 1; i++) {
|
for (int i = 0; i < m_cols.size() - 1; i++) {
|
||||||
|
|
||||||
if ((left + gwidth) > (size.x)) {
|
if ((left + gwidth) > (size.x)) {
|
||||||
gwidth = size.x - left;
|
gwidth = size.x - left;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto rect = wxRect(left, 0, gwidth, size.y);
|
||||||
|
dc.GradientFillLinear(rect, m_cols[i], m_cols[i + 1], wxEAST);
|
||||||
|
left += gwidth;
|
||||||
|
}
|
||||||
|
dc.DrawBitmap(m_bitmap_border, wxPoint(0, 0));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
float ev_angle = 360.0 / m_cols.size();
|
||||||
|
float startAngle = 270.0;
|
||||||
|
float endAngle = 270.0;
|
||||||
|
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||||
|
for (int i = 0; i < m_cols.size(); i++) {
|
||||||
|
dc.SetBrush(m_cols[i]);
|
||||||
|
endAngle += ev_angle;
|
||||||
|
endAngle = endAngle > 360.0 ? endAngle - 360.0 : endAngle;
|
||||||
|
wxPoint center(size.x / 2, size.y / 2);
|
||||||
|
dc.DrawEllipticArc(center.x - radius, center.y - radius, 2 * radius, 2 * radius, startAngle, endAngle);
|
||||||
|
startAngle += ev_angle;
|
||||||
|
startAngle = startAngle > 360.0 ? startAngle - 360.0 : startAngle;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto rect = wxRect(left, 0, gwidth, size.y);
|
|
||||||
dc.GradientFillLinear(rect, m_cols[i], m_cols[i + 1], wxEAST);
|
|
||||||
left += gwidth;
|
|
||||||
}
|
}
|
||||||
dc.DrawBitmap(m_bitmap_border, wxPoint(0, 0));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,7 @@ public:
|
||||||
bool m_selected{false};
|
bool m_selected{false};
|
||||||
bool m_show_full{false};
|
bool m_show_full{false};
|
||||||
bool m_is_empty{false};
|
bool m_is_empty{false};
|
||||||
|
int ctype;
|
||||||
|
|
||||||
ColorPicker(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize);
|
ColorPicker(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize);
|
||||||
~ColorPicker();
|
~ColorPicker();
|
||||||
|
@ -109,6 +110,7 @@ public:
|
||||||
void set_color(wxColour color);
|
void set_color(wxColour color);
|
||||||
void set_empty_color(wxColour color);
|
void set_empty_color(wxColour color);
|
||||||
void set_colors(std::vector<wxColour> colors);
|
void set_colors(std::vector<wxColour> colors);
|
||||||
|
void set_ctype(int ctype);
|
||||||
|
|
||||||
void on_picker_color(wxCommandEvent& color);
|
void on_picker_color(wxCommandEvent& color);
|
||||||
MachineObject* obj{ nullptr };
|
MachineObject* obj{ nullptr };
|
||||||
|
|
|
@ -3884,6 +3884,10 @@ int MachineObject::parse_json(std::string payload)
|
||||||
curr_tray->color = "";
|
curr_tray->color = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tray_it->contains("ctype"))
|
||||||
|
curr_tray->ctype = (*tray_it)["ctype"].get<int>();
|
||||||
|
else
|
||||||
|
curr_tray->ctype = 0;
|
||||||
curr_tray->cols.clear();
|
curr_tray->cols.clear();
|
||||||
if (tray_it->contains("cols")) {
|
if (tray_it->contains("cols")) {
|
||||||
if ((*tray_it)["cols"].is_array()) {
|
if ((*tray_it)["cols"].is_array()) {
|
||||||
|
|
|
@ -194,6 +194,7 @@ public:
|
||||||
std::string nozzle_temp_min;
|
std::string nozzle_temp_min;
|
||||||
std::string xcam_info;
|
std::string xcam_info;
|
||||||
std::string uuid;
|
std::string uuid;
|
||||||
|
int ctype = 0;
|
||||||
float k = 0.0f; // k range: 0 ~ 0.5
|
float k = 0.0f; // k range: 0 ~ 0.5
|
||||||
float n = 0.0f; // k range: 0.6 ~ 2.0
|
float n = 0.0f; // k range: 0.6 ~ 2.0
|
||||||
int cali_idx = 0;
|
int cali_idx = 0;
|
||||||
|
|
|
@ -3504,7 +3504,7 @@ void StatusPanel::on_filament_edit(wxCommandEvent &event)
|
||||||
for (auto col : tray_it->second->cols) {
|
for (auto col : tray_it->second->cols) {
|
||||||
cols.push_back( AmsTray::decode_color(col));
|
cols.push_back( AmsTray::decode_color(col));
|
||||||
}
|
}
|
||||||
|
m_filament_setting_dlg->set_ctype(tray_it->second->ctype);
|
||||||
m_filament_setting_dlg->ams_filament_id = tray_it->second->setting_id;
|
m_filament_setting_dlg->ams_filament_id = tray_it->second->setting_id;
|
||||||
|
|
||||||
if (m_filament_setting_dlg->ams_filament_id.empty()) {
|
if (m_filament_setting_dlg->ams_filament_id.empty()) {
|
||||||
|
|
|
@ -52,6 +52,7 @@ bool AMSinfo::parse_ams_info(MachineObject *obj, Ams *ams, bool remain_flag, boo
|
||||||
if (it != ams->trayList.end() && it->second->is_exists) {
|
if (it != ams->trayList.end() && it->second->is_exists) {
|
||||||
if (it->second->is_tray_info_ready()) {
|
if (it->second->is_tray_info_ready()) {
|
||||||
info.can_id = it->second->id;
|
info.can_id = it->second->id;
|
||||||
|
info.ctype = it->second->ctype;
|
||||||
info.material_name = it->second->get_display_filament_type();
|
info.material_name = it->second->get_display_filament_type();
|
||||||
if (!it->second->color.empty()) {
|
if (!it->second->color.empty()) {
|
||||||
info.material_colour = AmsTray::decode_color(it->second->color);
|
info.material_colour = AmsTray::decode_color(it->second->color);
|
||||||
|
@ -81,6 +82,7 @@ bool AMSinfo::parse_ams_info(MachineObject *obj, Ams *ams, bool remain_flag, boo
|
||||||
} else {
|
} else {
|
||||||
info.can_id = it->second->id;
|
info.can_id = it->second->id;
|
||||||
info.material_name = "";
|
info.material_name = "";
|
||||||
|
info.ctype = 0;
|
||||||
info.material_colour = AMS_TRAY_DEFAULT_COL;
|
info.material_colour = AMS_TRAY_DEFAULT_COL;
|
||||||
info.material_state = AMSCanType::AMS_CAN_TYPE_THIRDBRAND;
|
info.material_state = AMSCanType::AMS_CAN_TYPE_THIRDBRAND;
|
||||||
wxColour(255, 255, 255);
|
wxColour(255, 255, 255);
|
||||||
|
@ -969,7 +971,7 @@ void AMSLib::render_extra_lib(wxDC& dc)
|
||||||
ScalableBitmap tray_bitmap_selected = m_can_index <= 1 ? m_bitmap_extra_tray_left_selected : m_bitmap_extra_tray_right_selected;
|
ScalableBitmap tray_bitmap_selected = m_can_index <= 1 ? m_bitmap_extra_tray_left_selected : m_bitmap_extra_tray_right_selected;
|
||||||
|
|
||||||
|
|
||||||
auto tmp_lib_colour = m_info.material_colour;
|
auto tmp_lib_colour = m_info.material_colour;
|
||||||
auto temp_bitmap_third = m_bitmap_editable_light;
|
auto temp_bitmap_third = m_bitmap_editable_light;
|
||||||
auto temp_bitmap_brand = m_bitmap_readonly_light;
|
auto temp_bitmap_brand = m_bitmap_readonly_light;
|
||||||
|
|
||||||
|
@ -1015,11 +1017,34 @@ void AMSLib::render_extra_lib(wxDC& dc)
|
||||||
temp_bitmap_brand = m_bitmap_readonly;
|
temp_bitmap_brand = m_bitmap_readonly;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dc.SetPen(wxPen(*wxTRANSPARENT_PEN));
|
||||||
|
if (m_info.material_cols.size() > 1) {
|
||||||
|
int left = FromDIP(10);
|
||||||
|
int gwidth = std::round(size.x / (m_info.material_cols.size() - 1));
|
||||||
|
//gradient
|
||||||
|
if (m_info.ctype == 0) {
|
||||||
|
for (int i = 0; i < m_info.material_cols.size() - 1; i++) {
|
||||||
|
auto rect = wxRect(left, FromDIP(10), size.x - FromDIP(20), size.y - FromDIP(20));
|
||||||
|
dc.GradientFillLinear(rect, m_info.material_cols[i], m_info.material_cols[i + 1], wxEAST);
|
||||||
|
left += gwidth;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
int cols_size = m_info.material_cols.size();
|
||||||
|
for (int i = 0; i < cols_size; i++) {
|
||||||
|
dc.SetBrush(wxBrush(m_info.material_cols[i]));
|
||||||
|
float x = FromDIP(10) + ((float)size.x - FromDIP(20)) * i / cols_size;
|
||||||
|
dc.DrawRoundedRectangle(x, FromDIP(10), ((float)size.x - FromDIP(20)) / cols_size, size.y - FromDIP(20), 0);
|
||||||
|
}
|
||||||
|
dc.SetBrush(wxBrush(tmp_lib_colour));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
dc.SetBrush(wxBrush(tmp_lib_colour));
|
||||||
|
dc.DrawRoundedRectangle(FromDIP(10), FromDIP(10), size.x - FromDIP(20), size.y - FromDIP(20), 0);
|
||||||
|
}
|
||||||
dc.SetPen(wxPen(*wxTRANSPARENT_PEN));
|
dc.SetPen(wxPen(*wxTRANSPARENT_PEN));
|
||||||
dc.SetBrush(wxBrush(tmp_lib_colour));
|
dc.SetBrush(wxBrush(tmp_lib_colour));
|
||||||
dc.DrawRoundedRectangle(FromDIP(10), FromDIP(10), size.x - FromDIP(20), size.y - FromDIP(20), 0);
|
|
||||||
|
|
||||||
|
|
||||||
if (!m_disable_mode) {
|
if (!m_disable_mode) {
|
||||||
// edit icon
|
// edit icon
|
||||||
if (m_info.material_state != AMSCanType::AMS_CAN_TYPE_EMPTY && m_info.material_state != AMSCanType::AMS_CAN_TYPE_NONE)
|
if (m_info.material_state != AMSCanType::AMS_CAN_TYPE_EMPTY && m_info.material_state != AMSCanType::AMS_CAN_TYPE_NONE)
|
||||||
|
@ -1122,21 +1147,58 @@ void AMSLib::render_generic_lib(wxDC &dc)
|
||||||
dc.DrawBitmap(m_bitmap_transparent.bmp(), FromDIP(4), FromDIP(4));
|
dc.DrawBitmap(m_bitmap_transparent.bmp(), FromDIP(4), FromDIP(4));
|
||||||
}
|
}
|
||||||
|
|
||||||
//gradient
|
|
||||||
if (m_info.material_cols.size() > 1) {
|
if (m_info.material_cols.size() > 1) {
|
||||||
int left = FromDIP(4);
|
int left = FromDIP(4);
|
||||||
float total_width = size.x - FromDIP(8);
|
float total_width = size.x - FromDIP(8);
|
||||||
int gwidth = std::round(total_width / (m_info.material_cols.size() - 1));
|
int gwidth = std::round(total_width / (m_info.material_cols.size() - 1));
|
||||||
|
//gradient
|
||||||
|
if (m_info.ctype == 0) {
|
||||||
|
for (int i = 0; i < m_info.material_cols.size() - 1; i++) {
|
||||||
|
|
||||||
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;
|
||||||
|
}
|
||||||
|
|
||||||
if ((left + gwidth) > (size.x - FromDIP(8))) {
|
auto rect = wxRect(left, height - curr_height + FromDIP(4), gwidth, curr_height);
|
||||||
gwidth = (size.x - FromDIP(4)) - left;
|
dc.GradientFillLinear(rect, m_info.material_cols[i], m_info.material_cols[i + 1], wxEAST);
|
||||||
|
left += gwidth;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//multicolour
|
||||||
|
gwidth = std::round(total_width / m_info.material_cols.size());
|
||||||
|
for (int i = 0; i < m_info.material_cols.size(); i++) {
|
||||||
|
dc.SetPen(wxPen(*wxTRANSPARENT_PEN));
|
||||||
|
dc.SetBrush(wxBrush(m_info.material_cols[i]));
|
||||||
|
if (i == 0 || i == m_info.material_cols.size() - 1) {
|
||||||
|
#ifdef __APPLE__
|
||||||
|
dc.DrawRoundedRectangle(left + gwidth * i, height - curr_height + FromDIP(4), gwidth, curr_height, m_radius);
|
||||||
|
#else
|
||||||
|
dc.DrawRoundedRectangle(left + gwidth * i, height - curr_height + FromDIP(4), gwidth, curr_height, m_radius - 1);
|
||||||
|
#endif
|
||||||
|
//add rectangle
|
||||||
|
int dr_gwidth = std::round(gwidth * 0.6);
|
||||||
|
if (i == 0) {
|
||||||
|
dc.DrawRectangle(left + gwidth - dr_gwidth, height - curr_height + FromDIP(4), dr_gwidth, curr_height);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
dc.DrawRectangle(left + gwidth*i, height - curr_height + FromDIP(4), dr_gwidth, curr_height);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
dc.DrawRectangle(left + gwidth * i, height - curr_height + FromDIP(4), gwidth, curr_height);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//reset pen and brush
|
||||||
|
if (m_selected || m_hover) {
|
||||||
|
dc.SetPen(wxPen(*wxTRANSPARENT_PEN));
|
||||||
|
dc.SetBrush(wxBrush(tmp_lib_colour));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
dc.SetPen(wxPen(tmp_lib_colour, 1, wxSOLID));
|
||||||
|
dc.SetBrush(wxBrush(tmp_lib_colour));
|
||||||
}
|
}
|
||||||
|
|
||||||
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 {
|
else {
|
||||||
|
|
|
@ -140,6 +140,7 @@ struct Caninfo
|
||||||
wxString material_name;
|
wxString material_name;
|
||||||
wxColour material_colour = {*wxWHITE};
|
wxColour material_colour = {*wxWHITE};
|
||||||
AMSCanType material_state;
|
AMSCanType material_state;
|
||||||
|
int ctype=0;
|
||||||
int material_remain = 100;
|
int material_remain = 100;
|
||||||
float k = 0.0f;
|
float k = 0.0f;
|
||||||
float n = 0.0f;
|
float n = 0.0f;
|
||||||
|
|
Loading…
Reference in New Issue