25 #include <dtkCoreSupport/dtkAbstractData.h>
26 #include <dtkCoreSupport/dtkAbstractDataFactory.h>
46 return "axlSphereReader";
51 return "axlSphereReader";
56 return QStringList() <<
"axlSphere";
61 return dtkAbstractDataFactory::instance()->registerDataReaderType(
"axlSphereReader", QStringList(),
createaxlSphereReader);
66 QDomElement element = node.toElement();
68 if(element.tagName() !=
"sphere")
83 return !this->
accept(node);
88 QDomElement element = node.toElement();
92 QString name = element.attribute(
"name");
95 currentSphere->setObjectName(name);
98 QString color = element.attribute(
"color");
101 QStringList colorList = color.split(
" ");
102 if(colorList.size() > 2)
103 currentSphere->
setColor(QColor(colorList.at(0).toInt(), colorList.at(1).toInt(), colorList.at(2).toInt()));
104 if(colorList.size() == 4)
105 currentSphere->
setOpacity(colorList.at(3).toFloat());
108 QString shader = element.attribute(
"shader");
110 if(!shader.isEmpty())
113 dirShader =
":axlShader/shader/"+shader;
114 if(!QFile::exists(dirShader))
116 QSettings settings(
"inria",
"dtk");
118 settings.beginGroup(
"shader");
119 dirShader = settings.value(
"path", defaultPath).toString();
121 dirShader.append(
"/"+shader);
126 QString size = element.attribute(
"size");
128 currentSphere->
setSize(size.toFloat());
131 QDomNodeList nodelistcenter = element.elementsByTagName(
"center") ;
132 QDomElement elementCenter = nodelistcenter.item(0).toElement() ;
134 QStringList coordinates = elementCenter.text().simplified().split(QRegExp(
"\\s+"));
135 if(coordinates.size() == 3)
138 currentSphere->
coordinates()[0] = coordinates[0].toFloat();
139 currentSphere->
coordinates()[1] = coordinates[1].toFloat();
140 currentSphere->
coordinates()[2] = coordinates[2].toFloat();
143 qDebug()<<
"Sphere data cannot be read correctly : coordinates";
146 QDomNodeList nodelistradius = element.elementsByTagName(
"radius") ;
147 QDomElement elementRadius = nodelistradius.item(0).toElement() ;
148 QStringList radius = elementRadius.text().simplified().split(QRegExp(
"\\s+"));
149 if(radius.size() == 1)
151 currentSphere->
setRadius(radius[0].toFloat());
154 qDebug()<<
"Sphere data cannot be read correctly : radius";
157 QDomNodeList nodeListField = element.elementsByTagName(
"field");
158 if(!nodeListField.isEmpty()){
159 for(
int i =0; i < nodeListField.size(); i++){
160 QDomElement fieldElement = nodeListField.at(i).toElement();
161 QString fieldType = fieldElement.attribute(
"type");
162 if(!fieldType.isEmpty()){
167 fieldToAdd->setObjectName(newName);
168 currentSphere->
addField(fieldToAdd);
174 return currentSphere;
QStringList handled(void) const
QString description(void) const
void setShader(const QString &shader)
static bool registered(void)
QString changeFieldName(QString fieldName)
dtkAbstractDataReader * create(const QString &interface_name)
double * coordinates(void) const
Returns coordinates of this sphere.
virtual axlAbstractData * read(const QDomNode &node)=0
void setRadius(double radius)
Class axlSphere defines 3D spheres.
dtkAbstractDataReader * createaxlSphereReader(void)
bool reject(const QDomNode &node)
Class axlAbstractField defines an API for arrays of numeric data.
bool hasChildNode(QDomElement element, const QString &tag)
void setOpacity(const double &opacity)
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)
axlAbstractData * read(const QDomNode &node)
Class axlAbstractData defines an API for all type of axel data.
QString identifier(void) const
bool accept(const QDomNode &node)