From 11eb2e3d151760b860e4258a1145b739460a5ed2 Mon Sep 17 00:00:00 2001 From: Pierre Kraemer Date: Mon, 21 Jan 2013 17:40:09 +0100 Subject: [PATCH] PythonSCHNApps is coming.. --- SCHNApps/CMakeLists.txt | 6 ++++ SCHNApps/Debug/CMakeLists.txt | 5 +++- .../differentialProperties/CMakeLists.txt | 2 -- SCHNApps/Plugins/importSurface/CMakeLists.txt | 2 -- SCHNApps/Plugins/render/CMakeLists.txt | 2 -- SCHNApps/Plugins/renderVector/CMakeLists.txt | 2 -- .../Plugins/subdivideSurface/CMakeLists.txt | 2 -- SCHNApps/Release/CMakeLists.txt | 5 +++- SCHNApps/build/python/setup.py | 16 ---------- SCHNApps/build/python/window_py.cpp | 17 ----------- SCHNApps/deprecated/system.cpp | 25 ---------------- SCHNApps/deprecated/system.h | 29 ------------------- SCHNApps/deprecated/vboHandler.cpp | 0 SCHNApps/deprecated/vboHandler.h | 29 ------------------- SCHNApps/include/plugin.h | 4 +-- SCHNApps/include/types.h | 6 ++-- SCHNApps/include/window.h | 17 +++++------ SCHNApps/main.py | 14 --------- SCHNApps/src/dialogs/pluginsDialog.cpp | 4 +-- SCHNApps/src/main.cpp | 27 ++++++++++++----- SCHNApps/src/window.cpp | 16 +++------- 21 files changed, 52 insertions(+), 178 deletions(-) delete mode 100644 SCHNApps/build/python/setup.py delete mode 100644 SCHNApps/build/python/window_py.cpp delete mode 100644 SCHNApps/deprecated/system.cpp delete mode 100644 SCHNApps/deprecated/system.h delete mode 100644 SCHNApps/deprecated/vboHandler.cpp delete mode 100644 SCHNApps/deprecated/vboHandler.h delete mode 100644 SCHNApps/main.py diff --git a/SCHNApps/CMakeLists.txt b/SCHNApps/CMakeLists.txt index 068b45b3b..51d7ae703 100644 --- a/SCHNApps/CMakeLists.txt +++ b/SCHNApps/CMakeLists.txt @@ -21,8 +21,14 @@ find_package(Qt4 REQUIRED) find_package(QGLViewer REQUIRED) +#=======Python=========# +find_package(PythonLibs REQUIRED) + + + #======SCHNApps=======# SET(SCHNApps_ROOT_DIR ${CGoGN_ROOT_DIR}/SCHNApps) +SET(EXECUTABLE_OUTPUT_PATH ${SCHNApps_ROOT_DIR}/bin) SET(LIBRARY_OUTPUT_PATH ${SCHNApps_ROOT_DIR}/lib) ADD_SUBDIRECTORY(${CMAKE_SOURCE_DIR}/Release Release) diff --git a/SCHNApps/Debug/CMakeLists.txt b/SCHNApps/Debug/CMakeLists.txt index 3e9d07b57..480316816 100644 --- a/SCHNApps/Debug/CMakeLists.txt +++ b/SCHNApps/Debug/CMakeLists.txt @@ -14,12 +14,14 @@ INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${QGLVIEWER_INCLUDE_DIR} + ${PYTHON_INCLUDE_DIRS} ${SCHNApps_ROOT_DIR}/include ) file( GLOB SCHNApps_SRC_FILES + ${SCHNApps_ROOT_DIR}/src/main.cpp ${SCHNApps_ROOT_DIR}/src/camera.cpp ${SCHNApps_ROOT_DIR}/src/mapHandler.cpp ${SCHNApps_ROOT_DIR}/src/plugin.cpp @@ -68,7 +70,7 @@ QT4_ADD_RESOURCES( RCC_FILES ${SCHNApps_ROOT_DIR}/resources/resources.qrc ) -ADD_LIBRARY( SCHNAppsD SHARED +ADD_EXECUTABLE( SCHNAppsD ${SCHNApps_SRC_FILES} ${UI_H_FILES} ${MOC_FILES} @@ -79,6 +81,7 @@ TARGET_LINK_LIBRARIES( SCHNAppsD ${CGoGN_LIBS_D} ${COMMON_LIBS} ${QGLVIEWER_LIBRARIES} + PythonQt ) diff --git a/SCHNApps/Plugins/differentialProperties/CMakeLists.txt b/SCHNApps/Plugins/differentialProperties/CMakeLists.txt index a15fcca36..4bd803a74 100644 --- a/SCHNApps/Plugins/differentialProperties/CMakeLists.txt +++ b/SCHNApps/Plugins/differentialProperties/CMakeLists.txt @@ -43,7 +43,6 @@ IF( ${CMAKE_BUILD_TYPE} STREQUAL Debug ) ) TARGET_LINK_LIBRARIES( DifferentialPropertiesPluginD - ${LIBRARY_OUTPUT_PATH}/libSCHNApps.so ${CGoGN_LIBS_D} ${COMMON_LIBS} ${QGLVIEWER_LIBRARIES} @@ -71,7 +70,6 @@ ELSE ( ${CMAKE_BUILD_TYPE} STREQUAL Debug ) ) TARGET_LINK_LIBRARIES( DifferentialPropertiesPlugin - ${LIBRARY_OUTPUT_PATH}/libSCHNApps.so ${CGoGN_LIBS_R} ${COMMON_LIBS} ${QGLVIEWER_LIBRARIES} diff --git a/SCHNApps/Plugins/importSurface/CMakeLists.txt b/SCHNApps/Plugins/importSurface/CMakeLists.txt index eba0f7005..e68317ba4 100644 --- a/SCHNApps/Plugins/importSurface/CMakeLists.txt +++ b/SCHNApps/Plugins/importSurface/CMakeLists.txt @@ -34,7 +34,6 @@ IF( ${CMAKE_BUILD_TYPE} STREQUAL Debug ) ) TARGET_LINK_LIBRARIES( ImportSurfacePluginD - ${LIBRARY_OUTPUT_PATH}/libSCHNApps.so ${CGoGN_LIBS_D} ${COMMON_LIBS} ${QGLVIEWER_LIBRARIES} @@ -62,7 +61,6 @@ ELSE ( ${CMAKE_BUILD_TYPE} STREQUAL Debug ) ) TARGET_LINK_LIBRARIES( ImportSurfacePlugin - ${LIBRARY_OUTPUT_PATH}/libSCHNApps.so ${CGoGN_LIBS_R} ${COMMON_LIBS} ${QGLVIEWER_LIBRARIES} diff --git a/SCHNApps/Plugins/render/CMakeLists.txt b/SCHNApps/Plugins/render/CMakeLists.txt index bebd4aed9..8647a02ad 100644 --- a/SCHNApps/Plugins/render/CMakeLists.txt +++ b/SCHNApps/Plugins/render/CMakeLists.txt @@ -38,7 +38,6 @@ IF( ${CMAKE_BUILD_TYPE} STREQUAL Debug ) ) TARGET_LINK_LIBRARIES( RenderPluginD - ${LIBRARY_OUTPUT_PATH}/libSCHNApps.so ${CGoGN_LIBS_D} ${COMMON_LIBS} ${QGLVIEWER_LIBRARIES} @@ -66,7 +65,6 @@ ELSE ( ${CMAKE_BUILD_TYPE} STREQUAL Debug ) ) TARGET_LINK_LIBRARIES( RenderPlugin - ${LIBRARY_OUTPUT_PATH}/libSCHNApps.so ${CGoGN_LIBS_R} ${COMMON_LIBS} ${QGLVIEWER_LIBRARIES} diff --git a/SCHNApps/Plugins/renderVector/CMakeLists.txt b/SCHNApps/Plugins/renderVector/CMakeLists.txt index eb5154030..b38227f98 100644 --- a/SCHNApps/Plugins/renderVector/CMakeLists.txt +++ b/SCHNApps/Plugins/renderVector/CMakeLists.txt @@ -38,7 +38,6 @@ IF( ${CMAKE_BUILD_TYPE} STREQUAL Debug ) ) TARGET_LINK_LIBRARIES( RenderVectorPluginD - ${LIBRARY_OUTPUT_PATH}/libSCHNApps.so ${CGoGN_LIBS_D} ${COMMON_LIBS} ${QGLVIEWER_LIBRARIES} @@ -66,7 +65,6 @@ ELSE ( ${CMAKE_BUILD_TYPE} STREQUAL Debug ) ) TARGET_LINK_LIBRARIES( RenderVectorPlugin - ${LIBRARY_OUTPUT_PATH}/libSCHNApps.so ${CGoGN_LIBS_R} ${COMMON_LIBS} ${QGLVIEWER_LIBRARIES} diff --git a/SCHNApps/Plugins/subdivideSurface/CMakeLists.txt b/SCHNApps/Plugins/subdivideSurface/CMakeLists.txt index bc14ceab1..724d0d1ed 100644 --- a/SCHNApps/Plugins/subdivideSurface/CMakeLists.txt +++ b/SCHNApps/Plugins/subdivideSurface/CMakeLists.txt @@ -38,7 +38,6 @@ IF( ${CMAKE_BUILD_TYPE} STREQUAL Debug ) ) TARGET_LINK_LIBRARIES( SubdivideSurfacePluginD - ${LIBRARY_OUTPUT_PATH}/libSCHNApps.so ${CGoGN_LIBS_D} ${COMMON_LIBS} ${QGLVIEWER_LIBRARIES} @@ -66,7 +65,6 @@ ELSE ( ${CMAKE_BUILD_TYPE} STREQUAL Debug ) ) TARGET_LINK_LIBRARIES( SubdivideSurfacePlugin - ${LIBRARY_OUTPUT_PATH}/libSCHNApps.so ${CGoGN_LIBS_R} ${COMMON_LIBS} ${QGLVIEWER_LIBRARIES} diff --git a/SCHNApps/Release/CMakeLists.txt b/SCHNApps/Release/CMakeLists.txt index 83bccb6c9..57ad489d3 100644 --- a/SCHNApps/Release/CMakeLists.txt +++ b/SCHNApps/Release/CMakeLists.txt @@ -14,12 +14,14 @@ INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${QGLVIEWER_INCLUDE_DIR} + ${PYTHON_INCLUDE_DIRS} ${SCHNApps_ROOT_DIR}/include ) file( GLOB SCHNApps_SRC_FILES + ${SCHNApps_ROOT_DIR}/src/main.cpp ${SCHNApps_ROOT_DIR}/src/camera.cpp ${SCHNApps_ROOT_DIR}/src/mapHandler.cpp ${SCHNApps_ROOT_DIR}/src/plugin.cpp @@ -68,7 +70,7 @@ QT4_ADD_RESOURCES( RCC_FILES ${SCHNApps_ROOT_DIR}/resources/resources.qrc ) -ADD_LIBRARY( SCHNApps SHARED +ADD_EXECUTABLE( SCHNApps ${SCHNApps_SRC_FILES} ${UI_H_FILES} ${MOC_FILES} @@ -79,6 +81,7 @@ TARGET_LINK_LIBRARIES( SCHNApps ${CGoGN_LIBS_R} ${COMMON_LIBS} ${QGLVIEWER_LIBRARIES} + PythonQt ) diff --git a/SCHNApps/build/python/setup.py b/SCHNApps/build/python/setup.py deleted file mode 100644 index b305566a9..000000000 --- a/SCHNApps/build/python/setup.py +++ /dev/null @@ -1,16 +0,0 @@ -from distutils.core import setup, Extension - -ext = Extension( - 'PySCHNApps', - library_dirs=['/usr/lib', 'usr/local/lib', '../../lib'], - libraries=['python2.7','boost_python-py27', 'SCHNApps'], - include_dirs=['../../include', '../../build/Release', '../../../include', '/usr/include/qt4', '/usr/include/libxml2'], - sources = ['window_py.cpp'] -) - -setup( - name = 'PySCHNApps', - version = '1.0', - description = 'SCHNApps from Python', - ext_modules = [ext] -) diff --git a/SCHNApps/build/python/window_py.cpp b/SCHNApps/build/python/window_py.cpp deleted file mode 100644 index 7c8be84d6..000000000 --- a/SCHNApps/build/python/window_py.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include -#include -#include - -#include "plugin.h" -#include "window.h" - -using namespace boost::python; - -BOOST_PYTHON_MODULE(PySCHNApps) -{ - class_("Window") - .def(init<>()) - .def("launch", &CGoGN::SCHNApps::Window::launch) - .def("loadPlugin", &CGoGN::SCHNApps::Window::loadPlugin_py) - ; -} diff --git a/SCHNApps/deprecated/system.cpp b/SCHNApps/deprecated/system.cpp deleted file mode 100644 index 363519c08..000000000 --- a/SCHNApps/deprecated/system.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "system.h" - -#include -#include -#include -#include -#include -#include - -namespace CGoGN -{ - -namespace SCHNApps -{ - -namespace System -{ - - - -} // namespace System - -} // namespace SCHNApps - -} // namespace CGoGN diff --git a/SCHNApps/deprecated/system.h b/SCHNApps/deprecated/system.h deleted file mode 100644 index 9aacdf625..000000000 --- a/SCHNApps/deprecated/system.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef _SYSTEM_H_ -#define _SYSTEM_H_ - -#include -#include - -#include "types.h" - -namespace CGoGN -{ - -namespace SCHNApps -{ - -class Window; -class SplitArea; - -namespace System -{ - - - -} // namespace System - -} // namespace SCHNApps - -} // namespace CGoGN - -#endif diff --git a/SCHNApps/deprecated/vboHandler.cpp b/SCHNApps/deprecated/vboHandler.cpp deleted file mode 100644 index e69de29bb..000000000 diff --git a/SCHNApps/deprecated/vboHandler.h b/SCHNApps/deprecated/vboHandler.h deleted file mode 100644 index 6586fcba9..000000000 --- a/SCHNApps/deprecated/vboHandler.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef _VBOHANDLER_H_ -#define _VBOHANDLER_H_ - -#include "Utils/vbo.h" - -class VBOHandler -{ -public: - VBOHandler(const QString& name, CGoGN::Utils::VBO* vbo) : - m_name(name), - m_vbo(vbo) - {} - - ~VBOHandler() - { - delete m_vbo; - } - - const QString& getName() { return m_name; } - void setName(const QString& name) { m_name = name; } - - CGoGN::Utils::VBO* getVBO() { return m_vbo; } - -protected: - QString m_name; - CGoGN::Utils::VBO* m_vbo; -}; - -#endif diff --git a/SCHNApps/include/plugin.h b/SCHNApps/include/plugin.h index d1e5150b4..a2e257dd8 100644 --- a/SCHNApps/include/plugin.h +++ b/SCHNApps/include/plugin.h @@ -1,8 +1,8 @@ #ifndef _PLUGIN_H_ #define _PLUGIN_H_ -#include -#include +#include +#include #include "types.h" diff --git a/SCHNApps/include/types.h b/SCHNApps/include/types.h index c0ab37900..4cadd9f9d 100644 --- a/SCHNApps/include/types.h +++ b/SCHNApps/include/types.h @@ -1,9 +1,9 @@ #ifndef _TYPES_H_ #define _TYPES_H_ -#include -#include -#include +#include +#include +#include #include "Topology/generic/parameters.h" #include "Topology/map/embeddedMap2.h" diff --git a/SCHNApps/include/window.h b/SCHNApps/include/window.h index 873323c28..9353cbe46 100644 --- a/SCHNApps/include/window.h +++ b/SCHNApps/include/window.h @@ -3,6 +3,7 @@ #include "ui_window.h" +#include "PythonQt/PythonQt.h" #include "types.h" class QVBoxLayout; @@ -29,9 +30,7 @@ public: * \fn Window() * \brief Constructor */ - Window(); - - Window(const Window& w); + Window(const QString& appPath, PythonQtObjectPtr& pythonContext); /** * \fn ~Window() @@ -39,11 +38,6 @@ public: */ ~Window(); - void launch() - { - this->QMainWindow::show(); - } - const QString& getAppPath() { return m_appPath; } /********************************************************* @@ -206,8 +200,7 @@ public: * \see getPlugins() * \see Plugin::enable() */ - Plugin* loadPlugin(const QString& pluginFilePath); - void loadPlugin_py(std::string path); +// Plugin* loadPlugin(const QString& pluginFilePath); /** * \fn void unloadPlugin(QString pluginName) @@ -274,6 +267,7 @@ public: protected: QString m_appPath; + PythonQtObjectPtr& m_pythonContext; bool m_initialization; @@ -299,6 +293,9 @@ protected: MapsDialog* m_mapsDialog; public slots: + + Plugin* loadPlugin(const QString& pluginFilePath); + /** * \fn void cb_about_SCHNApps(); * \brief function that is called when the "about SCHNApps" menu action is triggered diff --git a/SCHNApps/main.py b/SCHNApps/main.py deleted file mode 100644 index 230965db8..000000000 --- a/SCHNApps/main.py +++ /dev/null @@ -1,14 +0,0 @@ - -import sys -from PyQt4 import QtGui -import PySCHNApps - - -if __name__ == '__main__': - app = QtGui.QApplication(sys.argv) - - window = PySCHNApps.Window() - window.launch() -# window.loadPlugin("/home/kraemer/Dev/CGoGN/SCHNApps/lib/libRenderPlugin.so") - - sys.exit(app.exec_()) diff --git a/SCHNApps/src/dialogs/pluginsDialog.cpp b/SCHNApps/src/dialogs/pluginsDialog.cpp index 747a5f341..d21872be1 100644 --- a/SCHNApps/src/dialogs/pluginsDialog.cpp +++ b/SCHNApps/src/dialogs/pluginsDialog.cpp @@ -43,7 +43,7 @@ PluginsDialog::PluginsDialog(Window* window) : // restoreState(); - addPluginsDirectory(m_window->getAppPath() + QString("/lib/")); + addPluginsDirectory(m_window->getAppPath() + QString("../lib/")); init = false; } @@ -231,7 +231,7 @@ void PluginsDialog::cb_addPluginsDirectory() QString dir = QFileDialog::getExistingDirectory( this, tr("Select a directory"), - m_window->getAppPath() + QString("/lib/"), + m_window->getAppPath() + QString("../lib/"), QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks ); diff --git a/SCHNApps/src/main.cpp b/SCHNApps/src/main.cpp index d658c76bc..5b49b9c1d 100644 --- a/SCHNApps/src/main.cpp +++ b/SCHNApps/src/main.cpp @@ -1,19 +1,32 @@ #include +#include "PythonQt/PythonQt.h" +#include "PythonQt/PythonQtScriptingConsole.h" #include "window.h" int main(int argc, char* argv[]) { QApplication app(argc, argv); -// QSplashScreen* splash = new QSplashScreen(QPixmap(":splash/cgogn/splash.png")); -// splash->show(); -// splash->showMessage("Welcome to SCHNApps", Qt::AlignBottom | Qt::AlignCenter); + QSplashScreen* splash = new QSplashScreen(QPixmap(":splash/cgogn/splash.png")); + splash->show(); + splash->showMessage("Welcome to SCHNApps", Qt::AlignBottom | Qt::AlignCenter); - CGoGN::SCHNApps::Window window(app.applicationDirPath()); + // init PythonQt and Python itself + PythonQt::init(); + + // get a smart pointer to the __main__ module of the Python interpreter + PythonQtObjectPtr pythonContext = PythonQt::self()->getMainModule(); + + CGoGN::SCHNApps::Window window(app.applicationDirPath(), pythonContext); window.show(); -// splash->finish(&window); -// delete splash; - + pythonContext.addObject("window", &window); + + splash->finish(&window); + delete splash; + + PythonQtScriptingConsole pythonConsole(NULL, pythonContext); + pythonConsole.show(); + return app.exec(); } diff --git a/SCHNApps/src/window.cpp b/SCHNApps/src/window.cpp index d25ac5374..fb7d7ea66 100644 --- a/SCHNApps/src/window.cpp +++ b/SCHNApps/src/window.cpp @@ -26,9 +26,10 @@ namespace CGoGN namespace SCHNApps { -Window::Window() : +Window::Window(const QString& appPath, PythonQtObjectPtr& pythonContext) : QMainWindow(), - m_appPath("/home/kraemer/Dev/CGoGN/SCHNApps"), + m_appPath(appPath), + m_pythonContext(pythonContext), m_firstView(NULL), m_currentView(NULL) { @@ -80,11 +81,8 @@ Window::Window() : // program in its initialization phase m_initialization = false; -} -Window::Window(const Window& w) -{ - std::cout << "hiohoihoih" << std::endl; + m_pythonContext.addObject("dock", m_dock); } Window::~Window() @@ -466,12 +464,6 @@ Plugin* Window::loadPlugin(const QString& pluginFilePath) } } -void Window::loadPlugin_py(std::string path) -{ - QString p(QString::fromStdString(path)); - loadPlugin(p); -} - void Window::unloadPlugin(const QString& pluginName) { if (h_plugins.contains(pluginName)) -- GitLab