# HG changeset patch # User Laurent Bessard # Date 1383780706 -3600 # Node ID 4278d5c1e414a05dda15eb1a0fe5b1d74959b610 # Parent ef26fcb7f5d49d632ce2971e3934128de42fbb85 Fixed bug when graphic element position and size and connection points are decimal diff -r ef26fcb7f5d4 -r 4278d5c1e414 PLCControler.py --- a/PLCControler.py Thu Nov 07 00:16:00 2013 +0100 +++ b/PLCControler.py Thu Nov 07 00:31:46 2013 +0100 @@ -387,14 +387,14 @@ self.SpecificValues = None self.CurrentInstance = _BlockInstanceInfos( - *(_translate_args([str] + [int] * 5, args) + + *(_translate_args([str, int] + [float] * 4, args) + [specific_values, [], []])) self.BlockInstances[self.CurrentInstance.id] = self.CurrentInstance def AddInstanceConnection(self, context, *args): connection_args = _translate_args( - [str, str, _BoolValue, str, int, int], args) + [str, str, _BoolValue, str, float, float], args) self.CurrentConnection = _InstanceConnectionInfos( *(connection_args[1:4] + [ @@ -415,7 +415,7 @@ def AddLinkPoint(self, context, *args): self.CurrentLink.points.append(_Point( - *_translate_args([int, int], args))) + *_translate_args([float] * 2, args))) def AddAction(self, context, *args): if len(self.SpecificValues) == 0: diff -r ef26fcb7f5d4 -r 4278d5c1e414 xmlclass/xsdschema.py --- a/xmlclass/xsdschema.py Thu Nov 07 00:16:00 2013 +0100 +++ b/xmlclass/xsdschema.py Thu Nov 07 00:31:46 2013 +0100 @@ -44,14 +44,15 @@ return text return generateXMLTextMethod -def GenerateFloatXMLText(extra_values=[]): +def GenerateFloatXMLText(extra_values=[], decimal=None): + float_format = ("{:.%dg}" % decimal).format if decimal is not None else str def generateXMLTextMethod(value, name=None, indent=0): text = "" if name is not None: ind1, ind2 = getIndent(indent, name) text += ind1 + "<%s>" % name if value in extra_values or value % 1 != 0 or isinstance(value, IntType): - text += str(value) + text += float_format(value) else: text += "%.0f" % value if name is not None: @@ -2269,7 +2270,7 @@ "basename": "decimal", "extract": GenerateFloatExtraction("decimal"), "facets": DECIMAL_FACETS, - "generate": GenerateFloatXMLText(), + "generate": GenerateFloatXMLText(decimal=3), "initial": lambda: 0., "check": lambda x: isinstance(x, (IntType, FloatType)) },