Example #1
0
File: adg-adim.c Project: bert/adg
/**
 * adg_adim_new_full_from_model:
 * @model: (transfer none): the model from which the named pairs are taken
 * @ref1:  (allow-none):    the end point of the first line
 * @ref2:  (allow-none):    the end point of the second line
 * @org1:  (allow-none):    the origin of the first line
 * @org2:  (allow-none):    the origin of the second line
 * @pos:   (allow-none):    the position reference
 *
 * Creates a new angular dimension, specifing all the needed properties
 * in one shot and using named pairs from @model.
 *
 * Returns: the newly created angular dimension entity
 *
 * Since: 1.0
 **/
AdgADim *
adg_adim_new_full_from_model(AdgModel *model,
                             const gchar *ref1, const gchar *ref2,
                             const gchar *org1, const gchar *org2,
                             const gchar *pos)
{
    AdgADim *adim;
    AdgDim *dim;

    adim = adg_adim_new();
    dim = (AdgDim *) adim;

    if (ref1 != NULL)
        adg_dim_set_ref1_from_model(dim, model, ref1);

    if (ref2 != NULL)
        adg_dim_set_ref2_from_model(dim, model, ref2);

    if (pos != NULL)
        adg_dim_set_pos_from_model(dim, model, pos);

    if (org1 != NULL)
        adg_adim_set_org1_from_model(adim, model, org1);

    if (org2 != NULL)
        adg_adim_set_org2_from_model(adim, model, org2);

    return adim;
}
Example #2
0
File: adg-adim.c Project: bert/adg
/**
 * adg_adim_new_full:
 * @ref1: (allow-none): first reference point
 * @ref2: (allow-none): second reference point
 * @org1: (allow-none): first origin point
 * @org2: (allow-none): second origin point
 * @pos:  (allow-none): the position point
 *
 * Creates a new angular dimension, specifing all the needed
 * properties in one shot using #CpmlPair.
 *
 * Returns: the newly created angular dimension entity
 *
 * Since: 1.0
 **/
AdgADim *
adg_adim_new_full(const CpmlPair *ref1, const CpmlPair *ref2,
                  const CpmlPair *org1, const CpmlPair *org2,
                  const CpmlPair *pos)
{
    AdgADim *adim;
    AdgDim *dim;

    adim = adg_adim_new();
    dim = (AdgDim *) adim;

    if (ref1 != NULL)
        adg_dim_set_ref1_from_pair(dim, ref1);

    if (ref2 != NULL)
        adg_dim_set_ref2_from_pair(dim, ref2);

    if (pos != NULL)
        adg_dim_set_pos_from_pair(dim, pos);

    if (org1 != NULL)
        adg_adim_set_org1_from_pair(adim, org1);

    if (org2 != NULL)
        adg_adim_set_org2_from_pair(adim, org2);

    return adim;
}
Example #3
0
static void
_adg_property_dim_dress(void)
{
    AdgDim *dim;
    AdgDress valid_dress, incompatible_dress;
    AdgDress dim_dress;

    dim = ADG_DIM(adg_adim_new());
    valid_dress = ADG_DRESS_DIMENSION;
    incompatible_dress = ADG_DRESS_LINE;

    /* Using the public APIs */
    adg_dim_set_dim_dress(dim, valid_dress);
    dim_dress = adg_dim_get_dim_dress(dim);
    g_assert_cmpint(dim_dress, ==, valid_dress);

    adg_dim_set_dim_dress(dim, incompatible_dress);
    dim_dress = adg_dim_get_dim_dress(dim);
    g_assert_cmpint(dim_dress, ==, valid_dress);

    /* Using GObject property methods */
    g_object_set(dim, "dim-dress", valid_dress, NULL);
    g_object_get(dim, "dim-dress", &dim_dress, NULL);
    g_assert_cmpint(dim_dress, ==, valid_dress);

    g_object_set(dim, "dim-dress", incompatible_dress, NULL);
    g_object_get(dim, "dim-dress", &dim_dress, NULL);
    g_assert_cmpint(dim_dress, ==, valid_dress);

    adg_entity_destroy(ADG_ENTITY(dim));
}
Example #4
0
static void
_adg_property_detached(void)
{
    AdgDim *dim;
    AdgThreeState valid_three_state_1, valid_three_state_2, invalid_three_state;
    AdgThreeState detached;

    dim = ADG_DIM(adg_adim_new());
    valid_three_state_1 = ADG_THREE_STATE_UNKNOWN;
    valid_three_state_2 = ADG_THREE_STATE_OFF;
    invalid_three_state = 1234;

    /* Using the public APIs */
    adg_dim_set_detached(dim, valid_three_state_1);
    detached = adg_dim_get_detached(dim);
    g_assert_cmpint(detached, ==, valid_three_state_1);

    adg_dim_set_detached(dim, invalid_three_state);
    detached = adg_dim_get_detached(dim);
    g_assert_cmpint(detached, ==, valid_three_state_1);

    adg_dim_set_detached(dim, valid_three_state_2);
    detached = adg_dim_get_detached(dim);
    g_assert_cmpint(detached, ==, valid_three_state_2);

    /* Using GObject property methods */
    g_object_set(dim, "detached", valid_three_state_1, NULL);
    g_object_get(dim, "detached", &detached, NULL);
    g_assert_cmpint(detached, ==, valid_three_state_1);

    g_object_set(dim, "detached", invalid_three_state, NULL);
    g_object_get(dim, "detached", &detached, NULL);
    g_assert_cmpint(detached, ==, valid_three_state_1);

    g_object_set(dim, "detached", valid_three_state_2, NULL);
    g_object_get(dim, "detached", &detached, NULL);
    g_assert_cmpint(detached, ==, valid_three_state_2);

    adg_entity_destroy(ADG_ENTITY(dim));
}
Example #5
0
File: test-adim.c Project: bert/adg
static void
_adg_property_has_extension2(void)
{
    AdgADim *adim;
    gboolean invalid_boolean;
    gboolean has_extension2;

    adim = adg_adim_new();
    invalid_boolean = (gboolean) 1234;

    /* Using the public APIs */
    adg_adim_switch_extension2(adim, FALSE);
    has_extension2 = adg_adim_has_extension2(adim);
    g_assert_false(has_extension2);

    adg_adim_switch_extension2(adim, invalid_boolean);
    has_extension2 = adg_adim_has_extension2(adim);
    g_assert_false(has_extension2);

    adg_adim_switch_extension2(adim, TRUE);
    has_extension2 = adg_adim_has_extension2(adim);
    g_assert_true(has_extension2);

    /* Using GObject property methods */
    g_object_set(adim, "has-extension2", FALSE, NULL);
    g_object_get(adim, "has-extension2", &has_extension2, NULL);
    g_assert_false(has_extension2);

    g_object_set(adim, "has-extension2", invalid_boolean, NULL);
    g_object_get(adim, "has-extension2", &has_extension2, NULL);
    g_assert_false(has_extension2);

    g_object_set(adim, "has-extension2", TRUE, NULL);
    g_object_get(adim, "has-extension2", &has_extension2, NULL);
    g_assert_true(has_extension2);

    adg_entity_destroy(ADG_ENTITY(adim));
}
Example #6
0
File: test-adim.c Project: bert/adg
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);
}