Commit 35b8f97e authored by sumpfralle's avatar sumpfralle

vertical centering of text preview

added a small white border around the text preview
fixed preview of letters containing closed polygons


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@928 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent b65b6498
......@@ -12,6 +12,7 @@ Version 0.4.1 - UNRELEASED
* added support for DXF feature "LWPOLYLINE"
* added a configuration setting for automatically loading a custom task settings file on startup
* added a simple "undo" feature for reversing model manipulations
* added a minimum step width for GCode positions to be written
* the default filename extension for exported GCode files is now configurable
* unify DropCutter behaviour for models that are higher than the defined bounding box
* always move up to safety height in this case
......
......@@ -7595,7 +7595,7 @@ Please read the description of the Server Mode (linked below) to understand the
<child>
<object class="GtkHBox" id="hbox33">
<property name="visible">True</property>
<property name="spacing">2</property>
<property name="spacing">3</property>
<child>
<object class="GtkLabel" id="FontAuthorLabel">
<property name="visible">True</property>
......@@ -7620,6 +7620,9 @@ Please read the description of the Server Mode (linked below) to understand the
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="padding">5</property>
<property name="position">2</property>
</packing>
</child>
......@@ -7631,12 +7634,43 @@ Please read the description of the Server Mode (linked below) to understand the
<property name="use_markup">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkHSeparator" id="hseparator5">
<object class="GtkHBox" id="hbox28">
<property name="visible">True</property>
<property name="spacing">3</property>
<child>
<object class="GtkLabel" id="FontExamplesLinkLabel">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Rendered overview of all fonts:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLinkButton" id="FontExamplesLink">
<property name="label">gtk-index</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="has_tooltip">True</property>
<property name="relief">none</property>
<property name="use_stock">True</property>
<property name="uri">http://sourceforge.net/apps/mediawiki/pycam/index.php?title=EngraveFonts</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
......@@ -7644,6 +7678,16 @@ Please read the description of the Server Mode (linked below) to understand the
<property name="position">4</property>
</packing>
</child>
<child>
<object class="GtkHSeparator" id="hseparator5">
<property name="visible">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">5</property>
</packing>
</child>
<child>
<object class="GtkHBox" id="hbox35">
<property name="visible">True</property>
......@@ -7724,7 +7768,7 @@ Please read the description of the Server Mode (linked below) to understand the
</object>
<packing>
<property name="expand">False</property>
<property name="position">5</property>
<property name="position">6</property>
</packing>
</child>
<child>
......@@ -7746,7 +7790,7 @@ Please read the description of the Server Mode (linked below) to understand the
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">6</property>
<property name="position">7</property>
</packing>
</child>
<child>
......@@ -7756,7 +7800,7 @@ Please read the description of the Server Mode (linked below) to understand the
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">7</property>
<property name="position">8</property>
</packing>
</child>
<child>
......@@ -7769,7 +7813,7 @@ Please read the description of the Server Mode (linked below) to understand the
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">8</property>
<property name="position">9</property>
</packing>
</child>
<child>
......@@ -7786,7 +7830,7 @@ Please read the description of the Server Mode (linked below) to understand the
</child>
</object>
<packing>
<property name="position">9</property>
<property name="position">10</property>
</packing>
</child>
<child internal-child="action_area">
......@@ -7838,7 +7882,7 @@ Please read the description of the Server Mode (linked below) to understand the
<packing>
<property name="expand">False</property>
<property name="pack_type">end</property>
<property name="position">10</property>
<property name="position">11</property>
</packing>
</child>
</object>
......@@ -8081,6 +8125,6 @@ upon interesting bugs and weird results.</property>
</object>
<object class="GtkAdjustment" id="GCodeMinimumStepValue">
<property name="upper">100</property>
<property name="step_increment">5.0000000000000004e-05</property>
<property name="step_increment">5.0000000000000002e-05</property>
</object>
</interface>
......@@ -1854,24 +1854,36 @@ class ProjectGui:
0, 0, width, height)
# carefully check if there are lines in the rendered text
if text_model and (not text_model.maxx is None):
x_fac = (width - 1) / (text_model.maxx - text_model.minx)
y_fac = (height - 1) / (text_model.maxy - text_model.miny)
# leave a small border around the preview
border = 3
x_fac = (width - 1 - 2 * border) / \
(text_model.maxx - text_model.minx)
y_fac = (height - 1 - 2 * border) / \
(text_model.maxy - text_model.miny)
factor = min(x_fac, y_fac)
# vertically centered preview
y_offset = int((height - 2 * border - \
factor * (text_model.maxy - text_model.miny)) // 2)
gc = drawing_area.new_gc()
if text_model.minx == 0:
# left align
get_virtual_x = lambda x: int(x * factor)
get_virtual_x = lambda x: int(x * factor) + border
elif text_model.maxx == 0:
# right align
get_virtual_x = lambda x: width + int(x * factor) - 1
get_virtual_x = lambda x: width + int(x * factor) - 1 - border
else:
# center align
get_virtual_x = lambda x: int(width / 2.0 + x * factor) - 1
get_virtual_y = lambda y: \
height - int((y - text_model.miny) * factor) - 1
get_virtual_x = lambda x: \
int(width / 2.0 + x * factor) - 1 - border
get_virtual_y = lambda y: -y_offset + \
height - int((y - text_model.miny) * factor) - 1 - border
for polygon in text_model.get_polygons():
draw_points = []
for point in polygon.get_points():
points = polygon.get_points()
if polygon.is_closed:
# add the first point again to close the polygon
points.append(points[0])
for point in points:
x = get_virtual_x(point.x)
y = get_virtual_y(point.y)
draw_points.append((x, y))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment