Esempio n. 1
0
    def drawVector(self, fo_widget, f_anv, rv):
        """
        DOCUMENT ME!
        """
        # check input
        assert fo_widget

        l_pos = fo_widget.viewport.translate_pos(f_anv.radarPosition())

        lf_blip_size = fo_widget.viewport.f_blip_size

        str = "%03d" % rv
        rvec = rv - fo_widget._airspace.variation()

        lo_painter = QtGui.QPainter(fo_widget)
        assert lo_painter is not None

        lo_painter.setFont(QtGui.QFont("Arial", int(lf_blip_size * 1.5)))
        lo_painter.setPen(gdata.G_DCT_COLORS["instruction"])

        lo_painter.drawLine(int(l_pos.f_x),
                           int(l_pos.f_y),
                           int(l_pos.f_x + 2000 * tMath.dsin(rvec)),
                           int(l_pos.f_y - 2000 * tMath.dcos(rvec)))

        lo_painter.setFont(QtGui.QFont("Arial", int(lf_blip_size * 1.5)))

        if (rvec < 90) or ((rvec > 180) and (rvec < 270)):
            lo_painter.drawText(int(lf_blip_size + l_pos.f_x + lf_blip_size * 25 * tMath.dsin(rvec)),
                               int(lf_blip_size * 3 + l_pos.f_y - lf_blip_size * 25 * tMath.dcos(rvec)), str)
        else:
            lo_painter.drawText(int(lf_blip_size + l_pos.f_x + lf_blip_size * 25 * tMath.dsin(rvec)),
                               int(-lf_blip_size + l_pos.f_y - lf_blip_size * 25 * tMath.dcos(rvec)), str)

        del lo_painter
Esempio n. 2
0
    def drawApproach(self, fo_widget, f_anv, f_name):
        """
        DOCUMENT ME!
        """
        # check input
        assert fo_widget

        lf_blip_size = fo_widget.viewport.f_blip_size

        rwy = fo_widget.airspace.runway(f_name)
        l_pos = fo_widget.viewport.translate_pos(rwy.pos)

        lf_x = l_pos.f_x
        lf_y = l_pos.f_y

        l_track = tMath.trackOpposite(rwy.getTrack())
        l_track = 10.

        x1 = int(lf_x + fo_widget.viewport.pPNM() * tMath.dsin(l_track) * 10)
        y1 = int(lf_y - fo_widget.viewport.pPNM() * tMath.dcos(l_track) * 10)

        x2 = int(lf_x +
                 fo_widget.viewport.pPNM() * tMath.dsin(l_track + 4) * 11)
        y2 = int(lf_y -
                 fo_widget.viewport.pPNM() * tMath.dcos(l_track + 4) * 11)

        x3 = int(lf_x +
                 fo_widget.viewport.pPNM() * tMath.dsin(l_track - 4) * 11)
        y3 = int(lf_y -
                 fo_widget.viewport.pPNM() * tMath.dcos(l_track - 4) * 11)

        lo_painter = QtGui.QPainter(fo_widget)
        assert lo_painter is not None

        lo_painter.setPen(gdata.G_DCT_COLORS["instruction"])

        lo_painter.drawLine(x, y, x1, y1)
        lo_painter.drawLine(x, y, x2, y2)
        lo_painter.drawLine(x, y, x3, y3)

        lo_painter.drawLine(x1, y1, x2, y2)
        lo_painter.drawLine(x1, y1, x3, y3)

        l_pos = fo_widget.viewport.translate_pos(f_anv.radarPosition())

        str = "APP-%s" % f_name

        lo_painter.setFont(QtGui.QFont("Arial", int(lf_blip_size * 1.5)))
        lo_painter.drawText(int(l_pos.f_x + lf_blip_size),
                            int(l_pos.f_y + lf_blip_size * 2), str)

        del lo_painter
Esempio n. 3
0
    def makeApproach(self):
        """
        DOCUMENT ME!
        """
        # check input
        # assert f_control

        l_oXY = pxy.CPosXY(self._iMouseX, self._iMouseY)
        assert l_oXY is not None

        pos = self._viewport.translate_xy(l_oXY)

        l_fClosest_r = 1000000
        l_sClosest = ""

        i = 0

        while (self._airspace.arrivalRunway(i)):
            pos1 = self._airspace.getPosition(self._airspace.arrivalRunway(i))

            d = tMath.distLL(pos, pos1)
            a = tMath.trackDelta(
                self._airspace.runway(self._airspace.arrivalRunway(i)).track(),
                tMath.track(pos, pos1))

            r = d * tMath.dsin(abs(a))

            if ((r < l_fClosest_r) and (abs(a) < 90)):
                l_sClosest = self._airspace.arrivalRunway(i)
                l_fClosest_r = r

            i += 1

        self._s_approach = l_sClosest
        self._i_lateral_mode = self.C_LMODE_APP
