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) ...@@ -127,3 +127,10 @@ IF(CAMPVIS_DEPLOY_SHADERS)
) )
ENDFOREACH() ENDFOREACH()
ENDIF(CAMPVIS_DEPLOY_SHADERS) 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 { ...@@ -154,6 +154,8 @@ namespace campvis {
// Let Lua know where CAMPVis modules are located // Let Lua know where CAMPVis modules are located
if (! _luaVmState->execString("package.cpath = '" CAMPVIS_LUA_MODS_PATH "'")) if (! _luaVmState->execString("package.cpath = '" CAMPVIS_LUA_MODS_PATH "'"))
LERROR("Error setting up Lua VM."); 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 // Load CAMPVis' core Lua module to have SWIG glue for AutoEvaluationPipeline available
if (! _luaVmState->execString("require(\"campvis\")")) if (! _luaVmState->execString("require(\"campvis\")"))
...@@ -207,6 +209,13 @@ namespace campvis { ...@@ -207,6 +209,13 @@ namespace campvis {
_mainWindow->deinit(); _mainWindow->deinit();
QuadRenderer::deinit(); QuadRenderer::deinit();
// deinit OpenGL and cgt
cgt::deinitGL();
}
// 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: // now delete everything in the right order:
for (std::vector<PipelineRecord>::iterator it = _pipelines.begin(); it != _pipelines.end(); ++it) { for (std::vector<PipelineRecord>::iterator it = _pipelines.begin(); it != _pipelines.end(); ++it) {
delete it->_painter; delete it->_painter;
...@@ -216,13 +225,6 @@ namespace campvis { ...@@ -216,13 +225,6 @@ namespace campvis {
delete *it; delete *it;
} }
// deinit OpenGL and cgt
cgt::deinitGL();
}
// MainWindow dtor needs a valid CampVisApplication, so we need to call it here instead of during destruction.
delete _mainWindow;
GLJobProc.stop(); GLJobProc.stop();
OpenGLJobProcessor::deinit(); OpenGLJobProcessor::deinit();
SimpleJobProcessor::deinit(); SimpleJobProcessor::deinit();
......
...@@ -92,6 +92,9 @@ namespace campvis { ...@@ -92,6 +92,9 @@ namespace campvis {
if (_dataContainer != 0) { if (_dataContainer != 0) {
_dataContainer->s_dataAdded.disconnect(this); _dataContainer->s_dataAdded.disconnect(this);
} }
delete _pcWidget;
_pcWidget = nullptr;
} }
void DataContainerInspectorWidget::setDataContainer(DataContainer* dataContainer) { void DataContainerInspectorWidget::setDataContainer(DataContainer* dataContainer) {
......
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
#include "mainwindow.h" #include "mainwindow.h"
#include "cgt/assert.h" #include "cgt/assert.h"
#include "cgt/opengljobprocessor.h"
#include "application/campvisapplication.h" #include "application/campvisapplication.h"
#include "application/gui/datacontainerinspectorwidget.h" #include "application/gui/datacontainerinspectorwidget.h"
#include "application/gui/datacontainerinspectorcanvas.h" #include "application/gui/datacontainerinspectorcanvas.h"
...@@ -338,6 +340,7 @@ namespace campvis { ...@@ -338,6 +340,7 @@ namespace campvis {
void MainWindow::onLuaCommandExecuted(const QString& cmd) { void MainWindow::onLuaCommandExecuted(const QString& cmd) {
#ifdef CAMPVIS_HAS_SCRIPTING #ifdef CAMPVIS_HAS_SCRIPTING
if (_application->getLuaVmState() != nullptr) { if (_application->getLuaVmState() != nullptr) {
cgt::OpenGLJobProcessor::ScopedSynchronousGlJobExecution jobGuard;
_application->getLuaVmState()->execString(cmd.toStdString()); _application->getLuaVmState()->execString(cmd.toStdString());
} }
#endif #endif
......
...@@ -108,10 +108,24 @@ namespace campvis { ...@@ -108,10 +108,24 @@ namespace campvis {
virtual ~NumericProperty(); virtual ~NumericProperty();
}; };
%template(IntGenericProperty) GenericProperty< int >;
%template(IntProperty) NumericProperty< int >;
typedef NumericProperty< int > IntProperty;
%template(Ivec2GenericProperty) GenericProperty< cgt::Vector2<int> >; %template(Ivec2GenericProperty) GenericProperty< cgt::Vector2<int> >;
%template(IVec2Property) NumericProperty< cgt::Vector2<int> >; %template(IVec2Property) NumericProperty< cgt::Vector2<int> >;
typedef NumericProperty< cgt::Vector2<int> > IVec2Property; 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> template<typename T>
struct FloatingPointPropertyTraits {}; struct FloatingPointPropertyTraits {};
...@@ -144,6 +158,20 @@ namespace campvis { ...@@ -144,6 +158,20 @@ namespace campvis {
%template(FloatProperty) FloatingPointProperty<float>; %template(FloatProperty) FloatingPointProperty<float>;
typedef FloatingPointProperty< float > FloatProperty; 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 */ /* TFGeometry1D */
%nodefaultctor TFGeometry1D; %nodefaultctor TFGeometry1D;
...@@ -265,12 +293,16 @@ namespace campvis { ...@@ -265,12 +293,16 @@ namespace campvis {
/* Downcast the return value of HasPropertyCollection::getProperty to appropriate subclass */ /* Downcast the return value of HasPropertyCollection::getProperty to appropriate subclass */
%factory(AbstractProperty* campvis::HasPropertyCollection::getProperty, %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); campvis::DataNameProperty, campvis::StringProperty, campvis::ButtonProperty, campvis::BoolProperty);
/* Downcast the return value of HasPropertyCollection::getNestedProperty to appropriate subclass */ /* Downcast the return value of HasPropertyCollection::getNestedProperty to appropriate subclass */
%factory(AbstractProperty* campvis::HasPropertyCollection::getNestedProperty, %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); campvis::DataNameProperty, campvis::StringProperty, campvis::ButtonProperty, campvis::BoolProperty);
/* HasPropertyCollection */ /* HasPropertyCollection */
...@@ -302,6 +334,8 @@ namespace campvis { ...@@ -302,6 +334,8 @@ namespace campvis {
void addProperty(AbstractProperty& prop, int invalidationLevel); void addProperty(AbstractProperty& prop, int invalidationLevel);
void setPropertyInvalidationLevel(AbstractProperty& prop, int invalidationLevel); void setPropertyInvalidationLevel(AbstractProperty& prop, int invalidationLevel);
void process(DataContainer& data);
%immutable; %immutable;
sigslot::signal1<AbstractProcessor*> s_validated; sigslot::signal1<AbstractProcessor*> s_validated;
%mutable; %mutable;
...@@ -318,6 +352,10 @@ namespace campvis { ...@@ -318,6 +352,10 @@ namespace campvis {
const DataContainer& getDataContainer() const; const DataContainer& getDataContainer() const;
DataContainer& getDataContainer(); DataContainer& getDataContainer();
virtual void addProcessor(AbstractProcessor* processor);
virtual void executePipeline() = 0;
AbstractProcessor* getProcessor(const std::string& name) const;
}; };
/* AutoEvaluationPipeline */ /* AutoEvaluationPipeline */
......
...@@ -262,4 +262,16 @@ namespace campvis { ...@@ -262,4 +262,16 @@ namespace campvis {
if (_enabled) if (_enabled)
_evaluationCondition.notify_all(); _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 { ...@@ -148,6 +148,13 @@ namespace campvis {
*/ */
const std::vector<AbstractProcessor*>& getProcessors() const; 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. * Gets the flag whether this pipeline is currently enabled.
* \return _enabled * \return _enabled
......
...@@ -111,7 +111,7 @@ namespace campvis { ...@@ -111,7 +111,7 @@ namespace campvis {
if (! success) { if (! success) {
ILenum errorcode; ILenum errorcode;
while ((errorcode = ilGetError()) != IL_NO_ERROR) { 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 ...@@ -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 # 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. # 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_MODS_PATH=\"${CampvisLuaModulesDirectory}?${CMAKE_SHARED_MODULE_SUFFIX}\"")
LIST(APPEND CampvisGlobalDefinitions "-DCAMPVIS_LUA_SCRIPTS_PATH=\"${CampvisLuaModulesDirectory}?.lua\"")
SET(CampvisGlobalDefinitions "${CampvisGlobalDefinitions}" PARENT_SCOPE) SET(CampvisGlobalDefinitions "${CampvisGlobalDefinitions}" PARENT_SCOPE)
SET(CampvisBindingDirs ext/cgt core) 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