Developer documentation | Axl-2.5.1

axlFieldSpatialCoordinatesCreator.cpp
Go to the documentation of this file.
1 /* axlFieldSpatialCoordinatesCreator.h ---
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 
19 
20 #include <dtkCoreSupport/dtkAbstractProcessFactory.h>
21 #include <dtkCoreSupport/dtkAbstractDataFactory.h>
22 #include <dtkCoreSupport/dtkGlobal.h>
23 #include <QtGui>
24 
25 class axlFieldSpatialCoordinatesCreatorPrivate
26 {
27 public:
28  axlAbstractData * input;
29  double a;
30  double b;
31  double c;
32  axlFieldSpatialCoordinates *spatialField;
33 };
34 
36 {
37  d->a = 0;
38  d->b = 0;
39  d->c = 1;
40  d->input = NULL;
41  d->spatialField = NULL;
42 
43 }
44 
46 {
47  delete d;
48  d = NULL;
49 }
50 
51 void axlFieldSpatialCoordinatesCreator::setInput(dtkAbstractData *data, int channel)
52 {
53  if(axlAbstractData *axlData = dynamic_cast<axlAbstractData *>(data))
54  {
55  d->input = axlData;
56  }
57 
58 }
59 
60 
61 
62 void axlFieldSpatialCoordinatesCreator::setParameter(double value, int channel)
63 {
64  if(channel ==0)
65  d->a = value;
66  else if (channel == 1)
67  d->b = value;
68  else if (channel ==2)
69  d->c = value;
70  else
71  qDebug() << "channel has only three values possible : 0 to 2";
72 
73 }
74 
75 
77 {
78  if(!d->input)
79  return 0;
80 
81 
82  //create field
83  d->spatialField = new axlFieldSpatialCoordinates();
84  QString newName = d->input->changeFieldName(d->spatialField->objectName());
85  d->spatialField->setObjectName(newName);
86  d->input->addField(d->spatialField);
87 
88  if(!d->spatialField) // field not found !!
89  return 0;
90 
91 
92  d->spatialField->setParameter(d->a,0);
93  d->spatialField->setParameter(d->b,1);
94  d->spatialField->setParameter(d->c,2);
95  d->spatialField->update();
96 
97  // }
98 
99  QList<axlAbstractData *>list;
100  list << d->input;
101  emit dataSetFieldsChanged(list, d->spatialField->objectName());
102 
103 
104  return 1;
105 
106 }
107 
109 {
110  return "axlFieldSpatialCoordinatesCreator created fields for input dataset that evaluate ax+by+cz with (a,b,c) the direction chosen";
111 }
112 
114 {
115  return "axlFieldSpatialCoordinateGenerator";
116 }
117 
118 // /////////////////////////////////////////////////////////////////
119 // Type instanciation
120 // /////////////////////////////////////////////////////////////////
121 
123 {
125 }
126 
127 
Class axlFieldSpatialCoordinates defines an API for spatial field. The value are computed as follow :...
void dataSetFieldsChanged(QList< axlAbstractData * > dataSet, QString fieldName)
dtkAbstractProcess * createaxlFieldSpatialCoordinatesCreator(void)
Class axlAbstractData defines an API for all type of axel data.
void setInput(dtkAbstractData *data, int channel)