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) ); }
void GRIBTable::InitGribTable( int zone, ArrayOfGribRecordSets *rsa ) { //init fonts and colours wxFont dayfont = wxFont( 11, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD ); wxFont labelfont = wxFont( 10, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD ); wxFont timefont = wxFont( 9, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD ); wxFont datafont = wxFont( 9, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL ); wxColour colour; GetGlobalColor(_T("DILG1"), &colour); //populate "cursor position" display wxString l; l.Append(toSDMM_PlugIn(1, m_pGDialog->m_cursor_lat)).Append(_T(" ")) .Append(toSDMM_PlugIn(2, m_pGDialog->m_cursor_lon)); m_pCursorPosition->SetLabel(l); m_pCursorPosition->SetFont(wxFont(10, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL)); m_pPositionText->SetFont(wxFont(10, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL)); //init row attr wxGridCellAttr *daysrow = new wxGridCellAttr(); daysrow->SetFont(dayfont); daysrow->SetBackgroundColour(colour); daysrow->SetAlignment(wxALIGN_CENTRE, wxALIGN_CENTRE); wxGridCellAttr *timerow = new wxGridCellAttr(); timerow->SetFont(timefont); timerow->SetBackgroundColour(colour); timerow->SetAlignment(wxALIGN_CENTRE, wxALIGN_CENTRE); wxGridCellAttr *singledatarow = new wxGridCellAttr(); singledatarow->SetFont(datafont); singledatarow->SetAlignment(wxALIGN_CENTRE, wxALIGN_CENTRE); wxGridCellAttr *doubledatarow = new wxGridCellAttr(); doubledatarow->SetFont(datafont); doubledatarow->SetAlignment(wxALIGN_CENTRE, -1); //init labels m_pGribTable->SetLabelFont(labelfont); m_pGribTable->SetLabelBackgroundColour(colour); //create as columns as necessary m_pGribTable->AppendCols(rsa->GetCount()); m_pGribTable->SetSelectionBackground(colour); m_pGribTable->SetSelectionForeground(m_pGribTable->GetDefaultCellTextColour()); //init days row m_pGribTable->SetRowLabelValue(0, wxEmptyString); m_pGribTable->SetRowAttr(0, daysrow); //init time row m_pGribTable->SetRowLabelValue(1, wxEmptyString); m_pGribTable->SetRowAttr(1, timerow); //populate grib wxDateTime day(rsa->Item(0).m_Reference_Time); wxDateTime time; int ncols = -1,nrows,dcol = 0; for(unsigned i = 0; i < rsa->GetCount(); i++ ) { time = rsa->Item(i).m_Reference_Time; //populate 'time' row m_pGribTable->SetCellValue(GetTimeRowsStrings( rsa->Item(i).m_Reference_Time, zone , 0), 1, i ); nrows = 2; m_pTimeset = m_pGDialog->GetTimeLineRecordSet(time); GribRecord **RecordArray = m_pTimeset->m_GribRecordPtrArray; //create and polulate wind data row if(m_pGDialog->m_bGRIBActiveFile->m_GribIdxArray.Index(Idx_WIND_VX) != wxNOT_FOUND && m_pGDialog->m_bGRIBActiveFile->m_GribIdxArray.Index(Idx_WIND_VY) != wxNOT_FOUND) { AddDataRow( nrows, i, _("Wind"), doubledatarow ); wxString wc(GetWind(RecordArray)); //wind is a special case: if current unit is not bf ==> double speed display (current unit + bf) if(m_pGDialog->m_OverlaySettings.Settings[GribOverlaySettings::WIND].m_Units != GribOverlaySettings::BFS) if(!wc.IsEmpty()) wc.Append(_T("\n")).Append(GetWindBf(RecordArray)); // m_pGribTable->SetCellValue(nrows, i, wc); m_pGribTable->SetCellBackgroundColour(nrows, i, m_pDataCellsColour); nrows++; } //create and polulate Pressure data row if(m_pGDialog->m_bGRIBActiveFile->m_GribIdxArray.Index(Idx_PRESSURE) != wxNOT_FOUND) { AddDataRow( nrows, i, _("Pressure"), singledatarow ); m_pGribTable->SetCellValue(nrows, i, GetPressure(RecordArray)); nrows++; } //create and polulate Wind gusts data row if(m_pGDialog->m_bGRIBActiveFile->m_GribIdxArray.Index(Idx_WIND_GUST) != wxNOT_FOUND) { AddDataRow( nrows, i, _("Wind Gust"), singledatarow ); m_pGribTable->SetCellValue(nrows, i, GetWindGust(RecordArray)); m_pGribTable->SetCellBackgroundColour(nrows, i, m_pDataCellsColour); nrows++; } //create and polulate Waves data row if(m_pGDialog->m_bGRIBActiveFile->m_GribIdxArray.Index(Idx_HTSIGW) != wxNOT_FOUND || m_pGDialog->m_bGRIBActiveFile->m_GribIdxArray.Index(Idx_WVDIR) != wxNOT_FOUND) { AddDataRow( nrows, i, _("Waves"), doubledatarow ); m_pGribTable->SetCellValue(nrows, i, GetWaves(RecordArray)); m_pGribTable->SetCellBackgroundColour(nrows, i, m_pDataCellsColour); nrows++; } //create and polulate total rainfall data row if(m_pGDialog->m_bGRIBActiveFile->m_GribIdxArray.Index(Idx_PRECIP_TOT) != wxNOT_FOUND) { AddDataRow( nrows, i, _("Rainfall"), singledatarow ); m_pGribTable->SetCellValue(nrows, i, GetRainfall(RecordArray)); m_pGribTable->SetCellBackgroundColour(nrows, i, m_pDataCellsColour); nrows++; } //create and polulate total cloud control if(m_pGDialog->m_bGRIBActiveFile->m_GribIdxArray.Index(Idx_CLOUD_TOT) != wxNOT_FOUND) { AddDataRow( nrows, i, _("Cloud"), singledatarow ); m_pGribTable->SetCellValue(nrows, i, GetCloudCover(RecordArray)); m_pGribTable->SetCellBackgroundColour(nrows, i, m_pDataCellsColour); nrows++; } //create and polulate the Air Temperature data row if(m_pGDialog->m_bGRIBActiveFile->m_GribIdxArray.Index(Idx_AIR_TEMP) != wxNOT_FOUND) { AddDataRow( nrows, i, _("Air\nTemperature"), singledatarow ); m_pGribTable->SetCellValue(nrows, i, GetAirTemp(RecordArray)); m_pGribTable->SetCellBackgroundColour(nrows, i, m_pDataCellsColour); nrows++; } //create and polulate the Sea Surface Temperature data row if(m_pGDialog->m_bGRIBActiveFile->m_GribIdxArray.Index(Idx_SEA_TEMP) != wxNOT_FOUND) { AddDataRow( nrows, i, _("Sea\nTemperature"), singledatarow ); m_pGribTable->SetCellValue(nrows, i, GetSeaTemp(RecordArray)); m_pGribTable->SetCellBackgroundColour(nrows, i, m_pDataCellsColour); nrows++; } //create and polulate the Convective Available Potential Energy (CAPE) data row if(m_pGDialog->m_bGRIBActiveFile->m_GribIdxArray.Index(Idx_CAPE) != wxNOT_FOUND) { AddDataRow( nrows, i, _("CAPE"), singledatarow ); m_pGribTable->SetCellValue(nrows, i, GetCAPE(RecordArray)); m_pGribTable->SetCellBackgroundColour(nrows, i, m_pDataCellsColour); nrows++; } //create and polulate the current data row if(m_pGDialog->m_bGRIBActiveFile->m_GribIdxArray.Index(Idx_SEACURRENT_VX) != wxNOT_FOUND && m_pGDialog->m_bGRIBActiveFile->m_GribIdxArray.Index(Idx_SEACURRENT_VY) != wxNOT_FOUND) { AddDataRow( nrows, i, _("Current"), doubledatarow ); m_pGribTable->SetCellValue(nrows, i, GetCurrent(RecordArray)); m_pGribTable->SetCellBackgroundColour(nrows, i, m_pDataCellsColour); nrows++; } m_pGribTable->AutoSizeColumn(i, false); ncols++; //write 'days' row if(time.GetDateOnly() != day.GetDateOnly() || i == rsa->GetCount()- 1){ if( i == 0 ) continue; //not the first item if(i == rsa->GetCount() - 1 && ncols != 1) ncols++; ////if end of time range don't forgett the last col m_pGribTable->SetCellSize(0, dcol, 1, ncols); m_pGribTable->SetCellValue(0, dcol, GetTimeRowsStrings(day.GetDateOnly() , zone, 1)); day = rsa->Item(i).m_Reference_Time; dcol = i; if( ncols == 1){ //if only one item per day m_pGribTable->AutoSizeColumn(i-1, false); if(i == rsa->GetCount() - 1 ) { //if end of time range m_pGribTable->SetCellValue(0, i, GetTimeRowsStrings(day.GetDateOnly() , zone, 1)); m_pGribTable->AutoSizeColumn(i, false); } } ncols = 0; } } AutoSizeDataRows(); m_pGribTable->SetGridCursor( m_pGribTable->GetNumberRows(), 0); //put cursor outside the grid this->Fit(); this->Refresh(); }
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; }