Book a Demo

Author Topic: SetFixedRegion crashes EA?  (Read 10637 times)

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
SetFixedRegion crashes EA?
« on: July 09, 2016, 03:53:59 pm »
I must be doing something wrong.
I'm trying to replicate the behavior of the standard requirements that have a left border block that only sizes vertically, but stays the same width.

I thought I might use the SetFixedRegion() command to get that effect, but when I try it EA crashes hard getting the processor up to 100%
And this is repeated every time EA tries to execute the shape script.

Anyone know how to use the SetFixedRegion() correctly?

Here the shapescript that makes EA crash. Removing the SetFixedRegion fixes the crash.

Code: [Select]
shape main
{
 layouttype = "leftright";
 h_align = "left";
 v_align = "center";
 DefSize(150,35);
 SetFixedRegion(0,0,30,100);
 Addsubshape("borderBlock",30,100,0,0);
 Addsubshape("S",15,90,-28,2);
 SetFillColor(GetDefaultFillColor());
 SetPenColor(GetDefaultFillColor());
 AddSubShape("nameCompartment",70,100,-15,0);
 
shape borderBlock
{
SetFillColor(GetStatusColor());
SetPenColor(GetUserBorderColor());
rectangle(0,0,100,100);
}
shape nameCompartment
{
h_align = "center";
v_align = "center";
editablefield = "name";
SetPenColor(GetUserBorderColor());
Rectangle(0,0,100,100);
SetFontColor(0,0,0);
println("#name#");
}
shape S
{
setpencolor(255,255,255);
//left vertical line
SetPenWidth(2);
moveto(2,68);
lineto(2,100);
//bottom arc
moveto(2,77);
arcto(2,58,96,97,4,77,83,64);
SetPenWidth(2);
//diagonal
lineto(8,25);
//top arc
moveto(82,17);
arcto(5,3,82,34,82,17,10,33);
//right vertical
moveto(82,0);
lineto(82,31);
}
}

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: SetFixedRegion crashes EA?
« Reply #1 on: July 09, 2016, 04:38:49 pm »
SetFixedRegion sounds new to me. I had been looking for something like that some time ago with no success. So you should send a bug report.

q.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: SetFixedRegion crashes EA?
« Reply #2 on: July 09, 2016, 11:34:25 pm »
I use setfixedregion() quite a bit, but only on connectors.  I thought it was only for connectors.  The help implies that.

It's working OK for me under 12 and 13.

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

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: SetFixedRegion crashes EA?
« Reply #3 on: July 10, 2016, 12:31:14 am »
To complete what Paolo states:
Quote
Fixes a region in a connector into which a sub-shape can be drawn, so that the sub-shape is not rescaled with the length or orientation of the connector line.

For an example, see the 'Rotation Direction' script in the Example Scripts topic.

However, there's no reason to crash EA on wrong use. It should issue a warning when saving the script instead.

q.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: SetFixedRegion crashes EA?
« Reply #4 on: July 10, 2016, 05:15:09 am »
I use setfixedregion() quite a bit, but only on connectors.  I thought it was only for connectors.  The help implies that.

It's working OK for me under 12 and 13.

HTH,
Paolo
Yes it does, but Simon used it on a regular shape too in this thread, so I thought I'd give it a go.

I guess I just need to report it as a bug

Geert

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: SetFixedRegion crashes EA?
« Reply #5 on: July 11, 2016, 09:36:16 am »
It was intended for connectors, but I have found it useful on some element shape scripts.

My first thought was that the subshapes were causing an issue. Then I noticed the negatives in your script... I haven't had a chance to test it yet, but I'd wager that's what is causing the fixed region to fail.

PS. I'd describe this as a hang rather than a crash.
but when I try it EA crashes hard getting the processor up to 100%
I would define a crash as doing something that causes the operating system to terminate it without warning. A hang means the application will stop responding, and usually the OS will let you know and give you the option of terminating it. (But you can get that message at other times too)
« Last Edit: July 11, 2016, 09:42:09 am by Simon M »

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: SetFixedRegion crashes EA?
« Reply #6 on: July 11, 2016, 01:23:27 pm »
PS. I'd describe this as a hang rather than a crash.
but when I try it EA crashes hard getting the processor up to 100%
I would define a crash as doing something that causes the operating system to terminate it without warning. A hang means the application will stop responding, and usually the OS will let you know and give you the option of terminating it. (But you can get that message at other times too)
Hi Simon,

From your perspective that might be a big difference, but from a user perspective it isn't.
In both cases the application cannot be used anymore

Geert

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: SetFixedRegion crashes EA?
« Reply #7 on: July 11, 2016, 02:04:52 pm »
SetFixedRegion is a sub-optimal way to do what you are trying to do.

Instead, I would recommend using a border layout, which has always provided the capability of setting a fixed height or width. It can be nested to include multiple subshapes. But you could do the same by splitting the one subshape in two as well.

