feat(opTable): store op info in table, convert table pos getter to name getter
This commit is contained in:
@@ -6,12 +6,19 @@ void enzo::op::OperatorTable::addOperator(const char* internalName, const char*
|
|||||||
{
|
{
|
||||||
std::cout << "OPERATOR TABLE ADDED\n";
|
std::cout << "OPERATOR TABLE ADDED\n";
|
||||||
std::cout << "adding operator: " << displayName << "\n";
|
std::cout << "adding operator: " << displayName << "\n";
|
||||||
ctorStore_.push_back(ctorFunc);
|
opInfoStore_.push_back({internalName, displayName, ctorFunc});
|
||||||
}
|
}
|
||||||
|
|
||||||
enzo::nt::opConstructor enzo::op::OperatorTable::getOpConstructor(size_t pos)
|
enzo::nt::opConstructor enzo::op::OperatorTable::getOpConstructor(std::string name)
|
||||||
{
|
{
|
||||||
return ctorStore_.at(pos);
|
for(auto it = opInfoStore_.begin(); it!=opInfoStore_.end(); ++it)
|
||||||
|
{
|
||||||
|
if(it->internalName==name)
|
||||||
|
{
|
||||||
|
return it->ctorFunc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<enzo::nt::opConstructor> enzo::op::OperatorTable::ctorStore_;
|
std::vector<enzo::op::OpInfo> enzo::op::OperatorTable::opInfoStore_;
|
||||||
|
|||||||
@@ -4,15 +4,23 @@
|
|||||||
#include "Engine/Network/NetworkManager.h"
|
#include "Engine/Network/NetworkManager.h"
|
||||||
#include "Engine/Operator/GeometryOpDef.h"
|
#include "Engine/Operator/GeometryOpDef.h"
|
||||||
|
|
||||||
|
|
||||||
namespace enzo::op
|
namespace enzo::op
|
||||||
{
|
{
|
||||||
|
struct OpInfo
|
||||||
|
{
|
||||||
|
std::string internalName;
|
||||||
|
std::string displayName;
|
||||||
|
enzo::nt::opConstructor ctorFunc;
|
||||||
|
};
|
||||||
|
|
||||||
class BOOST_SYMBOL_EXPORT OperatorTable
|
class BOOST_SYMBOL_EXPORT OperatorTable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void addOperator(const char* internalName, const char* displayName, nt::opConstructor ctorFunc);
|
static void addOperator(const char* internalName, const char* displayName, nt::opConstructor ctorFunc);
|
||||||
static nt::opConstructor getOpConstructor(size_t pos);
|
static nt::opConstructor getOpConstructor(std::string name);
|
||||||
private:
|
private:
|
||||||
static std::vector<nt::opConstructor> ctorStore_;
|
static std::vector<OpInfo> opInfoStore_;
|
||||||
};
|
};
|
||||||
using addOperatorPtr = void (*)(const char* internalName, const char* displayName, nt::opConstructor ctorFunc);
|
using addOperatorPtr = void (*)(const char* internalName, const char* displayName, nt::opConstructor ctorFunc);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -314,7 +314,7 @@ void Network::keyPressEvent(QKeyEvent *event)
|
|||||||
}
|
}
|
||||||
case(Qt::Key_G):
|
case(Qt::Key_G):
|
||||||
{
|
{
|
||||||
if(auto newNode = createNode(op::OperatorTable::getOpConstructor(1)))
|
if(auto newNode = createNode(op::OperatorTable::getOpConstructor("transform")))
|
||||||
{
|
{
|
||||||
newNode->setPos(viewPos);
|
newNode->setPos(viewPos);
|
||||||
}
|
}
|
||||||
@@ -323,7 +323,7 @@ void Network::keyPressEvent(QKeyEvent *event)
|
|||||||
}
|
}
|
||||||
case(Qt::Key_F):
|
case(Qt::Key_F):
|
||||||
{
|
{
|
||||||
if(auto newNode = createNode(op::OperatorTable::getOpConstructor(0)))
|
if(auto newNode = createNode(op::OperatorTable::getOpConstructor("house")))
|
||||||
{
|
{
|
||||||
newNode->setPos(viewPos);
|
newNode->setPos(viewPos);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user