CAD Exchanger SDK
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.

vis_default_viewport.png
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
}
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.

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.

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

vis_default_viewcube.jpg
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:

vis_viewcube_animation.gif
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

vis_manipulator.jpg

To be added.

Exploded view

vis_exploded_view.jpg

To be added.

Sectioning and capping

vis_sectioning&capping.jpg

To be added.

PMI, measurements, annotations

vis_measurements.jpg
Measurements


vis_pmi_nist.jpg
PMI (Product and manufacturing information)

To be added.