27 #include <dtkCoreSupport/dtkAbstractProcessFactory.h>
28 #include <dtkCoreSupport/dtkAbstractProcess.h>
29 #include <dtkGuiSupport/dtkColorButton.h>
36 class axlInspectorToolCreatorPlanePrivate
39 QSlider *sliderOpacity;
40 dtkColorButton *colorButton;
43 QDoubleSpinBox *spinBoxCoordinatePoint_x;
44 QDoubleSpinBox *spinBoxCoordinatePoint_y;
45 QDoubleSpinBox *spinBoxCoordinatePoint_z;
47 QDoubleSpinBox *spinBoxCoordinateNormal_x;
48 QDoubleSpinBox *spinBoxCoordinateNormal_y;
49 QDoubleSpinBox *spinBoxCoordinateNormal_z;
51 QGroupBox *coordinates;
53 QLabel *messageToDisplay;
58 QVBoxLayout *layout =
new QVBoxLayout(
this);
61 d->sliderOpacity =
new QSlider(Qt::Horizontal,
this);
63 QHBoxLayout *layoutOpacity =
new QHBoxLayout;
64 layoutOpacity->addWidget(
new QLabel(
"Opacity",
this));
65 layoutOpacity->addWidget(d->sliderOpacity);
66 d->sliderOpacity->setMaximum(100);
69 d->colorButton =
new dtkColorButton(
this);
71 QHBoxLayout *layoutColorButton =
new QHBoxLayout;
72 layoutColorButton->addWidget(
new QLabel(
"Color",
this));
73 layoutColorButton->addWidget(d->colorButton);
74 d->colorButton->setColor(QColor(
"#a0a0a4"));
77 QVBoxLayout *layoutCoordonate =
new QVBoxLayout();
78 QHBoxLayout *layoutCoordinatePoint_x =
new QHBoxLayout();
79 QHBoxLayout *layoutCoordinatePoint_y =
new QHBoxLayout();
80 QHBoxLayout *layoutCoordinatePoint_z =
new QHBoxLayout();
81 QLabel *labelCoordinatePoint_x =
new QLabel(
"x",
this);
82 QLabel *labelCoordinatePoint_y =
new QLabel(
"y",
this);
83 QLabel *labelCoordinatePoint_z =
new QLabel(
"z",
this);
84 d->spinBoxCoordinatePoint_x =
new QDoubleSpinBox(
this);
85 d->spinBoxCoordinatePoint_y =
new QDoubleSpinBox(
this);
86 d->spinBoxCoordinatePoint_z =
new QDoubleSpinBox(
this);
88 QHBoxLayout *layoutCoordinateNormal_x =
new QHBoxLayout();
89 QHBoxLayout *layoutCoordinateNormal_y =
new QHBoxLayout();
90 QHBoxLayout *layoutCoordinateNormal_z =
new QHBoxLayout();
91 QLabel *labelCoordinateNormal_x =
new QLabel(
"x",
this);
92 QLabel *labelCoordinateNormal_y =
new QLabel(
"y",
this);
93 QLabel *labelCoordinateNormal_z =
new QLabel(
"z",
this);
94 d->spinBoxCoordinateNormal_x =
new QDoubleSpinBox(
this);
95 d->spinBoxCoordinateNormal_y =
new QDoubleSpinBox(
this);
96 d->spinBoxCoordinateNormal_z =
new QDoubleSpinBox(
this);
98 d->spinBoxCoordinatePoint_x->setValue(0.0);
99 d->spinBoxCoordinatePoint_y->setValue(0.0);
100 d->spinBoxCoordinatePoint_z->setValue(0.0);
101 d->spinBoxCoordinatePoint_x->setRange(-1000, 1000);
102 d->spinBoxCoordinatePoint_y->setRange(-1000, 1000);
103 d->spinBoxCoordinatePoint_z->setRange(-1000, 1000);
104 layoutCoordinatePoint_x->addWidget(labelCoordinatePoint_x);
105 layoutCoordinatePoint_x->addWidget(d->spinBoxCoordinatePoint_x);
106 layoutCoordinatePoint_y->addWidget(labelCoordinatePoint_y);
107 layoutCoordinatePoint_y->addWidget(d->spinBoxCoordinatePoint_y);
108 layoutCoordinatePoint_z->addWidget(labelCoordinatePoint_z);
109 layoutCoordinatePoint_z->addWidget(d->spinBoxCoordinatePoint_z);
110 layoutCoordonate->addWidget(
new QLabel(
"Point :",
this));
111 layoutCoordonate->addLayout(layoutCoordinatePoint_x);
112 layoutCoordonate->addLayout(layoutCoordinatePoint_y);
113 layoutCoordonate->addLayout(layoutCoordinatePoint_z);
115 d->spinBoxCoordinateNormal_x->setValue(1.0);
116 d->spinBoxCoordinateNormal_y->setValue(0.0);
117 d->spinBoxCoordinateNormal_z->setValue(0.0);
118 layoutCoordinateNormal_x->addWidget(labelCoordinateNormal_x);
119 layoutCoordinateNormal_x->addWidget(d->spinBoxCoordinateNormal_x);
120 layoutCoordinateNormal_y->addWidget(labelCoordinateNormal_y);
121 layoutCoordinateNormal_y->addWidget(d->spinBoxCoordinateNormal_y);
122 layoutCoordinateNormal_z->addWidget(labelCoordinateNormal_z);
123 layoutCoordinateNormal_z->addWidget(d->spinBoxCoordinateNormal_z);
124 layoutCoordonate->addWidget(
new QLabel(
"Normal :",
this));
125 layoutCoordonate->addLayout(layoutCoordinateNormal_x);
126 layoutCoordonate->addLayout(layoutCoordinateNormal_y);
127 layoutCoordonate->addLayout(layoutCoordinateNormal_z);
129 d->spinBoxCoordinatePoint_x->setSingleStep(0.1);
130 d->spinBoxCoordinatePoint_y->setSingleStep(0.1);
131 d->spinBoxCoordinatePoint_z->setSingleStep(0.1);
132 d->spinBoxCoordinateNormal_x->setSingleStep(0.1);
133 d->spinBoxCoordinateNormal_y->setSingleStep(0.1);
134 d->spinBoxCoordinateNormal_z->setSingleStep(0.1);
136 d->coordinates =
new QGroupBox(tr(
"Enter coordinates"),
this);
137 d->coordinates->setLayout(layoutCoordonate);
141 d->messageToDisplay =
new QLabel(
"",
this);
143 d->messageToDisplay->setText(creator->
description());
145 d->messageToDisplay->setStyleSheet(
"color: #ff0000;");
148 QPushButton *button =
new QPushButton(
"Create",
this);
149 connect(button, SIGNAL(clicked()),
this, SLOT(
run()));
151 layout->addWidget(
new QLabel(
"axlInspectorToolCreatorPlane",
this));
153 layout->addWidget(d->messageToDisplay);
154 layout->addWidget(d->coordinates);
155 layout->addLayout(layoutOpacity);
156 layout->addLayout(layoutColorButton);
157 layout->addWidget(button);
158 d->coordinates->hide();
170 d->controller = controller;
171 if(d->controller->size() < 2){
172 d->messageToDisplay->hide();
173 d->coordinates->show();
175 d->coordinates->hide();
176 bool hasRigthType =
false;
179 if(dynamic_cast<axlPoint *>(d->controller->data(item)))
181 else if(dynamic_cast<axlDataDynamic *>(d->controller->data(item)))
182 if(dynamic_cast<axlDataDynamic *>(d->controller->data(item))->outputs())
183 if(dynamic_cast<axlPoint *>(dynamic_cast<axlDataDynamic *>(d->controller->data(item))->outputs()))
190 d->messageToDisplay->hide();
191 d->coordinates->show();
197 QList<axlAbstractData *>list;
198 if(d->coordinates->isVisible()){
199 axlPoint *point =
new axlPoint(d->spinBoxCoordinatePoint_x->value(), d->spinBoxCoordinatePoint_y->value(), d->spinBoxCoordinatePoint_z->value());
200 axlPoint *normal =
new axlPoint(d->spinBoxCoordinateNormal_x->value(), d->spinBoxCoordinateNormal_y->value(), d->spinBoxCoordinateNormal_z->value());
202 list << point << normal;
210 if( !d->coordinates->isVisible()){
211 d->messageToDisplay->show();
214 if( d->controller->size() > 0){
217 if(item->text(2) ==
"Selected"|| item->text(2) ==
"Editable")
220 if(dynamic_cast<axlPoint *>(d->controller->data(item))) {
226 qDebug() <<
"To many inputs selected, only the two first points were used";
236 cylinder->
setColor(d->colorButton->color());
237 double opacity = 1.0 - 0.01 * d->sliderOpacity->value();
240 d->coordinates->hide();
245 d->coordinates->show();
246 d->messageToDisplay->hide();
250 d->messageToDisplay->hide();
251 axlPoint *point =
new axlPoint(d->spinBoxCoordinatePoint_x->value(), d->spinBoxCoordinatePoint_y->value(), d->spinBoxCoordinatePoint_z->value());
252 axlPoint *normal =
new axlPoint(d->spinBoxCoordinateNormal_x->value(), d->spinBoxCoordinateNormal_y->value(), d->spinBoxCoordinateNormal_z->value());
259 double opacity = 1.0 - 0.01 * d->sliderOpacity->value();
260 plane->setColor(d->colorButton->color());
261 plane->setOpacity(opacity);
Class axlPoint defines 3D points.
Class axlPlane defines 3D planes.
virtual dtkAbstractData * output(void)
virtual QString description(void) const
void setOpacity(const double &opacity)
virtual void setInput(dtkAbstractData *newData, int channel)
void setColor(double r, double g, double b)