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

📄 qgspointdialog.cpp

📁 一个非常好的GIS开源新版本
💻 CPP
📖 第 1 页 / 共 2 页
字号:
			    "supported.</p>"));      return false;    }    else    {      QMessageBox::critical(this, tr("Not implemented!"),			    tr("<p>The ") +                            cmbTransformType->currentText() +                            tr(" transform is not yet supported.</p>"));      return false;          }  }  catch (std::domain_error& e)  {    QMessageBox::critical(this, tr("Error"), QString(e.what()));    return false;  }  // warp the raster if needed  double xOffset = 0;  double yOffset = 0;  if (rotation != 0)  {    QgsGeorefWarpOptionsDialog d(this);    d.exec();    bool useZeroForTrans;    QString compressionMethod;    QgsImageWarper::ResamplingMethod resampling;    QgsImageWarper warper(-rotation);    d.getWarpOptions(resampling, useZeroForTrans, compressionMethod);    warper.warp(mLayer->source(), outputFileName, 		xOffset, yOffset, resampling, useZeroForTrans, compressionMethod);  }  // write the world file  QFile file(worldFileName);  if (!file.open(QIODevice::WriteOnly))  {    QMessageBox::critical(this, tr("Error"),          tr("Could not write to ") + worldFileName);    return false;  }  QTextStream stream(&file);  stream<<QString::number(pixelXSize, 'f', 15)<<endl	<<0<<endl	<<0<<endl	<<QString::number(-pixelYSize, 'f', 15)<<endl	<<QString::number((origin.x() - xOffset * pixelXSize), 'f', 15)<<endl	<<QString::number((origin.y() + yOffset * pixelYSize), 'f', 15)<<endl;    // write the data points in case we need them later  QFile pointFile(mLayer->source() + ".points");  if (pointFile.open(QIODevice::WriteOnly))  {    QTextStream points(&pointFile);    points<<"mapX\tmapY\tpixelX\tpixelY"<<endl;    for (unsigned int i = 0; i < mapCoords.size(); ++i)    {      points<<(QString("%1\t%2\t%3\t%4").	       arg(mapCoords[i].x()).arg(mapCoords[i].y(), 0, 'f', 15).	       arg(pixelCoords[i].x()).arg(pixelCoords[i].y(), 0, 'f', 15))<<endl;    }  }  return true;}void QgsPointDialog::zoomIn(){  mCanvas->setMapTool(mToolZoomIn);}void QgsPointDialog::zoomOut(){  mCanvas->setMapTool(mToolZoomOut);}void QgsPointDialog::zoomToLayer(){  if(mLayer)    {      mCanvas->setExtent(mLayer->extent());      mCanvas->refresh();    }}void QgsPointDialog::pan(){  mCanvas->setMapTool(mToolPan);}void QgsPointDialog::addPoint(){  mCanvas->setMapTool(mToolAddPoint);}void QgsPointDialog::deletePoint(){  mCanvas->setMapTool(mToolDeletePoint);}void QgsPointDialog::showCoordDialog(QgsPoint& pixelCoords){  MapCoordsDialog* mcd = new MapCoordsDialog(pixelCoords, mIface->getMapCanvas(), this);  connect(mcd, SIGNAL(pointAdded(const QgsPoint&, const QgsPoint&)),          this, SLOT(addPoint(const QgsPoint&, const QgsPoint&)));  mcd->show();}void QgsPointDialog::deleteDataPoint(QgsPoint& coords){  std::vector<QgsGeorefDataPoint*>::iterator it = mPoints.begin();    double maxDistSqr = (5 * mCanvas->mupp())*(5 * mCanvas->mupp());#ifdef QGISDEBUG  std::cout << "deleteDataPoint! maxDistSqr: " << maxDistSqr << std::endl;#endif  for ( ; it != mPoints.end(); it++)  {    QgsGeorefDataPoint* pt = *it;    double x = pt->pixelCoords().x() - coords.x();    double y = pt->pixelCoords().y() - coords.y();#ifdef QGISDEBUG  std::cout << "deleteDataPoint! test: " << (x*x+y*y) << std::endl;#endif    if ((x*x + y*y) < maxDistSqr)    {      mPoints.erase(it);      delete *it;      --mAcetateCounter;      mCanvas->refresh();      break;    }  }}void QgsPointDialog::enableRelevantControls(){  if (cmbTransformType->currentText() == tr("Linear"))  {    leSelectModifiedRaster->setEnabled(false);    pbnSelectModifiedRaster->setEnabled(false);  }  else  {    leSelectModifiedRaster->setEnabled(true);    pbnSelectModifiedRaster->setEnabled(true);  }    if ((cmbTransformType->currentText() == tr("Linear") &&       !leSelectWorldFile->text().isEmpty()) ||      (!leSelectWorldFile->text().isEmpty() &&       !leSelectModifiedRaster->text().isEmpty()))  {    pbnGenerateWorldFile->setEnabled(true);    pbnGenerateAndLoad->setEnabled(true);  }  else  {    pbnGenerateWorldFile->setEnabled(false);    pbnGenerateAndLoad->setEnabled(false);  }}QString QgsPointDialog::guessWorldFileName(const QString& raster){  int point = raster.findRev('.');  QString worldfile = "";  if (point != -1 && point != raster.length() - 1)     {      worldfile = raster.left(point + 1);      //MH: suffix .wld seems to be fine for most GDAL drivers      worldfile += "wld";    }  return worldfile;}void QgsPointDialog::enableModifiedRasterControls(bool state){  lblSelectModifiedRaster->setEnabled(state);  pbnSelectModifiedRaster->setEnabled(state);  leSelectModifiedRaster->setEnabled(state);}void QgsPointDialog::initialize(){  setupUi(this);    QString myIconPath = QgsApplication::themePath();    // setup actions  //  mActionZoomIn= new QAction(QIcon(myIconPath+"/mActionZoomIn.png"), tr("Zoom In"), this);  mActionZoomIn->setShortcut(tr("z"));  mActionZoomIn->setStatusTip(tr("Zoom In"));  connect(mActionZoomIn, SIGNAL(triggered()), this, SLOT(zoomIn()));  //  mActionZoomOut= new QAction(QIcon(myIconPath+"/mActionZoomOut.png"), tr("Zoom Out"), this);  mActionZoomOut->setShortcut(tr("Z"));  mActionZoomOut->setStatusTip(tr("Zoom Out"));  connect(mActionZoomOut, SIGNAL(triggered()), this, SLOT(zoomOut()));  //  mActionZoomToLayer= new QAction(QIcon(myIconPath+"/mActionZoomToLayer.png"), tr("Zoom To Layer"), this);  //mActionZoomToLayer->setShortcut(tr("Ctrl+O"));  mActionZoomToLayer->setStatusTip(tr("Zoom to Layer"));  connect(mActionZoomToLayer, SIGNAL(triggered()), this, SLOT(zoomToLayer()));  //  mActionPan= new QAction(QIcon(myIconPath+"/mActionPan.png"), tr("Pan Map"), this);  mActionPan->setStatusTip(tr("Pan the map"));  connect(mActionPan, SIGNAL(triggered()), this, SLOT(pan()));  //  mActionAddPoint= new QAction(QIcon(myIconPath+"/mActionCapturePoint.png"), tr("Add Point"), this);  mActionAddPoint->setShortcut(tr("."));  mActionAddPoint->setStatusTip(tr("Capture Points"));  connect(mActionAddPoint, SIGNAL(triggered()), this, SLOT(addPoint()));  //  mActionDeletePoint = new QAction(QIcon(myIconPath+"/mActionDeleteSelected.png"), tr("Delete Point"), this);  mActionDeletePoint->setStatusTip(tr("Delete Selected"));  connect(mActionDeletePoint, SIGNAL(triggered()), this, SLOT(deletePoint()));    // Map Tool Group  mMapToolGroup = new QActionGroup(this);  mActionPan->setCheckable(true);  mMapToolGroup->addAction(mActionPan);  mActionZoomIn->setCheckable(true);  mMapToolGroup->addAction(mActionZoomIn);  mActionZoomOut->setCheckable(true);  mMapToolGroup->addAction(mActionZoomOut);  mMapToolGroup->addAction(mActionZoomToLayer);  mActionAddPoint->setCheckable(true);  mMapToolGroup->addAction(mActionAddPoint);  mActionDeletePoint->setCheckable(true);  mMapToolGroup->addAction(mActionDeletePoint);    // set appopriate actions for tool buttons  tbnZoomIn->setDefaultAction(mActionZoomIn);  tbnZoomOut->setDefaultAction(mActionZoomOut);  tbnZoomToLayer->setDefaultAction(mActionZoomToLayer);  tbnPan->setDefaultAction(mActionPan);  tbnAddPoint->setDefaultAction(mActionAddPoint);  tbnDeletePoint->setDefaultAction(mActionDeletePoint);    // set up the canvas  QHBoxLayout* layout = new QHBoxLayout(canvasFrame);  layout->setAutoAdd(true);  mCanvas = new QgsMapCanvas(canvasFrame, "georefCanvas");  mCanvas->setBackgroundColor(Qt::white);  mCanvas->setMinimumWidth(400);  //mCanvas->freeze(true);    // set up map tools  mToolZoomIn = new QgsMapToolZoom(mCanvas, FALSE /* zoomOut */);   mToolZoomIn->setAction(mActionZoomIn);  mToolZoomOut = new QgsMapToolZoom(mCanvas, TRUE /* zoomOut */);   mToolZoomOut->setAction(mActionZoomOut);  mToolPan = new QgsMapToolPan(mCanvas);   mToolPan->setAction(mActionPan);  mToolAddPoint = new QgsGeorefTool(mCanvas, this, TRUE /* addPoint */);   mToolAddPoint->setAction(mActionAddPoint);  mToolDeletePoint = new QgsGeorefTool(mCanvas, this, FALSE /* addPoint */);   mToolDeletePoint->setAction(mActionDeletePoint);  // set the currently supported transforms  cmbTransformType->addItem(tr("Linear"));  cmbTransformType->addItem(tr("Helmert"));  enableModifiedRasterControls(false);  addPoint();  pbnGenerateWorldFile->setEnabled(false);  pbnGenerateAndLoad->setEnabled(false);}

⌨️ 快捷键说明

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