/* draw route on the map */ void GPXRoute::Draw(kGUICorners *c) { unsigned int i; GPXRouteEntry *re; kGUIColor col; kGUIColor col2; int px,py,lpx=0,lpy=0; GPXRow *row; /* todo, bounding box for route, compare against the corners */ col=GPX::GetTableColor(GetColorIndex()); col2=GPX::GetTableTColor(GetColorIndex()); for(i=0;i<m_numentries;++i) { re=m_entries.GetEntry(i); row=gpx->Locate(&re->m_wptname); if(!row) return; /* error, missing waypoint in track!!! */ gpx->m_curmap->ToMap(row->GetCoord(),&px,&py); px-=c->lx; py-=c->ty; if(i) GPXRoute::DrawLine(i,px,py,lpx,lpy,col); lpx=px; lpy=py; } }
void GPXRoute::Save(kGUITableObj *table,kGUITickBoxObj *draw,kGUIComboBoxObj *color) { unsigned int e; unsigned int nr; kGUIObj *obj; GPXRow *row; GPXRouteEntry *re; /* delete old entries if there are any? */ for(e=0;e<m_numentries;++e) delete m_entries.GetEntry(e); SetDraw(draw->GetSelected()); SetColorIndex(color->GetSelection()); nr=table->GetNumChildren(0); /* number of valid entries */ m_numentries=nr; m_entries.Alloc(nr); for(e=0;e<nr;++e) { obj=table->GetChild(e); row=static_cast<GPXRow *>(obj); re=new GPXRouteEntry(); re->m_wptname.SetString(row->GetWptName()); m_entries.SetEntry(e,re); } }
bool GPXRoute::Compare(kGUITableObj *table,kGUITickBoxObj *draw,kGUIComboBoxObj *color) { unsigned int e; kGUIObj *obj; GPXRow *row; GPXRouteEntry *re; if(table->GetNumChildren(0)!=m_numentries) return(true); /* draw flag has changed */ if(draw->GetSelected()!=GetDraw()) return(true); /* color has changed? */ if((unsigned int)color->GetSelection()!=GetColorIndex()) return(true); for(e=0;e<m_numentries;++e) { re=m_entries.GetEntry(e); /* route record */ obj=table->GetChild(e); row=static_cast<GPXRow *>(obj); if(strcmp(row->GetWptName(),re->m_wptname.GetString())) return(true); } return(false); /* same! */ }
void GPXRoute::Save(kGUIXMLItem *xml) { unsigned int e; unsigned int nc; GPXRouteEntry *re; kGUIXMLItem *fxml; kGUIXMLItem *flxml; /* count number of points in the route */ nc=0; for(e=0;e<m_numentries;++e) { re=m_entries.GetEntry(e); /* route record */ if(gpx->Locate(&re->m_wptname)) ++nc; } /* if no entries in route then don't save it */ if(nc) { fxml=xml->AddChild("route"); fxml->AddParm("name",m_name.GetString()); fxml->AddParm("draw",GetDraw()==true?"1":"0"); fxml->AddParm("color",GPX::GetTableColorName(GetColorIndex())); for(e=0;e<m_numentries;++e) { re=m_entries.GetEntry(e); /* route record */ /* only save if point is still in the main table */ if(gpx->Locate(&re->m_wptname)) flxml=fxml->AddChild("wptname",re->m_wptname.GetString()); } } }
void AutoOrderWindow::Update(void) { unsigned int newcount; unsigned int newbest; m_busyrect.Animate(); newcount=m_tsp.GetCount(); if(newcount!=m_count) { m_count=newcount; m_tries.Sprintf("Tries: %d",m_count); newbest=m_tsp.GetNewBest(); if(newbest!=m_curbest) { unsigned int f; unsigned int s; unsigned int nc=m_t->GetNumChildren(); int *curlist=m_tsp.GetCurList(); double dist=0.0f,ratio,eval1,eval2; GPXRow *lrow; GPXRow *row; /* generate results report */ GPX::GetDistInfo(gpx->GetCurrentDist(),0,&ratio,&eval1,&eval2); s=0; while(curlist[s]) ++s; lrow=0; for(f=0;f<nc;++f) { row=m_rows.GetEntry(curlist[s]); if(lrow) dist+=(lrow->GetCoord()->Dist(row->GetCoord())*ratio); lrow=row; if(++s==nc) s=0; } if(dist<m_startdist) m_best.Sprintf("Distance: %.2f",dist); } } }
void GPXRoute::Load(kGUITableObj *table,kGUITickBoxObj *draw,kGUIComboBoxObj *color) { unsigned int e; GPXRow *row; GPXRow *fullrow; GPXRouteEntry *re; draw->SetSelected(GetDraw()); color->SetSelectionz(GetColorIndex()); table->DeleteChildren(); for(e=0;e<m_numentries;++e) { re=m_entries.GetEntry(e); /* route record */ fullrow=gpx->Locate(&re->m_wptname); if(fullrow) { row=new GPXRow(); /* copy record from full table */ row->Copy(fullrow); table->AddRow(row); } } }