Book a Demo

Author Topic: suppress stereotyp icon in own profile  (Read 9055 times)

JoMa

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
suppress stereotyp icon in own profile
« on: April 08, 2015, 06:52:02 pm »
Hi everyone,

I've created a SysML-profile refining the metaclass "property". Everything works fine, except I get an Icon on the top right corner everytime I use my own property. It can be hidden by changing diagram settings (Elements|Use Stereotyp Icons), but I'd like to hide it by default or even better define my own or no icon. Is there a way to do this?
I also refined a block, which more or less overwrites the SysML <<block>>. Here no such things happen.

Thanks in advance!

Markus

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: suppress stereotyp icon in own profile
« Reply #1 on: April 08, 2015, 08:30:48 pm »
Have you tried assigning a shape script?

q.

JoMa

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: suppress stereotyp icon in own profile
« Reply #2 on: April 08, 2015, 09:00:29 pm »
yes, the own property appearance is changed by a shape script using two decorations. But the one on the upper right corner is not mine  ;)

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: suppress stereotyp icon in own profile
« Reply #3 on: April 08, 2015, 10:28:01 pm »
Would you mind to post your script?

q.

JoMa

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: suppress stereotyp icon in own profile
« Reply #4 on: April 08, 2015, 10:38:13 pm »
Hi,

here is the script. It does mainly evaluate the tagged values to draw two decorations (ASIL and element type). Now there is also the problem that the upper left decoration is drawn above the element name. It's a matter of the element size and name length, but looks ugly. Showing the stereotype by name helps but looks ugly, too.

Code: [Select]
shape main
{
      drawnativeshape();
      if (HasTag("ElementType","mechanical"))
      {
            setfillcolor(192,192,192);
            drawnativeshape();
            return;
      }
      if (HasTag("ElementType","electrical"))
      {
            setfillcolor(234,128,102);
            drawnativeshape();
            return;
      }
      if (HasTag("ElementType","logical"))
      {
            setfillcolor(204,255,204);
            drawnativeshape();
            return;
      }
      if (HasTag("ElementType","functional"))
      {
            drawnativeshape();
            return;
      }
}

decoration Type
{      
      orientation = "SW";
      if (HasTag("ElementType","mechanical"))
      {
            println("mech");
            return;
      }
      if (HasTag("ElementType","electrical"))
      {
            println("eHW");
            return;
      }
      if (HasTag("ElementType","logical"))
      {
            println("SW");
            return;
      }
      if (HasTag("ElementType","functional"))
      {
            println("Fct");
            return;
      }
}

decoration SIL
{
      orientation = "NW";
      if (HasTag("SafetyIntegrity"))
      {
            startpath();
            moveto(0,0);
            lineto(100,0);
            lineto(100,100);
            lineto(0,100);
            endpath();
      }
      
      // ASIL QM
      if (HasTag("SafetyIntegrity","ASIL QM"))
      {
            setfillcolor(0, 255, 0);
            fillandstrokepath();
            println("QM");
            return;
      }
      if (HasTag("SafetyIntegrity","ASIL QM(A)"))
      {
            setfillcolor(0, 255, 0);
            fillandstrokepath();
            println("QM(A)");
            return;
      }
      if (HasTag("SafetyIntegrity","ASIL QM(B)"))
      {
            setfillcolor(0, 255, 0);
            fillandstrokepath();
            println("QM(B)");
            return;
      }
      if (HasTag("SafetyIntegrity","ASIL QM(C)"))
      {
            setfillcolor(0, 255, 0);
            fillandstrokepath();
            println("QM(C)");
            return;
      }
      if (HasTag("SafetyIntegrity","ASIL QM(D)"))
      {
            setfillcolor(0, 255, 0);
            fillandstrokepath();
            println("QM(D)");
            return;
      }
      
      // ASIL A
      if (HasTag("SafetyIntegrity","ASIL A"))
      {
            setfillcolor(255, 255, 0);
            fillandstrokepath();
            print("A");
            return;
      }
      if (HasTag("SafetyIntegrity","ASIL A(B)"))
      {
            setfillcolor(255, 255, 0);
            fillandstrokepath();
            print("A(B)");
            return;
      }
      if (HasTag("SafetyIntegrity","ASIL A(C)"))
      {
            setfillcolor(255, 255, 0);
            fillandstrokepath();
            print("A(C)");
            return;
      }
      if (HasTag("SafetyIntegrity","ASIL A(D)"))
      {
            setfillcolor(255, 255, 0);
            fillandstrokepath();
            print("A(D)");
            return;
      }
      
      // ASIL B
      if (HasTag("SafetyIntegrity","ASIL B"))
      {
            setfillcolor(255, 104, 32);
            fillandstrokepath();
            println("B");
            return;
      }
      if (HasTag("SafetyIntegrity","ASIL B(C)"))
      {
            setfillcolor(255, 104, 32);
            fillandstrokepath();
            println("B(C)");
            return;
      }
      if (HasTag("SafetyIntegrity","ASIL B(D)"))
      {
            setfillcolor(255, 104, 32);
            fillandstrokepath();
            println("B(D)");
            return;
      }
      
      // ASIL C
      if (HasTag("SafetyIntegrity","ASIL C"))
      {
            setfillcolor(255, 0, 0);
            fillandstrokepath();
            println("C");
            return;
      }
      if (HasTag("SafetyIntegrity","ASIL C(D)"))
      {
            setfillcolor(255, 0, 0);
            fillandstrokepath();
            println("C(D)");
            return;
      }
      // ASIL D
      if (HasTag("SafetyIntegrity","ASIL D"))
      {
            setfillcolor(192, 0, 157);
            fillandstrokepath();
            println("D");
            return;
      }
}

Thanks,
Markus

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: suppress stereotyp icon in own profile
« Reply #5 on: April 08, 2015, 11:21:28 pm »
I guess the drawNativeShape is the culprit. It will (IIRC) draw the shape from the inherited stereotype. Try removing it.

q.

JoMa

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: suppress stereotyp icon in own profile
« Reply #6 on: April 08, 2015, 11:35:11 pm »
I already assumed that ... unfortunately I will need to completely redesign the shape then ... without having bold font of the name and loosing some possibilities to manipulate the diagrams, I guess.

Luckily I found a good book about how to make Shape Script easy  ;)

Thanks anyway!

Markus

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: suppress stereotyp icon in own profile
« Reply #7 on: April 08, 2015, 11:50:45 pm »
 :D - You can't have the cake and eat it the same time

q.

JoMa

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: suppress stereotyp icon in own profile
« Reply #8 on: April 09, 2015, 12:17:19 am »
You are right ...

Maybe this is off topic, but is there a way to detect whether "Show Stereotype Icon" in the diagram properties is enabled or not?
Using a complete own shape will not work with "Feature and Compartment Visibility ...", won't it?

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: suppress stereotyp icon in own profile
« Reply #9 on: April 09, 2015, 10:00:45 am »
Is your property stereotype named «property»? Because that specific stereotype puts an icon decoration in the top right corner. (I wish it didn't, but it's not going to change). Choose any other name for your stereotype and it won't be an issue.

Alternatively, you can define a custom diagram type that has the "Use Stereotype Icons" option switched off by default, and always use that diagram type.

Quote
is there a way to detect whether "Show Stereotype Icon" in the diagram properties is enabled or not?
Sorry, no. Send in a feature request.
The Sparx Team
[email protected]

JoMa

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: suppress stereotyp icon in own profile
« Reply #10 on: April 09, 2015, 08:43:59 pm »
That's it! My intention was to somehow overwrite the original Property, which has no stereotype at all by default. It worked for <<block>> by extending the UML::Class and using _metatype = Block and naming the new stereotype "block".
How to do this with a property so new elements have Type = Property but no stereotype?
« Last Edit: April 09, 2015, 08:44:52 pm by JOSTMRK »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: suppress stereotyp icon in own profile
« Reply #11 on: April 10, 2015, 03:36:07 am »
Quote
is there a way to detect whether "Show Stereotype Icon" in the diagram properties is enabled or not?
Check t_diagram.PDATA for ShowIcons and HideEStereo. They either set to 0, 1 or not present at all. Also look on p. 47 of my Inside book.

q.
« Last Edit: April 10, 2015, 03:41:11 am by qwerty »