Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rel_Left/Right/Up/Down are not followed when using LAYOUT_LEFT_RIGHT. #174

Closed
oliv3r opened this issue Aug 11, 2021 · 3 comments · Fixed by #177
Closed

Rel_Left/Right/Up/Down are not followed when using LAYOUT_LEFT_RIGHT. #174

oliv3r opened this issue Aug 11, 2021 · 3 comments · Fixed by #177

Comments

@oliv3r
Copy link

oliv3r commented Aug 11, 2021

With a simple graph like
LAYOUT_UP_DOWN

@startuml

!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Context.puml

System(sysA, "System A", "System A")
System(sysB, "System B", "System B")

System_Boundary(sysbA, "System Boundary A") {
   Container(conA, "Container A", "Container A")
   Container(conB, "Container B", "Container B")

   Rel_Right(conA, conB, "Rel right")
}

Rel_Left(sysA, sysB, "Rel left")
Rel_Right(sysA, sysB, "Rel right")

@enduml

The behavior changes significantly (left becomes up) when using LAYOUT_LEFT_RIGHT.
LAYOUT_LEFT_RIGHT

@startuml

!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Context.puml

LAYOUT_LEFT_RIGHT()

System(sysA, "System A", "System A")
System(sysB, "System B", "System B")

System_Boundary(sysbA, "System Boundary A") {
   Container(conA, "Container A", "Container A")
   Container(conB, "Container B", "Container B")

   Rel_Right(conA, conB, "Rel right")
}

Rel_Left(sysA, sysB, "Rel left")
Rel_Right(sysA, sysB, "Rel right")

@enduml

And so to get the design right, one has to quirkingly use Up/Down to mean Left/Right.
LEFT_is_UP

@startuml

!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Context.puml

LAYOUT_LEFT_RIGHT()

System(sysA, "System A", "System A")
System(sysB, "System B", "System B")

System_Boundary(sysbA, "System Boundary A") {
   Container(conA, "Container A", "Container A")
   Container(conB, "Container B", "Container B")

   Rel_Up(conA, conB, "Rel right")
}

Rel_Down(sysA, sysB, "Rel left")
Rel_Up(sysA, sysB, "Rel right")

@enduml
@kirchsth
Copy link
Contributor

kirchsth commented Aug 11, 2021

Hi @oliv3r,

this is known PlantUML behavior which we cannot directly influence. We could only introduce a new LAYOUT_LEFT_RIGHT_KEEP_DIRECTIONS() macro and rotate it internally like below

@startuml
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Context.puml

' possible (incomplete) extension start >>>>>>>>>>>>>>>>>>

!global $right_rotated=%false()

!procedure LAYOUT_LEFT_RIGHT_KEEP_DIRECTIONS() 
!global $right_rotated=%true()
left to right direction
!endprocedure

!unquoted procedure Rel_D($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="")
!if ($right_rotated)
$getRel("-RIGHT->>", $from, $to, $label, $techn, $descr, $sprite, $tags, $link)
!else
$getRel("-DOWN->>", $from, $to, $label, $techn, $descr, $sprite, $tags, $link)
!endif
!endprocedure
!unquoted procedure Rel_Down($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="")
!if ($right_rotated)
$getRel("-RIGHT->>", $from, $to, $label, $techn, $descr, $sprite, $tags, $link)
!else
$getRel("-DOWN->>", $from, $to, $label, $techn, $descr, $sprite, $tags, $link)
!endif
!endprocedure

!unquoted procedure Rel_U($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="")
!if ($right_rotated)
$getRel("-LEFT->>", $from, $to, $label, $techn, $descr, $sprite, $tags, $link)
!else
$getRel("-UP->>", $from, $to, $label, $techn, $descr, $sprite, $tags, $link)
!endif
!endprocedure
!unquoted procedure Rel_Up($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="")
!if ($right_rotated)
$getRel("-LEFT->>", $from, $to, $label, $techn, $descr, $sprite, $tags, $link)
!else
$getRel("-UP->>", $from, $to, $label, $techn, $descr, $sprite, $tags, $link)
!endif
!endprocedure

!unquoted procedure Rel_L($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="")
!if ($right_rotated)
$getRel("-UP->>", $from, $to, $label, $techn, $descr, $sprite, $tags, $link)
!else
$getRel("-LEFT->>", $from, $to, $label, $techn, $descr, $sprite, $tags, $link)
!endif
!endprocedure
!unquoted procedure Rel_Left($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="")
!if ($right_rotated)
$getRel("-UP->>", $from, $to, $label, $techn, $descr, $sprite, $tags, $link)
!else
$getRel("-LEFT->>", $from, $to, $label, $techn, $descr, $sprite, $tags, $link)
!endif
!endprocedure

!unquoted procedure Rel_R($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="")
!if ($right_rotated)
$getRel("-DOWN->>", $from, $to, $label, $techn, $descr, $sprite, $tags, $link)
!else
$getRel("-RIGHT->>", $from, $to, $label, $techn, $descr, $sprite, $tags, $link)
!endif
!endprocedure
!unquoted procedure Rel_Right($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="")
!if ($right_rotated)
$getRel("-DOWN->>", $from, $to, $label, $techn, $descr, $sprite, $tags, $link)
!else
$getRel("-RIGHT->>", $from, $to, $label, $techn, $descr, $sprite, $tags, $link)
!endif
!endprocedure

' possible extension end <<<<<<<<<<<<<<<<<<

' now it can be activated or not 
LAYOUT_LEFT_RIGHT_KEEP_DIRECTIONS()

System(sysA, "System A")
System(sysB, "System B")
System(sysC, "System C")

Rel(sysA, sysB, "Rel")
Rel(sysB, sysC, "Rel")

Person(P,"P")
Person(PU,"P Up")
Person(PD,"P Down")
Person(PL,"P Left")
Person(PR,"P Right")

Rel_Up(P, PU, "Up")
Rel_Down(P, PD, "Down")
Rel_Left(P, PL, "Left")
Rel_Right(P, PR, "Right")
@enduml

Without commented LAYOUT_LEFT_RIGHT_KEEP_DIRECTIONS() it looks like

With called LAYOUT_LEFT_RIGHT_KEEP_DIRECTIONS() it looks like

@Potherca: should we add an extension like this, or are our macros complex enough? What do you think?

Best regards
Helmut

@oliv3r
Copy link
Author

oliv3r commented Aug 12, 2021

@kirchsth I figured ;) but as a user of C4; I would expect this to 'just work'. So if this can be hidden in a macro, that sounds like a big pro to me?

kirchsth added a commit to kirchsth/C4-PlantUML that referenced this issue Aug 21, 2021
@kirchsth
Copy link
Contributor

@oliv3r: I think it is solved with PR #177. Can you please test it and add your comments?
Thank you and best regards
Hellmut

@kirchsth kirchsth linked a pull request Aug 21, 2021 that will close this issue
kirchsth added a commit that referenced this issue Aug 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants