From 78cdeeffe6534358962c606576b22356b0ee847b Mon Sep 17 00:00:00 2001 From: Guido Ranzuglia granzuglia Date: Wed, 12 Sep 2012 08:41:58 +0000 Subject: [PATCH] optionCustom dialog and DecoratorParamsTreeWidget have now a consistent behaviour --- src/meshlab/customDialog.cpp | 11 +++++++++-- src/meshlab/layerDialog.cpp | 32 +++++++++++++++++++------------- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/src/meshlab/customDialog.cpp b/src/meshlab/customDialog.cpp index 41ccbf005..e2bac4a93 100644 --- a/src/meshlab/customDialog.cpp +++ b/src/meshlab/customDialog.cpp @@ -105,7 +105,14 @@ void CustomDialog::updateSettings() /*emit tw->horizontalHeader()->sectionAutoResize( 0,QHeaderView::ResizeToContents); emit tw->horizontalHeader()->sectionAutoResize( 1,QHeaderView::ResizeToContents);*/ } + //Maybe a MeshDocument parameter is needed. See loadFrameContent definition + +/*WARNING!*******************************************************/ +//In defPar->defVal the hardwired value is memorized +//in curPar->defVal the one in the sys reg +/****************************************************************/ + SettingDialog::SettingDialog( RichParameter* currentPar, RichParameter* defaultPar, QWidget* parent /*= 0*/ ) :QDialog(parent),frame(this),curPar(currentPar),defPar(defaultPar),tmppar(NULL) { @@ -150,7 +157,7 @@ void SettingDialog::save() qDebug("Writing into Settings param with name %s and content ****%s****",qPrintable(tmppar->name),qPrintable(docstring)); QSettings setting; setting.setValue(tmppar->name,QVariant(docstring)); - tmppar->pd->defVal->set(*tmppar->val); + curPar->pd->defVal->set(*tmppar->val); } void SettingDialog::apply() @@ -173,7 +180,7 @@ void SettingDialog::reset() void SettingDialog::load() { assert(frame.stdfieldwidgets.size() == 1); - frame.stdfieldwidgets.at(0)->resetValue(); + frame.stdfieldwidgets.at(0)->setWidgetValue(*(curPar->pd->defVal)); } SettingDialog::~SettingDialog() diff --git a/src/meshlab/layerDialog.cpp b/src/meshlab/layerDialog.cpp index 700ed60fa..eafca45f6 100644 --- a/src/meshlab/layerDialog.cpp +++ b/src/meshlab/layerDialog.cpp @@ -603,9 +603,15 @@ DecoratorParamsTreeWidget::DecoratorParamsTreeWidget(QAction* act,MainWindow *mw decPlug->initGlobalParameterSet(act,tmpSet); if (tmpSet.paramList.size() != 0) { + const RichParameterSet& currSet = mw->currentGlobalPars(); + + /********************************************************************************************************************/ + //WARNING! The hardwired original value is maintained in the defValue contained inside the tmpSet's parameters + //the register system saved value instead is in the defValues of the params inside the current globalParameters set + /********************************************************************************************************************/ + for(int jj = 0;jj < tmpSet.paramList.size();++jj) { - RichParameterSet currSet = mw->currentGlobalPars(); RichParameter* par = currSet.findParameter(tmpSet.paramList[jj]->name); tmpSet.setValue(tmpSet.paramList[jj]->name,*(par->val)); } @@ -622,7 +628,6 @@ DecoratorParamsTreeWidget::DecoratorParamsTreeWidget(QAction* act,MainWindow *mw dialoglayout->addWidget(loadbut,countel,2); dialoglayout->addWidget(frame,0,0,countel,3); this->setLayout(dialoglayout); - int si = dialoglayout->rowCount(); connect(frame,SIGNAL(parameterChanged()),this,SLOT(apply())); connect(resetbut,SIGNAL(clicked()),this,SLOT(reset())); connect(savebut,SIGNAL(clicked()),this,SLOT(save())); @@ -656,20 +661,16 @@ void DecoratorParamsTreeWidget::save() qDebug("Writing into Settings param with name %s and content ****%s****",qPrintable(p->name),qPrintable(docstring)); QSettings setting; setting.setValue(p->name,QVariant(docstring)); - p->pd->defVal->set(*p->val); + RichParameterSet& currSet = mainWin->currentGlobalPars(); + RichParameter* par = currSet.findParameter(tmpSet.paramList[ii]->name); + par->pd->defVal->set(*(tmpSet.paramList[ii]->val)); } } void DecoratorParamsTreeWidget::reset() { - //qDebug("resetting the value of param %s to the hardwired default",qPrintable(curPar->name)); - for(int ii = 0;ii < tmpSet.paramList.size();++ii) - { - const RichParameter& defPar = *(mainWin->currentGlobalPars().findParameter(tmpSet.paramList[ii]->name)); - tmpSet.paramList[ii]->val->set(*(defPar.val)); - frame->stdfieldwidgets.at(ii)->setWidgetValue(*(tmpSet.paramList[ii]->val)); - } - apply(); + for(int ii = 0;ii < frame->stdfieldwidgets.size();++ii) + frame->stdfieldwidgets[ii]->resetValue(); } void DecoratorParamsTreeWidget::apply() @@ -688,6 +689,11 @@ void DecoratorParamsTreeWidget::apply() void DecoratorParamsTreeWidget::load() { - for(int ii = 0;ii < frame->stdfieldwidgets.size();++ii) - frame->stdfieldwidgets[ii]->resetValue(); + for(int ii = 0;ii < tmpSet.paramList.size();++ii) + { + const RichParameter& defPar = *(mainWin->currentGlobalPars().findParameter(tmpSet.paramList[ii]->name)); + tmpSet.paramList[ii]->val->set(*(defPar.pd->defVal)); + frame->stdfieldwidgets.at(ii)->setWidgetValue(*(tmpSet.paramList[ii]->val)); + } + apply(); }