def elaborateSelSet(self, selSet, shiftKey): if self.checkDimLayers == True: dimEntitySet = QadEntitySet(selSet) # La funzione verifica se le entità che fanno parte di un entitySet sono anche parte di quotatura e, # in caso affermativo, aggiunge tutti i componenti delle quotature all'entitySet. QadDimStyles.addAllDimComponentsToEntitySet(dimEntitySet, self.onlyEditableLayers) selSet.unite(dimEntitySet) if self.AddOnSelection == True: # aggiungi al gruppo di selezione if shiftKey: # se la selezione é avvenuta con shift premuto if self.pickAdd == 0: # The objects most recently selected become the selection set # verifico se ci sono degli oggetti non ancora selezionati intersectSS = QadEntitySet(selSet) intersectSS.subtract(self.entitySet) if intersectSS.isEmpty(): # tutti gli oggetti erano già selezionati self.AddRemoveSelSet(selSet, False) # rimuovo il gruppo di selezione else: self.AddRemoveSelSet(selSet, True) # aggiungo il gruppo di selezione else: self.AddRemoveSelSet(selSet, False) # rimuovo il gruppo di selezione else: # senza tasto shift if self.pickAdd == 0: # The objects most recently selected become the selection set self.SetSelSet(selSet) else: self.AddRemoveSelSet(selSet, True) # aggiungo il gruppo di selezione else: # se si deve rimuovere dal gruppo di selezione self.AddRemoveEntity(selSet, False) # rimuovo il gruppo di selezione
def setMode(self, mode): self.mode = mode # si richiede la selezione dell'oggetto da misurare if self.mode == Qad_lengthen_maptool_ModeEnum.ASK_FOR_OBJ_TO_MISURE: self.setSelectionMode( QadGetPointSelectionModeEnum.ENTITY_SELECTION) # 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) self.layersToCheck = layerList self.onlyEditableLayers = False self.setSnapType(QadSnapTypeEnum.DISABLE) # si richiede il delta elif self.mode == Qad_lengthen_maptool_ModeEnum.ASK_FOR_DELTA: self.OpMode = "DElta" self.setSelectionMode(QadGetPointSelectionModeEnum.POINT_SELECTION) # non si richiede niente elif self.mode == Qad_lengthen_maptool_ModeEnum.NONE: self.setSelectionMode(QadGetPointSelectionModeEnum.POINT_SELECTION) # si richiede la selezione dell'oggetto da allungare elif self.mode == Qad_lengthen_maptool_ModeEnum.ASK_FOR_OBJ_TO_LENGTHEN: self.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.layersToCheck = layerList self.onlyEditableLayers = True self.setSnapType(QadSnapTypeEnum.DISABLE) # si richiede la percentuale elif self.mode == Qad_lengthen_maptool_ModeEnum.ASK_FOR_PERCENT: self.setSelectionMode(QadGetPointSelectionModeEnum.POINT_SELECTION) self.OpMode = "Percent" # si richiede il totale elif self.mode == Qad_lengthen_maptool_ModeEnum.ASK_FOR_TOTAL: self.OpMode = "Total" self.setSelectionMode(QadGetPointSelectionModeEnum.POINT_SELECTION) # si richiede il nuovo punto dell'estremità in modalità dinamica elif self.mode == Qad_lengthen_maptool_ModeEnum.ASK_FOR_DYNAMIC_POINT: self.OpMode = "DYnamic" self.setSelectionMode(QadGetPointSelectionModeEnum.POINT_SELECTION)
def setMode(self, mode): self.mode = mode # si richiede la selezione dell'oggetto da misurare if self.mode == Qad_lengthen_maptool_ModeEnum.ASK_FOR_OBJ_TO_MISURE: self.setSelectionMode(QadGetPointSelectionModeEnum.ENTITY_SELECTION) # 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) self.layersToCheck = layerList self.onlyEditableLayers = False self.setSnapType(QadSnapTypeEnum.DISABLE) # si richiede il delta elif self.mode == Qad_lengthen_maptool_ModeEnum.ASK_FOR_DELTA: self.OpMode = "DElta" self.setSelectionMode(QadGetPointSelectionModeEnum.POINT_SELECTION) # non si richiede niente elif self.mode == Qad_lengthen_maptool_ModeEnum.NONE: self.setSelectionMode(QadGetPointSelectionModeEnum.POINT_SELECTION) # si richiede la selezione dell'oggetto da allungare elif self.mode == Qad_lengthen_maptool_ModeEnum.ASK_FOR_OBJ_TO_LENGTHEN: self.setSelectionMode(QadGetPointSelectionModeEnum.ENTITY_SELECTION_DYNAMIC) # 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) self.layersToCheck = layerList self.onlyEditableLayers = True self.setSnapType(QadSnapTypeEnum.DISABLE) # si richiede la percentuale elif self.mode == Qad_lengthen_maptool_ModeEnum.ASK_FOR_PERCENT: self.setSelectionMode(QadGetPointSelectionModeEnum.POINT_SELECTION) self.OpMode = "Percent" # si richiede il totale elif self.mode == Qad_lengthen_maptool_ModeEnum.ASK_FOR_TOTAL: self.OpMode = "Total" self.setSelectionMode(QadGetPointSelectionModeEnum.POINT_SELECTION) # si richiede il nuovo punto dell'estremità in modalità dinamica elif self.mode == Qad_lengthen_maptool_ModeEnum.ASK_FOR_DYNAMIC_POINT: self.OpMode = "DYnamic" self.setSelectionMode(QadGetPointSelectionModeEnum.POINT_SELECTION)
def SetEntity(self, entity): # controllo sul layer if self.onlyEditableLayers == True and entity.layer.isEditable() == False: self.showMsgOnAddRemove(0) return # controllo sul tipo if (self.checkPointLayer == False and entity.layer.geometryType() == QGis.Point) or \ (self.checkLineLayer == False and entity.layer.geometryType() == QGis.Line) or \ (self.checkPolygonLayer == False and entity.layer.geometryType() == QGis.Polygon): self.showMsgOnAddRemove(0) return # controllo su layer delle quotature # verifico se l'entità appartiene ad uno stile di quotatura dimEntity = QadDimStyles.getDimEntity(entity) if self.checkDimLayers == False and dimEntity is not None: self.showMsgOnAddRemove(0) return self.entitySet.deselectOnLayer() self.entitySet.clear() self.entitySet.addEntity(entity) if self.checkDimLayers == True and dimEntity is not None: # Aggiungo i componenenti della quotatura a set <entitySet> self.entitySet.unite(dimEntity.getEntitySet()) self.showMsgOnAddRemove(self.entitySet.count()) self.entitySet.selectOnLayer(False) # incremental = False aaaaaaaaaaaaaaaaaaaaaaaaaa qui parte l'evento activate di qad_maptool (se il layer non è in modifica) self.lastEntitySet.clear() self.lastEntitySet.addEntity(entity)
def SetEntity(self, entity): # controllo sul layer if self.onlyEditableLayers == True and entity.layer.isEditable() == False: self.showMsgOnAddRemove(0) return # controllo sul tipo if (self.checkPointLayer == False and entity.layer.geometryType() == QGis.Point) or \ (self.checkLineLayer == False and entity.layer.geometryType() == QGis.Line) or \ (self.checkPolygonLayer == False and entity.layer.geometryType() == QGis.Polygon): self.showMsgOnAddRemove(0) return # controllo su layer delle quotature # verifico se l'entità appartiene ad uno stile di quotatura dimEntity = QadDimStyles.getDimEntity(entity) if self.checkDimLayers == False and dimEntity is not None: self.showMsgOnAddRemove(0) return self.entitySet.deselectOnLayer() self.entitySet.clear() self.entitySet.addEntity(entity) if self.checkDimLayers == True and dimEntity is not None: # Aggiungo i componenenti della quotatura a set <entitySet> self.entitySet.unite(dimEntity.getEntitySet()) self.showMsgOnAddRemove(self.entitySet.count()) self.entitySet.selectOnLayer(False) # incremental = False aaaaaaaaaaaaaaaaaaaaaaaaaa qui parte l'evento activate di qad_maptool self.lastEntitySet.clear() self.lastEntitySet.addEntity(entity)
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 setMode(self, mode): self.mode = mode # si richiede la selezione del primo oggetto # si richiede la selezione del secondo oggetto if self.mode == Qad_fillet_maptool_ModeEnum.ASK_FOR_FIRST_LINESTRING or \ self.mode == Qad_fillet_maptool_ModeEnum.ASK_FOR_SECOND_LINESTRING: if self.mode == Qad_fillet_maptool_ModeEnum.ASK_FOR_FIRST_LINESTRING: self.setSelectionMode( QadGetPointSelectionModeEnum.ENTITY_SELECTION) else: self.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.layersToCheck = layerList self.setSnapType(QadSnapTypeEnum.DISABLE) # non si richiede niente elif self.mode == Qad_fillet_maptool_ModeEnum.NONE: self.setSelectionMode(QadGetPointSelectionModeEnum.POINT_SELECTION) self.setDrawMode(QadGetPointDrawModeEnum.NONE) # si richiede la selezione della polilinea elif self.mode == Qad_fillet_maptool_ModeEnum.ASK_FOR_POLYLINE: self.setSelectionMode( QadGetPointSelectionModeEnum.ENTITY_SELECTION_DYNAMIC) # 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) self.layersToCheck = layerList self.setSnapType(QadSnapTypeEnum.DISABLE)
def setMode(self, mode): self.mode = mode # si richiede la selezione di un'entità if self.mode == Qad_pedit_maptool_ModeEnum.ASK_FOR_ENTITY_SEL: self.setSelectionMode( QadGetPointSelectionModeEnum.ENTITY_SELECTION) # 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) self.layersToCheck = layerList self.setSnapType(QadSnapTypeEnum.DISABLE) # non si richiede niente elif self.mode == Qad_pedit_maptool_ModeEnum.NONE: self.setSelectionMode(QadGetPointSelectionModeEnum.POINT_SELECTION) self.setDrawMode(QadGetPointDrawModeEnum.NONE) # si richiede il primo punto per calcolo distanza di approssimazione # si richiede la posizione più vicina ad un vertice elif self.mode == Qad_pedit_maptool_ModeEnum.ASK_FOR_FIRST_TOLERANCE_PT: self.onlyEditableLayers = False self.checkPointLayer = True self.checkLineLayer = True self.checkPolygonLayer = True self.setSnapType() self.setSelectionMode(QadGetPointSelectionModeEnum.POINT_SELECTION) self.setDrawMode(QadGetPointDrawModeEnum.NONE) # noto il primo punto per calcolo distanza di approssimazione si richiede il secondo punto elif self.mode == Qad_pedit_maptool_ModeEnum.FIRST_TOLERANCE_PT_KNOWN_ASK_FOR_SECOND_PT or \ self.mode == Qad_pedit_maptool_ModeEnum.ASK_FOR_NEW_VERTEX or \ self.mode == Qad_pedit_maptool_ModeEnum.ASK_FOR_MOVE_VERTEX: self.onlyEditableLayers = False self.checkPointLayer = True self.checkLineLayer = True self.checkPolygonLayer = True self.setSnapType() self.setSelectionMode(QadGetPointSelectionModeEnum.POINT_SELECTION) self.setDrawMode(QadGetPointDrawModeEnum.ELASTIC_LINE) self.setStartPoint(self.firstPt) # si richiede la posizione più vicina ad un vertice elif self.mode == Qad_pedit_maptool_ModeEnum.ASK_FOR_VERTEX: self.setSnapType(QadSnapTypeEnum.DISABLE) self.setSelectionMode(QadGetPointSelectionModeEnum.POINT_SELECTION) self.setDrawMode(QadGetPointDrawModeEnum.NONE) # si richede il punto base (grip mode) elif self.mode == Qad_pedit_maptool_ModeEnum.ASK_FOR_BASE_PT: self.setSnapType() self.setSelectionMode(QadGetPointSelectionModeEnum.POINT_SELECTION) self.setDrawMode(QadGetPointDrawModeEnum.NONE)
def SetSelSet(self, selSet): for layerEntitySet in self.entitySet.layerEntitySetList: # se il layer non é presente in selSet if selSet.findLayerEntitySet(layerEntitySet) is None: layerEntitySet.deselectOnLayer() else: layerEntitySet.deselectOnLayer() self.entitySet.set(selSet) if self.checkDimLayers == True: dimEntitySet = QadEntitySet(selSet) # La funzione verifica se le entità che fanno parte di un entitySet sono anche parte di quotatura e, # in caso affermativo, aggiunge tutti i componenti delle quotature all'entitySet. QadDimStyles.addAllDimComponentsToEntitySet(dimEntitySet, self.onlyEditableLayers) self.entitySet.unite(dimEntitySet) self.showMsgOnAddRemove(self.entitySet.count()) self.entitySet.selectOnLayer(False) # incremental = False self.lastEntitySet.set(selSet)
def setMode(self, mode): self.mode = mode # si richiede la selezione di un'entità if self.mode == Qad_pedit_maptool_ModeEnum.ASK_FOR_ENTITY_SEL: self.setSelectionMode(QadGetPointSelectionModeEnum.ENTITY_SELECTION) # solo layer lineari o poligono editabili che non appartengano a quote layerList = [] for layer in self.plugIn.canvas.layers(): if layer.type() == QgsMapLayer.VectorLayer and \ (layer.geometryType() == QGis.Line or layer.geometryType() == QGis.Polygon) and \ layer.isEditable(): if len(QadDimStyles.getDimListByLayer(layer)) == 0: layerList.append(layer) self.layersToCheck = layerList self.setSnapType(QadSnapTypeEnum.DISABLE) # non si richiede niente elif self.mode == Qad_pedit_maptool_ModeEnum.NONE: self.setSelectionMode(QadGetPointSelectionModeEnum.POINT_SELECTION) self.setDrawMode(QadGetPointDrawModeEnum.NONE) # si richiede il primo punto per calcolo distanza di approssimazione # si richiede la posizione più vicina ad un vertice elif self.mode == Qad_pedit_maptool_ModeEnum.ASK_FOR_FIRST_TOLERANCE_PT: self.onlyEditableLayers = False self.checkPointLayer = True self.checkLineLayer = True self.checkPolygonLayer = True self.setSnapType() self.setSelectionMode(QadGetPointSelectionModeEnum.POINT_SELECTION) self.setDrawMode(QadGetPointDrawModeEnum.NONE) # noto il primo punto per calcolo distanza di approssimazione si richiede il secondo punto elif self.mode == Qad_pedit_maptool_ModeEnum.FIRST_TOLERANCE_PT_KNOWN_ASK_FOR_SECOND_PT or \ self.mode == Qad_pedit_maptool_ModeEnum.ASK_FOR_NEW_VERTEX or \ self.mode == Qad_pedit_maptool_ModeEnum.ASK_FOR_MOVE_VERTEX: self.onlyEditableLayers = False self.checkPointLayer = True self.checkLineLayer = True self.checkPolygonLayer = True self.setSnapType() self.setSelectionMode(QadGetPointSelectionModeEnum.POINT_SELECTION) self.setDrawMode(QadGetPointDrawModeEnum.ELASTIC_LINE) self.setStartPoint(self.firstPt) # si richiede la posizione più vicina ad un vertice elif self.mode == Qad_pedit_maptool_ModeEnum.ASK_FOR_VERTEX: self.setSnapType(QadSnapTypeEnum.DISABLE) self.setSelectionMode(QadGetPointSelectionModeEnum.POINT_SELECTION) self.setDrawMode(QadGetPointDrawModeEnum.NONE) # si richede il punto base (grip mode) elif self.mode == Qad_pedit_maptool_ModeEnum.ASK_FOR_BASE_PT: self.setSnapType() self.setSelectionMode(QadGetPointSelectionModeEnum.POINT_SELECTION) self.setDrawMode(QadGetPointDrawModeEnum.NONE)
def setMode(self, mode): self.mode = mode # si richiede la selezione del primo oggetto # si richiede la selezione del secondo oggetto if self.mode == Qad_fillet_maptool_ModeEnum.ASK_FOR_FIRST_LINESTRING or \ self.mode == Qad_fillet_maptool_ModeEnum.ASK_FOR_SECOND_LINESTRING: if self.mode == Qad_fillet_maptool_ModeEnum.ASK_FOR_FIRST_LINESTRING: self.setSelectionMode(QadGetPointSelectionModeEnum.ENTITY_SELECTION) else: self.setSelectionMode(QadGetPointSelectionModeEnum.ENTITY_SELECTION_DYNAMIC) # 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) self.layersToCheck = layerList self.setSnapType(QadSnapTypeEnum.DISABLE) # non si richiede niente elif self.mode == Qad_fillet_maptool_ModeEnum.NONE: self.setSelectionMode(QadGetPointSelectionModeEnum.POINT_SELECTION) self.setDrawMode(QadGetPointDrawModeEnum.NONE) # si richiede la selezione della polilinea elif self.mode == Qad_fillet_maptool_ModeEnum.ASK_FOR_POLYLINE: self.setSelectionMode(QadGetPointSelectionModeEnum.ENTITY_SELECTION_DYNAMIC) # solo layer lineari o poligono editabili che non appartengano a quote layerList = [] for layer in self.plugIn.canvas.layers(): if layer.type() == QgsMapLayer.VectorLayer and \ (layer.geometryType() == QGis.Line or layer.geometryType() == QGis.Polygon) and \ layer.isEditable(): if len(QadDimStyles.getDimListByLayer(layer)) == 0: layerList.append(layer) self.layersToCheck = layerList self.setSnapType(QadSnapTypeEnum.DISABLE)
def AddRemoveEntity(self, entity, Add): # controllo sul layer if self.onlyEditableLayers == True and entity.layer.isEditable() == False: self.showMsgOnAddRemove(0) return # controllo sul tipo if (self.checkPointLayer == False and entity.layer.geometryType() == QGis.Point) or \ (self.checkLineLayer == False and entity.layer.geometryType() == QGis.Line) or \ (self.checkPolygonLayer == False and entity.layer.geometryType() == QGis.Polygon): self.showMsgOnAddRemove(0) return # controllo su layer delle quotature if self.checkDimLayers == False and len(QadDimStyles.getDimListByLayer(entity.layer)) > 0: self.showMsgOnAddRemove(0) return self.entitySet.deselectOnLayer() if Add == True: # aggiungi al gruppo di selezione self.entitySet.addEntity(entity) else: # rimuovi dal gruppo di selezione self.entitySet.removeEntity(entity) if self.checkDimLayers == True: dimEntitySet = QadEntitySet() dimEntitySet.addEntity(entity) # La funzione verifica se le entità che fanno parte di un entitySet sono anche parte di quotatura e, # in caso affermativo, aggiunge/rimuove tutti i componenti delle quotature all'entitySet. QadDimStyles.addAllDimComponentsToEntitySet(dimEntitySet, self.onlyEditableLayers) if Add == True: # aggiungi al gruppo di selezione self.entitySet.unite(dimEntitySet) else: # rimuovi dal gruppo di selezione self.entitySet.subtract(dimEntitySet) self.showMsgOnAddRemove(dimEntitySet.count()) else: self.showMsgOnAddRemove(1) self.entitySet.selectOnLayer(False) # incremental = False self.lastEntitySet.clear() self.lastEntitySet.addEntity(entity)
def setEntity(self, layer, fid): del self.entity if self.selDimEntity: # se è possibile restituire un oggetto QadDimEntity # verifico se l'entità appartiene ad uno stile di quotatura self.entity = QadDimStyles.getDimEntity(layer, fid) if self.entity is None: # se non è una quota self.entity = QadEntity() self.entity.set(layer, fid) else: self.entity = QadEntity() self.entity.set(layer, fid) self.entity.selectOnLayer()
def getLayersToCheck(self): layerList = [] for layer in qad_utils.getVisibleVectorLayers(self.plugIn.canvas): # Tutti i layer vettoriali visibili # considero solo i layer vettoriali che sono filtrati per tipo if ((layer.geometryType() == QGis.Point and self.checkPointLayer == True) or \ (layer.geometryType() == QGis.Line and self.checkLineLayer == True) or \ (layer.geometryType() == QGis.Polygon and self.checkPolygonLayer == True)) and \ (self.onlyEditableLayers == False or layer.isEditable()): # se devo includere i layers delle quotature if self.checkDimLayers == True or \ len(QadDimStyles.getDimListByLayer(layer)) == 0: layerList.append(layer) return layerList
def setMode(self, mode): self.clear() self.mode = mode # si richiede il primo punto per calcolo offset if self.mode == Qad_offset_maptool_ModeEnum.ASK_FOR_FIRST_OFFSET_PT: self.setSelectionMode(QadGetPointSelectionModeEnum.POINT_SELECTION) self.setDrawMode(QadGetPointDrawModeEnum.NONE) self.onlyEditableLayers = False # noto il primo punto per calcolo offset si richiede il secondo punto if self.mode == Qad_offset_maptool_ModeEnum.FIRST_OFFSET_PT_KNOWN_ASK_FOR_SECOND_PT: self.setSelectionMode(QadGetPointSelectionModeEnum.POINT_SELECTION) self.setDrawMode(QadGetPointDrawModeEnum.ELASTIC_LINE) self.setStartPoint(self.firstPt) self.onlyEditableLayers = False # nota la distanza di offset si richiede il punto per stabilire da che parte elif self.mode == Qad_offset_maptool_ModeEnum.OFFSET_KNOWN_ASK_FOR_SIDE_PT: self.setSelectionMode(QadGetPointSelectionModeEnum.POINT_SELECTION) self.setDrawMode(QadGetPointDrawModeEnum.NONE) self.onlyEditableLayers = False # si richiede il punto di passaggio per stabilire da che parte e a quale offset elif self.mode == Qad_offset_maptool_ModeEnum.ASK_FOR_PASSAGE_PT: self.setSelectionMode(QadGetPointSelectionModeEnum.POINT_SELECTION) self.setDrawMode(QadGetPointDrawModeEnum.NONE) self.onlyEditableLayers = False # si richiede la selezione di un oggetto elif self.mode == Qad_offset_maptool_ModeEnum.ASK_FOR_ENTITY_SELECTION: self.setSelectionMode( QadGetPointSelectionModeEnum.ENTITY_SELECTION) # 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) self.layersToCheck = layerList self.setDrawMode(QadGetPointDrawModeEnum.NONE) self.onlyEditableLayers = True
def setMode(self, mode): self.clear() self.mode = mode # si richiede il primo punto per calcolo offset if self.mode == Qad_offset_maptool_ModeEnum.ASK_FOR_FIRST_OFFSET_PT: self.setSelectionMode(QadGetPointSelectionModeEnum.POINT_SELECTION) self.setDrawMode(QadGetPointDrawModeEnum.NONE) self.onlyEditableLayers = False # noto il primo punto per calcolo offset si richiede il secondo punto if self.mode == Qad_offset_maptool_ModeEnum.FIRST_OFFSET_PT_KNOWN_ASK_FOR_SECOND_PT: self.setSelectionMode(QadGetPointSelectionModeEnum.POINT_SELECTION) self.setDrawMode(QadGetPointDrawModeEnum.ELASTIC_LINE) self.setStartPoint(self.firstPt) self.onlyEditableLayers = False # nota la distanza di offset si richiede il punto per stabilire da che parte elif self.mode == Qad_offset_maptool_ModeEnum.OFFSET_KNOWN_ASK_FOR_SIDE_PT: self.setSelectionMode(QadGetPointSelectionModeEnum.POINT_SELECTION) self.setDrawMode(QadGetPointDrawModeEnum.NONE) self.onlyEditableLayers = False # si richiede il punto di passaggio per stabilire da che parte e a quale offset elif self.mode == Qad_offset_maptool_ModeEnum.ASK_FOR_PASSAGE_PT: self.setSelectionMode(QadGetPointSelectionModeEnum.POINT_SELECTION) self.setDrawMode(QadGetPointDrawModeEnum.NONE) self.onlyEditableLayers = False # si richiede la selezione di un oggetto elif self.mode == Qad_offset_maptool_ModeEnum.ASK_FOR_ENTITY_SELECTION: self.setSelectionMode(QadGetPointSelectionModeEnum.ENTITY_SELECTION) # solo layer lineari o poligono editabili che non appartengano a quote layerList = [] for layer in self.plugIn.canvas.layers(): if layer.type() == QgsMapLayer.VectorLayer and \ (layer.geometryType() == QGis.Line or layer.geometryType() == QGis.Polygon) and \ layer.isEditable(): if len(QadDimStyles.getDimListByLayer(layer)) == 0: layerList.append(layer) self.layersToCheck = layerList self.setDrawMode(QadGetPointDrawModeEnum.NONE) self.onlyEditableLayers = True
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
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.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 = None if self.virtualCmd == False: # se si vuole veramente salvare la polylinea in un layer # il layer corrente deve essere editabile e di tipo linea o poligono currLayer, errMsg = qad_layer.getCurrLayerEditable(self.plugIn.canvas, [QGis.Line, QGis.Polygon]) if currLayer is None: self.showErr(errMsg) return True # fine comando # il layer corrente non deve appartenere a quotature dimStyleList = QadDimStyles.getDimListByLayer(currLayer) if len(dimStyleList) > 0: dimStyleNames = "" for i in xrange(0, len(dimStyleList), 1): if i > 0: dimStyleNames += ", " dimStyleNames += dimStyleList[i].name errMsg = QadMsg.translate("QAD", "\nCurrent layer is a layer referenced to {0} dimension style and it is not valid.\n") self.showErr(errMsg.format(dimStyleNames)) 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) #========================================================================= # BUFFER 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().setMode(Qad_mbuffer_maptool_ModeEnum.NONE_KNOWN_ASK_FOR_FIRST_PT) if currLayer is not None: self.getPointMapTool().geomType = QGis.Line if currLayer.geometryType() == QGis.Line else QGis.Polygon # si appresta ad attendere un punto o un numero reale # msg, inputType, default, keyWords, valori positivi msg = QadMsg.translate("Command_MBUFFER", "Specify the buffer length <{0}>: ") self.waitFor(msg.format(str(self.plugIn.lastRadius)), \ QadInputTypeEnum.POINT2D | QadInputTypeEnum.FLOAT, \ self.plugIn.lastRadius, "", \ QadInputModeEnum.NOT_NULL | QadInputModeEnum.NOT_ZERO | QadInputModeEnum.NOT_NEGATIVE) self.step = 2 return False #========================================================================= # RISPOSTA ALLA RICHIESTA LARGHEZZA (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 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 type(value) == QgsPoint: self.startPtForBufferWidth = value # imposto il map tool self.getPointMapTool().startPtForBufferWidth = self.startPtForBufferWidth self.getPointMapTool().entitySet.set(self.entitySet) self.getPointMapTool().segments = self.segments self.getPointMapTool().setMode(Qad_mbuffer_maptool_ModeEnum.FIRST_PT_ASK_FOR_BUFFER_WIDTH) # si appresta ad attendere un punto self.waitForPoint(QadMsg.translate("Command_MBUFFER", "Specify second point: ")) self.step = 3 return False else: self.width = value self.plugIn.setLastRadius(self.width) if self.virtualCmd == False: # se si vuole veramente salvare i buffer in un layer self.AddGeoms(currLayer) return True # fine comando #========================================================================= # RISPOSTA ALLA RICHIESTA SECONDO PUNTO DELLA LARGHEZZA BUFFER (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.width = qad_utils.getDistance(self.startPtForBufferWidth, value) self.plugIn.setLastRadius(self.width) if self.virtualCmd == False: # se si vuole veramente salvare i buffer in un layer self.AddGeoms(currLayer) 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 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.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 = None if self.virtualCmd == False: # se si vuole veramente salvare la polylinea in un layer # il layer corrente deve essere editabile e di tipo linea o poligono currLayer, errMsg = qad_layer.getCurrLayerEditable( self.plugIn.canvas, [QGis.Line, QGis.Polygon]) if currLayer is None: self.showErr(errMsg) return True # fine comando # il layer corrente non deve appartenere a quotature dimStyleList = QadDimStyles.getDimListByLayer(currLayer) if len(dimStyleList) > 0: dimStyleNames = "" for i in xrange(0, len(dimStyleList), 1): if i > 0: dimStyleNames += ", " dimStyleNames += dimStyleList[i].name errMsg = QadMsg.translate( "QAD", "\nCurrent layer is a layer referenced to {0} dimension style and it is not valid.\n" ) self.showErr(errMsg.format(dimStyleNames)) 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) #========================================================================= # BUFFER 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().setMode( Qad_mbuffer_maptool_ModeEnum.NONE_KNOWN_ASK_FOR_FIRST_PT) if currLayer is not None: self.getPointMapTool( ).geomType = QGis.Line if currLayer.geometryType( ) == QGis.Line else QGis.Polygon # si appresta ad attendere un punto o un numero reale # msg, inputType, default, keyWords, valori positivi msg = QadMsg.translate("Command_MBUFFER", "Specify the buffer length <{0}>: ") self.waitFor(msg.format(str(self.plugIn.lastRadius)), \ QadInputTypeEnum.POINT2D | QadInputTypeEnum.FLOAT, \ self.plugIn.lastRadius, "", \ QadInputModeEnum.NOT_NULL | QadInputModeEnum.NOT_ZERO | QadInputModeEnum.NOT_NEGATIVE) self.step = 2 return False #========================================================================= # RISPOSTA ALLA RICHIESTA LARGHEZZA (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 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 type(value) == QgsPoint: self.startPtForBufferWidth = value # imposto il map tool self.getPointMapTool( ).startPtForBufferWidth = self.startPtForBufferWidth self.getPointMapTool().entitySet.set(self.entitySet) self.getPointMapTool().segments = self.segments self.getPointMapTool().setMode( Qad_mbuffer_maptool_ModeEnum.FIRST_PT_ASK_FOR_BUFFER_WIDTH) # si appresta ad attendere un punto self.waitForPoint( QadMsg.translate("Command_MBUFFER", "Specify second point: ")) self.step = 3 return False else: self.width = value self.plugIn.setLastRadius(self.width) if self.virtualCmd == False: # se si vuole veramente salvare i buffer in un layer self.AddGeoms(currLayer) return True # fine comando #========================================================================= # RISPOSTA ALLA RICHIESTA SECONDO PUNTO DELLA LARGHEZZA BUFFER (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.width = qad_utils.getDistance(self.startPtForBufferWidth, value) self.plugIn.setLastRadius(self.width) if self.virtualCmd == False: # se si vuole veramente salvare i buffer in un layer self.AddGeoms(currLayer) return True # fine comando
def __initQadInfo(self): # inizializza entityType, qadGeom, dimStyle, dimId if self.isInitialized() == False: return QadEntityGeomTypeEnum.NONE self.dimStyle = None self.dimId = None g = self.getGeometry() if g is None: return QadEntityGeomTypeEnum.NONE # trasformo la geometria nel crs del canvas per lavorare con coordinate piane xy coordTransform = QgsCoordinateTransform(self.layer.crs(), iface.mapCanvas().mapRenderer().destinationCrs()) g.transform(coordTransform) wkbType = g.wkbType() if wkbType == QGis.WKBPoint: from qad_dim import QadDimStyles # to avoid cyclic import # verifico se l'entità appartiene ad uno stile di quotatura dimStyle, dimId = QadDimStyles.getDimIdByEntity(self) if (dimStyle is not None) and (dimId is not None): self.dimStyle = dimStyle # stile di quotatura di appartenenza self.dimId = dimId # codice quotatura di appartenenza if qad_layer.isTextLayer(self.layer): self.entityType = QadEntityGeomTypeEnum.TEXT elif qad_layer.isSymbolLayer(self.layer): self.entityType = QadEntityGeomTypeEnum.SYMBOL self.qadGeom = g.asPoint() # un punto if wkbType == QGis.WKBMultiPoint: if qad_layer.isTextLayer(self.layer): self.entityType = QadEntityGeomTypeEnum.TEXT elif qad_layer.isSymbolLayer(self.layer): self.entityType = QadEntityGeomTypeEnum.SYMBOL self.qadGeom = g.asMultiPoint() # lista di punti elif wkbType == QGis.WKBLineString: from qad_dim import QadDimStyles # to avoid cyclic import # verifico se l'entità appartiene ad uno stile di quotatura dimStyle, dimId = QadDimStyles.getDimIdByEntity(self) if (dimStyle is not None) and (dimId is not None): self.entityType = QadEntityGeomTypeEnum.DIMENSION_COMPONENT self.dimStyle = dimStyle # stile di quotatura di appartenenza self.dimId = dimId # codice quotatura di appartenenza self.entityType, self.qadGeom = self.__fromPoyline(g.asPolyline()) elif wkbType == QGis.WKBMultiLineString: self.entityType = [] self.qadGeom = [] lineList = g.asMultiPolyline() # vettore di linee for line in lineList: entityType, qadGeom = self.__fromPoyline(g.asPolyline()) self.entityType.append(entityType) self.qadGeom.append(qadGeom) elif wkbType == QGis.WKBPolygon: self.entityType = [] self.qadGeom = [] polygon = g.asPolygon() # vettore di linee for line in polygon: entityType, qadGeom = self.__fromPoyline(line) self.entityType.append(entityType) self.qadGeom.append(qadGeom) elif wkbType == QGis.WKBMultiPolygon: self.entityType = [] self.qadGeom = [] polygonList = g.asMultiPolygon() # vettore di poligoni for polygon in polygonList: partialEntityType = [] partialQadGeom = [] for line in polygon: entityType, qadGeom = self.__fromPoyline(line) partialEntityType.append(entityType) partialQadGeom.append(qadGeom) self.entityType.append(partialEntityType) self.qadGeom.append(partialQadGeom)
def run(self, msgMapTool = False, msg = None): # ritorna: # True per selezione non terminata # False per selezione terminata 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 # errore #========================================================================= # RICHIESTA PRIMO PUNTO PER SELEZIONE OGGETTI if self.step == 0: # if you can also select objects before you start a command if QadVariables.get(QadMsg.translate("Environment variables", "PICKFIRST")) == 1: if self.AddCurrentQgsSelectedFeatures() == True: self.plugIn.setLastEntitySet(self.entitySet) return True; self.WaitForFirstPoint() return False # continua #========================================================================= # RISPOSTA ALLA RICHIESTA PRIMO PUNTO PER SELEZIONE OGGETTI elif self.step == 1: # dopo aver atteso un punto o enter 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 if self.entitySet.count() > 0: self.plugIn.setLastEntitySet(self.entitySet) return True # fine else: self.setMapTool(self.getPointMapTool()) # riattivo il maptool return False # continua shiftKey = self.getPointMapTool().shiftKey # se é stata selezionata un'entità if self.getPointMapTool().entity.isInitialized(): value = self.getPointMapTool().entity else: value = self.getPointMapTool().point else: # il punto arriva come parametro della funzione shiftKey = False value = msg if value is None: if self.entitySet.count() > 0: self.plugIn.setLastEntitySet(self.entitySet) return True # fine if type(value) == unicode: self.currSelectionMode = value if value == QadMsg.translate("Command_SSGET", "Window") or value == "Window" or \ value == QadMsg.translate("Command_SSGET", "Crossing") or value == "Crossing": # "Finestra" = Seleziona tutti gli oggetti che si trovano completamente all'interno di un rettangolo definito da due punti # "Interseca" = Seleziona gli oggetti che intersecano o si trovano all'interno di un'area definita da due punti # imposto il map tool self.getPointMapTool().setSelectionMode(QadGetPointSelectionModeEnum.POINT_SELECTION) self.getPointMapTool().setDrawMode(QadGetPointDrawModeEnum.NONE) # si appresta ad attendere un punto self.waitForPoint(QadMsg.translate("Command_SSGET", "First corner: ")) self.step = 2 if value == QadMsg.translate("Command_SSGET", "Last") or value == "Last": # Seleziona l'ultima entità inserita if self.plugIn.getLastEntity() is None: self.showMsgOnAddRemove(0) else: self.AddRemoveEntity(self.plugIn.getLastEntity(), self.AddOnSelection) if self.SingleSelection == True and self.entitySet.count() > 0: self.plugIn.setLastEntitySet(self.entitySet) return True # fine if self.exitAfterSelection == True: return True # fine self.WaitForFirstPoint() elif value == QadMsg.translate("Command_SSGET", "Box") or value == "Box": # Seleziona tutti gli oggetti che intersecano o si trovano all'interno di un rettangolo specificato da due punti. # Se i punti del rettangolo sono specificati da destra a sinistra, Riquadro equivale ad Interseca, # altrimenti é equivalente a Finestra # imposto il map tool self.getPointMapTool().setSelectionMode(QadGetPointSelectionModeEnum.POINT_SELECTION) self.getPointMapTool().setDrawMode(QadGetPointDrawModeEnum.NONE) # si appresta ad attendere un punto self.waitForPoint(QadMsg.translate("Command_SSGET", "First corner: ")) self.step = 2 elif value == QadMsg.translate("Command_SSGET", "All") or value == "All": # Seleziona tutti gli oggetti selSet = qad_utils.getSelSet("X", self.getPointMapTool(), None, \ self.getLayersToCheck()) self.elaborateSelSet(selSet, False) if self.SingleSelection == True and self.entitySet.count() > 0: self.plugIn.setLastEntitySet(self.entitySet) return True # fine if self.exitAfterSelection == True: return True # fine self.WaitForFirstPoint() elif value == QadMsg.translate("Command_SSGET", "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 = 4 elif value == QadMsg.translate("Command_SSGET", "WPolygon") or value == "WPolygon" or \ value == QadMsg.translate("Command_SSGET", "CPolygon") or value == "CPolygon": # "FPoligono" = Seleziona oggetti che si trovano completamente all'interno di un poligono definito da punti # "IPoligono" = Seleziona gli oggetti che intersecano o si trovano all'interno di un poligono definito specificando dei punti self.MPOLYGONCommand = QadMPOLYGONCommandClass(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.MPOLYGONCommand.virtualCmd = True if value == QadMsg.translate("Command_SSGET", "WPolygon") or value == "WPolygon": self.MPOLYGONCommand.setRubberBandColor(None, getColorForWindowSelectionArea()) else: self.MPOLYGONCommand.setRubberBandColor(None, getColorForCrossingSelectionArea()) self.MPOLYGONCommand.run(msgMapTool, msg) self.step = 7 elif value == QadMsg.translate("Command_SSGET", "WCircle") or value == "WCircle" or \ value == QadMsg.translate("Command_SSGET", "CCircle") or value == "CCircle": # "FCerchio" = Seleziona oggetti che si trovano completamente all'interno di un cerchio # "ICerchio" = Seleziona oggetti che intersecano o si trovano all'interno di un cerchio self.CIRCLECommand = QadCIRCLECommandClass(self.plugIn) # se questo flag = True il comando serve all'interno di un altro comando per disegnare un cerchio # che non verrà salvata su un layer self.CIRCLECommand.virtualCmd = True if value == QadMsg.translate("Command_SSGET", "WCircle") or value == "WCircle": self.CIRCLECommand.setRubberBandColor(None, getColorForWindowSelectionArea()) else: self.CIRCLECommand.setRubberBandColor(None, getColorForCrossingSelectionArea()) self.CIRCLECommand.run(msgMapTool, msg) self.step = 5 elif value == QadMsg.translate("Command_SSGET", "WObjects") or value == "WObjects" or \ value == QadMsg.translate("Command_SSGET", "CObjects") or value == "CObjects": # "FOggetti" = Seleziona oggetti che si trovano completamente all'interno di oggetti da selezionare # "IOggetti" = Seleziona oggetti che intersecano o si trovano all'interno di oggetti da selezionare self.SSGetClass = QadSSGetClass(self.plugIn) self.SSGetClass.run(msgMapTool, msg) self.step = 6 elif value == QadMsg.translate("Command_SSGET", "WBuffer") or value == "WBuffer" or \ value == QadMsg.translate("Command_SSGET", "CBuffer") or value == "CBuffer": # ho dovuto spostare questo import perché qad_mbuffer_cmd fa l'import di qad_ssget_cmd from qad_mbuffer_cmd import QadMBUFFERCommandClass # "FBuffer" = Seleziona oggetti che si trovano completamente all'interno di buffer intorno ad oggetti da selezionare # "IBuffer" = Seleziona oggetti che intersecano o si trovano all'interno di buffer intorno ad oggetti da selezionare self.MBUFFERCommand = QadMBUFFERCommandClass(self.plugIn) # se questo flag = True il comando serve all'interno di un altro comando per disegnare un cerchio # che non verrà salvata su un layer self.MBUFFERCommand.virtualCmd = True if value == QadMsg.translate("Command_SSGET", "WBuffer") or value == "WBuffer": self.MBUFFERCommand.setRubberBandColor(None, getColorForWindowSelectionArea()) else: self.MBUFFERCommand.setRubberBandColor(None, getColorForCrossingSelectionArea()) self.MBUFFERCommand.run(msgMapTool, msg) self.step = 8 elif value == QadMsg.translate("Command_SSGET", "Add") or value == "Add": # Passa al metodo Aggiungi: gli oggetti selezionati possono essere aggiunti al gruppo di selezione self.AddOnSelection = True self.WaitForFirstPoint() elif value == QadMsg.translate("Command_SSGET", "Remove") or value == "Remove": # Passa al metodo Rimuovi: gli oggetti possono essere rimossi dal gruppo di selezione self.AddOnSelection = False self.WaitForFirstPoint() elif value == QadMsg.translate("Command_SSGET", "Previous") or value == "Previous": # Seleziona il gruppo di selezione più recente if self.plugIn.lastEntitySet is None: self.showMsgOnAddRemove(0) else: entitySet = QadEntitySet() entitySet.set(self.plugIn.lastEntitySet) # controllo sul layer if self.onlyEditableLayers == True: entitySet.removeNotEditable() # controllo sul tipo if self.checkPointLayer == False: entitySet.removeGeomType(QGis.Point) if self.checkLineLayer == False: entitySet.removeGeomType(QGis.Line) if self.checkPolygonLayer == False: entitySet.removeGeomType(QGis.Polygon) # controllo sulle quotature if self.checkDimLayers == False: QadDimStyles.removeAllDimLayersFromEntitySet(entitySet) entitySet.removeNotExisting() self.elaborateSelSet(entitySet, False) if self.SingleSelection == True and self.entitySet.count() > 0: self.plugIn.setLastEntitySet(self.entitySet) return True # fine if self.exitAfterSelection == True: return True # fine self.WaitForFirstPoint() elif value == QadMsg.translate("Command_SSGET", "Undo") or value == "Undo": # Annulla la selezione dell'oggetto aggiunto più recentemente al gruppo di selezione. # Inverto il tipo di selezione prevAddOnSelection = self.AddOnSelection self.AddOnSelection = not self.AddOnSelection self.elaborateSelSet(self.lastEntitySet, False) # Ripristino il tipo di selezione self.AddOnSelection = prevAddOnSelection if self.SingleSelection == True and self.entitySet.count() > 0: self.plugIn.setLastEntitySet(self.entitySet) return True # fine if self.exitAfterSelection == True: return True # fine self.WaitForFirstPoint() elif value == QadMsg.translate("Command_SSGET", "AUto") or value == "AUto": # Passa alla selezione automatica: vengono selezionati gli oggetti sui quali si posiziona il puntatore. # Facendo clic su un'area vuota all'interno o all'esterno di un oggetto, # si crea il primo angolo di un rettangolo di selezione, come per il metodo Riquadro self.SingleSelection = False self.WaitForFirstPoint() elif value == QadMsg.translate("Command_SSGET", "SIngle") or value == "SIngle": # Passa al metodo Singolo: viene selezionato il primo oggetto o gruppo di oggetti indicato, # senza che vengano richieste altre selezioni. self.SingleSelection = True if self.entitySet.count() > 0: self.plugIn.setLastEntitySet(self.entitySet) return True # fine self.WaitForFirstPoint() elif value == QadMsg.translate("Command_SSGET", "Help") or value == "Help": self.help = True self.WaitForFirstPoint() elif type(value) == QgsPoint: # se é stato inserito il punto iniziale del rettangolo self.currSelectionMode = QadMsg.translate("Command_SSGET", "Box") self.points.append(value) self.getPointMapTool().setSelectionMode(QadGetPointSelectionModeEnum.ENTITYSET_SELECTION) self.getPointMapTool().setDrawMode(QadGetPointDrawModeEnum.ELASTIC_RECTANGLE) self.getPointMapTool().setStartPoint(value) # si appresta ad attendere un punto self.waitForPoint(QadMsg.translate("Command_SSGET", "Specify opposite corner: ")) self.step = 3 else: # se é stata selezionata un'entità self.elaborateEntity(value, shiftKey) if self.SingleSelection == True and self.entitySet.count() > 0: self.plugIn.setLastEntitySet(self.entitySet) return True # fine if self.exitAfterSelection == True: return True # fine self.WaitForFirstPoint() return False # continua #========================================================================= # RISPOSTA ALLA RICHIESTA DEL PRIMO PUNTO DEL RETTANGOLO DA OPZIONE # FINESTRA, INTERSECA, RIQUADRO (da step = 1) elif self.step == 2: # 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 self.showMsg(QadMsg.translate("Command_SSGET", "Window not correct.")) self.WaitForFirstPoint() 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 if type(value) == QgsPoint: self.points.append(value) self.getPointMapTool().setSelectionMode(QadGetPointSelectionModeEnum.ENTITYSET_SELECTION) self.getPointMapTool().setDrawMode(QadGetPointDrawModeEnum.ELASTIC_RECTANGLE) # cambio il colore impostato da setDrawMode if self.currSelectionMode == QadMsg.translate("Command_SSGET", "Window") or value == "Window": self.getPointMapTool().rectangleCrossingSelectionColor = self.getPointMapTool().rectangleWindowSelectionColor elif self.currSelectionMode == QadMsg.translate("Command_SSGET", "Crossing") or value == "Crossing": self.getPointMapTool().rectangleWindowSelectionColor = self.getPointMapTool().rectangleCrossingSelectionColor self.rectangleCrossingSelectionColor = getColorForCrossingSelectionArea() self.rectangleWindowSelectionColor = getColorForWindowSelectionArea() self.getPointMapTool().setStartPoint(value) # si appresta ad attendere un punto self.waitForPoint(QadMsg.translate("Command_SSGET", "Specify opposite corner: ")) self.step = 3 else: self.showMsg(QadMsg.translate("Command_SSGET", "Window not correct.")) self.WaitForFirstPoint() return False # continua #========================================================================= # RISPOSTA ALLA RICHIESTA DEL SECONDO PUNTO DEL RETTANGOLO (da step = 1) 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 self.showMsg(QadMsg.translate("Command_SSGET", "Window not correct.")) # si appresta ad attendere un punto self.waitForPoint(QadMsg.translate("Command_SSGET", "Specify opposite corner: ")) return False else: self.setMapTool(self.getPointMapTool()) # riattivo il maptool return False shiftKey = self.getPointMapTool().shiftKey value = self.getPointMapTool().point else: # il punto arriva come parametro della funzione shiftKey = False value = msg if type(value) == QgsPoint: self.getPointMapTool().clear() self.points.append(value) if self.currSelectionMode == QadMsg.translate("Command_SSGET", "Box") or \ self.currSelectionMode == "Box": if self.points[0].x() < value.x(): mode = "W" else: mode = "C" elif self.currSelectionMode == QadMsg.translate("Command_SSGET", "Window") or \ self.currSelectionMode == "Window": mode = "W" else: # "Interseca" mode = "C" selSet = qad_utils.getSelSet(mode, self.getPointMapTool(), self.points, \ self.getLayersToCheck()) self.elaborateSelSet(selSet, shiftKey) if self.SingleSelection == True and self.entitySet.count() > 0: self.plugIn.setLastEntitySet(self.entitySet) return True # fine if self.exitAfterSelection == True: return True # fine self.WaitForFirstPoint() else: self.showMsg(QadMsg.translate("Command_SSGET", "Window not correct.")) # si appresta ad attendere un punto self.waitForPoint(QadMsg.translate("Command_SSGET", "Specify opposite corner: ")) return False # continua #========================================================================= # RISPOSTA ALLA RICHIESTA PUNTO PER MODALITA' INTERCETTA (da step = 1 o 4) elif self.step == 4: # dopo aver atteso un punto si riavvia il comando if self.PLINECommand.run(msgMapTool, msg) == True: self.showMsg("\n") self.AddRemoveSelSetByFence(self.PLINECommand.vertices) del self.PLINECommand self.PLINECommand = None if self.SingleSelection == True and self.entitySet.count() > 0: self.plugIn.setLastEntitySet(self.entitySet) return True # fine if self.exitAfterSelection == True: return True # fine self.WaitForFirstPoint() return False #========================================================================= # RISPOSTA ALLA RICHIESTA PER MODALITA' FCERCHIO e ICERCHIO (da step = 1 o 5) elif self.step == 5: # dopo aver atteso un punto si riavvia il comando if self.CIRCLECommand.run(msgMapTool, msg) == True: self.showMsg("\n") if (self.CIRCLECommand.centerPt is not None) and \ (self.CIRCLECommand.radius is not None): circle = QadCircle() circle.set(self.CIRCLECommand.centerPt, self.CIRCLECommand.radius) points = circle.asPolyline() if self.currSelectionMode == QadMsg.translate("Command_SSGET", "WCircle") or \ self.currSelectionMode == "WCircle": self.AddRemoveSelSetByPolygon("WP", points) elif self.currSelectionMode == QadMsg.translate("Command_SSGET", "CCircle") or \ self.currSelectionMode == "CCircle": self.AddRemoveSelSetByPolygon("CP", points) del self.CIRCLECommand self.CIRCLECommand = None if self.SingleSelection == True and self.entitySet.count() > 0: self.plugIn.setLastEntitySet(self.entitySet) return True # fine if self.exitAfterSelection == True: return True # fine self.WaitForFirstPoint() return False #========================================================================= # RISPOSTA ALLA RICHIESTA DI SELEZIONE DI OGGETTI PER MODALITA' FOGGETTI e IOGGETTI (da step = 1 o 6) elif self.step == 6: # dopo aver atteso un punto si riavvia il comando if self.SSGetClass.run(msgMapTool, msg) == True: self.showMsg("\n") destCRS = self.SSGetClass.getPointMapTool().canvas.mapRenderer().destinationCrs() geoms = self.SSGetClass.entitySet.getGeometryCollection(destCRS) # trasformo la geometria if self.currSelectionMode == QadMsg.translate("Command_SSGET", "WObjects") or \ self.currSelectionMode == "WObjects": self.AddRemoveSelSetByGeometry("WO", geoms) elif self.currSelectionMode == QadMsg.translate("Command_SSGET", "CObjects") or \ self.currSelectionMode == "CObjects": self.AddRemoveSelSetByGeometry("CO", geoms) del self.SSGetClass self.SSGetClass = None if self.SingleSelection == True and self.entitySet.count() > 0: self.plugIn.setLastEntitySet(self.entitySet) return True # fine if self.exitAfterSelection == True: return True # fine self.WaitForFirstPoint() return False #========================================================================= # RISPOSTA ALLA RICHIESTA PER MODALITA' FPOLIGONO e IPOLIGONO (da step = 1 o 7) elif self.step == 7: # dopo aver atteso un punto si riavvia il comando if self.MPOLYGONCommand.run(msgMapTool, msg) == True: self.showMsg("\n") if self.currSelectionMode == QadMsg.translate("Command_SSGET", "WPolygon") or \ self.currSelectionMode == "WPolygon": self.AddRemoveSelSetByPolygon("WP", self.MPOLYGONCommand.vertices) elif self.currSelectionMode == QadMsg.translate("Command_SSGET", "CPolygon") or \ self.currSelectionMode == "CPolygon": self.AddRemoveSelSetByPolygon("CP", self.MPOLYGONCommand.vertices) del self.MPOLYGONCommand self.MPOLYGONCommand = None if self.SingleSelection == True and self.entitySet.count() > 0: self.plugIn.setLastEntitySet(self.entitySet) return True # fine if self.exitAfterSelection == True: return True # fine self.WaitForFirstPoint() return False #========================================================================= # RISPOSTA ALLA RICHIESTA DI SELEZIONE DI OGGETTI PER MODALITA' FBUFFER e IBUFFER (da step = 1 o 8) elif self.step == 8: # dopo aver atteso un punto si riavvia il comando if self.MBUFFERCommand.run(msgMapTool, msg) == True: self.showMsg("\n") bufferGeoms = [] for layerEntitySet in self.MBUFFERCommand.entitySet.layerEntitySetList: geoms = layerEntitySet.getGeometryCollection() width = qad_utils.distMapToLayerCoordinates(self.MBUFFERCommand.width, \ self.MBUFFERCommand.getPointMapTool().canvas,\ layerEntitySet.layer) for geom in geoms: bufferGeoms.append(geom.buffer(width, self.MBUFFERCommand.segments)) if self.currSelectionMode == QadMsg.translate("Command_SSGET", "WBuffer") or \ self.currSelectionMode == "WBuffer": self.AddRemoveSelSetByGeometry("WO", bufferGeoms) elif self.currSelectionMode == QadMsg.translate("Command_SSGET", "CBuffer") or \ self.currSelectionMode == "CBuffer": self.AddRemoveSelSetByGeometry("CO", bufferGeoms) del self.MBUFFERCommand self.MBUFFERCommand = None if self.SingleSelection == True and self.entitySet.count() > 0: self.plugIn.setLastEntitySet(self.entitySet) return True # fine if self.exitAfterSelection == True: return True # fine self.WaitForFirstPoint() return False
def __initQadInfo(self): # inizializza entityType, qadGeom, dimStyle, dimId if self.isInitialized() == False: return QadEntityGeomTypeEnum.NONE self.dimStyle = None self.dimId = None g = self.getGeometry() if g is None: return QadEntityGeomTypeEnum.NONE # trasformo la geometria nel crs del canvas per lavorare con coordinate piane xy coordTransform = QgsCoordinateTransform( self.layer.crs(), iface.mapCanvas().mapRenderer().destinationCrs()) g.transform(coordTransform) wkbType = g.wkbType() if wkbType == QGis.WKBPoint: from qad_dim import QadDimStyles # to avoid cyclic import # verifico se l'entità appartiene ad uno stile di quotatura dimStyle, dimId = QadDimStyles.getDimIdByEntity(self) if (dimStyle is not None) and (dimId is not None): self.dimStyle = dimStyle # stile di quotatura di appartenenza self.dimId = dimId # codice quotatura di appartenenza if qad_layer.isTextLayer(self.layer): self.entityType = QadEntityGeomTypeEnum.TEXT elif qad_layer.isSymbolLayer(self.layer): self.entityType = QadEntityGeomTypeEnum.SYMBOL self.qadGeom = g.asPoint() # un punto if wkbType == QGis.WKBMultiPoint: if qad_layer.isTextLayer(self.layer): self.entityType = QadEntityGeomTypeEnum.TEXT elif qad_layer.isSymbolLayer(self.layer): self.entityType = QadEntityGeomTypeEnum.SYMBOL self.qadGeom = g.asMultiPoint() # lista di punti elif wkbType == QGis.WKBLineString: from qad_dim import QadDimStyles # to avoid cyclic import # verifico se l'entità appartiene ad uno stile di quotatura dimStyle, dimId = QadDimStyles.getDimIdByEntity(self) if (dimStyle is not None) and (dimId is not None): self.entityType = QadEntityGeomTypeEnum.DIMENSION_COMPONENT self.dimStyle = dimStyle # stile di quotatura di appartenenza self.dimId = dimId # codice quotatura di appartenenza self.entityType, self.qadGeom = self.__fromPoyline(g.asPolyline()) elif wkbType == QGis.WKBMultiLineString: self.entityType = [] self.qadGeom = [] lineList = g.asMultiPolyline() # vettore di linee for line in lineList: entityType, qadGeom = self.__fromPoyline(g.asPolyline()) self.entityType.append(entityType) self.qadGeom.append(qadGeom) elif wkbType == QGis.WKBPolygon: self.entityType = [] self.qadGeom = [] polygon = g.asPolygon() # vettore di linee for line in polygon: entityType, qadGeom = self.__fromPoyline(line) self.entityType.append(entityType) self.qadGeom.append(qadGeom) elif wkbType == QGis.WKBMultiPolygon: self.entityType = [] self.qadGeom = [] polygonList = g.asMultiPolygon() # vettore di poligoni for polygon in polygonList: partialEntityType = [] partialQadGeom = [] for line in polygon: entityType, qadGeom = self.__fromPoyline(line) partialEntityType.append(entityType) partialQadGeom.append(qadGeom) self.entityType.append(partialEntityType) self.qadGeom.append(partialQadGeom)
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 #========================================================================= # 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