28 #include <dtkCoreSupport/dtkAbstractData.h>
29 #include <dtkCoreSupport/dtkAbstractDataFactory.h>
47 return "axlConeReader";
52 return "axlConeReader";
57 return QStringList() <<
"axlCone";
62 return dtkAbstractDataFactory::instance()->registerDataReaderType(
"axlConeReader", QStringList(),
createaxlConeReader);
67 QDomElement element = node.toElement();
69 if(element.tagName() !=
"cone")
83 return !this->
accept(node);
88 QDomElement element = node.toElement();
92 QString name = element.attribute(
"name");
95 currentCone->setObjectName(name);
98 QString color = element.attribute(
"color");
101 QStringList colorList = color.split(
" ");
102 if(colorList.size() > 2)
103 currentCone->
setColor(QColor(colorList.at(0).toInt(), colorList.at(1).toInt(), colorList.at(2).toInt()));
104 if(colorList.size() == 4)
105 currentCone->
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 currentCone->
setSize(size.toFloat());
131 QDomNodeList nodelistApex = element.elementsByTagName(
"point") ;
132 QDomElement elementApex = nodelistApex.item(0).toElement() ;
134 QStringList coordinates = elementApex.text().simplified().split(QRegExp(
"\\s+"));
135 if(coordinates.size() == 3)
137 currentCone->
setApex(
new axlPoint(coordinates[0].toDouble(), coordinates[1].toDouble(), coordinates[2].toDouble()));
140 qDebug()<<
"Cone data cannot be read correctly : coordinates";
143 QDomNodeList nodelistBasePoint = element.elementsByTagName(
"point") ;
144 QDomElement elementBasePoint = nodelistBasePoint.item(1).toElement() ;
146 coordinates = elementBasePoint.text().simplified().split(QRegExp(
"\\s+"));
147 if(coordinates.size() == 3)
149 currentCone->
setBasePoint(
new axlPoint(coordinates[0].toDouble(), coordinates[1].toDouble(), coordinates[2].toDouble()));
153 qDebug()<<
"Cone 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 currentCone->
setRadius(radius[0].toDouble());
165 qDebug()<<
"Cone 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()){
179 fieldToAdd->setObjectName(newName);
Class axlPoint defines 3D points.
QString identifier(void) const
bool accept(const QDomNode &node)
bool reject(const QDomNode &node)
QStringList handled(void) const
axlAbstractData * read(const QDomNode &node)
void setApex(axlPoint *apex)
Change apex of this cone.
void setShader(const QString &shader)
QString changeFieldName(QString fieldName)
void setRadius(double radius)
Change radius of this cone.
dtkAbstractDataReader * create(const QString &interface_name)
dtkAbstractDataReader * createaxlConeReader(void)
virtual axlAbstractData * read(const QDomNode &node)=0
Class axlAbstractField defines an API for arrays of numeric data.
QString description(void) const
static bool registered(void)
bool hasChildNode(QDomElement element, const QString &tag)
void setOpacity(const double &opacity)
Class axlCone defines 3D cones.
static axlFieldReadersFactory * instance(void)
void addField(axlAbstractField *field)
Add a field to the field list of the object.
void setBasePoint(axlPoint *basePoint)
Change base point of this cone.
void setSize(const double &size)
void setColor(double r, double g, double b)
Class axlAbstractData defines an API for all type of axel data.