Loading...
Searching...
No Matches
BALL::VIEW::RenderSetup Class Reference

`#include <BALL/VIEW/RENDERING/renderSetup.h>`

Inheritance diagram for BALL::VIEW::RenderSetup:

## Public Types

enum | RendererType { UNKNOWN_RENDERER = 0 , OPENGL_RENDERER , POV_RENDERER , VRML_RENDERER , STL_RENDERER , TILING_RENDERER , RTFACT_RENDERER }
enum | STEREO_SETUP { NONE , LEFT_EYE , RIGHT_EYE }

## Public Member Functions

| RenderSetup (Renderer *r, RenderTarget *t, Scene *scene, const Stage *stage)
| RenderSetup (const RenderSetup &rs)
virtual | ~RenderSetup ()
const RenderSetup & | operator= (const RenderSetup &rs)
void | init ()
void | resize (Size width, Size height)
void | pauseRendering ()
void | startRendering ()
bool | isPaused () const
RendererType | getRendererType ()
void | setReceiveBufferUpdates (bool do_receive)
bool | receivesBufferUpdates () const
void | updateCamera (const Camera *camera=0)
void | setOffset (const Vector3 &offset)
void | setStereoMode (STEREO_SETUP stereo)
void | bufferRepresentation (const Representation &rep)
void | removeRepresentation (const Representation &rep)
void | renderToBuffer ()
bool | exportPNG (const String &filename)
void | setLights (bool reset_all=false)
void | updateBackgroundColor ()
void | setupEnvironmentMap (const QImage &image)
Position | prepareGridTextures (const RegularData3D &grid, const ColorMap &map)
void | removeGridTextures (const RegularData3D &grid)
Vector3 | mapViewportTo3D (Position x, Position y)
Vector2 | map3DToViewport (const Vector3 &vec)
void | pickObjects (Position x1, Position y1, Position x2, Position y2, std::list< GeometricObject * > &objects)
void | showRuler (bool show)
void | updateMaterialForRepresentation (const Representation *rep)
void | projectionModeChanged ()
void | useContinuousLoop (bool use_loop)
void | stop ()
bool | isAboutToQuit ()
bool | isContinuous ()
void | setTimeToLive (int ttl)
int | getTimeToLive () const
void | exportPNGAfterTTL (String filename)
virtual void | makeCurrent ()
virtual void | run ()
void | lock ()
void | unlock ()
bool | bufferIsReady ()
| Returns true if the buffer has been filled and just waits for painting.
bool | isReadyToSwap ()
| Returns true iff bufferIsReady() holds for this renderer and all dependent ones.
void | setBufferReady (bool is_ready)
std::deque< boost::shared_ptr< RenderSetup > > & | getDependentRenderers ()
void | makeDependentOn (boost::shared_ptr< RenderSetup > &partner)

## Public Attributes

Renderer * | renderer
RenderTarget * | target
QWaitCondition | wait_for_render
Mutex | loop_mutex

## Protected Member Functions

void | renderToBuffer_ ()
void | initType_ ()

## Protected Attributes

bool | rendering_paused_
bool | receive_updates_
bool | use_offset_
bool | about_to_quit_
Camera | camera_
Vector3 | camera_offset_
STEREO_SETUP | stereo_setup_
bool | use_continuous_loop_
Scene * | scene_
Stage const * | stage_
Mutex | render_mutex_
bool | show_ruler_
GLRenderWindow * | gl_target_
GLRenderer * | gl_renderer_
int | ttl_
bool | export_after_ttl_
String | export_after_ttl_filename_
std::deque< boost::shared_ptr< RenderSetup > > | keep_in_sync_
bool | buffer_is_ready_
RendererType | renderer_type_

## Detailed Description

This class encapsulates a (renderer, target) pair for Scene.

Please try to call functions inside this class instead of working with the renderers and targets directly to ensure thread safety.

Definition at line 44 of file renderSetup.h.

## Member Enumeration Documentation

## RendererType

enum BALL::VIEW::RenderSetup::RendererType

The type of the encapsulated renderer

Enumerator
UNKNOWN_RENDERER | A fallback.
OPENGL_RENDERER | Standard OpenGL renderer.
POV_RENDERER | Renders into a POVRay file.
VRML_RENDERER | Renders into a VRML file (deprecated).
STL_RENDERER | Renders into an STL file.
TILING_RENDERER | Used for offscreen rendering.
RTFACT_RENDERER | RTfact renderer (depends on the RTfact library).

Definition at line 62 of file renderSetup.h.

## STEREO_SETUP

enum BALL::VIEW::RenderSetup::STEREO_SETUP

Enumerator
NONE |
LEFT_EYE |
RIGHT_EYE |

