Commit 11eb2e3d authored by Pierre Kraemer's avatar Pierre Kraemer

PythonSCHNApps is coming..

parent 170fedde
...@@ -21,8 +21,14 @@ find_package(Qt4 REQUIRED) ...@@ -21,8 +21,14 @@ find_package(Qt4 REQUIRED)
find_package(QGLViewer REQUIRED) find_package(QGLViewer REQUIRED)
#=======Python=========#
find_package(PythonLibs REQUIRED)
#======SCHNApps=======# #======SCHNApps=======#
SET(SCHNApps_ROOT_DIR ${CGoGN_ROOT_DIR}/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) SET(LIBRARY_OUTPUT_PATH ${SCHNApps_ROOT_DIR}/lib)
ADD_SUBDIRECTORY(${CMAKE_SOURCE_DIR}/Release Release) ADD_SUBDIRECTORY(${CMAKE_SOURCE_DIR}/Release Release)
......
...@@ -14,12 +14,14 @@ INCLUDE_DIRECTORIES( ...@@ -14,12 +14,14 @@ INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}
${QGLVIEWER_INCLUDE_DIR} ${QGLVIEWER_INCLUDE_DIR}
${PYTHON_INCLUDE_DIRS}
${SCHNApps_ROOT_DIR}/include ${SCHNApps_ROOT_DIR}/include
) )
file( file(
GLOB GLOB
SCHNApps_SRC_FILES SCHNApps_SRC_FILES
${SCHNApps_ROOT_DIR}/src/main.cpp
${SCHNApps_ROOT_DIR}/src/camera.cpp ${SCHNApps_ROOT_DIR}/src/camera.cpp
${SCHNApps_ROOT_DIR}/src/mapHandler.cpp ${SCHNApps_ROOT_DIR}/src/mapHandler.cpp
${SCHNApps_ROOT_DIR}/src/plugin.cpp ${SCHNApps_ROOT_DIR}/src/plugin.cpp
...@@ -68,7 +70,7 @@ QT4_ADD_RESOURCES( RCC_FILES ...@@ -68,7 +70,7 @@ QT4_ADD_RESOURCES( RCC_FILES
${SCHNApps_ROOT_DIR}/resources/resources.qrc ${SCHNApps_ROOT_DIR}/resources/resources.qrc
) )
ADD_LIBRARY( SCHNAppsD SHARED ADD_EXECUTABLE( SCHNAppsD
${SCHNApps_SRC_FILES} ${SCHNApps_SRC_FILES}
${UI_H_FILES} ${UI_H_FILES}
${MOC_FILES} ${MOC_FILES}
...@@ -79,6 +81,7 @@ TARGET_LINK_LIBRARIES( SCHNAppsD ...@@ -79,6 +81,7 @@ TARGET_LINK_LIBRARIES( SCHNAppsD
${CGoGN_LIBS_D} ${CGoGN_LIBS_D}
${COMMON_LIBS} ${COMMON_LIBS}
${QGLVIEWER_LIBRARIES} ${QGLVIEWER_LIBRARIES}
PythonQt
) )
......
...@@ -43,7 +43,6 @@ IF( ${CMAKE_BUILD_TYPE} STREQUAL Debug ) ...@@ -43,7 +43,6 @@ IF( ${CMAKE_BUILD_TYPE} STREQUAL Debug )
) )
TARGET_LINK_LIBRARIES( DifferentialPropertiesPluginD TARGET_LINK_LIBRARIES( DifferentialPropertiesPluginD
${LIBRARY_OUTPUT_PATH}/libSCHNApps.so
${CGoGN_LIBS_D} ${CGoGN_LIBS_D}
${COMMON_LIBS} ${COMMON_LIBS}
${QGLVIEWER_LIBRARIES} ${QGLVIEWER_LIBRARIES}
...@@ -71,7 +70,6 @@ ELSE ( ${CMAKE_BUILD_TYPE} STREQUAL Debug ) ...@@ -71,7 +70,6 @@ ELSE ( ${CMAKE_BUILD_TYPE} STREQUAL Debug )
) )
TARGET_LINK_LIBRARIES( DifferentialPropertiesPlugin TARGET_LINK_LIBRARIES( DifferentialPropertiesPlugin
${LIBRARY_OUTPUT_PATH}/libSCHNApps.so
${CGoGN_LIBS_R} ${CGoGN_LIBS_R}
${COMMON_LIBS} ${COMMON_LIBS}
${QGLVIEWER_LIBRARIES} ${QGLVIEWER_LIBRARIES}
......
...@@ -34,7 +34,6 @@ IF( ${CMAKE_BUILD_TYPE} STREQUAL Debug ) ...@@ -34,7 +34,6 @@ IF( ${CMAKE_BUILD_TYPE} STREQUAL Debug )
) )
TARGET_LINK_LIBRARIES( ImportSurfacePluginD TARGET_LINK_LIBRARIES( ImportSurfacePluginD
${LIBRARY_OUTPUT_PATH}/libSCHNApps.so
${CGoGN_LIBS_D} ${CGoGN_LIBS_D}
${COMMON_LIBS} ${COMMON_LIBS}
${QGLVIEWER_LIBRARIES} ${QGLVIEWER_LIBRARIES}
...@@ -62,7 +61,6 @@ ELSE ( ${CMAKE_BUILD_TYPE} STREQUAL Debug ) ...@@ -62,7 +61,6 @@ ELSE ( ${CMAKE_BUILD_TYPE} STREQUAL Debug )
) )
TARGET_LINK_LIBRARIES( ImportSurfacePlugin TARGET_LINK_LIBRARIES( ImportSurfacePlugin
${LIBRARY_OUTPUT_PATH}/libSCHNApps.so
${CGoGN_LIBS_R} ${CGoGN_LIBS_R}
${COMMON_LIBS} ${COMMON_LIBS}
${QGLVIEWER_LIBRARIES} ${QGLVIEWER_LIBRARIES}
......
...@@ -38,7 +38,6 @@ IF( ${CMAKE_BUILD_TYPE} STREQUAL Debug ) ...@@ -38,7 +38,6 @@ IF( ${CMAKE_BUILD_TYPE} STREQUAL Debug )
) )
TARGET_LINK_LIBRARIES( RenderPluginD TARGET_LINK_LIBRARIES( RenderPluginD
${LIBRARY_OUTPUT_PATH}/libSCHNApps.so
${CGoGN_LIBS_D} ${CGoGN_LIBS_D}
${COMMON_LIBS} ${COMMON_LIBS}
${QGLVIEWER_LIBRARIES} ${QGLVIEWER_LIBRARIES}
...@@ -66,7 +65,6 @@ ELSE ( ${CMAKE_BUILD_TYPE} STREQUAL Debug ) ...@@ -66,7 +65,6 @@ ELSE ( ${CMAKE_BUILD_TYPE} STREQUAL Debug )
) )
TARGET_LINK_LIBRARIES( RenderPlugin TARGET_LINK_LIBRARIES( RenderPlugin
${LIBRARY_OUTPUT_PATH}/libSCHNApps.so
${CGoGN_LIBS_R} ${CGoGN_LIBS_R}
${COMMON_LIBS} ${COMMON_LIBS}
${QGLVIEWER_LIBRARIES} ${QGLVIEWER_LIBRARIES}
......
...@@ -38,7 +38,6 @@ IF( ${CMAKE_BUILD_TYPE} STREQUAL Debug ) ...@@ -38,7 +38,6 @@ IF( ${CMAKE_BUILD_TYPE} STREQUAL Debug )
) )
TARGET_LINK_LIBRARIES( RenderVectorPluginD TARGET_LINK_LIBRARIES( RenderVectorPluginD
${LIBRARY_OUTPUT_PATH}/libSCHNApps.so
${CGoGN_LIBS_D} ${CGoGN_LIBS_D}
${COMMON_LIBS} ${COMMON_LIBS}
${QGLVIEWER_LIBRARIES} ${QGLVIEWER_LIBRARIES}
...@@ -66,7 +65,6 @@ ELSE ( ${CMAKE_BUILD_TYPE} STREQUAL Debug ) ...@@ -66,7 +65,6 @@ ELSE ( ${CMAKE_BUILD_TYPE} STREQUAL Debug )
) )
TARGET_LINK_LIBRARIES( RenderVectorPlugin TARGET_LINK_LIBRARIES( RenderVectorPlugin
${LIBRARY_OUTPUT_PATH}/libSCHNApps.so
${CGoGN_LIBS_R} ${CGoGN_LIBS_R}
${COMMON_LIBS} ${COMMON_LIBS}
${QGLVIEWER_LIBRARIES} ${QGLVIEWER_LIBRARIES}
......
...@@ -38,7 +38,6 @@ IF( ${CMAKE_BUILD_TYPE} STREQUAL Debug ) ...@@ -38,7 +38,6 @@ IF( ${CMAKE_BUILD_TYPE} STREQUAL Debug )
) )
TARGET_LINK_LIBRARIES( SubdivideSurfacePluginD TARGET_LINK_LIBRARIES( SubdivideSurfacePluginD
${LIBRARY_OUTPUT_PATH}/libSCHNApps.so
${CGoGN_LIBS_D} ${CGoGN_LIBS_D}
${COMMON_LIBS} ${COMMON_LIBS}
${QGLVIEWER_LIBRARIES} ${QGLVIEWER_LIBRARIES}
...@@ -66,7 +65,6 @@ ELSE ( ${CMAKE_BUILD_TYPE} STREQUAL Debug ) ...@@ -66,7 +65,6 @@ ELSE ( ${CMAKE_BUILD_TYPE} STREQUAL Debug )
) )
TARGET_LINK_LIBRARIES( SubdivideSurfacePlugin TARGET_LINK_LIBRARIES( SubdivideSurfacePlugin
${LIBRARY_OUTPUT_PATH}/libSCHNApps.so
${CGoGN_LIBS_R} ${CGoGN_LIBS_R}
${COMMON_LIBS} ${COMMON_LIBS}
${QGLVIEWER_LIBRARIES} ${QGLVIEWER_LIBRARIES}
......
...@@ -14,12 +14,14 @@ INCLUDE_DIRECTORIES( ...@@ -14,12 +14,14 @@ INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}
${QGLVIEWER_INCLUDE_DIR} ${QGLVIEWER_INCLUDE_DIR}
${PYTHON_INCLUDE_DIRS}
${SCHNApps_ROOT_DIR}/include ${SCHNApps_ROOT_DIR}/include
) )
file( file(
GLOB GLOB
SCHNApps_SRC_FILES SCHNApps_SRC_FILES
${SCHNApps_ROOT_DIR}/src/main.cpp
${SCHNApps_ROOT_DIR}/src/camera.cpp ${SCHNApps_ROOT_DIR}/src/camera.cpp
${SCHNApps_ROOT_DIR}/src/mapHandler.cpp ${SCHNApps_ROOT_DIR}/src/mapHandler.cpp
${SCHNApps_ROOT_DIR}/src/plugin.cpp ${SCHNApps_ROOT_DIR}/src/plugin.cpp
...@@ -68,7 +70,7 @@ QT4_ADD_RESOURCES( RCC_FILES ...@@ -68,7 +70,7 @@ QT4_ADD_RESOURCES( RCC_FILES
${SCHNApps_ROOT_DIR}/resources/resources.qrc ${SCHNApps_ROOT_DIR}/resources/resources.qrc
) )
ADD_LIBRARY( SCHNApps SHARED ADD_EXECUTABLE( SCHNApps
${SCHNApps_SRC_FILES} ${SCHNApps_SRC_FILES}
${UI_H_FILES} ${UI_H_FILES}
${MOC_FILES} ${MOC_FILES}
...@@ -79,6 +81,7 @@ TARGET_LINK_LIBRARIES( SCHNApps ...@@ -79,6 +81,7 @@ TARGET_LINK_LIBRARIES( SCHNApps
${CGoGN_LIBS_R} ${CGoGN_LIBS_R}
${COMMON_LIBS} ${COMMON_LIBS}
${QGLVIEWER_LIBRARIES} ${QGLVIEWER_LIBRARIES}
PythonQt
) )
......
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]
)
#include <boost/python.hpp>
#include <boost/python/module.hpp>
#include <boost/python/def.hpp>
#include "plugin.h"
#include "window.h"
using namespace boost::python;
BOOST_PYTHON_MODULE(PySCHNApps)
{
class_<CGoGN::SCHNApps::Window>("Window")
.def(init<>())
.def("launch", &CGoGN::SCHNApps::Window::launch)
.def("loadPlugin", &CGoGN::SCHNApps::Window::loadPlugin_py)
;
}
#include "system.h"
#include <QErrorMessage>
#include <QMessageBox>
#include <QFileInfo>
#include <QUrl>
#include <QVBoxLayout>
#include <QTextBrowser>
namespace CGoGN
{
namespace SCHNApps
{
namespace System
{
} // namespace System
} // namespace SCHNApps
} // namespace CGoGN
#ifndef _SYSTEM_H_
#define _SYSTEM_H_
#include <QWidget>
#include <QSplashScreen>
#include "types.h"
namespace CGoGN
{
namespace SCHNApps
{
class Window;
class SplitArea;
namespace System
{
} // namespace System
} // namespace SCHNApps
} // namespace CGoGN
#endif
#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
#ifndef _PLUGIN_H_ #ifndef _PLUGIN_H_
#define _PLUGIN_H_ #define _PLUGIN_H_
#include <QtCore/QtPlugin> #include <QtPlugin>
#include <QtGui/QAction> #include <QAction>
#include "types.h" #include "types.h"
......
#ifndef _TYPES_H_ #ifndef _TYPES_H_
#define _TYPES_H_ #define _TYPES_H_
#include <QtCore/QHash> #include <QHash>
#include <QtCore/QMap> #include <QMap>
#include <QtCore/QString> #include <QString>
#include "Topology/generic/parameters.h" #include "Topology/generic/parameters.h"
#include "Topology/map/embeddedMap2.h" #include "Topology/map/embeddedMap2.h"
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include "ui_window.h" #include "ui_window.h"
#include "PythonQt/PythonQt.h"
#include "types.h" #include "types.h"
class QVBoxLayout; class QVBoxLayout;
...@@ -29,9 +30,7 @@ public: ...@@ -29,9 +30,7 @@ public:
* \fn Window() * \fn Window()
* \brief Constructor * \brief Constructor
*/ */
Window(); Window(const QString& appPath, PythonQtObjectPtr& pythonContext);
Window(const Window& w);
/** /**
* \fn ~Window() * \fn ~Window()
...@@ -39,11 +38,6 @@ public: ...@@ -39,11 +38,6 @@ public:
*/ */
~Window(); ~Window();
void launch()
{
this->QMainWindow::show();
}
const QString& getAppPath() { return m_appPath; } const QString& getAppPath() { return m_appPath; }
/********************************************************* /*********************************************************
...@@ -206,8 +200,7 @@ public: ...@@ -206,8 +200,7 @@ public:
* \see getPlugins() * \see getPlugins()
* \see Plugin::enable() * \see Plugin::enable()
*/ */
Plugin* loadPlugin(const QString& pluginFilePath); // Plugin* loadPlugin(const QString& pluginFilePath);
void loadPlugin_py(std::string path);
/** /**
* \fn void unloadPlugin(QString pluginName) * \fn void unloadPlugin(QString pluginName)
...@@ -274,6 +267,7 @@ public: ...@@ -274,6 +267,7 @@ public:
protected: protected:
QString m_appPath; QString m_appPath;
PythonQtObjectPtr& m_pythonContext;
bool m_initialization; bool m_initialization;
...@@ -299,6 +293,9 @@ protected: ...@@ -299,6 +293,9 @@ protected:
MapsDialog* m_mapsDialog; MapsDialog* m_mapsDialog;
public slots: public slots:
Plugin* loadPlugin(const QString& pluginFilePath);
/** /**
* \fn void cb_about_SCHNApps(); * \fn void cb_about_SCHNApps();
* \brief function that is called when the "about SCHNApps" menu action is triggered * \brief function that is called when the "about SCHNApps" menu action is triggered
......
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_())
...@@ -43,7 +43,7 @@ PluginsDialog::PluginsDialog(Window* window) : ...@@ -43,7 +43,7 @@ PluginsDialog::PluginsDialog(Window* window) :
// restoreState(); // restoreState();
addPluginsDirectory(m_window->getAppPath() + QString("/lib/")); addPluginsDirectory(m_window->getAppPath() + QString("../lib/"));
init = false; init = false;
} }
...@@ -231,7 +231,7 @@ void PluginsDialog::cb_addPluginsDirectory() ...@@ -231,7 +231,7 @@ void PluginsDialog::cb_addPluginsDirectory()
QString dir = QFileDialog::getExistingDirectory( QString dir = QFileDialog::getExistingDirectory(
this, this,
tr("Select a directory"), tr("Select a directory"),
m_window->getAppPath() + QString("/lib/"), m_window->getAppPath() + QString("../lib/"),
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks
); );
......
#include <QSplashScreen> #include <QSplashScreen>
#include "PythonQt/PythonQt.h"
#include "PythonQt/PythonQtScriptingConsole.h"
#include "window.h" #include "window.h"
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
QApplication app(argc, argv); QApplication app(argc, argv);
// QSplashScreen* splash = new QSplashScreen(QPixmap(":splash/cgogn/splash.png")); QSplashScreen* splash = new QSplashScreen(QPixmap(":splash/cgogn/splash.png"));
// splash->show(); splash->show();
// splash->showMessage("Welcome to SCHNApps", Qt::AlignBottom | Qt::AlignCenter); 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(); window.show();
// splash->finish(&window); pythonContext.addObject("window", &window);
// delete splash;
splash->finish(&window);
delete splash;
PythonQtScriptingConsole pythonConsole(NULL, pythonContext);
pythonConsole.show();
return app.exec(); return app.exec();
} }
...@@ -26,9 +26,10 @@ namespace CGoGN ...@@ -26,9 +26,10 @@ namespace CGoGN
namespace SCHNApps namespace SCHNApps
{ {
Window::Window() : Window::Window(const QString& appPath, PythonQtObjectPtr& pythonContext) :
QMainWindow(), QMainWindow(),
m_appPath("/home/kraemer/Dev/CGoGN/SCHNApps"), m_appPath(appPath),
m_pythonContext(pythonContext),
m_firstView(NULL), m_firstView(NULL),
m_currentView(NULL) m_currentView(NULL)
{ {
...@@ -80,11 +81,8 @@ Window::Window() : ...@@ -80,11 +81,8 @@ Window::Window() :
// program in its initialization phase // program in its initialization phase
m_initialization = false; m_initialization = false;
}
Window::Window(const Window& w) m_pythonContext.addObject("dock", m_dock);
{
std::cout << "hiohoihoih" << std::endl;
} }
Window::~Window() Window::~Window()
...@@ -466,12 +464,6 @@ Plugin* Window::loadPlugin(const QString& pluginFilePath) ...@@ -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) void Window::unloadPlugin(const QString& pluginName)
{ {
if (h_plugins.contains(pluginName)) if (h_plugins.contains(pluginName))
......
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