def __init__(self, drawingType, siteCode='', georef=False, parent=None):
        super(SelectDrawingDialog, self).__init__(parent)
        self.setupUi(self)

        self._dir = None  # QDir
        self._fileList = []
        self._georef = georef

        keys = sorted(Config.classCodes.keys())
        for key in keys:
            classCode = Config.classCodes[key]
            if classCode['drawing']:
                self.drawingTypeCombo.addItem(classCode['label'], classCode['class'])
        self.drawingTypeCombo.setCurrentIndex(self.drawingTypeCombo.findData(drawingType))
        self.drawingTypeCombo.currentIndexChanged.connect(self._findFiles)
        self.findFilter = ReturnPressedFilter(self)
        self.findFilter.returnPressed.connect(self._findFiles)
        self.siteCodeEdit.installEventFilter(self.findFilter)
        self.idSpin.installEventFilter(self.findFilter)
        self.eastingSpin.installEventFilter(self.findFilter)
        self.northingSpin.installEventFilter(self.findFilter)
        self.idSpin.lineEdit().selectAll()
        self.fileList.setSelectionMode(QAbstractItemView.ExtendedSelection)
        self.buttonBox.button(QDialogButtonBox.Open).setDefault(True)

        if georef:
            self._dir = Settings.georefDrawingDir(drawingType)
        else:
            self._dir = Settings.drawingDir(drawingType)
        self._dir.setFilter(QDir.Files | QDir.NoDotAndDotDot)
        self.siteCodeEdit.setText(siteCode)
        self.findButton.clicked.connect(self._findFiles)
        self._findFiles()
    def __init__(self, drawingType, siteCode='', georef=False, parent=None):
        super(SelectDrawingDialog, self).__init__(parent)
        self.setupUi(self)

        self._dir = None  # QDir
        self._fileList = []
        self._georef = georef

        keys = sorted(Config.classCodes.keys())
        for key in keys:
            classCode = Config.classCodes[key]
            if classCode['drawing']:
                self.drawingTypeCombo.addItem(classCode['label'],
                                              classCode['class'])
        self.drawingTypeCombo.setCurrentIndex(
            self.drawingTypeCombo.findData(drawingType))
        self.drawingTypeCombo.currentIndexChanged.connect(self._findFiles)
        self.findFilter = ReturnPressedFilter(self)
        self.findFilter.returnPressed.connect(self._findFiles)
        self.siteCodeEdit.installEventFilter(self.findFilter)
        self.idSpin.installEventFilter(self.findFilter)
        self.eastingSpin.installEventFilter(self.findFilter)
        self.northingSpin.installEventFilter(self.findFilter)
        self.idSpin.lineEdit().selectAll()
        self.fileList.setSelectionMode(QAbstractItemView.ExtendedSelection)
        self.buttonBox.button(QDialogButtonBox.Open).setDefault(True)

        if georef:
            self._dir = Settings.georefDrawingDir(drawingType)
        else:
            self._dir = Settings.drawingDir(drawingType)
        self._dir.setFilter(QDir.Files | QDir.NoDotAndDotDot)
        self.siteCodeEdit.setText(siteCode)
        self.findButton.clicked.connect(self._findFiles)
        self._findFiles()
示例#3
0
 def georeferencePlan(self, sourceFile, mode='name'):
     drawings = Config.drawings
     for drawing in drawings:
         drawings[drawing]['raw'] = Settings.drawingDir(drawing)
         drawings[drawing]['geo'] = Settings.georefDrawingDir(drawing)
         drawings[drawing]['suffix'] = '_r'
         drawings[drawing]['crs'] = self._plugin.project().crs().authid()
         drawings[drawing]['grid'] = self._plugin.project().collection('grid').layer('points')
         drawings[drawing]['local_x'] = 'local_x'
         drawings[drawing]['local_y'] = 'local_y'
     georefDialog = GeorefDialog(drawings)
     if georefDialog.loadImage(sourceFile) and georefDialog.exec_():
         self._setDrawing(georefDialog.drawing())
         self._plugin.project().loadGeoLayer(georefDialog.geoFileInfo())
示例#4
0
 def loadDrawing(self, item, zoomToDrawing=True):
     if not Config.classCodes[item.classCode()]['drawing']:
         return
     drawingDir = Settings.georefDrawingDir(item.classCode())
     drawingDir.setFilter(QDir.Files | QDir.NoDotAndDotDot)
     name = item.name()
     nameList = []
     nameList.append(name + '.png')
     nameList.append(name + '.tif')
     nameList.append(name + '.tiff')
     nameList.append(name + '_*.png')
     nameList.append(name + '_*.tif')
     nameList.append(name + '_*.tiff')
     drawingDir.setNameFilters(nameList)
     drawings = drawingDir.entryInfoList()
     for drawing in drawings:
         self._setDrawing(Drawing(drawing))
         self._plugin.loadGeoLayer(drawing, zoomToDrawing)
示例#5
0
 def _configureDrawing(self, drawing):
     Settings.drawingDir(drawing).mkpath('.')
     Settings.georefDrawingDir(drawing).mkpath('.')