📄 mapinfo.cpp
字号:
if (spec->IsArea)
{ if (spec->areax<1 || spec->areay<1)
{ QMessageBox mb( tr("Map Download"), tr("Area not walid. You must specify another area."), QMessageBox::Warning, QMessageBox::Ok | QMessageBox::Default, QMessageBox::NoButton, QMessageBox::NoButton );
mb.exec();
mb.hide();
valid = 0;
}
}
else {
if (spec->slatitude >= spec->elatitude)
{ QMessageBox mb( tr("Map Download"), tr("Start Latitude mus be lower then End Latitude."), QMessageBox::Warning, QMessageBox::Ok | QMessageBox::Default, QMessageBox::NoButton, QMessageBox::NoButton );
mb.exec();
mb.hide();
valid = 0;
}
if (spec->slongitude >= spec->elongitude)
{ QMessageBox mb( tr("Map Download"), tr("Start Longitude mus be lower then End Longitude."), QMessageBox::Warning, QMessageBox::Ok | QMessageBox::Default, QMessageBox::NoButton, QMessageBox::NoButton );
mb.exec();
mb.hide();
valid = 0;
}
}
}
else {
valid = 0;
break;
}
} while (!valid);
char *com;
if (valid) {
com=(char *)malloc(512);
#if 0 // PROXY
if (application->gpsData->useProxy)
{ system((const char *)("export http_proxy="+application->gpsData->proxyUrl));
printf("%s\n",(const char *)tr("export http_proxy="+application->gpsData->proxyUrl));
}
#endif
if (spec->IsArea)
{ as+=" -la %.5f -lo %.5f -sc %li -a %.2fx%.2f -p -P m -f Dd -md %s -r %1i %s";
sprintf(com,as.latin1(), spec->latitude, spec->longitude, spec->scale, spec->areax, spec->areay,
(const char*)spec->dir, spec->res, (const char *)spec->param);
}
else {
as+=" -sla %.5f -slo %.5f -ela %.5f -elo %.5f -sc %li -p -P m -f Dd -md %s -r %1i %s";
sprintf(com,as.latin1(), spec->slatitude, spec->slongitude, spec->elatitude, spec->elongitude, spec->scale,
(const char *)spec->dir, spec->res, (const char *)spec->param);
}
QMessageBox mb( tr("Start Downloading maps."), tr(" Start Downloading maps...\r\n It can take from few miutes to few hours.\n Push OK button to start."), QMessageBox::Warning, QMessageBox::Ok | QMessageBox::Default, QMessageBox::NoButton, QMessageBox::NoButton );
printf("%s \n\n",com);
mb.exec();
int status=0;
if ( (status=system(com)) != 0)
{
mb.hide();
if (status == -1 )
{ QMessageBox mb( tr("Runing downmap error."), tr(" Can't execute downmap utility.\nCheck is it exist and acces (execute) rigths to it\r\n Push OK button."), QMessageBox::Critical, QMessageBox::Ok | QMessageBox::Default, QMessageBox::NoButton, QMessageBox::NoButton );
mb.exec();
mb.hide();
}
else
{ QMessageBox mb( tr("Downloading error."), tr(" Download ERROR.\n If you use proxy: Run Console (terminal)\n and enter command:\n export http_proxy=http://proxy:<port #>\n then run from terminal qpegps\n Example:\n# export http_proxy=http://mypoxy:8080\n# qpegps\n Push OK button."), QMessageBox::Critical, QMessageBox::Ok | QMessageBox::Default, QMessageBox::NoButton, QMessageBox::NoButton );
mb.exec();
mb.hide();
}
}
else mb.hide();
sleep(2);
free(com);
mapSelector->reReadMaps();
break;
}
break;
}
}
void MapInfo::startImportD()
{
ImportMapDialog imDialog(mapSelector, this, "import map", TRUE, 0);
imDialog.setCaption(tr("select image"));
imDialog.exec();
if(imDialog.result()==QDialog::Accepted && imDialog.imageSelected)
{
#ifndef DESKTOP
QFileInfo fi(imDialog.mapImageLnk.file());
#else
QString file = imDialog.imageDialog->selectedFile();
QFileInfo fi(file);
#endif
QString fn = mapSelector->mapPathStr();
fn.append("/"+fi.baseName()+".png");
QImage *orgImage;
orgImage = new QImage(fi.filePath());
if(orgImage->depth() > 8) // use max. 8 bit colors to reduce memory consumption
*orgImage = orgImage->convertDepth(8);
image = new QPixmap();
image->convertFromImage(*orgImage);
delete orgImage;
image = new QPixmap(fi.filePath());
MapParDialog mapPar(0,this,"set parameter",TRUE,0);
mapPar.setCaption(tr("set projection parameter"));
mapPar.exec();
if(mapPar.result()==QDialog::Accepted)
{
/* transfer map parameters to map entry */
switch(mapPar.projectionCB->currentItem() )
{
case 0: // LINEAR
{
QString str = fi.baseName() +".png "+ mapPar.scaleLE->text() +" "+
str.setNum(image->width()) +" "+ str.setNum(image->height())
+" "+
QString::number(Position::number(mapPar.lg1LE->text(), Position::Lon)) +" "+
QString::number(Position::number(mapPar.lt1LE->text(), Position::Lat)) +" "+
mapPar.x1LE->text() +" "+ mapPar.y1LE->text() +" "+
QString::number(Position::number(mapPar.lg2LE->text(), Position::Lon)) +" "+
QString::number(Position::number(mapPar.lt2LE->text(), Position::Lat)) +" "+
mapPar.x2LE->text() +" "+ mapPar.y2LE->text();
MapLin * mapLin = new MapLin(str);
mapSelector->addMap(mapLin);
}
break;
case 1: // CEA
{
QString str = fi.baseName() +".png "+ mapPar.scaleLE->text() +" "+
str.setNum(image->width()) +" "+ str.setNum(image->height())
+" "+
QString::number(Position::number(mapPar.lg1LE->text(), Position::Lon)) +" "+
QString::number(Position::number(mapPar.lt1LE->text(), Position::Lat)) +" "+
mapPar.x1LE->text() +" "+ mapPar.y1LE->text() + " "+
QString::number(Position::number(mapPar.lg2LE->text(), Position::Lon)) +" "+
QString::number(Position::number(mapPar.lt2LE->text(), Position::Lat)) +" "+
mapPar.x2LE->text() +" "+ mapPar.y2LE->text();
MapCEA * mapCea = new MapCEA(str);
mapSelector->addMap(mapCea);
}
break;
case 2: // UTM
{
QString str = fi.baseName() +".png "+ mapPar.scaleLE->text() +" "+
str.setNum(image->width()) +" "+
str.setNum(image->height())
+" "+
mapPar.zoneLE->text() +" "+ mapPar.lt1LE->text() +" "+
mapPar.lg1LE->text() +" "+
mapPar.x1LE->text() +" "+ mapPar.y1LE->text() + " "+
mapPar.lt2LE->text() +" "+ mapPar.lg2LE->text() +" "+
mapPar.x2LE->text() +" "+ mapPar.y2LE->text();
MapUTM * mapUtm2 = new MapUTM(str, TRUE);
mapSelector->addMap(mapUtm2);
}
break;
case 3: // TM
{
QString str = fi.baseName() +".png "+ mapPar.scaleLE->text() +" "+
str.setNum(image->width()) +" "+
str.setNum(image->height())
+" "+
QString::number(Position::number(mapPar.lg1LE->text(), Position::Lon)) +" "+
QString::number(Position::number(mapPar.lt1LE->text(), Position::Lat)) +" "+
mapPar.x1LE->text() +" "+ mapPar.y1LE->text() + " "+
QString::number(Position::number(mapPar.lg2LE->text(), Position::Lon)) +" "+
QString::number(Position::number(mapPar.lt2LE->text(), Position::Lat)) +" "+
mapPar.x2LE->text() +" "+ mapPar.y2LE->text() +
" "+ QString::number(Position::number(mapPar.stdLongLE->text(), Position::Lon));
MapUTM * mapUtm3 = new MapUTM(str, FALSE);
mapSelector->addMap(mapUtm3);
}
break;
case 4: // MERCATOR
{
QString str = fi.baseName() +".png "+ mapPar.scaleLE->text() +" "+
str.setNum(image->width()) +" "+ str.setNum(image->height())
+" "+
QString::number(Position::number(mapPar.lg1LE->text(), Position::Lon)) +" "+
QString::number(Position::number(mapPar.lt1LE->text(), Position::Lat)) +" "+
mapPar.x1LE->text() +" "+ mapPar.y1LE->text() + " "+
QString::number(Position::number(mapPar.lg2LE->text(), Position::Lon)) +" "+
QString::number(Position::number(mapPar.lt2LE->text(), Position::Lat)) +" "+
mapPar.x2LE->text() +" "+ mapPar.y2LE->text();
MapMercator * mapMercator = new MapMercator(str);
mapSelector->addMap(mapMercator);
}
break;
case 5: // LAMBERT
{
QString str = fi.baseName() +".png "+ mapPar.scaleLE->text() +" "+
str.setNum(image->width()) +" "+ str.setNum(image->height())
+" "+
QString::number(Position::number(mapPar.lg1LE->text(), Position::Lon)) +" "+
QString::number(Position::number(mapPar.lt1LE->text(), Position::Lat)) +" "+
mapPar.x1LE->text() +" "+ mapPar.y1LE->text() + " "+
QString::number(Position::number(mapPar.lg2LE->text(), Position::Lon)) +" "+
QString::number(Position::number(mapPar.lt2LE->text(), Position::Lat)) +" "+
mapPar.x2LE->text() +" "+ mapPar.y2LE->text() +
" "+ QString::number(Position::number(mapPar.stdLat1LE->text(), Position::Lat)) +" "+
QString::number(Position::number(mapPar.stdLat2LE->text(), Position::Lat)) +" "+
QString::number(Position::number(mapPar.refLongLE->text(), Position::Lon));
MapLambert * mapLambert = new MapLambert(str);
mapSelector->addMap(mapLambert);
}
break;
case 6: // FRITZ
{
QString str = fi.baseName() +".png "+ mapPar.scaleLE->text() +" "+
str.setNum(image->width()) +" "+ str.setNum(image->height())
+" "+ QString::number(Position::number(mapPar.centerLatLE->text(), Position::Lat)) +" "+
QString::number(Position::number(mapPar.centerLongLE->text(), Position::Lon));
MapFritz * mapFritz = new MapFritz(str);
mapSelector->addMap(mapFritz);
}
break;
}
if(imDialog.bg && imDialog.bg->id(imDialog.bg->selected()))
{
#ifndef DESKTOP
// delete original image file/docLnk
imDialog.mapImageLnk.removeFiles();
//QFile mapFileOrg(imDialog.mapImageLnk.file());
//mapFileOrg.remove();
//QFile mapFileOrgL(imDialog.mapImageLnk.linkFile());
//mapFileOrgL.remove();
#else
QFile mapFileOrg(file);
mapFileOrg.remove();
#endif
}
if( !image->save(fn,"PNG"))
qWarning(tr("could not create map image"));
delete image;
mapSelector->writeMapFile();
mapListChanged();
}
}
}
void MapInfo::startRemoveD()
{
RemoveMapDialog rmDialog(mapSelector->at(mapSelect->currentItem()), this, "remove map", TRUE, 0);
rmDialog.setCaption(tr("Remove Map"));
rmDialog.exec();
if(rmDialog.result()==QDialog::Accepted)
{
if (rmDialog.deleteCB->isChecked())
{
QString filename = mapSelector->mapPathStr();
filename.append(mapSelect->currentText());
QFile mapImage(filename);
mapImage.remove();
}
mapSelector->delMap(mapSelect->currentItem());
mapSelector->writeMapFile();
if(mapSelect->currentItem()>0)
mapsIndex = mapSelect->currentItem()-1;
else
mapsIndex = 0;
mapListChanged();
}
}
void MapInfo::startChangeD()
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -