lot of constness, everything seems to work

This commit is contained in:
alemuntoni 2020-08-02 20:14:35 +02:00
parent a1a326e536
commit f67548bbc2
30 changed files with 196 additions and 166 deletions

View File

@ -49,9 +49,11 @@ const QString& RichParameter::toolTip() const
return tooltip;
}
Value& RichParameter::value()
void RichParameter::setValue(const Value& ov)
{
return *val;
assert(val->typeName() == ov.typeName());
delete val;
val = ov.clone();
}
QDomElement RichParameter::fillToXMLDocument(QDomDocument& doc, bool saveDescriptionAndTooltip) const
@ -366,9 +368,9 @@ QString RichAbsPerc::stringType() const
return "RichAbsPerc";
}
QDomElement RichAbsPerc::fillToXMLDocument(QDomDocument& doc) const
QDomElement RichAbsPerc::fillToXMLDocument(QDomDocument& doc, bool saveDescriptionAndTooltip) const
{
QDomElement parElem = RichParameter::fillToXMLDocument(doc);
QDomElement parElem = RichParameter::fillToXMLDocument(doc, saveDescriptionAndTooltip);
parElem.setAttribute("min",QString::number(min));
parElem.setAttribute("max",QString::number(max));
return parElem;
@ -405,9 +407,9 @@ QString RichEnum::stringType() const
return "RichEnum";
}
QDomElement RichEnum::fillToXMLDocument(QDomDocument& doc) const
QDomElement RichEnum::fillToXMLDocument(QDomDocument& doc, bool saveDescriptionAndTooltip) const
{
QDomElement parElem = RichParameter::fillToXMLDocument(doc);
QDomElement parElem = RichParameter::fillToXMLDocument(doc, saveDescriptionAndTooltip);
parElem.setAttribute("enum_cardinality", enumvalues.size());
for(int ii = 0; ii < enumvalues.size(); ++ii)
parElem.setAttribute(QString("enum_val")+QString::number(ii), enumvalues.at(ii));
@ -446,9 +448,9 @@ QString RichDynamicFloat::stringType() const
return "RichDynamicFloat";
}
QDomElement RichDynamicFloat::fillToXMLDocument(QDomDocument& doc) const
QDomElement RichDynamicFloat::fillToXMLDocument(QDomDocument& doc, bool saveDescriptionAndTooltip) const
{
QDomElement parElem = RichParameter::fillToXMLDocument(doc);
QDomElement parElem = RichParameter::fillToXMLDocument(doc, saveDescriptionAndTooltip);
parElem.setAttribute("min",QString::number(min));
parElem.setAttribute("max",QString::number(max));
return parElem;
@ -485,9 +487,9 @@ QString RichOpenFile::stringType() const
return "RichOpenFile";
}
QDomElement RichOpenFile::fillToXMLDocument(QDomDocument& doc) const
QDomElement RichOpenFile::fillToXMLDocument(QDomDocument& doc, bool saveDescriptionAndTooltip) const
{
QDomElement parElem = RichParameter::fillToXMLDocument(doc);
QDomElement parElem = RichParameter::fillToXMLDocument(doc, saveDescriptionAndTooltip);
parElem.setAttribute("exts_cardinality", exts.size());
for(int ii = 0; ii < exts.size(); ++ii)
parElem.setAttribute(QString("ext_val")+QString::number(ii), exts[ii]);
@ -525,9 +527,9 @@ QString RichSaveFile::stringType() const
return "RichSaveFile";
}
QDomElement RichSaveFile::fillToXMLDocument(QDomDocument& doc) const
QDomElement RichSaveFile::fillToXMLDocument(QDomDocument& doc, bool saveDescriptionAndTooltip) const
{
QDomElement parElem = RichParameter::fillToXMLDocument(doc);
QDomElement parElem = RichParameter::fillToXMLDocument(doc, saveDescriptionAndTooltip);
parElem.setAttribute("ext", ext);
return parElem;
}

View File

@ -41,9 +41,10 @@ public:
const Value& value() const;
const QString& fieldDescription() const;
const QString& toolTip() const;
Value& value();
virtual QString stringType() const = 0;
void setValue(const Value& ov);
virtual QDomElement fillToXMLDocument(QDomDocument& doc, bool saveDescriptionAndTooltip = true) const;
virtual RichParameter* clone() const = 0;
@ -164,7 +165,7 @@ public:
~RichAbsPerc();
QString stringType() const;
QDomElement fillToXMLDocument(QDomDocument& doc) const;
QDomElement fillToXMLDocument(QDomDocument& doc, bool saveDescriptionAndTooltip = true) const;
RichAbsPerc* clone() const;
bool operator==(const RichParameter& rb);
@ -179,7 +180,7 @@ public:
~RichEnum();
QString stringType() const;
QDomElement fillToXMLDocument(QDomDocument& doc) const;
QDomElement fillToXMLDocument(QDomDocument& doc, bool saveDescriptionAndTooltip = true) const;
RichEnum* clone() const;
bool operator==(const RichParameter& rb);
@ -193,7 +194,7 @@ public:
~RichDynamicFloat();
QString stringType() const;
QDomElement fillToXMLDocument(QDomDocument& doc) const;
QDomElement fillToXMLDocument(QDomDocument& doc, bool saveDescriptionAndTooltip = true) const;
RichDynamicFloat* clone() const;
bool operator==(const RichParameter& rb);
@ -208,7 +209,7 @@ public:
~RichOpenFile();
QString stringType() const;
QDomElement fillToXMLDocument(QDomDocument& doc) const;
QDomElement fillToXMLDocument(QDomDocument& doc, bool saveDescriptionAndTooltip = true) const;
RichOpenFile* clone() const;
bool operator==(const RichParameter& rb);
@ -222,7 +223,7 @@ public:
~RichSaveFile();
QString stringType() const;
QDomElement fillToXMLDocument(QDomDocument& doc) const;
QDomElement fillToXMLDocument(QDomDocument& doc, bool saveDescriptionAndTooltip = true) const;
RichSaveFile* clone() const;
bool operator==(const RichParameter& rb);

View File

@ -168,9 +168,28 @@ const RichParameter* RichParameterList::findParameter(const QString& name) const
return nullptr;
}
RichParameter* RichParameterList::at(unsigned int i)
{
if (i >= size())
return nullptr;
const_iterator it = begin();
std::advance(it, i);
return *it;
}
const RichParameter* RichParameterList::at(unsigned int i) const
{
if (i >= size())
return nullptr;
const_iterator it = begin();
std::advance(it, i);
return *it;
}
void RichParameterList::setValue(const QString& name,const Value& newval)
{
findParameter(name)->value().set(newval);
assert(hasParameter(name));
findParameter(name)->setValue(newval);
}
RichParameter* RichParameterList::addParam(const RichParameter& pd )

View File

@ -62,6 +62,8 @@ public:
bool hasParameter(const QString& name) const;
RichParameter* findParameter(const QString& name);
const RichParameter* findParameter(const QString& name) const;
RichParameter* at(unsigned int i);
const RichParameter* at(unsigned int i) const;
void setValue(const QString& name, const Value& val);
RichParameter* addParam(const RichParameter& pd);

View File

@ -561,12 +561,12 @@ public:
virtual QString decorationInfo(QAction *a) const { return decorationInfo(ID(a)); }
virtual bool startDecorate(QAction *, MeshDocument &, RichParameterList *, GLArea *) { return false; }
virtual bool startDecorate(QAction *, MeshModel &, RichParameterList *, GLArea *) { return false; }
virtual void decorateMesh(QAction *, MeshModel &, RichParameterList *, GLArea *, QPainter *, GLLogStream &) = 0;
virtual void decorateDoc(QAction *, MeshDocument &, RichParameterList *, GLArea *, QPainter *, GLLogStream &) = 0;
virtual void endDecorate(QAction *, MeshModel &, RichParameterList *, GLArea *) {}
virtual void endDecorate(QAction *, MeshDocument &, RichParameterList *, GLArea *) {}
virtual bool startDecorate(QAction *, MeshDocument &, const RichParameterList *, GLArea *) { return false; }
virtual bool startDecorate(QAction *, MeshModel &, const RichParameterList *, GLArea *) { return false; }
virtual void decorateMesh(QAction *, MeshModel &, const RichParameterList *, GLArea *, QPainter *, GLLogStream &) = 0;
virtual void decorateDoc(QAction *, MeshDocument &, const RichParameterList *, GLArea *, QPainter *, GLLogStream &) = 0;
virtual void endDecorate(QAction *, MeshModel &, const RichParameterList *, GLArea *) {}
virtual void endDecorate(QAction *, MeshDocument &, const RichParameterList *, GLArea *) {}
/** \brief tests if a decoration is applicable to a mesh.
* used only for PerMesh Decorators.

View File

@ -228,7 +228,7 @@ void FilterScriptDialog::editOldParameters( const int row )
RichParameterList::iterator j = oldParameterSet.begin();
//now set values to be the old values
for (; i != newParameterSet.end(); ++i, ++j){
(*i)->value().set((*j)->value());
(*i)->setValue((*j)->value());
}
} else
qDebug() << "the size of the given list is not the same as the filter suggests it should be. your filter script may be out of date, or there is a bug in the filter script class";

View File

@ -120,7 +120,7 @@ GLArea::GLArea(QWidget *parent, MultiViewer_Container *mvcont, RichParameterList
//connecting the MainWindow Slots to GLArea signal (simple passthrough)
if(mainwindow != NULL){
connect(this,SIGNAL(updateMainWindowMenus()),mainwindow,SLOT(updateMenus()));
connect(mainwindow,SIGNAL(dispatchCustomSettings(RichParameterList&)),this,SLOT(updateCustomSettingValues(RichParameterList&)));
connect(mainwindow,SIGNAL(dispatchCustomSettings(const RichParameterList&)),this,SLOT(updateCustomSettingValues(const RichParameterList&)));
}else{
qDebug("The parent of the GLArea parent is not a pointer to the meshlab MainWindow.");
}
@ -1752,7 +1752,7 @@ Point3f GLArea::getViewDir()
return vcg::Inverse(rotM)*vcg::Point3f(0,0,1);
}
void GLArea::updateCustomSettingValues( RichParameterList& rps )
void GLArea::updateCustomSettingValues( const RichParameterList& rps )
{
makeCurrent();
glas.updateGlobalParameterSet(rps);

View File

@ -223,7 +223,7 @@ public slots:
void setColorMode(RenderMode& rm,vcg::GLW::ColorMode mode);
void setTextureMode(vcg::GLW::TextureMode mode);
void setTextureMode(RenderMode& rm,vcg::GLW::TextureMode mode);*/
void updateCustomSettingValues(RichParameterList& rps);
void updateCustomSettingValues(const RichParameterList& rps);
void endEdit()
{

View File

@ -28,7 +28,7 @@ void GLAreaSetting::initGlobalParameterSet( RichParameterList * defaultGlobalPar
}
void GLAreaSetting::updateGlobalParameterSet( RichParameterList& rps )
void GLAreaSetting::updateGlobalParameterSet( const RichParameterList& rps )
{
logAreaColor = rps.getColor4b(logAreaColorParam());
backgroundBotColor = rps.getColor4b(backgroundBotColorParam());

View File

@ -70,10 +70,10 @@ public:
inline static QString wheelDirectionParam() {return "MeshLab::Appearance::wheelDirection";}
void updateGlobalParameterSet( RichParameterList& rps );
void updateGlobalParameterSet(const RichParameterList& rps );
static void initGlobalParameterSet( RichParameterList * defaultGlobalParamSet);
RichParameterList *currentGlobalParamSet;
const RichParameterList *currentGlobalParamSet;
};

View File

@ -1302,7 +1302,7 @@ void DecoratorParamsTreeWidget::save()
setting.setValue(p->name(),QVariant(docstring));
RichParameterList& currSet = mainWin->currentGlobalPars();
RichParameter* par = currSet.findParameter(p->name());
par->value().set(p->value());
par->setValue(p->value());
}
}
@ -1333,7 +1333,7 @@ void DecoratorParamsTreeWidget::load()
for(RichParameter* p : tmpSet)
{
const RichParameter& defPar = *(mainWin->currentGlobalPars().findParameter(p->name()));
p->value().set(defPar.value());
p->setValue(defPar.value());
frame->stdfieldwidgets.at(ii++)->setWidgetValue(p->value());
}
apply();

