moving meshlab settings classes

This commit is contained in:
alemuntoni 2020-08-02 11:12:14 +02:00
parent 4a9d520928
commit a1a326e536
8 changed files with 206 additions and 132 deletions

View File

@ -8,7 +8,6 @@
set(SOURCES
additionalgui.cpp
changetexturename.cpp
customDialog.cpp
filterScriptDialog.cpp
glarea.cpp
glarea_setting.cpp
@ -27,6 +26,8 @@ set(SOURCES
meshlab_settings/richparameterlistdialog.cpp
meshlab_settings/richparameterlistframe.cpp
meshlab_settings/richparameterwidgets.cpp
meshlab_settings/settingdialog.cpp
meshlab_settings/meshlabsettingsdialog.cpp
${VCGDIR}/wrap/gui/trackball.cpp
${VCGDIR}/wrap/gui/trackmode.cpp
${VCGDIR}/wrap/gui/coordinateframe.cpp)
@ -34,7 +35,6 @@ set(SOURCES
set(HEADERS
additionalgui.h
changetexturename.h
customDialog.h
filterScriptDialog.h
glarea.h
glarea_setting.h
@ -53,6 +53,8 @@ set(HEADERS
meshlab_settings/richparameterlistdialog.h
meshlab_settings/richparameterlistframe.h
meshlab_settings/richparameterwidgets.h
meshlab_settings/settingdialog.h
meshlab_settings/meshlabsettingsdialog.h
${VCGDIR}/wrap/gui/trackball.h
${VCGDIR}/wrap/gui/trackmode.h
${VCGDIR}/wrap/gl/trimesh.h)

View File

@ -41,7 +41,7 @@
#include <QWidgetAction>
#include "mainwindow.h"
#include "plugindialog.h"
#include "customDialog.h"
#include "meshlab_settings/meshlabsettingsdialog.h"
#include "saveSnapshotDialog.h"
#include "ui_congratsDialog.h"

View File

@ -26,7 +26,7 @@
#include "mainwindow.h"
#include "plugindialog.h"
#include "filterScriptDialog.h"
#include "customDialog.h"
#include "meshlab_settings/meshlabsettingsdialog.h"
#include "saveSnapshotDialog.h"
#include "ui_aboutDialog.h"
#include "savemaskexporter.h"
@ -2686,7 +2686,7 @@ void MainWindow::showLayerDlg(bool visible)
void MainWindow::setCustomize()
{
CustomDialog dialog(currentGlobalParams,defaultGlobalParams, this);
MeshLabSettingsDialog dialog(currentGlobalParams,defaultGlobalParams, this);
connect(&dialog,SIGNAL(applyCustomSetting()),this,SLOT(updateCustomSettings()));
dialog.exec();
}

View File

@ -31,10 +31,11 @@ HEADERS += \
../common/interfaces.h \
mainwindow.h \
glarea.h \
meshlab_settings/meshlabsettingsdialog.h \
meshlab_settings/settingdialog.h \
multiViewer_Container.h \
glarea_setting.h \
plugindialog.h \
customDialog.h \
filterScriptDialog.h \
saveSnapshotDialog.h \
savemaskexporter.h \
@ -58,9 +59,10 @@ SOURCES += \
mainwindow_Init.cpp \
mainwindow_RunTime.cpp \
glarea.cpp \
meshlab_settings/meshlabsettingsdialog.cpp \
meshlab_settings/settingdialog.cpp \
multiViewer_Container.cpp \
plugindialog.cpp \
customDialog.cpp \
filterScriptDialog.cpp \
saveSnapshotDialog.cpp \
layerDialog.cpp \

View File

@ -1,14 +1,14 @@
/****************************************************************************
* MeshLab o o *
* A versatile mesh processing toolbox o o *
* VCGLib o o *
* Visual and Computer Graphics Library o o *
* _ O _ *
* Copyright(C) 2005 \/)\/ *
* Copyright(C) 2004-2020 \/)\/ *
* Visual Computing Lab /\/| *
* ISTI - Italian National Research Council | *
* \ *
* All rights reserved. *
* *
* This program is free software; you can redistribute it and/or modify *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
@ -21,13 +21,16 @@
* *
****************************************************************************/
#include <common/filter_parameter/rich_parameter_list.h>
#include "customDialog.h"
#include <QPalette>
#include <QHeaderView>
#include "meshlabsettingsdialog.h"
#include "settingdialog.h"
#include <QHeaderView>
using namespace vcg;
CustomDialog::CustomDialog(RichParameterList& curparset, RichParameterList& defparset, QWidget * parent)
MeshLabSettingsDialog::MeshLabSettingsDialog(RichParameterList& curparset, RichParameterList& defparset, QWidget * parent)
:QDialog(parent),curParSet(curparset),defParSet(defparset)
{
setModal(false);
@ -46,7 +49,7 @@ CustomDialog::CustomDialog(RichParameterList& curparset, RichParameterList& defp
this->setWindowTitle(tr("Global Parameters Window"));
}
void CustomDialog::openSubDialog( QTableWidgetItem* itm )
void MeshLabSettingsDialog::openSubDialog( QTableWidgetItem* itm )
{
int rprow = tw->row(itm);
RichParameter *defPar = defParSet.findParameter(vrp[rprow]->name());
@ -57,11 +60,11 @@ void CustomDialog::openSubDialog( QTableWidgetItem* itm )
delete setdial;
}
CustomDialog::~CustomDialog()
MeshLabSettingsDialog::~MeshLabSettingsDialog()
{
}
void CustomDialog::updateSettings()
void MeshLabSettingsDialog::updateSettings()
{
QStringList slst;
slst.push_back("Variable Name");
@ -73,9 +76,9 @@ void CustomDialog::updateSettings()
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)
@ -106,7 +109,7 @@ void CustomDialog::updateSettings()
emit tw->horizontalHeader()->sectionAutoResize( 1,QHeaderView::ResizeToContents);*/
}
QTableWidgetItem* CustomDialog::createQTableWidgetItemFromRichParameter(const RichParameter& pd)
QTableWidgetItem* MeshLabSettingsDialog::createQTableWidgetItemFromRichParameter(const RichParameter& pd)
{
if (pd.value().isAbsPerc()){
return new QTableWidgetItem(QString::number(pd.value().getAbsPerc()));
@ -168,80 +171,3 @@ QTableWidgetItem* CustomDialog::createQTableWidgetItemFromRichParameter(const Ri
return nullptr;
}
}
//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, QWidget* parent /*= 0*/ )
:QDialog(parent),frame(this),curPar(currentPar),defPar(defaultPar),tmppar(NULL)
{
setModal(true);
savebut = new QPushButton("Save",this);
resetbut = new QPushButton("Reset",this);
applybut = new QPushButton("Apply",this);
loadbut = new QPushButton("Load",this);
closebut = new QPushButton("Close",this);
QGridLayout* dialoglayout = new QGridLayout(parent);
dialoglayout->addWidget(savebut,1,0);
dialoglayout->addWidget(resetbut,1,1);
dialoglayout->addWidget(loadbut,1,2);
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);
connect(applybut,SIGNAL(clicked()),this,SLOT(apply()));
connect(resetbut,SIGNAL(clicked()),this,SLOT(reset()));
connect(savebut,SIGNAL(clicked()),this,SLOT(save()));
connect(loadbut,SIGNAL(clicked()),this,SLOT(load()));
connect(closebut,SIGNAL(clicked()),this,SLOT(close()));
}
void SettingDialog::save()
{
apply();
QDomDocument doc("MeshLabSettings");
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));
QSettings setting;
setting.setValue(tmppar->name(),QVariant(docstring));
curPar->value().set(tmppar->value());
}
void SettingDialog::apply()
{
assert(frame.stdfieldwidgets.size() == 1);
frame.stdfieldwidgets.at(0)->collectWidgetValue();
curPar->value().set(tmppar->value());
emit applySettingSignal();
}
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());
apply();
}
void SettingDialog::load()
{
assert(frame.stdfieldwidgets.size() == 1);
frame.stdfieldwidgets.at(0)->setWidgetValue(curPar->value());
}
SettingDialog::~SettingDialog()
{
}

