def rotate(self, entity, basePt, angle, rotFldName):
      # entity = entità da ruotare
      # basePt = punto base
      # angle = angolo di rotazione in gradi
      # rotFldName = campo della tabella che memorizza la rotazione
      # verifico se l'entità appartiene ad uno stile di quotatura
      if entity.whatIs() == "ENTITY":
         f = entity.getFeature()
         # ruoto l'entità
         f.setGeometry(qad_utils.rotateQgsGeometry(entity.getGeometry(), basePt, angle))
         if len(rotFldName) > 0:
            rotValue = f.attribute(rotFldName)
            rotValue = 0 if rotValue is None else qad_utils.toRadians(rotValue) # la rotazione é in gradi nel campo della feature
            rotValue = rotValue + angle
            f.setAttribute(rotFldName, qad_utils.toDegrees(qad_utils.normalizeAngle(rotValue)))               
         
         if self.copyEntities == False:
            # plugIn, layer, feature, refresh, check_validity
            if qad_layer.updateFeatureToLayer(self.plugIn, entity.layer, f, False, False) == False:
               return False
         else:
            # plugIn, layer, features, coordTransform, refresh, check_validity
            if qad_layer.addFeatureToLayer(self.plugIn, entity.layer, f, None, False, False) == False:
               return False
               
      elif entity.whatIs() == "DIMENTITY":
         # stiro la quota
         if self.copyEntities == False:
            if entity.deleteToLayers(self.plugIn) == False:
               return False           
         entity.rotate(self.plugIn, basePt, angle)
         if entity.addToLayers(self.plugIn) == False:
            return False             

      return True
Exemple #2
0
    def mirror(self, f, pt1, pt2, rotFldName, layerEntitySet, entitySet,
               dimEntity):

        if dimEntity is None:
            # scalo la feature e la rimuovo da entitySet (é la prima)
            f.setGeometry(qad_utils.mirrorQgsGeometry(f.geometry(), pt1, pt2))
            if len(rotFldName) > 0:
                rotValue = f.attribute(rotFldName)
                # a volte vale None e a volte null (vai a capire...)
                rotValue = 0 if rotValue is None or isinstance(
                    rotValue, QPyNullVariant) else qad_utils.toRadians(
                        rotValue
                    )  # la rotazione é in gradi nel campo della feature
                ptDummy = qad_utils.getPolarPointByPtAngle(pt1, rotValue, 1)
                mirrorAngle = qad_utils.getAngleBy2Pts(pt1, pt2)
                ptDummy = qad_utils.mirrorPoint(ptDummy, pt1, mirrorAngle)
                rotValue = qad_utils.getAngleBy2Pts(pt1, ptDummy)
                f.setAttribute(
                    rotFldName,
                    qad_utils.toDegrees(qad_utils.normalizeAngle(rotValue)))

            if self.copyFeatures == False:
                # plugIn, layer, feature, refresh, check_validity
                if qad_layer.updateFeatureToLayer(self.plugIn,
                                                  layerEntitySet.layer, f,
                                                  False, False) == False:
                    self.plugIn.destroyEditCommand()
                    return False
            else:
                # plugIn, layer, features, coordTransform, refresh, check_validity
                if qad_layer.addFeatureToLayer(self.plugIn,
                                               layerEntitySet.layer, f, None,
                                               False, False) == False:
                    self.plugIn.destroyEditCommand()
                    return False

            del layerEntitySet.featureIds[0]
        else:
            # scalo la quota e la rimuovo da entitySet
            mirrorAngle = qad_utils.getAngleBy2Pts(pt1, pt2)
            dimEntitySet = dimEntity.getEntitySet()
            if self.copyFeatures == False:
                if dimEntity.deleteToLayers(self.plugIn) == False:
                    return False
            newDimEntity = QadDimEntity(dimEntity)  # la copio
            newDimEntity.mirror(pt1, mirrorAngle)
            if newDimEntity.addToLayers(self.plugIn) == False:
                return False
            entitySet.subtract(dimEntitySet)
    def rotate(self, f, basePt, angle, rotFldName, layerEntitySet, entitySet):
        # verifico se l'entità appartiene ad uno stile di quotatura
        dimEntity = QadDimStyles.getDimEntity(layerEntitySet.layer, f.id())

        if dimEntity is None:
            # ruoto la feature e la rimuovo da entitySet (é la prima)
            f.setGeometry(
                qad_utils.rotateQgsGeometry(f.geometry(), basePt, angle))

            if len(rotFldName) > 0:
                rotValue = f.attribute(rotFldName)
                # a volte vale None e a volte null (vai a capire...)
                rotValue = 0 if rotValue is None or isinstance(
                    rotValue, QPyNullVariant) else qad_utils.toRadians(
                        rotValue
                    )  # la rotazione é in gradi nel campo della feature
                rotValue = rotValue + angle
                f.setAttribute(
                    rotFldName,
                    qad_utils.toDegrees(qad_utils.normalizeAngle(rotValue)))

            if self.copyFeatures == False:
                # plugIn, layer, feature, refresh, check_validity
                if qad_layer.updateFeatureToLayer(self.plugIn,
                                                  layerEntitySet.layer, f,
                                                  False, False) == False:
                    self.plugIn.destroyEditCommand()
                    return False
            else:
                # plugIn, layer, features, coordTransform, refresh, check_validity
                if qad_layer.addFeatureToLayer(self.plugIn,
                                               layerEntitySet.layer, f, None,
                                               False, False) == False:
                    self.plugIn.destroyEditCommand()
                    return False
            del layerEntitySet.featureIds[0]
        else:
            # ruoto la quota e la rimuovo da entitySet
            dimEntitySet = dimEntity.getEntitySet()
            if self.copyFeatures == False:
                if dimEntity.deleteToLayers(self.plugIn) == False:
                    return False
            newDimEntity = QadDimEntity(dimEntity)  # la copio
            newDimEntity.rotate(basePt, angle)
            if newDimEntity.addToLayers(self.plugIn) == False:
                return False
            entitySet.subtract(dimEntitySet)

        return True
Exemple #4
0
    def mirror(self, entity, pt1, pt2, rotFldName):
        # entity = entità da specchiare
        # pt1 e pt2 = linea di simmetria
        # rotFldName = campo della tabella che memorizza la rotazione
        # verifico se l'entità appartiene ad uno stile di quotatura
        if entity.whatIs() == "ENTITY":
            f = entity.getFeature()
            # specchio l'entità
            f.setGeometry(
                qad_utils.mirrorQgsGeometry(entity.getGeometry(), pt1, pt2))
            if len(rotFldName) > 0:
                rotValue = f.attribute(rotFldName)
                # a volte vale None e a volte null (vai a capire...)
                rotValue = 0 if rotValue is None or isinstance(
                    rotValue, QPyNullVariant) else qad_utils.toRadians(
                        rotValue
                    )  # la rotazione é in gradi nel campo della feature
                ptDummy = qad_utils.getPolarPointByPtAngle(pt1, rotValue, 1)
                mirrorAngle = qad_utils.getAngleBy2Pts(pt1, pt2)
                ptDummy = qad_utils.mirrorPoint(ptDummy, pt1, mirrorAngle)
                rotValue = qad_utils.getAngleBy2Pts(pt1, ptDummy)
                f.setAttribute(
                    rotFldName,
                    qad_utils.toDegrees(qad_utils.normalizeAngle(rotValue)))

            if self.copyEntities == False:
                # plugIn, layer, feature, refresh, check_validity
                if qad_layer.updateFeatureToLayer(self.plugIn, entity.layer, f,
                                                  False, False) == False:
                    return False
            else:
                # plugIn, layer, features, coordTransform, refresh, check_validity
                if qad_layer.addFeatureToLayer(self.plugIn, entity.layer, f,
                                               None, False, False) == False:
                    return False
        elif entity.whatIs() == "DIMENTITY":
            mirrorAngle = qad_utils.getAngleBy2Pts(pt1, pt2)
            # specchio la quota
            if self.copyEntities == False:
                if entity.deleteToLayers(self.plugIn) == False:
                    return False

            newDimEntity = QadDimEntity(entity)  # la copio
            newDimEntity.mirror(pt1, mirrorAngle)
            if newDimEntity.addToLayers(self.plugIn) == False:
                return False

        return True
    def accept_text_tab(self):
        self.dimStyle.textFont = self.textFont.currentText()
        self.dimStyle.textColor = self.textColor.color().name()
        self.dimStyle.textHeight = self.textHeight.value()

        # textVerticalPos
        if self.textVerticalPos.currentIndex() == 0:
            self.dimStyle.textVerticalPos = QadDimStyleTxtVerticalPosEnum.CENTERED_LINE
        elif self.textVerticalPos.currentIndex() == 1:
            self.dimStyle.textVerticalPos = QadDimStyleTxtVerticalPosEnum.ABOVE_LINE
        elif self.textVerticalPos.currentIndex() == 2:
            self.dimStyle.textVerticalPos = QadDimStyleTxtVerticalPosEnum.EXTERN_LINE
        elif self.textVerticalPos.currentIndex() == 3:
            self.dimStyle.textVerticalPos = QadDimStyleTxtVerticalPosEnum.BELOW_LINE

        # textHorizontalPos
        if self.textHorizontalPos.currentIndex() == 0:
            self.dimStyle.textHorizontalPos = QadDimStyleTxtHorizontalPosEnum.CENTERED_LINE
        elif self.textHorizontalPos.currentIndex() == 1:
            self.dimStyle.textHorizontalPos = QadDimStyleTxtHorizontalPosEnum.FIRST_EXT_LINE
        elif self.textHorizontalPos.currentIndex() == 2:
            self.dimStyle.textHorizontalPos = QadDimStyleTxtHorizontalPosEnum.SECOND_EXT_LINE
        elif self.textHorizontalPos.currentIndex() == 3:
            self.dimStyle.textHorizontalPos = QadDimStyleTxtHorizontalPosEnum.FIRST_EXT_LINE_UP
        elif self.textHorizontalPos.currentIndex() == 4:
            self.dimStyle.textHorizontalPos = QadDimStyleTxtHorizontalPosEnum.SECOND_EXT_LINE_UP

        # textDirection
        if self.textDirection.currentIndex() == 0:
            self.dimStyle.textDirection = QadDimStyleTxtDirectionEnum.SX_TO_DX
        elif self.textDirection.currentIndex() == 1:
            self.dimStyle.textDirection = QadDimStyleTxtDirectionEnum.DX_TO_SX

        self.dimStyle.textOffsetDist = self.textOffsetDist.value()

        # textForcedRot
        if self.textRotModeHorizontal.isChecked():
            self.dimStyle.textRotMode = QadDimStyleTxtRotModeEnum.HORIZONTAL
        elif self.textRotModeAligned.isChecked():
            self.dimStyle.textRotMode = QadDimStyleTxtRotModeEnum.ALIGNED_LINE
        elif self.textRotModeISO.isChecked():
            self.dimStyle.textRotMode = QadDimStyleTxtRotModeEnum.ISO
        elif self.textRotModeFixedRot.isChecked():
            self.dimStyle.textRotMode = QadDimStyleTxtRotModeEnum.FORCED_ROTATION

        self.dimStyle.textForcedRot = qad_utils.toRadians(
            self.textForcedRot.value())
    def rotate(self, entity, basePt, angle, rotFldName):
        # entity = entità da ruotare
        # basePt = punto base
        # angle = angolo di rotazione in gradi
        # rotFldName = campo della tabella che memorizza la rotazione
        # verifico se l'entità appartiene ad uno stile di quotatura
        if entity.whatIs() == "ENTITY":
            f = entity.getFeature()
            # ruoto l'entità
            f.setGeometry(
                qad_utils.rotateQgsGeometry(entity.getGeometry(), basePt,
                                            angle))
            if len(rotFldName) > 0:
                rotValue = f.attribute(rotFldName)
                # a volte vale None e a volte null (vai a capire...)
                rotValue = 0 if rotValue is None or isinstance(
                    rotValue, QPyNullVariant) else qad_utils.toRadians(
                        rotValue
                    )  # la rotazione é in gradi nel campo della feature
                rotValue = rotValue + angle
                f.setAttribute(
                    rotFldName,
                    qad_utils.toDegrees(qad_utils.normalizeAngle(rotValue)))

            if self.copyEntities == False:
                # plugIn, layer, feature, refresh, check_validity
                if qad_layer.updateFeatureToLayer(self.plugIn, entity.layer, f,
                                                  False, False) == False:
                    return False
            else:
                # plugIn, layer, features, coordTransform, refresh, check_validity
                if qad_layer.addFeatureToLayer(self.plugIn, entity.layer, f,
                                               None, False, False) == False:
                    return False

        elif entity.whatIs() == "DIMENTITY":
            # stiro la quota
            if self.copyEntities == False:
                if entity.deleteToLayers(self.plugIn) == False:
                    return False
            newDimEntity = QadDimEntity(entity)  # la copio
            newDimEntity.rotate(basePt, angle)
            if newDimEntity.addToLayers(self.plugIn) == False:
                return False

        return True
 def accept_text_tab(self):
    self.dimStyle.textFont = self.textFont.currentText()
    self.dimStyle.textColor = self.textColor.color().name()
    self.dimStyle.textHeight = self.textHeight.value()
    
    # textVerticalPos
    if self.textVerticalPos.currentIndex() == 0:
       self.dimStyle.textVerticalPos = QadDimStyleTxtVerticalPosEnum.CENTERED_LINE
    elif self.textVerticalPos.currentIndex() == 1:
       self.dimStyle.textVerticalPos = QadDimStyleTxtVerticalPosEnum.ABOVE_LINE
    elif self.textVerticalPos.currentIndex() == 2:
       self.dimStyle.textVerticalPos = QadDimStyleTxtVerticalPosEnum.EXTERN_LINE
    elif self.textVerticalPos.currentIndex() == 3:
       self.dimStyle.textVerticalPos = QadDimStyleTxtVerticalPosEnum.BELOW_LINE
 
    # textHorizontalPos
    if self.textHorizontalPos.currentIndex() == 0:
       self.dimStyle.textHorizontalPos = QadDimStyleTxtHorizontalPosEnum.CENTERED_LINE
    elif self.textHorizontalPos.currentIndex() == 1:
       self.dimStyle.textHorizontalPos = QadDimStyleTxtHorizontalPosEnum.FIRST_EXT_LINE
    elif self.textHorizontalPos.currentIndex() == 2:
       self.dimStyle.textHorizontalPos = QadDimStyleTxtHorizontalPosEnum.SECOND_EXT_LINE
    elif self.textHorizontalPos.currentIndex() == 3:
       self.dimStyle.textHorizontalPos = QadDimStyleTxtHorizontalPosEnum.FIRST_EXT_LINE_UP
    elif self.textHorizontalPos.currentIndex() == 4:
       self.dimStyle.textHorizontalPos = QadDimStyleTxtHorizontalPosEnum.SECOND_EXT_LINE_UP
    
    # textDirection
    if self.textDirection.currentIndex() == 0:
       self.dimStyle.textDirection = QadDimStyleTxtDirectionEnum.SX_TO_DX
    elif self.textDirection.currentIndex() == 1:
       self.dimStyle.textDirection = QadDimStyleTxtDirectionEnum.DX_TO_SX
    
    self.dimStyle.textOffsetDist = self.textOffsetDist.value()
    
    # textForcedRot
    if self.textRotModeHorizontal.isChecked():
       self.dimStyle.textRotMode = QadDimStyleTxtRotModeEnum.HORIZONTAL
    elif self.textRotModeAligned.isChecked():
       self.dimStyle.textRotMode = QadDimStyleTxtRotModeEnum.ALIGNED_LINE
    elif self.textRotModeISO.isChecked():
       self.dimStyle.textRotMode = QadDimStyleTxtRotModeEnum.ISO
    elif self.textRotModeFixedRot.isChecked():
       self.dimStyle.textRotMode = QadDimStyleTxtRotModeEnum.FORCED_ROTATION
   
    self.dimStyle.textForcedRot = qad_utils.toRadians(self.textForcedRot.value())
   def mirror(self, entity, pt1, pt2, rotFldName):
      # entity = entità da specchiare
      # pt1 e pt2 = linea di simmetria
      # rotFldName = campo della tabella che memorizza la rotazione
      # verifico se l'entità appartiene ad uno stile di quotatura
      if entity.whatIs() == "ENTITY":
         f = entity.getFeature()
         # specchio l'entità
         f.setGeometry(qad_utils.mirrorQgsGeometry(entity.getGeometry(), pt1, pt2))
         if len(rotFldName) > 0:
            rotValue = f.attribute(rotFldName)
            rotValue = 0 if rotValue is None else qad_utils.toRadians(rotValue) # la rotazione é in gradi nel campo della feature
            ptDummy = qad_utils.getPolarPointByPtAngle(pt1, rotValue, 1)
            mirrorAngle = qad_utils.getAngleBy2Pts(pt1, pt2)
            ptDummy = qad_utils.mirrorPoint(ptDummy, pt1, mirrorAngle)
            rotValue = qad_utils.getAngleBy2Pts(pt1, ptDummy)
            f.setAttribute(rotFldName, qad_utils.toDegrees(qad_utils.normalizeAngle(rotValue)))               
                  
         if self.copyEntities == False:
            # plugIn, layer, feature, refresh, check_validity
            if qad_layer.updateFeatureToLayer(self.plugIn, entity.layer, f, False, False) == False:
               return False
         else:             
            # plugIn, layer, features, coordTransform, refresh, check_validity
            if qad_layer.addFeatureToLayer(self.plugIn, entity.layer, f, None, False, False) == False:
               return False
      elif entity.whatIs() == "DIMENTITY":
         mirrorAngle = qad_utils.getAngleBy2Pts(pt1, pt2)
         # specchio la quota
         if self.copyEntities == False:
            if entity.deleteToLayers(self.plugIn) == False:
               return False           
         entity.mirror(self.plugIn, pt1, mirrorAngle)
         if entity.addToLayers(self.plugIn) == False:
            return False             

      return True
   def rotate(self, f, basePt, angle, rotFldName, layerEntitySet, entitySet):
      # verifico se l'entità appartiene ad uno stile di quotatura
      dimEntity = QadDimStyles.getDimEntity(layerEntitySet.layer, f.id())
      
      if dimEntity is None:
         # ruoto la feature e la rimuovo da entitySet (é la prima)
         f.setGeometry(qad_utils.rotateQgsGeometry(f.geometry(), basePt, angle))

         if len(rotFldName) > 0:
            rotValue = f.attribute(rotFldName)
            rotValue = 0 if rotValue is None else qad_utils.toRadians(rotValue) # la rotazione é in gradi nel campo della feature
            rotValue = rotValue + angle
            f.setAttribute(rotFldName, qad_utils.toDegrees(qad_utils.normalizeAngle(rotValue)))               

         if self.copyFeatures == False:
            # plugIn, layer, feature, refresh, check_validity
            if qad_layer.updateFeatureToLayer(self.plugIn, layerEntitySet.layer, f, False, False) == False:
               self.plugIn.destroyEditCommand()
               return False
         else:             
            # plugIn, layer, features, coordTransform, refresh, check_validity
            if qad_layer.addFeatureToLayer(self.plugIn, layerEntitySet.layer, f, None, False, False) == False:
               self.plugIn.destroyEditCommand()
               return False
         del layerEntitySet.featureIds[0]
      else:
         # ruoto la quota e la rimuovo da entitySet
         dimEntitySet = dimEntity.getEntitySet()
         if self.copyFeatures == False:
            if dimEntity.deleteToLayers(self.plugIn) == False:
               return False                      
         dimEntity.rotate(self.plugIn, basePt, angle)
         if dimEntity.addToLayers(self.plugIn) == False:
            return False             
         entitySet.subtract(dimEntitySet)
            
      return True
   def mirror(self, f, pt1, pt2, rotFldName, layerEntitySet, entitySet, dimEntity):
      
      if dimEntity is None:
         # scalo la feature e la rimuovo da entitySet (é la prima)
         f.setGeometry(qad_utils.mirrorQgsGeometry(f.geometry(), pt1, pt2))
         if len(rotFldName) > 0:
            rotValue = f.attribute(rotFldName)
            rotValue = 0 if rotValue is None else qad_utils.toRadians(rotValue) # la rotazione é in gradi nel campo della feature
            ptDummy = qad_utils.getPolarPointByPtAngle(pt1, rotValue, 1)
            mirrorAngle = qad_utils.getAngleBy2Pts(pt1, pt2)
            ptDummy = qad_utils.mirrorPoint(ptDummy, pt1, mirrorAngle)
            rotValue = qad_utils.getAngleBy2Pts(pt1, ptDummy)
            f.setAttribute(rotFldName, qad_utils.toDegrees(qad_utils.normalizeAngle(rotValue)))               
                  
         if self.copyFeatures == False:
            # plugIn, layer, feature, refresh, check_validity
            if qad_layer.updateFeatureToLayer(self.plugIn, layerEntitySet.layer, f, False, False) == False:
               self.plugIn.destroyEditCommand()
               return False
         else:             
            # plugIn, layer, features, coordTransform, refresh, check_validity
            if qad_layer.addFeatureToLayer(self.plugIn, layerEntitySet.layer, f, None, False, False) == False:
               self.plugIn.destroyEditCommand()
               return False

         del layerEntitySet.featureIds[0]
      else:
         # scalo la quota e la rimuovo da entitySet
         mirrorAngle = qad_utils.getAngleBy2Pts(pt1, pt2)
         dimEntitySet = dimEntity.getEntitySet()
         if self.copyFeatures == False:
            if dimEntity.deleteToLayers(self.plugIn) == False:
               return False                      
         dimEntity.mirror(self.plugIn, pt1, mirrorAngle)
         if dimEntity.addToLayers(self.plugIn) == False:
            return False             
         entitySet.subtract(dimEntitySet)
