def _mapTransform(self, obj, tr): # convert to a type that can be mapped retType = None if isinstance(obj, (tuple, list)): retType = type(obj) if np.isscalar(obj[0]): if len(obj) == 2: obj = Qt.QPointF(*obj) elif len(obj) == 3: obj = Qt.QVector3D(*obj) else: raise TypeError("Cannot map %s of length %d." % (type(obj).__name__, len(obj))) elif isinstance(obj[0], np.ndarray): obj = np.concatenate([x[np.newaxis, ...] for x in obj]) else: raise Exception('Cannot map--object of type %s ' % str(type(obj[0]))) if isinstance(obj, Qt.QPointF): ret = tr.map(obj) if retType is not None: return retType([ret.x(), ret.y()]) return ret elif isinstance(obj, Qt.QVector3D): ret = tr.map(obj) if retType is not None: return retType([ret.x(), ret.y(), ret.z()]) return ret elif isinstance(obj, np.ndarray): # m = np.array(tr.copyDataTo()).reshape(4,4) # m1 = m[:2,:2, np.newaxis] # obj = obj[np.newaxis,...] # m2 = (m1*obj).sum(axis=0) # m2 += m[:2,3,np.newaxis] m2 = pg.transformCoordinates(tr, obj) return m2 else: raise Exception('Cannot map--object of type %s ' % str(type(obj)))
def listPoints(self): pts = self.localPoints() tr = self.viewTransform() if tr is None: return [] return pg.transformCoordinates(tr, pts, transpose=True)