亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? maps.cpp

?? 給予QT的qps開源最新源碼
?? CPP
?? 第 1 頁 / 共 3 頁
字號:
/*
   qpegps is a program for displaying a map centered at the current longitude/
   latitude as read from a gps receiver.

   Copyright (C) 2002 Ralf Haselmeier <Ralf.Haselmeier@gmx.de>

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

 */
#include <dirent.h> 
#include <sys/stat.h> 
#include "qpegps.h"
#include "mapdisp.h"
#include "track.h"

#include "convert.h"

const double PI_1_2 = M_PI / 2.0;
const double PI_1_4 = M_PI / 4.0;
const double PI_3_4 = M_PI * 0.75;

// ----- NON-MEMBER FUNCTIONS -----

inline double checkLg(double lon)
{
   if ( lon > M_PI ) {
      lon -= 2 * M_PI;
   } else if ( lon < -M_PI ) {
      lon += 2 * M_PI;
   }
   return lon;
}

MapSelector * MapBase::mapSelector = NULL;

// ----- METHODS ------

MapBase::MapBase(QString &, const QString &subdir)
{
   // read map info
//   mapIStream = new QTextIStream(&mapInfo);
//   *mapIStream >> mapName >> scale >> mapSizeX >> mapSizeY;
   mapDir = subdir;
}

MapBase::MapBase()
{
}

MapBase::~MapBase()
{
}

int MapBase::operator<(MapBase & map)
{
   return (scale < map.scale);
}

int MapBase::operator==(MapBase & map)
{
   return (scale == map.scale);
}

int MapBase::operator>(MapBase & map)
{
   return (scale > map.scale);
}

bool MapBase::isInside(const Position & pos)
{
//qDebug("Latitude %f < %f < %f = %d", limitSouthEast.lat, pos.lat, limitNorthWest.lat, pos.lat>=limitSouthEast.lat && pos.lat<=limitNorthWest.lat);
//qDebug("Longitude %f < %f < %f = %d", limitSouthEast.lon, pos.lon, limitNorthWest.lon, pos.lon <= limitSouthEast.lon && pos.lon >= limitNorthWest.lon);
	return (pos.lat>=limitSouthEast.lat && pos.lat<=limitNorthWest.lat &&
		pos.lon <= limitSouthEast.lon && pos.lon >= limitNorthWest.lon);
}

QString MapBase::name( void )
{
    QString fullname = mapDir + mapName;
    return( fullname );
}

MapBase *MapBase::newMap(QString &mapType, QString &mapInfo, const QString &subdir)
{
   MapBase *map;

   if(mapType == "LAMBERT")
		map = new MapLambert(mapInfo, subdir);
	else if(mapType == "CEA")
		map = new MapCEA(mapInfo, subdir);
	else if(mapType == "MERCATOR")
		map = new MapMercator(mapInfo, subdir);
	else if(mapType == "TM")
		map = new MapUTM(mapInfo,FALSE, subdir);
	else if(mapType == "UTM")
		map = new MapUTM(mapInfo,TRUE, subdir);
	else if(mapType == "LINEAR")
		map = new MapLin(mapInfo, subdir);
	else if(mapType == "FRITZ")
		map = new MapFritz(mapInfo, subdir);
	else if(mapType == "TILED")
		map = new MapTiled(mapInfo, subdir);
	else
		map = NULL;

   return map;
}

MapSelector::MapSelector(Qpegps *app/*, QString *mapPath*/)
{
   application = app;
   //	mapPathStr = mapPath;
   maps.setAutoDelete(TRUE);
   actMapList.setAutoDelete(FALSE);
   actMap = NULL;
   selectedScale = 0;
   currentMapImg = new QImage;

   MapBase::mapSelector = this;

   timer = new QTimer(this);
   connect( timer, SIGNAL(timeout()),
         SLOT(updateMapsLoaded()) ); 
   // check for non used image maps every 500 ms
   timer->start(500, false);
}

MapSelector::~MapSelector()
{
	delete currentMapImg;
}

void MapSelector::reReadMaps()
{
   application->wait(true, "Please wait: reading maps...");
   clearMaps();
   readMaps();

   emit mapsChanged();
   application->wait(false);
}

void MapSelector::readMaps( const QString &subdir )
{
   QString filename(mapPathStr());
/*   if( newSubdir != "" ) {
      newSubdir += "/";
   }*/
   filename.append( "/" + subdir + "maps.txt");
   QFile mapFile(filename);
   if ( mapFile.open(IO_ReadOnly) ) {
      application->wait(true, "Please wait: reading maps from " + filename);
      
      QTextStream t( &mapFile );
	   QString pro;
	   QString mapInfo;
	   MapBase *map;
      const QStringList& list = QStringList::split('\n', t.read());
      mapFile.close();
      QStringList::ConstIterator it;
      for(it=list.begin(); it!=list.end(); ++it) {
         const QString& s = *it;
         int sp = s.find(' ');
         pro = s.left(sp);
         mapInfo = s.right(s.length()-sp-1);
         map = MapBase::newMap(pro, mapInfo, subdir);
         // add the map
		   if (map)
			   maps.append(map);
      }
		maps.sort();
   } else if( subdir == "" ) {
		QFileInfo mfi(filename);
		QMessageBox::critical( 0, "qpeGPS",
			tr( "couldn't open \n%1\n"
			"If file does not exist it will be created.\n"
			"File info:\n"
			"exists = %2\n"
			"is readable = %3\n"
			"is a file = %4\n"
			"is a directory = %5\n"
			"is a symbolic link = %6\n"
			"owner = %7")
			.arg(filename).arg(mfi.exists())
			.arg(mfi.isReadable()).arg(mfi.isFile())
			.arg(mfi.isDir()).arg(mfi.isSymLink()).arg(mfi.owner()));
		if ( !mfi.exists() ) { 
			mapFile.open(IO_ReadWrite); 
			mapFile.close(); 
			chmod((const char*)filename,0777);
		} 
	}
   /* Now open any subfolders and search for their "maps.txt" 
   entries and add those maps as well */
   if (mapOptions.searchMapsInSubdirs) {
#ifdef __arm__
      // this approach is faster than using QDir
      DIR *d;
      struct dirent *de;
	   QString newDir = "";
      if( (d = ::opendir(mapPathStr() + "/" + subdir)) == NULL ) {
         application->wait(false);
         return;
      }
      while( (de = readdir( d )) != NULL ) {
         if (de->d_type == DT_DIR && 
            strcmp(de->d_name, ".") != 0 && strcmp(de->d_name, "..")) {
            newDir = subdir + de->d_name;
		      readMaps( newDir + "/" );
         }
      }

      closedir( d);
#else
      QDir d( mapPathStr() + "/" + subdir );
	   d.setFilter( QDir::Dirs );
    //    d.setSorting( QDir::Size | QDir::Reversed );

	   const QFileInfoList *list = d.entryInfoList();
	   QFileInfoListIterator it( *list );      // create list iterator
	   QFileInfo *fi;                          // pointer for traversing

	   QString newDir = "";

    //    printf( "     BYTES FILENAME\n" );      // print header
	   while ( (fi=it.current()) ) {           // for each file...
	      if( ( fi->fileName() != "." ) && ( fi->fileName() != ".." ) ) {
            newDir = subdir + fi->fileName();
		      readMaps( newDir + "/" );
	      }
	      ++it;                               // goto next list element
	   } 
#endif
   }
   application->wait(false);
}

void MapSelector::writeMapFile()
{
   QString filename = mapPathStr();
   filename.append("/");
   filename.append("/maps.txt");
   QFile mapFile(filename);
   mapFile.open(IO_WriteOnly);
   QTextStream t(&mapFile);
   MapBase *aMap;
   for (aMap = maps.first (); aMap != 0; aMap = maps.next())
   {
       if( aMap->mapDir == "" ) /* Try to only save when the maps is recorded not in a sub folder */
	   t << aMap->getParameterStr() << "\n";
   }
   mapFile.close();
   // re-read maps for initialiting structs

   reReadMaps();
}

void MapSelector::clearMaps()
{
   actMapList.clear();
	clearMapsLoaded();
	// clear previous map list
	maps.setAutoDelete(TRUE);
	maps.clear(); // FIXME => critical for mapInfo ...
}

void MapSelector::chooseLessDetailedMap()
{
   MapBase *aMap;
    if(actMap) {
		if(actMap->scale < actMapList.last()->scale)
		{
			// if no scale selected
			if (selectedScale == 0)
				// start with the current (most detail) to search a lower detail
				selectedScale = actMap->scale;
			aMap=actMapList.first();
			while(aMap && (aMap->scale < /*actmap->scale*/selectedScale*1.1))
			{
				aMap = actMapList.next();
			}
			if(aMap)
				selectedScale = aMap->scale;
			else
				selectedScale = actMap->scale;
		}
		else
			selectedScale = actMap->scale;
    }
}

void MapSelector::chooseMoreDetailedMap()
{
    MapBase *aMap;

    if(actMap && actMap->scale > actMapList.first()->scale) {
		aMap = actMapList.last();
		while(aMap && (aMap->scale > /*actmap->scale*/selectedScale*0.9))
			aMap = actMapList.prev();
		if(aMap)
			selectedScale = aMap->scale;
    }
    else
		selectedScale = 0;
}

void MapSelector::showAvailableMaps()
{
    MapBase *aMap;

    qDebug(tr("Maps at current position:"));
    aMap = actMapList.first();
    while(aMap) {
		qDebug(tr("%1 %2").arg(aMap->scale).arg(aMap->name()));
		aMap = actMapList.next();
    }
}

void MapSelector::clearMapsLoaded()
{
   QMap<MapImage *,int>::Iterator it;
   for( it = mapsLoaded.begin(); it != mapsLoaded.end(); ++it ){
		it.key()->unload();
   }
   mapsLoaded.clear();
}

bool MapSelector::searchMap(const Position & pos/*, int maxMaps*/)
{
	MapBase *aMap;
	int numberOfChecks;
   bool mapAdded = false;
	// find map
	// and get position in map coordinates

	// check if the actual maps are still valid
	aMap = actMapList.first();
	while(aMap)
	{
		if(!aMap->isInside(pos))
		{
         actMapList.take();
			aMap = actMapList.current(); //next item
		}
		else
			aMap = actMapList.next();
	}
	// search all the list until it found a map
	numberOfChecks = maps.count();
/*	if(numberOfChecks > maxMaps)
		numberOfChecks = maxMaps;
	else if(numberOfChecks < 1)
		// less than 10 -> check all
		numberOfChecks = maps.count();*/
	aMap = maps.current();
	while(numberOfChecks)
	{
		if(aMap && aMap->isInside(pos) && !actMapList.containsRef(aMap) )
		{
			actMapList.append(aMap);
         mapAdded = true;
		}
		if(aMap)
			aMap = maps.next();
		if(!aMap)
			aMap = maps.first();
		numberOfChecks--;
	}
   if (mapAdded)
      // order the list
      actMapList.sort();

   if(actMapList.isEmpty())
		return FALSE;
	else
		return TRUE;
}

void MapSelector::selectMap(const Position & pos, QRect rect)
{
	MapBase *aMap, *theMap;
	double xc, yc, scale, cover, tcover;

	// get Map with best scale + coverage
	// list is still sorted by scale
	// scroll to the map, with appropriate scale
	aMap = actMapList.first();
	scale = aMap->scale;
	while(aMap && (aMap->scale < 0.9*selectedScale))
	{
		aMap = actMapList.next();
	};
	// all maps have a lower scale => take map with highest scale
	if(!aMap)
		aMap = actMapList.last();

	theMap = aMap;
	scale = aMap->scale;
	// get map with best coverage with approx. the same scale
	aMap->calcxy(&xc, &yc, pos);
	cover = aMap->coverage(xc, yc, rect.width(),rect.height());
	aMap = actMapList.next();
	while( aMap && (cover < -1) && (1.9 * scale > aMap->scale))
	{
		aMap->calcxy(&xc, &yc, pos);
		tcover = aMap->coverage(xc, yc, rect.width(),rect.height());
		if(tcover > cover)
		{
			theMap=aMap;
			cover = tcover;
		}
		aMap = actMapList.next();
	}

   if(theMap != actMap){
      // replace the current map
      actMap = theMap;
   }
}

bool MapSelector::loadMapImage( MapImage *map )
{
   // check if it is loaded
   if (mapsLoaded.contains(map)) {
      // already loaded, restart counter
      mapsLoaded[map] = 20; // 10 seconds
      return true;
   }
   // load the map
   if (map->load()) {
      // add tracks 
		if (application->viewTrack)
			map->addTrack(application->viewTrack, 
				application->viewTrack->trackOptions.trackColor, 
            application->viewTrack->trackOptions.track_thick);
      // all ok, add the map to the loaded map list
      mapsLoaded[map] = 20; // 10 seconds
      return true;
   }
   return false;
}

