Merge pull request #558 from acq4/canvas-updates

Clean up canvas codebase
This commit is contained in:
Luke Campagnola 2017-09-13 21:34:07 -07:00 committed by GitHub
commit daedbf68db
6 changed files with 232 additions and 365 deletions

View File

@ -19,9 +19,11 @@ elif QT_LIB == 'PyQt5':
import numpy as np import numpy as np
from .. import debug from .. import debug
import weakref import weakref
import gc
from .CanvasManager import CanvasManager from .CanvasManager import CanvasManager
from .CanvasItem import CanvasItem, GroupCanvasItem from .CanvasItem import CanvasItem, GroupCanvasItem
class Canvas(QtGui.QWidget): class Canvas(QtGui.QWidget):
sigSelectionChanged = QtCore.Signal(object, object) sigSelectionChanged = QtCore.Signal(object, object)
@ -32,7 +34,6 @@ class Canvas(QtGui.QWidget):
QtGui.QWidget.__init__(self, parent) QtGui.QWidget.__init__(self, parent)
self.ui = Ui_Form() self.ui = Ui_Form()
self.ui.setupUi(self) self.ui.setupUi(self)
#self.view = self.ui.view
self.view = ViewBox() self.view = ViewBox()
self.ui.view.setCentralItem(self.view) self.ui.view.setCentralItem(self.view)
self.itemList = self.ui.itemList self.itemList = self.ui.itemList
@ -49,9 +50,7 @@ class Canvas(QtGui.QWidget):
self.redirect = None ## which canvas to redirect items to self.redirect = None ## which canvas to redirect items to
self.items = [] self.items = []
#self.view.enableMouse()
self.view.setAspectLocked(True) self.view.setAspectLocked(True)
#self.view.invertY()
grid = GridItem() grid = GridItem()
self.grid = CanvasItem(grid, name='Grid', movable=False) self.grid = CanvasItem(grid, name='Grid', movable=False)
@ -69,8 +68,6 @@ class Canvas(QtGui.QWidget):
self.ui.itemList.sigItemMoved.connect(self.treeItemMoved) self.ui.itemList.sigItemMoved.connect(self.treeItemMoved)
self.ui.itemList.itemSelectionChanged.connect(self.treeItemSelected) self.ui.itemList.itemSelectionChanged.connect(self.treeItemSelected)
self.ui.autoRangeBtn.clicked.connect(self.autoRange) self.ui.autoRangeBtn.clicked.connect(self.autoRange)
#self.ui.storeSvgBtn.clicked.connect(self.storeSvg)
#self.ui.storePngBtn.clicked.connect(self.storePng)
self.ui.redirectCheck.toggled.connect(self.updateRedirect) self.ui.redirectCheck.toggled.connect(self.updateRedirect)
self.ui.redirectCombo.currentIndexChanged.connect(self.updateRedirect) self.ui.redirectCombo.currentIndexChanged.connect(self.updateRedirect)
self.multiSelectBox.sigRegionChanged.connect(self.multiSelectBoxChanged) self.multiSelectBox.sigRegionChanged.connect(self.multiSelectBoxChanged)
@ -88,21 +85,11 @@ class Canvas(QtGui.QWidget):
self.ui.redirectCombo.setHostName(self.registeredName) self.ui.redirectCombo.setHostName(self.registeredName)
self.menu = QtGui.QMenu() self.menu = QtGui.QMenu()
#self.menu.setTitle("Image")
remAct = QtGui.QAction("Remove item", self.menu) remAct = QtGui.QAction("Remove item", self.menu)
remAct.triggered.connect(self.removeClicked) remAct.triggered.connect(self.removeClicked)
self.menu.addAction(remAct) self.menu.addAction(remAct)
self.menu.remAct = remAct self.menu.remAct = remAct
self.ui.itemList.contextMenuEvent = self.itemListContextMenuEvent self.ui.itemList.contextMenuEvent = self.itemListContextMenuEvent
#def storeSvg(self):
#from pyqtgraph.GraphicsScene.exportDialog import ExportDialog
#ex = ExportDialog(self.ui.view)
#ex.show()
#def storePng(self):
#self.ui.view.writeImage()
def splitterMoved(self): def splitterMoved(self):
self.resizeEvent() self.resizeEvent()
@ -135,7 +122,6 @@ class Canvas(QtGui.QWidget):
s = min(self.width(), max(100, min(200, self.width()*0.25))) s = min(self.width(), max(100, min(200, self.width()*0.25)))
s2 = self.width()-s s2 = self.width()-s
self.ui.splitter.setSizes([s2, s]) self.ui.splitter.setSizes([s2, s])
def updateRedirect(self, *args): def updateRedirect(self, *args):
### Decide whether/where to redirect items and make it so ### Decide whether/where to redirect items and make it so
@ -154,7 +140,6 @@ class Canvas(QtGui.QWidget):
self.reclaimItems() self.reclaimItems()
else: else:
self.redirectItems(redirect) self.redirectItems(redirect)
def redirectItems(self, canvas): def redirectItems(self, canvas):
for i in self.items: for i in self.items:
@ -171,12 +156,9 @@ class Canvas(QtGui.QWidget):
else: else:
parent.removeChild(li) parent.removeChild(li)
canvas.addItem(i) canvas.addItem(i)
def reclaimItems(self): def reclaimItems(self):
items = self.items items = self.items
#self.items = {'Grid': items['Grid']}
#del items['Grid']
self.items = [self.grid] self.items = [self.grid]
items.remove(self.grid) items.remove(self.grid)
@ -185,9 +167,6 @@ class Canvas(QtGui.QWidget):
self.addItem(i) self.addItem(i)
def treeItemChanged(self, item, col): def treeItemChanged(self, item, col):
#gi = self.items.get(item.name, None)
#if gi is None:
#return
try: try:
citem = item.canvasItem() citem = item.canvasItem()
except AttributeError: except AttributeError:
@ -203,25 +182,16 @@ class Canvas(QtGui.QWidget):
def treeItemSelected(self): def treeItemSelected(self):
sel = self.selectedItems() sel = self.selectedItems()
#sel = []
#for listItem in self.itemList.selectedItems():
#if hasattr(listItem, 'canvasItem') and listItem.canvasItem is not None:
#sel.append(listItem.canvasItem)
#sel = [self.items[item.name] for item in sel]
if len(sel) == 0: if len(sel) == 0:
#self.selectWidget.hide()
return return
multi = len(sel) > 1 multi = len(sel) > 1
for i in self.items: for i in self.items:
#i.ctrlWidget().hide()
## updated the selected state of every item ## updated the selected state of every item
i.selectionChanged(i in sel, multi) i.selectionChanged(i in sel, multi)
if len(sel)==1: if len(sel)==1:
#item = sel[0]
#item.ctrlWidget().show()
self.multiSelectBox.hide() self.multiSelectBox.hide()
self.ui.mirrorSelectionBtn.hide() self.ui.mirrorSelectionBtn.hide()
self.ui.reflectSelectionBtn.hide() self.ui.reflectSelectionBtn.hide()
@ -229,14 +199,6 @@ class Canvas(QtGui.QWidget):
elif len(sel) > 1: elif len(sel) > 1:
self.showMultiSelectBox() self.showMultiSelectBox()
#if item.isMovable():
#self.selectBox.setPos(item.item.pos())
#self.selectBox.setSize(item.item.sceneBoundingRect().size())
#self.selectBox.show()
#else:
#self.selectBox.hide()
#self.emit(QtCore.SIGNAL('itemSelected'), self, item)
self.sigSelectionChanged.emit(self, sel) self.sigSelectionChanged.emit(self, sel)
def selectedItems(self): def selectedItems(self):
@ -245,19 +207,9 @@ class Canvas(QtGui.QWidget):
""" """
return [item.canvasItem() for item in self.itemList.selectedItems() if item.canvasItem() is not None] return [item.canvasItem() for item in self.itemList.selectedItems() if item.canvasItem() is not None]
#def selectedItem(self):
#sel = self.itemList.selectedItems()
#if sel is None or len(sel) < 1:
#return
#return self.items.get(sel[0].name, None)
def selectItem(self, item): def selectItem(self, item):
li = item.listItem li = item.listItem
#li = self.getListItem(item.name())
#print "select", li
self.itemList.setCurrentItem(li) self.itemList.setCurrentItem(li)
def showMultiSelectBox(self): def showMultiSelectBox(self):
## Get list of selected canvas items ## Get list of selected canvas items
@ -281,7 +233,6 @@ class Canvas(QtGui.QWidget):
self.ui.mirrorSelectionBtn.show() self.ui.mirrorSelectionBtn.show()
self.ui.reflectSelectionBtn.show() self.ui.reflectSelectionBtn.show()
self.ui.resetTransformsBtn.show() self.ui.resetTransformsBtn.show()
#self.multiSelectBoxBase = self.multiSelectBox.getState().copy()
def mirrorSelectionClicked(self): def mirrorSelectionClicked(self):
for ci in self.selectedItems(): for ci in self.selectedItems():
@ -312,7 +263,6 @@ class Canvas(QtGui.QWidget):
ci.setTemporaryTransform(transform) ci.setTemporaryTransform(transform)
ci.sigTransformChanged.emit(ci) ci.sigTransformChanged.emit(ci)
def addGraphicsItem(self, item, **opts): def addGraphicsItem(self, item, **opts):
"""Add a new GraphicsItem to the scene at pos. """Add a new GraphicsItem to the scene at pos.
Common options are name, pos, scale, and z Common options are name, pos, scale, and z
@ -321,13 +271,11 @@ class Canvas(QtGui.QWidget):
item._canvasItem = citem item._canvasItem = citem
self.addItem(citem) self.addItem(citem)
return citem return citem
def addGroup(self, name, **kargs): def addGroup(self, name, **kargs):
group = GroupCanvasItem(name=name) group = GroupCanvasItem(name=name)
self.addItem(group, **kargs) self.addItem(group, **kargs)
return group return group
def addItem(self, citem): def addItem(self, citem):
""" """
@ -363,7 +311,6 @@ class Canvas(QtGui.QWidget):
#name = newname #name = newname
## find parent and add item to tree ## find parent and add item to tree
#currentNode = self.itemList.invisibleRootItem()
insertLocation = 0 insertLocation = 0
#print "Inserting node:", name #print "Inserting node:", name
@ -413,11 +360,7 @@ class Canvas(QtGui.QWidget):
node.setCheckState(0, QtCore.Qt.Unchecked) node.setCheckState(0, QtCore.Qt.Unchecked)
node.name = name node.name = name
#if citem.opts['parent'] != None:
## insertLocation is incorrect in this case
parent.insertChild(insertLocation, node) parent.insertChild(insertLocation, node)
#else:
#root.insertChild(insertLocation, node)
citem.name = name citem.name = name
citem.listItem = node citem.listItem = node
@ -435,36 +378,6 @@ class Canvas(QtGui.QWidget):
if len(self.items) == 2: if len(self.items) == 2:
self.autoRange() self.autoRange()
#for n in name:
#nextnode = None
#for x in range(currentNode.childCount()):
#ch = currentNode.child(x)
#if hasattr(ch, 'name'): ## check Z-value of current item to determine insert location
#zval = ch.canvasItem.zValue()
#if zval > z:
###print " ->", x
#insertLocation = x+1
#if n == ch.text(0):
#nextnode = ch
#break
#if nextnode is None: ## If name doesn't exist, create it
#nextnode = QtGui.QTreeWidgetItem([n])
#nextnode.setFlags((nextnode.flags() | QtCore.Qt.ItemIsUserCheckable) & ~QtCore.Qt.ItemIsDropEnabled)
#nextnode.setCheckState(0, QtCore.Qt.Checked)
### Add node to correct position in list by Z-value
###print " ==>", insertLocation
#currentNode.insertChild(insertLocation, nextnode)
#if n == name[-1]: ## This is the leaf; add some extra properties.
#nextnode.name = name
#if n == name[0]: ## This is the root; make the item movable
#nextnode.setFlags(nextnode.flags() | QtCore.Qt.ItemIsDragEnabled)
#else:
#nextnode.setFlags(nextnode.flags() & ~QtCore.Qt.ItemIsDragEnabled)
#currentNode = nextnode
return citem return citem
def treeItemMoved(self, item, parent, index): def treeItemMoved(self, item, parent, index):
@ -481,31 +394,6 @@ class Canvas(QtGui.QWidget):
for i in range(len(siblings)): for i in range(len(siblings)):
item = siblings[i] item = siblings[i]
item.setZValue(zvals[i]) item.setZValue(zvals[i])
#item = self.itemList.topLevelItem(i)
##ci = self.items[item.name]
#ci = item.canvasItem
#if ci is None:
#continue
#if ci.zValue() != zvals[i]:
#ci.setZValue(zvals[i])
#if self.itemList.topLevelItemCount() < 2:
#return
#name = item.name
#gi = self.items[name]
#if index == 0:
#next = self.itemList.topLevelItem(1)
#z = self.items[next.name].zValue()+1
#else:
#prev = self.itemList.topLevelItem(index-1)
#z = self.items[prev.name].zValue()-1
#gi.setZValue(z)
def itemVisibilityChanged(self, item): def itemVisibilityChanged(self, item):
listItem = item.listItem listItem = item.listItem
@ -521,7 +409,6 @@ class Canvas(QtGui.QWidget):
if isinstance(item, QtGui.QTreeWidgetItem): if isinstance(item, QtGui.QTreeWidgetItem):
item = item.canvasItem() item = item.canvasItem()
if isinstance(item, CanvasItem): if isinstance(item, CanvasItem):
item.setCanvas(None) item.setCanvas(None)
listItem = item.listItem listItem = item.listItem
@ -532,25 +419,24 @@ class Canvas(QtGui.QWidget):
ctrl = item.ctrlWidget() ctrl = item.ctrlWidget()
ctrl.hide() ctrl.hide()
self.ui.ctrlLayout.removeWidget(ctrl) self.ui.ctrlLayout.removeWidget(ctrl)
ctrl.setParent(None)
else: else:
if hasattr(item, '_canvasItem'): if hasattr(item, '_canvasItem'):
self.removeItem(item._canvasItem) self.removeItem(item._canvasItem)
else: else:
self.view.removeItem(item) self.view.removeItem(item)
## disconnect signals, remove from list, etc.. gc.collect()
def clear(self): def clear(self):
while len(self.items) > 0: while len(self.items) > 0:
self.removeItem(self.items[0]) self.removeItem(self.items[0])
def addToScene(self, item): def addToScene(self, item):
self.view.addItem(item) self.view.addItem(item)
def removeFromScene(self, item): def removeFromScene(self, item):
self.view.removeItem(item) self.view.removeItem(item)
def listItems(self): def listItems(self):
"""Return a dictionary of name:item pairs""" """Return a dictionary of name:item pairs"""
@ -559,15 +445,10 @@ class Canvas(QtGui.QWidget):
def getListItem(self, name): def getListItem(self, name):
return self.items[name] return self.items[name]
#def scene(self):
#return self.view.scene()
def itemTransformChanged(self, item): def itemTransformChanged(self, item):
#self.emit(QtCore.SIGNAL('itemTransformChanged'), self, item)
self.sigItemTransformChanged.emit(self, item) self.sigItemTransformChanged.emit(self, item)
def itemTransformChangeFinished(self, item): def itemTransformChangeFinished(self, item):
#self.emit(QtCore.SIGNAL('itemTransformChangeFinished'), self, item)
self.sigItemTransformChangeFinished.emit(self, item) self.sigItemTransformChangeFinished.emit(self, item)
def itemListContextMenuEvent(self, ev): def itemListContextMenuEvent(self, ev):
@ -575,13 +456,13 @@ class Canvas(QtGui.QWidget):
self.menu.popup(ev.globalPos()) self.menu.popup(ev.globalPos())
def removeClicked(self): def removeClicked(self):
#self.removeItem(self.menuItem)
for item in self.selectedItems(): for item in self.selectedItems():
self.removeItem(item) self.removeItem(item)
self.menuItem = None self.menuItem = None
import gc import gc
gc.collect() gc.collect()
class SelectBox(ROI): class SelectBox(ROI):
def __init__(self, scalable=False): def __init__(self, scalable=False):
#QtGui.QGraphicsRectItem.__init__(self, 0, 0, size[0], size[1]) #QtGui.QGraphicsRectItem.__init__(self, 0, 0, size[0], size[1])
@ -593,14 +474,3 @@ class SelectBox(ROI):
self.addScaleHandle([0, 0], center, lockAspect=True) self.addScaleHandle([0, 0], center, lockAspect=True)
self.addRotateHandle([0, 1], center) self.addRotateHandle([0, 1], center)
self.addRotateHandle([1, 0], center) self.addRotateHandle([1, 0], center)

View File

@ -1,4 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import numpy as np
from ..Qt import QtGui, QtCore, QtSvg, QT_LIB from ..Qt import QtGui, QtCore, QtSvg, QT_LIB
from ..graphicsItems.ROI import ROI from ..graphicsItems.ROI import ROI
from .. import SRTTransform, ItemGroup from .. import SRTTransform, ItemGroup
@ -87,14 +88,12 @@ class CanvasItem(QtCore.QObject):
self.alphaSlider.valueChanged.connect(self.alphaChanged) self.alphaSlider.valueChanged.connect(self.alphaChanged)
self.alphaSlider.sliderPressed.connect(self.alphaPressed) self.alphaSlider.sliderPressed.connect(self.alphaPressed)
self.alphaSlider.sliderReleased.connect(self.alphaReleased) self.alphaSlider.sliderReleased.connect(self.alphaReleased)
#self.canvas.sigSelectionChanged.connect(self.selectionChanged)
self.resetTransformBtn.clicked.connect(self.resetTransformClicked) self.resetTransformBtn.clicked.connect(self.resetTransformClicked)
self.copyBtn.clicked.connect(self.copyClicked) self.copyBtn.clicked.connect(self.copyClicked)
self.pasteBtn.clicked.connect(self.pasteClicked) self.pasteBtn.clicked.connect(self.pasteClicked)
self.setMovable(self.opts['movable']) ## update gui to reflect this option self.setMovable(self.opts['movable']) ## update gui to reflect this option
if 'transform' in self.opts: if 'transform' in self.opts:
self.baseTransform = self.opts['transform'] self.baseTransform = self.opts['transform']
else: else:
@ -114,7 +113,6 @@ class CanvasItem(QtCore.QObject):
## every CanvasItem implements its own individual selection box ## every CanvasItem implements its own individual selection box
## so that subclasses are free to make their own. ## so that subclasses are free to make their own.
self.selectBox = SelectBox(scalable=self.opts['scalable'], rotatable=self.opts['rotatable']) self.selectBox = SelectBox(scalable=self.opts['scalable'], rotatable=self.opts['rotatable'])
#self.canvas.scene().addItem(self.selectBox)
self.selectBox.hide() self.selectBox.hide()
self.selectBox.setZValue(1e6) self.selectBox.setZValue(1e6)
self.selectBox.sigRegionChanged.connect(self.selectBoxChanged) ## calls selectBoxMoved self.selectBox.sigRegionChanged.connect(self.selectBoxChanged) ## calls selectBoxMoved
@ -129,16 +127,7 @@ class CanvasItem(QtCore.QObject):
self.tempTransform = SRTTransform() ## holds the additional transform that happens during a move - gets added to the userTransform when move is done. self.tempTransform = SRTTransform() ## holds the additional transform that happens during a move - gets added to the userTransform when move is done.
self.userTransform = SRTTransform() ## stores the total transform of the object self.userTransform = SRTTransform() ## stores the total transform of the object
self.resetUserTransform() self.resetUserTransform()
## now happens inside resetUserTransform -> selectBoxToItem
# self.selectBoxBase = self.selectBox.getState().copy()
#print "Created canvas item", self
#print " base:", self.baseTransform
#print " user:", self.userTransform
#print " temp:", self.tempTransform
#print " bounds:", self.item.sceneBoundingRect()
def setMovable(self, m): def setMovable(self, m):
self.opts['movable'] = m self.opts['movable'] = m
@ -239,7 +228,6 @@ class CanvasItem(QtCore.QObject):
# s=self.updateTransform() # s=self.updateTransform()
# self.setTranslate(-2*s['pos'][0], -2*s['pos'][1]) # self.setTranslate(-2*s['pos'][0], -2*s['pos'][1])
# self.selectBoxFromUser() # self.selectBoxFromUser()
def hasUserTransform(self): def hasUserTransform(self):
#print self.userRotate, self.userTranslate #print self.userRotate, self.userTranslate
@ -252,10 +240,15 @@ class CanvasItem(QtCore.QObject):
alpha = val / 1023. alpha = val / 1023.
self._graphicsItem.setOpacity(alpha) self._graphicsItem.setOpacity(alpha)
def setAlpha(self, alpha):
self.alphaSlider.setValue(int(np.clip(alpha * 1023, 0, 1023)))
def alpha(self):
return self.alphaSlider.value() / 1023.
def isMovable(self): def isMovable(self):
return self.opts['movable'] return self.opts['movable']
def selectBoxMoved(self): def selectBoxMoved(self):
"""The selection box has moved; get its transformation information and pass to the graphics item""" """The selection box has moved; get its transformation information and pass to the graphics item"""
self.userTransform = self.selectBox.getGlobalTransform(relativeTo=self.selectBoxBase) self.userTransform = self.selectBox.getGlobalTransform(relativeTo=self.selectBoxBase)
@ -290,7 +283,6 @@ class CanvasItem(QtCore.QObject):
self.userTransform.setScale(x, y) self.userTransform.setScale(x, y)
self.selectBoxFromUser() self.selectBoxFromUser()
self.updateTransform() self.updateTransform()
def setTemporaryTransform(self, transform): def setTemporaryTransform(self, transform):
self.tempTransform = transform self.tempTransform = transform
@ -302,21 +294,6 @@ class CanvasItem(QtCore.QObject):
self.resetTemporaryTransform() self.resetTemporaryTransform()
self.selectBoxFromUser() ## update the selection box to match the new userTransform self.selectBoxFromUser() ## update the selection box to match the new userTransform
#st = self.userTransform.saveState()
#self.userTransform = self.userTransform * self.tempTransform ## order is important!
#### matrix multiplication affects the scale factors, need to reset
#if st['scale'][0] < 0 or st['scale'][1] < 0:
#nst = self.userTransform.saveState()
#self.userTransform.setScale([-nst['scale'][0], -nst['scale'][1]])
#self.resetTemporaryTransform()
#self.selectBoxFromUser()
#self.selectBoxChangeFinished()
def resetTemporaryTransform(self): def resetTemporaryTransform(self):
self.tempTransform = SRTTransform() ## don't use Transform.reset()--this transform might be used elsewhere. self.tempTransform = SRTTransform() ## don't use Transform.reset()--this transform might be used elsewhere.
self.updateTransform() self.updateTransform()
@ -339,20 +316,13 @@ class CanvasItem(QtCore.QObject):
def displayTransform(self, transform): def displayTransform(self, transform):
"""Updates transform numbers in the ctrl widget.""" """Updates transform numbers in the ctrl widget."""
tr = transform.saveState() tr = transform.saveState()
self.transformGui.translateLabel.setText("Translate: (%f, %f)" %(tr['pos'][0], tr['pos'][1])) self.transformGui.translateLabel.setText("Translate: (%f, %f)" %(tr['pos'][0], tr['pos'][1]))
self.transformGui.rotateLabel.setText("Rotate: %f degrees" %tr['angle']) self.transformGui.rotateLabel.setText("Rotate: %f degrees" %tr['angle'])
self.transformGui.scaleLabel.setText("Scale: (%f, %f)" %(tr['scale'][0], tr['scale'][1])) self.transformGui.scaleLabel.setText("Scale: (%f, %f)" %(tr['scale'][0], tr['scale'][1]))
#self.transformGui.mirrorImageCheck.setChecked(False)
#if tr['scale'][0] < 0:
# self.transformGui.mirrorImageCheck.setChecked(True)
def resetUserTransform(self): def resetUserTransform(self):
#self.userRotate = 0
#self.userTranslate = pg.Point(0,0)
self.userTransform.reset() self.userTransform.reset()
self.updateTransform() self.updateTransform()
@ -368,8 +338,6 @@ class CanvasItem(QtCore.QObject):
def restoreTransform(self, tr): def restoreTransform(self, tr):
try: try:
#self.userTranslate = pg.Point(tr['trans'])
#self.userRotate = tr['rot']
self.userTransform = SRTTransform(tr) self.userTransform = SRTTransform(tr)
self.updateTransform() self.updateTransform()
@ -377,16 +345,11 @@ class CanvasItem(QtCore.QObject):
self.sigTransformChanged.emit(self) self.sigTransformChanged.emit(self)
self.sigTransformChangeFinished.emit(self) self.sigTransformChangeFinished.emit(self)
except: except:
#self.userTranslate = pg.Point([0,0])
#self.userRotate = 0
self.userTransform = SRTTransform() self.userTransform = SRTTransform()
debug.printExc("Failed to load transform:") debug.printExc("Failed to load transform:")
#print "set transform", self, self.userTranslate
def saveTransform(self): def saveTransform(self):
"""Return a dict containing the current user transform""" """Return a dict containing the current user transform"""
#print "save transform", self, self.userTranslate
#return {'trans': list(self.userTranslate), 'rot': self.userRotate}
return self.userTransform.saveState() return self.userTransform.saveState()
def selectBoxFromUser(self): def selectBoxFromUser(self):
@ -404,7 +367,6 @@ class CanvasItem(QtCore.QObject):
#self.selectBox.setAngle(self.userRotate) #self.selectBox.setAngle(self.userRotate)
#self.selectBox.setPos([x2, y2]) #self.selectBox.setPos([x2, y2])
self.selectBox.blockSignals(False) self.selectBox.blockSignals(False)
def selectBoxToItem(self): def selectBoxToItem(self):
"""Move/scale the selection box so it fits the item's bounding rect. (assumes item is not rotated)""" """Move/scale the selection box so it fits the item's bounding rect. (assumes item is not rotated)"""
@ -424,11 +386,6 @@ class CanvasItem(QtCore.QObject):
self.opts['z'] = z self.opts['z'] = z
if z is not None: if z is not None:
self._graphicsItem.setZValue(z) self._graphicsItem.setZValue(z)
#def selectionChanged(self, canvas, items):
#self.selected = len(items) == 1 and (items[0] is self)
#self.showSelectBox()
def selectionChanged(self, sel, multi): def selectionChanged(self, sel, multi):
""" """
@ -456,16 +413,12 @@ class CanvasItem(QtCore.QObject):
def hideSelectBox(self): def hideSelectBox(self):
self.selectBox.hide() self.selectBox.hide()
def selectBoxChanged(self): def selectBoxChanged(self):
self.selectBoxMoved() self.selectBoxMoved()
#self.updateTransform(self.selectBox)
#self.emit(QtCore.SIGNAL('transformChanged'), self)
self.sigTransformChanged.emit(self) self.sigTransformChanged.emit(self)
def selectBoxChangeFinished(self): def selectBoxChangeFinished(self):
#self.emit(QtCore.SIGNAL('transformChangeFinished'), self)
self.sigTransformChangeFinished.emit(self) self.sigTransformChangeFinished.emit(self)
def alphaPressed(self): def alphaPressed(self):
@ -500,6 +453,25 @@ class CanvasItem(QtCore.QObject):
def isVisible(self): def isVisible(self):
return self.opts['visible'] return self.opts['visible']
def saveState(self):
return {
'type': self.__class__.__name__,
'name': self.name,
'visible': self.isVisible(),
'alpha': self.alpha(),
'userTransform': self.saveTransform(),
'z': self.zValue(),
'scalable': self.opts['scalable'],
'rotatable': self.opts['rotatable'],
'movable': self.opts['movable'],
}
def restoreState(self, state):
self.setVisible(state['visible'])
self.setAlpha(state['alpha'])
self.restoreTransform(state['userTransform'])
self.setZValue(state['z'])
class GroupCanvasItem(CanvasItem): class GroupCanvasItem(CanvasItem):
""" """

