Merge branch 'devel'

This commit is contained in:
Alessandro Muntoni 2023-12-12 12:11:11 +01:00
commit 98947bcfdc
226 changed files with 12012 additions and 4230 deletions

View File

@ -53,4 +53,4 @@ runs:
- name: Configure and Build
shell: bash
run: |
bash scripts/${{ runner.os }}/1_build.sh ${{ steps.envs.outputs.build_option }} ${{ steps.envs.outputs.nightly }} --ccache
bash scripts/${{ runner.os }}/1_build.sh ${{ steps.envs.outputs.build_option }} ${{ steps.envs.outputs.nightly }} --use_brew_llvm --ccache

View File

@ -128,7 +128,6 @@ jobs:
read -a strarrd <<< "$STR_VERSION"
ML_VERSION_D=${strarrd[1]} #get the meshlab version from the string
echo "ml_version_d=$ML_VERSION_D" >> $GITHUB_OUTPUT
#access to this variable using ${{steps.envs.outputs.ml_version}} or ${{steps.envs.outputs.ml_version_d}}
- name: Create MeshLab Portable Linux Archive
run: |
cd meshlab_linux_portable
@ -148,27 +147,6 @@ jobs:
with:
name: MeshLab_macOS_packages_double
path: meshlab_macos_dmg_double
- name: Download MacOS Portable
uses: actions/download-artifact@v3
with:
name: MeshLab_macOS_portable
path: meshlab_macos_portable
- name: Download MacOS Portable-d
uses: actions/download-artifact@v3
with:
name: MeshLab_macOS_portable_double
path: meshlab_macos_portable_double
- name: Change Permissions
run: |
chmod +x meshlab_macos_portable/MeshLab*.app/Contents/MacOS/meshlab
chmod +x meshlab_macos_portable_double/MeshLab*.app/Contents/MacOS/meshlab
- name: Create MeshLab Portable MacOS
run: |
cd meshlab_macos_portable
tar -cvzf ../MeshLab${{steps.envs.outputs.ml_version}}-macos.tar.gz *
cd ../meshlab_macos_portable_double
tar -cvzf ../MeshLab${{steps.envs.outputs.ml_version_d}}-macos.tar.gz *
cd ..
#Download Windows Packages
- name: Download Windows ZIP
@ -211,8 +189,6 @@ jobs:
MeshLab${{steps.envs.outputs.ml_version_d}}-linux.tar.gz
meshlab_linux_appimage/MeshLab${{steps.envs.outputs.ml_version}}-linux.AppImage
meshlab_linux_appimage_double/MeshLab${{steps.envs.outputs.ml_version_d}}-linux.AppImage
MeshLab${{steps.envs.outputs.ml_version}}-macos.tar.gz
MeshLab${{steps.envs.outputs.ml_version_d}}-macos.tar.gz
meshlab_macos_dmg/MeshLab${{steps.envs.outputs.ml_version}}-macos.dmg
meshlab_macos_dmg_double/MeshLab${{steps.envs.outputs.ml_version_d}}-macos.dmg
MeshLab${{steps.envs.outputs.ml_version}}-windows.zip

View File

@ -2,8 +2,8 @@
Privacy Disclaimer
Please read it carefully.
MeshLab will automatically check for the availability of updated versions and will notify the need of upgrading the software to the users. For this reason, from time to time, MeshLab will issue a http network connection. If you prefer that MeshLab does not communicate in any way with its developers, simply use a plain firewall and prevent any MeshLab access to the network. This will not limit in any way the normal behaviour of MeshLab. When using MeshLab some aggregated statistical data about only the specific usage of MeshLab are collected: the number and size of the opened/saved meshes; nothing more. Periodically this information is sent back to the developers. This data will be used for statistical analysis only.
Paranoids can also look at the sources for seeing what is transmitted.
MeshLab will automatically check for the availability of updated versions and will notify the need of upgrading the software to the users. For this reason, from time to time, MeshLab will issue a http network connection. If you prefer that MeshLab does not communicate in any way with its developers, simply use a plain firewall and prevent any MeshLab access to the network, or disable the update check in the system preferences. This will not limit in any way the normal behaviour of MeshLab apart from getting notified when new releases are distributed.
Important: when using MeshLab the following aggregated statistical data are collected: the number of opened meshes, the number of saved meshes, and the total sum of the number of vertices opened by the user. This statistically aggregated information (three integers) is sent back to the developer when checking for updates. Disabling the check for updates also disable this data collection.
We would like to remark that the kind of aggregated information collected by MeshLab is probably by far less sensitive than the information that is silently collected by most web sites when you surf them: ip address, visited pages, frequency of return. We would also like to stress that we really need this information in order to assess how diffusely MeshLab is used and what is its impact on the 3D community.

19
sample/TextureSingle.ply Normal file
View File

@ -0,0 +1,19 @@
ply
format ascii 1.0
comment VCGLIB generated
comment TextureFile TextureDouble_A.png
element vertex 4
property float x
property float y
property float z
element face 2
property list uchar int vertex_indices
property list uchar float texcoord
property int texnumber
end_header
0 0 0
1 0 0
1 1 0
0 1 0
3 0 1 2 6 0 0 2 0 2 2 0
3 0 2 3 6 0 0 2 2 0 2 0

View File

@ -5,7 +5,8 @@
# Run this script if you never installed any of the MeshLab dependencies.
DONT_INSTALL_QT=false
DONT_INSTALL_CGAL_BOOST=false
DONT_INSTALL_CGAL_BOOST=true
DONT_INSTALL_EMBREE=true
#checking for parameters
for i in "$@"
@ -19,6 +20,10 @@ case $i in
DONT_INSTALL_CGAL_BOOST=true
shift # past argument=value
;;
--dont_install_embree)
DONT_INSTALL_EMBREE=true
shift # past argument=value
;;
*)
# unknown option
;;
@ -30,7 +35,7 @@ echo "=== installing mesa packages..."
sudo apt-get install -y mesa-common-dev libglu1-mesa-dev
echo "=== installing cmake, patchelf, gmp, mpfr and xcerces-c..."
sudo apt-get install -y cmake ninja-build patchelf libgmp-dev libmpfr-dev libxerces-c-dev
sudo apt-get install -y cmake ninja-build patchelf libgmp-dev libmpfr-dev libxerces-c-dev libtbb-dev
if [ "$DONT_INSTALL_QT" = false ] ; then
echo "=== installing qt packages..."
@ -50,3 +55,10 @@ if [ "$DONT_INSTALL_CGAL_BOOST" = false ] ; then
else
echo "=== jumping installation of cgal and boost packages..."
fi
if [ "$DONT_INSTALL_EMBREE" = false ] ; then
echo "=== installing embree..."
sudo apt-get install -y libembree-dev
else
echo "=== jumping installation of embree package..."
fi

View File

@ -22,7 +22,7 @@ case $i in
esac
done
brew install coreutils node cmake ninja libomp cgal xerces-c
brew install coreutils node cmake ninja llvm libomp cgal xerces-c tbb embree
npm install -g appdmg
if [ "$DONT_INSTALL_QT" = false ] ; then

View File

@ -7,6 +7,7 @@ BUILD_PATH=$SOURCE_PATH/build
INSTALL_PATH=$SOURCE_PATH/install
DOUBLE_PRECISION_OPTION=""
NIGHTLY_OPTION=""
USE_BREW_LLVM=false
QT_DIR=""
CCACHE=""
@ -38,6 +39,14 @@ case $i in
QT_DIR=${i#*=}
shift # past argument=value
;;
--use_brew_llvm)
USE_BREW_LLVM=true
shift # past argument=value
;;
--use_brew_qt)
QT_DIR=$(brew --prefix qt5)
shift # past argument=value
;;
--ccache)
CCACHE="-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache"
shift # past argument=value
@ -65,6 +74,20 @@ then
export Qt5_DIR=$QT_DIR
fi
if [ "$USE_BREW_LLVM" = true ] ; then
BREW_PATH="$(brew --prefix)"
LLVM_PATH="$(brew --prefix llvm)"
export SDKROOT=$(xcrun --sdk macosx --show-sdk-path)
export LIBRARY_PATH="$LIBRARY_PATH:$SDKROOT/usr/lib"
export PATH="$LLVM_PATH/bin:$PATH"
export CC="$LLVM_PATH/bin/clang"
export CXX="$LLVM_PATH/bin/clang++"
export COMPILER=${CXX}
export CFLAGS="-I $BREW_PATH/include -I $LLVM_PATH/include"
export CXXFLAGS="-I $BREW_PATH/include -I $LLVM_PATH/include"
export LDFLAGS="-L $LIBRARY_PATH -L $BREW_PATH/lib -L $LLVM_PATH/lib"
fi
BUILD_PATH=$(realpath $BUILD_PATH)
INSTALL_PATH=$(realpath $INSTALL_PATH)

View File

@ -104,6 +104,7 @@ set(EXTERNAL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external)
add_subdirectory(${EXTERNAL_DIR})
add_subdirectory(common)
add_subdirectory(common_gui)
if (NOT MESHLAB_BUILD_ONLY_LIBRARIES)
add_subdirectory(meshlab)
@ -147,7 +148,10 @@ if(NOT DEFINED MESHLAB_PLUGINS) # it may be already defined in parent directory
meshlabplugins/filter_color_projection
meshlabplugins/filter_colorproc
meshlabplugins/filter_create
meshlabplugins/filter_cubization
meshlabplugins/filter_developability
meshlabplugins/filter_dirt
meshlabplugins/filter_embree
meshlabplugins/filter_fractal
meshlabplugins/filter_func
meshlabplugins/filter_img_patch_param
@ -157,6 +161,7 @@ if(NOT DEFINED MESHLAB_PLUGINS) # it may be already defined in parent directory
meshlabplugins/filter_layer
meshlabplugins/filter_measure
meshlabplugins/filter_mesh_booleans
meshlabplugins/filter_mesh_alpha_wrap
meshlabplugins/filter_meshing
meshlabplugins/filter_mls
meshlabplugins/filter_mutualglobal

View File

