Permalink
Browse files

Add Rectangle plugin

Remove duplicate constructors
Add block in constructor
Add block in DXF loading
Make some entities manage TempEntities themselves if required
  • Loading branch information...
feragon committed Jul 21, 2017
1 parent 15774b6 commit 35e494472c65dabbdefa26d0c577d8d8492b4ff2
Showing with 1,568 additions and 824 deletions.
  1. +49 −58 lcDXFDWG/libdxfrw/dxfimpl.cpp
  2. +1 −0 lcDXFDWG/libopencad_interface/libopencad.cpp
  3. +5 −0 lcUI/lua/qtbridge.cpp
  4. +48 −2 lcUI/luainterface.cpp
  5. +9 −0 lcUI/luainterface.h
  6. +9 −9 lcUILua/actions/arcoperations.lua
  7. +9 −9 lcUILua/actions/circleoperations.lua
  8. +6 −6 lcUILua/actions/copyoperation.lua
  9. +12 −12 lcUILua/actions/dimalignedoperations.lua
  10. +12 −12 lcUILua/actions/dimangularoperations.lua
  11. +12 −12 lcUILua/actions/dimdiametricoperations.lua
  12. +12 −12 lcUILua/actions/dimlinearoperations.lua
  13. +12 −12 lcUILua/actions/dimradialoperations.lua
  14. +9 −9 lcUILua/actions/ellipseoperations.lua
  15. +9 −9 lcUILua/actions/lineoperations.lua
  16. +9 −9 lcUILua/actions/lwpolylineoperations.lua
  17. +6 −6 lcUILua/actions/moveoperation.lua
  18. +0 −1 lcUILua/actions/operations.lua
  19. +1 −1 lcUILua/actions/removeoperation.lua
  20. +6 −6 lcUILua/actions/rotateoperation.lua
  21. +6 −6 lcUILua/actions/scaleoperation.lua
  22. +7 −7 lcUILua/actions/splineoperations.lua
  23. +5 −5 lcUILua/actions/trimoperation.lua
  24. +0 −32 lcUILua/kernel/event.lua
  25. +0 −48 lcUILua/kernel/pluginmanager.lua
  26. +1 −11 lcUILua/oldplugins/rectangle/plugin.lua
  27. +351 −0 lcUILua/plugins/rectangle/plugin.lua
  28. 0 lcUILua/plugins/test/plugin.lua
  29. +8 −6 lcUILua/ui/cadmdichild.lua
  30. +5 −5 lcUILua/ui/commandline.lua
  31. +0 −1 lcUILua/ui/init.lua
  32. +24 −23 lcUILua/ui/operations.lua
  33. +23 −5 lcadluascript/builders/customentity.cpp
  34. +11 −3 lcadluascript/builders/customentity.h
  35. +15 −3 lcadluascript/lckernelbridge.cpp
  36. +5 −0 lcadluascript/managers/luacustomentitymanager.cpp
  37. +6 −0 lcadluascript/managers/luacustomentitymanager.h
  38. +7 −12 lcadluascript/managers/pluginmanager.cpp
  39. +5 −4 lcadluascript/managers/pluginmanager.h
  40. +24 −10 lcadluascript/primitive/customentity.cpp
  41. +7 −3 lcadluascript/primitive/customentity.h
  42. +2 −1 lckernel/CMakeLists.txt
  43. +5 −4 lckernel/cad/base/cadentity.cpp
  44. +2 −9 lckernel/cad/base/cadentity.h
  45. +7 −1 lckernel/cad/builders/cadentity.h
  46. +5 −3 lckernel/cad/dochelpers/documentimpl.cpp
  47. +31 −0 lckernel/cad/interface/unmanageddraggable.h
  48. +13 −0 lckernel/cad/operations/blockops.cpp
  49. +1 −1 lckernel/cad/operations/layerops.cpp
  50. +5 −10 lckernel/cad/primitive/arc.cpp
  51. +12 −22 lckernel/cad/primitive/arc.h
  52. +5 −9 lckernel/cad/primitive/circle.cpp
  53. +3 −11 lckernel/cad/primitive/circle.h
  54. +4 −0 lckernel/cad/primitive/customentity.cpp
  55. +4 −3 lckernel/cad/primitive/customentity.h
  56. +56 −10 lckernel/cad/primitive/dimaligned.cpp
  57. +4 −3 lckernel/cad/primitive/dimaligned.h
  58. +48 −11 lckernel/cad/primitive/dimangular.cpp
  59. +4 −3 lckernel/cad/primitive/dimangular.h
  60. +48 −18 lckernel/cad/primitive/dimdiametric.cpp
  61. +21 −22 lckernel/cad/primitive/dimdiametric.h
  62. +66 −10 lckernel/cad/primitive/dimlinear.cpp
  63. +23 −9 lckernel/cad/primitive/dimlinear.h
  64. +42 −17 lckernel/cad/primitive/dimradial.cpp
  65. +22 −20 lckernel/cad/primitive/dimradial.h
  66. +70 −32 lckernel/cad/primitive/ellipse.cpp
  67. +11 −12 lckernel/cad/primitive/ellipse.h
  68. +38 −18 lckernel/cad/primitive/image.cpp
  69. +14 −13 lckernel/cad/primitive/image.h
  70. +9 −3 lckernel/cad/primitive/insert.cpp
  71. +1 −1 lckernel/cad/primitive/insert.h
  72. +22 −12 lckernel/cad/primitive/line.cpp
  73. +11 −13 lckernel/cad/primitive/line.h
  74. +29 −12 lckernel/cad/primitive/lwpolyline.cpp
  75. +18 −12 lckernel/cad/primitive/lwpolyline.h
  76. +15 −11 lckernel/cad/primitive/point.cpp
  77. +7 −12 lckernel/cad/primitive/point.h
  78. +47 −9 lckernel/cad/primitive/spline.cpp
  79. +4 −2 lckernel/cad/primitive/spline.h
  80. +17 −31 lckernel/cad/primitive/text.cpp
  81. +4 −24 lckernel/cad/primitive/text.h
  82. +3 −2 lcviewernoqt/drawitems/lcvdrawitem.cpp
  83. +2 −1 lcviewernoqt/drawitems/lcvdrawitem.h
  84. +42 −18 lcviewernoqt/managers/dragmanager.cpp
  85. +3 −1 lcviewernoqt/managers/dragmanager.h
  86. +6 −3 luacmdinterface/main.cpp
  87. +16 −16 unittest/lckernel/primitive/entitytest.cpp
@@ -158,12 +158,13 @@ void DXFimpl::addEllipse(const DRW_Ellipse& data) {
auto lcEllipse = std::make_shared<lc::entity::Ellipse>(coord(data.basePoint),
coord(data.secPoint),
coord(data.basePoint).distanceTo(coord(data.secPoint)) / data.ratio,
data.staparam, data.endparam,
layer, mf);
if (_currentBlock == nullptr) {
//TODO: block
}
data.staparam,
data.endparam,
data.isccw,
layer,
mf,
_currentBlock
);
_entityBuilder->appendEntity(lcEllipse);
}
@@ -219,11 +220,10 @@ void DXFimpl::addSpline(const DRW_Spline* data) {
data->tgEnd.x, data->tgEnd.y, data->tgEnd.z,
data->normalVec.x, data->normalVec.y, data->normalVec.z,
static_cast<lc::geo::Spline::splineflag>(data->flags),
layer, mf);
if (_currentBlock == nullptr) {
//TODO: block
}
layer,
mf,
_currentBlock
);
_entityBuilder->appendEntity(lcSpline);
}
@@ -240,11 +240,10 @@ void DXFimpl::addText(const DRW_Text& data) {
lc::TextConst::DrawingDirection(data.textgen),
lc::TextConst::HAlign(data.alignH),
lc::TextConst::VAlign(data.alignV),
layer, mf);
if (_currentBlock == nullptr) {
//TODO: block
}
layer,
mf,
_currentBlock
);
_entityBuilder->appendEntity(lcText);
}
@@ -255,12 +254,11 @@ void DXFimpl::addPoint(const DRW_Point& data) {
return;
}
std::shared_ptr<lc::MetaInfo> mf = getMetaInfo(data);
auto lcPoint = std::make_shared<lc::entity::Point>(coord(data.basePoint), layer, mf);
if (_currentBlock == nullptr) {
//TODO: block
}
auto lcPoint = std::make_shared<lc::entity::Point>(coord(data.basePoint),
layer,
mf,
_currentBlock
);
_entityBuilder->appendEntity(lcPoint);
}
@@ -281,11 +279,10 @@ void DXFimpl::addDimAlign(const DRW_DimAligned* data) {
data->getText(),
coord(data->getDef1Point()),
coord(data->getDef2Point()),
layer, mf);
if (_currentBlock == nullptr) {
//TODO: block
}
layer,
mf,
_currentBlock
);
_entityBuilder->appendEntity(lcDimAligned);
}
@@ -308,11 +305,10 @@ void DXFimpl::addDimLinear(const DRW_DimLinear* data) {
coord(data->getDef2Point()),
data->getAngle(),
data->getOblique(),
layer, mf);
if (_currentBlock == nullptr) {
//TODO: block
}
layer,
mf,
_currentBlock
);
_entityBuilder->appendEntity(lcDimLinear);
}
@@ -333,13 +329,11 @@ void DXFimpl::addDimRadial(const DRW_DimRadial* data) {
data->getText(),
coord(data->getDiameterPoint()),
data->getLeaderLength(),
layer, mf
layer,
mf,
_currentBlock
);
if (_currentBlock == nullptr) {
//TODO: block
}
_entityBuilder->appendEntity(lcDimRadial);
}
@@ -359,13 +353,11 @@ void DXFimpl::addDimDiametric(const DRW_DimDiametric* data) {
data->getText(),
coord(data->getDiameter2Point()),
data->getLeaderLength(),
layer, mf
layer,
mf,
_currentBlock
);
if (_currentBlock == nullptr) {
//TODO: block
}
_entityBuilder->appendEntity(lcDimDiametric);
}
@@ -387,13 +379,11 @@ void DXFimpl::addDimAngular(const DRW_DimAngular* data) {
coord(data->getFirstLine2()),
coord(data->getSecondLine1()),
coord(data->getSecondLine2()),
layer, mf
layer,
mf,
_currentBlock
);
if (_currentBlock == nullptr) {
//TODO: block
}
_entityBuilder->appendEntity(lcDimAngular);
}
@@ -421,13 +411,17 @@ void DXFimpl::addLWPolyline(const DRW_LWPolyline& data) {
auto isCLosed = data.flags&0x01;
auto lcLWPolyline = std::make_shared<lc::entity::LWPolyline>(
points, data.width, data.elevation, data.thickness, isCLosed, coord(data.extPoint),layer, mf
points,
data.width,
data.elevation,
data.thickness,
isCLosed,
coord(data.extPoint),
layer,
mf,
_currentBlock
);
if (_currentBlock == nullptr) {
//TODO: block
}
_entityBuilder->appendEntity(lcLWPolyline);
}
@@ -538,13 +532,10 @@ void DXFimpl::linkImage(const DRW_ImageDef *data) {
base, uv, vv,
image->sizeu, image->sizev,
image->brightness, image->contrast, image->fade,
layer, mf
layer,
mf,
_currentBlock
);
if (_currentBlock == nullptr) {
//TODO: block
}
_entityBuilder->appendEntity(lcImage);
image = imageMapCache.erase( image ) ; // advances iter
@@ -125,6 +125,7 @@ void lc::FileLibs::LibOpenCad::addEllipse(lc::Layer_SPtr layer, const CADEllipse
ellipse->getRadius(),
ellipse->getStartingAngle(),
ellipse->getEndingAngle(),
false,
layer,
metaInfo(ellipse)
);
View
@@ -208,6 +208,11 @@ void addLCBindings(lua_State *L) {
.addFunction("luaConnect", &LuaInterface::luaConnect)
.addFunction("connect", &LuaInterface::qtConnect)
.addFunction("pluginList", &LuaInterface::pluginList)
.addFunction("operation", &LuaInterface::operation)
.addFunction("setOperation", &LuaInterface::setOperation)
.addFunction("registerEvent", &LuaInterface::registerEvent)
.addFunction("deleteEvent", &LuaInterface::deleteEvent)
.addFunction("triggerEvent", &LuaInterface::triggerEvent)
.endClass()
.beginExtendClass<LuaScript, QDockWidget>("LuaScript")
View
@@ -1,19 +1,25 @@
#include <lclua.h>
#include <managers/luacustomentitymanager.h>
#include "luainterface.h"
LuaInterface::LuaInterface() :
_L(LuaIntf::LuaState::newState()),
_pluginManager("gui") {
_pluginManager(_L, "gui") {
}
LuaInterface::~LuaInterface() {
_luaQObjects.clear();
_operations.clear();
_events.clear();
lc::LuaCustomEntityManager::getInstance().removePlugins();
_L.close();
}
void LuaInterface::initLua() {
auto lcLua = lc::LCLua(_L);
lcLua.setF_openFileDialog(&LuaInterface::openFileDialog);
lcLua.addLuaLibs();
lcLua.importLCKernel();
@@ -29,7 +35,7 @@ void LuaInterface::initLua() {
lua_pop(_L, 1);
}
_pluginManager.loadPlugins(&LuaInterface::openFileDialog);
_pluginManager.loadPlugins();
}
bool LuaInterface::luaConnect(
@@ -127,3 +133,43 @@ FILE* LuaInterface::openFileDialog(bool isOpening, const char* description, cons
return fopen(path.toStdString().c_str(), mode);
}
LuaIntf::LuaRef LuaInterface::operation(unsigned int windowID) {
if(_operations.find(windowID) != _operations.end()) {
return _operations[windowID];
}
return LuaIntf::LuaRef();
}
void LuaInterface::setOperation(unsigned int windowID, LuaIntf::LuaRef operation) {
_operations[windowID] = operation;
}
void LuaInterface::registerEvent(const std::string& event, LuaIntf::LuaRef callback) {
if(callback.isTable() && !callback.has("onEvent")) {
return;
}
_events[event].push_back(callback);
}
void LuaInterface::deleteEvent(const std::string& event, LuaIntf::LuaRef callback) {
auto it = std::find(_events[event].begin(), _events[event].end(), callback);
if(it != _events[event].end()) {
_events[event].erase(it);
}
}
void LuaInterface::triggerEvent(const std::string& event, LuaIntf::LuaRef args) {
auto events = _events[event];
for(auto eventCallback : events) {
if(eventCallback.isFunction()) {
eventCallback(event, args);
}
else if(eventCallback.isTable()) {
eventCallback.get("onEvent").call(eventCallback, event, args);
}
}
}
View
@@ -96,8 +96,17 @@ class LuaInterface {
static FILE* openFileDialog(bool isOpening, const char* description, const char* mode);
LuaIntf::LuaRef operation(unsigned int windowID);
void setOperation(unsigned int windowID, LuaIntf::LuaRef);
void registerEvent(const std::string& event, LuaIntf::LuaRef callback);
void deleteEvent(const std::string& event, LuaIntf::LuaRef callback);
void triggerEvent(const std::string& event, LuaIntf::LuaRef args);
private:
LuaIntf::LuaState _L;
std::vector<LuaQObject_SPtr> _luaQObjects;
lc::PluginManager _pluginManager;
std::map<unsigned int, LuaIntf::LuaRef> _operations;
std::map<std::string, std::vector<LuaIntf::LuaRef>> _events;
};
@@ -20,7 +20,7 @@ function ArcOperations:_init(id)
self.arc = nil
self.arc_id = ID():id()
event.register('point', self)
luaInterface:registerEvent('point', self)
message("Click on center")
end
@@ -43,8 +43,8 @@ function ArcOperations:newData(point)
self.arc = self:getArc(point, 0, 0, 0)
active_widget():tempEntities():addEntity(self.arc)
event.register('mouseMove', self)
event.register('number', self)
luaInterface:registerEvent('mouseMove', self)
luaInterface:registerEvent('number', self)
message("Click on second point or enter the radius")
elseif(self.radius == nil) then
@@ -104,18 +104,18 @@ function ArcOperations:createArc()
b:appendEntity(a)
b:execute()
event.delete('mouseMove', self)
event.delete('number', self)
event.delete('point', self)
luaInterface:deleteEvent('mouseMove', self)
luaInterface:deleteEvent('number', self)
luaInterface:deleteEvent('point', self)
end
function ArcOperations:close()
if(not self.finished) then
active_widget():tempEntities():removeEntity(self.arc)
self.finished = true
event.delete('mouseMove', self)
event.delete('number', self)
event.delete('point', self)
luaInterface:deleteEvent('mouseMove', self)
luaInterface:deleteEvent('number', self)
luaInterface:deleteEvent('point', self)
end
end
Oops, something went wrong.

0 comments on commit 35e4944

Please sign in to comment.