| 1 |
/* File: layout_feature.inl; Copyright and License: see below */ |
| 2 |
|
| 3 |
#include <assert.h> |
| 4 |
|
| 5 |
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 |
assert ( NULL != feature_data ); |
| 10 |
assert ( NULL != classifier ); |
| 11 |
|
| 12 |
geometry_rectangle_init_empty( &((*this_).symbol_box) ); |
| 13 |
geometry_rectangle_init_empty( &((*this_).label_box) ); |
| 14 |
(*this_).icon_direction = GEOMETRY_DIRECTION_CENTER; |
| 15 |
(*this_).data = feature_data; |
| 16 |
(*this_).classifier = classifier; |
| 17 |
} |
| 18 |
|
| 19 |
static inline void layout_feature_destroy ( layout_feature_t *this_ ) |
| 20 |
{ |
| 21 |
geometry_rectangle_destroy( &((*this_).symbol_box) ); |
| 22 |
geometry_rectangle_destroy( &((*this_).label_box) ); |
| 23 |
(*this_).data = NULL; |
| 24 |
} |
| 25 |
|
| 26 |
static inline bool layout_feature_is_valid ( const layout_feature_t *this_ ) |
| 27 |
{ |
| 28 |
bool result; |
| 29 |
if (( (*this_).data == NULL )||( (*this_).classifier == NULL )) |
| 30 |
{ |
| 31 |
result = false; /* cannot happen on initialized objects */ |
| 32 |
} |
| 33 |
else |
| 34 |
{ |
| 35 |
result = data_feature_is_valid( (*this_).data ) |
| 36 |
&& layout_visible_classifier_is_valid( (*this_).classifier ) |
| 37 |
&& ( data_feature_get_classifier_row_id( (*this_).data ) == layout_visible_classifier_get_classifier_id( (*this_).classifier )); |
| 38 |
} |
| 39 |
return result; |
| 40 |
} |
| 41 |
|
| 42 |
static inline const geometry_rectangle_t *layout_feature_get_symbol_box_const ( const layout_feature_t *this_ ) |
| 43 |
{ |
| 44 |
return &((*this_).symbol_box); |
| 45 |
} |
| 46 |
|
| 47 |
static inline geometry_point_t layout_feature_get_symbol_middle ( const layout_feature_t *this_ ) |
| 48 |
{ |
| 49 |
geometry_point_t result; |
| 50 |
geometry_point_init( &result, |
| 51 |
geometry_rectangle_get_center_x( &((*this_).symbol_box) ), |
| 52 |
geometry_rectangle_get_center_y( &((*this_).symbol_box) ) |
| 53 |
); |
| 54 |
return result; |
| 55 |
} |
| 56 |
|
| 57 |
static inline void layout_feature_set_symbol_box ( layout_feature_t *this_, const geometry_rectangle_t *feature_symbol_box ) |
| 58 |
{ |
| 59 |
geometry_rectangle_replace( &((*this_).symbol_box), feature_symbol_box ); |
| 60 |
} |
| 61 |
|
| 62 |
static inline geometry_direction_t layout_feature_get_icon_direction ( const layout_feature_t *this_ ) |
| 63 |
{ |
| 64 |
return (*this_).icon_direction; |
| 65 |
} |
| 66 |
|
| 67 |
static inline void layout_feature_set_icon_direction ( layout_feature_t *this_, geometry_direction_t direction ) |
| 68 |
{ |
| 69 |
(*this_).icon_direction = direction; |
| 70 |
} |
| 71 |
|
| 72 |
static inline const geometry_rectangle_t *layout_feature_get_label_box_const ( const layout_feature_t *this_ ) |
| 73 |
{ |
| 74 |
return &((*this_).label_box); |
| 75 |
} |
| 76 |
|
| 77 |
static inline void layout_feature_set_label_box ( layout_feature_t *this_, const geometry_rectangle_t *label_box ) |
| 78 |
{ |
| 79 |
geometry_rectangle_replace( &((*this_).label_box), label_box ); |
| 80 |
} |
| 81 |
|
| 82 |
static inline const data_feature_t *layout_feature_get_data_const ( const layout_feature_t *this_ ) |
| 83 |
{ |
| 84 |
return (*this_).data; |
| 85 |
} |
| 86 |
|
| 87 |
static inline layout_visible_classifier_t *layout_feature_get_classifier_ptr ( layout_feature_t *this_ ) |
| 88 |
{ |
| 89 |
return (*this_).classifier; |
| 90 |
} |
| 91 |
|
| 92 |
static inline const layout_visible_classifier_t *layout_feature_get_classifier_const ( const layout_feature_t *this_ ) |
| 93 |
{ |
| 94 |
return (*this_).classifier; |
| 95 |
} |
| 96 |
|
| 97 |
static inline data_row_t layout_feature_get_feature_id ( const layout_feature_t *this_ ) |
| 98 |
{ |
| 99 |
return data_feature_get_row_id( (*this_).data ); |
| 100 |
} |
| 101 |
|
| 102 |
|
| 103 |
/* |
| 104 |
Copyright 2018-2026 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 |
*/ |