Line data Source code
1 : /* File: pencil_layouter.inl; Copyright and License: see below */ 2 : 3 : #include "u8/u8_log.h" 4 : #include <assert.h> 5 : 6 0 : static inline void pencil_layouter_prepare ( pencil_layouter_t *this_ ) 7 : { 8 0 : pencil_layout_data_resync( &((*this_).layout_data) ); 9 0 : pencil_feature_layouter_reset( &((*this_).feature_layouter) ); 10 0 : } 11 : 12 : static inline pencil_layout_data_t *pencil_layouter_get_layout_data_ptr ( pencil_layouter_t *this_ ) 13 : { 14 : return &((*this_).layout_data); 15 : } 16 : 17 0 : static inline const pencil_layout_data_t *pencil_layouter_get_layout_data_const ( const pencil_layouter_t *this_ ) 18 : { 19 0 : return &((*this_).layout_data); 20 : } 21 : 22 0 : static inline const pencil_size_t *pencil_layouter_get_pencil_size_const ( pencil_layouter_t *this_ ) 23 : { 24 0 : return &((*this_).pencil_size); 25 : } 26 : 27 0 : static inline void pencil_layouter_is_pos_on_grid ( const pencil_layouter_t *this_, 28 : double x, 29 : double y, 30 : double snap_distance, 31 : bool *out_x_on_grid, 32 : bool *out_y_on_grid ) 33 : { 34 0 : assert ( NULL != out_x_on_grid ); 35 0 : assert ( NULL != out_y_on_grid ); 36 : 37 0 : double x_dist = geometry_non_linear_scale_get_closest_fix_location( &((*this_).x_scale), x ) - x; 38 0 : double y_dist = geometry_non_linear_scale_get_closest_fix_location( &((*this_).y_scale), y ) - y; 39 : 40 0 : *out_x_on_grid = ((-snap_distance < x_dist)&&( x_dist < snap_distance)); 41 0 : *out_y_on_grid = ((-snap_distance < y_dist)&&( y_dist < snap_distance)); 42 0 : } 43 : 44 0 : static inline void pencil_layouter_get_grid_lines ( const pencil_layouter_t *this_, 45 : double *out_x0, 46 : double *out_y0, 47 : double *out_dx, 48 : double *out_dy, 49 : uint32_t *out_x_count, 50 : uint32_t *out_y_count ) 51 : { 52 0 : assert( out_x0 != NULL ); 53 0 : assert( out_y0 != NULL ); 54 0 : assert( out_dx != NULL ); 55 0 : assert( out_dy != NULL ); 56 0 : assert( out_x_count != NULL ); 57 0 : assert( out_y_count != NULL ); 58 : 59 0 : *out_x0 = geometry_non_linear_scale_get_location ( &((*this_).x_scale), /*order=*/ INT32_MIN ); 60 0 : *out_dx = geometry_non_linear_scale_get_grid_distances ( &((*this_).x_scale) ); 61 0 : *out_x_count = geometry_non_linear_scale_get_grid_intervals ( &((*this_).x_scale) ) + 1; 62 : 63 0 : *out_y0 = geometry_non_linear_scale_get_location ( &((*this_).y_scale), /*order=*/ INT32_MIN ); 64 0 : *out_dy = geometry_non_linear_scale_get_grid_distances ( &((*this_).y_scale) ); 65 0 : *out_y_count = geometry_non_linear_scale_get_grid_intervals ( &((*this_).y_scale) ) + 1; 66 0 : } 67 : 68 : 69 : /* 70 : Copyright 2017-2024 Andreas Warnke 71 : 72 : Licensed under the Apache License, Version 2.0 (the "License"); 73 : you may not use this file except in compliance with the License. 74 : You may obtain a copy of the License at 75 : 76 : http://www.apache.org/licenses/LICENSE-2.0 77 : 78 : Unless required by applicable law or agreed to in writing, software 79 : distributed under the License is distributed on an "AS IS" BASIS, 80 : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 81 : See the License for the specific language governing permissions and 82 : limitations under the License. 83 : */