View File

@ -0,0 +1,57 @@
/****************************************************************************
* VCGLib o o *
* Visual and Computer Graphics Library o o *
* _ O _ *
* Copyright(C) 2004-2020 \/)\/ *
* Visual Computing Lab /\/| *
* ISTI - Italian National Research Council | *
* \ *
* All rights reserved. *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) *
* for more details. *
* *
****************************************************************************/
#ifndef MESHLABSETTINGSDIALOG_H
#define MESHLABSETTINGSDIALOG_H
#include <QDialog>
#include <QTableWidget>
#include <common/filter_parameter/rich_parameter_list.h>
class MeshLabSettingsDialog : public QDialog
{
Q_OBJECT
public:
MeshLabSettingsDialog(RichParameterList& parset,RichParameterList& defparset,QWidget *parent = 0);
~MeshLabSettingsDialog();
//void loadCurrentSetting(RichParameterSet& parset);
public slots:
void openSubDialog(QTableWidgetItem* itm);
void updateSettings();
signals:
void applyCustomSetting();
private:
RichParameterList& curParSet;
RichParameterList& defParSet;
QTableWidget* tw;
QVector<RichParameter*> vrp;
void dispatch(const RichParameter& par);
QPushButton* closebut;
static QTableWidgetItem* createQTableWidgetItemFromRichParameter(const RichParameter& pd);
};
#endif // MESHLABSETTINGSDIALOG_H

