Skip to content

Commit

Permalink
gltbx: fixes for pyopengl
Browse files Browse the repository at this point in the history
- OpenGL.GLU imports may change previously loaded modules, so place first
- Deprecation updates to get wx_ellipsoids_test.py to work
  • Loading branch information
bkpoon committed Jan 20, 2025
1 parent 14a4955 commit 33f6a7e
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 14 deletions.
10 changes: 5 additions & 5 deletions cctbx/maptbx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2241,16 +2241,16 @@ def get_points(start, end, step=None, n_steps=None):
# check end point
end_ = points[-1]
d = math.sqrt(
(end_[0] - start[0])**2 +
(end_[1] - start[1])**2 +
(end_[0] - start[0])**2 +
(end_[1] - start[1])**2 +
(end_[2] - start[2])**2)
if d<length: points.append(end)
#
return points
#
points = get_points(start=points_cart[0], end=points_cart[1], step=step,
n_steps=n_steps)

dist = flex.double()
vals = flex.double()
mv_max = None
Expand All @@ -2267,11 +2267,11 @@ def get_points(start, end, step=None, n_steps=None):
mv = map_data.eight_point_interpolation(pf)
else:
mv = map_data.tricubic_interpolation(pf)
if mv_max is None:
if mv_max is None:
mv_max = mv
point_max = p[:]
else:
if mv > mv_max:
if mv > mv_max:
mv_max = mv
point_max = p[:]
vals.append(mv)
Expand Down
2 changes: 1 addition & 1 deletion crys3d/qttbx/xray_structure_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from PyQt4.QtCore import Qt
from crys3d import qttbx
import crys3d.qttbx.xray_structure_viewer_controls
from gltbx import quadrics, gl_managed
from gltbx.gl import *
from gltbx.glu import *
from gltbx import quadrics, gl_managed
from cctbx import crystal
from cctbx.array_family import flex
from cctbx.eltbx import covalent_radii
Expand Down
6 changes: 4 additions & 2 deletions crys3d/wx_model_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@

from crys3d import wx_tools
from crys3d.model import model_data
# pyopengl GLU imports may change location of gltbx imports (e.g. quadrics),
# so place these first
from gltbx.gl import *
from gltbx.glu import *
from gltbx.wx_viewer import wxGLWindow
import gltbx.util
from gltbx import viewer_utils, quadrics
from gltbx.gl import *
from gltbx.glu import *
import gltbx
import libtbx.phil
from libtbx.introspection import method_debug_log
Expand Down
6 changes: 3 additions & 3 deletions gltbx/images.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import absolute_import, division, print_function
import os.path
from libtbx.utils import to_bytes
from six.moves import range

def encode(data):
Expand Down Expand Up @@ -50,9 +51,9 @@ def decode(self, edata):
def as_wx_Bitmap(self):
import wx
w,h = self.get_size()
data = self.get_data()
data = to_bytes(self.get_data())
mask = self.get_mask()
img = wx.EmptyImage(w, h)
img = wx.Image(w, h)
img.SetData(data)
if (mask >= 0):
img.SetMaskColour(ord(data[mask]), ord(data[mask+1]), ord(data[mask+2]))
Expand All @@ -64,4 +65,3 @@ def as_wx_Bitmap(self):
print('from gltbx.images import img_data\n')
for arg in sys.argv[1:]:
create_encoded(arg)

4 changes: 2 additions & 2 deletions gltbx/wx_ellipsoids_test.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from __future__ import absolute_import, division, print_function
import wx
import gltbx.util
from gltbx.gl import *
from gltbx.glu import *
from gltbx import wx_viewer
from gltbx import quadrics
import unicodedata
from gltbx.gl import *
from gltbx.glu import *
from six.moves import zip

class MyGLWindow(wx_viewer.wxGLWindow):
Expand Down
2 changes: 1 addition & 1 deletion gltbx/wx_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1021,7 +1021,7 @@ def OnInit(self):
" Keyboard shortcut: a")

self.toggle_spin_id = wx.NewId()
tb.AddCheckTool(self.toggle_spin_id,
tb.AddCheckTool(self.toggle_spin_id, 'label',
images.spin_img.as_wx_Bitmap(),
shortHelp="Spin on/off",
longHelp="Turns auto-spin on/off. Keyboard shortcut: s")
Expand Down

0 comments on commit 33f6a7e

Please sign in to comment.