Commit 7a9d2a7f authored by Christian Schulte zu Berge's avatar Christian Schulte zu Berge
Browse files

* Added Lua bindings for all variants of IVecXProperty and VecXProperty

* Added automatic copy of inspect.lua to binary directory to CMake build scripts
* Added AbstractPipeline::getProcessor(std::string&)
* Added ScopedSynchronousGlJobExecution guard to Lua command execution to ensure having an OpenGL context present
* Fixed ordering in CampvisApplication::deinit()
parent 1f2c60bd
......@@ -127,3 +127,10 @@ IF(CAMPVIS_DEPLOY_SHADERS)
)
ENDFOREACH()
ENDIF(CAMPVIS_DEPLOY_SHADERS)
# copy over Lua stuff
ADD_CUSTOM_COMMAND(
TARGET campvis-application
COMMAND ${CMAKE_COMMAND} -E copy "${CampvisHome}/application/lua/inspect.lua" "$<TARGET_FILE_DIR:campvis-application>/lua-mods/inspect.lua"
)
......@@ -154,6 +154,8 @@ namespace campvis {
// Let Lua know where CAMPVis modules are located
if (! _luaVmState->execString("package.cpath = '" CAMPVIS_LUA_MODS_PATH "'"))
LERROR("Error setting up Lua VM.");
if (! _luaVmState->execString("package.path = package.path .. ';" CAMPVIS_LUA_SCRIPTS_PATH "'"))
LERROR("Error setting up Lua VM.");
// Load CAMPVis' core Lua module to have SWIG glue for AutoEvaluationPipeline available
if (! _luaVmState->execString("require(\"campvis\")"))
......@@ -207,15 +209,6 @@ namespace campvis {
_mainWindow->deinit();
QuadRenderer::deinit();
// now delete everything in the right order:
for (std::vector<PipelineRecord>::iterator it = _pipelines.begin(); it != _pipelines.end(); ++it) {
delete it->_painter;
delete it->_pipeline;
}
for (std::vector<DataContainer*>::iterator it = _dataContainers.begin(); it != _dataContainers.end(); ++it) {
delete *it;
}
// deinit OpenGL and cgt
cgt::deinitGL();
}
......@@ -223,6 +216,15 @@ namespace campvis {
// MainWindow dtor needs a valid CampVisApplication, so we need to call it here instead of during destruction.
delete _mainWindow;
// now delete everything in the right order:
for (std::vector<PipelineRecord>::iterator it = _pipelines.begin(); it != _pipelines.end(); ++it) {
delete it->_painter;
delete it->_pipeline;
}
for (std::vector<DataContainer*>::iterator it = _dataContainers.begin(); it != _dataContainers.end(); ++it) {
delete *it;
}
GLJobProc.stop();
OpenGLJobProcessor::deinit();
SimpleJobProcessor::deinit();
......
......@@ -92,6 +92,9 @@ namespace campvis {
if (_dataContainer != 0) {
_dataContainer->s_dataAdded.disconnect(this);
}
delete _pcWidget;
_pcWidget = nullptr;
}
void DataContainerInspectorWidget::setDataContainer(DataContainer* dataContainer) {
......
......@@ -25,6 +25,8 @@
#include "mainwindow.h"
#include "cgt/assert.h"
#include "cgt/opengljobprocessor.h"
#include "application/campvisapplication.h"
#include "application/gui/datacontainerinspectorwidget.h"
#include "application/gui/datacontainerinspectorcanvas.h"
......@@ -338,6 +340,7 @@ namespace campvis {
void MainWindow::onLuaCommandExecuted(const QString& cmd) {
#ifdef CAMPVIS_HAS_SCRIPTING
if (_application->getLuaVmState() != nullptr) {
cgt::OpenGLJobProcessor::ScopedSynchronousGlJobExecution jobGuard;
_application->getLuaVmState()->execString(cmd.toStdString());
}
#endif
......
......@@ -108,10 +108,24 @@ namespace campvis {
virtual ~NumericProperty();
};
%template(IntGenericProperty) GenericProperty< int >;
%template(IntProperty) NumericProperty< int >;
typedef NumericProperty< int > IntProperty;
%template(Ivec2GenericProperty) GenericProperty< cgt::Vector2<int> >;
%template(IVec2Property) NumericProperty< cgt::Vector2<int> >;
typedef NumericProperty< cgt::Vector2<int> > IVec2Property;
%template(Ivec3GenericProperty) GenericProperty< cgt::Vector3<int> >;
%template(IVec3Property) NumericProperty< cgt::Vector3<int> >;
typedef NumericProperty< cgt::Vector3<int> > IVec3Property;
%template(Ivec4GenericProperty) GenericProperty< cgt::Vector4<int> >;
%template(IVec4Property) NumericProperty< cgt::Vector4<int> >;
typedef NumericProperty< cgt::Vector4<int> > IVec4Property;
template<typename T>
struct FloatingPointPropertyTraits {};
......@@ -144,6 +158,20 @@ namespace campvis {
%template(FloatProperty) FloatingPointProperty<float>;
typedef FloatingPointProperty< float > FloatProperty;
%template(Vec2GenericProperty) GenericProperty< cgt::Vector2<float> >;
%template(Vec2NumericProperty) NumericProperty< cgt::Vector2<float> >;
%template(Vec2Property) FloatingPointProperty< cgt::Vector2<float> >;
typedef FloatingPointProperty< cgt::Vector2<float> > Vec2Property;
%template(Vec3GenericProperty) GenericProperty< cgt::Vector3<float> >;
%template(Vec3NumericProperty) NumericProperty< cgt::Vector3<float> >;
%template(Vec3Property) FloatingPointProperty< cgt::Vector3<float> >;
typedef FloatingPointProperty< cgt::Vector3<float> > Vec3Property;
%template(Vec4GenericProperty) GenericProperty< cgt::Vector4<float> >;
%template(Vec4NumericProperty) NumericProperty< cgt::Vector4<float> >;
%template(Vec4Property) FloatingPointProperty< cgt::Vector4<float> >;
typedef FloatingPointProperty< cgt::Vector4<float> > Vec4Property;
/* TFGeometry1D */
%nodefaultctor TFGeometry1D;
......@@ -265,12 +293,16 @@ namespace campvis {
/* Downcast the return value of HasPropertyCollection::getProperty to appropriate subclass */
%factory(AbstractProperty* campvis::HasPropertyCollection::getProperty,
campvis::FloatProperty, campvis::IVec2Property, campvis::TransferFunctionProperty,
campvis::IntProperty, campvis::IVec2Property, campvis::IVec3Property, campvis::IVec4Property,
campvis::FloatProperty, campvis::Vec2Property, campvis::Vec3Property, campvis::Vec4Property,
campvis::TransferFunctionProperty,
campvis::DataNameProperty, campvis::StringProperty, campvis::ButtonProperty, campvis::BoolProperty);
/* Downcast the return value of HasPropertyCollection::getNestedProperty to appropriate subclass */
%factory(AbstractProperty* campvis::HasPropertyCollection::getNestedProperty,
campvis::FloatProperty, campvis::IVec2Property, campvis::TransferFunctionProperty,
campvis::IntProperty, campvis::IVec2Property, campvis::IVec3Property, campvis::IVec4Property,
campvis::FloatProperty, campvis::Vec2Property, campvis::Vec3Property, campvis::Vec4Property,
campvis::TransferFunctionProperty,
campvis::DataNameProperty, campvis::StringProperty, campvis::ButtonProperty, campvis::BoolProperty);
/* HasPropertyCollection */
......@@ -302,6 +334,8 @@ namespace campvis {
void addProperty(AbstractProperty& prop, int invalidationLevel);
void setPropertyInvalidationLevel(AbstractProperty& prop, int invalidationLevel);
void process(DataContainer& data);
%immutable;
sigslot::signal1<AbstractProcessor*> s_validated;
%mutable;
......@@ -318,6 +352,10 @@ namespace campvis {
const DataContainer& getDataContainer() const;
DataContainer& getDataContainer();
virtual void addProcessor(AbstractProcessor* processor);
virtual void executePipeline() = 0;
AbstractProcessor* getProcessor(const std::string& name) const;
};
/* AutoEvaluationPipeline */
......
......@@ -262,4 +262,16 @@ namespace campvis {
if (_enabled)
_evaluationCondition.notify_all();
}
AbstractProcessor* AbstractPipeline::getProcessor(const std::string& name) const {
for (auto it = _processors.begin(); it != _processors.end(); ++it) {
if ((*it)->getName() == name)
return *it;
}
return nullptr;
}
}
......@@ -148,6 +148,13 @@ namespace campvis {
*/
const std::vector<AbstractProcessor*>& getProcessors() const;
/**
* Returns the first processor of this pipeline whose name matches \a name.
* \param name The name of the processor to find
* \return The first processor whose name matches \a name, 0 if no such processor exists.
*/
AbstractProcessor* getProcessor(const std::string& name) const;
/**
* Gets the flag whether this pipeline is currently enabled.
* \return _enabled
......
......@@ -111,7 +111,7 @@ namespace campvis {
if (! success) {
ILenum errorcode;
while ((errorcode = ilGetError()) != IL_NO_ERROR) {
LERROR("Error while writing '" << filename << "': "<< iluErrorString(errorcode));
LERROR("Error while writing '" << filename << "': "<< (errorcode));
}
}
......
......@@ -31,6 +31,7 @@ SET(CampvisLuaModulesDirectory "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_CFG_IN
# Lua modules will be placed in a sub-directory that won't be picked up by Lua automatically. Let
# the code know via a #define what that sub-directory is so that it can instruct Lua to search it.
LIST(APPEND CampvisGlobalDefinitions "-DCAMPVIS_LUA_MODS_PATH=\"${CampvisLuaModulesDirectory}?${CMAKE_SHARED_MODULE_SUFFIX}\"")
LIST(APPEND CampvisGlobalDefinitions "-DCAMPVIS_LUA_SCRIPTS_PATH=\"${CampvisLuaModulesDirectory}?.lua\"")
SET(CampvisGlobalDefinitions "${CampvisGlobalDefinitions}" PARENT_SCOPE)
SET(CampvisBindingDirs ext/cgt core)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment