ENABLE_GCODE_VIEWER set as default in:
3DScene hpp/cpp AboutDialog.cpp BackgroundSlicingProcess hpp/cpp BitmapCache.cpp ConfigWizard_private.hpp GUI_App hpp/cpp GUI_Init.cpp
This commit is contained in:
parent
2ea00cf916
commit
faff112ea8
@ -993,290 +993,6 @@ bool GLVolumeCollection::has_toolpaths_to_export() const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !ENABLE_GCODE_VIEWER
|
|
||||||
void GLVolumeCollection::export_toolpaths_to_obj(const char* filename) const
|
|
||||||
{
|
|
||||||
if (filename == nullptr)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!has_toolpaths_to_export())
|
|
||||||
return;
|
|
||||||
|
|
||||||
// collect color information to generate materials
|
|
||||||
typedef std::array<float, 4> Color;
|
|
||||||
std::set<Color> colors;
|
|
||||||
for (const GLVolume* volume : this->volumes)
|
|
||||||
{
|
|
||||||
if (!can_export_to_obj(*volume))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
Color color;
|
|
||||||
::memcpy((void*)color.data(), (const void*)volume->color, 4 * sizeof(float));
|
|
||||||
colors.insert(color);
|
|
||||||
}
|
|
||||||
|
|
||||||
// save materials file
|
|
||||||
boost::filesystem::path mat_filename(filename);
|
|
||||||
mat_filename.replace_extension("mtl");
|
|
||||||
FILE* fp = boost::nowide::fopen(mat_filename.string().c_str(), "w");
|
|
||||||
if (fp == nullptr) {
|
|
||||||
BOOST_LOG_TRIVIAL(error) << "GLVolumeCollection::export_toolpaths_to_obj: Couldn't open " << mat_filename.string().c_str() << " for writing";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf(fp, "# G-Code Toolpaths Materials\n");
|
|
||||||
fprintf(fp, "# Generated by %s based on Slic3r\n", SLIC3R_BUILD_ID);
|
|
||||||
|
|
||||||
unsigned int colors_count = 1;
|
|
||||||
for (const Color& color : colors)
|
|
||||||
{
|
|
||||||
fprintf(fp, "\nnewmtl material_%d\n", colors_count++);
|
|
||||||
fprintf(fp, "Ka 1 1 1\n");
|
|
||||||
fprintf(fp, "Kd %f %f %f\n", color[0], color[1], color[2]);
|
|
||||||
fprintf(fp, "Ks 0 0 0\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
fclose(fp);
|
|
||||||
|
|
||||||
// save geometry file
|
|
||||||
fp = boost::nowide::fopen(filename, "w");
|
|
||||||
if (fp == nullptr) {
|
|
||||||
BOOST_LOG_TRIVIAL(error) << "GLVolumeCollection::export_toolpaths_to_obj: Couldn't open " << filename << " for writing";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf(fp, "# G-Code Toolpaths\n");
|
|
||||||
fprintf(fp, "# Generated by %s based on Slic3r\n", SLIC3R_BUILD_ID);
|
|
||||||
fprintf(fp, "\nmtllib ./%s\n", mat_filename.filename().string().c_str());
|
|
||||||
|
|
||||||
unsigned int vertices_count = 0;
|
|
||||||
unsigned int normals_count = 0;
|
|
||||||
unsigned int volumes_count = 0;
|
|
||||||
|
|
||||||
for (const GLVolume* volume : this->volumes)
|
|
||||||
{
|
|
||||||
if (!can_export_to_obj(*volume))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
std::vector<float> src_vertices_and_normals_interleaved;
|
|
||||||
std::vector<int> src_triangle_indices;
|
|
||||||
std::vector<int> src_quad_indices;
|
|
||||||
|
|
||||||
if (!volume->indexed_vertex_array.vertices_and_normals_interleaved.empty())
|
|
||||||
// data are in CPU memory
|
|
||||||
src_vertices_and_normals_interleaved = volume->indexed_vertex_array.vertices_and_normals_interleaved;
|
|
||||||
else if ((volume->indexed_vertex_array.vertices_and_normals_interleaved_VBO_id != 0) && (volume->indexed_vertex_array.vertices_and_normals_interleaved_size != 0))
|
|
||||||
{
|
|
||||||
// data are in GPU memory
|
|
||||||
src_vertices_and_normals_interleaved = std::vector<float>(volume->indexed_vertex_array.vertices_and_normals_interleaved_size, 0.0f);
|
|
||||||
|
|
||||||
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, volume->indexed_vertex_array.vertices_and_normals_interleaved_VBO_id));
|
|
||||||
glsafe(::glGetBufferSubData(GL_ARRAY_BUFFER, 0, src_vertices_and_normals_interleaved.size() * sizeof(float), src_vertices_and_normals_interleaved.data()));
|
|
||||||
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, 0));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!volume->indexed_vertex_array.triangle_indices.empty())
|
|
||||||
{
|
|
||||||
// data are in CPU memory
|
|
||||||
size_t size = std::min(volume->indexed_vertex_array.triangle_indices.size(), volume->tverts_range.second - volume->tverts_range.first);
|
|
||||||
if (size != 0)
|
|
||||||
{
|
|
||||||
std::vector<int>::const_iterator it_begin = volume->indexed_vertex_array.triangle_indices.begin() + volume->tverts_range.first;
|
|
||||||
std::vector<int>::const_iterator it_end = volume->indexed_vertex_array.triangle_indices.begin() + volume->tverts_range.first + size;
|
|
||||||
std::copy(it_begin, it_end, std::back_inserter(src_triangle_indices));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ((volume->indexed_vertex_array.triangle_indices_VBO_id != 0) && (volume->indexed_vertex_array.triangle_indices_size != 0))
|
|
||||||
{
|
|
||||||
// data are in GPU memory
|
|
||||||
size_t size = std::min(volume->indexed_vertex_array.triangle_indices_size, volume->tverts_range.second - volume->tverts_range.first);
|
|
||||||
if (size != 0)
|
|
||||||
{
|
|
||||||
src_triangle_indices = std::vector<int>(size, 0);
|
|
||||||
|
|
||||||
glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, volume->indexed_vertex_array.triangle_indices_VBO_id));
|
|
||||||
glsafe(::glGetBufferSubData(GL_ELEMENT_ARRAY_BUFFER, volume->tverts_range.first * sizeof(int), size * sizeof(int), src_triangle_indices.data()));
|
|
||||||
glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!volume->indexed_vertex_array.quad_indices.empty())
|
|
||||||
{
|
|
||||||
// data are in CPU memory
|
|
||||||
size_t size = std::min(volume->indexed_vertex_array.quad_indices.size(), volume->qverts_range.second - volume->qverts_range.first);
|
|
||||||
if (size != 0)
|
|
||||||
{
|
|
||||||
std::vector<int>::const_iterator it_begin = volume->indexed_vertex_array.quad_indices.begin() + volume->qverts_range.first;
|
|
||||||
std::vector<int>::const_iterator it_end = volume->indexed_vertex_array.quad_indices.begin() + volume->qverts_range.first + size;
|
|
||||||
std::copy(it_begin, it_end, std::back_inserter(src_quad_indices));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ((volume->indexed_vertex_array.quad_indices_VBO_id != 0) && (volume->indexed_vertex_array.quad_indices_size != 0))
|
|
||||||
{
|
|
||||||
// data are in GPU memory
|
|
||||||
size_t size = std::min(volume->indexed_vertex_array.quad_indices_size, volume->qverts_range.second - volume->qverts_range.first);
|
|
||||||
if (size != 0)
|
|
||||||
{
|
|
||||||
src_quad_indices = std::vector<int>(size, 0);
|
|
||||||
|
|
||||||
glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, volume->indexed_vertex_array.quad_indices_VBO_id));
|
|
||||||
glsafe(::glGetBufferSubData(GL_ELEMENT_ARRAY_BUFFER, volume->qverts_range.first * sizeof(int), size * sizeof(int), src_quad_indices.data()));
|
|
||||||
glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (src_triangle_indices.empty() && src_quad_indices.empty())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
++volumes_count;
|
|
||||||
|
|
||||||
// reduce output size by keeping only used vertices and normals
|
|
||||||
|
|
||||||
struct Vector
|
|
||||||
{
|
|
||||||
std::array<coord_t, 3> vector;
|
|
||||||
|
|
||||||
explicit Vector(float* ptr)
|
|
||||||
{
|
|
||||||
vector[0] = scale_(*(ptr + 0));
|
|
||||||
vector[1] = scale_(*(ptr + 1));
|
|
||||||
vector[2] = scale_(*(ptr + 2));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
typedef std::vector<Vector> Vectors;
|
|
||||||
|
|
||||||
auto vector_less = [](const Vector& v1, const Vector& v2)->bool {
|
|
||||||
return v1.vector < v2.vector;
|
|
||||||
};
|
|
||||||
|
|
||||||
auto vector_equal = [](const Vector& v1, const Vector& v2)->bool {
|
|
||||||
return (v1.vector[0] == v2.vector[0]) && (v1.vector[1] == v2.vector[1]) && (v1.vector[2] == v2.vector[2]);
|
|
||||||
};
|
|
||||||
|
|
||||||
// copy used vertices and normals data
|
|
||||||
Vectors dst_normals;
|
|
||||||
Vectors dst_vertices;
|
|
||||||
|
|
||||||
unsigned int src_triangle_indices_size = (unsigned int)src_triangle_indices.size();
|
|
||||||
for (unsigned int i = 0; i < src_triangle_indices_size; ++i)
|
|
||||||
{
|
|
||||||
float* src_ptr = src_vertices_and_normals_interleaved.data() + src_triangle_indices[i] * 6;
|
|
||||||
dst_normals.emplace_back(src_ptr + 0);
|
|
||||||
dst_vertices.emplace_back(src_ptr + 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int src_quad_indices_size = (unsigned int)src_quad_indices.size();
|
|
||||||
for (unsigned int i = 0; i < src_quad_indices_size; ++i)
|
|
||||||
{
|
|
||||||
float* src_ptr = src_vertices_and_normals_interleaved.data() + src_quad_indices[i] * 6;
|
|
||||||
dst_normals.emplace_back(src_ptr + 0);
|
|
||||||
dst_vertices.emplace_back(src_ptr + 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
// sort vertices and normals
|
|
||||||
std::sort(dst_normals.begin(), dst_normals.end(), vector_less);
|
|
||||||
std::sort(dst_vertices.begin(), dst_vertices.end(), vector_less);
|
|
||||||
|
|
||||||
// remove duplicated vertices and normals
|
|
||||||
dst_normals.erase(std::unique(dst_normals.begin(), dst_normals.end(), vector_equal), dst_normals.end());
|
|
||||||
dst_vertices.erase(std::unique(dst_vertices.begin(), dst_vertices.end(), vector_equal), dst_vertices.end());
|
|
||||||
|
|
||||||
// reindex triangles and quads
|
|
||||||
struct IndicesPair
|
|
||||||
{
|
|
||||||
int vertex;
|
|
||||||
int normal;
|
|
||||||
IndicesPair(int vertex, int normal) : vertex(vertex), normal(normal) {}
|
|
||||||
};
|
|
||||||
typedef std::vector<IndicesPair> Indices;
|
|
||||||
|
|
||||||
unsigned int src_vertices_count = (unsigned int)src_vertices_and_normals_interleaved.size() / 6;
|
|
||||||
std::vector<int> src_dst_vertex_indices_map(src_vertices_count, -1);
|
|
||||||
std::vector<int> src_dst_normal_indices_map(src_vertices_count, -1);
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < src_vertices_count; ++i)
|
|
||||||
{
|
|
||||||
float* src_ptr = src_vertices_and_normals_interleaved.data() + i * 6;
|
|
||||||
src_dst_normal_indices_map[i] = std::distance(dst_normals.begin(), std::lower_bound(dst_normals.begin(), dst_normals.end(), Vector(src_ptr + 0), vector_less));
|
|
||||||
src_dst_vertex_indices_map[i] = std::distance(dst_vertices.begin(), std::lower_bound(dst_vertices.begin(), dst_vertices.end(), Vector(src_ptr + 3), vector_less));
|
|
||||||
}
|
|
||||||
|
|
||||||
Indices dst_triangle_indices;
|
|
||||||
if (src_triangle_indices_size > 0)
|
|
||||||
dst_triangle_indices.reserve(src_triangle_indices_size);
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < src_triangle_indices_size; ++i)
|
|
||||||
{
|
|
||||||
int id = src_triangle_indices[i];
|
|
||||||
dst_triangle_indices.emplace_back(src_dst_vertex_indices_map[id], src_dst_normal_indices_map[id]);
|
|
||||||
}
|
|
||||||
|
|
||||||
Indices dst_quad_indices;
|
|
||||||
if (src_quad_indices_size > 0)
|
|
||||||
dst_quad_indices.reserve(src_quad_indices_size);
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < src_quad_indices_size; ++i)
|
|
||||||
{
|
|
||||||
int id = src_quad_indices[i];
|
|
||||||
dst_quad_indices.emplace_back(src_dst_vertex_indices_map[id], src_dst_normal_indices_map[id]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// save to file
|
|
||||||
fprintf(fp, "\n# vertices volume %d\n", volumes_count);
|
|
||||||
for (const Vector& v : dst_vertices)
|
|
||||||
{
|
|
||||||
fprintf(fp, "v %g %g %g\n", unscale<float>(v.vector[0]), unscale<float>(v.vector[1]), unscale<float>(v.vector[2]));
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf(fp, "\n# normals volume %d\n", volumes_count);
|
|
||||||
for (const Vector& n : dst_normals)
|
|
||||||
{
|
|
||||||
fprintf(fp, "vn %g %g %g\n", unscale<float>(n.vector[0]), unscale<float>(n.vector[1]), unscale<float>(n.vector[2]));
|
|
||||||
}
|
|
||||||
|
|
||||||
Color color;
|
|
||||||
::memcpy((void*)color.data(), (const void*)volume->color, 4 * sizeof(float));
|
|
||||||
fprintf(fp, "\n# material volume %d\n", volumes_count);
|
|
||||||
fprintf(fp, "usemtl material_%lld\n", (long long)(1 + std::distance(colors.begin(), colors.find(color))));
|
|
||||||
|
|
||||||
int base_vertex_id = vertices_count + 1;
|
|
||||||
int base_normal_id = normals_count + 1;
|
|
||||||
|
|
||||||
if (!dst_triangle_indices.empty())
|
|
||||||
{
|
|
||||||
fprintf(fp, "\n# triangular facets volume %d\n", volumes_count);
|
|
||||||
for (unsigned int i = 0; i < (unsigned int)dst_triangle_indices.size(); i += 3)
|
|
||||||
{
|
|
||||||
fprintf(fp, "f %d//%d %d//%d %d//%d\n",
|
|
||||||
base_vertex_id + dst_triangle_indices[i + 0].vertex, base_normal_id + dst_triangle_indices[i + 0].normal,
|
|
||||||
base_vertex_id + dst_triangle_indices[i + 1].vertex, base_normal_id + dst_triangle_indices[i + 1].normal,
|
|
||||||
base_vertex_id + dst_triangle_indices[i + 2].vertex, base_normal_id + dst_triangle_indices[i + 2].normal);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!dst_quad_indices.empty())
|
|
||||||
{
|
|
||||||
fprintf(fp, "\n# quadrangular facets volume %d\n", volumes_count);
|
|
||||||
for (unsigned int i = 0; i < (unsigned int)src_quad_indices.size(); i += 4)
|
|
||||||
{
|
|
||||||
fprintf(fp, "f %d//%d %d//%d %d//%d %d//%d\n",
|
|
||||||
base_vertex_id + dst_quad_indices[i + 0].vertex, base_normal_id + dst_quad_indices[i + 0].normal,
|
|
||||||
base_vertex_id + dst_quad_indices[i + 1].vertex, base_normal_id + dst_quad_indices[i + 1].normal,
|
|
||||||
base_vertex_id + dst_quad_indices[i + 2].vertex, base_normal_id + dst_quad_indices[i + 2].normal,
|
|
||||||
base_vertex_id + dst_quad_indices[i + 3].vertex, base_normal_id + dst_quad_indices[i + 3].normal);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
vertices_count += (unsigned int)dst_vertices.size();
|
|
||||||
normals_count += (unsigned int)dst_normals.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
fclose(fp);
|
|
||||||
}
|
|
||||||
#endif // !ENABLE_GCODE_VIEWER
|
|
||||||
|
|
||||||
// caller is responsible for supplying NO lines with zero length
|
// caller is responsible for supplying NO lines with zero length
|
||||||
static void thick_lines_to_indexed_vertex_array(
|
static void thick_lines_to_indexed_vertex_array(
|
||||||
const Lines &lines,
|
const Lines &lines,
|
||||||
@ -1923,287 +1639,4 @@ void _3DScene::point3_to_verts(const Vec3crd& point, double width, double height
|
|||||||
thick_point_to_verts(point, width, height, volume);
|
thick_point_to_verts(point, width, height, volume);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !ENABLE_GCODE_VIEWER
|
|
||||||
GLModel::GLModel()
|
|
||||||
: m_filename("")
|
|
||||||
{
|
|
||||||
m_volume.shader_outside_printer_detection_enabled = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
GLModel::~GLModel()
|
|
||||||
{
|
|
||||||
reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLModel::set_color(const float* color, unsigned int size)
|
|
||||||
{
|
|
||||||
::memcpy((void*)m_volume.color, (const void*)color, (size_t)(std::min((unsigned int)4, size) * sizeof(float)));
|
|
||||||
m_volume.set_render_color(color, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
const Vec3d& GLModel::get_offset() const
|
|
||||||
{
|
|
||||||
return m_volume.get_volume_offset();
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLModel::set_offset(const Vec3d& offset)
|
|
||||||
{
|
|
||||||
m_volume.set_volume_offset(offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
const Vec3d& GLModel::get_rotation() const
|
|
||||||
{
|
|
||||||
return m_volume.get_volume_rotation();
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLModel::set_rotation(const Vec3d& rotation)
|
|
||||||
{
|
|
||||||
m_volume.set_volume_rotation(rotation);
|
|
||||||
}
|
|
||||||
|
|
||||||
const Vec3d& GLModel::get_scale() const
|
|
||||||
{
|
|
||||||
return m_volume.get_volume_scaling_factor();
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLModel::set_scale(const Vec3d& scale)
|
|
||||||
{
|
|
||||||
m_volume.set_volume_scaling_factor(scale);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLModel::reset()
|
|
||||||
{
|
|
||||||
m_volume.indexed_vertex_array.release_geometry();
|
|
||||||
m_filename = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLModel::render() const
|
|
||||||
{
|
|
||||||
GLShaderProgram* shader = GUI::wxGetApp().get_current_shader();
|
|
||||||
if (shader == nullptr)
|
|
||||||
return;
|
|
||||||
|
|
||||||
glsafe(::glEnable(GL_BLEND));
|
|
||||||
glsafe(::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));
|
|
||||||
|
|
||||||
glsafe(::glCullFace(GL_BACK));
|
|
||||||
glsafe(::glEnableClientState(GL_VERTEX_ARRAY));
|
|
||||||
glsafe(::glEnableClientState(GL_NORMAL_ARRAY));
|
|
||||||
|
|
||||||
shader->set_uniform("uniform_color", m_volume.render_color, 4);
|
|
||||||
m_volume.render();
|
|
||||||
|
|
||||||
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, 0));
|
|
||||||
glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0));
|
|
||||||
|
|
||||||
glsafe(::glDisableClientState(GL_VERTEX_ARRAY));
|
|
||||||
glsafe(::glDisableClientState(GL_NORMAL_ARRAY));
|
|
||||||
|
|
||||||
glsafe(::glDisable(GL_BLEND));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GLArrow::on_init()
|
|
||||||
{
|
|
||||||
Pointf3s vertices;
|
|
||||||
std::vector<Vec3i> triangles;
|
|
||||||
|
|
||||||
// bottom face
|
|
||||||
vertices.emplace_back(0.5, 0.0, -0.1);
|
|
||||||
vertices.emplace_back(0.5, 2.0, -0.1);
|
|
||||||
vertices.emplace_back(1.0, 2.0, -0.1);
|
|
||||||
vertices.emplace_back(0.0, 3.0, -0.1);
|
|
||||||
vertices.emplace_back(-1.0, 2.0, -0.1);
|
|
||||||
vertices.emplace_back(-0.5, 2.0, -0.1);
|
|
||||||
vertices.emplace_back(-0.5, 0.0, -0.1);
|
|
||||||
|
|
||||||
// top face
|
|
||||||
vertices.emplace_back(0.5, 0.0, 0.1);
|
|
||||||
vertices.emplace_back(0.5, 2.0, 0.1);
|
|
||||||
vertices.emplace_back(1.0, 2.0, 0.1);
|
|
||||||
vertices.emplace_back(0.0, 3.0, 0.1);
|
|
||||||
vertices.emplace_back(-1.0, 2.0, 0.1);
|
|
||||||
vertices.emplace_back(-0.5, 2.0, 0.1);
|
|
||||||
vertices.emplace_back(-0.5, 0.0, 0.1);
|
|
||||||
|
|
||||||
// bottom face
|
|
||||||
triangles.emplace_back(0, 6, 1);
|
|
||||||
triangles.emplace_back(6, 5, 1);
|
|
||||||
triangles.emplace_back(5, 4, 3);
|
|
||||||
triangles.emplace_back(5, 3, 1);
|
|
||||||
triangles.emplace_back(1, 3, 2);
|
|
||||||
|
|
||||||
// top face
|
|
||||||
triangles.emplace_back(7, 8, 13);
|
|
||||||
triangles.emplace_back(13, 8, 12);
|
|
||||||
triangles.emplace_back(12, 10, 11);
|
|
||||||
triangles.emplace_back(8, 10, 12);
|
|
||||||
triangles.emplace_back(8, 9, 10);
|
|
||||||
|
|
||||||
// side face
|
|
||||||
triangles.emplace_back(0, 1, 8);
|
|
||||||
triangles.emplace_back(8, 7, 0);
|
|
||||||
triangles.emplace_back(1, 2, 9);
|
|
||||||
triangles.emplace_back(9, 8, 1);
|
|
||||||
triangles.emplace_back(2, 3, 10);
|
|
||||||
triangles.emplace_back(10, 9, 2);
|
|
||||||
triangles.emplace_back(3, 4, 11);
|
|
||||||
triangles.emplace_back(11, 10, 3);
|
|
||||||
triangles.emplace_back(4, 5, 12);
|
|
||||||
triangles.emplace_back(12, 11, 4);
|
|
||||||
triangles.emplace_back(5, 6, 13);
|
|
||||||
triangles.emplace_back(13, 12, 5);
|
|
||||||
triangles.emplace_back(6, 0, 7);
|
|
||||||
triangles.emplace_back(7, 13, 6);
|
|
||||||
|
|
||||||
m_volume.indexed_vertex_array.load_mesh(TriangleMesh(vertices, triangles));
|
|
||||||
m_volume.indexed_vertex_array.finalize_geometry(true);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
GLCurvedArrow::GLCurvedArrow(unsigned int resolution)
|
|
||||||
: GLModel()
|
|
||||||
, m_resolution(resolution)
|
|
||||||
{
|
|
||||||
if (m_resolution == 0)
|
|
||||||
m_resolution = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GLCurvedArrow::on_init()
|
|
||||||
{
|
|
||||||
Pointf3s vertices;
|
|
||||||
std::vector<Vec3i> triangles;
|
|
||||||
|
|
||||||
double ext_radius = 2.5;
|
|
||||||
double int_radius = 1.5;
|
|
||||||
double step = 0.5 * (double)PI / (double)m_resolution;
|
|
||||||
|
|
||||||
unsigned int vertices_per_level = 4 + 2 * m_resolution;
|
|
||||||
|
|
||||||
// bottom face
|
|
||||||
vertices.emplace_back(0.0, 1.5, -0.1);
|
|
||||||
vertices.emplace_back(0.0, 1.0, -0.1);
|
|
||||||
vertices.emplace_back(-1.0, 2.0, -0.1);
|
|
||||||
vertices.emplace_back(0.0, 3.0, -0.1);
|
|
||||||
vertices.emplace_back(0.0, 2.5, -0.1);
|
|
||||||
|
|
||||||
for (unsigned int i = 1; i <= m_resolution; ++i)
|
|
||||||
{
|
|
||||||
double angle = (double)i * step;
|
|
||||||
double x = ext_radius * ::sin(angle);
|
|
||||||
double y = ext_radius * ::cos(angle);
|
|
||||||
|
|
||||||
vertices.emplace_back(x, y, -0.1);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < m_resolution; ++i)
|
|
||||||
{
|
|
||||||
double angle = (double)i * step;
|
|
||||||
double x = int_radius * ::cos(angle);
|
|
||||||
double y = int_radius * ::sin(angle);
|
|
||||||
|
|
||||||
vertices.emplace_back(x, y, -0.1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// top face
|
|
||||||
vertices.emplace_back(0.0, 1.5, 0.1);
|
|
||||||
vertices.emplace_back(0.0, 1.0, 0.1);
|
|
||||||
vertices.emplace_back(-1.0, 2.0, 0.1);
|
|
||||||
vertices.emplace_back(0.0, 3.0, 0.1);
|
|
||||||
vertices.emplace_back(0.0, 2.5, 0.1);
|
|
||||||
|
|
||||||
for (unsigned int i = 1; i <= m_resolution; ++i)
|
|
||||||
{
|
|
||||||
double angle = (double)i * step;
|
|
||||||
double x = ext_radius * ::sin(angle);
|
|
||||||
double y = ext_radius * ::cos(angle);
|
|
||||||
|
|
||||||
vertices.emplace_back(x, y, 0.1);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < m_resolution; ++i)
|
|
||||||
{
|
|
||||||
double angle = (double)i * step;
|
|
||||||
double x = int_radius * ::cos(angle);
|
|
||||||
double y = int_radius * ::sin(angle);
|
|
||||||
|
|
||||||
vertices.emplace_back(x, y, 0.1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// bottom face
|
|
||||||
triangles.emplace_back(0, 1, 2);
|
|
||||||
triangles.emplace_back(0, 2, 4);
|
|
||||||
triangles.emplace_back(4, 2, 3);
|
|
||||||
|
|
||||||
int first_id = 4;
|
|
||||||
int last_id = (int)vertices_per_level;
|
|
||||||
triangles.emplace_back(last_id, 0, first_id);
|
|
||||||
triangles.emplace_back(last_id, first_id, first_id + 1);
|
|
||||||
for (unsigned int i = 1; i < m_resolution; ++i)
|
|
||||||
{
|
|
||||||
triangles.emplace_back(last_id - i, last_id - i + 1, first_id + i);
|
|
||||||
triangles.emplace_back(last_id - i, first_id + i, first_id + i + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// top face
|
|
||||||
last_id += 1;
|
|
||||||
triangles.emplace_back(last_id + 0, last_id + 2, last_id + 1);
|
|
||||||
triangles.emplace_back(last_id + 0, last_id + 4, last_id + 2);
|
|
||||||
triangles.emplace_back(last_id + 4, last_id + 3, last_id + 2);
|
|
||||||
|
|
||||||
first_id = last_id + 4;
|
|
||||||
last_id = last_id + 4 + 2 * (int)m_resolution;
|
|
||||||
triangles.emplace_back(last_id, first_id, (int)vertices_per_level + 1);
|
|
||||||
triangles.emplace_back(last_id, first_id + 1, first_id);
|
|
||||||
for (unsigned int i = 1; i < m_resolution; ++i)
|
|
||||||
{
|
|
||||||
triangles.emplace_back(last_id - i, first_id + i, last_id - i + 1);
|
|
||||||
triangles.emplace_back(last_id - i, first_id + i + 1, first_id + i);
|
|
||||||
}
|
|
||||||
|
|
||||||
// side face
|
|
||||||
for (unsigned int i = 0; i < 4 + 2 * (unsigned int)m_resolution; ++i)
|
|
||||||
{
|
|
||||||
triangles.emplace_back(i, vertices_per_level + 2 + i, i + 1);
|
|
||||||
triangles.emplace_back(i, vertices_per_level + 1 + i, vertices_per_level + 2 + i);
|
|
||||||
}
|
|
||||||
triangles.emplace_back(vertices_per_level, vertices_per_level + 1, 0);
|
|
||||||
triangles.emplace_back(vertices_per_level, 2 * vertices_per_level + 1, vertices_per_level + 1);
|
|
||||||
|
|
||||||
m_volume.indexed_vertex_array.load_mesh(TriangleMesh(vertices, triangles));
|
|
||||||
m_volume.indexed_vertex_array.finalize_geometry(true);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GLBed::on_init_from_file(const std::string& filename)
|
|
||||||
{
|
|
||||||
reset();
|
|
||||||
|
|
||||||
if (!boost::filesystem::exists(filename))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (!boost::algorithm::iends_with(filename, ".stl"))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
Model model;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
model = Model::read_from_file(filename);
|
|
||||||
}
|
|
||||||
catch (std::exception & /* ex */)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_filename = filename;
|
|
||||||
|
|
||||||
m_volume.indexed_vertex_array.load_mesh(model.mesh());
|
|
||||||
m_volume.indexed_vertex_array.finalize_geometry(true);
|
|
||||||
|
|
||||||
float color[4] = { 0.235f, 0.235f, 0.235f, 1.0f };
|
|
||||||
set_color(color, 4);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
#endif // !ENABLE_GCODE_VIEWER
|
|
||||||
|
|
||||||
} // namespace Slic3r
|
} // namespace Slic3r
|
||||||
|
@ -588,10 +588,6 @@ public:
|
|||||||
std::string log_memory_info() const;
|
std::string log_memory_info() const;
|
||||||
|
|
||||||
bool has_toolpaths_to_export() const;
|
bool has_toolpaths_to_export() const;
|
||||||
#if !ENABLE_GCODE_VIEWER
|
|
||||||
// Export the geometry of the GLVolumes toolpaths of this collection into the file with the given path, in obj format
|
|
||||||
void export_toolpaths_to_obj(const char* filename) const;
|
|
||||||
#endif // !ENABLE_GCODE_VIEWER
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GLVolumeCollection(const GLVolumeCollection &other);
|
GLVolumeCollection(const GLVolumeCollection &other);
|
||||||
@ -600,68 +596,6 @@ private:
|
|||||||
|
|
||||||
GLVolumeWithIdAndZList volumes_to_render(const GLVolumePtrs& volumes, GLVolumeCollection::ERenderType type, const Transform3d& view_matrix, std::function<bool(const GLVolume&)> filter_func = nullptr);
|
GLVolumeWithIdAndZList volumes_to_render(const GLVolumePtrs& volumes, GLVolumeCollection::ERenderType type, const Transform3d& view_matrix, std::function<bool(const GLVolume&)> filter_func = nullptr);
|
||||||
|
|
||||||
#if !ENABLE_GCODE_VIEWER
|
|
||||||
class GLModel
|
|
||||||
{
|
|
||||||
protected:
|
|
||||||
GLVolume m_volume;
|
|
||||||
std::string m_filename;
|
|
||||||
|
|
||||||
public:
|
|
||||||
GLModel();
|
|
||||||
virtual ~GLModel();
|
|
||||||
|
|
||||||
// init() / init_from_file() shall be called with the OpenGL context active!
|
|
||||||
bool init() { return on_init(); }
|
|
||||||
bool init_from_file(const std::string& filename) { return on_init_from_file(filename); }
|
|
||||||
|
|
||||||
void center_around(const Vec3d& center) { m_volume.set_volume_offset(center - m_volume.bounding_box().center()); }
|
|
||||||
void set_color(const float* color, unsigned int size);
|
|
||||||
|
|
||||||
const Vec3d& get_offset() const;
|
|
||||||
void set_offset(const Vec3d& offset);
|
|
||||||
const Vec3d& get_rotation() const;
|
|
||||||
void set_rotation(const Vec3d& rotation);
|
|
||||||
const Vec3d& get_scale() const;
|
|
||||||
void set_scale(const Vec3d& scale);
|
|
||||||
|
|
||||||
const std::string& get_filename() const { return m_filename; }
|
|
||||||
const BoundingBoxf3& get_bounding_box() const { return m_volume.bounding_box(); }
|
|
||||||
const BoundingBoxf3& get_transformed_bounding_box() const { return m_volume.transformed_bounding_box(); }
|
|
||||||
|
|
||||||
void reset();
|
|
||||||
|
|
||||||
void render() const;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual bool on_init() { return false; }
|
|
||||||
virtual bool on_init_from_file(const std::string& filename) { return false; }
|
|
||||||
};
|
|
||||||
|
|
||||||
class GLArrow : public GLModel
|
|
||||||
{
|
|
||||||
protected:
|
|
||||||
bool on_init() override;
|
|
||||||
};
|
|
||||||
|
|
||||||
class GLCurvedArrow : public GLModel
|
|
||||||
{
|
|
||||||
unsigned int m_resolution;
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit GLCurvedArrow(unsigned int resolution);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
bool on_init() override;
|
|
||||||
};
|
|
||||||
|
|
||||||
class GLBed : public GLModel
|
|
||||||
{
|
|
||||||
protected:
|
|
||||||
bool on_init_from_file(const std::string& filename) override;
|
|
||||||
};
|
|
||||||
#endif // !ENABLE_GCODE_VIEWER
|
|
||||||
|
|
||||||
struct _3DScene
|
struct _3DScene
|
||||||
{
|
{
|
||||||
static void thick_lines_to_verts(const Lines& lines, const std::vector<double>& widths, const std::vector<double>& heights, bool closed, double top_z, GLVolume& volume);
|
static void thick_lines_to_verts(const Lines& lines, const std::vector<double>& widths, const std::vector<double>& heights, bool closed, double top_z, GLVolume& volume);
|
||||||
|
@ -37,17 +37,10 @@ void AboutDialogLogo::onRepaint(wxEvent &event)
|
|||||||
// CopyrightsDialog
|
// CopyrightsDialog
|
||||||
// -----------------------------------------
|
// -----------------------------------------
|
||||||
CopyrightsDialog::CopyrightsDialog()
|
CopyrightsDialog::CopyrightsDialog()
|
||||||
#if ENABLE_GCODE_VIEWER
|
|
||||||
: DPIDialog((wxWindow*)wxGetApp().mainframe, wxID_ANY, from_u8((boost::format("%1% - %2%")
|
: DPIDialog((wxWindow*)wxGetApp().mainframe, wxID_ANY, from_u8((boost::format("%1% - %2%")
|
||||||
% (wxGetApp().is_editor() ? SLIC3R_APP_NAME : GCODEVIEWER_APP_NAME)
|
% (wxGetApp().is_editor() ? SLIC3R_APP_NAME : GCODEVIEWER_APP_NAME)
|
||||||
% _utf8(L("Portions copyright"))).str()),
|
% _utf8(L("Portions copyright"))).str()),
|
||||||
wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
|
wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
|
||||||
#else
|
|
||||||
: DPIDialog((wxWindow*)wxGetApp().mainframe, wxID_ANY, from_u8((boost::format("%1% - %2%")
|
|
||||||
% SLIC3R_APP_NAME
|
|
||||||
% _utf8(L("Portions copyright"))).str()),
|
|
||||||
wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
|
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
|
||||||
{
|
{
|
||||||
this->SetFont(wxGetApp().normal_font());
|
this->SetFont(wxGetApp().normal_font());
|
||||||
this->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
|
this->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
|
||||||
@ -208,13 +201,8 @@ void CopyrightsDialog::onCloseDialog(wxEvent &)
|
|||||||
}
|
}
|
||||||
|
|
||||||
AboutDialog::AboutDialog()
|
AboutDialog::AboutDialog()
|
||||||
#if ENABLE_GCODE_VIEWER
|
|
||||||
: DPIDialog((wxWindow*)wxGetApp().mainframe, wxID_ANY, from_u8((boost::format(_utf8(L("About %s"))) % (wxGetApp().is_editor() ? SLIC3R_APP_NAME : GCODEVIEWER_APP_NAME)).str()), wxDefaultPosition,
|
: DPIDialog((wxWindow*)wxGetApp().mainframe, wxID_ANY, from_u8((boost::format(_utf8(L("About %s"))) % (wxGetApp().is_editor() ? SLIC3R_APP_NAME : GCODEVIEWER_APP_NAME)).str()), wxDefaultPosition,
|
||||||
wxDefaultSize, /*wxCAPTION*/wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
|
wxDefaultSize, /*wxCAPTION*/wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
|
||||||
#else
|
|
||||||
: DPIDialog((wxWindow*)wxGetApp().mainframe, wxID_ANY, from_u8((boost::format(_utf8(L("About %s"))) % SLIC3R_APP_NAME).str()), wxDefaultPosition,
|
|
||||||
wxDefaultSize, /*wxCAPTION*/wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
|
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
|
||||||
{
|
{
|
||||||
SetFont(wxGetApp().normal_font());
|
SetFont(wxGetApp().normal_font());
|
||||||
|
|
||||||
@ -226,11 +214,7 @@ AboutDialog::AboutDialog()
|
|||||||
main_sizer->Add(hsizer, 0, wxEXPAND | wxALL, 20);
|
main_sizer->Add(hsizer, 0, wxEXPAND | wxALL, 20);
|
||||||
|
|
||||||
// logo
|
// logo
|
||||||
#if ENABLE_GCODE_VIEWER
|
|
||||||
m_logo_bitmap = ScalableBitmap(this, wxGetApp().is_editor() ? "PrusaSlicer_192px.png" : "PrusaSlicer-gcodeviewer_192px.png", 192);
|
m_logo_bitmap = ScalableBitmap(this, wxGetApp().is_editor() ? "PrusaSlicer_192px.png" : "PrusaSlicer-gcodeviewer_192px.png", 192);
|
||||||
#else
|
|
||||||
m_logo_bitmap = ScalableBitmap(this, "PrusaSlicer_192px.png", 192);
|
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
|
||||||
m_logo = new wxStaticBitmap(this, wxID_ANY, m_logo_bitmap.bmp());
|
m_logo = new wxStaticBitmap(this, wxID_ANY, m_logo_bitmap.bmp());
|
||||||
hsizer->Add(m_logo, 1, wxALIGN_CENTER_VERTICAL);
|
hsizer->Add(m_logo, 1, wxALIGN_CENTER_VERTICAL);
|
||||||
|
|
||||||
@ -239,11 +223,7 @@ AboutDialog::AboutDialog()
|
|||||||
|
|
||||||
// title
|
// title
|
||||||
{
|
{
|
||||||
#if ENABLE_GCODE_VIEWER
|
|
||||||
wxStaticText* title = new wxStaticText(this, wxID_ANY, wxGetApp().is_editor() ? SLIC3R_APP_NAME : GCODEVIEWER_APP_NAME, wxDefaultPosition, wxDefaultSize);
|
wxStaticText* title = new wxStaticText(this, wxID_ANY, wxGetApp().is_editor() ? SLIC3R_APP_NAME : GCODEVIEWER_APP_NAME, wxDefaultPosition, wxDefaultSize);
|
||||||
#else
|
|
||||||
wxStaticText* title = new wxStaticText(this, wxID_ANY, SLIC3R_APP_NAME, wxDefaultPosition, wxDefaultSize);
|
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
|
||||||
wxFont title_font = GUI::wxGetApp().bold_font();
|
wxFont title_font = GUI::wxGetApp().bold_font();
|
||||||
title_font.SetFamily(wxFONTFAMILY_ROMAN);
|
title_font.SetFamily(wxFONTFAMILY_ROMAN);
|
||||||
title_font.SetPointSize(24);
|
title_font.SetPointSize(24);
|
||||||
@ -253,7 +233,7 @@ AboutDialog::AboutDialog()
|
|||||||
|
|
||||||
// version
|
// version
|
||||||
{
|
{
|
||||||
auto version_string = _L("Version")+ " " + std::string(SLIC3R_VERSION);
|
auto version_string = _L("Version") + " " + std::string(SLIC3R_VERSION);
|
||||||
wxStaticText* version = new wxStaticText(this, wxID_ANY, version_string.c_str(), wxDefaultPosition, wxDefaultSize);
|
wxStaticText* version = new wxStaticText(this, wxID_ANY, version_string.c_str(), wxDefaultPosition, wxDefaultSize);
|
||||||
wxFont version_font = GetFont();
|
wxFont version_font = GetFont();
|
||||||
#ifdef __WXMSW__
|
#ifdef __WXMSW__
|
||||||
|
@ -141,11 +141,7 @@ void BackgroundSlicingProcess::process_fff()
|
|||||||
// Passing the timestamp
|
// Passing the timestamp
|
||||||
evt.SetInt((int)(m_fff_print->step_state_with_timestamp(PrintStep::psSlicingFinished).timestamp));
|
evt.SetInt((int)(m_fff_print->step_state_with_timestamp(PrintStep::psSlicingFinished).timestamp));
|
||||||
wxQueueEvent(GUI::wxGetApp().mainframe->m_plater, evt.Clone());
|
wxQueueEvent(GUI::wxGetApp().mainframe->m_plater, evt.Clone());
|
||||||
#if ENABLE_GCODE_VIEWER
|
|
||||||
m_fff_print->export_gcode(m_temp_output_path, m_gcode_result, m_thumbnail_cb);
|
m_fff_print->export_gcode(m_temp_output_path, m_gcode_result, m_thumbnail_cb);
|
||||||
#else
|
|
||||||
m_fff_print->export_gcode(m_temp_output_path, m_gcode_preview_data, m_thumbnail_cb);
|
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
|
||||||
if (this->set_step_started(bspsGCodeFinalize)) {
|
if (this->set_step_started(bspsGCodeFinalize)) {
|
||||||
if (! m_export_path.empty()) {
|
if (! m_export_path.empty()) {
|
||||||
wxQueueEvent(GUI::wxGetApp().mainframe->m_plater, new wxCommandEvent(m_event_export_began_id));
|
wxQueueEvent(GUI::wxGetApp().mainframe->m_plater, new wxCommandEvent(m_event_export_began_id));
|
||||||
@ -433,25 +429,14 @@ Print::ApplyStatus BackgroundSlicingProcess::apply(const Model &model, const Dyn
|
|||||||
assert(m_print != nullptr);
|
assert(m_print != nullptr);
|
||||||
assert(config.opt_enum<PrinterTechnology>("printer_technology") == m_print->technology());
|
assert(config.opt_enum<PrinterTechnology>("printer_technology") == m_print->technology());
|
||||||
Print::ApplyStatus invalidated = m_print->apply(model, config);
|
Print::ApplyStatus invalidated = m_print->apply(model, config);
|
||||||
#if ENABLE_GCODE_VIEWER
|
|
||||||
if ((invalidated & PrintBase::APPLY_STATUS_INVALIDATED) != 0 && m_print->technology() == ptFFF &&
|
if ((invalidated & PrintBase::APPLY_STATUS_INVALIDATED) != 0 && m_print->technology() == ptFFF &&
|
||||||
!this->m_fff_print->is_step_done(psGCodeExport))
|
!this->m_fff_print->is_step_done(psGCodeExport)) {
|
||||||
{
|
|
||||||
// Some FFF status was invalidated, and the G-code was not exported yet.
|
// Some FFF status was invalidated, and the G-code was not exported yet.
|
||||||
// Let the G-code preview UI know that the final G-code preview is not valid.
|
// Let the G-code preview UI know that the final G-code preview is not valid.
|
||||||
// In addition, this early memory deallocation reduces memory footprint.
|
// In addition, this early memory deallocation reduces memory footprint.
|
||||||
if (m_gcode_result != nullptr)
|
if (m_gcode_result != nullptr)
|
||||||
m_gcode_result->reset();
|
m_gcode_result->reset();
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
if ((invalidated & PrintBase::APPLY_STATUS_INVALIDATED) != 0 && m_print->technology() == ptFFF &&
|
|
||||||
m_gcode_preview_data != nullptr && ! this->m_fff_print->is_step_done(psGCodeExport)) {
|
|
||||||
// Some FFF status was invalidated, and the G-code was not exported yet.
|
|
||||||
// Let the G-code preview UI know that the final G-code preview is not valid.
|
|
||||||
// In addition, this early memory deallocation reduces memory footprint.
|
|
||||||
m_gcode_preview_data->reset();
|
|
||||||
}
|
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
|
||||||
return invalidated;
|
return invalidated;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,9 +11,7 @@
|
|||||||
#include "libslic3r/GCode/ThumbnailData.hpp"
|
#include "libslic3r/GCode/ThumbnailData.hpp"
|
||||||
#include "libslic3r/Format/SL1.hpp"
|
#include "libslic3r/Format/SL1.hpp"
|
||||||
#include "slic3r/Utils/PrintHost.hpp"
|
#include "slic3r/Utils/PrintHost.hpp"
|
||||||
#if ENABLE_GCODE_VIEWER
|
|
||||||
#include "libslic3r/GCode/GCodeProcessor.hpp"
|
#include "libslic3r/GCode/GCodeProcessor.hpp"
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
|
||||||
|
|
||||||
|
|
||||||
namespace boost { namespace filesystem { class path; } }
|
namespace boost { namespace filesystem { class path; } }
|
||||||
@ -21,9 +19,6 @@ namespace boost { namespace filesystem { class path; } }
|
|||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
|
|
||||||
class DynamicPrintConfig;
|
class DynamicPrintConfig;
|
||||||
#if !ENABLE_GCODE_VIEWER
|
|
||||||
class GCodePreviewData;
|
|
||||||
#endif // !ENABLE_GCODE_VIEWER
|
|
||||||
class Model;
|
class Model;
|
||||||
class SLAPrint;
|
class SLAPrint;
|
||||||
|
|
||||||
@ -88,11 +83,7 @@ public:
|
|||||||
void set_fff_print(Print *print) { m_fff_print = print; }
|
void set_fff_print(Print *print) { m_fff_print = print; }
|
||||||
void set_sla_print(SLAPrint *print) { m_sla_print = print; m_sla_print->set_printer(&m_sla_archive); }
|
void set_sla_print(SLAPrint *print) { m_sla_print = print; m_sla_print->set_printer(&m_sla_archive); }
|
||||||
void set_thumbnail_cb(ThumbnailsGeneratorCallback cb) { m_thumbnail_cb = cb; }
|
void set_thumbnail_cb(ThumbnailsGeneratorCallback cb) { m_thumbnail_cb = cb; }
|
||||||
#if ENABLE_GCODE_VIEWER
|
|
||||||
void set_gcode_result(GCodeProcessor::Result* result) { m_gcode_result = result; }
|
void set_gcode_result(GCodeProcessor::Result* result) { m_gcode_result = result; }
|
||||||
#else
|
|
||||||
void set_gcode_preview_data(GCodePreviewData* gpd) { m_gcode_preview_data = gpd; }
|
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
|
||||||
|
|
||||||
// The following wxCommandEvent will be sent to the UI thread / Plater window, when the slicing is finished
|
// The following wxCommandEvent will be sent to the UI thread / Plater window, when the slicing is finished
|
||||||
// and the background processing will transition into G-code export.
|
// and the background processing will transition into G-code export.
|
||||||
@ -198,13 +189,8 @@ private:
|
|||||||
// Non-owned pointers to Print instances.
|
// Non-owned pointers to Print instances.
|
||||||
Print *m_fff_print = nullptr;
|
Print *m_fff_print = nullptr;
|
||||||
SLAPrint *m_sla_print = nullptr;
|
SLAPrint *m_sla_print = nullptr;
|
||||||
#if ENABLE_GCODE_VIEWER
|
|
||||||
// Data structure, to which the G-code export writes its annotations.
|
// Data structure, to which the G-code export writes its annotations.
|
||||||
GCodeProcessor::Result *m_gcode_result = nullptr;
|
GCodeProcessor::Result *m_gcode_result = nullptr;
|
||||||
#else
|
|
||||||
// Data structure, to which the G-code export writes its annotations.
|
|
||||||
GCodePreviewData *m_gcode_preview_data = nullptr;
|
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
|
||||||
// Callback function, used to write thumbnails into gcode.
|
// Callback function, used to write thumbnails into gcode.
|
||||||
ThumbnailsGeneratorCallback m_thumbnail_cb = nullptr;
|
ThumbnailsGeneratorCallback m_thumbnail_cb = nullptr;
|
||||||
SL1Archive m_sla_archive;
|
SL1Archive m_sla_archive;
|
||||||
|
@ -3,9 +3,7 @@
|
|||||||
#include "libslic3r/Utils.hpp"
|
#include "libslic3r/Utils.hpp"
|
||||||
#include "../Utils/MacDarkMode.hpp"
|
#include "../Utils/MacDarkMode.hpp"
|
||||||
#include "GUI.hpp"
|
#include "GUI.hpp"
|
||||||
#if ENABLE_GCODE_VIEWER
|
|
||||||
#include "GUI_Utils.hpp"
|
#include "GUI_Utils.hpp"
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
|
||||||
|
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
|
|
||||||
@ -357,17 +355,6 @@ wxBitmap BitmapCache::mksolid(size_t width, size_t height, unsigned char r, unsi
|
|||||||
return wxImage_to_wxBitmap_with_alpha(std::move(image), scale);
|
return wxImage_to_wxBitmap_with_alpha(std::move(image), scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if !ENABLE_GCODE_VIEWER
|
|
||||||
static inline int hex_digit_to_int(const char c)
|
|
||||||
{
|
|
||||||
return
|
|
||||||
(c >= '0' && c <= '9') ? int(c - '0') :
|
|
||||||
(c >= 'A' && c <= 'F') ? int(c - 'A') + 10 :
|
|
||||||
(c >= 'a' && c <= 'f') ? int(c - 'a') + 10 : -1;
|
|
||||||
}
|
|
||||||
#endif // !ENABLE_GCODE_VIEWER
|
|
||||||
|
|
||||||
bool BitmapCache::parse_color(const std::string& scolor, unsigned char* rgb_out)
|
bool BitmapCache::parse_color(const std::string& scolor, unsigned char* rgb_out)
|
||||||
{
|
{
|
||||||
rgb_out[0] = rgb_out[1] = rgb_out[2] = 0;
|
rgb_out[0] = rgb_out[1] = rgb_out[2] = 0;
|
||||||
|
@ -565,9 +565,7 @@ struct ConfigWizard::priv
|
|||||||
|
|
||||||
priv(ConfigWizard *q)
|
priv(ConfigWizard *q)
|
||||||
: q(q)
|
: q(q)
|
||||||
#if ENABLE_GCODE_VIEWER
|
|
||||||
, appconfig_new(AppConfig::EAppMode::Editor)
|
, appconfig_new(AppConfig::EAppMode::Editor)
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
|
||||||
, filaments(T_FFF)
|
, filaments(T_FFF)
|
||||||
, sla_materials(T_SLA)
|
, sla_materials(T_SLA)
|
||||||
{}
|
{}
|
||||||
|
@ -177,11 +177,7 @@ public:
|
|||||||
// load bitmap for logo
|
// load bitmap for logo
|
||||||
BitmapCache bmp_cache;
|
BitmapCache bmp_cache;
|
||||||
int logo_size = lround(width * 0.25);
|
int logo_size = lround(width * 0.25);
|
||||||
#if ENABLE_GCODE_VIEWER
|
|
||||||
wxBitmap logo_bmp = *bmp_cache.load_svg(wxGetApp().is_editor() ? "prusa_slicer_logo" : "add_gcode", logo_size, logo_size);
|
wxBitmap logo_bmp = *bmp_cache.load_svg(wxGetApp().is_editor() ? "prusa_slicer_logo" : "add_gcode", logo_size, logo_size);
|
||||||
#else
|
|
||||||
wxBitmap logo_bmp = *bmp_cache.load_svg("prusa_slicer_logo", logo_size, logo_size);
|
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
|
||||||
|
|
||||||
wxCoord margin = int(m_scale * 20);
|
wxCoord margin = int(m_scale * 20);
|
||||||
|
|
||||||
@ -229,11 +225,7 @@ private:
|
|||||||
void init(wxFont init_font)
|
void init(wxFont init_font)
|
||||||
{
|
{
|
||||||
// title
|
// title
|
||||||
#if ENABLE_GCODE_VIEWER
|
|
||||||
title = wxGetApp().is_editor() ? SLIC3R_APP_NAME : GCODEVIEWER_APP_NAME;
|
title = wxGetApp().is_editor() ? SLIC3R_APP_NAME : GCODEVIEWER_APP_NAME;
|
||||||
#else
|
|
||||||
title = SLIC3R_APP_NAME;
|
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
|
||||||
|
|
||||||
// dynamically get the version to display
|
// dynamically get the version to display
|
||||||
version = _L("Version") + " " + std::string(SLIC3R_VERSION);
|
version = _L("Version") + " " + std::string(SLIC3R_VERSION);
|
||||||
@ -601,13 +593,11 @@ void GUI_App::post_init()
|
|||||||
if (! this->initialized())
|
if (! this->initialized())
|
||||||
throw Slic3r::RuntimeError("Calling post_init() while not yet initialized");
|
throw Slic3r::RuntimeError("Calling post_init() while not yet initialized");
|
||||||
|
|
||||||
#if ENABLE_GCODE_VIEWER
|
|
||||||
if (this->init_params->start_as_gcodeviewer) {
|
if (this->init_params->start_as_gcodeviewer) {
|
||||||
if (! this->init_params->input_files.empty())
|
if (! this->init_params->input_files.empty())
|
||||||
this->plater()->load_gcode(wxString::FromUTF8(this->init_params->input_files[0].c_str()));
|
this->plater()->load_gcode(wxString::FromUTF8(this->init_params->input_files[0].c_str()));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
#endif // ENABLE_GCODE_VIEWER_AS
|
|
||||||
#if 0
|
#if 0
|
||||||
// Load the cummulative config over the currently active profiles.
|
// Load the cummulative config over the currently active profiles.
|
||||||
//FIXME if multiple configs are loaded, only the last one will have an effect.
|
//FIXME if multiple configs are loaded, only the last one will have an effect.
|
||||||
@ -626,22 +616,14 @@ void GUI_App::post_init()
|
|||||||
this->plater()->load_files(this->init_params->input_files, true, true);
|
this->plater()->load_files(this->init_params->input_files, true, true);
|
||||||
if (! this->init_params->extra_config.empty())
|
if (! this->init_params->extra_config.empty())
|
||||||
this->mainframe->load_config(this->init_params->extra_config);
|
this->mainframe->load_config(this->init_params->extra_config);
|
||||||
#if ENABLE_GCODE_VIEWER
|
|
||||||
}
|
}
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IMPLEMENT_APP(GUI_App)
|
IMPLEMENT_APP(GUI_App)
|
||||||
|
|
||||||
#if ENABLE_GCODE_VIEWER
|
|
||||||
GUI_App::GUI_App(EAppMode mode)
|
GUI_App::GUI_App(EAppMode mode)
|
||||||
#else
|
|
||||||
GUI_App::GUI_App()
|
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
|
||||||
: wxApp()
|
: wxApp()
|
||||||
#if ENABLE_GCODE_VIEWER
|
|
||||||
, m_app_mode(mode)
|
, m_app_mode(mode)
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
|
||||||
, m_em_unit(10)
|
, m_em_unit(10)
|
||||||
, m_imgui(new ImGuiWrapper())
|
, m_imgui(new ImGuiWrapper())
|
||||||
, m_wizard(nullptr)
|
, m_wizard(nullptr)
|
||||||
@ -705,11 +687,7 @@ void GUI_App::init_app_config()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!app_config)
|
if (!app_config)
|
||||||
#if ENABLE_GCODE_VIEWER
|
|
||||||
app_config = new AppConfig(is_editor() ? AppConfig::EAppMode::Editor : AppConfig::EAppMode::GCodeViewer);
|
app_config = new AppConfig(is_editor() ? AppConfig::EAppMode::Editor : AppConfig::EAppMode::GCodeViewer);
|
||||||
#else
|
|
||||||
app_config = new AppConfig();
|
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
|
||||||
|
|
||||||
// load settings
|
// load settings
|
||||||
m_app_conf_exists = app_config->exists();
|
m_app_conf_exists = app_config->exists();
|
||||||
@ -717,7 +695,6 @@ void GUI_App::init_app_config()
|
|||||||
std::string error = app_config->load();
|
std::string error = app_config->load();
|
||||||
if (!error.empty()) {
|
if (!error.empty()) {
|
||||||
// Error while parsing config file. We'll customize the error message and rethrow to be displayed.
|
// Error while parsing config file. We'll customize the error message and rethrow to be displayed.
|
||||||
#if ENABLE_GCODE_VIEWER
|
|
||||||
if (is_editor()) {
|
if (is_editor()) {
|
||||||
throw Slic3r::RuntimeError(
|
throw Slic3r::RuntimeError(
|
||||||
_u8L("Error parsing PrusaSlicer config file, it is probably corrupted. "
|
_u8L("Error parsing PrusaSlicer config file, it is probably corrupted. "
|
||||||
@ -725,14 +702,11 @@ void GUI_App::init_app_config()
|
|||||||
"\n\n" + app_config->config_path() + "\n\n" + error);
|
"\n\n" + app_config->config_path() + "\n\n" + error);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
|
||||||
throw Slic3r::RuntimeError(
|
throw Slic3r::RuntimeError(
|
||||||
_u8L("Error parsing PrusaGCodeViewer config file, it is probably corrupted. "
|
_u8L("Error parsing PrusaGCodeViewer config file, it is probably corrupted. "
|
||||||
"Try to manually delete the file to recover from the error.") +
|
"Try to manually delete the file to recover from the error.") +
|
||||||
"\n\n" + app_config->config_path() + "\n\n" + error);
|
"\n\n" + app_config->config_path() + "\n\n" + error);
|
||||||
#if ENABLE_GCODE_VIEWER
|
|
||||||
}
|
}
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -775,9 +749,7 @@ bool GUI_App::on_init_inner()
|
|||||||
|
|
||||||
// Slic3r::debugf "wxWidgets version %s, Wx version %s\n", wxVERSION_STRING, wxVERSION;
|
// Slic3r::debugf "wxWidgets version %s, Wx version %s\n", wxVERSION_STRING, wxVERSION;
|
||||||
|
|
||||||
#if ENABLE_GCODE_VIEWER
|
|
||||||
if (is_editor()) {
|
if (is_editor()) {
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
|
||||||
std::string msg = Http::tls_global_init();
|
std::string msg = Http::tls_global_init();
|
||||||
std::string ssl_cert_store = app_config->get("tls_accepted_cert_store_location");
|
std::string ssl_cert_store = app_config->get("tls_accepted_cert_store_location");
|
||||||
bool ssl_accept = app_config->get("tls_cert_store_accepted") == "yes" && ssl_cert_store == Http::tls_system_cert_store();
|
bool ssl_accept = app_config->get("tls_cert_store_accepted") == "yes" && ssl_cert_store == Http::tls_system_cert_store();
|
||||||
@ -795,9 +767,7 @@ bool GUI_App::on_init_inner()
|
|||||||
app_config->set("tls_accepted_cert_store_location",
|
app_config->set("tls_accepted_cert_store_location",
|
||||||
dlg.IsCheckBoxChecked() ? Http::tls_system_cert_store() : "");
|
dlg.IsCheckBoxChecked() ? Http::tls_system_cert_store() : "");
|
||||||
}
|
}
|
||||||
#if ENABLE_GCODE_VIEWER
|
|
||||||
}
|
}
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
|
||||||
|
|
||||||
app_config->set("version", SLIC3R_VERSION);
|
app_config->set("version", SLIC3R_VERSION);
|
||||||
app_config->save();
|
app_config->save();
|
||||||
@ -807,11 +777,7 @@ bool GUI_App::on_init_inner()
|
|||||||
SplashScreen* scrn = nullptr;
|
SplashScreen* scrn = nullptr;
|
||||||
if (app_config->get("show_splash_screen") == "1") {
|
if (app_config->get("show_splash_screen") == "1") {
|
||||||
// make a bitmap with dark grey banner on the left side
|
// make a bitmap with dark grey banner on the left side
|
||||||
#if ENABLE_GCODE_VIEWER
|
|
||||||
wxBitmap bmp = SplashScreen::MakeBitmap(wxBitmap(from_u8(var(is_editor() ? "splashscreen.jpg" : "splashscreen-gcodepreview.jpg")), wxBITMAP_TYPE_JPEG));
|
wxBitmap bmp = SplashScreen::MakeBitmap(wxBitmap(from_u8(var(is_editor() ? "splashscreen.jpg" : "splashscreen-gcodepreview.jpg")), wxBITMAP_TYPE_JPEG));
|
||||||
#else
|
|
||||||
wxBitmap bmp = SplashScreen::MakeBitmap(wxBitmap(from_u8(var("splashscreen.jpg")), wxBITMAP_TYPE_JPEG));
|
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
|
||||||
|
|
||||||
// Detect position (display) to show the splash screen
|
// Detect position (display) to show the splash screen
|
||||||
// Now this position is equal to the mainframe position
|
// Now this position is equal to the mainframe position
|
||||||
@ -837,9 +803,7 @@ bool GUI_App::on_init_inner()
|
|||||||
// supplied as argument to --datadir; in that case we should still run the wizard
|
// supplied as argument to --datadir; in that case we should still run the wizard
|
||||||
preset_bundle->setup_directories();
|
preset_bundle->setup_directories();
|
||||||
|
|
||||||
#if ENABLE_GCODE_VIEWER
|
|
||||||
if (is_editor()) {
|
if (is_editor()) {
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
|
||||||
#ifdef __WXMSW__
|
#ifdef __WXMSW__
|
||||||
associate_3mf_files();
|
associate_3mf_files();
|
||||||
#endif // __WXMSW__
|
#endif // __WXMSW__
|
||||||
@ -854,14 +818,12 @@ bool GUI_App::on_init_inner()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
#if ENABLE_GCODE_VIEWER
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
#ifdef __WXMSW__
|
#ifdef __WXMSW__
|
||||||
associate_gcode_files();
|
associate_gcode_files();
|
||||||
#endif // __WXMSW__
|
#endif // __WXMSW__
|
||||||
}
|
}
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
|
||||||
|
|
||||||
// initialize label colors and fonts
|
// initialize label colors and fonts
|
||||||
init_label_colours();
|
init_label_colours();
|
||||||
@ -889,18 +851,12 @@ bool GUI_App::on_init_inner()
|
|||||||
Slic3r::I18N::set_translate_callback(libslic3r_translate_callback);
|
Slic3r::I18N::set_translate_callback(libslic3r_translate_callback);
|
||||||
|
|
||||||
// application frame
|
// application frame
|
||||||
#if ENABLE_GCODE_VIEWER
|
|
||||||
if (scrn && is_editor())
|
if (scrn && is_editor())
|
||||||
#else
|
|
||||||
if (scrn)
|
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
|
||||||
scrn->SetText(_L("Preparing settings tabs..."));
|
scrn->SetText(_L("Preparing settings tabs..."));
|
||||||
|
|
||||||
mainframe = new MainFrame();
|
mainframe = new MainFrame();
|
||||||
// hide settings tabs after first Layout
|
// hide settings tabs after first Layout
|
||||||
#if ENABLE_GCODE_VIEWER
|
|
||||||
if (is_editor())
|
if (is_editor())
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
|
||||||
mainframe->select_tab(size_t(0));
|
mainframe->select_tab(size_t(0));
|
||||||
|
|
||||||
sidebar().obj_list()->init_objects(); // propagate model objects to object list
|
sidebar().obj_list()->init_objects(); // propagate model objects to object list
|
||||||
@ -941,9 +897,7 @@ bool GUI_App::on_init_inner()
|
|||||||
if (once) {
|
if (once) {
|
||||||
once = false;
|
once = false;
|
||||||
|
|
||||||
#if ENABLE_GCODE_VIEWER
|
|
||||||
if (preset_updater != nullptr) {
|
if (preset_updater != nullptr) {
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
|
||||||
check_updates(false);
|
check_updates(false);
|
||||||
|
|
||||||
CallAfter([this] {
|
CallAfter([this] {
|
||||||
@ -951,9 +905,7 @@ bool GUI_App::on_init_inner()
|
|||||||
preset_updater->slic3r_update_notify();
|
preset_updater->slic3r_update_notify();
|
||||||
preset_updater->sync(preset_bundle);
|
preset_updater->sync(preset_bundle);
|
||||||
});
|
});
|
||||||
#if ENABLE_GCODE_VIEWER
|
|
||||||
}
|
}
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
//sets window property to mainframe so other instances can indentify it
|
//sets window property to mainframe so other instances can indentify it
|
||||||
@ -962,7 +914,6 @@ bool GUI_App::on_init_inner()
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
#if ENABLE_GCODE_VIEWER
|
|
||||||
if (is_gcode_viewer()) {
|
if (is_gcode_viewer()) {
|
||||||
mainframe->update_layout();
|
mainframe->update_layout();
|
||||||
if (plater_ != nullptr)
|
if (plater_ != nullptr)
|
||||||
@ -970,7 +921,6 @@ bool GUI_App::on_init_inner()
|
|||||||
plater_->set_printer_technology(ptFFF);
|
plater_->set_printer_technology(ptFFF);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
|
||||||
load_current_presets();
|
load_current_presets();
|
||||||
mainframe->Show(true);
|
mainframe->Show(true);
|
||||||
|
|
||||||
@ -1163,9 +1113,7 @@ void GUI_App::check_printer_presets()
|
|||||||
|
|
||||||
void GUI_App::recreate_GUI(const wxString& msg_name)
|
void GUI_App::recreate_GUI(const wxString& msg_name)
|
||||||
{
|
{
|
||||||
#if ENABLE_GCODE_VIEWER
|
|
||||||
m_is_recreating_gui = true;
|
m_is_recreating_gui = true;
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
|
||||||
|
|
||||||
mainframe->shutdown();
|
mainframe->shutdown();
|
||||||
|
|
||||||
@ -1175,9 +1123,7 @@ void GUI_App::recreate_GUI(const wxString& msg_name)
|
|||||||
|
|
||||||
MainFrame *old_main_frame = mainframe;
|
MainFrame *old_main_frame = mainframe;
|
||||||
mainframe = new MainFrame();
|
mainframe = new MainFrame();
|
||||||
#if ENABLE_GCODE_VIEWER
|
|
||||||
if (is_editor())
|
if (is_editor())
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
|
||||||
// hide settings tabs after first Layout
|
// hide settings tabs after first Layout
|
||||||
mainframe->select_tab(size_t(0));
|
mainframe->select_tab(size_t(0));
|
||||||
// Propagate model objects to object list.
|
// Propagate model objects to object list.
|
||||||
@ -1210,9 +1156,7 @@ void GUI_App::recreate_GUI(const wxString& msg_name)
|
|||||||
// config_wizard_startup(true);
|
// config_wizard_startup(true);
|
||||||
// });
|
// });
|
||||||
|
|
||||||
#if ENABLE_GCODE_VIEWER
|
|
||||||
m_is_recreating_gui = false;
|
m_is_recreating_gui = false;
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI_App::system_info()
|
void GUI_App::system_info()
|
||||||
@ -1297,7 +1241,6 @@ void GUI_App::import_model(wxWindow *parent, wxArrayString& input_files) const
|
|||||||
dialog.GetPaths(input_files);
|
dialog.GetPaths(input_files);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLE_GCODE_VIEWER
|
|
||||||
void GUI_App::load_gcode(wxWindow* parent, wxString& input_file) const
|
void GUI_App::load_gcode(wxWindow* parent, wxString& input_file) const
|
||||||
{
|
{
|
||||||
input_file.Clear();
|
input_file.Clear();
|
||||||
@ -1309,7 +1252,6 @@ void GUI_App::load_gcode(wxWindow* parent, wxString& input_file) const
|
|||||||
if (dialog.ShowModal() == wxID_OK)
|
if (dialog.ShowModal() == wxID_OK)
|
||||||
input_file = dialog.GetPath();
|
input_file = dialog.GetPath();
|
||||||
}
|
}
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
|
||||||
|
|
||||||
bool GUI_App::switch_language()
|
bool GUI_App::switch_language()
|
||||||
{
|
{
|
||||||
@ -1545,17 +1487,13 @@ void GUI_App::add_config_menu(wxMenuBar *menu)
|
|||||||
const auto config_wizard_name = _(ConfigWizard::name(true));
|
const auto config_wizard_name = _(ConfigWizard::name(true));
|
||||||
const auto config_wizard_tooltip = from_u8((boost::format(_utf8(L("Run %s"))) % config_wizard_name).str());
|
const auto config_wizard_tooltip = from_u8((boost::format(_utf8(L("Run %s"))) % config_wizard_name).str());
|
||||||
// Cmd+, is standard on OS X - what about other operating systems?
|
// Cmd+, is standard on OS X - what about other operating systems?
|
||||||
#if ENABLE_GCODE_VIEWER
|
|
||||||
if (is_editor()) {
|
if (is_editor()) {
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
|
||||||
local_menu->Append(config_id_base + ConfigMenuWizard, config_wizard_name + dots, config_wizard_tooltip);
|
local_menu->Append(config_id_base + ConfigMenuWizard, config_wizard_name + dots, config_wizard_tooltip);
|
||||||
local_menu->Append(config_id_base + ConfigMenuSnapshots, _L("&Configuration Snapshots") + dots, _L("Inspect / activate configuration snapshots"));
|
local_menu->Append(config_id_base + ConfigMenuSnapshots, _L("&Configuration Snapshots") + dots, _L("Inspect / activate configuration snapshots"));
|
||||||
local_menu->Append(config_id_base + ConfigMenuTakeSnapshot, _L("Take Configuration &Snapshot"), _L("Capture a configuration snapshot"));
|
local_menu->Append(config_id_base + ConfigMenuTakeSnapshot, _L("Take Configuration &Snapshot"), _L("Capture a configuration snapshot"));
|
||||||
local_menu->Append(config_id_base + ConfigMenuUpdate, _L("Check for updates"), _L("Check for configuration updates"));
|
local_menu->Append(config_id_base + ConfigMenuUpdate, _L("Check for updates"), _L("Check for configuration updates"));
|
||||||
local_menu->AppendSeparator();
|
local_menu->AppendSeparator();
|
||||||
#if ENABLE_GCODE_VIEWER
|
|
||||||
}
|
}
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
|
||||||
local_menu->Append(config_id_base + ConfigMenuPreferences, _L("&Preferences") + dots +
|
local_menu->Append(config_id_base + ConfigMenuPreferences, _L("&Preferences") + dots +
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
"\tCtrl+,",
|
"\tCtrl+,",
|
||||||
@ -1563,16 +1501,10 @@ void GUI_App::add_config_menu(wxMenuBar *menu)
|
|||||||
"\tCtrl+P",
|
"\tCtrl+P",
|
||||||
#endif
|
#endif
|
||||||
_L("Application preferences"));
|
_L("Application preferences"));
|
||||||
#if ENABLE_GCODE_VIEWER
|
|
||||||
wxMenu* mode_menu = nullptr;
|
wxMenu* mode_menu = nullptr;
|
||||||
if (is_editor()) {
|
if (is_editor()) {
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
|
||||||
local_menu->AppendSeparator();
|
local_menu->AppendSeparator();
|
||||||
#if ENABLE_GCODE_VIEWER
|
|
||||||
mode_menu = new wxMenu();
|
mode_menu = new wxMenu();
|
||||||
#else
|
|
||||||
auto mode_menu = new wxMenu();
|
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
|
||||||
mode_menu->AppendRadioItem(config_id_base + ConfigMenuModeSimple, _L("Simple"), _L("Simple View Mode"));
|
mode_menu->AppendRadioItem(config_id_base + ConfigMenuModeSimple, _L("Simple"), _L("Simple View Mode"));
|
||||||
// mode_menu->AppendRadioItem(config_id_base + ConfigMenuModeAdvanced, _L("Advanced"), _L("Advanced View Mode"));
|
// mode_menu->AppendRadioItem(config_id_base + ConfigMenuModeAdvanced, _L("Advanced"), _L("Advanced View Mode"));
|
||||||
mode_menu->AppendRadioItem(config_id_base + ConfigMenuModeAdvanced, _CTX(L_CONTEXT("Advanced", "Mode"), "Mode"), _L("Advanced View Mode"));
|
mode_menu->AppendRadioItem(config_id_base + ConfigMenuModeAdvanced, _CTX(L_CONTEXT("Advanced", "Mode"), "Mode"), _L("Advanced View Mode"));
|
||||||
@ -1582,21 +1514,15 @@ void GUI_App::add_config_menu(wxMenuBar *menu)
|
|||||||
Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { if (get_mode() == comExpert) evt.Check(true); }, config_id_base + ConfigMenuModeExpert);
|
Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { if (get_mode() == comExpert) evt.Check(true); }, config_id_base + ConfigMenuModeExpert);
|
||||||
|
|
||||||
local_menu->AppendSubMenu(mode_menu, _L("Mode"), wxString::Format(_L("%s View Mode"), SLIC3R_APP_NAME));
|
local_menu->AppendSubMenu(mode_menu, _L("Mode"), wxString::Format(_L("%s View Mode"), SLIC3R_APP_NAME));
|
||||||
#if ENABLE_GCODE_VIEWER
|
|
||||||
}
|
}
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
|
||||||
local_menu->AppendSeparator();
|
local_menu->AppendSeparator();
|
||||||
local_menu->Append(config_id_base + ConfigMenuLanguage, _L("&Language"));
|
local_menu->Append(config_id_base + ConfigMenuLanguage, _L("&Language"));
|
||||||
#if ENABLE_GCODE_VIEWER
|
|
||||||
if (is_editor()) {
|
if (is_editor()) {
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
|
||||||
local_menu->AppendSeparator();
|
local_menu->AppendSeparator();
|
||||||
local_menu->Append(config_id_base + ConfigMenuFlashFirmware, _L("Flash printer &firmware"), _L("Upload a firmware image into an Arduino based printer"));
|
local_menu->Append(config_id_base + ConfigMenuFlashFirmware, _L("Flash printer &firmware"), _L("Upload a firmware image into an Arduino based printer"));
|
||||||
// TODO: for when we're able to flash dictionaries
|
// TODO: for when we're able to flash dictionaries
|
||||||
// local_menu->Append(config_id_base + FirmwareMenuDict, _L("Flash language file"), _L("Upload a language dictionary file into a Prusa printer"));
|
// local_menu->Append(config_id_base + FirmwareMenuDict, _L("Flash language file"), _L("Upload a language dictionary file into a Prusa printer"));
|
||||||
#if ENABLE_GCODE_VIEWER
|
|
||||||
}
|
}
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
|
||||||
|
|
||||||
local_menu->Bind(wxEVT_MENU, [this, config_id_base](wxEvent &event) {
|
local_menu->Bind(wxEVT_MENU, [this, config_id_base](wxEvent &event) {
|
||||||
switch (event.GetId() - config_id_base) {
|
switch (event.GetId() - config_id_base) {
|
||||||
@ -1650,10 +1576,8 @@ void GUI_App::add_config_menu(wxMenuBar *menu)
|
|||||||
PreferencesDialog dlg(mainframe);
|
PreferencesDialog dlg(mainframe);
|
||||||
dlg.ShowModal();
|
dlg.ShowModal();
|
||||||
app_layout_changed = dlg.settings_layout_changed();
|
app_layout_changed = dlg.settings_layout_changed();
|
||||||
#if ENABLE_GCODE_VIEWER
|
|
||||||
if (dlg.seq_top_layer_only_changed())
|
if (dlg.seq_top_layer_only_changed())
|
||||||
this->plater_->refresh_print();
|
this->plater_->refresh_print();
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
|
||||||
}
|
}
|
||||||
if (app_layout_changed) {
|
if (app_layout_changed) {
|
||||||
// hide full main_sizer for mainFrame
|
// hide full main_sizer for mainFrame
|
||||||
@ -1672,19 +1596,13 @@ void GUI_App::add_config_menu(wxMenuBar *menu)
|
|||||||
// the dialog needs to be destroyed before the call to switch_language()
|
// the dialog needs to be destroyed before the call to switch_language()
|
||||||
// or sometimes the application crashes into wxDialogBase() destructor
|
// or sometimes the application crashes into wxDialogBase() destructor
|
||||||
// so we put it into an inner scope
|
// so we put it into an inner scope
|
||||||
#if ENABLE_GCODE_VIEWER
|
|
||||||
wxString title = is_editor() ? wxString(SLIC3R_APP_NAME) : wxString(GCODEVIEWER_APP_NAME);
|
wxString title = is_editor() ? wxString(SLIC3R_APP_NAME) : wxString(GCODEVIEWER_APP_NAME);
|
||||||
title += " - " + _L("Language selection");
|
title += " - " + _L("Language selection");
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
|
||||||
wxMessageDialog dialog(nullptr,
|
wxMessageDialog dialog(nullptr,
|
||||||
_L("Switching the language will trigger application restart.\n"
|
_L("Switching the language will trigger application restart.\n"
|
||||||
"You will lose content of the plater.") + "\n\n" +
|
"You will lose content of the plater.") + "\n\n" +
|
||||||
_L("Do you want to proceed?"),
|
_L("Do you want to proceed?"),
|
||||||
#if ENABLE_GCODE_VIEWER
|
|
||||||
title,
|
title,
|
||||||
#else
|
|
||||||
wxString(SLIC3R_APP_NAME) + " - " + _L("Language selection"),
|
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
|
||||||
wxICON_QUESTION | wxOK | wxCANCEL);
|
wxICON_QUESTION | wxOK | wxCANCEL);
|
||||||
if (dialog.ShowModal() == wxID_CANCEL)
|
if (dialog.ShowModal() == wxID_CANCEL)
|
||||||
return;
|
return;
|
||||||
@ -1703,16 +1621,12 @@ void GUI_App::add_config_menu(wxMenuBar *menu)
|
|||||||
|
|
||||||
using std::placeholders::_1;
|
using std::placeholders::_1;
|
||||||
|
|
||||||
#if ENABLE_GCODE_VIEWER
|
|
||||||
if (mode_menu != nullptr) {
|
if (mode_menu != nullptr) {
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
|
||||||
auto modfn = [this](int mode, wxCommandEvent&) { if (get_mode() != mode) save_mode(mode); };
|
auto modfn = [this](int mode, wxCommandEvent&) { if (get_mode() != mode) save_mode(mode); };
|
||||||
mode_menu->Bind(wxEVT_MENU, std::bind(modfn, comSimple, _1), config_id_base + ConfigMenuModeSimple);
|
mode_menu->Bind(wxEVT_MENU, std::bind(modfn, comSimple, _1), config_id_base + ConfigMenuModeSimple);
|
||||||
mode_menu->Bind(wxEVT_MENU, std::bind(modfn, comAdvanced, _1), config_id_base + ConfigMenuModeAdvanced);
|
mode_menu->Bind(wxEVT_MENU, std::bind(modfn, comAdvanced, _1), config_id_base + ConfigMenuModeAdvanced);
|
||||||
mode_menu->Bind(wxEVT_MENU, std::bind(modfn, comExpert, _1), config_id_base + ConfigMenuModeExpert);
|
mode_menu->Bind(wxEVT_MENU, std::bind(modfn, comExpert, _1), config_id_base + ConfigMenuModeExpert);
|
||||||
#if ENABLE_GCODE_VIEWER
|
|
||||||
}
|
}
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
|
||||||
|
|
||||||
menu->Append(local_menu, _L("&Configuration"));
|
menu->Append(local_menu, _L("&Configuration"));
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,6 @@ static wxString dots("…", wxConvUTF8);
|
|||||||
|
|
||||||
class GUI_App : public wxApp
|
class GUI_App : public wxApp
|
||||||
{
|
{
|
||||||
#if ENABLE_GCODE_VIEWER
|
|
||||||
public:
|
public:
|
||||||
enum class EAppMode : unsigned char
|
enum class EAppMode : unsigned char
|
||||||
{
|
{
|
||||||
@ -106,14 +105,10 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
|
||||||
|
|
||||||
bool m_initialized { false };
|
bool m_initialized { false };
|
||||||
bool m_app_conf_exists{ false };
|
bool m_app_conf_exists{ false };
|
||||||
#if ENABLE_GCODE_VIEWER
|
|
||||||
EAppMode m_app_mode{ EAppMode::Editor };
|
EAppMode m_app_mode{ EAppMode::Editor };
|
||||||
bool m_is_recreating_gui{ false };
|
bool m_is_recreating_gui{ false };
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
|
||||||
|
|
||||||
wxColour m_color_label_modified;
|
wxColour m_color_label_modified;
|
||||||
wxColour m_color_label_sys;
|
wxColour m_color_label_sys;
|
||||||
@ -149,19 +144,13 @@ public:
|
|||||||
bool OnInit() override;
|
bool OnInit() override;
|
||||||
bool initialized() const { return m_initialized; }
|
bool initialized() const { return m_initialized; }
|
||||||
|
|
||||||
#if ENABLE_GCODE_VIEWER
|
|
||||||
explicit GUI_App(EAppMode mode = EAppMode::Editor);
|
explicit GUI_App(EAppMode mode = EAppMode::Editor);
|
||||||
#else
|
|
||||||
GUI_App();
|
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
|
||||||
~GUI_App() override;
|
~GUI_App() override;
|
||||||
|
|
||||||
#if ENABLE_GCODE_VIEWER
|
|
||||||
EAppMode get_app_mode() const { return m_app_mode; }
|
EAppMode get_app_mode() const { return m_app_mode; }
|
||||||
bool is_editor() const { return m_app_mode == EAppMode::Editor; }
|
bool is_editor() const { return m_app_mode == EAppMode::Editor; }
|
||||||
bool is_gcode_viewer() const { return m_app_mode == EAppMode::GCodeViewer; }
|
bool is_gcode_viewer() const { return m_app_mode == EAppMode::GCodeViewer; }
|
||||||
bool is_recreating_gui() const { return m_is_recreating_gui; }
|
bool is_recreating_gui() const { return m_is_recreating_gui; }
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
|
||||||
|
|
||||||
// To be called after the GUI is fully built up.
|
// To be called after the GUI is fully built up.
|
||||||
// Process command line parameters cached in this->init_params,
|
// Process command line parameters cached in this->init_params,
|
||||||
@ -199,9 +188,7 @@ public:
|
|||||||
void keyboard_shortcuts();
|
void keyboard_shortcuts();
|
||||||
void load_project(wxWindow *parent, wxString& input_file) const;
|
void load_project(wxWindow *parent, wxString& input_file) const;
|
||||||
void import_model(wxWindow *parent, wxArrayString& input_files) const;
|
void import_model(wxWindow *parent, wxArrayString& input_files) const;
|
||||||
#if ENABLE_GCODE_VIEWER
|
|
||||||
void load_gcode(wxWindow* parent, wxString& input_file) const;
|
void load_gcode(wxWindow* parent, wxString& input_file) const;
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
|
||||||
|
|
||||||
static bool catch_error(std::function<void()> cb, const std::string& err);
|
static bool catch_error(std::function<void()> cb, const std::string& err);
|
||||||
|
|
||||||
|
@ -22,7 +22,6 @@ namespace GUI {
|
|||||||
int GUI_Run(GUI_InitParams ¶ms)
|
int GUI_Run(GUI_InitParams ¶ms)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
#if ENABLE_GCODE_VIEWER
|
|
||||||
GUI::GUI_App* gui = new GUI::GUI_App(params.start_as_gcodeviewer ? GUI::GUI_App::EAppMode::GCodeViewer : GUI::GUI_App::EAppMode::Editor);
|
GUI::GUI_App* gui = new GUI::GUI_App(params.start_as_gcodeviewer ? GUI::GUI_App::EAppMode::GCodeViewer : GUI::GUI_App::EAppMode::Editor);
|
||||||
if (gui->get_app_mode() != GUI::GUI_App::EAppMode::GCodeViewer) {
|
if (gui->get_app_mode() != GUI::GUI_App::EAppMode::GCodeViewer) {
|
||||||
// G-code viewer is currently not performing instance check, a new G-code viewer is started every time.
|
// G-code viewer is currently not performing instance check, a new G-code viewer is started every time.
|
||||||
@ -32,29 +31,20 @@ int GUI_Run(GUI_InitParams ¶ms)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
GUI::GUI_App *gui = new GUI::GUI_App();
|
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
|
||||||
|
|
||||||
// gui->autosave = m_config.opt_string("autosave");
|
// gui->autosave = m_config.opt_string("autosave");
|
||||||
GUI::GUI_App::SetInstance(gui);
|
GUI::GUI_App::SetInstance(gui);
|
||||||
gui->init_params = ¶ms;
|
gui->init_params = ¶ms;
|
||||||
/*
|
/*
|
||||||
#if ENABLE_GCODE_VIEWER
|
|
||||||
gui->CallAfter([gui, this, &load_configs, params.start_as_gcodeviewer] {
|
gui->CallAfter([gui, this, &load_configs, params.start_as_gcodeviewer] {
|
||||||
#else
|
|
||||||
gui->CallAfter([gui, this, &load_configs] {
|
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
|
||||||
if (!gui->initialized()) {
|
if (!gui->initialized()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLE_GCODE_VIEWER
|
|
||||||
if (params.start_as_gcodeviewer) {
|
if (params.start_as_gcodeviewer) {
|
||||||
if (!m_input_files.empty())
|
if (!m_input_files.empty())
|
||||||
gui->plater()->load_gcode(wxString::FromUTF8(m_input_files[0].c_str()));
|
gui->plater()->load_gcode(wxString::FromUTF8(m_input_files[0].c_str()));
|
||||||
} else {
|
} else {
|
||||||
#endif // ENABLE_GCODE_VIEWER_AS
|
|
||||||
#if 0
|
#if 0
|
||||||
// Load the cummulative config over the currently active profiles.
|
// Load the cummulative config over the currently active profiles.
|
||||||
//FIXME if multiple configs are loaded, only the last one will have an effect.
|
//FIXME if multiple configs are loaded, only the last one will have an effect.
|
||||||
@ -73,9 +63,7 @@ int GUI_Run(GUI_InitParams ¶ms)
|
|||||||
gui->plater()->load_files(m_input_files, true, true);
|
gui->plater()->load_files(m_input_files, true, true);
|
||||||
if (!m_extra_config.empty())
|
if (!m_extra_config.empty())
|
||||||
gui->mainframe->load_config(m_extra_config);
|
gui->mainframe->load_config(m_extra_config);
|
||||||
#if ENABLE_GCODE_VIEWER
|
|
||||||
}
|
}
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
|
||||||
});
|
});
|
||||||
*/
|
*/
|
||||||
int result = wxEntry(params.argc, params.argv);
|
int result = wxEntry(params.argc, params.argv);
|
||||||
|
Loading…
Reference in New Issue
Block a user