def _redraw_label(self):
if self.label is not None:
self.viewwidget.removeItem(self.label)
cos_th = np.cos(self.angle() / 180. * np.pi)
sin_th = np.sin(self.angle() / 180. * np.pi)
text_pos = self.position\
+ [self.radius * cos_th, self.radius * sin_th]
if cos_th > 0 and sin_th > 0:
my_anchor = (0, 1)
elif cos_th > 0 and sin_th < 0:
my_anchor = (0, 0)
elif cos_th < 0 and sin_th < 0:
my_anchor = (1, 0)
else:
my_anchor = (1, 1)
# Updating the position of the circleROI origin in case it has been rotated.
# It is important for finish=False so that this action does not call this
# _redraw_label method recursively
self.setPos(self.position + self.get_marker_offset(), finish=False)
my_color = self.color
if self.selected:
my_color = self.selectcolor
self.label = pg.TextItem(text=self.poi.get_name(),
anchor=my_anchor,
color=my_color
)
self.label.setPos(text_pos[0], text_pos[1])
self.viewwidget.addItem(self.label)
评论列表
文章目录