mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-16 18:12:10 +00:00
NEW: Add tag for variable layer_height
jira: STUDIO-7412 Change-Id: I4b5c8e158b073b302db6faad77bb8ca0f70f766a (cherry picked from commit ffc34acf783aa1f6ac23f24a96fff30be90880d0) (cherry picked from commit 86a8e6c433799d931e441d5ea387702b03ff50f8)
This commit is contained in:
@@ -396,6 +396,7 @@ void ObjectList::create_objects_ctrl()
|
||||
|
||||
m_columns_width.resize(colCount);
|
||||
m_columns_width[colName] = 22;
|
||||
m_columns_width[colHeight] = 3;
|
||||
m_columns_width[colPrint] = 3;
|
||||
m_columns_width[colFilament] = 5;
|
||||
m_columns_width[colSupportPaint] = 3;
|
||||
@@ -417,6 +418,10 @@ void ObjectList::create_objects_ctrl()
|
||||
//name_col->SetBitmap(create_scaled_bitmap("organize", nullptr, FromDIP(18)));
|
||||
AppendColumn(name_col);
|
||||
|
||||
// column Variable height Property (Icon) of the view control:
|
||||
AppendBitmapColumn(" ", colHeight, wxOSX ? wxDATAVIEW_CELL_EDITABLE : wxDATAVIEW_CELL_INERT, 3 * em,
|
||||
wxALIGN_CENTER_HORIZONTAL, 0);
|
||||
|
||||
// column PrintableProperty (Icon) of the view control:
|
||||
AppendBitmapColumn(" ", colPrint, wxOSX ? wxDATAVIEW_CELL_EDITABLE : wxDATAVIEW_CELL_INERT, m_columns_width[colPrint]*em,
|
||||
wxALIGN_CENTER_HORIZONTAL, 0);
|
||||
@@ -1000,6 +1005,12 @@ void ObjectList::set_filament_column_hidden(const bool hide) const
|
||||
update_name_column_width();
|
||||
}
|
||||
|
||||
void ObjectList::set_variable_height_column_hidden(const bool hide) const
|
||||
{
|
||||
GetColumn(colHeight)->SetHidden(hide);
|
||||
update_name_column_width();
|
||||
}
|
||||
|
||||
// BBS
|
||||
void ObjectList::set_color_paint_hidden(const bool hide) const
|
||||
{
|
||||
@@ -1376,7 +1387,9 @@ void ObjectList::list_manipulation(const wxPoint& mouse_pos, bool evt_context_me
|
||||
{
|
||||
const wxString title = col->GetTitle();
|
||||
ColumnNumber col_num = (ColumnNumber)col->GetModelColumn();
|
||||
if (col_num == colPrint)
|
||||
if (col_num == colHeight)
|
||||
enable_layers_editing();
|
||||
else if (col_num == colPrint)
|
||||
toggle_printable_state();
|
||||
else if (col_num == colSupportPaint) {
|
||||
ObjectDataViewModelNode* node = (ObjectDataViewModelNode*)item.GetID();
|
||||
@@ -1509,7 +1522,7 @@ void ObjectList::extruder_editing()
|
||||
|
||||
wxPoint pos = this->get_mouse_position_in_control();
|
||||
wxSize size = wxSize(column_width, -1);
|
||||
pos.x = GetColumn(colName)->GetWidth() + GetColumn(colPrint)->GetWidth() + 5;
|
||||
pos.x = GetColumn(colName)->GetWidth() + GetColumn(colPrint)->GetWidth() + GetColumn(colHeight)->GetWidth() + 5;
|
||||
pos.y -= GetTextExtent("m").y;
|
||||
|
||||
apply_extruder_selector(&m_extruder_editor, this, "1", pos, size);
|
||||
@@ -3641,6 +3654,18 @@ wxDataViewItem ObjectList::add_settings_item(wxDataViewItem parent_item, const D
|
||||
#endif
|
||||
}
|
||||
|
||||
void ObjectList::update_variable_layer_obj_num(ObjectDataViewModelNode* obj_node, size_t layer_data_count) {
|
||||
if (obj_node){
|
||||
if (obj_node->IsVaribaleHeight() == hiVariable && layer_data_count <= 4){
|
||||
m_variable_layer_obj_num--;
|
||||
}
|
||||
else if (obj_node->IsVaribaleHeight() == hiUnVariable && layer_data_count > 4){
|
||||
m_variable_layer_obj_num++;
|
||||
}
|
||||
GetColumn(colHeight)->SetHidden(m_variable_layer_obj_num == 0);
|
||||
update_name_column_width();
|
||||
}
|
||||
}
|
||||
|
||||
void ObjectList::update_info_items(size_t obj_idx, wxDataViewItemArray* selections/* = nullptr*/, bool added_object/* = false*/)
|
||||
{
|
||||
@@ -3679,6 +3704,14 @@ void ObjectList::update_info_items(size_t obj_idx, wxDataViewItemArray* selectio
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
ObjectDataViewModelNode* obj_node = static_cast<ObjectDataViewModelNode*>(item_obj.GetID());
|
||||
auto layer_data_count = model_object->layer_height_profile.get().size();
|
||||
update_variable_layer_obj_num(obj_node, layer_data_count);
|
||||
// If the length of layer_height_profile is greater than 4, variable layer height is applied
|
||||
m_objects_model->SetObjectVariableHeightState(layer_data_count > 4 ? hiVariable : hiUnVariable, item_obj);
|
||||
}
|
||||
|
||||
{
|
||||
bool shows = m_objects_model->IsSupportPainted(item_obj);
|
||||
bool should_show = printer_technology() == ptFFF
|
||||
@@ -3841,6 +3874,8 @@ void ObjectList::add_object_to_list(size_t obj_idx, bool call_selection_changed,
|
||||
else
|
||||
m_objects_model->SetPrintableState(model_object->instances[0]->printable ? piPrintable : piUnprintable, obj_idx);
|
||||
|
||||
m_objects_model->SetObjectVariableHeightState(model_object->layer_height_profile.get().size() > 4 ? hiVariable : hiUnVariable, m_objects_model->GetItemById(obj_idx));
|
||||
|
||||
// add settings to the object, if it has those
|
||||
add_settings_item(item, &model_object->config.get());
|
||||
|
||||
@@ -3953,17 +3988,23 @@ void ObjectList::delete_instance_from_list(const size_t obj_idx, const size_t in
|
||||
|
||||
void ObjectList::delete_from_model_and_list(const ItemType type, const int obj_idx, const int sub_obj_idx)
|
||||
{
|
||||
if ( !(type&(itObject|itVolume|itInstance)) )
|
||||
if (!(type&(itObject|itVolume|itInstance)))
|
||||
return;
|
||||
|
||||
take_snapshot("Delete selected");
|
||||
|
||||
if (type&itObject) {
|
||||
bool was_cut = object(obj_idx)->is_cut();
|
||||
// For variable layer height, the size of layer data is larger than 4
|
||||
bool vari_layer_height = (object(obj_idx)->layer_height_profile.get().size() > 4);
|
||||
if (del_object(obj_idx)) {
|
||||
delete_object_from_list(obj_idx);
|
||||
if (was_cut)
|
||||
update_lock_icons_for_model();
|
||||
if (vari_layer_height) {
|
||||
m_variable_layer_obj_num--;
|
||||
set_variable_height_column_hidden(m_variable_layer_obj_num == 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -3992,11 +4033,17 @@ void ObjectList::delete_from_model_and_list(const std::vector<ItemForDelete>& it
|
||||
need_update = true;
|
||||
bool refresh_immediately = false;
|
||||
bool was_cut = object(item->obj_idx)->is_cut();
|
||||
// For variable layer height, the size of layer data is larger than 4
|
||||
bool vari_layer_height = (object(item->obj_idx)->layer_height_profile.get().size() > 4);
|
||||
if (!del_object(item->obj_idx, refresh_immediately))
|
||||
return;
|
||||
m_objects_model->Delete(m_objects_model->GetItemById(item->obj_idx));
|
||||
if (was_cut)
|
||||
update_lock_icons_for_model();
|
||||
if (vari_layer_height) {
|
||||
m_variable_layer_obj_num--;
|
||||
set_variable_height_column_hidden(m_variable_layer_obj_num == 0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!del_subobject_from_object(item->obj_idx, item->sub_obj_idx, item->type))
|
||||
|
||||
@@ -166,6 +166,7 @@ private:
|
||||
ObjectDataViewModel *m_objects_model{ nullptr };
|
||||
ModelConfig *m_config {nullptr};
|
||||
std::vector<ModelObject*> *m_objects{ nullptr };
|
||||
size_t m_variable_layer_obj_num = 0;
|
||||
|
||||
BitmapComboBox *m_extruder_editor { nullptr };
|
||||
|
||||
@@ -225,6 +226,8 @@ public:
|
||||
void update_filament_colors();
|
||||
// show/hide "Extruder" column for Objects List
|
||||
void set_filament_column_hidden(const bool hide) const;
|
||||
// show/hide variable height column for Objects List
|
||||
void set_variable_height_column_hidden(const bool hide) const;
|
||||
// BBS
|
||||
void set_color_paint_hidden(const bool hide) const;
|
||||
void set_support_paint_hidden(const bool hide) const;
|
||||
@@ -417,6 +420,7 @@ public:
|
||||
void update_settings_item_and_selection(wxDataViewItem item, wxDataViewItemArray& selections);
|
||||
void update_object_list_by_printer_technology();
|
||||
void update_info_items(size_t obj_idx, wxDataViewItemArray* selections = nullptr, bool added_object = false);
|
||||
void update_variable_layer_obj_num(ObjectDataViewModelNode* obj_node, size_t layer_data_count);
|
||||
|
||||
void instances_to_separated_object(const int obj_idx, const std::set<int>& inst_idx);
|
||||
void instances_to_separated_objects(const int obj_idx);
|
||||
@@ -441,6 +445,7 @@ public:
|
||||
//update printable state for item from objects model
|
||||
void update_printable_state(int obj_idx, int instance_idx);
|
||||
void toggle_printable_state();
|
||||
void enable_layers_editing();
|
||||
|
||||
//BBS: remove const qualifier
|
||||
void set_extruder_for_selected_items(const int extruder);
|
||||
|
||||
@@ -209,6 +209,13 @@ void ObjectDataViewModelNode::set_printable_icon(PrintIndicator printable)
|
||||
create_scaled_bitmap(m_printable == piPrintable ? "check_on" : "check_off_focused");
|
||||
}
|
||||
|
||||
void ObjectDataViewModelNode::set_variable_height_icon(VaryHeightIndicator vari_height) {
|
||||
if (m_variable_height == vari_height)
|
||||
return;
|
||||
m_variable_height = vari_height;
|
||||
m_variable_height_icon = m_variable_height == hiUnVariable ? m_empty_bmp : create_scaled_bitmap("toolbar_variable_layer_height", nullptr, 20);
|
||||
}
|
||||
|
||||
void ObjectDataViewModelNode::set_action_icon(bool enable)
|
||||
{
|
||||
if (m_action_enable == enable)
|
||||
@@ -306,6 +313,8 @@ void ObjectDataViewModelNode::msw_rescale()
|
||||
if (m_printable != piUndef)
|
||||
m_printable_icon = create_scaled_bitmap(m_printable == piPrintable ? "obj_printable" : "obj_unprintable");
|
||||
|
||||
m_variable_height_icon = m_variable_height == hiUnVariable ? m_empty_bmp : create_scaled_bitmap("toolbar_variable_layer_height", nullptr, 20);
|
||||
|
||||
if (!m_opt_categories.empty())
|
||||
update_settings_digest_bitmaps();
|
||||
|
||||
@@ -319,6 +328,9 @@ bool ObjectDataViewModelNode::SetValue(const wxVariant& variant, unsigned col)
|
||||
case colPrint:
|
||||
m_printable_icon << variant;
|
||||
return true;
|
||||
case colHeight:
|
||||
m_variable_height_icon << variant;
|
||||
return true;
|
||||
case colName: {
|
||||
DataViewBitmapText data;
|
||||
data << variant;
|
||||
@@ -871,6 +883,14 @@ bool ObjectDataViewModel::IsPrintable(const wxDataViewItem& item) const
|
||||
return node->IsPrintable() == piPrintable;
|
||||
}
|
||||
|
||||
bool ObjectDataViewModel::IsVariableHeight(const wxDataViewItem& item) const {
|
||||
ObjectDataViewModelNode* node = static_cast<ObjectDataViewModelNode*>(item.GetID());
|
||||
if (!node)
|
||||
return false;
|
||||
|
||||
return node->IsVaribaleHeight() == hiVariable;
|
||||
}
|
||||
|
||||
wxDataViewItem ObjectDataViewModel::AddLayersRoot(const wxDataViewItem &parent_item)
|
||||
{
|
||||
return AddRoot(parent_item, itLayerRoot);
|
||||
@@ -1751,6 +1771,9 @@ void ObjectDataViewModel::GetValue(wxVariant &variant, const wxDataViewItem &ite
|
||||
case colPrint:
|
||||
variant << node->m_printable_icon;
|
||||
break;
|
||||
case colHeight:
|
||||
variant << node->m_variable_height_icon;
|
||||
break;
|
||||
case colName:
|
||||
variant << DataViewBitmapText(node->m_name, node->m_bmp);
|
||||
break;
|
||||
@@ -2279,6 +2302,18 @@ wxDataViewItem ObjectDataViewModel::SetObjectPrintableState(
|
||||
return obj_item;
|
||||
}
|
||||
|
||||
// is the height is variable?
|
||||
wxDataViewItem ObjectDataViewModel::SetObjectVariableHeightState(VaryHeightIndicator vari_height, wxDataViewItem obj_item) {
|
||||
|
||||
ObjectDataViewModelNode* node = static_cast<ObjectDataViewModelNode*>(obj_item.GetID());
|
||||
if (!node)
|
||||
return wxDataViewItem(0);
|
||||
node->set_variable_height_icon(vari_height);
|
||||
ItemChanged(obj_item);
|
||||
|
||||
return obj_item;
|
||||
}
|
||||
|
||||
bool ObjectDataViewModel::IsColorPainted(wxDataViewItem& item) const
|
||||
{
|
||||
ObjectDataViewModelNode* node = static_cast<ObjectDataViewModelNode*>(item.GetID());
|
||||
|
||||
@@ -38,6 +38,7 @@ enum ItemType {
|
||||
enum ColumnNumber
|
||||
{
|
||||
colName = 0, // item name
|
||||
colHeight , // variable height
|
||||
colPrint , // printable property
|
||||
colFilament , // extruder selection
|
||||
// BBS
|
||||
@@ -55,6 +56,12 @@ enum PrintIndicator
|
||||
piUnprintable , // unprintable
|
||||
};
|
||||
|
||||
enum VaryHeightIndicator
|
||||
{
|
||||
hiUnVariable, // unvariable height
|
||||
hiVariable, // variable height
|
||||
};
|
||||
|
||||
enum class InfoItemType
|
||||
{
|
||||
Undef,
|
||||
@@ -94,6 +101,9 @@ class ObjectDataViewModelNode
|
||||
wxBitmap m_sinking_icon;
|
||||
PrintIndicator m_printable {piUndef};
|
||||
wxBitmap m_printable_icon;
|
||||
|
||||
VaryHeightIndicator m_variable_height{ hiUnVariable };
|
||||
wxBitmap m_variable_height_icon;
|
||||
std::string m_warning_icon_name{ "" };
|
||||
bool m_has_lock{false}; // for cut object icon
|
||||
|
||||
@@ -244,6 +254,7 @@ public:
|
||||
t_layer_height_range GetLayerRange() const { return m_layer_range; }
|
||||
wxString GetExtruder() { return m_extruder; }
|
||||
PrintIndicator IsPrintable() const { return m_printable; }
|
||||
VaryHeightIndicator IsVaribaleHeight() const { return m_variable_height; }
|
||||
// BBS
|
||||
bool HasColorPainting() const { return m_color_enable; }
|
||||
bool HasSupportPainting() const { return m_support_enable; }
|
||||
@@ -285,6 +296,7 @@ public:
|
||||
void set_extruder_icon();
|
||||
// Set printable icon for node
|
||||
void set_printable_icon(PrintIndicator printable);
|
||||
void set_variable_height_icon(VaryHeightIndicator vari_height);
|
||||
void set_action_icon(bool enable);
|
||||
// BBS
|
||||
void set_color_icon(bool enable);
|
||||
@@ -479,12 +491,15 @@ public:
|
||||
bool IsPrintable(const wxDataViewItem &item) const;
|
||||
void UpdateObjectPrintable(wxDataViewItem parent_item);
|
||||
void UpdateInstancesPrintable(wxDataViewItem parent_item);
|
||||
bool IsVariableHeight(const wxDataViewItem& item) const;
|
||||
|
||||
void SetVolumeType(const wxDataViewItem &item, const Slic3r::ModelVolumeType type);
|
||||
ModelVolumeType GetVolumeType(const wxDataViewItem &item);
|
||||
wxDataViewItem SetPrintableState( PrintIndicator printable, int obj_idx,
|
||||
int subobj_idx = -1,
|
||||
ItemType subobj_type = itInstance);
|
||||
wxDataViewItem SetObjectPrintableState(PrintIndicator printable, wxDataViewItem obj_item);
|
||||
wxDataViewItem SetObjectVariableHeightState(VaryHeightIndicator vari_height, wxDataViewItem obj_item);
|
||||
// BBS
|
||||
bool IsColorPainted(wxDataViewItem& item) const;
|
||||
bool IsSupportPainted(wxDataViewItem &item) const;
|
||||
|
||||
Reference in New Issue
Block a user