mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-12 01:07:52 -06:00
Merge branch 'dev' of https://github.com/BasF0/Cura
This commit is contained in:
commit
b219f57b22
5 changed files with 68 additions and 2 deletions
|
@ -15,9 +15,10 @@ from UM.View.RenderBatch import RenderBatch
|
||||||
from UM.View.GL.OpenGL import OpenGL
|
from UM.View.GL.OpenGL import OpenGL
|
||||||
|
|
||||||
from cura.Settings.ExtruderManager import ExtruderManager
|
from cura.Settings.ExtruderManager import ExtruderManager
|
||||||
|
from cura.LayerPolygon import LayerPolygon
|
||||||
|
|
||||||
import os.path
|
import os.path
|
||||||
|
import numpy
|
||||||
|
|
||||||
## RenderPass used to display g-code paths.
|
## RenderPass used to display g-code paths.
|
||||||
from .NozzleNode import NozzleNode
|
from .NozzleNode import NozzleNode
|
||||||
|
@ -60,6 +61,9 @@ class SimulationPass(RenderPass):
|
||||||
self._current_shader = self._layer_shader
|
self._current_shader = self._layer_shader
|
||||||
# Use extruder 0 if the extruder manager reports extruder index -1 (for single extrusion printers)
|
# Use extruder 0 if the extruder manager reports extruder index -1 (for single extrusion printers)
|
||||||
self._layer_shader.setUniformValue("u_active_extruder", float(max(0, self._extruder_manager.activeExtruderIndex)))
|
self._layer_shader.setUniformValue("u_active_extruder", float(max(0, self._extruder_manager.activeExtruderIndex)))
|
||||||
|
if not self._compatibility_mode:
|
||||||
|
self._layer_shader.setUniformValue("u_starts_color", Color(*Application.getInstance().getTheme().getColor("layerview_starts").getRgb()))
|
||||||
|
|
||||||
if self._layer_view:
|
if self._layer_view:
|
||||||
self._layer_shader.setUniformValue("u_max_feedrate", self._layer_view.getMaxFeedrate())
|
self._layer_shader.setUniformValue("u_max_feedrate", self._layer_view.getMaxFeedrate())
|
||||||
self._layer_shader.setUniformValue("u_min_feedrate", self._layer_view.getMinFeedrate())
|
self._layer_shader.setUniformValue("u_min_feedrate", self._layer_view.getMinFeedrate())
|
||||||
|
@ -71,6 +75,7 @@ class SimulationPass(RenderPass):
|
||||||
self._layer_shader.setUniformValue("u_show_helpers", self._layer_view.getShowHelpers())
|
self._layer_shader.setUniformValue("u_show_helpers", self._layer_view.getShowHelpers())
|
||||||
self._layer_shader.setUniformValue("u_show_skin", self._layer_view.getShowSkin())
|
self._layer_shader.setUniformValue("u_show_skin", self._layer_view.getShowSkin())
|
||||||
self._layer_shader.setUniformValue("u_show_infill", self._layer_view.getShowInfill())
|
self._layer_shader.setUniformValue("u_show_infill", self._layer_view.getShowInfill())
|
||||||
|
self._layer_shader.setUniformValue("u_show_starts", self._layer_view.getShowStarts())
|
||||||
else:
|
else:
|
||||||
#defaults
|
#defaults
|
||||||
self._layer_shader.setUniformValue("u_max_feedrate", 1)
|
self._layer_shader.setUniformValue("u_max_feedrate", 1)
|
||||||
|
@ -83,6 +88,7 @@ class SimulationPass(RenderPass):
|
||||||
self._layer_shader.setUniformValue("u_show_helpers", 1)
|
self._layer_shader.setUniformValue("u_show_helpers", 1)
|
||||||
self._layer_shader.setUniformValue("u_show_skin", 1)
|
self._layer_shader.setUniformValue("u_show_skin", 1)
|
||||||
self._layer_shader.setUniformValue("u_show_infill", 1)
|
self._layer_shader.setUniformValue("u_show_infill", 1)
|
||||||
|
self._layer_shader.setUniformValue("u_show_starts", 1)
|
||||||
|
|
||||||
if not self._tool_handle_shader:
|
if not self._tool_handle_shader:
|
||||||
self._tool_handle_shader = OpenGL.getInstance().createShaderProgram(Resources.getPath(Resources.Shaders, "toolhandle.shader"))
|
self._tool_handle_shader = OpenGL.getInstance().createShaderProgram(Resources.getPath(Resources.Shaders, "toolhandle.shader"))
|
||||||
|
@ -161,6 +167,13 @@ class SimulationPass(RenderPass):
|
||||||
self._current_shader = self._layer_shader
|
self._current_shader = self._layer_shader
|
||||||
self._switching_layers = True
|
self._switching_layers = True
|
||||||
|
|
||||||
|
# The first line does not have a previous line: add a MoveCombingType in front for start detection
|
||||||
|
# this way the first start of the layer can also be drawn
|
||||||
|
prev_line_types = numpy.concatenate([numpy.asarray([LayerPolygon.MoveCombingType], dtype = numpy.float32), layer_data._attributes["line_types"]["value"]])
|
||||||
|
# Remove the last element
|
||||||
|
prev_line_types = prev_line_types[0:layer_data._attributes["line_types"]["value"].size]
|
||||||
|
layer_data._attributes["prev_line_types"] = {'opengl_type': 'float', 'value': prev_line_types, 'opengl_name': 'a_prev_line_type'}
|
||||||
|
|
||||||
layers_batch = RenderBatch(self._current_shader, type = RenderBatch.RenderType.Solid, mode = RenderBatch.RenderMode.Lines, range = (start, end), backface_cull = True)
|
layers_batch = RenderBatch(self._current_shader, type = RenderBatch.RenderType.Solid, mode = RenderBatch.RenderMode.Lines, range = (start, end), backface_cull = True)
|
||||||
layers_batch.addItem(node.getWorldTransformation(), layer_data)
|
layers_batch.addItem(node.getWorldTransformation(), layer_data)
|
||||||
layers_batch.render(self._scene.getActiveCamera())
|
layers_batch.render(self._scene.getActiveCamera())
|
||||||
|
|
|
@ -111,6 +111,7 @@ class SimulationView(CuraView):
|
||||||
Application.getInstance().getPreferences().addPreference("layerview/show_helpers", True)
|
Application.getInstance().getPreferences().addPreference("layerview/show_helpers", True)
|
||||||
Application.getInstance().getPreferences().addPreference("layerview/show_skin", True)
|
Application.getInstance().getPreferences().addPreference("layerview/show_skin", True)
|
||||||
Application.getInstance().getPreferences().addPreference("layerview/show_infill", True)
|
Application.getInstance().getPreferences().addPreference("layerview/show_infill", True)
|
||||||
|
Application.getInstance().getPreferences().addPreference("layerview/show_starts", True)
|
||||||
|
|
||||||
self._updateWithPreferences()
|
self._updateWithPreferences()
|
||||||
|
|
||||||
|
@ -146,6 +147,7 @@ class SimulationView(CuraView):
|
||||||
self._show_helpers = True
|
self._show_helpers = True
|
||||||
self._show_skin = True
|
self._show_skin = True
|
||||||
self._show_infill = True
|
self._show_infill = True
|
||||||
|
self._show_starts = True
|
||||||
self.resetLayerData()
|
self.resetLayerData()
|
||||||
|
|
||||||
def getActivity(self) -> bool:
|
def getActivity(self) -> bool:
|
||||||
|
@ -355,6 +357,13 @@ class SimulationView(CuraView):
|
||||||
def getShowInfill(self) -> bool:
|
def getShowInfill(self) -> bool:
|
||||||
return self._show_infill
|
return self._show_infill
|
||||||
|
|
||||||
|
def setShowStarts(self, show: bool) -> None:
|
||||||
|
self._show_starts = show
|
||||||
|
self.currentLayerNumChanged.emit()
|
||||||
|
|
||||||
|
def getShowStarts(self) -> bool:
|
||||||
|
return self._show_starts
|
||||||
|
|
||||||
def getCompatibilityMode(self) -> bool:
|
def getCompatibilityMode(self) -> bool:
|
||||||
return self._compatibility_mode
|
return self._compatibility_mode
|
||||||
|
|
||||||
|
@ -638,6 +647,7 @@ class SimulationView(CuraView):
|
||||||
self.setShowHelpers(bool(Application.getInstance().getPreferences().getValue("layerview/show_helpers")))
|
self.setShowHelpers(bool(Application.getInstance().getPreferences().getValue("layerview/show_helpers")))
|
||||||
self.setShowSkin(bool(Application.getInstance().getPreferences().getValue("layerview/show_skin")))
|
self.setShowSkin(bool(Application.getInstance().getPreferences().getValue("layerview/show_skin")))
|
||||||
self.setShowInfill(bool(Application.getInstance().getPreferences().getValue("layerview/show_infill")))
|
self.setShowInfill(bool(Application.getInstance().getPreferences().getValue("layerview/show_infill")))
|
||||||
|
self.setShowStarts(bool(Application.getInstance().getPreferences().getValue("layerview/show_starts")))
|
||||||
|
|
||||||
self._startUpdateTopLayers()
|
self._startUpdateTopLayers()
|
||||||
self.preferencesChanged.emit()
|
self.preferencesChanged.emit()
|
||||||
|
@ -653,6 +663,7 @@ class SimulationView(CuraView):
|
||||||
"layerview/show_helpers",
|
"layerview/show_helpers",
|
||||||
"layerview/show_skin",
|
"layerview/show_skin",
|
||||||
"layerview/show_infill",
|
"layerview/show_infill",
|
||||||
|
"layerview/show_starts",
|
||||||
}:
|
}:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
@ -82,6 +82,7 @@ Cura.ExpandableComponent
|
||||||
property bool show_helpers: UM.Preferences.getValue("layerview/show_helpers")
|
property bool show_helpers: UM.Preferences.getValue("layerview/show_helpers")
|
||||||
property bool show_skin: UM.Preferences.getValue("layerview/show_skin")
|
property bool show_skin: UM.Preferences.getValue("layerview/show_skin")
|
||||||
property bool show_infill: UM.Preferences.getValue("layerview/show_infill")
|
property bool show_infill: UM.Preferences.getValue("layerview/show_infill")
|
||||||
|
property bool show_starts: UM.Preferences.getValue("layerview/show_starts")
|
||||||
|
|
||||||
// If we are in compatibility mode, we only show the "line type"
|
// If we are in compatibility mode, we only show the "line type"
|
||||||
property bool show_legend: UM.SimulationView.compatibilityMode ? true : UM.Preferences.getValue("layerview/layer_view_type") == 1
|
property bool show_legend: UM.SimulationView.compatibilityMode ? true : UM.Preferences.getValue("layerview/layer_view_type") == 1
|
||||||
|
@ -250,6 +251,12 @@ Cura.ExpandableComponent
|
||||||
preference: "layerview/show_infill",
|
preference: "layerview/show_infill",
|
||||||
colorId: "layerview_infill"
|
colorId: "layerview_infill"
|
||||||
});
|
});
|
||||||
|
typesLegendModel.append({
|
||||||
|
label: catalog.i18nc("@label", "Starts"),
|
||||||
|
initialValue: viewSettings.show_starts,
|
||||||
|
preference: "layerview/show_starts",
|
||||||
|
colorId: "layerview_starts"
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ vertex41core =
|
||||||
in highp vec4 a_normal;
|
in highp vec4 a_normal;
|
||||||
in highp vec2 a_line_dim; // line width and thickness
|
in highp vec2 a_line_dim; // line width and thickness
|
||||||
in highp float a_extruder;
|
in highp float a_extruder;
|
||||||
|
in highp float a_prev_line_type;
|
||||||
in highp float a_line_type;
|
in highp float a_line_type;
|
||||||
in highp float a_feedrate;
|
in highp float a_feedrate;
|
||||||
in highp float a_thickness;
|
in highp float a_thickness;
|
||||||
|
@ -32,6 +33,7 @@ vertex41core =
|
||||||
out lowp vec2 v_line_dim;
|
out lowp vec2 v_line_dim;
|
||||||
out highp int v_extruder;
|
out highp int v_extruder;
|
||||||
out highp mat4 v_extruder_opacity;
|
out highp mat4 v_extruder_opacity;
|
||||||
|
out float v_prev_line_type;
|
||||||
out float v_line_type;
|
out float v_line_type;
|
||||||
|
|
||||||
out lowp vec4 f_color;
|
out lowp vec4 f_color;
|
||||||
|
@ -92,6 +94,7 @@ vertex41core =
|
||||||
v_normal = (u_normalMatrix * normalize(a_normal)).xyz;
|
v_normal = (u_normalMatrix * normalize(a_normal)).xyz;
|
||||||
v_line_dim = a_line_dim;
|
v_line_dim = a_line_dim;
|
||||||
v_extruder = int(a_extruder);
|
v_extruder = int(a_extruder);
|
||||||
|
v_prev_line_type = a_prev_line_type;
|
||||||
v_line_type = a_line_type;
|
v_line_type = a_line_type;
|
||||||
v_extruder_opacity = u_extruder_opacity;
|
v_extruder_opacity = u_extruder_opacity;
|
||||||
|
|
||||||
|
@ -108,13 +111,16 @@ geometry41core =
|
||||||
uniform highp mat4 u_viewMatrix;
|
uniform highp mat4 u_viewMatrix;
|
||||||
uniform highp mat4 u_projectionMatrix;
|
uniform highp mat4 u_projectionMatrix;
|
||||||
|
|
||||||
|
uniform lowp vec4 u_starts_color;
|
||||||
|
|
||||||
uniform int u_show_travel_moves;
|
uniform int u_show_travel_moves;
|
||||||
uniform int u_show_helpers;
|
uniform int u_show_helpers;
|
||||||
uniform int u_show_skin;
|
uniform int u_show_skin;
|
||||||
uniform int u_show_infill;
|
uniform int u_show_infill;
|
||||||
|
uniform int u_show_starts;
|
||||||
|
|
||||||
layout(lines) in;
|
layout(lines) in;
|
||||||
layout(triangle_strip, max_vertices = 26) out;
|
layout(triangle_strip, max_vertices = 40) out;
|
||||||
|
|
||||||
in vec4 v_color[];
|
in vec4 v_color[];
|
||||||
in vec3 v_vertex[];
|
in vec3 v_vertex[];
|
||||||
|
@ -122,6 +128,7 @@ geometry41core =
|
||||||
in vec2 v_line_dim[];
|
in vec2 v_line_dim[];
|
||||||
in int v_extruder[];
|
in int v_extruder[];
|
||||||
in mat4 v_extruder_opacity[];
|
in mat4 v_extruder_opacity[];
|
||||||
|
in float v_prev_line_type[];
|
||||||
in float v_line_type[];
|
in float v_line_type[];
|
||||||
|
|
||||||
out vec4 f_color;
|
out vec4 f_color;
|
||||||
|
@ -268,6 +275,29 @@ geometry41core =
|
||||||
|
|
||||||
EndPrimitive();
|
EndPrimitive();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ((u_show_starts == 1) && (v_prev_line_type[0] != 1) && (v_line_type[0] == 1)) {
|
||||||
|
float w = v_line_dim[0].x / 2;
|
||||||
|
float h = v_line_dim[0].y / 2;
|
||||||
|
|
||||||
|
myEmitVertex(v_vertex[0] + vec3( w, h, w), u_starts_color, normalize(vec3( 1.0, 1.0, 1.0)), viewProjectionMatrix * (gl_in[0].gl_Position + vec4( w, h, w, 0.0))); // Front-top-left
|
||||||
|
myEmitVertex(v_vertex[0] + vec3(-w, h, w), u_starts_color, normalize(vec3(-1.0, 1.0, 1.0)), viewProjectionMatrix * (gl_in[0].gl_Position + vec4(-w, h, w, 0.0))); // Front-top-right
|
||||||
|
myEmitVertex(v_vertex[0] + vec3( w, -h, w), u_starts_color, normalize(vec3( 1.0, -1.0, 1.0)), viewProjectionMatrix * (gl_in[0].gl_Position + vec4( w, -h, w, 0.0))); // Front-bottom-left
|
||||||
|
myEmitVertex(v_vertex[0] + vec3(-w, -h, w), u_starts_color, normalize(vec3(-1.0, -1.0, 1.0)), viewProjectionMatrix * (gl_in[0].gl_Position + vec4(-w, -h, w, 0.0))); // Front-bottom-right
|
||||||
|
myEmitVertex(v_vertex[0] + vec3(-w, -h, -w), u_starts_color, normalize(vec3(-1.0, -1.0, -1.0)), viewProjectionMatrix * (gl_in[0].gl_Position + vec4(-w, -h, -w, 0.0))); // Back-bottom-right
|
||||||
|
myEmitVertex(v_vertex[0] + vec3(-w, h, w), u_starts_color, normalize(vec3(-1.0, 1.0, 1.0)), viewProjectionMatrix * (gl_in[0].gl_Position + vec4(-w, h, w, 0.0))); // Front-top-right
|
||||||
|
myEmitVertex(v_vertex[0] + vec3(-w, h, -w), u_starts_color, normalize(vec3(-1.0, 1.0, -1.0)), viewProjectionMatrix * (gl_in[0].gl_Position + vec4(-w, h, -w, 0.0))); // Back-top-right
|
||||||
|
myEmitVertex(v_vertex[0] + vec3( w, h, w), u_starts_color, normalize(vec3( 1.0, 1.0, 1.0)), viewProjectionMatrix * (gl_in[0].gl_Position + vec4( w, h, w, 0.0))); // Front-top-left
|
||||||
|
myEmitVertex(v_vertex[0] + vec3( w, h, -w), u_starts_color, normalize(vec3( 1.0, 1.0, -1.0)), viewProjectionMatrix * (gl_in[0].gl_Position + vec4( w, h, -w, 0.0))); // Back-top-left
|
||||||
|
myEmitVertex(v_vertex[0] + vec3( w, -h, w), u_starts_color, normalize(vec3( 1.0, -1.0, 1.0)), viewProjectionMatrix * (gl_in[0].gl_Position + vec4( w, -h, w, 0.0))); // Front-bottom-left
|
||||||
|
myEmitVertex(v_vertex[0] + vec3( w, -h, -w), u_starts_color, normalize(vec3( 1.0, -1.0, -1.0)), viewProjectionMatrix * (gl_in[0].gl_Position + vec4( w, -h, -w, 0.0))); // Back-bottom-left
|
||||||
|
myEmitVertex(v_vertex[0] + vec3(-w, -h, -w), u_starts_color, normalize(vec3(-1.0, -1.0, -1.0)), viewProjectionMatrix * (gl_in[0].gl_Position + vec4(-w, -h, -w, 0.0))); // Back-bottom-right
|
||||||
|
myEmitVertex(v_vertex[0] + vec3( w, h, -w), u_starts_color, normalize(vec3( 1.0, 1.0, -1.0)), viewProjectionMatrix * (gl_in[0].gl_Position + vec4( w, h, -w, 0.0))); // Back-top-left
|
||||||
|
myEmitVertex(v_vertex[0] + vec3(-w, h, -w), u_starts_color, normalize(vec3(-1.0, 1.0, -1.0)), viewProjectionMatrix * (gl_in[0].gl_Position + vec4(-w, h, -w, 0.0))); // Back-top-right
|
||||||
|
|
||||||
|
EndPrimitive();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fragment41core =
|
fragment41core =
|
||||||
|
@ -312,10 +342,13 @@ u_diffuseColor = [1.0, 0.79, 0.14, 1.0]
|
||||||
u_minimumAlbedo = [0.1, 0.1, 0.1, 1.0]
|
u_minimumAlbedo = [0.1, 0.1, 0.1, 1.0]
|
||||||
u_shininess = 20.0
|
u_shininess = 20.0
|
||||||
|
|
||||||
|
u_starts_color = [1.0, 1.0, 1.0, 1.0]
|
||||||
|
|
||||||
u_show_travel_moves = 0
|
u_show_travel_moves = 0
|
||||||
u_show_helpers = 1
|
u_show_helpers = 1
|
||||||
u_show_skin = 1
|
u_show_skin = 1
|
||||||
u_show_infill = 1
|
u_show_infill = 1
|
||||||
|
u_show_starts = 1
|
||||||
|
|
||||||
u_min_feedrate = 0
|
u_min_feedrate = 0
|
||||||
u_max_feedrate = 1
|
u_max_feedrate = 1
|
||||||
|
@ -337,6 +370,7 @@ a_normal = normal
|
||||||
a_line_dim = line_dim
|
a_line_dim = line_dim
|
||||||
a_extruder = extruder
|
a_extruder = extruder
|
||||||
a_material_color = material_color
|
a_material_color = material_color
|
||||||
|
a_prev_line_type = prev_line_type
|
||||||
a_line_type = line_type
|
a_line_type = line_type
|
||||||
a_feedrate = feedrate
|
a_feedrate = feedrate
|
||||||
a_thickness = thickness
|
a_thickness = thickness
|
||||||
|
|
|
@ -389,6 +389,7 @@
|
||||||
"layerview_support_interface": [63, 127, 255, 127],
|
"layerview_support_interface": [63, 127, 255, 127],
|
||||||
"layerview_prime_tower": [0, 255, 255, 255],
|
"layerview_prime_tower": [0, 255, 255, 255],
|
||||||
"layerview_nozzle": [224, 192, 16, 64],
|
"layerview_nozzle": [224, 192, 16, 64],
|
||||||
|
"layerview_starts": [255, 255, 255, 255],
|
||||||
|
|
||||||
"tab_status_connected": [50, 130, 255, 255],
|
"tab_status_connected": [50, 130, 255, 255],
|
||||||
"tab_status_disconnected": [200, 200, 200, 255],
|
"tab_status_disconnected": [200, 200, 200, 255],
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue