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

new sip export for scenewin

git-svn-id: https://dng.biozentrum.unibas.ch/svn/openstructure/trunk@2082 5a81b35b-ba03-0410-adc8-b2c5c5119f08
parent f9459152
No related branches found
No related tags found
No related merge requests found
......@@ -25,6 +25,7 @@ using namespace boost::python;
#include <ost/gui/gl_win.hh>
#include <ost/gui/perspective.hh>
#include <ost/gui/scene_win/scene_win.hh>
#include <ost/gui/tools/tool_options_win.hh>
#include <ost/gui/python_shell/python_shell.hh>
......@@ -32,7 +33,6 @@ using namespace boost::python;
#include "sip_handler.hh"
#include "tool_options_win_proxy.hh"
#include "scene_win_proxy.hh"
#include "sequence_viewer_proxy.hh"
#if OST_IMG_ENABLED
#include "data_viewer_proxy.hh"
......@@ -49,11 +49,6 @@ ToolOptionsWinProxy app_get_tool_options_win(GostyApp* app)
return ToolOptionsWinProxy(app->GetToolOptionsWin());
}
SceneWinProxy app_get_scene_win(GostyApp* app)
{
return SceneWinProxy(app->GetSceneWin());
}
SequenceViewerProxy app_get_seq_viewer(GostyApp* app)
{
return SequenceViewerProxy(app->GetSequenceViewer());
......@@ -103,8 +98,10 @@ void export_Gosty()
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("GetSceneWin", &GostyApp::GetSceneWin,
return_value_policy<reference_existing_object>())
.add_property("scene_win", make_function(&GostyApp::GetSceneWin,
return_value_policy<reference_existing_object>()))
.def("GetSequenceViewer", &app_get_seq_viewer)
.add_property("seq_viewer", &app_get_seq_viewer)
.def("GetToolOptionsWin", &app_get_tool_options_win)
......
......@@ -22,6 +22,8 @@
#include "scene_win_proxy.hh"
#include "sip_handler.hh"
#include <ost/gui/scene_win/context_menu.hh>
using namespace boost::python;
......@@ -32,32 +34,13 @@ namespace {
void context_menu_add_action(ContextMenu* cm, object action, int types)
{
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")(action));
QAction* act = reinterpret_cast<QAction*>(addr);
QAction* act = get_cpp_qobject<QAction>(action);
if(act){
ContextActionTypes type = ContextActionTypes(types);
cm->AddAction(act,type);
}
}
object context_menu_get_qobject(ContextMenu* cm)
{
static object sip_module=import("sip");
static object pyqt4_module=import("PyQt4.QtCore");
size_t addr = reinterpret_cast<size_t>(cm);
object obj(addr);
object sip_handle=obj;
object qobject = pyqt4_module.attr("QObject");
object object = sip_module.attr("wrapinstance")(sip_handle, qobject);
return object;
}
}
void export_SceneWin()
......@@ -80,14 +63,16 @@ void export_SceneWin()
class_<ContextMenu, boost::noncopyable>("ContextMenu", no_init)
.def("AddAction", &context_menu_add_action)
.def("GetQObject", &context_menu_get_qobject)
.add_property("qobject",&context_menu_get_qobject)
.def("GetQObject",&get_py_qobject<ContextMenu>)
.add_property("qobject", &get_py_qobject<ContextMenu>)
;
class_<SceneWinProxy, bases<SipHandlerBase> >("SceneWin")
.def("Show", &SceneWinProxy::Show)
.def("Hide", &SceneWinProxy::Hide)
.def("GetContextMenu", &SceneWinProxy::GetContextMenu, return_value_policy<reference_existing_object>())
class_<SceneWin, boost::noncopyable>("SceneWin", no_init)
.def("Show", &SceneWin::show)
.def("Hide", &SceneWin::hide)
.def("GetContextMenu", &SceneWin::GetContextMenu, return_value_policy<reference_existing_object>())
.def("GetQObject",&get_py_qobject<SceneWin>)
.add_property("qobject", &get_py_qobject<SceneWin>)
;
}
......
......@@ -147,6 +147,6 @@ class AlignmentContextMenu(QtCore.QObject):
ShowResultDialog(ent_list, res_list).exec_()
def _InitContextMenu():
cm=gui.GostyApp.Instance().GetSceneWin().GetContextMenu()
def _InitContextMenu(app):
cm=app.scene_win.GetContextMenu()
AlignmentContextMenu(cm)
\ No newline at end of file
......@@ -77,8 +77,8 @@ class InitMenuBar(QtCore.QObject):
def OpenDocs(self):
QtGui.QDesktopServices.openUrl(QtCore.QUrl("http://www.openstructure.org/docs/index.html"))
def _InitMenuBar(menu_bar):
InitMenuBar(menu_bar)
def _InitMenuBar(app):
InitMenuBar(app.perspective.menubar)
## \example menubar_example.py
#
......
......@@ -33,10 +33,11 @@ class SpacenavControl(QtCore.QObject):
self.rot = not self.rot
print "Rotation Enabled:",self.rot
def _InitSpaceNav(parent):
def _InitSpaceNav(app):
try:
spnav = gui.SpnavInput.GetQThread()
spnav.start()
parent = app.gl_win.qobject
SpacenavControl(spnav,parent)
except AttributeError:
pass
\ No newline at end of file
......@@ -41,8 +41,7 @@ class InitInspectorMenu(QtCore.QObject):
def Toggle(self):
self.inspector_.setVisible(self.show_.isChecked())
def _InitInspector():
app=gui.GostyApp.Instance()
def _InitInspector(app):
mywidget = InspectorDialog(app.gl_win.qobject)
mywidget.setWindowFlags(QtCore.Qt.Dialog | QtCore.Qt.Tool)
mywidget.show()
......
......@@ -47,10 +47,8 @@ class InspectorWidget(ToolBarOptionsWidget):
self.obs = SceneObserverImpl()
self.obs.AttachObserver(self)
ost.scene.AttachObserver(self.obs)
app=gui.GostyApp.Instance()
self.scene_selection_ = gui.SceneSelection.Instance()
scenewin = sip.wrapinstance(app.GetSceneWin().GetSipHandle(),QtGui.QWidget)
QtCore.QObject.connect(scenewin,QtCore.SIGNAL("ActiveNodesChanged()"),
QtCore.QObject.connect(app.scene_win.qobject,QtCore.SIGNAL("ActiveNodesChanged()"),
self.ActiveNodesChanged)
self.setMinimumSize(250,215)
......
......@@ -29,7 +29,8 @@ def _InitRuleBasedBuilder():
# switch to rule-based builder for high fidelity if compounds.chemlib is
# available
_InitRuleBasedBuilder()
def _InitPanels(app, panels):
def _InitPanels(app):
panels = app.perspective.panels
panels.AddWidgetToPool('ost.gui.FileBrowser', -1)
panels.AddWidgetToPool('ost.gui.PythonShell', 1)
panels.AddWidgetToPool('ost.gui.RemoteLoader', -1)
......@@ -48,17 +49,17 @@ def _InitFrontEnd():
app=gui.GostyApp.Instance()
app.SetAppTitle("DNG")
main_area=app.perspective.main_area
_InitPanels(app, app.perspective.panels)
_InitMenuBar(app.perspective.menubar)
_InitSpaceNav(app.perspective.panels.qobject)
_InitContextMenu()
_InitPanels(app)
_InitMenuBar(app)
_InitSpaceNav(app)
_InitContextMenu(app)
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:
__import__(module_name)
app.ProcessEvents()
_InitInspector()
_InitInspector(app)
def _load_files():
for pdb_id in options.pdb_ids:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment