def canvasPressEvent(self, event): # volevo mettere questo evento nel canvasReleaseEvent # ma il tasto destro non genera quel tipo di evento if event.button() == Qt.RightButton: self.displayPopupMenuOnQuiescentState(event.pos()) elif event.button() == Qt.LeftButton: # verifico se tasto shift premuto shiftKey = True if event.modifiers() & Qt.ShiftModifier else False # posizione corrente del mouse point = self.toMapCoordinates(event.pos()) # leggo il punto grip che si interseca alla posizione del mouse entityGripPoint = self.entitySetGripPoints.isIntersecting(point) if entityGripPoint is not None: if shiftKey == False: # lancio il comando selectedEntityGripPoints = self.entitySetGripPoints.getSelectedEntityGripPoints( ) # se non ci sono già grip selezionati if len(selectedEntityGripPoints) == 0: # seleziono il corrente if self.entitySetGripPoints.selectIntersectingGripPoints( point) > 0: selectedEntityGripPoints = self.entitySetGripPoints.getSelectedEntityGripPoints( ) # lancio il comando self.plugIn.runCommand("QadVirtualGripCommandsClass", [QadVirtualGripCommandsEnum.STRECTH, \ self.entitySetGripPoints, entityGripPoint.getPoint()]) else: # shift premuto # inverto lo stato ai grip che intersecano il punto self.entitySetGripPoints.toggleSelectIntersectingGripPoints( point) else: result = qad_utils.getEntSel(event.pos(), self, \ QadVariables.get(QadMsg.translate("Environment variables", "PICKBOX"))) if result is not None: feature = result[0] layer = result[1] tmpEntity = QadEntity() tmpEntity.set(layer, feature.id()) SSGetClass = QadSSGetClass(self.plugIn) SSGetClass.entitySet.set(self.entitySet) SSGetClass.elaborateEntity(tmpEntity, shiftKey) self.plugIn.showMsg("\n", True) # ripete il prompt self.entitySet.set(SSGetClass.entitySet) del SSGetClass # che deseleziona gli oggetti self.entitySet.selectOnLayer(False) self.refreshEntityGripPoints(self.entitySet) else: self.plugIn.runCommand("QadVirtualSelCommandClass", point)
def canvasPressEvent(self, event): # I wanted to put this event in the canvasReleaseEvent # But the right button does not generate that kind of event if event.button() == Qt.RightButton: self.displayPopupMenuOnQuiescentState(event.pos()) elif event.button() == Qt.LeftButton: # I check if the shift key is pressed shiftKey = True if event.modifiers() & Qt.ShiftModifier else False # Current mouse position point = self.toMapCoordinates(event.pos()) # I read the grip point that intersects the mouse position entityGripPoint = self.entitySetGripPoints.isIntersecting(point) if entityGripPoint is not None: if shiftKey == False: # lancio il comando selectedEntityGripPoints = self.entitySetGripPoints.getSelectedEntityGripPoints( ) # se non ci sono già grip selezionati if len(selectedEntityGripPoints) == 0: # seleziono il corrente if self.entitySetGripPoints.selectIntersectingGripPoints( point) > 0: selectedEntityGripPoints = self.entitySetGripPoints.getSelectedEntityGripPoints( ) # lancio il comando self.plugIn.runCommand("QadVirtualGripCommandsClass", [QadVirtualGripCommandsEnum.STRECTH, \ self.entitySetGripPoints, entityGripPoint.getPoint()]) else: # Shift pressed # Invert the state of grips intersecting the point self.entitySetGripPoints.toggleSelectIntersectingGripPoints( point) else: result = qad_utils.getEntSel(event.pos(), self, \ QadVariables.get(QadMsg.translate("Environment variables", "PICKBOX"))) if result is not None: feature = result[0] layer = result[1] tmpEntity = QadEntity() tmpEntity.set(layer, feature.id()) SSGetClass = QadSSGetClass(self.plugIn) SSGetClass.entitySet.set(self.entitySet) SSGetClass.elaborateEntity(tmpEntity, shiftKey) self.plugIn.showMsg("\n", True) # Repeat the prompt self.entitySet.set(SSGetClass.entitySet) del SSGetClass # Which deselects objects self.entitySet.selectOnLayer(False) self.refreshEntityGripPoints(self.entitySet) else: self.plugIn.runCommand("QadVirtualSelCommandClass", point)
def canvasPressEvent(self, event): # volevo mettere questo evento nel canvasReleaseEvent # ma il tasto destro non genera quel tipo di evento if event.button() == Qt.RightButton: # Se é stato premuto il tasto CTRL (o META) if (event.modifiers() & Qt.ControlModifier) or (event.modifiers() & Qt.MetaModifier): self.displayPopupMenu(event.pos()) else: # self.clear() da rivedere self.rightButton = True elif event.button() == Qt.LeftButton: if ( self.getSelectionMode() == QadGetPointSelectionModeEnum.ENTITY_SELECTION_DYNAMIC or self.getSelectionMode() == QadGetPointSelectionModeEnum.ENTITY_SELECTION ): self.tmpPoint = self.toMapCoordinates(event.pos()) result = qad_utils.getEntSel( event.pos(), self, self.layersToCheck, self.checkPointLayer, self.checkLineLayer, self.checkPolygonLayer, True, self.onlyEditableLayers, ) if result is not None: feature = result[0] layer = result[1] self.tmpEntity.set(layer, feature.id()) self.__QadSnapper.removeReferenceLines() self.__QadSnapPointsDisplayManager.hide() self.__setPoint(event) self.rightButton = False if self.__oldSnapType is not None: self.setSnapType(self.__oldSnapType) # riporto il valore precedente self.__QadSnapper.setProgressDistance(self.__oldSnapProgrDist) # tasto shift premuto durante il click del mouse self.shiftKey = True if event.modifiers() & Qt.ShiftModifier else False # tasto ctrl premuto durante il click del mouse self.ctrlKey = True if event.modifiers() & Qt.ControlModifier else False self.plugIn.QadCommands.continueCommandFromMapTool()
def canvasPressEvent(self, event): # volevo mettere questo evento nel canvasReleaseEvent # ma il tasto destro non genera quel tipo di evento if event.button() == Qt.RightButton: self.displayPopupMenuOnQuiescentState(event.pos()) elif event.button() == Qt.LeftButton: # verifico se tasto shift premuto shiftKey = True if event.modifiers() & Qt.ShiftModifier else False # posizione corrente del mouse point = self.toMapCoordinates(event.pos()) # leggo il punto grip che si interseca alla posizione del mouse entityGripPoint = self.entitySetGripPoints.isIntersecting(point) if entityGripPoint is not None: if shiftKey == False: # lancio il comando selectedEntityGripPoints = self.entitySetGripPoints.getSelectedEntityGripPoints() # se non ci sono già grip selezionati if len(selectedEntityGripPoints) == 0: # seleziono il corrente if self.entitySetGripPoints.selectIntersectingGripPoints(point) > 0: selectedEntityGripPoints = self.entitySetGripPoints.getSelectedEntityGripPoints() # lancio il comando self.plugIn.runCommand("QadVirtualGripCommandsClass", [QadVirtualGripCommandsEnum.STRECTH, \ self.entitySetGripPoints, entityGripPoint.getPoint()]) else: # shift premuto # inverto lo stato ai grip che intersecano il punto self.entitySetGripPoints.toggleSelectIntersectingGripPoints(point) else: result = qad_utils.getEntSel(event.pos(), self, \ QadVariables.get(QadMsg.translate("Environment variables", "PICKBOX"))) if result is not None: feature = result[0] layer = result[1] tmpEntity = QadEntity() tmpEntity.set(layer, feature.id()) SSGetClass = QadSSGetClass(self.plugIn) SSGetClass.entitySet.set(self.entitySet) SSGetClass.elaborateEntity(tmpEntity, shiftKey) self.plugIn.showMsg("\n", True) # ripete il prompt self.entitySet.set(SSGetClass.entitySet) del SSGetClass # che deseleziona gli oggetti self.entitySet.selectOnLayer(False) self.refreshEntityGripPoints(self.entitySet) else: self.plugIn.runCommand("QadVirtualSelCommandClass", point)
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 #========================================================================= # RICHIESTA SELEZIONE OGGETTI LIMITI if self.step == 0: # inizio del comando CurrSettingsMsg = QadMsg.translate("QAD", "\nCurrent settings: ") if self.edgeMode == 0: # 0 = nessuna estensione CurrSettingsMsg = CurrSettingsMsg + QadMsg.translate("Command_TRIM", "Edge = No extend") else: CurrSettingsMsg = CurrSettingsMsg + QadMsg.translate("Command_TRIM", "Edge = Extend") self.showMsg(CurrSettingsMsg) self.showMsg(QadMsg.translate("Command_TRIM", "\nSelect trim limits...")) if self.SSGetClass.run(msgMapTool, msg) == True: # selezione terminata self.step = 1 return self.run(msgMapTool, msg) #========================================================================= # RISPOSTA ALLA SELEZIONE OGGETTI LIMITI elif self.step == 1: self.limitEntitySet.set(self.SSGetClass.entitySet) if self.limitEntitySet.count() == 0: return True # fine comando # si appresta ad attendere la selezione degli oggetti da estendere/tagliare self.waitForObjectSel() return False #========================================================================= # RISPOSTA ALLA SELEZIONE OGGETTI DA ESTENDERE elif self.step == 2: 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 else: value = self.getPointMapTool().point else: # il punto arriva come parametro della funzione value = msg if type(value) == unicode: if value == QadMsg.translate("Command_TRIM", "Fence") or value == "Fence": # Seleziona tutti gli oggetti che intersecano una polilinea self.PLINECommand = QadPLINECommandClass(self.plugIn) # 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.run(msgMapTool, msg) self.step = 3 return False elif value == QadMsg.translate("Command_TRIM", "Crossing") or value == "Crossing": # Seleziona tutti gli oggetti che intersecano un rettangolo self.RECTANGLECommand = QadRECTANGLECommandClass(self.plugIn) # 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.RECTANGLECommand.virtualCmd = True self.RECTANGLECommand.run(msgMapTool, msg) self.step = 4 return False elif value == QadMsg.translate("Command_TRIM", "Edge") or value == "Edge": # Per estendere un oggetto usando anche le estensioni degli oggetti di riferimento # vedi variabile EDGEMODE keyWords = QadMsg.translate("Command_TRIM", "Extend") + "/" + \ QadMsg.translate("Command_TRIM", "No extend") if self.edgeMode == 0: # 0 = nessuna estensione self.defaultValue = QadMsg.translate("Command_TRIM", "No") else: self.defaultValue = QadMsg.translate("Command_TRIM", "Extend") prompt = QadMsg.translate("Command_TRIM", "Specify an extension mode [{0}] <{1}>: ").format(keyWords, self.defaultValue) englishKeyWords = "Extend" + "/" + "No extend" keyWords += "_" + englishKeyWords # si appresta ad attendere enter o una parola chiave # msg, inputType, default, keyWords, nessun controllo self.waitFor(prompt, \ QadInputTypeEnum.KEYWORDS, \ self.defaultValue, \ keyWords, QadInputModeEnum.NONE) self.step = 5 return False elif value == QadMsg.translate("Command_TRIM", "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.")) elif type(value) == QgsPoint: # se é stato selezionato un punto self.entitySet.clear() if self.getPointMapTool().entity.isInitialized(): self.entitySet.addEntity(self.getPointMapTool().entity) ToExtend = True if self.getPointMapTool().shiftKey == True else False self.trimFeatures(QgsGeometry.fromPoint(value), ToExtend) else: # cerco se ci sono entità nel punto indicato considerando # 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) result = qad_utils.getEntSel(self.getPointMapTool().toCanvasCoordinates(value), self.getPointMapTool(), \ QadVariables.get(QadMsg.translate("Environment variables", "PICKBOX")), \ layerList) if result is not None: feature = result[0] layer = result[1] point = result[2] self.entitySet.addEntity(QadEntity().set(layer, feature.id())) self.trimFeatures(QgsGeometry.fromPoint(point), False) else: return True # fine comando # si appresta ad attendere la selezione degli oggetti da estendere/tagliare self.waitForObjectSel() return False #========================================================================= # RISPOSTA ALLA RICHIESTA PUNTO PER MODALITA' INTERCETTA (da step = 2) elif self.step == 3: # dopo aver atteso un punto si riavvia il comando if self.PLINECommand.run(msgMapTool, msg) == True: if len(self.PLINECommand.vertices) > 1: if msgMapTool == True: # se la polilinea arriva da una selezione grafica ToExtend = True if self.getPointMapTool().shiftKey == True else False else: ToExtend = False # cerco tutte le geometrie passanti per la polilinea saltando i layer punto e poligono # e considerando solo layer editabili self.entitySet = qad_utils.getSelSet("F", self.getPointMapTool(), self.PLINECommand.vertices, \ None, False, True, False, \ True) self.trimFeatures(QgsGeometry.fromPolyline(self.PLINECommand.vertices), ToExtend) del self.PLINECommand self.PLINECommand = None # si appresta ad attendere la selezione degli oggetti da estendere/tagliare self.waitForObjectSel() self.getPointMapTool().refreshSnapType() # aggiorno lo snapType che può essere variato dal maptool di pline return False #========================================================================= # RISPOSTA ALLA RICHIESTA PUNTO PER MODALITA' INTERSECA (da step = 2) elif self.step == 4: # dopo aver atteso un punto si riavvia il comando if self.RECTANGLECommand.run(msgMapTool, msg) == True: if len(self.RECTANGLECommand.vertices) > 1: if msgMapTool == True: # se la polilinea arriva da una selezione grafica ToExtend = True if self.getPointMapTool().shiftKey == True else False else: ToExtend = False # cerco tutte le geometrie passanti per la polilinea saltando i layer punto e poligono # e considerando solo layer editabili self.entitySet = qad_utils.getSelSet("F", self.getPointMapTool(), self.RECTANGLECommand.vertices, \ None, False, True, False, \ True) self.trimFeatures(QgsGeometry.fromPolyline(self.RECTANGLECommand.vertices), ToExtend) del self.RECTANGLECommand self.RECTANGLECommand = None # si appresta ad attendere la selezione degli oggetti da estendere/tagliare self.waitForObjectSel() self.getPointMapTool().refreshSnapType() # aggiorno lo snapType che può essere variato dal maptool di rectangle return False #========================================================================= # RISPOSTA ALLA RICHIESTA DI TIPO DI ESTENSIONE (da step = 2) elif self.step == 5: # 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 = self.defaultValue 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("Command_TRIM", "No") or value == "No": self.edgeMode = 0 QadVariables.set(QadMsg.translate("Environment variables", "EDGEMODE"), self.edgeMode) QadVariables.save() # si appresta ad attendere la selezione degli oggetti da estendere/tagliare self.waitForObjectSel() elif value == QadMsg.translate("Command_TRIM", "Extend") or value == "Extend": self.edgeMode = 1 QadVariables.set(QadMsg.translate("Environment variables", "EDGEMODE"), self.edgeMode) QadVariables.save() # si appresta ad attendere la selezione degli oggetti da estendere/tagliare self.waitForObjectSel() return False
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 #========================================================================= # RICHIESTA SELEZIONE OGGETTO if self.step == 0: # inizio del comando # si appresta ad attendere la selezione degli oggetti da estendere/tagliare self.waitForObjectSelToMisure() return False #========================================================================= # RISPOSTA ALLA SELEZIONE OGGETTI DA MISURARE elif self.step == 1: 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 = self.defaultValue else: self.setMapTool(self.getPointMapTool()) # riattivo il maptool return False else: value = self.getPointMapTool().point else: # il punto arriva come parametro della funzione value = msg if type(value) == unicode: if value == QadMsg.translate("Command_LENGTHEN", "DElta") or value == "DElta": self.waitForDelta() return False elif value == QadMsg.translate("Command_LENGTHEN", "Percent") or value == "Percent": self.waitForPercent() return False elif value == QadMsg.translate("Command_LENGTHEN", "Total") or value == "Total": self.waitForTotal() return False elif value == QadMsg.translate("Command_LENGTHEN", "DYnamic") or value == "DYnamic": self.OpMode = "DYnamic" self.plugIn.setLastOpMode_lengthen(self.OpMode) # si appresta ad attendere la selezione degli oggetti da allungare self.waitForObjectSel() return False elif type(value) == QgsPoint: # se é stato selezionato un punto if self.getPointMapTool().entity.isInitialized(): self.showLength(self.getPointMapTool().entity, value) else: # cerco se ci sono entità nel punto indicato considerando # solo layer di tipo lineari che non appartengano a quote o di tipo poligono layerList = [] for layer in self.plugIn.canvas.layers(): if layer.type() == QgsMapLayer.VectorLayer and \ layer.geometryType() == QGis.Line or layer.geometryType() == QGis.Polygon: if len(QadDimStyles.getDimListByLayer(layer)) == 0: layerList.append(layer) result = qad_utils.getEntSel(self.getPointMapTool().toCanvasCoordinates(value), self.getPointMapTool(), \ layerList) if result is not None: feature = result[0] layer = result[1] self.showLength(QadEntity().set(layer, feature.id()), value) else: return True # fine comando # si appresta ad attendere la selezione degli oggetti da misurare self.waitForObjectSelToMisure() return False #========================================================================= # RISPOSTA ALLA RICHIESTA DEL DELTA (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 value = self.plugIn.lastDelta_lengthen # opzione di default "spostamento" else: self.setMapTool(self.getPointMapTool()) # riattivo il maptool return False else: value = self.getPointMapTool().point else: # il punto arriva come parametro della funzione value = msg if type(value) == unicode: if value == QadMsg.translate("Command_LENGTHEN", "Angle") or value == "Angle": self.waitForDeltaAngle(msgMapTool, msg) elif type(value) == QgsPoint: # se é stato inserito un punto self.startPt = value self.waitForDeltaLength(msgMapTool, msg) elif type(value) == float: # se é stato inserito il delta self.plugIn.setLastDelta_lengthen(value) self.OpType = "length" self.value = value # si appresta ad attendere la selezione degli oggetti da allungare self.waitForObjectSel() return False #========================================================================= # RISPOSTA ALLA RICHIESTA DELLA LUNGHEZZA DEL DELTA (da step = 2) elif self.step == 3: # dopo aver atteso un punto o un numero reale si riavvia il comando if self.GetDistClass.run(msgMapTool, msg) == True: if self.GetDistClass.dist is not None: self.plugIn.setLastDelta_lengthen(self.GetDistClass.dist) self.value = self.GetDistClass.dist # si appresta ad attendere la selezione degli oggetti da allungare self.waitForObjectSel() #========================================================================= # RISPOSTA ALLA RICHIESTA DELL'ANGOLO DEL DELTA (da step = 2) elif self.step == 4: # dopo aver atteso un punto o un numero reale si riavvia il comando if self.GetAngleClass.run(msgMapTool, msg) == True: if self.GetAngleClass.angle is not None: self.plugIn.setLastDeltaAngle_lengthen(self.GetAngleClass.angle) self.value = self.GetAngleClass.angle # si appresta ad attendere la selezione degli oggetti da allungare self.waitForObjectSel() #========================================================================= # RISPOSTA ALLA SELEZIONE OGGETTI DA ALLUNGARE elif self.step == 5: 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 else: value = self.getPointMapTool().point else: # il punto arriva come parametro della funzione value = msg if type(value) == unicode: if value == QadMsg.translate("Command_LENGTHEN", "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.")) elif type(value) == QgsPoint: # se é stato selezionato un punto if self.getPointMapTool().entity.isInitialized(): self.setInfo(self.getPointMapTool().entity, value) if self.OpMode != "DYnamic": self.lengthen(value) else: self.waitForDynamicPt() return False else: # cerco se ci sono entità nel punto indicato considerando # 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(QadDimStyles.getDimListByLayer(layer)) == 0: layerList.append(layer) result = qad_utils.getEntSel(self.getPointMapTool().toCanvasCoordinates(value), self.getPointMapTool(), \ layerList) if result is not None: feature = result[0] layer = result[1] self.setInfo(QadEntity().set(layer, feature.id()), value) if self.OpMode != "DYnamic": self.lengthen(value) else: self.waitForDynamicPt() return False else: return True # fine comando # si appresta ad attendere la selezione degli oggetti da allungare self.waitForObjectSel() return False #========================================================================= # RISPOSTA ALLA RICHIESTA PERCENTUALE (da step = 1) elif self.step == 6: # dopo aver atteso 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 value = self.plugIn.lastPerc_lengthen else: self.setMapTool(self.getPointMapTool()) # riattivo il maptool return False else: return False else: # il punto arriva come parametro della funzione value = msg if type(value) == float: # é stata inserita la percentuale self.plugIn.setLastPerc_lengthen(value) self.value = value # si appresta ad attendere la selezione degli oggetti da allungare self.waitForObjectSel() return False #========================================================================= # RISPOSTA ALLA RICHIESTA DEL TOTALE (da step = 1) elif self.step == 7: # 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 value = self.plugIn.lastTotal_lengthen else: self.setMapTool(self.getPointMapTool()) # riattivo il maptool return False else: value = self.getPointMapTool().point else: # il punto arriva come parametro della funzione value = msg if type(value) == unicode: if value == QadMsg.translate("Command_LENGTHEN", "Angle") or value == "Angle": self.waitForTotalAngle(msgMapTool, msg) elif type(value) == QgsPoint: # se é stato inserito un punto self.startPt = value self.waitForTotalLength(msgMapTool, msg) elif type(value) == float: # se é stato inserito il delta self.plugIn.setLastTotal_lengthen(value) self.OpType = "length" self.value = value # si appresta ad attendere la selezione degli oggetti da allungare self.waitForObjectSel() return False #========================================================================= # RISPOSTA ALLA RICHIESTA DELLA LUNGHEZZA DEL TOTALE (da step = 7) elif self.step == 8: # dopo aver atteso un punto o un numero reale si riavvia il comando if self.GetDistClass.run(msgMapTool, msg) == True: if self.GetDistClass.dist is not None: self.plugIn.setLastTotal_lengthen(self.GetDistClass.dist) self.value = self.GetDistClass.dist # si appresta ad attendere la selezione degli oggetti da allungare self.waitForObjectSel() return False #========================================================================= # RISPOSTA ALLA RICHIESTA DELL'ANGOLO DEL DELTA (da step = 7) elif self.step == 9: # dopo aver atteso un punto o un numero reale si riavvia il comando if self.GetAngleClass.run(msgMapTool, msg) == True: if self.GetAngleClass.angle is not None: self.plugIn.setLastTotalAngle_lengthen(self.GetAngleClass.angle) self.value = self.GetAngleClass.angle # si appresta ad attendere la selezione degli oggetti da allungare self.waitForObjectSel() return False #========================================================================= # RISPOSTA ALLA RICHIESTA DELLA NUOVA ESTREMITA' IN MODO DINAMICO (da step = 5) elif self.step == 10: # 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 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 un punto self.lengthen(value) # si appresta ad attendere la selezione degli oggetti da allungare self.waitForObjectSel() 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 if self.step == 0: CurrSettingsMsg = QadMsg.translate("QAD", "\nCurrent settings: ") if self.filletMode == 1: CurrSettingsMsg = CurrSettingsMsg + QadMsg.translate( "Command_FILLET", "Mode = Trim-extend") else: CurrSettingsMsg = CurrSettingsMsg + QadMsg.translate( "Command_FILLET", "Mode = No trim-extend") CurrSettingsMsg = CurrSettingsMsg + QadMsg.translate( "Command_FILLET", ", Radius = ") + str(self.radius) self.showMsg(CurrSettingsMsg) self.waitForFirstEntSel() return False # continua #========================================================================= # RISPOSTA ALLA SELEZIONE PRIMO OGGETTO elif self.step == 1: 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 else: value = self.getPointMapTool().point else: # il punto arriva come parametro della funzione value = msg if type(value) == unicode or type(value) == str: if value == QadMsg.translate("Command_FILLET", "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.")) self.waitForFirstEntSel( ) # si appresta ad attendere la selezione del primo oggetto elif value == QadMsg.translate( "Command_FILLET", "Polyline") or value == "Polyline": self.WaitForPolyline() # l'opzione Radius viene tradotta in italiano in "RAggio" nel contesto "waitForFirstEntSel" elif value == QadMsg.translate( "Command_FILLET", "Radius", "waitForFirstEntSel") or value == "Radius": if self.GetDistClass is not None: del self.GetDistClass self.GetDistClass = QadGetDistClass(self.plugIn) prompt = QadMsg.translate("Command_FILLET", "Specify fillet radius <{0}>: ") self.GetDistClass.msg = prompt.format(str(self.radius)) self.GetDistClass.dist = self.radius self.GetDistClass.inputMode = QadInputModeEnum.NOT_NEGATIVE self.step = 3 self.GetDistClass.run(msgMapTool, msg) elif value == QadMsg.translate("Command_FILLET", "Trim") or value == "Trim": self.waitForFilletMode() elif value == QadMsg.translate( "Command_FILLET", "Multiple") or value == "Multiple": self.multi = True self.waitForFirstEntSel( ) # si appresta ad attendere la selezione del primo oggetto elif type(value) == QgsPoint: # se é stato selezionato un punto self.entity1.clear() self.linearObjectList1.removeAll() if self.getPointMapTool().entity.isInitialized(): if self.setEntityInfo(True, self.getPointMapTool().entity.layer, \ self.getPointMapTool().entity.featureId, value) == True: self.waitForSecondEntSel( ) # si appresta ad attendere la selezione del secondo oggetto return False else: # cerco se ci sono entità nel punto indicato considerando # solo layer lineari o poligono 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 or layer.geometryType() == QGis.Polygon) and \ layer.isEditable(): if len(QadDimStyles.getDimListByLayer(layer)) == 0: layerList.append(layer) result = qad_utils.getEntSel(self.getPointMapTool().toCanvasCoordinates(value), \ self.getPointMapTool(), \ layerList) if result is not None: # result[0] = feature, result[1] = layer, result[0] = point if self.setEntityInfo(True, result[1], result[0].id(), result[2]) == True: self.waitForSecondEntSel( ) # si appresta ad attendere la selezione del secondo oggetto return False self.waitForFirstEntSel( ) # si appresta ad attendere la selezione del primo oggetto else: return True # fine comando return False #========================================================================= # RISPOSTA ALLA SELEZIONE DI UNA POLILINEA (da step = 1) elif self.step == 2: 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 else: value = self.getPointMapTool().point else: # il punto arriva come parametro della funzione value = msg if type(value) == unicode or type(value) == str: # l'opzione Radius viene tradotta in italiano in "Raggio" nel contesto "WaitForPolyline" if value == QadMsg.translate( "Command_FILLET", "Radius", "WaitForPolyline") or value == "Radius": if self.GetDistClass is not None: del self.GetDistClass self.GetDistClass = QadGetDistClass(self.plugIn) prompt = QadMsg.translate("Command_FILLET", "Specify fillet radius <{0}>: ") self.GetDistClass.msg = prompt.format(str(self.radius)) self.GetDistClass.dist = self.radius self.GetDistClass.inputMode = QadInputModeEnum.NOT_NEGATIVE self.step = 5 self.GetDistClass.run(msgMapTool, msg) return False elif type(value) == QgsPoint: # se é stato selezionato un punto self.entity1.clear() self.linearObjectList1.removeAll() if self.getPointMapTool().entity.isInitialized(): if self.setEntityInfo(True, self.getPointMapTool().entity.layer, \ self.getPointMapTool().entity.featureId, value) == True: if self.filletPolyline() == False or self.multi: self.waitForFirstEntSel( ) # si appresta ad attendere la selezione del primo oggetto return False else: return True else: # cerco se ci sono entità nel punto indicato considerando # solo layer lineari o poligono 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 or layer.geometryType() == QGis.Polygon) and \ layer.isEditable(): if len(QadDimStyles.getDimListByLayer(layer)) == 0: layerList.append(layer) result = qad_utils.getEntSel(self.getPointMapTool().toCanvasCoordinates(value), \ self.getPointMapTool(), \ QadVariables.get(QadMsg.translate("Environment variables", "PICKBOX")), \ layerList) if result is not None: # result[0] = feature, result[1] = layer, result[0] = point if self.setEntityInfo(True, result[1], result[0].id(), result[2]) == True: if self.filletPolyline() == False or self.multi: self.waitForFirstEntSel( ) # si appresta ad attendere la selezione del primo oggetto return False else: return True else: return True # fine comando self.WaitForPolyline() return False #========================================================================= # RISPOSTA ALLA RICHIESTA DEL RAGGIO DI RACCORDO (da step = 1) elif self.step == 3: if self.GetDistClass.run(msgMapTool, msg) == True: if self.GetDistClass.dist is not None: self.radius = self.GetDistClass.dist QadVariables.set( QadMsg.translate("Environment variables", "FILLETRAD"), self.radius) QadVariables.save() self.waitForFirstEntSel( ) # si appresta ad attendere la selezione del primo oggetto self.getPointMapTool().refreshSnapType( ) # aggiorno lo snapType che può essere variato dal maptool di distanza return False # fine comando #========================================================================= # RISPOSTA ALLA RICHIESTA DELLA MODALITA' DI TAGLIO (da step = 1) 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 value = self.filletMode else: self.setMapTool( self.getPointMapTool()) # riattivo il maptool return False else: value = self.getPointMapTool().point else: # il punto arriva come parametro della funzione value = msg if type(value) == unicode or type(value) == str: if value == QadMsg.translate( "Command_FILLET", "Trim-extend") or value == "Trim-extend": self.filletMode = 1 elif value == QadMsg.translate( "Command_FILLET", "No trim-extend") or value == "No trim-extend": self.filletMode = 2 self.plugIn.setFilletMode(self.filletMode) self.waitForFirstEntSel( ) # si appresta ad attendere la selezione del primo oggetto return False #========================================================================= # RISPOSTA ALLA RICHIESTA DEL RAGGIO DI RACCORDO (da step = 3) elif self.step == 5: if self.GetDistClass.run(msgMapTool, msg) == True: if self.GetDistClass.dist is not None: self.radius = self.GetDistClass.dist QadVariables.set( QadMsg.translate("Environment variables", "FILLETRAD"), self.radius) QadVariables.save() self.WaitForPolyline() self.getPointMapTool().refreshSnapType( ) # aggiorno lo snapType che può essere variato dal maptool di distanza return False # fine comando #========================================================================= # RISPOSTA ALLA SELEZIONE SECONDO OGGETTO elif self.step == 6: 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 else: value = self.getPointMapTool().point else: # il punto arriva come parametro della funzione value = msg if type(value) == unicode or type(value) == str: # l'opzione Radius viene tradotta in italiano in "RAggio" nel contesto "waitForSecondEntSel" if value == QadMsg.translate( "Command_FILLET", "Radius", "waitForSecondEntSel") or value == "Radius": if self.GetDistClass is not None: del self.GetDistClass self.GetDistClass = QadGetDistClass(self.plugIn) prompt = QadMsg.translate("Command_FILLET", "Specify fillet radius <{0}>: ") self.GetDistClass.msg = prompt.format(str(self.radius)) self.GetDistClass.dist = self.radius self.GetDistClass.inputMode = QadInputModeEnum.NOT_NEGATIVE self.step = 7 self.GetDistClass.run(msgMapTool, msg) return False elif type(value) == QgsPoint: # se é stato selezionato un punto self.entity2.clear() self.linearObjectList2.removeAll() if self.getPointMapTool().entity.isInitialized(): if self.setEntityInfo(False, self.getPointMapTool().entity.layer, \ self.getPointMapTool().entity.featureId, value) == True: if self.getPointMapTool().shiftKey == True: dummyRadius = self.radius self.radius = 0 dummyFilletMode = self.filletMode self.filletMode = 1 # modalità di raccordo; 1=Taglia-estendi result = self.fillet() self.radius = dummyRadius self.filletMode = dummyFilletMode else: result = self.fillet() if result == False: self.waitForSecondEntSel( ) # si appresta ad attendere la selezione del secondo oggetto return False if self.multi: self.waitForFirstEntSel( ) # si appresta ad attendere la selezione del primo oggetto return False else: return True else: # cerco se ci sono entità nel punto indicato considerando # solo layer lineari o poligono 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 or layer.geometryType() == QGis.Polygon) and \ layer.isEditable(): if len(QadDimStyles.getDimListByLayer(layer)) == 0: layerList.append(layer) result = qad_utils.getEntSel(self.getPointMapTool().toCanvasCoordinates(value), \ self.getPointMapTool(), \ QadVariables.get(QadMsg.translate("Environment variables", "PICKBOX")), \ layerList) if result is not None: # result[0] = feature, result[1] = layer, result[0] = point if self.setEntityInfo(False, result[1], result[0].id(), result[2]) == True: if self.fillet() == False: self.waitForSecondEntSel( ) # si appresta ad attendere la selezione del secondo oggetto return False if self.multi: self.waitForFirstEntSel( ) # si appresta ad attendere la selezione del primo oggetto return False else: return True else: return True # fine comando self.waitForSecondEntSel( ) # si appresta ad attendere la selezione del secondo oggetto return False #========================================================================= # RISPOSTA ALLA RICHIESTA DEL RAGGIO DI RACCORDO (da step = 6) elif self.step == 7: if self.GetDistClass.run(msgMapTool, msg) == True: if self.GetDistClass.dist is not None: self.radius = self.GetDistClass.dist QadVariables.set( QadMsg.translate("Environment variables", "FILLETRAD"), self.radius) QadVariables.save() self.waitForSecondEntSel( ) # si appresta ad attendere la selezione del secondo oggetto self.getPointMapTool().refreshSnapType( ) # aggiorno lo snapType che può essere variato dal maptool di distanza return False # fine comando
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: CurrSettingsMsg = QadMsg.translate("QAD", "\nCurrent settings: ") if self.filletMode == 1: CurrSettingsMsg = CurrSettingsMsg + QadMsg.translate("Command_FILLET", "Mode = Trim-extend") else: CurrSettingsMsg = CurrSettingsMsg + QadMsg.translate("Command_FILLET", "Mode = No trim-extend") CurrSettingsMsg = CurrSettingsMsg + QadMsg.translate("Command_FILLET", ", Radius = ") + str(self.radius) self.showMsg(CurrSettingsMsg) self.waitForFirstEntSel() return False # continua #========================================================================= # RISPOSTA ALLA SELEZIONE PRIMO OGGETTO elif self.step == 1: 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 else: value = self.getPointMapTool().point else: # il punto arriva come parametro della funzione value = msg if type(value) == unicode: if value == QadMsg.translate("Command_FILLET", "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.")) self.waitForFirstEntSel() # si appresta ad attendere la selezione del primo oggetto elif value == QadMsg.translate("Command_FILLET", "Polyline") or value == "Polyline": self.WaitForPolyline() # l'opzione Radius viene tradotta in italiano in "RAggio" nel contesto "waitForFirstEntSel" elif value == QadMsg.translate("Command_FILLET", "Radius", "waitForFirstEntSel") or value == "Radius": if self.GetDistClass is not None: del self.GetDistClass self.GetDistClass = QadGetDistClass(self.plugIn) prompt = QadMsg.translate("Command_FILLET", "Specify fillet radius <{0}>: ") self.GetDistClass.msg = prompt.format(str(self.radius)) self.GetDistClass.dist = self.radius self.GetDistClass.inputMode = QadInputModeEnum.NOT_NEGATIVE self.step = 3 self.GetDistClass.run(msgMapTool, msg) elif value == QadMsg.translate("Command_FILLET", "Trim") or value == "Trim": self.waitForFilletMode() elif value == QadMsg.translate("Command_FILLET", "Multiple") or value == "Multiple": self.multi = True self.waitForFirstEntSel() # si appresta ad attendere la selezione del primo oggetto elif type(value) == QgsPoint: # se é stato selezionato un punto self.entity1.clear() self.linearObjectList1.removeAll() if self.getPointMapTool().entity.isInitialized(): if self.setEntityInfo(True, self.getPointMapTool().entity.layer, \ self.getPointMapTool().entity.featureId, value) == True: self.waitForSecondEntSel() # si appresta ad attendere la selezione del secondo oggetto return False else: # cerco se ci sono entità nel punto indicato considerando # solo layer lineari o poligono 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 or layer.geometryType() == QGis.Polygon) and \ layer.isEditable(): if len(QadDimStyles.getDimListByLayer(layer)) == 0: layerList.append(layer) result = qad_utils.getEntSel(self.getPointMapTool().toCanvasCoordinates(value), \ self.getPointMapTool(), \ layerList) if result is not None: # result[0] = feature, result[1] = layer, result[0] = point if self.setEntityInfo(True, result[1], result[0].id(), result[2]) == True: self.waitForSecondEntSel() # si appresta ad attendere la selezione del secondo oggetto return False self.waitForFirstEntSel() # si appresta ad attendere la selezione del primo oggetto else: return True # fine comando return False #========================================================================= # RISPOSTA ALLA SELEZIONE DI UNA POLILINEA (da step = 1) elif self.step == 2: 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 else: value = self.getPointMapTool().point else: # il punto arriva come parametro della funzione value = msg if type(value) == unicode: # l'opzione Radius viene tradotta in italiano in "Raggio" nel contesto "WaitForPolyline" if value == QadMsg.translate("Command_FILLET", "Radius", "WaitForPolyline") or value == "Radius": if self.GetDistClass is not None: del self.GetDistClass self.GetDistClass = QadGetDistClass(self.plugIn) prompt = QadMsg.translate("Command_FILLET", "Specify fillet radius <{0}>: ") self.GetDistClass.msg = prompt.format(str(self.radius)) self.GetDistClass.dist = self.radius self.GetDistClass.inputMode = QadInputModeEnum.NOT_NEGATIVE self.step = 5 self.GetDistClass.run(msgMapTool, msg) return False elif type(value) == QgsPoint: # se é stato selezionato un punto self.entity1.clear() self.linearObjectList1.removeAll() if self.getPointMapTool().entity.isInitialized(): if self.setEntityInfo(True, self.getPointMapTool().entity.layer, \ self.getPointMapTool().entity.featureId, value) == True: if self.filletPolyline() == False or self.multi: self.waitForFirstEntSel() # si appresta ad attendere la selezione del primo oggetto return False else: return True else: # cerco se ci sono entità nel punto indicato considerando # solo layer lineari o poligono 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 or layer.geometryType() == QGis.Polygon) and \ layer.isEditable(): if len(QadDimStyles.getDimListByLayer(layer)) == 0: layerList.append(layer) result = qad_utils.getEntSel(self.getPointMapTool().toCanvasCoordinates(value), \ self.getPointMapTool(), \ QadVariables.get(QadMsg.translate("Environment variables", "PICKBOX")), \ layerList) if result is not None: # result[0] = feature, result[1] = layer, result[0] = point if self.setEntityInfo(True, result[1], result[0].id(), result[2]) == True: if self.filletPolyline() == False or self.multi: self.waitForFirstEntSel() # si appresta ad attendere la selezione del primo oggetto return False else: return True else: return True # fine comando self.WaitForPolyline() return False #========================================================================= # RISPOSTA ALLA RICHIESTA DEL RAGGIO DI RACCORDO (da step = 1) elif self.step == 3: if self.GetDistClass.run(msgMapTool, msg) == True: if self.GetDistClass.dist is not None: self.radius = self.GetDistClass.dist QadVariables.set(QadMsg.translate("Environment variables", "FILLETRAD"), self.radius) QadVariables.save() self.waitForFirstEntSel() # si appresta ad attendere la selezione del primo oggetto self.getPointMapTool().refreshSnapType() # aggiorno lo snapType che può essere variato dal maptool di distanza return False # fine comando #========================================================================= # RISPOSTA ALLA RICHIESTA DELLA MODALITA' DI TAGLIO (da step = 1) 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 value = self.filletMode else: self.setMapTool(self.getPointMapTool()) # riattivo il maptool return False else: value = self.getPointMapTool().point else: # il punto arriva come parametro della funzione value = msg if type(value) == unicode: if value == QadMsg.translate("Command_FILLET", "Trim-extend") or value == "Trim-extend": self.filletMode = 1 elif value == QadMsg.translate("Command_FILLET", "No trim-extend") or value == "No trim-extend": self.filletMode = 2 self.plugIn.setFilletMode(self.filletMode) self.waitForFirstEntSel() # si appresta ad attendere la selezione del primo oggetto return False #========================================================================= # RISPOSTA ALLA RICHIESTA DEL RAGGIO DI RACCORDO (da step = 3) elif self.step == 5: if self.GetDistClass.run(msgMapTool, msg) == True: if self.GetDistClass.dist is not None: self.radius = self.GetDistClass.dist QadVariables.set(QadMsg.translate("Environment variables", "FILLETRAD"), self.radius) QadVariables.save() self.WaitForPolyline() self.getPointMapTool().refreshSnapType() # aggiorno lo snapType che può essere variato dal maptool di distanza return False # fine comando #========================================================================= # RISPOSTA ALLA SELEZIONE SECONDO OGGETTO elif self.step == 6: 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 else: value = self.getPointMapTool().point else: # il punto arriva come parametro della funzione value = msg if type(value) == unicode: # l'opzione Radius viene tradotta in italiano in "RAggio" nel contesto "waitForSecondEntSel" if value == QadMsg.translate("Command_FILLET", "Radius", "waitForSecondEntSel") or value == "Radius": if self.GetDistClass is not None: del self.GetDistClass self.GetDistClass = QadGetDistClass(self.plugIn) prompt = QadMsg.translate("Command_FILLET", "Specify fillet radius <{0}>: ") self.GetDistClass.msg = prompt.format(str(self.radius)) self.GetDistClass.dist = self.radius self.GetDistClass.inputMode = QadInputModeEnum.NOT_NEGATIVE self.step = 7 self.GetDistClass.run(msgMapTool, msg) return False elif type(value) == QgsPoint: # se é stato selezionato un punto self.entity2.clear() self.linearObjectList2.removeAll() if self.getPointMapTool().entity.isInitialized(): if self.setEntityInfo(False, self.getPointMapTool().entity.layer, \ self.getPointMapTool().entity.featureId, value) == True: if self.getPointMapTool().shiftKey == True: dummyRadius = self.radius self.radius = 0 dummyFilletMode = self.filletMode self.filletMode = 1 # modalità di raccordo; 1=Taglia-estendi result = self.fillet() self.radius = dummyRadius self.filletMode = dummyFilletMode else: result = self.fillet() if result == False: self.waitForSecondEntSel() # si appresta ad attendere la selezione del secondo oggetto return False if self.multi: self.waitForFirstEntSel() # si appresta ad attendere la selezione del primo oggetto return False else: return True else: # cerco se ci sono entità nel punto indicato considerando # solo layer lineari o poligono 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 or layer.geometryType() == QGis.Polygon) and \ layer.isEditable(): if len(QadDimStyles.getDimListByLayer(layer)) == 0: layerList.append(layer) result = qad_utils.getEntSel(self.getPointMapTool().toCanvasCoordinates(value), \ self.getPointMapTool(), \ QadVariables.get(QadMsg.translate("Environment variables", "PICKBOX")), \ layerList) if result is not None: # result[0] = feature, result[1] = layer, result[0] = point if self.setEntityInfo(False, result[1], result[0].id(), result[2]) == True: if self.fillet() == False: self.waitForSecondEntSel() # si appresta ad attendere la selezione del secondo oggetto return False if self.multi: self.waitForFirstEntSel() # si appresta ad attendere la selezione del primo oggetto return False else: return True else: return True # fine comando self.waitForSecondEntSel() # si appresta ad attendere la selezione del secondo oggetto return False #========================================================================= # RISPOSTA ALLA RICHIESTA DEL RAGGIO DI RACCORDO (da step = 6) elif self.step == 7: if self.GetDistClass.run(msgMapTool, msg) == True: if self.GetDistClass.dist is not None: self.radius = self.GetDistClass.dist QadVariables.set(QadMsg.translate("Environment variables", "FILLETRAD"), self.radius) QadVariables.save() self.waitForSecondEntSel() # si appresta ad attendere la selezione del secondo oggetto self.getPointMapTool().refreshSnapType() # aggiorno lo snapType che può essere variato dal maptool di distanza return False # fine comando
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 #========================================================================= # RICHIESTA PUNTO o ENTITA' if self.step == 0: # inizio del comando # imposto il map tool self.getPointMapTool().setSelectionMode(QadGetPointSelectionModeEnum.ENTITY_SELECTION) # imposto i layer da controllare sul maptool self.getPointMapTool().layersToCheck = self.getLayersToCheck() keyWords = QadMsg.translate("Command_ENTSEL", "Last") englishKeyWords = "Last" keyWords += "_" + englishKeyWords # si appresta ad attendere un punto o enter o una parola chiave # msg, inputType, default, keyWords, nessun controllo self.waitFor(self.msg, \ QadInputTypeEnum.POINT2D | QadInputTypeEnum.KEYWORDS, \ None, \ keyWords, QadInputModeEnum.NONE) self.step = 1 return False #========================================================================= # RISPOSTA ALLA RICHIESTA PUNTO o ENTITA' elif self.step == 1: # dopo aver atteso un punto si riavvia il comando entity = None 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 if self.getPointMapTool().entity.isInitialized(): entity = self.getPointMapTool().entity else: # il punto arriva come parametro della funzione value = msg if value is None: return True # fine comando if type(value) == unicode: if value == QadMsg.translate("Command_ENTSEL", "Last") or value == "Last": # Seleziona l'ultima entità inserita lastEnt = self.plugIn.getLastEntity() if lastEnt is not None: # controllo sul layer if self.onlyEditableLayers == False or lastEnt.layer.isEditable() == True: # controllo sul tipo if (self.checkPointLayer == True and lastEnt.layer.geometryType() == QGis.Point) or \ (self.checkLineLayer == True and lastEnt.layer.geometryType() == QGis.Line) or \ (self.checkPolygonLayer == True and lastEnt.layer.geometryType() == QGis.Polygon): # controllo su layer delle quotature if self.checkDimLayers == True or lastEnt.isDimensionComponent() == False: self.setEntity(lastEnt.layer, lastEnt.featureId) elif type(value) == QgsPoint: if entity is None: # cerco se ci sono entità nel punto indicato result = qad_utils.getEntSel(self.getPointMapTool().toCanvasCoordinates(value), self.getPointMapTool(), \ self.getLayersToCheck()) if result is not None: feature = result[0] layer = result[1] self.setEntity(layer, feature.id()) else: self.setEntity(entity.layer, entity.featureId) self.point = value return True # fine comando
def canvasMoveEvent(self, event): self.tmpPoint = self.toMapCoordinates(event.pos()) self.tmpEntity.clear() self.__csrRubberBand.moveEvent(self.tmpPoint) # se l'obiettivo é selezionare un'entità in modo dinamico if self.getSelectionMode() == QadGetPointSelectionModeEnum.ENTITY_SELECTION_DYNAMIC: result = qad_utils.getEntSel(event.pos(), self, \ self.layersToCheck, \ self.checkPointLayer, \ self.checkLineLayer, \ self.checkPolygonLayer, \ True, self.onlyEditableLayers) # se l'obiettivo é selezionare un punto elif self.getSelectionMode() == QadGetPointSelectionModeEnum.POINT_SELECTION: result = qad_utils.getEntSel(event.pos(), self, \ None, \ self.__geometryTypesAccordingToSnapType[0], \ self.__geometryTypesAccordingToSnapType[1], \ self.__geometryTypesAccordingToSnapType[2], \ True, \ self.onlyEditableLayers) else: result = None if result is not None: feature = result[0] layer = result[1] self.tmpEntity.set(layer, feature.id()) geometry = feature.geometry() point = self.toLayerCoordinates(layer, event.pos()) # se é stata selezionata una geometria diversa da quella selezionata precedentemente if (self.__prevGeom is None) or not self.__prevGeom.equals(geometry): self.__prevGeom = QgsGeometry(geometry) runToggleReferenceLines = lambda: self.toggleReferenceLines(self.__prevGeom, point, layer.crs()) self.__stopTimer = False self.__timer.singleShot(500, runToggleReferenceLines) oSnapPoints = self.__QadSnapper.getSnapPoint(geometry, point, \ layer.crs(), \ None, \ self.__PolarAng) # se l'obiettivo é selezionare un punto elif self.getSelectionMode() == QadGetPointSelectionModeEnum.POINT_SELECTION: # se non é stata trovato alcun oggetto allora verifico se una geometria di tmpGeometries rientra nel pickbox tmpGeometry = qad_utils.getGeomInPickBox(event.pos(), self, \ self.tmpGeometries, \ None, \ self.__geometryTypesAccordingToSnapType[0], \ self.__geometryTypesAccordingToSnapType[1], \ self.__geometryTypesAccordingToSnapType[2], \ True) if tmpGeometry is not None: # se é stata selezionata una geometria diversa da quella selezionata precedentemente if (self.__prevGeom is None) or not self.__prevGeom.equals(tmpGeometry): self.__prevGeom = QgsGeometry(tmpGeometry) runToggleReferenceLines = lambda: self.toggleReferenceLines(self.__prevGeom, self.tmpPoint, \ self.canvas.mapRenderer().destinationCrs()) self.__stopTimer = False self.__timer.singleShot(500, runToggleReferenceLines) self.__QadSnapper.clearCacheSnapPoints() # pulisco la cache perché tmpGeometry può essere variato oSnapPoints = self.__QadSnapper.getSnapPoint(tmpGeometry, self.tmpPoint, \ self.canvas.mapRenderer().destinationCrs(), \ None, \ self.__PolarAng, True) else: oSnapPoints = self.__QadSnapper.getSnapPoint(None, self.tmpPoint, \ self.canvas.mapRenderer().destinationCrs(), \ None, \ self.__PolarAng) self.__prevGeom = None self.__stopTimer = True oSnapPoint = None # se l'obiettivo é selezionare un punto if self.getSelectionMode() == QadGetPointSelectionModeEnum.POINT_SELECTION: # visualizzo il punto di snap self.__QadSnapPointsDisplayManager.show(oSnapPoints, \ self.__QadSnapper.getExtLines(), \ self.__QadSnapper.getExtArcs(), \ self.__QadSnapper.getParLines(), \ self.__QadSnapper.getIntExtLine(), \ self.__QadSnapper.getIntExtArc()) self.point = None self.tmpPoint = None # memorizzo il punto di snap in point (prendo il primo valido) for item in oSnapPoints.items(): points = item[1] if points is not None: self.tmpPoint = points[0] oSnapPoint = points[0] break if self.tmpPoint is None: self.tmpPoint = self.toMapCoordinates(event.pos()) # tasto shift premuto durante il movimento del mouse self.tmpShiftKey = True if event.modifiers() & Qt.ShiftModifier else False if self.__RubberBand is not None: if oSnapPoint is None: if self.__startPoint is not None: # c'é un punto di partenza if self.tmpShiftKey == False: # se non è premuto shift if self.__OrthoMode == 1: # orto attivato self.tmpPoint = self.getOrthoCoord(self.tmpPoint) else: # se non è premuto shift devo fare il toggle di ortho if self.__OrthoMode == 0: # se orto disattivato lo attivo temporaneamente self.tmpPoint = self.getOrthoCoord(self.tmpPoint) if self.getDrawMode() != QadGetPointDrawModeEnum.NONE: # previsto uso della linea elastica o rettangolo elastico self.moveElastic(self.tmpPoint)
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 PUNTO o ENTITA' if self.step == 0: # inizio del comando # imposto il map tool self.getPointMapTool().setSelectionMode(QadGetPointSelectionModeEnum.ENTITY_SELECTION) # imposto i layer da controllare sul maptool self.getPointMapTool().layersToCheck = self.getLayersToCheck() keyWords = QadMsg.translate("Command_ENTSEL", "Last") englishKeyWords = "Last" keyWords += "_" + englishKeyWords # si appresta ad attendere un punto o enter o una parola chiave # msg, inputType, default, keyWords, nessun controllo self.waitFor(self.msg, \ QadInputTypeEnum.POINT2D | QadInputTypeEnum.KEYWORDS, \ None, \ keyWords, QadInputModeEnum.NONE) self.step = 1 return False #========================================================================= # RISPOSTA ALLA RICHIESTA PUNTO o ENTITA' elif self.step == 1: # dopo aver atteso un punto si riavvia il comando entity = None 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 self.canceledByUsr = True return True # fine comando else: self.setMapTool(self.getPointMapTool()) # riattivo il maptool return False value = self.getPointMapTool().point if self.getPointMapTool().entity.isInitialized(): entity = self.getPointMapTool().entity else: # il punto arriva come parametro della funzione value = msg if value is None: self.canceledByUsr = True return True # fine comando if type(value) == unicode: if value == QadMsg.translate("Command_ENTSEL", "Last") or value == "Last": # Seleziona l'ultima entità inserita lastEnt = self.plugIn.getLastEntity() if lastEnt is not None: # controllo sul layer if self.onlyEditableLayers == False or lastEnt.layer.isEditable() == True: # controllo sul tipo if (self.checkPointLayer == True and lastEnt.layer.geometryType() == QGis.Point) or \ (self.checkLineLayer == True and lastEnt.layer.geometryType() == QGis.Line) or \ (self.checkPolygonLayer == True and lastEnt.layer.geometryType() == QGis.Polygon): # controllo su layer delle quotature if self.checkDimLayers == True or lastEnt.isDimensionComponent() == False: self.setEntity(lastEnt.layer, lastEnt.featureId) elif type(value) == QgsPoint: if entity is None: # cerco se ci sono entità nel punto indicato result = qad_utils.getEntSel(self.getPointMapTool().toCanvasCoordinates(value), self.getPointMapTool(), \ QadVariables.get(QadMsg.translate("Environment variables", "PICKBOX")), \ self.getLayersToCheck()) if result is not None: feature = result[0] layer = result[1] self.setEntity(layer, feature.id()) else: self.setEntity(entity.layer, entity.featureId) self.point = value if self.deselectOnFinish: self.entity.deselectOnLayer() return True # fine comando
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 #========================================================================= # RICHIESTA SELEZIONE OGGETTO if self.step == 0: # inizio del comando # si appresta ad attendere la selezione degli oggetti da estendere/tagliare self.waitForObjectSelToMisure() return False #========================================================================= # RISPOSTA ALLA SELEZIONE OGGETTI DA MISURARE elif self.step == 1: 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 = self.defaultValue else: self.setMapTool(self.getPointMapTool()) # riattivo il maptool return False else: value = self.getPointMapTool().point else: # il punto arriva come parametro della funzione value = msg if type(value) == unicode: if value == QadMsg.translate("Command_LENGTHEN", "DElta") or value == "DElta": self.waitForDelta() return False elif value == QadMsg.translate("Command_LENGTHEN", "Percent") or value == "Percent": self.waitForPercent() return False elif value == QadMsg.translate("Command_LENGTHEN", "Total") or value == "Total": self.waitForTotal() return False elif value == QadMsg.translate("Command_LENGTHEN", "DYnamic") or value == "DYnamic": self.OpMode = "DYnamic" self.plugIn.setLastOpMode_lengthen(self.OpMode) # si appresta ad attendere la selezione degli oggetti da allungare self.waitForObjectSel() return False elif type(value) == QgsPoint: # se é stato selezionato un punto if self.getPointMapTool().entity.isInitialized(): self.showLength(self.getPointMapTool().entity, value) else: # cerco se ci sono entità nel punto indicato considerando # solo layer di tipo lineari che non appartengano a quote o di tipo poligono layerList = [] for layer in qad_utils.getVisibleVectorLayers(self.plugIn.canvas): # Tutti i layer vettoriali visibili if layer.geometryType() == QGis.Line or layer.geometryType() == QGis.Polygon: if len(QadDimStyles.getDimListByLayer(layer)) == 0: layerList.append(layer) result = qad_utils.getEntSel(self.getPointMapTool().toCanvasCoordinates(value), \ self.getPointMapTool(), \ QadVariables.get(QadMsg.translate("Environment variables", "PICKBOX")), \ layerList) if result is not None: feature = result[0] layer = result[1] self.showLength(QadEntity().set(layer, feature.id()), value) else: return True # fine comando # si appresta ad attendere la selezione degli oggetti da misurare self.waitForObjectSelToMisure() return False #========================================================================= # RISPOSTA ALLA RICHIESTA DEL DELTA (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 value = self.plugIn.lastDelta_lengthen # opzione di default "spostamento" else: self.setMapTool(self.getPointMapTool()) # riattivo il maptool return False else: value = self.getPointMapTool().point else: # il punto arriva come parametro della funzione value = msg if type(value) == unicode: if value == QadMsg.translate("Command_LENGTHEN", "Angle") or value == "Angle": self.waitForDeltaAngle(msgMapTool, msg) elif type(value) == QgsPoint: # se é stato inserito un punto self.startPt = value self.waitForDeltaLength(msgMapTool, msg) elif type(value) == float: # se é stato inserito il delta self.plugIn.setLastDelta_lengthen(value) self.OpType = "length" self.value = value # si appresta ad attendere la selezione degli oggetti da allungare self.waitForObjectSel() return False #========================================================================= # RISPOSTA ALLA RICHIESTA DELLA LUNGHEZZA DEL DELTA (da step = 2) elif self.step == 3: # dopo aver atteso un punto o un numero reale si riavvia il comando if self.GetDistClass.run(msgMapTool, msg) == True: if self.GetDistClass.dist is not None: self.plugIn.setLastDelta_lengthen(self.GetDistClass.dist) self.value = self.GetDistClass.dist # si appresta ad attendere la selezione degli oggetti da allungare self.waitForObjectSel() #========================================================================= # RISPOSTA ALLA RICHIESTA DELL'ANGOLO DEL DELTA (da step = 2) elif self.step == 4: # dopo aver atteso un punto o un numero reale si riavvia il comando if self.GetAngleClass.run(msgMapTool, msg) == True: if self.GetAngleClass.angle is not None: self.plugIn.setLastDeltaAngle_lengthen(self.GetAngleClass.angle) self.value = self.GetAngleClass.angle # si appresta ad attendere la selezione degli oggetti da allungare self.waitForObjectSel() #========================================================================= # RISPOSTA ALLA SELEZIONE OGGETTI DA ALLUNGARE elif self.step == 5: 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 else: value = self.getPointMapTool().point else: # il punto arriva come parametro della funzione value = msg if type(value) == unicode: if value == QadMsg.translate("Command_LENGTHEN", "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.")) elif type(value) == QgsPoint: # se é stato selezionato un punto if self.getPointMapTool().entity.isInitialized(): self.setInfo(self.getPointMapTool().entity, value) if self.OpMode != "DYnamic": self.lengthen(value) else: self.waitForDynamicPt() return False else: # cerco se ci sono entità nel punto indicato considerando # 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) result = qad_utils.getEntSel(self.getPointMapTool().toCanvasCoordinates(value), \ self.getPointMapTool(), \ QadVariables.get(QadMsg.translate("Environment variables", "PICKBOX")), \ layerList) if result is not None: feature = result[0] layer = result[1] self.setInfo(QadEntity().set(layer, feature.id()), value) if self.OpMode != "DYnamic": self.lengthen(value) else: self.waitForDynamicPt() return False else: return True # fine comando # si appresta ad attendere la selezione degli oggetti da allungare self.waitForObjectSel() return False #========================================================================= # RISPOSTA ALLA RICHIESTA PERCENTUALE (da step = 1) elif self.step == 6: # dopo aver atteso 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 value = self.plugIn.lastPerc_lengthen else: self.setMapTool(self.getPointMapTool()) # riattivo il maptool return False else: return False else: # il punto arriva come parametro della funzione value = msg if type(value) == float: # é stata inserita la percentuale self.plugIn.setLastPerc_lengthen(value) self.value = value # si appresta ad attendere la selezione degli oggetti da allungare self.waitForObjectSel() return False #========================================================================= # RISPOSTA ALLA RICHIESTA DEL TOTALE (da step = 1) elif self.step == 7: # 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 value = self.plugIn.lastTotal_lengthen else: self.setMapTool(self.getPointMapTool()) # riattivo il maptool return False else: value = self.getPointMapTool().point else: # il punto arriva come parametro della funzione value = msg if type(value) == unicode: if value == QadMsg.translate("Command_LENGTHEN", "Angle") or value == "Angle": self.waitForTotalAngle(msgMapTool, msg) elif type(value) == QgsPoint: # se é stato inserito un punto self.startPt = value self.waitForTotalLength(msgMapTool, msg) elif type(value) == float: # se é stato inserito il delta self.plugIn.setLastTotal_lengthen(value) self.OpType = "length" self.value = value # si appresta ad attendere la selezione degli oggetti da allungare self.waitForObjectSel() return False #========================================================================= # RISPOSTA ALLA RICHIESTA DELLA LUNGHEZZA DEL TOTALE (da step = 7) elif self.step == 8: # dopo aver atteso un punto o un numero reale si riavvia il comando if self.GetDistClass.run(msgMapTool, msg) == True: if self.GetDistClass.dist is not None: self.plugIn.setLastTotal_lengthen(self.GetDistClass.dist) self.value = self.GetDistClass.dist # si appresta ad attendere la selezione degli oggetti da allungare self.waitForObjectSel() return False #========================================================================= # RISPOSTA ALLA RICHIESTA DELL'ANGOLO DEL DELTA (da step = 7) elif self.step == 9: # dopo aver atteso un punto o un numero reale si riavvia il comando if self.GetAngleClass.run(msgMapTool, msg) == True: if self.GetAngleClass.angle is not None: self.plugIn.setLastTotalAngle_lengthen(self.GetAngleClass.angle) self.value = self.GetAngleClass.angle # si appresta ad attendere la selezione degli oggetti da allungare self.waitForObjectSel() return False #========================================================================= # RISPOSTA ALLA RICHIESTA DELLA NUOVA ESTREMITA' IN MODO DINAMICO (da step = 5) elif self.step == 10: # 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 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 un punto self.lengthen(value) # si appresta ad attendere la selezione degli oggetti da allungare self.waitForObjectSel() return False