# Path: drawingDimensioning/py3_helpers.py
# def encode_if_py2(unicode_object):
#     '''return unicode for py3 and bytes for py2'''
#     if sys.version_info.major < 3:
#         return unicode_object.encode("utf8")
#     else:
#         return unicode_object


from drawingDimensioning.command import *
from drawingDimensioning.py3_helpers import encode_if_py2
        from .grabPointAdd import  Proxy_grabPoint
    if radialLine_x != None and radialLine_y != None:
        XML_body.append( svgLine(radialLine_x, radialLine_y, start_x, start_y, lineColor, strokeWidth) )
        if tail_x != None and tail_y != None:
            XML_body.append( svgLine(radialLine_x, radialLine_y, tail_x, radialLine_y, lineColor, strokeWidth) )
            XML_body.append(' <circle cx ="%f" cy ="%f" r="%f" stroke="%s" fill="%s" /> ' % (tail_x, radialLine_y, noteCircle_radius, lineColor, noteCircle_fill) )
            XML_body.append( textRenderer_noteCircle( tail_x - 1.5, radialLine_y + 1.5, noteCircleText ) )
    return '<g> %s </g>' % '\n'.join(XML_body)

d.registerPreference( 'strokeWidth')
d.registerPreference( 'lineColor' )
d.registerPreference( 'noteCircle_radius', 4.5, increment=0.5, label='radius')
d.registerPreference( 'noteCircle_fill', RGBtoUnsigned(255, 255, 255), kind='color', label='fill' )
d.registerPreference( 'textRenderer_noteCircle', ['inherit','5', 150<<16], 'text properties (Note Circle)', kind='font' )
d.max_selections = 3

class NoteCircleText_widget:
    def __init__(self):
        self.counter = 1
    def valueChanged( self, arg1):
        d.noteCircleText = '%i' % arg1
        self.counter = arg1 + 1
    def generateWidget( self, dimensioningProcess ):
        self.spinbox = QtGui.QSpinBox()
        self.spinbox.setValue(self.counter)
        d.noteCircleText = '%i' % self.counter
        self.spinbox.valueChanged.connect(self.valueChanged)
        self.counter = self.counter + 1
        return DimensioningTaskDialog_generate_row_hbox('no.', self.spinbox)
    def add_properties_to_dimension_object( self, obj ):
        obj.addProperty("App::PropertyString", 'noteText', 'Parameters')

# Path: drawingDimensioning/py3_helpers.py
# def encode_if_py2(unicode_object):
#     '''return unicode for py3 and bytes for py2'''
#     if sys.version_info.major < 3:
#         return unicode_object.encode("utf8")
#     else:
#         return unicode_object


# Path: drawingDimensioning/noteCircle.py
from drawingDimensioning.command import *
from drawingDimensioning.py3_helpers import encode_if_py2
        from .grabPointAdd import  Proxy_grabPoint

    if radialLine_x != None and radialLine_y != None:
        XML_body.append( svgLine(radialLine_x, radialLine_y, start_x, start_y, lineColor, strokeWidth) )
        if tail_x != None and tail_y != None:
            XML_body.append( svgLine(radialLine_x, radialLine_y, tail_x, radialLine_y, lineColor, strokeWidth) )
            XML_body.append(' <circle cx ="%f" cy ="%f" r="%f" stroke="%s" fill="%s" /> ' % (tail_x, radialLine_y, noteCircle_radius, lineColor, noteCircle_fill) )
            XML_body.append( textRenderer_noteCircle( tail_x - 1.5, radialLine_y + 1.5, noteCircleText ) )
    return '<g> %s </g>' % '\n'.join(XML_body)

d.registerPreference( 'strokeWidth')
d.registerPreference( 'lineColor' )
d.registerPreference( 'noteCircle_radius', 4.5, increment=0.5, label='radius')
d.registerPreference( 'noteCircle_fill', RGBtoUnsigned(255, 255, 255), kind='color', label='fill' )
d.registerPreference( 'textRenderer_noteCircle', ['inherit','5', 150<<16], 'text properties (Note Circle)', kind='font' )
d.max_selections = 3

class NoteCircleText_widget:
    def __init__(self):
        self.counter = 1
    def valueChanged( self, arg1):
        d.noteCircleText = '%i' % arg1
        self.counter = arg1 + 1
    def generateWidget( self, dimensioningProcess ):
        self.spinbox = QtGui.QSpinBox()
        self.spinbox.setValue(self.counter)
        d.noteCircleText = '%i' % self.counter
        self.spinbox.valueChanged.connect(self.valueChanged)
        self.counter = self.counter + 1
        return DimensioningTaskDialog_generate_row_hbox('no.', self.spinbox)
    def add_properties_to_dimension_object( self, obj ):
        obj.addProperty("App::PropertyString", 'noteText', 'Parameters')

        obj.noteText = encode_if_py2(d.noteCircleText) 