From e88e3a4232e4b07ef50e7efa9faae0236f4f8930 Mon Sep 17 00:00:00 2001 From: Luke Campagnola Date: Wed, 13 Sep 2017 21:01:38 -0700 Subject: [PATCH 1/4] code cleanup --- pyqtgraph/canvas/Canvas.py | 135 +-------------------------------- pyqtgraph/canvas/CanvasItem.py | 56 +------------- 2 files changed, 3 insertions(+), 188 deletions(-) diff --git a/pyqtgraph/canvas/Canvas.py b/pyqtgraph/canvas/Canvas.py index 5b5ce2f7..a9f1d918 100644 --- a/pyqtgraph/canvas/Canvas.py +++ b/pyqtgraph/canvas/Canvas.py @@ -32,7 +32,6 @@ class Canvas(QtGui.QWidget): QtGui.QWidget.__init__(self, parent) self.ui = Ui_Form() self.ui.setupUi(self) - #self.view = self.ui.view self.view = ViewBox() self.ui.view.setCentralItem(self.view) self.itemList = self.ui.itemList @@ -49,9 +48,7 @@ class Canvas(QtGui.QWidget): self.redirect = None ## which canvas to redirect items to self.items = [] - #self.view.enableMouse() self.view.setAspectLocked(True) - #self.view.invertY() grid = GridItem() self.grid = CanvasItem(grid, name='Grid', movable=False) @@ -69,8 +66,6 @@ class Canvas(QtGui.QWidget): self.ui.itemList.sigItemMoved.connect(self.treeItemMoved) self.ui.itemList.itemSelectionChanged.connect(self.treeItemSelected) 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.redirectCombo.currentIndexChanged.connect(self.updateRedirect) self.multiSelectBox.sigRegionChanged.connect(self.multiSelectBoxChanged) @@ -88,21 +83,11 @@ class Canvas(QtGui.QWidget): self.ui.redirectCombo.setHostName(self.registeredName) self.menu = QtGui.QMenu() - #self.menu.setTitle("Image") remAct = QtGui.QAction("Remove item", self.menu) remAct.triggered.connect(self.removeClicked) self.menu.addAction(remAct) self.menu.remAct = remAct 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): self.resizeEvent() @@ -135,7 +120,6 @@ class Canvas(QtGui.QWidget): s = min(self.width(), max(100, min(200, self.width()*0.25))) s2 = self.width()-s self.ui.splitter.setSizes([s2, s]) - def updateRedirect(self, *args): ### Decide whether/where to redirect items and make it so @@ -154,7 +138,6 @@ class Canvas(QtGui.QWidget): self.reclaimItems() else: self.redirectItems(redirect) - def redirectItems(self, canvas): for i in self.items: @@ -171,12 +154,9 @@ class Canvas(QtGui.QWidget): else: parent.removeChild(li) canvas.addItem(i) - def reclaimItems(self): items = self.items - #self.items = {'Grid': items['Grid']} - #del items['Grid'] self.items = [self.grid] items.remove(self.grid) @@ -185,9 +165,6 @@ class Canvas(QtGui.QWidget): self.addItem(i) def treeItemChanged(self, item, col): - #gi = self.items.get(item.name, None) - #if gi is None: - #return try: citem = item.canvasItem() except AttributeError: @@ -203,25 +180,16 @@ class Canvas(QtGui.QWidget): def treeItemSelected(self): 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: - #self.selectWidget.hide() return multi = len(sel) > 1 for i in self.items: - #i.ctrlWidget().hide() ## updated the selected state of every item i.selectionChanged(i in sel, multi) if len(sel)==1: - #item = sel[0] - #item.ctrlWidget().show() self.multiSelectBox.hide() self.ui.mirrorSelectionBtn.hide() self.ui.reflectSelectionBtn.hide() @@ -229,14 +197,6 @@ class Canvas(QtGui.QWidget): elif len(sel) > 1: 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) def selectedItems(self): @@ -245,19 +205,9 @@ class Canvas(QtGui.QWidget): """ 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): li = item.listItem - #li = self.getListItem(item.name()) - #print "select", li self.itemList.setCurrentItem(li) - - def showMultiSelectBox(self): ## Get list of selected canvas items @@ -281,7 +231,6 @@ class Canvas(QtGui.QWidget): self.ui.mirrorSelectionBtn.show() self.ui.reflectSelectionBtn.show() self.ui.resetTransformsBtn.show() - #self.multiSelectBoxBase = self.multiSelectBox.getState().copy() def mirrorSelectionClicked(self): for ci in self.selectedItems(): @@ -312,7 +261,6 @@ class Canvas(QtGui.QWidget): ci.setTemporaryTransform(transform) ci.sigTransformChanged.emit(ci) - def addGraphicsItem(self, item, **opts): """Add a new GraphicsItem to the scene at pos. Common options are name, pos, scale, and z @@ -321,13 +269,11 @@ class Canvas(QtGui.QWidget): item._canvasItem = citem self.addItem(citem) return citem - def addGroup(self, name, **kargs): group = GroupCanvasItem(name=name) self.addItem(group, **kargs) return group - def addItem(self, citem): """ @@ -363,7 +309,6 @@ class Canvas(QtGui.QWidget): #name = newname ## find parent and add item to tree - #currentNode = self.itemList.invisibleRootItem() insertLocation = 0 #print "Inserting node:", name @@ -413,11 +358,7 @@ class Canvas(QtGui.QWidget): node.setCheckState(0, QtCore.Qt.Unchecked) node.name = name - #if citem.opts['parent'] != None: - ## insertLocation is incorrect in this case parent.insertChild(insertLocation, node) - #else: - #root.insertChild(insertLocation, node) citem.name = name citem.listItem = node @@ -435,36 +376,6 @@ class Canvas(QtGui.QWidget): if len(self.items) == 2: 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 def treeItemMoved(self, item, parent, index): @@ -481,31 +392,6 @@ class Canvas(QtGui.QWidget): for i in range(len(siblings)): item = siblings[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): listItem = item.listItem @@ -521,7 +407,6 @@ class Canvas(QtGui.QWidget): if isinstance(item, QtGui.QTreeWidgetItem): item = item.canvasItem() - if isinstance(item, CanvasItem): item.setCanvas(None) listItem = item.listItem @@ -559,15 +444,10 @@ class Canvas(QtGui.QWidget): def getListItem(self, name): return self.items[name] - #def scene(self): - #return self.view.scene() - def itemTransformChanged(self, item): - #self.emit(QtCore.SIGNAL('itemTransformChanged'), self, item) self.sigItemTransformChanged.emit(self, item) def itemTransformChangeFinished(self, item): - #self.emit(QtCore.SIGNAL('itemTransformChangeFinished'), self, item) self.sigItemTransformChangeFinished.emit(self, item) def itemListContextMenuEvent(self, ev): @@ -575,13 +455,13 @@ class Canvas(QtGui.QWidget): self.menu.popup(ev.globalPos()) def removeClicked(self): - #self.removeItem(self.menuItem) for item in self.selectedItems(): self.removeItem(item) self.menuItem = None import gc gc.collect() + class SelectBox(ROI): def __init__(self, scalable=False): #QtGui.QGraphicsRectItem.__init__(self, 0, 0, size[0], size[1]) @@ -593,14 +473,3 @@ class SelectBox(ROI): self.addScaleHandle([0, 0], center, lockAspect=True) self.addRotateHandle([0, 1], center) self.addRotateHandle([1, 0], center) - - - - - - - - - - - diff --git a/pyqtgraph/canvas/CanvasItem.py b/pyqtgraph/canvas/CanvasItem.py index a06235b2..bab89e89 100644 --- a/pyqtgraph/canvas/CanvasItem.py +++ b/pyqtgraph/canvas/CanvasItem.py @@ -87,14 +87,12 @@ class CanvasItem(QtCore.QObject): self.alphaSlider.valueChanged.connect(self.alphaChanged) self.alphaSlider.sliderPressed.connect(self.alphaPressed) self.alphaSlider.sliderReleased.connect(self.alphaReleased) - #self.canvas.sigSelectionChanged.connect(self.selectionChanged) self.resetTransformBtn.clicked.connect(self.resetTransformClicked) self.copyBtn.clicked.connect(self.copyClicked) self.pasteBtn.clicked.connect(self.pasteClicked) self.setMovable(self.opts['movable']) ## update gui to reflect this option - if 'transform' in self.opts: self.baseTransform = self.opts['transform'] else: @@ -114,7 +112,6 @@ class CanvasItem(QtCore.QObject): ## every CanvasItem implements its own individual selection box ## so that subclasses are free to make their own. self.selectBox = SelectBox(scalable=self.opts['scalable'], rotatable=self.opts['rotatable']) - #self.canvas.scene().addItem(self.selectBox) self.selectBox.hide() self.selectBox.setZValue(1e6) self.selectBox.sigRegionChanged.connect(self.selectBoxChanged) ## calls selectBoxMoved @@ -129,16 +126,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.userTransform = SRTTransform() ## stores the total transform of the object 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): self.opts['movable'] = m @@ -239,7 +227,6 @@ class CanvasItem(QtCore.QObject): # s=self.updateTransform() # self.setTranslate(-2*s['pos'][0], -2*s['pos'][1]) # self.selectBoxFromUser() - def hasUserTransform(self): #print self.userRotate, self.userTranslate @@ -255,7 +242,6 @@ class CanvasItem(QtCore.QObject): def isMovable(self): return self.opts['movable'] - def selectBoxMoved(self): """The selection box has moved; get its transformation information and pass to the graphics item""" self.userTransform = self.selectBox.getGlobalTransform(relativeTo=self.selectBoxBase) @@ -290,7 +276,6 @@ class CanvasItem(QtCore.QObject): self.userTransform.setScale(x, y) self.selectBoxFromUser() self.updateTransform() - def setTemporaryTransform(self, transform): self.tempTransform = transform @@ -302,21 +287,6 @@ class CanvasItem(QtCore.QObject): self.resetTemporaryTransform() 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): self.tempTransform = SRTTransform() ## don't use Transform.reset()--this transform might be used elsewhere. self.updateTransform() @@ -339,20 +309,13 @@ class CanvasItem(QtCore.QObject): def displayTransform(self, transform): """Updates transform numbers in the ctrl widget.""" - tr = transform.saveState() self.transformGui.translateLabel.setText("Translate: (%f, %f)" %(tr['pos'][0], tr['pos'][1])) self.transformGui.rotateLabel.setText("Rotate: %f degrees" %tr['angle']) 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): - #self.userRotate = 0 - #self.userTranslate = pg.Point(0,0) self.userTransform.reset() self.updateTransform() @@ -368,8 +331,6 @@ class CanvasItem(QtCore.QObject): def restoreTransform(self, tr): try: - #self.userTranslate = pg.Point(tr['trans']) - #self.userRotate = tr['rot'] self.userTransform = SRTTransform(tr) self.updateTransform() @@ -377,16 +338,11 @@ class CanvasItem(QtCore.QObject): self.sigTransformChanged.emit(self) self.sigTransformChangeFinished.emit(self) except: - #self.userTranslate = pg.Point([0,0]) - #self.userRotate = 0 self.userTransform = SRTTransform() debug.printExc("Failed to load transform:") - #print "set transform", self, self.userTranslate def saveTransform(self): """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() def selectBoxFromUser(self): @@ -404,7 +360,6 @@ class CanvasItem(QtCore.QObject): #self.selectBox.setAngle(self.userRotate) #self.selectBox.setPos([x2, y2]) self.selectBox.blockSignals(False) - def selectBoxToItem(self): """Move/scale the selection box so it fits the item's bounding rect. (assumes item is not rotated)""" @@ -424,11 +379,6 @@ class CanvasItem(QtCore.QObject): self.opts['z'] = z if z is not None: 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): """ @@ -456,16 +406,12 @@ class CanvasItem(QtCore.QObject): def hideSelectBox(self): self.selectBox.hide() - def selectBoxChanged(self): self.selectBoxMoved() - #self.updateTransform(self.selectBox) - #self.emit(QtCore.SIGNAL('transformChanged'), self) self.sigTransformChanged.emit(self) def selectBoxChangeFinished(self): - #self.emit(QtCore.SIGNAL('transformChangeFinished'), self) self.sigTransformChangeFinished.emit(self) def alphaPressed(self): From ee117fd957c1f001a089c1dc6733ce35fb4dff69 Mon Sep 17 00:00:00 2001 From: Luke Campagnola Date: Wed, 13 Sep 2017 21:02:58 -0700 Subject: [PATCH 2/4] Give CanvasItem alpha/setAlpha methods --- pyqtgraph/canvas/CanvasItem.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pyqtgraph/canvas/CanvasItem.py b/pyqtgraph/canvas/CanvasItem.py index bab89e89..eb6d0a61 100644 --- a/pyqtgraph/canvas/CanvasItem.py +++ b/pyqtgraph/canvas/CanvasItem.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +import numpy as np from ..Qt import QtGui, QtCore, QtSvg, QT_LIB from ..graphicsItems.ROI import ROI from .. import SRTTransform, ItemGroup @@ -239,6 +240,12 @@ class CanvasItem(QtCore.QObject): alpha = val / 1023. 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): return self.opts['movable'] From 65b5b6a7bc40a88e6eea75cbe488406f5861c1db Mon Sep 17 00:00:00 2001 From: Luke Campagnola Date: Wed, 13 Sep 2017 21:04:04 -0700 Subject: [PATCH 3/4] Add CanvasItem.saveState/restoreState --- pyqtgraph/canvas/Canvas.py | 9 +++++---- pyqtgraph/canvas/CanvasItem.py | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/pyqtgraph/canvas/Canvas.py b/pyqtgraph/canvas/Canvas.py index a9f1d918..2ebc2ba1 100644 --- a/pyqtgraph/canvas/Canvas.py +++ b/pyqtgraph/canvas/Canvas.py @@ -19,9 +19,11 @@ elif QT_LIB == 'PyQt5': import numpy as np from .. import debug import weakref +import gc from .CanvasManager import CanvasManager from .CanvasItem import CanvasItem, GroupCanvasItem + class Canvas(QtGui.QWidget): sigSelectionChanged = QtCore.Signal(object, object) @@ -417,25 +419,24 @@ class Canvas(QtGui.QWidget): ctrl = item.ctrlWidget() ctrl.hide() self.ui.ctrlLayout.removeWidget(ctrl) + ctrl.setParent(None) else: if hasattr(item, '_canvasItem'): self.removeItem(item._canvasItem) else: self.view.removeItem(item) - - ## disconnect signals, remove from list, etc.. + + gc.collect() def clear(self): while len(self.items) > 0: self.removeItem(self.items[0]) - def addToScene(self, item): self.view.addItem(item) def removeFromScene(self, item): self.view.removeItem(item) - def listItems(self): """Return a dictionary of name:item pairs""" diff --git a/pyqtgraph/canvas/CanvasItem.py b/pyqtgraph/canvas/CanvasItem.py index eb6d0a61..c406256c 100644 --- a/pyqtgraph/canvas/CanvasItem.py +++ b/pyqtgraph/canvas/CanvasItem.py @@ -453,6 +453,25 @@ class CanvasItem(QtCore.QObject): def isVisible(self): 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): """ From d8ffc21446d618c4464a10a738b7d4d7762bd58d Mon Sep 17 00:00:00 2001 From: Luke Campagnola Date: Wed, 13 Sep 2017 21:04:43 -0700 Subject: [PATCH 4/4] Refactor canvas ui to make it easier to embed / extend --- pyqtgraph/canvas/CanvasTemplate.ui | 176 +++++++++++----------- pyqtgraph/canvas/CanvasTemplate_pyqt.py | 63 ++++---- pyqtgraph/canvas/CanvasTemplate_pyqt5.py | 66 ++++---- pyqtgraph/canvas/CanvasTemplate_pyside.py | 66 ++++---- 4 files changed, 198 insertions(+), 173 deletions(-) diff --git a/pyqtgraph/canvas/CanvasTemplate.ui b/pyqtgraph/canvas/CanvasTemplate.ui index b05c11cd..bfdacf38 100644 --- a/pyqtgraph/canvas/CanvasTemplate.ui +++ b/pyqtgraph/canvas/CanvasTemplate.ui @@ -6,14 +6,14 @@ 0 0 - 490 - 414 + 821 + 578 Form - + 0 @@ -26,88 +26,96 @@ Qt::Horizontal - - - - - - - 0 - 1 - - - - Auto Range - - - - - - - 0 - - - - - Check to display all local items in a remote canvas. - - - Redirect - - - - - - - - - - - - - 0 - 100 - - - - true - - - - 1 + + + Qt::Vertical + + + + + + + + 0 + 1 + - - - - - - - 0 - - - - - - - Reset Transforms - - - - - - - Mirror Selection - - - - - - - MirrorXY - - - - + + Auto Range + + + + + + + 0 + + + + + Check to display all local items in a remote canvas. + + + Redirect + + + + + + + + + + + + + 0 + 100 + + + + true + + + + 1 + + + + + + + + Reset Transforms + + + + + + + Mirror Selection + + + + + + + MirrorXY + + + + + + + + + 0 + + + 0 + + + diff --git a/pyqtgraph/canvas/CanvasTemplate_pyqt.py b/pyqtgraph/canvas/CanvasTemplate_pyqt.py index b65ef465..3569c8e7 100644 --- a/pyqtgraph/canvas/CanvasTemplate_pyqt.py +++ b/pyqtgraph/canvas/CanvasTemplate_pyqt.py @@ -1,6 +1,6 @@ # -*- 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 # @@ -25,39 +25,42 @@ except AttributeError: class Ui_Form(object): def setupUi(self, Form): Form.setObjectName(_fromUtf8("Form")) - Form.resize(490, 414) - self.gridLayout = QtGui.QGridLayout(Form) - self.gridLayout.setMargin(0) - self.gridLayout.setSpacing(0) - self.gridLayout.setObjectName(_fromUtf8("gridLayout")) + Form.resize(821, 578) + self.gridLayout_2 = QtGui.QGridLayout(Form) + self.gridLayout_2.setMargin(0) + self.gridLayout_2.setSpacing(0) + self.gridLayout_2.setObjectName(_fromUtf8("gridLayout_2")) self.splitter = QtGui.QSplitter(Form) self.splitter.setOrientation(QtCore.Qt.Horizontal) self.splitter.setObjectName(_fromUtf8("splitter")) self.view = GraphicsView(self.splitter) self.view.setObjectName(_fromUtf8("view")) - self.layoutWidget = QtGui.QWidget(self.splitter) - self.layoutWidget.setObjectName(_fromUtf8("layoutWidget")) - self.gridLayout_2 = QtGui.QGridLayout(self.layoutWidget) - self.gridLayout_2.setObjectName(_fromUtf8("gridLayout_2")) - self.autoRangeBtn = QtGui.QPushButton(self.layoutWidget) + self.vsplitter = QtGui.QSplitter(self.splitter) + self.vsplitter.setOrientation(QtCore.Qt.Vertical) + self.vsplitter.setObjectName(_fromUtf8("vsplitter")) + self.canvasCtrlWidget = QtGui.QWidget(self.vsplitter) + 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.setHorizontalStretch(0) sizePolicy.setVerticalStretch(1) sizePolicy.setHeightForWidth(self.autoRangeBtn.sizePolicy().hasHeightForWidth()) self.autoRangeBtn.setSizePolicy(sizePolicy) 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.setSpacing(0) self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) - self.redirectCheck = QtGui.QCheckBox(self.layoutWidget) + self.redirectCheck = QtGui.QCheckBox(self.canvasCtrlWidget) self.redirectCheck.setObjectName(_fromUtf8("redirectCheck")) self.horizontalLayout.addWidget(self.redirectCheck) - self.redirectCombo = CanvasCombo(self.layoutWidget) + self.redirectCombo = CanvasCombo(self.canvasCtrlWidget) self.redirectCombo.setObjectName(_fromUtf8("redirectCombo")) self.horizontalLayout.addWidget(self.redirectCombo) - self.gridLayout_2.addLayout(self.horizontalLayout, 5, 0, 1, 2) - self.itemList = TreeWidget(self.layoutWidget) + self.gridLayout.addLayout(self.horizontalLayout, 1, 0, 1, 2) + self.itemList = TreeWidget(self.canvasCtrlWidget) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(100) @@ -66,21 +69,23 @@ class Ui_Form(object): self.itemList.setHeaderHidden(True) self.itemList.setObjectName(_fromUtf8("itemList")) self.itemList.headerItem().setText(0, _fromUtf8("1")) - self.gridLayout_2.addWidget(self.itemList, 6, 0, 1, 2) - self.ctrlLayout = QtGui.QGridLayout() + self.gridLayout.addWidget(self.itemList, 2, 0, 1, 2) + 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.setObjectName(_fromUtf8("ctrlLayout")) - self.gridLayout_2.addLayout(self.ctrlLayout, 10, 0, 1, 2) - 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.gridLayout_2.addWidget(self.splitter, 0, 0, 1, 1) self.retranslateUi(Form) QtCore.QMetaObject.connectSlotsByName(Form) diff --git a/pyqtgraph/canvas/CanvasTemplate_pyqt5.py b/pyqtgraph/canvas/CanvasTemplate_pyqt5.py index 20f5e339..03310d39 100644 --- a/pyqtgraph/canvas/CanvasTemplate_pyqt5.py +++ b/pyqtgraph/canvas/CanvasTemplate_pyqt5.py @@ -1,8 +1,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! @@ -11,39 +11,43 @@ from PyQt5 import QtCore, QtGui, QtWidgets class Ui_Form(object): def setupUi(self, Form): Form.setObjectName("Form") - Form.resize(490, 414) - self.gridLayout = QtWidgets.QGridLayout(Form) - self.gridLayout.setContentsMargins(0, 0, 0, 0) - self.gridLayout.setSpacing(0) - self.gridLayout.setObjectName("gridLayout") + Form.resize(821, 578) + self.gridLayout_2 = QtWidgets.QGridLayout(Form) + self.gridLayout_2.setContentsMargins(0, 0, 0, 0) + self.gridLayout_2.setSpacing(0) + self.gridLayout_2.setObjectName("gridLayout_2") self.splitter = QtWidgets.QSplitter(Form) self.splitter.setOrientation(QtCore.Qt.Horizontal) self.splitter.setObjectName("splitter") self.view = GraphicsView(self.splitter) self.view.setObjectName("view") - self.layoutWidget = QtWidgets.QWidget(self.splitter) - self.layoutWidget.setObjectName("layoutWidget") - self.gridLayout_2 = QtWidgets.QGridLayout(self.layoutWidget) - self.gridLayout_2.setObjectName("gridLayout_2") - self.autoRangeBtn = QtWidgets.QPushButton(self.layoutWidget) + self.vsplitter = QtWidgets.QSplitter(self.splitter) + self.vsplitter.setOrientation(QtCore.Qt.Vertical) + self.vsplitter.setObjectName("vsplitter") + self.canvasCtrlWidget = QtWidgets.QWidget(self.vsplitter) + 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.setHorizontalStretch(0) sizePolicy.setVerticalStretch(1) sizePolicy.setHeightForWidth(self.autoRangeBtn.sizePolicy().hasHeightForWidth()) self.autoRangeBtn.setSizePolicy(sizePolicy) 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.setSpacing(0) self.horizontalLayout.setObjectName("horizontalLayout") - self.redirectCheck = QtWidgets.QCheckBox(self.layoutWidget) + self.redirectCheck = QtWidgets.QCheckBox(self.canvasCtrlWidget) self.redirectCheck.setObjectName("redirectCheck") self.horizontalLayout.addWidget(self.redirectCheck) - self.redirectCombo = CanvasCombo(self.layoutWidget) + self.redirectCombo = CanvasCombo(self.canvasCtrlWidget) self.redirectCombo.setObjectName("redirectCombo") self.horizontalLayout.addWidget(self.redirectCombo) - self.gridLayout_2.addLayout(self.horizontalLayout, 5, 0, 1, 2) - self.itemList = TreeWidget(self.layoutWidget) + self.gridLayout.addLayout(self.horizontalLayout, 1, 0, 1, 2) + self.itemList = TreeWidget(self.canvasCtrlWidget) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(100) @@ -52,21 +56,23 @@ class Ui_Form(object): self.itemList.setHeaderHidden(True) self.itemList.setObjectName("itemList") self.itemList.headerItem().setText(0, "1") - self.gridLayout_2.addWidget(self.itemList, 6, 0, 1, 2) - self.ctrlLayout = QtWidgets.QGridLayout() + self.gridLayout.addWidget(self.itemList, 2, 0, 1, 2) + 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.setObjectName("ctrlLayout") - self.gridLayout_2.addLayout(self.ctrlLayout, 10, 0, 1, 2) - 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.gridLayout_2.addWidget(self.splitter, 0, 0, 1, 1) self.retranslateUi(Form) QtCore.QMetaObject.connectSlotsByName(Form) diff --git a/pyqtgraph/canvas/CanvasTemplate_pyside.py b/pyqtgraph/canvas/CanvasTemplate_pyside.py index b0e05a07..570d5bd1 100644 --- a/pyqtgraph/canvas/CanvasTemplate_pyside.py +++ b/pyqtgraph/canvas/CanvasTemplate_pyside.py @@ -1,8 +1,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 # # WARNING! All changes made in this file will be lost! @@ -12,40 +12,43 @@ from PySide import QtCore, QtGui class Ui_Form(object): def setupUi(self, Form): Form.setObjectName("Form") - Form.resize(490, 414) - self.gridLayout = QtGui.QGridLayout(Form) - self.gridLayout.setContentsMargins(0, 0, 0, 0) - self.gridLayout.setSpacing(0) - self.gridLayout.setObjectName("gridLayout") + Form.resize(821, 578) + self.gridLayout_2 = QtGui.QGridLayout(Form) + self.gridLayout_2.setContentsMargins(0, 0, 0, 0) + self.gridLayout_2.setSpacing(0) + self.gridLayout_2.setObjectName("gridLayout_2") self.splitter = QtGui.QSplitter(Form) self.splitter.setOrientation(QtCore.Qt.Horizontal) self.splitter.setObjectName("splitter") self.view = GraphicsView(self.splitter) self.view.setObjectName("view") - self.layoutWidget = QtGui.QWidget(self.splitter) - self.layoutWidget.setObjectName("layoutWidget") - self.gridLayout_2 = QtGui.QGridLayout(self.layoutWidget) - self.gridLayout_2.setContentsMargins(0, 0, 0, 0) - self.gridLayout_2.setObjectName("gridLayout_2") - self.autoRangeBtn = QtGui.QPushButton(self.layoutWidget) + self.vsplitter = QtGui.QSplitter(self.splitter) + self.vsplitter.setOrientation(QtCore.Qt.Vertical) + self.vsplitter.setObjectName("vsplitter") + self.canvasCtrlWidget = QtGui.QWidget(self.vsplitter) + self.canvasCtrlWidget.setObjectName("canvasCtrlWidget") + 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.setHorizontalStretch(0) sizePolicy.setVerticalStretch(1) sizePolicy.setHeightForWidth(self.autoRangeBtn.sizePolicy().hasHeightForWidth()) self.autoRangeBtn.setSizePolicy(sizePolicy) 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.setSpacing(0) self.horizontalLayout.setObjectName("horizontalLayout") - self.redirectCheck = QtGui.QCheckBox(self.layoutWidget) + self.redirectCheck = QtGui.QCheckBox(self.canvasCtrlWidget) self.redirectCheck.setObjectName("redirectCheck") self.horizontalLayout.addWidget(self.redirectCheck) - self.redirectCombo = CanvasCombo(self.layoutWidget) + self.redirectCombo = CanvasCombo(self.canvasCtrlWidget) self.redirectCombo.setObjectName("redirectCombo") self.horizontalLayout.addWidget(self.redirectCombo) - self.gridLayout_2.addLayout(self.horizontalLayout, 5, 0, 1, 2) - self.itemList = TreeWidget(self.layoutWidget) + self.gridLayout.addLayout(self.horizontalLayout, 1, 0, 1, 2) + self.itemList = TreeWidget(self.canvasCtrlWidget) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(100) @@ -54,21 +57,24 @@ class Ui_Form(object): self.itemList.setHeaderHidden(True) self.itemList.setObjectName("itemList") self.itemList.headerItem().setText(0, "1") - self.gridLayout_2.addWidget(self.itemList, 6, 0, 1, 2) - self.ctrlLayout = QtGui.QGridLayout() - 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.gridLayout.addWidget(self.itemList, 2, 0, 1, 2) + self.resetTransformsBtn = QtGui.QPushButton(self.canvasCtrlWidget) self.resetTransformsBtn.setObjectName("resetTransformsBtn") - self.gridLayout_2.addWidget(self.resetTransformsBtn, 7, 0, 1, 1) - self.mirrorSelectionBtn = QtGui.QPushButton(self.layoutWidget) + self.gridLayout.addWidget(self.resetTransformsBtn, 3, 0, 1, 2) + self.mirrorSelectionBtn = QtGui.QPushButton(self.canvasCtrlWidget) self.mirrorSelectionBtn.setObjectName("mirrorSelectionBtn") - self.gridLayout_2.addWidget(self.mirrorSelectionBtn, 3, 0, 1, 1) - self.reflectSelectionBtn = QtGui.QPushButton(self.layoutWidget) + self.gridLayout.addWidget(self.mirrorSelectionBtn, 4, 0, 1, 1) + self.reflectSelectionBtn = QtGui.QPushButton(self.canvasCtrlWidget) self.reflectSelectionBtn.setObjectName("reflectSelectionBtn") - self.gridLayout_2.addWidget(self.reflectSelectionBtn, 3, 1, 1, 1) - self.gridLayout.addWidget(self.splitter, 0, 0, 1, 1) + self.gridLayout.addWidget(self.reflectSelectionBtn, 4, 1, 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) QtCore.QMetaObject.connectSlotsByName(Form)