View File

@ -6,14 +6,14 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>490</width> <width>821</width>
<height>414</height> <height>578</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Form</string> <string>Form</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout_2">
<property name="margin"> <property name="margin">
<number>0</number> <number>0</number>
</property> </property>
@ -26,88 +26,96 @@
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<widget class="GraphicsView" name="view"/> <widget class="GraphicsView" name="view"/>
<widget class="QWidget" name="layoutWidget"> <widget class="QSplitter" name="vsplitter">
<layout class="QGridLayout" name="gridLayout_2"> <property name="orientation">
<item row="2" column="0" colspan="2"> <enum>Qt::Vertical</enum>
<widget class="QPushButton" name="autoRangeBtn"> </property>
<property name="sizePolicy"> <widget class="QWidget" name="canvasCtrlWidget" native="true">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed"> <layout class="QGridLayout" name="gridLayout">
<horstretch>0</horstretch> <item row="0" column="0" colspan="2">
<verstretch>1</verstretch> <widget class="QPushButton" name="autoRangeBtn">
</sizepolicy> <property name="sizePolicy">
</property> <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<property name="text"> <horstretch>0</horstretch>
<string>Auto Range</string> <verstretch>1</verstretch>
</property> </sizepolicy>
</widget>
</item>
<item row="5" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>0</number>
</property>
<item>
<widget class="QCheckBox" name="redirectCheck">
<property name="toolTip">
<string>Check to display all local items in a remote canvas.</string>
</property>
<property name="text">
<string>Redirect</string>
</property>
</widget>
</item>
<item>
<widget class="CanvasCombo" name="redirectCombo"/>
</item>
</layout>
</item>
<item row="6" column="0" colspan="2">
<widget class="TreeWidget" name="itemList">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>100</verstretch>
</sizepolicy>
</property>
<property name="headerHidden">
<bool>true</bool>
</property>
<column>
<property name="text">
<string notr="true">1</string>
</property> </property>
</column> <property name="text">
</widget> <string>Auto Range</string>
</item> </property>
<item row="10" column="0" colspan="2"> </widget>
<layout class="QGridLayout" name="ctrlLayout"> </item>
<property name="spacing"> <item row="1" column="0" colspan="2">
<number>0</number> <layout class="QHBoxLayout" name="horizontalLayout">
</property> <property name="spacing">
</layout> <number>0</number>
</item> </property>
<item row="7" column="0"> <item>
<widget class="QPushButton" name="resetTransformsBtn"> <widget class="QCheckBox" name="redirectCheck">
<property name="text"> <property name="toolTip">
<string>Reset Transforms</string> <string>Check to display all local items in a remote canvas.</string>
</property> </property>
</widget> <property name="text">
</item> <string>Redirect</string>
<item row="3" column="0"> </property>
<widget class="QPushButton" name="mirrorSelectionBtn"> </widget>
<property name="text"> </item>
<string>Mirror Selection</string> <item>
</property> <widget class="CanvasCombo" name="redirectCombo"/>
</widget> </item>
</item> </layout>
<item row="3" column="1"> </item>
<widget class="QPushButton" name="reflectSelectionBtn"> <item row="2" column="0" colspan="2">
<property name="text"> <widget class="TreeWidget" name="itemList">
<string>MirrorXY</string> <property name="sizePolicy">
</property> <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
</widget> <horstretch>0</horstretch>
</item> <verstretch>100</verstretch>
</layout> </sizepolicy>
</property>
<property name="headerHidden">
<bool>true</bool>
</property>
<column>
<property name="text">
<string notr="true">1</string>
</property>
</column>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QPushButton" name="resetTransformsBtn">
<property name="text">
<string>Reset Transforms</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QPushButton" name="mirrorSelectionBtn">
<property name="text">
<string>Mirror Selection</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QPushButton" name="reflectSelectionBtn">
<property name="text">
<string>MirrorXY</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="canvasItemCtrl" native="true">
<layout class="QGridLayout" name="ctrlLayout">
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
</layout>
</widget>
</widget> </widget>
</widget> </widget>
</item> </item>

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'pyqtgraph/canvas/CanvasTemplate.ui' # Form implementation generated from reading ui file 'CanvasTemplate.ui'
# #
# Created by: PyQt4 UI code generator 4.11.4 # Created by: PyQt4 UI code generator 4.11.4
# #
@ -25,39 +25,42 @@ except AttributeError:
class Ui_Form(object): class Ui_Form(object):
def setupUi(self, Form): def setupUi(self, Form):
Form.setObjectName(_fromUtf8("Form")) Form.setObjectName(_fromUtf8("Form"))
Form.resize(490, 414) Form.resize(821, 578)
self.gridLayout = QtGui.QGridLayout(Form) self.gridLayout_2 = QtGui.QGridLayout(Form)
self.gridLayout.setMargin(0) self.gridLayout_2.setMargin(0)
self.gridLayout.setSpacing(0) self.gridLayout_2.setSpacing(0)
self.gridLayout.setObjectName(_fromUtf8("gridLayout")) self.gridLayout_2.setObjectName(_fromUtf8("gridLayout_2"))
self.splitter = QtGui.QSplitter(Form) self.splitter = QtGui.QSplitter(Form)
self.splitter.setOrientation(QtCore.Qt.Horizontal) self.splitter.setOrientation(QtCore.Qt.Horizontal)
self.splitter.setObjectName(_fromUtf8("splitter")) self.splitter.setObjectName(_fromUtf8("splitter"))
self.view = GraphicsView(self.splitter) self.view = GraphicsView(self.splitter)
self.view.setObjectName(_fromUtf8("view")) self.view.setObjectName(_fromUtf8("view"))
self.layoutWidget = QtGui.QWidget(self.splitter) self.vsplitter = QtGui.QSplitter(self.splitter)
self.layoutWidget.setObjectName(_fromUtf8("layoutWidget")) self.vsplitter.setOrientation(QtCore.Qt.Vertical)
self.gridLayout_2 = QtGui.QGridLayout(self.layoutWidget) self.vsplitter.setObjectName(_fromUtf8("vsplitter"))
self.gridLayout_2.setObjectName(_fromUtf8("gridLayout_2")) self.canvasCtrlWidget = QtGui.QWidget(self.vsplitter)
self.autoRangeBtn = QtGui.QPushButton(self.layoutWidget) self.canvasCtrlWidget.setObjectName(_fromUtf8("canvasCtrlWidget"))
self.gridLayout = QtGui.QGridLayout(self.canvasCtrlWidget)
self.gridLayout.setObjectName(_fromUtf8("gridLayout"))
self.autoRangeBtn = QtGui.QPushButton(self.canvasCtrlWidget)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0) sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(1) sizePolicy.setVerticalStretch(1)
sizePolicy.setHeightForWidth(self.autoRangeBtn.sizePolicy().hasHeightForWidth()) sizePolicy.setHeightForWidth(self.autoRangeBtn.sizePolicy().hasHeightForWidth())
self.autoRangeBtn.setSizePolicy(sizePolicy) self.autoRangeBtn.setSizePolicy(sizePolicy)
self.autoRangeBtn.setObjectName(_fromUtf8("autoRangeBtn")) self.autoRangeBtn.setObjectName(_fromUtf8("autoRangeBtn"))
self.gridLayout_2.addWidget(self.autoRangeBtn, 2, 0, 1, 2) self.gridLayout.addWidget(self.autoRangeBtn, 0, 0, 1, 2)
self.horizontalLayout = QtGui.QHBoxLayout() self.horizontalLayout = QtGui.QHBoxLayout()
self.horizontalLayout.setSpacing(0) self.horizontalLayout.setSpacing(0)
self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout"))
self.redirectCheck = QtGui.QCheckBox(self.layoutWidget) self.redirectCheck = QtGui.QCheckBox(self.canvasCtrlWidget)
self.redirectCheck.setObjectName(_fromUtf8("redirectCheck")) self.redirectCheck.setObjectName(_fromUtf8("redirectCheck"))
self.horizontalLayout.addWidget(self.redirectCheck) self.horizontalLayout.addWidget(self.redirectCheck)
self.redirectCombo = CanvasCombo(self.layoutWidget) self.redirectCombo = CanvasCombo(self.canvasCtrlWidget)
self.redirectCombo.setObjectName(_fromUtf8("redirectCombo")) self.redirectCombo.setObjectName(_fromUtf8("redirectCombo"))
self.horizontalLayout.addWidget(self.redirectCombo) self.horizontalLayout.addWidget(self.redirectCombo)
self.gridLayout_2.addLayout(self.horizontalLayout, 5, 0, 1, 2) self.gridLayout.addLayout(self.horizontalLayout, 1, 0, 1, 2)
self.itemList = TreeWidget(self.layoutWidget) self.itemList = TreeWidget(self.canvasCtrlWidget)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0) sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(100) sizePolicy.setVerticalStretch(100)
@ -66,21 +69,23 @@ class Ui_Form(object):
self.itemList.setHeaderHidden(True) self.itemList.setHeaderHidden(True)
self.itemList.setObjectName(_fromUtf8("itemList")) self.itemList.setObjectName(_fromUtf8("itemList"))
self.itemList.headerItem().setText(0, _fromUtf8("1")) self.itemList.headerItem().setText(0, _fromUtf8("1"))
self.gridLayout_2.addWidget(self.itemList, 6, 0, 1, 2) self.gridLayout.addWidget(self.itemList, 2, 0, 1, 2)
self.ctrlLayout = QtGui.QGridLayout() self.resetTransformsBtn = QtGui.QPushButton(self.canvasCtrlWidget)
self.resetTransformsBtn.setObjectName(_fromUtf8("resetTransformsBtn"))
self.gridLayout.addWidget(self.resetTransformsBtn, 3, 0, 1, 2)
self.mirrorSelectionBtn = QtGui.QPushButton(self.canvasCtrlWidget)
self.mirrorSelectionBtn.setObjectName(_fromUtf8("mirrorSelectionBtn"))
self.gridLayout.addWidget(self.mirrorSelectionBtn, 4, 0, 1, 1)
self.reflectSelectionBtn = QtGui.QPushButton(self.canvasCtrlWidget)
self.reflectSelectionBtn.setObjectName(_fromUtf8("reflectSelectionBtn"))
self.gridLayout.addWidget(self.reflectSelectionBtn, 4, 1, 1, 1)
self.canvasItemCtrl = QtGui.QWidget(self.vsplitter)
self.canvasItemCtrl.setObjectName(_fromUtf8("canvasItemCtrl"))
self.ctrlLayout = QtGui.QGridLayout(self.canvasItemCtrl)
self.ctrlLayout.setMargin(0)
self.ctrlLayout.setSpacing(0) self.ctrlLayout.setSpacing(0)
self.ctrlLayout.setObjectName(_fromUtf8("ctrlLayout")) self.ctrlLayout.setObjectName(_fromUtf8("ctrlLayout"))
self.gridLayout_2.addLayout(self.ctrlLayout, 10, 0, 1, 2) self.gridLayout_2.addWidget(self.splitter, 0, 0, 1, 1)
self.resetTransformsBtn = QtGui.QPushButton(self.layoutWidget)
self.resetTransformsBtn.setObjectName(_fromUtf8("resetTransformsBtn"))
self.gridLayout_2.addWidget(self.resetTransformsBtn, 7, 0, 1, 1)
self.mirrorSelectionBtn = QtGui.QPushButton(self.layoutWidget)
self.mirrorSelectionBtn.setObjectName(_fromUtf8("mirrorSelectionBtn"))
self.gridLayout_2.addWidget(self.mirrorSelectionBtn, 3, 0, 1, 1)
self.reflectSelectionBtn = QtGui.QPushButton(self.layoutWidget)
self.reflectSelectionBtn.setObjectName(_fromUtf8("reflectSelectionBtn"))
self.gridLayout_2.addWidget(self.reflectSelectionBtn, 3, 1, 1, 1)
self.gridLayout.addWidget(self.splitter, 0, 0, 1, 1)
self.retranslateUi(Form) self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form) QtCore.QMetaObject.connectSlotsByName(Form)

