Developer documentation | Axl-2.5.1

axlFieldSpatialCoordinates.cpp
Go to the documentation of this file.
1 /* axlFieldSpatialCoordinates.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 "axlAbstractProcess.h"
18 #include <axlCore/axlPoint.h>
19 
20 #include <dtkCoreSupport/dtkGlobal.h>
21 
22 #include <dtkCoreSupport/dtkAbstractDataFactory.h>
23 #include <dtkCoreSupport/dtkAbstractProcessFactory.h>
24 
25 class axlFieldSpatialCoordinatesPrivate
26 {
27 public:
28 
29 // axlFieldSpatialCoordinates::Kind kind;
30 // axlFieldSpatialCoordinates::Type type;
31 // axlFieldSpatialCoordinates::Support support;
32  double a;
33  double b;
34  double c;
35 
36 };
37 
38 // /////////////////////////////////////////////////////////////////
39 // axlFieldSpatialCoordinates implementation
40 // /////////////////////////////////////////////////////////////////
41 
43 
47 {
51  this->setObjectName(this->identifier());
52 
53  d->a = 0;
54  d->b = 0;
55  d->c = 1;
56 
57 }
58 
59 
60 
62 
66 {
67  delete d;
68 
69  d = NULL;
70 }
71 
72 
74 
77 double axlFieldSpatialCoordinates::scalar(double x, double y, double z)
78 {
79  return (d->a*x +d->b*y +d->c*z);
80 }
81 
82 
84 
87 void axlFieldSpatialCoordinates::setParameter(double parameter, int channel){
88 
89  if(channel == 0)
90  d->a = parameter;
91  else if(channel ==1)
92  d->b = parameter;
93  else if(channel ==2)
94  d->c = parameter;
95  else
96  qDebug()<< "3 channels possible : 0 to 2";
97 
98 }
99 
101 
105  if(channel ==0)
106  return d->a;
107  else if(channel ==1)
108  return d->b;
109  else if (channel == 2)
110  return d->c;
111  else {
112  qDebug() << "channel has only three possible values : 0 to 2.";
113  return -1;
114  }
115 
116 }
117 
118 
120 
124 {
125  QString qstr;
126 
127  qstr.append("axlFieldSpatialCoordinates : ");
128  qstr.append("Type : Float");
129  qstr.append(";Kind : Scalar");
130  qstr.append(";Support : Point");
131 
132  return qstr;
133 
134 }
135 
137 
141 {
142  return "axlFieldSpatialCoordinates";
143 
144 }
145 
146 
149 
153 {
154  emit updated();
155 }
156 
157 // /////////////////////////////////////////////////////////////////
158 // axlFieldSpatialCoordinates documentation
159 // /////////////////////////////////////////////////////////////////
160 
167 // /////////////////////////////////////////////////////////////////
168 // Type instanciation
169 // /////////////////////////////////////////////////////////////////
170 
171 dtkAbstractData *createaxlFieldSpatialCoordinates(void)
172 {
173  return new axlFieldSpatialCoordinates;
174 }
Class axlFieldSpatialCoordinates defines an API for spatial field. The value are computed as follow :...
QString identifier(void) const
Returns the identifier of the field which is "axlFieldSpatialCoordinates".
dtkAbstractData * createaxlFieldSpatialCoordinates(void)
Class axlAbstractFieldSpatial defines an API for spatial field.
double parameter(int channel)
Returns the channel-th parameter value.
virtual void setType(Type type)
Sets the type of the field which can be either int, float or double.
virtual ~axlFieldSpatialCoordinates(void)
Destroys a spatial field.
QString description(void) const
Returns the description of the field.
void setParameter(double parameter, int channel)
Sets the coordinates direction.
virtual void setSupport(Support support)
virtual void setKind(Kind kind)
Sets the kind of the field which can be either scalar, vector or tensor.
double scalar(double x, double y=0, double z=0)
Returns the value of the spatial field at the coordinates point entered.