25 #include <dtkGuiSupport/dtkColorButton.h>
26 #include <dtkGuiSupport/dtkSplitter.h>
30 class axlInspectorObjectPointPrivate
35 QDoubleSpinBox *coordinate_x;
36 QDoubleSpinBox *coordinate_y;
37 QDoubleSpinBox *coordinate_z;
40 QDoubleSpinBox *sizeSpinBox;
43 dtkColorButton *colorButton;
44 QComboBox *comboBoxShader;
46 QCheckBox *checkBoxShader;
47 QLineEdit *lineEditShader;
48 QPushButton *buttonShader;
50 QSlider *sliderOpacity;
55 d(new axlInspectorObjectPointPrivate)
57 d->coordinate_x = NULL;
58 d->coordinate_y = NULL;
59 d->coordinate_z = NULL;
62 d->sizeSpinBox = NULL;
64 d->colorButton = NULL;
65 d->comboBoxShader = NULL;
67 d->checkBoxShader = NULL;
68 d->lineEditShader = NULL;
69 d->buttonShader = NULL;
71 d->sliderOpacity = NULL;
89 return QSize(300, 300);
95 connect(d->point, SIGNAL(modifiedGeometry(
void)),
this, SLOT(
updateValues(
void)));
99 void axlInspectorObjectPoint::initWidget()
101 QVBoxLayout *layoutTop =
new QVBoxLayout(
this);
102 layoutTop->addWidget(
new QLabel(
"axlInspectorObjectPoint",
this));
106 d->coordinate_x =
new QDoubleSpinBox(
this);
107 d->coordinate_x->setRange(-1000.0, 1000);
108 d->coordinate_x->setValue(d->point->x());
109 d->coordinate_x->setSingleStep(0.1);
111 d->coordinate_y =
new QDoubleSpinBox(
this);
112 d->coordinate_y->setRange(-1000.0, 1000);
113 d->coordinate_y->setSingleStep(0.1);
114 d->coordinate_y->setValue(d->point->y());
116 d->coordinate_z =
new QDoubleSpinBox(
this);
117 d->coordinate_z->setRange(-1000, 1000);
118 d->coordinate_z->setValue(d->point->z());
119 d->coordinate_z->setSingleStep(0.1);
121 QHBoxLayout *layoutCoordinate_x =
new QHBoxLayout;
122 layoutCoordinate_x->addWidget(
new QLabel(
"X",
this));
123 layoutCoordinate_x->addWidget(d->coordinate_x);
125 QHBoxLayout *layoutCoordinate_y =
new QHBoxLayout;
126 layoutCoordinate_y->addWidget(
new QLabel(
"Y",
this));
127 layoutCoordinate_y->addWidget(d->coordinate_y);
129 QHBoxLayout *layoutCoordinate_z =
new QHBoxLayout;
130 layoutCoordinate_z->addWidget(
new QLabel(
"Z",
this));
131 layoutCoordinate_z->addWidget(d->coordinate_z);
143 d->sizeSpinBox =
new QDoubleSpinBox(
this);
144 d->sizeSpinBox->setDecimals(3);
145 d->sizeSpinBox->setRange(0, 4);
146 d->sizeSpinBox->setSingleStep(0.005);
147 d->sizeSpinBox->setValue(d->point->size());
149 QHBoxLayout *layoutSize =
new QHBoxLayout;
150 layoutSize->addWidget(
new QLabel(
"Size",
this));
151 layoutSize->addWidget(d->sizeSpinBox);
155 d->colorButton =
new dtkColorButton(
this);
157 QHBoxLayout *layoutColorButton =
new QHBoxLayout;
158 layoutColorButton->addWidget(
new QLabel(
"Color",
this));
159 layoutColorButton->addWidget(d->colorButton);
160 d->colorButton->setColor(this->initColorValue());
164 d->sliderOpacity =
new QSlider(Qt::Horizontal,
this);
166 QHBoxLayout *layoutOpacity =
new QHBoxLayout;
167 layoutOpacity->addWidget(
new QLabel(
"Opacity",
this));
168 layoutOpacity->addWidget(d->sliderOpacity);
169 d->sliderOpacity->setMaximum(100);
170 d->sliderOpacity->setValue(initOpacityValue());
173 d->comboBoxShader =
new QComboBox(
this);
174 d->comboBoxShader->setInsertPolicy(QComboBox::InsertAlphabetically);
176 d->checkBoxShader =
new QCheckBox(
this);
177 d->lineEditShader =
new QLineEdit(
this);
178 d->buttonShader =
new QPushButton(
this);
179 d->buttonShader->setText(
"open");
181 d->lineEditShader->setText(this->initShaderValue());
182 this->initComboBoxShaderValue();
184 if(d->lineEditShader->text().isEmpty())
186 d->lineEditShader->setEnabled(
false);
187 d->buttonShader->setEnabled(
false);
188 d->comboBoxShader->setEnabled(
false);
191 d->checkBoxShader->setChecked(
true);
196 QVBoxLayout *layoutShader =
new QVBoxLayout;
197 QHBoxLayout *layoutShader1 =
new QHBoxLayout;
199 QLabel *labelShader =
new QLabel(
"Shader",
this);
200 layoutShader1->addWidget(labelShader);
201 layoutShader1->addWidget(d->checkBoxShader);
202 layoutShader1->addWidget(d->comboBoxShader);
203 layoutShader1->addWidget(d->buttonShader);
205 layoutShader1->setStretchFactor(labelShader, 2);
206 layoutShader1->setStretchFactor(d->checkBoxShader, 1);
207 layoutShader1->setStretchFactor(d->comboBoxShader, 4);
208 layoutShader1->setStretchFactor(d->buttonShader, 3);
210 layoutShader->addLayout(layoutShader1);
211 layoutShader->addWidget(d->lineEditShader);
213 layoutTop->addLayout(layoutCoordinate_x);
214 layoutTop->addLayout(layoutCoordinate_y);
215 layoutTop->addLayout(layoutCoordinate_z);
217 layoutTop->addLayout(layoutColorButton);
218 layoutTop->addLayout(layoutSize);
219 layoutTop->addLayout(layoutOpacity);
220 layoutTop->addLayout(layoutShader);
222 QWidget *top =
new QWidget(
this);
223 top->setMaximumWidth(295);
225 top->setLayout(layoutTop);
237 connect(d->coordinate_x, SIGNAL(valueChanged(
double)),
this, SLOT(
onCoordDataChanged_x(
double)));
238 connect(d->coordinate_y, SIGNAL(valueChanged(
double)),
this, SLOT(
onCoordDataChanged_y(
double)));
239 connect(d->coordinate_z, SIGNAL(valueChanged(
double)),
this, SLOT(
onCoordDataChanged_z(
double)));
241 connect(d->colorButton, SIGNAL(colorChanged(QColor)),
this, SLOT(
onColorChanged(QColor)));
243 connect(d->sizeSpinBox, SIGNAL(valueChanged(
double)),
this, SLOT(
onSizeChanged(
double)));
244 connect(d->sliderOpacity, SIGNAL(valueChanged(
int)),
this, SLOT(
onOpacityChanged(
int)));
246 connect(d->comboBoxShader, SIGNAL(currentIndexChanged(QString)),
this, SLOT(
onLineEditShaderChanged(QString)));
248 connect(d->buttonShader, SIGNAL(clicked()),
this, SLOT(
openShader()));
249 connect(d->lineEditShader, SIGNAL(textChanged(QString)),
this, SLOT(
onShaderChanged(QString)));
254 int axlInspectorObjectPoint::initSizeValue(
void)
256 double initSize = 100.0*(log(d->point->size()/0.125))/log(2.0);
265 void axlInspectorObjectPoint::initComboBoxShaderValue(
void)
267 if(d->comboBoxShader) {
273 QDir dirShader(
":axlShader/shader/");
274 dirShader.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
276 dirShader.setNameFilters(filters);
278 QFileInfoList list = dirShader.entryInfoList();
283 QSettings settings(
"inria",
"dtk");
285 settings.beginGroup(
"shader");
286 QString defaultPathShader = settings.value(
"path", defaultPath).toString();
287 defaultPathShader.append(
"/");
289 QDir defaultDirShader(defaultPathShader);
290 defaultDirShader.setNameFilters(filters);
291 QFileInfoList list2 = defaultDirShader.entryInfoList();
297 for (
int i = 0; i < list.size(); ++i) {
298 if(!items.contains(list.at(i).fileName()))
299 items << list.at(i).fileName();
303 int indInitShader = -1;
304 int indCurrentShader = -1;
306 foreach(QString item, items) {
308 d->comboBoxShader->addItem(item);
310 QFileInfo currentFileInfo(d->lineEditShader->text());
312 if(currentFileInfo.exists())
314 if(item == currentFileInfo.fileName())
315 indInitShader =indCurrentShader;
320 if(indInitShader != -1)
321 d->comboBoxShader->setCurrentIndex(indInitShader);
328 QDir dirShader(
":axlShader/shader/");
329 dirShader.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
331 QFileInfo currentFile(dirShader, shader);
332 if(!currentFile.exists())
334 QSettings settings(
"inria",
"dtk");
336 settings.beginGroup(
"shader");
337 QString defaultPathShader = settings.value(
"path", defaultPath).toString();
338 defaultPathShader.append(
"/");
340 QDir defaultDirShader(defaultPathShader);
341 currentFile = QFileInfo(defaultDirShader, shader);
345 d->lineEditShader->setText(currentFile.absoluteFilePath());
352 double x = d->point->x();
353 d->coordinate_x->setValue(x);
358 double y = d->point->y();
359 d->coordinate_y->setValue(y);
364 double z = d->point->z();
365 d->coordinate_z->setValue(z);
372 const QSignalBlocker blockerCoordX(d->coordinate_x);
373 const QSignalBlocker blockerCoordY(d->coordinate_y);
374 const QSignalBlocker blockerCoordZ(d->coordinate_z);
376 d->coordinate_x->setValue(d->point->x());
377 d->coordinate_y->setValue(d->point->y());
378 d->coordinate_z->setValue(d->point->z());
381 QString axlInspectorObjectPoint::initShaderValue(
void)
383 return d->point->shader();
387 QColor axlInspectorObjectPoint::initColorValue(
void)
389 return d->point->color();
393 int axlInspectorObjectPoint::initOpacityValue(
void)
395 double initOpacity = 0.0;
396 double opacity = d->point->opacity();
397 if(opacity > initOpacity)
398 initOpacity = opacity;
400 return 100 * (1.0 - initOpacity);
405 if(d->lineEditShader->isEnabled())
408 fileToOpen = QFileDialog::getOpenFileName(
this, tr(
"Open shader"),
"", tr(
"vs file (*.vs)"));
409 d->lineEditShader->setText(fileToOpen);
415 d->point->setShader(shader);
419 d->point->touchProperty();
426 d->comboBoxShader->setEnabled(
true);
427 d->lineEditShader->setEnabled(
true);
428 d->buttonShader->setEnabled(
true);
431 d->point->setShader(d->lineEditShader->text());
435 d->comboBoxShader->setEnabled(
false);
436 d->lineEditShader->setEnabled(
false);
437 d->buttonShader->setEnabled(
false);
439 d->point->setShader(
"");
444 d->point->touchProperty();
450 d->point->touchGeometry();
457 d->point->touchGeometry();
464 d->point->touchGeometry();
470 QVariant variant = d->point->QObject::property(
"color");
471 if(variant.isValid())
473 d->point->setColor(color);
475 d->point->touchProperty();
492 d->point->setSize(size);
493 d->point->touchGeometry();
500 double opacity_d = 1.0 - 0.01 * opacity;
501 d->point->setOpacity(opacity_d);
504 d->point->touchProperty();
Class axlPoint defines 3D points.
void onChangedBoxValue_x(void)
void onShaderStateChanged(bool isShader)
bool caseInsensitiveLessThan(const QString &s1, const QString &s2)
void onCoordDataChanged_x(double x)
void onSizeChanged(double size)
void setData(axlPoint *point)
void onColorChanged(QColor color)
void onOpacityChanged(int opacity)
void onChangedBoxValue_z(void)
void onLineEditShaderChanged(QString)
void onCoordDataChanged_y(double y)
void onChangedBoxValue_y(void)
void onCoordDataChanged_z(double z)
void onShaderChanged(QString)
QSize sizeHint(void) const
~axlInspectorObjectPoint(void)
axlInspectorObjectPoint(QWidget *parent=0)