cee::vis::View

class View : public RefCountedObject

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.

../_images/view.png

Models

A model is a visual setup and presentation of your data. CEETRON Envision offers 3 types of models; GeometryModel, UnstructGridModel and MarkupModel. (Read more about the different model types under the Model

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().

../_images/uml_view.png

See also

Viewer, Model, Camera, and OverlayItem

Public Functions

View()

Constructs a view object.

const Viewer *attachedViewer() const

Returns this view’s attached viewer.

void attachToViewer(Viewer *viewer)

Attaches this view to the specified viewer.

void detachFromViewer()

Detaches the view from the current viewer.

size_t modelCount() const

Returns number of models.

size_t modelIndex(const Model *model) const

Returns index of the specified model.

Returns UNDEFINED_SIZE_T if model could not be found

Model *model(size_t modelIndex)

Returns the model at the given index.

void addModel(Model *model)

Adds a model to the view.

void removeAllModels()

Removes all models from view.

void removeModel(Model *model)

Removes specified model from view.

void 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 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 Overlay &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 &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

const Clipping &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 &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

const Camera &camera() const

Returns the view’s camera.

Camera &camera()

Returns the view’s camera.

BoundingBox 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.

Background background() const

Returns the background.

void setBackground(const Background &background)

Sets the background color(s)

Color3f haloColor() const

Returns the color of the halo.

void setHaloColor(const Color3f &color)

Sets the color of the halo.

bool isDropShadowEnabled() const

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

See also

enableDropShadow

bool 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.

TransparencyMode transparencyMode() const

Returns the current transparency mode.

void 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.

bool 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 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 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 lastRenderingPerformanceInfo(PerformanceInfo *info) const

Gets the last rendering performance information in info.

void 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 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.

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.

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 *framebufferData()

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