23 #include <dtkCoreSupport/dtkAbstractData.h>
26 #include <dtkCoreSupport/dtkAbstractDataFactory.h>
44 return "axlFieldSpatialWriter";
49 return "axlFieldSpatialWriter";
54 return QStringList() <<
"axlAbstractField";
59 return dtkAbstractDataFactory::instance()->registerDataWriterType(
"axlFieldSpatialWriter", QStringList(),
createaxlFieldSpatialWriter);
73 return !this->
accept(data);
80 QDomElement fieldElement = doc->createElement(
"field");
82 if(dynamic_cast<axlAbstractFieldSpatial *>(field))
83 fieldElement.setAttribute(
"type",
"spatial");
84 else if(dynamic_cast<axlAbstractFieldParametric *>(field))
85 fieldElement.setAttribute(
"type",
"parametric");
87 fieldElement.setAttribute(
"type",
"discrete");
90 fieldElement.setAttribute(
"name", field->name());
95 int fieldSupport= field->
support();
97 fieldElement.setAttribute(
"support",
"point");
98 else if (fieldSupport == 2)
99 fieldElement.setAttribute(
"support",
"cell");
101 fieldElement.setAttribute(
"support",
"custom");
104 int fieldKind= field->
kind();
106 fieldElement.setAttribute(
"kind",
"scalar");
107 else if (fieldKind == 2)
108 fieldElement.setAttribute(
"kind",
"vector");
110 fieldElement.setAttribute(
"kind",
"tensor");
113 int fieldType= field->
type();
115 fieldElement.setAttribute(
"type",
"int");
116 else if (fieldType == 2)
117 fieldElement.setAttribute(
"type",
"float");
119 fieldElement.setAttribute(
"type",
"double");
123 int size = field->
size();
128 for(
int i = 0 ; i < size; i++)
129 QTextStream(&fieldsText) <<
"\n" << QString::number(fieldD->scalar(i));
130 else if(fieldKind == 2)
131 for(
int i = 0 ; i < size; i++)
132 QTextStream(&fieldsText) <<
"\n" << QString::number((fieldD->vector(i))[0]) <<
" "<< QString::number((fieldD->vector(i))[1]) <<
" "<< QString::number((fieldD->vector(i))[2]);
135 QDomText fieldsDomText = doc->createTextNode(fieldsText);
136 fieldElement.appendChild(fieldsDomText);
139 fieldElement.setAttribute(
"parent", dynamic_cast<axlAbstractData *>(field->parent())->name());
151 int res =
dynamic_cast<QMetaObject *
>(field)->indexOfMethod(
"setParameter");
152 fieldElement.setAttribute(
"res",QString::number(res));
154 qDebug()<<
"no parameter values to write";
165 QDomElement axlFieldSpatialWriter::elementByWriter(
axlAbstractDataWriter *axl_writer, QDomDocument *doc, dtkAbstractData *data)
172 if(!axl_writer->
accept(data))
175 element = axl_writer->
write(doc, data);
QStringList handled(void) const
Class axlAbstractFieldParametric defines an API for parametric field.
virtual bool accept(dtkAbstractData *data)=0
QDomElement write(QDomDocument *doc, dtkAbstractData *data)
static bool registered(void)
QString identifier(void) const
Class axlAbstractFieldDiscrete defines an API for arrays of numeric data.
QString description(void) const
virtual Support support(void)
Class axlAbstractField defines an API for arrays of numeric data.
~axlFieldSpatialWriter(void)
dtkAbstractDataWriter * createaxlFieldSpatialWriter(void)
axlFieldSpatialWriter(void)
virtual QDomElement write(QDomDocument *doc, dtkAbstractData *data)=0
bool accept(dtkAbstractData *data)
bool reject(dtkAbstractData *data)