<s> from cpatool import CPATool <EOL> from dbconnect import DBConnect , UniqueImageClause , image_key_columns , object_key_columns <EOL> import sqltools as sql <EOL> from multiclasssql import filter_table_prefix <EOL> from properties import Properties <EOL> import guiutils as ui <EOL> from gating import GatingHelper <EOL> from wx . combo import OwnerDrawnComboBox as ComboBox <EOL> import imagetools <EOL> import logging <EOL> import numpy as np <EOL> import os <EOL> import sys <EOL> import re <EOL> import wx <EOL> import matplotlib . cm <EOL> from matplotlib . figure import Figure <EOL> from matplotlib . backends . backend_wxagg import FigureCanvasWxAgg <EOL> from matplotlib . backends . backend_wxagg import NavigationToolbar2WxAgg as NavigationToolbar <EOL> p = Properties . getInstance ( ) <EOL> db = DBConnect . getInstance ( ) <EOL> ID_EXIT = wx . NewId ( ) <EOL> LOG_SCALE = '<STR_LIT>' <EOL> LINEAR_SCALE = '<STR_LIT>' <EOL> class DataSourcePanel ( wx . Panel ) : <EOL> '''<STR_LIT>''' <EOL> def __init__ ( self , parent , figpanel , ** kwargs ) : <EOL> wx . Panel . __init__ ( self , parent , ** kwargs ) <EOL> self . SetBackgroundColour ( '<STR_LIT>' ) <EOL> self . figpanel = figpanel <EOL> sizer = wx . BoxSizer ( wx . VERTICAL ) <EOL> self . x_table_choice = ui . TableComboBox ( self , - <NUM_LIT:1> , style = wx . CB_READONLY ) <EOL> self . y_table_choice = ui . TableComboBox ( self , - <NUM_LIT:1> , style = wx . CB_READONLY ) <EOL> self . x_choice = ComboBox ( self , - <NUM_LIT:1> , size = ( <NUM_LIT:200> , - <NUM_LIT:1> ) , style = wx . CB_READONLY ) <EOL> self . y_choice = ComboBox ( self , - <NUM_LIT:1> , size = ( <NUM_LIT:200> , - <NUM_LIT:1> ) , style = wx . CB_READONLY ) <EOL> self . gridsize_input = wx . TextCtrl ( self , - <NUM_LIT:1> , '<STR_LIT>' ) <EOL> maps = [ m for m in matplotlib . cm . datad . keys ( ) if not m . endswith ( "<STR_LIT>" ) ] <EOL> maps . sort ( ) <EOL> self . colormap_choice = ComboBox ( self , - <NUM_LIT:1> , choices = maps , style = wx . CB_READONLY ) <EOL> self . colormap_choice . SetSelection ( maps . index ( '<STR_LIT>' ) ) <EOL> self . color_scale_choice = ComboBox ( self , - <NUM_LIT:1> , choices = [ LINEAR_SCALE , LOG_SCALE ] , style = wx . CB_READONLY ) <EOL> self . color_scale_choice . Select ( <NUM_LIT:0> ) <EOL> self . x_scale_choice = ComboBox ( self , - <NUM_LIT:1> , choices = [ LINEAR_SCALE , LOG_SCALE ] , style = wx . CB_READONLY ) <EOL> self . x_scale_choice . Select ( <NUM_LIT:0> ) <EOL> self . y_scale_choice = ComboBox ( self , - <NUM_LIT:1> , choices = [ LINEAR_SCALE , LOG_SCALE ] , style = wx . CB_READONLY ) <EOL> self . y_scale_choice . Select ( <NUM_LIT:0> ) <EOL> self . filter_choice = ui . FilterComboBox ( self , style = wx . CB_READONLY ) <EOL> self . filter_choice . Select ( <NUM_LIT:0> ) <EOL> self . gate_choice = ui . GateComboBox ( self , style = wx . CB_READONLY ) <EOL> self . update_chart_btn = wx . Button ( self , - <NUM_LIT:1> , "<STR_LIT>" ) <EOL> self . update_x_choices ( ) <EOL> self . update_y_choices ( ) <EOL> sz = wx . BoxSizer ( wx . HORIZONTAL ) <EOL> sz . Add ( wx . StaticText ( self , - <NUM_LIT:1> , "<STR_LIT>" ) , <NUM_LIT:0> , wx . TOP , <NUM_LIT:4> ) <EOL> sz . AddSpacer ( ( <NUM_LIT:3> , - <NUM_LIT:1> ) ) <EOL> sz . Add ( self . x_table_choice , <NUM_LIT:1> , wx . EXPAND ) <EOL> sz . AddSpacer ( ( <NUM_LIT:3> , - <NUM_LIT:1> ) ) <EOL> sz . Add ( self . x_choice , <NUM_LIT:2> , wx . EXPAND ) <EOL> sz . AddSpacer ( ( <NUM_LIT:5> , - <NUM_LIT:1> ) ) <EOL> sz . Add ( wx . StaticText ( self , - <NUM_LIT:1> , "<STR_LIT>" ) , <NUM_LIT:0> , wx . TOP , <NUM_LIT:4> ) <EOL> sz . AddSpacer ( ( <NUM_LIT:3> , - <NUM_LIT:1> ) ) <EOL> sz . Add ( self . x_scale_choice ) <EOL> sizer . Add ( sz , <NUM_LIT:1> , wx . EXPAND ) <EOL> sizer . AddSpacer ( ( - <NUM_LIT:1> , <NUM_LIT:2> ) ) <EOL> sz = wx . BoxSizer ( wx . HORIZONTAL ) <EOL> sz . Add ( wx . StaticText ( self , - <NUM_LIT:1> , "<STR_LIT>" ) , <NUM_LIT:0> , wx . TOP , <NUM_LIT:4> ) <EOL> sz . AddSpacer ( ( <NUM_LIT:3> , - <NUM_LIT:1> ) ) <EOL> sz . Add ( self . y_table_choice , <NUM_LIT:1> , wx . EXPAND ) <EOL> sz . AddSpacer ( ( <NUM_LIT:3> , - <NUM_LIT:1> ) ) <EOL> sz . Add ( self . y_choice , <NUM_LIT:2> , wx . EXPAND ) <EOL> sz . AddSpacer ( ( <NUM_LIT:5> , - <NUM_LIT:1> ) ) <EOL> sz . Add ( wx . StaticText ( self , - <NUM_LIT:1> , "<STR_LIT>" ) , <NUM_LIT:0> , wx . TOP , <NUM_LIT:4> ) <EOL> sz . AddSpacer ( ( <NUM_LIT:3> , - <NUM_LIT:1> ) ) <EOL> sz . Add ( self . y_scale_choice ) <EOL> sizer . Add ( sz , <NUM_LIT:1> , wx . EXPAND ) <EOL> sizer . AddSpacer ( ( - <NUM_LIT:1> , <NUM_LIT:2> ) ) <EOL> sz = wx . BoxSizer ( wx . HORIZONTAL ) <EOL> sz . Add ( wx . StaticText ( self , - <NUM_LIT:1> , "<STR_LIT>" ) , <NUM_LIT:0> , wx . TOP , <NUM_LIT:4> ) <EOL> sz . AddSpacer ( ( <NUM_LIT:3> , - <NUM_LIT:1> ) ) <EOL> sz . Add ( self . gridsize_input , <NUM_LIT:1> , wx . TOP , <NUM_LIT:3> ) <EOL> sz . AddSpacer ( ( <NUM_LIT:5> , - <NUM_LIT:1> ) ) <EOL> sz . Add ( wx . StaticText ( self , label = '<STR_LIT>' ) , <NUM_LIT:0> , wx . TOP , <NUM_LIT:4> ) <EOL> sz . AddSpacer ( ( <NUM_LIT:3> , - <NUM_LIT:1> ) ) <EOL> sz . Add ( self . colormap_choice , <NUM_LIT:1> , wx . EXPAND ) <EOL> sz . AddSpacer ( ( <NUM_LIT:5> , - <NUM_LIT:1> ) ) <EOL> sz . Add ( wx . StaticText ( self , label = '<STR_LIT>' ) , <NUM_LIT:0> , wx . TOP , <NUM_LIT:4> ) <EOL> sz . AddSpacer ( ( <NUM_LIT:3> , - <NUM_LIT:1> ) ) <EOL> sz . Add ( self . color_scale_choice , <NUM_LIT:1> , wx . EXPAND ) <EOL> sizer . Add ( sz , <NUM_LIT:1> , wx . EXPAND ) <EOL> sizer . AddSpacer ( ( - <NUM_LIT:1> , <NUM_LIT:5> ) ) <EOL> sz = wx . BoxSizer ( wx . HORIZONTAL ) <EOL> sz . Add ( wx . StaticText ( self , - <NUM_LIT:1> , "<STR_LIT>" ) , <NUM_LIT:0> , wx . TOP , <NUM_LIT:4> ) <EOL> sz . AddSpacer ( ( <NUM_LIT:3> , - <NUM_LIT:1> ) ) <EOL> sz . Add ( self . filter_choice , <NUM_LIT:1> , wx . EXPAND ) <EOL> sz . AddSpacer ( ( <NUM_LIT:5> , - <NUM_LIT:1> ) ) <EOL> sz . Add ( wx . StaticText ( self , - <NUM_LIT:1> , "<STR_LIT>" ) , <NUM_LIT:0> , wx . TOP , <NUM_LIT:4> ) <EOL> sz . AddSpacer ( ( <NUM_LIT:3> , - <NUM_LIT:1> ) ) <EOL> sz . Add ( self . gate_choice , <NUM_LIT:1> , wx . EXPAND ) <EOL> sizer . Add ( sz , <NUM_LIT:1> , wx . EXPAND ) <EOL> sizer . AddSpacer ( ( - <NUM_LIT:1> , <NUM_LIT:5> ) ) <EOL> sizer . Add ( self . update_chart_btn ) <EOL> wx . EVT_COMBOBOX ( self . x_table_choice , - <NUM_LIT:1> , self . on_x_table_selected ) <EOL> wx . EVT_COMBOBOX ( self . y_table_choice , - <NUM_LIT:1> , self . on_y_table_selected ) <EOL> self . gate_choice . addobserver ( self . on_gate_selected ) <EOL> wx . EVT_COMBOBOX ( self . colormap_choice , - <NUM_LIT:1> , self . on_cmap_selected ) <EOL> wx . EVT_BUTTON ( self . update_chart_btn , - <NUM_LIT:1> , self . update_figpanel ) <EOL> self . SetSizer ( sizer ) <EOL> self . Show ( <NUM_LIT:1> ) <EOL> @ property <EOL> def x_column ( self ) : <EOL> x_table_choice_id = self . x_table_choice . GetSelection ( ) <EOL> x_choice_id = self . x_choice . GetSelection ( ) <EOL> return sql . Column ( self . x_table_choice . GetString ( x_table_choice_id ) , <EOL> self . x_choice . GetString ( x_choice_id ) ) <EOL> @ property <EOL> def y_column ( self ) : <EOL> y_table_choice_id = self . y_table_choice . GetSelection ( ) <EOL> y_choice_id = self . y_choice . GetSelection ( ) <EOL> return sql . Column ( self . y_table_choice . GetString ( y_table_choice_id ) , <EOL> self . y_choice . GetString ( y_choice_id ) ) <EOL> @ property <EOL> def filter ( self ) : <EOL> return self . filter_choice . get_filter_or_none ( ) <EOL> def on_x_table_selected ( self , evt ) : <EOL> table = self . x_table_choice . Value <EOL> if table == ui . TableComboBox . OTHER_TABLE : <EOL> t = ui . get_other_table_from_user ( self ) <EOL> if t is not None : <EOL> self . x_table_choice . Items = self . x_table_choice . Items [ : - <NUM_LIT:1> ] + [ t ] + self . x_table_choice . Items [ - <NUM_LIT:1> : ] <EOL> self . x_table_choice . Select ( self . x_table_choice . Items . index ( t ) ) <EOL> sel = self . y_table_choice . GetSelection ( ) <EOL> self . y_table_choice . Items = self . y_table_choice . Items [ : - <NUM_LIT:1> ] + [ t ] + self . y_table_choice . Items [ - <NUM_LIT:1> : ] <EOL> self . y_table_choice . SetSelection ( sel ) <EOL> else : <EOL> self . x_table_choice . Select ( <NUM_LIT:0> ) <EOL> return <EOL> self . update_x_choices ( ) <EOL> def on_y_table_selected ( self , evt ) : <EOL> table = self . y_table_choice . Value <EOL> if table == ui . TableComboBox . OTHER_TABLE : <EOL> t = ui . get_other_table_from_user ( self ) <EOL> if t is not None : <EOL> self . y_table_choice . Items = self . y_table_choice . Items [ : - <NUM_LIT:1> ] + [ t ] + self . y_table_choice . Items [ - <NUM_LIT:1> : ] <EOL> self . y_table_choice . Select ( self . y_table_choice . Items . index ( t ) ) <EOL> sel = self . x_table_choice . GetSelection ( ) <EOL> self . x_table_choice . Items = self . x_table_choice . Items [ : - <NUM_LIT:1> ] + [ t ] + self . x_table_choice . Items [ - <NUM_LIT:1> : ] <EOL> self . x_table_choice . SetSelection ( sel ) <EOL> else : <EOL> self . y_table_choice . Select ( <NUM_LIT:0> ) <EOL> return <EOL> self . update_y_choices ( ) <EOL> def on_gate_selected ( self , gate_name ) : <EOL> self . update_gate_helper ( ) <EOL> def update_gate_helper ( self ) : <EOL> gate_name = self . gate_choice . get_gatename_or_none ( ) <EOL> if gate_name : <EOL> self . figpanel . gate_helper . set_displayed_gate ( p . gates [ gate_name ] , self . x_column , self . y_column ) <EOL> else : <EOL> self . figpanel . gate_helper . disable ( ) <EOL> def on_cmap_selected ( self , evt ) : <EOL> self . figpanel . set_colormap ( self . colormap_choice . GetString ( self . colormap_choice . GetSelection ( ) ) ) <EOL> def update_x_choices ( self ) : <EOL> tablename = self . x_table_choice . Value <EOL> fieldnames = db . GetColumnNames ( tablename ) <EOL> self . x_choice . Clear ( ) <EOL> self . x_choice . AppendItems ( fieldnames ) <EOL> self . x_choice . SetSelection ( <NUM_LIT:0> ) <EOL> def update_y_choices ( self ) : <EOL> tablename = self . y_table_choice . Value <EOL> fieldnames = db . GetColumnNames ( tablename ) <EOL> self . y_choice . Clear ( ) <EOL> self . y_choice . AppendItems ( fieldnames ) <EOL> self . y_choice . SetSelection ( <NUM_LIT:0> ) <EOL> def get_numeric_columns_from_table ( self , table ) : <EOL> '''<STR_LIT>''' <EOL> measurements = db . GetColumnNames ( table ) <EOL> types = db . GetColumnTypes ( table ) <EOL> return [ m for m , t in zip ( measurements , types ) if t in [ float , int , long ] ] <EOL> def _plotting_per_object_data ( self ) : <EOL> return ( p . object_table and <EOL> p . object_table in [ self . x_column . table , self . y_column . table ] <EOL> or ( self . x_column . table != p . image_table and db . adjacent ( p . object_table , self . x_column . table ) ) <EOL> or ( self . y_column . table != p . image_table and db . adjacent ( p . object_table , self . y_column . table ) ) <EOL> ) <EOL> def update_figpanel ( self , evt = None ) : <EOL> self . gate_choice . set_gatable_columns ( [ self . x_column , self . y_column ] ) <EOL> points = self . _load_points ( ) <EOL> self . figpanel . setgridsize ( int ( self . gridsize_input . GetValue ( ) ) ) <EOL> self . figpanel . set_x_scale ( self . x_scale_choice . GetString ( self . x_scale_choice . GetSelection ( ) ) ) <EOL> self . figpanel . set_y_scale ( self . y_scale_choice . GetString ( self . y_scale_choice . GetSelection ( ) ) ) <EOL> self . figpanel . set_color_scale ( self . color_scale_choice . GetString ( self . color_scale_choice . GetSelection ( ) ) ) <EOL> self . figpanel . set_x_label ( self . x_column . col ) <EOL> self . figpanel . set_y_label ( self . y_column . col ) <EOL> self . figpanel . set_colormap ( self . colormap_choice . GetString ( self . colormap_choice . GetSelection ( ) ) ) <EOL> self . figpanel . setpointslists ( points ) <EOL> self . figpanel . draw ( ) <EOL> self . update_gate_helper ( ) <EOL> def _load_points ( self ) : <EOL> q = sql . QueryBuilder ( ) <EOL> select = [ self . x_column , self . y_column ] <EOL> q . set_select_clause ( select ) <EOL> if self . filter != None : <EOL> q . add_filter ( self . filter ) <EOL> return db . execute ( str ( q ) ) <EOL> def save_settings ( self ) : <EOL> '''<STR_LIT>''' <EOL> d = { '<STR_LIT>' : self . x_table_choice . GetString ( self . x_table_choice . GetSelection ( ) ) , <EOL> '<STR_LIT>' : self . y_table_choice . GetString ( self . y_table_choice . GetSelection ( ) ) , <EOL> '<STR_LIT>' : self . x_choice . GetString ( self . x_choice . GetSelection ( ) ) , <EOL> '<STR_LIT>' : self . y_choice . GetString ( self . y_choice . GetSelection ( ) ) , <EOL> '<STR_LIT>' : self . x_scale_choice . GetString ( self . x_scale_choice . GetSelection ( ) ) , <EOL> '<STR_LIT>' : self . y_scale_choice . GetString ( self . y_scale_choice . GetSelection ( ) ) , <EOL> '<STR_LIT>' : self . gridsize_input . GetValue ( ) , <EOL> '<STR_LIT>' : self . colormap_choice . GetString ( self . colormap_choice . GetSelection ( ) ) , <EOL> '<STR_LIT>' : self . color_scale_choice . GetString ( self . color_scale_choice . GetSelection ( ) ) , <EOL> '<STR_LIT>' : self . filter_choice . GetString ( self . filter_choice . GetSelection ( ) ) , <EOL> '<STR_LIT>' : self . figpanel . subplot . get_xlim ( ) , <EOL> '<STR_LIT>' : self . figpanel . subplot . get_ylim ( ) , <EOL> '<STR_LIT:version>' : '<STR_LIT:1>' , <EOL> } <EOL> if self . gate_choice . get_gatename_or_none ( ) : <EOL> d [ '<STR_LIT>' ] = self . gate_choice . GetString ( self . gate_choice . GetSelection ( ) ) <EOL> return d <EOL> def load_settings ( self , settings ) : <EOL> '''<STR_LIT>''' <EOL> if '<STR_LIT:version>' not in settings : <EOL> if '<STR_LIT>' in settings : <EOL> settings [ '<STR_LIT>' ] = settings [ '<STR_LIT>' ] <EOL> settings [ '<STR_LIT>' ] = settings [ '<STR_LIT>' ] <EOL> settings [ '<STR_LIT:version>' ] = '<STR_LIT:1>' <EOL> if '<STR_LIT>' in settings : <EOL> self . x_table_choice . SetStringSelection ( settings [ '<STR_LIT>' ] ) <EOL> self . update_x_choices ( ) <EOL> if '<STR_LIT>' in settings : <EOL> self . y_table_choice . SetStringSelection ( settings [ '<STR_LIT>' ] ) <EOL> self . update_y_choices ( ) <EOL> if '<STR_LIT>' in settings : <EOL> self . x_choice . SetStringSelection ( settings [ '<STR_LIT>' ] ) <EOL> if '<STR_LIT>' in settings : <EOL> self . y_choice . SetStringSelection ( settings [ '<STR_LIT>' ] ) <EOL> if '<STR_LIT>' in settings : <EOL> self . x_scale_choice . SetStringSelection ( settings [ '<STR_LIT>' ] ) <EOL> if '<STR_LIT>' in settings : <EOL> self . y_scale_choice . SetStringSelection ( settings [ '<STR_LIT>' ] ) <EOL> if '<STR_LIT>' in settings : <EOL> self . gridsize_input . SetValue ( settings [ '<STR_LIT>' ] ) <EOL> if '<STR_LIT>' in settings : <EOL> self . colormap_choice . SetStringSelection ( settings [ '<STR_LIT>' ] ) <EOL> if '<STR_LIT>' in settings : <EOL> self . color_scale_choice . SetStringSelection ( settings [ '<STR_LIT>' ] ) <EOL> if '<STR_LIT>' in settings : <EOL> self . filter_choice . SetStringSelection ( settings [ '<STR_LIT>' ] ) <EOL> self . update_figpanel ( ) <EOL> if '<STR_LIT>' in settings : <EOL> self . figpanel . subplot . set_xlim ( eval ( settings [ '<STR_LIT>' ] ) ) <EOL> if '<STR_LIT>' in settings : <EOL> self . figpanel . subplot . set_ylim ( eval ( settings [ '<STR_LIT>' ] ) ) <EOL> if '<STR_LIT>' in settings : <EOL> self . gate_choice . SetStringSelection ( settings [ '<STR_LIT>' ] ) <EOL> self . figpanel . gate_helper . set_displayed_gate ( <EOL> p . gates [ settings [ '<STR_LIT>' ] ] , self . x_column , self . y_column ) <EOL> self . figpanel . draw ( ) <EOL> class DensityPanel ( FigureCanvasWxAgg ) : <EOL> def __init__ ( self , parent , ** kwargs ) : <EOL> self . figure = Figure ( ) <EOL> FigureCanvasWxAgg . __init__ ( self , parent , - <NUM_LIT:1> , self . figure , ** kwargs ) <EOL> self . canvas = self . figure . canvas <EOL> self . SetMinSize ( ( <NUM_LIT:100> , <NUM_LIT:100> ) ) <EOL> self . figure . set_facecolor ( ( <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> ) ) <EOL> self . figure . set_edgecolor ( ( <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> ) ) <EOL> self . canvas . SetBackgroundColour ( '<STR_LIT>' ) <EOL> self . subplot = self . figure . add_subplot ( <NUM_LIT> ) <EOL> self . gate_helper = GatingHelper ( self . subplot , self ) <EOL> self . navtoolbar = None <EOL> self . point_list = [ ] <EOL> self . gridsize = <NUM_LIT:50> <EOL> self . cb = None <EOL> self . x_scale = LINEAR_SCALE <EOL> self . y_scale = LINEAR_SCALE <EOL> self . color_scale = None <EOL> self . x_label = '<STR_LIT>' <EOL> self . y_label = '<STR_LIT>' <EOL> self . cmap = '<STR_LIT>' <EOL> self . canvas . mpl_connect ( '<STR_LIT>' , self . on_release ) <EOL> def setpointslists ( self , points ) : <EOL> self . subplot . clear ( ) <EOL> self . point_list = points <EOL> plot_pts = np . array ( points ) . astype ( float ) <EOL> if self . x_scale == LOG_SCALE : <EOL> plot_pts = plot_pts [ ( plot_pts [ : , <NUM_LIT:0> ] > <NUM_LIT:0> ) ] <EOL> if self . y_scale == LOG_SCALE : <EOL> plot_pts = plot_pts [ ( plot_pts [ : , <NUM_LIT:1> ] > <NUM_LIT:0> ) ] <EOL> hb = self . subplot . hexbin ( plot_pts [ : , <NUM_LIT:0> ] , plot_pts [ : , <NUM_LIT:1> ] , <EOL> gridsize = self . gridsize , <EOL> xscale = self . x_scale , <EOL> yscale = self . y_scale , <EOL> bins = self . color_scale , <EOL> cmap = matplotlib . cm . get_cmap ( self . cmap ) ) <EOL> if self . cb : <EOL> self . cb . remove ( ) <EOL> self . figure . subplots_adjust ( right = <NUM_LIT> ) <EOL> self . cb = self . figure . colorbar ( hb , fraction = <NUM_LIT> , pad = <NUM_LIT> ) <EOL> if self . color_scale == LOG_SCALE : <EOL> self . cb . set_label ( '<STR_LIT>' ) <EOL> self . subplot . set_xlabel ( self . x_label ) <EOL> self . subplot . set_ylabel ( self . y_label ) <EOL> xmin = np . nanmin ( plot_pts [ : , <NUM_LIT:0> ] ) <EOL> xmax = np . nanmax ( plot_pts [ : , <NUM_LIT:0> ] ) <EOL> ymin = np . nanmin ( plot_pts [ : , <NUM_LIT:1> ] ) <EOL> ymax = np . nanmax ( plot_pts [ : , <NUM_LIT:1> ] ) <EOL> if self . x_scale == LOG_SCALE : <EOL> xmin = xmin / <NUM_LIT> <EOL> xmax = xmax * <NUM_LIT> <EOL> else : <EOL> xmin = xmin - ( xmax - xmin ) / <NUM_LIT> <EOL> xmax = xmax + ( xmax - xmin ) / <NUM_LIT> <EOL> if self . y_scale == LOG_SCALE : <EOL> ymin = ymin / <NUM_LIT> <EOL> ymax = ymax * <NUM_LIT> <EOL> else : <EOL> ymin = ymin - ( ymax - ymin ) / <NUM_LIT> <EOL> ymax = ymax + ( ymax - ymin ) / <NUM_LIT> <EOL> self . subplot . axis ( [ xmin , xmax , ymin , ymax ] ) <EOL> self . reset_toolbar ( ) <EOL> def getpointslists ( self ) : <EOL> return self . point_list <EOL> def setgridsize ( self , gridsize ) : <EOL> self . gridsize = gridsize <EOL> def set_x_scale ( self , scale ) : <EOL> self . x_scale = scale <EOL> def set_y_scale ( self , scale ) : <EOL> self . y_scale = scale <EOL> def set_color_scale ( self , scale ) : <EOL> if scale == LINEAR_SCALE : <EOL> scale = None <EOL> self . color_scale = scale <EOL> def set_x_label ( self , label ) : <EOL> self . x_label = label <EOL> def set_y_label ( self , label ) : <EOL> self . y_label = label <EOL> def set_colormap ( self , cmap ) : <EOL> self . cmap = cmap <EOL> self . draw ( ) <EOL> def get_toolbar ( self ) : <EOL> if not self . navtoolbar : <EOL> self . navtoolbar = NavigationToolbar ( self . canvas ) <EOL> return self . navtoolbar <EOL> def reset_toolbar ( self ) : <EOL> if self . navtoolbar : <EOL> self . navtoolbar . _views . clear ( ) <EOL> self . navtoolbar . _positions . clear ( ) <EOL> self . navtoolbar . push_current ( ) <EOL> def set_configpanel ( self , configpanel ) : <EOL> '''<STR_LIT>''' <EOL> self . configpanel = configpanel <EOL> def on_release ( self , evt ) : <EOL> if evt . button == <NUM_LIT:3> : <EOL> self . show_popup_menu ( ( evt . x , self . canvas . GetSize ( ) [ <NUM_LIT:1> ] - evt . y ) , None ) <EOL> def show_popup_menu ( self , ( x , y ) , data ) : <EOL> self . popup_menu_filters = { } <EOL> popup = wx . Menu ( ) <EOL> loadimages_table_item = popup . Append ( - <NUM_LIT:1> , '<STR_LIT>' ) <EOL> selected_gate = self . configpanel . gate_choice . get_gatename_or_none ( ) <EOL> selected_gates = [ ] <EOL> if selected_gate : <EOL> selected_gates = [ selected_gate ] <EOL> self . Bind ( wx . EVT_MENU , <EOL> lambda ( e ) : ui . prompt_user_to_create_loadimages_table ( self , selected_gates ) , <EOL> loadimages_table_item ) <EOL> show_images_in_gate_item = popup . Append ( - <NUM_LIT:1> , '<STR_LIT>' ) <EOL> show_images_in_gate_item . Enable ( selected_gate is not None ) <EOL> self . Bind ( wx . EVT_MENU , self . show_images_from_gate , show_images_in_gate_item ) <EOL> if p . object_table : <EOL> show_objects_in_gate_item = popup . Append ( - <NUM_LIT:1> , '<STR_LIT>' % ( p . object_name [ <NUM_LIT:1> ] ) ) <EOL> show_objects_in_gate_item . Enable ( selected_gate is not None ) <EOL> self . Bind ( wx . EVT_MENU , self . show_objects_from_gate , show_objects_in_gate_item ) <EOL> self . PopupMenu ( popup , ( x , y ) ) <EOL> def show_objects_from_gate ( self , evt = None ) : <EOL> '''<STR_LIT>''' <EOL> gatename = self . configpanel . gate_choice . get_gatename_or_none ( ) <EOL> if gatename : <EOL> ui . show_objects_from_gate ( gatename ) <EOL> def show_images_from_gate ( self , evt = None ) : <EOL> '''<STR_LIT>''' <EOL> gatename = self . configpanel . gate_choice . get_gatename_or_none ( ) <EOL> if gatename : <EOL> ui . show_images_from_gate ( gatename ) <EOL> class Density ( wx . Frame , CPATool ) : <EOL> '''<STR_LIT>''' <EOL> def __init__ ( self , parent , size = ( <NUM_LIT> , <NUM_LIT> ) , ** kwargs ) : <EOL> wx . Frame . __init__ ( self , parent , - <NUM_LIT:1> , size = size , title = '<STR_LIT>' , ** kwargs ) <EOL> CPATool . __init__ ( self ) <EOL> self . SetName ( self . tool_name ) <EOL> self . SetBackgroundColour ( "<STR_LIT>" ) <EOL> figpanel = DensityPanel ( self ) <EOL> configpanel = DataSourcePanel ( self , figpanel ) <EOL> figpanel . set_configpanel ( configpanel ) <EOL> self . SetToolBar ( figpanel . get_toolbar ( ) ) <EOL> sizer = wx . BoxSizer ( wx . VERTICAL ) <EOL> sizer . Add ( figpanel , <NUM_LIT:1> , wx . EXPAND ) <EOL> sizer . Add ( configpanel , <NUM_LIT:0> , wx . EXPAND | wx . ALL , <NUM_LIT:5> ) <EOL> self . SetSizer ( sizer ) <EOL> self . save_settings = configpanel . save_settings <EOL> self . load_settings = configpanel . load_settings <EOL> def SetToolBar ( self , toolbar ) : <EOL> from matplotlib . backends . backend_wx import _load_bitmap <EOL> toolbar . Hide ( ) <EOL> tb = self . CreateToolBar ( ( wx . TB_HORIZONTAL | wx . TB_TEXT ) ) <EOL> _NTB2_HOME = wx . NewId ( ) <EOL> _NTB2_BACK = wx . NewId ( ) <EOL> _NTB2_FORWARD = wx . NewId ( ) <EOL> _NTB2_PAN = wx . NewId ( ) <EOL> _NTB2_ZOOM = wx . NewId ( ) <EOL> _NTB2_SAVE = wx . NewId ( ) <EOL> _NTB2_SUBPLOT = wx . NewId ( ) <EOL> tb . AddSimpleTool ( _NTB2_HOME , _load_bitmap ( '<STR_LIT>' ) , '<STR_LIT>' , '<STR_LIT>' ) <EOL> tb . AddSimpleTool ( _NTB2_BACK , _load_bitmap ( '<STR_LIT>' ) , '<STR_LIT>' , '<STR_LIT>' ) <EOL> tb . AddSimpleTool ( _NTB2_FORWARD , _load_bitmap ( '<STR_LIT>' ) , '<STR_LIT>' , '<STR_LIT>' ) <EOL> tb . AddCheckTool ( _NTB2_PAN , _load_bitmap ( '<STR_LIT>' ) , shortHelp = '<STR_LIT>' , longHelp = '<STR_LIT>' ) <EOL> tb . AddCheckTool ( _NTB2_ZOOM , _load_bitmap ( '<STR_LIT>' ) , shortHelp = '<STR_LIT>' , longHelp = '<STR_LIT>' ) <EOL> tb . AddSeparator ( ) <EOL> tb . AddSimpleTool ( _NTB2_SUBPLOT , _load_bitmap ( '<STR_LIT>' ) , '<STR_LIT>' , '<STR_LIT>' ) <EOL> tb . AddSimpleTool ( _NTB2_SAVE , _load_bitmap ( '<STR_LIT>' ) , '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . Bind ( wx . EVT_TOOL , toolbar . home , id = _NTB2_HOME ) <EOL> self . Bind ( wx . EVT_TOOL , toolbar . forward , id = _NTB2_FORWARD ) <EOL> self . Bind ( wx . EVT_TOOL , toolbar . back , id = _NTB2_BACK ) <EOL> self . Bind ( wx . EVT_TOOL , toolbar . zoom , id = _NTB2_ZOOM ) <EOL> self . Bind ( wx . EVT_TOOL , toolbar . pan , id = _NTB2_PAN ) <EOL> self . Bind ( wx . EVT_TOOL , toolbar . configure_subplots , id = _NTB2_SUBPLOT ) <EOL> self . Bind ( wx . EVT_TOOL , toolbar . save_figure , id = _NTB2_SAVE ) <EOL> tb . Realize ( ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> app = wx . PySimpleApp ( ) <EOL> logging . basicConfig ( level = logging . DEBUG , ) <EOL> if len ( sys . argv ) > <NUM_LIT:1> : <EOL> propsFile = sys . argv [ <NUM_LIT:1> ] <EOL> p . LoadFile ( propsFile ) <EOL> else : <EOL> if not p . show_load_dialog ( ) : <EOL> print '<STR_LIT>' <EOL> wx . GetApp ( ) . Exit ( ) <EOL> sys . exit ( ) <EOL> density = Density ( None ) <EOL> density . Show ( ) <EOL> app . MainLoop ( ) </s>
