Пример #1
0
    def update_anchors(self):
        points, labels = self.master.get_anchors()
        if points is None:
            return
        r = self.scaled_radius * np.max(np.linalg.norm(points, axis=1))
        if self.anchor_items is None:
            self.anchor_items = []
            for point, label in zip(points, labels):
                anchor = AnchorItem(line=QLineF(0, 0, *point))
                anchor._label.setToolTip(f"<b>{label}</b>")
                label = label[:MAX_LABEL_LEN - 3] + "..." if len(
                    label) > MAX_LABEL_LEN else label
                anchor.setText(label)
                anchor.setFont(self.parameter_setter.anchor_font)

                visible = self.always_show_axes or np.linalg.norm(point) > r
                anchor.setVisible(visible)
                anchor.setPen(pg.mkPen((100, 100, 100)))
                self.plot_widget.addItem(anchor)
                self.anchor_items.append(anchor)
        else:
            for anchor, point, label in zip(self.anchor_items, points, labels):
                anchor.setLine(QLineF(0, 0, *point))
                visible = self.always_show_axes or np.linalg.norm(point) > r
                anchor.setVisible(visible)
                anchor.setFont(self.parameter_setter.anchor_font)
Пример #2
0
 def update_anchors(self):
     points, labels = self.master.get_anchors()
     if points is None:
         return
     r = self.scaled_radius
     if self.anchor_items is None:
         self.anchor_items = []
         for point, label in zip(points, labels):
             anchor = AnchorItem(line=QLineF(0, 0, *point), text=label)
             anchor.setVisible(np.linalg.norm(point) > r)
             anchor.setPen(pg.mkPen((100, 100, 100)))
             anchor.setFont(self.parameter_setter.anchor_font)
             self.plot_widget.addItem(anchor)
             self.anchor_items.append(anchor)
     else:
         for anchor, point, label in zip(self.anchor_items, points, labels):
             anchor.setLine(QLineF(0, 0, *point))
             anchor.setText(label)
             anchor.setVisible(np.linalg.norm(point) > r)
             anchor.setFont(self.parameter_setter.anchor_font)