Exemple #11
0
def doMoveAndRotateGeom(plugIn, f, g, layer, offSetX, offSetY, angle,
                        rotFldName, basePt, coordTransform, addToLayer,
                        highlightObj):
    # funzione di ausilio
    newGeom = qad_utils.moveQgsGeometry(g, offSetX, offSetY)
    if angle is not None:
        newGeom = qad_utils.rotateQgsGeometry(newGeom, basePt, angle)

    newGeom.transform(coordTransform)

    if addToLayer:
        newF = QgsFeature(f)  # la copio perchè altrimenti qgis si incarta
        newF.setGeometry(newGeom)

        if len(rotFldName) > 0:
            rotValue = newF.attribute(rotFldName)
            # a volte vale None e a volte null (vai a capire...)
            rotValue = 0 if rotValue is None or isinstance(
                rotValue, QPyNullVariant) else qad_utils.toRadians(
                    rotValue
                )  # la rotazione é in gradi nel campo della feature
            rotValue = rotValue + angle
            newF.setAttribute(
                rotFldName,
                qad_utils.toDegrees(qad_utils.normalizeAngle(rotValue)))

        # plugIn, layer, feature, coordTransform, refresh, check_validity
        if qad_layer.addFeatureToLayer(plugIn, layer, newF, None, False,
                                       False) == False:
            return False

    if highlightObj is not None:
        highlightObj.addGeometry(newGeom, layer)

    del newGeom

    return True
Exemple #12
0
    def rotate(self, basePt, angle):
        # basePt = punto base espresso in map coordinate
        # restituisce una feature ruotata
        canvas = qgis.utils.iface.mapCanvas()
        destinationCrs = canvas.mapSettings().destinationCrs()

        f = self.getFeature()
        g = g.geometry()
        g.transform(QgsCoordinateTransform(self.crs(), destinationCrs))
        # ruoto la feature
        g = qad_utils.rotateQgsGeometry(g, basePt, angle)
        g.transform(QgsCoordinateTransform(destinationCrs, self.crs()))
        f.setGeometry(g)

        rotFldName = ""
        if self.getEntityType() == QadEntityGeomTypeEnum.TEXT:
            # se la rotazione dipende da un solo campo
            rotFldNames = qad_label.get_labelRotationFieldNames(self.layer)
            if len(rotFldNames) == 1 and len(rotFldNames[0]) > 0:
                rotFldName = rotFldNames[0]
        elif self.getEntityType() == QadEntityGeomTypeEnum.SYMBOL:
            rotFldName = qad_layer.get_symbolRotationFieldName(self.layer)

        if len(rotFldName) > 0:
            rotValue = f.attribute(rotFldName)
            # a volte vale None e a volte null (vai a capire...)
            rotValue = 0 if rotValue is None or isinstance(
                rotValue, QPyNullVariant) else qad_utils.toRadians(
                    rotValue
                )  # la rotazione é in gradi nel campo della feature
            rotValue = rotValue + angle
            f.setAttribute(
                rotFldName,
                qad_utils.toDegrees(qad_utils.normalizeAngle(rotValue)))

        return f
   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
      if self.step == 0: # inizio del comando
         if self.entitySet.isEmpty(): # non ci sono oggetti da ruotare
            return True
         self.showMsg(QadMsg.translate("Command_GRIPROTATE", "\n** ROTATE **\n"))
         # si appresta ad attendere un punto di rotazione
         self.waitForRotatePoint()
         return False
      
      #=========================================================================
      # RISPOSTA ALLA RICHIESTA DI UN PUNTO DI ROTAZIONE
      elif self.step == 1:
         ctrlKey = False
         if msgMapTool == True: # il punto arriva da una selezione grafica
            # la condizione seguente si verifica se durante la selezione di un punto
            # é stato attivato un altro plugin che ha disattivato Qad
            # quindi stato riattivato il comando che torna qui senza che il maptool
            # abbia selezionato un punto            
            if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
               if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
                  value = None
               else:
                  self.setMapTool(self.getPointMapTool()) # riattivo il maptool
                  return False
            else:
               value = self.getPointMapTool().point

            ctrlKey = self.getPointMapTool().ctrlKey
         else: # il punto arriva come parametro della funzione
            value = msg

         if type(value) == unicode:
            if value == QadMsg.translate("Command_GRIPROTATE", "Base point") or value == "Base point":
               # si appresta ad attendere il punto base
               self.waitForBasePt()
            elif value == QadMsg.translate("Command_GRIPROTATE", "Copy") or value == "Copy":
               # Copia entità lasciando inalterate le originali
               self.copyEntities = True                     
               # si appresta ad attendere un punto di rotazione
               self.waitForRotatePoint()
            elif value == QadMsg.translate("Command_GRIPROTATE", "Undo") or value == "Undo":
               if self.nOperationsToUndo > 0: 
                  self.nOperationsToUndo = self.nOperationsToUndo - 1
                  self.plugIn.undoEditCommand()
               else:
                  self.showMsg(QadMsg.translate("QAD", "\nThe command has been canceled."))                  
               # si appresta ad attendere un punto di rotazione
               self.waitForRotatePoint()
            elif value == QadMsg.translate("Command_GRIPROTATE", "Reference") or value == "Reference":
               # si appresta ad attendere l'angolo di riferimento                      
               self.waitForReferenceRot()
            elif value == QadMsg.translate("Command_GRIPROTATE", "eXit") or value == "eXit":
               return True # fine comando
         elif type(value) == QgsPoint or type(value) == float: # se é stato inserito l'angolo di rotazione
            if type(value) == QgsPoint: # se é stato inserito l'angolo di rotazione con un punto
               angle = qad_utils.getAngleBy2Pts(self.basePt, value)
            else:
               angle = qad_utils.toRadians(value)
            angle = angle - self.ReferenceAng
            self.plugIn.setLastRot(angle)

            if ctrlKey:
               self.copyEntities = True
            
            self.rotateFeatures(angle)

            if self.copyEntities == False:
               return True

            # si appresta ad attendere un punto di rotazione
            self.waitForRotatePoint()
          
         else:
            if self.copyEntities == False:
               self.skipToNextGripCommand = True
            return True # fine comando
                                          
         return False 

              
      #=========================================================================
      # RISPOSTA ALLA RICHIESTA PUNTO BASE (da step = 1)
      elif self.step == 2: # dopo aver atteso un punto
         if msgMapTool == True: # il punto arriva da una selezione grafica
            # la condizione seguente si verifica se durante la selezione di un punto
            # é stato attivato un altro plugin che ha disattivato Qad
            # quindi stato riattivato il comando che torna qui senza che il maptool
            # abbia selezionato un punto            
            if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
               if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
                  pass # opzione di default "spostamento"
               else:
                  self.setMapTool(self.getPointMapTool()) # riattivo il maptool
                  return False

            value = self.getPointMapTool().point
         else: # il punto arriva come parametro della funzione
            value = msg

         if type(value) == QgsPoint: # se é stato inserito il punto base
            self.basePt.set(value.x(), value.y())
            # imposto il map tool
            self.getPointMapTool().basePt = self.basePt
            
         # si appresta ad attendere un punto di rotazione
         self.waitForRotatePoint()

         return False


      #=========================================================================
      # RISPOSTA ALLA RICHIESTA PRIMO PUNTO PER ANGOLO ROTAZIONE DI RIFERIMENTO (da step = 1)
      elif self.step == 3: # dopo aver atteso un punto o un numero reale si riavvia il comando
         if msgMapTool == True: # il punto arriva da una selezione grafica
            # la condizione seguente si verifica se durante la selezione di un punto
            # é stato attivato un altro plugin che ha disattivato Qad
            # quindi stato riattivato il comando che torna qui senza che il maptool
            # abbia selezionato un punto            
            if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
               if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
                  return True # fine comando
               else:
                  self.setMapTool(self.getPointMapTool()) # riattivo il maptool
                  return False

            value = self.getPointMapTool().point
         else: # il punto arriva come parametro della funzione
            value = msg

         if type(value) == float: # se é stato inserito l'angolo di rotazione
            self.ReferenceAng = qad_utils.toRadians(value)
            self.getPointMapTool().ReferenceAng = self.ReferenceAng 
            # si appresta ad attendere un punto di rotazione
            self.waitForRotatePoint()

         elif type(value) == QgsPoint: # se é stato inserito l'angolo di rotazione con un punto                                 
            self.Pt1ReferenceAng = QgsPoint(value)
            self.getPointMapTool().Pt1ReferenceAng = self.Pt1ReferenceAng 
            # imposto il map tool
            self.getPointMapTool().setMode(Qad_rotate_maptool_ModeEnum.FIRST_PT_KNOWN_ASK_FOR_SECOND_PT_REFERENCE_ANG)
            # si appresta ad attendere un punto
            self.waitForPoint(QadMsg.translate("Command_GRIPROTATE", "Specify second point: "))
            self.step = 4
            
         return False

      #=========================================================================
      # RISPOSTA ALLA RICHIESTA SECONDO PUNTO PER NUOVO ANGOLO ROTAZIONE (da step = 3)
      elif self.step == 4: # dopo aver atteso un punto o un numero reale si riavvia il comando
         if msgMapTool == True: # il punto arriva da una selezione grafica
            # la condizione seguente si verifica se durante la selezione di un punto
            # é stato attivato un altro plugin che ha disattivato Qad
            # quindi stato riattivato il comando che torna qui senza che il maptool
            # abbia selezionato un punto            
            if self.getPointMapTool().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 l'angolo di rotazione
            if type(value) == QgsPoint: # se é stato inserito l'angolo di rotazione con un punto                        
               self.ReferenceAng = qad_utils.getAngleBy2Pts(self.Pt1ReferenceAng, value)
            else:
               self.ReferenceAng = qad_utils.toRadians(value)
            self.getPointMapTool().ReferenceAng = self.ReferenceAng 
            
         # si appresta ad attendere un punto di rotazione
         self.waitForRotatePoint()
         
         return False
