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