diff options
| author | Arne Dußin | 2020-12-06 02:00:43 +0100 |
|---|---|---|
| committer | Arne Dußin | 2020-12-06 02:00:43 +0100 |
| commit | 3bc690803fb59493ea8180fd630d65b3e26642d0 (patch) | |
| tree | 9e3a0a9905c8daeb49e21688f8559c15ec80f7d8 | |
| parent | f76bb4c8b9bdbee48ad0c865314ca84282f0c707 (diff) | |
| download | graf_karto-3bc690803fb59493ea8180fd630d65b3e26642d0.tar.gz graf_karto-3bc690803fb59493ea8180fd630d65b3e26642d0.zip | |
Add new concept for class structure in UML
| -rwxr-xr-x | generate_diagrams.sh | 5 | ||||
| -rw-r--r-- | uml/class_diagram.uml | 170 |
2 files changed, 175 insertions, 0 deletions
diff --git a/generate_diagrams.sh b/generate_diagrams.sh new file mode 100755 index 0000000..da9f8c8 --- /dev/null +++ b/generate_diagrams.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +# Simple script to generate UML files from plantuml into target/uml. + +plantuml -r uml/* -o ../target/uml/ -progress $@ 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<<struct>> PaleRed + BorderColor<<struct>> DarkRed +} + +skinparam interface { + BackgroundColor<<trait>> PaleBlue + BorderColor<<trait>> Blue +} + +entity Editor <<struct>> { + - 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<f64>, mouse_blocked: bool) + + draw(&self, rld: &mut RaylibDrawHandle, transform: &Transform) + .. Getters .. + + active(&self) -> ToolType + + map_data(&self) -> &MapData +} + +entity MapData <<struct>> { + - rooms: Vec<Rect<f64>> + - polygons: Vec<Polygon<f64>> + - walls: Vec<LineSegment<f64> + - icons: Vec<IconInfo> + -- Associated functions -- + + new() -> Self + + load_file(&mut self, path: AsRef<Path>) -> io::Result<()> + + write_file(&self, path: AsRef<Path>) -> io::Result<()> + .. Attribute access .. + + rooms(&self) -> &Vec<Rect<f64>> + + rooms_mut(&mut self) -> &mut Vec<Rect<f64>> + + polygons(&self) -> &Vec<Polygon<f64>> + + polygons_mut(&mut self) -> &mut Vec<Polygon<f64>> + + walls(&self) -> &Vec<LineSegment<f64>> + + walls_mut(&mut self) -> &mut Vec<LineSegment<f64>> + + icons(&self) -> &Vec<IconInfo> + + icons_mut(&mut self) -> &mut Vec<IconInfo> +} + +interface Tool <<trait>> { + + activate(&mut self) + + deactivate(&mut self) + # update(&mut self, map: &MapData, mouse_pos_m: &Vec2<f64>) + # 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<f64>, Vec2<f64>)> + -- 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<f32>) -> bool + + draw(&self, screen_height: u16, rld: &mut impl RaylibDrawGui, editor: &mut Editor) + } +} + +package "Tools" #ff5555-ffaaaa { + entity DeletionTool <<struct>> { + - deletion_rect: Option<(Vec2<f64>, Vec2<f64>)> + -- Tool implementation -- + deactivate(&mut self) + update(&mut self, mouse_pos_m: &Vec2<f64>) + 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 <<struct>> { + - keybindings: IconToolKeybindings + - icon_id: usize + - icon_pos: Vec2<f64> + - icon_rotation: f64 + -- Tool implementation -- + update(&mut self, mouse_pos_m: &Vec2<f64>) + draw(&self, rld: &mut RaylibDrawHandle, transform: &Transform) + place_single(&mut self, map: &mutMapData) + on_button_pressed(&mut self, button: Button) + } + + entity PolygonRoomTool <<struct>> { + -- Tool implementation -- + activate(&mut self) + update(&mut self, mouse_pos_m: &Vec2<f64>) + draw(&self, rld: &mut RaylibDrawHandle, transform: &Transform) + place_single(&mut self, &mut MapData) + finish(&mut self, map: &mut MapData) + abort(&mut self) + } + entity UnfinishedPolygon <<struct>> { + + corners: Vec<Vec2<f64>> + + working_corner: Vec2<f64> + -- Associated functions -- + + check_validity_completed(&self) -> Result<(), PolygonError<f64>> + + check_validity_all(&self) -> Result<(), PolygonError<f64>> + + try_into_completed(&mut self) -> Option<Polygon<f64>> + + try_into_all(&mut self) -> Option<Polygon<f64>> + + try_push_working(&mut self) -> Result<(), PolygonError<f64>> + } + PolygonRoomTool "1" -l-> "1" UnfinishedPolygon + + entity RoomTool <<struct>> { + rect: Option<(Vec2<f64>, Vec2<f64>)> + -- Tool implementation -- + deactivate(&mut self) + update(&mut self, mouse_pos_m: &Vec2<f64>) + 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 <<struct>> { + wall: Option<LineSegment<f64>> + -- Tool implementation -- + deactivate(&mut self) + update(&mut self, mouse_pos_m: &Vec2<f64>) + 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 |