Esempio n. 4
0
    def drawRunway(self, fo_widget, f_rwy):
        """
        DOCUMENT ME!
        """
        # check input
        assert fo_widget

        # obtém a posição da runway
        l_pos = fo_widget.viewport.translate_pos(f_rwy.pos)

        # componentes X e Y
        lf_x = l_pos.f_x
        lf_y = l_pos.f_y

        # obtém a direção da runway
        l_track = tMath.trackOpposite(f_rwy.fTrack)

        x_mile = fo_widget.viewport.pPNM() * tMath.dsin(l_track)
        y_mile = -fo_widget.viewport.pPNM() * tMath.dcos(l_track)

        # cria um painter
        lo_painter = QtGui.QPainter(fo_widget)
        assert lo_painter is not None

        # seleciona a caneta
        lo_painter.setPen(gdata.G_DCT_COLORS["runway"])

        for li_ndx in range(1, 25, 2):
            lo_painter.drawLine(int(lf_x + li_ndx * x_mile),
                                int(lf_y + li_ndx * y_mile),
                                int(lf_x + (li_ndx + 1) * x_mile),
                                int(lf_y + (li_ndx + 1) * y_mile))

        lo_painter.drawLine(int(lf_x + 10 * x_mile - y_mile / 2.),
                            int(lf_y + 10 * y_mile + x_mile / 2.),
                            int(lf_x + 10 * x_mile + y_mile / 2.),
                            int(lf_y + 10 * y_mile - x_mile / 2.))
        lo_painter.drawLine(int(lf_x + 25 * x_mile - y_mile / 2.),
                            int(lf_y + 25 * y_mile + x_mile / 2.),
                            int(lf_x + 25 * x_mile + y_mile / 2.),
                            int(lf_y + 25 * y_mile - x_mile / 2.))

        # libera o painter
        del lo_painter
Esempio n. 5
0
    def makeRoute(self):
        """
        DOCUMENT ME!
        """
        # check input
        # assert f_control

        # get mouse position
        l_oXY = pxy.CPosXY(self._iMouseX, self._iMouseY)
        assert l_oXY is not None

        # converte as coordenadas de tela para mapa
        pos = self.__viewport.translate_xy(l_oXY)

        # inicia variáveis
        l_sClosest = ""
        l_fClosest_r = 1000000

        # first arrival
        i = 0
        srt = self.__airspace.arrival(0)

        # scan all arrival's
        while srt is not None:
            # init flag
            apply = False

            # first runway
            rw = 0

            # scan all runway's
            while self.__airspace.arrivalRunway(rw):
                # arrival belongs to runway ?
                if srt.belongsToRunway(self.__airspace.arrivalRunway(rw)):
                    # ok, found
                    apply = True

                # next runway
                rw += 1

            # no found any runway ?
            if not apply:
                # next arrival
                i += 1
                srt = self.__airspace.arrival(i)

                # next loop
                continue

            n = 0
            while srt.item(n) is not None:
                pos1 = self.__airspace.getPosition(srt.item(n)._sName)
                r = tMath.distLL(pos, pos1)

                if srt.item(n + 1):
                    pos2 = self.__airspace.getPosition(srt.item(n + 1)._sName)
                    rttrk = tMath.track(pos1, pos2)
                    rtdist = tMath.distLL(pos1, pos2)
                    mstrk = tMath.track(pos1, pos)
                    tdelta = tMath.trackDelta(rttrk, mstrk)
                    prog = tMath.distLL(pos, pos1) * tMath.dcos(tdelta)

                    if ((prog > 0) and (prog < rtdist)):
                        r = tMath.distLL(pos, pos1) * tMath.dsin(abs(tdelta))

                # distância menor que a anterior ?
                if r < l_fClosest_r:
                    # this is the new closest element
                    l_sClosest = srt.getName()
                    l_fClosest_r = r

                n += 1

            # next arrival
            i += 1
            srt = self.__airspace.arrival(i)

        # first transition
        i = 0
        srt = self.__airspace.transition(0)

        # scan all transitions
        while srt is not None:
            # init flag
            apply = False

            # first runway
            rw = 0

            # scan all runway's
            while self.__airspace.arrivalRunway(rw):
                # transition belongs to runway ?
                if srt.belongsToRunway(self.__airspace.arrivalRunway(rw)):
                    # ok, found
                    apply = True

                # next runway
                rw += 1

            # no found any transition ?
            if not apply:
                # next transition
                i += 1
                srt = self.__airspace.transition(i)

                # next loop
                continue

            n = 0
            while srt.item(n):
                pos1 = self.__airspace.getPosition(srt.item(n)._sName)
                r = tMath.distLL(pos, pos1)

                if srt.item(n + 1):
                    pos2 = self.__airspace.getPosition(srt.item(n + 1)._sName)
                    rttrk = tMath.track(pos1, pos2)
                    rtdist = tMath.distLL(pos1, pos2)
                    mstrk = tMath.track(pos1, pos)
                    tdelta = tMath.trackDelta(rttrk, mstrk)
                    prog = tMath.distLL(pos, pos1) * tMath.dcos(tdelta)

                    if ((prog > 0) and (prog < rtdist)):
                        r = tMath.distLL(pos, pos1) * tMath.dsin(abs(tdelta))

                if r < l_fClosest_r:
                    l_sClosest = srt._sName()
                    l_fClosest_r = r

                n += 1

            # next transition
            i += 1
            srt = self.__airspace.transition(i)

        self.__s_route = l_sClosest
        self.__i_lateral_mode = self.C_LMODE_RTE