NorMIT-nav  2023.01.05-dev+develop.0da12
An IGT application
cxMeshTextureData.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 "cxMeshTextureData.h"
14 #include "cxDoubleProperty.h"
15 #include "cxBoolProperty.h"
16 
17 namespace cx
18 {
20  : mPatientModelService(patientModelService)
21  , mCylinderText("Cylinder")
22  , mPlaneText("Plane")
23  , mSphereText("Sphere")
24 {
25  this->initialize();
26 }
27 
28 void MeshTextureData::addXml(QDomNode &dataNode)
29 {
30  for (unsigned i=0; i<mProperties.size(); ++i)
31  {
32  XmlOptionItem item(mProperties[i]->getUid(), dataNode.toElement());
33  item.writeVariant(mProperties[i]->getValueAsVariant());
34  }
35 }
36 
37 void MeshTextureData::parseXml(QDomNode &dataNode)
38 {
39  for (unsigned i=0; i<mProperties.size(); ++i)
40  {
41  XmlOptionItem item(mProperties[i]->getUid(), dataNode.toElement());
42  QVariant orgval = mProperties[i]->getValueAsVariant();
43  mProperties[i]->setValueFromVariant(item.readVariant(orgval));
44  }
45 }
46 
47 void MeshTextureData::addProperty(PropertyPtr property)
48 {
49  mProperties.push_back(property);
50  connect(property.get(), &Property::changed, this, &MeshTextureData::changed);
51 }
52 
53 void MeshTextureData::initialize()
54 {
55  mTextureImage = StringPropertySelectImage::New(mPatientModelService);
56  mTextureImage->setValueName("Texture image");
57  mTextureImage->setHelp("Select an imported 2D image to use as texture.");
58  mTextureImage->setOnly2DImagesFilter(true);
59  this->addProperty(mTextureImage);
60 
61  mTextureShape = StringProperty::initialize("texture_type", "Texture shape",
62  "The texture is applied in predefined geometric shapes. Select the shape which gives the best fit to your mesh.",
63  "Cylinder",
64  QStringList()
65  << this->getCylinderText()
66  << this->getPlaneText()
67  << this->getSphereText());
68  this->addProperty(mTextureShape);
69 
70  mScaleX = DoubleProperty::initialize("texture_scale_X", "Scale X", "How many times to draw the image along the X axis.", 1, DoubleRange(1,100000,1), 0);
71  this->addProperty(mScaleX);
72 
73  mScaleY = DoubleProperty::initialize("texture_scale_Y", "Scale Y", "How many times to draw the image along the Y axis.", 1, DoubleRange(1,100000,1), 0);
74  this->addProperty(mScaleY);
75 
76  mPositionX = DoubleProperty::initialize("texture_position_X", "Position X", "Where to start drawing the image along the X axis.", 0, DoubleRange(-100000,100000,0.01), 2);
77  this->addProperty(mPositionX);
78 
79  mPositionY = DoubleProperty::initialize("texture_position_Y", "Position Y", "Where to start drawing the image along the Y axis.", 0, DoubleRange(-100000,100000,0.01), 2);
80  this->addProperty(mPositionY);
81 
82  mRepeat = BoolProperty::initialize("repeat", "Repeat", "Repeat texture over surface", true);
83  this->addProperty(mRepeat);
84 }
85 
87 {
88  return mSphereText;
89 }
90 
92 {
93  return mPlaneText;
94 }
95 
97 {
98  return mCylinderText;
99 }
100 
102 {
103  return mPositionY;
104 }
105 
107 {
108  return mPositionX;
109 }
110 
112 {
113  return mRepeat;
114 }
115 
116 std::vector<PropertyPtr> MeshTextureData::getProperties() const
117 {
118  return mProperties;
119 }
120 
122 {
123  return mScaleY;
124 }
125 
127 {
128  return mScaleX;
129 }
130 
132 {
133  return mTextureImage;
134 }
135 
137 {
138  return mTextureShape;
139 }
140 
141 } // namespace cx
cx::BoolProperty::initialize
static BoolPropertyPtr initialize(const QString &uid, QString name, QString help, bool value, QDomNode root=QDomNode())
Definition: cxBoolProperty.cpp:30
cx::MeshTextureData::getPositionX
DoublePropertyPtr getPositionX() const
Definition: cxMeshTextureData.cpp:106
cx::XmlOptionItem::writeVariant
void writeVariant(const QVariant &val)
Definition: cxXmlOptionItem.cpp:172
cx::MeshTextureData::getTextureImage
StringPropertySelectImagePtr getTextureImage() const
Definition: cxMeshTextureData.cpp:131
cx::MeshTextureData::getCylinderText
QString getCylinderText() const
Definition: cxMeshTextureData.cpp:96
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cx::Property::changed
void changed()
emit when the underlying data value is changed: The user interface will be updated.
cx::BoolPropertyPtr
boost::shared_ptr< class BoolProperty > BoolPropertyPtr
Definition: cxPlusConnectWidget.h:29
cx::MeshTextureData::parseXml
void parseXml(QDomNode &dataNode)
Definition: cxMeshTextureData.cpp:37
cx::MeshTextureData::getPlaneText
QString getPlaneText() const
Definition: cxMeshTextureData.cpp:91
cx::StringPropertyPtr
boost::shared_ptr< class StringProperty > StringPropertyPtr
Definition: cxVideoConnectionWidget.h:42
cxDoubleProperty.h
cx::PropertyPtr
boost::shared_ptr< class Property > PropertyPtr
Definition: cxLocalServerStreamerServer.h:25
cx::DoubleProperty::initialize
static DoublePropertyPtr initialize(const QString &uid, QString name, QString help, double value, DoubleRange range, int decimals, QDomNode root=QDomNode())
Definition: cxDoubleProperty.cpp:30
cx::DoublePropertyPtr
boost::shared_ptr< class DoubleProperty > DoublePropertyPtr
Definition: cxReconstructionMethodService.h:33
cx::StringPropertySelectImage::New
static StringPropertySelectImagePtr New(PatientModelServicePtr patientModelService)
Definition: cxSelectDataStringProperty.h:76
cx::XmlOptionItem::readVariant
QVariant readVariant(const QVariant &defval=QVariant()) const
Definition: cxXmlOptionItem.cpp:163
cx::StringPropertySelectImagePtr
boost::shared_ptr< class StringPropertySelectImage > StringPropertySelectImagePtr
Definition: cxRegisterI2IWidget.h:23
cx::XmlOptionItem
Helper class for storing one string value in an xml document.
Definition: cxXmlOptionItem.h:38
cx::PatientModelServicePtr
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
Definition: cxLogicManager.h:25
cx::MeshTextureData::getSphereText
QString getSphereText() const
Definition: cxMeshTextureData.cpp:86
cx::MeshTextureData::getTextureShape
StringPropertyPtr getTextureShape() const
Definition: cxMeshTextureData.cpp:136
cx::MeshTextureData::getScaleY
DoublePropertyPtr getScaleY() const
Definition: cxMeshTextureData.cpp:121
cx::MeshTextureData::getProperties
std::vector< PropertyPtr > getProperties() const
Definition: cxMeshTextureData.cpp:116
cx::MeshTextureData::getScaleX
DoublePropertyPtr getScaleX() const
Definition: cxMeshTextureData.cpp:126
cx::MeshTextureData::addXml
void addXml(QDomNode &dataNode)
Definition: cxMeshTextureData.cpp:28
cxMeshTextureData.h
cx::StringProperty::initialize
static StringPropertyPtr initialize(const QString &uid, QString name, QString help, QString value, QStringList range, QDomNode root=QDomNode())
Definition: cxStringProperty.cpp:29
cx::MeshTextureData::getPositionY
DoublePropertyPtr getPositionY() const
Definition: cxMeshTextureData.cpp:101
cx::MeshTextureData::MeshTextureData
MeshTextureData(PatientModelServicePtr patientModelService)
Definition: cxMeshTextureData.cpp:19
cxBoolProperty.h
cx::MeshTextureData::changed
void changed()
cx::MeshTextureData::getRepeat
BoolPropertyPtr getRepeat() const
Definition: cxMeshTextureData.cpp:111