Developer documentation | Axl-2.5.1

axlAbstractView.cpp
Go to the documentation of this file.
1 /* axlAbstractView.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 "axlAbstractView.h"
23 #include "axlAbstractActor.h"
24 #include "axlAbstractActorField.h"
25 #include "axlAbstractField.h"
26 #include "axlViewController.h"
27 #include "axlDataDynamic.h"
28 
29 #include <dtkCoreSupport/dtkAbstractViewFactory.h>
30 
31 
32 class axlAbstractViewPrivate
33 {
34 public:
35  axlViewController *view_controller;
36 };
37 
38 axlAbstractView::axlAbstractView(void) : dtkAbstractView(), d(new axlAbstractViewPrivate)
39 {
40  d->view_controller = new axlViewController;
41 
42  connect(d->view_controller, SIGNAL(inserted()), this, SIGNAL(inserted()));
43 }
44 
46 {
47  disconnect(d->view_controller, SIGNAL(inserted()), this, SIGNAL(inserted()));
48 
49  delete d->view_controller;
50  delete d;
51 
52  d = NULL;
53 }
54 
56 {
57  DTK_DEFAULT_IMPLEMENTATION;
58 
59  Q_UNUSED(data);
60 
61  return NULL;
62 }
63 
64 QList<axlAbstractActor *> axlAbstractView::insertSet(QList<axlAbstractData *> dataSet)
65 {
66  DTK_DEFAULT_IMPLEMENTATION;
67 
68  Q_UNUSED(dataSet);
69 
70  return QList<axlAbstractActor *>();
71 }
72 
73 void axlAbstractView::removeSet(QList<axlAbstractActor *> actorSet)
74 {
75  DTK_DEFAULT_IMPLEMENTATION;
76 
77  Q_UNUSED(actorSet);
78 }
79 
80 void axlAbstractView::removeSetFields(QList<axlAbstractActorField *> actorSet)
81 {
82  DTK_DEFAULT_IMPLEMENTATION;
83 
84  Q_UNUSED(actorSet);
85 }
86 
87 void axlAbstractView::activeDefaultLigh(bool useDefaultLight)
88 {
89  DTK_DEFAULT_IMPLEMENTATION;
90 
91  Q_UNUSED(useDefaultLight);
92 }
93 
94 void axlAbstractView::setLight(int i, bool hide, double *position, double *ambiant, double *diffuse, double *specular, int exponent)
95 {
96  DTK_DEFAULT_IMPLEMENTATION;
97 
98  Q_UNUSED(i);
99  Q_UNUSED(hide);
100  Q_UNUSED(position);
101  Q_UNUSED(ambiant);
102  Q_UNUSED(diffuse);
103  Q_UNUSED(specular);
104  Q_UNUSED(exponent);
105 }
106 
108 {
109  if(axlAbstractField *axlData = dynamic_cast<axlAbstractField *> (data))
110  return d->view_controller->actorField(axlData);
111  else
112  return d->view_controller->actor(data);
113 }
114 
115 void axlAbstractView::insert(dtkAbstractData *data, axlAbstractActor *actor)
116 {
117  axlAbstractField *dataField = dynamic_cast<axlAbstractField *>(data);
118  axlAbstractActorField *actorField = dynamic_cast<axlAbstractActorField *>(actor);
119 
120 
121  if(dataField && actorField)
122  d->view_controller->insertField(dataField, actorField);
123  else
124  d->view_controller->insert(data, actor);
125 }
126 
127 void axlAbstractView::removeData(dtkAbstractData *data)
128 {
129  d->view_controller->remove(data);
130 }
131 
132 void axlAbstractView::removeField(dtkAbstractData *data)
133 {
134  if(axlAbstractField* dataField = dynamic_cast<axlAbstractField*>(data))
135  d->view_controller->removeField(dataField);
136 }
137 
139 {
140  return d->view_controller;
141 }
142 
144 {
145  DTK_DEFAULT_IMPLEMENTATION;
146 }
147 
149 {
150  DTK_DEFAULT_IMPLEMENTATION;
151 }
152 
154 {
155  DTK_DEFAULT_IMPLEMENTATION;
156 }
157 
159 {
160  DTK_DEFAULT_IMPLEMENTATION;
161 }
162 
164 {
165  DTK_DEFAULT_IMPLEMENTATION;
166 }
167 
169 {
170  DTK_DEFAULT_IMPLEMENTATION;
171 }
172 
174 {
175  DTK_DEFAULT_IMPLEMENTATION;
176 }
177 
178 void axlAbstractView::setCameraPosition(double x, double y, double z)
179 {
180  DTK_DEFAULT_IMPLEMENTATION;
181 }
182 
183 void axlAbstractView::setGrid(bool isGridX, bool isGridY, bool isGridZ)
184 {
185  Q_UNUSED(isGridX);
186  Q_UNUSED(isGridY);
187  Q_UNUSED(isGridZ);
188 
189  DTK_DEFAULT_IMPLEMENTATION;
190 }
191 
192 void axlAbstractView::showColorMapping(dtkAbstractData *data)
193 {
194  if(dynamic_cast<axlAbstractSurfaceBSpline *>(data))
195  d->view_controller->actor(data)->onSamplingChanged();
196 }
197 
198 void axlAbstractView::onShaderChanged(dtkAbstractData *data, QString isophoteShaderXml)
199 {
200  d->view_controller->actor(data)->setShader(isophoteShaderXml);
201 }
202 
203 void axlAbstractView::onControlPointChanged(dtkAbstractData *data)
204 {
205  d->view_controller->actor(data)->onControlPointChanged();
206 // this->widget()->update();
207  this->update();
208 }
209 
210 void axlAbstractView::onTubeFilterRadiusChanged(dtkAbstractData *data, double radius)
211 {
212  if(dynamic_cast<axlAbstractCurveBSpline *>(data))
213  d->view_controller->actor(data)->onTubeFilterRadiusChanged(radius);
214  else
215  d->view_controller->actor(data)->setSize(radius);
216 
217  this->update();
218 }
219 
220 void axlAbstractView::processIsophoteByShader(dtkAbstractData *data, QString isophoteShaderXml)
221 {
222  if(dynamic_cast<axlAbstractSurfaceBSpline *>(data))
223  d->view_controller->actor(data)->setShaderFromString(isophoteShaderXml);
224 }
225 
226 void axlAbstractView::dataChangedByGeometry(dtkAbstractData *data)
227 {
228  d->view_controller->actor(data)->onUpdateGeometry();
229 }
230 
231 
232 void axlAbstractView::dataChangedByOpacity(dtkAbstractData *data, double opacity)
233 {
234  d->view_controller->actor(data)->setOpacity(opacity);
235 }
236 
237 void axlAbstractView::dataChangedBySize(dtkAbstractData *data, double size)
238 {
239  d->view_controller->actor(data)->setSize(size);
240 }
241 
242 void axlAbstractView::dataChangedByColor(dtkAbstractData *data, double red, double green, double blue)
243 {
244  d->view_controller->actor(data)->setColor(red, green, blue);
245 }
246 
248 
255 void axlAbstractView::dataChangedByProperty(dtkAbstractData *data, int channel)
256 {
257  if (channel == 0) {
258  //qDebug() << Q_FUNC_INFO;
259  QColor color = dynamic_cast<axlAbstractData *>(data)->color();
260  d->view_controller->actor(data)->setColor(color.red(), color.green(), color.blue());
261  } else if (channel == 1) {
262  double opacity = dynamic_cast<axlAbstractData *>(data)->opacity();
263  d->view_controller->actor(data)->setOpacity(opacity);
264  } else if (channel == 2) {
265  QString xmlFile = dynamic_cast<axlAbstractData *>(data)->shader();
266  d->view_controller->actor(data)->setShader(xmlFile);
267  } else if (channel == 3) {
268  double size = dynamic_cast<axlAbstractData *>(data)->size();
269  axlAbstractActor *actor = d->view_controller->actor(data);
270  if (actor) {
271  //qDebug() << Q_FUNC_INFO<< "size";
272  // if(!(actor->identifier()=="axlActorMesh")){
273  // d->view_controller->actor(data)->onUpdateGeometry();
274  // }else{
275  actor->setSize(size);
276  // }
277  }
278  }
279 
280  // if(!dynamic_cast<axlAbstractData *>(data)->fields().isEmpty())
281  // dynamic_cast<axlAbstractData *>(data)->runFieldUpdated();
282 
283  this->update();
284 }
285 
286 void axlAbstractView::onInterpolationChanded(dtkAbstractData *data, int interpolation)
287 {
288  d->view_controller->actor(data)->setInterpolation(interpolation);
289 }
290 
291 void axlAbstractView::onStateChanged(dtkAbstractData *data, int mode)
292 {
293  d->view_controller->actor(data)->onModeChanged(mode);
294 // this->widget()->update();
295  this->update();
296 }
297 
298 void axlAbstractView::onActorVisibilityChanged(dtkAbstractData *data, bool actorVisibility)
299 {
300  if(actorVisibility){
301  d->view_controller->actor(data)->show();
302  if( axlDataDynamic* axlData = dynamic_cast<axlDataDynamic*>(data)){
303  int indiceOutput = axlData->numberOfChannels();
304  for( int i = 0; i < indiceOutput; i++){
305  d->view_controller->actor(axlData->outputs(i))->show();
306  }
307  }
308 
309 
310  if(d->view_controller->actor(data)->parent()){
311  //hide parents for dynamic object, the problem is hide not just one output actor.
312  d->view_controller->actor(data)->parent()->show();
313  }
314  // axlAbstractData* axlData = dynamic_cast<axlAbstractData*>(data);
315  // foreach(axlAbstractField* field, axlData->fields()){
316  // d->view_controller->actorField(field)->show();
317  // }
318  }
319  else{
320  d->view_controller->actor(data)->hide();
321 
322  if( axlDataDynamic* axlData = dynamic_cast<axlDataDynamic*>(data)){
323  int indiceOutput = axlData->numberOfChannels();
324  for( int i = 0; i < indiceOutput; i++){
325  d->view_controller->actor(axlData->outputs(i))->hide();
326  }
327 
328  }
329 
330  if(d->view_controller->actor(data)->parent()){
331  //hide parents for dynamic object, not just one output actor.
332  d->view_controller->actor(data)->parent()->hide();
334  // if(axlDataDynamic* axlObject = dynamic_cast<axlDataDynamic *>(d->view_controller->actor(data)->parent()->data())){
335  // int indiceO = axlObject->numberOfChannels();
336  // for( int i = 0; i < indiceO; i++){
337  // if(d->view_controller->actor(axlObject->outputs(i))->data()->objectName() == d->view_controller->actor(data)->objectName() ){
338  // qDebug() << "passe a l'endroit souhaite";
339  // d->view_controller->actor(axlObject->outputs(i))->hide();
340  // }
341  // }
342 
343  // }
344  }
345  // axlAbstractData* axlData = dynamic_cast<axlAbstractData*>(data);
346  // foreach(axlAbstractField* field, axlData->fields()){
347  // d->view_controller->actorField(field)->hide();
348  // }
349 
350 
352  if (!dynamic_cast<axlAbstractData *>(data)->fields().isEmpty()) {
353  foreach (axlAbstractField * field,dynamic_cast<axlAbstractData *>(data)->fields() ) {
354  axlAbstractField::Kind kind = field->kind();
355 
356  if (kind == axlAbstractField::Scalar) {
357  d->view_controller->actorField(field)->displayAsNoneScalar();
358  } else if (kind == axlAbstractField::Vector) {
359  d->view_controller->actorField(field)->displayAsNoneVector();
360  }
361 
362  }
363  }
364  }
365 
366 // this->widget()->update();
367  this->update();
368 }
369 
370 void axlAbstractView::ondataSetRemoved(QList<dtkAbstractData *> dataSetToRemoved)
371 {
372  QList<axlAbstractActor *> actorSetToRemoved;
373  QList<axlAbstractActorField *> actorSetFieldToRemoved;
374 
375  for(int i = 0 ; i < dataSetToRemoved .size() ; i++)
376  {
377  if(axlAbstractActor *actor = d->view_controller->actor(dataSetToRemoved.value(i)))
378  actorSetToRemoved << actor;
379 
380  if (axlAbstractData* data = dynamic_cast<axlAbstractData*>(dataSetToRemoved.value(i))){
381  foreach(axlAbstractField* field,data->fields()){
382  if(axlAbstractActorField *actor = d->view_controller->actorField(field)){
383  actorSetFieldToRemoved << actor;
384  }
385  }
386  }
387  }
388  this->removeSet(actorSetToRemoved);
389  this->removeSetFields(actorSetFieldToRemoved);
390 }
391 
393 {
394  return d->view_controller->size();
395 }
396 
397 void axlAbstractView::onLightPositionChanged(double x, double y, double z)
398 {
399  emit lightPositionChanged(x, y, z);
400 }
401 
403 {
404  Q_UNUSED(resolution);
405 
406  DTK_DEFAULT_IMPLEMENTATION;
407 }
408 
410 {
411  Q_UNUSED(show);
412 
413  DTK_DEFAULT_IMPLEMENTATION;
414 }
415 
417 {
418  Q_UNUSED(gradient);
419 
420  DTK_DEFAULT_IMPLEMENTATION;
421 }
422 
424 {
425  DTK_DEFAULT_IMPLEMENTATION;
426 
427  return 0;
428 }
429 
430 void axlAbstractView::setParallelScale(double parallelScale)
431 {
432  Q_UNUSED(parallelScale);
433 
434  DTK_DEFAULT_IMPLEMENTATION;
435 }
436 
438 {
439  DTK_DEFAULT_IMPLEMENTATION;
440 
441  return 0.0;
442 }
443 
445 {
446  DTK_DEFAULT_IMPLEMENTATION;
447 
448  return NULL;
449 }
450 
452 {
453  DTK_DEFAULT_IMPLEMENTATION;
454 
455  return 0;
456 }
457 
459 {
460  DTK_DEFAULT_IMPLEMENTATION;
461 
462  return 0;
463 }
464 
466 {
467  DTK_DEFAULT_IMPLEMENTATION;
468 
469  return NULL;
470 }
471 
472 void axlAbstractView::setCameraFocalPoint(double x, double y, double z)
473 {
474  Q_UNUSED(x);
475  Q_UNUSED(y);
476  Q_UNUSED(z);
477 
478  DTK_DEFAULT_IMPLEMENTATION;
479 }
480 
482 {
483  DTK_DEFAULT_IMPLEMENTATION;
484 
485  return NULL;
486 }
487 
488 void axlAbstractView::setCameraUp(double x, double y, double z)
489 {
490  Q_UNUSED(x);
491  Q_UNUSED(y);
492  Q_UNUSED(z);
493 
494  DTK_DEFAULT_IMPLEMENTATION;
495 }
496 
498 {
499  DTK_DEFAULT_IMPLEMENTATION;
500 
501  return 0.0;
502 }
503 
505 {
506  Q_UNUSED(angle);
507 
508  DTK_DEFAULT_IMPLEMENTATION;
509 }
510 
511 
513  DTK_DEFAULT_IMPLEMENTATION;
514 
515  return NULL;
516 }
517 
519 {
520  Q_UNUSED(parallel);
521 
522  DTK_DEFAULT_IMPLEMENTATION;
523 }
524 
526 
529 void axlAbstractView::add(dtkAbstractData *data)
530 {
531  if(axlAbstractData *axldata = dynamic_cast<axlAbstractData *>(data) )
532  {
533  if(!d->view_controller->contains(axldata))
534  emit insertData(axldata);
535  else
536  dtkWarn() << "this data has already been inserted";
537  }
538 }
539 
541 
544 void axlAbstractView::updateFieldActor(dtkAbstractData *data)
545 {
546  Q_UNUSED(data);
547 
548  DTK_DEFAULT_IMPLEMENTATION;
549 }
550 
551 
552 
553 
555 {
556  DTK_DEFAULT_IMPLEMENTATION;
557 }
558 
560 {
561  DTK_DEFAULT_IMPLEMENTATION;
562 }
563 
565 {
566  DTK_DEFAULT_IMPLEMENTATION;
567 }
568 
570 {
571  DTK_DEFAULT_IMPLEMENTATION;
572 }
573 
574 
576 {
577 
578 }
579 
580 void axlAbstractView::onUpdateActorField(QList<axlAbstractData *> axlDataSet, QString fieldName)
581 {
582  Q_UNUSED(axlDataSet);
583 }
584 
585 
586 dtkAbstractViewFactory *axlAbstractView::getSingletonFactory(void)
587 {
588  //qDebug()<<"axlAbstractView :: getSingletonFactory"<<dtkAbstractViewFactory::instance();
589 
590  return dtkAbstractViewFactory::instance();
591 }
axlViewController * controller(void)
virtual double getCameraViewAngle(void)
virtual void setTrackballInteractor(void)
virtual bool getBackgroundGradient(void)
void dataChangedByProperty(dtkAbstractData *data, int channel)
Modify the right property, which is defined by the channel number :
virtual void setCameraPosition(double x, double y, double z)
virtual void onShowAxis(bool show)
void onActorVisibilityChanged(dtkAbstractData *data, bool actorVisibility)
virtual void setJoystickInteractor(void)
virtual void setParallelCamera(bool parallel)
void dataChangedByGeometry(dtkAbstractData *data)
dtkAbstractViewFactory * getSingletonFactory(void)
virtual ~axlAbstractView(void)
virtual void activeDefaultLigh(bool useDefaultLight)
virtual double * getBackgroundColor(void)
void onLightPositionChanged(double x, double y, double z)
void inserted(void)
virtual void setCameraViewPositiveX(void)
virtual void updateFieldActor(dtkAbstractData *data)
Use view as input to update fields actors on a data.
void onGridResolutionChanged(int resolution)
void onStateChanged(dtkAbstractData *data, int mode)
virtual void removeField(dtkAbstractData *data)
virtual void setObjectCamera(void)
void onInterpolationChanded(dtkAbstractData *data, int interpolation)
void dataChangedByColor(dtkAbstractData *data, double red, double green, double blue)
virtual double * getCameraFocalPoint(void)
virtual double getParallelScale(void)
virtual void removeSet(QList< axlAbstractActor * > actorSet)
virtual void removeData(dtkAbstractData *data)
void processIsophoteByShader(dtkAbstractData *data, QString isophoteShaderXml)
virtual bool getAxesVisibility(void)
void insertData(axlAbstractData *data)
void onShaderChanged(dtkAbstractData *data, QString isophoteShaderXml)
virtual double * getWorldCameraPosition(void)
virtual void setCameraViewPositiveZ(void)
virtual Kind kind(void)
Class axlDataDynamic defines a dynamic object.
virtual bool getParallelProjection(void)
void ondataSetRemoved(QList< dtkAbstractData * > dataSetToRemoved)
void onControlPointChanged(dtkAbstractData *data)
virtual void update(void)
void showColorMapping(dtkAbstractData *data)
virtual void setCameraUp(double x, double y, double z)
virtual int size(void)
void dataChangedBySize(dtkAbstractData *data, double size)
virtual double * getCameraUp(void)
virtual void setParallelScale(double parallelScale)
virtual axlAbstractActor * actor(dtkAbstractData *data)
virtual void onUpdateActorField(QList< axlAbstractData * > axlDataSet, QString fieldName)
virtual void setGrid(bool isGridX, bool isGridY, bool isGridZ)
virtual void setCameraViewDefaut(void)
Class axlAbstractField defines an API for arrays of numeric data.
virtual void setCameraViewNegativeZ(void)
virtual void setWorldCamera(void)
virtual void setCameraViewNegativeX(void)
virtual void setSize(double size)
virtual void add(dtkAbstractData *data)
Use view as input to open a data in axel.
virtual axlAbstractActor * insert(axlAbstractData *data)
void lightPositionChanged(double x, double y, double z)
virtual void onBackgroundGradientChange(bool gradient)
void dataChangedByOpacity(dtkAbstractData *data, double opacity)
virtual QList< axlAbstractActor * > insertSet(QList< axlAbstractData * > dataSet)
QList< axlAbstractField * > fields(void)
virtual void setCameraViewNegativeY(void)
virtual void setCameraFocalPoint(double x, double y, double z)
virtual void setCameraViewAngle(double angle)
void onTubeFilterRadiusChanged(dtkAbstractData *data, double radius)
virtual void setCameraViewPositiveY(void)
Class axlAbstractData defines an API for all type of axel data.
virtual void setLight(int i, bool hide, double *position, double *ambiant, double *diffuse, double *specular, int exponent)
virtual void removeSetFields(QList< axlAbstractActorField * > actorSet)
double angle(axlPoint vCompute, axlPoint vRef, axlPoint normal)