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()
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())
def _configureDrawing(self, drawing): Settings.drawingDir(drawing).mkpath('.') Settings.georefDrawingDir(drawing).mkpath('.')