Book a Demo

Author Topic: Initial position of DiagramObject  (Read 5697 times)

gtsoftware

  • EA Novice
  • *
  • Posts: 19
  • Karma: +0/-0
    • View Profile
Initial position of DiagramObject
« on: March 25, 2006, 04:24:06 am »
Hi,

When add a DiagramObject and then read back the position I get some very big numbers; I had been expecting small numbers along the lines of the various examples.


   Set m_currentClass = m_logicalModelPackage.elements.AddNew(className$, "Class")
   m_currentClass.update
   m_logicalModelPackage.elements.Refresh ' Added this because otherwise elements.count etc. not updated
   ' Now add the class to the diagram
   Dim v As Object
   Set v = m_currentDiagram.DiagramObjects.AddNew("", "")
   v.ElementID = m_currentClass.ElementID
   v.update
   
   Dim objDiag As EA.DiagramObject
   Set objDiag = v
   Debug.Print "New " & className$ & " " & objDiag.Left & "," & objDiag.Top & "," & objDiag.Right & "," & objDiag.bottom


Why does it produce these huge numbers? ???


New NameOfClass 4522050,2949168,4390982,3538989


I'm aware that you can set the initial position of a DiagramObject, but I'm not using that as it happens not to fit when the position data is available in my app that drives EA ( 6.1.788 ).


«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Initial position of DiagramObject
« Reply #1 on: March 25, 2006, 02:32:05 pm »
The units appear to be the same ones Sparx uses for page sizing. Look in the user guide for this. It may be in the documentation section - I can't remember, and I last looked back in version 4.1.

Also, the Y coordinate appers to increase from bottom to top, as a cartesian diagram on paper would. You may have to play around a bit to get the feel of it.

Finally, if the EA drawing engine feels your element does not have a 'reasonable' size (this is not defined anywhere) it will size the object on its own. This can produce fairly strange results, since it seems not to always use the standard defaults.

Hope I've cleared the water more than I've muddied it.
David
No, you can't have it!

gtsoftware

  • EA Novice
  • *
  • Posts: 19
  • Karma: +0/-0
    • View Profile
Re: Initial position of DiagramObject
« Reply #2 on: March 26, 2006, 12:54:34 pm »
Thanks for the pointer but I've searched the .chm file for 'page size' 'page units' and the like without coming across the units.

I think I'll just set a 10,10 position at creation and see how that goes.

Colin

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Initial position of DiagramObject
« Reply #3 on: March 27, 2006, 06:33:07 am »
Here's a useful test. Create a new diagram, and retrieve or set its page size programmatically. Then compare with how big the diagram says it is in the EA properties window (F5).
No, you can't have it!

gtsoftware

  • EA Novice
  • *
  • Posts: 19
  • Karma: +0/-0
    • View Profile
Re: Initial position of DiagramObject
« Reply #4 on: March 27, 2006, 08:34:02 am »
I'm not sure what this will prove but using VB I can break in to the code and query in the immediate window, with the result that a new diagram has cx 800 and cy 1100 but a newly added diagram object has very much larger values that don't seem ordered.

Hitting F5 gets me a dialog with the page size as 210 by 297 millimetres (A4)

Code: [Select]

? m_currentDiagram.cy
1100
? m_currentDiagram.cx
800

? objDiag.left
4325433
? objDiag.right
4325425
? objDiag.top
2949218
? objDiag.bottom
3670061


I think I'm updating and refreshing everything in sight but it could still be something in that area. Generally though I think I'm using EA in a way that wasn't envisaged - namely just as a viewer of automatically generated class objects.

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Initial position of DiagramObject
« Reply #5 on: March 27, 2006, 10:03:15 am »
No, this is a way that was envisioned.

Your cx and cy values refer to a page size of 800 by 1100 hundredths of an inch. I also suspect that someplace (EA or Windows) you've got a mapping between A4 and Letter size.

The position of any specific DiagramObject (DO) may be outside of these values, since the DO in question may not be on the top left page.

Remember that the cy decreases towards the bottom of your canvas, and is negative. Depending on how wide and tall your overall used area is the coordinates may be a fairly large in magnitude. Try a small model, or query one you've created by hand, and see what you get. Try looking in t_diagramobjects.

David
No, you can't have it!