Beispiel #1
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
Beispiel #2
0
    def translate_pos(self, f_pos):
        """
        translate pos
        """
        # check input
        assert f_pos

        # create answer
        l_xy = pxy.CPosXY()
        assert l_xy is not None

        # lat/lng
        lf_delta_lat = (f_pos.f_lat - self.__center.f_lat) * cdefs.D_CNV_GR2NM
        lf_delta_lng = (f_pos.f_lng - self.__center.f_lng) * cdefs.D_CNV_GR2NM

        # escala
        lf_esc = self.__f_width / self.__f_zoom

        # convert to x/y
        l_xy.f_y = self.__f_height / 2. - lf_delta_lat * lf_esc
        l_xy.f_x = self.__f_width / 2. + lf_delta_lng * math.cos(
            math.radians(self.__center.f_lat)) * lf_esc

        # return
        return l_xy
Beispiel #3
0
    def makeVector(self, f_iVal):
        """
        DOCUMENT ME!
        """
        # check input
        # assert f_control

        # M_LOG.debug("f_iVal....: " + str(f_iVal))
        # M_LOG.debug("aoAircraft: " + str(len(self.__dct_flight)))

        # verifica se o índice é válido
        if (f_iVal < 0) or (f_iVal >= len(self.__dct_flight)):
            # cai fora...
            return

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

        # converte as coordenadas de tela para mapa
        l_pos = self.__viewport.translate_xy(l_XY)

        self.__f_radar_vector = tMath.track(
            self.__dct_flight[f_iVal].radarPosition(),
            l_pos) + self.__airspace.variation()

        l_iRem = int(self.__f_radar_vector * 10.) % 50

        self.__f_radar_vector = int(
            self.__f_radar_vector) - (int(self.__f_radar_vector) % 5)

        if l_iRem >= 25:
            self.__f_radar_vector += 5.

        if self.__f_radar_vector > 360.:
            self.__f_radar_vector -= 360.

        if 0. == self.__f_radar_vector:
            self.__f_radar_vector = 360.

        self.__i_lateral_mode = self.C_LMODE_HDG
Beispiel #4
0
    def mouseMoveEvent(self, f_evt):
        """
        called when the mouse pointer is moved over the radar window

        @param  f_evt: QMouseEvent*, not used in this function
        """
        # check input
        assert f_evt

        # checks
        Normal = 0
        Panning = 1
        Zoom = 2

        m_Mode = 0
        '''
        QRect radarwndrect ;
        QPoint globalpnt ;
        QRect statusbarrect ;
        '''
        # M_LOG.debug("_iActiveAC...: " + str(self.__i_active_ac))
        # M_LOG.debug("_iLateralMode: " + str(self.__i_lateral_mode))

        self._iMouseX = f_evt.x()
        self._iMouseY = f_evt.y()

        if self.__i_active_ac >= 0:
            if self.C_LMODE_HDG == self.__i_lateral_mode:
                self.makeVector(self.__i_active_ac)

            elif self.C_LMODE_DCT == self.__i_lateral_mode:
                self.makeDirect()

            elif self.C_LMODE_RTE == self.__i_lateral_mode:
                self.makeRoute()

            elif self.C_LMODE_APP == self.__i_lateral_mode:
                self.makeApproach()

            self.repaint()

        else:
            # pnt = QtGui.QCursor.pos () ;
            # point = mapFromGlobal(pnt) ;

            # CheckFocus () ;

            # check the radar window mode
            if Normal == m_Mode:
                '''
                # No mode is activated for the radar window having the focus
                # No process is to be performed if the radar window is over
                # another radar window for which the panning mode is activated
                if m_psMainWnd
                    if(m_psMainWnd->m_Mode == Panning)
                        break ;

                if m_psSecWnd1
                    if(m_psSecWnd1->m_Mode == Panning)
                        break ;

                if m_psSecWnd2
                    if(m_psSecWnd2->m_Mode == Panning)
                        break ;
                '''
                # the status bar must show the current lat long of the mouse pointer
                # if it presents the focus and the mouse pointer is over the view
                # QPoint pnt ;

                if (
                        1
                ):  # m_bsForcedMove or (( point != m_LastCursorPos) and(hasMouse ()))):
                    '''
                    killTimer(m_TimerId) ;
                    m_TimerId = startTimer(100) ;

                    pnt = point ;
                    DPtoLP(&pnt) ;

                    radarwndrect = this->geometry () ;
                    statusbarrect = GetStatusBar ()->rect () ;
                    '''
                    # the mouse pointer must not be over the status bar
                    if (
                            1
                    ):  # globalpnt.y () <= radarwndrect.y () + radarwndrect.height () - statusbarrect.height ()):

                        # converte a posição do mouse para coordenadas XY
                        l_oXY = pxy.CPosXY(f_evt.x(), f_evt.y())
                        assert l_oXY

                        # converte coordenadas XY para geográfica
                        l_oGeo = self.__viewport.translate_xy(l_oXY)
                        assert l_oGeo

                        # atualiza a statusBar
                        self.__parent.status_bar.update_coordinates(
                            unicode(l_oGeo) + " (%d, %d)" %
                            (f_evt.x(), f_evt.y()))

                        # libera a área alocada
                        del l_oGeo

                pass
                '''
                m_LastCursorPos = point ;

                # the event is then transmitted to the graphical element that are
                # under modification or that has the implicit focus
                if(hasMouse ())

                    if(m_pModifElem)
                        m_pModifElem->onMouseMove(0, point) ;

                    if(m_pCurElem)

                        curprio = m_pCurElem->GetPriority(point, true) ;

                        if(curprio == 0)

                            m_pCurElem->SelectElement(false) ;
                            m_pCurElem = NULL ;
                else:
                    # if the element being modified is not within the view the event is transmitted
                    # anyway in order to cancel the tool creation mode
                    if(m_pModifElem)
                        m_pModifElem->onMouseMove(0, point) ;
                '''
                pass

            elif (Panning == m_Mode):
                '''
                # panning mode
                if(m_ReducePanning >= 10)
                {
                    m_ReducePanning = 0 ;
                    QRect rect = QWidget::rect () ;
                    QSize size ;
                    QPoint pnt ;
                    size = QSize(rect.center ().x () - point.x (), rect.center ().y () - point.y ()) ;
                    DPtoLP(&size) ;
                    size.setHeight(-size.height ()) ;

                    # Because of the range limitation, the center must remains within predefined limits
                    # if (( size.width ()) ||(size.height ()))
                    {
                        # Following the first move of the mouse pointer this check is not performed and over all the presentation of the view is not updated as the first move is the positionning of the mouse pointer at the center of the view
                        if(!m_FirstPanningMove)
                        {
                            pnt = GetCentre () ;
                            pnt = QPoint(pnt.x () + size.width (), pnt.y () + size.height ()) ;

                            /*if(pnt.x () >5000)
                                pnt.setX(5000) ;

                            if(pnt.x () <-5000)
                                pnt.setX(-5000) ;

                            if(pnt.y () >5000)
                                pnt.setY(5000) ;

                            if(pnt.y () <-5000)
                                pnt.setY(-5000) ;*/

                            SetCentre(pnt) ;
                            onUpdate(NULL, 0, NULL) ;

                        } # end if

                        m_FirstPanningMove = false ;
                        rect = geometry () ;
                        QCursor::setPos(rect.center () .x (), rect.center () .y ()) ;
                        CTOORArrow::UpdateFromView(this) ;

                    } # end if
                }
                else
                    m_ReducePanning ++ ;
                '''
                pass

            elif Zoom == m_Mode:
                '''
                # zoom mode
                radarwndrect = this->geometry () ;
                globalpnt = QCursor::pos () ;
                statusbarrect = GetStatusBar ()->rect () ;

                # the mouse pointer must be over the radar window to perform the change
                if (( globalpnt.x () >= radarwndrect.x () + radarwndrect.width ()) ||
                   (globalpnt.x () <= radarwndrect.x ()) ||
                   (globalpnt.y () <= radarwndrect.y ()) ||
                   (globalpnt.y () >= radarwndrect.y () + radarwndrect.height () - statusbarrect.height ()))
                {
                    m_Mode = Normal ;
                    setCursor(*CAsdApp::GetApp ()->GetCursor(MPNormalSelect)) ;

                } # end if
                '''
                pass
