Schematics dropped into the editor window have a more sensible initial position
This commit is contained in:
parent
21df3c4b94
commit
fba87789f7
@ -881,7 +881,7 @@ class EditorSession(QtCore.QObject):
|
|||||||
for url in mimeData.urls():
|
for url in mimeData.urls():
|
||||||
if url.isLocalFile():
|
if url.isLocalFile():
|
||||||
filename = url.toLocalFile()
|
filename = url.toLocalFile()
|
||||||
self.importSchematic(filename)
|
self.importSchematic(filename, position + face.vector)
|
||||||
break
|
break
|
||||||
|
|
||||||
def mapItemWasDropped(self, mimeData, position, face):
|
def mapItemWasDropped(self, mimeData, position, face):
|
||||||
@ -927,18 +927,24 @@ class EditorSession(QtCore.QObject):
|
|||||||
|
|
||||||
# --- Library support ---
|
# --- Library support ---
|
||||||
|
|
||||||
def importSchematic(self, filename):
|
def importSchematic(self, filename, importPos=None):
|
||||||
schematic = WorldEditor(filename, readonly=True)
|
schematic = WorldEditor(filename, readonly=True)
|
||||||
ray = self.editorTab.currentView().rayAtCenter()
|
ray = self.editorTab.currentView().rayAtCenter()
|
||||||
pos, face = rayCastInBounds(ray, self.currentDimension)
|
if importPos is not None:
|
||||||
if pos is None:
|
pos = importPos
|
||||||
pos = ray.point
|
|
||||||
else:
|
else:
|
||||||
pos = pos + face.vector
|
pos, face = rayCastInBounds(ray, self.currentDimension)
|
||||||
|
if pos is None:
|
||||||
|
pos = ray.point
|
||||||
|
else:
|
||||||
|
pos = pos + face.vector
|
||||||
|
|
||||||
name = os.path.basename(filename)
|
name = os.path.basename(filename)
|
||||||
dim = schematic.getDimension()
|
dim = schematic.getDimension()
|
||||||
imp = PendingImport(schematic.getDimension(), pos, dim.bounds, name)
|
center = dim.bounds.center
|
||||||
|
bottomCenter = pos - (center[0], 0, center[2])
|
||||||
|
|
||||||
|
imp = PendingImport(schematic.getDimension(), bottomCenter, dim.bounds, name)
|
||||||
command = PasteImportCommand(self, imp, "Import %s" % name)
|
command = PasteImportCommand(self, imp, "Import %s" % name)
|
||||||
self.undoStack.push(command)
|
self.undoStack.push(command)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user