Exemple #14
0
   def rotate(self, basePt, angle):
      # basePt = punto base espresso in map coordinate
      # restituisce una feature ruotata
      canvas = qgis.utils.iface.mapCanvas()
      destinationCrs = canvas.mapSettings().destinationCrs()

      f = self.getFeature()
      g = g.geometry()
      g.transform(QgsCoordinateTransform(self.crs(), destinationCrs))
      # ruoto la feature
      g = qad_utils.rotateQgsGeometry(g, basePt, angle)
      g.transform(QgsCoordinateTransform(destinationCrs, self.crs()))
      f.setGeometry(g)
      
      rotFldName = ""
      if self.getEntityType() == QadEntityGeomTypeEnum.TEXT:
         # se la rotazione dipende da un solo campo
         rotFldNames = qad_label.get_labelRotationFieldNames(self.layer)
         if len(rotFldNames) == 1 and len(rotFldNames[0]) > 0:
            rotFldName = rotFldNames[0]         
      elif self.getEntityType() == QadEntityGeomTypeEnum.SYMBOL:
         rotFldName = qad_layer.get_symbolRotationFieldName(self.layer)
      
      if len(rotFldName) > 0:
         rotValue = f.attribute(rotFldName)
         # a volte vale None e a volte null (vai a capire...)
         rotValue = 0 if rotValue is None or isinstance(rotValue, QPyNullVariant) else qad_utils.toRadians(rotValue) # la rotazione é in gradi nel campo della feature
         rotValue = rotValue + angle
         f.setAttribute(rotFldName, qad_utils.toDegrees(qad_utils.normalizeAngle(rotValue)))               

      return f
    def run(self, msgMapTool=False, msg=None):
        if self.plugIn.canvas.mapSettings().destinationCrs().geographicFlag():
            self.showMsg(
                QadMsg.translate(
                    "QAD",
                    "\nThe coordinate reference system of the project must be a projected coordinate system.\n"
                ))
            return True  # fine comando

        #=========================================================================
        # RICHIESTA SELEZIONE OGGETTI
        if self.step == 0:  # inizio del comando
            if self.entitySet.isEmpty():  # non ci sono oggetti da ruotare
                return True
            self.showMsg(
                QadMsg.translate("Command_GRIPROTATE", "\n** ROTATE **\n"))
            # si appresta ad attendere un punto di rotazione
            self.waitForRotatePoint()
            return False

        #=========================================================================
        # RISPOSTA ALLA RICHIESTA DI UN PUNTO DI ROTAZIONE
        elif self.step == 1:
            ctrlKey = False
            if msgMapTool == True:  # il punto arriva da una selezione grafica
                # la condizione seguente si verifica se durante la selezione di un punto
                # é stato attivato un altro plugin che ha disattivato Qad
                # quindi stato riattivato il comando che torna qui senza che il maptool
                # abbia selezionato un punto
                if self.getPointMapTool(
                ).point is None:  # il maptool é stato attivato senza un punto
                    if self.getPointMapTool(
                    ).rightButton == True:  # se usato il tasto destro del mouse
                        value = None
                    else:
                        self.setMapTool(
                            self.getPointMapTool())  # riattivo il maptool
                        return False
                else:
                    value = self.getPointMapTool().point

                ctrlKey = self.getPointMapTool().ctrlKey
            else:  # il punto arriva come parametro della funzione
                value = msg

            if type(value) == unicode:
                if value == QadMsg.translate(
                        "Command_GRIPROTATE",
                        "Base point") or value == "Base point":
                    # si appresta ad attendere il punto base
                    self.waitForBasePt()
                elif value == QadMsg.translate("Command_GRIPROTATE",
                                               "Copy") or value == "Copy":
                    # Copia entità lasciando inalterate le originali
                    self.copyEntities = True
                    # si appresta ad attendere un punto di rotazione
                    self.waitForRotatePoint()
                elif value == QadMsg.translate("Command_GRIPROTATE",
                                               "Undo") or value == "Undo":
                    if self.nOperationsToUndo > 0:
                        self.nOperationsToUndo = self.nOperationsToUndo - 1
                        self.plugIn.undoEditCommand()
                    else:
                        self.showMsg(
                            QadMsg.translate(
                                "QAD", "\nThe command has been canceled."))
                    # si appresta ad attendere un punto di rotazione
                    self.waitForRotatePoint()
                elif value == QadMsg.translate(
                        "Command_GRIPROTATE",
                        "Reference") or value == "Reference":
                    # si appresta ad attendere l'angolo di riferimento
                    self.waitForReferenceRot()
                elif value == QadMsg.translate("Command_GRIPROTATE",
                                               "eXit") or value == "eXit":
                    return True  # fine comando
            elif type(value) == QgsPoint or type(
                    value
            ) == float:  # se é stato inserito l'angolo di rotazione
                if type(
                        value
                ) == QgsPoint:  # se é stato inserito l'angolo di rotazione con un punto
                    angle = qad_utils.getAngleBy2Pts(self.basePt, value)
                else:
                    angle = qad_utils.toRadians(value)
                angle = angle - self.ReferenceAng
                self.plugIn.setLastRot(angle)

                if ctrlKey:
                    self.copyEntities = True

                self.rotateFeatures(angle)

                if self.copyEntities == False:
                    return True

                # si appresta ad attendere un punto di rotazione
                self.waitForRotatePoint()

            else:
                if self.copyEntities == False:
                    self.skipToNextGripCommand = True
                return True  # fine comando

            return False

        #=========================================================================
        # RISPOSTA ALLA RICHIESTA PUNTO BASE (da step = 1)
        elif self.step == 2:  # dopo aver atteso un punto
            if msgMapTool == True:  # il punto arriva da una selezione grafica
                # la condizione seguente si verifica se durante la selezione di un punto
                # é stato attivato un altro plugin che ha disattivato Qad
                # quindi stato riattivato il comando che torna qui senza che il maptool
                # abbia selezionato un punto
                if self.getPointMapTool(
                ).point is None:  # il maptool é stato attivato senza un punto
                    if self.getPointMapTool(
                    ).rightButton == True:  # se usato il tasto destro del mouse
                        pass  # opzione di default "spostamento"
                    else:
                        self.setMapTool(
                            self.getPointMapTool())  # riattivo il maptool
                        return False

                value = self.getPointMapTool().point
            else:  # il punto arriva come parametro della funzione
                value = msg

            if type(value) == QgsPoint:  # se é stato inserito il punto base
                self.basePt.set(value.x(), value.y())
                # imposto il map tool
                self.getPointMapTool().basePt = self.basePt

            # si appresta ad attendere un punto di rotazione
            self.waitForRotatePoint()

            return False

        #=========================================================================
        # RISPOSTA ALLA RICHIESTA PRIMO PUNTO PER ANGOLO ROTAZIONE DI RIFERIMENTO (da step = 1)
        elif self.step == 3:  # dopo aver atteso un punto o un numero reale si riavvia il comando
            if msgMapTool == True:  # il punto arriva da una selezione grafica
                # la condizione seguente si verifica se durante la selezione di un punto
                # é stato attivato un altro plugin che ha disattivato Qad
                # quindi stato riattivato il comando che torna qui senza che il maptool
                # abbia selezionato un punto
                if self.getPointMapTool(
                ).point is None:  # il maptool é stato attivato senza un punto
                    if self.getPointMapTool(
                    ).rightButton == True:  # se usato il tasto destro del mouse
                        return True  # fine comando
                    else:
                        self.setMapTool(
                            self.getPointMapTool())  # riattivo il maptool
                        return False

                value = self.getPointMapTool().point
            else:  # il punto arriva come parametro della funzione
                value = msg

            if type(value
                    ) == float:  # se é stato inserito l'angolo di rotazione
                self.ReferenceAng = qad_utils.toRadians(value)
                self.getPointMapTool().ReferenceAng = self.ReferenceAng
                # si appresta ad attendere un punto di rotazione
                self.waitForRotatePoint()

            elif type(
                    value
            ) == QgsPoint:  # se é stato inserito l'angolo di rotazione con un punto
                self.Pt1ReferenceAng = QgsPoint(value)
                self.getPointMapTool().Pt1ReferenceAng = self.Pt1ReferenceAng
                # imposto il map tool
                self.getPointMapTool().setMode(
                    Qad_rotate_maptool_ModeEnum.
                    FIRST_PT_KNOWN_ASK_FOR_SECOND_PT_REFERENCE_ANG)
                # si appresta ad attendere un punto
                self.waitForPoint(
                    QadMsg.translate("Command_GRIPROTATE",
                                     "Specify second point: "))
                self.step = 4

            return False

        #=========================================================================
        # RISPOSTA ALLA RICHIESTA SECONDO PUNTO PER NUOVO ANGOLO ROTAZIONE (da step = 3)
        elif self.step == 4:  # dopo aver atteso un punto o un numero reale si riavvia il comando
            if msgMapTool == True:  # il punto arriva da una selezione grafica
                # la condizione seguente si verifica se durante la selezione di un punto
                # é stato attivato un altro plugin che ha disattivato Qad
                # quindi stato riattivato il comando che torna qui senza che il maptool
                # abbia selezionato un punto
                if self.getPointMapTool(
                ).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 l'angolo di rotazione
                if type(
                        value
                ) == QgsPoint:  # se é stato inserito l'angolo di rotazione con un punto
                    self.ReferenceAng = qad_utils.getAngleBy2Pts(
                        self.Pt1ReferenceAng, value)
                else:
                    self.ReferenceAng = qad_utils.toRadians(value)
                self.getPointMapTool().ReferenceAng = self.ReferenceAng

            # si appresta ad attendere un punto di rotazione
            self.waitForRotatePoint()

            return False
    def run(self, msgMapTool=False, msg=None):
        if self.plugIn.canvas.mapSettings().destinationCrs().geographicFlag():
            self.showMsg(
                QadMsg.translate(
                    "QAD",
                    "\nThe coordinate reference system of the project must be a projected coordinate system.\n"
                ))
            return True  # fine comando

        #=========================================================================
        # RICHIESTA SELEZIONE OGGETTI
        if self.step == 0:  # inizio del comando
            if self.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)

        #=========================================================================
        # RUOTA 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_rotate_maptool_ModeEnum.NONE_KNOWN_ASK_FOR_BASE_PT)

            # si appresta ad attendere un punto
            self.waitForPoint(
                QadMsg.translate("Command_ROTATE", "Specify base point: "))

            self.step = 2
            return False

        #=========================================================================
        # RISPOSTA ALLA RICHIESTA PUNTO BASE (da step = 1)
        elif self.step == 2:  # dopo aver atteso un punto o un numero reale si riavvia il comando
            if msgMapTool == True:  # il punto arriva da una selezione grafica
                # la condizione seguente si verifica se durante la selezione di un punto
                # é stato attivato un altro plugin che ha disattivato Qad
                # quindi stato riattivato il comando che torna qui senza che il maptool
                # abbia selezionato un punto
                if self.getPointMapTool(
                ).point is None:  # il maptool é stato attivato senza un punto
                    if self.getPointMapTool(
                    ).rightButton == True:  # se usato il tasto destro del mouse
                        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.basePt = QgsPoint(value)

            self.getPointMapTool().basePt = self.basePt
            self.getPointMapTool().entitySet.set(self.entitySet)
            # si appresta ad attendere l'angolo di rotazione
            self.waitForRotation()

            return False

        #=========================================================================
        # RISPOSTA ALLA RICHIESTA SECONDO PUNTO PER ANGOLO ROTAZIONE (da step = 2)
        elif self.step == 3:  # dopo aver atteso un punto o un numero reale si riavvia il comando
            if msgMapTool == True:  # il punto arriva da una selezione grafica
                # la condizione seguente si verifica se durante la selezione di un punto
                # é stato attivato un altro plugin che ha disattivato Qad
                # quindi stato riattivato il comando che torna qui senza che il maptool
                # abbia selezionato un punto
                if self.getPointMapTool(
                ).point is None:  # il maptool é stato attivato senza un punto
                    if self.getPointMapTool(
                    ).rightButton == True:  # se usato il tasto destro del mouse
                        return True  # fine comando
                    else:
                        self.setMapTool(
                            self.getPointMapTool())  # riattivo il maptool
                        return False

                value = self.getPointMapTool().point
            else:  # il punto arriva come parametro della funzione
                value = msg

            if type(value) == unicode:
                if value == QadMsg.translate("Command_ROTATE",
                                             "Copy") or value == "Copy":
                    self.copyFeatures = True
                    self.showMsg(
                        QadMsg.translate(
                            "Command_ROTATE",
                            "\nRotation of a copy of the selected objects."))
                    # si appresta ad attendere l'angolo di rotazione
                    self.waitForRotation()
                elif value == QadMsg.translate(
                        "Command_ROTATE", "Reference") or value == "Reference":
                    # si appresta ad attendere l'angolo di riferimento
                    self.waitForReferenceRot()
            elif type(value) == QgsPoint or type(
                    value
            ) == float:  # se é stato inserito l'angolo di rotazione
                if type(
                        value
                ) == QgsPoint:  # se é stato inserito l'angolo di rotazione con un punto
                    angle = qad_utils.getAngleBy2Pts(self.basePt, value)
                else:
                    angle = qad_utils.toRadians(value)
                self.plugIn.setLastRot(angle)

                self.RotateGeoms(angle)
                return True  # fine comando

            return False

        #=========================================================================
        # RISPOSTA ALLA RICHIESTA PRIMO PUNTO PER ANGOLO ROTAZIONE DI RIFERIMENTO (da step = 3)
        elif self.step == 4:  # dopo aver atteso un punto o un numero reale si riavvia il comando
            if msgMapTool == True:  # il punto arriva da una selezione grafica
                # la condizione seguente si verifica se durante la selezione di un punto
                # é stato attivato un altro plugin che ha disattivato Qad
                # quindi stato riattivato il comando che torna qui senza che il maptool
                # abbia selezionato un punto
                if self.getPointMapTool(
                ).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
                    ) == float:  # se é stato inserito l'angolo di rotazione
                self.ReferenceAng = qad_utils.toRadians(value)
                self.getPointMapTool().ReferenceAng = self.ReferenceAng
                # si appresta ad attendere il nuovo angolo
                self.waitForNewReferenceRot()

            elif type(
                    value
            ) == QgsPoint:  # se é stato inserito l'angolo di rotazione con un punto
                self.Pt1ReferenceAng = QgsPoint(value)
                self.getPointMapTool().Pt1ReferenceAng = self.Pt1ReferenceAng
                # imposto il map tool
                self.getPointMapTool().setMode(
                    Qad_rotate_maptool_ModeEnum.
                    FIRST_PT_KNOWN_ASK_FOR_SECOND_PT_REFERENCE_ANG)
                # si appresta ad attendere un punto
                self.waitForPoint(
                    QadMsg.translate("Command_ROTATE",
                                     "Specify second point: "))
                self.step = 5

            return False

        #=========================================================================
        # RISPOSTA ALLA RICHIESTA SECONDO PUNTO PER ANGOLO ROTAZIONE DI RIFERIMENTO (da step = 4)
        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(
                ).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

            angle = qad_utils.getAngleBy2Pts(self.Pt1ReferenceAng, value)
            self.ReferenceAng = angle
            self.getPointMapTool().ReferenceAng = self.ReferenceAng
            # si appresta ad attendere il nuovo angolo
            self.waitForNewReferenceRot()

            return False

        #=========================================================================
        # RISPOSTA ALLA RICHIESTA SECONDO PUNTO PER NUOVO ANGOLO ROTAZIONE (da step = 4 e 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) == unicode:
                if value == QadMsg.translate("Command_ROTATE",
                                             "Points") or value == "Points":
                    # imposto il map tool
                    self.getPointMapTool().setMode(
                        Qad_rotate_maptool_ModeEnum.
                        ASK_FOR_FIRST_NEW_ROTATION_PT)
                    # si appresta ad attendere un punto
                    self.waitForPoint(
                        QadMsg.translate("Command_ROTATE",
                                         "Specify first point: "))
                    self.step = 7
            elif type(value) == QgsPoint or type(
                    value
            ) == float:  # se é stato inserito l'angolo di rotazione
                if type(
                        value
                ) == QgsPoint:  # se é stato inserito l'angolo di rotazione con un punto
                    angle = qad_utils.getAngleBy2Pts(self.basePt, value)
                else:
                    angle = qad_utils.toRadians(value)

                angle = angle - self.ReferenceAng
                self.plugIn.setLastRot(angle)
                self.RotateGeoms(angle)
                return True  # fine comando

            return False

        #=========================================================================
        # RISPOSTA ALLA RICHIESTA PRIMO PUNTO PER NUOVO ANGOLO ROTAZIONE (da step = 6)
        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
                        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.Pt1NewAng = value
            # imposto il map tool
            self.getPointMapTool().Pt1NewAng = self.Pt1NewAng
            self.getPointMapTool().setMode(
                Qad_rotate_maptool_ModeEnum.
                FIRST_PT_KNOWN_ASK_FOR_SECOND_NEW_ROTATION_PT)
            # si appresta ad attendere un punto
            self.waitForPoint(
                QadMsg.translate("Command_ROTATE", "Specify second point: "))
            self.step = 8

            return False

        #=========================================================================
        # RISPOSTA ALLA RICHIESTA SECONDO PUNTO PER NUOVO ANGOLO ROTAZIONE (da step = 7)
        elif self.step == 8:  # 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

            angle = qad_utils.getAngleBy2Pts(self.Pt1NewAng, value)

            angle = angle - self.ReferenceAng
            self.plugIn.setLastRot(angle)
            self.RotateGeoms(angle)
            return True  # fine comando