@ -41,6 +41,8 @@ else()
endif()
set(HEADERS
filter_history/filter.h
filter_history/filter_history.h
ml_document/helpers/mesh_document_state_data.h
ml_document/helpers/mesh_model_state_data.h
ml_document/base_types.h
@ -53,9 +55,34 @@ set(HEADERS
ml_shared_data_context/ml_plugin_gl_context.h
ml_shared_data_context/ml_scene_gl_shared_data_context.h
ml_shared_data_context/ml_shared_data_context.h
parameters/rich_parameter.h
parameters/rich_parameters.h
parameters/values.h
parameters/rich_parameter_list.h
parameters/value.h
parameters/rich_parameter/rich_bool.h
parameters/rich_parameter/rich_color.h
parameters/rich_parameter/rich_direction.h
parameters/rich_parameter/rich_dynamic_float.h
parameters/rich_parameter/rich_enum.h
parameters/rich_parameter/rich_file_open.h
parameters/rich_parameter/rich_file_save.h
parameters/rich_parameter/rich_float.h
parameters/rich_parameter/rich_int.h
parameters/rich_parameter/rich_matrix44.h
parameters/rich_parameter/rich_mesh.h
parameters/rich_parameter/rich_parameter.h
parameters/rich_parameter/rich_percentage.h
parameters/rich_parameter/rich_position.h
parameters/rich_parameter/rich_shot.h
parameters/rich_parameter/rich_string.h
parameters/value/bool_value.h
parameters/value/color_value.h
parameters/value/float_value.h
parameters/value/int_value.h
parameters/value/matrix44_value.h
parameters/value/point3_value.h
parameters/value/shot_value.h
parameters/value/string_value.h
parameters/value/value.h
plugins/containers/generic_container_iterator.h
plugins/containers/decorate_plugin_container.h
plugins/containers/edit_plugin_container.h
@ -89,6 +116,8 @@ set(HEADERS
mlexception.h)
set(SOURCES
filter_history/filter.cpp
filter_history/filter_history.cpp
ml_document/helpers/mesh_document_state_data.cpp
ml_document/cmesh.cpp
ml_document/mesh_document.cpp
@ -99,9 +128,32 @@ set(SOURCES
ml_shared_data_context/ml_plugin_gl_context.cpp
ml_shared_data_context/ml_scene_gl_shared_data_context.cpp
ml_shared_data_context/ml_shared_data_context.cpp
parameters/rich_parameter.cpp
parameters/rich_parameters.cpp
parameters/rich_parameter_list.cpp
parameters/value.cpp
parameters/rich_parameter/rich_bool.cpp
parameters/rich_parameter/rich_color.cpp
parameters/rich_parameter/rich_direction.cpp
parameters/rich_parameter/rich_dynamic_float.cpp
parameters/rich_parameter/rich_enum.cpp
parameters/rich_parameter/rich_file_open.cpp
parameters/rich_parameter/rich_file_save.cpp
parameters/rich_parameter/rich_float.cpp
parameters/rich_parameter/rich_int.cpp
parameters/rich_parameter/rich_matrix44.cpp
parameters/rich_parameter/rich_mesh.cpp
parameters/rich_parameter/rich_parameter.cpp
parameters/rich_parameter/rich_percentage.cpp
parameters/rich_parameter/rich_position.cpp
parameters/rich_parameter/rich_shot.cpp
parameters/rich_parameter/rich_string.cpp
parameters/value/bool_value.cpp
parameters/value/color_value.cpp
parameters/value/float_value.cpp
parameters/value/int_value.cpp
parameters/value/matrix44_value.cpp
parameters/value/point3_value.cpp
parameters/value/shot_value.cpp
parameters/value/string_value.cpp
plugins/containers/decorate_plugin_container.cpp
plugins/containers/edit_plugin_container.cpp
plugins/containers/filter_plugin_container.cpp

View File

@ -0,0 +1,136 @@
/*****************************************************************************
* MeshLab o o *
* An extendible mesh processor o o *
* _ O _ *
* Copyright(C) 2005-2022 \/)\/ *
* 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.h"
Filter::Filter()
{
}
Filter::Filter(
const FilterPlugin* plugin,
const QAction* filter,
const RichParameterList& paramList) :
plugin(plugin),
filter(filter),
paramList(paramList)
{
}
void Filter::setParameterValue(const std::string &parameter, const Value &value)
{
RichParameter& rp = paramList.getParameterByName(QString::fromStdString(parameter));
rp.setValue(value);
}
/**
* @brief returns a string containing a pymeshlab python call of the filter with the current
* parameters set.
* @param meshSetName: the name of the MeshSet object.
* @return
*/
std::string Filter::pyMeshLabCall(std::string meshSetName) const
{
bool first = true;
std::string call = meshSetName + "." + plugin->pythonFilterName(filter).toStdString() + "(";
for (const RichParameter& p : paramList) {
// parameter must be added only if its value is not default
if (!p.isValueDefault()) {
if (!p.isOfType<RichShot>()) { // RichShot not yet supported by pymeshlab
// if it is not the first parameter we are adding, we put the comma after the last
// parameter, because we are going to add another one
if (first) {
first = false;
}
else {
call += ", ";
}
call += p.pythonName().toStdString() + " = ";
if (p.isOfType<RichBool>()) {
if (p.value().getBool()) {
call += "True";
}
else {
call += "False";
}
}
else if (p.isOfType<RichColor>()) {
QColor c = p.value().getColor();
call += "pymeshlab.Color(";
call += std::to_string(c.red()) + ", ";
call += std::to_string(c.green()) + ", ";
call += std::to_string(c.blue()) + ", ";
call += std::to_string(c.alpha()) + ")";
}
else if (p.isOfType<RichDirection>() || p.isOfType<RichPosition>()) {
Point3m pp = p.value().getPoint3();
call += "numpy.array([";
call += std::to_string(pp[0]) + ", ";
call += std::to_string(pp[1]) + ", ";
call += std::to_string(pp[2]) + "])";
}
else if (p.isOfType<RichDynamicFloat>() || p.isOfType<RichFloat>()) {
call += std::to_string(p.value().getFloat());
}
else if (
p.isOfType<RichEnum>() || p.isOfType<RichInt>() || p.isOfType<RichMesh>()) {
call += std::to_string(p.value().getInt());
}
else if (
p.isOfType<RichString>() || p.isOfType<RichFileOpen>() ||
p.isOfType<RichFileSave>()) {
call += "'" + p.value().getString().toStdString() + "'";
}
else if (p.isOfType<RichMatrix44>()) {
Matrix44m m = p.value().getMatrix44();
call += "numpy.array([";
bool firstRow = true;
for (unsigned int i = 0; i < 4 ; i++) {
if (firstRow)
firstRow = false;
else
call += ", ";
call += "[";
bool firstCol = true;
for (unsigned int j = 0; j < 4 ; j++) {
if (firstCol)
firstCol = false;
else
call += ", ";
call += std::to_string(m.ElementAt(i,j));
}
call += "]";
}
call += "])";
}
else if (p.isOfType<RichPercentage>()) {
const RichPercentage& rp = dynamic_cast<const RichPercentage&>(p);
float per = (p.value().getFloat() / (rp.max - rp.min) ) * 100;
call += "pymeshlab.PercentageValue(" + std::to_string(per) + ")";
}
}
}
}
call += ")";
return call;
}

View File

@ -0,0 +1,49 @@
/*****************************************************************************
* MeshLab o o *
* An extendible mesh processor o o *
* _ O _ *
* Copyright(C) 2005-2022 \/)\/ *
* 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_H
#define FILTER_H
#include <common/parameters/rich_parameter_list.h>
#include <common/plugins/plugin_manager.h>
class Filter
{
public:
Filter();
Filter(
const FilterPlugin* plugin,
const QAction* filter,
const RichParameterList& paramList);
void setParameterValue(const std::string& parameter, const Value& value);
std::string pyMeshLabCall(std::string meshSetName = "ms") const;
private:
const FilterPlugin* plugin;
const QAction* filter;
RichParameterList paramList;
};
#endif // FILTER_H

View File

@ -0,0 +1,44 @@
/*****************************************************************************
* MeshLab o o *
* An extendible mesh processor o o *
* _ O _ *
* Copyright(C) 2005-2022 \/)\/ *
* 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_history.h"
FilterHistory::iterator FilterHistory::begin()
{
return history.begin();
}
FilterHistory::iterator FilterHistory::end()
{
return history.end();
}
FilterHistory::const_iterator FilterHistory::begin() const
{
return history.begin();
}
FilterHistory::const_iterator FilterHistory::end() const
{
return history.end();
}

View File

@ -0,0 +1,45 @@
/*****************************************************************************
* MeshLab o o *
* An extendible mesh processor o o *
* _ O _ *
* Copyright(C) 2005-2022 \/)\/ *
* 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 MESHLAB_FILTER_HISTORY_H
#define MESHLAB_FILTER_HISTORY_H
#include <list>
#include "filter.h"
class FilterHistory
{
using iterator = std::list<Filter>::iterator;
using const_iterator = std::list<Filter>::const_iterator;
iterator begin();
iterator end();
const_iterator begin() const;
const_iterator end() const;
private:
std::list<Filter> history;
};
#endif // MESHLAB_FILTER_HISTORY_H

View File

@ -1,900 +0,0 @@
/****************************************************************************
* MeshLab o o *
* A versatile mesh processing toolbox 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 "rich_parameter.h"
#include "../ml_document/mesh_document.h"
#include "../python/python_utils.h"
/**** RichParameter Class ****/
RichParameter::RichParameter(const RichParameter& rp) :
pName(rp.pName),
val(rp.value().clone()),
fieldDesc(rp.fieldDesc),
tooltip(rp.tooltip),
advanced(rp.advanced),
pCategory(rp.pCategory)
{
}
RichParameter::RichParameter(RichParameter&& rp) :
pName(std::move(rp.pName)),
fieldDesc(std::move(rp.fieldDesc)),
tooltip(std::move(rp.tooltip)),
pCategory(std::move(rp.pCategory))
{
val = rp.val;
rp.val = nullptr;
advanced = rp.advanced;
}
RichParameter::RichParameter(
const QString& nm,
const Value& v,
const QString& desc,
const QString& tltip,
bool isAdvanced,
const QString& category) :
pName(nm),
val(v.clone()),
fieldDesc(desc),
tooltip(tltip),
advanced(isAdvanced),
pCategory(category)
{
}
RichParameter::~RichParameter()
{
delete val;
}
const QString& RichParameter::name() const
{
return pName;
}
const Value& RichParameter::value() const
{
return *val;
}
const QString& RichParameter::fieldDescription() const
{
return fieldDesc;
}
const QString& RichParameter::toolTip() const
{
return tooltip;
}
bool RichParameter::isAdvanced() const
{
return advanced;
}
const QString& RichParameter::category() const
{
return pCategory;
}
void RichParameter::setName(const QString& newName)
{
pName = newName;
}
void RichParameter::setValue(const Value& ov)
{
assert(val->typeName() == ov.typeName());
delete val;
val = ov.clone();
}
QDomElement RichParameter::fillToXMLDocument(QDomDocument& doc, bool saveDescriptionAndTooltip) const
{
QDomElement parElem = doc.createElement("Param");
parElem.setAttribute("name", pName);
parElem.setAttribute("type", stringType());
if (saveDescriptionAndTooltip) {
parElem.setAttribute("description", fieldDesc);
parElem.setAttribute("tooltip",tooltip);
}
val->fillToXMLElement(parElem);
return parElem;
}
/**
* @brief returns the name of the parameter used in python (for pymeshlab)
*/
QString RichParameter::pythonName() const
{
return pymeshlab::computePythonName(pName);
}
/**
* @brief returns the type if the parameter (as a string) used in python
* (for pymeshlab)
*/
QString RichParameter::pythonType() const
{
return pymeshlab::computePythonTypeString(*this);
}
RichParameter& RichParameter::operator=(const RichParameter& rp)
{
if (&rp != this){
delete val;
val = rp.value().clone();
pName = rp.pName;
fieldDesc = rp.fieldDesc;
tooltip = rp.tooltip;
}
return *this;
}
RichParameter& RichParameter::operator=(RichParameter&& rp)
{
assert(&rp != this);
val = rp.val;
rp.val = nullptr;
pName = std::move(rp.pName);
fieldDesc = std::move(rp.fieldDesc);
tooltip = std::move(rp.tooltip);
return *this;
}
/**** RichBool Class ****/
RichBool::RichBool(
const QString& nm,
const bool defval,
const QString& desc,
const QString& tltip,
bool hidden,
const QString& category) :
RichParameter(nm, BoolValue(defval), desc, tltip, hidden, category)
{
}
RichBool::~RichBool()
{
}
QString RichBool::stringType() const
{
return "RichBool";
}
RichBool* RichBool::clone() const
{
return new RichBool(*this);
}
bool RichBool::operator==( const RichParameter& rb )
{
return (rb.value().isBool() && (pName == rb.name()) && (value().getBool() == rb.value().getBool()));
}
/**** RichInt Class ****/
RichInt::RichInt(
const QString& nm,
const int defval,
const QString& desc,
const QString& tltip,
bool hidden,
const QString& category) :
RichParameter(nm, IntValue(defval),desc, tltip, hidden, category)
{
}
RichInt::~RichInt()
{
}
QString RichInt::stringType() const
{
return "RichInt";
}
RichInt* RichInt::clone() const
{
return new RichInt(*this);
}
bool RichInt::operator==( const RichParameter& rb )
{
return (rb.value().isInt() &&(pName == rb.name()) && (value().getInt() == rb.value().getInt()));
}
/**** RichFloat Class ****/
RichFloat::RichFloat(
const QString& nm,
const Scalarm defval,
const QString& desc,
const QString& tltip,
bool hidden,
const QString& category) :
RichParameter(nm, FloatValue(defval),desc, tltip, hidden, category)
{
}
RichFloat::~RichFloat()
{
}
QString RichFloat::stringType() const
{
return "RichFloat";
}
RichFloat* RichFloat::clone() const
{
return new RichFloat(*this);
}
bool RichFloat::operator==( const RichParameter& rb )
{
return (rb.value().isFloat() &&(pName == rb.name()) && (value().getFloat() == rb.value().getFloat()));
}
/**** RichString Class ****/
RichString::RichString(
const QString& nm,
const QString& defval,
const QString& desc,
const QString& tltip,
bool hidden,
const QString& category) :
RichParameter(nm, StringValue(defval),desc,tltip, hidden, category)
{
}
RichString::~RichString()
{
}
QString RichString::stringType() const
{
return "RichString";
}
RichString* RichString::clone() const
{
return new RichString(*this);
}
bool RichString::operator==( const RichParameter& rb )
{
return (rb.value().isString() &&(pName == rb.name()) && (value().getString() == rb.value().getString()));
}
/**** RichMatrix44f Class ****/
RichMatrix44f::RichMatrix44f(
const QString& nm,
const Matrix44m& defval,
const QString& desc,
const QString& tltip,
bool hidden,
const QString& category) :
RichParameter(nm, Matrix44fValue(defval),desc, tltip, hidden, category)
{
}
RichMatrix44f::~RichMatrix44f()
{
}
QString RichMatrix44f::stringType() const
{
return "RichMatrix44f";
}
RichMatrix44f* RichMatrix44f::clone() const
{
return new RichMatrix44f(*this);
}
bool RichMatrix44f::operator==( const RichParameter& rb )
{
return (rb.value().isMatrix44f() &&(pName == rb.name()) && (value().getMatrix44f() == rb.value().getMatrix44f()));
}
/**** RichPosition Class ****/
RichPosition::RichPosition(
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)
{
}
RichPosition::~RichPosition()
{
}
QString RichPosition::stringType() const
{
return "RichPosition";
}
RichPosition* RichPosition::clone() const
{
return new RichPosition(*this);
}
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()));
}
/**** RichShotf Class ****/
RichShotf::RichShotf(
const QString& nm,
const Shotm& defval,
const QString& desc,
const QString& tltip,
bool hidden,
const QString& category) :
RichParameter(nm, ShotfValue(defval),desc, tltip, hidden, category)
{
}
RichShotf::~RichShotf()
{
}
QString RichShotf::stringType() const
{
return "RichShotf";
}
RichShotf* RichShotf::clone() const
{
return new RichShotf(*this);
}
bool RichShotf::operator==( const RichParameter& rb )
{
return (rb.value().isShotf() &&(pName == rb.name()) );
// TODO REAL TEST OF EQUALITY // && (value().getShotf() == rb.value().getShotf()));
}
/**** RichColor Class ****/
RichColor::RichColor(
const QString& nm,
const QColor& defval,
const QString& desc,
const QString& tltip,
bool hidden,
const QString& category) :
RichParameter(nm, ColorValue(defval),desc, tltip, hidden, category)
{
}
RichColor::~RichColor()
{
}
QString RichColor::stringType() const
{
return "RichColor";
}
RichColor* RichColor::clone() const
{
return new RichColor(*this);
}
bool RichColor::operator==( const RichParameter& rb )
{
return (rb.value().isColor() &&(pName == rb.name()) && (value().getColor() == rb.value().getColor()));
}
/**** RichAbsPerc Class ****/
RichAbsPerc::RichAbsPerc(
const QString& nm,
const Scalarm defval,
const Scalarm minval,
const Scalarm maxval,
const QString& desc,
const QString& tltip,
bool hidden,
const QString& category) :
RichParameter(nm, FloatValue(defval), desc, tltip, hidden, category), min(minval), max(maxval)
{
}
RichAbsPerc::~RichAbsPerc()
{
}
QString RichAbsPerc::stringType() const
{
return "RichAbsPerc";
}
QDomElement RichAbsPerc::fillToXMLDocument(QDomDocument& doc, bool saveDescriptionAndTooltip) const
{
QDomElement parElem = RichParameter::fillToXMLDocument(doc, saveDescriptionAndTooltip);
parElem.setAttribute("min",QString::number(min));
parElem.setAttribute("max",QString::number(max));
return parElem;
}
RichAbsPerc* RichAbsPerc::clone() const
{
return new RichAbsPerc(*this);
}
bool RichAbsPerc::operator==( const RichParameter& rb )
{
return (rb.isOfType<RichAbsPerc>() &&(pName == rb.name()) && (value().getFloat() == rb.value().getFloat()));
}
/**** RichEnum Class ****/
RichEnum::RichEnum(
const QString& nm,
const int defval,
const QStringList& values,
const QString& desc,
const QString& tltip,
bool hidden,
const QString& category) :
RichParameter(nm, IntValue(defval),desc, tltip, hidden, category), enumvalues(values)
{
}
RichEnum::~RichEnum()
{
}
QString RichEnum::stringType() const
{
return "RichEnum";
}
QDomElement RichEnum::fillToXMLDocument(QDomDocument& doc, bool saveDescriptionAndTooltip) const
{
QDomElement parElem = RichParameter::fillToXMLDocument(doc, saveDescriptionAndTooltip);
parElem.setAttribute("enum_cardinality", enumvalues.size());
for(int ii = 0; ii < enumvalues.size(); ++ii)
parElem.setAttribute(QString("enum_val")+QString::number(ii), enumvalues.at(ii));
return parElem;
}
RichEnum* RichEnum::clone() const
{
return new RichEnum(*this);
}
bool RichEnum::operator==( const RichParameter& rb )
{
return (rb.isOfType<RichEnum>() &&(pName == rb.name()) && (value().getInt() == rb.value().getInt()));
}
/**** RichDynamicFloat Class ****/
RichDynamicFloat::RichDynamicFloat(
const QString& nm,
const Scalarm defval,
const Scalarm minval,
const Scalarm maxval,
const QString& desc,
const QString& tltip,
bool hidden,
const QString& category) :
RichParameter(nm, FloatValue(defval),desc, tltip, hidden, category), min(minval), max(maxval)
{
}
RichDynamicFloat::~RichDynamicFloat()
{
}
QString RichDynamicFloat::stringType() const
{
return "RichDynamicFloat";
}
QDomElement RichDynamicFloat::fillToXMLDocument(QDomDocument& doc, bool saveDescriptionAndTooltip) const
{
QDomElement parElem = RichParameter::fillToXMLDocument(doc, saveDescriptionAndTooltip);
parElem.setAttribute("min",QString::number(min));
parElem.setAttribute("max",QString::number(max));
return parElem;
}
RichDynamicFloat* RichDynamicFloat::clone() const
{
return new RichDynamicFloat(*this);
}
bool RichDynamicFloat::operator==( const RichParameter& rb )
{
return (rb.isOfType<RichDynamicFloat>() &&(pName == rb.name()) && (value().getFloat() == rb.value().getFloat()));
}
/**** RichOpenFile Class ****/
RichOpenFile::RichOpenFile(
const QString& nm,
const QString& directorydefval,
const QStringList& exts,
const QString& desc,
const QString& tltip,
bool hidden,
const QString& category) :
RichParameter(nm, StringValue(directorydefval), desc, tltip, hidden, category), exts(exts)
{
}
RichOpenFile::~RichOpenFile()
{
}
QString RichOpenFile::stringType() const
{
return "RichOpenFile";
}
QDomElement RichOpenFile::fillToXMLDocument(QDomDocument& doc, bool saveDescriptionAndTooltip) const
{
QDomElement parElem = RichParameter::fillToXMLDocument(doc, saveDescriptionAndTooltip);
parElem.setAttribute("exts_cardinality", exts.size());
for(int ii = 0; ii < exts.size(); ++ii)
parElem.setAttribute(QString("ext_val")+QString::number(ii), exts[ii]);
return parElem;
}
RichOpenFile* RichOpenFile::clone() const
{
return new RichOpenFile(*this);
}
bool RichOpenFile::operator==( const RichParameter& rb )
{
return (rb.isOfType<RichOpenFile>() &&(pName == rb.name()) && (value().getString() == rb.value().getString()));
}
/**** RichSaveFile Class ****/
RichSaveFile::RichSaveFile(
const QString& nm,
const QString& filedefval,
const QString& ext,
const QString& desc,
const QString& tltip,
bool hidden,
const QString& category) :
RichParameter(nm, StringValue(filedefval), desc, tltip, hidden, category), ext(ext)
{
}
RichSaveFile::~RichSaveFile()
{
}
QString RichSaveFile::stringType() const
{
return "RichSaveFile";
}
QDomElement RichSaveFile::fillToXMLDocument(QDomDocument& doc, bool saveDescriptionAndTooltip) const
{
QDomElement parElem = RichParameter::fillToXMLDocument(doc, saveDescriptionAndTooltip);
parElem.setAttribute("ext", ext);
return parElem;
}
RichSaveFile* RichSaveFile::clone() const
{
return new RichSaveFile(*this);
}
bool RichSaveFile::operator==( const RichParameter& rb )
{
return (rb.isOfType<RichSaveFile>() &&(pName == rb.name()) && (value().getString() == rb.value().getString()));
}
/**** RichMesh Class ****/
RichMesh::RichMesh(
const QString& nm,
unsigned int meshind,
const MeshDocument* doc,
const QString& desc,
const QString& tltip,
bool hidden,
const QString& category):
RichParameter(nm,IntValue(meshind), desc, tltip, hidden, category), meshdoc(doc)
{
}
RichMesh::~RichMesh()
{
}
QString RichMesh::stringType() const
{
return "RichMesh";
}
RichMesh* RichMesh::clone() const
{
return new RichMesh(*this);
}
bool RichMesh::operator==( const RichParameter& rb )
{
return (rb.isOfType<RichMesh>() &&(pName == rb.name()) && (value().getInt() == rb.value().getInt()));
}
/**** RichParameterAdapter Class ****/
bool RichParameterAdapter::create( const QDomElement& np,RichParameter*& par )
{
QString name=np.attribute("name");
QString type=np.attribute("type");
QString desc=np.attribute("description");
QString tooltip=np.attribute("tooltip");
// qDebug(" Reading Param with name %s : %s", qUtf8Printable(name), qUtf8Printable(type));
bool corrconv = false;
if(type=="RichBool") {
QString val = np.attribute("value").toLower();
if ((val != QString("true")) && (val != QString("false")))
return false;
par = new RichBool(name,np.attribute("value")!=QString("false"),desc,tooltip);
return true;
}
if(type=="RichInt") {
int val = np.attribute("value").toInt(&corrconv);
if (!corrconv)
return false;
par = new RichInt(name,val,desc,tooltip);
return true;
}
if(type=="RichFloat") {
float val = np.attribute("value").toFloat(&corrconv);
if (!corrconv)
return false;
par = new RichFloat(name,val,desc,tooltip);
return true;
}
if(type=="RichString") {
par = new RichString(name,np.attribute("value"),desc,tooltip);
return true;
}
if(type=="RichAbsPerc") {
float val = np.attribute("value").toFloat(&corrconv);
if ((!corrconv) && (val >= 0.0f) && (val <= 100.0f))
return false;
float min = np.attribute("min").toFloat(&corrconv);
if (!corrconv)
return false;
float max = np.attribute("max").toFloat(&corrconv);
if (!corrconv)
return false;
par = new RichAbsPerc(name,val,min,max,desc,tooltip);
return true;
}
if(type=="RichColor") {
unsigned int r = np.attribute("r").toUInt(&corrconv);
if ((!corrconv) && (r <= 255))
return false;
unsigned int g = np.attribute("g").toUInt(&corrconv);
if ((!corrconv) && (g <= 255))
return false;
unsigned int b = np.attribute("b").toUInt(&corrconv);
if ((!corrconv) && (b <= 255))
return false;
unsigned int a = np.attribute("a").toUInt(&corrconv);
if ((!corrconv) && (a <= 255))
return false;
QColor col(r,g,b,a);
par= new RichColor(name,col,desc,tooltip);
return true;
}
if(type=="RichMatrix44f") {
Matrix44m mm;
for(int i=0;i<16;++i)
{
Scalarm val = np.attribute(QString("val")+QString::number(i)).toFloat(&corrconv);
if (!corrconv)
return false;
mm.V()[i]=val;
}
par = new RichMatrix44f(name,mm,desc,tooltip);
return true;
}
if(type=="RichEnum") {
QStringList list;
int enum_card = np.attribute(QString("enum_cardinality")).toUInt(&corrconv);
if (!corrconv)
return false;
for(int i=0;i<enum_card;++i)
list<<np.attribute(QString("enum_val")+QString::number(i));
int val = np.attribute("value").toInt(&corrconv);
if ((!corrconv) && (val >=0) && (val < enum_card))
return false;
par = new RichEnum(name,val,list,desc,tooltip);
return true;
}
if(type == "RichMesh") {
int val = np.attribute("value").toInt(&corrconv);
if (!corrconv)
return false;
par = new RichMesh(name, val, nullptr, desc,tooltip);
return true;
}
if(type == "RichDynamicFloat") {
float min = np.attribute("min").toFloat(&corrconv);
if (!corrconv)
return false;
float max = np.attribute("max").toFloat(&corrconv);
if (!corrconv)
return false;
float val = np.attribute("value").toFloat(&corrconv);
if ((!corrconv) && (val >= min) && (val <= max))
return false;
par = new RichDynamicFloat(name, val, min, max, desc, tooltip);
return true;
}
if(type == "RichOpenFile") {
QStringList list;
int exts_card = np.attribute(QString("exts_cardinality")).toUInt(&corrconv);
if (!corrconv)
return false;
for(int i=0;i<exts_card;++i)
list<<np.attribute(QString("exts_val")+QString::number(i));
QString defdir = np.attribute("value");
par = new RichOpenFile(name,defdir,list,desc,tooltip);
return true;
}
if(type == "RichSaveFile") {
QString deffile = np.attribute("value");
QString ext = np.attribute("ext");
par = new RichSaveFile(name,deffile,ext,desc,tooltip);
return true;
}
if(type=="RichPoint3f") { // 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=="RichPosition") { // for backward compatibility
vcg::Point3f val;
val[0]=np.attribute("x").toFloat(&corrconv);
if (!corrconv)
return false;
val[1]=np.attribute("y").toFloat(&corrconv);
if (!corrconv)
return false;
val[2]=np.attribute("z").toFloat(&corrconv);
if (!corrconv)
return false;
par = new RichPosition(name, val,desc,tooltip);
return true;
}
if(type=="RichDirection") { // for backward compatibility
vcg::Point3f val;
val[0]=np.attribute("x").toFloat(&corrconv);
if (!corrconv)
return false;
val[1]=np.attribute("y").toFloat(&corrconv);
if (!corrconv)
return false;
val[2]=np.attribute("z").toFloat(&corrconv);
if (!corrconv)
return false;
par = new RichDirection(name, val,desc,tooltip);
return true;
}
if(type=="RichShotf") {
Shotm val;
assert(0); //TODO!!!!
par = new RichShotf(name, val,desc,tooltip);
return true;
}
return false;
}

View File

@ -1,398 +0,0 @@
/****************************************************************************
* MeshLab o o *
* A versatile mesh processing toolbox 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 MESHLAB_RICH_PARAMETER_H
#define MESHLAB_RICH_PARAMETER_H
#include "value.h"
#include <QDomElement>
class MeshDocument;
/**
* @brief The RichParameter class
*
* The RichParameter class is a representation of a MeshLab parameter that contains
* a value of a certain type (see the Value class and its specializations) plus
* some other decorators, like a parameter description and a tooltip.
*
* All these decorators allow MeshLab to automatically design GUI interfaces for
* every RichParameter spcialization.
*
* Every specialization must implement the following member functions:
* - QString stringType() const : returns a string representation of the type of the RichParameter
* - RichParameter* clone() const : returns a *new* object which is a clone of the RichParameter
* - bool operator==(const RichParameter& rp): returns true if the two RichParameter are the same
*/
class RichParameter
{
public:
RichParameter(const RichParameter& rp);
RichParameter(RichParameter&& rp);
RichParameter(
const QString& nm,
const Value& v,
const QString& desc = QString(),
const QString& tltip = QString(),
bool isAdvanced = false,
const QString& category = QString());
virtual ~RichParameter();
const QString& name() const;
const Value& value() const;
const QString& fieldDescription() const;
const QString& toolTip() const;
bool isAdvanced() const;
const QString& category() const;
template <class RichParam>
bool isOfType() const
{
const RichParam* t = dynamic_cast<const RichParam*>(this);
return (t != nullptr);
}
virtual QString stringType() const = 0;
void setName(const QString& newName);
void setValue(const Value& ov);
virtual QDomElement fillToXMLDocument(QDomDocument& doc, bool saveDescriptionAndTooltip = true) const;
//python names of paraeter
QString pythonName() const;
QString pythonType() const;
virtual RichParameter* clone() const = 0;
RichParameter& operator=(const RichParameter& rp);
RichParameter& operator=(RichParameter&& rp);
virtual bool operator==(const RichParameter& rp) = 0;
protected:
QString pName;
Value* val;
QString fieldDesc;
QString tooltip;
bool advanced;
QString pCategory;
};
class RichBool : public RichParameter
{
public:
RichBool(
const QString& nm,
const bool defval,
const QString& desc = QString(),
const QString& tltip = QString(),
bool hidden = false,
const QString& category = QString());
~RichBool();
QString stringType() const;
RichBool* clone() const;
bool operator==(const RichParameter& rb);
};
class RichInt : public RichParameter
{
public:
RichInt(
const QString& nm,
const int defval,
const QString& desc = QString(),
const QString& tltip = QString(),
bool hidden = false,
const QString& category = QString());
~RichInt();
QString stringType() const;
RichInt* clone() const;
bool operator==(const RichParameter& rb);
};
class RichFloat : public RichParameter
{
public:
RichFloat(
const QString& nm,
const Scalarm defval,
const QString& desc = QString(),
const QString& tltip = QString(),
bool hidden = false,
const QString& category = QString());
~RichFloat();
QString stringType() const;
RichFloat* clone() const;
bool operator==(const RichParameter& rb);
};
class RichString : public RichParameter
{
public:
RichString(
const QString& nm,
const QString& defval,
const QString& desc = QString(),
const QString& tltip = QString(),
bool hidden = false,
const QString& category = QString());
~RichString();
QString stringType() const;
RichString* clone() const;
bool operator==(const RichParameter& rb);
};
class RichMatrix44f : public RichParameter
{
public:
RichMatrix44f(
const QString& nm,
const Matrix44m& defval,
const QString& desc = QString(),
const QString& tltip = QString(),
bool hidden = false,
const QString& category = QString());
~RichMatrix44f();
QString stringType() const;
RichMatrix44f* clone() const;
bool operator==(const RichParameter& rb);
};
class RichPosition : public RichParameter
{
public:
RichPosition(
const QString& nm,
const Point3m& defval,
const QString& desc = QString(),
const QString& tltip = QString(),
bool hidden = false,
const QString& category = QString());
~RichPosition();
QString stringType() 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);
};
class RichShotf : public RichParameter
{
public:
RichShotf(
const QString& nm,
const Shotm& defval,
const QString& desc = QString(),
const QString& tltip = QString(),
bool hidden = false,
const QString& category = QString());
~RichShotf();
QString stringType() const;
RichShotf* clone() const;
bool operator==(const RichParameter& rb);
};
class RichColor : public RichParameter
{
public:
RichColor(
const QString& nm,
const QColor& defval,
const QString& desc = QString(),
const QString& tltip = QString(),
bool hidden = false,
const QString& category = QString());
~RichColor();
QString stringType() const;
RichColor* clone() const;
bool operator==(const RichParameter& rb);
};
class RichAbsPerc : public RichParameter
{
public:
RichAbsPerc(
const QString& nm,
const Scalarm defval,
const Scalarm minval,
const Scalarm maxval,
const QString& desc = QString(),
const QString& tltip = QString(),
bool hidden = false,
const QString& category = QString());
~RichAbsPerc();
QString stringType() const;
QDomElement fillToXMLDocument(QDomDocument& doc, bool saveDescriptionAndTooltip = true) const;
RichAbsPerc* clone() const;
bool operator==(const RichParameter& rb);
Scalarm min;
Scalarm max;
};
class RichEnum : public RichParameter
{
public:
RichEnum(
const QString& nm,
const int defval,
const QStringList& values,
const QString& desc = QString(),
const QString& tltip = QString(),
bool hidden = false,
const QString& category = QString());
~RichEnum();
QString stringType() const;
QDomElement fillToXMLDocument(QDomDocument& doc, bool saveDescriptionAndTooltip = true) const;
RichEnum* clone() const;
bool operator==(const RichParameter& rb);
QStringList enumvalues;
};
class RichDynamicFloat : public RichParameter
{
public:
RichDynamicFloat(
const QString& nm,
const Scalarm defval,
const Scalarm minval,
const Scalarm maxval,
const QString& desc = QString(),
const QString& tltip = QString(),
bool hidden = false,
const QString& category = QString());
~RichDynamicFloat();
QString stringType() const;
QDomElement fillToXMLDocument(QDomDocument& doc, bool saveDescriptionAndTooltip = true) const;
RichDynamicFloat* clone() const;
bool operator==(const RichParameter& rb);
Scalarm min;
Scalarm max;
};
class RichOpenFile : public RichParameter
{
public:
RichOpenFile(
const QString& nm,
const QString& directorydefval,
const QStringList& exts,
const QString& desc = QString(),
const QString& tltip = QString(),
bool hidden = false,
const QString& category = QString());
~RichOpenFile();
QString stringType() const;
QDomElement fillToXMLDocument(QDomDocument& doc, bool saveDescriptionAndTooltip = true) const;
RichOpenFile* clone() const;
bool operator==(const RichParameter& rb);
QStringList exts;
};
class RichSaveFile : public RichParameter
{
public:
RichSaveFile(
const QString& nm,
const QString& filedefval,
const QString& ext,
const QString& desc = QString(),
const QString& tltip = QString(),
bool hidden = false,
const QString& category = QString());
~RichSaveFile();
QString stringType() const;
QDomElement fillToXMLDocument(QDomDocument& doc, bool saveDescriptionAndTooltip = true) const;
RichSaveFile* clone() const;
bool operator==(const RichParameter& rb);
QString ext;
};
class RichMesh : public RichParameter
{
public:
RichMesh(
const QString& nm,
unsigned int meshindex,
const MeshDocument* doc,
const QString& desc = QString(),
const QString& tltip = QString(),
bool hidden = false,
const QString& category = QString());
~RichMesh();
QString stringType() const;
RichMesh* clone() const;
bool operator==(const RichParameter& rb);
const MeshDocument* meshdoc;
};
class RichParameterAdapter
{
public:
static bool create(const QDomElement& np, RichParameter*& par);
};
#endif // MESHLAB_RICH_PARAMETER_H

