Computer Assisted Medical Intervention Tool Kit  version 6.0
Loading...
Searching...
No Matches
Property.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 PROPERTY_H
27#define PROPERTY_H
28
29#include <QVariant>
30#include <QStringList>
31#include <QIcon>
32
33#include "CamiTKAPI.h"
34
35namespace camitk {
36
307
308public:
317 Property(QString name, const QVariant& variant, QString description, QString unit);
318
321
323 virtual ~Property() = default;
324
326 const QString& getName() const;
327
329 const QVariant& getInitialValue() const;
330
332 void setReadOnly(bool);
333
335 bool getReadOnly() const;
336
338 void setDescription(QString);
339
341 const QString& getDescription() const;
342
344 void setUnit(QString);
345
347 const QString& getUnit() const;
348
363 void setAttribute(const QString& attribute, const QVariant& value);
364
376 QVariant getAttribute(QString attName);
377
379 QStringList getAttributeList();
380
384 void setEnumTypeName(QString);
385
395 void setEnumTypeName(QString enumTypeName, QObject* objectDeclaringTheEnum);
396
398 QString getEnumTypeName() const;
399
407 QString getEnumValueAsString(const QObject* objectDeclaringTheEnum) const;
408
410 QMap<int, QIcon> getEnumIcons() const;
411
413 void setEnumIcons(const QMap<int, QIcon>& enumIcons);
414
419 void setGroupName(QString groupName);
420
424 QString getGroupName() const;
425
436 static Property* getProperty(QObject* object, QString name);
437
443 static QJsonObject getPropertyInformation(QObject* object, QString name);
444
446 static QString getValueAsString(QVariant v);
447
448private:
450 QString name;
451
453 QString groupName;
454
460 QVariant initialValue;
461
463 QString description;
464
466 QString unit;
467
469 bool readOnly;
470
472 QMap<QString, QVariant> attributeValues;
473
475 QString enumTypeName;
476
478 QMap<int, QIcon> enumIcons;
479};
480
481}
482
483#endif // PROPERTY_H
#define CAMITK_API
Definition CamiTKAPI.h:66
QString getEnumTypeName() const
Definition Property.cpp:123
void setAttribute(const QString &attribute, const QVariant &value)
Set a given property for this attribute.
Definition Property.cpp:203
static QString getValueAsString(QVariant v)
Transform a QVariant to a QString representation.
Definition Property.cpp:325
void setReadOnly(bool)
set this property as read-only
Definition Property.cpp:93
QString getGroupName() const
get this property subgroup's name
Definition Property.cpp:178
const QString & getDescription() const
get the description
Definition Property.cpp:108
void setUnit(QString)
set the unit
Definition Property.cpp:113
void setGroupName(QString groupName)
Set the group name.
Definition Property.cpp:183
QString getEnumValueAsString(const QObject *objectDeclaringTheEnum) const
Utility method to get the current property value as a string.
Definition Property.cpp:154
const QString & getName() const
get the name of the property
Definition Property.cpp:83
const QString & getUnit() const
get the unit
Definition Property.cpp:118
virtual ~Property()=default
Destructor.
void setDescription(QString)
set the description (can be rich text)
Definition Property.cpp:103
QStringList getAttributeList()
returns the list of attribute names that are specific to this property
Definition Property.cpp:198
QVariant getAttribute(QString attName)
get the current value of a given attribute, see setAttribute() if the attribute attName was never set...
Definition Property.cpp:188
void setEnumIcons(const QMap< int, QIcon > &enumIcons)
set the icons for all the enums
Definition Property.cpp:173
static QJsonObject getPropertyInformation(QObject *object, QString name)
Get the CamiTK property information as QJsonObject If name is the name of a CamiTK property of the gi...
Definition Property.cpp:233
void setEnumTypeName(QString)
if the property's type is an enum, set the name of the registered Qt Enum.
Definition Property.cpp:128
bool getReadOnly() const
Definition Property.cpp:98
Property(QString name, const QVariant &variant, QString description, QString unit)
Constructor.
Definition Property.cpp:40
static Property * getProperty(QObject *object, QString name)
get the camitk::Property decoration of a named property of the given QObject or nullptr if object doe...
Definition Property.cpp:209
const QVariant & getInitialValue() const
return the initial (default) value
Definition Property.cpp:88
QMap< int, QIcon > getEnumIcons() const
get the enum icons
Definition Property.cpp:168
Definition Action.cpp:40