Author Topic: Move EmbeddedElement from one Element to another  (Read 13059 times)

Viking

  • EA User
  • **
  • Posts: 400
  • Karma: +2/-2
    • View Profile
Re: Move EmbeddedElement from one Element to another
« Reply #15 on: June 17, 2020, 10:47:35 pm »
Sorry, I don't remember (too long ago). Anyhow, you just need to experiment with one horizontal and one veritcal edge of the outer element. Best you move a port manually and look which coordinates EA gives it in comparison to its embedding element. IIRC a port has 15x15 size and so you have a 7 offset. No idea how to cope with ports that have adjustable size. q.

Size 15x15 is correct.

Do I need to change only one coordinate of the port or all 4 (I struggle with both variants) ?

qwerty

  • EA Guru
  • *****
  • Posts: 13573
  • Karma: +395/-301
  • I'm no guru at all
    • View Profile
Re: Move EmbeddedElement from one Element to another
« Reply #16 on: June 17, 2020, 10:52:55 pm »
You need to calculate BL BR TL TR for the port. Depending on which parent edge you have to add/sub 7. Just look into what a sample port shows. Not too difficult to have a look, is it?

q.

Viking

  • EA User
  • **
  • Posts: 400
  • Karma: +2/-2
    • View Profile
Re: Move EmbeddedElement from one Element to another
« Reply #17 on: June 17, 2020, 11:10:29 pm »
You need to calculate BL BR TL TR for the port. Depending on which parent edge you have to add/sub 7. Just look into what a sample port shows. Not too difficult to have a look, is it? q.

