named object in the data model More...
#include <MRObject.h>
Classes | |
struct | ProtectedStruct |
Public Types | |
using | XfChangedSignal = Signal<void() > |
Public Member Functions | |
Object ()=default | |
Object (Object &&) noexcept=default | |
Object & | operator= (Object &&) noexcept=default |
virtual | ~Object ()=default |
virtual const char * | typeName () const |
template<typename T > | |
T * | asType () |
template<typename T > | |
const T * | asType () const |
const std::string & | name () const |
virtual void | setName (std::string name) |
MRMESH_API std::shared_ptr< const Object > | find (const std::string_view &name) const |
finds a direct child by name | |
std::shared_ptr< Object > | find (const std::string_view &name) |
template<typename T > | |
std::shared_ptr< const T > | find () const |
finds a direct child by type | |
template<typename T > | |
std::shared_ptr< T > | find () |
template<typename T > | |
std::shared_ptr< const T > | find (const std::string_view &name) const |
finds a direct child by name and type | |
template<typename T > | |
std::shared_ptr< T > | find (const std::string_view &name) |
const AffineXf3f & | xf (ViewportId id={}, bool *isDef=nullptr) const |
virtual MRMESH_API void | setXf (const AffineXf3f &xf, ViewportId id={}) |
virtual MRMESH_API void | resetXf (ViewportId id={}) |
forgets specific transform in given viewport (or forgets all specific transforms for {} input) | |
const ViewportProperty< AffineXf3f > & | xfsForAllViewports () const |
returns xfs for all viewports, combined into a single object | |
virtual void | setXfsForAllViewports (ViewportProperty< AffineXf3f > xf) |
modifies xfs for all viewports at once | |
MRMESH_API AffineXf3f | worldXf (ViewportId id={}, bool *isDef=nullptr) const |
MRMESH_API void | setWorldXf (const AffineXf3f &xf, ViewportId id={}) |
virtual MRMESH_API void | applyScale (float scaleFactor) |
scale object size (all point positions) | |
MRMESH_API ViewportMask | globalVisibilityMask () const |
returns all viewports where this object is visible together with all its parents | |
bool | globalVisibility (ViewportMask viewportMask=ViewportMask::any()) const |
returns true if this object is visible together with all its parents in any of given viewports | |
MRMESH_API void | setGlobalVisibility (bool on, ViewportMask viewportMask=ViewportMask::any()) |
if true sets all predecessors visible, otherwise sets this object invisible | |
bool | isLocked () const |
object properties lock for UI | |
virtual void | setLocked (bool on) |
bool | isParentLocked () const |
virtual void | setParentLocked (bool lock) |
const Object * | parent () const |
returns parent object in the tree | |
Object * | parent () |
MRMESH_API bool | isAncestor (const Object *ancestor) const |
return true if given object is ancestor of this one, false otherwise | |
MRMESH_API Object * | findCommonAncestor (Object &other) |
const Object * | findCommonAncestor (const Object &other) const |
virtual MRMESH_API bool | detachFromParent () |
const std::vector< std::shared_ptr< Object > > & | children () |
an object can hold other sub-objects | |
const std::vector< std::shared_ptr< const Object > > & | children () const |
virtual MRMESH_API bool | addChild (std::shared_ptr< Object > child, bool recognizedChild=true) |
virtual MRMESH_API bool | addChildBefore (std::shared_ptr< Object > newChild, const std::shared_ptr< Object > &existingChild) |
bool | removeChild (const std::shared_ptr< Object > &child) |
returns false if it was not child of this | |
virtual MRMESH_API bool | removeChild (Object *child) |
virtual MRMESH_API void | removeAllChildren () |
detaches all recognized children from this, keeping all unrecognized ones | |
MRMESH_API void | sortChildren () |
sort recognized children by name | |
virtual MRMESH_API bool | select (bool on) |
selects the object, returns true if value changed, otherwise returns false | |
virtual bool | isSelected () const |
virtual MRMESH_API void | setAncillary (bool ancillary) |
bool | isAncillary () const |
MRMESH_API void | setVisible (bool on, ViewportMask viewportMask=ViewportMask::all()) |
sets the object visible in the viewports specified by the mask (by default in all viewports) | |
bool | isVisible (ViewportMask viewportMask=ViewportMask::any()) const |
checks whether the object is visible in any of the viewports specified by the mask (by default in any viewport) | |
virtual MRMESH_API void | setVisibilityMask (ViewportMask viewportMask) |
specifies object visibility as bitmask of viewports | |
virtual ViewportMask | visibilityMask () const |
gets object visibility as bitmask of viewports | |
virtual bool | getRedrawFlag (ViewportMask) const |
this method virtual because others data model types could have dirty flags or something | |
void | resetRedrawFlag () const |
MRMESH_API std::shared_ptr< Object > | cloneTree () const |
clones all tree of this object (except ancillary and unrecognized children) | |
virtual MRMESH_API std::shared_ptr< Object > | clone () const |
clones current object only, without parent and/or children | |
MRMESH_API std::shared_ptr< Object > | shallowCloneTree () const |
virtual MRMESH_API std::shared_ptr< Object > | shallowClone () const |
virtual MRMESH_API std::vector< std::string > | getInfoLines () const |
return several info lines that can better describe object in the UI | |
virtual std::string | getClassName () const |
return human readable name of subclass | |
MRMESH_API Expected< std::vector< std::future< Expected< void > > > > | serializeRecursive (const std::filesystem::path &path, Json::Value &root, int childId) const |
MRMESH_API Expected< void > | deserializeRecursive (const std::filesystem::path &path, const Json::Value &root, ProgressCallback progressCb={}, int *objCounter=nullptr) |
MRMESH_API void | swap (Object &other) |
virtual Box3f | getWorldBox (ViewportId={}) const |
returns bounding box of this object in world coordinates for default or specific viewport | |
MRMESH_API Box3f | getWorldTreeBox (ViewportId={}) const |
returns bounding box of this object and all children visible in given (or default) viewport in world coordinates | |
virtual bool | hasVisualRepresentation () const |
does the object have any visual representation (visible points, triangles, edges, etc.), no considering child objects | |
virtual bool | hasModel () const |
virtual MRMESH_API size_t | heapBytes () const |
returns the amount of memory this object occupies on heap | |
Object (ProtectedStruct, const Object &obj) | |
Public Member Functions inherited from MR::ObjectChildrenHolder | |
ObjectChildrenHolder ()=default | |
ObjectChildrenHolder (const ObjectChildrenHolder &) noexcept | |
ObjectChildrenHolder & | operator= (const ObjectChildrenHolder &) noexcept |
MRMESH_API | ObjectChildrenHolder (ObjectChildrenHolder &&) noexcept |
MRMESH_API ObjectChildrenHolder & | operator= (ObjectChildrenHolder &&) noexcept |
MRMESH_API | ~ObjectChildrenHolder () |
MRMESH_API std::shared_ptr< Object > | getSharedPtr () const |
MRMESH_API size_t | heapBytes () const |
Static Public Member Functions | |
static constexpr const char * | TypeName () noexcept |
Public Attributes | |
XfChangedSignal | worldXfChangedSignal |
Protected Member Functions | |
Object (const Object &obj)=default | |
user should not be able to call copy implicitly, use clone() function instead | |
virtual MRMESH_API void | swapBase_ (Object &other) |
swaps whole object (signals too) | |
virtual MRMESH_API void | swapSignals_ (Object &other) |
virtual MRMESH_API Expected< std::future< Expected< void > > > | serializeModel_ (const std::filesystem::path &path) const |
virtual MRMESH_API void | serializeFields_ (Json::Value &root) const |
virtual MRMESH_API Expected< void > | deserializeModel_ (const std::filesystem::path &path, ProgressCallback progressCb={}) |
Reads model from file. | |
virtual MRMESH_API void | deserializeFields_ (const Json::Value &root) |
virtual MRMESH_API void | propagateWorldXfChangedSignal_ () |
Protected Attributes | |
std::string | name_ |
ViewportProperty< AffineXf3f > | xf_ |
ViewportMask | visibilityMask_ = ViewportMask::all() |
bool | locked_ = false |
bool | parentLocked_ = false |
bool | selected_ { false } |
bool | ancillary_ { false } |
bool | needRedraw_ {false} |
Protected Attributes inherited from MR::ObjectChildrenHolder | |
ObjectChildrenHolder * | parent_ = nullptr |
std::vector< std::shared_ptr< Object > > | children_ |
std::vector< std::weak_ptr< Object > > | bastards_ |
recognized ones | |
named object in the data model
using MR::Object::XfChangedSignal = Signal<void() > |
signal about xf changing triggered in setXf and setWorldXf, it is called for children too triggered in addChild and addChildBefore, it is called only for children object
|
default |
|
defaultnoexcept |
|
virtualdefault |
|
inline |
|
protecteddefault |
user should not be able to call copy implicitly, use clone() function instead
|
virtual |
adds given object at the end of children (recognized or not); returns false if it was already child of this, of if given pointer is empty; child object will always report this as parent after the call;
recognizedChild | if set to false then child object will be excluded from children() and it will be stored by weak_ptr |
|
virtual |
adds given object in the recognized children before existingChild; if newChild was already among this children then moves it just before existingChild keeping the order of other children intact; returns false if newChild is nullptr, or existingChild is not a child of this
|
virtual |
scale object size (all point positions)
Reimplemented in MR::ObjectDistanceMap, MR::ObjectLabel, MR::ObjectLinesHolder, MR::ObjectMeshHolder, MR::ObjectPointsHolder, and MR::ObjectVoxels.
|
inline |
|
inline |
|
inline |
an object can hold other sub-objects
|
inline |
|
virtual |
clones current object only, without parent and/or children
Reimplemented in MR::AngleMeasurementObject, MR::CircleObject, MR::ConeObject, MR::CylinderObject, MR::DistanceMeasurementObject, MR::LineObject, MR::ObjectDistanceMap, MR::ObjectGcode, MR::ObjectImGuiLabel, MR::ObjectLabel, MR::ObjectLines, MR::ObjectLinesHolder, MR::ObjectMesh, MR::ObjectMeshHolder, MR::ObjectPoints, MR::ObjectPointsHolder, MR::ObjectVoxels, MR::PlaneObject, MR::PointObject, MR::RadiusMeasurementObject, MR::SceneRootObject, MR::SphereObject, and MR::VisualObject.
MRMESH_API std::shared_ptr< Object > MR::Object::cloneTree | ( | ) | const |
clones all tree of this object (except ancillary and unrecognized children)
|
protectedvirtual |
Reads parameters from json value
Reimplemented in MR::AngleMeasurementObject, MR::DistanceMeasurementObject, MR::FeatureObject, MR::ObjectDistanceMap, MR::ObjectGcode, MR::ObjectImGuiLabel, MR::ObjectLabel, MR::ObjectLinesHolder, MR::ObjectMeshHolder, MR::ObjectPointsHolder, MR::ObjectVoxels, MR::RadiusMeasurementObject, MR::SceneRootObject, and MR::VisualObject.
|
protectedvirtual |
Reads model from file.
Reimplemented in MR::CircleObject, MR::ConeObject, MR::CylinderObject, MR::LineObject, MR::ObjectDistanceMap, MR::ObjectMeshHolder, MR::ObjectPointsHolder, MR::ObjectVoxels, MR::PlaneObject, MR::PointObject, and MR::SphereObject.
MRMESH_API Expected< void > MR::Object::deserializeRecursive | ( | const std::filesystem::path & | path, |
const Json::Value & | root, | ||
ProgressCallback | progressCb = {}, | ||
int * | objCounter = nullptr ) |
loads subtree into this Object models from the folder by given path and fields from given JSON
|
virtual |
removes this from its parent children list returns false if it was already orphan
|
inline |
|
inline |
|
inline |
MRMESH_API std::shared_ptr< const Object > MR::Object::find | ( | const std::string_view & | name | ) | const |
finds a direct child by name
|
nodiscard |
Find a common ancestor between this object and the other one. Returns null on failure (which is impossible if both are children of the scene root). Will return this
if other
matches this
.
|
inlinevirtual |
return human readable name of subclass
Reimplemented in MR::AngleMeasurementObject, MR::CircleObject, MR::ConeObject, MR::CylinderObject, MR::DistanceMeasurementObject, MR::LineObject, MR::ObjectDistanceMap, MR::ObjectGcode, MR::ObjectLines, MR::ObjectMesh, MR::ObjectPoints, MR::ObjectVoxels, MR::PlaneObject, MR::PointObject, MR::RadiusMeasurementObject, MR::SphereObject, and MR::VisualObject.
|
virtual |
return several info lines that can better describe object in the UI
Reimplemented in MR::AngleMeasurementObject, MR::DistanceMeasurementObject, MR::ObjectDistanceMap, MR::ObjectGcode, MR::ObjectLines, MR::ObjectMesh, MR::ObjectPoints, MR::ObjectVoxels, MR::RadiusMeasurementObject, and MR::VisualObject.
|
inlinevirtual |
this method virtual because others data model types could have dirty flags or something
Reimplemented in MR::ObjectMeshHolder, and MR::VisualObject.
|
inlinevirtual |
returns bounding box of this object in world coordinates for default or specific viewport
Reimplemented in MR::ObjectLabel, MR::ObjectLinesHolder, MR::ObjectMeshHolder, MR::ObjectPointsHolder, and MR::VisualObject.
MRMESH_API Box3f MR::Object::getWorldTreeBox | ( | ViewportId | = {} | ) | const |
returns bounding box of this object and all children visible in given (or default) viewport in world coordinates
empty box
|
inline |
returns true if this object is visible together with all its parents in any of given viewports
MRMESH_API ViewportMask MR::Object::globalVisibilityMask | ( | ) | const |
returns all viewports where this object is visible together with all its parents
|
inlinenodiscardvirtual |
does the object have any model available (but possibly empty), e.g. ObjectMesh has valid mesh() or ObjectPoints has valid pointCloud()
Reimplemented in MR::ObjectDistanceMap, MR::ObjectLinesHolder, MR::ObjectMeshHolder, MR::ObjectPointsHolder, and MR::ObjectVoxels.
|
inlinenodiscardvirtual |
does the object have any visual representation (visible points, triangles, edges, etc.), no considering child objects
Reimplemented in MR::ObjectImGuiLabel, MR::ObjectLabel, MR::ObjectLinesHolder, MR::ObjectMeshHolder, MR::ObjectPointsHolder, and MR::ObjectVoxels.
|
nodiscardvirtual |
returns the amount of memory this object occupies on heap
Reimplemented in MR::ObjectDistanceMap, MR::ObjectGcode, MR::ObjectLabel, MR::ObjectLinesHolder, MR::ObjectMeshHolder, MR::ObjectPointsHolder, MR::ObjectVoxels, and MR::VisualObject.
MRMESH_API bool MR::Object::isAncestor | ( | const Object * | ancestor | ) | const |
return true if given object is ancestor of this one, false otherwise
|
inline |
|
inline |
object properties lock for UI
|
inlinenodiscard |
If true, the scene tree GUI doesn't allow you to drag'n'drop this object into a different parent. Defaults to false.
|
inlinevirtual |
|
inline |
checks whether the object is visible in any of the viewports specified by the mask (by default in any viewport)
|
inline |
|
inline |
|
inline |
returns parent object in the tree
|
protectedvirtual |
Reimplemented in MR::AngleMeasurementObject, MR::DistanceMeasurementObject, and MR::RadiusMeasurementObject.
|
virtual |
detaches all recognized children from this, keeping all unrecognized ones
|
inline |
returns false if it was not child of this
|
virtual |
|
inline |
|
virtual |
forgets specific transform in given viewport (or forgets all specific transforms for {} input)
Reimplemented in MR::FeatureObject.
|
virtual |
selects the object, returns true if value changed, otherwise returns false
Reimplemented in MR::ObjectGcode, and MR::SceneRootObject.
|
protectedvirtual |
Write parameters to given Json::Value,
Reimplemented in MR::AngleMeasurementObject, MR::CircleObject, MR::ConeObject, MR::CylinderObject, MR::DistanceMeasurementObject, MR::FeatureObject, MR::LineObject, MR::ObjectDistanceMap, MR::ObjectGcode, MR::ObjectImGuiLabel, MR::ObjectLabel, MR::ObjectLines, MR::ObjectLinesHolder, MR::ObjectMesh, MR::ObjectMeshHolder, MR::ObjectPoints, MR::ObjectPointsHolder, MR::ObjectVoxels, MR::PlaneObject, MR::PointObject, MR::RadiusMeasurementObject, MR::SceneRootObject, MR::SphereObject, and MR::VisualObject.
|
protectedvirtual |
Creates future to save object model (e.g. mesh) in given file path is full filename without extension
Reimplemented in MR::CircleObject, MR::ConeObject, MR::CylinderObject, MR::LineObject, MR::ObjectDistanceMap, MR::ObjectMeshHolder, MR::ObjectPointsHolder, MR::ObjectVoxels, MR::PlaneObject, MR::PointObject, and MR::SphereObject.
MRMESH_API Expected< std::vector< std::future< Expected< void > > > > MR::Object::serializeRecursive | ( | const std::filesystem::path & | path, |
Json::Value & | root, | ||
int | childId ) const |
creates futures that save this object subtree: models in the folder by given path and fields in given JSON
childId | is its ordinal number within the parent |
|
virtual |
ancillary object is an object hidden (in scene menu) from a regular user such objects cannot be selected, and if it has been selected, it is unselected when turn ancillary
Reimplemented in MR::SceneRootObject.
MRMESH_API void MR::Object::setGlobalVisibility | ( | bool | on, |
ViewportMask | viewportMask = ViewportMask::any() ) |
if true sets all predecessors visible, otherwise sets this object invisible
|
inlinevirtual |
|
inlinevirtual |
Reimplemented in MR::SceneRootObject.
|
inlinevirtual |
|
virtual |
specifies object visibility as bitmask of viewports
MRMESH_API void MR::Object::setVisible | ( | bool | on, |
ViewportMask | viewportMask = ViewportMask::all() ) |
sets the object visible in the viewports specified by the mask (by default in all viewports)
MRMESH_API void MR::Object::setWorldXf | ( | const AffineXf3f & | xf, |
ViewportId | id = {} ) |
|
virtual |
Reimplemented in MR::FeatureObject.
|
inlinevirtual |
modifies xfs for all viewports at once
|
virtual |
clones current object only, without parent and/or children clones only pointers to mesh, points or voxels
Reimplemented in MR::AngleMeasurementObject, MR::CircleObject, MR::ConeObject, MR::CylinderObject, MR::DistanceMeasurementObject, MR::LineObject, MR::ObjectDistanceMap, MR::ObjectGcode, MR::ObjectImGuiLabel, MR::ObjectLabel, MR::ObjectLines, MR::ObjectLinesHolder, MR::ObjectMesh, MR::ObjectMeshHolder, MR::ObjectPoints, MR::ObjectPointsHolder, MR::ObjectVoxels, MR::PlaneObject, MR::PointObject, MR::RadiusMeasurementObject, MR::SphereObject, and MR::VisualObject.
MRMESH_API std::shared_ptr< Object > MR::Object::shallowCloneTree | ( | ) | const |
clones all tree of this object (except ancillary and unrecognied children) clones only pointers to mesh, points or voxels
MRMESH_API void MR::Object::sortChildren | ( | ) |
sort recognized children by name
MRMESH_API void MR::Object::swap | ( | Object & | other | ) |
swaps this object with other note: do not swap object signals, so listeners will get notifications from swapped object requires implementation of swapBase_
and swapSignals_
(if type has signals)
|
protectedvirtual |
swaps whole object (signals too)
Reimplemented in MR::AngleMeasurementObject, MR::CircleObject, MR::ConeObject, MR::CylinderObject, MR::DistanceMeasurementObject, MR::LineObject, MR::ObjectDistanceMap, MR::ObjectGcode, MR::ObjectImGuiLabel, MR::ObjectLabel, MR::ObjectLines, MR::ObjectLinesHolder, MR::ObjectMesh, MR::ObjectMeshHolder, MR::ObjectPoints, MR::ObjectPointsHolder, MR::ObjectVoxels, MR::PlaneObject, MR::PointObject, MR::RadiusMeasurementObject, MR::SphereObject, and MR::VisualObject.
|
protectedvirtual |
swaps signals, used in swap
function to return back signals after swapBase_
Reimplemented in MR::ObjectGcode, MR::ObjectLines, MR::ObjectMesh, MR::ObjectMeshHolder, MR::ObjectPoints, MR::ObjectPointsHolder, and MR::ObjectVoxels.
|
inlinestaticconstexprnoexcept |
|
inlinevirtual |
Reimplemented in MR::AngleMeasurementObject, MR::CircleObject, MR::ConeObject, MR::CylinderObject, MR::DistanceMeasurementObject, MR::LineObject, MR::ObjectDistanceMap, MR::ObjectGcode, MR::ObjectImGuiLabel, MR::ObjectLabel, MR::ObjectLines, MR::ObjectLinesHolder, MR::ObjectMesh, MR::ObjectMeshHolder, MR::ObjectPoints, MR::ObjectPointsHolder, MR::ObjectVoxels, MR::PlaneObject, MR::PointObject, MR::RadiusMeasurementObject, MR::SceneRootObject, MR::SphereObject, and MR::VisualObject.
|
inlinevirtual |
gets object visibility as bitmask of viewports
MRMESH_API AffineXf3f MR::Object::worldXf | ( | ViewportId | id = {}, |
bool * | isDef = nullptr ) const |
this space to world space transformation for default or specific viewport
isDef | receives true if the object has default transformation in this viewport (same as worldXf() returns) |
|
inline |
this space to parent space transformation (to world space if no parent) for default or given viewport
isDef | receives true if the object has default transformation in this viewport (same as xf() returns) |
|
inline |
returns xfs for all viewports, combined into a single object
|
protected |
|
protected |
|
protected |
|
mutableprotected |
|
protected |
|
protected |
|
protected |
XfChangedSignal MR::Object::worldXfChangedSignal |
|
protected |