mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-08-03 20:13:59 -06:00
Removed legacy GUI Perl bindings,
replaced Print & SLAPrint pointers with BackgroundProcessing pointer at the GLCanvas3D level, so that the Print & SLAPrint access will be synchronized with the current printer technology.
This commit is contained in:
parent
86c11df554
commit
bde4153d44
29 changed files with 121 additions and 1679 deletions
|
@ -842,7 +842,7 @@ void GLVolumeCollection::load_object_auxiliary(
|
|||
// finalize_geometry() clears the vertex arrays, therefore the bounding box has to be computed before finalize_geometry().
|
||||
v.bounding_box = v.indexed_vertex_array.bounding_box();
|
||||
v.indexed_vertex_array.finalize_geometry(use_VBOs);
|
||||
v.composite_id = GLVolume::CompositeID(obj_idx, -milestone, (int)instance_idx.first);
|
||||
v.composite_id = GLVolume::CompositeID(obj_idx, - int(milestone), (int)instance_idx.first);
|
||||
v.geometry_id = std::pair<size_t, size_t>(timestamp, model_instance.id().id);
|
||||
// Create a copy of the convex hull mesh for each instance. Use a move operator on the last instance.
|
||||
v.set_convex_hull((&instance_idx == &instances.back()) ? new TriangleMesh(std::move(convex_hull)) : new TriangleMesh(convex_hull), true);
|
||||
|
@ -1906,14 +1906,9 @@ void _3DScene::set_config(wxGLCanvas* canvas, DynamicPrintConfig* config)
|
|||
s_canvas_mgr.set_config(canvas, config);
|
||||
}
|
||||
|
||||
void _3DScene::set_print(wxGLCanvas* canvas, Print* print)
|
||||
void _3DScene::set_process(wxGLCanvas* canvas, BackgroundSlicingProcess* process)
|
||||
{
|
||||
s_canvas_mgr.set_print(canvas, print);
|
||||
}
|
||||
|
||||
void _3DScene::set_SLA_print(wxGLCanvas* canvas, SLAPrint* print)
|
||||
{
|
||||
s_canvas_mgr.set_SLA_print(canvas, print);
|
||||
s_canvas_mgr.set_process(canvas, process);
|
||||
}
|
||||
|
||||
void _3DScene::set_model(wxGLCanvas* canvas, Model* model)
|
||||
|
|
|
@ -603,8 +603,7 @@ public:
|
|||
static GUI::GLCanvas3D* get_canvas(wxGLCanvas* canvas);
|
||||
|
||||
static void set_config(wxGLCanvas* canvas, DynamicPrintConfig* config);
|
||||
static void set_print(wxGLCanvas* canvas, Print* print);
|
||||
static void set_SLA_print(wxGLCanvas* canvas, SLAPrint* print);
|
||||
static void set_process(wxGLCanvas* canvas, BackgroundSlicingProcess* process);
|
||||
static void set_model(wxGLCanvas* canvas, Model* model);
|
||||
|
||||
static void set_bed_shape(wxGLCanvas* canvas, const Pointfs& shape);
|
||||
|
|
|
@ -53,6 +53,11 @@ void BackgroundSlicingProcess::select_technology(PrinterTechnology tech)
|
|||
assert(m_print != nullptr);
|
||||
}
|
||||
|
||||
PrinterTechnology BackgroundSlicingProcess::current_printer_technology() const
|
||||
{
|
||||
return m_print->technology();
|
||||
}
|
||||
|
||||
// This function may one day be merged into the Print, but historically the print was separated
|
||||
// from the G-code generator.
|
||||
void BackgroundSlicingProcess::process_fff()
|
||||
|
|
|
@ -56,6 +56,14 @@ public:
|
|||
|
||||
// Activate either m_fff_print or m_sla_print.
|
||||
void select_technology(PrinterTechnology tech);
|
||||
|
||||
// Get the currently active printer technology.
|
||||
PrinterTechnology current_printer_technology() const;
|
||||
// Get the current print. It is either m_fff_print or m_sla_print.
|
||||
const PrintBase* current_print() const { return m_print; }
|
||||
const Print* fff_print() const { return m_fff_print; }
|
||||
const SLAPrint* sla_print() const { return m_sla_print; }
|
||||
|
||||
// Start the background processing. Returns false if the background processing was already running.
|
||||
bool start();
|
||||
// Cancel the background processing. Returns false if the background processing was not running.
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "admesh/stl.h"
|
||||
#include "libslic3r/libslic3r.h"
|
||||
#include "slic3r/GUI/3DScene.hpp"
|
||||
#include "slic3r/GUI/BackgroundSlicingProcess.hpp"
|
||||
#include "slic3r/GUI/GLShader.hpp"
|
||||
#include "slic3r/GUI/GUI.hpp"
|
||||
#include "slic3r/GUI/PresetBundle.hpp"
|
||||
|
@ -3249,8 +3250,7 @@ GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas)
|
|||
, m_context(nullptr)
|
||||
, m_toolbar(*this)
|
||||
, m_config(nullptr)
|
||||
, m_print(nullptr)
|
||||
, m_sla_print(nullptr)
|
||||
, m_process(nullptr)
|
||||
, m_model(nullptr)
|
||||
, m_dirty(true)
|
||||
, m_initialized(false)
|
||||
|
@ -3443,14 +3443,9 @@ void GLCanvas3D::set_config(DynamicPrintConfig* config)
|
|||
m_config = config;
|
||||
}
|
||||
|
||||
void GLCanvas3D::set_print(Print* print)
|
||||
void GLCanvas3D::set_process(BackgroundSlicingProcess *process)
|
||||
{
|
||||
m_print = print;
|
||||
}
|
||||
|
||||
void GLCanvas3D::set_SLA_print(SLAPrint* print)
|
||||
{
|
||||
m_sla_print = print;
|
||||
m_process = process;
|
||||
}
|
||||
|
||||
void GLCanvas3D::set_model(Model* model)
|
||||
|
@ -3875,7 +3870,7 @@ void GLCanvas3D::reload_scene(bool refresh_immediately, bool force_full_scene_re
|
|||
|
||||
m_reload_delayed = ! m_canvas->IsShown() && ! refresh_immediately && ! force_full_scene_refresh;
|
||||
|
||||
PrinterTechnology printer_technology = wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology();
|
||||
PrinterTechnology printer_technology = m_process->current_printer_technology();
|
||||
|
||||
if (m_regenerate_volumes)
|
||||
{
|
||||
|
@ -3892,12 +3887,13 @@ void GLCanvas3D::reload_scene(bool refresh_immediately, bool force_full_scene_re
|
|||
}
|
||||
}
|
||||
if (printer_technology == ptSLA) {
|
||||
const SLAPrint *sla_print = this->sla_print();
|
||||
#ifdef _DEBUG
|
||||
// Verify that the SLAPrint object is synchronized with m_model.
|
||||
check_model_ids_equal(*m_model, m_sla_print->model());
|
||||
check_model_ids_equal(*m_model, sla_print->model());
|
||||
#endif /* _DEBUG */
|
||||
sla_support_state.reserve(m_sla_print->objects().size());
|
||||
for (const SLAPrintObject *print_object : m_sla_print->objects()) {
|
||||
sla_support_state.reserve(sla_print->objects().size());
|
||||
for (const SLAPrintObject *print_object : sla_print->objects()) {
|
||||
SLASupportState state;
|
||||
for (size_t istep = 0; istep < sla_steps.size(); ++ istep) {
|
||||
state.step[istep] = print_object->step_state_with_timestamp(sla_steps[istep]);
|
||||
|
@ -4017,7 +4013,8 @@ void GLCanvas3D::reload_scene(bool refresh_immediately, bool force_full_scene_re
|
|||
}
|
||||
if (printer_technology == ptSLA) {
|
||||
size_t idx = 0;
|
||||
for (const SLAPrintObject *print_object : m_sla_print->objects()) {
|
||||
const SLAPrint *sla_print = this->sla_print();
|
||||
for (const SLAPrintObject *print_object : sla_print->objects()) {
|
||||
SLASupportState &state = sla_support_state[idx ++];
|
||||
const ModelObject *model_object = print_object->model_object();
|
||||
// Find an index of the ModelObject
|
||||
|
@ -4026,9 +4023,9 @@ void GLCanvas3D::reload_scene(bool refresh_immediately, bool force_full_scene_re
|
|||
continue;
|
||||
// There may be new SLA volumes added to the scene for this print_object.
|
||||
// Find the object index of this print_object in the Model::objects list.
|
||||
auto it = std::find(m_sla_print->model().objects.begin(), m_sla_print->model().objects.end(), model_object);
|
||||
assert(it != m_sla_print->model().objects.end());
|
||||
object_idx = it - m_sla_print->model().objects.begin();
|
||||
auto it = std::find(sla_print->model().objects.begin(), sla_print->model().objects.end(), model_object);
|
||||
assert(it != sla_print->model().objects.end());
|
||||
object_idx = it - sla_print->model().objects.begin();
|
||||
// Collect indices of this print_object's instances, for which the SLA support meshes are to be added to the scene.
|
||||
// pairs of <instance_idx, print_instance_idx>
|
||||
std::vector<std::pair<size_t, size_t>> instances[std::tuple_size<SLASteps>::value];
|
||||
|
@ -4092,11 +4089,12 @@ void GLCanvas3D::reload_scene(bool refresh_immediately, bool force_full_scene_re
|
|||
float w = dynamic_cast<const ConfigOptionFloat*>(m_config->option("wipe_tower_width"))->value;
|
||||
float a = dynamic_cast<const ConfigOptionFloat*>(m_config->option("wipe_tower_rotation_angle"))->value;
|
||||
|
||||
float depth = m_print->get_wipe_tower_depth();
|
||||
if (!m_print->is_step_done(psWipeTower))
|
||||
const Print *print = m_process->fff_print();
|
||||
float depth = print->get_wipe_tower_depth();
|
||||
if (!print->is_step_done(psWipeTower))
|
||||
depth = (900.f/w) * (float)(extruders_count - 1) ;
|
||||
m_volumes.load_wipe_tower_preview(1000, x, y, w, depth, (float)height, a, m_use_VBOs && m_initialized, !m_print->is_step_done(psWipeTower),
|
||||
m_print->config().nozzle_diameter.values[0] * 1.25f * 4.5f);
|
||||
m_volumes.load_wipe_tower_preview(1000, x, y, w, depth, (float)height, a, m_use_VBOs && m_initialized, !print->is_step_done(psWipeTower),
|
||||
print->config().nozzle_diameter.values[0] * 1.25f * 4.5f);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4145,7 +4143,8 @@ void GLCanvas3D::reload_scene(bool refresh_immediately, bool force_full_scene_re
|
|||
|
||||
void GLCanvas3D::load_gcode_preview(const GCodePreviewData& preview_data, const std::vector<std::string>& str_tool_colors)
|
||||
{
|
||||
if ((m_canvas != nullptr) && (m_print != nullptr))
|
||||
const Print *print = this->fff_print();
|
||||
if ((m_canvas != nullptr) && (print != nullptr))
|
||||
{
|
||||
#if !ENABLE_USE_UNIQUE_GLCONTEXT
|
||||
// ensures that this canvas is current
|
||||
|
@ -4186,12 +4185,13 @@ void GLCanvas3D::load_gcode_preview(const GCodePreviewData& preview_data, const
|
|||
|
||||
void GLCanvas3D::load_preview(const std::vector<std::string>& str_tool_colors)
|
||||
{
|
||||
if (m_print == nullptr)
|
||||
const Print *print = this->fff_print();
|
||||
if (print == nullptr)
|
||||
return;
|
||||
|
||||
_load_print_toolpaths();
|
||||
_load_wipe_tower_toolpaths(str_tool_colors);
|
||||
for (const PrintObject* object : m_print->objects())
|
||||
for (const PrintObject* object : print->objects())
|
||||
{
|
||||
if (object != nullptr)
|
||||
_load_print_object_toolpaths(*object, str_tool_colors);
|
||||
|
@ -4472,7 +4472,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||
// A volume is selected and the mouse is inside the reset button.
|
||||
// The PrintObject::adjust_layer_height_profile() call adjusts the profile of its associated ModelObject, it does not modify the profile of the PrintObject itself,
|
||||
// therefore it is safe to call it while the background processing is running.
|
||||
const_cast<PrintObject*>(m_print->get_object(layer_editing_object_idx))->reset_layer_height_profile();
|
||||
const_cast<PrintObject*>(this->fff_print()->get_object(layer_editing_object_idx))->reset_layer_height_profile();
|
||||
// Index 2 means no editing, just wait for mouse up event.
|
||||
m_layers_editing.state = LayersEditing::Completed;
|
||||
|
||||
|
@ -5400,7 +5400,8 @@ float GLCanvas3D::_get_zoom_to_bounding_box_factor(const BoundingBoxf3& bbox) co
|
|||
|
||||
void GLCanvas3D::_mark_volumes_for_layer_height() const
|
||||
{
|
||||
if (m_print == nullptr)
|
||||
const Print *print = (m_process == nullptr) ? nullptr : m_process->fff_print();
|
||||
if (print == nullptr)
|
||||
return;
|
||||
|
||||
for (GLVolume* vol : m_volumes.volumes)
|
||||
|
@ -5409,10 +5410,10 @@ void GLCanvas3D::_mark_volumes_for_layer_height() const
|
|||
int shader_id = m_layers_editing.get_shader_program_id();
|
||||
|
||||
if (is_layers_editing_enabled() && (shader_id != -1) && vol->selected &&
|
||||
vol->has_layer_height_texture() && (object_id < (int)m_print->objects().size()))
|
||||
vol->has_layer_height_texture() && (object_id < (int)print->objects().size()))
|
||||
{
|
||||
vol->set_layer_height_texture_data(m_layers_editing.get_z_texture_id(), shader_id,
|
||||
m_print->get_object(object_id), _get_layers_editing_cursor_z_relative(), m_layers_editing.band_width);
|
||||
print->get_object(object_id), _get_layers_editing_cursor_z_relative(), m_layers_editing.band_width);
|
||||
}
|
||||
else
|
||||
vol->reset_layer_height_texture_data();
|
||||
|
@ -5623,7 +5624,8 @@ void GLCanvas3D::_render_legend_texture() const
|
|||
|
||||
void GLCanvas3D::_render_layer_editing_overlay() const
|
||||
{
|
||||
if ((m_print == nullptr) || m_print->objects().empty())
|
||||
const Print *print = this->fff_print();
|
||||
if ((print == nullptr) || print->objects().empty())
|
||||
return;
|
||||
|
||||
GLVolume* volume = nullptr;
|
||||
|
@ -5643,10 +5645,10 @@ void GLCanvas3D::_render_layer_editing_overlay() const
|
|||
// If the active object was not allocated at the Print, go away.This should only be a momentary case between an object addition / deletion
|
||||
// and an update by Platter::async_apply_config.
|
||||
int object_idx = volume->object_idx();
|
||||
if ((int)m_print->objects().size() <= object_idx)
|
||||
if ((int)print->objects().size() <= object_idx)
|
||||
return;
|
||||
|
||||
const PrintObject* print_object = m_print->get_object(object_idx);
|
||||
const PrintObject* print_object = print->get_object(object_idx);
|
||||
if (print_object == nullptr)
|
||||
return;
|
||||
|
||||
|
@ -5854,10 +5856,11 @@ void GLCanvas3D::_perform_layer_editing_action(wxMouseEvent* evt)
|
|||
if (object_idx_selected == -1)
|
||||
return;
|
||||
|
||||
if (m_print == nullptr)
|
||||
const Print *print = this->fff_print();
|
||||
if (print == nullptr)
|
||||
return;
|
||||
|
||||
const PrintObject* selected_obj = m_print->get_object(object_idx_selected);
|
||||
const PrintObject* selected_obj = print->get_object(object_idx_selected);
|
||||
if (selected_obj == nullptr)
|
||||
return;
|
||||
|
||||
|
@ -5880,7 +5883,7 @@ void GLCanvas3D::_perform_layer_editing_action(wxMouseEvent* evt)
|
|||
int volume_idx = 0;
|
||||
for (int i = 0; i < object_idx_selected; ++i)
|
||||
{
|
||||
const PrintObject* obj = m_print->get_object(i);
|
||||
const PrintObject* obj = print->get_object(i);
|
||||
if (obj != nullptr)
|
||||
{
|
||||
for (int j = 0; j < (int)obj->region_volumes.size(); ++j)
|
||||
|
@ -5953,29 +5956,30 @@ void GLCanvas3D::_load_print_toolpaths()
|
|||
return;
|
||||
#endif // !ENABLE_USE_UNIQUE_GLCONTEXT
|
||||
|
||||
if (m_print == nullptr)
|
||||
const Print *print = this->fff_print();
|
||||
if (print == nullptr)
|
||||
return;
|
||||
|
||||
if (!m_print->is_step_done(psSkirt) || !m_print->is_step_done(psBrim))
|
||||
if (!print->is_step_done(psSkirt) || !print->is_step_done(psBrim))
|
||||
return;
|
||||
|
||||
if (!m_print->has_skirt() && (m_print->config().brim_width.value == 0))
|
||||
if (!print->has_skirt() && (print->config().brim_width.value == 0))
|
||||
return;
|
||||
|
||||
const float color[] = { 0.5f, 1.0f, 0.5f, 1.0f }; // greenish
|
||||
|
||||
// number of skirt layers
|
||||
size_t total_layer_count = 0;
|
||||
for (const PrintObject* print_object : m_print->objects())
|
||||
for (const PrintObject* print_object : print->objects())
|
||||
{
|
||||
total_layer_count = std::max(total_layer_count, print_object->total_layer_count());
|
||||
}
|
||||
size_t skirt_height = m_print->has_infinite_skirt() ? total_layer_count : std::min<size_t>(m_print->config().skirt_height.value, total_layer_count);
|
||||
if ((skirt_height == 0) && (m_print->config().brim_width.value > 0))
|
||||
size_t skirt_height = print->has_infinite_skirt() ? total_layer_count : std::min<size_t>(print->config().skirt_height.value, total_layer_count);
|
||||
if ((skirt_height == 0) && (print->config().brim_width.value > 0))
|
||||
skirt_height = 1;
|
||||
|
||||
// get first skirt_height layers (maybe this should be moved to a PrintObject method?)
|
||||
const PrintObject* object0 = m_print->objects().front();
|
||||
const PrintObject* object0 = print->objects().front();
|
||||
std::vector<float> print_zs;
|
||||
print_zs.reserve(skirt_height * 2);
|
||||
for (size_t i = 0; i < std::min(skirt_height, object0->layers().size()); ++i)
|
||||
|
@ -5998,9 +6002,9 @@ void GLCanvas3D::_load_print_toolpaths()
|
|||
volume.offsets.push_back(volume.indexed_vertex_array.quad_indices.size());
|
||||
volume.offsets.push_back(volume.indexed_vertex_array.triangle_indices.size());
|
||||
if (i == 0)
|
||||
_3DScene::extrusionentity_to_verts(m_print->brim(), print_zs[i], Point(0, 0), volume);
|
||||
_3DScene::extrusionentity_to_verts(print->brim(), print_zs[i], Point(0, 0), volume);
|
||||
|
||||
_3DScene::extrusionentity_to_verts(m_print->skirt(), print_zs[i], Point(0, 0), volume);
|
||||
_3DScene::extrusionentity_to_verts(print->skirt(), print_zs[i], Point(0, 0), volume);
|
||||
}
|
||||
volume.bounding_box = volume.indexed_vertex_array.bounding_box();
|
||||
volume.indexed_vertex_array.finalize_geometry(m_use_VBOs && m_initialized);
|
||||
|
@ -6162,10 +6166,11 @@ void GLCanvas3D::_load_print_object_toolpaths(const PrintObject& print_object, c
|
|||
|
||||
void GLCanvas3D::_load_wipe_tower_toolpaths(const std::vector<std::string>& str_tool_colors)
|
||||
{
|
||||
if ((m_print == nullptr) || m_print->wipe_tower_data().tool_changes.empty())
|
||||
const Print *print = this->fff_print();
|
||||
if ((print == nullptr) || print->wipe_tower_data().tool_changes.empty())
|
||||
return;
|
||||
|
||||
if (!m_print->is_step_done(psWipeTower))
|
||||
if (!print->is_step_done(psWipeTower))
|
||||
return;
|
||||
|
||||
std::vector<float> tool_colors = _parse_colors(str_tool_colors);
|
||||
|
@ -6202,12 +6207,12 @@ void GLCanvas3D::_load_wipe_tower_toolpaths(const std::vector<std::string>& str_
|
|||
std::vector<WipeTower::ToolChangeResult> final;
|
||||
} ctxt;
|
||||
|
||||
ctxt.print = m_print;
|
||||
ctxt.print = print;
|
||||
ctxt.tool_colors = tool_colors.empty() ? nullptr : &tool_colors;
|
||||
if (m_print->wipe_tower_data().priming && m_print->config().single_extruder_multi_material_priming)
|
||||
ctxt.priming.emplace_back(*m_print->wipe_tower_data().priming.get());
|
||||
if (m_print->wipe_tower_data().final_purge)
|
||||
ctxt.final.emplace_back(*m_print->wipe_tower_data().final_purge.get());
|
||||
if (print->wipe_tower_data().priming && print->config().single_extruder_multi_material_priming)
|
||||
ctxt.priming.emplace_back(*print->wipe_tower_data().priming.get());
|
||||
if (print->wipe_tower_data().final_purge)
|
||||
ctxt.final.emplace_back(*print->wipe_tower_data().final_purge.get());
|
||||
|
||||
ctxt.wipe_tower_angle = ctxt.print->config().wipe_tower_rotation_angle.value/180.f * PI;
|
||||
ctxt.wipe_tower_pos = WipeTower::xy(ctxt.print->config().wipe_tower_x.value, ctxt.print->config().wipe_tower_y.value);
|
||||
|
@ -6215,7 +6220,7 @@ void GLCanvas3D::_load_wipe_tower_toolpaths(const std::vector<std::string>& str_
|
|||
BOOST_LOG_TRIVIAL(debug) << "Loading wipe tower toolpaths in parallel - start";
|
||||
|
||||
//FIXME Improve the heuristics for a grain size.
|
||||
size_t n_items = m_print->wipe_tower_data().tool_changes.size() + (ctxt.priming.empty() ? 0 : 1);
|
||||
size_t n_items = print->wipe_tower_data().tool_changes.size() + (ctxt.priming.empty() ? 0 : 1);
|
||||
size_t grain_size = std::max(n_items / 128, size_t(1));
|
||||
tbb::spin_mutex new_volume_mutex;
|
||||
auto new_volume = [this, &new_volume_mutex](const float *color) -> GLVolume* {
|
||||
|
@ -6820,13 +6825,14 @@ void GLCanvas3D::_load_shells()
|
|||
size_t initial_volumes_count = m_volumes.volumes.size();
|
||||
m_gcode_preview_volume_index.first_volumes.emplace_back(GCodePreviewVolumeIndex::Shell, 0, (unsigned int)initial_volumes_count);
|
||||
|
||||
if (m_print->objects().empty())
|
||||
const Print *print = this->fff_print();
|
||||
if (print->objects().empty())
|
||||
// nothing to render, return
|
||||
return;
|
||||
|
||||
// adds objects' volumes
|
||||
unsigned int object_id = 0;
|
||||
for (const PrintObject* obj : m_print->objects())
|
||||
for (const PrintObject* obj : print->objects())
|
||||
{
|
||||
const ModelObject* model_obj = obj->model_object();
|
||||
|
||||
|
@ -6843,15 +6849,15 @@ void GLCanvas3D::_load_shells()
|
|||
|
||||
if (wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology() == ptFFF) {
|
||||
// adds wipe tower's volume
|
||||
double max_z = m_print->objects()[0]->model_object()->get_model()->bounding_box().max(2);
|
||||
const PrintConfig& config = m_print->config();
|
||||
double max_z = print->objects()[0]->model_object()->get_model()->bounding_box().max(2);
|
||||
const PrintConfig& config = print->config();
|
||||
unsigned int extruders_count = config.nozzle_diameter.size();
|
||||
if ((extruders_count > 1) && config.single_extruder_multi_material && config.wipe_tower && !config.complete_objects) {
|
||||
float depth = m_print->get_wipe_tower_depth();
|
||||
if (!m_print->is_step_done(psWipeTower))
|
||||
float depth = print->get_wipe_tower_depth();
|
||||
if (!print->is_step_done(psWipeTower))
|
||||
depth = (900.f/config.wipe_tower_width) * (float)(extruders_count - 1) ;
|
||||
m_volumes.load_wipe_tower_preview(1000, config.wipe_tower_x, config.wipe_tower_y, config.wipe_tower_width, depth, max_z, config.wipe_tower_rotation_angle,
|
||||
m_use_VBOs && m_initialized, !m_print->is_step_done(psWipeTower), m_print->config().nozzle_diameter.values[0] * 1.25f * 4.5f);
|
||||
m_use_VBOs && m_initialized, !print->is_step_done(psWipeTower), print->config().nozzle_diameter.values[0] * 1.25f * 4.5f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7050,5 +7056,15 @@ void GLCanvas3D::_resize_toolbar() const
|
|||
}
|
||||
}
|
||||
|
||||
const Print* GLCanvas3D::fff_print() const
|
||||
{
|
||||
return (m_process == nullptr) ? nullptr : m_process->fff_print();
|
||||
}
|
||||
|
||||
const SLAPrint* GLCanvas3D::sla_print() const
|
||||
{
|
||||
return (m_process == nullptr) ? nullptr : m_process->sla_print();
|
||||
}
|
||||
|
||||
} // namespace GUI
|
||||
} // namespace Slic3r
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace Slic3r {
|
|||
|
||||
class GLShader;
|
||||
class ExPolygon;
|
||||
class SLAPrint;
|
||||
class BackgroundSlicingProcess;
|
||||
|
||||
namespace GUI {
|
||||
|
||||
|
@ -704,9 +704,8 @@ private:
|
|||
mutable GLVolumeCollection m_volumes;
|
||||
Selection m_selection;
|
||||
DynamicPrintConfig* m_config;
|
||||
Print* m_print;
|
||||
SLAPrint* m_sla_print;
|
||||
Model* m_model;
|
||||
BackgroundSlicingProcess *m_process;
|
||||
|
||||
// Screen is only refreshed from the OnIdle handler if it is dirty.
|
||||
bool m_dirty;
|
||||
|
@ -759,8 +758,7 @@ public:
|
|||
int check_volumes_outside_state(const DynamicPrintConfig* config) const;
|
||||
|
||||
void set_config(DynamicPrintConfig* config);
|
||||
void set_print(Print* print);
|
||||
void set_SLA_print(SLAPrint* print);
|
||||
void set_process(BackgroundSlicingProcess* process);
|
||||
void set_model(Model* model);
|
||||
|
||||
const Selection& get_selection() const { return m_selection; }
|
||||
|
@ -955,6 +953,9 @@ private:
|
|||
void _resize_toolbar() const;
|
||||
|
||||
static std::vector<float> _parse_colors(const std::vector<std::string>& colors);
|
||||
|
||||
const Print* fff_print() const;
|
||||
const SLAPrint* sla_print() const;
|
||||
};
|
||||
|
||||
} // namespace GUI
|
||||
|
|
|
@ -265,18 +265,11 @@ void GLCanvas3DManager::set_config(wxGLCanvas* canvas, DynamicPrintConfig* confi
|
|||
it->second->set_config(config);
|
||||
}
|
||||
|
||||
void GLCanvas3DManager::set_print(wxGLCanvas* canvas, Print* print)
|
||||
void GLCanvas3DManager::set_process(wxGLCanvas* canvas, BackgroundSlicingProcess* process)
|
||||
{
|
||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
||||
if (it != m_canvases.end())
|
||||
it->second->set_print(print);
|
||||
}
|
||||
|
||||
void GLCanvas3DManager::set_SLA_print(wxGLCanvas* canvas, SLAPrint* print)
|
||||
{
|
||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
||||
if (it != m_canvases.end())
|
||||
it->second->set_SLA_print(print);
|
||||
it->second->set_process(process);
|
||||
}
|
||||
|
||||
void GLCanvas3DManager::set_model(wxGLCanvas* canvas, Model* model)
|
||||
|
|
|
@ -12,9 +12,8 @@ class wxGLContext;
|
|||
|
||||
namespace Slic3r {
|
||||
|
||||
class BackgroundSlicingProcess;
|
||||
class DynamicPrintConfig;
|
||||
class Print;
|
||||
class SLAPrint;
|
||||
class Model;
|
||||
class ExPolygon;
|
||||
typedef std::vector<ExPolygon> ExPolygons;
|
||||
|
@ -93,8 +92,7 @@ public:
|
|||
GLCanvas3D* get_canvas(wxGLCanvas* canvas);
|
||||
|
||||
void set_config(wxGLCanvas* canvas, DynamicPrintConfig* config);
|
||||
void set_print(wxGLCanvas* canvas, Print* print);
|
||||
void set_SLA_print(wxGLCanvas* canvas, SLAPrint* print);
|
||||
void set_process(wxGLCanvas* canvas, BackgroundSlicingProcess* process);
|
||||
void set_model(wxGLCanvas* canvas, Model* model);
|
||||
|
||||
void set_bed_shape(wxGLCanvas* canvas, const Pointfs& shape);
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
#include "wxExtensions.hpp"
|
||||
#include "GUI_Preview.hpp"
|
||||
#include "GUI_PreviewIface.hpp"
|
||||
#include "AboutDialog.hpp"
|
||||
#include "AppConfig.hpp"
|
||||
#include "ConfigWizard.hpp"
|
||||
|
@ -81,8 +80,6 @@ void break_to_debugger()
|
|||
#endif /* _WIN32 */
|
||||
}
|
||||
|
||||
PreviewIface* g_preview = nullptr;
|
||||
|
||||
bool config_wizard_startup(bool app_config_exists)
|
||||
{
|
||||
if (!app_config_exists || wxGetApp().preset_bundle->printers.size() <= 1) {
|
||||
|
@ -119,17 +116,6 @@ void config_wizard(int reason)
|
|||
wxGetApp().load_current_presets();
|
||||
}
|
||||
|
||||
PreviewIface* create_preview_iface(wxNotebook* parent, DynamicPrintConfig* config, Print* print, GCodePreviewData* gcode_preview_data)
|
||||
{
|
||||
if (g_preview == nullptr)
|
||||
{
|
||||
Preview* panel = new Preview(parent, config, print, gcode_preview_data);
|
||||
g_preview = new PreviewIface(panel);
|
||||
}
|
||||
|
||||
return g_preview;
|
||||
}
|
||||
|
||||
// opt_index = 0, by the reason of zero-index in ConfigOptionVector by default (in case only one element)
|
||||
void change_opt_value(DynamicPrintConfig& config, const t_config_option_key& opt_key, const boost::any& value, int opt_index /*= 0*/)
|
||||
{
|
||||
|
|
|
@ -17,7 +17,6 @@ namespace Slic3r {
|
|||
|
||||
class AppConfig;
|
||||
class DynamicPrintConfig;
|
||||
class PreviewIface;
|
||||
class Print;
|
||||
class GCodePreviewData;
|
||||
class AppControllerBase;
|
||||
|
@ -70,8 +69,6 @@ extern bool config_wizard_startup(bool app_config_exists);
|
|||
// The run_reason argument is actually ConfigWizard::RunReason, but int is used here because of Perl.
|
||||
extern void config_wizard(int run_reason);
|
||||
|
||||
PreviewIface* create_preview_iface(wxNotebook* notebook, DynamicPrintConfig* config, Print* print, GCodePreviewData* gcode_preview_data);
|
||||
|
||||
// Change option value in config
|
||||
void change_opt_value(DynamicPrintConfig& config, const t_config_option_key& opt_key, const boost::any& value, int opt_index = 0);
|
||||
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
#include "../../libslic3r/libslic3r.h"
|
||||
#include "libslic3r/libslic3r.h"
|
||||
#include "libslic3r/GCode/PreviewData.hpp"
|
||||
#include "GUI_Preview.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
#include "GUI.hpp"
|
||||
#include "AppConfig.hpp"
|
||||
#include "3DScene.hpp"
|
||||
#include "BackgroundSlicingProcess.hpp"
|
||||
#include "GLCanvas3DManager.hpp"
|
||||
#include "../../libslic3r/GCode/PreviewData.hpp"
|
||||
#include "PresetBundle.hpp"
|
||||
#include "wxExtensions.hpp"
|
||||
|
||||
|
@ -24,7 +25,7 @@ namespace Slic3r {
|
|||
namespace GUI {
|
||||
|
||||
|
||||
Preview::Preview(wxNotebook* notebook, DynamicPrintConfig* config, Print* print, GCodePreviewData* gcode_preview_data, std::function<void()> schedule_background_process_func)
|
||||
Preview::Preview(wxNotebook* notebook, DynamicPrintConfig* config, BackgroundSlicingProcess* process, GCodePreviewData* gcode_preview_data, std::function<void()> schedule_background_process_func)
|
||||
: m_canvas(nullptr)
|
||||
, m_double_slider_sizer(nullptr)
|
||||
, m_label_view_type(nullptr)
|
||||
|
@ -36,7 +37,7 @@ Preview::Preview(wxNotebook* notebook, DynamicPrintConfig* config, Print* print,
|
|||
, m_checkbox_unretractions(nullptr)
|
||||
, m_checkbox_shells(nullptr)
|
||||
, m_config(config)
|
||||
, m_print(print)
|
||||
, m_process(process)
|
||||
, m_gcode_preview_data(gcode_preview_data)
|
||||
, m_number_extruders(1)
|
||||
, m_preferred_color_mode("feature")
|
||||
|
@ -45,7 +46,7 @@ Preview::Preview(wxNotebook* notebook, DynamicPrintConfig* config, Print* print,
|
|||
, m_force_sliders_full_range(false)
|
||||
, m_schedule_background_process(schedule_background_process_func)
|
||||
{
|
||||
if (init(notebook, config, print, gcode_preview_data))
|
||||
if (init(notebook, config, process, gcode_preview_data))
|
||||
{
|
||||
notebook->AddPage(this, _(L("Preview")));
|
||||
show_hide_ui_elements("none");
|
||||
|
@ -53,9 +54,9 @@ Preview::Preview(wxNotebook* notebook, DynamicPrintConfig* config, Print* print,
|
|||
}
|
||||
}
|
||||
|
||||
bool Preview::init(wxNotebook* notebook, DynamicPrintConfig* config, Print* print, GCodePreviewData* gcode_preview_data)
|
||||
bool Preview::init(wxNotebook* notebook, DynamicPrintConfig* config, BackgroundSlicingProcess* process, GCodePreviewData* gcode_preview_data)
|
||||
{
|
||||
if ((notebook == nullptr) || (config == nullptr) || (print == nullptr) || (gcode_preview_data == nullptr))
|
||||
if ((notebook == nullptr) || (config == nullptr) || (process == nullptr) || (gcode_preview_data == nullptr))
|
||||
return false;
|
||||
|
||||
// creates this panel add append it to the given notebook as a new page
|
||||
|
@ -68,7 +69,7 @@ bool Preview::init(wxNotebook* notebook, DynamicPrintConfig* config, Print* prin
|
|||
_3DScene::allow_multisample(m_canvas, GLCanvas3DManager::can_multisample());
|
||||
_3DScene::enable_shader(m_canvas, true);
|
||||
_3DScene::set_config(m_canvas, m_config);
|
||||
_3DScene::set_print(m_canvas, m_print);
|
||||
_3DScene::set_process(m_canvas, process);
|
||||
_3DScene::enable_legend_texture(m_canvas, true);
|
||||
_3DScene::enable_dynamic_background(m_canvas, true);
|
||||
|
||||
|
@ -250,10 +251,12 @@ void Preview::load_print()
|
|||
// is performed on all of them(this ensures that _shifted_copies was
|
||||
// populated and we know the number of layers)
|
||||
unsigned int n_layers = 0;
|
||||
if (m_print->is_step_done(posSlice))
|
||||
assert(m_process->current_printer_technology() == ptFFF);
|
||||
const Print *print = m_process->fff_print();
|
||||
if (print->is_step_done(posSlice))
|
||||
{
|
||||
std::set<float> zs;
|
||||
for (const PrintObject* print_object : m_print->objects())
|
||||
for (const PrintObject* print_object : print->objects())
|
||||
{
|
||||
const LayerPtrs& layers = print_object->layers();
|
||||
const SupportLayerPtrs& support_layers = print_object->support_layers();
|
||||
|
@ -285,7 +288,7 @@ void Preview::load_print()
|
|||
{
|
||||
// It is left to Slic3r to decide whether the print shall be colored by the tool or by the feature.
|
||||
// Color by feature if it is a single extruder print.
|
||||
unsigned int number_extruders = (unsigned int)m_print->extruders().size();
|
||||
unsigned int number_extruders = (unsigned int)print->extruders().size();
|
||||
int tool_idx = m_choice_view_type->FindString(_(L("Tool")));
|
||||
int type = (number_extruders > 1) ? tool_idx /* color by a tool number */ : 0; // color by a feature type
|
||||
m_choice_view_type->SetSelection(type);
|
||||
|
|
|
@ -19,6 +19,7 @@ namespace Slic3r {
|
|||
|
||||
class DynamicPrintConfig;
|
||||
class Print;
|
||||
class BackgroundSlicingProcess;
|
||||
class GCodePreviewData;
|
||||
|
||||
namespace GUI {
|
||||
|
@ -37,7 +38,7 @@ class Preview : public wxPanel
|
|||
wxCheckBox* m_checkbox_shells;
|
||||
|
||||
DynamicPrintConfig* m_config;
|
||||
Print* m_print;
|
||||
BackgroundSlicingProcess* m_process;
|
||||
GCodePreviewData* m_gcode_preview_data;
|
||||
|
||||
// Calling this function object forces Plater::schedule_background_process.
|
||||
|
@ -53,7 +54,7 @@ class Preview : public wxPanel
|
|||
PrusaDoubleSlider* m_slider {nullptr};
|
||||
|
||||
public:
|
||||
Preview(wxNotebook* notebook, DynamicPrintConfig* config, Print* print, GCodePreviewData* gcode_preview_data, std::function<void()> schedule_background_process = [](){});
|
||||
Preview(wxNotebook* notebook, DynamicPrintConfig* config, BackgroundSlicingProcess* process, GCodePreviewData* gcode_preview_data, std::function<void()> schedule_background_process = [](){});
|
||||
virtual ~Preview();
|
||||
|
||||
wxGLCanvas* get_wxglcanvas() { return m_canvas; }
|
||||
|
@ -73,7 +74,7 @@ public:
|
|||
void refresh_print();
|
||||
|
||||
private:
|
||||
bool init(wxNotebook* notebook, DynamicPrintConfig* config, Print* print, GCodePreviewData* gcode_preview_data);
|
||||
bool init(wxNotebook* notebook, DynamicPrintConfig* config, BackgroundSlicingProcess* process, GCodePreviewData* gcode_preview_data);
|
||||
|
||||
void bind_event_handlers();
|
||||
void unbind_event_handlers();
|
||||
|
|
|
@ -1,57 +0,0 @@
|
|||
#include "../../libslic3r/libslic3r.h"
|
||||
#include "GUI_PreviewIface.hpp"
|
||||
#include "GUI_Preview.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
void PreviewIface::set_number_extruders(unsigned int number_extruders)
|
||||
{
|
||||
m_preview->set_number_extruders(number_extruders);
|
||||
}
|
||||
|
||||
void PreviewIface::reset_gcode_preview_data()
|
||||
{
|
||||
m_preview->reset_gcode_preview_data();
|
||||
}
|
||||
|
||||
void PreviewIface::reload_print(bool force)
|
||||
{
|
||||
m_preview->reload_print(force);
|
||||
}
|
||||
|
||||
void PreviewIface::set_canvas_as_dirty()
|
||||
{
|
||||
m_preview->set_canvas_as_dirty();
|
||||
}
|
||||
|
||||
void PreviewIface::set_enabled(bool enabled)
|
||||
{
|
||||
m_preview->set_enabled(enabled);
|
||||
}
|
||||
|
||||
void PreviewIface::set_bed_shape(const Pointfs& shape)
|
||||
{
|
||||
m_preview->set_bed_shape(shape);
|
||||
}
|
||||
|
||||
void PreviewIface::select_view(const std::string& direction)
|
||||
{
|
||||
m_preview->select_view(direction);
|
||||
}
|
||||
|
||||
void PreviewIface::set_viewport_from_scene(wxGLCanvas* canvas)
|
||||
{
|
||||
m_preview->set_viewport_from_scene(canvas);
|
||||
}
|
||||
|
||||
void PreviewIface::set_viewport_into_scene(wxGLCanvas* canvas)
|
||||
{
|
||||
m_preview->set_viewport_into_scene(canvas);
|
||||
}
|
||||
|
||||
void PreviewIface::set_drop_target(wxDropTarget* target)
|
||||
{
|
||||
m_preview->set_drop_target(target);
|
||||
}
|
||||
|
||||
} // namespace Slic3r
|
|
@ -1,36 +0,0 @@
|
|||
#ifndef slic3r_GUI_PreviewIface_hpp_
|
||||
#define slic3r_GUI_PreviewIface_hpp_
|
||||
|
||||
#include "../../libslic3r/Point.hpp"
|
||||
|
||||
class wxGLCanvas;
|
||||
class wxDropTarget;
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
namespace GUI {
|
||||
class Preview;
|
||||
} // namespace GUI
|
||||
|
||||
class PreviewIface
|
||||
{
|
||||
GUI::Preview* m_preview;
|
||||
|
||||
public:
|
||||
explicit PreviewIface(GUI::Preview* preview) : m_preview(preview) {}
|
||||
|
||||
void set_number_extruders(unsigned int number_extruders);
|
||||
void reset_gcode_preview_data();
|
||||
void reload_print(bool force = false);
|
||||
void set_canvas_as_dirty();
|
||||
void set_enabled(bool enabled);
|
||||
void set_bed_shape(const Pointfs& shape);
|
||||
void select_view(const std::string& direction);
|
||||
void set_viewport_from_scene(wxGLCanvas* canvas);
|
||||
void set_viewport_into_scene(wxGLCanvas* canvas);
|
||||
void set_drop_target(wxDropTarget* target);
|
||||
};
|
||||
|
||||
} // namespace Slic3r
|
||||
|
||||
#endif // slic3r_GUI_PreviewIface_hpp_
|
|
@ -1064,7 +1064,7 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
|
|||
|
||||
panel3d->SetSizer(panel3dsizer);
|
||||
notebook->AddPage(panel3d, _(L("3D")));
|
||||
preview = new GUI::Preview(notebook, config, &print, &gcode_preview_data, [this](){ schedule_background_process(); });
|
||||
preview = new GUI::Preview(notebook, config, &background_process, &gcode_preview_data, [this](){ schedule_background_process(); });
|
||||
|
||||
_3DScene::get_canvas(canvas3D)->set_external_gizmo_widgets_parent(panel_gizmo_widgets);
|
||||
|
||||
|
@ -1073,8 +1073,7 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
|
|||
_3DScene::enable_moving(canvas3D, true);
|
||||
// XXX: more config from 3D.pm
|
||||
_3DScene::set_model(canvas3D, &model);
|
||||
_3DScene::set_print(canvas3D, &print);
|
||||
_3DScene::set_SLA_print(canvas3D, &sla_print);
|
||||
_3DScene::set_process(canvas3D, &background_process);
|
||||
_3DScene::set_config(canvas3D, config);
|
||||
_3DScene::enable_gizmos(canvas3D, true);
|
||||
_3DScene::enable_toolbar(canvas3D, true);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue