# Path: drawingDimensioning/py3_helpers.py
#     def unicode(*args):
# def translate(*args):
# def encode_if_py2(unicode_object):
# def map(function, arg):
# 
# Path: drawingDimensioning/svgLib.py
# class SvgTextRenderer:
#     def __init__(self, font_family='inherit', font_size='inherit', fill='rgb(0,0,0)'):
#         self.font_family = font_family
#         self.font_size = font_size
#         self.fill = fill
#     def __call__(self, x, y, text, text_anchor='inherit', rotation=None):
#         '''
#         text_anchor = start | middle | end | inherit
#         rotation is in degress, and is done about x,y
#         '''
#         try:
#             XML = '''<text x="%f" y="%f" font-family="%s" font-size="%s" fill="%s" text-anchor="%s" %s >%s</text>'''  % (  x, y, self.font_family, self.font_size,  self.fill, text_anchor, 'transform="rotate(%f %f,%f)"' % (rotation,x,y) if rotation != None else '', text )
#         except UnicodeDecodeError:
#             text_utf8 = unicode( text, 'utf8' )
#             XML = '''<text x="%f" y="%f" font-family="%s" font-size="%s" fill="%s" text-anchor="%s" %s >%s</text>'''  % (  x, y, self.font_family, self.font_size,  self.fill, text_anchor, 'transform="rotate(%f %f,%f)"' % (rotation,x,y) if rotation != None else '', text_utf8 )
#         return XML
#     def __repr__(self):
#         return '<svgLib_dd.SvgTextRenderer family="%s" font_size="%s" fill="%s">' % (self.font_family, self.font_size, self.fill )


import sys
import FreeCAD
from drawingDimensioning.py3_helpers import unicode, unicode_type, map, encode_if_py2
from PySide import QtGui, QtCore, QtSvg
from drawingDimensioning.svgConstructor import SvgTextRenderer

    def generateWidget( self, dimensioningProcess, width = 60, height = 30 ):
        self.dimensioningProcess = dimensioningProcess
        colorBox = QtGui.QGraphicsView( self.graphicsScene )
        colorBox.setMaximumWidth( width )
        colorBox.setMaximumHeight( height )
        colorBox.setHorizontalScrollBarPolicy( QtCore.Qt.ScrollBarPolicy.ScrollBarAlwaysOff )
        colorBox.setVerticalScrollBarPolicy( QtCore.Qt.ScrollBarPolicy.ScrollBarAlwaysOff )
        self.family_textbox = QtGui.QLineEdit()
        self.size_textbox = QtGui.QLineEdit()

        groupbox = QtGui.QGroupBox(self.label)
        hbox = QtGui.QHBoxLayout()
        hbox.addWidget( self.family_textbox )
        hbox.addStretch(1)
        hbox.addWidget( self.size_textbox )
        hbox.addStretch(1)
        hbox.addWidget( colorBox )
        groupbox.setLayout(hbox)
        self.revertToDefault()
        self.family_textbox.textChanged.connect( self.update_dimensionConstructorKWs )
        self.size_textbox.textChanged.connect( self.update_dimensionConstructorKWs )
        return groupbox
    def add_properties_to_dimension_object( self, obj ):
        obj.addProperty("App::PropertyString", self.name+ '_family', self.category)
        obj.addProperty("App::PropertyString", self.name+ '_size', self.category)
        obj.addProperty("App::PropertyString", self.name+ '_color', self.category)
        textRenderer = self.dimensioningProcess.dimensionConstructorKWs[ self.name ]
        setattr( obj, self.name + '_family', encode_if_py2(textRenderer.font_family) )
        setattr( obj, self.name + '_size', encode_if_py2(textRenderer.font_size) )

# Path: drawingDimensioning/py3_helpers.py
#     def unicode(*args):
# def translate(*args):
# def encode_if_py2(unicode_object):
# def map(function, arg):
# 
# Path: drawingDimensioning/svgLib.py
# class SvgTextRenderer:
#     def __init__(self, font_family='inherit', font_size='inherit', fill='rgb(0,0,0)'):
#         self.font_family = font_family
#         self.font_size = font_size
#         self.fill = fill
#     def __call__(self, x, y, text, text_anchor='inherit', rotation=None):
#         '''
#         text_anchor = start | middle | end | inherit
#         rotation is in degress, and is done about x,y
#         '''
#         try:
#             XML = '''<text x="%f" y="%f" font-family="%s" font-size="%s" fill="%s" text-anchor="%s" %s >%s</text>'''  % (  x, y, self.font_family, self.font_size,  self.fill, text_anchor, 'transform="rotate(%f %f,%f)"' % (rotation,x,y) if rotation != None else '', text )
#         except UnicodeDecodeError:
#             text_utf8 = unicode( text, 'utf8' )
#             XML = '''<text x="%f" y="%f" font-family="%s" font-size="%s" fill="%s" text-anchor="%s" %s >%s</text>'''  % (  x, y, self.font_family, self.font_size,  self.fill, text_anchor, 'transform="rotate(%f %f,%f)"' % (rotation,x,y) if rotation != None else '', text_utf8 )
#         return XML
#     def __repr__(self):
#         return '<svgLib_dd.SvgTextRenderer family="%s" font_size="%s" fill="%s">' % (self.font_family, self.font_size, self.fill )


# Path: drawingDimensioning/command/preferences.py
import sys
import FreeCAD
from drawingDimensioning.py3_helpers import unicode, unicode_type, map, encode_if_py2
from PySide import QtGui, QtCore, QtSvg
from drawingDimensioning.svgConstructor import SvgTextRenderer


    def generateWidget( self, dimensioningProcess, width = 60, height = 30 ):
        self.dimensioningProcess = dimensioningProcess
        colorBox = QtGui.QGraphicsView( self.graphicsScene )
        colorBox.setMaximumWidth( width )
        colorBox.setMaximumHeight( height )
        colorBox.setHorizontalScrollBarPolicy( QtCore.Qt.ScrollBarPolicy.ScrollBarAlwaysOff )
        colorBox.setVerticalScrollBarPolicy( QtCore.Qt.ScrollBarPolicy.ScrollBarAlwaysOff )
        self.family_textbox = QtGui.QLineEdit()
        self.size_textbox = QtGui.QLineEdit()

        groupbox = QtGui.QGroupBox(self.label)
        hbox = QtGui.QHBoxLayout()
        hbox.addWidget( self.family_textbox )
        hbox.addStretch(1)
        hbox.addWidget( self.size_textbox )
        hbox.addStretch(1)
        hbox.addWidget( colorBox )
        groupbox.setLayout(hbox)
        self.revertToDefault()
        self.family_textbox.textChanged.connect( self.update_dimensionConstructorKWs )
        self.size_textbox.textChanged.connect( self.update_dimensionConstructorKWs )
        return groupbox
    def add_properties_to_dimension_object( self, obj ):
        obj.addProperty("App::PropertyString", self.name+ '_family', self.category)
        obj.addProperty("App::PropertyString", self.name+ '_size', self.category)
        obj.addProperty("App::PropertyString", self.name+ '_color', self.category)
        textRenderer = self.dimensioningProcess.dimensionConstructorKWs[ self.name ]
        setattr( obj, self.name + '_family', encode_if_py2(textRenderer.font_family) )
        setattr( obj, self.name + '_size', encode_if_py2(textRenderer.font_size) )

        setattr( obj, self.name + '_color', encode_if_py2(textRenderer.fill) )