24 #include <dtkCoreSupport/dtkAbstractData.h>
25 #include <dtkCoreSupport/dtkAbstractDataFactory.h>
43 return "axlPointSetReader";
48 return "axlPointSetReader";
53 return QStringList() <<
"axlPointSet";
58 return dtkAbstractDataFactory::instance()->registerDataReaderType(
"axlPointSetReader", QStringList(),
createaxlPointSetReader);
63 QDomElement element = node.toElement();
65 if(element.tagName() !=
"pointset")
79 return !this->
accept(node);
84 QDomElement element = node.toElement();
89 QString name = element.attribute(
"name");
92 currentPointSet->setObjectName(name);
95 QString color = element.attribute(
"color");
106 QStringList colorList = color.split(
" ");
107 if(colorList.size() > 2)
108 currentPointSet->
setColor(QColor(colorList.at(0).toInt(), colorList.at(1).toInt(), colorList.at(2).toInt()));
109 if(colorList.size() == 4)
110 currentPointSet->
setOpacity(colorList.at(3).toFloat());
114 QString shader = element.attribute(
"shader");
116 if(!shader.isEmpty())
119 dirShader =
":axlShader/shader/"+shader;
120 if(!QFile::exists(dirShader))
122 QSettings settings(
"inria",
"dtk");
124 settings.beginGroup(
"shader");
125 dirShader = settings.value(
"path", defaultPath).toString();
127 dirShader.append(
"/"+shader);
132 QString size = element.attribute(
"size");
134 currentPointSet->
setSize(size.toFloat());
137 QDomNodeList nodelistcoordinates = element.elementsByTagName(
"points") ;
138 QDomElement elementCoordinates = nodelistcoordinates.item(0).toElement() ;
140 QStringList coordinates = elementCoordinates.text().simplified().split(QRegExp(
"\\s+"));
143 for(
int i=0 ; i<coordinates.size() ; i+=6) {
144 float x = coordinates[i+0].toFloat();
145 float y = coordinates[i+1].toFloat();
146 float z = coordinates[i+2].toFloat();
147 int r = coordinates[i+3].toInt();
148 int g = coordinates[i+4].toInt();
149 int b = coordinates[i+5].toInt();
151 currentPoint->
setColor(QColor(r, g, b));
152 currentPointSet->
push_back(currentPoint);
157 for(
int i=0 ; i<coordinates.size() ; i+=3) {
158 float x = coordinates[i+0].toFloat() ;
159 float y = coordinates[i+1].toFloat() ;
160 float z = coordinates[i+2].toFloat() ;
165 return currentPointSet;
Class axlPoint defines 3D points.
void setShader(const QString &shader)
void setUniqueColor(const bool uniqueColor)
dtkAbstractDataReader * createaxlPointSetReader(void)
void push_back(axlPoint *p)
QStringList handled(void) const
QString identifier(void) const
bool accept(const QDomNode &node)
bool hasChildNode(QDomElement element, const QString &tag)
QString description(void) const
void setOpacity(const double &opacity)
dtkAbstractData * read(const QDomNode &node)
void setSize(const double &size)
void setColor(double r, double g, double b)
static bool registered(void)
bool reject(const QDomNode &node)