View File

@ -65,7 +65,7 @@ class MainWindowSetting
{
public:
static void initGlobalParameterSet(RichParameterList* gblset);
void updateGlobalParameterSet( RichParameterList& rps );
void updateGlobalParameterSet(const RichParameterList& rps );
std::ptrdiff_t maxgpumem;
inline static QString maximumDedicatedGPUMem() {return "MeshLab::System::maxGPUMemDedicatedToGeometry";}
@ -101,7 +101,7 @@ public:
//const QString appVer() const {return tr("1.3.2"); }
MainWindowSetting mwsettings;
signals:
void dispatchCustomSettings(RichParameterList& rps);
void dispatchCustomSettings(const RichParameterList& rps);
void filterExecuted();
void updateLayerTable();

View File

@ -898,7 +898,6 @@ void MainWindow::loadMeshLabSettings()
}
}
//emit dispatchCustomSettings(currentGlobalParams);
}
void MainWindow::addToMenu(QList<QAction *> actionList, QMenu *menu, const char *slot)
@ -1171,12 +1170,11 @@ void MainWindowSetting::initGlobalParameterSet(RichParameterList* glbset)
glbset->addParam(RichInt(maxTextureMemoryParam(), 256, "Max Texture Memory (in MB)", "The maximum quantity of texture memory allowed to load mesh textures"));
}
void MainWindowSetting::updateGlobalParameterSet(RichParameterList& rps)
void MainWindowSetting::updateGlobalParameterSet(const RichParameterList& rps)
{
maxgpumem = (std::ptrdiff_t)rps.getInt(maximumDedicatedGPUMem()) * (float)(1024 * 1024);
perbatchprimitives = (size_t)rps.getInt(perBatchPrimitives());
minpolygonpersmoothrendering = (size_t)rps.getInt(minPolygonNumberPerSmoothRendering());
// permeshtoolbar = rps.getBool(perMeshRenderingToolBar());
highprecision = false;
if (MeshLabScalarTest<Scalarm>::doublePrecision())
highprecision = rps.getBool(highPrecisionRendering());

View File

@ -2687,7 +2687,7 @@ void MainWindow::showLayerDlg(bool visible)
void MainWindow::setCustomize()
{
MeshLabSettingsDialog dialog(currentGlobalParams,defaultGlobalParams, this);
connect(&dialog,SIGNAL(applyCustomSetting()),this,SLOT(updateCustomSettings()));
connect(&dialog, SIGNAL(applyCustomSetting()), this, SLOT(updateCustomSettings()));
dialog.exec();
}

View File

@ -30,12 +30,16 @@
using namespace vcg;
MeshLabSettingsDialog::MeshLabSettingsDialog(RichParameterList& curparset, RichParameterList& defparset, QWidget * parent)
:QDialog(parent),curParSet(curparset),defParSet(defparset)
MeshLabSettingsDialog::MeshLabSettingsDialog(
RichParameterList& curparset,
const RichParameterList& defparset,
QWidget * parent) :
QDialog(parent),
curParSet(curparset),
defParSet(defparset)
{
setModal(false);
closebut = new QPushButton("Close",this);
//QVBoxLayout* layout = new QVBoxLayout(parent);
QGridLayout* layout = new QGridLayout(parent);
setLayout(layout);
tw = new QTableWidget(curParSet.size(),2,this);
@ -44,18 +48,24 @@ MeshLabSettingsDialog::MeshLabSettingsDialog(RichParameterList& curparset, RichP
setMinimumWidth(totlen);
layout->addWidget(tw,0,0,1,5);
layout->addWidget(closebut,1,4,1,1);
connect(tw,SIGNAL(itemDoubleClicked(QTableWidgetItem* )),this,SLOT(openSubDialog(QTableWidgetItem*)));
connect(closebut,SIGNAL(clicked()),this,SLOT(close()));
connect(tw, SIGNAL(itemDoubleClicked(QTableWidgetItem* )), this, SLOT(openSubDialog(QTableWidgetItem*)));
connect(closebut, SIGNAL(clicked()), this, SLOT(close()));
this->setWindowTitle(tr("Global Parameters Window"));
}
void MeshLabSettingsDialog::openSubDialog( QTableWidgetItem* itm )
/**
* @brief This slot is executed when a setting is double clicked
* @param itm
*/
void MeshLabSettingsDialog::openSubDialog(QTableWidgetItem* itm)
{
int rprow = tw->row(itm);
RichParameter *defPar = defParSet.findParameter(vrp[rprow]->name());
SettingDialog* setdial = new SettingDialog(vrp[rprow],defPar,this);
connect(setdial,SIGNAL(applySettingSignal()),this,SIGNAL(applyCustomSetting()));
connect(setdial,SIGNAL(applySettingSignal()),this,SLOT(updateSettings()));
const RichParameter *defPar = defParSet.at(rprow);
RichParameter* curPar = curParSet.at(rprow);
SettingDialog* setdial = new SettingDialog(*curPar,*defPar,this);
connect(
setdial, SIGNAL(applySettingSignal(const RichParameter&)),
this, SLOT(updateSingleSetting(const RichParameter&)));
setdial->exec();
delete setdial;
}
@ -72,41 +82,32 @@ void MeshLabSettingsDialog::updateSettings()
tw->setHorizontalHeaderLabels(slst);
tw->horizontalHeader()->setStretchLastSection(true);
tw->setShowGrid(true);
//tw->setWordWrap(false);
tw->verticalHeader()->hide();
tw->setSelectionBehavior(QAbstractItemView::SelectRows);
//tw->horizontalHeader()->setResizeMode(tw->columnCount() - 1, QHeaderView::Stretch);
//int sz = tw->font().pointSize();
int ii = 0;
for(RichParameter* p : curParSet)
{
for(RichParameter* p : curParSet) {
QTableWidgetItem* item = new QTableWidgetItem(p->name());
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled |Qt::ItemIsDropEnabled |Qt::ItemIsUserCheckable |Qt::ItemIsEnabled);
//if (maxlen[0] < item->text().size() * sz)
// maxlen[0] = item->text().size() * sz;
//item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
tw->setItem(ii,0,item);
//butt = new QPushButton(richparset.paramList.at(ii)->name,this);
QTableWidgetItem* twi = createQTableWidgetItemFromRichParameter(*p);
twi->setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled |Qt::ItemIsDropEnabled |Qt::ItemIsUserCheckable |Qt::ItemIsEnabled);
tw->setItem(ii++,1,twi);
//if (maxlen[1] < twi->text().size() * sz)
// maxlen[1] = twi->text().size() * sz;
vrp.push_back(p);
}
tw->resizeColumnsToContents();
tw->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
//tw->setColumnWidth(0,tw->horizontalHeader()->width());
//tw->setColumnWidth(1,tw->horizontalHeader()->width());
}
/*emit tw->horizontalHeader()->sectionAutoResize( 0,QHeaderView::ResizeToContents);
emit tw->horizontalHeader()->sectionAutoResize( 1,QHeaderView::ResizeToContents);*/
void MeshLabSettingsDialog::updateSingleSetting(const RichParameter& rp)
{
RichParameter* p = curParSet.findParameter(rp.name());
assert(p->stringType() == rp.stringType());
curParSet.setValue(rp.name(), rp.value());
updateSettings();
emit applyCustomSetting();
}
QTableWidgetItem* MeshLabSettingsDialog::createQTableWidgetItemFromRichParameter(const RichParameter& pd)
@ -170,4 +171,5 @@ QTableWidgetItem* MeshLabSettingsDialog::createQTableWidgetItemFromRichParameter
assert(0);
return nullptr;
}
return nullptr;
}

