Developer documentation | Axl-2.5.1

axlFieldSpatialPointDistanceWriter.cpp
Go to the documentation of this file.
1 /* axlFieldSpatialPointDistanceWriter.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 #include <axlCore/axlPoint.h>
19 
20 #include <dtkCoreSupport/dtkAbstractData.h>
21 #include <dtkCoreSupport/dtkAbstractDataFactory.h>
22 
23 // /////////////////////////////////////////////////////////////////
24 // axlFieldSpatialPointDistanceWriter
25 // /////////////////////////////////////////////////////////////////
26 
28 {
29  this->setObjectName(this->description());
30 }
31 
33 {
34 
35 }
36 
38 {
39  return "axlFieldSpatialPointDistanceWriter";
40 }
41 
43 {
44  return "axlFieldSpatialPointDistanceWriter";
45 }
46 
48 {
49  return QStringList() << "axlAbstractField" << "axlAbstractFieldSpatial" << "axlFieldSpatialCoordinates";
50 }
51 
53 {
54  return dtkAbstractDataFactory::instance()->registerDataWriterType("axlFieldSpatialPointDistanceWriter", QStringList(), createaxlFieldSpatialPointDistanceWriter);
55 }
56 
57 bool axlFieldSpatialPointDistanceWriter::accept(dtkAbstractData *data)
58 {
59  axlFieldSpatialPointDistance *spatialField = dynamic_cast<axlFieldSpatialPointDistance *>(data);
60  if(spatialField)
61  return true;
62 
63  return false;
64 }
65 
66 bool axlFieldSpatialPointDistanceWriter::reject(dtkAbstractData *data)
67 {
68  return !this->accept(data);
69 }
70 
71 QDomElement axlFieldSpatialPointDistanceWriter::write(QDomDocument *doc, dtkAbstractData *data)
72 {
73  axlFieldSpatialPointDistance *field = dynamic_cast<axlFieldSpatialPointDistance *>(data);
74 
75  QDomElement fieldElement = doc->createElement("field");
76 
78  fieldElement.setAttribute("type", field->identifier());
79 
81 
82  QDomElement parameter = doc->createElement("input");
83  parameter.setAttribute("xcoordinate", field->getPoint()->x());
84  parameter.setAttribute("ycoordinate", field->getPoint()->y());
85  parameter.setAttribute("zcoordinate", field->getPoint()->z());
86  parameter.setAttribute("type", "data");
87  fieldElement.appendChild(parameter);
88 
89  return fieldElement;
90 }
91 
92 
93 
94 QDomElement axlFieldSpatialPointDistanceWriter::elementByWriter(axlAbstractDataWriter *axl_writer, QDomDocument *doc, dtkAbstractData *data)
95 {
96  QDomElement element;
97 
98  if(!axl_writer)
99  return element;
100 
101  if(!axl_writer->accept(data))
102  return element;
103 
104  element = axl_writer->write(doc, data);
105 
106  return element;
107 }
108 
109 dtkAbstractDataWriter *createaxlFieldSpatialPointDistanceWriter(void)
110 {
112 }
113 
QString identifier(void) const
Returns the identifier of the field "axlFieldSpatialPointDistance".
virtual bool accept(dtkAbstractData *data)=0
axlPoint * getPoint(void)
Returns the reference point.
dtkAbstractDataWriter * createaxlFieldSpatialPointDistanceWriter(void)
Class axlFieldSpatialPointDistance defines an API for spatial field.
double y
Definition: axlPoint.h:37
double z
Definition: axlPoint.h:38
virtual QDomElement write(QDomDocument *doc, dtkAbstractData *data)=0
QDomElement write(QDomDocument *doc, dtkAbstractData *data)
double x
Definition: axlPoint.h:37