コード例 #1
0
 def GetYBlackZone(self):
     y = 0.0
     normalizedHeight = self.surface.widget.width() / (GetImageWidth() /
                                                       GetImageHeight())
     if (self.surface.widget.width() / self.surface.widget.height()) < (
             GetImageWidth() / GetImageHeight()):
         y = (self.surface.widget.height() - (normalizedHeight)) / 2.0
     return y
コード例 #2
0
 def GetXBlackZone(self):
     x = 0.0
     normalizedWidth = self.surface.widget.height() * (GetImageWidth() /
                                                       GetImageHeight())
     if (self.surface.widget.width() / self.surface.widget.height()) > (
             GetImageWidth() / GetImageHeight()):
         x = (self.surface.widget.width() - (normalizedWidth)) / 2.0
     return x
コード例 #3
0
 def IsPointOnScreen(self, x, y):
     res = True
     normalizedWidth = self.surface.widget.height() * (GetImageWidth() /
                                                       GetImageHeight())
     normalizedHeight = self.surface.widget.width() / (GetImageWidth() /
                                                       GetImageHeight())
     if x > (normalizedWidth +
             self.GetXBlackZone()) or x < self.GetXBlackZone():
         res = False
     if y > (normalizedHeight +
             self.GetYBlackZone()) or y < self.GetYBlackZone():
         res = False
     return res
コード例 #4
0
ファイル: QgsVideo.py プロジェクト: Mariosmsk/QGISFMV
    def mouseDoubleClickEvent(self, event):
        """
        :type event: QMouseEvent
        :param event:
        :return:
        """
        if GetImageHeight() == 0:
            return

        if (not vut.IsPointOnScreen(event.x(), event.y(), self.surface)):
            return

        if self.gt is not None and self._interaction.lineDrawer:
            self.drawLines.append([None, None, None])
            self.UpdateSurface()
            return
        if self.gt is not None and self._interaction.ruler:
            self.drawRuler.append([None, None, None])
            self.UpdateSurface()
            return
        if self.gt is not None and self._interaction.polygonDrawer:
            self.drawPolygon.append([None, None, None])

            AddDrawPolygonOnMap(self.poly_coordinates)

            # Empty RubberBand
            for _ in range(self.poly_RubberBand.numberOfVertices()):
                self.poly_RubberBand.removeLastPoint()
            # Empty List
            self.poly_coordinates = []
            self.UpdateSurface()
            return

        self.setFullScreen(not self.isFullScreen())
        event.accept()
コード例 #5
0
ファイル: QgsVideoUtils.py プロジェクト: tlh22/QGISFMV
 def GetYRatio(surface):
     '''ratio between event.y() and real image height on screen.
     @type surface: QAbstractVideoSurface
     @param surface: Abstract video surface
     @return: double
     '''
     return GetImageHeight() / (surface.widget.height() - (2 * VideoUtils.GetYBlackZone(surface)))
コード例 #6
0
ファイル: QgsVideoUtils.py プロジェクト: singme163/QGISFMV
 def GetNormalizedHeight(surface):
     """Calculate normalized Height
     @type surface: QAbstractVideoSurface
     @param surface: Abstract video surface
     @return: double
     """
     return surface.widget.width() / (GetImageWidth() / GetImageHeight())
コード例 #7
0
 def GetXBlackZone(surface):
     ''' Return is X in black screen on video '''
     x = 0.0
     if (surface.widget.width() / surface.widget.height()) > (
             GetImageWidth() / GetImageHeight()):
         x = (surface.widget.width() -
              (VideoUtils.GetNormalizedWidth(surface))) / 2.0
     return x
コード例 #8
0
 def GetYBlackZone(surface):
     ''' Return is Y in black screen on video '''
     y = 0.0
     if (surface.widget.width() / surface.widget.height()) < (
             GetImageWidth() / GetImageHeight()):
         y = (surface.widget.height() -
              (VideoUtils.GetNormalizedHeight(surface))) / 2.0
     return y
コード例 #9
0
ファイル: QgsVideoUtils.py プロジェクト: tlh22/QGISFMV
 def GetNormalizedWidth(surface):
     '''Calculate normalized Width
     @type surface: QAbstractVideoSurface
     @param surface: Abstract video surface
     @return: double
     '''
     try:
         return surface.widget.height(
         ) * (GetImageWidth() / GetImageHeight())
     except ZeroDivisionError:
         return 0.0
