1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
|
# Copyright (c) 2015 Ultimaker B.V.
# Uranium is released under the terms of the LGPLv3 or higher.
from UM.Math.Vector import Vector
from UM.Mesh.MeshBuilder import MeshBuilder
from UM.Scene.ToolHandle import ToolHandle
class MirrorToolHandle(ToolHandle):
"""Provides the two pyramid-shaped toolhandles for each axis for the mirror tool"""
def __init__(self, parent = None):
self._name = "MirrorToolHandle"
super().__init__(parent)
self._handle_width = 8
self._handle_height = 14
self._handle_position = 20
def buildMesh(self):
mb = MeshBuilder()
#SOLIDMESH
mb.addPyramid(
width = self._handle_width,
height = self._handle_height,
depth = self._handle_width,
center = Vector(0, self._handle_position, 0),
color = self._y_axis_color
)
mb.addPyramid(
width = self._handle_width,
height = self._handle_height,
depth = self._handle_width,
center = Vector(0, -self._handle_position, 0),
color = self._y_axis_color,
axis = Vector.Unit_X,
angle = 180
)
mb.addPyramid(
width = self._handle_width,
height = self._handle_height,
depth = self._handle_width,
center = Vector(self._handle_position, 0, 0),
color = self._x_axis_color,
axis = Vector.Unit_Z,
angle = 90
)
mb.addPyramid(
width = self._handle_width,
height = self._handle_height,
depth = self._handle_width,
center = Vector(-self._handle_position, 0, 0),
color = self._x_axis_color,
axis = Vector.Unit_Z,
angle = -90
)
mb.addPyramid(
width = self._handle_width,
height = self._handle_height,
depth = self._handle_width,
center = Vector(0, 0, -self._handle_position),
color = self._z_axis_color,
axis = Vector.Unit_X,
angle = 90
)
mb.addPyramid(
width = self._handle_width,
height = self._handle_height,
depth = self._handle_width,
center = Vector(0, 0, self._handle_position),
color = self._z_axis_color,
axis = Vector.Unit_X,
angle = -90
)
self.setSolidMesh(mb.build())
#SELECTIONMESH
mb.addPyramid(
width = self._handle_width,
height = self._handle_height,
depth = self._handle_width,
center = Vector(0, self._handle_position, 0),
color = ToolHandle.YAxisSelectionColor
)
mb.addPyramid(
width = self._handle_width,
height = self._handle_height,
depth = self._handle_width,
center = Vector(0, -self._handle_position, 0),
color = ToolHandle.YAxisSelectionColor,
axis = Vector.Unit_X,
angle = 180
)
mb.addPyramid(
width = self._handle_width,
height = self._handle_height,
depth = self._handle_width,
center = Vector(self._handle_position, 0, 0),
color = ToolHandle.XAxisSelectionColor,
axis = Vector.Unit_Z,
angle = 90
)
mb.addPyramid(
width = self._handle_width,
height = self._handle_height,
depth = self._handle_width,
center = Vector(-self._handle_position, 0, 0),
color = ToolHandle.XAxisSelectionColor,
axis = Vector.Unit_Z,
angle = -90
)
mb.addPyramid(
width = self._handle_width,
height = self._handle_height,
depth = self._handle_width,
center = Vector(0, 0, -self._handle_position),
color = ToolHandle.ZAxisSelectionColor,
axis = Vector.Unit_X,
angle = 90
)
mb.addPyramid(
width = self._handle_width,
height = self._handle_height,
depth = self._handle_width,
center = Vector(0, 0, self._handle_position),
color = ToolHandle.ZAxisSelectionColor,
axis = Vector.Unit_X,
angle = -90
)
self.setSelectionMesh(mb.build())
|