void MapSelector::drawMap(QPixmap *viewer, const Position & pos)
{
	if (searchMap(pos)) {
		selectMap(pos, viewer->rect());
		
		// draw the map
		actMap->draw(viewer, pos);
	}
	else {
      actMap = NULL;
   }
}

double MapBase::coverage(double x, double y, int width, int height)
{
    // determines the area on the display, which is not covered by the Map
    // 0 = map fills the display
    // <0 = -1 * pixels without map

   double tmp = mapSizeX - x;
   double coverX = ( x > tmp ) ? tmp : x;
   tmp = mapSizeY - y;
   double coverY = ( y > tmp ) ? tmp : y;
   coverX -= width / 2;
   coverY -= height / 2;
   coverX = ( coverX > 0 ) ? 0 : coverX * height;
   coverY = ( coverY > 0 ) ? 0 : coverY * width;

   return coverX + coverY;
}

void MapSelector::updateMapsLoaded()
{
   QMap<MapImage *,int>::Iterator it;
   MapImage *deleteMap = NULL;
   for( it = mapsLoaded.begin(); it != mapsLoaded.end(); ++it ){
      if (deleteMap != NULL) {
         mapsLoaded.remove(deleteMap);
         deleteMap = NULL;
      }
      int counter = it.data() -1;
      if (counter) {
         // update value
         mapsLoaded[it.key()] = counter;
      }
      else {
         deleteMap = it.key();
         deleteMap->unload();
      }
   }
   if (deleteMap != NULL)
      mapsLoaded.remove(deleteMap);
}

MapBase *MapSelector::find( QString &mapName )
{
   MapBase *map;
   for (map = maps.first(); map != 0; map = maps.next()) {
      if (map->name() == mapName)
         return map;
   }
   // not found
   return NULL;
}

