Debian Codegraph @

pencil/include/pencil_classifier_composer.h

raw
1 /* File: pencil_classifier_composer.h; Copyright and License: see below */
2
3 #ifndef PENCIL_CLASSIFIER_COMPOSER_H
4 #define PENCIL_CLASSIFIER_COMPOSER_H
5
6 /* public file for the doxygen documentation: */
7 /*!
8 * \file
9 * \brief Renders a classifier by composing it of draw_graphics, draw_classifier_icon and draw_classifier_label commands
10 */
11
12 #include "pencil_marker.h"
13 #include "pencil_size.h"
14 #include "pencil_feature_painter.h"
15 #include "pencil_error.h"
16 #include "layout/layout_visible_set.h"
17 #include "layout/layout_visible_classifier.h"
18 #include "draw/draw_classifier_icon.h"
19 #include "draw/draw_classifier_label.h"
20 #include "draw/draw_classifier_contour.h"
21 #include "draw/draw_stereotype_icon.h"
22 #include "geometry/geometry_rectangle.h"
23 #include "geometry/geometry_dimensions.h"
24 #include "geometry/geometry_h_align.h"
25 #include "geometry/geometry_v_align.h"
26 #include "entity/data_diagram.h"
27 #include "set/data_small_set.h"
28 #include "set/data_profile_part.h"
29 #include "set/data_visible_set.h"
30 #include "entity/data_id.h"
31 #include "data_rules.h"
32 #include <cairo.h>
33 #include <stdint.h>
34
35 /*!
36 * \brief attributes of the classifier-internal layouter
37 *
38 * \note This class is stateless.
39 * It may either be instantiated once and used many times or be instantiated per use.
40 *
41 * The outer encompassing rectangle of the classifier is called
42 * - envelope
43 * .
44 *
45 * There are two general layout schemes, based on the classifier type.
46 * Layouts with a contour (an outer border) follow the scheme
47 * - label + optional icon
48 * - space
49 * .
50 * whereas layouts with an icon follow the scheme
51 * - icon
52 * - label
53 * - space
54 * .
55 *
56 * The icon is
57 * - either an indicator of the classifier type
58 * - or a graphical representation of the stereotype.
59 * .
60 *
61 * The label consists of
62 * - an optional textual representation of the stereotype and
63 * - the name.
64 * .
65 *
66 * The space consists of compartments:
67 * - properties
68 * - operations
69 * - tagged values
70 * - contained classifiers
71 * .
72 */
73 struct pencil_classifier_composer_struct {
74 pencil_marker_t marker; /*!< own instance of a marker */
75 draw_classifier_icon_t draw_classifier_icon; /*!< collection of draw symbol/icon functions */
76 draw_classifier_label_t draw_classifier_label; /*!< collection of draw label functions */
77 draw_classifier_contour_t draw_classifier_contour; /*!< collection of draw contour functions */
78 draw_stereotype_icon_t draw_stereotype_icon; /*!< collection of draw functions for custom stereotype images */
79 };
80
81 typedef struct pencil_classifier_composer_struct pencil_classifier_composer_t;
82
83 /*!
84 * \brief initializes the painter
85 *
86 * \param this_ pointer to own object attributes
87 */
88 void pencil_classifier_composer_init( pencil_classifier_composer_t *this_ );
89
90 /*!
91 * \brief destroys the painter
92 *
93 * \param this_ pointer to own object attributes
94 */
95 void pencil_classifier_composer_destroy( pencil_classifier_composer_t *this_ );
96
97 /*!
98 * \brief recalculates symbol_box and label_box based on new space_and_label
99 *
100 * Precondition: the objects coordinates need to be valid already. This is just a partly recalculation.
101 *
102 * \param this_ pointer to own object attributes
103 * \param space exact new space
104 * \param shows_contained_children true if the classifier has contained children
105 * (needed for uml package because the symbol differs)
106 * \param profile pointer to the profile-part that provides the stereotypes of the elements to be drawn
107 * \param pencil_size set of sizes and colors for drawing lines and text
108 * \param font_layout pango layout object to determine the font metrics in the current cairo drawing context
109 * \param io_classifier_layout classifier layout of which the box coordinates shall be modified. Must not be NULL.
110 * \return PENCIL_ERROR_NONE in case of success,
111 * PENCIL_ERROR_OUT_OF_BOUNDS in case of additionally needed width by label text
112 */
113 pencil_error_t pencil_classifier_composer_expand_space ( pencil_classifier_composer_t *this_,
114 const geometry_rectangle_t *space,
115 bool shows_contained_children,
116 const data_profile_part_t *profile,
117 const pencil_size_t *pencil_size,
118 PangoLayout *font_layout,
119 layout_visible_classifier_t *io_classifier_layout
120 );
121
122 /*!
123 * \brief resizes the contour, inner drawing space for contained classifiers and features - and the label_box
124 *
125 * This method returns values to embrace title and ornaments. classifiers symbol_box is expected to be fix.
126 *
127 * \param this_ pointer to own object attributes
128 * \param envelope exact new outer envelope box; should be big enough to contain the classifier
129 * \param shows_contained_children true if the classifier has contained children
130 * (needed for uml package because the symbol differs)
131 * \param profile pointer to the profile-part that provides the stereotypes of the elements to be drawn
132 * \param pencil_size set of sizes and colors for drawing lines and text
133 * \param font_layout pango layout object to determine the font metrics in the current cairo drawing context
134 * \param io_classifier_layout input is symbol box, output is space and label_box. Must not be NULL.
135 * \return PENCIL_ERROR_NONE in case of success,
136 * PENCIL_ERROR_OUT_OF_BOUNDS in case of additionally needed width or height
137 */
138 pencil_error_t pencil_classifier_composer_set_envelope_box ( pencil_classifier_composer_t *this_,
139 const geometry_rectangle_t *envelope,
140 bool shows_contained_children,
141 const data_profile_part_t *profile,
142 const pencil_size_t *pencil_size,
143 PangoLayout *font_layout,
144 layout_visible_classifier_t *io_classifier_layout
145 );
146
147 /*!
148 * \brief determines the dimensions of the stereotype and name of the classifier.
149 *
150 * Internally, this method determines also the classifier type and icon-dimensions to calculate the label alignment.
151 *
152 * \param this_ pointer to own object attributes
153 * \param visible_classifier the visible_classifier consisting of diagramelement and classifier to draw
154 * \param shows_contained_children true if the classifier has contained children
155 * (needed for uml package because the symbol differs)
156 * \param has_stereotype_icon true if no stereotype label shall be printed because an icon is shown instead
157 * \param space_and_label proposed rectangle for the position,
158 * width and height of: label and icon and features and contained classifiers
159 * \param pencil_size set of sizes and colors for drawing lines and text
160 * \param font_layout pango layout object to determine the font metrics in the current cairo drawing context
161 * \param out_label_box position and dimensions of the label box (smallest box containing stereotype-as-text and name)
162 * \param out_icon_box position and dimensions of the icon box of the stereotype icon (in case of has_stereotype_icon)
163 * \param out_label_compartment position and dimensions of label compartment
164 * (width as the inner_area if fitting, may contain an icon)
165 * \return PENCIL_ERROR_NONE in case of success,
166 * PENCIL_ERROR_OUT_OF_BOUNDS in case of additionally needed width or height
167 */
168 pencil_error_t pencil_classifier_composer_private_get_label_box ( pencil_classifier_composer_t *this_,
169 const data_visible_classifier_t *visible_classifier,
170 bool shows_contained_children,
171 bool has_stereotype_icon,
172 const geometry_rectangle_t *space_and_label,
173 const pencil_size_t *pencil_size,
174 PangoLayout *font_layout,
175 geometry_rectangle_t *out_label_box,
176 geometry_rectangle_t *out_icon_box,
177 geometry_rectangle_t *out_label_compartment
178 );
179
180 #endif /* PENCIL_CLASSIFIER_COMPOSER_H */
181
182
183 /*
184 Copyright 2016-2026 Andreas Warnke
185
186 Licensed under the Apache License, Version 2.0 (the "License");
187 you may not use this file except in compliance with the License.
188 You may obtain a copy of the License at
189
190 http://www.apache.org/licenses/LICENSE-2.0
191
192 Unless required by applicable law or agreed to in writing, software
193 distributed under the License is distributed on an "AS IS" BASIS,
194 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
195 See the License for the specific language governing permissions and
196 limitations under the License.
197 */