Book a Demo

Author Topic: Connector.StartPointX/Y and related - valid values  (Read 8305 times)

Mhatch

  • EA User
  • **
  • Posts: 27
  • Karma: +0/-0
    • View Profile
Connector.StartPointX/Y and related - valid values
« on: September 10, 2013, 07:37:07 am »
I am accessing the EA.Connector.StartPointX, .StartPointY, .EndPointX, and .EndPointY values from the object model.  The values do not appear to be consistently set after creating/updating a diagram, and they are inconsistent by connector type (say 'association' vs. 'dependency').

Repro scenario
1. Create a new component model, add two components
2. Add an association connector between them

Run the following query replacing 'Component12' with a component name in step 1

select c.Connector_ID, c.Name, c.Start_Object_ID, c.PtStartX, c.PtStartY, c.PtEndX, c.PtEndY, do.RectTop, do.RectLeft, do.RectRight, do.RectBottom, o.*
from ((t_connector c inner join t_diagramobjects do on c.Start_Object_ID = do.Object_ID)
inner join t_object o on o.Object_ID = do.Object_ID)
where o.Name = 'Component12'

Note that the X and Y values (columns 4-7 from query) are all zero

3. Update the association connector name to something (like 'Foo').
4. Run the query again, notice that X and Y values now have valid values

5. Repeat steps 2-5, but create a dependency connection and notice that X and Y values to not change (stay zero) regardless of changes made to the model.

Anyone encountered this before?  Is there a better reliable source for the connector end point values?  Any reliable method to cause them to be updated as in step 3 for an association connector (labeling/renaming the connector)?
« Last Edit: September 10, 2013, 07:37:43 am by mike.hatch »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Connector.StartPointX/Y and related - valid va
« Reply #1 on: September 10, 2013, 09:13:06 am »
I guess these values are just for the size of qualifiers. Actually they do not seem to make much sense at all.

If you are after location on the diagram look into t_diagramlinks.

I checked with dependencies but they are not zero in my case (build 1007).

q.

Mhatch

  • EA User
  • **
  • Posts: 27
  • Karma: +0/-0
    • View Profile
Re: Connector.StartPointX/Y and related - valid va
« Reply #2 on: September 10, 2013, 09:54:42 am »
I am on build 1007 as well.  Strange.

I have been looking at the DiagramLink object as well, and I assume that the 'Geometry' field is the place, but there is no reference for this compound field.  

I assume that the 'SX', 'SY' and related values represent the start and end points, but those values don't make sense to me either, and they are always set to the same values.  Meaning: SX=EX and SY=EY, which doesn't make sense if they represent the start and end points of the link.  

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: Connector.StartPointX/Y and related - valid va
« Reply #3 on: September 10, 2013, 10:06:05 am »
SX and SY are relative to the centre of the start object and EX and EY are relative to the centre of the end object. If you have your connectors set to draw centre to centre, then all four values will initially be set to 0.
The Sparx Team
[email protected]

Mhatch

  • EA User
  • **
  • Posts: 27
  • Karma: +0/-0
    • View Profile
Re: Connector.StartPointX/Y and related - valid va
« Reply #4 on: September 10, 2013, 10:11:13 am »
That seems to just tell me that the connector start or end point is on the edge of the object (SX & EX = Width/2 and SY & EY = Height/2), which is not specific to which edge, and the point along on the edge of the object that it is connected?

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Connector.StartPointX/Y and related - valid va
« Reply #5 on: September 10, 2013, 07:40:47 pm »
If SX is width/2 then the connector is on the right side. If -width/2 then on the left. If SY = height/2 then on top and -height/2 on the bottom. Either abs(SX) == width/2 or abs(SY) == height/2. If both conditions match then it's located on an edge.

I will have to add this information to my Inside book.

q.
« Last Edit: September 10, 2013, 07:42:34 pm by qwerty »

Mhatch

  • EA User
  • **
  • Posts: 27
  • Karma: +0/-0
    • View Profile
Re: Connector.StartPointX/Y and related - valid va
« Reply #6 on: September 11, 2013, 01:14:03 am »
That is helpful.  So the only remaining question is how to tell where along the edge the connector is located.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Connector.StartPointX/Y and related - valid va
« Reply #7 on: September 11, 2013, 05:30:37 am »
I don't exactly understand what you need to know. The connector is directly drawn from start to end (calculated from the S/E-X/Y values related to the Start end End objects, as long as style is set to 3 (see the setting in the Style property). Do you need to know how bends are coded?

q.

Mhatch

  • EA User
  • **
  • Posts: 27
  • Karma: +0/-0
    • View Profile
Re: Connector.StartPointX/Y and related - valid va
« Reply #8 on: September 11, 2013, 06:25:44 am »
Thanks qwerty - I didn't see how to determine where along the edge the connector point lay.  I figured it out - the values increase from 0 to object.Height (or Width) /2.

Mhatch

  • EA User
  • **
  • Posts: 27
  • Karma: +0/-0
    • View Profile
Re: Connector.StartPointX/Y and related - valid va
« Reply #9 on: September 12, 2013, 11:21:38 am »
Some more information after research on this topic - the SX and SY values reflect an x,y coordinate for the start point (and EX/EY for the end point) of a diagram link object.

The values of SX and SY are relative to the object connected, and range from SX = -(Width/2) on the left to Width/2 on the right.
SY values range from -(Height/2) on the bottom to Height/2 on the top edge.

This not enough data, however to completely place the point, since determining the x/y values only will place the point somewhere in the middle of the object if SX <= Width/2 or SY <=Height/2

There is another value in the DiagramLink.Geometry 'blob' called 'EDGE' which tells you the edge on the start (client) object of the link.  EDGE ranges in value from 1-4, with 1=Top, 2=Right, 3=Bottom, 4=Left.

This allows placing the connector on the edge of the start object, because if EDGE = 1 you set the Y value to Height/2
EDGE=2, set X=Width/2, EDGE=3, set Y= -(Height/2), EDGE-4, set X=-(Width/2).

This does not allow for placing the endpoint, however, because you don't know which edge of the end object.  This does not seem to be exposed in the API, but if you query t_connector, you can see that sparx does have the data, in the columns 'Start_Edge', and 'End_Edge'.  End_Edge is not exposed in the automation API, from what I can tell?

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Connector.StartPointX/Y and related - valid va
« Reply #10 on: September 13, 2013, 05:53:34 am »
I guess the Edge data is redundant since either SX or SY is always +-width/height half. So you can determine which side the connector is attached. However, the Edge value might make it easier.

Your observation that some data in the tables are not exposed in the API is correct. It applies to more than what you discovered (though from the heart I can't tell which other value is also a candidate). It would be nice (and consistent) if all values would be available through the API. Feel free to send a bug/feature report. But do not expect too much too soon. EA is no longer a speed boat but more a big tanker. And changing the course is more inert.

q.