# Path: drawingDimensioning/core.py
# def debugPrint( level, msg ):
# def findUnusedObjectName(base, counterStart=1, fmt='%03i'):
# def errorMessagebox_with_traceback(title='Error'):
# def getDrawingPageGUIVars():
#     def __init__(self, data):
# def recomputeWithOutViewReset( drawingVars ):
# def printGraphicsViewInfo( drawingVars ):
#     def Activated(self):
#     def GetResources(self): 
# def dimensionableObjects ( page ):
# class DrawingPageGUIVars:
# class helpCommand:
#     T = gV.transform()
#     T = drawingVars.graphicsView.transform()
# 
# Path: drawingDimensioning/py3_helpers.py
#     def unicode(*args):
# def translate(*args):
# def encode_if_py2(unicode_object):
# def map(function, arg):


from .core import *
from .core import  __dir__ # not imported with * directive
from .grid import *
from drawingDimensioning.py3_helpers import unicode_type, encode_if_py2
    #preview.SVG.
    drawingVars.graphicsScene.addItem( preview.SVG )

    debugPrint(4, 'adding Rect')
    preview.rect.setRect(0, 0, drawingVars.width, drawingVars.height)
    preview.rect.dimensionSvgFun = dimensionSvgFun
    preview.rect.dimensionClickHandler = dimensionClickHandler
    preview.rect.setAcceptHoverEvents(True)
    preview.rect.setFlag( QtGui.QGraphicsItem.GraphicsItemFlag.ItemIsFocusable, True )
    preview.rect.setCursor( QtCore.Qt.ArrowCursor ) # http://qt-project.org/doc/qt-5/qt.html#CursorShape-enum
    preview.rect.setZValue( 0.1 )
    drawingVars.graphicsScene.addItem( preview.rect )
    debugPrint(4, 'DimensionPreviewSvgGraphicsItem added to graphics Scene')


def removePreviewGraphicItems( recomputeActiveDocument = True, launchEndFunction=False, closeDialog=True ):
    debugPrint(4,'removePreviewGraphicItems called, recomputeActiveDocument %s' % recomputeActiveDocument)
    preview.drawingVars.graphicsScene.removeItem( preview.SVG )
    preview.drawingVars.graphicsScene.removeItem( preview.rect )
    preview.removedQtItems = True
    if recomputeActiveDocument:
        debugPrint(3,'removePreviewGraphicItems: recomputing')
        recomputeWithOutViewReset( preview.drawingVars )
    if closeDialog and preview.dimensioningProcessTracker.taskDialog != None:
        FreeCADGui.Control.closeDialog()
    del preview.drawingVars
    if launchEndFunction and preview.dimensioningProcessTracker.endFunction != None:
        timer.start( 1 ) # 1 ms (in theory)



# Path: drawingDimensioning/core.py
# def debugPrint( level, msg ):
# def findUnusedObjectName(base, counterStart=1, fmt='%03i'):
# def errorMessagebox_with_traceback(title='Error'):
# def getDrawingPageGUIVars():
#     def __init__(self, data):
# def recomputeWithOutViewReset( drawingVars ):
# def printGraphicsViewInfo( drawingVars ):
#     def Activated(self):
#     def GetResources(self): 
# def dimensionableObjects ( page ):
# class DrawingPageGUIVars:
# class helpCommand:
#     T = gV.transform()
#     T = drawingVars.graphicsView.transform()
# 
# Path: drawingDimensioning/py3_helpers.py
#     def unicode(*args):
# def translate(*args):
# def encode_if_py2(unicode_object):
# def map(function, arg):


# Path: drawingDimensioning/previewDimension.py
from .core import *
from .core import  __dir__ # not imported with * directive
from .grid import *
from drawingDimensioning.py3_helpers import unicode_type, encode_if_py2

    #preview.SVG.
    drawingVars.graphicsScene.addItem( preview.SVG )

    debugPrint(4, 'adding Rect')
    preview.rect.setRect(0, 0, drawingVars.width, drawingVars.height)
    preview.rect.dimensionSvgFun = dimensionSvgFun
    preview.rect.dimensionClickHandler = dimensionClickHandler
    preview.rect.setAcceptHoverEvents(True)
    preview.rect.setFlag( QtGui.QGraphicsItem.GraphicsItemFlag.ItemIsFocusable, True )
    preview.rect.setCursor( QtCore.Qt.ArrowCursor ) # http://qt-project.org/doc/qt-5/qt.html#CursorShape-enum
    preview.rect.setZValue( 0.1 )
    drawingVars.graphicsScene.addItem( preview.rect )
    debugPrint(4, 'DimensionPreviewSvgGraphicsItem added to graphics Scene')


def removePreviewGraphicItems( recomputeActiveDocument = True, launchEndFunction=False, closeDialog=True ):
    debugPrint(4,'removePreviewGraphicItems called, recomputeActiveDocument %s' % recomputeActiveDocument)
    preview.drawingVars.graphicsScene.removeItem( preview.SVG )
    preview.drawingVars.graphicsScene.removeItem( preview.rect )
    preview.removedQtItems = True
    if recomputeActiveDocument:
        debugPrint(3,'removePreviewGraphicItems: recomputing')
        recomputeWithOutViewReset( preview.drawingVars )
    if closeDialog and preview.dimensioningProcessTracker.taskDialog != None:
        FreeCADGui.Control.closeDialog()
    del preview.drawingVars
    if launchEndFunction and preview.dimensioningProcessTracker.endFunction != None:
        timer.start( 1 ) # 1 ms (in theory)



def executeEndFunction():