/** * 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; }
static void _adg_property_ref2(void) { AdgDim *dim; AdgModel *model; AdgPoint *origin, *explicit_point, *model_point; AdgPoint *ref2; dim = ADG_DIM(adg_rdim_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)); ref2 = adg_dim_get_ref2(dim); g_assert_null(ref2); /* Using the public APIs */ adg_dim_set_ref2_explicit(dim, 0, 0); ref2 = adg_dim_get_ref2(dim); g_assert_true(adg_point_equal(ref2, origin)); adg_dim_set_ref2(dim, NULL); ref2 = adg_dim_get_ref2(dim); g_assert_null(ref2); adg_dim_set_ref2(dim, explicit_point); ref2 = adg_dim_get_ref2(dim); g_assert_true(adg_point_equal(ref2, explicit_point)); adg_dim_set_ref2_from_model(dim, model, "dummy"); ref2 = adg_dim_get_ref2(dim); g_assert_nonnull(ref2); adg_dim_set_ref2_from_model(dim, model, "named-pair"); ref2 = adg_dim_get_ref2(dim); g_assert_true(adg_point_equal(ref2, model_point)); /* Using GObject property methods */ g_object_set(dim, "ref2", origin, NULL); g_object_get(dim, "ref2", &ref2, NULL); g_assert_true(adg_point_equal(ref2, origin)); adg_point_destroy(ref2); g_object_set(dim, "ref2", NULL, NULL); g_object_get(dim, "ref2", &ref2, NULL); g_assert_null(ref2); g_object_set(dim, "ref2", explicit_point, NULL); g_object_get(dim, "ref2", &ref2, NULL); g_assert_true(adg_point_equal(ref2, explicit_point)); adg_point_destroy(ref2); adg_dim_set_ref2_from_model(dim, model, "dummy"); g_object_get(dim, "ref2", &ref2, NULL); g_assert_nonnull(ref2); adg_point_destroy(ref2); g_object_set(dim, "ref2", model_point, NULL); g_object_get(dim, "ref2", &ref2, NULL); g_assert_true(adg_point_equal(ref2, model_point)); adg_point_destroy(ref2); adg_point_destroy(origin); adg_point_destroy(explicit_point); adg_point_destroy(model_point); adg_entity_destroy(ADG_ENTITY(dim)); g_object_unref(model); }