Beispiel #1
0
void TCWin::OnTCWinPopupTimerEvent( wxTimerEvent& event )
{

    int x, y;
    bool ShowRollover;

    GetClientSize( &x, &y );
    wxRegion cursorarea(m_graph_rect);
    if( cursorarea.Contains( curs_x, curs_y ) ) {
        ShowRollover = true;
        SetCursor( *pParent->pCursorCross );
        if( NULL == m_pTCRolloverWin ) {
            m_pTCRolloverWin = new RolloverWin( this, -1, false );
            // doesn't really work, mouse positions are relative to rollover window
            // not this window.
            // effect: hide rollover window if mouse on rollover
            m_pTCRolloverWin->SetMousePropogation( 1 );
            m_pTCRolloverWin->Hide();
        }
        float t, d;
        wxString p, s;
        //set time on x cursor position
        t = ( 25 / ( (float) x * 8 / 10 ) ) * ( (float) curs_x - ( (float) x * 1 / 10 ) );
        int tt = m_t_graphday_00_at_station + (int) ( t * 3600 );
        wxDateTime thd;
        time_t ths = tt + ( m_corr_mins * 60 );
        thd.Set( ths );
        p.Printf( thd.Format( _T("%Hh %Mmn") ) );
        p.Append( _T("\n") );

        //set tide level or current speed at that time
        ptcmgr->GetTideOrCurrent( tt, pIDX->IDX_rec_num, t, d );
        s.Printf( _T("%3.2f "), ( t < 0 && CURRENT_PLOT == m_plot_type ) ? -t : t ); // always positive if current
        p.Append( s );

        //set unit
        Station_Data *pmsd = pIDX->pref_sta_data;
        if( pmsd ) p.Append( wxString( pmsd->units_abbrv, wxConvUTF8 ) );

        //set current direction
        if( CURRENT_PLOT == m_plot_type ) {
            s.Printf( wxString("%3.0f°", wxConvUTF8), d );
            p.Append( _T("\n") );
            p.Append( s );
        }

        //set rollover area size
        wxSize win_size;
        win_size.Set( x * 90 / 100, y * 80 / 100 );

        m_pTCRolloverWin->SetString( p );
        m_pTCRolloverWin->SetBestPosition( curs_x, curs_y, 1, 1, TC_ROLLOVER, win_size );
        m_pTCRolloverWin->SetBitmap( TC_ROLLOVER );
        m_pTCRolloverWin->Refresh();
        m_pTCRolloverWin->Show();
        
        //  Mark the actual spot on the curve
        // x value is clear...
        //  Find the point in the window that is used for the curev rendering, rounding as necessary
        
        int idx = 1; // in case m_graph_rect.width is weird ie ppx never > curs_x
        for( int i = 0; i < 26; i++ ) {
            float ppx = m_graph_rect.x + ( ( i ) * m_graph_rect.width / 25.f );
            if(ppx > curs_x){
                idx = i;
                break;
            }
        }

        wxPointList *list = (wxPointList *)&m_sList;
        wxPoint *a = list->Item(idx-1)->GetData();
        wxPoint *b = list->Item(idx)->GetData();
        
        float pct = (curs_x  - a->x) / (float)((b->x - a->x));
        float dy = pct * (b->y - a->y);
        
        ySpot = a->y + dy;
        xSpot = curs_x;
        
        Refresh(true);
        
        
    } else {
        SetCursor( *pParent->pCursorArrow );
        ShowRollover = false;
    }

    if( m_pTCRolloverWin && m_pTCRolloverWin->IsShown() && !ShowRollover ) {
        m_pTCRolloverWin->Hide();
    }

}
Beispiel #2
0
void TCWin::OnTCWinPopupTimerEvent( wxTimerEvent& event )
{

    int x, y;
    bool ShowRollover;

    GetClientSize( &x, &y );
    wxRegion cursorarea(m_graph_rect);
    if( cursorarea.Contains( curs_x, curs_y ) ) {
        ShowRollover = true;
        SetCursor( *pParent->pCursorCross );
        if( NULL == m_pTCRolloverWin ) {
            m_pTCRolloverWin = new RolloverWin( this );
            m_pTCRolloverWin->SetMousePropogation( 1 );
            m_pTCRolloverWin->Hide();
        }
        float t, d;
        wxString p, s;
        //set time on x cursor position
        t = ( 25 / ( (float) x * 8 / 10 ) ) * ( (float) curs_x - ( (float) x * 1 / 10 ) );
        int tt = m_t_graphday_00_at_station + (int) ( t * 3600 );
        wxDateTime thd;
        time_t ths = tt + ( m_corr_mins * 60 );
        thd.Set( ths );
        p.Printf( thd.Format( _T("%Hh %Mmn") ) );
        p.Append( _T("\n") );

        //set tide level or current speed at that time
        ptcmgr->GetTideOrCurrent( tt, pIDX->IDX_rec_num, t, d );
        s.Printf( _T("%3.2f "), ( t < 0 && CURRENT_PLOT == m_plot_type ) ? -t : t ); // always positive if current
        p.Append( s );

        //set unit
        Station_Data *pmsd = pIDX->pref_sta_data;
        if( pmsd ) p.Append( wxString( pmsd->units_abbrv, wxConvUTF8 ) );

        //set current direction
        if( CURRENT_PLOT == m_plot_type ) {
            s.Printf( wxString("%3.0f°", wxConvUTF8), d );
            p.Append( _T("\n") );
            p.Append( s );
        }

        //set rollover area size
        wxSize win_size;
        win_size.Set( x * 90 / 100, y * 80 / 100 );

        m_pTCRolloverWin->SetString( p );
        m_pTCRolloverWin->SetBestPosition( curs_x, curs_y, 1, 1, TC_ROLLOVER, win_size );
        m_pTCRolloverWin->SetBitmap( TC_ROLLOVER );
        m_pTCRolloverWin->Refresh();
        m_pTCRolloverWin->Show();
    } else {
        SetCursor( *pParent->pCursorArrow );
        ShowRollover = false;
    }

    if( m_pTCRolloverWin && m_pTCRolloverWin->IsShown() && !ShowRollover ) {
        m_pTCRolloverWin->Hide();
        m_pTCRolloverWin = NULL;
    }

}