void MapSelector::delMap( MapBase *delmap )
{
   if (actMapList.find(delmap))

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美中文字幕不卡| 中文字幕欧美三区| 久久一区二区视频| 久久精品视频一区二区| 欧美激情在线一区二区| 一区二区成人在线视频| 亚洲高清久久久| 激情都市一区二区| jlzzjlzz亚洲日本少妇| 欧美日精品一区视频| 欧美一区二区精品| 国产精品的网站| 日韩激情av在线| av电影一区二区| 91麻豆精品国产自产在线观看一区| 久久先锋影音av| 亚洲精品视频在线观看网站| 日本中文在线一区| 色婷婷综合视频在线观看| 日韩欧美一区二区在线视频| 国产精品久久久久久一区二区三区 | 国产一区二区三区在线观看免费| 99久久综合99久久综合网站| 日韩精品一区二区在线观看| 国产精品二三区| 激情文学综合网| 欧美日韩亚洲另类| 国产精品伦一区| 久久精品国内一区二区三区| 在线免费不卡视频| 日本一区二区三级电影在线观看 | 亚洲综合无码一区二区| 懂色av一区二区在线播放| 日韩一级片在线观看| 亚洲国产成人va在线观看天堂| 粉嫩一区二区三区在线看| 久久久一区二区三区| 美国毛片一区二区| 555夜色666亚洲国产免| 亚洲成精国产精品女| 91福利小视频| 亚洲女人的天堂| 色综合色狠狠综合色| 亚洲另类中文字| 欧美色区777第一页| 一区二区三区91| 欧美日韩视频在线一区二区| 亚洲一二三四在线观看| 欧美在线综合视频| 日韩高清不卡一区二区| 日韩欧美一区二区免费| 久久99精品久久久久婷婷| 欧美亚洲禁片免费| 日韩av中文在线观看| 精品不卡在线视频| 成人免费视频免费观看| 亚洲在线观看免费| 欧美岛国在线观看| 成人污污视频在线观看| 国产午夜精品理论片a级大结局| 精品亚洲欧美一区| 国产精品家庭影院| 色综合中文综合网| 精品久久久久久综合日本欧美 | 色乱码一区二区三区88| 视频一区欧美日韩| 国产色一区二区| 欧美视频一区二| 国产尤物一区二区| 亚洲欧美激情在线| 久久亚洲免费视频| 欧美午夜精品久久久久久孕妇| 久久99国产精品尤物| 一区二区三区日韩精品视频| 精品乱码亚洲一区二区不卡| 91搞黄在线观看| 国产老妇另类xxxxx| 亚洲成人av在线电影| 日本一二三四高清不卡| 91麻豆精品国产91久久久久久久久 | 午夜精品久久久久久久99樱桃 | av一区二区三区在线| 久久成人免费网站| 一区二区在线观看视频| 国产欧美一区二区在线| 精品久久久久久最新网址| 欧美日韩aaaaa| 欧美亚洲综合在线| 色香蕉久久蜜桃| 97精品久久久午夜一区二区三区 | 中文字幕一区二区三区乱码在线| 7777精品伊人久久久大香线蕉超级流畅| 成人免费黄色大片| 国产精品77777| 国产乱码精品一区二区三区av| 日本va欧美va精品| 日本三级亚洲精品| 欧美a级理论片| 免费观看在线综合色| 日本成人在线电影网| 免费成人在线网站| 激情五月婷婷综合| 国产一区二区三区在线观看精品| 久久精品国产久精国产| 国产一区不卡在线| 国产一区视频网站| 成人av免费在线观看| 色婷婷激情综合| 欧美一区二区三区系列电影| 欧美电视剧在线观看完整版| 久久伊99综合婷婷久久伊| 国产精品欧美一区二区三区| 亚洲欧洲综合另类在线| 五月婷婷色综合| 国产在线观看免费一区| 99这里只有久久精品视频| 欧美自拍丝袜亚洲| 欧美电视剧在线观看完整版| 国产拍欧美日韩视频二区| 一区二区三区在线视频观看58| 亚洲成精国产精品女| 国产乱人伦精品一区二区在线观看| 成人精品国产一区二区4080| 一本色道久久综合精品竹菊| 日韩一级欧美一级| 尤物视频一区二区| 国产一区二区三区黄视频 | 图片区小说区国产精品视频 | 欧美在线视频日韩| 久久新电视剧免费观看| 亚洲图片欧美一区| 国产福利一区二区三区视频在线 | 美女视频网站黄色亚洲| 91蜜桃传媒精品久久久一区二区| 欧美一级在线观看| 一区二区欧美国产| 粉嫩久久99精品久久久久久夜| 欧美妇女性影城| 亚洲精品欧美二区三区中文字幕| 国产精一区二区三区| 欧美精品免费视频| 亚洲天堂精品视频| av在线不卡电影| 国产精品午夜在线观看| 狠狠色综合日日| 精品入口麻豆88视频| 日本欧美一区二区| 欧美日韩亚洲国产综合| 亚洲综合清纯丝袜自拍| 99久久er热在这里只有精品66| 国产亚洲婷婷免费| 国产激情视频一区二区在线观看 | 91热门视频在线观看| 国产人成亚洲第一网站在线播放| 日韩av中文字幕一区二区| 7777精品伊人久久久大香线蕉| 午夜精品一区二区三区免费视频| 91国产福利在线| 天天综合色天天综合| 91麻豆精品国产91久久久久久 | 欧美视频在线一区二区三区| 亚洲午夜久久久久| 欧美一区二区视频免费观看| 狠狠色狠狠色综合| 国产欧美日韩麻豆91| 99久久精品国产导航| 亚洲国产中文字幕在线视频综合 | 日本久久一区二区三区| 亚洲超碰97人人做人人爱| 日韩精品专区在线| 豆国产96在线|亚洲| 亚洲精品videosex极品| 在线不卡免费欧美| 国产东北露脸精品视频| 亚洲欧美日韩中文播放 | 国产精品高潮久久久久无| 色吧成人激情小说| 日韩av电影免费观看高清完整版 | 一本在线高清不卡dvd| 五月综合激情网| 久久免费的精品国产v∧| 日本久久一区二区三区| 国产精品资源在线看| 一区二区三区毛片| 久久久亚洲国产美女国产盗摄 | 欧美日韩视频不卡| 丁香另类激情小说| 另类小说色综合网站| 亚洲一区二区三区美女| 国产日韩三级在线| 91精品国产欧美一区二区18| av不卡在线播放| 成人免费视频网站在线观看| 免费精品视频在线| 亚洲国产欧美在线| 国产精品久久久久久久岛一牛影视 | 欧美r级电影在线观看| 欧亚洲嫩模精品一区三区| 成人激情小说乱人伦| 粉嫩aⅴ一区二区三区四区|