MetaCase Homepage
Forum Home Forum Home > > MetaEdit+
  New Posts New Posts RSS Feed - Scale in object representation
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Scale in object representation

 Post Reply Post Reply
Author
Message
alev View Drop Down
Contributor
Contributor
Avatar

Joined: 08.Oct.2010
Location: Arnhem, NL
Points: 19
Post Options Post Options   Thanks (0) Thanks(0)   Quote alev Quote  Post ReplyReply Direct Link To This Post Topic: Scale in object representation
    Posted: 07.Apr.2011 at 14:03
Hi,

I am generating an MXM file to import into MetaEdit+ and would like to import information about location and size of modeling elements in a diagram. The MetaEdit+ Workbench explains MXM format very well, but I miss information on how to specify size of an element on a diagram. (I assume size has something to do with 'scale' in MXM object representation.)

So given x, y, left, right, top, bottom, area info of an element, how is scale calculated?

Thank you.


Edited by alev - 07.Apr.2011 at 14:04
Back to Top
stevek View Drop Down
MetaCase
MetaCase
Avatar

Joined: 11.Mar.2008
Points: 643
Post Options Post Options   Thanks (0) Thanks(0)   Quote stevek Quote  Post ReplyReply Direct Link To This Post Posted: 07.Apr.2011 at 14:41
Scale is relative to the default size of the symbol, as defined in Symbol Editor - i.e. the size of a new element of that type in a Diagram. If you omit the scale attribute, you'll get the default size. If you want it twice as wide and three times as tall, use scale="2,3".

If you want a particular absolute height and width, you'll need to know the height and width of the default size, and calculate the desired scale from those. I suppose one way is to make a defaultSize.mxm with a single graph called defaultSize, containing an instance and representation of each object type, with no scale supplied. Import that with "internal 'fileInPatch: defaultSize.mxm' execute", then run a generator on it to find the width and height of each element. You can store those in variables, and use them later when calculating the desired scale values. After the import, you probably want to abandon with "internal 'abandon' execute", to avoid saving the temporary defaultSize graph.

/* To get the default sizes and store them in variables */
do graphs where id='defaultSize'
{  foreach .()
    {  variable 'width' type write
           width
         close
    }
}

/* To calculate x scale from $myWidth */
math
   $myWidth    ' / '    variable 'width' type read
evaluate
Back to Top
alev View Drop Down
Contributor
Contributor
Avatar

Joined: 08.Oct.2010
Location: Arnhem, NL
Points: 19
Post Options Post Options   Thanks (0) Thanks(0)   Quote alev Quote  Post ReplyReply Direct Link To This Post Posted: 07.Apr.2011 at 15:42
Steven, thank you. With your suggestion I finished the generator.

Since the default size of the symbol, as defined in Symbol Editor does not change often, I simply read default width and height from an existing model and put those numbers as parameters in the generator.

Thanks again for a lightning fast reply!
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.05
Copyright ©2001-2022 Web Wiz Ltd.

This page was generated in 0.047 seconds.