25 #include <dtkGuiSupport/dtkColorButton.h>
26 #include <dtkGuiSupport/dtkSplitter.h>
30 class axlInspectorObjectPointSetPrivate
36 dtkColorButton *colorButton;
37 QComboBox *comboBoxShader;
39 QCheckBox *checkBoxShader;
40 QLineEdit *lineEditShader;
41 QPushButton *buttonShader;
43 QSlider *sliderOpacity;
50 d->colorButton = NULL;
51 d->comboBoxShader = NULL;
53 d->checkBoxShader = NULL;
54 d->lineEditShader = NULL;
55 d->buttonShader = NULL;
57 d->sliderOpacity = NULL;
69 return QSize(300, 300);
73 d->pointSet = pointSet;
77 void axlInspectorObjectPointSet::initWidget()
79 QVBoxLayout *layoutTop =
new QVBoxLayout(
this);
80 layoutTop->addWidget(
new QLabel(
"axlInspectorObjectPointSet",
this));
84 layoutTop->addWidget(
new QLabel(
"NumberOfPoint : " +QString::number(d->pointSet->numberOfPoints()),
this));
88 d->sliderSize =
new QSlider(Qt::Horizontal,
this);
90 QHBoxLayout *layoutSize =
new QHBoxLayout;
91 layoutSize->addWidget(
new QLabel(
"Size",
this));
92 layoutSize->addWidget(d->sliderSize);
93 d->sliderSize->setMinimum(-300);
94 d->sliderSize->setMaximum(900);
95 d->sliderSize->setValue(initSizeValue());
98 QHBoxLayout *layoutColorButton =
new QHBoxLayout;
99 if(d->pointSet->isUniqueColor())
101 d->colorButton =
new dtkColorButton(
this);
103 layoutColorButton->addWidget(
new QLabel(
"Color",
this));
104 layoutColorButton->addWidget(d->colorButton);
105 d->colorButton->setColor(this->initColorValue());
109 d->sliderOpacity =
new QSlider(Qt::Horizontal,
this);
111 QHBoxLayout *layoutOpacity =
new QHBoxLayout;
112 layoutOpacity->addWidget(
new QLabel(
"Opacity",
this));
113 layoutOpacity->addWidget(d->sliderOpacity);
114 d->sliderOpacity->setMaximum(100);
115 d->sliderOpacity->setValue(initOpacityValue());
118 d->comboBoxShader =
new QComboBox(
this);
119 d->comboBoxShader->setInsertPolicy(QComboBox::InsertAlphabetically);
121 d->checkBoxShader =
new QCheckBox(
this);
122 d->lineEditShader =
new QLineEdit(
this);
123 d->buttonShader =
new QPushButton(
this);
124 d->buttonShader->setText(
"open");
126 d->lineEditShader->setText(this->initShaderValue());
127 this->initComboBoxShaderValue();
129 if(d->lineEditShader->text().isEmpty())
131 d->lineEditShader->setEnabled(
false);
132 d->buttonShader->setEnabled(
false);
133 d->comboBoxShader->setEnabled(
false);
136 d->checkBoxShader->setChecked(
true);
141 QVBoxLayout *layoutShader =
new QVBoxLayout;
142 QHBoxLayout *layoutShader1 =
new QHBoxLayout;
144 QLabel *labelShader =
new QLabel(
"Shader",
this);
145 layoutShader1->addWidget(labelShader);
146 layoutShader1->addWidget(d->checkBoxShader);
147 layoutShader1->addWidget(d->comboBoxShader);
148 layoutShader1->addWidget(d->buttonShader);
150 layoutShader1->setStretchFactor(labelShader, 2);
151 layoutShader1->setStretchFactor(d->checkBoxShader, 1);
152 layoutShader1->setStretchFactor(d->comboBoxShader, 4);
153 layoutShader1->setStretchFactor(d->buttonShader, 3);
155 layoutShader->addLayout(layoutShader1);
156 layoutShader->addWidget(d->lineEditShader);
158 layoutTop->addLayout(layoutSize);
160 if(d->pointSet->isUniqueColor())
161 layoutTop->addLayout(layoutColorButton);
162 layoutTop->addLayout(layoutOpacity);
163 layoutTop->addLayout(layoutShader);
165 QWidget *top =
new QWidget(
this);
166 top->setMaximumWidth(295);
168 top->setLayout(layoutTop);
179 connect(d->sliderSize, SIGNAL(valueChanged(
int)),
this, SLOT(
onSizeChanged(
int)));
182 if(d->pointSet->isUniqueColor())
185 connect(d->sliderOpacity, SIGNAL(valueChanged(
int)),
this, SLOT(
onOpacityChanged(
int)));
187 connect(d->comboBoxShader, SIGNAL(currentIndexChanged(QString)),
this, SLOT(
onLineEditShaderChanged(QString)));
189 connect(d->buttonShader, SIGNAL(clicked()),
this, SLOT(
openShader()));
190 connect(d->lineEditShader, SIGNAL(textChanged(QString)),
this, SLOT(
onShaderChanged(QString)));
195 int axlInspectorObjectPointSet::initSizeValue(
void)
197 double initSize = 100.0 * (log(d->pointSet->size()/0.125))/log(2);
202 void axlInspectorObjectPointSet::initComboBoxShaderValue(
void)
204 if(d->comboBoxShader) {
210 QDir dirShader(
":axlShader/shader/");
211 dirShader.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
213 dirShader.setNameFilters(filters);
215 QFileInfoList list = dirShader.entryInfoList();
220 QSettings settings(
"inria",
"dtk");
222 settings.beginGroup(
"shader");
223 QString defaultPathShader = settings.value(
"path", defaultPath).toString();
224 defaultPathShader.append(
"/");
226 QDir defaultDirShader(defaultPathShader);
227 defaultDirShader.setNameFilters(filters);
228 QFileInfoList list2 = defaultDirShader.entryInfoList();
234 for (
int i = 0; i < list.size(); ++i) {
235 if(!items.contains(list.at(i).fileName()))
236 items << list.at(i).fileName();
240 int indInitShader = -1;
241 int indCurrentShader = -1;
243 foreach(QString item, items) {
245 d->comboBoxShader->addItem(item);
247 QFileInfo currentFileInfo(d->lineEditShader->text());
249 if(currentFileInfo.exists())
251 if(item == currentFileInfo.fileName())
252 indInitShader =indCurrentShader;
257 if(indInitShader != -1)
258 d->comboBoxShader->setCurrentIndex(indInitShader);
265 QDir dirShader(
":axlShader/shader/");
266 dirShader.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
268 QFileInfo currentFile(dirShader, shader);
269 if(!currentFile.exists())
271 QSettings settings(
"inria",
"dtk");
273 settings.beginGroup(
"shader");
274 QString defaultPathShader = settings.value(
"path", defaultPath).toString();
275 defaultPathShader.append(
"/");
277 QDir defaultDirShader(defaultPathShader);
278 currentFile = QFileInfo(defaultDirShader, shader);
282 d->lineEditShader->setText(currentFile.absoluteFilePath());
285 QString axlInspectorObjectPointSet::initShaderValue(
void)
287 return d->pointSet->shader();
291 QColor axlInspectorObjectPointSet::initColorValue(
void)
293 return d->pointSet->color();
297 int axlInspectorObjectPointSet::initOpacityValue(
void)
299 double initOpacity = 0.0;
300 double opacity = d->pointSet->opacity();
301 if(opacity > initOpacity)
302 initOpacity = opacity;
304 return 100 * (1.0 - initOpacity);
309 if(d->lineEditShader->isEnabled())
312 fileToOpen = QFileDialog::getOpenFileName(
this, tr(
"Open shader"),
"", tr(
"vs file (*.vs)"));
313 d->lineEditShader->setText(fileToOpen);
319 d->pointSet->setShader(shader);
330 d->comboBoxShader->setEnabled(
true);
331 d->lineEditShader->setEnabled(
true);
332 d->buttonShader->setEnabled(
true);
336 d->comboBoxShader->setEnabled(
false);
337 d->lineEditShader->setEnabled(
false);
338 d->buttonShader->setEnabled(
false);
344 QVariant variant = d->pointSet->QObject::property(
"color");
345 if(variant.isValid())
347 d->pointSet->setColor(color);
358 double size_d = pow(2.0, size/100.0 - 3.0);
360 QVariant variant = d->pointSet->QObject::property(
"size");
361 if(variant.isValid())
363 d->pointSet->setSize(size_d);
373 double opacity_d = 1.0 - 0.01 * opacity;
375 QVariant variant = d->pointSet->QObject::property(
"opacity");
376 if(variant.isValid())
378 d->pointSet->setOpacity(opacity_d);
~axlInspectorObjectPointSet(void)
void onOpacityChanged(int opacity)
void colorChanged(QColor color, dtkAbstractData *data)
void setData(axlPointSet *pointt)
axlInspectorObjectPointSet(QWidget *parent=0)
bool caseInsensitiveLessThan(const QString &s1, const QString &s2)
void dataChangedByOpacity(dtkAbstractData *data, double opacity)
void dataChangedBySize(dtkAbstractData *data, double size)
void onShaderChanged(QString)
void onShaderStateChanged(bool isShader)
void onSizeChanged(int size)
void onColorChanged(QColor color)
void onLineEditShaderChanged(QString)
QSize sizeHint(void) const
void dataChangedByColor(dtkAbstractData *data, double red, double green, double blue)
void dataChangedByShader(dtkAbstractData *data, QString isophoteShaderXml)