コード例 #10
0
ファイル: QgsVideoUtils.py プロジェクト: frpin33/QGISFMV
 def GetYBlackZone(surface):
     ''' Return is Y in black screen on video '''
     y = 0.0
     try:
         if (surface.widget.width() / surface.widget.height()) < (
                 GetImageWidth() / GetImageHeight()):
             y = (surface.widget.height() -
                  (VideoUtils.GetNormalizedHeight(surface))) / 2.0
     except ZeroDivisionError:
         None
     return y
コード例 #11
0
    def mouseDoubleClickEvent(self, event):
        """
         Mouse double click event
        :type event: QMouseEvent
        :param event:
        :return:
        """
        if GetImageHeight() == 0:
            return

        if not vut.IsPointOnScreen(event.x(), event.y(), self.surface):
            return

        if GetGCPGeoTransform() is not None and self._interaction.lineDrawer:
            self.drawLines.append([None, None, None])
            return

        if GetGCPGeoTransform(
        ) is not None and self._interaction.measureDistance:
            self.drawMeasureDistance.append([None, None, None])
            self.parent.actionMeasureDistance.toggle()
            return

        if GetGCPGeoTransform() is not None and self._interaction.measureArea:
            self.drawMeasureArea.append([None, None, None])
            self.parent.actionMeasureArea.toggle()
            return

        if GetGCPGeoTransform(
        ) is not None and self._interaction.polygonDrawer:

            ok = AddDrawPolygonOnMap(self.poly_coordinates)
            # Prevent invalid geometry (Polygon with 2 points)
            if not ok:
                return

            self.drawPolygon.append([None, None, None])

            # Empty RubberBand
            for _ in range(self.poly_Canvas_RubberBand.numberOfVertices()):
                self.poly_Canvas_RubberBand.removeLastPoint()
            # Empty List
            self.poly_coordinates = []
            return

        self.UpdateSurface()
        scr = QApplication.desktop().screenNumber(self)
        self.setGeometry(QApplication.desktop().screenGeometry(scr))
        self.setFullScreen(not self.isFullScreen())
        event.accept()
コード例 #12
0
ファイル: QgsVideoUtils.py プロジェクト: singme163/QGISFMV
 def GetYBlackZone(surface):
     """Return is Y in black screen on video
     @type surface: QAbstractVideoSurface
     @param surface: Abstract video surface
     @return: double
     """
     y = 0.0
     try:
         if (surface.widget.width() / surface.widget.height()) < (
                 GetImageWidth() / GetImageHeight()):
             y = (surface.widget.height() -
                  (VideoUtils.GetNormalizedHeight(surface))) / 2.0
     except ZeroDivisionError:
         None
     return y
コード例 #13
0
 def GetXBlackZone(surface):
     '''Return is X in black screen on video
     @type surface: QAbstractVideoSurface
     @param surface: Abstract video surface
     @return: double
     '''
     x = 0.0
     try:
         if (surface.widget.width() / surface.widget.height()) > (
                 GetImageWidth() / GetImageHeight()):
             x = (surface.widget.width() -
                  (VideoUtils.GetNormalizedWidth(surface))) / 2.0
     except ZeroDivisionError:
         None
     return x
