26 #include <dtkCoreSupport/dtkAbstractProcessFactory.h>
27 #include <dtkCoreSupport/dtkAbstractProcess.h>
31 class axlInspectorLightPrivate
36 QCheckBox *checkBoxUseDefaultLight;
37 QCheckBox *checkBoxHideLight;
40 QDoubleSpinBox *spinBoxCoordonate_x;
41 QDoubleSpinBox *spinBoxCoordonate_y;
42 QDoubleSpinBox *spinBoxCoordonate_z;
44 QSpinBox *spinBoxAmbiant_x;
45 QSpinBox *spinBoxAmbiant_y;
46 QSpinBox *spinBoxAmbiant_z;
48 QSpinBox *spinBoxDiffuse_x;
49 QSpinBox *spinBoxDiffuse_y;
50 QSpinBox *spinBoxDiffuse_z;
52 QSpinBox *spinBoxSpecular_x;
53 QSpinBox *spinBoxSpecular_y;
54 QSpinBox *spinBoxSpecular_z;
56 QSpinBox *spinBoxExponent;
63 QVBoxLayout *layout =
new QVBoxLayout(
this);
65 QGridLayout *layoutLight1 =
new QGridLayout();
68 QHBoxLayout *layoutCheckBox =
new QHBoxLayout();
70 QLabel *labelCheckBox =
new QLabel(
"Use default light :",
this);
71 labelCheckBox->setToolTip(
"If the box is checked, the default light of the view plugin is"
72 "actived, if not, light widget is activated. In this case, the light is"
73 "draw in the view and user can handle it");
75 d->checkBoxUseDefaultLight =
new QCheckBox(
this);
76 d->checkBoxUseDefaultLight->setChecked(
true);
77 layoutCheckBox->addWidget(labelCheckBox);
78 layoutCheckBox->addWidget(d->checkBoxUseDefaultLight);
81 QHBoxLayout *layoutCheckBoxHideLight =
new QHBoxLayout();
83 QLabel *labelCheckBoxHideLight =
new QLabel(
"Hide light :",
this);
84 labelCheckBoxHideLight->setToolTip(
"Check the box to Hide or not the Light Actor");
86 d->checkBoxHideLight =
new QCheckBox(
this);
87 d->checkBoxHideLight->setChecked(
false);
88 layoutCheckBoxHideLight->addWidget(labelCheckBoxHideLight);
89 layoutCheckBoxHideLight->addWidget(d->checkBoxHideLight);
93 QHBoxLayout *layoutCoordonate_x =
new QHBoxLayout();
94 QHBoxLayout *layoutCoordonate_y =
new QHBoxLayout();
95 QHBoxLayout *layoutCoordonate_z =
new QHBoxLayout();
96 QLabel *labelCoordonate =
new QLabel(
"Position",
this);
97 labelCoordonate->setToolTip(
"Define the light position in the world space");
98 d->spinBoxCoordonate_x =
new QDoubleSpinBox(
this);
99 d->spinBoxCoordonate_y =
new QDoubleSpinBox(
this);
100 d->spinBoxCoordonate_z =
new QDoubleSpinBox(
this);
102 d->spinBoxCoordonate_x->setMinimum(-500);
103 d->spinBoxCoordonate_x->setMaximum(500);
104 d->spinBoxCoordonate_y->setMinimum(-500);
105 d->spinBoxCoordonate_y->setMaximum(500);
106 d->spinBoxCoordonate_z->setMinimum(-500);
107 d->spinBoxCoordonate_z->setMaximum(500);
109 d->spinBoxCoordonate_x->setValue(0.0);
110 d->spinBoxCoordonate_y->setValue(0.0);
111 d->spinBoxCoordonate_z->setValue(0.0);
113 d->spinBoxCoordonate_x->setSingleStep(0.1);
114 d->spinBoxCoordonate_y->setSingleStep(0.1);
115 d->spinBoxCoordonate_z->setSingleStep(0.1);
118 layoutCoordonate_x->addWidget(d->spinBoxCoordonate_x);
119 layoutCoordonate_y->addWidget(d->spinBoxCoordonate_y);
120 layoutCoordonate_z->addWidget(d->spinBoxCoordonate_z);
122 layoutLight1->addWidget(labelCoordonate, 0, 0);
123 layoutLight1->addLayout(layoutCoordonate_x, 0, 1);
124 layoutLight1->addLayout(layoutCoordonate_y, 0, 2);
125 layoutLight1->addLayout(layoutCoordonate_z, 0, 3);
129 QHBoxLayout *layoutAmbiant_x =
new QHBoxLayout();
130 QHBoxLayout *layoutAmbiant_y =
new QHBoxLayout();
131 QHBoxLayout *layoutAmbiant_z =
new QHBoxLayout();
132 QLabel *labelAmbiant =
new QLabel(
"Ambiant",
this);
133 labelAmbiant->setToolTip(
"Define the light Ambiant. Each value is defined between 0 and 255");
135 d->spinBoxAmbiant_x =
new QSpinBox(
this);
136 d->spinBoxAmbiant_x->setMinimum(0);
137 d->spinBoxAmbiant_x->setMaximum(255);
138 d->spinBoxAmbiant_x->setValue(255);
139 d->spinBoxAmbiant_y =
new QSpinBox(
this);
140 d->spinBoxAmbiant_y->setMinimum(0);
141 d->spinBoxAmbiant_y->setMaximum(255);
142 d->spinBoxAmbiant_y->setValue(255);
143 d->spinBoxAmbiant_z =
new QSpinBox(
this);
144 d->spinBoxAmbiant_z->setMinimum(0);
145 d->spinBoxAmbiant_z->setMaximum(255);
146 d->spinBoxAmbiant_z->setValue(255);
147 layoutAmbiant_x->addWidget(d->spinBoxAmbiant_x);
148 layoutAmbiant_y->addWidget(d->spinBoxAmbiant_y);
149 layoutAmbiant_z->addWidget(d->spinBoxAmbiant_z);
150 layoutLight1->addWidget(labelAmbiant, 1, 0);
151 layoutLight1->addLayout(layoutAmbiant_x, 1, 1);
152 layoutLight1->addLayout(layoutAmbiant_y, 1, 2);
153 layoutLight1->addLayout(layoutAmbiant_z, 1, 3);
157 QHBoxLayout *layoutDiffuse_x =
new QHBoxLayout();
158 QHBoxLayout *layoutDiffuse_y =
new QHBoxLayout();
159 QHBoxLayout *layoutDiffuse_z =
new QHBoxLayout();
161 QLabel *labelDiffuse =
new QLabel(
"Diffuse",
this);
162 labelDiffuse->setToolTip(
"Define the light diffuse. Each value is defined between 0 and 255");
164 d->spinBoxDiffuse_x =
new QSpinBox(
this);
165 d->spinBoxDiffuse_x->setMinimum(0);
166 d->spinBoxDiffuse_x->setMaximum(255);
167 d->spinBoxDiffuse_x->setValue(255);
169 d->spinBoxDiffuse_y =
new QSpinBox(
this);
170 d->spinBoxDiffuse_y->setMinimum(0);
171 d->spinBoxDiffuse_y->setMaximum(255);
172 d->spinBoxDiffuse_y->setValue(255);
174 d->spinBoxDiffuse_z =
new QSpinBox(
this);
175 d->spinBoxDiffuse_z->setMinimum(0);
176 d->spinBoxDiffuse_z->setMaximum(255);
177 d->spinBoxDiffuse_z->setValue(255);
179 layoutDiffuse_x->addWidget(d->spinBoxDiffuse_x);
180 layoutDiffuse_y->addWidget(d->spinBoxDiffuse_y);
181 layoutDiffuse_z->addWidget(d->spinBoxDiffuse_z);
183 layoutLight1->addWidget(labelDiffuse, 2, 0);
184 layoutLight1->addLayout(layoutDiffuse_x, 2, 1);
185 layoutLight1->addLayout(layoutDiffuse_y, 2, 2);
186 layoutLight1->addLayout(layoutDiffuse_z, 2, 3);
190 QHBoxLayout *layoutSpecular_x =
new QHBoxLayout();
191 QHBoxLayout *layoutSpecular_y =
new QHBoxLayout();
192 QHBoxLayout *layoutSpecular_z =
new QHBoxLayout();
193 QLabel *labelSpecular =
new QLabel(
"Specular",
this);
194 labelSpecular->setToolTip(
"Define the light Specular. Each value is defined between 0 and 255");
195 d->spinBoxSpecular_x =
new QSpinBox(
this);
196 d->spinBoxSpecular_x->setMinimum(0);
197 d->spinBoxSpecular_x->setMaximum(255);
198 d->spinBoxSpecular_x->setValue(255);
199 d->spinBoxSpecular_y =
new QSpinBox(
this);
200 d->spinBoxSpecular_y->setMinimum(0);
201 d->spinBoxSpecular_y->setMaximum(255);
202 d->spinBoxSpecular_y->setValue(255);
203 d->spinBoxSpecular_z =
new QSpinBox(
this);
204 d->spinBoxSpecular_z->setMinimum(0);
205 d->spinBoxSpecular_z->setMaximum(255);
206 d->spinBoxSpecular_z->setValue(255);
207 layoutSpecular_x->addWidget(d->spinBoxSpecular_x);
208 layoutSpecular_y->addWidget(d->spinBoxSpecular_y);
209 layoutSpecular_z->addWidget(d->spinBoxSpecular_z);
211 layoutLight1->addWidget(labelSpecular, 3, 0);
212 layoutLight1->addLayout(layoutSpecular_x, 3, 1);
213 layoutLight1->addLayout(layoutSpecular_y, 3, 2);
214 layoutLight1->addLayout(layoutSpecular_z, 3, 3);
217 QHBoxLayout *layoutExponent =
new QHBoxLayout();
218 QLabel *labelExponent =
new QLabel(
"Exponent",
this);
219 labelExponent->setToolTip(
"Define the light Specular Exponent. More the exponent is elevated, more the specular effect of the light will be strong");
220 d->spinBoxExponent =
new QSpinBox(
this);
221 d->spinBoxExponent->setValue(50);
222 d->spinBoxExponent->setMinimum(0);
223 layoutExponent->addWidget(labelExponent);
224 layoutExponent->addWidget(d->spinBoxExponent);
226 layout->addLayout(layoutCheckBox);
227 layout->addLayout(layoutCheckBoxHideLight);
228 layout->addLayout(layoutLight1);
229 layout->addLayout(layoutExponent);
231 this->setStateLight(
false);
234 connect(d->checkBoxUseDefaultLight, SIGNAL(clicked(
bool)),
this, SLOT(
onActiveDefaultLight(
bool)));
238 connect(d->spinBoxCoordonate_x, SIGNAL(valueChanged(QString)),
this, SLOT(
onValueChanged(QString)));
239 connect(d->spinBoxCoordonate_y, SIGNAL(valueChanged(QString)),
this, SLOT(
onValueChanged(QString)));
240 connect(d->spinBoxCoordonate_z, SIGNAL(valueChanged(QString)),
this, SLOT(
onValueChanged(QString)));
241 connect(d->spinBoxAmbiant_x, SIGNAL(valueChanged(QString)),
this, SLOT(
onValueChanged(QString)));
242 connect(d->spinBoxAmbiant_y, SIGNAL(valueChanged(QString)),
this, SLOT(
onValueChanged(QString)));
243 connect(d->spinBoxAmbiant_z, SIGNAL(valueChanged(QString)),
this, SLOT(
onValueChanged(QString)));
244 connect(d->spinBoxDiffuse_x, SIGNAL(valueChanged(QString)),
this, SLOT(
onValueChanged(QString)));
245 connect(d->spinBoxDiffuse_y, SIGNAL(valueChanged(QString)),
this, SLOT(
onValueChanged(QString)));
246 connect(d->spinBoxDiffuse_z, SIGNAL(valueChanged(QString)),
this, SLOT(
onValueChanged(QString)));
247 connect(d->spinBoxSpecular_x, SIGNAL(valueChanged(QString)),
this, SLOT(
onValueChanged(QString)));
248 connect(d->spinBoxSpecular_y, SIGNAL(valueChanged(QString)),
this, SLOT(
onValueChanged(QString)));
249 connect(d->spinBoxSpecular_z, SIGNAL(valueChanged(QString)),
this, SLOT(
onValueChanged(QString)));
250 connect(d->spinBoxExponent, SIGNAL(valueChanged(QString)),
this, SLOT(
onValueChanged(QString)));
275 this->setStateLight(!useDefaultLight);
278 d->view->activeDefaultLigh(useDefaultLight);
280 qDebug()<<
"No view available to change the light. Please load a view plugin";
287 void axlInspectorLight::setStateLight(
bool state)
289 d->checkBoxHideLight->setEnabled(state);
291 d->spinBoxCoordonate_x->setEnabled(state);
292 d->spinBoxCoordonate_y->setEnabled(state);
293 d->spinBoxCoordonate_z->setEnabled(state);
295 d->spinBoxAmbiant_x->setEnabled(state);
296 d->spinBoxAmbiant_y->setEnabled(state);
297 d->spinBoxAmbiant_z->setEnabled(state);
299 d->spinBoxDiffuse_x->setEnabled(state);
300 d->spinBoxDiffuse_y->setEnabled(state);
301 d->spinBoxDiffuse_z->setEnabled(state);
303 d->spinBoxSpecular_x->setEnabled(state);
304 d->spinBoxSpecular_y->setEnabled(state);
305 d->spinBoxSpecular_z->setEnabled(state);
307 d->spinBoxExponent->setEnabled(state);
314 double *position =
new double[3];
315 double *ambiant =
new double[3];
316 double *diffuse =
new double[3];
317 double *specular =
new double[3];
319 position[0] = (double)(d->spinBoxCoordonate_x->value());
320 position[1] = (double)(d->spinBoxCoordonate_y->value());
321 position[2] = (double)(d->spinBoxCoordonate_z->value());
323 ambiant[0] = (double)((
double)(d->spinBoxAmbiant_x->value())/255.0);
324 ambiant[1] = (double)(
double)((d->spinBoxAmbiant_y->value())/255.0);
325 ambiant[2] = (double)(
double)((d->spinBoxAmbiant_z->value())/255.0);
327 diffuse[0] = (double)((
double)(d->spinBoxDiffuse_x->value())/255.0);
328 diffuse[1] = (double)((
double)(d->spinBoxDiffuse_y->value())/255.0);
329 diffuse[2] = (double)((
double)(d->spinBoxDiffuse_z->value())/255.0);
331 specular[0] = (double)((
double)(d->spinBoxSpecular_x->value())/255.0);
332 specular[1] = (double)((
double)(d->spinBoxSpecular_y->value())/255.0);
333 specular[2] = (double)((
double)(d->spinBoxSpecular_z->value())/255.0);
335 d->view->setLight(1, d->checkBoxHideLight->isChecked(), position, ambiant, diffuse, specular, d->spinBoxExponent->value());
345 disconnect(d->spinBoxCoordonate_x, SIGNAL(valueChanged(QString)),
this, SLOT(
onValueChanged(QString)));
346 disconnect(d->spinBoxCoordonate_y, SIGNAL(valueChanged(QString)),
this, SLOT(
onValueChanged(QString)));
347 disconnect(d->spinBoxCoordonate_z, SIGNAL(valueChanged(QString)),
this, SLOT(
onValueChanged(QString)));
349 d->spinBoxCoordonate_x->setValue(x);
350 d->spinBoxCoordonate_y->setValue(y);
351 d->spinBoxCoordonate_z->setValue(z);
353 connect(d->spinBoxCoordonate_x, SIGNAL(valueChanged(QString)),
this, SLOT(
onValueChanged(QString)));
354 connect(d->spinBoxCoordonate_y, SIGNAL(valueChanged(QString)),
this, SLOT(
onValueChanged(QString)));
355 connect(d->spinBoxCoordonate_z, SIGNAL(valueChanged(QString)),
this, SLOT(
onValueChanged(QString)));
void onLightVisibilityChanged(bool hide)
void onValueChanged(QString value)
axlInspectorLight(QWidget *parent=0)
void onPositionChanged(double x, double y, double z)
void onActiveDefaultLight(bool useDefaultLight)
void setView(axlAbstractView *view)