# 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
                    pass
                elif instruction.startswith('createDimension:'):
                    viewName = instruction.split(':')[1]
                    FreeCAD.ActiveDocument.openTransaction(viewName)
                    XML = self.dimensionSvgFun( x, y )
                    debugPrint(3, XML)
                    debugPrint(2, 'creating dimension %s' % viewName)
                    obj = App.ActiveDocument.addObject('Drawing::FeatureViewPython',viewName)
                    obj.ViewResult = XML
                    d = preview.dimensioningProcessTracker
                    d.ProxyClass( obj, d.selections, d.proxy_svgFun )
                    if hasattr( obj.ViewObject, 'Proxy'):
                        d.ViewObjectProxyClass( obj.ViewObject, d.dialogIconPath )
                    preview.drawingVars.page.addObject( obj ) #App.ActiveDocument.getObject(viewName) )
                    removePreviewGraphicItems( recomputeActiveDocument=True, launchEndFunction=True )
                    FreeCAD.ActiveDocument.commitTransaction()
                elif instruction == 'stopPreview':
                    removePreviewGraphicItems( recomputeActiveDocument=True, launchEndFunction=True )
            else:
                event.ignore()
        except:
            App.Console.PrintError(traceback.format_exc())

    def hoverMoveEvent(self, event):
        try:
            x, y = preview.applyTransform( event.scenePos() )
            debugPrint(4, 'hoverMoveEvent: x %f, y %f' % (x, y) )
            x, y= applyGridRounding( x, y)
            XML = '<svg width="%i" height="%i"> %s </svg>' % (preview.drawingVars.width, preview.drawingVars.height, self.dimensionSvgFun( x, y ))
            if isinstance(XML, unicode_type): 

# 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

                    pass
                elif instruction.startswith('createDimension:'):
                    viewName = instruction.split(':')[1]
                    FreeCAD.ActiveDocument.openTransaction(viewName)
                    XML = self.dimensionSvgFun( x, y )
                    debugPrint(3, XML)
                    debugPrint(2, 'creating dimension %s' % viewName)
                    obj = App.ActiveDocument.addObject('Drawing::FeatureViewPython',viewName)
                    obj.ViewResult = XML
                    d = preview.dimensioningProcessTracker
                    d.ProxyClass( obj, d.selections, d.proxy_svgFun )
                    if hasattr( obj.ViewObject, 'Proxy'):
                        d.ViewObjectProxyClass( obj.ViewObject, d.dialogIconPath )
                    preview.drawingVars.page.addObject( obj ) #App.ActiveDocument.getObject(viewName) )
                    removePreviewGraphicItems( recomputeActiveDocument=True, launchEndFunction=True )
                    FreeCAD.ActiveDocument.commitTransaction()
                elif instruction == 'stopPreview':
                    removePreviewGraphicItems( recomputeActiveDocument=True, launchEndFunction=True )
            else:
                event.ignore()
        except:
            App.Console.PrintError(traceback.format_exc())

    def hoverMoveEvent(self, event):
        try:
            x, y = preview.applyTransform( event.scenePos() )
            debugPrint(4, 'hoverMoveEvent: x %f, y %f' % (x, y) )
            x, y= applyGridRounding( x, y)
            XML = '<svg width="%i" height="%i"> %s </svg>' % (preview.drawingVars.width, preview.drawingVars.height, self.dimensionSvgFun( x, y ))
            if isinstance(XML, unicode_type): 

                XML = encode_if_py2(XML)