Esempio n. 1
0
 def mouseReleaseEvent(self, event):
     if not self.show_reticle and event.button() == Qt.LeftButton:
         return
     if event.button() == Qt.LeftButton:
         if self.bbox_label is not None:
             self.end_pt = event.pos()
             rect = self.pt2rect(self.start_pt, self.end_pt)
             if rect.width() > 5 and rect.height() > 5:
                 if self.is_new_tube:
                     if self.bboxes['current_tube'] is not None:
                         self.bboxes['other_tubes'].append(
                             self.bboxes['current_tube'])
                     self.is_new_tube = False
                 bbox = BoundingBox.from_qrect(rect, self.bbox_label, 1)
                 self.bboxes['current_tube'] = bbox
                 self.bbox_added.emit(self.proj_to_real_img(bbox))
         self.update()
     elif event.button() == Qt.RightButton:
         if not self.mouse_down:
             bbox = self.bboxes['current_tube']
             if (bbox is not None and
                     bbox.contain(event.pos().x(), event.pos().y())):
                 self.bboxes['current_tube'] = None
                 self.bbox_deleted.emit()
             self.update()
     self.mouse_down = False
Esempio n. 2
0
 def display(self, pixmap):
     self.scale_ratio = max(pixmap.width() / self.width(),
                            pixmap.height() / self.height())
     scaled_pixmap = pixmap.scaled(self.width() - 2, self.height() - 2,
                                   Qt.KeepAspectRatio)
     x = int((self.width() - scaled_pixmap.width()) / 2)
     y = int((self.height() - scaled_pixmap.height()) / 2)
     self.img_region = BoundingBox.from_qrect(
         QRect(QPoint(x, y), scaled_pixmap.size()))
     self.setPixmap(scaled_pixmap)
     self.update()