Move currentSelection and selectionChanged to EditorSession

This commit is contained in:
David Vierra 2015-01-06 11:20:59 -10:00
parent 2074faa840
commit de969c05f1
2 changed files with 15 additions and 10 deletions

View File

@ -22,7 +22,7 @@ from mcedit2.worldview.camera import CameraWorldViewFrame
from mcedit2.worldview.cutaway import CutawayWorldViewFrame
from mcedit2.worldview.minimap import MinimapWorldView
from mcedit2.worldview.overhead import OverheadWorldViewFrame
from mceditlib.geometry import Vector
from mceditlib.geometry import Vector, BoundingBox
from mceditlib.exceptions import PlayerNotFound
from mceditlib.revisionhistory import UndoFolderExists
from mceditlib.worldeditor import WorldEditor
@ -190,13 +190,17 @@ class EditorSession(QtCore.QObject):
self.worldEditor.close()
self.worldEditor = None
selectionChanged = QtCore.Signal(BoundingBox)
_currentSelection = None
@property
def currentSelection(self):
return self.selectionTool.currentSelection
return self._currentSelection
@currentSelection.setter
def currentSelection(self, value):
self.selectionTool.currentSelection = value
self._currentSelection = value
self.selectionChanged.emit(value)
# --- Menu commands ---

View File

@ -159,6 +159,8 @@ class SelectionTool(EditorTool):
super(SelectionTool, self).__init__(editorSession, *args, **kwargs)
toolWidget = QtGui.QWidget()
editorSession.selectionChanged.connect(self.selectionDidChange)
self.toolWidget = toolWidget
self.coordInput = SelectionCoordinateWidget()
@ -194,7 +196,6 @@ class SelectionTool(EditorTool):
self.overlayNode.addChild(self.faceHoverNode)
self.newSelectionNode = None
self.currentSelection = None
@property
def hideSelectionWalls(self):
@ -204,19 +205,19 @@ class SelectionTool(EditorTool):
def hideSelectionWalls(self, value):
self.selectionNode.filled = not value
@property
def currentSelection(self):
return self._currentSelection
return self.editorSession.currentSelection
@currentSelection.setter
def currentSelection(self, value):
self._currentSelection = value
self.coordInput.boundingBox = value
self.updateNodes()
self.editorSession.currentSelection = value
def coordInputChanged(self, box):
self._currentSelection = box
self.currentSelection = box
def selectionDidChange(self, value):
self.coordInput.boundingBox = value
self.updateNodes()
def updateNodes(self):