SelectionCursorNode and SelectionFaceNode now use 4-tuple colors
This commit is contained in:
parent
ab0f1934ec
commit
52a137df59
@ -168,6 +168,7 @@ class SelectCommand(QtGui.QUndoCommand):
|
||||
self.previousBox = self.editorSession.currentSelection
|
||||
self.editorSession.currentSelection = self.box
|
||||
|
||||
|
||||
class SelectionTool(EditorTool):
|
||||
name = "Select"
|
||||
iconName = "select_blocks"
|
||||
@ -337,9 +338,8 @@ class SelectionCursorRenderNode(rendernode.RenderNode):
|
||||
point = self.sceneNode.point
|
||||
if point is None:
|
||||
return
|
||||
#selectionColor = map(lambda a: a * a * a * a, self.sceneNode.color)
|
||||
r, g, b = self.sceneNode.color
|
||||
alpha = 0.3
|
||||
|
||||
r, g, b, a = self.sceneNode.color
|
||||
box = BoundingBox(point, (1, 1, 1))
|
||||
|
||||
with gl.glPushAttrib(GL.GL_DEPTH_BUFFER_BIT | GL.GL_ENABLE_BIT | GL.GL_POLYGON_BIT):
|
||||
@ -351,19 +351,19 @@ class SelectionCursorRenderNode(rendernode.RenderNode):
|
||||
|
||||
GL.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_FILL)
|
||||
|
||||
GL.glColor(r, g, b, alpha)
|
||||
GL.glColor(r, g, b, a)
|
||||
cubes.drawFace(box, self.sceneNode.face)
|
||||
|
||||
# Wire box
|
||||
GL.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_LINE)
|
||||
|
||||
GL.glLineWidth(3.0)
|
||||
GL.glColor(1., 1., 1., alpha)
|
||||
GL.glColor(1., 1., 1., a)
|
||||
|
||||
cubes.drawBox(box)
|
||||
|
||||
GL.glLineWidth(1.0)
|
||||
GL.glColor(0.2, 0.2, 0.2, alpha)
|
||||
GL.glColor(0.2, 0.2, 0.2, a)
|
||||
|
||||
cubes.drawBox(box)
|
||||
|
||||
@ -371,7 +371,7 @@ class SelectionCursorRenderNode(rendernode.RenderNode):
|
||||
class SelectionCursor(scenenode.Node):
|
||||
RenderNodeClass = SelectionCursorRenderNode
|
||||
|
||||
def __init__(self, point=Vector(0, 0, 0), face=faces.FaceXDecreasing, color=(.3, .3, 1)):
|
||||
def __init__(self, point=Vector(0, 0, 0), face=faces.FaceXDecreasing, color=(.3, .3, 1, .8)):
|
||||
super(SelectionCursor, self).__init__()
|
||||
self._point = point
|
||||
self._face = face
|
||||
|
@ -300,13 +300,15 @@ class BoxHandle(scenenode.Node, QtCore.QObject):
|
||||
self.faceDragNode.visible = False
|
||||
if self.moveModifierDown(event):
|
||||
self.faceDragNode.color = self._moveFaceColor
|
||||
self.faceDragNode.wireColor = self._moveFaceColor
|
||||
self.faceDragNode.wireColor = self._moveFaceWireColor
|
||||
else:
|
||||
self.faceDragNode.color = self._resizeFaceColor
|
||||
self.faceDragNode.wireColor = self._resizeFaceColor
|
||||
self.faceDragNode.wireColor = self._resizeFaceWireColor
|
||||
|
||||
_moveFaceColor = (0.3, 0.9, 0.3)
|
||||
_resizeFaceColor = (0.3, 0.6, 0.9)
|
||||
_moveFaceColor = (0.3, 0.9, 0.3, 0.3)
|
||||
_moveFaceWireColor = (0.3, 0.9, 0.3, 0.8)
|
||||
_resizeFaceColor = (0.3, 0.6, 0.9, 0.3)
|
||||
_resizeFaceWireColor = (0.3, 0.6, 0.9, 0.8)
|
||||
|
||||
# --- Mouse events ---
|
||||
|
||||
|
@ -343,20 +343,19 @@ class SelectionFaceRenderNode(rendernode.RenderNode):
|
||||
if box is None:
|
||||
return
|
||||
|
||||
alpha = 0.16
|
||||
with gl.glPushAttrib(GL.GL_DEPTH_BUFFER_BIT | GL.GL_ENABLE_BIT | GL.GL_LINE_BIT):
|
||||
GL.glDisable(GL.GL_DEPTH_TEST)
|
||||
GL.glDepthMask(False)
|
||||
GL.glEnable(GL.GL_BLEND)
|
||||
GL.glPolygonOffset(self.sceneNode.depth, self.sceneNode.depth)
|
||||
|
||||
r, g, b = self.sceneNode.wireColor
|
||||
GL.glColor(r, g, b, .8)
|
||||
r, g, b, a = self.sceneNode.wireColor
|
||||
GL.glColor(r, g, b, a)
|
||||
GL.glLineWidth(3.0)
|
||||
cubes.drawFace(box, self.sceneNode.face, GL.GL_LINE_STRIP)
|
||||
|
||||
r, g, b = self.sceneNode.color
|
||||
GL.glColor(r, g, b, alpha)
|
||||
r, g, b, a = self.sceneNode.color
|
||||
GL.glColor(r, g, b, a)
|
||||
GL.glEnable(GL.GL_DEPTH_TEST)
|
||||
cubes.drawFace(box, self.sceneNode.face)
|
||||
|
||||
@ -386,13 +385,14 @@ class SelectionFaceNode(scenenode.Node):
|
||||
self._face = value
|
||||
self.dirty = True
|
||||
|
||||
_color = (.3, .3, 1)
|
||||
_color = (.3, .3, 1, .15)
|
||||
@property
|
||||
def color(self):
|
||||
return self._color
|
||||
|
||||
@color.setter
|
||||
def color(self, value):
|
||||
assert len(value) == 4
|
||||
self._color = value
|
||||
self.dirty = True
|
||||
|
||||
@ -403,6 +403,7 @@ class SelectionFaceNode(scenenode.Node):
|
||||
|
||||
@wireColor.setter
|
||||
def wireColor(self, value):
|
||||
assert len(value) == 4
|
||||
self._wireColor = value
|
||||
self.dirty = True
|
||||
|
||||
|
@ -79,6 +79,18 @@ class MCESettingsNamespace(object):
|
||||
self.prefix = prefix
|
||||
|
||||
def getOption(self, key, type=None, default=None):
|
||||
"""
|
||||
Parameters
|
||||
----------
|
||||
key: str
|
||||
type: bool | int | float | str
|
||||
default: Any
|
||||
|
||||
Returns
|
||||
-------
|
||||
|
||||
option: MCESettingsOption
|
||||
"""
|
||||
return self.rootSettings.getOption(self.prefix + key, type, default)
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user