26 #include <dtkCoreSupport/dtkAbstractData.h>
27 #include <dtkCoreSupport/dtkAbstractDataFactory.h>
46 return "axlCylinderWriter";
51 return "axlCylinderWriter";
56 return QStringList() <<
"axlCylinder";
61 return dtkAbstractDataFactory::instance()->registerDataWriterType(
"axlCylinderWriter", QStringList(),
createaxlCylinderWriter);
75 return !this->
accept(data);
83 QDomElement cylinderElement = doc->createElement(
"cylinder");
84 cylinderElement.setAttribute(
"name",cylinder->name());
88 cylinderElement.setAttribute(
"size", QString::number(cylinder->
size()));
93 QColor qcolor = cylinder->
color();
95 QTextStream(&color) << QString::number(qcolor.red()) <<
" "
96 << QString::number(qcolor.green()) <<
" "
97 << QString::number(qcolor.blue()) <<
" "
98 << QString::number(cylinder->
opacity());
99 cylinderElement.setAttribute(
"color", color);
102 QString shader = cylinder->
shader();
103 QFileInfo shaderFileInfo(shader);
104 cylinderElement.setAttribute(
"shader", shaderFileInfo.fileName());
108 QDomElement firstPoint = doc->createElement(
"point");
109 QString firstPointStr;
110 QTextStream(&firstPointStr) << QString::number(cylinder->
firstPoint()->
x()) <<
" "<< QString::number(cylinder->
firstPoint()->
y()) <<
" "<< QString::number(cylinder->
firstPoint()->
z());
111 QDomText firstPointDomText = doc->createTextNode(firstPointStr);
112 firstPoint.appendChild(firstPointDomText);
114 cylinderElement.appendChild(firstPoint);
117 QDomElement secondPoint = doc->createElement(
"point");
118 QString secondPointStr;
119 QTextStream(&secondPointStr) << QString::number(cylinder->
secondPoint()->
x()) <<
" "<< QString::number(cylinder->
secondPoint()->
y()) <<
" "<< QString::number(cylinder->
secondPoint()->
z());
120 QDomText secondPointDomText = doc->createTextNode(secondPointStr);
121 secondPoint.appendChild(secondPointDomText);
123 cylinderElement.appendChild(secondPoint);
126 QDomElement radius = doc->createElement(
"radius");
128 QTextStream(&radiusStr) << QString::number(cylinder->
radius());
129 QDomText radiusDomText = doc->createTextNode(radiusStr);
130 radius.appendChild(radiusDomText);
132 cylinderElement.appendChild(radius);
136 if(!cylinder->
fields().isEmpty()){
139 QDomElement fieldElement = field_writer->
write(doc, field);
140 cylinderElement.appendChild(fieldElement);
145 return cylinderElement;
149 QDomElement axlCylinderWriter::elementByWriter(
axlAbstractDataWriter *axl_writer, QDomDocument *doc, dtkAbstractData *data)
156 if(!axl_writer->
accept(data))
159 element = axl_writer->
write(doc, data);
bool accept(dtkAbstractData *data)
QDomElement write(QDomDocument *doc, dtkAbstractData *data)
QStringList handled(void) const
virtual bool accept(dtkAbstractData *data)=0
axlPoint * secondPoint(void) const
Returns second point of the cylinder.
Class axlCylinder defines 3D cylinders.
bool reject(dtkAbstractData *data)
static axlFieldWritersFactory * instance(void)
axlPoint * firstPoint(void) const
Returns first point of the cylinder.
virtual QString identifier(void) const
dtkAbstractDataWriter * createaxlCylinderWriter(void)
QString description(void) const
dtkAbstractDataWriter * create(const QString &interface_name)
Class axlAbstractField defines an API for arrays of numeric data.
static bool registered(void)
QList< axlAbstractField * > fields(void)
virtual QDomElement write(QDomDocument *doc, dtkAbstractData *data)=0
QString identifier(void) const