![]() |
COLNEO Pro 1.2
|
3D Viewer API interface.
API is provided by Javascript object (WebForms, Macros) cnView3dAPI.
(c) COLNEO GmbH
Public Member Functions | |
| setCurrentSceneRenderer (std::function< QImage(QSize &, int, QColor &, bool, QVariantList &, bool, bool, QVariantList &)> renderer) | |
Constructors, Destructor | |
Interface IApiObject | |
|
slot |
Activates a viewpoint linked to a SmartSet.
| vpId | ID of SmartSet associated with the view point. |
|
slot |
Clears the transient clash colors and bounding box from the 3D viewport.
Temporary object styles, visibility, and selection states replaced by showClash() are restored.
|
slot |
Remove/Delete all overlays.
|
slot |
|
slot |
Clears the points collected during the active measurement session.
|
slot |
Create a new overlay in 3D view.
| name | |
| content | HTML content of overlay/legend |
| config | {
"position" : [ x:int , y:int ]
}
|
|
slot |
Creates a viewpoint.
A viewpoint is created as Smartset with a view (camera, clipping) attached.
To delete a viewpoint, use method cnCoreAPI.deleteObject(id).
| parentId | Parent to which the viewpoint is appended. To append the viewpoint on top level, use the ID returned by cnCoreAPI.getRootId(domain, 'viewpoints'). |
| name | Name of the new viewpoint. |
| options | {
"set_as_home": false, // optional key, not part of internal options //@jh better remove here!
"visible": true, // store visible objects
"selected": false, // store selected objects (not implemented yet)
"styles": {
"colors": "current", // one of ("none", "current", "fixed")
"fixed_color": "#ff00ffff" // RGBA hex color value
"show_legend": true
},
"clipping": false, // store clipping planes
"redlining" : false // store redlining
}
|
|
slot |
Get ID of active viewpoint.
|
slot |
Returns the current camera configuration of the 3D viewport.
This method retrieves the complete state of the currently active camera and returns it as a JSON-compatible structure (QVariantMap) in the API response data field.
|
slot |
|
slot |
|
slot |
Get current view.
|
slot |
Get ID of home viewpoint.
|
slot |
Get info about OpenGL version etc.
|
slot |
Returns the current navigation mode.
|
slot |
Get overlay.
|
slot |
Get config data (position etc) of overlay.
|
slot |
Get IDs of all overlays.
|
slot |
|
slot |
Returns the snapped world-space points picked during the active measurement session.
The response data is an array of coordinate arrays. The list is cleared when Escape is pressed, the measurement handler is cleared, or navigation mode changes. Outside measurement mode, an empty array is returned.
|
slot |
Get bounding box of scene, i.e. of all objects in coordination model
|
slot |
Returns the scene translation from global coordinates to internal render coordinates.
The translation is applied as follows:
|
slot |
Captures the current 3D view as a Base64-encoded PNG image.
The screenshot contains the OpenGL viewport. If includeLegend is true, the legend is composited onto the image when it is currently visible.
| options | Screenshot options. All keys are optional. {
"legend": true // Include a visible legend; defaults to true.
"redlining": true // Include visible redlinings; defaults to true.
}
|
data value is the Base64-encoded PNG image data. The value does not include a data-URL prefix.
|
slot |
Gets view data from specified viewpoint.
| vpId | ID of viewpoint. |
|
slot |
Retrieves the IDs of all viewpoints in the design domain. Containers are not included in the list.
|
slot |
Hide all overlays
|
slot |
Checks if the Legend overlay is visible.
|
slot |
Checks if the QuickInfo is visible.
|
slot |
Ray traces the currently visible 3D scene and returns a Base64-encoded PNG image. The renderer uses the active viewport camera, scene colors, transparency, clipping, and visibility configuration.
| options | Rendering options. All members are optional. {
"size": [420, 300],
"quality": 1,
"baseplane": "#fcfcfc",
"shadow": true,
"include_legend": true,
"lights": [{
"type": "point",
"color": [1.0, 1.0, 1.0],
"intensity": 1.0,
"position": ["$eye.x", "$eye.y", "$eye.z"],
"lookat": ["$bbox.min.x", "$bbox.min.y", "$bbox.min.z"],
"range": 20.0,
"innerConeAngle": 20.0,
"outerConeAngle": 30.0,
"castShadows": true,
"shadowBias": 0.001,
"enabled": true
}]
}
|
baseplane is a Qt-compatible color string such as "#fcfcfc", "#80fcfcfc", or "lightgray". If omitted, no base plane is rendered. Set shadow to true to calculate soft shadows; it defaults to false. Set include_legend to true to composite the currently visible viewport legend as a 2D overlay on the ray-traced image. It defaults to false; no legend is added when it is currently hidden.
Supported light types are directional, point, spot, and ambient. Colors are normalized RGB arrays. Position coordinates may be numbers or scene-relative expressions: $eye.x, $eye.y, $eye.z, and the bounding-box coordinates $bbox.min.x through $bbox.max.z. The bounding box contains only objects that pass the renderer's visibility filters. $bbox.midx, $bbox.midy, and $bbox.midz select its center coordinates. Compact spellings such as $bbox.minx and dotted spellings such as $bbox.mid.x are accepted. A numeric offset may follow, for example $bbox.max.z + 10 or $eye.x - 2.5.
For directional and spot lights, lookat is the world-space point toward which the light at position points. It accepts the same numeric and scene-relative coordinates as position.
If lights is omitted, the original camera-relative key light is used. Passing an empty array disables this default light.
|
slot |
Rebuild internal scene graph for rendering. Call this method after creating new 3D objects to enforce rendering of new objects.
|
slot |
Remove(delete) overlay.
| id | Id of overlay |
|
slot |
|
slot |
Resets the current 3D viewer configuration to the default settings.
|
slot |
Reset home viewpoint.
|
slot |
Resets the 3D view.
Clears the selection, resets any clipping planes and shows all objects.
|
slot |
Patches the camera configuration of the 3D viewport.
This method updates only the provided properties of the currently active camera. Omitted properties retain their current values. A projection-only patch preserves the visible extent when switching between perspective and 'orthographic' 'projection'.
| cam | Partial camera configuration, for example: { "projection": "orthographic" } The input aliases near, far, lookat, and up, as well as three-element vector arrays, remain accepted for compatibility. |
|
slot |
Sets a clipping plane for the 3D view.
| clipping | Clipping-plane definition. Its format is the same as an individual clipping-plane map returned by getClippingPlanes(): {
"normal": [x, y, z],
"ref_point": [x, y, z]
}
|
|
slot |
Sets the configuration of 3D viewer.
| cfg | Configuration object (JSON) const cfg = {
"background_color": "#ffffff",
"selection_color": "#00ff00",
"objects": {
"openings": {
"visible": true,
"use_custom_color": false,
"color": "#ff000040"
},
"spaces": {
"visible": true,
"use_custom_color": false,
"color": "#0091c926"
},
"lines": {
"visible": true
}
},
"edges": {
"visible": true,
"color": "#5c5c5c"
},
"grid": {
"visible": true,
"color": "#e0e0e0"
},
"bounding_boxes": {
"visible": false,
"color": "#00ff00",
"offset": 0.05
},
"rendering": {
"fast_paint": true,
"ambient_occlusion": {
"enabled": true,
"radius": 3.0
}
},
"clipping": {
"fill_faces": true,
"color": "#b8b3c7",
}
}
|
| setCurrentSceneRenderer | ( | std::function< QImage(QSize &, int, QColor &, bool, QVariantList &, bool, bool, QVariantList &)> | renderer | ) |
Sets the application-provided renderer for the current 3D scene.
The project library does not depend on the GUI renderer, so GUI applications provide the rendering callback during initialization.
|
slot |
Set viewpoint with ID 'vpID' as home viewpoint for the current project.
If an empty ID or non-existent ID is passed, an error code is returned.
| vpID | ID of the viewpoint that is to be set as the home viewpoint |
|
slot |
Sets the visibility of the Legend overlay.
| visible | True to show the overlay, false to hide it. |
|
slot |
Sets the navigation mode of 3D view.
| cfg | {
"mode" : one of ["orbit", "walk", "clip", "measure", "redline"]
}
|
|
slot |
Get config data (position etc) of overlay
| config | {
"position" : [ x:int , y:int ]
}
|
|
slot |
Set HTML content of overlay
|
slot |
|
slot |
Sets the visibility of the overlay.
| id | ID of the overlay |
| visible | True to show the overlay, false to hide it. |
|
slot |
Sets the visibility of the QuickInfo.
| visible | True to show the QuickInfo, false to hide it. |
|
slot |
Sets view data to specified viewpoint.
| vpId | ID of viewpoint. |
| data | View data |
|
slot |
Show all overlays
|
slot |
Shows one clash finding in the 3D viewport. The two clashing objects are made visible and rendered opaquely with the colors of selections A and B. Other scene objects are hidden. A red corner-frame bounding box marks the clash, while secondary wireframes show the models containing the affected objects. Camera zoom is based on the affected objects' average bounding-box size and remains focused on the clash location.
| clashId | Persistent ID returned as clash_id in a clash result finding. |
|
slot |
Show home viewpoint.
|
slot |
|
slot |
|
slot |
Updates a viewpoint.
Unlike updateSmartSets(), which updates the SmartSet structure according to the given rule, this function updates only the viewpoint.
| vpId | ID of viewpoint (SmartSet) |
|
slot |
Adjusts the view to fit the bounding box of all objects (even hidden).
| opt | Options (optional) {
'view' : one of [ 'current' , 'top' , 'left' , 'right' , 'front' , 'back' ]
// 'current' is default, i.e. view direction/vector is not changed
}
|
Example
|
slot |
Adjusts the view to fit the bounding box of the given objects.
This method modifies the current view so that all provided objects are visible in the viewport. The method computes the combined bounding box of all valid objects and moves the eye point (camera position) accordingly, so that the entire bounding box fits within the view. The current viewing direction is preserved.
| objectIds | A list of object IDs. The bounding boxes of the associated objects will be used to compute the zoom target. |
| options | Options (optional) {
'view' : one of [ 'current' , 'top' , 'left' , 'right' , 'front' , 'back' ]
// 'current' is default, i.e. view direction/vector is not changed
}
|
|
slot |
Adjusts the view to fit the bounding box of the given points.
This method modifies the current view so that all provided points are visible in the viewport. The method computes the combined bounding box of all valid points and moves the eye point (camera position) accordingly, so that the entire bounding box fits within the view. The current viewing direction is preserved.
| points | An array of points. The x, y and z coordinates must be passed on as a list one after the other. The length of the list must be divisible by three. |
| options | Options (optional) {
'view' : one of [ 'current' , 'top' , 'left' , 'right' , 'front' , 'back' ]
// 'current' is default, i.e. view direction/vector is not changed
}
|