| 1 |
/* File: pencil_classifier_painter.c; Copyright and License: see below */ |
| 2 |
|
| 3 |
#include "pencil_classifier_painter.h" |
| 4 |
#include "u8/u8_trace.h" |
| 5 |
#include "u8/u8_f64.h" |
| 6 |
#include "utf8stringbuf/utf8stringbuf.h" |
| 7 |
#include "utf8stringbuf/utf8string.h" |
| 8 |
#include <pango/pangocairo.h> |
| 9 |
#include <stdio.h> |
| 10 |
#include <stdlib.h> |
| 11 |
#include <assert.h> |
| 12 |
|
| 13 |
void pencil_classifier_painter_init( pencil_classifier_painter_t *this_ ) |
| 14 |
{ |
| 15 |
U8_TRACE_BEGIN(); |
| 16 |
|
| 17 |
pencil_marker_init( &((*this_).marker) ); |
| 18 |
draw_classifier_icon_init( &((*this_).draw_classifier_icon) ); |
| 19 |
draw_classifier_label_init( &((*this_).draw_classifier_label) ); |
| 20 |
draw_classifier_contour_init( &((*this_).draw_classifier_contour) ); |
| 21 |
draw_stereotype_icon_init( &((*this_).draw_stereotype_icon) ); |
| 22 |
|
| 23 |
U8_TRACE_END(); |
| 24 |
} |
| 25 |
|
| 26 |
void pencil_classifier_painter_destroy( pencil_classifier_painter_t *this_ ) |
| 27 |
{ |
| 28 |
U8_TRACE_BEGIN(); |
| 29 |
|
| 30 |
draw_classifier_icon_destroy( &((*this_).draw_classifier_icon) ); |
| 31 |
draw_classifier_label_destroy( &((*this_).draw_classifier_label) ); |
| 32 |
draw_classifier_contour_destroy( &((*this_).draw_classifier_contour) ); |
| 33 |
draw_stereotype_icon_destroy( &((*this_).draw_stereotype_icon) ); |
| 34 |
pencil_marker_destroy( &((*this_).marker) ); |
| 35 |
|
| 36 |
U8_TRACE_END(); |
| 37 |
} |
| 38 |
|
| 39 |
void pencil_classifier_painter_draw( pencil_classifier_painter_t *this_, |
| 40 |
const layout_visible_classifier_t *layouted_classifier, |
| 41 |
data_id_t mark_focused, |
| 42 |
data_id_t mark_highlighted, |
| 43 |
const data_small_set_t *mark_selected, |
| 44 |
const layout_visible_set_t *layout_data, |
| 45 |
const data_profile_part_t *profile, |
| 46 |
const pencil_size_t *pencil_size, |
| 47 |
PangoLayout *font_layout, |
| 48 |
cairo_t *cr ) |
| 49 |
{ |
| 50 |
U8_TRACE_BEGIN(); |
| 51 |
assert( NULL != layouted_classifier ); |
| 52 |
assert( NULL != mark_selected ); |
| 53 |
assert( NULL != layout_data ); |
| 54 |
assert( NULL != profile ); |
| 55 |
assert( NULL != pencil_size ); |
| 56 |
assert( NULL != font_layout ); |
| 57 |
assert( NULL != cr ); |
| 58 |
|
| 59 |
const data_visible_classifier_t *const visible_classifier |
| 60 |
= layout_visible_classifier_get_data_const( layouted_classifier ); |
| 61 |
const geometry_rectangle_t *const classifier_symbol_box |
| 62 |
= layout_visible_classifier_get_symbol_box_const( layouted_classifier ); |
| 63 |
const geometry_rectangle_t *const classifier_label_box |
| 64 |
= layout_visible_classifier_get_label_box_const( layouted_classifier ); |
| 65 |
const geometry_rectangle_t *const classifier_icon_box |
| 66 |
= layout_visible_classifier_get_icon_box_const( layouted_classifier ); |
| 67 |
const data_classifier_t *const classifier |
| 68 |
= data_visible_classifier_get_classifier_const( visible_classifier ); |
| 69 |
const data_diagramelement_t *const diagramelement |
| 70 |
= data_visible_classifier_get_diagramelement_const( visible_classifier ); |
| 71 |
const data_classifier_type_t classifier_type = data_classifier_get_main_type( classifier ); |
| 72 |
const char *const classifier_stereotype = data_classifier_get_stereotype_const( classifier ); |
| 73 |
const bool has_stereotype_image |
| 74 |
= draw_stereotype_icon_exists( &((*this_).draw_stereotype_icon), classifier_stereotype, profile ); |
| 75 |
const data_diagramelement_flag_t display_flags |
| 76 |
= data_diagramelement_get_display_flags( diagramelement ); |
| 77 |
|
| 78 |
const double gap = pencil_size_get_standard_object_border( pencil_size ); |
| 79 |
const double std_line_width = pencil_size_get_standard_line_width( pencil_size ); |
| 80 |
/* set the right drawing color */ |
| 81 |
GdkRGBA foreground_color; |
| 82 |
{ |
| 83 |
if ( data_id_equals_id( &mark_highlighted, DATA_TABLE_DIAGRAMELEMENT, data_diagramelement_get_row_id( diagramelement ) ) ) |
| 84 |
{ |
| 85 |
foreground_color = pencil_size_get_highlight_color( pencil_size ); |
| 86 |
} |
| 87 |
else if ( 0 != ( display_flags & DATA_DIAGRAMELEMENT_FLAG_GRAY_OUT )) |
| 88 |
{ |
| 89 |
foreground_color = pencil_size_get_gray_out_color( pencil_size ); |
| 90 |
} |
| 91 |
else |
| 92 |
{ |
| 93 |
foreground_color = pencil_size_get_standard_color( pencil_size ); |
| 94 |
} |
| 95 |
} |
| 96 |
|
| 97 |
U8_TRACE_INFO_INT("drawing classifier id", data_classifier_get_row_id( classifier ) ); |
| 98 |
|
| 99 |
/* draw the stereotype image */ |
| 100 |
bool icon_override = false; /* in case of a stereotype image, the icon shall not be drawn. */ |
| 101 |
if ( has_stereotype_image ) |
| 102 |
{ |
| 103 |
/* check if the image is a small icon within a contour or if it is the full symbol */ |
| 104 |
const bool has_contour = geometry_rectangle_is_containing( classifier_symbol_box, classifier_label_box ); |
| 105 |
|
| 106 |
cairo_set_line_width( cr, std_line_width ); |
| 107 |
|
| 108 |
u8_error_info_t err_info; |
| 109 |
const u8_error_t stereotype_err |
| 110 |
= draw_stereotype_icon_draw( &((*this_).draw_stereotype_icon), |
| 111 |
data_classifier_get_stereotype_const( classifier ), |
| 112 |
profile, |
| 113 |
&foreground_color, |
| 114 |
&err_info, |
| 115 |
has_contour ? classifier_icon_box : classifier_symbol_box, |
| 116 |
cr |
| 117 |
); |
| 118 |
if ( u8_error_info_is_error( &err_info ) ) |
| 119 |
{ |
| 120 |
U8_LOG_WARNING_INT( "stereotype image: unxpected token in svg path in line", |
| 121 |
u8_error_info_get_line( &err_info ) |
| 122 |
); |
| 123 |
} |
| 124 |
icon_override = ( stereotype_err == U8_ERROR_NONE ); |
| 125 |
} |
| 126 |
|
| 127 |
/* draw the classifier */ |
| 128 |
{ |
| 129 |
/* set line width */ |
| 130 |
cairo_set_line_width( cr, std_line_width ); |
| 131 |
/* set color */ |
| 132 |
cairo_set_source_rgba( cr, foreground_color.red, foreground_color.green, foreground_color.blue, foreground_color.alpha ); |
| 133 |
|
| 134 |
/* highlight */ |
| 135 |
if ( 0 != ( display_flags & DATA_DIAGRAMELEMENT_FLAG_EMPHASIS )) |
| 136 |
{ |
| 137 |
const GdkRGBA emph_color = pencil_size_get_emphasized_bgcolor( pencil_size ); |
| 138 |
cairo_set_source_rgba( cr, emph_color.red, emph_color.green, emph_color.blue, emph_color.alpha ); |
| 139 |
cairo_rectangle ( cr, |
| 140 |
geometry_rectangle_get_left( classifier_label_box ), |
| 141 |
geometry_rectangle_get_top( classifier_label_box ), |
| 142 |
geometry_rectangle_get_width( classifier_label_box ), |
| 143 |
geometry_rectangle_get_height( classifier_label_box ) |
| 144 |
); |
| 145 |
cairo_fill (cr); |
| 146 |
cairo_set_source_rgba( cr, foreground_color.red, foreground_color.green, foreground_color.blue, foreground_color.alpha ); |
| 147 |
} |
| 148 |
|
| 149 |
/* draw label */ |
| 150 |
draw_classifier_label_draw_stereotype_and_name( &((*this_).draw_classifier_label), |
| 151 |
visible_classifier, |
| 152 |
( ! has_stereotype_image ), |
| 153 |
&foreground_color, |
| 154 |
classifier_label_box, |
| 155 |
pencil_size, |
| 156 |
font_layout, |
| 157 |
cr |
| 158 |
); |
| 159 |
|
| 160 |
/* draw rectangle */ |
| 161 |
geometry_rectangle_t classifier_symbol_border; |
| 162 |
{ |
| 163 |
geometry_rectangle_copy( &classifier_symbol_border, classifier_symbol_box ); |
| 164 |
geometry_rectangle_enlarge( &classifier_symbol_border, -2.0*gap, -2.0*gap ); |
| 165 |
geometry_rectangle_shift( &classifier_symbol_border, gap, gap ); |
| 166 |
} |
| 167 |
const double symbol_left = geometry_rectangle_get_left ( &classifier_symbol_border ); |
| 168 |
const double symbol_top = geometry_rectangle_get_top ( &classifier_symbol_border ); |
| 169 |
const double symbol_width = geometry_rectangle_get_width ( &classifier_symbol_border ); |
| 170 |
const double symbol_height = geometry_rectangle_get_height ( &classifier_symbol_border ); |
| 171 |
switch ( classifier_type ) |
| 172 |
{ |
| 173 |
case DATA_CLASSIFIER_TYPE_REQUIREMENT: /* SysML */ |
| 174 |
case DATA_CLASSIFIER_TYPE_PART: |
| 175 |
{ |
| 176 |
draw_classifier_contour_draw_rect ( &((*this_).draw_classifier_contour), classifier_symbol_box, pencil_size, cr ); |
| 177 |
} |
| 178 |
break; |
| 179 |
|
| 180 |
case DATA_CLASSIFIER_TYPE_BLOCK: /* SysML */ |
| 181 |
case DATA_CLASSIFIER_TYPE_CLASS: |
| 182 |
case DATA_CLASSIFIER_TYPE_OBJECT: |
| 183 |
case DATA_CLASSIFIER_TYPE_INTERFACE: |
| 184 |
case DATA_CLASSIFIER_TYPE_STEREOTYPE: |
| 185 |
{ |
| 186 |
draw_classifier_contour_draw_rect ( &((*this_).draw_classifier_contour), classifier_symbol_box, pencil_size, cr ); |
| 187 |
pencil_classifier_painter_private_draw_feature_compartments( this_, |
| 188 |
layouted_classifier, |
| 189 |
layout_data, |
| 190 |
pencil_size, |
| 191 |
cr |
| 192 |
); |
| 193 |
} |
| 194 |
break; |
| 195 |
|
| 196 |
case DATA_CLASSIFIER_TYPE_COMPONENT: |
| 197 |
{ |
| 198 |
draw_classifier_contour_draw_rect ( &((*this_).draw_classifier_contour), classifier_symbol_box, pencil_size, cr ); |
| 199 |
|
| 200 |
/* draw icon */ |
| 201 |
const double component_icon_height = pencil_size_get_title_font_size( pencil_size ); |
| 202 |
const geometry_rectangle_t icon_bounds |
| 203 |
= draw_classifier_icon_get_component_bounds( &((*this_).draw_classifier_icon), |
| 204 |
symbol_left + symbol_width - gap, /* x */ |
| 205 |
symbol_top + gap, /* y */ |
| 206 |
GEOMETRY_H_ALIGN_RIGHT, |
| 207 |
GEOMETRY_V_ALIGN_TOP, |
| 208 |
component_icon_height |
| 209 |
); |
| 210 |
if ( ! icon_override ) |
| 211 |
{ |
| 212 |
draw_classifier_icon_draw_component ( &((*this_).draw_classifier_icon), icon_bounds, cr ); |
| 213 |
} |
| 214 |
} |
| 215 |
break; |
| 216 |
|
| 217 |
case DATA_CLASSIFIER_TYPE_ARTIFACT: |
| 218 |
{ |
| 219 |
draw_classifier_contour_draw_rect ( &((*this_).draw_classifier_contour), classifier_symbol_box, pencil_size, cr ); |
| 220 |
|
| 221 |
/* draw icon */ |
| 222 |
const double artifact_icon_height = pencil_size_get_title_font_size( pencil_size ); |
| 223 |
const geometry_rectangle_t icon_bounds |
| 224 |
= draw_classifier_icon_get_artifact_bounds( &((*this_).draw_classifier_icon), |
| 225 |
symbol_left + symbol_width - gap, /* x */ |
| 226 |
symbol_top + gap, /* y */ |
| 227 |
GEOMETRY_H_ALIGN_RIGHT, |
| 228 |
GEOMETRY_V_ALIGN_TOP, |
| 229 |
artifact_icon_height |
| 230 |
); |
| 231 |
if ( ! icon_override ) |
| 232 |
{ |
| 233 |
draw_classifier_icon_draw_artifact ( &((*this_).draw_classifier_icon), icon_bounds, cr ); |
| 234 |
} |
| 235 |
} |
| 236 |
break; |
| 237 |
|
| 238 |
case DATA_CLASSIFIER_TYPE_ACTIVITY: |
| 239 |
case DATA_CLASSIFIER_TYPE_STATE: |
| 240 |
case DATA_CLASSIFIER_TYPE_CONSTRAINT_BLOCK: |
| 241 |
{ |
| 242 |
draw_classifier_contour_draw_rounded_rect ( &((*this_).draw_classifier_contour), classifier_symbol_box, false, pencil_size, cr ); |
| 243 |
pencil_classifier_painter_private_draw_feature_compartments( this_, |
| 244 |
layouted_classifier, |
| 245 |
layout_data, |
| 246 |
pencil_size, |
| 247 |
cr |
| 248 |
); |
| 249 |
} |
| 250 |
break; |
| 251 |
|
| 252 |
case DATA_CLASSIFIER_TYPE_DYN_INTERRUPTABLE_REGION: |
| 253 |
{ |
| 254 |
draw_classifier_contour_draw_rounded_rect ( &((*this_).draw_classifier_contour), classifier_symbol_box, true, pencil_size, cr ); |
| 255 |
} |
| 256 |
break; |
| 257 |
|
| 258 |
case DATA_CLASSIFIER_TYPE_USE_CASE: |
| 259 |
{ |
| 260 |
draw_classifier_contour_draw_ellipse ( &((*this_).draw_classifier_contour), classifier_symbol_box, pencil_size, cr ); |
| 261 |
pencil_classifier_painter_private_draw_feature_compartments( this_, |
| 262 |
layouted_classifier, |
| 263 |
layout_data, |
| 264 |
pencil_size, |
| 265 |
cr |
| 266 |
); |
| 267 |
} |
| 268 |
break; |
| 269 |
|
| 270 |
case DATA_CLASSIFIER_TYPE_NODE: |
| 271 |
{ |
| 272 |
draw_classifier_contour_draw_3d_box ( &((*this_).draw_classifier_contour), classifier_symbol_box, pencil_size, cr ); |
| 273 |
} |
| 274 |
break; |
| 275 |
|
| 276 |
case DATA_CLASSIFIER_TYPE_ACTOR: |
| 277 |
{ |
| 278 |
if ( ! icon_override ) |
| 279 |
{ |
| 280 |
const double actor_height = symbol_height; |
| 281 |
const double half_width = 0.5 * symbol_width; |
| 282 |
const geometry_rectangle_t icon_bounds |
| 283 |
= draw_classifier_icon_get_actor_bounds( &((*this_).draw_classifier_icon), |
| 284 |
symbol_left + half_width, |
| 285 |
symbol_top, |
| 286 |
GEOMETRY_H_ALIGN_CENTER, |
| 287 |
GEOMETRY_V_ALIGN_TOP, |
| 288 |
actor_height |
| 289 |
); |
| 290 |
draw_classifier_icon_draw_actor ( &((*this_).draw_classifier_icon), icon_bounds, cr ); |
| 291 |
} |
| 292 |
} |
| 293 |
break; |
| 294 |
|
| 295 |
case DATA_CLASSIFIER_TYPE_DYN_INITIAL_NODE: |
| 296 |
case DATA_CLASSIFIER_TYPE_DYN_FINAL_NODE: |
| 297 |
case DATA_CLASSIFIER_TYPE_DYN_SHALLOW_HISTORY: |
| 298 |
case DATA_CLASSIFIER_TYPE_DYN_DEEP_HISTORY: |
| 299 |
{ |
| 300 |
if ( ! icon_override ) |
| 301 |
{ |
| 302 |
const double circle_diameter = symbol_height; |
| 303 |
const double half_width = 0.5 * symbol_width; |
| 304 |
const geometry_rectangle_t icon_bounds |
| 305 |
= draw_classifier_icon_get_circle_bounds( &((*this_).draw_classifier_icon), |
| 306 |
symbol_left + half_width, |
| 307 |
symbol_top, |
| 308 |
GEOMETRY_H_ALIGN_CENTER, |
| 309 |
GEOMETRY_V_ALIGN_TOP, |
| 310 |
circle_diameter |
| 311 |
); |
| 312 |
const bool stroke = ( classifier_type != DATA_CLASSIFIER_TYPE_DYN_INITIAL_NODE ); |
| 313 |
const bool fill = ( ( classifier_type == DATA_CLASSIFIER_TYPE_DYN_INITIAL_NODE ) |
| 314 |
|| ( classifier_type == DATA_CLASSIFIER_TYPE_DYN_FINAL_NODE ) ); |
| 315 |
const bool shallow_history = ( classifier_type == DATA_CLASSIFIER_TYPE_DYN_SHALLOW_HISTORY ); |
| 316 |
const bool deep_history = ( classifier_type == DATA_CLASSIFIER_TYPE_DYN_DEEP_HISTORY ); |
| 317 |
draw_classifier_icon_draw_circle( &((*this_).draw_classifier_icon), |
| 318 |
icon_bounds, |
| 319 |
pencil_size, |
| 320 |
stroke, |
| 321 |
fill, |
| 322 |
shallow_history, |
| 323 |
deep_history, |
| 324 |
cr |
| 325 |
); |
| 326 |
} |
| 327 |
} |
| 328 |
break; |
| 329 |
|
| 330 |
case DATA_CLASSIFIER_TYPE_DYN_ACCEPT_EVENT : |
| 331 |
{ |
| 332 |
draw_classifier_contour_draw_accept_event ( &((*this_).draw_classifier_contour), classifier_symbol_box, pencil_size, cr ); |
| 333 |
} |
| 334 |
break; |
| 335 |
|
| 336 |
case DATA_CLASSIFIER_TYPE_DYN_SEND_SIGNAL: |
| 337 |
{ |
| 338 |
draw_classifier_contour_draw_send_signal ( &((*this_).draw_classifier_contour), classifier_symbol_box, pencil_size, cr ); |
| 339 |
} |
| 340 |
break; |
| 341 |
|
| 342 |
case DATA_CLASSIFIER_TYPE_DYN_ACCEPT_TIME_EVENT: |
| 343 |
{ |
| 344 |
if ( ! icon_override ) |
| 345 |
{ |
| 346 |
const double time_icon_height = symbol_height; |
| 347 |
const double half_width = 0.5 * symbol_width; |
| 348 |
const geometry_rectangle_t icon_bounds |
| 349 |
= draw_classifier_icon_get_time_bounds( &((*this_).draw_classifier_icon), |
| 350 |
symbol_left + half_width, |
| 351 |
symbol_top, |
| 352 |
GEOMETRY_H_ALIGN_CENTER, |
| 353 |
GEOMETRY_V_ALIGN_TOP, |
| 354 |
time_icon_height |
| 355 |
); |
| 356 |
draw_classifier_icon_draw_time ( &((*this_).draw_classifier_icon), icon_bounds, cr ); |
| 357 |
} |
| 358 |
} |
| 359 |
break; |
| 360 |
|
| 361 |
case DATA_CLASSIFIER_TYPE_DYN_FORK_NODE: |
| 362 |
case DATA_CLASSIFIER_TYPE_DYN_JOIN_NODE: |
| 363 |
{ |
| 364 |
if ( ! icon_override ) |
| 365 |
{ |
| 366 |
const double box_icon_height = symbol_height; |
| 367 |
const double half_width = 0.5 * symbol_width; |
| 368 |
const geometry_rectangle_t icon_bounds |
| 369 |
= draw_classifier_icon_get_sync_bounds( &((*this_).draw_classifier_icon), |
| 370 |
symbol_left + half_width, |
| 371 |
symbol_top, |
| 372 |
GEOMETRY_H_ALIGN_CENTER, |
| 373 |
GEOMETRY_V_ALIGN_TOP, |
| 374 |
box_icon_height, |
| 375 |
pencil_size |
| 376 |
); |
| 377 |
draw_classifier_icon_draw_sync ( &((*this_).draw_classifier_icon), icon_bounds, cr ); |
| 378 |
} |
| 379 |
} |
| 380 |
break; |
| 381 |
|
| 382 |
case DATA_CLASSIFIER_TYPE_DYN_DECISION_NODE: |
| 383 |
{ |
| 384 |
draw_classifier_contour_draw_rhombus ( &((*this_).draw_classifier_contour), classifier_symbol_box, pencil_size, cr ); |
| 385 |
} |
| 386 |
break; |
| 387 |
|
| 388 |
case DATA_CLASSIFIER_TYPE_SUBSYSTEM: |
| 389 |
{ |
| 390 |
draw_classifier_contour_draw_rect ( &((*this_).draw_classifier_contour), classifier_symbol_box, pencil_size, cr ); |
| 391 |
} |
| 392 |
break; |
| 393 |
|
| 394 |
case DATA_CLASSIFIER_TYPE_INTERACTION_USE: |
| 395 |
{ |
| 396 |
draw_classifier_contour_draw_diagram_ref ( &((*this_).draw_classifier_contour), classifier_symbol_box, pencil_size, cr ); |
| 397 |
} |
| 398 |
break; |
| 399 |
|
| 400 |
case DATA_CLASSIFIER_TYPE_PACKAGE: |
| 401 |
{ |
| 402 |
geometry_rectangle_t label_and_icon_box; |
| 403 |
geometry_rectangle_init_by_bounds( &label_and_icon_box, classifier_label_box, classifier_icon_box ); |
| 404 |
draw_classifier_contour_draw_package( &((*this_).draw_classifier_contour), |
| 405 |
classifier_symbol_box, |
| 406 |
&label_and_icon_box, |
| 407 |
pencil_size, |
| 408 |
cr |
| 409 |
); |
| 410 |
geometry_rectangle_destroy( &label_and_icon_box ); |
| 411 |
} |
| 412 |
break; |
| 413 |
|
| 414 |
case DATA_CLASSIFIER_TYPE_COMMENT: |
| 415 |
{ |
| 416 |
draw_classifier_contour_draw_comment ( &((*this_).draw_classifier_contour), classifier_symbol_box, pencil_size, cr ); |
| 417 |
} |
| 418 |
break; |
| 419 |
|
| 420 |
case DATA_CLASSIFIER_TYPE_IMAGE: |
| 421 |
{ |
| 422 |
if ( ! icon_override ) |
| 423 |
{ |
| 424 |
draw_classifier_contour_draw_rect ( &((*this_).draw_classifier_contour), classifier_symbol_box, pencil_size, cr ); |
| 425 |
} |
| 426 |
} |
| 427 |
break; |
| 428 |
|
| 429 |
default: |
| 430 |
{ |
| 431 |
/* this case can happen if a model file of a new cfu version is opened with an older version of cfu */ |
| 432 |
U8_LOG_ANOMALY("unknown data_classifier_type_t in pencil_classifier_painter_draw()"); |
| 433 |
/* type is unknown, so one cannot decide if to draw rounded corners. */ |
| 434 |
draw_classifier_contour_draw_cornerless( &((*this_).draw_classifier_contour), |
| 435 |
classifier_symbol_box, |
| 436 |
pencil_size, |
| 437 |
cr |
| 438 |
); |
| 439 |
} |
| 440 |
break; |
| 441 |
} |
| 442 |
|
| 443 |
if ( data_small_set_contains_row_id( mark_selected, DATA_TABLE_DIAGRAMELEMENT, data_diagramelement_get_row_id(diagramelement) ) ) |
| 444 |
{ |
| 445 |
pencil_marker_mark_selected_rectangle( &((*this_).marker), *classifier_symbol_box, cr ); |
| 446 |
} |
| 447 |
|
| 448 |
if ( data_id_equals_id( &mark_focused, DATA_TABLE_DIAGRAMELEMENT, data_diagramelement_get_row_id(diagramelement) ) |
| 449 |
|| data_id_equals_id( &mark_focused, DATA_TABLE_CLASSIFIER, data_classifier_get_row_id(classifier) ) ) |
| 450 |
{ |
| 451 |
pencil_marker_mark_focused_rectangle( &((*this_).marker), *classifier_symbol_box, cr ); |
| 452 |
} |
| 453 |
} |
| 454 |
|
| 455 |
U8_TRACE_END(); |
| 456 |
} |
| 457 |
|
| 458 |
void pencil_classifier_painter_private_draw_feature_compartments( const pencil_classifier_painter_t *this_, |
| 459 |
const layout_visible_classifier_t *layouted_classifier, |
| 460 |
const layout_visible_set_t *layout_data, |
| 461 |
const pencil_size_t *pencil_size, |
| 462 |
cairo_t *cr ) |
| 463 |
{ |
| 464 |
U8_TRACE_BEGIN(); |
| 465 |
assert( NULL != layouted_classifier ); |
| 466 |
assert( NULL != layout_data ); |
| 467 |
assert( NULL != pencil_size ); |
| 468 |
assert( NULL != cr ); |
| 469 |
|
| 470 |
/* define names for input data */ |
| 471 |
const geometry_rectangle_t *const classifier_symbol_box |
| 472 |
= layout_visible_classifier_get_symbol_box_const( layouted_classifier ); |
| 473 |
const geometry_rectangle_t *const classifier_space |
| 474 |
= layout_visible_classifier_get_space_const( layouted_classifier ); |
| 475 |
const double gap = pencil_size_get_standard_object_border( pencil_size ); |
| 476 |
const data_row_t diagele_id = layout_visible_classifier_get_diagramelement_id ( layouted_classifier ); |
| 477 |
|
| 478 |
/* determine number of properties and operations */ |
| 479 |
double compartment1_y = geometry_rectangle_get_top( classifier_space ) + gap; |
| 480 |
double compartment2_y = geometry_rectangle_get_top( classifier_space ) + 3.0 * gap; |
| 481 |
double compartment3_y = geometry_rectangle_get_top( classifier_space ) + 5.0 * gap; |
| 482 |
uint_fast32_t count_compartment_entries = 0; |
| 483 |
|
| 484 |
const uint32_t num_features = layout_visible_set_get_feature_count ( layout_data ); |
| 485 |
for ( uint32_t f_probe_idx = 0; f_probe_idx < num_features; f_probe_idx ++ ) |
| 486 |
{ |
| 487 |
const layout_feature_t *const f_probe_layout = layout_visible_set_get_feature_const ( layout_data, f_probe_idx ); |
| 488 |
assert ( NULL != f_probe_layout ); |
| 489 |
const layout_visible_classifier_t *const probe_vis_classfy = layout_feature_get_classifier_const ( f_probe_layout ); |
| 490 |
assert ( NULL != probe_vis_classfy ); |
| 491 |
|
| 492 |
/* check if this f_probe_layout has the same diagram element id as the_feature */ |
| 493 |
if ( diagele_id == layout_visible_classifier_get_diagramelement_id( probe_vis_classfy ) ) |
| 494 |
{ |
| 495 |
/* this is a feature of the current layouted_classifier */ |
| 496 |
const data_feature_t *const f_probe_data = layout_feature_get_data_const( f_probe_layout ); |
| 497 |
assert ( NULL != f_probe_data ); |
| 498 |
const data_feature_type_t f_probe_type = data_feature_get_main_type( f_probe_data ); |
| 499 |
const double f_probe_bottom |
| 500 |
= geometry_rectangle_get_bottom( layout_feature_get_symbol_box_const( f_probe_layout ) ); |
| 501 |
if ( data_feature_type_inside_compartment( f_probe_type ) ) |
| 502 |
{ |
| 503 |
count_compartment_entries ++; |
| 504 |
} |
| 505 |
if ( DATA_FEATURE_TYPE_PROPERTY == f_probe_type ) |
| 506 |
{ |
| 507 |
compartment2_y = u8_f64_max2( compartment2_y, f_probe_bottom + gap ); |
| 508 |
compartment3_y = u8_f64_max2( compartment3_y, f_probe_bottom + 3.0 * gap ); |
| 509 |
} |
| 510 |
else if ( DATA_FEATURE_TYPE_OPERATION == f_probe_type ) |
| 511 |
{ |
| 512 |
compartment3_y = u8_f64_max2( compartment3_y, f_probe_bottom + gap ); |
| 513 |
} |
| 514 |
} |
| 515 |
} |
| 516 |
|
| 517 |
/* draw compartments if there are features */ |
| 518 |
if ( count_compartment_entries != 0 ) |
| 519 |
{ |
| 520 |
const data_visible_classifier_t *const visible_classifier |
| 521 |
= layout_visible_classifier_get_data_const( layouted_classifier ); |
| 522 |
const data_classifier_t *const classifier |
| 523 |
= data_visible_classifier_get_classifier_const( visible_classifier ); |
| 524 |
const data_classifier_type_t classifier_type = data_classifier_get_main_type( classifier ); |
| 525 |
|
| 526 |
draw_classifier_contour_draw_compartment_line ( &((*this_).draw_classifier_contour), |
| 527 |
classifier_type, |
| 528 |
classifier_symbol_box, |
| 529 |
compartment1_y, |
| 530 |
pencil_size, |
| 531 |
cr |
| 532 |
); |
| 533 |
draw_classifier_contour_draw_compartment_line ( &((*this_).draw_classifier_contour), |
| 534 |
classifier_type, |
| 535 |
classifier_symbol_box, |
| 536 |
compartment2_y, |
| 537 |
pencil_size, |
| 538 |
cr |
| 539 |
); |
| 540 |
draw_classifier_contour_draw_compartment_line ( &((*this_).draw_classifier_contour), |
| 541 |
classifier_type, |
| 542 |
classifier_symbol_box, |
| 543 |
compartment3_y, |
| 544 |
pencil_size, |
| 545 |
cr |
| 546 |
); |
| 547 |
} |
| 548 |
|
| 549 |
U8_TRACE_END(); |
| 550 |
} |
| 551 |
|
| 552 |
|
| 553 |
/* |
| 554 |
Copyright 2016-2026 Andreas Warnke |
| 555 |
http://www.apache.org/licenses/LICENSE-2.0 |
| 556 |
|
| 557 |
Licensed under the Apache License, Version 2.0 (the "License"); |
| 558 |
you may not use this file except in compliance with the License. |
| 559 |
You may obtain a copy of the License at |
| 560 |
|
| 561 |
|
| 562 |
Unless required by applicable law or agreed to in writing, software |
| 563 |
distributed under the License is distributed on an "AS IS" BASIS, |
| 564 |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 565 |
See the License for the specific language governing permissions and |
| 566 |
limitations under the License. |
| 567 |
*/ |