Re: function to resize a UML class object's extent?



On 2001.11.29 16:59 Lars Clausen wrote:
On Fri, 30 Nov 2001, Cyrille Chepelov wrote:

Le jeu, nov 29, 2001, à 06:03:42 -0800, Robert Campbell a écrit:
Is any of this perhaps related to the problem that a UML class object
will not shrink when the longest attribute or method shrinks?  I'm
running the Windows version.

maybe... someone has to dig into umlclass_update_data() and see why it
behaves the way it does (I don't think there is anything specifically
Windows, except perhaps a slight but repeatable string width
miscalculation)

Dug.  Umlclass has two operations, umlclass_update_data() and
umlclass_calculate_data().  The latter figures out all the font sizes etc,
and is only called from copy, create, load, apply_properties and
change_apply (through set_state).  Should umlclass_set_props call
umlclass_calculate_data before umlclass_update_data, or is there a call to
obj->apply_properties_func implied in object_set_props_from_offsets?  I'm
losing my way somewhere in propoffsets.c:)  I'm thinking that extra call
might help it.

Based on what you found, I changed my code to this:

      /* these should be probably changed to more useful defaults
         eventually */
      start.x = 0.0;
      start.y = 0.0;
      umlclass_obj = otype->ops->create(&start, otype->default_user_data,
                                        &h1, &h2);
      layer_add_object(dia->active_layer, umlclass_obj);

      props = prop_list_from_descs(sql_prop_descs, pdtpp_true);
      g_assert(props->len == 1);

      nameprop = g_ptr_array_index(props, 0);

      /* the {persistent} tag should be made optional (or at least
         concealable) eventually */
      nameprop->string_data =
          g_strdup_printf("%s {persistent}",
                          gschema_element->base_table_def_sql->table_sql->str);
      /* this compulsory capitalization of class-names-as-table-names
         should be made optional eventually */
      nameprop->string_data[0] =
          (char) toupper((int)
                 gschema_element->base_table_def_sql->table_sql->str[0]);
      g_strdown(nameprop->string_data + 1);

      umlclass_obj->ops->set_props(umlclass_obj, props);
      umlclass_calculate_data(umlclass_obj);
      umlclass_update_data(umlclass_obj);

adding the extra calls to umlclass_calculate_data() and umlclass_update_data()
at the end, and everything works quite nicely now.  Thanks! (realizing of
course, that I need to remove it once the StdProp code is patched)

Andy




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]