Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
bubnikv committed Oct 30, 2019
2 parents ba39ee6 + b3f53c9 commit f60fbec
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 24 deletions.
1 change: 0 additions & 1 deletion src/libslic3r/LayerRegion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ void LayerRegion::make_perimeters(const SurfaceCollection &slices, SurfaceCollec

void LayerRegion::process_external_surfaces(const Layer *lower_layer, const Polygons *lower_layer_covered)
{
const Surfaces &surfaces = this->fill_surfaces.surfaces;
const bool has_infill = this->region()->config().fill_density.value > 0.;
const float margin = float(scale_(EXTERNAL_INFILL_MARGIN));

Expand Down
1 change: 0 additions & 1 deletion src/libslic3r/PolygonTrimmer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ TrimmedLoop trim_loop(const Polygon &loop, const EdgeGrid::Grid &grid)
TrimmedLoop out;

if (loop.size() >= 2) {
size_t cnt = loop.points.size();

struct Visitor {
Visitor(const EdgeGrid::Grid &grid, const Slic3r::Point *pt_prev, const Slic3r::Point *pt_this) : grid(grid), pt_prev(pt_prev), pt_this(pt_this) {}
Expand Down
5 changes: 2 additions & 3 deletions src/slic3r/Config/Version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,9 @@ size_t Index::load(const boost::filesystem::path &path)
value = left_trim(value + 1);
*key_end = 0;
boost::optional<Semver> semver;
if (maybe_semver)
if (maybe_semver)
semver = Semver::parse(key);
if (key_value_pair) {
if (key_value_pair) {
if (semver)
throw file_parser_error("Key cannot be a semantic version", path, idx_line);\
// Verify validity of the key / value pair.
Expand Down Expand Up @@ -288,7 +288,6 @@ Index::const_iterator Index::find(const Semver &ver) const

Index::const_iterator Index::recommended() const
{
int idx = -1;
const_iterator highest = this->end();
for (const_iterator it = this->begin(); it != this->end(); ++ it)
if (it->is_current_slic3r_supported() &&
Expand Down
1 change: 1 addition & 0 deletions src/slic3r/GUI/BackgroundSlicingProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ bool BackgroundSlicingProcess::select_technology(PrinterTechnology tech)
switch (tech) {
case ptFFF: m_print = m_fff_print; break;
case ptSLA: m_print = m_sla_print; break;
default: assert(false); break;
}
changed = true;
}
Expand Down
40 changes: 33 additions & 7 deletions src/slic3r/GUI/Field.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,13 @@ void Field::get_value_by_opt_type(wxString& str, const bool check_value/* = true
case coFloat:{
if (m_opt.type == coPercent && !str.IsEmpty() && str.Last() == '%')
str.RemoveLast();
else if (check_value && !str.IsEmpty() && str.Last() == '%') {
else if (!str.IsEmpty() && str.Last() == '%')
{
if (!check_value) {
m_value.clear();
break;
}

wxString label = m_Label->GetLabel();
if (label.Last() == '\n') label.RemoveLast();
while (label.Last() == ' ') label.RemoveLast();
Expand All @@ -169,13 +175,21 @@ void Field::get_value_by_opt_type(wxString& str, const bool check_value/* = true
{
if (m_opt.nullable && str == na_value())
val = ConfigOptionFloatsNullable::nil_value();
else if (check_value && !str.ToCDouble(&val))
else if (!str.ToCDouble(&val))
{
if (!check_value) {
m_value.clear();
break;
}
show_error(m_parent, _(L("Invalid numeric input.")));
set_value(double_to_string(val), true);
}
if (check_value && (m_opt.min > val || val > m_opt.max))
if (m_opt.min > val || val > m_opt.max)
{
if (!check_value) {
m_value.clear();
break;
}
show_error(m_parent, _(L("Input value is out of range")));
if (m_opt.min > val) val = m_opt.min;
if (val > m_opt.max) val = m_opt.max;
Expand All @@ -192,15 +206,24 @@ void Field::get_value_by_opt_type(wxString& str, const bool check_value/* = true
double val = 0.;
// Replace the first occurence of comma in decimal number.
str.Replace(",", ".", false);
if (check_value && !str.ToCDouble(&val))
if (!str.ToCDouble(&val))
{
if (!check_value) {
m_value.clear();
break;
}
show_error(m_parent, _(L("Invalid numeric input.")));
set_value(double_to_string(val), true);
}
else if (check_value && ((m_opt.sidetext.rfind("mm/s") != std::string::npos && val > m_opt.max) ||
else if (((m_opt.sidetext.rfind("mm/s") != std::string::npos && val > m_opt.max) ||
(m_opt.sidetext.rfind("mm ") != std::string::npos && val > 1)) &&
(m_value.empty() || std::string(str.ToUTF8().data()) != boost::any_cast<std::string>(m_value)))
{
if (!check_value) {
m_value.clear();
break;
}

const std::string sidetext = m_opt.sidetext.rfind("mm/s") != std::string::npos ? "mm/s" : "mm";
const wxString stVal = double_to_string(val, 2);
const wxString msg_text = wxString::Format(_(L("Do you mean %s%% instead of %s %s?\n"
Expand Down Expand Up @@ -351,6 +374,7 @@ bool TextCtrl::value_was_changed()
boost::any val = m_value;
wxString ret_str = static_cast<wxTextCtrl*>(window)->GetValue();
// update m_value!
// ret_str might be changed inside get_value_by_opt_type
get_value_by_opt_type(ret_str);

switch (m_opt.type) {
Expand Down Expand Up @@ -396,8 +420,10 @@ void TextCtrl::set_value(const boost::any& value, bool change_event/* = false*/)

if (!change_event) {
wxString ret_str = static_cast<wxTextCtrl*>(window)->GetValue();
// update m_value to correct work of next value_was_changed(),
// but don't check/change inputed value and don't show a warning message
/* Update m_value to correct work of next value_was_changed().
* But after checking of entered value, don't fix the "incorrect" value and don't show a warning message,
* just clear m_value in this case.
*/
get_value_by_opt_type(ret_str, false);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/slic3r/GUI/GLCanvas3D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1926,7 +1926,7 @@ void GLCanvas3D::reload_scene(bool refresh_immediately, bool force_full_scene_re
if (it->new_geometry()) {
// New volume.
unsigned int old_id = find_old_volume_id(it->composite_id);
if (old_id != -1)
if (old_id != (unsigned int)-1)
map_glvolume_old_to_new[old_id] = m_volumes.volumes.size();
m_volumes.load_object_volume(&model_object, obj_idx, volume_idx, instance_idx, m_color_by, m_initialized);
m_volumes.volumes.back()->geometry_id = key.geometry_id;
Expand Down
9 changes: 4 additions & 5 deletions src/slic3r/GUI/GUI_App.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class GUI_App : public wxApp
wxFont m_bold_font;
wxFont m_normal_font;

size_t m_em_unit; // width of a "m"-symbol in pixels for current system font
int m_em_unit; // width of a "m"-symbol in pixels for current system font
// Note: for 100% Scale m_em_unit = 10 -> it's a good enough coefficient for a size setting of controls

std::unique_ptr<wxLocale> m_wxLocale;
Expand All @@ -105,7 +105,7 @@ class GUI_App : public wxApp
bool initialized() const { return m_initialized; }

GUI_App();
~GUI_App();
~GUI_App() override;

static unsigned get_colour_approx_luma(const wxColour &colour);
static bool dark_mode();
Expand All @@ -124,8 +124,7 @@ class GUI_App : public wxApp
const wxFont& small_font() { return m_small_font; }
const wxFont& bold_font() { return m_bold_font; }
const wxFont& normal_font() { return m_normal_font; }
size_t em_unit() const { return m_em_unit; }
void set_em_unit(const size_t em_unit) { m_em_unit = em_unit; }
int em_unit() const { return m_em_unit; }
float toolbar_icon_scale(const bool is_limited = false) const;

void recreate_GUI();
Expand Down Expand Up @@ -155,7 +154,7 @@ class GUI_App : public wxApp
// Translate the language code to a code, for which Prusa Research maintains translations. Defaults to "en_US".
wxString current_language_code_safe() const;

virtual bool OnExceptionInMainLoop();
virtual bool OnExceptionInMainLoop() override;

#ifdef __APPLE__
// wxWidgets override to get an event on open files.
Expand Down
4 changes: 2 additions & 2 deletions src/slic3r/GUI/GUI_ObjectList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ void ObjectList::update_extruder_values_for_items(const size_t max_extruder)
auto object = (*m_objects)[i];
wxString extruder;
if (!object->config.has("extruder") ||
object->config.option<ConfigOptionInt>("extruder")->value > max_extruder)
size_t(object->config.option<ConfigOptionInt>("extruder")->value) > max_extruder)
extruder = _(L("default"));
else
extruder = wxString::Format("%d", object->config.option<ConfigOptionInt>("extruder")->value);
Expand All @@ -457,7 +457,7 @@ void ObjectList::update_extruder_values_for_items(const size_t max_extruder)
item = m_objects_model->GetItemByVolumeId(i, id);
if (!item) continue;
if (!object->volumes[id]->config.has("extruder") ||
object->volumes[id]->config.option<ConfigOptionInt>("extruder")->value > max_extruder)
size_t(object->volumes[id]->config.option<ConfigOptionInt>("extruder")->value) > max_extruder)
extruder = _(L("default"));
else
extruder = wxString::Format("%d", object->volumes[id]->config.option<ConfigOptionInt>("extruder")->value);
Expand Down
2 changes: 2 additions & 0 deletions src/slic3r/GUI/GUI_Preview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,8 @@ void Preview::load_print(bool keep_z_range)
load_print_as_fff(keep_z_range);
else if (tech == ptSLA)
load_print_as_sla();

Layout();
}

void Preview::reload_print(bool keep_volumes)
Expand Down
2 changes: 1 addition & 1 deletion src/slic3r/GUI/OptionsGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ void OptionsGroup::append_line(const Line& line, wxStaticText** full_Label/* = n

add_undo_buttuns_to_sizer(sizer, field);
if (is_window_field(field))
sizer->Add(field->getWindow(), option.opt.full_width ? 1 : 0, //(option.opt.full_width ? wxEXPAND : 0) |
sizer->Add(field->getWindow(), option.opt.full_width ? 1 : 0, //(option.opt.full_width ? wxEXPAND : 0) |
wxBOTTOM | wxTOP | (option.opt.full_width ? wxEXPAND : wxALIGN_CENTER_VERTICAL), (wxOSX || !staticbox) ? 0 : 2);
if (is_sizer_field(field))
sizer->Add(field->getSizer(), 1, /*(*/option.opt.full_width ? wxEXPAND : /*0) |*/ wxALIGN_CENTER_VERTICAL, 0);
Expand Down
4 changes: 2 additions & 2 deletions src/slic3r/GUI/Plater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4791,7 +4791,7 @@ bool Plater::undo_redo_string_getter(const bool is_undo, int idx, const char** o
const std::vector<UndoRedo::Snapshot>& ss_stack = p->undo_redo_stack().snapshots();
const int idx_in_ss_stack = p->get_active_snapshot_index() + (is_undo ? -(++idx) : idx);

if (0 < idx_in_ss_stack && idx_in_ss_stack < ss_stack.size() - 1) {
if (0 < idx_in_ss_stack && (size_t)idx_in_ss_stack < ss_stack.size() - 1) {
*out_text = ss_stack[idx_in_ss_stack].name.c_str();
return true;
}
Expand All @@ -4804,7 +4804,7 @@ void Plater::undo_redo_topmost_string_getter(const bool is_undo, std::string& ou
const std::vector<UndoRedo::Snapshot>& ss_stack = p->undo_redo_stack().snapshots();
const int idx_in_ss_stack = p->get_active_snapshot_index() + (is_undo ? -1 : 0);

if (0 < idx_in_ss_stack && idx_in_ss_stack < ss_stack.size() - 1) {
if (0 < idx_in_ss_stack && (size_t)idx_in_ss_stack < ss_stack.size() - 1) {
out_text = ss_stack[idx_in_ss_stack].name;
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/slic3r/GUI/wxExtensions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1020,7 +1020,7 @@ wxDataViewItem ObjectDataViewModel::Delete(const wxDataViewItem &item)
node_parent->GetChildren().Remove(node);

if (id > 0) {
if(id == node_parent->GetChildCount()) id--;
if (size_t(id) == node_parent->GetChildCount()) id--;
ret_item = wxDataViewItem(node_parent->GetChildren().Item(id));
}

Expand Down

0 comments on commit f60fbec

Please sign in to comment.