예제 #1
0
파일: floor_plan.py 프로젝트: hibtc/madgui
 def axis_arrow(self, label, x0, x1, arrow_size):
     path = arrow(x0, x1, arrow_size)
     if not path:
         return QPainterPath()
     plan = self.plan
     font = QFont(plan.font())
     font.setPointSize(14)
     metr = QFontMetrics(font)
     rect = metr.boundingRect(label)
     rect.setHeight(metr.xHeight())
     tran = self.deviceTransform(self.plan.viewportTransform()).inverted()[0]
     size = tran.mapRect(QRectF(rect)).size()
     w, h = size.width(), size.height()
     dir_ = (x1 - x0) / np.linalg.norm(x1 - x0)
     offs = [-w/2, +h/2] + dir_ * max(w, h)
     path.addText(QPointF(*(x1 + offs)), font, label)
     return path
예제 #2
0
 def axis_arrow(self, label, x0, x1, arrow_size):
     path = arrow(x0, x1, arrow_size)
     if not path:
         return QPainterPath()
     plan = self.plan
     font = QFont(plan.font())
     font.setPointSize(14)
     metr = QFontMetrics(font)
     rect = metr.boundingRect(label)
     rect.setHeight(metr.xHeight())
     tran = self.deviceTransform(
         self.plan.viewportTransform()).inverted()[0]
     size = tran.mapRect(QRectF(rect)).size()
     w, h = size.width(), size.height()
     dir_ = (x1 - x0) / np.linalg.norm(x1 - x0)
     offs = [-w / 2, +h / 2] + dir_ * max(w, h)
     path.addText(QPointF(*(x1 + offs)), font, label)
     return path