26 #include <dtkCoreSupport/dtkAbstractData.h>
27 #include <dtkCoreSupport/dtkAbstractDataFactory.h>
47 return "axlPlaneReader";
52 return "axlPlaneReader";
57 return QStringList() <<
"axlPlane";
62 return dtkAbstractDataFactory::instance()->registerDataReaderType(
"axlPlaneReader", QStringList(),
createaxlPlaneReader);
67 QDomElement element = node.toElement();
69 if(element.tagName() !=
"plane")
83 return !this->
accept(node);
88 QDomElement element = node.toElement();
92 QString name = element.attribute(
"name");
95 currentPlane->setObjectName(name);
98 QString color = element.attribute(
"color");
101 QStringList colorList = color.split(
" ");
102 if(colorList.size() > 2)
103 currentPlane->
setColor(QColor(colorList.at(0).toInt(), colorList.at(1).toInt(), colorList.at(2).toInt()));
104 if(colorList.size() == 4)
105 currentPlane->
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);
127 QString size = element.attribute(
"size");
129 currentPlane->
setSize(size.toFloat());
132 QDomNodeList nodelistPoint = element.elementsByTagName(
"point") ;
133 QDomElement elementPoint = nodelistPoint.item(0).toElement() ;
135 QStringList coordinates = elementPoint.text().simplified().split(QRegExp(
"\\s+"));
136 if(coordinates.size() == 3)
138 currentPlane->
setPoint(
new axlPoint(coordinates[0].toDouble(), coordinates[1].toDouble(), coordinates[2].toDouble()));
141 qDebug()<<
"Plane data cannot be read correctly : point";
144 QDomNodeList nodelistNormal = element.elementsByTagName(
"normal") ;
145 QDomElement elementNormal = nodelistNormal.item(0).toElement() ;
147 coordinates = elementNormal.text().simplified().split(QRegExp(
"\\s+"));
148 if(coordinates.size() == 3)
150 currentPlane->
setNormal(
new axlPoint(coordinates[0].toDouble(), coordinates[1].toDouble(), coordinates[2].toDouble()));
154 qDebug()<<
"Plane data cannot be read correctly : normal";
158 QDomNodeList nodeListField = element.elementsByTagName(
"field");
159 if(!nodeListField.isEmpty()){
160 for(
int i =0; i < nodeListField.size(); i++){
161 QDomElement fieldElement = nodeListField.at(i).toElement();
162 QString fieldType = fieldElement.attribute(
"type");
163 if(!fieldType.isEmpty()){
168 fieldToAdd->setObjectName(newName);
void setNormal(axlPoint *normal)
Change second point of this plane.
Class axlPoint defines 3D points.
QStringList handled(void) const
QString description(void) const
static bool registered(void)
bool accept(const QDomNode &node)
QString identifier(void) const
Class axlPlane defines 3D planes.
dtkAbstractDataReader * createaxlPlaneReader(void)
void setShader(const QString &shader)
QString changeFieldName(QString fieldName)
dtkAbstractDataReader * create(const QString &interface_name)
void setPoint(axlPoint *point)
Change first point of this plane.
axlAbstractData * read(const QDomNode &node)
virtual axlAbstractData * read(const QDomNode &node)=0
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)
bool reject(const QDomNode &node)
Class axlAbstractData defines an API for all type of axel data.