def waitForDistance(self): # imposto il map tool self.getPointMapTool().setMode(Qad_offset_maptool_ModeEnum.ASK_FOR_FIRST_OFFSET_PT) self.getPointMapTool().gapType = self.gapType keyWords = QadMsg.translate("Command_OFFSET", "Punto") + "/" + QadMsg.translate("Command_OFFSET", "Cancella") if self.offSet < 0: default = QadMsg.translate("Command_OFFSET", "Punto") else: default = self.offSet prompt = QadMsg.translate("Command_OFFSET", "Specificare distanza di offset o [{0}] <{1}>: ").format( keyWords, str(default) ) englishKeyWords = "Through" + "/" + "Erase" keyWords += "_" + englishKeyWords # si appresta ad attendere un punto o enter o una parola chiave o un numero reale # msg, inputType, default, keyWords, nessun controllo self.waitFor( prompt, QadInputTypeEnum.POINT2D | QadInputTypeEnum.FLOAT | QadInputTypeEnum.KEYWORDS, default, keyWords, QadInputModeEnum.NOT_ZERO | QadInputModeEnum.NOT_NEGATIVE, ) self.step = 1
def waitForObjectSel(self): self.step = 2 # imposto il map tool self.getPointMapTool().setSelectionMode(QadGetPointSelectionModeEnum.ENTITY_SELECTION_DYNAMIC) # solo layer lineari editabili che non appartengano a quote layerList = [] for layer in qad_utils.getVisibleVectorLayers(self.plugIn.canvas): # Tutti i layer vettoriali visibili if layer.geometryType() == QGis.Line and layer.isEditable(): if len(QadDimStyles.getDimListByLayer(layer)) == 0: layerList.append(layer) self.getPointMapTool().layersToCheck = layerList self.getPointMapTool().setDrawMode(QadGetPointDrawModeEnum.NONE) self.getPointMapTool().onlyEditableLayers = True keyWords = QadMsg.translate("Command_TRIM", "Fence") + "/" + \ QadMsg.translate("Command_TRIM", "Crossing") + "/" + \ QadMsg.translate("Command_TRIM", "Edge") + "/" + \ QadMsg.translate("Command_TRIM", "Undo") prompt = QadMsg.translate("Command_TRIM", "Select the object to trim or shift-select to extend or [{0}]: ").format(keyWords) englishKeyWords = "Fence" + "/" + "Crossing" + "/" + "Edge" + "/" + "Undo" keyWords += "_" + englishKeyWords # si appresta ad attendere un punto o enter o una parola chiave # msg, inputType, default, keyWords, nessun controllo self.waitFor(prompt, \ QadInputTypeEnum.POINT2D | QadInputTypeEnum.KEYWORDS, \ None, \ keyWords, QadInputModeEnum.NONE)
def refreshEntityGripPoints(self, entitySet = None): if entitySet is None: entitySet = self.entitySet gripObjLimit = QadVariables.get(QadMsg.translate("Environment variables", "GRIPOBJLIMIT")) if gripObjLimit != 0: # When set to 0, grips are always displayed. if entitySet.count() > gripObjLimit: # Suppresses the display of grips when the selection set includes more than the specified number of objects self.clearEntityGripPoints() return # cancello i grip delle entità che non sono in entitySet o che non sono in layer vettoriali modificabili i = self.entitySetGripPoints.count() - 1 while i >= 0: entityGripPoint = self.entitySetGripPoints.entityGripPoints[i] if entitySet.containsEntity(entityGripPoint.entity) == False or \ entityGripPoint.entity.layer.type() != QgsMapLayer.VectorLayer or entityGripPoint.entity.layer.isEditable() == False: self.entitySetGripPoints.entityGripPoints[i].removeItems() # lo stacco dal canvas del self.entitySetGripPoints.entityGripPoints[i] i = i - 1 entity = QadEntity() for layerEntitySet in entitySet.layerEntitySetList: # considero solo i layer vettoriali che sono modificabili layer = layerEntitySet.layer if layer.type() == QgsMapLayer.VectorLayer and layer.isEditable(): for featureId in layerEntitySet.featureIds: entity.set(layer, featureId) self.entitySetGripPoints.addEntity(entity, QadVariables.get(QadMsg.translate("Environment variables", "GRIPS")))
def waitForObjectSel(self): self.step = 2 # imposto il map tool self.getPointMapTool().setSelectionMode(QadGetPointSelectionModeEnum.ENTITY_SELECTION) # solo layer lineari editabili che non appartengano a quote layerList = [] for layer in self.plugIn.canvas.layers(): if layer.type() == QgsMapLayer.VectorLayer and layer.geometryType() == QGis.Line and \ layer.isEditable(): if len(self.plugIn.dimStyles.getDimListByLayer(layer)) == 0: layerList.append(layer) self.getPointMapTool().layersToCheck = layerList self.getPointMapTool().setDrawMode(QadGetPointDrawModeEnum.NONE) self.getPointMapTool().onlyEditableLayers = True keyWords = QadMsg.translate("Command_EXTEND", "iNTercetta") + "/" + \ QadMsg.translate("Command_EXTEND", "Interseca") + "/" + \ QadMsg.translate("Command_EXTEND", "Spigolo") + "/" + \ QadMsg.translate("Command_EXTEND", "Annulla") prompt = QadMsg.translate("Command_EXTEND", "Selezionare oggetto da estendere o selezionare oggetto tenendo premuto il tasto Maiusc per tagliarlo o [{0}]: ").format(keyWords) englishKeyWords = "Fence" + "/" + "Crossing" + "/" + "Edge" + "/" + "Undo" keyWords += "_" + englishKeyWords # si appresta ad attendere un punto o enter o una parola chiave # msg, inputType, default, keyWords, nessun controllo self.waitFor(prompt, \ QadInputTypeEnum.POINT2D | QadInputTypeEnum.KEYWORDS, \ None, \ keyWords, QadInputModeEnum.NONE)
def run(self, msgMapTool = False, msg = None): if self.plugIn.canvas.mapRenderer().destinationCrs().geographicFlag(): self.showMsg(QadMsg.translate("QAD", "\nThe coordinate reference system of the project must be a projected coordinate system.\n")) return True # fine comando if self.step == 0: self.waitForEntsel(msgMapTool, msg) self.step = 1 return False # continua elif self.step == 1: if self.EntSelClass.run(msgMapTool, msg) == True: if self.EntSelClass.entity.isInitialized(): layer = self.EntSelClass.entity.layer if self.plugIn.canvas.currentLayer() is None or \ self.plugIn.canvas.currentLayer() != layer: self.plugIn.canvas.setCurrentLayer(layer) self.plugIn.iface.setActiveLayer(layer) # lancia evento di deactivate e activate dei plugin self.plugIn.iface.legendInterface().refreshLayerSymbology(layer) msg = QadMsg.translate("Command_SETCURRLAYERBYGRAPH", "\nThe current layer is {0}.") self.showMsg(msg.format(layer.name())) del self.EntSelClass return True else: self.showMsg(QadMsg.translate("Command_SETCURRLAYERBYGRAPH", "No geometries in this position.")) self.waitForEntsel(msgMapTool, msg) return False # continua
def floatLineEditWidgetValidation(self, widget, varName, msg): var = self.tempQadVariables.getVariable(QadMsg.translate("Environment variables", varName)) err = False string = widget.text() if qad_utils.str2float(string) is None: err = True else: if var.minNum is not None: if qad_utils.str2float(string) < var.minNum: err = True if var.maxNum is not None: if qad_utils.str2float(string) > var.maxNum: err = True if err: msg = msg + QadMsg.translate("QAD", ": enter a number") if var.minNum is not None: minValMsg = msg + QadMsg.translate("QAD", " > {0}").format(str(var.minNum)) else: minValMsg = "" if var.maxNum is not None: if len(minValMsg) > 0: msg = msg + QadMsg.translate("QAD", " and") msg = msg + QadMsg.translate("QAD", " < {0}").format(str(var.maxNum)) msg = msg + "." QMessageBox.critical(self, "QAD", msg) widget.setFocus() widget.selectAll() return False return True
def init_selection_tab(self): # Inizializzazione del TAB "selection" # PICKBOX # aggiungo il QWidget chiamato QadPreviewPickBox # che eredita la posizione di widget_PICKBOX (che viene nascosto) self.widget_PICKBOX.setHidden(True) pickBoxColor = QColor(self.tempQadVariables.get(QadMsg.translate("Environment variables", "PICKBOXCOLOR"))) self.previewPickBox = QadPreviewPickBox(self.plugIn, pickBoxColor, self.widget_PICKBOX.parent()) self.previewPickBox.setGeometry(self.widget_PICKBOX.geometry()) self.previewPickBox.setObjectName("previewPickBox") var = self.tempQadVariables.getVariable(QadMsg.translate("Environment variables", "PICKBOX")) self.horizontalSlider_PICKBOX.setMinimum(var.minNum) #self.horizontalSlider_PICKBOX.setMaximum(var.maxNum) self.horizontalSlider_PICKBOX.setMaximum(20) # oltre i 20 non ci sta nel riquadro self.horizontalSlider_PICKBOX.setValue(var.value) # PICKFIRST pickFirst = False if self.tempQadVariables.get(QadMsg.translate("Environment variables", "PICKFIRST")) == 0 else True self.checkBox_PICKFIRST.setChecked(pickFirst) # PICKADD pickAdd = self.tempQadVariables.get(QadMsg.translate("Environment variables", "PICKADD")) if pickAdd == 0: self.checkBox_PICKADD.setChecked(True) else: self.checkBox_PICKADD.setChecked(False) # GRIPSIZE # aggiungo il QWidget chiamato QadPreviewGripSize # che eredita la posizione di widget_GRIPSIZE (che viene nascosto) self.widget_GRIPSIZE.setHidden(True) fillColor = QColor(self.tempQadVariables.get(QadMsg.translate("Environment variables", "GRIPCOLOR"))) borderColor = QColor(self.tempQadVariables.get(QadMsg.translate("Environment variables", "GRIPCONTOUR"))) self.previewGripSize = QadPreviewGripSize(self.plugIn, fillColor, borderColor, self.widget_GRIPSIZE.parent()) self.previewGripSize.setGeometry(self.widget_GRIPSIZE.geometry()) self.previewGripSize.setObjectName("previewGripSize") var = self.tempQadVariables.getVariable(QadMsg.translate("Environment variables", "GRIPSIZE")) self.horizontalSlider_GRIPSIZE.setMinimum(var.minNum) #self.horizontalSlider_PGRIPSIZE.setMaximum(var.maxNum) self.horizontalSlider_GRIPSIZE.setMaximum(20) # oltre i 20 non ci sta nel riquadro self.horizontalSlider_GRIPSIZE.setValue(var.value) # GRIPS grips = False if self.tempQadVariables.get(QadMsg.translate("Environment variables", "GRIPS")) == 0 else True self.checkBox_GRIPS.setChecked(grips) # GRIPMULTIFUNCTIONAL gripMultiFunctional = self.tempQadVariables.get(QadMsg.translate("Environment variables", "GRIPMULTIFUNCTIONAL")) self.checkBox_GRIPMULTIFUNCTIONAL_ON_DYNAMIC_MENU_AND_HOT_GRIPT.setChecked(gripMultiFunctional & QadGRIPMULTIFUNCTIONALEnum.ON_DYNAMIC_MENU_AND_HOT_GRIPT) # GRIPOBJLIMIT gripObjLimit = self.tempQadVariables.get(QadMsg.translate("Environment variables", "GRIPOBJLIMIT")) self.lineEdit_GRIPOBJLIMIT.setText(str(gripObjLimit)) self.lineEdit_GRIPOBJLIMIT.setValidator(QIntValidator(self.lineEdit_GRIPOBJLIMIT)) self.lineEdit_GRIPOBJLIMIT.installEventFilter(self) self.checkBox_GRIPS_ON_clicked()
def displayPopupMenu(self, pos): if self.selectedDimStyle is None: return popupMenu = QMenu(self) action = QAction(QadMsg.translate("DimStyle_Dialog", "Set current"), popupMenu) popupMenu.addAction(action) QObject.connect(action, SIGNAL("triggered()"), self.setCurrentStyle) action = QAction(QadMsg.translate("DimStyle_Dialog", "Rename"), popupMenu) popupMenu.addAction(action) QObject.connect(action, SIGNAL("triggered()"), self.startEditingItem) action = QAction(QadMsg.translate("DimStyle_Dialog", "Modify description"), popupMenu) popupMenu.addAction(action) QObject.connect(action, SIGNAL("triggered()"), self.updDescrSelectedDimStyle) action = QAction(QadMsg.translate("DimStyle_Dialog", "Remove"), popupMenu) currDimStyleName = QadVariables.get(QadMsg.translate("Environment variables", "DIMSTYLE")) if self.selectedDimStyle.name == currDimStyleName: action.setDisabled(True) popupMenu.addAction(action) QObject.connect(action, SIGNAL("triggered()"), self.delSelectedDimStyle) popupMenu.popup(self.dimStyleList.mapToGlobal(pos))
def getInvalidInputMsg(self): """ restituisce il messaggio di input non valido """ if self.inputType & QadInputTypeEnum.POINT2D or \ self.inputType & QadInputTypeEnum.POINT3D: if self.inputType & QadInputTypeEnum.KEYWORDS and \ (self.inputType & QadInputTypeEnum.FLOAT or self.inputType & QadInputTypeEnum.ANGLE): return QadMsg.translate("QAD", "\nEnter a point, a real number or a keyword.\n") elif self.inputType & QadInputTypeEnum.KEYWORDS: return QadMsg.translate("QAD", "\nEnter a point or a keyword.\n") elif self.inputType & QadInputTypeEnum.FLOAT or self.inputType & QadInputTypeEnum.ANGLE: return QadMsg.translate("QAD", "\nEnter a point or a real number.\n") else: return QadMsg.translate("QAD", "\nPoint not valid.\n") elif self.inputType & QadInputTypeEnum.KEYWORDS: return QadMsg.translate("QAD", "\nKeyword not valid.\n") elif self.inputType & QadInputTypeEnum.STRING: return QadMsg.translate("QAD", "\nString not valid.\n") elif self.inputType & QadInputTypeEnum.INT: return QadMsg.translate("QAD", "\nInteger number not valid.\n") elif self.inputType & QadInputTypeEnum.LONG: return QadMsg.translate("QAD", "\nLong integer number not valid.\n") elif self.inputType & QadInputTypeEnum.FLOAT or self.inputType & QadInputTypeEnum.ANGLE: return QadMsg.translate("QAD", "\nReal number not valid.\n") elif self.inputType & QadInputTypeEnum.BOOL: return QadMsg.translate("QAD", "\nBoolean not valid.\n") else: return ""
def WaitForMainMenu(self): self.poligonEntity.selectOnLayer(False) keyWords = QadMsg.translate("Command_MAPMPEDIT", "Add") + "/" + \ QadMsg.translate("Command_MAPMPEDIT", "Delete") + "/" + \ QadMsg.translate("Command_MAPMPEDIT", "Union") + "/" + \ QadMsg.translate("Command_MAPMPEDIT", "Substract") + "/" + \ QadMsg.translate("Command_MAPMPEDIT", "Intersect") + "/" + \ QadMsg.translate("Command_MAPMPEDIT", "include Objs") englishKeyWords = "Add" + "/" + "Delete" + "/" + "Union" + "/" + "Substract" + "/" + "Intersect" "/" + "include Objs" if self.nOperationsToUndo > 0: # se c'è qualcosa che si può annullare keyWords = keyWords + "/" + QadMsg.translate("Command_MAPMPEDIT", "Undo") englishKeyWords = englishKeyWords + "/" + "Undo" keyWords = keyWords + "/" + QadMsg.translate("Command_MAPMPEDIT", "eXit") englishKeyWords = englishKeyWords + "/" + "eXit" default = QadMsg.translate("Command_MAPMPEDIT", "eXit") prompt = QadMsg.translate("Command_MAPMPEDIT", "Enter an option [{0}] <{1}>: ").format(keyWords, default) self.step = 2 self.getPointMapTool().setSelectionMode(QadGetPointSelectionModeEnum.NONE) self.getPointMapTool().setDrawMode(QadGetPointDrawModeEnum.NONE) keyWords += "_" + englishKeyWords # si appresta ad attendere enter o una parola chiave # msg, inputType, default, keyWords, nessun controllo self.waitFor(prompt, \ QadInputTypeEnum.KEYWORDS, \ None, \ keyWords, QadInputModeEnum.NONE) return False
def addSnapTypeByPopupMenu(self, _snapType): value = QadVariables.get(QadMsg.translate("Environment variables", "OSMODE")) if value & QadSnapTypeEnum.DISABLE: value = value - QadSnapTypeEnum.DISABLE QadVariables.set(QadMsg.translate("Environment variables", "OSMODE"), value | _snapType) QadVariables.save() self.plugIn.refreshCommandMapToolSnapType()
def getInvalidInputMsg(self): """ restituisce il messaggio di input non valido """ if self.inputType & QadInputTypeEnum.POINT2D or \ self.inputType & QadInputTypeEnum.POINT3D: if self.inputType & QadInputTypeEnum.KEYWORDS and \ (self.inputType & QadInputTypeEnum.FLOAT or self.inputType & QadInputTypeEnum.ANGLE): return QadMsg.translate("QAD", "\nE' richiesto un punto, un numero reale o la parola chiave di un'opzione.\n") elif self.inputType & QadInputTypeEnum.KEYWORDS: return QadMsg.translate("QAD", "\nE' richiesto un punto o la parola chiave di un'opzione.\n") elif self.inputType & QadInputTypeEnum.FLOAT or self.inputType & QadInputTypeEnum.ANGLE: return QadMsg.translate("QAD", "\nE' richiesto un punto o un numero reale.\n") else: return QadMsg.translate("QAD", "\nPunto non valido.\n") elif self.inputType & QadInputTypeEnum.KEYWORDS: return QadMsg.translate("QAD", "\nParola chiave dell'opzione non valida.\n") elif self.inputType & QadInputTypeEnum.STRING: return QadMsg.translate("QAD", "\nStringa non valida.\n") elif self.inputType & QadInputTypeEnum.INT: return QadMsg.translate("QAD", "\nNumero intero non valido.\n") elif self.inputType & QadInputTypeEnum.LONG: return QadMsg.translate("QAD", "\nNumero intero lungo non valido.\n") elif self.inputType & QadInputTypeEnum.FLOAT or self.inputType & QadInputTypeEnum.ANGLE: return QadMsg.translate("QAD", "\nNumero reale non valido.\n") elif self.inputType & QadInputTypeEnum.BOOL: return QadMsg.translate("QAD", "\nValore booleano non valido.\n") else: return ""
def delCurrentSubGeomToPolygon(self): """ Cancella la sotto-geometria corrente dal poligono da modificare """ geom = self.poligonEntity.getGeometry() # la posizione é espressa con una lista (<index ogg. princ> [<index ogg. sec.>]) part = self.currAtSubGeom[0] if len(self.currAtSubGeom) == 2: ring = self.currAtSubGeom[1] if geom.deleteRing(ring + 1, part) == False: # cancello una isola (Ring 0 is outer ring and can't be deleted) self.showMsg(QadMsg.translate("QAD", "Invalid object.")) return False else: if geom.deletePart(part) == False: # cancello una parte self.showMsg(QadMsg.translate("QAD", "Invalid object.")) return False f = self.poligonEntity.getFeature() f.setGeometry(geom) self.plugIn.beginEditCommand("Feature edited", self.poligonEntity.layer) # plugIn, layer, feature, refresh, check_validity if qad_layer.updateFeatureToLayer(self.plugIn, self.poligonEntity.layer, f, False, False) == False: self.plugIn.destroyEditCommand() return False self.plugIn.endEditCommand() self.nOperationsToUndo = self.nOperationsToUndo + 1
def init_osnap_tab(self): # Inizializzazione del TAB che riguarda gli SNAP ad oggetto # Memorizzo il valore dell'OSMODE per determinare gli osnap impostati OsMode = QadVariables.get(QadMsg.translate("Environment variables", "OSMODE")) self.checkBox_CENP.setChecked(OsMode & QadSnapTypeEnum.CEN) self.checkBox_ENDP.setChecked(OsMode & QadSnapTypeEnum.END) self.checkBox_END_PLINE.setChecked(OsMode & QadSnapTypeEnum.END_PLINE) self.checkBox_EXTP.setChecked(OsMode & QadSnapTypeEnum.EXT) self.checkBox_INTP.setChecked(OsMode & QadSnapTypeEnum.INT) self.checkBox_MIDP.setChecked(OsMode & QadSnapTypeEnum.MID) self.checkBox_NODP.setChecked(OsMode & QadSnapTypeEnum.NOD) self.checkBox_QUADP.setChecked(OsMode & QadSnapTypeEnum.QUA) #self.checkBox_INSP.setChecked(OsMode & QadSnapTypeEnum.INS) #self.checkBox_INTAPP.setChecked(OsMode & QadSnapTypeEnum.APP) self.checkBox_NEARP.setChecked(OsMode & QadSnapTypeEnum.NEA) self.checkBox_PERP.setChecked(OsMode & QadSnapTypeEnum.PER) self.checkBox_PARALP.setChecked(OsMode & QadSnapTypeEnum.PAR) self.checkBox_PROGRESP.setChecked(OsMode & QadSnapTypeEnum.PR) self.checkBox_TANP.setChecked(OsMode & QadSnapTypeEnum.TAN) self.checkBox_EXT_INT.setChecked(OsMode & QadSnapTypeEnum.EXT_INT) self.checkBox_TANP.setChecked(OsMode & QadSnapTypeEnum.TAN) self.checkBox_IsOsnapON.setChecked(not(OsMode & QadSnapTypeEnum.DISABLE)) ProgrDistance = QadVariables.get(QadMsg.translate("Environment variables", "OSPROGRDISTANCE")) stringA = str(ProgrDistance) self.lineEdit_ProgrDistance.setText(stringA) self.lineEdit_ProgrDistance.setValidator(QDoubleValidator(self.lineEdit_ProgrDistance)) self.lineEdit_ProgrDistance.installEventFilter(self)
def waitForObjectSelToMisure(self): self.step = 1 # imposto il map tool self.getPointMapTool().setMode(Qad_lengthen_maptool_ModeEnum.ASK_FOR_OBJ_TO_MISURE) if self.plugIn.lastOpMode_lengthen == "DElta": self.defaultValue = QadMsg.translate("Command_LENGTHEN", "DElta") elif self.plugIn.lastOpMode_lengthen == "Percent": self.defaultValue = QadMsg.translate("Command_LENGTHEN", "Percent") elif self.plugIn.lastOpMode_lengthen == "Total": self.defaultValue = QadMsg.translate("Command_LENGTHEN", "Total") elif self.plugIn.lastOpMode_lengthen == "DYnamic": self.defaultValue = QadMsg.translate("Command_LENGTHEN", "DYnamic") else: self.defaultValue = None keyWords = QadMsg.translate("Command_LENGTHEN", "DElta") + "/" + \ QadMsg.translate("Command_LENGTHEN", "Percent") + "/" + \ QadMsg.translate("Command_LENGTHEN", "Total") + "/" + \ QadMsg.translate("Command_LENGTHEN", "DYnamic") if self.defaultValue is None: prompt = QadMsg.translate("Command_LENGTHEN", "Select an object or [{0}] <{1}>: ").format(keyWords, self.defaultValue) else: prompt = QadMsg.translate("Command_LENGTHEN", "Select an object or [{0}] <{1}>: ").format(keyWords, self.defaultValue) englishKeyWords = "DElta" + "/" + "Percent" + "/" + "Total" + "/" + "DYnamic" keyWords += "_" + englishKeyWords # si appresta ad attendere un punto o enter o una parola chiave # msg, inputType, default, keyWords, nessun controllo self.waitFor(prompt, \ QadInputTypeEnum.POINT2D | QadInputTypeEnum.KEYWORDS, \ self.defaultValue, \ keyWords, QadInputModeEnum.NONE)
def waitForPassagePt(self): # imposto il map tool self.getPointMapTool().setMode(Qad_offset_maptool_ModeEnum.ASK_FOR_PASSAGE_PT) if self.multi == False: keyWords = QadMsg.translate("Command_OFFSET", "Exit") + "/" + \ QadMsg.translate("Command_OFFSET", "Multiple") + "/" + \ QadMsg.translate("Command_OFFSET", "Undo") defaultMsg = QadMsg.translate("Command_OFFSET", "Exit") default = QadMsg.translate("Command_OFFSET", "Exit") englishKeyWords = "Exit" + "/" + "Multiple" + "/" + "Undo" else: keyWords = QadMsg.translate("Command_OFFSET", "Exit") + "/" + \ QadMsg.translate("Command_OFFSET", "Undo") defaultMsg = QadMsg.translate("Command_OFFSET", "next object") default = None englishKeyWords = "Exit" + "/" + "Undo" if self.OnlySegment == False: keyWords = keyWords + "/" + \ QadMsg.translate("Command_OFFSET", "Segment") englishKeyWords = englishKeyWords + "/" + "Segment" prompt = QadMsg.translate("Command_OFFSET", "Specify through point or [{0}] <{1}>: ") keyWords += "_" + englishKeyWords # si appresta ad attendere un punto o enter o una parola chiave # msg, inputType, default, keyWords, valore nullo non permesso self.waitFor(prompt.format(keyWords, defaultMsg), \ QadInputTypeEnum.POINT2D | QadInputTypeEnum.KEYWORDS, \ default, \ keyWords, QadInputModeEnum.NONE) self.step = 4
def run(self, msgMapTool = False, msg = None): if self.step == 0: # inizio del comando if self.firstTime == True: self.showMsg(QadMsg.translate("Command_SETCURRUPDATEABLELAYERBYGRAPH", "\nSelect objects whose layers will be the editable: ")) self.firstTime = False if self.SSGetClass.run(msgMapTool, msg) == True: # selezione terminata self.step = 1 return self.run(msgMapTool, msg) else: return False # continua elif self.step == 1: # dopo aver atteso la selezione di oggetti message = "" for layerEntitySet in self.SSGetClass.entitySet.layerEntitySetList: layer = layerEntitySet.layer if layer.isEditable() == False: if layer.startEditing() == True: self.plugIn.iface.legendInterface().refreshLayerSymbology(layer) self.showMsg(QadMsg.translate("Command_SETCURRUPDATEABLELAYERBYGRAPH", "\nThe layer {0} is editable.").format(layer.name())) if len(self.SSGetClass.entitySet.layerEntitySetList) == 1: layer = self.SSGetClass.entitySet.layerEntitySetList[0].layer if self.plugIn.canvas.currentLayer() is None or \ self.plugIn.canvas.currentLayer() != layer: self.plugIn.canvas.setCurrentLayer(layer) self.plugIn.iface.setActiveLayer(layer) # lancia evento di deactivate e activate dei plugin self.plugIn.iface.legendInterface().refreshLayerSymbology(layer) self.showMsg(QadMsg.translate("Command_SETCURRUPDATEABLELAYERBYGRAPH", "\nThe current layer is {0}.").format(layer.name())) return True
def showAllProps(self, dimStyle): if self.tableWidget.model() is not None: # Pulisce la tabella self.tableWidget.model().reset() self.tableWidget.setRowCount(0) self.tableWidget.setColumnCount(2) headerLabels = [] headerLabels.append(QadMsg.translate("DimStyle_Diff_Dialog", "Descrizione")) headerLabels.append(dimStyle.name) self.tableWidget.setHorizontalHeaderLabels(headerLabels) self.tableWidget.horizontalHeader().show() self.count = 0 propsDict = dimStyle.getPropList().items() for prop in propsDict: propName = prop[0] propDescr = prop[1][0] propValue = prop[1][1] self.insertProp(propDescr, propValue) self.tableWidget.sortItems(0) self.tableWidget.horizontalHeader().setResizeMode(0, QHeaderView.ResizeToContents) self.tableWidget.horizontalHeader().setResizeMode(1, QHeaderView.Interactive) self.msg.setText(QadMsg.translate("DimStyle_Diff_Dialog", "Tutte le proprietà dello stile di quota: ") + dimStyle.name)
def ButtonBOX_Accepted(self): newOSMODE = 0 if self.checkBox_CENP.checkState() == Qt.Checked: newOSMODE = newOSMODE | QadSnapTypeEnum.CEN if self.checkBox_ENDP.checkState() == Qt.Checked: newOSMODE = newOSMODE | QadSnapTypeEnum.END if self.checkBox_END_PLINE.checkState() == Qt.Checked: newOSMODE = newOSMODE | QadSnapTypeEnum.END_PLINE if self.checkBox_EXTP.checkState() == Qt.Checked: newOSMODE = newOSMODE | QadSnapTypeEnum.EXT if self.checkBox_INTP.checkState() == Qt.Checked: newOSMODE = newOSMODE | QadSnapTypeEnum.INT if self.checkBox_MIDP.checkState() == Qt.Checked: newOSMODE = newOSMODE | QadSnapTypeEnum.MID if self.checkBox_NODP.checkState() == Qt.Checked: newOSMODE = newOSMODE | QadSnapTypeEnum.NOD if self.checkBox_QUADP.checkState() == Qt.Checked: newOSMODE = newOSMODE | QadSnapTypeEnum.QUA #if self.checkBox_INSP.checkState() == Qt.Checked: # newOSMODE = newOSMODE | QadSnapTypeEnum.INS #if self.checkBox_INTAPP.checkState() == Qt.Checked: # newOSMODE = newOSMODE | QadSnapTypeEnum.APP if self.checkBox_NEARP.checkState() == Qt.Checked: newOSMODE = newOSMODE | QadSnapTypeEnum.NEA if self.checkBox_PARALP.checkState() == Qt.Checked: newOSMODE = newOSMODE | QadSnapTypeEnum.PAR if self.checkBox_PERP.checkState() == Qt.Checked: newOSMODE = newOSMODE | QadSnapTypeEnum.PER if self.checkBox_PROGRESP.checkState() == Qt.Checked: newOSMODE = newOSMODE | QadSnapTypeEnum.PR if self.checkBox_TANP.checkState() == Qt.Checked: newOSMODE = newOSMODE | QadSnapTypeEnum.TAN if self.checkBox_EXT_INT.checkState() == Qt.Checked: newOSMODE = newOSMODE | QadSnapTypeEnum.EXT_INT if self.checkBox_IsOsnapON.checkState() == Qt.Unchecked: newOSMODE = newOSMODE | QadSnapTypeEnum.DISABLE QadVariables.set(QadMsg.translate("Environment variables", "OSMODE"), newOSMODE) AutoSnap = QadVariables.get(QadMsg.translate("Environment variables", "AUTOSNAP")) if self.checkBox_PolarPickPoint.checkState() == Qt.Checked: AutoSnap = AutoSnap | 8 elif AutoSnap & 8: AutoSnap = AutoSnap - 8 QadVariables.set(QadMsg.translate("Environment variables", "AUTOSNAP"), AutoSnap) # Memorizzo il valore di PolarANG SUserAngle = self.comboBox_increment_angle.currentText() UserAngle = qad_utils.str2float(SUserAngle) QadVariables.set(QadMsg.translate("Environment variables", "POLARANG"), UserAngle) SProgrDist = self.lineEdit_ProgrDistance.text() ProgrDist = qad_utils.str2float(SProgrDist) QadVariables.set(QadMsg.translate("Environment variables", "OSPROGRDISTANCE"), ProgrDist) QadVariables.save() self.close() return True
def addEntitySetToPolyline(self, entitySet, removeOriginals = True): """ Aggiunge il set di entità alla polilinea da modificare """ geom = self.entity.getGeometry() layerList = [] layerList.append(self.entity.layer) for layerEntitySet in entitySet.layerEntitySetList: layer = layerEntitySet.layer if layer.geometryType() != QGis.Polygon and layer.geometryType() != QGis.Line: self.showMsg(QadMsg.translate("QAD", "Invalid object.")) return False if removeOriginals: layerList.append(layer) coordTransform = QgsCoordinateTransform(layer.crs(), self.entity.layer.crs()) for featureId in layerEntitySet.featureIds: # se la feature è quella di entity è errore if layer.id() == self.entity.layerId() and featureId == self.entity.featureId: self.showMsg(QadMsg.translate("QAD", "Invalid object.")) return False f = layerEntitySet.getFeature(featureId) # trasformo la geometria nel crs del layer dell'entità da modificare geomToAdd = f.geometry() geomToAdd.transform(coordTransform) # Riduco la geometria in point o polyline simplifiedGeoms = qad_utils.asPointOrPolyline(geomToAdd) for simplifiedGeom in simplifiedGeoms: points = simplifiedGeom.asPolyline() # vettore di punti # aggiungo una parte if geom.addPart(points) != 0: # 0 in case of success self.showMsg(QadMsg.translate("QAD", "Invalid object.")) return False f = self.entity.getFeature() f.setGeometry(geom) layerList = entitySet.getLayerList() layerList.append(self.entity.layer) self.plugIn.beginEditCommand("Feature edited", layerList) # plugIn, layer, feature, refresh, check_validity if qad_layer.updateFeatureToLayer(self.plugIn, self.entity.layer, f, False, False) == False: self.plugIn.destroyEditCommand() return False if removeOriginals: for layerEntitySet in entitySet.layerEntitySetList: if qad_layer.deleteFeaturesToLayer(self.plugIn, layerEntitySet.layer, layerEntitySet.featureIds, False) == False: self.plugIn.destroyEditCommand() return self.plugIn.endEditCommand() return True
def init_context_list(self): self.contextList = dict() # description, element dictionary contextDescr = QadMsg.translate("WindowColor_Dialog", "Model Space") # x lupdate self.contextList[QadColorContextEnum.MODEL_SPACE_2D] = [contextDescr, self.get_MODEL_SPACE_2D_element_dict()] contextDescr = QadMsg.translate("WindowColor_Dialog", "Command line") # x lupdate self.contextList[QadColorContextEnum.COMMAND_LINE] = [contextDescr, self.get_COMMAND_LINE_element_dict()]
def retranslateUi(self, DimStyle_Dialog): qad_dimstyle_ui.Ui_DimStyle_Dialog.retranslateUi(self, self) # "none" viene tradotto in italiano in "nessuno" nel contesto "currentDimStyle" # "none" viene tradotto in italiano in "nessuna" nel contesto "descriptionSelectedStyle" # "none" viene tradotto in italiano in "nessuno" nel contesto "selectedStyle" self.currentDimStyle.setText(QadMsg.translate("DimStyle_Dialog", "none", "currentDimStyle")) self.descriptionSelectedStyle.setText(QadMsg.translate("DimStyle_Dialog", "none", "descriptionSelectedStyle")) self.selectedStyle.setText(QadMsg.translate("DimStyle_Dialog", "none", "selectedStyle"))
def renSelectedDimStyle(self, newName): if self.selectedDimStyle is None: return if QadDimStyles.renameDimStyle(self.selectedDimStyle.name, newName) == False: QMessageBox.critical(self, QadMsg.translate("QAD", "QAD"), \ QadMsg.translate("DimStyle_Dialog", "Dimension style not renamed.")) else: self.init()
def __init__(self, mapCanvas): QgsMapCanvasItem.__init__(self, mapCanvas) self.canvas = mapCanvas self.iconType = QadGripIconTypeEnum.BOX # icon to be shown self.iconSize = QadVariables.get(QadMsg.translate("Environment variables", "GRIPSIZE")) self.borderColor = QadVariables.get(QadMsg.translate("Environment variables", "GRIPCONTOUR")) # color of the border self.center = QgsPoint(0, 0) # coordinates of the point in the center self.setGrip(QadGripStatusEnum.UNSELECTED, QadGripIconTypeEnum.BOX)
def renSelectedDimStyle(self, newName): if self.selectedDimStyle is None: return if self.plugIn.dimStyles.renameDimStyle(self.selectedDimStyle.name, newName) == False: QMessageBox.critical(self, QadMsg.translate("QAD", "QAD"), \ QadMsg.translate("DimStyle_Dialog", "Lo stile di quotatura non è stato rinominato.")) else: self.init()
def refreshPreviewColor(self): pickBoxColor = QColor(self.tempQadVariables.get(QadMsg.translate("Environment variables", "PICKBOXCOLOR"))) self.previewPickBox.color = pickBoxColor autoSnapColor = QColor(self.tempQadVariables.get(QadMsg.translate("Environment variables", "AUTOSNAPCOLOR"))) self.previewAutoSnapMarker.color = autoSnapColor apertureColor = QColor(self.tempQadVariables.get(QadMsg.translate("Environment variables", "PICKBOXCOLOR"))) cursorColor = QColor(self.tempQadVariables.get(QadMsg.translate("Environment variables", "CURSORCOLOR"))) self.previewAperture.color = apertureColor self.previewAperture.cursorColor = cursorColor
def init_polar_tab(self): # Inizializzazione del TAB che riguarda il puntamento polare UserAngle = QadVariables.get(QadMsg.translate("Environment variables", "POLARANG")) angoliDef = ["90", "45", "30", "22.5", "18", "15", "10", "5"] self.comboBox_increment_angle.addItems(angoliDef) stringA = str(UserAngle) self.comboBox_increment_angle.lineEdit().setText(stringA) self.comboBox_increment_angle.installEventFilter(self) AutoSnap = QadVariables.get(QadMsg.translate("Environment variables", "AUTOSNAP")) self.checkBox_PolarPickPoint.setChecked(AutoSnap & 8)
def run(self, msgMapTool=False, msg=None): if self.plugIn.canvas.mapRenderer().destinationCrs().geographicFlag(): self.showMsg( QadMsg.translate( "QAD", "\nThe coordinate reference system of the project must be a projected coordinate system.\n" ) ) return True # fine comando if self.virtualCmd == False: # se si vuole veramente salvare la polylinea in un layer currLayer, errMsg = qad_layer.getCurrLayerEditable(self.plugIn.canvas, QGis.Polygon) if currLayer is None: self.showErr(errMsg) return True # fine comando # ========================================================================= # RICHIESTA PRIMO PUNTO PER SELEZIONE OGGETTI if self.step == 0: self.PLINECommand = QadPLINECommandClass(self.plugIn, True) # se questo flag = True il comando serve all'interno di un altro comando per disegnare una linea # che non verrà salvata su un layer self.PLINECommand.virtualCmd = True self.PLINECommand.asToolForMPolygon = True # per rubberband tipo poligono self.PLINECommand.run(msgMapTool, msg) self.step = 1 return False # continua # ========================================================================= # RISPOSTA ALLA RICHIESTA PUNTO (da step = 0 o 1) elif self.step == 1: # dopo aver atteso un punto si riavvia il comando if self.PLINECommand.run(msgMapTool, msg) == True: verticesLen = len(self.PLINECommand.vertices) if verticesLen > 3: self.vertices = self.PLINECommand.vertices[:] # copio la lista firstVertex = self.vertices[0] # se l'ultimo vertice non é uguale al primo if self.vertices[verticesLen - 1] != firstVertex: # aggiungo un vertice con le stesse coordinate del primo self.vertices.append(firstVertex) if self.virtualCmd == False: # se si vuole veramente salvare la polylinea in un layer if qad_layer.addPolygonToLayer(self.plugIn, currLayer, self.vertices) == False: self.showMsg(QadMsg.translate("Command_MPOLYGON", "\nPolygon not valid.\n")) del self.vertices[:] # svuoto la lista else: self.showMsg(QadMsg.translate("Command_MPOLYGON", "\nPolygon not valid.\n")) del self.PLINECommand self.PLINECommand = None return True # fine return False
def initActions(self, inputType, keyWords): self.delActions() # inizializzo la lista di parole chiave contestuale al comando corrente (lingua locale) # carattere separatore tra le parole chiave in lingua locale e quelle in inglese localEnglishKeyWords = keyWords.split("_") localKeyWords = localEnglishKeyWords[0].split("/") # carattere separatore delle parole chiave msg = QadMsg.translate("ContextualCmdMenu", "Enter") action = QAction(msg, self) self.addAction(action) self.connections.append([action, self.enterActionByContextualMenu]) msg = QadMsg.translate("ContextualCmdMenu", "Cancel") action = QAction(msg, self) self.addAction(action) self.connections.append([action, self.cancelActionByContextualMenu]) if inputType & QadInputTypeEnum.POINT2D or inputType & QadInputTypeEnum.POINT3D: msg = QadMsg.translate("ContextualCmdMenu", "Recent Input") recentPtsMenu = self.addMenu(msg) ptsHistory = self.plugIn.ptsHistory ptsHistoryLen = len(ptsHistory) i = ptsHistoryLen - 1 cmdInputHistoryMax = QadVariables.get(QadMsg.translate("Environment variables", "CMDINPUTHISTORYMAX")) # ciclo sulla storia degli ultimi punti usati while i >= 0 and (ptsHistoryLen - i) <= cmdInputHistoryMax: strPt = qad_utils.QgsPointToString(ptsHistory[i]) i = i - 1 action = QAction(strPt, recentPtsMenu) recentPtsMenu.addAction(action) self.connections.append([action, self.showEvaluateMsgByContextualMenu]) self.addSeparator() # ciclo sulle opzioni correnti del comando in uso for keyWord in localKeyWords: action = QAction(keyWord, self) self.addAction(action) self.connections.append([action, self.showEvaluateMsgByContextualMenu]) if inputType & QadInputTypeEnum.POINT2D or inputType & QadInputTypeEnum.POINT3D: self.addSeparator() osnapMenu = QadOsnapContextualMenuClass(self.plugIn) self.addMenu(osnapMenu) # creo tutte le connessioni per gli eventi for connection in self.connections: action = connection[0] slot = connection[1] QObject.connect(action, SIGNAL("triggered()"), slot)
def displayPopupMenuOnQuiescentState(self, pos): popupMenu = QMenu(self.canvas) history = self.plugIn.getHistoryfromTxtWindow() isLastCmdToInsert = True isRecentMenuToInsert = True historyLen = len(history) i = historyLen - 1 cmdInputHistoryMax = QadVariables.get(QadMsg.translate("Environment variables", "CMDINPUTHISTORYMAX")) while i >= 0 and (historyLen - i) <= cmdInputHistoryMax: cmdName = history[i] i = i - 1 cmd = self.plugIn.QadCommands.getCommandObj(cmdName) if cmd is not None: if isLastCmdToInsert: isLastCmdToInsert = False msg = QadMsg.translate("Popup_menu_graph_window", "Repeat ") + cmd.getName() icon = cmd.getIcon() if icon is None: lastCmdAction = QAction(msg, popupMenu) else: lastCmdAction = QAction(icon, msg, popupMenu) cmd.connectQAction(lastCmdAction) popupMenu.addAction(lastCmdAction) else: if isRecentMenuToInsert: isRecentMenuToInsert = False recentCmdsMenu = popupMenu.addMenu(QadMsg.translate("Popup_menu_graph_window", "Recent commands")) icon = cmd.getIcon() if icon is None: recentCmdAction = QAction(cmd.getName(), recentCmdsMenu) else: recentCmdAction = QAction(icon, cmd.getName(), recentCmdsMenu) cmd.connectQAction(recentCmdAction) recentCmdsMenu.addAction(recentCmdAction) if isLastCmdToInsert == False: # menu non vuoto popupMenu.addSeparator() # aggiungo comando "OPTIONS" cmd = self.plugIn.QadCommands.getCommandObj(QadMsg.translate("Command_list", "OPTIONS")) icon = cmd.getIcon() if icon is None: optionsCmdAction = QAction(cmd.getName(), popupMenu) else: optionsCmdAction = QAction(icon, cmd.getName(), popupMenu) cmd.connectQAction(optionsCmdAction) popupMenu.addAction(optionsCmdAction) popupMenu.popup(self.canvas.mapToGlobal(pos))
def init_primaryUnits_tab(self): self.onInit = True # textDecimals self.textDecimals.addItem( QadMsg.translate("DimStyle_Details_Dialog", "0")) self.textDecimals.addItem( QadMsg.translate("DimStyle_Details_Dialog", "0.0")) self.textDecimals.addItem( QadMsg.translate("DimStyle_Details_Dialog", "0.00")) self.textDecimals.addItem( QadMsg.translate("DimStyle_Details_Dialog", "0.000")) self.textDecimals.addItem( QadMsg.translate("DimStyle_Details_Dialog", "0.0000")) self.textDecimals.addItem( QadMsg.translate("DimStyle_Details_Dialog", "0.00000")) self.textDecimals.addItem( QadMsg.translate("DimStyle_Details_Dialog", "0.000000")) self.textDecimals.addItem( QadMsg.translate("DimStyle_Details_Dialog", "0.0000000")) self.textDecimals.addItem( QadMsg.translate("DimStyle_Details_Dialog", "0.00000000")) self.textDecimals.setCurrentIndex(self.dimStyle.textDecimals) # textDecimalSep self.textDecimalSep.addItem( QadMsg.translate("DimStyle_Details_Dialog", "'.' Period")) self.textDecimalSep.addItem( QadMsg.translate("DimStyle_Details_Dialog", "',' Comma")) self.textDecimalSep.addItem( QadMsg.translate("DimStyle_Details_Dialog", "' ' Space")) if self.dimStyle.textDecimalSep == ".": # punto self.textDecimalSep.setCurrentIndex(0) elif self.dimStyle.textDecimalSep == ",": # virgola self.textDecimalSep.setCurrentIndex(1) elif self.dimStyle.textDecimalSep == " ": # spazio self.textDecimalSep.setCurrentIndex(2) self.textPrefix.setText(self.dimStyle.textPrefix) self.textSuffix.setText(self.dimStyle.textSuffix) self.textSuppressLeadingZeros.setChecked( self.dimStyle.textSuppressLeadingZeros) self.textDecimalZerosSuppression.setChecked( self.dimStyle.textDecimalZerosSuppression) self.onInit = False
def getNote(self): # impostare le note esplicative del comando return QadMsg.translate( "Command_DIMSTYLE", "Creates new styles, sets the current style, modifies styles, sets overrides on the current style, and compares styles." )
def getName(self): return QadMsg.translate("Command_list", "MIRROR")
def getNote(self): # impostare le note esplicative del comando return QadMsg.translate("Command_SETVAR", "Sets the QAD environment variables.")
def getNote(self): # impostare le note esplicative del comando return QadMsg.translate( "Command_SETCURRUPDATEABLELAYERBYGRAPH", "Sets the layers of a graphical objects as editable.")
def getName(self): return QadMsg.translate("Command_list", "SETCURRLAYERBYGRAPH")
def getNote(self): # impostare le note esplicative del comando return QadMsg.translate("Command_INSERT", "Insert a symbol.")
def run(self, msgMapTool=False, msg=None): if self.plugIn.canvas.mapSettings().destinationCrs().geographicFlag(): self.showMsg( QadMsg.translate( "QAD", "\nThe coordinate reference system of the project must be a projected coordinate system.\n" )) return True # fine comando currLayer, errMsg = qad_layer.getCurrLayerEditable( self.plugIn.canvas, QGis.Point) if currLayer is None: self.showErr(errMsg) return True # fine comando if qad_layer.isSymbolLayer(currLayer) == False: errMsg = QadMsg.translate( "QAD", "\nCurrent layer is not a symbol layer.") errMsg = errMsg + QadMsg.translate( "QAD", "\nA symbol layer is a vector punctual layer without label.\n") self.showErr(errMsg) return True # fine comando if len(QadDimStyles.getDimListByLayer(currLayer)) > 0: errMsg = QadMsg.translate( "QAD", "\nThe current layer belongs to a dimension style.\n") self.showErr(errMsg) return True # fine comando if self.step == 0: self.waitForEntsel(msgMapTool, msg) return False # continua #========================================================================= # RISPOSTA ALLA SELEZIONE DI UN'ENTITA' (da step = 0) elif self.step == QadMEASURECommandClassStepEnum.ASK_FOR_ENT: if self.entSelClass.run(msgMapTool, msg) == True: if self.entSelClass.entity.isInitialized(): # se il layer di destinazione è di tipo simbolo if qad_layer.isSymbolLayer(currLayer) == True: # se il simbolo può essere ruotato if len(qad_layer.get_symbolRotationFieldName( currLayer)) > 0: self.waitForAlignmentObjs() else: self.waitForSegmentLength() return False else: if self.entSelClass.canceledByUsr == True: # fine comando return True self.showMsg( QadMsg.translate("QAD", "No geometries in this position.")) self.waitForEntsel(msgMapTool, msg) return False # continua #========================================================================= # RISPOSTA ALLA RICHIESTA DI ALLINEARE GLI OGGETTI (da step = ASK_FOR_ENT) elif self.step == QadMEASURECommandClassStepEnum.ASK_FOR_ALIGNMENT: # dopo aver atteso una parola chiave si riavvia il comando if msgMapTool == True: # il punto arriva da una selezione grafica if self.getPointMapTool( ).rightButton == True: # se usato il tasto destro del mouse value = self.defaultValue else: self.setMapTool( self.getPointMapTool()) # riattivo il maptool return False else: # la parola chiave arriva come parametro della funzione value = msg if type(value) == unicode: if value == QadMsg.translate("QAD", "Yes") or value == "Yes": self.objectAlignment = True else: self.objectAlignment = False self.waitForSegmentLength() return False #========================================================================= # RISPOSTA ALLA RICHIESTA DELLA LUNGHEZZA DEL SEGMENTO (da step = ASK_FOR_ALIGNMENT) #========================================================================= elif self.step == QadMEASURECommandClassStepEnum.ASK_SEGMENT_LENGTH: # dopo aver atteso un numero reale si riavvia il comando if self.GetDistClass.run(msgMapTool, msg) == True: self.getPointMapTool().refreshSnapType( ) # aggiorno lo snapType che può essere variato da altri maptool if self.GetDistClass.dist is not None: self.segmentLength = self.GetDistClass.dist self.doMeasure(currLayer) del self.GetDistClass return True # fine comando else: return False
def getName(self): return QadMsg.translate("Command_list", "MEASURE")
def getNote(self): # impostare le note esplicative del comando return QadMsg.translate( "Command_MEASURE", "Creates punctual objects at measured intervals along the length or perimeter of an object." )
def getName(self): return QadMsg.translate("Command_list", "OPTIONS")
def run(self, msgMapTool = False, msg = None): if self.plugIn.canvas.mapSettings().destinationCrs().geographicFlag(): self.showMsg(QadMsg.translate("QAD", "\nThe coordinate reference system of the project must be a projected coordinate system.\n")) return True # fine comando #========================================================================= # RICHIESTA SELEZIONE OGGETTI if self.step == 0: # inizio del comando if self.SSGetClass.run(msgMapTool, msg) == True: # selezione terminata self.step = 1 self.getPointMapTool().refreshSnapType() # aggiorno lo snapType che può essere variato dal maptool di selezione entità return self.run(msgMapTool, msg) #========================================================================= # SPECCHIA OGGETTI elif self.step == 1: self.entitySet.set(self.SSGetClass.entitySet) if self.entitySet.count() == 0: return True # fine comando # imposto il map tool self.getPointMapTool().entitySet.set(self.entitySet) self.getPointMapTool().setMode(Qad_mirror_maptool_ModeEnum.NONE_KNOWN_ASK_FOR_FIRST_PT) # si appresta ad attendere un punto self.waitForPoint(QadMsg.translate("Command_MIRROR", "Specify first point of mirror line: ")) self.step = 2 return False #========================================================================= # RISPOSTA ALLA RICHIESTA PUNTO BASE (da step = 1) elif self.step == 2: # dopo aver atteso un punto o un numero reale si riavvia il comando if msgMapTool == True: # il punto arriva da una selezione grafica # la condizione seguente si verifica se durante la selezione di un punto # é stato attivato un altro plugin che ha disattivato Qad # quindi stato riattivato il comando che torna qui senza che il maptool # abbia selezionato un punto if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse # si appresta ad attendere un punto self.waitForPoint(QadMsg.translate("Command_MIRROR", "Specify first point of mirror line: ")) return False else: self.setMapTool(self.getPointMapTool()) # riattivo il maptool return False value = self.getPointMapTool().point else: # il punto arriva come parametro della funzione value = msg self.firstMirrorPt.set(value.x(), value.y()) # imposto il map tool self.getPointMapTool().firstMirrorPt = self.firstMirrorPt self.getPointMapTool().setMode(Qad_mirror_maptool_ModeEnum.FIRST_PT_KNOWN_ASK_FOR_SECOND_PT) # si appresta ad attendere un punto self.waitForPoint(QadMsg.translate("Command_MIRROR", "Specify second point of mirror line: ")) self.step = 3 return False #========================================================================= # RISPOSTA ALLA RICHIESTA SECONDO PUNTO PER SPECCHIO (da step = 2) elif self.step == 3: # dopo aver atteso un punto si riavvia il comando if msgMapTool == True: # il punto arriva da una selezione grafica # la condizione seguente si verifica se durante la selezione di un punto # é stato attivato un altro plugin che ha disattivato Qad # quindi stato riattivato il comando che torna qui senza che il maptool # abbia selezionato un punto if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse # si appresta ad attendere un punto self.waitForPoint(QadMsg.translate("Command_MIRROR", "Specify second point of mirror line: ")) else: self.setMapTool(self.getPointMapTool()) # riattivo il maptool return False value = self.getPointMapTool().point else: # il punto arriva come parametro della funzione value = msg if qad_utils.ptNear(self.firstMirrorPt, value): self.showMsg(QadMsg.translate("Command_MIRROR", "\nThe points must be different.")) # si appresta ad attendere un punto self.waitForPoint(QadMsg.translate("Command_MIRROR", "Specify second point of mirror line: ")) return False self.secondMirrorPt.set(value.x(), value.y()) keyWords = QadMsg.translate("QAD", "Yes") + "/" + \ QadMsg.translate("QAD", "No") if self.copyFeatures == False: default = QadMsg.translate("QAD", "Yes") else: default = QadMsg.translate("QAD", "No") prompt = QadMsg.translate("Command_MIRROR", "Erase source objects ? [{0}] <{1}>: ").format(keyWords, default) englishKeyWords = "Yes" + "/" + "No" keyWords += "_" + englishKeyWords # si appresta ad attendere enter o una parola chiave # msg, inputType, default, keyWords, nessun controllo self.waitFor(prompt, \ QadInputTypeEnum.KEYWORDS, \ default, \ keyWords, QadInputModeEnum.NONE) self.getPointMapTool().setMode(Qad_mirror_maptool_ModeEnum.NONE_KNOWN_ASK_FOR_FIRST_PT) self.step = 4 return False #========================================================================= # RISPOSTA ALLA RICHIESTA DI CANCELLAZIONE OGGETTO SORGENTE (da step = 3) elif self.step == 4: # dopo aver atteso un punto o un numero reale si riavvia il comando if msgMapTool == True: # il punto arriva da una selezione grafica # la condizione seguente si verifica se durante la selezione di un punto # é stato attivato un altro plugin che ha disattivato Qad # quindi stato riattivato il comando che torna qui senza che il maptool # abbia selezionato un punto if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse value = QadMsg.translate("QAD", "No") else: self.setMapTool(self.getPointMapTool()) # riattivo il maptool return False else: # il valore arriva come parametro della funzione value = msg if type(value) == unicode: if value == QadMsg.translate("QAD", "Yes") or value == "Yes": self.copyFeatures = False elif value == QadMsg.translate("QAD", "No") or value == "No": self.copyFeatures = True self.mirrorGeoms() return True # fine comando return False
def init_text_tab(self): self.onInit = True index = self.textFont.findText(self.dimStyle.textFont) self.textFont.setCurrentIndex(index) self.textColor.setColor(QColor(self.dimStyle.textColor)) self.textHeight.setValue(self.dimStyle.textHeight) # textVerticalPos self.textVerticalPos.addItem( QadMsg.translate("DimStyle_Details_Dialog", "Centered")) self.textVerticalPos.addItem( QadMsg.translate("DimStyle_Details_Dialog", "Above")) self.textVerticalPos.addItem( QadMsg.translate("DimStyle_Details_Dialog", "Outside")) self.textVerticalPos.addItem( QadMsg.translate("DimStyle_Details_Dialog", "Below")) if self.dimStyle.textVerticalPos == QadDimStyleTxtVerticalPosEnum.CENTERED_LINE: self.textVerticalPos.setCurrentIndex(0) elif self.dimStyle.textVerticalPos == QadDimStyleTxtVerticalPosEnum.ABOVE_LINE: self.textVerticalPos.setCurrentIndex(1) elif self.dimStyle.textVerticalPos == QadDimStyleTxtVerticalPosEnum.EXTERN_LINE: self.textVerticalPos.setCurrentIndex(2) elif self.dimStyle.textVerticalPos == QadDimStyleTxtVerticalPosEnum.BELOW_LINE: self.textVerticalPos.setCurrentIndex(3) # textHorizontalPos self.textHorizontalPos.addItem( QadMsg.translate("DimStyle_Details_Dialog", "Centered")) self.textHorizontalPos.addItem( QadMsg.translate("DimStyle_Details_Dialog", "At Ext Line 1")) self.textHorizontalPos.addItem( QadMsg.translate("DimStyle_Details_Dialog", "At Ext Line 2")) self.textHorizontalPos.addItem( QadMsg.translate("DimStyle_Details_Dialog", "Over Ext Line 1")) self.textHorizontalPos.addItem( QadMsg.translate("DimStyle_Details_Dialog", "Over Ext Line 2")) if self.dimStyle.textHorizontalPos == QadDimStyleTxtHorizontalPosEnum.CENTERED_LINE: self.textHorizontalPos.setCurrentIndex(0) elif self.dimStyle.textHorizontalPos == QadDimStyleTxtHorizontalPosEnum.FIRST_EXT_LINE: self.textHorizontalPos.setCurrentIndex(1) elif self.dimStyle.textHorizontalPos == QadDimStyleTxtHorizontalPosEnum.SECOND_EXT_LINE: self.textHorizontalPos.setCurrentIndex(2) elif self.dimStyle.textHorizontalPos == QadDimStyleTxtHorizontalPosEnum.FIRST_EXT_LINE_UP: self.textHorizontalPos.setCurrentIndex(3) elif self.dimStyle.textHorizontalPos == QadDimStyleTxtHorizontalPosEnum.SECOND_EXT_LINE_UP: self.textHorizontalPos.setCurrentIndex(4) # textDirection self.textDirection.addItem( QadMsg.translate("DimStyle_Details_Dialog", "Left-to-Right")) self.textDirection.addItem( QadMsg.translate("DimStyle_Details_Dialog", "Right-to-Left")) if self.dimStyle.textDirection == QadDimStyleTxtDirectionEnum.SX_TO_DX: self.textDirection.setCurrentIndex(0) elif self.dimStyle.textDirection == QadDimStyleTxtDirectionEnum.DX_TO_SX: self.textDirection.setCurrentIndex(1) self.textOffsetDist.setValue(self.dimStyle.textOffsetDist) # textForcedRot if self.dimStyle.textRotMode == QadDimStyleTxtRotModeEnum.HORIZONTAL: self.textRotModeHorizontal.setChecked(True) elif self.dimStyle.textRotMode == QadDimStyleTxtRotModeEnum.ALIGNED_LINE: self.textRotModeAligned.setChecked(True) elif self.dimStyle.textRotMode == QadDimStyleTxtRotModeEnum.ISO: self.textRotModeISO.setChecked(True) elif self.dimStyle.textRotMode == QadDimStyleTxtRotModeEnum.FORCED_ROTATION: self.textRotModeFixedRot.setChecked(True) self.textForcedRot.setValue( qad_utils.toDegrees(self.dimStyle.textForcedRot)) self.textRotModeFixedRotToggled(self.textRotModeFixedRot.isChecked()) self.onInit = False
def waitForBasePt(self): self.step = 2 # imposto il map tool self.getPointMapTool().setMode(Qad_mirror_maptool_ModeEnum.NONE_KNOWN_ASK_FOR_FIRST_PT) # si appresta ad attendere un punto self.waitForPoint(QadMsg.translate("Command_GRIPROTATE", "Specify base point: "))
def getNote(self): # impostare le note esplicative del comando return QadMsg.translate( "Command_SETCURRLAYERBYGRAPH", "Sets a layer of a graphical object as current.")
def getName(self): return QadMsg.translate("Command_list", "SETVAR")
def run(self, msgMapTool=False, msg=None): if self.step == 0: # inizio del comando # si appresta ad attendere una stringa self.waitForString(QadMsg.translate("Command_SETVAR", "Enter the variable name or [?]: "), \ QadMsg.translate("Command_SETVAR", "?")) self.step = 1 return False elif self.step == 1: # dopo aver atteso il nome della variabile si riavvia il comando if msgMapTool == True: # niente può arrivare da grafica return False # il nome della variabile arriva come parametro della funzione self.varName = msg if self.varName == QadMsg.translate("Command_SETVAR", "?"): # lista delle variabili # si appresta ad attendere una stringa self.waitForString(QadMsg.translate("Command_SETVAR", "Enter variable(s) to list <*>: "), \ QadMsg.translate("Command_SETVAR", "*")) self.step = 3 return False else: variable = QadVariables.getVariable(self.varName) if variable is None: msg = QadMsg.translate( "Command_SETVAR", "\nUnknown variable. Enter {0} ? to list variable names." ) self.showErr( msg.format(QadMsg.translate("Command_list", "SETVAR"))) return False else: varValue = variable.value varDescr = variable.descr varType = str(type(varValue)) if len(varDescr) > 0: self.showMsg("\n" + varDescr) msg = QadMsg.translate( "Command_SETVAR", "Enter new value for variable {0} <{1}>: ") if varType == "<type 'str'>": # si appresta ad attendere una stringa self.waitForString(msg.format(self.varName, varValue), varValue) elif varType == "<type 'int'>": # si appresta ad attendere un numero intero self.waitForInt(msg.format(self.varName, varValue), varValue) elif varType == "<type 'float'>": # si appresta ad attendere un numero reale self.waitForFloat(msg.format(self.varName, varValue), varValue) elif varType == "<type 'bool'>": # si appresta ad attendere un numero reale self.waitForBool(msg.format(self.varName, varValue), varValue) self.step = 2 return False elif self.step == 2: # dopo aver atteso il valore della variabile si riavvia il comando if msgMapTool == True: # niente può arrivare da grafica return False # il valore della variabile arriva come parametro della funzione QadVariables.set(self.varName, msg) QadVariables.save() self.plugIn.UpdatedVariablesEvent() return True elif self.step == 3: # dopo aver atteso il nome della variabile si riavvia il comando if msgMapTool == True: # niente può arrivare da grafica return False if msg == "*": varNames = QadVariables.getVarNames() else: # il nome della variabile arriva come parametro della funzione varNames = msg.strip().split(",") varNames.sort() for self.varName in varNames: self.varName = self.varName.strip() varValue = QadVariables.get(self.varName) if varValue is not None: msg = "\n" + self.varName + "=" + str(varValue) self.showMsg(msg) self.plugIn.UpdatedVariablesEvent() return True
def ButtonHELP_Pressed(self): qadShowPluginHelp(QadMsg.translate("Help", "Dimensioning"))
def fromPolyline(self, points, startVertex, atLeastNSegment = None): """ setta le caratteristiche del primo arco incontrato nella lista di punti partendo dalla posizione startVertex (0-indexed) ritorna la posizione nella lista del punto iniziale e finale se é stato trovato un arco altrimenti None N.B. in punti NON devono essere in coordinate geografiche """ if atLeastNSegment is None: _atLeastNSegment = QadVariables.get(QadMsg.translate("Environment variables", "ARCMINSEGMENTQTY"), 12) else: _atLeastNSegment = atLeastNSegment totPoints = len(points) # perché sia un arco ci vogliono almeno _atLeastNSegment segmenti if (totPoints - 1) - startVertex < _atLeastNSegment or _atLeastNSegment < 2: return None # per problemi di approssimazione dei calcoli epsilon = 1.e-4 # percentuale del raggio per ottenere max diff. di una distanza con il raggio InfinityLinePerpOnMiddle1 = None InfinityLinePerpOnMiddle2 = None nSegment = 0 i = startVertex while i < totPoints - 1: if InfinityLinePerpOnMiddle1 is None: InfinityLinePerpOnMiddle1 = qad_utils.getInfinityLinePerpOnMiddle(points[i], points[i + 1]) nStartVertex = i nSegment = 1 i = i + 1 continue elif InfinityLinePerpOnMiddle2 is None: InfinityLinePerpOnMiddle2 = qad_utils.getInfinityLinePerpOnMiddle(points[i], points[i + 1]) if InfinityLinePerpOnMiddle2 is None: InfinityLinePerpOnMiddle1 = None nSegment = 0 else: # calcolo il presunto centro con 2 segmenti center = qad_utils.getIntersectionPointOn2InfinityLines(InfinityLinePerpOnMiddle1[0], \ InfinityLinePerpOnMiddle1[1], \ InfinityLinePerpOnMiddle2[0], \ InfinityLinePerpOnMiddle2[1]) if center is None: # linee parallele InfinityLinePerpOnMiddle1 = InfinityLinePerpOnMiddle2 InfinityLinePerpOnMiddle2 = None nStartVertex = i nSegment = 1 else: nSegment = nSegment + 1 radius = qad_utils.getDistance(center, points[i + 1]) # calcolo il presunto raggio tolerance = radius * epsilon # calcolo il verso dell'arco e l'angolo dell'arco # se un punto intermedio dell'arco è a sinistra del # segmento che unisce i due punti allora il verso è antiorario startClockWise = True if qad_utils.leftOfLine(points[i], points[i - 1], points[i + 1]) < 0 else False angle = qad_utils.getAngleBy3Pts(points[i - 1], center, points[i + 1], startClockWise) prevInfinityLinePerpOnMiddle = InfinityLinePerpOnMiddle2 else: # e sono già stati valutati almeno 2 segmenti notInArc = False currInfinityLinePerpOnMiddle = qad_utils.getInfinityLinePerpOnMiddle(points[i], points[i + 1]) if currInfinityLinePerpOnMiddle is None: notInArc = True else: # calcolo il presunto centro con 2 segmenti currCenter = qad_utils.getIntersectionPointOn2InfinityLines(prevInfinityLinePerpOnMiddle[0], \ prevInfinityLinePerpOnMiddle[1], \ currInfinityLinePerpOnMiddle[0], \ currInfinityLinePerpOnMiddle[1]) if currCenter is None: # linee parallele notInArc = True else: # calcolo il verso dell'arco e l'angolo clockWise = True if qad_utils.leftOfLine(points[i], points[i - 1], points[i + 1]) < 0 else False angle = angle + qad_utils.getAngleBy3Pts(points[i], center, points[i + 1], startClockWise) # se la distanza è così vicina a quella del raggio # il verso dell'arco deve essere quello iniziale # l'angolo dell'arco non può essere >= 360 gradi if qad_utils.ptNear(center, currCenter, tolerance) and \ startClockWise == clockWise and \ angle < 2 * math.pi: nSegment = nSegment + 1 # anche questo segmento fa parte dell'arco prevInfinityLinePerpOnMiddle = currInfinityLinePerpOnMiddle else: notInArc = True # questo segmento non fa parte del cerchio if notInArc: # se sono stati trovati un numero sufficiente di segmenti successivi if nSegment >= _atLeastNSegment: # se é un angolo giro e il primo punto = ultimo punto allora points é un cerchio if qad_utils.doubleNear(angle, 2 * math.pi) and points[0] == points[-1]: return None break else: i = i - 2 InfinityLinePerpOnMiddle1 = None InfinityLinePerpOnMiddle2 = None i = i + 1 # se sono stati trovati un numero sufficiente di segmenti successivi if nSegment >= _atLeastNSegment: nEndVertex = nStartVertex + nSegment # se il punto iniziale e quello finale non coincidono é un arco if points[nStartVertex] != points[nEndVertex]: self.center = center self.radius = radius # se il verso é orario if startClockWise: # inverto l'angolo iniziale con quello finale self.endAngle = qad_utils.getAngleBy2Pts(center, points[nStartVertex]) self.startAngle = qad_utils.getAngleBy2Pts(center, points[nEndVertex]) else: self.startAngle = qad_utils.getAngleBy2Pts(center, points[nStartVertex]) self.endAngle = qad_utils.getAngleBy2Pts(center, points[nEndVertex]) return nStartVertex, nEndVertex return None
def getName(self): return QadMsg.translate("Command_list", "INSERT")
def getNote(self): # impostare le note esplicative del comando return QadMsg.translate("Command_MIRROR", "Creates a mirrored copy of selected objects.")
def run(self, msgMapTool=False, msg=None): if self.plugIn.canvas.mapSettings().destinationCrs().geographicFlag(): self.showMsg( QadMsg.translate( "QAD", "\nThe coordinate reference system of the project must be a projected coordinate system.\n" )) return True # fine comando currLayer, errMsg = qad_layer.getCurrLayerEditable( self.plugIn.canvas, QGis.Point) if currLayer is None: self.showErr(errMsg) return True # fine comando if qad_layer.isSymbolLayer(currLayer) == False: errMsg = QadMsg.translate( "QAD", "\nCurrent layer is not a symbol layer.") errMsg = errMsg + QadMsg.translate( "QAD", "\nA symbol layer is a vector punctual layer without label.\n") self.showErr(errMsg) return True # fine comando #========================================================================= # RICHIESTA PUNTO DI INSERIMENTO if self.step == 0: # inizio del comando self.waitForPoint() # si appresta ad attendere un punto self.step = self.step + 1 return False #========================================================================= # RISPOSTA ALLA RICHIESTA PUNTO DI INSERIMENTO elif self.step == 1: # dopo aver atteso un punto si riavvia il comando if msgMapTool == True: # il punto arriva da una selezione grafica # la condizione seguente si verifica se durante la selezione di un punto # é stato attivato un altro plugin che ha disattivato Qad # quindi stato riattivato il comando che torna qui senza che il maptool # abbia selezionato un punto if self.getPointMapTool( ).point is None: # il maptool é stato attivato senza un punto if self.getPointMapTool( ).rightButton == True: # se usato il tasto destro del mouse return True # fine comando else: self.setMapTool( self.getPointMapTool()) # riattivo il maptool return False pt = self.getPointMapTool().point else: # il punto arriva come parametro della funzione pt = msg self.insPt = QgsPoint(pt) self.plugIn.setLastPoint(self.insPt) # se la scala dipende da un campo scaleFldName = qad_layer.get_symbolScaleFieldName(currLayer) if len(scaleFldName) > 0: # si appresta ad attendere la scala self.GetDistClass = QadGetDistClass(self.plugIn) prompt = QadMsg.translate("Command_INSERT", "Specify the symbol scale <{0}>: ") self.GetDistClass.msg = prompt.format(str(self.scale)) self.GetDistClass.dist = self.scale self.GetDistClass.inputMode = QadInputModeEnum.NOT_NEGATIVE | QadInputModeEnum.NOT_ZERO self.GetDistClass.startPt = self.insPt self.step = 2 self.GetDistClass.run(msgMapTool, msg) return False else: # se la rotazione dipende da un campo rotFldName = qad_layer.get_symbolRotationFieldName(currLayer) if len(rotFldName) > 0: if self.GetAngleClass is not None: del self.GetAngleClass # si appresta ad attendere l'angolo di rotazione self.GetAngleClass = QadGetAngleClass(self.plugIn) prompt = QadMsg.translate( "Command_INSERT", "Specify the symbol rotation <{0}>: ") self.GetAngleClass.msg = prompt.format( str(qad_utils.toDegrees(self.rot))) self.GetAngleClass.angle = self.rot self.GetAngleClass.startPt = self.insPt self.step = 3 self.GetAngleClass.run(msgMapTool, msg) return False else: self.addFeature(currLayer) return True #========================================================================= # RISPOSTA ALLA RICHIESTA SCALA (da step = 1) elif self.step == 2: if self.GetDistClass.run(msgMapTool, msg) == True: if self.GetDistClass.dist is not None: self.scale = self.GetDistClass.dist self.plugIn.setLastScale(self.scale) del self.GetDistClass self.GetDistClass = None # se la rotazione dipende da un campo rotFldName = qad_layer.get_symbolRotationFieldName( currLayer) if len(rotFldName) > 0: if self.GetAngleClass is not None: del self.GetAngleClass # si appresta ad attendere l'angolo di rotazione self.GetAngleClass = QadGetAngleClass(self.plugIn) prompt = QadMsg.translate( "Command_INSERT", "Specify the symbol rotation <{0}>: ") self.GetAngleClass.msg = prompt.format( str(qad_utils.toDegrees(self.rot))) self.GetAngleClass.angle = self.rot self.GetAngleClass.startPt = self.insPt self.step = 3 self.GetAngleClass.run(msgMapTool, msg) return False else: self.addFeature(currLayer) return True else: return True return False #========================================================================= # RISPOSTA ALLA RICHIESTA ROTAZIONE (da step = 1 o 2) elif self.step == 3: if self.GetAngleClass.run(msgMapTool, msg) == True: if self.GetAngleClass.angle is not None: self.rot = self.GetAngleClass.angle self.plugIn.setLastRot(self.rot) self.addFeature(currLayer) return True # fine comando else: return True return False
def run(self, msgMapTool = False, msg = None): if self.plugIn.canvas.mapSettings().destinationCrs().geographicFlag(): self.showMsg(QadMsg.translate("QAD", "\nThe coordinate reference system of the project must be a projected coordinate system.\n")) return True # fine comando #========================================================================= # RICHIESTA SELEZIONE OGGETTI if self.step == 0: # inizio del comando if self.entitySet.isEmpty(): # non ci sono oggetti da ruotare return True self.showMsg(QadMsg.translate("Command_GRIPMIRROR", "\n** MIRROR **\n")) # si appresta ad attendere il secondo punto di specchio self.waitForMirrorPoint() #========================================================================= # RISPOSTA ALLA RICHIESTA SECONDO PUNTO PER SPECCHIO elif self.step == 1: # dopo aver atteso un punto si riavvia il comando ctrlKey = False if msgMapTool == True: # il punto arriva da una selezione grafica # la condizione seguente si verifica se durante la selezione di un punto # é stato attivato un altro plugin che ha disattivato Qad # quindi stato riattivato il comando che torna qui senza che il maptool # abbia selezionato un punto if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse value = None else: self.setMapTool(self.getPointMapTool()) # riattivo il maptool return False ctrlKey = self.getPointMapTool().ctrlKey value = self.getPointMapTool().point else: # il punto arriva come parametro della funzione value = msg if type(value) == unicode: if value == QadMsg.translate("Command_GRIPMIRROR", "Base point") or value == "Base point": # si appresta ad attendere il punto base self.waitForBasePt() elif value == QadMsg.translate("Command_GRIPMIRROR", "Copy") or value == "Copy": # Copia entità lasciando inalterate le originali self.copyEntities = True # si appresta ad attendere il secondo punto di specchio self.waitForMirrorPoint() elif value == QadMsg.translate("Command_GRIPMIRROR", "Undo") or value == "Undo": if self.nOperationsToUndo > 0: self.nOperationsToUndo = self.nOperationsToUndo - 1 self.plugIn.undoEditCommand() else: self.showMsg(QadMsg.translate("QAD", "\nThe command has been canceled.")) # si appresta ad attendere il secondo punto di specchio self.waitForMirrorPoint() elif value == QadMsg.translate("Command_GRIPMIRROR", "eXit") or value == "eXit": return True # fine comando elif type(value) == QgsPoint: # se é stato inserito il secondo punto if qad_utils.ptNear(self.basePt, value): self.showMsg(QadMsg.translate("Command_GRIPMIRROR", "\nThe points must be different.")) # si appresta ad attendere il secondo punto di specchio self.waitForMirrorPoint() return False self.secondMirrorPt.set(value.x(), value.y()) if ctrlKey: self.copyEntities = True self.mirrorGeoms() if self.copyEntities == False: return True # si appresta ad attendere il secondo punto di specchio self.waitForMirrorPoint() else: if self.copyEntities == False: self.skipToNextGripCommand = True return True # fine comando return False #========================================================================= # RISPOSTA ALLA RICHIESTA PUNTO BASE (da step = 1) elif self.step == 2: # dopo aver atteso un punto if msgMapTool == True: # il punto arriva da una selezione grafica # la condizione seguente si verifica se durante la selezione di un punto # é stato attivato un altro plugin che ha disattivato Qad # quindi stato riattivato il comando che torna qui senza che il maptool # abbia selezionato un punto if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse pass # opzione di default "spostamento" else: self.setMapTool(self.getPointMapTool()) # riattivo il maptool return False value = self.getPointMapTool().point else: # il punto arriva come parametro della funzione value = msg if type(value) == QgsPoint: # se é stato inserito il punto base self.basePt.set(value.x(), value.y()) # si appresta ad attendere il secondo punto di specchio self.waitForMirrorPoint() return False
def getName(self): return QadMsg.translate("Command_list", "DIMSTYLE")
def run(self, msgMapTool = False, msg = None): if self.plugIn.canvas.mapSettings().destinationCrs().geographicFlag(): self.showMsg(QadMsg.translate("QAD", "\nThe coordinate reference system of the project must be a projected coordinate system.\n")) return True # fine comando #========================================================================= # RICHIESTA SELEZIONE OGGETTI if self.step == 0: # inizio del comando if self.SSGetClass.run(msgMapTool, msg) == True: # selezione terminata self.step = 1 self.getPointMapTool().refreshSnapType() # aggiorno lo snapType che può essere variato dal maptool di selezione entità return self.run(msgMapTool, msg) #========================================================================= # SPOSTA OGGETTI elif self.step == 1: self.entitySet.set(self.SSGetClass.entitySet) if self.entitySet.count() == 0: return True # fine comando # imposto il map tool self.getPointMapTool().entitySet.set(self.entitySet) self.getPointMapTool().setMode(Qad_move_maptool_ModeEnum.NONE_KNOWN_ASK_FOR_BASE_PT) keyWords = QadMsg.translate("Command_MOVE", "Displacement") prompt = QadMsg.translate("Command_MOVE", "Specify base point or [{0}] <{0}>: ").format(keyWords) englishKeyWords = "Displacement" keyWords += "_" + englishKeyWords # si appresta ad attendere un punto o enter o una parola chiave # msg, inputType, default, keyWords, nessun controllo self.waitFor(prompt, \ QadInputTypeEnum.POINT2D | QadInputTypeEnum.KEYWORDS, \ None, \ keyWords, QadInputModeEnum.NONE) self.step = 2 return False #========================================================================= # RISPOSTA ALLA RICHIESTA PUNTO BASE (da step = 1) elif self.step == 2: # dopo aver atteso un punto o un numero reale si riavvia il comando if msgMapTool == True: # il punto arriva da una selezione grafica # la condizione seguente si verifica se durante la selezione di un punto # é stato attivato un altro plugin che ha disattivato Qad # quindi stato riattivato il comando che torna qui senza che il maptool # abbia selezionato un punto if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse pass # opzione di default "spostamento" else: self.setMapTool(self.getPointMapTool()) # riattivo il maptool return False value = self.getPointMapTool().point else: # il punto arriva come parametro della funzione value = msg if value is None or type(value) == unicode or type(value) == str: self.basePt.set(0, 0) self.getPointMapTool().basePt = self.basePt self.getPointMapTool().setMode(Qad_move_maptool_ModeEnum.BASE_PT_KNOWN_ASK_FOR_MOVE_PT) # si appresta ad attendere un punto msg = QadMsg.translate("Command_MOVE", "Specify the displacement fom the origin point 0,0 <{0}, {1}>: ") # msg, inputType, default, keyWords, nessun controllo self.waitFor(msg.format(str(self.plugIn.lastOffsetPt.x()), str(self.plugIn.lastOffsetPt.y())), \ QadInputTypeEnum.POINT2D, \ self.plugIn.lastOffsetPt, \ "", QadInputModeEnum.NONE) self.step = 4 elif type(value) == QgsPoint: # se é stato inserito il punto base self.basePt.set(value.x(), value.y()) # imposto il map tool self.getPointMapTool().basePt = self.basePt self.getPointMapTool().setMode(Qad_move_maptool_ModeEnum.BASE_PT_KNOWN_ASK_FOR_MOVE_PT) # si appresta ad attendere un punto o enter o una parola chiave # msg, inputType, default, keyWords, nessun controllo self.waitFor(QadMsg.translate("Command_MOVE", "Specify the second point or <use first point as displacement from the origin point 0,0>: "), \ QadInputTypeEnum.POINT2D, \ None, \ "", QadInputModeEnum.NONE) self.step = 3 return False #========================================================================= # RISPOSTA ALLA RICHIESTA SECONDO PUNTO PER SPOSTAMENTO (da step = 2) elif self.step == 3: # dopo aver atteso un punto o un numero reale si riavvia il comando if msgMapTool == True: # il punto arriva da una selezione grafica # la condizione seguente si verifica se durante la selezione di un punto # é stato attivato un altro plugin che ha disattivato Qad # quindi stato riattivato il comando che torna qui senza che il maptool # abbia selezionato un punto if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse return True # fine comando else: self.setMapTool(self.getPointMapTool()) # riattivo il maptool return False value = self.getPointMapTool().point else: # il punto arriva come parametro della funzione value = msg if value is None: newPt = QgsPoint(self.basePt.x() * 2, self.basePt.y() * 2) self.moveGeoms(newPt) elif type(value) == QgsPoint: # se é stato inserito lo spostamento con un punto self.moveGeoms(value) return True # fine comando #========================================================================= # RISPOSTA ALLA RICHIESTA DEL PUNTO DI SPOSTAMENTO (da step = 2) elif self.step == 4: # dopo aver atteso un punto o un numero reale si riavvia il comando if msgMapTool == True: # il punto arriva da una selezione grafica # la condizione seguente si verifica se durante la selezione di un punto # é stato attivato un altro plugin che ha disattivato Qad # quindi stato riattivato il comando che torna qui senza che il maptool # abbia selezionato un punto if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse return True # fine comando else: self.setMapTool(self.getPointMapTool()) # riattivo il maptool return False value = self.getPointMapTool().point else: # il punto arriva come parametro della funzione value = msg self.plugIn.setLastOffsetPt(value) self.moveGeoms(value) return True
def getNote(self): # impostare le note esplicative del comando return QadMsg.translate("Command_OPTIONS", "QAD Options.")
def getName(self): return QadMsg.translate("Command_list", "BREAK")
def getNote(self): # impostare le note esplicative del comando return QadMsg.translate("Command_MOVE", "Moves the selected objects.")
def run(self, msgMapTool=False, msg=None): if self.plugIn.canvas.mapSettings().destinationCrs().geographicFlag(): self.showMsg( QadMsg.translate( "QAD", "\nThe coordinate reference system of the project must be a projected coordinate system.\n" )) return True # fine comando if self.step == 0: self.waitForEntsel(msgMapTool, msg) return False # continua #========================================================================= # RISPOSTA ALLA SELEZIONE DI UN'ENTITA' (da step = 0) elif self.step == 1: if self.entSelClass.run(msgMapTool, msg) == True: if self.entSelClass.entity.isInitialized(): layer = self.entSelClass.entity.layer self.firstPt = self.entSelClass.point self.plugIn.setLastPoint(self.firstPt) keyWords = QadMsg.translate("Command_BREAK", "First point") prompt = QadMsg.translate( "Command_BREAK", "Specify second break point or [{0}]: ").format( keyWords) self.step = 2 self.getPointMapTool().refreshSnapType( ) # aggiorno lo snapType che può essere variato dal maptool di selezione entità englishKeyWords = "First point" keyWords += "_" + englishKeyWords # si appresta ad attendere un punto o enter o una parola chiave # msg, inputType, default, keyWords, nessun controllo self.waitFor(prompt, \ QadInputTypeEnum.POINT2D | QadInputTypeEnum.KEYWORDS, \ None, \ keyWords, QadInputModeEnum.NONE) return False else: if self.entSelClass.canceledByUsr == True: # fine comando return True self.showMsg( QadMsg.translate("QAD", "No geometries in this position.")) self.waitForEntsel(msgMapTool, msg) return False # continua #========================================================================= # RISPOSTA ALLA RICHIESTA DEL SECONDO PUNTO DI INTERRUZIONE (da step = 1) elif self.step == 2: # dopo aver atteso un punto o una parola chiave si riavvia il comando if msgMapTool == True: # il punto arriva da una selezione grafica # la condizione seguente si verifica se durante la selezione di un punto # é stato attivato un altro plugin che ha disattivato Qad # quindi stato riattivato il comando che torna qui senza che il maptool # abbia selezionato un punto if self.getPointMapTool( ).point is None: # il maptool é stato attivato senza un punto if self.getPointMapTool( ).rightButton == True: # se usato il tasto destro del mouse pass # opzione di default "secondo punto" else: self.setMapTool( self.getPointMapTool()) # riattivo il maptool return False value = self.getPointMapTool().point else: # il punto arriva come parametro della funzione value = msg if value is None or type(value) == unicode: # si appresta ad attendere un punto self.waitForPoint( QadMsg.translate("Command_BREAK", "Specify first break point: ")) self.step = 3 elif type( value) == QgsPoint: # se é stato inserito il secondo punto self.secondPt = value self.plugIn.setLastPoint(self.secondPt) self.breakFeatures() return True return False #========================================================================= # RISPOSTA ALLA RICHIESTA DEL PRIMO PUNTO DI INTERRUZIONE (da step = 2) elif self.step == 3: # dopo aver atteso un punto si riavvia il comando if msgMapTool == True: # il punto arriva da una selezione grafica # la condizione seguente si verifica se durante la selezione di un punto # é stato attivato un altro plugin che ha disattivato Qad # quindi stato riattivato il comando che torna qui senza che il maptool # abbia selezionato un punto if self.getPointMapTool( ).point is None: # il maptool é stato attivato senza un punto if self.getPointMapTool( ).rightButton == True: # se usato il tasto destro del mouse return True # fine comando else: self.setMapTool( self.getPointMapTool()) # riattivo il maptool return False value = self.getPointMapTool().point else: # il punto arriva come parametro della funzione value = msg self.firstPt = value self.plugIn.setLastPoint(self.firstPt) # si appresta ad attendere un punto self.waitForPoint( QadMsg.translate("Command_BREAK", "Specify second break point: ")) self.step = 4 return False #========================================================================= # RISPOSTA ALLA RICHIESTA DEL SECONDO PUNTO DI INTERRUZIONE (da step = 3) elif self.step == 4: # dopo aver atteso un punto si riavvia il comando if msgMapTool == True: # il punto arriva da una selezione grafica # la condizione seguente si verifica se durante la selezione di un punto # é stato attivato un altro plugin che ha disattivato Qad # quindi stato riattivato il comando che torna qui senza che il maptool # abbia selezionato un punto if self.getPointMapTool( ).point is None: # il maptool é stato attivato senza un punto if self.getPointMapTool( ).rightButton == True: # se usato il tasto destro del mouse return True # fine comando else: self.setMapTool( self.getPointMapTool()) # riattivo il maptool return False value = self.getPointMapTool().point else: # il punto arriva come parametro della funzione value = msg self.secondPt = value self.plugIn.setLastPoint(self.secondPt) self.breakFeatures() return True
def getNote(self): # impostare le note esplicative del comando return QadMsg.translate("Command_BREAK", "Breaks an object.")