Line data Source code
1 : /* File: layout_feature.inl; Copyright and License: see below */
2 :
3 : #include <assert.h>
4 :
5 356 : static inline void layout_feature_init ( layout_feature_t *this_,
6 : const data_feature_t *feature_data,
7 : layout_visible_classifier_t *classifier )
8 : {
9 356 : assert ( NULL != feature_data );
10 356 : assert ( NULL != classifier );
11 :
12 356 : geometry_rectangle_init_empty( &((*this_).symbol_box) );
13 356 : geometry_rectangle_init_empty( &((*this_).label_box) );
14 356 : (*this_).icon_direction = GEOMETRY_DIRECTION_CENTER;
15 356 : (*this_).data = feature_data;
16 356 : (*this_).classifier = classifier;
17 356 : }
18 :
19 356 : static inline void layout_feature_destroy ( layout_feature_t *this_ )
20 : {
21 356 : geometry_rectangle_destroy( &((*this_).symbol_box) );
22 356 : geometry_rectangle_destroy( &((*this_).label_box) );
23 356 : (*this_).data = NULL;
24 356 : }
25 :
26 712 : static inline bool layout_feature_is_valid ( const layout_feature_t *this_ )
27 : {
28 : bool result;
29 712 : if (( (*this_).data == NULL )||( (*this_).classifier == NULL ))
30 : {
31 0 : result = false; /* cannot happen on initialized objects */
32 : }
33 : else
34 : {
35 1424 : result = data_feature_is_valid( (*this_).data )
36 712 : && layout_visible_classifier_is_valid( (*this_).classifier )
37 1424 : && ( data_feature_get_classifier_row_id( (*this_).data ) == layout_visible_classifier_get_classifier_id( (*this_).classifier ));
38 : }
39 712 : return result;
40 : }
41 :
42 0 : static inline const geometry_rectangle_t *layout_feature_get_symbol_box_const ( const layout_feature_t *this_ )
43 : {
44 0 : return &((*this_).symbol_box);
45 : }
46 :
47 0 : static inline geometry_point_t layout_feature_get_symbol_middle ( const layout_feature_t *this_ )
48 : {
49 : geometry_point_t result;
50 0 : geometry_point_init( &result,
51 : geometry_rectangle_get_center_x( &((*this_).symbol_box) ),
52 : geometry_rectangle_get_center_y( &((*this_).symbol_box) )
53 : );
54 0 : return result;
55 : }
56 :
57 0 : static inline void layout_feature_set_symbol_box ( layout_feature_t *this_, const geometry_rectangle_t *feature_symbol_box )
58 : {
59 0 : geometry_rectangle_replace( &((*this_).symbol_box), feature_symbol_box );
60 0 : }
61 :
62 0 : static inline geometry_direction_t layout_feature_get_icon_direction ( const layout_feature_t *this_ )
63 : {
64 0 : return (*this_).icon_direction;
65 : }
66 :
67 0 : static inline void layout_feature_set_icon_direction ( layout_feature_t *this_, geometry_direction_t direction )
68 : {
69 0 : (*this_).icon_direction = direction;
70 0 : }
71 :
72 0 : static inline const geometry_rectangle_t *layout_feature_get_label_box_const ( const layout_feature_t *this_ )
73 : {
74 0 : return &((*this_).label_box);
75 : }
76 :
77 0 : static inline void layout_feature_set_label_box ( layout_feature_t *this_, const geometry_rectangle_t *label_box )
78 : {
79 0 : geometry_rectangle_replace( &((*this_).label_box), label_box );
80 0 : }
81 :
82 8 : static inline const data_feature_t *layout_feature_get_data_const ( const layout_feature_t *this_ )
83 : {
84 8 : return (*this_).data;
85 : }
86 :
87 8 : static inline layout_visible_classifier_t *layout_feature_get_classifier_ptr ( layout_feature_t *this_ )
88 : {
89 8 : return (*this_).classifier;
90 : }
91 :
92 0 : static inline const layout_visible_classifier_t *layout_feature_get_classifier_const ( const layout_feature_t *this_ )
93 : {
94 0 : return (*this_).classifier;
95 : }
96 :
97 204 : static inline data_row_t layout_feature_get_feature_id ( const layout_feature_t *this_ )
98 : {
99 204 : return data_feature_get_row_id( (*this_).data );
100 : }
101 :
102 :
103 : /*
104 : Copyright 2018-2025 Andreas Warnke
105 :
106 : Licensed under the Apache License, Version 2.0 (the "License");
107 : you may not use this file except in compliance with the License.
108 : You may obtain a copy of the License at
109 :
110 : http://www.apache.org/licenses/LICENSE-2.0
111 :
112 : Unless required by applicable law or agreed to in writing, software
113 : distributed under the License is distributed on an "AS IS" BASIS,
114 : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
115 : See the License for the specific language governing permissions and
116 : limitations under the License.
117 : */
|