示例#1
0
void EBL::CentreOnBoat( bool bMoveEndPoint )
{
    ODPoint *pStartPoint = m_pODPointList->GetFirst()->GetData();
    ODPoint *pEndPoint = m_pODPointList->GetLast()->GetData();
    pStartPoint->m_lat = g_pfFix.Lat;
    pStartPoint->m_lon = g_pfFix.Lon;

    if(m_dLength == 0.) m_dLength = pEndPoint->m_seg_len;

    if(bMoveEndPoint && !m_bEndPointMoving) {
        if(m_bRotateWithBoat) {
            MaintainWith();
        } else {
            if(!m_bFixedEndPosition) {
                PositionBearingDistanceMercator_Plugin(pStartPoint->m_lat, pStartPoint->m_lon, m_dEBLAngle, m_dLength, &pEndPoint->m_lat, &pEndPoint->m_lon);
            } else {
                double brg;
                double hdg = 0.;
                DistanceBearingMercator_Plugin(pEndPoint->m_lat, pEndPoint->m_lon, pStartPoint->m_lat, pStartPoint->m_lon, &brg, &m_dLength);
                switch(m_iMaintainWith) {
                    case ID_EBL_MAINTAIN_WITH_HEADING:
                        if(!isnan(g_pfFix.Hdt))
                            hdg = g_pfFix.Hdt;
                        break;
                    case ID_EBL_MAINTAIN_WITH_COG:
                        if(!isnan(g_pfFix.Cog))
                            hdg = g_pfFix.Cog;
                        break;
                }
                if(hdg > brg)
                    m_dEBLAngle = brg + 360 - hdg;
                else if(hdg < brg)
                    m_dEBLAngle = hdg - brg;
                else m_dEBLAngle = 0;
            }
        }
    } else {
        DistanceBearingMercator_Plugin(pEndPoint->m_lat, pEndPoint->m_lon, pStartPoint->m_lat, pStartPoint->m_lon, &m_dEBLAngle, &m_dLength);
        m_dBoatHeading = g_pfFix.Hdt;
        m_dBoatCOG = g_pfFix.Cog;
    }
    pStartPoint->m_ODPointName = _("Boat");
    m_bCentreOnBoat = true;
    
    UpdateEBL();
    if(m_bVRM) {
        ODPoint *pStartPoint = m_pODPointList->GetFirst()->GetData();
        pStartPoint->SetODPointRangeRingsStep( m_dLength / pStartPoint->GetODPointRangeRingsNumber() );
    }
    
    bool l_bRequestRefresh = true;
    if(g_pEBLPropDialog && g_pEBLPropDialog->IsShown())
        l_bRequestRefresh = g_pEBLPropDialog->UpdateProperties();
    
    m_bSaveUpdates = false;
    if(l_bRequestRefresh)
        RequestRefresh( g_ocpn_draw_pi->m_parent_window );
    
    return;
}
示例#2
0
void EBL::MoveEndPoint( bool bUpdateEBL )
{
    ODPoint *pEndPoint = m_pODPointList->GetLast()->GetData();
    ODPoint *pStartPoint = m_pODPointList->GetFirst()->GetData();

    if(m_dLength == 0.) m_dLength = pEndPoint->m_seg_len;
    
    if(m_bRotateWithBoat) {
        MaintainWith();
    } else {
        if(!m_bFixedEndPosition)
            PositionBearingDistanceMercator_Plugin(pStartPoint->m_lat, pStartPoint->m_lon, m_dEBLAngle, m_dLength, &pEndPoint->m_lat, &pEndPoint->m_lon);
    }
    
    if(m_bVRM)
        pStartPoint->SetODPointRangeRingsStep( m_dLength / pStartPoint->GetODPointRangeRingsNumber() );
    
    if(g_pEBLPropDialog && g_pEBLPropDialog->IsShown())
        g_pEBLPropDialog->UpdateProperties();
    
    if(bUpdateEBL) {
        bool l_bSaveUpdatesState = m_bSaveUpdates;
        m_bSaveUpdates = true;
        UpdateEBL();
        m_bSaveUpdates = l_bSaveUpdatesState;
    } else
        UpdateEBL();
}
示例#3
0
void EBL::MoveEndPoint( void )
{
    ODPoint *pEndPoint = m_pODPointList->GetLast()->GetData();
    ODPoint *pStartPoint = m_pODPointList->GetFirst()->GetData();
    DistanceBearingMercator_Plugin(pEndPoint->m_lat, pEndPoint->m_lon, pStartPoint->m_lat, pStartPoint->m_lon, &m_dEBLAngle, &m_dLength);
    if(m_bRotateWithBoat) {
        switch(m_iMaintainWith) {
            case ID_EBL_MAINTAIN_WITH_HEADING:
                m_dEBLAngle -= g_pfFix.Hdt;
                break;
            case ID_EBL_MAINTAIN_WITH_COG:
                m_dEBLAngle -= g_pfFix.Cog;
                break;
        }
    }
    m_dBoatHeading = g_pfFix.Hdt;
    m_dBoatCOG = g_pfFix.Cog;

    if(m_bVRM) {
        ODPoint *pStartPoint = m_pODPointList->GetFirst()->GetData();
        pStartPoint->SetODPointRangeRingsStep( m_dLength / pStartPoint->GetODPointRangeRingsNumber() );
    }
    if(g_pEBLPropDialog && g_pEBLPropDialog->IsShown())
        g_pEBLPropDialog->UpdateProperties();
    
}
示例#4
0
void EBL::DrawGL( PlugIn_ViewPort &piVP )
{
    if(m_bVRM) {
        ODPoint *pStartPoint = m_pODPointList->GetFirst()->GetData();
        ODPoint *pEndPoint = m_pODPointList->GetLast()->GetData();
        pStartPoint->SetODPointRangeRingsStep( pEndPoint->m_seg_len / pStartPoint->GetODPointRangeRingsNumber() );
    }
    ODPath::DrawGL( piVP );
}
示例#5
0
void EBL::MoveEndPoint( double inc_lat, double inc_lon )
{
    ODPoint *pEndPoint = m_pODPointList->GetLast()->GetData();
    pEndPoint->m_lat -= inc_lat;
    pEndPoint->m_lon -= inc_lon;
    if(m_bVRM) {
        ODPoint *pStartPoint = m_pODPointList->GetFirst()->GetData();
        pStartPoint->SetODPointRangeRingsStep( pEndPoint->m_seg_len / pStartPoint->GetODPointRangeRingsNumber() );
    }
    if(g_pEBLPropDialog && g_pEBLPropDialog->IsShown())
        g_pEBLPropDialog->UpdateProperties();
}
示例#6
0
BoundaryPoint *PointMan::FindLineCrossingBoundaryPtr( double StartLon, double StartLat, double EndLon, double EndLat, int type, int state )
{
    // search boundary point
    wxODPointListNode *node = GetODPointList()->GetFirst();
    while( node ) {
        ODPoint *od = static_cast<ODPoint *>(node->GetData());
        if( od->IsListed() ) {
            if( od->m_bIsInPath && !od->m_bKeepXPath ) {
                node = node->GetNext();
                continue;
            }
            // if there's no ring there's nothing to do
            if (!od->GetShowODPointRangeRings() || 
                    od->GetODPointRangeRingsNumber() == 0 ||
                    od->GetODPointRangeRingsStep() == 0.f)
            {
                node = node->GetNext();
                continue;
            }
            BoundaryPoint *op = dynamic_cast<BoundaryPoint *>(node->GetData());
            if (!op) {
                node = node->GetNext();
                continue;
            }
            bool l_bNext = false;
            switch (type) {
                case ID_BOUNDARY_ANY:
                    l_bNext = false;
                    break;
                case ID_BOUNDARY_EXCLUSION:
                    if(!op->m_bExclusionBoundaryPoint) l_bNext = true;
                    break;
                case ID_BOUNDARY_INCLUSION:
                    if(!op->m_bInclusionBoundaryPoint) l_bNext = true;
                    break;
                case ID_BOUNDARY_NIETHER:
                    if(op->m_bExclusionBoundaryPoint || op->m_bInclusionBoundaryPoint) l_bNext = true;
                    break;
            }
            if (!l_bNext) {
               // 0 nautical miles 1 kilometer
               double f = (op->m_iODPointRangeRingsStepUnits == 1)?1000.0:1852.31;
               // in meters
               double dst = op->GetODPointRangeRingsNumber() * op->GetODPointRangeRingsStep() * f;
               if (DistancePointLine( op->m_lon, op->m_lat, StartLon, StartLat, EndLon, EndLat, dst )) {
                  return op;
               }
            }
        }
        node = node->GetNext();
    }
    return 0;
}
示例#7
0
void EBL::CentreOnBoat( void )
{
    ODPoint *pStartPoint = m_pODPointList->GetFirst()->GetData();
    pStartPoint->m_lat = g_pfFix.Lat;
    pStartPoint->m_lon = g_pfFix.Lon;
    pStartPoint->m_ODPointName = _("Boat");
    m_bCentreOnBoat = true;
    
    UpdateEBL();
    if(m_bVRM) {
        ODPoint *pStartPoint = m_pODPointList->GetFirst()->GetData();
        ODPoint *pEndPoint = m_pODPointList->GetLast()->GetData();
        pStartPoint->SetODPointRangeRingsStep( pEndPoint->m_seg_len / pStartPoint->GetODPointRangeRingsNumber() );
    }
    
    if(g_pEBLPropDialog && g_pEBLPropDialog->IsShown())
        g_pEBLPropDialog->UpdateProperties();

    m_bSaveUpdates = false;
    RequestRefresh( g_ocpn_draw_pi->m_parent_window );
    
    return;
}
示例#8
0
void EBL::MoveStartPoint( double lat, double lon )
{
    ODPoint *pEndPoint = m_pODPointList->GetLast()->GetData();
    ODPoint *pStartPoint = m_pODPointList->GetFirst()->GetData();
    pStartPoint->m_lat = lat;
    pStartPoint->m_lon = lon;
    if(m_dLength == 0.) m_dLength = pEndPoint->m_seg_len;
    
    if(m_bRotateWithBoat){
        MaintainWith();
    } else {
        PositionBearingDistanceMercator_Plugin(pStartPoint->m_lat, pStartPoint->m_lon, m_dEBLAngle, m_dLength, &pEndPoint->m_lat, &pEndPoint->m_lon);
    }
    
    
    if(m_bVRM) {
        ODPoint *pStartPoint = m_pODPointList->GetFirst()->GetData();
        pStartPoint->SetODPointRangeRingsStep( m_dLength / pStartPoint->GetODPointRangeRingsNumber() );
    }
    if(g_pEBLPropDialog && g_pEBLPropDialog->IsShown())
        g_pEBLPropDialog->UpdateProperties();
    
}