Book a Demo

Author Topic: lineto behaves differently for main than endshapes  (Read 6126 times)

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
lineto behaves differently for main than endshapes
« on: August 29, 2008, 01:42:50 pm »
In the main shape the X value appears to be a percentage of the line, the Y value is some offset (but not to same scale - seems to be approximately 1/10th scale).

In the subshape, both x and y are absolute values.

shape main
{
    lineto(75,75);
}
shape target
{
    lineto(75,75);
}

Observe the inconsistent behaviour.

NOTE: this percentage stuff also seems to apply to shapes drawn in the main shape for the connector - try drawing some and see...

Paolo
« Last Edit: August 29, 2008, 01:54:14 pm by PaoloFCantoni »
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: lineto behaves differently for main than endsh
« Reply #1 on: August 29, 2008, 01:47:47 pm »
Ouch! That might explain a few strange results over the past while.

[Of course, another explanation would be my rather poor drawing talents, whether automated or not...]

Even if there is a reason for this, there should be a set of consistent options that can be applied to either end (individually). [IMHO of course.]
« Last Edit: August 29, 2008, 01:48:54 pm by Midnight »
No, you can't have it!

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: lineto behaves differently for main than endsh
« Reply #2 on: August 29, 2008, 02:57:19 pm »
Quote
In the main shape the X value appears to be a percentage of the line, the Y value is some offset (but not to same scale - seems to be approximately 1/10th scale).

In the subshape, both x and y are absolute values.
Well, yes. You wouldn't want an arrowhead to resize in proportion to the length of the relationship, so x and y in the source and target shapes need to be absolutes. You wouldn't want the width of a line to resize in proportion to its length, so y in the main shape needs to be absolute. You can't know how long a line is going to be when defining the shape script, so x in the main shape can't be absolute. This probably needs to be documented if it isn't already...
« Last Edit: August 29, 2008, 02:58:23 pm by KP »
The Sparx Team
[email protected]

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: lineto behaves differently for main than endsh
« Reply #3 on: August 29, 2008, 06:32:09 pm »
Quote
Well, yes. You wouldn't want an arrowhead to resize in proportion to the length of the relationship, so x and y in the source and target shapes need to be absolutes. You wouldn't want the width of a line to resize in proportion to its length, so y in the main shape needs to be absolute. You can't know how long a line is going to be when defining the shape script, so x in the main shape can't be absolute. This probably needs to be documented if it isn't already...
I'm not disagreeing with the behaviour - just the non-documentation AND the naming.

There needs be two methods.  The lineto - which works identically in both situations and percentlineto which only works on the main shape.  The semantic signatures of the two methods are different - consequently they should NOT have the same name.

Also, it's not clear what the Y value is there for...

PLUS there is the implication for the drawing of shapes...  There's NO Way that I can tell to draw a shape (for example in the centre of the line).  My example - where I discovered all these anomalies was:  trying to draw the Assembly connector using shape scripts.  (Leaving aside the other bug that you can't override the nativeshape of the assembly).

Can anyone show me how to draw the Assembly connector (say, using an Association since the bug above) using a shape script?

Paolo
« Last Edit: January 30, 2010, 01:54:25 am by PaoloFCantoni »
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: lineto behaves differently for main than endsh
« Reply #4 on: August 29, 2008, 09:04:46 pm »
Quote
...
Can anyone show me how to draw the Assembly connector (say, using an Association since the bug above) using a shape script?
...
Don't you already have enough pain in your life?
No, you can't have it!

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: lineto behaves differently for main than endsh
« Reply #5 on: August 31, 2008, 11:46:58 pm »
Quote
Don't you already have enough pain in your life?
Obviously not... ;)

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: lineto behaves differently for main than endsh
« Reply #6 on: September 01, 2008, 08:46:36 am »
I haven't really done a lot with shape scripts, but from looking at the documentation I've come up with the following.  (Which I admit isn't perfect)

Code: [Select]
shape main
{
  // draw a dashed line
  noshadow=true;
  setlinestyle("SOLID");
  moveto(0,0);
  lineto(100,0);

  setorigin("CENTER",0,0);
  addsubshape("assembly", 15, 15);
            
  shape assembly
  {
    scalable="false";
    ellipse(3,3,12,12);
    arc(0,0,15,15,7,0,7,15);
  }
}

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: lineto behaves differently for main than endsh
« Reply #7 on: September 01, 2008, 11:19:37 am »
Thanks Simon!

It was the scalable attribute I was missing...

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: lineto behaves differently for main than endsh
« Reply #8 on: September 01, 2008, 09:28:40 pm »
This brings up an old point.

To say it once again...

We need additional documentation. This should include a new set of examples. The ones we have are limited, dated, and not well related to specific drawing tasks. What's there is not wrong, but it is simply to thin.
No, you can't have it!

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: lineto behaves differently for main than endsh
« Reply #9 on: September 02, 2008, 12:02:43 am »
Quote
I haven't really done a lot with shape scripts, but from looking at the documentation I've come up with the following.  (Which I admit isn't perfect)
Hi Simon,

I couldn't make it work...

It seems to me that subshapes don't work in edges (lines).

Before I report a bug can anyone confirm that subshapes DO work for lines and therefore I'm doing something wrong?

Again, can anyone show me how to use shape scripts to make an Association look like an Assembly?  (Not that this makes sense, it's just illustrate how to do this kind of stuff).

TIA,
Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: lineto behaves differently for main than endsh
« Reply #10 on: January 30, 2010, 06:39:07 pm »
Quote
I haven't really done a lot with shape scripts, but from looking at the documentation I've come up with the following.  (Which I admit isn't perfect)
Code: [Select]
[Removed]

This version is a bit closer.   The problem is that the subshapes are not automatically rotated with the angle of the connector.  This version looks close enough and will "rotate" correctly.

Code: [Select]
shape main
{
      noshadow=true;
      setlinestyle("SOLID");
      lineto(100,0);

      setorigin("CENTER",0,0);
      addsubshape("socket", 15, 15);
      setorigin("CENTER",2,-15);
      addsubshape("ball", 15, 15);
                  
      shape ball
      {
            scalable="false";
            ellipse(1,1,14,14);
      }
      shape socket
      {
            scalable="false";
            ellipse(0,0,15,15);
      }
 }
I'll report the shapescript non-rotation as a bug...

Paolo
« Last Edit: January 30, 2010, 06:47:50 pm by PaoloFCantoni »
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!