Line data Source code
1 : /* File: pencil_diagram_maker.inl; Copyright and License: see below */
2 :
3 : #include "pencil_diagram_maker.h"
4 : #include "u8/u8_trace.h"
5 : #include <assert.h>
6 :
7 0 : static inline void pencil_diagram_maker_init( pencil_diagram_maker_t *this_,
8 : const data_visible_set_t *input_data,
9 : const data_profile_part_t *profile )
10 : {
11 0 : U8_TRACE_BEGIN();
12 0 : assert( NULL != input_data );
13 0 : assert( NULL != profile );
14 :
15 0 : pencil_diagram_painter_init( &((*this_).diagram_painter) );
16 0 : pencil_classifier_composer_init( &((*this_).classifier_painter) );
17 0 : pencil_relationship_painter_init( &((*this_).relationship_painter) );
18 0 : pencil_feature_painter_init( &((*this_).feature_painter) );
19 :
20 0 : (*this_).input_data = input_data;
21 0 : (*this_).profile = profile;
22 0 : pencil_layouter_init( &((*this_).layouter), input_data, profile );
23 :
24 0 : (*this_).snap_to_grid_distance = 5.000001;
25 :
26 0 : U8_TRACE_END();
27 0 : }
28 :
29 : static inline void pencil_diagram_maker_reinit( pencil_diagram_maker_t *this_,
30 : const data_visible_set_t *input_data,
31 : const data_profile_part_t *profile )
32 : {
33 : U8_TRACE_BEGIN();
34 : assert( NULL != input_data );
35 : assert( NULL != profile );
36 :
37 : (*this_).input_data = input_data;
38 : (*this_).profile = profile;
39 : pencil_layouter_reinit( &((*this_).layouter), input_data, profile );
40 :
41 : U8_TRACE_END();
42 : }
43 :
44 0 : static inline void pencil_diagram_maker_destroy( pencil_diagram_maker_t *this_ )
45 : {
46 0 : U8_TRACE_BEGIN();
47 :
48 0 : pencil_diagram_painter_destroy( &((*this_).diagram_painter) );
49 0 : pencil_classifier_composer_destroy( &((*this_).classifier_painter) );
50 0 : pencil_relationship_painter_destroy( &((*this_).relationship_painter) );
51 0 : pencil_feature_painter_destroy( &((*this_).feature_painter) );
52 :
53 0 : pencil_layouter_destroy( &((*this_).layouter) );
54 0 : (*this_).input_data = NULL;
55 :
56 0 : U8_TRACE_END();
57 0 : }
58 :
59 0 : static inline void pencil_diagram_maker_define_grid ( pencil_diagram_maker_t *this_,
60 : geometry_rectangle_t diagram_bounds,
61 : cairo_t *cr )
62 : {
63 0 : U8_TRACE_BEGIN();
64 :
65 0 : PangoLayout *font_layout;
66 0 : font_layout = pango_cairo_create_layout (cr);
67 :
68 0 : pencil_layouter_prepare ( &((*this_).layouter) );
69 0 : pencil_layouter_define_grid ( &((*this_).layouter), diagram_bounds, font_layout );
70 :
71 0 : g_object_unref (font_layout);
72 :
73 0 : U8_TRACE_END();
74 0 : }
75 :
76 0 : static inline void pencil_diagram_maker_layout_elements ( pencil_diagram_maker_t *this_,
77 : data_stat_t *io_layout_stat,
78 : cairo_t *cr )
79 : {
80 0 : U8_TRACE_BEGIN();
81 0 : assert( cr != NULL );
82 :
83 : /* trace input data: */
84 0 : const data_id_t diag_id = data_diagram_get_data_id( data_visible_set_get_diagram_const( (*this_).input_data ) );
85 0 : data_id_trace( &diag_id );
86 0 : data_profile_part_trace( (*this_).profile );
87 :
88 0 : PangoLayout *font_layout;
89 0 : font_layout = pango_cairo_create_layout (cr);
90 :
91 0 : pencil_layouter_layout_elements ( &((*this_).layouter), font_layout );
92 0 : if ( io_layout_stat != NULL )
93 : {
94 0 : pencil_layout_data_get_statistics( pencil_layouter_get_layout_data_const( &((*this_).layouter) ), io_layout_stat );
95 : }
96 :
97 0 : g_object_unref (font_layout);
98 :
99 0 : U8_TRACE_END();
100 0 : }
101 :
102 0 : static inline pencil_error_t pencil_diagram_maker_get_object_id_at_pos ( const pencil_diagram_maker_t *this_,
103 : double x,
104 : double y,
105 : pencil_type_filter_t filter,
106 : data_full_id_t* out_selected_id,
107 : data_full_id_t* out_surrounding_id )
108 : {
109 0 : return pencil_layouter_get_object_id_at_pos ( &((*this_).layouter),
110 : x,
111 : y,
112 : 3.0,
113 : filter,
114 : out_selected_id,
115 : out_surrounding_id
116 : );
117 : }
118 :
119 0 : static inline void pencil_diagram_maker_is_pos_on_grid ( const pencil_diagram_maker_t *this_,
120 : double x,
121 : double y,
122 : bool *out_x_on_grid,
123 : bool *out_y_on_grid )
124 : {
125 0 : pencil_layouter_is_pos_on_grid ( &((*this_).layouter),
126 : x,
127 : y,
128 0 : (*this_).snap_to_grid_distance,
129 : out_x_on_grid,
130 : out_y_on_grid
131 : );
132 : }
133 :
134 0 : static inline void pencil_diagram_maker_get_grid_lines ( const pencil_diagram_maker_t *this_,
135 : double *out_x0,
136 : double *out_y0,
137 : double *out_dx,
138 : double *out_dy,
139 : uint32_t *out_x_count,
140 : uint32_t *out_y_count
141 : )
142 : {
143 0 : pencil_layouter_get_grid_lines( &((*this_).layouter), out_x0, out_y0, out_dx, out_dy, out_x_count, out_y_count );
144 : }
145 :
146 :
147 : /*
148 : Copyright 2016-2024 Andreas Warnke
149 :
150 : Licensed under the Apache License, Version 2.0 (the "License");
151 : you may not use this file except in compliance with the License.
152 : You may obtain a copy of the License at
153 :
154 : http://www.apache.org/licenses/LICENSE-2.0
155 :
156 : Unless required by applicable law or agreed to in writing, software
157 : distributed under the License is distributed on an "AS IS" BASIS,
158 : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
159 : See the License for the specific language governing permissions and
160 : limitations under the License.
161 : */
|