Hide menu
cadex::ModelPrs_OffscreenViewPort Class Reference

Defines a viewport without any visible window (frame). More...

Inheritance diagram for cadex::ModelPrs_OffscreenViewPort:

Public Types

typedef cadex::internal::ModelPrs_OffscreenViewPortImpl ImplType

Public Member Functions

 ModelPrs_OffscreenViewPort ()
bool AttachToScene (const ModelPrs_Scene &theScene)
 Attaches to ModelPrs_Scene. More...
void Resize (unsigned int theWidth, unsigned int theHeight)
 Resizes ViewPort. More...
bool GrabToImage (const Base_UTF16String &thePath) const
 Grab to image in specified thePath. More...
std::vector< unsigned char > GrabToBuffer () const
 Grab to buffer. More...
void FitAll ()
 Fit content to ViewPort size.
void FitBox (const ModelData_Box &theBox)
 Fit content to box.
void RotateToAngle (ModelPrs_AxisType theType, double theAngle)
 Rotate to angle around specified Axis.
const ModelPrs_BackgroundStyleBackgroundStyle () const
 Returns a background style. More...
void SetBackgroundStyle (const ModelPrs_BackgroundStyle &theStyle)
 Sets a background style. More...
const ModelPrs_ViewCubeStyleViewCubeStyle () const
 Sets a view cube style. More...
void SetViewCubeStyle (const ModelPrs_ViewCubeStyle &theStyle)
 Returns a view cube style. More...
const ModelData_Box2dViewCubeGeometry () const
 Returns a view cube geometry.
void SetViewCubeGeometry (const ModelData_Box2d &theBox)
 Sets a view cube geometry.
bool ViewCubeEnabled () const
 Return a view cube enabled state.
void SetViewCubeEnabled (bool theEnabled)
 Sets a visibility of view cube.
ModelPrs_CameraProjectionType CameraProjectionType () const
 Returns a camera projection type. More...
void SetCameraProjectionType (ModelPrs_CameraProjectionType theType)
 Sets a camera projection type. More...
void SetCameraPositionType (ModelPrs_CameraPositionType theOrientation)
 Sets a camera position type.
void SetCameraView (const ModelData_Point &thePosition, const ModelData_Point &theTarget, const ModelData_Direction &theUp)
 Sets a custom camera position.
ModelPrs_Exploder Exploder ()
 Returns object to manage model explosion.
- Public Member Functions inherited from cadex::Base_PublicObject
 Base_PublicObject ()
 Constructor. More...
void Nullify ()
 Resets reference to implementation object.
bool IsNull () const
 Returns true if the object is nullified. More...
 operator bool () const
 Casts the object to the bool type. More...
internal::Base_HandledObject * Impl () const
 Return a handle to backend (reserved for internal use).
const internal::Base_Handle & HImpl () const
template<typename T >
T * Impl () const
 Reserved for internal use.
bool operator== (const Base_PublicObject &theObject) const
bool operator!= (const Base_PublicObject &theObject) const

Additional Inherited Members

- Protected Member Functions inherited from cadex::Base_PublicObject
 Base_PublicObject (const internal::Base_HandledObject *theObject)
 Constructor (reserved for internal use).
template<typename T >
T * GetOrCreateImpl ()
 Reserved for internal use.

Detailed Description

Defines a viewport without any visible window (frame).

This class is a part of Visualization Toolkit add-on, which is licensed separately from the base CAD Exchanger SDK.

The off-screen component encapsulates an unvisible viewport which is used to display objects in 3D space.

See also

The following code snippet demonstrates how to use this for image generations:

ModelPrs_Scene aScene;
aScene.AddRoot (aNode);
aViewport.Resize (800, 600);
aViewport.AttachToScene (aScene);
aViewPort.GrabToImage ("model.png");

An off-screen viewport contains a shared pointer to its internal implementation, so simple copying an object will just copy a shared pointer. Therefore any modification of the copied object will propagate to original object.

See also
Using pimpl pattern

Member Function Documentation

◆ AttachToScene()

bool cadex::ModelPrs_OffscreenViewPort::AttachToScene ( const ModelPrs_Scene theScene)

Attaches to ModelPrs_Scene.

Scene will notifies attached ViewPort about changes and it will do redraw.


◆ BackgroundStyle()

const ModelPrs_BackgroundStyle & cadex::ModelPrs_OffscreenViewPort::BackgroundStyle ( ) const

Returns a background style.

See also

◆ CameraProjectionType()

ModelPrs_CameraProjectionType cadex::ModelPrs_OffscreenViewPort::CameraProjectionType ( ) const

Returns a camera projection type.

See also

◆ GrabToBuffer()

std::vector< unsigned char > cadex::ModelPrs_OffscreenViewPort::GrabToBuffer ( ) const

Grab to buffer.

The buffer size will equal ViewPort's size (width * height).

See also

◆ GrabToImage()

bool cadex::ModelPrs_OffscreenViewPort::GrabToImage ( const Base_UTF16String thePath) const

Grab to image in specified thePath.

Requires to provide a full path to output file including extension:

aViewPort.GrabToImage ("test.png");

The file name extension must be one of .png, .jpg, .bmp, .gif. The image size will equal to ViewPort size. This image size manages by Resize():

aViewPort.Resize (800, 600);
See also

◆ Resize()

void cadex::ModelPrs_OffscreenViewPort::Resize ( unsigned int  theWidth,
unsigned int  theHeight 

Resizes ViewPort.

Both values must be more then zero.


◆ SetBackgroundStyle()

void cadex::ModelPrs_OffscreenViewPort::SetBackgroundStyle ( const ModelPrs_BackgroundStyle theStyle)

Sets a background style.

See also

◆ SetCameraProjectionType()

void cadex::ModelPrs_OffscreenViewPort::SetCameraProjectionType ( ModelPrs_CameraProjectionType  theType)

Sets a camera projection type.

See also

◆ SetViewCubeStyle()

void cadex::ModelPrs_OffscreenViewPort::SetViewCubeStyle ( const ModelPrs_ViewCubeStyle theStyle)

Returns a view cube style.

See also

◆ ViewCubeStyle()

const ModelPrs_ViewCubeStyle & cadex::ModelPrs_OffscreenViewPort::ViewCubeStyle ( ) const

Sets a view cube style.

See also
Definition: ModelPrs_OffscreenViewPort.cxx:239