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

This commit is contained in:
Enrico Turri 2018-05-14 10:02:28 +02:00
commit 32063cbe23
12 changed files with 115 additions and 55 deletions

View file

@ -275,7 +275,7 @@ bool GCodePreviewData::empty() const
return extrusion.layers.empty() && travel.polylines.empty() && retraction.positions.empty() && unretraction.positions.empty();
}
const GCodePreviewData::Color& GCodePreviewData::get_extrusion_role_color(ExtrusionRole role) const
GCodePreviewData::Color GCodePreviewData::get_extrusion_role_color(ExtrusionRole role) const
{
return extrusion.role_colors[role];
}

View file

@ -187,7 +187,7 @@ public:
void reset();
bool empty() const;
const Color& get_extrusion_role_color(ExtrusionRole role) const;
Color get_extrusion_role_color(ExtrusionRole role) const;
Color get_height_color(float height) const;
Color get_width_color(float width) const;
Color get_feedrate_color(float feedrate) const;

View file

@ -111,7 +111,8 @@ PrintConfigDef::PrintConfigDef()
"with cooling (use a fan) before tweaking this.");
def->cli = "bridge-flow-ratio=f";
def->min = 0;
def->default_value = new ConfigOptionFloat(1);
def->max = 2;
def->default_value = new ConfigOptionFloat(1);
def = this->add("bridge_speed", coFloat);
def->label = L("Bridges");

View file

@ -14,7 +14,7 @@
#include <boost/thread.hpp>
#define SLIC3R_FORK_NAME "Slic3r Prusa Edition"
#define SLIC3R_VERSION "1.40.0"
#define SLIC3R_VERSION "1.40.0-alpha"
#define SLIC3R_BUILD "UNKNOWN"
typedef int32_t coord_t;

View file

@ -2313,7 +2313,7 @@ void _3DScene::_load_gcode_extrusion_paths(const GCodePreviewData& preview_data,
return 0.0f;
}
static const GCodePreviewData::Color& path_color(const GCodePreviewData& data, const std::vector<float>& tool_colors, float value)
static GCodePreviewData::Color path_color(const GCodePreviewData& data, const std::vector<float>& tool_colors, float value)
{
switch (data.extrusion.view_type)
{
@ -2329,7 +2329,7 @@ void _3DScene::_load_gcode_extrusion_paths(const GCodePreviewData& preview_data,
return data.get_volumetric_rate_color(value);
case GCodePreviewData::Extrusion::Tool:
{
static GCodePreviewData::Color color;
GCodePreviewData::Color color;
::memcpy((void*)color.rgba, (const void*)(tool_colors.data() + (unsigned int)value * 4), 4 * sizeof(float));
return color;
}
@ -2366,7 +2366,6 @@ void _3DScene::_load_gcode_extrusion_paths(const GCodePreviewData& preview_data,
};
typedef std::vector<Filter> FiltersList;
size_t initial_volumes_count = volumes.volumes.size();
// detects filters
@ -2390,7 +2389,6 @@ void _3DScene::_load_gcode_extrusion_paths(const GCodePreviewData& preview_data,
for (Filter& filter : filters)
{
s_gcode_preview_volume_index.first_volumes.emplace_back(GCodePreviewVolumeIndex::Extrusion, (unsigned int)filter.role, (unsigned int)volumes.volumes.size());
GLVolume* volume = new GLVolume(Helper::path_color(preview_data, tool_colors, filter.value).rgba);
if (volume != nullptr)
{

View file

@ -82,10 +82,8 @@ namespace Slic3r { namespace GUI {
return std::regex_match(string, regex_pattern);
}
// boost::any Field::get_value_by_opt_type(wxString& str)
void Field::get_value_by_opt_type(wxString& str)
{
// boost::any m_value;
switch (m_opt.type){
case coInt:
m_value = wxAtoi(str);
@ -96,8 +94,25 @@ namespace Slic3r { namespace GUI {
case coFloat:{
if (m_opt.type == coPercent && str.Last() == '%')
str.RemoveLast();
else if (str.Last() == '%') {
wxString label = m_Label->GetLabel();
if (label.Last() == '\n') label.RemoveLast();
while (label.Last() == ' ') label.RemoveLast();
if (label.Last() == ':') label.RemoveLast();
show_error(m_parent, wxString::Format(_(L("%s doesn't support percentage")), label));
set_value(double_to_string(m_opt.min), true);
m_value = double(m_opt.min);
break;
}
double val;
str.ToCDouble(&val);
if (m_opt.min > val && val > m_opt.max)
{
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;
set_value(double_to_string(val), true);
}
m_value = val;
break; }
case coString:
@ -108,8 +123,6 @@ namespace Slic3r { namespace GUI {
default:
break;
}
// return m_value;
}
void TextCtrl::BUILD() {
@ -170,17 +183,32 @@ namespace Slic3r { namespace GUI {
//! to allow the default handling
event.Skip();
//! eliminating the g-code pop up text description
temp->GetToolTip()->Enable(false);
bool flag = false;
#ifdef __WXGTK__
// I have no idea why, but on GTK flag works in other way
flag = true;
#endif // __WXGTK__
temp->GetToolTip()->Enable(flag);
}), temp->GetId());
#if !defined(__WXGTK__)
temp->Bind(wxEVT_KILL_FOCUS, ([this, temp](wxEvent& e)
{
e.Skip();// on_kill_focus(e);
temp->GetToolTip()->Enable(true);
}), temp->GetId());
#endif // __WXGTK__
temp->Bind(wxEVT_TEXT, ([this](wxCommandEvent) { on_change_field(); }), temp->GetId());
// select all text using Ctrl+A
temp->Bind(wxEVT_CHAR, ([temp](wxKeyEvent& event)
{
if (wxGetKeyState(wxKeyCode('A')) && wxGetKeyState(WXK_CONTROL))
temp->SetSelection(-1, -1); //select all
event.Skip();
}));
// recast as a wxWindow to fit the calling convention
window = dynamic_cast<wxWindow*>(temp);
}
@ -188,9 +216,9 @@ namespace Slic3r { namespace GUI {
boost::any& TextCtrl::get_value()
{
wxString ret_str = static_cast<wxTextCtrl*>(window)->GetValue();
/*boost::any ret_val*/get_value_by_opt_type(ret_str);
get_value_by_opt_type(ret_str);
return m_value;//ret_val;
return m_value;
}
void TextCtrl::enable() { dynamic_cast<wxTextCtrl*>(window)->Enable(); dynamic_cast<wxTextCtrl*>(window)->SetEditable(true); }

View file

@ -124,7 +124,6 @@ public:
virtual wxWindow* getWindow() { return nullptr; }
bool is_matched(const std::string& string, const std::string& pattern);
// boost::any get_value_by_opt_type(wxString& str);
void get_value_by_opt_type(wxString& str);
/// Factory method for generating new derived classes.