cee::vis::View Class Reference

Provides a render area in the user control/widget to enable visualization of the current model data and overlay items. More...

Public Member Functions

 View ()
 Constructs a view object. More...
 
const ViewerattachedViewer () const
 Returns this view's attached viewer. More...
 
void attachToViewer (Viewer *viewer)
 Attaches this view to the specified viewer. More...
 
void detachFromViewer ()
 Detaches the view from the current viewer. More...
 
size_t modelCount () const
 Returns number of models. More...
 
size_t modelIndex (const Model *model) const
 Returns index of the specified model. More...
 
Modelmodel (size_t modelIndex)
 Returns the model at the given index. More...
 
void addModel (Model *model)
 Adds a model to the view. More...
 
void removeAllModels ()
 Removes all models from view. More...
 
void removeModel (Model *model)
 Removes specified model from view. More...
 
void setModelOpenGLCapabilitiesFromView (Model *model) const
 Sets the OpenGL capabilities from a given model. More...
 
void addSecondPassModel (Model *model)
 Adds a model to the second render pass of the view. More...
 
const Overlayoverlay () const
 Returns the Overlay object. More...
 
Overlayoverlay ()
 Returns the Overlay object. More...
 
const Clippingclipping () const
 Returns the Clipping object. More...
 
Clippingclipping ()
 Returns the Clipping object. More...
 
const Cameracamera () const
 Returns the view's camera. More...
 
Cameracamera ()
 Returns the view's camera. More...
 
BoundingBox boundingBox ()
 Returns the bounding box. More...
 
Background background () const
 Returns the background. More...
 
void setBackground (const Background &background)
 Sets the background color(s) More...
 
Color3f haloColor () const
 Returns the color of the halo. More...
 
void setHaloColor (const Color3f &color)
 Sets the color of the halo. More...
 
bool isDropShadowEnabled () const
 Returns true if Drop Shadow rendering is enabled in the view. More...
 
bool enableDropShadow (bool enable)
 Turns on/off the display of a drop shadow in the view. More...
 
TransparencyMode transparencyMode () const
 Returns the current transparency mode. More...
 
void setTransparencyMode (const TransparencyMode &transparency)
 Sets which transparency mode to use. More...
 
bool renderToImage (unsigned int width, unsigned int height, Image *image)
 Renders the contents of the view to an image. More...
 
bool renderToImage (Image *image)
 Renders the contents of the view to an image. More...
 
void renderViewInAttachedViewer ()
 Core render method for the view, render using the attached viewer. More...
 
void lastRenderingPerformanceInfo (PerformanceInfo *info) const
 Gets the last rendering performance information in info. More...
 
void requestRedraw ()
 Triggers a redraw in the view. More...
 
void requestImmediateRedraw ()
 Redraws the view now, not waiting on a normal requestRedraw. More...
 
bool regionClosestVertex (int x, int y, unsigned int width, unsigned int height, Vec3d *vertex)
 Finds the vertex closest to the front clipping plane in the given region. More...
 
void * framebufferData ()
 Returns the framebuffer data as an array of RGB values. (8 bit components) More...
 
- Public Member Functions inherited from cee::RefCountedObject
void addRef () const
 Increments the reference count for this object. More...
 
void release () const
 Decrements the reference count for this object. More...
 
int refCount () const
 Returns the reference count for this object. More...
 
void setRefCountZero () const
 Sets the ref count to zero, but DOES NOT delete the object. More...
 
Inheritance diagram for cee::vis::View:
cee::RefCountedObject

Detailed Description

Provides a render area in the user control/widget to enable visualization of the current model data and overlay items.

Each view must be attached to a system specific Viewer that enables the OpenGL rendering to be shown in the applications system.

A view can contain any number of models and overlay items. The figure below contains one UnstructGridModel, a colorlegend overlay, a navigation cube overlay and a text box overlay. The view is set up with a gradient color using the Background class.

Models

A model is a visual setup and presentation of your data. Ceetron Desktop Components offers 3 types of models; GeometryModel, UnstructGridModel and MarkupModel. (Read more about the different model types under the model topic). Each view can contain one or more models to be visualized. (One model can also be visualized in several views.) Add a model to a view using addModel().

Camera

The camera provides support for camera manipulation in the view. The camera contains the lookat vectors, type of perspective and defines the viewport. The camera also manages the input handler, which can either one of the built-in handlers or a custom made. Each view has its own camera object which can be accessed through camera().

Overlay

The view offers several types of overlay items. These are visual elements drawn as an overlay in front of the model in the view, for instance, the color legend for scalar results. Overlay items are added and managed using the class Overlay.

Available overlay item types are:


To get the current view rendered to an image object, call renderToImage() with the wanted width and height. The image object contains raw RGBA colors and can easily be read from any image exporter tools.

The bounding box surrounding all currently visible models in the view can be found using boundingBox().

See also
Viewer
Model
Camera
OverlayItem

Constructor & Destructor Documentation

cee::vis::View::View ( )

Constructs a view object.

Member Function Documentation

void cee::vis::View::addModel ( Model model)

Adds a model to the view.

void cee::vis::View::addSecondPassModel ( Model model)

Adds a model to the second render pass of the view.

Adds a model to the view, but it will be drawn after all the normal models, and the depth buffer will be cleared before this second pass, making all models added to the second pass overdraw the normal models.

const Viewer * cee::vis::View::attachedViewer ( ) const

Returns this view's attached viewer.

void cee::vis::View::attachToViewer ( Viewer viewer)

Attaches this view to the specified viewer.

Background cee::vis::View::background ( ) const

Returns the background.

cee::BoundingBox cee::vis::View::boundingBox ( )

Returns the bounding box.

The bounding box will always be the smallest possible surrounding all models in the view.

Note: Models with use2dPixelProjection() set to true will not be considered by this method.

const Camera & cee::vis::View::camera ( ) const

Returns the view's camera.

Camera & cee::vis::View::camera ( )

Returns the view's camera.

const Clipping & cee::vis::View::clipping ( ) const

Returns the Clipping object.

Clipping planes are used to clip parts of the geometry in the scene to be able to look inside. Anything behind (on the opposite side of the plane normal) the given planes is hidden.

See also
Clipping
Clipping & cee::vis::View::clipping ( )

Returns the Clipping object.

Clipping planes are used to clip parts of the geometry in the scene to be able to look inside. Anything behind (on the opposite side of the plane normal) the given planes is hidden.

See also
Clipping
void cee::vis::View::detachFromViewer ( )

Detaches the view from the current viewer.

bool cee::vis::View::enableDropShadow ( bool  enable)

Turns on/off the display of a drop shadow in the view.

If enabled, a shadow of the current model will be displayed on a plane in the bottom of the view.

void * cee::vis::View::framebufferData ( )

Returns the framebuffer data as an array of RGB values. (8 bit components)

Color3f cee::vis::View::haloColor ( ) const

Returns the color of the halo.

bool cee::vis::View::isDropShadowEnabled ( ) const

Returns true if Drop Shadow rendering is enabled in the view.

See also
enableDropShadow
void cee::vis::View::lastRenderingPerformanceInfo ( PerformanceInfo info) const

Gets the last rendering performance information in info.

Model * cee::vis::View::model ( size_t  modelIndex)

Returns the model at the given index.

size_t cee::vis::View::modelCount ( ) const

Returns number of models.

size_t cee::vis::View::modelIndex ( const Model model) const

Returns index of the specified model.

Returns UNDEFINED_SIZE_T if model could not be found

const Overlay & cee::vis::View::overlay ( ) const

Returns the Overlay object.

Overlay items are visual item presented overlaying the models in the View, for instance a color legend for scalar settings.

See also
Overlay
Overlay & cee::vis::View::overlay ( )

Returns the Overlay object.

Overlay items are visual item presented overlaying the models in the View, for instance a color legend for scalar settings.

See also
Overlay
bool cee::vis::View::regionClosestVertex ( int  x,
int  y,
unsigned int  width,
unsigned int  height,
Vec3d vertex 
)

Finds the vertex closest to the front clipping plane in the given region.

The x and y coordinates must be specified in OpenGL style coordinates, which means a right handed coordinate system with the origin in the lower left corner of the window. The width and height is in pixels.

If any vertex was found (method returning true), it will be set in the vertex parameter. The vertex is in world coordinates.

Returns true if a vertex was found. False if not.

void cee::vis::View::removeAllModels ( )

Removes all models from view.

void cee::vis::View::removeModel ( Model model)

Removes specified model from view.

bool cee::vis::View::renderToImage ( unsigned int  width,
unsigned int  height,
Image image 
)

Renders the contents of the view to an image.

Will do off-screen rendering of the view contents and return the resulting image in image.

Note! Overlay items specified using pixel size (for instance color legend), will not be scaled when changing width and height.

Note! The image width must be a multiple of 4. If it isn't, the specified width will be adjusted automatically before image creation.

Warning
Off-screen rendering requires hardware OpenGL support, and support for OpenGL 3.0 or support for FramebufferObjects through extensions.
bool cee::vis::View::renderToImage ( Image image)

Renders the contents of the view to an image.

Grabs the current frame buffer so the size of the image will be the same as the viewport of of the current camera.

Note! The image width must be a multiple of 4. If it isn't, the specified width will be adjusted automatically before image creation.

void cee::vis::View::renderViewInAttachedViewer ( )

Core render method for the view, render using the attached viewer.

This method should not be called directly, but should typically be used as part of a redraw operation from the GUI system (typically from a derived Viewer) To trigger a redraw on a view, please use requestRedraw()

void cee::vis::View::requestImmediateRedraw ( )

Redraws the view now, not waiting on a normal requestRedraw.

This will do an immediate update of the window, and not wait for the message processing that is the normal case for requestRedraw(). This is useful for updating the view multiple times in application code without the application message pump being processed.

Examples that use this is the camera animation (e.g. for the navigation cube) and per frame update of the unstruct grid model.

void cee::vis::View::requestRedraw ( )

Triggers a redraw in the view.

This will call requestRedraw() in the attached viewer, which will typically invalidate the 3D window, but not necessarily redraw it immediately.

void cee::vis::View::setBackground ( const Background background)

Sets the background color(s)

void cee::vis::View::setHaloColor ( const Color3f color)

Sets the color of the halo.

void cee::vis::View::setModelOpenGLCapabilitiesFromView ( Model model) const

Sets the OpenGL capabilities from a given model.

You should add the model to the view before adding contents to the model. If you want to add content to a model without adding it to a view, call setModelOpenGLCapabilitiesFromView() for the given model.

void cee::vis::View::setTransparencyMode ( const TransparencyMode transparency)

Sets which transparency mode to use.

Note: All modes except SIMPLE require shader support, so the OpenGL context needs to support shaders. Also, you cannot disable shader support with ModelSettings::setUseShaderPrograms(false) if you use any other mode than SIMPLE.

TransparencyMode cee::vis::View::transparencyMode ( ) const

Returns the current transparency mode.