def objectSavePath(self): """ TOWRITE :rtype: `QPainterPath`_ """ s = self.scale() # qreal trans = QTransform() trans.rotate(self.rotation()) trans.scale(s, s) return trans.map(self.normalPath)
def objectSavePath(self): """ TOWRITE :rtype: `QPainterPath`_ """ s = self.scale() # qreal trans = QTransform() trans.rotate(self.rotation()) trans.scale(s, s) return trans.map(normalPath)
def objectSavePath(self): """ TOWRITE :rtype: `QPainterPath`_ """ closedPath = self.normalPath # QPainterPath closedPath.closeSubpath() s = self.scale() # qreal trans = QTransform() trans.rotate(self.rotation()) trans.scale(s, s) return trans.map(closedPath)
def objectSavePath(self): """ TOWRITE :rtype: `QPainterPath`_ """ closedPath = normalPath # QPainterPath closedPath.closeSubpath() s = self.scale() # qreal trans = QTransform() trans.rotate(self.rotation()) trans.scale(s, s) return trans.map(closedPath)
def subPathList(self): """ TOWRITE :rtype: QList<QPainterPath> """ s = self.scale() # qreal trans = QTransform() trans.rotate(self.rotation()) trans.scale(s, s) ## QList<QPainterPath> pathList; pathList = [] path = self.objTextPath # QPainterPath element = QPainterPath.Element pathMoves = [] # QList<int> numMoves = 0 # int for i in range(0, path.elementCount()): # for(int i = 0; i < path.elementCount(); i++) element = path.elementAt(i) if element.isMoveTo(): pathMoves.append(i) # pathMoves << i; numMoves += 1 # numMoves++; pathMoves.append(path.elementCount()) # pathMoves << path.elementCount(); for p in range(0, len(pathMoves) - 1): # for(int p = 0; p < pathMoves.size()-1 && p < numMoves; p++) if not (p < numMoves): break subPath = QPainterPath() for i in range(pathMoves[p], pathMoves[p + 1]): # for(int i = pathMoves.value(p); i < pathMoves.value(p+1); i++) element = path.elementAt(i) if element.isMoveTo(): subPath.moveTo(element.x, element.y) elif element.isLineTo(): subPath.lineTo(element.x, element.y) elif element.isCurveTo(): subPath.cubicTo(path.elementAt(i).x, path.elementAt(i).y, # control point 1 path.elementAt(i + 1).x, path.elementAt(i + 1).y, # control point 2 path.elementAt(i + 2).x, path.elementAt(i + 2).y) # end point pathList.append(trans.map(subPath)) return pathList
def bbox(self): """ Get the bounding rect of a AREF. Returns bbox: the Rect which indicates the bbox of current gds element or none if failed to calculate the bbox. """ if self.refer_to is None or self.pts is None or self.row <= 0 or self.col <= 0 or len(self.pts) != 3: return None row_pitch_x = (self.pts[2].x - self.pts[0].x) / self.row row_pitch_y = (self.pts[2].y - self.pts[0].y) / self.row col_pitch_x = (self.pts[1].x - self.pts[0].x) / self.col col_pitch_y = (self.pts[1].y - self.pts[0].y) / self.col ref_bbox = self.refer_to.bbox() if ref_bbox is None: return None rect1 = QRect(ref_bbox.x, ref_bbox.y, ref_bbox.width, ref_bbox.height) reflect_transform = QTransform() if self.reflect is True: reflect_transform.scale(1, -1) mag_transform = QTransform().scale(self.mag, self.mag) rotate_transform = QTransform().rotate(self.angle) shift_transforms = [QTransform().translate(self.pts[0].x, self.pts[0].y), QTransform().translate(self.pts[0].x + col_pitch_x * (self.col-1), self.pts[0].y + col_pitch_y * (self.col-1)), QTransform().translate(self.pts[0].x + row_pitch_x * (self.row-1), self.pts[0].y + row_pitch_y * (self.row-1)), QTransform().translate(self.pts[0].x + row_pitch_x * (self.row-1) + col_pitch_x * (self.col-1), self.pts[0].y + row_pitch_y * (self.row-1) + col_pitch_y * (self.col-1))] llx = lly = GDS_MAX_INT urx = ury = GDS_MIN_INT for shift in shift_transforms: transform = reflect_transform*mag_transform*rotate_transform*shift map_rect = transform.mapRect(rect1) if map_rect.x() < llx: llx = map_rect.x() if map_rect.y() < lly: lly = map_rect.y() if map_rect.x() + map_rect.width() > urx: urx = map_rect.x() + map_rect.width() if map_rect.y() + map_rect.height() > ury: ury = map_rect.y() + map_rect.height() return BBox(llx, lly, urx - llx, ury - lly)
def subPathList(self): """ TOWRITE :rtype: QList<QPainterPath> """ s = self.scale() # qreal trans = QTransform() trans.rotate(self.rotation()) trans.scale(s, s) ## QList<QPainterPath> pathList; pathList = [] path = objTextPath # QPainterPath element = QPainterPath.Element pathMoves = [] # QList<int> numMoves = 0 # int for i in range(0, path.elementCount()): # for(int i = 0; i < path.elementCount(); i++) element = path.elementAt(i) if element.isMoveTo(): pathMoves.append(i) # pathMoves << i; numMoves += 1 # numMoves++; pathMoves.append(path.elementCount()) # pathMoves << path.elementCount(); for p in range(0, pathMoves.size() - 1 and numMoves): # for(int p = 0; p < pathMoves.size()-1 && p < numMoves; p++) subPath = QPainterPath() for i in range(pathMoves.value(p), pathMoves.value(p + 1)): # for(int i = pathMoves.value(p); i < pathMoves.value(p+1); i++) element = path.elementAt(i) if element.isMoveTo(): subPath.moveTo(element.x, element.y) elif element.isLineTo(): subPath.lineTo(element.x, element.y) elif element.isCurveTo(): subPath.cubicTo(path.elementAt(i).x, path.elementAt(i).y, # control point 1 path.elementAt(i + 1).x, path.elementAt(i + 1).y, # control point 2 path.elementAt(i + 2).x, path.elementAt(i + 2).y) # end point pathList.append(trans.map(subPath)) return pathList
def objectSavePath(self): """ TOWRITE :rtype: `QPainterPath`_ """ path = QPainterPath() r = self.rect() # QRectF path.arcMoveTo(r, 0) path.arcTo(r, 0, 360) s = self.scale() # qreal trans = QTransform() trans.rotate(self.rotation()) trans.scale(s, s) return trans.map(path)
def objectSavePath(self): """ TOWRITE :rtype: `QPainterPath`_ """ path = QPainterPath() r = self.rect() # QRectF path.arcMoveTo(r, 0) path.arcTo(r, 0, 360) s = self.scale() # qreal trans = QTransform() trans.rotate(self.rotation()) trans.scale(s, s) return trans.map(path)
def objectSavePath(self): """ TOWRITE :rtype: `QPainterPath`_ """ path = QPainterPath() r = self.rect() # QRectF path.moveTo(r.bottomLeft()) path.lineTo(r.bottomRight()) path.lineTo(r.topRight()) path.lineTo(r.topLeft()) path.lineTo(r.bottomLeft()) s = self.scale() # qreal trans = QTransform() trans.rotate(self.rotation()) trans.scale(s, s) return trans.map(path)
def objectSavePath(self): """ TOWRITE :rtype: `QPainterPath`_ """ path = QPainterPath() r = self.rect() # QRectF path.moveTo(r.bottomLeft()) path.lineTo(r.bottomRight()) path.lineTo(r.topRight()) path.lineTo(r.topLeft()) path.lineTo(r.bottomLeft()) s = self.scale() # qreal trans = QTransform() trans.rotate(self.rotation()) trans.scale(s, s) return trans.map(path)
def paintEvent(self, event): #mtx = self.mtx mtx = QTransform() mtx.rotate(self.mrotation) mtx.scale(self.mscale.x(), self.mscale.y()) mtx.translate(self.mtranslate.x(), self.mtranslate.y()) eyepos = QPointF(self.epx, self.dof) ppoi = QPointF(self.ppx, self.ppy) point = QRectF(0.0,0.0,0.05,0.05); tpoi = mtx.map(ppoi) teyepos = mtx.map(eyepos) evec = QVector2D(tpoi - teyepos).normalized() pts = find_points(float2(tpoi.x(),tpoi.y()), float2(evec.x(), evec.y())) print pts qp = QtGui.QPainter() qp.begin(self) qp.scale(self.width()/5.0,self.height()/5.0) qp.translate(2.5,2.5) #draw voxel bounds qp.drawRect(QRectF(0.0,0.0,1.0,1.0)) #qp.transform(mtx) #draw eyepos point.moveTo(mtx.map(eyepos)) qp.fillRect(point, QColor("black")) point.moveTo(mtx.map(ppoi)) qp.fillRect(point, QColor("grey")) qp.setPen(QColor("cyan")) qp.drawLine(mtx.map(QLineF(-0.5,0.0,1.5,0.0))) qp.setPen(QColor("blue")) qp.drawLine(mtx.map(QLineF(-0.0,0.0,1.0,0.0))) qp.setPen(QColor("lime")) qp.drawLine(QLineF(eyepos,ppoi)) qp.setPen(QColor("green")) qp.drawLine(QLineF(teyepos,tpoi)) qp.setPen(QColor("orange")) qp.drawLine(QLineF(pts['x'],pts['y'],pts['z'], pts['w'])) point.moveTo(QPointF(pts['x'],pts['y'])) qp.fillRect(point, QColor("red")) point.moveTo(QPointF(pts['z'],pts['w'])) qp.fillRect(point, QColor("pink")) qp.end()
def bbox(self): """ Get the bounding rect of a SREF. Returns bbox: the BBox which indicates the bbox of current gds element or none if failed to calculate the bbox. """ if self.refer_to is None or self.pt is None: return None ref_bbox = self.refer_to.bbox() if ref_bbox is None: return None reflect_transform = QTransform() if self.reflect is True: reflect_transform.scale(1, -1) mag_transform = QTransform().scale(self.mag, self.mag) rotate_transform = QTransform().rotate(self.angle) shift_transform = QTransform().translate(self.pt.x, self.pt.y) transform = reflect_transform * mag_transform * rotate_transform * shift_transform rect = QRect(ref_bbox.x, ref_bbox.y, ref_bbox.width, ref_bbox.height) rect2 = transform.mapRect(rect) return BBox(rect2.x(), rect2.y(), rect2.width(), rect2.height())