28 #include <dtkCoreSupport/dtkAbstractData.h>
29 #include <dtkCoreSupport/dtkAbstractDataFactory.h>
43 return "axlCircleArcReader";
47 return "axlCircleArcReader";
51 return QStringList() <<
"axlCircleArc";
55 return dtkAbstractDataFactory::instance()->registerDataReaderType(
"axlCircleArcReader", QStringList(),
createaxlCircleArcReader);
59 QDomElement element = node.toElement();
61 if (element.tagName() !=
"arc")
83 return !this->
accept(node);
87 QDomElement element = node.toElement();
93 QString name = element.attribute(
"name");
94 if (!name.isEmpty()) {
95 currentArc->setObjectName(name);
99 QString color = element.attribute(
"color");
100 if (!color.isEmpty()) {
101 QStringList colorList = color.split(
" ");
102 if (colorList.size() > 2)
103 currentArc->
setColor(QColor(colorList.at(0).toInt(), colorList.at(1).toInt(), colorList.at(2).toInt()));
104 if (colorList.size() == 4)
105 currentArc->
setOpacity(colorList.at(3).toFloat());
109 QString shader = element.attribute(
"shader");
111 if (!shader.isEmpty()) {
113 dirShader =
":axlShader/shader/" + shader;
114 if (!QFile::exists(dirShader)) {
115 QSettings settings(
"inria",
"dtk");
117 settings.beginGroup(
"shader");
118 dirShader = settings.value(
"path", defaultPath).toString();
119 dirShader.append(
"/" + shader);
125 QString size = element.attribute(
"size");
127 currentArc->
setSize(size.toFloat());
130 QDomNodeList nodeListPoint1 = element.elementsByTagName(
"point1");
131 QDomElement elementPoint1 = nodeListPoint1.item(0).toElement();
132 QStringList coordPoint1 = elementPoint1.text().simplified().split(QRegExp(
"\\s+"));
133 if (coordPoint1.size() == 3)
134 currentArc->
setPoint1(
new axlPoint(coordPoint1[0].toDouble(), coordPoint1[1].toDouble(), coordPoint1[2].toDouble()));
136 dtkWarn() <<
"Error within axlCircleArcReader::read, arc data cannot be read correctly: point1 coordinates";
139 QDomNodeList nodeListPoint2 = element.elementsByTagName(
"point2");
140 QDomElement elementPoint2 = nodeListPoint2.item(0).toElement();
141 QStringList coordPoint2 = elementPoint2.text().simplified().split(QRegExp(
"\\s+"));
142 if (coordPoint2.size() == 3)
143 currentArc->
setPoint2(
new axlPoint(coordPoint2[0].toDouble(), coordPoint2[1].toDouble(), coordPoint2[2].toDouble()));
145 dtkWarn() <<
"Error within axlCircleArcReader::read, arc data cannot be read correctly: point2 coordinates";
148 QDomNodeList nodeListCenter = element.elementsByTagName(
"center");
149 QDomElement elementCenter = nodeListCenter.item(0).toElement();
150 QStringList coordCenter = elementCenter.text().simplified().split(QRegExp(
"\\s+"));
151 if (coordCenter.size() == 3)
152 currentArc->
setCenter(
new axlPoint(coordCenter[0].toDouble(), coordCenter[1].toDouble(), coordCenter[2].toDouble()));
154 dtkWarn() <<
"Error within axlCircleArcReader::read, arc data cannot be read correctly: radius coordinates";
157 QDomNodeList nodeListNormal = element.elementsByTagName(
"normal");
158 QDomElement elementNormal = nodeListNormal.item(0).toElement();
159 QStringList coordNormal = elementNormal.text().simplified().split(QRegExp(
"\\s+"));
160 if (coordNormal.size() == 3)
161 currentArc->
setNormal(
new axlPoint(coordNormal[0].toDouble(), coordNormal[1].toDouble(), coordNormal[2].toDouble()));
163 dtkWarn() <<
"Error within axlCircleArcReader::read, arc data cannot be read correctly: normal coordinates";
166 QDomNodeList nodeListCCW = element.elementsByTagName(
"ccw");
167 QDomElement elementCCW = nodeListCCW.item(0).toElement();
168 QString coordCCW = elementCCW.text().simplified();
170 currentArc->
setDirect(coordCCW.toInt(&ok));
172 dtkWarn() <<
"Error within axlCircleArcReader::read, arc data cannot be read correctly: ccw bool value";
176 QDomNodeList nodeListField = element.elementsByTagName(
"field");
177 if(!nodeListField.isEmpty()){
178 for(
int i =0; i < nodeListField.size(); i++){
179 QDomElement fieldElement = nodeListField.at(i).toElement();
180 QString fieldType = fieldElement.attribute(
"type");
181 if(!fieldType.isEmpty()){
186 fieldToAdd->setObjectName(newName);
Class axlPoint defines 3D points.
bool reject(const QDomNode &node)
void setCenter(const axlPoint ¢er)
void setDirect(bool direct)
void setShader(const QString &shader)
QString changeFieldName(QString fieldName)
dtkAbstractDataReader * create(const QString &interface_name)
QString identifier(void) const
bool accept(const QDomNode &node)
virtual axlAbstractData * read(const QDomNode &node)=0
QString description(void) const
virtual ~axlCircleArcReader(void)
Class axlAbstractField defines an API for arrays of numeric data.
void setPoint1(const axlPoint &point1)
static bool registered(void)
bool hasChildNode(QDomElement element, const QString &tag)
void setOpacity(const double &opacity)
void setPoint2(const axlPoint &point2)
static axlFieldReadersFactory * instance(void)
void addField(axlAbstractField *field)
Add a field to the field list of the object.
dtkAbstractDataReader * createaxlCircleArcReader(void)
void setSize(const double &size)
void setColor(double r, double g, double b)
QStringList handled(void) const
axlAbstractData * read(const QDomNode &node)
Class axlAbstractData defines an API for all type of axel data.
void setNormal(const axlPoint &normal)