- start working on QRCode Tool - serching for alternatives
This commit is contained in:
@@ -13,6 +13,7 @@ CAD program, and create G-Code for Isolation routing.
|
|||||||
- working on the Calibrate Excellon Tool
|
- working on the Calibrate Excellon Tool
|
||||||
- finished the GUI layout for 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 - not working yet
|
||||||
|
- start working on QRCode Tool - serching for alternatives
|
||||||
|
|
||||||
21.10.2019
|
21.10.2019
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
# import xml.etree.ElementTree as ET
|
# import xml.etree.ElementTree as ET
|
||||||
from svg.path import Line, Arc, CubicBezier, QuadraticBezier, parse_path
|
from svg.path import Line, Arc, CubicBezier, QuadraticBezier, parse_path
|
||||||
from svg.path.path import Move
|
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
|
from shapely.affinity import skew, affine_transform, rotate
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
@@ -71,7 +71,6 @@ def path2shapely(path, object_type, res=1.0):
|
|||||||
rings = []
|
rings = []
|
||||||
|
|
||||||
for component in path:
|
for component in path:
|
||||||
|
|
||||||
# Line
|
# Line
|
||||||
if isinstance(component, Line):
|
if isinstance(component, Line):
|
||||||
start = component.start
|
start = component.start
|
||||||
@@ -123,6 +122,8 @@ def path2shapely(path, object_type, res=1.0):
|
|||||||
|
|
||||||
if points:
|
if points:
|
||||||
rings.append(points)
|
rings.append(points)
|
||||||
|
|
||||||
|
rings = MultiLineString(rings)
|
||||||
if len(rings) > 0:
|
if len(rings) > 0:
|
||||||
if len(rings) == 1:
|
if len(rings) == 1:
|
||||||
# Polygons are closed and require more than 2 points
|
# Polygons are closed and require more than 2 points
|
||||||
@@ -131,7 +132,14 @@ def path2shapely(path, object_type, res=1.0):
|
|||||||
else:
|
else:
|
||||||
geo_element = LineString(rings[0])
|
geo_element = LineString(rings[0])
|
||||||
else:
|
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)
|
geometry.append(geo_element)
|
||||||
|
|
||||||
return geometry
|
return geometry
|
||||||
|
|||||||
@@ -18,7 +18,8 @@ import math
|
|||||||
import io
|
import io
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import logging
|
import logging
|
||||||
import pyqrcode
|
import qrcode
|
||||||
|
import qrcode.image.svg
|
||||||
from lxml import etree as ET
|
from lxml import etree as ET
|
||||||
|
|
||||||
import gettext
|
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()
|
self.units = self.app.ui.general_defaults_form.general_app_group.units_radio.get_value().upper()
|
||||||
|
|
||||||
def execute(self):
|
def execute(self):
|
||||||
svg_file = io.StringIO('')
|
svg_file = io.BytesIO()
|
||||||
svg_class = pyqrcode.QRCode("FlatCAM - 2D - Computer aided PCB Manufacturing Tool")
|
svg_file = qrcode.make("FlatCAM - 2D - Computer aided PCB Manufacturing Tool",
|
||||||
svg_class.svg(svg_file, scale=4, xmldecl=False)
|
image_factory=qrcode.image.svg.SvgFragmentImage)
|
||||||
|
|
||||||
def obj_init(geo_obj, app_obj):
|
def obj_init(geo_obj, app_obj):
|
||||||
print(svg_file)
|
units = self.app.ui.general_defaults_form.general_app_group.units_radio.get_value()
|
||||||
geo_obj.import_svg(svg_file)
|
try:
|
||||||
|
geo_obj.import_svg(svg_file)
|
||||||
|
except Exception as e:
|
||||||
|
print(str(e))
|
||||||
|
|
||||||
with self.app.proc_container.new("Import SVG"):
|
with self.app.proc_container.new("Import SVG"):
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user