From 6e4d3b34c853d36690aef8494a5bdf4f9bbf505c Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Mon, 30 May 2022 11:28:06 +0200 Subject: [PATCH] values reorganization --- src/common/CMakeLists.txt | 20 +- src/common/parameters/rich_parameter.cpp | 16 +- src/common/parameters/rich_parameter.h | 2 +- src/common/parameters/rich_parameter_list.cpp | 6 +- src/common/parameters/value.cpp | 75 ----- src/common/parameters/value.h | 296 ------------------ src/common/parameters/value/bool_value.cpp | 69 ++++ src/common/parameters/value/bool_value.h | 47 +++ src/common/parameters/value/color_value.cpp | 71 +++++ src/common/parameters/value/color_value.h | 47 +++ src/common/parameters/value/float_value.cpp | 68 ++++ src/common/parameters/value/float_value.h | 47 +++ src/common/parameters/value/int_value.cpp | 63 ++++ src/common/parameters/value/int_value.h | 47 +++ .../parameters/value/matrix44_value.cpp | 69 ++++ src/common/parameters/value/matrix44_value.h | 47 +++ src/common/parameters/value/point3_value.cpp | 70 +++++ src/common/parameters/value/point3_value.h | 47 +++ src/common/parameters/value/shot_value.cpp | 69 ++++ src/common/parameters/value/shot_value.h | 47 +++ src/common/parameters/value/string_value.cpp | 68 ++++ src/common/parameters/value/string_value.h | 47 +++ src/common/parameters/value/value.h | 103 ++++++ src/common/parameters/value/values.h | 36 +++ src/common/python/function_parameter.cpp | 8 +- src/meshlab/dialogs/options_dialog.cpp | 2 +- .../richparameterwidgets.cpp | 36 +-- 27 files changed, 1115 insertions(+), 408 deletions(-) delete mode 100644 src/common/parameters/value.cpp delete mode 100644 src/common/parameters/value.h create mode 100644 src/common/parameters/value/bool_value.cpp create mode 100644 src/common/parameters/value/bool_value.h create mode 100644 src/common/parameters/value/color_value.cpp create mode 100644 src/common/parameters/value/color_value.h create mode 100644 src/common/parameters/value/float_value.cpp create mode 100644 src/common/parameters/value/float_value.h create mode 100644 src/common/parameters/value/int_value.cpp create mode 100644 src/common/parameters/value/int_value.h create mode 100644 src/common/parameters/value/matrix44_value.cpp create mode 100644 src/common/parameters/value/matrix44_value.h create mode 100644 src/common/parameters/value/point3_value.cpp create mode 100644 src/common/parameters/value/point3_value.h create mode 100644 src/common/parameters/value/shot_value.cpp create mode 100644 src/common/parameters/value/shot_value.h create mode 100644 src/common/parameters/value/string_value.cpp create mode 100644 src/common/parameters/value/string_value.h create mode 100644 src/common/parameters/value/value.h create mode 100644 src/common/parameters/value/values.h diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index bbe7f2930..652ed16a8 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -55,7 +55,16 @@ set(HEADERS ml_shared_data_context/ml_shared_data_context.h parameters/rich_parameter.h parameters/rich_parameter_list.h - parameters/value.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 + parameters/value/values.h plugins/containers/generic_container_iterator.h plugins/containers/decorate_plugin_container.h plugins/containers/edit_plugin_container.h @@ -101,7 +110,14 @@ set(SOURCES ml_shared_data_context/ml_shared_data_context.cpp parameters/rich_parameter.cpp parameters/rich_parameter_list.cpp - parameters/value.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 diff --git a/src/common/parameters/rich_parameter.cpp b/src/common/parameters/rich_parameter.cpp index 5e2d7f575..f5ca64ce4 100644 --- a/src/common/parameters/rich_parameter.cpp +++ b/src/common/parameters/rich_parameter.cpp @@ -301,7 +301,7 @@ RichMatrix44f::RichMatrix44f( const QString& tltip, bool hidden, const QString& category) : - RichParameter(nm, Matrix44fValue(defval),desc, tltip, hidden, category) + RichParameter(nm, Matrix44Value(defval),desc, tltip, hidden, category) { } @@ -321,7 +321,7 @@ RichMatrix44f* RichMatrix44f::clone() const bool RichMatrix44f::operator==( const RichParameter& rb ) { - return (rb.value().isMatrix44f() &&(pName == rb.name()) && (value().getMatrix44f() == rb.value().getMatrix44f())); + return (rb.value().isMatrix44() &&(pName == rb.name()) && (value().getMatrix44() == rb.value().getMatrix44())); } /**** RichPosition Class ****/ @@ -333,7 +333,7 @@ RichPosition::RichPosition( const QString& tltip, bool hidden, const QString& category) : - RichParameter(nm, Point3fValue(defval),desc, tltip, hidden, category) + RichParameter(nm, Point3Value(defval),desc, tltip, hidden, category) { } @@ -353,7 +353,7 @@ RichPosition* RichPosition::clone() const bool RichPosition::operator==( const RichParameter& rb ) { - return (rb.value().isPoint3f() &&(pName == rb.name()) && (value().getPoint3f() == rb.value().getPoint3f())); + return (rb.value().isPoint3() &&(pName == rb.name()) && (value().getPoint3() == rb.value().getPoint3())); } /**** RichDirection Class ****/ @@ -365,7 +365,7 @@ RichDirection::RichDirection( const QString& tltip, bool hidden, const QString& category) : - RichParameter(nm, Point3fValue(defval), desc, tltip, hidden, category) + RichParameter(nm, Point3Value(defval), desc, tltip, hidden, category) { } @@ -385,7 +385,7 @@ RichDirection* RichDirection::clone() const bool RichDirection::operator==(const RichParameter& rb) { - return (rb.value().isPoint3f() &&(pName == rb.name()) && (value().getPoint3f() == rb.value().getPoint3f())); + return (rb.value().isPoint3() &&(pName == rb.name()) && (value().getPoint3() == rb.value().getPoint3())); } /**** RichShotf Class ****/ @@ -397,7 +397,7 @@ RichShotf::RichShotf( const QString& tltip, bool hidden, const QString& category) : - RichParameter(nm, ShotfValue(defval),desc, tltip, hidden, category) + RichParameter(nm, ShotValue(defval),desc, tltip, hidden, category) { } @@ -417,7 +417,7 @@ RichShotf* RichShotf::clone() const bool RichShotf::operator==( const RichParameter& rb ) { - return (rb.value().isShotf() &&(pName == rb.name()) ); + return (rb.value().isShot() &&(pName == rb.name()) ); // TODO REAL TEST OF EQUALITY // && (value().getShotf() == rb.value().getShotf())); } diff --git a/src/common/parameters/rich_parameter.h b/src/common/parameters/rich_parameter.h index 7f72ce96f..9412e411d 100644 --- a/src/common/parameters/rich_parameter.h +++ b/src/common/parameters/rich_parameter.h @@ -24,7 +24,7 @@ #ifndef MESHLAB_RICH_PARAMETER_H #define MESHLAB_RICH_PARAMETER_H -#include "value.h" +#include "value/values.h" #include class MeshDocument; diff --git a/src/common/parameters/rich_parameter_list.cpp b/src/common/parameters/rich_parameter_list.cpp index 344b3643a..824a26835 100644 --- a/src/common/parameters/rich_parameter_list.cpp +++ b/src/common/parameters/rich_parameter_list.cpp @@ -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 RichParameterList::getShotf(const QString& name) const { - return Shot::Construct(getParameterByName(name).value().getShotf()); + return Shot::Construct(getParameterByName(name).value().getShot()); } /** diff --git a/src/common/parameters/value.cpp b/src/common/parameters/value.cpp deleted file mode 100644 index e5dff7899..000000000 --- a/src/common/parameters/value.cpp +++ /dev/null @@ -1,75 +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 "value.h" - -#include "../ml_document/mesh_document.h" - -void BoolValue::fillToXMLElement(QDomElement& element) const -{ - QString v = pval ? "true" : "false"; - element.setAttribute("value", v); -} - -void IntValue::fillToXMLElement(QDomElement& element) const -{ - element.setAttribute("value", QString::number(pval)); -} - -void FloatValue::fillToXMLElement(QDomElement& element) const -{ - element.setAttribute("value", QString::number(pval)); -} - -void StringValue::fillToXMLElement(QDomElement& element) const -{ - element.setAttribute("value", pval); -} - -void Matrix44fValue::fillToXMLElement(QDomElement& element) const -{ - for(unsigned int ii = 0;ii < 16;++ii) - element.setAttribute(QString("val")+QString::number(ii),QString::number(pval.V()[ii])); -} - -void Point3fValue::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())); -} - -void ShotfValue::fillToXMLElement(QDomElement&) const -{ - assert(0); - //TODO!!! -} - -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())); -} - diff --git a/src/common/parameters/value.h b/src/common/parameters/value.h deleted file mode 100644 index ee6f5c06c..000000000 --- a/src/common/parameters/value.h +++ /dev/null @@ -1,296 +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 "../ml_document/cmesh.h" -#include -#include -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 bool operator==(const Value& p) 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); } - inline bool operator==(const Value& p) const - { - if (p.isBool()) - return pval == p.getBool(); - else - return false; - } - 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); } - inline bool operator==(const Value& p) const - { - if (p.isInt()) - return pval == p.getInt(); - else - return false; - } - 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); } - inline bool operator==(const Value& p) const - { - if (p.isFloat()) - return pval == p.getFloat(); - else - return false; - } - 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); } - inline bool operator==(const Value& p) const - { - if (p.isString()) - return pval == p.getString(); - else - return false; - } - 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); } - inline bool operator==(const Value& p) const - { - if (p.isMatrix44f()) - return pval == p.getMatrix44f(); - else - return false; - } - 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); } - inline bool operator==(const Value& p) const - { - if (p.isMatrix44f()) - return pval == p.getPoint3f(); - else - return false; - } - 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); } - inline bool operator==(const Value& p) const - { - if (p.isShotf()) - return pval == p.getShotf(); - else - return false; - } - 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); } - inline bool operator==(const Value& p) const - { - if (p.isColor()) - return pval == p.getColor(); - else - return false; - } - void fillToXMLElement(QDomElement& element) const; - -private: - QColor pval; -}; - -#endif //MESHLAB_VALUE_H diff --git a/src/common/parameters/value/bool_value.cpp b/src/common/parameters/value/bool_value.cpp new file mode 100644 index 000000000..833fc4f47 --- /dev/null +++ b/src/common/parameters/value/bool_value.cpp @@ -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 + +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); +} diff --git a/src/common/parameters/value/bool_value.h b/src/common/parameters/value/bool_value.h new file mode 100644 index 000000000..b5c934128 --- /dev/null +++ b/src/common/parameters/value/bool_value.h @@ -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 diff --git a/src/common/parameters/value/color_value.cpp b/src/common/parameters/value/color_value.cpp new file mode 100644 index 000000000..f40b3decb --- /dev/null +++ b/src/common/parameters/value/color_value.cpp @@ -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 + +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())); +} diff --git a/src/common/parameters/value/color_value.h b/src/common/parameters/value/color_value.h new file mode 100644 index 000000000..c497c8e2a --- /dev/null +++ b/src/common/parameters/value/color_value.h @@ -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 diff --git a/src/common/parameters/value/float_value.cpp b/src/common/parameters/value/float_value.cpp new file mode 100644 index 000000000..406642fda --- /dev/null +++ b/src/common/parameters/value/float_value.cpp @@ -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 + +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)); +} diff --git a/src/common/parameters/value/float_value.h b/src/common/parameters/value/float_value.h new file mode 100644 index 000000000..93530b568 --- /dev/null +++ b/src/common/parameters/value/float_value.h @@ -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 diff --git a/src/common/parameters/value/int_value.cpp b/src/common/parameters/value/int_value.cpp new file mode 100644 index 000000000..43ccf594f --- /dev/null +++ b/src/common/parameters/value/int_value.cpp @@ -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 + +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)); +} diff --git a/src/common/parameters/value/int_value.h b/src/common/parameters/value/int_value.h new file mode 100644 index 000000000..8d3479bda --- /dev/null +++ b/src/common/parameters/value/int_value.h @@ -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 diff --git a/src/common/parameters/value/matrix44_value.cpp b/src/common/parameters/value/matrix44_value.cpp new file mode 100644 index 000000000..202cb4d8e --- /dev/null +++ b/src/common/parameters/value/matrix44_value.cpp @@ -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 + +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])); +} diff --git a/src/common/parameters/value/matrix44_value.h b/src/common/parameters/value/matrix44_value.h new file mode 100644 index 000000000..b5e75695b --- /dev/null +++ b/src/common/parameters/value/matrix44_value.h @@ -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 diff --git a/src/common/parameters/value/point3_value.cpp b/src/common/parameters/value/point3_value.cpp new file mode 100644 index 000000000..e8cb906c6 --- /dev/null +++ b/src/common/parameters/value/point3_value.cpp @@ -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 + +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())); +} diff --git a/src/common/parameters/value/point3_value.h b/src/common/parameters/value/point3_value.h new file mode 100644 index 000000000..bdfab998e --- /dev/null +++ b/src/common/parameters/value/point3_value.h @@ -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 diff --git a/src/common/parameters/value/shot_value.cpp b/src/common/parameters/value/shot_value.cpp new file mode 100644 index 000000000..379db5236 --- /dev/null +++ b/src/common/parameters/value/shot_value.cpp @@ -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 + +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!!! +} diff --git a/src/common/parameters/value/shot_value.h b/src/common/parameters/value/shot_value.h new file mode 100644 index 000000000..c6b3f8e43 --- /dev/null +++ b/src/common/parameters/value/shot_value.h @@ -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 diff --git a/src/common/parameters/value/string_value.cpp b/src/common/parameters/value/string_value.cpp new file mode 100644 index 000000000..c5005678e --- /dev/null +++ b/src/common/parameters/value/string_value.cpp @@ -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 + +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); +} diff --git a/src/common/parameters/value/string_value.h b/src/common/parameters/value/string_value.h new file mode 100644 index 000000000..a814d1703 --- /dev/null +++ b/src/common/parameters/value/string_value.h @@ -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 diff --git a/src/common/parameters/value/value.h b/src/common/parameters/value/value.h new file mode 100644 index 000000000..87a8f724b --- /dev/null +++ b/src/common/parameters/value/value.h @@ -0,0 +1,103 @@ +/***************************************************************************** + * 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 +#include +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; +}; + +#endif //MESHLAB_VALUE_H diff --git a/src/common/parameters/value/values.h b/src/common/parameters/value/values.h new file mode 100644 index 000000000..0d3efe629 --- /dev/null +++ b/src/common/parameters/value/values.h @@ -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 "bool_value.h" +#include "color_value.h" +#include "float_value.h" +#include "int_value.h" +#include "matrix44_value.h" +#include "point3_value.h" +#include "shot_value.h" +#include "string_value.h" + +#endif // MESHLAB_VALUES_H diff --git a/src/common/python/function_parameter.cpp b/src/common/python/function_parameter.cpp index c8d32eb4b..56e7531b1 100644 --- a/src/common/python/function_parameter.cpp +++ b/src/common/python/function_parameter.cpp @@ -134,7 +134,7 @@ void pymeshlab::FunctionParameter::printDefaultValue(std::ostream& o) const return; } if (parameter->isOfType()){ - const MESHLAB_SCALAR* v = parameter->value().getMatrix44f().V(); + 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,9 +142,9 @@ void pymeshlab::FunctionParameter::printDefaultValue(std::ostream& o) const return; } if (parameter->isOfType() || parameter->isOfType()) { - 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()) { diff --git a/src/meshlab/dialogs/options_dialog.cpp b/src/meshlab/dialogs/options_dialog.cpp index cbcb79984..8083dc023 100644 --- a/src/meshlab/dialogs/options_dialog.cpp +++ b/src/meshlab/dialogs/options_dialog.cpp @@ -140,7 +140,7 @@ QTableWidgetItem* MeshLabOptionsDialog::createQTableWidgetItemFromRichParameter( return nullptr; } else if (pd.isOfType() || pd.isOfType()){ - vcg::Point3f pp = pd.value().getPoint3f(); + vcg::Point3f pp = pd.value().getPoint3(); QString pst = "P3(" + QString::number(pp.X()) + "," + QString::number(pp.Y()) + "," + QString::number(pp.Z()) + ")"; return new QTableWidgetItem(pst); } diff --git a/src/meshlab/rich_parameter_gui/richparameterwidgets.cpp b/src/meshlab/rich_parameter_gui/richparameterwidgets.cpp index edb6020bc..558e86a58 100644 --- a/src/meshlab/rich_parameter_gui/richparameterwidgets.cpp +++ b/src/meshlab/rich_parameter_gui/richparameterwidgets.cpp @@ -503,7 +503,7 @@ PositionWidget::PositionWidget( widgets.push_back(coordSB[i]); connect(coordSB[i], SIGNAL(textChanged(QString)), p, SIGNAL(parameterChanged())); } - this->setValue(paramName, parameter->value().getPoint3f()); + this->setValue(paramName, parameter->value().getPoint3()); // if we have a connection to the current glarea we can setup the additional // button for getting the current view direction. if (gla_curr) { @@ -592,20 +592,20 @@ vcg::Point3f PositionWidget::getValue() void PositionWidget::collectWidgetValue() { - parameter->setValue(Point3fValue(vcg::Point3f( + parameter->setValue(Point3Value(vcg::Point3f( coordSB[0]->text().toFloat(), coordSB[1]->text().toFloat(), coordSB[2]->text().toFloat()))); } void PositionWidget::resetWidgetValue() { for (unsigned int ii = 0; ii < 3; ++ii) - coordSB[ii]->setText(QString::number(parameter->value().getPoint3f()[ii], 'g', 3)); + coordSB[ii]->setText(QString::number(parameter->value().getPoint3()[ii], 'g', 3)); } void PositionWidget::setWidgetValue(const Value& nv) { for (unsigned int ii = 0; ii < 3; ++ii) - coordSB[ii]->setText(QString::number(nv.getPoint3f()[ii], 'g', 3)); + coordSB[ii]->setText(QString::number(nv.getPoint3()[ii], 'g', 3)); } void PositionWidget::addWidgetToGridLayout(QGridLayout* lay, const int r) @@ -647,7 +647,7 @@ DirectionWidget::DirectionWidget( widgets.push_back(coordSB[i]); connect(coordSB[i], SIGNAL(textChanged(QString)), p, SIGNAL(parameterChanged())); } - this->setValue(paramName, parameter->value().getPoint3f()); + this->setValue(paramName, parameter->value().getPoint3()); // if we have a connection to the current glarea we can setup the additional // button for getting the current view direction. if (gla_curr) { @@ -721,20 +721,20 @@ vcg::Point3f DirectionWidget::getValue() void DirectionWidget::collectWidgetValue() { - parameter->setValue(Point3fValue(vcg::Point3f( + parameter->setValue(Point3Value(vcg::Point3f( coordSB[0]->text().toFloat(), coordSB[1]->text().toFloat(), coordSB[2]->text().toFloat()))); } void DirectionWidget::resetWidgetValue() { for (unsigned int ii = 0; ii < 3; ++ii) - coordSB[ii]->setText(QString::number(parameter->value().getPoint3f()[ii], 'g', 3)); + coordSB[ii]->setText(QString::number(parameter->value().getPoint3()[ii], 'g', 3)); } void DirectionWidget::setWidgetValue(const Value& nv) { for (unsigned int ii = 0; ii < 3; ++ii) - coordSB[ii]->setText(QString::number(nv.getPoint3f()[ii], 'g', 3)); + coordSB[ii]->setText(QString::number(nv.getPoint3()[ii], 'g', 3)); } void DirectionWidget::addWidgetToGridLayout(QGridLayout* lay, const int r) @@ -782,7 +782,7 @@ Matrix44fWidget::Matrix44fWidget( this, SLOT(invalidateMatrix(const QString&))); } - this->setValue(paramName, parameter->value().getMatrix44f()); + this->setValue(paramName, parameter->value().getMatrix44()); QLabel* headerL = new QLabel("Matrix:", this); vlay->addWidget(headerL, 0, Qt::AlignTop); @@ -876,10 +876,10 @@ void Matrix44fWidget::collectWidgetValue() Matrix44m tempM; for (unsigned int i = 0; i < 16; ++i) tempM[i / 4][i % 4] = coordSB[i]->text().toFloat(); - parameter->setValue(Matrix44fValue(tempM)); + parameter->setValue(Matrix44Value(tempM)); } else { - parameter->setValue(Matrix44fValue(m)); + parameter->setValue(Matrix44Value(m)); } } @@ -890,16 +890,16 @@ void Matrix44fWidget::resetWidgetValue() m.SetIdentity(); for (unsigned int ii = 0; ii < 16; ++ii) { coordSB[ii]->setText( - QString::number(parameter->value().getMatrix44f()[ii / 4][ii % 4], 'g', 3)); + QString::number(parameter->value().getMatrix44()[ii / 4][ii % 4], 'g', 3)); } } void Matrix44fWidget::setWidgetValue(const Value& nv) { valid = true; - m = nv.getMatrix44f(); + m = nv.getMatrix44(); for (unsigned int ii = 0; ii < 16; ++ii) - coordSB[ii]->setText(QString::number(nv.getMatrix44f()[ii / 4][ii % 4], 'g', 3)); + coordSB[ii]->setText(QString::number(nv.getMatrix44()[ii / 4][ii % 4], 'g', 3)); } void Matrix44fWidget::addWidgetToGridLayout(QGridLayout* lay, const int r) @@ -930,7 +930,7 @@ ShotfWidget::ShotfWidget( hlay = new QHBoxLayout(); - this->setShotValue(paramName, parameter->value().getShotf()); + this->setShotValue(paramName, parameter->value().getShot()); // if we have a connection to the current glarea we can setup the additional // button for getting the current view direction. if (gla_curr) { @@ -1008,17 +1008,17 @@ Shotm ShotfWidget::getValue() void ShotfWidget::collectWidgetValue() { - parameter->setValue(ShotfValue(curShot)); + parameter->setValue(ShotValue(curShot)); } void ShotfWidget::resetWidgetValue() { - curShot = parameter->value().getShotf(); + curShot = parameter->value().getShot(); } void ShotfWidget::setWidgetValue(const Value& nv) { - curShot = nv.getShotf(); + curShot = nv.getShot(); } void ShotfWidget::addWidgetToGridLayout(QGridLayout* lay, const int r)