bool ODSelect::DeleteSelectablePoint( void *pdata, int SeltypeToDelete ) { SelectItem *pFindSel; if( NULL != pdata ) { // Iterate on the list wxSelectableItemListNode *node = pSelectList->GetFirst(); while( node ) { pFindSel = node->GetData(); if( pFindSel->m_seltype == SeltypeToDelete ) { if( pdata == pFindSel->m_pData1 ) { delete pFindSel; delete node; g_pRolloverPoint = NULL; if( SELTYPE_ODPOINT == SeltypeToDelete ){ ODPoint *prp = (ODPoint *)pdata; prp->SetSelectNode( NULL ); } return true; } } node = node->GetNext(); } } return false; }
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(); }
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 ); }
bool ODSelect::DeleteAllSelectableTypePoints( int SeltypeToDelete ) { SelectItem *pFindSel; // Iterate on the list wxSelectableItemListNode *node = pSelectList->GetFirst(); while( node ) { pFindSel = node->GetData(); if( pFindSel->m_seltype == SeltypeToDelete ) { delete node; if( SELTYPE_ODPOINT == SeltypeToDelete ){ ODPoint *prp = (ODPoint *)pFindSel->m_pData1; prp->SetSelectNode( NULL ); } delete pFindSel; node = pSelectList->GetFirst(); goto got_next_node; } node = node->GetNext(); got_next_node: continue; } return true; }
bool ODSelect::DeleteAllSelectableODPoints( ODPath *pr ) { SelectItem *pFindSel; // Iterate on the select list wxSelectableItemListNode *node = pSelectList->GetFirst(); while( node ) { pFindSel = node->GetData(); if( pFindSel->m_seltype == SELTYPE_ODPOINT ) { ODPoint *ps = (ODPoint *) pFindSel->m_pData1; // inner loop iterates on the path's point list wxODPointListNode *pnode = ( pr->m_pODPointList )->GetFirst(); while( pnode ) { ODPoint *prp = pnode->GetData(); if( prp == ps ) { delete pFindSel; pSelectList->DeleteNode( node ); //delete node; prp->SetSelectNode( NULL ); node = pSelectList->GetFirst(); goto got_next_outer_node; } pnode = pnode->GetNext(); } } node = node->GetNext(); got_next_outer_node: continue; } return true; }
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; }
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(); }
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 ); }
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(); }
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; }
void PointMan::SetColorScheme( PI_ColorScheme cs ) { //ProcessIcons( g_ODStyleManager->GetCurrentStyle() ); // Iterate on the ODPoint list, requiring each to reload icon m_ColourScheme = cs; wxODPointListNode *node = m_pODPointList->GetFirst(); while( node ) { ODPoint *pr = node->GetData(); pr->SetColourScheme(cs); pr->ReLoadIcon(); node = node->GetNext(); } }
void EBL::AddPoint( ODPoint *pNewPoint, bool b_rename_in_sequence, bool b_deferBoxCalc, bool b_isLoading ) { ODPath::AddPoint( pNewPoint, b_rename_in_sequence, b_deferBoxCalc, b_isLoading ); if(pNewPoint->m_ODPointName == _("Start") || pNewPoint->m_ODPointName == _("Boat")) { pNewPoint->SetODPointRangeRingsNumber( 1 ); pNewPoint->SetODPointRangeRingsStep( 0 ); pNewPoint->SetODPointRangeRingsColour( GetCurrentColour() ); if(m_bVRM) pNewPoint->m_bShowODPointRangeRings = true; else pNewPoint->m_bShowODPointRangeRings = false; } else if(pNewPoint->m_ODPointName == _("End")) { ODPoint *pFirstPoint = m_pODPointList->GetFirst()->GetData(); pFirstPoint->SetODPointRangeRingsStep( pNewPoint->m_seg_len ); } }
void PathProp::OnPathPropMenuSelected( wxCommandEvent& event ) { switch( event.GetId() ) { case ID_PATHPROP_MENU_DELETE: { long item = -1; item = m_opList->GetNextItem( item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED ); if( item == -1 ) break; ODPoint *op; op = (ODPoint *) m_opList->GetItemData( item ); wxString sMessage( wxS("Are you sure you want to remove this ") ); wxString sCaption( wxS("OCPN Draw Remove ") ); wxString sType( wxS("") ); if (!op || op->GetTypeString().IsNull() || op->GetTypeString().IsEmpty() ) sType.append( wxS("Point") ); else sType.append( op->GetTypeString() ); sMessage.append( sType ); sMessage.append( wxS("?") ); sCaption.append( sType ); int dlg_return = OCPNMessageBox_PlugIn( this, sMessage, sCaption, (long) wxYES_NO | wxCANCEL | wxYES_DEFAULT ); if( dlg_return == wxID_YES ) { m_pPath->RemovePointFromPath( op, m_pPath ); } break; } case ID_PATHPROP_MENU_EDIT_WP: { long item = -1; item = m_opList->GetNextItem( item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED ); if( item == -1 ) break; ODPoint *op = (ODPoint *) m_opList->GetItemData( item ); if( !op ) break; PathManagerDialog::ODPointShowPropertiesDialog( op, this ); break; } } }
void EBL::CentreOnLatLon( double lat, double lon ) { ODPoint *pStartPoint = m_pODPointList->GetFirst()->GetData(); pStartPoint->m_lat = lat; pStartPoint->m_lon = lon; pStartPoint->m_ODPointName = _("Start"); if(pStartPoint->GetIconName() != wxEmptyString) { pStartPoint->SetIconName( g_sEBLStartIconName ); pStartPoint->ReLoadIcon(); } m_bCentreOnBoat = false; m_bSaveUpdates = true; UpdateEBL(); if(g_pEBLPropDialog && g_pEBLPropDialog->IsShown()) g_pEBLPropDialog->UpdateProperties(); RequestRefresh( g_ocpn_draw_pi->m_parent_window ); return; }
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; }
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(); }
void PointMan::DeleteAllODPoints( bool b_delete_used ) { // Iterate on the ODPoint list, deleting all wxODPointListNode *node = m_pODPointList->GetFirst(); while( node ) { ODPoint *prp = node->GetData(); // if argument is false, then only delete non-path ODPoints if( !prp->m_bIsInLayer && ( prp->GetIconName() != _T("mob") ) && ( ( b_delete_used && prp->m_bKeepXPath ) || !prp->m_bIsInPath ) ) { DestroyODPoint(prp); if(prp->m_sTypeString == wxT("ODPoint")) delete prp; else if(prp->m_sTypeString == wxT("Text Point")) { delete (TextPoint *)node->GetData(); } node = m_pODPointList->GetFirst(); } else node = node->GetNext(); } return; }
void EBL::CentreOnLatLon( double lat, double lon ) { ODPoint *pStartPoint = m_pODPointList->GetFirst()->GetData(); ODPoint *pEndPoint = m_pODPointList->GetLast()->GetData(); pStartPoint->m_lat = lat; pStartPoint->m_lon = lon; DistanceBearingMercator_Plugin(pEndPoint->m_lat, pEndPoint->m_lon, pStartPoint->m_lat, pStartPoint->m_lon, &m_dEBLAngle, &m_dLength); m_bRotateWithBoat = false; m_bCentreOnBoat = false; pStartPoint->m_ODPointName = _("Start"); if(pStartPoint->GetIconName() != wxEmptyString) { pStartPoint->SetIconName( g_sEBLStartIconName ); pStartPoint->ReLoadIcon(); } m_bCentreOnBoat = false; m_bSaveUpdates = true; UpdateEBL(); if(g_pEBLPropDialog && g_pEBLPropDialog->IsShown()) g_pEBLPropDialog->UpdateProperties(); RequestRefresh( g_ocpn_draw_pi->m_parent_window ); return; }
bool PathProp::UpdateProperties( Path *pPath ) { if( NULL == pPath ) return false; ::wxBeginBusyCursor(); m_PathNameCtl->SetValue( pPath->m_PathNameString ); m_textDescription->SetValue( pPath->m_PathDescription); m_pPathActive->SetValue( pPath->IsActive() ); double brg; double join_distance = 0.; ODPoint *first_point = pPath->GetPoint( 1 ); if( first_point ) DistanceBearingMercator_Plugin( first_point->m_lat, first_point->m_lon, g_dLat, g_dLon, &brg, &join_distance ); // Update the "tides event" column header wxListItem column_info; if( m_opList->GetColumn( 6, column_info ) ) { wxString c = _("Next tide event"); if( gpIDX && m_starttime.IsValid() ) { c = _T("@~~"); c.Append( wxString( gpIDX->IDX_station_name, wxConvUTF8 ) ); int i = c.Find( ',' ); if( i != wxNOT_FOUND ) c.Remove( i ); } column_info.SetText( c ); m_opList->SetColumn( 6, column_info ); } // Total length double total_length = pPath->m_path_length; wxString slen; slen.Printf( wxT("%5.2f ") + getUsrDistanceUnit_Plugin(), toUsrDistance_Plugin( total_length ) ); m_TotalDistCtl->SetValue( slen ); wxString time_form; wxString tide_form; // Iterate on Route Points wxODPointListNode *node = pPath->m_pODPointList->GetFirst(); int i = 0; double slat = g_dLat; double slon = g_dLon; int stopover_count = 0; bool arrival = true; // marks which pass over the wpt we do - 1. arrival 2. departure bool enroute = true; // for active route, skip all points up to the active point wxString nullify = _T("----"); while( node ) { ODPoint *prp = node->GetData(); long item_line_index = i + stopover_count; // Leg wxString t; t.Printf( _T("%d"), i ); if( i == 0 ) t = _T("Boat"); if( arrival ) m_opList->SetItem( item_line_index, 0, t ); // Mark Name if( arrival ) m_opList->SetItem( item_line_index, 1, prp->GetName() ); // Store Dewcription if( arrival ) m_opList->SetItem( item_line_index, 8, prp->GetDescription() ); // Distance // Note that Distance/Bearing for Leg 000 is as from current position double brg, leg_dist; bool starting_point = false; starting_point = ( i == 0 ) && enroute; if( m_pEnroutePoint && !starting_point ) starting_point = ( prp->m_GUID == m_pEnroutePoint->m_GUID ); DistanceBearingMercator_Plugin( prp->m_lat, prp->m_lon, slat, slon, &brg, &leg_dist ); // calculation of course at current WayPoint. double course=10, tmp_leg_dist=23; wxODPointListNode *next_node = node->GetNext(); ODPoint * _next_prp = (next_node)? next_node->GetData(): NULL; if (_next_prp ) { DistanceBearingMercator_Plugin( _next_prp->m_lat, _next_prp->m_lon, prp->m_lat, prp->m_lon, &course, &tmp_leg_dist ); }else { course = 0.0; tmp_leg_dist = 0.0; } //prp->SetCourse(course); // save the course to the next waypoint for printing. // end of calculation t.Printf( _T("%6.2f ") + getUsrDistanceUnit_Plugin(), toUsrDistance_Plugin( leg_dist ) ); if( arrival ) m_opList->SetItem( item_line_index, 2, t ); if( !enroute ) m_opList->SetItem( item_line_index, 2, nullify ); prp->SetDistance(leg_dist); // save the course to the next waypoint for printing. // Bearing if( g_bShowMag ) t.Printf( _T("%03.0f Deg. M"), g_ocpn_draw_pi->GetTrueOrMag( brg ) ); else t.Printf( _T("%03.0f Deg. T"), g_ocpn_draw_pi->GetTrueOrMag( brg ) ); // if( arrival ) // m_opList->SetItem( item_line_index, 3, t ); // if( !enroute ) // m_opList->SetItem( item_line_index, 3, nullify ); // Course (bearing of next ) if (_next_prp){ if( g_bShowMag ) t.Printf( _T("%03.0f Deg. M"), g_ocpn_draw_pi->GetTrueOrMag( course ) ); else t.Printf( _T("%03.0f Deg. T"), g_ocpn_draw_pi->GetTrueOrMag( course ) ); if( arrival ) m_opList->SetItem( item_line_index, 7, t ); } else m_opList->SetItem( item_line_index, 7, nullify ); // Lat/Lon wxString tlat = toSDMM_PlugIn( 1, prp->m_lat, prp->m_bIsInTrack ); // low precision for routes if( arrival ) m_opList->SetItem( item_line_index, 4, tlat ); wxString tlon = toSDMM_PlugIn( 2, prp->m_lon, prp->m_bIsInTrack ); if( arrival ) m_opList->SetItem( item_line_index, 5, tlon ); tide_form = _T(""); //LMT_Offset = long( ( prp->m_lon ) * 3600. / 15. ); // Save for iterating distance/bearing calculation slat = prp->m_lat; slon = prp->m_lon; // if stopover (ETD) found, loop for next output line for the same point // with departure time & tide information if( arrival && ( prp->m_seg_etd.IsValid() ) ) { stopover_count++; arrival = false; } else { arrival = true; i++; node = node->GetNext(); } } if( pPath->m_ActiveLineColour == wxEmptyString ) m_chColor->Select( 0 ); else { for( unsigned int i = 0; i < sizeof( ::GpxxColorNames ) / sizeof(wxString); i++ ) { if( pPath->m_ActiveLineColour == ::GpxxColorNames[i] ) { m_chColor->Select( i + 1 ); break; } } } if( pPath->m_ActiveFillColour == wxEmptyString ) m_chLineColor->Select( 0 ); else { for( unsigned int i = 0; i < sizeof( ::GpxxColorNames ) / sizeof(wxString); i++ ) { if( pPath->m_ActiveFillColour == ::GpxxColorNames[i] ) { m_chLineColor->Select( i + 1 ); break; } } } for( unsigned int i = 0; i < sizeof( ::StyleValues ) / sizeof(int); i++ ) { if( pPath->m_style == ::StyleValues[i] ) { m_chStyle->Select( i ); break; } } for( unsigned int i = 0; i < sizeof( ::WidthValues ) / sizeof(int); i++ ) { if( pPath->m_width == ::WidthValues[i] ) { m_chWidth->Select( i ); break; } } ::wxEndBusyCursor(); return true; }
bool EBLProp::SaveChanges( void ) { wxColour l_EBLOrigColour = m_pEBL->GetCurrentColour(); ODPoint *pFirstPoint = m_pEBL->m_pODPointList->GetFirst()->GetData(); bool l_bUpdatePath = false; double l_dLength; m_textCtrlTotalLength->GetValue().ToDouble( &l_dLength ); l_dLength = fromUsrDistance_Plugin( l_dLength ); if(m_pEBL->m_dLength != l_dLength) { l_bUpdatePath = true; m_pEBL->m_dLength = l_dLength; } if(pFirstPoint->GetODPointRangeRingsColour() == l_EBLOrigColour) pFirstPoint->SetODPointRangeRingsColour( m_pEBL->GetCurrentColour() ); m_pEBL->m_bFixedEndPosition = m_checkBoxEBLFixedEndPosition->GetValue(); m_pEBL->m_iPersistenceType = m_radioBoxPathPersistence->GetSelection(); if(m_pEBL->m_iPersistenceType == ID_NOT_PERSISTENT || m_pEBL->m_iPersistenceType == ID_PERSISTENT_CRASH) m_pEBL->m_bTemporary = true; else m_pEBL->m_bTemporary = false; m_pEBL->m_bRotateWithBoat = m_checkBoxRotateWithBoat->GetValue(); if(m_pEBL->m_bRotateWithBoat) m_pEBL->m_bFixedEndPosition = false; m_pEBL->m_iMaintainWith = m_radioBoxMaintainWith->GetSelection(); double l_dEBLAngle; m_textCtrlEBLAngle->GetValue().ToDouble( &l_dEBLAngle ); if(m_pEBL->m_bRotateWithBoat) { if(l_dEBLAngle != m_pEBL->m_dEBLAngle) { l_bUpdatePath = true; m_pEBL->m_dEBLAngle = l_dEBLAngle; } } else if(!m_pEBL->m_bFixedEndPosition) { switch (m_pEBL->m_iMaintainWith) { case ID_MAINTAIN_WITH_HEADING: m_pEBL->m_dEBLAngle = l_dEBLAngle + g_pfFix.Hdm; break; case ID_MAINTAIN_WITH_COG: m_pEBL->m_dEBLAngle = l_dEBLAngle + g_pfFix.Cog; break; } } if(l_bUpdatePath) m_pEBL->MoveEndPoint(true); m_pEBL->m_bDrawArrow = m_checkBoxPathShowArrow->GetValue(); m_pEBL->m_bVRM = m_checkBoxShowVRM->GetValue(); m_pEBL->m_bAlwaysShowInfo = m_checkBoxShowEBLInfo->GetValue(); if(m_pEBL->m_bVRM) { pFirstPoint->m_bShowODPointRangeRings = true; } else pFirstPoint->m_bShowODPointRangeRings = false; m_pEBL->m_bPerpLine = m_checkBoxShowPerpLine->GetValue(); bool ret = ODPathPropertiesDialogImpl::SaveChanges(); return ret; }
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 }