- start working on QRCode Tool - serching for alternatives

This commit is contained in:
Marius Stanciu
2019-10-23 17:58:06 +03:00
parent bf670d7967
commit 70fbb7f852
3 changed files with 22 additions and 9 deletions

View File

@@ -13,6 +13,7 @@ CAD program, and create G-Code for Isolation routing.
- working on the Calibrate Excellon Tool
- finished the GUI layout for the Calibrate Excellon Tool
- start working on QRCode Tool - not working yet
- start working on QRCode Tool - serching for alternatives
21.10.2019

View File

@@ -22,7 +22,7 @@
# import xml.etree.ElementTree as ET
from svg.path import Line, Arc, CubicBezier, QuadraticBezier, parse_path
from svg.path.path import Move
from shapely.geometry import LineString
from shapely.geometry import LineString, LinearRing, MultiLineString
from shapely.affinity import skew, affine_transform, rotate
import numpy as np
@@ -71,7 +71,6 @@ def path2shapely(path, object_type, res=1.0):
rings = []
for component in path:
# Line
if isinstance(component, Line):
start = component.start
@@ -123,6 +122,8 @@ def path2shapely(path, object_type, res=1.0):
if points:
rings.append(points)
rings = MultiLineString(rings)
if len(rings) > 0:
if len(rings) == 1:
# Polygons are closed and require more than 2 points
@@ -131,7 +132,14 @@ def path2shapely(path, object_type, res=1.0):
else:
geo_element = LineString(rings[0])
else:
geo_element = Polygon(rings[0], rings[1:])
try:
geo_element = Polygon(rings[0], rings[1:])
except Exception as e:
coords = list()
for line in rings:
coords.append(line.coords[0])
coords.append(line.coords[1])
geo_element = Polygon(coords)
geometry.append(geo_element)
return geometry

View File

@@ -18,7 +18,8 @@ import math
import io
from datetime import datetime
import logging
import pyqrcode
import qrcode
import qrcode.image.svg
from lxml import etree as ET
import gettext
@@ -93,13 +94,16 @@ class QRCode(FlatCAMTool):
self.units = self.app.ui.general_defaults_form.general_app_group.units_radio.get_value().upper()
def execute(self):
svg_file = io.StringIO('')
svg_class = pyqrcode.QRCode("FlatCAM - 2D - Computer aided PCB Manufacturing Tool")
svg_class.svg(svg_file, scale=4, xmldecl=False)
svg_file = io.BytesIO()
svg_file = qrcode.make("FlatCAM - 2D - Computer aided PCB Manufacturing Tool",
image_factory=qrcode.image.svg.SvgFragmentImage)
def obj_init(geo_obj, app_obj):
print(svg_file)
geo_obj.import_svg(svg_file)
units = self.app.ui.general_defaults_form.general_app_group.units_radio.get_value()
try:
geo_obj.import_svg(svg_file)
except Exception as e:
print(str(e))
with self.app.proc_container.new("Import SVG"):