コード例 #1
0
ファイル: Boundary.cpp プロジェクト: cagscat/ocpn_draw_pi
ODPoint *Boundary::InsertPointAfter( ODPoint *pOP, double lat, double lon, bool bRenamePoints )
{
    ODPoint *newpoint = ODPath::InsertPointAfter( pOP, lat, lon, bRenamePoints );
    newpoint->SetTypeString( wxT("Boundary Point") );
    
    return ( newpoint );
}
コード例 #2
0
void ODDRDialogImpl::OnOK( wxCommandEvent& event )
{
    if( m_pDR != NULL ) {
        if( g_pPathMan->GetpActivePath() == m_pDR ) g_pPathMan->DeactivatePath( m_pDR );
        
        if( !g_pPathMan->DeletePath( m_pDR ) )
            return;
        if( g_pODPathPropDialog && ( g_pODPathPropDialog->IsShown()) && (m_pDR == g_pODPathPropDialog->GetPath()) ) {
            g_pODPathPropDialog->Hide();
        }
        
        if( g_pPathManagerDialog && g_pPathManagerDialog->IsShown() )
            g_pPathManagerDialog->UpdatePathListCtrl();
        
        if( g_pODPointPropDialog && g_pODPointPropDialog->IsShown() ) {
            g_pODPointPropDialog->ValidateMark();
            g_pODPointPropDialog->UpdateProperties();
        }
        
    }
    
    DR *l_pDR = new(DR);
    g_pDRList->Append( l_pDR );
    g_pPathList->Append( l_pDR );
    l_pDR->m_PathNameString << _("DR") << _T(" ") << g_pDRList->GetCount();
    
    ODPoint *beginPoint = new ODPoint( g_pfFix.Lat, g_pfFix.Lon, wxEmptyString, wxS("Start"), wxT("") );
    beginPoint->SetNameShown( false );
    beginPoint->SetTypeString( wxT("DR Point"));
    beginPoint->m_IconName = g_sDRPointIconName;
    beginPoint->m_bIsolatedMark = false;
    beginPoint->m_bShowODPointRangeRings = g_bDRPointShowRangeRings;
    beginPoint->m_iODPointRangeRingsNumber = g_iDRPointRangeRingsNumber;
    beginPoint->m_fODPointRangeRingsStep = g_fDRPointRangeRingsStep;
    beginPoint->m_iODPointRangeRingsStepUnits = g_iDRPointRangeRingsStepUnits;
    beginPoint->m_wxcODPointRangeRingsColour = g_colourDRPointRangeRingsColour;
    beginPoint->m_iRangeRingStyle = g_iDRPointRangeRingLineStyle;
    beginPoint->m_iRangeRingWidth = g_iDRPointRangeRingLineWidth;
    l_pDR->AddPoint( beginPoint, false );

    m_textCtrlSOG->GetValue().ToDouble( &l_pDR->m_dSoG );
    l_pDR->m_iCoG = g_ocpn_draw_pi->GetTrueOrMag( wxAtoi( m_textCtrlCOG->GetValue() ) );
    l_pDR->m_dMagCOG = g_dVar;
    m_textCtrlLength->GetValue().ToDouble( &l_pDR->m_dDRPathLength );
    m_textCtrlDRPointInterval->GetValue().ToDouble( &l_pDR->m_dDRPointInterval );
    
    l_pDR->m_iLengthType = m_radioBoxLengthType->GetSelection();
    l_pDR->m_iIntervalType = m_radioBoxIntervalType->GetSelection();
    l_pDR->m_iDistanceUnits = m_radioBoxDistanceUnits->GetSelection();
    l_pDR->m_iTimeUnits = m_radioBoxTimeUnits->GetSelection();
    
    switch ( m_radioBoxLengthType->GetSelection() ) {
        case ID_LT_TIME: {
            switch ( m_radioBoxTimeUnits->GetSelection() ) {
                case ID_TU_MINUTES:
                    l_pDR->m_dTotalLengthNM = ( l_pDR->m_dSoG / 60 ) * l_pDR->m_dDRPathLength;
                    break;
                case ID_TU_HOURS:
                    l_pDR->m_dTotalLengthNM = l_pDR->m_dSoG * l_pDR->m_dDRPathLength;
                    break;
                case ID_TU_DAYS:
                    l_pDR->m_dTotalLengthNM = ( l_pDR->m_dSoG * l_pDR->m_dDRPathLength ) * 24;
                    break;
            }
            break;
        }
        case ID_LT_DISTANCE: {
            if( m_radioBoxDistanceUnits->GetSelection() == ID_DU_KILOMETRES )
                l_pDR->m_dTotalLengthNM = l_pDR->m_dDRPathLength / 1.852;
            else
                l_pDR->m_dTotalLengthNM = l_pDR->m_dDRPathLength;
            break;
        }
    }
    
    switch ( m_radioBoxIntervalType->GetSelection() ) {
        case ID_IT_TIME: {
            switch ( m_radioBoxTimeUnits->GetSelection() ) {
                case ID_TU_MINUTES:
                    l_pDR->m_dDRPointIntervalNM = ( l_pDR->m_dSoG / 60 ) * l_pDR->m_dDRPointInterval;
                    break;
                case ID_TU_HOURS:
                    l_pDR->m_dDRPointIntervalNM = l_pDR->m_dSoG * l_pDR->m_dDRPointInterval;
                    break;
                case ID_TU_DAYS:
                    l_pDR->m_dDRPointIntervalNM = ( l_pDR->m_dSoG * l_pDR->m_dDRPointInterval ) * 24;
                    break;
            }
            break;
        }
        case ID_IT_DISTANCE: {
            if( m_radioBoxDistanceUnits->GetSelection() == ID_DU_KILOMETRES )
                l_pDR->m_dDRPointIntervalNM = l_pDR->m_dDRPointInterval / 1.852;
            else
                l_pDR->m_dDRPointIntervalNM = l_pDR->m_dDRPointInterval;
            break;
        }
    }
    
    double l_dStartLat = g_pfFix.Lat;
    double l_dStartLon = g_pfFix.Lon;
    double l_dEndLat;
    double l_dEndLon;

    PositionBearingDistanceMercator_Plugin( l_dStartLat, l_dStartLon, l_pDR->m_iCoG, l_pDR->m_dTotalLengthNM, &l_dEndLat, &l_dEndLon );
    
    int l_iNumODPoints = floor( l_pDR->m_dTotalLengthNM / l_pDR->m_dDRPointIntervalNM );
    double l_cumLength = l_pDR->m_dDRPointIntervalNM;
    double l_dSaveLat = l_dStartLat;
    double l_dSaveLon = l_dStartLon;
    for( int i = 0; i < l_iNumODPoints; i++ ) {
        double l_dLat, l_dLon;
        PositionBearingDistanceMercator_Plugin( l_dStartLat, l_dStartLon, l_pDR->m_iCoG, l_cumLength, &l_dLat, &l_dLon );
        ODPoint *l_NewPoint = new ODPoint( l_dLat, l_dLon, g_sDRPointIconName, wxT(""), wxT("") );
        l_NewPoint->SetNameShown( false );
        l_NewPoint->SetTypeString( wxS("DR Point") );
        l_NewPoint->m_bIsolatedMark = FALSE;
        l_NewPoint->m_bShowODPointRangeRings = g_bDRPointShowRangeRings;
        l_NewPoint->m_iODPointRangeRingsNumber = g_iDRPointRangeRingsNumber;
        l_NewPoint->m_fODPointRangeRingsStep = g_fDRPointRangeRingsStep;
        l_NewPoint->m_iODPointRangeRingsStepUnits = g_iDRPointRangeRingsStepUnits;
        l_NewPoint->m_wxcODPointRangeRingsColour = g_colourDRPointRangeRingsColour;
        l_NewPoint->m_iRangeRingStyle = g_iDRPointRangeRingLineStyle;
        l_NewPoint->m_iRangeRingWidth = g_iDRPointRangeRingLineWidth;
        l_pDR->AddPoint( l_NewPoint );
        g_pODSelect->AddSelectableODPoint( l_dLat, l_dLon, l_NewPoint );
        g_pODSelect->AddSelectablePathSegment( l_dLat, l_dLon, l_dSaveLat, l_dSaveLon, beginPoint, l_NewPoint, l_pDR );
        l_dSaveLat = l_dLat;
        l_dSaveLon = l_dLon;
        l_cumLength += l_pDR->m_dDRPointIntervalNM;
    }
    
    if( l_dEndLat != l_dSaveLat || l_dEndLon != l_dSaveLon ) {
        ODPoint *l_NewPoint = new ODPoint( l_dEndLat, l_dEndLon, g_sDRPointIconName, wxT(""), wxT("") );
        l_NewPoint->SetNameShown( false );
        l_NewPoint->SetTypeString( wxS("DR Point") );
        l_NewPoint->m_bIsolatedMark = FALSE;
        l_NewPoint->m_bShowODPointRangeRings = g_bDRPointShowRangeRings;
        l_NewPoint->m_iODPointRangeRingsNumber = g_iDRPointRangeRingsNumber;
        l_NewPoint->m_fODPointRangeRingsStep = g_fDRPointRangeRingsStep;
        l_NewPoint->m_iODPointRangeRingsStepUnits = g_iDRPointRangeRingsStepUnits;
        l_NewPoint->m_wxcODPointRangeRingsColour = g_colourDRPointRangeRingsColour;
        l_NewPoint->m_iRangeRingStyle = g_iDRPointRangeRingLineStyle;
        l_NewPoint->m_iRangeRingWidth = g_iDRPointRangeRingLineWidth;
        l_pDR->AddPoint( l_NewPoint );
        g_pODSelect->AddSelectableODPoint( l_dEndLat, l_dEndLon, l_NewPoint );
        g_pODSelect->AddSelectablePathSegment( l_dSaveLat, l_dSaveLon, l_dEndLat, l_dEndLon, beginPoint, l_NewPoint, l_pDR );
    }
    if(l_pDR->m_iPersistenceType == ID_DR_PERSISTENT || l_pDR->m_iPersistenceType == ID_DR_PERSISTENT_CRASH)
        g_pODConfig->AddNewPath( l_pDR, -1 );    // don't save over restart

    RequestRefresh( g_ocpn_draw_pi->m_parent_window );
    Show( false );
#ifdef __WXOSX__    
    EndModal(wxID_CANCEL);
#endif
}