Definition at line 86 of file renderSetup.h.

## Constructor & Destructor Documentation

## RenderSetup() [1/2]

BALL::VIEW::RenderSetup::RenderSetup | ( | Renderer * | r,
|  | RenderTarget * | t,
|  | Scene * | scene,
|  | const Stage * | stage )

## RenderSetup() [2/2]

BALL::VIEW::RenderSetup::RenderSetup | ( | const RenderSetup & | rs | ) |

## ~RenderSetup()

virtual BALL::VIEW::RenderSetup::~RenderSetup | ( |  | ) |

virtual

## Member Function Documentation

## bufferIsReady()

bool BALL::VIEW::RenderSetup::bufferIsReady | ( |  | ) |

inline

Returns true if the buffer has been filled and just waits for painting.

Definition at line 300 of file renderSetup.h.

## bufferRepresentation()

void BALL::VIEW::RenderSetup::bufferRepresentation | ( | const Representation & | rep | ) |

Makes the target the current context and forwards the given representation to the renderer for buffering.

If the renderer is not receiving buffer updates, this is a noop.

## exportPNG()

bool BALL::VIEW::RenderSetup::exportPNG | ( | const String & | filename | ) |

Render the current state into a PNG file.

## exportPNGAfterTTL()

void BALL::VIEW::RenderSetup::exportPNGAfterTTL | ( | String | filename | ) |

inline

Export rendered image to PNG after time to live has expired.

Definition at line 280 of file renderSetup.h.

## getDependentRenderers()

std::deque< boost::shared_ptr< RenderSetup > > & BALL::VIEW::RenderSetup::getDependentRenderers | ( |  | ) |

inline

Definition at line 309 of file renderSetup.h.

## getRendererType()

RendererType BALL::VIEW::RenderSetup::getRendererType | ( |  | ) |

inline

Returns the type of the encapsulated renderer.

Definition at line 121 of file renderSetup.h.

## getTimeToLive()

int BALL::VIEW::RenderSetup::getTimeToLive | ( |  | ) | const

inline

Returns the time to live for this renderer.

Definition at line 276 of file renderSetup.h.

## init()

void BALL::VIEW::RenderSetup::init | ( |  | ) |

Initialize renderer and target.

## initType_()

void BALL::VIEW::RenderSetup::initType_ | ( |  | ) |

protected

## isAboutToQuit()

bool BALL::VIEW::RenderSetup::isAboutToQuit | ( |  | ) |

inline

Indicates whether the renderer has already been stopped.

Definition at line 258 of file renderSetup.h.

## isContinuous()

bool BALL::VIEW::RenderSetup::isContinuous | ( |  | ) |

inline

Returns the mode of the render loop.

Definition at line 262 of file renderSetup.h.

## isPaused()

bool BALL::VIEW::RenderSetup::isPaused | ( |  | ) | const

inline

This function returns the rendering state of our renderer.

Definition at line 117 of file renderSetup.h.

## isReadyToSwap()

bool BALL::VIEW::RenderSetup::isReadyToSwap | ( |  | ) |

Returns true iff bufferIsReady() holds for this renderer and all dependent ones.

## lock()

void BALL::VIEW::RenderSetup::lock | ( |  | ) |

inline

Definition at line 292 of file renderSetup.h.

## makeCurrent()

virtual void BALL::VIEW::RenderSetup::makeCurrent | ( |  | ) |

virtual

Ensure correct current rendering context.

If the target type uses a GL context, this is made current if necessary. If the target does not need GL, this function is a noop.

## makeDependentOn()

void BALL::VIEW::RenderSetup::makeDependentOn | ( | boost::shared_ptr< RenderSetup > & | partner | ) |

inline

Definition at line 312 of file renderSetup.h.

## map3DToViewport()

Vector2 BALL::VIEW::RenderSetup::map3DToViewport | ( | const Vector3 & | vec | ) |

Compute the 2D position on the screen corresponding to the 3D point vec

## mapViewportTo3D()

Vector3 BALL::VIEW::RenderSetup::mapViewportTo3D | ( | Position | x,
|  | Position | y )

Compute the 3D position on the view plane corresponding to point (x,y) on the view port

## operator=()

const RenderSetup & BALL::VIEW::RenderSetup::operator= | ( | const RenderSetup & | rs | ) |

## pauseRendering()

void BALL::VIEW::RenderSetup::pauseRendering | ( |  | ) |

inline

Pause rendering. This function allows to skip rendering while still buffering representations. Thus, a paused renderer will still receive all updates to representations, it will just not display anything.

Definition at line 106 of file renderSetup.h.

## pickObjects()

