Viskores  1.0
Public Types | Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
viskores::rendering::Canvas Class Reference

Represents the image space that is the target of rendering. More...

#include <Canvas.h>

Inheritance diagram for viskores::rendering::Canvas:
viskores::rendering::CanvasRayTracer

Public Types

using ColorBufferType = viskores::cont::ArrayHandle< viskores::Vec4f_32 >
 
using DepthBufferType = viskores::cont::ArrayHandle< viskores::Float32 >
 
using FontTextureType = viskores::rendering::Texture2D< 1 >
 

Public Member Functions

 Canvas (viskores::Id width=1024, viskores::Id height=1024)
 Construct a canvas of a given width and height. More...
 
virtual ~Canvas ()
 
virtual viskores::rendering::CanvasNewCopy () const
 Create a new Canvas object of the same subtype as this one. More...
 
virtual void Clear ()
 Clear out the image buffers. More...
 
virtual void BlendBackground ()
 Blend the foreground data with the background color. More...
 
viskores::Id GetWidth () const
 The width of the image. More...
 
viskores::Id GetHeight () const
 The height of the image. More...
 
const ColorBufferTypeGetColorBuffer () const
 Get the color channels of the image. More...
 
ColorBufferTypeGetColorBuffer ()
 Get the color channels of the image. More...
 
const DepthBufferTypeGetDepthBuffer () const
 Get the depth channel of the image. More...
 
DepthBufferTypeGetDepthBuffer ()
 Get the depth channel of the image. More...
 
viskores::cont::DataSet GetDataSet (const std::string &colorFieldName="color", const std::string &depthFieldName="depth") const
 Gets the image in this Canvas as a viskores::cont::DataSet. More...
 
viskores::cont::DataSet GetDataSet (const char *colorFieldName, const char *depthFieldName="depth") const
 Gets the image in this Canvas as a viskores::cont::DataSet. More...
 
void ResizeBuffers (viskores::Id width, viskores::Id height)
 Change the size of the image. More...
 
const viskores::rendering::ColorGetBackgroundColor () const
 Specify the background color. More...
 
void SetBackgroundColor (const viskores::rendering::Color &color)
 Specify the background color. More...
 
const viskores::rendering::ColorGetForegroundColor () const
 Specify the foreground color used for annotations. More...
 
void SetForegroundColor (const viskores::rendering::Color &color)
 Specify the foreground color used for annotations. More...
 
viskores::Id2 GetScreenPoint (viskores::Float32 x, viskores::Float32 y, viskores::Float32 z, const viskores::Matrix< viskores::Float32, 4, 4 > &transfor) const
 
virtual void RefreshColorBuffer () const
 
virtual void RefreshDepthBuffer () const
 
virtual void SetViewToWorldSpace (const viskores::rendering::Camera &camera, bool clip)
 
virtual void SetViewToScreenSpace (const viskores::rendering::Camera &camera, bool clip)
 
virtual void SetViewportClipping (const viskores::rendering::Camera &, bool)
 
virtual void SaveAs (const std::string &fileName) const
 Save the rendered image. More...
 
virtual viskores::rendering::WorldAnnotatorCreateWorldAnnotator () const
 Creates a WorldAnnotator of a type that is paired with this Canvas. More...
 
virtual void AddColorSwatch (const viskores::Vec2f_64 &point0, const viskores::Vec2f_64 &point1, const viskores::Vec2f_64 &point2, const viskores::Vec2f_64 &point3, const viskores::rendering::Color &color) const
 
void AddColorSwatch (const viskores::Float64 x0, const viskores::Float64 y0, const viskores::Float64 x1, const viskores::Float64 y1, const viskores::Float64 x2, const viskores::Float64 y2, const viskores::Float64 x3, const viskores::Float64 y3, const viskores::rendering::Color &color) const
 
virtual void AddLine (const viskores::Vec2f_64 &point0, const viskores::Vec2f_64 &point1, viskores::Float32 linewidth, const viskores::rendering::Color &color) const
 
