Skip to content

Commit

Permalink
Merge pull request #37 from gdsfactory/fix-missing-layers
Browse files Browse the repository at this point in the history
add add_missing_layers flag
  • Loading branch information
sebastian-goeldi authored Dec 14, 2023
2 parents e1ffde3 + 6f4f0f2 commit 695b19c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/kweb/layout_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,14 @@

class LayoutViewServerEndpoint(WebSocketEndpoint):
editable: bool = False
add_missing_layers: bool = True

def __init_subclass__(cls, editable: bool = False, **kwargs: Any):
def __init_subclass__(
cls, editable: bool = False, add_missing_layers: bool = True, **kwargs: Any
):
super().__init_subclass__(**kwargs)
cls.editable = editable
cls.add_missing_layers = add_missing_layers

def __init__(self, *args: Any, **kwargs: Any) -> None:
super().__init__(*args, **kwargs)
Expand Down Expand Up @@ -255,6 +259,8 @@ async def connection(self, websocket: WebSocket, path: str | None = None) -> Non
if self.initial_cell:
self.set_current_cell(self.initial_cell)
self.layout_view.zoom_fit()
if self.add_missing_layers:
self.layout_view.add_missing_layers()
self.layout_view.max_hier()

await websocket.send_text(
Expand Down Expand Up @@ -414,5 +420,7 @@ async def reader(self, websocket: WebSocket, data: str) -> None:
self.layout_view.zoom_fit()


class EditableLayoutViewServerEndpoint(LayoutViewServerEndpoint, editable=True):
class EditableLayoutViewServerEndpoint(
LayoutViewServerEndpoint, editable=True, add_missing_layers=True
):
pass

0 comments on commit 695b19c

Please sign in to comment.