示例#1
0
   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
示例#2
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
示例#3
0
文件: qad_entity.py 项目: geosim/QAD
   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
示例#4
0
   def rotate(self, basePt, angle):
      # basePt = punto base espresso in map coordinate
      # restituisce una feature ruotata
      canvas = qad.mainWindow().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
示例#5
0
 def rotate(self, entity, basePt, angle):
    # verifico se l'entità appartiene ad uno stile di quotatura
    if entity.whatIs() == "ENTITY":
       # ruoto l'entità
       rotatedGeom = qad_utils.rotateQgsGeometry(entity.getGeometry(), basePt, angle)
       if rotatedGeom is not None:
          self.__highlight.addGeometry(rotatedGeom, entity.layer)
    else:
       # ruoto la quota
       entity.rotate(basePt, angle)
       self.__highlight.addGeometry(entity.textualFeature.geometry(), entity.getTextualLayer())
       self.__highlight.addGeometries(entity.getLinearGeometryCollection(), entity.getLinearLayer())
       self.__highlight.addGeometries(entity.getSymbolGeometryCollection(), entity.getSymbolLayer())
示例#6
0
 def rotate(self, entity, basePt, angle):
    # verifico se l'entità appartiene ad uno stile di quotatura
    if entity.whatIs() == "ENTITY":
       # ruoto l'entità
       rotatedGeom = qad_utils.rotateQgsGeometry(entity.getGeometry(), basePt, angle)
       if rotatedGeom is not None:
          self.__highlight.addGeometry(rotatedGeom, entity.layer)
    else:
       # ruoto la quota
       entity.rotate(basePt, angle)
       self.__highlight.addGeometry(entity.textualFeature.geometry(), entity.getTextualLayer())
       self.__highlight.addGeometries(entity.getLinearGeometryCollection(), entity.getLinearLayer())
       self.__highlight.addGeometries(entity.getSymbolGeometryCollection(), entity.getSymbolLayer())
    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
    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
示例#9
0
 def rotate(self, f, basePt, angle, layerEntitySet, entitySet):
    # verifico se l'entità appartiene ad uno stile di quotatura
    dimEntity = self.plugIn.dimStyles.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))
       self.__rubberBand.addGeometry(f.geometry(), layerEntitySet.layer)
       del layerEntitySet.featureIds[0]
    else:
       # ruoto la quota e la rimuovo da entitySet
       dimEntitySet = dimEntity.getEntitySet()
       dimEntity.rotate(self.plugIn, basePt, angle)
       self.__rubberBand.addGeometry(dimEntity.textualFeature.geometry(), dimEntity.getTextualLayer())
       self.__rubberBand.addGeometries(dimEntity.getLinearGeometryCollection(), dimEntity.getLinearLayer())
       self.__rubberBand.addGeometries(dimEntity.getSymbolGeometryCollection(), dimEntity.getSymbolLayer())
       entitySet.subtract(dimEntitySet)
示例#10
0
   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
示例#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