File: wrap_gui.cc

package info (click to toggle)
openstructure 2.9.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 205,228 kB
  • sloc: cpp: 188,129; python: 35,361; ansic: 34,298; fortran: 3,275; sh: 286; xml: 146; makefile: 29
file content (143 lines) | stat: -rw-r--r-- 3,917 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
//------------------------------------------------------------------------------
// This file is part of the OpenStructure project <www.openstructure.org>
//
// Copyright (C) 2008-2020 by the OpenStructure authors
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License as published by the Free
// Software Foundation; either version 3.0 of the License, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
// details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this library; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
//------------------------------------------------------------------------------

#include <boost/python.hpp>
#include <QString>
#include <iostream>
#include <ost/config.hh>
#include <ost/gui/admin.hh>
using namespace boost::python;

void export_AlignmentView();
void export_Tool();
void export_GLWin();
void export_MessageWidget();
void export_Gosty();
void export_PyShell();
void export_SceneWin();
void export_SequenceViewer();
void export_Panels();
void export_Perspective();
void export_SipHandler();
void export_SceneSelection();
void export_MainArea();
void export_MenuBar();
void export_FileLoader();
void export_FileViewer();
void export_Widget();
void export_GLCanvas();
void export_data_viewer();
void export_overlay();
void export_overlay_manager();

#if OST_SPNAV_ENABLED
void export_Input();
#endif

#include <boost/python/to_python_converter.hpp>

namespace {

  struct qstring_to_python_string
  {
    static PyObject* convert(QString const& s)
    {
      return boost::python::incref(boost::python::object(s.unicode()).ptr());
    }
  };

  struct qstring_from_python_string
  {
    qstring_from_python_string()
    {
      boost::python::converter::registry::push_back(
        &convertible,
        &construct,
        boost::python::type_id<QString>());
    }

    static void* convertible(PyObject* obj_ptr)
    {
      if (!PyUnicode_Check(obj_ptr)) return 0;
      return obj_ptr;
    }

    static void construct(
      PyObject* obj_ptr,
      boost::python::converter::rvalue_from_python_stage1_data* data)
    {
      PyObject* temp_bytes = PyUnicode_AsEncodedString(obj_ptr, "UTF-8", "strict");
      char* value = NULL;
      if (temp_bytes != NULL) {
        value = PyBytes_AS_STRING(temp_bytes);
        value = strdup(value);
        Py_DECREF(temp_bytes);
      }
      if (value == NULL) boost::python::throw_error_already_set();

      void* storage = (
        (boost::python::converter::rvalue_from_python_storage<QString>*)
          data)->storage.bytes;
      new (storage) QString(value);
      data->convertible = storage;
    }
  };


}
using namespace ost::gui;

BOOST_PYTHON_MODULE(_ost_gui)
{

  boost::python::to_python_converter<QString, qstring_to_python_string>();
  qstring_from_python_string();
  export_SipHandler();  
  export_Gosty();
  export_AlignmentView();
  export_Tool();
  export_MessageWidget();
  export_GLWin();
  export_MainArea();
  export_PyShell();
  export_Panels();
  export_MenuBar();
  export_Perspective();  
  export_SceneWin();
  export_SceneSelection();
  export_SequenceViewer();
  export_FileLoader();
  export_FileViewer();
  export_Widget();
  export_GLCanvas();

  #if OST_SPNAV_ENABLED
  export_Input();
  #endif

  export_data_viewer();
  export_overlay();
  export_overlay_manager();
  
  class_<AdminRights>("AdminRights", init<>())
    .def("Acquire", &AdminRights::Acquire)
    .def("Release", &AdminRights::Release)
    .def("CreateLink", &AdminRights::CreateLink)
  ;
}