Developer documentation | Axl-2.5.1

axlFieldSpatialPointDistance.cpp
Go to the documentation of this file.
1 /* axlFieldSpatialPointDistance.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 #include <sstream>
15 
17 #include "axlPoint.h"
18 #include "axlAbstractProcess.h"
19 
20 #include <dtkCoreSupport/dtkGlobal.h>
21 
22 #include <dtkCoreSupport/dtkAbstractDataFactory.h>
23 #include <dtkCoreSupport/dtkAbstractProcessFactory.h>
24 
25 class axlFieldSpatialPointDistancePrivate
26 {
27 public:
28 
29  axlPoint *point;
30 
31 
32 
33 };
34 
35 // /////////////////////////////////////////////////////////////////
36 // axlFieldSpatialPointDistance implementation
37 // /////////////////////////////////////////////////////////////////
38 
40 
44 {
45 
49  this->setObjectName(this->identifier());
50  d->point = new axlPoint(0,0,0);
51 }
52 
53 
54 
56 
60 {
61 
62  if(d->point){
63  delete d->point;
64  d->point = NULL;
65  }
66 
67  delete d;
68 
69  d = NULL;
70 }
71 
72 
74 
77 void axlFieldSpatialPointDistance::setParameter(double data, int channel){
78  if(channel ==0){
79  d->point->x() = data; //onXChanged(data);
80  }else if(channel == 1){
81  d->point->y() = data; //onYChanged(data);
82  }else if(channel==2){
83  d->point->z() = data; //onZChanged(data);
84  }
85 
86 }
87 
88 
90 
94  return d->point;
95 }
96 
97 
99 
102 double axlFieldSpatialPointDistance::scalar(double x, double y, double z)
103 {
104  return std::abs((x-d->point->x()) * (x-d->point->x()) + (y-d->point->y()) * (y-d->point->y()) + (z-d->point->z()) * (z-d->point->z()));
105 }
106 
107 
109 
113 {
114  QString qstr;
115 
116  qstr.append("axlFieldSpatialPointDistance");
117  qstr.append("Type : Float");
118  qstr.append(";Kind : Scalar");
119  qstr.append(";Support : Point");
120 
121  return qstr;
122 
123 }
124 
125 
127 
131 {
132  return "axlFieldSpatialPointDistance";
133 }
134 
135 
138 
142 {
143  emit updated();
144 }
145 
146 // /////////////////////////////////////////////////////////////////
147 // axlFieldSpatialPointDistance documentation
148 // /////////////////////////////////////////////////////////////////
149 
156 // /////////////////////////////////////////////////////////////////
157 // Type instanciation
158 // /////////////////////////////////////////////////////////////////
159 
161 {
162  return new axlFieldSpatialPointDistance;
163 }
164 
Class axlPoint defines 3D points.
Definition: axlPoint.h:34
QString identifier(void) const
Returns the identifier of the field "axlFieldSpatialPointDistance".
dtkAbstractData * createAxlFieldSpatialPointDistance(void)
double scalar(double x, double y=0, double z=0)
Returns the value of the spatial field at the coordinates point entered.
virtual ~axlFieldSpatialPointDistance(void)
Destroys a spatial field.
axlPoint * getPoint(void)
Returns the reference point.
Class axlAbstractFieldSpatial defines an API for spatial field.
Class axlFieldSpatialPointDistance defines an API for spatial field.
virtual void setType(Type type)
Sets the type of the field which can be either int, float or double.
virtual void setSupport(Support support)
QString description(void) const
Returns the description of the field.
void setParameter(double data, int channel)
Sets the reference point.
virtual void setKind(Kind kind)
Sets the kind of the field which can be either scalar, vector or tensor.