<s> import math <EOL> import numpy as np <EOL> from OpenGL . GL import * <EOL> from OpenGL . GLU import * <EOL> from OpenGL . GLUT import * <EOL> from boxfish . gl . glutils import * <EOL> from Torus5dModule import * <EOL> from OpenGL . GLE import glePolyCylinder <EOL> class Torus5dViewOverview ( Torus5dGLWidget ) : <EOL> '''<STR_LIT>''' <EOL> viewPlanesUpdateSignal = Signal ( dict ) <EOL> axisUpdateSignal = Signal ( int , int ) <EOL> def __init__ ( self , parent , dataModel ) : <EOL> '''<STR_LIT>''' <EOL> super ( Torus5dViewOverview , self ) . __init__ ( parent , dataModel , rotation = False ) <EOL> self . showVariance = False <EOL> self . overviewList = DisplayList ( self . drawOverview ) <EOL> self . overviewToolBarList = DisplayList ( self . drawOverviewToolBar ) <EOL> self . resizeSignal . connect ( self . updateDrawing ) <EOL> self . widget3dLists = [ ] <EOL> self . widget3dLists . append ( self . overviewList ) <EOL> self . widget2dLists = [ ] <EOL> self . widget2dLists . append ( self . overviewToolBarList ) <EOL> self . valuesInitialized = False <EOL> Qt . ShiftModifier = False <EOL> shape = property ( fget = lambda self : self . dataModel . shape ) <EOL> view_planes = property ( fget = lambda self : self . dataModel . view_planes ) <EOL> current_planes = property ( fget = lambda self : self . dataModel . current_planes ) <EOL> def initializeGL ( self ) : <EOL> """<STR_LIT>""" <EOL> super ( Torus5dViewOverview , self ) . initializeGL ( ) <EOL> glEnable ( GL_BLEND ) <EOL> glBlendFunc ( GL_SRC_ALPHA , GL_ONE_MINUS_SRC_ALPHA ) <EOL> def resetView ( self ) : <EOL> slice_shape = self . getSliceShape ( ) <EOL> w_span , h_span = slice_shape [ <NUM_LIT:0> ] , slice_shape [ <NUM_LIT:1> ] <EOL> if w_span != <NUM_LIT:0> and h_span != <NUM_LIT:0> : <EOL> single_span = self . getSliceSpan ( slice_shape ) <EOL> self . miniGap = single_span [ <NUM_LIT:0> ] / <NUM_LIT> <EOL> self . miniSpanX = single_span [ <NUM_LIT:0> ] <EOL> self . miniSpanY = single_span [ <NUM_LIT:1> ] <EOL> spans = single_span <EOL> spans [ <NUM_LIT:0> ] = ( self . miniGap + single_span [ <NUM_LIT:0> ] ) * self . shape [ <NUM_LIT:4> ] + self . miniGap <EOL> self . totalSpanX = spans [ <NUM_LIT:0> ] <EOL> aspect = self . width ( ) / float ( self . height ( ) ) <EOL> fovy = float ( self . fov ) * math . pi / <NUM_LIT> <EOL> disty = spans [ <NUM_LIT:1> ] / <NUM_LIT> / math . tan ( fovy ) <EOL> fovx = fovy * aspect <EOL> distx = spans [ <NUM_LIT:0> ] / <NUM_LIT> / math . tan ( fovx ) <EOL> self . translation = [ <NUM_LIT> , - <NUM_LIT> , - <NUM_LIT> ] <EOL> self . rotation = [ [ <NUM_LIT> , <NUM_LIT> , - <NUM_LIT> , <NUM_LIT:0.> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:0.> ] , <EOL> [ <NUM_LIT> , - <NUM_LIT> , <NUM_LIT> , <NUM_LIT:0.> ] , <EOL> [ <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:1.> ] ] <EOL> def update ( self , colors = True , values = True , reset = True ) : <EOL> if colors : super ( Torus5dViewOverview , self ) . update ( ) <EOL> if values : self . updateMiniMapValues ( ) <EOL> if reset : self . resetView ( ) <EOL> self . updateDrawing ( ) <EOL> def updateAxis ( self , axis , axis_index = - <NUM_LIT:1> ) : <EOL> '''<STR_LIT>''' <EOL> if self . axis != axis or self . axis_index != axis_index : <EOL> if axis_index == - <NUM_LIT:1> : <EOL> if self . axis == axis : <EOL> self . axis_index = self . nextAxisIndex ( ) <EOL> else : <EOL> self . axis_index = <NUM_LIT:0> <EOL> self . axis = axis <EOL> else : <EOL> self . axis = axis <EOL> self . axis_index = axis_index <EOL> self . resetView ( ) <EOL> self . updateDrawing ( ) <EOL> def updateDrawing ( self ) : <EOL> for disp_list in self . widget3dLists : <EOL> disp_list . update ( ) <EOL> for disp_list in self . widget2dLists : <EOL> disp_list . update ( ) <EOL> self . paintEvent ( None ) <EOL> def updateMiniMapValues ( self ) : <EOL> '''<STR_LIT>''' <EOL> self . planeLinkColors = list ( ) <EOL> plane_tot_index = <NUM_LIT:0> <EOL> plane_avg_index = <NUM_LIT:0> <EOL> for axis in range ( <NUM_LIT:4> ) : <EOL> aindex = <NUM_LIT:0> <EOL> for w , h , d in self . axis_map [ axis ] : <EOL> shape = self . shape [ : ] <EOL> slice_shape = [ shape [ w ] , shape [ h ] , shape [ axis ] ] <EOL> slice_indicies = [ w , h , axis ] <EOL> non_slice_indicies = [ i for i in range ( len ( shape ) ) if i not in slice_indicies ] <EOL> d_values = [ <NUM_LIT:0> ] <EOL> mini_shape = list ( ) <EOL> if shape [ axis ] != <NUM_LIT:0> : <EOL> shape = list ( shape ) <EOL> mini_shape = [ shape [ i ] if i in slice_indicies [ : <NUM_LIT:2> ] else <NUM_LIT:1> for i in range ( len ( shape ) ) ] <EOL> mini_shape = tuple ( mini_shape ) <EOL> plane_link_colors = np . tile ( self . default_link_color , [ shape [ d ] , shape [ <NUM_LIT:4> ] , shape [ w ] , shape [ h ] , <NUM_LIT:1> ] + [ <NUM_LIT:3> , <NUM_LIT:1> ] ) <EOL> plane_link_values = np . tile ( [ <NUM_LIT:0.> for i in range ( self . shape [ axis ] ) ] , [ shape [ d ] , shape [ <NUM_LIT:4> ] ] + [ shape [ w ] , shape [ h ] , <NUM_LIT:1> ] + [ <NUM_LIT:3> , <NUM_LIT:1> ] ) <EOL> plane_tot_index = <NUM_LIT:0> <EOL> for node in np . ndindex ( * mini_shape ) : <EOL> dim_count = <NUM_LIT:0> <EOL> for dim in slice_indicies : <EOL> val = [ [ <NUM_LIT:0.0> for k in range ( self . shape [ <NUM_LIT:4> ] ) ] for j in range ( self . shape [ d ] ) ] <EOL> count = [ [ <NUM_LIT:0> for k in range ( self . shape [ <NUM_LIT:4> ] ) ] for j in range ( self . shape [ d ] ) ] <EOL> subNode = list ( node ) <EOL> link_values = [ [ [ ] for k in range ( self . shape [ <NUM_LIT:4> ] ) ] for j in range ( self . shape [ d ] ) ] <EOL> for i in range ( self . shape [ axis ] ) : <EOL> for j in range ( self . shape [ d ] ) : <EOL> higher_dims = [ t for t in non_slice_indicies if t != d ] <EOL> for k in range ( self . shape [ higher_dims [ <NUM_LIT:0> ] ] ) : <EOL> subNode [ axis ] = i <EOL> subNode [ non_slice_indicies [ <NUM_LIT:0> ] ] = j <EOL> subNode [ non_slice_indicies [ <NUM_LIT:1> ] ] = k <EOL> current = self . dataModel . link_values [ <EOL> tuple ( subNode ) ] [ dim ] [ <NUM_LIT:0> ] <EOL> plane_link_values [ j ] [ k ] [ tuple ( [ node [ w ] , node [ h ] , <NUM_LIT:0> ] ) ] [ dim_count ] [ i ] = current <EOL> val [ j ] [ k ] += current <EOL> count [ j ] [ k ] += self . dataModel . link_values [ <EOL> tuple ( subNode ) ] [ dim ] [ <NUM_LIT:1> ] <EOL> if shape [ axis ] != <NUM_LIT:0> : <EOL> for j in range ( self . shape [ d ] ) : <EOL> for k in range ( self . shape [ higher_dims [ <NUM_LIT:0> ] ] ) : <EOL> plane_link_colors [ j ] [ k ] [ ( node [ w ] , node [ h ] , <NUM_LIT:0> ) ] [ dim_count ] = self . map_link_color ( <EOL> val [ j ] [ k ] / float ( self . shape [ axis ] ) , <NUM_LIT:1.0> ) if count [ j ] [ k ] / float ( self . shape [ axis ] ) >= <NUM_LIT:1> else self . default_link_color <EOL> dim_count += <NUM_LIT:1> <EOL> '''<STR_LIT>''' <EOL> self . planeLinkColors . append ( plane_link_colors . copy ( ) ) <EOL> aindex += <NUM_LIT:1> <EOL> self . valuesInitialized = True <EOL> def getAxisLabelColor ( self , val ) : <EOL> if val == '<STR_LIT:a>' : <EOL> color = ( <NUM_LIT:0.1> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:1.> ) <EOL> elif val == '<STR_LIT:b>' : <EOL> color = ( <NUM_LIT:0.1> , <NUM_LIT:0.1> , <NUM_LIT:1.> , <NUM_LIT:1.> ) <EOL> elif val == '<STR_LIT:c>' : <EOL> color = ( <NUM_LIT:1.> , <NUM_LIT:0.5> , <NUM_LIT:0.1> , <NUM_LIT:1.> ) <EOL> elif val == '<STR_LIT:d>' : <EOL> color = ( <NUM_LIT> , <NUM_LIT:0.1> , <NUM_LIT> , <NUM_LIT:1.> ) <EOL> elif val == '<STR_LIT:e>' : <EOL> color = ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT:0.1> , <NUM_LIT:1.> ) <EOL> elif val == <NUM_LIT:0> : <EOL> color = ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:1.> ) <EOL> return tuple ( list ( np . add ( color [ : <NUM_LIT:3> ] , <NUM_LIT> ) ) + [ <NUM_LIT:1.> ] ) <EOL> def getBorderColor ( self , axis , axis_index , d_val , e_val , d_color = True ) : <EOL> '''<STR_LIT>''' <EOL> w , h , d = self . axis_map [ axis ] [ axis_index ] <EOL> coords = self . parent . agent . coords <EOL> if axis == self . axis and axis_index == self . axis_index and d_val == self . current_planes [ d ] and e_val == self . current_planes [ <NUM_LIT:4> ] : <EOL> return self . getAxisLabelColor ( <NUM_LIT:0> ) <EOL> elif ( d_val , e_val ) in self . view_planes [ d ] : <EOL> if d_color : <EOL> return self . getAxisLabelColor ( coords [ d ] ) <EOL> else : <EOL> return self . getAxisLabelColor ( coords [ <NUM_LIT:4> ] ) <EOL> elif self . bright_bg_color : <EOL> return ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) <EOL> else : <EOL> return ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) <EOL> def getCylinderIndex ( self , node , shape , axis ) : <EOL> """<STR_LIT>""" <EOL> dims = shape [ : axis ] + shape [ axis + <NUM_LIT:1> : ] <EOL> num_cylinders = ( min ( dims ) + <NUM_LIT:1> ) / <NUM_LIT:2> <EOL> nonaxis = node [ : axis ] + node [ axis + <NUM_LIT:1> : ] <EOL> d_near_edge = [ min ( abs ( d - n - <NUM_LIT:1> ) , n ) for n , d in zip ( nonaxis , dims ) ] <EOL> return num_cylinders - min ( d_near_edge ) - <NUM_LIT:1> <EOL> def getMousePress ( self , x , y ) : <EOL> for i in range ( <NUM_LIT:4> ) : <EOL> x_start = self . arrowPos [ i ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] <EOL> x_end = self . arrowPos [ i ] [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] <EOL> y_start = self . arrowPos [ i ] [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] <EOL> y_end = self . arrowPos [ i ] [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] <EOL> if x >= x_start and x <= x_end and y >= y_start and y <= y_end : <EOL> if i == <NUM_LIT:0> : <EOL> self . changeView ( inc = False ) <EOL> elif i == <NUM_LIT:1> : <EOL> self . changeView ( inc = True ) <EOL> elif i == <NUM_LIT:2> : <EOL> self . changeViewPlane ( inc = True ) <EOL> else : <EOL> self . changeViewPlane ( inc = False ) <EOL> def getNextNode ( self , point , axis , amount ) : <EOL> """<STR_LIT>""" <EOL> p = list ( point ) <EOL> p [ axis ] += amount <EOL> return tuple ( p ) <EOL> def getNodePos2d ( self , node , shape , axis = <NUM_LIT:2> , scale = <NUM_LIT:1> ) : <EOL> '''<STR_LIT>''' <EOL> b = self . node_size * self . node_pack_factor <EOL> h = ( shape [ axis ] * b ) + self . gap <EOL> def coord ( n , d ) : <EOL> center = float ( shape [ d ] - <NUM_LIT:1> ) / <NUM_LIT:2> <EOL> inset = node [ axis ] * b * np . sign ( center - n ) <EOL> even = ( shape [ d ] % <NUM_LIT:2> == <NUM_LIT:0> ) <EOL> return h * ( n + int ( even and n > center ) ) + inset <EOL> dim = range ( <NUM_LIT:3> ) <EOL> dim . remove ( axis ) <EOL> node2d = np . zeros ( <NUM_LIT:3> ) <EOL> for d in dim : <EOL> node2d [ d ] = scale * coord ( node [ d ] , d ) <EOL> node2d *= self . axis_directions <EOL> return node2d <EOL> def getPlaneSpacing ( self ) : <EOL> slice_w , slice_h , slice_d = self . getSliceDims ( ) <EOL> spacing = self . getSliceSpan ( self . getSliceShape ( ) ) [ <NUM_LIT:1> ] <EOL> for axis in range ( len ( self . shape ) - <NUM_LIT:1> ) : <EOL> for axis_index in range ( len ( self . axis_map [ axis ] ) ) : <EOL> w , h , d = self . axis_map [ axis ] [ axis_index ] <EOL> if d == slice_d : <EOL> new_spacing = self . getSliceSpan ( [ self . shape [ w ] , self . shape [ h ] , self . shape [ d ] ] ) [ <NUM_LIT:1> ] <EOL> spacing = max ( spacing , new_spacing ) <EOL> return spacing <EOL> def getSliceDims ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . axis_map [ self . axis ] [ self . axis_index ] <EOL> def getSliceShape ( self ) : <EOL> '''<STR_LIT>''' <EOL> w , h , d = self . getSliceDims ( ) <EOL> return [ self . shape [ w ] , self . shape [ h ] , self . shape [ self . axis ] ] <EOL> def getSliceSpan ( self , shape , axis = <NUM_LIT:2> ) : <EOL> """<STR_LIT>""" <EOL> if len ( shape ) != <NUM_LIT:3> : <EOL> return <EOL> shape [ axis ] = <NUM_LIT:1> <EOL> x_span = abs ( self . getNodePos2d ( [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ] , shape , axis ) - <EOL> self . getNodePos2d ( [ shape [ <NUM_LIT:0> ] - <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> ] , shape , axis ) ) <EOL> y_span = abs ( self . getNodePos2d ( [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ] , shape , axis ) - <EOL> self . getNodePos2d ( [ <NUM_LIT:0> , shape [ <NUM_LIT:1> ] - <NUM_LIT:1> , <NUM_LIT:0> ] , shape , axis ) ) <EOL> z_span = abs ( self . getNodePos2d ( [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ] , shape , axis ) - <EOL> self . getNodePos2d ( [ <NUM_LIT:0> , <NUM_LIT:0> , shape [ <NUM_LIT:2> ] - <NUM_LIT:1> ] , shape , axis ) ) <EOL> return [ x_span [ <NUM_LIT:0> ] , y_span [ <NUM_LIT:1> ] , z_span [ <NUM_LIT:2> ] ] <EOL> def paintEvent ( self , event ) : <EOL> '''<STR_LIT>''' <EOL> with setupPaintEvent ( self ) : <EOL> glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) <EOL> glGetError ( ) <EOL> self . orient_scene ( ) <EOL> self . draw ( ) <EOL> super ( Torus5dViewOverview , self ) . paintEvent ( event ) <EOL> def draw ( self , toolbar = True ) : <EOL> '''<STR_LIT>''' <EOL> for func in self . widget3dLists : <EOL> func ( ) <EOL> if toolbar : <EOL> with overlays2D ( self . width ( ) , self . height ( ) , self . bg_color ) : <EOL> for func in self . widget2dLists : <EOL> func ( ) <EOL> def drawOverview ( self ) : <EOL> if max ( self . shape ) == <NUM_LIT:0> : <EOL> return <EOL> elif not self . valuesInitialized : <EOL> return <EOL> grey_value = ( self . bg_color [ <NUM_LIT:0> ] + self . bg_color [ <NUM_LIT:1> ] + self . bg_color [ <NUM_LIT:2> ] ) / <NUM_LIT:3> <EOL> if grey_value >= <NUM_LIT:0.5> : <EOL> self . bright_bg_color = True <EOL> else : <EOL> self . bright_bg_color = False <EOL> if grey_value >= <NUM_LIT> : <EOL> line_color = ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) <EOL> else : <EOL> line_color = ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) <EOL> prev_blend_on = glGetBoolean ( GL_BLEND ) <EOL> glEnable ( GL_BLEND ) <EOL> glBlendFunc ( GL_SRC_ALPHA , GL_ONE_MINUS_SRC_ALPHA ) <EOL> glClearColor ( * self . bg_color ) <EOL> glClear ( GL_COLOR_BUFFER_BIT ) <EOL> glClear ( GL_DEPTH_BUFFER_BIT ) <EOL> self . cylinder_width = <NUM_LIT:0.5> <EOL> w , h , d = self . axis_map [ self . axis ] [ self . axis_index ] <EOL> z_translate = self . getPlaneSpacing ( ) <EOL> glLineWidth ( <NUM_LIT:1.> ) <EOL> with glMatrix ( ) : <EOL> grid_y = - z_translate * <NUM_LIT:10> / <NUM_LIT> <EOL> max_grid_z = z_translate * ( self . shape [ d ] - <NUM_LIT:1> ) <EOL> max_grid_x = self . totalSpanX - <NUM_LIT:2> * self . miniGap <EOL> offset_grid = self . miniGap / <NUM_LIT> <EOL> glTranslatef ( - self . totalSpanX / <NUM_LIT> + self . miniGap , <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> glColor4f ( * line_color ) <EOL> with glSection ( GL_LINES ) : <EOL> for grid_x in np . arange ( int ( <NUM_LIT:0> ) , int ( max_grid_x + <NUM_LIT:2> * offset_grid + <NUM_LIT:0.5> ) + <NUM_LIT:2> , <NUM_LIT:2> ) : <EOL> for grid_z in np . arange ( int ( <NUM_LIT:0> ) , int ( max_grid_z + <NUM_LIT:2> * offset_grid + <NUM_LIT:0.5> ) + <NUM_LIT:2> , <NUM_LIT:2> ) : <EOL> glVertex3f ( grid_x - <NUM_LIT:2> - offset_grid , grid_y , - grid_z + <NUM_LIT:2> + offset_grid ) <EOL> glVertex3f ( grid_x - offset_grid , grid_y , - grid_z + <NUM_LIT:2> + offset_grid ) <EOL> glVertex3f ( grid_x - <NUM_LIT:2> - offset_grid , grid_y , - grid_z + offset_grid ) <EOL> glVertex3f ( grid_x - <NUM_LIT:2> - offset_grid , grid_y , - grid_z + <NUM_LIT:2> + offset_grid ) <EOL> glLineWidth ( <NUM_LIT> ) <EOL> for j in range ( self . shape [ <NUM_LIT:4> ] ) : <EOL> with glMatrix ( ) : <EOL> glTranslatef ( <NUM_LIT:0> , self . miniSpanY - z_translate , <NUM_LIT:0> ) <EOL> for i in range ( self . shape [ d ] ) : <EOL> self . drawMiniMapPlane ( i , j ) <EOL> with glMatrix ( ) : <EOL> self . drawPlaneLabel ( i , j ) <EOL> glTranslatef ( <NUM_LIT:0> , <NUM_LIT:0> , - z_translate ) <EOL> glTranslatef ( self . miniSpanX + self . miniGap , <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> if not prev_blend_on : <EOL> glDisable ( GL_BLEND ) <EOL> def drawOverviewToolBar ( self ) : <EOL> prev_blend_on = glGetBoolean ( GL_BLEND ) <EOL> glEnable ( GL_BLEND ) <EOL> glBlendFunc ( GL_SRC_ALPHA , GL_ONE_MINUS_SRC_ALPHA ) <EOL> if max ( self . shape ) == <NUM_LIT:0> : <EOL> return <EOL> grey_value = ( self . bg_color [ <NUM_LIT:0> ] + self . bg_color [ <NUM_LIT:1> ] + self . bg_color [ <NUM_LIT:2> ] ) / <NUM_LIT:3> <EOL> if grey_value >= <NUM_LIT:0.5> : <EOL> self . bright_bg_color = True <EOL> else : <EOL> self . bright_bg_color = False <EOL> eff_size = min ( self . width ( ) , self . height ( ) ) <EOL> w = max ( int ( eff_size * <NUM_LIT> ) , <NUM_LIT> ) <EOL> w = min ( w , <NUM_LIT> ) <EOL> h = w <EOL> x = int ( self . width ( ) - w ) <EOL> y = int ( self . height ( ) - h ) <EOL> setup_overlay2D ( x , y , w , h ) <EOL> with glMatrix ( ) : <EOL> glLoadIdentity ( ) <EOL> glTranslatef ( x , y , <NUM_LIT:0.> ) <EOL> glTranslatef ( w * <NUM_LIT> , h * <NUM_LIT> , <NUM_LIT:0.> ) <EOL> self . arrowPos = [ [ [ x + w * <NUM_LIT> , x + w * <NUM_LIT> ] , [ y + h * <NUM_LIT> , y + h * <NUM_LIT> ] ] for i in range ( <NUM_LIT:4> ) ] <EOL> self . drawOverviewControls ( w * <NUM_LIT> , h * <NUM_LIT> ) <EOL> if not prev_blend_on : <EOL> glDisable ( GL_BLEND ) <EOL> def drawMiniMapPlane ( self , d_val , e_val ) : <EOL> """<STR_LIT>""" <EOL> w , h , d = self . axis_map [ self . axis ] [ self . axis_index ] <EOL> effective_shape = ( self . shape [ w ] , self . shape [ h ] , <NUM_LIT:1> ) <EOL> if ( d_val , e_val ) in self . view_planes [ d ] : <EOL> selected = True <EOL> else : <EOL> selected = False <EOL> self . drawLinks ( effective_shape , <NUM_LIT:2> , self . planeLinkColors [ self . axis * <NUM_LIT:3> + self . axis_index ] [ d_val ] [ e_val ] , None , <NUM_LIT:1> , selected = selected ) <EOL> def drawOverviewControls ( self , w , h ) : <EOL> if self . bright_bg_color : <EOL> fill_color = ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) <EOL> line_color = ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) <EOL> tri_color = ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) <EOL> else : <EOL> fill_color = ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) <EOL> line_color = ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) <EOL> tri_color = ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) <EOL> with glMatrix ( ) : <EOL> x = <NUM_LIT:0> <EOL> y = h * <NUM_LIT> <EOL> arrow_w = w * <NUM_LIT> - <NUM_LIT:1> <EOL> arrow_h = h * <NUM_LIT> <EOL> glTranslatef ( x , y , <NUM_LIT:0.> ) <EOL> self . drawArrow ( arrow_w , arrow_h , <NUM_LIT> , '<STR_LIT:left>' , fill_color , line_color , tri_color ) <EOL> self . arrowPos [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] += x <EOL> self . arrowPos [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] += x + arrow_w <EOL> self . arrowPos [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] += y <EOL> self . arrowPos [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] += y + arrow_h <EOL> with glMatrix ( ) : <EOL> x = w * <NUM_LIT> + <NUM_LIT:1> <EOL> y = h * <NUM_LIT> <EOL> arrow_w = w * <NUM_LIT> - <NUM_LIT:1> <EOL> arrow_h = h * <NUM_LIT> <EOL> glTranslatef ( x , y , <NUM_LIT:0.> ) <EOL> self . drawArrow ( arrow_w , arrow_h , <NUM_LIT> , '<STR_LIT:right>' , fill_color , line_color , tri_color ) <EOL> self . arrowPos [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] += x <EOL> self . arrowPos [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] += x + arrow_w <EOL> self . arrowPos [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] += y <EOL> self . arrowPos [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] += y + arrow_h <EOL> with glMatrix ( ) : <EOL> x = w * <NUM_LIT> <EOL> y = h * <NUM_LIT> + <NUM_LIT:1> <EOL> arrow_w = w * <NUM_LIT> <EOL> arrow_h = h * <NUM_LIT> - <NUM_LIT:1> <EOL> glTranslatef ( x , y , <NUM_LIT:0.> ) <EOL> self . drawArrow ( arrow_w , arrow_h , <NUM_LIT> , '<STR_LIT>' , fill_color , line_color , tri_color ) <EOL> self . arrowPos [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] += x <EOL> self . arrowPos [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] += x + arrow_w <EOL> self . arrowPos [ <NUM_LIT:2> ] [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] += y <EOL> self . arrowPos [ <NUM_LIT:2> ] [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] += y + arrow_h <EOL> with glMatrix ( ) : <EOL> x = w * <NUM_LIT> <EOL> y = <NUM_LIT:0.> <EOL> arrow_w = w * <NUM_LIT> <EOL> arrow_h = h * <NUM_LIT> - <NUM_LIT:1> <EOL> glTranslatef ( x , y , <NUM_LIT:0.> ) <EOL> self . drawArrow ( arrow_w , arrow_h , <NUM_LIT> , '<STR_LIT>' , fill_color , line_color , tri_color ) <EOL> self . arrowPos [ <NUM_LIT:3> ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] += x <EOL> self . arrowPos [ <NUM_LIT:3> ] [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] += x + arrow_w <EOL> self . arrowPos [ <NUM_LIT:3> ] [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] += y <EOL> self . arrowPos [ <NUM_LIT:3> ] [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] += y + arrow_h <EOL> with glMatrix ( ) : <EOL> glTranslatef ( w * <NUM_LIT> , h * <NUM_LIT> , <NUM_LIT:0.> ) <EOL> self . drawIcon ( w * <NUM_LIT> , h * <NUM_LIT> , <NUM_LIT> , fill_color , line_color ) <EOL> def drawPlaneLabel ( self , d_val , e_val ) : <EOL> label_width = <NUM_LIT> <EOL> label_height = <NUM_LIT> <EOL> if e_val == <NUM_LIT:0> : <EOL> offset_x = - self . miniSpanX * <NUM_LIT:6> / <NUM_LIT:4> <EOL> offset_z = self . miniSpanY <EOL> elif e_val == <NUM_LIT:1> : <EOL> offset_x = self . miniSpanX * <NUM_LIT:5> / <NUM_LIT> <EOL> offset_z = self . miniSpanY <EOL> glLineWidth ( <NUM_LIT> ) <EOL> glRotate ( <NUM_LIT> , - <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> if d_val == <NUM_LIT:0> : <EOL> with glMatrix ( ) : <EOL> dist_x = ( self . miniSpanX - label_width * <NUM_LIT> ) / <NUM_LIT> <EOL> glTranslatef ( dist_x , - <NUM_LIT:2> * label_height , - self . miniSpanY ) <EOL> self . drawLabel ( label_height * <NUM_LIT> , self . miniSpanX * <NUM_LIT> , d_val , e_val , draw_dim_d = False ) <EOL> glTranslatef ( offset_x , - label_height / <NUM_LIT> , - self . miniSpanY ) <EOL> self . drawLabel ( label_height , self . miniSpanX , d_val , e_val , draw_dim_d = True ) <EOL> def drawArrow ( self , w , h , z_dist , direction , fill_color , line_color , tri_color ) : <EOL> glColor4f ( * fill_color ) <EOL> self . drawRect ( w , h , z_dist ) <EOL> glColor4f ( * line_color ) <EOL> self . drawBorder ( w , h , <NUM_LIT:1.> , z_dist + <NUM_LIT:0.1> ) <EOL> with glMatrix ( ) : <EOL> glTranslatef ( w * <NUM_LIT> + <NUM_LIT:1> , h * <NUM_LIT> + <NUM_LIT:1> , <NUM_LIT:0.> ) <EOL> glColor4f ( * tri_color ) <EOL> self . drawArrowHead ( w * <NUM_LIT> - <NUM_LIT:2> , h * <NUM_LIT> - <NUM_LIT:2> , z_dist + <NUM_LIT:0.1> , <NUM_LIT:1> , direction ) <EOL> def drawIcon ( self , w , h , z_dist , fill_color , line_color ) : <EOL> '''<STR_LIT>''' <EOL> width , height , depth = self . getSliceDims ( ) <EOL> glColor4f ( * fill_color ) <EOL> self . drawRect ( w , h , z_dist ) <EOL> dim_char = self . parent . agent . coords [ depth ] <EOL> eff_size = min ( w , h ) <EOL> scale_factor = eff_size * <NUM_LIT> <EOL> glColor4f ( * line_color ) <EOL> with glMatrix ( ) : <EOL> glTranslatef ( w * <NUM_LIT> , h * <NUM_LIT> , z_dist + <NUM_LIT> ) <EOL> glScalef ( scale_factor , scale_factor , <NUM_LIT:1.> ) <EOL> glutStrokeCharacter ( GLUT_STROKE_ROMAN , ord ( dim_char ) ) <EOL> glColor4f ( * self . getAxisLabelColor ( dim_char ) ) <EOL> self . drawBorder ( w , h , <NUM_LIT:1.> , z_dist + <NUM_LIT> ) <EOL> def drawLabel ( self , label_height , label_width , d_val , e_val , draw_dim_d ) : <EOL> coords = self . parent . agent . coords <EOL> w , h , d = self . axis_map [ self . axis ] [ self . axis_index ] <EOL> if self . bright_bg_color : <EOL> border_color = ( <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT> ) <EOL> text_color = border_color <EOL> fill_color = ( <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:0.1> ) <EOL> else : <EOL> border_color = ( <NUM_LIT:1.> , <NUM_LIT:1.> , <NUM_LIT:1.> , <NUM_LIT> ) <EOL> text_color = border_color <EOL> fill_color = ( <NUM_LIT:1.> , <NUM_LIT:1.> , <NUM_LIT:1.> , <NUM_LIT:0.1> ) <EOL> if draw_dim_d : <EOL> border_color = self . getBorderColor ( self . axis , self . axis_index , d_val , e_val ) <EOL> dim_char = coords [ d ] <EOL> dim_val = d_val <EOL> scale_factor = <NUM_LIT> <EOL> else : <EOL> dim_char = coords [ <NUM_LIT:4> ] <EOL> dim_val = e_val <EOL> scale_factor = <NUM_LIT> <EOL> if len ( str ( dim_val ) ) > <NUM_LIT:1> : <EOL> if draw_dim_d : <EOL> offset_x = self . miniSpanX / <NUM_LIT> <EOL> else : <EOL> offset_x = self . miniSpanX / <NUM_LIT> <EOL> two_digit_val = True <EOL> scale_factor -= <NUM_LIT> <EOL> else : <EOL> if draw_dim_d : <EOL> offset_x = self . miniSpanX / <NUM_LIT> <EOL> else : <EOL> offset_x = self . miniSpanX / <NUM_LIT> <EOL> two_digit_val = False <EOL> for border in [ <NUM_LIT:0> , <NUM_LIT:0.5> ] : <EOL> if border > <NUM_LIT:0> and draw_dim_d : <EOL> glColor4f ( * border_color ) <EOL> offset_z = - <NUM_LIT:0.1> <EOL> elif border > <NUM_LIT:0> : <EOL> offset_z = - <NUM_LIT:0.1> <EOL> else : <EOL> glColor4f ( * fill_color ) <EOL> offset_z = <NUM_LIT:0> <EOL> if draw_dim_d and border == <NUM_LIT:0> : <EOL> glLoadName ( e_val * self . shape [ d ] + d_val ) <EOL> glPushMatrix ( ) <EOL> with glSection ( GL_TRIANGLES ) : <EOL> glVertex3f ( - border , - border , offset_z ) <EOL> glVertex3f ( label_width + border , - border , offset_z ) <EOL> glVertex3f ( label_width + border , label_height + border , offset_z ) <EOL> glVertex3f ( label_width + border , label_height + border , offset_z ) <EOL> glVertex3f ( - border , label_height + border , offset_z ) <EOL> glVertex3f ( - border , - border , offset_z ) <EOL> if draw_dim_d and border == <NUM_LIT:0> : <EOL> glPopMatrix ( ) <EOL> glColor4f ( * text_color ) <EOL> glLineWidth ( <NUM_LIT> ) <EOL> glTranslatef ( offset_x , label_height / <NUM_LIT> , <NUM_LIT:0.> ) <EOL> with glMatrix ( ) : <EOL> glScalef ( scale_factor , scale_factor , <NUM_LIT:1> ) <EOL> glutStrokeCharacter ( GLUT_STROKE_ROMAN , ord ( dim_char ) ) <EOL> glTranslatef ( self . miniSpanX / <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> with glMatrix ( ) : <EOL> glScalef ( scale_factor , scale_factor , <NUM_LIT:1> ) <EOL> glutStrokeCharacter ( GLUT_STROKE_ROMAN , ord ( '<STR_LIT:=>' ) ) <EOL> glTranslatef ( self . miniSpanX / <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> with glMatrix ( ) : <EOL> glScalef ( scale_factor , scale_factor , <NUM_LIT:1> ) <EOL> glutStrokeCharacter ( GLUT_STROKE_ROMAN , ord ( str ( dim_val ) [ <NUM_LIT:0> ] ) ) <EOL> if two_digit_val : <EOL> glTranslatef ( self . miniSpanX / <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> with glMatrix ( ) : <EOL> glScalef ( scale_factor , scale_factor , <NUM_LIT:1> ) <EOL> glutStrokeCharacter ( GLUT_STROKE_ROMAN , ord ( str ( dim_val ) [ <NUM_LIT:1> ] ) ) <EOL> def drawLinks ( self , shape , axis , link_colors , link_variance , scale = <NUM_LIT:1> , selected = True ) : <EOL> glMaterialfv ( GL_FRONT_AND_BACK , GL_DIFFUSE , [ <NUM_LIT:1.0> , <NUM_LIT:1.0> , <NUM_LIT:1.0> , <NUM_LIT:1.0> ] ) <EOL> glPushMatrix ( ) <EOL> shape = tuple ( shape ) <EOL> for start_node in np . ndindex ( * shape ) : <EOL> colors = link_colors [ start_node ] <EOL> start_cyl = self . getCylinderIndex ( start_node , shape , axis ) <EOL> start = np . array ( self . getNodePos2d ( start_node , shape , axis , scale ) ) <EOL> for dim in range ( <NUM_LIT:3> ) : <EOL> end_node = self . getNextNode ( start_node , dim , <NUM_LIT:1> ) <EOL> if end_node [ dim ] >= shape [ dim ] : <EOL> continue <EOL> end_cyl = self . getCylinderIndex ( end_node , shape , axis ) <EOL> if start_cyl == end_cyl : <EOL> if start_cyl == <NUM_LIT:0> : <EOL> for t in range ( <NUM_LIT:3> ) : <EOL> if t != axis and t != dim : break <EOL> left_cyl = self . getCylinderIndex ( self . getNextNode ( start_node , t , - <NUM_LIT:1> ) , shape , axis ) <EOL> right_cyl = self . getCylinderIndex ( self . getNextNode ( start_node , t , <NUM_LIT:1> ) , shape , axis ) <EOL> if end_cyl == right_cyl and end_cyl == left_cyl : <EOL> continue <EOL> end = np . array ( self . getNodePos2d ( end_node , shape , axis , scale ) ) <EOL> if self . showVariance : <EOL> variance = link_variance [ start_node ] <EOL> center = start + ( ( end - start ) / <NUM_LIT:2> ) <EOL> minRadius = self . cylinder_width / <NUM_LIT:2> <EOL> self . drawCircle ( variance [ dim ] , self . min_variance , self . max_variance , minRadius , self . maxVarianceRadius , center ) <EOL> link_color_values = list ( colors [ dim ] ) <EOL> if not selected and link_color_values [ <NUM_LIT:3> ] != self . outOfRangeOpacity : <EOL> link_color_values [ <NUM_LIT:3> ] = <NUM_LIT> <EOL> glColor4f ( * link_color_values ) <EOL> self . drawLinkCylinder ( start , end ) <EOL> glPopMatrix ( ) <EOL> def drawArrowHead ( self , w , h , z_dist , size , direction ) : <EOL> if direction == '<STR_LIT:left>' : <EOL> glTranslatef ( - <NUM_LIT:1> , <NUM_LIT:0.> , <NUM_LIT:0.> ) <EOL> with glSection ( GL_TRIANGLES ) : <EOL> glVertex3f ( w , <NUM_LIT:0.> , z_dist ) <EOL> glVertex3f ( w , h , z_dist ) <EOL> glVertex3f ( w * ( <NUM_LIT:1> - size ) , h * <NUM_LIT:0.5> , z_dist ) <EOL> elif direction == '<STR_LIT:right>' : <EOL> glTranslatef ( <NUM_LIT:1> , <NUM_LIT:0.> , <NUM_LIT:0.> ) <EOL> with glSection ( GL_TRIANGLES ) : <EOL> glVertex3f ( <NUM_LIT:0.> , <NUM_LIT:0.> , z_dist ) <EOL> glVertex3f ( w * size , h * <NUM_LIT:0.5> , z_dist ) <EOL> glVertex3f ( <NUM_LIT:0.> , h , z_dist ) <EOL> elif direction == '<STR_LIT>' : <EOL> glTranslatef ( <NUM_LIT:0.> , <NUM_LIT:1.> , <NUM_LIT:0.> ) <EOL> with glSection ( GL_TRIANGLES ) : <EOL> glVertex3f ( <NUM_LIT:0.> , <NUM_LIT:0.> , z_dist ) <EOL> glVertex3f ( w , <NUM_LIT:0.> , z_dist ) <EOL> glVertex3f ( w * <NUM_LIT:0.5> , h * size , z_dist ) <EOL> elif direction == '<STR_LIT>' : <EOL> glTranslatef ( <NUM_LIT:0.> , - <NUM_LIT:1.> , <NUM_LIT:0.> ) <EOL> with glSection ( GL_TRIANGLES ) : <EOL> glVertex3f ( <NUM_LIT:0.> , h , z_dist ) <EOL> glVertex3f ( w , h , z_dist ) <EOL> glVertex3f ( w * <NUM_LIT:0.5> , h * ( <NUM_LIT:1> - size ) , z_dist ) <EOL> def drawBorder ( self , w , h , border_width , z_dist ) : <EOL> '''<STR_LIT>''' <EOL> glLineWidth ( border_width ) <EOL> with glSection ( GL_LINES ) : <EOL> glVertex3f ( <NUM_LIT:0.> , border_width / <NUM_LIT> , z_dist ) <EOL> glVertex3f ( w , border_width / <NUM_LIT> , z_dist ) <EOL> glVertex3f ( w - ( border_width / <NUM_LIT> ) , <NUM_LIT:0.> , z_dist ) <EOL> glVertex3f ( w - ( border_width / <NUM_LIT> ) , h , z_dist ) <EOL> glVertex3f ( w , h - ( border_width / <NUM_LIT> ) , z_dist ) <EOL> glVertex3f ( <NUM_LIT:0.> , h - ( border_width / <NUM_LIT> ) , z_dist ) <EOL> glVertex3f ( border_width / <NUM_LIT> , h , z_dist ) <EOL> glVertex3f ( border_width / <NUM_LIT> , <NUM_LIT:0.> , z_dist ) <EOL> def drawLinkCylinder ( self , start , end ) : <EOL> v = end - start <EOL> cyl_points = [ tuple ( p ) for p in [ start - v , start , end , end + v ] ] <EOL> glePolyCylinder ( cyl_points , None , self . cylinder_width ) <EOL> def drawRect ( self , w , h , z_dist ) : <EOL> with glSection ( GL_QUADS ) : <EOL> glVertex3f ( <NUM_LIT:0.> , <NUM_LIT:0.> , z_dist ) <EOL> glVertex3f ( w , <NUM_LIT:0.> , z_dist ) <EOL> glVertex3f ( w , h , z_dist ) <EOL> glVertex3f ( <NUM_LIT:0.> , h , z_dist ) <EOL> def changeNodeLinkBounds ( self , lower , upper , links = True ) : <EOL> if links : <EOL> self . lowerBoundLinks = lower <EOL> self . upperBoundLinks = upper <EOL> else : <EOL> self . lowerBoundNodes = lower <EOL> self . upperBoundNodes = upper <EOL> def changeView ( self , inc = True ) : <EOL> '''<STR_LIT>''' <EOL> w , h , d = self . getSliceDims ( ) <EOL> if inc and d < len ( self . shape ) - <NUM_LIT:2> : <EOL> d += <NUM_LIT:1> <EOL> elif inc : <EOL> d = <NUM_LIT:0> <EOL> elif not inc and d > <NUM_LIT:0> : <EOL> d -= <NUM_LIT:1> <EOL> elif not inc : <EOL> d = len ( self . shape ) - <NUM_LIT:2> <EOL> if d == self . axis : <EOL> if self . axis < len ( self . shape ) - <NUM_LIT:2> : <EOL> self . axis += <NUM_LIT:1> <EOL> else : <EOL> self . axis = <NUM_LIT:0> <EOL> self . setNewView ( d ) <EOL> self . axisUpdateSignal . emit ( self . axis , self . axis_index ) <EOL> self . updateAxis ( self . axis , self . axis_index ) <EOL> def changeViewPlane ( self , inc = True ) : <EOL> w , h , d = self . getSliceDims ( ) <EOL> done = False <EOL> while not done : <EOL> if inc and self . axis < len ( self . shape ) - <NUM_LIT:2> : <EOL> self . axis += <NUM_LIT:1> <EOL> elif inc : <EOL> self . axis = <NUM_LIT:0> <EOL> elif not inc and self . axis > <NUM_LIT:0> : <EOL> self . axis -= <NUM_LIT:1> <EOL> elif not inc : <EOL> self . axis = len ( self . shape ) - <NUM_LIT:2> <EOL> if self . axis != d : <EOL> done = True <EOL> self . setNewView ( d ) <EOL> self . axisUpdateSignal . emit ( self . axis , self . axis_index ) <EOL> self . updateAxis ( self . axis , self . axis_index ) <EOL> def mousePressEvent ( self , event ) : <EOL> if max ( self . shape ) == <NUM_LIT:0> : <EOL> return <EOL> if event . button ( ) == Qt . LeftButton : <EOL> self . getMousePress ( event . x ( ) , self . height ( ) - event . y ( ) ) <EOL> def mouseReleaseEvent ( self , event ) : <EOL> if max ( self . shape ) == <NUM_LIT:0> : <EOL> return <EOL> if event . button ( ) == Qt . RightButton : <EOL> self . processPlaneHighlights ( self . selectionPick ( event ) , right_click = True ) <EOL> elif event . button ( ) == Qt . LeftButton : <EOL> self . processPlaneHighlights ( self . selectionPick ( event ) , right_click = False ) <EOL> def processPlaneHighlights ( self , hitlist , right_click ) : <EOL> w , h , d = self . getSliceDims ( ) <EOL> for i in hitlist : <EOL> e_val = i / self . shape [ d ] <EOL> d_val = i - e_val * self . shape [ d ] <EOL> if right_click : <EOL> if ( d_val , e_val ) not in self . view_planes [ d ] : <EOL> self . view_planes [ d ] . add ( ( d_val , e_val ) ) <EOL> else : <EOL> if len ( self . view_planes [ d ] ) > <NUM_LIT:1> : <EOL> self . view_planes [ d ] . remove ( ( d_val , e_val ) ) <EOL> if self . current_planes [ d ] == d_val and self . current_planes [ <NUM_LIT:4> ] == e_val : <EOL> sorted_planes = sorted ( self . view_planes [ d ] , <EOL> key = lambda val : val [ <NUM_LIT:1> ] * self . shape [ d ] + val [ <NUM_LIT:0> ] ) <EOL> self . current_planes [ d ] = sorted_planes [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] <EOL> self . current_planes [ <NUM_LIT:4> ] = sorted_planes [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] <EOL> else : <EOL> if ( d_val , e_val ) not in self . view_planes [ d ] : <EOL> self . view_planes [ d ] . add ( ( d_val , e_val ) ) <EOL> self . current_planes [ d ] = d_val <EOL> self . current_planes [ <NUM_LIT:4> ] = e_val <EOL> self . viewPlanesUpdateSignal . emit ( self . view_planes ) <EOL> def selectionPick ( self , event ) : <EOL> """<STR_LIT>""" <EOL> self . paintEvent ( event ) <EOL> glDisable ( GL_LIGHTING ) <EOL> glDisable ( GL_LIGHT0 ) <EOL> prev_blend_on = glGetBoolean ( GL_BLEND ) <EOL> glDisable ( GL_BLEND ) <EOL> w , h , d = self . getSliceDims ( ) <EOL> select_buf_size = self . dataModel . shape [ d ] * self . dataModel . shape [ <NUM_LIT:4> ] + <NUM_LIT:10> <EOL> glSelectBuffer ( select_buf_size ) <EOL> glRenderMode ( GL_SELECT ) <EOL> glInitNames ( ) <EOL> glPushName ( <NUM_LIT:0> ) <EOL> viewport = glGetIntegerv ( GL_VIEWPORT ) <EOL> glMatrixMode ( GL_PROJECTION ) <EOL> glPushMatrix ( ) <EOL> glLoadIdentity ( ) <EOL> gluPickMatrix ( event . x ( ) , ( viewport [ <NUM_LIT:3> ] - event . y ( ) ) , <EOL> <NUM_LIT:1> , <NUM_LIT:1> , viewport ) <EOL> set_perspective ( self . fov , self . width ( ) / float ( self . height ( ) ) , <EOL> self . near_plane , self . far_plane ) <EOL> glMatrixMode ( GL_MODELVIEW ) <EOL> glPushMatrix ( ) <EOL> glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) <EOL> self . orient_scene ( ) <EOL> self . draw ( toolbar = False ) <EOL> super ( Torus5dViewOverview , self ) . paintGL ( ) <EOL> glPopMatrix ( ) <EOL> glMatrixMode ( GL_PROJECTION ) <EOL> glPopMatrix ( ) <EOL> glFlush ( ) <EOL> glMatrixMode ( GL_MODELVIEW ) <EOL> pick_buffer = glRenderMode ( GL_RENDER ) <EOL> nearest = <NUM_LIT> <EOL> hitlist = [ ] <EOL> for hit in pick_buffer : <EOL> if hit [ <NUM_LIT:0> ] < nearest : <EOL> nearest = hit [ <NUM_LIT:0> ] <EOL> hitlist = [ hit [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] ] <EOL> glEnable ( GL_LIGHTING ) <EOL> glEnable ( GL_LIGHT0 ) <EOL> glPolygonMode ( GL_FRONT_AND_BACK , GL_FILL ) <EOL> if prev_blend_on : <EOL> glEnable ( GL_BLEND ) <EOL> glBlendFunc ( GL_SRC_ALPHA , GL_ONE_MINUS_SRC_ALPHA ) <EOL> return hitlist <EOL> def setNewView ( self , d ) : <EOL> for i in range ( len ( self . axis_map [ self . axis ] ) ) : <EOL> temp_w , temp_h , temp_d = self . axis_map [ self . axis ] [ i ] <EOL> if d == temp_d : <EOL> self . axis_index = i <EOL> break <EOL> '''<STR_LIT>''' </s>
