23 #include <dtkCoreSupport/dtkAbstractData.h>
24 #include <dtkCoreSupport/dtkAbstractDataFactory.h>
40 return "axlPlaneParametricReader";
44 return "axlPlaneParametricReader";
48 return QStringList() <<
"axlPlaneParametric";
56 QDomElement element = node.toElement();
58 if(element.tagName() !=
"planeParam")
74 return !this->
accept(node);
78 QDomElement element = node.toElement();
84 QString name = element.attribute(
"name");
85 if (!name.isEmpty()) {
86 currentPlaneParametric->setObjectName(name);
90 QString color = element.attribute(
"color");
91 if (!color.isEmpty()) {
92 QStringList colorList = color.split(
" ");
93 if (colorList.size() > 2)
94 currentPlaneParametric->
setColor(QColor(colorList.at(0).toInt(), colorList.at(1).toInt(), colorList.at(2).toInt()));
95 if (colorList.size() == 4)
96 currentPlaneParametric->
setOpacity(colorList.at(3).toFloat());
100 QString shader = element.attribute(
"shader");
102 if (!shader.isEmpty()) {
104 dirShader =
":axlShader/shader/"+shader;
105 if (!QFile::exists(dirShader)) {
106 QSettings settings(
"inria",
"dtk");
108 settings.beginGroup(
"shader");
109 dirShader = settings.value(
"path", defaultPath).toString();
111 dirShader.append(
"/"+shader);
113 currentPlaneParametric->
setShader(dirShader);
117 QString size = element.attribute(
"size");
119 currentPlaneParametric->
setSize(size.toFloat());
122 QDomNodeList pointNodeList = element.elementsByTagName(
"point") ;
123 QDomElement pointElement = pointNodeList.item(0).toElement() ;
125 QStringList pointCoords = pointElement.text().simplified().split(QRegExp(
"\\s+"));
126 if(pointCoords.size() == 3)
127 currentPlaneParametric->
getPlane()->
setPoint(
new axlPoint(pointCoords[0].toDouble(), pointCoords[1].toDouble(), pointCoords[2].toDouble()));
129 dtkWarn() <<
"Error within axlPlaneParametricReader::read, data cannot be read correctly: point coordinates";
132 QDomNodeList normalNodeList = element.elementsByTagName(
"normal") ;
134 QDomElement normalElement = normalNodeList.item(0).toElement() ;
136 QStringList normalCoords = normalElement.text().simplified().split(QRegExp(
"\\s+"));
137 if(normalCoords.size() == 3)
138 currentPlaneParametric->
getPlane()->
setNormal(
new axlPoint(normalCoords[0].toDouble(), normalCoords[1].toDouble(), normalCoords[2].toDouble()));
140 dtkWarn() <<
"Error within axlPlaneParametricReader::read, data cannot be read correctly: normal coordinates";
143 QDomNodeList refdirNodeList = element.elementsByTagName(
"refdir") ;
145 QDomElement refdirElement = refdirNodeList.item(0).toElement() ;
147 QStringList refdirCoords = refdirElement.text().simplified().split(QRegExp(
"\\s+"));
148 if(refdirCoords.size() == 3)
149 currentPlaneParametric->
setI(
new axlPoint(refdirCoords[0].toDouble(), refdirCoords[1].toDouble(), refdirCoords[2].toDouble()));
151 dtkWarn() <<
"Error within axlPlaneParametricReader::read, data cannot be read correctly: refdir coordinates";
155 QDomNodeList nodeListField = element.elementsByTagName(
"field");
156 if(!nodeListField.isEmpty()){
157 for(
int i =0; i < nodeListField.size(); i++){
158 QDomElement fieldElement = nodeListField.at(i).toElement();
159 QString fieldType = fieldElement.attribute(
"type");
160 if(!fieldType.isEmpty()){
164 QString newName = currentPlaneParametric->
changeFieldName(fieldToAdd->name());
165 fieldToAdd->setObjectName(newName);
166 currentPlaneParametric->
addField(fieldToAdd);
172 return currentPlaneParametric;
void setNormal(axlPoint *normal)
Change second point of this plane.
Class axlPoint defines 3D points.
axlPlane * getPlane(void) const
void setShader(const QString &shader)
virtual ~axlPlaneParametricReader(void)
axlAbstractData * read(const QDomNode &node)
QString changeFieldName(QString fieldName)
dtkAbstractDataReader * create(const QString &interface_name)
QString description(void) const
void setPoint(axlPoint *point)
Change first point of this plane.
virtual axlAbstractData * read(const QDomNode &node)=0
static bool registered(void)
Class axlAbstractField defines an API for arrays of numeric data.
bool hasChildNode(QDomElement element, const QString &tag)
void setOpacity(const double &opacity)
axlPlaneParametricReader(void)
QStringList handled(void) const
QString identifier(void) const
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.
dtkAbstractDataReader * createaxlPlaneParametricReader(void)
bool accept(const QDomNode &node)