Initial update of Overlays JSDoc

This commit is contained in:
David Rowe 2017-11-17 17:59:11 +13:00
parent d3c33b1aaf
commit 12e005f215
7 changed files with 173 additions and 18 deletions

View file

@ -200,6 +200,25 @@ void Base3DOverlay::setProperties(const QVariantMap& originalProperties) {
}
}
// JSDoc for copying to @typedefs of overlay types that inherit Base3DOverlay.
/**jsdoc
* @typedef
* @property {string} name - TODO
* @property {Vec3} position - The position of the overlay center. Synonyms: <code>p1</code>, <code>point</code>, and
* <code>start</code>
* @property {Vec3} localPosition - The local position of the overlay relative to its parent.
* @property {Quat} rotation - The orientation of the overlay. Synonym: <code>orientation</code>.
* @property {Quat} localRotation - The orientation of the overlay relative to its parent.
* @property {boolean} isSolid - TODO w.r.t. isWire and isDashedLine. Synonyms: <ode>solid</code>, <code>isFilled</code>, or
* <code>filled</code>.
* @property {boolean} isWire - TODO. Synonym: <code>wire</code>.
* @property {boolean} isDashedLine - TODO. Synonym: <code>dashed</code>.
* @property {boolean} ignoreRayIntersection - TODO.
* @property {boolean} drawInFront - TODO.
* @property {boolean} grabbable - TODO.
* @property {Uuid} parentID - TODO.
* @property {number} parentJointIndex - TODO. Integer.
*/
QVariant Base3DOverlay::getProperty(const QString& property) {
if (property == "name") {
return _name;

View file

@ -134,6 +134,39 @@ void Cube3DOverlay::setProperties(const QVariantMap& properties) {
}
}
/**jsdoc
* @typedef {object} Overlays.cube3dProperties
* @property {number} borderSize - TODO
*
* @property {Vec3} dimensions - The dimensions of the overlay. Synonyms: <code>scale</code>, <code>size</code>.
*
* @property {string} name - TODO
* @property {Vec3} position - The position of the overlay center. Synonyms: <code>p1</code>, <code>point</code>, and
* <code>start</code>
* @property {Vec3} localPosition - The local position of the overlay relative to its parent.
* @property {Quat} rotation - The orientation of the overlay. Synonym: <code>orientation</code>.
* @property {Quat} localRotation - The orientation of the overlay relative to its parent.
* @property {boolean} isSolid - TODO w.r.t. isWire and isDashedLine. Synonyms: <ode>solid</code>, <code>isFilled</code>, and
* <code>filled</code>.
* @property {boolean} isWire - TODO. Synonym: <code>wire</code>.
* @property {boolean} isDashedLine - TODO. Synonym: <code>dashed</code>.
* @property {boolean} ignoreRayIntersection - TODO.
* @property {boolean} drawInFront - TODO.
* @property {boolean} grabbable - TODO.
* @property {Uuid} parentID - TODO.
* @property {number} parentJointIndex - TODO. Integer.
*
* @property {string} type - TODO.
* @property {RGB} color - TODO.
* @property {number} alpha - TODO.
* @property {number} pulseMax - TODO.
* @property {number} pulseMin - TODO.
* @property {number} pulsePeriod - TODO.
* @property {number} alphaPulse - TODO.
* @property {number} colorPulse - TODO.
* @property {boolean} visible - TODO.
* @property {string} anchor - TODO.
*/
QVariant Cube3DOverlay::getProperty(const QString& property) {
if (property == "borderSize") {
return _borderSize;

View file

@ -101,6 +101,20 @@ void Overlay::setProperties(const QVariantMap& properties) {
}
}
// JSDoc for copying to @typedefs of overlay types that inherit Base3DOverlay.
/**jsdoc
* @typedef
* @property {string} type - TODO.
* @property {RGB} color - TODO.
* @property {number} alpha - TODO.
* @property {number} pulseMax - TODO.
* @property {number} pulseMin - TODO.
* @property {number} pulsePeriod - TODO.
* @property {number} alphaPulse - TODO.
* @property {number} colorPulse - TODO.
* @property {boolean} visible - TODO.
* @property {string} anchor - TODO.
*/
QVariant Overlay::getProperty(const QString& property) {
if (property == "type") {
return QVariant(getType());

View file

@ -160,6 +160,48 @@ OverlayID Overlays::addOverlay(const QString& type, const QVariant& properties)
Overlay::Pointer thisOverlay = nullptr;
/**jsdoc
* <p>Overlays may be one of the following types:</p>
* <table>
* <thead>
* <tr><th>Value</th><th>2D/3D</th><th>Description</th></tr>
* </thead>
* <tbody>
* <tr><td><code>billboard</code></td><td>3D</td><td>Synonym for <code>image3d</code>.</td></td></tr>
* <tr><td><code>circle3d</code></td><td>3D</td><td>A circle.</td></tr>
* <tr><td><code>cube</code></td><td>3D</td><td>A cube. Can also use a <code>shape</code> to create a cube.</td></tr>
* <tr><td><code>grid</code></td><td>3D</td><td>A grid of lines in a plane.</td></tr>
* <tr><td><code>image</code></td><td>2D</td><td>An image.</td></tr>
* <tr><td><code>image3d</code></td><td>3D</td><td>An image.</td></tr>
* <tr><td><code>line3d</code></td><td>3D</td><td>A line</td></tr>
* <tr><td><code>model</code></td><td>3D</td><td>A model.</td></tr>
* <tr><td><code>rectangle</code></td><td>2D</td><td>A rectangle.</td></tr>
* <tr><td><code>rectangle3d</code></td><td>3D</td><td>A rectangle.</td></tr>
* <tr><td><code>shape</code></td><td>3D</td><td>A geometric shape, such as a cube, sphere, or cylinder.</td></tr>
* <tr><td><code>sphere</code></td><td>3D</td><td>A sphere. Can also use a <code>shape</code> to create a sphere.</td></tr>
* <tr><td><code>text</code></td><td>2D</td><td>Text.</td></tr>
* <tr><td><code>text3d</code></td><td>3D</td><td>Text.</td></tr>
* <tr><td><code>web3d</code></td><td>3D</td><td>Web content.</td></tr>
* </tbody>
* </table>
* @typedef {string} Overlays.OverlayType
*/
/**jsdoc
* <p>Different overlay types have different properties:</p>
* <table>
* <thead>
* <tr><th>Overlay Type</th><th>Overlay Properties</th></tr>
* </thead>
* <tbody>
* <tr><td><code>cube3d</code></td><td>{@link Overlays.cube3dProperties|cube3dProperties}</td></tr>
* <tr><td><code>sphere3d</code></td><td>{@link Overlays.sphere3dProperties|sphere3dProperties}</td></tr>
* <tr><td>TODO</td><td>TODO</td></tr>
* </tbody>
* </table>
* @typedef {object} Overlays.OverlayProperties
*/
if (type == ImageOverlay::TYPE) {
thisOverlay = Overlay::Pointer(new ImageOverlay(), [](Overlay* ptr) { ptr->deleteLater(); });
} else if (type == Image3DOverlay::TYPE || type == "billboard") { // "billboard" for backwards compatibility

View file

@ -45,12 +45,13 @@ void OverlayPropertyResultFromScriptValue(const QScriptValue& object, OverlayPro
const OverlayID UNKNOWN_OVERLAY_ID = OverlayID();
/**jsdoc
* @typedef Overlays.RayToOverlayIntersectionResult
* @property {bool} intersects True if the PickRay intersected with a 3D overlay.
* @property {Overlays.OverlayID} overlayID The ID of the overlay that was intersected with.
* @property {float} distance The distance from the PickRay origin to the intersection point.
* @property {Vec3} surfaceNormal The normal of the surface that was intersected with.
* @property {Vec3} intersection The point at which the PickRay intersected with the overlay.
* @typedef {object} Overlays.RayToOverlayIntersectionResult
* @property {boolean} intersects - <code>true</code> if the {@link PickRay} intersected with a 3D overlay, otherwise
* <code>false</code>. TODO: Only 3D overlay, really? What about the other properties?
* @property {Uuid} overlayID - The UUID of the overlay that was intersected with.
* @property {number} distance - The distance from the {@link PickRay} origin to the intersection point.
* @property {Vec3} surfaceNormal - The normal of the surface that was intersected with.
* @property {Vec3} intersection - The point at which the {@link PickRay} intersected with the overlay.
*/
class RayToOverlayIntersectionResult {
public:
@ -70,13 +71,10 @@ QScriptValue RayToOverlayIntersectionResultToScriptValue(QScriptEngine* engine,
void RayToOverlayIntersectionResultFromScriptValue(const QScriptValue& object, RayToOverlayIntersectionResult& value);
/**jsdoc
* @typedef {int} Overlays.OverlayID
*/
/**jsdoc
*
* Overlays namespace...
* The Overlays API provides facilities to create and interact with overlays. Overlays are 2D and 3D objects visible only to
* yourself and that aren't persisted to the domain. They are primarily used for UI.
* @namespace Overlays
* @property {Uuid} keyboardFocusOverlay - Get or set the [web3d]{@link Overlays.OverlayType} overlay that has keyboard focus.
*/
class Overlays : public QObject {
@ -116,13 +114,11 @@ public:
public slots:
/**jsdoc
* Add an overlays to the scene. The properties specified will depend
* on the type of overlay that is being created.
*
* Add an overlay to the scene.
* @function Overlays.addOverlay
* @param {string} type The type of the overlay to add.
* @param {Overlays.OverlayProperties} The properties of the overlay that you want to add.
* @return {Overlays.OverlayID} The ID of the newly created overlay.
* @param {Overlays.OverlayType} type - The type of the overlay to add.
* @param {Overlays.OverlayProperties} properties - The properties of the overlay to add.
* @return {Uuid} The UUID of the newly created overlay.
*/
OverlayID addOverlay(const QString& type, const QVariant& properties);
@ -307,7 +303,20 @@ public slots:
void sendHoverOverOverlay(const OverlayID& overlayID, const PointerEvent& event);
void sendHoverLeaveOverlay(const OverlayID& overlayID, const PointerEvent& event);
/**jsdoc
* Get the ID of the Web3D overlay that has keyboard focus.
* @function Overlays.getKeyboardFocusOverlay
* @returns {Uuid} The ID of the [web3d]{@link Overlays.OverlayType} overlay that has focus, if any, otherwise
* <code>null</code>.
*/
OverlayID getKeyboardFocusOverlay();
/**jsdoc
* Set the ID of the overlay that has keyboard focus.
* @function Overlays.setKeyboardFocusOverlay
* @param {Uuid} id - The ID of the [web3d]{@link Overlays.OverlayType} overlay to set keyboard focus to. Use
* {@link Uuid|Uuid.NULL} or <code>null</code> to unset keyboard focus from an overlay.
*/
void setKeyboardFocusOverlay(const OverlayID& id);
signals:

View file

@ -26,6 +26,39 @@ Sphere3DOverlay::Sphere3DOverlay(const Sphere3DOverlay* Sphere3DOverlay) :
{
}
/**jsdoc
* @typedef {object} Overlays.sphere3dProperties
*
* @property {Vec3} dimensions - The dimensions of the overlay. Synonyms: <code>scale</code>, <code>size</code>.
*
* @property {string} name - TODO
* @property {Vec3} position - The position of the overlay center. Synonyms: <code>p1</code>, <code>point</code>, and
* <code>start</code>
* @property {Vec3} localPosition - The local position of the overlay relative to its parent.
* @property {Quat} rotation - The orientation of the overlay. Synonym: <code>orientation</code>.
* @property {Quat} localRotation - The orientation of the overlay relative to its parent.
* @property {boolean} isSolid - TODO w.r.t. isWire and isDashedLine. Synonyms: <ode>solid</code>, <code>isFilled</code>, and
* <code>filled</code>.
* @property {boolean} isWire - TODO. Synonym: <code>wire</code>.
* @property {boolean} isDashedLine - TODO. Synonym: <code>dashed</code>.
* @property {boolean} ignoreRayIntersection - TODO.
* @property {boolean} drawInFront - TODO.
* @property {boolean} grabbable - TODO.
* @property {Uuid} parentID - TODO.
* @property {number} parentJointIndex - TODO. Integer.
*
* @property {string} type - TODO.
* @property {RGB} color - TODO.
* @property {number} alpha - TODO.
* @property {number} pulseMax - TODO.
* @property {number} pulseMin - TODO.
* @property {number} pulsePeriod - TODO.
* @property {number} alphaPulse - TODO.
* @property {number} colorPulse - TODO.
* @property {boolean} visible - TODO.
* @property {string} anchor - TODO.
*/
void Sphere3DOverlay::render(RenderArgs* args) {
if (!_renderVisible) {
return; // do nothing if we're not visible

View file

@ -61,6 +61,11 @@ void Volume3DOverlay::setProperties(const QVariantMap& properties) {
}
}
// JSDoc for copying to @typedefs of overlay types that inherit Volume3DOverlay.
/**jsdoc
* @typedef
* @property {Vec3} dimensions - The dimensions of the overlay. Synonyms: <code>scale</code>, <code>size</code>.
*/
QVariant Volume3DOverlay::getProperty(const QString& property) {
if (property == "dimensions" || property == "scale" || property == "size") {
return vec3toVariant(getDimensions());