NorMIT-nav  2023.01.05-dev+develop.0da12
An IGT application
cxColorProperty.cpp
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
11 
12 
13 #include "cxColorProperty.h"
14 #include "cxVector3D.h"
15 #include "cxTypeConversions.h"
16 
17 
18 namespace cx
19 {
20 
24 ColorPropertyPtr ColorProperty::initialize(const QString& uid, QString name, QString help, QColor value,
25  QDomNode root)
26 {
27  ColorPropertyPtr retval(new ColorProperty());
28  retval->mUid = uid;
29  retval->mName = name.isEmpty() ? uid : name;
30  retval->mHelp = help;
31  retval->mStore = XmlOptionItem(uid, root.toElement());
32  retval->mValue = string2color(retval->mStore.readValue(color2string(value)));
33  return retval;
34 }
35 
37 {
38  return mName;
39 }
40 
41 QString ColorProperty::getUid() const
42 {
43  return mUid;
44 }
45 
46 QString ColorProperty::getHelp() const
47 {
48  return mHelp;
49 }
50 
52 {
53  return mValue;
54 }
55 
56 bool ColorProperty::setValue(QColor val)
57 {
58  if (val == mValue)
59  return false;
60 
61  mValue = val;
62  mStore.writeValue(color2string(val));
63  emit valueWasSet();
64  emit changed();
65  return true;
66 }
67 
68 } // namespace cx
69 
cx::ColorPropertyPtr
boost::shared_ptr< class ColorProperty > ColorPropertyPtr
Definition: cxForwardDeclarations.h:144
cx::ColorProperty::getUid
virtual QString getUid() const
Definition: cxColorProperty.cpp:41
cx::ColorProperty::getValue
virtual QColor getValue() const
get the data value.
Definition: cxColorProperty.cpp:51
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
string2color
QColor string2color(QString input, QColor defaultValue)
Definition: cxTypeConversions.cpp:64
cx::Property::changed
void changed()
emit when the underlying data value is changed: The user interface will be updated.
cxVector3D.h
cx::ColorProperty::initialize
static ColorPropertyPtr initialize(const QString &uid, QString name, QString help, QColor value, QDomNode root=QDomNode())
Definition: cxColorProperty.cpp:24
color2string
QString color2string(QColor color)
Definition: cxTypeConversions.cpp:52
cx::ColorProperty
Definition: cxColorProperty.h:32
cx::XmlOptionItem
Helper class for storing one string value in an xml document.
Definition: cxXmlOptionItem.h:38
cx::ColorProperty::getDisplayName
virtual QString getDisplayName() const
name of data entity. Used for display to user.
Definition: cxColorProperty.cpp:36
cxTypeConversions.h
cx::ColorProperty::setValue
virtual bool setValue(QColor value)
set the data value.
Definition: cxColorProperty.cpp:56
cx::ColorProperty::getHelp
virtual QString getHelp() const
return a descriptive help string for the data, used for example as a tool tip.
Definition: cxColorProperty.cpp:46
cx::XmlOptionItem::writeValue
void writeValue(const QString &val)
Definition: cxXmlOptionItem.cpp:189
cx::ColorProperty::valueWasSet
void valueWasSet()
cxColorProperty.h