mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-30 20:21:12 -06:00 
			
		
		
		
	Merge branch 'master' of https://github.com/prusa3d/Slic3r
This commit is contained in:
		
						commit
						12fd5c500b
					
				
					 2 changed files with 74 additions and 41 deletions
				
			
		|  | @ -617,42 +617,71 @@ bool GLCanvas3D::Bed::_are_equal(const Pointfs& bed_1, const Pointfs& bed_2) | ||||||
|     return true; |     return true; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | const double GLCanvas3D::Axes::Radius = 0.5; | ||||||
|  | const double GLCanvas3D::Axes::ArrowBaseRadius = 2.5 * GLCanvas3D::Axes::Radius; | ||||||
|  | const double GLCanvas3D::Axes::ArrowLength = 5.0; | ||||||
|  | 
 | ||||||
| GLCanvas3D::Axes::Axes() | GLCanvas3D::Axes::Axes() | ||||||
|     : origin(Vec3d::Zero()) |     : origin(Vec3d::Zero()) | ||||||
|     , length(0.0f) |     , length(Vec3d::Zero()) | ||||||
| { | { | ||||||
|  |     m_quadric = ::gluNewQuadric(); | ||||||
|  |     if (m_quadric != nullptr) | ||||||
|  |         ::gluQuadricDrawStyle(m_quadric, GLU_FILL); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void GLCanvas3D::Axes::render(bool depth_test) const | GLCanvas3D::Axes::~Axes() | ||||||
| { | { | ||||||
|     if (depth_test) |     if (m_quadric != nullptr) | ||||||
|         ::glEnable(GL_DEPTH_TEST); |         ::gluDeleteQuadric(m_quadric); | ||||||
|     else | } | ||||||
|         ::glDisable(GL_DEPTH_TEST); |  | ||||||
| 
 | 
 | ||||||
|     ::glLineWidth(2.0f); | void GLCanvas3D::Axes::render() const | ||||||
|     ::glBegin(GL_LINES); | { | ||||||
|     // draw line for x axis
 |     if (m_quadric == nullptr) | ||||||
|  |         return; | ||||||
|  | 
 | ||||||
|  |     ::glEnable(GL_DEPTH_TEST); | ||||||
|  |     ::glEnable(GL_LIGHTING); | ||||||
|  | 
 | ||||||
|  |     // x axis
 | ||||||
|     ::glColor3f(1.0f, 0.0f, 0.0f); |     ::glColor3f(1.0f, 0.0f, 0.0f); | ||||||
|     ::glVertex3dv(origin.data()); |     ::glPushMatrix(); | ||||||
|     ::glVertex3f((GLfloat)origin(0) + length, (GLfloat)origin(1), (GLfloat)origin(2)); |     ::glTranslated(origin(0), origin(1), origin(2)); | ||||||
|     // draw line for y axis
 |     ::glRotated(90.0, 0.0, 1.0, 0.0); | ||||||
|     ::glColor3f(0.0f, 1.0f, 0.0f); |     render_axis(length(0)); | ||||||
|     ::glVertex3dv(origin.data()); |     ::glPopMatrix(); | ||||||
|     ::glVertex3f((GLfloat)origin(0), (GLfloat)origin(1) + length, (GLfloat)origin(2)); |  | ||||||
|     ::glEnd(); |  | ||||||
|     // draw line for Z axis
 |  | ||||||
|     // (re-enable depth test so that axis is correctly shown when objects are behind it)
 |  | ||||||
|     if (!depth_test) |  | ||||||
|         ::glEnable(GL_DEPTH_TEST); |  | ||||||
| 
 | 
 | ||||||
|     ::glBegin(GL_LINES); |     // y axis
 | ||||||
|  |     ::glColor3f(0.0f, 1.0f, 0.0f); | ||||||
|  |     ::glPushMatrix(); | ||||||
|  |     ::glTranslated(origin(0), origin(1), origin(2)); | ||||||
|  |     ::glRotated(-90.0, 1.0, 0.0, 0.0); | ||||||
|  |     render_axis(length(1)); | ||||||
|  |     ::glPopMatrix(); | ||||||
|  | 
 | ||||||
|  |     // z axis
 | ||||||
|     ::glColor3f(0.0f, 0.0f, 1.0f); |     ::glColor3f(0.0f, 0.0f, 1.0f); | ||||||
|     ::glVertex3dv(origin.data()); |     ::glPushMatrix(); | ||||||
|     ::glVertex3f((GLfloat)origin(0), (GLfloat)origin(1), (GLfloat)origin(2) + length); |     ::glTranslated(origin(0), origin(1), origin(2)); | ||||||
|     ::glEnd(); |     render_axis(length(2)); | ||||||
|  |     ::glPopMatrix(); | ||||||
|  | 
 | ||||||
|  |     ::glDisable(GL_LIGHTING); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | void GLCanvas3D::Axes::render_axis(double length) const | ||||||
|  | { | ||||||
|  |     ::gluQuadricOrientation(m_quadric, GLU_OUTSIDE); | ||||||
|  |     ::gluCylinder(m_quadric, Radius, Radius, length, 32, 1); | ||||||
|  |     ::gluQuadricOrientation(m_quadric, GLU_INSIDE); | ||||||
|  |     ::gluDisk(m_quadric, 0.0, Radius, 32, 1); | ||||||
|  |     ::glTranslated(0.0, 0.0, length); | ||||||
|  |     ::gluQuadricOrientation(m_quadric, GLU_OUTSIDE); | ||||||
|  |     ::gluCylinder(m_quadric, ArrowBaseRadius, 0.0, ArrowLength, 32, 1); | ||||||
|  |     ::gluQuadricOrientation(m_quadric, GLU_INSIDE); | ||||||
|  |     ::gluDisk(m_quadric, 0.0, ArrowBaseRadius, 32, 1); | ||||||
|  | } | ||||||
| 
 | 
 | ||||||
| GLCanvas3D::Shader::Shader() | GLCanvas3D::Shader::Shader() | ||||||
|     : m_shader(nullptr) |     : m_shader(nullptr) | ||||||
|  | @ -3781,7 +3810,7 @@ void GLCanvas3D::set_bed_shape(const Pointfs& shape) | ||||||
| 
 | 
 | ||||||
|     // Set the origin and size for painting of the coordinate system axes.
 |     // Set the origin and size for painting of the coordinate system axes.
 | ||||||
|     m_axes.origin = Vec3d(0.0, 0.0, (double)GROUND_Z); |     m_axes.origin = Vec3d(0.0, 0.0, (double)GROUND_Z); | ||||||
|     set_axes_length(0.3f * (float)m_bed.get_bounding_box().max_size()); |     set_bed_axes_length(0.1 * m_bed.get_bounding_box().max_size()); | ||||||
| 
 | 
 | ||||||
|     if (new_shape) |     if (new_shape) | ||||||
|         zoom_to_bed(); |         zoom_to_bed(); | ||||||
|  | @ -3789,9 +3818,9 @@ void GLCanvas3D::set_bed_shape(const Pointfs& shape) | ||||||
|     m_dirty = true; |     m_dirty = true; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void GLCanvas3D::set_axes_length(float length) | void GLCanvas3D::set_bed_axes_length(double length) | ||||||
| { | { | ||||||
|     m_axes.length = length; |     m_axes.length = length * Vec3d::Ones(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void GLCanvas3D::set_color_by(const std::string& value) | void GLCanvas3D::set_color_by(const std::string& value) | ||||||
|  | @ -4051,21 +4080,16 @@ void GLCanvas3D::render() | ||||||
|     _render_background(); |     _render_background(); | ||||||
| 
 | 
 | ||||||
|     if (is_custom_bed) // untextured bed needs to be rendered before objects
 |     if (is_custom_bed) // untextured bed needs to be rendered before objects
 | ||||||
|     { |  | ||||||
|         _render_bed(theta); |         _render_bed(theta); | ||||||
|         // disable depth testing so that axes are not covered by ground
 |  | ||||||
|         _render_axes(false); |  | ||||||
|     } |  | ||||||
| 
 | 
 | ||||||
|     _render_objects(); |     _render_objects(); | ||||||
|     _render_sla_slices(); |     _render_sla_slices(); | ||||||
|     _render_selection(); |     _render_selection(); | ||||||
| 
 | 
 | ||||||
|  |     _render_axes(); | ||||||
|  | 
 | ||||||
|     if (!is_custom_bed) // textured bed needs to be rendered after objects
 |     if (!is_custom_bed) // textured bed needs to be rendered after objects
 | ||||||
|     { |  | ||||||
|         _render_axes(true); |  | ||||||
|         _render_bed(theta); |         _render_bed(theta); | ||||||
|     } |  | ||||||
| 
 | 
 | ||||||
|     // we need to set the mouse's scene position here because the depth buffer
 |     // we need to set the mouse's scene position here because the depth buffer
 | ||||||
|     // could be invalidated by the following gizmo render methods
 |     // could be invalidated by the following gizmo render methods
 | ||||||
|  | @ -6019,9 +6043,9 @@ void GLCanvas3D::_render_bed(float theta) const | ||||||
|     m_bed.render(theta); |     m_bed.render(theta); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void GLCanvas3D::_render_axes(bool depth_test) const | void GLCanvas3D::_render_axes() const | ||||||
| { | { | ||||||
|     m_axes.render(depth_test); |     m_axes.render(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void GLCanvas3D::_render_objects() const | void GLCanvas3D::_render_objects() const | ||||||
|  |  | ||||||
|  | @ -20,6 +20,8 @@ class wxTimerEvent; | ||||||
| class wxPaintEvent; | class wxPaintEvent; | ||||||
| class wxGLCanvas; | class wxGLCanvas; | ||||||
| 
 | 
 | ||||||
|  | class GLUquadric; | ||||||
|  | typedef class GLUquadric GLUquadricObj; | ||||||
| 
 | 
 | ||||||
| namespace Slic3r { | namespace Slic3r { | ||||||
| 
 | 
 | ||||||
|  | @ -231,12 +233,20 @@ class GLCanvas3D | ||||||
| 
 | 
 | ||||||
|     struct Axes |     struct Axes | ||||||
|     { |     { | ||||||
|  |         static const double Radius; | ||||||
|  |         static const double ArrowBaseRadius; | ||||||
|  |         static const double ArrowLength; | ||||||
|         Vec3d origin; |         Vec3d origin; | ||||||
|         float length; |         Vec3d length; | ||||||
|  |         GLUquadricObj* m_quadric; | ||||||
| 
 | 
 | ||||||
|         Axes(); |         Axes(); | ||||||
|  |         ~Axes(); | ||||||
| 
 | 
 | ||||||
|         void render(bool depth_test) const; |         void render() const; | ||||||
|  | 
 | ||||||
|  |     private: | ||||||
|  |         void render_axis(double length) const; | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     class Shader |     class Shader | ||||||
|  | @ -870,8 +880,7 @@ public: | ||||||
|     // fills the m_bed.m_grid_lines and sets m_bed.m_origin.
 |     // fills the m_bed.m_grid_lines and sets m_bed.m_origin.
 | ||||||
|     // Sets m_bed.m_polygon to limit the object placement.
 |     // Sets m_bed.m_polygon to limit the object placement.
 | ||||||
|     void set_bed_shape(const Pointfs& shape); |     void set_bed_shape(const Pointfs& shape); | ||||||
| 
 |     void set_bed_axes_length(double length); | ||||||
|     void set_axes_length(float length); |  | ||||||
| 
 | 
 | ||||||
|     void set_clipping_plane(unsigned int id, const ClippingPlane& plane) |     void set_clipping_plane(unsigned int id, const ClippingPlane& plane) | ||||||
|     { |     { | ||||||
|  | @ -1011,7 +1020,7 @@ private: | ||||||
|     void _picking_pass() const; |     void _picking_pass() const; | ||||||
|     void _render_background() const; |     void _render_background() const; | ||||||
|     void _render_bed(float theta) const; |     void _render_bed(float theta) const; | ||||||
|     void _render_axes(bool depth_test) const; |     void _render_axes() const; | ||||||
|     void _render_objects() const; |     void _render_objects() const; | ||||||
|     void _render_selection() const; |     void _render_selection() const; | ||||||
|     void _render_warning_texture() const; |     void _render_warning_texture() const; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Enrico Turri
						Enrico Turri