Skip to content

Commit

Permalink
EKR support/SVG parsing fix
Browse files Browse the repository at this point in the history
EKR was properly detected prior but due to a SVG parsing error it was not loading correctly.  Issue has been address and it now loads correctly in the GUI. May address other issues occurring with SVG parsing errors.
  • Loading branch information
tb2097 authored Apr 4, 2021
1 parent e598fb7 commit c8cc441
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 19 deletions.
28 changes: 14 additions & 14 deletions wacom-gui/pad.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,22 +166,22 @@ def init_keys(self, dev_id, image, buttons, cmds):
if os.path.exists(bkground):
svgWidget = QSvgWidget(bkground)
col = col + 1
# get spacing for final image
svg_size = svgWidget.sizeHint()
img_h = float(540 - vspace)
img_w = float(860 - hspace)
scale_w = float(img_w / svg_size.width())
scale_h = float(img_h / svg_size.height())
if scale_h < scale_w:
vspace = round(img_w - (scale_h * svg_size.width()))
svg_vspace.changeSize(vspace, img_h, QSizePolicy.Fixed, QSizePolicy.Fixed)
svg_hspace.changeSize(img_w, 0, QSizePolicy.Fixed, QSizePolicy.Fixed)
else:
hspace = round(img_h - (scale_w * svg_size.height()))
svg_vspace.changeSize(0, img_h, QSizePolicy.Fixed, QSizePolicy.Fixed)
svg_hspace.changeSize(img_w, hspace, QSizePolicy.Fixed, QSizePolicy.Fixed)
except Exception as e:
print (e)
# get spacing for final image
svg_size = svgWidget.sizeHint()
img_h = float(540 - vspace)
img_w = float(860 - hspace)
scale_w = float(img_w / svg_size.width())
scale_h = float(img_h / svg_size.height())
if scale_h < scale_w:
vspace = round(img_w - (scale_h * svg_size.width()))
svg_vspace.changeSize(vspace, img_h, QSizePolicy.Fixed, QSizePolicy.Fixed)
svg_hspace.changeSize(img_w, 0, QSizePolicy.Fixed, QSizePolicy.Fixed)
else:
hspace = round(img_h - (scale_w * svg_size.height()))
svg_vspace.changeSize(0, img_h, QSizePolicy.Fixed, QSizePolicy.Fixed)
svg_hspace.changeSize(img_w, hspace, QSizePolicy.Fixed, QSizePolicy.Fixed)
# start to build...
# add top row
if self.buttons['top'].__len__() != 0:
Expand Down
15 changes: 10 additions & 5 deletions wacom-gui/wacom_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def get_connected_tablets(self):
if self.device_data[dev_type]['devID'] not in self.tablets.keys():
self.tablets[devID] = []
# assume if it's the same device it has the same inputs for all connected
if 'pad' in detected[device] :
if 'pad' in detected[device]:
dev_count = detected[device]['pad']['id'].__len__()
else :
dev_count = 1
Expand Down Expand Up @@ -256,7 +256,9 @@ def pretty_svg(self, device):
svg = '%s\n\t\t<path' % svg
# get attr
for attr in elem.attrib:
svg = "%s\n\t\t\t%s=\"%s\"" % (svg, attr, elem.attrib[attr])
#TODO: this fix path problem?
if not attr.startswith("{"):
svg = "%s\n\t\t\t%s=\"%s\"" % (svg, attr, elem.attrib[attr])
svg = "%s\n\t\t\tfill=\"none\" />" % svg
if elem.attrib['id'] in self.device_data[device]['pad']['buttons'].keys():
but_info = self.device_data[device]['pad']['buttons'][elem.attrib['id']]
Expand Down Expand Up @@ -339,9 +341,9 @@ def pretty_svg(self, device):
if True:
# if not os.path.isfile("/tmp/%s" % self.device_data[device]['svg']):
# shift every line to eliminate extra vertical whitespace...
svg_write = ''
yshift = ymin - 20
if yshift > 0:
svg_write = ''
for line in svg.split('\n'):
if 'sodipodi' in line:
line = "sodipodi:%s" % line.split('}')[1]
Expand All @@ -366,7 +368,8 @@ def pretty_svg(self, device):
svg_write = "%s\n%s" % (svg_write, d)
else:
svg_write = "%s\n%s" % (svg_write, line)
svg = svg_write
if svg_write != '':
svg = svg_write
# shift x values if it is too wide
if xmax >= 500:
xshift = 300 # shift over by 200 units in the x coord
Expand Down Expand Up @@ -417,6 +420,8 @@ def pretty_svg(self, device):
fill="#111111"/>
</g>%s""" % (xmax - 290, (ymax -yshift) + 20, xmax - 290, (ymax -yshift) + 20, svg_write)
else:
if not svg.strip().startswith("<g>"):
svg = "<g>%s" % svg
svg = """<svg
style="color:#000000;stroke:#7f7f7f;fill:#222222;stroke-width:.5;font-size:8"
width="%s"
Expand All @@ -431,7 +436,7 @@ def pretty_svg(self, device):
height="%s"
stroke="none"
fill="#111111"/>
</g>%s""" % (xmax + 50, (ymax - yshift) + 20, xmax + 50, (ymax - yshift) + 20, svg_write)
</g>%s""" % (xmax + 50, (ymax - yshift) + 20, xmax + 50, (ymax - yshift) + 20, svg)
f = open("/tmp/%s" % self.device_data[device]['svg'], "w")
f.write(svg)
f.close()
Expand Down

0 comments on commit c8cc441

Please sign in to comment.