/************************************************************************* * *N draw_face * *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: * * Purpose: *P * This function draws the specified face from the given face table. *E *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: * * Parameters: *A * row_num <input>==(ossim_int32) row id of the specified face. * facetable <input>==(vpf_table_type) VPF face primitive table. * ringtable <input>==(vpf_table_type) VPF ring primitive table. * edgetable <input>==(vpf_table_type) VPF edge primitive table. * fbr <input>==(vpf_table_type) VPF face bounding rectangle table. * outline <input>==(color_type) outline color. * c1 <input>==(color_type) 1st color in the fill pattern. * c2 <input>==(color_type) 2nd color in the fill pattern. * c3 <input>==(color_type) 3rd color in the fill pattern. * c4 <input>==(color_type) 4th color in the fill pattern. *E *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: * * History: *H * Barry Michaels May 1991 DOS Turbo C *E *************************************************************************/ void draw_face( ossim_int32 rownum, vpf_table_type facetable, vpf_table_type ringtable, vpf_table_type edgetable, vpf_table_type fbr, color_type outline, color_type c1, color_type c2, color_type c3, color_type c4 ) { row_type row; row = get_row( rownum, facetable ); draw_face_row(row,facetable, ringtable, edgetable, fbr, outline,c1,c2,c3,c4); free_row(row,facetable); }
/************************************************************************* * *N draw_selected_features * *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: * * Purpose: *P * This function draws the selected features from a specified feature * class based upon a query (either an expression or the pre-compiled * results of an expression). *E *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: * * Parameters: *A * view <inout>==(view_type *) view structure. * themenum <input>==(int) theme number. * library <input>==(library_type *) VPF library structure. * mapenv <input>==(map_environment_type *) map environment structure. * return <output>==(int) completion status: * 1 if completed successfully, * 0 if an error occurred. *E *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: * * History: *H * Barry Michaels August 1991 DOS Turbo C *E *************************************************************************/ int draw_selected_features( view_type *view, int themenum, library_type *library, map_environment_type *mapenv ) { int status, fcnum, finished, cov, tilecover, TILEPATH_, prim; int outline, color1, color2, color3, color4; vpf_table_type rngtable,edgtable,fbrtable, tile_table; row_type row; char *ptable[] = {"","edg","fac","txt","end","cnd"}; register rspf_int32 i, j, p, pclass, tile; int display_order[] = {FACE,EDGE,ENTITY_NODE,CONNECTED_NODE,TEXT}; register rspf_int32 starttile, endtile, startprim, endprim; rspf_int32 count; char path[255], covpath[255], tiledir[255], *buf, str[255]; char *drive, rngpath[255],edgpath[255],edxpath[255],fbrpath[255]; boolean rng_rdisk,edg_rdisk,fbr_rdisk; set_type primitives, feature_rows; fcrel_type fcrel; window_type info; struct viewporttype vp; getviewsettings(&vp); fcnum = view->theme[themenum].fcnum; sprintf(path,"%stileref\\tileref.aft",library->path); if (access(path,0) != 0) { tilecover = FALSE; } else { tile_table = vpf_open_table(path,disk,"rb",NULL); TILEPATH_ = table_pos("TILE_NAME",tile_table); tilecover = TRUE; } feature_rows = get_selected_features( view, themenum, *library ); for (p=0;p<5;p++) { pclass = display_order[p]; if ((pclass != library->fc[fcnum].primclass) && (library->fc[fcnum].primclass != COMPLEX_FEATURE)) continue; if ((library->fc[fcnum].primclass == COMPLEX_FEATURE) && (!library->fc[fcnum].cprim[pclass])) continue; /* Set up the feature class table relate chain. */ /* The feature table is fcrel.table[0]. */ /* The primitive table is the last table in the chain: */ /* fcrel.table[ fcrel.nchain-1 ]. */ j = 0; for (i=0;i<strlen(library->fc[fcnum].table);i++) if (library->fc[fcnum].table[i] == '\\') j = i+1; strcpy( str, &(library->fc[fcnum].table[j])); fcrel = select_feature_class_relate(fcnum, library, str, ptable[pclass]); prim = fcrel.nchain-1; /*** 'Tile' number 1 is the universe polygon for the tileref cover ***/ starttile = set_min(library->tile_set); if (starttile < 2) starttile = 2; endtile = set_max(library->tile_set); if (endtile < 2) endtile = 2; for (tile = starttile; tile <= endtile; tile++ ) { if (!set_member(tile,library->tile_set)) continue; if (tilecover) { row = get_row(tile,tile_table); buf = (char *)get_table_element(TILEPATH_,row,tile_table, NULL,&count); free_row(row,tile_table); strcpy(tiledir,buf); rightjust(tiledir); strcat(tiledir,"\\"); free(buf); } else { strcpy(tiledir,""); } cov = library->fc[fcnum].coverage; strcpy( covpath, library->cover[cov].path ); finished = TRUE; sprintf(path,"%s%s%s",covpath,tiledir,ptable[pclass]); if (access(path,0) != 0) continue; fcrel.table[prim] = vpf_open_table(path,disk,"rb",NULL); info = info_window("Searching..."); primitives = get_selected_tile_primitives( library, fcnum, fcrel, feature_rows, mapenv, tile, tiledir, &status ); delete_window(&info); setviewport(vp.left,vp.top,vp.right,vp.bottom,vp.clip); /* Reset plate-carree parameters (changed in */ /* get_selected_tile_primitives() ) */ if (mapenv->projection == PLATE_CARREE) set_plate_carree_parameters( central_meridian( mapenv->mapextent.x1, mapenv->mapextent.x2), 0.0, 1.0 ); if (primitives.size < 1) { vpf_close_table(&fcrel.table[prim]); continue; } if (!status) { set_nuke(&primitives); vpf_close_table(&fcrel.table[prim]); break; } if (pclass == FACE) { /* Must also open RNG, EDG, and FBR for drawing faces. */ /* If a RAM disk is specified, copy these to it and open */ /* them there. */ rng_rdisk = FALSE; edg_rdisk = FALSE; fbr_rdisk = FALSE; drive = getenv("TMP"); buf = (char *)vpfmalloc(255); sprintf(path,"%s%srng",covpath,tiledir); strcpy(rngpath,path); if (drive && filesize(path) < available_space(drive)) { sprintf(rngpath,"%s\\RNG",drive); sprintf(buf,"COPY %s %s > NUL",path,rngpath); system(buf); rng_rdisk = TRUE; } rngtable = vpf_open_table(rngpath,disk,"rb",NULL); sprintf(path,"%s%sedg",covpath,tiledir); strcpy(edgpath,path); sprintf(edxpath,"%s%sedx",covpath,tiledir); if (drive && (filesize(path)+filesize(edxpath))<available_space(drive)) { sprintf(edgpath,"%s\\EDG",drive); sprintf(buf,"COPY %s %s > NUL",path,edgpath); system(buf); sprintf(edxpath,"%s\\EDX",drive); sprintf(buf,"COPY %s%sedx %s > NUL",covpath,tiledir,edxpath); system(buf); edg_rdisk = TRUE; } edgtable = vpf_open_table(edgpath,disk,"rb",NULL); sprintf(path,"%s%sfbr",covpath,tiledir); strcpy(fbrpath,path); if (drive && filesize(path) < available_space(drive)) { sprintf(fbrpath,"%s\\FBR",drive); sprintf(buf,"COPY %s %s > NUL",path,fbrpath); system(buf); fbr_rdisk = TRUE; } fbrtable = vpf_open_table(fbrpath,disk,"rb",NULL); free(buf); } finished = 1; startprim = set_min(primitives); endprim = set_max(primitives); /* It turns out to be MUCH faster off of a CD-ROM to */ /* read each row and discard unwanted ones than to */ /* forward seek past them. It's about the same off */ /* of a hard disk. */ fseek(fcrel.table[prim].fp, index_pos(startprim,fcrel.table[prim]), SEEK_SET); for (i=startprim;i<=endprim;i++) { row = read_next_row(fcrel.table[prim]); if (set_member( i, primitives )) { /* Draw the primitive */ switch (pclass) { case EDGE: finished = draw_edge_row(row,fcrel.table[prim]); break; case ENTITY_NODE: case CONNECTED_NODE: finished = draw_point_row(row,fcrel.table[prim]); break; case FACE: gpgetlinecolor( &outline ); gpgetpattern( &color1, &color2, &color3, &color4 ); hidemousecursor(); draw_face_row( row,fcrel.table[prim], rngtable, edgtable, fbrtable, outline, color1, color2, color3, color4 ); showmousecursor(); finished = 1; if (kbhit()) { if (getch()==27) finished = 0; } break; case TEXT: finished = draw_text_row(row,fcrel.table[prim]); break; } } free_row(row,fcrel.table[prim]); if (!finished) { status = 0; break; } } if (pclass == FACE) { vpf_close_table(&rngtable); if (rng_rdisk) remove(rngpath); vpf_close_table(&edgtable); if (edg_rdisk) { remove(edgpath); remove(edxpath); } vpf_close_table(&fbrtable); if (fbr_rdisk) remove(fbrpath); } vpf_close_table(&fcrel.table[prim]); set_nuke(&primitives); if (!finished) { status = 0; break; } } if (!finished) { status = 0; deselect_feature_class_relate( &fcrel ); break; } status = 1; if (kbhit()) { if (getch()==27) { status = 0; deselect_feature_class_relate( &fcrel ); break; } } deselect_feature_class_relate(&fcrel); } if (tilecover) { vpf_close_table(&tile_table); } set_nuke(&feature_rows); return status; }