feat: Added PyG2O python library
This commit is contained in:
@@ -115,3 +115,11 @@ add_custom_command(
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-E copy_directory ${CPYTHON_STDLIB_DIR} $<TARGET_FILE_DIR:${PROJECT_NAME}>/lib
|
||||
)
|
||||
|
||||
# Copy the PyG2O library into the build/lib folder
|
||||
add_custom_command(
|
||||
TARGET ${PROJECT_NAME}
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-E copy_directory ${CMAKE_SOURCE_DIR}/g2o $<TARGET_FILE_DIR:${PROJECT_NAME}>/lib/g2o
|
||||
)
|
||||
5
g2o/__init__.py
Normal file
5
g2o/__init__.py
Normal file
@@ -0,0 +1,5 @@
|
||||
|
||||
from g2o.events import addEvent
|
||||
from g2o.events import callEvent
|
||||
from g2o.events import event
|
||||
from g2o.events import removeEventHandler
|
||||
36
g2o/events.py
Normal file
36
g2o/events.py
Normal file
@@ -0,0 +1,36 @@
|
||||
|
||||
eventList = {}
|
||||
|
||||
def callEvent(name, **args):
|
||||
if name in eventList:
|
||||
for event in eventList[name]:
|
||||
event['function'](**args)
|
||||
|
||||
def addEvent(name):
|
||||
if not name in eventList:
|
||||
eventList[name] = []
|
||||
|
||||
def event(name, priority = 9999):
|
||||
def inlineEvt(func):
|
||||
if not name in eventList:
|
||||
pass
|
||||
|
||||
eventList[name].append({'function': func, 'priority': priority})
|
||||
eventList[name].sort(key = lambda x: x['priority'])
|
||||
return func
|
||||
return inlineEvt
|
||||
|
||||
def removeEventHandler(name, func):
|
||||
if not name in eventList:
|
||||
pass
|
||||
|
||||
for index, item in enumerate(eventList[name]):
|
||||
if item['function'] == func:
|
||||
del eventList[name][index]
|
||||
|
||||
## registering all the events
|
||||
|
||||
addEvent('onInit')
|
||||
addEvent('onExit')
|
||||
addEvent('onTick')
|
||||
addEvent('onTime')
|
||||
Reference in New Issue
Block a user