Debian Codegraph @

pencil/include/pencil_feature_layouter.h

raw
1 /* File: pencil_feature_layouter.h; Copyright and License: see below */
2
3 #ifndef PENCIL_FEATURE_LAYOUTER_H
4 #define PENCIL_FEATURE_LAYOUTER_H
5
6 /* public file for the doxygen documentation: */
7 /*!
8 * \file
9 * \brief Calculates positions of features in a diagram
10 */
11
12 #include "pencil_size.h"
13 #include "layout/layout_visible_set.h"
14 #include "pencil_feature_painter.h"
15 #include "geometry/geometry_rectangle.h"
16 #include "geometry/geometry_dimensions.h"
17 #include "geometry/geometry_non_linear_scale.h"
18 #include "entity/data_diagram.h"
19 #include "set/data_visible_set.h"
20 #include "set/data_small_set.h"
21 #include "entity/data_id.h"
22 #include "data_rules.h"
23 #include "u8list/universal_array_index_sorter.h"
24 #include <cairo.h>
25 #include <stdint.h>
26
27 /*!
28 * \brief attributes of the feature layouter
29 *
30 * \note This class is stateless. Only the layout_data, pencil_size and profile objects are stateful.
31 * It may either be instantiated once and used many times or be instantiated per use.
32 */
33 struct pencil_feature_layouter_struct {
34 layout_visible_set_t *layout_data; /* pointer to external layout data */
35 const data_profile_part_t *profile; /*!< pointer to an external stereotype-image cache */
36 const pencil_size_t *pencil_size; /*!< pointer to an external pencil_size_t object, */
37 /*!< defining pen sizes, gap sizes, font sizes and colors */
38 data_rules_t rules; /*!< own instance of modelling rules */
39 bool label_dimensions_initialized; /*!< true if the widths and heights of labels in layout_data are already initialized */
40
41 pencil_feature_painter_t feature_painter; /*!< own instance of a painter object to ask for display dimensions */
42 };
43
44 typedef struct pencil_feature_layouter_struct pencil_feature_layouter_t;
45
46 /*!
47 * \brief initializes the feature layouter
48 *
49 * \param this_ pointer to own object attributes
50 * \param layout_data pointer to the layout information to be used and modified
51 * \param profile pointer to the profile-part that provides the stereotypes of the elements to be layouted
52 * \param pencil_size pointer to the pencil_size_t object
53 */
54 void pencil_feature_layouter_init( pencil_feature_layouter_t *this_,
55 layout_visible_set_t *layout_data,
56 const data_profile_part_t *profile,
57 const pencil_size_t *pencil_size
58 );
59
60 /*!
61 * \brief resets the label_dimensions_initialized flag to false
62 *
63 * \param this_ pointer to own object attributes
64 */
65 void pencil_feature_layouter_reset( pencil_feature_layouter_t *this_ );
66
67 /*!
68 * \brief destroys the feature layouter
69 *
70 * \param this_ pointer to own object attributes
71 */
72 void pencil_feature_layouter_destroy( pencil_feature_layouter_t *this_ );
73
74 /*!
75 * \brief determines the bounding boxes of the features
76 *
77 * \param this_ pointer to own object attributes
78 * \param font_layout pango layout object to determine the font metrics in the current cairo drawing context
79 */
80 void pencil_feature_layouter_do_layout ( pencil_feature_layouter_t *this_, PangoLayout *font_layout );
81
82 /*!
83 * \brief calculates feature bounding dimensions of property and operation features for one diagramelement
84 *
85 * \param this_ pointer to own object attributes
86 * \param diagramelement_id id of the diagramelement for which to calculate the feature bounds
87 * \param font_layout pango layout object to determine the font metrics in the current cairo drawing context
88 * \param[out] out_features_bounds memory location where the result shall be stored. Must not be NULL.
89 */
90 void pencil_feature_layouter_calculate_features_bounds ( pencil_feature_layouter_t *this_,
91 data_row_t diagramelement_id,
92 PangoLayout *font_layout,
93 geometry_dimensions_t *out_features_bounds
94 );
95
96 /*!
97 * \brief calculates the label dimensions of all features.
98 *
99 * This allows to arrange(move) the features in a subsequent step.
100 *
101 * \param this_ pointer to own object attributes
102 * \param font_layout pango layout object to determine the font metrics in the current cairo drawing context
103 */
104 void pencil_feature_layouter_private_init_label_dimensions( pencil_feature_layouter_t *this_,
105 PangoLayout *font_layout
106 );
107
108 /*!
109 * \brief determines the symbol box of a lifeline
110 *
111 * \param this_ pointer to own object attributes
112 * \param diagram_space drawing space of the diagram
113 * \param diagram_type diagram type of the diagram
114 * \param classifier_type type of the parent classifier
115 * \param classifier_symbol_box symbol box of the classifier
116 * \param classifier_envelope_box envelope box of the classifier
117 * \param[out] out_feature_layout output parameter: feature layout coordinates
118 */
119 void pencil_feature_layouter_private_layout_lifeline ( pencil_feature_layouter_t *this_,
120 const geometry_rectangle_t *diagram_space,
121 data_diagram_type_t diagram_type,
122 data_classifier_type_t classifier_type,
123 const geometry_rectangle_t *classifier_symbol_box,
124 const geometry_rectangle_t *classifier_envelope_box,
125 layout_feature_t *out_feature_layout
126 );
127
128 /*!
129 * \brief determines the symbol box of a port or action-pin or entry/exit state
130 *
131 * \param this_ pointer to own object attributes
132 * \param classifier_type type of the parent classifier
133 * \param classifier_symbol_box symbol box of the parent classifier
134 * \param the_feature the feature data to be layouted
135 * \param font_layout pango layout object to determine the font metrics in the current cairo drawing context
136 * \param[out] out_feature_layout output parameter: feature layout coordinates
137 */
138 void pencil_feature_layouter_private_layout_port_pin ( pencil_feature_layouter_t *this_,
139 data_classifier_type_t classifier_type,
140 const geometry_rectangle_t *classifier_symbol_box,
141 const data_feature_t *the_feature,
142 PangoLayout *font_layout,
143 layout_feature_t *out_feature_layout
144 );
145
146 /*!
147 * \brief determines the symbol box of a provided or required interface
148 *
149 * \param this_ pointer to own object attributes
150 * \param classifier_symbol_box symbol box of the classifier
151 * \param the_feature the feature data to be layouted
152 * \param font_layout pango layout object to determine the font metrics in the current cairo drawing context
153 * \param[out] out_feature_layout output parameter: feature layout coordinates
154 */
155 void pencil_feature_layouter_private_layout_interface ( pencil_feature_layouter_t *this_,
156 const geometry_rectangle_t *classifier_symbol_box,
157 const data_feature_t *the_feature,
158 PangoLayout *font_layout,
159 layout_feature_t *out_feature_layout
160 );
161
162 /*!
163 * \brief determines the symbol box of a property or operation or tagged-value
164 *
165 * \param this_ pointer to own object attributes
166 * \param classifier_space space area in the classifier
167 * \param font_layout pango layout object to determine the font metrics in the current cairo drawing context
168 * \param[in,out] io_feature_layout in+output parameter: feature layout coordinates
169 */
170 void pencil_feature_layouter_private_layout_compartment ( pencil_feature_layouter_t *this_,
171 const geometry_rectangle_t *classifier_space,
172 PangoLayout *font_layout,
173 layout_feature_t *io_feature_layout
174 );
175
176 #endif /* PENCIL_FEATURE_LAYOUTER_H */
177
178
179 /*
180 Copyright 2017-2026 Andreas Warnke
181
182 Licensed under the Apache License, Version 2.0 (the "License");
183 you may not use this file except in compliance with the License.
184 You may obtain a copy of the License at
185
186 http://www.apache.org/licenses/LICENSE-2.0
187
188 Unless required by applicable law or agreed to in writing, software
189 distributed under the License is distributed on an "AS IS" BASIS,
190 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
191 See the License for the specific language governing permissions and
192 limitations under the License.
193 */