| 1 |
/* File: draw_classifier_icon.h; Copyright and License: see below */ |
| 2 |
|
| 3 |
#ifndef DRAW_CLASSIFIER_ICON_H |
| 4 |
#define DRAW_CLASSIFIER_ICON_H |
| 5 |
|
| 6 |
/* public file for the doxygen documentation: */ |
| 7 |
/*! |
| 8 |
* \file |
| 9 |
* \brief Renders a classifier into a cairo drawing context |
| 10 |
*/ |
| 11 |
|
| 12 |
#include "pencil_size.h" |
| 13 |
#include "geometry/geometry_h_align.h" |
| 14 |
#include "geometry/geometry_v_align.h" |
| 15 |
#include "geometry/geometry_rectangle.h" |
| 16 |
#include "geometry/geometry_dimensions.h" |
| 17 |
#include "entity/data_classifier_type.h" |
| 18 |
#include <cairo.h> |
| 19 |
#include <stdint.h> |
| 20 |
|
| 21 |
/*! \brief aspect ratio of the artifact icon */ |
| 22 |
extern const double DRAW_CLASSIFIER_ICON_ARTIFACT_ICON_WIDTH_TO_HEIGHT; |
| 23 |
/*! \brief aspect ratio of the component icon */ |
| 24 |
extern const double DRAW_CLASSIFIER_ICON_COMPONENT_ICON_WIDTH_TO_HEIGHT; |
| 25 |
|
| 26 |
/*! |
| 27 |
* \brief attributes of the draw symbol functions |
| 28 |
* |
| 29 |
* \note This class is stateless. |
| 30 |
* It may either be instantiated once and used many times or be instantiated per use. |
| 31 |
*/ |
| 32 |
struct draw_classifier_icon_struct { |
| 33 |
int dummy; /*!< This object is a collection of stateless drawing functions */ |
| 34 |
}; |
| 35 |
|
| 36 |
typedef struct draw_classifier_icon_struct draw_classifier_icon_t; |
| 37 |
|
| 38 |
/*! |
| 39 |
* \brief initializes the draw_classifier_icon_t |
| 40 |
* |
| 41 |
* \param this_ pointer to own object attributes |
| 42 |
*/ |
| 43 |
static inline void draw_classifier_icon_init( draw_classifier_icon_t *this_ ); |
| 44 |
|
| 45 |
/*! |
| 46 |
* \brief destroys the draw_classifier_icon_t |
| 47 |
* |
| 48 |
* \param this_ pointer to own object attributes |
| 49 |
*/ |
| 50 |
static inline void draw_classifier_icon_destroy( draw_classifier_icon_t *this_ ); |
| 51 |
|
| 52 |
/*! |
| 53 |
* \brief determines the dimensions of the type icon. |
| 54 |
* |
| 55 |
* Type icons are e.g. artifact-icon or component-icon. |
| 56 |
* |
| 57 |
* \param this_ pointer to own object attributes |
| 58 |
* \param classifier_type type of the classifier to draw |
| 59 |
* \param pencil_size set of sizes and colors for drawing lines and text |
| 60 |
* \return dimension of the icon. |
| 61 |
*/ |
| 62 |
static inline geometry_dimensions_t draw_classifier_icon_get_icon_dimensions ( const draw_classifier_icon_t *this_, |
| 63 |
data_classifier_type_t classifier_type, |
| 64 |
const pencil_size_t *pencil_size |
| 65 |
); |
| 66 |
|
| 67 |
/*! |
| 68 |
* \brief calculates the bounding rectangle for component icon |
| 69 |
* |
| 70 |
* \param this_ pointer to own object attributes |
| 71 |
* \param x x location where to draw the icon |
| 72 |
* \param y y location where to draw the icon |
| 73 |
* \param h_align alignment of the icon versus the given x coordinate |
| 74 |
* \param v_align alignment of the icon versus the given y coordinate |
| 75 |
* \param height size of the icon |
| 76 |
* \return bounding box rectangle of the icon |
| 77 |
*/ |
| 78 |
static inline geometry_rectangle_t draw_classifier_icon_get_component_bounds ( const draw_classifier_icon_t *this_, |
| 79 |
double x, |
| 80 |
double y, |
| 81 |
geometry_h_align_t h_align, |
| 82 |
geometry_v_align_t v_align, |
| 83 |
double height |
| 84 |
); |
| 85 |
|
| 86 |
/*! |
| 87 |
* \brief draws the component icon into the bounds rect |
| 88 |
* |
| 89 |
* \param this_ pointer to own object attributes |
| 90 |
* \param bounds bounding rectangle of the icon |
| 91 |
* \param cr a cairo drawing context |
| 92 |
*/ |
| 93 |
void draw_classifier_icon_draw_component ( const draw_classifier_icon_t *this_, |
| 94 |
geometry_rectangle_t bounds, |
| 95 |
cairo_t *cr |
| 96 |
); |
| 97 |
|
| 98 |
/*! |
| 99 |
* \brief calculates the bounding rectangle for the artifact icon |
| 100 |
* |
| 101 |
* \param this_ pointer to own object attributes |
| 102 |
* \param x x location where to draw the icon |
| 103 |
* \param y y location where to draw the icon |
| 104 |
* \param h_align alignment of the icon versus the given x coordinate |
| 105 |
* \param v_align alignment of the icon versus the given y coordinate |
| 106 |
* \param height size of the icon |
| 107 |
* \return bounding box rectangle of the icon |
| 108 |
*/ |
| 109 |
static inline geometry_rectangle_t draw_classifier_icon_get_artifact_bounds ( const draw_classifier_icon_t *this_, |
| 110 |
double x, |
| 111 |
double y, |
| 112 |
geometry_h_align_t h_align, |
| 113 |
geometry_v_align_t v_align, |
| 114 |
double height |
| 115 |
); |
| 116 |
|
| 117 |
/*! |
| 118 |
* \brief draws the artifact icon into the bounds rect |
| 119 |
* |
| 120 |
* \param this_ pointer to own object attributes |
| 121 |
* \param bounds bounding rectangle of the icon |
| 122 |
* \param cr a cairo drawing context |
| 123 |
*/ |
| 124 |
void draw_classifier_icon_draw_artifact ( const draw_classifier_icon_t *this_, |
| 125 |
geometry_rectangle_t bounds, |
| 126 |
cairo_t *cr |
| 127 |
); |
| 128 |
|
| 129 |
/*! |
| 130 |
* \brief calculates the bounding rectangle for the actor icon |
| 131 |
* |
| 132 |
* \param this_ pointer to own object attributes |
| 133 |
* \param x x location where to draw the icon |
| 134 |
* \param y y location where to draw the icon |
| 135 |
* \param h_align alignment of the icon versus the given x coordinate |
| 136 |
* \param v_align alignment of the icon versus the given y coordinate |
| 137 |
* \param height size of the icon |
| 138 |
* \return bounding box rectangle of the icon |
| 139 |
*/ |
| 140 |
static inline geometry_rectangle_t draw_classifier_icon_get_actor_bounds ( const draw_classifier_icon_t *this_, |
| 141 |
double x, |
| 142 |
double y, |
| 143 |
geometry_h_align_t h_align, |
| 144 |
geometry_v_align_t v_align, |
| 145 |
double height |
| 146 |
); |
| 147 |
|
| 148 |
/*! |
| 149 |
* \brief draws the actor icon into the bounds rect |
| 150 |
* |
| 151 |
* \param this_ pointer to own object attributes |
| 152 |
* \param bounds bounding rectangle of the icon |
| 153 |
* \param cr a cairo drawing context |
| 154 |
*/ |
| 155 |
void draw_classifier_icon_draw_actor ( const draw_classifier_icon_t *this_, |
| 156 |
geometry_rectangle_t bounds, |
| 157 |
cairo_t *cr |
| 158 |
); |
| 159 |
|
| 160 |
/*! |
| 161 |
* \brief calculates the bounding rectangle for the circle icon at the defined location |
| 162 |
* |
| 163 |
* \param this_ pointer to own object attributes |
| 164 |
* \param x x location where to draw the icon |
| 165 |
* \param y y location where to draw the icon |
| 166 |
* \param h_align alignment of the icon versus the given x coordinate |
| 167 |
* \param v_align alignment of the icon versus the given y coordinate |
| 168 |
* \param height size of the icon |
| 169 |
* \return bounding box rectangle of the icon |
| 170 |
*/ |
| 171 |
static inline geometry_rectangle_t draw_classifier_icon_get_circle_bounds ( const draw_classifier_icon_t *this_, |
| 172 |
double x, |
| 173 |
double y, |
| 174 |
geometry_h_align_t h_align, |
| 175 |
geometry_v_align_t v_align, |
| 176 |
double height |
| 177 |
); |
| 178 |
|
| 179 |
/*! |
| 180 |
* \brief draws the circle icon into the bounds rect |
| 181 |
* |
| 182 |
* \param this_ pointer to own object attributes |
| 183 |
* \param bounds bounding rectangle of the icon |
| 184 |
* \param pencil_size a set of size-values used for drawing elements in this diagram |
| 185 |
* \param stroke true if the outer circle line shall be drawn |
| 186 |
* \param fill true if the inner circle area shall be filled |
| 187 |
* \param shallow_history true if the H character shall be drawn |
| 188 |
* \param deep_history true if the H* character pir shall be drawn |
| 189 |
* \param cr a cairo drawing context |
| 190 |
*/ |
| 191 |
void draw_classifier_icon_draw_circle ( const draw_classifier_icon_t *this_, |
| 192 |
geometry_rectangle_t bounds, |
| 193 |
const pencil_size_t *pencil_size, |
| 194 |
bool stroke, |
| 195 |
bool fill, |
| 196 |
bool shallow_history, |
| 197 |
bool deep_history, |
| 198 |
cairo_t *cr |
| 199 |
); |
| 200 |
|
| 201 |
/*! |
| 202 |
* \brief calculates the bounding rectangle for the time icon |
| 203 |
* |
| 204 |
* \param this_ pointer to own object attributes |
| 205 |
* \param x x location where to draw the icon |
| 206 |
* \param y y location where to draw the icon |
| 207 |
* \param h_align alignment of the icon versus the given x coordinate |
| 208 |
* \param v_align alignment of the icon versus the given y coordinate |
| 209 |
* \param height size of the icon |
| 210 |
* \return bounding box rectangle of the icon |
| 211 |
*/ |
| 212 |
static inline geometry_rectangle_t draw_classifier_icon_get_time_bounds ( const draw_classifier_icon_t *this_, |
| 213 |
double x, |
| 214 |
double y, |
| 215 |
geometry_h_align_t h_align, |
| 216 |
geometry_v_align_t v_align, |
| 217 |
double height |
| 218 |
); |
| 219 |
|
| 220 |
/*! |
| 221 |
* \brief draws the time icon into the bounds rect |
| 222 |
* |
| 223 |
* \param this_ pointer to own object attributes |
| 224 |
* \param bounds bounding rectangle of the icon |
| 225 |
* \param cr a cairo drawing context |
| 226 |
*/ |
| 227 |
void draw_classifier_icon_draw_time ( const draw_classifier_icon_t *this_, |
| 228 |
geometry_rectangle_t bounds, |
| 229 |
cairo_t *cr |
| 230 |
); |
| 231 |
|
| 232 |
/*! |
| 233 |
* \brief calculates the bounding rectangle for the sync icon |
| 234 |
* |
| 235 |
* \param this_ pointer to own object attributes |
| 236 |
* \param x x location where to draw the icon |
| 237 |
* \param y y location where to draw the icon |
| 238 |
* \param h_align alignment of the icon versus the given x coordinate |
| 239 |
* \param v_align alignment of the icon versus the given y coordinate |
| 240 |
* \param height size of the icon |
| 241 |
* \param pencil_size a set of size-values used for drawing elements in this diagram |
| 242 |
* \return bounding box rectangle of the icon |
| 243 |
*/ |
| 244 |
static inline geometry_rectangle_t draw_classifier_icon_get_sync_bounds ( const draw_classifier_icon_t *this_, |
| 245 |
double x, |
| 246 |
double y, |
| 247 |
geometry_h_align_t h_align, |
| 248 |
geometry_v_align_t v_align, |
| 249 |
double height, |
| 250 |
const pencil_size_t *pencil_size |
| 251 |
); |
| 252 |
|
| 253 |
/*! |
| 254 |
* \brief draws the sync icon into the bounds rect |
| 255 |
* |
| 256 |
* \param this_ pointer to own object attributes |
| 257 |
* \param bounds bounding rectangle of the icon |
| 258 |
* \param cr a cairo drawing context |
| 259 |
*/ |
| 260 |
void draw_classifier_icon_draw_sync ( const draw_classifier_icon_t *this_, |
| 261 |
geometry_rectangle_t bounds, |
| 262 |
cairo_t *cr |
| 263 |
); |
| 264 |
|
| 265 |
#include "draw_classifier_icon.inl" |
| 266 |
|
| 267 |
#endif /* DRAW_CLASSIFIER_ICON_H */ |
| 268 |
|
| 269 |
|
| 270 |
/* |
| 271 |
Copyright 2019-2026 Andreas Warnke |
| 272 |
|
| 273 |
Licensed under the Apache License, Version 2.0 (the "License"); |
| 274 |
you may not use this file except in compliance with the License. |
| 275 |
You may obtain a copy of the License at |
| 276 |
|
| 277 |
http://www.apache.org/licenses/LICENSE-2.0 |
| 278 |
|
| 279 |
Unless required by applicable law or agreed to in writing, software |
| 280 |
distributed under the License is distributed on an "AS IS" BASIS, |
| 281 |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 282 |
See the License for the specific language governing permissions and |
| 283 |
limitations under the License. |
| 284 |
*/ |