From 3bc690803fb59493ea8180fd630d65b3e26642d0 Mon Sep 17 00:00:00 2001 From: Arne Dußin Date: Sun, 6 Dec 2020 02:00:43 +0100 Subject: Add new concept for class structure in UML --- uml/class_diagram.uml | 170 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 170 insertions(+) create mode 100644 uml/class_diagram.uml (limited to 'uml/class_diagram.uml') diff --git a/uml/class_diagram.uml b/uml/class_diagram.uml new file mode 100644 index 0000000..91df569 --- /dev/null +++ b/uml/class_diagram.uml @@ -0,0 +1,170 @@ +@startuml + +skinparam linetype ortho + +skinparam entity { + BackgroundColor<> PaleRed + BorderColor<> DarkRed +} + +skinparam interface { + BackgroundColor<> PaleBlue + BorderColor<> Blue +} + +entity Editor <> { + - active: usize + -- Associated functions -- + + new(rl: &mut RaylibHandle, rlt: &RaylibThread, config: Config) -> Self + + set_active(&mut self, tool: ToolType) + + update(&mut self, mouse_pos_m: &Vec2, mouse_blocked: bool) + + draw(&self, rld: &mut RaylibDrawHandle, transform: &Transform) + .. Getters .. + + active(&self) -> ToolType + + map_data(&self) -> &MapData +} + +entity MapData <> { + - rooms: Vec> + - polygons: Vec> + - walls: Vec + - icons: Vec + -- Associated functions -- + + new() -> Self + + load_file(&mut self, path: AsRef) -> io::Result<()> + + write_file(&self, path: AsRef) -> io::Result<()> + .. Attribute access .. + + rooms(&self) -> &Vec> + + rooms_mut(&mut self) -> &mut Vec> + + polygons(&self) -> &Vec> + + polygons_mut(&mut self) -> &mut Vec> + + walls(&self) -> &Vec> + + walls_mut(&mut self) -> &mut Vec> + + icons(&self) -> &Vec + + icons_mut(&mut self) -> &mut Vec +} + +interface Tool <> { + + activate(&mut self) + + deactivate(&mut self) + # update(&mut self, map: &MapData, mouse_pos_m: &Vec2) + # draw(&self, rld: &mut RaylibDrawHandle, transform: &Transform) + .. Common keybinding handlers .. + + place_single(&mut self, map: &mut MapData) + + finish(&mut self, map: &mut MapData) + + abort(&mut self) + .. Special keybinding handler .. + + on_button_pressed(&mut self, map: &mut MapData, button: Button) +} + +package "GUI" #55ff55-aaffaa { + entity Dimensions { + - dimension_lines: Vec<(Vec2, Vec2)> + -- Associated functions -- + + new() -> Self + + update(&self, editor: &mut Editor) + + draw(&self, rld: &mut impl RaylibDraw, transform: &Transform) + } + + entity ToolSidebar { + - button_texture: Texture2D + -- Associated functions -- + + new(rl: &mut RaylibHandle, rlt: &RaylibThread) -> Self + + mouse_captured(screen_height: u16, mouse_pos_px: Vec2) -> bool + + draw(&self, screen_height: u16, rld: &mut impl RaylibDrawGui, editor: &mut Editor) + } +} + +package "Tools" #ff5555-ffaaaa { + entity DeletionTool <> { + - deletion_rect: Option<(Vec2, Vec2)> + -- Tool implementation -- + deactivate(&mut self) + update(&mut self, mouse_pos_m: &Vec2) + draw(&self, rld: &mut RaylibDrawHandle, transform: &Transform) + place_single(&mut self, map: &mut MapData) + finish(&mut self, map: &mut MapData) + abort(&mut self) + } + + entity IconTool <> { + - keybindings: IconToolKeybindings + - icon_id: usize + - icon_pos: Vec2 + - icon_rotation: f64 + -- Tool implementation -- + update(&mut self, mouse_pos_m: &Vec2) + draw(&self, rld: &mut RaylibDrawHandle, transform: &Transform) + place_single(&mut self, map: &mutMapData) + on_button_pressed(&mut self, button: Button) + } + + entity PolygonRoomTool <> { + -- Tool implementation -- + activate(&mut self) + update(&mut self, mouse_pos_m: &Vec2) + draw(&self, rld: &mut RaylibDrawHandle, transform: &Transform) + place_single(&mut self, &mut MapData) + finish(&mut self, map: &mut MapData) + abort(&mut self) + } + entity UnfinishedPolygon <> { + + corners: Vec> + + working_corner: Vec2 + -- Associated functions -- + + check_validity_completed(&self) -> Result<(), PolygonError> + + check_validity_all(&self) -> Result<(), PolygonError> + + try_into_completed(&mut self) -> Option> + + try_into_all(&mut self) -> Option> + + try_push_working(&mut self) -> Result<(), PolygonError> + } + PolygonRoomTool "1" -l-> "1" UnfinishedPolygon + + entity RoomTool <> { + rect: Option<(Vec2, Vec2)> + -- Tool implementation -- + deactivate(&mut self) + update(&mut self, mouse_pos_m: &Vec2) + draw(&self, rld: &mut RaylibDrawHandle, transform: &Transform) + place_single(&mut self, map: &mut MapData) + finish(&mut self, map: &mut MapData) + abort(&mut self) + } + + entity WallTool <> { + wall: Option> + -- Tool implementation -- + deactivate(&mut self) + update(&mut self, mouse_pos_m: &Vec2) + draw(&self, rld: &mut RaylibDrawHandle, transform: &Transform) + place_single(&mut self, map: &mut MapData) + finish(&mut self, map: &mut MapData) + abort(&mut self) + on_button_pressed(&mut self, map: &mut MapData, button: Button) + } +} + +' Alignment help so all tools are drawn from top to bottom +DeletionTool -d[hidden]- IconTool +IconTool -d[hidden]- PolygonRoomTool +PolygonRoomTool -d[hidden]- RoomTool +RoomTool -d[hidden]- WallTool + +GUI -[hidden]d- Editor +ToolSidebar -[hidden]r- Dimensions +ToolSidebar ..d..> Editor +Dimensions ..d..> Editor + +' The tools should be to the left of the tool trait +Tools -r[Hidden]- Tool + +DeletionTool ..r..> Tool : implements +IconTool ..r..> Tool : implements +PolygonRoomTool ..r..> Tool : implements +RoomTool ..r..> Tool : implements +WallTool ..r..> Tool : implements + +Editor "1" ---l---> "NumTools" Tool : tools +Editor "1" -d-> "1" MapData : map_data + +@enduml -- cgit v1.2.3-70-g09d2