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 ...@@ -12,6 +12,7 @@ Version 0.4.1 - UNRELEASED
* added support for DXF feature "LWPOLYLINE" * added support for DXF feature "LWPOLYLINE"
* added a configuration setting for automatically loading a custom task settings file on startup * 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 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 * the default filename extension for exported GCode files is now configurable
* unify DropCutter behaviour for models that are higher than the defined bounding box * unify DropCutter behaviour for models that are higher than the defined bounding box
* always move up to safety height in this case * 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 ...@@ -7595,7 +7595,7 @@ Please read the description of the Server Mode (linked below) to understand the
<child> <child>
<object class="GtkHBox" id="hbox33"> <object class="GtkHBox" id="hbox33">
<property name="visible">True</property> <property name="visible">True</property>
<property name="spacing">2</property> <property name="spacing">3</property>
<child> <child>
<object class="GtkLabel" id="FontAuthorLabel"> <object class="GtkLabel" id="FontAuthorLabel">
<property name="visible">True</property> <property name="visible">True</property>
...@@ -7620,6 +7620,9 @@ Please read the description of the Server Mode (linked below) to understand the ...@@ -7620,6 +7620,9 @@ Please read the description of the Server Mode (linked below) to understand the
</child> </child>
</object> </object>
<packing> <packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="padding">5</property>
<property name="position">2</property> <property name="position">2</property>
</packing> </packing>
</child> </child>
...@@ -7631,12 +7634,43 @@ Please read the description of the Server Mode (linked below) to understand the ...@@ -7631,12 +7634,43 @@ Please read the description of the Server Mode (linked below) to understand the
<property name="use_markup">True</property> <property name="use_markup">True</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property>
<property name="position">3</property> <property name="position">3</property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkHSeparator" id="hseparator5"> <object class="GtkHBox" id="hbox28">
<property name="visible">True</property> <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> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
...@@ -7644,6 +7678,16 @@ Please read the description of the Server Mode (linked below) to understand the ...@@ -7644,6 +7678,16 @@ Please read the description of the Server Mode (linked below) to understand the
<property name="position">4</property> <property name="position">4</property>
</packing> </packing>
</child> </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> <child>
<object class="GtkHBox" id="hbox35"> <object class="GtkHBox" id="hbox35">
<property name="visible">True</property> <property name="visible">True</property>
...@@ -7724,7 +7768,7 @@ Please read the description of the Server Mode (linked below) to understand the ...@@ -7724,7 +7768,7 @@ Please read the description of the Server Mode (linked below) to understand the
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="position">5</property> <property name="position">6</property>
</packing> </packing>
</child> </child>
<child> <child>
...@@ -7746,7 +7790,7 @@ Please read the description of the Server Mode (linked below) to understand the ...@@ -7746,7 +7790,7 @@ Please read the description of the Server Mode (linked below) to understand the
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">False</property> <property name="fill">False</property>
<property name="position">6</property> <property name="position">7</property>
</packing> </packing>
</child> </child>
<child> <child>
...@@ -7756,7 +7800,7 @@ Please read the description of the Server Mode (linked below) to understand the ...@@ -7756,7 +7800,7 @@ Please read the description of the Server Mode (linked below) to understand the
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">False</property> <property name="fill">False</property>
<property name="position">7</property> <property name="position">8</property>
</packing> </packing>
</child> </child>
<child> <child>
...@@ -7769,7 +7813,7 @@ Please read the description of the Server Mode (linked below) to understand the ...@@ -7769,7 +7813,7 @@ Please read the description of the Server Mode (linked below) to understand the
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">False</property> <property name="fill">False</property>
<property name="position">8</property> <property name="position">9</property>
</packing> </packing>
</child> </child>
<child> <child>
...@@ -7786,7 +7830,7 @@ Please read the description of the Server Mode (linked below) to understand the ...@@ -7786,7 +7830,7 @@ Please read the description of the Server Mode (linked below) to understand the
</child> </child>
</object> </object>
<packing> <packing>
<property name="position">9</property> <property name="position">10</property>
</packing> </packing>
</child> </child>
<child internal-child="action_area"> <child internal-child="action_area">
...@@ -7838,7 +7882,7 @@ Please read the description of the Server Mode (linked below) to understand the ...@@ -7838,7 +7882,7 @@ Please read the description of the Server Mode (linked below) to understand the
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="pack_type">end</property> <property name="pack_type">end</property>
<property name="position">10</property> <property name="position">11</property>
</packing> </packing>
</child> </child>
</object> </object>
...@@ -8081,6 +8125,6 @@ upon interesting bugs and weird results.</property> ...@@ -8081,6 +8125,6 @@ upon interesting bugs and weird results.</property>
</object> </object>
<object class="GtkAdjustment" id="GCodeMinimumStepValue"> <object class="GtkAdjustment" id="GCodeMinimumStepValue">
<property name="upper">100</property> <property name="upper">100</property>
<property name="step_increment">5.0000000000000004e-05</property> <property name="step_increment">5.0000000000000002e-05</property>
</object> </object>
</interface> </interface>
...@@ -1854,24 +1854,36 @@ class ProjectGui: ...@@ -1854,24 +1854,36 @@ class ProjectGui:
0, 0, width, height) 0, 0, width, height)
# carefully check if there are lines in the rendered text # carefully check if there are lines in the rendered text
if text_model and (not text_model.maxx is None): if text_model and (not text_model.maxx is None):
x_fac = (width - 1) / (text_model.maxx - text_model.minx) # leave a small border around the preview
y_fac = (height - 1) / (text_model.maxy - text_model.miny) 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) 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() gc = drawing_area.new_gc()
if text_model.minx == 0: if text_model.minx == 0:
# left align # left align
get_virtual_x = lambda x: int(x * factor) get_virtual_x = lambda x: int(x * factor) + border
elif text_model.maxx == 0: elif text_model.maxx == 0:
# right align # right align
get_virtual_x = lambda x: width + int(x * factor) - 1 get_virtual_x = lambda x: width + int(x * factor) - 1 - border
else: else:
# center align # center align
get_virtual_x = lambda x: int(width / 2.0 + x * factor) - 1 get_virtual_x = lambda x: \
get_virtual_y = lambda y: \ int(width / 2.0 + x * factor) - 1 - border
height - int((y - text_model.miny) * factor) - 1 get_virtual_y = lambda y: -y_offset + \
height - int((y - text_model.miny) * factor) - 1 - border
for polygon in text_model.get_polygons(): for polygon in text_model.get_polygons():
draw_points = [] 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) x = get_virtual_x(point.x)
y = get_virtual_y(point.y) y = get_virtual_y(point.y)
draw_points.append((x, 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