file_path
stringlengths 21
202
| content
stringlengths 19
1.02M
| size
int64 19
1.02M
| lang
stringclasses 8
values | avg_line_length
float64 5.88
100
| max_line_length
int64 12
993
| alphanum_fraction
float64 0.27
0.93
|
---|---|---|---|---|---|---|
omniverse-code/kit/include/omni/ui/scene/AbstractItem.h | // Copyright (c) 2021-2022, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "Api.h"
#include "Math.h"
#include "Object.h"
#include "Space.h"
#include <omni/ui/Callback.h>
#include <omni/ui/Property.h>
#include <memory>
#include <unordered_set>
OMNIUI_NAMESPACE_USING_DIRECTIVE
OMNIUI_SCENE_NAMESPACE_OPEN_SCOPE
class Scene;
class SceneView;
class DrawList;
class GestureManager;
struct MouseInput
{
enum class InputFlag : uint32_t
{
eViewHovered = (1 << 0),
};
MouseInput(const Vector2& inMouse = {},
const Vector2& inMouseWheel = {},
const Vector3& inMouseOrigin = {},
const Vector3& inMouseDirection = {},
const uint32_t& inModifiers = {},
const uint32_t& inClicked = {},
const uint32_t& inDoubleClicked = {},
const uint32_t& inReleased = {},
const uint32_t& inDown = {},
const uint32_t& inFlags = {})
: mouse{ inMouse },
mouseWheel{ inMouseWheel },
mouseOrigin{ inMouseOrigin },
mouseDirection{ inMouseDirection },
modifiers{ inModifiers },
clicked{ inClicked },
doubleClicked{ inDoubleClicked },
released{ inReleased },
down{ inDown },
flags{ inFlags }
{
}
Vector2 mouse;
Vector2 mouseWheel;
Vector3 mouseOrigin;
Vector3 mouseDirection;
uint32_t modifiers;
uint32_t clicked;
uint32_t doubleClicked;
uint32_t released;
uint32_t down;
uint32_t flags;
};
class OMNIUI_SCENE_CLASS_API AbstractItem : public std::enable_shared_from_this<AbstractItem>,
protected omni::ui::CallbackHelper<AbstractItem>
{
public:
OMNIUI_SCENE_API
virtual ~AbstractItem();
/**
* @brief Removes all the callbacks and circular references.
*/
OMNIUI_SCENE_API
virtual void destroy();
// We assume that all the operations with all the items should be performed with smart pointers because we have
// parent-child relationships, and we automatically put new items to parents in the create method of every item.
// If the object is copied or moved, it will break the Item-Container hierarchy.
// No copy
AbstractItem(const AbstractItem&) = delete;
// No copy-assignment
AbstractItem& operator=(const AbstractItem&) = delete;
// No move constructor and no move-assignments are allowed because of the C++ standard
OMNIUI_SCENE_API
void preDrawContent(const MouseInput& input, const Matrix44& projection, const Matrix44& view, float width, float height);
OMNIUI_SCENE_API
void drawContent(const Matrix44& projection, const Matrix44& view);
OMNIUI_SCENE_API
void postDrawContent(const Matrix44& projection, const Matrix44& view);
/**
* @brief Transform the given point from the coordinate system fromspace to
* the coordinate system tospace.
*/
OMNIUI_SCENE_API
virtual Vector3 transformSpace(Space fromSpace, Space toSpace, const Vector3& point) const;
/**
* @brief Transform the given vector from the coordinate system fromspace to
* the coordinate system tospace.
*/
OMNIUI_SCENE_API
virtual Vector4 transformSpace(Space fromSpace, Space toSpace, const Vector4& vector) const;
/**
* @brief Calculate the effective visibility of this prim, as defined by its
* most ancestral invisible opinion, if any.
*/
OMNIUI_SCENE_API
bool computeVisibility() const;
OMNIUI_PROPERTY(const AbstractContainer*, parent, DEFAULT, nullptr, READ_VALUE, getParent, PROTECTED, WRITE, _setParent);
OMNIUI_PROPERTY(const Scene*, scene, DEFAULT, nullptr, PROTECTED, READ_VALUE, _getScene, WRITE, setScene);
/**
* @brief The current SceneView this item is parented to.
*/
OMNIUI_PROPERTY(SceneView const*, sceneView, DEFAULT, nullptr, READ_VALUE, getSceneView, PROTECTED, WRITE, _setSceneView);
/**
* @brief This property holds whether the item is visible.
*/
OMNIUI_PROPERTY(
bool, visible, DEFAULT, true, READ, isVisible, WRITE, setVisible, PROTECTED, NOTIFY, _setVisibleChangedFn);
protected:
friend class AbstractContainer;
friend class SceneContainerStack;
OMNIUI_SCENE_API
virtual void _preDrawContent(
const MouseInput& input, const Matrix44& projection, const Matrix44& view, float width, float height);
OMNIUI_SCENE_API
virtual void _drawContent(const Matrix44& projection, const Matrix44& view) = 0;
OMNIUI_SCENE_API
virtual void _postDrawContent(const Matrix44& projection, const Matrix44& view);
OMNIUI_SCENE_API
AbstractItem();
OMNIUI_SCENE_API
DrawList* _getDrawList() const;
OMNIUI_SCENE_API
virtual void _collectManagers(std::unordered_set<GestureManager*>& managers) const = 0;
};
OMNIUI_SCENE_NAMESPACE_CLOSE_SCOPE
| 5,321 | C | 32.2625 | 126 | 0.679572 |
omniverse-code/kit/include/omni/ui/scene/ManipulatorModelHelper.h | // Copyright (c) 2020-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "AbstractManipulatorModel.h"
OMNIUI_SCENE_NAMESPACE_OPEN_SCOPE
/**
* @brief The ManipulatorModelHelper class provides the basic model functionality.
*
* TODO: It's very similar to ValueModelHelper. We need to template it. It's not templated now because we need a good
* solution for pybind11. Pybind11 doesn't like templated classes.
*/
class OMNIUI_SCENE_CLASS_API ManipulatorModelHelper
{
public:
OMNIUI_SCENE_API
virtual ~ManipulatorModelHelper();
/**
* @brief Called by the model when the model value is changed. The class should react to the changes.
*
* @param item The item in the model that is changed. If it's NULL, the root is changed.
*/
OMNIUI_SCENE_API
virtual void onModelUpdated(const std::shared_ptr<const AbstractManipulatorModel::AbstractManipulatorItem>& item) = 0;
/**
* @brief Set the current model.
*/
OMNIUI_SCENE_API
virtual void setModel(const std::shared_ptr<AbstractManipulatorModel>& model);
/**
* @brief Returns the current model.
*/
OMNIUI_SCENE_API
virtual const std::shared_ptr<AbstractManipulatorModel>& getModel() const;
protected:
OMNIUI_SCENE_API
ManipulatorModelHelper(const std::shared_ptr<AbstractManipulatorModel>& model);
private:
std::shared_ptr<AbstractManipulatorModel> m_model = {};
};
OMNIUI_SCENE_NAMESPACE_CLOSE_SCOPE
| 1,837 | C | 31.821428 | 122 | 0.738704 |
omniverse-code/kit/include/omni/ui/scene/Points.h | // Copyright (c) 2021-2022, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "AbstractShape.h"
#include "Math.h"
#include "Object.h"
OMNIUI_SCENE_NAMESPACE_OPEN_SCOPE
/**
* @brief Represents the point cloud.
*/
class OMNIUI_SCENE_CLASS_API Points : public AbstractShape
{
OMNIUI_SCENE_OBJECT(Points);
public:
class PointsGesturePayload : public AbstractGesture::GesturePayload
{
public:
Float distanceToPoint = Float(0.0);
Vector3 moved = Vector3{ 0.0 };
uint32_t closestPoint = UINT32_MAX;
};
OMNIUI_SCENE_API
virtual ~Points();
OMNIUI_SCENE_API
void intersect(const Vector3 origin,
const Vector3 direction,
const Vector2 mouse,
const Matrix44& projection,
const Matrix44& view,
GestureState state) override;
/**
* @brief Contains all the information about the intersection
*/
OMNIUI_SCENE_API
const PointsGesturePayload* getGesturePayload() const override;
/**
* @brief Contains all the information about the intersection at the specific state
*/
OMNIUI_SCENE_API
const PointsGesturePayload* getGesturePayload(GestureState state) const override;
/**
* @brief The distance in pixels from mouse pointer to the shape for the intersection.
*/
OMNIUI_SCENE_API
Float getIntersectionDistance() const override;
/**
* @brief List with positions of the points
*/
OMNIUI_PROPERTY(std::vector<Vector3>, positions, READ, getPositions, WRITE, setPositions);
/**
* @brief List of colors of the points
*/
OMNIUI_PROPERTY(std::vector<Color4>, colors, READ, getColors, WRITE, setColors);
/**
* @brief List of point sizes
*/
OMNIUI_PROPERTY(std::vector<float>, sizes, READ, getSizes, WRITE, setSizes);
/**
* @brief The size of the points for the intersection
*/
OMNIUI_PROPERTY(float,
intersectionSize,
DEFAULT,
0.0,
READ,
getIntersectionSize,
WRITE,
setIntersectionSize,
PROTECTED,
NOTIFY,
_setIntersectionSizeChangedFn);
protected:
/**
* @brief Constructs the point cloud object
*
* @param positions List of positions
*/
OMNIUI_SCENE_API
Points(const std::vector<Vector3>& positions = {});
OMNIUI_SCENE_API
void _drawContent(const Matrix44& projection, const Matrix44& view) override;
std::unique_ptr<PointsGesturePayload> m_lastGesturePayload;
std::array<std::unique_ptr<PointsGesturePayload>, static_cast<uint32_t>(GestureState::eCount)> m_itersections;
bool m_intersectionSizeExplicitlyChanged = false;
};
OMNIUI_SCENE_NAMESPACE_CLOSE_SCOPE
| 3,279 | C | 28.549549 | 114 | 0.645014 |
omniverse-code/kit/include/omni/ui/scene/Space.h | // Copyright (c) 2019-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "Api.h"
#include <string>
OMNIUI_SCENE_NAMESPACE_OPEN_SCOPE
/**
* @brief 3D positions and transformations exist within coordinate systems
* called spaces.
*/
enum class Space
{
eCurrent = 0,
eWorld,
eObject,
eNdc,
eScreen,
};
/**
* @brief Get the string with the name of the given space
*/
const std::string& getSpaceName(Space space);
OMNIUI_SCENE_NAMESPACE_CLOSE_SCOPE
| 863 | C | 22.999999 | 77 | 0.745075 |
omniverse-code/kit/include/omni/ui/scene/Math.h | // Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "Api.h"
#include <glm/glm/glm.hpp>
#define _USE_MATH_DEFINES
#include <math.h>
OMNIUI_SCENE_NAMESPACE_OPEN_SCOPE
// Using double as default float type
using Float = double;
// TODO: This is a temporary placeholder. We need to implement all of this.
using Color4 = glm::vec<4, Float, glm::defaultp>;
using Vector2 = glm::vec<2, Float, glm::defaultp>;
using Vector3 = glm::vec<3, Float, glm::defaultp>;
using Vector4 = glm::vec<4, Float, glm::defaultp>;
/**
* @brief Stores a 4x4 matrix of double elements. A basic type.
*
* Matrices are defined to be in row-major order.
*
* The matrix mode is required to define the matrix that resets the
* transformation to fit the geometry into NDC, Screen space, or rotate it to
* the camera direction.
*/
class Matrix44 : public glm::mat<4, 4, Float, glm::defaultp>
{
using BaseType = glm::mat<4, 4, Float, glm::defaultp>;
public:
// Constructor
template <typename... Args>
Matrix44(Args... args) : BaseType{ args... }
{
}
// TODO: getTranslate
// TODO: getRotate
// TODO: getScale
OMNIUI_SCENE_API
Matrix44 getInverse() const;
/**
* @brief Test this matrix for equality against another one
*/
OMNIUI_SCENE_API
inline bool operator == (const Matrix44& rhs) const {
return static_cast<const BaseType&>(*this) == static_cast<const BaseType&>(rhs);
}
/**
* @brief Test this matrix for inequality against another one
*/
OMNIUI_SCENE_API
inline bool operator != (const Matrix44& rhs) const {
return static_cast<const BaseType&>(*this) != static_cast<const BaseType&>(rhs);
}
/**
* @brief Rotates the matrix to be aligned with the camera
*
* @param view The view matrix of the camera
*/
OMNIUI_SCENE_API
Matrix44& setLookAtView(Matrix44 view);
/**
* @brief Creates a matrix to specify a translation at the given coordinates
*/
OMNIUI_SCENE_API
static Matrix44 getTranslationMatrix(Float x, Float y, Float z);
/**
* @brief Creates a matrix to specify a rotation around each axis
*
* @param degrees true if the angles are specified in degrees
*/
OMNIUI_SCENE_API
static Matrix44 getRotationMatrix(Float x, Float y, Float z, bool degrees = false);
/**
* @brief Creates a matrix to specify a scaling with the given scale factor per axis
*/
OMNIUI_SCENE_API
static Matrix44 getScaleMatrix(Float x, Float y, Float z);
};
void createRay(const Matrix44& projection, const Matrix44& view, const Vector2& mouse, Vector3* rayOrigin, Vector3* rayDir);
bool lineLineFindClosestPoints(const Vector3& p11,
const Vector3& p12,
const Vector3& p21,
const Vector3& p22,
Vector3* closest1,
Vector3* closest2,
Float* t1,
Float* t2);
bool lineSegFindClosestPoints(const Vector3& p11,
const Vector3& p12,
const Vector3& p21,
const Vector3& p22,
Vector3* closest1,
Vector3* closest2,
Float* t1,
Float* t2);
bool raySegFindClosestPoints(const Vector3& rayOrigin,
const Vector3& rayDir,
const Vector3& p0,
const Vector3& p1,
Vector3* rayPoint,
Vector3* segPoint,
Float* rayDistance,
Float* segDistance);
bool raySegPlaneGesturePayload(const Vector3& rayOrigin,
const Vector3& rayDir,
const Vector3& p,
const Vector3& v1,
const Vector3& v2,
Vector3* gesturePayload,
Float* s,
Float* t);
void raySegFindClosestPoint(const Vector3& rayOrigin, const Vector3& rayDir, const Vector3& p, Vector3* closest, Float* t);
Float screenSpaceDistance(
const Vector3& p1, const Vector3& p2, const Matrix44& projection, const Matrix44& view, const Vector2& frameSize);
template <typename T>
inline void _ensureCapacity(T& buffer, size_t capacity)
{
if (buffer.capacity() < capacity)
{
buffer.reserve(capacity);
}
}
OMNIUI_SCENE_NAMESPACE_CLOSE_SCOPE
| 5,119 | C | 32.246753 | 124 | 0.588201 |
omniverse-code/kit/include/omni/ui/scene/TransformBasis.h | // Copyright (c) 2023, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "Math.h"
#include <memory>
OMNIUI_SCENE_NAMESPACE_OPEN_SCOPE
/**
* @brief A basis for mutating the transform space of a omni::ui::scene::Transform object.
*
* This class can be subclassed to implement custom space transformations. Transform objects containing
* a TransformBasis will base their transform off of the space described therein.
*/
class OMNIUI_SCENE_CLASS_API TransformBasis : public std::enable_shared_from_this<TransformBasis>
{
public:
OMNIUI_SCENE_API
virtual ~TransformBasis();
/**
* @brief Given a world-space transform matrix, return a matrix describing the transform from the supplied
* matrix into the space described by this basis object.
*
* @param other The world-space transform to convert
* @return Matrix44 A transform representing the supplied matrix in the space described by this basis object
*/
OMNIUI_SCENE_API
Matrix44 convertFromWorld(const Matrix44& other);
/**
* @brief Get a world-space matrix describing the origin point of the space described
*
* @return Matrix44 the transformation matrix needed to convert to the described space's coordinates
*/
OMNIUI_SCENE_API
virtual Matrix44 getMatrix() = 0;
protected:
friend class Transform;
/**
* @brief Reimplement if your TransformBasis subclass needs to know when it's been attached to a transform
*
*/
OMNIUI_SCENE_API
virtual void _attachToTransform();
/**
* @brief Reimplement if your TransformBasis subclass needs to know when it's been detached from a transform
*
*/
OMNIUI_SCENE_API
virtual void _detachFromTransform();
};
OMNIUI_SCENE_NAMESPACE_CLOSE_SCOPE
| 2,161 | C | 31.757575 | 112 | 0.730217 |
omniverse-code/kit/include/omni/ui/scene/SceneView.h | // Copyright (c) 2021-2022, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "AbstractItem.h"
#include "ManipulatorModelHelper.h"
#include <omni/ui/Widget.h>
OMNIUI_SCENE_NAMESPACE_OPEN_SCOPE
class AbstractDrawSystem;
class Scene;
class SceneViewPrivate;
/**
* @brief The widget to render omni.ui.scene.
*/
class OMNIUI_SCENE_CLASS_API SceneView : public Widget, public ManipulatorModelHelper
{
OMNIUI_OBJECT(SceneView)
public:
enum class AspectRatioPolicy : uint8_t
{
eStretch = 0,
ePreserveAspectFit,
ePreserveAspectCrop,
ePreserveAspectVertical,
ePreserveAspectHorizontal,
};
OMNIUI_SCENE_API
~SceneView() override;
/**
* @brief The camera projection matrix. It's a shortcut for
* Matrix44(SceneView.model.get_as_floats("projection"))
*/
OMNIUI_SCENE_API
const Matrix44& getProjection() const;
/**
* @brief The camera view matrix. It's a shortcut for
* Matrix44(SceneView.model.get_as_floats("view"))
*/
OMNIUI_SCENE_API
const Matrix44& getView() const;
/**
* @brief Called by the model when the model value is changed. The class should react to the changes.
*
* @param item The item in the model that is changed. If it's NULL, the root is changed.
*/
OMNIUI_SCENE_API
void onModelUpdated(const std::shared_ptr<const AbstractManipulatorModel::AbstractManipulatorItem>& item) override;
/**
* @brief Convert NDC 2D [-1..1] coordinates to 3D ray.
*/
OMNIUI_SCENE_API
void getRayFromNdc(const Vector2& ndc, Vector3* rayOrigin, Vector3* rayDirection) const;
/**
* @brief The container that holds the shapes, gestures and managers.
*/
OMNIUI_PROPERTY(std::shared_ptr<Scene>, scene, READ, getScene, WRITE, setScene, PROTECTED, NOTIFY, _setSceneChangedFn);
/**
* @brief Aspect ratio of the rendering screen. This screen will be fit to the widget.
*
* SceneView simulates the behavior of the Kit viewport where the rendered
* image (screen) fits into the viewport (widget), and the camera has
* multiple policies that modify the camera projection matrix's aspect ratio
* to match it to the screen aspect ratio.
*
* When screen_aspect_ratio is 0, Screen size matches the Widget bounds.
*
* \internal
* +-Widget-------------+
* | |
* +-Screen-------------+
* | |
* | +----+ |
* | / /| |
* | +----+ | |
* | | | + |
* | | |/ |
* | +----+ |
* | |
* +--------------------+
* | |
* +--------------------+
* \endinternal
*/
OMNIUI_PROPERTY(float, screenAspectRatio, DEFAULT, 0.0, READ, getScreenAspectRatio, WRITE, setScreenAspectRatio);
/**
* @brief When it's false, the mouse events from other widgets inside the
* bounds are ignored. We need it to filter out mouse events from mouse
* events of widgets in `ui.VStack(content_clipping=1)`.
*/
OMNIUI_PROPERTY(bool, childWindowsInput, DEFAULT, true, READ, isChildWindowsInput, WRITE, setChildWindowsInput);
/**
* @brief Define what happens when the aspect ratio of the camera is
* different from the aspect ratio of the widget.
*/
OMNIUI_PROPERTY(AspectRatioPolicy,
aspectRatioPolicy,
DEFAULT,
AspectRatioPolicy::ePreserveAspectHorizontal,
READ,
getAspectRatioPolicy,
WRITE,
setAspectRatioPolicy);
Matrix44 getAmendedProjection() const;
OMNIUI_SCENE_API
virtual uint32_t getTextureUsageFlags() const {
return 0;
}
protected:
/**
* Constructor.
*/
OMNIUI_SCENE_API
SceneView(const std::shared_ptr<AbstractManipulatorModel>& model = nullptr);
/**
* @brief Creates DrawSystem. By default creates ImGuiDrawSystem. The
* developer can reimplement it to use a custom backend.
*/
OMNIUI_SCENE_API
virtual std::unique_ptr<AbstractDrawSystem> _createDrawSystem() const;
/**
* @brief Returns the mouse input object that has the information about 3D
* position, orientation, buttons, etc. By default it takes the information
* from ImGui, but the developer can override it to use a custom input
* provider.
*/
OMNIUI_SCENE_API
virtual MouseInput _captureInput(float width, float height, const Matrix44& view, const Matrix44& projection) const;
/**
* @brief Reimplemented the rendering code of the widget.
*
* @see Widget::_drawContent
*/
OMNIUI_SCENE_API
void _drawContent(float elapsedTime) override;
protected:
std::unique_ptr<AbstractDrawSystem> m_draw;
// Projection-view cache to avoid querying the model every frame.
// The camera projection.
Matrix44 m_projection;
// The camera transform.
Matrix44 m_view;
std::unique_ptr<SceneViewPrivate> m_prv;
};
OMNIUI_SCENE_NAMESPACE_CLOSE_SCOPE
| 5,571 | C | 30.659091 | 123 | 0.62951 |
omniverse-code/kit/include/omni/ui/scene/Arc.h | // Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "AbstractShape.h"
#include "Culling.h"
#include "Math.h"
#include "Object.h"
#include <array>
OMNIUI_SCENE_NAMESPACE_OPEN_SCOPE
class OMNIUI_SCENE_CLASS_API Arc : public AbstractShape
{
OMNIUI_SCENE_OBJECT(Arc);
public:
class ArcGesturePayload : public AbstractGesture::GesturePayload
{
public:
Float distanceToCenter = 0.0;
Float angle = 0.0;
Float movedDistanceToCenter = 0.0;
Float movedAngle = 0.0;
Vector3 moved = Vector3{ 0.0 };
bool culled = false;
};
OMNIUI_SCENE_API
virtual ~Arc();
OMNIUI_SCENE_API
void intersect(const Vector3 origin,
const Vector3 direction,
const Vector2 mouse,
const Matrix44& projection,
const Matrix44& view,
GestureState state) override;
/**
* @brief Contains all the information about the intersection
*/
OMNIUI_SCENE_API
const ArcGesturePayload* getGesturePayload() const override;
/**
* @brief Contains all the information about the intersection at the specific state
*/
OMNIUI_SCENE_API
const ArcGesturePayload* getGesturePayload(GestureState state) const override;
/**
* @brief The distance in pixels from mouse pointer to the shape for the intersection.
*/
OMNIUI_SCENE_API
Float getIntersectionDistance() const override;
/**
* @brief The radius of the circle
*/
OMNIUI_PROPERTY(Float, radius, READ, getRadius, WRITE, setRadius, NOTIFY, _setRadiusChangedFn);
/**
* @brief The start angle of the arc.
*
* Angle placement and directions are (0 to 90): Y to Z, Z to X, X to Y
*/
OMNIUI_PROPERTY(Float, begin, DEFAULT, -Float(M_PI), READ, getBegin, WRITE, setBegin, NOTIFY, _setBeginChangedFn);
/**
* @brief The end angle of the arc.
*
* Angle placement and directions are (0 to 90): Y to Z, Z to X, X to Y
*/
OMNIUI_PROPERTY(Float, end, DEFAULT, Float(M_PI), READ, getEnd, WRITE, setEnd, NOTIFY, _setEndChangedFn);
/**
* @brief The thickness of the line
*/
OMNIUI_PROPERTY(
float, thickness, DEFAULT, 1.0, READ, getThickness, WRITE, setThickness, PROTECTED, NOTIFY, _setThicknessChangedFn);
/**
* @brief The thickness of the line for the intersection
*/
OMNIUI_PROPERTY(float,
intersectionThickness,
DEFAULT,
0.0,
READ,
getIntersectionThickness,
WRITE,
setIntersectionThickness,
PROTECTED,
NOTIFY,
_setIntersectionThicknessChangedFn);
/**
* @brief The color of the line
*/
OMNIUI_PROPERTY(
Color4, color, DEFAULT, Color4{ 1.0 }, READ, getColor, WRITE, setColor, PROTECTED, NOTIFY, _setColorChangedFn);
/**
* @brief Number of points on the curve
*/
OMNIUI_PROPERTY(uint16_t,
tesselation,
DEFAULT,
36,
READ,
getTesselation,
WRITE,
setTesselation,
PROTECTED,
NOTIFY,
_setTesselationChangedFn);
/**
* @brief When true, it's a line. When false it's a mesh.
*/
OMNIUI_PROPERTY(
bool, wireframe, DEFAULT, false, READ, isWireframe, WRITE, setWireframe, PROTECTED, NOTIFY, _setWireframeChangedFn);
/**
* @brief Draw two radii of the circle
*/
OMNIUI_PROPERTY(bool, sector, DEFAULT, true, READ, isSector, WRITE, setSector, PROTECTED, NOTIFY, _setSectorChangedFn);
/**
* @brief The axis the circle plane is perpendicular to
*/
OMNIUI_PROPERTY(uint8_t, axis, DEFAULT, 2, READ, getAxis, WRITE, setAxis, NOTIFY, _setAxisChangedFn);
/**
* @brief Draw two radii of the circle
*/
OMNIUI_PROPERTY(
Culling, culling, DEFAULT, Culling::eNone, READ, getCulling, WRITE, setCulling, PROTECTED, NOTIFY, _setCullingChangedFn);
protected:
/**
* @brief Constructs Arc
*/
OMNIUI_SCENE_API
Arc(Float radius);
OMNIUI_SCENE_API
void _drawContent(const Matrix44& projection, const Matrix44& view) override;
void _dirtyCache();
void _rebuildCache();
// Cache to avoid computation every frame
std::vector<Vector3> m_cachedPoints;
std::vector<Color4> m_cachedColors;
std::vector<uint32_t> m_cachedVertexIndices;
std::vector<uint32_t> m_cachedVertexCounts;
std::vector<uint32_t> m_cachedFlags;
std::vector<float> m_cachedThicknesses;
bool m_cacheIsDirty = true;
std::unique_ptr<ArcGesturePayload> m_lastGesturePayload;
std::array<std::unique_ptr<ArcGesturePayload>, static_cast<uint32_t>(GestureState::eCount)> m_itersections;
bool m_intersectionThicknessExplicitlyChanged = false;
};
OMNIUI_SCENE_NAMESPACE_CLOSE_SCOPE
| 5,482 | C | 29.977401 | 129 | 0.623313 |
omniverse-code/kit/include/omni/ui/scene/SceneContainerScope.h | // Copyright (c) 2020-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "Api.h"
#include <memory>
#include <stack>
// Creates the scope with the given stack widget. So all the items in the scope will be automatically placed to the
// given stack.
// TODO: Probably it's not the best name.
#define OMNIUI_SCENE_WITH_CONTAINER(A) \
for (OMNIUI_SCENE_NS::SceneContainerScope<> __parent{ A }; __parent.isValid(); __parent.invalidate())
OMNIUI_SCENE_NAMESPACE_OPEN_SCOPE
class AbstractContainer;
class AbstractItem;
/**
* @brief Singleton object that holds the stack of containers. We use it to automatically add widgets to the top
* container when the widgets are created.
*/
class OMNIUI_SCENE_CLASS_API SceneContainerStack
{
public:
// Singleton pattern.
SceneContainerStack(const SceneContainerStack&) = delete;
SceneContainerStack& operator=(const SceneContainerStack&) = delete;
// No move constructor and no move-assignments are allowed because of 12.8 [class.copy]/9 and 12.8 [class.copy]/20
// of the C++ standard
/**
* @brief The only instance of the singleton.
*/
OMNIUI_SCENE_API
static SceneContainerStack& instance();
/**
* @brief Push the container to the top of the stack. All the newly created widgets will be added to this container.
*/
OMNIUI_SCENE_API
void push(std::shared_ptr<AbstractContainer> current);
/**
* @brief Removes the container from the stack. The previous one will be active.
*/
OMNIUI_SCENE_API
void pop();
/**
* @brief Add the given widget to the top container.
*/
OMNIUI_SCENE_API
bool addChildToTop(std::shared_ptr<AbstractItem> child);
OMNIUI_SCENE_API
static std::shared_ptr<AbstractContainer> top();
private:
// Disallow instantiation outside of the class.
SceneContainerStack() = default;
std::stack<std::shared_ptr<AbstractContainer>> m_stack;
};
/**
* @brief Puts the given container to the top of the stack when this object is constructed. And removes this container
* when it's destructed.
*/
class OMNIUI_SCENE_CLASS_API SceneContainerScopeBase
{
public:
OMNIUI_SCENE_API
SceneContainerScopeBase(const std::shared_ptr<AbstractContainer> current);
OMNIUI_SCENE_API
virtual ~SceneContainerScopeBase();
/**
* @brief Returns the container it was created with.
*/
const std::shared_ptr<AbstractContainer>& get() const
{
return m_current;
}
/**
* @brief Checks if this object is valid. It's always valid untill it's invalidated. Once it's invalidated, there is
* no way to make it valid again.
*/
bool isValid() const
{
return m_isValid;
}
/**
* @brief Makes this object invalid.
*/
void invalidate()
{
m_isValid = false;
}
private:
std::shared_ptr<AbstractContainer> m_current;
bool m_isValid;
};
/**
* @brief The templated class SceneContainerScope creates a new container and puts it to the top of the stack.
*/
template <class T = void>
class SceneContainerScope : public SceneContainerScopeBase
{
public:
template <typename... Args>
SceneContainerScope(Args&&... args) : SceneContainerScopeBase{ T::create(std::forward<Args>(args)...) }
{
}
};
/**
* @brief Specialization. It takes existing container and puts it to the top of the stack.
*/
template <>
class SceneContainerScope<void> : public SceneContainerScopeBase
{
public:
template <typename... Args>
SceneContainerScope(const std::shared_ptr<AbstractContainer> current)
: SceneContainerScopeBase{ std::move(current) }
{
}
};
OMNIUI_SCENE_NAMESPACE_CLOSE_SCOPE
| 4,163 | C | 27.520548 | 120 | 0.684122 |
omniverse-code/kit/include/omni/ui/scene/PolygonMesh.h | // Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "AbstractShape.h"
#include "Math.h"
#include "Object.h"
OMNIUI_SCENE_NAMESPACE_OPEN_SCOPE
/**
* @brief Encodes a mesh.
*/
class OMNIUI_SCENE_CLASS_API PolygonMesh : public AbstractShape
{
OMNIUI_SCENE_OBJECT(PolygonMesh);
public:
class PolygonMeshGesturePayload : public AbstractGesture::GesturePayload
{
public:
// The id of the face intersected.
int32_t faceId = -1;
// The coords of the intersection in the space of the face.
Float s = 0.0;
Float t = 0.0;
};
OMNIUI_SCENE_API
virtual ~PolygonMesh();
OMNIUI_SCENE_API
void intersect(const Vector3 origin,
const Vector3 direction,
const Vector2 mouse,
const Matrix44& projection,
const Matrix44& view,
GestureState state) override;
/**
* @brief Contains all the information about the intersection
*/
OMNIUI_SCENE_API
const PolygonMeshGesturePayload* getGesturePayload() const override;
/**
* @brief Contains all the information about the intersection at the specific state
*/
OMNIUI_SCENE_API
const PolygonMeshGesturePayload* getGesturePayload(GestureState state) const override;
/**
* @brief The distance in pixels from mouse pointer to the shape for the intersection.
*/
OMNIUI_SCENE_API
Float getIntersectionDistance() const override;
/**
* @brief The primary geometry attribute, describes points in local space.
*/
OMNIUI_PROPERTY(std::vector<Vector3>, positions, READ, getPositions, WRITE, setPositions, NOTIFY, _setPositionsChangedFn);
/**
* @brief Describes colors per vertex.
*/
OMNIUI_PROPERTY(std::vector<Color4>, colors, READ, getColors, WRITE, setColors, NOTIFY, _setColorsChangedFn);
/**
* @brief Provides the number of vertices in each face of the mesh, which is
* also the number of consecutive indices in vertex_indices that define the
* face. The length of this attribute is the number of faces in the mesh.
*/
OMNIUI_PROPERTY(std::vector<uint32_t>,
vertexCounts,
READ,
getVertexCounts,
WRITE,
setVertexCounts,
NOTIFY,
_setVertexCountsChangedFn);
/**
* @brief Flat list of the index (into the points attribute) of each vertex
* of each face in the mesh.
*/
OMNIUI_PROPERTY(std::vector<uint32_t>,
vertexIndices,
READ,
getVertexIndices,
WRITE,
setVertexIndices,
NOTIFY,
_setVertexIndicesChangedFn);
/**
* @brief When wireframe is true, it defines the thicknesses of lines.
*/
OMNIUI_PROPERTY(
std::vector<float>, thicknesses, READ, getThicknesses, WRITE, setThicknesses, NOTIFY, _setThicknessesChangedFn);
/**
* @brief The thickness of the line for the intersection
*/
OMNIUI_PROPERTY(float,
intersectionThickness,
DEFAULT,
0.0,
READ,
getIntersectionThickness,
WRITE,
setIntersectionThickness,
PROTECTED,
NOTIFY,
_setIntersectionThicknessChangedFn);
/**
* @brief When true, the mesh is drawn as lines.
*/
OMNIUI_PROPERTY(bool, wireframe, DEFAULT, false, READ, isWireframe, WRITE, setWireframe, NOTIFY, _setWireframeChangedFn);
protected:
/**
* @brief Construct a mesh with predefined properties.
*
* @param positions Describes points in local space.
* @param colors Describes colors per vertex.
* @param vertexCounts The number of vertices in each face.
* @param vertexIndices The list of the index of each vertex of each face in
* the mesh.
*/
OMNIUI_SCENE_API
PolygonMesh(const std::vector<Vector3>& positions,
const std::vector<Color4>& colors,
const std::vector<uint32_t>& vertexCounts,
const std::vector<uint32_t>& vertexIndices);
OMNIUI_SCENE_API
void _drawContent(const Matrix44& projection, const Matrix44& view) override;
void _dirtyCache();
void _rebuildCache();
void _calculateST(const Vector3 origin, const Vector3 direction, Float& g_s, Float& g_t, int32_t& g_faceId,
Vector3& g_itemClosestPoint, Vector3& g_rayClosestPoint, Float& g_rayDistance);
std::unique_ptr<PolygonMeshGesturePayload> m_lastGesturePayload;
std::array<std::unique_ptr<PolygonMeshGesturePayload>, static_cast<uint32_t>(GestureState::eCount)> m_itersections;
// Cache to avoid computation every frame
std::vector<Color4> m_cachedColors;
std::vector<uint32_t> m_cachedVertexIndices;
std::vector<uint32_t> m_cachedVertexCounts;
std::vector<float> m_cachedThicknesses;
std::vector<Vector2> m_cachedUvs;
std::vector<void*> m_cachedTextures;
bool m_cacheIsDirty = true;
bool m_intersectionThicknessExplicitlyChanged = false;
};
OMNIUI_SCENE_NAMESPACE_CLOSE_SCOPE
| 5,761 | C | 33.502994 | 126 | 0.631314 |
omniverse-code/kit/include/omni/ui/scene/DrawBufferIndex.h | // Copyright (c) 2021-2022, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "Api.h"
#include "DrawBuffer.h"
#include <array>
OMNIUI_SCENE_NAMESPACE_OPEN_SCOPE
/**
* @brief A simple array with BufferType::eCount elements. Every transform can
* match to several types of bufferrs (Line and Point for example). We use this
* object to track the index of each type.
*/
class DrawBufferIndex
{
public:
DrawBufferIndex()
{
this->clear();
}
size_t& operator[](size_t i)
{
return m_index[i];
}
const size_t& operator[](size_t i) const
{
return m_index[i];
}
constexpr size_t size() const
{
return static_cast<size_t>(DrawBuffer::BufferType::eCount);
}
void clear()
{
// Default is SIZE_MAX which means "no buffer"
std::fill(m_index.begin(), m_index.end(), SIZE_MAX);
}
bool empty() const
{
for (size_t i = 0, n = this->size(); i < n; ++i)
{
if ((*this)[i] != SIZE_MAX)
{
return false;
}
}
return true;
}
private:
typedef std::array<size_t, static_cast<size_t>(DrawBuffer::BufferType::eCount)> _BufferIndexArray;
_BufferIndexArray m_index;
};
OMNIUI_SCENE_NAMESPACE_CLOSE_SCOPE
| 1,682 | C | 22.704225 | 102 | 0.630797 |
omniverse-code/kit/include/omni/ui/scene/Line.h | // Copyright (c) 2021-2022, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "AbstractShape.h"
#include "Math.h"
#include "Object.h"
OMNIUI_SCENE_NAMESPACE_OPEN_SCOPE
class OMNIUI_SCENE_CLASS_API Line : public AbstractShape
{
OMNIUI_SCENE_OBJECT(Line);
public:
class LineGesturePayload : public AbstractGesture::GesturePayload
{
public:
Float lineDistance = 0.0;
Vector3 lineClosestPoint = Vector3{ 0.0 };
Float movedDistance = 0.0;
Vector3 moved = Vector3{ 0.0 };
};
OMNIUI_SCENE_API
virtual ~Line();
OMNIUI_SCENE_API
void intersect(const Vector3 origin,
const Vector3 direction,
const Vector2 mouse,
const Matrix44& projection,
const Matrix44& view,
GestureState state) override;
/**
* @brief Contains all the information about the intersection
*/
OMNIUI_SCENE_API
const LineGesturePayload* getGesturePayload() const override;
/**
* @brief Contains all the information about the intersection at the specific state
*/
OMNIUI_SCENE_API
const LineGesturePayload* getGesturePayload(GestureState state) const override;
/**
* @brief The distance in pixels from mouse pointer to the shape for the intersection.
*/
OMNIUI_SCENE_API
Float getIntersectionDistance() const override;
/**
* @brief The start point of the line
*/
OMNIUI_PROPERTY(Vector3, start, DEFAULT, Vector3{ 0.0 }, READ, getStart, WRITE, setStart);
/**
* @brief The end point of the line
*/
OMNIUI_PROPERTY(Vector3, end, DEFAULT, Vector3{ 0.0 }, READ, getEnd, WRITE, setEnd);
/**
* @brief The line color
*/
OMNIUI_PROPERTY(Color4, color, DEFAULT, Color4{ 1.0 }, READ, getColor, WRITE, setColor);
/**
* @brief The line thickness
*/
OMNIUI_PROPERTY(float, thickness, DEFAULT, 1.0, READ, getThickness, WRITE, setThickness);
/**
* @brief The thickness of the line for the intersection
*/
OMNIUI_PROPERTY(float,
intersectionThickness,
DEFAULT,
0.0,
READ,
getIntersectionThickness,
WRITE,
setIntersectionThickness,
PROTECTED,
NOTIFY,
_setIntersectionThicknessChangedFn);
protected:
OMNIUI_SCENE_API
Line();
OMNIUI_SCENE_API
void _drawContent(const Matrix44& projection, const Matrix44& view) override;
/**
* @brief A simple line
*
* @param start The start point of the line
* @param end The end point of the line
*/
OMNIUI_SCENE_API
Line(const Vector3& start, const Vector3& end);
std::unique_ptr<LineGesturePayload> m_lastGesturePayload;
std::array<std::unique_ptr<LineGesturePayload>, static_cast<uint32_t>(GestureState::eCount)> m_itersections;
bool m_intersectionThicknessExplicitlyChanged = false;
};
OMNIUI_SCENE_NAMESPACE_CLOSE_SCOPE
| 3,483 | C | 28.525423 | 112 | 0.638817 |
omniverse-code/kit/include/omni/ui/scene/HoverGesture.h | // Copyright (c) 2021-2022, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "Object.h"
#include "ShapeGesture.h"
#include <chrono>
OMNIUI_SCENE_NAMESPACE_OPEN_SCOPE
/**
* @brief The gesture that provides a way to capture event when mouse
* enters/leaves the item.
*/
class OMNIUI_SCENE_CLASS_API HoverGesture : public ShapeGesture
{
OMNIUI_GESTURE_OBJECT(HoverGesture)
public:
OMNIUI_SCENE_API
~HoverGesture();
/**
* @brief Called before processing to determine the state of the gesture.
*/
OMNIUI_SCENE_API
void preProcess(const Matrix44& projection, const Matrix44& view) override;
/**
* @brief Process the gesture and call callbacks if necessary.
*/
OMNIUI_SCENE_API
void process() override;
/**
* @brief Called if the callback is not set and the mouse enters the item
*/
OMNIUI_SCENE_API
virtual void onBegan();
/**
* @brief Called if the callback is not set and the mouse is hovering the item
*/
OMNIUI_SCENE_API
virtual void onChanged();
/**
* @brief Called if the callback is not set and the mouse leaves the item
*/
OMNIUI_SCENE_API
virtual void onEnded();
/**
* @brief The mouse button this gesture is watching.
*/
OMNIUI_PROPERTY(uint32_t, mouseButton, DEFAULT, 0, READ, getMouseButton, WRITE, setMouseButton);
/**
* @brief The modifier that should be pressed to trigger this gesture.
*/
OMNIUI_PROPERTY(uint32_t, modifiers, DEFAULT, UINT32_MAX, READ, getModifiers, WRITE, setModifiers);
/**
* @brief Determines whether the gesture is triggered only when the
* SceneView is hovered by the mouse and not covered by other window.
* By default it is false which means the gesture will trigger regardless of
* hover state.
*/
OMNIUI_PROPERTY(bool, triggerOnViewHover, DEFAULT, false, READ, getTriggerOnViewHover, WRITE, setTriggerOnViewHover);
/**
* @brief Called when the mouse enters the item
*/
OMNIUI_CALLBACK(OnBegan, void, AbstractShape const*);
/**
* @brief Called when the mouse is hovering the item
*/
OMNIUI_CALLBACK(OnChanged, void, AbstractShape const*);
/**
* @brief Called when the mouse leaves the item
*/
OMNIUI_CALLBACK(OnEnded, void, AbstractShape const*);
protected:
/**
* @brief Constructs an gesture to track when the user clicked the mouse.
*
* @param onEnded Function that is called when the user clicked the mouse
* button.
*/
OMNIUI_SCENE_API
HoverGesture(std::function<void(AbstractShape const*)> onEnded = nullptr);
Vector3 m_itemLastPoint = Vector3{ 0.0 };
Vector3 m_rayLastPoint = Vector3{ 0.0 };
// We need it because the gesture is triggered with a delay.
std::chrono::steady_clock::time_point m_startedAt;
// Flag that indicates the state when the gesture is about to ended.
bool m_readyForEnd = false;
};
OMNIUI_SCENE_NAMESPACE_CLOSE_SCOPE
| 3,395 | C | 28.530435 | 121 | 0.687776 |
omniverse-code/kit/include/omni/ui/scene/Transform.h | // Copyright (c) 2021-2022, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "AbstractContainer.h"
#include "DrawBufferIndex.h"
#include "Math.h"
#include "Object.h"
#include "Space.h"
#include "TransformBasis.h"
OMNIUI_SCENE_NAMESPACE_OPEN_SCOPE
/**
* @brief Transforms children with component affine transformations
*/
class OMNIUI_SCENE_CLASS_API Transform : public AbstractContainer
{
OMNIUI_SCENE_OBJECT(Transform);
public:
enum class LookAt
{
eNone = 0,
eCamera,
};
OMNIUI_SCENE_API
virtual ~Transform();
OMNIUI_SCENE_API
virtual void destroy();
Matrix44 getAccumulatedTransform() const override;
/**
* @brief Single transformation matrix
*/
OMNIUI_PROPERTY(Matrix44,
transform,
DEFAULT,
Matrix44{ (Float)1.0 },
READ,
getTransform,
WRITE,
setTransform,
PROTECTED,
NOTIFY,
_setTransformChangedFn);
/**
* @brief Which space the current transform will be rescaled before applying
* the matrix. It's useful to make the object the same size regardless the
* distance to the camera.
*/
OMNIUI_PROPERTY(Space, scaleTo, DEFAULT, Space::eCurrent, READ, getScaleTo, WRITE, setScaleTo);
/**
* @brief Rotates this transform to align the direction with the camera.
*/
OMNIUI_PROPERTY(LookAt, lookAt, DEFAULT, LookAt::eNone, READ, getLookAt, WRITE, setLookAt);
/**
* @brief Set a basis to this transform. A basis defines a different/new transform space for thisTransform,
* separate from any inherited hierarchy or existing, assumed space. As such, Transform objects with a non-null
* basis will adhere to their basis and ignore any existing transform stack in their tree.
*
* @param basis The basis to set. Setting this to nullptr or an empty shared_ptr is valid.
*/
OMNIUI_SCENE_API
void setBasis(std::shared_ptr<TransformBasis> basis);
/**
* @brief Get the basis pointer for this Transform.
*
* @return std::shared_ptr<TransformBasis> This may be an empty shared_ptr.
*/
OMNIUI_SCENE_API
std::shared_ptr<TransformBasis> getBasis() const;
protected:
/**
* @brief Constructor
*/
OMNIUI_SCENE_API
Transform();
OMNIUI_SCENE_API
void _preDrawContent(
const MouseInput& input, const Matrix44& projection, const Matrix44& view, float width, float height) override;
OMNIUI_SCENE_API
void _drawContent(const Matrix44& projection, const Matrix44& view) override;
OMNIUI_SCENE_API
Transform(const Matrix44& transform);
private:
Matrix44 m_cachedTransform = Matrix44{ (Float)1.0 };
DrawBufferIndex m_bufferIndex;
std::shared_ptr<TransformBasis> m_basis;
};
OMNIUI_SCENE_NAMESPACE_CLOSE_SCOPE
| 3,337 | C | 28.539823 | 119 | 0.664369 |
omniverse-code/kit/include/omni/ui/scene/ImageHelper.h | // Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "Api.h"
#include "Math.h"
#include <omni/ui/Property.h>
OMNIUI_NAMESPACE_OPEN_SCOPE
class ImageProvider;
OMNIUI_NAMESPACE_CLOSE_SCOPE
OMNIUI_SCENE_NAMESPACE_OPEN_SCOPE
class SceneView;
/**
* @brief The helper class for the widgets that are working with image, e.g. sc.Image and sc.TexturedMesh.
*/
class OMNIUI_SCENE_CLASS_API ImageHelper
{
public:
virtual std::shared_ptr<ImageProvider> const& getImageProvider() const = 0;
virtual void setImageProvider(std::shared_ptr<ImageProvider> const& v) = 0;
virtual std::string const& getSourceUrl() const = 0;
virtual void setSourceUrl(const std::string& url) = 0;
/**
* @brief The resolution for rasterization of svg and for ImageProvider.
*/
OMNIUI_PROPERTY(uint32_t, imageWidth, DEFAULT, 0, READ, getImageWidth, WRITE, setImageWidth);
/**
* @brief The resolution of rasterization of svg and for ImageProvider.
*/
OMNIUI_PROPERTY(uint32_t, imageHeight, DEFAULT, 0, READ, getImageHeight, WRITE, setImageHeight);
protected:
ImageHelper();
virtual ~ImageHelper();
void _prepareDrawContent(
const Matrix44& projection, const Matrix44& view, bool& cacheIsDirty, void** texture, void** resource);
void _sourceUrlChanged();
void _providerChanged();
float _computeImageWidth(float width) const;
float _computeImageHeight(float height) const;
// Image resolution cache
float m_textureWidthCache = 0.0f;
float m_textureHeightCache = 0.0f;
private:
const uint32_t m_textureUsageFlags;
bool m_sourceUrlChangedInternallyFlag = false;
};
OMNIUI_SCENE_NAMESPACE_CLOSE_SCOPE
| 2,088 | C | 28.842857 | 111 | 0.733238 |
omniverse-code/kit/include/omni/ui/scene/Scene.h | // Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "AbstractContainer.h"
#include "Object.h"
OMNIUI_SCENE_NAMESPACE_OPEN_SCOPE
class DrawBuffer;
struct DrawData;
class DrawList;
class AbstractGesture;
/**
* @brief Represents the root of the scene and holds the shapes, gestures and
* managers.
*/
class OMNIUI_SCENE_CLASS_API Scene : public AbstractContainer
{
OMNIUI_SCENE_OBJECT(Scene);
public:
OMNIUI_SCENE_API
virtual ~Scene();
OMNIUI_SCENE_API
void destroy() override;
/**
* @brief Returns gesture manager used by default.
*/
OMNIUI_SCENE_API
const std::shared_ptr<GestureManager>& getDefaultGestureManager() const;
/**
* @brief Return the number of buffers used. Using for unit testing.
*/
OMNIUI_SCENE_API
size_t getDrawListBufferCount() const;
protected:
friend class AbstractItem;
friend class SceneView;
OMNIUI_SCENE_API
Scene();
void _preDrawContent(
const MouseInput&, const Matrix44& projection, const Matrix44& view, float width, float height) override;
void _drawContent(const Matrix44& projection, const Matrix44& view) override;
void _postDrawContent(const Matrix44& projection, const Matrix44& view) override;
const Scene* _getScene() const override
{
return this;
}
const DrawData& _getDrawData() const;
DrawList* _getDrawList() const;
std::unique_ptr<DrawList> m_drawList;
std::shared_ptr<GestureManager> m_defaultGestureManager;
std::vector<std::shared_ptr<GestureManager>> m_gestureManagers;
// All the managers of the children
std::unordered_set<GestureManager*> m_cachedManagers;
std::unordered_set<AbstractGesture*> m_cachedGestures;
};
OMNIUI_SCENE_NAMESPACE_CLOSE_SCOPE
| 2,178 | C | 26.582278 | 113 | 0.72314 |
omniverse-code/kit/include/omni/ui/scene/GestureManager.h | // Copyright (c) 2021-2022, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "AbstractGesture.h"
#include "Api.h"
#include "Math.h"
#include <omni/ui/Property.h>
#include <memory>
#include <string>
#include <unordered_map>
#include <unordered_set>
OMNIUI_SCENE_NAMESPACE_OPEN_SCOPE
class AbstractGesture;
struct MouseInput;
/**
* @brief The object that controls batch processing and preventing of gestures.
* Typically each scene has a default manager and if the user wants to have own
* prevention logic, he can reimplement it.
*/
class OMNIUI_SCENE_CLASS_API GestureManager
{
public:
/**
* @brief Constructor
*/
OMNIUI_SCENE_API
GestureManager();
OMNIUI_SCENE_API
virtual ~GestureManager();
/**
* @brief Set the camera
*
* @todo resolution
*/
void setView(const Matrix44& projection, const Matrix44& view, const Vector2& frameSize);
/**
* @brief Process mouse inputs and do all the intersections.
*/
void preProcess(const MouseInput& input);
/**
* @brief Process all the prevention logic and reduce the number of
* gestures.
*/
void prevent(const std::unordered_set<AbstractGesture*>& cachedGestures);
/**
* @brief Process the gestures.
*/
void process();
/**
* @brief Clean-up caches, save states.
*/
void postProcess();
/**
* @brief Called per gesture. Determines if the gesture can be prevented.
*/
OMNIUI_SCENE_API
virtual bool canBePrevented(AbstractGesture* gesture) const;
/**
* @brief Called per gesture. Determines if the gesture should be prevented
* with another gesture. Useful to resolve intersections.
*/
OMNIUI_SCENE_API
virtual bool shouldPrevent(AbstractGesture* gesture, const AbstractGesture* gesturePreventer) const;
/**
* @brief Called once a frame. Should be overriden to inject own input to the gestures.
*/
OMNIUI_SCENE_API
virtual MouseInput amendInput(MouseInput input) const;
OMNIUI_SCENE_API
void setMaxWait(uint32_t);
OMNIUI_SCENE_API
void setMaxWait(uint32_t, bool force);
OMNIUI_SCENE_API
uint32_t getMaxWait() const;
private:
friend class AbstractItem;
friend class AbstractGesture;
friend class Scene;
struct PreventCache
{
// The latest state shouldPrevent is called for
GestureState canBePreventedState = GestureState::eNone;
};
// A data structure that stores the latest prevention-related state for each
// gesture currently being managed. By preserving this state information
// across frames, the prevention logic can optimize its processing, avoiding
// unnecessary checks for gestures whose state hasn't changed.
std::unordered_map<AbstractGesture*, GestureState> m_preventionStateCache;
void _trackGesture(AbstractGesture* gesture);
void _loseGesture(AbstractGesture* gesture);
void _collectGestures(std::unordered_set<AbstractGesture*>& gesture) const;
std::unordered_map<AbstractGesture*, PreventCache> m_cachedGestures;
Matrix44 m_projection = Matrix44{ (Float)1.0 };
Matrix44 m_view = Matrix44{ (Float)1.0 };
Vector2 m_frameSize = Vector2{ (Float)0.0 };
uint32_t m_maxWait = 0;
};
OMNIUI_SCENE_NAMESPACE_CLOSE_SCOPE
| 3,702 | C | 27.05303 | 104 | 0.702053 |
omniverse-code/kit/include/omni/ui/scene/AbstractContainer.h | // Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "AbstractItem.h"
OMNIUI_SCENE_NAMESPACE_OPEN_SCOPE
/**
* @brief Base class for all the items that have children
*/
class OMNIUI_SCENE_CLASS_API AbstractContainer : public AbstractItem
{
public:
OMNIUI_SCENE_API
~AbstractContainer() override;
OMNIUI_SCENE_API
void destroy() override;
/**
* @brief Transform the given point from the coordinate system fromspace to
* the coordinate system tospace.
*/
OMNIUI_SCENE_API
Vector3 transformSpace(Space fromSpace, Space toSpace, const Vector3& point) const override;
/**
* @brief Transform the given vector from the coordinate system fromspace to
* the coordinate system tospace.
*/
OMNIUI_SCENE_API
Vector4 transformSpace(Space fromSpace, Space toSpace, const Vector4& vector) const override;
/**
* @brief Adds item to this container in a manner specific to the container. If it's allowed to have one
* sub-widget only, it will be overwriten.
*/
OMNIUI_SCENE_API
virtual void addChild(std::shared_ptr<AbstractItem> item);
/**
* @brief Removes the container items from the container.
*/
OMNIUI_SCENE_API
virtual void clear();
OMNIUI_SCENE_API
virtual Matrix44 getAccumulatedTransform() const;
protected:
OMNIUI_SCENE_API
AbstractContainer();
void _preDrawContent(
const MouseInput& input, const Matrix44& projection, const Matrix44& view, float width, float height) override;
void _postDrawContent(const Matrix44& projection, const Matrix44& view) override;
OMNIUI_SCENE_API
void _collectManagers(std::unordered_set<GestureManager*>& managers) const override;
std::vector<std::shared_ptr<AbstractItem>> m_children;
};
OMNIUI_SCENE_NAMESPACE_CLOSE_SCOPE
| 2,229 | C | 30.40845 | 119 | 0.725437 |
omniverse-code/kit/include/omni/ui/scene/Image.h | // Copyright (c) 2021-2022, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "ImageHelper.h"
#include "Rectangle.h"
OMNIUI_SCENE_NAMESPACE_OPEN_SCOPE
class OMNIUI_SCENE_CLASS_API Image : public Rectangle, public ImageHelper
{
OMNIUI_SCENE_OBJECT(Image);
public:
enum class FillPolicy : uint8_t
{
eStretch = 0,
ePreserveAspectFit,
ePreserveAspectCrop
};
OMNIUI_SCENE_API
virtual ~Image();
/**
* @brief This property holds the image URL. It can be an `omni:` path, a `file:` path, a direct path or the path
* relative to the application root directory.
*/
OMNIUI_PROPERTY(
std::string, sourceUrl, READ, getSourceUrl, WRITE, setSourceUrl, PROTECTED, NOTIFY, _setSourceUrlChangedFn);
/**
* @brief This property holds the image provider. It can be an `omni:` path, a `file:` path, a direct path or the
* path relative to the application root directory.
*/
OMNIUI_PROPERTY(std::shared_ptr<ImageProvider>,
imageProvider,
READ,
getImageProvider,
WRITE,
setImageProvider,
PROTECTED,
NOTIFY,
_setImageProviderChangedFn);
/**
* @brief Define what happens when the source image has a different size than the item.
*/
OMNIUI_PROPERTY(FillPolicy,
fillPolicy,
DEFAULT,
FillPolicy::ePreserveAspectFit,
READ,
getFillPolicy,
WRITE,
setFillPolicy,
PROTECTED,
NOTIFY,
_setFillPolicyChangedFn);
protected:
/**
* @brief Created an image with the given URL
*/
OMNIUI_SCENE_API
Image(const std::string& sourceUrl, Float width = 1.0, Float height = 1.0);
/**
* @brief Created an image with the given provider
*/
OMNIUI_SCENE_API
Image(const std::shared_ptr<ImageProvider>& imageProvider, Float width = 1.0, Float height = 1.0);
/**
* @brief Created an empty image
*/
OMNIUI_SCENE_API
Image(Float width = 1.0, Float height = 1.0);
OMNIUI_SCENE_API
void _drawContent(const Matrix44& projection, const Matrix44& view) override;
void _rebuildCache() override;
private:
void _initialize(Float width, Float height);
std::vector<Vector2> m_cachedUvs;
};
OMNIUI_SCENE_NAMESPACE_CLOSE_SCOPE
| 2,924 | C | 28.545454 | 117 | 0.613543 |
omniverse-code/kit/include/omni/ui/scene/AbstractGesture.h | // Copyright (c) 2021-2022, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "AbstractItem.h"
#include "Api.h"
#include "Math.h"
#include <memory>
#include <unordered_set>
OMNIUI_SCENE_NAMESPACE_OPEN_SCOPE
class GestureManager;
/**
* @brief The state of all the gestures. Basically it's begin-change-end, but
* each gesture gesides its workflow.
*/
enum class GestureState : uint32_t
{
eNone = 0,
ePossible,
eBegan,
eChanged,
eEnded,
eCanceled,
ePrevented,
eCount
};
/**
* @brief The base class for the gestures to provides a way to capture mouse
* events in 3d scene.
*/
class OMNIUI_SCENE_CLASS_API AbstractGesture : protected CallbackHelper<AbstractGesture>
{
public:
class GesturePayload
{
public:
Vector3 itemClosestPoint;
Vector3 rayClosestPoint;
Float rayDistance;
};
OMNIUI_SCENE_API
virtual ~AbstractGesture();
/**
* @brief Set the Manager that controld this gesture
*/
OMNIUI_SCENE_API
void setManager(const std::shared_ptr<GestureManager>& manager);
/**
* @brief The Manager that controld this gesture
*/
OMNIUI_SCENE_API
const std::shared_ptr<GestureManager>& getManager() const;
/**
* @brief Called by scene to process the mouse inputs and do intersections
* with shapes. It can be an entry point to simulate the mouse input.
*
* @todo We probably don't need projection-view here. We can get it from
* manager.
*/
virtual void dispatchInput(const MouseInput& input,
const Matrix44& projection,
const Matrix44& view,
const Vector2& frameSize) = 0;
/**
* @brief Called before the processing to determine the state of the gesture.
*/
OMNIUI_SCENE_API
virtual void preProcess(const Matrix44& projection, const Matrix44& view);
/**
* @brief Process the gesture and call callbacks if necessary.
*/
OMNIUI_SCENE_API
virtual void process();
/**
* @brief Gestures are finished. Clean-up.
*/
OMNIUI_SCENE_API
virtual void postProcess();
/**
* @brief Get the internal state that was before the current state.
*/
OMNIUI_SCENE_API
GestureState getPreviousState() const;
/**
* @brief Get the internal state of the gesture.
*/
OMNIUI_SCENE_API
GestureState getState() const;
/**
* @brief Set the internal state of the gesture. It's the way to cancel,
* prevent, or restore the gesture.
*/
OMNIUI_SCENE_API
virtual void setState(GestureState state);
/**
* @brief Returns true if the gesture is just changed at the current frame.
* If the state is not changed, `process()` will not be executed.
*/
bool isStateChanged() const;
/**
* @brief Returns the relevant shape driving the gesture.
*/
OMNIUI_SCENE_API
virtual const AbstractItem* getSender() const = 0;
/**
* @brief Shortcut for sender.get_gesturePayload
*
* @return OMNIUI_SCENE_API const*
*/
OMNIUI_SCENE_API
virtual const GesturePayload* getGesturePayload() const = 0;
/**
* @brief Shortcut for sender.get_gesturePayload
*
* @return OMNIUI_SCENE_API const*
*/
OMNIUI_SCENE_API
virtual const GesturePayload* getGesturePayload(GestureState state) const = 0;
/**
* @brief The name of the object. It's used for debugging.
*/
OMNIUI_PROPERTY(std::string, name, READ, getName, WRITE, setName);
protected:
friend class GestureManager;
OMNIUI_SCENE_API
AbstractGesture();
private:
void _setCanBePrevented(bool canBe);
bool _getCanBePrevented() const;
std::shared_ptr<GestureManager> m_manager = nullptr;
GestureState m_previousState = GestureState::eNone;
GestureState m_state = GestureState::eNone;
bool m_stateChanged = false;
bool m_cachedCanBePrevented = false;
};
OMNIUI_SCENE_NAMESPACE_CLOSE_SCOPE
| 4,427 | C | 25.201183 | 88 | 0.660041 |
omniverse-code/kit/include/omni/ui/scene/DrawBuffer.h | // Copyright (c) 2021-2022, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "Api.h"
#include "Math.h"
#include "TransformBasis.h"
#include <omni/ui/Property.h>
#include <memory>
#include <vector>
OMNIUI_NAMESPACE_USING_DIRECTIVE
OMNIUI_SCENE_NAMESPACE_OPEN_SCOPE
/**
* @brief The InvisibleButton widget provides a transparent command button.
*/
class OMNIUI_SCENE_CLASS_API DrawBuffer
{
public:
typedef uint32_t DirtyBits;
static constexpr DirtyBits kDirtyBitTransform = (1 << 0);
struct Buffer
{
virtual ~Buffer();
std::vector<Vector4> m_positions;
std::vector<Color4> m_colors;
// Hashing
size_t m_positionsHash = 0;
size_t m_colorsHash = 0;
// Dirty Bits
static constexpr DirtyBits kDirtyBitPositions = (1 << 1);
static constexpr DirtyBits kDirtyBitColors = (1 << 2);
static constexpr DirtyBits kDirtyBitAll = UINT32_MAX;
};
struct Points : public Buffer
{
~Points() override;
std::vector<float> m_sizes;
// Hashing
size_t m_sizesHash = 0;
// Dirty Bits
static constexpr DirtyBits kDirtyBitSizes = (1 << 3);
static constexpr DirtyBits kDirtyBitAll =
kDirtyBitTransform | kDirtyBitPositions | kDirtyBitColors | kDirtyBitSizes;
};
struct Lines : public Buffer
{
~Lines() override;
std::vector<float> m_thicknesses;
std::vector<uint32_t> m_vertexCounts;
std::vector<uint32_t> m_vertexIndices;
std::vector<uint32_t> m_flags;
// Hashing
size_t m_thicknessesHash = 0;
size_t m_vertexCountsHash = 0;
size_t m_vertexIndicesHash = 0;
size_t m_flagsHash = 0;
// Dirty Bits
static constexpr DirtyBits kDirtyBitThicknesses = (1 << 3);
static constexpr DirtyBits kDirtyBitVertexCounts = (1 << 4);
static constexpr DirtyBits kDirtyBitVertexIndices = (1 << 5);
static constexpr DirtyBits kDirtyBitFlags = (1 << 6);
static constexpr DirtyBits kDirtyBitAll = kDirtyBitTransform | kDirtyBitPositions | kDirtyBitColors |
kDirtyBitThicknesses | kDirtyBitVertexCounts |
kDirtyBitVertexIndices | kDirtyBitFlags;
};
struct Polys : public Buffer
{
~Polys() override;
std::vector<uint32_t> m_vertexCounts;
std::vector<uint32_t> m_vertexIndices;
std::vector<Vector2> m_uvs;
std::vector<const void*> m_textures;
std::vector<const void*> m_resources;
// Hashing
size_t m_vertexCountsHash = 0;
size_t m_vertexIndicesHash = 0;
size_t m_uvsHash = 0;
size_t m_texturesHash = 0;
// Resources are linked to textures. It's impossible that resources
// changed and textures didn't change.
// Dirty Bits
static constexpr DirtyBits kDirtyBitVertexCounts = (1 << 3);
static constexpr DirtyBits kDirtyBitVertexIndices = (1 << 4);
static constexpr DirtyBits kDirtyBitUvs = (1 << 5);
static constexpr DirtyBits kDirtyBitTextures = (1 << 6);
static constexpr DirtyBits kDirtyBitAll = kDirtyBitTransform | kDirtyBitPositions | kDirtyBitColors |
kDirtyBitVertexCounts | kDirtyBitVertexIndices | kDirtyBitUvs |
kDirtyBitTextures;
};
struct Texts : public Buffer
{
~Texts() override;
std::vector<char> m_text;
std::vector<uint32_t> m_charactersCounts;
std::vector<float> m_sizes;
std::vector<uint32_t> m_flags;
// Hashing
size_t m_textHash = 0;
size_t m_charactersCountsHash = 0;
size_t m_sizesHash = 0;
size_t m_flagsHash = 0;
// Dirty Bits
static constexpr DirtyBits kDirtyBitText = (1 << 3);
static constexpr DirtyBits kDirtyBitCharactersCounts = (1 << 4);
static constexpr DirtyBits kDirtyBitSizes = (1 << 5);
static constexpr DirtyBits kDirtyBitFlags = (1 << 6);
static constexpr DirtyBits kDirtyBitAll = kDirtyBitTransform | kDirtyBitPositions | kDirtyBitColors |
kDirtyBitText | kDirtyBitCharactersCounts | kDirtyBitSizes |
kDirtyBitFlags;
};
enum class BufferType : size_t
{
eLines = 0,
ePoints,
ePolys,
eTexts,
eCount
};
OMNIUI_SCENE_API
DrawBuffer();
OMNIUI_SCENE_API
DrawBuffer(DrawBuffer&&);
OMNIUI_SCENE_API
~DrawBuffer();
OMNIUI_SCENE_API
void beginFrame();
OMNIUI_SCENE_API
void endFrame();
OMNIUI_SCENE_API
bool empty() const;
OMNIUI_SCENE_API
void addLine(const Vector3& begin, const Vector3& end, const Color4& color, float thickness);
OMNIUI_SCENE_API
void addText(const char* text, const Vector3& point, const Color4& color, float size, uint32_t flag);
OMNIUI_SCENE_API
void addPolygonLines(const Vector3* points,
const Color4* colors,
const float* thicknesses,
const uint32_t* vertexIndices,
const uint32_t* vertexCounts,
const uint32_t* flags,
size_t vertexCountSize);
OMNIUI_SCENE_API
void addRect(Float width, Float height, const Color4& color, const void* texture);
OMNIUI_SCENE_API
void addPolygonMesh(const Vector4* points,
const Color4* colors,
const uint32_t* vertexIndices,
const uint32_t* vertexCounts,
size_t vertexCountSize,
const Matrix44* transform = nullptr,
const Vector2* uvs = nullptr,
const void* const* textures = nullptr,
const void* const* resources = nullptr);
OMNIUI_SCENE_API
void addPolygonMesh(const Vector3* points,
const Color4* colors,
const uint32_t* vertexIndices,
const uint32_t* vertexCounts,
size_t vertexCountSize,
const Matrix44* transform = nullptr,
const Vector2* uvs = nullptr,
const void* const* textures = nullptr,
const void* const* resources = nullptr);
OMNIUI_SCENE_API
void addPoints(const Vector4* positions,
const Color4* colors,
const float* sizes,
size_t pointCount,
const Matrix44* transform = nullptr);
OMNIUI_SCENE_API
void addPoints(const Vector4* positions,
const Color4& color,
float size,
size_t pointCount,
const Matrix44* transform = nullptr);
OMNIUI_SCENE_API
void addPoints(const Vector3* positions,
const Color4* colors,
const float* sizes,
size_t pointCount,
const Matrix44* transform = nullptr);
OMNIUI_SCENE_API
void addPoints(const Vector3* positions,
const Color4& color,
float size,
size_t pointCount,
const Matrix44* transform = nullptr);
OMNIUI_SCENE_API
bool getPointBuffer(const Points** points) const;
OMNIUI_SCENE_API
bool getLineBuffer(const Lines** lines) const;
OMNIUI_SCENE_API
bool getPolyBuffer(const Polys** polys) const;
OMNIUI_SCENE_API
bool getTextBuffer(const Texts** texts) const;
OMNIUI_SCENE_API
BufferType getBufferType() const;
OMNIUI_SCENE_API
void setBufferType(BufferType bufferType);
/**
* @brief Returns what changed since the last call.
*
* It knows what's changed with hashing all the arrays.
*
* @return OMNIUI_SCENE_API
*/
OMNIUI_SCENE_API
DirtyBits getDirtyBits() const;
OMNIUI_PROPERTY(Matrix44, transform, DEFAULT, Matrix44{ (Float)1.0 }, READ, getTransform, WRITE, setTransform);
OMNIUI_PROPERTY(std::shared_ptr<TransformBasis>, basis, DEFAULT, nullptr, READ_VALUE, getBasis, WRITE, setBasis);
private:
size_t calVertexIndexSize(const uint32_t* vertexCounts, size_t vertexCountSize);
size_t calPointSize(const uint32_t* vertexIndices, size_t vertexIndexSize);
template <typename PointsType>
void _addPolygonMesh(const PointsType* points,
const Vector4* colors,
const uint32_t* vertexIndices,
const uint32_t* vertexCounts,
size_t vertexCountSize,
const Matrix44* transform = nullptr,
const Vector2* uvs = nullptr,
const void* const* textures = nullptr,
const void* const* resources = nullptr);
mutable size_t m_transformHash = 0;
BufferType m_bufferType = BufferType::eCount;
std::unique_ptr<Buffer> m_buffer;
};
OMNIUI_SCENE_NAMESPACE_CLOSE_SCOPE
| 9,733 | C | 33.034965 | 117 | 0.589746 |
omniverse-code/kit/include/omni/ui/scene/Culling.h | // Copyright (c) 2019-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "Api.h"
#include <string>
OMNIUI_SCENE_NAMESPACE_OPEN_SCOPE
enum class Culling
{
eNone = 0,
eBack,
eFront,
};
OMNIUI_SCENE_NAMESPACE_CLOSE_SCOPE
| 623 | C | 23.959999 | 77 | 0.764045 |
omniverse-code/kit/include/omni/ui/scene/ShapeGesture.h | // Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "AbstractGesture.h"
#include "AbstractShape.h"
OMNIUI_SCENE_NAMESPACE_OPEN_SCOPE
/**
* @brief The base class for the gestures to provides a way to capture mouse
* events in 3d scene.
*/
class OMNIUI_SCENE_CLASS_API ShapeGesture : public AbstractGesture
{
public:
OMNIUI_SCENE_API
~ShapeGesture() override;
/**
* @brief Called by scene to process the mouse inputs and do intersections
* with shapes. It can be an entry point to simulate the mouse input.
*
* @todo We probably don't need projection-view here. We can get it from
* manager.
*/
OMNIUI_SCENE_API
void dispatchInput(const MouseInput& input,
const Matrix44& projection,
const Matrix44& view,
const Vector2& frameSize) override;
/**
* @brief Returns the relevant shape driving the gesture.
*/
OMNIUI_SCENE_API
const AbstractShape* getSender() const override;
OMNIUI_SCENE_API
const GesturePayload* getGesturePayload() const override;
OMNIUI_SCENE_API
const GesturePayload* getGesturePayload(GestureState state) const override;
OMNIUI_SCENE_API
virtual const MouseInput& getRawInput() const;
protected:
friend class AbstractShape;
OMNIUI_SCENE_API
ShapeGesture();
// Last mouse event.
MouseInput m_input;
// Last frame size
Vector2 m_frameSize;
private:
void _assignItem(AbstractShape* item);
void _dischargeItem(AbstractShape* item);
AbstractShape* m_currentShape = nullptr;
std::unordered_set<AbstractShape*> m_items;
};
OMNIUI_SCENE_NAMESPACE_CLOSE_SCOPE
| 2,100 | C | 26.644736 | 79 | 0.701905 |
omniverse-code/kit/include/omni/ui/scene/Screen.h | // Copyright (c) 2021-2022, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "AbstractShape.h"
#include "Math.h"
#include "Object.h"
OMNIUI_SCENE_NAMESPACE_OPEN_SCOPE
/**
* @brief The empty shape that triggers all the gestures at any place. Is used
* to track gestures when the user clicked the empty space. For example for
* cameras.
*/
class OMNIUI_SCENE_CLASS_API Screen : public AbstractShape
{
OMNIUI_SCENE_OBJECT(Screen);
public:
class ScreenGesturePayload : public AbstractGesture::GesturePayload
{
public:
Vector3 direction = Vector3{ 0.0 };
Vector3 moved = Vector3{ 0.0 };
// TODO: Maybe we need mouse in AbstractGesture::GesturePayload
Vector2 mouse = Vector2{ 0.0 };
Vector2 mouseMoved = Vector2{ 0.0 };
};
OMNIUI_SCENE_API
virtual ~Screen();
OMNIUI_SCENE_API
void intersect(const Vector3 origin,
const Vector3 direction,
const Vector2 mouse,
const Matrix44& projection,
const Matrix44& view,
GestureState state) override;
/**
* @brief Contains all the information about the intersection
*/
OMNIUI_SCENE_API
const ScreenGesturePayload* getGesturePayload() const override;
/**
* @brief Contains all the information about the intersection at the specific state
*/
OMNIUI_SCENE_API
const ScreenGesturePayload* getGesturePayload(GestureState state) const override;
protected:
/**
* @brief Constructor
*/
OMNIUI_SCENE_API
Screen();
OMNIUI_SCENE_API
void _drawContent(const Matrix44& projection, const Matrix44& view) override;
std::unique_ptr<ScreenGesturePayload> m_lastGesturePayload;
std::array<std::unique_ptr<ScreenGesturePayload>, static_cast<uint32_t>(GestureState::eCount)> m_itersections;
};
OMNIUI_SCENE_NAMESPACE_CLOSE_SCOPE
| 2,295 | C | 29.613333 | 114 | 0.692375 |
omniverse-code/kit/include/omni/ui/scene/Widget.h | // Copyright (c) 2021-2022, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "Rectangle.h"
#include <memory>
OMNIUI_NAMESPACE_OPEN_SCOPE
class Frame;
OMNIUI_NAMESPACE_CLOSE_SCOPE
OMNIUI_SCENE_NAMESPACE_OPEN_SCOPE
class WindowPassThroughInputGesture;
/**
* @brief The shape that contains the omni.ui widgets. It automatically creates
* IAppWindow and transfers its content to the texture of the rectangle. It
* interacts with the mouse and sends the mouse events to the underlying window,
* so interacting with the UI on this rectangle is smooth for the user.
*/
class OMNIUI_SCENE_CLASS_API Widget : public Rectangle
{
OMNIUI_SCENE_OBJECT(Widget);
public:
enum class FillPolicy : uint8_t
{
eStretch = 0,
ePreserveAspectFit,
ePreserveAspectCrop
};
enum class UpdatePolicy : uint8_t
{
eOnDemand = 0,
eAlways,
eOnMouseHovered
};
OMNIUI_SCENE_API
virtual ~Widget();
/**
* @brief Return the main frame of the widget.
*/
OMNIUI_SCENE_API
const std::shared_ptr<omni::ui::Frame>& getFrame();
/**
* @brief Rebuild and recapture the widgets at the next frame. If `frame` has `build_fn`, it will also be called.
*/
OMNIUI_SCENE_API
void invalidate();
/**
* @brief Define what happens when the source image has a different size than the item.
*/
OMNIUI_PROPERTY(FillPolicy,
fillPolicy,
DEFAULT,
FillPolicy::ePreserveAspectFit,
READ,
getFillPolicy,
WRITE,
setFillPolicy,
PROTECTED,
NOTIFY,
_setFillPolicyChangedFn);
/**
* @brief Define when to redraw the widget.
*/
OMNIUI_PROPERTY(UpdatePolicy,
updatePolicy,
DEFAULT,
UpdatePolicy::eOnMouseHovered,
READ,
getUpdatePolicy,
WRITE,
setUpdatePolicy,
PROTECTED,
NOTIFY,
_setUpdatePolicyChangedFn);
/**
* @brief The resolution scale of the widget.
*/
OMNIUI_PROPERTY(float, resolutionScale, DEFAULT, 1.0f, READ, getResolutionScale, WRITE, setResolutionScale);
/**
* @brief The resolution of the widget framebuffer.
*/
OMNIUI_PROPERTY(uint32_t, resolutionWidth, DEFAULT, 0, READ, getResolutionWidth, WRITE, setResolutionWidth);
/**
* @brief The resolution of the widget framebuffer.
*/
OMNIUI_PROPERTY(uint32_t, resolutionHeight, DEFAULT, 0, READ, getResolutionHeight, WRITE, setResolutionHeight);
protected:
/**
* @brief Created an empty image
*/
OMNIUI_SCENE_API
Widget(Float width = 1.0, Float height = 1.0);
OMNIUI_SCENE_API
void _drawContent(const Matrix44& projection, const Matrix44& view) override;
// Recursively subdivide the poly
void _subdividePoly(size_t index, uint16_t levels);
void _rebuildCache() override;
void _validateImageProvider();
float _computeResolutionWidth() const;
float _computeResolutionHeight() const;
private:
std::vector<Vector2> m_cachedUvs;
// Widget resolution
uint32_t m_imageWidth = 0;
uint32_t m_imageHeight = 0;
// How many frames the mouse is outside the shape
uint32_t m_framesWhenMouseOutside = 0;
// How many frames since last invalidate
uint32_t m_framesCount = 0;
// Gesture and Image Provider shared_ptr to use it as a gesture
std::shared_ptr<WindowPassThroughInputGesture> m_inputGesture;
// Frozen widget is not updated. But AppWindow is valid.
bool m_frozen = false;
};
OMNIUI_SCENE_NAMESPACE_CLOSE_SCOPE
| 4,224 | C | 27.547297 | 117 | 0.637311 |
omniverse-code/kit/include/omni/ui/scene/ImguiDrawSystem.h | // Copyright (c) 2021-2022, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "AbstractDrawSystem.h"
#include <omni/ui/FontHelper.h>
#include <memory>
#include <vector>
OMNIUI_SCENE_NAMESPACE_OPEN_SCOPE
class DrawBuffer;
/**
* @brief The InvisibleButton widget provides a transparent command button.
*/
class OMNIUI_SCENE_CLASS_API ImguiDrawSystem : public AbstractDrawSystem, public FontHelper
{
public:
ImguiDrawSystem();
~ImguiDrawSystem() override;
void setup() override;
void beginFrame() override;
void render(const DrawBuffer* const * buffers,
size_t bufferCount,
const Matrix44& projection,
const Matrix44& view,
float width,
float height,
float dpiScale) override;
void endFrame() override;
void destroy() override;
private:
void _drawLines(const DrawBuffer& buffer, const Matrix44& projectionView, float width, float height, float dpiScale) const;
void _cachePolys(const DrawBuffer& buffer, const Matrix44& projectionView, float width, float height) const;
void _cachePoints(const DrawBuffer& buffer, const Matrix44& projectionView, float width, float height) const;
void _drawPolys(const Matrix44& projectionView, float width, float height, float dpiScale);
void _drawPoints(const Matrix44& projectionView, float width, float height, float dpiScale);
void _drawTexts(const DrawBuffer& buffer, const Matrix44& projectionView, float width, float height, float dpiScale);
std::unique_ptr<DrawBuffer> m_flatPolyCache;
std::vector<Float> m_polyDepth;
std::vector<size_t> m_polySorted;
std::vector<size_t> m_indexStart;
std::unique_ptr<DrawBuffer> m_flatPointCache;
std::vector<size_t> m_pointSorted;
};
OMNIUI_SCENE_NAMESPACE_CLOSE_SCOPE
| 2,215 | C | 33.624999 | 127 | 0.726411 |
omniverse-code/kit/include/omni/ui/scene/ManipulatorGesture.h | // Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "AbstractGesture.h"
#include "Manipulator.h"
OMNIUI_SCENE_NAMESPACE_OPEN_SCOPE
/**
* @brief The base class for the gestures to provides a way to capture events of
* the manipulator objects
*/
class OMNIUI_SCENE_CLASS_API ManipulatorGesture : public AbstractGesture
{
public:
OMNIUI_SCENE_API
~ManipulatorGesture() override;
/**
* @brief Called by scene to process the mouse inputs and do intersections
* with shapes. It can be an entry point to simulate the mouse input.
*
* @todo We probably don't need projection-view here. We can get it from
* manager.
*/
OMNIUI_SCENE_API
void dispatchInput(const MouseInput& input,
const Matrix44& projection,
const Matrix44& view,
const Vector2& frameSize) override;
/**
* @brief Called before processing to determine the state of the gesture.
*/
OMNIUI_SCENE_API
void preProcess(const Matrix44& projection, const Matrix44& view) override;
/**
* @brief Returns the relevant shape driving the gesture.
*/
OMNIUI_SCENE_API
const Manipulator* getSender() const override;
OMNIUI_SCENE_API
const GesturePayload* getGesturePayload() const override;
OMNIUI_SCENE_API
const GesturePayload* getGesturePayload(GestureState state) const override;
protected:
friend class Manipulator;
friend class PyManipulator;
/**
* @brief Constructor
*/
OMNIUI_SCENE_API
ManipulatorGesture();
OMNIUI_SCENE_API
virtual void _processWithGesturePayload(const Manipulator* sender,
GestureState state,
std::shared_ptr<AbstractGesture::GesturePayload> gesturePayload);
// Last mouse event.
MouseInput m_input;
std::shared_ptr<AbstractGesture::GesturePayload> m_gesturePayload;
private:
void _assignItem(Manipulator* item);
void _dischargeItem(Manipulator* item);
const Manipulator* m_currentShape = nullptr;
std::unordered_set<const Manipulator*> m_items;
};
OMNIUI_SCENE_NAMESPACE_CLOSE_SCOPE
| 2,611 | C | 29.022988 | 109 | 0.685178 |
omniverse-code/kit/include/omni/ui/scene/AbstractShape.h | // Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "AbstractGesture.h"
#include "AbstractItem.h"
OMNIUI_SCENE_NAMESPACE_OPEN_SCOPE
class ShapeGesture;
/**
* @brief Base class for all the items that can be drawn and intersected with
* mouse pointer.
*/
class OMNIUI_SCENE_CLASS_API AbstractShape : public AbstractItem
{
OMNIUI_SCENE_OBJECT(AbstractShape);
public:
OMNIUI_SCENE_API
~AbstractShape() override;
OMNIUI_SCENE_API
void destroy() override;
/**
* @brief All the gestures assigned to this shape
*/
OMNIUI_SCENE_API
const std::vector<std::shared_ptr<ShapeGesture>>& getGestures() const;
/**
* @brief Replace the gestures of the shape
*/
OMNIUI_SCENE_API
void setGestures(const std::vector<std::shared_ptr<ShapeGesture>>& gestures);
/**
* @brief Add a single gesture to the shape
*/
OMNIUI_SCENE_API
void addGesture(const std::shared_ptr<ShapeGesture>& gesture);
OMNIUI_SCENE_API
virtual void intersect(const Vector3 origin,
const Vector3 direction,
const Vector2 mouse,
const Matrix44& projection,
const Matrix44& view,
GestureState state) = 0;
/**
* @brief Contains all the information about the intersection
*/
OMNIUI_SCENE_API
virtual const AbstractGesture::GesturePayload* getGesturePayload() const = 0;
/**
* @brief Contains all the information about the intersection at the specific state
*/
OMNIUI_SCENE_API
virtual const AbstractGesture::GesturePayload* getGesturePayload(GestureState state) const = 0;
/**
* @brief The distance in pixels from mouse pointer to the shape for the intersection.
*/
OMNIUI_SCENE_API
virtual Float getIntersectionDistance() const;
protected:
friend class ShapeGesture;
OMNIUI_SCENE_API
AbstractShape();
OMNIUI_SCENE_API
void _preDrawContent(
const MouseInput& input, const Matrix44& projection, const Matrix44& view, float width, float height) override;
void _collectManagers(std::unordered_set<GestureManager*>& managers) const override;
void _cacheGesturePayload(const Vector3 origin,
const Vector3 direction,
const Vector2 mouse,
const Matrix44& projection,
const Matrix44& view,
GestureState state);
std::vector<std::shared_ptr<ShapeGesture>> m_gestures;
bool m_gesturePayloadCached = false;
};
OMNIUI_SCENE_NAMESPACE_CLOSE_SCOPE
| 3,095 | C | 29.352941 | 119 | 0.657189 |
omniverse-code/kit/include/omni/ui/scene/AbstractManipulatorModel.h | // Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "Api.h"
#include "Math.h"
#include <functional>
#include <map>
#include <memory>
#include <unordered_set>
#include <vector>
OMNIUI_SCENE_NAMESPACE_OPEN_SCOPE
class ManipulatorModelHelper;
/**
* - Bridge to data.
* - Operates with double and int arrays.
* - No strings.
* - No tree, it's a flat list of items.
* - Manipulator requires the model has specific items.
*/
class OMNIUI_SCENE_CLASS_API AbstractManipulatorModel
{
public:
class AbstractManipulatorItem
{
public:
virtual ~AbstractManipulatorItem() = default;
};
using ItemChangedCallback =
std::function<void(const AbstractManipulatorModel*, const AbstractManipulatorModel::AbstractManipulatorItem*)>;
OMNIUI_SCENE_API
virtual ~AbstractManipulatorModel();
/**
* @brief Returns the items that represents the identifier.
*/
OMNIUI_SCENE_API
virtual std::shared_ptr<const AbstractManipulatorItem> getItem(const std::string& identifier);
/**
* @brief Returns the float values of the item.
*/
OMNIUI_SCENE_API
virtual std::vector<Float> getAsFloats(const std::shared_ptr<const AbstractManipulatorItem>& item) = 0;
/**
* @brief Returns the int values of the item.
*/
OMNIUI_SCENE_API
virtual std::vector<int64_t> getAsInts(const std::shared_ptr<const AbstractManipulatorItem>& item) = 0;
/**
* @brief Sets the float values of the item.
*/
OMNIUI_SCENE_API
virtual void setFloats(const std::shared_ptr<const AbstractManipulatorItem>& item, std::vector<Float> value) = 0;
/**
* @brief Sets the int values of the item.
*/
OMNIUI_SCENE_API
virtual void setInts(const std::shared_ptr<const AbstractManipulatorItem>& item, std::vector<int64_t> value) = 0;
/**
* @brief Subscribe ManipulatorModelHelper to the changes of the model.
*
* We need to use regular pointers because we subscribe in the constructor
* of the widget and unsubscribe in the destructor. In constructor smart
* pointers are not available. We also don't allow copy and move of the
* widget.
*/
OMNIUI_SCENE_API
void subscribe(ManipulatorModelHelper* manipulator);
/**
* @brief Unsubscribe the ItemModelHelper widget from the changes of the
* model.
*/
OMNIUI_SCENE_API
void unsubscribe(ManipulatorModelHelper* manipulator);
/**
* @brief Adds the function that will be called every time the value
* changes.
*
* @return The id of the callback that is used to remove the callback.
*/
OMNIUI_SCENE_API
uint32_t addItemChangedFn(ItemChangedCallback&& fn);
/**
* @brief Remove the callback by its id.
*
* @param id The id that addValueChangedFn returns.
*/
OMNIUI_SCENE_API
void removeItemChangedFn(uint32_t id);
protected:
/**
* @brief Called when any data of the model is changed. It will notify the subscribed widgets.
*
* @param item The item in the model that is changed. If it's NULL, the root is changed.
*/
OMNIUI_SCENE_API
void _itemChanged(const std::shared_ptr<const AbstractManipulatorItem>& item);
private:
// All the widgets who use this model.
std::unordered_set<ManipulatorModelHelper*> m_manipulators;
// All the callbacks.
std::vector<ItemChangedCallback> m_itemChangedCallbacks;
// If the derived model doesn't want to create new items, the default
// implementation will do it.
std::map<std::string, std::shared_ptr<const AbstractManipulatorItem>> m_defaultItems;
};
OMNIUI_SCENE_NAMESPACE_CLOSE_SCOPE
| 4,072 | C | 29.62406 | 119 | 0.696218 |
omniverse-code/kit/include/omni/ui/scene/DoubleClickGesture.h | // Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "ClickGesture.h"
#include "Object.h"
#include <chrono>
OMNIUI_SCENE_NAMESPACE_OPEN_SCOPE
/**
* @brief The gesture that provides a way to capture double clicks.
*/
class OMNIUI_SCENE_CLASS_API DoubleClickGesture : public ClickGesture
{
OMNIUI_GESTURE_OBJECT(DoubleClickGesture)
public:
OMNIUI_SCENE_API
~DoubleClickGesture();
/**
* @brief Called before processing to determine the state of the gesture.
*/
OMNIUI_SCENE_API
void preProcess(const Matrix44& projection, const Matrix44& view) override;
protected:
/**
* @brief Construct the gesture to track double clicks
*
* @param onEnded Called when the user double clicked
*/
OMNIUI_SCENE_API
DoubleClickGesture(std::function<void(AbstractShape const*)> onEnded = nullptr);
};
OMNIUI_SCENE_NAMESPACE_CLOSE_SCOPE
| 1,293 | C | 27.130434 | 84 | 0.739366 |
omniverse-code/kit/include/omni/ui/scene/bind/BindManipulator.h | // Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "BindAbstractContainer.h"
#include "DocManipulator.h"
#include "DocManipulatorModelHelper.h"
OMNIUI_PROTECT_PYBIND11_OBJECT(OMNIUI_SCENE_NS::Manipulator, Manipulator);
// clang-format off
#define OMNIUI_PYBIND_INIT_PyManipulator \
OMNIUI_PYBIND_INIT_AbstractContainer \
OMNIUI_PYBIND_INIT_CAST(model, setModel, std::shared_ptr<AbstractManipulatorModel>) \
OMNIUI_PYBIND_INIT_CAST(gesture, addGesture, std::shared_ptr<ManipulatorGesture>) \
OMNIUI_PYBIND_INIT_CAST(gestures, setGestures, std::vector<std::shared_ptr<ManipulatorGesture>>) \
OMNIUI_PYBIND_INIT_CALLBACK(on_build_fn, setOnBuildFn, void(Manipulator const*))
#define OMNIUI_PYBIND_KWARGS_DOC_Manipulator \
"\n `model : `\n " \
OMNIUI_PYBIND_DOC_ManipulatorModelHelper_getModel \
"\n `gesture : `\n " \
OMNIUI_PYBIND_DOC_Manipulator_getGestures \
"\n `gestures : `\n " \
OMNIUI_PYBIND_DOC_Manipulator_getGestures \
"\n `on_build_fn : `\n " \
OMNIUI_PYBIND_DOC_Manipulator_onBuild \
OMNIUI_PYBIND_KWARGS_DOC_AbstractContainer
// clang-format on
| 2,495 | C | 64.684209 | 120 | 0.457315 |
omniverse-code/kit/include/omni/ui/scene/bind/BindManipulatorGesture.h | // Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "BindAbstractGesture.h"
#include "DocManipulatorGesture.h"
#include <omni/ui/bind/BindUtils.h>
OMNIUI_PROTECT_PYBIND11_OBJECT(OMNIUI_SCENE_NS::ManipulatorGesture, ManipulatorGesture);
#define OMNIUI_PYBIND_INIT_ManipulatorGesture OMNIUI_PYBIND_INIT_AbstractGesture
#define OMNIUI_PYBIND_INIT_PyManipulatorGesture OMNIUI_PYBIND_INIT_ManipulatorGesture
#define OMNIUI_PYBIND_KWARGS_DOC_ManipulatorGesture OMNIUI_PYBIND_KWARGS_DOC_AbstractGesture
#define OMNIUI_PYBIND_KWARGS_DOC_PyManipulatorGesture OMNIUI_PYBIND_KWARGS_DOC_ManipulatorGesture
OMNIUI_SCENE_NAMESPACE_OPEN_SCOPE
class PyManipulatorGesture : public ManipulatorGesture
{
public:
static std::shared_ptr<PyManipulatorGesture> create(pybind11::handle derivedFrom);
void process() override;
const pybind11::handle& getHandle() const;
private:
pybind11::handle m_derivedFrom;
};
OMNIUI_SCENE_NAMESPACE_CLOSE_SCOPE
| 1,353 | C | 33.717948 | 97 | 0.810791 |
omniverse-code/kit/include/omni/ui/scene/bind/BindDoubleClickGesture.h | // Copyright (c) 2019-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "BindClickGesture.h"
#include "DocDoubleClickGesture.h"
#include <omni/ui/scene/DoubleClickGesture.h>
OMNIUI_PROTECT_PYBIND11_OBJECT(OMNIUI_SCENE_NS::DoubleClickGesture, DoubleClickGesture);
// clang-format off
#define OMNIUI_PYBIND_INIT_PyDoubleClickGesture \
OMNIUI_PYBIND_INIT_PyClickGesture
#define OMNIUI_PYBIND_KWARGS_DOC_DoubleClickGesture \
OMNIUI_PYBIND_KWARGS_DOC_ClickGesture
#define OMNIUI_PYBIND_DOC_DoubleClickGesture_OnEnded OMNIUI_PYBIND_DOC_ClickGesture_OnEnded
// clang-format on
| 1,113 | C | 37.413792 | 120 | 0.703504 |
omniverse-code/kit/include/omni/ui/scene/bind/DocTransform.h | // Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_Transform \
"Transforms children with component affine transformations.\n" \
"\n"
#define OMNIUI_PYBIND_DOC_Transform_transform "Single transformation matrix.\n"
#define OMNIUI_PYBIND_DOC_Transform_scaleTo \
"Which space the current transform will be rescaled before applying the matrix. It's useful to make the object the same size regardless the distance to the camera.\n"
#define OMNIUI_PYBIND_DOC_Transform_lookAt "Rotates this transform to align the direction with the camera.\n"
#define OMNIUI_PYBIND_DOC_Transform_basis "A custom basis for representing this transform's coordinate system.\n"
#define OMNIUI_PYBIND_DOC_Transform_Transform "Constructor.\n"
| 1,368 | C | 44.633332 | 170 | 0.665205 |
omniverse-code/kit/include/omni/ui/scene/bind/DocScreen.h | // Copyright (c) 2019-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_Screen \
"The empty shape that triggers all the gestures at any place. Is used to track gestures when the user clicked the empty space. For example for cameras.\n" \
"\n"
#define OMNIUI_PYBIND_DOC_Screen_getGesturePayload "Contains all the information about the intersection.\n"
#define OMNIUI_PYBIND_DOC_Screen_getGesturePayload01 \
"Contains all the information about the intersection at the specific state.\n"
#define OMNIUI_PYBIND_DOC_Screen_Screen "Constructor.\n"
| 1,159 | C | 47.333331 | 160 | 0.651424 |
omniverse-code/kit/include/omni/ui/scene/bind/BindAbstractShape.h | // Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "BindAbstractItem.h"
#include "DocAbstractShape.h"
// clang-format off
#define OMNIUI_PYBIND_INIT_AbstractShape \
OMNIUI_PYBIND_INIT_CALL(gesture, setGestures, pythonToGestures) \
OMNIUI_PYBIND_INIT_CALL(gestures, setGestures, pythonToGestures) \
OMNIUI_PYBIND_INIT_AbstractItem
#define OMNIUI_PYBIND_KWARGS_DOC_AbstractShape \
"\n `gesture : `\n " \
OMNIUI_PYBIND_DOC_AbstractShape_getGestures \
"\n `gestures : `\n " \
OMNIUI_PYBIND_DOC_AbstractShape_getGestures \
OMNIUI_PYBIND_KWARGS_DOC_AbstractItem
// clang-format on
OMNIUI_SCENE_NAMESPACE_OPEN_SCOPE
std::vector<std::shared_ptr<ShapeGesture>> pythonToGestures(pybind11::handle obj);
OMNIUI_SCENE_NAMESPACE_CLOSE_SCOPE
| 1,752 | C | 49.085713 | 120 | 0.512557 |
omniverse-code/kit/include/omni/ui/scene/bind/BindTransform.h | // Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "BindAbstractContainer.h"
#include "DocTransform.h"
// clang-format off
#define OMNIUI_PYBIND_INIT_Transform \
OMNIUI_PYBIND_INIT_AbstractContainer \
OMNIUI_PYBIND_INIT_CALL(transform, setTransform, pythonToMatrix4) \
OMNIUI_PYBIND_INIT_CAST(scale_to, setScaleTo, Space) \
OMNIUI_PYBIND_INIT_CAST(look_at, setLookAt, Transform::LookAt) \
OMNIUI_PYBIND_INIT_CAST(basis, setBasis, std::shared_ptr<TransformBasis>)
#define OMNIUI_PYBIND_KWARGS_DOC_Transform \
"\n `transform : `\n " \
OMNIUI_PYBIND_DOC_Transform_transform \
"\n `scale_to : `\n " \
OMNIUI_PYBIND_DOC_Transform_scaleTo \
"\n `look_at : `\n " \
OMNIUI_PYBIND_DOC_Transform_lookAt \
"\n `basis : `\n " \
OMNIUI_PYBIND_DOC_Transform_basis \
OMNIUI_PYBIND_KWARGS_DOC_AbstractContainer
// clang-format on
| 2,377 | C | 66.942855 | 120 | 0.395036 |
omniverse-code/kit/include/omni/ui/scene/bind/BindLabel.h | // Copyright (c) 2018-2022, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "BindAbstractShape.h"
#include "DocLabel.h"
// clang-format off
#define OMNIUI_PYBIND_INIT_Label \
OMNIUI_PYBIND_INIT_AbstractShape \
OMNIUI_PYBIND_INIT_CALL(color, setColor, pythonToColor4) \
OMNIUI_PYBIND_INIT_CAST(size, setSize, float) \
OMNIUI_PYBIND_INIT_CAST(alignment, setAlignment, Alignment) \
OMNIUI_PYBIND_INIT_CAST(text, setText, std::string)
#define OMNIUI_PYBIND_KWARGS_DOC_Label \
"\n `color : `\n " \
OMNIUI_PYBIND_DOC_Label_color \
"\n `size : `\n " \
OMNIUI_PYBIND_DOC_Label_size \
"\n `alignment : `\n " \
OMNIUI_PYBIND_DOC_Label_alignment \
"\n `text : `\n " \
OMNIUI_PYBIND_DOC_Label_text \
OMNIUI_PYBIND_KWARGS_DOC_AbstractShape
// clang-format on
| 2,341 | C | 67.882351 | 120 | 0.365229 |
omniverse-code/kit/include/omni/ui/scene/bind/DocShapeGesture.h | // Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_ShapeGesture \
"The base class for the gestures to provides a way to capture mouse events in 3d scene.\n" \
"\n"
#define OMNIUI_PYBIND_DOC_ShapeGesture_dispatchInput \
"Called by scene to process the mouse inputs and do intersections with shapes. It can be an entry point to simulate the mouse input.\n" \
"Todo\n" \
"We probably don't need projection-view here. We can get it from manager.\n"
#define OMNIUI_PYBIND_DOC_ShapeGesture_getSender "Returns the relevant shape driving the gesture.\n"
| 1,311 | C | 56.043476 | 141 | 0.578947 |
omniverse-code/kit/include/omni/ui/scene/bind/DocAbstractContainer.h | // Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_AbstractContainer \
"Base class for all the items that have children.\n" \
"\n"
#define OMNIUI_PYBIND_DOC_AbstractContainer_transformSpace \
"Transform the given point from the coordinate system fromspace to the coordinate system tospace.\n"
#define OMNIUI_PYBIND_DOC_AbstractContainer_transformSpace01 \
"Transform the given vector from the coordinate system fromspace to the coordinate system tospace.\n"
#define OMNIUI_PYBIND_DOC_AbstractContainer_addChild \
"Adds item to this container in a manner specific to the container. If it's allowed to have one sub-widget only, it will be overwriten.\n"
#define OMNIUI_PYBIND_DOC_AbstractContainer_clear "Removes the container items from the container.\n"
| 1,526 | C | 51.655171 | 142 | 0.619266 |
omniverse-code/kit/include/omni/ui/scene/bind/DocScrollGesture.h | // Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_ScrollGesture \
"The gesture that provides a way to capture mouse scroll event.\n" \
"\n"
#define OMNIUI_PYBIND_DOC_ScrollGesture_preProcess "Called before processing to determine the state of the gesture.\n"
#define OMNIUI_PYBIND_DOC_ScrollGesture_process "Process the gesture and call callbacks if necessary.\n"
#define OMNIUI_PYBIND_DOC_ScrollGesture_onEnded "Called if the callback is not set when the user scrolls.\n"
#define OMNIUI_PYBIND_DOC_ScrollGesture_mouseButton "The mouse button this gesture is watching.\n"
#define OMNIUI_PYBIND_DOC_ScrollGesture_modifiers "The modifier that should be pressed to trigger this gesture.\n"
#define OMNIUI_PYBIND_DOC_ScrollGesture_OnEnded "Called when the user scrolls.\n"
#define OMNIUI_PYBIND_DOC_ScrollGesture_getScroll "Returns the current scroll state.\n"
#define OMNIUI_PYBIND_DOC_ScrollGesture_ScrollGesture \
"Constructs an gesture to track when the user clicked the mouse.\n" \
"\n" \
"\n" \
"### Arguments:\n" \
"\n" \
" `onEnded :`\n" \
" Function that is called when the user clicked the mouse button.\n"
| 2,366 | C | 51.599999 | 120 | 0.509298 |
omniverse-code/kit/include/omni/ui/scene/bind/DocClickGesture.h | // Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_ClickGesture \
"The gesture that provides a way to capture click mouse event.\n" \
"\n"
#define OMNIUI_PYBIND_DOC_ClickGesture_preProcess "Called before processing to determine the state of the gesture.\n"
#define OMNIUI_PYBIND_DOC_ClickGesture_process "Process the gesture and call callbacks if necessary.\n"
#define OMNIUI_PYBIND_DOC_ClickGesture_onEnded \
"Called if the callback is not set when the user releases the mouse button.\n"
#define OMNIUI_PYBIND_DOC_ClickGesture_mouseButton "The mouse button this gesture is watching.\n"
#define OMNIUI_PYBIND_DOC_ClickGesture_modifiers "The modifier that should be pressed to trigger this gesture.\n"
#define OMNIUI_PYBIND_DOC_ClickGesture_OnEnded "Called when the user releases the button.\n"
#define OMNIUI_PYBIND_DOC_ClickGesture_ClickGesture \
"Constructs an gesture to track when the user clicked the mouse.\n" \
"\n" \
"\n" \
"### Arguments:\n" \
"\n" \
" `onEnded :`\n" \
" Function that is called when the user clicked the mouse button.\n"
| 2,371 | C | 54.162789 | 120 | 0.482497 |
omniverse-code/kit/include/omni/ui/scene/bind/DocLabel.h | // Copyright (c) 2020-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_Label \
"\n" \
"Defines a standard label for user interface items\n"
#define OMNIUI_PYBIND_DOC_Label_text "This property holds the label's text.\n"
#define OMNIUI_PYBIND_DOC_Label_color "The color of the text.\n"
#define OMNIUI_PYBIND_DOC_Label_alignment \
"This property holds the alignment of the label's contents. By default, the contents of the label are left-aligned and vertically-centered.\n"
#define OMNIUI_PYBIND_DOC_Label_size "The font size.\n"
#define OMNIUI_PYBIND_DOC_Label_Label \
"A standard label for user interface items.\n" \
"\n" \
"\n" \
"### Arguments:\n" \
"\n" \
" `text :`\n" \
" The string with the text to display\n"
| 2,130 | C | 56.594593 | 146 | 0.397183 |
omniverse-code/kit/include/omni/ui/scene/bind/DocImage.h | // Copyright (c) 2020-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_Image \
"\n" \
"\n"
#define OMNIUI_PYBIND_DOC_Image_sourceUrl \
"This property holds the image URL. It can be an \"omni:\" path, a \"file:\" path, a direct path or the path " \
"relative to the application root directory.\n"
#define OMNIUI_PYBIND_DOC_Image_imageProvider \
"This property holds the image provider. It can be an \"omni:\" path, a \"file:\" path, a direct path or the path "\
"relative to the application root directory.\n"
#define OMNIUI_PYBIND_DOC_Image_fillPolicy \
"Define what happens when the source image has a different size than the item.\n"
#define OMNIUI_PYBIND_DOC_Image_Image "Created an image with the given URL.\n"
#define OMNIUI_PYBIND_DOC_Image_Image01 "Created an image with the given provider.\n"
#define OMNIUI_PYBIND_DOC_Image_Image2 "Created an empty image.\n"
| 1,743 | C | 46.135134 | 120 | 0.557659 |
omniverse-code/kit/include/omni/ui/scene/bind/BindPoints.h | // Copyright (c) 2020-2022, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "BindAbstractShape.h"
#include "DocPoints.h"
// clang-format off
#define OMNIUI_PYBIND_INIT_Points \
OMNIUI_PYBIND_INIT_AbstractShape \
OMNIUI_PYBIND_INIT_CALL(positions, setPositions, pythonListToVector3) \
OMNIUI_PYBIND_INIT_CALL(colors, setColors, pythonListToVector4) \
OMNIUI_PYBIND_INIT_CAST(sizes, setSizes, std::vector<float>) \
OMNIUI_PYBIND_INIT_CAST(intersection_sizes, setIntersectionSize, float)
#define OMNIUI_PYBIND_KWARGS_DOC_Points \
"\n `positions : `\n " \
OMNIUI_PYBIND_DOC_Points_positions \
"\n `colors : `\n " \
OMNIUI_PYBIND_DOC_Points_colors \
"\n `sizes : `\n " \
OMNIUI_PYBIND_DOC_Points_sizes \
"\n `intersection_sizes : `\n " \
OMNIUI_PYBIND_DOC_Points_intersectionSize \
OMNIUI_PYBIND_KWARGS_DOC_AbstractShape
// clang-format on
| 2,363 | C | 66.542855 | 120 | 0.397799 |
omniverse-code/kit/include/omni/ui/scene/bind/DocSceneView.h | // Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_SceneView \
"The widget to render omni.ui.scene.\n" \
"\n"
#define OMNIUI_PYBIND_DOC_SceneView_getProjection \
"The camera projection matrix. It's a shortcut for Matrix44(SceneView.model.get_as_floats(\"projection\"))\n"
#define OMNIUI_PYBIND_DOC_SceneView_getView \
"The camera view matrix. It's a shortcut for Matrix44(SceneView.model.get_as_floats(\"view\"))\n"
#define OMNIUI_PYBIND_DOC_SceneView_onModelUpdated \
"Called by the model when the model value is changed. The class should react to the changes.\n" \
"\n" \
"\n" \
"### Arguments:\n" \
"\n" \
" `item :`\n" \
" The item in the model that is changed. If it's NULL, the root is changed.\n\n"
#define OMNIUI_PYBIND_DOC_SceneView_scene "The container that holds the shapes, gestures and managers.\n"
#define OMNIUI_PYBIND_DOC_SceneView_screenAspectRatio \
"Aspect ratio of the rendering screen. This screen will be fit to the widget. " \
"SceneView simulates the behavior of the Kit viewport where the rendered image (screen) fits into the viewport " \
"(widget), and the camera has multiple policies that modify the camera projection matrix's aspect ratio to match " \
"it to the screen aspect ratio. " \
"When screen_aspect_ratio is 0, Screen size matches the Widget bounds.\n"
#define OMNIUI_PYBIND_DOC_SceneView_childWindowsInput \
"When it's false, the mouse events from other widgets inside the bounds are ignored. We need it to filter out mouse events from mouse events of widgets in `ui.VStack(content_clipping=1)`.\n"
#define OMNIUI_PYBIND_DOC_SceneView_aspectRatioPolicy \
"Define what happens when the aspect ratio of the camera is different from the aspect ratio of the widget.\n"
#define OMNIUI_PYBIND_DOC_SceneView_SceneView "Constructor.\n"
| 3,513 | C | 64.074073 | 194 | 0.478508 |
omniverse-code/kit/include/omni/ui/scene/bind/DocDoubleClickGesture.h | // Copyright (c) 2020-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_DoubleClickGesture \
"The gesture that provides a way to capture double clicks.\n" \
"\n"
#define OMNIUI_PYBIND_DOC_DoubleClickGesture_preProcess \
"Called before processing to determine the state of the gesture.\n"
#define OMNIUI_PYBIND_DOC_DoubleClickGesture_DoubleClickGesture \
"Construct the gesture to track double clicks.\n" \
"\n" \
"\n" \
"### Arguments:\n" \
"\n" \
" `onEnded :`\n" \
" Called when the user double clicked\n"
| 1,800 | C | 63.321426 | 120 | 0.388333 |
omniverse-code/kit/include/omni/ui/scene/bind/DocCameraModel.h | // Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_CameraModel \
"\n" \
"A model that holds projection and view matrices\n"
#define OMNIUI_PYBIND_DOC_CameraModel_CameraModel "Initialize the camera with the given projection/view matrices.\n"
#define OMNIUI_PYBIND_DOC_CameraModel_getItem "Returns the items that represents the identifier.\n"
#define OMNIUI_PYBIND_DOC_CameraModel_getAsFloats "Returns the float values of the item.\n"
#define OMNIUI_PYBIND_DOC_CameraModel_getAsInts "Returns the int values of the item.\n"
#define OMNIUI_PYBIND_DOC_CameraModel_setFloats "Sets the float values of the item.\n"
#define OMNIUI_PYBIND_DOC_CameraModel_setInts "Sets the int values of the item.\n"
#define OMNIUI_PYBIND_DOC_CameraModel_getProjection "The camera projection matrix.\n"
#define OMNIUI_PYBIND_DOC_CameraModel_getView "The camera view matrix.\n"
#define OMNIUI_PYBIND_DOC_CameraModel_setProjection "Set the camera projection matrix.\n"
#define OMNIUI_PYBIND_DOC_CameraModel_setView "Set the camera view matrix.\n"
| 1,661 | C | 36.772726 | 120 | 0.69416 |
omniverse-code/kit/include/omni/ui/scene/bind/DocManipulator.h | // Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_Manipulator \
"The base object for the custom manipulators.\n" \
"\n"
#define OMNIUI_PYBIND_DOC_Manipulator_onBuild "Called when Manipulator is dirty to build the content.\n"
#define OMNIUI_PYBIND_DOC_Manipulator_invalidate \
"Make Manipulator dirty so onBuild will be executed in _preDrawContent.\n"
#define OMNIUI_PYBIND_DOC_Manipulator_onModelUpdated \
"Called by the model when the model value is changed. The class should react to the changes.\n" \
"\n" \
"\n" \
"### Arguments:\n" \
"\n" \
" `item :`\n" \
" The item in the model that is changed. If it's NULL, the root is changed.\n"
#define OMNIUI_PYBIND_DOC_Manipulator_getGestures "All the gestures assigned to this manipulator.\n"
#define OMNIUI_PYBIND_DOC_Manipulator_setGestures "Replace the gestures of the manipulator.\n"
#define OMNIUI_PYBIND_DOC_Manipulator_addGesture "Add a single gesture to the manipulator.\n"
#define OMNIUI_PYBIND_DOC_Manipulator_OnBuild \
"Called when Manipulator is dirty to build the content. It's another way to build the manipulator's content on the case the user doesn't want to reimplement the class.\n"
#define OMNIUI_PYBIND_DOC_Manipulator_Manipulator "Constructor.\n"
| 2,610 | C | 54.55319 | 174 | 0.488123 |
omniverse-code/kit/include/omni/ui/scene/bind/BindDragGesture.h | // Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "BindShapeGesture.h"
#include "DocDragGesture.h"
#include <omni/ui/scene/DragGesture.h>
OMNIUI_PROTECT_PYBIND11_OBJECT(OMNIUI_SCENE_NS::DragGesture, DragGesture);
// clang-format off
#define OMNIUI_PYBIND_INIT_PyDragGesture \
OMNIUI_PYBIND_INIT_CAST(mouse_button, setMouseButton, uint32_t) \
OMNIUI_PYBIND_INIT_CAST(modifiers, setModifiers, uint32_t) \
OMNIUI_PYBIND_INIT_CAST(check_mouse_moved, setCheckMouseMoved, bool) \
OMNIUI_PYBIND_INIT_CALLBACK(on_began_fn, setOnBeganFn, void(AbstractShape const*)) \
OMNIUI_PYBIND_INIT_CALLBACK(on_changed_fn, setOnChangedFn, void(AbstractShape const*)) \
OMNIUI_PYBIND_INIT_CALLBACK(on_ended_fn, setOnEndedFn, void(AbstractShape const*)) \
OMNIUI_PYBIND_INIT_ShapeGesture
#define OMNIUI_PYBIND_KWARGS_DOC_DragGesture \
"\n `mouse_button : `\n " \
OMNIUI_PYBIND_DOC_DragGesture_mouseButton \
"\n `modifiers : `\n " \
OMNIUI_PYBIND_DOC_DragGesture_modifiers \
"\n `check_mouse_moved : `\n " \
OMNIUI_PYBIND_DOC_DragGesture_checkMouseMoved \
"\n `on_began_fn : `\n " \
OMNIUI_PYBIND_DOC_DragGesture_onBegan \
"\n `on_changed_fn : `\n " \
OMNIUI_PYBIND_DOC_DragGesture_onChanged \
"\n `on_ended_fn : `\n " \
OMNIUI_PYBIND_DOC_DragGesture_onEnded \
OMNIUI_PYBIND_KWARGS_DOC_ShapeGesture
// clang-format on
| 3,163 | C | 69.31111 | 120 | 0.413215 |
omniverse-code/kit/include/omni/ui/scene/bind/DocDragGesture.h | // Copyright (c) 2018-2023, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_DragGesture \
"The gesture that provides a way to capture click-and-drag mouse event.\n" \
"\n"
#define OMNIUI_PYBIND_DOC_DragGesture_preProcess "Called before processing to determine the state of the gesture.\n"
#define OMNIUI_PYBIND_DOC_DragGesture_process "Process the gesture and call callbacks if necessary.\n"
#define OMNIUI_PYBIND_DOC_DragGesture_onBegan \
"Called if the callback is not set when the user clicks the mouse button.\n"
#define OMNIUI_PYBIND_DOC_DragGesture_onChanged \
"Called if the callback is not set when the user moves the clicked button.\n"
#define OMNIUI_PYBIND_DOC_DragGesture_onEnded \
"Called if the callback is not set when the user releases the mouse button.\n"
#define OMNIUI_PYBIND_DOC_DragGesture_mouseButton "Mouse button that should be active to start the gesture.\n"
#define OMNIUI_PYBIND_DOC_DragGesture_modifiers "The keyboard modifier that should be active ti start the gesture.\n"
#define OMNIUI_PYBIND_DOC_DragGesture_checkMouseMoved \
"The check_mouse_moved property is a boolean flag that determines whether the DragGesture should verify if the 2D screen position of the mouse has changed before invoking the on_changed method. This property is essential in a 3D environment, as changes in the camera position can result in the mouse pointing to different locations in the 3D world even when the 2D screen position remains unchanged.\n\n" \
"Usage\n" \
"When check_mouse_moved is set to True, the DragGesture will only call the on_changed method if the actual 2D screen position of the mouse has changed. This can be useful when you want to ensure that the on_changed method is only triggered when there is a genuine change in the mouse's 2D screen position.\n" \
"If check_mouse_moved is set to False, the DragGesture will not check for changes in the mouse's 2D screen position before calling the on_changed method. This can be useful when you want the on_changed method to be invoked even if the mouse's 2D screen position hasn't changed, such as when the camera position is altered, and the mouse now points to a different location in the 3D world.\n"
#define OMNIUI_PYBIND_DOC_DragGesture_OnBegan "Called when the user starts drag.\n"
#define OMNIUI_PYBIND_DOC_DragGesture_OnChanged "Called when the user is dragging.\n"
#define OMNIUI_PYBIND_DOC_DragGesture_OnEnded "Called when the user releases the mouse and finishes the drag.\n"
#define OMNIUI_PYBIND_DOC_DragGesture_DragGesture "Construct the gesture to track mouse drags.\n"
| 4,201 | C | 72.719297 | 410 | 0.562247 |
omniverse-code/kit/include/omni/ui/scene/bind/DocPoints.h | // Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_Points \
"Represents the point cloud.\n" \
"\n"
#define OMNIUI_PYBIND_DOC_Points_getGesturePayload "Contains all the information about the intersection.\n"
#define OMNIUI_PYBIND_DOC_Points_getGesturePayload01 \
"Contains all the information about the intersection at the specific state.\n"
#define OMNIUI_PYBIND_DOC_Points_getIntersectionDistance \
"The distance in pixels from mouse pointer to the shape for the intersection.\n"
#define OMNIUI_PYBIND_DOC_Points_positions "List with positions of the points.\n"
#define OMNIUI_PYBIND_DOC_Points_colors "List of colors of the points.\n"
#define OMNIUI_PYBIND_DOC_Points_sizes "List of point sizes.\n"
#define OMNIUI_PYBIND_DOC_Points_intersectionSize "The size of the points for the intersection.\n"
#define OMNIUI_PYBIND_DOC_Points_Points \
"Constructs the point cloud object.\n" \
"\n" \
"\n" \
"### Arguments:\n" \
"\n" \
" `positions :`\n" \
" List of positions\n"
| 2,440 | C | 50.936169 | 120 | 0.442213 |
omniverse-code/kit/include/omni/ui/scene/bind/DocMatrix44.h | // Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_Matrix44 \
"Stores a 4x4 matrix of float elements. A basic type.\n" \
"Matrices are defined to be in row-major order.\n" \
"The matrix mode is required to define the matrix that resets the transformation to fit the geometry into NDC, Screen space, or rotate it to the camera direction.\n"
#define OMNIUI_PYBIND_DOC_Matrix44_setLookAtView \
"Rotates the matrix to be aligned with the camera.\n" \
"\n" \
"\n" \
"### Arguments:\n" \
"\n" \
" `view :`\n" \
" The view matrix of the camera\n"
#define OMNIUI_PYBIND_DOC_Matrix44_getTranslationMatrix \
"Creates a matrix to specify a translation at the given coordinates.\n"
#define OMNIUI_PYBIND_DOC_Matrix44_getRotationMatrix \
"Creates a matrix to specify a rotation around each axis.\n" \
"\n" \
"\n" \
"### Arguments:\n" \
"\n" \
" `degrees :`\n" \
" true if the angles are specified in degrees\n"
#define OMNIUI_PYBIND_DOC_Matrix44_getScaleMatrix \
"Creates a matrix to specify a scaling with the given scale factor per axis.\n"
| 3,191 | C | 73.232556 | 169 | 0.340019 |
omniverse-code/kit/include/omni/ui/scene/bind/DocImageHelper.h | // Copyright (c) 2018-2022, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_ImageHelper \
"The helper class for the widgets that are working with image, e.g. sc.Image and sc.TexturedMesh.\n" \
"\n"
#define OMNIUI_PYBIND_DOC_ImageHelper_imageWidth "The resolution for rasterization of svg and for ImageProvider.\n"
#define OMNIUI_PYBIND_DOC_ImageHelper_imageHeight "The resolution of rasterization of svg and for ImageProvider.\n"
| 940 | C | 46.049998 | 120 | 0.704255 |
omniverse-code/kit/include/omni/ui/scene/bind/DocAbstractItem.h | // Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_AbstractItem \
"\n" \
"\n"
#define OMNIUI_PYBIND_DOC_AbstractItem_destroy "Removes all the callbacks and circular references.\n"
#define OMNIUI_PYBIND_DOC_AbstractItem_transformSpace \
"Transform the given point from the coordinate system fromspace to the coordinate system tospace.\n"
#define OMNIUI_PYBIND_DOC_AbstractItem_transformSpace01 \
"Transform the given vector from the coordinate system fromspace to the coordinate system tospace.\n"
#define OMNIUI_PYBIND_DOC_AbstractItem_computeVisibility \
"Calculate the effective visibility of this prim, as defined by its most ancestral invisible opinion, if any.\n"
#define OMNIUI_PYBIND_DOC_AbstractItem_sceneView "The current SceneView this item is parented to.\n"
#define OMNIUI_PYBIND_DOC_AbstractItem_visible "This property holds whether the item is visible.\n"
| 1,705 | C | 47.742856 | 120 | 0.610557 |
omniverse-code/kit/include/omni/ui/scene/bind/BindAbstractGesture.h | // Copyright (c) 2019-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "DocAbstractGesture.h"
#include <omni/ui/bind/BindUtils.h>
OMNIUI_PROTECT_PYBIND11_OBJECT(OMNIUI_SCENE_NS::AbstractGesture, AbstractGesture);
// clang-format off
#define OMNIUI_PYBIND_INIT_AbstractGesture \
OMNIUI_PYBIND_INIT_CAST(name, setName, std::string) \
OMNIUI_PYBIND_INIT_CAST(manager, setManager, std::shared_ptr<GestureManager>)
#define OMNIUI_PYBIND_KWARGS_DOC_AbstractGesture \
"\n `name : `\n " \
OMNIUI_PYBIND_DOC_AbstractGesture_name \
"\n `manager : `\n " \
OMNIUI_PYBIND_DOC_AbstractGesture_getManager
// clang-format on
| 1,506 | C | 49.233332 | 120 | 0.518592 |
omniverse-code/kit/include/omni/ui/scene/bind/BindImage.h | // Copyright (c) 2020-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "BindRectangle.h"
#include "DocImage.h"
#include "DocImageHelper.h"
// clang-format off
#define OMNIUI_PYBIND_INIT_Image \
OMNIUI_PYBIND_INIT_Rectangle \
OMNIUI_PYBIND_INIT_CAST(source_url, setSourceUrl, std::string) \
OMNIUI_PYBIND_INIT_CAST(image_provider, setImageProvider, std::shared_ptr<ImageProvider>) \
OMNIUI_PYBIND_INIT_CAST(fill_policy, setFillPolicy, Image::FillPolicy) \
OMNIUI_PYBIND_INIT_CAST(image_width, setImageWidth, uint32_t) \
OMNIUI_PYBIND_INIT_CAST(image_height, setImageHeight, uint32_t) \
#define OMNIUI_PYBIND_KWARGS_DOC_Image \
"\n `source_url : `\n " \
OMNIUI_PYBIND_DOC_Image_sourceUrl \
"\n `image_provider : `\n " \
OMNIUI_PYBIND_DOC_Image_imageProvider \
"\n `fill_policy : `\n " \
OMNIUI_PYBIND_DOC_Image_fillPolicy \
"\n `image_width : `\n " \
OMNIUI_PYBIND_DOC_ImageHelper_imageWidth \
"\n `image_height : `\n " \
OMNIUI_PYBIND_DOC_ImageHelper_imageHeight \
OMNIUI_PYBIND_KWARGS_DOC_Rectangle
// clang-format on
| 2,770 | C | 70.05128 | 120 | 0.387004 |
omniverse-code/kit/include/omni/ui/scene/bind/DocAbstractManipulatorModel.h | // Copyright (c) 2021-2022, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_AbstractManipulatorModel \
"\n" \
"Bridge to data.\n" \
"Operates with double and int arrays.\n" \
"No strings.\n" \
"No tree, it's a flat list of items.\n" \
"Manipulator requires the model has specific items.\n"
#define OMNIUI_PYBIND_DOC_AbstractManipulatorModel_getItem "Returns the items that represents the identifier.\n"
#define OMNIUI_PYBIND_DOC_AbstractManipulatorModel_getAsFloats "Returns the Float values of the item.\n"
#define OMNIUI_PYBIND_DOC_AbstractManipulatorModel_getAsInts "Returns the int values of the item.\n"
#define OMNIUI_PYBIND_DOC_AbstractManipulatorModel_setFloats "Sets the Float values of the item.\n"
#define OMNIUI_PYBIND_DOC_AbstractManipulatorModel_setInts "Sets the int values of the item.\n"
#define OMNIUI_PYBIND_DOC_AbstractManipulatorModel_subscribe \
"Subscribe ManipulatorModelHelper to the changes of the model.\n" \
"We need to use regular pointers because we subscribe in the constructor of the widget and unsubscribe in the destructor. In constructor smart pointers are not available. We also don't allow copy and move of the widget.\n"
#define OMNIUI_PYBIND_DOC_AbstractManipulatorModel_unsubscribe \
"Unsubscribe the ItemModelHelper widget from the changes of the model.\n"
#define OMNIUI_PYBIND_DOC_AbstractManipulatorModel_addItemChangedFn \
"Adds the function that will be called every time the value changes.\n" \
"The id of the callback that is used to remove the callback.\n"
#define OMNIUI_PYBIND_DOC_AbstractManipulatorModel_removeItemChangedFn \
"Remove the callback by its id.\n" \
"\n" \
"\n" \
"### Arguments:\n" \
"\n" \
" `id :`\n" \
" The id that addValueChangedFn returns.\n"
| 3,651 | C | 63.070174 | 226 | 0.455218 |
omniverse-code/kit/include/omni/ui/scene/bind/BindCameraModel.h | // Copyright (c) 2020-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "DocCameraModel.h"
// clang-format off
#define OMNIUI_PYBIND_INIT_CameraModel
#define OMNIUI_PYBIND_KWARGS_DOC_CameraModel \
"\n `projection : `\n " \
OMNIUI_PYBIND_DOC_CameraModel_getProjection \
"\n `view : `\n " \
OMNIUI_PYBIND_DOC_CameraModel_getView
// clang-format on
| 1,088 | C | 46.347824 | 120 | 0.523897 |
omniverse-code/kit/include/omni/ui/scene/bind/DocWidget.h | // Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_Widget \
"The shape that contains the omni.ui widgets. It automatically creates IAppWindow and transfers its content to the texture of the rectangle. It interacts with the mouse and sends the mouse events to the underlying window, so interacting with the UI on this rectangle is smooth for the user.\n" \
"\n"
#define OMNIUI_PYBIND_DOC_Widget_getFrame "Return the main frame of the widget.\n"
#define OMNIUI_PYBIND_DOC_Widget_invalidate \
"Rebuild and recapture the widgets at the next frame. If\n" \
"frame\n" \
"build_fn\n"
#define OMNIUI_PYBIND_DOC_Widget_fillPolicy \
"Define what happens when the source image has a different size than the item.\n"
#define OMNIUI_PYBIND_DOC_Widget_updatePolicy "Define when to redraw the widget.\n"
#define OMNIUI_PYBIND_DOC_Widget_resolutionScale "The resolution scale of the widget.\n"
#define OMNIUI_PYBIND_DOC_Widget_resolutionWidth "The resolution of the widget framebuffer.\n"
#define OMNIUI_PYBIND_DOC_Widget_resolutionHeight "The resolution of the widget framebuffer.\n"
#define OMNIUI_PYBIND_DOC_Widget_Widget "Created an empty image.\n"
| 2,182 | C | 50.976189 | 299 | 0.567369 |
omniverse-code/kit/include/omni/ui/scene/bind/DocLine.h | // Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_Line \
"\n" \
"\n"
#define OMNIUI_PYBIND_DOC_Line_getGesturePayload "Contains all the information about the intersection.\n"
#define OMNIUI_PYBIND_DOC_Line_getGesturePayload01 \
"Contains all the information about the intersection at the specific state.\n"
#define OMNIUI_PYBIND_DOC_Line_getIntersectionDistance \
"The distance in pixels from mouse pointer to the shape for the intersection.\n"
#define OMNIUI_PYBIND_DOC_Line_start "The start point of the line.\n"
#define OMNIUI_PYBIND_DOC_Line_end "The end point of the line.\n"
#define OMNIUI_PYBIND_DOC_Line_color "The line color.\n"
#define OMNIUI_PYBIND_DOC_Line_thickness "The line thickness.\n"
#define OMNIUI_PYBIND_DOC_Line_intersectionThickness "The thickness of the line for the intersection.\n"
#define OMNIUI_PYBIND_DOC_Line_Line \
"A simple line.\n" \
"\n" \
"\n" \
"### Arguments:\n" \
"\n" \
" `start :`\n" \
" The start point of the line\n" \
"\n" \
" `end :`\n" \
" The end point of the line\n"
| 2,855 | C | 52.886791 | 120 | 0.380385 |
omniverse-code/kit/include/omni/ui/scene/bind/DocAbstractGesture.h | // Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_AbstractGesture \
"The base class for the gestures to provides a way to capture mouse events in 3d scene.\n" \
"\n"
#define OMNIUI_PYBIND_DOC_AbstractGesture_setManager "Set the Manager that controld this gesture.\n"
#define OMNIUI_PYBIND_DOC_AbstractGesture_getManager "The Manager that controld this gesture.\n"
#define OMNIUI_PYBIND_DOC_AbstractGesture_dispatchInput \
"Called by scene to process the mouse inputs and do intersections with shapes. It can be an entry point to simulate the mouse input.\n" \
"Todo\n" \
"We probably don't need projection-view here. We can get it from manager.\n"
#define OMNIUI_PYBIND_DOC_AbstractGesture_preProcess \
"Called before the processing to determine the state of the gesture.\n"
#define OMNIUI_PYBIND_DOC_AbstractGesture_process "Process the gesture and call callbacks if necessary.\n"
#define OMNIUI_PYBIND_DOC_AbstractGesture_postProcess "Gestures are finished. Clean-up.\n"
#define OMNIUI_PYBIND_DOC_AbstractGesture_getState "Get the internal state of the gesture.\n"
#define OMNIUI_PYBIND_DOC_AbstractGesture_setState \
"Set the internal state of the gesture. It's the way to cancel, prevent, or restore the gesture.\n"
#define OMNIUI_PYBIND_DOC_AbstractGesture_isStateChanged \
"Returns true if the gesture is just changed at the current frame. If the state is not changed,\n" \
"process()\n"
#define OMNIUI_PYBIND_DOC_AbstractGesture_getSender "Returns the relevant shape driving the gesture.\n"
#define OMNIUI_PYBIND_DOC_AbstractGesture_getGesturePayload \
"Shortcut for sender.get_gesturePayload.\n" \
"OMNIUI_SCENE_API const*\n"
#define OMNIUI_PYBIND_DOC_AbstractGesture_getGesturePayload01 \
"Shortcut for sender.get_gesturePayload.\n" \
"OMNIUI_SCENE_API const*\n"
#define OMNIUI_PYBIND_DOC_AbstractGesture_name "The name of the object. It's used for debugging.\n"
| 3,156 | C | 48.328124 | 141 | 0.576996 |
omniverse-code/kit/include/omni/ui/scene/bind/BindLine.h | // Copyright (c) 2020-2022, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "BindAbstractShape.h"
#include "DocLine.h"
// clang-format off
#define OMNIUI_PYBIND_INIT_Line \
OMNIUI_PYBIND_INIT_AbstractShape \
OMNIUI_PYBIND_INIT_CALL(start, setStart, pythonToVector3) \
OMNIUI_PYBIND_INIT_CALL(end, setEnd, pythonToVector3) \
OMNIUI_PYBIND_INIT_CALL(color, setColor, pythonToColor4) \
OMNIUI_PYBIND_INIT_CAST(thickness, setThickness, float) \
OMNIUI_PYBIND_INIT_CAST(intersection_thickness, setIntersectionThickness, float)
#define OMNIUI_PYBIND_KWARGS_DOC_Line \
"\n `start : `\n " \
OMNIUI_PYBIND_DOC_Line_start \
"\n `end : `\n " \
OMNIUI_PYBIND_DOC_Line_end \
"\n `color : `\n " \
OMNIUI_PYBIND_DOC_Line_color \
"\n `thickness : `\n " \
OMNIUI_PYBIND_DOC_Line_thickness \
"\n `intersection_thickness : `\n " \
OMNIUI_PYBIND_DOC_Line_intersectionThickness \
OMNIUI_PYBIND_KWARGS_DOC_AbstractShape
// clang-format on
| 2,733 | C | 70.947367 | 120 | 0.363337 |
omniverse-code/kit/include/omni/ui/scene/bind/BindScrollGesture.h | // Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "BindShapeGesture.h"
#include "DocScrollGesture.h"
#include <omni/ui/scene/ScrollGesture.h>
OMNIUI_PROTECT_PYBIND11_OBJECT(OMNIUI_SCENE_NS::ScrollGesture, ScrollGesture);
// clang-format off
#define OMNIUI_PYBIND_INIT_PyScrollGesture \
OMNIUI_PYBIND_INIT_CAST(mouse_button, setMouseButton, uint32_t) \
OMNIUI_PYBIND_INIT_CAST(modifiers, setModifiers, uint32_t) \
OMNIUI_PYBIND_INIT_CALLBACK(on_ended_fn, setOnEndedFn, void(AbstractShape const*)) \
OMNIUI_PYBIND_INIT_ShapeGesture
#define OMNIUI_PYBIND_KWARGS_DOC_ScrollGesture \
"\n `mouse_button : `\n " \
OMNIUI_PYBIND_DOC_ScrollGesture_mouseButton \
"\n `modifiers : `\n " \
OMNIUI_PYBIND_DOC_ScrollGesture_modifiers \
"\n `on_ended_fn : `\n " \
OMNIUI_PYBIND_DOC_ScrollGesture_OnEnded \
OMNIUI_PYBIND_KWARGS_DOC_ShapeGesture
// clang-format on
| 2,082 | C | 56.86111 | 120 | 0.470701 |
omniverse-code/kit/include/omni/ui/scene/bind/BindRectangle.h | // Copyright (c) 2020-2022, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "BindAbstractShape.h"
#include "DocRectangle.h"
// clang-format off
#define OMNIUI_PYBIND_INIT_Rectangle \
OMNIUI_PYBIND_INIT_AbstractShape \
OMNIUI_PYBIND_INIT_CAST(width, setWidth, Float) \
OMNIUI_PYBIND_INIT_CAST(height, setHeight, Float) \
OMNIUI_PYBIND_INIT_CAST(thickness, setThickness, float) \
OMNIUI_PYBIND_INIT_CAST(intersection_thickness, setIntersectionThickness, float) \
OMNIUI_PYBIND_INIT_CALL(color, setColor, pythonToColor4) \
OMNIUI_PYBIND_INIT_CAST(axis, setAxis, uint8_t) \
OMNIUI_PYBIND_INIT_CAST(wireframe, setWireframe, bool)
#define OMNIUI_PYBIND_KWARGS_DOC_Rectangle \
"\n `width : `\n " \
OMNIUI_PYBIND_DOC_Rectangle_width \
"\n `height : `\n " \
OMNIUI_PYBIND_DOC_Rectangle_height \
"\n `thickness : `\n " \
OMNIUI_PYBIND_DOC_Rectangle_thickness \
"\n `intersection_thickness : `\n " \
OMNIUI_PYBIND_DOC_Rectangle_intersectionThickness \
"\n `color : `\n " \
OMNIUI_PYBIND_DOC_Rectangle_color \
"\n `axis : `\n " \
OMNIUI_PYBIND_DOC_Rectangle_axis \
"\n `wireframe : `\n " \
OMNIUI_PYBIND_DOC_Rectangle_wireframe \
OMNIUI_PYBIND_KWARGS_DOC_AbstractShape
// clang-format on
| 3,438 | C | 77.159089 | 120 | 0.344677 |
omniverse-code/kit/include/omni/ui/scene/bind/DocHoverGesture.h | // Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_HoverGesture \
"The gesture that provides a way to capture event when mouse enters/leaves the item.\n" \
"\n"
#define OMNIUI_PYBIND_DOC_HoverGesture_preProcess "Called before processing to determine the state of the gesture.\n"
#define OMNIUI_PYBIND_DOC_HoverGesture_process "Process the gesture and call callbacks if necessary.\n"
#define OMNIUI_PYBIND_DOC_HoverGesture_onBegan "Called if the callback is not set and the mouse enters the item.\n"
#define OMNIUI_PYBIND_DOC_HoverGesture_onChanged \
"Called if the callback is not set and the mouse is hovering the item.\n"
#define OMNIUI_PYBIND_DOC_HoverGesture_onEnded "Called if the callback is not set and the mouse leaves the item.\n"
#define OMNIUI_PYBIND_DOC_HoverGesture_mouseButton "The mouse button this gesture is watching.\n"
#define OMNIUI_PYBIND_DOC_HoverGesture_modifiers "The modifier that should be pressed to trigger this gesture.\n"
#define OMNIUI_PYBIND_DOC_HoverGesture_triggerOnViewHover "Determines whether the gesture is triggered only when the SceneView is being hovered by the mouse.\n"
#define OMNIUI_PYBIND_DOC_HoverGesture_OnBegan "Called when the mouse enters the item.\n"
#define OMNIUI_PYBIND_DOC_HoverGesture_OnChanged "Called when the mouse is hovering the item.\n"
#define OMNIUI_PYBIND_DOC_HoverGesture_OnEnded "Called when the mouse leaves the item.\n"
#define OMNIUI_PYBIND_DOC_HoverGesture_HoverGesture \
"Constructs an gesture to track when the user clicked the mouse.\n" \
"\n" \
"\n" \
"### Arguments:\n" \
"\n" \
" `onEnded :`\n" \
" Function that is called when the user clicked the mouse button.\n"
| 2,953 | C | 49.931034 | 160 | 0.549949 |
omniverse-code/kit/include/omni/ui/scene/bind/BindAbstractItem.h | // Copyright (c) 2019-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "DocAbstractItem.h"
// clang-format off
#define OMNIUI_PYBIND_INIT_AbstractItem OMNIUI_PYBIND_INIT_CAST(visible, setVisible, bool)
#define OMNIUI_PYBIND_KWARGS_DOC_AbstractItem \
"\n `visible : `\n " \
OMNIUI_PYBIND_DOC_AbstractItem_visible
// clang-format on
| 821 | C | 36.363635 | 90 | 0.690621 |
omniverse-code/kit/include/omni/ui/scene/bind/BindPolygonMesh.h | // Copyright (c) 2021-2022, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "BindAbstractShape.h"
#include "DocPolygonMesh.h"
// clang-format off
#define OMNIUI_PYBIND_INIT_PolygonMesh \
OMNIUI_PYBIND_INIT_AbstractShape \
OMNIUI_PYBIND_INIT_CALL(positions, setPositions, pythonListToVector3) \
OMNIUI_PYBIND_INIT_CALL(colors, setColors, pythonListToVector4) \
OMNIUI_PYBIND_INIT_CAST(vertex_counts, setVertexCounts, std::vector<uint32_t>) \
OMNIUI_PYBIND_INIT_CAST(vertex_indices, setVertexIndices, std::vector<uint32_t>) \
OMNIUI_PYBIND_INIT_CAST(thicknesses, setThicknesses, std::vector<float>) \
OMNIUI_PYBIND_INIT_CAST(intersection_thickness, setIntersectionThickness, float) \
OMNIUI_PYBIND_INIT_CAST(wireframe, setWireframe, bool)
#define OMNIUI_PYBIND_KWARGS_DOC_PolygonMesh \
"\n `positions : `\n " \
OMNIUI_PYBIND_DOC_PolygonMesh_positions \
"\n `colors : `\n " \
OMNIUI_PYBIND_DOC_PolygonMesh_colors \
"\n `vertex_counts : `\n " \
OMNIUI_PYBIND_DOC_PolygonMesh_vertexCounts \
"\n `vertex_indices : `\n " \
OMNIUI_PYBIND_DOC_PolygonMesh_vertexIndices \
"\n `thicknesses : `\n " \
OMNIUI_PYBIND_DOC_PolygonMesh_thicknesses \
"\n `intersection_thickness : `\n " \
OMNIUI_PYBIND_DOC_PolygonMesh_intersectionThickness \
"\n `wireframe: `\n " \
OMNIUI_PYBIND_DOC_PolygonMesh_wireframe \
OMNIUI_PYBIND_KWARGS_DOC_AbstractShape
// clang-format on
| 3,440 | C | 77.204544 | 120 | 0.390116 |
omniverse-code/kit/include/omni/ui/scene/bind/BindCurve.h | // Copyright (c) 2020-2022, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "BindAbstractShape.h"
#include "DocCurve.h"
// clang-format off
#define OMNIUI_PYBIND_INIT_Curve \
OMNIUI_PYBIND_INIT_AbstractShape \
OMNIUI_PYBIND_INIT_CALL(positions, setPositions, pythonListToVector3) \
OMNIUI_PYBIND_INIT_CALL(colors, setColors, pythonListToVector4) \
OMNIUI_PYBIND_INIT_CAST(thicknesses, setThicknesses, std::vector<float>) \
OMNIUI_PYBIND_INIT_CAST(intersection_thickness, setIntersectionThickness, float) \
OMNIUI_PYBIND_INIT_CAST(curve_type, setCurveType, Curve::CurveType) \
OMNIUI_PYBIND_INIT_CAST(tessellation, setTessellation, uint16_t)
#define OMNIUI_PYBIND_KWARGS_DOC_Curve \
"\n `positions : `\n " \
OMNIUI_PYBIND_DOC_Curve_positions \
"\n `colors : `\n " \
OMNIUI_PYBIND_DOC_Curve_colors \
"\n `thicknesses : `\n " \
OMNIUI_PYBIND_DOC_Curve_thicknesses \
"\n `intersection_thickness : `\n " \
OMNIUI_PYBIND_DOC_Curve_intersectionThickness \
"\n `curve_type : `\n " \
OMNIUI_PYBIND_DOC_Curve_curveType \
"\n `tessellation : `\n " \
OMNIUI_PYBIND_DOC_Curve_tessellation \
OMNIUI_PYBIND_KWARGS_DOC_AbstractShape
// clang-format on
| 3,081 | C | 74.17073 | 120 | 0.379747 |
omniverse-code/kit/include/omni/ui/scene/bind/DocArc.h | // Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_Arc \
"\n" \
"\n"
#define OMNIUI_PYBIND_DOC_Arc_getGesturePayload "Contains all the information about the intersection.\n"
#define OMNIUI_PYBIND_DOC_Arc_getGesturePayload01 \
"Contains all the information about the intersection at the specific state.\n"
#define OMNIUI_PYBIND_DOC_Arc_getIntersectionDistance \
"The distance in pixels from mouse pointer to the shape for the intersection.\n"
#define OMNIUI_PYBIND_DOC_Arc_radius "The radius of the circle.\n"
#define OMNIUI_PYBIND_DOC_Arc_begin \
"The start angle of the arc. " \
"Angle placement and directions are (0 to 90): Y to Z, Z to X, X to Y\n"
#define OMNIUI_PYBIND_DOC_Arc_end \
"The end angle of the arc. " \
"Angle placement and directions are (0 to 90): Y to Z, Z to X, X to Y\n"
#define OMNIUI_PYBIND_DOC_Arc_thickness "The thickness of the line.\n"
#define OMNIUI_PYBIND_DOC_Arc_intersectionThickness "The thickness of the line for the intersection.\n"
#define OMNIUI_PYBIND_DOC_Arc_color "The color of the line.\n"
#define OMNIUI_PYBIND_DOC_Arc_tesselation "Number of points on the curve.\n"
#define OMNIUI_PYBIND_DOC_Arc_wireframe "When true, it's a line. When false it's a mesh.\n"
#define OMNIUI_PYBIND_DOC_Arc_sector "Draw two radii of the circle.\n"
#define OMNIUI_PYBIND_DOC_Arc_axis "The axis the circle plane is perpendicular to.\n"
#define OMNIUI_PYBIND_DOC_Arc_culling "Draw two radii of the circle.\n"
#define OMNIUI_PYBIND_DOC_Arc_Arc "Constructs Arc.\n"
| 2,645 | C | 39.707692 | 120 | 0.553875 |
omniverse-code/kit/include/omni/ui/scene/bind/DocManipulatorModelHelper.h | // Copyright (c) 2020-2022, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_ManipulatorModelHelper \
"The ManipulatorModelHelper class provides the basic model functionality.\n"
#define OMNIUI_PYBIND_DOC_ManipulatorModelHelper_onModelUpdated \
"Called by the model when the model value is changed. The class should react to the changes.\n" \
"\n" \
"\n" \
"### Arguments:\n" \
"\n" \
" `item :`\n" \
" The item in the model that is changed. If it's NULL, the root is changed.\n"
#define OMNIUI_PYBIND_DOC_ManipulatorModelHelper_getRayFromNdc "Convert NDC 2D [-1..1] coordinates to 3D ray.\n"
#define OMNIUI_PYBIND_DOC_ManipulatorModelHelper_setModel "Set the current model.\n"
#define OMNIUI_PYBIND_DOC_ManipulatorModelHelper_getModel "Returns the current model.\n"
| 1,887 | C | 57.999998 | 120 | 0.480127 |
omniverse-code/kit/include/omni/ui/scene/bind/BindWidget.h | // Copyright (c) 2020-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "BindRectangle.h"
#include "DocWidget.h"
// clang-format off
#define OMNIUI_PYBIND_INIT_Widget \
OMNIUI_PYBIND_INIT_Rectangle \
OMNIUI_PYBIND_INIT_CAST(fill_policy, setFillPolicy, Widget::FillPolicy) \
OMNIUI_PYBIND_INIT_CAST(update_policy, setUpdatePolicy, Widget::UpdatePolicy) \
OMNIUI_PYBIND_INIT_CAST(resolution_scale, setResolutionScale, float) \
OMNIUI_PYBIND_INIT_CAST(resolution_width, setResolutionWidth, uint32_t) \
OMNIUI_PYBIND_INIT_CAST(resolution_height, setResolutionHeight, uint32_t)
#define OMNIUI_PYBIND_KWARGS_DOC_Widget \
"\n `fill_policy : `\n " \
OMNIUI_PYBIND_DOC_Widget_fillPolicy \
"\n `update_policy : `\n " \
OMNIUI_PYBIND_DOC_Widget_updatePolicy \
"\n `resolution_scale : `\n " \
OMNIUI_PYBIND_DOC_Widget_resolutionScale \
"\n `resolution_width : `\n " \
OMNIUI_PYBIND_DOC_Widget_resolutionWidth \
"\n `resolution_height : `\n " \
OMNIUI_PYBIND_DOC_Widget_resolutionHeight \
OMNIUI_PYBIND_KWARGS_DOC_Rectangle
// clang-format on
| 2,720 | C | 70.605261 | 120 | 0.402941 |
omniverse-code/kit/include/omni/ui/scene/bind/BindHoverGesture.h | // Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "BindShapeGesture.h"
#include "DocHoverGesture.h"
#include <omni/ui/scene/HoverGesture.h>
OMNIUI_PROTECT_PYBIND11_OBJECT(OMNIUI_SCENE_NS::HoverGesture, HoverGesture);
// clang-format off
#define OMNIUI_PYBIND_INIT_PyHoverGesture \
OMNIUI_PYBIND_INIT_CAST(mouse_button, setMouseButton, uint32_t) \
OMNIUI_PYBIND_INIT_CAST(modifiers, setModifiers, uint32_t) \
OMNIUI_PYBIND_INIT_CAST(trigger_on_view_hover, setTriggerOnViewHover, bool) \
OMNIUI_PYBIND_INIT_CALLBACK(on_began_fn, setOnBeganFn, void(AbstractShape const*)) \
OMNIUI_PYBIND_INIT_CALLBACK(on_changed_fn, setOnChangedFn, void(AbstractShape const*)) \
OMNIUI_PYBIND_INIT_CALLBACK(on_ended_fn, setOnEndedFn, void(AbstractShape const*)) \
OMNIUI_PYBIND_INIT_ShapeGesture
#define OMNIUI_PYBIND_KWARGS_DOC_HoverGesture \
"\n `mouse_button : `\n " \
OMNIUI_PYBIND_DOC_HoverGesture_mouseButton \
"\n `modifiers : `\n " \
OMNIUI_PYBIND_DOC_HoverGesture_modifiers \
"\n `trigger_on_view_hover : `\n " \
OMNIUI_PYBIND_DOC_HoverGesture_triggerOnViewHover \
"\n `on_began_fn : `\n " \
OMNIUI_PYBIND_DOC_HoverGesture_onBegan \
"\n `on_changed_fn : `\n " \
OMNIUI_PYBIND_DOC_HoverGesture_onChanged \
"\n `on_ended_fn : `\n " \
OMNIUI_PYBIND_DOC_HoverGesture_onEnded \
OMNIUI_PYBIND_KWARGS_DOC_ShapeGesture
// clang-format on
| 3,167 | C | 69.399998 | 120 | 0.420272 |
omniverse-code/kit/include/omni/ui/scene/bind/DocScene.h | // Copyright (c) 2019-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_Scene "Top level module string\n" \
"Represents the root of the scene and holds the shapes, gestures and managers.\n" \
"\n"
#define OMNIUI_PYBIND_DOC_Scene_Scene "Constructor"
#define OMNIUI_PYBIND_DOC_Scene_getDrawListBufferCount "Return the number of buffers used. Using for unit testing."
| 874 | C | 47.611108 | 120 | 0.696796 |
omniverse-code/kit/include/omni/ui/scene/bind/DocAbstractShape.h | // Copyright (c) 2019-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_AbstractShape \
"Base class for all the items that can be drawn and intersected with mouse pointer.\n" \
"\n"
#define OMNIUI_PYBIND_DOC_AbstractShape_getGestures "All the gestures assigned to this shape.\n"
#define OMNIUI_PYBIND_DOC_AbstractShape_setGestures "Replace the gestures of the shape.\n"
#define OMNIUI_PYBIND_DOC_AbstractShape_addGesture "Add a single gesture to the shape.\n"
#define OMNIUI_PYBIND_DOC_AbstractShape_getGesturePayload "Contains all the information about the intersection.\n"
#define OMNIUI_PYBIND_DOC_AbstractShape_getGesturePayload01 \
"Contains all the information about the intersection at the specific state.\n"
| 1,311 | C | 42.733332 | 120 | 0.688024 |
omniverse-code/kit/include/omni/ui/scene/bind/BindTexturedMesh.h | // Copyright (c) 2021-2022, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "BindPolygonMesh.h"
#include "DocTexturedMesh.h"
#include "DocImageHelper.h"
// clang-format off
#define OMNIUI_PYBIND_INIT_TexturedMesh \
OMNIUI_PYBIND_INIT_PolygonMesh \
OMNIUI_PYBIND_INIT_CALL(uvs, setUvs, pythonListToVector2) \
OMNIUI_PYBIND_INIT_CAST(source_url, setSourceUrl, std::string) \
OMNIUI_PYBIND_INIT_CAST(image_provider, setImageProvider, std::shared_ptr<ImageProvider>) \
OMNIUI_PYBIND_INIT_CAST(image_width, setImageWidth, uint32_t) \
OMNIUI_PYBIND_INIT_CAST(image_height, setImageHeight, uint32_t)
#define OMNIUI_PYBIND_KWARGS_DOC_TexturedMesh \
"\n `uvs : `\n " \
OMNIUI_PYBIND_DOC_TexturedMesh_uvs \
"\n `source_url : `\n " \
OMNIUI_PYBIND_DOC_TexturedMesh_sourceUrl \
"\n `image_provider : `\n " \
OMNIUI_PYBIND_DOC_TexturedMesh_imageProvider \
"\n `image_width : `\n " \
OMNIUI_PYBIND_DOC_ImageHelper_imageWidth \
"\n `image_height : `\n " \
OMNIUI_PYBIND_DOC_ImageHelper_imageHeight \
OMNIUI_PYBIND_KWARGS_DOC_PolygonMesh
// clang-format on
| 2,742 | C | 69.333332 | 120 | 0.399708 |
omniverse-code/kit/include/omni/ui/scene/bind/BindArc.h | // Copyright (c) 2020-2022, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "BindAbstractShape.h"
#include "DocArc.h"
// clang-format off
#define OMNIUI_PYBIND_INIT_Arc \
OMNIUI_PYBIND_INIT_AbstractShape \
OMNIUI_PYBIND_INIT_CAST(begin, setBegin, Float) \
OMNIUI_PYBIND_INIT_CAST(end, setEnd, Float) \
OMNIUI_PYBIND_INIT_CAST(thickness, setThickness, float) \
OMNIUI_PYBIND_INIT_CAST(intersection_thickness, setIntersectionThickness, float) \
OMNIUI_PYBIND_INIT_CALL(color, setColor, pythonToColor4) \
OMNIUI_PYBIND_INIT_CAST(tesselation, setTesselation, uint16_t) \
OMNIUI_PYBIND_INIT_CAST(axis, setAxis, uint8_t) \
OMNIUI_PYBIND_INIT_CAST(sector, setSector, bool) \
OMNIUI_PYBIND_INIT_CAST(culling, setCulling, Culling) \
OMNIUI_PYBIND_INIT_CAST(wireframe, setWireframe, bool)
#define OMNIUI_PYBIND_KWARGS_DOC_Arc \
"\n `begin : `\n " \
OMNIUI_PYBIND_DOC_Arc_begin \
"\n `end : `\n " \
OMNIUI_PYBIND_DOC_Arc_end \
"\n `thickness : `\n " \
OMNIUI_PYBIND_DOC_Arc_thickness \
"\n `intersection_thickness : `\n " \
OMNIUI_PYBIND_DOC_Arc_intersectionThickness \
"\n `color : `\n " \
OMNIUI_PYBIND_DOC_Arc_color \
"\n `tesselation : `\n " \
OMNIUI_PYBIND_DOC_Arc_tesselation \
"\n `axis : `\n " \
OMNIUI_PYBIND_DOC_Arc_axis \
"\n `sector : `\n " \
OMNIUI_PYBIND_DOC_Arc_sector \
"\n `culling : `\n " \
OMNIUI_PYBIND_DOC_Arc_culling \
"\n `wireframe : `\n " \
OMNIUI_PYBIND_DOC_Arc_wireframe \
OMNIUI_PYBIND_KWARGS_DOC_AbstractShape
// clang-format on
| 4,521 | C | 84.320753 | 120 | 0.299934 |
omniverse-code/kit/include/omni/ui/scene/bind/DocGestureManager.h | // Copyright (c) 2021-2022, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_GestureManager \
"The object that controls batch processing and preventing of gestures. Typically each scene has a default manager and if the user wants to have own prevention logic, he can reimplement it.\n" \
"\n"
#define OMNIUI_PYBIND_DOC_GestureManager_GestureManager "Constructor.\n"
#define OMNIUI_PYBIND_DOC_GestureManager_setView \
"Set the camera.\n" \
"Todo\n" \
"resolution\n"
#define OMNIUI_PYBIND_DOC_GestureManager_preProcess "Process mouse inputs and do all the intersections.\n"
#define OMNIUI_PYBIND_DOC_GestureManager_prevent "Process all the prevention logic and reduce the number of gestures.\n"
#define OMNIUI_PYBIND_DOC_GestureManager_process "Process the gestures.\n"
#define OMNIUI_PYBIND_DOC_GestureManager_postProcess "Clean-up caches, save states.\n"
#define OMNIUI_PYBIND_DOC_GestureManager_canBePrevented \
"Called per gesture. Determines if the gesture can be prevented.\n"
#define OMNIUI_PYBIND_DOC_GestureManager_shouldPrevent \
"Called per gesture. Determines if the gesture should be prevented with another gesture. Useful to resolve intersections.\n"
#define OMNIUI_PYBIND_DOC_GestureManager_amendInput \
"Called once a frame. Should be overriden to inject own input to the gestures.\n"
| 2,371 | C | 49.468084 | 197 | 0.574019 |
omniverse-code/kit/include/omni/ui/scene/bind/DocPolygonMesh.h | // Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_PolygonMesh \
"Encodes a mesh.\n" \
"\n"
#define OMNIUI_PYBIND_DOC_PolygonMesh_getGesturePayload "Contains all the information about the intersection.\n"
#define OMNIUI_PYBIND_DOC_PolygonMesh_getGesturePayload01 \
"Contains all the information about the intersection at the specific state.\n"
#define OMNIUI_PYBIND_DOC_PolygonMesh_getIntersectionDistance \
"The distance in pixels from mouse pointer to the shape for the intersection.\n"
#define OMNIUI_PYBIND_DOC_PolygonMesh_positions "The primary geometry attribute, describes points in local space.\n"
#define OMNIUI_PYBIND_DOC_PolygonMesh_colors "Describes colors per vertex.\n"
#define OMNIUI_PYBIND_DOC_PolygonMesh_vertexCounts \
"Provides the number of vertices in each face of the mesh, which is also the number of consecutive indices in vertex_indices that define the face. The length of this attribute is the number of faces in the mesh.\n"
#define OMNIUI_PYBIND_DOC_PolygonMesh_vertexIndices \
"Flat list of the index (into the points attribute) of each vertex of each face in the mesh.\n"
#define OMNIUI_PYBIND_DOC_PolygonMesh_thicknesses "When wireframe is true, it defines the thicknesses of lines.\n"
#define OMNIUI_PYBIND_DOC_PolygonMesh_intersectionThickness "The thickness of the line for the intersection.\n"
#define OMNIUI_PYBIND_DOC_PolygonMesh_wireframe "When true, the mesh is drawn as lines.\n"
#define OMNIUI_PYBIND_DOC_PolygonMesh_PolygonMesh \
"Construct a mesh with predefined properties.\n" \
"\n" \
"\n" \
"### Arguments:\n" \
"\n" \
" `positions :`\n" \
" Describes points in local space.\n" \
"\n" \
" `colors :`\n" \
" Describes colors per vertex.\n" \
"\n" \
" `vertexCounts :`\n" \
" The number of vertices in each face.\n" \
"\n" \
" `vertexIndices :`\n" \
" The list of the index of each vertex of each face in the mesh.\n"
| 4,340 | C | 63.791044 | 218 | 0.404608 |
omniverse-code/kit/include/omni/ui/scene/bind/DocRectangle.h | // Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_Rectangle \
"\n" \
"\n"
#define OMNIUI_PYBIND_DOC_Rectangle_getGesturePayload "Contains all the information about the intersection.\n"
#define OMNIUI_PYBIND_DOC_Rectangle_getGesturePayload01 \
"Contains all the information about the intersection at the specific state.\n"
#define OMNIUI_PYBIND_DOC_Rectangle_getIntersectionDistance \
"The distance in pixels from mouse pointer to the shape for the intersection.\n"
#define OMNIUI_PYBIND_DOC_Rectangle_width "The size of the rectangle.\n"
#define OMNIUI_PYBIND_DOC_Rectangle_height "The size of the rectangle.\n"
#define OMNIUI_PYBIND_DOC_Rectangle_thickness "The thickness of the line.\n"
#define OMNIUI_PYBIND_DOC_Rectangle_intersectionThickness "The thickness of the line for the intersection.\n"
#define OMNIUI_PYBIND_DOC_Rectangle_color "The color of the line.\n"
#define OMNIUI_PYBIND_DOC_Rectangle_wireframe "When true, it's a line. When false it's a mesh.\n"
#define OMNIUI_PYBIND_DOC_Rectangle_axis "The axis the rectangle is perpendicular to.\n"
#define OMNIUI_PYBIND_DOC_Rectangle_Rectangle \
"Construct a rectangle with predefined size.\n" \
"\n" \
"\n" \
"### Arguments:\n" \
"\n" \
" `width :`\n" \
" The size of the rectangle\n" \
"\n" \
" `height :`\n" \
" The size of the rectangle\n"
| 3,091 | C | 51.406779 | 120 | 0.429311 |
omniverse-code/kit/include/omni/ui/scene/bind/BindClickGesture.h | // Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "BindShapeGesture.h"
#include "DocClickGesture.h"
#include <omni/ui/scene/ClickGesture.h>
OMNIUI_PROTECT_PYBIND11_OBJECT(OMNIUI_SCENE_NS::ClickGesture, ClickGesture);
// clang-format off
#define OMNIUI_PYBIND_INIT_PyClickGesture \
OMNIUI_PYBIND_INIT_CAST(mouse_button, setMouseButton, uint32_t) \
OMNIUI_PYBIND_INIT_CAST(modifiers, setModifiers, uint32_t) \
OMNIUI_PYBIND_INIT_CALLBACK(on_ended_fn, setOnEndedFn, void(AbstractShape const*)) \
OMNIUI_PYBIND_INIT_ShapeGesture
#define OMNIUI_PYBIND_KWARGS_DOC_ClickGesture \
"\n `mouse_button : `\n " \
OMNIUI_PYBIND_DOC_ClickGesture_mouseButton \
"\n `modifiers : `\n " \
OMNIUI_PYBIND_DOC_ClickGesture_modifiers \
"\n `on_ended_fn : `\n " \
OMNIUI_PYBIND_DOC_ClickGesture_OnEnded \
OMNIUI_PYBIND_KWARGS_DOC_ShapeGesture
// clang-format on
| 2,078 | C | 56.749998 | 120 | 0.467276 |
omniverse-code/kit/include/omni/ui/scene/bind/BindMath.h | // Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "DocMatrix44.h"
#include <omni/ui/scene/Math.h>
#include <omni/ui/bind/Pybind.h>
OMNIUI_SCENE_NAMESPACE_OPEN_SCOPE
pybind11::object matrix4ToPython(const Matrix44& matrix);
Matrix44 pythonToMatrix4(const pybind11::handle& obj);
pybind11::object vector2ToPython(const Vector2& vec);
Vector2 pythonToVector2(const pybind11::handle& obj);
pybind11::object vector3ToPython(const Vector3& vec);
Vector3 pythonToVector3(const pybind11::handle& obj);
pybind11::object vector4ToPython(const Vector4& vec);
Vector4 pythonToVector4(const pybind11::handle& obj);
Color4 pythonToColor4(const pybind11::handle& obj);
std::vector<Vector4> pythonListToVector4(const pybind11::handle& obj);
std::vector<Vector3> pythonListToVector3(const pybind11::handle& obj);
std::vector<Vector2> pythonListToVector2(const pybind11::handle& obj);
pybind11::object vector4ToPythonList(const std::vector<Vector4>& vec);
pybind11::object vector3ToPythonList(const std::vector<Vector3>& vec);
pybind11::object vector2ToPythonList(const std::vector<Vector2>& vec);
OMNIUI_SCENE_NAMESPACE_CLOSE_SCOPE
| 1,527 | C | 41.444443 | 77 | 0.800262 |
omniverse-code/kit/include/omni/ui/scene/bind/BindSceneView.h | // Copyright (c) 2019-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "DocManipulatorModelHelper.h"
#include "DocSceneView.h"
#include <omni/ui/bind/BindWidget.h>
// clang-format off
#define OMNIUI_PYBIND_INIT_SceneView \
OMNIUI_PYBIND_INIT_CAST(aspect_ratio_policy, setAspectRatioPolicy, SceneView::AspectRatioPolicy) \
OMNIUI_PYBIND_INIT_CAST(screen_aspect_ratio, setScreenAspectRatio, float) \
OMNIUI_PYBIND_INIT_CAST(child_windows_input, setChildWindowsInput, bool) \
OMNIUI_PYBIND_INIT_CAST(scene, setScene, std::shared_ptr<Scene>) \
OMNIUI_PYBIND_INIT_CAST(model, setModel, std::shared_ptr<AbstractManipulatorModel>) \
OMNIUI_PYBIND_INIT_Widget
#define OMNIUI_PYBIND_KWARGS_DOC_SceneView \
"\n `aspect_ratio_policy : `\n " \
OMNIUI_PYBIND_DOC_SceneView_aspectRatioPolicy \
"\n `model : `\n " \
OMNIUI_PYBIND_DOC_SceneView_getView \
"\n `screen_aspect_ratio : `\n " \
OMNIUI_PYBIND_DOC_SceneView_screenAspectRatio \
"\n `child_windows_input : `\n " \
OMNIUI_PYBIND_DOC_SceneView_childWindowsInput \
OMNIUI_PYBIND_KWARGS_DOC_Widget
// clang-format on
| 2,478 | C | 67.861109 | 120 | 0.454802 |
omniverse-code/kit/include/omni/ui/scene/bind/DocCurve.h | // Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_Curve \
"Represents the curve.\n" \
"\n"
#define OMNIUI_PYBIND_DOC_Curve_getGesturePayload "Contains all the information about the intersection.\n"
#define OMNIUI_PYBIND_DOC_Curve_getGesturePayload01 \
"Contains all the information about the intersection at the specific state.\n"
#define OMNIUI_PYBIND_DOC_Curve_getIntersectionDistance \
"The distance in pixels from mouse pointer to the shape for the intersection.\n"
#define OMNIUI_PYBIND_DOC_Curve_positions \
"The list of positions which defines the curve. It has at least two positions. The curve has len(positions)-1\n"
#define OMNIUI_PYBIND_DOC_Curve_colors \
"The list of colors which defines color per vertex. It has the same length as positions.\n"
#define OMNIUI_PYBIND_DOC_Curve_thicknesses \
"The list of thicknesses which defines thickness per vertex. It has the same length as positions.\n"
#define OMNIUI_PYBIND_DOC_Curve_intersectionThickness "The thickness of the line for the intersection.\n"
#define OMNIUI_PYBIND_DOC_Curve_curveType "The curve interpolation type.\n"
#define OMNIUI_PYBIND_DOC_Curve_tessellation "The number of points per curve segment. It can't be less than 2.\n"
#define OMNIUI_PYBIND_DOC_Curve_Curve \
"Constructs Curve.\n" \
"\n" \
"\n" \
"### Arguments:\n" \
"\n" \
" `positions :`\n" \
" List of positions\n"
| 3,101 | C | 54.392856 | 120 | 0.44534 |
omniverse-code/kit/include/omni/experimental/job/IJob.gen.h | // Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
// --------- Warning: This is a build system generated file. ----------
//
//! @file
//!
//! @brief This file was generated by <i>omni.bind</i>.
#include <omni/core/OmniAttr.h>
#include <omni/core/Interface.h>
#include <omni/core/ResultError.h>
#include <functional>
#include <utility>
#include <type_traits>
#ifndef OMNI_BIND_INCLUDE_INTERFACE_IMPL
/**
* Interface for providing a CPU affinity mask to the plugin. Instances of this interface can be thought of as an array
* of \c MaskType values, which allows for setting affinities on machines with more than 64 processors. Each affinity
* mask this object contains is a bitmask that represents the associated CPUs.
*
* On Linux, this object is treated as one large bitset analogous to cpu_set_t. So \c get_affinity_mask(0) represents
* CPUs 0-63, \c get_affinity_mask(1) represents CPUs 64-127, etc.
*
* On Windows, each affinity mask in this object applies to its own Processor Group, so \c get_affinity_mask(0) is for
* Processor Group 0, \c get_affinity_mask(1) for Processor Group 1, etc.
*/
template <>
class omni::core::Generated<omni::experimental::job::IAffinityMask_abi> : public omni::experimental::job::IAffinityMask_abi
{
public:
OMNI_PLUGIN_INTERFACE("omni::experimental::job::IAffinityMask")
/**
* Gets the affinity mask at \c index.
*
* @note \c index must be less than \ref get_mask_count_abi()
*
* @param index Index to get affinity mask for.
*
* @return The affinity mask at the provided index.
*/
omni::experimental::job::MaskType get_affinity_mask(size_t index) noexcept;
/**
* Gets the affinity \c mask at \c index.
*
* @note \c index must be less than \ref get_mask_count_abi()
*
* @param index Index to set affinity mask for.
* @param mask Mask to set.
*/
void set_affinity_mask(size_t index, omni::experimental::job::MaskType mask) noexcept;
/**
* Gets the current number of affinity masks stored by this object.
*
* @return The current number of affinity masks stored by this object.
*/
size_t get_mask_count() noexcept;
/**
* Gets the default number of affinity masks stored by this object.
*
* @return The default number of affinity masks stored by this object.
*/
size_t get_default_mask_count() noexcept;
/**
* Sets the number of affinity masks stored by this object to \c count.
*
* If \c count is greater than the current size, the appended affinity masks will bet set to \c 0. If \c count
* is less than the current size, then this object will only contain the first \c count elements after this call.
*
* @param count Number of affinity masks to set the size to.
*/
void set_mask_count(size_t count) noexcept;
};
/**
* Basic interface for launching jobs on a foreign job system.
*/
template <>
class omni::core::Generated<omni::experimental::job::IJob_abi> : public omni::experimental::job::IJob_abi
{
public:
OMNI_PLUGIN_INTERFACE("omni::experimental::job::IJob")
/**
* Adds a new job to be executed.
*
* @param job_fn User provided function to be executed by a worker.
* @param job_data User provided data for the job, the memory must not be released until it no longer needed by the
* task.
*/
void enqueue_job(omni::experimental::job::JobFunction job_fn, void* job_data) noexcept;
};
/**
* Interface for managing the number of workers in the job system.
*/
template <>
class omni::core::Generated<omni::experimental::job::IJobWorker_abi> : public omni::experimental::job::IJobWorker_abi
{
public:
OMNI_PLUGIN_INTERFACE("omni::experimental::job::IJobWorker")
/**
* Returns default number of workers used for creation of a new Job system.
*
* @return The default number of workers.
*/
size_t get_default_worker_count() noexcept;
/**
* Returns the number of worker threads in the job system.
*
* @returns The number of worker threads.
*/
size_t get_worker_count() noexcept;
/**
* Sets the number of workers in the job system.
*
* This function may stop all current threads and reset any previously set thread affinity.
*
* @param count The new number of workers to set in the system. A value of 0 means to use the default value returned
* by getDefaultWorkerCount()
*/
void set_worker_count(size_t count) noexcept;
};
/**
* Interface for setting CPU affinity for the job system.
*/
template <>
class omni::core::Generated<omni::experimental::job::IJobAffinity_abi> : public omni::experimental::job::IJobAffinity_abi
{
public:
OMNI_PLUGIN_INTERFACE("omni::experimental::job::IJobAffinity")
/**
* Gets the current affinity of a worker.
*
* @param worker_id The worker to set the affinity of. If this id is larger than the current number of workers,
* a \c nullptr will be returned.
*
* @return The current affinity being used by the worker. The returned value may be \c nullptr if the worker's
* affinity could not be determined.
*/
omni::core::ObjectPtr<omni::experimental::job::IAffinityMask> get_affinity(size_t worker_id) noexcept;
/**
* Attempts to set the affinity for the specified worker.
*
* @note On Windows each thread can only belong to a single Processor Group, so the CPU Affinity will only be set
* to the first non-zero entry. That is to say, if both \c mask->get_affinity_mask(0) and
* \c mask->get_affinity_mask(1) both have bits sets, only the CPUs in \c mask->get_affinity_mask(0) will be set for
* the affinity.
*
* @param worker_id The worker to set the affinity of. If this id is larger than the current number of workers,
* false will be returned.
* @param mask The affinity values to set.
*
* @return true if the affinity was successfully set, false otherwise.
*/
bool set_affinity(size_t worker_id, omni::core::ObjectParam<omni::experimental::job::IAffinityMask> mask) noexcept;
};
#endif
#ifndef OMNI_BIND_INCLUDE_INTERFACE_DECL
inline omni::experimental::job::MaskType omni::core::Generated<omni::experimental::job::IAffinityMask_abi>::get_affinity_mask(
size_t index) noexcept
{
return get_affinity_mask_abi(index);
}
inline void omni::core::Generated<omni::experimental::job::IAffinityMask_abi>::set_affinity_mask(
size_t index, omni::experimental::job::MaskType mask) noexcept
{
set_affinity_mask_abi(index, mask);
}
inline size_t omni::core::Generated<omni::experimental::job::IAffinityMask_abi>::get_mask_count() noexcept
{
return get_mask_count_abi();
}
inline size_t omni::core::Generated<omni::experimental::job::IAffinityMask_abi>::get_default_mask_count() noexcept
{
return get_default_mask_count_abi();
}
inline void omni::core::Generated<omni::experimental::job::IAffinityMask_abi>::set_mask_count(size_t count) noexcept
{
set_mask_count_abi(count);
}
inline void omni::core::Generated<omni::experimental::job::IJob_abi>::enqueue_job(
omni::experimental::job::JobFunction job_fn, void* job_data) noexcept
{
enqueue_job_abi(job_fn, job_data);
}
inline size_t omni::core::Generated<omni::experimental::job::IJobWorker_abi>::get_default_worker_count() noexcept
{
return get_default_worker_count_abi();
}
inline size_t omni::core::Generated<omni::experimental::job::IJobWorker_abi>::get_worker_count() noexcept
{
return get_worker_count_abi();
}
inline void omni::core::Generated<omni::experimental::job::IJobWorker_abi>::set_worker_count(size_t count) noexcept
{
set_worker_count_abi(count);
}
inline omni::core::ObjectPtr<omni::experimental::job::IAffinityMask> omni::core::Generated<
omni::experimental::job::IJobAffinity_abi>::get_affinity(size_t worker_id) noexcept
{
return omni::core::steal(get_affinity_abi(worker_id));
}
inline bool omni::core::Generated<omni::experimental::job::IJobAffinity_abi>::set_affinity(
size_t worker_id, omni::core::ObjectParam<omni::experimental::job::IAffinityMask> mask) noexcept
{
return set_affinity_abi(worker_id, mask.get());
}
#endif
#undef OMNI_BIND_INCLUDE_INTERFACE_DECL
#undef OMNI_BIND_INCLUDE_INTERFACE_IMPL
| 8,693 | C | 34.056451 | 126 | 0.695962 |
omniverse-code/kit/include/omni/experimental/job/IJob.h | // Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
//! @file
//!
//! @brief IJob definition file.
#pragma once
#include "../../../carb/Interface.h"
#include "../../core/IObject.h"
#include "../../../carb/IObject.h"
namespace omni
{
/** Namespace for experimental Interfaces and functionality. */
namespace experimental
{
namespace job
{
/**
* Defines the function for performing a user-provided job.
*
* @param job_data User provided data for the job, the memory must not be released until it no longer needed by the
* task.
*/
using JobFunction = void (*)(void* job_data);
/** Forward declaration of the IAffinityMask interface. */
OMNI_DECLARE_INTERFACE(IAffinityMask);
/**
* Alias for an affinity mask.
*/
using MaskType = uint64_t;
/**
* Interface for providing a CPU affinity mask to the plugin. Instances of this interface can be thought of as an array
* of \c MaskType values, which allows for setting affinities on machines with more than 64 processors. Each affinity
* mask this object contains is a bitmask that represents the associated CPUs.
*
* On Linux, this object is treated as one large bitset analogous to cpu_set_t. So \c get_affinity_mask(0) represents
* CPUs 0-63, \c get_affinity_mask(1) represents CPUs 64-127, etc.
*
* On Windows, each affinity mask in this object applies to its own Processor Group, so \c get_affinity_mask(0) is for
* Processor Group 0, \c get_affinity_mask(1) for Processor Group 1, etc.
*/
class IAffinityMask_abi
: public omni::core::Inherits<omni::core::IObject, OMNI_TYPE_ID("omni.experimental.job.IAffinityMask")>
{
protected:
/**
* Gets the affinity mask at \c index.
*
* @note \c index must be less than \ref get_mask_count_abi()
*
* @param index Index to get affinity mask for.
*
* @return The affinity mask at the provided index.
*/
virtual MaskType get_affinity_mask_abi(size_t index) noexcept = 0;
/**
* Gets the affinity \c mask at \c index.
*
* @note \c index must be less than \ref get_mask_count_abi()
*
* @param index Index to set affinity mask for.
* @param mask Mask to set.
*/
virtual void set_affinity_mask_abi(size_t index, MaskType mask) noexcept = 0;
/**
* Gets the current number of affinity masks stored by this object.
*
* @return The current number of affinity masks stored by this object.
*/
virtual size_t get_mask_count_abi() noexcept = 0;
/**
* Gets the default number of affinity masks stored by this object.
*
* @return The default number of affinity masks stored by this object.
*/
virtual size_t get_default_mask_count_abi() noexcept = 0;
/**
* Sets the number of affinity masks stored by this object to \c count.
*
* If \c count is greater than the current size, the appended affinity masks will bet set to \c 0. If \c count
* is less than the current size, then this object will only contain the first \c count elements after this call.
*
* @param count Number of affinity masks to set the size to.
*/
virtual void set_mask_count_abi(size_t count) noexcept = 0;
};
/** Forward declaration of the IJob interface. */
OMNI_DECLARE_INTERFACE(IJob);
/** Forward declaration of the IJobWorker interface. */
OMNI_DECLARE_INTERFACE(IJobWorker);
/** Forward declaration of the IJobAffinity interface. */
OMNI_DECLARE_INTERFACE(IJobAffinity);
/**
* Basic interface for launching jobs on a foreign job system.
*/
class IJob_abi : public omni::core::Inherits<omni::core::IObject, OMNI_TYPE_ID("omni.experimental.job.IJob")>
{
protected:
/**
* Adds a new job to be executed.
*
* @param job_fn User provided function to be executed by a worker.
* @param job_data User provided data for the job, the memory must not be released until it no longer needed by the
* task.
*/
virtual void enqueue_job_abi(JobFunction job_fn, OMNI_ATTR("in, out") void* job_data) noexcept = 0;
};
/**
* Interface for managing the number of workers in the job system.
*/
class IJobWorker_abi : public omni::core::Inherits<omni::core::IObject, OMNI_TYPE_ID("omni.experimental.job.IJobWorker")>
{
protected:
/**
* Returns default number of workers used for creation of a new Job system.
*
* @return The default number of workers.
*/
virtual size_t get_default_worker_count_abi() noexcept = 0;
/**
* Returns the number of worker threads in the job system.
*
* @returns The number of worker threads.
*/
virtual size_t get_worker_count_abi() noexcept = 0;
/**
* Sets the number of workers in the job system.
*
* This function may stop all current threads and reset any previously set thread affinity.
*
* @param count The new number of workers to set in the system. A value of 0 means to use the default value returned
* by getDefaultWorkerCount()
*/
virtual void set_worker_count_abi(size_t count) noexcept = 0;
};
/**
* Interface for setting CPU affinity for the job system.
*/
class IJobAffinity_abi
: public omni::core::Inherits<omni::core::IObject, OMNI_TYPE_ID("omni.experimental.job.IJobAffinity")>
{
protected:
/**
* Gets the current affinity of a worker.
*
* @param worker_id The worker to set the affinity of. If this id is larger than the current number of workers,
* a \c nullptr will be returned.
*
* @return The current affinity being used by the worker. The returned value may be \c nullptr if the worker's
* affinity could not be determined.
*/
virtual IAffinityMask* get_affinity_abi(size_t worker_id) noexcept = 0;
/**
* Attempts to set the affinity for the specified worker.
*
* @note On Windows each thread can only belong to a single Processor Group, so the CPU Affinity will only be set
* to the first non-zero entry. That is to say, if both \c mask->get_affinity_mask(0) and
* \c mask->get_affinity_mask(1) both have bits sets, only the CPUs in \c mask->get_affinity_mask(0) will be set for
* the affinity.
*
* @param worker_id The worker to set the affinity of. If this id is larger than the current number of workers,
* false will be returned.
* @param mask The affinity values to set.
*
* @return true if the affinity was successfully set, false otherwise.
*/
virtual bool set_affinity_abi(size_t worker_id, OMNI_ATTR("not_null") IAffinityMask* mask) noexcept = 0;
};
} // namespace job
} // namespace experimental
} // namespace omni
#include "IJob.gen.h"
| 7,005 | C | 34.20603 | 121 | 0.684511 |
omniverse-code/kit/include/omni/experimental/url/IUrl.gen.h | // Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
// --------- Warning: This is a build system generated file. ----------
//
//! @file
//!
//! @brief This file was generated by <i>omni.bind</i>.
#include <omni/core/OmniAttr.h>
#include <omni/core/Interface.h>
#include <omni/core/ResultError.h>
#include <functional>
#include <utility>
#include <type_traits>
#ifndef OMNI_BIND_INCLUDE_INTERFACE_IMPL
template <>
class omni::core::Generated<omni::experimental::IUrl_abi> : public omni::experimental::IUrl_abi
{
public:
OMNI_PLUGIN_INTERFACE("omni::experimental::IUrl")
/**
* Clears this URL
*/
void clear() noexcept;
/**
* Return the string representation of this URL
*/
omni::string to_string() noexcept;
/**
* Return the string representation of this URL, but with valid UTF-8 characters
* decoded. This will leave invalid UTF-8 byte sequences and certain ASCII characters
* encoded; including control codes, and characters that are reserved by the URL
* specification as sub-delimiters.
*/
omni::string to_string_utf8() noexcept;
/**
* Sets this URL from a string
*/
void from_string(const omni::string& url_string) noexcept;
/**
* Sets this URL from a posix file path
* The scheme will be "file" and the path will be the normalized and encoded file path
* Normalization includes removing redundant path segments such as "//", "/./" and
* collapsing ".." segments if possible. For example, it will convert "a/b/../" to "a"
*/
void from_filepath_posix(const omni::string& filepath) noexcept;
/**
* Sets this URL from a windows file path
* The scheme will be "file" and the path will be the normalized and encoded file path
* Path normalization includes everything from "from_filepath_posix_abi" plus:
* - The drive letter is made uppercase
* - Path separators are converted from \\ to /
* - UNC paths such as "\\\\server\\share\path" or "\\\\?\\C:\\path" are handled correctly
*/
void from_filepath_windows(const omni::string& filepath) noexcept;
/**
* Sets this URL from a file path based on the native OS.
* This calls either from_filepath_posix_abi or from_filepath_windows_abi
*/
void from_filepath_native(const omni::string& filepath) noexcept;
/**
* Returns true if the URL has a scheme component.
* "scheme" is the part before the first colon, for example "http" or "omniverse".
* A URL without a scheme component can only be a relative reference.
*
* @see get_scheme()
* @see set_scheme()
*/
bool has_scheme() noexcept;
/**
* Returns true if the URL has an authority component.
* "authority" is the part between the // and /
* For example "user@server:port"
*
* @see get_authority_encoded()
* @see set_authority_encoded()
* @see has_userinfo()
* @see has_host()
* @see has_port()
*/
bool has_authority() noexcept;
/**
* Returns true if the URL has a userinfo sub-component.
* "userinfo" is the part of the authority before @
*
* @see get_userinfo()
* @see set_userinfo()
* @see has_authority()
*/
bool has_userinfo() noexcept;
/**
* Returns true if the URL has a host sub-component.
* "host" is the part of the authority between @ and :
*
* @see get_host()
* @see set_host()
* @see has_authority()
*/
bool has_host() noexcept;
/**
* Returns true if the URL has a port sub-component.
* "port" is the part of the authority after :
*
* @see get_port()
* @see set_port()
* @see has_authority()
*/
bool has_port() noexcept;
/**
* Returns true if the URL has a path component.
* "path" is the part after _abi(and including) /
* For example "/path/to/my/file.txt"
*
* @see get_path_encoded()
* @see set_path_encoded()
* @see set_path_decoded()
*/
bool has_path() noexcept;
/**
* Returns true if the URL has a query component.
* "query" is the part after ? but before #
*
* @see get_query_encoded()
* @see set_query_encoded()
* @see set_query_decoded()
*/
bool has_query() noexcept;
/**
* Returns true if the URL has a fragment component.
* "fragment" is the part after #
*
* @see get_fragment_encoded()
* @see set_fragment_encoded()
* @see set_fragment_decoded()
*/
bool has_fragment() noexcept;
/**
* Returns the scheme.
* The scheme will always be fully decoded and in lower case.
*
* @see has_scheme()
* @see set_scheme()
*/
omni::string get_scheme() noexcept;
/**
* Returns the authority, which may contain percent-encoded data
* For example if the 'userinfo' contains : or @ it must be percent-encoded.
*
* @see set_authority_encoded()
* @see get_userinfo()
* @see get_host()
* @see get_port()
*/
omni::string get_authority_encoded() noexcept;
/**
* Returns the userinfo, fully decoded.
*
* @see get_authority_encoded()
* @see set_userinfo()
* @see has_userinfo()
*/
omni::string get_userinfo() noexcept;
/**
* Returns the host, fully decoded.
*
* @see get_authority_encoded()
* @see set_host()
* @see has_host()
*/
omni::string get_host() noexcept;
/**
* Returns the port number
*
* @see get_authority_encoded()
* @see set_port()
* @see has_port()
*/
uint16_t get_port() noexcept;
/**
* Returns the percent-encoded path component.
*
* @see get_path_utf8()
* @see set_path_encoded()
* @see set_path_decoded()
* @see has_path()
*/
omni::string get_path_encoded() noexcept;
/**
* Returns the path component with all printable ascii and valid UTF-8 characters decoded
* Invalid UTF-8 and ASCII control codes will still be percent-encoded.
* It's generally safe to print the result of this function on screen and in log files.
*
* @see get_path_encoded()
* @see set_path_encoded()
* @see set_path_decoded()
* @see has_path()
*/
omni::string get_path_utf8() noexcept;
/**
* Returns the percent-encoded query component.
*
* @see get_query_encoded()
* @see set_query_encoded()
* @see set_query_decoded()
* @see has_query()
*/
omni::string get_query_encoded() noexcept;
/**
* Returns the percent-encoded fragment component.
*
* @see get_fragment_encoded()
* @see set_fragment_encoded()
* @see set_fragment_decoded()
* @see has_fragment()
*/
omni::string get_fragment_encoded() noexcept;
/**
* Sets the scheme.
*
* @see has_scheme()
* @see get_scheme()
*/
void set_scheme(const omni::string& scheme) noexcept;
/**
* Sets the authority, which is expected to have all the sub-components percent-encoded.
* If characters that _MUST_ be encoded are detected, they will be percent-encoded, however the percent sign itself
* will _NOT_ be encoded.
*
* @see get_authority_encoded()
* @see set_userinfo()
* @see set_host()
* @see set_port()
*/
void set_authority_encoded(const omni::string& authority) noexcept;
/**
* Sets the userinfo. This function expects the userinfo is not already percent-encoded.
*
* @see set_authority_encoded()
* @see get_userinfo()
* @see has_userinfo()
*/
void set_userinfo(const omni::string& userinfo) noexcept;
/**
* Sets the host. This function expects the host is not already percent-encoded.
*
* @see set_authority_encoded()
* @see get_host()
* @see has_host()
*/
void set_host(const omni::string& host) noexcept;
/**
* Sets the port number
*
* @see set_authority_encoded()
* @see get_port()
* @see has_port()
*/
void set_port(uint16_t port) noexcept;
/**
* Sets the path, which is already percent-encoded.
* If characters that _MUST_ be encoded are detected, they will be percent-encoded, however the percent sign itself
* will _NOT_ be encoded.
*
* @see get_path_encoded()
* @see set_path_decoded()
* @see has_path()
*/
void set_path_encoded(const omni::string& path_encoded) noexcept;
/**
* Sets the path, which is NOT already percent-encoded.
* If characters that _MUST_ be encoded are detected, they will be percent-encoded, including the percent sign
* itself
*
* @see get_path_encoded()
* @see set_path_encoded()
* @see has_path()
*/
void set_path_decoded(const omni::string& path_decoded) noexcept;
/**
* Sets the query, which is already percent-encoded.
* If characters that _MUST_ be encoded are detected, they will be percent-encoded, however the percent sign itself
* will _NOT_ be encoded.
*
* @see get_query_encoded()
* @see set_query_decoded()
* @see has_query()
*/
void set_query_encoded(const omni::string& query_encoded) noexcept;
/**
* Sets the query, which is NOT already percent-encoded.
* If characters that _MUST_ be encoded are detected, they will be percent-encoded, including the percent sign
* itself
*
* @see get_query_encoded()
* @see set_query_encoded()
* @see has_query()
*/
void set_query_decoded(const omni::string& query_decoded) noexcept;
/**
* Sets the fragment, which is already percent-encoded.
* If characters that _MUST_ be encoded are detected, they will be percent-encoded, however the percent sign itself
* will _NOT_ be encoded.
*
* @see get_fragment_encoded()
* @see set_fragment_decoded()
* @see has_fragment()
*/
void set_fragment_encoded(const omni::string& fragment_encoded) noexcept;
/**
* Sets the fragment, which is NOT already percent-encoded.
* If characters that _MUST_ be encoded are detected, they will be percent-encoded, including the percent sign
* itself
*
* @see get_fragment_encoded()
* @see set_fragment_encoded()
* @see has_fragment()
*/
void set_fragment_decoded(const omni::string& fragment_decoded) noexcept;
/**
* Create a new IUrl object that represents the shortest possible URL that makes @p other_url relative to this URL.
*
* Relative URLs are described in section 5.2 "Relative Resolution" of RFC-3986
*
* @param other_url URL to make a relative URL to.
*
* @return A new IUrl object that is the relative URL between this URL and @p other_url.
*/
omni::core::ObjectPtr<omni::experimental::IUrl> make_relative(
omni::core::ObjectParam<omni::experimental::IUrl> other_url) noexcept;
/**
* Creates a new IUrl object that is the result of resolving the provided @p relative_url with this URL as the base
* URL.
*
* The algorithm for doing the combination is described in section 5.2 "Relative Resolution" of RFC-3986.
*
* @param relative_url URL to resolve with this URL as the base URL.
*
* @return A new IUrl object that is the result of resolving @p relative_url with this URL.
*/
omni::core::ObjectPtr<omni::experimental::IUrl> resolve_relative(
omni::core::ObjectParam<omni::experimental::IUrl> relative_url) noexcept;
};
#endif
#ifndef OMNI_BIND_INCLUDE_INTERFACE_DECL
inline void omni::core::Generated<omni::experimental::IUrl_abi>::clear() noexcept
{
clear_abi();
}
inline omni::string omni::core::Generated<omni::experimental::IUrl_abi>::to_string() noexcept
{
return to_string_abi();
}
inline omni::string omni::core::Generated<omni::experimental::IUrl_abi>::to_string_utf8() noexcept
{
return to_string_utf8_abi();
}
inline void omni::core::Generated<omni::experimental::IUrl_abi>::from_string(const omni::string& url_string) noexcept
{
from_string_abi(url_string);
}
inline void omni::core::Generated<omni::experimental::IUrl_abi>::from_filepath_posix(const omni::string& filepath) noexcept
{
from_filepath_posix_abi(filepath);
}
inline void omni::core::Generated<omni::experimental::IUrl_abi>::from_filepath_windows(const omni::string& filepath) noexcept
{
from_filepath_windows_abi(filepath);
}
inline void omni::core::Generated<omni::experimental::IUrl_abi>::from_filepath_native(const omni::string& filepath) noexcept
{
from_filepath_native_abi(filepath);
}
inline bool omni::core::Generated<omni::experimental::IUrl_abi>::has_scheme() noexcept
{
return has_scheme_abi();
}
inline bool omni::core::Generated<omni::experimental::IUrl_abi>::has_authority() noexcept
{
return has_authority_abi();
}
inline bool omni::core::Generated<omni::experimental::IUrl_abi>::has_userinfo() noexcept
{
return has_userinfo_abi();
}
inline bool omni::core::Generated<omni::experimental::IUrl_abi>::has_host() noexcept
{
return has_host_abi();
}
inline bool omni::core::Generated<omni::experimental::IUrl_abi>::has_port() noexcept
{
return has_port_abi();
}
inline bool omni::core::Generated<omni::experimental::IUrl_abi>::has_path() noexcept
{
return has_path_abi();
}
inline bool omni::core::Generated<omni::experimental::IUrl_abi>::has_query() noexcept
{
return has_query_abi();
}
inline bool omni::core::Generated<omni::experimental::IUrl_abi>::has_fragment() noexcept
{
return has_fragment_abi();
}
inline omni::string omni::core::Generated<omni::experimental::IUrl_abi>::get_scheme() noexcept
{
return get_scheme_abi();
}
inline omni::string omni::core::Generated<omni::experimental::IUrl_abi>::get_authority_encoded() noexcept
{
return get_authority_encoded_abi();
}
inline omni::string omni::core::Generated<omni::experimental::IUrl_abi>::get_userinfo() noexcept
{
return get_userinfo_abi();
}
inline omni::string omni::core::Generated<omni::experimental::IUrl_abi>::get_host() noexcept
{
return get_host_abi();
}
inline uint16_t omni::core::Generated<omni::experimental::IUrl_abi>::get_port() noexcept
{
return get_port_abi();
}
inline omni::string omni::core::Generated<omni::experimental::IUrl_abi>::get_path_encoded() noexcept
{
return get_path_encoded_abi();
}
inline omni::string omni::core::Generated<omni::experimental::IUrl_abi>::get_path_utf8() noexcept
{
return get_path_utf8_abi();
}
inline omni::string omni::core::Generated<omni::experimental::IUrl_abi>::get_query_encoded() noexcept
{
return get_query_encoded_abi();
}
inline omni::string omni::core::Generated<omni::experimental::IUrl_abi>::get_fragment_encoded() noexcept
{
return get_fragment_encoded_abi();
}
inline void omni::core::Generated<omni::experimental::IUrl_abi>::set_scheme(const omni::string& scheme) noexcept
{
set_scheme_abi(scheme);
}
inline void omni::core::Generated<omni::experimental::IUrl_abi>::set_authority_encoded(const omni::string& authority) noexcept
{
set_authority_encoded_abi(authority);
}
inline void omni::core::Generated<omni::experimental::IUrl_abi>::set_userinfo(const omni::string& userinfo) noexcept
{
set_userinfo_abi(userinfo);
}
inline void omni::core::Generated<omni::experimental::IUrl_abi>::set_host(const omni::string& host) noexcept
{
set_host_abi(host);
}
inline void omni::core::Generated<omni::experimental::IUrl_abi>::set_port(uint16_t port) noexcept
{
set_port_abi(port);
}
inline void omni::core::Generated<omni::experimental::IUrl_abi>::set_path_encoded(const omni::string& path_encoded) noexcept
{
set_path_encoded_abi(path_encoded);
}
inline void omni::core::Generated<omni::experimental::IUrl_abi>::set_path_decoded(const omni::string& path_decoded) noexcept
{
set_path_decoded_abi(path_decoded);
}
inline void omni::core::Generated<omni::experimental::IUrl_abi>::set_query_encoded(const omni::string& query_encoded) noexcept
{
set_query_encoded_abi(query_encoded);
}
inline void omni::core::Generated<omni::experimental::IUrl_abi>::set_query_decoded(const omni::string& query_decoded) noexcept
{
set_query_decoded_abi(query_decoded);
}
inline void omni::core::Generated<omni::experimental::IUrl_abi>::set_fragment_encoded(
const omni::string& fragment_encoded) noexcept
{
set_fragment_encoded_abi(fragment_encoded);
}
inline void omni::core::Generated<omni::experimental::IUrl_abi>::set_fragment_decoded(
const omni::string& fragment_decoded) noexcept
{
set_fragment_decoded_abi(fragment_decoded);
}
inline omni::core::ObjectPtr<omni::experimental::IUrl> omni::core::Generated<omni::experimental::IUrl_abi>::make_relative(
omni::core::ObjectParam<omni::experimental::IUrl> other_url) noexcept
{
return omni::core::steal(make_relative_abi(other_url.get()));
}
inline omni::core::ObjectPtr<omni::experimental::IUrl> omni::core::Generated<omni::experimental::IUrl_abi>::resolve_relative(
omni::core::ObjectParam<omni::experimental::IUrl> relative_url) noexcept
{
return omni::core::steal(resolve_relative_abi(relative_url.get()));
}
#endif
#undef OMNI_BIND_INCLUDE_INTERFACE_DECL
#undef OMNI_BIND_INCLUDE_INTERFACE_IMPL
| 17,715 | C | 29.078098 | 126 | 0.654361 |
omniverse-code/kit/include/omni/experimental/url/IUrl.h | // Copyright (c) 2022-2023, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "../../core/IObject.h"
#include "../../String.h"
namespace omni
{
namespace experimental
{
OMNI_DECLARE_INTERFACE(IUrl);
class IUrl_abi : public omni::core::Inherits<omni::core::IObject, OMNI_TYPE_ID("omni.IUrl")>
{
protected:
/**
* Clears this URL
*/
virtual void clear_abi() noexcept = 0;
/**
* Return the string representation of this URL
*/
virtual omni::string to_string_abi() noexcept = 0;
/**
* Return the string representation of this URL, but with valid UTF-8 characters
* decoded. This will leave invalid UTF-8 byte sequences and certain ASCII characters
* encoded; including control codes, and characters that are reserved by the URL
* specification as sub-delimiters.
*/
virtual omni::string to_string_utf8_abi() noexcept = 0;
/**
* Sets this URL from a string
*/
virtual void from_string_abi(omni::string const& url_string) noexcept = 0;
/**
* Sets this URL from a posix file path
* The scheme will be "file" and the path will be the normalized and encoded file path
* Normalization includes removing redundant path segments such as "//", "/./" and
* collapsing ".." segments if possible. For example, it will convert "a/b/../" to "a"
*/
virtual void from_filepath_posix_abi(omni::string const& filepath) noexcept = 0;
/**
* Sets this URL from a windows file path
* The scheme will be "file" and the path will be the normalized and encoded file path
* Path normalization includes everything from "from_filepath_posix_abi" plus:
* - The drive letter is made uppercase
* - Path separators are converted from \\ to /
* - UNC paths such as "\\\\server\\share\path" or "\\\\?\\C:\\path" are handled correctly
*/
virtual void from_filepath_windows_abi(omni::string const& filepath) noexcept = 0;
/**
* Sets this URL from a file path based on the native OS.
* This calls either from_filepath_posix_abi or from_filepath_windows_abi
*/
virtual void from_filepath_native_abi(omni::string const& filepath) noexcept = 0;
/**
* Returns true if the URL has a scheme component.
* "scheme" is the part before the first colon, for example "http" or "omniverse".
* A URL without a scheme component can only be a relative reference.
*
* @see get_scheme()
* @see set_scheme()
*/
virtual bool has_scheme_abi() noexcept = 0;
/**
* Returns true if the URL has an authority component.
* "authority" is the part between the // and /
* For example "user@server:port"
*
* @see get_authority_encoded()
* @see set_authority_encoded()
* @see has_userinfo()
* @see has_host()
* @see has_port()
*/
virtual bool has_authority_abi() noexcept = 0;
/**
* Returns true if the URL has a userinfo sub-component.
* "userinfo" is the part of the authority before @
*
* @see get_userinfo()
* @see set_userinfo()
* @see has_authority()
*/
virtual bool has_userinfo_abi() noexcept = 0;
/**
* Returns true if the URL has a host sub-component.
* "host" is the part of the authority between @ and :
*
* @see get_host()
* @see set_host()
* @see has_authority()
*/
virtual bool has_host_abi() noexcept = 0;
/**
* Returns true if the URL has a port sub-component.
* "port" is the part of the authority after :
*
* @see get_port()
* @see set_port()
* @see has_authority()
*/
virtual bool has_port_abi() noexcept = 0;
/**
* Returns true if the URL has a path component.
* "path" is the part after _abi(and including) /
* For example "/path/to/my/file.txt"
*
* @see get_path_encoded()
* @see set_path_encoded()
* @see set_path_decoded()
*/
virtual bool has_path_abi() noexcept = 0;
/**
* Returns true if the URL has a query component.
* "query" is the part after ? but before #
*
* @see get_query_encoded()
* @see set_query_encoded()
* @see set_query_decoded()
*/
virtual bool has_query_abi() noexcept = 0;
/**
* Returns true if the URL has a fragment component.
* "fragment" is the part after #
*
* @see get_fragment_encoded()
* @see set_fragment_encoded()
* @see set_fragment_decoded()
*/
virtual bool has_fragment_abi() noexcept = 0;
/**
* Returns the scheme.
* The scheme will always be fully decoded and in lower case.
*
* @see has_scheme()
* @see set_scheme()
*/
virtual omni::string get_scheme_abi() noexcept = 0;
/**
* Returns the authority, which may contain percent-encoded data
* For example if the 'userinfo' contains : or @ it must be percent-encoded.
*
* @see set_authority_encoded()
* @see get_userinfo()
* @see get_host()
* @see get_port()
*/
virtual omni::string get_authority_encoded_abi() noexcept = 0;
/**
* Returns the userinfo, fully decoded.
*
* @see get_authority_encoded()
* @see set_userinfo()
* @see has_userinfo()
*/
virtual omni::string get_userinfo_abi() noexcept = 0;
/**
* Returns the host, fully decoded.
*
* @see get_authority_encoded()
* @see set_host()
* @see has_host()
*/
virtual omni::string get_host_abi() noexcept = 0;
/**
* Returns the port number
*
* @see get_authority_encoded()
* @see set_port()
* @see has_port()
*/
virtual uint16_t get_port_abi() noexcept = 0;
/**
* Returns the percent-encoded path component.
*
* @see get_path_utf8()
* @see set_path_encoded()
* @see set_path_decoded()
* @see has_path()
*/
virtual omni::string get_path_encoded_abi() noexcept = 0;
/**
* Returns the path component with all printable ascii and valid UTF-8 characters decoded
* Invalid UTF-8 and ASCII control codes will still be percent-encoded.
* It's generally safe to print the result of this function on screen and in log files.
*
* @see get_path_encoded()
* @see set_path_encoded()
* @see set_path_decoded()
* @see has_path()
*/
virtual omni::string get_path_utf8_abi() noexcept = 0;
/**
* Returns the percent-encoded query component.
*
* @see get_query_encoded()
* @see set_query_encoded()
* @see set_query_decoded()
* @see has_query()
*/
virtual omni::string get_query_encoded_abi() noexcept = 0;
/**
* Returns the percent-encoded fragment component.
*
* @see get_fragment_encoded()
* @see set_fragment_encoded()
* @see set_fragment_decoded()
* @see has_fragment()
*/
virtual omni::string get_fragment_encoded_abi() noexcept = 0;
/**
* Sets the scheme.
*
* @see has_scheme()
* @see get_scheme()
*/
virtual void set_scheme_abi(omni::string const& scheme) noexcept = 0;
/**
* Sets the authority, which is expected to have all the sub-components percent-encoded.
* If characters that _MUST_ be encoded are detected, they will be percent-encoded, however the percent sign itself
* will _NOT_ be encoded.
*
* @see get_authority_encoded()
* @see set_userinfo()
* @see set_host()
* @see set_port()
*/
virtual void set_authority_encoded_abi(omni::string const& authority) noexcept = 0;
/**
* Sets the userinfo. This function expects the userinfo is not already percent-encoded.
*
* @see set_authority_encoded()
* @see get_userinfo()
* @see has_userinfo()
*/
virtual void set_userinfo_abi(omni::string const& userinfo) noexcept = 0;
/**
* Sets the host. This function expects the host is not already percent-encoded.
*
* @see set_authority_encoded()
* @see get_host()
* @see has_host()
*/
virtual void set_host_abi(omni::string const& host) noexcept = 0;
/**
* Sets the port number
*
* @see set_authority_encoded()
* @see get_port()
* @see has_port()
*/
virtual void set_port_abi(uint16_t port) noexcept = 0;
/**
* Sets the path, which is already percent-encoded.
* If characters that _MUST_ be encoded are detected, they will be percent-encoded, however the percent sign itself
* will _NOT_ be encoded.
*
* @see get_path_encoded()
* @see set_path_decoded()
* @see has_path()
*/
virtual void set_path_encoded_abi(omni::string const& path_encoded) noexcept = 0;
/**
* Sets the path, which is NOT already percent-encoded.
* If characters that _MUST_ be encoded are detected, they will be percent-encoded, including the percent sign
* itself
*
* @see get_path_encoded()
* @see set_path_encoded()
* @see has_path()
*/
virtual void set_path_decoded_abi(omni::string const& path_decoded) noexcept = 0;
/**
* Sets the query, which is already percent-encoded.
* If characters that _MUST_ be encoded are detected, they will be percent-encoded, however the percent sign itself
* will _NOT_ be encoded.
*
* @see get_query_encoded()
* @see set_query_decoded()
* @see has_query()
*/
virtual void set_query_encoded_abi(omni::string const& query_encoded) noexcept = 0;
/**
* Sets the query, which is NOT already percent-encoded.
* If characters that _MUST_ be encoded are detected, they will be percent-encoded, including the percent sign
* itself
*
* @see get_query_encoded()
* @see set_query_encoded()
* @see has_query()
*/
virtual void set_query_decoded_abi(omni::string const& query_decoded) noexcept = 0;
/**
* Sets the fragment, which is already percent-encoded.
* If characters that _MUST_ be encoded are detected, they will be percent-encoded, however the percent sign itself
* will _NOT_ be encoded.
*
* @see get_fragment_encoded()
* @see set_fragment_decoded()
* @see has_fragment()
*/
virtual void set_fragment_encoded_abi(omni::string const& fragment_encoded) noexcept = 0;
/**
* Sets the fragment, which is NOT already percent-encoded.
* If characters that _MUST_ be encoded are detected, they will be percent-encoded, including the percent sign
* itself
*
* @see get_fragment_encoded()
* @see set_fragment_encoded()
* @see has_fragment()
*/
virtual void set_fragment_decoded_abi(omni::string const& fragment_decoded) noexcept = 0;
/**
* Create a new IUrl object that represents the shortest possible URL that makes @p other_url relative to this URL.
*
* Relative URLs are described in section 5.2 "Relative Resolution" of RFC-3986
*
* @param other_url URL to make a relative URL to.
*
* @return A new IUrl object that is the relative URL between this URL and @p other_url.
*/
virtual IUrl* make_relative_abi(IUrl* other_url) noexcept = 0;
/**
* Creates a new IUrl object that is the result of resolving the provided @p relative_url with this URL as the base
* URL.
*
* The algorithm for doing the combination is described in section 5.2 "Relative Resolution" of RFC-3986.
*
* @param relative_url URL to resolve with this URL as the base URL.
*
* @return A new IUrl object that is the result of resolving @p relative_url with this URL.
*/
virtual IUrl* resolve_relative_abi(IUrl* relative_url) noexcept = 0;
};
} // namespace experimental
} // namespace omni
#include "IUrl.gen.h"
| 12,193 | C | 30.672727 | 119 | 0.620848 |
omniverse-code/kit/include/omni/graph/io/BundleAttrib.h | // Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#pragma message("omni/graph/io/BundleAttrib.h is deprecated. Include omni/graph/core/BundleAttrib.h instead.")
// ====================================================================================================
/* _____ _ _ _ _ _
| __ \ | \ | | | | | | | |
| | | | ___ | \| | ___ | |_ | | | |___ ___
| | | |/ _ \ | . ` |/ _ \| __| | | | / __|/ _ \
| |__| | (_) | | |\ | (_) | |_ | |__| \__ \ __/
|_____/ \___/ |_| \_|\___/ \__| \____/|___/\___|
This is a temporary interface that can change at any time.
*/
// ====================================================================================================
#include "IDirtyID.h"
#include <omni/graph/core/IBundle.h>
namespace omni
{
namespace graph
{
namespace io
{
class BundlePrim;
class ConstBundlePrim;
using BundleAttribSourceType OMNI_GRAPH_IO_DEPRECATED = uint8_t;
/**
* BundleAttributeSource is used to differentiate between UsdAttributes
* and UsdRelationships.
*
* TODO: Investigate why we can't use eRelationship for this purpose.
*/
enum class OMNI_GRAPH_IO_DEPRECATED BundleAttribSource : BundleAttribSourceType
{
Attribute,
Relationship,
};
/**
* Attribute in bundle primitive.
*
* In contrast to (Const)BundlePrim and (Const)BundlePrims, PrimAttribute uses
* const qualifier to express constness of the attribute.
*
* TODO: Review if const qualifier is appropriate.
*/
class OMNI_GRAPH_IO_DEPRECATED BundleAttrib
{
public:
/**
* Backward compatibility alias.
*/
using SourceType = BundleAttribSourceType;
using Source = BundleAttribSource;
BundleAttrib() = default;
/**
* Read initialization.
*/
BundleAttrib(ConstBundlePrim& prim, omni::graph::core::NameToken name) noexcept;
/**
* Read-Write initialization.
*/
BundleAttrib(BundlePrim& prim,
omni::graph::core::NameToken name,
omni::graph::core::Type type,
size_t arrayElementCount,
BundleAttribSource source) noexcept;
BundleAttrib(BundleAttrib const&) = delete;
BundleAttrib(BundleAttrib&&) noexcept = delete;
BundleAttrib& operator=(BundleAttrib const&) = delete;
BundleAttrib& operator=(BundleAttrib&&) noexcept = delete;
/**
* @return Bundle Primitive where this attribute belongs to.
*/
ConstBundlePrim* getBundlePrim() const noexcept;
/**
* @return Bundle Primitive where this attribute belongs to.
*/
BundlePrim* getBundlePrim() noexcept;
/**
* @return Non const attribute handle of this attribute.
*/
omni::graph::core::AttributeDataHandle handle() noexcept;
/**
* @return Const attribute handle of this attribute.
*/
omni::graph::core::ConstAttributeDataHandle handle() const noexcept;
/**
* @return Name of this attribute.
*/
omni::graph::core::NameToken name() const noexcept;
/**
* @return Type of this attribute.
*/
omni::graph::core::Type type() const noexcept;
/**
* @return Interpolation of this attribute.
*/
omni::graph::core::NameToken interpolation() const noexcept;
/**
* Set interpolation for this attribute.
*
* @return True if operation successful, false otherwise.
*/
bool setInterpolation(omni::graph::core::NameToken interpolation) noexcept;
/**
* Clean interpolation information for this attribute.
*/
void clearInterpolation() noexcept;
/**
* @return Dirty Id of this attribute.
*/
DirtyIDType dirtyID() const noexcept;
/**
* Set dirty id to given value.
*
* @return True if successful, false otherwise.
*/
bool setDirtyID(DirtyIDType dirtyID) noexcept;
/**
* Bump dirty id for this attribute.
*
* @return True if successful, false otherwise.
*/
bool bumpDirtyID() noexcept;
/**
* Set source for this attribute.
*
* @return True if successful, false otherwise.
*/
bool setSource(Source source) noexcept;
/**
* Reset source to default value for this attribute.
*/
void clearSource() noexcept;
/**
* @return True if this attribute is an array attribute.
*/
bool isArray() const noexcept;
/**
* @return Size of this attribute. If attribute is not an array, then size is 1.
*/
size_t size() const noexcept;
/**
* Changes size of this attribute.
*/
void resize(size_t arrayElementCount) noexcept;
/**
* Copy attribute contents from another attribute.
* Destination name is preserved.
*/
void copyContentsFrom(BundleAttrib const& sourceAttr) noexcept;
/**
* @return Internal data as void pointer.
*/
void* getDataInternal() noexcept;
/**
* @return Internal data as void pointer.
*/
void const* getDataInternal() const noexcept;
template <typename T>
T get() const noexcept;
// NOTE: If this is not an array type attribute, this pointer may not be valid once any prim,
// even if it's not the prim containing this attribute, has an attribute added or removed,
// due to how attribute data is stored.
template <typename T>
T* getData() noexcept;
template <typename T>
T const* getData() const noexcept;
template <typename T>
T const* getConstData() const noexcept;
template <typename T>
void set(T const& value) noexcept;
template <typename T>
void set(T const* values, size_t elementCount) noexcept;
/***********************************************************************************************
*
* TODO: Following methods might be deprecated in the future.
* In the next iteration when real interface starts to emerge, we can retire those methods.
*
***********************************************************************************************/
/**
* @todo First iteration of MPiB didn't use 'eRelationship' type to describe relationships.
* Thus, strange approach was created to treat attribute, that is a relationship as a "source".
*/
Source source() const noexcept;
/**
* @return true if this attribute is data.
*/
bool isAttributeData() const noexcept;
/**
* @return true if this attribute is relationship.
*/
bool isRelationshipData() const noexcept;
/**
* @deprecated IBundle2 interface does not require prefixing, use getName().
*/
omni::graph::core::NameToken prefixedName() const noexcept;
private:
/**
* Remove attribute and its internal data.
*/
void clearContents() noexcept;
omni::graph::core::IConstBundle2* getConstBundlePtr() const noexcept;
omni::graph::core::IBundle2* getBundlePtr() noexcept;
ConstBundlePrim* m_bundlePrim{ nullptr };
// Attribute Definition:
omni::graph::core::NameToken m_name = carb::flatcache::kUninitializedToken;
carb::flatcache::TypeC m_type;
// Attribute Property Cached Values:
omni::graph::core::NameToken m_interpolation = carb::flatcache::kUninitializedToken;
DirtyIDType m_dirtyID{ kInvalidDirtyID };
Source m_source { BundleAttribSource::Attribute };
friend class ConstBundlePrims;
friend class BundlePrim;
};
/**
* Do not use! Backward compatibility alias.
*/
using BundleAttributeInfo OMNI_GRAPH_IO_DEPRECATED = BundleAttrib;
} // namespace io
} // namespace graph
} // namespace omni
#include "BundleAttribImpl.h"
| 8,030 | C | 27.178947 | 110 | 0.608219 |
omniverse-code/kit/include/omni/graph/io/BundlePrims.h | // Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#pragma message("omni/graph/io/BundlePrims.h is deprecated. Include omni/graph/core/BundlePrims.h instead.")
// ====================================================================================================
/* _____ _ _ _ _ _
| __ \ | \ | | | | | | | |
| | | | ___ | \| | ___ | |_ | | | |___ ___
| | | |/ _ \ | . ` |/ _ \| __| | | | / __|/ _ \
| |__| | (_) | | |\ | (_) | |_ | |__| \__ \ __/
|_____/ \___/ |_| \_|\___/ \__| \____/|___/\___|
This is a temporary interface that can change at any time.
*/
// ====================================================================================================
#include "ConstBundlePrims.h"
namespace omni
{
namespace graph
{
namespace io
{
class BundlePrims;
class BundlePrimIterator;
class BundlePrimAttrIterator;
/**
* Collection of read-write attributes in a primitive.
*/
class OMNI_GRAPH_IO_DEPRECATED BundlePrim : public ConstBundlePrim
{
public:
using AttrMapIteratorType = BundleAttributeMap::iterator;
/**
* @return Parent of this bundle prim.
*/
BundlePrims* getBundlePrims() noexcept;
/**
* @return Bundle handle of this primitive.
*/
omni::graph::core::BundleHandle handle() noexcept;
/**
* Sets type of the primitive.
*/
void setType(omni::graph::core::NameToken type) noexcept;
/**
* @return Cached instance of BundleAttrib if attribute is found successfully, nullptr otherwise.
*/
BundleAttrib* getAttr(omni::graph::core::NameToken attrName) noexcept;
/**
* @return BundleAttrib if attribute is added successfully, nullptr otherwise.
*/
BundleAttrib* addAttr(omni::graph::core::NameToken attrName,
omni::graph::core::Type type,
size_t arrayElementCount = 0,
BundleAttrib::Source source = BundleAttrib::Source::Attribute) noexcept;
/**
* Convenience structure for adding attributes.
*/
struct AddAttrInfo
{
omni::graph::core::NameToken attrName;
omni::graph::core::Type type;
size_t arrayElementCount;
BundleAttrib::Source source;
};
/**
* Adds a list of attributes to this bundle prim.
*
* @param[in] attrList Vector of all the new attributes to be added to this prim
* @returns True if all (new) attributes were added successfully
*
* @todo Weakness of this interface is that it forces usage of std::vector.
*/
bool addAttrs(std::vector<AddAttrInfo> const& attrList) noexcept;
/**
* Remove attribute with a given name from this primitive.
*/
void removeAttr(omni::graph::core::NameToken attrName) noexcept;
/**
* Recursively remove all attributes from this primitive.
*/
void clearContents() noexcept;
/**
* Copy contents from another bundle prim.
*/
void copyContentsFrom(ConstBundlePrim& source, bool removeAttrsNotInSource = true) noexcept;
/**
* Bump dirty id for this bundle prim.
*/
void bumpDirtyID() noexcept;
/**
* Set dirty id for this bundle prim.
*/
void setDirtyID(DirtyIDType dirtyID) noexcept;
/**
* @return Attribute iterator pointing to the first attribute in this bundle.
*/
BundlePrimAttrIterator begin() noexcept;
/**
* @return Attribute iterator pointing to the last attribute in this bundle.
*/
BundlePrimAttrIterator end() noexcept;
/**
* @return Attribute iterator pointing to the first attribute in this bundle.
*/
ConstBundlePrimAttrIterator cbegin() noexcept;
/**
* @return Attribute iterator pointing to the last attribute in this bundle.
*/
ConstBundlePrimAttrIterator cend() noexcept;
/***********************************************************************************************
*
* TODO: Following methods might be deprecated in the future.
* In the next iteration when real interface starts to emerge, we can retire those methods.
*
***********************************************************************************************/
/**
* Create an attribute that is a relationship type.
*/
BundleAttrib* addRelationship(omni::graph::core::NameToken name, size_t targetCount) noexcept;
/**
* @deprecated Do not use! It doesn't do anything, it's kept for backward compatibility.
*/
void setPath(omni::graph::core::NameToken path) noexcept;
/**
* @deprecated Use getBundlePrims.
*/
BundlePrims* bundlePrims() noexcept;
/**
* @deprecated Do not use!
*/
void copyContentsFrom(ConstBundlePrim const& source, bool removeAttrsNotInSource = true) noexcept;
private:
/**
* Direct initialization with IBundle interface.
*
* ConstBundlePrim and BundlePrim take advantage of polymorphic relationship
* between IConstBundle and IBundle interfaces.
* In order to modify bundles, BundlePrim makes an attempt to cast IConstBundle
* to IBundle interface. When this process is successful then, bundle can be modified.
*
* Only BundlePrims is allowed to create instances of BundlePrim.
*/
BundlePrim(BundlePrims& bundlePrims, BundlePrimIndex primIndex, omni::core::ObjectPtr<IBundle2> bundle);
/**
* Clear contents of IBundle.
*/
void recursiveClearContents(omni::graph::core::GraphContextObj const& context,
omni::graph::core::IBundleFactory* factory,
omni::graph::core::IBundle2* bundle) noexcept;
/**
* @return Make an attempt to cast IConstBundle interface to IBundle. Returns nullptr if operation failed.
*/
omni::graph::core::IBundle2* getBundlePtr(omni::graph::core::IConstBundle2* constBundle) noexcept;
/**
* @return Make an attempt to cast IConstBundle interface to IBundle. Returns nullptr if operation failed.
*/
omni::graph::core::IBundle2* getBundlePtr() noexcept;
/**
* @return True if primitive is an instance of common attributes.
*/
bool isCommonAttrs() const noexcept
{
return m_primIndex == kInvalidBundlePrimIndex;
}
friend class BundlePrimIterator;
friend class BundlePrims;
friend class BundleAttrib;
};
/**
* Collection of read-write primitives in a bundle.
*
* Bundle Primitives is not movable, not copyable. It lifespan is managed by the user.
*/
class OMNI_GRAPH_IO_DEPRECATED BundlePrims : public ConstBundlePrims
{
public:
/**
* Acquire access to a bundle primitives under given handle.
*/
BundlePrims(omni::graph::core::GraphContextObj const& context, omni::graph::core::BundleHandle const& bundle);
~BundlePrims() noexcept;
/**
* @return Bundle handle of this primitive.
*/
omni::graph::core::BundleHandle handle() noexcept;
/**
* @return BundlePrim under given index, or nullptr if prim is not found.
*/
BundlePrim* getPrim(BundlePrimIndex primIndex) noexcept;
/**
* @return BundlePrim allowing access to attributes to this bundle primitives.
*/
BundlePrim& getCommonAttrs() noexcept;
/**
* Add new primitives to this bundle.
*
* @return Number of successfully added primitives.
*/
size_t addPrims(size_t primCountToAdd) noexcept;
/**
* Remove primitive under given index.
*/
bool removePrim(BundlePrimIndex primIndex) noexcept;
/**
* Cleans up this primitive bundle. Remove all primitives and attributes.
*/
void clearContents() noexcept;
/**
* Bump id of this bundle primitives.
*/
DirtyIDType bumpBundleDirtyID() noexcept;
/**
* @return Primitive iterator pointing to the first primitive in this bundle.
*/
BundlePrimIterator begin() noexcept;
/**
* @return Primitive iterator pointing to the last primitive in this bundle.
*/
BundlePrimIterator end() noexcept;
/**
* @return Primitive iterator pointing to the first primitive in this bundle.
*/
ConstBundlePrimIterator cbegin() noexcept;
/**
* @return Primitive iterator pointing to the last primitive in this bundle.
*/
ConstBundlePrimIterator cend() noexcept;
/***********************************************************************************************
*
* TODO: Following methods might be deprecated in the future.
* In the next iteration when real interface starts to emerge, we can retire those methods.
*
***********************************************************************************************/
/**
* @deprecated Don't use! Read attach() description.
*/
BundlePrims();
/**
* @deprecated Use appropriate constructor and heap allocate BundlePrims.
*
* @todo: There is no benefit of using this method. Cache has to be rebuild from scratch
* whenever BundlePrims is attached/detached.
* It would be better to remove default constructor and enforce cache construction
* through constructor with arguments.
*/
void attach(omni::graph::core::GraphContextObj const& context, omni::graph::core::BundleHandle const& bundle) noexcept;
/**
* @deprecated Use appropriate constructor and heap allocate ConstBundlePrims.
*/
void detach() noexcept;
/**
* @deprecated Do not use! This function is deprecated. Adding prim types has been moved to attach.
* ConstBundlePrims attach function will iterate over prims and collect their
* paths and types.@brief
*/
omni::graph::core::NameToken* addPrimTypesIfMissing() noexcept;
/**
* @deprecated Do not use! Use removePrim with index. This override introduces ambiguity where int can
* be converted to a pointer.
*
* @todo: Weakness of removePrim design is that it introduces two overrides with following arguments:
* * pointer
* * integer
* This leads to ambiguity during override resolution. Override with a pointer should be avoided
* and removed in the future.
*/
bool removePrim(ConstBundlePrim* prim) noexcept;
/**
* @deprecated Do not use! There is no need for this function to exist.
* Get the primitive and call clearContents().
*/
BundlePrim* getClearedPrim(BundlePrimIndex primIndex) noexcept;
/**
* @deprecated Responsibility to cache primitive's attributes has been moved to BundlePrim.
*/
void ensurePrimAttrsCached(BundlePrimIndex primIndex) noexcept;
/**
* This method exists for backward compatibility only. With new interface bundle holds the type.
*
* @deprecated Do not use! Use getConstPrimTypes().
*/
omni::graph::core::NameToken* getPrimTypes() noexcept;
/**
* This method exists for backward compatibility only. With new interface bundle holds the path.
*
* @deprecated Do not use! Use getConstPrimPaths().
*/
omni::graph::core::NameToken* getPrimPaths() noexcept;
/**
* @deprecated Do not use! Path is a part of IBundle interface.
*/
omni::graph::core::NameToken* addPrimPathsIfMissing() noexcept;
private:
/**
* @return Returns nullptr if bundle is read only, or IBundle2 instance otherwise.
*/
omni::graph::core::IBundle2* getBundlePtr() noexcept;
/**
* @return Get prim dirty ids of this bundle.
*/
DirtyIDType* getPrimDirtyIDs() noexcept;
// cached attribute handles
using AttributeDataHandle = omni::graph::core::AttributeDataHandle;
AttributeDataHandle m_bundleDirtyIDAttr{ AttributeDataHandle::invalidValue() };
AttributeDataHandle m_primDirtyIDsAttr{ AttributeDataHandle::invalidValue() };
AttributeDataHandle m_primPathsAttr{ AttributeDataHandle::invalidValue() };
AttributeDataHandle m_primTypesAttr{ AttributeDataHandle::invalidValue() };
AttributeDataHandle m_primIndexAttr{ AttributeDataHandle::invalidValue() };
friend class BundlePrim;
friend class BundleAttrib;
};
/**
* Primitives in Bundle iterator.
*/
class OMNI_GRAPH_IO_DEPRECATED BundlePrimIterator
{
public:
BundlePrimIterator(BundlePrims& bundlePrims, BundlePrimIndex primIndex = 0) noexcept;
BundlePrimIterator(BundlePrimIterator const& that) noexcept = default;
BundlePrimIterator& operator=(BundlePrimIterator const& that) noexcept = default;
bool operator==(BundlePrimIterator const& that) const noexcept;
bool operator!=(BundlePrimIterator const& that) const noexcept;
BundlePrim& operator*() noexcept;
BundlePrim* operator->() noexcept;
BundlePrimIterator& operator++() noexcept;
private:
BundlePrims* m_bundlePrims;
BundlePrimIndex m_primIndex;
};
/**
* Attributes in Primitive iterator.
*/
class OMNI_GRAPH_IO_DEPRECATED BundlePrimAttrIterator
{
public:
BundlePrimAttrIterator(BundlePrim& bundlePrim, BundlePrim::AttrMapIteratorType attrIter) noexcept;
BundlePrimAttrIterator(BundlePrimAttrIterator const& that) noexcept = default;
BundlePrimAttrIterator& operator=(BundlePrimAttrIterator const& that) noexcept = default;
bool operator==(BundlePrimAttrIterator const& that) const noexcept;
bool operator!=(BundlePrimAttrIterator const& that) const noexcept;
BundleAttrib& operator*() noexcept;
BundleAttrib* operator->() noexcept;
BundlePrimAttrIterator& operator++() noexcept;
BundleAttrib const* getConst() noexcept;
private:
BundlePrim* m_bundlePrim;
BundlePrim::AttrMapIteratorType m_attrIter;
};
} // namespace io
} // namespace graph
} // namespace omni
#include "BundlePrimsImpl.h"
| 14,273 | C | 31.738532 | 123 | 0.637497 |
omniverse-code/kit/include/omni/graph/io/ConstBundlePrimsImpl.h | // Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "ConstBundlePrims.h"
#include <omni/graph/core/CppWrappers.h>
#include <omni/graph/core/iComputeGraph.h>
#include <omni/graph/core/ComputeGraph.h>
#include <algorithm>
namespace omni
{
namespace graph
{
namespace io
{
// ====================================================================================================
//
// Const Bundle Primitive
//
// ====================================================================================================
inline ConstBundlePrim::ConstBundlePrim(ConstBundlePrims& bundlePrims,
BundlePrimIndex primIndex,
omni::core::ObjectPtr<omni::graph::core::IConstBundle2> bundle)
: m_bundlePrims{ &bundlePrims }, m_bundle{ std::move(bundle) }, m_primIndex{ primIndex }
{
// Read and cache all non internal attributes.
readAndCacheAttributes();
}
inline void ConstBundlePrim::readAndCacheAttributes() noexcept
{
using namespace omni::graph::core;
IConstBundle2* bundle = getConstBundlePtr();
GraphContextObj const& context = getConstBundlePrims()->context();
std::vector<ConstAttributeDataHandle> attrHandles(bundle->getAttributeCount());
bundle->getConstAttributes(attrHandles.data(), attrHandles.size());
auto& attrs = getAttributes();
for(ConstAttributeDataHandle& attrHandle : attrHandles)
{
if(!attrHandle.isValid())
continue;
NameToken attrName = context.iAttributeData->getName(context, attrHandle);
attrs.insert(std::make_pair(attrName, std::make_unique<BundleAttrib>(*this, attrName)));
}
}
inline BundleAttrib const* ConstBundlePrim::getConstAttr(core::NameToken attrName) noexcept
{
using namespace omni::graph::core;
// Try to find cached attributes
auto& attrMap = getAttributes();
auto it = attrMap.find(attrName);
if (it != attrMap.end())
{
return it->second.get();
}
// Try to find attribute in this bundle.
IConstBundle2* bundle = getConstBundlePtr();
ConstAttributeDataHandle attributeHandle = bundle->getConstAttributeByName(attrName);
if (!attributeHandle.isValid())
{
// attribute is not found, ensure entry is removed from the cache.
auto it = attrMap.find(attrName);
if (it != attrMap.end())
{
attrMap.erase(it);
}
return nullptr;
}
// Check if attribute in the bundle is stale
auto newPrimAttribute = new BundleAttrib{ *this, attrName};
std::unique_ptr<BundleAttrib> primAttributePtr{ newPrimAttribute };
attrMap.emplace(attrName, std::move(primAttributePtr));
return newPrimAttribute;
}
inline BundleAttrib const* ConstBundlePrim::getAttr(omni::graph::core::NameToken attrName) const noexcept
{
return const_cast<ConstBundlePrim*>(this)->getConstAttr(attrName);
}
inline size_t ConstBundlePrim::attrCount() noexcept
{
return getAttributes().size();
}
inline BundlePrimIndex ConstBundlePrim::primIndex() noexcept
{
return m_primIndex;
}
inline omni::graph::core::NameToken ConstBundlePrim::path() noexcept
{
using namespace omni::graph::core;
ConstBundlePrims* bundlePrims = getConstBundlePrims();
BundlePrimIndex const primIndex = this->primIndex();
if (primIndex >= bundlePrims->getPrimCount())
{
return carb::flatcache::kUninitializedToken;
}
NameToken const* paths = bundlePrims->getConstPrimPaths();
return (paths != nullptr) ? paths[primIndex] : carb::flatcache::kUninitializedToken;
}
inline omni::graph::core::NameToken ConstBundlePrim::path() const noexcept
{
return const_cast<ConstBundlePrim*>(this)->path();
}
inline omni::graph::core::NameToken ConstBundlePrim::type() noexcept
{
using namespace omni::graph::core;
ConstBundlePrims* bundlePrims = getConstBundlePrims();
BundlePrimIndex const primIndex = this->primIndex();
if (primIndex >= bundlePrims->getPrimCount())
{
return carb::flatcache::kUninitializedToken;
}
NameToken const* types = bundlePrims->getConstPrimTypes();
return (types != nullptr) ? types[primIndex] : carb::flatcache::kUninitializedToken;
}
inline omni::graph::core::NameToken ConstBundlePrim::type() const noexcept
{
return const_cast<ConstBundlePrim*>(this)->type();
}
inline DirtyIDType ConstBundlePrim::dirtyID() noexcept
{
ConstBundlePrims* bundlePrims = getConstBundlePrims();
if (primIndex() >= bundlePrims->getPrimCount())
{
return bundlePrims->getBundleDirtyID();
}
DirtyIDType const* dirtyIDs = m_bundlePrims->getPrimDirtyIDs();
return (dirtyIDs != nullptr) ? dirtyIDs[m_primIndex] : kInvalidDirtyID;
}
inline DirtyIDType ConstBundlePrim::dirtyID() const noexcept
{
return const_cast<ConstBundlePrim*>(this)->dirtyID();
}
inline ConstBundlePrims* ConstBundlePrim::getConstBundlePrims() noexcept
{
return m_bundlePrims;
}
inline ConstBundlePrimAttrIterator ConstBundlePrim::begin() noexcept
{
return ConstBundlePrimAttrIterator(*this, getAttributes().begin());
}
inline ConstBundlePrimAttrIterator ConstBundlePrim::end() noexcept
{
return ConstBundlePrimAttrIterator(*this, getAttributes().end());
}
inline ConstBundlePrimAttrIterator ConstBundlePrim::begin() const noexcept
{
ConstBundlePrim& thisPrim = const_cast<ConstBundlePrim&>(*this);
return ConstBundlePrimAttrIterator(thisPrim, thisPrim.getAttributes().begin());
}
inline ConstBundlePrimAttrIterator ConstBundlePrim::end() const noexcept
{
ConstBundlePrim& thisPrim = const_cast<ConstBundlePrim&>(*this);
return ConstBundlePrimAttrIterator(thisPrim, thisPrim.getAttributes().end());
}
inline omni::graph::core::IConstBundle2* ConstBundlePrim::getConstBundlePtr() noexcept
{
return m_bundle.get();
}
inline ConstBundlePrim::BundleAttributeMap& ConstBundlePrim::getAttributes() noexcept
{
return m_attributes;
}
// ====================================================================================================
//
// Const Bundle Primitives
//
// ====================================================================================================
inline ConstBundlePrims::ConstBundlePrims()
{
}
inline ConstBundlePrims::ConstBundlePrims(omni::graph::core::GraphContextObj const& context,
omni::graph::core::ConstBundleHandle const& bundle)
: ConstBundlePrims()
{
attach(context, bundle);
}
inline void ConstBundlePrims::detach() noexcept
{
m_bundleDirtyID = kInvalidDirtyID;
m_primTypes = nullptr;
m_primPaths = nullptr;
m_primDirtyIDs = nullptr;
m_iDirtyID = nullptr;
m_primitives.clear();
m_commonAttributes.reset();
m_context = omni::graph::core::GraphContextObj{};
m_bundle.release();
m_factory.release();
}
inline omni::graph::core::NameToken const* ConstBundlePrims::getConstPrimPaths() noexcept
{
return m_primPaths;
}
inline ConstBundlePrims::BundlePrimArray& ConstBundlePrims::getPrimitives() noexcept
{
return m_primitives;
}
inline omni::graph::core::NameToken const* ConstBundlePrims::getConstPrimTypes() noexcept
{
return m_primTypes;
}
inline omni::graph::core::ConstBundleHandle ConstBundlePrims::getConstHandle() noexcept
{
return m_bundle->getConstHandle();
}
template <typename FUNC>
ConstBundlePrim* ConstBundlePrims::getConstPrim(BundlePrimIndex primIndex, FUNC createBundlePrim) noexcept
{
// Return invalid const bundle prim if out of bounds.
size_t const bundlePrimCount = getPrimCount();
if (primIndex >= bundlePrimCount)
{
return nullptr;
}
// Search and return if in cache.
auto& prims = getPrimitives();
if (prims.size() != bundlePrimCount)
{
prims.resize(bundlePrimCount);
}
if (prims[primIndex] != nullptr)
{
return prims[primIndex].get();
}
// update the cache and return the bundle prim.
std::unique_ptr<ConstBundlePrim> newBundlePrim{ createBundlePrim() };
if (!newBundlePrim)
{
return nullptr;
}
ConstBundlePrim* newBundlePrimPtr = newBundlePrim.get();
prims[primIndex] = std::move(newBundlePrim);
return newBundlePrimPtr;
}
inline ConstBundlePrim* ConstBundlePrims::getPrim(BundlePrimIndex primIndex) noexcept
{
return getConstPrim(primIndex);
}
inline ConstBundlePrim* ConstBundlePrims::getConstPrim(BundlePrimIndex primIndex) noexcept
{
using namespace omni::graph::core;
auto createBundlePrim = [this, &bundlePrims = *this, &primIndex]() -> ConstBundlePrim*
{
ConstBundleHandle bundleHandle = getConstBundlePtr()->getConstChildBundle(primIndex);
if (!bundleHandle.isValid())
{
return nullptr;
}
omni::core::ObjectPtr<IConstBundle2> childBundle = getBundleFactoryPtr()->getConstBundle(context(), bundleHandle);
if (!childBundle)
{
return nullptr;
}
return new ConstBundlePrim{ bundlePrims, primIndex, childBundle };
};
return getConstPrim(primIndex, createBundlePrim);
}
inline DirtyIDType ConstBundlePrims::getBundleDirtyID() noexcept
{
return m_bundleDirtyID;
}
inline DirtyIDType const* ConstBundlePrims::getPrimDirtyIDs() noexcept
{
return m_primDirtyIDs;
}
inline ConstBundlePrim& ConstBundlePrims::getConstCommonAttrs() noexcept
{
return *m_commonAttributes;
}
inline omni::graph::core::GraphContextObj const& ConstBundlePrims::context() noexcept
{
using namespace omni::graph::core;
if (m_bundle)
{
m_context = m_bundle->getContext();
}
else
{
m_context = GraphContextObj{};
}
return m_context;
}
inline DirtyIDType ConstBundlePrims::getNextDirtyID() noexcept
{
return m_iDirtyID->getNextDirtyID();
}
inline void ConstBundlePrims::attach(omni::graph::core::GraphContextObj const& context,
omni::graph::core::ConstBundleHandle const& bundleHandle) noexcept
{
using namespace omni::graph::core;
ComputeGraph* computeGraph = carb::getCachedInterface<ComputeGraph>();
omni::core::ObjectPtr<IBundleFactory> factory = computeGraph->getBundleFactoryInterfacePtr();
omni::core::ObjectPtr<IConstBundle2> bundle = factory->getConstBundle(context, bundleHandle);
attach(std::move(factory), std::move(bundle));
}
inline void ConstBundlePrims::attach(omni::core::ObjectPtr<omni::graph::core::IBundleFactory>&& factoryPtr,
omni::core::ObjectPtr<omni::graph::core::IConstBundle2>&& bundlePtr) noexcept
{
using namespace omni::graph::core;
// Initialize members
m_factory = std::move(factoryPtr);
m_bundle = std::move(bundlePtr);
// Initialize common attributes to provide access to ConstBundlePrims attributes.
m_commonAttributes.reset(new ConstBundlePrim(*this, kInvalidBundlePrimIndex, m_bundle));
// Acquire IDirtyID interface
m_iDirtyID = carb::getCachedInterface<omni::graph::io::IDirtyID>();
if (!m_bundle->isValid())
{
return;
}
// TODO: Following code is necessary for backward compatibility.
IConstBundle2* bundle = getConstBundlePtr();
GraphContextObj const& context = this->context();
// Bundle DirtyID.
auto& bundleDirtyIDDef = detail::getBundleDirtyIDDefinition();
ConstAttributeDataHandle bundleDirtyIDHandle = bundle->getConstBundleMetadataByName(bundleDirtyIDDef.token);
if (bundleDirtyIDHandle.isValid())
{
setBundleDirtyID(*getDataR<DirtyIDType>(context, bundleDirtyIDHandle));
}
else
{
setBundleDirtyID(kInvalidDirtyID);
}
// Prim DirtyIDs.
auto& primDirtyIDsDef = detail::getPrimDirtyIDsDefinition();
ConstAttributeDataHandle primDirtyIDsHandle = bundle->getConstBundleMetadataByName(primDirtyIDsDef.token);
if (primDirtyIDsHandle.isValid())
{
size_t arrayLength = 0;
context.iAttributeData->getElementCount(&arrayLength, context, &primDirtyIDsHandle, 1);
setPrimDirtyIDsData(*getDataR<DirtyIDType*>(context, primDirtyIDsHandle));
}
else
{
setPrimDirtyIDsData(nullptr);
}
// Prim Paths.
auto& primPathsDef = detail::getPrimPathsDefinition();
ConstAttributeDataHandle primPathsHandle = bundle->getConstBundleMetadataByName(primPathsDef.token);
if (primPathsHandle.isValid())
{
size_t arrayLength = 0;
context.iAttributeData->getElementCount(&arrayLength, context, &primPathsHandle, 1);
setPrimPathsData(*getDataR<NameToken*>(context, primPathsHandle));
}
else
{
setPrimPathsData(nullptr);
}
// Prim Types.
auto& primTypesDef = detail::getPrimTypesDefinition();
ConstAttributeDataHandle primTypesHandle = bundle->getConstBundleMetadataByName(primTypesDef.token);
if (primTypesHandle.isValid())
{
size_t arrayLength = 0;
context.iAttributeData->getElementCount(&arrayLength, context, &primTypesHandle, 1);
setPrimTypesData(*getDataR<NameToken*>(context, primTypesHandle));
}
else
{
setPrimTypesData(nullptr);
}
}
inline void ConstBundlePrims::setBundleDirtyID(DirtyIDType bundleDirtyID) noexcept
{
m_bundleDirtyID = bundleDirtyID;
}
inline void ConstBundlePrims::setPrimDirtyIDsData(DirtyIDType const* primDirtyIDs) noexcept
{
m_primDirtyIDs = primDirtyIDs;
}
inline void ConstBundlePrims::setPrimPathsData(omni::graph::core::NameToken const* primPaths) noexcept
{
m_primPaths = primPaths;
}
inline void ConstBundlePrims::setPrimTypesData(omni::graph::core::NameToken const* primTypes) noexcept
{
m_primTypes = primTypes;
}
inline omni::graph::core::IBundleFactory* ConstBundlePrims::getBundleFactoryPtr() noexcept
{
return m_factory.get();
}
inline omni::graph::core::IConstBundle2* ConstBundlePrims::getConstBundlePtr() noexcept
{
return m_bundle.get();
}
inline size_t ConstBundlePrims::getPrimCount() noexcept
{
if (IConstBundle2* bundle = getConstBundlePtr())
{
return bundle->getChildBundleCount();
}
return 0;
}
inline ConstBundlePrimIterator ConstBundlePrims::begin() noexcept
{
return ConstBundlePrimIterator(*this);
}
inline ConstBundlePrimIterator ConstBundlePrims::end() noexcept
{
return ConstBundlePrimIterator(*this, getPrimCount());
}
/***********************************************************************************************
*
* TODO: Following methods might be deprecated in the future, but are kept for backward compatibility.
* In the next iteration when real interface starts to emerge, we can retire those methods.
*
***********************************************************************************************/
inline ConstBundlePrim& ConstBundlePrims::getCommonAttrs() noexcept
{
return getConstCommonAttrs();
}
inline omni::graph::core::ConstBundleHandle ConstBundlePrims::handle() noexcept
{
return m_bundle->getConstHandle();
}
inline omni::graph::core::NameToken const* ConstBundlePrims::getPrimPaths() noexcept
{
return getConstPrimPaths();
}
inline void ConstBundlePrims::separateAttrs() noexcept
{
// There is nothing to separate. This function is deprecated.
}
inline void ConstBundlePrims::ensurePrimAttrsCached(BundlePrimIndex primIndex) noexcept
{
// Responsibility of caching attributes was moved to Bundle Prim.
}
// ====================================================================================================
//
// Const Bundle Primitive Iterator
//
// ====================================================================================================
inline ConstBundlePrimIterator::ConstBundlePrimIterator(ConstBundlePrims& bundlePrims, BundlePrimIndex primIndex) noexcept
: m_bundlePrims(&bundlePrims), m_primIndex(primIndex)
{
}
inline bool ConstBundlePrimIterator::operator==(ConstBundlePrimIterator const& that) const noexcept
{
return m_bundlePrims == that.m_bundlePrims && m_primIndex == that.m_primIndex;
}
inline bool ConstBundlePrimIterator::operator!=(ConstBundlePrimIterator const& that) const noexcept
{
return !(*this == that);
}
inline ConstBundlePrim& ConstBundlePrimIterator::operator*() noexcept
{
return *(m_bundlePrims->getConstPrim(m_primIndex));
}
inline ConstBundlePrim* ConstBundlePrimIterator::operator->() noexcept
{
return m_bundlePrims->getConstPrim(m_primIndex);
}
inline ConstBundlePrimIterator& ConstBundlePrimIterator::operator++() noexcept
{
++m_primIndex;
return *this;
}
// ====================================================================================================
//
// Const Bundle Primitive Attribute Iterator
//
// ====================================================================================================
inline ConstBundlePrimAttrIterator::ConstBundlePrimAttrIterator(ConstBundlePrim& bundlePrim, ConstBundlePrim::AttrMapIteratorType attrIter) noexcept
: m_bundlePrim(&bundlePrim), m_attrIter(attrIter)
{
}
inline bool ConstBundlePrimAttrIterator::operator==(ConstBundlePrimAttrIterator const& that) const noexcept
{
return m_bundlePrim == that.m_bundlePrim && m_attrIter == that.m_attrIter;
}
inline bool ConstBundlePrimAttrIterator::operator!=(ConstBundlePrimAttrIterator const& that) const noexcept
{
return !(*this == that);
}
inline BundleAttrib const& ConstBundlePrimAttrIterator::operator*() const noexcept
{
CARB_ASSERT(m_attrIter->second);
return *(m_attrIter->second);
}
inline BundleAttrib const*ConstBundlePrimAttrIterator:: operator->() const noexcept
{
CARB_ASSERT(m_attrIter->second);
return m_attrIter->second.get();
}
inline ConstBundlePrimAttrIterator& ConstBundlePrimAttrIterator::operator++() noexcept
{
++m_attrIter;
return *this;
}
} // namespace io
} // namespace graph
} // namespace omni
| 18,404 | C | 29.522388 | 148 | 0.672843 |
omniverse-code/kit/include/omni/graph/io/BundleAttribImpl.h | // Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "BundleAttrib.h"
#include <omni/graph/core/iComputeGraph.h>
#include <omni/graph/core/CppWrappers.h>
#include <omni/math/linalg/vec.h>
#include <omni/math/linalg/matrix.h>
#include <omni/math/linalg/quat.h>
#include <omni/math/linalg/half.h>
namespace omni
{
namespace math
{
namespace linalg
{
template <typename T>
struct TypeToBaseType
{
constexpr static omni::graph::core::BaseDataType baseType = omni::graph::core::BaseDataType::eUnknown;
};
template <>
struct TypeToBaseType<half>
{
constexpr static omni::graph::core::BaseDataType baseType = omni::graph::core::BaseDataType::eHalf;
};
template <>
struct TypeToBaseType<float>
{
constexpr static omni::graph::core::BaseDataType baseType = omni::graph::core::BaseDataType::eFloat;
};
template <>
struct TypeToBaseType<double>
{
constexpr static omni::graph::core::BaseDataType baseType = omni::graph::core::BaseDataType::eDouble;
};
template <>
struct TypeToBaseType<bool>
{
constexpr static omni::graph::core::BaseDataType baseType = omni::graph::core::BaseDataType::eBool;
};
template <>
struct TypeToBaseType<unsigned char>
{
constexpr static omni::graph::core::BaseDataType baseType = omni::graph::core::BaseDataType::eUChar;
};
template <>
struct TypeToBaseType<int>
{
constexpr static omni::graph::core::BaseDataType baseType = omni::graph::core::BaseDataType::eInt;
};
template <>
struct TypeToBaseType<int64_t>
{
constexpr static omni::graph::core::BaseDataType baseType = omni::graph::core::BaseDataType::eInt64;
};
template <>
struct TypeToBaseType<unsigned int>
{
constexpr static omni::graph::core::BaseDataType baseType = omni::graph::core::BaseDataType::eUInt;
};
template <>
struct TypeToBaseType<uint64_t>
{
constexpr static omni::graph::core::BaseDataType baseType = omni::graph::core::BaseDataType::eUInt64;
};
template <>
struct TypeToBaseType<carb::flatcache::Token>
{
constexpr static omni::graph::core::BaseDataType baseType = omni::graph::core::BaseDataType::eToken;
};
template <typename T, size_t N>
struct TypeToBaseType<base_vec<T, N>>
{
constexpr static omni::graph::core::BaseDataType baseType = TypeToBaseType<T>::baseType;
};
template <typename T>
struct TypeToBaseType<vec2<T>>
{
constexpr static omni::graph::core::BaseDataType baseType = TypeToBaseType<T>::baseType;
};
template <typename T>
struct TypeToBaseType<vec3<T>>
{
constexpr static omni::graph::core::BaseDataType baseType = TypeToBaseType<T>::baseType;
};
template <typename T>
struct TypeToBaseType<vec4<T>>
{
constexpr static omni::graph::core::BaseDataType baseType = TypeToBaseType<T>::baseType;
};
template <typename T>
struct TypeToBaseType<quat<T>>
{
constexpr static omni::graph::core::BaseDataType baseType = TypeToBaseType<T>::baseType;
};
template <typename T, size_t N>
struct TypeToBaseType<base_matrix<T, N>>
{
constexpr static omni::graph::core::BaseDataType baseType = TypeToBaseType<T>::baseType;
};
template <typename T>
struct TypeToBaseType<matrix2<T>>
{
constexpr static omni::graph::core::BaseDataType baseType = TypeToBaseType<T>::baseType;
};
template <typename T>
struct TypeToBaseType<matrix3<T>>
{
constexpr static omni::graph::core::BaseDataType baseType = TypeToBaseType<T>::baseType;
};
template <typename T>
struct TypeToBaseType<matrix4<T>>
{
constexpr static omni::graph::core::BaseDataType baseType = TypeToBaseType<T>::baseType;
};
template <typename T>
struct TypeToComponentCount
{
constexpr static size_t count = 1;
};
template <typename T, size_t N>
struct TypeToComponentCount<base_vec<T,N>>
{
constexpr static size_t count = N;
};
template <typename T>
struct TypeToComponentCount<vec2<T>>
{
constexpr static size_t count = 2;
};
template <typename T>
struct TypeToComponentCount<vec3<T>>
{
constexpr static size_t count = 3;
};
template <typename T>
struct TypeToComponentCount<vec4<T>>
{
constexpr static size_t count = 4;
};
template <typename T>
struct TypeToComponentCount<quat<T>>
{
constexpr static size_t count = 4;
};
template <typename T, size_t N>
struct TypeToComponentCount<base_matrix<T,N>>
{
constexpr static size_t count = N*N;
};
template <typename T>
struct TypeToComponentCount<matrix2<T>>
{
constexpr static size_t count = 4;
};
template <typename T>
struct TypeToComponentCount<matrix3<T>>
{
constexpr static size_t count = 9;
};
template <typename T>
struct TypeToComponentCount<matrix4<T>>
{
constexpr static size_t count = 16;
};
} // namespace linalg
} // namespace math
} // namespace omni
namespace omni
{
namespace graph
{
namespace io
{
namespace detail
{
//
// Non-owning string buffer with compile time size evaluation
//
class StringBuffer
{
public:
using value_type = char const*;
using size_type = std::size_t;
using const_iterator = char const*;
constexpr StringBuffer(value_type data, size_type size) noexcept : m_data{ data }, m_size{ size }
{
}
constexpr explicit StringBuffer(value_type data) noexcept : StringBuffer{ data, len(data) }
{
}
constexpr StringBuffer(StringBuffer const&) = default;
constexpr StringBuffer(StringBuffer&&) = default;
constexpr value_type data() const noexcept
{
return m_data;
}
constexpr size_type size() const noexcept
{
return m_size;
}
constexpr const_iterator begin() const noexcept
{
return m_data;
}
constexpr const_iterator end() const noexcept
{
return m_data + m_size;
}
private:
constexpr size_type len(value_type start) const noexcept
{
value_type end = start;
for (; *end != '\0'; ++end)
;
return end - start;
}
value_type m_data;
size_type m_size;
};
// Helper class to keep name and type together.
struct AttrDefinition
{
AttrDefinition(StringBuffer _name, omni::graph::core::Type _type, omni::graph::core::NameToken _token) noexcept
: name{ _name }
, type{ _type }
, token{ _token }
{
}
AttrDefinition(carb::flatcache::IToken const* iToken, char const* _text, omni::graph::core::Type _type) noexcept
: AttrDefinition{ StringBuffer{_text}, _type, iToken->getHandle(_text) }
{
}
AttrDefinition(AttrDefinition const&) = delete;
AttrDefinition(AttrDefinition&&) = delete;
AttrDefinition& operator=(AttrDefinition const&) = delete;
AttrDefinition& operator=(AttrDefinition&&) = delete;
StringBuffer name; // Name and size of the attribute
omni::graph::core::Type type; // Type of the attribute
omni::graph::core::NameToken token; // Token representation of the name
};
// Attribute Level Definitions:
inline AttrDefinition const& getAttrInterpolationDefinition() noexcept
{
using namespace carb::flatcache;
using namespace omni::graph::core;
static AttrDefinition d{ carb::getCachedInterface<IToken>(), "interpolation", Type{ BaseDataType::eToken, 1, 0 } };
return d;
}
inline AttrDefinition const& getAttrDirtyIdDefinition() noexcept
{
using namespace carb::flatcache;
using namespace omni::graph::core;
static AttrDefinition d{ carb::getCachedInterface<IToken>(), "dirtyID", Type{ BaseDataType::eUInt64, 1, 0 } };
return d;
}
inline AttrDefinition const& getAttrSourceDefinition() noexcept
{
using namespace carb::flatcache;
using namespace omni::graph::core;
static AttrDefinition d{ carb::getCachedInterface<IToken>(), "source", Type{ BaseDataType::eUChar, 1, 0 } };
return d;
}
// Primitive Level Definitions:
inline AttrDefinition const& getPrimPathsDefinition() noexcept
{
using namespace carb::flatcache;
using namespace omni::graph::core;
static AttrDefinition d{ carb::getCachedInterface<IToken>(), "primPaths", Type{ BaseDataType::eToken, 1, 1 } };
return d;
}
inline AttrDefinition const& getPrimTypesDefinition() noexcept
{
using namespace carb::flatcache;
using namespace omni::graph::core;
static AttrDefinition d{ carb::getCachedInterface<IToken>(), "primTypes", Type{ BaseDataType::eToken, 1, 1 } };
return d;
}
inline AttrDefinition const& getPrimIndexDefinition() noexcept
{
using namespace carb::flatcache;
using namespace omni::graph::core;
static AttrDefinition d{ carb::getCachedInterface<IToken>(), "primIndex", Type{ BaseDataType::eUInt64, 1, 0 } };
return d;
}
inline AttrDefinition const& getPrimDirtyIDsDefinition() noexcept
{
using namespace carb::flatcache;
using namespace omni::graph::core;
static AttrDefinition d{ carb::getCachedInterface<IToken>(), "primDirtyIDs", Type{ BaseDataType::eUInt64, 1, 1 } };
return d;
}
// Bundle Level Definitions
inline AttrDefinition const& getBundleDirtyIDDefinition() noexcept
{
using namespace carb::flatcache;
using namespace omni::graph::core;
static AttrDefinition d{ carb::getCachedInterface<IToken>(), "bundleDirtyID", Type{ BaseDataType::eUInt64, 1, 0 } };
return d;
}
// Constant types.
constexpr omni::graph::core::Type s_relationshipType{ omni::graph::core::BaseDataType::eToken, 1, 1 };
} // namespace detail
inline bool BundleAttrib::isRelationshipData() const noexcept
{
return m_source == Source::Relationship && type() == detail::s_relationshipType;
}
inline bool BundleAttrib::setInterpolation(omni::graph::core::NameToken interpolation) noexcept
{
using namespace omni::graph::core;
if (m_interpolation == interpolation)
return true;
if (interpolation == carb::flatcache::kUninitializedToken)
{
clearInterpolation();
return true;
}
if (IBundle2* bundle = getBundlePtr())
{
auto& interpDef = detail::getAttrInterpolationDefinition();
AttributeDataHandle interpolationAttr = bundle->getAttributeMetadataByName(m_name, interpDef.token);
if (!interpolationAttr.isValid())
{
interpolationAttr = bundle->createAttributeMetadata(m_name, interpDef.token, interpDef.type);
}
m_interpolation = interpolation;
auto context = bundle->getContext();
*getDataW<NameToken>(context, interpolationAttr) = interpolation;
return true;
}
return false;
}
inline bool BundleAttrib::setDirtyID(DirtyIDType dirtyID) noexcept
{
using namespace omni::graph::core;
if(m_dirtyID == dirtyID)
return true;
if (IBundle2* bundle = getBundlePtr())
{
auto& dirtyIdDef = detail::getAttrDirtyIdDefinition();
AttributeDataHandle dirtyIDAttr = bundle->getAttributeMetadataByName(m_name, dirtyIdDef.token);
if (!dirtyIDAttr.isValid())
{
dirtyIDAttr = bundle->createAttributeMetadata(m_name, dirtyIdDef.token, dirtyIdDef.type);
}
m_dirtyID = dirtyID;
auto context = bundle->getContext();
*omni::graph::core::getDataW<DirtyIDType>(context, dirtyIDAttr) = dirtyID;
return true;
}
return false;
}
inline bool BundleAttrib::setSource(Source source) noexcept
{
using namespace omni::graph::core;
if(m_source == source)
return true;
if (IBundle2* bundle = getBundlePtr())
{
auto& sourceDef = detail::getAttrSourceDefinition();
AttributeDataHandle sourceAttr = bundle->getAttributeMetadataByName(m_name, sourceDef.token);
if(!sourceAttr.isValid())
{
sourceAttr = bundle->createAttributeMetadata(m_name, sourceDef.token, sourceDef.type);
}
m_source = source;
auto context = bundle->getContext();
*omni::graph::core::getDataW<SourceType>(context, sourceAttr) = static_cast<SourceType>(source);
return true;
}
return false;
}
inline void BundleAttrib::copyContentsFrom(BundleAttrib const& sourceAttr) noexcept
{
using namespace omni::graph::core;
if (m_dirtyID == sourceAttr.m_dirtyID)
return;
IBundle2* dstBundle = getBundlePtr();
IConstBundle2* srcBundle = sourceAttr.getConstBundlePtr();
if (!dstBundle)
{
return;
}
auto context = dstBundle->getContext();
// Copy Attribute
AttributeDataHandle dstAttrHandle = dstBundle->getAttributeByName(m_name);
ConstAttributeDataHandle srcAttrHandle = srcBundle->getConstAttributeByName(sourceAttr.m_name);
// Ensure that copyData updated the type correctly, if needed.
CARB_ASSERT(context.iAttributeData->getType(context, dstAttrHandle) == Type(m_type));
context.iAttributeData->copyData(dstAttrHandle, context, srcAttrHandle);
// Copy the cached type
m_type = sourceAttr.m_type;
// Copy the interpolation (does nothing if the same; clears interpolation if none on sourceAttr)
setInterpolation(sourceAttr.interpolation());
// Copy the dirty ID
setDirtyID(sourceAttr.m_dirtyID);
// Copy source
setSource(sourceAttr.m_source);
}
inline void BundleAttrib::clearInterpolation() noexcept
{
using namespace omni::graph::core;
if (IBundle2* bundle = getBundlePtr())
{
auto context = bundle->getContext();
auto& interpDef = detail::getAttrInterpolationDefinition();
bundle->removeAttributeMetadata(m_name, interpDef.token);
m_interpolation = carb::flatcache::kUninitializedToken;
}
}
inline ConstBundlePrim* BundleAttrib::getBundlePrim() const noexcept
{
return m_bundlePrim;
}
inline void BundleAttrib::clearSource() noexcept
{
using namespace omni::graph::core;
if (IBundle2* bundle = getBundlePtr())
{
auto context = bundle->getContext();
auto& sourceDef = detail::getAttrSourceDefinition();
bundle->removeAttributeMetadata(m_name, sourceDef.token);
m_source = BundleAttribSource::Attribute;
}
}
inline omni::graph::core::NameToken BundleAttrib::name() const noexcept
{
return m_name;
}
inline omni::graph::core::NameToken BundleAttrib::interpolation() const noexcept
{
return m_interpolation;
}
inline DirtyIDType BundleAttrib::dirtyID() const noexcept
{
return m_dirtyID;
}
inline omni::graph::core::Type BundleAttrib::type() const noexcept
{
return omni::graph::core::Type(m_type);
}
inline bool BundleAttrib::isArray() const noexcept
{
omni::graph::core::Type type{ carb::flatcache::TypeC{ m_type } };
CARB_ASSERT(type.arrayDepth < 2);
return (type.arrayDepth != 0);
}
inline BundleAttrib::Source BundleAttrib::source() const noexcept
{
return m_source;
}
inline bool BundleAttrib::isAttributeData() const noexcept
{
return m_source == Source::Attribute;
}
inline omni::graph::core::NameToken BundleAttrib::prefixedName() const noexcept
{
return m_name;
}
inline size_t BundleAttrib::size() const noexcept
{
using namespace omni::graph::core;
if (!isArray())
{
return 1;
}
IConstBundle2* bundle = getConstBundlePtr();
auto context = bundle->getContext();
ConstAttributeDataHandle attr = bundle->getConstAttributeByName(m_name);
size_t count;
context.iAttributeData->getElementCount(&count, context, &attr, 1);
return count;
}
inline void BundleAttrib::resize(size_t arrayElementCount) noexcept
{
using namespace omni::graph::core;
CARB_ASSERT(isArray());
if (IBundle2* bundle = getBundlePtr())
{
auto context = bundle->getContext();
AttributeDataHandle attr = bundle->getAttributeByName(m_name);
context.iAttributeData->setElementCount(context, attr, arrayElementCount);
}
}
inline void* BundleAttrib::getDataInternal() noexcept
{
using namespace omni::graph::core;
if (IBundle2* bundle = getBundlePtr())
{
auto context = bundle->getContext();
AttributeDataHandle attr = bundle->getAttributeByName(m_name);
if (Type(m_type).arrayDepth == 0)
{
return getDataW<void>(context, attr);
}
return *getDataW<void*>(context, attr);
}
return nullptr;
}
inline void const* BundleAttrib::getDataInternal() const noexcept
{
using namespace omni::graph::core;
IConstBundle2* constBundle = getConstBundlePtr();
GraphContextObj context = constBundle->getContext();
ConstAttributeDataHandle attr = constBundle->getConstAttributeByName(m_name);
if (Type(m_type).arrayDepth == 0)
{
return getDataR<void const>(context, attr);
}
return *getDataR<void const*>(context, attr);
}
inline omni::graph::core::AttributeDataHandle BundleAttrib::handle() noexcept
{
using namespace omni::graph::core;
if (IBundle2* bundle = getBundlePtr())
{
return AttributeDataHandle(AttrKey(bundle->getHandle(), m_name.token));
}
return AttributeDataHandle{ AttributeDataHandle::invalidValue() };
}
inline omni::graph::core::ConstAttributeDataHandle BundleAttrib::handle() const noexcept
{
using namespace omni::graph::core;
if(IConstBundle2* bundle = getConstBundlePtr())
{
return ConstAttributeDataHandle{ AttrKey(bundle->getConstHandle(), m_name.token) };
}
return ConstAttributeDataHandle{ ConstAttributeDataHandle::invalidValue() };
}
template <typename T>
T* BundleAttrib::getData() noexcept
{
// It must be valid to request a pointer to type T.
// requesting a float* or vec3f* for a vec3f type is valid, but double* or vec2f* is not.
using namespace omni::math::linalg;
using Type = omni::graph::core::Type;
bool const isSameBaseType = TypeToBaseType<T>::baseType == Type(m_type).baseType;
bool const isSameCount = TypeToComponentCount<T>::count == Type(m_type).componentCount;
bool const isValidCast = isSameBaseType && (TypeToComponentCount<T>::count == 1 || isSameCount);
return isValidCast ? reinterpret_cast<T*>(getDataInternal()) : nullptr;
}
template <typename T>
T const* BundleAttrib::getData() const noexcept
{
// It must be valid to request a pointer to type T.
// requesting a float* or vec3f* for a vec3f type is valid, but double* or vec2f* is not.
using namespace omni::math::linalg;
using Type = omni::graph::core::Type;
bool const isValidCast =
TypeToBaseType<T>::baseType == Type(m_type).baseType &&
(TypeToComponentCount<T>::count == 1 ||
TypeToComponentCount<T>::count == Type(m_type).componentCount);
return isValidCast ? reinterpret_cast<T const*>(getDataInternal()) : nullptr;
}
template <typename T>
T const* BundleAttrib::getConstData() const noexcept
{
return getData<T>();
}
template <typename T>
T BundleAttrib::get() const noexcept
{
using namespace omni::math::linalg;
using Type = omni::graph::core::Type;
// TODO: Figure out how to support array attributes here.
CARB_ASSERT(Type(m_type).arrayDepth == 0);
// This has stronger requirements than getData, since get<float>() isn't valid
// for a vec3f attribute, but getData<float>() is valid for a vec3f attribute.
CARB_ASSERT(TypeToComponentCount<T>::count == Type(m_type).componentCount);
return *getConstData<T>();
}
template <typename T>
void BundleAttrib::set(T const& value) noexcept
{
using namespace omni::math::linalg;
using Type = omni::graph::core::Type;
CARB_ASSERT(Type(m_type).arrayDepth == 0);
// This has stronger requirements than getData, since set(1.0f) isn't valid
// for a vec3f attribute, but getData<float>() is valid for a vec3f attribute.
CARB_ASSERT(TypeToComponentCount<T>::count == Type(m_type).componentCount);
*getData<T>() = value;
}
template <typename T>
void BundleAttrib::set(T const* values, size_t elementCount) noexcept
{
using namespace omni::math::linalg;
using Type = omni::graph::core::Type;
CARB_ASSERT(Type(m_type).arrayDepth == 1);
// This has stronger requirements than getData, since set(float const*,size_t) isn't valid
// for a vec3f attribute, but getData<float>() is valid for a vec3f attribute.
CARB_ASSERT(TypeToComponentCount<T>::count == Type(m_type).componentCount);
resize(elementCount);
if (elementCount > 0)
{
T* p = getData<T>();
for (size_t i = 0; i < elementCount; ++i)
{
p[i] = values[i];
}
}
}
inline void BundleAttrib::clearContents() noexcept
{
using namespace omni::graph::core;
/**
* Remove attribute. Its metadata will be removed automatically together with it.
*/
IBundle2* bundle = getBundlePtr();
bundle->removeAttributeByName(m_name);
/**
* Invalidate data.
*/
m_source = BundleAttribSource::Attribute;
m_dirtyID = kInvalidDirtyID;
m_interpolation = carb::flatcache::kUninitializedToken;
m_type = carb::flatcache::kUnknownType;
m_name = carb::flatcache::kUninitializedToken;
m_bundlePrim = nullptr;
}
} // namespace io
} // namespace graph
} // namespace omni
| 21,248 | C | 27.483914 | 120 | 0.694324 |
omniverse-code/kit/include/omni/graph/io/IDirtyID.h | // Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#pragma message("omni/graph/io/IDirtyID.h is deprecated. Include omni/graph/core/IDirtyID.h instead.")
#define OMNI_GRAPH_IO_DEPRECATED [[deprecated("Use the counterpart in the omni::graph::core namespace instead.")]]
#include <carb/Interface.h>
#include <stddef.h>
#include <stdint.h>
namespace omni
{
namespace graph
{
namespace io
{
using DirtyIDType OMNI_GRAPH_IO_DEPRECATED = uint64_t;
OMNI_GRAPH_IO_DEPRECATED static constexpr DirtyIDType kInvalidDirtyID = ~DirtyIDType(0);
OMNI_GRAPH_IO_DEPRECATED static constexpr size_t kFunctionSize = sizeof(void (*)());
struct OMNI_GRAPH_IO_DEPRECATED IDirtyID
{
CARB_PLUGIN_INTERFACE("omni::graph::io::IDirtyID", 1, 0);
/**
* @return The next dirty ID, atomically incrementing the counter inside.
*/
DirtyIDType(CARB_ABI* getNextDirtyID)() = nullptr;
};
// Update this every time a new ABI function is added, to ensure one isn't accidentally added in the middle
static_assert(offsetof(IDirtyID, getNextDirtyID) == 0 * kFunctionSize,
"New IDirtyID ABI methods must be added at the end");
// DEPRECATED, BundlePrims class caches iDirtyID interface internally
// This must be instantiated in every extension that uses it, similar to Token::iToken.
// The exact location doesn't matter too much, though the PluginInterface.cpp is probably the best option.
OMNI_GRAPH_IO_DEPRECATED extern const IDirtyID* iDirtyID;
template <typename PREVIOUS_T>
OMNI_GRAPH_IO_DEPRECATED inline bool checkDirtyIDChanged(PREVIOUS_T& previousID, DirtyIDType newID)
{
if (newID != previousID)
{
previousID = newID;
return true;
}
// Equal, but if they're invalid, still treat them as changed
return (newID == kInvalidDirtyID);
}
}
}
}
| 2,187 | C | 33.187499 | 114 | 0.745313 |
omniverse-code/kit/include/omni/graph/io/BundlePrimsImpl.h | // Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "BundlePrims.h"
namespace omni
{
namespace graph
{
namespace io
{
// ====================================================================================================
//
// Bundle Attribute
//
// Because entire Bundle Prims is inlined, we have to put definition of those functions
// after declaration of ConstBundlePrim and ConstBundlePrims.
// ====================================================================================================
inline BundleAttrib::BundleAttrib(ConstBundlePrim& prim, omni::graph::core::NameToken name) noexcept
{
using namespace omni::graph::core;
// Get attribute handle and attribute properties
IConstBundle2* bundle = prim.getConstBundlePtr();
ConstAttributeDataHandle attributeHandle = bundle->getConstAttributeByName(name);
if(!attributeHandle.isValid())
{
return;
}
GraphContextObj const& context = prim.getConstBundlePrims()->context();
m_bundlePrim = &prim;
m_name = name;
m_type = carb::flatcache::TypeC(context.iAttributeData->getType(context, attributeHandle));
// Read attribute properties.
ConstAttributeDataHandle propertyAttributeHandle;
propertyAttributeHandle =
bundle->getConstAttributeMetadataByName(name, detail::getAttrInterpolationDefinition().token);
if(propertyAttributeHandle.isValid())
{
m_interpolation = *getDataR<NameToken>(context, propertyAttributeHandle);
}
propertyAttributeHandle =
bundle->getConstAttributeMetadataByName(name, detail::getAttrDirtyIdDefinition().token);
if(propertyAttributeHandle.isValid())
{
m_dirtyID = *getDataR<DirtyIDType>(context, propertyAttributeHandle);
}
propertyAttributeHandle =
bundle->getConstAttributeMetadataByName(name, detail::getAttrSourceDefinition().token);
if(propertyAttributeHandle.isValid())
{
m_source = static_cast<Source>(*getDataR<SourceType>(context, propertyAttributeHandle));
}
}
inline BundleAttrib::BundleAttrib(BundlePrim& prim, omni::graph::core::NameToken name, omni::graph::core::Type type, size_t arrayElementCount, Source source) noexcept
: BundleAttrib{ prim, name }
{
using namespace omni::graph::core;
// Attribute exists!
if (m_bundlePrim)
{
return;
}
// Attribute does not exist.
IBundle2* bundle = prim.getBundlePtr();
GraphContextObj const& context = prim.getConstBundlePrims()->context();
auto handle = bundle->createAttribute(name, type, arrayElementCount);
omni::graph::core::getDataW<void*>(context, handle); // remove after OM-50059 is merged.
m_bundlePrim = &prim;
m_name = name;
m_type = carb::flatcache::TypeC(type);
// Interpolation is optional.
// DirtyId is a unique id that tracks if attribute has changed.
setDirtyID(prim.getConstBundlePrims()->getNextDirtyID());
// Source of the attribute identifies "data" or "relationship"
setSource(source);
}
inline BundlePrim* BundleAttrib::getBundlePrim() noexcept
{
IConstBundle2* constBundle = getConstBundlePtr();
if(auto bundle = omni::cast<IBundle2>(constBundle))
{
return static_cast<BundlePrim*>(m_bundlePrim);
}
return nullptr;
}
inline omni::graph::core::IConstBundle2* BundleAttrib::getConstBundlePtr() const noexcept
{
ConstBundlePrim* bundlePrim = getBundlePrim();
return bundlePrim->getConstBundlePtr();
}
inline omni::graph::core::IBundle2* BundleAttrib::getBundlePtr() noexcept
{
BundlePrim* bundlePrim = getBundlePrim();
return bundlePrim->getBundlePtr();
}
inline bool BundleAttrib::bumpDirtyID() noexcept
{
BundlePrim* bundlePrim = getBundlePrim();
bundlePrim->bumpDirtyID();
DirtyIDType nextId = bundlePrim->getConstBundlePrims()->getNextDirtyID();
return setDirtyID(nextId);
}
// ====================================================================================================
//
// Bundle Primitive
//
// ====================================================================================================
inline BundlePrim::BundlePrim(BundlePrims& bundlePrims, BundlePrimIndex primIndex, omni::core::ObjectPtr<omni::graph::core::IBundle2> bundle)
: ConstBundlePrim{ bundlePrims, primIndex, std::move(bundle) }
{
}
inline void BundlePrim::setPath(omni::graph::core::NameToken path) noexcept
{
using namespace omni::graph::core;
BundlePrims* bundlePrims = getBundlePrims();
NameToken* primPaths = bundlePrims->addPrimPathsIfMissing();
primPaths[primIndex()] = path;
}
inline void BundlePrim::setType(omni::graph::core::NameToken type) noexcept
{
using namespace omni::graph::core;
BundlePrims* bundlePrims = getBundlePrims();
NameToken* primTypes = bundlePrims->addPrimTypesIfMissing();
primTypes[primIndex()] = type;
}
inline void BundlePrim::setDirtyID(DirtyIDType dirtyID) noexcept
{
auto primDirtyIDs = getBundlePrims()->getPrimDirtyIDs();
primDirtyIDs[m_primIndex] = dirtyID;
}
inline void BundlePrim::bumpDirtyID() noexcept
{
if (isCommonAttrs())
{
BundlePrims* bundlePrims = getBundlePrims();
bundlePrims->bumpBundleDirtyID();
}
else
{
DirtyIDType nextId = getBundlePrims()->getNextDirtyID();
setDirtyID(nextId);
}
}
inline BundleAttrib* BundlePrim::addAttr(omni::graph::core::NameToken attrName,
omni::graph::core::Type type,
size_t arrayElementCount,
BundleAttribSource source) noexcept
{
using namespace omni::graph::core;
auto& attrs = getAttributes();
// Erase existing attribute.
auto it = attrs.find(attrName);
if (it != attrs.end())
{
it->second->clearContents();
attrs.erase(it);
}
auto attr = new BundleAttrib{ *this, attrName, type, arrayElementCount, source };
attrs.emplace(attrName, attr);
return attr;
}
inline BundleAttrib* BundlePrim::addRelationship(omni::graph::core::NameToken name, size_t targetCount) noexcept
{
return addAttr(name, detail::s_relationshipType, targetCount, BundleAttribSource::Relationship);
}
inline bool BundlePrim::addAttrs(std::vector<BundlePrim::AddAttrInfo> const& attrList) noexcept
{
using namespace omni::graph::core;
IBundle2* bundle = getBundlePtr();
auto& attrs = getAttributes();
// Remove attributes that exists but properties are different.
std::vector<BundlePrim::AddAttrInfo> attrToCreate;
attrToCreate.reserve(attrList.size());
for (auto const& newAttr : attrList) {
auto it = attrs.find(newAttr.attrName);
if (it == attrs.end())
{
attrToCreate.push_back(newAttr);
continue;
}
BundleAttrib const* attr = it->second.get();
if (attr->type() != newAttr.type ||
attr->size() != newAttr.arrayElementCount ||
attr->source() != newAttr.source)
{
it->second->clearContents();
attrs.erase(it);
attrToCreate.push_back(newAttr);
}
// attribute is the same nothing to do.
}
// Create attributes that require instantiation.
for (auto const& tmp : attrToCreate)
{
auto attr = new BundleAttrib{ *this, tmp.attrName, tmp.type, tmp.arrayElementCount, tmp.source };
attrs.emplace(tmp.attrName, attr);
}
return true;
}
inline void BundlePrim::removeAttr(omni::graph::core::NameToken attrName) noexcept
{
using namespace omni::graph::core;
// Remove attribute from internal member.
auto& attrs = getAttributes();
auto it = attrs.find(attrName);
if (it != attrs.end())
{
it->second->clearContents();
attrs.erase(it);
}
}
inline void BundlePrim::clearContents() noexcept
{
using namespace omni::graph::core;
auto& attrs = getAttributes();
for (auto& attr : attrs)
{
attr.second->clearContents();
}
getAttributes().clear();
}
inline void BundlePrim::copyContentsFrom(ConstBundlePrim const& source, bool removeAttrsNotInSource /* = true*/) noexcept
{
return copyContentsFrom(const_cast<ConstBundlePrim&>(source), removeAttrsNotInSource);
}
inline void BundlePrim::copyContentsFrom(ConstBundlePrim& source, bool removeAttrsNotInSource /* = true*/) noexcept
{
using namespace omni::graph::core;
// Nothing to do if they're already equal.
if (dirtyID() == source.dirtyID())
return;
BundlePrims* bundlePrims = getBundlePrims();
// Add/set any attributes from source, if the dirty IDs are different, being sure to copy the dirty IDs.
// first we batch add them, then we copy the contents
std::vector<BundlePrim::AddAttrInfo> attrsToAdd;
attrsToAdd.reserve(source.attrCount());
for (auto const& sourceAttr : source)
{
NameToken name = sourceAttr.name();
// NOTE: Request a const attribute, to avoid bumping its dirty ID.
BundleAttrib const* constDestAttr = getConstAttr(name);
if (constDestAttr != nullptr && constDestAttr->dirtyID() == sourceAttr.dirtyID())
{
continue;
}
if (constDestAttr == nullptr)
{
attrsToAdd.push_back(
{ sourceAttr.m_name, Type(carb::flatcache::TypeC{ sourceAttr.m_type }), 0, sourceAttr.m_source });
}
}
// add the attributes
addAttrs(attrsToAdd);
// copy the data
for (auto const& sourceAttr : source)
{
NameToken name = sourceAttr.name();
// NOTE: Request a const attribute, to avoid bumping its dirty ID.
BundleAttrib const* constDestAttr = getConstAttr(name);
CARB_ASSERT(constDestAttr != nullptr);
if (constDestAttr == nullptr || constDestAttr->dirtyID() == sourceAttr.dirtyID())
{
continue;
}
const_cast<BundleAttrib*>(constDestAttr)->copyContentsFrom(sourceAttr);
}
CARB_ASSERT(attrCount() >= source.attrCount());
// If there are more attributes in this than in source, remove any that aren't in source.
auto& attrMap = getAttributes();
if (attrCount() > source.attrCount() && removeAttrsNotInSource)
{
std::vector<NameToken> attrsToRemove;
for (auto it = attrMap.begin(); it != attrMap.end();)
{
if (source.getConstAttr(it->second->name()) == nullptr)
{
it->second->clearContents();
it = attrMap.erase(it);
}
else
{
++it;
}
}
}
}
inline BundleAttrib* BundlePrim::getAttr(omni::graph::core::NameToken attrName) noexcept
{
auto& attrs = getAttributes();
auto it = attrs.find(attrName);
if (it == attrs.end())
{
return nullptr;
}
BundleAttrib* attr = it->second.get();
// TODO: Consider whether it's worth bumping the dirty ID later, when modification occurs.
attr->bumpDirtyID();
return attr;
}
inline omni::graph::core::BundleHandle BundlePrim::handle() noexcept
{
return getBundlePtr()->getHandle();
}
inline BundlePrims* BundlePrim::getBundlePrims() noexcept
{
omni::graph::core::IBundle2* bundle = getBundlePtr();
if (bundle)
{
ConstBundlePrims* bundlePrims = ConstBundlePrim::getConstBundlePrims();
return static_cast<BundlePrims*>(bundlePrims);
}
return nullptr;
}
inline BundlePrims* BundlePrim::bundlePrims() noexcept
{
return getBundlePrims();
}
inline BundlePrimAttrIterator BundlePrim::begin() noexcept
{
return BundlePrimAttrIterator(*this, getAttributes().begin());
}
inline BundlePrimAttrIterator BundlePrim::end() noexcept
{
return BundlePrimAttrIterator(*this, getAttributes().end());
}
inline ConstBundlePrimAttrIterator BundlePrim::cbegin() noexcept
{
return ConstBundlePrim::begin();
}
inline ConstBundlePrimAttrIterator BundlePrim::cend() noexcept
{
return ConstBundlePrim::end();
}
inline omni::graph::core::IBundle2* BundlePrim::getBundlePtr(omni::graph::core::IConstBundle2* constBundle) noexcept
{
auto bundle = omni::cast<omni::graph::core::IBundle2>(constBundle);
return bundle.get();
}
inline omni::graph::core::IBundle2* BundlePrim::getBundlePtr() noexcept
{
using namespace omni::graph::core;
IConstBundle2* constBundle = getConstBundlePtr();
IBundle2* bundle = getBundlePtr(constBundle);
return bundle;
}
// ====================================================================================================
//
// Bundle Primitives
//
// ====================================================================================================
inline BundlePrims::~BundlePrims() noexcept
{
detach();
}
inline omni::graph::core::BundleHandle BundlePrims::handle() noexcept
{
using namespace omni::graph::core;
if (IBundle2* bundle = getBundlePtr())
{
return bundle->getHandle();
}
return BundleHandle{ BundleHandle::invalidValue() };
}
inline void BundlePrims::ensurePrimAttrsCached(BundlePrimIndex primIndex) noexcept
{
}
inline BundlePrims::BundlePrims()
: ConstBundlePrims()
{
}
inline BundlePrims::BundlePrims(omni::graph::core::GraphContextObj const& context,
omni::graph::core::BundleHandle const& bundle)
: BundlePrims()
{
attach(context, bundle);
}
inline void BundlePrims::attach(omni::graph::core::GraphContextObj const& context,
omni::graph::core::BundleHandle const& bundleHandle) noexcept
{
using namespace omni::graph::core;
ComputeGraph* computeGraph = carb::getCachedInterface<ComputeGraph>();
omni::core::ObjectPtr<IBundleFactory> factoryPtr = computeGraph->getBundleFactoryInterfacePtr();
omni::core::ObjectPtr<IBundle2> bundlePtr = factoryPtr->getBundle(context, bundleHandle);
ConstBundlePrims::attach(std::move(factoryPtr), std::move(bundlePtr));
IBundle2* bundle = getBundlePtr();
//
// Bundle Level Attributes
//
auto& bundleDirtyIDDef = detail::getBundleDirtyIDDefinition();
if (!m_bundleDirtyIDAttr.isValid())
{
m_bundleDirtyIDAttr = bundle->createBundleMetadata(bundleDirtyIDDef.token, bundleDirtyIDDef.type);
DirtyIDType newBundleDirtyID = getNextDirtyID();
setBundleDirtyID(newBundleDirtyID);
*getDataW<DirtyIDType>(context, m_bundleDirtyIDAttr) = newBundleDirtyID;
}
else
{
setBundleDirtyID(*getDataR<DirtyIDType>(context, m_bundleDirtyIDAttr));
}
auto& primDirtyIDsDef = detail::getPrimDirtyIDsDefinition();
m_primDirtyIDsAttr = bundle->getBundleMetadataByName(primDirtyIDsDef.token);
if(!m_primDirtyIDsAttr.isValid())
{
m_primDirtyIDsAttr = bundle->createBundleMetadata(primDirtyIDsDef.token, primDirtyIDsDef.type, 0);
setPrimDirtyIDsData(*getDataW<DirtyIDType*>(context, m_primDirtyIDsAttr));
}
auto& primPathsDef = detail::getPrimPathsDefinition();
m_primPathsAttr = bundle->getBundleMetadataByName(primPathsDef.token);
auto& primTypesDef = detail::getPrimTypesDefinition();
m_primTypesAttr = bundle->getBundleMetadataByName(primTypesDef.token);
auto& primIndexDef = detail::getPrimIndexDefinition();
m_primIndexAttr = bundle->getBundleMetadataByName(primIndexDef.token);
}
inline void BundlePrims::detach() noexcept
{
using omni::graph::core::AttributeDataHandle;
if(m_bundleDirtyIDAttr.isValid())
{
auto& context = this->context();
// Assume that the bundle has changed, given that this is a non-const bundle wrapper.
*getDataW<DirtyIDType>(context, m_bundleDirtyIDAttr) = getNextDirtyID();
m_bundleDirtyIDAttr = AttributeDataHandle{ AttributeDataHandle::invalidValue() };
}
m_primDirtyIDsAttr = AttributeDataHandle{ AttributeDataHandle::invalidValue() };
m_primIndexAttr = AttributeDataHandle{ AttributeDataHandle::invalidValue() };
m_primTypesAttr = AttributeDataHandle{ AttributeDataHandle::invalidValue() };
m_primPathsAttr = AttributeDataHandle{ AttributeDataHandle::invalidValue() };
ConstBundlePrims::detach();
}
inline BundlePrim* BundlePrims::getPrim(BundlePrimIndex primIndex) noexcept
{
using namespace omni::graph::core;
auto createBundlePrim = [this, &bundlePrims = *this, &primIndex]() -> BundlePrim*
{
BundleHandle bundleHandle = getBundlePtr()->getChildBundle(primIndex);
if (!bundleHandle.isValid())
{
return nullptr;
}
omni::core::ObjectPtr<IBundle2> childBundle = getBundleFactoryPtr()->getBundle(context(), bundleHandle);
if (!childBundle)
{
return nullptr;
}
return new BundlePrim{ bundlePrims, primIndex, childBundle };
};
// Since we acquire BundlePrim instance through BundlePrims interface,
// we are required to bump dirty id of this prim because intention is to modify it.
auto bundlePrim = static_cast<BundlePrim*>(ConstBundlePrims::getConstPrim(primIndex, createBundlePrim));
bundlePrim->bumpDirtyID();
return bundlePrim;
}
inline BundlePrim* BundlePrims::getClearedPrim(BundlePrimIndex primIndex) noexcept
{
BundlePrim* bundlePrim = getPrim(primIndex);
if(!bundlePrim)
{
return nullptr;
}
bundlePrim->clearContents();
return bundlePrim;
}
inline omni::graph::core::NameToken* BundlePrims::addPrimPathsIfMissing() noexcept
{
using namespace omni::graph::core;
// check if prims are valid size
if (m_primPathsAttr.isValid())
{
return getPrimPaths();
}
// Create a new primPaths attribute.
IBundle2* bundle = getBundlePtr();
auto& primPathsDef = detail::getPrimPathsDefinition();
size_t const primCount = getPrimCount();
m_primPathsAttr = bundle->createBundleMetadata(primPathsDef.token, primPathsDef.type, primCount);
NameToken* primPaths = *getDataW<NameToken*>(context(), m_primPathsAttr);
for(size_t i = 0; i < primCount; ++i)
{
primPaths[i] = carb::flatcache::kUninitializedToken;
}
setPrimPathsData(primPaths);
return primPaths;
}
inline omni::graph::core::NameToken* BundlePrims::addPrimTypesIfMissing() noexcept
{
using namespace omni::graph::core;
if(m_primTypesAttr.isValid())
{
return getPrimTypes();
}
// Create a new primTypes attribute.
IBundle2* bundle = getBundlePtr();
auto& primTypesDef = detail::getPrimTypesDefinition();
size_t const primCount = getPrimCount();
m_primTypesAttr = bundle->createBundleMetadata(primTypesDef.token, primTypesDef.type, primCount);
NameToken* primTypes = *getDataW<NameToken*>(context(), m_primTypesAttr);
for(size_t i = 0; i < primCount; ++i)
{
primTypes[i] = carb::flatcache::kUninitializedToken;
}
setPrimTypesData(primTypes);
return primTypes;
}
inline BundlePrim& BundlePrims::getCommonAttrs() noexcept
{
ConstBundlePrim& commonAttributes = ConstBundlePrims::getConstCommonAttrs();
return static_cast<BundlePrim&>(commonAttributes);
}
inline omni::graph::core::IBundle2* BundlePrims::getBundlePtr() noexcept
{
using namespace omni::graph::core;
auto constBundle = getConstBundlePtr();
auto bundle = omni::cast<IBundle2>(constBundle);
return bundle.get();
}
inline uint64_t BundlePrims::bumpBundleDirtyID() noexcept
{
if (m_bundleDirtyIDAttr.isValid())
{
auto& context = this->context();
DirtyIDType dirtyID = getNextDirtyID();
*getDataW<DirtyIDType>(context, m_bundleDirtyIDAttr) = dirtyID;
return dirtyID;
}
return kInvalidDirtyID;
}
inline void BundlePrims::clearContents() noexcept
{
for (BundlePrimIndex primIndex = getPrimCount(); primIndex != 0;)
{
--primIndex;
removePrim(primIndex);
}
// Delete all attributes from this bundle.
BundlePrim& thisBundle = getCommonAttrs();
thisBundle.clearContents();
// remove internal data
IBundle2* bundle = getBundlePtr();
using omni::graph::core::AttributeDataHandle;
// Clearing bundle prims internal attributes such as bundleDirtyID and others causes downstream problems.
// Initial implementation never cleared those attributes.
#if 0
auto bundlePrimsInternalAttributes = {
std::ref(m_bundleDirtyIDAttr), //
std::ref(m_primDirtyIDsAttr), //
std::ref(m_primPathsAttr), //
std::ref(m_primTypesAttr), //
std::ref(m_primIndexAttr), //
};
for (auto& internalAttribute : bundlePrimsInternalAttributes)
{
if (internalAttribute.get().isValid())
{
bundle->removeAttribute(internalAttribute.get());
}
internalAttribute.get() = AttributeDataHandle{ AttributeDataHandle::invalidValue() };
}
#endif
}
inline bool BundlePrims::removePrim(ConstBundlePrim* prim) noexcept
{
return removePrim(prim->primIndex());
}
inline bool BundlePrims::removePrim(BundlePrimIndex primIndex) noexcept
{
using namespace omni::graph::core;
IBundle2* bundle = getBundlePtr();
auto& context = this->context();
auto& prims = getPrimitives();
// remove children and attributes
BundlePrim* childBundlePrim = getPrim(primIndex);
if (!childBundlePrim)
{
return false;
}
// clear contents and remove bundle from a map
childBundlePrim->clearContents();
bundle->removeChildBundle(childBundlePrim->handle());
// If removed primitive is not the last one,
// swap last one with removed one and update index.
size_t const newPrimCount = prims.size() - 1;
if (primIndex != newPrimCount)
{
prims[primIndex] = std::move(prims[newPrimCount]);
prims[primIndex]->m_primIndex = primIndex;
}
prims.resize(newPrimCount);
// Update contents of array attributes
if (primIndex != newPrimCount)
{
auto primDirtyIDs = getPrimDirtyIDs();
primDirtyIDs[primIndex] = primDirtyIDs[newPrimCount];
auto primPaths = getPrimPaths();
if (primPaths != nullptr)
{
primPaths[primIndex] = primPaths[newPrimCount];
}
auto primTypes = getPrimTypes();
if (primTypes != nullptr)
{
primTypes[primIndex] = primTypes[newPrimCount];
}
}
// Reduce element counts of underlying attributes and update the pointers in case they've changed.
context.iAttributeData->setElementCount(context, m_primDirtyIDsAttr, newPrimCount);
setPrimDirtyIDsData(*getDataW<DirtyIDType*>(context, m_primDirtyIDsAttr));
if (m_primPathsAttr.isValid())
{
context.iAttributeData->setElementCount(context, m_primPathsAttr, newPrimCount);
setPrimPathsData(*getDataW<NameToken*>(context, m_primPathsAttr));
}
if (m_primTypesAttr.isValid())
{
context.iAttributeData->setElementCount(context, m_primTypesAttr, newPrimCount);
setPrimTypesData(*getDataW<NameToken*>(context, m_primTypesAttr));
}
return true;
}
inline size_t BundlePrims::addPrims(size_t primCountToAdd) noexcept
{
using namespace omni::graph::core;
size_t oldPrimCount = getConstBundlePtr()->getChildBundleCount();
if (primCountToAdd == 0)
{
return oldPrimCount;
}
size_t const newPrimCount = oldPrimCount + primCountToAdd;
CARB_ASSERT(newPrimCount > oldPrimCount);
IBundle2* bundle = getBundlePtr();
IBundleFactory* factory = getBundleFactoryPtr();
auto& context = this->context();
// Create primIndex that stores last index of the primitive.
if(!m_primIndexAttr.isValid())
{
auto& primIndexDef = detail::getPrimIndexDefinition();
m_primIndexAttr = bundle->getBundleMetadataByName(primIndexDef.token);
if(!m_primIndexAttr.isValid())
{
m_primIndexAttr = bundle->createBundleMetadata(primIndexDef.token, primIndexDef.type);
*getDataW<uint64_t>(context, m_primIndexAttr) = 0;
}
}
uint64_t* primIndexData = getDataW<uint64_t>(context, m_primIndexAttr);
// Create new child bundles.
// All children are called 'prim' + primIndex, because IBundle2 interface does not allow sparse hierarchy.
// Then child paths are stored as an attribute.
BundlePrimArray& prims = getPrimitives();
prims.resize(newPrimCount);
std::string primPathStr;
for (BundlePrimIndex primIndex = oldPrimCount; primIndex < newPrimCount; ++primIndex)
{
primPathStr = "prim" + std::to_string(*primIndexData + primIndex);
NameToken primName = context.iToken->getHandle(primPathStr.data());
BundleHandle childHandle = bundle->createChildBundle(primName);
auto childBundle = factory->getBundle(context, childHandle);
prims[primIndex].reset(new BundlePrim(*this, primIndex, std::move(childBundle)));
}
// Update primDirtyIDs.
if(m_primDirtyIDsAttr.isValid())
{
context.iAttributeData->setElementCount(context, m_primDirtyIDsAttr, newPrimCount);
}
else
{
auto& primDirtyIDsDef = detail::getPrimDirtyIDsDefinition();
m_primDirtyIDsAttr = bundle->createBundleMetadata(primDirtyIDsDef.token, primDirtyIDsDef.type, newPrimCount);
}
setPrimDirtyIDsData(*getDataW<DirtyIDType*>(context, m_primDirtyIDsAttr));
auto primDirtyIDs = getPrimDirtyIDs();
for (BundlePrimIndex i = oldPrimCount; i < newPrimCount; ++i)
{
primDirtyIDs[i] = getNextDirtyID();
}
// Update primPaths.
if(m_primPathsAttr.isValid())
{
context.iAttributeData->setElementCount(context, m_primPathsAttr, newPrimCount);
NameToken* primPathsData = *getDataW<NameToken*>(context, m_primPathsAttr);
for (BundlePrimIndex primIndex = oldPrimCount; primIndex < newPrimCount; ++primIndex)
{
primPathsData[primIndex] = carb::flatcache::kUninitializedToken;
}
setPrimPathsData(primPathsData);
}
// Update primTypes.
if(m_primTypesAttr.isValid())
{
context.iAttributeData->setElementCount(context, m_primTypesAttr, newPrimCount);
NameToken* primTypesData = *getDataW<NameToken*>(context, m_primTypesAttr);
for(BundlePrimIndex primIndex = oldPrimCount; primIndex < newPrimCount; ++primIndex)
{
primTypesData[primIndex] = carb::flatcache::kUninitializedToken;
}
setPrimTypesData(primTypesData);
}
*primIndexData += primCountToAdd; // Update prim index offset.
return oldPrimCount;
}
inline DirtyIDType* BundlePrims::getPrimDirtyIDs() noexcept
{
return const_cast<DirtyIDType*>(ConstBundlePrims::getPrimDirtyIDs());
}
inline omni::graph::core::NameToken* BundlePrims::getPrimTypes() noexcept
{
return const_cast<omni::graph::core::NameToken*>(ConstBundlePrims::getConstPrimTypes());
}
inline omni::graph::core::NameToken* BundlePrims::getPrimPaths() noexcept
{
return const_cast<omni::graph::core::NameToken*>(ConstBundlePrims::getConstPrimPaths());
}
inline BundlePrimIterator BundlePrims::begin() noexcept
{
return BundlePrimIterator(*this);
}
inline BundlePrimIterator BundlePrims::end() noexcept
{
return BundlePrimIterator(*this, getPrimCount());
}
inline ConstBundlePrimIterator BundlePrims::cbegin() noexcept
{
return ConstBundlePrims::begin();
}
inline ConstBundlePrimIterator BundlePrims::cend() noexcept
{
return ConstBundlePrims::end();
}
// ====================================================================================================
//
// Bundle Primitive Iterator
//
// ====================================================================================================
inline BundlePrimIterator::BundlePrimIterator(BundlePrims& bundlePrims, BundlePrimIndex primIndex) noexcept
: m_bundlePrims(&bundlePrims), m_primIndex(primIndex)
{
}
inline bool BundlePrimIterator::operator==(BundlePrimIterator const& that) const noexcept
{
return m_bundlePrims == that.m_bundlePrims && m_primIndex == that.m_primIndex;
}
inline bool BundlePrimIterator::operator!=(BundlePrimIterator const& that) const noexcept
{
return !(*this == that);
}
inline BundlePrim& BundlePrimIterator::operator*() noexcept
{
return *(m_bundlePrims->getPrim(m_primIndex));
}
inline BundlePrim* BundlePrimIterator::operator->() noexcept
{
return m_bundlePrims->getPrim(m_primIndex);
}
inline BundlePrimIterator& BundlePrimIterator::operator++() noexcept
{
++m_primIndex;
return *this;
}
// ====================================================================================================
//
// Bundle Primitive Attribute Iterator
//
// ====================================================================================================
inline BundlePrimAttrIterator::BundlePrimAttrIterator(BundlePrim& bundlePrim, BundlePrim::AttrMapIteratorType attrIter) noexcept
: m_bundlePrim(&bundlePrim), m_attrIter(attrIter)
{
}
inline bool BundlePrimAttrIterator::operator==(BundlePrimAttrIterator const& that) const noexcept
{
return m_bundlePrim == that.m_bundlePrim && m_attrIter == that.m_attrIter;
}
inline bool BundlePrimAttrIterator::operator!=(BundlePrimAttrIterator const& that) const noexcept
{
return !(*this == that);
}
inline BundleAttrib const* BundlePrimAttrIterator::getConst() noexcept
{
CARB_ASSERT(m_bundlePrim != nullptr);
CARB_ASSERT(m_attrIter->second);
BundleAttrib* attr = m_attrIter->second.get();
// NOTE: Does not bump the dirty ID, since this is const.
return attr;
}
inline BundleAttrib& BundlePrimAttrIterator::operator*() noexcept
{
CARB_ASSERT(m_bundlePrim != nullptr);
CARB_ASSERT(m_attrIter->second);
BundleAttrib* attr = m_attrIter->second.get();
// TODO: Consider bumping the dirty ID later, when modification occurs.
attr->bumpDirtyID();
return *attr;
}
inline BundleAttrib* BundlePrimAttrIterator::operator->() noexcept
{
CARB_ASSERT(m_bundlePrim != nullptr);
CARB_ASSERT(m_attrIter->second);
BundleAttrib* attr = m_attrIter->second.get();
// TODO: Consider bumping the dirty ID later, when modification occurs.
attr->bumpDirtyID();
return attr;
}
inline BundlePrimAttrIterator& BundlePrimAttrIterator::operator++() noexcept
{
++m_attrIter;
return *this;
}
} // namespace io
} // namespace graph
} // namespace omni
| 31,032 | C | 30.601833 | 166 | 0.659029 |
omniverse-code/kit/include/omni/graph/io/ConstBundlePrims.h | // Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#pragma message("omni/graph/io/ConstBundlePrims.h is deprecated. Include omni/graph/core/ConstBundlePrims.h instead.")
// ====================================================================================================
/* _____ _ _ _ _ _
| __ \ | \ | | | | | | | |
| | | | ___ | \| | ___ | |_ | | | |___ ___
| | | |/ _ \ | . ` |/ _ \| __| | | | / __|/ _ \
| |__| | (_) | | |\ | (_) | |_ | |__| \__ \ __/
|_____/ \___/ |_| \_|\___/ \__| \____/|___/\___|
This is a temporary interface that can change at any time.
*/
// ====================================================================================================
#include "BundleAttrib.h"
#include <omni/graph/core/IBundleFactory.h>
#include <unordered_map>
#include <memory>
#include <vector>
namespace omni
{
namespace graph
{
namespace io
{
class ConstBundlePrims;
class ConstBundlePrimIterator;
class ConstBundlePrimAttrIterator;
/**
* Index used to identify primitives in a bundle.
*/
using BundlePrimIndex OMNI_GRAPH_IO_DEPRECATED = size_t;
OMNI_GRAPH_IO_DEPRECATED constexpr BundlePrimIndex kInvalidBundlePrimIndex = ~BundlePrimIndex(0);
/**
* Collection of read-only attributes in a primitive.
*
* Const Bundle Primitive is not movable, not copyable. It lifespan is managed by Const Bundle Primitives.
*/
class OMNI_GRAPH_IO_DEPRECATED ConstBundlePrim
{
public:
using BundleAttributeMap = std::unordered_map<omni::graph::core::NameToken, std::unique_ptr<BundleAttrib>>;
using AttrMapIteratorType = BundleAttributeMap::const_iterator;
ConstBundlePrim(ConstBundlePrim const&) = delete;
ConstBundlePrim(ConstBundlePrim&&) = delete;
ConstBundlePrim& operator=(ConstBundlePrim const& that) = delete;
ConstBundlePrim& operator=(ConstBundlePrim&&) = delete;
/**
* @return Parent bundle prims of this primitive.
*/
ConstBundlePrims* getConstBundlePrims() noexcept;
/**
* @return Number of attributes in this primitive. Does not include internal attributes.
*/
size_t attrCount() noexcept;
/**
* @return PrimAttribute if attribute with given name is found, nullptr otherwise.
*/
BundleAttrib const* getConstAttr(omni::graph::core::NameToken attrName) noexcept;
/**
* @return Index of this primitive in parent bundle.
*/
BundlePrimIndex primIndex() noexcept;
/**
* @return Path of this primitive.
*/
omni::graph::core::NameToken path() noexcept;
/**
* @return Type of this primitive.
*/
omni::graph::core::NameToken type() noexcept;
/**
* @return Dirty id value of this primitive.
*/
DirtyIDType dirtyID() noexcept;
/**
* @return Attribute iterator pointing to the first attribute in this bundle.
*/
ConstBundlePrimAttrIterator begin() noexcept;
/**
* @return Attribute iterator pointing to the last attribute in this bundle.
*/
ConstBundlePrimAttrIterator end() noexcept;
/***********************************************************************************************
*
* TODO: Following methods might be deprecated in the future.
* In the next iteration when real interface starts to emerge, we can retire those methods.
*
***********************************************************************************************/
/**
* @deprecated Do not use!. Use getConstAttr().
*/
[[deprecated("Use non const instead.")]]
BundleAttrib const* getAttr(omni::graph::core::NameToken attrName) const noexcept;
/**
* @deprecated Do not use!. Use non-const variant of path().
*/
[[deprecated("Use non const instead.")]]
omni::graph::core::NameToken path() const noexcept;
/**
* @deprecated Do not use!. Use non-const variant of type().
*/
[[deprecated("Use non const instead.")]]
omni::graph::core::NameToken type() const noexcept;
/**
* @deprecated Do not use!. Use non-const variant of dirtyID().
*/
[[deprecated("Use non const instead.")]]
DirtyIDType dirtyID() const noexcept;
/**
* @deprecated Do not use!. Use non-const variant of begin().
*/
[[deprecated("Use non const instead.")]]
ConstBundlePrimAttrIterator begin() const noexcept;
/**
* @deprecated Do not use!. Use non-const variant of end().
*/
[[deprecated("Use non const instead.")]]
ConstBundlePrimAttrIterator end() const noexcept;
protected:
/**
* Direct initialization with IConstBundle interface.
*
* ConstBundlePrim and BundlePrim take advantage of polymorphic relationship
* between IConstBundle and IBundle interfaces.
* In order to modify bundles, BundlePrim makes attempt to down cast IConstBundle
* to IBundle interface. When this process is successful then, bundle can be modified.
*
* Only ConstBundlePrims is allowed to create instances of ConstBundlePrim.
*/
ConstBundlePrim(ConstBundlePrims& bundlePrims,
BundlePrimIndex primIndex,
omni::core::ObjectPtr<omni::graph::core::IConstBundle2> bundle);
/**
* @return IConstBundle interface for this bundle primitive.
*/
omni::graph::core::IConstBundle2* getConstBundlePtr() noexcept;
/**
* @return Get attribute used by ConstBundlePrims and BundlePrims.
*/
BundleAttributeMap& getAttributes() noexcept;
/**
* Reads public attributes from the bundle and caches them as BundleAttribs.
*/
void readAndCacheAttributes() noexcept;
private:
ConstBundlePrims* m_bundlePrims{ nullptr }; // Parent of this bundle prim.
omni::core::ObjectPtr<omni::graph::core::IConstBundle2> m_bundle;
BundlePrimIndex m_primIndex{ kInvalidBundlePrimIndex }; // Index of a child bundle of this primitive.
DirtyIDType m_dirtyId{ kInvalidDirtyID };
BundleAttributeMap m_attributes; // Cached public attributes that belong to this primitive.
friend class BundleAttrib; // Required to access IConstBundle interface.
friend class BundlePrim; // Required to access primitive type.
friend class BundlePrims; // Required to update internal indices.
friend class ConstBundlePrims; // Required to call constructor.
};
/**
* Collection of read-only primitives in a bundle.
*
* Const Bundle Primitives is not movable, not copyable. It lifespan is managed by the user.
*/
class OMNI_GRAPH_IO_DEPRECATED ConstBundlePrims
{
public:
ConstBundlePrims();
ConstBundlePrims(omni::graph::core::GraphContextObj const& context,
omni::graph::core::ConstBundleHandle const& bundle);
ConstBundlePrims(ConstBundlePrims const&) = delete;
ConstBundlePrims(ConstBundlePrims&&) = delete;
ConstBundlePrims& operator=(ConstBundlePrims const&) = delete;
ConstBundlePrims& operator=(ConstBundlePrims&&) = delete;
/**
* @return Bundle handle of this primitive.
*/
omni::graph::core::ConstBundleHandle getConstHandle() noexcept;
/**
* @return Number of primitives in this bundle of primitives.
*/
size_t getPrimCount() noexcept;
/**
* @return Get read only primitive under specified index.
*/
ConstBundlePrim* getConstPrim(BundlePrimIndex primIndex) noexcept;
/**
* @return Dirty Id of all primitives.
*/
DirtyIDType getBundleDirtyID() noexcept;
/**
* @return Bundle primitives dirty ids.
*/
DirtyIDType const* getPrimDirtyIDs() noexcept;
/**
* Paths of all primitives in this bundle.
*
* Primitive paths are lazily computed. This operation can be slow because iteration over all
* bundles is required. ConstBundlePrim access paths directly from primitives.
* Use only when necessary.
*
* @todo Paths should be represented by PathC type.
*
* @return Pointer to primitive paths array, or nullptr if there are no primitive paths.
*/
omni::graph::core::NameToken const* getConstPrimPaths() noexcept;
/**
* Get primitive types in this bundle of primitives. Once primitive is created path can not be changed.
* Primitive can be copied but not moved.
*/
omni::graph::core::NameToken const* getConstPrimTypes() noexcept;
/**
* Common Attributes are attributes that are shared for entire bundle.
* An example of a common attribute is "transform" attribute.
*
* @return ConstBundlePrims as ConstBundlePrim to access attributes.
*/
ConstBundlePrim& getConstCommonAttrs() noexcept;
/**
* @return Context where bundle primitives belongs to.
*/
omni::graph::core::GraphContextObj const& context() noexcept;
/**
* @return Primitive iterator pointing to the first primitive in this bundle.
*/
ConstBundlePrimIterator begin() noexcept;
/**
* @return Primitive iterator pointing to the last primitive in this bundle.
*/
ConstBundlePrimIterator end() noexcept;
/***********************************************************************************************
*
* TODO: Following methods might be deprecated in the future.
* In the next iteration when real interface starts to emerge, we can retire those methods.
*
***********************************************************************************************/
/**
* @deprecated Do not use! Use getConstPrim().
*/
ConstBundlePrim* getPrim(BundlePrimIndex primIndex) noexcept;
/**
* @deprecated Dirty id management is an internal state of this class and should be private.
*
* @return Next available id.
*/
DirtyIDType getNextDirtyID() noexcept;
/**
* @deprecated Use appropriate constructor and heap allocate ConstBundlePrims.
*
* @todo: There is no benefit of using this method. Cache has to be rebuild from scratch
* whenever ConstBundlePrims is attached/detached.
* It would be better to remove default constructor and enforce cache construction
* through constructor with arguments.
*/
void attach(omni::graph::core::GraphContextObj const& context,
omni::graph::core::ConstBundleHandle const& bundle) noexcept;
/**
* @deprecated Use appropriate constructor and heap allocate ConstBundlePrims.
*/
void detach() noexcept;
/**
* @deprecated Use getConstHandle.
*/
omni::graph::core::ConstBundleHandle handle() noexcept;
/**
* @deprecated Use getConstPrimPaths.
*/
omni::graph::core::NameToken const* getPrimPaths() noexcept;
/**
* @deprecated Use getConstCommonAttrs.
*/
ConstBundlePrim& getCommonAttrs() noexcept;
/**
* @deprecated There is no need to separate attributes. Inherently IBundle2 interface keeps them separated.
*/
void separateAttrs() noexcept;
/**
* @deprecated Caching attributes is not needed. Calling this method doesn't do anything.
*/
void ensurePrimAttrsCached(BundlePrimIndex primIndex) noexcept;
protected:
using ConstBundlePrimPtr = std::unique_ptr<ConstBundlePrim>;
using BundlePrimArray = std::vector<ConstBundlePrimPtr>;
/**
* Get bundle primitives in this bundle.
*/
BundlePrimArray& getPrimitives() noexcept;
/**
* IConstBundle2 is a polymorphic base for IBundle2, thus passing bundle argument allows passing
* version of the interface that allows mutations.
*/
void attach(omni::core::ObjectPtr<omni::graph::core::IBundleFactory>&& factory,
omni::core::ObjectPtr<omni::graph::core::IConstBundle2>&& bundle) noexcept;
/**
* @return Factory to spawn instances of IBundle interface.
*/
omni::graph::core::IBundleFactory* getBundleFactoryPtr() noexcept;
/**
* @return IBundle instance of this bundle.
*/
omni::graph::core::IConstBundle2* getConstBundlePtr() noexcept;
/**
* Instances of BundlePrim are instantiated on demand. Argument create allows
* instantiation mutable or immutable IConstBundle2 interface.
*/
template<typename FUNC>
ConstBundlePrim* getConstPrim(BundlePrimIndex primIndex, FUNC create) noexcept;
void setBundleDirtyID(DirtyIDType bundleDirtyID) noexcept;
void setPrimDirtyIDsData(DirtyIDType const* primDirtyIDs) noexcept;
void setPrimPathsData(omni::graph::core::NameToken const* primPaths) noexcept;
void setPrimTypesData(omni::graph::core::NameToken const* primTypes) noexcept;
private:
omni::core::ObjectPtr<omni::graph::core::IBundleFactory> m_factory;
omni::core::ObjectPtr<omni::graph::core::IConstBundle2> m_bundle;
omni::graph::core::GraphContextObj m_context; // Backward compatibility.
/**
* ConstBundlePrims is a bundle as well. To access attributes under this bundle we need to acquire
* an instance of ConstBundlePrim for this bundle. Common attributes, with unfortunate name,
* gives us ability to access those attributes.
*/
ConstBundlePrimPtr m_commonAttributes;
BundlePrimArray m_primitives; // Cached instances of BundlePrim.
IDirtyID* m_iDirtyID{ nullptr }; // Cached interface to manage generation of unique ids.
DirtyIDType m_bundleDirtyID;
DirtyIDType const* m_primDirtyIDs{ nullptr }; // Backward compatibility - cached prim ids.
omni::graph::core::NameToken const* m_primPaths{ nullptr }; // Backward compatibility - cached prim paths.
omni::graph::core::NameToken const* m_primTypes{ nullptr }; // Backward compatibility - cached prim types.
friend class ConstBundlePrim;
friend class BundlePrim;
friend class BundleAttrib;
};
/**
* Primitives in Bundle iterator.
*/
class OMNI_GRAPH_IO_DEPRECATED ConstBundlePrimIterator
{
public:
ConstBundlePrimIterator(ConstBundlePrims& bundlePrims, BundlePrimIndex primIndex = 0) noexcept;
ConstBundlePrimIterator(ConstBundlePrimIterator const& that) noexcept = default;
ConstBundlePrimIterator& operator=(ConstBundlePrimIterator const& that) noexcept = default;
bool operator==(ConstBundlePrimIterator const& that) const noexcept;
bool operator!=(ConstBundlePrimIterator const& that) const noexcept;
ConstBundlePrim& operator*() noexcept;
ConstBundlePrim* operator->() noexcept;
ConstBundlePrimIterator& operator++() noexcept;
private:
ConstBundlePrims* m_bundlePrims;
BundlePrimIndex m_primIndex;
};
/**
* Attributes in Primitive iterator.
*/
class OMNI_GRAPH_IO_DEPRECATED ConstBundlePrimAttrIterator
{
public:
ConstBundlePrimAttrIterator(ConstBundlePrim& bundlePrim, ConstBundlePrim::AttrMapIteratorType attrIter) noexcept;
ConstBundlePrimAttrIterator(ConstBundlePrimAttrIterator const& that) noexcept = default;
ConstBundlePrimAttrIterator& operator=(ConstBundlePrimAttrIterator const& that) noexcept = default;
bool operator==(ConstBundlePrimAttrIterator const& that) const noexcept;
bool operator!=(ConstBundlePrimAttrIterator const& that) const noexcept;
BundleAttrib const& operator*() const noexcept;
BundleAttrib const* operator->() const noexcept;
ConstBundlePrimAttrIterator& operator++() noexcept;
private:
ConstBundlePrim* m_bundlePrim;
ConstBundlePrim::AttrMapIteratorType m_attrIter;
};
} // namespace io
} // namespace graph
} // namespace omni
#include "ConstBundlePrimsImpl.h"
| 15,915 | C | 33.6 | 118 | 0.660446 |
omniverse-code/kit/include/omni/graph/action/IActionGraph.h | // Copyright (c) 2023, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
//! @file IActionGraph.h
//!
//! @brief Defines @ref omni::graph::action::IActionGraph_abi
#pragma once
#include <omni/core/IObject.h>
#include <omni/core/Omni.h>
#include <omni/graph/core/iComputeGraph.h>
namespace omni
{
namespace graph
{
namespace action
{
//! Declare the IActionGraph interface definition
OMNI_DECLARE_INTERFACE(IActionGraph);
/**
* @brief Functions for implementing nodes which are used in `Action Graph`.
*
* Nodes in `Action Graph` have special functionality which is not present in other graph types.
*/
class IActionGraph_abi : public omni::core::Inherits<omni::core::IObject, OMNI_TYPE_ID("omni.graph.action.IActionGraph")>
{
protected:
/**
* @brief Indicate that the given output attribute should be enabled, so that execution flow should continue
* along downstream networks.
*
* @note This should only be called from within a node @c compute function.
*
* @param[in] attributeName attribute on the current node to be set
* @param[in] instanceIdx In vectorized context, the instance index relative to the currently targeted graph
*
* @return Success if executed successfully
*/
virtual OMNI_ATTR("no_py") omni::core::Result
setExecutionEnabled_abi(omni::graph::core::NameToken attributeName,
omni::graph::core::InstanceIndex instanceIdx) noexcept = 0;
/**
* @brief Indicate that the given output attribute should be enabled, and the current node should be pushed to the
* execution @c stack. This means that when the downstream execution flow has completed, this node will be
* @c popped from the execution stack and its @c compute function will be called again.
*
* @note This should only be called from within a node @c compute function.
*
* @param[in] attributeName attribute on the current node to be set
* @param[in] instanceIdx In vectorized context, the instance index relative to the currently targeted graph
*
* @return Success if executed successfully
*/
virtual OMNI_ATTR("no_py") omni::core::Result
setExecutionEnabledAndPushed_abi(omni::graph::core::NameToken attributeName,
omni::graph::core::InstanceIndex instanceIdx) noexcept = 0;
/**
* @brief Indicate that the current execution flow should be blocked at the given node, and the node should be
* @c ticked every update of the Graph (@c compute function called), until it calls \ref endLatentState_abi.
*
* @note This should only be called from within a node @c compute function.
*
* @param[in] instanceIdx In vectorized context, the instance index relative to the currently targeted graph
*
* @return Success if executed successfully
*/
virtual OMNI_ATTR("no_py") omni::core::Result
startLatentState_abi(omni::graph::core::InstanceIndex instanceIdx) noexcept = 0;
/**
* @brief Indicate that the current execution flow should be un-blocked at the given node, if it is currently in a
* latent state. It is an error to call this function before calling \ref startLatentState_abi.
*
* @note This should only be called from within a node @c compute function.
*
* @param[in] instanceIdx In vectorized context, the instance index relative to the currently targeted graph
*
* @return Success if executed successfully
*/
virtual OMNI_ATTR("no_py") omni::core::Result
endLatentState_abi(omni::graph::core::InstanceIndex instanceIdx) noexcept = 0;
/**
* @brief Read the current latent state of the node. This state is set using \ref startLatentState_abi and \ref endLatentState_abi
*
* @note This should only be called from within a node @c compute function.
*
* @param[in] instanceIdx In vectorized context, the instance index relative to the currently targeted graph
* @returns true if the node is currently in a latent state
*
* @return false if the node is not in a latent state, or the call failed
*/
virtual OMNI_ATTR("no_py") bool
getLatentState_abi(omni::graph::core::InstanceIndex instanceIdx) noexcept = 0;
/**
* @brief Read the enabled state of an input execution attribute. An input attribute is considered enabled if it is
* connected to the upstream node that was computed immediately prior to the currently computing node. Event nodes
* and nodes in latent state may not have any enabled input.
*
* @note This should only be called from within a node @c compute function.
*
* @param[in] attributeName attribute on the current node to be set
* @param[in] instanceIdx In vectorized context, the instance index relative to the currently targeted graph
* @returns true if the given attribute is considered enabled.
*
* @return false if the attribute is considered disabled or the call failed
*/
virtual OMNI_ATTR("no_py") bool
getExecutionEnabled_abi(omni::graph::core::NameToken attributeName,
omni::graph::core::InstanceIndex instanceIdx) noexcept = 0;
};
//! Access the IActionGraph interface. This is more efficient than creating an instance each time it is needed.
//!
//! The returned pointer is a singleton managed by *omni.graph.action*, and does *not* have @ref
//! omni::core::IObject::acquire() called on it before being returned. The caller should *not* call @ref
//! omni::core::IObject::release() on the returned raw pointer.
//!
//! @thread_safety This method is thread safe.
inline IActionGraph* getInterface() noexcept;
} // namespace action
} // namespace graph
} // namespace omni
// generated API declaration
#define OMNI_BIND_INCLUDE_INTERFACE_DECL
#include "IActionGraph.gen.h"
// additional headers needed for API implementation
#include <omni/core/ITypeFactory.h>
inline omni::graph::action::IActionGraph* omni::graph::action::getInterface() noexcept
{
// createType() always calls acquire() and returns an ObjectPtr to make sure release() is called. we don't want to
// hold a ref here to avoid static destruction issues. here we allow the returned ObjectPtr to destruct (after
// calling get()) to release our ref. we know the DLL in which the singleton was created is maintaining a ref and
// will keep the singleton alive for the lifetime of the DLL.
static auto sSingleton = omni::core::createType<omni::graph::action::IActionGraph>().get();
return sSingleton;
}
// generated API implementation
#define OMNI_BIND_INCLUDE_INTERFACE_IMPL
#include "IActionGraph.gen.h"
| 7,073 | C | 44.057325 | 134 | 0.709459 |
omniverse-code/kit/include/omni/graph/action/IActionGraph.gen.h | // Copyright (c) 2023, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
// --------- Warning: This is a build system generated file. ----------
//
//! @file
//!
//! @brief This file was generated by <i>omni.bind</i>.
#include <omni/core/Interface.h>
#include <omni/core/OmniAttr.h>
#include <omni/core/ResultError.h>
#include <functional>
#include <type_traits>
#include <utility>
#ifndef OMNI_BIND_INCLUDE_INTERFACE_IMPL
/**
* @brief Functions for implementing nodes which are used in `Action Graph`.
*
* Nodes in `Action Graph` have special functionality which is not present in other graph types.
*/
template <>
class omni::core::Generated<omni::graph::action::IActionGraph_abi> : public omni::graph::action::IActionGraph_abi
{
public:
OMNI_PLUGIN_INTERFACE("omni::graph::action::IActionGraph")
/**
* @brief Indicate that the given output attribute should be enabled, so that execution flow should continue
* along downstream networks.
*
* @note This should only be called from within a node @c compute function.
*
* @param[in] attributeName attribute on the current node to be set
* @param[in] instanceIdx In vectorized context, the instance index relative to the currently targeted graph
*
* @return Success if executed successfully
*/
omni::core::Result setExecutionEnabled(omni::graph::core::NameToken attributeName,
omni::graph::core::InstanceIndex instanceIdx) noexcept;
/**
* @brief Indicate that the given output attribute should be enabled, and the current node should be pushed to the
* execution @c stack. This means that when the downstream execution flow has completed, this node will be
* @c popped from the execution stack and its @c compute function will be called again.
*
* @note This should only be called from within a node @c compute function.
*
* @param[in] attributeName attribute on the current node to be set
* @param[in] instanceIdx In vectorized context, the instance index relative to the currently targeted graph
*
* @return Success if executed successfully
*/
omni::core::Result setExecutionEnabledAndPushed(omni::graph::core::NameToken attributeName,
omni::graph::core::InstanceIndex instanceIdx) noexcept;
/**
* @brief Indicate that the current execution flow should be blocked at the given node, and the node should be
* @c ticked every update of the Graph (@c compute function called), until it calls \ref endLatentState_abi.
*
* @note This should only be called from within a node @c compute function.
*
* @param[in] instanceIdx In vectorized context, the instance index relative to the currently targeted graph
*
* @return Success if executed successfully
*/
omni::core::Result startLatentState(omni::graph::core::InstanceIndex instanceIdx) noexcept;
/**
* @brief Indicate that the current execution flow should be un-blocked at the given node, if it is currently in a
* latent state. It is an error to call this function before calling \ref startLatentState_abi.
*
* @note This should only be called from within a node @c compute function.
*
* @param[in] instanceIdx In vectorized context, the instance index relative to the currently targeted graph
*
* @return Success if executed successfully
*/
omni::core::Result endLatentState(omni::graph::core::InstanceIndex instanceIdx) noexcept;
/**
* @brief Read the current latent state of the node. This state is set using \ref startLatentState_abi and \ref
* endLatentState_abi
*
* @note This should only be called from within a node @c compute function.
*
* @param[in] instanceIdx In vectorized context, the instance index relative to the currently targeted graph
* @returns true if the node is currently in a latent state
*
* @return false if the node is not in a latent state, or the call failed
*/
bool getLatentState(omni::graph::core::InstanceIndex instanceIdx) noexcept;
/**
* @brief Read the enabled state of an input execution attribute. An input attribute is considered enabled if it is
* connected to the upstream node that was computed immediately prior to the currently computing node. Event nodes
* and nodes in latent state may not have any enabled input.
*
* @note This should only be called from within a node @c compute function.
*
* @param[in] attributeName attribute on the current node to be set
* @param[in] instanceIdx In vectorized context, the instance index relative to the currently targeted graph
* @returns true if the given attribute is considered enabled.
*
* @return false if the attribute is considered disabled or the call failed
*/
bool getExecutionEnabled(omni::graph::core::NameToken attributeName,
omni::graph::core::InstanceIndex instanceIdx) noexcept;
};
#endif
#ifndef OMNI_BIND_INCLUDE_INTERFACE_DECL
inline omni::core::Result omni::core::Generated<omni::graph::action::IActionGraph_abi>::setExecutionEnabled(
omni::graph::core::NameToken attributeName, omni::graph::core::InstanceIndex instanceIdx) noexcept
{
return setExecutionEnabled_abi(attributeName, instanceIdx);
}
inline omni::core::Result omni::core::Generated<omni::graph::action::IActionGraph_abi>::setExecutionEnabledAndPushed(
omni::graph::core::NameToken attributeName, omni::graph::core::InstanceIndex instanceIdx) noexcept
{
return setExecutionEnabledAndPushed_abi(attributeName, instanceIdx);
}
inline omni::core::Result omni::core::Generated<omni::graph::action::IActionGraph_abi>::startLatentState(
omni::graph::core::InstanceIndex instanceIdx) noexcept
{
return startLatentState_abi(instanceIdx);
}
inline omni::core::Result omni::core::Generated<omni::graph::action::IActionGraph_abi>::endLatentState(
omni::graph::core::InstanceIndex instanceIdx) noexcept
{
return endLatentState_abi(instanceIdx);
}
inline bool omni::core::Generated<omni::graph::action::IActionGraph_abi>::getLatentState(
omni::graph::core::InstanceIndex instanceIdx) noexcept
{
return getLatentState_abi(instanceIdx);
}
inline bool omni::core::Generated<omni::graph::action::IActionGraph_abi>::getExecutionEnabled(
omni::graph::core::NameToken attributeName, omni::graph::core::InstanceIndex instanceIdx) noexcept
{
return getExecutionEnabled_abi(attributeName, instanceIdx);
}
#endif
#undef OMNI_BIND_INCLUDE_INTERFACE_DECL
#undef OMNI_BIND_INCLUDE_INTERFACE_IMPL
| 7,053 | C | 41.751515 | 119 | 0.716858 |
omniverse-code/kit/include/omni/graph/action/PyIActionGraph.gen.h | // Copyright (c) 2023, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
// --------- Warning: This is a build system generated file. ----------
//
#pragma once
#include <omni/core/ITypeFactory.h>
#include <omni/python/PyBind.h>
#include <omni/python/PyString.h>
#include <omni/python/PyVec.h>
#include <sstream>
auto bindIActionGraph(py::module& m)
{
// hack around pybind11 issues with C++17
// - https://github.com/pybind/pybind11/issues/2234
// - https://github.com/pybind/pybind11/issues/2666
// - https://github.com/pybind/pybind11/issues/2856
py::class_<omni::core::Generated<omni::graph::action::IActionGraph_abi>,
omni::python::detail::PyObjectPtr<omni::core::Generated<omni::graph::action::IActionGraph_abi>>,
omni::core::IObject>
clsParent(m, "_IActionGraph");
py::class_<omni::graph::action::IActionGraph, omni::core::Generated<omni::graph::action::IActionGraph_abi>,
omni::python::detail::PyObjectPtr<omni::graph::action::IActionGraph>, omni::core::IObject>
cls(m, "IActionGraph", R"OMNI_BIND_RAW_(@brief Functions for implementing nodes which are used in `Action Graph`.
Nodes in `Action Graph` have special functionality which is not present in other graph types.)OMNI_BIND_RAW_");
cls.def(py::init(
[](const omni::core::ObjectPtr<omni::core::IObject>& obj)
{
auto tmp = omni::core::cast<omni::graph::action::IActionGraph>(obj.get());
if (!tmp)
{
throw std::runtime_error("invalid type conversion");
}
return tmp;
}));
cls.def(py::init(
[]()
{
auto tmp = omni::core::createType<omni::graph::action::IActionGraph>();
if (!tmp)
{
throw std::runtime_error("unable to create omni::graph::action::IActionGraph instantiation");
}
return tmp;
}));
return omni::python::PyBind<omni::graph::action::IActionGraph>::bind(cls);
}
| 2,401 | C | 41.14035 | 121 | 0.640983 |
omniverse-code/kit/include/omni/graph/exec/unstable/IPopulatePass.h | // Copyright (c) 2022-2023, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
//! @file IPopulatePass.h
//!
//! @brief Defines @ref omni::graph::exec::unstable::IPopulatePass.
#pragma once
#include <omni/graph/exec/unstable/IPass.h>
namespace omni
{
namespace graph
{
namespace exec
{
namespace unstable
{
// forward declarations needed by interface declaration
class IGraphBuilder;
class INode;
class IPopulatePass;
class IPopulatePass_abi;
//! Base class for populate passes.
//!
//! Register a populate pass with @ref OMNI_GRAPH_EXEC_REGISTER_POPULATE_PASS(). When registering a pass, a "name to
//! match" is also specified. This name is the name of a node or definition on which the registered pass should
//! populate.
//!
//! Populate passes are typically the first pass type to run in the pass pipeline. When a node is encountered during
//! construction, only a single populate pass will get a chance to populate the newly discovered node. If no pass is
//! registered against the node's name, the node definition's name is used to find a population pass to run.
//!
//! Populate pass is allowed to attach a new definition to a node it runs on.
//!
//! Minimal rebuild of the execution graph topology should be considered by the pass each time it runs. Pass pipeline
//! leaves the responsibility of deciding if pass needs to run to the implementation. At minimum it can rely on
//! verifying that topology of @ref omni::graph::exec::unstable::NodeGraphDef it generated before is still valid or
//! @ref omni::graph::exec::unstable::NodeDef has not changed.
//!
//! See @ref groupOmniGraphExecPasses for more pass related functionality.
class IPopulatePass_abi : public omni::core::Inherits<IPass, OMNI_TYPE_ID("omni.graph.exec.unstable.IPopulatePass")>
{
protected:
//! Call from pass pipeline to apply graph transformations on a given node (definition or topology).
virtual OMNI_ATTR("throw_result") omni::core::Result run_abi(IGraphBuilder* builder, INode* node) noexcept = 0;
};
//! Smart pointer managing an instance of @ref IPopulatePass.
using PopulatePassPtr = omni::core::ObjectPtr<IPopulatePass>;
} // namespace unstable
} // namespace exec
} // namespace graph
} // namespace omni
// generated API declaration
#define OMNI_BIND_INCLUDE_INTERFACE_DECL
#include <omni/graph/exec/unstable/IPopulatePass.gen.h>
//! @copydoc omni::graph::exec::unstable::IPopulatePass_abi
//!
//! @ingroup groupOmniGraphExecPasses groupOmniGraphExecInterfaces
class omni::graph::exec::unstable::IPopulatePass
: public omni::core::Generated<omni::graph::exec::unstable::IPopulatePass_abi>
{
};
// additional headers needed for API implementation
#include <omni/graph/exec/unstable/IGraphBuilder.h>
#include <omni/graph/exec/unstable/INode.h>
// generated API implementation
#define OMNI_BIND_INCLUDE_INTERFACE_IMPL
#include <omni/graph/exec/unstable/IPopulatePass.gen.h>
| 3,256 | C | 37.773809 | 117 | 0.764128 |
omniverse-code/kit/include/omni/graph/exec/unstable/IGraph.gen.h | // Copyright (c) 2022-2023, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
// --------- Warning: This is a build system generated file. ----------
//
//! @file
//!
//! @brief This file was generated by <i>omni.bind</i>.
#include <omni/core/Interface.h>
#include <omni/core/OmniAttr.h>
#include <omni/core/ResultError.h>
#include <functional>
#include <type_traits>
#include <utility>
#ifndef OMNI_BIND_INCLUDE_INTERFACE_IMPL
//! Top-level container for storing the Execution Framework's graph of graphs.
//!
//! @ref omni::graph::exec::unstable::IGraph is the top-level container used to store the graph of graphs. This
//! top-level container is referred to as the <i>execution graph</i>.
//!
//! @ref omni::graph::exec::unstable::IGraph's responsibilities include:
//!
//! - Tracking if the graph is currently being constructed. See @ref omni::graph::exec::unstable::IGraph::inBuild().
//!
//! - Tracking gross changes to the topologies of graphs within the execution graph. This is done with the <i>global
//! topology stamp</i> (see @ref omni::graph::exec::unstable::IGraph::getGlobalTopologyStamp()). Each time a topology
//! is invalidated, the global topology stamp is incremented. Consumers of the execution graph can use this stamp to
//! detect changes in the graph. See @rstref{Graph Invalidation <ef_graph_invalidation>} for details.
//!
//! - Owning and providing access to the top level graph definition (see @ref
//! omni::graph::exec::unstable::IGraph::getNodeGraphDef()). The root node of the top-level graph definition is the
//! root of execution graph. @ref omni::graph::exec::unstable::IGraph is the only container, other than @ref
//! omni::graph::exec::unstable::INode, that attaches to definitions.
//!
//! See @rstref{Graph Concepts <ef_graph_concepts>} for more information on how @ref omni::graph::exec::unstable::IGraph
//! fits into the Execution Framework.
//!
//! See @ref omni::graph::exec::unstable::Graph for a concrete implementation of this interface.
template <>
class omni::core::Generated<omni::graph::exec::unstable::IGraph_abi> : public omni::graph::exec::unstable::IGraph_abi
{
public:
OMNI_PLUGIN_INTERFACE("omni::graph::exec::unstable::IGraph")
//! Access the top-level node graph definition.
//!
//! The returned @ref omni::graph::exec::unstable::INodeGraphDef will *not* have
//! @ref omni::core::IObject::acquire() called before being returned.
//!
//! @thread_safety This method is thread safe. The returned pointer will be valid for the lifetime of this @ref
//! omni::graph::exec::unstable::IGraph.
omni::graph::exec::unstable::INodeGraphDef* getNodeGraphDef() noexcept;
//! Name set on the graph during construction.
//!
//! @thread_safety This method is thread safe. The returned pointer will be valid for the lifetime of this @ref
//! omni::graph::exec::unstable::IGraph.
const omni::graph::exec::unstable::ConstName& getName() noexcept;
//! Return global topology of the graph. Useful when detecting that graph transformation pipeline needs to run.
//!
//! See @rstref{Graph Invalidation <ef_graph_invalidation>} to understand how this stamp is used to detect changes
//! in the graph.
//!
//! @thread_safety This method is thread safe. The returned pointer will be valid for the lifetime of this @ref
//! omni::graph::exec::unstable::IGraph. It is up to the caller to mutate the stamp in a thread safe manner.
omni::graph::exec::unstable::Stamp* getGlobalTopologyStamp() noexcept;
//! Return @c true if a @ref omni::graph::exec::unstable::IGraphBuilder is currently building a part of this graph.
//!
//! @thread_safety This method is thread safe.
bool inBuild() noexcept;
//! Mark that an @ref omni::graph::exec::unstable::IGraphBuilder is currently building a part of this graph.
//!
//! Each builder should call @c _setInBuild(true) followed by @c _setInBuild(false) once building is complete. Since
//! multiple builders can be active at a time, it is safe for this method to be called multiple times.
//!
//! This method should only be called by @ref omni::graph::exec::unstable::IGraphBuilder.
//!
//! @thread_safety This method is thread safe.
void _setInBuild(bool inBuild) noexcept;
};
#endif
#ifndef OMNI_BIND_INCLUDE_INTERFACE_DECL
inline omni::graph::exec::unstable::INodeGraphDef* omni::core::Generated<
omni::graph::exec::unstable::IGraph_abi>::getNodeGraphDef() noexcept
{
return getNodeGraphDef_abi();
}
inline const omni::graph::exec::unstable::ConstName& omni::core::Generated<omni::graph::exec::unstable::IGraph_abi>::getName() noexcept
{
return *(getName_abi());
}
inline omni::graph::exec::unstable::Stamp* omni::core::Generated<
omni::graph::exec::unstable::IGraph_abi>::getGlobalTopologyStamp() noexcept
{
return getGlobalTopologyStamp_abi();
}
inline bool omni::core::Generated<omni::graph::exec::unstable::IGraph_abi>::inBuild() noexcept
{
return inBuild_abi();
}
inline void omni::core::Generated<omni::graph::exec::unstable::IGraph_abi>::_setInBuild(bool inBuild) noexcept
{
_setInBuild_abi(inBuild);
}
#endif
#undef OMNI_BIND_INCLUDE_INTERFACE_DECL
#undef OMNI_BIND_INCLUDE_INTERFACE_IMPL
| 5,648 | C | 42.122137 | 135 | 0.712819 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.