23 #include <dtkGuiSupport/dtkColorButton.h>
26 #include <dtkCoreSupport/dtkAbstractProcessFactory.h>
33 class axlInspectorToolCreatorDataDynamicDialogPrivate
36 QSlider *sliderOpacity;
37 dtkColorButton *colorButton;
40 QLineEdit *process_name;
41 QLineEdit *listDoubleValues;
44 QLabel *messageToDisplay;
65 d->layout =
new QVBoxLayout(
this);
68 d->sliderOpacity =
new QSlider(Qt::Horizontal,
this);
70 QHBoxLayout *layoutOpacity =
new QHBoxLayout;
71 layoutOpacity->addWidget(
new QLabel(
"Opacity",
this));
72 layoutOpacity->addWidget(d->sliderOpacity);
73 d->sliderOpacity->setMaximum(100);
76 d->colorButton =
new dtkColorButton(
this);
78 QHBoxLayout *layoutColorButton =
new QHBoxLayout;
79 layoutColorButton->addWidget(
new QLabel(
"Color",
this));
80 layoutColorButton->addWidget(d->colorButton);
81 d->colorButton->setColor(QColor(
"#a0a0a4"));
84 QHBoxLayout *layoutProcessName =
new QHBoxLayout;
85 layoutProcessName->addWidget(
new QLabel(
"Process name",
this));
86 d->process_name =
new QLineEdit(
this);
87 QCompleter *completer =
new QCompleter(dtkAbstractProcessFactory::instance()->creators(),
this);
88 completer->setCaseSensitivity(Qt::CaseSensitive);
89 d->process_name->setCompleter(completer);
91 layoutProcessName->addWidget(d->process_name);
92 connect(d->process_name, SIGNAL(textChanged(QString)),
this, SLOT(
setProcessName()));
95 QHBoxLayout *layoutDoubleValues =
new QHBoxLayout;
96 QLabel *labelParameters =
new QLabel(
"double inputs values",
this);
97 layoutDoubleValues->addWidget(labelParameters);
98 d->listDoubleValues =
new QLineEdit(
this);
99 layoutDoubleValues->addWidget(d->listDoubleValues);
102 d->messageToDisplay =
new QLabel(
"",
this);
103 d->messageToDisplay->setStyleSheet(
"color: #ff0000;");
104 d->messageToDisplay->setVisible(
false);
107 d->errorMessage =
new QLabel(
"wrong inputs number or type,\n please select them as describe above");
108 d->errorMessage->setStyleSheet(
"color: #ff0000;");
109 d->errorMessage->setVisible(
false);
112 QHBoxLayout *layoutIsDynamic =
new QHBoxLayout(
this);
113 QLabel *labelIsStatic =
new QLabel(
"static",
this);
114 layoutIsDynamic->addWidget(labelIsStatic);
115 d->isStatic =
new QCheckBox(
this);
116 layoutIsDynamic->addWidget(d->isStatic);
119 QPushButton *button =
new QPushButton(
"Create",
this);
120 connect(button, SIGNAL(clicked()),
this, SLOT(
run()));
122 d->layout->addWidget(
new QLabel(
"axlInspectorToolCreatorDataDynamic",
this));
123 d->layout->addLayout(layoutOpacity);
124 d->layout->addLayout(layoutColorButton);
125 d->layout->addLayout(layoutProcessName);
126 d->layout->addWidget(d->messageToDisplay);
127 d->layout->addLayout(layoutDoubleValues);
128 d->layout->addWidget(d->dialog);
129 d->layout->addLayout(layoutIsDynamic);
130 d->layout->addWidget(button);
131 d->layout->addWidget(d->errorMessage);
133 d->listDoubleValues->hide();
134 labelParameters->hide();
155 d->controller = controller;
156 d->dialog->setController(controller);
170 QString processName = d->process_name->text();
172 if(!processName.isEmpty()){
179 d->layout->removeWidget(d->dialog);
184 d->dialog = newDialog;
185 d->dialog->setController(d->controller);
186 d->messageToDisplay->hide();
187 d->listDoubleValues->hide();
189 if(dynamic_cast<axlInspectorToolCreator *>(d->dialog))
192 d->dialog->setController(d->controller);
194 QObjectList listChildren = d->dialog->children();
195 for(
int i = 0; i < listChildren.size();i++){
196 if(dynamic_cast<QPushButton *>(listChildren.at(i)) ){
197 dynamic_cast<QWidget *
>(listChildren.at(i))->hide();
198 }
else if(dynamic_cast<QSlider *>(listChildren.at(i))){
199 dynamic_cast<QWidget *
>(listChildren.at(i))->hide();
200 }
else if(dynamic_cast<QLabel *>(listChildren.at(i))){
201 if(dynamic_cast<QLabel *>(listChildren.at(i))->text() ==
"Opacity" ||
dynamic_cast<QLabel *
>(listChildren.at(i))->text() ==
"Color")
202 dynamic_cast<QWidget *>(listChildren.at(i))->hide();
210 d->layout->insertWidget(6, d->dialog);
214 QString textToDisplay ;
218 textToDisplay.append(
"\n double inputs values: ");
219 d->messageToDisplay->setText(textToDisplay);
220 d->messageToDisplay->show();
222 d->listDoubleValues->show();
226 d->listDoubleValues->hide();
227 d->messageToDisplay->setText(
"This process doesn't exist");
228 d->messageToDisplay->show();
240 d->errorMessage->hide();
243 QString processName = d->process_name->text();
244 if(!processName.isEmpty()){
249 if(d->isStatic->isChecked()){
258 if(item->text(2) ==
"Selected"|| item->text(2) ==
"Editable")
260 if(dynamic_cast<axlAbstractData *>(d->controller->data(item))) {
261 if(
axlDataDynamic *axldata = dynamic_cast<axlDataDynamic *>(d->controller->data(item)))
262 dynamicData->
setInput(axldata->outputs());
264 dynamicData->
setInput(d->controller->data(item));
271 QString doubleValues = d->listDoubleValues->text();
272 if(d->listDoubleValues->isVisible() && !doubleValues.isEmpty()){
273 int sizeList = doubleValues.size();
276 while(indice <= sizeList){
277 if(doubleValues.at(indice).isSpace() || indice ==(sizeList)){
278 if(!value.isEmpty()){
279 bool hasLetter =
false;
280 for(
int j = 0;j <value.size();j++){
281 if(value.at(j).isLetter())
285 double newInputValue = value.toDouble();
293 value.append(doubleValues.at(indice));
298 QObjectList list = this->children();
299 for(
int i = 0;i < list.size();i++){
300 if(QFrame *frame = dynamic_cast<QFrame *>(list.at(i))){
301 QObjectList list1 = frame->children();
302 for(
int j = 0;j < list1.size();j++){
303 if(QDoubleSpinBox *box = dynamic_cast<QDoubleSpinBox *>(list1.at(j))){
304 double value = box->value();
307 }
else if(QSpinBox *box = dynamic_cast<QSpinBox *>(list1.at(j))){
308 int value = box->value();
321 if(d->dialog && dynamic_cast<axlInspectorToolCreator *>(d->dialog)){
323 for(
int j = 0;j< listInputs.size();j++){
324 dynamicData->
setInput(listInputs.at(j));
329 for(
int k = 0; k < dynamicData->
inputs().size();k++){
330 if(!(dynamicData->
inputs().at(k)->identifier() ==
"axlDouble") && !(dynamicData->
inputs().at(k)->identifier() ==
"axlInteger")){
331 dynamicData->
inputs().at(k)->setColor(d->colorButton->color());
332 double opacity = 1.0 - 0.01 * d->sliderOpacity->value();
333 dynamicData->
inputs().at(k)->setOpacity(opacity);
339 dynamicData->
setColor(d->colorButton->color());
340 double opacity = 1.0 - 0.01 * d->sliderOpacity->value();
346 d->errorMessage->show();
347 if(d->dialog && dynamic_cast<axlInspectorToolCreator *>(d->dialog)){
359 dynamicData->
setColor(d->colorButton->color());
360 double opacity = 1.0 - 0.01 * d->sliderOpacity->value();
virtual void update(void)
Update the dynamic object.
int setProcess(QString processName)
Create the dynamic object process only with the name of its latter.
virtual bool hasParameters(void)
void setType(axlDataDynamic::Type type)
Sets the type of the object. Type could be dynamic or static.
Class axlDouble defines a double.
axlAbstractData * outputs(void)
Return the first output of the list.
axlAbstractProcess * process(void)
Return the process.
Class axlDataDynamic defines a dynamic object.
void setInput(dtkAbstractData *data, int channel=0)
Add input;.
virtual QString description(void) const
Class axlInteger defines an integer.
QList< axlAbstractData * > inputs(void)
Return input list;.
void setOpacity(const double &opacity)
void clearInputs(void)
Clear input list.
void setColor(double r, double g, double b)
virtual QString identifier(void) const