Debian Codegraph @

pencil/include/layout/layout_visible_set.h

raw
1 /* File: layout_visible_set.h; Copyright and License: see below */
2
3 #ifndef LAYOUT_VISIBLE_SET_H
4 #define LAYOUT_VISIBLE_SET_H
5
6 /* public file for the doxygen documentation: */
7 /*!
8 * \file
9 * \brief Stores the layout data for input data.
10 */
11
12 #include "geometry/geometry_connector.h"
13 #include "geometry/geometry_rectangle.h"
14 #include "layout/layout_diagram.h"
15 #include "layout/layout_feature.h"
16 #include "layout/layout_relationship.h"
17 #include "layout/layout_visible_classifier.h"
18 #include "filter/pencil_visibility.h"
19 #include "set/data_visible_set.h"
20 #include "set/data_stat.h"
21 #include "data_rules.h"
22 #include <cairo.h>
23 #include <stdint.h>
24 #include <stdbool.h>
25
26 /*!
27 * \brief constants for maximum values of layout_visible_set_t
28 *
29 * While the data_visible_set_t contains features and relationships just once,
30 * layout_visible_set_t contains these once per instance of every visible_classifier_t.
31 */
32 enum layout_visible_set_max_enum {
33 LAYOUT_VISIBLE_SET_MAX_CLASSIFIERS = DATA_VISIBLE_SET_MAX_CLASSIFIERS, /*!< maximum number of classifiers to be shown in one single diagram */
34 LAYOUT_VISIBLE_SET_MAX_FEATURES = DATA_VISIBLE_SET_MAX_FEATURES + 32, /*!< maximum number of features to be shown in one single diagram */
35 LAYOUT_VISIBLE_SET_MAX_RELATIONSHIPS = DATA_VISIBLE_SET_MAX_RELATIONSHIPS * 2, /*!< maximum number of relationships to be shown in one single diagram */
36 };
37
38 /*!
39 * \brief attributes of the layout_visible_set_t
40 *
41 * layout_visible_set_t contains a consistent subset of the database model:
42 * If a feature is contained, its classifier is contained.
43 * If a relationship is contained, the classifiers of both ends are contained.
44 *
45 * In case the data exceeds the limits of the member arrays, some data cannot be shown.
46 * There is no guarantee for completeness.
47 */
48 struct layout_visible_set_struct {
49 /* diagram layout*/
50 layout_diagram_t diagram_layout; /*!< layout data of the diagram */
51 bool diagram_valid; /*!< true if diagram_layout is initialized */
52
53 /* classifier layout*/
54 layout_visible_classifier_t visible_classifier_layout[LAYOUT_VISIBLE_SET_MAX_CLASSIFIERS]; /*!< layout data of visible classifiers */
55 uint32_t visible_classifier_count; /*!< number of all layouted visible classifier records */
56
57 /* feature layout */
58 layout_feature_t feature_layout[LAYOUT_VISIBLE_SET_MAX_FEATURES]; /*!< layout data of features */
59 uint32_t feature_count; /*!< number of all layouted feature records */
60
61 /* relationship layout */
62 layout_relationship_t relationship_layout[LAYOUT_VISIBLE_SET_MAX_RELATIONSHIPS]; /*!< layout data of relationships */
63 uint32_t relationship_count; /*!< number of all layouted relationship records */
64
65 /* input data */
66 const data_visible_set_t *input_data; /*!< the input data which is base for the layout data */
67 data_rules_t filter_rules; /*!< own instance of uml and sysml consistency rules */
68 };
69
70 typedef struct layout_visible_set_struct layout_visible_set_t;
71
72 /*!
73 * \brief initializes the painter input data layout
74 *
75 * \param this_ pointer to own object attributes
76 * \param input_data pointer to the (cached) data to be layouted
77 */
78 void layout_visible_set_init( layout_visible_set_t *this_, const data_visible_set_t *input_data );
79
80 /*!
81 * \brief re-initializes the painter input data layout
82 *
83 * reinit shall be called when the input_data set has changed
84 * to ensure that the layout data reflects the input data
85 *
86 * \param this_ pointer to own object attributes
87 * \param input_data pointer to the (cached) data to be layouted
88 */
89 static inline void layout_visible_set_reinit( layout_visible_set_t *this_, const data_visible_set_t *input_data );
90
91 /*!
92 * \brief destroys the painter input data layout
93 *
94 * \param this_ pointer to own object attributes
95 */
96 void layout_visible_set_destroy( layout_visible_set_t *this_ );
97
98 /*!
99 * \brief re-initializes the painter input data layout
100 *
101 * resync shall be called when any element in the input_data set has changed
102 * (but not the set itself)
103 * to ensure that the layout data reflects the input data
104 *
105 * \param this_ pointer to own object attributes
106 */
107 static inline void layout_visible_set_resync( layout_visible_set_t *this_ );
108
109 /*!
110 * \brief checks if this set contains valid layout data for a diagram
111 *
112 * This function checks if the data was initialized - it does not perform a consistency check.
113 *
114 * \param this_ pointer to own object attributes
115 * \return true if this object contains valid layout data
116 */
117 static inline bool layout_visible_set_is_valid( const layout_visible_set_t *this_ );
118
119 /* ================================ diagram ================================ */
120
121 /*!
122 * \brief gets the layouted diagram
123 *
124 * \param this_ pointer to own object attributes
125 * \return pointer to layout_diagram_t.
126 */
127 static inline layout_diagram_t *layout_visible_set_get_diagram_ptr ( layout_visible_set_t *this_ );
128
129 /*!
130 * \brief gets the layouted diagram
131 *
132 * \param this_ pointer to own object attributes
133 * \return pointer to layout_diagram_t.
134 */
135 static inline const layout_diagram_t *layout_visible_set_get_diagram_const ( const layout_visible_set_t *this_ );
136
137 /* ================================ classifiers ================================ */
138
139 /*!
140 * \brief gets the number of visible classifiers within the painter layout data
141 *
142 * \param this_ pointer to own object attributes
143 */
144 static inline uint32_t layout_visible_set_get_visible_classifier_count ( const layout_visible_set_t *this_ );
145
146 /*!
147 * \brief gets the layouted visible_classifier
148 *
149 * \param this_ pointer to own object attributes
150 * \param index index of the layouted classifier to retrieve; 0 &lt;= index &lt; LAYOUT_VISIBLE_SET_MAX_CLASSIFIERS.
151 * \return pointer to layout_visible_classifier_t.
152 */
153 static inline layout_visible_classifier_t *layout_visible_set_get_visible_classifier_ptr ( layout_visible_set_t *this_, uint32_t index );
154
155 /*!
156 * \brief gets the layouted visible_classifier
157 *
158 * \param this_ pointer to own object attributes
159 * \param index index of the layouted classifier to retrieve; 0 &lt;= index &lt; LAYOUT_VISIBLE_SET_MAX_CLASSIFIERS.
160 * \return pointer to layout_visible_classifier_t.
161 */
162 static inline const layout_visible_classifier_t *layout_visible_set_get_visible_classifier_const ( const layout_visible_set_t *this_, uint32_t index );
163
164 /* ================================ features ================================ */
165
166 /*!
167 * \brief gets the number of features within the painter layout data
168 *
169 * \param this_ pointer to own object attributes
170 */
171 static inline uint32_t layout_visible_set_get_feature_count ( const layout_visible_set_t *this_ );
172
173 /*!
174 * \brief gets the layouted feature
175 *
176 * \param this_ pointer to own object attributes
177 * \param index index of the layouted feature to retrieve; 0 &lt;= index &lt; LAYOUT_VISIBLE_SET_MAX_FEATURES.
178 * \return pointer to layout_feature_t.
179 */
180 static inline layout_feature_t *layout_visible_set_get_feature_ptr ( layout_visible_set_t *this_, uint32_t index );
181
182 /*!
183 * \brief gets the layouted feature
184 *
185 * \param this_ pointer to own object attributes
186 * \param index index of the layouted feature to retrieve; 0 &lt;= index &lt; LAYOUT_VISIBLE_SET_MAX_FEATURES.
187 * \return pointer to layout_feature_t.
188 */
189 static inline const layout_feature_t *layout_visible_set_get_feature_const ( const layout_visible_set_t *this_, uint32_t index );
190
191 /* ================================ relationships ================================ */
192
193 /*!
194 * \brief gets the visibility of a relationship
195 *
196 * \param this_ pointer to own object attributes
197 * \param index index of the relationship visibility to retrieve; 0 &lt;= index &lt; LAYOUT_VISIBLE_SET_MAX_RELATIONSHIPS.
198 * \return true if visible.
199 */
200 static inline pencil_visibility_t layout_visible_set_get_relationship_visibility ( const layout_visible_set_t *this_, uint32_t index );
201
202 /*!
203 * \brief sets the visibility of a relationship
204 *
205 * \param this_ pointer to own object attributes
206 * \param index index of the relationship visibility to set; 0 &lt;= index &lt; LAYOUT_VISIBLE_SET_MAX_RELATIONSHIPS.
207 * \param visible true if visible.
208 */
209 static inline void layout_visible_set_set_relationship_visibility ( layout_visible_set_t *this_, uint32_t index, pencil_visibility_t visible );
210
211 /*!
212 * \brief gets the number of relationships within the painter layout data
213 *
214 * \param this_ pointer to own object attributes
215 */
216 static inline uint32_t layout_visible_set_get_relationship_count ( const layout_visible_set_t *this_ );
217
218 /*!
219 * \brief gets the layouted relationship
220 *
221 * \param this_ pointer to own object attributes
222 * \param index index of the layouted relationship to retrieve; 0 &lt;= index &lt; LAYOUT_VISIBLE_SET_MAX_RELATIONSHIPS.
223 * \return pointer to layout_relationship_t.
224 */
225 static inline layout_relationship_t *layout_visible_set_get_relationship_ptr ( layout_visible_set_t *this_, uint32_t index );
226
227 /*!
228 * \brief gets the layouted relationship
229 *
230 * \param this_ pointer to own object attributes
231 * \param index index of the layouted relationship to retrieve; 0 &lt;= index &lt; LAYOUT_VISIBLE_SET_MAX_RELATIONSHIPS.
232 * \return pointer to layout_relationship_t.
233 */
234 static inline const layout_relationship_t *layout_visible_set_get_relationship_const ( const layout_visible_set_t *this_, uint32_t index );
235
236 /*!
237 * \brief determines if ancestor is an ancestor of descendant
238 *
239 * \param this_ pointer to own object attributes
240 * \param ancestor the ancestor classifier
241 * \param descendant the descendant classifier
242 * \return true if there is a DATA_RELATIONSHIP_TYPE_UML_CONTAINMENT relationship from ancestor to descendant within the data_visible_set object
243 */
244 static inline bool layout_visible_set_is_ancestor ( const layout_visible_set_t *this_,
245 const layout_visible_classifier_t *ancestor,
246 const layout_visible_classifier_t *descendant
247 );
248
249 /*!
250 * \brief counts the number of ancestors of a classifier
251 *
252 * \param this_ pointer to own object attributes
253 * \param classifier the classifier of which to count ancestors
254 * \return number of ancestors of classifier which are listed in this_.
255 */
256 static inline uint32_t layout_visible_set_count_ancestors ( const layout_visible_set_t *this_,
257 const layout_visible_classifier_t *classifier
258 );
259
260 /*!
261 * \brief counts the number of descendants of a classifier
262 *
263 * \param this_ pointer to own object attributes
264 * \param classifier the classifier of which to count decendants
265 * \return number of descendants of classifier which are listed in this_.
266 */
267 static inline uint32_t layout_visible_set_count_descendants ( const layout_visible_set_t *this_,
268 const layout_visible_classifier_t *classifier
269 );
270
271 /* ================================ misc ================================ */
272
273 /*!
274 * \brief checks if the layout_visible_set is initialized and consistent
275 *
276 * \param this_ pointer to own object attributes
277 * \return true if this_ contains valid data for sketching a diagram
278 */
279 bool layout_visible_set_is_consistent ( const layout_visible_set_t *this_ );
280
281 /*!
282 * \brief gets statistics on layout_visible_set.
283 *
284 * This encompasses number of objects, number of overlaps with the diagram border (warnings),
285 * number of objects outside diagram (errors). It does not evaluate the layouting quality.
286 *
287 * \param this_ pointer to own object attributes
288 * \param io_layout_stat pointer to already initialized statistics object where layouting statistics are added
289 */
290 void layout_visible_set_get_statistics ( const layout_visible_set_t *this_, data_stat_t *io_layout_stat );
291
292 /*!
293 * \brief initializes the diagram_layout member
294 *
295 * \param this_ pointer to own object attributes, input_data shall be already initialized
296 */
297 void layout_visible_set_private_init_diagram( layout_visible_set_t *this_ );
298
299 /*!
300 * \brief initializes the visible_classifier_layout array
301 *
302 * \param this_ pointer to own object attributes, input_data shall be already initialized
303 */
304 void layout_visible_set_private_init_classifiers( layout_visible_set_t *this_ );
305
306 /*!
307 * \brief initializes the feature_layout array
308 *
309 * \param this_ pointer to own object attributes, input_data and visible_classifier_layout shall be already initialized
310 */
311 void layout_visible_set_private_init_features( layout_visible_set_t *this_ );
312
313 /*!
314 * \brief initializes the relationship_layout array
315 *
316 * \param this_ pointer to own object attributes, input_data and visible_classifier_layout and feature_layout shall be already initialized
317 */
318 void layout_visible_set_private_init_relationships( layout_visible_set_t *this_ );
319
320 /*!
321 * \brief initializes all layout relationships for one data relationship
322 *
323 * \param this_ pointer to own object attributes, input_data and visible_classifier_layout and feature_layout shall be already initialized
324 * \param relationship_data pointer into the data set structure (*this_).input_data, pointing to the data relationship struct
325 * \param io_dropped_relationships io parameter, counter that is increased for every non-instantiated layout relationship
326 * \return number of created layout relationships
327 */
328 uint32_t layout_visible_set_private_init_relationship( layout_visible_set_t *this_,
329 const data_relationship_t *relationship_data,
330 uint32_t *io_dropped_relationships
331 );
332
333 #include "layout_visible_set.inl"
334
335 #endif /* LAYOUT_VISIBLE_SET_H */
336
337
338 /*
339 Copyright 2017-2026 Andreas Warnke
340
341 Licensed under the Apache License, Version 2.0 (the "License");
342 you may not use this file except in compliance with the License.
343 You may obtain a copy of the License at
344
345 http://www.apache.org/licenses/LICENSE-2.0
346
347 Unless required by applicable law or agreed to in writing, software
348 distributed under the License is distributed on an "AS IS" BASIS,
349 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
350 See the License for the specific language governing permissions and
351 limitations under the License.
352 */