Permalink
Browse files

Drag points support in Lua entities

  • Loading branch information...
feragon committed Jul 7, 2017
1 parent d9a68be commit bf661b344756a1ea53e1ff2d3c78b74c3fa23439
@@ -27,7 +27,9 @@ const LuaIntf::LuaRef& CustomEntityBuilder::snapFunction() const {
bool CustomEntityBuilder::checkValues() {
return InsertBuilder::checkValues() &&
_snapFunction.isValid() && _snapFunction.isFunction() &&
_nearestPointFunction.isValid() && _nearestPointFunction.isFunction();
_nearestPointFunction.isValid() && _nearestPointFunction.isFunction() &&
_dragPointsFunction.isValid() && _dragPointsFunction.isFunction();
_newDragPointsFunction.isValid() && _newDragPointsFunction.isFunction();
}
const LuaIntf::LuaRef& CustomEntityBuilder::nearestPointFunction() const {
@@ -38,4 +40,20 @@ void CustomEntityBuilder::setNearestPointFunction(const LuaIntf::LuaRef& nearest
_nearestPointFunction = nearestPointFunction;
}
const LuaIntf::LuaRef& CustomEntityBuilder::dragPointsFunction() const {
return _dragPointsFunction;
}
void CustomEntityBuilder::setDragPointsFunction(const LuaIntf::LuaRef& dragPointsFunction) {
_dragPointsFunction = dragPointsFunction;
}
const LuaIntf::LuaRef& CustomEntityBuilder::newDragPointsFunction() const {
return _newDragPointsFunction;
}
void CustomEntityBuilder::setNewDragPointsFunction(const LuaIntf::LuaRef& setDragPointsFunction) {
_newDragPointsFunction = setDragPointsFunction;
}
@@ -19,13 +19,21 @@ namespace lc {
const LuaIntf::LuaRef& nearestPointFunction() const;
void setNearestPointFunction(const LuaIntf::LuaRef& nearestPointFunction);
const LuaIntf::LuaRef& dragPointsFunction() const;
void setDragPointsFunction(const LuaIntf::LuaRef& dragPointsFunction);
const LuaIntf::LuaRef& newDragPointsFunction() const;
void setNewDragPointsFunction(const LuaIntf::LuaRef& newDragPointsFunction);
bool checkValues() override;
entity::LuaCustomEntity_CSPtr build();
private:
LuaIntf::LuaRef _snapFunction;
LuaIntf::LuaRef _nearestPointFunction;
LuaIntf::LuaRef _dragPointsFunction;
LuaIntf::LuaRef _newDragPointsFunction;
};
}
}
@@ -613,6 +613,10 @@ void LCLua::importLCKernel() {
.addFunction("setSnapFunction", &builder::CustomEntityBuilder::setSnapFunction)
.addFunction("nearestPointFunction", &builder::CustomEntityBuilder::nearestPointFunction)
.addFunction("setNearestPointFunction", &builder::CustomEntityBuilder::setNearestPointFunction)
.addFunction("dragPointsFunction", &builder::CustomEntityBuilder::dragPointsFunction)
.addFunction("setDragPointsFunction", &builder::CustomEntityBuilder::setDragPointsFunction)
.addFunction("newDragPointsFunction", &builder::CustomEntityBuilder::newDragPointsFunction)
.addFunction("setNewDragPointsFunction", &builder::CustomEntityBuilder::setNewDragPointsFunction)
.addFunction("checkValues", &builder::CustomEntityBuilder::checkValues)
.addFunction("build", &builder::CustomEntityBuilder::build)
.endClass()
View
@@ -12,6 +12,7 @@ extern "C" {
namespace LuaIntf {
LUA_USING_SHARED_PTR_TYPE(std::shared_ptr)
LUA_USING_LIST_TYPE(std::vector)
LUA_USING_MAP_TYPE(std::map)
}
namespace lc {
@@ -7,13 +7,17 @@ using namespace entity;
LuaCustomEntity::LuaCustomEntity(const lc::builder::CustomEntityBuilder& builder) :
CustomEntity(builder),
_snapPoints(builder.snapFunction()),
_nearestPoint(builder.nearestPointFunction()) {
_nearestPoint(builder.nearestPointFunction()),
_dragPoints(builder.dragPointsFunction()),
_newDragPoints(builder.newDragPointsFunction()) {
}
LuaCustomEntity::LuaCustomEntity(Insert_CSPtr insert, LuaCustomEntity_CSPtr customEntity, bool sameID) :
CustomEntity(insert, sameID),
_snapPoints(customEntity->_snapPoints),
_nearestPoint(customEntity->_nearestPoint) {
_nearestPoint(customEntity->_nearestPoint),
_dragPoints(customEntity->_dragPoints),
_newDragPoints(customEntity->_newDragPoints) {
}
@@ -66,3 +70,13 @@ CADEntity_CSPtr LuaCustomEntity::mirror(const geo::Coordinate& axis1, const geo:
CADEntity_CSPtr LuaCustomEntity::modify(Layer_CSPtr layer, const MetaInfo_CSPtr metaInfo) const {
return modifyInsert(Insert::modify(layer, metaInfo));
}
std::map<unsigned int, geo::Coordinate> LuaCustomEntity::dragPoints() const {
auto dragPointsDupl = _dragPoints;
return dragPointsDupl.call<std::map<unsigned int, geo::Coordinate>>();
}
CADEntity_CSPtr LuaCustomEntity::setDragPoints(std::map<unsigned int, lc::geo::Coordinate> dragPoints) const {
auto newDragPointsDupl = _newDragPoints;
return newDragPointsDupl.call<CADEntity_CSPtr>(dragPoints);
}
@@ -24,6 +24,9 @@ namespace lc {
virtual geo::Coordinate nearestPointOnPath(const geo::Coordinate& coord) const override;
std::map<unsigned int, geo::Coordinate> dragPoints() const override;
CADEntity_CSPtr setDragPoints(std::map<unsigned int, lc::geo::Coordinate> dragPoints) const override;
CADEntity_CSPtr modifyInsert(CADEntity_CSPtr insert) const;
CADEntity_CSPtr move(const geo::Coordinate& offset) const override;
CADEntity_CSPtr copy(const geo::Coordinate& offset) const override;
@@ -35,6 +38,8 @@ namespace lc {
private:
LuaIntf::LuaRef _snapPoints;
LuaIntf::LuaRef _nearestPoint;
LuaIntf::LuaRef _dragPoints;
LuaIntf::LuaRef _newDragPoints;
};
DECLARE_SHORT_SHARED_PTR(LuaCustomEntity)
@@ -16,6 +16,9 @@ namespace lc {
virtual geo::Coordinate nearestPointOnPath(const geo::Coordinate& coord) const override = 0;
virtual std::map<unsigned int, geo::Coordinate> dragPoints() const override = 0;
virtual CADEntity_CSPtr setDragPoints(std::map<unsigned int, lc::geo::Coordinate> dragPoints) const override = 0;
virtual CADEntity_CSPtr move(const geo::Coordinate& offset) const override = 0;
virtual CADEntity_CSPtr copy(const geo::Coordinate& offset) const override = 0;
virtual CADEntity_CSPtr rotate(const geo::Coordinate& rotation_center, const double rotation_angle) const override = 0;

0 comments on commit bf661b3

Please sign in to comment.