Beispiel #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
Beispiel #6
0
    def makeDirect(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

        # primeiro waypoint
        i = 0
        wpt = self.__airspace.waypoint(0)

        # scan all waypoints
        while wpt is not None:
            # calcula a distância do mouse ao waypoint
            r = tMath.distLL(pos, wpt.position())

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

            # next waypoint
            i += 1
            wpt = self.__airspace.waypoint(i)

        # primeiro vor
        i = 0
        wpt = self.__airspace.vor(0)

        # scan all vor's
        while wpt is not None:
            # calcula a distância do mouse ao vor
            r = tMath.distLL(pos, wpt.position())

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

            # next vor
            i += 1
            wpt = self.__airspace.vor(i)

        # primeiro ndb
        i = 0
        wpt = self.__airspace.ndb(0)

        # scan all ndb's
        while wpt is not None:
            # calcula a distância do mouse ao ndb
            r = tMath.distLL(pos, wpt.position())

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

            # next ndb
            i += 1
            wpt = self.__airspace.ndb(i)

        # salva nome do elemento mais próximo do mouse
        self.__s_direct = l_sClosest
        self.__i_lateral_mode = self.C_LMODE_DCT
Beispiel #7
0
    def mouseReleaseEvent(self, f_evt):
        """
        DOCUMENT ME!
        """
        # check input
        assert f_evt

        if f_evt.button() & QtCore.Qt.LeftButton:
            # none aircraft active ?
            if self.__i_active_ac < 0:
                # update mouse
                self._iMouseX = f_evt.x()
                self._iMouseY = f_evt.y()

                # find closest aircraft
                l_XY = pxy.CPosXY(self._iMouseX, self._iMouseY)
                assert l_XY is not None

                l_pos = self.__viewport.translate_xy(l_XY)

                l_fClosest_r = 1000000
                # l_iClosest = -1

                # for key in xrange(len(self.__dct_flight)):
                # r = tMath.distLL(l_pos, self.__dct_flight[key].radarPosition())

                # if r < l_fClosest_r:
                # l_iClosest = key
                # l_fClosest_r = r

                # activate Vector
                # self.showLateral(l_iClosest)
                self.makeVector(self.__i_active_ac)
                self.repaint()

            else:  # Yes, order HDG
                if self.C_LMODE_HDG == self.__i_lateral_mode:
                    self.__dct_flight[self.__i_active_ac].instructHeading(
                        int(self.__f_radar_vector))

                elif self.C_LMODE_DCT == self.__i_lateral_mode:
                    self.__dct_flight[self.__i_active_ac].instructDirect(
                        self.__s_direct)

                elif self.C_LMODE_RTE == self.__i_lateral_mode:
                    self.__dct_flight[self.__i_active_ac].instructRoute(
                        self.__s_route)

                elif self.C_LMODE_APP == self.__i_lateral_mode:
                    self.__dct_flight[self.__i_active_ac].instructApproach(
                        self.__s_approach)

                self.hideLateral()
                self.repaint()

        elif f_evt.button() & QtCore.Qt.MidButton:
            l_XY = pxy.CPosXY(f_evt.x(), f_evt.y())
            assert l_XY is not None

            l_pos = self.__viewport.translate_xy(l_XY)
            self.__viewport.center = l_pos

            self.repaint()

        elif f_evt.button() & QtCore.Qt.RightButton:
            # cancel vectoring
            if self.__i_active_ac >= 0:
                self.hideLateral()
                self.repaint()