From fb0a6ac4ed5a862643153df679670f937fff2234 Mon Sep 17 00:00:00 2001
From: Pascal Engeler <engelerp@phys.ethz.ch>
Date: Fri, 3 Sep 2021 10:34:55 +0200
Subject: [PATCH] drawing handler documentation

---
 README.md | 121 ++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 112 insertions(+), 9 deletions(-)

diff --git a/README.md b/README.md
index 995791d..042ca47 100644
--- a/README.md
+++ b/README.md
@@ -99,10 +99,13 @@ Todo
 **Constructors and Destructors**
 
 - `Drawer(Toolbox&)`
+  - **Notes**:
+  
+    The argument is unused. It should be removed.
 
-- `Drawer(const Drawer&)`
+- `Drawer(const Drawer&) = default`
 
-- `~Drawer()`
+- `~Drawer() = default`
 
 **Public Function Members**
 - `void start_drawing(const float x, const float y)`:
@@ -230,31 +233,131 @@ N/A
 ### DrawingHandler ([drawing_handler.hpp](include/drawing_handler.hpp), [drawing_handler.cpp](src/drawing_handler.cpp))
 **Description**
 
-Todo
+This class handles all aspects of the `Zeichnen` / `Radieren` functionality. It constructs `Drawer` objects on demand, manages their OpenGL infrastructure and chooses appropriate rendering targets.
 
 **Usage**
 
-Todo
+- Construct one object at the start of the application with a fully initialized `Toolbox`
+- In each frame, call `update(Toolbox&)`
 
 **Constructors and Destructors**
 
-Todo
+- `DrawingHandler(Toolbox&)`
+  - **Notes**
+
+    `Toolbox` is needed to find shader sources and obtain handles to the damping and wave textures.
+
+- `~DrawingHandler()`
 
 **Public Function Members**
 
-Todo
+- `void update(Toolbox&)`
+
+  - **Description**: 
+
+    Handles messages directed to it, parses events and takes the necessary actions (spawn / delete `Drawer`s, draw with `Drawer`s using correct infrastructure).
+
+  - **Preconditions**: 
+  
+    The object is initialized correctly.
+
+  - **Postconditions**: 
+  
+    The desired portions have been drawn to static damping and to the wave 1 texture.
+
+  - **Notes**: 
+
+    N/A
+
+- `size_t num_drawers()`
+
+  - **Description**: 
+
+    Returns the current number of active `Drawer`s.
+
+  - **Preconditions**: 
+  
+    N/A
+
+  - **Postconditions**: 
+  
+    N/A
+
+  - **Notes**: 
+
+    N/A
 
 **Private Function Members**
 
-Todo
+- `void draw_(Toolbox&)`
+
+  - **Notes**: 
+
+    Does nothing.
+
+- `bool in_wave_window_(const Toolbox&, const Pevent&) const`
+
+  - **Description**: 
+
+    Check if an event is within the wave window.
+
+  - **Preconditions**: 
+  
+    N/A
+
+  - **Postconditions**: 
+  
+    Returns `true` if the event is in the wave window, and `false` else (i.e. when event is in the GUI window).
+
+  - **Notes**: 
+
+    N/A
+
+- `std::array<float, 2> drawerCoordinates_(const Pevent&, const Toolbox&)`
+
+  - **Description**: 
+
+    Compute drawer coordinates of a `Pevent`.
+
+  - **Preconditions**: 
+  
+    N/A
+
+  - **Postconditions**: 
+  
+    N/A
+
+  - **Notes**: 
+
+    The method `Drawer::draw` should be called with the return values of this function.
 
 **Public Data Members**
 
-Todo
+N/A
 
 **Private Data Members**
 
-Todo
+- `std::list<std::pair<Drawer, SDL_FingerID> > drawpairs_`
+
+  List of `Drawer`s and the corresponding `SDL_FingerID` that spawned/controls them.
+
+- `int previous_mstate_`
+
+  `tb.mstate` from previous frame
+
+- `float draw_value_, erase_value_` **DEPRECATED**
+  
+- `GLuint vao_, vbo_`
+
+  Vertex Array Object and Vertex Buffer Object that are used by the `Drawer`s
+
+- `GLuint fbo_, fbo_wave_`
+
+  Framebuffers that target the static damping texture (`fbo_`) and the wave texture 1 (`fbo_wave_`)
+
+- `Shader shader_draw_`
+
+  Shader that is used.
 
 **Notes**
 
-- 
GitLab