diff --git a/src/slic3r/GUI/GUI_ObjectTable.cpp b/src/slic3r/GUI/GUI_ObjectTable.cpp index 48d92a4d58..1fc07bf5a2 100644 --- a/src/slic3r/GUI/GUI_ObjectTable.cpp +++ b/src/slic3r/GUI/GUI_ObjectTable.cpp @@ -1393,8 +1393,10 @@ wxString ObjectGridTable::GetValue (int row, int col) else if (grid_col->type == coInt) { ConfigOptionInt& option_value = dynamic_cast(option); return wxString::Format("%d", option_value.value); - } - else if (grid_col->type == coFloat) { + } else if (grid_col->type == coFloat) { + if (auto option_values = dynamic_cast(&option)) { + return wxString::Format("%.2f", option_values->get_at(0)); + } ConfigOptionFloat& option_value = dynamic_cast(option); return wxString::Format("%.2f", option_value.value); } @@ -1592,16 +1594,25 @@ void ObjectGridTable::SetValue( int row, int col, const wxString& value ) else { update_value_to_object(m_panel->m_model, grid_row, col); } - } - else if (grid_col->type == coFloat) { - ConfigOptionFloat &option_value = dynamic_cast((*grid_row)[(GridColType)col]); - ConfigOptionFloat &option_ori_value = dynamic_cast((*grid_row)[(GridColType)(col+1)]); + } else if (grid_col->type == coFloat) { + if (auto option_values = dynamic_cast(&(*grid_row)[(GridColType) col])) { + ConfigOptionFloatsNullable& option_ori_values = dynamic_cast((*grid_row)[(GridColType) (col + 1)]); - double double_value; - value.ToDouble(&double_value); - option_value.value = (float)double_value; + double double_value; + value.ToDouble(&double_value); + option_values->values.at(0) = (float) double_value; - update_value_to_config(grid_row->config, grid_col->key, option_value, option_ori_value); + update_value_to_config(grid_row->config, grid_col->key, *option_values, option_ori_values); + } else { + ConfigOptionFloat& option_value = dynamic_cast((*grid_row)[(GridColType) col]); + ConfigOptionFloat& option_ori_value = dynamic_cast((*grid_row)[(GridColType) (col + 1)]); + + double double_value; + value.ToDouble(&double_value); + option_value.value = (float) double_value; + + update_value_to_config(grid_row->config, grid_col->key, option_value, option_ori_value); + } } else if (grid_col->type == coInt) { ConfigOptionInt &option_value = dynamic_cast((*grid_row)[(GridColType)col]); @@ -1676,8 +1687,11 @@ double ObjectGridTable::GetValueAsDouble( int row, int col ) return 0; ObjectGridRow* grid_row = m_grid_data[row - 1]; - ConfigOptionFloat &option_value = dynamic_cast((*grid_row)[(GridColType)col]); - return (double )option_value.getFloat(); + if (auto option_values = dynamic_cast(&(*grid_row)[(GridColType) col])) { + return (double) option_values->get_at(0); + } + ConfigOptionFloat& option_value = dynamic_cast((*grid_row)[(GridColType) col]); + return (double) option_value.getFloat(); } void ObjectGridTable::SetValueAsLong( int row, int col, long value ) @@ -1722,6 +1736,17 @@ void ObjectGridTable::SetValueAsDouble(int row, int col, double value) if ((value > 100.f) || (value < 0.f)) return; } + + if (auto option_values = dynamic_cast(&(*grid_row)[(GridColType) col])) { + ConfigOptionFloatsNullable &option_ori_values = dynamic_cast((*grid_row)[(GridColType) (col + 1)]); + + option_values->values.at(0) = (float) value; + + update_value_to_config(grid_row->config, grid_col->key, *option_values, option_ori_values); + + return; + } + ConfigOptionFloat &option_value = dynamic_cast((*grid_row)[(GridColType)col]); ConfigOptionFloat &option_ori_value = dynamic_cast((*grid_row)[(GridColType)(col+1)]); @@ -1981,8 +2006,8 @@ void ObjectGridTable::construct_object_configs(ObjectGrid *object_grid) object_grid->ori_enable_support = *(global_config.option(m_col_data[col_enable_support]->key)); object_grid->brim_type = *(get_object_config_value>(global_config, object_grid->config, m_col_data[col_brim_type]->key)); object_grid->ori_brim_type = *(global_config.option>(m_col_data[col_brim_type]->key)); - object_grid->speed_perimeter = *(get_object_config_value(global_config, object_grid->config, m_col_data[col_speed_perimeter]->key)); - object_grid->ori_speed_perimeter = *(global_config.option(m_col_data[col_speed_perimeter]->key)); + object_grid->speed_perimeter = *(get_object_config_value(global_config, object_grid->config, m_col_data[col_speed_perimeter]->key)); + object_grid->ori_speed_perimeter = *(global_config.option(m_col_data[col_speed_perimeter]->key)); m_grid_data.push_back(object_grid); int volume_count = object->volumes.size(); @@ -2031,7 +2056,7 @@ void ObjectGridTable::construct_object_configs(ObjectGrid *object_grid) volume_grid->ori_enable_support = object_grid->enable_support; volume_grid->brim_type = *(get_volume_config_value>(global_config, object_grid->config, volume_grid->config, m_col_data[col_brim_type]->key)); volume_grid->ori_brim_type = object_grid->brim_type; - volume_grid->speed_perimeter = *(get_volume_config_value(global_config, object_grid->config, volume_grid->config, m_col_data[col_speed_perimeter]->key)); + volume_grid->speed_perimeter = *(get_volume_config_value(global_config, object_grid->config, volume_grid->config, m_col_data[col_speed_perimeter]->key)); volume_grid->ori_speed_perimeter = object_grid->speed_perimeter; m_grid_data.push_back(volume_grid); } @@ -2077,8 +2102,8 @@ void ObjectGridTable::reload_object_data(ObjectGridRow* grid_row, const std::str grid_row->ori_enable_support = *(global_config.option(m_col_data[col_enable_support]->key)); grid_row->brim_type = *(get_object_config_value>(global_config, grid_row->config, m_col_data[col_brim_type]->key)); grid_row->ori_brim_type = *(global_config.option>(m_col_data[col_brim_type]->key)); - grid_row->speed_perimeter = *(get_object_config_value(global_config, grid_row->config, m_col_data[col_speed_perimeter]->key)); - grid_row->ori_speed_perimeter = *(global_config.option(m_col_data[col_speed_perimeter]->key)); + grid_row->speed_perimeter = *(get_object_config_value(global_config, grid_row->config, m_col_data[col_speed_perimeter]->key)); + grid_row->ori_speed_perimeter = *(global_config.option(m_col_data[col_speed_perimeter]->key)); } else if (category == L("Quality")) { grid_row->layer_height = *(get_object_config_value(global_config, grid_row->config, m_col_data[col_layer_height]->key)); @@ -2099,8 +2124,8 @@ void ObjectGridTable::reload_object_data(ObjectGridRow* grid_row, const std::str grid_row->ori_brim_type = *(global_config.option>(m_col_data[col_brim_type]->key)); } else if (category == L("Speed")) { - grid_row->speed_perimeter = *(get_object_config_value(global_config, grid_row->config, m_col_data[col_speed_perimeter]->key)); - grid_row->ori_speed_perimeter = *(global_config.option(m_col_data[col_speed_perimeter]->key)); + grid_row->speed_perimeter = *(get_object_config_value(global_config, grid_row->config, m_col_data[col_speed_perimeter]->key)); + grid_row->ori_speed_perimeter = *(global_config.option(m_col_data[col_speed_perimeter]->key)); } } @@ -2117,7 +2142,7 @@ void ObjectGridTable::reload_part_data(ObjectGridRow* volume_row, ObjectGridRow* volume_row->ori_enable_support = object_row->enable_support; volume_row->brim_type = *(get_volume_config_value>(global_config, object_row->config, volume_row->config, m_col_data[col_brim_type]->key)); volume_row->ori_brim_type = object_row->brim_type; - volume_row->speed_perimeter = *(get_volume_config_value(global_config, object_row->config, volume_row->config, m_col_data[col_speed_perimeter]->key)); + volume_row->speed_perimeter = *(get_volume_config_value(global_config, object_row->config, volume_row->config, m_col_data[col_speed_perimeter]->key)); volume_row->ori_speed_perimeter = object_row->speed_perimeter; } else if (category == L("Quality")) { @@ -2154,7 +2179,7 @@ void ObjectGridTable::reload_part_data(ObjectGridRow* volume_row, ObjectGridRow* volume_row->ori_brim_type = object_row->brim_type; } else if (category == L("Speed")) { - volume_row->speed_perimeter = *(get_volume_config_value(global_config, object_row->config, volume_row->config, m_col_data[col_speed_perimeter]->key)); + volume_row->speed_perimeter = *(get_volume_config_value(global_config, object_row->config, volume_row->config, m_col_data[col_speed_perimeter]->key)); if (volume_row->speed_perimeter == object_row->speed_perimeter) { volume_row->config->erase(m_col_data[col_speed_perimeter]->key); } @@ -2549,6 +2574,8 @@ bool ObjectGridTable::OnCellLeftClick(int row, int col, ConfigOptionType &type) void ObjectGridTable::OnSelectCell(int row, int col) { m_selected_cells.clear(); + if (!m_panel->m_side_window) + return; m_panel->m_side_window->Freeze(); if (row == 0 || col == col_filaments) { m_panel->m_object_settings->UpdateAndShow(row, false, false, false, nullptr, nullptr, std::string()); diff --git a/src/slic3r/GUI/GUI_ObjectTable.hpp b/src/slic3r/GUI/GUI_ObjectTable.hpp index a21436fe0e..a5a0059e1b 100644 --- a/src/slic3r/GUI/GUI_ObjectTable.hpp +++ b/src/slic3r/GUI/GUI_ObjectTable.hpp @@ -344,8 +344,8 @@ public: ConfigOptionBool ori_enable_support; ConfigOptionEnum brim_type; ConfigOptionEnum ori_brim_type; - ConfigOptionFloat speed_perimeter; - ConfigOptionFloat ori_speed_perimeter; + ConfigOptionFloatsNullable speed_perimeter; + ConfigOptionFloatsNullable ori_speed_perimeter; ModelConfig* config; ModelVolumeType model_volume_type;