Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self):
note = Div(text="<b>NOTE</b>: Each plan may only have one protocol assigned. "
"Updating database will overwrite any existing data.", width=700)
self.update_checkbox = CheckboxGroup(labels=["Only update plans in table."], active=[0])
self.toxicity = [] # Will be used to link to Toxicity tab
self.source = ColumnDataSource(data=dict(mrn=['']))
self.source.selected.on_change('indices', self.source_listener)
self.clear_source_selection_button = Button(label='Clear Selection', button_type='primary', width=150)
self.clear_source_selection_button.on_click(self.clear_source_selection)
self.protocol = Select(value='', options=[''], title='Protocols:')
self.physician = Select(value='', options=[''], title='Physician:', width=150)
self.date_filter_by = Select(value='None', options=['None', 'sim_study_date', 'import_time_stamp'],
title='Date Filter Type:', width=150)
self.date_filter_by.on_change('value', self.date_ticker)
self.date_start = DatePicker(title='Start Date:', width=200)
self.date_start.on_change('value', self.date_ticker)
self.date_end = DatePicker(title='End Date:', width=200)
self.date_end.on_change('value', self.date_ticker)
self.update_protocol_options()
self.update_physician_options()
f2 = Frame("F2")
f1.tri.data = dict(x = [0.1,0.8], y = [0.1,0.1], size = [tri_size,tri_size])
#seg = dict(x0=[0.095,0.097,0.099,0.101,0.103,0.105],
# x1=[0.095+shift,0.097+shift,0.099+shift,0.101+shift,0.103+shift,0.105+shift],
# y0=[0.09]*5, y1=[0.088]*5)
t_line = dict(x=[0.7,0.9], y=[ground,ground])
#sliders:
mag_start = -100
mag_end = 100
mag_val = 0
mag_slider = Slider(title="Kraftbetrag", value=mag_val, start=mag_start, end=mag_end, step=1)
#Toggle button:
button = Button(label="Save", button_type="success")
rbutton = Button(label="Reset", button_type="success")
loc_start = 0
loc_end = 100
loc_val = 50
loc_slider = Slider(title="Kraftposition", value=loc_val, start=loc_start, end=loc_end, step=1)
#p2loc_slider = Slider(title=f2.name + " Kraftposition", value=loc_val, start=loc_start, end=loc_end, step=1)
def create_orig(o):
x = [o.x0,o.x0,o.xf,o.xf]
y = [o.y0,o.yf,o.yf,o.y0]
o.pts.data = dict(x = x, y = y )
def create_prof(f):
paramInt = f.get_param()
i = f.get_mag()
width=100)
self.time_prev_button.on_click(self.on_time_prev)
# Create time selection dropdown widget
self.time_list = sorted([time_str + 'UTC' for time_str in
self.datasets['simim']['data'].get_data('I').keys()
if time_str in self.datasets['simim']['data'].get_data('I').keys()])
time_dd_list = [(k1, k1) for k1 in self.time_list]
self.data_time_dd = bokeh.models.widgets.Dropdown(label='Time',
menu=time_dd_list,
button_type='warning',
width=300)
self.data_time_dd.on_change('value', self.on_data_time_change)
# Create next timestep button widget
self.time_next_button = bokeh.models.widgets.Button(label='Next',
button_type='warning',
width=100)
self.time_next_button.on_click(self.on_time_next)
# Set layout rows for widgets
self.time_row = \
bokeh.layouts.row(self.time_prev_button,
bokeh.models.Spacer(width=20, height=60),
self.data_time_dd,
bokeh.models.Spacer(width=20, height=60),
self.time_next_button)
self.major_config_row = bokeh.layouts.row(self.wavelength_dd)
self.plots_row = bokeh.layouts.row(*self.bokeh_imgs)
self.info_row = bokeh.layouts.row(bokeh.models.Spacer(width=400, height=100),
self.colorbar_div,
bokeh.models.Spacer(width=400, height=100))
#Magnitude of load slider:
mag_start = -100
mag_end = 100
mag_val = 0
mag_slider = Slider(title="Magnitude", value=mag_val,
start=mag_start, end=mag_end, step=1)
#Position of load slider:
loc_start = 0
loc_end = 100
loc_val = 50
loc_slider = Slider(title="Position", value=loc_val,
start=loc_start, end=loc_end, step=1)
#Toggle buttons:
button = Button(label="Save Deformed Frame", button_type="success") #Button to save the deformed frain. Calls function
rbutton = Button(label="Reset", button_type="success") #Reset button. Calls init function
################################################################################
###Functions
################################################################################
def create_orig(o):
'''Creates stationary original frame'''
x = [o.x0,o.x0,o.xf,o.xf]
y = [o.y0,o.yf,o.yf,o.y0]
o.pts.data = dict(x = x, y = y)
def update_fun(attr,old,new):
text_node = Div(text="Node:", width=100, height=20)
text_joints = Div(text="Joints:", width=100, height=20)
text_elements = Div(text="Line elements:", width=100, height=20)
text_loads = Div(text="Loads:", width=100, height=20)
b_height = 50
b_line_width = 72
# configure buttons for mechanical supports
button_support_clamped = Button(label="", css_classes=[eLnum.ElSupEnum.SUPPORT_CLAMPED.name], width=b_height,
height=b_height)
curr_doc.buttons[eLnum.ElSupEnum.SUPPORT_CLAMPED.value] = button_support_clamped
button_support_clamped.on_click(partial(vis_cbs.cb_button_element_click, curr_doc=curr_doc,
button_enum=eLnum.ElSupEnum.SUPPORT_CLAMPED))
button_support_normal = Button(label="", css_classes=[eLnum.ElSupEnum.SUPPORT_NORMAL_FORCE.name], width=b_height,
height=b_height)
curr_doc.buttons[eLnum.ElSupEnum.SUPPORT_NORMAL_FORCE.value] = button_support_normal
button_support_normal.on_click(partial(vis_cbs.cb_button_element_click, curr_doc=curr_doc,
button_enum=eLnum.ElSupEnum.SUPPORT_NORMAL_FORCE))
button_support_transverse = Button(label="", css_classes=[eLnum.ElSupEnum.SUPPORT_TRANSVERSE_FORCE.name],
width=b_height, height=b_height)
curr_doc.buttons[eLnum.ElSupEnum.SUPPORT_TRANSVERSE_FORCE.value] = button_support_transverse
button_support_transverse.on_click(partial(vis_cbs.cb_button_element_click, curr_doc=curr_doc,
button_enum=eLnum.ElSupEnum.SUPPORT_TRANSVERSE_FORCE))
button_support_fixed_conti = Button(label="", css_classes=[eLnum.ElSupEnum.SUPPORT_FIXED_CONTINUOUS.name],
width=b_height, height=b_height)
curr_doc.buttons[eLnum.ElSupEnum.SUPPORT_FIXED_CONTINUOUS.value] = button_support_fixed_conti
button_support_fixed_conti.on_click(
partial(vis_cbs.cb_button_element_click, curr_doc=curr_doc, button_enum=eLnum.ElSupEnum.SUPPORT_FIXED_CONTINUOUS))
def button_save_table(table):
"""Button to save selected data table as csv.
Notes
-----
* Does not work for column values containing tuples (like 'neighbors')
* Currently columns being saved are hard coded in the javascript callback
* Available styles: 'default', 'primary', 'success', 'warning', 'danger'
"""
button = Button(label="Download selected data", button_type="success")
button.callback = CustomJS(args=dict(source=table.source),
code=open(join(dirname(__file__),
"download_data.js")).read())
return widgetbox(button)
def _create_widgets(self):
"""
Main setup function for creating GUI widgets for user feedback.
"""
input_fields, self.feedback_dict = \
self._process_config(self.config_path)
self.submit_button = bokeh.models.widgets.Button(label='Submit',
button_type='warning',
width=BUTTON_WIDTH)
self.submit_button.on_click(self._on_submit)
self.feedback_layout = bokeh.layouts.column(input_fields,
self.submit_button)
self.tv_data = {}
roi_colors = plot_colors.cnames.keys()
roi_colors.sort()
roi_viewer_options = [''] + sources.dvhs.data['mrn']
self.mrn_select = Select(value='', options=roi_viewer_options, width=200, title='MRN')
self.study_date_select = Select(value='', options=[''], width=200, title='Sim Study Date')
self.uid_select = Select(value='', options=[''], width=400, title='Study Instance UID')
self.roi_select = {str(i): Select(value='', options=[''], width=200, title='ROI %s Name' % i) for i in range(1, 6)}
colors = ['blue', 'green', 'red', 'orange', 'lightgreen']
self.roi_select_color = {str(i): Select(value=colors[i-1], options=roi_colors, width=150, title='ROI %s Color' % i) for i in range(1, 6)}
self.slice_select = Select(value='', options=[''], width=200, title='Slice: z = ')
self.previous_slice = Button(label="<", button_type="primary", width=50)
self.next_slice = Button(label=">", button_type="primary", width=50)
self.flip_x_axis_button = Button(label='Flip X-Axis', button_type='primary', width=100)
self.flip_y_axis_button = Button(label='Flip Y-Axis', button_type='primary', width=100)
self.plot_tv_button = Button(label='Plot TV', button_type='primary', width=100)
self.mrn_select.on_change('value', self.mrn_ticker)
self.study_date_select.on_change('value', self.study_date_ticker)
self.uid_select.on_change('value', self.uid_ticker)
self.slice_select.on_change('value', self.slice_ticker)
self.previous_slice.on_click(self.go_to_previous_slice)
self.next_slice.on_click(self.go_to_next_slice)
self.flip_x_axis_button.on_click(self.flip_x_axis)
self.flip_y_axis_button.on_click(self.flip_y_axis)
self.plot_tv_button.on_click(self.plot_tv)
self.fig = figure(plot_width=825, plot_height=600, match_aspect=True,
tools="pan,wheel_zoom,reset,crosshair,save")
'''
'''
# Create variable selection dropdown widget
variable_menu_list = \
create_dropdown_opt_list_from_dict(VARIABLE_DD_DICT,
self.plot_names)
label = Label("Variable: {}")
self.model_variable_drop_down = \
bokeh.models.widgets.Dropdown(label=label.first(variable_menu_list),
menu=variable_menu_list)
label.listen_to(self.model_variable_drop_down)
self.model_variable_drop_down.on_change('value', self.on_var_change)
# Create previous timestep button widget
self.time_previous_button = \
bokeh.models.widgets.Button(label='Previous validity time')
self.time_previous_button.on_click(self.on_time_prev)
# Create next timestep button widget
self.time_next_button = \
bokeh.models.widgets.Button(label='Next validity time')
self.time_next_button.on_click(self.on_time_next)
# select model run
label = Label("Model run: {}")
model_run_list = create_model_run_list(self.datasets.keys())
self.model_run_drop_down = \
bokeh.models.widgets.Dropdown(label=label.first(model_run_list),
menu=model_run_list)
label.listen_to(self.model_run_drop_down)
self.model_run_drop_down.on_change('value', self._on_model_run_change)
else:
self.dvh_review_rois = ['']
# Add Current row to source
self.add_endpoint_row_button = Button(label="Add Endpoint", button_type="primary", width=200)
self.add_endpoint_row_button.on_click(self.add_endpoint)
self.ep_row = Select(value='', options=[''], width=50, title="Row")
self.ep_options = ["Dose (Gy)", "Dose (%)", "Volume (cc)", "Volume (%)"]
self.select_ep_type = Select(value=self.ep_options[0], options=self.ep_options, width=180, title="Output")
self.select_ep_type.on_change('value', self.select_ep_type_ticker)
self.ep_text_input = TextInput(value='', title="Input Volume (cc):", width=180)
self.ep_text_input.on_change('value', self.ep_text_input_ticker)
self.ep_units_in = RadioButtonGroup(labels=["cc", "%"], active=0, width=100)
self.ep_units_in.on_change('active', self.ep_units_in_ticker)
self.delete_ep_row_button = Button(label="Delete", button_type="warning", width=100)
self.delete_ep_row_button.on_click(self.delete_ep_row)
tools = "pan,wheel_zoom,box_zoom,reset,crosshair,save"
self.plot = figure(plot_width=1050, plot_height=500, tools=tools, active_drag="box_zoom")
self.plot.min_border_left = options.MIN_BORDER
self.plot.min_border_bottom = options.MIN_BORDER
self.plot.add_tools(HoverTool(show_arrow=False, line_policy='next',
tooltips=[('Label', '@mrn @roi_name'),
('Dose', '$x'),
('Volume', '$y')]))
self.plot.xaxis.axis_label_text_font_size = options.PLOT_AXIS_LABEL_FONT_SIZE
self.plot.yaxis.axis_label_text_font_size = options.PLOT_AXIS_LABEL_FONT_SIZE
self.plot.xaxis.major_label_text_font_size = options.PLOT_AXIS_MAJOR_LABEL_FONT_SIZE
self.plot.yaxis.major_label_text_font_size = options.PLOT_AXIS_MAJOR_LABEL_FONT_SIZE
self.plot.yaxis.axis_label_text_baseline = "bottom"
self.plot.lod_factor = options.LOD_FACTOR # level of detail during interactive plot events