Skip to content
Snippets Groups Projects
Commit 5e776460 authored by stefan's avatar stefan
Browse files

Applied sip export changes to:

 - GLWin and SpaceNav

git-svn-id: https://dng.biozentrum.unibas.ch/svn/openstructure/trunk@2075 5a81b35b-ba03-0410-adc8-b2c5c5119f08
parent dd039b69
No related branches found
No related tags found
No related merge requests found
...@@ -17,19 +17,23 @@ ...@@ -17,19 +17,23 @@
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#include <boost/python.hpp> #include <boost/python.hpp>
#include "gl_win_proxy.hh"
#include <ost/gui/gl_win.hh>
#include "sip_handler.hh"
using namespace boost::python; using namespace boost::python;
using namespace ost; using namespace ost;
using namespace ost::gui; using namespace ost::gui;
void export_GLWin() void export_GLWin()
{ {
class_<GLWinProxy, bases<SipHandlerBase> >("GLWin") class_<GLWin, boost::noncopyable >("GLWin", no_init)
.def("Show", &GLWinProxy::Show) .def("Show", &GLWin::show)
.def("Hide", &GLWinProxy::Hide) .def("Hide", &GLWin::hide)
.def("StatusMessage",&GLWinProxy::StatusMessage) .def("StatusMessage",&GLWin::StatusMessage)
.def("GetQObject",&ost::gui::get_qobject<GLWin>)
.add_property("qobject", &ost::gui::get_qobject<GLWin>)
; ;
} }
......
...@@ -53,11 +53,6 @@ ToolOptionsWinProxy app_get_tool_options_win(GostyApp* app) ...@@ -53,11 +53,6 @@ ToolOptionsWinProxy app_get_tool_options_win(GostyApp* app)
return ToolOptionsWinProxy(app->GetToolOptionsWin()); return ToolOptionsWinProxy(app->GetToolOptionsWin());
} }
GLWinProxy app_get_gl_win(GostyApp* app)
{
return GLWinProxy(app->GetGLWin());
}
SceneWinProxy app_get_scene_win(GostyApp* app) SceneWinProxy app_get_scene_win(GostyApp* app)
{ {
return SceneWinProxy(app->GetSceneWin()); return SceneWinProxy(app->GetSceneWin());
...@@ -99,8 +94,10 @@ void export_Gosty() ...@@ -99,8 +94,10 @@ void export_Gosty()
.def("SetAppTitle", &GostyApp::SetAppTitle) .def("SetAppTitle", &GostyApp::SetAppTitle)
.def("GetPyShell", &app_get_py_shell) .def("GetPyShell", &app_get_py_shell)
.add_property("py_shell", &app_get_py_shell) .add_property("py_shell", &app_get_py_shell)
.def("GetGLWin", &app_get_gl_win) .def("GetGLWin", &GostyApp::GetGLWin,
.add_property("gl_win", &app_get_gl_win) return_value_policy<reference_existing_object>())
.add_property("gl_win", make_function(&GostyApp::GetGLWin,
return_value_policy<reference_existing_object>()))
.def("GetSceneWin", &app_get_scene_win) .def("GetSceneWin", &app_get_scene_win)
.add_property("scene_win", &app_get_scene_win) .add_property("scene_win", &app_get_scene_win)
.def("GetSequenceViewer", &app_get_seq_viewer) .def("GetSequenceViewer", &app_get_seq_viewer)
......
...@@ -17,7 +17,11 @@ ...@@ -17,7 +17,11 @@
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#include <boost/python.hpp> #include <boost/python.hpp>
#include <iostream>
#include <ost/gui/input/spnav_input.hh>
#include "sip_handler.hh"
#include "spnav_input_proxy.hh" #include "spnav_input_proxy.hh"
using namespace boost::python; using namespace boost::python;
...@@ -30,22 +34,18 @@ object spnav_get_instance() ...@@ -30,22 +34,18 @@ object spnav_get_instance()
{ {
static object sip_module=import("sip"); static object sip_module=import("sip");
static object pyqt4_module=import("PyQt4.QtCore"); static object pyqt4_module=import("PyQt4.QtCore");
SpnavInput* spnav = SpnavInput::Instance(); return ost::gui::get_qobject<SpnavInput>(SpnavInput::Instance());
unsigned long addr = reinterpret_cast<unsigned long>(spnav);
object obj(addr);
object qthread = pyqt4_module.attr("QThread");
object thread = sip_module.attr("wrapinstance")(addr, qthread);
return thread;
} }
} }
void export_Input() void export_Input()
{ {
class_<SpnavInputProxy, bases<SipHandlerBase> >("SpnavInput",no_init) class_<SpnavInput, bases<SipHandlerBase>, boost::noncopyable >("SpnavInput",no_init)
.def("GetQThread", &spnav_get_instance).staticmethod("GetQThread") .def("GetQThread", &spnav_get_instance).staticmethod("GetQThread")
.def("Instance", &SpnavInputProxy::Instance, .def("GetQObject", &ost::gui::get_qobject<SpnavInput>)
.add_property("qobject", &ost::gui::get_qobject<SpnavInput>)
.def("Instance", &SpnavInput::Instance,
return_value_policy<reference_existing_object>()).staticmethod("Instance") return_value_policy<reference_existing_object>()).staticmethod("Instance")
; ;
} }
......
...@@ -107,6 +107,30 @@ void main_area_hide_sub_window(MainArea* m, const SipHandlerBase& sh) ...@@ -107,6 +107,30 @@ void main_area_hide_sub_window(MainArea* m, const SipHandlerBase& sh)
m->HideSubWindow(reinterpret_cast<QWidget*>(sh.GetSipHandle())); m->HideSubWindow(reinterpret_cast<QWidget*>(sh.GetSipHandle()));
} }
void main_area_add_pers_widget_g(MainArea* m, const QString& title,
const QString& name, object py_object, int window_states)
{
static object sip_module=import("sip");
static object gui_module=import("ost.gui");
static object pyqt4_module=import("PyQt4.QtCore");
unsigned long addr = extract<unsigned long>(sip_module.attr("unwrapinstance")(py_object));
QWidget* widget = reinterpret_cast<QWidget*>(addr);
if(widget){
Qt::WindowStates q_window_states =Qt::WindowStates(window_states);
m->AddPersistentWidget(title, name, widget, q_window_states);
}
}
} }
void export_MainArea() void export_MainArea()
...@@ -121,6 +145,7 @@ void export_MainArea() ...@@ -121,6 +145,7 @@ void export_MainArea()
.def("AddPersistentWidget", &main_area_add_pers_widget_d) .def("AddPersistentWidget", &main_area_add_pers_widget_d)
.def("AddPersistentWidget", &main_area_add_pers_widget_e) .def("AddPersistentWidget", &main_area_add_pers_widget_e)
.def("AddPersistentWidget", &main_area_add_pers_widget_f) .def("AddPersistentWidget", &main_area_add_pers_widget_f)
.def("AddPersistentWidget", &main_area_add_pers_widget_g)
.def("width", &MainArea::width) .def("width", &MainArea::width)
.def("height", &MainArea::height) .def("height", &MainArea::height)
.def("ShowSubWindow", &MainArea::ShowSubWindow) .def("ShowSubWindow", &MainArea::ShowSubWindow)
......
...@@ -27,8 +27,6 @@ using namespace boost::python; ...@@ -27,8 +27,6 @@ using namespace boost::python;
using namespace ost; using namespace ost;
using namespace ost::gui; using namespace ost::gui;
namespace { namespace {
unsigned long sip_handle(QObject* w) unsigned long sip_handle(QObject* w)
......
...@@ -42,8 +42,7 @@ class InitInspectorMenu(QtCore.QObject): ...@@ -42,8 +42,7 @@ class InitInspectorMenu(QtCore.QObject):
def _InitInspector(): def _InitInspector():
app=gui.GostyApp.Instance() app=gui.GostyApp.Instance()
gl_win=sip.wrapinstance(app.gl_win.GetSipHandle(),QtGui.QWidget) mywidget = InspectorDialog(app.gl_win.qobject)
mywidget = InspectorDialog(gl_win)
mywidget.setWindowFlags(QtCore.Qt.Dialog | QtCore.Qt.Tool) mywidget.setWindowFlags(QtCore.Qt.Dialog | QtCore.Qt.Tool)
mywidget.show() mywidget.show()
unwrapped = gui.BPQtHandle(sip.unwrapinstance(mywidget)) unwrapped = gui.BPQtHandle(sip.unwrapinstance(mywidget))
......
...@@ -19,15 +19,33 @@ ...@@ -19,15 +19,33 @@
#ifndef OST_GUI_SIP_HANDLER_HH #ifndef OST_GUI_SIP_HANDLER_HH
#define OST_GUI_SIP_HANDLER_HH #define OST_GUI_SIP_HANDLER_HH
#include <ost/message.hh> #include <boost/python.hpp>
#include <QWidget> #include <QWidget>
#include <ost/message.hh>
using namespace boost::python;
/* /*
Author: Ansgar Philippsen, Marco Biasini Author: Ansgar Philippsen, Marco Biasini
*/ */
namespace ost { namespace gui { namespace ost { namespace gui {
template <class O> object get_qobject(O* obj)
{
static object sip_module=import("sip");
static object pyqt4_module=import("PyQt4.QtCore");
QObject* qobject = qobject_cast<QObject*>(obj);
unsigned long addr = reinterpret_cast<unsigned long>(qobject);
object py_qobject = pyqt4_module.attr("QObject");
object object = sip_module.attr("wrapinstance")(addr, py_qobject);
return object;
};
class SipHandlerBase { class SipHandlerBase {
public: public:
virtual ~SipHandlerBase() {} virtual ~SipHandlerBase() {}
......
...@@ -53,7 +53,7 @@ def _InitFrontEnd(): ...@@ -53,7 +53,7 @@ def _InitFrontEnd():
_InitMenuBar(app.perspective.GetMenuBar()) _InitMenuBar(app.perspective.GetMenuBar())
_InitSpaceNav(app.perspective.panels.qwidget) _InitSpaceNav(app.perspective.panels.qwidget)
_InitContextMenu() _InitContextMenu()
main_area.AddPersistentWidget("3D Scene", "gl_win" , app.gl_win, int(QtCore.Qt.WindowMaximized)) main_area.AddPersistentWidget("3D Scene", "gl_win" , app.gl_win.qobject, int(QtCore.Qt.WindowMaximized))
app.perspective.Restore() app.perspective.Restore()
additional_modules=getattr(__main__, 'ADDITIONAL_GUI_MODULES', []) additional_modules=getattr(__main__, 'ADDITIONAL_GUI_MODULES', [])
for module_name in additional_modules: for module_name in additional_modules:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment