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

View File

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