Commit ad329be8 authored by Catgolin's avatar Catgolin
Browse files

Merge branch 'dev' of framagit.org:Catgolin/Dessinateur into userinterface

parents 2fb9c1be 94d58026
Pipeline #450751 passed with stage
in 30 seconds
# How to use
# Français
## Comment utiliser l'application
### Utiliser directement
1. Télécharger le code source
2. Charger le fichier `index.html`
### Inclure l'application dans une page HTML
1. Importer le fichier `build/app.js`
2. Charger le constructeur `MCDG.default` en passant un `HTMLCanvasElement` en argument
3. Lancer la méthode `run()` sur l'objet créé pour faire fonctionner l'application dans le `HTMLCanvasElement` donné.
# English
## How to use
### Use the application directly
1. Download the source
2. Load the `index.html` file
### Include the application in a HTML page or in a larger javaScript application
1. Import the `build/app.js` file
2. Use `MCDG.default` as constructor for the application, passing an `HTMLCanvasElement` as an argument
3. Run the `start()` function on the application object thus created in order to run the application in the given `HTMLCanvasElement`.
3. Run the `start()` function on the application object thus created in order to run the application in the given `HTMLCanvasElement`
# How to build
## How to build
1. Run `npm install webpack`
2. Run `webpack`
3. Get back the `build/app.js` file
# Project architecture
## Project architecture
- app: source code of the application
- activities
......@@ -27,68 +51,3 @@
- vendor: third-party libraries
# Description of the processus
When the user performs an event (click, key pressed, etc.) :
1- The Controllers tries to interpret this event as an interaction with the GUI elements.
2a- If a GUI element is able to manage the event, it will be executed, eventually updating the state of the Controller or modifying the currently selected tool.
2b- If no GUI element is able to manage the event, the Controller delegates the event to the tool currently selected and sees if an Operation is returned.
3- If the tool returned an Operation, the Controller saves a Memento and then executes the Operation.
# Description of the classes for the project
Model : represents the state of the scene, composed of a collection of layers
- Model.construct()
- get layers(): Layer[] - return the list of all layers of the model
- add(in: Model model): void - incorporate the elements of the other model to this
- substract(in: Model model): void - remove from this the elements of the other model
- compare(in: Model model): Model - return a model containg all the elements that are not identical to both models
- removeLayer(in: string layerId): bool - remove a layer identified by it's id and return if the layer was successfully removed or not
- addLayer(in: Layer layer): void - add the layer to the model
- createLayer(in: ?string layerId): Layer - create a layer with the specified id and adds it to the model
- copy(): Model - return a copy of this model, with copies of the layers
Layer : represents one part of the scene, composed of many elements. Some layers can be locked in order to forbid any interaction with it (eg. the layer describing the target polygon, which is not to be modified by the user)
- Model.construct(in: ?string layerId)
- get elements(): Element[] - return the list of elements contained in this layer
- get id(): string - return a uniq chain of characters identifying this layer
- addElement(in: Element element): void - add the element to the layer
- removeElement(in: Element element): void - remove the element from the layer
- copy(): Layer - return a copy to this layer, with the same id and copies of the elements
Element : interface representing any object of the scene
- abstract get id(): string - return a uniq chain of characters identifying this layer
- abstract copy(): Element - return a copy of this element, with the same id
ElementPrinter : interface for printing an element in the view
- ElementPrinter.construt(in: Camera camera)
- print(in: Element element) - prints the element in the camera
Camera :
- convertCoord(x, y): int x, int y - returns the coordinates of the point in the system of the camera
Action : interface of a trasnformation to be applied on one element
- execute(out: Model model): void - apply the transformation on the relevant elements of the model
- revert(out: Model model): void - revert the execution of the action on the elements of the model, assuming it is in a state directly resulting from the execution
Operation: interface of a human-readable transformation of the scene, composed of one or many actions
- execute(): Model - apply all the actions to the model and returns a copy of the part of the model relevant to this operation in the state resulting the execution
- revert(): void - revert all the actions on the model and returns a copy of the part of the model relevant to this operation in the state prior to the execution
- load(in: Model model): Memento - select the relevant parts of the model in order to execute the action and returns a Memento object encapsulating it's state prior to the execution of the action.
- toString(): string - describe the operation in geometric terms
Memento: encapsulates an operation along with the state of the part of the model relevant to this operation in the state prior to it's execution
- Log.construct(Operation operation, Model state)
Tool: interface of the types of action that can be applied by the user
- get options(): ToolOptions - returns the object representing the options of this tool
- initialize(): void - set the tool in the state it needs to be just after it is selected by the user
- updateSelection(in: Model selection): void - updates the list of elements selected by the user
- onMouseDown(in: Vector position): ?Operation - performed when the left click of the mouse is pressed after this tool was selected, with position representing the coordinates of the click in the model's repository system. If an operation is to be executed after this event, it is returned but not performed.
- onMouseUp(in: Mode: position): ?Operation - performed when the left click of the mouse is released, with position representing the coordinates of the click in the model's repository system. If an operation is to be executed after this event, it is returned but not performed.
- onKeyPressed(in: key): ?Operation - performed when a key is pressed and this tool is selected. If an operation is to be executed after this event, it is returned but not performed.
ToolOption: interface for the configuration options of the tool
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment