Merge remote-tracking branch 'remotes/jpcgt/flatcam/Beta' into Beta

This commit is contained in:
camellan
2019-06-08 23:16:41 +04:00
68 changed files with 8057 additions and 7048 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1,15 +1,15 @@
############################################################
# ########################################################## ##
# FlatCAM: 2D Post-processing for Manufacturing #
# http://flatcam.org #
# Author: Juan Pablo Caram (c) #
# Date: 2/5/2014 #
# MIT Licence #
############################################################
# ########################################################## ##
############################################################
# ########################################################## ##
# File Modified (major mod): Marius Adrian Stanciu #
# Date: 3/10/2019 #
############################################################
# ########################################################## ##
from PyQt5 import QtGui, QtCore, QtWidgets
from PyQt5.QtCore import Qt, pyqtSignal, pyqtSlot
@@ -159,6 +159,10 @@ class LengthEntry(QtWidgets.QLineEdit):
'MM': 1.0}
}
self.readyToEdit = True
self.editingFinished.connect(self.on_edit_finished)
def on_edit_finished(self):
self.clearFocus()
def mousePressEvent(self, e, Parent=None):
super(LengthEntry, self).mousePressEvent(e) # required to deselect on 2e click
@@ -209,6 +213,10 @@ class FloatEntry(QtWidgets.QLineEdit):
def __init__(self, parent=None):
super(FloatEntry, self).__init__(parent)
self.readyToEdit = True
self.editingFinished.connect(self.on_edit_finished)
def on_edit_finished(self):
self.clearFocus()
def mousePressEvent(self, e, Parent=None):
super(FloatEntry, self).mousePressEvent(e) # required to deselect on 2e click
@@ -256,6 +264,10 @@ class FloatEntry2(QtWidgets.QLineEdit):
def __init__(self, parent=None):
super(FloatEntry2, self).__init__(parent)
self.readyToEdit = True
self.editingFinished.connect(self.on_edit_finished)
def on_edit_finished(self):
self.clearFocus()
def mousePressEvent(self, e, Parent=None):
super(FloatEntry2, self).mousePressEvent(e) # required to deselect on 2e click
@@ -295,6 +307,10 @@ class IntEntry(QtWidgets.QLineEdit):
self.allow_empty = allow_empty
self.empty_val = empty_val
self.readyToEdit = True
self.editingFinished.connect(self.on_edit_finished)
def on_edit_finished(self):
self.clearFocus()
def mousePressEvent(self, e, Parent=None):
super(IntEntry, self).mousePressEvent(e) # required to deselect on 2e click
@@ -335,6 +351,10 @@ class FCEntry(QtWidgets.QLineEdit):
def __init__(self, parent=None):
super(FCEntry, self).__init__(parent)
self.readyToEdit = True
self.editingFinished.connect(self.on_edit_finished)
def on_edit_finished(self):
self.clearFocus()
def mousePressEvent(self, e, Parent=None):
super(FCEntry, self).mousePressEvent(e) # required to deselect on 2e click
@@ -365,6 +385,10 @@ class FCEntry2(FCEntry):
def __init__(self, parent=None):
super(FCEntry2, self).__init__(parent)
self.readyToEdit = True
self.editingFinished.connect(self.on_edit_finished)
def on_edit_finished(self):
self.clearFocus()
def set_value(self, val):
try:
@@ -378,6 +402,10 @@ class EvalEntry(QtWidgets.QLineEdit):
def __init__(self, parent=None):
super(EvalEntry, self).__init__(parent)
self.readyToEdit = True
self.editingFinished.connect(self.on_edit_finished)
def on_edit_finished(self):
self.clearFocus()
def mousePressEvent(self, e, Parent=None):
super(EvalEntry, self).mousePressEvent(e) # required to deselect on 2e click
@@ -420,6 +448,10 @@ class EvalEntry2(QtWidgets.QLineEdit):
def __init__(self, parent=None):
super(EvalEntry2, self).__init__(parent)
self.readyToEdit = True
self.editingFinished.connect(self.on_edit_finished)
def on_edit_finished(self):
self.clearFocus()
def mousePressEvent(self, e, Parent=None):
super(EvalEntry2, self).mousePressEvent(e) # required to deselect on 2e click
@@ -1462,6 +1494,10 @@ class FCSpinner(QtWidgets.QSpinBox):
def __init__(self, parent=None):
super(FCSpinner, self).__init__(parent)
self.readyToEdit = True
self.editingFinished.connect(self.on_edit_finished)
def on_edit_finished(self):
self.clearFocus()
def mousePressEvent(self, e, parent=None):
super(FCSpinner, self).mousePressEvent(e) # required to deselect on 2e click
@@ -1497,6 +1533,10 @@ class FCDoubleSpinner(QtWidgets.QDoubleSpinBox):
def __init__(self, parent=None):
super(FCDoubleSpinner, self).__init__(parent)
self.readyToEdit = True
self.editingFinished.connect(self.on_edit_finished)
def on_edit_finished(self):
self.clearFocus()
def mousePressEvent(self, e, parent=None):
super(FCDoubleSpinner, self).mousePressEvent(e) # required to deselect on 2e click

View File

@@ -1,15 +1,15 @@
############################################################
# ########################################################## ##
# FlatCAM: 2D Post-processing for Manufacturing #
# http://flatcam.org #
# Author: Juan Pablo Caram (c) #
# Date: 2/5/2014 #
# MIT Licence #
############################################################
# ########################################################## ##
############################################################
# ########################################################## ##
# File Modified (major mod): Marius Adrian Stanciu #
# Date: 3/10/2019 #
############################################################
# ########################################################## ##
from PyQt5 import QtGui, QtCore, QtWidgets
from PyQt5.QtCore import Qt
@@ -36,22 +36,22 @@ class ObjectUI(QtWidgets.QWidget):
layout = QtWidgets.QVBoxLayout()
self.setLayout(layout)
## Page Title box (spacing between children)
# ## Page Title box (spacing between children)
self.title_box = QtWidgets.QHBoxLayout()
layout.addLayout(self.title_box)
## Page Title icon
# ## Page Title icon
pixmap = QtGui.QPixmap(icon_file)
self.icon = QtWidgets.QLabel()
self.icon.setPixmap(pixmap)
self.title_box.addWidget(self.icon, stretch=0)
## Title label
# ## Title label
self.title_label = QtWidgets.QLabel("<font size=5><b>%s</b></font>" % title)
self.title_label.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
self.title_box.addWidget(self.title_label, stretch=1)
## App Level label
# ## App Level label
self.level = QtWidgets.QLabel("")
self.level.setToolTip(
_(
@@ -66,16 +66,16 @@ class ObjectUI(QtWidgets.QWidget):
self.level.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
self.title_box.addWidget(self.level)
## Box box for custom widgets
# ## Box box for custom widgets
# This gets populated in offspring implementations.
self.custom_box = QtWidgets.QVBoxLayout()
layout.addLayout(self.custom_box)
###########################
## Common to all objects ##
###########################
######################### ##
# ## Common to all objects # ##
######################### ##
#### Scale ####
#### Scale ## ##
self.scale_label = QtWidgets.QLabel(_('<b>Scale:</b>'))
self.scale_label.setToolTip(
_("Change the size of the object.")
@@ -104,7 +104,7 @@ class ObjectUI(QtWidgets.QWidget):
self.scale_button.setFixedWidth(70)
self.scale_grid.addWidget(self.scale_button, 0, 2)
#### Offset ####
#### Offset ## ##
self.offset_label = QtWidgets.QLabel(_('<b>Offset:</b>'))
self.offset_label.setToolTip(
_("Change the position of this object.")
@@ -176,7 +176,7 @@ class GerberObjectUI(ObjectUI):
self.plot_cb.setFixedWidth(59)
grid0.addWidget(self.plot_cb, 0, 3)
## Object name
# ## Object name
self.name_hlay = QtWidgets.QHBoxLayout()
self.custom_box.addLayout(self.name_hlay)
name_label = QtWidgets.QLabel(_("<b>Name:</b>"))
@@ -188,7 +188,7 @@ class GerberObjectUI(ObjectUI):
hlay_plot = QtWidgets.QHBoxLayout()
self.custom_box.addLayout(hlay_plot)
#### Gerber Apertures ####
#### Gerber Apertures ## ##
self.apertures_table_label = QtWidgets.QLabel(_('<b>Apertures:</b>'))
self.apertures_table_label.setToolTip(
_("Apertures Table for the Gerber Object.")
@@ -380,7 +380,7 @@ class GerberObjectUI(ObjectUI):
grid2 = QtWidgets.QGridLayout()
self.custom_box.addLayout(grid2)
## Clear non-copper regions
# ## Clear non-copper regions
self.clearcopper_label = QtWidgets.QLabel(_("<b>Clear N-copper:</b>"))
self.clearcopper_label.setToolTip(
_("Create a Geometry object with\n"
@@ -396,7 +396,7 @@ class GerberObjectUI(ObjectUI):
)
grid2.addWidget(self.generate_ncc_button, 0, 1)
## Board cutout
# ## Board cutout
self.board_cutout_label = QtWidgets.QLabel(_("<b>Board cutout:</b>"))
self.board_cutout_label.setToolTip(
_("Create toolpaths to cut around\n"
@@ -412,7 +412,7 @@ class GerberObjectUI(ObjectUI):
)
grid2.addWidget(self.generate_cutout_button, 1, 1)
## Non-copper regions
# ## Non-copper regions
self.noncopper_label = QtWidgets.QLabel(_("<b>Non-copper regions:</b>"))
self.noncopper_label.setToolTip(
_("Create polygons covering the\n"
@@ -450,7 +450,7 @@ class GerberObjectUI(ObjectUI):
self.generate_noncopper_button = QtWidgets.QPushButton(_('Generate Geo'))
grid4.addWidget(self.generate_noncopper_button, 1, 1)
## Bounding box
# ## Bounding box
self.boundingbox_label = QtWidgets.QLabel(_('<b>Bounding Box:</b>'))
self.boundingbox_label.setToolTip(
_("Create a geometry surrounding the Gerber object.\n"
@@ -498,7 +498,7 @@ class ExcellonObjectUI(ObjectUI):
icon_file='share/drill32.png',
parent=parent)
#### Plot options ####
#### Plot options ## ##
hlay_plot = QtWidgets.QHBoxLayout()
self.custom_box.addLayout(hlay_plot)
@@ -511,7 +511,7 @@ class ExcellonObjectUI(ObjectUI):
hlay_plot.addStretch()
hlay_plot.addWidget(self.solid_cb)
## Object name
# ## Object name
self.name_hlay = QtWidgets.QHBoxLayout()
self.custom_box.addLayout(self.name_hlay)
name_label = QtWidgets.QLabel(_("<b>Name:</b>"))
@@ -532,7 +532,7 @@ class ExcellonObjectUI(ObjectUI):
hlay_plot = QtWidgets.QHBoxLayout()
self.tools_box.addLayout(hlay_plot)
#### Tools Drills ####
#### Tools Drills ## ##
self.tools_table_label = QtWidgets.QLabel(_('<b>Tools Table</b>'))
self.tools_table_label.setToolTip(
_("Tools in this Excellon object\n"
@@ -580,7 +580,7 @@ class ExcellonObjectUI(ObjectUI):
self.empty_label = QtWidgets.QLabel('')
self.tools_box.addWidget(self.empty_label)
#### Create CNC Job ####
#### Create CNC Job ## ##
self.cncjob_label = QtWidgets.QLabel(_('<b>Create CNC Job</b>'))
self.cncjob_label.setToolTip(
_("Create a CNC Job object\n"
@@ -768,7 +768,7 @@ class ExcellonObjectUI(ObjectUI):
)
self.tools_box.addWidget(self.generate_cnc_button)
#### Milling Holes Drills####
#### Milling Holes Drills## ##
self.mill_hole_label = QtWidgets.QLabel(_('<b>Mill Holes</b>'))
self.mill_hole_label.setToolTip(
_("Create Geometry for milling holes.")
@@ -833,7 +833,7 @@ class GeometryObjectUI(ObjectUI):
self.plot_options_label = QtWidgets.QLabel(_("<b>Plot Options:</b>"))
self.custom_box.addWidget(self.plot_options_label)
## Object name
# ## Object name
self.name_hlay = QtWidgets.QHBoxLayout()
self.custom_box.addLayout(self.name_hlay)
name_label = QtWidgets.QLabel(_("<b>Name:</b>"))
@@ -854,7 +854,7 @@ class GeometryObjectUI(ObjectUI):
hlay_plot = QtWidgets.QHBoxLayout()
self.geo_tools_box.addLayout(hlay_plot)
#### Tools ####
#### Tools ## ##
self.tools_table_label = QtWidgets.QLabel(_('<b>Tools Table</b>'))
self.tools_table_label.setToolTip(
_("Tools in this Geometry object used for cutting.\n"
@@ -964,7 +964,7 @@ class GeometryObjectUI(ObjectUI):
self.grid1.addWidget(self.tool_offset_entry, 0, 1)
self.grid1.addWidget(spacer_lbl, 0, 2)
#### Add a new Tool ####
#### Add a new Tool ## ##
hlay = QtWidgets.QHBoxLayout()
self.geo_tools_box.addLayout(hlay)
@@ -1022,7 +1022,7 @@ class GeometryObjectUI(ObjectUI):
#-----------------------------------
# Create CNC Job
#-----------------------------------
#### Tools Data ####
#### Tools Data ## ##
self.tool_data_label = QtWidgets.QLabel(_('<b>Tool Data</b>'))
self.tool_data_label.setToolTip(
_(
@@ -1346,7 +1346,7 @@ class CNCObjectUI(ObjectUI):
self.offset_label.hide()
self.offset_button.hide()
## Plot options
# ## Plot options
self.plot_options_label = QtWidgets.QLabel(_("<b>Plot Options:</b>"))
self.custom_box.addWidget(self.plot_options_label)
@@ -1366,7 +1366,17 @@ class CNCObjectUI(ObjectUI):
{"label": "Cut", "value": "cut"}
], stretch=False)
## Object name
self.annotation_label = QtWidgets.QLabel(_("<b>Display Annotation:</b>"))
self.annotation_label.setToolTip(
_(
"This selects if to display text annotation on the plot.\n"
"When checked it will display numbers in order for each end\n"
"of a travel line."
)
)
self.annotation_cb = FCCheckBox()
# ## Object name
self.name_hlay = QtWidgets.QHBoxLayout()
self.custom_box.addLayout(self.name_hlay)
name_label = QtWidgets.QLabel(_("<b>Name:</b>"))
@@ -1399,9 +1409,12 @@ class CNCObjectUI(ObjectUI):
f_lay.addWidget(self.cncplot_method_label, 0, 0)
f_lay.addWidget(self.cncplot_method_combo, 0, 1)
f_lay.addWidget(QtWidgets.QLabel(''), 0, 2)
f_lay.addWidget(self.t_distance_label, 1, 0)
f_lay.addWidget(self.t_distance_entry, 1, 1)
f_lay.addWidget(self.units_label, 1, 2)
f_lay.addWidget(self.annotation_label, 1, 0)
f_lay.addWidget(self.annotation_cb, 1, 1)
f_lay.addWidget(QtWidgets.QLabel(''), 1, 2)
f_lay.addWidget(self.t_distance_label, 2, 0)
f_lay.addWidget(self.t_distance_entry, 2, 1)
f_lay.addWidget(self.units_label, 2, 2)
self.t_distance_label.hide()
self.t_distance_entry.setVisible(False)
@@ -1462,9 +1475,9 @@ class CNCObjectUI(ObjectUI):
)
self.custom_box.addWidget(self.updateplot_button)
##################
## Export G-Code
##################
################ ##
# ## Export G-Code
################ ##
self.export_gcode_label = QtWidgets.QLabel(_("<b>Export CNC Code:</b>"))
self.export_gcode_label.setToolTip(
_("Export and save G-Code to\n"

View File

@@ -1,10 +1,10 @@
############################################################
# ########################################################## ##
# FlatCAM: 2D Post-processing for Manufacturing #
# http://caram.cl/software/flatcam #
# Author: Juan Pablo Caram (c) #
# Date: 2/5/2014 #
# MIT Licence #
############################################################
# ########################################################## ##
from PyQt5 import QtCore
@@ -51,7 +51,7 @@ class PlotCanvas(QtCore.QObject):
self.vispy_canvas.native.setParent(self.app.ui)
self.container.addWidget(self.vispy_canvas.native)
### AXIS ###
# ## AXIS # ##
self.v_line = InfiniteLine(pos=0, color=(0.70, 0.3, 0.3, 1.0), vertical=True,
parent=self.vispy_canvas.view.scene)
@@ -74,7 +74,7 @@ class PlotCanvas(QtCore.QObject):
self.text_collection = self.new_text_collection()
# TODO: Should be setting to show/hide CNC job annotations (global or per object)
self.text_collection.enabled = False
self.text_collection.enabled = True
# draw a rectangle made out of 4 lines on the canvas to serve as a hint for the work area
# all CNC have a limited workspace

View File

@@ -1,10 +1,10 @@
############################################################
# ########################################################## ##
# FlatCAM: 2D Post-processing for Manufacturing #
# http://flatcam.org #
# File Author: Dennis Hayrullin #
# Date: 2/5/2016 #
# MIT Licence #
############################################################
# ########################################################## ##
import numpy as np
from PyQt5.QtGui import QPalette

View File

@@ -1,10 +1,10 @@
############################################################
# ########################################################## ##
# FlatCAM: 2D Post-processing for Manufacturing #
# http://flatcam.org #
# File Author: Dennis Hayrullin #
# Date: 2/5/2016 #
# MIT Licence #
############################################################
# ########################################################## ##
from vispy.visuals import markers, LineVisual, InfiniteLineVisual
from vispy.visuals.axis import Ticker, _get_ticks_talbot

View File

@@ -1,10 +1,10 @@
############################################################
# ########################################################## ##
# FlatCAM: 2D Post-processing for Manufacturing #
# http://flatcam.org #
# File Author: Dennis Hayrullin #
# Date: 2/5/2016 #
# MIT Licence #
############################################################
# ########################################################## ##
from OpenGL import GLU

View File

@@ -1,10 +1,10 @@
############################################################
# ########################################################## ##
# FlatCAM: 2D Post-processing for Manufacturing #
# http://flatcam.org #
# File Author: Dennis Hayrullin #
# Date: 2/5/2016 #
# MIT Licence #
############################################################
# ########################################################## ##
from vispy.visuals import CompoundVisual, LineVisual, MeshVisual, TextVisual, MarkersVisual
from vispy.scene.visuals import VisualNode, generate_docstring, visuals
@@ -456,20 +456,26 @@ class TextCollectionVisual(TextVisual):
self.data = {}
self.last_key = -1
self.lock = threading.Lock()
self.method = 'gpu'
super(TextCollectionVisual, self).__init__(**kwargs)
self.freeze()
def add(self, text, pos, visible=True, update=True):
def add(self, text, pos, visible=True, update=True, font_size=9, color='black'):
"""
Adds array of text to collection
:param text: list
Array of strings ['str1', 'str2', ... ]
:param pos: list
Array of string positions [(0, 0), (10, 10), ... ]
:param visible: bool
| Set True to make it visible
:param update: bool
Set True to redraw collection
:param font_size: int
Set font size to redraw collection
:param color: string
Set font color to redraw collection
:return: int
Index of array
"""
@@ -480,7 +486,7 @@ class TextCollectionVisual(TextVisual):
self.lock.release()
# Prepare data for translation
self.data[key] = {'text': text, 'pos': pos, 'visible': visible}
self.data[key] = {'text': text, 'pos': pos, 'visible': visible,'font_size': font_size, 'color': color}
if update:
self.redraw()
@@ -516,6 +522,8 @@ class TextCollectionVisual(TextVisual):
"""
labels = []
pos = []
font_s = 9
color = 'black'
# Merge buffers
for data in list(self.data.values()):
@@ -523,6 +531,8 @@ class TextCollectionVisual(TextVisual):
try:
labels += data['text']
pos += data['pos']
font_s = data['font_size']
color = data['color']
except Exception as e:
print("Data error", e)
@@ -530,6 +540,8 @@ class TextCollectionVisual(TextVisual):
if len(labels) > 0:
self.text = labels
self.pos = pos
self.font_size = font_s
self.color = color
else:
self.text = None
self.pos = (0, 0)