26 #include <dtkCoreSupport/dtkAbstractData.h>
27 #include <dtkCoreSupport/dtkAbstractDataFactory.h>
47 return "axlCylinderReader";
52 return "axlCylinderReader";
57 return QStringList() <<
"axlCylinder";
62 return dtkAbstractDataFactory::instance()->registerDataReaderType(
"axlCylinderReader", QStringList(),
createaxlCylinderReader);
67 QDomElement element = node.toElement();
69 if(element.tagName() !=
"cylinder")
83 return !this->
accept(node);
88 QDomElement element = node.toElement();
92 QString name = element.attribute(
"name");
95 currentCylinder->setObjectName(name);
98 QString color = element.attribute(
"color");
101 QStringList colorList = color.split(
" ");
102 if(colorList.size() > 2)
103 currentCylinder->
setColor(QColor(colorList.at(0).toInt(), colorList.at(1).toInt(), colorList.at(2).toInt()));
104 if(colorList.size() == 4)
105 currentCylinder->
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 currentCylinder->
setSize(size.toFloat());
130 QDomNodeList nodelistPoint = element.elementsByTagName(
"point") ;
133 QDomElement elementfirstPoint = nodelistPoint.item(0).toElement() ;
135 QStringList coordinates = elementfirstPoint.text().simplified().split(QRegExp(
"\\s+"));
136 if(coordinates.size() == 3)
138 currentCylinder->
setFirstPoint(
new axlPoint(coordinates[0].toDouble(), coordinates[1].toDouble(), coordinates[2].toDouble()));
141 qDebug()<<
"Cylinder data cannot be read correctly : coordinates";
144 QDomElement elementsecondPoint = nodelistPoint.item(1).toElement() ;
146 coordinates = elementsecondPoint.text().simplified().split(QRegExp(
"\\s+"));
147 if(coordinates.size() == 3)
149 currentCylinder->
setSecondPoint(
new axlPoint(coordinates[0].toDouble(), coordinates[1].toDouble(), coordinates[2].toDouble()));
153 qDebug()<<
"Cylinder data cannot be read correctly : coordinates";
156 QDomNodeList nodelistradius = element.elementsByTagName(
"radius") ;
157 QDomElement elementradius = nodelistradius.item(0).toElement() ;
159 QStringList radius = elementradius.text().simplified().split(QRegExp(
"\\s+"));
160 if(radius.size() == 1)
162 currentCylinder->
setRadius(radius[0].toDouble());
165 qDebug()<<
"Cylinder data cannot be read correctly : radius";
169 QDomNodeList nodeListField = element.elementsByTagName(
"field");
170 if(!nodeListField.isEmpty()){
171 for(
int i =0; i < nodeListField.size(); i++){
172 QDomElement fieldElement = nodeListField.at(i).toElement();
173 QString fieldType = fieldElement.attribute(
"type");
174 if(!fieldType.isEmpty()){
178 QString newName = currentCylinder->
changeFieldName(fieldToAdd->name());
179 fieldToAdd->setObjectName(newName);
180 currentCylinder->
addField(fieldToAdd);
186 return currentCylinder;
Class axlPoint defines 3D points.
void setFirstPoint(axlPoint *p1)
Change first point of this cylinder.
void setRadius(double radius)
Change radius of this cylinder.
bool reject(const QDomNode &node)
QStringList handled(void) const
Class axlCylinder defines 3D cylinders.
void setShader(const QString &shader)
void setSecondPoint(axlPoint *p2)
Change second point of this cylinder.
QString changeFieldName(QString fieldName)
dtkAbstractDataReader * createaxlCylinderReader(void)
dtkAbstractDataReader * create(const QString &interface_name)
axlAbstractData * read(const QDomNode &node)
virtual axlAbstractData * read(const QDomNode &node)=0
QString identifier(void) const
bool accept(const QDomNode &node)
Class axlAbstractField defines an API for arrays of numeric data.
QString description(void) const
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)
Class axlAbstractData defines an API for all type of axel data.
static bool registered(void)