From ad88cf4b0619a2e4d6ed8a526cedc6afe6508b2e Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Wed, 4 Aug 2021 12:23:10 +0200 Subject: [PATCH 01/22] first draft of new filter dialog --- src/meshlab/CMakeLists.txt | 3 + src/meshlab/dialogs/filter_dock_dialog.cpp | 14 +++ src/meshlab/dialogs/filter_dock_dialog.h | 22 ++++ src/meshlab/dialogs/filter_dock_dialog.ui | 101 ++++++++++++++++++ .../richparameterlistframe.cpp | 19 +++- .../richparameterlistframe.h | 3 + 6 files changed, 160 insertions(+), 2 deletions(-) create mode 100644 src/meshlab/dialogs/filter_dock_dialog.cpp create mode 100644 src/meshlab/dialogs/filter_dock_dialog.h create mode 100644 src/meshlab/dialogs/filter_dock_dialog.ui diff --git a/src/meshlab/CMakeLists.txt b/src/meshlab/CMakeLists.txt index 750acd512..7111216d7 100644 --- a/src/meshlab/CMakeLists.txt +++ b/src/meshlab/CMakeLists.txt @@ -16,6 +16,7 @@ set(SOURCES multiViewer_Container.cpp dialogs/about_dialog.cpp dialogs/congrats_dialog.cpp + dialogs/filter_dock_dialog.cpp dialogs/filter_script_dialog.cpp dialogs/options_dialog.cpp dialogs/plugin_info_dialog.cpp @@ -43,6 +44,7 @@ set(HEADERS snapshotsetting.h dialogs/about_dialog.h dialogs/congrats_dialog.h + dialogs/filter_dock_dialog.h dialogs/filter_script_dialog.h dialogs/options_dialog.h dialogs/plugin_info_dialog.h @@ -61,6 +63,7 @@ set(RESOURCES meshlab.qrc) set(UI dialogs/about_dialog.ui dialogs/congrats_dialog.ui + dialogs/filter_dock_dialog.ui dialogs/filter_script_dialog.ui dialogs/plugin_info_dialog.ui dialogs/save_mesh_attributes_dialog.ui diff --git a/src/meshlab/dialogs/filter_dock_dialog.cpp b/src/meshlab/dialogs/filter_dock_dialog.cpp new file mode 100644 index 000000000..a6404d19b --- /dev/null +++ b/src/meshlab/dialogs/filter_dock_dialog.cpp @@ -0,0 +1,14 @@ +#include "filter_dock_dialog.h" +#include "ui_filter_dock_dialog.h" + +FilterDockDialog::FilterDockDialog(QWidget *parent) : + QDockWidget(parent), + ui(new Ui::FilterDockDialog) +{ + ui->setupUi(this); +} + +FilterDockDialog::~FilterDockDialog() +{ + delete ui; +} diff --git a/src/meshlab/dialogs/filter_dock_dialog.h b/src/meshlab/dialogs/filter_dock_dialog.h new file mode 100644 index 000000000..13eaaa2dc --- /dev/null +++ b/src/meshlab/dialogs/filter_dock_dialog.h @@ -0,0 +1,22 @@ +#ifndef FILTER_DOCK_DIALOG_H +#define FILTER_DOCK_DIALOG_H + +#include + +namespace Ui { +class FilterDockDialog; +} + +class FilterDockDialog : public QDockWidget +{ + Q_OBJECT + +public: + explicit FilterDockDialog(QWidget *parent = nullptr); + ~FilterDockDialog(); + +private: + Ui::FilterDockDialog *ui; +}; + +#endif // FILTER_DOCK_DIALOG_H diff --git a/src/meshlab/dialogs/filter_dock_dialog.ui b/src/meshlab/dialogs/filter_dock_dialog.ui new file mode 100644 index 000000000..4620a71d6 --- /dev/null +++ b/src/meshlab/dialogs/filter_dock_dialog.ui @@ -0,0 +1,101 @@ + + + FilterDockDialog + + + + 0 + 0 + 400 + 539 + + + + Filter Title + + + + + + + Apply + + + + + + + Default + + + + + + + + true + + + + Filter Description + + + + + + + Preview + + + + + + + Help + + + + + + + Close + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + RichParameterListFrame + QFrame +
rich_parameter_gui/richparameterlistframe.h
+ 1 +
+
+ + +
diff --git a/src/meshlab/rich_parameter_gui/richparameterlistframe.cpp b/src/meshlab/rich_parameter_gui/richparameterlistframe.cpp index 5ab308a0a..80bddb5db 100644 --- a/src/meshlab/rich_parameter_gui/richparameterlistframe.cpp +++ b/src/meshlab/rich_parameter_gui/richparameterlistframe.cpp @@ -35,6 +35,11 @@ using namespace vcg; +RichParameterListFrame::RichParameterListFrame(QWidget* parent) : + QFrame(parent), gla(nullptr), hiddenFrame(nullptr) +{ +} + RichParameterListFrame::RichParameterListFrame( const RichParameterList& curParSet, const RichParameterList& defParSet, @@ -49,7 +54,7 @@ RichParameterListFrame::RichParameterListFrame( const RichParameterList& curParSet, QWidget* p, QWidget* gla) : - QFrame(p), gla(gla) + QFrame(p), gla(gla), hiddenFrame(nullptr) { loadFrameContent(curParSet); } @@ -59,7 +64,7 @@ RichParameterListFrame::RichParameterListFrame( const RichParameter& defPar, QWidget* p, QWidget* gla) : - QFrame(p), gla(gla) + QFrame(p), gla(gla), hiddenFrame(nullptr) { loadFrameContent(curPar, defPar); } @@ -68,6 +73,16 @@ RichParameterListFrame::~RichParameterListFrame() { } +void RichParameterListFrame::initParams( + const RichParameterList& curParSet, + const RichParameterList& defParSet, + QWidget* gla) +{ + if (gla != nullptr) + this->gla = gla; + loadFrameContent(curParSet, defParSet); +} + /** * @brief RichParameterListFrame::readValues * From GUI to RichParameterList diff --git a/src/meshlab/rich_parameter_gui/richparameterlistframe.h b/src/meshlab/rich_parameter_gui/richparameterlistframe.h index 727bbaa6b..0d5260268 100644 --- a/src/meshlab/rich_parameter_gui/richparameterlistframe.h +++ b/src/meshlab/rich_parameter_gui/richparameterlistframe.h @@ -50,11 +50,14 @@ class RichParameterListFrame : public QFrame public: typedef std::map::iterator iterator; + RichParameterListFrame(QWidget *parent); RichParameterListFrame(const RichParameterList& curParSet, const RichParameterList& defParSet, QWidget *p, QWidget *gla=0); RichParameterListFrame(const RichParameterList& curParSet, QWidget *p, QWidget *gla=0); RichParameterListFrame(const RichParameter& curPar, const RichParameter& defPar, QWidget *p, QWidget *gla=0); ~RichParameterListFrame(); + void initParams(const RichParameterList& curParSet, const RichParameterList& defParSet, QWidget *gla=nullptr); + // 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 void writeValuesOnParameterList(RichParameterList &curParSet); From 2205561259cdda077d88385b6377dcc948031823 Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Wed, 18 Aug 2021 16:13:33 +0200 Subject: [PATCH 02/22] using new filter dock dialog --- src/meshlab/dialogs/filter_dock_dialog.cpp | 46 ++++++- src/meshlab/dialogs/filter_dock_dialog.h | 27 +++- src/meshlab/dialogs/filter_dock_dialog.ui | 102 ++++++++++----- src/meshlab/mainwindow.h | 12 +- src/meshlab/mainwindow_Init.cpp | 2 +- src/meshlab/mainwindow_RunTime.cpp | 117 ++++++++---------- src/meshlab/ml_std_par_dialog.cpp | 4 +- .../richparameterlistframe.cpp | 17 ++- .../richparameterlistframe.h | 1 + 9 files changed, 206 insertions(+), 122 deletions(-) diff --git a/src/meshlab/dialogs/filter_dock_dialog.cpp b/src/meshlab/dialogs/filter_dock_dialog.cpp index a6404d19b..a1ac181d5 100644 --- a/src/meshlab/dialogs/filter_dock_dialog.cpp +++ b/src/meshlab/dialogs/filter_dock_dialog.cpp @@ -1,14 +1,56 @@ #include "filter_dock_dialog.h" #include "ui_filter_dock_dialog.h" -FilterDockDialog::FilterDockDialog(QWidget *parent) : +FilterDockDialog::FilterDockDialog( + const RichParameterList& rpl, + FilterPlugin* plugin, + const QAction* filter, + QWidget* parent, + GLArea* glArea) : QDockWidget(parent), - ui(new Ui::FilterDockDialog) + ui(new Ui::FilterDockDialog), + filter(filter), + parameters(rpl), + currentGLArea(glArea) { ui->setupUi(this); + + this->setWindowTitle(plugin->filterName(filter)); + ui->filterInfoLabel->setText(plugin->filterInfo(filter)); + + ui->parameterFrame->initParams(rpl, rpl, (QWidget*)glArea); + ui->parameterFrame->setMinimumSize(ui->parameterFrame->sizeHint()); + setMinimumWidth(sizeHint().width()); } FilterDockDialog::~FilterDockDialog() { delete ui; } + +void FilterDockDialog::on_applyPushButton_clicked() +{ + ui->parameterFrame->writeValuesOnParameterList(parameters); + emit applyButtonClicked(filter, parameters); +} + + +void FilterDockDialog::on_helpPushButton_clicked() +{ + ui->parameterFrame->toggleHelp(); + ui->parameterFrame->setMinimumWidth(ui->parameterFrame->sizeHint().width()); + setMinimumWidth(sizeHint().width()); +} + + +void FilterDockDialog::on_closePushButton_clicked() +{ + close(); +} + + +void FilterDockDialog::on_defaultPushButton_clicked() +{ + ui->parameterFrame->resetValues(); +} + diff --git a/src/meshlab/dialogs/filter_dock_dialog.h b/src/meshlab/dialogs/filter_dock_dialog.h index 13eaaa2dc..adf8faa2f 100644 --- a/src/meshlab/dialogs/filter_dock_dialog.h +++ b/src/meshlab/dialogs/filter_dock_dialog.h @@ -3,6 +3,10 @@ #include +#include + +class GLArea; + namespace Ui { class FilterDockDialog; } @@ -12,11 +16,32 @@ class FilterDockDialog : public QDockWidget Q_OBJECT public: - explicit FilterDockDialog(QWidget *parent = nullptr); + explicit FilterDockDialog( + const RichParameterList& rpl, + FilterPlugin* plugin, + const QAction* filter, + QWidget *parent = nullptr, + GLArea* glArea = nullptr); ~FilterDockDialog(); +signals: + void applyButtonClicked(const QAction*, RichParameterList); + +private slots: + void on_applyPushButton_clicked(); + + void on_helpPushButton_clicked(); + + void on_closePushButton_clicked(); + + void on_defaultPushButton_clicked(); + private: Ui::FilterDockDialog *ui; + + const QAction* filter; + RichParameterList parameters; + GLArea* currentGLArea; }; #endif // FILTER_DOCK_DIALOG_H diff --git a/src/meshlab/dialogs/filter_dock_dialog.ui b/src/meshlab/dialogs/filter_dock_dialog.ui index 4620a71d6..3be20c72f 100644 --- a/src/meshlab/dialogs/filter_dock_dialog.ui +++ b/src/meshlab/dialogs/filter_dock_dialog.ui @@ -15,20 +15,34 @@ - + + + + Close + + + + Apply - + Default + + + + Help + + + @@ -39,52 +53,74 @@ Filter Description + + Qt::RichText + + + true + + + true + - + Preview - - - - Help - - - - - - - Close - - - - + - QFrame::StyledPanel + QFrame::NoFrame - QFrame::Raised + QFrame::Plain + + Qt::ScrollBarAlwaysOff + + + true + + + + + 0 + 0 + 382 + 388 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + QFrame::NoFrame + + + QFrame::Raised + + + + + - - - - Qt::Vertical - - - - 20 - 40 - - - - diff --git a/src/meshlab/mainwindow.h b/src/meshlab/mainwindow.h index 0214e9413..74d0d4ba3 100644 --- a/src/meshlab/mainwindow.h +++ b/src/meshlab/mainwindow.h @@ -36,6 +36,7 @@ #include "glarea.h" #include "layerDialog.h" #include "ml_std_par_dialog.h" +#include "dialogs/filter_dock_dialog.h" #include "multiViewer_Container.h" #include "ml_render_gui.h" @@ -93,15 +94,15 @@ class MainWindow : public QMainWindow Q_OBJECT public: - // callback function to execute a filter - void executeFilter(const QAction *action, RichParameterList &srcpar, bool isPreview = false); - MainWindow(); ~MainWindow(); static bool QCallBack(const int pos, const char * str); //const QString appName() const {return tr("MeshLab v")+appVer(); } //const QString appVer() const {return tr("1.3.2"); } MainWindowSetting mwsettings; +public slots: + // callback function to execute a filter + void executeFilter(const QAction *action, const RichParameterList& srcpar, bool isPreview = false); signals: void dispatchCustomSettings(const RichParameterList& rps); void filterExecuted(); @@ -201,7 +202,7 @@ private slots: void updateMenus(); void updateSubFiltersMenu(const bool createmenuenabled,const bool validmeshdoc); void updateMenuItems(QMenu* menu,const bool enabled); - void updateStdDialog(); + void closeFilterDockDialog(); void enableDocumentSensibleActionsContainer(const bool enable); void setSplit(QAction *qa); void setUnsplit(); @@ -246,7 +247,6 @@ private: int longestActionWidthInMenu(QMenu* m,const int longestwidth); int longestActionWidthInMenu( QMenu* m); int longestActionWidthInAllMenus(); - void createStdPluginWnd(); // this one is void initGlobalParameters(); void createActions(); void createMenus(); @@ -277,7 +277,7 @@ private: int idGet; bool verboseCheckingFlag; - MeshlabStdDialog *stddialog; + FilterDockDialog* filterDockDialog; static QProgressBar *qb; QMdiArea *mdiarea; diff --git a/src/meshlab/mainwindow_Init.cpp b/src/meshlab/mainwindow_Init.cpp index 6540246e4..8d53a6ed4 100644 --- a/src/meshlab/mainwindow_Init.cpp +++ b/src/meshlab/mainwindow_Init.cpp @@ -127,7 +127,7 @@ MainWindow::MainWindow(): createToolBars(); createMenus(); gpumeminfo = new vcg::QtThreadSafeMemoryInfo(mwsettings.maxgpumem); - stddialog = 0; + filterDockDialog = 0; setAcceptDrops(true); mdiarea->setAcceptDrops(true); setWindowTitle(MeshLabApplication::shortName()); diff --git a/src/meshlab/mainwindow_RunTime.cpp b/src/meshlab/mainwindow_RunTime.cpp index 76822ac19..ff540ea8a 100644 --- a/src/meshlab/mainwindow_RunTime.cpp +++ b/src/meshlab/mainwindow_RunTime.cpp @@ -100,41 +100,6 @@ void MainWindow::updateRecentProjActions() recentProjActs[j]->setVisible(false); } -// creates the standard plugin window -void MainWindow::createStdPluginWnd() -{ - //checks if a MeshlabStdDialog is already open and closes it - if (stddialog!=0) - { - stddialog->close(); - delete stddialog; - } - stddialog = new MeshlabStdDialog(this); - stddialog->setAllowedAreas ( Qt::NoDockWidgetArea); - //addDockWidget(Qt::RightDockWidgetArea,stddialog); - - //stddialog->setAttribute(Qt::WA_DeleteOnClose,true); - stddialog->setFloating(true); - stddialog->hide(); - connect(GLA(),SIGNAL(glareaClosed()),this,SLOT(updateStdDialog())); - connect(GLA(),SIGNAL(glareaClosed()),stddialog,SLOT(closeClick())); -} - -// When we switch the current model (and we change the active window) -// we have to close the stddialog. -// this one is called when user switch current window. -void MainWindow::updateStdDialog() -{ - if(stddialog!=0){ - if(GLA()!=0){ - if(stddialog->curModel != meshDoc()->mm()){ - stddialog->curgla=0; // invalidate the curgla member that is no more valid. - stddialog->close(); - } - } - } -} - void MainWindow::updateCustomSettings() { mwsettings.updateGlobalParameterList(currentGlobalParams); @@ -246,8 +211,6 @@ void MainWindow::enableDocumentSensibleActionsContainer(const bool allowed) editToolBar->setEnabled(allowed); } - - //menu create is not enabled only in case of not valid/existing meshdocument void MainWindow::updateSubFiltersMenu( const bool createmenuenabled,const bool validmeshdoc ) { @@ -741,8 +704,6 @@ void MainWindow::dropEvent ( QDropEvent * event ) this, "File format not supported", extension + " file format is not supported by MeshLab."); } - - } showLayerDlg(layervis || meshDoc()->meshNumber() > 0); } @@ -911,8 +872,6 @@ void MainWindow::showTooltip(QAction* q) // It is split in two part // - startFilter that setup the dialogs and asks for parameters // - executeFilter callback invoked when the params have been set up. - - void MainWindow::startFilter(const QAction* action) { if(currentViewContainer() == NULL) return; @@ -920,7 +879,7 @@ void MainWindow::startFilter(const QAction* action) // In order to avoid that a filter changes something assumed by the current editing tool, // before actually starting the filter we close the current editing tool (if any). - if (GLA()->getCurrentEditAction() != NULL) + if (GLA()->getCurrentEditAction() != nullptr) endEdit(); updateMenus(); @@ -930,49 +889,73 @@ void MainWindow::startFilter(const QAction* action) if (action == nullptr) throw MLException("Invalid filter action value."); FilterPlugin *iFilter = qobject_cast(action->parent()); - if (meshDoc() == NULL) + if (meshDoc() == nullptr) return; - //OLD FILTER PHILOSOPHY - if (iFilter != NULL) - { - //if(iFilter->getClass(action) == MeshFilterInterface::MeshCreation) - //{ - // qDebug("MeshCreation"); - // GLA()->meshDoc->addNewMesh("",iFilter->filterName(action) ); - //} - //else - if (!iFilter->isFilterApplicable(action,(*meshDoc()->mm()),missingPreconditions)) - { + if (iFilter != nullptr) { + if (!iFilter->isFilterApplicable(action,(*meshDoc()->mm()),missingPreconditions)) { QString enstr = missingPreconditions.join(","); QMessageBox::warning(this, tr("PreConditions' Failure"), QString("Warning the filter '" + iFilter->filterName(action) + "' has not been applied.
" "Current mesh does not have " + enstr + ".")); return; } - if(currentViewContainer()) - { + if(currentViewContainer()) { iFilter->setLog(currentViewContainer()->LogPtr()); currentViewContainer()->LogPtr()->setBookmark(); } - // just to be sure... - createStdPluginWnd(); + + //checks if a filterDockDialog is already open and closes it + if (filterDockDialog != nullptr) { + filterDockDialog->close(); + delete filterDockDialog; + } // (2) Ask for filter parameters and eventually directly invoke the filter // showAutoDialog return true if a dialog have been created (and therefore the execution is demanded to the apply event) // if no dialog is created the filter must be executed immediately - if(! stddialog->showAutoDialog(iFilter, meshDoc()->mm(), (meshDoc()), action, this, GLA()) ) - { - RichParameterList dummyParSet; - executeFilter(action, dummyParSet, false); + + RichParameterList rpl = iFilter->initParameterList(action, *meshDoc()); + if (rpl.isEmpty()) { + executeFilter(action, rpl, false); //Insert the filter to filterHistory FilterNameParameterValuesPair tmp; - tmp.first = action->text(); tmp.second = dummyParSet; + tmp.first = action->text(); + tmp.second = rpl; meshDoc()->filterHistory.append(tmp); } + else { + filterDockDialog = new FilterDockDialog( + rpl, + iFilter, action, + this, GLA() + ); + filterDockDialog->setAllowedAreas (Qt::NoDockWidgetArea); + addDockWidget(Qt::RightDockWidgetArea, filterDockDialog); + + //stddialog->setAttribute(Qt::WA_DeleteOnClose,true); + filterDockDialog->setFloating(true); + connect( + GLA(), SIGNAL(glareaClosed()), + this, SLOT(closeFilterDockDialog())); + connect( + filterDockDialog, SIGNAL(applyButtonClicked(const QAction*, RichParameterList)), + this, SLOT(executeFilter(const QAction*, RichParameterList))); + filterDockDialog->show(); + } } - -}//void MainWindow::startFilter() +} + +// When we switch the current model (and we change the active window) +// we have to close the stddialog. +// this one is called when user switch current window. +void MainWindow::closeFilterDockDialog() +{ + if(filterDockDialog != nullptr) { + filterDockDialog->close(); + filterDockDialog = nullptr; + } +} void MainWindow::updateSharedContextDataAfterFilterExecution(int postcondmask,int fclasses,bool& newmeshcreated) @@ -1127,7 +1110,7 @@ from the user defined dialog */ -void MainWindow::executeFilter(const QAction* action, RichParameterList ¶ms, bool isPreview) +void MainWindow::executeFilter(const QAction* action, const RichParameterList ¶ms, bool isPreview) { FilterPlugin *iFilter = qobject_cast(action->parent()); qb->show(); @@ -3140,7 +3123,7 @@ void MainWindow::switchCurrentContainer(QMdiSubWindow * subwin) { updateLayerDialog(); updateMenus(); - updateStdDialog(); + closeFilterDockDialog(); } } diff --git a/src/meshlab/ml_std_par_dialog.cpp b/src/meshlab/ml_std_par_dialog.cpp index 7bca2b58b..7bbae0439 100644 --- a/src/meshlab/ml_std_par_dialog.cpp +++ b/src/meshlab/ml_std_par_dialog.cpp @@ -181,14 +181,14 @@ void MeshlabStdDialog::applyClick() updateRenderingData(curmwi, curModel); } - //PreView Caching: if the apply parameters are the same to those used in the preview mode - //we don't need to reapply the filter to the mesh if ((q != nullptr) && (curMeshDoc != nullptr)) { FilterNameParameterValuesPair oldpair; oldpair.first = q->text(); oldpair.second = curParSet; curMeshDoc->filterHistory.append(oldpair); } + //PreView Caching: if the apply parameters are the same to those used in the preview mode + //we don't need to reapply the filter to the mesh bool isEqual = (curParSet == prevParSet); if (curModel && (isEqual) && (validcache)) { meshCacheState.apply(curModel); diff --git a/src/meshlab/rich_parameter_gui/richparameterlistframe.cpp b/src/meshlab/rich_parameter_gui/richparameterlistframe.cpp index 80bddb5db..dfed59d2c 100644 --- a/src/meshlab/rich_parameter_gui/richparameterlistframe.cpp +++ b/src/meshlab/rich_parameter_gui/richparameterlistframe.cpp @@ -36,7 +36,7 @@ using namespace vcg; RichParameterListFrame::RichParameterListFrame(QWidget* parent) : - QFrame(parent), gla(nullptr), hiddenFrame(nullptr) + QFrame(parent), isHelpVisible(false), gla(nullptr), hiddenFrame(nullptr) { } @@ -45,7 +45,7 @@ RichParameterListFrame::RichParameterListFrame( const RichParameterList& defParSet, QWidget* p, QWidget* gla) : - QFrame(p), gla(gla), hiddenFrame(nullptr) + QFrame(p), isHelpVisible(false), gla(gla), hiddenFrame(nullptr) { loadFrameContent(curParSet, defParSet); } @@ -54,7 +54,7 @@ RichParameterListFrame::RichParameterListFrame( const RichParameterList& curParSet, QWidget* p, QWidget* gla) : - QFrame(p), gla(gla), hiddenFrame(nullptr) + QFrame(p), isHelpVisible(false), gla(gla), hiddenFrame(nullptr) { loadFrameContent(curParSet); } @@ -64,7 +64,7 @@ RichParameterListFrame::RichParameterListFrame( const RichParameter& defPar, QWidget* p, QWidget* gla) : - QFrame(p), gla(gla), hiddenFrame(nullptr) + QFrame(p), isHelpVisible(false), gla(gla), hiddenFrame(nullptr) { loadFrameContent(curPar, defPar); } @@ -105,9 +105,9 @@ void RichParameterListFrame::resetValues() void RichParameterListFrame::toggleHelp() { + isHelpVisible = !isHelpVisible; for(int i = 0; i < helpList.count(); i++) - helpList.at(i)->setVisible(!helpList.at(i)->isVisible()) ; - updateGeometry(); + helpList.at(i)->setVisible(isHelpVisible); } unsigned int RichParameterListFrame::size() const @@ -136,11 +136,8 @@ void RichParameterListFrame::toggleAdvancedParameters() hiddenFrame->setVisible(true); showHiddenFramePushButton->setText("▲"); } - QFrame* p = dynamic_cast(parent()); - if (p){ - p->setMinimumSize(p->sizeHint()); - } } + setMinimumSize(sizeHint()); } void RichParameterListFrame::loadFrameContent( diff --git a/src/meshlab/rich_parameter_gui/richparameterlistframe.h b/src/meshlab/rich_parameter_gui/richparameterlistframe.h index 0d5260268..33cd0d3b3 100644 --- a/src/meshlab/rich_parameter_gui/richparameterlistframe.h +++ b/src/meshlab/rich_parameter_gui/richparameterlistframe.h @@ -89,6 +89,7 @@ private: std::map stdfieldwidgets; QVector helpList; + bool isHelpVisible; QWidget *gla; // used for having a link to the glarea that spawned the parameter asking. QFrame* hiddenFrame; From bfa5bd65a4be844dacd1d707a4f67738b3812e81 Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Wed, 8 Sep 2021 12:11:28 +0200 Subject: [PATCH 03/22] check if filter is previewable --- src/meshlab/dialogs/filter_dock_dialog.cpp | 34 ++++++++++++++++------ src/meshlab/dialogs/filter_dock_dialog.h | 20 ++++++++----- src/meshlab/mainwindow_Init.cpp | 2 +- src/meshlab/mainwindow_RunTime.cpp | 19 +++++------- 4 files changed, 45 insertions(+), 30 deletions(-) diff --git a/src/meshlab/dialogs/filter_dock_dialog.cpp b/src/meshlab/dialogs/filter_dock_dialog.cpp index a1ac181d5..37e0a863d 100644 --- a/src/meshlab/dialogs/filter_dock_dialog.cpp +++ b/src/meshlab/dialogs/filter_dock_dialog.cpp @@ -2,15 +2,17 @@ #include "ui_filter_dock_dialog.h" FilterDockDialog::FilterDockDialog( - const RichParameterList& rpl, - FilterPlugin* plugin, - const QAction* filter, - QWidget* parent, - GLArea* glArea) : + const RichParameterList& rpl, + FilterPlugin* plugin, + const QAction* filter, + QWidget* parent, + GLArea* glArea) : QDockWidget(parent), ui(new Ui::FilterDockDialog), + plugin(plugin), filter(filter), parameters(rpl), + mask(plugin->postCondition(filter)), currentGLArea(glArea) { ui->setupUi(this); @@ -18,8 +20,11 @@ FilterDockDialog::FilterDockDialog( this->setWindowTitle(plugin->filterName(filter)); ui->filterInfoLabel->setText(plugin->filterInfo(filter)); - ui->parameterFrame->initParams(rpl, rpl, (QWidget*)glArea); + ui->parameterFrame->initParams(rpl, rpl, (QWidget*) glArea); ui->parameterFrame->setMinimumSize(ui->parameterFrame->sizeHint()); + + if (!isPreviewable()) + ui->previewCheckBox->setVisible(false); setMinimumWidth(sizeHint().width()); } @@ -34,7 +39,6 @@ void FilterDockDialog::on_applyPushButton_clicked() emit applyButtonClicked(filter, parameters); } - void FilterDockDialog::on_helpPushButton_clicked() { ui->parameterFrame->toggleHelp(); @@ -42,15 +46,27 @@ void FilterDockDialog::on_helpPushButton_clicked() setMinimumWidth(sizeHint().width()); } - void FilterDockDialog::on_closePushButton_clicked() { close(); } - void FilterDockDialog::on_defaultPushButton_clicked() { ui->parameterFrame->resetValues(); } +bool FilterDockDialog::isPreviewable() const +{ + if ((filter == nullptr) || (plugin == nullptr) || + (plugin->filterArity(filter) != FilterPlugin::SINGLE_MESH)) + return false; + + if ((mask == MeshModel::MM_UNKNOWN) || (mask == MeshModel::MM_NONE)) + return false; + + if ((mask & MeshModel::MM_VERTNUMBER) || (mask & MeshModel::MM_FACENUMBER)) + return false; + + return true; +} diff --git a/src/meshlab/dialogs/filter_dock_dialog.h b/src/meshlab/dialogs/filter_dock_dialog.h index adf8faa2f..d4f056921 100644 --- a/src/meshlab/dialogs/filter_dock_dialog.h +++ b/src/meshlab/dialogs/filter_dock_dialog.h @@ -17,11 +17,11 @@ class FilterDockDialog : public QDockWidget public: explicit FilterDockDialog( - const RichParameterList& rpl, - FilterPlugin* plugin, - const QAction* filter, - QWidget *parent = nullptr, - GLArea* glArea = nullptr); + const RichParameterList& rpl, + FilterPlugin* plugin, + const QAction* filter, + QWidget* parent = nullptr, + GLArea* glArea = nullptr); ~FilterDockDialog(); signals: @@ -37,11 +37,15 @@ private slots: void on_defaultPushButton_clicked(); private: - Ui::FilterDockDialog *ui; + bool isPreviewable() const; - const QAction* filter; + Ui::FilterDockDialog* ui; + + FilterPlugin* plugin; + const QAction* filter; RichParameterList parameters; - GLArea* currentGLArea; + unsigned int mask; + GLArea* currentGLArea; }; #endif // FILTER_DOCK_DIALOG_H diff --git a/src/meshlab/mainwindow_Init.cpp b/src/meshlab/mainwindow_Init.cpp index 8d53a6ed4..4ec690fd4 100644 --- a/src/meshlab/mainwindow_Init.cpp +++ b/src/meshlab/mainwindow_Init.cpp @@ -127,7 +127,7 @@ MainWindow::MainWindow(): createToolBars(); createMenus(); gpumeminfo = new vcg::QtThreadSafeMemoryInfo(mwsettings.maxgpumem); - filterDockDialog = 0; + filterDockDialog = nullptr; setAcceptDrops(true); mdiarea->setAcceptDrops(true); setWindowTitle(MeshLabApplication::shortName()); diff --git a/src/meshlab/mainwindow_RunTime.cpp b/src/meshlab/mainwindow_RunTime.cpp index ff540ea8a..5f635f350 100644 --- a/src/meshlab/mainwindow_RunTime.cpp +++ b/src/meshlab/mainwindow_RunTime.cpp @@ -925,22 +925,17 @@ void MainWindow::startFilter(const QAction* action) meshDoc()->filterHistory.append(tmp); } else { - filterDockDialog = new FilterDockDialog( - rpl, - iFilter, action, - this, GLA() - ); - filterDockDialog->setAllowedAreas (Qt::NoDockWidgetArea); + filterDockDialog = new FilterDockDialog(rpl, iFilter, action, this, GLA()); + filterDockDialog->setAllowedAreas(Qt::NoDockWidgetArea); addDockWidget(Qt::RightDockWidgetArea, filterDockDialog); - //stddialog->setAttribute(Qt::WA_DeleteOnClose,true); filterDockDialog->setFloating(true); + connect(GLA(), SIGNAL(glareaClosed()), this, SLOT(closeFilterDockDialog())); connect( - GLA(), SIGNAL(glareaClosed()), - this, SLOT(closeFilterDockDialog())); - connect( - filterDockDialog, SIGNAL(applyButtonClicked(const QAction*, RichParameterList)), - this, SLOT(executeFilter(const QAction*, RichParameterList))); + filterDockDialog, + SIGNAL(applyButtonClicked(const QAction*, RichParameterList)), + this, + SLOT(executeFilter(const QAction*, RichParameterList))); filterDockDialog->show(); } } From 7b531d32a64429dfad46e3a3fac292d6ca345443 Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Wed, 8 Sep 2021 16:22:23 +0200 Subject: [PATCH 04/22] preview working --- src/meshlab/dialogs/filter_dock_dialog.cpp | 135 ++++++++++++++++++++- src/meshlab/dialogs/filter_dock_dialog.h | 24 +++- src/meshlab/mainwindow.h | 2 +- src/meshlab/mainwindow_RunTime.cpp | 24 ++-- 4 files changed, 166 insertions(+), 19 deletions(-) diff --git a/src/meshlab/dialogs/filter_dock_dialog.cpp b/src/meshlab/dialogs/filter_dock_dialog.cpp index 37e0a863d..2b16e8493 100644 --- a/src/meshlab/dialogs/filter_dock_dialog.cpp +++ b/src/meshlab/dialogs/filter_dock_dialog.cpp @@ -1,6 +1,8 @@ #include "filter_dock_dialog.h" #include "ui_filter_dock_dialog.h" +#include "../mainwindow.h" + FilterDockDialog::FilterDockDialog( const RichParameterList& rpl, FilterPlugin* plugin, @@ -13,7 +15,12 @@ FilterDockDialog::FilterDockDialog( filter(filter), parameters(rpl), mask(plugin->postCondition(filter)), - currentGLArea(glArea) + currentGLArea(glArea), + isPreviewMeshStateValid(false), + prevParams(rpl), + mw(nullptr), + md(nullptr), + mesh(nullptr) { ui->setupUi(this); @@ -23,8 +30,31 @@ FilterDockDialog::FilterDockDialog( ui->parameterFrame->initParams(rpl, rpl, (QWidget*) glArea); ui->parameterFrame->setMinimumSize(ui->parameterFrame->sizeHint()); - if (!isPreviewable()) + if (!isFilterPreviewable(plugin, filter)) { ui->previewCheckBox->setVisible(false); + } + else { + // parent should be always the mainwindow + mw = static_cast(parent); + if (mw) { + md = mw->meshDoc(); + mesh = mw->meshDoc()->mm(); + if (md == nullptr || mesh == nullptr) { + ui->previewCheckBox->setVisible(false); + mw = nullptr; + md = nullptr; + mesh = nullptr; + } + else { + noPreviewMeshState.create(mask, mesh); + connect(ui->parameterFrame, SIGNAL(parameterChanged()), this, SLOT(applyDynamic())); + connect(md, SIGNAL(currentMeshChanged(int)), this, SLOT(changeCurrentMesh(int))); + } + } + else { + ui->previewCheckBox->setVisible(false); + } + } setMinimumWidth(sizeHint().width()); } @@ -33,10 +63,59 @@ FilterDockDialog::~FilterDockDialog() delete ui; } +void FilterDockDialog::on_previewCheckBox_stateChanged(int state) +{ + if (state == Qt::Checked) { + ui->parameterFrame->writeValuesOnParameterList(parameters); + + // if the preview mesh state is valid and parameters are not changed, we do not need to + // apply again the filter + if (isPreviewMeshStateValid && parameters == prevParams) { + previewMeshState.apply(mesh); + updateRenderingData(mw, mesh); + if (currentGLArea != nullptr) + currentGLArea->updateAllDecorators(); + } + else { // we need to apply the filter + applyDynamic(); + if (currentGLArea != nullptr) + currentGLArea->updateAllDecorators(); + } + } + else { // not checked - exit from preview + noPreviewMeshState.apply(mesh); + updateRenderingData(mw, mesh); + if (currentGLArea != nullptr) + currentGLArea->updateAllDecorators(); + } +} + void FilterDockDialog::on_applyPushButton_clicked() { ui->parameterFrame->writeValuesOnParameterList(parameters); - emit applyButtonClicked(filter, parameters); + + if (isPreviewable()) { + if (mesh) { + // first, restore the mesh to the no-preview state + noPreviewMeshState.apply(mesh); + updateRenderingData(mw, mesh); + } + } + + if (isPreviewable() && isPreviewMeshStateValid && parameters == prevParams) { + previewMeshState.apply(mesh); + updateRenderingData(mw, mesh); + } + else + emit applyButtonClicked(filter, parameters, false, true); + + if (isPreviewable()) { + // save the no-preview state, after the filter was applied + noPreviewMeshState.create(mask, mesh); + } + + if (currentGLArea) + currentGLArea->update(); } void FilterDockDialog::on_helpPushButton_clicked() @@ -56,8 +135,44 @@ void FilterDockDialog::on_defaultPushButton_clicked() ui->parameterFrame->resetValues(); } +void FilterDockDialog::applyDynamic() +{ + if (ui->previewCheckBox->isChecked()) { + prevParams = parameters; + ui->parameterFrame->writeValuesOnParameterList(parameters); + ui->parameterFrame->writeValuesOnParameterList(prevParams); + + // first, restore the mesh to the no-preview state + noPreviewMeshState.apply(mesh); + // then, apply dynamically with the new parameters + mw->executeFilter(filter, parameters, true); + // save the preview state + previewMeshState.create(mask, mesh); + isPreviewMeshStateValid = true; + + if (currentGLArea) + currentGLArea->update(); + } +} + +void FilterDockDialog::changeCurrentMesh(int meshId) +{ + if (isPreviewable()) { + noPreviewMeshState.apply(mesh); + mesh = md->getMesh(meshId); + noPreviewMeshState.create(mask, mesh); + applyDynamic(); + } +} + bool FilterDockDialog::isPreviewable() const { + return ui->previewCheckBox->isVisible(); +} + +bool FilterDockDialog::isFilterPreviewable(FilterPlugin* plugin, const QAction* filter) +{ + unsigned int mask = plugin->postCondition(filter); if ((filter == nullptr) || (plugin == nullptr) || (plugin->filterArity(filter) != FilterPlugin::SINGLE_MESH)) return false; @@ -70,3 +185,17 @@ bool FilterDockDialog::isPreviewable() const return true; } + +void FilterDockDialog::updateRenderingData(MainWindow* mw, MeshModel* mesh) +{ + if (mw != nullptr && mesh != nullptr) { + MultiViewer_Container* mvcont = mw->currentViewContainer(); + if (mvcont != nullptr) { + MLSceneGLSharedDataContext* shar = mvcont->sharedDataContext(); + if (shar != nullptr) { + shar->meshAttributesUpdated(mesh->id(), true, MLRenderingData::RendAtts(true)); + shar->manageBuffers(mesh->id()); + } + } + } +} diff --git a/src/meshlab/dialogs/filter_dock_dialog.h b/src/meshlab/dialogs/filter_dock_dialog.h index d4f056921..048cb472c 100644 --- a/src/meshlab/dialogs/filter_dock_dialog.h +++ b/src/meshlab/dialogs/filter_dock_dialog.h @@ -3,9 +3,11 @@ #include +#include #include class GLArea; +class MainWindow; namespace Ui { class FilterDockDialog; @@ -25,20 +27,25 @@ public: ~FilterDockDialog(); signals: - void applyButtonClicked(const QAction*, RichParameterList); + void applyButtonClicked(const QAction*, RichParameterList, bool, bool); private slots: + void on_previewCheckBox_stateChanged(int state); void on_applyPushButton_clicked(); - void on_helpPushButton_clicked(); - void on_closePushButton_clicked(); - void on_defaultPushButton_clicked(); + // preview slots + void applyDynamic(); + void changeCurrentMesh(int meshId); + private: bool isPreviewable() const; + static bool isFilterPreviewable(FilterPlugin* plugin, const QAction* filter); + static void updateRenderingData(MainWindow* mw, MeshModel* mesh); + Ui::FilterDockDialog* ui; FilterPlugin* plugin; @@ -46,6 +53,15 @@ private: RichParameterList parameters; unsigned int mask; GLArea* currentGLArea; + + // preview + bool isPreviewMeshStateValid; + MeshModelState noPreviewMeshState; + MeshModelState previewMeshState; + RichParameterList prevParams; + MainWindow* mw; + MeshDocument* md; + MeshModel* mesh; }; #endif // FILTER_DOCK_DIALOG_H diff --git a/src/meshlab/mainwindow.h b/src/meshlab/mainwindow.h index 74d0d4ba3..9b44bb532 100644 --- a/src/meshlab/mainwindow.h +++ b/src/meshlab/mainwindow.h @@ -102,7 +102,7 @@ public: MainWindowSetting mwsettings; public slots: // callback function to execute a filter - void executeFilter(const QAction *action, const RichParameterList& srcpar, bool isPreview = false); + void executeFilter(const QAction *action, const RichParameterList& srcpar, bool isPreview = false, bool saveOnHistory = false); signals: void dispatchCustomSettings(const RichParameterList& rps); void filterExecuted(); diff --git a/src/meshlab/mainwindow_RunTime.cpp b/src/meshlab/mainwindow_RunTime.cpp index 5f635f350..602717802 100644 --- a/src/meshlab/mainwindow_RunTime.cpp +++ b/src/meshlab/mainwindow_RunTime.cpp @@ -916,13 +916,7 @@ void MainWindow::startFilter(const QAction* action) RichParameterList rpl = iFilter->initParameterList(action, *meshDoc()); if (rpl.isEmpty()) { - executeFilter(action, rpl, false); - - //Insert the filter to filterHistory - FilterNameParameterValuesPair tmp; - tmp.first = action->text(); - tmp.second = rpl; - meshDoc()->filterHistory.append(tmp); + executeFilter(action, rpl, false, true); } else { filterDockDialog = new FilterDockDialog(rpl, iFilter, action, this, GLA()); @@ -933,9 +927,9 @@ void MainWindow::startFilter(const QAction* action) connect(GLA(), SIGNAL(glareaClosed()), this, SLOT(closeFilterDockDialog())); connect( filterDockDialog, - SIGNAL(applyButtonClicked(const QAction*, RichParameterList)), + SIGNAL(applyButtonClicked(const QAction*, RichParameterList, bool, bool)), this, - SLOT(executeFilter(const QAction*, RichParameterList))); + SLOT(executeFilter(const QAction*, RichParameterList, bool, bool))); filterDockDialog->show(); } } @@ -1104,8 +1098,8 @@ from the automatic dialog from the user defined dialog */ - -void MainWindow::executeFilter(const QAction* action, const RichParameterList ¶ms, bool isPreview) +void MainWindow::executeFilter( + const QAction* action, const RichParameterList& params, bool isPreview, bool saveOnHistory) { FilterPlugin *iFilter = qobject_cast(action->parent()); qb->show(); @@ -1265,6 +1259,14 @@ void MainWindow::executeFilter(const QAction* action, const RichParameterList &p updateSharedContextDataAfterFilterExecution(postCondMask,fclasses,newmeshcreated); meshDoc()->meshDocStateData().clear(); + + if (saveOnHistory){ + //Insert the filter to filterHistory + FilterNameParameterValuesPair tmp; + tmp.first = action->text(); + tmp.second = params; + meshDoc()->filterHistory.append(tmp); + } } catch (const std::bad_alloc& bdall) { meshDoc()->setBusy(false); From b4fecec6eb5aedfc88d73d04db97dee90b7d4a1c Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Thu, 9 Sep 2021 10:22:24 +0200 Subject: [PATCH 05/22] documentation and some size fix --- src/meshlab/dialogs/filter_dock_dialog.cpp | 28 +++++++++++++++------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/src/meshlab/dialogs/filter_dock_dialog.cpp b/src/meshlab/dialogs/filter_dock_dialog.cpp index 2b16e8493..7b4c1c777 100644 --- a/src/meshlab/dialogs/filter_dock_dialog.cpp +++ b/src/meshlab/dialogs/filter_dock_dialog.cpp @@ -28,13 +28,17 @@ FilterDockDialog::FilterDockDialog( ui->filterInfoLabel->setText(plugin->filterInfo(filter)); ui->parameterFrame->initParams(rpl, rpl, (QWidget*) glArea); - ui->parameterFrame->setMinimumSize(ui->parameterFrame->sizeHint()); + // by default, the previewCheckBox is visible when the dialog is constructed. + // now, we check if the filter is previewable: + // - if it is previewable, we set all data structures necessary to make the preview available + // - if it is not previewable, we set the previewCheckBox non visible if (!isFilterPreviewable(plugin, filter)) { ui->previewCheckBox->setVisible(false); } else { - // parent should be always the mainwindow + // parent should always be the mainwindow + // if not, the filter won't be previewable mw = static_cast(parent); if (mw) { md = mw->meshDoc(); @@ -55,7 +59,9 @@ FilterDockDialog::FilterDockDialog( ui->previewCheckBox->setVisible(false); } } - setMinimumWidth(sizeHint().width()); + ui->parameterFrame->showNormal(); + ui->parameterFrame->adjustSize(); + showNormal(); } FilterDockDialog::~FilterDockDialog() @@ -65,13 +71,13 @@ FilterDockDialog::~FilterDockDialog() void FilterDockDialog::on_previewCheckBox_stateChanged(int state) { - if (state == Qt::Checked) { + if (state == Qt::Checked) { //enable preview ui->parameterFrame->writeValuesOnParameterList(parameters); // if the preview mesh state is valid and parameters are not changed, we do not need to // apply again the filter if (isPreviewMeshStateValid && parameters == prevParams) { - previewMeshState.apply(mesh); + previewMeshState.apply(mesh); // apply the preview state to the mesh updateRenderingData(mw, mesh); if (currentGLArea != nullptr) currentGLArea->updateAllDecorators(); @@ -82,8 +88,8 @@ void FilterDockDialog::on_previewCheckBox_stateChanged(int state) currentGLArea->updateAllDecorators(); } } - else { // not checked - exit from preview - noPreviewMeshState.apply(mesh); + else { // not checked - disable preview + noPreviewMeshState.apply(mesh); // re-apply old state of the mesh updateRenderingData(mw, mesh); if (currentGLArea != nullptr) currentGLArea->updateAllDecorators(); @@ -121,8 +127,9 @@ void FilterDockDialog::on_applyPushButton_clicked() void FilterDockDialog::on_helpPushButton_clicked() { ui->parameterFrame->toggleHelp(); - ui->parameterFrame->setMinimumWidth(ui->parameterFrame->sizeHint().width()); - setMinimumWidth(sizeHint().width()); + ui->parameterFrame->updateGeometry(); + ui->parameterFrame->adjustSize(); + updateGeometry(); } void FilterDockDialog::on_closePushButton_clicked() @@ -167,6 +174,9 @@ void FilterDockDialog::changeCurrentMesh(int meshId) bool FilterDockDialog::isPreviewable() const { + // the actual check whether the filter is previewable or not is made in the consturctor, calling + // the function isFilterPreviewable(). + // when a filter is previewable, the previewCheckBox is visible. return ui->previewCheckBox->isVisible(); } From ec8febd96170ab8a9dae21af1ef216f97191c31f Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Thu, 9 Sep 2021 10:53:46 +0200 Subject: [PATCH 06/22] small size improvement --- src/meshlab/dialogs/filter_dock_dialog.cpp | 3 --- src/meshlab/rich_parameter_gui/richparameterlistframe.cpp | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/meshlab/dialogs/filter_dock_dialog.cpp b/src/meshlab/dialogs/filter_dock_dialog.cpp index 7b4c1c777..069444e5b 100644 --- a/src/meshlab/dialogs/filter_dock_dialog.cpp +++ b/src/meshlab/dialogs/filter_dock_dialog.cpp @@ -59,9 +59,6 @@ FilterDockDialog::FilterDockDialog( ui->previewCheckBox->setVisible(false); } } - ui->parameterFrame->showNormal(); - ui->parameterFrame->adjustSize(); - showNormal(); } FilterDockDialog::~FilterDockDialog() diff --git a/src/meshlab/rich_parameter_gui/richparameterlistframe.cpp b/src/meshlab/rich_parameter_gui/richparameterlistframe.cpp index dfed59d2c..ef2e8140c 100644 --- a/src/meshlab/rich_parameter_gui/richparameterlistframe.cpp +++ b/src/meshlab/rich_parameter_gui/richparameterlistframe.cpp @@ -108,6 +108,9 @@ void RichParameterListFrame::toggleHelp() isHelpVisible = !isHelpVisible; for(int i = 0; i < helpList.count(); i++) helpList.at(i)->setVisible(isHelpVisible); + setMinimumSize(sizeHint()); + adjustSize(); + updateGeometry(); } unsigned int RichParameterListFrame::size() const From dc5f1fbfd68eb7ee19f7c519a385bf409be9f9c4 Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Thu, 9 Sep 2021 10:59:20 +0200 Subject: [PATCH 07/22] added vertical spacer to filter dock dialog --- src/meshlab/dialogs/filter_dock_dialog.ui | 130 ++++++++++++---------- 1 file changed, 73 insertions(+), 57 deletions(-) diff --git a/src/meshlab/dialogs/filter_dock_dialog.ui b/src/meshlab/dialogs/filter_dock_dialog.ui index 3be20c72f..2518a2508 100644 --- a/src/meshlab/dialogs/filter_dock_dialog.ui +++ b/src/meshlab/dialogs/filter_dock_dialog.ui @@ -15,62 +15,6 @@ - - - - Close - - - - - - - Apply - - - - - - - Default - - - - - - - Help - - - - - - - - true - - - - Filter Description - - - Qt::RichText - - - true - - - true - - - - - - - Preview - - - @@ -91,7 +35,7 @@ 0 0 382 - 388 + 342 @@ -121,6 +65,78 @@ + + + + Help + + + + + + + + true + + + + Filter Description + + + Qt::RichText + + + true + + + true + + + + + + + Default + + + + + + + Close + + + + + + + Preview + + + + + + + Apply + + + + + + + Qt::Vertical + + + QSizePolicy::Minimum + + + + 20 + 40 + + + + From edfd15504df88453674964362624a08c55094e5d Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Thu, 9 Sep 2021 11:17:23 +0200 Subject: [PATCH 08/22] remove vertical spacer --- src/meshlab/dialogs/filter_dock_dialog.ui | 130 ++++++++++------------ 1 file changed, 57 insertions(+), 73 deletions(-) diff --git a/src/meshlab/dialogs/filter_dock_dialog.ui b/src/meshlab/dialogs/filter_dock_dialog.ui index 2518a2508..4334b3313 100644 --- a/src/meshlab/dialogs/filter_dock_dialog.ui +++ b/src/meshlab/dialogs/filter_dock_dialog.ui @@ -15,6 +15,62 @@ + + + + Close + + + + + + + Help + + + + + + + + true + + + + Filter Description + + + Qt::RichText + + + true + + + true + + + + + + + Apply + + + + + + + Default + + + + + + + Preview + + + @@ -35,7 +91,7 @@ 0 0 382 - 342 + 388 @@ -65,78 +121,6 @@ - - - - Help - - - - - - - - true - - - - Filter Description - - - Qt::RichText - - - true - - - true - - - - - - - Default - - - - - - - Close - - - - - - - Preview - - - - - - - Apply - - - - - - - Qt::Vertical - - - QSizePolicy::Minimum - - - - 20 - 40 - - - - From 9ff4476a76a234de271cce5c34a5a2abad287a48 Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Thu, 9 Sep 2021 11:27:34 +0200 Subject: [PATCH 09/22] working as expected without scrollbar --- src/meshlab/dialogs/filter_dock_dialog.ui | 73 ++++++++--------------- 1 file changed, 26 insertions(+), 47 deletions(-) diff --git a/src/meshlab/dialogs/filter_dock_dialog.ui b/src/meshlab/dialogs/filter_dock_dialog.ui index 4334b3313..8f2e42acc 100644 --- a/src/meshlab/dialogs/filter_dock_dialog.ui +++ b/src/meshlab/dialogs/filter_dock_dialog.ui @@ -15,14 +15,14 @@ - + Close - + Help @@ -50,21 +50,21 @@ - + Apply - + Default - + Preview @@ -72,55 +72,34 @@ - + + + + 0 + 0 + + QFrame::NoFrame - QFrame::Plain + QFrame::Raised - - Qt::ScrollBarAlwaysOff - - - true - - - - - 0 - 0 - 382 - 388 - - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - QFrame::NoFrame - - - QFrame::Raised - - - - - + + + + Qt::Vertical + + + + 20 + 5 + + + + From 51b7c7b5fd97ef2462d9121b9b47d1a91d159301 Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Thu, 9 Sep 2021 12:22:12 +0200 Subject: [PATCH 10/22] add VerticalScrollArea class --- src/meshlab/CMakeLists.txt | 2 ++ .../gui_utils/vertical_scroll_area.cpp | 24 +++++++++++++++++ src/meshlab/gui_utils/vertical_scroll_area.h | 26 +++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 src/meshlab/gui_utils/vertical_scroll_area.cpp create mode 100644 src/meshlab/gui_utils/vertical_scroll_area.h diff --git a/src/meshlab/CMakeLists.txt b/src/meshlab/CMakeLists.txt index 7111216d7..5fcaed3f2 100644 --- a/src/meshlab/CMakeLists.txt +++ b/src/meshlab/CMakeLists.txt @@ -23,6 +23,7 @@ set(SOURCES dialogs/save_mesh_attributes_dialog.cpp dialogs/save_snapshot_dialog.cpp dialogs/setting_dialog.cpp + gui_utils/vertical_scroll_area.cpp rich_parameter_gui/richparameterlistdialog.cpp rich_parameter_gui/richparameterlistframe.cpp rich_parameter_gui/richparameterwidgets.cpp @@ -51,6 +52,7 @@ set(HEADERS dialogs/save_mesh_attributes_dialog.h dialogs/save_snapshot_dialog.h dialogs/setting_dialog.h + gui_utils/vertical_scroll_area.h rich_parameter_gui/richparameterlistdialog.h rich_parameter_gui/richparameterlistframe.h rich_parameter_gui/richparameterwidgets.h diff --git a/src/meshlab/gui_utils/vertical_scroll_area.cpp b/src/meshlab/gui_utils/vertical_scroll_area.cpp new file mode 100644 index 000000000..19a5eab77 --- /dev/null +++ b/src/meshlab/gui_utils/vertical_scroll_area.cpp @@ -0,0 +1,24 @@ +#include "vertical_scroll_area.h" + +#include +#include +#include + +#include "vertical_scroll_area.h" + +VerticalScrollArea::VerticalScrollArea(QWidget *parent) : + QScrollArea(parent) +{ + setWidgetResizable(true); + setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); +} + +bool VerticalScrollArea::eventFilter(QObject *o, QEvent *e) +{ + // This works because QScrollArea::setWidget installs an eventFilter on the widget + if(o && o == widget() && e->type() == QEvent::Resize) + setMinimumWidth(widget()->minimumSizeHint().width() + verticalScrollBar()->width()); + + return QScrollArea::eventFilter(o, e); +} diff --git a/src/meshlab/gui_utils/vertical_scroll_area.h b/src/meshlab/gui_utils/vertical_scroll_area.h new file mode 100644 index 000000000..28a5254a0 --- /dev/null +++ b/src/meshlab/gui_utils/vertical_scroll_area.h @@ -0,0 +1,26 @@ +#ifndef VERTICALSCROLLAREA_H +#define VERTICALSCROLLAREA_H + +#include + +/** + * @brief The VerticalScrollArea class + * + * This class is necessary because Qt does not provide a pure Vertical Scroll Area, + * that behaves as a normal qwidget horizontally. + * + * @see https://forum.qt.io/topic/13374/solved-qscrollarea-vertical-scroll-only + */ +class VerticalScrollArea : public QScrollArea +{ + Q_OBJECT +public: + explicit VerticalScrollArea(QWidget* parent = 0); + + virtual bool eventFilter(QObject* o, QEvent* e); + +private: + QWidget* m_scrollAreaWidgetContents; +}; + +#endif // VERTICALSCROLLAREA_H From 9ac8ac7381fd810aafe11b687331c9234ed447a6 Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Thu, 9 Sep 2021 12:31:34 +0200 Subject: [PATCH 11/22] set VerticalScrollArea to FilterDock --- src/meshlab/CMakeLists.txt | 2 - src/meshlab/dialogs/filter_dock_dialog.ui | 128 ++++++--- src/meshlab/layerDialog.cpp | 3 +- src/meshlab/mainwindow.h | 1 - src/meshlab/ml_std_par_dialog.cpp | 301 ---------------------- src/meshlab/ml_std_par_dialog.h | 80 ------ 6 files changed, 92 insertions(+), 423 deletions(-) delete mode 100644 src/meshlab/ml_std_par_dialog.cpp delete mode 100644 src/meshlab/ml_std_par_dialog.h diff --git a/src/meshlab/CMakeLists.txt b/src/meshlab/CMakeLists.txt index 5fcaed3f2..27edb4c43 100644 --- a/src/meshlab/CMakeLists.txt +++ b/src/meshlab/CMakeLists.txt @@ -12,7 +12,6 @@ set(SOURCES ml_default_decorators.cpp ml_render_gui.cpp ml_rendering_actions.cpp - ml_std_par_dialog.cpp multiViewer_Container.cpp dialogs/about_dialog.cpp dialogs/congrats_dialog.cpp @@ -40,7 +39,6 @@ set(HEADERS ml_default_decorators.h ml_render_gui.h ml_rendering_actions.h - ml_std_par_dialog.h multiViewer_Container.h snapshotsetting.h dialogs/about_dialog.h diff --git a/src/meshlab/dialogs/filter_dock_dialog.ui b/src/meshlab/dialogs/filter_dock_dialog.ui index 8f2e42acc..df7ad573c 100644 --- a/src/meshlab/dialogs/filter_dock_dialog.ui +++ b/src/meshlab/dialogs/filter_dock_dialog.ui @@ -10,12 +10,18 @@ 539 + + + 0 + 0 + + Filter Title - + Close @@ -23,12 +29,81 @@ - + - Help + Apply + + + + QFrame::NoFrame + + + QFrame::Plain + + + true + + + + + 0 + 0 + 382 + 388 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + QFrame::NoFrame + + + QFrame::Raised + + + + + + + Qt::Vertical + + + + 20 + 191 + + + + + + + + @@ -50,56 +125,27 @@ - - - - Apply - - - - + Default - + Preview - - - - - 0 - 0 - - - - QFrame::NoFrame - - - QFrame::Raised + + + + Help - - - - Qt::Vertical - - - - 20 - 5 - - - - @@ -110,6 +156,12 @@
rich_parameter_gui/richparameterlistframe.h
1 + + VerticalScrollArea + QScrollArea +
gui_utils/vertical_scroll_area.h
+ 1 +
diff --git a/src/meshlab/layerDialog.cpp b/src/meshlab/layerDialog.cpp index c8b750eb1..a9d94bf29 100644 --- a/src/meshlab/layerDialog.cpp +++ b/src/meshlab/layerDialog.cpp @@ -37,11 +37,12 @@ $Log: stdpardialog.cpp,v $ #include "mainwindow.h" #include "ui_layerDialog.h" #include "layerDialog.h" +#include "rich_parameter_gui/richparameterlistframe.h" #include "../common/mlexception.h" using namespace std; -LayerDialog::LayerDialog(QWidget *parent ) +LayerDialog::LayerDialog(QWidget *parent ) : QDockWidget(parent) { ui = new Ui::layerDialog(); diff --git a/src/meshlab/mainwindow.h b/src/meshlab/mainwindow.h index 9b44bb532..336f71398 100644 --- a/src/meshlab/mainwindow.h +++ b/src/meshlab/mainwindow.h @@ -35,7 +35,6 @@ #include "glarea.h" #include "layerDialog.h" -#include "ml_std_par_dialog.h" #include "dialogs/filter_dock_dialog.h" #include "multiViewer_Container.h" #include "ml_render_gui.h" diff --git a/src/meshlab/ml_std_par_dialog.cpp b/src/meshlab/ml_std_par_dialog.cpp deleted file mode 100644 index 7bbae0439..000000000 --- a/src/meshlab/ml_std_par_dialog.cpp +++ /dev/null @@ -1,301 +0,0 @@ -#include "ml_std_par_dialog.h" -#include "mainwindow.h" - -static void updateRenderingData(MainWindow* curmwi, MeshModel* curmodel) -{ - if ((curmwi != nullptr) && (curmodel != nullptr)) { - MultiViewer_Container* mvcont = curmwi->currentViewContainer(); - if (mvcont != nullptr) { - MLSceneGLSharedDataContext* shar = mvcont->sharedDataContext(); - if (shar != nullptr) { - shar->meshAttributesUpdated(curmodel->id(), true, MLRenderingData::RendAtts(true)); - shar->manageBuffers(curmodel->id()); - } - } - } -} - -MeshlabStdDialog::MeshlabStdDialog(QWidget *p) : - QDockWidget(QString("Plugin"), p), - qf(nullptr), - stdParFrame(nullptr), - curAction(nullptr), - previewCB(nullptr), - curmask(MeshModel::MM_UNKNOWN), - curModel(nullptr), - curmfi(nullptr), - curmwi(nullptr) -{ -} - -/* manages the setup of the standard parameter window, when the execution of a plugin filter is requested */ -bool MeshlabStdDialog::showAutoDialog(FilterPlugin *mfi, MeshModel *mm, MeshDocument * mdp, const QAction *action, MainWindow *mwi, QWidget *gla) -{ - validcache = false; - curAction = action; - curmfi = mfi; - curmwi = mwi; - prevParSet.clear(); - curModel = mm; - curMeshDoc = mdp; - curgla = gla; - - curParSet = mfi->initParameterList(action, *mdp); - curmask = mfi->postCondition(action); - if (curParSet.isEmpty() && !isPreviewable()) return false; - - createFrame(); - loadFrameContent(); - if (isPreviewable()) { - meshState.create(curmask, curModel); - connect(stdParFrame, SIGNAL(parameterChanged()), this, SLOT(applyDynamic())); - } - connect(curMeshDoc, SIGNAL(currentMeshChanged(int)), this, SLOT(changeCurrentMesh(int))); - raise(); - activateWindow(); - return true; -} - -void MeshlabStdDialog::changeCurrentMesh(int meshInd) -{ - if (isPreviewable()) - { - meshState.apply(curModel); - curModel = curMeshDoc->getMesh(meshInd); - meshState.create(curmask, curModel); - applyDynamic(); - } -} - -bool MeshlabStdDialog::isPreviewable() -{ - if ((curAction == NULL) || (curmfi == NULL) || (curmfi->filterArity(curAction) != FilterPlugin::SINGLE_MESH)) - return false; - - if ((curmask == MeshModel::MM_UNKNOWN) || (curmask == MeshModel::MM_NONE)) - return false; - - if ((curmask & MeshModel::MM_VERTNUMBER) || - (curmask & MeshModel::MM_FACENUMBER)) - return false; - - return true; -} - -void MeshlabStdDialog::createFrame() -{ - if (qf) - delete qf; - - QFrame *newqf = new QFrame(this); - setWidget(newqf); - setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); - qf = newqf; -} - -// update the values of the widgets with the values in the paramlist; -void MeshlabStdDialog::resetValues() -{ - curParSet = curmfi->initParameterList(curAction, *curMeshDoc); - - assert(qf); - assert(qf->isVisible()); - // assert(curParSet.paramList.count() == stdfieldwidgets.count()); - stdParFrame->resetValues(); -} - -void MeshlabStdDialog::loadFrameContent() -{ - assert(qf); - qf->hide(); - - QGridLayout *gridLayout = new QGridLayout(qf); - - setWindowTitle(curmfi->filterName(curAction)); - QLabel *ql = new QLabel("" + curmfi->filterInfo(curAction) + "", qf); - ql->setTextFormat(Qt::RichText); - ql->setWordWrap(true); - ql->setOpenExternalLinks(true); - gridLayout->addWidget(ql, 0, 0, 1, 2, Qt::AlignTop); // this widgets spans over two columns. - - stdParFrame = new RichParameterListFrame(curParSet, this, curgla); - gridLayout->addWidget(stdParFrame, 1, 0, 1, 2); - - int buttonRow = 2; // the row where the line of buttons start - - QPushButton *helpButton = new QPushButton("Help", qf); - QPushButton *closeButton = new QPushButton("Close", qf); - QPushButton *applyButton = new QPushButton("Apply", qf); - QPushButton *defaultButton = new QPushButton("Default", qf); - applyButton->setFocus(); -#ifdef Q_OS_MAC - // Hack needed on mac for correct sizes of button in the bottom of the dialog. - helpButton->setMinimumSize(100, 25); - closeButton->setMinimumSize(100, 25); - applyButton->setMinimumSize(100, 25); - defaultButton->setMinimumSize(100, 25); -#endif - - gridLayout->addItem(new QSpacerItem(40, 20, QSizePolicy::Minimum, QSizePolicy::Expanding), buttonRow++, 0); - - if (isPreviewable()) { - previewCB = new QCheckBox("Preview", qf); - previewCB->setCheckState(Qt::Unchecked); - gridLayout->addWidget(previewCB, buttonRow + 0, 0, Qt::AlignBottom); - connect(previewCB, SIGNAL(toggled(bool)), this, SLOT(togglePreview())); - buttonRow++; - } - gridLayout->addWidget(helpButton, buttonRow + 0, 1, Qt::AlignBottom); - gridLayout->addWidget(defaultButton, buttonRow + 0, 0, Qt::AlignBottom); - gridLayout->addWidget(closeButton, buttonRow + 1, 0, Qt::AlignBottom); - gridLayout->addWidget(applyButton, buttonRow + 1, 1, Qt::AlignBottom); - - connect(helpButton, SIGNAL(clicked()), this, SLOT(toggleHelp())); - connect(applyButton, SIGNAL(clicked()), this, SLOT(applyClick())); - connect(closeButton, SIGNAL(clicked()), this, SLOT(closeClick())); - connect(defaultButton, SIGNAL(clicked()), this, SLOT(resetValues())); - - qf->showNormal(); - qf->adjustSize(); - - //set the minimum size so it will shrink down to the right size after the help is toggled - showNormal(); -} - -void MeshlabStdDialog::toggleHelp() -{ - stdParFrame->toggleHelp(); - qf->updateGeometry(); - qf->adjustSize(); - this->updateGeometry(); -} - -void MeshlabStdDialog::applyClick() -{ - const QAction *q = curAction; - stdParFrame->writeValuesOnParameterList(curParSet); - - // Note that curModel CAN BE NULL (for creation filters on empty docs...) - if (curmask && curModel) { - meshState.apply(curModel); - updateRenderingData(curmwi, curModel); - } - - if ((q != nullptr) && (curMeshDoc != nullptr)) { - FilterNameParameterValuesPair oldpair; - oldpair.first = q->text(); oldpair.second = curParSet; - curMeshDoc->filterHistory.append(oldpair); - } - - //PreView Caching: if the apply parameters are the same to those used in the preview mode - //we don't need to reapply the filter to the mesh - bool isEqual = (curParSet == prevParSet); - if (curModel && (isEqual) && (validcache)) { - meshCacheState.apply(curModel); - updateRenderingData(curmwi, curModel); - } - else - curmwi->executeFilter(q, curParSet, false); - - if (curmask && curModel) - meshState.create(curmask, curModel); - if (this->curgla) - this->curgla->update(); - -} - -void MeshlabStdDialog::applyDynamic() -{ - if (!previewCB->isChecked()) - return; - const QAction *q = curAction; - stdParFrame->writeValuesOnParameterList(curParSet); - //for cache mechanism - //needed to allocate the required memory space in prevParSet - //it called the operator=(RichParameterSet) function defined in RichParameterSet - prevParSet = curParSet; - stdParFrame->writeValuesOnParameterList(prevParSet); - // Restore the - meshState.apply(curModel); - curmwi->executeFilter(q, curParSet, true); - meshCacheState.create(curmask, curModel); - validcache = true; - - - if (this->curgla) - this->curgla->update(); -} - -void MeshlabStdDialog::togglePreview() -{ - if (previewCB == NULL) - return; - - GLArea* glarea = qobject_cast(curgla); - - if (previewCB->isChecked()) - { - stdParFrame->writeValuesOnParameterList(curParSet); - if (!prevParSet.isEmpty() && (validcache) && (curParSet == prevParSet)) - { - meshCacheState.apply(curModel); - updateRenderingData(curmwi, curModel); - if (glarea != NULL) - glarea->updateAllDecorators(); - - } - else - { - applyDynamic(); - if (glarea != NULL) - glarea->updateAllDecorators(); - } - } - else - { - meshState.apply(curModel); - updateRenderingData(curmwi, curModel); - if (glarea != NULL) - glarea->updateAllDecorators(); - } - curgla->update(); -} - -/* click event for the close button of the standard plugin window */ -void MeshlabStdDialog::closeClick() -{ - //int mask = 0;//curParSet.getDynamicFloatMask(); - if (curmask != MeshModel::MM_UNKNOWN) - { - - meshState.apply(curModel); - if (isPreviewable() && (previewCB != NULL) && previewCB->isChecked()) - { - updateRenderingData(curmwi, curModel); - } - - } - curmask = MeshModel::MM_UNKNOWN; - // Perform the update only if there is Valid GLarea. - if (this->curgla) - { - if ((previewCB != NULL) && (previewCB->isChecked()) && (curmwi != NULL) && (curmwi->GLA() != NULL)) - curmwi->GLA()->updateAllPerMeshDecorators(); - - this->curgla->update(); - } - close(); -} - - -// click event for the standard red crossed close button in the upper right widget's corner -void MeshlabStdDialog::closeEvent(QCloseEvent * /*event*/) -{ - closeClick(); -} - -MeshlabStdDialog::~MeshlabStdDialog() -{ - delete stdParFrame; - delete previewCB; -} diff --git a/src/meshlab/ml_std_par_dialog.h b/src/meshlab/ml_std_par_dialog.h deleted file mode 100644 index b15329b5f..000000000 --- a/src/meshlab/ml_std_par_dialog.h +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -* MeshLab o o * -* A versatile mesh processing toolbox o o * -* _ O _ * -* Copyright(C) 2005 \/)\/ * -* 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 ML_STD_PAR_DIALOG -#define ML_STD_PAR_DIALOG - -#include -#include -#include -#include "rich_parameter_gui/richparameterlistframe.h" - -class MainWindow; -class MeshlabStdDialog : public QDockWidget -{ - Q_OBJECT - -public: - MeshlabStdDialog(QWidget *p = NULL); - ~MeshlabStdDialog(); - - void createFrame(); - void loadFrameContent(); - - bool showAutoDialog(FilterPlugin *mfi, MeshModel *mm, MeshDocument * md, const QAction* q, MainWindow *mwi, QWidget *gla=0); - bool isPreviewable(); - -public slots: - void closeClick(); - -private slots: - void applyClick(); - void resetValues(); - void toggleHelp(); - void togglePreview(); - void applyDynamic(); - void changeCurrentMesh(int meshInd); - -public: - QFrame *qf; - RichParameterListFrame *stdParFrame; - const QAction *curAction; - MeshModelState meshState; - MeshModelState meshCacheState; - QCheckBox *previewCB; - - void closeEvent ( QCloseEvent * event ); - - uint curmask; - MeshModel *curModel; - MeshDocument * curMeshDoc; - FilterPlugin *curmfi; - MainWindow *curmwi; - QWidget * curgla; - RichParameterList curParSet; - RichParameterList prevParSet; - bool validcache; - -}; - -#endif From 643c60ff1a77fae7b52865a1915fdf33cb6d525b Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Thu, 9 Sep 2021 14:36:40 +0200 Subject: [PATCH 12/22] add tooltip and vertical spacer to frame --- src/meshlab/dialogs/filter_dock_dialog.ui | 13 ------------- .../rich_parameter_gui/richparameterlistframe.cpp | 7 ++++++- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/src/meshlab/dialogs/filter_dock_dialog.ui b/src/meshlab/dialogs/filter_dock_dialog.ui index df7ad573c..4fa0e561b 100644 --- a/src/meshlab/dialogs/filter_dock_dialog.ui +++ b/src/meshlab/dialogs/filter_dock_dialog.ui @@ -87,19 +87,6 @@ - - - - Qt::Vertical - - - - 20 - 191 - - - - diff --git a/src/meshlab/rich_parameter_gui/richparameterlistframe.cpp b/src/meshlab/rich_parameter_gui/richparameterlistframe.cpp index ef2e8140c..1a50aaa57 100644 --- a/src/meshlab/rich_parameter_gui/richparameterlistframe.cpp +++ b/src/meshlab/rich_parameter_gui/richparameterlistframe.cpp @@ -134,10 +134,12 @@ void RichParameterListFrame::toggleAdvancedParameters() if (hiddenFrame->isVisible()){ hiddenFrame->setVisible(false); showHiddenFramePushButton->setText("▼"); + showHiddenFramePushButton->setToolTip("Show advanced parameters"); } else { hiddenFrame->setVisible(true); showHiddenFramePushButton->setText("▲"); + showHiddenFramePushButton->setToolTip("Hide advanced parameters"); } } setMinimumSize(sizeHint()); @@ -205,15 +207,18 @@ void RichParameterListFrame::loadFrameContent( wd->addWidgetToGridLayout(flay,j++); } } - //hiddenFrame->setMinimumSize(hiddenFrame->sizeHint()); glay->addWidget(hiddenFrame, i++, 0, 1, 3); hiddenFrame->setVisible(false); showHiddenFramePushButton = new QPushButton("", this); showHiddenFramePushButton->setFlat(true); showHiddenFramePushButton->setText("▼"); + showHiddenFramePushButton->setToolTip("Show advanced parameters"); glay->addWidget(showHiddenFramePushButton, i++, 0, 1, 3); connect(showHiddenFramePushButton, SIGNAL(clicked()), this, SLOT(toggleAdvancedParameters())); } + + QSpacerItem* spacer = new QSpacerItem(40, 20, QSizePolicy::Minimum, QSizePolicy::Expanding); + glay->addItem(spacer, i++, 0); setLayout(glay); } From a615bf05f3ed0bf05c0d239e9d086dace3408cea Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Thu, 9 Sep 2021 14:40:35 +0200 Subject: [PATCH 13/22] copyright and refactor --- src/meshlab/dialogs/filter_dock_dialog.cpp | 27 +++++++++++- src/meshlab/dialogs/filter_dock_dialog.h | 22 ++++++++++ .../gui_utils/vertical_scroll_area.cpp | 29 +++++++++++-- src/meshlab/gui_utils/vertical_scroll_area.h | 28 +++++++++++-- .../richparameterlistdialog.h | 42 +++++++++---------- 5 files changed, 118 insertions(+), 30 deletions(-) diff --git a/src/meshlab/dialogs/filter_dock_dialog.cpp b/src/meshlab/dialogs/filter_dock_dialog.cpp index 069444e5b..2cfe8650e 100644 --- a/src/meshlab/dialogs/filter_dock_dialog.cpp +++ b/src/meshlab/dialogs/filter_dock_dialog.cpp @@ -1,3 +1,25 @@ +/**************************************************************************** + * VCGLib o o * + * Visual and Computer Graphics Library o o * + * _ O _ * + * Copyright(C) 2004-2021 \/)\/ * + * 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 "filter_dock_dialog.h" #include "ui_filter_dock_dialog.h" @@ -68,7 +90,7 @@ FilterDockDialog::~FilterDockDialog() void FilterDockDialog::on_previewCheckBox_stateChanged(int state) { - if (state == Qt::Checked) { //enable preview + if (state == Qt::Checked) { // enable preview ui->parameterFrame->writeValuesOnParameterList(parameters); // if the preview mesh state is valid and parameters are not changed, we do not need to @@ -85,7 +107,8 @@ void FilterDockDialog::on_previewCheckBox_stateChanged(int state) currentGLArea->updateAllDecorators(); } } - else { // not checked - disable preview + // not checked - disable preview + else { noPreviewMeshState.apply(mesh); // re-apply old state of the mesh updateRenderingData(mw, mesh); if (currentGLArea != nullptr) diff --git a/src/meshlab/dialogs/filter_dock_dialog.h b/src/meshlab/dialogs/filter_dock_dialog.h index 048cb472c..9576d08e5 100644 --- a/src/meshlab/dialogs/filter_dock_dialog.h +++ b/src/meshlab/dialogs/filter_dock_dialog.h @@ -1,3 +1,25 @@ +/**************************************************************************** + * VCGLib o o * + * Visual and Computer Graphics Library o o * + * _ O _ * + * Copyright(C) 2004-2021 \/)\/ * + * 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 FILTER_DOCK_DIALOG_H #define FILTER_DOCK_DIALOG_H diff --git a/src/meshlab/gui_utils/vertical_scroll_area.cpp b/src/meshlab/gui_utils/vertical_scroll_area.cpp index 19a5eab77..17712676d 100644 --- a/src/meshlab/gui_utils/vertical_scroll_area.cpp +++ b/src/meshlab/gui_utils/vertical_scroll_area.cpp @@ -1,3 +1,25 @@ +/**************************************************************************** + * VCGLib o o * + * Visual and Computer Graphics Library o o * + * _ O _ * + * Copyright(C) 2004-2021 \/)\/ * + * 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 "vertical_scroll_area.h" #include @@ -6,18 +28,17 @@ #include "vertical_scroll_area.h" -VerticalScrollArea::VerticalScrollArea(QWidget *parent) : - QScrollArea(parent) +VerticalScrollArea::VerticalScrollArea(QWidget* parent) : QScrollArea(parent) { setWidgetResizable(true); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); } -bool VerticalScrollArea::eventFilter(QObject *o, QEvent *e) +bool VerticalScrollArea::eventFilter(QObject* o, QEvent* e) { // This works because QScrollArea::setWidget installs an eventFilter on the widget - if(o && o == widget() && e->type() == QEvent::Resize) + if (o && o == widget() && e->type() == QEvent::Resize) setMinimumWidth(widget()->minimumSizeHint().width() + verticalScrollBar()->width()); return QScrollArea::eventFilter(o, e); diff --git a/src/meshlab/gui_utils/vertical_scroll_area.h b/src/meshlab/gui_utils/vertical_scroll_area.h index 28a5254a0..cfcf73292 100644 --- a/src/meshlab/gui_utils/vertical_scroll_area.h +++ b/src/meshlab/gui_utils/vertical_scroll_area.h @@ -1,5 +1,27 @@ -#ifndef VERTICALSCROLLAREA_H -#define VERTICALSCROLLAREA_H +/**************************************************************************** + * VCGLib o o * + * Visual and Computer Graphics Library o o * + * _ O _ * + * Copyright(C) 2004-2021 \/)\/ * + * 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 VERTICAL_SCROLL_AREA_H +#define VERTICAL_SCROLL_AREA_H #include @@ -23,4 +45,4 @@ private: QWidget* m_scrollAreaWidgetContents; }; -#endif // VERTICALSCROLLAREA_H +#endif // VERTICAL_SCROLL_AREA_H diff --git a/src/meshlab/rich_parameter_gui/richparameterlistdialog.h b/src/meshlab/rich_parameter_gui/richparameterlistdialog.h index 141f643e2..6265586cc 100644 --- a/src/meshlab/rich_parameter_gui/richparameterlistdialog.h +++ b/src/meshlab/rich_parameter_gui/richparameterlistdialog.h @@ -1,25 +1,25 @@ /**************************************************************************** -* 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. * -* * -****************************************************************************/ + * VCGLib o o * + * Visual and Computer Graphics Library o o * + * _ O _ * + * Copyright(C) 2004-2021 \/)\/ * + * 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 RICHPARAMETERLISTDIALOG_H #define RICHPARAMETERLISTDIALOG_H From 8b490fc2e8e7d99a0b33c81512cfd09b8015ceb4 Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Thu, 9 Sep 2021 17:32:27 +0200 Subject: [PATCH 14/22] RichPoint3f split into RichPosition and RichDirection --- src/common/parameters/rich_parameter.cpp | 50 ++++- src/common/parameters/rich_parameter.h | 26 ++- src/common/python/function_parameter.cpp | 2 +- src/common/python/python_utils.cpp | 4 +- src/meshlab/dialogs/options_dialog.cpp | 2 +- .../richparameterlistframe.cpp | 7 +- .../richparameterwidgets.cpp | 190 +++++++++++++++--- .../rich_parameter_gui/richparameterwidgets.h | 37 +++- src/meshlabplugins/filter_ao/filter_ao.cpp | 2 +- .../filter_camera/filter_camera.cpp | 6 +- .../filter_colorproc/filter_colorproc.cpp | 2 +- .../filter_dirt/filter_dirt.cpp | 6 +- .../filter_geodesic/filter_geodesic.cpp | 2 +- .../filter_io_nxs/filter_io_nxs.cpp | 2 +- .../filter_meshing/meshfilter.cpp | 12 +- .../filter_qhull/filter_qhull.cpp | 2 +- .../filter_select/meshselect.cpp | 2 +- .../filter_unsharp/filter_unsharp.cpp | 8 +- src/meshlabplugins/io_u3d/io_u3d.cpp | 4 +- 19 files changed, 288 insertions(+), 78 deletions(-) diff --git a/src/common/parameters/rich_parameter.cpp b/src/common/parameters/rich_parameter.cpp index a7cc1c312..b728863af 100644 --- a/src/common/parameters/rich_parameter.cpp +++ b/src/common/parameters/rich_parameter.cpp @@ -324,9 +324,9 @@ bool RichMatrix44f::operator==( const RichParameter& rb ) return (rb.value().isMatrix44f() &&(pName == rb.name()) && (value().getMatrix44f() == rb.value().getMatrix44f())); } -/**** RichPoint3f Class ****/ +/**** RichPosition Class ****/ -RichPoint3f::RichPoint3f( +RichPosition::RichPosition( const QString& nm, const Point3m& defval, const QString& desc, @@ -337,21 +337,53 @@ RichPoint3f::RichPoint3f( { } -RichPoint3f::~RichPoint3f() +RichPosition::~RichPosition() { } -QString RichPoint3f::stringType() const +QString RichPosition::stringType() const { - return "RichPoint3f"; + return "RichPosition"; } -RichPoint3f* RichPoint3f::clone() const +RichPosition* RichPosition::clone() const { - return new RichPoint3f(*this); + return new RichPosition(*this); } -bool RichPoint3f::operator==( const RichParameter& rb ) +bool RichPosition::operator==( const RichParameter& rb ) +{ + return (rb.value().isPoint3f() &&(pName == rb.name()) && (value().getPoint3f() == rb.value().getPoint3f())); +} + +/**** RichDirection Class ****/ + +RichDirection::RichDirection( + const QString& nm, + const Point3m& defval, + const QString& desc, + const QString& tltip, + bool hidden, + const QString& category) : + RichParameter(nm, Point3fValue(defval), desc, tltip, hidden, category) +{ +} + +RichDirection::~RichDirection() +{ +} + +QString RichDirection::stringType() const +{ + return "RichDirection"; +} + +RichDirection* RichDirection::clone() const +{ + return new RichDirection(*this); +} + +bool RichDirection::operator==(const RichParameter& rb) { return (rb.value().isPoint3f() &&(pName == rb.name()) && (value().getPoint3f() == rb.value().getPoint3f())); } @@ -835,7 +867,7 @@ bool RichParameterAdapter::create( const QDomElement& np,RichParameter** par ) if (!corrconv) return false; - *par = new RichPoint3f(name, val,desc,tooltip); + *par = new RichPosition(name, val,desc,tooltip); return true; } if(type=="RichShotf") { diff --git a/src/common/parameters/rich_parameter.h b/src/common/parameters/rich_parameter.h index 1a8c7b29f..75c2d7689 100644 --- a/src/common/parameters/rich_parameter.h +++ b/src/common/parameters/rich_parameter.h @@ -188,21 +188,39 @@ public: bool operator==(const RichParameter& rb); }; -class RichPoint3f : public RichParameter +class RichPosition : public RichParameter { public: - RichPoint3f( + RichPosition( const QString& nm, const Point3m& defval, const QString& desc = QString(), const QString& tltip = QString(), bool hidden = false, const QString& category = QString()); - ~RichPoint3f(); + ~RichPosition(); QString stringType() const; - RichPoint3f* clone() const; + RichPosition* clone() const; + bool operator==(const RichParameter& rb); +}; + +class RichDirection : public RichParameter +{ +public: + RichDirection( + const QString& nm, + const Point3m& defval, + const QString& desc = QString(), + const QString& tltip = QString(), + bool hidden = false, + const QString& category = QString()); + ~RichDirection(); + + QString stringType() const; + + RichDirection* clone() const; bool operator==(const RichParameter& rb); }; diff --git a/src/common/python/function_parameter.cpp b/src/common/python/function_parameter.cpp index 1dff641d2..c8d32eb4b 100644 --- a/src/common/python/function_parameter.cpp +++ b/src/common/python/function_parameter.cpp @@ -141,7 +141,7 @@ void pymeshlab::FunctionParameter::printDefaultValue(std::ostream& o) const << "[" << v[12] << ", " << v[13] << ", " << v[14] << ", " << v[15] << "]]"; return; } - if (parameter->isOfType()) { + if (parameter->isOfType() || parameter->isOfType()) { o << "[" << parameter->value().getPoint3f().X() << ", " << parameter->value().getPoint3f().Y() << ", " << parameter->value().getPoint3f().Z() << "]"; diff --git a/src/common/python/python_utils.cpp b/src/common/python/python_utils.cpp index ff9d70d63..ed6e452ba 100644 --- a/src/common/python/python_utils.cpp +++ b/src/common/python/python_utils.cpp @@ -44,7 +44,9 @@ QString pymeshlab::computePythonTypeString(const RichParameter& par) return PYTHON_TYPE_STRING; if (par.isOfType()) return PYTHON_TYPE_MATRIX44F; - if (par.isOfType()) + if (par.isOfType()) + return PYTHON_TYPE_POINT3F; + if (par.isOfType()) return PYTHON_TYPE_POINT3F; if (par.isOfType()) return PYTHON_TYPE_SHOTF; diff --git a/src/meshlab/dialogs/options_dialog.cpp b/src/meshlab/dialogs/options_dialog.cpp index f38bd30d4..cbcb79984 100644 --- a/src/meshlab/dialogs/options_dialog.cpp +++ b/src/meshlab/dialogs/options_dialog.cpp @@ -139,7 +139,7 @@ QTableWidgetItem* MeshLabOptionsDialog::createQTableWidgetItemFromRichParameter( assert(0); return nullptr; } - else if (pd.isOfType()){ + else if (pd.isOfType() || pd.isOfType()){ vcg::Point3f pp = pd.value().getPoint3f(); QString pst = "P3(" + QString::number(pp.X()) + "," + QString::number(pp.Y()) + "," + QString::number(pp.Z()) + ")"; return new QTableWidgetItem(pst); diff --git a/src/meshlab/rich_parameter_gui/richparameterlistframe.cpp b/src/meshlab/rich_parameter_gui/richparameterlistframe.cpp index 1a50aaa57..4ea6faa43 100644 --- a/src/meshlab/rich_parameter_gui/richparameterlistframe.cpp +++ b/src/meshlab/rich_parameter_gui/richparameterlistframe.cpp @@ -266,8 +266,11 @@ RichParameterWidget* RichParameterListFrame::createWidgetFromRichParameter( else if (pd.isOfType()){ return new Matrix44fWidget(parent, (const RichMatrix44f&)pd, (const RichMatrix44f&)def, reinterpret_cast(parent)->gla); } - else if (pd.isOfType()){ - return new Point3fWidget(parent, (const RichPoint3f&)pd, (const RichPoint3f&)def, reinterpret_cast(parent)->gla); + else if (pd.isOfType()){ + return new PositionWidget(parent, (const RichPosition&)pd, (const RichPosition&)def, reinterpret_cast(parent)->gla); + } + else if (pd.isOfType()){ + return new DirectionWidget(parent, (const RichDirection&)pd, (const RichDirection&)def, reinterpret_cast(parent)->gla); } else if (pd.isOfType()){ return new ShotfWidget(parent, (const RichShotf&)pd, (const RichShotf&)def, reinterpret_cast(parent)->gla); diff --git a/src/meshlab/rich_parameter_gui/richparameterwidgets.cpp b/src/meshlab/rich_parameter_gui/richparameterwidgets.cpp index b7c9f1be6..6b3006f36 100644 --- a/src/meshlab/rich_parameter_gui/richparameterwidgets.cpp +++ b/src/meshlab/rich_parameter_gui/richparameterwidgets.cpp @@ -458,10 +458,10 @@ void AbsPercWidget::addWidgetToGridLayout( QGridLayout* lay,const int r ) } /******************************************/ -// Point3fWidget Implementation +// PositionWidget Implementation /******************************************/ -Point3fWidget::Point3fWidget(QWidget *p, const RichPoint3f& rpf, const RichPoint3f& rdef, QWidget *gla_curr): +PositionWidget::PositionWidget(QWidget *p, const RichPosition& rpf, const RichPosition& rdef, QWidget *gla_curr): RichParameterWidget(p,rpf, rdef) { //qDebug("Creating a Point3fWidget"); @@ -490,16 +490,7 @@ Point3fWidget::Point3fWidget(QWidget *p, const RichPoint3f& rpf, const RichPoint this->setValue(paramName,rp->value().getPoint3f()); if(gla_curr) // if we have a connection to the current glarea we can setup the additional button for getting the current view direction. { - getPoint3Button = new QPushButton("Get",this); - getPoint3Button->setMaximumWidth(getPoint3Button->sizeHint().width()/2); - - getPoint3Button->setFlat(true); - getPoint3Button->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Preferred); - //getPoint3Button->setMinimumWidth(getPoint3Button->sizeHint().width()); - //this->addWidget(getPoint3Button,0,Qt::AlignHCenter); - vlay->addWidget(getPoint3Button); QStringList names; - names << "View Dir."; names << "View Pos."; names << "Surf. Pos."; names << "Raster Camera Pos."; @@ -511,46 +502,57 @@ Point3fWidget::Point3fWidget(QWidget *p, const RichPoint3f& rpf, const RichPoint //this->addWidget(getPoint3Combo,0,Qt::AlignHCenter); vlay->addWidget(getPoint3Combo); - connect(getPoint3Button,SIGNAL(clicked()),this,SLOT(getPoint())); - connect(getPoint3Combo,SIGNAL(currentIndexChanged(int)),this,SLOT(getPoint())); - connect(gla_curr,SIGNAL(transmitViewDir(QString,Point3m)),this,SLOT(setValue(QString,Point3m))); - connect(gla_curr,SIGNAL(transmitShot(QString,Shotm)),this,SLOT(setShotValue(QString,Shotm))); + //connect(getPoint3Combo,SIGNAL(currentIndexChanged(int)),this,SLOT(getPoint())); connect(gla_curr,SIGNAL(transmitSurfacePos(QString,Point3m)),this,SLOT(setValue(QString,Point3m))); connect(gla_curr,SIGNAL(transmitCameraPos(QString, Point3m)),this,SLOT(setValue(QString, Point3m))); + connect(gla_curr,SIGNAL(transmitShot(QString,Shotm)),this,SLOT(setShotValue(QString,Shotm))); connect(gla_curr,SIGNAL(transmitTrackballPos(QString, Point3m)),this,SLOT(setValue(QString, Point3m))); - connect(this,SIGNAL(askViewDir(QString)),gla_curr,SLOT(sendViewDir(QString))); connect(this,SIGNAL(askViewPos(QString)),gla_curr,SLOT(sendViewerShot(QString))); connect(this,SIGNAL(askSurfacePos(QString)),gla_curr,SLOT(sendSurfacePos(QString))); connect(this,SIGNAL(askCameraPos(QString)),gla_curr,SLOT(sendRasterShot(QString))); connect(this,SIGNAL(askTrackballPos(QString)),gla_curr,SLOT(sendTrackballPos(QString))); + + getPoint3Button = new QPushButton("Get",this); + getPoint3Button->setMaximumWidth(getPoint3Button->sizeHint().width()/2); + + getPoint3Button->setFlat(true); + getPoint3Button->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Preferred); + connect(getPoint3Button,SIGNAL(clicked()),this,SLOT(getPoint())); + + vlay->addWidget(getPoint3Button); } //gridLay->addLayout(lay,row,1,Qt::AlignTop); } -Point3fWidget::~Point3fWidget() +PositionWidget::~PositionWidget() { //qDebug("Deallocating a point3fwidget"); this->disconnect(); } -void Point3fWidget::getPoint() +void PositionWidget::getPoint() { int index = getPoint3Combo->currentIndex(); - //qDebug("Got signal %i",index); switch(index) { - case 0: emit askViewDir(paramName); break; - case 1: emit askViewPos(paramName); break; - case 2: emit askSurfacePos(paramName); break; - case 3: emit askCameraPos(paramName); break; - case 4: emit askTrackballPos(paramName); break; + case 0: + emit askViewPos(paramName); + break; + case 1: + emit askSurfacePos(paramName); + break; + case 2: + emit askCameraPos(paramName); + break; + case 3: + emit askTrackballPos(paramName); + break; default : assert(0); } } -void Point3fWidget::setValue(QString name,Point3m newVal) +void PositionWidget::setValue(QString name,Point3m newVal) { - //qDebug("setValue parametername: %s ", qUtf8Printable(name)); if(name==paramName) { for(int i =0;i<3;++i) @@ -558,35 +560,159 @@ void Point3fWidget::setValue(QString name,Point3m newVal) } } -void Point3fWidget::setShotValue(QString name, Shotm newValShot) +void PositionWidget::setShotValue(QString name, Shotm newValShot) { vcg::Point3f p = newValShot.GetViewPoint(); setValue(name,p); } -vcg::Point3f Point3fWidget::getValue() +vcg::Point3f PositionWidget::getValue() { return vcg::Point3f(coordSB[0]->text().toFloat(),coordSB[1]->text().toFloat(),coordSB[2]->text().toFloat()); } -void Point3fWidget::collectWidgetValue() +void PositionWidget::collectWidgetValue() { rp->setValue(Point3fValue(vcg::Point3f(coordSB[0]->text().toFloat(),coordSB[1]->text().toFloat(),coordSB[2]->text().toFloat()))); } -void Point3fWidget::resetWidgetValue() +void PositionWidget::resetWidgetValue() { for(unsigned int ii = 0; ii < 3;++ii) coordSB[ii]->setText(QString::number(rp->value().getPoint3f()[ii],'g',3)); } -void Point3fWidget::setWidgetValue( const Value& nv ) +void PositionWidget::setWidgetValue( const Value& nv ) { for(unsigned int ii = 0; ii < 3;++ii) coordSB[ii]->setText(QString::number(nv.getPoint3f()[ii],'g',3)); } -void Point3fWidget::addWidgetToGridLayout( QGridLayout* lay,const int r ) +void PositionWidget::addWidgetToGridLayout( QGridLayout* lay,const int r ) +{ + if (lay != NULL) + { + lay->addWidget(descLab,r,0); + lay->addLayout(vlay,r,1); + } + RichParameterWidget::addWidgetToGridLayout(lay,r); +} + +/******************************************/ +// DirectionWidget Implementation +/******************************************/ + +DirectionWidget::DirectionWidget(QWidget *p, const RichDirection& rpf, const RichDirection& rdef, QWidget *gla_curr): + RichParameterWidget(p,rpf, rdef) +{ + paramName = rpf.name(); + descLab = new QLabel(rpf.fieldDescription(),this); + descLab->setToolTip(rpf.fieldDescription()); + + vlay = new QHBoxLayout(); + vlay->setSpacing(0); + for(int i =0;i<3;++i) + { + coordSB[i]= new QLineEdit(this); + QFont baseFont=coordSB[i]->font(); + if(baseFont.pixelSize() != -1) baseFont.setPixelSize(baseFont.pixelSize()*3/4); + else baseFont.setPointSize(baseFont.pointSize()*3/4); + coordSB[i]->setFont(baseFont); + coordSB[i]->setMaximumWidth(coordSB[i]->sizeHint().width()/2); + coordSB[i]->setValidator(new QDoubleValidator()); + coordSB[i]->setAlignment(Qt::AlignRight); + coordSB[i]->setSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Preferred); + vlay->addWidget(coordSB[i]); + connect(coordSB[i],SIGNAL(textChanged(QString)),p,SIGNAL(parameterChanged())); + } + this->setValue(paramName,rp->value().getPoint3f()); + if(gla_curr) // if we have a connection to the current glarea we can setup the additional button for getting the current view direction. + { + QStringList names; + names << "View Dir."; + names << "Raster Camera Dir."; + + getPoint3Combo = new QComboBox(this); + getPoint3Combo->addItems(names); + vlay->addWidget(getPoint3Combo); + + //connect(getPoint3Combo,SIGNAL(currentIndexChanged(int)),this,SLOT(getPoint())); + connect(gla_curr,SIGNAL(transmitViewDir(QString,Point3m)),this,SLOT(setValue(QString,Point3m))); + connect(gla_curr,SIGNAL(transmitShot(QString,Shotm)),this,SLOT(setShotValue(QString,Shotm))); + connect(this,SIGNAL(askViewDir(QString)),gla_curr,SLOT(sendViewDir(QString))); + connect(this,SIGNAL(askCameraDir(QString)),gla_curr,SLOT(sendRasterShot(QString))); + + getPoint3Button = new QPushButton("Get",this); + getPoint3Button->setMaximumWidth(getPoint3Button->sizeHint().width()/2); + + getPoint3Button->setFlat(true); + getPoint3Button->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Preferred); + connect(getPoint3Button,SIGNAL(clicked()),this,SLOT(getPoint())); + + vlay->addWidget(getPoint3Button); + } +} + +DirectionWidget::~DirectionWidget() +{ + //qDebug("Deallocating a point3fwidget"); + this->disconnect(); +} + +void DirectionWidget::getPoint() +{ + int index = getPoint3Combo->currentIndex(); + switch(index) + { + case 0: + emit askViewDir(paramName); + break; + case 1: + emit askCameraDir(paramName); + break; + + default : assert(0); + } +} + +void DirectionWidget::setValue(QString name,Point3m newVal) +{ + if(name==paramName) + { + for(int i =0;i<3;++i) + coordSB[i]->setText(QString::number(newVal[i],'g',4)); + } +} + +void DirectionWidget::setShotValue(QString name, Shotm newValShot) +{ + vcg::Point3f p = newValShot.GetViewDir(); + setValue(name,p); +} + +vcg::Point3f DirectionWidget::getValue() +{ + return vcg::Point3f(coordSB[0]->text().toFloat(),coordSB[1]->text().toFloat(),coordSB[2]->text().toFloat()); +} + +void DirectionWidget::collectWidgetValue() +{ + rp->setValue(Point3fValue(vcg::Point3f(coordSB[0]->text().toFloat(),coordSB[1]->text().toFloat(),coordSB[2]->text().toFloat()))); +} + +void DirectionWidget::resetWidgetValue() +{ + for(unsigned int ii = 0; ii < 3;++ii) + coordSB[ii]->setText(QString::number(rp->value().getPoint3f()[ii],'g',3)); +} + +void DirectionWidget::setWidgetValue( const Value& nv ) +{ + for(unsigned int ii = 0; ii < 3;++ii) + coordSB[ii]->setText(QString::number(nv.getPoint3f()[ii],'g',3)); +} + +void DirectionWidget::addWidgetToGridLayout( QGridLayout* lay,const int r ) { if (lay != NULL) { diff --git a/src/meshlab/rich_parameter_gui/richparameterwidgets.h b/src/meshlab/rich_parameter_gui/richparameterwidgets.h index ba2f03afd..b8d6a5335 100644 --- a/src/meshlab/rich_parameter_gui/richparameterwidgets.h +++ b/src/meshlab/rich_parameter_gui/richparameterwidgets.h @@ -196,12 +196,12 @@ protected: QGridLayout* vlay; }; -class Point3fWidget : public RichParameterWidget +class PositionWidget : public RichParameterWidget { Q_OBJECT public: - Point3fWidget(QWidget *p, const RichPoint3f& rpf, const RichPoint3f& rdef, QWidget *gla); - ~Point3fWidget(); + PositionWidget(QWidget *p, const RichPosition& rpf, const RichPosition& rdef, QWidget *gla); + ~PositionWidget(); QString paramName; vcg::Point3f getValue(); @@ -215,7 +215,6 @@ public: void setValue(QString name, Point3m val); void setShotValue(QString name, Shotm val); signals: - void askViewDir(QString); void askViewPos(QString); void askSurfacePos(QString); void askCameraPos(QString); @@ -229,6 +228,36 @@ protected: QHBoxLayout* vlay; }; +class DirectionWidget : public RichParameterWidget +{ + Q_OBJECT +public: + DirectionWidget(QWidget *p, const RichDirection& rpf, const RichDirection& rdef, QWidget *gla); + ~DirectionWidget(); + QString paramName; + vcg::Point3f getValue(); + + void addWidgetToGridLayout(QGridLayout* lay,const int r); + void collectWidgetValue(); + void resetWidgetValue(); + void setWidgetValue(const Value& nv); + +public slots: + void getPoint(); + void setValue(QString name, Point3m val); + void setShotValue(QString name, Shotm val); +signals: + void askViewDir(QString); + void askCameraDir(QString); + +protected: + QLineEdit * coordSB[3]; + QComboBox *getPoint3Combo; + QPushButton *getPoint3Button; + QLabel* descLab; + QHBoxLayout* vlay; +}; + class Matrix44fWidget : public RichParameterWidget { Q_OBJECT diff --git a/src/meshlabplugins/filter_ao/filter_ao.cpp b/src/meshlabplugins/filter_ao/filter_ao.cpp index bf51531ab..3d6c6fea7 100644 --- a/src/meshlabplugins/filter_ao/filter_ao.cpp +++ b/src/meshlabplugins/filter_ao/filter_ao.cpp @@ -135,7 +135,7 @@ RichParameterList AmbientOcclusionPlugin::initParameterList(const QAction *actio " - 1 means that all the light cames from the specified cone of directions
" " - other values mix the two set of lighting directions ")); parlst.addParam(RichInt ("reqViews",AMBOCC_DEFAULT_NUM_VIEWS,"Requested views", "Number of different views uniformly placed around the mesh. More views means better accuracy at the cost of increased calculation time")); - parlst.addParam(RichPoint3f("coneDir",Point3m(0,1,0),"Lighting Direction", "Number of different views placed around the mesh. More views means better accuracy at the cost of increased calculation time")); + parlst.addParam(RichDirection("coneDir",Point3m(0,1,0),"Lighting Direction", "Number of different views placed around the mesh. More views means better accuracy at the cost of increased calculation time")); parlst.addParam(RichFloat("coneAngle",30,"Cone amplitude", "Number of different views uniformly placed around the mesh. More views means better accuracy at the cost of increased calculation time")); parlst.addParam(RichBool("useGPU",AMBOCC_USEGPU_BY_DEFAULT,"Use GPU acceleration","Only works for per-vertex AO. In order to use GPU-Mode, your hardware must support FBOs, FP32 Textures and Shaders. Normally increases the performance by a factor of 4x-5x")); //parlst.addParam(RichBool("useVBO",AMBOCC_USEVBO_BY_DEFAULT,"Use VBO if supported","By using VBO, Meshlab loads all the vertex structure in the VRam, greatly increasing rendering speed (for both CPU and GPU mode). Disable it if problem occurs")); diff --git a/src/meshlabplugins/filter_camera/filter_camera.cpp b/src/meshlabplugins/filter_camera/filter_camera.cpp index 382d4ae5c..01722f4d1 100644 --- a/src/meshlabplugins/filter_camera/filter_camera.cpp +++ b/src/meshlabplugins/filter_camera/filter_camera.cpp @@ -112,8 +112,8 @@ RichParameterList FilterCameraPlugin::initParameterList(const QAction *action, c rotCenter.push_back("custom point"); parlst.addParam(RichEnum("rotCenter", 0, rotCenter, tr("Center of rotation:"), tr("Choose a method"))); parlst.addParam(RichDynamicFloat("angle",0,-360,360,"Rotation Angle","Angle of rotation (in degree). If snapping is enabled this value is rounded according to the snap value")); - parlst.addParam(RichPoint3f("customAxis",Point3m(0,0,0),"Custom axis","This rotation axis is used only if the 'custom axis' option is chosen.")); - parlst.addParam(RichPoint3f("customCenter",Point3m(0,0,0),"Custom center","This rotation center is used only if the 'custom point' option is chosen.")); + parlst.addParam(RichDirection("customAxis",Point3m(0,0,0),"Custom axis","This rotation axis is used only if the 'custom axis' option is chosen.")); + parlst.addParam(RichPosition("customCenter",Point3m(0,0,0),"Custom center","This rotation center is used only if the 'custom point' option is chosen.")); parlst.addParam(RichBool ("toallRaster", false, "Apply to all active Raster layers", "Apply the same scaling to all the active Raster layers: it is taken into account only if 'Raster Camera' is selected")); parlst.addParam(RichBool ("toall", false, "Apply to all active Raster and visible Mesh layers", "Apply the same scaling to all the layers, including any visible 3D layer")); } @@ -129,7 +129,7 @@ RichParameterList FilterCameraPlugin::initParameterList(const QAction *action, c scaleCenter.push_back("camera viewpoint"); scaleCenter.push_back("custom point"); parlst.addParam(RichEnum("scaleCenter", 0, scaleCenter, tr("Center of scaling:"), tr("Choose a method"))); - parlst.addParam(RichPoint3f("customCenter",Point3m(0,0,0),"Custom center","This scaling center is used only if the 'custom point' option is chosen.")); + parlst.addParam(RichPosition("customCenter",Point3m(0,0,0),"Custom center","This scaling center is used only if the 'custom point' option is chosen.")); parlst.addParam(RichFloat("scale", 1.0, "Scale factor", "The scale factor that has to be applied to the camera")); parlst.addParam(RichBool ("toallRaster", false, "Apply to all active Raster layers", "Apply the same scaling to all the active Raster layers: it is taken into account only if 'Raster Camera' is selected")); parlst.addParam(RichBool ("toall", false, "Apply to all active Raster and visible Mesh layers", "Apply the same scaling to all the layers, including any visible 3D layer")); diff --git a/src/meshlabplugins/filter_colorproc/filter_colorproc.cpp b/src/meshlabplugins/filter_colorproc/filter_colorproc.cpp index 19fa2d0a8..b1ca3062d 100644 --- a/src/meshlabplugins/filter_colorproc/filter_colorproc.cpp +++ b/src/meshlabplugins/filter_colorproc/filter_colorproc.cpp @@ -281,7 +281,7 @@ RichParameterList FilterColorProc::initParameterList(const QAction *a, const Mes par.addParam(RichColor("color1", color1, "Color 1:", "Sets the first color to mix with Perlin Noise function.")); par.addParam(RichColor("color2", color2, "Color 2:", "Sets the second color to mix with Perlin Noise function.")); par.addParam(RichDynamicFloat("freq", 10.0f, 0.1f, 100.0f,"Frequency:","Frequency of the Perlin Noise function, expressed as multiples of mesh bbox (frequency 10 means a noise period of bbox diagonal / 10). High frequencies produces many small splashes of colours, while low frequencies produces few big splashes.")); - par.addParam(RichPoint3f("offset", Point3f(0.0f, 0.0f, 0.0f), "Offset", "This values is the XYZ frequency offset of the Noise function (offset 1 means 1 period shift).")); + par.addParam(RichPosition("offset", Point3f(0.0f, 0.0f, 0.0f), "Offset", "This values is the XYZ frequency offset of the Noise function (offset 1 means 1 period shift).")); par.addParam(RichBool("onSelected", false, "Only on selection", "If checked, only affects selected vertices")); break; } diff --git a/src/meshlabplugins/filter_dirt/filter_dirt.cpp b/src/meshlabplugins/filter_dirt/filter_dirt.cpp index 9d4c49c2d..562ddb172 100644 --- a/src/meshlabplugins/filter_dirt/filter_dirt.cpp +++ b/src/meshlabplugins/filter_dirt/filter_dirt.cpp @@ -105,7 +105,7 @@ RichParameterList FilterDirt::initParameterList(const QAction* filter, const Mes switch(ID(filter)){ case FP_DIRT:{ - par.addParam(RichPoint3f("dust_dir", Point3m(0, 1, 0), "Direction", "Direction of the dust source")); + par.addParam(RichDirection("dust_dir", Point3m(0, 1, 0), "Direction", "Direction of the dust source")); par.addParam(RichInt("nparticles", 3, "max particles x face", "Max Number of Dust Particles to Generate Per Face")); par.addParam(RichFloat("slippiness", 1.0f, "s", "The surface slippines(large s means less sticky)")); par.addParam(RichFloat("adhesion", 0.2f, "k", "Factor to model the general adhesion")); @@ -114,8 +114,8 @@ RichParameterList FilterDirt::initParameterList(const QAction* filter, const Mes break; } case FP_CLOUD_MOVEMENT:{ - par.addParam(RichPoint3f("gravity_dir", Point3m(0, -1, 0), "g", "Direction of gravity")); - par.addParam(RichPoint3f("force_dir", Point3m(0, 0, 0), "force", "Direction of the force acting on the points cloud")); + par.addParam(RichDirection("gravity_dir", Point3m(0, -1, 0), "g", "Direction of gravity")); + par.addParam(RichDirection("force_dir", Point3m(0, 0, 0), "force", "Direction of the force acting on the points cloud")); par.addParam(RichInt("steps", 1, "s", "Simulation Steps")); par.addParam(RichDynamicFloat("adhesion", 1.0f, 0.0f, 1.0f, "adhesion", "Factor to model the general adhesion.")); par.addParam(RichFloat("velocity", 0, "v", "Initial velocity of the particle")); diff --git a/src/meshlabplugins/filter_geodesic/filter_geodesic.cpp b/src/meshlabplugins/filter_geodesic/filter_geodesic.cpp index c77c43dad..8336c0066 100644 --- a/src/meshlabplugins/filter_geodesic/filter_geodesic.cpp +++ b/src/meshlabplugins/filter_geodesic/filter_geodesic.cpp @@ -238,7 +238,7 @@ RichParameterList FilterGeodesic::initParameterList(const QAction *action, const switch(ID(action)) { case FP_QUALITY_POINT_GEODESIC : - parlst.addParam(RichPoint3f("startPoint",m.cm.bbox.min,"Starting point","The starting point from which geodesic distance has to be computed. If it is not a surface vertex, the closest vertex to the specified point is used as starting seed point.")); + parlst.addParam(RichPosition("startPoint",m.cm.bbox.min,"Starting point","The starting point from which geodesic distance has to be computed. If it is not a surface vertex, the closest vertex to the specified point is used as starting seed point.")); parlst.addParam(RichAbsPerc("maxDistance",m.cm.bbox.Diag(),0,m.cm.bbox.Diag()*2,"Max Distance","If not zero it indicates a cut off value to be used during geodesic distance computation.")); break; case FP_QUALITY_SELECTED_GEODESIC : diff --git a/src/meshlabplugins/filter_io_nxs/filter_io_nxs.cpp b/src/meshlabplugins/filter_io_nxs/filter_io_nxs.cpp index aae47d0eb..fdabe4a80 100644 --- a/src/meshlabplugins/filter_io_nxs/filter_io_nxs.cpp +++ b/src/meshlabplugins/filter_io_nxs/filter_io_nxs.cpp @@ -261,7 +261,7 @@ RichParameterList FilterIONXSPlugin::nxsParameters() const params.addParam(RichInt("skiplevels", 0, "Skip levels", "Decimation skipped for n levels. Use for meshes with large textures " "and very few vertices.")); - params.addParam(RichPoint3f("origin", Point3m(0,0,0), "Origin", "new origin for the model")); + params.addParam(RichPosition("origin", Point3m(0,0,0), "Origin", "new origin for the model")); params.addParam(RichBool("center", false, "Center", "Set origin in the bounding box center", true)); params.addParam(RichBool("pow_2_textures", false, "Pow 2 textures", "Create textures to be power of 2", true)); params.addParam(RichBool("deepzoom", false, "Deepzoom", diff --git a/src/meshlabplugins/filter_meshing/meshfilter.cpp b/src/meshlabplugins/filter_meshing/meshfilter.cpp index 93ba76137..c3f69f090 100644 --- a/src/meshlabplugins/filter_meshing/meshfilter.cpp +++ b/src/meshlabplugins/filter_meshing/meshfilter.cpp @@ -534,8 +534,8 @@ RichParameterList ExtraMeshFilterPlugin::initParameterList(const QAction * actio rotCenter.push_back("custom point"); parlst.addParam(RichEnum("rotCenter", 0, rotCenter, tr("Center of rotation:"), tr("Choose a method"))); parlst.addParam(RichDynamicFloat("angle",0,-360,360,"Rotation Angle","Angle of rotation (in degree). If snapping is enabled this value is rounded according to the snap value")); - parlst.addParam(RichPoint3f("customAxis",Point3f(0,0,0),"Custom axis","This rotation axis is used only if the 'custom axis' option is chosen.")); - parlst.addParam(RichPoint3f("customCenter",Point3f(0,0,0),"Custom center","This rotation center is used only if the 'custom point' option is chosen.")); + parlst.addParam(RichDirection("customAxis",Point3f(0,0,0),"Custom axis","This rotation axis is used only if the 'custom axis' option is chosen.")); + parlst.addParam(RichPosition("customCenter",Point3f(0,0,0),"Custom center","This rotation center is used only if the 'custom point' option is chosen.")); parlst.addParam(RichBool("snapFlag", false, "Snap angle", "If selected, before starting the filter will remove any unreferenced vertex (for which curvature values are not defined)")); parlst.addParam(RichFloat("snapAngle",30,"Snapping Value","This value is used to snap the rotation angle (i.e. if the snapping value is 30, 227 becomes 210).")); parlst.addParam(RichBool ("Freeze",true,"Freeze Matrix","The transformation is explicitly applied, and the vertex coordinates are actually changed")); @@ -561,7 +561,7 @@ RichParameterList ExtraMeshFilterPlugin::initParameterList(const QAction * actio parlst.addParam(RichDynamicFloat("axisX",0,-5.0*bb.Diag(),5.0*bb.Diag(),"X Axis","when using [XYZ translation], amount of translation along the X axis (in model units)")); parlst.addParam(RichDynamicFloat("axisY",0,-5.0*bb.Diag(),5.0*bb.Diag(),"Y Axis","when using [XYZ translation], amount of translation along the Y axis (in model units)")); parlst.addParam(RichDynamicFloat("axisZ",0,-5.0*bb.Diag(),5.0*bb.Diag(),"Z Axis","when using [XYZ translation], amount of translation along the Z axis (in model units)")); - parlst.addParam(RichPoint3f("newOrigin", Point3f(0, 0, 0), "New Origin:", "when using [Set new Origin], this is the location of the new Origin.")); + parlst.addParam(RichPosition("newOrigin", Point3f(0, 0, 0), "New Origin:", "when using [Set new Origin], this is the location of the new Origin.")); parlst.addParam(RichBool ("Freeze",true,"Freeze Matrix","The transformation is explicitly applied, and the vertex coordinates are actually changed")); parlst.addParam(RichBool ("allLayers",false,"Apply to all visible Layers","If selected the filter will be applied to all visible mesh layers")); } @@ -578,7 +578,7 @@ RichParameterList ExtraMeshFilterPlugin::initParameterList(const QAction * actio scaleCenter.push_back("barycenter"); scaleCenter.push_back("custom point"); parlst.addParam(RichEnum("scaleCenter", 0, scaleCenter, tr("Center of scaling:"), tr("Choose a method"))); - parlst.addParam(RichPoint3f("customCenter",Point3f(0,0,0),"Custom center","This scaling center is used only if the 'custom point' option is chosen.")); + parlst.addParam(RichPosition("customCenter",Point3f(0,0,0),"Custom center","This scaling center is used only if the 'custom point' option is chosen.")); parlst.addParam(RichBool("unitFlag",false,"Scale to Unit bbox","If selected, the object is scaled to a box whose sides are at most 1 unit length")); parlst.addParam(RichBool ("Freeze",true,"Freeze Matrix","The transformation is explicitly applied, and the vertex coordinates are actually changed")); parlst.addParam(RichBool ("allLayers",false,"Apply to all visible Layers","If selected the filter will be applied to all visible mesh layers")); @@ -599,7 +599,7 @@ RichParameterList ExtraMeshFilterPlugin::initParameterList(const QAction * actio parlst.addParam(RichInt ("K",(int)10,"Neighbour num","The number of neighbors used to estimate normals.")); parlst.addParam(RichInt ("smoothIter",0,"Smooth Iteration","The number of smoothing iteration done on the p used to estimate and propagate normals.")); parlst.addParam(RichBool("flipFlag",false,"Flip normals w.r.t. viewpoint","If the 'viewpoint' (i.e. scanner position) is known, it can be used to disambiguate normals orientation, so that all the normals will be oriented in the same direction.")); - parlst.addParam(RichPoint3f("viewPos",m.cm.shot.Extrinsics.Tra(),"Viewpoint Pos.","The viewpoint position can be set by hand (i.e. getting the current viewpoint) or it can be retrieved from mesh camera, if the viewpoint position is stored there.")); + parlst.addParam(RichDirection("viewPos",m.cm.shot.Extrinsics.Tra(),"Viewpoint Pos.","The viewpoint position can be set by hand (i.e. getting the current viewpoint) or it can be retrieved from mesh camera, if the viewpoint position is stored there.")); break; case FP_NORMAL_SMOOTH_POINTCLOUD: @@ -625,7 +625,7 @@ RichParameterList ExtraMeshFilterPlugin::initParameterList(const QAction * actio { QStringList axis = QStringList() <<"X Axis"<<"Y Axis"<<"Z Axis"<<"Custom Axis"; parlst.addParam(RichEnum ("planeAxis", 0, axis, tr("Plane perpendicular to"), tr("The Slicing plane will be done perpendicular to the axis"))); - parlst.addParam(RichPoint3f("customAxis",Point3f(0,1,0),"Custom axis","Specify a custom axis, this is only valid if the above parameter is set to Custom")); + parlst.addParam(RichDirection("customAxis",Point3f(0,1,0),"Custom axis","Specify a custom axis, this is only valid if the above parameter is set to Custom")); parlst.addParam(RichFloat ("planeOffset", 0.0, "Cross plane offset", "Specify an offset of the cross-plane. The offset corresponds to the distance from the point specified in the plane reference parameter. By default (Cross plane offset == 0)")); parlst.addParam(RichEnum ("relativeTo",2,QStringList()<<"Bounding box center"<<"Bounding box min"<<"Origin","plane reference","Specify the reference from which the planes are shifted")); parlst.addParam(RichBool("createSectionSurface",false,"Create also section surface","If selected, in addition to a layer with the section polyline, it will be created also a layer with a triangulated version of the section polyline. This only works if the section polyline is closed")); diff --git a/src/meshlabplugins/filter_qhull/filter_qhull.cpp b/src/meshlabplugins/filter_qhull/filter_qhull.cpp index 50cd8f306..e34396bea 100644 --- a/src/meshlabplugins/filter_qhull/filter_qhull.cpp +++ b/src/meshlabplugins/filter_qhull/filter_qhull.cpp @@ -182,7 +182,7 @@ RichParameterList QhullPlugin::initParameterList(const QAction *action,const Mes false, "Use ViewPoint from Mesh Camera", "Uses the ViewPoint from the camera associated to the current mesh\n if there is no camera, an error occurs")); - parlst.addParam(RichPoint3f("viewpoint", + parlst.addParam(RichDirection("viewpoint", Point3f(0.0f, 0.0f, 0.0f), "ViewPoint", "if UseCamera is true, this value is ignored")); diff --git a/src/meshlabplugins/filter_select/meshselect.cpp b/src/meshlabplugins/filter_select/meshselect.cpp index 5ccbfb28e..65ef6410b 100644 --- a/src/meshlabplugins/filter_select/meshselect.cpp +++ b/src/meshlabplugins/filter_select/meshselect.cpp @@ -211,7 +211,7 @@ RichParameterList SelectionFilterPlugin::initParameterList(const QAction *action { parlst.addParam(RichDynamicFloat("anglelimit", 75.0f, 0.0f, 180.0f, "angle threshold (deg)", "faces with normal at higher angle w.r.t. the view direction are selected")); parlst.addParam(RichBool ("usecamera", false, "Use ViewPoint from Mesh Camera", "Uses the ViewPoint from the camera associated to the current mesh\n if there is no camera, an error occurs")); - parlst.addParam(RichPoint3f("viewpoint", Point3f(0.0f, 0.0f, 0.0f), "ViewPoint", "if UseCamera is true, this value is ignored")); + parlst.addParam(RichDirection("viewpoint", Point3f(0.0f, 0.0f, 0.0f), "ViewPoint", "if UseCamera is true, this value is ignored")); } break; case FP_SELECT_UGLY : diff --git a/src/meshlabplugins/filter_unsharp/filter_unsharp.cpp b/src/meshlabplugins/filter_unsharp/filter_unsharp.cpp index 988002e4f..f874dac41 100644 --- a/src/meshlabplugins/filter_unsharp/filter_unsharp.cpp +++ b/src/meshlabplugins/filter_unsharp/filter_unsharp.cpp @@ -359,7 +359,7 @@ RichParameterList FilterUnsharp::initParameterList(const QAction *action, const break; case FP_DEPTH_SMOOTH: parlst.addParam(RichInt ("stepSmoothNum", (int) 3,"Smoothing steps", "The number of times that the whole algorithm (normal smoothing + vertex fitting) is iterated.")); - parlst.addParam(RichPoint3f ("viewPoint", Point3f(0,0,0),"Viewpoint", "The position of the view point that is used to get the constraint direction.")); + parlst.addParam(RichDirection ("viewPoint", Point3f(0,0,0),"Viewpoint", "The position of the view point that is used to get the constraint direction.")); parlst.addParam(RichAbsPerc ("delta", 1.0, 0, 1.0, "Strength", "How much smoothing is applied: 0 (no smooth) e 1 (full smooth)")); parlst.addParam(RichBool ("Selected",md.mm()->cm.sfn>0,"Affect only selection","If checked the filter is performed only on the selected area")); break; @@ -369,7 +369,7 @@ RichParameterList FilterUnsharp::initParameterList(const QAction *action, const tr("Step:"), tr("The purpose of this filter is to constrain any smoothing algorithm to moving vertices only along a give line of sight.
First you should store current vertex position, than after applying one of the many smoothing algorithms you should re start this filter and blend the original positions with the smoothed results.
" "Given a view point vp , the smoothed vertex position vs and the original position v, The new vertex position is computed as the projection of vs on the line connecting v and vp."))); - parlst.addParam(RichPoint3f ("viewPoint", Point3f(0,0,0),"Viewpoint", "The position of the view point that is used to get the constraint direction.")); + parlst.addParam(RichDirection ("viewPoint", Point3f(0,0,0),"Viewpoint", "The position of the view point that is used to get the constraint direction.")); parlst.addParam(RichBool ("Selected",md.mm()->cm.sfn>0,"Affect only selected faces","If checked the filter is performed only on the selected faces")); break; case FP_TAUBIN_SMOOTH: @@ -397,8 +397,8 @@ RichParameterList FilterUnsharp::initParameterList(const QAction *action, const } break; case FP_SCALAR_HARMONIC_FIELD: - parlst.addParam(RichPoint3f("point1", md.mm()->cm.bbox.min, "Point 1", "A vertex on the mesh that represent one harmonic field boundary condition.")); - parlst.addParam(RichPoint3f("point2", md.mm()->cm.bbox.max, "Point 2", "A vertex on the mesh that represent one harmonic field boundary condition.")); + parlst.addParam(RichPosition("point1", md.mm()->cm.bbox.min, "Point 1", "A vertex on the mesh that represent one harmonic field boundary condition.")); + parlst.addParam(RichPosition("point2", md.mm()->cm.bbox.max, "Point 2", "A vertex on the mesh that represent one harmonic field boundary condition.")); parlst.addParam(RichDynamicFloat("value1", 0.0f, 0.0f, 1.0f, "value for the 1st point", "Harmonic field value for the vertex.")); parlst.addParam(RichDynamicFloat("value2", 1.0f, 0.0f, 1.0f, "value for the 2nd point", "Harmonic field value for the vertex.")); parlst.addParam(RichBool("colorize", true, "Colorize", "Colorize the mesh to provide an indication of the obtained harmonic field.")); diff --git a/src/meshlabplugins/io_u3d/io_u3d.cpp b/src/meshlabplugins/io_u3d/io_u3d.cpp index d9b70b695..bf9b876ed 100644 --- a/src/meshlabplugins/io_u3d/io_u3d.cpp +++ b/src/meshlabplugins/io_u3d/io_u3d.cpp @@ -189,9 +189,9 @@ RichParameterList U3DIOPlugin::initSaveParameter(const QString &, const MeshMode m.cm.bbox.Center(),m.cm.bbox.Diag()); Point3m pos = _param._campar->_obj_pos; Point3m dir(0.0f,0.0f,-1.0f * _param._campar->_obj_bbox_diag); - par.addParam(RichPoint3f("position_val",dir, "Camera Position", + par.addParam(RichPosition("position_val",dir, "Camera Position", "The position in which the camera is set. The default value is derived by the 3d mesh's bounding box.")); - par.addParam(RichPoint3f("target_val",pos, "Camera target point", + par.addParam(RichDirection("target_val",pos, "Camera target point", "The point towards the camera is seeing. The default value is derived by the 3d mesh's bounding box.")); par.addParam(RichFloat("fov_val",60.0f, "Camera's FOV Angle 0..180","Camera's FOV Angle. The values' range is between 0-180 degree. The default value is 60.")); From 43a8430962bd26287617f85deece569553b3a743 Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Thu, 9 Sep 2021 17:43:49 +0200 Subject: [PATCH 15/22] adjust backwards compatibility of scripts for RichPosition and RichDirection --- src/common/parameters/rich_parameter.cpp | 32 +++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/common/parameters/rich_parameter.cpp b/src/common/parameters/rich_parameter.cpp index b728863af..1f32cc5ba 100644 --- a/src/common/parameters/rich_parameter.cpp +++ b/src/common/parameters/rich_parameter.cpp @@ -855,7 +855,7 @@ bool RichParameterAdapter::create( const QDomElement& np,RichParameter** par ) return true; } - if(type=="RichPoint3f") { + if(type=="RichPoint3f") { // for backward compatibility vcg::Point3f val; val[0]=np.attribute("x").toFloat(&corrconv); if (!corrconv) @@ -870,6 +870,36 @@ bool RichParameterAdapter::create( const QDomElement& np,RichParameter** par ) *par = new RichPosition(name, val,desc,tooltip); return true; } + if(type=="RichPosition") { // for backward compatibility + vcg::Point3f val; + val[0]=np.attribute("x").toFloat(&corrconv); + if (!corrconv) + return false; + val[1]=np.attribute("y").toFloat(&corrconv); + if (!corrconv) + return false; + val[2]=np.attribute("z").toFloat(&corrconv); + if (!corrconv) + return false; + + *par = new RichPosition(name, val,desc,tooltip); + return true; + } + if(type=="RichDirection") { // for backward compatibility + vcg::Point3f val; + val[0]=np.attribute("x").toFloat(&corrconv); + if (!corrconv) + return false; + val[1]=np.attribute("y").toFloat(&corrconv); + if (!corrconv) + return false; + val[2]=np.attribute("z").toFloat(&corrconv); + if (!corrconv) + return false; + + *par = new RichDirection(name, val,desc,tooltip); + return true; + } if(type=="RichShotf") { Shotm val; assert(0); //TODO!!!! From f6b7143836ca59b1e65652d0c5a5192bb591951f Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Fri, 10 Sep 2021 11:17:42 +0200 Subject: [PATCH 16/22] using vertical scroll area in save dialog --- .../dialogs/save_mesh_attributes_dialog.cpp | 15 +++-- .../dialogs/save_mesh_attributes_dialog.ui | 63 +++++++++++++++++-- 2 files changed, 66 insertions(+), 12 deletions(-) diff --git a/src/meshlab/dialogs/save_mesh_attributes_dialog.cpp b/src/meshlab/dialogs/save_mesh_attributes_dialog.cpp index f6c5cfdd0..21f14cd69 100644 --- a/src/meshlab/dialogs/save_mesh_attributes_dialog.cpp +++ b/src/meshlab/dialogs/save_mesh_attributes_dialog.cpp @@ -55,16 +55,20 @@ SaveMeshAttributesDialog::SaveMeshAttributesDialog( QFileInfo fi(m->fullName()); this->setWindowTitle("Choose Saving Options for: '"+ fi.baseName() +"'"); // Show the additional parameters only for formats that have some. - if(additionalSaveParametrs.isEmpty()) + if(additionalSaveParametrs.isEmpty()) { ui->saveParBox->hide(); - else + } + else { ui->saveParBox->show(); + ui->scrollArea->setMinimumSize(ui->scrollArea->width(), ui->saveParBox->sizeHint().height()); + ui->scrollArea->adjustSize(); + updateGeometry(); + } //all - none ui->AllButton->setChecked(true); //ui->NoneButton->setChecked(true); - if( m->cm.textures.size() == 0 ) - { + if( m->cm.textures.size() == 0 ) { ui->check_iom_wedgtexcoord->setDisabled(true); ui->check_iom_wedgtexcoord->setChecked(false); ui->saveTextureCheckBox->setDisabled(true); @@ -73,8 +77,7 @@ SaveMeshAttributesDialog::SaveMeshAttributesDialog( } textureNames.reserve(m->cm.textures.size()); - for(const std::string& tname : m->cm.textures) - { + for(const std::string& tname : m->cm.textures) { textureNames.push_back(tname); QString item(tname.c_str()); ui->listTextureName->addItem(item); diff --git a/src/meshlab/dialogs/save_mesh_attributes_dialog.ui b/src/meshlab/dialogs/save_mesh_attributes_dialog.ui index 261247d1e..c86eaa65f 100644 --- a/src/meshlab/dialogs/save_mesh_attributes_dialog.ui +++ b/src/meshlab/dialogs/save_mesh_attributes_dialog.ui @@ -306,15 +306,58 @@ - - - Additional Parameters + + + QFrame::NoFrame + + QFrame::Plain + + + true + + + + + 0 + 0 + 669 + 68 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + Additional Parameters + + + + + - - - @@ -412,6 +455,14 @@ + + + VerticalScrollArea + QScrollArea +
gui_utils/vertical_scroll_area.h
+ 1 +
+
From 19678302b8983342c303b202af3ceb035439a755 Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Mon, 13 Sep 2021 10:10:26 +0200 Subject: [PATCH 17/22] better graphic for RichPosition and RichDirection, label description for RichBool --- .../richparameterwidgets.cpp | 31 ++++++++++--------- .../rich_parameter_gui/richparameterwidgets.h | 2 ++ 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/meshlab/rich_parameter_gui/richparameterwidgets.cpp b/src/meshlab/rich_parameter_gui/richparameterwidgets.cpp index 6b3006f36..ff2d0f751 100644 --- a/src/meshlab/rich_parameter_gui/richparameterwidgets.cpp +++ b/src/meshlab/rich_parameter_gui/richparameterwidgets.cpp @@ -97,7 +97,9 @@ void RichParameterWidget::addWidgetToGridLayout( QGridLayout* lay, const int r) BoolWidget::BoolWidget(QWidget* p, const RichBool& rb , const RichBool& rdef) : RichParameterWidget(p,rb, rdef) { - cb = new QCheckBox(rp->fieldDescription(),this); + descriptionLabel = new QLabel(rp->fieldDescription(),this); + cb = new QCheckBox("",this); + descriptionLabel->setToolTip(rp->toolTip()); cb->setToolTip(rp->toolTip()); cb->setChecked(rp->value().getBool()); @@ -125,8 +127,10 @@ void BoolWidget::setWidgetValue( const Value& nv ) void BoolWidget::addWidgetToGridLayout(QGridLayout* lay,const int r) { - if (lay !=NULL) - lay->addWidget(cb,r,0,1,2); + if (lay !=NULL){ + lay->addWidget(descriptionLabel, r, 0); + lay->addWidget(cb,r,1); + } RichParameterWidget::addWidgetToGridLayout(lay,r); } @@ -464,12 +468,9 @@ void AbsPercWidget::addWidgetToGridLayout( QGridLayout* lay,const int r ) PositionWidget::PositionWidget(QWidget *p, const RichPosition& rpf, const RichPosition& rdef, QWidget *gla_curr): RichParameterWidget(p,rpf, rdef) { - //qDebug("Creating a Point3fWidget"); paramName = rpf.name(); - //int row = gridLay->rowCount() - 1; descLab = new QLabel(rpf.fieldDescription(),this); descLab->setToolTip(rpf.fieldDescription()); - //gridLay->addWidget(descLab,row,0); vlay = new QHBoxLayout(); vlay->setSpacing(0); @@ -483,7 +484,7 @@ PositionWidget::PositionWidget(QWidget *p, const RichPosition& rpf, const RichPo coordSB[i]->setMaximumWidth(coordSB[i]->sizeHint().width()/2); coordSB[i]->setValidator(new QDoubleValidator()); coordSB[i]->setAlignment(Qt::AlignRight); - coordSB[i]->setSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Preferred); + coordSB[i]->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred); vlay->addWidget(coordSB[i]); connect(coordSB[i],SIGNAL(textChanged(QString)),p,SIGNAL(parameterChanged())); } @@ -498,8 +499,7 @@ PositionWidget::PositionWidget(QWidget *p, const RichPosition& rpf, const RichPo getPoint3Combo = new QComboBox(this); getPoint3Combo->addItems(names); - //getPoint3Combo->setMinimumWidth(getPoint3Combo->sizeHint().width()); - //this->addWidget(getPoint3Combo,0,Qt::AlignHCenter); + getPoint3Combo->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Preferred); vlay->addWidget(getPoint3Combo); //connect(getPoint3Combo,SIGNAL(currentIndexChanged(int)),this,SLOT(getPoint())); @@ -513,10 +513,10 @@ PositionWidget::PositionWidget(QWidget *p, const RichPosition& rpf, const RichPo connect(this,SIGNAL(askTrackballPos(QString)),gla_curr,SLOT(sendTrackballPos(QString))); getPoint3Button = new QPushButton("Get",this); - getPoint3Button->setMaximumWidth(getPoint3Button->sizeHint().width()/2); + //getPoint3Button->setMaximumWidth(getPoint3Button->sizeHint().width()/2); - getPoint3Button->setFlat(true); - getPoint3Button->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Preferred); + //getPoint3Button->setFlat(true); + getPoint3Button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); connect(getPoint3Button,SIGNAL(clicked()),this,SLOT(getPoint())); vlay->addWidget(getPoint3Button); @@ -621,7 +621,7 @@ DirectionWidget::DirectionWidget(QWidget *p, const RichDirection& rpf, const Ric coordSB[i]->setMaximumWidth(coordSB[i]->sizeHint().width()/2); coordSB[i]->setValidator(new QDoubleValidator()); coordSB[i]->setAlignment(Qt::AlignRight); - coordSB[i]->setSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Preferred); + coordSB[i]->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred); vlay->addWidget(coordSB[i]); connect(coordSB[i],SIGNAL(textChanged(QString)),p,SIGNAL(parameterChanged())); } @@ -634,6 +634,7 @@ DirectionWidget::DirectionWidget(QWidget *p, const RichDirection& rpf, const Ric getPoint3Combo = new QComboBox(this); getPoint3Combo->addItems(names); + getPoint3Combo->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Preferred); vlay->addWidget(getPoint3Combo); //connect(getPoint3Combo,SIGNAL(currentIndexChanged(int)),this,SLOT(getPoint())); @@ -643,9 +644,9 @@ DirectionWidget::DirectionWidget(QWidget *p, const RichDirection& rpf, const Ric connect(this,SIGNAL(askCameraDir(QString)),gla_curr,SLOT(sendRasterShot(QString))); getPoint3Button = new QPushButton("Get",this); - getPoint3Button->setMaximumWidth(getPoint3Button->sizeHint().width()/2); + //getPoint3Button->setMaximumWidth(getPoint3Button->sizeHint().width()/2); - getPoint3Button->setFlat(true); + //getPoint3Button->setFlat(true); getPoint3Button->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Preferred); connect(getPoint3Button,SIGNAL(clicked()),this,SLOT(getPoint())); diff --git a/src/meshlab/rich_parameter_gui/richparameterwidgets.h b/src/meshlab/rich_parameter_gui/richparameterwidgets.h index b8d6a5335..955ff78f9 100644 --- a/src/meshlab/rich_parameter_gui/richparameterwidgets.h +++ b/src/meshlab/rich_parameter_gui/richparameterwidgets.h @@ -81,6 +81,8 @@ public: void resetWidgetValue(); void setWidgetValue(const Value& nv); +private: + QLabel* descriptionLabel; QCheckBox* cb; }; From bddfeb4451ce04df0f4d1ba48a9f369a30a4955b Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Mon, 13 Sep 2021 11:07:10 +0200 Subject: [PATCH 18/22] better management of help labels in rich widgets --- src/meshlab/dialogs/filter_dock_dialog.ui | 3 + .../richparameterlistframe.cpp | 7 +- .../richparameterlistframe.h | 1 - .../richparameterwidgets.cpp | 1087 +++++++++-------- .../rich_parameter_gui/richparameterwidgets.h | 284 ++--- 5 files changed, 698 insertions(+), 684 deletions(-) diff --git a/src/meshlab/dialogs/filter_dock_dialog.ui b/src/meshlab/dialogs/filter_dock_dialog.ui index 4fa0e561b..5d3f8504a 100644 --- a/src/meshlab/dialogs/filter_dock_dialog.ui +++ b/src/meshlab/dialogs/filter_dock_dialog.ui @@ -131,6 +131,9 @@ Help + + true +
diff --git a/src/meshlab/rich_parameter_gui/richparameterlistframe.cpp b/src/meshlab/rich_parameter_gui/richparameterlistframe.cpp index 4ea6faa43..022e1ba1d 100644 --- a/src/meshlab/rich_parameter_gui/richparameterlistframe.cpp +++ b/src/meshlab/rich_parameter_gui/richparameterlistframe.cpp @@ -106,8 +106,9 @@ void RichParameterListFrame::resetValues() void RichParameterListFrame::toggleHelp() { isHelpVisible = !isHelpVisible; - for(int i = 0; i < helpList.count(); i++) - helpList.at(i)->setVisible(isHelpVisible); + for(auto& p : stdfieldwidgets) { + p.second->setHelpVisible(isHelpVisible); + } setMinimumSize(sizeHint()); adjustSize(); updateGeometry(); @@ -182,7 +183,6 @@ void RichParameterListFrame::loadFrameContent( const RichParameter& defrp = defParSet.getParameterByName(fpi->name()); RichParameterWidget* wd = createWidgetFromRichParameter(this, *fpi, defrp); stdfieldwidgets[fpi->name()] = wd; - helpList.push_back(wd->helpLab); wd->addWidgetToGridLayout(glay,i++); } } @@ -203,7 +203,6 @@ void RichParameterListFrame::loadFrameContent( const RichParameter& defrp = defParSet.getParameterByName(fpi->name()); RichParameterWidget* wd = createWidgetFromRichParameter(this, *fpi, defrp); stdfieldwidgets[fpi->name()] = wd; - helpList.push_back(wd->helpLab); wd->addWidgetToGridLayout(flay,j++); } } diff --git a/src/meshlab/rich_parameter_gui/richparameterlistframe.h b/src/meshlab/rich_parameter_gui/richparameterlistframe.h index 33cd0d3b3..7c81af174 100644 --- a/src/meshlab/rich_parameter_gui/richparameterlistframe.h +++ b/src/meshlab/rich_parameter_gui/richparameterlistframe.h @@ -88,7 +88,6 @@ private: const RichParameter& def); std::map stdfieldwidgets; - QVector helpList; bool isHelpVisible; QWidget *gla; // used for having a link to the glarea that spawned the parameter asking. diff --git a/src/meshlab/rich_parameter_gui/richparameterwidgets.cpp b/src/meshlab/rich_parameter_gui/richparameterwidgets.cpp index ff2d0f751..29ba7cb0b 100644 --- a/src/meshlab/rich_parameter_gui/richparameterwidgets.cpp +++ b/src/meshlab/rich_parameter_gui/richparameterwidgets.cpp @@ -1,92 +1,101 @@ -/**************************************************************************** -* MeshLab 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. * -* * -****************************************************************************/ +/***************************************************************************** + * MeshLab o o * + * Visual and Computer Graphics Library o o * + * _ O _ * + * Copyright(C) 2004-2021 \/)\/ * + * 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 "richparameterwidgets.h" -#include -#include -#include #include +#include +#include +#include #include /******************************************/ // MeshLabWidget Implementation /******************************************/ -RichParameterWidget::RichParameterWidget(QWidget* p, const RichParameter& rpar , const RichParameter& defaultParam): - QWidget(p) , rp(rpar.clone()), defp(defaultParam.clone()) +RichParameterWidget::RichParameterWidget( + QWidget* p, + const RichParameter& rpar, + const RichParameter& defaultParam) : + QWidget(p), parameter(rpar.clone()), defaultParameter(defaultParam.clone()) { - if (rp!= NULL) { - helpLab = new QLabel(""+rpar.toolTip() +"",this); - helpLab->setTextFormat(Qt::RichText); - helpLab->setWordWrap(true); - helpLab->setVisible(false); - helpLab->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); - helpLab->setMinimumWidth(250); - helpLab->setMaximumWidth(QWIDGETSIZE_MAX); + if (parameter != nullptr) { + descriptionLabel = new QLabel(parameter->fieldDescription(), this); + descriptionLabel->setToolTip(parameter->toolTip()); + + helpLabel = new QLabel("" + rpar.toolTip() + "", this); + helpLabel->setTextFormat(Qt::RichText); + helpLabel->setWordWrap(true); + helpLabel->setVisible(false); + helpLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); + helpLabel->setMinimumWidth(250); + // helpLabel->setMaximumWidth(QWIDGETSIZE_MAX); } } RichParameterWidget::~RichParameterWidget() { - delete rp; - delete defp; + delete parameter; + delete defaultParameter; } void RichParameterWidget::resetValue() { - rp->setValue(defp->value()); + parameter->setValue(defaultParameter->value()); resetWidgetValue(); } void RichParameterWidget::setValue(const Value& v) { - rp->setValue(v); + parameter->setValue(v); resetWidgetValue(); } - +void RichParameterWidget::setHelpVisible(bool b) +{ + helpLabel->setVisible(b); +} const Value& RichParameterWidget::widgetValue() { collectWidgetValue(); - return rp->value(); + return parameter->value(); } const RichParameter& RichParameterWidget::richParameter() const { - return *rp; + return *parameter; } QString RichParameterWidget::parameterName() const { - return rp->name(); + return parameter->name(); } - -void RichParameterWidget::addWidgetToGridLayout( QGridLayout* lay, const int r) +void RichParameterWidget::addWidgetToGridLayout(QGridLayout* lay, const int r) { if (lay != NULL) { - lay->addWidget(helpLab, r, 2, 1, 1, Qt::AlignLeft); + lay->addWidget(descriptionLabel, r, 0); + lay->addWidget(helpLabel, r, 2, 1, 1, Qt::AlignLeft); } } @@ -94,16 +103,14 @@ void RichParameterWidget::addWidgetToGridLayout( QGridLayout* lay, const int r) // BoolWidget Implementation /******************************************/ -BoolWidget::BoolWidget(QWidget* p, const RichBool& rb , const RichBool& rdef) : - RichParameterWidget(p,rb, rdef) +BoolWidget::BoolWidget(QWidget* p, const RichBool& rb, const RichBool& rdef) : + RichParameterWidget(p, rb, rdef) { - descriptionLabel = new QLabel(rp->fieldDescription(),this); - cb = new QCheckBox("",this); - descriptionLabel->setToolTip(rp->toolTip()); - cb->setToolTip(rp->toolTip()); - cb->setChecked(rp->value().getBool()); + cb = new QCheckBox("", this); + cb->setToolTip(parameter->toolTip()); + cb->setChecked(parameter->value().getBool()); - connect(cb,SIGNAL(stateChanged(int)),p,SIGNAL(parameterChanged())); + connect(cb, SIGNAL(stateChanged(int)), p, SIGNAL(parameterChanged())); } BoolWidget::~BoolWidget() @@ -112,41 +119,38 @@ BoolWidget::~BoolWidget() void BoolWidget::collectWidgetValue() { - rp->setValue(BoolValue(cb->isChecked())); + parameter->setValue(BoolValue(cb->isChecked())); } void BoolWidget::resetWidgetValue() { - cb->setChecked(rp->value().getBool()); + cb->setChecked(parameter->value().getBool()); } -void BoolWidget::setWidgetValue( const Value& nv ) +void BoolWidget::setWidgetValue(const Value& nv) { cb->setChecked(nv.getBool()); } -void BoolWidget::addWidgetToGridLayout(QGridLayout* lay,const int r) +void BoolWidget::addWidgetToGridLayout(QGridLayout* lay, const int r) { - if (lay !=NULL){ - lay->addWidget(descriptionLabel, r, 0); - lay->addWidget(cb,r,1); + if (lay != NULL) { + lay->addWidget(cb, r, 1); } - RichParameterWidget::addWidgetToGridLayout(lay,r); + RichParameterWidget::addWidgetToGridLayout(lay, r); } /******************************************/ // LineEditWidget Implementation /******************************************/ -LineEditWidget::LineEditWidget(QWidget* p, const RichParameter& rpar , const RichParameter& rdef) : - RichParameterWidget(p,rpar, rdef) +LineEditWidget::LineEditWidget(QWidget* p, const RichParameter& rpar, const RichParameter& rdef) : + RichParameterWidget(p, rpar, rdef) { - lab = new QLabel(rp->fieldDescription(),this); lned = new QLineEdit(this); - lab->setToolTip(rp->toolTip()); - connect(lned,SIGNAL(editingFinished()),this,SLOT(changeChecker())); - connect(this,SIGNAL(lineEditChanged()),p,SIGNAL(parameterChanged())); + connect(lned, SIGNAL(editingFinished()), this, SLOT(changeChecker())); + connect(this, SIGNAL(lineEditChanged()), p, SIGNAL(parameterChanged())); lned->setAlignment(Qt::AlignLeft); } @@ -156,43 +160,42 @@ LineEditWidget::~LineEditWidget() void LineEditWidget::changeChecker() { - if(lned->text() != this->lastVal) { + if (lned->text() != this->lastVal) { this->lastVal = lned->text(); - if(!this->lastVal.isEmpty()) + if (!this->lastVal.isEmpty()) emit lineEditChanged(); } } -void LineEditWidget::addWidgetToGridLayout( QGridLayout* lay,const int r ) +void LineEditWidget::addWidgetToGridLayout(QGridLayout* lay, const int r) { - if (lay !=NULL) { - lay->addWidget(lab,r,0); - lay->addWidget(lned,r,1); + if (lay != NULL) { + lay->addWidget(lned, r, 1); } - RichParameterWidget::addWidgetToGridLayout(lay,r); + RichParameterWidget::addWidgetToGridLayout(lay, r); } /******************************************/ // IntWidget Implementation /******************************************/ -IntWidget::IntWidget( QWidget* p, const RichInt& rpar, const RichInt& rdef ) : - LineEditWidget(p,rpar, rdef) +IntWidget::IntWidget(QWidget* p, const RichInt& rpar, const RichInt& rdef) : + LineEditWidget(p, rpar, rdef) { - lned->setText(QString::number(rp->value().getInt())); + lned->setText(QString::number(parameter->value().getInt())); } void IntWidget::collectWidgetValue() { - rp->setValue(IntValue(lned->text().toInt())); + parameter->setValue(IntValue(lned->text().toInt())); } void IntWidget::resetWidgetValue() { - lned->setText(QString::number(rp->value().getInt())); + lned->setText(QString::number(parameter->value().getInt())); } -void IntWidget::setWidgetValue( const Value& nv ) +void IntWidget::setWidgetValue(const Value& nv) { lned->setText(QString::number(nv.getInt())); } @@ -201,48 +204,48 @@ void IntWidget::setWidgetValue( const Value& nv ) // FloatWidget Implementation /******************************************/ -FloatWidget::FloatWidget(QWidget* p, const RichFloat& rpar , const RichFloat& rdef) : - LineEditWidget(p,rpar, rdef) +FloatWidget::FloatWidget(QWidget* p, const RichFloat& rpar, const RichFloat& rdef) : + LineEditWidget(p, rpar, rdef) { - lned->setText(QString::number(rp->value().getFloat(),'g',3)); + lned->setText(QString::number(parameter->value().getFloat(), 'g', 3)); } void FloatWidget::collectWidgetValue() { - rp->setValue(FloatValue(lned->text().toFloat())); + parameter->setValue(FloatValue(lned->text().toFloat())); } void FloatWidget::resetWidgetValue() { - lned->setText(QString::number(rp->value().getFloat(),'g',3)); + lned->setText(QString::number(parameter->value().getFloat(), 'g', 3)); } -void FloatWidget::setWidgetValue( const Value& nv ) +void FloatWidget::setWidgetValue(const Value& nv) { - lned->setText(QString::number(nv.getFloat(),'g',3)); + lned->setText(QString::number(nv.getFloat(), 'g', 3)); } /******************************************/ // StringWidget Implementation /******************************************/ -StringWidget::StringWidget(QWidget* p, const RichString& rpar , const RichString& rdef) : - LineEditWidget(p,rpar, rdef) +StringWidget::StringWidget(QWidget* p, const RichString& rpar, const RichString& rdef) : + LineEditWidget(p, rpar, rdef) { - lned->setText(rp->value().getString()); + lned->setText(parameter->value().getString()); } void StringWidget::collectWidgetValue() { - rp->setValue(StringValue(lned->text())); + parameter->setValue(StringValue(lned->text())); } void StringWidget::resetWidgetValue() { - lned->setText(rp->value().getString()); + lned->setText(parameter->value().getString()); } -void StringWidget::setWidgetValue( const Value& nv ) +void StringWidget::setWidgetValue(const Value& nv) { lned->setText(nv.getString()); } @@ -251,95 +254,92 @@ void StringWidget::setWidgetValue( const Value& nv ) // ColorWidget Implementation /******************************************/ - -ColorWidget::ColorWidget(QWidget *p, const RichColor& newColor, const RichColor& rdef) - :RichParameterWidget(p,newColor, rdef),pickcol() +ColorWidget::ColorWidget(QWidget* p, const RichColor& newColor, const RichColor& rdef) : + RichParameterWidget(p, newColor, rdef), pickcol() { - colorLabel = new QLabel(this); - descLabel = new QLabel(rp->fieldDescription(),this); + colorLabel = new QLabel(this); colorButton = new QPushButton(this); colorButton->setAutoFillBackground(true); colorButton->setFlat(true); - colorButton->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed); - //const QColor cl = rp->pd->defvalue().getColor(); - //resetWidgetValue(); + colorButton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); + // const QColor cl = rp->pd->defvalue().getColor(); + // resetWidgetValue(); initWidgetValue(); - //int row = gridLay->rowCount() - 1; - //gridLay->addWidget(descLabel,row,0,Qt::AlignTop); + // int row = gridLay->rowCount() - 1; + // gridLay->addWidget(descLabel,row,0,Qt::AlignTop); vlay = new QHBoxLayout(); QFontMetrics met(colorLabel->font()); - QColor black(Qt::black); - QString blackname = "(" + black.name() + ")"; - QSize sz = met.size(Qt::TextSingleLine,blackname); + QColor black(Qt::black); + QString blackname = "(" + black.name() + ")"; + QSize sz = met.size(Qt::TextSingleLine, blackname); colorLabel->setMaximumWidth(sz.width()); colorLabel->setMinimumWidth(sz.width()); - vlay->addWidget(colorLabel,0,Qt::AlignRight); + vlay->addWidget(colorLabel, 0, Qt::AlignRight); vlay->addWidget(colorButton); - - //gridLay->addLayout(lay,row,1,Qt::AlignTop); - pickcol = rp->value().getColor(); - connect(colorButton,SIGNAL(clicked()),this,SLOT(pickColor())); - connect(this,SIGNAL(dialogParamChanged()),p,SIGNAL(parameterChanged())); + // gridLay->addLayout(lay,row,1,Qt::AlignTop); + pickcol = parameter->value().getColor(); + connect(colorButton, SIGNAL(clicked()), this, SLOT(pickColor())); + connect(this, SIGNAL(dialogParamChanged()), p, SIGNAL(parameterChanged())); } ColorWidget::~ColorWidget() { delete colorButton; delete colorLabel; - delete descLabel; } -void ColorWidget::addWidgetToGridLayout( QGridLayout* lay,const int r ) +void ColorWidget::addWidgetToGridLayout(QGridLayout* lay, const int r) { - if (lay != NULL) - { - lay->addWidget(descLabel,r,0); - lay->addLayout(vlay,r,1); + if (lay != NULL) { + lay->addLayout(vlay, r, 1); } - RichParameterWidget::addWidgetToGridLayout(lay,r); + RichParameterWidget::addWidgetToGridLayout(lay, r); } void ColorWidget::collectWidgetValue() { - rp->setValue(ColorValue(pickcol)); + parameter->setValue(ColorValue(pickcol)); } void ColorWidget::resetWidgetValue() { - QColor cl = rp->value().getColor(); - pickcol = cl; + QColor cl = parameter->value().getColor(); + pickcol = cl; updateColorInfo(cl); } -void ColorWidget::setWidgetValue( const Value& nv ) +void ColorWidget::setWidgetValue(const Value& nv) { QColor cl = nv.getColor(); - pickcol = cl; + pickcol = cl; updateColorInfo(cl); } void ColorWidget::initWidgetValue() { - QColor cl = rp->value().getColor(); - pickcol = cl; + QColor cl = parameter->value().getColor(); + pickcol = cl; updateColorInfo(cl); } void ColorWidget::updateColorInfo(const ColorValue& newColor) { QColor col = newColor.getColor(); - colorLabel->setText("("+col.name()+")"); + colorLabel->setText("(" + col.name() + ")"); QPalette palette(col); colorButton->setPalette(palette); } void ColorWidget::pickColor() { - pickcol = QColorDialog::getColor(pickcol,this->parentWidget(),"Pick a Color",QColorDialog::DontUseNativeDialog|QColorDialog::ShowAlphaChannel); - if(pickcol.isValid()) - { + pickcol = QColorDialog::getColor( + pickcol, + this->parentWidget(), + "Pick a Color", + QColorDialog::DontUseNativeDialog | QColorDialog::ShowAlphaChannel); + if (pickcol.isValid()) { collectWidgetValue(); updateColorInfo(ColorValue(pickcol)); } @@ -350,77 +350,75 @@ void ColorWidget::pickColor() // AbsPercWidget Implementation /******************************************/ - -AbsPercWidget::AbsPercWidget(QWidget *p, const RichAbsPerc& rabs, const RichAbsPerc& rdef): - RichParameterWidget(p,rabs, rdef) +AbsPercWidget::AbsPercWidget(QWidget* p, const RichAbsPerc& rabs, const RichAbsPerc& rdef) : + RichParameterWidget(p, rabs, rdef) { m_min = rabs.min; m_max = rabs.max; - fieldDesc = new QLabel(rp->fieldDescription() + " (abs and %)",this); - fieldDesc->setToolTip(rp->toolTip()); - absSB = new QDoubleSpinBox(this); + descriptionLabel->setText(descriptionLabel->text() + " (abs and %)"); + + absSB = new QDoubleSpinBox(this); percSB = new QDoubleSpinBox(this); - absSB->setMinimum(m_min-(m_max-m_min)); - absSB->setMaximum(m_max*2); + absSB->setMinimum(m_min - (m_max - m_min)); + absSB->setMaximum(m_max * 2); absSB->setAlignment(Qt::AlignRight); - int decimals= 7-ceil(log10(fabs(m_max-m_min)) ) ; - //qDebug("range is (%f %f) %f ",m_max,m_min,fabs(m_max-m_min)); - //qDebug("log range is %f ",log10(fabs(m_max-m_min))); + int decimals = 7 - ceil(log10(fabs(m_max - m_min))); + // qDebug("range is (%f %f) %f ",m_max,m_min,fabs(m_max-m_min)); + // qDebug("log range is %f ",log10(fabs(m_max-m_min))); absSB->setDecimals(decimals); - absSB->setSingleStep((m_max-m_min)/100.0); - float initVal = rp->value().getFloat(); + absSB->setSingleStep((m_max - m_min) / 100.0); + float initVal = parameter->value().getFloat(); absSB->setValue(initVal); percSB->setMinimum(-200); percSB->setMaximum(200); percSB->setAlignment(Qt::AlignRight); percSB->setSingleStep(0.5); - percSB->setValue((100*(initVal - m_min))/(m_max - m_min)); + percSB->setValue((100 * (initVal - m_min)) / (m_max - m_min)); percSB->setDecimals(3); - QLabel *absLab=new QLabel(" world unit"); - QLabel *percLab=new QLabel(" perc on"+QString("(%1 .. %2)").arg(m_min).arg(m_max)+""); + QLabel* absLab = new QLabel(" world unit"); + QLabel* percLab = new QLabel( + " perc on" + QString("(%1 .. %2)").arg(m_min).arg(m_max) + ""); // gridLay->addWidget(fieldDesc,row,0,Qt::AlignHCenter); vlay = new QGridLayout(); - vlay->addWidget(absLab,0,0,Qt::AlignHCenter); - vlay->addWidget(percLab,0,1,Qt::AlignHCenter); + vlay->addWidget(absLab, 0, 0, Qt::AlignHCenter); + vlay->addWidget(percLab, 0, 1, Qt::AlignHCenter); - vlay->addWidget(absSB,1,0,Qt::AlignTop); - vlay->addWidget(percSB,1,1,Qt::AlignTop); + vlay->addWidget(absSB, 1, 0, Qt::AlignTop); + vlay->addWidget(percSB, 1, 1, Qt::AlignTop); - //gridLay->addLayout(lay,row,1,Qt::AlignTop); + // gridLay->addLayout(lay,row,1,Qt::AlignTop); - connect(absSB,SIGNAL(valueChanged(double)),this,SLOT(on_absSB_valueChanged(double))); - connect(percSB,SIGNAL(valueChanged(double)),this,SLOT(on_percSB_valueChanged(double))); - connect(this,SIGNAL(dialogParamChanged()),p,SIGNAL(parameterChanged())); + connect(absSB, SIGNAL(valueChanged(double)), this, SLOT(on_absSB_valueChanged(double))); + connect(percSB, SIGNAL(valueChanged(double)), this, SLOT(on_percSB_valueChanged(double))); + connect(this, SIGNAL(dialogParamChanged()), p, SIGNAL(parameterChanged())); } AbsPercWidget::~AbsPercWidget() { delete absSB; delete percSB; - delete fieldDesc; } - void AbsPercWidget::on_absSB_valueChanged(double newv) { - disconnect(percSB,SIGNAL(valueChanged(double)),this,SLOT(on_percSB_valueChanged(double))); - percSB->setValue((100*(newv - m_min))/(m_max - m_min)); - connect(percSB,SIGNAL(valueChanged(double)),this,SLOT(on_percSB_valueChanged(double))); + disconnect(percSB, SIGNAL(valueChanged(double)), this, SLOT(on_percSB_valueChanged(double))); + percSB->setValue((100 * (newv - m_min)) / (m_max - m_min)); + connect(percSB, SIGNAL(valueChanged(double)), this, SLOT(on_percSB_valueChanged(double))); emit dialogParamChanged(); } void AbsPercWidget::on_percSB_valueChanged(double newv) { - disconnect(absSB,SIGNAL(valueChanged(double)),this,SLOT(on_absSB_valueChanged(double))); - absSB->setValue((m_max - m_min)*0.01*newv + m_min); - connect(absSB,SIGNAL(valueChanged(double)),this,SLOT(on_absSB_valueChanged(double))); + disconnect(absSB, SIGNAL(valueChanged(double)), this, SLOT(on_absSB_valueChanged(double))); + absSB->setValue((m_max - m_min) * 0.01 * newv + m_min); + connect(absSB, SIGNAL(valueChanged(double)), this, SLOT(on_absSB_valueChanged(double))); emit dialogParamChanged(); } @@ -428,69 +426,71 @@ void AbsPercWidget::setValue(float val, float minV, float maxV) { assert(absSB); absSB->setValue(val); - m_min=minV; - m_max=maxV; + m_min = minV; + m_max = maxV; } void AbsPercWidget::collectWidgetValue() { - rp->setValue(FloatValue(absSB->value())); + parameter->setValue(FloatValue(absSB->value())); } void AbsPercWidget::resetWidgetValue() { - //const AbsPercDecoration* absd = reinterpret_cast(&(rp->pd)); - RichAbsPerc* ap = reinterpret_cast(rp); - setValue(rp->value().getFloat(),ap->min,ap->max); + // const AbsPercDecoration* absd = reinterpret_cast(&(rp->pd)); + RichAbsPerc* ap = reinterpret_cast(parameter); + setValue(parameter->value().getFloat(), ap->min, ap->max); } -void AbsPercWidget::setWidgetValue( const Value& nv ) +void AbsPercWidget::setWidgetValue(const Value& nv) { - //const AbsPercDecoration* absd = reinterpret_cast(&(rp->pd)); - RichAbsPerc* ap = reinterpret_cast(rp); - setValue(nv.getFloat(),ap->min,ap->max); + // const AbsPercDecoration* absd = reinterpret_cast(&(rp->pd)); + RichAbsPerc* ap = reinterpret_cast(parameter); + setValue(nv.getFloat(), ap->min, ap->max); } -void AbsPercWidget::addWidgetToGridLayout( QGridLayout* lay,const int r ) +void AbsPercWidget::addWidgetToGridLayout(QGridLayout* lay, const int r) { - if (lay != NULL) - { - lay->addWidget(fieldDesc,r,0,Qt::AlignLeft); - lay->addLayout(vlay,r,1,Qt::AlignTop); + if (lay != NULL) { + lay->addLayout(vlay, r, 1, Qt::AlignTop); } - RichParameterWidget::addWidgetToGridLayout(lay,r); + RichParameterWidget::addWidgetToGridLayout(lay, r); } /******************************************/ // PositionWidget Implementation /******************************************/ -PositionWidget::PositionWidget(QWidget *p, const RichPosition& rpf, const RichPosition& rdef, QWidget *gla_curr): - RichParameterWidget(p,rpf, rdef) +PositionWidget::PositionWidget( + QWidget* p, + const RichPosition& rpf, + const RichPosition& rdef, + QWidget* gla_curr) : + RichParameterWidget(p, rpf, rdef) { paramName = rpf.name(); - descLab = new QLabel(rpf.fieldDescription(),this); - descLab->setToolTip(rpf.fieldDescription()); vlay = new QHBoxLayout(); vlay->setSpacing(0); - for(int i =0;i<3;++i) - { - coordSB[i]= new QLineEdit(this); - QFont baseFont=coordSB[i]->font(); - if(baseFont.pixelSize() != -1) baseFont.setPixelSize(baseFont.pixelSize()*3/4); - else baseFont.setPointSize(baseFont.pointSize()*3/4); + for (int i = 0; i < 3; ++i) { + coordSB[i] = new QLineEdit(this); + QFont baseFont = coordSB[i]->font(); + if (baseFont.pixelSize() != -1) + baseFont.setPixelSize(baseFont.pixelSize() * 3 / 4); + else + baseFont.setPointSize(baseFont.pointSize() * 3 / 4); coordSB[i]->setFont(baseFont); - coordSB[i]->setMaximumWidth(coordSB[i]->sizeHint().width()/2); + coordSB[i]->setMaximumWidth(coordSB[i]->sizeHint().width() / 2); coordSB[i]->setValidator(new QDoubleValidator()); coordSB[i]->setAlignment(Qt::AlignRight); - coordSB[i]->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred); + coordSB[i]->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); vlay->addWidget(coordSB[i]); - connect(coordSB[i],SIGNAL(textChanged(QString)),p,SIGNAL(parameterChanged())); + connect(coordSB[i], SIGNAL(textChanged(QString)), p, SIGNAL(parameterChanged())); } - this->setValue(paramName,rp->value().getPoint3f()); - if(gla_curr) // if we have a connection to the current glarea we can setup the additional button for getting the current view direction. - { + this->setValue(paramName, parameter->value().getPoint3f()); + // if we have a connection to the current glarea we can setup the additional + // button for getting the current view direction. + if (gla_curr) { QStringList names; names << "View Pos."; names << "Surf. Pos."; @@ -499,156 +499,174 @@ PositionWidget::PositionWidget(QWidget *p, const RichPosition& rpf, const RichPo getPoint3Combo = new QComboBox(this); getPoint3Combo->addItems(names); - getPoint3Combo->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Preferred); + getPoint3Combo->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); vlay->addWidget(getPoint3Combo); - //connect(getPoint3Combo,SIGNAL(currentIndexChanged(int)),this,SLOT(getPoint())); - connect(gla_curr,SIGNAL(transmitSurfacePos(QString,Point3m)),this,SLOT(setValue(QString,Point3m))); - connect(gla_curr,SIGNAL(transmitCameraPos(QString, Point3m)),this,SLOT(setValue(QString, Point3m))); - connect(gla_curr,SIGNAL(transmitShot(QString,Shotm)),this,SLOT(setShotValue(QString,Shotm))); - connect(gla_curr,SIGNAL(transmitTrackballPos(QString, Point3m)),this,SLOT(setValue(QString, Point3m))); - connect(this,SIGNAL(askViewPos(QString)),gla_curr,SLOT(sendViewerShot(QString))); - connect(this,SIGNAL(askSurfacePos(QString)),gla_curr,SLOT(sendSurfacePos(QString))); - connect(this,SIGNAL(askCameraPos(QString)),gla_curr,SLOT(sendRasterShot(QString))); - connect(this,SIGNAL(askTrackballPos(QString)),gla_curr,SLOT(sendTrackballPos(QString))); + // connect(getPoint3Combo,SIGNAL(currentIndexChanged(int)),this,SLOT(getPoint())); + connect( + gla_curr, + SIGNAL(transmitSurfacePos(QString, Point3m)), + this, + SLOT(setValue(QString, Point3m))); + connect( + gla_curr, + SIGNAL(transmitCameraPos(QString, Point3m)), + this, + SLOT(setValue(QString, Point3m))); + connect( + gla_curr, + SIGNAL(transmitShot(QString, Shotm)), + this, + SLOT(setShotValue(QString, Shotm))); + connect( + gla_curr, + SIGNAL(transmitTrackballPos(QString, Point3m)), + this, + SLOT(setValue(QString, Point3m))); + connect(this, SIGNAL(askViewPos(QString)), gla_curr, SLOT(sendViewerShot(QString))); + connect(this, SIGNAL(askSurfacePos(QString)), gla_curr, SLOT(sendSurfacePos(QString))); + connect(this, SIGNAL(askCameraPos(QString)), gla_curr, SLOT(sendRasterShot(QString))); + connect(this, SIGNAL(askTrackballPos(QString)), gla_curr, SLOT(sendTrackballPos(QString))); - getPoint3Button = new QPushButton("Get",this); - //getPoint3Button->setMaximumWidth(getPoint3Button->sizeHint().width()/2); + getPoint3Button = new QPushButton("Get", this); + // getPoint3Button->setMaximumWidth(getPoint3Button->sizeHint().width()/2); - //getPoint3Button->setFlat(true); + // getPoint3Button->setFlat(true); getPoint3Button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); - connect(getPoint3Button,SIGNAL(clicked()),this,SLOT(getPoint())); + connect(getPoint3Button, SIGNAL(clicked()), this, SLOT(getPoint())); vlay->addWidget(getPoint3Button); } - //gridLay->addLayout(lay,row,1,Qt::AlignTop); + // gridLay->addLayout(lay,row,1,Qt::AlignTop); } PositionWidget::~PositionWidget() { - //qDebug("Deallocating a point3fwidget"); + // qDebug("Deallocating a point3fwidget"); this->disconnect(); } void PositionWidget::getPoint() { int index = getPoint3Combo->currentIndex(); - switch(index) - { - case 0: - emit askViewPos(paramName); - break; - case 1: - emit askSurfacePos(paramName); - break; - case 2: - emit askCameraPos(paramName); - break; - case 3: - emit askTrackballPos(paramName); - break; - default : assert(0); + switch (index) { + case 0: emit askViewPos(paramName); break; + case 1: emit askSurfacePos(paramName); break; + case 2: emit askCameraPos(paramName); break; + case 3: emit askTrackballPos(paramName); break; + default: assert(0); } } -void PositionWidget::setValue(QString name,Point3m newVal) +void PositionWidget::setValue(QString name, Point3m newVal) { - if(name==paramName) - { - for(int i =0;i<3;++i) - coordSB[i]->setText(QString::number(newVal[i],'g',4)); + if (name == paramName) { + for (int i = 0; i < 3; ++i) + coordSB[i]->setText(QString::number(newVal[i], 'g', 4)); } } void PositionWidget::setShotValue(QString name, Shotm newValShot) { vcg::Point3f p = newValShot.GetViewPoint(); - setValue(name,p); + setValue(name, p); } vcg::Point3f PositionWidget::getValue() { - return vcg::Point3f(coordSB[0]->text().toFloat(),coordSB[1]->text().toFloat(),coordSB[2]->text().toFloat()); + return vcg::Point3f( + coordSB[0]->text().toFloat(), coordSB[1]->text().toFloat(), coordSB[2]->text().toFloat()); } void PositionWidget::collectWidgetValue() { - rp->setValue(Point3fValue(vcg::Point3f(coordSB[0]->text().toFloat(),coordSB[1]->text().toFloat(),coordSB[2]->text().toFloat()))); + parameter->setValue(Point3fValue(vcg::Point3f( + coordSB[0]->text().toFloat(), coordSB[1]->text().toFloat(), coordSB[2]->text().toFloat()))); } void PositionWidget::resetWidgetValue() { - for(unsigned int ii = 0; ii < 3;++ii) - coordSB[ii]->setText(QString::number(rp->value().getPoint3f()[ii],'g',3)); + for (unsigned int ii = 0; ii < 3; ++ii) + coordSB[ii]->setText(QString::number(parameter->value().getPoint3f()[ii], 'g', 3)); } -void PositionWidget::setWidgetValue( const Value& nv ) +void PositionWidget::setWidgetValue(const Value& nv) { - for(unsigned int ii = 0; ii < 3;++ii) - coordSB[ii]->setText(QString::number(nv.getPoint3f()[ii],'g',3)); + for (unsigned int ii = 0; ii < 3; ++ii) + coordSB[ii]->setText(QString::number(nv.getPoint3f()[ii], 'g', 3)); } -void PositionWidget::addWidgetToGridLayout( QGridLayout* lay,const int r ) +void PositionWidget::addWidgetToGridLayout(QGridLayout* lay, const int r) { - if (lay != NULL) - { - lay->addWidget(descLab,r,0); - lay->addLayout(vlay,r,1); + if (lay != NULL) { + lay->addLayout(vlay, r, 1); } - RichParameterWidget::addWidgetToGridLayout(lay,r); + RichParameterWidget::addWidgetToGridLayout(lay, r); } /******************************************/ // DirectionWidget Implementation /******************************************/ -DirectionWidget::DirectionWidget(QWidget *p, const RichDirection& rpf, const RichDirection& rdef, QWidget *gla_curr): - RichParameterWidget(p,rpf, rdef) +DirectionWidget::DirectionWidget( + QWidget* p, + const RichDirection& rpf, + const RichDirection& rdef, + QWidget* gla_curr) : + RichParameterWidget(p, rpf, rdef) { paramName = rpf.name(); - descLab = new QLabel(rpf.fieldDescription(),this); - descLab->setToolTip(rpf.fieldDescription()); vlay = new QHBoxLayout(); vlay->setSpacing(0); - for(int i =0;i<3;++i) - { - coordSB[i]= new QLineEdit(this); - QFont baseFont=coordSB[i]->font(); - if(baseFont.pixelSize() != -1) baseFont.setPixelSize(baseFont.pixelSize()*3/4); - else baseFont.setPointSize(baseFont.pointSize()*3/4); + for (int i = 0; i < 3; ++i) { + coordSB[i] = new QLineEdit(this); + QFont baseFont = coordSB[i]->font(); + if (baseFont.pixelSize() != -1) + baseFont.setPixelSize(baseFont.pixelSize() * 3 / 4); + else + baseFont.setPointSize(baseFont.pointSize() * 3 / 4); coordSB[i]->setFont(baseFont); - coordSB[i]->setMaximumWidth(coordSB[i]->sizeHint().width()/2); + coordSB[i]->setMaximumWidth(coordSB[i]->sizeHint().width() / 2); coordSB[i]->setValidator(new QDoubleValidator()); coordSB[i]->setAlignment(Qt::AlignRight); - coordSB[i]->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred); + coordSB[i]->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); vlay->addWidget(coordSB[i]); - connect(coordSB[i],SIGNAL(textChanged(QString)),p,SIGNAL(parameterChanged())); + connect(coordSB[i], SIGNAL(textChanged(QString)), p, SIGNAL(parameterChanged())); } - this->setValue(paramName,rp->value().getPoint3f()); - if(gla_curr) // if we have a connection to the current glarea we can setup the additional button for getting the current view direction. - { + this->setValue(paramName, parameter->value().getPoint3f()); + // if we have a connection to the current glarea we can setup the additional + // button for getting the current view direction. + if (gla_curr) { QStringList names; names << "View Dir."; names << "Raster Camera Dir."; getPoint3Combo = new QComboBox(this); getPoint3Combo->addItems(names); - getPoint3Combo->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Preferred); + getPoint3Combo->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); vlay->addWidget(getPoint3Combo); - //connect(getPoint3Combo,SIGNAL(currentIndexChanged(int)),this,SLOT(getPoint())); - connect(gla_curr,SIGNAL(transmitViewDir(QString,Point3m)),this,SLOT(setValue(QString,Point3m))); - connect(gla_curr,SIGNAL(transmitShot(QString,Shotm)),this,SLOT(setShotValue(QString,Shotm))); - connect(this,SIGNAL(askViewDir(QString)),gla_curr,SLOT(sendViewDir(QString))); - connect(this,SIGNAL(askCameraDir(QString)),gla_curr,SLOT(sendRasterShot(QString))); + // connect(getPoint3Combo,SIGNAL(currentIndexChanged(int)),this,SLOT(getPoint())); + connect( + gla_curr, + SIGNAL(transmitViewDir(QString, Point3m)), + this, + SLOT(setValue(QString, Point3m))); + connect( + gla_curr, + SIGNAL(transmitShot(QString, Shotm)), + this, + SLOT(setShotValue(QString, Shotm))); + connect(this, SIGNAL(askViewDir(QString)), gla_curr, SLOT(sendViewDir(QString))); + connect(this, SIGNAL(askCameraDir(QString)), gla_curr, SLOT(sendRasterShot(QString))); - getPoint3Button = new QPushButton("Get",this); - //getPoint3Button->setMaximumWidth(getPoint3Button->sizeHint().width()/2); + getPoint3Button = new QPushButton("Get", this); + // getPoint3Button->setMaximumWidth(getPoint3Button->sizeHint().width()/2); - //getPoint3Button->setFlat(true); - getPoint3Button->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Preferred); - connect(getPoint3Button,SIGNAL(clicked()),this,SLOT(getPoint())); + // getPoint3Button->setFlat(true); + getPoint3Button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); + connect(getPoint3Button, SIGNAL(clicked()), this, SLOT(getPoint())); vlay->addWidget(getPoint3Button); } @@ -656,109 +674,110 @@ DirectionWidget::DirectionWidget(QWidget *p, const RichDirection& rpf, const Ric DirectionWidget::~DirectionWidget() { - //qDebug("Deallocating a point3fwidget"); + // qDebug("Deallocating a point3fwidget"); this->disconnect(); } void DirectionWidget::getPoint() { int index = getPoint3Combo->currentIndex(); - switch(index) - { - case 0: - emit askViewDir(paramName); - break; - case 1: - emit askCameraDir(paramName); - break; + switch (index) { + case 0: emit askViewDir(paramName); break; + case 1: emit askCameraDir(paramName); break; - default : assert(0); + default: assert(0); } } -void DirectionWidget::setValue(QString name,Point3m newVal) +void DirectionWidget::setValue(QString name, Point3m newVal) { - if(name==paramName) - { - for(int i =0;i<3;++i) - coordSB[i]->setText(QString::number(newVal[i],'g',4)); + if (name == paramName) { + for (int i = 0; i < 3; ++i) + coordSB[i]->setText(QString::number(newVal[i], 'g', 4)); } } void DirectionWidget::setShotValue(QString name, Shotm newValShot) { vcg::Point3f p = newValShot.GetViewDir(); - setValue(name,p); + setValue(name, p); } vcg::Point3f DirectionWidget::getValue() { - return vcg::Point3f(coordSB[0]->text().toFloat(),coordSB[1]->text().toFloat(),coordSB[2]->text().toFloat()); + return vcg::Point3f( + coordSB[0]->text().toFloat(), coordSB[1]->text().toFloat(), coordSB[2]->text().toFloat()); } void DirectionWidget::collectWidgetValue() { - rp->setValue(Point3fValue(vcg::Point3f(coordSB[0]->text().toFloat(),coordSB[1]->text().toFloat(),coordSB[2]->text().toFloat()))); + parameter->setValue(Point3fValue(vcg::Point3f( + coordSB[0]->text().toFloat(), coordSB[1]->text().toFloat(), coordSB[2]->text().toFloat()))); } void DirectionWidget::resetWidgetValue() { - for(unsigned int ii = 0; ii < 3;++ii) - coordSB[ii]->setText(QString::number(rp->value().getPoint3f()[ii],'g',3)); + for (unsigned int ii = 0; ii < 3; ++ii) + coordSB[ii]->setText(QString::number(parameter->value().getPoint3f()[ii], 'g', 3)); } -void DirectionWidget::setWidgetValue( const Value& nv ) +void DirectionWidget::setWidgetValue(const Value& nv) { - for(unsigned int ii = 0; ii < 3;++ii) - coordSB[ii]->setText(QString::number(nv.getPoint3f()[ii],'g',3)); + for (unsigned int ii = 0; ii < 3; ++ii) + coordSB[ii]->setText(QString::number(nv.getPoint3f()[ii], 'g', 3)); } -void DirectionWidget::addWidgetToGridLayout( QGridLayout* lay,const int r ) +void DirectionWidget::addWidgetToGridLayout(QGridLayout* lay, const int r) { - if (lay != NULL) - { - lay->addWidget(descLab,r,0); - lay->addLayout(vlay,r,1); + if (lay != NULL) { + lay->addLayout(vlay, r, 1); } - RichParameterWidget::addWidgetToGridLayout(lay,r); + RichParameterWidget::addWidgetToGridLayout(lay, r); } /******************************************/ // Matrix44fWidget Implementation /******************************************/ -Matrix44fWidget::Matrix44fWidget(QWidget *p, const RichMatrix44f& rpf, const RichMatrix44f& rdef, QWidget *gla_curr): - RichParameterWidget(p,rpf, rdef) +Matrix44fWidget::Matrix44fWidget( + QWidget* p, + const RichMatrix44f& rpf, + const RichMatrix44f& rdef, + QWidget* gla_curr) : + RichParameterWidget(p, rpf, rdef) { valid = false; m.SetIdentity(); paramName = rpf.name(); - //int row = gridLay->rowCount() - 1; + // int row = gridLay->rowCount() - 1; - descLab = new QLabel(rpf.fieldDescription(),this); - descLab->setToolTip(rpf.fieldDescription()); - //gridLay->addWidget(descLab,row,0,Qt::AlignTop); - vlay = new QVBoxLayout(); + // gridLay->addWidget(descLab,row,0,Qt::AlignTop); + vlay = new QVBoxLayout(); lay44 = new QGridLayout(); - for(int i =0;i<16;++i) - { - coordSB[i]= new QLineEdit(p); - QFont baseFont=coordSB[i]->font(); - if(baseFont.pixelSize() != -1) baseFont.setPixelSize(baseFont.pixelSize()*3/4); - else baseFont.setPointSize(baseFont.pointSize()*3/4); + for (int i = 0; i < 16; ++i) { + coordSB[i] = new QLineEdit(p); + QFont baseFont = coordSB[i]->font(); + if (baseFont.pixelSize() != -1) + baseFont.setPixelSize(baseFont.pixelSize() * 3 / 4); + else + baseFont.setPointSize(baseFont.pointSize() * 3 / 4); coordSB[i]->setFont(baseFont); - //coordSB[i]->setMinimumWidth(coordSB[i]->sizeHint().width()/4); + // coordSB[i]->setMinimumWidth(coordSB[i]->sizeHint().width()/4); coordSB[i]->setMinimumWidth(0); - coordSB[i]->setMaximumWidth(coordSB[i]->sizeHint().width()/2); - //coordSB[i]->setSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Fixed); + coordSB[i]->setMaximumWidth(coordSB[i]->sizeHint().width() / 2); + // coordSB[i]->setSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Fixed); coordSB[i]->setValidator(new QDoubleValidator(p)); coordSB[i]->setAlignment(Qt::AlignRight); - //this->addWidget(coordSB[i],1,Qt::AlignHCenter); - lay44->addWidget(coordSB[i],i/4,i%4); - connect(coordSB[i], SIGNAL(textChanged(const QString&)), this, SLOT(invalidateMatrix(const QString&))); + // this->addWidget(coordSB[i],1,Qt::AlignHCenter); + lay44->addWidget(coordSB[i], i / 4, i % 4); + connect( + coordSB[i], + SIGNAL(textChanged(const QString&)), + this, + SLOT(invalidateMatrix(const QString&))); } - this->setValue(paramName,rp->value().getMatrix44f()); + this->setValue(paramName, parameter->value().getMatrix44f()); QLabel* headerL = new QLabel("Matrix:", this); vlay->addWidget(headerL, 0, Qt::AlignTop); @@ -771,13 +790,16 @@ Matrix44fWidget::Matrix44fWidget(QWidget *p, const RichMatrix44f& rpf, const Ric QPushButton* pasteMatrixButton = new QPushButton("Paste from clipboard"); vlay->addWidget(pasteMatrixButton); - //gridLay->addLayout(vlay,row,1,Qt::AlignTop); - - connect(gla_curr,SIGNAL(transmitMatrix(QString,Matrix44m)),this,SLOT(setValue(QString,Matrix44m))); - connect(getMatrixButton,SIGNAL(clicked()),this,SLOT(getMatrix())); - connect(pasteMatrixButton,SIGNAL(clicked()),this,SLOT(pasteMatrix())); - connect(this,SIGNAL(askMeshMatrix(QString)), gla_curr,SLOT(sendMeshMatrix(QString))); + // gridLay->addLayout(vlay,row,1,Qt::AlignTop); + connect( + gla_curr, + SIGNAL(transmitMatrix(QString, Matrix44m)), + this, + SLOT(setValue(QString, Matrix44m))); + connect(getMatrixButton, SIGNAL(clicked()), this, SLOT(getMatrix())); + connect(pasteMatrixButton, SIGNAL(clicked()), this, SLOT(pasteMatrix())); + connect(this, SIGNAL(askMeshMatrix(QString)), gla_curr, SLOT(sendMeshMatrix(QString))); } Matrix44fWidget::~Matrix44fWidget() @@ -786,16 +808,14 @@ Matrix44fWidget::~Matrix44fWidget() void Matrix44fWidget::setValue(QString name, Matrix44m newVal) { - if(name==paramName) - { - for(int i =0;i<16;++i) - coordSB[i]->setText(QString::number(newVal[i/4][i%4],'g',4)); + if (name == paramName) { + for (int i = 0; i < 16; ++i) + coordSB[i]->setText(QString::number(newVal[i / 4][i % 4], 'g', 4)); valid = true; - m = newVal; + m = newVal; } } - Matrix44m Matrix44fWidget::getValue() { if (!valid) { @@ -814,13 +834,13 @@ void Matrix44fWidget::getMatrix() void Matrix44fWidget::pasteMatrix() { - QClipboard *clipboard = QApplication::clipboard(); - QString shotString = clipboard->text().trimmed(); + QClipboard* clipboard = QApplication::clipboard(); + QString shotString = clipboard->text().trimmed(); if (shotString.contains(' ')) { QStringList list1 = shotString.split(" "); if (list1.size() != 16) return; - valid = false; + valid = false; int id = 0; for (QStringList::iterator i = list1.begin(); i != list1.end(); ++i, ++id) { bool ok = true; @@ -844,38 +864,39 @@ void Matrix44fWidget::pasteMatrix() void Matrix44fWidget::collectWidgetValue() { if (!valid) { - Matrix44m tempM; - for (unsigned int i = 0; i < 16; ++i) tempM[i / 4][i % 4] = coordSB[i]->text().toFloat(); - rp->setValue(Matrix44fValue(tempM)); + Matrix44m tempM; + for (unsigned int i = 0; i < 16; ++i) + tempM[i / 4][i % 4] = coordSB[i]->text().toFloat(); + parameter->setValue(Matrix44fValue(tempM)); } else - rp->setValue(Matrix44fValue(m)); + parameter->setValue(Matrix44fValue(m)); } void Matrix44fWidget::resetWidgetValue() { valid = false; - vcg::Matrix44f m; m.SetIdentity(); - for(unsigned int ii = 0; ii < 16;++ii) - coordSB[ii]->setText(QString::number(rp->value().getMatrix44f()[ii/4][ii%4],'g',3)); + vcg::Matrix44f m; + m.SetIdentity(); + for (unsigned int ii = 0; ii < 16; ++ii) + coordSB[ii]->setText( + QString::number(parameter->value().getMatrix44f()[ii / 4][ii % 4], 'g', 3)); } -void Matrix44fWidget::setWidgetValue( const Value& nv ) +void Matrix44fWidget::setWidgetValue(const Value& nv) { valid = true; - m = nv.getMatrix44f(); - for(unsigned int ii = 0; ii < 16;++ii) - coordSB[ii]->setText(QString::number(nv.getMatrix44f()[ii/4][ii%4],'g',3)); + m = nv.getMatrix44f(); + for (unsigned int ii = 0; ii < 16; ++ii) + coordSB[ii]->setText(QString::number(nv.getMatrix44f()[ii / 4][ii % 4], 'g', 3)); } -void Matrix44fWidget::addWidgetToGridLayout( QGridLayout* lay,const int r ) +void Matrix44fWidget::addWidgetToGridLayout(QGridLayout* lay, const int r) { - if (lay != NULL) - { - lay->addWidget(descLab,r,0,Qt::AlignTop); - lay->addLayout(vlay,r,1,Qt::AlignTop); + if (lay != NULL) { + lay->addLayout(vlay, r, 1, Qt::AlignTop); } - RichParameterWidget::addWidgetToGridLayout(lay,r); + RichParameterWidget::addWidgetToGridLayout(lay, r); } void Matrix44fWidget::invalidateMatrix(const QString& /*s*/) @@ -887,25 +908,23 @@ void Matrix44fWidget::invalidateMatrix(const QString& /*s*/) // ShotfWidget Implementation /******************************************/ -ShotfWidget::ShotfWidget(QWidget *p, const RichShotf& rpf, const RichShotf& rdef, QWidget *gla_curr): - RichParameterWidget(p,rpf, rdef) +ShotfWidget::ShotfWidget( + QWidget* p, + const RichShotf& rpf, + const RichShotf& rdef, + QWidget* gla_curr) : + RichParameterWidget(p, rpf, rdef) { - paramName = rpf.name(); - //int row = gridLay->rowCount() - 1; - - descLab = new QLabel(rpf.fieldDescription(),p); - descLab->setToolTip(rpf.fieldDescription()); - //gridLay->addWidget(descLab,row,0,Qt::AlignTop); hlay = new QHBoxLayout(); - - this->setShotValue(paramName,rp->value().getShotf()); - if(gla_curr) // if we have a connection to the current glarea we can setup the additional button for getting the current view direction. + this->setShotValue(paramName, parameter->value().getShotf()); + if (gla_curr) // if we have a connection to the current glarea we can setup the additional + // button for getting the current view direction. { - getShotButton = new QPushButton("Get shot",this); - getShotButton->setSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Preferred); + getShotButton = new QPushButton("Get shot", this); + getShotButton->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred); hlay->addWidget(getShotButton); QStringList names; @@ -917,51 +936,56 @@ ShotfWidget::ShotfWidget(QWidget *p, const RichShotf& rpf, const RichShotf& rdef getShotCombo = new QComboBox(this); getShotCombo->addItems(names); hlay->addWidget(getShotCombo); - connect(getShotCombo,SIGNAL(currentIndexChanged(int)),this,SLOT(getShot())); - connect(getShotButton,SIGNAL(clicked()),this,SLOT(getShot())); - connect(gla_curr,SIGNAL(transmitShot(QString, Shotm)),this,SLOT(setShotValue(QString,Shotm))); - connect(this,SIGNAL(askViewerShot(QString)),gla_curr,SLOT(sendViewerShot(QString))); - connect(this,SIGNAL(askMeshShot(QString)), gla_curr,SLOT(sendMeshShot(QString))); - connect(this,SIGNAL(askRasterShot(QString)),gla_curr,SLOT(sendRasterShot(QString))); + connect(getShotCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(getShot())); + connect(getShotButton, SIGNAL(clicked()), this, SLOT(getShot())); + connect( + gla_curr, + SIGNAL(transmitShot(QString, Shotm)), + this, + SLOT(setShotValue(QString, Shotm))); + connect(this, SIGNAL(askViewerShot(QString)), gla_curr, SLOT(sendViewerShot(QString))); + connect(this, SIGNAL(askMeshShot(QString)), gla_curr, SLOT(sendMeshShot(QString))); + connect(this, SIGNAL(askRasterShot(QString)), gla_curr, SLOT(sendRasterShot(QString))); } - //gridLay->addLayout(hlay,row,1,Qt::AlignTop); + // gridLay->addLayout(hlay,row,1,Qt::AlignTop); } void ShotfWidget::getShot() { int index = getShotCombo->currentIndex(); - switch(index) { - case 0 : emit askViewerShot(paramName); break; - case 1 : emit askMeshShot(paramName); break; - case 2 : emit askRasterShot(paramName); break; - case 3: - { - QString filename = QFileDialog::getOpenFileName(this, tr("Load xml camera"), "./", tr("Xml Files (*.xml)")); - QFile qf(filename); - QFileInfo qfInfo(filename); + switch (index) { + case 0: emit askViewerShot(paramName); break; + case 1: emit askMeshShot(paramName); break; + case 2: emit askRasterShot(paramName); break; + case 3: { + QString filename = QFileDialog::getOpenFileName( + this, tr("Load xml camera"), "./", tr("Xml Files (*.xml)")); + QFile qf(filename); + QFileInfo qfInfo(filename); - if( !qf.open(QIODevice::ReadOnly ) ) - return ; + if (!qf.open(QIODevice::ReadOnly)) + return; - QDomDocument doc("XmlDocument"); //It represents the XML document - if(!doc.setContent( &qf )) return; - qf.close(); + QDomDocument doc("XmlDocument"); // It represents the XML document + if (!doc.setContent(&qf)) + return; + qf.close(); - QString type = doc.doctype().name(); + QString type = doc.doctype().name(); - } - break; - default : assert(0); + } break; + default: assert(0); } } -ShotfWidget::~ShotfWidget() {} - -void ShotfWidget::setShotValue(QString name,Shotm newVal) +ShotfWidget::~ShotfWidget() { - if(name==paramName) - { - curShot=newVal; +} + +void ShotfWidget::setShotValue(QString name, Shotm newVal) +{ + if (name == paramName) { + curShot = newVal; } } @@ -972,72 +996,72 @@ Shotm ShotfWidget::getValue() void ShotfWidget::collectWidgetValue() { - rp->setValue(ShotfValue(curShot)); + parameter->setValue(ShotfValue(curShot)); } void ShotfWidget::resetWidgetValue() { - curShot = rp->value().getShotf(); + curShot = parameter->value().getShotf(); } -void ShotfWidget::setWidgetValue( const Value& nv ) +void ShotfWidget::setWidgetValue(const Value& nv) { curShot = nv.getShotf(); } -void ShotfWidget::addWidgetToGridLayout( QGridLayout* lay,const int r ) +void ShotfWidget::addWidgetToGridLayout(QGridLayout* lay, const int r) { - if (lay != NULL) - { - lay->addLayout(hlay,r,1); - lay->addWidget(descLab,r,0); + if (lay != NULL) { + lay->addLayout(hlay, r, 1); } - RichParameterWidget::addWidgetToGridLayout(lay,r); + RichParameterWidget::addWidgetToGridLayout(lay, r); } /******************************************/ // DynamicFloatWidget Implementation /******************************************/ -DynamicFloatWidget::DynamicFloatWidget(QWidget *p, const RichDynamicFloat& rdf, const RichDynamicFloat& rdef): - RichParameterWidget(p,rdf, rdef) +DynamicFloatWidget::DynamicFloatWidget( + QWidget* p, + const RichDynamicFloat& rdf, + const RichDynamicFloat& rdef) : + RichParameterWidget(p, rdf, rdef) { int numbdecimaldigit = 4; - minVal = rdf.min; - maxVal = rdf.max; - valueLE = new QLineEdit(this); + minVal = rdf.min; + maxVal = rdf.max; + valueLE = new QLineEdit(this); valueLE->setAlignment(Qt::AlignRight); - valueSlider = new QSlider(Qt::Horizontal,this); - valueSlider->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed); - fieldDesc = new QLabel(rp->fieldDescription(),this); + valueSlider = new QSlider(Qt::Horizontal, this); + valueSlider->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); valueSlider->setMinimum(0); valueSlider->setMaximum(100); - valueSlider->setValue(floatToInt(rp->value().getFloat())); - RichDynamicFloat* dfd = reinterpret_cast(rp); - //const DynamicFloatDecoration* dfd = reinterpret_cast(&(rp->pd)); + valueSlider->setValue(floatToInt(parameter->value().getFloat())); + RichDynamicFloat* dfd = reinterpret_cast(parameter); + // const DynamicFloatDecoration* dfd = reinterpret_cast(&(rp->pd)); QFontMetrics fm(valueLE->font()); - QSize sz = fm.size(Qt::TextSingleLine,QString::number(0)); - valueLE->setValidator(new QDoubleValidator (dfd->min,dfd->max, numbdecimaldigit, valueLE)); - valueLE->setText(QString::number(rp->value().getFloat())); - valueLE->setSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Fixed); + QSize sz = fm.size(Qt::TextSingleLine, QString::number(0)); + valueLE->setValidator(new QDoubleValidator(dfd->min, dfd->max, numbdecimaldigit, valueLE)); + valueLE->setText(QString::number(parameter->value().getFloat())); + valueLE->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); - //int row = gridLay->rowCount() - 1; - //lay->addWidget(fieldDesc,row,0); + // int row = gridLay->rowCount() - 1; + // lay->addWidget(fieldDesc,row,0); hlay = new QHBoxLayout(); hlay->addWidget(valueLE); hlay->addWidget(valueSlider); - int maxlenghtplusdot = 8;//numbmaxvaluedigit + numbdecimaldigit + 1; + int maxlenghtplusdot = 8; // numbmaxvaluedigit + numbdecimaldigit + 1; valueLE->setMaxLength(maxlenghtplusdot); valueLE->setMaximumWidth(sz.width() * maxlenghtplusdot); + // gridLay->addLayout(hlay,row,1); - //gridLay->addLayout(hlay,row,1); - - connect(valueLE,SIGNAL(textChanged(const QString &)),this,SLOT(setValue())); - connect(valueSlider,SIGNAL(valueChanged(int)),this,SLOT(setValue(int))); - connect(this,SIGNAL(dialogParamChanged()),p,SIGNAL(parameterChanged())); + connect(valueLE, SIGNAL(textChanged(const QString&)), this, SLOT(setValue())); + connect(valueSlider, SIGNAL(valueChanged(int)), this, SLOT(setValue(int))); + connect(this, SIGNAL(dialogParamChanged()), p, SIGNAL(parameterChanged())); } DynamicFloatWidget::~DynamicFloatWidget() @@ -1049,81 +1073,77 @@ float DynamicFloatWidget::getValue() return float(valueLE->text().toDouble()); } -void DynamicFloatWidget::setValue(float newVal) +void DynamicFloatWidget::setValue(float newVal) { - if( QString::number(intToFloat(newVal)) != valueLE->text()) + if (QString::number(intToFloat(newVal)) != valueLE->text()) valueLE->setText(QString::number(intToFloat(newVal))); } -void DynamicFloatWidget::setValue(int newVal) +void DynamicFloatWidget::setValue(int newVal) { - if(floatToInt(float(valueLE->text().toDouble())) != newVal) - { + if (floatToInt(float(valueLE->text().toDouble())) != newVal) { valueLE->setText(QString::number(intToFloat(newVal))); } } void DynamicFloatWidget::setValue() { - float newValLE=float(valueLE->text().toDouble()); + float newValLE = float(valueLE->text().toDouble()); valueSlider->setValue(floatToInt(newValLE)); emit dialogParamChanged(); } float DynamicFloatWidget::intToFloat(int val) { - return minVal+float(val)/100.0f*(maxVal-minVal); + return minVal + float(val) / 100.0f * (maxVal - minVal); } int DynamicFloatWidget::floatToInt(float val) { - return int (100.0f*(val-minVal)/(maxVal-minVal)); + return int(100.0f * (val - minVal) / (maxVal - minVal)); } void DynamicFloatWidget::collectWidgetValue() { - rp->setValue(FloatValue(valueLE->text().toFloat())); + parameter->setValue(FloatValue(valueLE->text().toFloat())); } void DynamicFloatWidget::resetWidgetValue() { - valueLE->setText(QString::number(rp->value().getFloat())); + valueLE->setText(QString::number(parameter->value().getFloat())); } -void DynamicFloatWidget::setWidgetValue( const Value& nv ) +void DynamicFloatWidget::setWidgetValue(const Value& nv) { valueLE->setText(QString::number(nv.getFloat())); } -void DynamicFloatWidget::addWidgetToGridLayout( QGridLayout* lay,const int r ) +void DynamicFloatWidget::addWidgetToGridLayout(QGridLayout* lay, const int r) { - if (lay != NULL) - { - lay->addWidget(fieldDesc,r,0); - lay->addLayout(hlay,r,1); + if (lay != NULL) { + lay->addLayout(hlay, r, 1); } - RichParameterWidget::addWidgetToGridLayout(lay,r); + RichParameterWidget::addWidgetToGridLayout(lay, r); } /******************************************/ // ComboWidget Implementation /******************************************/ -ComboWidget::ComboWidget(QWidget *p, const RichParameter& rpar, const RichParameter& rdef) : - RichParameterWidget(p,rpar, rdef) { +ComboWidget::ComboWidget(QWidget* p, const RichParameter& rpar, const RichParameter& rdef) : + RichParameterWidget(p, rpar, rdef) +{ } -void ComboWidget::Init(QWidget *p,int defaultEnum, QStringList values) +void ComboWidget::Init(QWidget* p, int defaultEnum, QStringList values) { - enumLabel = new QLabel(this); - enumLabel->setText(rp->fieldDescription()); enumCombo = new QComboBox(this); enumCombo->addItems(values); setIndex(defaultEnum); - //int row = gridLay->rowCount() - 1; - //gridLay->addWidget(enumLabel,row,0,Qt::AlignTop); - //gridLay->addWidget(enumCombo,row,1,Qt::AlignTop); - connect(enumCombo,SIGNAL(activated(int)),this,SIGNAL(dialogParamChanged())); - connect(this,SIGNAL(dialogParamChanged()),p,SIGNAL(parameterChanged())); + // int row = gridLay->rowCount() - 1; + // gridLay->addWidget(enumLabel,row,0,Qt::AlignTop); + // gridLay->addWidget(enumCombo,row,1,Qt::AlignTop); + connect(enumCombo, SIGNAL(activated(int)), this, SIGNAL(dialogParamChanged())); + connect(this, SIGNAL(dialogParamChanged()), p, SIGNAL(parameterChanged())); } void ComboWidget::setIndex(int newEnum) @@ -1139,29 +1159,26 @@ int ComboWidget::getIndex() ComboWidget::~ComboWidget() { delete enumCombo; - delete enumLabel; } -void ComboWidget::addWidgetToGridLayout( QGridLayout* lay,const int r ) +void ComboWidget::addWidgetToGridLayout(QGridLayout* lay, const int r) { - if (lay != NULL) - { - lay->addWidget(enumLabel,r,0); - lay->addWidget(enumCombo,r,1); + if (lay != NULL) { + lay->addWidget(enumCombo, r, 1); } - RichParameterWidget::addWidgetToGridLayout(lay,r); + RichParameterWidget::addWidgetToGridLayout(lay, r); } /******************************************/ -//EnumWidget Implementation +// EnumWidget Implementation /******************************************/ -EnumWidget::EnumWidget(QWidget *p, const RichEnum& rpar, const RichEnum& rdef) : - ComboWidget(p,rpar, rdef) +EnumWidget::EnumWidget(QWidget* p, const RichEnum& rpar, const RichEnum& rdef) : + ComboWidget(p, rpar, rdef) { - //you MUST call it!!!! - Init(p,rpar.value().getInt(),rpar.enumvalues); - //assert(enumCombo != NULL); + // you MUST call it!!!! + Init(p, rpar.value().getInt(), rpar.enumvalues); + // assert(enumCombo != NULL); } int EnumWidget::getSize() @@ -1171,60 +1188,60 @@ int EnumWidget::getSize() void EnumWidget::collectWidgetValue() { - rp->setValue(IntValue(enumCombo->currentIndex())); + parameter->setValue(IntValue(enumCombo->currentIndex())); } void EnumWidget::resetWidgetValue() { - enumCombo->setCurrentIndex(rp->value().getInt()); + enumCombo->setCurrentIndex(parameter->value().getInt()); } -void EnumWidget::setWidgetValue( const Value& nv ) +void EnumWidget::setWidgetValue(const Value& nv) { enumCombo->setCurrentIndex(nv.getInt()); } /******************************************/ -//MeshWidget Implementation +// MeshWidget Implementation /******************************************/ -MeshWidget::MeshWidget(QWidget *p, const RichMesh& rpar, const RichMesh& rdef) : - ComboWidget(p,rpar, rdef) +MeshWidget::MeshWidget(QWidget* p, const RichMesh& rpar, const RichMesh& rdef) : + ComboWidget(p, rpar, rdef) { - md=((RichMesh*)rp)->meshdoc; + md = ((RichMesh*) parameter)->meshdoc; QStringList meshNames; - //make the default mesh Index be 0 - //defaultMeshIndex = -1; + // make the default mesh Index be 0 + // defaultMeshIndex = -1; - int currentmeshindex = -1; - unsigned int i = 0; - for(const MeshModel& mm : md->meshIterator()) { + int currentmeshindex = -1; + unsigned int i = 0; + for (const MeshModel& mm : md->meshIterator()) { QString shortName = mm.label(); meshNames.push_back(shortName); - if(mm.id() == (unsigned int)rp->value().getInt()) { + if (mm.id() == (unsigned int) parameter->value().getInt()) { currentmeshindex = i; } ++i; } - Init(p,currentmeshindex,meshNames); + Init(p, currentmeshindex, meshNames); } void MeshWidget::collectWidgetValue() { auto it = md->meshBegin(); std::advance(it, enumCombo->currentIndex()); - rp->setValue(IntValue((*it).id())); + parameter->setValue(IntValue((*it).id())); } void MeshWidget::resetWidgetValue() { - int meshindex = -1; - unsigned int i = 0; - for(const MeshModel& mm : md->meshIterator()) { - if(mm.id() == (unsigned int)rp->value().getInt()) { + int meshindex = -1; + unsigned int i = 0; + for (const MeshModel& mm : md->meshIterator()) { + if (mm.id() == (unsigned int) parameter->value().getInt()) { meshindex = i; } ++i; @@ -1232,12 +1249,12 @@ void MeshWidget::resetWidgetValue() enumCombo->setCurrentIndex(meshindex); } -void MeshWidget::setWidgetValue( const Value& nv ) +void MeshWidget::setWidgetValue(const Value& nv) { - int meshindex = -1; - unsigned int i = 0; - for(const MeshModel& mm : md->meshIterator()) { - if(mm.id() == (unsigned int)nv.getInt()) { + int meshindex = -1; + unsigned int i = 0; + for (const MeshModel& mm : md->meshIterator()) { + if (mm.id() == (unsigned int) nv.getInt()) { meshindex = i; } ++i; @@ -1246,44 +1263,42 @@ void MeshWidget::setWidgetValue( const Value& nv ) } /******************************************/ -//IOFileWidget Implementation +// IOFileWidget Implementation /******************************************/ -IOFileWidget::IOFileWidget(QWidget* p, const RichParameter& rpar , const RichParameter& rdef) : - RichParameterWidget(p,rpar, rdef) +IOFileWidget::IOFileWidget(QWidget* p, const RichParameter& rpar, const RichParameter& rdef) : + RichParameterWidget(p, rpar, rdef) { filename = new QLineEdit(this); filename->setText(tr("")); - browse = new QPushButton(this); - descLab = new QLabel(rp->fieldDescription(),this); + browse = new QPushButton(this); browse->setText("..."); - //const QColor cl = rp->pd->defvalue().getColor(); - //resetWidgetValue(); - //int row = gridLay->rowCount() - 1; - //gridLay->addWidget(descLab,row,0,Qt::AlignTop); + // const QColor cl = rp->pd->defvalue().getColor(); + // resetWidgetValue(); + // int row = gridLay->rowCount() - 1; + // gridLay->addWidget(descLab,row,0,Qt::AlignTop); hlay = new QHBoxLayout(); - hlay->addWidget(filename,2); + hlay->addWidget(filename, 2); hlay->addWidget(browse); - connect(browse,SIGNAL(clicked()),this,SLOT(selectFile())); - connect(this,SIGNAL(dialogParamChanged()),p,SIGNAL(parameterChanged())); + connect(browse, SIGNAL(clicked()), this, SLOT(selectFile())); + connect(this, SIGNAL(dialogParamChanged()), p, SIGNAL(parameterChanged())); } IOFileWidget::~IOFileWidget() { delete filename; delete browse; - delete descLab; } void IOFileWidget::collectWidgetValue() { - rp->setValue(StringValue(filename->text())); + parameter->setValue(StringValue(filename->text())); } void IOFileWidget::resetWidgetValue() { - QString fle = rp->value().getString(); + QString fle = parameter->value().getString(); updateFileName(fle); } @@ -1293,30 +1308,28 @@ void IOFileWidget::setWidgetValue(const Value& nv) updateFileName(fle); } -void IOFileWidget::updateFileName( const StringValue& file ) +void IOFileWidget::updateFileName(const StringValue& file) { filename->setText(file.getString()); } -void IOFileWidget::addWidgetToGridLayout( QGridLayout* lay,const int r ) +void IOFileWidget::addWidgetToGridLayout(QGridLayout* lay, const int r) { - if (lay != NULL) - { - lay->addWidget(descLab,r,0,Qt::AlignTop); - lay->addLayout(hlay,r,1,Qt::AlignTop); + if (lay != NULL) { + lay->addLayout(hlay, r, 1, Qt::AlignTop); } - RichParameterWidget::addWidgetToGridLayout(lay,r); + RichParameterWidget::addWidgetToGridLayout(lay, r); } /******************************************/ -//SaveFileWidget Implementation +// SaveFileWidget Implementation /******************************************/ -SaveFileWidget::SaveFileWidget(QWidget* p, const RichSaveFile& rpar , const RichSaveFile& rdef) : - IOFileWidget(p,rpar, rdef) +SaveFileWidget::SaveFileWidget(QWidget* p, const RichSaveFile& rpar, const RichSaveFile& rdef) : + IOFileWidget(p, rpar, rdef) { - filename->setText(rp->value().getString()); - QString tmp = rp->value().getString(); + filename->setText(parameter->value().getString()); + QString tmp = parameter->value().getString(); } SaveFileWidget::~SaveFileWidget() @@ -1325,43 +1338,43 @@ SaveFileWidget::~SaveFileWidget() void SaveFileWidget::selectFile() { - //SaveFileDecoration* dec = reinterpret_cast(rp->pd); - RichSaveFile* dec = reinterpret_cast(rp); - QString ext; - QString fl = QFileDialog::getSaveFileName(this,tr("Save"),rp->value().getString(),dec->ext); + // SaveFileDecoration* dec = reinterpret_cast(rp->pd); + RichSaveFile* dec = reinterpret_cast(parameter); + QString ext; + QString fl = + QFileDialog::getSaveFileName(this, tr("Save"), parameter->value().getString(), dec->ext); collectWidgetValue(); updateFileName(fl); StringValue fileName(fl); - rp->setValue(fileName); + parameter->setValue(fileName); emit dialogParamChanged(); } /******************************************/ -//OpenFileWidget Implementation +// OpenFileWidget Implementation /******************************************/ -OpenFileWidget::OpenFileWidget(QWidget *p, const RichOpenFile& rdf, const RichOpenFile& rdef) : - IOFileWidget(p,rdf, rdef) +OpenFileWidget::OpenFileWidget(QWidget* p, const RichOpenFile& rdf, const RichOpenFile& rdef) : + IOFileWidget(p, rdf, rdef) { } void OpenFileWidget::selectFile() { - //OpenFileDecoration* dec = reinterpret_cast(rp->pd); - RichOpenFile* dec = reinterpret_cast(rp); - QString ext; - QString path = QDir::homePath(); - if (!rp->value().getString().isEmpty()) - path = rp->value().getString(); - QString fl = QFileDialog::getOpenFileName(this,tr("Open"), path, dec->exts.join(";;")); + // OpenFileDecoration* dec = reinterpret_cast(rp->pd); + RichOpenFile* dec = reinterpret_cast(parameter); + QString ext; + QString path = QDir::homePath(); + if (!parameter->value().getString().isEmpty()) + path = parameter->value().getString(); + QString fl = QFileDialog::getOpenFileName(this, tr("Open"), path, dec->exts.join(";;")); collectWidgetValue(); updateFileName(fl); StringValue fileName(fl); - rp->setValue(fileName); + parameter->setValue(fileName); emit dialogParamChanged(); } - OpenFileWidget::~OpenFileWidget() { } diff --git a/src/meshlab/rich_parameter_gui/richparameterwidgets.h b/src/meshlab/rich_parameter_gui/richparameterwidgets.h index 955ff78f9..44607ee5c 100644 --- a/src/meshlab/rich_parameter_gui/richparameterwidgets.h +++ b/src/meshlab/rich_parameter_gui/richparameterwidgets.h @@ -1,41 +1,41 @@ -/**************************************************************************** -* MeshLab 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. * -* * -****************************************************************************/ +/***************************************************************************** + * MeshLab o o * + * Visual and Computer Graphics Library o o * + * _ O _ * + * Copyright(C) 2004-2021 \/)\/ * + * 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 RICHPARAMETERLISTWIDGETS_H #define RICHPARAMETERLISTWIDGETS_H -#include +#include +#include +#include #include #include -#include #include #include -#include -#include #include +#include -#include #include +#include class RichParameterWidget : public QWidget { @@ -45,93 +45,97 @@ public: // this one is called by resetValue to reset the values inside the widgets. virtual void resetWidgetValue() = 0; - // bring the values from the Qt widgets to the parameter (e.g. from the checkBox to the parameter). - virtual void collectWidgetValue() = 0; + // bring the values from the Qt widgets to the parameter (e.g. from the checkBox to the + // parameter). + virtual void collectWidgetValue() = 0; virtual void setWidgetValue(const Value& nv) = 0; virtual ~RichParameterWidget(); - virtual void addWidgetToGridLayout(QGridLayout* lay,const int r) = 0; + virtual void addWidgetToGridLayout(QGridLayout* lay, const int r) = 0; // called when the user press the 'default' button to reset the parameter values to its default. - // It just set the parameter value and then it calls the specialized resetWidgetValue() to update also the widget. + // It just set the parameter value and then it calls the specialized resetWidgetValue() to + // update also the widget. void resetValue(); void setValue(const Value& v); + void setHelpVisible(bool b); // update the parameter with the current widget values and return it. - const Value& widgetValue(); + const Value& widgetValue(); const RichParameter& richParameter() const; QString parameterName() const; - QLabel* helpLab; - signals: void parameterChanged(); + protected: - RichParameter* rp; - RichParameter* defp; + QLabel* descriptionLabel; + QLabel* helpLabel; + + RichParameter* parameter; + RichParameter* defaultParameter; }; class BoolWidget : public RichParameterWidget { public: - BoolWidget(QWidget* p, const RichBool& rb, const RichBool&rdef); + BoolWidget(QWidget* p, const RichBool& rb, const RichBool& rdef); ~BoolWidget(); - void addWidgetToGridLayout(QGridLayout* lay,const int r); + void addWidgetToGridLayout(QGridLayout* lay, const int r); void collectWidgetValue(); void resetWidgetValue(); void setWidgetValue(const Value& nv); private: - QLabel* descriptionLabel; QCheckBox* cb; }; class LineEditWidget : public RichParameterWidget { - Q_OBJECT + Q_OBJECT protected: - QLabel* lab; QLineEdit* lned; - QString lastVal; + QString lastVal; + +private slots: + void changeChecker(); +signals: + void lineEditChanged(); - private slots: - void changeChecker(); - signals: - void lineEditChanged(); public: - LineEditWidget(QWidget* p, const RichParameter& rpar, const RichParameter&rdef); + LineEditWidget(QWidget* p, const RichParameter& rpar, const RichParameter& rdef); ~LineEditWidget(); - void addWidgetToGridLayout(QGridLayout* lay,const int r); - virtual void collectWidgetValue() = 0; - virtual void resetWidgetValue() = 0; + void addWidgetToGridLayout(QGridLayout* lay, const int r); + virtual void collectWidgetValue() = 0; + virtual void resetWidgetValue() = 0; virtual void setWidgetValue(const Value& nv) = 0; }; class IntWidget : public LineEditWidget { public: - IntWidget(QWidget* p, const RichInt& rpar, const RichInt&rdef); - ~IntWidget(){} + IntWidget(QWidget* p, const RichInt& rpar, const RichInt& rdef); + ~IntWidget() {} void collectWidgetValue(); void resetWidgetValue(); void setWidgetValue(const Value& nv); }; -class FloatWidget : public LineEditWidget +class FloatWidget : public LineEditWidget { public: FloatWidget(QWidget* p, const RichFloat& rpar, const RichFloat& rdef); - ~FloatWidget(){} + ~FloatWidget() {} void collectWidgetValue(); void resetWidgetValue(); void setWidgetValue(const Value& nv); }; -class StringWidget : public LineEditWidget +class StringWidget : public LineEditWidget { public: StringWidget(QWidget* p, const RichString& rpar, const RichString& rdef); - ~StringWidget(){} + ~StringWidget() {} void collectWidgetValue(); void resetWidgetValue(); void setWidgetValue(const Value& nv); @@ -141,17 +145,17 @@ class ColorWidget : public RichParameterWidget { Q_OBJECT public: - ColorWidget(QWidget *p, const RichColor& newColor, const RichColor& rdef); + ColorWidget(QWidget* p, const RichColor& newColor, const RichColor& rdef); ~ColorWidget(); - void addWidgetToGridLayout(QGridLayout* lay,const int r); + void addWidgetToGridLayout(QGridLayout* lay, const int r); void collectWidgetValue(); void resetWidgetValue(); void setWidgetValue(const Value& nv); void initWidgetValue(); private: - void updateColorInfo(const ColorValue& newColor); + void updateColorInfo(const ColorValue& newColor); private slots: void pickColor(); signals: @@ -162,16 +166,15 @@ protected: private: QPushButton* colorButton; - QLabel* colorLabel; - QLabel* descLabel; - QColor pickcol; + QLabel* colorLabel; + QColor pickcol; }; class AbsPercWidget : public RichParameterWidget { Q_OBJECT public: - AbsPercWidget(QWidget *p, const RichAbsPerc& rabs, const RichAbsPerc& rdef); + AbsPercWidget(QWidget* p, const RichAbsPerc& rabs, const RichAbsPerc& rdef); ~AbsPercWidget(); void addWidgetToGridLayout(QGridLayout* lay, const int r); @@ -180,7 +183,7 @@ public: void setWidgetValue(const Value& nv); private: - void setValue(float val, float minV, float maxV); + void setValue(float val, float minV, float maxV); public slots: @@ -190,43 +193,41 @@ signals: void dialogParamChanged(); protected: - QDoubleSpinBox *absSB; - QDoubleSpinBox *percSB; - QLabel* fieldDesc; - float m_min; - float m_max; - QGridLayout* vlay; + QDoubleSpinBox* absSB; + QDoubleSpinBox* percSB; + float m_min; + float m_max; + QGridLayout* vlay; }; class PositionWidget : public RichParameterWidget { Q_OBJECT public: - PositionWidget(QWidget *p, const RichPosition& rpf, const RichPosition& rdef, QWidget *gla); + PositionWidget(QWidget* p, const RichPosition& rpf, const RichPosition& rdef, QWidget* gla); ~PositionWidget(); - QString paramName; + QString paramName; vcg::Point3f getValue(); - void addWidgetToGridLayout(QGridLayout* lay,const int r); + void addWidgetToGridLayout(QGridLayout* lay, const int r); void collectWidgetValue(); void resetWidgetValue(); void setWidgetValue(const Value& nv); - public slots: - void getPoint(); - void setValue(QString name, Point3m val); - void setShotValue(QString name, Shotm val); - signals: +public slots: + void getPoint(); + void setValue(QString name, Point3m val); + void setShotValue(QString name, Shotm val); +signals: void askViewPos(QString); void askSurfacePos(QString); void askCameraPos(QString); void askTrackballPos(QString); protected: - QLineEdit * coordSB[3]; - QComboBox *getPoint3Combo; - QPushButton *getPoint3Button; - QLabel* descLab; + QLineEdit* coordSB[3]; + QComboBox* getPoint3Combo; + QPushButton* getPoint3Button; QHBoxLayout* vlay; }; @@ -234,29 +235,28 @@ class DirectionWidget : public RichParameterWidget { Q_OBJECT public: - DirectionWidget(QWidget *p, const RichDirection& rpf, const RichDirection& rdef, QWidget *gla); + DirectionWidget(QWidget* p, const RichDirection& rpf, const RichDirection& rdef, QWidget* gla); ~DirectionWidget(); - QString paramName; + QString paramName; vcg::Point3f getValue(); - void addWidgetToGridLayout(QGridLayout* lay,const int r); + void addWidgetToGridLayout(QGridLayout* lay, const int r); void collectWidgetValue(); void resetWidgetValue(); void setWidgetValue(const Value& nv); public slots: - void getPoint(); - void setValue(QString name, Point3m val); - void setShotValue(QString name, Shotm val); + void getPoint(); + void setValue(QString name, Point3m val); + void setShotValue(QString name, Shotm val); signals: void askViewDir(QString); void askCameraDir(QString); protected: - QLineEdit * coordSB[3]; - QComboBox *getPoint3Combo; - QPushButton *getPoint3Button; - QLabel* descLab; + QLineEdit* coordSB[3]; + QComboBox* getPoint3Combo; + QPushButton* getPoint3Button; QHBoxLayout* vlay; }; @@ -265,12 +265,16 @@ class Matrix44fWidget : public RichParameterWidget Q_OBJECT public: - Matrix44fWidget(QWidget *p, const RichMatrix44f& rpf, const RichMatrix44f& rdef, QWidget *gla_curr); + Matrix44fWidget( + QWidget* p, + const RichMatrix44f& rpf, + const RichMatrix44f& rdef, + QWidget* gla_curr); ~Matrix44fWidget(); - QString paramName; + QString paramName; Matrix44m getValue(); - void addWidgetToGridLayout(QGridLayout* lay,const int r); + void addWidgetToGridLayout(QGridLayout* lay, const int r); void collectWidgetValue(); void resetWidgetValue(); void setWidgetValue(const Value& nv); @@ -284,13 +288,12 @@ signals: void askMeshMatrix(QString); protected: - QLineEdit * coordSB[16]; - QPushButton *getPoint3Button; - QLabel* descLab; + QLineEdit* coordSB[16]; + QPushButton* getPoint3Button; QGridLayout* lay44; QVBoxLayout* vlay; - Matrix44m m; - bool valid; + Matrix44m m; + bool valid; }; class ShotfWidget : public RichParameterWidget @@ -298,30 +301,29 @@ class ShotfWidget : public RichParameterWidget Q_OBJECT public: - ShotfWidget(QWidget *p, const RichShotf& rpf, const RichShotf& rdef, QWidget *gla); + ShotfWidget(QWidget* p, const RichShotf& rpf, const RichShotf& rdef, QWidget* gla); ~ShotfWidget(); QString paramName; - Shotm getValue(); + Shotm getValue(); - void addWidgetToGridLayout(QGridLayout* lay,const int r); + void addWidgetToGridLayout(QGridLayout* lay, const int r); void collectWidgetValue(); void resetWidgetValue(); void setWidgetValue(const Value& nv); public slots: - void getShot(); - void setShotValue(QString name, Shotm val); + void getShot(); + void setShotValue(QString name, Shotm val); signals: void askRasterShot(QString); void askMeshShot(QString); void askViewerShot(QString); protected: - Shotm curShot; - QLineEdit * shotLE; - QPushButton *getShotButton; - QComboBox *getShotCombo; - QLabel* descLab; + Shotm curShot; + QLineEdit* shotLE; + QPushButton* getShotButton; + QComboBox* getShotCombo; QHBoxLayout* hlay; }; @@ -330,13 +332,13 @@ class DynamicFloatWidget : public RichParameterWidget Q_OBJECT public: - DynamicFloatWidget(QWidget *p, const RichDynamicFloat& rdf, const RichDynamicFloat& rdef); + DynamicFloatWidget(QWidget* p, const RichDynamicFloat& rdf, const RichDynamicFloat& rdef); ~DynamicFloatWidget(); float getValue(); void setValue(float val, float minV, float maxV); - void addWidgetToGridLayout(QGridLayout* lay,const int r); + void addWidgetToGridLayout(QGridLayout* lay, const int r); void collectWidgetValue(); void resetWidgetValue(); void setWidgetValue(const Value& nv); @@ -347,38 +349,38 @@ public slots: void setValue(float newValue); signals: - //void valueChanged(int mask); + // void valueChanged(int mask); void dialogParamChanged(); protected: - QLineEdit *valueLE; - QSlider *valueSlider; - QLabel* fieldDesc; - float minVal; - float maxVal; + QLineEdit* valueLE; + QSlider* valueSlider; + float minVal; + float maxVal; QHBoxLayout* hlay; -private : + +private: float intToFloat(int val); - int floatToInt(float val); + int floatToInt(float val); }; class ComboWidget : public RichParameterWidget { Q_OBJECT protected: - QComboBox *enumCombo; - QLabel *enumLabel; + QComboBox* enumCombo; + public: - ComboWidget(QWidget *p, const RichParameter& rpar, const RichParameter& rdef); + ComboWidget(QWidget* p, const RichParameter& rpar, const RichParameter& rdef); ~ComboWidget(); - void Init(QWidget *p,int newEnum, QStringList values); - void addWidgetToGridLayout(QGridLayout* lay,const int r); - virtual void collectWidgetValue() = 0; - virtual void resetWidgetValue() = 0; + void Init(QWidget* p, int newEnum, QStringList values); + void addWidgetToGridLayout(QGridLayout* lay, const int r); + virtual void collectWidgetValue() = 0; + virtual void resetWidgetValue() = 0; virtual void setWidgetValue(const Value& nv) = 0; - int getIndex(); - void setIndex(int newEnum); + int getIndex(); + void setIndex(int newEnum); signals: void dialogParamChanged(); @@ -389,24 +391,25 @@ class EnumWidget : public ComboWidget Q_OBJECT public: - EnumWidget(QWidget *p, const RichEnum& rpar, const RichEnum& rdef); - ~EnumWidget(){}; + EnumWidget(QWidget* p, const RichEnum& rpar, const RichEnum& rdef); + ~EnumWidget() {}; void collectWidgetValue(); void resetWidgetValue(); void setWidgetValue(const Value& nv); - //returns the number of items in the list + // returns the number of items in the list int getSize(); }; class MeshWidget : public ComboWidget { private: - const MeshDocument *md; + const MeshDocument* md; + public: - MeshWidget(QWidget *p, const RichMesh& defaultMesh, const RichMesh& rdef); - ~MeshWidget(){}; + MeshWidget(QWidget* p, const RichMesh& defaultMesh, const RichMesh& rdef); + ~MeshWidget() {}; void collectWidgetValue(); void resetWidgetValue(); @@ -421,10 +424,10 @@ protected: IOFileWidget(QWidget* p, const RichParameter& rpar, const RichParameter& rdef); ~IOFileWidget(); - void updateFileName(const StringValue& file); + void updateFileName(const StringValue& file); public: - void addWidgetToGridLayout(QGridLayout* lay,const int r); + void addWidgetToGridLayout(QGridLayout* lay, const int r); void collectWidgetValue(); void resetWidgetValue(); void setWidgetValue(const Value& nv); @@ -435,11 +438,9 @@ protected slots: signals: void dialogParamChanged(); - protected: - QLineEdit* filename; + QLineEdit* filename; QPushButton* browse; - QLabel* descLab; QHBoxLayout* hlay; }; @@ -452,14 +453,13 @@ public: protected slots: void selectFile(); - }; class OpenFileWidget : public IOFileWidget { Q_OBJECT public: - OpenFileWidget(QWidget *p, const RichOpenFile& rdf, const RichOpenFile& rdef); + OpenFileWidget(QWidget* p, const RichOpenFile& rdf, const RichOpenFile& rdef); ~OpenFileWidget(); /*void collectWidgetValue(); From 75afd20f92763d21cc5385d05eb224f80b150d68 Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Mon, 13 Sep 2021 12:47:32 +0200 Subject: [PATCH 19/22] revised size policies for all widgets --- .../richparameterwidgets.cpp | 107 +++++------------- .../rich_parameter_gui/richparameterwidgets.h | 2 +- 2 files changed, 31 insertions(+), 78 deletions(-) diff --git a/src/meshlab/rich_parameter_gui/richparameterwidgets.cpp b/src/meshlab/rich_parameter_gui/richparameterwidgets.cpp index 29ba7cb0b..69bb3310c 100644 --- a/src/meshlab/rich_parameter_gui/richparameterwidgets.cpp +++ b/src/meshlab/rich_parameter_gui/richparameterwidgets.cpp @@ -41,14 +41,14 @@ RichParameterWidget::RichParameterWidget( if (parameter != nullptr) { descriptionLabel = new QLabel(parameter->fieldDescription(), this); descriptionLabel->setToolTip(parameter->toolTip()); + descriptionLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); helpLabel = new QLabel("" + rpar.toolTip() + "", this); helpLabel->setTextFormat(Qt::RichText); helpLabel->setWordWrap(true); helpLabel->setVisible(false); - helpLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); + helpLabel->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred); helpLabel->setMinimumWidth(250); - // helpLabel->setMaximumWidth(QWIDGETSIZE_MAX); } } @@ -95,7 +95,7 @@ void RichParameterWidget::addWidgetToGridLayout(QGridLayout* lay, const int r) { if (lay != NULL) { lay->addWidget(descriptionLabel, r, 0); - lay->addWidget(helpLabel, r, 2, 1, 1, Qt::AlignLeft); + lay->addWidget(helpLabel, r, 2); } } @@ -261,12 +261,8 @@ ColorWidget::ColorWidget(QWidget* p, const RichColor& newColor, const RichColor& colorButton = new QPushButton(this); colorButton->setAutoFillBackground(true); colorButton->setFlat(true); - colorButton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - // const QColor cl = rp->pd->defvalue().getColor(); - // resetWidgetValue(); + colorButton->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); initWidgetValue(); - // int row = gridLay->rowCount() - 1; - // gridLay->addWidget(descLabel,row,0,Qt::AlignTop); vlay = new QHBoxLayout(); QFontMetrics met(colorLabel->font()); @@ -278,7 +274,6 @@ ColorWidget::ColorWidget(QWidget* p, const RichColor& newColor, const RichColor& vlay->addWidget(colorLabel, 0, Qt::AlignRight); vlay->addWidget(colorButton); - // gridLay->addLayout(lay,row,1,Qt::AlignTop); pickcol = parameter->value().getColor(); connect(colorButton, SIGNAL(clicked()), this, SLOT(pickColor())); connect(this, SIGNAL(dialogParamChanged()), p, SIGNAL(parameterChanged())); @@ -367,12 +362,11 @@ AbsPercWidget::AbsPercWidget(QWidget* p, const RichAbsPerc& rabs, const RichAbsP absSB->setAlignment(Qt::AlignRight); int decimals = 7 - ceil(log10(fabs(m_max - m_min))); - // qDebug("range is (%f %f) %f ",m_max,m_min,fabs(m_max-m_min)); - // qDebug("log range is %f ",log10(fabs(m_max-m_min))); absSB->setDecimals(decimals); absSB->setSingleStep((m_max - m_min) / 100.0); float initVal = parameter->value().getFloat(); absSB->setValue(initVal); + absSB->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); percSB->setMinimum(-200); percSB->setMaximum(200); @@ -380,12 +374,11 @@ AbsPercWidget::AbsPercWidget(QWidget* p, const RichAbsPerc& rabs, const RichAbsP percSB->setSingleStep(0.5); percSB->setValue((100 * (initVal - m_min)) / (m_max - m_min)); percSB->setDecimals(3); + percSB->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); QLabel* absLab = new QLabel(" world unit"); QLabel* percLab = new QLabel( " perc on" + QString("(%1 .. %2)").arg(m_min).arg(m_max) + ""); - // gridLay->addWidget(fieldDesc,row,0,Qt::AlignHCenter); - vlay = new QGridLayout(); vlay->addWidget(absLab, 0, 0, Qt::AlignHCenter); vlay->addWidget(percLab, 0, 1, Qt::AlignHCenter); @@ -393,8 +386,6 @@ AbsPercWidget::AbsPercWidget(QWidget* p, const RichAbsPerc& rabs, const RichAbsP vlay->addWidget(absSB, 1, 0, Qt::AlignTop); vlay->addWidget(percSB, 1, 1, Qt::AlignTop); - // gridLay->addLayout(lay,row,1,Qt::AlignTop); - connect(absSB, SIGNAL(valueChanged(double)), this, SLOT(on_absSB_valueChanged(double))); connect(percSB, SIGNAL(valueChanged(double)), this, SLOT(on_percSB_valueChanged(double))); connect(this, SIGNAL(dialogParamChanged()), p, SIGNAL(parameterChanged())); @@ -424,7 +415,6 @@ void AbsPercWidget::on_percSB_valueChanged(double newv) void AbsPercWidget::setValue(float val, float minV, float maxV) { - assert(absSB); absSB->setValue(val); m_min = minV; m_max = maxV; @@ -437,14 +427,12 @@ void AbsPercWidget::collectWidgetValue() void AbsPercWidget::resetWidgetValue() { - // const AbsPercDecoration* absd = reinterpret_cast(&(rp->pd)); RichAbsPerc* ap = reinterpret_cast(parameter); setValue(parameter->value().getFloat(), ap->min, ap->max); } void AbsPercWidget::setWidgetValue(const Value& nv) { - // const AbsPercDecoration* absd = reinterpret_cast(&(rp->pd)); RichAbsPerc* ap = reinterpret_cast(parameter); setValue(nv.getFloat(), ap->min, ap->max); } @@ -480,10 +468,9 @@ PositionWidget::PositionWidget( else baseFont.setPointSize(baseFont.pointSize() * 3 / 4); coordSB[i]->setFont(baseFont); - coordSB[i]->setMaximumWidth(coordSB[i]->sizeHint().width() / 2); + coordSB[i]->setMinimumWidth(coordSB[i]->sizeHint().width() / 4); coordSB[i]->setValidator(new QDoubleValidator()); - coordSB[i]->setAlignment(Qt::AlignRight); - coordSB[i]->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); + coordSB[i]->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); vlay->addWidget(coordSB[i]); connect(coordSB[i], SIGNAL(textChanged(QString)), p, SIGNAL(parameterChanged())); } @@ -499,10 +486,9 @@ PositionWidget::PositionWidget( getPoint3Combo = new QComboBox(this); getPoint3Combo->addItems(names); - getPoint3Combo->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); + getPoint3Combo->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); vlay->addWidget(getPoint3Combo); - // connect(getPoint3Combo,SIGNAL(currentIndexChanged(int)),this,SLOT(getPoint())); connect( gla_curr, SIGNAL(transmitSurfacePos(QString, Point3m)), @@ -529,20 +515,15 @@ PositionWidget::PositionWidget( connect(this, SIGNAL(askTrackballPos(QString)), gla_curr, SLOT(sendTrackballPos(QString))); getPoint3Button = new QPushButton("Get", this); - // getPoint3Button->setMaximumWidth(getPoint3Button->sizeHint().width()/2); - - // getPoint3Button->setFlat(true); - getPoint3Button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); + getPoint3Button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); connect(getPoint3Button, SIGNAL(clicked()), this, SLOT(getPoint())); vlay->addWidget(getPoint3Button); } - // gridLay->addLayout(lay,row,1,Qt::AlignTop); } PositionWidget::~PositionWidget() { - // qDebug("Deallocating a point3fwidget"); this->disconnect(); } @@ -627,10 +608,10 @@ DirectionWidget::DirectionWidget( else baseFont.setPointSize(baseFont.pointSize() * 3 / 4); coordSB[i]->setFont(baseFont); - coordSB[i]->setMaximumWidth(coordSB[i]->sizeHint().width() / 2); + coordSB[i]->setMinimumWidth(coordSB[i]->sizeHint().width() / 4); coordSB[i]->setValidator(new QDoubleValidator()); coordSB[i]->setAlignment(Qt::AlignRight); - coordSB[i]->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); + coordSB[i]->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); vlay->addWidget(coordSB[i]); connect(coordSB[i], SIGNAL(textChanged(QString)), p, SIGNAL(parameterChanged())); } @@ -644,10 +625,9 @@ DirectionWidget::DirectionWidget( getPoint3Combo = new QComboBox(this); getPoint3Combo->addItems(names); - getPoint3Combo->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); + getPoint3Combo->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); vlay->addWidget(getPoint3Combo); - // connect(getPoint3Combo,SIGNAL(currentIndexChanged(int)),this,SLOT(getPoint())); connect( gla_curr, SIGNAL(transmitViewDir(QString, Point3m)), @@ -662,10 +642,7 @@ DirectionWidget::DirectionWidget( connect(this, SIGNAL(askCameraDir(QString)), gla_curr, SLOT(sendRasterShot(QString))); getPoint3Button = new QPushButton("Get", this); - // getPoint3Button->setMaximumWidth(getPoint3Button->sizeHint().width()/2); - - // getPoint3Button->setFlat(true); - getPoint3Button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); + getPoint3Button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); connect(getPoint3Button, SIGNAL(clicked()), this, SLOT(getPoint())); vlay->addWidget(getPoint3Button); @@ -674,7 +651,6 @@ DirectionWidget::DirectionWidget( DirectionWidget::~DirectionWidget() { - // qDebug("Deallocating a point3fwidget"); this->disconnect(); } @@ -749,9 +725,7 @@ Matrix44fWidget::Matrix44fWidget( valid = false; m.SetIdentity(); paramName = rpf.name(); - // int row = gridLay->rowCount() - 1; - // gridLay->addWidget(descLab,row,0,Qt::AlignTop); vlay = new QVBoxLayout(); lay44 = new QGridLayout(); @@ -763,13 +737,9 @@ Matrix44fWidget::Matrix44fWidget( else baseFont.setPointSize(baseFont.pointSize() * 3 / 4); coordSB[i]->setFont(baseFont); - // coordSB[i]->setMinimumWidth(coordSB[i]->sizeHint().width()/4); - coordSB[i]->setMinimumWidth(0); - coordSB[i]->setMaximumWidth(coordSB[i]->sizeHint().width() / 2); - // coordSB[i]->setSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Fixed); + coordSB[i]->setMinimumWidth(coordSB[i]->sizeHint().width()/4); + coordSB[i]->setSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Fixed); coordSB[i]->setValidator(new QDoubleValidator(p)); - coordSB[i]->setAlignment(Qt::AlignRight); - // this->addWidget(coordSB[i],1,Qt::AlignHCenter); lay44->addWidget(coordSB[i], i / 4, i % 4); connect( coordSB[i], @@ -849,8 +819,9 @@ void Matrix44fWidget::pasteMatrix() return; } id = 0; - for (QStringList::iterator i = list1.begin(); i != list1.end(); ++i, ++id) + for (QStringList::iterator i = list1.begin(); i != list1.end(); ++i, ++id) { coordSB[id]->setText(*i); + } } else { QByteArray value = QByteArray::fromBase64(shotString.toLocal8Bit()); @@ -869,8 +840,9 @@ void Matrix44fWidget::collectWidgetValue() tempM[i / 4][i % 4] = coordSB[i]->text().toFloat(); parameter->setValue(Matrix44fValue(tempM)); } - else + else { parameter->setValue(Matrix44fValue(m)); + } } void Matrix44fWidget::resetWidgetValue() @@ -878,9 +850,10 @@ void Matrix44fWidget::resetWidgetValue() valid = false; vcg::Matrix44f m; m.SetIdentity(); - for (unsigned int ii = 0; ii < 16; ++ii) + for (unsigned int ii = 0; ii < 16; ++ii) { coordSB[ii]->setText( QString::number(parameter->value().getMatrix44f()[ii / 4][ii % 4], 'g', 3)); + } } void Matrix44fWidget::setWidgetValue(const Value& nv) @@ -920,11 +893,11 @@ ShotfWidget::ShotfWidget( hlay = new QHBoxLayout(); this->setShotValue(paramName, parameter->value().getShotf()); - if (gla_curr) // if we have a connection to the current glarea we can setup the additional - // button for getting the current view direction. - { + // if we have a connection to the current glarea we can setup the additional + // button for getting the current view direction. + if (gla_curr) { getShotButton = new QPushButton("Get shot", this); - getShotButton->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred); + getShotButton->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); hlay->addWidget(getShotButton); QStringList names; @@ -947,7 +920,6 @@ ShotfWidget::ShotfWidget( connect(this, SIGNAL(askMeshShot(QString)), gla_curr, SLOT(sendMeshShot(QString))); connect(this, SIGNAL(askRasterShot(QString)), gla_curr, SLOT(sendRasterShot(QString))); } - // gridLay->addLayout(hlay,row,1,Qt::AlignTop); } void ShotfWidget::getShot() @@ -1034,22 +1006,17 @@ DynamicFloatWidget::DynamicFloatWidget( valueLE->setAlignment(Qt::AlignRight); valueSlider = new QSlider(Qt::Horizontal, this); - valueSlider->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); + valueSlider->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); valueSlider->setMinimum(0); valueSlider->setMaximum(100); valueSlider->setValue(floatToInt(parameter->value().getFloat())); RichDynamicFloat* dfd = reinterpret_cast(parameter); - // const DynamicFloatDecoration* dfd = reinterpret_cast(&(rp->pd)); QFontMetrics fm(valueLE->font()); QSize sz = fm.size(Qt::TextSingleLine, QString::number(0)); valueLE->setValidator(new QDoubleValidator(dfd->min, dfd->max, numbdecimaldigit, valueLE)); valueLE->setText(QString::number(parameter->value().getFloat())); valueLE->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); - // int row = gridLay->rowCount() - 1; - // lay->addWidget(fieldDesc,row,0); - hlay = new QHBoxLayout(); hlay->addWidget(valueLE); hlay->addWidget(valueSlider); @@ -1057,8 +1024,6 @@ DynamicFloatWidget::DynamicFloatWidget( valueLE->setMaxLength(maxlenghtplusdot); valueLE->setMaximumWidth(sz.width() * maxlenghtplusdot); - // gridLay->addLayout(hlay,row,1); - connect(valueLE, SIGNAL(textChanged(const QString&)), this, SLOT(setValue())); connect(valueSlider, SIGNAL(valueChanged(int)), this, SLOT(setValue(int))); connect(this, SIGNAL(dialogParamChanged()), p, SIGNAL(parameterChanged())); @@ -1134,14 +1099,11 @@ ComboWidget::ComboWidget(QWidget* p, const RichParameter& rpar, const RichParame { } -void ComboWidget::Init(QWidget* p, int defaultEnum, QStringList values) +void ComboWidget::init(QWidget* p, int defaultEnum, QStringList values) { enumCombo = new QComboBox(this); enumCombo->addItems(values); setIndex(defaultEnum); - // int row = gridLay->rowCount() - 1; - // gridLay->addWidget(enumLabel,row,0,Qt::AlignTop); - // gridLay->addWidget(enumCombo,row,1,Qt::AlignTop); connect(enumCombo, SIGNAL(activated(int)), this, SIGNAL(dialogParamChanged())); connect(this, SIGNAL(dialogParamChanged()), p, SIGNAL(parameterChanged())); } @@ -1176,9 +1138,7 @@ void ComboWidget::addWidgetToGridLayout(QGridLayout* lay, const int r) EnumWidget::EnumWidget(QWidget* p, const RichEnum& rpar, const RichEnum& rdef) : ComboWidget(p, rpar, rdef) { - // you MUST call it!!!! - Init(p, rpar.value().getInt(), rpar.enumvalues); - // assert(enumCombo != NULL); + init(p, rpar.value().getInt(), rpar.enumvalues); } int EnumWidget::getSize() @@ -1214,7 +1174,6 @@ MeshWidget::MeshWidget(QWidget* p, const RichMesh& rpar, const RichMesh& rdef) : // make the default mesh Index be 0 // defaultMeshIndex = -1; - int currentmeshindex = -1; unsigned int i = 0; for (const MeshModel& mm : md->meshIterator()) { @@ -1226,7 +1185,7 @@ MeshWidget::MeshWidget(QWidget* p, const RichMesh& rpar, const RichMesh& rdef) : ++i; } - Init(p, currentmeshindex, meshNames); + init(p, currentmeshindex, meshNames); } void MeshWidget::collectWidgetValue() @@ -1273,10 +1232,6 @@ IOFileWidget::IOFileWidget(QWidget* p, const RichParameter& rpar, const RichPara filename->setText(tr("")); browse = new QPushButton(this); browse->setText("..."); - // const QColor cl = rp->pd->defvalue().getColor(); - // resetWidgetValue(); - // int row = gridLay->rowCount() - 1; - // gridLay->addWidget(descLab,row,0,Qt::AlignTop); hlay = new QHBoxLayout(); hlay->addWidget(filename, 2); hlay->addWidget(browse); @@ -1338,7 +1293,6 @@ SaveFileWidget::~SaveFileWidget() void SaveFileWidget::selectFile() { - // SaveFileDecoration* dec = reinterpret_cast(rp->pd); RichSaveFile* dec = reinterpret_cast(parameter); QString ext; QString fl = @@ -1361,7 +1315,6 @@ OpenFileWidget::OpenFileWidget(QWidget* p, const RichOpenFile& rdf, const RichOp void OpenFileWidget::selectFile() { - // OpenFileDecoration* dec = reinterpret_cast(rp->pd); RichOpenFile* dec = reinterpret_cast(parameter); QString ext; QString path = QDir::homePath(); diff --git a/src/meshlab/rich_parameter_gui/richparameterwidgets.h b/src/meshlab/rich_parameter_gui/richparameterwidgets.h index 44607ee5c..fa3702bcb 100644 --- a/src/meshlab/rich_parameter_gui/richparameterwidgets.h +++ b/src/meshlab/rich_parameter_gui/richparameterwidgets.h @@ -373,7 +373,7 @@ protected: public: ComboWidget(QWidget* p, const RichParameter& rpar, const RichParameter& rdef); ~ComboWidget(); - void Init(QWidget* p, int newEnum, QStringList values); + void init(QWidget* p, int newEnum, QStringList values); void addWidgetToGridLayout(QGridLayout* lay, const int r); virtual void collectWidgetValue() = 0; virtual void resetWidgetValue() = 0; From 17a5b53132a9ed68eaea2d2349d65e94c505fc36 Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Mon, 13 Sep 2021 15:26:49 +0200 Subject: [PATCH 20/22] label align right on parameter widgets --- src/meshlab/rich_parameter_gui/richparameterwidgets.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/meshlab/rich_parameter_gui/richparameterwidgets.cpp b/src/meshlab/rich_parameter_gui/richparameterwidgets.cpp index 69bb3310c..234d79ef4 100644 --- a/src/meshlab/rich_parameter_gui/richparameterwidgets.cpp +++ b/src/meshlab/rich_parameter_gui/richparameterwidgets.cpp @@ -94,7 +94,7 @@ QString RichParameterWidget::parameterName() const void RichParameterWidget::addWidgetToGridLayout(QGridLayout* lay, const int r) { if (lay != NULL) { - lay->addWidget(descriptionLabel, r, 0); + lay->addWidget(descriptionLabel, r, 0, 1, 1, Qt::AlignRight); lay->addWidget(helpLabel, r, 2); } } From 9c5b38b75f3f689acff3bd99f688b26d5f4620b8 Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Mon, 13 Sep 2021 18:21:08 +0200 Subject: [PATCH 21/22] make right sizes of filter dock dialog --- src/meshlab/dialogs/filter_dock_dialog.cpp | 8 ++++++++ src/meshlab/dialogs/filter_dock_dialog.ui | 3 +++ 2 files changed, 11 insertions(+) diff --git a/src/meshlab/dialogs/filter_dock_dialog.cpp b/src/meshlab/dialogs/filter_dock_dialog.cpp index 2cfe8650e..ffd044633 100644 --- a/src/meshlab/dialogs/filter_dock_dialog.cpp +++ b/src/meshlab/dialogs/filter_dock_dialog.cpp @@ -81,6 +81,14 @@ FilterDockDialog::FilterDockDialog( ui->previewCheckBox->setVisible(false); } } + + //horrible hack to make the window of almost the right size... + ui->filterInfoLabel->adjustSize(); + ui->parameterFrame->adjustSize(); + resize( + width(), + ui->filterInfoLabel->height() + ui->parameterFrame->height() + + ui->previewCheckBox->height() + ui->applyPushButton->height() * 2 + 10); } FilterDockDialog::~FilterDockDialog() diff --git a/src/meshlab/dialogs/filter_dock_dialog.ui b/src/meshlab/dialogs/filter_dock_dialog.ui index 5d3f8504a..f317bd6e2 100644 --- a/src/meshlab/dialogs/filter_dock_dialog.ui +++ b/src/meshlab/dialogs/filter_dock_dialog.ui @@ -43,6 +43,9 @@ QFrame::Plain + + QAbstractScrollArea::AdjustToContentsOnFirstShow + true From 4672de317f01ad3ebb846faa9070cd0e3c1717ca Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Wed, 15 Sep 2021 09:05:34 +0200 Subject: [PATCH 22/22] make apply button default in filter dialog --- src/common/ml_document/cmesh.h | 1 - src/meshlab/dialogs/filter_dock_dialog.ui | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/common/ml_document/cmesh.h b/src/common/ml_document/cmesh.h index d9654e459..9ea2a0838 100644 --- a/src/common/ml_document/cmesh.h +++ b/src/common/ml_document/cmesh.h @@ -46,7 +46,6 @@ template class CurvaturemOcf: public CurvatureOcf { public: static void Name(std::vector & name){name.push_back(std::string("CurvaturemOcf"));T::Name(name);} }; - template class CurvatureDirmOcf: public CurvatureDirOcf, T> { public: static void Name(std::vector & name){name.push_back(std::string("CurvatureDirmOcf"));T::Name(name);} }; diff --git a/src/meshlab/dialogs/filter_dock_dialog.ui b/src/meshlab/dialogs/filter_dock_dialog.ui index f317bd6e2..92180a538 100644 --- a/src/meshlab/dialogs/filter_dock_dialog.ui +++ b/src/meshlab/dialogs/filter_dock_dialog.ui @@ -33,6 +33,9 @@ Apply + + true +