Debian Codegraph @

pencil/include/pencil_layouter.h

raw
1 /* File: pencil_layouter.h; Copyright and License: see below */
2
3 #ifndef PENCIL_LAYOUTER_H
4 #define PENCIL_LAYOUTER_H
5
6 /* public file for the doxygen documentation: */
7 /*!
8 * \file
9 * \brief Calculates positions of classifiers, features and relationships in a diagram
10 */
11
12 #include "pencil_marker.h"
13 #include "pencil_classifier_composer.h"
14 #include "pencil_size.h"
15 #include "layout/layout_visible_set.h"
16 #include "pencil_diagram_painter.h"
17 #include "pencil_feature_painter.h"
18 #include "pencil_feature_layouter.h"
19 #include "pencil_feat_label_layouter.h"
20 #include "pencil_relationship_2d_layouter.h"
21 #include "pencil_relationship_1d_layouter.h"
22 #include "pencil_rel_label_layouter.h"
23 #include "pencil_classifier_2d_layouter.h"
24 #include "pencil_classifier_1d_layouter.h"
25 #include "pencil_error.h"
26 #include "layout/layout_order.h"
27 #include "geometry/geometry_rectangle.h"
28 #include "geometry/geometry_dimensions.h"
29 #include "geometry/geometry_grid.h"
30 #include "set/data_full_id.h"
31 #include "set/data_profile_part.h"
32 #include "set/data_small_set.h"
33 #include "set/data_stat.h"
34 #include "set/data_visible_set.h"
35 #include "entity/data_diagram.h"
36 #include "entity/data_id.h"
37 #include "data_rules.h"
38 #include "u8list/universal_array_index_sorter.h"
39 #include <cairo.h>
40 #include <stdint.h>
41
42 /*!
43 * \brief attributes of the layouter
44 */
45 struct pencil_layouter_struct {
46 layout_visible_set_t layout_data; /* own instance of layout data */
47 const data_profile_part_t *profile; /*!< pointer to an external stereotype-image cache */
48
49 pencil_size_t pencil_size; /*!< own instance of a pencil_size_t object, defining pen sizes, gap sizes, font sizes and colors */
50 geometry_grid_t grid; /*!< own instance of a pair of scale objects to calculate positions from order numbers */
51 geometry_dimensions_t default_classifier_size; /*!< own instance of a classifier default size */
52 data_rules_t rules; /*!< own instance of modelling rules */
53
54 pencil_diagram_painter_t diagram_painter; /*!< own instance of a painter object to ask for display dimensions */
55
56 pencil_classifier_2d_layouter_t pencil_classifier_2d_layouter; /*!< own instance of a helper object to layout classifiers */
57 pencil_classifier_1d_layouter_t pencil_classifier_1d_layouter; /*!< own instance of a helper object to layout classifiers */
58 pencil_feature_layouter_t feature_layouter; /*!< own instance of a helper object to layout features */
59 pencil_feat_label_layouter_t feature_label_layouter; /*!< own instance of a helper object to layout feature labels */
60 pencil_relationship_2d_layouter_t pencil_relationship_2d_layouter; /*!< own instance of a helper object to layout relationships */
61 pencil_relationship_1d_layouter_t pencil_relationship_1d_layouter; /*!< own instance of a helper object to layout relationships */
62 pencil_rel_label_layouter_t relationship_label_layouter; /*!< own instance of a helper object to layout relationship labels */
63 };
64
65 typedef struct pencil_layouter_struct pencil_layouter_t;
66
67 /*!
68 * \brief initializes the layouter
69 *
70 * \param this_ pointer to own object attributes
71 * \param input_data pointer to the (cached) data to be layouted
72 * \param profile pointer to the profile-part that provides the stereotypes of the elements to be layouted
73 */
74 void pencil_layouter_init( pencil_layouter_t *this_,
75 const data_visible_set_t *input_data,
76 const data_profile_part_t *profile
77 );
78
79 /*!
80 * \brief re-initializes the layouter to layout new/other input_data
81 *
82 * \param this_ pointer to own object attributes
83 * \param input_data pointer to the data to be layouted
84 * \param profile pointer to the profile-part that provides the stereotypes of the elements to be layouted
85 */
86 void pencil_layouter_reinit( pencil_layouter_t *this_,
87 const data_visible_set_t *input_data,
88 const data_profile_part_t *profile
89 );
90
91 /*!
92 * \brief destroys the layouter
93 *
94 * \param this_ pointer to own object attributes
95 */
96 void pencil_layouter_destroy( pencil_layouter_t *this_ );
97
98 /*!
99 * \brief resets previous layout data, synchronizes the internal layout data with the *input_data
100 *
101 * \param this_ pointer to own object attributes
102 */
103 static inline void pencil_layouter_prepare ( pencil_layouter_t *this_ );
104
105 /*!
106 * \brief defines the grid coordinates
107 *
108 * \param this_ pointer to own object attributes
109 * \param diagram_bounds the diagram_bounds rectangle where to draw the diagram
110 * \param font_layout pango layout object to determine the font metrics in the current cairo drawing context
111 */
112 void pencil_layouter_define_grid ( pencil_layouter_t *this_,
113 geometry_rectangle_t diagram_bounds,
114 PangoLayout *font_layout
115 );
116
117 /*!
118 * \brief returns the geometry_grid_t
119 *
120 * \param this_ pointer to own object attributes
121 */
122 static inline const geometry_grid_t *pencil_layouter_get_grid_const ( const pencil_layouter_t *this_ );
123
124 /*!
125 * \brief layouts the chosen diagram contents into the diagram_bounds area
126 *
127 * \param this_ pointer to own object attributes
128 * \param font_layout pango layout object to determine the font metrics in the current cairo drawing context
129 */
130 void pencil_layouter_layout_elements ( pencil_layouter_t *this_, PangoLayout *font_layout );
131
132 /* !
133 * \brief returns the layout_visible_set_t object
134 *
135 * \param this_ pointer to own object attributes
136 */
137 static inline layout_visible_set_t *pencil_layouter_get_layout_data_ptr ( pencil_layouter_t *this_ );
138
139 /*!
140 * \brief returns the layout_visible_set_t object
141 *
142 * \param this_ pointer to own object attributes
143 */
144 static inline const layout_visible_set_t *pencil_layouter_get_layout_data_const ( const pencil_layouter_t *this_ );
145
146 /*!
147 * \brief returns the pencil size object
148 *
149 * \param this_ pointer to own object attributes
150 */
151 static inline const pencil_size_t *pencil_layouter_get_pencil_size_const ( pencil_layouter_t *this_ );
152
153 /*!
154 * \brief gets the layout order for a classifier at a given position
155 *
156 * \param this_ pointer to own object attributes
157 *
158 * \param c_type classifier type for which to determine the order
159 * \param x x-position
160 * \param y y-position
161 * \param snap_distance maximum distance to the next grid line when to snap to a grid position
162 * \param out_layout_order order at given position
163 * \return PENCIL_ERROR_OUT_OF_BOUNDS if the given position x, y is not in the diagram
164 */
165 pencil_error_t pencil_layouter_get_classifier_order_at_pos ( const pencil_layouter_t *this_,
166 data_classifier_type_t c_type,
167 double x,
168 double y,
169 double snap_distance,
170 layout_order_t* out_layout_order
171 );
172
173 /*!
174 * \brief gets the layout order for a feature at a given position (relative to a classifier)
175 *
176 * \param this_ pointer to own object attributes
177 * \param feature_ptr pointer to the feature for which to determine the order at x/y
178 * \param x x-position
179 * \param y y-position
180 * \param out_layout_order order at given position
181 * \return PENCIL_ERROR_OUT_OF_BOUNDS if the given position x, y is not in the diagram,
182 * PENCIL_ERROR_UNKNOWN_OBJECT if the object is not in the diagram or has unsupported type
183 */
184 pencil_error_t pencil_layouter_get_feature_order_at_pos ( const pencil_layouter_t *this_,
185 const data_feature_t *feature_ptr,
186 double x,
187 double y,
188 layout_order_t* out_layout_order
189 );
190
191 /*!
192 * \brief gets the layout order for a relationship at a given position
193 *
194 * \param this_ pointer to own object attributes
195 * \param x x-position
196 * \param y y-position
197 * \param out_layout_order order at given position
198 * \return PENCIL_ERROR_OUT_OF_BOUNDS if the given position x, y is not in the diagram,
199 * PENCIL_ERROR_UNKNOWN_OBJECT if the object is not in the diagram or has unsupported type
200 */
201 pencil_error_t pencil_layouter_get_relationship_order_at_pos ( const pencil_layouter_t *this_,
202 double x,
203 double y,
204 layout_order_t* out_layout_order
205 );
206
207 /*!
208 * \brief proposes a default classifier bounds rectangle
209 *
210 * \param this_ pointer to own object attributes
211 */
212 void pencil_layouter_private_propose_default_classifier_size ( pencil_layouter_t *this_ );
213
214 #include "pencil_layouter.inl"
215
216 #endif /* PENCIL_LAYOUTER_H */
217
218
219 /*
220 Copyright 2017-2026 Andreas Warnke
221
222 Licensed under the Apache License, Version 2.0 (the "License");
223 you may not use this file except in compliance with the License.
224 You may obtain a copy of the License at
225
226 http://www.apache.org/licenses/LICENSE-2.0
227
228 Unless required by applicable law or agreed to in writing, software
229 distributed under the License is distributed on an "AS IS" BASIS,
230 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
231 See the License for the specific language governing permissions and
232 limitations under the License.
233 */