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_painter_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 : U8_TRACE_END();
25 0 : }
26 :
27 : static inline void pencil_diagram_maker_reinit( pencil_diagram_maker_t *this_,
28 : const data_visible_set_t *input_data,
29 : const data_profile_part_t *profile )
30 : {
31 : U8_TRACE_BEGIN();
32 : assert( NULL != input_data );
33 : assert( NULL != profile );
34 :
35 : (*this_).input_data = input_data;
36 : (*this_).profile = profile;
37 : pencil_layouter_reinit( &((*this_).layouter), input_data, profile );
38 :
39 : U8_TRACE_END();
40 : }
41 :
42 0 : static inline void pencil_diagram_maker_destroy( pencil_diagram_maker_t *this_ )
43 : {
44 0 : U8_TRACE_BEGIN();
45 :
46 0 : pencil_diagram_painter_destroy( &((*this_).diagram_painter) );
47 0 : pencil_classifier_painter_destroy( &((*this_).classifier_painter) );
48 0 : pencil_relationship_painter_destroy( &((*this_).relationship_painter) );
49 0 : pencil_feature_painter_destroy( &((*this_).feature_painter) );
50 :
51 0 : pencil_layouter_destroy( &((*this_).layouter) );
52 0 : (*this_).input_data = NULL;
53 :
54 0 : U8_TRACE_END();
55 0 : }
56 :
57 0 : static inline void pencil_diagram_maker_define_grid( pencil_diagram_maker_t *this_,
58 : geometry_rectangle_t diagram_bounds,
59 : cairo_t *cr )
60 : {
61 0 : U8_TRACE_BEGIN();
62 :
63 : PangoLayout *font_layout;
64 0 : font_layout = pango_cairo_create_layout (cr);
65 :
66 0 : pencil_layouter_prepare ( &((*this_).layouter) );
67 0 : pencil_layouter_define_grid ( &((*this_).layouter), diagram_bounds, font_layout );
68 :
69 0 : g_object_unref (font_layout);
70 :
71 0 : U8_TRACE_END();
72 0 : }
73 :
74 0 : static inline const geometry_grid_t *pencil_diagram_maker_get_grid_const ( const pencil_diagram_maker_t *this_ )
75 : {
76 0 : return pencil_layouter_get_grid_const( &((*this_).layouter) );
77 : }
78 :
79 0 : static inline void pencil_diagram_maker_layout_elements( pencil_diagram_maker_t *this_,
80 : data_stat_t *io_layout_stat,
81 : cairo_t *cr )
82 : {
83 0 : U8_TRACE_BEGIN();
84 0 : assert( cr != NULL );
85 :
86 : /* trace input data: */
87 0 : const data_id_t diag_id = data_diagram_get_data_id( data_visible_set_get_diagram_const( (*this_).input_data ) );
88 0 : data_id_trace( &diag_id );
89 0 : data_profile_part_trace( (*this_).profile );
90 :
91 : PangoLayout *font_layout;
92 0 : font_layout = pango_cairo_create_layout (cr);
93 :
94 0 : pencil_layouter_layout_elements ( &((*this_).layouter), font_layout );
95 0 : if ( io_layout_stat != NULL )
96 : {
97 0 : layout_visible_set_get_statistics( pencil_layouter_get_layout_data_const( &((*this_).layouter) ), io_layout_stat );
98 : }
99 :
100 0 : g_object_unref (font_layout);
101 :
102 0 : U8_TRACE_END();
103 0 : }
104 :
105 0 : static inline const layout_visible_set_t *pencil_diagram_maker_get_layout_data_const( const pencil_diagram_maker_t *this_ )
106 : {
107 0 : return pencil_layouter_get_layout_data_const( &((*this_).layouter) );
108 : }
109 :
110 :
111 : /*
112 : Copyright 2016-2025 Andreas Warnke
113 :
114 : Licensed under the Apache License, Version 2.0 (the "License");
115 : you may not use this file except in compliance with the License.
116 : You may obtain a copy of the License at
117 :
118 : http://www.apache.org/licenses/LICENSE-2.0
119 :
120 : Unless required by applicable law or agreed to in writing, software
121 : distributed under the License is distributed on an "AS IS" BASIS,
122 : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
123 : See the License for the specific language governing permissions and
124 : limitations under the License.
125 : */
|