Developer documentation | Axl-2.5.1

axlCircleArcCreator.cpp
Go to the documentation of this file.
1 /* axlCircleArcCreator.cpp ---
2  *
3  * Author: Anais Ducoffe
4  * Copyright (C) 2013, Anais Ducoffe, INRIA.
5  */
6 
7 /* Commentary:
8  */
9 
10 /* Change log:
11  *
12  */
13 #include "axlCircleArcCreator.h"
14 #include <axlCore/axlPoint.h>
15 #include <axlCore/axlCircleArc.h>
16 #include <axlCore/axlInteger.h>
18 
19 #include <dtkCoreSupport/dtkAbstractProcessFactory.h>
20 
24 
25 class axlCircleArcCreatorPrivate{
26 
27 public :
28  axlPoint *point1;
29  axlPoint *point2;
30  axlPoint *point3;
31  axlPoint *point4;
32  bool direct;
33  axlCircleArc *output;
34 };
35 
39 axlCircleArcCreator::axlCircleArcCreator(QObject *parent) : axlAbstractCreatorProcess(), d(new axlCircleArcCreatorPrivate) {
40  d->point1 = NULL;
41  d->point2 = NULL;
42  d->point3 = NULL;
43  d->point4 = NULL;
44  d->direct = true;
45  d->output = NULL;
46 }
47 
49 
50  delete d;
51  d = NULL;
52 }
53 
55 
62  if(channel == 0) {
63  return d->point1;
64  } else if(channel == 1) {
65  return d->point2;
66  } else if (channel == 2) {
67  return d->point3;
68  } else if (channel == 3) {
69  return d->point4;
70  } else {
71  return NULL;
72  }
73 }
74 
76 
80  if(process->output()){
81  d->output = dynamic_cast<axlCircleArc *>(process->output());
82  }
83 }
84 
86 
90  return true;
91 }
92 
94 
97 dtkAbstractData *axlCircleArcCreator::output(void){
98  return d->output;
99 }
100 
102 
108 void axlCircleArcCreator::setInput(dtkAbstractData *newData, int channel){
109  if(dynamic_cast<axlPoint *>(newData)){
110  axlPoint *point = dynamic_cast<axlPoint *>(newData);
111  if(channel == 0){
112  d->point1 = point;
113  }else if(channel == 1){
114  d->point2 = point;
115  }
116  else if(channel == 2){
117  d->point3 = point;
118  }
119  else if(channel == 3){
120  d->point4 = point;
121  }
122  }
123 }
124 
126 
130  if(data == 0 || data == 1){
131  d->direct = data;
132  }
133 
134 }
135 
137 
141 
142  if(d->output == NULL){
143  if(d->point1 && d->point2 && d->point3 && d->point4){
144  d->output = new axlCircleArc(d->point1, d->point2, d->point3, d->point4, d->direct);
145  return 1;
146  }else{
147  return 0;
148  }
149  }else{
150  if(d->point1 && d->point2 && d->point3 && d->point4){
151  d->output->setValues(d->point1, d->point2, d->point3, d->point4, d->direct);
152  return 1;
153  }else{
154  return 0;
155  }
156 
157  }
158 
159 }
160 
162  return "create a circle arc with four points : \n the two first ones are extremity, the third one is its center\n and the last one its normal \n and a boolean :\n the direction";
163 }
164 
165 
167  return "axlCircleArcCreator";
168 }
169 
170 dtkAbstractProcess *createaxlCircleArcCreator(void){
171 
172  return new axlCircleArcCreator;
173 }
174 
175 
176 // /////////////////////////////////////////////////////////////////
177 // axlCircleArcCreator documentation
178 // /////////////////////////////////////////////////////////////////
179 
Class axlPoint defines 3D points.
Definition: axlPoint.h:34
virtual void setParameter(int data)
Assigns the value of the boolean parameter which says whether it is direct .
virtual ~axlCircleArcCreator(void)
virtual QString description(void) const
Class axlCircleArcCreator defines an process which creates an axlCircleArc.
virtual dtkAbstractData * output(void)
Return the results of the process : NULL or the axlCircleArc.
dtkAbstractProcess * createaxlCircleArcCreator(void)
void copyProcess(axlAbstractProcess *process)
Return a copy of the process, useful for dynamic objects.
virtual int update(void)
Create an axlCircleArc.
virtual void setInput(dtkAbstractData *newData, int channel)
Assigns points :
virtual axlAbstractData * getInput(int channel) const
Return the input points of the process.
axlCircleArcCreator(QObject *parent=0)
bool hasParameters(void)
Return true as the process needs one parameter.
Class axlAbstractData defines an API for all type of axel data.
virtual QString identifier(void) const