void BALL::VIEW::RenderSetup::pickObjects | ( | Position | x1,
|  | Position | y1,
|  | Position | x2,
|  | Position | y2,
|  | std::list< GeometricObject * > & | objects )

Pick all objects in the given screen rectangle.

## prepareGridTextures()

Position BALL::VIEW::RenderSetup::prepareGridTextures | ( | const RegularData3D & | grid,
|  | const ColorMap & | map )

Send a grid texture to the renderer.

If the current renderer can not handle this kind of object, this is a noop.

## projectionModeChanged()

void BALL::VIEW::RenderSetup::projectionModeChanged | ( |  | ) |

Notifies the renderer that the projection mode has changed.

## receivesBufferUpdates()

bool BALL::VIEW::RenderSetup::receivesBufferUpdates | ( |  | ) | const

inline

Returns the buffering state of the renderer.

Definition at line 142 of file renderSetup.h.

## removeGridTextures()

void BALL::VIEW::RenderSetup::removeGridTextures | ( | const RegularData3D & | grid | ) |

Remove a grid texture from the renderer.

If the current renderer can not handle this kind of object, this is a noop.

## removeRepresentation()

void BALL::VIEW::RenderSetup::removeRepresentation | ( | const Representation & | rep | ) |

Makes the target the current context and forwards the given representation to the renderer for removal.

If the renderer is not receiving buffer updates, this is a noop.

## renderToBuffer()

void BALL::VIEW::RenderSetup::renderToBuffer | ( |  | ) |

Renders the current state into the given buffer.

Please note that this function only does anything when rendering is event-based, and if the renderer is not paused. If continuous rendering is set to true, the updates will be performed in a continuous loop instead and this function will immediately return.

## renderToBuffer_()

void BALL::VIEW::RenderSetup::renderToBuffer_ | ( |  | ) |

protected

## resize()

void BALL::VIEW::RenderSetup::resize | ( | Size | width,
|  | Size | height )

Resize renderer and target.

## run()

virtual void BALL::VIEW::RenderSetup::run | ( |  | ) |

virtual

## setBufferReady()

void BALL::VIEW::RenderSetup::setBufferReady | ( | bool | is_ready | ) |

inline

Definition at line 306 of file renderSetup.h.

## setLights()

void BALL::VIEW::RenderSetup::setLights | ( | bool | reset_all = false | ) |

Calls light setup for the current renderer.

## setOffset()

void BALL::VIEW::RenderSetup::setOffset | ( | const Vector3 & | offset | ) |

Sets an offset to apply to camera position and look at point.

Please note that the offset is interpreted as relative to the camera with components (right, up, view) and will be updated at each position change.

## setReceiveBufferUpdates()

void BALL::VIEW::RenderSetup::setReceiveBufferUpdates | ( | bool | do_receive | ) |

inline

Prevent updating of rendering buffers.

This function allows to prevent the renderer from buffering or deleting representations.

Please note that this is potentially dangerous, since the renderer will not be made aware of deleted representations. Callers should make sure that the renderer state is effectively reset upon reactivating this switch.

A common use case for this function is to support two render targets sharing one render context, where we want to prevent the second target from rebuffering all representations already seen by the first.

Definition at line 138 of file renderSetup.h.

## setStereoMode()

void BALL::VIEW::RenderSetup::setStereoMode | ( | STEREO_SETUP | stereo | ) |

inline

This function turns the connected renderer into part of a stereo setup.

Depending on the value set here, renderers will be passed additional information upon update camera to set eye separation and focal distance or to prepare correct frustra.

Definition at line 164 of file renderSetup.h.

## setTimeToLive()

void BALL::VIEW::RenderSetup::setTimeToLive | ( | int | ttl | ) |

inline

Sets the number of render operations this renderer should perform.

Every render operation will decrease the time to live of this RenderSetup. If ttl == 0, the owner of this RenderSetup (e.g., the Scene), will usually destroy this instance.

To represent an infinite live time, set ttl = -1 (this is also the default).

Definition at line 272 of file renderSetup.h.

## setupEnvironmentMap()

void BALL::VIEW::RenderSetup::setupEnvironmentMap | ( | const QImage & | image | ) |

Setup an environment map if supported by the Renderer.

## showRuler()

void BALL::VIEW::RenderSetup::showRuler | ( | bool | show | ) |

Show a simple ruler.

If supported by the renderer implementation, this function can be used to produce a simple ruler that is rendered together with the other representations. The main use of this function is in the edit mode, where it can help to straighten-up structures and to correctly estimate angles and distances.

## startRendering()

void BALL::VIEW::RenderSetup::startRendering | ( |  | ) |

inline

This function allows to activate a paused renderer again. Please note that the corresponding window will not be automatically updated. This has to be performed by the caller.

