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/common/parameters/rich_parameter.cpp b/src/common/parameters/rich_parameter.cpp index a7cc1c312..1f32cc5ba 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())); } @@ -823,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) @@ -835,7 +867,37 @@ 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=="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") { 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/CMakeLists.txt b/src/meshlab/CMakeLists.txt index 750acd512..27edb4c43 100644 --- a/src/meshlab/CMakeLists.txt +++ b/src/meshlab/CMakeLists.txt @@ -12,16 +12,17 @@ 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 + dialogs/filter_dock_dialog.cpp dialogs/filter_script_dialog.cpp dialogs/options_dialog.cpp dialogs/plugin_info_dialog.cpp 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 @@ -38,17 +39,18 @@ 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 dialogs/congrats_dialog.h + dialogs/filter_dock_dialog.h dialogs/filter_script_dialog.h dialogs/options_dialog.h dialogs/plugin_info_dialog.h 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 @@ -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..ffd044633 --- /dev/null +++ b/src/meshlab/dialogs/filter_dock_dialog.cpp @@ -0,0 +1,239 @@ +/**************************************************************************** + * 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" + +#include "../mainwindow.h" + +FilterDockDialog::FilterDockDialog( + 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), + isPreviewMeshStateValid(false), + prevParams(rpl), + mw(nullptr), + md(nullptr), + mesh(nullptr) +{ + ui->setupUi(this); + + this->setWindowTitle(plugin->filterName(filter)); + ui->filterInfoLabel->setText(plugin->filterInfo(filter)); + + ui->parameterFrame->initParams(rpl, rpl, (QWidget*) glArea); + + // 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 always be the mainwindow + // if not, the filter won't be previewable + 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); + } + } + + //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() +{ + delete ui; +} + +void FilterDockDialog::on_previewCheckBox_stateChanged(int state) +{ + 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); // apply the preview state to the mesh + updateRenderingData(mw, mesh); + if (currentGLArea != nullptr) + currentGLArea->updateAllDecorators(); + } + else { // we need to apply the filter + applyDynamic(); + if (currentGLArea != nullptr) + currentGLArea->updateAllDecorators(); + } + } + // not checked - disable preview + else { + noPreviewMeshState.apply(mesh); // re-apply old state of the mesh + updateRenderingData(mw, mesh); + if (currentGLArea != nullptr) + currentGLArea->updateAllDecorators(); + } +} + +void FilterDockDialog::on_applyPushButton_clicked() +{ + ui->parameterFrame->writeValuesOnParameterList(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() +{ + ui->parameterFrame->toggleHelp(); + ui->parameterFrame->updateGeometry(); + ui->parameterFrame->adjustSize(); + updateGeometry(); +} + +void FilterDockDialog::on_closePushButton_clicked() +{ + close(); +} + +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 +{ + // 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(); +} + +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; + + if ((mask == MeshModel::MM_UNKNOWN) || (mask == MeshModel::MM_NONE)) + return false; + + if ((mask & MeshModel::MM_VERTNUMBER) || (mask & MeshModel::MM_FACENUMBER)) + return false; + + 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 new file mode 100644 index 000000000..9576d08e5 --- /dev/null +++ b/src/meshlab/dialogs/filter_dock_dialog.h @@ -0,0 +1,89 @@ +/**************************************************************************** + * 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 + +#include + +#include +#include + +class GLArea; +class MainWindow; + +namespace Ui { +class FilterDockDialog; +} + +class FilterDockDialog : public QDockWidget +{ + Q_OBJECT + +public: + explicit FilterDockDialog( + const RichParameterList& rpl, + FilterPlugin* plugin, + const QAction* filter, + QWidget* parent = nullptr, + GLArea* glArea = nullptr); + ~FilterDockDialog(); + +signals: + 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; + const QAction* filter; + 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/dialogs/filter_dock_dialog.ui b/src/meshlab/dialogs/filter_dock_dialog.ui new file mode 100644 index 000000000..92180a538 --- /dev/null +++ b/src/meshlab/dialogs/filter_dock_dialog.ui @@ -0,0 +1,164 @@ + + + FilterDockDialog + + + + 0 + 0 + 400 + 539 + + + + + 0 + 0 + + + + Filter Title + + + + + + + Close + + + + + + + Apply + + + true + + + + + + + QFrame::NoFrame + + + QFrame::Plain + + + QAbstractScrollArea::AdjustToContentsOnFirstShow + + + true + + + + + 0 + 0 + 382 + 388 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + QFrame::NoFrame + + + QFrame::Raised + + + + + + + + + + + + true + + + + Filter Description + + + Qt::RichText + + + true + + + true + + + + + + + Default + + + + + + + Preview + + + + + + + Help + + + true + + + + + + + + + RichParameterListFrame + QFrame +
rich_parameter_gui/richparameterlistframe.h
+ 1 +
+ + VerticalScrollArea + QScrollArea +
gui_utils/vertical_scroll_area.h
+ 1 +
+
+ + +
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/dialogs/save_mesh_attributes_dialog.cpp b/src/meshlab/dialogs/save_mesh_attributes_dialog.cpp index 5b09b6bdb..54c5cc9d1 100644 --- a/src/meshlab/dialogs/save_mesh_attributes_dialog.cpp +++ b/src/meshlab/dialogs/save_mesh_attributes_dialog.cpp @@ -53,16 +53,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); @@ -71,8 +75,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 7caae5bba..855e65ff0 100644 --- a/src/meshlab/dialogs/save_mesh_attributes_dialog.ui +++ b/src/meshlab/dialogs/save_mesh_attributes_dialog.ui @@ -299,15 +299,58 @@ - - - Additional Parameters + + + QFrame::NoFrame + + QFrame::Plain + + + true + + + + + 0 + 0 + 669 + 68 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + Additional Parameters + + + + + - - - @@ -405,6 +448,14 @@ + + + VerticalScrollArea + QScrollArea +
gui_utils/vertical_scroll_area.h
+ 1 +
+
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..17712676d --- /dev/null +++ b/src/meshlab/gui_utils/vertical_scroll_area.cpp @@ -0,0 +1,45 @@ +/**************************************************************************** + * 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 +#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..cfcf73292 --- /dev/null +++ b/src/meshlab/gui_utils/vertical_scroll_area.h @@ -0,0 +1,48 @@ +/**************************************************************************** + * 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 + +/** + * @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 // VERTICAL_SCROLL_AREA_H 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 0214e9413..336f71398 100644 --- a/src/meshlab/mainwindow.h +++ b/src/meshlab/mainwindow.h @@ -35,7 +35,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 +93,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, bool saveOnHistory = false); signals: void dispatchCustomSettings(const RichParameterList& rps); void filterExecuted(); @@ -201,7 +201,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 +246,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 +276,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..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); - stddialog = 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 2db305aab..65a512088 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,62 @@ 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); - - //Insert the filter to filterHistory - FilterNameParameterValuesPair tmp; - tmp.first = action->text(); tmp.second = dummyParSet; - meshDoc()->filterHistory.append(tmp); + + RichParameterList rpl = iFilter->initParameterList(action, *meshDoc()); + if (rpl.isEmpty()) { + executeFilter(action, rpl, false, true); + } + else { + filterDockDialog = new FilterDockDialog(rpl, iFilter, action, this, GLA()); + filterDockDialog->setAllowedAreas(Qt::NoDockWidgetArea); + addDockWidget(Qt::RightDockWidgetArea, filterDockDialog); + + filterDockDialog->setFloating(true); + connect(GLA(), SIGNAL(glareaClosed()), this, SLOT(closeFilterDockDialog())); + connect( + filterDockDialog, + SIGNAL(applyButtonClicked(const QAction*, RichParameterList, bool, bool)), + this, + SLOT(executeFilter(const QAction*, RichParameterList, bool, bool))); + 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) @@ -1126,8 +1098,8 @@ from the automatic dialog from the user defined dialog */ - -void MainWindow::executeFilter(const QAction* action, 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(); @@ -1287,6 +1259,14 @@ void MainWindow::executeFilter(const QAction* action, RichParameterList ¶ms, 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); @@ -3146,7 +3126,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 deleted file mode 100644 index 7bca2b58b..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); - } - - //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); - } - - 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 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 diff --git a/src/meshlab/rich_parameter_gui/richparameterlistframe.cpp b/src/meshlab/rich_parameter_gui/richparameterlistframe.cpp index 5ab308a0a..022e1ba1d 100644 --- a/src/meshlab/rich_parameter_gui/richparameterlistframe.cpp +++ b/src/meshlab/rich_parameter_gui/richparameterlistframe.cpp @@ -35,12 +35,17 @@ using namespace vcg; +RichParameterListFrame::RichParameterListFrame(QWidget* parent) : + QFrame(parent), isHelpVisible(false), gla(nullptr), hiddenFrame(nullptr) +{ +} + RichParameterListFrame::RichParameterListFrame( const RichParameterList& curParSet, const RichParameterList& defParSet, QWidget* p, QWidget* gla) : - QFrame(p), gla(gla), hiddenFrame(nullptr) + QFrame(p), isHelpVisible(false), gla(gla), hiddenFrame(nullptr) { loadFrameContent(curParSet, defParSet); } @@ -49,7 +54,7 @@ RichParameterListFrame::RichParameterListFrame( const RichParameterList& curParSet, QWidget* p, QWidget* gla) : - QFrame(p), gla(gla) + QFrame(p), isHelpVisible(false), 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), isHelpVisible(false), 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 @@ -90,8 +105,12 @@ void RichParameterListFrame::resetValues() void RichParameterListFrame::toggleHelp() { - for(int i = 0; i < helpList.count(); i++) - helpList.at(i)->setVisible(!helpList.at(i)->isVisible()) ; + isHelpVisible = !isHelpVisible; + for(auto& p : stdfieldwidgets) { + p.second->setHelpVisible(isHelpVisible); + } + setMinimumSize(sizeHint()); + adjustSize(); updateGeometry(); } @@ -116,16 +135,15 @@ void RichParameterListFrame::toggleAdvancedParameters() if (hiddenFrame->isVisible()){ hiddenFrame->setVisible(false); showHiddenFramePushButton->setText("▼"); + showHiddenFramePushButton->setToolTip("Show advanced parameters"); } else { hiddenFrame->setVisible(true); showHiddenFramePushButton->setText("▲"); - } - QFrame* p = dynamic_cast(parent()); - if (p){ - p->setMinimumSize(p->sizeHint()); + showHiddenFramePushButton->setToolTip("Hide advanced parameters"); } } + setMinimumSize(sizeHint()); } void RichParameterListFrame::loadFrameContent( @@ -165,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++); } } @@ -186,19 +203,21 @@ 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++); } } - //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); } @@ -246,8 +265,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/richparameterlistframe.h b/src/meshlab/rich_parameter_gui/richparameterlistframe.h index 727bbaa6b..7c81af174 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); @@ -85,7 +88,7 @@ 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. QFrame* hiddenFrame; diff --git a/src/meshlab/rich_parameter_gui/richparameterwidgets.cpp b/src/meshlab/rich_parameter_gui/richparameterwidgets.cpp index b7c9f1be6..234d79ef4 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()); + 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::MinimumExpanding, QSizePolicy::Preferred); + helpLabel->setMinimumWidth(250); } } 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, 1, 1, Qt::AlignRight); + lay->addWidget(helpLabel, r, 2); } } @@ -94,14 +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) { - cb = new QCheckBox(rp->fieldDescription(),this); - 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() @@ -110,39 +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(cb,r,0,1,2); - RichParameterWidget::addWidgetToGridLayout(lay,r); + if (lay != NULL) { + lay->addWidget(cb, r, 1); + } + 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); } @@ -152,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())); } @@ -197,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()); } @@ -247,95 +254,87 @@ 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::MinimumExpanding, QSizePolicy::Fixed); initWidgetValue(); - //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())); + 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)); } @@ -346,160 +345,140 @@ 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))); 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); + absSB->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); 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)+""); - - // gridLay->addWidget(fieldDesc,row,0,Qt::AlignHCenter); + 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) + ""); 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); - - 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(); } 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); + 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); + 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); } /******************************************/ -// Point3fWidget Implementation +// PositionWidget Implementation /******************************************/ -Point3fWidget::Point3fWidget(QWidget *p, const RichPoint3f& rpf, const RichPoint3f& 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) { - //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); - 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]->setMinimumWidth(coordSB[i]->sizeHint().width() / 4); coordSB[i]->setValidator(new QDoubleValidator()); - coordSB[i]->setAlignment(Qt::AlignRight); - coordSB[i]->setSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Preferred); + coordSB[i]->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); 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. - { - 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); + 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 << "View Pos."; names << "Surf. Pos."; names << "Raster Camera Pos."; @@ -507,131 +486,268 @@ Point3fWidget::Point3fWidget(QWidget *p, const RichPoint3f& rpf, const RichPoint getPoint3Combo = new QComboBox(this); getPoint3Combo->addItems(names); - //getPoint3Combo->setMinimumWidth(getPoint3Combo->sizeHint().width()); - //this->addWidget(getPoint3Combo,0,Qt::AlignHCenter); + getPoint3Combo->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); 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(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(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))); + 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->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + 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; - 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 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) - 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 Point3fWidget::setShotValue(QString name, Shotm newValShot) +void PositionWidget::setShotValue(QString name, Shotm newValShot) { vcg::Point3f p = newValShot.GetViewPoint(); - setValue(name,p); + 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()); + 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()))); + parameter->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)); + for (unsigned int ii = 0; ii < 3; ++ii) + coordSB[ii]->setText(QString::number(parameter->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)); + 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); + 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) +{ + paramName = rpf.name(); + + 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]->setMinimumWidth(coordSB[i]->sizeHint().width() / 4); + coordSB[i]->setValidator(new QDoubleValidator()); + coordSB[i]->setAlignment(Qt::AlignRight); + coordSB[i]->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); + vlay->addWidget(coordSB[i]); + connect(coordSB[i], SIGNAL(textChanged(QString)), p, SIGNAL(parameterChanged())); + } + 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::Fixed); + vlay->addWidget(getPoint3Combo); + + 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->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + connect(getPoint3Button, SIGNAL(clicked()), this, SLOT(getPoint())); + + vlay->addWidget(getPoint3Button); + } +} + +DirectionWidget::~DirectionWidget() +{ + 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() +{ + 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(parameter->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) { + lay->addLayout(vlay, r, 1); + } + 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; - descLab = new QLabel(rpf.fieldDescription(),this); - descLab->setToolTip(rpf.fieldDescription()); - //gridLay->addWidget(descLab,row,0,Qt::AlignTop); - vlay = new QVBoxLayout(); + 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(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], SIGNAL(textChanged(const QString&)), this, SLOT(invalidateMatrix(const QString&))); + 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); @@ -644,13 +760,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() @@ -659,16 +778,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) { @@ -687,13 +804,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; @@ -702,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()); @@ -717,38 +835,41 @@ 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 { + parameter->setValue(Matrix44fValue(m)); } - else - rp->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*/) @@ -760,25 +881,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. - { - getShotButton = new QPushButton("Get shot",this); - getShotButton->setSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Preferred); + this->setShotValue(paramName, parameter->value().getShotf()); + // 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::Fixed); hlay->addWidget(getShotButton); QStringList names; @@ -790,51 +909,55 @@ 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); } 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; } } @@ -845,72 +968,65 @@ 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::MinimumExpanding, 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); 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); - - //int row = gridLay->rowCount() - 1; - //lay->addWidget(fieldDesc,row,0); + 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); 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); - - 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() @@ -922,81 +1038,74 @@ 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())); + connect(enumCombo, SIGNAL(activated(int)), this, SIGNAL(dialogParamChanged())); + connect(this, SIGNAL(dialogParamChanged()), p, SIGNAL(parameterChanged())); } void ComboWidget::setIndex(int newEnum) @@ -1012,29 +1121,24 @@ 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); + init(p, rpar.value().getInt(), rpar.enumvalues); } int EnumWidget::getSize() @@ -1044,60 +1148,59 @@ 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; - - int currentmeshindex = -1; - unsigned int i = 0; - for(const MeshModel& mm : md->meshIterator()) { + // make the default mesh Index be 0 + // defaultMeshIndex = -1; + 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; @@ -1105,12 +1208,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; @@ -1119,44 +1222,38 @@ 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); 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); } @@ -1166,30 +1263,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() @@ -1198,43 +1293,41 @@ 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); + 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(";;")); + 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 ba2f03afd..fa3702bcb 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,91 +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: 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); @@ -139,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: @@ -160,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); @@ -178,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: @@ -188,44 +193,70 @@ 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 Point3fWidget : public RichParameterWidget +class PositionWidget : public RichParameterWidget { Q_OBJECT public: - Point3fWidget(QWidget *p, const RichPoint3f& rpf, const RichPoint3f& rdef, QWidget *gla); - ~Point3fWidget(); - QString paramName; + PositionWidget(QWidget* p, const RichPosition& rpf, const RichPosition& rdef, QWidget* gla); + ~PositionWidget(); + 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: - void askViewDir(QString); +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; +}; + +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; QHBoxLayout* vlay; }; @@ -234,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); @@ -253,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 @@ -267,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; }; @@ -299,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); @@ -316,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(); @@ -358,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(); @@ -390,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); @@ -404,11 +438,9 @@ protected slots: signals: void dialogParamChanged(); - protected: - QLineEdit* filename; + QLineEdit* filename; QPushButton* browse; - QLabel* descLab; QHBoxLayout* hlay; }; @@ -421,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(); 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 334416f61..f1652db1a 100644 --- a/src/meshlabplugins/filter_io_nxs/filter_io_nxs.cpp +++ b/src/meshlabplugins/filter_io_nxs/filter_io_nxs.cpp @@ -259,7 +259,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 84598d35e..b2454d8e4 100644 --- a/src/meshlabplugins/filter_select/meshselect.cpp +++ b/src/meshlabplugins/filter_select/meshselect.cpp @@ -210,7 +210,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."));