Computer Assisted Medical Intervention Tool Kit  version 6.0
Loading...
Searching...
No Matches
PropertyObject.h
Go to the documentation of this file.
1/*****************************************************************************
2 * $CAMITK_LICENCE_BEGIN$
3 *
4 * CamiTK - Computer Assisted Medical Intervention ToolKit
5 * (c) 2001-2025 Univ. Grenoble Alpes, CNRS, Grenoble INP - UGA, TIMC, 38000 Grenoble, France
6 *
7 * Visit http://camitk.imag.fr for more information
8 *
9 * This file is part of CamiTK.
10 *
11 * CamiTK is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
14 *
15 * CamiTK is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public License
21 * version 3 along with CamiTK. If not, see <http://www.gnu.org/licenses/>.
22 *
23 * $CAMITK_LICENCE_END$
24 ****************************************************************************/
25
26#ifndef PROPERTYOBJECT_H
27#define PROPERTYOBJECT_H
28
29// Qt includes
30#include <QObject>
31
32// CamiTK includes
33#include "CamiTKAPI.h"
34#include "Property.h"
36
37namespace camitk {
38
65 saveToSettings("mySection")
66 \endcode
67
68 See the Application class for an example of a property object load/save to settings.
69
70 * @see ObjectController, Property
71 */
72class CAMITK_API PropertyObject : public QObject, public InterfacePersistence {
73
74 Q_OBJECT
75
76public:
81 PropertyObject(QString name);
82
84 ~PropertyObject() override;
85
96 virtual bool addProperty(Property*);
97
108 Q_INVOKABLE virtual const camitk::Property* getProperty(QString name) const;
109 Q_INVOKABLE virtual camitk::Property* getProperty(QString name);
110
114 virtual void removeProperty(Property*);
115
117 virtual unsigned int getNumberOfProperties() const;
118
120 virtual QString getPropertyName(unsigned int index) const;
121
123 virtual QVariant getPropertyValue(unsigned int index);
124
126 virtual QVariant getPropertyValue(const QString name) const;
127
129 void loadFromSettings(const QString& settingGroupName);
130
132 void saveToSettings(const QString& settingGroupName);
133
135 static QString toCamelCase(const QString&);
136
143 virtual QVariant toVariant() const override;
144
146 virtual void fromVariant(const QVariant&) override;
147
149 virtual QUuid getUuid() const override;
150
152 virtual bool setUuid(QUuid) override;
154
155private:
159 QMap<QString, Property*> propertiesMap;
161};
162
163}
164
165#endif // PROPERTYOBJECT_H
#define CAMITK_API
Definition CamiTKAPI.h:66
Interface for all objects that should be serialized by the PersistenceManager.
Definition InterfacePersistence.h:38
virtual unsigned int getNumberOfProperties() const
get the current number of property
Definition PropertyObject.cpp:84
virtual void removeProperty(Property *)
Remove a CamiTK property of this object.
Definition PropertyObject.cpp:78
void saveToSettings(const QString &settingGroupName)
save setting in the given group name using all the property values
Definition PropertyObject.cpp:262
virtual Q_INVOKABLE const camitk::Property * getProperty(QString name) const
Get a Property given its name.
Definition PropertyObject.cpp:69
void loadFromSettings(const QString &settingGroupName)
initializes all property values from setting values found in the given group name
Definition PropertyObject.cpp:165
virtual bool addProperty(Property *)
Tag a new CamiTK property to this object.
Definition PropertyObject.cpp:60
static QString toCamelCase(const QString &)
utility method to transform property name to camel case. Quite useful to make sure all settings are s...
Definition PropertyObject.cpp:118
virtual bool setUuid(QUuid) override
Set the unique ID of the propertyObject (usually the uuid of the containing object).
Definition PropertyObject.cpp:151
virtual QVariant getPropertyValue(unsigned int index)
get the value of the property at the given index, a non valid QVariant if the index is out of bounds ...
Definition PropertyObject.cpp:99
virtual QString getPropertyName(unsigned int index) const
get the name of the property at the given index, null string if index is out of bounds (i....
Definition PropertyObject.cpp:89
virtual QUuid getUuid() const override
Get the unique ID of the propertyObject (usually the uuid of the containing object).
Definition PropertyObject.cpp:146
virtual QVariant toVariant() const override
Definition PropertyObject.cpp:130
virtual void fromVariant(const QVariant &) override
Load data from a QVariant to initialize the current object.
Definition PropertyObject.cpp:141
PropertyObject(QString name)
Default constructor.
Definition PropertyObject.cpp:43
This class describes a property that can be used in components and actions or any class that needs to...
Definition Property.h:306
Definition Action.cpp:40