Closed dgutson closed 2 years ago
Hi! I assume with "Robot" you mean an automated system that represents the User?
The reason for asking is that, looking at the C4 documentation, I can not find mention of the Robot shape.
It is currently already possible to change the sprite for a user, using a parameter $sprite="{name-of-sprite}"
:
@startuml
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/v2.4.0/C4_Container.puml
!include https://raw.githubusercontent.com/tupadr3/plantuml-icon-font-sprites/v2.4.0/font-awesome-5/robot.puml
LAYOUT_WITH_LEGEND()
Person(user, "Robot", "Non-human User", $sprite="robot")
Container(container, "Some Container", "Technology", "Optional Description", $sprite="robot")
System(system, "Some System", "Also non-human", $sprite="robot")
Rel(user, container, "Label", "Technology")
Rel(system, container, "Label", "Other Technology")
@enduml
Would that suffice for your use-case?
Hi! I assume with "Robot" you mean an automated system that represents the User?
Yes, for example a user of an API, or automation.
The reason for asking is that, looking at the C4 documentation, I can not find mention of the Robot shape.
Oh yes there it is: https://github.com/structurizr/dsl/blob/master/docs/language-reference.md#element-style check the Robot shape.
It is currently already possible to change the sprite for a user, using a parameter
$sprite="{name-of-sprite}"
:
I actually did that, imported the sprite, etc. But it would be much simpler if I could just name the sprite "robot" in the same sense I can with "person" and "person2".
The reason for asking is that, looking at the C4 documentation, I can not find mention of the Robot shape.
Correct. A point many people miss is that C4 model does not prescribe any notation in terms of colours, shapes, etc. From https://c4model.com/#Notation
Oh yes there it is: https://github.com/structurizr/dsl/blob/master/docs/language-reference.md#element-style check the Robot shape.
The robot shape you're referring to is from the Structurizr tooling, which is my implementation of a tool that supports the C4 model. It also implements many other shapes too, but these aren't a part of the C4 model. C4 model != Structurizr.
@simonbrowndotje Thank you for chiming in!
Adding other shapes was discussed in more detail in #145. As Simon mentioned, C4 model != Structurizr. We do not want to make this project a copy of Structuriz or add (too many) new shapes, otherwise we would have to make a very generic implementation and we lose the C4 relation and create a new "Meta" notation.
There is also the problem that there is no "Robot" equivalent shape in PlantUML, so we would need to fall back to using sprites anyway (which is already possible).
It would be possible to create a Robot
and Robot_Ext
method yourself, but I am not convinced that would be more productive than just using icons.
To give you an idea what such an implementation would look like:
!global $ROBOT_SHAPE = "actor"
!global $ROBOT_BG_COLOR = "#0D559C"
!global $ROBOT_BORDER_COLOR = "#0D559C"
!global $EXTERNAL_ROBOT_BG_COLOR = "#7E7E7E"
!global $EXTERNAL_ROBOT_BORDER_COLOR = "#7E7E7E"
!global $defaultRobotSprite = "robot"
AddElementTag('robot', $bgColor=$ROBOT_BG_COLOR, $borderColor=$ROBOT_BORDER_COLOR, $sprite=$defaultRobotSprite)
AddElementTag('external_robot', $bgColor=$EXTERNAL_ROBOT_BG_COLOR, $borderColor=$EXTERNAL_ROBOT_BORDER_COLOR, $sprite=$defaultRobotSprite)
UpdateElementStyle("robot", $ROBOT_BG_COLOR, $ELEMENT_FONT_COLOR, $ROBOT_BORDER_COLOR)
UpdateElementStyle("external_robot", $EXTERNAL_ROBOT_BG_COLOR, $ELEMENT_FONT_COLOR, $EXTERNAL_ROBOT_BORDER_COLOR)
!unquoted procedure Robot($alias, $label, $descr="", $sprite="", $tags="", $link="")
!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "robot")
rectangle "$getRobot($label, $descr, $sprite)$getProps()" $toStereos("robot", $tags) as $alias $getLink($link)
!endprocedure
!unquoted procedure Robot_Ext($alias, $label, $descr="", $sprite="", $tags="", $link="")
!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "external_robot")
rectangle "$getRobot($label, $descr, $sprite)$getProps()" $toStereos("external_robot", $tags) as $alias $getLink($link)
!endprocedure
!function $getRobot($label, $descr, $sprite)
!if ($sprite == "") && ($defaultRobotSprite != "")
!$sprite = $defaultRobotSprite
!endif
!if ($descr == "") && ($sprite == "")
!return '=='+$label
!endif
!if ($descr == "") && ($sprite != "")
!return $getSprite($sprite)+'\n=='+$label
!endif
!if ($descr != "") && ($sprite == "")
!return '=='+$label+'\n\n '+$descr
!endif
!if ($descr != "") && ($sprite != "")
!return $getSprite($sprite)+'\n=='+$label+'\n\n '+$descr
!endif
!endfunction
!procedure LAYOUT_WITH_LEGEND()
hide stereotype
legend right
|<color:$LEGEND_TITLE_COLOR>**Legend**</color> |
|<$PERSON_BG_COLOR> person |
|<$ROBOT_BG_COLOR> robot |
|<$SYSTEM_BG_COLOR> system |
|<$CONTAINER_BG_COLOR> container |
|<$COMPONENT_BG_COLOR> component |
|<$EXTERNAL_PERSON_BG_COLOR> external person |
|<$EXTERNAL_ROBOT_BG_COLOR> external robot |
|<$EXTERNAL_SYSTEM_BG_COLOR> external system |
|<$EXTERNAL_CONTAINER_BG_COLOR> external container |
|<$EXTERNAL_COMPONENT_BG_COLOR> external component |
endlegend
!endprocedure
and that's assuming I didn't forget anything (which I probably did).
Although I can understand that is not satisfactory, I'm afraid I'm going to have to close this issue as "Won't Fix"
@Potherca ok I understand.
I solved this with this snippet:
!define FONTAWESOME5 https://raw.githubusercontent.com/plantuml/plantuml-stdlib/master/tupadr3/font-awesome-5
!include FONTAWESOME5/robot.puml
!include FONTAWESOME5/users.puml
'do this only if we're generating C4-puml:
!if (%function_exists("AddElementTag"))
AddElementTag("users", $sprite="users")
AddElementTag("robot_user", $sprite="robot")
AddElementTag("multi", $shadowing="true")
HIDE_STEREOTYPE()
!endif
Excuse my ignorance: what's the difference with your code above? Of course, in functional terms. What misses my implementation?
What misses my implementation?
That depends mostly on how much of the underlying functionality you use.
My example includes rudimentary support for a Robot
and Robot_Ext
method, so this can be done:
Robot(robot, "Robot", "Non-human User")
Robot_Ext(external_robot, "External Robot", "Another Non-human User")
Rel(robot, external_robot, "Label")
as well as various configuration options.
Hi @dgutson and @Potherca,
we could add the 2 robot sprites like the person sprites that it can be used like e.g. (external) systems/components.
@startuml
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Context.puml
!include <tupadr3/font-awesome-5/robot.puml>
sprite $robot2 [48x48/16] {
000000000000000088888888888888880000000000000000
000000000000000AFFFFFFFFFFFFFFFFA000000000000000
00000000000000CFFFFFFFFFFFFFFFFFFC00000000000000
00000000000004EFFFFFFFFFFFFFFFFFFE40000000000000
0000000000000AFFFFFFFFFFFFFFFFFFFFA0000000000000
00000000000008FFFFFFFFFFFFFFFFFFFF80000000000000
00000000000008FFFFFFFFFFFFFFFFFFFF80000000000000
00000000000008FFFFFFFFFFFFFFFFFFFF80000000000000
00000000000888FFFFFFFFFFFFFFFFFFFF88800000000000
00000000008FF8FFFFFFFFFFFFFFFFFFFF8FF80000000000
00000000008FF8FFFFFFFFFFFFFFFFFFFF8FF80000000000
00000000008FF8FFFFFFFFFFFFFFFFFFFF8FF80000000000
00000000008FF8FFFFFFFFFFFFFFFFFFFF8FF80000000000
00000000008FF8FFFFFFFFFFFFFFFFFFFF8FF80000000000
00000000008FF8FFFFFFFFFFFFFFFFFFFF8FF80000000000
00000000000888FFFFFFFFFFFFFFFFFFFF88800000000000
00000000000008FFFFFFFFFFFFFFFFFFFF80000000000000
00000000000008FFFFFFFFFFFFFFFFFFFF80000000000000
00000000000008FFFFFFFFFFFFFFFFFFFF80000000000000
00000000000008FFFFFFFFFFFFFFFFFFFF80000000000000
00000000000008FFFFFFFFFFFFFFFFFFFF80000000000000
00000000000004CFFFFFFFFFFFFFFFFFFC40000000000000
000000488888848CFFFFFFFFFFFFFFFFC848888884000000
00000CFFFFFFFFC888888888888888888CFFFFFFFFC00000
00008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF80000
0000CFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC0000
0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000
0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000
0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000
0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000
0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000
0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000
0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000
0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000
0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000
0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000
0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000
0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000
0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000
0008FFFFFFFF8FFFFFFFFFFFFFFFFFFFFFF8FFFFFFFF8000
0008FFFFFFFF8FFFFFFFFFFFFFFFFFFFFFF8FFFFFFFF8000
0008FFFFFFFF8FFFFFFFFFFFFFFFFFFFFFF8FFFFFFFF8000
0008FFFFFFFF8FFFFFFFFFFFFFFFFFFFFFF8FFFFFFFF8000
0008FFFFFFFF8FFFFFFFFFFFFFFFFFFFFFF8FFFFFFFF8000
0000CFFFFFFF8FFFFFFFFFFFFFFFFFFFFFF8FFFFFFFC0000
00008FFFFFFF8FFFFFFFFFFFFFFFFFFFFFF8FFFFFFF80000
00000CFFFFFF8FFFFFFFFFFFFFFFFFFFFFF8FFFFFFC00000
000000488887578888888888888888888864688884000000
}
AddExternalSystemTag(humanoidRobot, $legendText="humanoid robot (external)", $sprite="robot")
AddSystemTag(cleanroomRobot, $legendText="cleanroom robot", $sprite="robot2")
' only that sprites are displayed in legend too
AddPersonTag(user, $legendText="user", $sprite="person")
AddPersonTag(admin, $legendText="admin", $sprite="person2")
Person(pA, "Person A", $sprite="person", $tags="user")
Person(pB, "Person B", $sprite="person2", $tags="admin")
System_Ext(robA, "Roboter A", $tags="humanoidRobot")
System(robB, "Roboter B", $tags="cleanroomRobot")
SHOW_LEGEND()
@enduml
BR Helmut
PS.: @dgutson: if you use !include <tupadr3/font-awesome-5/robot.puml>
from the stdlib then no external url access is required
I changed the "robot" sprite, maybe it looks better
@startuml
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Context.puml
sprite $robot [48x48/16] {
000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
000000000005BFFFFFFFFFFFFFFFFFFFFFE9100000000000
0000000000AFFFFFFFFFFFFFFFFFFFFFFFFFE30000000000
0000000007FFFFFFFFFFFFFFFFFFFFFFFFFFFE1000000000
000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000000000
000000004FFFFFFFFFFFFFFFFFFFFFFFFFFFFFC000000000
000000005FFFFFFFFFFFFFFFFFFFFFFFFFFFFFD000000000
000000005FFFFFFFFFFFFFFFFFFFFFFFFFFFFFE000000000
000000005FFFFFFFFFFFFFFFFFFFFFFFFFFFFFE000000000
000699405FFFFFFC427FFFFFFFFFC427FFFFFFE009982000
008FFF705FFFFFE10006FFFFFFFE00007FFFFFE00FFFF100
00CFFF705FFFFFA00001FFFFFFF900002FFFFFE00FFFF500
00DFFF705FFFFFB00002FFFFFFFA00003FFFFFE00FFFF500
00DFFF705FFFFFF4000AFFFFFFFF3000BFFFFFE00FFFF500
00DFFF705FFFFFFFA8DFFFFFFFFFFA8DFFFFFFE00FFFF500
00DFFF705FFFFFFFFFFFFFFFFFFFFFFFFFFFFFE00FFFF500
00DFFF705FFFFFFFFFFFFFFFFFFFFFFFFFFFFFE00FFFF500
00DFFF705FFFFFFFFFFFFFFFFFFFFFFFFFFFFFE00FFFF500
00DFFF705FFFFFFFFFFFFFFFFFFFFFFFFFFFFFE00FFFF500
00DFFF705FFFFFFFFFFFFFFFFFFFFFFFFFFFFFE00FFFF500
00CFFF705FFFFFF87777777777777777CFFFFFE00FFFF500
008FFF705FFFFFF100000000000000009FFFFFE00FFFF100
000699405FFFFFF76666666666666666CFFFFFE009982000
000000005FFFFFFFFFFFFFFFFFFFFFFFFFFFFFE000000000
000000005FFFFFFFFFFFFFFFFFFFFFFFFFFFFFE000000000
000000004FFFFFFFFFFFFFFFFFFFFFFFFFFFFFC000000000
000000000EFFFFFFFFFFFFFFFFFFFFFFFFFFFF7000000000
0000000005FFFFFFFFFFFFFFFFFFFFFFFFFFFD0000000000
00000000004CFFFFFFFFFFFFFFFFFFFFFFFF910000000000
000000000000011111111111111111111110000000000000
000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
}
sprite $robot2 [48x48/16] {
000000000000000088888888888888880000000000000000
000000000000000AFFFFFFFFFFFFFFFFA000000000000000
00000000000000CFFFFFFFFFFFFFFFFFFC00000000000000
00000000000004EFFFFFFFFFFFFFFFFFFE40000000000000
0000000000000AFFFFFFFFFFFFFFFFFFFFA0000000000000
00000000000008FFFFFFFFFFFFFFFFFFFF80000000000000
00000000000008FFFFFFFFFFFFFFFFFFFF80000000000000
00000000000008FFFFFFFFFFFFFFFFFFFF80000000000000
00000000000888FFFFFFFFFFFFFFFFFFFF88800000000000
00000000008FF8FFFFFFFFFFFFFFFFFFFF8FF80000000000
00000000008FF8FFFFFFFFFFFFFFFFFFFF8FF80000000000
00000000008FF8FFFFFFFFFFFFFFFFFFFF8FF80000000000
00000000008FF8FFFFFFFFFFFFFFFFFFFF8FF80000000000
00000000008FF8FFFFFFFFFFFFFFFFFFFF8FF80000000000
00000000008FF8FFFFFFFFFFFFFFFFFFFF8FF80000000000
00000000000888FFFFFFFFFFFFFFFFFFFF88800000000000
00000000000008FFFFFFFFFFFFFFFFFFFF80000000000000
00000000000008FFFFFFFFFFFFFFFFFFFF80000000000000
00000000000008FFFFFFFFFFFFFFFFFFFF80000000000000
00000000000008FFFFFFFFFFFFFFFFFFFF80000000000000
00000000000008FFFFFFFFFFFFFFFFFFFF80000000000000
00000000000004CFFFFFFFFFFFFFFFFFFC40000000000000
000000488888848CFFFFFFFFFFFFFFFFC848888884000000
00000CFFFFFFFFC888888888888888888CFFFFFFFFC00000
00008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF80000
0000CFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC0000
0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000
0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000
0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000
0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000
0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000
0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000
0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000
0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000
0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000
0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000
0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000
0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000
0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000
0008FFFFFFFF8FFFFFFFFFFFFFFFFFFFFFF8FFFFFFFF8000
0008FFFFFFFF8FFFFFFFFFFFFFFFFFFFFFF8FFFFFFFF8000
0008FFFFFFFF8FFFFFFFFFFFFFFFFFFFFFF8FFFFFFFF8000
0008FFFFFFFF8FFFFFFFFFFFFFFFFFFFFFF8FFFFFFFF8000
0000CFFFFFFF8FFFFFFFFFFFFFFFFFFFFFF8FFFFFFFC0000
00008FFFFFFF8FFFFFFFFFFFFFFFFFFFFFF8FFFFFFF80000
00000CFFFFFF8FFFFFFFFFFFFFFFFFFFFFF8FFFFFFC00000
000000488887578888888888888888888864688884000000
000000000000000000000000000000000000000000000000
}
AddExternalSystemTag(humanoidRobot, $legendText="humanoid robot (external)", $sprite="robot")
AddSystemTag(cleanroomRobot, $legendText="cleanroom robot", $sprite="robot2")
' only that sprites are displayed in legend too
AddPersonTag(user, $legendText="user", $sprite="person")
AddPersonTag(admin, $legendText="admin", $sprite="person2")
Person(pA, "Person A", $sprite="person", $tags="user")
Person(pB, "Person B", $sprite="person2", $tags="admin")
System_Ext(robA, "Roboter A", $tags="humanoidRobot")
System(robB, "Roboter B", $tags="cleanroomRobot")
SHOW_LEGEND()
@enduml
Looks good to me. :+1:
@Potherca @kirchsth you guys rock!
Please allow the Person() macro to specify the shape.