1 # Copyright (C) 2013-2020 Roland Lutz
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software Foundation,
15 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 def get_line(rev
, ob
):
20 line
= rev
.get_object_data(ob
).line
21 return line
.width
, line
.cap_style
, line
.dash_style
, \
22 line
.dash_length
, line
.dash_space
24 def get_fill(rev
, ob
):
25 fill
= rev
.get_object_data(ob
).fill
26 return fill
.type, fill
.width
, fill
.angle0
, fill
.pitch0
, \
27 fill
.angle1
, fill
.pitch1
29 def check_line_attr(obtype
):
30 rev
= xorn
.storage
.Revision()
32 ob
= rev
.add_object(data
)
35 data
.line
.cap_style
= 1
36 data
.line
.dash_length
= 73.
37 data
.line
.dash_space
= 74.
39 data
.line
.dash_style
= 0
40 rev
.set_object_data(ob
, data
)
41 assert get_line(rev
, ob
) == (70., 1, 0, 0., 0.)
43 data
.line
.dash_style
= 1
44 rev
.set_object_data(ob
, data
)
45 assert get_line(rev
, ob
) == (70., 1, 1, 0., 74.)
47 data
.line
.dash_style
= 2
48 rev
.set_object_data(ob
, data
)
49 assert get_line(rev
, ob
) == (70., 1, 2, 73., 74.)
51 data
.line
.dash_style
= 3
52 rev
.set_object_data(ob
, data
)
53 assert get_line(rev
, ob
) == (70., 1, 3, 73., 74.)
55 data
.line
.dash_style
= 4
56 rev
.set_object_data(ob
, data
)
57 assert get_line(rev
, ob
) == (70., 1, 4, 73., 74.)
59 def check_fill_attr(obtype
):
60 rev
= xorn
.storage
.Revision()
62 ob
= rev
.add_object(data
)
66 data
.fill
.pitch0
= 83.
68 data
.fill
.pitch1
= 85.
71 rev
.set_object_data(ob
, data
)
72 assert get_fill(rev
, ob
) == (0, 0., 0, 0., 0, 0.)
75 rev
.set_object_data(ob
, data
)
76 assert get_fill(rev
, ob
) == (1, 0., 0, 0., 0, 0.)
79 rev
.set_object_data(ob
, data
)
80 assert get_fill(rev
, ob
) == (2, 81., 82, 83., 84, 85.)
83 rev
.set_object_data(ob
, data
)
84 assert get_fill(rev
, ob
) == (3, 81., 82, 83., 0, 0.)
87 rev
.set_object_data(ob
, data
)
88 assert get_fill(rev
, ob
) == (4, 0., 0, 0., 0, 0.)
91 check_line_attr(xorn
.storage
.Arc
)
94 check_line_attr(xorn
.storage
.Box
)
95 check_fill_attr(xorn
.storage
.Box
)
98 check_line_attr(xorn
.storage
.Circle
)
99 check_fill_attr(xorn
.storage
.Circle
)
105 check_line_attr(xorn
.storage
.Line
)
111 check_line_attr(xorn
.storage
.Path
)
112 check_fill_attr(xorn
.storage
.Path
)