24 #include <dtkCoreSupport/dtkAbstractData.h>
26 #include <dtkGuiSupport/dtkColorButton.h>
27 #include <dtkGuiSupport/dtkSplitter.h>
33 class axlInspectorObjectCompositePrivate
37 dtkColorButton *colorButton;
39 QComboBox *comboBoxShader;
41 QCheckBox *checkBoxShader;
42 QLineEdit *lineEditShader;
43 QPushButton *buttonShader;
45 QSlider *sliderOpacity;
57 d->sliderOpacity =
new QSlider(Qt::Horizontal,
this);
58 d->sliderOpacity->setMaximum(100);
60 d->comboBoxShader =
new QComboBox(
this);
62 d->checkBoxShader =
new QCheckBox(
this);
63 d->lineEditShader =
new QLineEdit(
this);
64 d->buttonShader =
new QPushButton(
this);
65 d->buttonShader->setText(
"open");
66 d->lineEditShader->setEnabled(
false);
67 d->buttonShader->setEnabled(
false);
68 d->comboBoxShader->setEnabled(
false);
70 d->colorButton =
new dtkColorButton(
this);
72 QHBoxLayout *layoutColorButton =
new QHBoxLayout;
73 layoutColorButton->addWidget(
new QLabel(
"Color",
this));
74 layoutColorButton->addWidget(d->colorButton);
76 QHBoxLayout *layoutOpacity =
new QHBoxLayout;
77 layoutOpacity->addWidget(
new QLabel(
"Opacity",
this));
78 layoutOpacity->addWidget(d->sliderOpacity);
80 QVBoxLayout *layoutShader =
new QVBoxLayout;
81 QHBoxLayout *layoutShader1 =
new QHBoxLayout;
82 QLabel *labelShader =
new QLabel(
"Shader",
this);
83 layoutShader1->addWidget(labelShader);
84 layoutShader1->addWidget(d->checkBoxShader);
85 layoutShader1->addWidget(d->comboBoxShader);
86 layoutShader1->addWidget(d->buttonShader);
87 layoutShader1->setStretchFactor(labelShader, 2);
88 layoutShader1->setStretchFactor(d->checkBoxShader, 1);
89 layoutShader1->setStretchFactor(d->comboBoxShader, 4);
90 layoutShader1->setStretchFactor(d->buttonShader, 3);
92 layoutShader->addLayout(layoutShader1);
93 layoutShader->addWidget(d->lineEditShader);
95 QVBoxLayout *layoutTop =
new QVBoxLayout;
96 layoutTop->addWidget(
new QLabel(
"axlInspectorObjectComposite",
this));
97 layoutTop->addLayout(layoutColorButton);
98 layoutTop->addLayout(layoutOpacity);
99 layoutTop->addLayout(layoutShader);
100 layoutTop->addStretch(1);
102 QWidget *top =
new QWidget(
this);
103 top->setMaximumWidth(295);
104 top->setLayout(layoutTop);
106 dtkSplitter *splitter =
new dtkSplitter(
this,
true);
107 splitter->setOrientation(Qt::Vertical);
108 splitter->addWidget(top);
109 splitter->addWidget(d->parameter_space);
111 QVBoxLayout *layout =
new QVBoxLayout(
this);
112 layout->setContentsMargins(0, 0, 0, 0);
113 layout->setSpacing(0);
114 layout->addWidget(splitter);
118 connect(d->buttonShader, SIGNAL(clicked()),
this, SLOT(
openShader()));
124 connect(d->parameter_space, SIGNAL(
update()),
this, SIGNAL(
update()));
136 return QSize(300, 300);
144 QColor color =
object->color();
146 d->colorButton->setColor(color);
147 d->sliderOpacity->setValue(100 * (1.0 - d->data->opacity()));
148 d->lineEditShader->setText(d->data->shader());
149 this->initComboBoxShaderValue();
152 connect(d->colorButton, SIGNAL(colorChanged(QColor)),
this, SLOT(
onColorChanged(QColor)));
154 connect(d->colorButton, SIGNAL(colorChanged(QColor)),
this, SLOT(
onColorChanged(QColor)));
156 connect(d->sliderOpacity, SIGNAL(valueChanged(
int)),
this, SLOT(
onOpacityChanged(
int)));
158 connect(d->lineEditShader, SIGNAL(textChanged(QString)),
this, SLOT(
onShaderChanged(QString)));
159 connect(d->comboBoxShader, SIGNAL(currentIndexChanged(QString)),
this, SLOT(
onLineEditShaderChanged(QString)));
166 d->data->setColor(color);
176 if(d->lineEditShader->isEnabled())
179 fileToOpen = QFileDialog::getOpenFileName(
this, tr(
"Open shader"),
"", tr(
"vs file (*.vs)"));
180 d->lineEditShader->setText(fileToOpen);
184 void axlInspectorObjectComposite::initComboBoxShaderValue(
void)
186 if(d->comboBoxShader) {
192 QDir dirShader(
":axlShader/shader/");
193 dirShader.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
195 dirShader.setNameFilters(filters);
197 QFileInfoList list = dirShader.entryInfoList();
202 QSettings settings(
"inria",
"dtk");
204 settings.beginGroup(
"shader");
205 QString defaultPathShader = settings.value(
"path", defaultPath).toString();
206 defaultPathShader.append(
"/");
208 QDir defaultDirShader(defaultPathShader);
209 defaultDirShader.setNameFilters(filters);
210 QFileInfoList list2 = defaultDirShader.entryInfoList();
216 for (
int i = 0; i < list.size(); ++i) {
217 if(!items.contains(list.at(i).fileName()))
218 items << list.at(i).fileName();
222 int indInitShader = -1;
223 int indCurrentShader = -1;
225 foreach(QString item, items) {
227 d->comboBoxShader->addItem(item);
229 QFileInfo currentFileInfo(d->lineEditShader->text());
231 if(currentFileInfo.exists())
233 if(item == currentFileInfo.fileName())
234 indInitShader =indCurrentShader;
239 if(indInitShader != -1)
240 d->comboBoxShader->setCurrentIndex(indInitShader);
247 d->data->setShader(shader);
258 QDir dirShader(
":axlShader/shader/");
259 dirShader.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
261 QFileInfo currentFile(dirShader, shader);
262 if(!currentFile.exists())
264 QSettings settings(
"inria",
"dtk");
266 settings.beginGroup(
"shader");
267 QString defaultPathShader = settings.value(
"path", defaultPath).toString();
268 defaultPathShader.append(
"/");
270 QDir defaultDirShader(defaultPathShader);
271 currentFile = QFileInfo(defaultDirShader, shader);
275 d->lineEditShader->setText(currentFile.absoluteFilePath());
282 d->comboBoxShader->setEnabled(
true);
283 d->lineEditShader->setEnabled(
true);
284 d->buttonShader->setEnabled(
true);
291 d->comboBoxShader->setEnabled(
false);
292 d->lineEditShader->setEnabled(
false);
293 d->buttonShader->setEnabled(
false);
303 double opacity_d = 1.0 - 0.01 * opacity;
304 d->data->setOpacity(opacity_d);
void onOpacityChanged(int opacity)
void modifiedProperty(dtkAbstractData *, int)
void moveCurrentPoint(double u, double v, dtkAbstractData *data)
bool caseInsensitiveLessThan(const QString &s1, const QString &s2)
void onShowCurrentPoint(double u, double v)
void hideCurrentPoint(double u, double v, dtkAbstractData *data)
axlInspectorObjectComposite(QWidget *parent=0)
void onColorChanged(QColor color)
void onLineEditShaderChanged(QString)
void onMoveCurrentPoint(double u, double v)
void setData(axlAbstractDataComposite *data)
void onHideCurrentPoint(double u, double v)
void onShaderStateChanged(bool isShader)
~axlInspectorObjectComposite(void)
void onShaderChanged(QString)
void showCurrentPoint(double u, double v, dtkAbstractData *data)
QSize sizeHint(void) const