Skip to content

Commit 39d5f6e

Browse files
authored
DataModel (+ Holders & Features) group comments reworked in doxygen format (#147)
1 parent 0bf98d7 commit 39d5f6e

21 files changed

+374
-337
lines changed

source/MRMesh/MRCircleObject.h

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@
44

55
namespace MR
66
{
7+
/// \defgroup FeaturesGroup Features
8+
/// \ingroup DataModelGroup
79

8-
// Object to show sphere feature, position and radius are controlled by xf
10+
/// Object to show sphere feature, position and radius are controlled by xf
11+
/// \ingroup FeaturesGroup
912
class MRMESH_CLASS CircleObject : public ObjectLinesHolder
1013
{
1114
public:
12-
// Creates simple sphere object with center in zero and radius - 1
15+
/// Creates simple sphere object with center in zero and radius - 1
1316
MRMESH_API CircleObject();
14-
// Finds best sphere to approx given points
17+
/// Finds best sphere to approx given points
1518
MRMESH_API CircleObject( const std::vector<Vector3f>& pointsToApprox );
1619

1720
CircleObject( CircleObject&& ) noexcept = default;
@@ -21,7 +24,7 @@ class MRMESH_CLASS CircleObject : public ObjectLinesHolder
2124
constexpr static const char* TypeName() noexcept { return "CircleObject"; }
2225
virtual const char* typeName() const override { return TypeName(); }
2326

24-
// this ctor is public only for std::make_shared used inside clone()
27+
/// \note this ctor is public only for std::make_shared used inside clone()
2528
CircleObject( ProtectedStruct, const CircleObject& obj ) : CircleObject( obj )
2629
{}
2730

@@ -30,22 +33,22 @@ class MRMESH_CLASS CircleObject : public ObjectLinesHolder
3033
MRMESH_API virtual std::shared_ptr<Object> clone() const override;
3134
MRMESH_API virtual std::shared_ptr<Object> shallowClone() const override;
3235

33-
// calculates radius from xf
36+
/// calculates radius from xf
3437
MRMESH_API float getRadius() const;
35-
// calculates center from xf
38+
/// calculates center from xf
3639
MRMESH_API Vector3f getCenter() const;
37-
// calculates normal from xf
40+
/// calculates normal from xf
3841
MRMESH_API Vector3f getNormal() const;
39-
// updates xf to fit given radius
42+
/// updates xf to fit given radius
4043
MRMESH_API void setRadius( float radius );
41-
// updates xf to fit given center
44+
/// updates xf to fit given center
4245
MRMESH_API void setCenter( const Vector3f& center );
43-
// updates xf to fit given normal
46+
/// updates xf to fit given normal
4447
MRMESH_API void setNormal( const Vector3f& normal );
4548
protected:
4649
CircleObject( const CircleObject& other ) = default;
4750

48-
// swaps this object with other
51+
/// swaps this object with other
4952
MRMESH_API virtual void swapBase_( Object& other ) override;
5053

5154
MRMESH_API virtual void serializeFields_( Json::Value& root ) const override;

source/MRMesh/MRLineObject.h

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
namespace MR
66
{
77

8-
// Object to show plane feature
8+
/// Object to show plane feature
9+
/// \ingroup FeaturesGroup
910
class MRMESH_CLASS LineObject : public ObjectLinesHolder
1011
{
1112
public:
12-
// Creates simple plane object
13+
/// Creates simple plane object
1314
MRMESH_API LineObject();
14-
// Finds best plane to approx given points
15+
/// Finds best plane to approx given points
1516
MRMESH_API LineObject( const std::vector<Vector3f>& pointsToApprox );
1617

1718
LineObject( LineObject&& ) noexcept = default;
@@ -21,7 +22,7 @@ class MRMESH_CLASS LineObject : public ObjectLinesHolder
2122
constexpr static const char* TypeName() noexcept { return "LineObject"; }
2223
virtual const char* typeName() const override { return TypeName(); }
2324

24-
// this ctor is public only for std::make_shared used inside clone()
25+
/// \note this ctor is public only for std::make_shared used inside clone()
2526
LineObject( ProtectedStruct, const LineObject& obj ) : LineObject( obj )
2627
{}
2728

@@ -30,20 +31,20 @@ class MRMESH_CLASS LineObject : public ObjectLinesHolder
3031
MRMESH_API virtual std::shared_ptr<Object> clone() const override;
3132
MRMESH_API virtual std::shared_ptr<Object> shallowClone() const override;
3233

33-
// calculates direction from xf
34+
/// calculates direction from xf
3435
MRMESH_API Vector3f getDirection() const;
35-
// calculates center from xf
36+
/// calculates center from xf
3637
MRMESH_API Vector3f getCenter() const;
37-
// updates xf to fit given normal
38+
/// updates xf to fit given normal
3839
MRMESH_API void setDirection( const Vector3f& normal );
39-
// updates xf to fit given center
40+
/// updates xf to fit given center
4041
MRMESH_API void setCenter( const Vector3f& center );
41-
// updates xf to scale size
42+
/// updates xf to scale size
4243
MRMESH_API void setSize( float size );
4344
protected:
4445
LineObject( const LineObject& other ) = default;
4546

46-
// swaps this object with other
47+
/// swaps this object with other
4748
MRMESH_API virtual void swapBase_( Object& other ) override;
4849

4950
MRMESH_API virtual void serializeFields_( Json::Value& root ) const override;

source/MRMesh/MRObject.h

Lines changed: 82 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,13 @@ class Value;
2323
namespace 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
2733
class MutexOwner
2834
{
2935
public:
@@ -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
4349
struct 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

5662
protected:
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
6369
class MRMESH_CLASS Object : public ObjectChildrenHolder
6470
{
6571
public:
@@ -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;
205212
protected:
206213
struct ProtectedStruct{ explicit ProtectedStruct() = default; };
207214
public:
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

211218
protected:
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

Comments
 (0)