Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
d416d4b
import tidy
David-Baddeley Jul 15, 2024
57fbdab
make text objects constant magnification and orientation
David-Baddeley Jul 15, 2024
e3a5ad4
make gl rendered text highdpi aware, add a labels layer type
David-Baddeley Jul 15, 2024
8b98178
fix updating
David-Baddeley Jul 15, 2024
a3d0477
fix colour mapping for text labels
David-Baddeley Jul 16, 2024
e933ab9
bring things kicking and screaming into present
David-Baddeley Jul 21, 2024
cba20c4
more moderngl fixes
David-Baddeley Jul 22, 2024
2eefee6
fix regression in legacy lut overlay
David-Baddeley Jul 22, 2024
23544dd
fix image layers in core profile
David-Baddeley Jul 22, 2024
c2d3444
fix pointsprites regression
David-Baddeley Jul 22, 2024
13eacf9
fix point scaling on highDPI displays
David-Baddeley Jul 22, 2024
eed324c
fix axes deprecation in legacy mode
David-Baddeley Jul 22, 2024
9a6de9f
add timing
David-Baddeley Jul 22, 2024
b75f670
fix LUT funnyness after refresh
David-Baddeley Jul 23, 2024
4b5ca38
fix text overlays for gl core profile
David-Baddeley Jul 23, 2024
3086557
work around for max point size (currently only for 'points' method)
David-Baddeley Jul 23, 2024
315c638
max point size bug fixed for spheres and pointsprites
David-Baddeley Jul 23, 2024
13d8624
update quiver and tracks layers for glcore
David-Baddeley Jul 25, 2024
488ab44
remove dependancy on PyGLM
David-Baddeley Jul 26, 2024
63d2ded
add geometry shader for wide lines
David-Baddeley Jul 28, 2024
a760fea
Merge branch 'master' of github.com:python-microscopy/python-microsco…
David-Baddeley Jul 28, 2024
436e5cf
fix axes overlay
David-Baddeley Jul 29, 2024
16af8f4
view clipping tidy up
David-Baddeley Jul 29, 2024
4ce69f7
fix line widths in quiver etc
David-Baddeley Jul 29, 2024
136e985
fix stencilling
David-Baddeley Jul 29, 2024
11e55a2
make flat points show up on linux
David-Baddeley Jul 30, 2024
15ba23d
fix transparent and shaded points
David-Baddeley Jul 30, 2024
1ef7f4f
remove unused import of legacy canvas
David-Baddeley Jul 30, 2024
d57adec
fix fProfile conversion and PYMEVis tabs on linux
David-Baddeley Jul 30, 2024
b5bad5a
fix GPU memory leak
David-Baddeley Jul 30, 2024
63fea98
add phong shading as option for meshes
David-Baddeley Jul 30, 2024
e3b8bfb
fix session loading
David-Baddeley Jul 30, 2024
52d57e3
fix point aspect ratio issue
David-Baddeley Jul 30, 2024
950dbc1
make paste into wx.py.shell work with unicode
David-Baddeley Jul 31, 2024
cfbfb51
fix text colour
David-Baddeley Jul 31, 2024
4ab33c9
fix for windows
David-Baddeley Jul 31, 2024
bdb33c8
fix scale box
David-Baddeley Jul 31, 2024
a677867
make core profile the default
David-Baddeley Jul 31, 2024
ccbc4df
add session support for more layer types
David-Baddeley Jul 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions PYME/Acquire/acquiremainframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import PYME.ui.manualFoldPanel as afp
import wx
import wx.lib.agw.aui as aui
import wx.py.shell
import PYME.ui.shell

logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -122,7 +122,7 @@ def __init__(self, parent, options = None):
self.splash.Show()


self.sh = wx.py.shell.Shell(id=-1,
self.sh = PYME.ui.shell.Shell(id=-1,
parent=self, size=wx.Size(-1, -1), style=0, locals=self.__dict__,
introText='PYMEAcquire - note that help, license, etc. below is for Python, not PYME\n\n')
self.AddPage(self.sh, caption='Shell')
Expand Down
2 changes: 1 addition & 1 deletion PYME/DSView/modules/annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ def DrawOverlays(self, view, dc):
def render(self, gl_canvas):
import OpenGL.GL as gl

gl.glDisable(gl.GL_LIGHTING)
#gl.glDisable(gl.GL_LIGHTING)
gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_LINE)
gl.glDisable(gl.GL_DEPTH_TEST)

Expand Down
8 changes: 7 additions & 1 deletion PYME/DSView/modules/psfTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,19 @@
import wx
import wx.html2
import wx.grid
import wx.lib.agw.aui as aui


from jinja2 import Environment, PackageLoader
env = Environment(loader=PackageLoader('PYME.DSView.modules', 'templates'))

