Book a Demo

Author Topic: 100% not 100% in lineto() for shapescripts  (Read 7538 times)

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
100% not 100% in lineto() for shapescripts
« on: January 12, 2016, 07:01:09 pm »
If you alter the relationship line in a shapescript (such as having one style up to 50% and a different style for the remainder).  The lineto(100,0) command (for the second part of the line) only works up to the first way-point.  So for any line style (other than Direct) the result will not be as expected.

Example:
   if (HasProperty("source.targetscope","instance"))   //For Arc
   {
      setpen(87,255,192,1);
      lineto(50,0);
   }
   else
   {
      setpen(255,0,0,3);
      lineto(50,0);
   }
   if (HasProperty("target.targetscope","classifier"))   //For Arc
   {
      setpen(87,255,192,2);
      lineto(100,0);
   }
   else
   {
      setpen(255,0,0,3);
      lineto(100,0);
   }

Reported,
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: 100% not 100% in lineto() for shapescripts
« Reply #1 on: January 13, 2016, 08:24:39 am »
Not quite right.

The shape script only runs for the center segment, in effect allowing a decoration to be applied on the center segment. From memory all other segments are drawn using the first line style defined.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: 100% not 100% in lineto() for shapescripts
« Reply #2 on: January 13, 2016, 10:33:23 am »
Not quite right.

The shape script only runs for the center segment, in effect allowing a decoration to be applied on the center segment. From memory all other segments are drawn using the first line style defined.
Hi Simon,

Can you explain that in a bit more detail? Since I can't reconcile what I'm seeing with what you just said (It sort of does, but I'm not sure).

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: 100% not 100% in lineto() for shapescripts
« Reply #3 on: January 13, 2016, 11:42:47 am »
Apply this shape script to a connector with (at least) two waypoints and read the comments inside.

Code: [Select]
shape main
{
    noShadow=true;

    // This pen style will be ignored
    // because nothing is drawn.
    setpen(0,0,0,1);
    SetLineStyle("solid");
   
    // This pen style will be used for
    // non-center segments because it
    // is the first that is used for
    // drawing.
    setpen(255,0,0,2);
    SetLineStyle("dash");
    moveto(0,0);
    lineto(50,0);
   
    // This line style is used in the center
    // segment, but no others because it
    // isn't the first one drawn with.
    setpen(0,255,0,1);
    SetLineStyle("dot");
    lineto(100,0);
   
    // This line style is used for an
    // annotation in the center segment only.
    setpen(0,0,0,1);
    SetLineStyle("solid");
    setfixedregion(40,-10,60,10);
    ellipse(40,-10,60,10);
}

Let me know if that doesn't answer your questions.
« Last Edit: January 13, 2016, 12:29:38 pm by Simon M »

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: 100% not 100% in lineto() for shapescripts
« Reply #4 on: January 13, 2016, 03:55:42 pm »
Thanks Simon,

Actually that code didn't answer all my questions, just raised a few more, but the following code should allow shapescript designers to understand how the shapescript will react to way-points as they are added/removed. Your script (with my mods) also answers many questions I had about why the lines behave the way they do - for some of the standard scripts.

Code: [Select]
shape main
{
    noShadow=true;

    // This pen style will be ignored
    // because nothing is drawn.
    setpen(0,0,0,1);
    SetLineStyle("solid");
   
    // This pen style will be used for
    // non-center segments because it
    // is the first that is used for
    // drawing.
    setpen(255,0,0,2);
    SetLineStyle("dash");
    moveto(0,0);
    lineto(0,0); //Even though the drawing is to (0,0)!
   
  //NOTE: we're going to split the center segment into 3 parts
   // This line style is used in the center
    // segment, but no others because it
    // isn't the first one drawn with.
    setpen(0,0,255,1); //First part
    SetLineStyle("dashdot");
    lineto(20,0);
    setpen(0,255,0,2); //Second part
    SetLineStyle("dot");
    lineto(80,0);
    setpen(128,128,128,1); //Third part
    SetLineStyle("dashdotdot");
    lineto(100,0);
   
    // This line style is used for a
    // decoration in the center segment only.
    setpen(0,0,0,1);
    SetLineStyle("solid");
    setfixedregion(40,-10,60,10);
    ellipse(40,-10,60,10);
}

BTW: where is the stuff about "Center" segments documented?

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: 100% not 100% in lineto() for shapescripts
« Reply #5 on: January 14, 2016, 08:29:30 am »
Okay, good to hear you've worked out what to expect.

The center segment behavior came from my memory. I couldn't find it in the help anywhere so I passed on a request to explain it with connector shape scripts to the help team.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: 100% not 100% in lineto() for shapescripts
« Reply #6 on: January 15, 2016, 11:17:35 am »
I'd already worked out what I expected - and what I got wasn't what I expected...  ;D

If you look at what I was able to do with the lineto(0,0).  It seems to me that if you took the rendering at (0,0) in the centre section and applied it to all the segments prior to the center; then took the rendering at (100,0) and applied it to the segments following, you'd have a more intuitive result.

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