View File

@ -1,8 +1,8 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'pyqtgraph/canvas/CanvasTemplate.ui' # Form implementation generated from reading ui file 'CanvasTemplate.ui'
# #
# Created by: PyQt5 UI code generator 5.5.1 # Created by: PyQt5 UI code generator 5.7.1
# #
# WARNING! All changes made in this file will be lost! # WARNING! All changes made in this file will be lost!
@ -11,39 +11,43 @@ from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Form(object): class Ui_Form(object):
def setupUi(self, Form): def setupUi(self, Form):
Form.setObjectName("Form") Form.setObjectName("Form")
Form.resize(490, 414) Form.resize(821, 578)
self.gridLayout = QtWidgets.QGridLayout(Form) self.gridLayout_2 = QtWidgets.QGridLayout(Form)
self.gridLayout.setContentsMargins(0, 0, 0, 0) self.gridLayout_2.setContentsMargins(0, 0, 0, 0)
self.gridLayout.setSpacing(0) self.gridLayout_2.setSpacing(0)
self.gridLayout.setObjectName("gridLayout") self.gridLayout_2.setObjectName("gridLayout_2")
self.splitter = QtWidgets.QSplitter(Form) self.splitter = QtWidgets.QSplitter(Form)
self.splitter.setOrientation(QtCore.Qt.Horizontal) self.splitter.setOrientation(QtCore.Qt.Horizontal)
self.splitter.setObjectName("splitter") self.splitter.setObjectName("splitter")
self.view = GraphicsView(self.splitter) self.view = GraphicsView(self.splitter)
self.view.setObjectName("view") self.view.setObjectName("view")
self.layoutWidget = QtWidgets.QWidget(self.splitter) self.vsplitter = QtWidgets.QSplitter(self.splitter)
self.layoutWidget.setObjectName("layoutWidget") self.vsplitter.setOrientation(QtCore.Qt.Vertical)
self.gridLayout_2 = QtWidgets.QGridLayout(self.layoutWidget) self.vsplitter.setObjectName("vsplitter")
self.gridLayout_2.setObjectName("gridLayout_2") self.canvasCtrlWidget = QtWidgets.QWidget(self.vsplitter)
self.autoRangeBtn = QtWidgets.QPushButton(self.layoutWidget) self.canvasCtrlWidget.setObjectName("canvasCtrlWidget")
self.gridLayout = QtWidgets.QGridLayout(self.canvasCtrlWidget)
self.gridLayout.setContentsMargins(0, 0, 0, 0)
self.gridLayout.setObjectName("gridLayout")
self.autoRangeBtn = QtWidgets.QPushButton(self.canvasCtrlWidget)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Fixed) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0) sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(1) sizePolicy.setVerticalStretch(1)
sizePolicy.setHeightForWidth(self.autoRangeBtn.sizePolicy().hasHeightForWidth()) sizePolicy.setHeightForWidth(self.autoRangeBtn.sizePolicy().hasHeightForWidth())
self.autoRangeBtn.setSizePolicy(sizePolicy) self.autoRangeBtn.setSizePolicy(sizePolicy)
self.autoRangeBtn.setObjectName("autoRangeBtn") self.autoRangeBtn.setObjectName("autoRangeBtn")
self.gridLayout_2.addWidget(self.autoRangeBtn, 2, 0, 1, 2) self.gridLayout.addWidget(self.autoRangeBtn, 0, 0, 1, 2)
self.horizontalLayout = QtWidgets.QHBoxLayout() self.horizontalLayout = QtWidgets.QHBoxLayout()
self.horizontalLayout.setSpacing(0) self.horizontalLayout.setSpacing(0)
self.horizontalLayout.setObjectName("horizontalLayout") self.horizontalLayout.setObjectName("horizontalLayout")
self.redirectCheck = QtWidgets.QCheckBox(self.layoutWidget) self.redirectCheck = QtWidgets.QCheckBox(self.canvasCtrlWidget)
self.redirectCheck.setObjectName("redirectCheck") self.redirectCheck.setObjectName("redirectCheck")
self.horizontalLayout.addWidget(self.redirectCheck) self.horizontalLayout.addWidget(self.redirectCheck)
self.redirectCombo = CanvasCombo(self.layoutWidget) self.redirectCombo = CanvasCombo(self.canvasCtrlWidget)
self.redirectCombo.setObjectName("redirectCombo") self.redirectCombo.setObjectName("redirectCombo")
self.horizontalLayout.addWidget(self.redirectCombo) self.horizontalLayout.addWidget(self.redirectCombo)
self.gridLayout_2.addLayout(self.horizontalLayout, 5, 0, 1, 2) self.gridLayout.addLayout(self.horizontalLayout, 1, 0, 1, 2)
self.itemList = TreeWidget(self.layoutWidget) self.itemList = TreeWidget(self.canvasCtrlWidget)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0) sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(100) sizePolicy.setVerticalStretch(100)
@ -52,21 +56,23 @@ class Ui_Form(object):
self.itemList.setHeaderHidden(True) self.itemList.setHeaderHidden(True)
self.itemList.setObjectName("itemList") self.itemList.setObjectName("itemList")
self.itemList.headerItem().setText(0, "1") self.itemList.headerItem().setText(0, "1")
self.gridLayout_2.addWidget(self.itemList, 6, 0, 1, 2) self.gridLayout.addWidget(self.itemList, 2, 0, 1, 2)
self.ctrlLayout = QtWidgets.QGridLayout() self.resetTransformsBtn = QtWidgets.QPushButton(self.canvasCtrlWidget)
self.resetTransformsBtn.setObjectName("resetTransformsBtn")
self.gridLayout.addWidget(self.resetTransformsBtn, 3, 0, 1, 2)
self.mirrorSelectionBtn = QtWidgets.QPushButton(self.canvasCtrlWidget)
self.mirrorSelectionBtn.setObjectName("mirrorSelectionBtn")
self.gridLayout.addWidget(self.mirrorSelectionBtn, 4, 0, 1, 1)
self.reflectSelectionBtn = QtWidgets.QPushButton(self.canvasCtrlWidget)
self.reflectSelectionBtn.setObjectName("reflectSelectionBtn")
self.gridLayout.addWidget(self.reflectSelectionBtn, 4, 1, 1, 1)
self.canvasItemCtrl = QtWidgets.QWidget(self.vsplitter)
self.canvasItemCtrl.setObjectName("canvasItemCtrl")
self.ctrlLayout = QtWidgets.QGridLayout(self.canvasItemCtrl)
self.ctrlLayout.setContentsMargins(0, 0, 0, 0)
self.ctrlLayout.setSpacing(0) self.ctrlLayout.setSpacing(0)
self.ctrlLayout.setObjectName("ctrlLayout") self.ctrlLayout.setObjectName("ctrlLayout")
self.gridLayout_2.addLayout(self.ctrlLayout, 10, 0, 1, 2) self.gridLayout_2.addWidget(self.splitter, 0, 0, 1, 1)
self.resetTransformsBtn = QtWidgets.QPushButton(self.layoutWidget)
self.resetTransformsBtn.setObjectName("resetTransformsBtn")
self.gridLayout_2.addWidget(self.resetTransformsBtn, 7, 0, 1, 1)
self.mirrorSelectionBtn = QtWidgets.QPushButton(self.layoutWidget)
self.mirrorSelectionBtn.setObjectName("mirrorSelectionBtn")
self.gridLayout_2.addWidget(self.mirrorSelectionBtn, 3, 0, 1, 1)
self.reflectSelectionBtn = QtWidgets.QPushButton(self.layoutWidget)
self.reflectSelectionBtn.setObjectName("reflectSelectionBtn")
self.gridLayout_2.addWidget(self.reflectSelectionBtn, 3, 1, 1, 1)
self.gridLayout.addWidget(self.splitter, 0, 0, 1, 1)
self.retranslateUi(Form) self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form) QtCore.QMetaObject.connectSlotsByName(Form)

