27 #include <dtkCoreSupport/dtkAbstractProcessFactory.h>
28 #include <dtkCoreSupport/dtkAbstractProcess.h>
29 #include <dtkGuiSupport/dtkColorButton.h>
37 class axlInspectorToolCreatorCylinderPrivate
40 QSlider *sliderOpacity;
41 dtkColorButton *colorButton;
44 QDoubleSpinBox *spinBoxCoordinateFirst_x;
45 QDoubleSpinBox *spinBoxCoordinateFirst_y;
46 QDoubleSpinBox *spinBoxCoordinateFirst_z;
48 QDoubleSpinBox *spinBoxCoordinateSecond_x;
49 QDoubleSpinBox *spinBoxCoordinateSecond_y;
50 QDoubleSpinBox *spinBoxCoordinateSecond_z;
52 QDoubleSpinBox *spinBoxRadius;
53 QGroupBox *coordinates;
55 QLabel *messageToDisplay;
60 QVBoxLayout *layout =
new QVBoxLayout(
this);
63 d->sliderOpacity =
new QSlider(Qt::Horizontal,
this);
65 QHBoxLayout *layoutOpacity =
new QHBoxLayout;
66 layoutOpacity->addWidget(
new QLabel(
"Opacity",
this));
67 layoutOpacity->addWidget(d->sliderOpacity);
68 d->sliderOpacity->setMaximum(100);
71 d->colorButton =
new dtkColorButton(
this);
73 QHBoxLayout *layoutColorButton =
new QHBoxLayout;
74 layoutColorButton->addWidget(
new QLabel(
"Color",
this));
75 layoutColorButton->addWidget(d->colorButton);
76 d->colorButton->setColor(QColor(
"#a0a0a4"));
79 QVBoxLayout *layoutCoordonate =
new QVBoxLayout();
80 QHBoxLayout *layoutCoordinateFirst_x =
new QHBoxLayout();
81 QHBoxLayout *layoutCoordinateFirst_y =
new QHBoxLayout();
82 QHBoxLayout *layoutCoordinateFirst_z =
new QHBoxLayout();
83 QLabel *labelCoordinateFirst_x =
new QLabel(
"x",
this);
84 QLabel *labelCoordinateFirst_y =
new QLabel(
"y",
this);
85 QLabel *labelCoordinateFirst_z =
new QLabel(
"z",
this);
86 d->spinBoxCoordinateFirst_x =
new QDoubleSpinBox(
this);
87 d->spinBoxCoordinateFirst_y =
new QDoubleSpinBox(
this);
88 d->spinBoxCoordinateFirst_z =
new QDoubleSpinBox(
this);
90 QHBoxLayout *layoutCoordinateSecond_x =
new QHBoxLayout();
91 QHBoxLayout *layoutCoordinateSecond_y =
new QHBoxLayout();
92 QHBoxLayout *layoutCoordinateSecond_z =
new QHBoxLayout();
93 QLabel *labelCoordinateSecond_x =
new QLabel(
"x",
this);
94 QLabel *labelCoordinateSecond_y =
new QLabel(
"y",
this);
95 QLabel *labelCoordinateSecond_z =
new QLabel(
"z",
this);
96 d->spinBoxCoordinateSecond_x =
new QDoubleSpinBox(
this);
97 d->spinBoxCoordinateSecond_y =
new QDoubleSpinBox(
this);
98 d->spinBoxCoordinateSecond_z =
new QDoubleSpinBox(
this);
100 QHBoxLayout *layoutRadius =
new QHBoxLayout();
101 QLabel *labelRadius =
new QLabel(
"radius :",
this);
102 d->spinBoxRadius =
new QDoubleSpinBox(
this);
104 d->spinBoxCoordinateFirst_x->setValue(0.0);
105 d->spinBoxCoordinateFirst_y->setValue(0.0);
106 d->spinBoxCoordinateFirst_z->setValue(0.0);
109 d->spinBoxCoordinateFirst_x->setRange(-1000, 1000);
110 d->spinBoxCoordinateFirst_y->setRange(-1000, 1000);
111 d->spinBoxCoordinateFirst_z->setRange(-1000, 1000);
112 layoutCoordinateFirst_x->addWidget(labelCoordinateFirst_x);
113 layoutCoordinateFirst_x->addWidget(d->spinBoxCoordinateFirst_x);
114 layoutCoordinateFirst_y->addWidget(labelCoordinateFirst_y);
115 layoutCoordinateFirst_y->addWidget(d->spinBoxCoordinateFirst_y);
116 layoutCoordinateFirst_z->addWidget(labelCoordinateFirst_z);
117 layoutCoordinateFirst_z->addWidget(d->spinBoxCoordinateFirst_z);
118 layoutCoordonate->addWidget(
new QLabel(
"First point :",
this));
119 layoutCoordonate->addLayout(layoutCoordinateFirst_x);
120 layoutCoordonate->addLayout(layoutCoordinateFirst_y);
121 layoutCoordonate->addLayout(layoutCoordinateFirst_z);
123 d->spinBoxCoordinateSecond_x->setValue(1.0);
124 d->spinBoxCoordinateSecond_y->setValue(0.0);
125 d->spinBoxCoordinateSecond_z->setValue(0.0);
127 d->spinBoxCoordinateSecond_x->setRange(-1000, 1000);
128 d->spinBoxCoordinateSecond_y->setRange(-1000, 1000);
129 d->spinBoxCoordinateSecond_z->setRange(-1000, 1000);
130 layoutCoordinateSecond_x->addWidget(labelCoordinateSecond_x);
131 layoutCoordinateSecond_x->addWidget(d->spinBoxCoordinateSecond_x);
132 layoutCoordinateSecond_y->addWidget(labelCoordinateSecond_y);
133 layoutCoordinateSecond_y->addWidget(d->spinBoxCoordinateSecond_y);
134 layoutCoordinateSecond_z->addWidget(labelCoordinateSecond_z);
135 layoutCoordinateSecond_z->addWidget(d->spinBoxCoordinateSecond_z);
136 layoutCoordonate->addWidget(
new QLabel(
"Second point :",
this));
137 layoutCoordonate->addLayout(layoutCoordinateSecond_x);
138 layoutCoordonate->addLayout(layoutCoordinateSecond_y);
139 layoutCoordonate->addLayout(layoutCoordinateSecond_z);
141 layoutRadius->addWidget(labelRadius);
142 layoutRadius->addWidget(d->spinBoxRadius);
143 d->spinBoxRadius->setValue(1.0);
145 d->spinBoxCoordinateFirst_x->setSingleStep(0.1);
146 d->spinBoxCoordinateFirst_y->setSingleStep(0.1);
147 d->spinBoxCoordinateFirst_z->setSingleStep(0.1);
148 d->spinBoxCoordinateSecond_x->setSingleStep(0.1);
149 d->spinBoxCoordinateSecond_y->setSingleStep(0.1);
150 d->spinBoxCoordinateSecond_z->setSingleStep(0.1);
151 d->spinBoxRadius->setSingleStep(0.1);
153 d->coordinates =
new QGroupBox(tr(
"Enter coordinates"),
this);
154 d->coordinates->setLayout(layoutCoordonate);
157 d->messageToDisplay =
new QLabel(
"",
this);
159 d->messageToDisplay->setText(creator->
description());
161 d->messageToDisplay->setStyleSheet(
"color: #ff0000;");
163 QPushButton *button =
new QPushButton(
"Create",
this);
164 connect(button, SIGNAL(clicked()),
this, SLOT(
run()));
166 layout->addWidget(
new QLabel(
"axlInspectorToolCreatorCylinder",
this));
168 layout->addWidget(d->messageToDisplay);
169 layout->addWidget(d->coordinates);
170 layout->addLayout(layoutRadius);
171 layout->addLayout(layoutOpacity);
172 layout->addLayout(layoutColorButton);
173 layout->addWidget(button);
174 d->coordinates->hide();
186 d->controller = controller;
187 if(d->controller->size() < 2){
188 d->messageToDisplay->hide();
189 d->coordinates->show();
191 d->coordinates->hide();
192 bool hasRigthType =
false;
195 if(dynamic_cast<axlPoint *>(d->controller->data(item)))
197 else if(dynamic_cast<axlDataDynamic *>(d->controller->data(item)))
198 if(dynamic_cast<axlDataDynamic *>(d->controller->data(item))->outputs())
199 if(dynamic_cast<axlPoint *>(dynamic_cast<axlDataDynamic *>(d->controller->data(item))->outputs()))
206 d->coordinates->show();
207 d->messageToDisplay->hide();
215 QList<axlAbstractData *>list;
216 if(d->coordinates->isVisible()){
218 axlPoint *firstPoint =
new axlPoint(d->spinBoxCoordinateFirst_x->value(), d->spinBoxCoordinateFirst_y->value(), d->spinBoxCoordinateFirst_z->value());
219 axlPoint *secondPoint =
new axlPoint(d->spinBoxCoordinateSecond_x->value(), d->spinBoxCoordinateSecond_y->value(), d->spinBoxCoordinateSecond_z->value());
223 list << firstPoint << secondPoint << radius;
232 if( !d->coordinates->isVisible()){
233 d->messageToDisplay->show();
236 if(d->controller->size()!=0){
239 if(item->text(2) ==
"Selected"|| item->text(2) ==
"Editable")
242 if(dynamic_cast<axlPoint *>(d->controller->data(item))) {
248 qDebug() <<
"To many inputs selected, only the two first points were used";
259 cylinder->
setColor(d->colorButton->color());
260 double opacity = 1.0 - 0.01 * d->sliderOpacity->value();
263 d->coordinates->hide();
267 d->coordinates->show();
268 d->messageToDisplay->hide();
274 d->messageToDisplay->hide();
276 axlPoint *firstPoint =
new axlPoint(d->spinBoxCoordinateFirst_x->value(), d->spinBoxCoordinateFirst_y->value(), d->spinBoxCoordinateFirst_z->value());
277 axlPoint *secondPoint =
new axlPoint(d->spinBoxCoordinateSecond_x->value(), d->spinBoxCoordinateSecond_y->value(), d->spinBoxCoordinateSecond_z->value());
281 cylinder->
setColor(d->colorButton->color());
282 double opacity = 1.0 - 0.01 * d->sliderOpacity->value();
283 cylinder->setOpacity(opacity);
Class axlPoint defines 3D points.
Class axlDouble defines a double.
Class axlCylinder defines 3D cylinders.
virtual dtkAbstractData * output(void)
virtual QString description(void) const
void setOpacity(const double &opacity)
virtual void setParameter(double data)
void setColor(double r, double g, double b)
virtual void setInput(dtkAbstractData *newData, int channel)