Beispiel #1
0
int
main(int argc, char *argv[])
{
    AdgPath *path;

    adg_test_init(&argc, &argv);

    adg_test_add_object_checks("/adg/hatch/type/object", ADG_TYPE_HATCH);
    adg_test_add_entity_checks("/adg/hatch/type/entity", ADG_TYPE_HATCH);

    path = adg_path_new();
    adg_path_move_to_explicit(path, 1, 2);
    adg_path_line_to_explicit(path, 4, 5);
    adg_path_line_to_explicit(path, 7, 8);
    adg_path_close(path);
    adg_test_add_global_space_checks("/adg/hatch/behavior/global-space", adg_hatch_new(ADG_TRAIL(path)));
    adg_test_add_local_space_checks("/adg/hatch/behavior/local-space", adg_hatch_new(ADG_TRAIL(path)));
    g_object_unref(path);

    g_test_add_func("/adg/hatch/property/fill-dress", _adg_property_fill_dress);

    return g_test_run();
}
Beispiel #2
0
static void
_adg_behavior_named_pair(void)
{
    CpmlPair p1 = { 123, 456 };
    AdgPoint *explicit_point, *explicit_point2, *model_point;
    AdgModel *model;
    CpmlPair *pair;

    explicit_point = adg_point_new();
    g_assert_nonnull(explicit_point);
    adg_point_set_pair(explicit_point, &p1);

    explicit_point2 = adg_point_new();
    g_assert_nonnull(explicit_point2);
    adg_point_set_pair_explicit(explicit_point2, p1.x, p1.y);

    /* Checking comparison APIs */
    g_assert_true(adg_point_equal(explicit_point, explicit_point2));
    adg_point_set_pair_explicit(explicit_point2, 78, 90);
    g_assert_false(adg_point_equal(explicit_point, explicit_point2));
    pair = (CpmlPair *) explicit_point2;
    adg_assert_isapprox(pair->x, 78);
    adg_assert_isapprox(pair->y, 90);

    pair = adg_point_get_pair(explicit_point);
    g_assert_true(cpml_pair_equal(pair, &p1));
    g_free(pair);

    model = ADG_MODEL(adg_path_new());
    g_assert_nonnull(model);
    adg_model_set_named_pair(model, "named-pair", &p1);

    model_point = adg_point_new();
    g_assert_nonnull(model_point);
    adg_point_set_pair_from_model(model_point, model, "named-pair");

    pair = adg_point_get_pair(model_point);
    g_assert_true(cpml_pair_equal(pair, &p1));
    g_free(pair);

    /* Ensure ADG does not consider an explicit point equals to
     * a point bound to a named pair with the same coordinates */
    g_assert_false(adg_point_equal(explicit_point, model_point));

    /* Check for lazy evaluation of named pairs */
    adg_point_set_pair_from_model(model_point, model, "unexistent-pair");
    pair = (CpmlPair *) model_point;
    adg_assert_isapprox(pair->x, p1.x);
    adg_assert_isapprox(pair->y, p1.y);

    /* Check behavior on undefined named pair */
    g_assert_false(adg_point_update(model_point));
    g_assert_null(adg_point_get_pair(model_point));

    adg_point_set_pair_from_model(model_point, model, "named-pair");
    g_assert_true(adg_point_update(model_point));

    /* Check for case sensitiveness */
    adg_point_set_pair_from_model(model_point, model, "Named-Pair");
    g_assert_null(adg_point_get_pair(model_point));
    g_assert_false(adg_point_update(model_point));

    /* Check if adg_point_get_pair() triggers an adg_point_update() */
    adg_point_set_pair_from_model(model_point, model, "named-pair");
    pair = adg_point_get_pair(model_point);
    g_assert_true(cpml_pair_equal(pair, &p1));
    g_free(pair);

    adg_point_destroy(explicit_point);
    adg_point_destroy(model_point);
    g_object_unref(model);
}
Beispiel #3
0
static void
_adg_arrange_class(AdgLogoClass *logo_class)
{
    AdgLogoClassPrivate *data_class;
    CpmlExtents *extents;

    data_class = logo_class->data_class;
    extents = &data_class->extents;

    if (data_class->symbol == NULL) {
        AdgPath *path = adg_path_new();

        adg_path_move_to_explicit(path, 8, 26);
        adg_path_line_to_explicit(path, 24, 10);
        adg_path_arc_to_explicit(path, 32, 18, 24, 26);
        adg_path_line_to_explicit(path, 24, 11);

        adg_path_move_to_explicit(path, 40, 10);
        adg_path_arc_to_explicit(path, 32, 18, 40, 26);
        adg_path_line_to_explicit(path, 40, 22);
        adg_path_line_to_explicit(path, 38, 22);

        adg_path_move_to_explicit(path, 23, 22);
        adg_path_line_to_explicit(path, 16, 22);

        data_class->symbol = path;
        extents->is_defined = FALSE;
    }

    if (data_class->screen == NULL) {
        AdgPath *path = adg_path_new();

        adg_path_move_to_explicit(path, 3, 3);
        adg_path_line_to_explicit(path, 47, 3);
        adg_path_fillet(path, 10);
        adg_path_line_to_explicit(path, 47, 33);
        adg_path_fillet(path, 10);
        adg_path_line_to_explicit(path, 3, 33);
        adg_path_fillet(path, 10);
        adg_path_close(path);
        adg_path_fillet(path, 10);

        data_class->screen = path;
        extents->is_defined = FALSE;
    }

    if (data_class->frame == NULL) {
        AdgPath *path = adg_path_new();

        adg_path_move_to_explicit(path, 0, 0);
        adg_path_line_to_explicit(path, 50, 0);
        adg_path_line_to_explicit(path, 50, 36);
        adg_path_line_to_explicit(path, 0, 36);
        adg_path_close(path);

        data_class->frame = path;
        extents->is_defined = FALSE;
    }

    if (!data_class->extents.is_defined) {
        cpml_extents_add(extents,
                         adg_trail_get_extents((AdgTrail *) data_class->symbol));
        cpml_extents_add(extents,
                         adg_trail_get_extents((AdgTrail *) data_class->screen));
        cpml_extents_add(extents,
                         adg_trail_get_extents((AdgTrail *) data_class->frame));
    }
}
Beispiel #4
0
static void
_adg_arrange_class(AdgProjectionClass *projection_class,
                   AdgProjectionScheme scheme)
{
    AdgProjectionClassPrivate *data_class;
    AdgPath *symbol, *axis;

    data_class = projection_class->data_class;

    if (data_class->scheme == scheme)
        return;

    if (data_class->symbol != NULL)
        g_object_unref(data_class->symbol);

    if (data_class->axis != NULL)
        g_object_unref(data_class->axis);

    data_class->scheme = scheme;

    switch(scheme) {
    case ADG_PROJECTION_SCHEME_UNDEFINED:
        symbol = NULL;
        axis = NULL;
        break;
    case ADG_PROJECTION_SCHEME_FIRST_ANGLE:
        symbol = adg_path_new();
        adg_path_move_to_explicit(symbol, 4, 19);
        adg_path_line_to_explicit(symbol, 24, 24);
        adg_path_line_to_explicit(symbol, 24, 4);
        adg_path_line_to_explicit(symbol, 4, 9);
        adg_path_close(symbol);
        adg_path_move_to_explicit(symbol, 49, 14);
        adg_path_arc_to_explicit(symbol, 29, 14, 49, 14);
        adg_path_move_to_explicit(symbol, 44, 14);
        adg_path_arc_to_explicit(symbol, 34, 14, 44, 14);

        axis = adg_path_new();
        adg_path_move_to_explicit(axis, 0, 14);
        adg_path_line_to_explicit(axis, 53, 14);
        adg_path_move_to_explicit(axis, 39, 0);
        adg_path_line_to_explicit(axis, 39, 28);
        break;
    case ADG_PROJECTION_SCHEME_THIRD_ANGLE:
        symbol = adg_path_new();
        adg_path_move_to_explicit(symbol, 29, 19);
        adg_path_line_to_explicit(symbol, 49, 24);
        adg_path_line_to_explicit(symbol, 49, 4);
        adg_path_line_to_explicit(symbol, 29, 9);
        adg_path_close(symbol);
        adg_path_move_to_explicit(symbol, 24, 14);
        adg_path_arc_to_explicit(symbol, 4, 14, 24, 14);
        adg_path_move_to_explicit(symbol, 19, 14);
        adg_path_arc_to_explicit(symbol, 9, 14, 19, 14);

        axis = adg_path_new();
        adg_path_move_to_explicit(axis, 0, 14);
        adg_path_line_to_explicit(axis, 53, 14);
        adg_path_move_to_explicit(axis, 14, 0);
        adg_path_line_to_explicit(axis, 14, 28);
        break;
    default:
        g_return_if_reached();
        break;
    }

    data_class->symbol = symbol;
    data_class->axis = axis;
    data_class->extents.is_defined = FALSE;

    if (axis != NULL)
        cpml_extents_add(&data_class->extents,
                         adg_trail_get_extents((AdgTrail *) axis));

    if (symbol != NULL)
        cpml_extents_add(&data_class->extents,
                         adg_trail_get_extents((AdgTrail *) symbol));
}
Beispiel #5
0
static void
_adg_property_org1(void)
{
    AdgADim *adim;
    AdgModel *model;
    AdgPoint *origin, *explicit_point, *model_point;
    AdgPoint *org1;

    adim = adg_adim_new();
    model = ADG_MODEL(adg_path_new());
    origin = adg_point_new();
    explicit_point = adg_point_new();
    model_point = adg_point_new();

    adg_point_set_pair_explicit(origin, 0, 0);
    adg_point_set_pair_explicit(explicit_point, 123, 321);
    adg_model_set_named_pair(model, "named-pair", (CpmlPair *) explicit_point);
    adg_point_set_pair_from_model(model_point, model, "named-pair");

    /* Ensure ADG does not consider an explicit point equals to
     * a point bound to a named pair with the same coordinates */
    g_assert_false(adg_point_equal(explicit_point, model_point));

    org1 = adg_adim_get_org1(adim);
    g_assert_null(org1);

    /* Using the public APIs */
    adg_adim_set_org1_explicit(adim, 0, 0);
    org1 = adg_adim_get_org1(adim);
    g_assert_true(adg_point_equal(org1, origin));

    adg_adim_set_org1(adim, NULL);
    org1 = adg_adim_get_org1(adim);
    g_assert_null(org1);

    adg_adim_set_org1(adim, explicit_point);
    org1 = adg_adim_get_org1(adim);
    g_assert_true(adg_point_equal(org1, explicit_point));

    adg_adim_set_org1_from_model(adim, model, "dummy");
    org1 = adg_adim_get_org1(adim);
    g_assert_nonnull(org1);

    adg_adim_set_org1_from_model(adim, model, "named-pair");
    org1 = adg_adim_get_org1(adim);
    g_assert_true(adg_point_equal(org1, model_point));

    /* Using GObject property methods */
    g_object_set(adim, "org1", origin, NULL);
    g_object_get(adim, "org1", &org1, NULL);
    g_assert_true(adg_point_equal(org1, origin));
    adg_point_destroy(org1);

    g_object_set(adim, "org1", NULL, NULL);
    g_object_get(adim, "org1", &org1, NULL);
    g_assert_null(org1);

    g_object_set(adim, "org1", explicit_point, NULL);
    g_object_get(adim, "org1", &org1, NULL);
    g_assert_true(adg_point_equal(org1, explicit_point));
    adg_point_destroy(org1);

    adg_adim_set_org1_from_model(adim, model, "dummy");
    g_object_get(adim, "org1", &org1, NULL);
    g_assert_nonnull(org1);
    adg_point_destroy(org1);

    g_object_set(adim, "org1", model_point, NULL);
    g_object_get(adim, "org1", &org1, NULL);
    g_assert_true(adg_point_equal(org1, model_point));
    adg_point_destroy(org1);

    adg_point_destroy(origin);
    adg_point_destroy(explicit_point);
    adg_point_destroy(model_point);
    adg_entity_destroy(ADG_ENTITY(adim));
    g_object_unref(model);
}