No, its not. I calculated all cordinates. I retieved the wrong coordinates for any reason :(
« Last Edit: June 17, 2020, 11:28:31 pm by Viking »

Viking

  • EA User
  • **
  • Posts: 400
  • Karma: +2/-2
    • View Profile
Re: Move EmbeddedElement from one Element to another
« Reply #18 on: June 18, 2020, 12:08:19 am »
You need to calculate BL BR TL TR for the port. Depending on which parent edge you have to add/sub 7. Just look into what a sample port shows. Not too difficult to have a look, is it? q.

I did the following:

Element (parent) new position: l: 146 r: 236 t: -193 b: -263
(Port old position l: 603 r: 618 t: -215 b: -230)
Port new position l: 229 r: 244 t: -215 b: -230

Port r – l = 15 (correct)
Port b – t = 15 (correct)
Port l - Element r = -7 (correct)
Port r - Element r = 7 8 (correct)

EA OM changes only Port l and r and keeps t and b. What's wrong?
« Last Edit: June 18, 2020, 03:46:04 am by Viking »

qwerty

  • EA Guru
  • *****
  • Posts: 13573
  • Karma: +395/-301
  • I'm no guru at all
    • View Profile
Re: Move EmbeddedElement from one Element to another
« Reply #19 on: June 18, 2020, 01:51:51 am »
244 - 236 = 8

q.

Viking

  • EA User
  • **
  • Posts: 400
  • Karma: +2/-2
    • View Profile
Re: Move EmbeddedElement from one Element to another
« Reply #20 on: June 18, 2020, 03:05:24 am »

Viking

  • EA User
  • **
  • Posts: 400
  • Karma: +2/-2
    • View Profile
Re: Move EmbeddedElement from one Element to another
« Reply #21 on: June 18, 2020, 03:58:16 am »
But it still does not work :(

qwerty

  • EA Guru
  • *****
  • Posts: 13573
  • Karma: +395/-301
  • I'm no guru at all
    • View Profile
Re: Move EmbeddedElement from one Element to another
« Reply #22 on: June 18, 2020, 04:46:49 am »
You are giving me a hard time.

Orientation LRTB element and port to the right
E: 210 310 -190 -270
P: 303 318 -230 -245
-> port L 303 = element R 310 - 7
    port R 318 = element R 310 + 8

to the left
E: 210 310 -190 -270
P: 202 217 -230 -245
-> port L 202 = element L 210 - 8
     port R 217 = element L 210 + 7

to the top
E: 210 310 -190 -270
P: 250 265 -183 -198
-> port T -183 = element T -190 + 7
    port B -198 = element T -190 - 8

to the bottom
E: 210 310 -190 -270
P: 261 276 -263 -278
-> port T -263= element B -270 + 7
    port B -278 = element T -270 - 8

So: to the inside 7 px and to the outside 8 px from the element edge.

q.

Arnoud_B

  • EA User
  • **
  • Posts: 76
  • Karma: +0/-0
    • View Profile
Re: Move EmbeddedElement from one Element to another
« Reply #23 on: June 18, 2020, 05:22:33 am »
Hi, I am working on the same 'problem' so interested in this treat. I have a related question; how can you see that there are diagramObjects embedded inside another diagram object? That one object is the parent of another does not mean that they are visualized inside one another on the diagram. I would like to format my diagram automatically and if there are display objects inside display objects inside ... I have to calculate their size and position accordingly.

Viking

  • EA User
  • **
  • Posts: 400
  • Karma: +2/-2
    • View Profile
Re: Move EmbeddedElement from one Element to another
« Reply #24 on: June 18, 2020, 05:32:30 am »
You are giving me a hard time.

I see. I am very sorry. Thank you very much for your incredible assistance !

But it still does not work. I even tried 15/2, which I saw in an implementation of Helmut Ortmann at github.

I reload the diagram before and afterwards. I update the DiagramObject. Everything which works normally does not work in this case.

qwerty

  • EA Guru
  • *****
  • Posts: 13573
  • Karma: +395/-301
  • I'm no guru at all
    • View Profile
Re: Move EmbeddedElement from one Element to another
« Reply #25 on: June 18, 2020, 05:40:08 am »
@viking please show your code...

@Arnoud_B you need to retrieve the object via the id from the diagram object. Only there you can see which one is an embeeded one (via the element parent relation).

q.
« Last Edit: June 18, 2020, 05:42:41 am by qwerty »

Arnoud_B

  • EA User
  • **
  • Posts: 76
  • Karma: +0/-0
    • View Profile
Re: Move EmbeddedElement from one Element to another
« Reply #26 on: June 18, 2020, 06:13:58 am »
Quote
"@Arnoud_B you need to retrieve the object via the id from the diagram object. Only there you can see which one is an embeeded one (via the element parent relation)."

Well that I figured out already but that is not enough; an element that is embedded as child in a parent can be perfectly be displayed next to its parent and not inside its parent. Only if you move it inside you cannot move it out anymore.
I want to be able to detect with a script if the diagram object of the child element is inside the diagram object of the parent element so I can make the parent diagram object larger.

qwerty

  • EA Guru
  • *****
  • Posts: 13573
  • Karma: +395/-301
  • I'm no guru at all
    • View Profile
Re: Move EmbeddedElement from one Element to another
« Reply #27 on: June 18, 2020, 06:18:48 am »
Well, EA "usually" (but as EA is, not always) puts embedded elements inside or attached to their parents. Whether or not elements are graphically overlapping can only be detected by their position (top, left, bottom, right). That's quite simple geometry to use here. There is no attribute where you can detect that a diagram object is embedded or not (except via the parent relation of the underlying objects).

q.

Viking

  • EA User
  • **
  • Posts: 400
  • Karma: +2/-2
    • View Profile
Re: Move EmbeddedElement from one Element to another
« Reply #28 on: June 18, 2020, 04:57:12 pm »
Issue solved !

I had to save (Update()) the moved ParentElement BEFORE I can expect EA to recognize changes to it. Although the ParentElement (to which I wanted to attach the EmbeddedElemenet) has been moved on the Diagram successfully, EA had the old position in "memory".

Lessons learned are (maybe wrong) that Update saves changes to the in objects in memory (maybe also to the database). Otherwise they do not exist for further processing.

@qwerty, many thanks for your valuable support.
« Last Edit: June 18, 2020, 06:14:34 pm by Viking »

Arnoud_B

  • EA User
  • **
  • Posts: 76
  • Karma: +0/-0
    • View Profile
Re: Move EmbeddedElement from one Element to another
« Reply #29 on: June 18, 2020, 05:07:56 pm »
Quote
Well, EA "usually" (but as EA is, not always) puts embedded elements inside or attached to their parents. Whether or not elements are graphically overlapping can only be detected by their position (top, left, bottom, right). That's quite simple geometry to use here. There is no attribute where you can detect that a diagram object is embedded or not (except via the parent relation of the underlying objects).

Well I agree that the mathematics involved are not complex but it is quite some coding as you have to check ALL elements on the diagram to see if they are in the same position (a full table scan implemented in scripting code). Then I have to check if the items are simply in the same place (they have no parent/child) relation or they should actually be embedded on diagram level.
Well I have some coding to do, however a collection of embedded (child) Diagram objects on the (parent) diagram object just like the Element itself would make life easier for me  :'(