26 #include <dtkGuiSupport/dtkColorButton.h>
27 #include <dtkGuiSupport/dtkSplitter.h>
31 class axlInspectorObjectPlanePrivate
35 QDoubleSpinBox *coordinatePoint_x;
36 QDoubleSpinBox *coordinatePoint_y;
37 QDoubleSpinBox *coordinatePoint_z;
39 QDoubleSpinBox *coordinateNormal_x;
40 QDoubleSpinBox *coordinateNormal_y;
41 QDoubleSpinBox *coordinateNormal_z;
44 QDoubleSpinBox *sizeSpinBox;
46 dtkColorButton *colorButton;
47 QComboBox *comboBoxShader;
49 QCheckBox *checkBoxShader;
50 QLineEdit *lineEditShader;
51 QPushButton *buttonShader;
53 QSlider *sliderOpacity;
59 d(new axlInspectorObjectPlanePrivate)
61 d->coordinatePoint_x = NULL;
62 d->coordinatePoint_y = NULL;
63 d->coordinatePoint_z = NULL;
65 d->coordinateNormal_x = NULL;
66 d->coordinateNormal_y = NULL;
67 d->coordinateNormal_z = NULL;
70 d->sizeSpinBox = NULL;
72 d->colorButton = NULL;
73 d->comboBoxShader = NULL;
75 d->checkBoxShader = NULL;
76 d->lineEditShader = NULL;
77 d->buttonShader = NULL;
79 d->sliderOpacity = NULL;
91 return QSize(300, 300);
97 connect(d->plane, SIGNAL(modifiedGeometry(
void)),
this, SLOT(
updateValues(
void)));
101 void axlInspectorObjectPlane::initWidget()
103 QVBoxLayout *layoutTop =
new QVBoxLayout(
this);
104 layoutTop->addWidget(
new QLabel(
"axlInspectorObjectPlane",
this));
107 d->coordinatePoint, onCoordDataChangedPoint,
111 d->coordinateNormal, onCoordDataChangedNormal,
115 d->sizeSpinBox =
new QDoubleSpinBox(
this);
116 d->sizeSpinBox->setDecimals(3);
117 d->sizeSpinBox->setRange(0, 10);
118 d->sizeSpinBox->setSingleStep(0.005);
119 d->sizeSpinBox->setValue(d->plane->size());
121 QHBoxLayout *layoutSize =
new QHBoxLayout;
122 layoutSize->addWidget(
new QLabel(
"Size",
this));
123 layoutSize->addWidget(d->sizeSpinBox);
124 layoutTop->addLayout(layoutSize);
125 connect(d->sizeSpinBox, SIGNAL(valueChanged(
double)),
this, SLOT(
onSizeChanged(
double)));
130 d->comboBoxShader, d->checkBoxShader, d->lineEditShader, d->buttonShader,
134 QWidget *top =
new QWidget(
this);
135 top->setMaximumWidth(295);
136 top->setLayout(layoutTop);
140 int axlInspectorObjectPlane::initSizeValue(
void)
142 double initSize = 100.0*(log(d->plane->size()/0.125))/log(2.0);
151 d->lineEditShader->setText(this->
filePath(shader));
154 QString axlInspectorObjectPlane::initShaderValue(
void)
156 return d->plane->shader();
160 QColor axlInspectorObjectPlane::initColorValue(
void)
162 return d->plane->color();
166 int axlInspectorObjectPlane::initOpacityValue(
void)
168 double initOpacity = 0.0;
169 double opacity = d->plane->opacity();
170 if(opacity > initOpacity)
171 initOpacity = opacity;
173 return 100 * (1.0 - initOpacity);
178 if(d->lineEditShader->isEnabled())
181 fileToOpen = QFileDialog::getOpenFileName(
this, tr(
"Open shader"),
"", tr(
"vs file (*.vs)"));
182 d->lineEditShader->setText(fileToOpen);
188 d->plane->setShader(shader);
190 d->plane->touchProperty();
198 d->comboBoxShader->setEnabled(
true);
199 d->lineEditShader->setEnabled(
true);
200 d->buttonShader->setEnabled(
true);
202 d->plane->setShader(d->lineEditShader->text());
206 d->comboBoxShader->setEnabled(
false);
207 d->lineEditShader->setEnabled(
false);
208 d->buttonShader->setEnabled(
false);
209 d->plane->setShader(
"");
213 d->plane->touchProperty();
219 d->plane->point()->x() = x;
220 d->plane->touchGeometry();
226 d->plane->point()->y() = y;
227 d->plane->touchGeometry();
233 d->plane->point()->z() = z;
234 d->plane->touchGeometry();
241 d->plane->normal()->x() = x;
242 d->plane->touchGeometry();
248 d->plane->normal()->y() = y;
249 d->plane->touchGeometry();
255 d->plane->normal()->z() = z;
256 d->plane->touchGeometry();
262 QVariant variant = d->plane->QObject::property(
"color");
263 if(variant.isValid())
265 d->plane->setColor(color);
267 d->plane->touchProperty();
290 d->plane->setSize(size);
294 d->plane->touchGeometry();
299 double opacity_d = 1.0 - 0.01 * opacity;
301 QVariant variant = d->plane->QObject::property(
"opacity");
302 if(variant.isValid())
304 d->plane->setOpacity(opacity_d);
306 d->plane->touchProperty();
315 const QSignalBlocker blockerPointX(d->coordinatePoint_x);
316 const QSignalBlocker blockerPointY(d->coordinatePoint_y);
317 const QSignalBlocker blockerPointZ(d->coordinatePoint_z);
318 const QSignalBlocker blockerNormalX(d->coordinateNormal_x);
319 const QSignalBlocker blockerNormalY(d->coordinateNormal_y);
320 const QSignalBlocker blockerNormalZ(d->coordinateNormal_z);
322 d->coordinatePoint_x->setValue(d->plane->point()->x());
323 d->coordinatePoint_y->setValue(d->plane->point()->y());
324 d->coordinatePoint_z->setValue(d->plane->point()->z());
326 d->coordinateNormal_x->setValue(d->plane->normal()->x());
327 d->coordinateNormal_y->setValue(d->plane->normal()->y());
328 d->coordinateNormal_z->setValue(d->plane->normal()->z());
~axlInspectorObjectPlane(void)
#define addColorButton(layoutTop, colorButton, slot, init)
#define addOpacitySlider(layoutTop, sliderOpacity, slot, init)
void onColorChanged(QColor color)
void setData(axlPlane *pointt)
void onLineEditShaderChanged(QString)
#define addPointLayout(layoutTop, name, title, coordinatePoint, slot, init)
Class axlPlane defines 3D planes.
void onShaderChanged(QString)
void onOpacityChanged(int opacity)
void onShaderStateChanged(bool isShader)
void onCoordDataChangedPoint_z(double z)
void onCoordDataChangedNormal_y(double y)
axlInspectorObjectPlane(QWidget *parent=0)
void onSizeChanged(double size)
void onCoordDataChangedNormal_x(double x)
void onCoordDataChangedPoint_y(double y)
#define addShaderComboBox(layoutTop, comboBoxShader, checkBoxShader, lineEditShader, buttonShader, onComboBoxChanged, onCheckBoxChanged, onTextChanged, openShader, init)
void onCoordDataChangedPoint_x(double x)
QString filePath(const QString &shader)
void onCoordDataChangedNormal_z(double z)
QSize sizeHint(void) const