26 #include <dtkCoreSupport/dtkAbstractProcessFactory.h>
27 #include <dtkCoreSupport/dtkAbstractProcess.h>
28 #include <dtkGuiSupport/dtkColorButton.h>
37 class axlInspectorToolCreatorSpherePrivate
40 QSlider *sliderOpacity;
41 dtkColorButton *colorButton;
44 QDoubleSpinBox *spinBoxCoordonate_x;
45 QDoubleSpinBox *spinBoxCoordonate_y;
46 QDoubleSpinBox *spinBoxCoordonate_z;
47 QDoubleSpinBox *spinBoxRadius;
49 QGroupBox *coordinates;
50 QLabel *messageToDisplay;
56 QVBoxLayout *layout =
new QVBoxLayout(
this);
59 d->sliderOpacity =
new QSlider(Qt::Horizontal,
this);
61 QHBoxLayout *layoutOpacity =
new QHBoxLayout;
62 layoutOpacity->addWidget(
new QLabel(
"Opacity",
this));
63 layoutOpacity->addWidget(d->sliderOpacity);
64 d->sliderOpacity->setMaximum(100);
67 d->colorButton =
new dtkColorButton(
this);
69 QHBoxLayout *layoutColorButton =
new QHBoxLayout;
70 layoutColorButton->addWidget(
new QLabel(
"Color",
this));
71 layoutColorButton->addWidget(d->colorButton);
72 d->colorButton->setColor(QColor(
"#a0a0a4"));
75 QVBoxLayout *layoutCoordonate =
new QVBoxLayout();
76 QHBoxLayout *layoutCoordonate_x =
new QHBoxLayout();
77 QHBoxLayout *layoutCoordonate_y =
new QHBoxLayout();
78 QHBoxLayout *layoutCoordonate_z =
new QHBoxLayout();
79 QHBoxLayout *layoutRadius =
new QHBoxLayout();
80 QLabel *labelCoordonate_x =
new QLabel(
"x",
this);
81 QLabel *labelCoordonate_y =
new QLabel(
"y",
this);
82 QLabel *labelCoordonate_z =
new QLabel(
"z",
this);
83 QLabel *labelRadius =
new QLabel(
"radius",
this);
84 d->spinBoxCoordonate_x =
new QDoubleSpinBox(
this);
85 d->spinBoxCoordonate_y =
new QDoubleSpinBox(
this);
86 d->spinBoxCoordonate_z =
new QDoubleSpinBox(
this);
87 d->spinBoxRadius =
new QDoubleSpinBox(
this);
89 d->spinBoxCoordonate_x->setValue(0.0);
90 d->spinBoxCoordonate_y->setValue(0.0);
91 d->spinBoxCoordonate_z->setValue(0.0);
92 d->spinBoxRadius->setValue(1.0);
93 d->spinBoxCoordonate_x->setSingleStep(0.1);
94 d->spinBoxCoordonate_y->setSingleStep(0.1);
95 d->spinBoxCoordonate_z->setSingleStep(0.1);
96 d->spinBoxRadius->setSingleStep(0.1);
97 d->spinBoxCoordonate_x->setRange(-1000, 1000);
98 d->spinBoxCoordonate_y->setRange(-1000, 1000);
99 d->spinBoxCoordonate_z->setRange(-1000, 1000);
100 layoutCoordonate_x->addWidget(labelCoordonate_x);
101 layoutCoordonate_x->addWidget(d->spinBoxCoordonate_x);
102 layoutCoordonate_y->addWidget(labelCoordonate_y);
103 layoutCoordonate_y->addWidget(d->spinBoxCoordonate_y);
104 layoutCoordonate_z->addWidget(labelCoordonate_z);
105 layoutCoordonate_z->addWidget(d->spinBoxCoordonate_z);
106 layoutRadius->addWidget(labelRadius);
107 layoutRadius->addWidget(d->spinBoxRadius);
109 layoutCoordonate->addLayout(layoutCoordonate_x);
110 layoutCoordonate->addLayout(layoutCoordonate_y);
111 layoutCoordonate->addLayout(layoutCoordonate_z);
113 d->coordinates =
new QGroupBox(tr(
"Enter coordinates"),
this);
114 d->coordinates->setLayout(layoutCoordonate);
117 d->messageToDisplay =
new QLabel(
"",
this);
119 d->messageToDisplay->setText(creator->
description());
121 d->messageToDisplay->setStyleSheet(
"color: #ff0000;");
123 QPushButton *button =
new QPushButton(
"Create",
this);
124 connect(button, SIGNAL(clicked()),
this, SLOT(
run()));
126 layout->addWidget(
new QLabel(
"axlInspectorToolCreatorSphere",
this));
128 layout->addWidget(d->messageToDisplay);
129 layout->addWidget(d->coordinates);
130 layout->addLayout(layoutRadius);
131 layout->addLayout(layoutOpacity);
132 layout->addLayout(layoutColorButton);
133 layout->addWidget(button);
134 d->coordinates->hide();
146 d->controller = controller;
147 if(d->controller->size() < 1){
148 d->messageToDisplay->hide();
149 d->coordinates->show();
151 d->coordinates->hide();
152 bool hasRigthType =
false;
155 if(dynamic_cast<axlPoint *>(d->controller->data(item)))
157 else if(dynamic_cast<axlDataDynamic *>(d->controller->data(item)))
158 if(dynamic_cast<axlDataDynamic *>(d->controller->data(item))->outputs())
159 if(dynamic_cast<axlPoint *>(dynamic_cast<axlDataDynamic *>(d->controller->data(item))->outputs()))
166 d->messageToDisplay->hide();
167 d->coordinates->show();
174 QList<axlAbstractData *> list;
175 if(d->coordinates->isVisible()){
176 axlPoint *center =
new axlPoint(d->spinBoxCoordonate_x->value(), d->spinBoxCoordonate_y->value(), d->spinBoxCoordonate_z->value());
179 list << center << radius;
188 if(!d->coordinates->isVisible()){
189 d->messageToDisplay->show();
192 if(d->controller->size()!=0){
195 if(item->text(2) ==
"Selected"|| item->text(2) ==
"Editable")
198 if(dynamic_cast<axlPoint *>(d->controller->data(item))) {
204 qDebug() <<
"To many inputs selected, only the two first points were used";
214 sphere->
setColor(d->colorButton->color());
215 double opacity = 1.0 - 0.01 * d->sliderOpacity->value();
221 d->coordinates->show();
222 d->messageToDisplay->hide();
226 d->messageToDisplay->hide();
227 axlSphere *newSphere =
new axlSphere(d->spinBoxCoordonate_x->value(), d->spinBoxCoordonate_y->value(), d->spinBoxCoordonate_z->value(), d->spinBoxRadius->value());
229 newSphere->
setColor(d->colorButton->color());
230 double opacity = 1.0 - 0.01 * d->sliderOpacity->value();
Class axlPoint defines 3D points.
virtual void setInput(dtkAbstractData *newData, int channel)
Class axlDouble defines a double.
virtual QString description(void) const
virtual void setParameter(double data)
virtual dtkAbstractData * output(void)
Class axlSphere defines 3D spheres.
void setOpacity(const double &opacity)
void setColor(double r, double g, double b)