mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
Added all kinds of options to layer view
This commit is contained in:
parent
fc4c60b0dc
commit
6271774528
8 changed files with 122 additions and 22 deletions
|
@ -76,8 +76,8 @@ class LayerDataBuilder(MeshBuilder):
|
|||
material_colors = numpy.zeros((line_dimensions.shape[0], 4), dtype=numpy.float32)
|
||||
for extruder_nr in range(material_color_map.shape[0]):
|
||||
material_colors[extruders == extruder_nr] = material_color_map[extruder_nr]
|
||||
material_colors[line_types == LayerPolygon.MoveCombingType] = [0.0, 0.0, 0.8, 1.0]
|
||||
material_colors[line_types == LayerPolygon.MoveRetractionType] = [0.0, 0.0, 0.8, 1.0]
|
||||
material_colors[line_types == LayerPolygon.MoveCombingType] = colors[line_types == LayerPolygon.MoveCombingType]
|
||||
material_colors[line_types == LayerPolygon.MoveRetractionType] = colors[line_types == LayerPolygon.MoveRetractionType]
|
||||
|
||||
attributes = {
|
||||
"line_dimensions": {
|
||||
|
|
|
@ -88,7 +88,6 @@ class LayerPolygon:
|
|||
|
||||
# Create an array with colors for each vertex and remove the color data for the points that has been thrown away.
|
||||
colors[self._vertex_begin:self._vertex_end, :] = numpy.tile(self._colors, (1, 2)).reshape((-1, 4))[needed_points_list.ravel()]
|
||||
colors[self._vertex_begin:self._vertex_end, :] *= numpy.array([[0.5, 0.5, 0.5, 1.0]], numpy.float32)
|
||||
|
||||
# Create an array with line widths for each vertex.
|
||||
line_dimensions[self._vertex_begin:self._vertex_end, 0] = numpy.tile(self._line_widths, (1, 2)).reshape((-1, 1))[needed_points_list.ravel()][:, 0]
|
||||
|
|
|
@ -105,6 +105,7 @@ class ProcessSlicedLayersJob(Job):
|
|||
polygon = layer.getRepeatedMessage("path_segment", p)
|
||||
|
||||
extruder = polygon.extruder
|
||||
x = dir(polygon)
|
||||
|
||||
line_types = numpy.fromstring(polygon.line_type, dtype="u1") # Convert bytearray to numpy array
|
||||
line_types = line_types.reshape((-1,1))
|
||||
|
|
|
@ -42,12 +42,20 @@ class LayerPass(RenderPass):
|
|||
self._layer_shader.setUniformValue("u_only_color_active_extruder", (1 if self._layer_view.getOnlyColorActiveExtruder() else 0))
|
||||
self._layer_shader.setUniformValue("u_extruder_opacity", self._layer_view.getExtruderOpacities())
|
||||
self._layer_shader.setUniformValue("u_show_travel_moves", self._layer_view.getShowTravelMoves())
|
||||
self._layer_shader.setUniformValue("u_show_support", self._layer_view.getShowSupport())
|
||||
self._layer_shader.setUniformValue("u_show_adhesion", self._layer_view.getShowAdhesion())
|
||||
self._layer_shader.setUniformValue("u_show_skin", self._layer_view.getShowSkin())
|
||||
self._layer_shader.setUniformValue("u_show_infill", self._layer_view.getShowInfill())
|
||||
else:
|
||||
#defaults
|
||||
self._layer_shader.setUniformValue("u_layer_view_type", 1)
|
||||
self._layer_shader.setUniformValue("u_only_color_active_extruder", 1)
|
||||
self._layer_shader.setUniformValue("u_extruder_opacity", [1, 1, 1, 1])
|
||||
self._layer_shader.setUniformValue("u_show_travel_moves", 0)
|
||||
self._layer_shader.setUniformValue("u_show_support", 1)
|
||||
self._layer_shader.setUniformValue("u_show_adhesion", 1)
|
||||
self._layer_shader.setUniformValue("u_show_skin", 1)
|
||||
self._layer_shader.setUniformValue("u_show_infill", 1)
|
||||
|
||||
if not self._tool_handle_shader:
|
||||
self._tool_handle_shader = OpenGL.getInstance().createShaderProgram(Resources.getPath(Resources.Shaders, "toolhandle.shader"))
|
||||
|
|
|
@ -64,6 +64,10 @@ class LayerView(View):
|
|||
self._only_color_active_extruder = True
|
||||
self._extruder_opacity = [1.0, 1.0, 1.0, 1.0]
|
||||
self._show_travel_moves = 0
|
||||
self._show_support = 1
|
||||
self._show_adhesion = 1
|
||||
self._show_skin = 1
|
||||
self._show_infill = 1
|
||||
|
||||
Preferences.getInstance().addPreference("view/top_layer_count", 5)
|
||||
Preferences.getInstance().addPreference("view/only_show_top_layers", False)
|
||||
|
@ -168,6 +172,34 @@ class LayerView(View):
|
|||
def getShowTravelMoves(self):
|
||||
return self._show_travel_moves
|
||||
|
||||
def setShowSupport(self, show):
|
||||
self._show_support = show
|
||||
self.currentLayerNumChanged.emit()
|
||||
|
||||
def getShowSupport(self):
|
||||
return self._show_support
|
||||
|
||||
def setShowAdhesion(self, show):
|
||||
self._show_adhesion = show
|
||||
self.currentLayerNumChanged.emit()
|
||||
|
||||
def getShowAdhesion(self):
|
||||
return self._show_adhesion
|
||||
|
||||
def setShowSkin(self, show):
|
||||
self._show_skin = show
|
||||
self.currentLayerNumChanged.emit()
|
||||
|
||||
def getShowSkin(self):
|
||||
return self._show_skin
|
||||
|
||||
def setShowInfill(self, show):
|
||||
self._show_infill = show
|
||||
self.currentLayerNumChanged.emit()
|
||||
|
||||
def getShowInfill(self):
|
||||
return self._show_infill
|
||||
|
||||
def calculateMaxLayers(self):
|
||||
scene = self.getController().getScene()
|
||||
self._activity = True
|
||||
|
|
|
@ -136,20 +136,15 @@ Item
|
|||
text: "Line type"
|
||||
type_id: 1 // these ids match the switching in the shader
|
||||
}
|
||||
ListElement {
|
||||
text: "Printing speed"
|
||||
type_id: 2
|
||||
}
|
||||
}
|
||||
|
||||
ComboBox
|
||||
{
|
||||
id: layer_type_combobox
|
||||
anchors.top: slider_background.bottom
|
||||
anchors.left: parent.left
|
||||
model: layerViewTypes
|
||||
onActivated: {
|
||||
CuraApplication.log("Combobox" + String(index));
|
||||
CuraApplication.log(layerViewTypes.get(index).type_id);
|
||||
UM.LayerView.setLayerViewType(layerViewTypes.get(index).type_id);
|
||||
}
|
||||
}
|
||||
|
@ -174,12 +169,39 @@ Item
|
|||
onClicked: {
|
||||
UM.LayerView.setShowTravelMoves(checked ? 1 : 0);
|
||||
}
|
||||
text: "Travel moves"
|
||||
text: "Show travel moves"
|
||||
}
|
||||
CheckBox {
|
||||
checked: true
|
||||
onClicked: {
|
||||
UM.LayerView.setShowSupport(checked ? 1 : 0);
|
||||
}
|
||||
text: "Show support"
|
||||
}
|
||||
CheckBox {
|
||||
checked: true
|
||||
onClicked: {
|
||||
UM.LayerView.setShowAdhesion(checked ? 1 : 0);
|
||||
}
|
||||
text: "Show adhesion"
|
||||
}
|
||||
CheckBox {
|
||||
checked: true
|
||||
onClicked: {
|
||||
UM.LayerView.setShowSkin(checked ? 1 : 0);
|
||||
}
|
||||
text: "Show skin"
|
||||
}
|
||||
CheckBox {
|
||||
checked: true
|
||||
onClicked: {
|
||||
UM.LayerView.setShowInfill(checked ? 1 : 0);
|
||||
}
|
||||
text: "Show infill"
|
||||
}
|
||||
CheckBox {
|
||||
checked: true
|
||||
onClicked: {
|
||||
CuraApplication.log("First" + checked);
|
||||
UM.LayerView.setOnlyColorActiveExtruder(checked);
|
||||
}
|
||||
text: "Only color active extruder"
|
||||
|
|
|
@ -69,12 +69,36 @@ class LayerViewProxy(QObject):
|
|||
if type(active_view) == LayerView.LayerView.LayerView:
|
||||
active_view.setExtruderOpacity(extruder_nr, opacity)
|
||||
|
||||
@pyqtSlot(bool)
|
||||
@pyqtSlot(int)
|
||||
def setShowTravelMoves(self, show):
|
||||
active_view = self._controller.getActiveView()
|
||||
if type(active_view) == LayerView.LayerView.LayerView:
|
||||
active_view.setShowTravelMoves(show)
|
||||
|
||||
@pyqtSlot(int)
|
||||
def setShowSupport(self, show):
|
||||
active_view = self._controller.getActiveView()
|
||||
if type(active_view) == LayerView.LayerView.LayerView:
|
||||
active_view.setShowSupport(show)
|
||||
|
||||
@pyqtSlot(int)
|
||||
def setShowAdhesion(self, show):
|
||||
active_view = self._controller.getActiveView()
|
||||
if type(active_view) == LayerView.LayerView.LayerView:
|
||||
active_view.setShowAdhesion(show)
|
||||
|
||||
@pyqtSlot(int)
|
||||
def setShowSkin(self, show):
|
||||
active_view = self._controller.getActiveView()
|
||||
if type(active_view) == LayerView.LayerView.LayerView:
|
||||
active_view.setShowSkin(show)
|
||||
|
||||
@pyqtSlot(int)
|
||||
def setShowInfill(self, show):
|
||||
active_view = self._controller.getActiveView()
|
||||
if type(active_view) == LayerView.LayerView.LayerView:
|
||||
active_view.setShowInfill(show)
|
||||
|
||||
def _layerActivityChanged(self):
|
||||
self.activityChanged.emit()
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@ vertex =
|
|||
uniform lowp int u_only_color_active_extruder;
|
||||
uniform lowp vec4 u_extruder_opacity; // currently only for max 4 extruders, others always visible
|
||||
|
||||
uniform lowp float u_shade_factor;
|
||||
uniform highp mat4 u_normalMatrix;
|
||||
|
||||
attribute highp vec4 a_vertex;
|
||||
|
@ -45,20 +44,15 @@ vertex =
|
|||
// shade the color depending on the extruder index stored in the alpha component of the color
|
||||
|
||||
switch (u_layer_view_type) {
|
||||
case 0: // "Line type"
|
||||
case 0: // "Material color"
|
||||
v_color = a_material_color;
|
||||
break;
|
||||
case 1: // "Material color"
|
||||
v_color = a_color;
|
||||
break;
|
||||
case 2: // "Speed"
|
||||
case 1: // "Line type"
|
||||
v_color = a_color;
|
||||
break;
|
||||
}
|
||||
if (u_only_color_active_extruder == 1) {
|
||||
v_color = (a_extruder == u_active_extruder) ? v_color : vec4(0.4, 0.4, 0.4, v_color.a);
|
||||
} else {
|
||||
v_color = (a_extruder == u_active_extruder) ? v_color : vec4((v_color * u_shade_factor).rgb, v_color.a);
|
||||
}
|
||||
if (a_extruder < 4) {
|
||||
v_color.a *= u_extruder_opacity[a_extruder]; // make it (in)visible
|
||||
|
@ -82,6 +76,10 @@ geometry =
|
|||
|
||||
uniform highp mat4 u_viewProjectionMatrix;
|
||||
uniform int u_show_travel_moves;
|
||||
uniform int u_show_support;
|
||||
uniform int u_show_adhesion;
|
||||
uniform int u_show_skin;
|
||||
uniform int u_show_infill;
|
||||
|
||||
layout(lines) in;
|
||||
layout(triangle_strip, max_vertices = 26) out;
|
||||
|
@ -113,9 +111,22 @@ geometry =
|
|||
float size_y;
|
||||
|
||||
// See LayerPolygon; 8 is MoveCombingType, 9 is RetractionType
|
||||
if (((v_line_type[0] == 8) || (v_line_type[0] == 9)) && (u_show_travel_moves == 0)) {
|
||||
if ((u_show_travel_moves == 0) && ((v_line_type[0] == 8) || (v_line_type[0] == 9))) {
|
||||
return;
|
||||
}
|
||||
if ((u_show_support == 0) && ((v_line_type[0] == 4) || (v_line_type[0] == 7) || (v_line_type[0] == 10))) {
|
||||
return;
|
||||
}
|
||||
if ((u_show_adhesion == 0) && (v_line_type[0] == 5)) {
|
||||
return;
|
||||
}
|
||||
if ((u_show_skin == 0) && ((v_line_type[0] == 1) || (v_line_type[0] == 2) || (v_line_type[0] == 3))) {
|
||||
return;
|
||||
}
|
||||
if ((u_show_infill == 0) && (v_line_type[0] == 6)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ((v_line_type[0] == 8) || (v_line_type[0] == 9)) {
|
||||
// fixed size for movements
|
||||
size_x = 0.1;
|
||||
|
@ -315,13 +326,16 @@ u_layer_view_type = 0
|
|||
u_only_color_active_extruder = 1
|
||||
u_extruder_opacity = [1.0, 1.0]
|
||||
|
||||
u_shade_factor = 0.60
|
||||
u_specularColor = [0.4, 0.4, 0.4, 1.0]
|
||||
u_ambientColor = [0.3, 0.3, 0.3, 0.0]
|
||||
u_diffuseColor = [1.0, 0.79, 0.14, 1.0]
|
||||
u_shininess = 20.0
|
||||
|
||||
u_show_travel_moves = 0
|
||||
u_show_support = 1
|
||||
u_show_adhesion = 1
|
||||
u_show_skin = 1
|
||||
u_show_infill = 1
|
||||
|
||||
[bindings]
|
||||
u_modelViewProjectionMatrix = model_view_projection_matrix
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue