23 #include <dtkCoreSupport/dtkAbstractData.h>
24 #include <dtkCoreSupport/dtkAbstractDataFactory.h>
40 return "axlTorusParametricReader";
44 return "axlTorusParametricReader";
48 return QStringList() <<
"axlTorusParametric";
56 QDomElement element = node.toElement();
58 if(element.tagName() !=
"torusParam")
80 return !this->
accept(node);
84 QDomElement element = node.toElement();
90 QString name = element.attribute(
"name");
92 currentTorusParametric->setObjectName(name);
96 QString color = element.attribute(
"color");
97 if(!color.isEmpty()) {
98 QStringList colorList = color.split(
" ");
99 if(colorList.size() > 2)
100 currentTorusParametric->
setColor(QColor(colorList.at(0).toInt(), colorList.at(1).toInt(), colorList.at(2).toInt()));
101 if(colorList.size() == 4)
102 currentTorusParametric->
setOpacity(colorList.at(3).toFloat());
106 QString shader = element.attribute(
"shader");
108 if(!shader.isEmpty()) {
110 dirShader =
":axlShader/shader/"+shader;
111 if(!QFile::exists(dirShader)) {
112 QSettings settings(
"inria",
"dtk");
114 settings.beginGroup(
"shader");
115 dirShader = settings.value(
"path", defaultPath).toString();
117 dirShader.append(
"/"+shader);
119 currentTorusParametric->
setShader(dirShader);
122 QString size = element.attribute(
"size");
124 currentTorusParametric->
setSize(size.toFloat());
130 QDomNodeList centerNodeList = element.elementsByTagName(
"center") ;
132 QDomElement centerElement = centerNodeList.item(0).toElement() ;
134 QStringList centerCoords = centerElement.text().simplified().split(QRegExp(
"\\s+"));
135 if(centerCoords.size() == 3)
136 torus.
setCenter(
new axlPoint(centerCoords[0].toDouble(), centerCoords[1].toDouble(), centerCoords[2].toDouble()));
138 dtkWarn() <<
"TorusParametric data cannot be read correctly : center coordinates";
141 QDomNodeList directionNodeList = element.elementsByTagName(
"direction") ;
143 QDomElement directionElement = directionNodeList.item(0).toElement() ;
145 QStringList directionCoords = directionElement.text().simplified().split(QRegExp(
"\\s+"));
146 if(directionCoords.size() == 3)
147 torus.
setDirection(
new axlPoint(directionCoords[0].toDouble(), directionCoords[1].toDouble(), directionCoords[2].toDouble()));
149 dtkWarn() <<
"TorusParametric data cannot be read correctly : direction coordinates";
152 QDomNodeList ringRadiusNodeList = element.elementsByTagName(
"ringRadius") ;
154 QDomElement ringRadiusElement = ringRadiusNodeList.item(0).toElement() ;
156 QStringList ringRadiusCoords = ringRadiusElement.text().simplified().split(QRegExp(
"\\s+"));
157 if(ringRadiusCoords.size() == 1)
160 dtkWarn() <<
"TorusParametric data cannot be read correctly : ring radius";
163 QDomNodeList crossSectionRadiusNodeList = element.elementsByTagName(
"crossSectionRadius") ;
165 QDomElement crossSectionRadiusElement = crossSectionRadiusNodeList.item(0).toElement() ;
167 QStringList crossSectionRadiusCoords = crossSectionRadiusElement.text().simplified().split(QRegExp(
"\\s+"));
168 if(crossSectionRadiusCoords.size() == 1)
171 dtkWarn() <<
"TorusParametric data cannot be read correctly : refdir coordinates";
173 currentTorusParametric->
setTorus(torus);
176 QDomNodeList refdirNodeList = element.elementsByTagName(
"refdir") ;
178 QDomElement refdirElement = refdirNodeList.item(0).toElement() ;
180 QStringList refdirCoords = refdirElement.text().simplified().split(QRegExp(
"\\s+"));
181 if(refdirCoords.size() == 3)
182 currentTorusParametric->
setR(
new axlPoint(refdirCoords[0].toDouble(), refdirCoords[1].toDouble(), refdirCoords[2].toDouble()));
184 dtkWarn() <<
"TorusParametric data cannot be read correctly : refdir coordinates";
187 QDomNodeList nodeListField = element.elementsByTagName(
"field");
188 if(!nodeListField.isEmpty()){
189 for(
int i =0; i < nodeListField.size(); i++){
190 QDomElement fieldElement = nodeListField.at(i).toElement();
191 QString fieldType = fieldElement.attribute(
"type");
192 if(!fieldType.isEmpty()){
196 QString newName = currentTorusParametric->
changeFieldName(fieldToAdd->name());
197 fieldToAdd->setObjectName(newName);
198 currentTorusParametric->
addField(fieldToAdd);
204 return currentTorusParametric;
bool accept(const QDomNode &node)
Class axlPoint defines 3D points.
dtkAbstractDataReader * createaxlTorusParametricReader(void)
void setCenter(axlPoint *center)
void setCrossSectionRadius(double crossSectionRadius)
void setShader(const QString &shader)
static bool registered(void)
axlAbstractData * read(const QDomNode &node)
QString changeFieldName(QString fieldName)
dtkAbstractDataReader * create(const QString &interface_name)
bool reject(const QDomNode &node)
void setTorus(const axlTorus &torus)
virtual axlAbstractData * read(const QDomNode &node)=0
Class axlAbstractField defines an API for arrays of numeric data.
void setRingRadius(double ringRadius)
void setDirection(axlPoint *direction)
bool hasChildNode(QDomElement element, const QString &tag)
axlTorusParametricReader(void)
void setOpacity(const double &opacity)
static axlFieldReadersFactory * instance(void)
void addField(axlAbstractField *field)
Add a field to the field list of the object.
QStringList handled(void) const
void setSize(const double &size)
void setColor(double r, double g, double b)
QString identifier(void) const
virtual ~axlTorusParametricReader(void)
Class axlAbstractData defines an API for all type of axel data.
QString description(void) const