Developer documentation | Axl-2.5.1

axlPlane.cpp
Go to the documentation of this file.
1 /* axlPlane.cpp ---
2  *
3  * Author: Meriadeg Perrinel
4  * Copyright (C) 2008 - Meriadeg Perrinel, Inria.
5  * Created: Tue Nov 9 16:58:59 2010 (+0100)
6  * Version: $Id$
7  * Last-Updated: Tue Nov 9 17:09:38 2010 (+0100)
8  * By: Meriadeg Perrinel
9  * Update #: 19
10  */
11 
12 /* Commentary:
13  *
14  */
15 
16 /* Change log:
17  *
18  */
19 
20 #include "axlPlane.h"
21 
22 #include "axlPoint.h"
23 
24 #include <dtkCoreSupport/dtkGlobal.h>
25 
26 // /////////////////////////////////////////////////////////////////
27 // axlPlanePrivate
28 // /////////////////////////////////////////////////////////////////
29 
30 class axlPlanePrivate
31 {
32 public:
33  axlPoint *point;
34  axlPoint *normal;
35 };
36 
37 // /////////////////////////////////////////////////////////////////
38 // axlPlane implementation
39 // /////////////////////////////////////////////////////////////////
40 
42 
47 axlPlane::axlPlane(QObject *parent) : axlAbstractData(), d(new axlPlanePrivate)
48 {
49  DTK_UNUSED(parent);
50 
51  this->setObjectName(this->identifier());
52 
53  d->point = new axlPoint;
54  d->normal = new axlPoint;
55 }
56 
58 
63 axlPlane::axlPlane(axlPoint *point, axlPoint *normal, QObject *parent) : axlAbstractData(), d(new axlPlanePrivate)
64 {
65  this->setObjectName(this->identifier());
66 
67  d->point = new axlPoint(point);
68  d->normal = new axlPoint(normal);
69 }
70 
72 
77 axlPlane::axlPlane(const axlPoint& point, const axlPoint& normal, QObject *parent) : axlAbstractData(), d(new axlPlanePrivate)
78 {
79  this->setObjectName(this->identifier());
80 
81  d->point = new axlPoint(point);
82  d->normal = new axlPoint(normal);
83 }
84 
86 
89 axlPlane::axlPlane(const axlPlane& other) : axlAbstractData(), d(new axlPlanePrivate)
90 {
91  this->setObjectName(this->identifier());
92  this->setParent(other.parent());
93  d->point = new axlPoint(other.d->point);
94  d->normal = new axlPoint(other.d->normal);
95 }
96 
98 
102 {
103  if(d->normal)
104  {
105  delete d->normal;
106  d->normal = NULL;
107  }
108  if(d->point)
109  {
110  delete d->point;
111  d->point = NULL;
112  }
113  delete d;
114  d = NULL;
115 }
116 
118 
122 {
123  *(d->point) = *(other.d->point);
124  *(d->normal) = *(other.d->normal);
125 
126  return (*this);
127 }
128 
130 
134 {
135  return d->point;
136 }
137 
139 
143 {
144  return d->normal;
145 }
146 
147 
149 
152 void axlPlane::setValues(axlPoint *point, axlPoint *normal)
153 {
154  *(d->point) = *point;
155  *(d->normal) = *normal;
156  //this->touchGeometry();
157 }
158 
160 
164 {
165  *(d->point) = *point;
166  //this->touchGeometry();
167 }
168 
169 void axlPlane::setPoint(double *p)
170 {
171  d->point->coordinates()[0] = p[0];
172  d->point->coordinates()[1] = p[1];
173  d->point->coordinates()[2] = p[2];
174  //this->touchGeometry();
175 }
176 
178 
182 {
183  *(d->normal) = *normal;
184  //this->touchGeometry();
185 }
186 
187 void axlPlane::setNormal(double *normal)
188 {
189  d->normal->coordinates()[0] = normal[0];
190  d->normal->coordinates()[1] = normal[1];
191  d->normal->coordinates()[2] = normal[2];
192 // this->touchGeometry();
193 }
194 
196 {
197  d->point->setCoordinates(point.x(),point.y(),point.z());
198  this->touchGeometry();
199 }
200 
202 {
203  d->normal->setCoordinates(normal.x(),normal.y(),normal.z());
204  this->touchGeometry();
205 }
206 
207 // /////////////////////////////////////////////////////////////////
208 // Debug operators
209 // /////////////////////////////////////////////////////////////////
210 
211 QDebug operator<<(QDebug dbg, axlPlane plane)
212 {
213  dbg.nospace() << plane.description();
214 
215  return dbg.space();
216 }
217 
218 QDebug operator<<(QDebug dbg, axlPlane& plane)
219 {
220  dbg.nospace() << plane.description();
221 
222  return dbg.space();
223 }
224 
225 QDebug operator<<(QDebug dbg, axlPlane *plane)
226 {
227  dbg.nospace() << plane->description();
228 
229  return dbg.space();
230 }
231 
232 QString axlPlane::description(void) const
233 {
234  QString result = "axlPlane";
235  result.append("\nPoint : "+d->point->description() + "\nNormal : "+d->normal->description());
236  return result;
237 }
238 
239 QString axlPlane::identifier(void) const
240 {
241  return "axlPlane";
242 }
243 
245 //void axlPlane::onPointChanged(axlPoint *point)
246 //{
247 // *(d->point) = *point;
249 //}
250 
251 //void axlPlane::onNormalChanged(axlPoint *normal)
252 //{
253 // *(d->normal) = *normal;
255 //}
256 
257 
258 QVariantList axlPlane::convertDataToQVariant(void) const{
259  QVariantList list;
260  QVariant id = QVariant::fromValue(identifier());
261  QVariantList point = d->point->convertDataToQVariant();
262  QVariantList normal = d->normal->convertDataToQVariant();
263  list.append(id);
264  list.append(point);
265  list.append(normal);
266  QVariant name = QVariant::fromValue(objectName());
267  list.append(name);
268  return list;
269 
270 }
271 
272 int axlPlane::convertQVariantToData(const QVariantList &data){
273  QVariantList point;
274  point.append(data.at(1));
275  point.append(data.at(2));
276  point.append(data.at(3));
277  point.append(data.at(4));
278  point.append(data.at(5));
279  d->point->convertQVariantToData(point);
280  QVariantList normal;
281  normal.append(data.at(6));
282  normal.append(data.at(7));
283  normal.append(data.at(8));
284  normal.append(data.at(9));
285  normal.append(data.at(10));
286  d->normal->convertQVariantToData(normal);
287  setObjectName(data.last().toString());
288  return 1;
289 }
290 
291 //to be registered to the data factory.
292 dtkAbstractData *createaxlPlane(void)
293 {
294  return new axlPlane;
295 }
296 
297 // /////////////////////////////////////////////////////////////////
298 // axlPlane documentation
299 // /////////////////////////////////////////////////////////////////
300 
void touchGeometry(void)
void setNormal(axlPoint *normal)
Change second point of this plane.
Definition: axlPlane.cpp:181
Class axlPoint defines 3D points.
Definition: axlPoint.h:34
Class axlPlane defines 3D planes.
Definition: axlPlane.h:34
void setValues(axlPoint *point, axlPoint *normal)
Change first point and second point of this plane.
Definition: axlPlane.cpp:152
axlPoint * point(void) const
Returns the point of the plane.
Definition: axlPlane.cpp:133
QDebug operator<<(QDebug dbg, axlPlane plane)
Definition: axlPlane.cpp:211
~axlPlane(void)
Destroys the axel plane.
Definition: axlPlane.cpp:101
void touchPoint(axlPoint point)
Definition: axlPlane.cpp:195
void setPoint(axlPoint *point)
Change first point of this plane.
Definition: axlPlane.cpp:163
axlPlane(QObject *parent=0)
Constructs a axel plane of with point and normal vector are NULL with parent parent of QObject type...
Definition: axlPlane.cpp:47
double y
Definition: axlPoint.h:37
void touchNormal(axlPoint normal)
Definition: axlPlane.cpp:201
axlPoint * normal(void) const
Returns the normal of the plane.
Definition: axlPlane.cpp:142
double z
Definition: axlPoint.h:38
virtual QString identifier(void) const
Definition: axlPlane.cpp:239
virtual QString description(void) const
Definition: axlPlane.cpp:232
int convertQVariantToData(const QVariantList &data)
Modify properties and geometry variables of the axlAbstractData. Return 1 if the modification was suc...
Definition: axlPlane.cpp:272
axlPlane & operator=(const axlPlane &other)
Assigns other to this plane and returns a reference to this plane.
Definition: axlPlane.cpp:121
QVariantList convertDataToQVariant(void) const
Convert an axlAbstractData into a QVariantList that specifies all properties of the axlAbstractData...
Definition: axlPlane.cpp:258
double x
Definition: axlPoint.h:37
Class axlAbstractData defines an API for all type of axel data.
dtkAbstractData * createaxlPlane(void)
Definition: axlPlane.cpp:292