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::{ffi, Point3D, Sphere, Vec3};
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 size of the box on all three axes, and stores
222    /// it into the given `size` vector.
223    ///
224    /// # Returns
225    ///
226    ///
227    /// ## `size`
228    /// return location for the size
229    #[doc(alias = "graphene_box_get_size")]
230    #[doc(alias = "get_size")]
231    pub fn size(&self) -> Vec3 {
232        unsafe {
233            let mut size = Vec3::uninitialized();
234            ffi::graphene_box_get_size(self.to_glib_none().0, size.to_glib_none_mut().0);
235            size
236        }
237    }
238
239    /// Retrieves the size of the `self` on the X axis.
240    ///
241    /// # Returns
242    ///
243    /// the width of the box
244    #[doc(alias = "graphene_box_get_width")]
245    #[doc(alias = "get_width")]
246    pub fn width(&self) -> f32 {
247        unsafe { ffi::graphene_box_get_width(self.to_glib_none().0) }
248    }
249
250    /// Intersects the two given [`Box`][crate::Box].
251    ///
252    /// If the two boxes do not intersect, `res` will contain a degenerate box
253    /// initialized with [`empty()`][Self::empty()].
254    /// ## `b`
255    /// a [`Box`][crate::Box]
256    ///
257    /// # Returns
258    ///
259    /// true if the two boxes intersect
260    ///
261    /// ## `res`
262    /// return location for the result
263    #[doc(alias = "graphene_box_intersection")]
264    pub fn intersection(&self, b: &Box) -> Option<Box> {
265        unsafe {
266            let mut res = Box::uninitialized();
267            let ret = ffi::graphene_box_intersection(
268                self.to_glib_none().0,
269                b.to_glib_none().0,
270                res.to_glib_none_mut().0,
271            );
272            if ret {
273                Some(res)
274            } else {
275                None
276            }
277        }
278    }
279
280    /// Unions the two given [`Box`][crate::Box].
281    /// ## `b`
282    /// the box to union to `self`
283    ///
284    /// # Returns
285    ///
286    ///
287    /// ## `res`
288    /// return location for the result
289    #[doc(alias = "graphene_box_union")]
290    #[must_use]
291    pub fn union(&self, b: &Box) -> Box {
292        unsafe {
293            let mut res = Box::uninitialized();
294            ffi::graphene_box_union(
295                self.to_glib_none().0,
296                b.to_glib_none().0,
297                res.to_glib_none_mut().0,
298            );
299            res
300        }
301    }
302
303    /// A degenerate [`Box`][crate::Box] that can only be expanded.
304    ///
305    /// The returned value is owned by Graphene and should not be modified or freed.
306    ///
307    /// # Returns
308    ///
309    /// a [`Box`][crate::Box]
310    #[doc(alias = "graphene_box_empty")]
311    pub fn empty() -> Box {
312        assert_initialized_main_thread!();
313        unsafe { from_glib_none(ffi::graphene_box_empty()) }
314    }
315
316    /// A degenerate [`Box`][crate::Box] that cannot be expanded.
317    ///
318    /// The returned value is owned by Graphene and should not be modified or freed.
319    ///
320    /// # Returns
321    ///
322    /// a [`Box`][crate::Box]
323    #[doc(alias = "graphene_box_infinite")]
324    pub fn infinite() -> Box {
325        assert_initialized_main_thread!();
326        unsafe { from_glib_none(ffi::graphene_box_infinite()) }
327    }
328
329    /// A [`Box`][crate::Box] with the minimum vertex set at (-1, -1, -1) and the
330    /// maximum vertex set at (0, 0, 0).
331    ///
332    /// The returned value is owned by Graphene and should not be modified or freed.
333    ///
334    /// # Returns
335    ///
336    /// a [`Box`][crate::Box]
337    #[doc(alias = "graphene_box_minus_one")]
338    pub fn minus_one() -> Box {
339        assert_initialized_main_thread!();
340        unsafe { from_glib_none(ffi::graphene_box_minus_one()) }
341    }
342
343    /// A [`Box`][crate::Box] with the minimum vertex set at (0, 0, 0) and the
344    /// maximum vertex set at (1, 1, 1).
345    ///
346    /// The returned value is owned by Graphene and should not be modified or freed.
347    ///
348    /// # Returns
349    ///
350    /// a [`Box`][crate::Box]
351    #[doc(alias = "graphene_box_one")]
352    pub fn one() -> Box {
353        assert_initialized_main_thread!();
354        unsafe { from_glib_none(ffi::graphene_box_one()) }
355    }
356
357    /// A [`Box`][crate::Box] with the minimum vertex set at (-1, -1, -1) and the
358    /// maximum vertex set at (1, 1, 1).
359    ///
360    /// The returned value is owned by Graphene and should not be modified or freed.
361    ///
362    /// # Returns
363    ///
364    /// a [`Box`][crate::Box]
365    #[doc(alias = "graphene_box_one_minus_one")]
366    pub fn one_minus_one() -> Box {
367        assert_initialized_main_thread!();
368        unsafe { from_glib_none(ffi::graphene_box_one_minus_one()) }
369    }
370
371    /// A [`Box`][crate::Box] with both the minimum and maximum vertices set at (0, 0, 0).
372    ///
373    /// The returned value is owned by Graphene and should not be modified or freed.
374    ///
375    /// # Returns
376    ///
377    /// a [`Box`][crate::Box]
378    #[doc(alias = "graphene_box_zero")]
379    pub fn zero() -> Box {
380        assert_initialized_main_thread!();
381        unsafe { from_glib_none(ffi::graphene_box_zero()) }
382    }
383}
384
385impl PartialEq for Box {
386    #[inline]
387    fn eq(&self, other: &Self) -> bool {
388        self.equal(other)
389    }
390}
391
392impl Eq for Box {}