⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qgsgpsplugingui.cpp

📁 一个非常好的GIS开源新版本
💻 CPP
📖 第 1 页 / 共 2 页
字号:
void QgsGPSPluginGui::on_pbnIMPOutput_clicked() {  QString myFileNameQString =     QFileDialog::getSaveFileName(this, //parent dialog				 tr("Choose a filename to save under"),                 ".", //initial dir				 tr("GPS eXchange format (*.gpx)"));  if (!myFileNameQString.isEmpty())    leIMPOutput->setText(myFileNameQString);}void QgsGPSPluginGui::populatePortComboBoxes() {  #ifdef linux  // look for linux serial devices  QString linuxDev("/dev/ttyS%1");  for (int i = 0; i < 10; ++i) {    if (QFileInfo(linuxDev.arg(i)).exists()) {      cmbDLPort->insertItem(linuxDev.arg(i));      cmbULPort->insertItem(linuxDev.arg(i));    }    else      break;  }    // and the ttyUSB* devices (serial USB adaptor)  linuxDev = "/dev/ttyUSB%1";  for (int i = 0; i < 10; ++i) {    if (QFileInfo(linuxDev.arg(i)).exists()) {      cmbDLPort->insertItem(linuxDev.arg(i));      cmbULPort->insertItem(linuxDev.arg(i));    }    else      break;  }  #endif#ifdef __FreeBSD__ // freebsd  // and freebsd devices (untested)  QString freebsdDev("/dev/cuaa%1");  for (int i = 0; i < 10; ++i) {    if (QFileInfo(freebsdDev.arg(i)).exists()) {      cmbDLPort->insertItem(freebsdDev.arg(i));      cmbULPort->insertItem(freebsdDev.arg(i));    }    else      break;  }  // and the ucom devices (serial USB adaptors)  freebsdDev = "/dev/ucom%1";  for (int i = 0; i < 10; ++i) {    if (QFileInfo(freebsdDev.arg(i)).exists()) {      cmbDLPort->insertItem(freebsdDev.arg(i));      cmbULPort->insertItem(freebsdDev.arg(i));    }    else      break;  } #endif  #ifdef sparc  // and solaris devices (also untested)  QString solarisDev("/dev/cua/%1");  for (int i = 'a'; i < 'k'; ++i) {    if (QFileInfo(solarisDev.arg(char(i))).exists()) {      cmbDLPort->insertItem(solarisDev.arg(char(i)));      cmbULPort->insertItem(solarisDev.arg(char(i)));    }    else      break;  }#endif#ifdef WIN32  cmbULPort->insertItem("com1");  cmbULPort->insertItem("com2");  cmbULPort->insertItem("usb:");  cmbDLPort->insertItem("com1");  cmbDLPort->insertItem("com2");  cmbDLPort->insertItem("usb:");#endif  // OSX, OpenBSD, NetBSD etc? Anyone?    // remember the last ports used  QSettings settings;  QString lastDLPort = settings.readEntry("/Plugin-GPS/lastdlport", "");  QString lastULPort = settings.readEntry("/Plugin-GPS/lastulport", "");  for (int i = 0; i < cmbDLPort->count(); ++i) {    if (cmbDLPort->text(i) == lastDLPort) {      cmbDLPort->setCurrentItem(i);      break;    }  }  for (int i = 0; i < cmbULPort->count(); ++i) {    if (cmbULPort->text(i) == lastULPort) {      cmbULPort->setCurrentItem(i);      break;    }  }}void QgsGPSPluginGui::populateULLayerComboBox() {  for (std::vector<QgsVectorLayer*>::size_type i = 0; i < mGPXLayers.size(); ++i)    cmbULLayer->insertItem(mGPXLayers[i]->name());}void QgsGPSPluginGui::populateIMPBabelFormats() {  mBabelFilter = "";  cmbULDevice->clear();  cmbDLDevice->clear();  QSettings settings;  QString lastDLDevice = settings.readEntry("/Plugin-GPS/lastdldevice", "");  QString lastULDevice = settings.readEntry("/Plugin-GPS/lastuldevice", "");  BabelMap::const_iterator iter;  for (iter = mImporters.begin(); iter != mImporters.end(); ++iter)    mBabelFilter.append((const char*)iter->first).append(" (*.*);;");  mBabelFilter.chop(2);   // Remove the trailing ;;, which otherwise leads to an empty filetype  int u = -1, d = -1;  std::map<QString, QgsGPSDevice*>::const_iterator iter2;  for (iter2 = mDevices.begin(); iter2 != mDevices.end(); ++iter2) {    cmbULDevice->insertItem(iter2->first);    if (iter2->first == lastULDevice)      u = cmbULDevice->count() - 1;    cmbDLDevice->insertItem(iter2->first);    if (iter2->first == lastDLDevice)      d = cmbDLDevice->count() - 1;  }  if (u != -1)    cmbULDevice->setCurrentItem(u);  if (d != -1)    cmbDLDevice->setCurrentItem(d);}void QgsGPSPluginGui::populateLoadDialog() {  QString format = QString("<p>%1</p><p>%2</p>");  QString sentence1 = tr("GPX is the %1, which is used to store information about waypoints, routes, and tracks.").    arg(QString("<a href=http://www.topografix.com/gpx.asp>%1</a>").arg(tr("GPS eXchange file format")));  QString sentence2 = tr("Select a GPX file and then select the feature types that you want to load.");  QString text = format.arg(sentence1).arg(sentence2);  teLoadDescription->setHtml(text);  QgsDebugMsg(text);}void QgsGPSPluginGui::populateDLDialog() {  QString format = QString("<p>%1 %2 %3<p>%4 %5</p>");  QString sentence1 = tr("This tool will help you download data from a GPS device.");  QString sentence2 = tr("Choose your GPS device, the port it is connected to, the feature type you want to download, a name for your new layer, and the GPX file where you want to store the data.");  QString sentence3 = tr("If your device isn't listed, or if you want to change some settings, you can also edit the devices.");  QString sentence4 = tr("This tool uses the program GPSBabel (%1) to transfer the data.")    .arg("<a href=\"http://www.gpsbabel.org\">http://www.gpsbabel.org</a>");    QString sentence5 = tr("This requires that you have GPSBabel installed where QGIS can find it.");  QString text = format.arg(sentence1).arg(sentence2).arg(sentence3).arg(sentence4).arg(sentence5);  teDLDescription->setHtml(text);  QgsDebugMsg(text);}void QgsGPSPluginGui::populateULDialog() {  QString format = QString("<p>%1 %2 %3<p>%4 %5</p>");  QString sentence1 = tr("This tool will help you upload data from a GPX layer to a GPS device.");  QString sentence2 = tr("Choose the layer you want to upload, the device you want to upload it to, and the port your device is connected to.");  QString sentence3 = tr("If your device isn't listed, or if you want to change some settings, you can also edit the devices.");  QString sentence4 = tr("This tool uses the program GPSBabel (%1) to transfer the data.")    .arg("<a href=\"http://www.gpsbabel.org\">http://www.gpsbabel.org</a>");    QString sentence5 = tr("This requires that you have GPSBabel installed where QGIS can find it.");  QString text = format.arg(sentence1).arg(sentence2).arg(sentence3).arg(sentence4).arg(sentence5);  teULDescription->setHtml(text);  QgsDebugMsg(text);}void QgsGPSPluginGui::populateIMPDialog() {  QString format = QString("<p>%1 %2<p><p>%3 %4</p>");  QString sentence1 = tr("QGIS can only load GPX files by itself, but many other formats can be converted to GPX using GPSBabel (%1).")    .arg("<a href=\"http://www.gpsbabel.org\">http://www.gpsbabel.org</a>");  QString sentence2 = tr("This requires that you have GPSBabel installed where QGIS can find it.");  QString sentence3 = tr("Select a GPS file format and the file that you want to import, the feature type that you want to use, a GPX filename that you want to save the converted file as, and a name for the new layer.");  QString sentence4 = tr("All file formats can not store waypoints, routes, and tracks, so some feature types may be disabled for some file formats.");  QString text = format.arg(sentence1).arg(sentence2).arg(sentence3).arg(sentence4);  teIMPDescription->setHtml(text);  QgsDebugMsg(text);}void QgsGPSPluginGui::populateCONVDialog() {  cmbCONVType->insertItem(tr("Routes") + " -> " + tr("Waypoints"));  cmbCONVType->insertItem(tr("Waypoints") + " -> " + tr("Routes"));  QString format = QString("<html><body><p>%1 %2<p>%3</body></html>");  QString sentence1 = tr("QGIS can perform conversions of GPX files, by using GPSBabel (%1) to perform the conversions.")    .arg("<a href=\"http://www.gpsbabel.org\">http://www.gpsbabel.org</a>");  QString sentence2 = tr("This requires that you have GPSBabel installed where QGIS can find it.");  QString sentence3 = tr("Select a GPX input file name, the type of conversion you want to perform, a GPX filename that you want to save the converted file as, and a name for the new layer created from the result.");  QString text = format.arg(sentence1).arg(sentence2).arg(sentence3);  teCONVDescription->setHtml(text);  QgsDebugMsg(text);}void QgsGPSPluginGui::on_pbnCONVInput_clicked(){  QString myFileTypeQString;  QString myFilterString=tr("GPS eXchange format (*.gpx)");  QSettings settings;  QString dir = settings.readEntry("/Plugin-GPS/gpxdirectory");  if (dir.isEmpty())    dir = ".";  QString myFileNameQString = QFileDialog::getOpenFileName(          this, //parent dialog          tr("Select GPX file"), //caption          dir, //initial dir          myFilterString, //filters to select          &myFileTypeQString); //the pointer to store selected filter  if (!myFileNameQString.isEmpty())    leCONVInput->setText(myFileNameQString);}void QgsGPSPluginGui::on_pbnCONVOutput_clicked() {  QString myFileNameQString =     QFileDialog::getSaveFileName(this, //parent dialog				 tr("Choose a filename to save under"),                 ".", //initial dir				 tr("GPS eXchange format (*.gpx)"));  if (!myFileNameQString.isEmpty())    leCONVOutput->setText(myFileNameQString);}void QgsGPSPluginGui::openDeviceEditor() {  QgsGPSDeviceDialog* dlg = new QgsGPSDeviceDialog(mDevices);  dlg->show();  connect(dlg, SIGNAL(devicesChanged()), this, SLOT(devicesUpdated()));}void QgsGPSPluginGui::devicesUpdated() {  populateIMPBabelFormats();}void QgsGPSPluginGui::on_buttonBox_helpRequested(){  QgsContextHelp::run(context_id);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -