28 #include <dtkCoreSupport/dtkAbstractProcessFactory.h>
29 #include <dtkCoreSupport/dtkAbstractProcess.h>
30 #include <dtkGuiSupport/dtkColorButton.h>
38 class axlInspectorToolCreatorTorusPrivate {
40 QSlider *sliderOpacity;
41 dtkColorButton *colorButton;
44 QDoubleSpinBox* coordinateCenter_x;
45 QDoubleSpinBox* coordinateCenter_y;
46 QDoubleSpinBox* coordinateCenter_z;
48 QDoubleSpinBox* coordinateDirection_x;
49 QDoubleSpinBox* coordinateDirection_y;
50 QDoubleSpinBox* coordinateDirection_z;
52 QDoubleSpinBox* ringRadius;
54 QDoubleSpinBox* crossSectionRadius;
56 QGroupBox *coordinates;
57 QLabel *messageToDisplay;
65 d->sliderOpacity =
new QSlider(Qt::Horizontal,
this);
67 QHBoxLayout *layoutOpacity =
new QHBoxLayout;
68 layoutOpacity->addWidget(
new QLabel(
"Opacity",
this));
69 layoutOpacity->addWidget(d->sliderOpacity);
70 d->sliderOpacity->setMaximum(100);
73 d->colorButton =
new dtkColorButton(
this);
75 QHBoxLayout *layoutColorButton =
new QHBoxLayout;
76 layoutColorButton->addWidget(
new QLabel(
"Color",
this));
77 layoutColorButton->addWidget(d->colorButton);
78 d->colorButton->setColor(QColor(
"#a0a0a4"));
81 d->coordinateCenter_x =
new QDoubleSpinBox(
this);
82 d->coordinateCenter_x->setValue(0.0);
83 d->coordinateCenter_x->setRange(-1000, 1000);
84 d->coordinateCenter_x->setSingleStep(0.1);
85 d->coordinateCenter_y =
new QDoubleSpinBox(
this);
86 d->coordinateCenter_y->setValue(0.0);
87 d->coordinateCenter_y->setRange(-1000, 1000);
88 d->coordinateCenter_y->setSingleStep(0.1);
89 d->coordinateCenter_z =
new QDoubleSpinBox(
this);
90 d->coordinateCenter_z->setValue(0.0);
91 d->coordinateCenter_z->setRange(-1000, 1000);
92 d->coordinateCenter_z->setSingleStep(0.1);
94 QVBoxLayout *layoutCenter =
new QVBoxLayout;
96 QHBoxLayout *layoutCenter_x =
new QHBoxLayout;
97 QLabel *labelCenter_x =
new QLabel(
"x",
this);
98 QHBoxLayout *layoutCenter_y =
new QHBoxLayout;
99 QLabel *labelCenter_y =
new QLabel(
"y",
this);
100 QHBoxLayout *layoutCenter_z =
new QHBoxLayout;
101 QLabel *labelCenter_z =
new QLabel(
"z",
this);
103 layoutCenter_x->addWidget(labelCenter_x);
104 layoutCenter_x->addWidget(d->coordinateCenter_x);
105 layoutCenter_y->addWidget(labelCenter_y);
106 layoutCenter_y->addWidget(d->coordinateCenter_y);
107 layoutCenter_z->addWidget(labelCenter_z);
108 layoutCenter_z->addWidget(d->coordinateCenter_z);
110 layoutCenter->addWidget(
new QLabel(
"Center:",
this));
111 layoutCenter->addLayout(layoutCenter_x);
112 layoutCenter->addLayout(layoutCenter_y);
113 layoutCenter->addLayout(layoutCenter_z);
116 d->coordinateDirection_x =
new QDoubleSpinBox(
this);
117 d->coordinateDirection_x->setValue(0.0);
118 d->coordinateDirection_x->setRange(-1000, 1000);
119 d->coordinateDirection_x->setSingleStep(0.1);
120 d->coordinateDirection_y =
new QDoubleSpinBox(
this);
121 d->coordinateDirection_y->setValue(0.0);
122 d->coordinateDirection_y->setRange(-1000, 1000);
123 d->coordinateDirection_y->setSingleStep(0.1);
124 d->coordinateDirection_z =
new QDoubleSpinBox(
this);
125 d->coordinateDirection_z->setValue(1.0);
126 d->coordinateDirection_z->setRange(-1000, 1000);
127 d->coordinateDirection_z->setSingleStep(0.1);
129 QVBoxLayout *layoutDirection =
new QVBoxLayout;
131 QHBoxLayout *layoutDirection_x =
new QHBoxLayout;
132 QLabel *labelDirection_x =
new QLabel(
"x",
this);
133 QHBoxLayout *layoutDirection_y =
new QHBoxLayout;
134 QLabel *labelDirection_y =
new QLabel(
"y",
this);
135 QHBoxLayout *layoutDirection_z =
new QHBoxLayout;
136 QLabel *labelDirection_z =
new QLabel(
"z",
this);
138 layoutDirection_x->addWidget(labelDirection_x);
139 layoutDirection_x->addWidget(d->coordinateDirection_x);
140 layoutDirection_y->addWidget(labelDirection_y);
141 layoutDirection_y->addWidget(d->coordinateDirection_y);
142 layoutDirection_z->addWidget(labelDirection_z);
143 layoutDirection_z->addWidget(d->coordinateDirection_z);
145 layoutDirection->addWidget(
new QLabel(
"Second point to create direction:",
this));
146 layoutDirection->addLayout(layoutDirection_x);
147 layoutDirection->addLayout(layoutDirection_y);
148 layoutDirection->addLayout(layoutDirection_z);
151 d->ringRadius =
new QDoubleSpinBox(
this);
152 d->ringRadius->setValue(1.0);
153 d->ringRadius->setSingleStep(0.1);
155 QHBoxLayout *layoutRingRadius =
new QHBoxLayout;
156 QLabel *labelRingRadius =
new QLabel(
"Ring Radius:",
this);
158 layoutRingRadius->addWidget(labelRingRadius);
159 layoutRingRadius->addWidget(d->ringRadius);
162 d->crossSectionRadius =
new QDoubleSpinBox(
this);
163 d->crossSectionRadius->setValue(0.2);
164 d->crossSectionRadius->setSingleStep(0.1);
166 QHBoxLayout *layoutCrossSectionRadius =
new QHBoxLayout;
167 QLabel *labelCrossSectionRadius =
new QLabel(
"Cross Section Radius:",
this);
169 layoutCrossSectionRadius->addWidget(labelCrossSectionRadius);
170 layoutCrossSectionRadius->addWidget(d->crossSectionRadius);
172 d->coordinates =
new QGroupBox(tr(
"Enter coordinates"),
this);
173 QVBoxLayout *layoutCoordonate =
new QVBoxLayout(
this);
174 layoutCoordonate->addLayout(layoutCenter);
175 layoutCoordonate->addLayout(layoutDirection);
176 d->coordinates->setLayout(layoutCoordonate);
178 d->messageToDisplay =
new QLabel(
"Select two points : the torus center \n and the other one to determine its orientation",
this);
179 d->messageToDisplay->setStyleSheet(
"color: #ff0000;");
182 QPushButton *button =
new QPushButton(
"Create",
this);
183 connect(button, SIGNAL(clicked()),
this, SLOT(
run()));
185 QVBoxLayout *layout =
new QVBoxLayout(
this);
187 layout->addWidget(
new QLabel(
"axlInspectorToolCreatorTorus",
this));
190 layout->addWidget(d->messageToDisplay);
191 layout->addWidget(d->coordinates);
192 layout->addLayout(layoutRingRadius);
193 layout->addLayout(layoutCrossSectionRadius);
194 layout->addLayout(layoutOpacity);
195 layout->addLayout(layoutColorButton);
196 layout->addWidget(button);
197 d->coordinates->hide();
198 d->messageToDisplay->show();
207 d->controller = controller;
208 if(d->controller->size() < 2){
209 d->messageToDisplay->hide();
210 d->coordinates->show();
212 d->coordinates->hide();
213 bool hasRigthType =
false;
216 if(dynamic_cast<axlPoint *>(d->controller->data(item)))
218 else if(dynamic_cast<axlDataDynamic *>(d->controller->data(item)))
219 if(dynamic_cast<axlDataDynamic *>(d->controller->data(item))->outputs())
220 if(dynamic_cast<axlPoint *>(dynamic_cast<axlDataDynamic *>(d->controller->data(item))->outputs()))
227 d->messageToDisplay->hide();
228 d->coordinates->show();
234 QList<axlAbstractData *>list;
235 if(d->coordinates->isVisible()){
236 axlPoint *center =
new axlPoint(d->coordinateCenter_x->value(), d->coordinateCenter_y->value(), d->coordinateCenter_z->value());
237 axlPoint *direction =
new axlPoint(d->coordinateDirection_x->value(), d->coordinateDirection_y->value(), d->coordinateDirection_z->value());
243 list << center << direction << ringRadius << crossSectionRadius;
251 if(!d->coordinates->isVisible()){
252 d->messageToDisplay->show();
255 if(d->controller->size() > 0){
258 if(item->text(2) ==
"Selected"|| item->text(2) ==
"Editable")
261 if(dynamic_cast<axlPoint *>(d->controller->data(item))) {
267 qDebug() <<
"To many inputs selected, only the two first points were used";
276 creator->
setParameter(d->crossSectionRadius->value(),1);
279 torus->
setColor(d->colorButton->color());
280 double opacity = 1.0 - 0.01 * d->sliderOpacity->value();
283 d->coordinates->hide();
287 d->messageToDisplay->hide();
288 d->coordinates->show();
292 d->messageToDisplay->hide();
293 axlPoint *center =
new axlPoint(d->coordinateCenter_x->value(), d->coordinateCenter_y->value(), d->coordinateCenter_z->value());
294 axlPoint *direction =
new axlPoint(d->coordinateDirection_x->value(), d->coordinateDirection_y->value(), d->coordinateDirection_z->value());
296 axlTorus* newTorus =
new axlTorus(center, direction, d->ringRadius->value(), d->crossSectionRadius->value());
298 newTorus->
setColor(d->colorButton->color());
299 double opacity = 1.0 - 0.01 * d->sliderOpacity->value();
300 newTorus->setOpacity(opacity);
virtual void setInput(dtkAbstractData *newData, int channel)
Class axlPoint defines 3D points.
Class axlDouble defines a double.
virtual void setParameter(double data, int channel)
void setOpacity(const double &opacity)
void setColor(double r, double g, double b)
virtual dtkAbstractData * output(void)