View File

@ -33,21 +33,27 @@ class MeshLabSettingsDialog : public QDialog
{
Q_OBJECT
public:
MeshLabSettingsDialog(RichParameterList& parset,RichParameterList& defparset,QWidget *parent = 0);
MeshLabSettingsDialog(
RichParameterList& parset,
const RichParameterList& defparset,
QWidget *parent = 0);
~MeshLabSettingsDialog();
//void loadCurrentSetting(RichParameterSet& parset);
public slots:
void openSubDialog(QTableWidgetItem* itm);
void updateSettings();
signals:
void applyCustomSetting();
private slots:
void openSubDialog(QTableWidgetItem* itm);
void updateSingleSetting(const RichParameter& rp);
private:
void updateSettings();
RichParameterList& curParSet;
RichParameterList& defParSet;
const RichParameterList& defParSet;
QTableWidget* tw;
QVector<RichParameter*> vrp;
void dispatch(const RichParameter& par);
QPushButton* closebut;

View File

@ -54,15 +54,13 @@ void RichParameterListFrame::resetValues(RichParameterList &curParSet)
}
/* creates widgets for the standard parameters */
void RichParameterListFrame::loadFrameContent(RichParameterList &curParSet,MeshDocument * /*_mdPt*/ )
void RichParameterListFrame::loadFrameContent(const RichParameterList &curParSet, MeshDocument * /*_mdPt*/ )
{
if(layout()) delete layout();
if(layout())
delete layout();
QGridLayout* glay = new QGridLayout();
// QGridLayout *vlayout = new QGridLayout(this);
// vLayout->setAlignment(Qt::AlignTop);
int i = 0;
for(RichParameter* fpi : curParSet)
{
for(const RichParameter* fpi : curParSet) {
RichParameterWidget* wd = createWidgetFromRichParameter(this, *fpi, *fpi);
//vLayout->addWidget(wd,i,0,1,1,Qt::AlignTop);
stdfieldwidgets.push_back(wd);

View File

@ -50,7 +50,7 @@ class RichParameterListFrame : public QFrame
public:
RichParameterListFrame(QWidget *p, QWidget *gla=0);
void loadFrameContent(RichParameterList &curParSet,MeshDocument *mdPt = 0);
void loadFrameContent(const RichParameterList& curParSet, MeshDocument *mdPt = 0);
// The curParSet that is passed must be 'compatible' with the RichParameterSet that have been used to create the frame.
// This function updates the RichParameterSet used to create the frame AND fill also the passed <curParSet>

View File

@ -53,7 +53,7 @@ RichParameterWidget::~RichParameterWidget()
void RichParameterWidget::resetValue()
{
rp->value().set(defp->value());
rp->setValue(defp->value());
resetWidgetValue();
}
@ -64,6 +64,11 @@ const Value& RichParameterWidget::widgetValue()
return rp->value();
}
const RichParameter& RichParameterWidget::richParameter() const
{
return *rp;
}
QString RichParameterWidget::parameterName() const
{
return rp->name();
@ -97,7 +102,7 @@ BoolWidget::~BoolWidget()
void BoolWidget::collectWidgetValue()
{
rp->value().set(BoolValue(cb->isChecked()));
rp->setValue(BoolValue(cb->isChecked()));
}
void BoolWidget::resetWidgetValue()
@ -169,7 +174,7 @@ IntWidget::IntWidget( QWidget* p, const RichInt& rpar, const RichInt& rdef ) :
void IntWidget::collectWidgetValue()
{
rp->value().set(IntValue(lned->text().toInt()));
rp->setValue(IntValue(lned->text().toInt()));
}
void IntWidget::resetWidgetValue()
@ -194,7 +199,7 @@ FloatWidget::FloatWidget(QWidget* p, const RichFloat& rpar , const RichFloat& rd
void FloatWidget::collectWidgetValue()
{
rp->value().set(FloatValue(lned->text().toFloat()));
rp->setValue(FloatValue(lned->text().toFloat()));
}
void FloatWidget::resetWidgetValue()
@ -219,7 +224,7 @@ StringWidget::StringWidget(QWidget* p, const RichString& rpar , const RichString
void StringWidget::collectWidgetValue()
{
rp->value().set(StringValue(lned->text()));
rp->setValue(StringValue(lned->text()));
}
void StringWidget::resetWidgetValue()
@ -288,7 +293,7 @@ void ColorWidget::addWidgetToGridLayout( QGridLayout* lay,const int r )
void ColorWidget::collectWidgetValue()
{
rp->value().set(ColorValue(pickcol));
rp->setValue(ColorValue(pickcol));
}
void ColorWidget::resetWidgetValue()
@ -419,7 +424,7 @@ void AbsPercWidget::setValue(float val, float minV, float maxV)
void AbsPercWidget::collectWidgetValue()
{
rp->value().set(AbsPercValue(float(absSB->value())));
rp->setValue(AbsPercValue(float(absSB->value())));
}
void AbsPercWidget::resetWidgetValue()
@ -560,7 +565,7 @@ vcg::Point3f Point3fWidget::getValue()
void Point3fWidget::collectWidgetValue()
{
rp->value().set(Point3fValue(vcg::Point3f(coordSB[0]->text().toFloat(),coordSB[1]->text().toFloat(),coordSB[2]->text().toFloat())));
rp->setValue(Point3fValue(vcg::Point3f(coordSB[0]->text().toFloat(),coordSB[1]->text().toFloat(),coordSB[2]->text().toFloat())));
}
void Point3fWidget::resetWidgetValue()
@ -708,10 +713,10 @@ void Matrix44fWidget::collectWidgetValue()
if (!valid) {
vcg::Matrix44f tempM;
for (unsigned int i = 0; i < 16; ++i) tempM[i / 4][i % 4] = coordSB[i]->text().toFloat();
rp->value().set(Matrix44fValue(tempM));
rp->setValue(Matrix44fValue(tempM));
}
else
rp->value().set(Matrix44fValue(m));
rp->setValue(Matrix44fValue(m));
}
void Matrix44fWidget::resetWidgetValue()
@ -834,7 +839,7 @@ vcg::Shotf ShotfWidget::getValue()
void ShotfWidget::collectWidgetValue()
{
rp->value().set(ShotfValue(curShot));
rp->setValue(ShotfValue(curShot));
}
void ShotfWidget::resetWidgetValue()
@ -943,7 +948,7 @@ int DynamicFloatWidget::floatToInt(float val)
void DynamicFloatWidget::collectWidgetValue()
{
rp->value().set(DynamicFloatValue(valueLE->text().toFloat()));
rp->setValue(DynamicFloatValue(valueLE->text().toFloat()));
}
void DynamicFloatWidget::resetWidgetValue()
@ -1033,7 +1038,7 @@ int EnumWidget::getSize()
void EnumWidget::collectWidgetValue()
{
rp->value().set(EnumValue(enumCombo->currentIndex()));
rp->setValue(EnumValue(enumCombo->currentIndex()));
}
void EnumWidget::resetWidgetValue()
@ -1105,7 +1110,7 @@ void MeshWidget::collectWidgetValue()
//MeshDecoration* dec = reinterpret_cast<MeshDecoration*>(rp->pd);
RichMesh* rm = reinterpret_cast<RichMesh*>(rp);
rm->meshindex = enumCombo->currentIndex();
rp->value().set(MeshValue(md->meshList.at(rm->meshindex)));
rp->setValue(MeshValue(md->meshList.at(rm->meshindex)));
}
void MeshWidget::resetWidgetValue()
@ -1176,7 +1181,7 @@ IOFileWidget::~IOFileWidget()
void IOFileWidget::collectWidgetValue()
{
rp->value().set(FileValue(fl));
rp->setValue(FileValue(fl));
}
void IOFileWidget::resetWidgetValue()
@ -1232,7 +1237,7 @@ void SaveFileWidget::selectFile()
collectWidgetValue();
updateFileName(fl);
FileValue fileName(fl);
rp->value().set(fileName);
rp->setValue(fileName);
emit dialogParamChanged();
}
@ -1254,7 +1259,7 @@ void OpenFileWidget::selectFile()
collectWidgetValue();
updateFileName(fl);
FileValue fileName(fl);
rp->value().set(fileName);
rp->setValue(fileName);
emit dialogParamChanged();
}

View File

@ -56,6 +56,7 @@ public:
void resetValue();
// update the parameter with the current widget values and return it.
const Value& widgetValue();
const RichParameter& richParameter() const;
QString parameterName() const;

View File

@ -23,24 +23,22 @@
#include "settingdialog.h"
//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,
const RichParameter* defaultPar,
const RichParameter& currentPar,
const RichParameter& defaultPar,
QWidget* parent) :
QDialog(parent),
frame(this),
curPar(currentPar),
defPar(defaultPar),
tmppar(NULL)
curPar(currentPar.clone()),
defPar(defaultPar.clone())
{
tmpParSet = RichParameterList();
tmpParSet.addParam(*curPar);
frame.loadFrameContent(tmpParSet);
setModal(true);
//no need to delete these objects, thanks to qt's parent resource management
savebut = new QPushButton("Save",this);
resetbut = new QPushButton("Reset",this);
applybut = new QPushButton("Apply",this);
@ -55,9 +53,7 @@ SettingDialog::SettingDialog(
dialoglayout->addWidget(applybut,1,3);
dialoglayout->addWidget(closebut,1,4);
RichParameterList tmpParSet;
tmppar = tmpParSet.addParam(*curPar);
frame.loadFrameContent(tmpParSet);
dialoglayout->addWidget(&frame,0,0,1,5);
dialoglayout->setSizeConstraint(QLayout::SetFixedSize);
setLayout(dialoglayout);
@ -76,29 +72,29 @@ SettingDialog::~SettingDialog()
void SettingDialog::save()
{
apply();
const RichParameter& tmppar = frame.stdfieldwidgets.at(0)->richParameter();
QDomDocument doc("MeshLabSettings");
doc.appendChild(tmppar->fillToXMLDocument(doc));
doc.appendChild(tmppar.fillToXMLDocument(doc));
QString docstring = doc.toString();
qDebug("Writing into Settings param with name %s and content ****%s****", qUtf8Printable(tmppar->name()), qUtf8Printable(docstring));
qDebug("Writing into Settings param with name %s and content ****%s****", qUtf8Printable(tmppar.name()), qUtf8Printable(docstring));
QSettings setting;
setting.setValue(tmppar->name(),QVariant(docstring));
curPar->value().set(tmppar->value());
setting.setValue(tmppar.name(),QVariant(docstring));
curPar->setValue(tmppar.value());
}
void SettingDialog::apply()
{
assert(frame.stdfieldwidgets.size() == 1);
frame.stdfieldwidgets.at(0)->collectWidgetValue();
curPar->value().set(tmppar->value());
emit applySettingSignal();
curPar->setValue(frame.stdfieldwidgets.at(0)->widgetValue());
emit applySettingSignal(*curPar);
}
void SettingDialog::reset()
{
qDebug("resetting the value of param %s to the hardwired default", qUtf8Printable(curPar->name()));
tmppar->value().set(defPar->value());
assert(frame.stdfieldwidgets.size() == 1);
frame.stdfieldwidgets.at(0)->setWidgetValue(tmppar->value());
frame.stdfieldwidgets.at(0)->resetValue();
apply();
}

View File

@ -32,7 +32,7 @@ class SettingDialog : public QDialog
{
Q_OBJECT
public:
SettingDialog(RichParameter* curPar, const RichParameter* defPar,QWidget* parent = 0);
SettingDialog(const RichParameter& curPar, const RichParameter& defPar,QWidget* parent = 0);
~SettingDialog();
public slots:
void save();
@ -41,13 +41,13 @@ public slots:
void load();
signals:
void applySettingSignal();
void applySettingSignal(const RichParameter&);
private:
RichParameterList tmpParSet;
RichParameterListFrame frame;
RichParameter* curPar;
const RichParameter* defPar;
RichParameter* tmppar;
QPushButton* savebut;
QPushButton* applybut;
QPushButton* resetbut;

View File

@ -80,7 +80,7 @@ void DecorateBackgroundPlugin::initGlobalParameterSet(QAction *action, RichParam
}
}
bool DecorateBackgroundPlugin::startDecorate( QAction * action, MeshDocument &/*m*/, RichParameterList * parset, GLArea * gla)
bool DecorateBackgroundPlugin::startDecorate( QAction * action, MeshDocument &/*m*/, const RichParameterList * parset, GLArea * gla)
{
if (!GLExtensionsManager::initializeGLextensions_notThrowing()) {
return false;
@ -99,7 +99,7 @@ bool DecorateBackgroundPlugin::startDecorate( QAction * action, MeshDocument &/*
return true;
}
void DecorateBackgroundPlugin::decorateDoc(QAction *a, MeshDocument &m, RichParameterList * parset,GLArea * gla, QPainter *, GLLogStream &)
void DecorateBackgroundPlugin::decorateDoc(QAction *a, MeshDocument &m, const RichParameterList * parset,GLArea * gla, QPainter *, GLLogStream &)
{
static QString lastname("uninitialized");
switch(ID(a))

View File

@ -83,9 +83,9 @@ DecorateBackgroundPlugin()
QString cubemapFileName;
bool startDecorate(QAction * /*mode*/, MeshDocument &/*m*/, RichParameterList * /*parent*/ par, GLArea * /*parent*/);
void decorateDoc(QAction *a, MeshDocument &md, RichParameterList *, GLArea *gla, QPainter *, GLLogStream &_log);
void decorateMesh(QAction *, MeshModel &, RichParameterList *, GLArea *, QPainter *, GLLogStream &){}
bool startDecorate(QAction * /*mode*/, MeshDocument &/*m*/, const RichParameterList * /*parent*/ par, GLArea * /*parent*/);
void decorateDoc(QAction *a, MeshDocument &md, const RichParameterList *, GLArea *gla, QPainter *, GLLogStream &_log);
void decorateMesh(QAction *, MeshModel &, const RichParameterList *, GLArea *, QPainter *, GLLogStream &){}
void initGlobalParameterSet(QAction *, RichParameterList &/*globalparam*/);
int getDecorationClass(QAction * /*action*/) const { return MeshDecorateInterface::PerDocument; }

View File

@ -74,7 +74,7 @@ QString DecorateBasePlugin::decorationName(FilterIDType filter) const
return QString("error!");
}
void DecorateBasePlugin::decorateDoc(QAction *a, MeshDocument &md, RichParameterList *rm, GLArea *gla, QPainter *painter,GLLogStream &/*_log*/)
void DecorateBasePlugin::decorateDoc(QAction *a, MeshDocument &md, const RichParameterList *rm, GLArea *gla, QPainter *painter,GLLogStream &/*_log*/)
{
QFont qf;
@ -157,7 +157,7 @@ void DecorateBasePlugin::decorateDoc(QAction *a, MeshDocument &md, RichParameter
} // end switch
}
void DecorateBasePlugin::decorateMesh(QAction *a, MeshModel &m, RichParameterList *rm, GLArea *gla, QPainter *painter,GLLogStream &_log)
void DecorateBasePlugin::decorateMesh(QAction *a, MeshModel &m, const RichParameterList *rm, GLArea *gla, QPainter *painter,GLLogStream &_log)
{
this->setLog(&_log);
QFont qf;
@ -561,7 +561,7 @@ bool DecorateBasePlugin::isDecorationApplicable(QAction *action, const MeshModel
return true;
}
bool DecorateBasePlugin::startDecorate(QAction * action, MeshDocument &, RichParameterList *, GLArea *)
bool DecorateBasePlugin::startDecorate(QAction * action, MeshDocument &, const RichParameterList *, GLArea *)
{
switch(ID(action))
{
@ -578,7 +578,7 @@ bool DecorateBasePlugin::startDecorate(QAction * action, MeshDocument &, RichPar
}
void DecorateBasePlugin::endDecorate(QAction * action, MeshModel &m, RichParameterList *, GLArea *)
void DecorateBasePlugin::endDecorate(QAction * action, MeshModel &m, const RichParameterList *, GLArea *)
{
switch(ID(action))
{
@ -593,7 +593,7 @@ void DecorateBasePlugin::endDecorate(QAction * action, MeshModel &m, RichParamet
}
}
bool DecorateBasePlugin::startDecorate(QAction * action, MeshModel &m, RichParameterList *rm, GLArea *gla)
bool DecorateBasePlugin::startDecorate(QAction * action, MeshModel &m, const RichParameterList *rm, GLArea *gla)
{
switch(ID(action))
{
@ -815,7 +815,7 @@ void DecorateBasePlugin::DisplayCamera(QString who, Shotm &ls, int cameraSourceI
focal,ls.Intrinsics.PixelSizeMm[0],ls.Intrinsics.PixelSizeMm[1]);
}
void DecorateBasePlugin::DrawCamera(MeshModel *m, Shotm &ls, vcg::Color4b camcolor, Matrix44m &currtr, RichParameterList *rm, QPainter * /*painter*/, QFont /*qf*/)
void DecorateBasePlugin::DrawCamera(MeshModel *m, Shotm &ls, vcg::Color4b camcolor, Matrix44m &currtr, const RichParameterList *rm, QPainter * /*painter*/, QFont /*qf*/)
{
if(!ls.IsValid()) // no drawing if camera not valid
return;
@ -913,7 +913,7 @@ void DecorateBasePlugin::DrawCamera(MeshModel *m, Shotm &ls, vcg::Color4b camcol
glPopAttrib();
}
void DecorateBasePlugin::DrawColorHistogram(CHist &ch, GLArea *gla, QPainter *painter, RichParameterList *par, QFont qf)
void DecorateBasePlugin::DrawColorHistogram(CHist &ch, GLArea *gla, QPainter *painter, const RichParameterList *par, QFont qf)
{
glMatrixMode(GL_PROJECTION);
glPushMatrix();
@ -983,7 +983,7 @@ void DecorateBasePlugin::PlaceTexParam(int /*TexInd*/, int /*TexNum*/)
}
void DecorateBasePlugin::DrawTexParam(MeshModel &m, GLArea *gla, QPainter *painter, RichParameterList *rm, QFont qf)
void DecorateBasePlugin::DrawTexParam(MeshModel &m, GLArea *gla, QPainter *painter, const RichParameterList *rm, QFont qf)
{
if ((gla == NULL) && (gla->getSceneGLSharedContext() == NULL))
return;

View File

@ -100,21 +100,21 @@ public:
void DrawEdgeLabel(MeshModel &m, QPainter *gla);
void DrawFaceLabel(MeshModel &m, QPainter *gla);
void DisplayCamera(QString who, Shotm &ls, int cameraSourceId);
void DrawCamera(MeshModel *m, Shotm &ls, vcg::Color4b camcolor, Matrix44m &currtr, RichParameterList *rm, QPainter *painter, QFont qf);
void DrawCamera(MeshModel *m, Shotm &ls, vcg::Color4b camcolor, Matrix44m &currtr, const RichParameterList *rm, QPainter *painter, QFont qf);
void PlaceTexParam(int TexInd, int TexNum);
void DrawTexParam(MeshModel &m, GLArea *gla, QPainter *painter, RichParameterList *, QFont qf);
void DrawColorHistogram(CHist &ch, GLArea *gla, QPainter *painter, RichParameterList *, QFont qf);
void DrawTexParam(MeshModel &m, GLArea *gla, QPainter *painter, const RichParameterList*, QFont qf);
void DrawColorHistogram(CHist &ch, GLArea *gla, QPainter *painter, const RichParameterList*, QFont qf);
void DrawLineVector(std::vector<PointPC> &EV);
//void DrawTriVector(std::vector<PointPC> &EV);
//void DrawDotVector(std::vector<PointPC> &EV, float basesize=4.0);
void decorateDoc(QAction *a, MeshDocument &md, RichParameterList *, GLArea *gla, QPainter *painter, GLLogStream &_log);
void decorateMesh(QAction *a, MeshModel &md, RichParameterList *, GLArea *gla, QPainter *painter, GLLogStream &_log);
bool startDecorate(QAction * /*mode*/, MeshModel &/*m*/, RichParameterList *, GLArea * /*parent*/);
void endDecorate(QAction * /*mode*/, MeshModel &/*m*/, RichParameterList *, GLArea * /*parent*/);
bool startDecorate(QAction * /*mode*/, MeshDocument &/*m*/, RichParameterList *, GLArea * /*parent*/);
void decorateDoc(QAction *a, MeshDocument &md, const RichParameterList *, GLArea *gla, QPainter *painter, GLLogStream &_log);
void decorateMesh(QAction *a, MeshModel &md, const RichParameterList *, GLArea *gla, QPainter *painter, GLLogStream &_log);
bool startDecorate(QAction * /*mode*/, MeshModel &/*m*/, const RichParameterList *, GLArea * /*parent*/);
void endDecorate(QAction * /*mode*/, MeshModel &/*m*/, const RichParameterList *, GLArea * /*parent*/);
bool startDecorate(QAction * /*mode*/, MeshDocument &/*m*/, const RichParameterList *, GLArea * /*parent*/);
bool isDecorationApplicable(QAction *action, const MeshModel& m, QString &ErrorMessage) const;
int getDecorationClass(QAction * /*action*/) const;
void initGlobalParameterSet(QAction *, RichParameterList &/*globalparam*/);

View File

@ -231,8 +231,8 @@ void DecorateRasterProjPlugin::initGlobalParameterSet( QAction *act, RichParamet
}
void DecorateRasterProjPlugin::updateCurrentMesh( MeshDocument &m,
RichParameterList &par )
void DecorateRasterProjPlugin::updateCurrentMesh(MeshDocument &m,
const RichParameterList& par )
{
if( par.getBool("MeshLab::Decoration::ProjRasterOnAllMeshes") )
{
@ -522,7 +522,7 @@ bool DecorateRasterProjPlugin::initShaders(std::string &logs)
bool DecorateRasterProjPlugin::startDecorate( QAction *act,
MeshDocument & m,
RichParameterList * /*par*/,
const RichParameterList * /*par*/,
GLArea * /*gla*/ )
{
switch( ID(act) )
@ -569,7 +569,7 @@ bool DecorateRasterProjPlugin::startDecorate( QAction *act,
void DecorateRasterProjPlugin::endDecorate( QAction *act,
MeshDocument & /*m*/,
RichParameterList * /*par*/,
const RichParameterList * /*par*/,
GLArea * /*gla*/ )
{
switch( ID(act) )
@ -594,7 +594,7 @@ void DecorateRasterProjPlugin::endDecorate( QAction *act,
void DecorateRasterProjPlugin::setPointParameters( MeshDrawer &md,
RichParameterList *par )
const RichParameterList *par )
{
if( par->getBool("MeshLab::Appearance::pointSmooth") )
glEnable( GL_POINT_SMOOTH );
@ -629,7 +629,7 @@ void DecorateRasterProjPlugin::setPointParameters( MeshDrawer &md,
void DecorateRasterProjPlugin::decorateDoc( QAction *act,
MeshDocument &m ,
RichParameterList *par,
const RichParameterList *par,
GLArea *gla,
QPainter *,
GLLogStream &)

View File

@ -92,11 +92,11 @@ public:
// Member functions.
private:
void updateCurrentMesh( MeshDocument &m,
RichParameterList &par );
const RichParameterList &par );
void updateCurrentRaster( MeshDocument &m, QGLContext* glctx, MLSceneGLSharedDataContext* ctx);
void setPointParameters( MeshDrawer &md,
RichParameterList *par );
void setPointParameters(MeshDrawer &md,
const RichParameterList* par );
void drawScene();
void drawSceneShadow();
void updateShadowProjectionMatrix();
@ -112,10 +112,10 @@ private:
public:
inline QList<QAction*> actions() const { return actionList; }
bool startDecorate(QAction *act, MeshDocument &m, RichParameterList *par, GLArea *gla );
void decorateMesh( QAction * , MeshModel & , RichParameterList * , GLArea * , QPainter * , GLLogStream & ) {}
void decorateDoc( QAction *act, MeshDocument &m, RichParameterList *par, GLArea *gla, QPainter *p, GLLogStream & );
void endDecorate( QAction *act, MeshDocument &m, RichParameterList *par, GLArea *gla );
bool startDecorate(QAction *act, MeshDocument &m, const RichParameterList *par, GLArea *gla );
void decorateMesh( QAction * , MeshModel & , const RichParameterList * , GLArea * , QPainter * , GLLogStream & ) {}
void decorateDoc(QAction *act, MeshDocument &m, const RichParameterList* par, GLArea *gla, QPainter *p, GLLogStream & );
void endDecorate( QAction *act, MeshDocument &m, const RichParameterList *par, GLArea *gla );
void initGlobalParameterSet( QAction *act, RichParameterList &par );
int getDecorationClass( QAction *act ) const;
};

View File

@ -74,7 +74,7 @@ void DecorateShadowPlugin::initGlobalParameterSet(QAction *action, RichParameter
}
}
bool DecorateShadowPlugin::startDecorate(QAction* action, MeshDocument& /*m*/, RichParameterList* parset, GLArea* /*gla*/)
bool DecorateShadowPlugin::startDecorate(QAction* action, MeshDocument& /*m*/, const RichParameterList* parset, GLArea* /*gla*/)
{
bool result;
@ -118,7 +118,7 @@ bool DecorateShadowPlugin::startDecorate(QAction* action, MeshDocument& /*m*/, R
return false;
}
void DecorateShadowPlugin::endDecorate(QAction * action, MeshDocument & /*md*/, RichParameterList * parset, GLArea * /*gla*/)
void DecorateShadowPlugin::endDecorate(QAction * action, MeshDocument & /*md*/, const RichParameterList * parset, GLArea * /*gla*/)
{
switch (ID(action))
{
@ -165,7 +165,7 @@ void DecorateShadowPlugin::endDecorate(QAction * action, MeshDocument & /*md*/,
}
void DecorateShadowPlugin::decorateDoc(QAction *action, MeshDocument &md, RichParameterList *, GLArea *gla, QPainter *, GLLogStream &)
void DecorateShadowPlugin::decorateDoc(QAction *action, MeshDocument &md, const RichParameterList *, GLArea *gla, QPainter *, GLLogStream &)
{
switch (ID(action)) {
case DP_SHOW_SHADOW:

View File

@ -88,10 +88,10 @@ public:
QList<QAction *> actions () const {return actionList;}
bool startDecorate(QAction * /*mode*/, MeshDocument & /*m*/, RichParameterList * /*parent*/ par, GLArea * /*parent*/);
void decorateMesh(QAction *, MeshModel &, RichParameterList *, GLArea *, QPainter *, GLLogStream &){}
void decorateDoc(QAction *a, MeshDocument &m, RichParameterList *, GLArea *gla, QPainter *p, GLLogStream &);
void endDecorate(QAction *, MeshDocument &, RichParameterList *, GLArea *);
bool startDecorate(QAction * /*mode*/, MeshDocument & /*m*/, const RichParameterList * /*parent*/ par, GLArea * /*parent*/);
void decorateMesh(QAction *, MeshModel &, const RichParameterList *, GLArea *, QPainter *, GLLogStream &){}
void decorateDoc(QAction *a, MeshDocument &m, const RichParameterList*, GLArea *gla, QPainter *p, GLLogStream &);
void endDecorate(QAction *, MeshDocument &, const RichParameterList *, GLArea *);
void initGlobalParameterSet(QAction *, RichParameterList & globalparam);
int getDecorationClass(QAction * /*action*/) const { return MeshDecorateInterface::PerDocument; }