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

PythonSCHNApps is coming..

parent 170fedde
......@@ -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)
......
......@@ -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
)
......
......@@ -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}
......
......@@ -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}
......
......@@ -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}
......
......@@ -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}
......
......@@ -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}
......
......@@ -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
)
......
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_
#define _PLUGIN_H_
#include <QtCore/QtPlugin>
#include <QtGui/QAction>
#include <QtPlugin>
#include <QAction>
#include "types.h"
......
#ifndef _TYPES_H_
#define _TYPES_H_
#include <QtCore/QHash>
#include <QtCore/QMap>
#include <QtCore/QString>
#include <QHash>
#include <QMap>
#include <QString>
#include "Topology/generic/parameters.h"
#include "Topology/map/embeddedMap2.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
......
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) :
// 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
);
......
#include <QSplashScreen>
#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();
}
......@@ -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))
......
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