diff -u C:\FGCVS\Atlas\src\Atlas.cxx ..\..\src\Atlas.cxx --- C:\FGCVS\Atlas\src\Atlas.cxx Thu Nov 18 12:25:24 2010 +++ ..\..\src\Atlas.cxx Fri Dec 03 18:56:46 2010 @@ -273,8 +273,11 @@ // By default, when we show a flight track, we display the information // window and graphs window. If this is false (this can be toggled by // the user), then we don't show them. +#ifdef _MSC_VER +bool showGraphWindow = false; +#else // !_MSC_VER bool showGraphWindow = true; - +#endif // _MSC_VER y/n // Some default colours. // float trackColour[4] = {0.0, 0.0, 1.0, 1.0}; // float markColour[4] = {1.0, 1.0, 0.0, 1.0}; @@ -4544,7 +4547,9 @@ glutKeyboardFunc(keyPressed); glutSpecialFunc(specPressed); glutVisibilityFunc(mainVisibilityFunc); - +#ifdef _MSC_VER + glutPositionWindow(0,0); +#endif // _MSC_VER // Read in files. for (unsigned int i = 0; i < prefs.flightFiles.size(); i++) { // First check if we've loaded that file already. Common subdirectories: C:\FGCVS\Atlas\src\CVS and ..\..\src\CVS Common subdirectories: C:\FGCVS\Atlas\src\data and ..\..\src\data diff -u C:\FGCVS\Atlas\src\Graphs.cxx ..\..\src\Graphs.cxx --- C:\FGCVS\Atlas\src\Graphs.cxx Tue Jun 01 08:52:43 2010 +++ ..\..\src\Graphs.cxx Thu Dec 02 16:01:32 2010 @@ -1120,7 +1120,9 @@ Graphs::Values::~Values() { free(_label); +#ifndef _MSC_VER puDeleteObject(_slider); +#endif // !_MSC_VER } void Graphs::Values::setFlightTrack(FlightTrack *ft) diff -u C:\FGCVS\Atlas\src\Image.cxx ..\..\src\Image.cxx --- C:\FGCVS\Atlas\src\Image.cxx Sun May 16 14:45:52 2010 +++ ..\..\src\Image.cxx Wed Dec 01 18:42:50 2010 @@ -28,7 +28,9 @@ #include #include -#include +extern "C" { + #include +} #include // For OpenGL stuff diff -u C:\FGCVS\Atlas\src\Map.cxx ..\..\src\Map.cxx --- C:\FGCVS\Atlas\src\Map.cxx Sun May 16 14:45:52 2010 +++ ..\..\src\Map.cxx Mon Dec 06 16:53:37 2010 @@ -65,7 +65,18 @@ #include "MapEXT.hxx" #endif #endif +#ifdef _MSC_VER +/* Drag in other Windows libraries as required by FreeGLUT */ +#ifndef NO_LIB_PRAGMAS +#pragma comment (lib, "glu32.lib") /* link OpenGL Utility lib */ +#pragma comment (lib, "opengl32.lib") /* link Microsoft OpenGL lib */ +#pragma comment (lib, "gdi32.lib") /* link Windows GDI lib */ +#pragma comment (lib, "winmm.lib") /* link Windows MultiMedia lib */ +#pragma comment (lib, "user32.lib") /* link Windows user lib */ #endif +#endif // _MSC_VER + +#endif // !__APPLE__ #include #include @@ -119,6 +130,91 @@ static int bufferSize; // Size of rendering buffer. +#ifdef ADD_CHUNK_LIMIT +typedef struct tagMAP_CHUNK { + int lat,lon; +}MAP_CHUNK; +typedef vector vmap_chunk; +static vmap_chunk map_chunk; // store of user '--chunks=e000n40' input +static int gotChunkLimits = 0; // count of user 10x10 chunks given +static int forceRewrite = 0; // re-build a set of map (change color, etc) +#endif // #ifdef ADD_CHUNK_LIMIT + +static time_t bgn_time = 0; +static time_t last_time; +static int _s_tile_cnt; +void commence_tile( const char * pn ) +{ + int elap; + if (bgn_time == 0) { + _s_tile_cnt = 0; + time(&bgn_time); + } + time(&last_time); + elap = last_time - bgn_time; + _s_tile_cnt++; + printf("%4d: ", _s_tile_cnt); + printf("%s: ", pn); +} + +void end_tile(void) +{ + time_t end_time; + int et_tile, et_total; + time(&end_time); + et_tile = end_time - last_time; + et_total = end_time - bgn_time; + int hrs, mins, secs; + mins = et_total / 60; + secs = et_total - (mins * 60); + hrs = mins / 60; + mins = mins - (hrs * 60); + printf(" [%02d:%02d:%02d]\n", hrs, mins, secs); +} + +//////////////////////////////////////////////////////////////////////////////// +// Renders a single scenery tile, perhaps at several different sizes, +// storing the results as image files, overwritting any existing. +//////////////////////////////////////////////////////////////////////////////// +void renderMap2(TileInfo *t) +{ + const bitset& maps = t->mapLevels(); + // This tile has missing maps. Load, render, save, and unload + // them. + try { + bool first = true; + commence_tile(t->name()); + + mapper->set(t); + for (unsigned int i = 0; i < TileManager::MAX_MAP_LEVEL; i++) { + if (maps[i]) { + mapper->draw(i + rescaleFactor); + if (createJPEG) { + mapper->save(i, TileMapper::JPEG, jpegQuality); + } else { + mapper->save(i, TileMapper::PNG); + } + + if (!first) { + printf(", "); + } + printf("%u", i); + first = false; + if (!renderToFramebuffer) { + glutSwapBuffers(); + } + } + } + end_tile(); + } catch (runtime_error &e) { + // EYE - make these strings constants? + if (strcmp(e.what(), "scenery") == 0) { + fprintf(stderr, "%s: Unable to load buckets for '%s' from '%s'\n", + appName, t->name(), t->sceneryDir().str().c_str()); + } + } +} + //////////////////////////////////////////////////////////////////////////////// // Renders a single scenery tile, perhaps at several different sizes, // storing the results as image files. It only generates maps if they @@ -130,12 +226,11 @@ if (maps.none()) { return; } - // This tile has missing maps. Load, render, save, and unload // them. try { bool first = true; - printf("%s: ", t->name()); + commence_tile(t->name()); mapper->set(t); for (unsigned int i = 0; i < TileManager::MAX_MAP_LEVEL; i++) { @@ -157,7 +252,7 @@ } } } - printf("\n"); + end_tile(); } catch (runtime_error &e) { // EYE - make these strings constants? if (strcmp(e.what(), "scenery") == 0) { @@ -171,6 +266,10 @@ { printf("Map - FlightGear mapping utility\n\n"); printf("Usage:\n"); +#ifdef ADD_CHUNK_LIMIT + printf(" --chunk=e000n40 Limit mapping to each 'chunk', 10x10 degree blocks.\n"); + printf(" --force Force overwrite of existing images.\n"); +#endif // ADD_CHUNK_LIMIT printf(" --fg-root=path Overrides FG_ROOT environment variable\n"); printf(" --fg-scenery=path Overrides FG_SCENERY environment variable\n"); printf(" --atlas=path Store maps in path\n"); @@ -205,6 +304,21 @@ fg_root.set(arg + 10); } else if (strncmp(arg, "--fg-scenery=", 13) == 0) { scenery.set(arg + 13); +#ifdef ADD_CHUNK_LIMIT + } else if (strncmp(arg, "--chunk=", 8) == 0) { + char ns = 'n', ew = 'e'; // like, --chunk=w130n30, for w123n37 KSFO + MAP_CHUNK mc; + if (sscanf(arg + 8, "%c%3d%c%2d", &ew, &mc.lon, &ns, &mc.lat) == 4) { + if (ew == 'w') mc.lon *= -1; + if (ns == 's') mc.lat *= -1; + map_chunk.push_back(mc); + gotChunkLimits++; + } else { + return false; + } + } else if (strcmp(arg, "--force") == 0) { + forceRewrite = 1; +#endif // #ifdef ADD_CHUNK_LIMIT } else if (strncmp(arg, "--atlas=", 8) == 0) { atlas.set(arg + 8); } else if (strncmp(arg, "--palette=", 10) == 0) { @@ -333,7 +447,10 @@ } #else #ifdef HAVE_SGGLEXT_H - Map_Exit_Ext( &fbo, &rbo ); + if (renderToFramebuffer) + { + Map_Exit_Ext( &fbo, &rbo ); + } #endif #endif if (mapper) { @@ -348,6 +465,14 @@ //////////////////////////////////////////////////////////////////////////////// int main(int argc, char **argv) { +#ifdef _MSC_VER + int skipped_count = 0; + int tile_counter = 0; + SGPath sdir; + int write_map = 0; + int maps_written = 0; + int sk_no_src, sk_not_in_range, sk_forced, sk_no_overwrite; +#endif // _MSC_VER appName = argv[0]; // Read the FG_ROOT and FG_SCENERY environment variables before @@ -603,6 +728,32 @@ printf("be able to read them on this machine.\n"); } +#ifdef ADD_CHUNK_LIMIT + int ii, ilat, ilon; +#endif + +#ifdef ADD_CHUNK_LIMIT + if (verbose) { + if (renderToFramebuffer) { + printf("Render to frame buffer...\n"); + } else { + printf("Render to screen...\n"); + } + if ( gotChunkLimits ) { + printf("Chunk Limited: lat,lon "); + for (ii = 0; ii < map_chunk.size(); ii++) { + ilat = map_chunk[ii].lat; + ilon = map_chunk[ii].lon; + printf(" [%d,%d]", ilat, ilon ); + } + printf(", ie %d 10x10 chunks.\n", ii); + } + if ( forceRewrite ) { + printf("Got overwrite flag, for all images.\n"); + } + } +#endif // #ifdef ADD_CHUNK_LIMIT + if (test) { // Print out a report, then exit. printf("Scenery directory:\n\t%s\n", scenery.c_str()); @@ -623,6 +774,92 @@ int tileCount = 0, mapCount = 0; map::const_iterator i = tiles.begin(); +#ifdef _MSC_VER + skipped_count = 0; + tile_counter = 0; + sk_no_src = 0; + sk_not_in_range = 0; + sk_forced = 0; // regardless of destination + sk_no_overwrite = 0; + for (; i != tiles.end(); i++) { + TileInfo *t = i->second; + const bitset& maps = t->missingMaps(); + sdir = t->sceneryDir(); + tile_counter++; // tiles found, BOTH in 'src' and 'dst' + if (sdir.isNull() || !sdir.exists() ) { + // no use building a 'map' image, if no data to base it on... + skipped_count++; // just found in 'dst' does not mean 'src' exists + sk_no_src++; + continue; + } +#ifdef ADD_CHUNK_LIMIT + if (gotChunkLimits) { + // ***TBD*** maybe check for lat,lon wrap? + int in_range = 0; // assume NOT in range, since we have user limits + for (ii = 0; ii < map_chunk.size(); ii++) + { + ilat = map_chunk[ii].lat; + ilon = map_chunk[ii].lon; + if ((t->lat() < ilat) || + (t->lat() >= (ilat + 10)) || + (t->lon() < ilon) || + (t->lon() >= (ilon + 10))) { + // this tile is out of range + } else { + in_range++; // this tile MATCHES a user chunk range + break; // we are interested to build this MAP ;=)) + } + } + if ( !in_range ) { + skipped_count++; + sk_not_in_range++; + continue; + } + } +#endif // !#ifdef ADD_CHUNK_LIMIT + write_map = 0; + if ( forceRewrite ) { + write_map = 1; // renderMap2(t); // no check if image exists - just WRITE it! + sk_forced++; + } else { + if ( t->missingMaps().none() ) { + skipped_count++; + sk_no_overwrite++; + } else { + write_map = 2; + } + } + if (write_map) { + if (mapCount == 0) { + printf("Missing maps:\n"); + } + mapCount++; // renderMap(t) FOR SURE; + printf("\t%s: ", t->name()); + // EYE - use maps.count()? + for (unsigned int j = 0; j < TileManager::MAX_MAP_LEVEL; j++) { + if (maps[j]) { + // mapCount++; + printf("%d ", j); + } + } + printf("\n"); + } + } + if (verbose) { + printf("Of total %d, skip-no-src %d, not-in-rng %d, forced %d, no-ovrwrt %d, to-write %d\n", + tile_counter, sk_no_src, sk_not_in_range, sk_forced, + sk_no_overwrite, mapCount ); + + } + printf("Would render %d tiles, skip %d...\n", + tile_counter - skipped_count, + skipped_count); + if (mapCount) { + // we got some MAPS to WRITE, for what ever reason, then + tileCount = tile_counter; + // else, we have NO mpas to write... + } +#else // !_MSC_VER for (; i != tiles.end(); i++) { TileInfo *t = i->second; const bitset& maps = t->missingMaps(); @@ -642,6 +879,7 @@ printf("\n"); } } +#endif // _MSC_VER y/n printf("\n-------------------- Summary --------------------\n"); if (tileCount > 0) { printf("%d tile(s) missing %d map(s)\n", @@ -660,10 +898,76 @@ const map& tiles = tileManager->tiles(); map::const_iterator i = tiles.begin(); +#ifdef _MSC_VER + skipped_count = 0; + tile_counter = 0; + sk_no_src = 0; + sk_not_in_range = 0; + sk_forced = 0; // regardless of destination + sk_no_overwrite = 0; + for (; i != tiles.end(); i++) { + TileInfo *t = i->second; + sdir = t->sceneryDir(); + tile_counter++; + if (sdir.isNull() || !sdir.exists() ) { + // no use building a 'map' image, if no data to base it on... + skipped_count++; + sk_no_src++; + continue; + } +#ifdef ADD_CHUNK_LIMIT + if (gotChunkLimits) { + // ***TBD*** maybe check for lat,lon wrap? + int in_range = 0; + for (ii = 0; ii < map_chunk.size(); ii++) + { + ilat = map_chunk[ii].lat; + ilon = map_chunk[ii].lon; + if ((t->lat() < ilat) || + (t->lat() >= (ilat + 10)) || + (t->lon() < ilon) || + (t->lon() >= (ilon + 10))) { + // this tile is out of range + } else { + in_range++; // this tile MATCHES a user chunk range + break; + } + } + if ( !in_range ) { + skipped_count++; + sk_not_in_range++; + continue; + } + } +#endif // !#ifdef ADD_CHUNK_LIMIT + if ( forceRewrite ) { + renderMap2(t); // no check if image exists - just WRITE it! + sk_forced++; + maps_written++; + } else { + if ( t->missingMaps().none() ) { + skipped_count++; + sk_no_overwrite++; + } else { + renderMap(t); + maps_written++; + } + } + } + printf("Of total %d, skip-no-src %d, not-in-rng %d, forced %d, no-ovrwrt %d, written %d\n", + tile_counter, sk_no_src, sk_not_in_range, sk_forced, + sk_no_overwrite, maps_written ); + if (verbose) { + printf("Done rendering %d tile MAPS, skipped %d...\n", + tile_counter - skipped_count, + skipped_count); + } +#else // !_MSC_VER for (; i != tiles.end(); i++) { - TileInfo *t = i->second; - renderMap(t); + TileInfo *t = i->second; + renderMap(t); } +#endif // _MSC_VER y/n cleanup(0); diff -u C:\FGCVS\Atlas\src\misc.cxx ..\..\src\misc.cxx --- C:\FGCVS\Atlas\src\misc.cxx Sun Jun 27 17:21:31 2010 +++ ..\..\src\misc.cxx Thu Dec 02 15:03:04 2010 @@ -511,18 +511,19 @@ const char *AtlasString::_appendf(const char *fmt, va_list ap) { - size_t newLen; #ifdef _MSC_VER + int newLen; // Window's verion of vsnprintf() returns -1 when the string won't // fit, so we need to keep trying with larger buffers until it // does. - while ((newLen = vsnprintf_s(_buf + _strlen, _size - _strlen, _TRUNCATE, - fmt, ap)) < 0) { + while ((newLen = vsnprintf_s(_buf + _strlen, _size - _strlen, + _size - _strlen - 1, fmt, ap)) < 0) { _size += _increment; _buf = (char *)realloc(_buf, _size); assert(_buf != NULL); } #else + size_t newLen; va_list ap_copy; va_copy(ap_copy, ap); diff -u C:\FGCVS\Atlas\src\Notifications.cxx ..\..\src\Notifications.cxx --- C:\FGCVS\Atlas\src\Notifications.cxx Mon Jun 15 10:44:58 2009 +++ ..\..\src\Notifications.cxx Thu Dec 02 15:49:16 2010 @@ -51,6 +51,7 @@ void Notification::unsubscribe(Subscriber *s, type n) { +#ifndef _MSC_VER if (n == All) { assert(_notifications.size() == All); for (unsigned int i = 0; i < _notifications.size(); i++) { @@ -59,6 +60,7 @@ } else { _notifications[n].erase(s); } +#endif // _MSC_VER } void Notification::notify(type n) diff -u C:\FGCVS\Atlas\src\Palette.cxx ..\..\src\Palette.cxx --- C:\FGCVS\Atlas\src\Palette.cxx Fri Apr 09 09:56:29 2010 +++ ..\..\src\Palette.cxx Sat Dec 04 17:15:52 2010 @@ -20,6 +20,9 @@ You should have received a copy of the GNU General Public License along with Atlas. If not, see . ---------------------------------------------------------------------------*/ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif #include "Palette.hxx" diff -u C:\FGCVS\Atlas\src\Subbucket.cxx ..\..\src\Subbucket.cxx --- C:\FGCVS\Atlas\src\Subbucket.cxx Sun May 16 14:45:53 2010 +++ ..\..\src\Subbucket.cxx Sat Nov 27 21:41:16 2010 @@ -72,7 +72,11 @@ // All points within the chunk are relative to the reference // point. Therefore, to place points in absolute 3D space, we // need to add the reference point to all points. +#ifdef _MSC_VER + const SGVec3& gbs_p = _chunk.get_gbs_center(); +#else // !_MSC_VER const SGVec3& gbs_p = _chunk.get_gbs_center2(); +#endif // _MSC_VER y/n // Get all the points, and use them to set our maximum elevation // figure. diff -u C:\FGCVS\Atlas\src\Subbucket.hxx ..\..\src\Subbucket.hxx --- C:\FGCVS\Atlas\src\Subbucket.hxx Sun May 16 14:45:53 2010 +++ ..\..\src\Subbucket.hxx Thu Nov 18 15:26:22 2010 @@ -38,8 +38,13 @@ #include #include #if (defined(_MSC_VER) && !defined(HAVE_TRI_UNORDERED)) +#include // TR1 +#include +#include #include #include +#include +// #include #else #include #include @@ -59,7 +64,12 @@ // Note: the decision to use XOR to combine the two values was // made on the basis of pure ignorance. There are, no doubt, // better ways. +#ifdef _MSC_VER + //return std::hash()(x.first ^ x.second); + return stdext::hash_value(x.first ^ x.second); +#else // !_MSC_VER return std::tr1::hash()(x.first ^ x.second); +#endif // _MSC_VER y/n } }; diff -u C:\FGCVS\Atlas\src\Tiles.cxx ..\..\src\Tiles.cxx --- C:\FGCVS\Atlas\src\Tiles.cxx Tue Jun 01 08:52:49 2010 +++ ..\..\src\Tiles.cxx Fri Dec 03 13:25:14 2010 @@ -245,21 +245,37 @@ SGPath scenery10 = scenery; ulDir *dir1; ulDirEnt *ent1; - + if (ent10->d_isdir && (sscanf(ent10->d_name, "%*1c%2d0%*1c%1d0", &lon, &lat) == 2)) { // Go through the subdirectory. scenery10.append(ent10->d_name); dir1 = ulOpenDir(scenery10.c_str()); while (dir1 && (ent1 = ulReadDir(dir1))) { +#ifdef _MSC_VER + char ns = 'n', ew = 'e'; + if (ent1->d_isdir && + (sscanf(ent1->d_name, "%c%3d%c%2d", &ew, &lon, &ns, &lat) == 4) +#else // !_MSC_VER if (ent1->d_isdir && - (sscanf(ent1->d_name, "%*1c%3d%*1c%2d", &lon, &lat) - == 2)) { + (sscanf(ent1->d_name, "%*1c%3d%*1c%2d", &lon, &lat) == 2) +#endif // _MSC_VER + ) + { // Whew! Looks like we've got ourselves a scenery // directory! Add the tile to our "database". SGPath scenery1 = scenery10; scenery1.append(ent1->d_name); TileInfo *t = _getTile(ent1->d_name); +#ifdef _MSC_VER + // w122n37 + if (ew == 'w') + lon *= -1; // west of greenwitch (0) + if (ns == 's') + lat *= -1; // south of equator + t->_lat = lat; // store the location + t->_lon = lon; // from directory name. +#endif // _MSC_VER t->_setScenery(scenery1); } } @@ -293,7 +309,13 @@ // See if it has a "tilish" name followed by a suffix. int lat, lon; - if (sscanf(e->d_name, "%*1c%3d%*1c%2d.%*s", &lon, &lat) == 2) { +#ifdef _MSC_VER + char ns = 'n', ew = 'e'; + if (sscanf(e->d_name, "%c%3d%c%2d", &ew, &lon, &ns, &lat) == 4) +#else // !_MSC_VER + if (sscanf(e->d_name, "%*1c%3d%*1c%2d.%*s", &lon, &lat) == 2) +#endif // _MSC_VER y/n + { // Get the name without the suffix. char root[8]; strncpy(root, e->d_name, 7); @@ -302,7 +324,11 @@ // Get the tile and tell it that it has a map at this // level. TileInfo *t = _getTile(root); - t->_setExists(i); + if (ew == 'w') lon = -lon; + if (ns == 's') lat = -lat; + t->_lat = lat; + t->_lon = lon; + t->_setExists(i); // as a printed map, but may not have the scenery path } } ulCloseDir(d);