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

This commit is contained in:
Enrico Turri 2018-03-06 08:36:37 +01:00
commit a600dbc06c
25 changed files with 20541 additions and 4959 deletions

View File

@ -31,6 +31,8 @@ use Slic3r::GUI::OptionsGroup;
use Slic3r::GUI::OptionsGroup::Field; use Slic3r::GUI::OptionsGroup::Field;
use Slic3r::GUI::SystemInfo; use Slic3r::GUI::SystemInfo;
use Wx::Locale gettext => 'L';
our $have_OpenGL = eval "use Slic3r::GUI::3DScene; 1"; our $have_OpenGL = eval "use Slic3r::GUI::3DScene; 1";
our $have_LWP = eval "use LWP::UserAgent; 1"; our $have_LWP = eval "use LWP::UserAgent; 1";
@ -280,8 +282,9 @@ sub update_ui_from_settings {
sub open_model { sub open_model {
my ($self, $window) = @_; my ($self, $window) = @_;
my $dialog = Wx::FileDialog->new($window // $self->GetTopWindow, 'Choose one or more files (STL/OBJ/AMF/PRUSA):', my $dlg_title = L('Choose one or more files (STL/OBJ/AMF/3MF/PRUSA):');
my $dialog = Wx::FileDialog->new($window // $self->GetTopWindow, $dlg_title,
$self->{app_config}->get_last_dir, "", $self->{app_config}->get_last_dir, "",
MODEL_WILDCARD, wxFD_OPEN | wxFD_MULTIPLE | wxFD_FILE_MUST_EXIST); MODEL_WILDCARD, wxFD_OPEN | wxFD_MULTIPLE | wxFD_FILE_MUST_EXIST);
if ($dialog->ShowModal != wxID_OK) { if ($dialog->ShowModal != wxID_OK) {

View File

@ -13,6 +13,8 @@ use Wx qw(wxTheApp :misc :pen :brush :sizer :font :cursor wxTAB_TRAVERSAL);
use Wx::Event qw(EVT_MOUSE_EVENTS EVT_PAINT EVT_ERASE_BACKGROUND EVT_SIZE); use Wx::Event qw(EVT_MOUSE_EVENTS EVT_PAINT EVT_ERASE_BACKGROUND EVT_SIZE);
use base 'Wx::Panel'; use base 'Wx::Panel';
use Wx::Locale gettext => 'L';
sub new { sub new {
my $class = shift; my $class = shift;
my ($parent, $size, $objects, $model, $config) = @_; my ($parent, $size, $objects, $model, $config) = @_;
@ -126,8 +128,8 @@ sub repaint {
$dc->SetFont(Wx::Font->new(14, wxDEFAULT, wxNORMAL, wxNORMAL)); $dc->SetFont(Wx::Font->new(14, wxDEFAULT, wxNORMAL, wxNORMAL));
$dc->DrawLabel( $dc->DrawLabel(
join('-', +(localtime)[3,4]) eq '13-8' join('-', +(localtime)[3,4]) eq '13-8'
? 'What do you want to print today? ™' # Sept. 13, 2006. The first part ever printed by a RepRap to make another RepRap. ? L('What do you want to print today? ™') # Sept. 13, 2006. The first part ever printed by a RepRap to make another RepRap.
: 'Drag your objects here', : L('Drag your objects here'),
Wx::Rect->new(0, 0, $self->GetSize->GetWidth, $self->GetSize->GetHeight), wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL); Wx::Rect->new(0, 0, $self->GetSize->GetWidth, $self->GetSize->GetHeight), wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL);
} }

View File

@ -8,6 +8,8 @@ use Wx qw(:misc :sizer :slider :statictext :keycode wxWHITE wxCB_READONLY);
use Wx::Event qw(EVT_SLIDER EVT_KEY_DOWN EVT_CHECKBOX EVT_CHOICE EVT_CHECKLISTBOX); use Wx::Event qw(EVT_SLIDER EVT_KEY_DOWN EVT_CHECKBOX EVT_CHOICE EVT_CHECKLISTBOX);
use base qw(Wx::Panel Class::Accessor); use base qw(Wx::Panel Class::Accessor);
use Wx::Locale gettext => 'L';
__PACKAGE__->mk_accessors(qw(print gcode_preview_data enabled _loaded canvas slider_low slider_high single_layer auto_zoom)); __PACKAGE__->mk_accessors(qw(print gcode_preview_data enabled _loaded canvas slider_low slider_high single_layer auto_zoom));
sub new { sub new {
@ -58,30 +60,42 @@ sub new {
$z_label_high->SetFont($Slic3r::GUI::small_font); $z_label_high->SetFont($Slic3r::GUI::small_font);
$self->single_layer(0); $self->single_layer(0);
my $checkbox_singlelayer = $self->{checkbox_singlelayer} = Wx::CheckBox->new($self, -1, "1 Layer"); my $checkbox_singlelayer = $self->{checkbox_singlelayer} = Wx::CheckBox->new($self, -1, L("1 Layer"));
my $label_view_type = $self->{label_view_type} = Wx::StaticText->new($self, -1, "View"); my $label_view_type = $self->{label_view_type} = Wx::StaticText->new($self, -1, L("View"));
my $choice_view_type = $self->{choice_view_type} = Wx::Choice->new($self, -1); my $choice_view_type = $self->{choice_view_type} = Wx::Choice->new($self, -1);
$choice_view_type->Append("Feature type"); $choice_view_type->Append(L("Feature type"));
$choice_view_type->Append("Height"); $choice_view_type->Append(L("Height"));
$choice_view_type->Append("Width"); $choice_view_type->Append(L("Width"));
$choice_view_type->Append("Speed"); $choice_view_type->Append(L("Speed"));
$choice_view_type->Append("Tool"); $choice_view_type->Append(L("Tool"));
$choice_view_type->SetSelection(0); $choice_view_type->SetSelection(0);
my $label_show_features = $self->{label_show_features} = Wx::StaticText->new($self, -1, "Show"); my $label_show_features = $self->{label_show_features} = Wx::StaticText->new($self, -1, L("Show"));
my $combochecklist_features = $self->{combochecklist_features} = Wx::ComboCtrl->new(); my $combochecklist_features = $self->{combochecklist_features} = Wx::ComboCtrl->new();
$combochecklist_features->Create($self, -1, "Feature types", wxDefaultPosition, [200, -1], wxCB_READONLY); $combochecklist_features->Create($self, -1, L("Feature types"), wxDefaultPosition, [200, -1], wxCB_READONLY);
my $feature_text = "Feature types"; my $feature_text = L("Feature types");
my $feature_items = "Perimeter|External perimeter|Overhang perimeter|Internal infill|Solid infill|Top solid infill|Bridge infill|Gap fill|Skirt|Support material|Support material interface|Wipe tower|Custom"; my $feature_items = L("Perimeter")."|"
.L("External perimeter")."|"
.L("Overhang perimeter")."|"
.L("Internal infill")."|"
.L("Solid infill")."|"
.L("Top solid infill")."|"
.L("Bridge infill")."|"
.L("Gap fill")."|"
.L("Skirt")."|"
.L("Support material")."|"
.L("Support material interface")."|"
.L("Wipe tower")."|"
.L("Custom");
Slic3r::GUI::create_combochecklist($combochecklist_features, $feature_text, $feature_items, 1); Slic3r::GUI::create_combochecklist($combochecklist_features, $feature_text, $feature_items, 1);
my $checkbox_travel = $self->{checkbox_travel} = Wx::CheckBox->new($self, -1, "Travel"); my $checkbox_travel = $self->{checkbox_travel} = Wx::CheckBox->new($self, -1, L("Travel"));
my $checkbox_retractions = $self->{checkbox_retractions} = Wx::CheckBox->new($self, -1, "Retractions"); my $checkbox_retractions = $self->{checkbox_retractions} = Wx::CheckBox->new($self, -1, L("Retractions"));
my $checkbox_unretractions = $self->{checkbox_unretractions} = Wx::CheckBox->new($self, -1, "Unretractions"); my $checkbox_unretractions = $self->{checkbox_unretractions} = Wx::CheckBox->new($self, -1, L("Unretractions"));
my $checkbox_shells = $self->{checkbox_shells} = Wx::CheckBox->new($self, -1, "Shells"); my $checkbox_shells = $self->{checkbox_shells} = Wx::CheckBox->new($self, -1, L("Shells"));
my $hsizer = Wx::BoxSizer->new(wxHORIZONTAL); my $hsizer = Wx::BoxSizer->new(wxHORIZONTAL);
my $vsizer = Wx::BoxSizer->new(wxVERTICAL); my $vsizer = Wx::BoxSizer->new(wxVERTICAL);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -10,5 +10,9 @@ c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp
c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.hpp c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.hpp
c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp
C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp
c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp
c:\src\Slic3r\lib\Slic3r\GUI.pm
c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm
c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm
c:\src\Slic3r\lib\Slic3r\GUI\Plater\2D.pm
c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,8 @@
#include "Analyzer.hpp" #include "Analyzer.hpp"
#include "PreviewData.hpp" #include "PreviewData.hpp"
#include <float.h> #include <float.h>
#include <wx/intl.h>
#include "slic3r/GUI/GUI.hpp"
namespace Slic3r { namespace Slic3r {
@ -132,21 +134,21 @@ const GCodePreviewData::Color GCodePreviewData::Extrusion::Default_Extrusion_Rol
// todo: merge with Slic3r::ExtrusionRole2String() from GCode.cpp // todo: merge with Slic3r::ExtrusionRole2String() from GCode.cpp
const std::string GCodePreviewData::Extrusion::Default_Extrusion_Role_Names[Num_Extrusion_Roles] const std::string GCodePreviewData::Extrusion::Default_Extrusion_Role_Names[Num_Extrusion_Roles]
{ {
"None", L("None"),
"Perimeter", L("Perimeter"),
"External perimeter", L("External perimeter"),
"Overhang perimeter", L("Overhang perimeter"),
"Internal infill", L("Internal infill"),
"Solid infill", L("Solid infill"),
"Top solid infill", L("Top solid infill"),
"Bridge infill", L("Bridge infill"),
"Gap fill", L("Gap fill"),
"Skirt", L("Skirt"),
"Support material", L("Support material"),
"Support material interface", L("Support material interface"),
"Wipe tower", L("Wipe tower"),
"Custom", L("Custom"),
"Mixed" L("Mixed")
}; };
const GCodePreviewData::Extrusion::EViewType GCodePreviewData::Extrusion::Default_View_Type = GCodePreviewData::Extrusion::FeatureType; const GCodePreviewData::Extrusion::EViewType GCodePreviewData::Extrusion::Default_View_Type = GCodePreviewData::Extrusion::FeatureType;
@ -325,15 +327,15 @@ std::string GCodePreviewData::get_legend_title() const
switch (extrusion.view_type) switch (extrusion.view_type)
{ {
case Extrusion::FeatureType: case Extrusion::FeatureType:
return "Feature type"; return L("Feature type");
case Extrusion::Height: case Extrusion::Height:
return "Height (mm)"; return L("Height (mm)");
case Extrusion::Width: case Extrusion::Width:
return "Width (mm)"; return L("Width (mm)");
case Extrusion::Feedrate: case Extrusion::Feedrate:
return "Speed (mm/s)"; return L("Speed (mm/s)");
case Extrusion::Tool: case Extrusion::Tool:
return "Tool"; return L("Tool");
} }
return ""; return "";
@ -368,7 +370,7 @@ GCodePreviewData::LegendItemsList GCodePreviewData::get_legend_items(const std::
items.reserve(last_valid - first_valid + 1); items.reserve(last_valid - first_valid + 1);
for (unsigned int i = (unsigned int)first_valid; i <= (unsigned int)last_valid; ++i) for (unsigned int i = (unsigned int)first_valid; i <= (unsigned int)last_valid; ++i)
{ {
items.emplace_back(extrusion.role_names[i], extrusion.role_colors[i]); items.emplace_back(_CHB(extrusion.role_names[i].c_str()).data(), extrusion.role_colors[i]);
} }
break; break;
@ -394,8 +396,8 @@ GCodePreviewData::LegendItemsList GCodePreviewData::get_legend_items(const std::
items.reserve(tools_colors_count); items.reserve(tools_colors_count);
for (unsigned int i = 0; i < tools_colors_count; ++i) for (unsigned int i = 0; i < tools_colors_count; ++i)
{ {
char buf[32]; char buf[MIN_BUF_LENGTH_FOR_L];
sprintf(buf, "Extruder %d", i + 1); sprintf(buf, _CHB(L("Extruder %d")), i + 1);
GCodePreviewData::Color color; GCodePreviewData::Color color;
::memcpy((void*)color.rgba, (const void*)(tool_colors.data() + i * 4), 4 * sizeof(float)); ::memcpy((void*)color.rgba, (const void*)(tool_colors.data() + i * 4), 4 * sizeof(float));

View File

@ -27,6 +27,8 @@
#include <wx/image.h> #include <wx/image.h>
#include <wx/settings.h> #include <wx/settings.h>
#include "GUI.hpp"
namespace Slic3r { namespace Slic3r {
void GLIndexedVertexArray::load_mesh_flat_shading(const TriangleMesh &mesh) void GLIndexedVertexArray::load_mesh_flat_shading(const TriangleMesh &mesh)
@ -1144,7 +1146,7 @@ bool _3DScene::LegendTexture::generate(const GCodePreviewData& preview_data, con
m_data.clear(); m_data.clear();
// collects items to render // collects items to render
const std::string& title = preview_data.get_legend_title(); auto title = GUI::L_str(preview_data.get_legend_title());
const GCodePreviewData::LegendItemsList& items = preview_data.get_legend_items(tool_colors); const GCodePreviewData::LegendItemsList& items = preview_data.get_legend_items(tool_colors);
unsigned int items_count = (unsigned int)items.size(); unsigned int items_count = (unsigned int)items.size();
@ -1166,7 +1168,7 @@ bool _3DScene::LegendTexture::generate(const GCodePreviewData& preview_data, con
unsigned int max_text_height = 0; unsigned int max_text_height = 0;
for (const GCodePreviewData::LegendItem& item : items) for (const GCodePreviewData::LegendItem& item : items)
{ {
memDC.GetTextExtent(item.text, &w, &h); memDC.GetTextExtent(GUI::from_u8(item.text), &w, &h);
max_text_width = std::max(max_text_width, (unsigned int)w); max_text_width = std::max(max_text_width, (unsigned int)w);
max_text_height = std::max(max_text_height, (unsigned int)h); max_text_height = std::max(max_text_height, (unsigned int)h);
} }
@ -1243,7 +1245,7 @@ bool _3DScene::LegendTexture::generate(const GCodePreviewData& preview_data, con
memDC.DrawRectangle(wxRect(icon_x_inner, icon_y + 1, px_inner_square, px_inner_square)); memDC.DrawRectangle(wxRect(icon_x_inner, icon_y + 1, px_inner_square, px_inner_square));
// draw text // draw text
memDC.DrawText(item.text, text_x, icon_y + text_y_offset); memDC.DrawText(GUI::from_u8(item.text), text_x, icon_y + text_y_offset);
// update y // update y
icon_y += icon_y_step; icon_y += icon_y_step;

View File

@ -23,8 +23,7 @@ namespace Slic3r { namespace GUI {
// Also, docs for wxEvent::Skip() say "In general, it is recommended to skip all // Also, docs for wxEvent::Skip() say "In general, it is recommended to skip all
// non-command events to allow the default handling to take place." // non-command events to allow the default handling to take place."
event.Skip(); event.Skip();
std::cerr << "calling Field::on_kill_focus from " << m_opt_id<< "\n"; // call the registered function if it is available
// call the registered function if it is available
if (m_on_kill_focus!=nullptr) if (m_on_kill_focus!=nullptr)
m_on_kill_focus(); m_on_kill_focus();
} }

View File

@ -336,7 +336,7 @@ void add_debug_menu(wxMenuBar *menu, int event_language_change)
} }
} }
}); });
menu->Append(local_menu, _T("&Localization")); menu->Append(local_menu, _(L("&Localization")));
//#endif //#endif
} }
@ -405,11 +405,15 @@ void change_opt_value(DynamicPrintConfig& config, t_config_option_key opt_key, b
val = boost::any_cast<double>(value); val = boost::any_cast<double>(value);
break; break;
} }
case coPercents: case coPercents:{
case coFloats:{ ConfigOptionPercents* vec_new = new ConfigOptionPercents{ boost::any_cast<double>(value) };
double& val = config.opt_float(opt_key, 0); config.option<ConfigOptionPercents>(opt_key)->set_at(vec_new, opt_index, opt_index);
val = boost::any_cast<double>(value);
break; break;
}
case coFloats:{
ConfigOptionFloats* vec_new = new ConfigOptionFloats{ boost::any_cast<double>(value) };
config.option<ConfigOptionFloats>(opt_key)->set_at(vec_new, opt_index, opt_index);
break;
} }
case coString: case coString:
config.set_key_value(opt_key, new ConfigOptionString(boost::any_cast<std::string>(value))); config.set_key_value(opt_key, new ConfigOptionString(boost::any_cast<std::string>(value)));
@ -422,7 +426,7 @@ void change_opt_value(DynamicPrintConfig& config, t_config_option_key opt_key, b
} }
else{ else{
ConfigOptionStrings* vec_new = new ConfigOptionStrings{ boost::any_cast<std::string>(value) }; ConfigOptionStrings* vec_new = new ConfigOptionStrings{ boost::any_cast<std::string>(value) };
config.option<ConfigOptionStrings>(opt_key)->set_at(vec_new, opt_index, opt_index); config.option<ConfigOptionStrings>(opt_key)->set_at(vec_new, opt_index, 0);
} }
} }
break; break;
@ -431,14 +435,14 @@ void change_opt_value(DynamicPrintConfig& config, t_config_option_key opt_key, b
break; break;
case coBools:{ case coBools:{
ConfigOptionBools* vec_new = new ConfigOptionBools{ boost::any_cast<bool>(value) }; ConfigOptionBools* vec_new = new ConfigOptionBools{ boost::any_cast<bool>(value) };
config.option<ConfigOptionBools>(opt_key)->set_at(vec_new, opt_index, opt_index); config.option<ConfigOptionBools>(opt_key)->set_at(vec_new, opt_index, 0);
break;} break;}
case coInt: case coInt:
config.set_key_value(opt_key, new ConfigOptionInt(boost::any_cast<int>(value))); config.set_key_value(opt_key, new ConfigOptionInt(boost::any_cast<int>(value)));
break; break;
case coInts:{ case coInts:{
ConfigOptionInts* vec_new = new ConfigOptionInts{ boost::any_cast<int>(value) }; ConfigOptionInts* vec_new = new ConfigOptionInts{ boost::any_cast<int>(value) };
config.option<ConfigOptionInts>(opt_key)->set_at(vec_new, opt_index, opt_index); config.option<ConfigOptionInts>(opt_key)->set_at(vec_new, opt_index, 0);
} }
break; break;
case coEnum:{ case coEnum:{
@ -473,7 +477,6 @@ void change_opt_value(DynamicPrintConfig& config, t_config_option_key opt_key, b
void add_created_tab(Tab* panel, PresetBundle *preset_bundle) void add_created_tab(Tab* panel, PresetBundle *preset_bundle)
{ {
panel->m_show_btn_incompatible_presets = g_AppConfig->get("show_incompatible_presets").empty();
panel->create_preset_tab(preset_bundle); panel->create_preset_tab(preset_bundle);
// Load the currently selected preset into the GUI, update the preset selection box. // Load the currently selected preset into the GUI, update the preset selection box.
@ -516,7 +519,7 @@ void create_combochecklist(wxComboCtrl* comboCtrl, std::string text, std::string
comboCtrl->EnablePopupAnimation(false); comboCtrl->EnablePopupAnimation(false);
comboCtrl->SetPopupControl(popup); comboCtrl->SetPopupControl(popup);
popup->SetStringValue(text); popup->SetStringValue(from_u8(text));
popup->Bind(wxEVT_CHECKLISTBOX, [popup](wxCommandEvent& evt) { popup->OnCheckListBox(evt); }); popup->Bind(wxEVT_CHECKLISTBOX, [popup](wxCommandEvent& evt) { popup->OnCheckListBox(evt); });
popup->Bind(wxEVT_LISTBOX, [popup](wxCommandEvent& evt) { popup->OnListBoxSelection(evt); }); popup->Bind(wxEVT_LISTBOX, [popup](wxCommandEvent& evt) { popup->OnListBoxSelection(evt); });
popup->Bind(wxEVT_KEY_DOWN, [popup](wxKeyEvent& evt) { popup->OnKeyEvent(evt); }); popup->Bind(wxEVT_KEY_DOWN, [popup](wxKeyEvent& evt) { popup->OnKeyEvent(evt); });
@ -527,7 +530,7 @@ void create_combochecklist(wxComboCtrl* comboCtrl, std::string text, std::string
for (const std::string& item : items_str) for (const std::string& item : items_str)
{ {
popup->Append(item); popup->Append(from_u8(item));
} }
for (unsigned int i = 0; i < popup->GetCount(); ++i) for (unsigned int i = 0; i < popup->GetCount(); ++i)

View File

@ -34,6 +34,9 @@ class TabIface;
//! With wxConvUTF8 explicitly specify that the source string is already in UTF-8 encoding //! With wxConvUTF8 explicitly specify that the source string is already in UTF-8 encoding
#define _CHB(s) wxGetTranslation(wxString(s, wxConvUTF8)).utf8_str() #define _CHB(s) wxGetTranslation(wxString(s, wxConvUTF8)).utf8_str()
// Minimal buffer length for translated string (char buf[MIN_BUF_LENGTH_FOR_L])
#define MIN_BUF_LENGTH_FOR_L 128
namespace GUI { namespace GUI {
class Tab; class Tab;

View File

@ -151,7 +151,12 @@ void OptionsGroup::append_line(const Line& line) {
ConfigOptionDef option = opt.opt; ConfigOptionDef option = opt.opt;
// add label if any // add label if any
if (option.label != "") { if (option.label != "") {
auto field_label = new wxStaticText(parent(), wxID_ANY, L_str(option.label) + ":", wxDefaultPosition, wxDefaultSize); wxString str_label = L_str(option.label);
//! To correct translation by context have to use wxGETTEXT_IN_CONTEXT macro from wxWidget 3.1.1
// wxString str_label = (option.label == "Top" || option.label == "Bottom") ?
// wxGETTEXT_IN_CONTEXT("Layers", wxString(option.label.c_str()):
// L_str(option.label);
auto field_label = new wxStaticText(parent(), wxID_ANY, str_label + ":", wxDefaultPosition, wxDefaultSize);
field_label->SetFont(label_font); field_label->SetFont(label_font);
sizer->Add(field_label, 0, wxALIGN_CENTER_VERTICAL, 0); sizer->Add(field_label, 0, wxALIGN_CENTER_VERTICAL, 0);
} }

View File

@ -113,8 +113,7 @@ PageShp Tab::add_options_page(wxString title, std::string icon, bool is_extruder
// Index of icon in an icon list $self->{icons}. // Index of icon in an icon list $self->{icons}.
auto icon_idx = 0; auto icon_idx = 0;
if (!icon.empty()) { if (!icon.empty()) {
if (m_icon_index.find(icon) == m_icon_index.end()) icon_idx = (m_icon_index.find(icon) == m_icon_index.end()) ? -1 : m_icon_index.at(icon);
icon_idx = -1;
if (icon_idx == -1) { if (icon_idx == -1) {
// Add a new icon to the icon list. // Add a new icon to the icon list.
const auto img_icon = new wxIcon(from_u8(Slic3r::var(icon)), wxBITMAP_TYPE_PNG); const auto img_icon = new wxIcon(from_u8(Slic3r::var(icon)), wxBITMAP_TYPE_PNG);
@ -147,12 +146,25 @@ void Tab::update_tab_ui()
m_presets->update_tab_ui(m_presets_choice, m_show_incompatible_presets); m_presets->update_tab_ui(m_presets_choice, m_show_incompatible_presets);
} }
template<class T>
boost::any get_new_value(const DynamicPrintConfig &config_new, const DynamicPrintConfig &config_old, std::string opt_key, int &index)
{
for (int i = 0; i < config_new.option<T>(opt_key)->values.size(); i++)
if (config_new.option<T>(opt_key)->values[i] !=
config_old.option<T>(opt_key)->values[i]){
index = i;
break;
}
return config_new.option<T>(opt_key)->values[index];
}
// Load a provied DynamicConfig into the tab, modifying the active preset. // Load a provied DynamicConfig into the tab, modifying the active preset.
// This could be used for example by setting a Wipe Tower position by interactive manipulation in the 3D view. // This could be used for example by setting a Wipe Tower position by interactive manipulation in the 3D view.
void Tab::load_config(DynamicPrintConfig config) void Tab::load_config(DynamicPrintConfig config)
{ {
bool modified = 0; bool modified = 0;
boost::any value; boost::any value;
int opt_index = 0;
for(auto opt_key : m_config->diff(config)) { for(auto opt_key : m_config->diff(config)) {
switch ( config.def()->get(opt_key)->type ){ switch ( config.def()->get(opt_key)->type ){
case coFloatOrPercent: case coFloatOrPercent:
@ -168,28 +180,26 @@ void Tab::load_config(DynamicPrintConfig config)
value = config.opt_string(opt_key); value = config.opt_string(opt_key);
break; break;
case coPercents: case coPercents:
value = config.option<ConfigOptionPercents>(opt_key)->values.at(0); value = get_new_value<ConfigOptionPercents>(config, *m_config, opt_key, opt_index);
break; break;
case coFloats: case coFloats:
value = config.opt_float(opt_key, 0); value = get_new_value<ConfigOptionFloats>(config, *m_config, opt_key, opt_index);
break; break;
case coStrings: case coStrings:
if (config.option<ConfigOptionStrings>(opt_key)->values.empty()) value = config.option<ConfigOptionStrings>(opt_key)->values.empty() ? "" :
value = ""; get_new_value<ConfigOptionStrings>(config, *m_config, opt_key, opt_index);
else
value = config.opt_string(opt_key, static_cast<unsigned int>(0));
break; break;
case coBool: case coBool:
value = config.opt_bool(opt_key); value = config.opt_bool(opt_key);
break; break;
case coBools: case coBools:
value = config.opt_bool(opt_key, 0); value = get_new_value<ConfigOptionBools>(config, *m_config, opt_key, opt_index);
break; break;
case coInt: case coInt:
value = config.opt_int(opt_key); value = config.opt_int(opt_key);
break; break;
case coInts: case coInts:
value = config.opt_int(opt_key, 0); value = get_new_value<ConfigOptionInts>(config, *m_config, opt_key, opt_index);
break; break;
case coEnum:{ case coEnum:{
if (opt_key.compare("external_fill_pattern") == 0 || if (opt_key.compare("external_fill_pattern") == 0 ||
@ -210,7 +220,7 @@ void Tab::load_config(DynamicPrintConfig config)
default: default:
break; break;
} }
change_opt_value(*m_config, opt_key, value); change_opt_value(*m_config, opt_key, value, opt_index);
modified = 1; modified = 1;
} }
if (modified) { if (modified) {
@ -768,14 +778,15 @@ void TabPrint::update()
get_field(el)->toggle(have_wipe_tower); get_field(el)->toggle(have_wipe_tower);
m_recommended_thin_wall_thickness_description_line->SetText( m_recommended_thin_wall_thickness_description_line->SetText(
PresetHints::recommended_thin_wall_thickness(*m_preset_bundle)); from_u8(PresetHints::recommended_thin_wall_thickness(*m_preset_bundle)));
Thaw(); Thaw();
} }
void TabPrint::OnActivate() void TabPrint::OnActivate()
{ {
m_recommended_thin_wall_thickness_description_line->SetText(PresetHints::recommended_thin_wall_thickness(*m_preset_bundle)); m_recommended_thin_wall_thickness_description_line->SetText(
from_u8(PresetHints::recommended_thin_wall_thickness(*m_preset_bundle)));
} }
void TabFilament::build() void TabFilament::build()
@ -1044,7 +1055,7 @@ void TabPrinter::build()
btn->Bind(wxEVT_BUTTON, [this, parent](wxCommandEvent e){ btn->Bind(wxEVT_BUTTON, [this, parent](wxCommandEvent e){
if (m_event_button_browse > 0){ if (m_event_button_browse > 0){
wxCommandEvent event(m_event_button_browse); wxCommandEvent event(m_event_button_browse);
event.SetString(_(L("Button BROWSE was clicked!"))); event.SetString("Button BROWSE was clicked!");
g_wxMainFrame->ProcessWindowEvent(event); g_wxMainFrame->ProcessWindowEvent(event);
} }
// // # look for devices // // # look for devices
@ -1079,7 +1090,7 @@ void TabPrinter::build()
btn->Bind(wxEVT_BUTTON, [this, parent](wxCommandEvent e) { btn->Bind(wxEVT_BUTTON, [this, parent](wxCommandEvent e) {
if (m_event_button_test > 0){ if (m_event_button_test > 0){
wxCommandEvent event(m_event_button_test); wxCommandEvent event(m_event_button_test);
event.SetString(_(L("Button TEST was clicked!"))); event.SetString("Button TEST was clicked!");
g_wxMainFrame->ProcessWindowEvent(event); g_wxMainFrame->ProcessWindowEvent(event);
} }
// my $ua = LWP::UserAgent->new; // my $ua = LWP::UserAgent->new;
@ -1183,7 +1194,9 @@ void TabPrinter::extruders_count_changed(size_t extruders_count){
void TabPrinter::build_extruder_pages(){ void TabPrinter::build_extruder_pages(){
for (auto extruder_idx = m_extruder_pages.size(); extruder_idx < m_extruders_count; ++extruder_idx){ for (auto extruder_idx = m_extruder_pages.size(); extruder_idx < m_extruders_count; ++extruder_idx){
//# build page //# build page
auto page = add_options_page(_(L("Extruder ")) + wxString::Format(_T("%i"), extruder_idx + 1), "funnel.png", true); char buf[MIN_BUF_LENGTH_FOR_L];
sprintf(buf, _CHB(L("Extruder %d")), extruder_idx + 1);
auto page = add_options_page(from_u8(buf), "funnel.png", true);
m_extruder_pages.push_back(page); m_extruder_pages.push_back(page);
auto optgroup = page->new_optgroup(_(L("Size"))); auto optgroup = page->new_optgroup(_(L("Size")));
@ -1613,6 +1626,7 @@ void Tab::update_ui_from_settings()
{ {
// Show the 'show / hide presets' button only for the print and filament tabs, and only if enabled // Show the 'show / hide presets' button only for the print and filament tabs, and only if enabled
// in application preferences. // in application preferences.
m_show_btn_incompatible_presets = get_app_config()->get("show_incompatible_presets")[0] == '1' ? true : false;
bool show = m_show_btn_incompatible_presets && m_presets->name().compare("printer") != 0; bool show = m_show_btn_incompatible_presets && m_presets->name().compare("printer") != 0;
show ? m_btn_hide_incompatible_presets->Show() : m_btn_hide_incompatible_presets->Hide(); show ? m_btn_hide_incompatible_presets->Show() : m_btn_hide_incompatible_presets->Hide();
// If the 'show / hide presets' button is hidden, hide the incompatible presets. // If the 'show / hide presets' button is hidden, hide the incompatible presets.

View File

@ -106,7 +106,7 @@ protected:
public: public:
PresetBundle* m_preset_bundle; PresetBundle* m_preset_bundle;
bool m_show_btn_incompatible_presets; bool m_show_btn_incompatible_presets = false;
PresetCollection* m_presets; PresetCollection* m_presets;
DynamicPrintConfig* m_config; DynamicPrintConfig* m_config;