# 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
        self.dd_parms.SetString( self.name, self.val_to_FreeCAD_parm( self.dimensioningProcess.dimensionConstructorKWs[ self.name ] ) )
    def set_textbox_text( self, values ):
        self.textbox.clear()
        for v in values:
            self.textbox.append( str(v) if type(v) == float else v )
    def revertToDefault( self ):
        self.set_textbox_text( self.getDefaultValue() )
    def generateWidget( self, dimensioningProcess ):
        self.dimensioningProcess = dimensioningProcess
        self.textbox = QtGui.QTextEdit()
        self.revertToDefault()
        self.textbox.textChanged.connect( self.textChanged )
        return DimensioningTaskDialog_generate_row_hbox( self.label, self.textbox )
    def textChanged( self, arg1=None):
        self.dimensioningProcess.dimensionConstructorKWs[ self.name ] = self.textbox.toPlainText().split('\n')
    def add_properties_to_dimension_object( self, obj ):
        obj.addProperty("App::PropertyStringList", self.name, self.category)
        KWs = self.dimensioningProcess.dimensionConstructorKWs
        setattr( obj, self.name, [ encode_if_py2(v) for v in KWs[ self.name ] ] )
    def get_values_from_dimension_object( self, obj, KWs ):
        KWs[self.name] = getattr( obj, self.name )
DimensioningPreferenceClasses['string_list'] = DimensioningPreference_string_list

class DimensioningPreference_float_list(DimensioningPreference_string_list):
    def val_to_FreeCAD_parm( self, val ):
        return '\n'.join(map(str, val))
    def FreeCAD_parm_to_val( self, FreeCAD_parm ):
        return map(float, FreeCAD_parm.split('\n'))
    def textChanged( self, arg1=None):
        try:

# 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

        self.dd_parms.SetString( self.name, self.val_to_FreeCAD_parm( self.dimensioningProcess.dimensionConstructorKWs[ self.name ] ) )
    def set_textbox_text( self, values ):
        self.textbox.clear()
        for v in values:
            self.textbox.append( str(v) if type(v) == float else v )
    def revertToDefault( self ):
        self.set_textbox_text( self.getDefaultValue() )
    def generateWidget( self, dimensioningProcess ):
        self.dimensioningProcess = dimensioningProcess
        self.textbox = QtGui.QTextEdit()
        self.revertToDefault()
        self.textbox.textChanged.connect( self.textChanged )
        return DimensioningTaskDialog_generate_row_hbox( self.label, self.textbox )
    def textChanged( self, arg1=None):
        self.dimensioningProcess.dimensionConstructorKWs[ self.name ] = self.textbox.toPlainText().split('\n')
    def add_properties_to_dimension_object( self, obj ):
        obj.addProperty("App::PropertyStringList", self.name, self.category)
        KWs = self.dimensioningProcess.dimensionConstructorKWs
        setattr( obj, self.name, [ encode_if_py2(v) for v in KWs[ self.name ] ] )
    def get_values_from_dimension_object( self, obj, KWs ):
        KWs[self.name] = getattr( obj, self.name )
DimensioningPreferenceClasses['string_list'] = DimensioningPreference_string_list

class DimensioningPreference_float_list(DimensioningPreference_string_list):
    def val_to_FreeCAD_parm( self, val ):
        return '\n'.join(map(str, val))
    def FreeCAD_parm_to_val( self, FreeCAD_parm ):
        return map(float, FreeCAD_parm.split('\n'))
    def textChanged( self, arg1=None):
        try:

            self.dimensioningProcess.dimensionConstructorKWs[ self.name ] = map(float, [v for v in self.textbox.toPlainText().split('\n') if len(v.strip())>0])