mirror of
https://git.mirrors.martin98.com/https://github.com/bambulab/BambuStudio.git
synced 2025-08-06 08:36:08 +08:00
NEW: Add tag for variable layer_height
jira: STUDIO-7412 Change-Id: I4b5c8e158b073b302db6faad77bb8ca0f70f766a (cherry picked from commit ffc34acf783aa1f6ac23f24a96fff30be90880d0)
This commit is contained in:
parent
fd9767eb4f
commit
86a8e6c433
@ -367,6 +367,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;
|
||||
@ -388,6 +389,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, 3*em,
|
||||
wxALIGN_CENTER_HORIZONTAL, 0);
|
||||
@ -867,6 +872,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
|
||||
{
|
||||
@ -1241,7 +1252,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();
|
||||
@ -1373,7 +1386,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);
|
||||
@ -3548,6 +3561,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*/)
|
||||
{
|
||||
@ -3586,6 +3611,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
|
||||
@ -3748,6 +3781,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());
|
||||
|
||||
@ -3858,17 +3893,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 {
|
||||
@ -3897,11 +3938,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))
|
||||
@ -5540,6 +5587,7 @@ void ObjectList::msw_rescale()
|
||||
const int em = wxGetApp().em_unit();
|
||||
|
||||
GetColumn(colName )->SetWidth(20 * em);
|
||||
GetColumn(colHeight)->SetWidth(3 * em);
|
||||
GetColumn(colPrint )->SetWidth( 3 * em);
|
||||
GetColumn(colFilament)->SetWidth( 5 * em);
|
||||
// BBS
|
||||
@ -5957,6 +6005,26 @@ void ObjectList::toggle_printable_state()
|
||||
wxGetApp().plater()->reload_paint_after_background_process_apply();
|
||||
}
|
||||
|
||||
void ObjectList::enable_layers_editing()
|
||||
{
|
||||
wxDataViewItemArray sels;
|
||||
GetSelections(sels);
|
||||
if (sels.IsEmpty())
|
||||
return;
|
||||
|
||||
wxDataViewItem frst_item = sels[0];
|
||||
|
||||
ItemType type = m_objects_model->GetItemType(frst_item);
|
||||
if (!(type & itObject))
|
||||
return;
|
||||
//take_snapshot("");
|
||||
|
||||
auto view3d = wxGetApp().plater()->get_view3D_canvas3D();
|
||||
if (view3d != nullptr && m_objects_model->IsVariableHeight(frst_item)){
|
||||
view3d->enable_layers_editing(true);
|
||||
}
|
||||
}
|
||||
|
||||
ModelObject* ObjectList::object(const int obj_idx) const
|
||||
{
|
||||
if (obj_idx < 0)
|
||||
|
@ -167,6 +167,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 };
|
||||
|
||||
@ -224,6 +225,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;
|
||||
@ -416,6 +419,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);
|
||||
@ -440,6 +444,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);
|
||||
|
@ -203,6 +203,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)
|
||||
@ -300,6 +307,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();
|
||||
|
||||
@ -313,6 +322,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;
|
||||
@ -849,6 +861,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);
|
||||
@ -1729,6 +1749,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;
|
||||
@ -2257,6 +2280,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());
|
||||
|
@ -39,6 +39,7 @@ enum ItemType {
|
||||
enum ColumnNumber
|
||||
{
|
||||
colName = 0, // item name
|
||||
colHeight , // variable height
|
||||
colPrint , // printable property
|
||||
colFilament , // extruder selection
|
||||
// BBS
|
||||
@ -56,6 +57,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
|
||||
|
||||
@ -242,6 +252,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; }
|
||||
@ -283,6 +294,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);
|
||||
@ -471,12 +483,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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user