Definition at line 113 of file renderSetup.h.

## stop()

void BALL::VIEW::RenderSetup::stop | ( |  | ) |

inline

Signal the renderer to quit as soon as possible.

Note: this function works asynchronously, so a rs.wait(); maybe required.

Definition at line 254 of file renderSetup.h.

## unlock()

void BALL::VIEW::RenderSetup::unlock | ( |  | ) |

inline

Definition at line 293 of file renderSetup.h.

## updateBackgroundColor()

void BALL::VIEW::RenderSetup::updateBackgroundColor | ( |  | ) |

Setup background color.

## updateCamera()

void BALL::VIEW::RenderSetup::updateCamera | ( | const Camera * | camera = 0 | ) |

Tells the connected renderer to update its camera.

This function applies transformations like adding an offset to camera position and view point before handing over the camera to the renderer.

## updateMaterialForRepresentation()

void BALL::VIEW::RenderSetup::updateMaterialForRepresentation | ( | const Representation * | rep | ) |

## useContinuousLoop()

void BALL::VIEW::RenderSetup::useContinuousLoop | ( | bool | use_loop | ) |

Decide between event based and (threaded) continuous loop rendering.

## Member Data Documentation

## about_to_quit_

bool BALL::VIEW::RenderSetup::about_to_quit_

protected

Definition at line 324 of file renderSetup.h.

## buffer_is_ready_

bool BALL::VIEW::RenderSetup::buffer_is_ready_

protected

Definition at line 360 of file renderSetup.h.

## camera_

Camera BALL::VIEW::RenderSetup::camera_

protected

Definition at line 326 of file renderSetup.h.

## camera_offset_

Vector3 BALL::VIEW::RenderSetup::camera_offset_

protected

Definition at line 327 of file renderSetup.h.

## export_after_ttl_

bool BALL::VIEW::RenderSetup::export_after_ttl_

protected

Definition at line 353 of file renderSetup.h.

## export_after_ttl_filename_

String BALL::VIEW::RenderSetup::export_after_ttl_filename_

protected

Definition at line 354 of file renderSetup.h.

## gl_renderer_

GLRenderer* BALL::VIEW::RenderSetup::gl_renderer_

protected

Definition at line 348 of file renderSetup.h.

## gl_target_

GLRenderWindow* BALL::VIEW::RenderSetup::gl_target_

protected

Definition at line 344 of file renderSetup.h.

## keep_in_sync_

std::deque<boost::shared_ptr<RenderSetup> > BALL::VIEW::RenderSetup::keep_in_sync_

protected

Definition at line 358 of file renderSetup.h.

## loop_mutex

Mutex BALL::VIEW::RenderSetup::loop_mutex

mutable

Definition at line 297 of file renderSetup.h.

## receive_updates_

bool BALL::VIEW::RenderSetup::receive_updates_

protected

Definition at line 321 of file renderSetup.h.

## render_mutex_

Mutex BALL::VIEW::RenderSetup::render_mutex_

mutable protected

Definition at line 338 of file renderSetup.h.

## renderer

Renderer* BALL::VIEW::RenderSetup::renderer

Definition at line 57 of file renderSetup.h.

## renderer_type_

RendererType BALL::VIEW::RenderSetup::renderer_type_

protected

Definition at line 363 of file renderSetup.h.

## rendering_paused_

bool BALL::VIEW::RenderSetup::rendering_paused_

protected

Definition at line 320 of file renderSetup.h.

## scene_

Scene* BALL::VIEW::RenderSetup::scene_

protected

Definition at line 334 of file renderSetup.h.

## show_ruler_

bool BALL::VIEW::RenderSetup::show_ruler_

protected

Definition at line 340 of file renderSetup.h.

## stage_

Stage const* BALL::VIEW::RenderSetup::stage_

protected

Definition at line 335 of file renderSetup.h.

## stereo_setup_

STEREO_SETUP BALL::VIEW::RenderSetup::stereo_setup_

protected

Definition at line 329 of file renderSetup.h.

## target

RenderTarget* BALL::VIEW::RenderSetup::target

Definition at line 58 of file renderSetup.h.

## ttl_

int BALL::VIEW::RenderSetup::ttl_

protected

Definition at line 351 of file renderSetup.h.

## use_continuous_loop_

bool BALL::VIEW::RenderSetup::use_continuous_loop_

protected

Definition at line 332 of file renderSetup.h.

## use_offset_

bool BALL::VIEW::RenderSetup::use_offset_

protected

Definition at line 322 of file renderSetup.h.

## wait_for_render

QWaitCondition BALL::VIEW::RenderSetup::wait_for_render

mutable

Definition at line 295 of file renderSetup.h.