def canvasMoveEvent(self, event): QadGetPoint.canvasMoveEvent(self, event) self.__rubberBand.reset() result = False del self.vertices[:] # svuoto la lista if self.mode is not None: # noto il centro si richiede il raggio if self.mode == Qad_polygon_maptool_ModeEnum.CENTER_PT_KNOWN_ASK_FOR_RADIUS: radius = qad_utils.getDistance(self.centerPt, self.tmpPoint) InscribedOption = True if self.constructionModeByCenter == QadMsg.translate("Command_POLYGON", "Inscribed in circle") else False self.vertices.extend(qad_utils.getPolygonByNsidesCenterRadius(self.sideNumber, self.centerPt, radius, \ InscribedOption, self.tmpPoint)) result = True # si richiede il secondo punto dello spigolo elif self.mode == Qad_polygon_maptool_ModeEnum.FIRST_EDGE_PT_KNOWN_ASK_FOR_SECOND_EDGE_PT: self.vertices.extend(qad_utils.getPolygonByNsidesEdgePts(self.sideNumber, self.firstEdgePt, \ self.tmpPoint)) result = True if result == True: if self.vertices is not None: if self.geomType == QGis.Polygon: self.__rubberBand.setPolygon(self.vertices) else: self.__rubberBand.setLine(self.vertices)
def canvasMoveEvent(self, event): QadGetPoint.canvasMoveEvent(self, event) self.__rubberBand.reset() result = False del self.vertices[:] # svuoto la lista if self.mode is not None: # noto il centro si richiede il raggio if self.mode == Qad_polygon_maptool_ModeEnum.CENTER_PT_KNOWN_ASK_FOR_RADIUS: radius = qad_utils.getDistance(self.centerPt, self.tmpPoint) InscribedOption = True if self.constructionModeByCenter == QadMsg.translate( "Command_POLYGON", "Inscribed in circle") else False self.vertices.extend(qad_utils.getPolygonByNsidesCenterRadius(self.sideNumber, self.centerPt, radius, \ InscribedOption, self.tmpPoint)) result = True # si richiede il secondo punto dello spigolo elif self.mode == Qad_polygon_maptool_ModeEnum.FIRST_EDGE_PT_KNOWN_ASK_FOR_SECOND_EDGE_PT: self.vertices.extend(qad_utils.getPolygonByNsidesEdgePts(self.sideNumber, self.firstEdgePt, \ self.tmpPoint)) result = True if result == True: if self.vertices is not None: if self.geomType == QGis.Polygon: self.__rubberBand.setPolygon(self.vertices) else: self.__rubberBand.setLine(self.vertices)
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 #========================================================================= # RICHIESTA NUMERO DI LATI DEL POLIGONO if self.step == 0: # inizio del comando self.WaitForSideNumber() return False #========================================================================= # RISPOSTA ALLA RICHIESTA DEL NUMERO DI LATI DEL POLIGONO (da step = 0) elif self.step == 1: # dopo aver atteso un punto si riavvia il comando if msgMapTool == True: # il punto arriva da una selezione grafica if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse value = self.sideNumber else: return False else: # il punto arriva come parametro della funzione value = msg if type(value) == int: if value < 3: self.showErr(QadMsg.translate("Command_POLYGON", "\nEnter an integer greater than 2.")) else: self.sideNumber = value self.getPointMapTool().sideNumber = self.sideNumber self.plugIn.setLastPolygonSideNumber(self.sideNumber) self.WaitForCenter() else: self.WaitForSideNumber() return False # continua #========================================================================= # RISPOSTA ALLA RICHIESTA DEL CENTRO DEL POLIGONO (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.WaitForCenter() 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) == unicode: if value == QadMsg.translate("Command_POLYGON", "Edge") or value == "Edge": self.WaitForFirstEdgePt() elif type(value) == QgsPoint: self.centerPt = value self.getPointMapTool().centerPt = self.centerPt self.WaitForInscribedCircumscribedOption() return False # continua #========================================================================= # RISPOSTA ALLA RICHIESTA DI POLIGONO INSCRITTO O CIRCOSCRITTO (da step = 2) elif self.step == 3: 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.constructionModeByCenter else: self.setMapTool(self.getPointMapTool()) # riattivo il maptool return False else: value = self.getPointMapTool().point else: # la parola chiave arriva come parametro della funzione value = msg if type(value) == unicode: self.constructionModeByCenter = value self.plugIn.setLastPolygonConstructionModeByCenter(self.constructionModeByCenter) self.getPointMapTool().constructionModeByCenter = self.constructionModeByCenter if self.constructionModeByCenter == QadMsg.translate("Command_POLYGON", "Area") or self.constructionModeByCenter == "Area": self.WaitForArea() else: self.WaitForRadius(currLayer) return False # fine comando #========================================================================= # RISPOSTA ALLA RICHIESTA DEL RAGGIO (da step = 3) elif self.step == 4: 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 or type(value) == float: # se é stato inserito il raggio del cerchio if type(value) == QgsPoint: # se é stato inserito il raggio del cerchio con un punto self.radius = qad_utils.getDistance(self.centerPt, value) ptStart = value else: self.radius = value ptStart = None self.plugIn.setLastRadius(self.radius) if self.constructionModeByCenter == QadMsg.translate("Command_POLYGON", "Inscribed in circle") or \ self.constructionModeByCenter == "Inscribed in circle": mode = True else: mode = False self.vertices.extend(qad_utils.getPolygonByNsidesCenterRadius(self.sideNumber, self.centerPt, self.radius, \ mode, ptStart)) if self.virtualCmd == False: # se si vuole veramente salvare i buffer in un layer self.addPolygonToLayer(currLayer) return True return False # fine comando #========================================================================= # RISPOSTA ALLA RICHIESTA DEL PRIMO PUNTO DELLO SPIGOLO (da step = 2) elif self.step == 5: # 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 if type(value) == QgsPoint: self.firstEdgePt = value self.WaitForSecondEdgePt(currLayer) return False #========================================================================= # RISPOSTA ALLA RICHIESTA DEL SECONDO PUNTO DELLO SPIGOLO (da step = 5) elif self.step == 6: # 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.vertices.extend(qad_utils.getPolygonByNsidesEdgePts(self.sideNumber, self.firstEdgePt, value)) if self.virtualCmd == False: # se si vuole veramente salvare i buffer in un layer self.addPolygonToLayer(currLayer) return True return False #========================================================================= # RISPOSTA ALLA RICHIESTA AREA POLIGONO (da step = 3) elif self.step == 7: # 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.area 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 l'area self.vertices.extend(qad_utils.getPolygonByNsidesArea(self.sideNumber, self.centerPt, value)) if self.virtualCmd == False: # se si vuole veramente salvare i buffer in un layer self.addPolygonToLayer(currLayer) return True 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 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 #========================================================================= # RICHIESTA NUMERO DI LATI DEL POLIGONO if self.step == 0: # inizio del comando self.WaitForSideNumber() return False #========================================================================= # RISPOSTA ALLA RICHIESTA DEL NUMERO DI LATI DEL POLIGONO (da step = 0) elif self.step == 1: # dopo aver atteso un punto si riavvia il comando if msgMapTool == True: # il punto arriva da una selezione grafica if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse value = self.sideNumber else: return False else: # il punto arriva come parametro della funzione value = msg if type(value) == int: if value < 3: self.showErr(QadMsg.translate("Command_POLYGON", "\nEnter an integer greater than 2.")) else: self.sideNumber = value self.getPointMapTool().sideNumber = self.sideNumber self.plugIn.setLastPolygonSideNumber(self.sideNumber) self.WaitForCenter() else: self.WaitForSideNumber() return False # continua #========================================================================= # RISPOSTA ALLA RICHIESTA DEL CENTRO DEL POLIGONO (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.WaitForCenter() 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) == unicode: if value == QadMsg.translate("Command_POLYGON", "Edge") or value == "Edge": self.WaitForFirstEdgePt() elif type(value) == QgsPoint: self.centerPt = value self.getPointMapTool().centerPt = self.centerPt self.WaitForInscribedCircumscribedOption() return False # continua #========================================================================= # RISPOSTA ALLA RICHIESTA DI POLIGONO INSCRITTO O CIRCOSCRITTO (da step = 2) elif self.step == 3: 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.constructionModeByCenter else: self.setMapTool(self.getPointMapTool()) # riattivo il maptool return False else: value = self.getPointMapTool().point else: # la parola chiave arriva come parametro della funzione value = msg if type(value) == unicode: self.constructionModeByCenter = value self.plugIn.setLastPolygonConstructionModeByCenter(self.constructionModeByCenter) self.getPointMapTool().constructionModeByCenter = self.constructionModeByCenter if self.constructionModeByCenter == QadMsg.translate("Command_POLYGON", "Area") or self.constructionModeByCenter == "Area": self.WaitForArea() else: self.WaitForRadius(currLayer) return False # fine comando #========================================================================= # RISPOSTA ALLA RICHIESTA DEL RAGGIO (da step = 3) elif self.step == 4: 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 or type(value) == float: # se é stato inserito il raggio del cerchio if type(value) == QgsPoint: # se é stato inserito il raggio del cerchio con un punto self.radius = qad_utils.getDistance(self.centerPt, value) ptStart = value else: self.radius = value ptStart = None self.plugIn.setLastRadius(self.radius) if self.constructionModeByCenter == QadMsg.translate("Command_POLYGON", "Inscribed in circle") or \ self.constructionModeByCenter == "Inscribed in circle": mode = True else: mode = False self.vertices.extend(qad_utils.getPolygonByNsidesCenterRadius(self.sideNumber, self.centerPt, self.radius, \ mode, ptStart)) if self.virtualCmd == False: # se si vuole veramente salvare i buffer in un layer self.addPolygonToLayer(currLayer) return True return False # fine comando #========================================================================= # RISPOSTA ALLA RICHIESTA DEL PRIMO PUNTO DELLO SPIGOLO (da step = 2) elif self.step == 5: # 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 if type(value) == QgsPoint: self.firstEdgePt = value self.WaitForSecondEdgePt(currLayer) return False #========================================================================= # RISPOSTA ALLA RICHIESTA DEL SECONDO PUNTO DELLO SPIGOLO (da step = 5) elif self.step == 6: # 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.vertices.extend(qad_utils.getPolygonByNsidesEdgePts(self.sideNumber, self.firstEdgePt, value)) if self.virtualCmd == False: # se si vuole veramente salvare i buffer in un layer self.addPolygonToLayer(currLayer) return True return False #========================================================================= # RISPOSTA ALLA RICHIESTA AREA POLIGONO (da step = 3) elif self.step == 7: # 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.area 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 l'area self.vertices.extend(qad_utils.getPolygonByNsidesArea(self.sideNumber, self.centerPt, value)) if self.virtualCmd == False: # se si vuole veramente salvare i buffer in un layer self.addPolygonToLayer(currLayer) return True return False