bool EBLProp::UpdateProperties( EBL *pInEBL ) { SetGlobalLocale(); wxString s; m_checkBoxEBLFixedEndPosition->SetValue( pInEBL->m_bFixedEndPosition ); m_radioBoxPathPersistence->SetSelection( pInEBL->m_iPersistenceType ); m_checkBoxPathShowArrow->SetValue( pInEBL->m_bDrawArrow ); m_checkBoxShowVRM->SetValue( pInEBL->m_bVRM ); m_checkBoxShowEBLInfo->SetValue( pInEBL->m_bAlwaysShowInfo ); m_checkBoxShowPerpLine->SetValue( pInEBL->m_bPerpLine ); m_checkBoxRotateWithBoat->SetValue( pInEBL->m_bRotateWithBoat ); m_radioBoxMaintainWith->SetSelection( pInEBL->m_iMaintainWith ); if(pInEBL->m_bCentreOnBoat) m_checkBoxRotateWithBoat->Enable(true); else m_checkBoxRotateWithBoat->Enable(false); if(pInEBL->m_bFixedEndPosition) { m_radioBoxMaintainWith->Enable(false); m_textCtrlEBLAngle->Enable(false); m_textCtrlTotalLength->SetEditable(false); } else { m_radioBoxMaintainWith->Enable(true); m_textCtrlEBLAngle->Enable(true); m_textCtrlTotalLength->SetEditable(true); } #if wxCHECK_VERSION(3,0,0) && !defined(__WXMSW__) if(pInEBL->m_dEBLAngle > 180) m_dODEBLAngleValidator = pInEBL->m_dEBLAngle - 360; else m_dODEBLAngleValidator = pInEBL->m_dEBLAngle; m_dODEBLLengthValidator = toUsrDistance_Plugin(pInEBL->m_dLength); #else if(pInEBL->m_dEBLAngle > 180) s.Printf( _T("%.2f"), pInEBL->m_dEBLAngle - 360 ); else s.Printf( _T("%.2f"), pInEBL->m_dEBLAngle ); m_textCtrlEBLAngle->SetValue(s); s.Printf( _T("%5.2f"), toUsrDistance_Plugin(m_pEBL->m_dLength) ); m_textCtrlTotalLength->SetValue(s); #endif if(pInEBL->m_bRotateWithBoat) { m_checkBoxEBLFixedEndPosition->Enable(false); } else { m_checkBoxEBLFixedEndPosition->Enable(true); } m_bLockUpdate = false; ResetGlobalLocale(); return ODPathPropertiesDialogImpl::UpdateProperties( pInEBL ); }
void TacticsInstrument_FromOwnship::SetData(int st, double data, wxString unit) { if (st == m_cap_flag1) { c_lat = data; } else if (st == m_cap_flag2) { c_lon = data; } else if (st == m_cap_flag3) { s_lat = data; } else if (st == m_cap_flag4) { s_lon = data; } else return; if ( s_lat < 99999999 && s_lon < 99999999 ) { double brg,dist; DistanceBearingMercator_Plugin(c_lat, c_lon, s_lat, s_lon, &brg, &dist); m_data1.Printf(_T("%03d ") + DEGREE_SIGN,(int)brg); m_data2.Printf(_T("%3.2f %s"), toUsrDistance_Plugin(dist, g_iDashDistanceUnit), getUsrDistanceUnit_Plugin(g_iDashDistanceUnit).c_str()); } Refresh(false); }
void ObjSearchDialogImpl::AddObject(const wxString& feature, const wxString& objectname, double lat, double lon, double dist, double scale, int nativescale, const wxString& chart) { wxListItem item; int n = m_listCtrlResults->GetItemCount(); item.SetId(n); item.SetText( objectname ); m_listCtrlResults->InsertItem( item ); m_listCtrlResults->SetItem(n, 0, HumanizeFeatureName(feature)); m_listCtrlResults->SetItem(n, 1, objectname); m_listCtrlResults->SetItem(n, 2, toSDMM_PlugIn(1, lat)); m_listCtrlResults->SetItem(n, 3, toSDMM_PlugIn(2, lon)); m_listCtrlResults->SetItem(n, 4, wxString::Format(_T("%.1f"), toUsrDistance_Plugin(dist, -1))); m_listCtrlResults->SetItem(n, 5, wxString::Format(_T("%.4f"), scale)); m_listCtrlResults->SetItem(n, 6, wxString::Format(_T("%i"), nativescale)); m_listCtrlResults->SetItem(n, 7, chart); m_listCtrlResults->SetItemData(n, (int) (dist * 10) ); }
bool EBLProp::UpdateProperties( void ) { wxString s; if(m_bLockUpdate) return true; ODPathPropertiesDialogImpl::UpdateProperties(); if(!m_bLockEBLAngle){ if(m_pEBL->m_dEBLAngle > 180) s.Printf( _T("%.2f"), m_pEBL->m_dEBLAngle - 360 ); else s.Printf( _T("%.2f"), m_pEBL->m_dEBLAngle ); m_textCtrlEBLAngle->SetValue(s); } if(!m_bLockEBLLength) { s.Printf( _T("%.2f"), toUsrDistance_Plugin(m_pEBL->m_dLength) ); m_textCtrlTotalLength->SetValue(s); } return true; }
void objsearch_pi::FindObjects( const wxString& feature_filter, const wxString& search_string, double lat, double lon, double dist ) { if (!m_bDBUsable) { wxMessageBox(_("There is a problem with your database, check the OpenCPN logfile for more information.")); return; } m_pObjSearchDialog->ClearObjects(); wxString safe_value = search_string; safe_value.Replace(_T("'"), _T("''")); wxSQLite3ResultSet set; if ( dist > 0.1 ) set = SelectFromDB( m_db, wxString::Format( wxT("SELECT COUNT(*) FROM object o LEFT JOIN feature f ON (o.feature_id = f.id) WHERE instr('%s', featurename) > 0 AND objname LIKE '%%%s%%' AND distanceMercator(lat, lon, %f, %f) <= %f"), feature_filter.c_str(), safe_value.c_str(), lat, lon, dist ) ); else set = SelectFromDB( m_db, wxString::Format( wxT("SELECT COUNT(*) FROM object o LEFT JOIN feature f ON (o.feature_id = f.id) WHERE instr('%s', featurename) > 0 AND objname LIKE '%%%s%%'"), feature_filter.c_str(), safe_value.c_str() ) ); int objects_found = 0; if (m_bDBUsable) { objects_found = set.GetInt(0); } set.Finalize(); int show = wxYES; if ( objects_found > 1000 ) { show = wxMessageBox( wxString::Format( _("Your search resulted in %i objects found. This is a lot, do you really want to show all of them?"), objects_found ), _("Too many objects found"), wxYES_NO | wxCENTER ); } if ( show == wxYES ) { if (m_bDBUsable) { if ( dist > 0.1 ) set = SelectFromDB( m_db, wxString::Format( wxT("SELECT f.featurename, o.objname, o.lat, o.lon, ch.scale, ch.nativescale, ch.chartname, distanceMercator(lat, lon, %f, %f) FROM object o LEFT JOIN feature f ON (o.feature_id = f.id) LEFT JOIN chart ch ON (o.chart_id = ch.id) WHERE instr('%s', featurename) > 0 AND objname LIKE '%%%s%%' AND distanceMercator(lat, lon, %f, %f) <= %f"),lat, lon, feature_filter.c_str(), safe_value.c_str(), lat, lon, dist ) ); else set = SelectFromDB( m_db, wxString::Format( wxT("SELECT f.featurename, o.objname, o.lat, o.lon, ch.scale, ch.nativescale, ch.chartname, distanceMercator(lat, lon, %f, %f) FROM object o LEFT JOIN feature f ON (o.feature_id = f.id) LEFT JOIN chart ch ON (o.chart_id = ch.id) WHERE instr('%s', featurename) > 0 AND objname LIKE '%%%s%%'"), lat, lon, feature_filter.c_str(), safe_value.c_str() ) ); if (m_bDBUsable) { while (set.NextRow()) { m_pObjSearchDialog->AddObject( set.GetAsString(0), set.GetAsString(1), set.GetDouble(2), set.GetDouble(3), toUsrDistance_Plugin(set.GetDouble(7)), set.GetDouble(4), set.GetInt(5), set.GetAsString(6) ); } m_pObjSearchDialog->SortResults(); } set.Finalize(); } } }
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; }
void TacticsInstrument_BearingCompass::SetData(int st, double data, wxString unit) { if (st == OCPN_DBP_STC_COG) { m_Cog = data; } else if (st == OCPN_DBP_STC_HDT) { m_AngleStart = -data; m_MainValue = data; m_MainValueUnit = unit; m_Hdt = data; } else if (st == OCPN_DBP_STC_CURRDIR) { m_CurrDir = data; m_CurrDirUnit = unit; } else if (st == OCPN_DBP_STC_CURRSPD) { m_CurrSpeed = data; m_CurrSpeedUnit = unit; } else if (st == OCPN_DBP_STC_DTW) { if (!GetSingleWaypoint(_T("TacticsWP"), m_pMark)){ m_ExtraValueDTW = data; m_ExtraValueDTWUnit = unit; } } else if (st == OCPN_DBP_STC_TWA) { m_curTack = unit; m_TWA = data; } else if (st == OCPN_DBP_STC_TWD) { m_TWD = data; } else if (st == OCPN_DBP_STC_AWA) { m_AWA = data; } else if (st == OCPN_DBP_STC_TWS) { m_TWS = data; } else if (st == OCPN_DBP_STC_LEEWAY) { m_Leeway = data; m_LeewayUnit = unit; } else if (st == OCPN_DBP_STC_LAT) { m_lat = data; } else if (st == OCPN_DBP_STC_LON) { m_lon = data; } else if (st == OCPN_DBP_STC_STW) { m_StW = data; } if (m_Cog != -999 && m_Hdt != -999){ m_diffCogHdt = m_Cog - m_Hdt; } if (st == OCPN_DBP_STC_BRG) { //if (!GetSingleWaypoint(_T("TacticsWP"), m_pMark)){ m_Bearing = data; m_ToWpt = unit; /*} else{ if (m_pMark) { double dist; DistanceBearingMercator_Plugin(m_pMark->m_lat, m_pMark->m_lon, m_lat, m_lon, &m_Bearing, &dist); m_ToWpt = _T("TacticsWP"); m_ExtraValueDTW = toUsrDistance_Plugin(dist, g_iDashDistanceUnit); m_ExtraValueDTWUnit = getUsrDistanceUnit_Plugin(g_iDashDistanceUnit); } }*/ m_BearingUnit = _T("\u00B0"); } if (!GetSingleWaypoint(_T("TacticsWP"), m_pMark)) m_pMark = NULL; if (m_pMark && !wxIsNaN(m_lat) && !wxIsNaN(m_lon)) { double dist; DistanceBearingMercator_Plugin(m_pMark->m_lat, m_pMark->m_lon, m_lat, m_lon, &m_Bearing, &dist); m_ToWpt = _T("TacticsWP"); m_ExtraValueDTW = toUsrDistance_Plugin(dist, g_iDashDistanceUnit); m_ExtraValueDTWUnit = getUsrDistanceUnit_Plugin(g_iDashDistanceUnit); m_BearingUnit = _T("\u00B0"); } if (!m_pMark && wxIsNaN(m_Bearing)){ m_ToWpt = _T("---"); m_ExtraValueDTW = NAN; m_predictedSog = NAN; m_ExtraValueDTWUnit = getUsrDistanceUnit_Plugin(g_iDashDistanceUnit); m_BearingUnit = _T("\u00B0"); } CalculateLaylineDegreeRange(); }