Code: [Select]
shape main
{
layouttype = "border";
AddSubShape("left", "W");
AddSubShape("rest", "CENTER");

shape left
{
preferredwidth=10;
setfillcolor(getstatuscolor());
rectangle(0,0,90,100);
}

shape rest
{
layouttype = "border";
AddSubShape("S", "W");
AddSubShape("namepart", "CENTER");
shape S
{
preferredwidth=20;
setpencolor(255,255,255);
//left vertical line
SetPenWidth(2);
moveto(2,68);
lineto(2,100);
//bottom arc
moveto(2,77);
arcto(2,58,96,97,4,77,83,64);
SetPenWidth(2);
//diagonal
lineto(8,25);
//top arc
moveto(82,17);
arcto(5,3,82,34,82,17,10,33);
//right vertical
moveto(82,0);
lineto(82,31);
}
shape namepart
{
h_align = "left";
v_align = "center";
rectangle(0,0,100,100);
println("#name#");
}
}

}

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: SetFixedRegion crashes EA?
« Reply #8 on: July 11, 2016, 02:16:26 pm »
SetFixedRegion is a sub-optimal way to do what you are trying to do.

Instead, I would recommend using a border layout, which has always provided the capability of setting a fixed height or width. It can be nested to include multiple subshapes. But you could do the same by splitting the one subshape in two as well.

Code: [Select]
shape main
{
layouttype = "border";
AddSubShape("left", "W");
AddSubShape("rest", "CENTER");

shape left
{
preferredwidth=10;
setfillcolor(getstatuscolor());
rectangle(0,0,90,100);
}

shape rest
{
layouttype = "border";
AddSubShape("S", "W");
AddSubShape("namepart", "CENTER");
shape S
{
preferredwidth=20;
setpencolor(255,255,255);
//left vertical line
SetPenWidth(2);
moveto(2,68);
lineto(2,100);
//bottom arc
moveto(2,77);
arcto(2,58,96,97,4,77,83,64);
SetPenWidth(2);
//diagonal
lineto(8,25);
//top arc
moveto(82,17);
arcto(5,3,82,34,82,17,10,33);
//right vertical
moveto(82,0);
lineto(82,31);
}
shape namepart
{
h_align = "left";
v_align = "center";
rectangle(0,0,100,100);
println("#name#");
}
}

}

Super! Thanks Simon!

That's going to make my client happy :)

Geert

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: SetFixedRegion crashes EA?
« Reply #9 on: July 11, 2016, 02:35:53 pm »
From your perspective that might be a big difference, but from a user perspective it isn't.
In both cases the application cannot be used anymore
Absolutely, at one point before I hit post, I described it as a subtle distinction. I was also thinking of including a comment that the result is the same from an user perspective. They lose any unsaved information. In the end I thought that my pedantry had gone far enough and left it out.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: SetFixedRegion crashes EA?
« Reply #10 on: July 11, 2016, 04:53:27 pm »
From your perspective that might be a big difference, but from a user perspective it isn't.
In both cases the application cannot be used anymore
Absolutely, at one point before I hit post, I described it as a subtle distinction. I was also thinking of including a comment that the result is the same from an user perspective. They lose any unsaved information. In the end I thought that my pedantry had gone far enough and left it out.
Wot?  Not enough pedantry?   ;D

Couldn't resist....  ;)

Paolo

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

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: SetFixedRegion crashes EA?
« Reply #11 on: July 12, 2016, 04:37:42 am »
Thanks to Simon's suggestion I now have a shapescript that does exactly what I want it to do.
The left block stays the same width no matter how the element is resized

Code: [Select]
shape main
{
 layouttype = "border";
 h_align = "left";
 v_align = "center";
 DefSize(150,35);
 Addsubshape("borderBlock","W");

 SetFillColor(GetDefaultFillColor());
 SetPenColor(GetDefaultFillColor());
 AddSubShape("nameCompartment","CENTER");
 
shape borderBlock
{
layouttype = "leftright";
preferredWidth=35;
SetFillColor(GetStatusColor());
SetPenColor(GetUserBorderColor());
rectangle(0,0,100,100);
AddSubShape("S",40,80,10,10);
AddSubShape("R",40,80,12,10);
shape S
{
setpencolor(0,0,0);
SetPenWidth(2);
//left vertical line
moveto(2,68);
lineto(2,100);
//bottom arc
moveto(2,77);
arcto(5,58,96,97,5,80,83,64);
//diagonal
lineto(8,25);
//top arc
moveto(82,17);
arcto(5,3,82,34,82,17,10,33);
//right vertical
moveto(82,0);
lineto(82,31);
}
shape R
{
SetPenWidth(2);
setpencolor(0,0,0);
//left vertical
lineto(23,0);
lineto(23,100);
moveto(0,100);
lineto(44,100);
//right leg
moveto(100,100);
lineto(79,100);
lineto(44,50);
lineto(23,50);
moveto(44,50);
//belly
arcto(13,1,70,50,44,51,44,0);
lineto(23,0);
}
}
shape nameCompartment
{
h_align = "center";
v_align = "center";
editablefield = "name";
SetPenColor(GetUserBorderColor());
Rectangle(0,0,100,100);
SetFontColor(0,0,0);
println("#name#");
}

}

Geert