Layerview can now deal with visibility extruder nrs. 4+

part of CURA-7426
This commit is contained in:
Remco Burema 2020-05-06 18:03:32 +02:00
parent 2687578a86
commit 99e99e4650
No known key found for this signature in database
GPG key ID: 215C49431D43F98C
6 changed files with 20 additions and 19 deletions

View file

@ -77,7 +77,7 @@ class SimulationPass(RenderPass):
self._layer_shader.setUniformValue("u_max_thickness", 1) self._layer_shader.setUniformValue("u_max_thickness", 1)
self._layer_shader.setUniformValue("u_min_thickness", 0) self._layer_shader.setUniformValue("u_min_thickness", 0)
self._layer_shader.setUniformValue("u_layer_view_type", 1) self._layer_shader.setUniformValue("u_layer_view_type", 1)
self._layer_shader.setUniformValue("u_extruder_opacity", [1, 1, 1, 1]) self._layer_shader.setUniformValue("u_extruder_opacity", [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]])
self._layer_shader.setUniformValue("u_show_travel_moves", 0) self._layer_shader.setUniformValue("u_show_travel_moves", 0)
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)

View file

@ -12,6 +12,7 @@ from UM.Event import Event, KeyEvent
from UM.Job import Job from UM.Job import Job
from UM.Logger import Logger from UM.Logger import Logger
from UM.Math.Color import Color from UM.Math.Color import Color
from UM.Math.Matrix import Matrix
from UM.Mesh.MeshBuilder import MeshBuilder from UM.Mesh.MeshBuilder import MeshBuilder
from UM.Message import Message from UM.Message import Message
from UM.Platform import Platform from UM.Platform import Platform
@ -139,7 +140,7 @@ class SimulationView(CuraView):
def _resetSettings(self) -> None: def _resetSettings(self) -> None:
self._layer_view_type = 0 # type: int # 0 is material color, 1 is color by linetype, 2 is speed, 3 is layer thickness self._layer_view_type = 0 # type: int # 0 is material color, 1 is color by linetype, 2 is speed, 3 is layer thickness
self._extruder_count = 0 self._extruder_count = 0
self._extruder_opacity = [1.0, 1.0, 1.0, 1.0] self._extruder_opacity = [[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]
self._show_travel_moves = False self._show_travel_moves = False
self._show_helpers = True self._show_helpers = True
self._show_skin = True self._show_skin = True
@ -308,15 +309,15 @@ class SimulationView(CuraView):
## Set the extruder opacity ## Set the extruder opacity
# #
# \param extruder_nr 0..3 # \param extruder_nr 0..15
# \param opacity 0.0 .. 1.0 # \param opacity 0.0 .. 1.0
def setExtruderOpacity(self, extruder_nr: int, opacity: float) -> None: def setExtruderOpacity(self, extruder_nr: int, opacity: float) -> None:
if 0 <= extruder_nr <= 3: if 0 <= extruder_nr <= 15:
self._extruder_opacity[extruder_nr] = opacity self._extruder_opacity[extruder_nr // 4][extruder_nr % 4] = opacity
self.currentLayerNumChanged.emit() self.currentLayerNumChanged.emit()
def getExtruderOpacities(self)-> List[float]: def getExtruderOpacities(self) -> Matrix:
return self._extruder_opacity return Matrix(self._extruder_opacity)
def setShowTravelMoves(self, show): def setShowTravelMoves(self, show):
self._show_travel_moves = show self._show_travel_moves = show

View file

@ -152,7 +152,7 @@ fragment41core =
u_active_extruder = 0.0 u_active_extruder = 0.0
u_shade_factor = 0.60 u_shade_factor = 0.60
u_layer_view_type = 0 u_layer_view_type = 0
u_extruder_opacity = [1.0, 1.0, 1.0, 1.0] u_extruder_opacity = [[1.0, 1.0, 1.0, 1.0],[1.0, 1.0, 1.0, 1.0],[1.0, 1.0, 1.0, 1.0],[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

View file

@ -11,7 +11,7 @@ vertex41core =
uniform lowp float u_max_thickness; uniform lowp float u_max_thickness;
uniform lowp float u_min_thickness; uniform lowp float u_min_thickness;
uniform lowp int u_layer_view_type; uniform lowp int u_layer_view_type;
uniform lowp vec4 u_extruder_opacity; // currently only for max 4 extruders, others always visible uniform lowp mat4 u_extruder_opacity; // currently only for max 16 extruders, others always visible
uniform highp mat4 u_normalMatrix; uniform highp mat4 u_normalMatrix;
@ -31,7 +31,7 @@ vertex41core =
out highp vec3 v_normal; out highp vec3 v_normal;
out lowp vec2 v_line_dim; out lowp vec2 v_line_dim;
out highp int v_extruder; out highp int v_extruder;
out highp vec4 v_extruder_opacity; out highp mat4 v_extruder_opacity;
out float v_line_type; out float v_line_type;
out lowp vec4 f_color; out lowp vec4 f_color;
@ -121,7 +121,7 @@ geometry41core =
in vec3 v_normal[]; in vec3 v_normal[];
in vec2 v_line_dim[]; in vec2 v_line_dim[];
in int v_extruder[]; in int v_extruder[];
in vec4 v_extruder_opacity[]; in mat4 v_extruder_opacity[];
in float v_line_type[]; in float v_line_type[];
out vec4 f_color; out vec4 f_color;
@ -152,7 +152,7 @@ geometry41core =
float size_x; float size_x;
float size_y; float size_y;
if ((v_extruder_opacity[0][v_extruder[0]] == 0.0) && (v_line_type[0] != 8) && (v_line_type[0] != 9)) { if ((v_extruder_opacity[0][int(mod(v_extruder[0], 4))][v_extruder[0]/4] == 0.0) && (v_line_type[0] != 8) && (v_line_type[0] != 9)) {
return; return;
} }
// See LayerPolygon; 8 is MoveCombingType, 9 is RetractionType // See LayerPolygon; 8 is MoveCombingType, 9 is RetractionType
@ -304,7 +304,7 @@ fragment41core =
[defaults] [defaults]
u_active_extruder = 0.0 u_active_extruder = 0.0
u_layer_view_type = 0 u_layer_view_type = 0
u_extruder_opacity = [1.0, 1.0, 1.0, 1.0] u_extruder_opacity = [[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]
u_specularColor = [0.4, 0.4, 0.4, 1.0] u_specularColor = [0.4, 0.4, 0.4, 1.0]
u_ambientColor = [0.3, 0.3, 0.3, 0.0] u_ambientColor = [0.3, 0.3, 0.3, 0.0]

View file

@ -6,7 +6,7 @@ vertex41core =
uniform highp mat4 u_projectionMatrix; uniform highp mat4 u_projectionMatrix;
uniform lowp float u_active_extruder; uniform lowp float u_active_extruder;
uniform lowp vec4 u_extruder_opacity; // currently only for max 4 extruders, others always visible uniform lowp mat4 u_extruder_opacity; // currently only for max 16 extruders, others always visible
uniform highp mat4 u_normalMatrix; uniform highp mat4 u_normalMatrix;
@ -25,7 +25,7 @@ vertex41core =
out highp vec3 v_normal; out highp vec3 v_normal;
out lowp vec2 v_line_dim; out lowp vec2 v_line_dim;
out highp int v_extruder; out highp int v_extruder;
out highp vec4 v_extruder_opacity; out highp mat4 v_extruder_opacity;
out float v_line_type; out float v_line_type;
out lowp vec4 f_color; out lowp vec4 f_color;
@ -75,7 +75,7 @@ geometry41core =
in vec3 v_normal[]; in vec3 v_normal[];
in vec2 v_line_dim[]; in vec2 v_line_dim[];
in int v_extruder[]; in int v_extruder[];
in vec4 v_extruder_opacity[]; in mat4 v_extruder_opacity[];
in float v_line_type[]; in float v_line_type[];
out vec4 f_color; out vec4 f_color;
@ -106,7 +106,7 @@ geometry41core =
float size_x; float size_x;
float size_y; float size_y;
if ((v_extruder_opacity[0][v_extruder[0]] == 0.0) && (v_line_type[0] != 8) && (v_line_type[0] != 9)) { if ((v_extruder_opacity[0][int(mod(v_extruder[0], 4))][v_extruder[0] / 4] == 0.0) && (v_line_type[0] != 8) && (v_line_type[0] != 9)) {
return; return;
} }
// See LayerPolygon; 8 is MoveCombingType, 9 is RetractionType // See LayerPolygon; 8 is MoveCombingType, 9 is RetractionType
@ -256,7 +256,7 @@ fragment41core =
[defaults] [defaults]
u_active_extruder = 0.0 u_active_extruder = 0.0
u_extruder_opacity = [1.0, 1.0, 1.0, 1.0] u_extruder_opacity = [[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]
u_specularColor = [0.4, 0.4, 0.4, 1.0] u_specularColor = [0.4, 0.4, 0.4, 1.0]
u_ambientColor = [0.3, 0.3, 0.3, 0.0] u_ambientColor = [0.3, 0.3, 0.3, 0.0]

View file

@ -157,7 +157,7 @@ fragment41core =
u_active_extruder = 0.0 u_active_extruder = 0.0
u_shade_factor = 0.60 u_shade_factor = 0.60
u_layer_view_type = 0 u_layer_view_type = 0
u_extruder_opacity = [1.0, 1.0, 1.0, 1.0] u_extruder_opacity = [[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [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