Merge branch 'dev' of https://github.com/prusa3d/Slic3r into dev

This commit is contained in:
Enrico Turri 2018-08-29 13:35:22 +02:00
commit 4c80a104f5
14 changed files with 56 additions and 64 deletions

View File

@ -136,7 +136,7 @@ sub new {
$_->set_scaling_factor($scale) for @{ $model_object->instances };
# Set object scale on c++ side
Slic3r::GUI::set_object_scale($obj_idx, $model_object->instances->[0]->scaling_factor * 100);
# Slic3r::GUI::set_object_scale($obj_idx, $model_object->instances->[0]->scaling_factor * 100);
# $object->transform_thumbnail($self->{model}, $obj_idx);
@ -1278,7 +1278,7 @@ sub changescale {
}
# Set object scale on c++ side
Slic3r::GUI::set_object_scale($obj_idx, $scale);
# Slic3r::GUI::set_object_scale($obj_idx, $scale);
$scale /= 100; # turn percent into factor
my $variation = $scale / $model_instance->scaling_factor;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 506 B

After

Width:  |  Height:  |  Size: 631 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 518 B

After

Width:  |  Height:  |  Size: 651 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 577 B

After

Width:  |  Height:  |  Size: 1001 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 528 B

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 508 B

After

Width:  |  Height:  |  Size: 997 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 483 B

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 521 B

After

Width:  |  Height:  |  Size: 654 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 517 B

After

Width:  |  Height:  |  Size: 650 B

View File

@ -226,7 +226,7 @@ wxDataViewColumn* object_ctrl_create_extruder_column(int extruders_count)
choices.Add(wxString::Format("%d", i));
wxDataViewChoiceRenderer *c =
new wxDataViewChoiceRenderer(choices, wxDATAVIEW_CELL_EDITABLE, wxALIGN_CENTER_HORIZONTAL);
wxDataViewColumn* column = new wxDataViewColumn(_(L("Extruder")), c, 3, 60, wxALIGN_CENTER_HORIZONTAL, wxDATAVIEW_COL_RESIZABLE);
wxDataViewColumn* column = new wxDataViewColumn(_(L("Extruder")), c, 2, 60, wxALIGN_CENTER_HORIZONTAL, wxDATAVIEW_COL_RESIZABLE);
return column;
}
@ -246,7 +246,7 @@ void create_objects_ctrl(wxWindow* win, wxBoxSizer*& objects_sz)
#endif // wxUSE_DRAG_AND_DROP && wxUSE_UNICODE
// column 0(Icon+Text) of the view control:
m_objects_ctrl->AppendIconTextColumn(_(L("Name")), 0, wxDATAVIEW_CELL_INERT, 120,
m_objects_ctrl->AppendIconTextColumn(_(L("Name")), 0, wxDATAVIEW_CELL_INERT, 200,
wxALIGN_LEFT, wxDATAVIEW_COL_RESIZABLE);
// column 1 of the view control:
@ -254,14 +254,10 @@ void create_objects_ctrl(wxWindow* win, wxBoxSizer*& objects_sz)
wxALIGN_CENTER_HORIZONTAL, wxDATAVIEW_COL_RESIZABLE);
// column 2 of the view control:
m_objects_ctrl->AppendTextColumn(_(L("Scale")), 2, wxDATAVIEW_CELL_INERT, 55,
wxALIGN_CENTER_HORIZONTAL, wxDATAVIEW_COL_RESIZABLE);
// column 3 of the view control:
m_objects_ctrl->AppendColumn(object_ctrl_create_extruder_column(4));
// column 4 of the view control:
m_objects_ctrl->AppendBitmapColumn(" ", 4, wxDATAVIEW_CELL_INERT, 25,
// column 3 of the view control:
m_objects_ctrl->AppendBitmapColumn(" ", 3, wxDATAVIEW_CELL_INERT, 25,
wxALIGN_CENTER_HORIZONTAL, wxDATAVIEW_COL_RESIZABLE);
}
@ -659,8 +655,7 @@ void show_collpane_settings(bool expert_mode)
void add_object_to_list(const std::string &name, ModelObject* model_object)
{
wxString item_name = name;
int scale = model_object->instances[0]->scaling_factor * 100;
auto item = m_objects_model->Add(item_name, model_object->instances.size(), scale);
auto item = m_objects_model->Add(item_name, model_object->instances.size());
m_objects_ctrl->Select(item);
// Add error icon if detected auto-repaire
@ -697,6 +692,8 @@ void delete_object_from_list()
// m_objects_ctrl->Select(m_objects_model->Delete(item));
m_objects_model->Delete(item);
part_selection_changed();
// if (m_objects_model->IsEmpty())
// m_collpane_settings->Show(false);
}
@ -704,6 +701,8 @@ void delete_object_from_list()
void delete_all_objects_from_list()
{
m_objects_model->DeleteAll();
part_selection_changed();
// m_collpane_settings->Show(false);
}
@ -713,12 +712,6 @@ void set_object_count(int idx, int count)
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()
{
if (!m_objects_ctrl->GetSelection())
@ -834,10 +827,10 @@ void object_ctrl_key_event(wxKeyEvent& event)
void object_ctrl_item_value_change(wxDataViewEvent& event)
{
if (event.GetColumn() == 3)
if (event.GetColumn() == 2)
{
wxVariant variant;
m_objects_model->GetValue(variant, event.GetItem(), 3);
m_objects_model->GetValue(variant, event.GetItem(), 2);
#ifdef __WXOSX__
g_selected_extruder = variant.GetString();
#else // --> for Linux
@ -930,8 +923,8 @@ void update_settings_list()
no_updates.reset(nullptr);
#endif
get_right_panel()->Layout();
get_right_panel()->GetParent()->Layout();
/*get_right_panel()*/parent->Layout();
get_right_panel()->GetParent()->GetParent()->Layout();
}
void get_settings_choice(wxMenu *menu, int id, bool is_part)
@ -1523,7 +1516,7 @@ void part_selection_changed()
void set_extruder_column_hidden(bool hide)
{
m_objects_ctrl->GetColumn(3)->SetHidden(hide);
m_objects_ctrl->GetColumn(2)->SetHidden(hide);
}
void update_extruder_in_config(const wxString& selection)
@ -1668,9 +1661,9 @@ void update_objects_list_extruder_column(int extruders_count)
extruders_count = 1;
// delete old 3rd column
m_objects_ctrl->DeleteColumn(m_objects_ctrl->GetColumn(3));
m_objects_ctrl->DeleteColumn(m_objects_ctrl->GetColumn(2));
// insert new created 3rd column
m_objects_ctrl->InsertColumn(3, object_ctrl_create_extruder_column(extruders_count));
m_objects_ctrl->InsertColumn(2, object_ctrl_create_extruder_column(extruders_count));
// set show/hide for this column
set_extruder_column_hidden(extruders_count <= 1);
}

View File

@ -9,6 +9,7 @@ class wxArrayString;
class wxMenu;
class wxDataViewEvent;
class wxKeyEvent;
class wxControl;
namespace Slic3r {
class ModelObject;
@ -61,8 +62,6 @@ void delete_object_from_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
@ -70,6 +69,8 @@ void select_current_object(int idx);
// Remove objects/sub-object from the list
void remove();
//void create_double_slider(wxWindow* parent, wxControl* slider);
void object_ctrl_selection_changed();
void object_ctrl_context_menu();
void object_ctrl_key_event(wxKeyEvent& event);

View File

@ -362,7 +362,7 @@ void PrusaObjectDataViewModelNode::set_part_action_icon() {
// PrusaObjectDataViewModel
// ----------------------------------------------------------------------------
wxDataViewItem PrusaObjectDataViewModel::Add(wxString &name)
wxDataViewItem PrusaObjectDataViewModel::Add(const wxString &name)
{
auto root = new PrusaObjectDataViewModelNode(name);
m_objects.push_back(root);
@ -373,9 +373,9 @@ wxDataViewItem PrusaObjectDataViewModel::Add(wxString &name)
return child;
}
wxDataViewItem PrusaObjectDataViewModel::Add(wxString &name, int instances_count, int scale)
wxDataViewItem PrusaObjectDataViewModel::Add(const wxString &name, const int instances_count/*, int scale*/)
{
auto root = new PrusaObjectDataViewModelNode(name, instances_count, scale);
auto root = new PrusaObjectDataViewModelNode(name, instances_count);
m_objects.push_back(root);
// notify control
wxDataViewItem child((void*)root);
@ -562,15 +562,6 @@ wxString PrusaObjectDataViewModel::GetCopy(const wxDataViewItem &item) const
return node->m_copy;
}
wxString PrusaObjectDataViewModel::GetScale(const wxDataViewItem &item) const
{
PrusaObjectDataViewModelNode *node = (PrusaObjectDataViewModelNode*)item.GetID();
if (!node) // happens if item.IsOk()==false
return wxEmptyString;
return node->m_scale;
}
wxIcon& PrusaObjectDataViewModel::GetIcon(const wxDataViewItem &item) const
{
PrusaObjectDataViewModelNode *node = (PrusaObjectDataViewModelNode*)item.GetID();
@ -592,12 +583,9 @@ void PrusaObjectDataViewModel::GetValue(wxVariant &variant, const wxDataViewItem
variant = node->m_copy;
break;
case 2:
variant = node->m_scale;
break;
case 3:
variant = node->m_extruder;
break;
case 4:
case 3:
variant << node->m_action_icon;
break;
default:
@ -750,8 +738,12 @@ unsigned int PrusaObjectDataViewModel::GetChildren(const wxDataViewItem &parent,
return count;
}
// ************************************** EXPERIMENTS ***************************************
PrusaDoubleSlider::PrusaDoubleSlider( wxWindow *parent,
// ----------------------------------------------------------------------------
// PrusaDoubleSlider
// ----------------------------------------------------------------------------
PrusaDoubleSlider::PrusaDoubleSlider(wxWindow *parent,
wxWindowID id,
int lowerValue,
int higherValue,
@ -1012,8 +1004,8 @@ wxString PrusaDoubleSlider::get_label(const SelectedSlider& selection) const
const wxString str = m_values.empty() ?
wxNumberFormatter::ToString(m_label_koef*value, 2, wxNumberFormatter::Style_None) :
wxNumberFormatter::ToString(m_values[value], 2, wxNumberFormatter::Style_None);
return wxString::Format("%s\n(%d)", str, value);
wxNumberFormatter::ToString(m_values[value].second, 2, wxNumberFormatter::Style_None);
return wxString::Format("%s\n(%d)", str, m_values.empty() ? value : m_values[value].first);
}
void PrusaDoubleSlider::draw_thumb_text(wxDC& dc, const wxPoint& pos, const SelectedSlider& selection) const
@ -1449,5 +1441,9 @@ void PrusaLockButton::enter_button(const bool enter)
Update();
}
// ************************************** EXPERIMENTS ***************************************
// *****************************************************************************

View File

@ -157,11 +157,10 @@ class PrusaObjectDataViewModelNode
MyObjectTreeModelNodePtrArray m_children;
wxIcon m_empty_icon;
public:
PrusaObjectDataViewModelNode(const wxString &name, int instances_count=1, int scale=100) {
PrusaObjectDataViewModelNode(const wxString &name, const int instances_count=1) {
m_parent = NULL;
m_name = name;
m_copy = wxString::Format("%d", instances_count);
m_scale = wxString::Format("%d%%", scale);
m_type = "object";
m_volume_id = -1;
#ifdef __WXGTK__
@ -181,7 +180,6 @@ public:
m_parent = parent;
m_name = sub_obj_name;
m_copy = wxEmptyString;
m_scale = wxEmptyString;
m_icon = icon;
m_type = "volume";
m_volume_id = volume_id;
@ -203,7 +201,6 @@ public:
wxString m_name;
wxIcon& m_icon = m_empty_icon;
wxString m_copy;
wxString m_scale;
std::string m_type;
int m_volume_id;
bool m_container = false;
@ -270,12 +267,9 @@ public:
m_copy = variant.GetString();
return true;
case 2:
m_scale = variant.GetString();
return true;
case 3:
m_extruder = variant.GetString();
return true;
case 4:
case 3:
m_action_icon << variant;
return true;
default:
@ -349,8 +343,8 @@ public:
delete object;
}
wxDataViewItem Add(wxString &name);
wxDataViewItem Add(wxString &name, int instances_count, int scale);
wxDataViewItem Add(const wxString &name);
wxDataViewItem Add(const wxString &name, const int instances_count);
wxDataViewItem AddChild(const wxDataViewItem &parent_item,
const wxString &name,
const wxIcon& icon,
@ -368,7 +362,6 @@ public:
wxString GetName(const wxDataViewItem &item) const;
wxString GetCopy(const wxDataViewItem &item) const;
wxString GetScale(const wxDataViewItem &item) const;
wxIcon& GetIcon(const wxDataViewItem &item) const;
// helper methods to change the model
@ -495,7 +488,12 @@ public:
private:
wxString m_value;
};
// ******************************* EXPERIMENTS **********************************************
// ----------------------------------------------------------------------------
// PrusaDoubleSlider
// ----------------------------------------------------------------------------
enum SelectedSlider {
ssUndef,
ssLower,
@ -537,7 +535,7 @@ public:
void SetKoefForLabels(const double koef) {
m_label_koef = koef;
}
void SetSliderValues(const std::vector<double>& values) {
void SetSliderValues(const std::vector<std::pair<int, double>>& values) {
m_values = values;
}
@ -633,7 +631,7 @@ private:
std::vector<wxPen*> line_pens;
std::vector<wxPen*> segm_pens;
std::set<int> m_ticks;
std::vector<double> m_values;
std::vector<std::pair<int,double>> m_values;
};
@ -670,6 +668,9 @@ private:
int m_lock_icon_dim;
};
// ******************************* EXPERIMENTS **********************************************
// ******************************************************************************************

View File

@ -146,9 +146,6 @@ void 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(); %};
@ -185,3 +182,7 @@ void register_on_request_update_callback(SV* callback)
void deregister_on_request_update_callback()
%code%{ Slic3r::GUI::g_on_request_update_callback.deregister_callback(); %};
//void create_double_slider(SV *ui_parent, SV *ui_ds)
// %code%{ Slic3r::GUI::create_double_slider( (wxWindow*)wxPli_sv_2_object(aTHX_ ui_parent, "Wx::Window"),
// (wxControl*)wxPli_sv_2_object(aTHX_ ui_ds, "Wx::Control")); %};