Hide menu
3D view operations

Viewport

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.

\subsection sdk_vis_3dview_operations_initializing_qtqml        QtQuick/QML component

The following example demonstrates usage of QML component:

ModelPrsQtQuick_ViewPort {
id: viewPort
width: 800
height: 600
}
Note
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.

\subsection sdk_vis_3dview_operations_initializing_wpf          WPF (Windows Platform Foundation) component

For .NET framework you can use ModelPrsWPF_ViewPort:

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

And attach it to 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.

\subsection sdk_vis_3dview_operations_initializing_offscreen    Offscreen component

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

ModelPrs_Scene aScene;
ModelPrs_OffscreenViewPort aViewport;
aViewport.AttachToScene (aScene);
aViewport.Resize (300, 300);
...
aViewport.FitAll();
aViewport.GrabToImage ("test.png");

Viewport settings

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

  • Background color: flat color or gradient;
  • Camera settings.

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

Viewcube

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

Viewcube

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.

Manipulator

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 sdk_examples_pmi_viewer

Measurements

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.

Measurements

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.

static void RegisterQtTypes()
Registers QML types.
Definition: ModelPrsQtQuick_ViewPort.cxx:342
Defines classes, types, and global functions related to CAD Exchanger.
Definition: cadexsdk.txt:172