Merge remote-tracking branch 'origin/et_system_printers'
@ -18,6 +18,8 @@ config_update_url = http://files.prusa3d.com/wp-content/uploads/repository/Prusa
|
||||
name = Creality Ender-3
|
||||
variants = 0.4
|
||||
technology = FFF
|
||||
bed_model = ender3_bed.stl
|
||||
bed_texture = ender3.svg
|
||||
default_materials = Creality PLA @ENDER3; Prusament PLA @ENDER3
|
||||
|
||||
# All presets starting with asterisk, for example *common*, are intermediate and they will
|
||||
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
@ -22,6 +22,8 @@ name = Original Prusa MINI
|
||||
variants = 0.4; 0.25; 0.6
|
||||
technology = FFF
|
||||
family = MINI
|
||||
bed_model = mini_bed.stl
|
||||
bed_texture = mini.svg
|
||||
default_materials = Prusament PLA; Prusament PETG @MINI
|
||||
|
||||
[printer_model:MK3S]
|
||||
@ -29,6 +31,8 @@ name = Original Prusa i3 MK3S
|
||||
variants = 0.4; 0.25; 0.6
|
||||
technology = FFF
|
||||
family = MK3
|
||||
bed_model = mk3_bed.stl
|
||||
bed_texture = mk3.svg
|
||||
default_materials = Prusament PLA; Prusament PETG
|
||||
|
||||
[printer_model:MK3]
|
||||
@ -36,6 +40,8 @@ name = Original Prusa i3 MK3
|
||||
variants = 0.4; 0.25; 0.6
|
||||
technology = FFF
|
||||
family = MK3
|
||||
bed_model = mk3_bed.stl
|
||||
bed_texture = mk3.svg
|
||||
default_materials = Prusament PLA; Prusament PETG
|
||||
|
||||
[printer_model:MK3SMMU2S]
|
||||
@ -43,6 +49,8 @@ name = Original Prusa i3 MK3S MMU2S
|
||||
variants = 0.4; 0.25; 0.6
|
||||
technology = FFF
|
||||
family = MK3
|
||||
bed_model = mk3_bed.stl
|
||||
bed_texture = mk3.svg
|
||||
default_materials = Prusament PLA @MMU2; Prusament PETG @MMU2
|
||||
|
||||
[printer_model:MK3MMU2]
|
||||
@ -50,6 +58,8 @@ name = Original Prusa i3 MK3 MMU2
|
||||
variants = 0.4; 0.25; 0.6
|
||||
technology = FFF
|
||||
family = MK3
|
||||
bed_model = mk3_bed.stl
|
||||
bed_texture = mk3.svg
|
||||
default_materials = Prusament PLA @MMU2; Prusament PETG @MMU2
|
||||
|
||||
[printer_model:MK2.5S]
|
||||
@ -57,6 +67,8 @@ name = Original Prusa i3 MK2.5S
|
||||
variants = 0.4; 0.25; 0.6
|
||||
technology = FFF
|
||||
family = MK2.5
|
||||
bed_model = mk3_bed.stl
|
||||
bed_texture = mk3.svg
|
||||
default_materials = Prusament PLA; Prusament PETG
|
||||
|
||||
[printer_model:MK2.5]
|
||||
@ -64,6 +76,8 @@ name = Original Prusa i3 MK2.5
|
||||
variants = 0.4; 0.25; 0.6
|
||||
technology = FFF
|
||||
family = MK2.5
|
||||
bed_model = mk3_bed.stl
|
||||
bed_texture = mk3.svg
|
||||
default_materials = Prusament PLA; Prusament PETG
|
||||
|
||||
[printer_model:MK2.5SMMU2S]
|
||||
@ -71,6 +85,8 @@ name = Original Prusa i3 MK2.5S MMU2S
|
||||
variants = 0.4; 0.25; 0.6
|
||||
technology = FFF
|
||||
family = MK2.5
|
||||
bed_model = mk3_bed.stl
|
||||
bed_texture = mk3.svg
|
||||
default_materials = Prusament PLA @MMU2; Prusament PETG @MMU2
|
||||
|
||||
[printer_model:MK2.5MMU2]
|
||||
@ -78,6 +94,8 @@ name = Original Prusa i3 MK2.5 MMU2
|
||||
variants = 0.4; 0.25; 0.6
|
||||
technology = FFF
|
||||
family = MK2.5
|
||||
bed_model = mk3_bed.stl
|
||||
bed_texture = mk3.svg
|
||||
default_materials = Prusament PLA @MMU2; Prusament PETG @MMU2
|
||||
|
||||
[printer_model:MK2S]
|
||||
@ -85,6 +103,8 @@ name = Original Prusa i3 MK2S
|
||||
variants = 0.4; 0.25; 0.6
|
||||
technology = FFF
|
||||
family = MK2
|
||||
bed_model = mk2_bed.stl
|
||||
bed_texture = mk2.svg
|
||||
default_materials = Prusament PLA; Prusament PETG
|
||||
|
||||
[printer_model:MK2SMM]
|
||||
@ -92,6 +112,8 @@ name = Original Prusa i3 MK2S MMU1
|
||||
variants = 0.4; 0.6
|
||||
technology = FFF
|
||||
family = MK2
|
||||
bed_model = mk2_bed.stl
|
||||
bed_texture = mk2.svg
|
||||
default_materials = Prusament PLA; Prusament PETG @MMU1
|
||||
|
||||
[printer_model:SL1]
|
||||
@ -99,6 +121,8 @@ name = Original Prusa SL1
|
||||
variants = default
|
||||
technology = SLA
|
||||
family = SL1
|
||||
bed_model = sl1_bed.stl
|
||||
bed_texture = sl1.svg
|
||||
default_materials = Prusa Transparent Tough @0.05
|
||||
|
||||
# All presets starting with asterisk, for example *common*, are intermediate and they will
|
||||
|
Before Width: | Height: | Size: 8.8 KiB After Width: | Height: | Size: 8.8 KiB |
Before Width: | Height: | Size: 61 KiB After Width: | Height: | Size: 61 KiB |
Before Width: | Height: | Size: 61 KiB After Width: | Height: | Size: 61 KiB |
Before Width: | Height: | Size: 9.2 KiB After Width: | Height: | Size: 9.2 KiB |
@ -189,8 +189,6 @@ void Bed3D::Axes::render_axis(double length) const
|
||||
|
||||
Bed3D::Bed3D()
|
||||
: m_type(Custom)
|
||||
, m_custom_texture("")
|
||||
, m_custom_model("")
|
||||
, m_vbo_id(0)
|
||||
, m_scale_factor(1.0f)
|
||||
{
|
||||
@ -198,31 +196,31 @@ Bed3D::Bed3D()
|
||||
|
||||
bool Bed3D::set_shape(const Pointfs& shape, const std::string& custom_texture, const std::string& custom_model)
|
||||
{
|
||||
EType new_type = detect_type(shape);
|
||||
auto check_texture = [](const std::string& texture) {
|
||||
return !texture.empty() && (boost::algorithm::iends_with(texture, ".png") || boost::algorithm::iends_with(texture, ".svg")) && boost::filesystem::exists(texture);
|
||||
};
|
||||
|
||||
// check that the passed custom texture filename is valid
|
||||
std::string cst_texture(custom_texture);
|
||||
if (!cst_texture.empty())
|
||||
{
|
||||
if ((!boost::algorithm::iends_with(custom_texture, ".png") && !boost::algorithm::iends_with(custom_texture, ".svg")) || !boost::filesystem::exists(custom_texture))
|
||||
cst_texture = "";
|
||||
}
|
||||
auto check_model = [](const std::string& model) {
|
||||
return !model.empty() && boost::algorithm::iends_with(model, ".stl") && boost::filesystem::exists(model);
|
||||
};
|
||||
|
||||
// check that the passed custom texture filename is valid
|
||||
std::string cst_model(custom_model);
|
||||
if (!cst_model.empty())
|
||||
{
|
||||
if (!boost::algorithm::iends_with(custom_model, ".stl") || !boost::filesystem::exists(custom_model))
|
||||
cst_model = "";
|
||||
}
|
||||
auto [new_type, system_model, system_texture] = detect_type(shape);
|
||||
|
||||
if ((m_shape == shape) && (m_type == new_type) && (m_custom_texture == cst_texture) && (m_custom_model == cst_model))
|
||||
std::string texture_filename = custom_texture.empty() ? system_texture : custom_texture;
|
||||
if (!check_texture(texture_filename))
|
||||
texture_filename.clear();
|
||||
|
||||
std::string model_filename = custom_model.empty() ? system_model : custom_model;
|
||||
if (!check_model(model_filename))
|
||||
model_filename.clear();
|
||||
|
||||
if ((m_shape == shape) && (m_type == new_type) && (m_texture_filename == texture_filename) && (m_model_filename == model_filename))
|
||||
// No change, no need to update the UI.
|
||||
return false;
|
||||
|
||||
m_shape = shape;
|
||||
m_custom_texture = cst_texture;
|
||||
m_custom_model = cst_model;
|
||||
m_texture_filename = texture_filename;
|
||||
m_model_filename = model_filename;
|
||||
m_type = new_type;
|
||||
|
||||
calc_bounding_boxes();
|
||||
@ -244,7 +242,7 @@ bool Bed3D::set_shape(const Pointfs& shape, const std::string& custom_texture, c
|
||||
m_texture.reset();
|
||||
m_model.reset();
|
||||
|
||||
// Set the origin and size for painting of the coordinate system axes.
|
||||
// Set the origin and size for rendering the coordinate system axes.
|
||||
m_axes.origin = Vec3d(0.0, 0.0, (double)GROUND_Z);
|
||||
m_axes.length = 0.1 * m_bounding_box.max_size() * Vec3d::Ones();
|
||||
|
||||
@ -273,11 +271,7 @@ void Bed3D::render(GLCanvas3D& canvas, float theta, float scale_factor, bool sho
|
||||
|
||||
switch (m_type)
|
||||
{
|
||||
case MK2: { render_prusa(canvas, "mk2", theta > 90.0f); break; }
|
||||
case MK3: { render_prusa(canvas, "mk3", theta > 90.0f); break; }
|
||||
case SL1: { render_prusa(canvas, "sl1", theta > 90.0f); break; }
|
||||
case MINI: { render_prusa(canvas, "mini", theta > 90.0f); break; }
|
||||
case ENDER3: { render_prusa(canvas, "ender3", theta > 90.0f); break; }
|
||||
case System: { render_system(canvas, theta > 90.0f); break; }
|
||||
default:
|
||||
case Custom: { render_custom(canvas, theta > 90.0f); break; }
|
||||
}
|
||||
@ -359,10 +353,8 @@ static std::string system_print_bed_texture(const Preset &preset)
|
||||
return out;
|
||||
}
|
||||
|
||||
Bed3D::EType Bed3D::detect_type(const Pointfs& shape) const
|
||||
std::tuple<Bed3D::EType, std::string, std::string> Bed3D::detect_type(const Pointfs& shape) const
|
||||
{
|
||||
EType type = Custom;
|
||||
|
||||
auto bundle = wxGetApp().preset_bundle;
|
||||
if (bundle != nullptr)
|
||||
{
|
||||
@ -371,39 +363,12 @@ Bed3D::EType Bed3D::detect_type(const Pointfs& shape) const
|
||||
{
|
||||
if (curr->config.has("bed_shape"))
|
||||
{
|
||||
if (curr->vendor != nullptr)
|
||||
if (shape == dynamic_cast<const ConfigOptionPoints*>(curr->config.option("bed_shape"))->values)
|
||||
{
|
||||
if ((curr->vendor->name == "Prusa Research") && (shape == dynamic_cast<const ConfigOptionPoints*>(curr->config.option("bed_shape"))->values))
|
||||
{
|
||||
if (boost::contains(curr->name, "SL1"))
|
||||
{
|
||||
type = SL1;
|
||||
break;
|
||||
}
|
||||
else if (boost::contains(curr->name, "MK3") || boost::contains(curr->name, "MK2.5"))
|
||||
{
|
||||
type = MK3;
|
||||
break;
|
||||
}
|
||||
else if (boost::contains(curr->name, "MK2"))
|
||||
{
|
||||
type = MK2;
|
||||
break;
|
||||
}
|
||||
else if (boost::contains(curr->name, "MINI"))
|
||||
{
|
||||
type = MINI;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if ((curr->vendor->name == "Creality") && (shape == dynamic_cast<const ConfigOptionPoints*>(curr->config.option("bed_shape"))->values))
|
||||
{
|
||||
if (boost::contains(curr->name, "ENDER-3"))
|
||||
{
|
||||
type = ENDER3;
|
||||
break;
|
||||
}
|
||||
}
|
||||
std::string model_filename = system_print_bed_model(*curr);
|
||||
std::string texture_filename = system_print_bed_texture(*curr);
|
||||
if (!model_filename.empty() && !texture_filename.empty())
|
||||
return std::make_tuple(System, model_filename, texture_filename);
|
||||
}
|
||||
}
|
||||
|
||||
@ -411,7 +376,7 @@ Bed3D::EType Bed3D::detect_type(const Pointfs& shape) const
|
||||
}
|
||||
}
|
||||
|
||||
return type;
|
||||
return std::make_tuple(Custom, "", "");
|
||||
}
|
||||
|
||||
void Bed3D::render_axes() const
|
||||
@ -420,35 +385,35 @@ void Bed3D::render_axes() const
|
||||
m_axes.render();
|
||||
}
|
||||
|
||||
void Bed3D::render_prusa(GLCanvas3D& canvas, const std::string& key, bool bottom) const
|
||||
void Bed3D::render_system(GLCanvas3D& canvas, bool bottom) const
|
||||
{
|
||||
if (!bottom)
|
||||
render_model(m_custom_model.empty() ? resources_dir() + "/models/" + key + "_bed.stl" : m_custom_model);
|
||||
render_model();
|
||||
|
||||
render_texture(m_custom_texture.empty() ? resources_dir() + "/icons/bed/" + key + ".svg" : m_custom_texture, bottom, canvas);
|
||||
render_texture(bottom, canvas);
|
||||
}
|
||||
|
||||
void Bed3D::render_texture(const std::string& filename, bool bottom, GLCanvas3D& canvas) const
|
||||
void Bed3D::render_texture(bool bottom, GLCanvas3D& canvas) const
|
||||
{
|
||||
if (filename.empty())
|
||||
if (m_texture_filename.empty())
|
||||
{
|
||||
m_texture.reset();
|
||||
render_default(bottom);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((m_texture.get_id() == 0) || (m_texture.get_source() != filename))
|
||||
if ((m_texture.get_id() == 0) || (m_texture.get_source() != m_texture_filename))
|
||||
{
|
||||
m_texture.reset();
|
||||
|
||||
if (boost::algorithm::iends_with(filename, ".svg"))
|
||||
if (boost::algorithm::iends_with(m_texture_filename, ".svg"))
|
||||
{
|
||||
// use higher resolution images if graphic card and opengl version allow
|
||||
GLint max_tex_size = GLCanvas3DManager::get_gl_info().get_max_tex_size();
|
||||
if ((m_temp_texture.get_id() == 0) || (m_temp_texture.get_source() != filename))
|
||||
if ((m_temp_texture.get_id() == 0) || (m_temp_texture.get_source() != m_texture_filename))
|
||||
{
|
||||
// generate a temporary lower resolution texture to show while no main texture levels have been compressed
|
||||
if (!m_temp_texture.load_from_svg_file(filename, false, false, false, max_tex_size / 8))
|
||||
if (!m_temp_texture.load_from_svg_file(m_texture_filename, false, false, false, max_tex_size / 8))
|
||||
{
|
||||
render_default(bottom);
|
||||
return;
|
||||
@ -457,18 +422,18 @@ void Bed3D::render_texture(const std::string& filename, bool bottom, GLCanvas3D&
|
||||
}
|
||||
|
||||
// starts generating the main texture, compression will run asynchronously
|
||||
if (!m_texture.load_from_svg_file(filename, true, true, true, max_tex_size))
|
||||
if (!m_texture.load_from_svg_file(m_texture_filename, true, true, true, max_tex_size))
|
||||
{
|
||||
render_default(bottom);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (boost::algorithm::iends_with(filename, ".png"))
|
||||
else if (boost::algorithm::iends_with(m_texture_filename, ".png"))
|
||||
{
|
||||
// generate a temporary lower resolution texture to show while no main texture levels have been compressed
|
||||
if ((m_temp_texture.get_id() == 0) || (m_temp_texture.get_source() != filename))
|
||||
if ((m_temp_texture.get_id() == 0) || (m_temp_texture.get_source() != m_texture_filename))
|
||||
{
|
||||
if (!m_temp_texture.load_from_file(filename, false, GLTexture::None, false))
|
||||
if (!m_temp_texture.load_from_file(m_texture_filename, false, GLTexture::None, false))
|
||||
{
|
||||
render_default(bottom);
|
||||
return;
|
||||
@ -477,7 +442,7 @@ void Bed3D::render_texture(const std::string& filename, bool bottom, GLCanvas3D&
|
||||
}
|
||||
|
||||
// starts generating the main texture, compression will run asynchronously
|
||||
if (!m_texture.load_from_file(filename, true, GLTexture::MultiThreaded, true))
|
||||
if (!m_texture.load_from_file(m_texture_filename, true, GLTexture::MultiThreaded, true))
|
||||
{
|
||||
render_default(bottom);
|
||||
return;
|
||||
@ -576,12 +541,12 @@ void Bed3D::render_texture(const std::string& filename, bool bottom, GLCanvas3D&
|
||||
}
|
||||
}
|
||||
|
||||
void Bed3D::render_model(const std::string& filename) const
|
||||
void Bed3D::render_model() const
|
||||
{
|
||||
if (filename.empty())
|
||||
if (m_model_filename.empty())
|
||||
return;
|
||||
|
||||
if ((m_model.get_filename() != filename) && m_model.init_from_file(filename))
|
||||
if ((m_model.get_filename() != m_model_filename) && m_model.init_from_file(m_model_filename))
|
||||
{
|
||||
// move the model so that its origin (0.0, 0.0, 0.0) goes into the bed shape center and a bit down to avoid z-fighting with the texture quad
|
||||
Vec3d shift = m_bounding_box.center();
|
||||
@ -602,16 +567,16 @@ void Bed3D::render_model(const std::string& filename) const
|
||||
|
||||
void Bed3D::render_custom(GLCanvas3D& canvas, bool bottom) const
|
||||
{
|
||||
if (m_custom_texture.empty() && m_custom_model.empty())
|
||||
if (m_texture_filename.empty() && m_model_filename.empty())
|
||||
{
|
||||
render_default(bottom);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!bottom)
|
||||
render_model(m_custom_model);
|
||||
render_model();
|
||||
|
||||
render_texture(m_custom_texture, bottom, canvas);
|
||||
render_texture(bottom, canvas);
|
||||
}
|
||||
|
||||
void Bed3D::render_default(bool bottom) const
|
||||
|
@ -5,6 +5,8 @@
|
||||
#include "3DScene.hpp"
|
||||
#include "GLShader.hpp"
|
||||
|
||||
#include <tuple>
|
||||
|
||||
class GLUquadric;
|
||||
typedef class GLUquadric GLUquadricObj;
|
||||
|
||||
@ -64,11 +66,7 @@ class Bed3D
|
||||
public:
|
||||
enum EType : unsigned char
|
||||
{
|
||||
MK2,
|
||||
MK3,
|
||||
SL1,
|
||||
MINI,
|
||||
ENDER3,
|
||||
System,
|
||||
Custom,
|
||||
Num_Types
|
||||
};
|
||||
@ -76,19 +74,19 @@ public:
|
||||
private:
|
||||
EType m_type;
|
||||
Pointfs m_shape;
|
||||
std::string m_custom_texture;
|
||||
std::string m_custom_model;
|
||||
std::string m_texture_filename;
|
||||
std::string m_model_filename;
|
||||
mutable BoundingBoxf3 m_bounding_box;
|
||||
mutable BoundingBoxf3 m_extended_bounding_box;
|
||||
Polygon m_polygon;
|
||||
GeometryBuffer m_triangles;
|
||||
GeometryBuffer m_gridlines;
|
||||
mutable GLTexture m_texture;
|
||||
mutable GLBed m_model;
|
||||
// temporary texture shown until the main texture has still no levels compressed
|
||||
mutable GLTexture m_temp_texture;
|
||||
mutable Shader m_shader;
|
||||
mutable unsigned int m_vbo_id;
|
||||
mutable GLBed m_model;
|
||||
Axes m_axes;
|
||||
|
||||
mutable float m_scale_factor;
|
||||
@ -99,7 +97,6 @@ public:
|
||||
|
||||
EType get_type() const { return m_type; }
|
||||
|
||||
bool is_prusa() const { return (m_type == MK2) || (m_type == MK3) || (m_type == SL1); }
|
||||
bool is_custom() const { return m_type == Custom; }
|
||||
|
||||
const Pointfs& get_shape() const { return m_shape; }
|
||||
@ -116,11 +113,11 @@ private:
|
||||
void calc_bounding_boxes() const;
|
||||
void calc_triangles(const ExPolygon& poly);
|
||||
void calc_gridlines(const ExPolygon& poly, const BoundingBox& bed_bbox);
|
||||
EType detect_type(const Pointfs& shape) const;
|
||||
std::tuple<EType, std::string, std::string> detect_type(const Pointfs& shape) const;
|
||||
void render_axes() const;
|
||||
void render_prusa(GLCanvas3D& canvas, const std::string& key, bool bottom) const;
|
||||
void render_texture(const std::string& filename, bool bottom, GLCanvas3D& canvas) const;
|
||||
void render_model(const std::string& filename) const;
|
||||
void render_system(GLCanvas3D& canvas, bool bottom) const;
|
||||
void render_texture(bool bottom, GLCanvas3D& canvas) const;
|
||||
void render_model() const;
|
||||
void render_custom(GLCanvas3D& canvas, bool bottom) const;
|
||||
void render_default(bool bottom) const;
|
||||
void reset();
|
||||
|