Developer documentation | Axl-2.5.1

axlFieldParametricCurveWriter.cpp
Go to the documentation of this file.
1 /* axlFieldParametricCurveWriter.cpp ---
2  *
3  * Author: Anais Ducoffe
4  * Copyright (C) 2013 - Anais Ducoffe, Inria.
5  */
6 
7 /* Commentary:
8  *
9  */
10 
11 /* Change log:
12  *
13  */
14 
16 
18 
19 #include <dtkCoreSupport/dtkAbstractData.h>
20 #include <dtkCoreSupport/dtkAbstractDataFactory.h>
21 
22 // /////////////////////////////////////////////////////////////////
23 // axlFieldParametricCurveWriter
24 // /////////////////////////////////////////////////////////////////
25 
27 {
28  this->setObjectName(this->description());
29 }
30 
32 {
33 
34 }
35 
37 {
38  return "axlFieldParametricCurveWriter";
39 }
40 
42 {
43  return "axlFieldParametricCurveWriter";
44 }
45 
47 {
48  return QStringList() << "axlFieldParametricCurve";
49 }
50 
52 {
53  return dtkAbstractDataFactory::instance()->registerDataWriterType("axlFieldParametricCurveWriter", QStringList(), createaxlFieldParametricCurveWriter);
54 }
55 
56 bool axlFieldParametricCurveWriter::accept(dtkAbstractData *data)
57 {
58  axlFieldParametricCurve *spatialField = dynamic_cast<axlFieldParametricCurve *>(data);
59  if(spatialField)
60  return true;
61 
62  return false;
63 }
64 
65 bool axlFieldParametricCurveWriter::reject(dtkAbstractData *data)
66 {
67  return !this->accept(data);
68 }
69 
70 QDomElement axlFieldParametricCurveWriter::write(QDomDocument *doc, dtkAbstractData *data)
71 {
72  axlFieldParametricCurve *field = dynamic_cast<axlFieldParametricCurve *>(data);
73 
74  QDomElement fieldElement = doc->createElement("field");
75 
77  fieldElement.setAttribute("type", field->identifier());
78 
80  axlAbstractDataWriter *function_writer = dynamic_cast<axlAbstractDataWriter *>(dtkAbstractDataFactory::instance()->writer(field->getFunction()->identifier()+"Writer"));
81  QDomElement functionElement = function_writer->write(doc, field->getFunction());
82  fieldElement.appendChild(functionElement);
83 
84 
85  return fieldElement;
86 }
87 
88 
89 
90 QDomElement axlFieldParametricCurveWriter::elementByWriter(axlAbstractDataWriter *axl_writer, QDomDocument *doc, dtkAbstractData *data)
91 {
92  QDomElement element;
93 
94  if(!axl_writer)
95  return element;
96 
97  if(!axl_writer->accept(data))
98  return element;
99 
100  element = axl_writer->write(doc, data);
101 
102  return element;
103 }
104 
105 dtkAbstractDataWriter *createaxlFieldParametricCurveWriter(void)
106 {
108 }
109 
virtual QString identifier(void) const
Returns the identifier of the field "axlFieldParametricCurve".
virtual bool accept(dtkAbstractData *data)=0
Class axlFieldParametricCurve defines an API for field which owns a BSpline curve.
QDomElement write(QDomDocument *doc, dtkAbstractData *data)
dtkAbstractDataWriter * createaxlFieldParametricCurveWriter(void)
virtual QDomElement write(QDomDocument *doc, dtkAbstractData *data)=0
axlAbstractData * getFunction(void)
Returns the Bspline function which determines the values of the BSpline field.