# Path: qad_highlight.py
# class QadHighlight():
#    def __init__(self, mapCanvas, borderColor = None, fillColor = None):
#       self.mapCanvas = mapCanvas
#       self.__highlight = []
# 
#    def __del__(self):
#       self.reset()
#       
#       for highlight in self.__highlight:
#          self.mapCanvas.scene().removeItem(highlight)
# 
#       del self.__highlight[:]
#    
#    def hide(self):
#       for highlight in self.__highlight:
#          highlight.hide()
# 
#    def show(self):
#       for highlight in self.__highlight:
#          highlight.show()
#       
#    def addGeometry(self, geom, layer, borderColor = None, fillColor = None):
#       highlight = createHighlight(self.mapCanvas, geom, layer, borderColor, fillColor)
#       highlight.show()
#       self.__highlight.append(highlight)
# 
#    def addGeometries(self, geoms, layer, borderColor = None, fillColor = None):
#       for g in geoms:
#          self.addGeometry(g, layer, borderColor, fillColor)         
#          
#    def reset(self):
#       self.hide()
#       for highlight in self.__highlight:
#          self.mapCanvas.scene().removeItem(highlight)
#       del self.__highlight[:]
# 
# Path: qad_msg.py
# class QadMsgClass():
#    def __init__(self):
#    def translate(self, context, sourceText, disambiguation = None, encoding = QCoreApplication.UnicodeUTF8, n = -1):
# def qadShowPluginHelp(section = "", filename = "index", packageName = None):


from PyQt4.QtCore import *
from PyQt4.QtGui import *
from qgis.core import *
from qgis.gui import *
from qad_snapper import *
from qad_snappointsdisplaymanager import *
from qad_variables import *
from qad_getpoint import *
from qad_dim import *
from qad_highlight import QadHighlight
from qad_msg import QadMsg
import math
import qad_utils
import qad_stretch_fun
         # stiro la feature
         stretchedGeom = qad_stretch_fun.stretchQgsGeometry(stretchedGeom, containerGeom, \
                                                            offSetX, offSetY, \
                                                            tolerance2ApproxCurve)
         
         if stretchedGeom is not None:
            # trasformo la geometria nel crs del layer
            coordTransform = QgsCoordinateTransform(self.canvas.mapSettings().destinationCrs(), entity.layer.crs())
            stretchedGeom.transform(coordTransform)
            self.__highlight.addGeometry(stretchedGeom, entity.layer)

      elif entity.whatIs() == "DIMENTITY":
         newDimEntity = QadDimEntity(entity) # la copio
         # stiro la quota
         newDimEntity.stretch(containerGeom, offSetX, offSetY)
         self.__highlight.addGeometry(newDimEntity.textualFeature.geometry(), newDimEntity.getTextualLayer())
         self.__highlight.addGeometries(newDimEntity.getLinearGeometryCollection(), newDimEntity.getLinearLayer())
         self.__highlight.addGeometries(newDimEntity.getSymbolGeometryCollection(), newDimEntity.getSymbolLayer())
            
      return True


   #============================================================================
   # addStretchedGeometries
   #============================================================================
   def addStretchedGeometries(self, newPt):
      self.__highlight.reset()            

      dimElaboratedList = [] # lista delle quotature già elaborate


# Path: qad_highlight.py
# class QadHighlight():
#    def __init__(self, mapCanvas, borderColor = None, fillColor = None):
#       self.mapCanvas = mapCanvas
#       self.__highlight = []
# 
#    def __del__(self):
#       self.reset()
#       
#       for highlight in self.__highlight:
#          self.mapCanvas.scene().removeItem(highlight)
# 
#       del self.__highlight[:]
#    
#    def hide(self):
#       for highlight in self.__highlight:
#          highlight.hide()
# 
#    def show(self):
#       for highlight in self.__highlight:
#          highlight.show()
#       
#    def addGeometry(self, geom, layer, borderColor = None, fillColor = None):
#       highlight = createHighlight(self.mapCanvas, geom, layer, borderColor, fillColor)
#       highlight.show()
#       self.__highlight.append(highlight)
# 
#    def addGeometries(self, geoms, layer, borderColor = None, fillColor = None):
#       for g in geoms:
#          self.addGeometry(g, layer, borderColor, fillColor)         
#          
#    def reset(self):
#       self.hide()
#       for highlight in self.__highlight:
#          self.mapCanvas.scene().removeItem(highlight)
#       del self.__highlight[:]
# 
# Path: qad_msg.py
# class QadMsgClass():
#    def __init__(self):
#    def translate(self, context, sourceText, disambiguation = None, encoding = QCoreApplication.UnicodeUTF8, n = -1):
# def qadShowPluginHelp(section = "", filename = "index", packageName = None):


# Path: qad_stretch_maptool.py
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from qgis.core import *
from qgis.gui import *
from qad_snapper import *
from qad_snappointsdisplaymanager import *
from qad_variables import *
from qad_getpoint import *
from qad_dim import *
from qad_highlight import QadHighlight
from qad_msg import QadMsg
import math
import qad_utils
import qad_stretch_fun

         # stiro la feature
         stretchedGeom = qad_stretch_fun.stretchQgsGeometry(stretchedGeom, containerGeom, \
                                                            offSetX, offSetY, \
                                                            tolerance2ApproxCurve)
         
         if stretchedGeom is not None:
            # trasformo la geometria nel crs del layer
            coordTransform = QgsCoordinateTransform(self.canvas.mapSettings().destinationCrs(), entity.layer.crs())
            stretchedGeom.transform(coordTransform)
            self.__highlight.addGeometry(stretchedGeom, entity.layer)

      elif entity.whatIs() == "DIMENTITY":
         newDimEntity = QadDimEntity(entity) # la copio
         # stiro la quota
         newDimEntity.stretch(containerGeom, offSetX, offSetY)
         self.__highlight.addGeometry(newDimEntity.textualFeature.geometry(), newDimEntity.getTextualLayer())
         self.__highlight.addGeometries(newDimEntity.getLinearGeometryCollection(), newDimEntity.getLinearLayer())
         self.__highlight.addGeometries(newDimEntity.getSymbolGeometryCollection(), newDimEntity.getSymbolLayer())
            
      return True


   #============================================================================
   # addStretchedGeometries
   #============================================================================
   def addStretchedGeometries(self, newPt):
      self.__highlight.reset()            

      dimElaboratedList = [] # lista delle quotature già elaborate


      tolerance2ApproxCurve = QadVariables.get(QadMsg.translate("Environment variables", "TOLERANCE2APPROXCURVE"))