Ejemplo n.º 1
0
static
void ob_text(XA_TREE *wt, RECT *r, RECT *o, OBJC_COLOURS *c, char *t, int state, int und)
{
	if (t)
	if (*t)
	{
		OBJECT *ob = wt->tree + wt->current;
		bool fits = !o or (o and (o->h >= r->h - (d3_foreground(ob) ? 4 : 0)));	/* HR 300602 */

		if (c)		/* set according to circumstances. */
		{
/*			HR 051002: more restrictions	*/
			if (    c->opaque
			    and !MONO
			    and d3_any(ob)
			    and (
			                 c->pattern eq IP_HOLLOW
			         or (    c->pattern eq IP_SOLID
			             and c->fillc eq WHITE
			            )
			        )
			   )
			{
				f_color(screen.dial_colours.bg_col);
				wr_mode(MD_REPLACE);
				gbar(0, o ? o : r);
				wr_mode(MD_TRANS);
			}
			else
				wr_mode(c->opaque ? MD_REPLACE : MD_TRANS);
		}

		if (!MONO and (state&DISABLED) != 0)
		{
			done(DISABLED);
			if (fits)
			{
				t_color(screen.dial_colours.lit_col);
				v_gtext(C.vh, r->x+1, r->y+1, t);
				t_color(screen.dial_colours.shadow_col);
			}
		}

		if (fits)
			v_gtext(C.vh, r->x, r->y, t);

		/* Now underline the shortcut character, if any. */
		if (und >= 0)
		{
			int l = strlen(t);
			if (und < l)
			{
				G_i x = r->x + und*screen.c_max_w,
				    y = r->y + screen.c_max_h - 1;
				line(x, y, x + screen.c_max_w - 1, y, RED);
			}
		}
	}
}
Ejemplo n.º 2
0
static
void g_text(XA_TREE *wt, RECT r, RECT *o, char *text, int state)
{
	/* HR: only center the text. ;-) */
	r.y += (r.h-screen.c_max_h) / 2;
	if (!MONO and (state&DISABLED) != 0)
	{
		t_color(screen.dial_colours.lit_col);
		v_gtext(C.vh, r.x+1, r.y+1, text);
		t_color(screen.dial_colours.shadow_col);
		v_gtext(C.vh, r.x,   r.y,   text);
		done(DISABLED);
	othw
		t_color(menu_dis_col(wt));	/* HR */
		ob_text(wt, &r, o, nil, text, 0, (state&WHITEBAK) ? (state>>8)&0x7f : -1);
		if (state&DISABLED)
		{
			write_disable(&wt->r, screen.dial_colours.bg_col);
			done(DISABLED);
		}
	}
Ejemplo n.º 3
0
	t_color shade_hit(const t_ray_intersection& hit) const {
		return (t_color((0.5f * hit.sn().x() + 0.5f), (0.5f * hit.sn().y() + 0.5f), (0.5f * hit.sn().z() + 0.5f)));
	}
Ejemplo n.º 4
0
// Use A* algorithm to calculate shortest path between intersections
vector<unsigned> DirectedPath(unsigned startid, unsigned endid) {
    unordered_map<unsigned, bool> flag; //if node is visited
    unordered_map<unsigned, double> dist; //weight of edge
    unordered_map<unsigned, pair<unsigned, unsigned>> prev; //the previous node&edge of key
    prev[startid] = make_pair(startid, 0);
    LatLon end = getIntersectionPosition(endid);
    priority_queue<pair<unsigned, double>, vector<pair<unsigned, double>>, comparenorm> Q; // the node to be visited
    vector<unsigned> Path;
    Q.push(make_pair(startid, 0));
    unordered_map<unsigned, unsigned>* outedges; //the out going edges of an intersection
    
//    unordered_map<unsigned, unordered_map<unsigned, pair<unsigned, unsigned>>>::iterator memo;
//    bool found_memo = false;
//    unsigned memoid = 0;
    
    /**************************DEBUG USE***************************/
    bool DEBUG = 0; //enable to draw the process of computing the path
    /***************************************************************/
    
    while (!Q.empty()) {
        unsigned currentid = Q.top().first; // accessing the weight of the edge, or distance 
        Q.pop();

        if (currentid == endid) break;
        if (flag[currentid] != 1) {
            flag[currentid] = 1;
            
//            memo = Memoize(currentid, endid); //unfinished implementation of memoization
//            if (memo != Memo.end()) {
//                found_memo = true;
//                memoid = currentid;
//                cout << "i broke out" <<endl;
//                break;  
//            }
            
//            vector<unsigned> testdraw; //for debug use
            
            outedges = &getOutEdges(currentid); //obtain the outgoing edges and the other end point
            for (unordered_map<unsigned, unsigned>::const_iterator iter = outedges->begin(); iter != outedges->end(); iter++) {
                //for all the street segments around the current intersections
                
                //street segment id
                unsigned path_segment = iter->first; 
                //the other end point intersection id
                unsigned nextid = iter->second;
                
                // how long it takes to travel through this segment
                double travel_time = find_segment_travel_time(path_segment) + dist[currentid];
                
                //if the current street segment is on the same street with the next street segment
                if (getStreetSegmentStreetID(path_segment) != getStreetSegmentStreetID(prev[currentid].second))
                    travel_time += 0.25;

//                if (DEBUG) {
//                    testdraw.push_back(path_segment);
//                    DrawPath(testdraw, t_color(64, 153, 255));
//                }
                
                // if the current path to next intersection is found to be faster than the 
                // previous path, update the path and time 
                if ((dist[nextid] == 0) || (travel_time < dist[nextid])) {
                    dist[nextid] = travel_time;
                    prev[nextid] = make_pair(currentid, path_segment);
                }
                
                // get the position of the next intersection id
                LatLon currentposition = getIntersectionPosition(nextid);
                
                // find the distance between the next intersection id and the end point
                double current_distance = find_distance_between_two_points(currentposition, end);
                         
                double weight = ((dist[nextid]) + current_distance * 0.06 / 100);
                
                // put the intersection into the priority queue
                Q.push(make_pair(nextid, weight));

            }
        }
    }
//    if(found_memo){
//        unsigned iter = endid;
//        while (iter != memoid) {
//        pair<unsigned, unsigned> idandpath = ((memo->second).find(iter))->second;
//        Path.insert(Path.begin(), idandpath.second);
//        iter = idandpath.first;
//        }
//        endid = memoid;
//    }
    
    unsigned iter = endid;
    while ((iter != startid) && (dist[endid] != 0)) {
        pair<unsigned, unsigned> idandpath = prev[iter];
        Path.insert(Path.begin(), idandpath.second);
//        if (DEBUG) {
//            bool OneWay = getStreetSegmentOneWay(idandpath.second);
//            StreetSegmentEnds ids = getStreetSegmentEnds(idandpath.second);
//            if (OneWay && (ids.from == iter)) {
//                cout << "ONEWAY PATH: " << idandpath.second << endl;
//                cout << "FROM: "<< ids.from << " TO: " << ids.to << endl;
//                cout << "INSTEAD OF: " << idandpath.first  << " TO: " << iter <<endl;
//                bool connected = are_directly_connected(idandpath.first, iter);
//                cout << "ARE THEY DIRECTLY CONNECTED? " << connected << endl;
//                break;
//            }
//        }
//        Memo[iter] = prev;
//        prev.erase(iter);
        
        iter = idandpath.first;
    }
    if (DEBUG) {
        DrawPath(Path, t_color(255, 0, 0));
        double computed_time = compute_path_travel_time(Path);
        if (computed_time == 0) cout <<"PATH FROM: "<< startid <<" TO "<< endid << " NOT FOUND"<<endl;
    }
    return Path;
}
Ejemplo n.º 5
0
void setupColor()
{
    //please when you add a color  comment the color scheme enum beside it and 
    //add the enum to color.h
    //call add ColorScheme here
    
    addColorScheme(t_color(0xDF, 0xDF, 0xDF), t_color(0x00, 0x00, 0x00)); //grey to black
    addColorScheme(t_color(0x8C, 0x8C, 0x8C), t_color(0x9C, 0x73, 0x10)); // Street Borders (BORDERC)
    addColorScheme(t_color(0xFF, 0xFF, 0xFF), t_color(0x9C, 0x73, 0x10)); // Street (STREETC)
    addColorScheme(t_color(0xFF, 0xE1, 0x68), t_color(0x9C, 0x73, 0x10)); // highways (HIGHWAYC) (orange)
    addColorScheme(t_color(0xAC, 0xC7, 0xF2), t_color(0x00, 0xFF, 0xFF)); // water (BLUEC)
    addColorScheme(t_color(0xFA, 0xF2, 0xC7), t_color(0xF3, 0xF3, 0x15)); // sand (TANC)
    addColorScheme(t_color(0xCA, 0xDF, 0xAA), t_color(0x00, 0xFF, 0x00)); // grass (GREENC) (green)
    addColorScheme(t_color(0x87, 0xCE, 0xFA), t_color(0xFF, 0x00, 0xFF)); // POIs (POIC)
    addColorScheme(t_color(0xFF, 0x00, 0xFF), t_color(0xFF, 0x00, 0xFF)); // testing magenta
    addColorScheme(t_color(0x00, 0x00, 0x00), t_color(0xFF, 0xFF, 0xFF)); // Black to white (TEXT)
    addColorScheme(t_color(0xFF, 0x00, 0x00), t_color(0xFF, 0x00, 0x00)); // Highlighted path (red)
    addColorScheme(t_color(0xC0, 0xE2, 0xFF), t_color(0x00, 0xFF, 0xFF)); // light blue
    addColorScheme(t_color(0xAA, 0xC5, 0xF0), t_color(0x00, 0xFF, 0xFF)); // dark blue
    addColorScheme(t_color(0xF2, 0xCA, 0xEA), t_color(0xF3, 0xF3, 0x15)); // pink (tourist attractions)
    addColorScheme(t_color(0x71, 0x8C, 0xC3), t_color(0x00, 0xFF, 0xFF)); // theme (for addons and stuff)
    addColorScheme(t_color(0xCF, 0xE1, 0xB7), t_color(0x00, 0xFF, 0x00)); // light green
    addColorScheme(t_color(0xC8, 0xDC, 0xC8), t_color(0x00, 0xFF, 0x00)); // dark green (kind of turquoise right now)
    addColorScheme(t_color(0xDE, 0xB8, 0x87), t_color(0xF3, 0xF3, 0x15)); // brown
    addColorScheme(t_color(0xBD, 0xB7, 0x6B), t_color(0xF3, 0xF3, 0x15)); // green brown
    addColorScheme(t_color(0xA9, 0xA9, 0xA9), t_color(0x9C, 0x73, 0x10)); // grey
    addColorScheme(t_color(0xC0, 0xC7, 0xCF), t_color(0x00, 0xFF, 0xFF)); // one way symbols
}