View File

@ -0,0 +1,54 @@
/****************************************************************************
* MeshLab o o *
* A versatile mesh processing toolbox o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 "rich_bool.h"
RichBool::RichBool(
const QString& nm,
const bool defval,
const QString& desc,
const QString& tltip,
bool hidden,
const QString& category) :
RichParameter(nm, BoolValue(defval), desc, tltip, hidden, category)
{
}
RichBool::~RichBool()
{
}
QString RichBool::stringType() const
{
return "RichBool";
}
RichBool* RichBool::clone() const
{
return new RichBool(*this);
}
bool RichBool::operator==( const RichParameter& rb )
{
return (rb.value().isBool() && (pName == rb.name()) && (value().getBool() == rb.value().getBool()));
}

View File

@ -0,0 +1,47 @@
/****************************************************************************
* MeshLab o o *
* A versatile mesh processing toolbox o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 MESHLAB_RICH_BOOL_H
#define MESHLAB_RICH_BOOL_H
#include "rich_parameter.h"
class RichBool : public RichParameter
{
public:
RichBool(
const QString& nm,
const bool defval,
const QString& desc = QString(),
const QString& tltip = QString(),
bool hidden = false,
const QString& category = QString());
~RichBool();
QString stringType() const;
RichBool* clone() const;
bool operator==(const RichParameter& rb);
};
#endif // MESHLAB_RICH_BOOL_H

View File

@ -0,0 +1,54 @@
/****************************************************************************
* MeshLab o o *
* A versatile mesh processing toolbox o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 "rich_color.h"
RichColor::RichColor(
const QString& nm,
const QColor& defval,
const QString& desc,
const QString& tltip,
bool hidden,
const QString& category) :
RichParameter(nm, ColorValue(defval),desc, tltip, hidden, category)
{
}
RichColor::~RichColor()
{
}
QString RichColor::stringType() const
{
return "RichColor";
}
RichColor* RichColor::clone() const
{
return new RichColor(*this);
}
bool RichColor::operator==( const RichParameter& rb )
{
return (rb.value().isColor() &&(pName == rb.name()) && (value().getColor() == rb.value().getColor()));
}

View File

@ -0,0 +1,47 @@
/****************************************************************************
* MeshLab o o *
* A versatile mesh processing toolbox o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 MESHLAB_RICH_COLOR_H
#define MESHLAB_RICH_COLOR_H
#include "rich_parameter.h"
class RichColor : public RichParameter
{
public:
RichColor(
const QString& nm,
const QColor& defval,
const QString& desc = QString(),
const QString& tltip = QString(),
bool hidden = false,
const QString& category = QString());
~RichColor();
QString stringType() const;
RichColor* clone() const;
bool operator==(const RichParameter& rb);
};
#endif // MESHLAB_RICH_COLOR_H

View File

@ -0,0 +1,54 @@
/****************************************************************************
* MeshLab o o *
* A versatile mesh processing toolbox o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 "rich_direction.h"
RichDirection::RichDirection(
const QString& nm,
const Point3m& defval,
const QString& desc,
const QString& tltip,
bool hidden,
const QString& category) :
RichParameter(nm, Point3Value(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().isPoint3() &&(pName == rb.name()) && (value().getPoint3() == rb.value().getPoint3()));
}

View File

@ -0,0 +1,47 @@
/****************************************************************************
* MeshLab o o *
* A versatile mesh processing toolbox o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 MESHLAB_RICH_DIRECTION_H
#define MESHLAB_RICH_DIRECTION_H
#include "rich_parameter.h"
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);
};
#endif // MESHLAB_RICH_DIRECTION_H

View File

@ -0,0 +1,64 @@
/****************************************************************************
* MeshLab o o *
* A versatile mesh processing toolbox o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 "rich_dynamic_float.h"
RichDynamicFloat::RichDynamicFloat(
const QString& nm,
const Scalarm defval,
const Scalarm minval,
const Scalarm maxval,
const QString& desc,
const QString& tltip,
bool hidden,
const QString& category) :
RichParameter(nm, FloatValue(defval),desc, tltip, hidden, category), min(minval), max(maxval)
{
}
RichDynamicFloat::~RichDynamicFloat()
{
}
QString RichDynamicFloat::stringType() const
{
return "RichDynamicFloat";
}
QDomElement RichDynamicFloat::fillToXMLDocument(QDomDocument& doc, bool saveDescriptionAndTooltip) const
{
QDomElement parElem = RichParameter::fillToXMLDocument(doc, saveDescriptionAndTooltip);
parElem.setAttribute("min",QString::number(min));
parElem.setAttribute("max",QString::number(max));
return parElem;
}
RichDynamicFloat* RichDynamicFloat::clone() const
{
return new RichDynamicFloat(*this);
}
bool RichDynamicFloat::operator==( const RichParameter& rb )
{
return (rb.isOfType<RichDynamicFloat>() &&(pName == rb.name()) && (value().getFloat() == rb.value().getFloat()));
}

View File

@ -0,0 +1,52 @@
/****************************************************************************
* MeshLab o o *
* A versatile mesh processing toolbox o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 MESHLAB_RICH_DYNAMIC_FLOAT_H
#define MESHLAB_RICH_DYNAMIC_FLOAT_H
#include "rich_parameter.h"
class RichDynamicFloat : public RichParameter
{
public:
RichDynamicFloat(
const QString& nm,
const Scalarm defval,
const Scalarm minval,
const Scalarm maxval,
const QString& desc = QString(),
const QString& tltip = QString(),
bool hidden = false,
const QString& category = QString());
~RichDynamicFloat();
QString stringType() const;
QDomElement fillToXMLDocument(QDomDocument& doc, bool saveDescriptionAndTooltip = true) const;
RichDynamicFloat* clone() const;
bool operator==(const RichParameter& rb);
Scalarm min;
Scalarm max;
};
#endif // MESHLAB_RICH_DYNAMIC_FLOAT_H

View File

@ -0,0 +1,65 @@
/****************************************************************************
* MeshLab o o *
* A versatile mesh processing toolbox o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 "rich_enum.h"
RichEnum::RichEnum(
const QString& nm,
const int defval,
const QStringList& values,
const QString& desc,
const QString& tltip,
bool hidden,
const QString& category) :
RichParameter(nm, IntValue(defval),desc, tltip, hidden, category), enumvalues(values)
{
}
RichEnum::~RichEnum()
{
}
QString RichEnum::stringType() const
{
return "RichEnum";
}
QDomElement RichEnum::fillToXMLDocument(QDomDocument& doc, bool saveDescriptionAndTooltip) const
{
QDomElement parElem = RichParameter::fillToXMLDocument(doc, saveDescriptionAndTooltip);
parElem.setAttribute("enum_cardinality", enumvalues.size());
for(int ii = 0; ii < enumvalues.size(); ++ii)
parElem.setAttribute(QString("enum_val")+QString::number(ii), enumvalues.at(ii));
return parElem;
}
RichEnum* RichEnum::clone() const
{
return new RichEnum(*this);
}
bool RichEnum::operator==( const RichParameter& rb )
{
return (rb.isOfType<RichEnum>() &&(pName == rb.name()) && (value().getInt() == rb.value().getInt()));
}

View File

@ -0,0 +1,50 @@
/****************************************************************************
* MeshLab o o *
* A versatile mesh processing toolbox o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 MESHLAB_RICH_ENUM_H
#define MESHLAB_RICH_ENUM_H
#include "rich_parameter.h"
class RichEnum : public RichParameter
{
public:
RichEnum(
const QString& nm,
const int defval,
const QStringList& values,
const QString& desc = QString(),
const QString& tltip = QString(),
bool hidden = false,
const QString& category = QString());
~RichEnum();
QString stringType() const;
QDomElement fillToXMLDocument(QDomDocument& doc, bool saveDescriptionAndTooltip = true) const;
RichEnum* clone() const;
bool operator==(const RichParameter& rb);
QStringList enumvalues;
};
#endif // MESHLAB_RICH_ENUM_H

View File

@ -0,0 +1,64 @@
/****************************************************************************
* MeshLab o o *
* A versatile mesh processing toolbox o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 "rich_file_open.h"
RichFileOpen::RichFileOpen(
const QString& nm,
const QString& directorydefval,
const QStringList& exts,
const QString& desc,
const QString& tltip,
bool hidden,
const QString& category) :
RichParameter(nm, StringValue(directorydefval), desc, tltip, hidden, category), exts(exts)
{
}
RichFileOpen::~RichFileOpen()
{
}
QString RichFileOpen::stringType() const
{
return "RichOpenFile";
}
QDomElement RichFileOpen::fillToXMLDocument(QDomDocument& doc, bool saveDescriptionAndTooltip) const
{
QDomElement parElem = RichParameter::fillToXMLDocument(doc, saveDescriptionAndTooltip);
parElem.setAttribute("exts_cardinality", exts.size());
for(int ii = 0; ii < exts.size(); ++ii)
parElem.setAttribute(QString("ext_val")+QString::number(ii), exts[ii]);
return parElem;
}
RichFileOpen* RichFileOpen::clone() const
{
return new RichFileOpen(*this);
}
bool RichFileOpen::operator==( const RichParameter& rb )
{
return (rb.isOfType<RichFileOpen>() &&(pName == rb.name()) && (value().getString() == rb.value().getString()));
}

View File

@ -0,0 +1,50 @@
/****************************************************************************
* MeshLab o o *
* A versatile mesh processing toolbox o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 MESHLAB_RICH_FILE_OPEN_H
#define MESHLAB_RICH_FILE_OPEN_H
#include "rich_parameter.h"
class RichFileOpen : public RichParameter
{
public:
RichFileOpen(
const QString& nm,
const QString& directorydefval,
const QStringList& exts,
const QString& desc = QString(),
const QString& tltip = QString(),
bool hidden = false,
const QString& category = QString());
~RichFileOpen();
QString stringType() const;
QDomElement fillToXMLDocument(QDomDocument& doc, bool saveDescriptionAndTooltip = true) const;
RichFileOpen* clone() const;
bool operator==(const RichParameter& rb);
QStringList exts;
};
#endif // MESHLAB_RICH_FILE_OPEN_H

View File

@ -0,0 +1,62 @@
/****************************************************************************
* MeshLab o o *
* A versatile mesh processing toolbox o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 "rich_file_save.h"
RichFileSave::RichFileSave(
const QString& nm,
const QString& filedefval,
const QString& ext,
const QString& desc,
const QString& tltip,
bool hidden,
const QString& category) :
RichParameter(nm, StringValue(filedefval), desc, tltip, hidden, category), ext(ext)
{
}
RichFileSave::~RichFileSave()
{
}
QString RichFileSave::stringType() const
{
return "RichSaveFile";
}
QDomElement RichFileSave::fillToXMLDocument(QDomDocument& doc, bool saveDescriptionAndTooltip) const
{
QDomElement parElem = RichParameter::fillToXMLDocument(doc, saveDescriptionAndTooltip);
parElem.setAttribute("ext", ext);
return parElem;
}
RichFileSave* RichFileSave::clone() const
{
return new RichFileSave(*this);
}
bool RichFileSave::operator==( const RichParameter& rb )
{
return (rb.isOfType<RichFileSave>() &&(pName == rb.name()) && (value().getString() == rb.value().getString()));
}

View File

@ -0,0 +1,50 @@
/****************************************************************************
* MeshLab o o *
* A versatile mesh processing toolbox o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 MESHLAB_RICH_FILE_SAVE_H
#define MESHLAB_RICH_FILE_SAVE_H
#include "rich_parameter.h"
class RichFileSave : public RichParameter
{
public:
RichFileSave(
const QString& nm,
const QString& filedefval,
const QString& ext,
const QString& desc = QString(),
const QString& tltip = QString(),
bool hidden = false,
const QString& category = QString());
~RichFileSave();
QString stringType() const;
QDomElement fillToXMLDocument(QDomDocument& doc, bool saveDescriptionAndTooltip = true) const;
RichFileSave* clone() const;
bool operator==(const RichParameter& rb);
QString ext;
};
#endif // MESHLAB_RICH_FILE_SAVE_H

View File

@ -0,0 +1,55 @@
/****************************************************************************
* MeshLab o o *
* A versatile mesh processing toolbox o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 "rich_float.h"
RichFloat::RichFloat(
const QString& nm,
const Scalarm defval,
const QString& desc,
const QString& tltip,
bool hidden,
const QString& category) :
RichParameter(nm, FloatValue(defval),desc, tltip, hidden, category)
{
}
RichFloat::~RichFloat()
{
}
QString RichFloat::stringType() const
{
return "RichFloat";
}
RichFloat* RichFloat::clone() const
{
return new RichFloat(*this);
}
bool RichFloat::operator==( const RichParameter& rb )
{
return (rb.value().isFloat() &&(pName == rb.name()) && (value().getFloat() == rb.value().getFloat()));
}

View File

@ -0,0 +1,47 @@
/****************************************************************************
* MeshLab o o *
* A versatile mesh processing toolbox o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 MESHLAB_RICH_FLOAT_H
#define MESHLAB_RICH_FLOAT_H
#include "rich_parameter.h"
class RichFloat : public RichParameter
{
public:
RichFloat(
const QString& nm,
const Scalarm defval,
const QString& desc = QString(),
const QString& tltip = QString(),
bool hidden = false,
const QString& category = QString());
~RichFloat();
QString stringType() const;
RichFloat* clone() const;
bool operator==(const RichParameter& rb);
};
#endif // MESHLAB_RICH_FLOAT_H

View File

@ -0,0 +1,55 @@
/****************************************************************************
* MeshLab o o *
* A versatile mesh processing toolbox o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 "rich_int.h"
RichInt::RichInt(
const QString& nm,
const int defval,
const QString& desc,
const QString& tltip,
bool hidden,
const QString& category) :
RichParameter(nm, IntValue(defval),desc, tltip, hidden, category)
{
}
RichInt::~RichInt()
{
}
QString RichInt::stringType() const
{
return "RichInt";
}
RichInt* RichInt::clone() const
{
return new RichInt(*this);
}
bool RichInt::operator==( const RichParameter& rb )
{
return (rb.value().isInt() &&(pName == rb.name()) && (value().getInt() == rb.value().getInt()));
}

View File

@ -0,0 +1,47 @@
/****************************************************************************
* MeshLab o o *
* A versatile mesh processing toolbox o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 MESHLAB_RICH_INT_H
#define MESHLAB_RICH_INT_H
#include "rich_parameter.h"
class RichInt : public RichParameter
{
public:
RichInt(
const QString& nm,
const int defval,
const QString& desc = QString(),
const QString& tltip = QString(),
bool hidden = false,
const QString& category = QString());
~RichInt();
QString stringType() const;
RichInt* clone() const;
bool operator==(const RichParameter& rb);
};
#endif // MESHLAB_RICH_INT_H

View File

@ -0,0 +1,55 @@
/****************************************************************************
* MeshLab o o *
* A versatile mesh processing toolbox o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 "rich_matrix44.h"
RichMatrix44::RichMatrix44(
const QString& nm,
const Matrix44m& defval,
const QString& desc,
const QString& tltip,
bool hidden,
const QString& category) :
RichParameter(nm, Matrix44Value(defval),desc, tltip, hidden, category)
{
}
RichMatrix44::~RichMatrix44()
{
}
QString RichMatrix44::stringType() const
{
return "RichMatrix44f";
}
RichMatrix44* RichMatrix44::clone() const
{
return new RichMatrix44(*this);
}
bool RichMatrix44::operator==( const RichParameter& rb )
{
return (rb.value().isMatrix44() &&(pName == rb.name()) && (value().getMatrix44() == rb.value().getMatrix44()));
}

View File

@ -0,0 +1,47 @@
/****************************************************************************
* MeshLab o o *
* A versatile mesh processing toolbox o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 MESHLAB_RICH_MATRIX44_H
#define MESHLAB_RICH_MATRIX44_H
#include "rich_parameter.h"
class RichMatrix44 : public RichParameter
{
public:
RichMatrix44(
const QString& nm,
const Matrix44m& defval,
const QString& desc = QString(),
const QString& tltip = QString(),
bool hidden = false,
const QString& category = QString());
~RichMatrix44();
QString stringType() const;
RichMatrix44* clone() const;
bool operator==(const RichParameter& rb);
};
#endif // MESHLAB_RICH_MATRIX44_H

View File

@ -0,0 +1,56 @@
/****************************************************************************
* MeshLab o o *
* A versatile mesh processing toolbox o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 "rich_mesh.h"
RichMesh::RichMesh(
const QString& nm,
unsigned int meshind,
const MeshDocument* doc,
const QString& desc,
const QString& tltip,
bool hidden,
const QString& category):
RichParameter(nm,IntValue(meshind), desc, tltip, hidden, category), meshdoc(doc)
{
}
RichMesh::~RichMesh()
{
}
QString RichMesh::stringType() const
{
return "RichMesh";
}
RichMesh* RichMesh::clone() const
{
return new RichMesh(*this);
}
bool RichMesh::operator==( const RichParameter& rb )
{
return (rb.isOfType<RichMesh>() &&(pName == rb.name()) && (value().getInt() == rb.value().getInt()));
}

View File

@ -0,0 +1,49 @@
/****************************************************************************
* MeshLab o o *
* A versatile mesh processing toolbox o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 MESHLAB_RICH_MESH_H
#define MESHLAB_RICH_MESH_H
#include "rich_parameter.h"
class RichMesh : public RichParameter
{
public:
RichMesh(
const QString& nm,
unsigned int meshindex,
const MeshDocument* doc,
const QString& desc = QString(),
const QString& tltip = QString(),
bool hidden = false,
const QString& category = QString());
~RichMesh();
QString stringType() const;
RichMesh* clone() const;
bool operator==(const RichParameter& rb);
const MeshDocument* meshdoc;
};
#endif // MESHLAB_RICH_MESH_H

View File

@ -0,0 +1,186 @@
/****************************************************************************
* MeshLab o o *
* A versatile mesh processing toolbox o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 "rich_parameter.h"
#include <common/ml_document/mesh_document.h>
#include <common/python/python_utils.h>
RichParameter::RichParameter(const RichParameter& rp) :
pName(rp.pName),
val(rp.value().clone()),
fieldDesc(rp.fieldDesc),
tooltip(rp.tooltip),
advanced(rp.advanced),
defaultValue(rp.defaultValue),
pCategory(rp.pCategory)
{
}
RichParameter::RichParameter(RichParameter&& rp)
{
swap(rp);
}
RichParameter::RichParameter(
const QString& nm,
const Value& v,
const QString& desc,
const QString& tltip,
bool isAdvanced,
const QString& category) :
pName(nm),
val(v.clone()),
fieldDesc(desc),
tooltip(tltip),
advanced(isAdvanced),
defaultValue(true),
pCategory(category)
{
}
RichParameter::~RichParameter()
{
delete val;
}
const QString& RichParameter::name() const
{
return pName;
}
const Value& RichParameter::value() const
{
return *val;
}
const QString& RichParameter::fieldDescription() const
{
return fieldDesc;
}
const QString& RichParameter::toolTip() const
{
return tooltip;
}
bool RichParameter::isAdvanced() const
{
return advanced;
}
bool RichParameter::isValueDefault() const
{
return defaultValue;
}
const QString& RichParameter::category() const
{
return pCategory;
}
void RichParameter::setName(const QString& newName)
{
pName = newName;
}
void RichParameter::setValue(const Value& ov, bool isDefault)
{
assert(val->typeName() == ov.typeName());
delete val;
val = ov.clone();
defaultValue = isDefault;
}
void RichParameter::setDefaultValue(bool isDefault)
{
defaultValue = isDefault;
}
QDomElement RichParameter::fillToXMLDocument(QDomDocument& doc, bool saveDescriptionAndTooltip) const
{
QDomElement parElem = doc.createElement("Param");
parElem.setAttribute("name", pName);
parElem.setAttribute("type", stringType());
if (saveDescriptionAndTooltip) {
parElem.setAttribute("description", fieldDesc);
parElem.setAttribute("tooltip",tooltip);
}
val->fillToXMLElement(parElem);
return parElem;
}
/**
* @brief returns the name of the parameter used in python (for pymeshlab)
*/
QString RichParameter::pythonName() const
{
return pymeshlab::computePythonName(pName);
}
/**
* @brief returns the type if the parameter (as a string) used in python
* (for pymeshlab)
*/
QString RichParameter::pythonType() const
{
return pymeshlab::computePythonTypeString(*this);
}
RichParameter& RichParameter::operator=(const RichParameter& rp)
{
if (&rp != this){
delete val;
val = rp.value().clone();
pName = rp.pName;
fieldDesc = rp.fieldDesc;
tooltip = rp.tooltip;
advanced = rp.advanced;
defaultValue = rp.defaultValue;
pCategory = rp.pCategory;
}
return *this;
}
RichParameter& RichParameter::operator=(RichParameter&& rp)
{
::swap(*this, rp);
return *this;
}
void RichParameter::swap(RichParameter &rp)
{
::swap(*this, rp);
}
void swap(RichParameter &rp1, RichParameter &rp2)
{
using std::swap;
swap(rp1.pName, rp2.pName);
swap(rp1.val, rp2.val);
swap(rp1.fieldDesc, rp2.fieldDesc);
swap(rp1.tooltip, rp2.tooltip);
swap(rp1.advanced, rp2.advanced);
swap(rp1.defaultValue, rp2.defaultValue);
swap(rp1.pCategory, rp2.pCategory);
}

View File

@ -0,0 +1,109 @@
/****************************************************************************
* MeshLab o o *
* A versatile mesh processing toolbox o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 MESHLAB_RICH_PARAMETER_H
#define MESHLAB_RICH_PARAMETER_H
#include <QDomElement>
#include <common/parameters/values.h>
class MeshDocument;
/**
* @brief The RichParameter class
*
* The RichParameter class is a representation of a MeshLab parameter that contains
* a value of a certain type (see the Value class and its specializations) plus
* some other decorators, like a parameter description and a tooltip.
*
* All these decorators allow MeshLab to automatically design GUI interfaces for
* every RichParameter spcialization.
*
* Every specialization must implement the following member functions:
* - QString stringType() const : returns a string representation of the type of the RichParameter
* - RichParameter* clone() const : returns a *new* object which is a clone of the RichParameter
* - bool operator==(const RichParameter& rp): returns true if the two RichParameter are the same
*/
class RichParameter
{
public:
RichParameter(const RichParameter& rp);
RichParameter(RichParameter&& rp);
RichParameter(
const QString& nm,
const Value& v,
const QString& desc = QString(),
const QString& tltip = QString(),
bool isAdvanced = false,
const QString& category = QString());
virtual ~RichParameter();
const QString& name() const;
const Value& value() const;
const QString& fieldDescription() const;
const QString& toolTip() const;
bool isAdvanced() const;
bool isValueDefault() const;
const QString& category() const;
template <class RichParam>
bool isOfType() const
{
const RichParam* t = dynamic_cast<const RichParam*>(this);
return (t != nullptr);
}
void setName(const QString& newName);
void setValue(const Value& ov, bool isDefault = false);
void setDefaultValue(bool isDefault = true);
virtual QDomElement fillToXMLDocument(QDomDocument& doc, bool saveDescriptionAndTooltip = true) const;
//python names of paraeter
QString pythonName() const;
QString pythonType() const;
RichParameter& operator=(const RichParameter& rp);
RichParameter& operator=(RichParameter&& rp);
virtual RichParameter* clone() const = 0;
virtual QString stringType() const = 0;
virtual bool operator==(const RichParameter& rp) = 0;
friend void swap(RichParameter& rp1, RichParameter& rp2);
void swap(RichParameter& rp);
protected:
QString pName;
Value* val;
QString fieldDesc;
QString tooltip;
bool advanced;
bool defaultValue;
QString pCategory;
};
void swap(RichParameter& rp1, RichParameter& rp2);
#endif // MESHLAB_RICH_PARAMETER_H

View File

