Porting object list manipulation from Perl to c++:
* Set count and scale to the objects on c++ side * Select/unselect object
This commit is contained in:
parent
dcf0b432cb
commit
5f82d01f19
@ -949,6 +949,8 @@ sub increase {
|
||||
$self->{print}->objects->[$obj_idx]->add_copy($instance->offset);
|
||||
}
|
||||
$self->{list}->SetItem($obj_idx, 1, $model_object->instances_count);
|
||||
# Set conut of object on c++ side
|
||||
Slic3r::GUI::set_object_count($obj_idx, $model_object->instances_count);
|
||||
|
||||
# only autoarrange if user has autocentering enabled
|
||||
$self->stop_background_process;
|
||||
@ -975,6 +977,8 @@ sub decrease {
|
||||
$self->{print}->objects->[$obj_idx]->delete_last_copy;
|
||||
}
|
||||
$self->{list}->SetItem($obj_idx, 1, $model_object->instances_count);
|
||||
# Set conut of object on c++ side
|
||||
Slic3r::GUI::set_object_count($obj_idx, $model_object->instances_count);
|
||||
} elsif (defined $copies_asked) {
|
||||
# The "decrease" came from the "set number of copies" dialog.
|
||||
$self->remove;
|
||||
@ -1168,6 +1172,8 @@ sub changescale {
|
||||
}
|
||||
|
||||
$self->{list}->SetItem($obj_idx, 2, "$scale%");
|
||||
# Set object scale on c++ side
|
||||
Slic3r::GUI::set_object_scale($obj_idx, $scale);
|
||||
$scale /= 100; # turn percent into factor
|
||||
|
||||
my $variation = $scale / $model_instance->scaling_factor;
|
||||
@ -2096,6 +2102,9 @@ sub select_object {
|
||||
$self->{list}->Select($o, 0);
|
||||
$PreventListEvents = 0;
|
||||
}
|
||||
|
||||
# Unselect all objects in the list on c++ side
|
||||
Slic3r::GUI::unselect_objects();
|
||||
|
||||
if (defined $obj_idx) {
|
||||
$self->{objects}->[$obj_idx]->selected(1);
|
||||
@ -2105,6 +2114,8 @@ sub select_object {
|
||||
$PreventListEvents = 1;
|
||||
$self->{list}->Select($obj_idx, 1);
|
||||
$PreventListEvents = 0;
|
||||
# Select current object in the list on c++ side
|
||||
Slic3r::GUI::select_current_object($obj_idx);
|
||||
} else {
|
||||
# TODO: deselect all in list
|
||||
}
|
||||
|
@ -1071,6 +1071,28 @@ void delete_all_objects_from_list()
|
||||
m_collpane_settings->Show(false);
|
||||
}
|
||||
|
||||
void set_object_count(int idx, int count)
|
||||
{
|
||||
m_objects_model->SetValue(wxString::Format("%d", count), idx, 1);
|
||||
m_objects_ctrl->Refresh();
|
||||
}
|
||||
|
||||
void set_object_scale(int idx, int scale)
|
||||
{
|
||||
m_objects_model->SetValue(wxString::Format("%d%%", scale), idx, 2);
|
||||
m_objects_ctrl->Refresh();
|
||||
}
|
||||
|
||||
void unselect_objects()
|
||||
{
|
||||
m_objects_ctrl->UnselectAll();
|
||||
}
|
||||
|
||||
void select_current_object(int idx)
|
||||
{
|
||||
m_objects_ctrl->Select(m_objects_model->GetItemById(idx));
|
||||
}
|
||||
|
||||
void add_expert_mode_part(wxWindow* parent, wxBoxSizer* sizer)
|
||||
{
|
||||
wxWindowUpdateLocker noUpdates(parent);
|
||||
|
@ -181,6 +181,14 @@ void add_object_to_list(const std::string &name, int instances_count=1, int scal
|
||||
void delete_object_from_list();
|
||||
// Delete all objects from the list
|
||||
void delete_all_objects_from_list();
|
||||
// Set count of object on c++ side
|
||||
void set_object_count(int idx, int count);
|
||||
// Set object scale on c++ side
|
||||
void set_object_scale(int idx, int scale);
|
||||
// Unselect all objects in the list on c++ side
|
||||
void unselect_objects();
|
||||
// Select current object in the list on c++ side
|
||||
void select_current_object(int idx);
|
||||
|
||||
void add_expert_mode_part(wxWindow* parent, wxBoxSizer* sizer);
|
||||
void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFlexGridSizer* preset_sizer);
|
||||
|
@ -505,22 +505,7 @@ bool MyObjectTreeModel::SetValue(const wxVariant &variant, const wxDataViewItem
|
||||
wxASSERT(item.IsOk());
|
||||
|
||||
MyObjectTreeModelNode *node = (MyObjectTreeModelNode*)item.GetID();
|
||||
switch (col)
|
||||
{
|
||||
case 0:
|
||||
node->m_name = variant.GetString();
|
||||
return true;
|
||||
case 1:
|
||||
node->m_copy = variant.GetString();
|
||||
return true;
|
||||
case 2:
|
||||
node->m_scale = variant.GetString();
|
||||
return true;
|
||||
|
||||
default:;
|
||||
// wxLogError("MyObjectTreeModel::SetValue: wrong column");
|
||||
}
|
||||
return false;
|
||||
return node->SetValue(variant, col);
|
||||
}
|
||||
|
||||
bool MyObjectTreeModel::SetValue(const wxVariant &variant, const int item_idx, unsigned int col)
|
||||
|
@ -131,6 +131,18 @@ void delete_object_from_list()
|
||||
void delete_all_objects_from_list()
|
||||
%code%{ Slic3r::GUI::delete_all_objects_from_list(); %};
|
||||
|
||||
void set_object_count(int idx, int count)
|
||||
%code%{ Slic3r::GUI::set_object_count(idx, count); %};
|
||||
|
||||
void set_object_scale(int idx, int scale)
|
||||
%code%{ Slic3r::GUI::set_object_scale(idx, scale); %};
|
||||
|
||||
void unselect_objects()
|
||||
%code%{ Slic3r::GUI::unselect_objects(); %};
|
||||
|
||||
void select_current_object(int idx)
|
||||
%code%{ Slic3r::GUI::select_current_object(idx); %};
|
||||
|
||||
std::string fold_utf8_to_ascii(const char *src)
|
||||
%code%{ RETVAL = Slic3r::fold_utf8_to_ascii(src); %};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user