27 #include <dtkCoreSupport/dtkAbstractProcessFactory.h>
28 #include <dtkCoreSupport/dtkAbstractProcess.h>
29 #include <dtkGuiSupport/dtkColorButton.h>
37 class axlInspectorToolCreatorLinePrivate
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;
51 QGroupBox *coordinates;
53 QLabel *messageToDisplay;
58 QVBoxLayout *layout =
new QVBoxLayout(
this);
60 d->messageToDisplay =
new QLabel(
"Select two points to create a line",
this);
61 d->messageToDisplay->setStyleSheet(
"color: #ff0000;");
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"));
79 QVBoxLayout *layoutCoordonate =
new QVBoxLayout(
this);
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 d->spinBoxCoordinateFirst_x->setValue(0.0);
101 d->spinBoxCoordinateFirst_y->setValue(0.0);
102 d->spinBoxCoordinateFirst_z->setValue(0.0);
103 d->spinBoxCoordinateFirst_x->setRange(-1000, 1000);
104 d->spinBoxCoordinateFirst_y->setRange(-1000, 1000);
105 d->spinBoxCoordinateFirst_z->setRange(-1000, 1000);
106 d->spinBoxCoordinateFirst_x->setSingleStep(0.1);
107 d->spinBoxCoordinateFirst_y->setSingleStep(0.1);
108 d->spinBoxCoordinateFirst_z->setSingleStep(0.1);
109 layoutCoordinateFirst_x->addWidget(labelCoordinateFirst_x);
110 layoutCoordinateFirst_x->addWidget(d->spinBoxCoordinateFirst_x);
111 layoutCoordinateFirst_y->addWidget(labelCoordinateFirst_y);
112 layoutCoordinateFirst_y->addWidget(d->spinBoxCoordinateFirst_y);
113 layoutCoordinateFirst_z->addWidget(labelCoordinateFirst_z);
114 layoutCoordinateFirst_z->addWidget(d->spinBoxCoordinateFirst_z);
115 layoutCoordonate->addWidget(
new QLabel(
"First point :",
this));
116 layoutCoordonate->addLayout(layoutCoordinateFirst_x);
117 layoutCoordonate->addLayout(layoutCoordinateFirst_y);
118 layoutCoordonate->addLayout(layoutCoordinateFirst_z);
120 d->spinBoxCoordinateSecond_x->setValue(1.0);
121 d->spinBoxCoordinateSecond_y->setValue(0.0);
122 d->spinBoxCoordinateSecond_z->setValue(0.0);
123 d->spinBoxCoordinateSecond_x->setRange(-1000, 1000);
124 d->spinBoxCoordinateSecond_y->setRange(-1000, 1000);
125 d->spinBoxCoordinateSecond_z->setRange(-1000, 1000);
126 d->spinBoxCoordinateSecond_x->setSingleStep(0.1);
127 d->spinBoxCoordinateSecond_y->setSingleStep(0.1);
128 d->spinBoxCoordinateSecond_z->setSingleStep(0.1);
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);
142 d->coordinates =
new QGroupBox(tr(
"Enter coordinates"),
this);
143 d->coordinates->setLayout(layoutCoordonate);
147 QPushButton *button =
new QPushButton(
"Create",
this);
148 connect(button, SIGNAL(clicked()),
this, SLOT(
run()));
150 layout->addWidget(
new QLabel(
"axlInspectorToolCreatorLine",
this));
152 layout->addWidget(d->messageToDisplay);
153 layout->addWidget(d->coordinates);
155 layout->addLayout(layoutOpacity);
156 layout->addLayout(layoutColorButton);
157 layout->addWidget(button);
159 d->coordinates->hide();
160 d->messageToDisplay->hide();
172 d->controller = controller;
173 if(d->controller->size() < 2){
174 d->coordinates->show();
176 d->coordinates->hide();
177 bool hasRigthType =
false;
180 if(dynamic_cast<axlPoint *>(d->controller->data(item)))
182 else if(dynamic_cast<axlDataDynamic *>(d->controller->data(item)))
183 if(dynamic_cast<axlDataDynamic *>(d->controller->data(item))->outputs())
184 if(dynamic_cast<axlPoint *>(dynamic_cast<axlDataDynamic *>(d->controller->data(item))->outputs()))
191 d->coordinates->show();
193 d->messageToDisplay->show();
199 QList<axlAbstractData *> list;
200 if(d->coordinates->isVisible()){
201 axlPoint *firstPoint =
new axlPoint(d->spinBoxCoordinateFirst_x->value(), d->spinBoxCoordinateFirst_y->value(), d->spinBoxCoordinateFirst_z->value());
202 axlPoint *secondPoint =
new axlPoint(d->spinBoxCoordinateSecond_x->value(), d->spinBoxCoordinateSecond_y->value(), d->spinBoxCoordinateSecond_z->value());
205 list << firstPoint << secondPoint;
214 if( !d->coordinates->isVisible()){
217 if(!d->controller->size()==0){
220 if(item->text(2) ==
"Selected"|| item->text(2) ==
"Editable")
223 if(dynamic_cast<axlPoint *>(d->controller->data(item))) {
229 qDebug() <<
"To many inputs selected, only the two first points were used";
238 line->
setColor(d->colorButton->color());
239 double opacity = 1.0 - 0.01 * d->sliderOpacity->value();
245 d->coordinates->show();
246 d->messageToDisplay->hide();
253 axlPoint *firstPoint =
new axlPoint(d->spinBoxCoordinateFirst_x->value(), d->spinBoxCoordinateFirst_y->value(), d->spinBoxCoordinateFirst_z->value());
254 axlPoint *secondPoint =
new axlPoint(d->spinBoxCoordinateSecond_x->value(), d->spinBoxCoordinateSecond_y->value(), d->spinBoxCoordinateSecond_z->value());
257 double opacity = 1.0 - 0.01 * d->sliderOpacity->value();
258 line->setColor(d->colorButton->color());
259 line->setOpacity(opacity);
263 d->coordinates->show();
264 d->messageToDisplay->hide();
Class axlPoint defines 3D points.
Class axlLine defines 3D lines.
virtual dtkAbstractData * output(void)
virtual void setInput(dtkAbstractData *newData, int channel)
void setOpacity(const double &opacity)
void setColor(double r, double g, double b)