void DrawOptionalPath(const map<string,infoT> &point,const set<arcT> &arc){ cout<<"select the start point and end point use the mouse in the map."<<endl; cout<<"you will get the optimal path"<<endl; coordT startP,endP; string sp,ep; //get the start and end while(true){ cout<<"please click the start point....."<<endl; startP=GetMouseClick(); map<string,infoT>::const_iterator itr=point.begin(); while(itr!=point.end()){ if(WithinDistance(startP,itr->second.location)) break; itr++; } if(itr==point.end()){ cout<<"wrong click,there is no point in the click place"<<endl; } else{ cout<<"the start point is "<<itr->first<<endl; sp=itr->first; break; } } while(true){ cout<<"please click the end point....."<<endl; endP=GetMouseClick(); map<string,infoT>::const_iterator itr=point.begin(); while(itr!=point.end()){ if(WithinDistance(endP,itr->second.location)) break; itr++; } if(itr==point.end()){ cout<<"wrong click,there is no point in the click place"<<endl; } else{ cout<<"the end point is "<<itr->first<<endl; ep=itr->first; break; } } //draw the optional path set<string> include; set< vector<laborT> > path; include.insert(sp); cout<<"start drawing optional path..."<<endl; draw(point,arc,include,path,sp,ep); }
nodeT * GetPoint(Set<nodeT *> graph, string message, string color) { nodeT *node; while (true) { cout << message << endl; coordT point1 = GetMouseClick(); bool pointFound = false; Set<nodeT *>::Iterator itr = graph.iterator(); while (itr.hasNext()) { // Test if click was close enough to a known location node = itr.next(); if (WithinDistance(GetCoords(node),point1)) { cout << node->name << endl; DrawFilledCircleWithLabel(GetCoords(node), color); pointFound = true; break; } } if (pointFound) break; else cout << "Try Again" << endl; } return node; }
string getLocName(string s, Map<coordT> &m) { string name; while (true) { cout << s; coordT loc = GetMouseClick(); Map<coordT>::Iterator it = m.iterator(); while (it.hasNext()) { name = it.next(); if (WithinDistance(loc, m[name])) { cout << name << " chosen." <<endl; DrawFilledCircleWithLabel(m[name], "Red", name); return name; } } cout << "Invalid click. Please try again." << endl << endl; } }