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
Branches
Tags
No related merge requests found
......@@ -17,19 +17,23 @@
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//------------------------------------------------------------------------------
#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 ost;
using namespace ost::gui;
void export_GLWin()
{
class_<GLWinProxy, bases<SipHandlerBase> >("GLWin")
.def("Show", &GLWinProxy::Show)
.def("Hide", &GLWinProxy::Hide)
.def("StatusMessage",&GLWinProxy::StatusMessage)
class_<GLWin, boost::noncopyable >("GLWin", no_init)
.def("Show", &GLWin::show)
.def("Hide", &GLWin::hide)
.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)
return ToolOptionsWinProxy(app->GetToolOptionsWin());
}
GLWinProxy app_get_gl_win(GostyApp* app)
{
return GLWinProxy(app->GetGLWin());
}
SceneWinProxy app_get_scene_win(GostyApp* app)
{
return SceneWinProxy(app->GetSceneWin());
......@@ -99,8 +94,10 @@ void export_Gosty()
.def("SetAppTitle", &GostyApp::SetAppTitle)
.def("GetPyShell", &app_get_py_shell)
.add_property("py_shell", &app_get_py_shell)
.def("GetGLWin", &app_get_gl_win)
.add_property("gl_win", &app_get_gl_win)
.def("GetGLWin", &GostyApp::GetGLWin,
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)
.add_property("scene_win", &app_get_scene_win)
.def("GetSequenceViewer", &app_get_seq_viewer)
......
......@@ -17,7 +17,11 @@
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//------------------------------------------------------------------------------
#include <boost/python.hpp>
#include <iostream>
#include <ost/gui/input/spnav_input.hh>
#include "sip_handler.hh"
#include "spnav_input_proxy.hh"
using namespace boost::python;
......@@ -30,22 +34,18 @@ object spnav_get_instance()
{
static object sip_module=import("sip");
static object pyqt4_module=import("PyQt4.QtCore");
SpnavInput* spnav = 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;
return ost::gui::get_qobject<SpnavInput>(SpnavInput::Instance());
}
}
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("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")
;
}
......
......@@ -107,6 +107,30 @@ void main_area_hide_sub_window(MainArea* m, const SipHandlerBase& sh)
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()
......@@ -121,6 +145,7 @@ void export_MainArea()
.def("AddPersistentWidget", &main_area_add_pers_widget_d)
.def("AddPersistentWidget", &main_area_add_pers_widget_e)
.def("AddPersistentWidget", &main_area_add_pers_widget_f)
.def("AddPersistentWidget", &main_area_add_pers_widget_g)
.def("width", &MainArea::width)
.def("height", &MainArea::height)
.def("ShowSubWindow", &MainArea::ShowSubWindow)
......
......@@ -27,8 +27,6 @@ using namespace boost::python;
using namespace ost;
using namespace ost::gui;
namespace {
unsigned long sip_handle(QObject* w)
......
......@@ -42,8 +42,7 @@ class InitInspectorMenu(QtCore.QObject):
def _InitInspector():
app=gui.GostyApp.Instance()
gl_win=sip.wrapinstance(app.gl_win.GetSipHandle(),QtGui.QWidget)
mywidget = InspectorDialog(gl_win)
mywidget = InspectorDialog(app.gl_win.qobject)
mywidget.setWindowFlags(QtCore.Qt.Dialog | QtCore.Qt.Tool)
mywidget.show()
unwrapped = gui.BPQtHandle(sip.unwrapinstance(mywidget))
......
......@@ -19,15 +19,33 @@
#ifndef OST_GUI_SIP_HANDLER_HH
#define OST_GUI_SIP_HANDLER_HH
#include <ost/message.hh>
#include <boost/python.hpp>
#include <QWidget>
#include <ost/message.hh>
using namespace boost::python;
/*
Author: Ansgar Philippsen, Marco Biasini
*/
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 {
public:
virtual ~SipHandlerBase() {}
......
......@@ -53,7 +53,7 @@ def _InitFrontEnd():
_InitMenuBar(app.perspective.GetMenuBar())
_InitSpaceNav(app.perspective.panels.qwidget)
_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()
additional_modules=getattr(__main__, 'ADDITIONAL_GUI_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