| 1 |
/* File: pencil_relationship_painter.c; Copyright and License: see below */ |
| 2 |
|
| 3 |
#include "pencil_relationship_painter.h" |
| 4 |
#include "layout/layout_visible_set.h" |
| 5 |
#include "u8/u8_trace.h" |
| 6 |
#include "utf8stringbuf/utf8string.h" |
| 7 |
#include <pango/pangocairo.h> |
| 8 |
#include <stdio.h> |
| 9 |
#include <stdlib.h> |
| 10 |
#include <assert.h> |
| 11 |
|
| 12 |
void pencil_relationship_painter_init( pencil_relationship_painter_t *this_ ) |
| 13 |
{ |
| 14 |
U8_TRACE_BEGIN(); |
| 15 |
|
| 16 |
pencil_marker_init( &((*this_).marker) ); |
| 17 |
draw_relationship_label_init( &((*this_).draw_relationship_label) ); |
| 18 |
|
| 19 |
U8_TRACE_END(); |
| 20 |
} |
| 21 |
|
| 22 |
void pencil_relationship_painter_destroy( pencil_relationship_painter_t *this_ ) |
| 23 |
{ |
| 24 |
U8_TRACE_BEGIN(); |
| 25 |
|
| 26 |
draw_relationship_label_destroy( &((*this_).draw_relationship_label) ); |
| 27 |
pencil_marker_destroy( &((*this_).marker) ); |
| 28 |
|
| 29 |
U8_TRACE_END(); |
| 30 |
} |
| 31 |
|
| 32 |
void pencil_relationship_painter_draw ( pencil_relationship_painter_t *this_, |
| 33 |
const layout_relationship_t *layouted_relationship, |
| 34 |
bool mark_focused, |
| 35 |
bool mark_highlighted, |
| 36 |
bool mark_selected, |
| 37 |
const data_profile_part_t *profile, |
| 38 |
const pencil_size_t *pencil_size, |
| 39 |
PangoLayout *layout, |
| 40 |
cairo_t *cr ) |
| 41 |
{ |
| 42 |
U8_TRACE_BEGIN(); |
| 43 |
assert( NULL != layouted_relationship ); |
| 44 |
assert( NULL != profile ); |
| 45 |
assert( NULL != pencil_size ); |
| 46 |
assert( NULL != layout ); |
| 47 |
assert( NULL != cr ); |
| 48 |
|
| 49 |
const data_relationship_t *const the_relationship |
| 50 |
= layout_relationship_get_data_const( layouted_relationship ); |
| 51 |
const geometry_connector_t *const connector_shape |
| 52 |
= layout_relationship_get_shape_const( layouted_relationship ); |
| 53 |
|
| 54 |
if ( data_relationship_is_valid( the_relationship ) ) |
| 55 |
{ |
| 56 |
U8_TRACE_INFO_INT("drawing relationship id", data_relationship_get_row_id( the_relationship ) ); |
| 57 |
|
| 58 |
/* set the right line width */ |
| 59 |
const double std_line_width = pencil_size_get_standard_line_width( pencil_size ); |
| 60 |
cairo_set_line_width( cr, std_line_width ); |
| 61 |
|
| 62 |
/* set the right drawing color */ |
| 63 |
GdkRGBA foreground_color; |
| 64 |
{ |
| 65 |
if ( mark_highlighted ) |
| 66 |
{ |
| 67 |
foreground_color = pencil_size_get_highlight_color( pencil_size ); |
| 68 |
} |
| 69 |
else if (( PENCIL_VISIBILITY_GRAY_OUT == layout_relationship_get_visibility( layouted_relationship ) ) |
| 70 |
|| ( PENCIL_VISIBILITY_IMPLICIT == layout_relationship_get_visibility( layouted_relationship ) )) |
| 71 |
{ |
| 72 |
foreground_color = pencil_size_get_gray_out_color( pencil_size ); |
| 73 |
} |
| 74 |
else |
| 75 |
{ |
| 76 |
foreground_color = pencil_size_get_standard_color( pencil_size ); |
| 77 |
} |
| 78 |
|
| 79 |
cairo_set_source_rgba( cr, foreground_color.red, foreground_color.green, foreground_color.blue, foreground_color.alpha ); |
| 80 |
} |
| 81 |
|
| 82 |
/* get points */ |
| 83 |
double p1x = geometry_connector_get_source_end_x ( connector_shape ); |
| 84 |
double p1y = geometry_connector_get_source_end_y ( connector_shape ); |
| 85 |
double p2x = geometry_connector_get_main_line_source_x ( connector_shape ); |
| 86 |
double p2y = geometry_connector_get_main_line_source_y ( connector_shape ); |
| 87 |
double p3x = geometry_connector_get_main_line_destination_x ( connector_shape ); |
| 88 |
double p3y = geometry_connector_get_main_line_destination_y ( connector_shape ); |
| 89 |
double p4x = geometry_connector_get_destination_end_x ( connector_shape ); |
| 90 |
double p4y = geometry_connector_get_destination_end_y ( connector_shape ); |
| 91 |
double center_x = (p2x+p3x)/2.0; |
| 92 |
double center_y = (p2y+p3y)/2.0; |
| 93 |
|
| 94 |
/* determine arrow direction */ |
| 95 |
int arrow_clock_direction; /* wall-clock direction assuming ascending y direction to top */ |
| 96 |
if ( fabs( p3x-p4x ) > 0.5 ) |
| 97 |
{ |
| 98 |
arrow_clock_direction = ( p3x < p4x ) ? 3 : 9; |
| 99 |
} |
| 100 |
else |
| 101 |
{ |
| 102 |
if ( fabs( p3y-p4y ) > 0.5 ) |
| 103 |
{ |
| 104 |
arrow_clock_direction = ( p3y < p4y ) ? 0 : 6; |
| 105 |
} |
| 106 |
else |
| 107 |
{ |
| 108 |
/* maybe the first segment is too short, take into account two segments */ |
| 109 |
if ( fabs( p2x-p4x ) > 0.5 ) |
| 110 |
{ |
| 111 |
arrow_clock_direction = ( p2x < p4x ) ? 3 : 9; |
| 112 |
} |
| 113 |
else |
| 114 |
{ |
| 115 |
if ( fabs( p2y-p4y ) > 0.5 ) |
| 116 |
{ |
| 117 |
arrow_clock_direction = ( p2y < p4y ) ? 0 : 6; |
| 118 |
} |
| 119 |
else |
| 120 |
{ |
| 121 |
/* maybe the first two segments are too short, take into account all segments */ |
| 122 |
if ( fabs( p1x-p4x ) > 0.5 ) |
| 123 |
{ |
| 124 |
arrow_clock_direction = ( p1x < p4x ) ? 3 : 9; |
| 125 |
} |
| 126 |
else |
| 127 |
{ |
| 128 |
if ( fabs( p1y-p4y ) > 0.5 ) |
| 129 |
{ |
| 130 |
arrow_clock_direction = ( p1y < p4y ) ? 0 : 6; |
| 131 |
} |
| 132 |
else |
| 133 |
{ |
| 134 |
/* connector has no length */ |
| 135 |
arrow_clock_direction = 0; |
| 136 |
} |
| 137 |
} |
| 138 |
} |
| 139 |
} |
| 140 |
} |
| 141 |
} |
| 142 |
|
| 143 |
/* determine feathers direction */ |
| 144 |
int feathers_clock_direction; /* wall-clock direction assuming ascending y direction to top */ |
| 145 |
if ( fabs( p2x-p1x ) > 0.5 ) |
| 146 |
{ |
| 147 |
feathers_clock_direction = ( p2x < p1x ) ? 9 : 3; |
| 148 |
} |
| 149 |
else |
| 150 |
{ |
| 151 |
if ( fabs( p2y-p1y ) > 0.5 ) |
| 152 |
{ |
| 153 |
feathers_clock_direction = ( p2y < p1y ) ? 0 : 6; |
| 154 |
} |
| 155 |
else |
| 156 |
{ |
| 157 |
/* maybe the first segment is too short, take into account two segments */ |
| 158 |
if ( fabs( p3x-p1x ) > 0.5 ) |
| 159 |
{ |
| 160 |
feathers_clock_direction = ( p3x < p1x ) ? 9 : 3; |
| 161 |
} |
| 162 |
else |
| 163 |
{ |
| 164 |
if ( fabs( p3y-p1y ) > 0.5 ) |
| 165 |
{ |
| 166 |
feathers_clock_direction = ( p3y < p1y ) ? 0 : 6; |
| 167 |
} |
| 168 |
else |
| 169 |
{ |
| 170 |
/* maybe the first two segments are too short, take into account all segments */ |
| 171 |
if ( fabs( p4x-p1x ) > 0.5 ) |
| 172 |
{ |
| 173 |
feathers_clock_direction = ( p4x < p1x ) ? 9 : 3; |
| 174 |
} |
| 175 |
else |
| 176 |
{ |
| 177 |
if ( fabs( p4y-p1y ) > 0.5 ) |
| 178 |
{ |
| 179 |
feathers_clock_direction = ( p4y < p1y ) ? 0 : 6; |
| 180 |
} |
| 181 |
else |
| 182 |
{ |
| 183 |
/* connector has no length */ |
| 184 |
feathers_clock_direction = 0; |
| 185 |
} |
| 186 |
} |
| 187 |
} |
| 188 |
} |
| 189 |
} |
| 190 |
} |
| 191 |
|
| 192 |
/* draw arrow */ |
| 193 |
switch ( data_relationship_get_main_type( the_relationship ) ) |
| 194 |
{ |
| 195 |
case DATA_RELATIONSHIP_TYPE_UML_ASSOCIATION: |
| 196 |
case DATA_RELATIONSHIP_TYPE_UML_GENERALIZATION: |
| 197 |
case DATA_RELATIONSHIP_TYPE_UML_ASYNC_CALL: |
| 198 |
case DATA_RELATIONSHIP_TYPE_UML_SYNC_CALL: |
| 199 |
case DATA_RELATIONSHIP_TYPE_UML_CONTROL_FLOW: |
| 200 |
case DATA_RELATIONSHIP_TYPE_UML_OBJECT_FLOW: |
| 201 |
case DATA_RELATIONSHIP_TYPE_UML_EXTEND: /* t.b.d. */ |
| 202 |
case DATA_RELATIONSHIP_TYPE_UML_INCLUDE: /* t.b.d. */ |
| 203 |
case DATA_RELATIONSHIP_TYPE_UML_DEPLOY: |
| 204 |
case DATA_RELATIONSHIP_TYPE_UML_MANIFEST: /* t.b.d. */ |
| 205 |
case DATA_RELATIONSHIP_TYPE_UML_REALIZATION: |
| 206 |
case DATA_RELATIONSHIP_TYPE_UML_DEPENDENCY: |
| 207 |
case DATA_RELATIONSHIP_TYPE_UML_RETURN_CALL: |
| 208 |
case DATA_RELATIONSHIP_TYPE_UML_REFINE: |
| 209 |
case DATA_RELATIONSHIP_TYPE_UML_TRACE: |
| 210 |
{ |
| 211 |
const double half_stroke_length = 0.5 * pencil_size_get_arrow_stroke_length( pencil_size ); |
| 212 |
const double part_stroke_length = pencil_size_get_arrow_stroke_087_length( pencil_size ); |
| 213 |
bool close_path; |
| 214 |
if (( data_relationship_get_main_type( the_relationship ) == DATA_RELATIONSHIP_TYPE_UML_GENERALIZATION ) |
| 215 |
|| ( data_relationship_get_main_type( the_relationship ) == DATA_RELATIONSHIP_TYPE_UML_REALIZATION )) |
| 216 |
{ |
| 217 |
close_path = true; |
| 218 |
} |
| 219 |
else |
| 220 |
{ |
| 221 |
close_path = false; |
| 222 |
} |
| 223 |
switch ( arrow_clock_direction ) |
| 224 |
{ |
| 225 |
case 0: /* direction: 12 o clock */ |
| 226 |
{ |
| 227 |
cairo_move_to ( cr, p4x - half_stroke_length, p4y - part_stroke_length ); |
| 228 |
cairo_line_to ( cr, p4x, p4y ); |
| 229 |
cairo_line_to ( cr, p4x + half_stroke_length, p4y - part_stroke_length ); |
| 230 |
if ( close_path ) |
| 231 |
{ |
| 232 |
cairo_line_to ( cr, p4x - half_stroke_length, p4y - part_stroke_length ); |
| 233 |
p4y = p4y - part_stroke_length; |
| 234 |
/* if p3 == p4, also move p3 */ |
| 235 |
if ( p3y > p4y ) |
| 236 |
{ |
| 237 |
p3y = p4y; |
| 238 |
} |
| 239 |
} |
| 240 |
} |
| 241 |
break; |
| 242 |
|
| 243 |
case 3: |
| 244 |
{ |
| 245 |
cairo_move_to ( cr, p4x - part_stroke_length, p4y - half_stroke_length ); |
| 246 |
cairo_line_to ( cr, p4x, p4y ); |
| 247 |
cairo_line_to ( cr, p4x - part_stroke_length, p4y + half_stroke_length ); |
| 248 |
if ( close_path ) |
| 249 |
{ |
| 250 |
cairo_line_to ( cr, p4x - part_stroke_length, p4y - half_stroke_length ); |
| 251 |
p4x = p4x - part_stroke_length; |
| 252 |
/* if p3 == p4, also move p3 */ |
| 253 |
if ( p3x > p4x ) |
| 254 |
{ |
| 255 |
p3x = p4x; |
| 256 |
} |
| 257 |
} |
| 258 |
} |
| 259 |
break; |
| 260 |
|
| 261 |
case 6: |
| 262 |
{ |
| 263 |
cairo_move_to ( cr, p4x + half_stroke_length, p4y + part_stroke_length ); |
| 264 |
cairo_line_to ( cr, p4x, p4y ); |
| 265 |
cairo_line_to ( cr, p4x - half_stroke_length, p4y + part_stroke_length ); |
| 266 |
if ( close_path ) |
| 267 |
{ |
| 268 |
cairo_line_to ( cr, p4x + half_stroke_length, p4y + part_stroke_length ); |
| 269 |
p4y = p4y + part_stroke_length; |
| 270 |
/* if p3 == p4, also move p3 */ |
| 271 |
if ( p3y < p4y ) |
| 272 |
{ |
| 273 |
p3y = p4y; |
| 274 |
} |
| 275 |
} |
| 276 |
} |
| 277 |
break; |
| 278 |
|
| 279 |
case 9: |
| 280 |
{ |
| 281 |
cairo_move_to ( cr, p4x + part_stroke_length, p4y + half_stroke_length ); |
| 282 |
cairo_line_to ( cr, p4x, p4y ); |
| 283 |
cairo_line_to ( cr, p4x + part_stroke_length, p4y - half_stroke_length ); |
| 284 |
if ( close_path ) |
| 285 |
{ |
| 286 |
cairo_line_to ( cr, p4x + part_stroke_length, p4y + half_stroke_length ); |
| 287 |
p4x = p4x + part_stroke_length; |
| 288 |
/* if p3 == p4, also move p3 */ |
| 289 |
if ( p3x < p4x ) |
| 290 |
{ |
| 291 |
p3x = p4x; |
| 292 |
} |
| 293 |
} |
| 294 |
} |
| 295 |
break; |
| 296 |
|
| 297 |
default: |
| 298 |
{ |
| 299 |
U8_LOG_ERROR("illegal case"); |
| 300 |
} |
| 301 |
break; |
| 302 |
} |
| 303 |
if (( data_relationship_get_main_type( the_relationship ) == DATA_RELATIONSHIP_TYPE_UML_SYNC_CALL ) |
| 304 |
|| ( data_relationship_get_main_type( the_relationship ) == DATA_RELATIONSHIP_TYPE_UML_RETURN_CALL )) |
| 305 |
{ |
| 306 |
cairo_fill (cr); |
| 307 |
} |
| 308 |
else |
| 309 |
{ |
| 310 |
cairo_stroke (cr); |
| 311 |
} |
| 312 |
} |
| 313 |
break; |
| 314 |
|
| 315 |
case DATA_RELATIONSHIP_TYPE_UML_AGGREGATION: |
| 316 |
case DATA_RELATIONSHIP_TYPE_UML_COMPOSITION: |
| 317 |
case DATA_RELATIONSHIP_TYPE_UML_CONTAINMENT: |
| 318 |
case DATA_RELATIONSHIP_TYPE_UML_COMMUNICATION_PATH: |
| 319 |
{ |
| 320 |
/* no arrow tip */ |
| 321 |
} |
| 322 |
break; |
| 323 |
|
| 324 |
default: |
| 325 |
{ |
| 326 |
U8_LOG_ANOMALY("unknown data_relationship_type_t in pencil_relationship_painter_draw()"); |
| 327 |
/* this may happen if a new database file has been read by an old program version */ |
| 328 |
/* no arrow tip */ |
| 329 |
} |
| 330 |
break; |
| 331 |
} |
| 332 |
|
| 333 |
/* draw feathers */ |
| 334 |
switch ( data_relationship_get_main_type( the_relationship ) ) |
| 335 |
{ |
| 336 |
case DATA_RELATIONSHIP_TYPE_UML_AGGREGATION: |
| 337 |
case DATA_RELATIONSHIP_TYPE_UML_COMPOSITION: |
| 338 |
{ |
| 339 |
/* rhomboid */ |
| 340 |
const double half_stroke_length = 0.5 * pencil_size_get_arrow_stroke_length( pencil_size ); |
| 341 |
const double part_stroke_length = pencil_size_get_arrow_stroke_087_length( pencil_size ); |
| 342 |
switch ( feathers_clock_direction ) |
| 343 |
{ |
| 344 |
case 0: /* direction: 12 o clock */ |
| 345 |
{ |
| 346 |
cairo_move_to ( cr, p1x, p1y ); |
| 347 |
cairo_line_to ( cr, p1x - half_stroke_length, p1y - part_stroke_length ); |
| 348 |
cairo_line_to ( cr, p1x, p1y - 2.0 * part_stroke_length ); |
| 349 |
cairo_line_to ( cr, p1x + half_stroke_length, p1y - part_stroke_length ); |
| 350 |
cairo_line_to ( cr, p1x, p1y ); |
| 351 |
p1y = p1y - 2.0 * part_stroke_length; |
| 352 |
/* if p2 == p1, also move p2 */ |
| 353 |
if ( p2y > p1y ) |
| 354 |
{ |
| 355 |
p2y = p1y; |
| 356 |
} |
| 357 |
} |
| 358 |
break; |
| 359 |
|
| 360 |
case 3: |
| 361 |
{ |
| 362 |
cairo_move_to ( cr, p1x, p1y ); |
| 363 |
cairo_line_to ( cr, p1x + part_stroke_length, p1y - half_stroke_length ); |
| 364 |
cairo_line_to ( cr, p1x + 2.0 * part_stroke_length, p1y ); |
| 365 |
cairo_line_to ( cr, p1x + part_stroke_length, p1y + half_stroke_length ); |
| 366 |
cairo_line_to ( cr, p1x, p1y ); |
| 367 |
p1x = p1x + 2.0 * part_stroke_length; |
| 368 |
/* if p2 == p1, also move p2 */ |
| 369 |
if ( p2x < p1x ) |
| 370 |
{ |
| 371 |
p2x = p1x; |
| 372 |
} |
| 373 |
} |
| 374 |
break; |
| 375 |
|
| 376 |
case 6: |
| 377 |
{ |
| 378 |
cairo_move_to ( cr, p1x, p1y ); |
| 379 |
cairo_line_to ( cr, p1x + half_stroke_length, p1y + part_stroke_length ); |
| 380 |
cairo_line_to ( cr, p1x, p1y + 2.0 * part_stroke_length ); |
| 381 |
cairo_line_to ( cr, p1x - half_stroke_length, p1y + part_stroke_length ); |
| 382 |
cairo_line_to ( cr, p1x, p1y ); |
| 383 |
p1y = p1y + 2.0 * part_stroke_length; |
| 384 |
/* if p2 == p1, also move p2 */ |
| 385 |
if ( p2y < p1y ) |
| 386 |
{ |
| 387 |
p2y = p1y; |
| 388 |
} |
| 389 |
} |
| 390 |
break; |
| 391 |
|
| 392 |
case 9: |
| 393 |
{ |
| 394 |
cairo_move_to ( cr, p1x, p1y ); |
| 395 |
cairo_line_to ( cr, p1x - part_stroke_length, p1y + half_stroke_length ); |
| 396 |
cairo_line_to ( cr, p1x - 2.0 * part_stroke_length, p1y ); |
| 397 |
cairo_line_to ( cr, p1x - part_stroke_length, p1y - half_stroke_length ); |
| 398 |
cairo_line_to ( cr, p1x, p1y ); |
| 399 |
p1x = p1x - 2.0 * part_stroke_length; |
| 400 |
/* if p2 == p1, also move p2 */ |
| 401 |
if ( p2x > p1x ) |
| 402 |
{ |
| 403 |
p2x = p1x; |
| 404 |
} |
| 405 |
} |
| 406 |
break; |
| 407 |
|
| 408 |
default: |
| 409 |
{ |
| 410 |
U8_LOG_ERROR("illegal case"); |
| 411 |
} |
| 412 |
break; |
| 413 |
} |
| 414 |
if ( data_relationship_get_main_type( the_relationship ) == DATA_RELATIONSHIP_TYPE_UML_COMPOSITION ) |
| 415 |
{ |
| 416 |
cairo_fill (cr); |
| 417 |
} |
| 418 |
else |
| 419 |
{ |
| 420 |
cairo_stroke (cr); |
| 421 |
} |
| 422 |
} |
| 423 |
break; |
| 424 |
|
| 425 |
case DATA_RELATIONSHIP_TYPE_UML_CONTAINMENT: |
| 426 |
{ |
| 427 |
/* circle with plus */ |
| 428 |
/* const double stroke_length = pencil_size_get_arrow_stroke_length( pencil_size ); */ |
| 429 |
const double half_stroke_length = 0.5 * pencil_size_get_arrow_stroke_length( pencil_size ); |
| 430 |
switch ( feathers_clock_direction ) |
| 431 |
{ |
| 432 |
case 0: /* direction: 12 o clock */ |
| 433 |
{ |
| 434 |
cairo_new_sub_path (cr); /* to be called before arc */ |
| 435 |
cairo_arc ( cr, p1x, p1y - half_stroke_length, half_stroke_length, 0.0, 2.0*M_PI ); |
| 436 |
cairo_move_to ( cr, p1x - half_stroke_length, p1y - half_stroke_length ); |
| 437 |
cairo_line_to ( cr, p1x + half_stroke_length, p1y - half_stroke_length ); |
| 438 |
cairo_stroke (cr); |
| 439 |
} |
| 440 |
break; |
| 441 |
|
| 442 |
case 3: |
| 443 |
{ |
| 444 |
cairo_new_sub_path (cr); |
| 445 |
cairo_arc ( cr, p1x + half_stroke_length, p1y, half_stroke_length, 0.0, 2.0*M_PI ); |
| 446 |
cairo_move_to ( cr, p1x + half_stroke_length, p1y - half_stroke_length ); |
| 447 |
cairo_line_to ( cr, p1x + half_stroke_length, p1y + half_stroke_length ); |
| 448 |
cairo_stroke (cr); |
| 449 |
} |
| 450 |
break; |
| 451 |
|
| 452 |
case 6: |
| 453 |
{ |
| 454 |
cairo_new_sub_path (cr); |
| 455 |
cairo_arc ( cr, p1x, p1y + half_stroke_length, half_stroke_length, 0.0, 2.0*M_PI ); |
| 456 |
cairo_move_to ( cr, p1x - half_stroke_length, p1y + half_stroke_length ); |
| 457 |
cairo_line_to ( cr, p1x + half_stroke_length, p1y + half_stroke_length ); |
| 458 |
cairo_stroke (cr); |
| 459 |
} |
| 460 |
break; |
| 461 |
|
| 462 |
case 9: |
| 463 |
{ |
| 464 |
cairo_new_sub_path (cr); |
| 465 |
cairo_arc ( cr, p1x - half_stroke_length, p1y, half_stroke_length, 0.0, 2.0*M_PI ); |
| 466 |
cairo_move_to ( cr, p1x - half_stroke_length, p1y - half_stroke_length ); |
| 467 |
cairo_line_to ( cr, p1x - half_stroke_length, p1y + half_stroke_length ); |
| 468 |
cairo_stroke (cr); |
| 469 |
} |
| 470 |
break; |
| 471 |
|
| 472 |
default: |
| 473 |
{ |
| 474 |
U8_LOG_ERROR("illegal case"); |
| 475 |
} |
| 476 |
break; |
| 477 |
} |
| 478 |
} |
| 479 |
break; |
| 480 |
|
| 481 |
case DATA_RELATIONSHIP_TYPE_UML_ASSOCIATION: |
| 482 |
case DATA_RELATIONSHIP_TYPE_UML_GENERALIZATION: |
| 483 |
case DATA_RELATIONSHIP_TYPE_UML_ASYNC_CALL: |
| 484 |
case DATA_RELATIONSHIP_TYPE_UML_SYNC_CALL: |
| 485 |
case DATA_RELATIONSHIP_TYPE_UML_COMMUNICATION_PATH: |
| 486 |
case DATA_RELATIONSHIP_TYPE_UML_CONTROL_FLOW: |
| 487 |
case DATA_RELATIONSHIP_TYPE_UML_OBJECT_FLOW: |
| 488 |
case DATA_RELATIONSHIP_TYPE_UML_EXTEND: /* t.b.d. */ |
| 489 |
case DATA_RELATIONSHIP_TYPE_UML_INCLUDE: /* t.b.d. */ |
| 490 |
case DATA_RELATIONSHIP_TYPE_UML_DEPLOY: |
| 491 |
case DATA_RELATIONSHIP_TYPE_UML_MANIFEST: /* t.b.d. */ |
| 492 |
case DATA_RELATIONSHIP_TYPE_UML_REALIZATION: |
| 493 |
case DATA_RELATIONSHIP_TYPE_UML_DEPENDENCY: |
| 494 |
case DATA_RELATIONSHIP_TYPE_UML_RETURN_CALL: |
| 495 |
case DATA_RELATIONSHIP_TYPE_UML_REFINE: |
| 496 |
case DATA_RELATIONSHIP_TYPE_UML_TRACE: |
| 497 |
{ |
| 498 |
/* no rhomboid or other feathers */ |
| 499 |
} |
| 500 |
break; |
| 501 |
|
| 502 |
default: |
| 503 |
{ |
| 504 |
U8_LOG_ANOMALY("unknown data_relationship_type_t in pencil_relationship_painter_draw()"); |
| 505 |
/* this may happen if a new database file has been read by an old program version */ |
| 506 |
/* no rhomboid or other feathers */ |
| 507 |
} |
| 508 |
break; |
| 509 |
} |
| 510 |
|
| 511 |
/* set the right line type: dashed/normal */ |
| 512 |
switch ( data_relationship_get_main_type( the_relationship ) ) |
| 513 |
{ |
| 514 |
case DATA_RELATIONSHIP_TYPE_UML_ASSOCIATION: |
| 515 |
case DATA_RELATIONSHIP_TYPE_UML_AGGREGATION: |
| 516 |
case DATA_RELATIONSHIP_TYPE_UML_COMPOSITION: |
| 517 |
case DATA_RELATIONSHIP_TYPE_UML_GENERALIZATION: |
| 518 |
case DATA_RELATIONSHIP_TYPE_UML_ASYNC_CALL: |
| 519 |
case DATA_RELATIONSHIP_TYPE_UML_SYNC_CALL: |
| 520 |
case DATA_RELATIONSHIP_TYPE_UML_COMMUNICATION_PATH: |
| 521 |
case DATA_RELATIONSHIP_TYPE_UML_CONTROL_FLOW: |
| 522 |
case DATA_RELATIONSHIP_TYPE_UML_OBJECT_FLOW: |
| 523 |
case DATA_RELATIONSHIP_TYPE_UML_CONTAINMENT: |
| 524 |
{ |
| 525 |
/* no dashes */ |
| 526 |
cairo_set_dash ( cr, NULL, 0, 0.0 ); |
| 527 |
} |
| 528 |
break; |
| 529 |
|
| 530 |
case DATA_RELATIONSHIP_TYPE_UML_EXTEND: /* t.b.d. */ |
| 531 |
case DATA_RELATIONSHIP_TYPE_UML_INCLUDE: /* t.b.d. */ |
| 532 |
case DATA_RELATIONSHIP_TYPE_UML_DEPLOY: |
| 533 |
case DATA_RELATIONSHIP_TYPE_UML_MANIFEST: /* t.b.d. */ |
| 534 |
case DATA_RELATIONSHIP_TYPE_UML_REALIZATION: |
| 535 |
case DATA_RELATIONSHIP_TYPE_UML_DEPENDENCY: |
| 536 |
case DATA_RELATIONSHIP_TYPE_UML_RETURN_CALL: |
| 537 |
case DATA_RELATIONSHIP_TYPE_UML_REFINE: |
| 538 |
case DATA_RELATIONSHIP_TYPE_UML_TRACE: |
| 539 |
{ |
| 540 |
double dashes[1]; |
| 541 |
dashes[0] = pencil_size_get_line_dash_length( pencil_size ); |
| 542 |
cairo_set_dash ( cr, dashes, 1, 0.0 ); |
| 543 |
} |
| 544 |
break; |
| 545 |
|
| 546 |
default: |
| 547 |
{ |
| 548 |
U8_LOG_ANOMALY("unknown data_relationship_type_t in pencil_relationship_painter_draw()"); |
| 549 |
/* this may happen if a new database file has been read by an old program version */ |
| 550 |
double error_dashes[1]; |
| 551 |
error_dashes[0] = 0.2*pencil_size_get_line_dash_length( pencil_size ); |
| 552 |
cairo_set_dash ( cr, error_dashes, 1, 0.0 ); |
| 553 |
} |
| 554 |
break; |
| 555 |
} |
| 556 |
|
| 557 |
/* draw connector line */ |
| 558 |
{ |
| 559 |
const double radius = 2.0 * pencil_size_get_arrow_stroke_length( pencil_size ); |
| 560 |
double dx; |
| 561 |
double dy; |
| 562 |
cairo_move_to ( cr, p1x, p1y ); |
| 563 |
dx = p2x - p1x; |
| 564 |
dy = p2y - p1y; |
| 565 |
if ( dx > +radius ) { dx = +radius; } |
| 566 |
if ( dx < -radius ) { dx = -radius; } |
| 567 |
if ( dy > +radius ) { dy = +radius; } |
| 568 |
if ( dy < -radius ) { dy = -radius; } |
| 569 |
cairo_line_to ( cr, p2x - dx, p2y - dy ); |
| 570 |
dx = center_x - p2x; |
| 571 |
dy = center_y - p2y; |
| 572 |
if ( dx > +radius ) { dx = +radius; } |
| 573 |
if ( dx < -radius ) { dx = -radius; } |
| 574 |
if ( dy > +radius ) { dy = +radius; } |
| 575 |
if ( dy < -radius ) { dy = -radius; } |
| 576 |
cairo_curve_to ( cr, p2x, p2y, p2x, p2y, p2x + dx, p2y + dy ); |
| 577 |
dx = p3x - center_x; |
| 578 |
dy = p3y - center_y; |
| 579 |
if ( dx > +radius ) { dx = +radius; } |
| 580 |
if ( dx < -radius ) { dx = -radius; } |
| 581 |
if ( dy > +radius ) { dy = +radius; } |
| 582 |
if ( dy < -radius ) { dy = -radius; } |
| 583 |
cairo_line_to ( cr, p3x - dx, p3y - dy ); |
| 584 |
dx = p4x - p3x; |
| 585 |
dy = p4y - p3y; |
| 586 |
if ( dx > +radius ) { dx = +radius; } |
| 587 |
if ( dx < -radius ) { dx = -radius; } |
| 588 |
if ( dy > +radius ) { dy = +radius; } |
| 589 |
if ( dy < -radius ) { dy = -radius; } |
| 590 |
cairo_curve_to ( cr, p3x, p3y, p3x, p3y, p3x + dx, p3y + dy ); |
| 591 |
cairo_line_to ( cr, p4x, p4y ); |
| 592 |
cairo_stroke (cr); |
| 593 |
} |
| 594 |
|
| 595 |
/* reset dashes */ |
| 596 |
cairo_set_dash ( cr, NULL, 0, 0.0 ); |
| 597 |
|
| 598 |
/* draw the label */ |
| 599 |
draw_relationship_label_draw_type_and_name ( &((*this_).draw_relationship_label), |
| 600 |
the_relationship, |
| 601 |
profile, |
| 602 |
&foreground_color, |
| 603 |
layout_relationship_get_label_box_const( layouted_relationship ), |
| 604 |
pencil_size, |
| 605 |
layout, |
| 606 |
cr |
| 607 |
); |
| 608 |
|
| 609 |
/* draw markers */ |
| 610 |
if ( mark_selected ) |
| 611 |
{ |
| 612 |
const geometry_rectangle_t bounds |
| 613 |
= geometry_connector_get_bounding_rectangle( connector_shape ); |
| 614 |
pencil_marker_mark_selected_rectangle( &((*this_).marker), bounds, cr ); |
| 615 |
} |
| 616 |
|
| 617 |
if ( mark_focused ) |
| 618 |
{ |
| 619 |
const geometry_rectangle_t bounds |
| 620 |
= geometry_connector_get_bounding_rectangle( connector_shape ); |
| 621 |
pencil_marker_mark_focused_rectangle( &((*this_).marker), bounds, cr ); |
| 622 |
} |
| 623 |
} |
| 624 |
else |
| 625 |
{ |
| 626 |
U8_LOG_ERROR("invalid relationship in array!"); |
| 627 |
} |
| 628 |
|
| 629 |
U8_TRACE_END(); |
| 630 |
} |
| 631 |
|
| 632 |
|
| 633 |
/* |
| 634 |
Copyright 2017-2026 Andreas Warnke |
| 635 |
|
| 636 |
Licensed under the Apache License, Version 2.0 (the "License"); |
| 637 |
you may not use this file except in compliance with the License. |
| 638 |
You may obtain a copy of the License at |
| 639 |
|
| 640 |
http://www.apache.org/licenses/LICENSE-2.0 |
| 641 |
|
| 642 |
Unless required by applicable law or agreed to in writing, software |
| 643 |
distributed under the License is distributed on an "AS IS" BASIS, |
| 644 |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 645 |
See the License for the specific language governing permissions and |
| 646 |
limitations under the License. |
| 647 |
*/ |