Skip to content

Commit f0077db

Browse files
authored
Retain branch color for open branches (#143)
* Retain branch color for open branches Signed-off-by: Thijs Baaijen <13253091+Thijss@users.noreply.github.com> * cleanup Signed-off-by: Thijs Baaijen <13253091+Thijss@users.noreply.github.com> * Fix order in stylesheet to make it more robust Signed-off-by: Thijs Baaijen <13253091+Thijss@users.noreply.github.com> --------- Signed-off-by: Thijs Baaijen <13253091+Thijss@users.noreply.github.com>
1 parent 577f19f commit f0077db

2 files changed

Lines changed: 18 additions & 6 deletions

File tree

src/power_grid_model_ds/_core/visualizer/layout/cytoscape_styling.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@
115115
"selector": "edge[from_status = 0], edge[to_status = 0]",
116116
"style": {
117117
"line-style": "dashed",
118-
"line-color": CYTO_COLORS["open_branch"],
119118
"target-arrow-color": CYTO_COLORS["open_branch"],
120119
"source-arrow-color": CYTO_COLORS["open_branch"],
121120
},
@@ -147,11 +146,12 @@
147146
_SELECTED_BRANCH_STYLE,
148147
_SELECTED_TRANSFORMER_STYLE,
149148
_SELECTED_LINK_STYLE,
150-
_OPEN_BRANCH_STYLE,
151-
_OPEN_FROM_SIDE_BRANCH_STYLE,
152-
_OPEN_TO_SIDE_BRANCH_STYLE,
153149
_GENERIC_BRANCH_STYLE,
154150
_SELECTED_GENERIC_BRANCH_STYLE,
155151
_ASYM_LINE_STYLE,
156152
_SELECTED_ASYM_LINE_STYLE,
153+
# Note: Keep the OPEN BRANCH styles last in list, otherwise they potentially get overridden.
154+
_OPEN_BRANCH_STYLE,
155+
_OPEN_FROM_SIDE_BRANCH_STYLE,
156+
_OPEN_TO_SIDE_BRANCH_STYLE,
157157
]

tests/integration/visualizer_tests.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def get_radial_grid() -> Grid:
2222

2323
def get_coordinated_grid() -> CoordinatedGrid:
2424
scale = 500
25-
grid = CoordinatedGrid.from_txt("S1 2 open", "2 3", "3 4", "S1 500000000", "500000000 6", "6 7 transformer")
25+
grid = CoordinatedGrid.from_txt("S1 2 open", "2 3", "3 4", "S1 500000000", "500000000 6", "6 7 transformer,open")
2626
grid.node.x = [3, 2.5, 2, 1.5, 3.5, 4, 4.5]
2727
grid.node.x *= scale
2828
grid.node.y = [3, 4, 3, 4, 3, 4, 3]
@@ -61,8 +61,20 @@ def visualize_grid_with_all_types():
6161
visualize(grid=grid, debug=True)
6262

6363

64+
def visualize_grid_with_all_open_types():
65+
grid = Grid.from_txt(
66+
"1 2 12,open",
67+
"2 3 link,23,open",
68+
"3 4 transformer,34,open",
69+
"4 5 generic_branch,45,open",
70+
"5 6 asym_line,56,open",
71+
)
72+
visualize(grid=grid, debug=True)
73+
74+
6475
if __name__ == "__main__":
6576
# visualize_grid()
6677
# visualize_coordinated_grid()
6778
# visualize_grid_with_links()
68-
visualize_grid_with_all_types()
79+
# visualize_grid_with_all_types()
80+
visualize_grid_with_all_open_types()

0 commit comments

Comments
 (0)