Exemplo n.º 1
0
 def __init__(self, parent=None, allowTransforms=True, hideCtrl=False, name=None):
     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
     self.itemList.setSelectionMode(self.itemList.ExtendedSelection)
     self.allowTransforms = allowTransforms
     self.multiSelectBox = SelectBox()
     self.view.addItem(self.multiSelectBox)
     self.multiSelectBox.hide()
     self.multiSelectBox.setZValue(1e6)
     self.ui.mirrorSelectionBtn.hide()
     self.ui.reflectSelectionBtn.hide()
     self.ui.resetTransformsBtn.hide()
     
     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)
     self.addItem(self.grid)
     
     self.hideBtn = QtGui.QPushButton('>', self)
     self.hideBtn.setFixedWidth(20)
     self.hideBtn.setFixedHeight(20)
     self.ctrlSize = 200
     self.sizeApplied = False
     self.hideBtn.clicked.connect(self.hideBtnClicked)
     self.ui.splitter.splitterMoved.connect(self.splitterMoved)
     
     self.ui.itemList.itemChanged.connect(self.treeItemChanged)
     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)
     self.multiSelectBox.sigRegionChangeFinished.connect(self.multiSelectBoxChangeFinished)
     self.ui.mirrorSelectionBtn.clicked.connect(self.mirrorSelectionClicked)
     self.ui.reflectSelectionBtn.clicked.connect(self.reflectSelectionClicked)
     self.ui.resetTransformsBtn.clicked.connect(self.resetTransformsClicked)
     
     self.resizeEvent()
     if hideCtrl:
         self.hideBtnClicked()
         
     if name is not None:
         self.registeredName = CanvasManager.instance().registerCanvas(self, name)
         self.ui.redirectCombo.setHostName(self.registeredName)
Exemplo n.º 2
0
 def __init__(self, parent=None, allowTransforms=True, hideCtrl=False, name=None):
     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
     self.itemList.setSelectionMode(self.itemList.ExtendedSelection)
     self.allowTransforms = allowTransforms
     self.multiSelectBox = SelectBox()
     self.view.addItem(self.multiSelectBox)
     self.multiSelectBox.hide()
     self.multiSelectBox.setZValue(1e6)
     self.ui.mirrorSelectionBtn.hide()
     self.ui.reflectSelectionBtn.hide()
     self.ui.resetTransformsBtn.hide()
     
     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)
     self.addItem(self.grid)
     
     self.hideBtn = QtGui.QPushButton('>', self)
     self.hideBtn.setFixedWidth(20)
     self.hideBtn.setFixedHeight(20)
     self.ctrlSize = 200
     self.sizeApplied = False
     self.hideBtn.clicked.connect(self.hideBtnClicked)
     self.ui.splitter.splitterMoved.connect(self.splitterMoved)
     
     self.ui.itemList.itemChanged.connect(self.treeItemChanged)
     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)
     self.multiSelectBox.sigRegionChangeFinished.connect(self.multiSelectBoxChangeFinished)
     self.ui.mirrorSelectionBtn.clicked.connect(self.mirrorSelectionClicked)
     self.ui.reflectSelectionBtn.clicked.connect(self.reflectSelectionClicked)
     self.ui.resetTransformsBtn.clicked.connect(self.resetTransformsClicked)
     
     self.resizeEvent()
     if hideCtrl:
         self.hideBtnClicked()
         
     if name is not None:
         self.registeredName = CanvasManager.instance().registerCanvas(self, name)
         self.ui.redirectCombo.setHostName(self.registeredName)
Exemplo n.º 3
0
 def updateRedirect(self, *args):
     ### Decide whether/where to redirect items and make it so
     cname = str(self.ui.redirectCombo.currentText())
     man = CanvasManager.instance()
     if self.ui.redirectCheck.isChecked() and cname != '':
         redirect = man.getCanvas(cname)
     else:
         redirect = None
         
     if self.redirect is redirect:
         return
         
     self.redirect = redirect
     if redirect is None:
         self.reclaimItems()
     else:
         self.redirectItems(redirect)
Exemplo n.º 4
0
 def updateRedirect(self, *args):
     ### Decide whether/where to redirect items and make it so
     cname = str(self.ui.redirectCombo.currentText())
     man = CanvasManager.instance()
     if self.ui.redirectCheck.isChecked() and cname != '':
         redirect = man.getCanvas(cname)
     else:
         redirect = None
         
     if self.redirect is redirect:
         return
         
     self.redirect = redirect
     if redirect is None:
         self.reclaimItems()
     else:
         self.redirectItems(redirect)