26 #include <dtkCoreSupport/dtkAbstractData.h>
27 #include <dtkCoreSupport/dtkAbstractDataFactory.h>
43 return "axlTorusReader";
47 return "axlTorusReader";
51 return QStringList() <<
"axlTorus";
55 return dtkAbstractDataFactory::instance()->registerDataReaderType(
"axlTorusReader", QStringList(),
createaxlTorusReader);
59 QDomElement element = node.toElement();
61 if (element.tagName() !=
"torus")
77 return !this->
accept(node);
81 QDomElement element = node.toElement();
85 QString name = element.attribute(
"name");
86 if (!name.isEmpty()) {
87 currentTorus->setObjectName(name);
90 QString color = element.attribute(
"color");
91 if (!color.isEmpty()) {
92 QStringList colorList = color.split(
" ");
93 if (colorList.size() > 2)
94 currentTorus->
setColor(QColor(colorList.at(0).toInt(), colorList.at(1).toInt(), colorList.at(2).toInt()));
95 if (colorList.size() == 4)
96 currentTorus->
setOpacity(colorList.at(3).toFloat());
99 QString shader = element.attribute(
"shader");
101 if (!shader.isEmpty()) {
103 dirShader =
":axlShader/shader/" + shader;
104 if (!QFile::exists(dirShader)) {
105 QSettings settings(
"inria",
"dtk");
107 settings.beginGroup(
"shader");
108 dirShader = settings.value(
"path", defaultPath).toString();
109 dirShader.append(
"/" + shader);
114 QString size = element.attribute(
"size");
116 currentTorus->
setSize(size.toFloat());
119 QDomNodeList nodeListCenter = element.elementsByTagName(
"center");
120 QDomElement elementCenter = nodeListCenter.item(0).toElement();
121 QStringList coordCenter = elementCenter.text().simplified().split(QRegExp(
"\\s+"));
122 if (coordCenter.size() == 3)
123 currentTorus->
setCenter(
new axlPoint(coordCenter[0].toDouble(), coordCenter[1].toDouble(), coordCenter[2].toDouble()));
125 qDebug() <<
"Torus data cannot be read correctly: radius coordinates";
128 QDomNodeList nodeListDirection = element.elementsByTagName(
"direction");
129 QDomElement elementDirection = nodeListDirection.item(0).toElement();
130 QStringList coordDirection = elementDirection.text().simplified().split(QRegExp(
"\\s+"));
131 if (coordDirection.size() == 3)
132 currentTorus->
setDirection(
new axlPoint(coordDirection[0].toDouble(), coordDirection[1].toDouble(), coordDirection[2].toDouble()));
134 qDebug() <<
"Torus data cannot be read correctly: direction coordinates";
137 QDomNodeList nodeListRingRadius = element.elementsByTagName(
"ringRadius");
138 QDomElement elementRingRadius = nodeListRingRadius.item(0).toElement();
139 QStringList ringRadius = elementRingRadius.text().simplified().split(QRegExp(
"\\s+"));
140 if (ringRadius.size() == 1)
143 qDebug() <<
"Torus data cannot be read correctly : ring radius";
146 QDomNodeList nodeListCrossSectionRadius = element.elementsByTagName(
"crossSectionRadius");
147 QDomElement elementCrossSectionRadius = nodeListCrossSectionRadius.item(0).toElement();
148 QStringList crossSectionRadius = elementCrossSectionRadius.text().simplified().split(QRegExp(
"\\s+"));
149 if (crossSectionRadius.size() == 1)
152 qDebug() <<
"Torus data cannot be read correctly : cross section radius";
155 QDomNodeList nodeListField = element.elementsByTagName(
"field");
156 if(!nodeListField.isEmpty()){
157 for(
int i = 0; i < nodeListField.size(); i++){
158 QDomElement fieldElement = nodeListField.at(i).toElement();
159 QString fieldType = fieldElement.attribute(
"type");
160 if(!fieldType.isEmpty()){
165 fieldToAdd->setObjectName(newName);
Class axlPoint defines 3D points.
QStringList handled(void) const
void setCenter(axlPoint *center)
void setCrossSectionRadius(double crossSectionRadius)
axlAbstractData * read(const QDomNode &node)
void setShader(const QString &shader)
QString changeFieldName(QString fieldName)
dtkAbstractDataReader * create(const QString &interface_name)
dtkAbstractDataReader * createaxlTorusReader(void)
virtual axlAbstractData * read(const QDomNode &node)=0
Class axlAbstractField defines an API for arrays of numeric data.
static bool registered(void)
void setRingRadius(double ringRadius)
bool accept(const QDomNode &node)
void setDirection(axlPoint *direction)
bool hasChildNode(QDomElement element, const QString &tag)
void setOpacity(const double &opacity)
QString identifier(void) const
virtual ~axlTorusReader(void)
static axlFieldReadersFactory * instance(void)
void addField(axlAbstractField *field)
Add a field to the field list of the object.
void setSize(const double &size)
void setColor(double r, double g, double b)
QString description(void) const
Class axlAbstractData defines an API for all type of axel data.
bool reject(const QDomNode &node)