void AddLine (viskores::Float64 x0, viskores::Float64 y0, viskores::Float64 x1, viskores::Float64 y1, viskores::Float32 linewidth, const viskores::rendering::Color &color) const
 
virtual void AddColorBar (const viskores::Bounds &bounds, const viskores::cont::ColorTable &colorTable, bool horizontal) const
 
void AddColorBar (viskores::Float32 x, viskores::Float32 y, viskores::Float32 width, viskores::Float32 height, const viskores::cont::ColorTable &colorTable, bool horizontal) const
 
virtual void AddText (const viskores::Vec2f_32 &position, viskores::Float32 scale, viskores::Float32 angle, viskores::Float32 windowAspect, const viskores::Vec2f_32 &anchor, const viskores::rendering::Color &color, const std::string &text) const
 
void AddText (viskores::Float32 x, viskores::Float32 y, viskores::Float32 scale, viskores::Float32 angle, viskores::Float32 windowAspect, viskores::Float32 anchorX, viskores::Float32 anchorY, const viskores::rendering::Color &color, const std::string &text) const
 
void AddText (const viskores::Matrix< viskores::Float32, 4, 4 > &transform, viskores::Float32 scale, const viskores::Vec2f_32 &anchor, const viskores::rendering::Color &color, const std::string &text, const viskores::Float32 &depth=0) const
 
void BeginTextRenderingBatch () const
 
void EndTextRenderingBatch () const
 

Private Member Functions

bool LoadFont () const
 
bool EnsureFontLoaded () const
 
const viskores::Matrix< viskores::Float32, 4, 4 > & GetModelView () const
 
const viskores::Matrix< viskores::Float32, 4, 4 > & GetProjection () const
 

Private Attributes

std::shared_ptr< CanvasInternals > Internals
 

Friends

class AxisAnnotation2D
 
class ColorBarAnnotation
 
class ColorLegendAnnotation
 
class TextAnnotationScreen
 
class TextRenderer
 
class WorldAnnotator
 

Detailed Description

Represents the image space that is the target of rendering.

Member Typedef Documentation

◆ ColorBufferType

◆ DepthBufferType

◆ FontTextureType

Constructor & Destructor Documentation

◆ Canvas()

viskores::rendering::Canvas::Canvas ( viskores::Id  width = 1024,
viskores::Id  height = 1024 
)

Construct a canvas of a given width and height.

◆ ~Canvas()

virtual viskores::rendering::Canvas::~Canvas ( )
virtual

Member Function Documentation

◆ AddColorBar() [1/2]

virtual void viskores::rendering::Canvas::AddColorBar ( const viskores::Bounds bounds,
const viskores::cont::ColorTable colorTable,
bool  horizontal 
) const
virtual

◆ AddColorBar() [2/2]

void viskores::rendering::Canvas::AddColorBar ( viskores::Float32  x,
viskores::Float32  y,
viskores::Float32  width,
viskores::Float32  height,
const viskores::cont::ColorTable colorTable,
bool  horizontal 
) const

◆ AddColorSwatch() [1/2]

void viskores::rendering::Canvas::AddColorSwatch ( const viskores::Float64  x0,
const viskores::Float64  y0,
const viskores::Float64  x1,
const viskores::Float64  y1,
const viskores::Float64  x2,
const viskores::Float64  y2,
const viskores::Float64  x3,
const viskores::Float64  y3,
const viskores::rendering::Color color 
) const

◆ AddColorSwatch() [2/2]

virtual void viskores::rendering::Canvas::AddColorSwatch ( const viskores::Vec2f_64 point0,
const viskores::Vec2f_64 point1,
const viskores::Vec2f_64 point2,
const viskores::Vec2f_64 point3,
const viskores::rendering::Color color 
) const
virtual

◆ AddLine() [1/2]

virtual void viskores::rendering::Canvas::AddLine ( const viskores::Vec2f_64 point0,
const viskores::Vec2f_64 point1,
viskores::Float32  linewidth,
const viskores::rendering::Color color 
) const
virtual

◆ AddLine() [2/2]

