Developer documentation | Axl-2.5.1

axlInspectorObjectDataDynamic.cpp
Go to the documentation of this file.
1 /* axlInspectorObjectDataDynamic.cpp ---
2  *
3  * Author: Anais Ducoffe
4  * Copyright (C) 2013 - Anais Ducoffe, Inria.
5  */
6 
7 /* Commentary:
8  *
9  */
10 
11 /* Change log:
12  *
13  */
14 
16 
17 #include <axlCore/axlDataDynamic.h>
18 #include <axlCore/axlDouble.h>
19 #include <axlCore/axlInteger.h>
20 #include <axlCore/axlLine.h>
24 
25 //#include <math>
26 #include <dtkGuiSupport/dtkColorButton.h>
27 #include <dtkGuiSupport/dtkSplitter.h>
28 
29 #include <QtGui>
30 
31 class axlInspectorObjectDataDynamicPrivate
32 {
33 public:
34  axlDataDynamic *dynamicData;
35  // dtkColorButton *colorButton;
36 
37  // QComboBox *comboBoxShader;
38 
39  // QCheckBox *checkBoxShader;
40  // QLineEdit *lineEditShader;
41  // QPushButton *buttonShader;
42 
43  // QSlider *sliderOpacity;
44  QVBoxLayout *layoutTop;
45 };
46 
48  axlInspectorObjectInterface(parent), //QFrame(parent),
49  d(new axlInspectorObjectDataDynamicPrivate)
50 {
51  d->dynamicData = NULL;
52 
53  d->layoutTop = new QVBoxLayout;
54  d->layoutTop->addWidget(new QLabel("axlInspectorObjectDataDynamic", this));
55  d->layoutTop->addStretch(1);
56 
57  QWidget *top = new QWidget(this);
58  top->setMaximumWidth(295);
59  top->setLayout(d->layoutTop);
60 
61  // connect(d->checkBoxShader, SIGNAL(clicked(bool)), this, SLOT(onShaderStateChanged(bool)));
62  // connect(d->buttonShader, SIGNAL(clicked()), this, SLOT(openShader()));
63 
64 }
65 
67 {
68  delete d;
69 
70  d = NULL;
71 }
72 
74 {
75  return QSize(300, 300);
76 }
77 
79 {
80 
81  d->dynamicData = dynamicData;
82 
83  //display outputs names
84  QLabel *newLabelOutput= new QLabel(this);
85  newLabelOutput->setText("Outputs :");
86  d->layoutTop->addWidget(newLabelOutput);
87  for(int i = 0;i < dynamicData->numberOfChannels();i++){
88  QLabel *newLabel= new QLabel(this);
89  newLabel->setText(d->dynamicData->outputs(i)->name());
90  d->layoutTop->addWidget(newLabel);
91  }
92 
93  //display inputs data and double
94  QLabel *newLabel= new QLabel(this);
95  newLabel->setText("Inputs :");
96  d->layoutTop->addWidget(newLabel);
97  for(int i = 0; i < d->dynamicData->inputs().size();i++){
98  if(axlDouble *valueInput = dynamic_cast<axlDouble *>(d->dynamicData->inputs().at(i))){
99  QDoubleSpinBox *newBox = new QDoubleSpinBox(this);
100  newBox->setValue(valueInput->value());
101  newBox->setSingleStep(0.10);
102  connect(newBox, SIGNAL(valueChanged(double)), valueInput, SLOT(setValue(double)));
103  connect(newBox, SIGNAL(valueChanged(double)), this, SIGNAL(update()));
104  d->layoutTop->addWidget(newBox);
105  }else if(axlInteger *valueInput = dynamic_cast<axlInteger *>(d->dynamicData->inputs().at(i))) {
106  QSpinBox *newBox = new QSpinBox(this);
107  newBox->setValue(valueInput->value());
108  connect(newBox, SIGNAL(valueChanged(int)), valueInput, SLOT(setValue(int)));
109  connect(newBox, SIGNAL(valueChanged(int)), this, SIGNAL(update()));
110  d->layoutTop->addWidget(newBox);
111  }else {
112  QLabel *newLabel= new QLabel(this);
113  newLabel->setText(d->dynamicData->inputs().at(i)->name());
114  d->layoutTop->addWidget(newLabel);
115  }
116  }
117 
118 
119  // connect(d->colorButton, SIGNAL(colorChanged(QColor)), this, SLOT(onColorChanged(QColor)));
120 
121  // connect(d->sliderOpacity, SIGNAL(valueChanged(int)), this, SLOT(onOpacityChanged(int)));
122 
123  // connect(d->lineEditShader, SIGNAL(textChanged(QString)), this, SLOT(onShaderChanged(QString)));
124  // connect(d->comboBoxShader, SIGNAL(currentIndexChanged(QString)), this, SLOT(onLineEditShaderChanged(QString)));
125 
126 
127 
128 }
129 
130 //void axlInspectorObjectDataDynamic::onPropertiesChanged(void){
131 
132 
133 // QObject *emitter = sender();
134 // axlAbstractData *data = qobject_cast<axlAbstractData *>(emitter);
135 
136 // qDebug() << Q_FUNC_INFO << data->name();
137 
138 // this->onColorChanged(data->color());
139 // d->colorButton->setColor(data->color());
140 // this->onOpacityChanged(data->opacity());
141 // d->sliderOpacity->setValue(100 * (1.0 - data->opacity()));
142 // this->onShaderChanged(data->shader());
143 // d->lineEditShader->setText(data->shader());
144 
145 //}
146 
147 //void axlInspectorObjectDataDynamic::initComboBoxShaderValue(void)
148 //{
149 // if(d->comboBoxShader)
150 // {
151 // // First add item of axlShader.qrc, then find shader from shader path
152 // QDir dirShader( ":axlShader/shader/");
153 // dirShader.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
154 
155 // QFileInfoList list = dirShader.entryInfoList();
156 // // for (int i = 0; i < list.size(); ++i) {
157 // // d->comboBoxShader->addItem(list.at(i).fileName());
158 // // }
159 
160 // QSettings settings("inria", "dtk");
161 // QString defaultPath;
162 // settings.beginGroup("shader");
163 // QString defaultPathShader = settings.value("path", defaultPath).toString();
164 // defaultPathShader.append("/");
165 
166 // QDir defaultDirShader(defaultPathShader);
167 // QStringList filters;
168 // filters << "*.xml";
169 // defaultDirShader.setNameFilters(filters);
170 // QFileInfoList list2 = defaultDirShader.entryInfoList();
171 
172 // list.append(list2);
173 
174 // QStringList items;
175 
176 // for (int i = 0; i < list.size(); ++i) {
177 // if(!items.contains(list.at(i).fileName()))
178 // items << list.at(i).fileName();
179 // }
180 
181 // qSort(items.begin(), items.end(), caseInsensitiveLessThan);
182 // int indInitShader = -1;
183 // int indCurrentShader = -1;
184 
185 
186 // foreach(QString item, items)
187 // {
188 // indCurrentShader++;
189 // d->comboBoxShader->addItem(item);
190 
191 // QFileInfo currentFileInfo(d->lineEditShader->text());
192 
193 // if(currentFileInfo.exists())
194 // {
195 // if(item == currentFileInfo.fileName())
196 // indInitShader =indCurrentShader;
197 // }
198 
199 // }
200 
201 // //init the value from the lineEditShader.
202 // if(indInitShader != 1)
203 // d->comboBoxShader->setCurrentIndex(indInitShader);
204 
205 // }
206 //}
207 
208 //void axlInspectorObjectDataDynamic::onLineEditShaderChanged(QString shader)
209 //{
210 // // First add item of axlShader.qrc, then find shader from shader path
211 // QDir dirShader( ":axlShader/shader/");
212 // dirShader.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
213 
214 // QFileInfo currentFile(dirShader, shader);
215 // if(!currentFile.exists())
216 // {
217 // QSettings settings("inria", "dtk");
218 // QString defaultPath;
219 // settings.beginGroup("shader");
220 // QString defaultPathShader = settings.value("path", defaultPath).toString();
221 // defaultPathShader.append("/");
222 
223 // QDir defaultDirShader(defaultPathShader);
224 // currentFile = QFileInfo(defaultDirShader, shader);
225 
226 // }
227 
228 // d->lineEditShader->setText(currentFile.absoluteFilePath());
229 //}
230 
231 
232 
233 //void axlInspectorObjectDataDynamic::openShader()
234 //{
235 // if(d->lineEditShader->isEnabled())
236 // {
237 // QString fileToOpen;
238 // fileToOpen = QFileDialog::getOpenFileName(this, tr("Open shader"), "", tr("xml document (*.xml)"));
239 // d->lineEditShader->setText(fileToOpen);
240 // }
241 //}
242 
243 //void axlInspectorObjectDataDynamic::onShaderChanged(QString shader)
244 //{
245 // d->dynamicData->setShader(shader);
246 
247 // // emit dataChangedByShader(d->dynamicData, d->lineEditShader->text());
248 // emit modifiedProperty(d->dynamicData, 2);
249 
250 // emit update();
251 //}
252 
253 //void axlInspectorObjectDataDynamic::onShaderStateChanged(bool isShader)
254 //{
255 // if(isShader)
256 // {
257 // d->comboBoxShader->setEnabled(true);
258 // d->lineEditShader->setEnabled(true);
259 // d->buttonShader->setEnabled(true);
260 // onLineEditShaderChanged(d->comboBoxShader->currentText());
261 
262 // d->dynamicData->setShader(d->lineEditShader->text());
263 // // emit dataChangedByShader(d->dynamicData, d->lineEditShader->text());
264 // }
265 // else
266 // {
267 // d->comboBoxShader->setEnabled(false);
268 // d->lineEditShader->setEnabled(false);
269 // d->buttonShader->setEnabled(false);
270 
271 // d->dynamicData->setShader("");
272 // // emit dataChangedByShader(d->dynamicData, "");
273 // }
274 
275 // emit modifiedProperty(d->dynamicData, 2);
276 // emit update();
277 //}
278 
279 
280 
281 //void axlInspectorObjectDataDynamic::onColorChanged(QColor color)
282 //{
283 
284 // d->dynamicData->setColor(color);
285 // d->dynamicData->outputs()->setColor(color);
286 // // emit dataChangedByColor(d->dynamicData, color.redF(), color.greenF(), color.blueF());
287 // emit modifiedProperty(d->dynamicData, 0);
288 
289 // emit update();
290 //}
291 
292 
293 //void axlInspectorObjectDataDynamic::onOpacityChanged(int opacity)
294 //{
295 // double opacity_d = 1.0 - 0.01 * opacity; // range from 0.00 to 1.00
296 // d->dynamicData->setOpacity(opacity_d);
297 // d->dynamicData->outputs()->setOpacity(opacity_d);
298 
299 // // emit dataChangedByOpacity(d->dynamicData, opacity_d);
300 // emit modifiedProperty(d->dynamicData, 1);
301 
302 // emit update();
303 //}
304 
305 
virtual int numberOfChannels(void)
Return the number of output(s);.
Class axlDouble defines a double.
Definition: axlDouble.h:29
Class axlDataDynamic defines a dynamic object.
Class axlInteger defines an integer.
Definition: axlInteger.h:28
void setData(axlDataDynamic *dynamicData)