mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-12 11:49:09 +08:00
SPE-1923: Fixed wrong x of tool position when z offset is applied
This commit is contained in:
parent
e26a8982da
commit
b467e5c247
@ -457,6 +457,7 @@ void GCodeProcessorResult::reset() {
|
||||
moves = std::vector<GCodeProcessorResult::MoveVertex>();
|
||||
bed_shape = Pointfs();
|
||||
max_print_height = 0.0f;
|
||||
z_offset = 0.0f;
|
||||
settings_ids.reset();
|
||||
extruders_count = 0;
|
||||
backtrace_enabled = false;
|
||||
@ -476,6 +477,7 @@ void GCodeProcessorResult::reset() {
|
||||
lines_ends.clear();
|
||||
bed_shape = Pointfs();
|
||||
max_print_height = 0.0f;
|
||||
z_offset = 0.0f;
|
||||
settings_ids.reset();
|
||||
extruders_count = 0;
|
||||
backtrace_enabled = false;
|
||||
@ -1304,6 +1306,8 @@ void GCodeProcessor::process_buffer(const std::string &buffer)
|
||||
|
||||
void GCodeProcessor::finalize(bool perform_post_process)
|
||||
{
|
||||
m_result.z_offset = m_z_offset;
|
||||
|
||||
// update width/height of wipe moves
|
||||
for (GCodeProcessorResult::MoveVertex& move : m_result.moves) {
|
||||
if (move.type == EMoveType::Wipe) {
|
||||
|
@ -157,6 +157,7 @@ namespace Slic3r {
|
||||
std::vector<std::vector<size_t>> lines_ends;
|
||||
Pointfs bed_shape;
|
||||
float max_print_height;
|
||||
float z_offset;
|
||||
SettingsIds settings_ids;
|
||||
size_t extruders_count;
|
||||
bool backtrace_enabled;
|
||||
|
@ -307,8 +307,8 @@ void GCodeViewer::SequentialView::Marker::init()
|
||||
void GCodeViewer::SequentialView::Marker::set_world_position(const Vec3f& position)
|
||||
{
|
||||
m_world_position = position;
|
||||
m_world_transform = (Geometry::translation_transform((position + m_z_offset * Vec3f::UnitZ()).cast<double>()) *
|
||||
Geometry::translation_transform(m_model.get_bounding_box().size().z() * Vec3d::UnitZ()) * Geometry::rotation_transform({ M_PI, 0.0, 0.0 })).cast<float>();
|
||||
m_world_transform = (Geometry::translation_transform((position + m_model_z_offset * Vec3f::UnitZ()).cast<double>()) *
|
||||
Geometry::translation_transform(m_model.get_bounding_box().size().z() * Vec3d::UnitZ()) * Geometry::rotation_transform({ M_PI, 0.0, 0.0 })).cast<float>();
|
||||
}
|
||||
|
||||
void GCodeViewer::SequentialView::Marker::render()
|
||||
@ -351,7 +351,7 @@ void GCodeViewer::SequentialView::Marker::render()
|
||||
imgui.text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, _u8L("Tool position") + ":");
|
||||
ImGui::SameLine();
|
||||
char buf[1024];
|
||||
const Vec3f position = m_world_position + m_world_offset;
|
||||
const Vec3f position = m_world_position + m_world_offset + m_z_offset * Vec3f::UnitZ();
|
||||
sprintf(buf, "X: %.3f, Y: %.3f, Z: %.3f", position.x(), position.y(), position.z());
|
||||
imgui.text(std::string(buf));
|
||||
|
||||
@ -841,6 +841,7 @@ void GCodeViewer::load(const GCodeProcessorResult& gcode_result, const Print& pr
|
||||
m_custom_gcode_per_print_z = gcode_result.custom_gcode_per_print_z;
|
||||
|
||||
m_max_print_height = gcode_result.max_print_height;
|
||||
m_z_offset = gcode_result.z_offset;
|
||||
|
||||
load_toolpaths(gcode_result);
|
||||
load_wipetower_shell(print);
|
||||
@ -1000,6 +1001,7 @@ void GCodeViewer::reset()
|
||||
m_paths_bounding_box.reset();
|
||||
m_max_bounding_box.reset();
|
||||
m_max_print_height = 0.0f;
|
||||
m_z_offset = 0.0f;
|
||||
m_tool_colors = std::vector<ColorRGBA>();
|
||||
m_extruders_count = 0;
|
||||
m_extruder_ids = std::vector<unsigned char>();
|
||||
@ -1042,6 +1044,7 @@ void GCodeViewer::render()
|
||||
if (m_sequential_view.current.last != m_sequential_view.endpoints.last) {
|
||||
m_sequential_view.marker.set_world_position(m_sequential_view.current_position);
|
||||
m_sequential_view.marker.set_world_offset(m_sequential_view.current_offset);
|
||||
m_sequential_view.marker.set_z_offset(m_z_offset);
|
||||
m_sequential_view.render(legend_height);
|
||||
}
|
||||
}
|
||||
|
@ -656,11 +656,14 @@ public:
|
||||
GLModel m_model;
|
||||
Vec3f m_world_position;
|
||||
Transform3f m_world_transform;
|
||||
// for seams, the position of the marker is on the last endpoint of the toolpath containing it
|
||||
// the offset is used to show the correct value of tool position in the "ToolPosition" window
|
||||
// see implementation of render() method
|
||||
// For seams, the position of the marker is on the last endpoint of the toolpath containing it.
|
||||
// This offset is used to show the correct value of tool position in the "ToolPosition" window.
|
||||
// See implementation of render() method
|
||||
Vec3f m_world_offset;
|
||||
float m_z_offset{ 0.5f };
|
||||
// z offset of the print
|
||||
float m_z_offset{ 0.0f };
|
||||
// z offset of the model
|
||||
float m_model_z_offset{ 0.5f };
|
||||
bool m_visible{ true };
|
||||
|
||||
public:
|
||||
@ -670,6 +673,7 @@ public:
|
||||
|
||||
void set_world_position(const Vec3f& position);
|
||||
void set_world_offset(const Vec3f& offset) { m_world_offset = offset; }
|
||||
void set_z_offset(float z_offset) { m_z_offset = z_offset; }
|
||||
|
||||
bool is_visible() const { return m_visible; }
|
||||
void set_visible(bool visible) { m_visible = visible; }
|
||||
@ -773,6 +777,7 @@ private:
|
||||
// bounding box of toolpaths + marker tools + shells
|
||||
BoundingBoxf3 m_max_bounding_box;
|
||||
float m_max_print_height{ 0.0f };
|
||||
float m_z_offset{ 0.0f };
|
||||
std::vector<ColorRGBA> m_tool_colors;
|
||||
Layers m_layers;
|
||||
std::array<unsigned int, 2> m_layers_z_range;
|
||||
|
Loading…
x
Reference in New Issue
Block a user