- start working on QRCode Tool - not working yet

This commit is contained in:
Marius Stanciu 2019-10-22 17:32:33 +03:00
parent cff0787107
commit bf670d7967
7 changed files with 123 additions and 1 deletions

View File

@ -2523,6 +2523,7 @@ class App(QtCore.QObject):
self.image_tool = None self.image_tool = None
self.pcb_wizard_tool = None self.pcb_wizard_tool = None
self.cal_exc_tool = None self.cal_exc_tool = None
self.qrcode_tool = None
# always install tools only after the shell is initialized because the self.inform.emit() depends on shell # always install tools only after the shell is initialized because the self.inform.emit() depends on shell
self.install_tools() self.install_tools()
@ -3109,6 +3110,9 @@ class App(QtCore.QObject):
self.paint_tool.install(icon=QtGui.QIcon('share/paint16.png'), pos=self.ui.menutool, self.paint_tool.install(icon=QtGui.QIcon('share/paint16.png'), pos=self.ui.menutool,
before=self.sub_tool.menuAction, separator=True) before=self.sub_tool.menuAction, separator=True)
self.qrcode_tool = QRCode(self)
self.qrcode_tool.install(icon=QtGui.QIcon('share/qrcode32.png'), pos=self.ui.menutool)
self.transform_tool = ToolTransform(self) self.transform_tool = ToolTransform(self)
self.transform_tool.install(icon=QtGui.QIcon('share/transform.png'), pos=self.ui.menuoptions, separator=True) self.transform_tool.install(icon=QtGui.QIcon('share/transform.png'), pos=self.ui.menuoptions, separator=True)
@ -3232,6 +3236,7 @@ class App(QtCore.QObject):
self.ui.calculators_btn.triggered.connect(lambda: self.calculator_tool.run(toggle=True)) self.ui.calculators_btn.triggered.connect(lambda: self.calculator_tool.run(toggle=True))
self.ui.transform_btn.triggered.connect(lambda: self.transform_tool.run(toggle=True)) self.ui.transform_btn.triggered.connect(lambda: self.transform_tool.run(toggle=True))
self.ui.qrcode_btn.triggered.connect(lambda: self.qrcode_tool.run(toggle=True))
def object2editor(self): def object2editor(self):
""" """

View File

@ -12,6 +12,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
21.10.2019 21.10.2019

View File

@ -755,6 +755,7 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.calculators_btn = self.toolbartools.addAction(QtGui.QIcon('share/calculator24.png'), _("Calculators Tool")) self.calculators_btn = self.toolbartools.addAction(QtGui.QIcon('share/calculator24.png'), _("Calculators Tool"))
self.transform_btn = self.toolbartools.addAction(QtGui.QIcon('share/transform.png'), _("Transform Tool")) self.transform_btn = self.toolbartools.addAction(QtGui.QIcon('share/transform.png'), _("Transform Tool"))
self.qrcode_btn = self.toolbartools.addAction(QtGui.QIcon('share/qrcode32.png'), _("QRCode Tool"))
# ######################################################################## # ########################################################################
# ########################## Excellon Editor Toolbar# #################### # ########################## Excellon Editor Toolbar# ####################
@ -2171,6 +2172,7 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.calculators_btn = self.toolbartools.addAction(QtGui.QIcon('share/calculator24.png'), self.calculators_btn = self.toolbartools.addAction(QtGui.QIcon('share/calculator24.png'),
_("Calculators Tool")) _("Calculators Tool"))
self.transform_btn = self.toolbartools.addAction(QtGui.QIcon('share/transform.png'), _("Transform Tool")) self.transform_btn = self.toolbartools.addAction(QtGui.QIcon('share/transform.png'), _("Transform Tool"))
self.qrcode_btn = self.toolbartools.addAction(QtGui.QIcon('share/qrcode32.png'), _("QRCode Tool"))
# ## Excellon Editor Toolbar # ## # ## Excellon Editor Toolbar # ##
self.select_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/pointer32.png'), _("Select")) self.select_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/pointer32.png'), _("Select"))

113
flatcamTools/ToolQRCode.py Normal file
View File

@ -0,0 +1,113 @@
# ##########################################################
# FlatCAM: 2D Post-processing for Manufacturing #
# File Author: Marius Adrian Stanciu (c) #
# Date: 3/10/2019 #
# MIT Licence #
# ##########################################################
from PyQt5 import QtWidgets, QtCore
from FlatCAMTool import FlatCAMTool
from flatcamGUI.GUIElements import FCDoubleSpinner, EvalEntry, FCCheckBox
from camlib import *
from shapely.geometry import Point
from shapely.geometry.base import *
import math
import io
from datetime import datetime
import logging
import pyqrcode
from lxml import etree as ET
import gettext
import FlatCAMTranslation as fcTranslate
import builtins
fcTranslate.apply_language('strings')
if '_' not in builtins.__dict__:
_ = gettext.gettext
log = logging.getLogger('base')
class QRCode(FlatCAMTool):
toolName = _("QRCode Tool")
def __init__(self, app):
FlatCAMTool.__init__(self, app)
self.app = app
self.canvas = self.app.plotcanvas
self.decimals = 4
self.units = ''
# ## Title
title_label = QtWidgets.QLabel("%s" % self.toolName)
title_label.setStyleSheet("""
QLabel
{
font-size: 16px;
font-weight: bold;
}
""")
self.layout.addWidget(title_label)
def run(self, toggle=True):
self.app.report_usage("QRCode()")
if toggle:
# if the splitter is hidden, display it, else hide it but only if the current widget is the same
if self.app.ui.splitter.sizes()[0] == 0:
self.app.ui.splitter.setSizes([1, 1])
else:
try:
if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName:
# if tab is populated with the tool but it does not have the focus, focus on it
if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab:
# focus on Tool Tab
self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab)
else:
self.app.ui.splitter.setSizes([0, 1])
except AttributeError:
pass
else:
if self.app.ui.splitter.sizes()[0] == 0:
self.app.ui.splitter.setSizes([1, 1])
FlatCAMTool.run(self)
self.set_tool_ui()
self.app.ui.notebook.setTabText(2, _("QRCode Tool"))
self.execute()
def install(self, icon=None, separator=None, **kwargs):
FlatCAMTool.install(self, icon, separator, shortcut='ALT+Q', **kwargs)
def set_tool_ui(self):
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)
def obj_init(geo_obj, app_obj):
print(svg_file)
geo_obj.import_svg(svg_file)
with self.app.proc_container.new("Import SVG"):
# Object creation
self.app.new_object('geometry', 'generated_qrcode', obj_init, plot=False)
# # Register recent file
# self.app.file_opened.emit("svg", img)
#
# # GUI feedback
# self.app.inform.emit("Opened: " + img)

View File

@ -26,6 +26,7 @@ from flatcamTools.ToolPcbWizard import PcbWizard
from flatcamTools.ToolPDF import ToolPDF from flatcamTools.ToolPDF import ToolPDF
from flatcamTools.ToolProperties import Properties from flatcamTools.ToolProperties import Properties
from flatcamTools.ToolQRCode import QRCode
from flatcamTools.ToolRulesCheck import RulesCheck from flatcamTools.ToolRulesCheck import RulesCheck
from flatcamTools.ToolShell import FCShell from flatcamTools.ToolShell import FCShell

BIN
share/qrcode32.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -1,4 +1,4 @@
from ObjectCollection import * from camlib import *
from tclCommands.TclCommand import TclCommandSignaled from tclCommands.TclCommand import TclCommandSignaled