View File

@ -1,8 +1,8 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'pyqtgraph/canvas/CanvasTemplate.ui' # Form implementation generated from reading ui file 'CanvasTemplate.ui'
# #
# Created: Wed Nov 9 18:02:00 2016 # Created: Fri Mar 24 16:09:39 2017
# by: pyside-uic 0.2.15 running on PySide 1.2.2 # by: pyside-uic 0.2.15 running on PySide 1.2.2
# #
# WARNING! All changes made in this file will be lost! # WARNING! All changes made in this file will be lost!
@ -12,40 +12,43 @@ from PySide import QtCore, QtGui
class Ui_Form(object): class Ui_Form(object):
def setupUi(self, Form): def setupUi(self, Form):
Form.setObjectName("Form") Form.setObjectName("Form")
Form.resize(490, 414) Form.resize(821, 578)
self.gridLayout = QtGui.QGridLayout(Form) self.gridLayout_2 = QtGui.QGridLayout(Form)
self.gridLayout.setContentsMargins(0, 0, 0, 0) self.gridLayout_2.setContentsMargins(0, 0, 0, 0)
self.gridLayout.setSpacing(0) self.gridLayout_2.setSpacing(0)
self.gridLayout.setObjectName("gridLayout") self.gridLayout_2.setObjectName("gridLayout_2")
self.splitter = QtGui.QSplitter(Form) self.splitter = QtGui.QSplitter(Form)
self.splitter.setOrientation(QtCore.Qt.Horizontal) self.splitter.setOrientation(QtCore.Qt.Horizontal)
self.splitter.setObjectName("splitter") self.splitter.setObjectName("splitter")
self.view = GraphicsView(self.splitter) self.view = GraphicsView(self.splitter)
self.view.setObjectName("view") self.view.setObjectName("view")
self.layoutWidget = QtGui.QWidget(self.splitter) self.vsplitter = QtGui.QSplitter(self.splitter)
self.layoutWidget.setObjectName("layoutWidget") self.vsplitter.setOrientation(QtCore.Qt.Vertical)
self.gridLayout_2 = QtGui.QGridLayout(self.layoutWidget) self.vsplitter.setObjectName("vsplitter")
self.gridLayout_2.setContentsMargins(0, 0, 0, 0) self.canvasCtrlWidget = QtGui.QWidget(self.vsplitter)
self.gridLayout_2.setObjectName("gridLayout_2") self.canvasCtrlWidget.setObjectName("canvasCtrlWidget")
self.autoRangeBtn = QtGui.QPushButton(self.layoutWidget) self.gridLayout = QtGui.QGridLayout(self.canvasCtrlWidget)
self.gridLayout.setContentsMargins(0, 0, 0, 0)
self.gridLayout.setObjectName("gridLayout")
self.autoRangeBtn = QtGui.QPushButton(self.canvasCtrlWidget)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0) sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(1) sizePolicy.setVerticalStretch(1)
sizePolicy.setHeightForWidth(self.autoRangeBtn.sizePolicy().hasHeightForWidth()) sizePolicy.setHeightForWidth(self.autoRangeBtn.sizePolicy().hasHeightForWidth())
self.autoRangeBtn.setSizePolicy(sizePolicy) self.autoRangeBtn.setSizePolicy(sizePolicy)
self.autoRangeBtn.setObjectName("autoRangeBtn") self.autoRangeBtn.setObjectName("autoRangeBtn")
self.gridLayout_2.addWidget(self.autoRangeBtn, 2, 0, 1, 2) self.gridLayout.addWidget(self.autoRangeBtn, 0, 0, 1, 2)
self.horizontalLayout = QtGui.QHBoxLayout() self.horizontalLayout = QtGui.QHBoxLayout()
self.horizontalLayout.setSpacing(0) self.horizontalLayout.setSpacing(0)
self.horizontalLayout.setObjectName("horizontalLayout") self.horizontalLayout.setObjectName("horizontalLayout")
self.redirectCheck = QtGui.QCheckBox(self.layoutWidget) self.redirectCheck = QtGui.QCheckBox(self.canvasCtrlWidget)
self.redirectCheck.setObjectName("redirectCheck") self.redirectCheck.setObjectName("redirectCheck")
self.horizontalLayout.addWidget(self.redirectCheck) self.horizontalLayout.addWidget(self.redirectCheck)
self.redirectCombo = CanvasCombo(self.layoutWidget) self.redirectCombo = CanvasCombo(self.canvasCtrlWidget)
self.redirectCombo.setObjectName("redirectCombo") self.redirectCombo.setObjectName("redirectCombo")
self.horizontalLayout.addWidget(self.redirectCombo) self.horizontalLayout.addWidget(self.redirectCombo)
self.gridLayout_2.addLayout(self.horizontalLayout, 5, 0, 1, 2) self.gridLayout.addLayout(self.horizontalLayout, 1, 0, 1, 2)
self.itemList = TreeWidget(self.layoutWidget) self.itemList = TreeWidget(self.canvasCtrlWidget)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0) sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(100) sizePolicy.setVerticalStretch(100)
@ -54,21 +57,24 @@ class Ui_Form(object):
self.itemList.setHeaderHidden(True) self.itemList.setHeaderHidden(True)
self.itemList.setObjectName("itemList") self.itemList.setObjectName("itemList")
self.itemList.headerItem().setText(0, "1") self.itemList.headerItem().setText(0, "1")
self.gridLayout_2.addWidget(self.itemList, 6, 0, 1, 2) self.gridLayout.addWidget(self.itemList, 2, 0, 1, 2)
self.ctrlLayout = QtGui.QGridLayout() self.resetTransformsBtn = QtGui.QPushButton(self.canvasCtrlWidget)
self.ctrlLayout.setSpacing(0)
self.ctrlLayout.setObjectName("ctrlLayout")
self.gridLayout_2.addLayout(self.ctrlLayout, 10, 0, 1, 2)
self.resetTransformsBtn = QtGui.QPushButton(self.layoutWidget)
self.resetTransformsBtn.setObjectName("resetTransformsBtn") self.resetTransformsBtn.setObjectName("resetTransformsBtn")
self.gridLayout_2.addWidget(self.resetTransformsBtn, 7, 0, 1, 1) self.gridLayout.addWidget(self.resetTransformsBtn, 3, 0, 1, 2)
self.mirrorSelectionBtn = QtGui.QPushButton(self.layoutWidget) self.mirrorSelectionBtn = QtGui.QPushButton(self.canvasCtrlWidget)
self.mirrorSelectionBtn.setObjectName("mirrorSelectionBtn") self.mirrorSelectionBtn.setObjectName("mirrorSelectionBtn")
self.gridLayout_2.addWidget(self.mirrorSelectionBtn, 3, 0, 1, 1) self.gridLayout.addWidget(self.mirrorSelectionBtn, 4, 0, 1, 1)
self.reflectSelectionBtn = QtGui.QPushButton(self.layoutWidget) self.reflectSelectionBtn = QtGui.QPushButton(self.canvasCtrlWidget)
self.reflectSelectionBtn.setObjectName("reflectSelectionBtn") self.reflectSelectionBtn.setObjectName("reflectSelectionBtn")
self.gridLayout_2.addWidget(self.reflectSelectionBtn, 3, 1, 1, 1) self.gridLayout.addWidget(self.reflectSelectionBtn, 4, 1, 1, 1)
self.gridLayout.addWidget(self.splitter, 0, 0, 1, 1) self.canvasItemCtrl = QtGui.QWidget(self.vsplitter)
self.canvasItemCtrl.setObjectName("canvasItemCtrl")
self.ctrlLayout = QtGui.QGridLayout(self.canvasItemCtrl)
self.ctrlLayout.setContentsMargins(0, 0, 0, 0)
self.ctrlLayout.setSpacing(0)
self.ctrlLayout.setContentsMargins(0, 0, 0, 0)
self.ctrlLayout.setObjectName("ctrlLayout")
self.gridLayout_2.addWidget(self.splitter, 0, 0, 1, 1)
self.retranslateUi(Form) self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form) QtCore.QMetaObject.connectSlotsByName(Form)