@ -0,0 +1,64 @@
/****************************************************************************
* MeshLab o o *
* A versatile mesh processing toolbox o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 "rich_percentage.h"
RichPercentage::RichPercentage(
const QString& nm,
const Scalarm defval,
const Scalarm minval,
const Scalarm maxval,
const QString& desc,
const QString& tltip,
bool hidden,
const QString& category) :
RichParameter(nm, FloatValue(defval), desc, tltip, hidden, category), min(minval), max(maxval)
{
}
RichPercentage::~RichPercentage()
{
}
QString RichPercentage::stringType() const
{
return "RichAbsPerc";
}
QDomElement RichPercentage::fillToXMLDocument(QDomDocument& doc, bool saveDescriptionAndTooltip) const
{
QDomElement parElem = RichParameter::fillToXMLDocument(doc, saveDescriptionAndTooltip);
parElem.setAttribute("min",QString::number(min));
parElem.setAttribute("max",QString::number(max));
return parElem;
}
RichPercentage* RichPercentage::clone() const
{
return new RichPercentage(*this);
}
bool RichPercentage::operator==( const RichParameter& rb )
{
return (rb.isOfType<RichPercentage>() &&(pName == rb.name()) && (value().getFloat() == rb.value().getFloat()));
}

View File

@ -0,0 +1,52 @@
/****************************************************************************
* MeshLab o o *
* A versatile mesh processing toolbox o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 MESHLAB_RICH_PERCENTAGE_H
#define MESHLAB_RICH_PERCENTAGE_H
#include "rich_parameter.h"
class RichPercentage : public RichParameter
{
public:
RichPercentage(
const QString& nm,
const Scalarm defval,
const Scalarm minval,
const Scalarm maxval,
const QString& desc = QString(),
const QString& tltip = QString(),
bool hidden = false,
const QString& category = QString());
~RichPercentage();
QString stringType() const;
QDomElement fillToXMLDocument(QDomDocument& doc, bool saveDescriptionAndTooltip = true) const;
RichPercentage* clone() const;
bool operator==(const RichParameter& rb);
Scalarm min;
Scalarm max;
};
#endif // MESHLAB_RICH_PERCENTAGE_H

View File

@ -0,0 +1,55 @@
/****************************************************************************
* MeshLab o o *
* A versatile mesh processing toolbox o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 "rich_position.h"
RichPosition::RichPosition(
const QString& nm,
const Point3m& defval,
const QString& desc,
const QString& tltip,
bool hidden,
const QString& category) :
RichParameter(nm, Point3Value(defval),desc, tltip, hidden, category)
{
}
RichPosition::~RichPosition()
{
}
QString RichPosition::stringType() const
{
return "RichPosition";
}
RichPosition* RichPosition::clone() const
{
return new RichPosition(*this);
}
bool RichPosition::operator==( const RichParameter& rb )
{
return (rb.value().isPoint3() &&(pName == rb.name()) && (value().getPoint3() == rb.value().getPoint3()));
}

View File

@ -0,0 +1,47 @@
/****************************************************************************
* MeshLab o o *
* A versatile mesh processing toolbox o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 MESHLAB_RICH_POSITION_H
#define MESHLAB_RICH_POSITION_H
#include "rich_parameter.h"
class RichPosition : public RichParameter
{
public:
RichPosition(
const QString& nm,
const Point3m& defval,
const QString& desc = QString(),
const QString& tltip = QString(),
bool hidden = false,
const QString& category = QString());
~RichPosition();
QString stringType() const;
RichPosition* clone() const;
bool operator==(const RichParameter& rb);
};
#endif // MESHLAB_RICH_POSITION_H

View File

@ -0,0 +1,56 @@
/****************************************************************************
* MeshLab o o *
* A versatile mesh processing toolbox o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 "rich_shot.h"
RichShot::RichShot(
const QString& nm,
const Shotm& defval,
const QString& desc,
const QString& tltip,
bool hidden,
const QString& category) :
RichParameter(nm, ShotValue(defval),desc, tltip, hidden, category)
{
}
RichShot::~RichShot()
{
}
QString RichShot::stringType() const
{
return "RichShotf";
}
RichShot* RichShot::clone() const
{
return new RichShot(*this);
}
bool RichShot::operator==( const RichParameter& rb )
{
return (rb.value().isShot() &&(pName == rb.name()) );
// TODO REAL TEST OF EQUALITY // && (value().getShotf() == rb.value().getShotf()));
}

View File

@ -0,0 +1,47 @@
/****************************************************************************
* MeshLab o o *
* A versatile mesh processing toolbox o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 MESHLAB_RICH_SHOT_H
#define MESHLAB_RICH_SHOT_H
#include "rich_parameter.h"
class RichShot : public RichParameter
{
public:
RichShot(
const QString& nm,
const Shotm& defval,
const QString& desc = QString(),
const QString& tltip = QString(),
bool hidden = false,
const QString& category = QString());
~RichShot();
QString stringType() const;
RichShot* clone() const;
bool operator==(const RichParameter& rb);
};
#endif // MESHLAB_RICH_SHOT_H

View File

@ -0,0 +1,55 @@
/****************************************************************************
* MeshLab o o *
* A versatile mesh processing toolbox o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 "rich_string.h"
RichString::RichString(
const QString& nm,
const QString& defval,
const QString& desc,
const QString& tltip,
bool hidden,
const QString& category) :
RichParameter(nm, StringValue(defval),desc,tltip, hidden, category)
{
}
RichString::~RichString()
{
}
QString RichString::stringType() const
{
return "RichString";
}
RichString* RichString::clone() const
{
return new RichString(*this);
}
bool RichString::operator==( const RichParameter& rb )
{
return (rb.value().isString() &&(pName == rb.name()) && (value().getString() == rb.value().getString()));
}

View File

@ -0,0 +1,47 @@
/****************************************************************************
* MeshLab o o *
* A versatile mesh processing toolbox o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 MESHLAB_RICH_STRING_H
#define MESHLAB_RICH_STRING_H
#include "rich_parameter.h"
class RichString : public RichParameter
{
public:
RichString(
const QString& nm,
const QString& defval,
const QString& desc = QString(),
const QString& tltip = QString(),
bool hidden = false,
const QString& category = QString());
~RichString();
QString stringType() const;
RichString* clone() const;
bool operator==(const RichParameter& rb);
};
#endif // MESHLAB_RICH_STRING_H

View File

@ -152,7 +152,7 @@ QString RichParameterList::getString(const QString& name) const
*/
Matrix44m RichParameterList::getMatrix44(const QString& name) const
{
return getParameterByName(name).value().getMatrix44f();
return getParameterByName(name).value().getMatrix44();
}
/**
@ -161,7 +161,7 @@ Matrix44m RichParameterList::getMatrix44(const QString& name) const
*/
Point3m RichParameterList::getPoint3m(const QString& name) const
{
return getParameterByName(name).value().getPoint3f();
return getParameterByName(name).value().getPoint3();
}
/**
@ -170,7 +170,7 @@ Point3m RichParameterList::getPoint3m(const QString& name) const
*/
Shot<Scalarm> RichParameterList::getShotf(const QString& name) const
{
return Shot<Scalarm>::Construct(getParameterByName(name).value().getShotf());
return Shot<Scalarm>::Construct(getParameterByName(name).value().getShot());
}
/**
@ -335,6 +335,13 @@ void RichParameterList::setValue(const QString& name,const Value& newval)
getParameterByName(name).setValue(newval);
}
void RichParameterList::setAllValuesAsDefault()
{
for (auto& p : paramList) {
p->setDefaultValue();
}
}
/**
* @brief adds a RichParameter to the list.
* @return a reference to the added parameter

View File

@ -24,7 +24,7 @@
#ifndef MESHLAB_RICH_PARAMETER_LIST_H
#define MESHLAB_RICH_PARAMETER_LIST_H
#include "rich_parameter.h"
#include "rich_parameters.h"
/**
* @brief The RichParameterList class
@ -123,6 +123,7 @@ public:
unsigned int numberAdvancedParameters() const;
void setValue(const QString& name, const Value& val);
void setAllValuesAsDefault();
RichParameter& addParam(const RichParameter& pd);
void join(const RichParameterList& rps);

View File

@ -0,0 +1,227 @@
/*****************************************************************************
* MeshLab o o *
* A versatile mesh processing toolbox o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 "rich_parameters.h"
bool RichParameterAdapter::create( const QDomElement& np,RichParameter*& par )
{
QString name=np.attribute("name");
QString type=np.attribute("type");
QString desc=np.attribute("description");
QString tooltip=np.attribute("tooltip");
// qDebug(" Reading Param with name %s : %s", qUtf8Printable(name), qUtf8Printable(type));
bool corrconv = false;
if(type=="RichBool") {
QString val = np.attribute("value").toLower();
if ((val != QString("true")) && (val != QString("false")))
return false;
par = new RichBool(name,np.attribute("value")!=QString("false"),desc,tooltip);
return true;
}
if(type=="RichInt") {
int val = np.attribute("value").toInt(&corrconv);
if (!corrconv)
return false;
par = new RichInt(name,val,desc,tooltip);
return true;
}
if(type=="RichFloat") {
float val = np.attribute("value").toFloat(&corrconv);
if (!corrconv)
return false;
par = new RichFloat(name,val,desc,tooltip);
return true;
}
if(type=="RichString") {
par = new RichString(name,np.attribute("value"),desc,tooltip);
return true;
}
if(type=="RichAbsPerc") {
float val = np.attribute("value").toFloat(&corrconv);
if ((!corrconv) && (val >= 0.0f) && (val <= 100.0f))
return false;
float min = np.attribute("min").toFloat(&corrconv);
if (!corrconv)
return false;
float max = np.attribute("max").toFloat(&corrconv);
if (!corrconv)
return false;
par = new RichPercentage(name,val,min,max,desc,tooltip);
return true;
}
if(type=="RichColor") {
unsigned int r = np.attribute("r").toUInt(&corrconv);
if ((!corrconv) && (r <= 255))
return false;
unsigned int g = np.attribute("g").toUInt(&corrconv);
if ((!corrconv) && (g <= 255))
return false;
unsigned int b = np.attribute("b").toUInt(&corrconv);
if ((!corrconv) && (b <= 255))
return false;
unsigned int a = np.attribute("a").toUInt(&corrconv);
if ((!corrconv) && (a <= 255))
return false;
QColor col(r,g,b,a);
par= new RichColor(name,col,desc,tooltip);
return true;
}
if(type=="RichMatrix44f") {
Matrix44m mm;
for(int i=0;i<16;++i)
{
Scalarm val = np.attribute(QString("val")+QString::number(i)).toFloat(&corrconv);
if (!corrconv)
return false;
mm.V()[i]=val;
}
par = new RichMatrix44(name,mm,desc,tooltip);
return true;
}
if(type=="RichEnum") {
QStringList list;
int enum_card = np.attribute(QString("enum_cardinality")).toUInt(&corrconv);
if (!corrconv)
return false;
for(int i=0;i<enum_card;++i)
list<<np.attribute(QString("enum_val")+QString::number(i));
int val = np.attribute("value").toInt(&corrconv);
if ((!corrconv) && (val >=0) && (val < enum_card))
return false;
par = new RichEnum(name,val,list,desc,tooltip);
return true;
}
if(type == "RichMesh") {
int val = np.attribute("value").toInt(&corrconv);
if (!corrconv)
return false;
par = new RichMesh(name, val, nullptr, desc,tooltip);
return true;
}
if(type == "RichDynamicFloat") {
float min = np.attribute("min").toFloat(&corrconv);
if (!corrconv)
return false;
float max = np.attribute("max").toFloat(&corrconv);
if (!corrconv)
return false;
float val = np.attribute("value").toFloat(&corrconv);
if ((!corrconv) && (val >= min) && (val <= max))
return false;
par = new RichDynamicFloat(name, val, min, max, desc, tooltip);
return true;
}
if(type == "RichOpenFile") {
QStringList list;
int exts_card = np.attribute(QString("exts_cardinality")).toUInt(&corrconv);
if (!corrconv)
return false;
for(int i=0;i<exts_card;++i)
list<<np.attribute(QString("exts_val")+QString::number(i));
QString defdir = np.attribute("value");
par = new RichFileOpen(name,defdir,list,desc,tooltip);
return true;
}
if(type == "RichSaveFile") {
QString deffile = np.attribute("value");
QString ext = np.attribute("ext");
par = new RichFileSave(name,deffile,ext,desc,tooltip);
return true;
}
if(type=="RichPoint3f") { // 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=="RichPosition") {
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") {
vcg::Point3f val;
val[0]=np.attribute("x").toFloat(&corrconv);
if (!corrconv)
return false;
val[1]=np.attribute("y").toFloat(&corrconv);
if (!corrconv)
return false;
val[2]=np.attribute("z").toFloat(&corrconv);
if (!corrconv)
return false;
par = new RichDirection(name, val,desc,tooltip);
return true;
}
if(type=="RichShotf") {
Shotm val;
assert(0); //TODO!!!!
par = new RichShot(name, val,desc,tooltip);
return true;
}
return false;
}

View File

@ -0,0 +1,50 @@
/*****************************************************************************
* MeshLab o o *
* A versatile mesh processing toolbox o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 MESHLAB_RICH_PARAMETERS_H
#define MESHLAB_RICH_PARAMETERS_H
#include "rich_parameter/rich_bool.h"
#include "rich_parameter/rich_color.h"
#include "rich_parameter/rich_direction.h"
#include "rich_parameter/rich_dynamic_float.h"
#include "rich_parameter/rich_enum.h"
#include "rich_parameter/rich_float.h"
#include "rich_parameter/rich_file_open.h"
#include "rich_parameter/rich_file_save.h"
#include "rich_parameter/rich_int.h"
#include "rich_parameter/rich_matrix44.h"
#include "rich_parameter/rich_mesh.h"
#include "rich_parameter/rich_percentage.h"
#include "rich_parameter/rich_position.h"
#include "rich_parameter/rich_shot.h"
#include "rich_parameter/rich_string.h"
#include "rich_parameter/rich_parameter.h"
class RichParameterAdapter
{
public:
static bool create(const QDomElement& np, RichParameter*& par);
};
#endif // MESHLAB_RICH_PARAMETERS_H

View File

@ -1,207 +0,0 @@
/****************************************************************************
* MeshLab o o *
* A versatile mesh processing toolbox 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 MESHLAB_VALUE_H
#define MESHLAB_VALUE_H
#include <QString>
#include <QColor>
#include "../ml_document/cmesh.h"
class MeshModel;
class MeshDocument;
class QDomElement;
/**
* @brief The Value class
*
* Represents a generic parameter value for meshlab.
* Specializations inherit from this class, depending on the type of the
* value. Value class is an attribute of the RichParameter class.
*/
class Value
{
public:
virtual ~Value() {}
virtual bool getBool() const { assert(0); return bool(); }
virtual int getInt() const { assert(0); return int(); }
virtual Scalarm getFloat() const { assert(0); return Scalarm(); }
virtual QString getString() const { assert(0); return QString(); }
virtual Matrix44m getMatrix44f() const { assert(0); return Matrix44m(); }
virtual Point3m getPoint3f() const { assert(0); return Point3m(); }
virtual Shotm getShotf() const { assert(0); return Shotm(); }
virtual QColor getColor() const { assert(0); return QColor(); }
virtual bool isBool() const { return false; }
virtual bool isInt() const { return false; }
virtual bool isFloat() const { return false; }
virtual bool isString() const { return false; }
virtual bool isMatrix44f() const { return false; }
virtual bool isPoint3f() const { return false; }
virtual bool isShotf() const { return false; }
virtual bool isColor() const { return false; }
virtual QString typeName() const = 0;
virtual void set(const Value& p) = 0;
virtual Value* clone() const = 0;
virtual void fillToXMLElement(QDomElement& element) const = 0;
};
class BoolValue : public Value
{
public:
BoolValue(const bool val) : pval(val) {};
~BoolValue() {}
inline bool getBool() const { return pval; }
inline bool isBool() const { return true; }
inline QString typeName() const { return QString("Bool"); }
inline void set(const Value& p) { pval = p.getBool(); }
inline BoolValue* clone() const {return new BoolValue(*this);}
void fillToXMLElement(QDomElement& element) const;
private:
bool pval;
};
class IntValue : public Value
{
public:
IntValue(const int val) : pval(val) {}
~IntValue() {}
inline int getInt() const { return pval; }
inline bool isInt() const { return true; }
inline QString typeName() const { return QString("Int"); }
inline void set(const Value& p) { pval = p.getInt(); }
inline IntValue* clone() const {return new IntValue(*this);}
void fillToXMLElement(QDomElement& element) const;
private:
int pval;
};
class FloatValue : public Value
{
public:
FloatValue(const float val) :pval(val) {}
~FloatValue() {}
inline Scalarm getFloat() const { return pval; }
inline bool isFloat() const { return true; }
inline QString typeName() const { return QString("Float"); }
inline void set(const Value& p) { pval = p.getFloat(); }
inline FloatValue* clone() const {return new FloatValue(*this);}
void fillToXMLElement(QDomElement& element) const;
private:
Scalarm pval;
};
class StringValue : public Value
{
public:
StringValue(const QString& val) :pval(val) {}
~StringValue() {}
inline QString getString() const { return pval; }
inline bool isString() const { return true; }
inline QString typeName() const { return QString("String"); }
inline void set(const Value& p) { pval = p.getString(); }
inline StringValue* clone() const {return new StringValue(*this);}
void fillToXMLElement(QDomElement& element) const;
private:
QString pval;
};
class Matrix44fValue : public Value
{
public:
Matrix44fValue(const Matrix44m& val) :pval(val) {}
//Matrix44fValue(const vcg::Matrix44d& val) :pval(vcg::Matrix44f::Construct(val)) {}
~Matrix44fValue() {}
inline Matrix44m getMatrix44f() const { return pval; }
inline bool isMatrix44f() const { return true; }
inline QString typeName() const { return QString("Matrix44f"); }
inline void set(const Value& p) { pval = p.getMatrix44f(); }
inline Matrix44fValue* clone() const {return new Matrix44fValue(*this);}
void fillToXMLElement(QDomElement& element) const;
private:
Matrix44m pval;
};
class Point3fValue : public Value
{
public:
Point3fValue(const Point3m& val) : pval(val) {}
~Point3fValue() {}
inline Point3m getPoint3f() const { return pval; }
inline bool isPoint3f() const { return true; }
inline QString typeName() const { return QString("Point3f"); }
inline void set(const Value& p) { pval = p.getPoint3f(); }
inline Point3fValue* clone() const {return new Point3fValue(*this);}
void fillToXMLElement(QDomElement& element) const;
private:
Point3m pval;
};
class ShotfValue : public Value
{
public:
ShotfValue(const Shotm& val) : pval(val) {}
~ShotfValue() {}
inline Shotm getShotf() const { return pval; }
inline bool isShotf() const { return true; }
inline QString typeName() const { return QString("Shotf"); }
inline void set(const Value& p) { pval = p.getShotf(); }
inline ShotfValue* clone() const {return new ShotfValue(*this);}
void fillToXMLElement(QDomElement& element) const;
private:
Shotm pval;
};
class ColorValue : public Value
{
public:
ColorValue(QColor val) :pval(val) {}
~ColorValue() {}
inline QColor getColor() const { return pval; }
inline bool isColor() const { return true; }
inline QString typeName() const { return QString("Color"); }
inline void set(const Value& p) { pval = p.getColor(); }
inline ColorValue* clone() const {return new ColorValue(*this);}
void fillToXMLElement(QDomElement& element) const;
private:
QColor pval;
};
#endif //MESHLAB_VALUE_H

View File

@ -0,0 +1,69 @@
/*****************************************************************************
* MeshLab o o *
* A versatile mesh processing toolbox o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 "bool_value.h"
#include <QDomElement>
BoolValue::BoolValue(const bool val) : pval(val)
{
}
bool BoolValue::getBool() const
{
return pval;
}
bool BoolValue::isBool() const
{
return true;
}
QString BoolValue::typeName() const
{
return QString("Bool");
}
void BoolValue::set(const Value &p)
{
pval = p.getBool();
}
BoolValue *BoolValue::clone() const
{
return new BoolValue(*this);
}
bool BoolValue::operator==(const Value &p) const
{
if (p.isBool())
return pval == p.getBool();
else
return false;
}
void BoolValue::fillToXMLElement(QDomElement& element) const
{
QString v = pval ? "true" : "false";
element.setAttribute("value", v);
}

View File

@ -0,0 +1,47 @@
/*****************************************************************************
* MeshLab o o *
* A versatile mesh processing toolbox o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 MESHLAB_BOOL_VALUE_H
#define MESHLAB_BOOL_VALUE_H
#include "value.h"
class BoolValue : public Value
{
public:
BoolValue(const bool val);
~BoolValue() {}
bool getBool() const;
bool isBool() const;
QString typeName() const;
void set(const Value& p);
BoolValue* clone() const;
bool operator==(const Value& p) const;
void fillToXMLElement(QDomElement& element) const;
private:
bool pval;
};
#endif // MESHLAB_BOOL_VALUE_H

View File

@ -0,0 +1,71 @@
/*****************************************************************************
* MeshLab o o *
* A versatile mesh processing toolbox o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 "color_value.h"
#include <QDomElement>
ColorValue::ColorValue(QColor val) : pval(val)
{
}
QColor ColorValue::getColor() const
{
return pval;
}
bool ColorValue::isColor() const
{
return true;
}
QString ColorValue::typeName() const
{
return QString("Color");
}
void ColorValue::set(const Value& p)
{
pval = p.getColor();
}
ColorValue* ColorValue::clone() const
{
return new ColorValue(*this);
}
bool ColorValue::operator==(const Value& p) const
{
if (p.isColor())
return pval == p.getColor();
else
return false;
}
void ColorValue::fillToXMLElement(QDomElement& element) const
{
element.setAttribute("r", QString::number(pval.red()));
element.setAttribute("g", QString::number(pval.green()));
element.setAttribute("b", QString::number(pval.blue()));
element.setAttribute("a", QString::number(pval.alpha()));
}

View File

@ -0,0 +1,47 @@
/*****************************************************************************
* MeshLab o o *
* A versatile mesh processing toolbox o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 MESHLAB_COLOR_VALUE_H
#define MESHLAB_COLOR_VALUE_H
#include "value.h"
class ColorValue : public Value
{
public:
ColorValue(QColor val);
~ColorValue() {}
QColor getColor() const;
bool isColor() const;
QString typeName() const;
void set(const Value& p);
ColorValue* clone() const;
bool operator==(const Value& p) const;
void fillToXMLElement(QDomElement& element) const;
private:
QColor pval;
};
#endif // MESHLAB_COLOR_VALUE_H

View File

@ -0,0 +1,68 @@
/*****************************************************************************
* MeshLab o o *
* A versatile mesh processing toolbox o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 "float_value.h"
#include <QDomElement>
FloatValue::FloatValue(const float val) : pval(val)
{
}
Scalarm FloatValue::getFloat() const
{
return pval;
}
bool FloatValue::isFloat() const
{
return true;
}
QString FloatValue::typeName() const
{
return QString("Float");
}
void FloatValue::set(const Value& p)
{
pval = p.getFloat();
}
FloatValue* FloatValue::clone() const
{
return new FloatValue(*this);
}
bool FloatValue::operator==(const Value& p) const
{
if (p.isFloat())
return pval == p.getFloat();
else
return false;
}
void FloatValue::fillToXMLElement(QDomElement& element) const
{
element.setAttribute("value", QString::number(pval));
}

View File

@ -0,0 +1,47 @@
/*****************************************************************************
* MeshLab o o *
* A versatile mesh processing toolbox o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 MESHLAB_FLOAT_VALUE_H
#define MESHLAB_FLOAT_VALUE_H
#include "value.h"
class FloatValue : public Value
{
public:
FloatValue(const float val);
~FloatValue() {}
Scalarm getFloat() const;
bool isFloat() const;
QString typeName() const;
void set(const Value& p);
FloatValue* clone() const;
bool operator==(const Value& p) const;
void fillToXMLElement(QDomElement& element) const;
private:
Scalarm pval;
};
#endif // MESHLAB_FLOAT_VALUE_H

View File

@ -0,0 +1,63 @@
/*****************************************************************************
* MeshLab o o *
* A versatile mesh processing toolbox o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 "int_value.h"
#include <QDomElement>
IntValue::IntValue(const int val) : pval(val)
{
}
int IntValue::getInt() const
{
return pval;
}
QString IntValue::typeName() const
{
return QString("Int");
}
void IntValue::set(const Value& p)
{
pval = p.getInt();
}
IntValue* IntValue::clone() const
{
return new IntValue(*this);
}
bool IntValue::operator==(const Value& p) const
{
if (p.isInt())
return pval == p.getInt();
else
return false;
}
void IntValue::fillToXMLElement(QDomElement& element) const
{
element.setAttribute("value", QString::number(pval));
}

View File

@ -0,0 +1,47 @@
/*****************************************************************************
* MeshLab o o *
* A versatile mesh processing toolbox o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 MESHLAB_INT_VALUE_H
#define MESHLAB_INT_VALUE_H
#include "value.h"
class IntValue : public Value
{
public:
IntValue(const int val);
~IntValue() {}
int getInt() const;
inline bool isInt() const { return true; }
QString typeName() const;
void set(const Value& p);
IntValue* clone() const;
bool operator==(const Value& p) const;
void fillToXMLElement(QDomElement& element) const;
private:
int pval;
};
#endif // MESHLAB_INT_VALUE_H

View File

@ -0,0 +1,69 @@
/*****************************************************************************
* MeshLab o o *
* A versatile mesh processing toolbox o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 "matrix44_value.h"
#include <QDomElement>
Matrix44Value::Matrix44Value(const Matrix44m& val) : pval(val)
{
}
Matrix44m Matrix44Value::getMatrix44() const
{
return pval;
}
bool Matrix44Value::isMatrix44() const
{
return true;
}
QString Matrix44Value::typeName() const
{
return QString("Matrix44");
}
void Matrix44Value::set(const Value& p)
{
pval = p.getMatrix44();
}
Matrix44Value* Matrix44Value::clone() const
{
return new Matrix44Value(*this);
}
bool Matrix44Value::operator==(const Value& p) const
{
if (p.isMatrix44())
return pval == p.getMatrix44();
else
return false;
}
void Matrix44Value::fillToXMLElement(QDomElement& element) const
{
for (unsigned int ii = 0; ii < 16; ++ii)
element.setAttribute(QString("val") + QString::number(ii), QString::number(pval.V()[ii]));
}

View File

@ -0,0 +1,47 @@
/*****************************************************************************
* MeshLab o o *
* A versatile mesh processing toolbox o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 MESHLAB_MATRIX44_VALUE_H
#define MESHLAB_MATRIX44_VALUE_H
#include "value.h"
class Matrix44Value : public Value
{
public:
Matrix44Value(const Matrix44m& val);
~Matrix44Value() {}
Matrix44m getMatrix44() const;
bool isMatrix44() const;
QString typeName() const;
void set(const Value& p);
Matrix44Value* clone() const;
bool operator==(const Value& p) const;
void fillToXMLElement(QDomElement& element) const;
private:
Matrix44m pval;
};
#endif // MESHLAB_MATRIX44_VALUE_H

View File

@ -0,0 +1,70 @@
/*****************************************************************************
* MeshLab o o *
* A versatile mesh processing toolbox o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 "point3_value.h"
#include <QDomElement>
Point3Value::Point3Value(const Point3m& val) : pval(val)
{
}
Point3m Point3Value::getPoint3() const
{
return pval;
}
bool Point3Value::isPoint3() const
{
return true;
}
QString Point3Value::typeName() const
{
return QString("Point3");
}
void Point3Value::set(const Value& p)
{
pval = p.getPoint3();
}
Point3Value* Point3Value::clone() const
{
return new Point3Value(*this);
}
bool Point3Value::operator==(const Value& p) const
{
if (p.isPoint3())
return pval == p.getPoint3();
else
return false;
}
void Point3Value::fillToXMLElement(QDomElement& element) const
{
element.setAttribute("x", QString::number(pval.X()));
element.setAttribute("y", QString::number(pval.Y()));
element.setAttribute("z", QString::number(pval.Z()));
}

View File

@ -0,0 +1,47 @@
/*****************************************************************************
* MeshLab o o *
* A versatile mesh processing toolbox o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 MESHLAB_POINT3_VALUE_H
#define MESHLAB_POINT3_VALUE_H
#include "value.h"
class Point3Value : public Value
{
public:
Point3Value(const Point3m& val);
~Point3Value() {}
Point3m getPoint3() const;
bool isPoint3() const;
QString typeName() const;
void set(const Value& p);
Point3Value* clone() const;
bool operator==(const Value& p) const;
void fillToXMLElement(QDomElement& element) const;
private:
Point3m pval;
};
#endif // MESHLAB_POINT3_VALUE_H

View File

@ -0,0 +1,69 @@
/*****************************************************************************
* MeshLab o o *
* A versatile mesh processing toolbox o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 "shot_value.h"
#include <QDomElement>
ShotValue::ShotValue(const Shotm& val) : pval(val)
{
}
Shotm ShotValue::getShot() const
{
return pval;
}
bool ShotValue::isShot() const
{
return true;
}
QString ShotValue::typeName() const
{
return QString("Shot");
}
void ShotValue::set(const Value& p)
{
pval = p.getShot();
}
ShotValue* ShotValue::clone() const
{
return new ShotValue(*this);
}
bool ShotValue::operator==(const Value& p) const
{
if (p.isShot())
return pval == p.getShot();
else
return false;
}
void ShotValue::fillToXMLElement(QDomElement&) const
{
assert(0);
// TODO!!!
}

View File

@ -0,0 +1,47 @@
/*****************************************************************************
* MeshLab o o *
* A versatile mesh processing toolbox o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 MESHLAB_SHOT_VALUE_H
#define MESHLAB_SHOT_VALUE_H
#include "value.h"
class ShotValue : public Value
{
public:
ShotValue(const Shotm& val);
~ShotValue() {}
Shotm getShot() const;
bool isShot() const;
QString typeName() const;
void set(const Value& p);
ShotValue* clone() const;
bool operator==(const Value& p) const;
void fillToXMLElement(QDomElement& element) const;
private:
Shotm pval;
};
#endif // MESHLAB_SHOT_VALUE_H

View File

@ -0,0 +1,68 @@
/*****************************************************************************
* MeshLab o o *
* A versatile mesh processing toolbox o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 "string_value.h"
#include <QDomElement>
StringValue::StringValue(const QString& val) : pval(val)
{
}
QString StringValue::getString() const
{
return pval;
}
bool StringValue::isString() const
{
return true;
}
QString StringValue::typeName() const
{
return QString("String");
}
void StringValue::set(const Value& p)
{
pval = p.getString();
}
StringValue* StringValue::clone() const
{
return new StringValue(*this);
}
bool StringValue::operator==(const Value& p) const
{
if (p.isString())
return pval == p.getString();
else
return false;
}
void StringValue::fillToXMLElement(QDomElement& element) const
{
element.setAttribute("value", pval);
}

View File

@ -0,0 +1,47 @@
/*****************************************************************************
* MeshLab o o *
* A versatile mesh processing toolbox o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 MESHLAB_STRING_VALUE_H
#define MESHLAB_STRING_VALUE_H
#include "value.h"
class StringValue : public Value
{
public:
StringValue(const QString& val);
~StringValue() {}
QString getString() const;
bool isString() const;
QString typeName() const;
void set(const Value& p);
StringValue* clone() const;
bool operator==(const Value& p) const;
void fillToXMLElement(QDomElement& element) const;
private:
QString pval;
};
#endif // MESHLAB_STRING_VALUE_H

View File

@ -0,0 +1,110 @@
/*****************************************************************************
* MeshLab o o *
* A versatile mesh processing toolbox o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 MESHLAB_VALUE_H
#define MESHLAB_VALUE_H
#include "../../ml_document/cmesh.h"
#include <QColor>
#include <QString>
class MeshModel;
class MeshDocument;
class QDomElement;
/**
* @brief The Value class
*
* Represents a generic parameter value for meshlab.
* Specializations inherit from this class, depending on the type of the
* value. Value class is an attribute of the RichParameter class.
*/
class Value
{
public:
virtual ~Value() {}
virtual bool getBool() const
{
assert(0);
return bool();
}
virtual int getInt() const
{
assert(0);
return int();
}
virtual Scalarm getFloat() const
{
assert(0);
return Scalarm();
}
virtual QString getString() const
{
assert(0);
return QString();
}
virtual Matrix44m getMatrix44() const
{
assert(0);
return Matrix44m();
}
virtual Point3m getPoint3() const
{
assert(0);
return Point3m();
}
virtual Shotm getShot() const
{
assert(0);
return Shotm();
}
virtual QColor getColor() const
{
assert(0);
return QColor();
}
virtual bool isBool() const { return false; }
virtual bool isInt() const { return false; }
virtual bool isFloat() const { return false; }
virtual bool isString() const { return false; }
virtual bool isMatrix44() const { return false; }
virtual bool isPoint3() const { return false; }
virtual bool isShot() const { return false; }
virtual bool isColor() const { return false; }
virtual QString typeName() const = 0;
virtual void set(const Value& p) = 0;
virtual Value* clone() const = 0;
virtual bool operator==(const Value& p) const = 0;
virtual void fillToXMLElement(QDomElement& element) const = 0;
template <class Val>
bool isOfType() const
{
const Val* t = dynamic_cast<const Val*>(this);
return (t != nullptr);
}
};
#endif //MESHLAB_VALUE_H