Exemple #17
0
def doMoveAndRotateGeom(plugIn, f, g, layer, offSetX, offSetY, angle, rotFldName, basePt, coordTransform, addToLayer, highlightObj):
   # funzione di ausilio
   newGeom = qad_utils.moveQgsGeometry(g, offSetX, offSetY)
   if angle is not None:
      newGeom = qad_utils.rotateQgsGeometry(newGeom, basePt, angle)

   newGeom.transform(coordTransform)

   if addToLayer:
      newF = QgsFeature(f) # la copio perchè altrimenti qgis si incarta
      newF.setGeometry(newGeom)
      
      if len(rotFldName) > 0:
         rotValue = newF.attribute(rotFldName)
         # a volte vale None e a volte null (vai a capire...)
         rotValue = 0 if rotValue is None or isinstance(rotValue, QPyNullVariant) else qad_utils.toRadians(rotValue) # la rotazione é in gradi nel campo della feature
         rotValue = rotValue + angle
         newF.setAttribute(rotFldName, qad_utils.toDegrees(qad_utils.normalizeAngle(rotValue)))               
      
      # plugIn, layer, feature, coordTransform, refresh, check_validity
      if qad_layer.addFeatureToLayer(plugIn, layer, newF, None, False, False) == False:
         return False

   if highlightObj is not None:
      highlightObj.addGeometry(newGeom, layer)
   
   del newGeom
   
   return True
    def run(self, msgMapTool=False, msg=None):
        if self.plugIn.canvas.mapSettings().destinationCrs().geographicFlag():
            self.showMsg(
                QadMsg.translate(
                    "QAD",
                    "\nThe coordinate reference system of the project must be a projected coordinate system.\n"
                ))
            return True  # fine comando

        #=========================================================================
        # RICHIESTA PUNTO o ENTITA'
        if self.step == 0:  # inizio del comando
            # si appresta ad attendere un punto o un numero reale
            # msg, inputType, default, keyWords, valori non nulli
            self.waitFor(self.msg, \
                         QadInputTypeEnum.POINT2D | QadInputTypeEnum.FLOAT, \
                         self.angle, "", \
                         QadInputModeEnum.NOT_NULL)

            if self.startPt is not None:
                # imposto il map tool
                self.getPointMapTool().setDrawMode(
                    QadGetPointDrawModeEnum.ELASTIC_LINE)
                self.getPointMapTool().setStartPoint(self.startPt)

            self.step = 1
            return False

        #=========================================================================
        # RISPOSTA ALLA RICHIESTA PUNTO O NUMERO REALE
        elif self.step == 1:  # dopo aver atteso un punto si riavvia il comando
            if msgMapTool == True:  # il punto arriva da una selezione grafica
                # la condizione seguente si verifica se durante la selezione di un punto
                # é stato attivato un altro plugin che ha disattivato Qad
                # quindi stato riattivato il comando che torna qui senza che il maptool
                # abbia selezionato un punto
                if self.getPointMapTool(
                ).point is None:  # il maptool é stato attivato senza un punto
                    if self.getPointMapTool(
                    ).rightButton == True:  # se usato il tasto destro del mouse
                        return True  # fine comando
                    else:
                        self.setMapTool(
                            self.getPointMapTool())  # riattivo il maptool
                        return False

                value = self.getPointMapTool().point
            else:  # il punto o il numero reale arriva come parametro della funzione
                value = msg

            if value is None:
                return True  # fine comando

            if type(value) == float:
                self.angle = qad_utils.toRadians(value)
                return True  # fine comando
            elif type(value) == QgsPoint:
                # il/i punto/i indicato/i da questa questa funzione non devono alterare lastpoint
                self.plugIn.setLastPoint(self.__prevLastPoint)

                if self.startPt is not None:
                    self.angle = qad_utils.getAngleBy2Pts(self.startPt, value)
                    return True  # fine comando
                else:
                    self.startPt = value
                    # imposto il map tool
                    self.getPointMapTool().setDrawMode(
                        QadGetPointDrawModeEnum.ELASTIC_LINE)
                    self.getPointMapTool().setStartPoint(self.startPt)
                    # si appresta ad attendere un punto
                    self.waitForPoint(
                        QadMsg.translate("QAD", "Specify second point: "))
                    self.step = 2

            return False

        #=========================================================================
        # RISPOSTA ALLA RICHIESTA SECONDO PUNTO DELLA ANGOLO (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
                        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

            # il/i punto/i indicato/i da questa questa funzione non devono alterare lastpoint
            self.plugIn.setLastPoint(self.__prevLastPoint)

            if qad_utils.ptNear(self.startPt, value):
                self.showMsg(
                    QadMsg.translate("QAD", "\nThe points must be different."))
                # si appresta ad attendere un punto
                self.waitForPoint(
                    QadMsg.translate("QAD", "Specify second point: "))
                return False
            else:
                self.angle = qad_utils.getAngleBy2Pts(self.startPt, value)
                return True  # fine comando
Exemple #19
0
   def evaluate(self, cmd):      
      #------------------------------------------------------------------------------
      # nome di un comando
      #------------------------------------------------------------------------------ 
      if self.inputType & QadInputTypeEnum.COMMAND:
         if cmd == "":
            cmd = unicode(self.showLast()) # ripeto ultimo comando
         
         if self.parentWidget().isValidCommand(cmd):
            self.updateHistory(cmd)
            self.parentWidget().runCommand(cmd)
         else:
            msg = QadMsg.translate("QAD", "\nComando sconosciuto \"{0}\".")
            self.showMsg(msg.format(cmd.encode('ascii','ignore')), True) # ripete il prompt
         return

      if cmd == "":
         if self.default is not None:
            if type(self.default) == QgsPoint:
               cmd = self.default.toString()
            else:
               cmd = unicode(self.default)              
               
         if cmd == "" and \
            not (self.inputMode & QadInputModeEnum.NOT_NULL): # permesso input nullo              
            self.parentWidget().continueCommand(None)         
            return
                       
      #------------------------------------------------------------------------------
      # punto 2D
      #------------------------------------------------------------------------------ 
      if self.inputType & QadInputTypeEnum.POINT2D:
         snapType = qad_utils.str2snapTypeEnum(cmd)
         if snapType != -1:
            # se é stato forzato uno snap
            snapParams = qad_utils.str2snapParams(cmd)
            self.parentWidget().forceCommandMapToolSnapTypeOnce(snapType, snapParams)
            self.showMsg(QadMsg.translate("QAD", "\n(impostato snap temporaneo)\n"), True) # ripeti il prompt
            return
         if (self.inputType & QadInputTypeEnum.INT) or \
            (self.inputType & QadInputTypeEnum.LONG) or \
            (self.inputType & QadInputTypeEnum.FLOAT) or \
            (self.inputType & QadInputTypeEnum.ANGLE) or \
            (self.inputType & QadInputTypeEnum.BOOL):
            oneNumberAllowed = False
         else:
            oneNumberAllowed = True
            
         pt = qad_utils.str2QgsPoint(cmd, \
                                     self.parentWidget().getLastPoint(), \
                                     self.parentWidget().getCurrenPointFromCommandMapTool(), \
                                     oneNumberAllowed)
                      
         if pt is not None:
            self.parentWidget().setLastPoint(pt)
            self.parentWidget().continueCommand(pt)
            return
            
      #------------------------------------------------------------------------------
      # punto 3D
      #------------------------------------------------------------------------------ 
      if self.inputType & QadInputTypeEnum.POINT3D: # punto
         pass
      
      #------------------------------------------------------------------------------
      # una parola chiave
      #------------------------------------------------------------------------------ 
      if self.inputType & QadInputTypeEnum.KEYWORDS:
         keyWord = self.evaluateKeyWords(cmd)
               
         if keyWord is not None:
            self.parentWidget().continueCommand(keyWord)
            return
                      
      #------------------------------------------------------------------------------
      # una stringa
      #------------------------------------------------------------------------------ 
      if self.inputType & QadInputTypeEnum.STRING:            
         if cmd is not None:            
            self.parentWidget().continueCommand(cmd)
            return       
                     
      #------------------------------------------------------------------------------
      # un numero intero
      #------------------------------------------------------------------------------ 
      if self.inputType & QadInputTypeEnum.INT:
         num = qad_utils.str2int(cmd)
         if num == 0 and (self.inputMode & QadInputModeEnum.NOT_ZERO): # non permesso valore = 0              
            num = None
         elif num < 0 and (self.inputMode & QadInputModeEnum.NOT_NEGATIVE): # non permesso valore < 0              
            num = None
         elif num > 0 and (self.inputMode & QadInputModeEnum.NOT_POSITIVE): # non permesso valore > 0              
            num = None
               
         if num is not None:
            self.parentWidget().continueCommand(int(num))
            return       
                     
      #------------------------------------------------------------------------------
      # un numero lungo
      #------------------------------------------------------------------------------ 
      if self.inputType & QadInputTypeEnum.LONG:
         num = qad_utils.str2long(cmd)
         if num == 0 and (self.inputMode & QadInputModeEnum.NOT_ZERO): # non permesso valore = 0              
            num = None
         elif num < 0 and (self.inputMode & QadInputModeEnum.NOT_NEGATIVE): # non permesso valore < 0              
            num = None
         elif num > 0 and (self.inputMode & QadInputModeEnum.NOT_POSITIVE): # non permesso valore > 0              
            num = None
            
         if num is not None:
            self.parentWidget().continueCommand(long(num))
            return       
                     
      #------------------------------------------------------------------------------
      # un numero reale
      #------------------------------------------------------------------------------ 
      if self.inputType & QadInputTypeEnum.FLOAT or self.inputType & QadInputTypeEnum.ANGLE:
         num = qad_utils.str2float(cmd)
         if num == 0 and (self.inputMode & QadInputModeEnum.NOT_ZERO): # non permesso valore = 0              
            num = None
         elif num < 0 and (self.inputMode & QadInputModeEnum.NOT_NEGATIVE): # non permesso valore < 0              
            num = None
         elif num > 0 and (self.inputMode & QadInputModeEnum.NOT_POSITIVE): # non permesso valore > 0              
            num = None
            
         if num is not None:
            if self.inputType & QadInputTypeEnum.ANGLE: # se é un angolo in gradi
               # i gradi vanno convertiti in radianti
               num = qad_utils.toRadians(num)            
            self.parentWidget().continueCommand(float(num))         
            return       

      #------------------------------------------------------------------------------
      # un valore booleano
      #------------------------------------------------------------------------------ 
      elif self.inputType & QadInputTypeEnum.BOOL:
         value = qad_utils.str2bool(cmd)
            
         if value is not None:
            self.parentWidget().continueCommand(value)
            return       

      self.showMsg(self.getInvalidInputMsg())
      
      if self.inputType & QadInputTypeEnum.KEYWORDS:
         self.displayKeyWordsPrompt()
      else:
         self.displayPrompt()
         
      return
   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
      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)
      
      #=========================================================================
      # RUOTA 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_rotate_maptool_ModeEnum.NONE_KNOWN_ASK_FOR_BASE_PT)

         # si appresta ad attendere un punto
         self.waitForPoint(QadMsg.translate("Command_ROTATE", "Specify base point: "))
                  
         self.step = 2     
         return False
         
      #=========================================================================
      # RISPOSTA ALLA RICHIESTA PUNTO BASE (da step = 1)
      elif self.step == 2: # dopo aver atteso un punto o un numero reale si riavvia il comando
         if msgMapTool == True: # il punto arriva da una selezione grafica
            # la condizione seguente si verifica se durante la selezione di un punto
            # é stato attivato un altro plugin che ha disattivato Qad
            # quindi stato riattivato il comando che torna qui senza che il maptool
            # abbia selezionato un punto            
            if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
               if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
                  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.basePt = QgsPoint(value)

         self.getPointMapTool().basePt = self.basePt
         self.getPointMapTool().entitySet.set(self.entitySet)
         # si appresta ad attendere l'angolo di rotazione                      
         self.waitForRotation()
         
         return False 
         
      #=========================================================================
      # RISPOSTA ALLA RICHIESTA SECONDO PUNTO PER ANGOLO ROTAZIONE (da step = 2)
      elif self.step == 3: # dopo aver atteso un punto o un numero reale si riavvia il comando
         if msgMapTool == True: # il punto arriva da una selezione grafica
            # la condizione seguente si verifica se durante la selezione di un punto
            # é stato attivato un altro plugin che ha disattivato Qad
            # quindi stato riattivato il comando che torna qui senza che il maptool
            # abbia selezionato un punto            
            if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
               if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
                  return True # fine comando
               else:
                  self.setMapTool(self.getPointMapTool()) # riattivo il maptool
                  return False

            value = self.getPointMapTool().point
         else: # il punto arriva come parametro della funzione
            value = msg

         if type(value) == unicode:
            if value == QadMsg.translate("Command_ROTATE", "Copy") or value == "Copy":
               self.copyFeatures = True
               self.showMsg(QadMsg.translate("Command_ROTATE", "\nRotation of a copy of the selected objects."))
               # si appresta ad attendere l'angolo di rotazione               
               self.waitForRotation()                
            elif value == QadMsg.translate("Command_ROTATE", "Reference") or value == "Reference":
               # si appresta ad attendere l'angolo di riferimento                      
               self.waitForReferenceRot()
         elif type(value) == QgsPoint or type(value) == float: # se é stato inserito l'angolo di rotazione
            if type(value) == QgsPoint: # se é stato inserito l'angolo di rotazione con un punto
               angle = qad_utils.getAngleBy2Pts(self.basePt, value)
            else:
               angle = qad_utils.toRadians(value)
            self.plugIn.setLastRot(angle)

            self.RotateGeoms(angle)
            return True # fine comando
         
         return False

      #=========================================================================
      # RISPOSTA ALLA RICHIESTA PRIMO PUNTO PER ANGOLO ROTAZIONE DI RIFERIMENTO (da step = 3)
      elif self.step == 4: # dopo aver atteso un punto o un numero reale si riavvia il comando
         if msgMapTool == True: # il punto arriva da una selezione grafica
            # la condizione seguente si verifica se durante la selezione di un punto
            # é stato attivato un altro plugin che ha disattivato Qad
            # quindi stato riattivato il comando che torna qui senza che il maptool
            # abbia selezionato un punto            
            if self.getPointMapTool().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) == float: # se é stato inserito l'angolo di rotazione
            self.ReferenceAng = qad_utils.toRadians(value)
            self.getPointMapTool().ReferenceAng = self.ReferenceAng 
            # si appresta ad attendere il nuovo angolo                    
            self.waitForNewReferenceRot()

         elif type(value) == QgsPoint: # se é stato inserito l'angolo di rotazione con un punto                                 
            self.Pt1ReferenceAng = QgsPoint(value)
            self.getPointMapTool().Pt1ReferenceAng = self.Pt1ReferenceAng 
            # imposto il map tool
            self.getPointMapTool().setMode(Qad_rotate_maptool_ModeEnum.FIRST_PT_KNOWN_ASK_FOR_SECOND_PT_REFERENCE_ANG)
            # si appresta ad attendere un punto
            self.waitForPoint(QadMsg.translate("Command_ROTATE", "Specify second point: "))
            self.step = 5           
            
         return False

      #=========================================================================
      # RISPOSTA ALLA RICHIESTA SECONDO PUNTO PER ANGOLO ROTAZIONE DI RIFERIMENTO (da step = 4)
      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().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

         angle = qad_utils.getAngleBy2Pts(self.Pt1ReferenceAng, value)
         self.ReferenceAng = angle
         self.getPointMapTool().ReferenceAng = self.ReferenceAng 
         # si appresta ad attendere il nuovo angolo                    
         self.waitForNewReferenceRot()
            
         return False

      #=========================================================================
      # RISPOSTA ALLA RICHIESTA SECONDO PUNTO PER NUOVO ANGOLO ROTAZIONE (da step = 4 e 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) == unicode:
            if value == QadMsg.translate("Command_ROTATE", "Points") or value == "Points":
               # imposto il map tool
               self.getPointMapTool().setMode(Qad_rotate_maptool_ModeEnum.ASK_FOR_FIRST_NEW_ROTATION_PT)
               # si appresta ad attendere un punto
               self.waitForPoint(QadMsg.translate("Command_ROTATE", "Specify first point: "))
               self.step = 7
         elif type(value) == QgsPoint or type(value) == float: # se é stato inserito l'angolo di rotazione
            if type(value) == QgsPoint: # se é stato inserito l'angolo di rotazione con un punto                        
               angle = qad_utils.getAngleBy2Pts(self.basePt, value)
            else:
               angle = qad_utils.toRadians(value)
            
            angle = angle - self.ReferenceAng
            self.plugIn.setLastRot(angle)
            self.RotateGeoms(angle)
            return True # fine comando

         return False
      
      #=========================================================================
      # RISPOSTA ALLA RICHIESTA PRIMO PUNTO PER NUOVO ANGOLO ROTAZIONE (da step = 6)
      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
                  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.Pt1NewAng = value
         # imposto il map tool
         self.getPointMapTool().Pt1NewAng = self.Pt1NewAng
         self.getPointMapTool().setMode(Qad_rotate_maptool_ModeEnum.FIRST_PT_KNOWN_ASK_FOR_SECOND_NEW_ROTATION_PT)
         # si appresta ad attendere un punto
         self.waitForPoint(QadMsg.translate("Command_ROTATE", "Specify second point: "))
         self.step = 8
            
         return False

      #=========================================================================
      # RISPOSTA ALLA RICHIESTA SECONDO PUNTO PER NUOVO ANGOLO ROTAZIONE (da step = 7)
      elif self.step == 8: # 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
               
         angle = qad_utils.getAngleBy2Pts(self.Pt1NewAng, value)
         
         angle = angle - self.ReferenceAng
         self.plugIn.setLastRot(angle)
         self.RotateGeoms(angle)
         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

      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 PRIMO PUNTO 
      if self.step == 0: # inizio del comando
         self.WaitForFirstCorner()         
         return False

      #=========================================================================
      # RISPOSTA ALLA RICHIESTA DEL PRIMO PUNTO DEL RETTANGOLO (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
            # 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_RECTANGLE", "Window not correct."))
                  self.WaitForFirstCorner()
                  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_RECTANGLE", "Chamfer") or value == "Chamfer":
               if self.GetDistClass is not None:
                  del self.GetDistClass
               self.GetDistClass = QadGetDistClass(self.plugIn)
               prompt = QadMsg.translate("Command_RECTANGLE", "Specify first chamfer distance for rectangle <{0}>: ")
               self.GetDistClass.msg = prompt.format(str(self.gapValue1))
               self.GetDistClass.dist = self.gapValue1
               self.GetDistClass.inputMode = QadInputModeEnum.NOT_NEGATIVE
               self.step = 4
               self.GetDistClass.run(msgMapTool, msg)     
            elif value == QadMsg.translate("Command_RECTANGLE", "Fillet") or value == "Fillet":
               if self.GetDistClass is not None:
                  del self.GetDistClass
               self.GetDistClass = QadGetDistClass(self.plugIn)
               prompt = QadMsg.translate("Command_RECTANGLE", "Specify rectangle fillet radius <{0}>: ")
               self.GetDistClass.msg = prompt.format(str(self.gapValue1))
               self.GetDistClass.dist = self.gapValue1
               self.GetDistClass.inputMode = QadInputModeEnum.NOT_NEGATIVE
               self.step = 3
               self.GetDistClass.run(msgMapTool, msg)     
         elif type(value) == QgsPoint:
            self.firstCorner = value
            self.getPointMapTool().firstCorner = self.firstCorner
            self.WaitForSecondCorner(currLayer)         

         return False # continua


      #=========================================================================
      # RISPOSTA ALLA RICHIESTA DEL SECONDO PUNTO DEL RETTANGOLO (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_RECTANGLE", "Window not correct."))
                  self.WaitForSecondCorner(currLayer)
                  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_RECTANGLE", "Area") or value == "Area":
               msg = QadMsg.translate("Command_RECTANGLE", "Enter rectangle area in current units <{0}>: ")
               # si appresta ad attendere un numero reale         
               # msg, inputType, default, keyWords, valori positivi
               self.waitFor(msg.format(str(self.area)), QadInputTypeEnum.FLOAT, \
                            self.area, "", \
                            QadInputModeEnum.NOT_ZERO | QadInputModeEnum.NOT_NEGATIVE)
               self.getPointMapTool().setMode(Qad_rectangle_maptool_ModeEnum.NONE_KNOWN_ASK_FOR_FIRST_CORNER)
                  
               self.step = 6
            elif value == QadMsg.translate("Command_RECTANGLE", "Dimensions") or value == "Dimensions":
               if self.GetDistClass is not None:
                  del self.GetDistClass
               self.GetDistClass = QadGetDistClass(self.plugIn)
               prompt = QadMsg.translate("Command_RECTANGLE", "Specify length for rectangle <{0}>: ")
               self.GetDistClass.msg = prompt.format(str(self.dim1))
               self.GetDistClass.dist = self.dim1
               self.step = 10
               self.GetDistClass.run(msgMapTool, msg)              
            elif value == QadMsg.translate("Command_RECTANGLE", "Rotation") or value == "Rotation":
               keyWords = QadMsg.translate("Command_RECTANGLE", "Points")
               self.defaultValue = self.rot
               prompt = QadMsg.translate("Command_RECTANGLE", "Specify rotation angle or [{0}] <{1}>: ").format(keyWords, str(qad_utils.toDegrees(self.rot)))
               
               englishKeyWords = "Points"
               keyWords += "_" + englishKeyWords
               # si appresta ad attendere un punto o un numero reale         
               # msg, inputType, default, keyWords, valori non nulli
               self.waitFor(prompt, \
                            QadInputTypeEnum.POINT2D | QadInputTypeEnum.FLOAT | QadInputTypeEnum.KEYWORDS, \
                            self.rot, keyWords)
               self.getPointMapTool().setMode(Qad_rectangle_maptool_ModeEnum.NONE_KNOWN_ASK_FOR_FIRST_CORNER)
               
               self.step = 12
         elif type(value) == QgsPoint:
            self.vertices.extend(qad_utils.getRectByCorners(self.firstCorner, value, self.rot, \
                                                            self.gapType, self.gapValue1, self.gapValue2))

            if self.virtualCmd == False: # se si vuole veramente salvare i buffer in un layer
               self.addRectangleToLayer(currLayer)
            return True       

         return False # continua

      #=========================================================================
      # RISPOSTA ALLA RICHIESTA RAGGIO DI CURVATURA (da step = 1)
      elif self.step == 3:
         if self.GetDistClass.run(msgMapTool, msg) == True:
            if self.GetDistClass.dist is not None:
               self.gapValue1 = self.GetDistClass.dist
               if self.gapValue1 == 0:
                  self.gapType = 0 # 0 = Angoli retti
               else:
                  self.gapType = 1 # 1 = Raccorda i segmenti

            self.WaitForFirstCorner()
            self.getPointMapTool().refreshSnapType() # aggiorno lo snapType che può essere variato dal maptool di distanza                     
         return False # fine comando

      #=========================================================================
      # RISPOSTA ALLA RICHIESTA PRIMA DISTANZA DI CIMATURA (da step = 1)
      elif self.step == 4:
         if self.GetDistClass.run(msgMapTool, msg) == True:
            if self.GetDistClass.dist is not None:
               self.gapValue1 = self.GetDistClass.dist
               
               if self.GetDistClass is not None:
                  del self.GetDistClass
               self.GetDistClass = QadGetDistClass(self.plugIn)
               prompt = QadMsg.translate("Command_RECTANGLE", "Specify second chamfer distance for rectangle <{0}>: ")
               self.GetDistClass.msg = prompt.format(str(self.gapValue2))
               self.GetDistClass.dist = self.gapValue2
               self.GetDistClass.inputMode = QadInputModeEnum.NOT_NEGATIVE
               self.step = 5
               self.GetDistClass.run(msgMapTool, msg)  
            else:   
               self.WaitForFirstCorner()
               self.getPointMapTool().refreshSnapType() # aggiorno lo snapType che può essere variato dal maptool di distanza                                 
         return False # fine comando
 
      #=========================================================================
      # RISPOSTA ALLA RICHIESTA SECONDA DISTANZA DI CIMATURA (da step = 1)
      elif self.step == 5:
         if self.GetDistClass.run(msgMapTool, msg) == True:
            if self.GetDistClass.dist is not None:
               self.gapValue2 = self.GetDistClass.dist               
               if self.gapValue1 == 0 or self.gapValue2 == 0:
                  self.gapType = 0 # 0 = Angoli retti
               else:
                  self.gapType = 2 # 2 = Cima i segmenti
                                   
            self.WaitForFirstCorner()
            self.getPointMapTool().refreshSnapType() # aggiorno lo snapType che può essere variato dal maptool di distanza                     
         return False # fine comando
 
      #=========================================================================
      # RISPOSTA ALLA RICHIESTA AREA RETTANGOLO (da step = 2)
      elif self.step == 6: # dopo aver atteso un punto si riavvia il comando
         keyWords = QadMsg.translate("Command_RECTANGLE", "Length") + "/" + \
                    QadMsg.translate("Command_RECTANGLE", "Width")
         englishKeyWords = "Length" + "/" + "Width"
         
         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.defaultValue = QadMsg.translate("Command_RECTANGLE", "Length")
                  prompt = QadMsg.translate("Command_RECTANGLE", "Calcolate the rectangle dimensions based on [{0}] <{1}>: ").format(keyWords, self.defaultValue)
                        
                  keyWords += "_" + englishKeyWords
                  # si appresta ad attendere una parola chiave         
                  # msg, inputType, default, keyWords, valori positivi
                  self.waitFor(prompt, QadInputTypeEnum.KEYWORDS, \
                               self.defaultValue, \
                               keyWords, QadInputModeEnum.NONE)                  
                  
                  self.step = 7
                  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) == float: # é stata inserita l'area
            self.area = value
            self.defaultValue = QadMsg.translate("Command_RECTANGLE", "Length")
            prompt = QadMsg.translate("Command_RECTANGLE", "Calcolate the rectangle dimensions based on [{0}] <{1}>: ").format(keyWords, self.defaultValue)
                  
            keyWords += "_" + englishKeyWords
            # si appresta ad attendere una parola chiave         
            # msg, inputType, default, keyWords, valori positivi
            self.waitFor(prompt, QadInputTypeEnum.KEYWORDS, \
                         self.defaultValue, \
                         keyWords, QadInputModeEnum.NONE)
            self.step = 7
         return False
            
      #=========================================================================
      # RISPOSTA ALLA RICHIESTA DELLA MODALITA' (LUNGHEZZA / LARGHEZZA) DATA L'AREA (da step = 6)
      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.defaultValue
                  return True # fine comando
               else:
                  self.setMapTool(self.getPointMapTool()) # riattivo il maptool
                  return False
            else:
               return False
         else: # il punto arriva come parametro della funzione
            value = msg

         if value == QadMsg.translate("Command_RECTANGLE", "Length") or value == "Length":
            if self.GetDistClass is not None:
               del self.GetDistClass
            self.GetDistClass = QadGetDistClass(self.plugIn)
            prompt = QadMsg.translate("Command_RECTANGLE", "Enter length for rectangle <{0}>: ")
            self.GetDistClass.msg = prompt.format(str(self.dim1))
            self.GetDistClass.dist = self.dim1
            self.step = 8
            self.GetDistClass.run(msgMapTool, msg)              
         elif value == QadMsg.translate("Command_RECTANGLE", "Width") or value == "Width":
            if self.GetDistClass is not None:
               del self.GetDistClass
            self.GetDistClass = QadGetDistClass(self.plugIn)
            prompt = QadMsg.translate("Command_RECTANGLE", "Enter width for rectangle <{0}>: ")
            self.GetDistClass.msg = prompt.format(str(self.dim1))
            self.GetDistClass.dist = self.dim1
            self.step = 9
            self.GetDistClass.run(msgMapTool, msg)              
            
         return False

      #=========================================================================
      # RISPOSTA ALLA RICHIESTA LUNGHEZZA RETTANGOLO DATA L'AREA (da step = 7)
      elif self.step == 8:
         if self.GetDistClass.run(msgMapTool, msg) == True:
            if self.GetDistClass.dist is not None:
					self.vertices.extend(qad_utils.getRectByAreaAndLength(self.firstCorner, self.area, self.GetDistClass.dist, \
																							self.rot, self.gapType, self.gapValue1, self.gapValue2))	
					if self.virtualCmd == False: # se si vuole veramente salvare i buffer in un layer
						self.addRectangleToLayer(currLayer)
					return True # fine comando		
         return False
            
      #=========================================================================
      # RISPOSTA ALLA RICHIESTA LARGHEZZA RETTANGOLO DATA L'AREA (da step = 7)
      elif self.step == 9:
         if self.GetDistClass.run(msgMapTool, msg) == True:
            if self.GetDistClass.dist is not None:
					self.vertices.extend(qad_utils.getRectByAreaAndWidth(self.firstCorner, self.area, self.GetDistClass.dist, \
																							self.rot, self.gapType, self.gapValue1, self.gapValue2))	
					if self.virtualCmd == False: # se si vuole veramente salvare i buffer in un layer
						self.addRectangleToLayer(currLayer)
					return True # fine comando		
         return False
            
      #=========================================================================
      # RISPOSTA ALLA RICHIESTA LUNGHEZZA RETTANGOLO (da step = 2)
      elif self.step == 10:
         if self.GetDistClass.run(msgMapTool, msg) == True:
            if self.GetDistClass.dist is not None:
               self.dim1 = self.GetDistClass.dist

            if self.GetDistClass is not None:
               del self.GetDistClass
            self.GetDistClass = QadGetDistClass(self.plugIn)
            prompt = QadMsg.translate("Command_RECTANGLE", "Enter width for rectangle <{0}>: ")
            self.GetDistClass.msg = prompt.format(str(self.dim1))
            self.GetDistClass.dist = self.dim1
            self.step = 11
            self.GetDistClass.run(msgMapTool, msg)              
                         
         return False

      #=========================================================================
      # RISPOSTA ALLA RICHIESTA LARGHEZZA RETTANGOLO (da step = 10)
      elif self.step == 11:
         if self.GetDistClass.run(msgMapTool, msg) == True:
            if self.GetDistClass.dist is not None:
               self.vertices.extend(qad_utils.getRectByCornerAndDims(self.firstCorner, self.dim1, self.GetDistClass.dist, \
                                                                     self.rot, self.gapType, self.gapValue1, self.gapValue2))   
               if self.virtualCmd == False: # se si vuole veramente salvare i buffer in un layer
                  self.addRectangleToLayer(currLayer)
               return True # fine comando      
         return False

      #=========================================================================
      # RISPOSTA ALLA RICHIESTA ROTAZIONE RETTANGOLO (da step = 2)
      elif self.step == 12: # 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
                  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_RECTANGLE", "Points") or value == "Points":
               # si appresta ad attendere l'angolo di rotazione                      
               if self.GetAngleClass is not None:
                  del self.GetAngleClass                  
               self.GetAngleClass = QadGetAngleClass(self.plugIn)
               self.GetAngleClass.msg = QadMsg.translate("Command_RECTANGLE", "Specify first point: ")
               self.GetAngleClass.angle = self.rot
               self.step = 13
               self.GetAngleClass.run(msgMapTool, msg)               
         elif type(value) == QgsPoint:
            self.rot = qad_utils.getAngleBy2Pts(self.firstCorner, value)
            self.WaitForSecondCorner(currLayer)
         elif type(value) == float:
            self.rot = qad_utils.toRadians(value)
            self.WaitForSecondCorner(currLayer)
            
         return False # continua
      
      #=========================================================================
      # RISPOSTA ALLA RICHIESTA ROTAZIONE RETTANGOLO (da step = 12)
      elif self.step == 13:
         if self.GetAngleClass.run(msgMapTool, msg) == True:
            if self.GetAngleClass.angle is not None:
               self.rot = self.GetAngleClass.angle
               self.plugIn.setLastRot(self.rot)
               self.WaitForSecondCorner(currLayer)
               self.getPointMapTool().refreshSnapType() # aggiorno lo snapType che può essere variato dal maptool di rotazione                     