コード例 #14
0
ファイル: QgsVideo.py プロジェクト: allouchmed/QGISFMV
    def mousePressEvent(self, event):
        """
        @type event: QMouseEvent
        @param event:
        @return:
        """
        if GetImageHeight() == 0:
            return

        # Prevent draw on video if not started or finished
        if self.parent.player.position() == 0:
            return

        if event.button() == Qt.LeftButton:

            # Magnifier Glass
            if self._interaction.magnifier:
                self.dragPos = event.pos()
                self.tapTimer.stop()
                self.tapTimer.start(10, self)

            if(not vut.IsPointOnScreen(event.x(), event.y(), self.surface)):
                return

            # point drawer
            if self.gt is not None and self._interaction.pointDrawer:
                Longitude, Latitude, Altitude = vut.GetPointCommonCoords(
                    event, self.surface)

                pointIndex = len(self.drawPtPos) + 1
                AddDrawPointOnMap(pointIndex, Longitude,
                                  Latitude, Altitude)

                self.drawPtPos.append([Longitude, Latitude, Altitude])

            # polygon drawer
            if self.gt is not None and self._interaction.polygonDrawer:
                Longitude, Latitude, Altitude = vut.GetPointCommonCoords(
                    event, self.surface)
                self.poly_Canvas_RubberBand.addPoint(QgsPointXY(Longitude, Latitude))
                self.poly_coordinates.extend(QgsPointXY(Longitude, Latitude))
                self.drawPolygon.append([Longitude, Latitude, Altitude])

            # line drawer
            if self.gt is not None and self._interaction.lineDrawer:
                Longitude, Latitude, Altitude = vut.GetPointCommonCoords(
                    event, self.surface)

                self.drawLines.append([Longitude, Latitude, Altitude])

                AddDrawLineOnMap(self.drawLines)

            self.origin = event.pos()
            # Object Tracking Interaction
            if self._interaction.objectTracking:
                self.Tracking_Video_RubberBand.setGeometry(
                    QRect(self.origin, QSize()))
                self.Tracking_Video_RubberBand.show()

            # Censure Interaction
            if self._interaction.censure:
                self.Censure_RubberBand.setGeometry(
                    QRect(self.origin, QSize()))
                self.Censure_RubberBand.show()

            # Measure Distance drawer
            if self.gt is not None and self._interaction.measureDistance:
                Longitude, Latitude, Altitude = vut.GetPointCommonCoords(
                    event, self.surface)
                self.drawMeasureDistance.append([Longitude, Latitude, Altitude])

            # Measure Distance drawer
            if self.gt is not None and self._interaction.measureArea:
                Longitude, Latitude, Altitude = vut.GetPointCommonCoords(
                    event, self.surface)
                self.drawMeasureArea.append([Longitude, Latitude, Altitude])

            # if not called, the paint event is not triggered.
            self.UpdateSurface()
コード例 #15
0
ファイル: QgsVideoUtils.py プロジェクト: frpin33/QGISFMV
 def GetNormalizedWidth(surface):
     try:
         return surface.widget.height() * (GetImageWidth() /
                                           GetImageHeight())
     except ZeroDivisionError:
         return 0.0
コード例 #16
0
ファイル: QgsVideo.py プロジェクト: Mariosmsk/QGISFMV
    def mousePressEvent(self, event):
        """
        :type event: QMouseEvent
        :param event:
        :return:
        """
        if GetImageHeight() == 0:
            return

        if event.button() == Qt.LeftButton:
            self.snapped = True
            self.pressPos = self.dragPos = event.pos()
            self.tapTimer.stop()
            self.tapTimer.start(100, self)

            if (not vut.IsPointOnScreen(event.x(), event.y(), self.surface)):
                self.UpdateSurface()
                return

            # point drawer
            if self.gt is not None and self._interaction.pointDrawer:
                Longitude, Latitude, Altitude = vut.GetPointCommonCoords(
                    event, self.surface)

                pointIndex = len(self.drawPtPos) + 1
                AddDrawPointOnMap(pointIndex, Longitude, Latitude, Altitude)

                self.drawPtPos.append([Longitude, Latitude, Altitude])

            # polygon drawer
            if self.gt is not None and self._interaction.polygonDrawer:
                Longitude, Latitude, Altitude = vut.GetPointCommonCoords(
                    event, self.surface)
                self.poly_RubberBand.addPoint(QgsPointXY(Longitude, Latitude))
                self.poly_coordinates.extend(QgsPointXY(Longitude, Latitude))
                self.drawPolygon.append([Longitude, Latitude, Altitude])

            # line drawer
            if self.gt is not None and self._interaction.lineDrawer:
                Longitude, Latitude, Altitude = vut.GetPointCommonCoords(
                    event, self.surface)

                self.drawLines.append([Longitude, Latitude, Altitude])

                AddDrawLineOnMap(self.drawLines)

            if self._interaction.objectTracking:
                self.origin = event.pos()
                self.Tracking_RubberBand.setGeometry(
                    QRect(self.origin, QSize()))
                self.Tracking_RubberBand.show()

            if self._interaction.censure:
                self.origin = event.pos()
                self.Censure_RubberBand.setGeometry(QRect(
                    self.origin, QSize()))
                self.Censure_RubberBand.show()

            # Ruler drawer
            if self.gt is not None and self._interaction.ruler:
                Longitude, Latitude, Altitude = vut.GetPointCommonCoords(
                    event, self.surface)
                self.drawRuler.append([Longitude, Latitude, Altitude])

        # if not called, the paint event is not triggered.
        self.UpdateSurface()
