| Date: | 2010-07-02 22:35:39 (2 months 5 days ago) |
|---|---|
| Author: | Nicola Fontana |
| Commit: | a09920ae91aff0fcd43217b82ea87cab8c31693f |
| Message: | [AdgRDim] Avoid the rendering of incomplete entities Checking the availability of all the needed data to define the entity and avoid the arrange() and render() phases on condition not fulfilled. |
| Files: |
src/adg/adg-rdim.c (6 diffs) |
Change Details
| src/adg/adg-rdim.c | ||
|---|---|---|
| 67 | 67 | static void _adg_render (AdgEntity *entity, |
| 68 | 68 | cairo_t *cr); |
| 69 | 69 | static gchar * _adg_default_value (AdgDim *dim); |
| 70 | static void _adg_update_geometry (AdgRDim *rdim); | |
| 70 | static gboolean _adg_update_geometry (AdgRDim *rdim); | |
| 71 | 71 | static void _adg_update_entities (AdgRDim *rdim); |
| 72 | 72 | static void _adg_clear_trail (AdgRDim *rdim); |
| 73 | 73 | static void _adg_dispose_marker (AdgRDim *rdim); |
| ... | ... | |
| 343 | 343 | data = rdim->data; |
| 344 | 344 | quote = adg_dim_get_quote(dim); |
| 345 | 345 | |
| 346 | _adg_update_geometry(rdim); | |
| 346 | if (!_adg_update_geometry(rdim)) | |
| 347 | return; | |
| 348 | ||
| 347 | 349 | _adg_update_entities(rdim); |
| 348 | 350 | |
| 349 | 351 | if (data->cpml.path.status == CAIRO_STATUS_SUCCESS) { |
| ... | ... | |
| 419 | 421 | const cairo_path_t *cairo_path; |
| 420 | 422 | |
| 421 | 423 | rdim = (AdgRDim *) entity; |
| 422 | dim = (AdgDim *) entity; | |
| 423 | 424 | data = rdim->data; |
| 425 | ||
| 426 | if (!data->geometry_arranged) { | |
| 427 | /* Entity not arranged, probably due to undefined pair found */ | |
| 428 | return; | |
| 429 | } | |
| 430 | ||
| 431 | dim = (AdgDim *) entity; | |
| 424 | 432 | dim_style = _ADG_GET_DIM_STYLE(dim); |
| 425 | 433 | |
| 426 | 434 | adg_style_apply((AdgStyle *) dim_style, entity, cr); |
| ... | ... | |
| 451 | 459 | dim_style = _ADG_GET_DIM_STYLE(dim); |
| 452 | 460 | format = adg_dim_style_get_number_format(dim_style); |
| 453 | 461 | |
| 454 | _adg_update_geometry(rdim); | |
| 462 | if (!_adg_update_geometry(rdim)) | |
| 463 | return g_strdup("undef"); | |
| 455 | 464 | |
| 456 | 465 | return g_strdup_printf(format, data->radius); |
| 457 | 466 | } |
| 458 | 467 | |
| 459 | static void | |
| 468 | static gboolean | |
| 460 | 469 | _adg_update_geometry(AdgRDim *rdim) |
| 461 | 470 | { |
| 462 | 471 | AdgRDimPrivate *data; |
| ... | ... | |
| 470 | 479 | data = rdim->data; |
| 471 | 480 | |
| 472 | 481 | if (data->geometry_arranged) |
| 473 | return; | |
| 482 | return TRUE; | |
| 474 | 483 | |
| 475 | 484 | dim = (AdgDim *) rdim; |
| 476 | dim_style = _ADG_GET_DIM_STYLE(rdim); | |
| 477 | 485 | ref1 = adg_point_get_pair(adg_dim_get_ref1(dim)); |
| 478 | 486 | ref2 = adg_point_get_pair(adg_dim_get_ref2(dim)); |
| 479 | 487 | pos = adg_point_get_pair(adg_dim_get_pos(dim)); |
| 488 | ||
| 489 | if (ref1 == NULL || ref2 == NULL || pos == NULL) | |
| 490 | return FALSE; | |
| 491 | ||
| 492 | dim_style = _ADG_GET_DIM_STYLE(rdim); | |
| 480 | 493 | spacing = adg_dim_style_get_baseline_spacing(dim_style); |
| 481 | 494 | level = adg_dim_get_level(dim); |
| 482 | 495 | pos_distance = cpml_pair_distance(pos, ref1); |
| 483 | 496 | vector.x = ref2->x - ref1->x; |
| 484 | 497 | vector.y = ref2->y - ref1->y; |
| 498 | ||
| 485 | 499 | if (cpml_pair_squared_distance(pos, ref1) < |
| 486 | 500 | cpml_pair_squared_distance(pos, ref2)) { |
| 487 | 501 | vector.x = -vector.x; |
| ... | ... | |
| 505 | 519 | cpml_vector_set_length(&data->shift.base, spacing * level); |
| 506 | 520 | |
| 507 | 521 | data->geometry_arranged = TRUE; |
| 522 | ||
| 523 | return TRUE; | |
| 508 | 524 | } |
| 509 | 525 | |
| 510 | 526 | static void |
| 511 | 527 | |
