Developer documentation | Axl-2.5.1

axlCompositeCurve.cpp
Go to the documentation of this file.
1 #include "axlCompositeCurve.h"
3 
4 #include <dtkCoreSupport/dtkGlobal.h>
5 
6 class axlCompositeCurvePrivate
7 {
8 public:
9  QList<axlAbstractCurve *> data; //data for curve
10  QPair<axlPoint *, axlPoint *> ends;//data for two end points.
11  bool tag;// tag : when tag == true -> just use "data", else use "ends". More details in headers file.
12  //this tag wil help us do not mix between two ways of Composite curve.
13 };
14 axlCompositeCurve::axlCompositeCurve(QObject *parent) : axlAbstractCurveParametric(), d(new axlCompositeCurvePrivate)
15 {
16 
17 };
18 
19 axlCompositeCurve::axlCompositeCurve(bool Case,QObject *parent) : axlAbstractCurveParametric(), d(new axlCompositeCurvePrivate)
20 {
21  d->tag = Case;
22 };
23 
25 {
26  delete d;
27  d = NULL;
28 };
29 
31 {
32  d->tag = Case;
33 }
34 
36 {
37  return d->tag;
38 }
40 {
41  if(d->tag)
42  return d->data.value(id);
43  else
44  return NULL;
45 }
46 
48 {
49  return d->data.size();
50 }
51 
52 void axlCompositeCurve::insert_list_curves(const QList<axlAbstractCurve *>& data_curves)
53 {
54  if(d->tag)
55  d->data.append(data_curves);
56 }
57 
58 void axlCompositeCurve::insert_list_curves(const QList<axlAbstractCurve>& data_curve)
59 {
60  if(d->tag)
61  {
62  for(int i = 0; i<data_curve.size(); i++)
63  {
64  d->data.append(new axlAbstractCurve(data_curve.value(i)));
65  }
66  }
67 }
68 
69 void axlCompositeCurve::insert_curve(axlAbstractCurve *curve, int id_want_inserted)
70 {
71  if(d->tag)
72  {
73  d->data.insert(id_want_inserted,curve);
74  }
75 }
76 
77 void axlCompositeCurve::insert_curve(axlAbstractCurve curve, int id_want_inserted)
78 {
79  if(d->tag)
80  {
81  d->data.insert(id_want_inserted,new axlAbstractCurve(curve));
82  }
83 }
84 
86 {
87  if(d->tag)
88  {
89  d->data.append(new axlAbstractCurve(curve));
90  }
91 }
93 {
94  if(d->tag)
95  {
96  d->data.append(curve);
97  }
98 }
99 
100 void axlCompositeCurve::append_point(const axlPoint& startPoint,const axlPoint& endPoint)
101 {
102  if(!d->tag)
103  {
104  d->ends.first = new axlPoint(startPoint);
105  d->ends.second = new axlPoint(endPoint);
106  }
107 }
109 {
110  if(!d->tag)
111  {
112  d->ends.first = startPoint;
113  d->ends.second = endPoint;
114  }
115 }
116 
118 {
119  return d->ends.first;
120 }
122 {
123  return d->ends.second;
124 }
126 {
127  if(d->tag)
128  d->data.removeLast();
129 }
130 
132 {
133  if(d->tag)
134  d->data.removeAt(id_want_remove);
135 }
136 
138 {
139  QString s = "axlCompositeCurve";
140  if(d->tag)
141  {
142  for(int i = 0; i <d->data.size(); i++)
143  {
144  s.append(d->data.at(i)->description() + "\n");
145  }
146  }
147  else
148  {
149  s.append(d->ends.first->description() + "\n");
150  s.append(d->ends.second->description());
151  }
152  return s;
153 }
154 
155 QString axlCompositeCurve::identifier(void) const
156 {
157  return "axlCompositeCurve";
158 }
159 
161 {
162  d->tag = other.d->tag;
163  d->data.clear();
164  if(d->tag)
165  {
166  d->data.append(other.d->data);
167  }
168  else
169  {
170  d->ends = other.d->ends;
171  }
172  return (*this);
173 }
174 
175 dtkAbstractData *createaxlCompositeCurve(void)
176 {
177  return new axlCompositeCurve;
178 }
dtkAbstractData * createaxlCompositeCurve(void)
Class axlPoint defines 3D points.
Definition: axlPoint.h:34
void remove_curve_at_id(int id_want_remove)
axlPoint * get_start_point()
void setCase(bool Case)
axlCompositeCurve & operator=(const axlCompositeCurve &other)
int count_curve(void) const
void append_point(const axlPoint &startPoint, const axlPoint &endPoint)
axlAbstractCurve * get_pt_curve_at_id(int id) const
void insert_curve(axlAbstractCurve *curve, int id_want_inserted)
void insert_list_curves(const QList< axlAbstractCurve > &data_curves)
axlPoint * get_end_point()
Generic interface for parametric curve.
void append_curve(const axlAbstractCurve &curve)
axlCompositeCurve(QObject *parent=0)
virtual QString description(void) const
virtual QString identifier(void) const