void viskores::rendering::Canvas::AddLine ( viskores::Float64  x0,
viskores::Float64  y0,
viskores::Float64  x1,
viskores::Float64  y1,
viskores::Float32  linewidth,
const viskores::rendering::Color color 
) const

◆ AddText() [1/3]

void viskores::rendering::Canvas::AddText ( const viskores::Matrix< viskores::Float32, 4, 4 > &  transform,
viskores::Float32  scale,
const viskores::Vec2f_32 anchor,
const viskores::rendering::Color color,
const std::string &  text,
const viskores::Float32 depth = 0 
) const

◆ AddText() [2/3]

virtual void viskores::rendering::Canvas::AddText ( const viskores::Vec2f_32 position,
viskores::Float32  scale,
viskores::Float32  angle,
viskores::Float32  windowAspect,
const viskores::Vec2f_32 anchor,
const viskores::rendering::Color color,
const std::string &  text 
) const
virtual

◆ AddText() [3/3]

void viskores::rendering::Canvas::AddText ( viskores::Float32  x,
viskores::Float32  y,
viskores::Float32  scale,
viskores::Float32  angle,
viskores::Float32  windowAspect,
viskores::Float32  anchorX,
viskores::Float32  anchorY,
const viskores::rendering::Color color,
const std::string &  text 
) const

◆ BeginTextRenderingBatch()

void viskores::rendering::Canvas::BeginTextRenderingBatch ( ) const

◆ BlendBackground()

virtual void viskores::rendering::Canvas::BlendBackground ( )
virtual

Blend the foreground data with the background color.

When a render is started, it is given a zeroed background rather than the background color specified by SetBackgroundColor(). This is because when blending pixel fragments of transparent objects the background color can interfere. Call this method after the render is completed for the final blend to get the proper background color.

◆ Clear()

virtual void viskores::rendering::Canvas::Clear ( )
virtual

Clear out the image buffers.

◆ CreateWorldAnnotator()

virtual viskores::rendering::WorldAnnotator* viskores::rendering::Canvas::CreateWorldAnnotator ( ) const
virtual

Creates a WorldAnnotator of a type that is paired with this Canvas.

Other types of world annotators might work, but this provides a default.

The WorldAnnotator is created with the C++ new keyword (so it should be deleted with delete later). A pointer to the created WorldAnnotator is returned.

◆ EndTextRenderingBatch()

void viskores::rendering::Canvas::EndTextRenderingBatch ( ) const

◆ EnsureFontLoaded()

bool viskores::rendering::Canvas::EnsureFontLoaded ( ) const
private

◆ GetBackgroundColor()

const viskores::rendering::Color& viskores::rendering::Canvas::GetBackgroundColor ( ) const

Specify the background color.

◆ GetColorBuffer() [1/2]

ColorBufferType& viskores::rendering::Canvas::GetColorBuffer ( )

Get the color channels of the image.

◆ GetColorBuffer() [2/2]

const ColorBufferType& viskores::rendering::Canvas::GetColorBuffer ( ) const

Get the color channels of the image.

◆ GetDataSet() [1/2]

viskores::cont::DataSet viskores::rendering::Canvas::GetDataSet ( const char *  colorFieldName,
const char *  depthFieldName = "depth" 
) const

Gets the image in this Canvas as a viskores::cont::DataSet.

The returned DataSet will be a uniform structured 2D grid. The color and depth buffers will be attached as field with the given names. If the name for the color or depth field is empty, then that respective field will not be added.

The arrays of the color and depth buffer are shallow copied. Thus, changes in the Canvas may cause unexpected behavior in the DataSet.

◆ GetDataSet() [2/2]

viskores::cont::DataSet viskores::rendering::Canvas::GetDataSet ( const std::string &  colorFieldName = "color",
const std::string &  depthFieldName = "depth" 
) const

Gets the image in this Canvas as a viskores::cont::DataSet.

The returned DataSet will be a uniform structured 2D grid. The color and depth buffers will be attached as field with the given names. If the name for the color or depth field is empty, then that respective field will not be added.

