Book a Demo

Author Topic: EA 6.1 Shape Script - sub shape / decoration  (Read 2948 times)

GeorgeStClair

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
EA 6.1 Shape Script - sub shape / decoration
« on: September 24, 2010, 11:04:33 pm »
Hi All,

I've created a custom shape script for a Test Case and wish to have it decorated with enumeration types and tagged values. This I've been able to achieve, when viewing using "Next Shape" in the Shape Editor their displaying at the right size and position but my decorations are appearing roughly 1/50th of the size they should be and are in the top right corner of the main shape when rendered finally. I've been trying to create them as shapes and then using sub shape also but this wouldn't render the sub shapes on the screen at all.

Can anyone advise on how to solve this? Code below.

George.
/*

Shape script for drawing a Test Case spanner
George St. Clair
24/09/2010

*/



shape main
{
//Initialisation attributes - must be before drawing commands
      preferredHeight = 100;
      preferredWidth = 100;
      h_align  =  "center";
      v_align  =  "center";
      layouttype="topdown";
      endpointy = 50;
      endpointx = 50;
      setlinestyle( "solid");
      
      //main shape drawing commands
      moveto(0,40);
      startpath();
      lineto(5,25);
      lineto(15,15);
      lineto(30,15);
      lineto(40,25);
      lineto(45,35);
      lineto(95,35);
      lineto(100,40);
      lineto(100,60);
      lineto(95,65);
      lineto(45,65);
      lineto(40,75);
      lineto(30,85);
      lineto(15,85);
      lineto(5,75);
      lineto(0,60);
      lineto(10,70);
      lineto(20,70);
      lineto(30,60);
      lineto(30,40);
      lineto(20,30);
      lineto(10,30);
      endpath();
      
      //main shape colouration
      setfillcolor ( 188, 186, 150); //titanium
      setpencolor ( 122,122,122); //r, g, b
      setpenwidth(1);

      fillandstrokepath();      
      //name embelishments
      printwrapped("#NAME#");      
}

decoration RunStatus
{      
      preferredHeight = 100;
      preferredWidth = 100;
      noshadow = "true";
      h_align  =  "center";
      v_align  =  "center";
      orientation="NE";
        SetOrigin("NW",0,0);
      fillandstrokepath();
      setpencolor ( 122,122,122); //r, g, b
      setpenwidth(1);
//      if (HasTag("Run Status", "Passed"))
//      {
            moveto(55,35);
            setfillcolor ( 114,255,9);
            startpath();
            lineto(65,35);
            lineto(55,65);
            lineto(45,65);
            endpath();
            fillandstrokepath();
//            return;
//      }            
      if (HasTag("Run Status", "Failed"))
      {
            setfillcolor ( 255, 9, 9);
            
            moveto(55,35);
            startpath();
            lineto(65,35);
            lineto(55,65);
            lineto(45,65);
            endpath();
            fillandstrokepath();
            return;      
      }
}

// 2 - Development Status
decoration DevelopmentStatus
{
      preferredHeight = 100;
      preferredWidth = 100;
      noshadow = "true";
      h_align  =  "center";
      v_align  =  "center";
      orientation="NE";
        SetOrigin("NW",0,0);
      //orientation = "NE";
      setpencolor ( 122,122,122); //r, g, b
      setpenwidth(1);
//      if (HasTag("Development Status", "Not Started"))
//      {
            moveto(70,35);
            setfillcolor ( 0,0,0);
            startpath();
            lineto(80,35);
            lineto(70,65);
            lineto(60,65);
            endpath();
            fillandstrokepath();
//            return;
//      }
      if (HasTag("Development Status", "In Development"))
      {
            setfillcolor ( 255,255,0);
      
            moveto(70,35);
            startpath();
            lineto(80,35);
            lineto(70,65);
            lineto(60,65);
            endpath();
            fillandstrokepath();
            return;
      }
      if (HasTag("Development Status", "For Review"))
      {
            setfillcolor ( 255,138,9);
            
            moveto(70,35);
            startpath();
            lineto(80,35);
            lineto(70,65);
            lineto(60,65);
            endpath();
            fillandstrokepath();
            return;
      }
      if (HasTag("Development Status", "Ready To Run"))
      {
            setfillcolor ( 114,255,9);
            
            moveto(70,35);
            startpath();
            lineto(80,35);
            lineto(70,65);
            lineto(60,65);
            endpath();
            fillandstrokepath();
            return;
      }
      if (HasTag("Development Status", "Blocked"))
      {
            setfillcolor ( 255,9,9);
            
            moveto(70,35);
            startpath();
            lineto(80,35);
            lineto(70,65);
            lineto(60,65);
            endpath();
            fillandstrokepath();
            return;
      }
}
      

      
// 3 - Regression tag
decoration RegressionTag
{      
      preferredHeight = 100;
      preferredWidth = 100;
      noshadow = "true";
      h_align  =  "center";
      v_align  =  "center";
      orientation="NE";
        SetOrigin("NW",0,0);
      setpencolor ( 122,122,122); //r, g, b
      setpenwidth(1);
      //orientation = "NE";
//      if (HasTag("IsRegression", "true"))
//      {
            moveto(80,35);
            setfillcolor(128,0,64);
            startpath();
            lineto(90,35);
            lineto(95,40);
            lineto(95,45);
            lineto(90,50);
            lineto(95,65);
            lineto(90,65);
            lineto(85,55);
            lineto(85,65);
            lineto(80,65);
            lineto(80,35);
            endpath();
            fillandstrokepath();
            
            //part 2
            moveto(85,40);
            setfillcolor( 188, 186, 150);
            startpath();
            lineto(89,40);
            lineto(89,45);
            lineto(85,45);
            endpath();
            fillandstrokepath();
//            return;
//      }
}

« Last Edit: September 24, 2010, 11:06:15 pm by bstdnator »

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: EA 6.1 Shape Script - sub shape / decoration
« Reply #1 on: September 27, 2010, 08:41:41 am »
Hi George,

PreferredHeight and PreferredWidth don't work with decoration shapes - decorations are always 16 x 16. You can go outside this size limit by going over 100% or going negative with your moveto() and lineto() commands.

Cool spanner, btw :)

Neil
« Last Edit: September 27, 2010, 08:42:09 am by KP »
The Sparx Team
[email protected]

GeorgeStClair

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: EA 6.1 Shape Script - sub shape / decoration
« Reply #2 on: September 27, 2010, 07:01:15 pm »
Hi Neil,

Thank you for your response. Having implemented this solution today I notice that the embellishment does not scale with the rest of the shape (and so is not displayed where i wish it to be).

Is it possible to achieve the desired result using 'shape' instead of 'decoration' and then addSubShape() ? When i've tired this they simply do not appear on top of my spanner, can you advise?
« Last Edit: September 27, 2010, 08:00:35 pm by bstdnator »