Author Topic: MDG - Cannot get SetPenWidth Shapescript to work  (Read 585 times)

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1210
  • Karma: +37/-2
    • View Profile
    • www.umlchannel.com
MDG - Cannot get SetPenWidth Shapescript to work
« on: September 01, 2022, 06:35:45 pm »
Hi,

I defined a SysML block stereotype within an MDG with a Type enum tagged value.
I'm trying to change the border colour and width according to the selected type value.

The colour is properly updated, yet I can't get the line width as expected.

Below is an example. I also tried moving DrawNativeShape at the beginning.

Code: [Select]
shape main{
      if (HasTag('Type','TypeA'))
     {
SetPenWidth(3);
SetPenColor(190, 30, 0);
    }
      if (HasTag('Type','TypeB'))
     {
SetPenWidth(3);
SetPenColor(255, 30, 0);
    }
    DrawNativeShape();
}


Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com


Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8317
  • Karma: +235/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: MDG - Cannot get SetPenWidth Shapescript to work
« Reply #1 on: September 01, 2022, 07:33:08 pm »
Hi,

I defined a SysML block stereotype within an MDG with a Type enum tagged value.
I'm trying to change the border colour and width according to the selected type value.

The colour is properly updated, yet I can't get the line width as expected.

Below is an example. I also tried moving DrawNativeShape at the beginning.

Code: [Select]
shape main{
      if (HasTag('Type','TypeA'))
     {
      SetPenWidth(3);
      SetPenColor(190, 30, 0);
    }
      if (HasTag('Type','TypeB'))
     {
      SetPenWidth(3);
      SetPenColor(255, 30, 0);
    }
    DrawNativeShape();
}
Hi Guillaume,
I don't think we've had trouble with pen width in our shapescripts (and we use it a lot, both for vertex and arc shapescripts), but a couple of points to think about.
Firstly, since you already know the colour and width for each condition.  Change the function to setpen(R,G,B,with).  See if that works.  If so, then report a defect.  Also, maybe try changing the order, setting colour then pen width.
Also, I hope you've got the closing bracket in your code.  I've had all sorts of issues with the trailing "}" accidentally missing!

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

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1210
  • Karma: +37/-2
    • View Profile
    • www.umlchannel.com
Re: MDG - Cannot get SetPenWidth Shapescript to work
« Reply #2 on: September 01, 2022, 08:01:46 pm »
Hi Paolo,

Thank you for your suggestion. I tried all options without any luck.
For some reasons it's not picked up when calling DrawNativeShape. I tried using Rectangle(0,0,100,100) which works but this is not ideal as it would need to redefine the whole rendering.
It's been reported to Sparx.

« Last Edit: September 01, 2022, 10:20:06 pm by Guillaume »
Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com


Modesto Vega

  • EA User
  • **
  • Posts: 880
  • Karma: +23/-8
    • View Profile
Re: MDG - Cannot get SetPenWidth Shapescript to work
« Reply #3 on: September 01, 2022, 11:49:48 pm »
Hi Guillaume,

I think the problem is that you are drawing a native shape.

By the way, we use legends to achieve what you are after.

qwerty

  • EA Guru
  • *****
  • Posts: 12966
  • Karma: +370/-298
  • I'm no guru at all
    • View Profile
Re: MDG - Cannot get SetPenWidth Shapescript to work
« Reply #4 on: September 02, 2022, 05:07:44 am »
The setpenwidth only works for lines you draw yourself. It does not work on the native shape's ilnes. I for myself would regard it a bug. But usually it's futile to report such errors to Sparx :-/

q.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8317
  • Karma: +235/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: MDG - Cannot get SetPenWidth Shapescript to work
« Reply #5 on: September 02, 2022, 08:31:15 am »
The setpenwidth only works for lines you draw yourself. It does not work on the native shape's lines. I for myself would regard it as a bug. But usually, it's futile to report such errors to Sparx :-/

q.
I didn't know that.  Probably because (like Modesto) we use other techniques (in our case, MDG default rendering for the basic shape and legends for dynamic) for rendering of native shape.

Paolo
« Last Edit: September 02, 2022, 08:33:02 am by Paolo F Cantoni »
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1210
  • Karma: +37/-2
    • View Profile
    • www.umlchannel.com
Re: MDG - Cannot get SetPenWidth Shapescript to work
« Reply #6 on: September 02, 2022, 06:49:03 pm »
Hello,

Thank you for your replies.
Diagram legends is a good workaround especially as it can be useful to show the colour definition on the diagrams.
Yet I would like the border width to be managed via the Shapescript when DrawNativeShape is called, since after all it the fill and border colors work great.

Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com


Modesto Vega

  • EA User
  • **
  • Posts: 880
  • Karma: +23/-8
    • View Profile
Re: MDG - Cannot get SetPenWidth Shapescript to work
« Reply #7 on: September 02, 2022, 07:26:01 pm »
Hello,

Thank you for your replies.
Diagram legends is a good workaround especially as it can be useful to show the colour definition on the diagrams.
Yet I would like the border width to be managed via the Shapescript when DrawNativeShape is called, since after all it the fill and border colors work great.
One of the reasons why we prefer to use legends instead of setting the line width and colour, and the shape fill through a ShapeScript is to avoid "collisions" between the ShapeScripts and the legends. Sparx EA does not handle those collisions very well. For example, if you set the pen width to 4, the pen colour to dark blue, and the fill colour to light blue through a ShapeScript, (from memory) you cannot consistently change all of those settings through a legend when used in specific diagrams.