Developer documentation | Axl-2.5.1

axlInspectorToolCreatorPoint.cpp
Go to the documentation of this file.
1 /* axlInspectorToolCreatorPoint.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/axlPoint.h>
26 #include <dtkCoreSupport/dtkAbstractProcessFactory.h>
27 #include <dtkCoreSupport/dtkAbstractProcess.h>
28 #include <dtkGuiSupport/dtkColorButton.h>
29 
30 #include <QtGui>
31 
32 class axlInspectorToolCreatorPointPrivate
33 {
34 public:
35  QSlider *sliderOpacity;
36  dtkColorButton *colorButton;
37  axlInspectorObjectController *controller;
38 
39  QDoubleSpinBox *spinBoxCoordonate_x;
40  QDoubleSpinBox *spinBoxCoordonate_y;
41  QDoubleSpinBox *spinBoxCoordonate_z;
42 };
43 
44 axlInspectorToolCreatorPoint::axlInspectorToolCreatorPoint(QWidget *parent) : axlInspectorToolCreator(parent), d(new axlInspectorToolCreatorPointPrivate)
45 {
46  QVBoxLayout *layout = new QVBoxLayout(this);
47 
48  //OPACITY//
49  d->sliderOpacity = new QSlider(Qt::Horizontal, this);
50 
51  QHBoxLayout *layoutOpacity = new QHBoxLayout;
52  layoutOpacity->addWidget(new QLabel("Opacity",this));
53  layoutOpacity->addWidget(d->sliderOpacity);
54  d->sliderOpacity->setMaximum(100);
55 
56  //COLOR//
57  d->colorButton = new dtkColorButton(this);
58 
59  QHBoxLayout *layoutColorButton = new QHBoxLayout;
60  layoutColorButton->addWidget(new QLabel("Color",this));
61  layoutColorButton->addWidget(d->colorButton);
62  d->colorButton->setColor(QColor("#a0a0a4"));
63 
64 
65  QVBoxLayout *layoutCoordonate = new QVBoxLayout();
66  QHBoxLayout *layoutCoordonate_x = new QHBoxLayout();
67  QHBoxLayout *layoutCoordonate_y = new QHBoxLayout();
68  QHBoxLayout *layoutCoordonate_z = new QHBoxLayout();
69  QLabel *labelCoordonate_x = new QLabel("x",this);
70  QLabel *labelCoordonate_y = new QLabel("y",this);
71  QLabel *labelCoordonate_z = new QLabel("z",this);
72  d->spinBoxCoordonate_x = new QDoubleSpinBox(this);
73  d->spinBoxCoordonate_y = new QDoubleSpinBox(this);
74  d->spinBoxCoordonate_z = new QDoubleSpinBox(this);
75 
76  d->spinBoxCoordonate_x->setRange(-1000, 1000);
77  d->spinBoxCoordonate_y->setRange(-1000, 1000);
78  d->spinBoxCoordonate_z->setRange(-1000, 1000);
79 
80  d->spinBoxCoordonate_x->setValue(0.0);
81  d->spinBoxCoordonate_y->setValue(0.0);
82  d->spinBoxCoordonate_z->setValue(0.0);
83  d->spinBoxCoordonate_x->setSingleStep(0.1);
84  d->spinBoxCoordonate_y->setSingleStep(0.1);
85  d->spinBoxCoordonate_z->setSingleStep(0.1);
86 
87  layoutCoordonate_x->addWidget(labelCoordonate_x);
88  layoutCoordonate_x->addWidget(d->spinBoxCoordonate_x);
89  layoutCoordonate_y->addWidget(labelCoordonate_y);
90  layoutCoordonate_y->addWidget(d->spinBoxCoordonate_y);
91  layoutCoordonate_z->addWidget(labelCoordonate_z);
92  layoutCoordonate_z->addWidget(d->spinBoxCoordonate_z);
93  layoutCoordonate->addLayout(layoutCoordonate_x);
94  layoutCoordonate->addLayout(layoutCoordonate_y);
95  layoutCoordonate->addLayout(layoutCoordonate_z);
96 
97  QPushButton *button = new QPushButton("Create", this);
98  connect(button, SIGNAL(clicked()), this, SLOT(run()));
99 
100  layout->addWidget(new QLabel("axlInspectorToolCreatorPoint", this));
101  layout->addLayout(layoutCoordonate);
102  layout->addLayout(layoutOpacity);
103  layout->addLayout(layoutColorButton);
104  layout->addWidget(button);
105 }
106 
108 {
109  delete d;
110 
111  d = NULL;
112 }
113 
115 {
116  d->controller = controller;
117 }
118 
120 {
121  axlPoint *newPoint = new axlPoint(d->spinBoxCoordonate_x->value(), d->spinBoxCoordonate_y->value(), d->spinBoxCoordonate_z->value());
122  newPoint->setColor(d->colorButton->color());
123  double opacity = 1.0 - 0.01 * d->sliderOpacity->value();
124  newPoint->setOpacity(opacity);
125  emit dataInserted(newPoint);
126 }
Class axlPoint defines 3D points.
Definition: axlPoint.h:34
void setController(axlInspectorObjectController *controller)
void dataInserted(axlAbstractData *data)
void setOpacity(const double &opacity)
void setColor(double r, double g, double b)