Skip to main content

graphene/auto/
box_.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::{Point3D, Sphere, Vec3, ffi};
6use glib::translate::*;
7
8glib::wrapper! {
9    /// A 3D box, described as the volume between a minimum and
10    /// a maximum vertices.
11    pub struct Box(BoxedInline<ffi::graphene_box_t>);
12
13    match fn {
14        copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::graphene_box_get_type(), ptr as *mut _) as *mut ffi::graphene_box_t,
15        free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::graphene_box_get_type(), ptr as *mut _),
16        type_ => || ffi::graphene_box_get_type(),
17    }
18}
19
20impl Box {
21    /// Checks whether the [`Box`][crate::Box] `self` contains the given
22    /// [`Box`][crate::Box] `b`.
23    /// ## `b`
24    /// a [`Box`][crate::Box]
25    ///
26    /// # Returns
27    ///
28    /// `true` if the box is contained in the given box
29    #[doc(alias = "graphene_box_contains_box")]
30    pub fn contains_box(&self, b: &Box) -> bool {
31        unsafe { ffi::graphene_box_contains_box(self.to_glib_none().0, b.to_glib_none().0) }
32    }
33
34    /// Checks whether `self` contains the given `point`.
35    /// ## `point`
36    /// the coordinates to check
37    ///
38    /// # Returns
39    ///
40    /// `true` if the point is contained in the given box
41    #[doc(alias = "graphene_box_contains_point")]
42    pub fn contains_point(&self, point: &Point3D) -> bool {
43        unsafe { ffi::graphene_box_contains_point(self.to_glib_none().0, point.to_glib_none().0) }
44    }
45
46    #[doc(alias = "graphene_box_equal")]
47    fn equal(&self, b: &Box) -> bool {
48        unsafe { ffi::graphene_box_equal(self.to_glib_none().0, b.to_glib_none().0) }
49    }
50
51    /// Expands the dimensions of `self` to include the coordinates at `point`.
52    /// ## `point`
53    /// the coordinates of the point to include
54    ///
55    /// # Returns
56    ///
57    ///
58    /// ## `res`
59    /// return location for the expanded box
60    #[doc(alias = "graphene_box_expand")]
61    #[must_use]
62    pub fn expand(&self, point: &Point3D) -> Box {
63        unsafe {
64            let mut res = Box::uninitialized();
65            ffi::graphene_box_expand(
66                self.to_glib_none().0,
67                point.to_glib_none().0,
68                res.to_glib_none_mut().0,
69            );
70            res
71        }
72    }
73
74    /// Expands the dimensions of `self` by the given `scalar` value.
75    ///
76    /// If `scalar` is positive, the [`Box`][crate::Box] will grow; if `scalar` is
77    /// negative, the [`Box`][crate::Box] will shrink.
78    /// ## `scalar`
79    /// a scalar value
80    ///
81    /// # Returns
82    ///
83    ///
84    /// ## `res`
85    /// return location for the expanded box
86    #[doc(alias = "graphene_box_expand_scalar")]
87    #[must_use]
88    pub fn expand_scalar(&self, scalar: f32) -> Box {
89        unsafe {
90            let mut res = Box::uninitialized();
91            ffi::graphene_box_expand_scalar(
92                self.to_glib_none().0,
93                scalar,
94                res.to_glib_none_mut().0,
95            );
96            res
97        }
98    }
99
100    /// Expands the dimensions of `self` to include the coordinates of the
101    /// given vector.
102    /// ## `vec`
103    /// the coordinates of the point to include, as a [`Vec3`][crate::Vec3]
104    ///
105    /// # Returns
106    ///
107    ///
108    /// ## `res`
109    /// return location for the expanded box
110    #[doc(alias = "graphene_box_expand_vec3")]
111    #[must_use]
112    pub fn expand_vec3(&self, vec: &Vec3) -> Box {
113        unsafe {
114            let mut res = Box::uninitialized();
115            ffi::graphene_box_expand_vec3(
116                self.to_glib_none().0,
117                vec.to_glib_none().0,
118                res.to_glib_none_mut().0,
119            );
120            res
121        }
122    }
123
124    /// Computes the bounding [`Sphere`][crate::Sphere] capable of containing the given
125    /// [`Box`][crate::Box].
126    ///
127    /// # Returns
128    ///
129    ///
130    /// ## `sphere`
131    /// return location for the bounding sphere
132    #[doc(alias = "graphene_box_get_bounding_sphere")]
133    #[doc(alias = "get_bounding_sphere")]
134    pub fn bounding_sphere(&self) -> Sphere {
135        unsafe {
136            let mut sphere = Sphere::uninitialized();
137            ffi::graphene_box_get_bounding_sphere(
138                self.to_glib_none().0,
139                sphere.to_glib_none_mut().0,
140            );
141            sphere
142        }
143    }
144
145    /// Retrieves the coordinates of the center of a [`Box`][crate::Box].
146    ///
147    /// # Returns
148    ///
149    ///
150    /// ## `center`
151    /// return location for the coordinates of
152    ///  the center
153    #[doc(alias = "graphene_box_get_center")]
154    #[doc(alias = "get_center")]
155    pub fn center(&self) -> Point3D {
156        unsafe {
157            let mut center = Point3D::uninitialized();
158            ffi::graphene_box_get_center(self.to_glib_none().0, center.to_glib_none_mut().0);
159            center
160        }
161    }
162
163    /// Retrieves the size of the `self` on the Z axis.
164    ///
165    /// # Returns
166    ///
167    /// the depth of the box
168    #[doc(alias = "graphene_box_get_depth")]
169    #[doc(alias = "get_depth")]
170    pub fn depth(&self) -> f32 {
171        unsafe { ffi::graphene_box_get_depth(self.to_glib_none().0) }
172    }
173
174    /// Retrieves the size of the `self` on the Y axis.
175    ///
176    /// # Returns
177    ///
178    /// the height of the box
179    #[doc(alias = "graphene_box_get_height")]
180    #[doc(alias = "get_height")]
181    pub fn height(&self) -> f32 {
182        unsafe { ffi::graphene_box_get_height(self.to_glib_none().0) }
183    }
184
185    /// Retrieves the coordinates of the maximum point of the given
186    /// [`Box`][crate::Box].
187    ///
188    /// # Returns
189    ///
190    ///
191    /// ## `max`
192    /// return location for the maximum point
193    #[doc(alias = "graphene_box_get_max")]
194    #[doc(alias = "get_max")]
195    pub fn max(&self) -> Point3D {
196        unsafe {
197            let mut max = Point3D::uninitialized();
198            ffi::graphene_box_get_max(self.to_glib_none().0, max.to_glib_none_mut().0);
199            max
200        }
201    }
202
203    /// Retrieves the coordinates of the minimum point of the given
204    /// [`Box`][crate::Box].
205    ///
206    /// # Returns
207    ///
208    ///
209    /// ## `min`
210    /// return location for the minimum point
211    #[doc(alias = "graphene_box_get_min")]
212    #[doc(alias = "get_min")]
213    pub fn min(&self) -> Point3D {
214        unsafe {
215            let mut min = Point3D::uninitialized();
216            ffi::graphene_box_get_min(self.to_glib_none().0, min.to_glib_none_mut().0);
217            min
218        }
219    }
220
221    /// Retrieves the coordinates of the minimum and maximum points of the
222    /// given [`Box`][crate::Box]
223    ///
224    /// # Returns
225    ///
226    ///
227    /// ## `min`
228    /// return location for the minimum point
229    ///
230    /// ## `max`
231    /// return location for the maximum point
232    #[cfg(feature = "v1_12")]
233    #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
234    #[doc(alias = "graphene_box_get_minmax")]
235    #[doc(alias = "get_minmax")]
236    pub fn minmax(&self) -> (Point3D, Point3D) {
237        unsafe {
238            let mut min = Point3D::uninitialized();
239            let mut max = Point3D::uninitialized();
240            ffi::graphene_box_get_minmax(
241                self.to_glib_none().0,
242                min.to_glib_none_mut().0,
243                max.to_glib_none_mut().0,
244            );
245            (min, max)
246        }
247    }
248
249    /// Retrieves the size of the box on all three axes, and stores
250    /// it into the given `size` vector.
251    ///
252    /// # Returns
253    ///
254    ///
255    /// ## `size`
256    /// return location for the size
257    #[doc(alias = "graphene_box_get_size")]
258    #[doc(alias = "get_size")]
259    pub fn size(&self) -> Vec3 {
260        unsafe {
261            let mut size = Vec3::uninitialized();
262            ffi::graphene_box_get_size(self.to_glib_none().0, size.to_glib_none_mut().0);
263            size
264        }
265    }
266
267    /// Retrieves the size of the `self` on the X axis.
268    ///
269    /// # Returns
270    ///
271    /// the width of the box
272    #[doc(alias = "graphene_box_get_width")]
273    #[doc(alias = "get_width")]
274    pub fn width(&self) -> f32 {
275        unsafe { ffi::graphene_box_get_width(self.to_glib_none().0) }
276    }
277
278    /// Intersects the two given [`Box`][crate::Box].
279    ///
280    /// If the two boxes do not intersect, `res` will contain a degenerate box
281    /// initialized with [`empty()`][Self::empty()].
282    /// ## `b`
283    /// a [`Box`][crate::Box]
284    ///
285    /// # Returns
286    ///
287    /// true if the two boxes intersect
288    ///
289    /// ## `res`
290    /// return location for the result
291    #[doc(alias = "graphene_box_intersection")]
292    pub fn intersection(&self, b: &Box) -> Option<Box> {
293        unsafe {
294            let mut res = Box::uninitialized();
295            let ret = ffi::graphene_box_intersection(
296                self.to_glib_none().0,
297                b.to_glib_none().0,
298                res.to_glib_none_mut().0,
299            );
300            if ret { Some(res) } else { None }
301        }
302    }
303
304    /// Unions the two given [`Box`][crate::Box].
305    /// ## `b`
306    /// the box to union to `self`
307    ///
308    /// # Returns
309    ///
310    ///
311    /// ## `res`
312    /// return location for the result
313    #[doc(alias = "graphene_box_union")]
314    #[must_use]
315    pub fn union(&self, b: &Box) -> Box {
316        unsafe {
317            let mut res = Box::uninitialized();
318            ffi::graphene_box_union(
319                self.to_glib_none().0,
320                b.to_glib_none().0,
321                res.to_glib_none_mut().0,
322            );
323            res
324        }
325    }
326
327    /// A degenerate [`Box`][crate::Box] that can only be expanded.
328    ///
329    /// The returned value is owned by Graphene and should not be modified or freed.
330    ///
331    /// # Returns
332    ///
333    /// a [`Box`][crate::Box]
334    #[doc(alias = "graphene_box_empty")]
335    pub fn empty() -> Box {
336        assert_initialized_main_thread!();
337        unsafe { from_glib_none(ffi::graphene_box_empty()) }
338    }
339
340    /// A degenerate [`Box`][crate::Box] that cannot be expanded.
341    ///
342    /// The returned value is owned by Graphene and should not be modified or freed.
343    ///
344    /// # Returns
345    ///
346    /// a [`Box`][crate::Box]
347    #[doc(alias = "graphene_box_infinite")]
348    pub fn infinite() -> Box {
349        assert_initialized_main_thread!();
350        unsafe { from_glib_none(ffi::graphene_box_infinite()) }
351    }
352
353    /// A [`Box`][crate::Box] with the minimum vertex set at (-1, -1, -1) and the
354    /// maximum vertex set at (0, 0, 0).
355    ///
356    /// The returned value is owned by Graphene and should not be modified or freed.
357    ///
358    /// # Returns
359    ///
360    /// a [`Box`][crate::Box]
361    #[doc(alias = "graphene_box_minus_one")]
362    pub fn minus_one() -> Box {
363        assert_initialized_main_thread!();
364        unsafe { from_glib_none(ffi::graphene_box_minus_one()) }
365    }
366
367    /// A [`Box`][crate::Box] with the minimum vertex set at (0, 0, 0) and the
368    /// maximum vertex set at (1, 1, 1).
369    ///
370    /// The returned value is owned by Graphene and should not be modified or freed.
371    ///
372    /// # Returns
373    ///
374    /// a [`Box`][crate::Box]
375    #[doc(alias = "graphene_box_one")]
376    pub fn one() -> Box {
377        assert_initialized_main_thread!();
378        unsafe { from_glib_none(ffi::graphene_box_one()) }
379    }
380
381    /// A [`Box`][crate::Box] with the minimum vertex set at (-1, -1, -1) and the
382    /// maximum vertex set at (1, 1, 1).
383    ///
384    /// The returned value is owned by Graphene and should not be modified or freed.
385    ///
386    /// # Returns
387    ///
388    /// a [`Box`][crate::Box]
389    #[doc(alias = "graphene_box_one_minus_one")]
390    pub fn one_minus_one() -> Box {
391        assert_initialized_main_thread!();
392        unsafe { from_glib_none(ffi::graphene_box_one_minus_one()) }
393    }
394
395    /// A [`Box`][crate::Box] with both the minimum and maximum vertices set at (0, 0, 0).
396    ///
397    /// The returned value is owned by Graphene and should not be modified or freed.
398    ///
399    /// # Returns
400    ///
401    /// a [`Box`][crate::Box]
402    #[doc(alias = "graphene_box_zero")]
403    pub fn zero() -> Box {
404        assert_initialized_main_thread!();
405        unsafe { from_glib_none(ffi::graphene_box_zero()) }
406    }
407}
408
409impl PartialEq for Box {
410    #[inline]
411    fn eq(&self, other: &Self) -> bool {
412        self.equal(other)
413    }
414}
415
416impl Eq for Box {}