Extract CoordinateWidget to its own file
This commit is contained in:
parent
85972c7867
commit
8d7c5e860f
@ -4,9 +4,9 @@
|
|||||||
from __future__ import absolute_import, division, print_function
|
from __future__ import absolute_import, division, print_function
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from PySide import QtGui, QtCore
|
from PySide import QtGui
|
||||||
from PySide.QtCore import Qt
|
|
||||||
|
|
||||||
|
from PySide.QtCore import Qt
|
||||||
from mcedit2.editorsession import PendingImport
|
from mcedit2.editorsession import PendingImport
|
||||||
from mcedit2.editortools import EditorTool
|
from mcedit2.editortools import EditorTool
|
||||||
from mcedit2.command import SimpleRevisionCommand
|
from mcedit2.command import SimpleRevisionCommand
|
||||||
@ -15,9 +15,9 @@ from mcedit2.rendering.selection import SelectionBoxNode, SelectionFaceNode, box
|
|||||||
from mcedit2.rendering.scenegraph import scenenode
|
from mcedit2.rendering.scenegraph import scenenode
|
||||||
from mcedit2.rendering.depths import DepthOffset
|
from mcedit2.rendering.depths import DepthOffset
|
||||||
from mcedit2.rendering.worldscene import WorldScene
|
from mcedit2.rendering.worldscene import WorldScene
|
||||||
from mcedit2.util.load_ui import load_ui
|
|
||||||
from mcedit2.util.showprogress import showProgress
|
from mcedit2.util.showprogress import showProgress
|
||||||
from mcedit2.util.worldloader import WorldLoader
|
from mcedit2.util.worldloader import WorldLoader
|
||||||
|
from mcedit2.widgets.coord_widget import CoordinateWidget
|
||||||
from mcedit2.widgets.layout import Column
|
from mcedit2.widgets.layout import Column
|
||||||
from mceditlib.geometry import Vector
|
from mceditlib.geometry import Vector
|
||||||
from mceditlib.selection import BoundingBox
|
from mceditlib.selection import BoundingBox
|
||||||
@ -79,47 +79,6 @@ class MoveFinishCommand(SimpleRevisionCommand):
|
|||||||
self.moveTool.removePendingImport(self.pendingImport)
|
self.moveTool.removePendingImport(self.pendingImport)
|
||||||
|
|
||||||
|
|
||||||
class CoordinateWidget(QtGui.QWidget):
|
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
super(CoordinateWidget, self).__init__(*args, **kwargs)
|
|
||||||
load_ui("coord_widget.ui", baseinstance=self)
|
|
||||||
|
|
||||||
self.xInput.valueChanged.connect(self.setX)
|
|
||||||
self.yInput.valueChanged.connect(self.setY)
|
|
||||||
self.zInput.valueChanged.connect(self.setZ)
|
|
||||||
|
|
||||||
pointChanged = QtCore.Signal(BoundingBox)
|
|
||||||
|
|
||||||
_point = Vector(0, 0, 0)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def point(self):
|
|
||||||
return self._point
|
|
||||||
|
|
||||||
@point.setter
|
|
||||||
def point(self, point):
|
|
||||||
self.setEnabled(point is not None)
|
|
||||||
self._point = point
|
|
||||||
if point is not None:
|
|
||||||
x, y, z = point
|
|
||||||
self.xInput.setValue(x)
|
|
||||||
self.yInput.setValue(y)
|
|
||||||
self.zInput.setValue(z)
|
|
||||||
|
|
||||||
self.pointChanged.emit(point)
|
|
||||||
|
|
||||||
def setX(self, value):
|
|
||||||
x, y, z = self.point
|
|
||||||
self.point = Vector(value, y, z)
|
|
||||||
|
|
||||||
def setY(self, value):
|
|
||||||
x, y, z = self.point
|
|
||||||
self.point = Vector(x, value, z)
|
|
||||||
|
|
||||||
def setZ(self, value):
|
|
||||||
x, y, z = self.point
|
|
||||||
self.point = Vector(x, y, value)
|
|
||||||
|
|
||||||
class PendingImportNode(TranslateNode):
|
class PendingImportNode(TranslateNode):
|
||||||
def __init__(self, pendingImport, textureAtlas):
|
def __init__(self, pendingImport, textureAtlas):
|
||||||
super(PendingImportNode, self).__init__()
|
super(PendingImportNode, self).__init__()
|
||||||
|
53
src/mcedit2/widgets/coord_widget.py
Normal file
53
src/mcedit2/widgets/coord_widget.py
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
"""
|
||||||
|
coord_widget
|
||||||
|
"""
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
import logging
|
||||||
|
from PySide import QtGui, QtCore
|
||||||
|
from mcedit2.util.load_ui import load_ui
|
||||||
|
from mceditlib.geometry import Vector
|
||||||
|
from mceditlib.selection import BoundingBox
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class CoordinateWidget(QtGui.QWidget):
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super(CoordinateWidget, self).__init__(*args, **kwargs)
|
||||||
|
load_ui("coord_widget.ui", baseinstance=self)
|
||||||
|
|
||||||
|
self.xInput.valueChanged.connect(self.setX)
|
||||||
|
self.yInput.valueChanged.connect(self.setY)
|
||||||
|
self.zInput.valueChanged.connect(self.setZ)
|
||||||
|
|
||||||
|
pointChanged = QtCore.Signal(BoundingBox)
|
||||||
|
|
||||||
|
_point = Vector(0, 0, 0)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def point(self):
|
||||||
|
return self._point
|
||||||
|
|
||||||
|
@point.setter
|
||||||
|
def point(self, point):
|
||||||
|
self.setEnabled(point is not None)
|
||||||
|
self._point = point
|
||||||
|
if point is not None:
|
||||||
|
x, y, z = point
|
||||||
|
self.xInput.setValue(x)
|
||||||
|
self.yInput.setValue(y)
|
||||||
|
self.zInput.setValue(z)
|
||||||
|
|
||||||
|
self.pointChanged.emit(point)
|
||||||
|
|
||||||
|
def setX(self, value):
|
||||||
|
x, y, z = self.point
|
||||||
|
self.point = Vector(value, y, z)
|
||||||
|
|
||||||
|
def setY(self, value):
|
||||||
|
x, y, z = self.point
|
||||||
|
self.point = Vector(x, value, z)
|
||||||
|
|
||||||
|
def setZ(self, value):
|
||||||
|
x, y, z = self.point
|
||||||
|
self.point = Vector(x, y, value)
|
Reference in New Issue
Block a user