23 #include <dtkCoreSupport/dtkAbstractData.h>
24 #include <dtkCoreSupport/dtkAbstractDataFactory.h>
40 return "axlCylinderParametricWriter";
44 return "axlCylinderParametricWriter";
48 return QStringList() <<
"axlCylinderParametric";
57 return cylinderParam != NULL;
61 return !this->
accept(data);
71 QDomElement cylinderParamElement = doc->createElement(
"cylinderParam");
72 cylinderParamElement.setAttribute(
"name",cylinder->name());
75 cylinderParamElement.setAttribute(
"size", QString::number(cylinder->
size()));
78 QColor qcolor = cylinder->
color();
80 QTextStream(&color) << QString::number(qcolor.red()) <<
" "
81 << QString::number(qcolor.green()) <<
" "
82 << QString::number(qcolor.blue()) <<
" "
83 << QString::number(cylinder->
opacity());
84 cylinderParamElement.setAttribute(
"color", color);
87 QString shader = cylinder->
shader();
88 QFileInfo shaderFileInfo(shader);
89 cylinderParamElement.setAttribute(
"shader", shaderFileInfo.fileName());
93 QDomElement firstPoint = doc->createElement(
"point");
94 QString firstPointStr;
95 QTextStream(&firstPointStr) << QString::number(cylinder->
firstPoint()->
x()) <<
" "<< QString::number(cylinder->
firstPoint()->
y()) <<
" "<< QString::number(cylinder->
firstPoint()->
z());
96 QDomText firstPointDomText = doc->createTextNode(firstPointStr);
97 firstPoint.appendChild(firstPointDomText);
99 cylinderParamElement.appendChild(firstPoint);
102 QDomElement secondPoint = doc->createElement(
"point");
103 QString secondPointStr;
104 QTextStream(&secondPointStr) << QString::number(cylinder->
secondPoint()->
x()) <<
" "<< QString::number(cylinder->
secondPoint()->
y()) <<
" "<< QString::number(cylinder->
secondPoint()->
z());
105 QDomText secondPointDomText = doc->createTextNode(secondPointStr);
106 secondPoint.appendChild(secondPointDomText);
108 cylinderParamElement.appendChild(secondPoint);
111 QDomElement radius = doc->createElement(
"radius");
113 QTextStream(&radiusStr) << QString::number(cylinder->
radius());
114 QDomText radiusDomText = doc->createTextNode(radiusStr);
115 radius.appendChild(radiusDomText);
117 cylinderParamElement.appendChild(radius);
120 QDomElement refdir = doc->createElement(
"refdir");
122 QTextStream(&refdirStr) << QString::number(cylinderParam->
getR()->
x()) <<
" "<< QString::number(cylinderParam->
getR()->
y()) <<
" "<< QString::number(cylinderParam->
getR()->
z());
123 QDomText refdirDomText = doc->createTextNode(refdirStr);
124 refdir.appendChild(refdirDomText);
126 cylinderParamElement.appendChild(refdir);
129 if(!cylinder->
fields().isEmpty()){
132 QDomElement fieldElement = field_writer->
write(doc, field);
133 cylinderParamElement.appendChild(fieldElement);
137 return cylinderParamElement;
141 QDomElement axlCylinderParametricWriter::elementByWriter(
axlAbstractDataWriter *axl_writer, QDomDocument *doc, dtkAbstractData *data) {
147 if(!axl_writer->
accept(data))
150 element = axl_writer->
write(doc, data);
bool accept(dtkAbstractData *data)
virtual ~axlCylinderParametricWriter(void)
virtual bool accept(dtkAbstractData *data)=0
axlPoint * secondPoint(void) const
Returns second point of the cylinder.
Class axlCylinder defines 3D cylinders.
static axlFieldWritersFactory * instance(void)
axlPoint * firstPoint(void) const
Returns first point of the cylinder.
virtual QString identifier(void) const
QString description(void) const
QString identifier(void) const
bool reject(dtkAbstractData *data)
dtkAbstractDataWriter * create(const QString &interface_name)
static bool registered(void)
Class axlAbstractField defines an API for arrays of numeric data.
axlCylinderParametricWriter(void)
dtkAbstractDataWriter * createaxlCylinderParametricWriter(void)
QDomElement write(QDomDocument *doc, dtkAbstractData *data)
QList< axlAbstractField * > fields(void)
virtual QDomElement write(QDomDocument *doc, dtkAbstractData *data)=0
axlCylinder * getCylinder(void) const
QStringList handled(void) const
axlPoint * getR(void) const