コード例 #17
0
ファイル: QgsVideo.py プロジェクト: Mariosmsk/QGISFMV
    def mouseMoveEvent(self, event):
        """
        :type event: QMouseEvent
        :param event:
        :return:
        """
        if GetImageHeight() == 0:
            return

        # check if the point  is on picture (not in black borders)
        if (not vut.IsPointOnScreen(event.x(), event.y(), self.surface)):
            return

        if self._interaction.pointDrawer or self._interaction.polygonDrawer or self._interaction.lineDrawer or self._interaction.ruler:
            self.setCursor(QCursor(Qt.CrossCursor))

        # Cursor Coordinates
        if self.gt is not None:

            Longitude, Latitude, Altitude = vut.GetPointCommonCoords(
                event, self.surface)

            txt = "<span style='font-size:10pt; font-weight:bold;'>Lon :</span>"
            txt += "<span style='font-size:9pt; font-weight:normal;'>" + \
                ("%.3f" % Longitude) + "</span>"
            txt += "<span style='font-size:10pt; font-weight:bold;'> Lat :</span>"
            txt += "<span style='font-size:9pt; font-weight:normal;'>" + \
                ("%.3f" % Latitude) + "</span>"

            if hasElevationModel():
                txt += "<span style='font-size:10pt; font-weight:bold;'> Alt :</span>"
                txt += "<span style='font-size:9pt; font-weight:normal;'>" + \
                    ("%.0f" % Altitude) + "</span>"
            else:
                txt += "<span style='font-size:10pt; font-weight:bold;'> Alt :</span>"
                txt += "<span style='font-size:9pt; font-weight:normal;'>-</span>"

            self.parent.lb_cursor_coord.setText(txt)

        else:
            self.parent.lb_cursor_coord.setText(
                "<span style='font-size:10pt; font-weight:bold;'>Lon :</span>"
                + "<span style='font-size:9pt; font-weight:normal;'>-</span>" +
                "<span style='font-size:10pt; font-weight:bold;'> Lat :</span>"
                + "<span style='font-size:9pt; font-weight:normal;'>-</span>" +
                "<span style='font-size:10pt; font-weight:bold;'> Alt :</span>"
                + "<span style='font-size:9pt; font-weight:normal;'>-</span>")

        if not event.buttons():
            return

        if not self.Tracking_RubberBand.isHidden():
            self.Tracking_RubberBand.setGeometry(
                QRect(self.origin, event.pos()).normalized())

        if not self.Censure_RubberBand.isHidden():
            self.Censure_RubberBand.setGeometry(
                QRect(self.origin, event.pos()).normalized())

        if not self.zoomed:
            delta = event.pos() - self.pressPos
            if not self.snapped:
                self.pressPos = event.pos()
                self.pan(delta)
                self.tapTimer.stop()
                return
            else:
                threshold = 10
                self.snapped &= delta.x() < threshold
                self.snapped &= delta.y() < threshold
                self.snapped &= delta.x() > -threshold
                self.snapped &= delta.y() > -threshold

        else:
            self.dragPos = event.pos()
            self.surface.updateVideoRect()
コード例 #18
0
ファイル: QgsVideoUtils.py プロジェクト: frpin33/QGISFMV
 def GetYRatio(surface):
     ''' ratio between event.y() and real image height on screen. '''
     return GetImageHeight() / (surface.widget.height() -
                                (2 * VideoUtils.GetYBlackZone(surface)))
コード例 #19
0
 def GetYRatio(self):
     return GetImageHeight() / (self.surface.widget.height() -
                                (2 * self.GetYBlackZone()))
コード例 #20
0
ファイル: QgsVideoUtils.py プロジェクト: frpin33/QGISFMV
 def GetNormalizedHeight(surface):
     return surface.widget.width() / (GetImageWidth() / GetImageHeight())
コード例 #21
0
 def GetYRatio(self):
     ''' ratio between event.y() and real image height on screen. '''
     return GetImageHeight() / (self.surface.widget.height() -
                                (2 * self.GetYBlackZone()))