28 #include <dtkGuiSupport/dtkColorButton.h>
29 #include <dtkGuiSupport/dtkSplitter.h>
33 class axlInspectorObjectLinePrivate
37 QDoubleSpinBox *coordinateFirst_x;
38 QDoubleSpinBox *coordinateFirst_y;
39 QDoubleSpinBox *coordinateFirst_z;
41 QDoubleSpinBox *coordinateSecond_x;
42 QDoubleSpinBox *coordinateSecond_y;
43 QDoubleSpinBox *coordinateSecond_z;
46 QDoubleSpinBox *sizeSpinBox;
48 dtkColorButton *colorButton;
50 QComboBox *comboBoxShader;
52 QCheckBox *checkBoxShader;
53 QLineEdit *lineEditShader;
54 QPushButton *buttonShader;
56 QSlider *sliderOpacity;
61 d(new axlInspectorObjectLinePrivate)
64 d->coordinateFirst_x = NULL;
65 d->coordinateFirst_y = NULL;
66 d->coordinateFirst_z = NULL;
68 d->coordinateSecond_x = NULL;
69 d->coordinateSecond_y = NULL;
70 d->coordinateSecond_z = NULL;
73 d->sizeSpinBox = NULL;
75 d->colorButton = NULL;
76 d->comboBoxShader = NULL;
78 d->checkBoxShader = NULL;
79 d->lineEditShader = NULL;
80 d->buttonShader = NULL;
82 d->sliderOpacity = NULL;
94 return QSize(300, 300);
102 connect(d->line, SIGNAL(modifiedGeometry(
void)),
this, SLOT(
updateValues(
void)));
109 double initSize = 100.0*(log(d->line->size()/0.125))/log(2.0);
116 return d->line->shader();
122 return d->line->color();
127 double initOpacity = 0.0;
128 double opacity = d->line->opacity();
130 if(opacity > initOpacity)
131 initOpacity = opacity;
133 return 100 * (1.0 - initOpacity);
138 QVBoxLayout *layoutTop =
new QVBoxLayout(
this);
139 layoutTop->addWidget(
new QLabel(
"axlInspectorObjectLine",
this));
142 d->coordinateFirst_x =
new QDoubleSpinBox(
this);
143 d->coordinateFirst_x->setRange(-1000, 1000);
144 d->coordinateFirst_x->setSingleStep(0.1);
145 d->coordinateFirst_x->setValue(d->line->firstPoint()->x());
147 d->coordinateFirst_y =
new QDoubleSpinBox(
this);
148 d->coordinateFirst_y->setRange(-1000, 1000);
149 d->coordinateFirst_y->setSingleStep(0.1);
150 d->coordinateFirst_y->setValue(d->line->firstPoint()->y());
152 d->coordinateFirst_z =
new QDoubleSpinBox(
this);
153 d->coordinateFirst_z->setRange(-1000, 1000);
154 d->coordinateFirst_z->setSingleStep(0.1);
155 d->coordinateFirst_z->setValue(d->line->firstPoint()->z());
157 d->coordinateSecond_x =
new QDoubleSpinBox(
this);
158 d->coordinateSecond_x->setRange(-1000, 1000);
159 d->coordinateSecond_x->setSingleStep(0.1);
160 d->coordinateSecond_x->setValue(d->line->secondPoint()->x());
162 d->coordinateSecond_y =
new QDoubleSpinBox(
this);
163 d->coordinateSecond_y->setRange(-1000, 1000);
164 d->coordinateSecond_y->setSingleStep(0.1);
165 d->coordinateSecond_y->setValue(d->line->secondPoint()->y());
167 d->coordinateSecond_z =
new QDoubleSpinBox(
this);
168 d->coordinateSecond_z->setRange(-1000, 1000);
169 d->coordinateSecond_z->setSingleStep(0.1);
170 d->coordinateSecond_z->setValue(d->line->secondPoint()->z());
173 QHBoxLayout *layoutcoordinateFirst_x =
new QHBoxLayout;
174 layoutcoordinateFirst_x->addWidget(
new QLabel(
"X",
this));
175 layoutcoordinateFirst_x->addWidget(d->coordinateFirst_x);
177 QHBoxLayout *layoutcoordinateFirst_y =
new QHBoxLayout;
178 layoutcoordinateFirst_y->addWidget(
new QLabel(
"Y",
this));
179 layoutcoordinateFirst_y->addWidget(d->coordinateFirst_y);
181 QHBoxLayout *layoutcoordinateFirst_z =
new QHBoxLayout;
182 layoutcoordinateFirst_z->addWidget(
new QLabel(
"Z",
this));
183 layoutcoordinateFirst_z->addWidget(d->coordinateFirst_z);
186 QHBoxLayout *layoutcoordinateSecond_x =
new QHBoxLayout;
187 layoutcoordinateSecond_x->addWidget(
new QLabel(
"X",
this));
188 layoutcoordinateSecond_x->addWidget(d->coordinateSecond_x);
190 QHBoxLayout *layoutcoordinateSecond_y =
new QHBoxLayout;
191 layoutcoordinateSecond_y->addWidget(
new QLabel(
"Y",
this));
192 layoutcoordinateSecond_y->addWidget(d->coordinateSecond_y);
194 QHBoxLayout *layoutcoordinateSecond_z =
new QHBoxLayout;
195 layoutcoordinateSecond_z->addWidget(
new QLabel(
"Z",
this));
196 layoutcoordinateSecond_z->addWidget(d->coordinateSecond_z);
208 d->sizeSpinBox =
new QDoubleSpinBox(
this);
209 d->sizeSpinBox->setDecimals(3);
210 d->sizeSpinBox->setRange(0, 10);
211 d->sizeSpinBox->setSingleStep(0.005);
212 d->sizeSpinBox->setValue(d->line->size());
214 QHBoxLayout *layoutSize =
new QHBoxLayout;
215 layoutSize->addWidget(
new QLabel(
"Size",
this));
216 layoutSize->addWidget(d->sizeSpinBox);
219 d->colorButton =
new dtkColorButton(
this);
221 QHBoxLayout *layoutColorButton =
new QHBoxLayout;
222 layoutColorButton->addWidget(
new QLabel(
"Color",
this));
223 layoutColorButton->addWidget(d->colorButton);
227 d->sliderOpacity =
new QSlider(Qt::Horizontal,
this);
229 QHBoxLayout *layoutOpacity =
new QHBoxLayout;
230 layoutOpacity->addWidget(
new QLabel(
"Opacity",
this));
231 layoutOpacity->addWidget(d->sliderOpacity);
232 d->sliderOpacity->setMaximum(100);
236 d->comboBoxShader =
new QComboBox(
this);
237 d->comboBoxShader->setInsertPolicy(QComboBox::InsertAlphabetically);
239 d->checkBoxShader =
new QCheckBox(
this);
240 d->lineEditShader =
new QLineEdit(
this);
241 d->buttonShader =
new QPushButton(
this);
242 d->buttonShader->setText(
"open");
247 if(d->lineEditShader->text().isEmpty())
249 d->lineEditShader->setEnabled(
false);
250 d->buttonShader->setEnabled(
false);
251 d->comboBoxShader->setEnabled(
false);
254 d->checkBoxShader->setChecked(
true);
256 QVBoxLayout *layoutShader =
new QVBoxLayout;
257 QHBoxLayout *layoutShader1 =
new QHBoxLayout;
259 QLabel *labelShader =
new QLabel(
"Shader",
this);
260 layoutShader1->addWidget(labelShader);
261 layoutShader1->addWidget(d->checkBoxShader);
262 layoutShader1->addWidget(d->comboBoxShader);
263 layoutShader1->addWidget(d->buttonShader);
265 layoutShader1->setStretchFactor(labelShader, 2);
266 layoutShader1->setStretchFactor(d->checkBoxShader, 1);
267 layoutShader1->setStretchFactor(d->comboBoxShader, 4);
268 layoutShader1->setStretchFactor(d->buttonShader, 3);
270 layoutShader->addLayout(layoutShader1);
271 layoutShader->addWidget(d->lineEditShader);
274 layoutTop->addWidget(
new QLabel(
"First point :",
this));
275 layoutTop->addLayout(layoutcoordinateFirst_x);
276 layoutTop->addLayout(layoutcoordinateFirst_y);
277 layoutTop->addLayout(layoutcoordinateFirst_z);
279 layoutTop->addWidget(
new QLabel(
"Second point :",
this));
280 layoutTop->addLayout(layoutcoordinateSecond_x);
281 layoutTop->addLayout(layoutcoordinateSecond_y);
282 layoutTop->addLayout(layoutcoordinateSecond_z);
284 layoutTop->addLayout(layoutSize);
286 layoutTop->addLayout(layoutColorButton);
287 layoutTop->addLayout(layoutOpacity);
288 layoutTop->addLayout(layoutShader);
290 QWidget *top =
new QWidget(
this);
292 top->setLayout(layoutTop);
293 top->setMaximumWidth(295);
303 connect(d->sizeSpinBox, SIGNAL(valueChanged(
double)),
this, SLOT(
onSizeChanged(
double)));
305 connect(d->colorButton, SIGNAL(colorChanged(QColor)),
this, SLOT(
onColorChanged(QColor)));
307 connect(d->sliderOpacity, SIGNAL(valueChanged(
int)),
this, SLOT(
onOpacityChanged(
int)));
308 connect(d->comboBoxShader, SIGNAL(currentIndexChanged(QString)),
this, SLOT(
onLineEditShaderChanged(QString)));
310 connect(d->buttonShader, SIGNAL(clicked()),
this, SLOT(
openShader()));
311 connect(d->lineEditShader, SIGNAL(textChanged(QString)),
this, SLOT(
onShaderChanged(QString)));
316 if(d->comboBoxShader) {
322 QDir dirShader(
":axlShader/shader/");
323 dirShader.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
325 dirShader.setNameFilters(filters);
327 QFileInfoList list = dirShader.entryInfoList();
332 QSettings settings(
"inria",
"dtk");
334 settings.beginGroup(
"shader");
335 QString defaultPathShader = settings.value(
"path", defaultPath).toString();
336 defaultPathShader.append(
"/");
338 QDir defaultDirShader(defaultPathShader);
339 defaultDirShader.setNameFilters(filters);
340 QFileInfoList list2 = defaultDirShader.entryInfoList();
346 for (
int i = 0; i < list.size(); ++i) {
347 if(!items.contains(list.at(i).fileName()))
348 items << list.at(i).fileName();
352 int indInitShader = -1;
353 int indCurrentShader = -1;
356 foreach(QString item, items) {
358 d->comboBoxShader->addItem(item);
360 QFileInfo currentFileInfo(d->lineEditShader->text());
362 if(currentFileInfo.exists()) {
363 if(item == currentFileInfo.fileName())
364 indInitShader =indCurrentShader;
369 if(indInitShader != -1)
370 d->comboBoxShader->setCurrentIndex(indInitShader);
378 QDir dirShader(
":axlShader/shader/");
379 dirShader.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
381 QFileInfo currentFile(dirShader, shader);
382 if(!currentFile.exists())
384 QSettings settings(
"inria",
"dtk");
386 settings.beginGroup(
"shader");
387 QString defaultPathShader = settings.value(
"path", defaultPath).toString();
388 defaultPathShader.append(
"/");
390 QDir defaultDirShader(defaultPathShader);
391 currentFile = QFileInfo(defaultDirShader, shader);
395 d->lineEditShader->setText(currentFile.absoluteFilePath());
400 if(d->lineEditShader->isEnabled())
403 fileToOpen = QFileDialog::getOpenFileName(
this, tr(
"Open shader"),
"", tr(
"vs file (*.vs)"));
404 d->lineEditShader->setText(fileToOpen);
410 d->line->setShader(shader);
414 d->line->touchProperty();
422 d->comboBoxShader->setEnabled(
true);
423 d->lineEditShader->setEnabled(
true);
424 d->buttonShader->setEnabled(
true);
431 d->comboBoxShader->setEnabled(
false);
432 d->lineEditShader->setEnabled(
false);
433 d->buttonShader->setEnabled(
false);
435 d->line->setShader(
"");
440 d->line->touchProperty();
447 if(d->line->parent()){
453 d->line->firstPoint()->x() = x;
456 d->line->touchGeometry();
462 if(d->line->parent()){
468 d->line->firstPoint()->y() = y;
471 d->line->touchGeometry();
477 if(d->line->parent()){
483 d->line->firstPoint()->z() = z;
486 d->line->touchGeometry();
493 if(d->line->parent()){
499 d->line->secondPoint()->x() = x;
502 d->line->touchGeometry();
508 if(d->line->parent()){
514 d->line->secondPoint()->y() = y;
517 d->line->touchGeometry();
523 if(d->line->parent()){
529 d->line->secondPoint()->z() = z;
532 d->line->touchGeometry();
538 QVariant variant = d->line->QObject::property(
"color");
539 if(variant.isValid())
541 d->line->setColor(color);
545 d->line->touchProperty();
568 d->line->setSize(size);
572 d->line->touchGeometry();
577 double opacity_d = 1.0 - 0.01 * opacity;
579 QVariant variant = d->line->QObject::property(
"opacity");
580 if(variant.isValid())
582 d->line->setOpacity(opacity_d);
586 d->line->touchProperty();
595 const QSignalBlocker blockerFirstX(d->coordinateFirst_x);
596 const QSignalBlocker blockerFirstY(d->coordinateFirst_y);
597 const QSignalBlocker blockerFirstZ(d->coordinateFirst_z);
598 const QSignalBlocker blockerSecondX(d->coordinateSecond_x);
599 const QSignalBlocker blockerSecondY(d->coordinateSecond_y);
600 const QSignalBlocker blockerSecondZ(d->coordinateSecond_z);
602 d->coordinateFirst_x->setValue(d->line->firstPoint()->x());
603 d->coordinateFirst_y->setValue(d->line->firstPoint()->y());
604 d->coordinateFirst_z->setValue(d->line->firstPoint()->z());
606 d->coordinateSecond_x->setValue(d->line->secondPoint()->x());
607 d->coordinateSecond_y->setValue(d->line->secondPoint()->y());
608 d->coordinateSecond_z->setValue(d->line->secondPoint()->z());
Class axlPoint defines 3D points.
Class axlLine defines 3D lines.
void onCoordDataChangedSecond_y(double y)
void onCoordDataChangedSecond_x(double x)
void onCoordDataChangedFirst_x(double x)
QSize sizeHint(void) const
bool caseInsensitiveLessThan(const QString &s1, const QString &s2)
void onCoordDataChangedSecond_z(double z)
void onCoordDataChangedFirst_y(double y)
QString initShaderValue(void)
void onShaderStateChanged(bool isShader)
QColor initColorValue(void)
Class axlDataDynamic defines a dynamic object.
void onShaderChanged(QString)
void onColorChanged(QColor color)
int initOpacityValue(void)
QList< axlAbstractData * > inputs(void)
Return input list;.
void initComboBoxShaderValue(void)
void onLineEditShaderChanged(QString)
void onSizeChanged(double size)
axlInspectorObjectLine(QWidget *parent=0)
~axlInspectorObjectLine(void)
void onOpacityChanged(int opacity)
void setData(axlLine *point)
void onCoordDataChangedFirst_z(double z)