Sparx Systems Forum

Enterprise Architect => General Board => Topic started by: rupertkiwi on September 19, 2019, 08:20:29 am

Title: Shapescript decorations
Post by: rupertkiwi on September 19, 2019, 08:20:29 am
Hi there,

Does anyone have shapescript decorations for the following:

Tick
Cross
Question Mark

Many thanks,
Rupert
Title: Re: Shapescript decorations
Post by: Eve on September 19, 2019, 10:03:19 am
My rough attempts.

Code: [Select]
decoration tick
{
orientation="NW";
SetPenWidth(2);
moveto(10,60);
lineto(40,90);
lineto(90,10);
}

decoration cross
{
orientation="NE";
SetPenWidth(2);
moveto(10,10);
lineto(90,90);
moveto(90,10);
lineto(10,90);
}

decoration question
{
orientation="SW";
SetPenWidth(2);
moveto(10,40);
BezierTo(10,20,30,10,50,10);
BezierTo(70,10,90,30,90,40);
BezierTo(90,60,50,70,50,90);

Ellipse(49,95,51,97);
}
Title: Re: Shapescript decorations
Post by: Paolo F Cantoni on September 19, 2019, 10:05:52 am
Hi there,

Does anyone have shapescript decorations for the following:

Tick
Cross
Question Mark

Many thanks,
Rupert
Hi Rupert,

a couple of questions and observations.

I presume that's an "x" cross and not a "t" cross.
I don't have such scripts (thanks, Eve), but I do have a pile of "shapescript assets" which are kept in a special folder for re-use in shapescripts.  Perhaps we should start a repository for them?

Paolo
Title: Re: Shapescript decorations
Post by: Geert Bellekens on September 19, 2019, 01:05:21 pm
Hi there,

Does anyone have shapescript decorations for the following:

Tick
Cross
Question Mark

Many thanks,
Rupert
Hi Rupert,

a couple of questions and observations.

I presume that's an "x" cross and not a "t" cross.
I don't have such scripts (thanks, Eve), but I do have a pile of "shapescript assets" which are kept in a special folder for re-use in shapescripts.  Perhaps we should start a repository for them?

Paolo
I started such a repository a while ago: https://github.com/GeertBellekens/Enterprise-Architect-Shapescript-Library (https://github.com/GeertBellekens/Enterprise-Architect-Shapescript-Library)

Geert
Title: Re: Shapescript decorations
Post by: Paolo F Cantoni on September 19, 2019, 01:31:12 pm
[SNIP]

I started such a repository a while ago: https://github.com/GeertBellekens/Enterprise-Architect-Shapescript-Library (https://github.com/GeertBellekens/Enterprise-Architect-Shapescript-Library)

Geert
Yes, Geert,

I knew about that.  But that holds full shapescripts.  Would it be appropriate to add a folder for "Assets" which are "fragments" of shapescripts -Like the decorations Rupert mentioned?

Paolo
Title: Re: Shapescript decorations
Post by: Geert Bellekens on September 19, 2019, 01:36:21 pm
[SNIP]

I started such a repository a while ago: https://github.com/GeertBellekens/Enterprise-Architect-Shapescript-Library (https://github.com/GeertBellekens/Enterprise-Architect-Shapescript-Library)

Geert
Yes, Geert,

I knew about that.  But that holds full shapescripts.  Would it be appropriate to add a folder for "Assets" which are "fragments" of shapescripts -Like the decorations Rupert mentioned?

Paolo
Sure we can do that.

Geert
Title: Re: Shapescript decorations
Post by: Paolo F Cantoni on September 19, 2019, 01:42:40 pm
[SNIP]

Sure we can do that.

Geert
OK, so we might have subfolders for decorations, main shapes, target shapes, source shapes, other shapes, code snippets etc?  You get the idea.

Paolo
Title: Re: Shapescript decorations
Post by: rupertkiwi on September 19, 2019, 03:04:46 pm
Thanks for everyone's help.

Does anyone know how to draw a vertical compartment on an element?

Rupert
Title: Re: Shapescript decorations
Post by: Eve on September 19, 2019, 05:20:06 pm
Quick improvement on the question mark. Looks nicer to my eyes at least.
Code: [Select]
decoration question
{
orientation="SW";
SetPenWidth(2);
moveto(50,80);
bezierto(50,60,70,50,70,40);
arcto(30,10,70,70,90,40,10,40);
SetPenWidth(1);
Ellipse(46,91,54,99);
}

What do you mean by a vertical compartment?
Title: Re: Shapescript decorations
Post by: rupertkiwi on September 20, 2019, 07:54:53 am
Hi Eve,

