26 #include <dtkCoreSupport/dtkAbstractData.h>
27 #include <dtkCoreSupport/dtkAbstractDataFactory.h>
31 #include <dtkMathSupport/dtkQuaternion.h>
45 return "axlEllipsoidReader";
49 return "axlEllipsoidReader";
53 return QStringList() <<
"axlEllipsoid";
57 return dtkAbstractDataFactory::instance()->registerDataReaderType(
"axlEllipsoidReader", QStringList(),
createaxlEllipsoidReader);
61 QDomElement element = node.toElement();
63 if(element.tagName() !=
"ellipsoid")
82 return !this->
accept(node);
86 QDomElement element = node.toElement();
90 QString name = element.attribute(
"name");
92 currentEllipsoid->setObjectName(name);
95 QString color = element.attribute(
"color");
96 if(!color.isEmpty()) {
97 QStringList colorList = color.split(
" ");
98 if(colorList.size() > 2)
99 currentEllipsoid->
setColor(QColor(colorList.at(0).toInt(), colorList.at(1).toInt(), colorList.at(2).toInt()));
100 if(colorList.size() == 4)
101 currentEllipsoid->
setOpacity(colorList.at(3).toFloat());
104 QString shader = element.attribute(
"shader");
106 if(!shader.isEmpty()) {
108 dirShader =
":axlShader/shader/"+shader;
109 if(!QFile::exists(dirShader))
111 QSettings settings(
"inria",
"dtk");
113 settings.beginGroup(
"shader");
114 dirShader = settings.value(
"path", defaultPath).toString();
116 dirShader.append(
"/"+shader);
121 QString size = element.attribute(
"size");
123 currentEllipsoid->
setSize(size.toFloat());
126 QDomNodeList nodelistcenter = element.elementsByTagName(
"center") ;
127 QDomElement elementCenter = nodelistcenter.item(0).toElement() ;
129 QStringList centerCoords = elementCenter.text().simplified().split(QRegExp(
"\\s+"));
130 if (centerCoords.size() == 3) {
131 currentEllipsoid->
setCenter(
new axlPoint(centerCoords[0].toFloat(), centerCoords[1].toFloat(), centerCoords[2].toFloat()));
133 qDebug()<<
"Ellispoid data cannot be read correctly : center Coords";
136 QDomNodeList nodelistSemiX = element.elementsByTagName(
"semix") ;
137 QDomElement elementSemiX = nodelistSemiX.item(0).toElement() ;
139 QStringList semiXCoords = elementSemiX.text().simplified().split(QRegExp(
"\\s+"));
140 if (semiXCoords.size() == 3) {
141 currentEllipsoid->
setSemiX(
new axlPoint(semiXCoords[0].toFloat(), semiXCoords[1].toFloat(), semiXCoords[2].toFloat()));
143 qDebug()<<
"Ellispoid data cannot be read correctly : semiX Coords";
146 QDomNodeList nodelistSemiY = element.elementsByTagName(
"semiy") ;
147 QDomElement elementSemiY = nodelistSemiY.item(0).toElement() ;
149 QStringList semiYCoords = elementSemiY.text().simplified().split(QRegExp(
"\\s+"));
150 if (semiYCoords.size() == 3) {
151 currentEllipsoid->
setSemiY(
new axlPoint(semiYCoords[0].toFloat(), semiYCoords[1].toFloat(), semiYCoords[2].toFloat()));
153 qDebug()<<
"Ellispoid data cannot be read correctly : semiY Coords";
156 QDomNodeList nodelistSemiZ = element.elementsByTagName(
"semiz") ;
157 QDomElement elementSemiZ = nodelistSemiZ.item(0).toElement() ;
159 QStringList semiZCoords = elementSemiZ.text().simplified().split(QRegExp(
"\\s+"));
160 if (semiZCoords.size() == 3) {
161 currentEllipsoid->
setSemiZ(
new axlPoint(semiZCoords[0].toFloat(), semiZCoords[1].toFloat(), semiZCoords[2].toFloat()));
163 qDebug()<<
"Ellispoid data cannot be read correctly : semiZ Coords";
166 QDomNodeList nodeListField = element.elementsByTagName(
"field");
167 if(!nodeListField.isEmpty()){
168 for(
int i =0; i < nodeListField.size(); i++){
169 QDomElement fieldElement = nodeListField.at(i).toElement();
170 QString fieldType = fieldElement.attribute(
"type");
171 if(!fieldType.isEmpty()){
175 QString newName = currentEllipsoid->
changeFieldName(fieldToAdd->name());
176 fieldToAdd->setObjectName(newName);
177 currentEllipsoid->
addField(fieldToAdd);
182 return currentEllipsoid;
QString identifier(void) const
Class axlPoint defines 3D points.
axlAbstractData * read(const QDomNode &node)
void setSemiZ(axlPoint *semiZ)
Change semi axes z value of this ellipsoid.
void setShader(const QString &shader)
void setCenter(axlPoint *center)
Change center of this ellipsoid.
QString changeFieldName(QString fieldName)
dtkAbstractDataReader * create(const QString &interface_name)
QString description(void) const
bool reject(const QDomNode &node)
~axlEllipsoidReader(void)
virtual axlAbstractData * read(const QDomNode &node)=0
static bool registered(void)
QStringList handled(void) const
void setSemiX(axlPoint *semiX)
Change semi axes x value of this ellipsoid.
Class axlAbstractField defines an API for arrays of numeric data.
bool hasChildNode(QDomElement element, const QString &tag)
void setOpacity(const double &opacity)
bool accept(const QDomNode &node)
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 axlEllipsoid defines 3D ellipsoids.
Class axlAbstractData defines an API for all type of axel data.
dtkAbstractDataReader * createaxlEllipsoidReader(void)
void setSemiY(axlPoint *semiY)
Change semi axes y value of this ellipsoid.