# Datenmodell

---

## Diagram
#### From the Database
![](_res/DB_Configuration.jpg)  

#### Without Localization
``` plantuml
@startuml
!define STYLE_RG
!includeurl https://raw.githubusercontent.com/raumgleiter/PlantUML-Style/master/PlantUML_Style.puml
!include <tupadr3/common>
!include <tupadr3/font-awesome/rocket>
!include <tupadr3/font-awesome-5/user>

' All Skinparams: https://plantuml-documentation.readthedocs.io/en/latest/formatting/all-skin-params.html
' skinparam defaultTextAlignment center

' allowmixing
' skinparam ClassAttributeIconSize 0.1
' skinparam CircledCharacterRadius 0
' skinparam CircledCharacterFontSize 0

'-----------------------------------------------------------------------------

left to right direction

'******************************************************************************

class scene_set {
  Association
  ---
  rule
}

class option_set {
  Association
  ---
  rule
}

class scene {
  A panel with an image and a title
  ---
  display_name
  subtitle
  order
}

class type {
  The header of the Configurator.
  Allows you to select a flat, etc.
  Can be used in other places to switch between scene setups.
  ---
  code
  subtype
}

class option {
  A selectable option
  E.g. a type of parquet
  ---
  display_name
  order
  hidden
}

class group {
  ---
  name_display
  subtitle
  order
  type
}

class scene_link {
  The linked scenes share the same selected Options.
  ---
  source
  target
}

class design_line {
  Options can belong to a design_line.
  When a design_line is applied,
  the option will be selected by the option_group
  ---
  display_name
  description
}

scene_set "*" -- "1" scene
scene_set "*" -- "1" type
scene "1" -- "*" group
scene "2" -- "*" scene_link

option_set "*" -- "1" option
option_set "*" -- "1" type
option "*" -- "1" group
option "*" -- "0..1" design_line


'-----------------------------------------------------------------------------
'-----------------------------------------------------------------------------

'******************************************************************************

@enduml
```

## Objects
#### Content Type
 - In Unreal this is called `Map` or `(Sub)Level`  

![](_res/Configurator_ContentSelection.jpg)

#### Scene
 - In ArchInteraction this is called `ConfiguratorPoint`.  

| Attribute | Description |
| --------- | ----------- |
| display | 0: only sliders, 1: menu and image, 2: menu and floorplan |

![](_res/Configurator_ScenePanel.jpg)

#### Group
 - In ArchInteraction this is called `Option`.  
 - The order of the groups defines the order of the rendered image layers.
   (Also note, if an image is missing it might also look like the order is wrong, but the layer might simply not be displayed.)

 ![](_res/Configurator_OptionGroup_Open.jpg)

#### Option
 - In ArchInteraction this is called `Variant`.  

 ![](_res/Configurator_Option.jpg)

---

## Types
 - Types represent a version of the configurator page.
 - They can adjust the available Options and Scenes using OptionSets and SceneSets.

 | Attribute | Description |
 | --------- | ----------- |
 | code | The value of the `T` parameter of the URL. |

#### OptionSet

 | Attribute | Description |
 | --------- | ----------- |
 | rule | override: ???, exclude: hide the option |

#### SceneSet

---

## Design Lines
 - Options linked to a design lines get activated with the activation of the respective design line.
 - The standard of the option behaves basically the same, but it only gets activated when the scene is loaded.  
![](_res/DB_DesignLines.jpg)  

---

## Scene Links
 - Unreal:
   - We can create an `Option_Toggle` (group) with `variants` (option) in the `Content Browser` (files) and add them once or multiple times to the `world` (configurator).
   - Each `Option_Toggle` in the scene can decide on what `Actors` (E.g. the floors of multiple rooms) should be affected.
   - Each `Option_Toggle` in the scene is exported as a separate group.
   - Therefore, scene links inexplicitly happen by targeting multiple `Actors` that so that they are visible in multiple `ConfiguratorPoints` (scene).  
![](_res/Configurator_SceneLink.jpg)

## Interface
 - Global data with the texts of the website  
![](_res/DB_Interface.jpg)  

---

## Transforms

 | Attribute | Description |
 | --------- | ----------- |
 | resource | ??? |
 | order | the order of this image-combination-action |
 | operation | append: ???, toggle: ???, toggleHidden: ???, switch: ??? |
 | data | ??? |

 | **Warning** |
 | ------------ |
 | In the code the data field gets renamed to resource during split up. This is confusing as it does not mean the resource field! |
 | resource > target |
 | data > resource > rid > child |

#### Operation: toggle

**How it works:** Shows only the groups (data-field) of the selected option (resource-field).  
**Requirements:** The name of the toggled group needs to contain the name of the option.  

**Example:** group `10.217` `manu: ele, mie` toggles between these groups:	`10.218, 10.219` `eleGroup, mieGroup`

Group:
![](_res/toggle_group.png)

Option:
![](_res/toggle_option.png)

Transform:
![](_res/toggle_transform.png)

**Tipps:**
 - Set the standard option (resource-field) and hide all other groups (data-field) to manually configure what option should be selected on startup.
 - You can combine multiple toggled groups (data-field) into one transform or split them up. It doesn't matter.

**Code:** Toggles the visibility of the data groups if the resource is named the same as an element in the data field or it is found within an element in the data field.

Syntax of Groups in the data field: A.B
A: Scene ID
B: Group ID

#### Operation: toggleHidden (Thesis)

Same as toggle, but without animation?

#### Operation: switch (Thesis)

**How it works:** Seems to be required in order for the configurator to find the correct folder of images?
**Code:** Makes the data groups visible if their active option is named like the resource. Otherwise hides it?
**Example:** group `10.217` switches between these groups:	`10.218, 10.219, 10.220`

In Pilatus it was required to add switch statements to a toggle construction:  
![](_res/transform_switch.jpg))

#### Operation: append

**How it works:** For some images we need to render some groups at the same time. This increases the render quality as the light can affect each other, etc. The append tool allows to choose the image with the right combination of files.  

**What it does:** It combines the names of options and strings to a filename. All images need to be in a folder named by the option that is linked as resource.  

**Example:** group `10.218` named `wall` looks in the `wall` folder for a filename built by `10.217, "_", 10.218`. The files could be named like `plaster_parquet`. `plaster` and `parquet` are options of the `wall` and `floor`.  

**Additional Requirements:** The resource needs to match the last element in the operation.

---

## Customers & Orders
 - Currently only one order by customers
 - Orders get locked when the room is built in reality  
![](_res/DB_Customers.jpg)  
