Exemplo n.º 1
0
    def mouseDoubleClickEvent(self, event):
        if self.DialogOpened is True:
            #self.BringWindowToFront()
            return

        if self.InsideRect is True:
            self.DialogOpened = True
            self.Dialog = AppImgDialog(self, self.LastRectHover, 0)
            self.Dialog.show()
            self.AppObjectFeedbackIndex = self.Dialog.objectIndex
            return

        if self.InsideRegion is True:
            self.DialogOpened = True
            self.Dialog = AppTextInRegionDialog(self, self.LastRectHover, 0)
            self.Dialog.show()
            self.AppObjectFeedbackIndex = self.Dialog.objectIndex
            return
Exemplo n.º 2
0
    def mouseReleaseEvent(self, event):

        self.MovingAppObject = False

        if self.DialogOpened is True:
            #self.BringWindowToFront()
            return

        if self.InsideRect is True or self.InsideRegion is True:
            self.pressed = False
            #self.AlexaAppImagesBackup[self.LastRectHover] = copy.deepcopy(self.AlexaAppImages[self.LastRectHover])
            self.update()
            return

        #if(event.type() == QEvent.MouseButtonRelease):
        if event.button() == Qt.LeftButton:

            if self.DialogOpened is True:
                #self.BringWindowToFront()
                return
            self.pressed = False
            self.released = True

            width = self.mouseNewX - self.mouseOldX
            height = self.mouseNewY - self.mouseOldY

            rect = QRect(self.mouseOldX, self.mouseOldY, width, height)

            if (rect.width() >= 3 or rect.width() <= -3) and (rect.height() >= 3 or rect.height() <= -3):
                AlexaObject = AlexaAppImagePlus()

                if (rect.width() < 0 and rect.height() < 0):

                    x = rect.x() + rect.width()
                    y = rect.y() + rect.height()
                    w = -rect.width()
                    h = -rect.height()
                    ##rect = QRect(x, y, w, h)

                elif (rect.width() < 0 and rect.height() > 0):

                    x = rect.x() + rect.width()
                    y = rect.y()
                    w = -rect.width()
                    h = rect.height()
                    ##rect = QRect(x, y, w, h)

                elif (rect.width() > 0 and rect.height() < 0):

                    x = rect.x()
                    y = rect.y() + rect.height()
                    w = rect.width()
                    h = -rect.height()
                    ##rect = QRect(x, y, w, h)
                else:
                    x = rect.x()
                    y = rect.y()
                    w = rect.width()
                    h = rect.height()
                    ##rect = QRect(x, y, w, h)

                if width < 0:
                    width = width * -1
                if height < 0:
                    height = height * -1

                if self.CropRegion is False:

                    #AlexaObject.Height = height
                    #AlexaObject.Width = width
                    AlexaObject.Height = h
                    AlexaObject.Width = w
                    AlexaObject.HeightTollerance = 10
                    AlexaObject.WidthTollerance = 10
                    AlexaObject.RectX = x
                    AlexaObject.RectY = y

                    self.AlexaAppImages.append(AlexaObject)
                    #self.AlexaAppImagesBackup.append(AlexaObject)
                    self.AlexaAppImagesBackup.append(copy.deepcopy(AlexaObject))
                    self.AlexaAppImagesDeleted = []

                    ##self.rectObjCollection.append(rect)
                    ##self.rectObjCollectionDeleted = []

                    #todo
                    self.DialogOpened = True
                    self.Dialog = AppImgDialog(self, len(self.AlexaAppImages)-1, 0)
                    self.Dialog.show()
                    self.AppObjectFeedbackIndex = self.Dialog.objectIndex
                elif self.CropRegion is True:
                    self.AlexaAppImages[self.AppObjectFeedbackIndex].CropRegionX = x - self.AlexaAppImages[self.AppObjectFeedbackIndex].RectX
                    self.AlexaAppImages[self.AppObjectFeedbackIndex].CropRegionY = y - self.AlexaAppImages[self.AppObjectFeedbackIndex].RectY
                    self.AlexaAppImages[self.AppObjectFeedbackIndex].CropRegionWidth = w
                    self.AlexaAppImages[self.AppObjectFeedbackIndex].CropRegionHeight = h
                    #todo
                    self.DialogOpened = True
                    self.Dialog = AppTextInRegionDialog(self, len(self.AlexaAppImages)-1, 0)
                    self.Dialog.show()
                    self.AppObjectFeedbackIndex = self.Dialog.objectIndex

                    self.CropRegion = False
                #ui = Ui_Dialog()
                #ui.setupUi(Dialog)
                #self.Dialog.show()

                #if sys.platform == 'win32':
                    #self.DialogHwnd = win32self, textgui.GetForegroundWindow()

            self.update()