104
108
stdParFrame->resetValues(curParSet);
107
void StdParFrame::resetValues(FilterParameterSet &curParSet)
111
void StdParFrame::resetValues(RichParameterSet &curParSet)
109
QList<FilterParameter> &parList =curParSet.paramList;
113
QList<RichParameter*> &parList =curParSet.paramList;
114
assert(stdfieldwidgets.size() == parList.size());
110
115
for(int i = 0; i < parList.count(); i++)
112
const FilterParameter &fpi=parList.at(i);
113
switch(fpi.fieldType)
115
case FilterParameter::PARBOOL:
116
if(fpi.fieldVal.toBool()) ((QCheckBox *)stdfieldwidgets.at(i))->setCheckState(Qt::Checked);
117
else ((QCheckBox *)stdfieldwidgets.at(i))->setCheckState(Qt::Unchecked);
119
case FilterParameter::PARFLOAT:
120
((QLineEdit *)stdfieldwidgets.at(i))->setText(QString::number(fpi.fieldVal.toDouble(),'g',3));
122
case FilterParameter::PARINT:
123
case FilterParameter::PARSTRING:
124
((QLineEdit *)stdfieldwidgets.at(i))->setText(fpi.fieldVal.toString());
126
case FilterParameter::PARABSPERC:
127
((AbsPercWidget *)stdfieldwidgets.at(i))->setValue(fpi.fieldVal.toDouble(),fpi.min,fpi.max);
129
case FilterParameter::PARCOLOR:
130
((QColorButton *)stdfieldwidgets.at(i))->setColor(QColor(fpi.fieldVal.toUInt()));
132
case FilterParameter::PARENUM:
133
((EnumWidget *)stdfieldwidgets.at(i))->setEnum(fpi.fieldVal.toUInt());
135
case FilterParameter::PARMESH:
136
if(NULL != fpi.pointerVal)
137
((MeshEnumWidget *)stdfieldwidgets.at(i))->setMesh((MeshModel *)(fpi.pointerVal));
140
int index = fpi.fieldVal.toInt();
141
//if a mesh exists at this index leave it otherwise pick 0
142
if(index >= ((MeshEnumWidget *)stdfieldwidgets.at(i))->getSize() ) index = 0;
144
((MeshEnumWidget *)stdfieldwidgets.at(i))->setEnum(index);
148
case FilterParameter::PARFLOATLIST:
150
QList<QVariant> list = fpi.fieldVal.toList();
151
((QVariantListWidget *)stdfieldwidgets.at(i))->setList(list);
154
case FilterParameter::PARDYNFLOAT:
156
float initVal = (float)fpi.fieldVal.toDouble();
157
((DynamicFloatWidget *)stdfieldwidgets.at(i))->setValue(initVal);
160
case FilterParameter::PAROPENFILENAME:
161
case FilterParameter::PARSAVEFILENAME:
162
((GetFileNameWidget *)stdfieldwidgets.at(i))->setFileName(fpi.fieldVal.toString());
117
RichParameter* fpi= parList.at(i);
119
stdfieldwidgets[i]->resetValue();
171
123
/* creates widgets for the standard parameters */
232
185
this->adjustSize();
235
void StdParFrame::loadFrameContent(FilterParameterSet &curParSet,MeshDocument *mdPt)
188
//void StdParFrame::loadFrameContent(ParameterDeclarationSet &curParSet,MeshDocument *mdPt)
189
void StdParFrame::loadFrameContent(RichParameterSet &curParSet,MeshDocument *mdPt)
237
191
if(layout()) delete layout();
238
QGridLayout *gridLayout = new QGridLayout(this);
239
setLayout(gridLayout);
240
// gridLayout->setColumnStretch(0,1);
241
// gridLayout->setColumnStretch(1,1);
242
// gridLayout->setColumnStretch(2,2);
251
DynamicFloatWidget *dfw;
254
QList<FilterParameter> &parList =curParSet.paramList;
192
QGridLayout * vLayout = new QGridLayout(this);
193
//vLayout->setAlignment(Qt::AlignLeading);
194
vLayout->setAlignment(Qt::AlignLeading);
199
QList<RichParameter*> &parList =curParSet.paramList;
202
RichWidgetInterfaceConstructor rwc(this);
258
203
for(int i = 0; i < parList.count(); i++)
260
const FilterParameter &fpi=parList.at(i);
261
ql = new QLabel("<small>"+fpi.fieldToolTip +"</small>",this);
262
ql->setTextFormat(Qt::RichText);
263
ql->setWordWrap(true);
264
ql->setVisible(false);
265
ql->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
266
ql->setMinimumWidth(250);
267
ql->setMaximumWidth(QWIDGETSIZE_MAX);
268
gridLayout->addWidget(ql,i,3,1,1,Qt::AlignTop);
269
helpList.push_back(ql);
271
switch(fpi.fieldType)
273
case FilterParameter::PARBOOL:
274
qcb = new QCheckBox(fpi.fieldDesc,this);
275
qcb->setToolTip(fpi.fieldToolTip);
276
if(fpi.fieldVal.toBool()) qcb->setCheckState(Qt::Checked);
277
gridLayout->addWidget(qcb,i,0,1,2,Qt::AlignTop);
278
stdfieldwidgets.push_back(qcb);
281
case FilterParameter::PARFLOAT:
282
ql = new QLabel(fpi.fieldDesc,this);
283
ql->setToolTip(fpi.fieldToolTip);
284
qle = new QLineEdit(QString::number(fpi.fieldVal.toDouble(),'g',3),this); // better formatting of floating point numbers
285
gridLayout->addWidget(ql,i,0,Qt::AlignTop);
286
gridLayout->addWidget(qle,i,1,Qt::AlignTop);
287
stdfieldwidgets.push_back(qle);
289
case FilterParameter::PARINT:
290
case FilterParameter::PARSTRING:
291
ql = new QLabel(fpi.fieldDesc,this);
292
ql->setToolTip(fpi.fieldToolTip);
294
qle = new QLineEdit(fpi.fieldVal.toString(),this);
296
gridLayout->addWidget(ql,i,0,Qt::AlignTop);
297
gridLayout->addWidget(qle,i,1,Qt::AlignTop);
299
stdfieldwidgets.push_back(qle);
302
case FilterParameter::PARABSPERC:
303
descr = fpi.fieldDesc + " (abs and %)";
304
ql = new QLabel(descr ,this);
305
ql->setToolTip(fpi.fieldToolTip);
307
apw = new AbsPercWidget(this,float(fpi.fieldVal.toDouble()),fpi.min,fpi.max);
308
gridLayout->addWidget(ql,i,0,Qt::AlignTop);
309
gridLayout->addLayout(apw,i,1,Qt::AlignTop);
311
stdfieldwidgets.push_back(apw);
314
case FilterParameter::PARCOLOR:
315
ql = new QLabel(fpi.fieldDesc,this);
316
ql->setToolTip(fpi.fieldToolTip);
318
qcbt = new QColorButton(this,QColor(fpi.fieldVal.toUInt()));
319
gridLayout->addWidget(ql,i,0,Qt::AlignTop);
320
gridLayout->addLayout(qcbt,i,1,Qt::AlignTop);
322
stdfieldwidgets.push_back(qcbt);
325
case FilterParameter::PARENUM:
326
ql = new QLabel(fpi.fieldDesc,this);
327
ql->setToolTip(fpi.fieldToolTip);
329
layout = new EnumWidget(this, fpi.fieldVal.toUInt(), fpi.enumValues);
330
gridLayout->addWidget(ql,i,0,Qt::AlignTop);
331
gridLayout->addLayout(layout,i,1,Qt::AlignTop);
333
stdfieldwidgets.push_back(layout);
337
case FilterParameter::PARMESH:
340
ql = new QLabel(fpi.fieldDesc,this);
341
ql->setToolTip(fpi.fieldToolTip);
343
MeshModel *defaultModel = 0;
344
int position = fpi.fieldVal.toInt();
346
//if there was no pointer try to use the position value to find the mesh in the mesh document
347
if(NULL == (fpi.pointerVal) &&
349
position < mdPt->meshList.size() )
351
//get the model from the position in the meshDocument
352
defaultModel = mdPt->getMesh(position);
353
} else //use the pointer provided
354
defaultModel = (MeshModel *)(fpi.pointerVal);
356
mew = new MeshEnumWidget(this, defaultModel, *mdPt);
358
gridLayout->addWidget(ql,i,0,Qt::AlignTop);
359
gridLayout->addLayout(mew,i,1,Qt::AlignTop);
360
stdfieldwidgets.push_back(mew);
364
case FilterParameter::PARFLOATLIST:
366
ql = new QLabel(fpi.fieldDesc,this);
367
ql->setToolTip(fpi.fieldToolTip);
369
QToolButton *addButton = new QToolButton(this);
370
addButton->setText("Add Row");
371
QToolButton *removeButton = new QToolButton(this);
372
removeButton->setText("Remove Row");
374
QVBoxLayout *leftLayout = new QVBoxLayout(this);
375
leftLayout->addWidget(ql);
376
leftLayout->addWidget(addButton);
377
leftLayout->addWidget(removeButton);
379
QList<QVariant> list = fpi.fieldVal.toList();
381
layout = new QVariantListWidget(this, list);
382
gridLayout->addLayout(leftLayout,i,0,Qt::AlignTop);
383
gridLayout->addLayout(layout,i,1,Qt::AlignTop);
385
connect(addButton, SIGNAL(clicked()), layout, SLOT(addRow()));
386
connect(removeButton, SIGNAL(clicked()), layout, SLOT(removeRow()));
388
stdfieldwidgets.push_back(layout);
392
case FilterParameter::PARDYNFLOAT :
393
ql = new QLabel(fpi.fieldDesc ,this);
394
ql->setToolTip(fpi.fieldToolTip);
396
dfw = new DynamicFloatWidget(this,float(fpi.fieldVal.toDouble()),fpi.min,fpi.max,fpi.mask);
397
gridLayout->addWidget(ql,i,0,Qt::AlignTop);
398
gridLayout->addLayout(dfw,i,1,Qt::AlignTop);
400
stdfieldwidgets.push_back(dfw);
401
connect(dfw,SIGNAL(valueChanged(int)),this,SIGNAL( dynamicFloatChanged(int) ));
405
case FilterParameter::PARPOINT3F :
407
ql = new QLabel(fpi.fieldDesc ,this);
408
ql->setToolTip(fpi.fieldToolTip);
411
QList<QVariant> pointVals = fpi.fieldVal.toList();
412
assert(pointVals.size()==3);
413
for(int ii=0;ii<3;++ii)
414
point[ii]=pointVals[ii].toDouble();
416
p3w = new Point3fWidget(this,point,fpi.fieldDesc,gla);
417
gridLayout->addWidget(ql,i,0,Qt::AlignTop);
418
gridLayout->addLayout(p3w,i,1,Qt::AlignTop);
419
stdfieldwidgets.push_back(p3w);
424
case FilterParameter::PAROPENFILENAME:
426
ql = new QLabel(fpi.fieldDesc,this);
427
ql->setToolTip(fpi.fieldToolTip);
429
QString defaultFileName = fpi.fieldVal.toString();
431
GetFileNameWidget *fileNameWidget = new GetFileNameWidget(
432
this, defaultFileName, true, fpi.enumValues.back());
434
gridLayout->addWidget(ql, i, 0, Qt::AlignTop);
435
gridLayout->addLayout(fileNameWidget, i, 1, Qt::AlignTop);
437
stdfieldwidgets.push_back(fileNameWidget);
441
case FilterParameter::PARSAVEFILENAME:
443
ql = new QLabel(fpi.fieldDesc,this);
444
ql->setToolTip(fpi.fieldToolTip);
446
QString defaultFileName = fpi.fieldVal.toString();
448
GetFileNameWidget *fileNameWidget = new GetFileNameWidget(
449
this, defaultFileName, false, fpi.enumValues.back());
451
gridLayout->addWidget(ql, i, 0, Qt::AlignTop);
452
gridLayout->addLayout(fileNameWidget, i, 1, Qt::AlignTop);
454
stdfieldwidgets.push_back(fileNameWidget);
205
RichParameter* fpi=parList.at(i);
207
//vLayout->addWidget(rwc.lastCreated,i,0,1,1,Qt::AlignTop);
208
stdfieldwidgets.push_back(rwc.lastCreated);
209
helpList.push_back(rwc.lastCreated->helpLab);
461
210
} // end for each parameter
480
229
this->adjustSize();
483
void StdParFrame::readValues(FilterParameterSet &curParSet)
485
QList<FilterParameter> &parList =curParSet.paramList;
487
for(int i = 0; i < parList.count(); i++)
489
QString sname = parList.at(i).fieldName;
490
switch(parList.at(i).fieldType)
492
case FilterParameter::PARBOOL:
493
curParSet.setBool(sname,((QCheckBox *)stdfieldwidgets[i])->checkState() == Qt::Checked);
495
case FilterParameter::PARINT:
496
curParSet.setInt(sname,((QLineEdit *)stdfieldwidgets[i])->text().toInt());
498
case FilterParameter::PARFLOAT:
499
curParSet.setFloat(sname,((QLineEdit *)stdfieldwidgets[i])->text().toFloat());
501
case FilterParameter::PARABSPERC:
502
curParSet.setAbsPerc(sname,((AbsPercWidget *)stdfieldwidgets[i])->getValue());
504
case FilterParameter::PARSTRING:
505
curParSet.setString(sname,((QLineEdit *)stdfieldwidgets[i])->text());
507
case FilterParameter::PARCOLOR:
508
curParSet.setColor(sname,((QColorButton *)stdfieldwidgets[i])->getColor());
510
case FilterParameter::PARENUM:
511
curParSet.setEnum(sname,((EnumWidget *)stdfieldwidgets[i])->getEnum());
513
case FilterParameter::PARMESH:
514
curParSet.setMesh(sname,((MeshEnumWidget *)stdfieldwidgets[i])->getMesh(), ((MeshEnumWidget *)stdfieldwidgets[i])->getEnum());
516
case FilterParameter::PARFLOATLIST:
517
curParSet.findParameter(sname)->fieldVal = ((QVariantListWidget *)stdfieldwidgets[i])->getList();
519
case FilterParameter::PARDYNFLOAT:
520
curParSet.findParameter(sname)->fieldVal = ((DynamicFloatWidget *)stdfieldwidgets[i])->getValue();
522
case FilterParameter::PAROPENFILENAME:
523
curParSet.setOpenFileName(sname, ((GetFileNameWidget *)stdfieldwidgets[i])->getFileName());
525
case FilterParameter::PARSAVEFILENAME:
526
curParSet.setSaveFileName(sname, ((GetFileNameWidget *)stdfieldwidgets[i])->getFileName());
528
case FilterParameter::PARPOINT3F:
529
curParSet.setPoint3f(sname,((Point3fWidget *)stdfieldwidgets[i])->getValue());
232
//void StdParFrame::readValues(ParameterDeclarationSet &curParSet)
233
void StdParFrame::readValues(RichParameterSet &curParSet)
235
QList<RichParameter*> &parList =curParSet.paramList;
236
assert(parList.size() == stdfieldwidgets.size());
237
QVector<MeshLabWidget*>::iterator it = stdfieldwidgets.begin();
238
for(int i = 0; i < parList.count(); i++)
240
QString sname = parList.at(i)->name;
241
curParSet.setValue(sname,(*it)->getWidgetValue());
246
StdParFrame::~StdParFrame()
538
251
/* click event for the apply button of the standard plugin window */
539
252
// If the filter has some dynamic parameters
559
279
if(!previewCB->isChecked()) return;
560
280
QAction *q = curAction;
561
281
stdParFrame->readValues(curParSet);
282
//for cache mechanism
283
//needed to allocate the required memory space in prevParSet
284
//it called the operator=(RichParameterSet) function defined in RichParameterSet
285
prevParSet = curParSet;
286
stdParFrame->readValues(prevParSet);
563
288
meshState.apply(curModel);
564
289
curmwi->executeFilter(q, curParSet, true);
290
meshCacheState.create(curmask,curModel);
295
this->curgla->update();
567
298
void MeshlabStdDialog::togglePreview()
569
if(previewCB->isChecked()) applyDynamic();
570
else meshState.apply(curModel);
300
if(previewCB->isChecked())
305
meshState.apply(curModel);
573
310
/* click event for the close button of the standard plugin window */
575
312
void MeshlabStdDialog::closeClick()
577
int mask = curParSet.getDynamicFloatMask();
578
if(mask) meshState.apply(curModel);
314
//int mask = 0;//curParSet.getDynamicFloatMask();
315
if(curmask) meshState.apply(curModel);
316
curmask = MeshModel::MM_UNKNOWN;
317
// Perform the update only if there is Valid GLarea.
318
if(this->curgla) this->curgla->update();
323
// click event for the standard red crossed close button in the upper right widget's corner
324
void MeshlabStdDialog::closeEvent(QCloseEvent * event)
329
MeshlabStdDialog::~MeshlabStdDialog()
582
337
/******************************************/
583
338
// AbsPercWidget Implementation
584
339
/******************************************/
585
AbsPercWidget::AbsPercWidget(QWidget *p, double defaultv, double minVal, double maxVal):QGridLayout(NULL)
343
AbsPercWidget::AbsPercWidget(QWidget *p, RichAbsPerc* rabs):MeshLabWidget(p,rabs)
346
AbsPercDecoration* absd = reinterpret_cast<AbsPercDecoration*>(rp->pd);
350
fieldDesc = new QLabel(rp->pd->fieldDesc + " (abs and %)",p);
351
fieldDesc->setToolTip(rp->pd->tooltip);
589
352
absSB = new QDoubleSpinBox(p);
590
353
percSB = new QDoubleSpinBox(p);
592
355
absSB->setMinimum(m_min-(m_max-m_min));
593
356
absSB->setMaximum(m_max*2);
594
357
absSB->setAlignment(Qt::AlignRight);
595
int decimals= 6-ceil(log10(fabs(m_max-m_min)) ) ;
359
int decimals= 7-ceil(log10(fabs(m_max-m_min)) ) ;
596
360
//qDebug("range is (%f %f) %f ",m_max,m_min,fabs(m_max-m_min));
597
361
//qDebug("log range is %f ",log10(fabs(m_max-m_min)));
598
362
absSB->setDecimals(decimals);
599
363
absSB->setSingleStep((m_max-m_min)/100.0);
600
absSB->setValue(defaultv);
364
float defaultv = rp->pd->defVal->getAbsPerc();
365
absSB->setValue(defaultv);
602
367
percSB->setMinimum(-200);
603
368
percSB->setMaximum(200);
604
369
percSB->setAlignment(Qt::AlignRight);
605
370
percSB->setSingleStep(0.5);
606
371
percSB->setValue((100*(defaultv - m_min))/(m_max - m_min));
372
percSB->setDecimals(3);
607
373
QLabel *absLab=new QLabel("<i> <small> world unit</small></i>");
608
374
QLabel *percLab=new QLabel("<i> <small> perc on"+QString("(%1 .. %2)").arg(m_min).arg(m_max)+"</small></i>");
610
this->addWidget(absLab,0,0,Qt::AlignHCenter);
611
this->addWidget(percLab,0,1,Qt::AlignHCenter);
613
this->addWidget(absSB,1,0);
614
this->addWidget(percSB,1,1,Qt::AlignTop);
376
int row = gridLay->rowCount() - 1;
377
gridLay->addWidget(fieldDesc,row,0,Qt::AlignHCenter);
379
QGridLayout* lay = new QGridLayout(p);
380
lay->addWidget(absLab,0,0,Qt::AlignHCenter);
381
lay->addWidget(percLab,0,1,Qt::AlignHCenter);
383
lay->addWidget(absSB,1,0,Qt::AlignTop);
384
lay->addWidget(percSB,1,1,Qt::AlignTop);
386
gridLay->addLayout(lay,row,1,Qt::AlignTop);
617
388
connect(absSB,SIGNAL(valueChanged(double)),this,SLOT(on_absSB_valueChanged(double)));
618
389
connect(percSB,SIGNAL(valueChanged(double)),this,SLOT(on_percSB_valueChanged(double)));
390
connect(this,SIGNAL(dialogParamChanged()),p,SLOT(parameterChanged()));
621
393
AbsPercWidget::~AbsPercWidget()
628
401
void AbsPercWidget::on_absSB_valueChanged(double newv)
630
403
percSB->setValue((100*(newv - m_min))/(m_max - m_min));
404
emit dialogParamChanged();
633
407
void AbsPercWidget::on_percSB_valueChanged(double newv)
635
409
absSB->setValue((m_max - m_min)*0.01*newv + m_min);
410
emit dialogParamChanged();
638
float AbsPercWidget::getValue()
640
return float(absSB->value());
413
//float AbsPercWidget::getValue()
415
// return float(absSB->value());
643
418
void AbsPercWidget::setValue(float val, float minV, float maxV)
734
534
return Point3f(coordSB[0]->text().toFloat(),coordSB[1]->text().toFloat(),coordSB[2]->text().toFloat());
737
/******************************************/
738
// QColorButton Implementation
739
/******************************************/
740
QColorButton::QColorButton(QWidget *p, QColor newColor):QHBoxLayout()
742
colorLabel = new QLabel(p);
743
colorButton = new QPushButton(p);
744
colorButton->setAutoFillBackground(true);
745
colorButton->setFlat(true);
747
this->addWidget(colorLabel);
748
this->addWidget(colorButton);
749
connect(colorButton,SIGNAL(clicked()),this,SLOT(pickColor()));
752
QColor QColorButton::getColor()
757
void QColorButton::setColor(QColor newColor)
759
currentColor=newColor;
760
colorLabel->setText("("+currentColor.name()+")");
761
QPalette palette(currentColor);
762
colorButton->setPalette(palette);
765
void QColorButton::pickColor()
767
QColor newColor=QColorDialog::getColor(QColor(255,255,255,255));
768
if(newColor.isValid()) setColor(newColor);
771
/******************************************/
772
//EnumWidget Implementation
773
/******************************************/
774
EnumWidget::EnumWidget(QWidget *p, int defaultEnum, QStringList values) {
775
Init(p,defaultEnum,values);
778
void EnumWidget::Init(QWidget *p, int defaultEnum, QStringList values)
537
void Point3fWidget::collectWidgetValue()
539
rp->val->set(Point3fValue(vcg::Point3f(coordSB[0]->text().toFloat(),coordSB[1]->text().toFloat(),coordSB[2]->text().toFloat())));
542
void Point3fWidget::resetWidgetValue()
544
for(unsigned int ii = 0; ii < 3;++ii)
545
coordSB[ii]->setText(QString::number(rp->pd->defVal->getPoint3f()[ii],'g',3));
552
ComboWidget::ComboWidget(QWidget *p, RichParameter* rpar) :MeshLabWidget(p,rpar) {
555
void ComboWidget::Init(QWidget *p,int defaultEnum, QStringList values)
780
557
enumLabel = new QLabel(p);
558
enumLabel->setText(rp->pd->fieldDesc);
781
559
enumCombo = new QComboBox(p);
782
560
enumCombo->addItems(values);
783
setEnum(defaultEnum);
784
this->addWidget(enumLabel);
785
this->addWidget(enumCombo);
788
int EnumWidget::getEnum()
561
setIndex(defaultEnum);
562
int row = gridLay->rowCount() - 1;
563
gridLay->addWidget(enumLabel,row,0,Qt::AlignTop);
564
gridLay->addWidget(enumCombo,row,1,Qt::AlignTop);
565
connect(enumCombo,SIGNAL(activated(int)),this,SIGNAL(dialogParamChanged()));
566
connect(this,SIGNAL(dialogParamChanged()),p,SIGNAL(parameterChanged()));
569
void ComboWidget::setIndex(int newEnum)
571
enumCombo->setCurrentIndex(newEnum);
574
int ComboWidget::getIndex()
790
576
return enumCombo->currentIndex();
793
void EnumWidget::setEnum(int newEnum)
795
enumCombo->setCurrentIndex(newEnum);
579
ComboWidget::~ComboWidget()
585
/******************************************/
586
//EnumWidget Implementation
587
/******************************************/
589
EnumWidget::EnumWidget(QWidget *p, RichEnum* rpar)
592
//you MUST call it!!!!
593
Init(p,rpar->pd->defVal->getEnum(),reinterpret_cast<EnumDecoration*>(rpar->pd)->enumvalues);
594
//assert(enumCombo != NULL);
798
597
int EnumWidget::getSize()
859
GenericParamDialog::~GenericParamDialog()
1028
864
/******************************************/
1029
865
// DynamicFloatWidget Implementation
1030
866
/******************************************/
1031
DynamicFloatWidget::DynamicFloatWidget(QWidget *p, double defaultv, double _minVal, double _maxVal, int _mask):QGridLayout(NULL)
870
DynamicFloatWidget::DynamicFloatWidget(QWidget *p, RichDynamicFloat* rdf):MeshLabWidget(p,rdf)
872
minVal = reinterpret_cast<DynamicFloatDecoration*>(rdf->pd)->min;
873
maxVal = reinterpret_cast<DynamicFloatDecoration*>(rdf->pd)->max;
1036
874
valueLE = new QLineEdit(p);
1037
875
valueSlider = new QSlider(Qt::Horizontal,p);
876
fieldDesc = new QLabel(rp->pd->fieldDesc);
1039
877
valueSlider->setMinimum(0);
1040
878
valueSlider->setMaximum(100);
1041
valueSlider->setValue(floatToInt(defaultv));
1042
valueLE->setValidator(new QDoubleValidator (minVal, maxVal, 5, valueLE));
1043
valueLE->setText(QString::number(defaultv));
879
valueSlider->setValue(floatToInt(rp->pd->defVal->getFloat()));
880
const DynamicFloatDecoration* dfd = reinterpret_cast<const DynamicFloatDecoration*>(&(rp->pd));
881
valueLE->setValidator(new QDoubleValidator (dfd->min,dfd->max, 5, valueLE));
882
valueLE->setText(QString::number(rp->pd->defVal->getFloat()));
1045
this->addWidget(valueLE,0,0,Qt::AlignHCenter);
1046
this->addWidget(valueSlider,0,1,Qt::AlignHCenter);
885
int row = gridLay->rowCount() - 1;
886
gridLay->addWidget(fieldDesc,row,0,Qt::AlignTop);
888
QHBoxLayout* lay = new QHBoxLayout(p);
889
lay->addWidget(valueLE,0,Qt::AlignHCenter);
890
lay->addWidget(valueSlider,0,Qt::AlignHCenter);
891
gridLay->addLayout(lay,row,1,Qt::AlignTop);
1048
893
connect(valueLE,SIGNAL(textChanged(const QString &)),this,SLOT(setValue()));
1049
894
connect(valueSlider,SIGNAL(valueChanged(int)),this,SLOT(setValue(int)));
895
connect(this,SIGNAL(dialogParamChanged()),p,SIGNAL(parameterChanged()));
1052
899
DynamicFloatWidget::~DynamicFloatWidget()
1088
936
return int (100.0f*(val-minVal)/(maxVal-minVal));
939
void DynamicFloatWidget::collectWidgetValue()
941
rp->val->set(DynamicFloatValue(valueLE->text().toFloat()));
944
void DynamicFloatWidget::resetWidgetValue()
946
valueLE->setText(QString::number(rp->pd->defVal->getFloat()));
949
/****************************/
950
Value& MeshLabWidget::getWidgetValue()
952
collectWidgetValue();
957
void MeshLabWidget::resetValue()
959
rp->val->set(*rp->pd->defVal);
963
MeshLabWidget::MeshLabWidget( QWidget* p,RichParameter* rpar )
968
helpLab = new QLabel("<small>"+rpar->pd->tooltip +"</small>",p);
969
helpLab->setTextFormat(Qt::RichText);
970
helpLab->setWordWrap(true);
971
helpLab->setVisible(false);
972
helpLab->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
973
helpLab->setMinimumWidth(250);
974
helpLab->setMaximumWidth(QWIDGETSIZE_MAX);
975
gridLay = qobject_cast<QGridLayout*>(p->layout());
976
assert(gridLay != 0);
977
int row = gridLay->rowCount();
978
gridLay->addWidget(helpLab,row,3,1,1,Qt::AlignTop);
982
void MeshLabWidget::InitRichParameter(RichParameter* rpar)
987
MeshLabWidget::~MeshLabWidget()
993
//connect(qcb,SIGNAL(stateChanged(int)),this,SIGNAL(parameterChanged()));
994
BoolWidget::BoolWidget( QWidget* p,RichBool* rb )
997
cb = new QCheckBox(rp->pd->fieldDesc,p);
998
cb->setToolTip(rp->pd->tooltip);
999
cb->setChecked(rp->pd->defVal->getBool());
1001
//gridlay->addWidget(this,i,0,1,1,Qt::AlignTop);
1003
int row = gridLay->rowCount() -1 ;
1004
gridLay->addWidget(cb,row,0,1,2,Qt::AlignTop);
1005
connect(cb,SIGNAL(stateChanged(int)),p,SIGNAL(parameterChanged()));
1009
void BoolWidget::collectWidgetValue()
1011
rp->val->set(BoolValue(cb->isChecked()));
1014
void BoolWidget::resetWidgetValue()
1016
cb->setChecked(rp->val->getBool());
1019
BoolWidget::~BoolWidget()
1024
//connect(qle,SIGNAL(editingFinished()),this,SIGNAL(parameterChanged()));
1025
LineEditWidget::LineEditWidget( QWidget* p,RichParameter* rpar )
1026
:MeshLabWidget(p,rpar)
1028
lab = new QLabel(rp->pd->fieldDesc,this);
1029
lned = new QLineEdit(this);
1030
int row = gridLay->rowCount() -1;
1032
lab->setToolTip(rp->pd->tooltip);
1033
gridLay->addWidget(lab,row,0,Qt::AlignTop);
1034
gridLay->addWidget(lned,row,1,Qt::AlignTop);
1035
connect(lned,SIGNAL(editingFinished()),p,SIGNAL(parameterChanged()));
1038
LineEditWidget::~LineEditWidget()
1043
IntWidget::IntWidget( QWidget* p,RichInt* rpar )
1044
:LineEditWidget(p,rpar)
1046
lned->setText(QString::number(rp->pd->defVal->getInt()));
1049
void IntWidget::collectWidgetValue()
1051
rp->val->set(IntValue(lned->text().toInt()));
1054
void IntWidget::resetWidgetValue()
1056
lned->setText(QString::number(rp->val->getInt()));
1060
FloatWidget::FloatWidget( QWidget* p,RichFloat* rpar )
1061
:LineEditWidget(p,rpar)
1063
lned->setText(QString::number(rp->pd->defVal->getFloat(),'g',3));
1066
void FloatWidget::collectWidgetValue()
1068
rp->val->set(FloatValue(lned->text().toFloat()));
1071
void FloatWidget::resetWidgetValue()
1073
lned->setText(QString::number(rp->val->getFloat(),'g',3));
1077
StringWidget::StringWidget( QWidget* p,RichString* rpar )
1078
:LineEditWidget(p,rpar)
1080
lned->setText(rp->pd->defVal->getString());
1083
void StringWidget::collectWidgetValue()
1085
rp->val->set(StringValue(lned->text()));
1088
void StringWidget::resetWidgetValue()
1090
lned->setText(rp->val->getString());
1094
//Matrix44fWidget::Matrix44fWidget( QWidget* p,RichMatrix44f* rpar )
1095
//:MeshLabWidget(p,rb)
1099
//void Matrix44fWidget::collectWidgetValue()
1103
//void Matrix44fWidget::resetWidgetValue()
1109
FloatListWidget::FloatListWidget( QWidget* p,RichMesh* rpar )
1110
:MeshLabWidget(p,rb)
1115
void FloatListWidget::collectWidgetValue()
1119
void FloatListWidget::resetWidgetValue()
1123
OpenFileWidget::OpenFileWidget( QWidget* p,RichMesh* rpar )
1124
:MeshLabWidget(p,rb)
1128
void OpenFileWidget::collectWidgetValue()
1132
void OpenFileWidget::resetWidgetValue()
1137
SaveFileWidget::SaveFileWidget( QWidget* p,RichSaveFile* rpar )
1138
:MeshLabWidget(p,rpar)
1143
void SaveFileWidget::collectWidgetValue()
1147
void SaveFileWidget::resetWidgetValue()
1152
ql = new QLabel(fpi.fieldDesc,this);
1153
ql->setToolTip(fpi.fieldToolTip);
1155
qcbt = new QColorButton(this,QColor(fpi.fieldVal.toUInt()));
1156
gridLayout->addWidget(ql,i,0,Qt::AlignTop);
1157
gridLayout->addLayout(qcbt,i,1,Qt::AlignTop);
1159
stdfieldwidgets.push_back(qcbt);
1160
connect(qcbt,SIGNAL(dialogParamChanged()),this,SIGNAL(parameterChanged()));
1163
/******************************************/
1164
// ColorWidget Implementation
1165
/******************************************/
1168
ColorWidget::ColorWidget(QWidget *p, RichColor* newColor)
1169
:MeshLabWidget(p,newColor),pickcol()
1172
colorLabel = new QLabel(p);
1173
descLabel = new QLabel(rp->pd->fieldDesc,p);
1174
colorButton = new QPushButton(p);
1175
colorButton->setAutoFillBackground(true);
1176
colorButton->setFlat(true);
1177
//const QColor cl = rp->pd->defVal->getColor();
1179
int row = gridLay->rowCount() - 1;
1180
gridLay->addWidget(descLabel,row,0,Qt::AlignTop);
1182
QHBoxLayout* lay = new QHBoxLayout(p);
1183
lay->addWidget(colorLabel);
1184
lay->addWidget(colorButton);
1186
gridLay->addLayout(lay,row,1,Qt::AlignTop);
1187
pickcol = rp->pd->defVal->getColor();
1188
connect(colorButton,SIGNAL(clicked()),this,SLOT(pickColor()));
1189
connect(this,SIGNAL(dialogParamChanged()),p,SIGNAL(parameterChanged()));
1192
void ColorWidget::updateColorInfo(const ColorValue& newColor)
1194
QColor col = newColor.getColor();
1195
colorLabel->setText("("+col.name()+")");
1196
QPalette palette(col);
1197
colorButton->setPalette(palette);
1200
void ColorWidget::pickColor()
1202
pickcol =QColorDialog::getColor(pickcol);
1203
if(pickcol.isValid())
1205
collectWidgetValue();
1206
updateColorInfo(ColorValue(pickcol));
1208
emit dialogParamChanged();
1211
void ColorWidget::resetWidgetValue()
1213
QColor cl = rp->pd->defVal->getColor();
1215
updateColorInfo(cl);
1218
void ColorWidget::collectWidgetValue()
1220
rp->val->set(ColorValue(pickcol));
1223
ColorWidget::~ColorWidget()
1231
void GetFileNameWidget::launchGetFileNameDialog()