25 #include <dtkCoreSupport/dtkAbstractData.h>
26 #include <dtkCoreSupport/dtkAbstractDataFactory.h>
45 return "axlSphereWriter";
50 return "axlSphereWriter";
55 return QStringList() <<
"axlSphere";
60 return dtkAbstractDataFactory::instance()->registerDataWriterType(
"axlSphereWriter", QStringList(),
createaxlSphereWriter);
74 return !this->
accept(data);
82 QDomElement sphereElement = doc->createElement(
"sphere");
83 sphereElement.setAttribute(
"name",sphere->name());
87 sphereElement.setAttribute(
"size", QString::number(sphere->
size()));
92 QColor qcolor = sphere->
color();
94 QTextStream(&color) << QString::number(qcolor.red()) <<
" "
95 << QString::number(qcolor.green()) <<
" "
96 << QString::number(qcolor.blue()) <<
" "
97 << QString::number(sphere->
opacity());
98 sphereElement.setAttribute(
"color", color);
101 QString shader = sphere->
shader();
102 QFileInfo shaderFileInfo(shader);
103 sphereElement.setAttribute(
"shader", shaderFileInfo.fileName());
107 QDomElement center = doc->createElement(
"center");
109 QTextStream(¢erStr) << QString::number(sphere->
x()) <<
" "<< QString::number(sphere->
y()) <<
" "<< QString::number(sphere->
z());
110 QDomText centerDomText = doc->createTextNode(centerStr);
111 center.appendChild(centerDomText);
113 sphereElement.appendChild(center);
115 QDomElement radius = doc->createElement(
"radius");
117 QTextStream(&radiusStr) << QString::number(sphere->
radius());
118 QDomText radiusDomText = doc->createTextNode(radiusStr);
119 radius.appendChild(radiusDomText);
121 sphereElement.appendChild(radius);
124 if(!sphere->
fields().isEmpty()){
127 QDomElement fieldElement = field_writer->
write(doc, field);
128 sphereElement.appendChild(fieldElement);
133 return sphereElement;
137 QDomElement axlSphereWriter::elementByWriter(
axlAbstractDataWriter *axl_writer, QDomDocument *doc, dtkAbstractData *data)
144 if(!axl_writer->
accept(data))
147 element = axl_writer->
write(doc, data);
static bool registered(void)
double x(void) const
Returns x-coordinate of this sphere.
virtual bool accept(dtkAbstractData *data)=0
dtkAbstractDataWriter * createaxlSphereWriter(void)
double z(void) const
Returns z-coordinate of this sphere.
static axlFieldWritersFactory * instance(void)
QString identifier(void) const
virtual QString identifier(void) const
bool accept(dtkAbstractData *data)
QString description(void) const
QDomElement write(QDomDocument *doc, dtkAbstractData *data)
Class axlSphere defines 3D spheres.
dtkAbstractDataWriter * create(const QString &interface_name)
Class axlAbstractField defines an API for arrays of numeric data.
bool reject(dtkAbstractData *data)
double y(void) const
Returns y-coordinate of this sphere.
QList< axlAbstractField * > fields(void)
virtual QDomElement write(QDomDocument *doc, dtkAbstractData *data)=0
QStringList handled(void) const