This commit is contained in:
Tim Kuipers 2015-07-28 15:20:22 +02:00
commit 2c010da555
6 changed files with 69 additions and 6 deletions

View file

@ -5,6 +5,17 @@ This is the new, shiny frontend for Cura. [daid/Cura](https://github.com/daid/Cu
We re-worked the whole GUI code at Ultimaker, because the old code started to become a unmaintainable.
Logging Issues
------------
Use [this](https://github.com/Ultimaker/Uranium/wiki/Bug-Reporting-Template) template to report issues. New issues that do not adhere to this template will take us a lot longer to handle and will therefore have a lower pirority.
For crashes and similar issues, please attach the following information:
* (On Windows) The log as produced by dxdiag (start -> run -> dxdiag -> save output)
* The Cura GUI log file, located at (Windows) $User/AppData/Local/cura/cura.log, (OSX) $User/.cura/cura.log
* The Cura Engine log, using Help -> Show Engine Log
Dependencies
------------

View file

@ -36,6 +36,7 @@ from . import BuildVolume
from . import CameraAnimation
from . import PrintInformation
from . import CuraActions
from . import MultiMaterialDecorator
from PyQt5.QtCore import pyqtSlot, QUrl, Qt, pyqtSignal, pyqtProperty
from PyQt5.QtGui import QColor, QIcon
@ -425,6 +426,23 @@ class CuraApplication(QtApplication):
self.getActiveMachine().setSettingValueByKey(key, value)
@pyqtSlot()
def mergeSelected(self):
self.groupSelected()
try:
group_node = Selection.getAllSelectedObjects()[0]
except Exception as e:
return
multi_material_decorator = MultiMaterialDecorator.MultiMaterialDecorator()
group_node.addDecorator(multi_material_decorator)
# Reset the position of each node
for node in group_node.getChildren():
new_position = node.getMeshData().getCenterPosition()
new_position.setY(0)
node.setPosition(new_position)
# Use the previously found center of the group bounding box as the new location of the group
group_node.setPosition(group_node.getBoundingBox().center)
@pyqtSlot()
def groupSelected(self):

View file

@ -0,0 +1,8 @@
from UM.Scene.SceneNodeDecorator import SceneNodeDecorator
class MultiMaterialDecorator(SceneNodeDecorator):
def __init__(self):
super().__init__()
def isMultiMaterial(self):
return True

View file

@ -80,9 +80,18 @@ class PlatformPhysics:
# Check for collisions between convex hulls
for other_node in BreadthFirstIterator(root):
# Ignore root, ourselves and anything that is not a normal SceneNode.
if other_node is root or type(other_node) is not SceneNode or other_node is node or other_node in node.getAllChildren() or node in other_node.getAllChildren():
if other_node is root or type(other_node) is not SceneNode or other_node is node:
continue
# Ignore colissions of a group with it's own children
if other_node in node.getAllChildren() or node in other_node.getAllChildren():
continue
# Ignore colissions within a group
if other_node.getParent().callDecoration("isGroup") is not None:
if node.getParent().callDecoration("isGroup") is other_node.getParent().callDecoration("isGroup"):
continue
# Ignore nodes that do not have the right properties set.
if not other_node.callDecoration("getConvexHull") or not other_node.getBoundingBox():
continue

View file

@ -19,6 +19,8 @@ Item {
property alias centerObject: centerObjectAction;
property alias groupObjects: groupObjectsAction;
property alias unGroupObjects:unGroupObjectsAction;
property alias mergeObjects: mergeObjectsAction;
//property alias unMergeObjects: unMergeObjectsAction;
property alias multiplyObject: multiplyObjectAction;
property alias splitObject: splitObjectAction;
@ -139,6 +141,13 @@ Item {
enabled: UM.Scene.isGroupSelected
}
Action
{
id: mergeObjectsAction
text: qsTr("Merge objects");
enabled: UM.Scene.numObjectsSelected > 1 ? true: false
}
Action {
id: multiplyObjectAction;
//: Duplicate object action

View file

@ -358,6 +358,11 @@ UM.MainWindow {
Printer.ungroupSelected()
}
mergeObjects.onTriggered:
{
Printer.mergeSelected()
}
deleteAll.onTriggered: Printer.deleteAll()
resetAllTranslation.onTriggered: Printer.resetAllTranslation()
resetAll.onTriggered: Printer.resetAll()
@ -378,27 +383,30 @@ UM.MainWindow {
id: objectContextMenu;
property variant objectId: -1;
MenuItem { action: actions.centerObject; }
MenuItem { action: actions.deleteObject; }
MenuItem { action: actions.multiplyObject; }
MenuItem { action: actions.splitObject; }
MenuItem { action: actions.groupObjects;}
MenuItem { action: actions.unGroupObjects;}
MenuSeparator { }
MenuItem { action: actions.deleteAll; }
MenuItem { action: actions.reloadAll; }
MenuItem { action: actions.resetAllTranslation; }
MenuItem { action: actions.resetAll; }
MenuItem { action: actions.groupObjects;}
MenuItem { action: actions.unGroupObjects;}
MenuItem { action: actions.mergeObjects;}
}
Menu {
id: contextMenu;
MenuItem { action: actions.deleteAll; }
MenuItem { action: actions.reloadAll; }
MenuItem { action: actions.resetAllTranslation; }
MenuItem { action: actions.resetAll; }
MenuItem { action: actions.groupObjects;}
MenuItem { action: actions.unGroupObjects;}
MenuItem { action: actions.mergeObjects;}
}
Connections {