An EventHandler to paint on terrains and pass edit events to one or more Editor objects. More...
#include <EditorHandler.h>
Public Member Functions | |
EditorHandler (float relativeRadius) | |
Creates a new EditorHandler. | |
bool | hasEditors () |
Returns true if this EditorHandler has associated Editor. | |
void | addEditor (Editor *editor) |
Adds an Editor to this EditorHandler. | |
void | removeEditor (Editor *editor) |
Removes an Editor from this EditorHandler. | |
void | setActive (bool active) |
Activates or deactivates this EditorHandler. | |
void | setActive (string group, bool active) |
Activates or deactivates the Editors that belong to 'group' inside this EditorHandler. | |
bool | isActive (string group) |
True if any of the Editors that belong to 'group' is activated. | |
void | reset () |
Cancels all editing operations performed on the active Editors. | |
vec3d | getPosition (int x, int y) |
Returns the world space point corresponding to the given screen coordinates. | |
Public Attributes | |
float | relativeRadius |
Paint brush radius relatively to the screen size. | |
float | brushColor [4] |
Value that will be written by the brush at each stroke. | |
Private Attributes | |
vector< Editor * > | editors |
The editors associated with this EditorHandler. | |
float | radius |
Paint brush radius in world space. | |
bool | update |
True if the current edition is over and the editors must be updated during redisplay. | |
bool | paint |
True if the user is currently painting. | |
vector< vec4d > | strokes |
The strokes of the currently painted shape. | |
int | newStrokes |
Number of new strokes since last call to redisplay. | |
vec2i | lastPos |
Last position of mouse in screen space. | |
float * | depthBuffer |
A copy of the depth buffer when the user started to paint. |
An EventHandler to paint on terrains and pass edit events to one or more Editor objects.
proland::EditorHandler::EditorHandler | ( | float | relativeRadius | ) |
Creates a new EditorHandler.
relativeRadius | size of the paint brush relatively to the screen size. |
void proland::EditorHandler::addEditor | ( | Editor * | editor | ) |
Adds an Editor to this EditorHandler.
The given Editor will receive edit events via its Editor::edit and Editor::update methods.
editor | an abstract Editor. |
vec3d proland::EditorHandler::getPosition | ( | int | x, | |
int | y | |||
) |
Returns the world space point corresponding to the given screen coordinates.
x | horizontal screen coordinate, in pixels. | |
y | vertical screen coordinate, in pixels. |
bool proland::EditorHandler::hasEditors | ( | ) |
Returns true if this EditorHandler has associated Editor.
bool proland::EditorHandler::isActive | ( | string | group | ) |
True if any of the Editors that belong to 'group' is activated.
void proland::EditorHandler::removeEditor | ( | Editor * | editor | ) |
Removes an Editor from this EditorHandler.
The given Editor will no longer receive edit events via its Editor::edit and Editor::update methods.
editor | an abstract Editor. |
void proland::EditorHandler::reset | ( | ) |
Cancels all editing operations performed on the active Editors.
void proland::EditorHandler::setActive | ( | string | group, | |
bool | active | |||
) |
Activates or deactivates the Editors that belong to 'group' inside this EditorHandler.
void proland::EditorHandler::setActive | ( | bool | active | ) |
Activates or deactivates this EditorHandler.
This method show or hides the pencil depending on the status of this EditorHandler.
float proland::EditorHandler::brushColor[4] |
Value that will be written by the brush at each stroke.
float* proland::EditorHandler::depthBuffer [private] |
A copy of the depth buffer when the user started to paint.
vector<Editor*> proland::EditorHandler::editors [private] |
The editors associated with this EditorHandler.
vec2i proland::EditorHandler::lastPos [private] |
Last position of mouse in screen space.
int proland::EditorHandler::newStrokes [private] |
Number of new strokes since last call to redisplay.
bool proland::EditorHandler::paint [private] |
True if the user is currently painting.
float proland::EditorHandler::radius [private] |
Paint brush radius in world space.
Paint brush radius relatively to the screen size.
vector<vec4d> proland::EditorHandler::strokes [private] |
The strokes of the currently painted shape.
When the user moves the mouse while in painting mode, strokes are sampled along the drawn path, at minimal distance between each other, and stored in this vector. Each stroke contains a world position and a radius (in world space).
bool proland::EditorHandler::update [private] |
True if the current edition is over and the editors must be updated during redisplay.