The arrays of the color and depth buffer are shallow copied. Thus, changes in the Canvas may cause unexpected behavior in the DataSet.

◆ GetDepthBuffer() [1/2]

DepthBufferType& viskores::rendering::Canvas::GetDepthBuffer ( )

Get the depth channel of the image.

◆ GetDepthBuffer() [2/2]

const DepthBufferType& viskores::rendering::Canvas::GetDepthBuffer ( ) const

Get the depth channel of the image.

◆ GetForegroundColor()

const viskores::rendering::Color& viskores::rendering::Canvas::GetForegroundColor ( ) const

Specify the foreground color used for annotations.

◆ GetHeight()

viskores::Id viskores::rendering::Canvas::GetHeight ( ) const

The height of the image.

◆ GetModelView()

const viskores::Matrix<viskores::Float32, 4, 4>& viskores::rendering::Canvas::GetModelView ( ) const
private

◆ GetProjection()

const viskores::Matrix<viskores::Float32, 4, 4>& viskores::rendering::Canvas::GetProjection ( ) const
private

◆ GetScreenPoint()

viskores::Id2 viskores::rendering::Canvas::GetScreenPoint ( viskores::Float32  x,
viskores::Float32  y,
viskores::Float32  z,
const viskores::Matrix< viskores::Float32, 4, 4 > &  transfor 
) const

◆ GetWidth()

viskores::Id viskores::rendering::Canvas::GetWidth ( ) const

The width of the image.

◆ LoadFont()

bool viskores::rendering::Canvas::LoadFont ( ) const
private

◆ NewCopy()

virtual viskores::rendering::Canvas* viskores::rendering::Canvas::NewCopy ( ) const
virtual

Create a new Canvas object of the same subtype as this one.

Reimplemented in viskores::rendering::CanvasRayTracer.

◆ RefreshColorBuffer()

virtual void viskores::rendering::Canvas::RefreshColorBuffer ( ) const
inlinevirtual

◆ RefreshDepthBuffer()

virtual void viskores::rendering::Canvas::RefreshDepthBuffer ( ) const
inlinevirtual

◆ ResizeBuffers()

void viskores::rendering::Canvas::ResizeBuffers ( viskores::Id  width,
viskores::Id  height 
)

Change the size of the image.

◆ SaveAs()

virtual void viskores::rendering::Canvas::SaveAs ( const std::string &  fileName) const
virtual

Save the rendered image.

If the filename ends with ".png", it will be saved in the portable network graphic format. Otherwise, the file will be saved in Netbpm portable pixmap format.

◆ SetBackgroundColor()

void viskores::rendering::Canvas::SetBackgroundColor ( const viskores::rendering::Color color)

Specify the background color.

◆ SetForegroundColor()

void viskores::rendering::Canvas::SetForegroundColor ( const viskores::rendering::Color color)

Specify the foreground color used for annotations.

◆ SetViewportClipping()

virtual void viskores::rendering::Canvas::SetViewportClipping ( const viskores::rendering::Camera ,
bool   
)
inlinevirtual

◆ SetViewToScreenSpace()

virtual void viskores::rendering::Canvas::SetViewToScreenSpace ( const viskores::rendering::Camera camera,
bool  clip 
)
virtual

◆ SetViewToWorldSpace()

virtual void viskores::rendering::Canvas::SetViewToWorldSpace ( const viskores::rendering::Camera camera,
bool  clip 
)
virtual

Friends And Related Function Documentation

◆ AxisAnnotation2D

friend class AxisAnnotation2D
friend

◆ ColorBarAnnotation

friend class ColorBarAnnotation
friend

◆ ColorLegendAnnotation

friend class ColorLegendAnnotation
friend

◆ TextAnnotationScreen

friend class TextAnnotationScreen
friend

◆ TextRenderer

friend class TextRenderer
friend

◆ WorldAnnotator

friend class WorldAnnotator
friend

Member Data Documentation

◆ Internals

std::shared_ptr<CanvasInternals> viskores::rendering::Canvas::Internals
private

The documentation for this class was generated from the following file: