1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
use std::cell::Cell;
use std::rc::Rc;
#[allow(unused_imports)]
use std::marker::PhantomData;
#[allow(unused_imports)]
use std::os::raw::c_void;
#[allow(unused_imports)]
use std::mem::transmute;
#[allow(unused_imports)]
use std::ffi::{CStr, CString};
use rute_ffi_base::*;
#[allow(unused_imports)]
use auto::*;
#[derive(Clone)]
pub struct PolygonF<'a> {
#[doc(hidden)]
pub data: Rc<Cell<Option<*const RUBase>>>,
#[doc(hidden)]
pub all_funcs: *const RUPolygonFAllFuncs,
#[doc(hidden)]
pub owned: bool,
#[doc(hidden)]
pub _marker: PhantomData<::std::cell::Cell<&'a ()>>,
}
impl<'a> PolygonF<'a> {
pub fn new() -> PolygonF<'a> {
let data = Rc::new(Cell::new(None));
let ffi_data = unsafe {
((*rute_ffi_get()).create_polygon_f)(
::std::ptr::null(),
transmute(rute_object_delete_callback as usize),
Rc::into_raw(data.clone()) as *const c_void,
)
};
data.set(Some(ffi_data.qt_data));
PolygonF {
data,
all_funcs: ffi_data.all_funcs,
owned: true,
_marker: PhantomData,
}
}
#[allow(dead_code)]
pub(crate) fn new_from_rc(ffi_data: RUPolygonF) -> PolygonF<'a> {
PolygonF {
data: unsafe { Rc::from_raw(ffi_data.host_data as *const Cell<Option<*const RUBase>>) },
all_funcs: ffi_data.all_funcs,
owned: false,
_marker: PhantomData,
}
}
#[allow(dead_code)]
pub(crate) fn new_from_owned(ffi_data: RUPolygonF) -> PolygonF<'a> {
PolygonF {
data: Rc::new(Cell::new(Some(ffi_data.qt_data as *const RUBase))),
all_funcs: ffi_data.all_funcs,
owned: true,
_marker: PhantomData,
}
}
#[allow(dead_code)]
pub(crate) fn new_from_temporary(ffi_data: RUPolygonF) -> PolygonF<'a> {
PolygonF {
data: Rc::new(Cell::new(Some(ffi_data.qt_data as *const RUBase))),
all_funcs: ffi_data.all_funcs,
owned: false,
_marker: PhantomData,
}
}
pub fn swap<P: PolygonFTrait<'a>>(&self, other: &P) -> &Self {
let (obj_other_1, _funcs) = other.get_polygon_f_obj_funcs();
let (obj_data, funcs) = self.get_polygon_f_obj_funcs();
unsafe {
((*funcs).swap)(obj_data, obj_other_1);
}
self
}
pub fn to_polygon(&self) -> Polygon {
let (obj_data, funcs) = self.get_polygon_f_obj_funcs();
unsafe {
let ret_val = ((*funcs).to_polygon)(obj_data);
let t = ret_val;
let ret_val;
if t.host_data != ::std::ptr::null() {
ret_val = Polygon::new_from_rc(t);
} else {
ret_val = Polygon::new_from_owned(t);
}
ret_val
}
}
pub fn is_closed(&self) -> bool {
let (obj_data, funcs) = self.get_polygon_f_obj_funcs();
unsafe {
let ret_val = ((*funcs).is_closed)(obj_data);
ret_val
}
}
pub fn bounding_rect(&self) -> RectF {
let (obj_data, funcs) = self.get_polygon_f_obj_funcs();
unsafe {
let ret_val = ((*funcs).bounding_rect)(obj_data);
let t = ret_val;
let ret_val;
if t.host_data != ::std::ptr::null() {
ret_val = RectF::new_from_rc(t);
} else {
ret_val = RectF::new_from_owned(t);
}
ret_val
}
}
pub fn contains_point<P: PointFTrait<'a>>(&self, pt: &P, fill_rule: FillRule) -> bool {
let (obj_pt_1, _funcs) = pt.get_point_f_obj_funcs();
let enum_fill_rule_2 = fill_rule as u32;
let (obj_data, funcs) = self.get_polygon_f_obj_funcs();
unsafe {
let ret_val = ((*funcs).contains_point)(obj_data, obj_pt_1, enum_fill_rule_2);
ret_val
}
}
pub fn united<P: PolygonFTrait<'a>>(&self, r: &P) -> PolygonF {
let (obj_r_1, _funcs) = r.get_polygon_f_obj_funcs();
let (obj_data, funcs) = self.get_polygon_f_obj_funcs();
unsafe {
let ret_val = ((*funcs).united)(obj_data, obj_r_1);
let t = ret_val;
let ret_val;
if t.host_data != ::std::ptr::null() {
ret_val = PolygonF::new_from_rc(t);
} else {
ret_val = PolygonF::new_from_owned(t);
}
ret_val
}
}
pub fn intersected<P: PolygonFTrait<'a>>(&self, r: &P) -> PolygonF {
let (obj_r_1, _funcs) = r.get_polygon_f_obj_funcs();
let (obj_data, funcs) = self.get_polygon_f_obj_funcs();
unsafe {
let ret_val = ((*funcs).intersected)(obj_data, obj_r_1);
let t = ret_val;
let ret_val;
if t.host_data != ::std::ptr::null() {
ret_val = PolygonF::new_from_rc(t);
} else {
ret_val = PolygonF::new_from_owned(t);
}
ret_val
}
}
pub fn intersects<P: PolygonFTrait<'a>>(&self, r: &P) -> bool {
let (obj_r_1, _funcs) = r.get_polygon_f_obj_funcs();
let (obj_data, funcs) = self.get_polygon_f_obj_funcs();
unsafe {
let ret_val = ((*funcs).intersects)(obj_data, obj_r_1);
ret_val
}
}
pub fn build(&self) -> Self {
self.clone()
}
}
pub trait PolygonFTrait<'a> {
#[inline]
#[doc(hidden)]
fn get_polygon_f_obj_funcs(&self) -> (*const RUBase, *const RUPolygonFFuncs);
}
impl<'a> PolygonFTrait<'a> for PolygonF<'a> {
#[doc(hidden)]
fn get_polygon_f_obj_funcs(&self) -> (*const RUBase, *const RUPolygonFFuncs) {
let obj = self.data.get().unwrap();
unsafe { (obj, (*self.all_funcs).polygon_f_funcs) }
}
}