View File

@ -0,0 +1,36 @@
/*****************************************************************************
* MeshLab o o *
* A versatile mesh processing toolbox o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 MESHLAB_VALUES_H
#define MESHLAB_VALUES_H
#include "value/bool_value.h"
#include "value/color_value.h"
#include "value/float_value.h"
#include "value/int_value.h"
#include "value/matrix44_value.h"
#include "value/point3_value.h"
#include "value/shot_value.h"
#include "value/string_value.h"
#endif // MESHLAB_VALUES_H

View File

@ -23,7 +23,7 @@
#include "function.h"
#include <QStringList>
#include "../parameters/rich_parameter.h"
#include <common/parameters/rich_parameters.h>
pymeshlab::Function::Function()
{

View File

@ -120,8 +120,8 @@ void pymeshlab::FunctionParameter::printDefaultValue(std::ostream& o) const
o << "'" << ren->enumvalues.at(ren->value().getInt()).toStdString() << "'";
return;
}
if (parameter->isOfType<RichAbsPerc>()) {
RichAbsPerc* rabs = dynamic_cast<RichAbsPerc*>(parameter);
if (parameter->isOfType<RichPercentage>()) {
RichPercentage* rabs = dynamic_cast<RichPercentage*>(parameter);
float abs = parameter->value().getFloat();
float perc = (abs - rabs->min) / (rabs->max - rabs->min) * 100;
o << perc << "%";
@ -133,8 +133,8 @@ void pymeshlab::FunctionParameter::printDefaultValue(std::ostream& o) const
" [min: " << rdyn->min << "; max: " << rdyn->max << "]";
return;
}
if (parameter->isOfType<RichMatrix44f>()){
const MESHLAB_SCALAR* v = parameter->value().getMatrix44f().V();
if (parameter->isOfType<RichMatrix44>()){
const MESHLAB_SCALAR* v = parameter->value().getMatrix44().V();
o << "[[" << v[0] << ", " << v[1] << ", " << v[2] << ", " << v[3] << "],"
<< "[" << v[4] << ", " << v[5] << ", " << v[6] << ", " << v[7] << "],"
<< "[" << v[8] << ", " << v[9] << ", " << v[10] << ", " << v[11] << "],"
@ -142,12 +142,12 @@ void pymeshlab::FunctionParameter::printDefaultValue(std::ostream& o) const
return;
}
if (parameter->isOfType<RichPosition>() || parameter->isOfType<RichDirection>()) {
o << "[" << parameter->value().getPoint3f().X() << ", "
<< parameter->value().getPoint3f().Y() << ", "
<< parameter->value().getPoint3f().Z() << "]";
o << "[" << parameter->value().getPoint3().X() << ", "
<< parameter->value().getPoint3().Y() << ", "
<< parameter->value().getPoint3().Z() << "]";
return;
}
if (parameter->isOfType<RichShotf>()) {
if (parameter->isOfType<RichShot>()) {
o << "None";
return;
}
@ -165,7 +165,7 @@ void pymeshlab::FunctionParameter::printDefaultValue(std::ostream& o) const
o << rm->value().getInt();
return;
}
if (parameter->isOfType<RichSaveFile>() || parameter->isOfType<RichOpenFile>()){
if (parameter->isOfType<RichFileSave>() || parameter->isOfType<RichFileOpen>()){
o << "'" << parameter->value().getString().toStdString() << "'";
return;
}

View File

@ -62,14 +62,6 @@ void pymeshlab::FunctionSet::loadFilterPlugin(FilterPlugin* fp)
f.addParameter(par);
}
filterSet.insert(f);
// Just for actual PyMeshLab version; this portion of code will be removed soon
QString oldPythonFilterName = computePythonName(fp->filterName(act));
f.setPythonFunctionName(oldPythonFilterName);
f.setDeprecated("You should use '" + pythonFilterName.toStdString() +
"' instead of '" + oldPythonFilterName.toStdString() + "'. See "
"https://pymeshlab.readthedocs.io/en/latest/index.html#filters-renaming");
filterSet.insert(f);
}
}
@ -85,7 +77,7 @@ void pymeshlab::FunctionSet::loadIOPlugin(IOPlugin* iop)
//filename parameter
QString sv = "file_name." + inputFormat;
QStringList sl(inputFormat);
RichOpenFile of("file_name", sv, sl, "File Name", "The name of the file to load");
RichFileOpen of("file_name", sv, sl, "File Name", "The name of the file to load");
FunctionParameter par(of);
f.addParameter(par);
@ -125,7 +117,7 @@ void pymeshlab::FunctionSet::loadIOPlugin(IOPlugin* iop)
}
//filename parameter
QString sv = "file_name." + outputFormat;
RichSaveFile of("file_name", sv, outputFormat, "File Name", "The name of the file to save");
RichFileSave of("file_name", sv, outputFormat, "File Name", "The name of the file to save");
FunctionParameter par(of);
f.addParameter(par);
@ -150,7 +142,7 @@ void pymeshlab::FunctionSet::loadIOPlugin(IOPlugin* iop)
//filename parameter
QString sv = "file_name." + inputImageFormat;
QStringList sl(inputImageFormat);
RichOpenFile of("file_name", sv, sl, "File Name", "The name of the file to load");
RichFileOpen of("file_name", sv, sl, "File Name", "The name of the file to load");
FunctionParameter par(of);
f.addParameter(par);

View File

@ -24,13 +24,14 @@
#include "python_utils.h"
#include <QRegularExpression>
#include "../parameters/rich_parameter.h"
#include <common/parameters/rich_parameters.h>
QString pymeshlab::computePythonTypeString(const RichParameter& par)
{
if (par.isOfType<RichEnum>())
return PYTHON_TYPE_ENUM;
if (par.isOfType<RichAbsPerc>())
if (par.isOfType<RichPercentage>())
return PYTHON_TYPE_ABSPERC;
if (par.isOfType<RichDynamicFloat>())
return PYTHON_TYPE_DYNAMIC_FLOAT;
@ -42,30 +43,31 @@ QString pymeshlab::computePythonTypeString(const RichParameter& par)
return PYTHON_TYPE_FLOAT;
if (par.isOfType<RichString>())
return PYTHON_TYPE_STRING;
if (par.isOfType<RichMatrix44f>())
if (par.isOfType<RichMatrix44>())
return PYTHON_TYPE_MATRIX44F;
if (par.isOfType<RichPosition>())
return PYTHON_TYPE_POINT3F;
if (par.isOfType<RichDirection>())
return PYTHON_TYPE_POINT3F;
if (par.isOfType<RichShotf>())
if (par.isOfType<RichShot>())
return PYTHON_TYPE_SHOTF;
if (par.isOfType<RichColor>())
return PYTHON_TYPE_COLOR;
if (par.isOfType<RichMesh>())
return PYTHON_TYPE_MESH;
if (par.isOfType<RichSaveFile>() || par.isOfType<RichOpenFile>())
if (par.isOfType<RichFileSave>() || par.isOfType<RichFileOpen>())
return PYTHON_TYPE_FILENAME;
return "still_unsupported";
}
QString pymeshlab::computePythonName(const QString& name)
{
static const QRegularExpression rgexp("[().,'\":+]+");
QString pythonName = name.toLower();
pythonName.replace(' ', '_');
pythonName.replace('/', '_');
pythonName.replace('-', '_');
pythonName.remove(QRegularExpression("[().,'\":+]+"));
pythonName.remove(rgexp);
if (pythonKeywords.contains(pythonName))
pythonName += "_";

View File

@ -74,18 +74,20 @@ class PolyMesh :
* The only matrix required to be non-empty is the 'vertices' matrix.
* Other matrices may be empty.
*
* If normals and quality matrices are give, their sizes must be coherent with
* If normals and quality matrices are given, their sizes must be coherent with
* the sizes of vertex and face matrices. If this requirement is not satisfied,
* a MLException will be thrown.
*
* @param vertices: #V*3 matrix of scalars (vertex coordinates)
* @param faces: #F*3 matrix of integers (vertex indices composing the faces)
* @param vertexNormals: #V*3 matrix of scalars (vertex normals)
* @param faceNormals: #F*3 matrix of scalars (face normals)
* @param vertices: #V×3 matrix of scalars (vertex coordinates)
* @param faces: #F×3 matrix of integers (vertex indices composing the faces)
* @param vertexNormals: #V×3 matrix of scalars (vertex normals)
* @param faceNormals: #F×3 matrix of scalars (face normals)
* @param vertexQuality: #V vector of scalars (vertex quality)
* @param faceQuality: #F vector of scalars (face quality)
* @param vertexColor: #V*4 vector of scalars (RGBA vertex colors in interval [0-1])
* @param faceColor: #F*4 vector of scalars (RGBA face colors in interval [0-1])
* @param vertexTexCoords: #V×2 matrix of scalars (vertex texture coordinates)
* @param wedgeTexCoords: #F*3×2 matrix scalars (texture coordinates for each face edge)
* @return a CMeshO made of the given components
*/
CMeshO meshlab::meshFromMatrices(
@ -97,16 +99,19 @@ CMeshO meshlab::meshFromMatrices(
const EigenVectorXm& vertexQuality,
const EigenVectorXm& faceQuality,
const EigenMatrixX4m& vertexColor,
const EigenMatrixX4m& faceColor)
const EigenMatrixX4m& faceColor,
const EigenMatrixX2m& vertexTexCoords,
const EigenMatrixX2m& wedgeTexCoords)
{
CMeshO m;
if (vertices.rows() > 0) {
// add vertices and their associated normals and quality if any
std::vector<CMeshO::VertexPointer> ivp(vertices.rows());
bool hasVNormals = vertexNormals.rows() > 0;
bool hasVQuality = vertexQuality.rows() > 0;
bool hasVColors = vertexColor.rows() > 0;
bool hasVNormals = vertexNormals.rows() > 0;
bool hasVQuality = vertexQuality.rows() > 0;
bool hasVColors = vertexColor.rows() > 0;
bool hasVTexCoords = vertexTexCoords.rows() > 0;
if (hasVNormals && (vertices.rows() != vertexNormals.rows())) {
throw MLException(
"Error while creating mesh: the number of vertex normals "
@ -122,6 +127,14 @@ CMeshO meshlab::meshFromMatrices(
"Error while creating mesh: the number of vertex colors "
"is different from the number of vertices.");
}
if (hasVTexCoords) {
if ((vertices.rows() != vertexTexCoords.rows())) {
throw MLException(
"Error while creating mesh: the number of vertex texture coordinates "
"is different from the number of vertices.");
}
m.vert.EnableTexCoord();
}
CMeshO::VertexIterator vi = vcg::tri::Allocator<CMeshO>::AddVertices(m, vertices.rows());
for (unsigned int i = 0; i < vertices.rows(); ++i, ++vi) {
ivp[i] = &*vi;
@ -134,19 +147,25 @@ CMeshO meshlab::meshFromMatrices(
vi->Q() = vertexQuality(i);
}
if (hasVColors) {
vi->C() = CMeshO::VertexType::ColorType(
vi->C().Construct(CMeshO::VertexType::ColorType(
vertexColor(i, 0) * 255,
vertexColor(i, 1) * 255,
vertexColor(i, 2) * 255,
vertexColor(i, 3) * 255);
vertexColor(i, 3) * 255));
}
if (hasVTexCoords) {
vi->T() = CMeshO::VertexType::TexCoordType(
vertexTexCoords(i, 0),
vertexTexCoords(i, 1));
}
}
// add faces and their associated normals and quality if any
bool hasFNormals = faceNormals.rows() > 0;
bool hasFQuality = faceQuality.rows() > 0;
bool hasFColors = faceColor.rows() > 0;
bool hasFNormals = faceNormals.rows() > 0;
bool hasFQuality = faceQuality.rows() > 0;
bool hasFColors = faceColor.rows() > 0;
bool hasFWedgeTexCoords = wedgeTexCoords.rows() > 0;
if (hasFNormals && (faces.rows() != faceNormals.rows())) {
throw MLException(
"Error while creating mesh: the number of face normals "
@ -168,6 +187,15 @@ CMeshO meshlab::meshFromMatrices(
}
m.face.EnableColor();
}
if (hasFWedgeTexCoords) {
if (faces.rows() * 3 != wedgeTexCoords.rows()) {
throw MLException(
"Error while creating mesh: the number of wedge texture coords "
"is different from three times the number of faces (a texture coordinate for "
"each edge of a face.");
}
m.face.EnableWedgeTexCoord();
}
CMeshO::FaceIterator fi = vcg::tri::Allocator<CMeshO>::AddFaces(m, faces.rows());
for (unsigned int i = 0; i < faces.rows(); ++i, ++fi) {
for (unsigned int j = 0; j < 3; j++) {
@ -190,11 +218,17 @@ CMeshO meshlab::meshFromMatrices(
fi->Q() = faceQuality(i);
}
if (hasFColors) {
fi->C() = CMeshO::FaceType::ColorType(
fi->C().Construct(CMeshO::FaceType::ColorType(
faceColor(i, 0) * 255,
faceColor(i, 1) * 255,
faceColor(i, 2) * 255,
faceColor(i, 3) * 255);
faceColor(i, 3) * 255));
}
if (hasFWedgeTexCoords) {
for (uint j = 0; j < 3; j++) {
fi->WT(j).U() = wedgeTexCoords(i*3 + j, 0);
fi->WT(j).V() = wedgeTexCoords(i*3 + j, 1);
}
}
}
@ -241,14 +275,15 @@ CMeshO meshlab::meshFromMatrices(
* called 'poly_birth_faces', which stores for each triangle of the mesh, the id
* of its polygonal birth face of the polygon mesh given in input.
*
* @param vertices: #V*3 matrix of scalars (vertex coordinates)
* @param vertices: #V×3 matrix of scalars (vertex coordinates)
* @param faces: #F list of vector of integers (vertex indices composing the faces)
* @param vertexNormals: #V*3 matrix of scalars (vertex normals)
* @param faceNormals: #F*3 matrix of scalars (face normals)
* @param vertexNormals: #V×3 matrix of scalars (vertex normals)
* @param faceNormals: #F×3 matrix of scalars (face normals)
* @param vertexQuality: #V vector of scalars (vertex quality)
* @param faceQuality: #F vector of scalars (face quality)
* @param vertexColor: #V*4 vector of scalars (RGBA vertex colors in interval [0-1])
* @param faceColor: #F*4 vector of scalars (RGBA face colors in interval [0-1])
* @param vertexTexCoords: #V×2 matrix of scalars (vertex texture coordinates)
* @return a CMeshO made of the given components
*/
CMeshO meshlab::polyMeshFromMatrices(
@ -259,7 +294,8 @@ CMeshO meshlab::polyMeshFromMatrices(
const EigenVectorXm& vertexQuality,
const EigenVectorXm& faceQuality,
const EigenMatrixX4m& vertexColor,
const EigenMatrixX4m& faceColor)
const EigenMatrixX4m& faceColor,
const EigenMatrixX2m& vertexTexCoords)
{
PolyMesh pm;
CMeshO m;
@ -267,9 +303,10 @@ CMeshO meshlab::polyMeshFromMatrices(
// add vertices and their associated normals and quality if any
std::vector<PolyMesh::VertexPointer> ivp(vertices.rows());
bool hasVNormals = vertexNormals.rows() > 0;
bool hasVQuality = vertexQuality.rows() > 0;
bool hasVColors = vertexColor.rows() > 0;
bool hasVNormals = vertexNormals.rows() > 0;
bool hasVQuality = vertexQuality.rows() > 0;
bool hasVColors = vertexColor.rows() > 0;
bool hasVTexCoords = vertexTexCoords.rows() > 0;
if (hasVNormals && (vertices.rows() != vertexNormals.rows())) {
throw MLException(
"Error while creating mesh: the number of vertex normals "
@ -285,6 +322,14 @@ CMeshO meshlab::polyMeshFromMatrices(
"Error while creating mesh: the number of vertex colors "
"is different from the number of vertices.");
}
if (hasVTexCoords) {
if ((vertices.rows() != vertexTexCoords.rows())) {
throw MLException(
"Error while creating mesh: the number of vertex texture coordinates "
"is different from the number of vertices.");
}
m.vert.EnableTexCoord();
}
PolyMesh::VertexIterator vi =
vcg::tri::Allocator<PolyMesh>::AddVertices(pm, vertices.rows());
for (unsigned int i = 0; i < vertices.rows(); ++i, ++vi) {
@ -298,11 +343,16 @@ CMeshO meshlab::polyMeshFromMatrices(
vi->Q() = vertexQuality(i);
}
if (hasVColors) {
vi->C() = CMeshO::VertexType::ColorType(
vi->C().Construct(CMeshO::VertexType::ColorType(
vertexColor(i, 0) * 255,
vertexColor(i, 1) * 255,
vertexColor(i, 2) * 255,
vertexColor(i, 3) * 255);
vertexColor(i, 3) * 255));
}
if (hasVTexCoords) {
vi->T() = CMeshO::VertexType::TexCoordType(
vertexTexCoords(i, 0),
vertexTexCoords(i, 1));
}
}
@ -353,11 +403,11 @@ CMeshO meshlab::polyMeshFromMatrices(
fi->Q() = faceQuality(i);
}
if (hasFColors) {
fi->C() = CMeshO::FaceType::ColorType(
fi->C().Construct(CMeshO::FaceType::ColorType(
faceColor(i, 0) * 255,
faceColor(i, 1) * 255,
faceColor(i, 2) * 255,
faceColor(i, 3) * 255);
faceColor(i, 3) * 255));
}
}

View File

@ -43,25 +43,28 @@ namespace meshlab {
// From eigen to CMeshO
CMeshO meshFromMatrices(
const EigenMatrixX3m& vertices,
const Eigen::MatrixX3i& faces = Eigen::MatrixX3i(),
const Eigen::MatrixX2i& edges = Eigen::MatrixX2i(),
const EigenMatrixX3m& vertexNormals = EigenMatrixX3m(),
const EigenMatrixX3m& faceNormals = EigenMatrixX3m(),
const EigenVectorXm& vertexQuality = EigenVectorXm(),
const EigenVectorXm& faceQuality = EigenVectorXm(),
const EigenMatrixX4m& vertexColor = EigenMatrixX4m(),
const EigenMatrixX4m& faceColor = EigenMatrixX4m());
const Eigen::MatrixX3i& faces = Eigen::MatrixX3i(),
const Eigen::MatrixX2i& edges = Eigen::MatrixX2i(),
const EigenMatrixX3m& vertexNormals = EigenMatrixX3m(),
const EigenMatrixX3m& faceNormals = EigenMatrixX3m(),
const EigenVectorXm& vertexQuality = EigenVectorXm(),
const EigenVectorXm& faceQuality = EigenVectorXm(),
const EigenMatrixX4m& vertexColor = EigenMatrixX4m(),
const EigenMatrixX4m& faceColor = EigenMatrixX4m(),
const EigenMatrixX2m& vertexTexCoords = EigenMatrixX2m(),
const EigenMatrixX2m& wedgeTexCoords = EigenMatrixX2m());
// From eigen to polygonal CMeshO
CMeshO polyMeshFromMatrices(
const EigenMatrixX3m& vertices,
const std::list<EigenVectorXui>& faces,
const EigenMatrixX3m& vertexNormals = EigenMatrixX3m(),
const EigenMatrixX3m& faceNormals = EigenMatrixX3m(),
const EigenVectorXm& vertexQuality = EigenVectorXm(),
const EigenVectorXm& faceQuality = EigenVectorXm(),
const EigenMatrixX4m& vertexColor = EigenMatrixX4m(),
const EigenMatrixX4m& faceColor = EigenMatrixX4m());
const EigenMatrixX3m& vertexNormals = EigenMatrixX3m(),
const EigenMatrixX3m& faceNormals = EigenMatrixX3m(),
const EigenVectorXm& vertexQuality = EigenVectorXm(),
const EigenVectorXm& faceQuality = EigenVectorXm(),
const EigenMatrixX4m& vertexColor = EigenMatrixX4m(),
const EigenMatrixX4m& faceColor = EigenMatrixX4m(),
const EigenMatrixX2m& vertexTexCoords = EigenMatrixX2m());
void addVertexScalarAttribute(
CMeshO& mesh,

View File

@ -0,0 +1,85 @@
set(HEADERS
gui_utils/clickable_label.h
gui_utils/vertical_scroll_area.h
rich_parameter/widgets/bool_widget.h
rich_parameter/widgets/color_widget.h
rich_parameter/widgets/combo_widget.h
rich_parameter/widgets/direction_widget.h
rich_parameter/widgets/dynamic_float_widget.h
rich_parameter/widgets/enum_widget.h
rich_parameter/widgets/float_widget.h
rich_parameter/widgets/int_widget.h
rich_parameter/widgets/io_file_widget.h
rich_parameter/widgets/line_edit_widget.h
rich_parameter/widgets/matrix44_widget.h
rich_parameter/widgets/mesh_widget.h
rich_parameter/widgets/open_file_widget.h
rich_parameter/widgets/percentage_widget.h
rich_parameter/widgets/point3_widget.h
rich_parameter/widgets/position_widget.h
rich_parameter/widgets/rich_parameter_widget.h
rich_parameter/widgets/rich_parameter_widgets.h
rich_parameter/widgets/save_file_widget.h
rich_parameter/widgets/shot_widget.h
rich_parameter/widgets/string_widget.h
rich_parameter/richparameterlistdialog.h
rich_parameter/rich_parameter_list_frame.h
)
set(SOURCES
gui_utils/clickable_label.cpp
gui_utils/vertical_scroll_area.cpp
rich_parameter/widgets/bool_widget.cpp
rich_parameter/widgets/color_widget.cpp
rich_parameter/widgets/combo_widget.cpp
rich_parameter/widgets/direction_widget.cpp
rich_parameter/widgets/dynamic_float_widget.cpp
rich_parameter/widgets/enum_widget.cpp
rich_parameter/widgets/float_widget.cpp
rich_parameter/widgets/int_widget.cpp
rich_parameter/widgets/io_file_widget.cpp
rich_parameter/widgets/line_edit_widget.cpp
rich_parameter/widgets/matrix44_widget.cpp
rich_parameter/widgets/mesh_widget.cpp
rich_parameter/widgets/open_file_widget.cpp
rich_parameter/widgets/percentage_widget.cpp
rich_parameter/widgets/point3_widget.cpp
rich_parameter/widgets/position_widget.cpp
rich_parameter/widgets/rich_parameter_widget.cpp
rich_parameter/widgets/save_file_widget.cpp
rich_parameter/widgets/shot_widget.cpp
rich_parameter/widgets/string_widget.cpp
rich_parameter/richparameterlistdialog.cpp
rich_parameter/rich_parameter_list_frame.cpp
)
set(RESOURCES )
set(TARGET_TYPE SHARED)
add_library(meshlab-common-gui ${TARGET_TYPE} ${SOURCES} ${HEADERS} ${RESOURCES})
target_link_libraries(
meshlab-common-gui
PUBLIC
meshlab-common
)
set_property(TARGET meshlab-common-gui PROPERTY FOLDER Core)
set_property(TARGET meshlab-common-gui
PROPERTY RUNTIME_OUTPUT_DIRECTORY ${MESHLAB_LIB_OUTPUT_DIR})
set_property(TARGET meshlab-common-gui
PROPERTY LIBRARY_OUTPUT_DIRECTORY ${MESHLAB_LIB_OUTPUT_DIR})
set_target_properties(meshlab-common-gui PROPERTIES
INSTALL_RPATH "${MESHLAB_LIB_INSTALL_DIR}:${INSTALL_RPATH}")
set_target_properties(meshlab-common-gui PROPERTIES
INSTALL_RPATH "$ORIGIN")
install(TARGETS meshlab-common-gui DESTINATION ${MESHLAB_LIB_INSTALL_DIR})

View File

@ -1,8 +1,8 @@
/*****************************************************************************
* VCGLib o o *
* MeshLab o o *
* Visual and Computer Graphics Library o o *
* _ O _ *
* Copyright(C) 2004-2021 \/)\/ *
* Copyright(C) 2004-2022 \/)\/ *
* Visual Computing Lab /\/| *
* ISTI - Italian National Research Council | *
* \ *
@ -21,7 +21,7 @@
* *
****************************************************************************/
#include "richparameterlistframe.h"
#include "rich_parameter_list_frame.h"
#include <QClipboard>
#include <QColorDialog>
@ -40,32 +40,36 @@ RichParameterListFrame::RichParameterListFrame(QWidget* parent) :
}
RichParameterListFrame::RichParameterListFrame(
const RichParameterList& curParSet,
const RichParameterList& defParSet,
const RichParameterList& parameterList,
const RichParameterList& defaultValuesList,
QWidget* p,
QWidget* gla) :
QFrame(p), isHelpVisible(false), gla(gla)
{
loadFrameContent(curParSet, defParSet);
loadFrameContent(parameterList, defaultValuesList);
}
RichParameterListFrame::RichParameterListFrame(
const RichParameterList& curParSet,
const RichParameterList& parameterList,
QWidget* p,
QWidget* gla) :
QFrame(p), isHelpVisible(false), gla(gla)
{
loadFrameContent(curParSet);
loadFrameContent(parameterList, parameterList);
}
RichParameterListFrame::RichParameterListFrame(
const RichParameter& curPar,
const RichParameter& defPar,
const RichParameter& parameter,
const RichParameter& defaultValue,
QWidget* p,
QWidget* gla) :
QFrame(p), isHelpVisible(false), gla(gla)
{
loadFrameContent(curPar, defPar);
RichParameterList crpl;
crpl.addParam(parameter);
RichParameterList drpl;
drpl.addParam(defaultValue);
loadFrameContent(crpl, drpl);
}
RichParameterListFrame::~RichParameterListFrame()
@ -91,14 +95,15 @@ void RichParameterListFrame::writeValuesOnParameterList(RichParameterList& curPa
{
assert(curParSet.size() == (unsigned int) stdfieldwidgets.size());
for (auto& p : stdfieldwidgets) {
curParSet.setValue(p.first, (p.second)->widgetValue());
curParSet.setValue(p.first, *(p.second)->getWidgetValue());
}
}
void RichParameterListFrame::resetValues()
{
for (auto& p : stdfieldwidgets) {
p.second->resetValue();
p.second->resetWidgetToDefaultValue();
rpl.getParameterByName(p.first).setValue(*p.second->getWidgetValue(), true);
}
}
@ -117,6 +122,16 @@ unsigned int RichParameterListFrame::size() const
return stdfieldwidgets.size();
}
RichParameterList RichParameterListFrame::currentRichParameterList() const
{
for (const auto& w : *this) {
if (w.second->hasBeenChanged()) {
rpl.getParameterByName(w.first).setValue(*w.second->getWidgetValue());
}
}
return rpl;
}
RichParameterListFrame::iterator RichParameterListFrame::begin()
{
return stdfieldwidgets.begin();
@ -127,6 +142,16 @@ RichParameterListFrame::iterator RichParameterListFrame::end()
return stdfieldwidgets.end();
}
RichParameterListFrame::const_iterator RichParameterListFrame::begin() const
{
return stdfieldwidgets.begin();
}
RichParameterListFrame::const_iterator RichParameterListFrame::end() const
{
return stdfieldwidgets.end();
}
void RichParameterListFrame::toggleAdvancedParameters()
{
if (areAdvancedParametersVisible) {
@ -175,7 +200,7 @@ void RichParameterListFrame::loadFrameContent(
// put the parameter widgets into the grid layout
for (const RichParameter* fpi : p.second) {
const RichParameter& defrp = defParSet.getParameterByName(fpi->name());
RichParameterWidget* wd = createWidgetFromRichParameter(this, *fpi, defrp);
RichParameterWidget* wd = createWidgetFromRichParameter(this, *fpi, defrp.value());
stdfieldwidgets[fpi->name()] = wd;
wd->addWidgetToGridLayout(glay, i++);
}
@ -195,95 +220,86 @@ void RichParameterListFrame::loadFrameContent(
QSpacerItem* spacer = new QSpacerItem(40, 20, QSizePolicy::Minimum, QSizePolicy::Expanding);
glay->addItem(spacer, i++, 0);
setLayout(glay);
}
/* creates widgets for the standard parameters */
void RichParameterListFrame::loadFrameContent(const RichParameterList& curParSet)
{
loadFrameContent(curParSet, curParSet);
}
void RichParameterListFrame::loadFrameContent(
const RichParameter& curPar,
const RichParameter& defPar)
{
RichParameterList crpl;
crpl.addParam(curPar);
RichParameterList drpl;
drpl.addParam(defPar);
loadFrameContent(crpl, drpl);
rpl = curParSet;
rpl.setAllValuesAsDefault();
}
RichParameterWidget* RichParameterListFrame::createWidgetFromRichParameter(
QWidget* parent,
const RichParameter& pd,
const RichParameter& def)
RichParameterListFrame* parent,
const RichParameter& pd,
const Value& defaultValue)
{
if (pd.isOfType<RichAbsPerc>()) {
return new AbsPercWidget(parent, (const RichAbsPerc&) pd, (const RichAbsPerc&) def);
RichParameterWidget* w = nullptr;
if (pd.isOfType<RichPercentage>() && defaultValue.isOfType<FloatValue>()) {
w = new PercentageWidget(
parent, (const RichPercentage&) pd, (const FloatValue&) defaultValue);
}
else if (pd.isOfType<RichDynamicFloat>()) {
return new DynamicFloatWidget(
parent, (const RichDynamicFloat&) pd, (const RichDynamicFloat&) def);
else if (pd.isOfType<RichDynamicFloat>() && defaultValue.isOfType<FloatValue>()) {
w = new DynamicFloatWidget(
parent, (const RichDynamicFloat&) pd, (const FloatValue&) defaultValue);
}
else if (pd.isOfType<RichEnum>()) {
return new EnumWidget(parent, (const RichEnum&) pd, (const RichEnum&) def);
else if (pd.isOfType<RichEnum>() && defaultValue.isOfType<IntValue>()) {
w = new EnumWidget(parent, (const RichEnum&) pd, (const IntValue&) defaultValue);
}
else if (pd.isOfType<RichBool>()) {
return new BoolWidget(parent, (const RichBool&) pd, (const RichBool&) def);
else if (pd.isOfType<RichBool>() && defaultValue.isOfType<BoolValue>()) {
w = new BoolWidget(parent, (const RichBool&) pd, (const BoolValue&) defaultValue);
}
else if (pd.isOfType<RichInt>()) {
return new IntWidget(parent, (const RichInt&) pd, (const RichInt&) def);
else if (pd.isOfType<RichInt>() && defaultValue.isOfType<IntValue>()) {
w = new IntWidget(parent, (const RichInt&) pd, (const IntValue&) defaultValue);
}
else if (pd.isOfType<RichFloat>()) {
return new FloatWidget(parent, (const RichFloat&) pd, (const RichFloat&) def);
else if (pd.isOfType<RichFloat>() && defaultValue.isOfType<FloatValue>()) {
w = new FloatWidget(parent, (const RichFloat&) pd, (const FloatValue&) defaultValue);
}
else if (pd.isOfType<RichString>()) {
return new StringWidget(parent, (const RichString&) pd, (const RichString&) def);
else if (pd.isOfType<RichString>() && defaultValue.isOfType<StringValue>()) {
w = new StringWidget(parent, (const RichString&) pd, (const StringValue&) defaultValue);
}
else if (pd.isOfType<RichMatrix44f>()) {
return new Matrix44fWidget(
else if (pd.isOfType<RichMatrix44>() && defaultValue.isOfType<Matrix44Value>()) {
w = new Matrix44Widget(
parent,
(const RichMatrix44f&) pd,
(const RichMatrix44f&) def,
(const RichMatrix44&) pd,
(const Matrix44Value&) defaultValue,
reinterpret_cast<RichParameterListFrame*>(parent)->gla);
}
else if (pd.isOfType<RichPosition>()) {
return new PositionWidget(
else if (pd.isOfType<RichPosition>() && defaultValue.isOfType<Point3Value>()) {
w = new PositionWidget(
parent,
(const RichPosition&) pd,
(const RichPosition&) def,
(const Point3Value&) defaultValue,
reinterpret_cast<RichParameterListFrame*>(parent)->gla);
}
else if (pd.isOfType<RichDirection>()) {
return new DirectionWidget(
else if (pd.isOfType<RichDirection>() && defaultValue.isOfType<Point3Value>()) {
w = new DirectionWidget(
parent,
(const RichDirection&) pd,
(const RichDirection&) def,
(const Point3Value&) defaultValue,
reinterpret_cast<RichParameterListFrame*>(parent)->gla);
}
else if (pd.isOfType<RichShotf>()) {
return new ShotfWidget(
else if (pd.isOfType<RichShot>() && defaultValue.isOfType<ShotValue>()) {
w = new ShotWidget(
parent,
(const RichShotf&) pd,
(const RichShotf&) def,
(const RichShot&) pd,
(const ShotValue&) defaultValue,
reinterpret_cast<RichParameterListFrame*>(parent)->gla);
}
else if (pd.isOfType<RichColor>()) {
return new ColorWidget(parent, (const RichColor&) pd, (const RichColor&) def);
else if (pd.isOfType<RichColor>() && defaultValue.isOfType<ColorValue>()) {
w = new ColorWidget(parent, (const RichColor&) pd, (const ColorValue&) defaultValue);
}
else if (pd.isOfType<RichOpenFile>()) {
return new OpenFileWidget(parent, (const RichOpenFile&) pd, (const RichOpenFile&) def);
else if (pd.isOfType<RichFileOpen>() && defaultValue.isOfType<StringValue>()) {
w = new OpenFileWidget(
parent, (const RichFileOpen&) pd, (const StringValue&) defaultValue);
}
else if (pd.isOfType<RichSaveFile>()) {
return new SaveFileWidget(parent, (const RichSaveFile&) pd, (const RichSaveFile&) def);
else if (pd.isOfType<RichFileSave>() && defaultValue.isOfType<StringValue>()) {
w = new SaveFileWidget(
parent, (const RichFileSave&) pd, (const StringValue&) defaultValue);
}
else if (pd.isOfType<RichMesh>()) {
return new MeshWidget(parent, (const RichMesh&) pd, (const RichMesh&) def);
else if (pd.isOfType<RichMesh>() && defaultValue.isOfType<IntValue>()) {
w = new MeshWidget(parent, (const RichMesh&) pd, (const IntValue&) defaultValue);
}
else {
std::cerr << "RichParameter type not supported for widget creation.\n";
assert(0);
return nullptr;
}
connect(w, SIGNAL(parameterChanged()), parent, SIGNAL(parameterChanged()));
return w;
}

View File

@ -1,8 +1,8 @@
/*****************************************************************************
* VCGLib o o *
* MeshLab o o *
* Visual and Computer Graphics Library o o *
* _ O _ *
* Copyright(C) 2004-2021 \/)\/ *
* Copyright(C) 2004-2022 \/)\/ *
* Visual Computing Lab /\/| *
* ISTI - Italian National Research Council | *
* \ *
@ -21,10 +21,10 @@
* *
****************************************************************************/
#ifndef RICHPARAMETERLISTFRAME_H
#define RICHPARAMETERLISTFRAME_H
#ifndef RICH_PARAMETER_LIST_FRAME_H
#define RICH_PARAMETER_LIST_FRAME_H
#include "richparameterwidgets.h"
#include "widgets/rich_parameter_widgets.h"
#include <map>
@ -49,14 +49,15 @@ class RichParameterListFrame : public QFrame
Q_OBJECT
public:
typedef std::map<QString, RichParameterWidget*>::iterator iterator;
typedef std::map<QString, RichParameterWidget*>::const_iterator const_iterator;
RichParameterListFrame(QWidget* parent);
RichParameterListFrame(
const RichParameterList& curParSet,
const RichParameterList& defParSet,
const RichParameterList& parameterList,
const RichParameterList& defaultValuesList,
QWidget* p,
QWidget* gla = 0);
RichParameterListFrame(const RichParameterList& curParSet, QWidget* p, QWidget* gla = 0);
RichParameterListFrame(const RichParameterList& parameterList, QWidget* p, QWidget* gla = 0);
RichParameterListFrame(
const RichParameter& curPar,
const RichParameter& defPar,
@ -79,8 +80,12 @@ public:
unsigned int size() const;
RichParameterList currentRichParameterList() const;
iterator begin();
iterator end();
const_iterator begin() const;
const_iterator end() const;
signals:
void parameterChanged();
@ -90,14 +95,15 @@ public slots:
private:
void loadFrameContent(const RichParameterList& curParSet, const RichParameterList& defParSet);
void loadFrameContent(const RichParameterList& curParSet);
void loadFrameContent(const RichParameter& curPar, const RichParameter& defPar);
static RichParameterWidget* createWidgetFromRichParameter(
QWidget* parent,
RichParameterListFrame *parent,
const RichParameter& pd,
const RichParameter& def);
const Value& defaultValue);
mutable RichParameterList rpl; // a list containing all the parameters in the frame.
// the list does not contain updated values.
// it is updated just when someone asks a list containing the current values of the frame
std::map<QString, RichParameterWidget*> stdfieldwidgets;
bool isHelpVisible;
@ -108,4 +114,4 @@ private:
QPushButton* showHiddenFramePushButton;
};
#endif // RICHPARAMETERLISTFRAME_H
#endif // RICH_PARAMETER_LIST_FRAME_H

View File

@ -26,8 +26,8 @@
#include <QDialog>
#include "../../common/parameters/rich_parameter_list.h"
#include "richparameterlistframe.h"
#include <common/parameters/rich_parameter_list.h>
#include "rich_parameter_list_frame.h"
/**
* @brief This class provide a modal dialog box for asking a generic parameter list

View File

@ -0,0 +1,58 @@
/*****************************************************************************
* MeshLab o o *
* Visual and Computer Graphics Library o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 "bool_widget.h"
BoolWidget::BoolWidget(QWidget* p, const RichBool& param, const BoolValue& defaultValue) :
RichParameterWidget(p, param, defaultValue)
{
cb = new QCheckBox("", this);
cb->setToolTip(param.toolTip());
cb->setChecked(param.value().getBool());
widgets.push_back(cb);
connect(cb, SIGNAL(stateChanged(int)), this, SLOT(setParameterChanged()));
connect(descriptionLabel, SIGNAL(clicked()), cb, SLOT(toggle()));
}
BoolWidget::~BoolWidget()
{
}
void BoolWidget::addWidgetToGridLayout(QGridLayout* lay, const int r)
{
if (lay != nullptr) {
lay->addWidget(cb, r, 1);
}
RichParameterWidget::addWidgetToGridLayout(lay, r);
}
std::shared_ptr<Value> BoolWidget::getWidgetValue() const
{
return std::make_shared<BoolValue>(cb->isChecked());
}
void BoolWidget::setWidgetValue(const Value& nv)
{
cb->setChecked(nv.getBool());
}

View File

@ -0,0 +1,43 @@
/*****************************************************************************
* MeshLab o o *
* Visual and Computer Graphics Library o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 MESHLAB_BOOL_WIDGET_H
#define MESHLAB_BOOL_WIDGET_H
#include "rich_parameter_widget.h"
class BoolWidget : public RichParameterWidget
{
public:
BoolWidget(QWidget* p, const RichBool& param, const BoolValue& defaultValue);
~BoolWidget();
void addWidgetToGridLayout(QGridLayout* lay, const int r);
std::shared_ptr<Value> getWidgetValue() const;
void setWidgetValue(const Value& nv);
private:
QCheckBox* cb;
};
#endif // MESHLAB_BOOL_WIDGET_H

View File

@ -0,0 +1,102 @@
/*****************************************************************************
* MeshLab o o *
* Visual and Computer Graphics Library o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 "color_widget.h"
#include <QColorDialog>
ColorWidget::ColorWidget(QWidget* p, const RichColor& param, const ColorValue& defaultValue) :
RichParameterWidget(p, param, defaultValue), pickcol(defaultValue.getColor())
{
colorLabel = new QLabel(this);
colorButton = new QPushButton(this);
colorButton->setAutoFillBackground(true);
colorButton->setFlat(true);
colorButton->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
QColor cl = param.value().getColor();
pickcol = cl;
updateColorInfo(cl);
vlay = new QHBoxLayout();
QFontMetrics met(colorLabel->font());
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(colorButton);
widgets.push_back(colorLabel);
widgets.push_back(colorButton);
connect(colorButton, SIGNAL(clicked()), this, SLOT(pickColor()));
connect(this, SIGNAL(dialogParamChanged()), this, SLOT(setParameterChanged()));
}
ColorWidget::~ColorWidget()
{
delete colorButton;
delete colorLabel;
}
void ColorWidget::addWidgetToGridLayout(QGridLayout* lay, const int r)
{
if (lay != nullptr) {
lay->addLayout(vlay, r, 1);
}
RichParameterWidget::addWidgetToGridLayout(lay, r);
}
std::shared_ptr<Value> ColorWidget::getWidgetValue() const
{
return std::make_shared<ColorValue>(pickcol);
}
void ColorWidget::setWidgetValue(const Value& nv)
{
QColor cl = nv.getColor();
pickcol = cl;
updateColorInfo(cl);
}
void ColorWidget::updateColorInfo(const ColorValue& newColor)
{
QColor col = newColor.getColor();
colorLabel->setText("(" + col.name() + ")");
QPalette palette(col);
colorButton->setPalette(palette);
}
void ColorWidget::pickColor()
{
QColor tmp = pickcol;
auto dialogParam = QColorDialog::DontUseNativeDialog | QColorDialog::ShowAlphaChannel;
pickcol = QColorDialog::getColor(pickcol, this->parentWidget(), "Pick a Color", dialogParam);
if (pickcol.isValid()) {
updateColorInfo(ColorValue(pickcol));
emit dialogParamChanged();
}
else {
pickcol = tmp;
}
}

View File

@ -0,0 +1,56 @@
/*****************************************************************************
* MeshLab o o *
* Visual and Computer Graphics Library o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 MESHLAB_COLOR_WIDGET_H
#define MESHLAB_COLOR_WIDGET_H
#include "rich_parameter_widget.h"
class ColorWidget : public RichParameterWidget
{
Q_OBJECT
public:
ColorWidget(QWidget* p, const RichColor& param, const ColorValue& defaultValue);
~ColorWidget();
void addWidgetToGridLayout(QGridLayout* lay, const int r);
std::shared_ptr<Value> getWidgetValue() const;
void setWidgetValue(const Value& nv);
private:
void updateColorInfo(const ColorValue& newColor);
private slots:
void pickColor();
signals:
void dialogParamChanged();
protected:
QHBoxLayout* vlay;
private:
QPushButton* colorButton;
QLabel* colorLabel;
QColor pickcol;
};
#endif // MESHLAB_COLOR_WIDGET_H

View File

@ -0,0 +1,71 @@
/*****************************************************************************
* MeshLab o o *
* Visual and Computer Graphics Library o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 "combo_widget.h"
ComboWidget::ComboWidget(QWidget* p, const RichParameter& param, const Value& defaultValue) :
RichParameterWidget(p, param, defaultValue), enumCombo(new QComboBox(this))
{
}
ComboWidget::ComboWidget(
QWidget* p,
const RichParameter& rpar,
const Value& defaultValue,
const QStringList& values,
int defaultEnum) :
RichParameterWidget(p, rpar, defaultValue), enumCombo(new QComboBox(this))
{
init(defaultEnum, values);
}
ComboWidget::~ComboWidget()
{
}
void ComboWidget::addWidgetToGridLayout(QGridLayout* lay, const int r)
{
if (lay != nullptr) {
lay->addWidget(enumCombo, r, 1);
}
RichParameterWidget::addWidgetToGridLayout(lay, r);
}
void ComboWidget::setIndex(int newEnum)
{
enumCombo->setCurrentIndex(newEnum);
}
int ComboWidget::getIndex()
{
return enumCombo->currentIndex();
}
void ComboWidget::init(int defaultEnum, QStringList values)
{
enumCombo->addItems(values);
widgets.push_back(enumCombo);
setIndex(defaultEnum);
connect(enumCombo, SIGNAL(activated(int)), this, SIGNAL(dialogParamChanged()));
connect(this, SIGNAL(dialogParamChanged()), this, SLOT(setParameterChanged()));
}

View File

@ -0,0 +1,59 @@
/*****************************************************************************
* MeshLab o o *
* Visual and Computer Graphics Library o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 MESHLAB_COMBO_WIDGET_H
#define MESHLAB_COMBO_WIDGET_H
#include "rich_parameter_widget.h"
class ComboWidget : public RichParameterWidget
{
Q_OBJECT
protected:
QComboBox* enumCombo;
public:
ComboWidget(QWidget* p, const RichParameter& param, const Value& defaultValue);
ComboWidget(
QWidget* p,
const RichParameter& rpar,
const Value& defaultValue,
const QStringList& values,
int defaultEnum);
~ComboWidget();
void addWidgetToGridLayout(QGridLayout* lay, const int r);
virtual std::shared_ptr<Value> getWidgetValue() const = 0;
virtual void setWidgetValue(const Value& nv) = 0;
int getIndex();
void setIndex(int newEnum);
signals:
void dialogParamChanged();
protected:
void init(int newEnum, QStringList values);
};
#endif // MESHLAB_COMBO_WIDGET_H

View File

@ -0,0 +1,67 @@
/*****************************************************************************
* MeshLab o o *
* Visual and Computer Graphics Library o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 "direction_widget.h"
DirectionWidget::DirectionWidget(
QWidget* p,
const RichDirection& param,
const Point3Value& defaultValue,
QWidget* gla) :
Point3Widget(p, param, defaultValue, gla)
{
// if we have a connection to the current glarea we can setup the additional
// button for getting the current view direction.
if (gla) {
QStringList names;
names << "View Dir.";
names << "Raster Camera Dir.";
getPoint3Combo->addItems(names);
connect(
gla, SIGNAL(transmitViewDir(QString, Point3m)), this, SLOT(setValue(QString, Point3m)));
connect(
gla, SIGNAL(transmitShot(QString, Shotm)), this, SLOT(setShotValue(QString, Shotm)));
connect(this, SIGNAL(askViewDir(QString)), gla, SLOT(sendViewDir(QString)));
connect(this, SIGNAL(askCameraDir(QString)), gla, SLOT(sendRasterShot(QString)));
connect(getPoint3Button, SIGNAL(clicked()), this, SLOT(getPoint()));
}
}
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);
}
}

View File

@ -0,0 +1,48 @@
/*****************************************************************************
* MeshLab o o *
* Visual and Computer Graphics Library o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 MESHLAB_DIRECTION_WIDGET_H
#define MESHLAB_DIRECTION_WIDGET_H
#include "point3_widget.h"
class DirectionWidget : public Point3Widget
{
Q_OBJECT
public:
DirectionWidget(
QWidget* p,
const RichDirection& param,
const Point3Value& defaultValue,
QWidget* gla);
~DirectionWidget();
public slots:
void getPoint();
signals:
void askViewDir(QString);
void askCameraDir(QString);
};
#endif // MESHLAB_DIRECTION_WIDGET_H

View File

@ -0,0 +1,117 @@
/*****************************************************************************
* MeshLab o o *
* Visual and Computer Graphics Library o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 "dynamic_float_widget.h"
DynamicFloatWidget::DynamicFloatWidget(
QWidget* p,
const RichDynamicFloat& param,
const FloatValue& defaultValue) :
RichParameterWidget(p, param, defaultValue)
{
int numbdecimaldigit = 4;
minVal = param.min;
maxVal = param.max;
valueLE = new QLineEdit(this);
valueLE->setAlignment(Qt::AlignRight);
valueSlider = new QSlider(Qt::Horizontal, this);
valueSlider->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
valueSlider->setMinimum(0);
valueSlider->setMaximum(100);
valueSlider->setValue(floatToInt(param.value().getFloat()));
QFontMetrics fm(valueLE->font());
QSize sz = fm.size(Qt::TextSingleLine, QString::number(0));
valueLE->setValidator(new QDoubleValidator(param.min, param.max, numbdecimaldigit, valueLE));
valueLE->setText(QString::number(param.value().getFloat()));
valueLE->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
hlay = new QHBoxLayout();
hlay->addWidget(valueLE);
hlay->addWidget(valueSlider);
widgets.push_back(valueLE);
widgets.push_back(valueSlider);
int maxlenghtplusdot = 8; // numbmaxvaluedigit + numbdecimaldigit + 1;
valueLE->setMaxLength(maxlenghtplusdot);
valueLE->setMaximumWidth(sz.width() * maxlenghtplusdot);
connect(valueLE, SIGNAL(textChanged(const QString&)), this, SLOT(setValueFromTextBox()));
connect(valueSlider, SIGNAL(valueChanged(int)), this, SLOT(setValue(int)));
connect(this, SIGNAL(dialogParamChanged()), this, SLOT(setParameterChanged()));
}
DynamicFloatWidget::~DynamicFloatWidget()
{
}
void DynamicFloatWidget::addWidgetToGridLayout(QGridLayout* lay, const int r)
{
if (lay != nullptr) {
lay->addLayout(hlay, r, 1);
}
RichParameterWidget::addWidgetToGridLayout(lay, r);
}
std::shared_ptr<Value> DynamicFloatWidget::getWidgetValue() const
{
return std::make_shared<FloatValue>(valueLE->text().toFloat());
}
void DynamicFloatWidget::setWidgetValue(const Value& nv)
{
valueLE->setText(QString::number(nv.getFloat()));
}
float DynamicFloatWidget::getValue()
{
return float(valueLE->text().toDouble());
}
void DynamicFloatWidget::setValue(int newVal)
{
if (floatToInt(float(valueLE->text().toDouble())) != newVal) {
valueLE->setText(QString::number(intToFloat(newVal)));
}
}
void DynamicFloatWidget::setValueFromTextBox()
{
float newValLE = float(valueLE->text().toDouble());
valueSlider->setValue(floatToInt(newValLE));
emit dialogParamChanged();
}
void DynamicFloatWidget::setValue(float newVal)
{
if (QString::number(intToFloat(newVal)) != valueLE->text())
valueLE->setText(QString::number(intToFloat(newVal)));
}
float DynamicFloatWidget::intToFloat(int val)
{
return minVal + float(val) / 100.0f * (maxVal - minVal);
}
int DynamicFloatWidget::floatToInt(float val)
{
return int(100.0f * (val - minVal) / (maxVal - minVal));
}

View File

@ -0,0 +1,63 @@
/*****************************************************************************
* MeshLab o o *
* Visual and Computer Graphics Library o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 MESHLAB_DYNAMIC_FLOAT_WIDGET_H
#define MESHLAB_DYNAMIC_FLOAT_WIDGET_H
#include "rich_parameter_widget.h"
class DynamicFloatWidget : public RichParameterWidget
{
Q_OBJECT
public:
DynamicFloatWidget(QWidget* p, const RichDynamicFloat& param, const FloatValue& defaultValue);
~DynamicFloatWidget();
void addWidgetToGridLayout(QGridLayout* lay, const int r);
std::shared_ptr<Value> getWidgetValue() const;
void setWidgetValue(const Value& nv);
float getValue();
public slots:
void setValue(int newv);
void setValueFromTextBox();
void setValue(float newValue);
signals:
// void valueChanged(int mask);
void dialogParamChanged();
private:
QLineEdit* valueLE;
QSlider* valueSlider;
float minVal;
float maxVal;
QHBoxLayout* hlay;
float intToFloat(int val);
int floatToInt(float val);
};
#endif // MESHLAB_DYNAMIC_FLOAT_WIDGET_H

View File

@ -0,0 +1,43 @@
/*****************************************************************************
* MeshLab o o *
* Visual and Computer Graphics Library o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 "enum_widget.h"
EnumWidget::EnumWidget(QWidget* p, const RichEnum& param, const IntValue& defaultValue) :
ComboWidget(p, param, defaultValue, param.enumvalues, param.value().getInt())
{
}
EnumWidget::~EnumWidget()
{
}
std::shared_ptr<Value> EnumWidget::getWidgetValue() const
{
return std::make_shared<IntValue>(enumCombo->currentIndex());
}
void EnumWidget::setWidgetValue(const Value& nv)
{
enumCombo->setCurrentIndex(nv.getInt());
}

View File

@ -0,0 +1,39 @@
/*****************************************************************************
* MeshLab o o *
* Visual and Computer Graphics Library o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 MESHLAB_ENUM_WIDGET_H
#define MESHLAB_ENUM_WIDGET_H
#include "combo_widget.h"
class EnumWidget : public ComboWidget
{
public:
EnumWidget(QWidget* p, const RichEnum& param, const IntValue& defaultValue);
~EnumWidget();;
std::shared_ptr<Value> getWidgetValue() const;
void setWidgetValue(const Value& nv);
};
#endif // MESHLAB_ENUM_WIDGET_H

View File

@ -0,0 +1,44 @@
/*****************************************************************************
* MeshLab o o *
* Visual and Computer Graphics Library o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 "float_widget.h"
FloatWidget::FloatWidget(QWidget* p, const RichFloat& param, const FloatValue& defaultValue) :
LineEditWidget(p, param, defaultValue)
{
lned->setText(QString::number(param.value().getFloat(), 'g', 3));
}
FloatWidget::~FloatWidget()
{
}
std::shared_ptr<Value> FloatWidget::getWidgetValue() const
{
return std::make_shared<FloatValue>(lned->text().toFloat());
}
void FloatWidget::setWidgetValue(const Value& nv)
{
lned->setText(QString::number(nv.getFloat(), 'g', 3));
}

View File

@ -0,0 +1,39 @@
/*****************************************************************************
* MeshLab o o *
* Visual and Computer Graphics Library o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 MESHLAB_FLOAT_WIDGET_H
#define MESHLAB_FLOAT_WIDGET_H
#include "line_edit_widget.h"
class FloatWidget : public LineEditWidget
{
public:
FloatWidget(QWidget* p, const RichFloat& param, const FloatValue& defaultValue);
~FloatWidget();
std::shared_ptr<Value> getWidgetValue() const;
void setWidgetValue(const Value& nv);
};
#endif // MESHLAB_FLOAT_WIDGET_H

View File

@ -0,0 +1,44 @@
/*****************************************************************************
* MeshLab o o *
* Visual and Computer Graphics Library o o *
* _ O _ *
* Copyright(C) 2004-2022 \/)\/ *
* 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 "int_widget.h"
IntWidget::IntWidget(QWidget* p, const RichInt& param, const IntValue& defaultValue) :
LineEditWidget(p, param, defaultValue)
{
lned->setText(QString::number(param.value().getInt()));
}
IntWidget::~IntWidget()
{
}
std::shared_ptr<Value> IntWidget::getWidgetValue() const
{
return std::make_shared<IntValue>(lned->text().toInt());
}
void IntWidget::setWidgetValue(const Value& nv)
{
lned->setText(QString::number(nv.getInt()));
}

Some files were not shown because too many files have changed in this diff Show More