feat: add xyz parameter type
This commit is contained in:
@@ -35,14 +35,14 @@ enzo::geo::Geometry enzo::op::Context::cloneInputGeo(unsigned int inputIndex)
|
||||
}
|
||||
|
||||
// TODO: cache value
|
||||
enzo::bt::floatT enzo::op::Context::evalFloatParm(const char* parmName) const
|
||||
enzo::bt::floatT enzo::op::Context::evalFloatParm(const char* parmName, const unsigned int index) const
|
||||
{
|
||||
enzo::nt::GeometryOperator& selfOp = networkManager_.getGeoOperator(opId_);
|
||||
std::weak_ptr<prm::Parameter> parameter = selfOp.getParameter(parmName);
|
||||
|
||||
if(auto sharedParm = parameter.lock())
|
||||
{
|
||||
return sharedParm->evalFloat();
|
||||
return sharedParm->evalFloat(index);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -15,7 +15,7 @@ class Context
|
||||
public:
|
||||
Context(enzo::nt::OpId opId, enzo::nt::NetworkManager& networkManager);
|
||||
enzo::geo::Geometry cloneInputGeo(unsigned int inputIndex);
|
||||
bt::floatT evalFloatParm(const char* parmName) const;
|
||||
bt::floatT evalFloatParm(const char* parmName, const unsigned int index=0) const;
|
||||
private:
|
||||
enzo::nt::OpId opId_;
|
||||
enzo::nt::NetworkManager& networkManager_;
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
#include "Engine/Parameter/Parameter.h"
|
||||
#include "Engine/Types.h"
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
enzo::prm::Parameter::Parameter(Template prmTemplate)
|
||||
: template_{prmTemplate}
|
||||
{
|
||||
floatValue_ = prmTemplate.getDefault();
|
||||
floatValues_ = std::vector<bt::floatT>(prmTemplate.getSize(), prmTemplate.getDefault());
|
||||
std::cout << "created new parameter: " << prmTemplate.getName() << "\n";
|
||||
}
|
||||
|
||||
@@ -13,13 +16,28 @@ std::string enzo::prm::Parameter::getName() const
|
||||
return template_.getName();
|
||||
}
|
||||
|
||||
enzo::bt::floatT enzo::prm::Parameter::evalFloat() const
|
||||
enzo::bt::floatT enzo::prm::Parameter::evalFloat(unsigned int index) const
|
||||
{
|
||||
return floatValue_;
|
||||
if(index >= floatValues_.size())
|
||||
throw std::out_of_range("Cannot access index: " + std::to_string(index) + " for parameter: " + getName());
|
||||
return floatValues_[index];
|
||||
}
|
||||
void enzo::prm::Parameter::setFloat(bt::floatT value)
|
||||
|
||||
enzo::prm::Type enzo::prm::Parameter::getType() const
|
||||
{
|
||||
floatValue_ = value;
|
||||
return template_.getType();
|
||||
}
|
||||
|
||||
enzo::bt::String enzo::prm::Parameter::evalString() const
|
||||
{
|
||||
return stringValue_;
|
||||
}
|
||||
|
||||
void enzo::prm::Parameter::setFloat(bt::floatT value, unsigned int index)
|
||||
{
|
||||
std::cout << "accessing at: " << index << "\n";
|
||||
std::cout << "size: " << floatValues_.size() << "\n";
|
||||
floatValues_[index] = value;
|
||||
valueChanged();
|
||||
}
|
||||
|
||||
|
||||
@@ -10,12 +10,16 @@ class Parameter
|
||||
public:
|
||||
Parameter(Template prmTemplate);
|
||||
std::string getName() const;
|
||||
bt::floatT evalFloat() const;
|
||||
void setFloat(bt::floatT value);
|
||||
bt::floatT evalFloat(unsigned int index=0) const;
|
||||
bt::String evalString() const;
|
||||
enzo::prm::Type getType() const;
|
||||
|
||||
void setFloat(bt::floatT value, unsigned int index=0);
|
||||
boost::signals2::signal<void ()> valueChanged;
|
||||
private:
|
||||
Template template_;
|
||||
bt::floatT floatValue_ = 0;
|
||||
std::vector<bt::floatT> floatValues_;
|
||||
bt::String stringValue_ = "";
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#include "Engine/Parameter/Template.h"
|
||||
#include "Engine/Parameter/Type.h"
|
||||
|
||||
enzo::prm::Template::Template(enzo::prm::Type type, const char* name, bt::floatT theDefault)
|
||||
: type_{type}, name_{name}, default_{theDefault}
|
||||
enzo::prm::Template::Template(enzo::prm::Type type, const char* name, bt::floatT theDefault, unsigned int vectorSize)
|
||||
: type_{type}, name_{name}, default_{theDefault}, vectorSize_(vectorSize)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -18,6 +18,18 @@ bool enzo::prm::Template::isValid() const
|
||||
|
||||
}
|
||||
|
||||
const enzo::prm::Type enzo::prm::Template::getType() const
|
||||
{
|
||||
return type_;
|
||||
}
|
||||
|
||||
const unsigned int enzo::prm::Template::getSize() const
|
||||
{
|
||||
return vectorSize_;
|
||||
}
|
||||
|
||||
|
||||
|
||||
const enzo::bt::floatT enzo::prm::Template::getDefault() const
|
||||
{
|
||||
return default_;
|
||||
|
||||
@@ -12,17 +12,21 @@ public:
|
||||
enzo::prm::Type type,
|
||||
const char* name,
|
||||
// TODO: change default to class that can store multiple types
|
||||
bt::floatT theDefault
|
||||
bt::floatT theDefault,
|
||||
unsigned int vectorSize = 1
|
||||
);
|
||||
Template();
|
||||
const char* getName() const;
|
||||
const bt::floatT getDefault() const;
|
||||
const prm::Type getType() const;
|
||||
const unsigned int getSize() const;
|
||||
bool isValid() const;
|
||||
private:
|
||||
enzo::prm::Type type_;
|
||||
bt::floatT default_;
|
||||
// TODO: make a class that holds token and name
|
||||
const char* name_;
|
||||
unsigned int vectorSize_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -31,12 +31,14 @@ namespace enzo
|
||||
using intT = int64_t;
|
||||
using Vector3 = Eigen::Vector3d;
|
||||
using Vector4 = Eigen::Vector4d;
|
||||
using String = std::string;
|
||||
}
|
||||
namespace prm
|
||||
{
|
||||
enum class Type
|
||||
{
|
||||
STRING,
|
||||
XYZ,
|
||||
FLOAT,
|
||||
INT,
|
||||
TOGGLE
|
||||
|
||||
Reference in New Issue
Block a user