dtDialog.py 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. # -*- coding: utf-8 -*-
  2. """
  3. /***************************************************************************
  4. DigitizingTools
  5. A QGIS plugin
  6. Subsumes different tools useful during digitizing sessions
  7. -------------------
  8. begin : 2013-02-25
  9. copyright : (C) 2013 by Bernhard Ströbl
  10. email : bernhard.stroebl@jena.de
  11. ***************************************************************************/
  12. /***************************************************************************
  13. * *
  14. * This program is free software; you can redistribute it and/or modify *
  15. * it under the terms of the GNU General Public License as published by *
  16. * the Free Software Foundation; either version 2 of the License, or *
  17. * (at your option) any later version. *
  18. * *
  19. ***************************************************************************/
  20. """
  21. from qgis.PyQt import QtWidgets, QtCore, uic
  22. import os
  23. from dtutils import dtGetVectorLayersByType
  24. ABOUT_CLASS, _ = uic.loadUiType(os.path.join(
  25. os.path.dirname(__file__), 'ui_about.ui'))
  26. CUTTER_CLASS, _ = uic.loadUiType(os.path.join(
  27. os.path.dirname(__file__), 'ui_dtcutter.ui'))
  28. class DigitizingToolsAbout(QtWidgets.QDialog, ABOUT_CLASS):
  29. def __init__(self, iface):
  30. QtWidgets.QDialog.__init__(self)
  31. self.setupUi(self)
  32. # keep reference to QGIS interface
  33. self.iface = iface
  34. aboutText = QtCore.QCoreApplication.translate("dtAbout", "Subsumes different tools useful during digitizing sessions")
  35. aboutText += "\n\n"
  36. aboutText += QtCore.QCoreApplication.translate("dtAbout", "List of Contributors:")
  37. aboutText +="\n"
  38. aboutText += "Sandra Lopes (Portugese translation)"
  39. aboutText +="\n"
  40. aboutText += "Alexandre Neto"
  41. aboutText += "\n"
  42. aboutText += "Jean-Cyrille Notter (French translation)"
  43. aboutText += "\n"
  44. aboutText += u"Bernhard Ströbl"
  45. aboutText += "\n"
  46. aboutText += u"Angelos Tzotsos"
  47. aboutText += "\n\n"
  48. aboutText += u"DigitizingTools is copyright (C) 2013 Bernhard Ströbl bernhard.stroebl[at]jena.de\n\n"
  49. aboutText += u"Licensed under the terms of the GNU GPL V 2:\n"
  50. aboutText += u"This program is free software; you can redistribute it and/or modify it under the"
  51. aboutText += " terms of the GNU General Public License as published by the Free Software Foundation;"
  52. aboutText += " either version 2 of the License, or (at your option) any later version."
  53. #QtGui.QMessageBox.information(None, "", aboutText)
  54. self.textArea.setPlainText(aboutText)
  55. class DtChooseCutterLayer(QtWidgets.QDialog, CUTTER_CLASS):
  56. def __init__(self, iface, isPolygonLayer, lastChoice):
  57. QtWidgets.QDialog.__init__(self)
  58. self.setupUi(self)
  59. # keep reference to QGIS interface
  60. self.iface = iface
  61. self.isPolygonLayer = isPolygonLayer
  62. self.setWindowTitle(QtCore.QCoreApplication.translate("dtCutterDialog",
  63. "Choose Layer"))
  64. self.lblCutter.setText(QtCore.QCoreApplication.translate("dtCutterDialog",
  65. "cutter layer"))
  66. self.chkCopy.setText(QtCore.QCoreApplication.translate("dtCutterDialog",
  67. "add cutter polygon to edit layer"))
  68. self.cutterLayer = lastChoice[0]
  69. self.copyPoly = lastChoice[1]
  70. self.initialize()
  71. def initialize(self):
  72. self.cbxLayer.clear()
  73. layerList = dtGetVectorLayersByType(self.iface, 2, False)
  74. for keyValue, valueArray in list(layerList.items()):
  75. self.cbxLayer.addItem(keyValue, valueArray)
  76. if self.cutterLayer != None:
  77. if self.cutterLayer.id() == valueArray[0]:
  78. self.cbxLayer.setCurrentText(keyValue)
  79. if not self.isPolygonLayer:
  80. self.chkCopy.setChecked(False)
  81. else:
  82. self.chkCopy.setChecked(self.copyPoly)
  83. self.chkCopy.setEnabled(self.isPolygonLayer)
  84. def accept(self):
  85. self.cutterLayer = self.cbxLayer.currentData()[1]
  86. self.copyPoly = self.chkCopy.isChecked()
  87. self.done(1)