View File

@ -0,0 +1,111 @@
/****************************************************************************
* VCGLib o o *
* Visual and Computer Graphics Library o o *
* _ O _ *
* Copyright(C) 2004-2020 \/)\/ *
* Visual Computing Lab /\/| *
* ISTI - Italian National Research Council | *
* \ *
* All rights reserved. *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) *
* for more details. *
* *
****************************************************************************/
#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,
QWidget* parent) :
QDialog(parent),
frame(this),
curPar(currentPar),
defPar(defaultPar),
tmppar(NULL)
{
setModal(true);
savebut = new QPushButton("Save",this);
resetbut = new QPushButton("Reset",this);
applybut = new QPushButton("Apply",this);
loadbut = new QPushButton("Load",this);
closebut = new QPushButton("Close",this);
QGridLayout* dialoglayout = new QGridLayout(parent);
dialoglayout->addWidget(savebut,1,0);
dialoglayout->addWidget(resetbut,1,1);
dialoglayout->addWidget(loadbut,1,2);
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);
connect(applybut,SIGNAL(clicked()),this,SLOT(apply()));
connect(resetbut,SIGNAL(clicked()),this,SLOT(reset()));
connect(savebut,SIGNAL(clicked()),this,SLOT(save()));
connect(loadbut,SIGNAL(clicked()),this,SLOT(load()));
connect(closebut,SIGNAL(clicked()),this,SLOT(close()));
}
SettingDialog::~SettingDialog()
{
}
void SettingDialog::save()
{
apply();
QDomDocument doc("MeshLabSettings");
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));
QSettings setting;
setting.setValue(tmppar->name(),QVariant(docstring));
curPar->value().set(tmppar->value());
}
void SettingDialog::apply()
{
assert(frame.stdfieldwidgets.size() == 1);
frame.stdfieldwidgets.at(0)->collectWidgetValue();
curPar->value().set(tmppar->value());
emit applySettingSignal();
}
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());
apply();
}
void SettingDialog::load()
{
assert(frame.stdfieldwidgets.size() == 1);
frame.stdfieldwidgets.at(0)->setWidgetValue(curPar->value());
}

View File

@ -1,14 +1,14 @@
/****************************************************************************
* MeshLab o o *
* A versatile mesh processing toolbox o o *
* VCGLib o o *
* Visual and Computer Graphics Library o o *
* _ O _ *
* Copyright(C) 2005 \/)\/ *
* Copyright(C) 2004-2020 \/)\/ *
* Visual Computing Lab /\/| *
* ISTI - Italian National Research Council | *
* \ *
* All rights reserved. *
* *
* This program is free software; you can redistribute it and/or modify *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
@ -21,13 +21,12 @@
* *
****************************************************************************/
#ifndef SETTINGDIALOG_H
#define SETTINGDIALOG_H
#include <QDialog>
#include <QDockWidget>
#include <QColorDialog>
#include <common/filter_parameter/rich_parameter_list.h>
#include "meshlab_settings/richparameterlistframe.h"
#include <common/filter_parameter/rich_parameter.h>
#include "richparameterlistframe.h"
class SettingDialog : public QDialog
{
@ -56,27 +55,4 @@ private:
QPushButton* loadbut;
};
class CustomDialog : public QDialog
{
Q_OBJECT
public:
CustomDialog(RichParameterList& parset,RichParameterList& defparset,QWidget *parent = 0);
~CustomDialog();
//void loadCurrentSetting(RichParameterSet& parset);
public slots:
void openSubDialog(QTableWidgetItem* itm);
void updateSettings();
signals:
void applyCustomSetting();
private:
RichParameterList& curParSet;
RichParameterList& defParSet;
QTableWidget* tw;
QVector<RichParameter*> vrp;
void dispatch(const RichParameter& par);
QPushButton* closebut;
static QTableWidgetItem* createQTableWidgetItemFromRichParameter(const RichParameter& pd);
};
#endif // SETTINGDIALOG_H