- in Tool Film added the page size and page orientation in case of saving the film as PDF file

- the application workspace has now a lot more options selectable in the Edit -> Preferences -> General -> GUI Preferences
This commit is contained in:
Marius Stanciu
2019-11-27 03:44:28 +02:00
committed by Marius
parent f1af9d7999
commit 58f24cbb37
7 changed files with 453 additions and 84 deletions

View File

@@ -76,7 +76,7 @@ class PlotCanvas(QtCore.QObject, VisPyCanvas):
# 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
self.draw_workspace()
self.draw_workspace(pagesize=self.fcapp.defaults["global_workspaceT"])
self.line_parent = None
self.cursor_v_line = InfiniteLine(pos=None, color=self.line_color, vertical=True,
@@ -107,37 +107,122 @@ class PlotCanvas(QtCore.QObject, VisPyCanvas):
# 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
def draw_workspace(self):
a = np.empty((0, 0))
# def draw_workspace(self):
# a = np.empty((0, 0))
#
# a4p_in = np.array([(0, 0), (8.3, 0), (8.3, 11.7), (0, 11.7)])
# a4l_in = np.array([(0, 0), (11.7, 0), (11.7, 8.3), (0, 8.3)])
# a3p_in = np.array([(0, 0), (11.7, 0), (11.7, 16.5), (0, 16.5)])
# a3l_in = np.array([(0, 0), (16.5, 0), (16.5, 11.7), (0, 11.7)])
#
# a4p_mm = np.array([(0, 0), (210, 0), (210, 297), (0, 297)])
# a4l_mm = np.array([(0, 0), (297, 0), (297, 210), (0, 210)])
# a3p_mm = np.array([(0, 0), (297, 0), (297, 420), (0, 420)])
# a3l_mm = np.array([(0, 0), (420, 0), (420, 297), (0, 297)])
#
# if self.fcapp.defaults['units'].upper() == 'MM':
# if self.fcapp.defaults['global_workspaceT'] == 'A4P':
# a = a4p_mm
# elif self.fcapp.defaults['global_workspaceT'] == 'A4L':
# a = a4l_mm
# elif self.fcapp.defaults['global_workspaceT'] == 'A3P':
# a = a3p_mm
# elif self.fcapp.defaults['global_workspaceT'] == 'A3L':
# a = a3l_mm
# else:
# if self.fcapp.defaults['global_workspaceT'] == 'A4P':
# a = a4p_in
# elif self.fcapp.defaults['global_workspaceT'] == 'A4L':
# a = a4l_in
# elif self.fcapp.defaults['global_workspaceT'] == 'A3P':
# a = a3p_in
# elif self.fcapp.defaults['global_workspaceT'] == 'A3L':
# a = a3l_in
#
# self.delete_workspace()
#
# self.b_line = Line(pos=a[0:2], color=(0.70, 0.3, 0.3, 1.0),
# antialias=True, method='agg', parent=self.view.scene)
# self.r_line = Line(pos=a[1:3], color=(0.70, 0.3, 0.3, 1.0),
# antialias=True, method='agg', parent=self.view.scene)
#
# self.t_line = Line(pos=a[2:4], color=(0.70, 0.3, 0.3, 1.0),
# antialias=True, method='agg', parent=self.view.scene)
# self.l_line = Line(pos=np.array((a[0], a[3])), color=(0.70, 0.3, 0.3, 1.0),
# antialias=True, method='agg', parent=self.view.scene)
#
# if self.fcapp.defaults['global_workspace'] is False:
# self.delete_workspace()
a4p_in = np.array([(0, 0), (8.3, 0), (8.3, 11.7), (0, 11.7)])
a4l_in = np.array([(0, 0), (11.7, 0), (11.7, 8.3), (0, 8.3)])
a3p_in = np.array([(0, 0), (11.7, 0), (11.7, 16.5), (0, 16.5)])
a3l_in = np.array([(0, 0), (16.5, 0), (16.5, 11.7), (0, 11.7)])
# delete the workspace lines from the plot by removing the parent
a4p_mm = np.array([(0, 0), (210, 0), (210, 297), (0, 297)])
a4l_mm = np.array([(0, 0), (297, 0), (297, 210), (0, 210)])
a3p_mm = np.array([(0, 0), (297, 0), (297, 420), (0, 420)])
a3l_mm = np.array([(0, 0), (420, 0), (420, 297), (0, 297)])
def draw_workspace(self, pagesize):
pagesize_dict = dict()
pagesize_dict.update(
{
'A0': (841, 1189),
'A1': (594, 841),
'A2': (420, 594),
'A3': (297, 420),
'A4': (210, 297),
'A5': (148, 210),
'A6': (105, 148),
'A7': (74, 105),
'A8': (52, 74),
'A9': (37, 52),
'A10': (26, 37),
if self.fcapp.defaults['units'].upper() == 'MM':
if self.fcapp.defaults['global_workspaceT'] == 'A4P':
a = a4p_mm
elif self.fcapp.defaults['global_workspaceT'] == 'A4L':
a = a4l_mm
elif self.fcapp.defaults['global_workspaceT'] == 'A3P':
a = a3p_mm
elif self.fcapp.defaults['global_workspaceT'] == 'A3L':
a = a3l_mm
else:
if self.fcapp.defaults['global_workspaceT'] == 'A4P':
a = a4p_in
elif self.fcapp.defaults['global_workspaceT'] == 'A4L':
a = a4l_in
elif self.fcapp.defaults['global_workspaceT'] == 'A3P':
a = a3p_in
elif self.fcapp.defaults['global_workspaceT'] == 'A3L':
a = a3l_in
'B0': (1000, 1414),
'B1': (707, 1000),
'B2': (500, 707),
'B3': (353, 500),
'B4': (250, 353),
'B5': (176, 250),
'B6': (125, 176),
'B7': (88, 125),
'B8': (62, 88),
'B9': (44, 62),
'B10': (31, 44),
'C0': (917, 1297),
'C1': (648, 917),
'C2': (458, 648),
'C3': (324, 458),
'C4': (229, 324),
'C5': (162, 229),
'C6': (114, 162),
'C7': (81, 114),
'C8': (57, 81),
'C9': (40, 57),
'C10': (28, 40),
# American paper sizes
'LETTER': (8.5*25.4, 11*25.4),
'LEGAL': (8.5*25.4, 14*25.4),
'ELEVENSEVENTEEN': (11*25.4, 17*25.4),
# From https://en.wikipedia.org/wiki/Paper_size
'JUNIOR_LEGAL': (5*25.4, 8*25.4),
'HALF_LETTER': (5.5*25.4, 8*25.4),
'GOV_LETTER': (8*25.4, 10.5*25.4),
'GOV_LEGAL': (8.5*25.4, 13*25.4),
'LEDGER': (17*25.4, 11*25.4),
}
)
try:
if self.fcapp.defaults['units'].upper() == 'MM':
dims = pagesize_dict[pagesize]
else:
dims = (pagesize_dict[pagesize][0]/25.4, pagesize_dict[pagesize][1]/25.4)
except Exception as e:
log.debug("PlotCanvas.draw_workspace() --> %s" % str(e))
return
if self.fcapp.defaults['global_workspace_orientation'] == 'l':
dims = (dims[1], dims[0])
a = np.array([(0, 0), (dims[0], 0), (dims[0], dims[1]), (0, dims[1])])
self.delete_workspace()
@@ -154,7 +239,6 @@ class PlotCanvas(QtCore.QObject, VisPyCanvas):
if self.fcapp.defaults['global_workspace'] is False:
self.delete_workspace()
# delete the workspace lines from the plot by removing the parent
def delete_workspace(self):
try:
self.b_line.parent = None

View File

@@ -343,19 +343,92 @@ class GeneralGUIPrefGroupUI(OptionsGroupUI):
_("Draw a delimiting rectangle on canvas.\n"
"The purpose is to illustrate the limits for our work.")
)
self.workspace_type_lbl = QtWidgets.QLabel('%s:' % _('Wk. format'))
self.workspace_type_lbl = QtWidgets.QLabel('%s:' % _('Wk. size'))
self.workspace_type_lbl.setToolTip(
_("Select the type of rectangle to be used on canvas,\n"
"as valid workspace.")
)
self.workspace_cb = FCCheckBox()
self.wk_cb = FCComboBox()
self.wk_cb.addItem('A4P')
self.wk_cb.addItem('A4L')
self.wk_cb.addItem('A3P')
self.wk_cb.addItem('A3L')
self.wks = OptionalInputSection(self.workspace_cb, [self.workspace_type_lbl, self.wk_cb])
self.pagesize = dict()
self.pagesize.update(
{
'A0': (841, 1189),
'A1': (594, 841),
'A2': (420, 594),
'A3': (297, 420),
'A4': (210, 297),
'A5': (148, 210),
'A6': (105, 148),
'A7': (74, 105),
'A8': (52, 74),
'A9': (37, 52),
'A10': (26, 37),
'B0': (1000, 1414),
'B1': (707, 1000),
'B2': (500, 707),
'B3': (353, 500),
'B4': (250, 353),
'B5': (176, 250),
'B6': (125, 176),
'B7': (88, 125),
'B8': (62, 88),
'B9': (44, 62),
'B10': (31, 44),
'C0': (917, 1297),
'C1': (648, 917),
'C2': (458, 648),
'C3': (324, 458),
'C4': (229, 324),
'C5': (162, 229),
'C6': (114, 162),
'C7': (81, 114),
'C8': (57, 81),
'C9': (40, 57),
'C10': (28, 40),
# American paper sizes
'LETTER': (8.5, 11),
'LEGAL': (8.5, 14),
'ELEVENSEVENTEEN': (11, 17),
# From https://en.wikipedia.org/wiki/Paper_size
'JUNIOR_LEGAL': (5, 8),
'HALF_LETTER': (5.5, 8),
'GOV_LETTER': (8, 10.5),
'GOV_LEGAL': (8.5, 13),
'LEDGER': (17, 11),
}
)
page_size_list = list(self.pagesize.keys())
self.wk_cb.addItems(page_size_list)
# self.wk_cb.addItem('A4P')
# self.wk_cb.addItem('A4L')
# self.wk_cb.addItem('A3P')
# self.wk_cb.addItem('A3L')
# Page orientation
self.wk_orientation_label = QtWidgets.QLabel('%s:' % _("Wk. Orientation"))
self.wk_orientation_label.setToolTip(_("Can be:\n"
"- Portrait\n"
"- Landscape"))
self.wk_orientation_radio = RadioSet([{'label': _('Portrait'), 'value': 'p'},
{'label': _('Landscape'), 'value': 'l'},
], stretch=False)
self.wks = OptionalInputSection(self.workspace_cb,
[
self.workspace_type_lbl,
self.wk_cb,
self.wk_orientation_label,
self.wk_orientation_radio
])
# Plot Fill Color
self.pf_color_label = QtWidgets.QLabel('%s:' % _('Plot Fill'))
@@ -579,6 +652,8 @@ class GeneralGUIPrefGroupUI(OptionsGroupUI):
self.form_box.addRow(self.workspace_lbl, self.workspace_cb)
self.form_box.addRow(self.workspace_type_lbl, self.wk_cb)
self.form_box.addRow(self.wk_orientation_label, self.wk_orientation_radio)
self.form_box.addRow(self.spacelabel, self.spacelabel)
self.form_box.addRow(self.pf_color_label, self.form_box_child_1)
self.form_box.addRow(self.pf_alpha_label, self.form_box_child_2)
@@ -4654,6 +4729,84 @@ class ToolsFilmPrefGroupUI(OptionsGroupUI):
grid0.addWidget(self.file_type_label, 15, 0)
grid0.addWidget(self.file_type_radio, 15, 1)
# Page orientation
self.orientation_label = QtWidgets.QLabel('%s:' % _("Page Orientation"))
self.orientation_label.setToolTip(_("Can be:\n"
"- Portrait\n"
"- Lanscape"))
self.orientation_radio = RadioSet([{'label': _('Portrait'), 'value': 'p'},
{'label': _('Landscape'), 'value': 'l'},
], stretch=False)
grid0.addWidget(self.orientation_label, 16, 0)
grid0.addWidget(self.orientation_radio, 16, 1)
# Page Size
self.pagesize_label = QtWidgets.QLabel('%s:' % _("Page Size"))
self.pagesize_label.setToolTip(_("A selection of standard ISO 216 page sizes."))
self.pagesize_combo = FCComboBox()
self.pagesize = dict()
self.pagesize.update(
{
'Bounds': None,
'A0': (841, 1189),
'A1': (594, 841),
'A2': (420, 594),
'A3': (297, 420),
'A4': (210, 297),
'A5': (148, 210),
'A6': (105, 148),
'A7': (74, 105),
'A8': (52, 74),
'A9': (37, 52),
'A10': (26, 37),
'B0': (1000, 1414),
'B1': (707, 1000),
'B2': (500, 707),
'B3': (353, 500),
'B4': (250, 353),
'B5': (176, 250),
'B6': (125, 176),
'B7': (88, 125),
'B8': (62, 88),
'B9': (44, 62),
'B10': (31, 44),
'C0': (917, 1297),
'C1': (648, 917),
'C2': (458, 648),
'C3': (324, 458),
'C4': (229, 324),
'C5': (162, 229),
'C6': (114, 162),
'C7': (81, 114),
'C8': (57, 81),
'C9': (40, 57),
'C10': (28, 40),
# American paper sizes
'LETTER': (8.5, 11),
'LEGAL': (8.5, 14),
'ELEVENSEVENTEEN': (11, 17),
# From https://en.wikipedia.org/wiki/Paper_size
'JUNIOR_LEGAL': (5, 8),
'HALF_LETTER': (5.5, 8),
'GOV_LETTER': (8, 10.5),
'GOV_LEGAL': (8.5, 13),
'LEDGER': (17, 11),
}
)
page_size_list = list(self.pagesize.keys())
self.pagesize_combo.addItems(page_size_list)
grid0.addWidget(self.pagesize_label, 17, 0)
grid0.addWidget(self.pagesize_combo, 17, 1)
self.layout.addStretch()