29 #include <dtkCoreSupport/dtkAbstractProcessFactory.h>
30 #include <dtkCoreSupport/dtkAbstractProcess.h>
32 #include <dtkGuiSupport/dtkColorButton.h>
36 class axlInspectorToolCreatorConePrivate
39 QSlider *sliderOpacity;
40 dtkColorButton *colorButton;
43 QDoubleSpinBox *spinBoxCoordinateApex_x;
44 QDoubleSpinBox *spinBoxCoordinateApex_y;
45 QDoubleSpinBox *spinBoxCoordinateApex_z;
47 QDoubleSpinBox *spinBoxCoordinateBasePoint_x;
48 QDoubleSpinBox *spinBoxCoordinateBasePoint_y;
49 QDoubleSpinBox *spinBoxCoordinateBasePoint_z;
51 QDoubleSpinBox *spinBoxRadius;
53 QGroupBox *coordinates;
55 QLabel *messageToDisplay;
61 QVBoxLayout *layout =
new QVBoxLayout(
this);
64 d->sliderOpacity =
new QSlider(Qt::Horizontal,
this);
66 QHBoxLayout *layoutOpacity =
new QHBoxLayout;
67 layoutOpacity->addWidget(
new QLabel(
"Opacity",
this));
68 layoutOpacity->addWidget(d->sliderOpacity);
69 d->sliderOpacity->setMaximum(100);
72 d->colorButton =
new dtkColorButton(
this);
74 QHBoxLayout *layoutColorButton =
new QHBoxLayout;
75 layoutColorButton->addWidget(
new QLabel(
"Color",
this));
76 layoutColorButton->addWidget(d->colorButton);
77 d->colorButton->setColor(QColor(
"#a0a0a4"));
84 QVBoxLayout *layoutCoordonate =
new QVBoxLayout();
85 QHBoxLayout *layoutCoordinateApex_x =
new QHBoxLayout();
86 QHBoxLayout *layoutCoordinateApex_y =
new QHBoxLayout();
87 QHBoxLayout *layoutCoordinateApex_z =
new QHBoxLayout();
88 QLabel *labelCoordinateApex_x =
new QLabel(
"x",
this);
89 QLabel *labelCoordinateApex_y =
new QLabel(
"y",
this);
90 QLabel *labelCoordinateApex_z =
new QLabel(
"z",
this);
91 d->spinBoxCoordinateApex_x =
new QDoubleSpinBox(
this);
92 d->spinBoxCoordinateApex_y =
new QDoubleSpinBox(
this);
93 d->spinBoxCoordinateApex_z =
new QDoubleSpinBox(
this);
95 QHBoxLayout *layoutCoordinateBasePoint_x =
new QHBoxLayout();
96 QHBoxLayout *layoutCoordinateBasePoint_y =
new QHBoxLayout();
97 QHBoxLayout *layoutCoordinateBasePoint_z =
new QHBoxLayout();
98 QLabel *labelCoordinateBasePoint_x =
new QLabel(
"x",
this);
99 QLabel *labelCoordinateBasePoint_y =
new QLabel(
"y",
this);
100 QLabel *labelCoordinateBasePoint_z =
new QLabel(
"z",
this);
101 d->spinBoxCoordinateBasePoint_x =
new QDoubleSpinBox(
this);
102 d->spinBoxCoordinateBasePoint_y =
new QDoubleSpinBox(
this);
103 d->spinBoxCoordinateBasePoint_z =
new QDoubleSpinBox(
this);
105 QHBoxLayout *layoutRadius =
new QHBoxLayout();
106 QLabel *labelRadius =
new QLabel(
"radius :",
this);
107 d->spinBoxRadius =
new QDoubleSpinBox(
this);
109 d->spinBoxCoordinateApex_x->setValue(0.0);
110 d->spinBoxCoordinateApex_y->setValue(0.0);
111 d->spinBoxCoordinateApex_z->setValue(0.0);
112 d->spinBoxCoordinateApex_x->setRange(-1000, 1000);
113 d->spinBoxCoordinateApex_y->setRange(-1000, 1000);
114 d->spinBoxCoordinateApex_z->setRange(-1000, 1000);
115 layoutCoordinateApex_x->addWidget(labelCoordinateApex_x);
116 layoutCoordinateApex_x->addWidget(d->spinBoxCoordinateApex_x);
117 layoutCoordinateApex_y->addWidget(labelCoordinateApex_y);
118 layoutCoordinateApex_y->addWidget(d->spinBoxCoordinateApex_y);
119 layoutCoordinateApex_z->addWidget(labelCoordinateApex_z);
120 layoutCoordinateApex_z->addWidget(d->spinBoxCoordinateApex_z);
121 layoutCoordonate->addWidget(
new QLabel(
"Apex point :",
this));
122 layoutCoordonate->addLayout(layoutCoordinateApex_x);
123 layoutCoordonate->addLayout(layoutCoordinateApex_y);
124 layoutCoordonate->addLayout(layoutCoordinateApex_z);
126 d->spinBoxCoordinateBasePoint_x->setValue(1.0);
127 d->spinBoxCoordinateBasePoint_y->setValue(0.0);
128 d->spinBoxCoordinateBasePoint_z->setValue(0.0);
129 d->spinBoxCoordinateBasePoint_x->setRange(-1000, 1000);
130 d->spinBoxCoordinateBasePoint_y->setRange(-1000, 1000);
131 d->spinBoxCoordinateBasePoint_z->setRange(-1000, 1000);
132 layoutCoordinateBasePoint_x->addWidget(labelCoordinateBasePoint_x);
133 layoutCoordinateBasePoint_x->addWidget(d->spinBoxCoordinateBasePoint_x);
134 layoutCoordinateBasePoint_y->addWidget(labelCoordinateBasePoint_y);
135 layoutCoordinateBasePoint_y->addWidget(d->spinBoxCoordinateBasePoint_y);
136 layoutCoordinateBasePoint_z->addWidget(labelCoordinateBasePoint_z);
137 layoutCoordinateBasePoint_z->addWidget(d->spinBoxCoordinateBasePoint_z);
138 layoutCoordonate->addWidget(
new QLabel(
"BasePoint point :",
this));
139 layoutCoordonate->addLayout(layoutCoordinateBasePoint_x);
140 layoutCoordonate->addLayout(layoutCoordinateBasePoint_y);
141 layoutCoordonate->addLayout(layoutCoordinateBasePoint_z);
143 layoutRadius->addWidget(labelRadius);
144 layoutRadius->addWidget(d->spinBoxRadius);
145 d->spinBoxRadius->setValue(1.0);
147 d->spinBoxCoordinateApex_x->setSingleStep(0.1);
148 d->spinBoxCoordinateApex_y->setSingleStep(0.1);
149 d->spinBoxCoordinateApex_z->setSingleStep(0.1);
150 d->spinBoxCoordinateBasePoint_x->setSingleStep(0.1);
151 d->spinBoxCoordinateBasePoint_y->setSingleStep(0.1);
152 d->spinBoxCoordinateBasePoint_z->setSingleStep(0.1);
153 d->spinBoxRadius->setSingleStep(0.1);
155 d->coordinates =
new QGroupBox(tr(
"Enter coordinates"),
this);
156 d->coordinates->setLayout(layoutCoordonate);
159 d->messageToDisplay =
new QLabel(
"",
this);
161 d->messageToDisplay->setText(creator->
description());
163 d->messageToDisplay->setStyleSheet(
"color: #ff0000;");
165 QPushButton *button =
new QPushButton(
"Create",
this);
166 connect(button, SIGNAL(clicked()),
this, SLOT(
run()));
168 layout->addWidget(
new QLabel(
"axlInspectorToolCreatorCone",
this));
170 layout->addWidget(d->messageToDisplay);
171 layout->addWidget(d->coordinates);
172 layout->addLayout(layoutRadius);
173 layout->addLayout(layoutOpacity);
174 layout->addLayout(layoutColorButton);
175 layout->addWidget(button);
176 d->coordinates->hide();
188 d->controller = controller;
189 if(d->controller->size() < 2){
190 d->messageToDisplay->hide();
191 d->coordinates->show();
193 d->coordinates->hide();
194 bool hasRigthType =
false;
197 if(dynamic_cast<axlPoint *>(d->controller->data(item)))
199 else if(dynamic_cast<axlDataDynamic *>(d->controller->data(item)))
200 if(dynamic_cast<axlDataDynamic *>(d->controller->data(item))->outputs())
201 if(dynamic_cast<axlPoint *>(dynamic_cast<axlDataDynamic *>(d->controller->data(item))->outputs()))
208 d->coordinates->show();
209 d->messageToDisplay->hide();
215 QList<axlAbstractData *>list;
216 if(d->coordinates->isVisible()){
217 axlPoint *Apex =
new axlPoint(d->spinBoxCoordinateApex_x->value(), d->spinBoxCoordinateApex_y->value(), d->spinBoxCoordinateApex_z->value());
218 axlPoint *basePoint =
new axlPoint(d->spinBoxCoordinateBasePoint_x->value(), d->spinBoxCoordinateBasePoint_y->value(), d->spinBoxCoordinateBasePoint_z->value());
222 list << Apex << basePoint << radius;
232 if( !d->coordinates->isVisible()){
234 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 cone->
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();
275 axlPoint *Apex =
new axlPoint(d->spinBoxCoordinateApex_x->value(), d->spinBoxCoordinateApex_y->value(), d->spinBoxCoordinateApex_z->value());
276 axlPoint *basePoint =
new axlPoint(d->spinBoxCoordinateBasePoint_x->value(), d->spinBoxCoordinateBasePoint_y->value(), d->spinBoxCoordinateBasePoint_z->value());
278 axlCone* cone =
new axlCone(Apex, basePoint, d->spinBoxRadius->value());
279 cone->
setColor(d->colorButton->color());
280 double opacity = 1.0 - 0.01 * d->sliderOpacity->value();
281 cone->setOpacity(opacity);
Class axlPoint defines 3D points.
Class axlDouble defines a double.
virtual void setParameter(double value)
virtual void setInput(dtkAbstractData *newData, int channel)
virtual QString description(void) const
virtual dtkAbstractData * output(void)
void setOpacity(const double &opacity)
Class axlCone defines 3D cones.
void setColor(double r, double g, double b)