from PYME.recipes.traits import HasTraits, Float, Int, Bool, Enum
import numpy as np

from matplotlib.figure import Figure
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas

from .graphViewPanel import *
#from .graphViewPanel import *
from PYME.Analysis.PSFEst import psfQuality

def remove_newlines(s):
Expand Down
4 changes: 2 additions & 2 deletions PYME/DSView/modules/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
#
##################

import wx.py.shell
import PYME.ui.shell
from PYME import config

def Plug(dsviewer):
sh = wx.py.shell.Shell(id=-1,
sh = PYME.ui.shell.Shell(id=-1,
parent=dsviewer, pos=wx.Point(0, 0), size=wx.Size(618, 451), style=0, locals=dsviewer.__dict__,
startupScript=config.get('dh5View-console-startup-file', None),
introText='PYMEImage - note that help, license, etc. below is for Python, not PYME\n\n')
Expand Down
8 changes: 7 additions & 1 deletion PYME/DSView/modules/visgui.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@
import os

from PYME.DSView.arrayViewPanel import ArrayViewPanel
from PYME.LMVis.gl_render3D_shaders import LMGLShaderCanvas

import PYME.config

if PYME.config.get('VisGUI-opengl-core-profile', False):
from PYME.LMVis.glcanvas_core import LMGLShaderCanvas
else:
from PYME.LMVis.gl_render3D_shaders import LMGLShaderCanvas

from six.moves import xrange

Expand Down
4 changes: 2 additions & 2 deletions PYME/LMVis/Extras/annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ def render(self, gl_canvas):
if not self.visible:
return

self._clear_shader_clipping(gl_canvas)
with self.get_shader_program(gl_canvas):
with self.get_shader_program(gl_canvas) as sp:
sp.clear_shader_clipping()
self._annotator.render(gl_canvas)

class Annotator(ann.AnnotateBase):
Expand Down
1 change: 1 addition & 0 deletions PYME/LMVis/Extras/extra_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ def open_surface(visFr):
raise ValueError('Invalid file extension .' + str(ext))
layer = TriangleRenderLayer(visFr.pipeline, dsname=surf_name, method='shaded')
visFr.add_layer(layer)
visFr.update_datasource_panel()

def save_surface(visFr):
import wx
Expand Down
12 changes: 9 additions & 3 deletions PYME/LMVis/VisGUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import argparse

import wx
import wx.py.shell
import PYME.ui.shell

#hacked so py2exe works
#from PYME.DSView.dsviewer import View3D
Expand Down Expand Up @@ -112,7 +112,8 @@ def __init__(self, parent, filename=None, id=wx.ID_ANY,
################################

self.MainWindow = self #so we can access from shell
self.sh = wx.py.shell.Shell(id=-1,
self.pymevis = self # more memorable alias for the main window
self.sh = PYME.ui.shell.Shell(id=-1,
parent=self, size=wx.Size(-1, -1), style=0, locals=self.__dict__,
startupScript=config.get('VisGUI-console-startup-file', None),
introText='PYMEVisualize - note that help, license, etc. below is for Python, not PYME\n\n')
Expand All @@ -130,7 +131,9 @@ def __init__(self, parent, filename=None, id=wx.ID_ANY,

self.generatedImages = []

self.sh.Execute('from pylab import *')
#self.sh.Execute('from pylab import *')
self.sh.Execute('import numpy as np')
self.sh.Execute('import matplotlib.pyplot as plt')
self.sh.Execute('from PYME.DSView.dsviewer import View3D')

import os
Expand Down Expand Up @@ -456,6 +459,8 @@ def parse():
default=True, help='switch shaders off(default: off)')
parser.add_argument('--new-layers', dest='new_layers', action='store_true', default=True)
parser.add_argument('--no-layers', dest='new_layers', action='store_false', default=True)
parser.add_argument('--opengl-core-profile', dest='opengl_core_profile', action='store_true', default=True)
parser.add_argument('--opengl-compatibility-profile', dest='opengl_core_profile', action='store_false', default=True)
parser.add_argument('-l', '--load', nargs=2, action='append', default=[], dest='load', metavar=('KEY', 'FILENAME'), help='Load one (or more) additional files into the recipe namespace.')
args = parser.parse_args()
return args
Expand All @@ -469,6 +474,7 @@ def main():
args = parse()

PYME.config.config['VisGUI-new_layers'] = args.new_layers
PYME.config.config['VisGUI-opengl-core-profile'] = args.opengl_core_profile

if wx.GetApp() is None: #check to see if there's already a wxApp instance (running from ipython -pylab or -wthread)
main_(args.file, use_shaders=args.use_shaders, args=args)
Expand Down
39 changes: 23 additions & 16 deletions PYME/LMVis/gl_render3D_shaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#
##################
from math import floor
import time

import numpy
import numpy as np
Expand Down Expand Up @@ -89,6 +90,8 @@ class LMGLShaderCanvas(GLCanvas):
ScaleBoxOverlayLayer = None
_is_initialized = False

core_profile = False #legacy fixed function OpenGL pipeline (see glcanvas_core.py for modern core profile implementation)

def __init__(self, parent, show_lut=True, display_mode='2D', view=None):
print("New Canvas")
attribute_list = [wx.glcanvas.WX_GL_RGBA, wx.glcanvas.WX_GL_STENCIL_SIZE, 8, wx.glcanvas.WX_GL_DOUBLEBUFFER]
Expand Down Expand Up @@ -300,10 +303,7 @@ def interlace_stencil(self):
# TODO - do we need to do anything differnt on win?
vmajor,vminor = wx.VERSION[:2]

if (vmajor >= 4) and (vminor >=1): # 4.1 or later
sc = self.GetContentScaleFactor()
else:
sc = 1
sc = self.content_scale_factor

#print('scale factor:', sc)

Expand Down Expand Up @@ -355,6 +355,7 @@ def _stereo_views(self):
return ['centre']

def OnDraw(self):
t0 = time.time()
self.SetCurrent(self.gl_context)
self.interlace_stencil()
GL.glEnable(GL.GL_DEPTH_TEST)
Expand Down Expand Up @@ -388,6 +389,8 @@ def OnDraw(self):
GL.glOrtho(-1, 1, ys, -ys, -1000, 1000)

GL.glMatrixMode(GL.GL_MODELVIEW)

#stereo offset
GL.glTranslatef(eye, 0.0, 0.0)

# move our object to be centred at -10
Expand All @@ -412,7 +415,7 @@ def OnDraw(self):

oit_layers = [] #layers which support order independent transparency - render these all together
for l in self.layers:
if getattr(l.engine, 'use_oit', lambda l: False)(l) or getattr(l.engine, 'oit', False):
if hasattr(l, 'engine') and (getattr(l.engine, 'use_oit', lambda l: False)(l) or getattr(l.engine, 'oit', False)):
#defer rendering
oit_layers.append(l)
else:
Expand Down Expand Up @@ -444,6 +447,8 @@ def OnDraw(self):
GL.glFlush()

self.SwapBuffers()

logger.debug('Frame rendered in: %3.4fs' % (time.time() - t0))

def init_oit(self):
self._fb = GL.glGenFramebuffers(1)
Expand Down Expand Up @@ -474,11 +479,7 @@ def resize_gl_oit(self, w, h):
# fix scaling error
# TODO - should this check be on wx, or OpenGL (or potentially python)
# TODO - do we need to do anything differnt on win?
vmajor,vminor = wx.VERSION[:2]
if vmajor >= 4 and vminor >=1: # 4.1 or later
sc = self.GetContentScaleFactor()
else:
sc = 1
sc = self.content_scale_factor

#sc = 1

Expand Down Expand Up @@ -696,6 +697,16 @@ def ymax(self):
def pixelsize(self):
return 2. / (self.view.scale * self.view_port_size[0])

@property
def content_scale_factor(self):
# version-safe way to get the content scale factor for high DPI screens
vmajor,vminor = wx.VERSION[:2]
if vmajor >= 4 and vminor >=1: # 4.1 or later
sc = self.GetContentScaleFactor()
else:
sc = 1
return sc

def _view_changed(self):
"""Notify anyone who is synced to our view"""
for callback in self.wantViewChangeNotification:
Expand Down Expand Up @@ -826,7 +837,7 @@ def OnMiddleUp(self, event):

def _ScreenCoordinatesToNm(self, x, y):
# FIXME!!!
sc = self.GetContentScaleFactor()
sc = self.content_scale_factor
x_ = self.pixelsize * (x - 0.5 * float(self.view_port_size[0])) + self.view.translation[0]
y_ = self.pixelsize * (y - 0.5 * float(self.view_port_size[1])) + self.view.translation[1]
# print x_, y_
Expand Down Expand Up @@ -944,11 +955,7 @@ def getSnapshot(self, mode=GL.GL_RGB):
# raise RuntimeError('{} is not a supported format.'.format(mode))
# img.show()
self.on_screen = False
vmajor, vminor = wx.VERSION[:2]
if (vmajor >= 4) and (vminor >= 1):
sc = self.GetContentScaleFactor()
else:
sc = 1
sc = self.content_scale_factor
view_port_size = (int(self.view_port_size[0]*sc), int(self.view_port_size[1]*sc))
off_screen_handler = OffScreenHandler(view_port_size, mode, self._num_antialias_samples)
with off_screen_handler:
Expand Down
Loading