Yes, that question mark looks better now.

What I would like is a vertical compartment on the left hand side of an element that I can colour in depending on its tagged value.

And then I would like horizontal compartments in the remaining space of the element to display the text from other tagged values.

Is that possible?

I only seem to be able to 'stack' horizontal compartments one on top of the other currently.

Thanks,
Rupert
Title: Re: Shapescript decorations
Post by: KP on September 20, 2019, 08:42:04 am
If you use the "border" layout type, you can add a sub shape on the "west" edge like so:

Code: [Select]
shape main
{
layouttype="border";
rectangle(0,0,100,100);

addsubshape("vert","W");

shape vert
{
preferredwidth=15;
setfillcolor(255,0,0);
rectangle(0,0,100,100);
}
}

Or East edge. If you want North or South edge, set a preferredheight value. And you can nest the layouttypes, so you can add a sub shape to the "center" (i.e. the rest of the shape) and that sub shape can have layouttype set to "topdown" or "leftright".
Title: Re: Shapescript decorations
Post by: rupertkiwi on September 20, 2019, 09:37:33 am
Thanks KP, that works. well.

However I am trying to 'colour' the vertical compartment based on a tagged value :

shape main
{
   layouttype="border";
 noshadow = "true";
 h_align = "left";
   setfillcolor(255,255,255);
 DefSize(340,140);
 roundRect(0,0,100,100,10,10);
 AddSubShape("nameCompartment","N");
 AddSubShape("translations","S");
 AddSubShape("vert","W");
   
   shape vert
   {
      preferredwidth=15;
      rectangle(0,0,100,100);
                  if(hastag("Capability","Manage Customers, Sales, Billing, Products & Services"))
   {
setfillcolor(0, 177, 195);
   }
   }

 shape nameCompartment
 {
    layouttype="topdown";
   h_align = "center";
   editablefield = "name";
   SetFontColor(128,0,0);
   println("#name#");
  }
 
 shape translations
  {
      h_align="CENTER";
      v_align="BOTTOM";
   println("GM: #TAG:GM#");
  }

}
      
   
But I can't seem to get the vertical compartment to colour in.

Do you have any ideas?

Thanks,
Rupert

Title: Re: Shapescript decorations
Post by: Paolo F Cantoni on September 20, 2019, 09:47:34 am
Rupert,

AFAIK, the HasTag function only compares to a single value.  If you are comparing using an Inclusive OR, you'll need to have four HasTag expressions.

HTH,
Paolo
Title: Re: Shapescript decorations
Post by: rupertkiwi on September 20, 2019, 10:01:30 am
Hi Paolo,

Yes, that's fine having several HasTag statements. I just can't seem to get the compartment to colour in.

Thanks,
Rupert
Title: Re: Shapescript decorations
Post by: KP on September 20, 2019, 10:02:06 am
   shape vert
   {
      preferredwidth=15;
      rectangle(0,0,100,100);
                  if(hastag("Capability","Manage Customers, Sales, Billing, Products & Services"))
   {
setfillcolor(0, 177, 195);
   }
   }

The setfillcolor() has to be before the rectangle()
Title: Re: Shapescript decorations
Post by: rupertkiwi on September 20, 2019, 10:16:38 am
Yes ! That works great, many thanks for your help
Title: Re: Shapescript decorations
Post by: rupertkiwi on September 20, 2019, 10:19:04 am
Also, what is the best practice for using shapescripts?

Should they be applied to a stereotype at a model or profile level?

What if you want the tagged values for the element represented differently in different diagrams?

Rupert
Title: Re: Shapescript decorations
Post by: Paolo F Cantoni on September 20, 2019, 10:39:51 am
Also, what is the best practice for using shapescripts?

Should they be applied to a stereotype at a model or profile level?

What if you want the tagged values for the element represented differently in different diagrams?

Rupert
We do it at the profile level.

If you want the shapescript to react to different digrams, you need to have a method for identifying the trigger.

We use a mixture of diagram.stereotype, diagram.mdgtype and diagram.name (as required).

HTH,
Paolo
Title: Re: Shapescript decorations
Post by: Geert Bellekens on September 21, 2019, 03:06:47 am
I've done something similar here:

https://github.com/GeertBellekens/Enterprise-Architect-Shapescript-Library/blob/master/RM%20Requirements/process_heatmap.shapescript (https://github.com/GeertBellekens/Enterprise-Architect-Shapescript-Library/blob/master/RM%20Requirements/process_heatmap.shapescript)

Geert