@@ -23,7 +23,13 @@ class Value;
2323namespace MR
2424{
2525
26- // This class exists to provide default copy and move operations on std::mutex
26+ /* *
27+ * \defgroup DataModelGroup Data Model
28+ * \brief This chapter represents documentation about data models
29+ * \{
30+ */
31+
32+ // / This class exists to provide default copy and move operations on std::mutex
2733class MutexOwner
2834{
2935public:
@@ -38,8 +44,8 @@ class MutexOwner
3844};
3945
4046
41- // since every object stores a pointer on its parent,
42- // copying of this object is prohibited and moving is taken with care
47+ // / since every object stores a pointer on its parent,
48+ // / copying of this object is prohibited and moving is taken with care
4349struct ObjectChildrenHolder
4450{
4551 ObjectChildrenHolder () = default ;
@@ -49,17 +55,17 @@ struct ObjectChildrenHolder
4955 MRMESH_API ObjectChildrenHolder & operator = ( ObjectChildrenHolder && ) noexcept ;
5056 MRMESH_API ~ObjectChildrenHolder ();
5157
52- // returns the amount of memory this object occupies on heap,
53- // including the memory of all recognized children
58+ // / returns the amount of memory this object occupies on heap,
59+ // / including the memory of all recognized children
5460 [[nodiscard]] size_t heapBytes () const ;
5561
5662protected:
5763 Object * parent_ = nullptr ;
58- std::vector< std::shared_ptr< Object > > children_; // recognized ones
59- std::vector< std::weak_ptr< Object > > bastards_; // unrecognized children to hide from the pubic
64+ std::vector< std::shared_ptr< Object > > children_; // / recognized ones
65+ std::vector< std::weak_ptr< Object > > bastards_; // / unrecognized children to hide from the pubic
6066};
6167
62- // named object in the data model
68+ // / named object in the data model
6369class MRMESH_CLASS Object : public ObjectChildrenHolder
6470{
6571public:
@@ -79,158 +85,159 @@ class MRMESH_CLASS Object : public ObjectChildrenHolder
7985 const std::string & name () const { return name_; }
8086 virtual void setName ( std::string name ) { name_ = std::move ( name ); }
8187
82- // finds a direct child by name
88+ // / finds a direct child by name
8389 MRMESH_API std::shared_ptr<const Object> find ( const std::string_view & name ) const ;
8490 std::shared_ptr<Object> find ( const std::string_view & name ) { return std::const_pointer_cast<Object>( const_cast <const Object*>( this )->find ( name ) ); }
8591
86- // finds a direct child by name and type
92+ // / finds a direct child by name and type
8793 template <typename T>
8894 std::shared_ptr<const T> find ( const std::string_view & name ) const ;
8995 template <typename T>
9096 std::shared_ptr<T> find ( const std::string_view & name ) { return std::const_pointer_cast<T>( const_cast <const Object*>( this )->find <T>( name ) ); }
9197
92- // this space to parent space transformation (to world space if no parent)
98+ // / this space to parent space transformation (to world space if no parent)
9399 const AffineXf3f & xf () const { return xf_; }
94100 MRMESH_API virtual void setXf ( const AffineXf3f& xf );
95101
96- // this space to world space transformation
102+ // / this space to world space transformation
97103 MRMESH_API AffineXf3f worldXf () const ;
98104 MRMESH_API void setWorldXf ( const AffineXf3f& xf );
99105
100- // scale object size (all point positions)
106+ // / scale object size (all point positions)
101107 MRMESH_API virtual void applyScale ( float scaleFactor );
102108
103- // returns all viewports where this object is visible together with all its parents
109+ // / returns all viewports where this object is visible together with all its parents
104110 MRMESH_API ViewportMask globalVisibilityMask () const ;
105- // returns true if this object is visible together with all its parents in any of given viewports
111+ // / returns true if this object is visible together with all its parents in any of given viewports
106112 bool globalVisibilty ( ViewportMask viewportMask = ViewportMask::any() ) const { return !( globalVisibilityMask () & viewportMask ).empty (); }
107- // if true sets all predecessors visible, otherwise sets this object invisible
113+ // / if true sets all predecessors visible, otherwise sets this object invisible
108114 MRMESH_API void setGlobalVisibilty ( bool on, ViewportMask viewportMask = ViewportMask::any() );
109115
110- // object properties lock for UI
116+ // / object properties lock for UI
111117 const bool isLocked () const { return locked_; }
112118 virtual void setLocked ( bool on ) { locked_ = on; }
113119
114- // returns parent object in the tree
120+ // / returns parent object in the tree
115121 const Object * parent () const { return parent_; }
116122 Object * parent () { return parent_; }
117123
118- // return true if given object is ancestor of this one, false otherwise
124+ // / return true if given object is ancestor of this one, false otherwise
119125 MRMESH_API bool isAncestor ( const Object* ancestor ) const ;
120126
121- // removes this from its parent children list
122- // returns false if it was already orphan
127+ // / removes this from its parent children list
128+ // / returns false if it was already orphan
123129 MRMESH_API virtual bool detachFromParent ();
124- // an object can hold other sub-objects
130+ // / an object can hold other sub-objects
125131 const std::vector<std::shared_ptr<Object>>& children () { return children_; }
126132 const std::vector<std::shared_ptr<const Object>>& children () const { return reinterpret_cast <const std::vector< std::shared_ptr< const Object > > &>( children_ ); }
127- // adds given object at the end of children (recognized or not);
128- // returns false if it was already child of this, of if given pointer is empty
133+ // / adds given object at the end of children (recognized or not);
134+ // / returns false if it was already child of this, of if given pointer is empty
129135 MRMESH_API virtual bool addChild ( std::shared_ptr<Object> child, bool recognizedChild = true );
130- // adds given object in the recognized children before existingChild;
131- // if newChild was already among this children then moves it just before existingChild keeping the order of other children intact;
132- // returns false if newChild is nullptr, or existingChild is not a child of this
136+ // / adds given object in the recognized children before existingChild;
137+ // / if newChild was already among this children then moves it just before existingChild keeping the order of other children intact;
138+ // / returns false if newChild is nullptr, or existingChild is not a child of this
133139 MRMESH_API virtual bool addChildBefore ( std::shared_ptr<Object> newChild, const std::shared_ptr<Object> & existingChild );
134- // returns false if it was not child of this
140+ // / returns false if it was not child of this
135141 bool removeChild ( const std::shared_ptr<Object>& child ) { return removeChild ( child.get () ); }
136142 MRMESH_API virtual bool removeChild ( Object* child );
137- // detaches all recognized children from this, keeping all unrecognized ones
143+ // / detaches all recognized children from this, keeping all unrecognized ones
138144 MRMESH_API virtual void removeAllChildren ();
139145 // / sort recognized children by name
140146 MRMESH_API void sortChildren ();
141147
142- // selects the object, returns true if value changed, otherwise returns false
148+ // / selects the object, returns true if value changed, otherwise returns false
143149 MRMESH_API virtual bool select ( bool on );
144150 bool isSelected () const { return selected_; }
145151
146- // ancillary object is an object hidden (in scene menu) from a regular user
147- // such objects cannot be selected, and if it has been selected, it is unselected when turn ancillary
152+ // / ancillary object is an object hidden (in scene menu) from a regular user
153+ // / such objects cannot be selected, and if it has been selected, it is unselected when turn ancillary
148154 MRMESH_API virtual void setAncillary ( bool ancillary );
149155 bool isAncillary () const { return ancillary_; }
150156
151- // sets the object visible in the viewports specified by the mask (by default in all viewports)
157+ // / sets the object visible in the viewports specified by the mask (by default in all viewports)
152158 MRMESH_API void setVisible ( bool on, ViewportMask viewportMask = ViewportMask::all() );
153- // checks whether the object is visible in any of the viewports specified by the mask (by default in any viewport)
159+ // / checks whether the object is visible in any of the viewports specified by the mask (by default in any viewport)
154160 bool isVisible ( ViewportMask viewportMask = ViewportMask::any() ) const { return !( visibilityMask_ & viewportMask ).empty (); }
155- // specifies object visibility as bitmask of viewports
161+ // / specifies object visibility as bitmask of viewports
156162 virtual void setVisibilityMask ( ViewportMask viewportMask ) { visibilityMask_ = viewportMask; }
157- // gets object visibility as bitmask of viewports
163+ // / gets object visibility as bitmask of viewports
158164 ViewportMask visibilityMask () const { return visibilityMask_; }
159165
160- // this method virtual because others data model types could have dirty flags or something
166+ // / this method virtual because others data model types could have dirty flags or something
161167 virtual bool getRedrawFlag ( ViewportMask ) const { return needRedraw_; }
162168 void resetRedrawFlag () const { needRedraw_ = false ; }
163169
164- // clones all tree of this object (except ancillary and unrecognized children)
170+ // / clones all tree of this object (except ancillary and unrecognized children)
165171 MRMESH_API std::shared_ptr<Object> cloneTree () const ;
166- // clones current object only, without parent and/or children
172+ // / clones current object only, without parent and/or children
167173 MRMESH_API virtual std::shared_ptr<Object> clone () const ;
168- // clones all tree of this object (except ancillary and unrecognied children)
169- // clones only pointers to mesh, points or voxels
174+ // / clones all tree of this object (except ancillary and unrecognied children)
175+ // / clones only pointers to mesh, points or voxels
170176 MRMESH_API std::shared_ptr<Object> shallowCloneTree () const ;
171- // clones current object only, without parent and/or children
172- // clones only pointers to mesh, points or voxels
177+ // / clones current object only, without parent and/or children
178+ // / clones only pointers to mesh, points or voxels
173179 MRMESH_API virtual std::shared_ptr<Object> shallowClone () const ;
174180
175- // return several info lines that can better describe object in the UI
181+ // / return several info lines that can better describe object in the UI
176182 virtual std::vector<std::string> getInfoLines () const { return {}; }
177183
178- // creates futures that save this object subtree:
179- // models in the folder by given path and
180- // fields in given JSON
181- tl::expected<std::vector<std::future<void >>, std::string> serializeRecursive ( const std::filesystem::path& path, Json::Value& root,
182- int childId ) const ; // childId is its ordinal number within the parent
184+ // / creates futures that save this object subtree:
185+ // / models in the folder by given path and
186+ // / fields in given JSON
187+ // / \param childId is its ordinal number within the parent
188+ tl::expected<std::vector<std::future<void >>, std::string> serializeRecursive ( const std::filesystem::path& path,
189+ Json::Value& root, int childId ) const ;
183190
184- // loads subtree into this Object
185- // models from the folder by given path and
186- // fields from given JSON
191+ // / loads subtree into this Object
192+ // / models from the folder by given path and
193+ // / fields from given JSON
187194 tl::expected<void , std::string> deserializeRecursive ( const std::filesystem::path& path, const Json::Value& root );
188195
189- // swaps this object with other
190- // note: do not swap object signals, so listeners will get notifications from swapped object
191- // requires implementation of `swapBase_` and `swapSignals_` (if type has signals)
196+ // / swaps this object with other
197+ // / note: do not swap object signals, so listeners will get notifications from swapped object
198+ // / requires implementation of `swapBase_` and `swapSignals_` (if type has signals)
192199 MRMESH_API void swap ( Object& other );
193200
194- // returns bounding box of this object in world coordinates
195- virtual Box3f getWorldBox () const { return {}; } // empty box
196- // returns bounding box of this object and all children visible in given viewports in world coordinates
201+ // / returns bounding box of this object in world coordinates
202+ virtual Box3f getWorldBox () const { return {}; } // / empty box
203+ // / returns bounding box of this object and all children visible in given viewports in world coordinates
197204 MRMESH_API Box3f getWorldTreeBox ( ViewportMask viewportMask = ViewportMask::any() ) const ;
198205
199- // returns the amount of memory this object occupies on heap
206+ // / returns the amount of memory this object occupies on heap
200207 [[nodiscard]] MRMESH_API virtual size_t heapBytes () const ;
201208
202- // signal about xf changing, triggered in setXf and setWorldXf
209+ // / signal about xf changing, triggered in setXf and setWorldXf
203210 using XfChangedSignal = boost::signals2::signal<void () >;
204211 XfChangedSignal xfChangedSignal;
205212protected:
206213 struct ProtectedStruct { explicit ProtectedStruct () = default; };
207214public:
208- // this ctor is public only for std::make_shared used inside clone()
215+ // / \note this ctor is public only for std::make_shared used inside clone()
209216 Object ( ProtectedStruct, const Object& obj ) : Object( obj ) {}
210217
211218protected:
212- // user should not be able to call copy implicitly, use clone() function instead
219+ // / user should not be able to call copy implicitly, use clone() function instead
213220 MRMESH_API Object ( const Object& obj );
214221
215- // swaps whole object (signals too)
222+ // / swaps whole object (signals too)
216223 MRMESH_API virtual void swapBase_ ( Object& other );
217- // swaps signals, used in `swap` function to return back signals after `swapBase_`
218- // pls call Parent::swapSignals_ first when overriding this function
224+ // / swaps signals, used in `swap` function to return back signals after `swapBase_`
225+ // / \note pls call Parent::swapSignals_ first when overriding this function
219226 MRMESH_API virtual void swapSignals_ ( Object& other );
220227
221- // Creates future to save object model (e.g. mesh) in given file
222- // path is full filename without extension
228+ // / Creates future to save object model (e.g. mesh) in given file
229+ // / path is full filename without extension
223230 MRMESH_API virtual tl::expected<std::future<void >, std::string> serializeModel_ ( const std::filesystem::path& path ) const ;
224231
225- // Write parameters to given Json::Value,
226- // if you override this method, please call Base::serializeFields_(root) in the beginning
232+ // / Write parameters to given Json::Value,
233+ // / \note if you override this method, please call Base::serializeFields_(root) in the beginning
227234 MRMESH_API virtual void serializeFields_ ( Json::Value& root ) const ;
228235
229- // Reads model from file
236+ // / Reads model from file
230237 MRMESH_API virtual tl::expected<void , std::string> deserializeModel_ ( const std::filesystem::path& path );
231238
232- // Reads parameters from json value
233- // if you override this method, please call Base::deserializeFields_(root) in the beginning
239+ // / Reads parameters from json value
240+ // / \note if you override this method, please call Base::deserializeFields_(root) in the beginning
234241 MRMESH_API virtual void deserializeFields_ ( const Json::Value& root );
235242
236243 std::string name_;
@@ -253,4 +260,6 @@ std::shared_ptr<const T> Object::find( const std::string_view & name ) const
253260 return {}; // not found
254261}
255262
256- } // namespace MR
263+ // / \}
264+
265+ } // /namespace MR
0 commit comments