mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-12-05 16:51:12 -07:00
Merge branch 'master' of https://github.com/Ultimaker/Cura
This commit is contained in:
commit
e524d028d7
64 changed files with 12202 additions and 441 deletions
|
|
@ -42,6 +42,10 @@ class ThreeMFReader(MeshReader):
|
|||
|
||||
# There can be multiple objects, try to load all of them.
|
||||
objects = root.findall("./3mf:resources/3mf:object", self._namespaces)
|
||||
if len(objects) == 0:
|
||||
Logger.log("w", "No objects found in 3MF file %s, either the file is corrupt or you are using an outdated format", file_name)
|
||||
return None
|
||||
|
||||
for object in objects:
|
||||
mesh = MeshData()
|
||||
node = SceneNode()
|
||||
|
|
@ -53,18 +57,17 @@ class ThreeMFReader(MeshReader):
|
|||
triangles = object.findall(".//3mf:triangle", self._namespaces)
|
||||
|
||||
mesh.reserveFaceCount(len(triangles))
|
||||
|
||||
|
||||
#for triangle in object.mesh.triangles.triangle:
|
||||
for triangle in triangles:
|
||||
v1 = int(triangle.get("v1"))
|
||||
v2 = int(triangle.get("v2"))
|
||||
v3 = int(triangle.get("v3"))
|
||||
mesh.addFace(vertex_list[v1][0],vertex_list[v1][2],vertex_list[v1][1],vertex_list[v2][0],vertex_list[v2][2],vertex_list[v2][1],vertex_list[v3][0],vertex_list[v3][2],vertex_list[v3][1])
|
||||
#TODO: We currently do not check for normals and simply recalculate them.
|
||||
mesh.addFace(vertex_list[v1][0],vertex_list[v1][1],vertex_list[v1][2],vertex_list[v2][0],vertex_list[v2][1],vertex_list[v2][2],vertex_list[v3][0],vertex_list[v3][1],vertex_list[v3][2])
|
||||
#TODO: We currently do not check for normals and simply recalculate them.
|
||||
mesh.calculateNormals()
|
||||
node.setMeshData(mesh)
|
||||
node.setSelectable(True)
|
||||
Logger.log("d", "Loaded a mesh with %s vertices", mesh.getVertexCount())
|
||||
|
||||
transformation = root.findall("./3mf:build/3mf:item[@objectid='{0}']".format(object.get("id")), self._namespaces)
|
||||
if transformation:
|
||||
|
|
@ -89,18 +92,18 @@ class ThreeMFReader(MeshReader):
|
|||
temp_mat._data[0,2] = splitted_transformation[6]
|
||||
temp_mat._data[1,2] = splitted_transformation[7]
|
||||
temp_mat._data[2,2] = splitted_transformation[8]
|
||||
|
||||
|
||||
# Translation
|
||||
temp_mat._data[0,3] = splitted_transformation[9]
|
||||
temp_mat._data[1,3] = splitted_transformation[10]
|
||||
temp_mat._data[2,3] = splitted_transformation[11]
|
||||
|
||||
|
||||
node.setPosition(Vector(temp_mat.at(0,3), temp_mat.at(1,3), temp_mat.at(2,3)))
|
||||
|
||||
|
||||
temp_quaternion = Quaternion()
|
||||
temp_quaternion.setByMatrix(temp_mat)
|
||||
node.setOrientation(temp_quaternion)
|
||||
|
||||
|
||||
# Magical scale extraction
|
||||
S2 = temp_mat.getTransposed().multiply(temp_mat)
|
||||
scale_x = math.sqrt(S2.at(0,0))
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ class ChangeLog(Extension, QObject,):
|
|||
self._change_logs = None
|
||||
Application.getInstance().engineCreatedSignal.connect(self._onEngineCreated)
|
||||
Preferences.getInstance().addPreference("general/latest_version_changelog_shown", "15.05.90") #First version of CURA with uranium
|
||||
self.addMenuItem(catalog.i18nc("@item:inmenu", "Show Changelog"), self.showChangelog)
|
||||
#self.showChangelog()
|
||||
|
||||
def getChangeLogs(self):
|
||||
|
|
@ -77,8 +78,8 @@ class ChangeLog(Extension, QObject,):
|
|||
def _onEngineCreated(self):
|
||||
if not self._version:
|
||||
return #We're on dev branch.
|
||||
if self._version > Preferences.getInstance().getValue("general/latest_version_changelog_shown"):
|
||||
self.showChangelog()
|
||||
#if self._version > Preferences.getInstance().getValue("general/latest_version_changelog_shown"):
|
||||
#self.showChangelog()
|
||||
|
||||
def showChangelog(self):
|
||||
if not self._changelog_window:
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ catalog = i18nCatalog("cura")
|
|||
def getMetaData():
|
||||
return {
|
||||
"plugin": {
|
||||
"name": catalog.i18nc("@label", "Change Log"),
|
||||
"name": catalog.i18nc("@label", "Changelog"),
|
||||
"author": "Ultimaker",
|
||||
"version": "1.0",
|
||||
"description": catalog.i18nc("@info:whatsthis", "Shows changes since latest checked version"),
|
||||
|
|
|
|||
|
|
@ -77,12 +77,20 @@ class CuraEngineBackend(Backend):
|
|||
self._message = None
|
||||
|
||||
self.backendConnected.connect(self._onBackendConnected)
|
||||
Application.getInstance().getController().toolOperationStarted.connect(self._onToolOperationStarted)
|
||||
Application.getInstance().getController().toolOperationStopped.connect(self._onToolOperationStopped)
|
||||
|
||||
Application.getInstance().getMachineManager().activeMachineInstanceChanged.connect(self._onInstanceChanged)
|
||||
|
||||
## Get the command that is used to call the engine.
|
||||
# This is usefull for debugging and used to actually start the engine
|
||||
# \return list of commands and args / parameters.
|
||||
def getEngineCommand(self):
|
||||
return [Preferences.getInstance().getValue("backend/location"), "connect", "127.0.0.1:{0}".format(self._port), "-j", Resources.getPath(Resources.MachineDefinitions, "fdmprinter.json"), "-vv"]
|
||||
active_machine = Application.getInstance().getMachineManager().getActiveMachineInstance()
|
||||
if not active_machine:
|
||||
return None
|
||||
|
||||
return [Preferences.getInstance().getValue("backend/location"), "connect", "127.0.0.1:{0}".format(self._port), "-j", active_machine.getMachineDefinition().getPath(), "-vv"]
|
||||
|
||||
## Emitted when we get a message containing print duration and material amount. This also implies the slicing has finished.
|
||||
# \param time The amount of time the print will take.
|
||||
|
|
@ -123,6 +131,7 @@ class CuraEngineBackend(Backend):
|
|||
pass
|
||||
self.slicingCancelled.emit()
|
||||
return
|
||||
|
||||
Logger.log("d", "Preparing to send slice data to engine.")
|
||||
object_groups = []
|
||||
if self._profile.getSettingValue("print_sequence") == "one_at_a_time":
|
||||
|
|
@ -221,10 +230,16 @@ class CuraEngineBackend(Backend):
|
|||
self._socket.sendMessage(slice_message)
|
||||
|
||||
def _onSceneChanged(self, source):
|
||||
if (type(source) is not SceneNode) or (source is self._scene.getRoot()) or (source.getMeshData() is None):
|
||||
if type(source) is not SceneNode:
|
||||
return
|
||||
|
||||
if(source.getMeshData().getVertices() is None):
|
||||
if source is self._scene.getRoot():
|
||||
return
|
||||
|
||||
if source.getMeshData() is None:
|
||||
return
|
||||
|
||||
if source.getMeshData().getVertices() is None:
|
||||
return
|
||||
|
||||
self._onChanged()
|
||||
|
|
@ -327,6 +342,7 @@ class CuraEngineBackend(Backend):
|
|||
if self._stored_layer_data:
|
||||
job = ProcessSlicedObjectListJob.ProcessSlicedObjectListJob(self._stored_layer_data)
|
||||
job.start()
|
||||
self._stored_layer_data = None
|
||||
else:
|
||||
self._layer_view_active = False
|
||||
|
||||
|
|
@ -346,3 +362,14 @@ class CuraEngineBackend(Backend):
|
|||
setting = message.settings.add()
|
||||
setting.name = key
|
||||
setting.value = str(value).encode()
|
||||
|
||||
def _onInstanceChanged(self):
|
||||
self._slicing = False
|
||||
self._restart = True
|
||||
if self._process is not None:
|
||||
Logger.log("d", "Killing engine process")
|
||||
try:
|
||||
self._process.terminate()
|
||||
except: # terminating a process that is already terminating causes an exception, silently ignore this.
|
||||
pass
|
||||
self.slicingCancelled.emit()
|
||||
|
|
|
|||
|
|
@ -102,15 +102,16 @@ class LayerView(View):
|
|||
continue
|
||||
except:
|
||||
continue
|
||||
|
||||
self._current_layer_mesh.addVertices(layer_mesh.getVertices())
|
||||
if self._current_layer_mesh: #Threading thing; Switching between views can cause the current layer mesh to be deleted.
|
||||
self._current_layer_mesh.addVertices(layer_mesh.getVertices())
|
||||
|
||||
# Scale layer color by a brightness factor based on the current layer number
|
||||
# This will result in a range of 0.5 - 1.0 to multiply colors by.
|
||||
brightness = (2.0 - (i / self._solid_layers)) / 2.0
|
||||
self._current_layer_mesh.addColors(layer_mesh.getColors() * brightness)
|
||||
|
||||
renderer.queueNode(node, mesh = self._current_layer_mesh, material = self._material)
|
||||
if self._current_layer_mesh:
|
||||
self._current_layer_mesh.addColors(layer_mesh.getColors() * brightness)
|
||||
if self._current_layer_mesh:
|
||||
renderer.queueNode(node, mesh = self._current_layer_mesh, material = self._material)
|
||||
|
||||
if not self._current_layer_jumps:
|
||||
self._current_layer_jumps = MeshData()
|
||||
|
|
|
|||
109
plugins/PerObjectSettingsTool/PerObjectSettingsModel.py
Normal file
109
plugins/PerObjectSettingsTool/PerObjectSettingsModel.py
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
# Copyright (c) 2015 Ultimaker B.V.
|
||||
# Uranium is released under the terms of the AGPLv3 or higher.
|
||||
|
||||
from PyQt5.QtCore import Qt, pyqtSlot, QUrl
|
||||
|
||||
from UM.Application import Application
|
||||
from UM.Qt.ListModel import ListModel
|
||||
from UM.Scene.Iterator.BreadthFirstIterator import BreadthFirstIterator
|
||||
from UM.Scene.SceneNode import SceneNode
|
||||
from UM.Settings.SettingOverrideDecorator import SettingOverrideDecorator
|
||||
from UM.Settings.ProfileOverrideDecorator import ProfileOverrideDecorator
|
||||
|
||||
from . import SettingOverrideModel
|
||||
|
||||
class PerObjectSettingsModel(ListModel):
|
||||
IdRole = Qt.UserRole + 1
|
||||
XRole = Qt.UserRole + 2
|
||||
YRole = Qt.UserRole + 3
|
||||
MaterialRole = Qt.UserRole + 4
|
||||
ProfileRole = Qt.UserRole + 5
|
||||
SettingsRole = Qt.UserRole + 6
|
||||
|
||||
def __init__(self, parent = None):
|
||||
super().__init__(parent)
|
||||
self._scene = Application.getInstance().getController().getScene()
|
||||
self._root = self._scene.getRoot()
|
||||
self._root.transformationChanged.connect(self._updatePositions)
|
||||
self._root.childrenChanged.connect(self._updateNodes)
|
||||
self._updateNodes(None)
|
||||
|
||||
self.addRoleName(self.IdRole,"id")
|
||||
self.addRoleName(self.XRole,"x")
|
||||
self.addRoleName(self.YRole,"y")
|
||||
self.addRoleName(self.MaterialRole, "material")
|
||||
self.addRoleName(self.ProfileRole, "profile")
|
||||
self.addRoleName(self.SettingsRole, "settings")
|
||||
|
||||
@pyqtSlot("quint64", str)
|
||||
def setObjectProfile(self, object_id, profile_name):
|
||||
self.setProperty(self.find("id", object_id), "profile", profile_name)
|
||||
|
||||
profile = None
|
||||
if profile_name != "global":
|
||||
profile = Application.getInstance().getMachineManager().findProfile(profile_name)
|
||||
|
||||
node = self._scene.findObject(object_id)
|
||||
if profile:
|
||||
if not node.getDecorator(ProfileOverrideDecorator):
|
||||
node.addDecorator(ProfileOverrideDecorator())
|
||||
node.callDecoration("setProfile", profile)
|
||||
else:
|
||||
if node.getDecorator(ProfileOverrideDecorator):
|
||||
node.removeDecorator(ProfileOverrideDecorator)
|
||||
|
||||
@pyqtSlot("quint64", str)
|
||||
def addSettingOverride(self, object_id, key):
|
||||
machine = Application.getInstance().getMachineManager().getActiveMachineInstance()
|
||||
if not machine:
|
||||
return
|
||||
|
||||
node = self._scene.findObject(object_id)
|
||||
if not node.getDecorator(SettingOverrideDecorator):
|
||||
node.addDecorator(SettingOverrideDecorator())
|
||||
|
||||
node.callDecoration("addSetting", key)
|
||||
|
||||
@pyqtSlot("quint64", str)
|
||||
def removeSettingOverride(self, object_id, key):
|
||||
node = self._scene.findObject(object_id)
|
||||
node.callDecoration("removeSetting", key)
|
||||
|
||||
if len(node.callDecoration("getAllSettings")) == 0:
|
||||
node.removeDecorator(SettingOverrideDecorator)
|
||||
|
||||
def _updatePositions(self, source):
|
||||
camera = Application.getInstance().getController().getScene().getActiveCamera()
|
||||
for node in BreadthFirstIterator(self._root):
|
||||
if type(node) is not SceneNode or not node.getMeshData():
|
||||
continue
|
||||
|
||||
projected_position = camera.project(node.getWorldPosition())
|
||||
|
||||
index = self.find("id", id(node))
|
||||
self.setProperty(index, "x", float(projected_position[0]))
|
||||
self.setProperty(index, "y", float(projected_position[1]))
|
||||
|
||||
def _updateNodes(self, source):
|
||||
self.clear()
|
||||
camera = Application.getInstance().getController().getScene().getActiveCamera()
|
||||
for node in BreadthFirstIterator(self._root):
|
||||
if type(node) is not SceneNode or not node.getMeshData() or not node.isSelectable():
|
||||
continue
|
||||
|
||||
projected_position = camera.project(node.getWorldPosition())
|
||||
|
||||
node_profile = node.callDecoration("getProfile")
|
||||
if not node_profile:
|
||||
node_profile = "global"
|
||||
else:
|
||||
node_profile = node_profile.getName()
|
||||
|
||||
self.appendItem({
|
||||
"id": id(node),
|
||||
"x": float(projected_position[0]),
|
||||
"y": float(projected_position[1]),
|
||||
"material": "",
|
||||
"profile": node_profile,
|
||||
"settings": SettingOverrideModel.SettingOverrideModel(node)
|
||||
})
|
||||
352
plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml
Normal file
352
plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml
Normal file
|
|
@ -0,0 +1,352 @@
|
|||
// Copyright (c) 2015 Ultimaker B.V.
|
||||
// Uranium is released under the terms of the AGPLv3 or higher.
|
||||
|
||||
import QtQuick 2.2
|
||||
import QtQuick.Controls 1.2
|
||||
import QtQuick.Controls.Styles 1.2
|
||||
import QtQuick.Window 2.2
|
||||
|
||||
import UM 1.1 as UM
|
||||
|
||||
Item {
|
||||
id: base;
|
||||
|
||||
width: 0;
|
||||
height: 0;
|
||||
|
||||
property variant position: mapToItem(null, 0, 0)
|
||||
|
||||
property real viewportWidth: UM.Application.mainWindow.width * UM.Application.mainWindow.viewportRect.width;
|
||||
property real viewportHeight: UM.Application.mainWindow.height * UM.Application.mainWindow.viewportRect.height;
|
||||
|
||||
property int currentIndex;
|
||||
|
||||
Rectangle {
|
||||
id: settingsPanel;
|
||||
|
||||
z: 3;
|
||||
|
||||
width: UM.Theme.sizes.per_object_settings_panel.width;
|
||||
height: items.height + UM.Theme.sizes.default_margin.height * 2;
|
||||
|
||||
opacity: 0;
|
||||
Behavior on opacity { NumberAnimation { } }
|
||||
|
||||
border.width: UM.Theme.sizes.per_object_settings_panel_border.width;
|
||||
border.color: UM.Theme.colors.per_object_settings_panel_border;
|
||||
|
||||
color: UM.Theme.colors.per_object_settings_panel_background;
|
||||
|
||||
DropArea {
|
||||
anchors.fill: parent;
|
||||
}
|
||||
|
||||
Column {
|
||||
id: items
|
||||
anchors.top: parent.top;
|
||||
anchors.topMargin: UM.Theme.sizes.default_margin.height;
|
||||
|
||||
spacing: UM.Theme.sizes.default_lining.height;
|
||||
|
||||
UM.SettingItem {
|
||||
id: profileSelection
|
||||
|
||||
x: UM.Theme.sizes.per_object_settings_panel_border.width + 1
|
||||
|
||||
width: UM.Theme.sizes.setting.width;
|
||||
height: UM.Theme.sizes.setting.height;
|
||||
|
||||
name: catalog.i18nc("@label", "Profile")
|
||||
type: "enum"
|
||||
perObjectSetting: true
|
||||
|
||||
style: UM.Theme.styles.setting_item;
|
||||
|
||||
options: UM.ProfilesModel { addUseGlobal: true }
|
||||
|
||||
value: UM.ActiveTool.properties.Model.getItem(base.currentIndex).profile
|
||||
|
||||
onItemValueChanged: {
|
||||
var item = UM.ActiveTool.properties.Model.getItem(base.currentIndex);
|
||||
UM.ActiveTool.properties.Model.setObjectProfile(item.id, value)
|
||||
}
|
||||
}
|
||||
|
||||
Repeater {
|
||||
id: settings;
|
||||
|
||||
model: UM.ActiveTool.properties.Model.getItem(base.currentIndex).settings
|
||||
|
||||
UM.SettingItem {
|
||||
width: UM.Theme.sizes.setting.width;
|
||||
height: UM.Theme.sizes.setting.height;
|
||||
x: UM.Theme.sizes.per_object_settings_panel_border.width + 1
|
||||
|
||||
name: model.label;
|
||||
type: model.type;
|
||||
value: model.value;
|
||||
description: model.description;
|
||||
unit: model.unit;
|
||||
valid: model.valid;
|
||||
perObjectSetting: true
|
||||
dismissable: true
|
||||
options: model.options
|
||||
|
||||
style: UM.Theme.styles.setting_item;
|
||||
|
||||
onItemValueChanged: {
|
||||
settings.model.setSettingValue(model.key, value)
|
||||
}
|
||||
|
||||
// Button {
|
||||
// anchors.left: parent.right;
|
||||
// text: "x";
|
||||
//
|
||||
// width: UM.Theme.sizes.setting.height;
|
||||
// height: UM.Theme.sizes.setting.height;
|
||||
//
|
||||
// opacity: parent.hovered || hovered ? 1 : 0;
|
||||
// onClicked: UM.ActiveTool.properties.Model.removeSettingOverride(UM.ActiveTool.properties.Model.getItem(base.currentIndex).id, model.key)
|
||||
//
|
||||
// style: ButtonStyle { }
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
Item
|
||||
{
|
||||
height: UM.Theme.sizes.default_margin.height / 2
|
||||
width: parent.width
|
||||
}
|
||||
|
||||
Button
|
||||
{
|
||||
id: customise_settings_button;
|
||||
anchors.right: profileSelection.right;
|
||||
visible: parseInt(UM.Preferences.getValue("cura/active_mode")) == 1
|
||||
|
||||
text: catalog.i18nc("@action:button", "Customize Settings");
|
||||
|
||||
style: ButtonStyle
|
||||
{
|
||||
background: Rectangle
|
||||
{
|
||||
width: control.width;
|
||||
height: control.height;
|
||||
color: control.hovered ? UM.Theme.colors.load_save_button_hover : UM.Theme.colors.load_save_button;
|
||||
}
|
||||
label: Label
|
||||
{
|
||||
text: control.text;
|
||||
color: UM.Theme.colors.load_save_button_text;
|
||||
}
|
||||
}
|
||||
|
||||
onClicked: settingPickDialog.visible = true;
|
||||
|
||||
Connections
|
||||
{
|
||||
target: UM.Preferences;
|
||||
|
||||
onPreferenceChanged:
|
||||
{
|
||||
customise_settings_button.visible = parseInt(UM.Preferences.getValue("cura/active_mode"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UM.I18nCatalog { id: catalog; name: "uranium"; }
|
||||
}
|
||||
|
||||
Repeater {
|
||||
model: UM.ActiveTool.properties.Model;
|
||||
delegate: Button {
|
||||
x: ((model.x + 1.0) / 2.0) * base.viewportWidth - base.position.x - width / 2
|
||||
y: -((model.y + 1.0) / 2.0) * base.viewportHeight + (base.viewportHeight - base.position.y) + height / 2
|
||||
|
||||
width: UM.Theme.sizes.per_object_settings_button.width
|
||||
height: UM.Theme.sizes.per_object_settings_button.height
|
||||
|
||||
tooltip: catalog.i18nc("@info:tooltip", "Customise settings for this object");
|
||||
|
||||
checkable: true;
|
||||
onClicked: {
|
||||
base.currentIndex = index;
|
||||
|
||||
settingsPanel.anchors.left = right;
|
||||
settingsPanel.anchors.top = top;
|
||||
|
||||
settingsPanel.opacity = 1;
|
||||
}
|
||||
|
||||
style: ButtonStyle
|
||||
{
|
||||
background: Rectangle
|
||||
{
|
||||
width: control.width;
|
||||
height: control.height;
|
||||
|
||||
color: control.hovered ? UM.Theme.colors.button_active : UM.Theme.colors.button_hover;
|
||||
}
|
||||
label: Image {
|
||||
width: control.width;
|
||||
height: control.height;
|
||||
sourceSize.width: width;
|
||||
sourceSize.height: height;
|
||||
source: UM.Theme.icons.plus;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UM.Dialog {
|
||||
id: settingPickDialog
|
||||
|
||||
title: catalog.i18nc("@title:window", "Pick a Setting to Customize")
|
||||
|
||||
TextField {
|
||||
id: filter;
|
||||
|
||||
anchors {
|
||||
top: parent.top;
|
||||
left: parent.left;
|
||||
right: parent.right;
|
||||
}
|
||||
|
||||
placeholderText: catalog.i18nc("@label:textbox", "Filter...");
|
||||
|
||||
onTextChanged: settingCategoriesModel.filter(text);
|
||||
}
|
||||
|
||||
ScrollView {
|
||||
id: view;
|
||||
anchors {
|
||||
top: filter.bottom;
|
||||
left: parent.left;
|
||||
right: parent.right;
|
||||
bottom: parent.bottom;
|
||||
}
|
||||
|
||||
Column {
|
||||
width: view.width - UM.Theme.sizes.default_margin.width * 2;
|
||||
height: childrenRect.height;
|
||||
|
||||
Repeater {
|
||||
id: settingList;
|
||||
|
||||
model: UM.SettingCategoriesModel { id: settingCategoriesModel; }
|
||||
|
||||
delegate: Item {
|
||||
id: delegateItem;
|
||||
|
||||
width: parent.width;
|
||||
height: childrenRect.height;
|
||||
|
||||
ToolButton {
|
||||
id: categoryHeader;
|
||||
text: model.name;
|
||||
checkable: true;
|
||||
width: parent.width;
|
||||
onCheckedChanged: settingsColumn.state != "" ? settingsColumn.state = "" : settingsColumn.state = "collapsed";
|
||||
|
||||
style: ButtonStyle {
|
||||
background: Rectangle
|
||||
{
|
||||
width: control.width;
|
||||
height: control.height;
|
||||
color: control.hovered ? palette.highlight : "transparent";
|
||||
}
|
||||
label: Row
|
||||
{
|
||||
spacing: UM.Theme.sizes.default_margin.width;
|
||||
Image
|
||||
{
|
||||
anchors.verticalCenter: parent.verticalCenter;
|
||||
source: control.checked ? UM.Theme.icons.arrow_right : UM.Theme.icons.arrow_bottom;
|
||||
}
|
||||
Label
|
||||
{
|
||||
text: control.text;
|
||||
font.bold: true;
|
||||
color: control.hovered ? palette.highlightedText : palette.text;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
property variant settingsModel: model.settings;
|
||||
|
||||
visible: model.visible;
|
||||
|
||||
Column {
|
||||
id: settingsColumn;
|
||||
|
||||
anchors.top: categoryHeader.bottom;
|
||||
|
||||
property real childrenHeight:
|
||||
{
|
||||
var h = 0.0;
|
||||
for(var i in children)
|
||||
{
|
||||
var item = children[i];
|
||||
h += children[i].height;
|
||||
if(item.settingVisible)
|
||||
{
|
||||
if(i > 0)
|
||||
{
|
||||
h += spacing;
|
||||
}
|
||||
}
|
||||
}
|
||||
return h;
|
||||
}
|
||||
|
||||
width: childrenRect.width;
|
||||
height: childrenHeight;
|
||||
Repeater {
|
||||
model: delegateItem.settingsModel;
|
||||
|
||||
delegate: ToolButton {
|
||||
id: button;
|
||||
x: model.depth * UM.Theme.sizes.default_margin.width;
|
||||
text: model.name;
|
||||
tooltip: model.description;
|
||||
|
||||
onClicked: {
|
||||
var object_id = UM.ActiveTool.properties.Model.getItem(base.currentIndex).id;
|
||||
UM.ActiveTool.properties.Model.addSettingOverride(object_id, model.key);
|
||||
settingPickDialog.visible = false;
|
||||
}
|
||||
|
||||
states: State {
|
||||
name: "filtered"
|
||||
when: model.filtered || !model.visible || !model.enabled
|
||||
PropertyChanges { target: button; height: 0; opacity: 0; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
states: State {
|
||||
name: "collapsed";
|
||||
|
||||
PropertyChanges { target: settingsColumn; opacity: 0; height: 0; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rightButtons: [
|
||||
Button {
|
||||
text: catalog.i18nc("@action:button", "Cancel");
|
||||
onClicked: {
|
||||
settingPickDialog.visible = false;
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
SystemPalette { id: palette; }
|
||||
}
|
||||
18
plugins/PerObjectSettingsTool/PerObjectSettingsTool.py
Normal file
18
plugins/PerObjectSettingsTool/PerObjectSettingsTool.py
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
# Copyright (c) 2015 Ultimaker B.V.
|
||||
# Uranium is released under the terms of the AGPLv3 or higher.
|
||||
|
||||
from UM.Tool import Tool
|
||||
|
||||
from . import PerObjectSettingsModel
|
||||
|
||||
class PerObjectSettingsTool(Tool):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
self.setExposedProperties("Model")
|
||||
|
||||
def event(self, event):
|
||||
return False
|
||||
|
||||
def getModel(self):
|
||||
return PerObjectSettingsModel.PerObjectSettingsModel()
|
||||
102
plugins/PerObjectSettingsTool/SettingOverrideModel.py
Normal file
102
plugins/PerObjectSettingsTool/SettingOverrideModel.py
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
# Copyright (c) 2015 Ultimaker B.V.
|
||||
# Uranium is released under the terms of the AGPLv3 or higher.
|
||||
|
||||
from PyQt5.QtCore import Qt, pyqtSlot, QUrl
|
||||
|
||||
from UM.Application import Application
|
||||
from UM.Qt.ListModel import ListModel
|
||||
from UM.Settings.SettingOverrideDecorator import SettingOverrideDecorator
|
||||
|
||||
class SettingOverrideModel(ListModel):
|
||||
KeyRole = Qt.UserRole + 1
|
||||
LabelRole = Qt.UserRole + 2
|
||||
DescriptionRole = Qt.UserRole + 3
|
||||
ValueRole = Qt.UserRole + 4
|
||||
TypeRole = Qt.UserRole + 5
|
||||
UnitRole = Qt.UserRole + 6
|
||||
ValidRole = Qt.UserRole + 7
|
||||
OptionsRole = Qt.UserRole + 8
|
||||
WarningDescriptionRole = Qt.UserRole + 9
|
||||
ErrorDescriptionRole = Qt.UserRole + 10
|
||||
|
||||
def __init__(self, node, parent = None):
|
||||
super().__init__(parent)
|
||||
|
||||
self._ignore_setting_change = None
|
||||
|
||||
self._node = node
|
||||
self._node.decoratorsChanged.connect(self._onDecoratorsChanged)
|
||||
self._onDecoratorsChanged(None)
|
||||
|
||||
self.addRoleName(self.KeyRole, "key")
|
||||
self.addRoleName(self.LabelRole, "label")
|
||||
self.addRoleName(self.DescriptionRole, "description")
|
||||
self.addRoleName(self.ValueRole,"value")
|
||||
self.addRoleName(self.TypeRole, "type")
|
||||
self.addRoleName(self.UnitRole, "unit")
|
||||
self.addRoleName(self.ValidRole, "valid")
|
||||
self.addRoleName(self.OptionsRole, "options")
|
||||
self.addRoleName(self.WarningDescriptionRole, "warning_description")
|
||||
self.addRoleName(self.ErrorDescriptionRole, "error_description")
|
||||
|
||||
@pyqtSlot(str, "QVariant")
|
||||
def setSettingValue(self, key, value):
|
||||
if not self._decorator:
|
||||
return
|
||||
|
||||
self._ignore_setting_change = key
|
||||
self._decorator.setSettingValue(key, value)
|
||||
self._ignore_setting_change = None
|
||||
|
||||
def _onDecoratorsChanged(self, node):
|
||||
if not self._node.getDecorator(SettingOverrideDecorator):
|
||||
self.clear()
|
||||
return
|
||||
|
||||
self._decorator = self._node.getDecorator(SettingOverrideDecorator)
|
||||
self._decorator.settingAdded.connect(self._onSettingsChanged)
|
||||
self._decorator.settingRemoved.connect(self._onSettingsChanged)
|
||||
self._decorator.settingValueChanged.connect(self._onSettingValueChanged)
|
||||
self._onSettingsChanged()
|
||||
|
||||
def _createOptionsModel(self, options):
|
||||
if not options:
|
||||
return None
|
||||
|
||||
model = ListModel()
|
||||
model.addRoleName(Qt.UserRole + 1, "value")
|
||||
model.addRoleName(Qt.UserRole + 2, "name")
|
||||
for value, name in options.items():
|
||||
model.appendItem({"value": str(value), "name": str(name)})
|
||||
return model
|
||||
|
||||
def _onSettingsChanged(self):
|
||||
self.clear()
|
||||
|
||||
items = []
|
||||
for key, setting in self._decorator.getAllSettings().items():
|
||||
value = self._decorator.getSettingValue(key)
|
||||
items.append({
|
||||
"key": key,
|
||||
"label": setting.getLabel(),
|
||||
"description": setting.getDescription(),
|
||||
"value": str(value),
|
||||
"type": setting.getType(),
|
||||
"unit": setting.getUnit(),
|
||||
"valid": setting.validate(value),
|
||||
"options": self._createOptionsModel(setting.getOptions()),
|
||||
"warning_description": setting.getWarningDescription(),
|
||||
"error_description": setting.getErrorDescription()
|
||||
})
|
||||
|
||||
items.sort(key = lambda i: i["key"])
|
||||
|
||||
for item in items:
|
||||
self.appendItem(item)
|
||||
|
||||
def _onSettingValueChanged(self, setting):
|
||||
index = self.find("key", setting.getKey())
|
||||
value = self._decorator.getSettingValue(setting.getKey())
|
||||
if index != -1 and self._ignore_setting_change != setting.getKey():
|
||||
self.setProperty(index, "value", str(value))
|
||||
self.setProperty(index, "valid", setting.validate(value))
|
||||
27
plugins/PerObjectSettingsTool/__init__.py
Normal file
27
plugins/PerObjectSettingsTool/__init__.py
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
# Copyright (c) 2015 Ultimaker B.V.
|
||||
# Uranium is released under the terms of the AGPLv3 or higher.
|
||||
|
||||
from . import PerObjectSettingsTool
|
||||
|
||||
from UM.i18n import i18nCatalog
|
||||
i18n_catalog = i18nCatalog("uranium")
|
||||
|
||||
def getMetaData():
|
||||
return {
|
||||
"plugin": {
|
||||
"name": i18n_catalog.i18nc("@label", "Per Object Settings Tool"),
|
||||
"author": "Ultimaker",
|
||||
"version": "1.0",
|
||||
"description": i18n_catalog.i18nc("@info:whatsthis", "Provides the Per Object Settings."),
|
||||
"api": 2
|
||||
},
|
||||
"tool": {
|
||||
"name": i18n_catalog.i18nc("@label", "Per Object Settings"),
|
||||
"description": i18n_catalog.i18nc("@info:tooltip", "Configure Per Object Settings"),
|
||||
"icon": "setting_per_object",
|
||||
"tool_panel": "PerObjectSettingsPanel.qml"
|
||||
},
|
||||
}
|
||||
|
||||
def register(app):
|
||||
return { "tool": PerObjectSettingsTool.PerObjectSettingsTool() }
|
||||
|
|
@ -22,18 +22,18 @@ class RemovableDriveOutputDevice(OutputDevice):
|
|||
self.setIconName("save_sd")
|
||||
self.setPriority(1)
|
||||
|
||||
def requestWrite(self, node):
|
||||
def requestWrite(self, node, file_name = None):
|
||||
gcode_writer = Application.getInstance().getMeshFileHandler().getWriterByMimeType("text/x-gcode")
|
||||
if not gcode_writer:
|
||||
Logger.log("e", "Could not find GCode writer, not writing to removable drive %s", self.getName())
|
||||
raise OutputDeviceError.WriteRequestFailedError()
|
||||
|
||||
file_name = None
|
||||
for n in BreadthFirstIterator(node):
|
||||
if n.getMeshData():
|
||||
file_name = n.getName()
|
||||
if file_name:
|
||||
break
|
||||
if file_name == None:
|
||||
for n in BreadthFirstIterator(node):
|
||||
if n.getMeshData():
|
||||
file_name = n.getName()
|
||||
if file_name:
|
||||
break
|
||||
|
||||
if not file_name:
|
||||
Logger.log("e", "Could not determine a proper file name when trying to write to %s, aborting", self.getName())
|
||||
|
|
|
|||
|
|
@ -37,7 +37,11 @@ class RemovableDrivePlugin(OutputDevicePlugin):
|
|||
raise NotImplementedError()
|
||||
|
||||
def ejectDevice(self, device):
|
||||
result = self.performEjectDevice(device)
|
||||
try:
|
||||
result = self.performEjectDevice(device)
|
||||
except Exception as e:
|
||||
result = False
|
||||
|
||||
if result:
|
||||
message = Message(catalog.i18nc("@info:status", "Ejected {0}. You can now safely remove the drive.").format(device.getName()))
|
||||
message.show()
|
||||
|
|
|
|||
|
|
@ -88,13 +88,10 @@ class WindowsRemovableDrivePlugin(RemovableDrivePlugin.RemovableDrivePlugin):
|
|||
|
||||
result = None
|
||||
# Then, try and tell it to eject
|
||||
try:
|
||||
if not windll.kernel32.DeviceIoControl(handle, IOCTL_STORAGE_EJECT_MEDIA, None, None, None, None, None, None):
|
||||
result = False
|
||||
else:
|
||||
result = True
|
||||
except Exception as e:
|
||||
if not windll.kernel32.DeviceIoControl(handle, IOCTL_STORAGE_EJECT_MEDIA, None, None, None, None, None, None):
|
||||
result = False
|
||||
else:
|
||||
result = True
|
||||
|
||||
# Finally, close the handle
|
||||
windll.kernel32.CloseHandle(handle)
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ class PrinterConnection(OutputDevice, QObject, SignalEmitter):
|
|||
|
||||
self._end_stop_thread = threading.Thread(target = self._pollEndStop)
|
||||
self._end_stop_thread.deamon = True
|
||||
self._poll_endstop = -1
|
||||
|
||||
# Printer is connected
|
||||
self._is_connected = False
|
||||
|
|
@ -63,7 +64,7 @@ class PrinterConnection(OutputDevice, QObject, SignalEmitter):
|
|||
self._listen_thread.daemon = True
|
||||
|
||||
self._update_firmware_thread = threading.Thread(target= self._updateFirmware)
|
||||
self._update_firmware_thread.deamon = True
|
||||
self._update_firmware_thread.daemon = True
|
||||
|
||||
self._heatup_wait_start_time = time.time()
|
||||
|
||||
|
|
@ -122,6 +123,7 @@ class PrinterConnection(OutputDevice, QObject, SignalEmitter):
|
|||
progressChanged = pyqtSignal()
|
||||
extruderTemperatureChanged = pyqtSignal()
|
||||
bedTemperatureChanged = pyqtSignal()
|
||||
firmwareUpdateComplete = pyqtSignal()
|
||||
|
||||
endstopStateChanged = pyqtSignal(str ,bool, arguments = ["key","state"])
|
||||
|
||||
|
|
@ -237,8 +239,9 @@ class PrinterConnection(OutputDevice, QObject, SignalEmitter):
|
|||
|
||||
@pyqtSlot()
|
||||
def startPollEndstop(self):
|
||||
self._poll_endstop = True
|
||||
self._end_stop_thread.start()
|
||||
if self._poll_endstop == -1:
|
||||
self._poll_endstop = True
|
||||
self._end_stop_thread.start()
|
||||
|
||||
@pyqtSlot()
|
||||
def stopPollEndstop(self):
|
||||
|
|
@ -323,6 +326,7 @@ class PrinterConnection(OutputDevice, QObject, SignalEmitter):
|
|||
|
||||
## Close the printer connection
|
||||
def close(self):
|
||||
Logger.log("d", "Closing the printer connection.")
|
||||
if self._connect_thread.isAlive():
|
||||
try:
|
||||
self._connect_thread.join()
|
||||
|
|
@ -345,7 +349,7 @@ class PrinterConnection(OutputDevice, QObject, SignalEmitter):
|
|||
self._serial = None
|
||||
|
||||
def isConnected(self):
|
||||
return self._is_connected
|
||||
return self._is_connected
|
||||
|
||||
@pyqtSlot(int)
|
||||
def heatupNozzle(self, temperature):
|
||||
|
|
@ -411,6 +415,7 @@ class PrinterConnection(OutputDevice, QObject, SignalEmitter):
|
|||
|
||||
def createControlInterface(self):
|
||||
if self._control_view is None:
|
||||
Logger.log("d", "Creating control interface for printer connection")
|
||||
path = QUrl.fromLocalFile(os.path.join(PluginRegistry.getInstance().getPluginPath("USBPrinting"), "ControlWindow.qml"))
|
||||
component = QQmlComponent(Application.getInstance()._engine, path)
|
||||
self._control_context = QQmlContext(Application.getInstance()._engine.rootContext())
|
||||
|
|
@ -455,7 +460,7 @@ class PrinterConnection(OutputDevice, QObject, SignalEmitter):
|
|||
self._bed_temperature = temperature
|
||||
self.bedTemperatureChanged.emit()
|
||||
|
||||
def requestWrite(self, node):
|
||||
def requestWrite(self, node, file_name = None):
|
||||
self.showControlInterface()
|
||||
|
||||
def _setEndstopState(self, endstop_key, value):
|
||||
|
|
@ -617,6 +622,6 @@ class PrinterConnection(OutputDevice, QObject, SignalEmitter):
|
|||
def _onFirmwareUpdateComplete(self):
|
||||
self._update_firmware_thread.join()
|
||||
self._update_firmware_thread = threading.Thread(target= self._updateFirmware)
|
||||
self._update_firmware_thread.deamon = True
|
||||
self._update_firmware_thread.daemon = True
|
||||
|
||||
self.connect()
|
||||
|
|
|
|||
|
|
@ -54,6 +54,15 @@ class USBPrinterManager(QObject, SignalEmitter, OutputDevicePlugin, Extension):
|
|||
addConnectionSignal = Signal()
|
||||
printerConnectionStateChanged = pyqtSignal()
|
||||
|
||||
progressChanged = pyqtSignal()
|
||||
@pyqtProperty(float, notify = progressChanged)
|
||||
def progress(self):
|
||||
progress = 0
|
||||
for name, connection in self._printer_connections.items():
|
||||
progress += connection.progress
|
||||
|
||||
return progress / len(self._printer_connections)
|
||||
|
||||
def start(self):
|
||||
self._check_updates = True
|
||||
self._update_thread.start()
|
||||
|
|
@ -84,12 +93,14 @@ class USBPrinterManager(QObject, SignalEmitter, OutputDevicePlugin, Extension):
|
|||
|
||||
self._firmware_view.show()
|
||||
|
||||
@pyqtSlot()
|
||||
def updateAllFirmware(self):
|
||||
self.spawnFirmwareInterface("")
|
||||
for printer_connection in self._printer_connections:
|
||||
try:
|
||||
self._printer_connections[printer_connection].updateFirmware(Resources.getPath(CuraApplication.ResourceTypes.Firmware, self._getDefaultFirmwareName()))
|
||||
except FileNotFoundError:
|
||||
Logger.log("w", "No firmware found for printer %s", printer_connection)
|
||||
continue
|
||||
|
||||
@pyqtSlot(str, result = bool)
|
||||
|
|
@ -153,6 +164,7 @@ class USBPrinterManager(QObject, SignalEmitter, OutputDevicePlugin, Extension):
|
|||
connection = PrinterConnection.PrinterConnection(serial_port)
|
||||
connection.connect()
|
||||
connection.connectionStateChanged.connect(self._onPrinterConnectionStateChanged)
|
||||
connection.progressChanged.connect(self.progressChanged)
|
||||
self._printer_connections[serial_port] = connection
|
||||
|
||||
def _onPrinterConnectionStateChanged(self, serial_port):
|
||||
|
|
@ -196,4 +208,4 @@ class USBPrinterManager(QObject, SignalEmitter, OutputDevicePlugin, Extension):
|
|||
base_list = base_list + glob.glob("/dev/ttyUSB*") + glob.glob("/dev/ttyACM*") + glob.glob("/dev/cu.*") + glob.glob("/dev/tty.usb*") + glob.glob("/dev/rfcomm*") + glob.glob("/dev/serial/by-id/*")
|
||||
return list(base_list)
|
||||
|
||||
_instance = None
|
||||
_instance = None
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue