- added a new parameter in Edit -> Preferences -> CNCJob named Annotation Color; it controls the color of the font used for annotations

- added a new parameter in Edit -> Preferences -> CNCJob named Annotation Size; it controls the size of the font used for annotations
- made visibility change threaded in FlatCAMObj()
This commit is contained in:
Marius Stanciu
2019-06-03 22:59:45 +03:00
parent 2a30101bb0
commit f06fec12ea
6 changed files with 120 additions and 29 deletions

View File

@@ -5458,45 +5458,77 @@ class CNCJobGenPrefGroupUI(OptionsGroupUI):
grid0.addWidget(self.annotation_cb, 2, 1)
grid0.addWidget(QtWidgets.QLabel(''), 2, 2)
# Number of circle steps for circular aperture linear approximation
# Annotation Font Size
self.annotation_fontsize_label = QtWidgets.QLabel(_("Annotation Size:"))
self.annotation_fontsize_label.setToolTip(
_("The font size of the annotation text. In pixels.")
)
grid0.addWidget(self.annotation_fontsize_label, 3, 0)
self.annotation_fontsize_sp = FCSpinner()
grid0.addWidget(self.annotation_fontsize_sp, 3, 1)
grid0.addWidget(QtWidgets.QLabel(''), 3, 2)
# Annotation Font Color
self.annotation_color_label = QtWidgets.QLabel(_('Annotation Color:'))
self.annotation_color_label.setToolTip(
_("Set the font color for the annotation texts.\n")
)
self.annotation_fontcolor_entry = FCEntry()
self.annotation_fontcolor_button = QtWidgets.QPushButton()
self.annotation_fontcolor_button.setFixedSize(15, 15)
self.form_box_child = QtWidgets.QHBoxLayout()
self.form_box_child.addWidget(self.annotation_fontcolor_entry)
self.form_box_child.addWidget(self.annotation_fontcolor_button)
self.form_box_child.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
color_widget = QtWidgets.QWidget()
color_widget.setLayout(self.form_box_child)
grid0.addWidget(self.annotation_color_label, 4, 0)
grid0.addWidget(color_widget, 4, 1)
grid0.addWidget(QtWidgets.QLabel(''), 4, 2)
# ###################################################################
# Number of circle steps for circular aperture linear approximation #
# ###################################################################
self.steps_per_circle_label = QtWidgets.QLabel(_("Circle Steps:"))
self.steps_per_circle_label.setToolTip(
_("The number of circle steps for <b>GCode</b> \n"
"circle and arc shapes linear approximation.")
"circle and arc shapes linear approximation.")
)
grid0.addWidget(self.steps_per_circle_label, 3, 0)
grid0.addWidget(self.steps_per_circle_label, 5, 0)
self.steps_per_circle_entry = IntEntry()
grid0.addWidget(self.steps_per_circle_entry, 3, 1)
grid0.addWidget(self.steps_per_circle_entry, 5, 1)
# Tool dia for plot
tdlabel = QtWidgets.QLabel(_('Tool dia:'))
tdlabel.setToolTip(
_("Diameter of the tool to be\n"
"rendered in the plot.")
"rendered in the plot.")
)
grid0.addWidget(tdlabel, 4, 0)
grid0.addWidget(tdlabel, 6, 0)
self.tooldia_entry = LengthEntry()
grid0.addWidget(self.tooldia_entry,4, 1)
grid0.addWidget(self.tooldia_entry,6, 1)
# Number of decimals to use in GCODE coordinates
cdeclabel = QtWidgets.QLabel(_('Coords dec.:'))
cdeclabel.setToolTip(
_("The number of decimals to be used for \n"
"the X, Y, Z coordinates in CNC code (GCODE, etc.)")
"the X, Y, Z coordinates in CNC code (GCODE, etc.)")
)
grid0.addWidget(cdeclabel, 5, 0)
grid0.addWidget(cdeclabel, 7, 0)
self.coords_dec_entry = IntEntry()
grid0.addWidget(self.coords_dec_entry, 5, 1)
grid0.addWidget(self.coords_dec_entry, 7, 1)
# Number of decimals to use in GCODE feedrate
frdeclabel = QtWidgets.QLabel(_('Feedrate dec.:'))
frdeclabel.setToolTip(
_("The number of decimals to be used for \n"
"the Feedrate parameter in CNC code (GCODE, etc.)")
"the Feedrate parameter in CNC code (GCODE, etc.)")
)
grid0.addWidget(frdeclabel, 6, 0)
grid0.addWidget(frdeclabel, 8, 0)
self.fr_dec_entry = IntEntry()
grid0.addWidget(self.fr_dec_entry, 6, 1)
grid0.addWidget(self.fr_dec_entry, 8, 1)
self.layout.addStretch()

View File

@@ -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)