Exemple #22
0
   def run(self, msgMapTool = False, msg = None):
      if self.plugIn.canvas.mapSettings().destinationCrs().geographicFlag():
         self.showMsg(QadMsg.translate("QAD", "\nThe coordinate reference system of the project must be a projected coordinate system.\n"))
         return True # fine comando

      #=========================================================================
      # RICHIESTA PUNTO o ENTITA'
      if self.step == 0: # inizio del comando
         # si appresta ad attendere un punto o un numero reale         
         # msg, inputType, default, keyWords, valori non nulli
         self.waitFor(self.msg, \
                      QadInputTypeEnum.POINT2D | QadInputTypeEnum.FLOAT, \
                      self.angle, "", \
                      QadInputModeEnum.NOT_NULL)
         
         if self.startPt is not None:            
            # imposto il map tool
            self.getPointMapTool().setDrawMode(QadGetPointDrawModeEnum.ELASTIC_LINE)
            self.getPointMapTool().setStartPoint(self.startPt)
                           
         self.step = 1
         return False

      #=========================================================================
      # RISPOSTA ALLA RICHIESTA PUNTO O NUMERO REALE
      elif self.step == 1: # dopo aver atteso un punto si riavvia il comando
         if msgMapTool == True: # il punto arriva da una selezione grafica
            # la condizione seguente si verifica se durante la selezione di un punto
            # é stato attivato un altro plugin che ha disattivato Qad
            # quindi stato riattivato il comando che torna qui senza che il maptool
            # abbia selezionato un punto            
            if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
               if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
                  return True # fine comando
               else:
                  self.setMapTool(self.getPointMapTool()) # riattivo il maptool
                  return False
               
            value = self.getPointMapTool().point
         else: # il punto o il numero reale arriva come parametro della funzione
            value = msg

         if value is None:
            return True # fine comando
         
         if type(value) == float:
            self.angle = qad_utils.toRadians(value)
            return True # fine comando
         elif type(value) == QgsPoint:
            # il/i punto/i indicato/i da questa questa funzione non devono alterare lastpoint 
            self.plugIn.setLastPoint(self.__prevLastPoint)
            
            if self.startPt is not None:
               self.angle = qad_utils.getAngleBy2Pts(self.startPt, value)
               return True # fine comando
            else:            
               self.startPt = value            
               # imposto il map tool
               self.getPointMapTool().setDrawMode(QadGetPointDrawModeEnum.ELASTIC_LINE)
               self.getPointMapTool().setStartPoint(self.startPt)
               # si appresta ad attendere un punto
               self.waitForPoint(QadMsg.translate("QAD", "Specify second point: "))
               self.step = 2

         return False
         
      #=========================================================================
      # RISPOSTA ALLA RICHIESTA SECONDO PUNTO DELLA ANGOLO (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
                  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

         # il/i punto/i indicato/i da questa questa funzione non devono alterare lastpoint 
         self.plugIn.setLastPoint(self.__prevLastPoint)
         
         if qad_utils.ptNear(self.startPt, value):
            self.showMsg(QadMsg.translate("QAD", "\nThe points must be different."))
            # si appresta ad attendere un punto
            self.waitForPoint(QadMsg.translate("QAD", "Specify second point: "))
            return False
         else:
            self.angle = qad_utils.getAngleBy2Pts(self.startPt, value)
            return True # fine comando