Developer documentation | Axl-2.5.1

axlInspectorToolCreatorPointSet.cpp
Go to the documentation of this file.
1 /* axlInspectorToolCreatorPointSet.cpp ---
2  *
3  * Author: Julien Wintz
4  * Copyright (C) 2008 - Julien Wintz, Inria.
5  * Created: Wed Mar 16 17:19:51 2011 (+0100)
6  * Version: $Id$
7  * Last-Updated: Wed Mar 16 17:38:31 2011 (+0100)
8  * By: Julien Wintz
9  * Update #: 31
10  */
11 
12 /* Commentary:
13  *
14  */
15 
16 /* Change log:
17  *
18  */
19 
23 
24 #include <axlCore/axlPointSet.h>
26 #include <dtkCoreSupport/dtkAbstractProcessFactory.h>
27 #include <dtkCoreSupport/dtkAbstractProcess.h>
28 #include <dtkGuiSupport/dtkColorButton.h>
29 
30 #include <QtGui>
31 
32 class axlInspectorToolCreatorPointSetPrivate
33 {
34 public:
35  QSlider *sliderOpacity;
36  dtkColorButton *colorButton;
37  axlInspectorObjectController *controller;
38 
39  QSpinBox *spinBoxNumPoints;
40 };
41 
42 axlInspectorToolCreatorPointSet::axlInspectorToolCreatorPointSet(QWidget *parent) : QFrame(parent), d(new axlInspectorToolCreatorPointSetPrivate)
43 {
44  QVBoxLayout *layout = new QVBoxLayout(this);
45 
46  //OPACITY//
47  d->sliderOpacity = new QSlider(Qt::Horizontal, this);
48 
49  QHBoxLayout *layoutOpacity = new QHBoxLayout;
50  layoutOpacity->addWidget(new QLabel("Opacity",this));
51  layoutOpacity->addWidget(d->sliderOpacity);
52  d->sliderOpacity->setMaximum(100);
53 
54  //COLOR//
55  d->colorButton = new dtkColorButton(this);
56 
57  QHBoxLayout *layoutColorButton = new QHBoxLayout;
58  layoutColorButton->addWidget(new QLabel("Color",this));
59  layoutColorButton->addWidget(d->colorButton);
60  d->colorButton->setColor(QColor("#a0a0a4"));
61 
62 
63  QHBoxLayout *layoutNumPoints = new QHBoxLayout;
64  QLabel *labelNumPoints = new QLabel("NumPoints",this);
65  d->spinBoxNumPoints = new QSpinBox(this);
66  d->spinBoxNumPoints->setMaximum(10000);
67  d->spinBoxNumPoints->setMinimum(1);
68  d->spinBoxNumPoints->setValue(1);
69  layoutNumPoints->addWidget(labelNumPoints);
70  layoutNumPoints->addWidget(d->spinBoxNumPoints);
71 
72  QPushButton *button = new QPushButton("Create", this);
73  connect(button, SIGNAL(clicked()), this, SLOT(run()));
74 
75  layout->addWidget(new QLabel("axlInspectorToolCreatorPointSet", this));
76  layout->addLayout(layoutNumPoints);
77  layout->addLayout(layoutOpacity);
78  layout->addLayout(layoutColorButton);
79  layout->addWidget(button);
80 }
81 
83 {
84  delete d;
85 
86  d = NULL;
87 }
88 
90 {
91  d->controller = controller;
92 }
93 
95 {
96  axlPointSet *newPointSet = new axlPointSet();
97 
98  for(int i = 0; i < d->spinBoxNumPoints->value(); i++)
99  {
100  newPointSet->push_back(new axlPoint(i, i, i));
101  }
102 
103  newPointSet->setSize(10.0);
104  newPointSet->setColor(d->colorButton->color());
105  double opacity = 1.0 - 0.01 * d->sliderOpacity->value();
106  newPointSet->setOpacity(opacity);
107 
108  emit dataInserted(newPointSet);
109 }
Class axlPoint defines 3D points.
Definition: axlPoint.h:34
void dataInserted(axlAbstractData *data)
void push_back(axlPoint *p)
Definition: axlPointSet.cpp:98
void setController(axlInspectorObjectController *controller)
void setOpacity(const double &opacity)
void setSize(const double &size)
void setColor(double r, double g, double b)