Hide menu
3D view operations


A viewport defines a rectangular frame (or canvas) which is used to display objects in 3D space. Viewport is platform-dependent and thus specific to each front-end. There is also a special type of viewport – ModelPrs_OffscreenViewPort which can be used for offscreen rendering.

QtQuick/QML-based viewport

The following table describes interactive operations, supported "out of the box" and corresponding default controls:

Action Mouse + Keyboard combination Touch combination
Selection Left Mouse Button Tap
Batch selection Ctrl + Left Mouse Button Not supported
Rotation Left Mouse Button and drag Touch and drag
Zoom Wheel +/- Pinch open and closed
Pan Ctrl + Left Mouse Button and drag Double touch and drag

Initializing viewport

Creating and initializing viewport is platform-specific. A scene may own a single viewport only.

The following code snippets demonstrate creating various supported viewport types. Note that any viewport object must be attached to a scene using AttachToScene() method available for each viewport type.

QtQuick/QML component

The following example demonstrates usage of QML component:

ModelPrsQtQuick_ViewPort {
id: viewPort
width: 800
height: 600
The ModelPrsQtQuick_ViewPort::RegisterQtTypes() method must be called before loading QmlComponent containing ModelPrsQtQuick_ViewPort.

The following code snippet demonstrates how to do it:

myEngine = new QQmlApplicationEngine (this);
QQmlComponent aComponent (myEngine);
aComponent.loadUrl (QUrl ("qrc:/qml/ApplicationWindow.qml"));
QObject* aQmlApp = nullptr;
if (aComponent.isReady()) {
aQmlApp = aComponent.create();

This code example demonstrates how to attach QML Viewport item to Scene:

QQuickWindow* myMainWindow = ...;
ModelPrs_Scene aScene;
auto aViewport = myMainWindow->findChild<ModelPrsQtQuick_ViewPort*> ("viewPort");
aViewport->AttachToScene (aScene);

Where viewPort is a name of ModelPrsQtQuick_ViewPort item in your QML code.

Refer to Basic Viewer Example.

WPF (Windows Platform Foundation) component

Here you can see how you can use ModelPrsWPF_ViewPort in your Xaml file:

<cadex:ModelPrsWPF_ViewPort x:Name="myViewPort" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>

Don't forget to attach it to the scene in your cs file:

myScene = new ModelPrs_Scene();
myViewPort.AttachToScene (myScene);

Where myViewPort is a name of the ModelPrsWPF_ViewPort item in your Xaml code.

Refer to Basic Viewer Example.

Windows Forms component

You can go the alternative way with .Net Framework. This example demonstrates how to use the Windows Forms component.

Create ModelPrsWinForms_ViewPort in your Designer.cs file (or in simple .cs file):

myViewPort = new ModelPrsWinForms_ViewPort();

The same code to attach to the scene:

myScene = new ModelPrs_Scene();
myViewPort.AttachToScene (myScene);

Where myViewPort is a name of the ModelPrsWinForms_ViewPort item in your Designer.cs file (or in simple .cs file).

Refer to Basic Viewer Example.

Offscreen component

The C++ ModelPrs_OffscreenViewPort class provides a viewport that can be used for offscreen rendering.

ModelPrs_Scene aScene;
ModelPrs_OffscreenViewPort aViewport;
aViewport.AttachToScene (aScene);
aViewport.Resize (300, 300);
... // Scene operations (Adding roots, Update, Wait)
aViewport.GrabToImage ("test.png");

Refer to Offscreen Rendering Example.

Viewport settings

A 3D view provides the following settings that can be customized:

  • Background color: flat color or gradient;
  • Camera settings: Perspective/Isometric projection, Camera position (available only for Offscreen);
  • Global Trihedron: visible/invisible;
  • Global Grid: visible/invisible;

Refer to Customized Viewer Example for demonstration of applying user-defined settings.


A viewcube is an interactive control that allows to switch between standard view camera positions (front, left, top, etc).


The viewcube provides 26 sensitive areas: 6 faces, 12 edges, 8 corners. Selecting each area activates smooth transition of the camera to its new position:

Switching camera position with viewcube

The viewcube appearance can be customized:

  • Position in the viewport;
  • Cube size;
  • Normal, cover and selection colors;
  • Cube and axis text colors.

Refer to Customized Viewer Example.


A manipulator is an interactive control that allows to move and rotate scene nodes using a mouse.

The manipulator provides two supported types of transformations: rotation and translation. There are 3 axes to rotate around and 3 axes to translate along. In total, there are 6 sensitive areas for this control.


The manipulator has two non-interactive auxiliary objects: the ruler and protractor. They appear when a transformation is active. Their purpose is to designate the starting position and to measure the current displacement of the scene node with respect to that starting position.


Refer to Manipulator Example for demonstration manipulator usage.

Product and manufacturing information

CAD Exchanger SDK provides an ability to display graphical PMI elements (see Product and Manufacturing Information (PMI)).

PMI (Product and manufacturing information)

Refer to PMI Viewer Example


For measurement purposes, you can use ModelPrs_MeasurementFactory.

There are 5 supported types of measurements:

  • Distance
  • Radius
  • Diameter
  • Angle between planes
  • Angle between 3 vertexes

All of the above can be displayed in a viewport. Besides, you can customize units, footnote size, color.


Refer to Measurements Example

Exploded view

The exploded view helps you to explore complex multi-component assemblies. You need just set explosion value and visual objects will change their position so that you can to see a model parts separated by distance.


Refer to Exploder Example

Sectioning and capping


To be added.