Add chunk-shaped selection box
This commit is contained in:
parent
29b7406c93
commit
0f7488f88a
@ -168,6 +168,15 @@ class Cylinder(BrushShape):
|
||||
distances = x + z
|
||||
return (distances < 1) & (0 <= y) & (y < h)
|
||||
|
||||
|
||||
class ChunkShape(BrushShape):
|
||||
ID = "Chunk"
|
||||
icon = None
|
||||
|
||||
def createShapedSelection(self, box, dimension):
|
||||
return box.chunkBox(dimension)
|
||||
|
||||
|
||||
class ParabolicDome(BrushShape):
|
||||
ID = "ParabolicDome"
|
||||
icon = None
|
||||
|
@ -9,6 +9,7 @@ from PySide import QtGui, QtCore
|
||||
|
||||
from mcedit2.editortools import EditorTool
|
||||
from mcedit2.editortools.brush import shapes
|
||||
from mcedit2.editortools.brush.shapes import ChunkShape
|
||||
from mcedit2.handles.boxhandle import BoxHandle
|
||||
from mcedit2.rendering import cubes
|
||||
from mcedit2.rendering.selection import SelectionScene, SelectionFaceNode
|
||||
@ -174,7 +175,7 @@ class SelectionTool(EditorTool):
|
||||
|
||||
self.coordInput = SelectionCoordinateWidget()
|
||||
self.coordInput.boxChanged.connect(self.coordInputChanged)
|
||||
self.shapeInput = ShapeWidget()
|
||||
self.shapeInput = ShapeWidget(addShapes=[ChunkShape()])
|
||||
self.shapeInput.shapeChanged.connect(self.shapeDidChange)
|
||||
self.toolWidget.setLayout(Column(self.coordInput,
|
||||
self.shapeInput,
|
||||
|
@ -17,6 +17,7 @@ log = logging.getLogger(__name__)
|
||||
@registerCustomWidget
|
||||
class ShapeWidget(QtGui.QWidget):
|
||||
def __init__(self, *args, **kwargs):
|
||||
addShapes = kwargs.pop('addShapes', None)
|
||||
super(ShapeWidget, self).__init__(*args, **kwargs)
|
||||
buttons = self.buttons = []
|
||||
layout = flowlayout.FlowLayout()
|
||||
@ -24,7 +25,10 @@ class ShapeWidget(QtGui.QWidget):
|
||||
actionGroup.setExclusive(True)
|
||||
iconBase = resourcePath("mcedit2/assets/mcedit2/icons")
|
||||
actions = {}
|
||||
for shape in getShapes():
|
||||
shapes = list(getShapes())
|
||||
if addShapes:
|
||||
shapes.extend(addShapes)
|
||||
for shape in shapes:
|
||||
if shape.icon is not None:
|
||||
filename = os.path.join(iconBase, shape.icon)
|
||||
assert os.path.exists(filename), "%r does not exist" % filename
|
||||
@ -54,11 +58,13 @@ class ShapeWidget(QtGui.QWidget):
|
||||
actions[shape.ID] = action
|
||||
|
||||
self.setLayout(layout)
|
||||
currentID = BrushShapeSetting.value(getShapes()[0].ID)
|
||||
shapesByID = {shape.ID:shape for shape in getShapes()}
|
||||
currentID = BrushShapeSetting.value(shapes[0].ID)
|
||||
shapesByID = {shape.ID: shape for shape in shapes}
|
||||
if currentID not in actions:
|
||||
currentID = shapes[0].ID
|
||||
actions[currentID].setChecked(True)
|
||||
|
||||
self.currentShape = shapesByID.get(currentID, getShapes()[0])
|
||||
self.currentShape = shapesByID.get(currentID, shapes[0])
|
||||
|
||||
shapeChanged = QtCore.Signal()
|
||||
|
||||
|
Reference in New Issue
Block a user