Ejemplo n.º 1
0
def save_surface_state(file):

  slist = []
  from chimera import openModels as om
  from _surface import SurfaceModel
  for s in om.list(modelTypes = [SurfaceModel]):
    plist = [p for p in s.surfacePieces
             if hasattr(p, 'save_in_session') and p.save_in_session]
    if plist:
      slist.append((s,plist)) 
  if len(slist) == 0:
    return

  smslist = []
  for s,plist in slist:
    sms = Surface_Model_State()
    sms.state_from_surface_model(s,plist)
    smslist.append(sms)
  
  from SessionUtil import objecttree
  t = objecttree.instance_tree_to_basic_tree(smslist)

  file.write('\n')
  file.write('def restore_surfaces():\n')
  file.write(' surface_state = \\\n')
  objecttree.write_basic_tree(t, file, indent = '  ')
  file.write('\n')
  file.write(' from Surface import session\n')
  file.write(' session.restore_surface_state(surface_state)\n')
  file.write('\n')
  file.write('try:\n')
  file.write(' restore_surfaces()\n')
  file.write('except:\n')
  file.write(" reportRestoreError('Error restoring surfaces')\n")
  file.write('\n')
def save_volume_data_state(volume_manager, file):

    s = Volume_Manager_State()
    s.state_from_manager(volume_manager)

    from os.path import dirname
    directory = dirname(file.fileName)
    if directory:
        s.use_relative_paths(directory)

    from SessionUtil import objecttree
    t = objecttree.instance_tree_to_basic_tree(s)

    file.write('\n')
    file.write('def restore_volume_data():\n')
    file.write(' volume_data_state = \\\n')
    objecttree.write_basic_tree(t, file, indent='  ')
    file.write('\n')
    file.write(' from VolumeViewer import session\n')
    file.write(' session.restore_volume_data_state(volume_data_state)\n')
    file.write('\n')
    file.write('try:\n')
    file.write('  restore_volume_data()\n')
    file.write('except:\n')
    file.write("  reportRestoreError('Error restoring volume data')\n")
    file.write('\n')
Ejemplo n.º 3
0
def save_volume_data_state(volume_manager, file):

  s = Volume_Manager_State()
  s.state_from_manager(volume_manager)

  from os.path import dirname
  directory = dirname(file.fileName)
  if directory:
    s.use_relative_paths(directory)
  
  from SessionUtil import objecttree
  t = objecttree.instance_tree_to_basic_tree(s)

  file.write('\n')
  file.write('def restore_volume_data():\n')
  file.write(' volume_data_state = \\\n')
  objecttree.write_basic_tree(t, file, indent = '  ')
  file.write('\n')
  file.write(' from VolumeViewer import session\n')
  file.write(' session.restore_volume_data_state(volume_data_state)\n')
  file.write('\n')
  file.write('try:\n')
  file.write('  restore_volume_data()\n')
  file.write('except:\n')
  file.write("  reportRestoreError('Error restoring volume data')\n")
  file.write('\n')
Ejemplo n.º 4
0
def save_surface_color_state(coloring_table, file):

  s = Surface_Colorings_State()
  s.state_from_coloring_table(coloring_table)

  from gui import surface_color_dialog
  dialog = surface_color_dialog()
  s.state_from_dialog(dialog)
  
  from SessionUtil import objecttree
  t = objecttree.instance_tree_to_basic_tree(s)

  file.write('\n')
  file.write('def restore_surface_color_mapping():\n')
  file.write(' try:\n')
  file.write('  surface_color_state = \\\n')
  objecttree.write_basic_tree(t, file, indent = '   ')
  file.write('\n')
  file.write('  import SurfaceColor.session\n')
  file.write('  SurfaceColor.session.restore_surface_color_state(surface_color_state)\n')
  file.write(' except:\n')
  file.write("  reportRestoreError('Error restoring surface color mapping')\n")
  file.write('\n')
  file.write('registerAfterModelsCB(restore_surface_color_mapping)\n')
  file.write('\n')
Ejemplo n.º 5
0
def save_path_tracer_state(path_tracer_dialog, file):

    if path_tracer_dialog:
        ds = Path_Tracer_Dialog_State()
        ds.state_from_dialog(path_tracer_dialog)
    else:
        ds = None
    mss = marker_set_states()
    s = (mss, ds)

    from SessionUtil import objecttree
    t = objecttree.instance_tree_to_basic_tree(s)

    file.write('\n')
    file.write('def restore_volume_path_tracer():\n')
    file.write(' path_tracer_state = \\\n')
    objecttree.write_basic_tree(t, file, indent='  ')
    file.write('\n')
    file.write(' import VolumePath.session\n')
    file.write(
        ' VolumePath.session.restore_path_tracer_state(path_tracer_state)\n')
    file.write('\n')
    file.write('try:\n')
    file.write('  restore_volume_path_tracer()\n')
    file.write('except:\n')
    file.write("  reportRestoreError('Error restoring volume path tracer')\n")
    file.write('\n')
Ejemplo n.º 6
0
def save_surface_color_state(coloring_table, file):

    s = Surface_Colorings_State()
    s.state_from_coloring_table(coloring_table)

    from gui import surface_color_dialog
    dialog = surface_color_dialog()
    s.state_from_dialog(dialog)

    from SessionUtil import objecttree
    t = objecttree.instance_tree_to_basic_tree(s)

    file.write('\n')
    file.write('def restore_surface_color_mapping():\n')
    file.write(' try:\n')
    file.write('  surface_color_state = \\\n')
    objecttree.write_basic_tree(t, file, indent='   ')
    file.write('\n')
    file.write('  import SurfaceColor.session\n')
    file.write(
        '  SurfaceColor.session.restore_surface_color_state(surface_color_state)\n'
    )
    file.write(' except:\n')
    file.write(
        "  reportRestoreError('Error restoring surface color mapping')\n")
    file.write('\n')
    file.write('registerAfterModelsCB(restore_surface_color_mapping)\n')
    file.write('\n')
Ejemplo n.º 7
0
def save_path_tracer_state(path_tracer_dialog, file):

  if path_tracer_dialog:
    ds = Path_Tracer_Dialog_State()
    ds.state_from_dialog(path_tracer_dialog)
  else:
    ds = None
  mss = marker_set_states()
  s = (mss, ds)
  
  from SessionUtil import objecttree
  t = objecttree.instance_tree_to_basic_tree(s)

  file.write('\n')
  file.write('def restore_volume_path_tracer():\n')
  file.write(' path_tracer_state = \\\n')
  objecttree.write_basic_tree(t, file, indent = '  ')
  file.write('\n')
  file.write(' import VolumePath.session\n')
  file.write(' VolumePath.session.restore_path_tracer_state(path_tracer_state)\n')
  file.write('\n')
  file.write('try:\n')
  file.write('  restore_volume_path_tracer()\n')
  file.write('except:\n')
  file.write("  reportRestoreError('Error restoring volume path tracer')\n")
  file.write('\n')
Ejemplo n.º 8
0
	def saveSession(self, trigger, data, file):
		isMapped = self.uiMaster().winfo_ismapped()
		if not isMapped and not self.models:
			# Not visible and no displayed surfaces
			return
		from SessionUtil import stateclasses, objecttree
		restoring_code = \
"""
def restoreIntersurfSession(state):
	import SimpleSession
	from Intersurf import Intersurf
	SimpleSession.registerAfterModelsCB(Intersurf.restoreSession, state)
risArgs = (%s)
try:
	restoreIntersurfSession(risArgs)
except:
	reportRestoreError("Error restoring Intersurf extension")
"""
		pageName = self.notebook.getcurselection()
		chosenMolecules = self.molChooser.getcurselection()
		chosenChains = self.chainChooser.getcurselection()
                opts = self.outputOptions.getvalue()
		pruneDistance = self.pruneDistance.getvalue()
		bias = self.moleculeBias.getvalue()
		if isinstance(self.histogram["datasource"], basestring):
			histogramData = self.histogram["datasource"]
		else:
			histogramData = self.histogramData
		markerValues = []
		markers, selectedMarker = self.histogram.currentmarkerinfo()
		if markers:
			for m in markers:
				markerValues.append((m["xy"], m["rgba"]))
		ms = stateclasses.Model_State()
		modelData = []
		trackedIndex = -1
		n = 0
		for m, v in self.models.iteritems():
			if self._trackedModel is m:
				trackedIndex = n
			ms.state_from_model(m)
			bt = objecttree.instance_tree_to_basic_tree(ms)
			modelData.append((v, bt))
			n += 1
		state = (pageName, chosenMolecules, chosenChains, opts,
				pruneDistance, bias,
				histogramData, markerValues,
				modelData, trackedIndex, isMapped)
		file.write(restoring_code % repr(state))
Ejemplo n.º 9
0
def save_hide_dust_state(dust_table, file):

    s = Hide_Dust_State()
    s.state_from_dust_table(dust_table)

    from SessionUtil import objecttree
    t = objecttree.instance_tree_to_basic_tree(s)

    file.write('\n')
    file.write('def restore_hide_dust():\n')
    file.write(' hide_dust_state = \\\n')
    objecttree.write_basic_tree(t, file, indent='   ')
    file.write('\n')
    file.write(' try:\n')
    file.write('  import HideDust.session\n')
    file.write('  HideDust.session.restore_hide_dust_state(hide_dust_state)\n')
    file.write(' except:\n')
    file.write("  reportRestoreError('Error restoring hide dust')\n")
    file.write('\n')
    file.write('registerAfterModelsCB(restore_hide_dust)\n')
    file.write('\n')
def save_scale_bar_state(scale_bar_dialog, file):

    s = Scale_Bar_Dialog_State()
    s.state_from_dialog(scale_bar_dialog)

    from SessionUtil import objecttree
    t = objecttree.instance_tree_to_basic_tree(s)

    file.write('\n')
    file.write('def restore_scale_bar():\n')
    file.write(' scale_bar_state = \\\n')
    objecttree.write_basic_tree(t, file, indent='  ')
    file.write('\n')
    file.write(' import ScaleBar.session\n')
    file.write(' ScaleBar.session.restore_scale_bar_state(scale_bar_state)\n')
    file.write('\n')
    file.write('try:\n')
    file.write('  restore_scale_bar()\n')
    file.write('except:\n')
    file.write("  reportRestoreError('Error restoring scale bar')\n")
    file.write('\n')
Ejemplo n.º 11
0
def save_icosahedron_state(icosahedron_dialog, file):

  s = Icosahedron_Dialog_State()
  s.state_from_dialog(icosahedron_dialog)
  
  from SessionUtil import objecttree
  t = objecttree.instance_tree_to_basic_tree(s)

  file.write('\n')
  file.write('def restore_icosahedron():\n')
  file.write(' icosahedron_state = \\\n')
  objecttree.write_basic_tree(t, file, indent = '  ')
  file.write('\n')
  file.write(' from Icosahedron import session\n')
  file.write(' session.restore_icosahedron_state(icosahedron_state)\n')
  file.write('\n')
  file.write('try:\n')
  file.write('  restore_icosahedron()\n')
  file.write('except:\n')
  file.write("  reportRestoreError('Error restoring icosahedron')\n")
  file.write('\n')
Ejemplo n.º 12
0
def save_volume_dialog_state(volume_dialog, file):

  s = Volume_Dialog_State()
  s.state_from_dialog(volume_dialog)
  
  from SessionUtil import objecttree
  t = objecttree.instance_tree_to_basic_tree(s)

  file.write('\n')
  file.write('def restore_volume_dialog():\n')
  file.write(' volume_dialog_state = \\\n')
  objecttree.write_basic_tree(t, file, indent = '  ')
  file.write('\n')
  file.write(' from VolumeViewer import session\n')
  file.write(' session.restore_volume_dialog_state(volume_dialog_state)\n')
  file.write('\n')
  file.write('try:\n')
  file.write('  restore_volume_dialog()\n')
  file.write('except:\n')
  file.write("  reportRestoreError('Error restoring volume dialog')\n")
  file.write('\n')
Ejemplo n.º 13
0
def save_icosahedron_state(icosahedron_dialog, file):

    s = Icosahedron_Dialog_State()
    s.state_from_dialog(icosahedron_dialog)

    from SessionUtil import objecttree
    t = objecttree.instance_tree_to_basic_tree(s)

    file.write('\n')
    file.write('def restore_icosahedron():\n')
    file.write(' icosahedron_state = \\\n')
    objecttree.write_basic_tree(t, file, indent='  ')
    file.write('\n')
    file.write(' from Icosahedron import session\n')
    file.write(' session.restore_icosahedron_state(icosahedron_state)\n')
    file.write('\n')
    file.write('try:\n')
    file.write('  restore_icosahedron()\n')
    file.write('except:\n')
    file.write("  reportRestoreError('Error restoring icosahedron')\n")
    file.write('\n')
Ejemplo n.º 14
0
def save_surface_zone_state(zone_table, file):

  s = Surface_Zone_State()
  s.state_from_zone_table(zone_table)
  
  from SessionUtil import objecttree
  t = objecttree.instance_tree_to_basic_tree(s)

  file.write('\n')
  file.write('def restore_surface_zones():\n')
  file.write(' surface_zone_state = \\\n')
  objecttree.write_basic_tree(t, file, indent = '   ')
  file.write('\n')
  file.write(' try:\n')
  file.write('  import SurfaceZone.session\n')
  file.write('  SurfaceZone.session.restore_surface_zone_state(surface_zone_state)\n')
  file.write(' except:\n')
  file.write("  reportRestoreError('Error restoring surface zones')\n")
  file.write('\n')
  file.write('registerAfterModelsCB(restore_surface_zones)\n')
  file.write('\n')
Ejemplo n.º 15
0
def save_scale_bar_state(scale_bar_dialog, file):

  s = Scale_Bar_Dialog_State()
  s.state_from_dialog(scale_bar_dialog)
  
  from SessionUtil import objecttree
  t = objecttree.instance_tree_to_basic_tree(s)

  file.write('\n')
  file.write('def restore_scale_bar():\n')
  file.write(' scale_bar_state = \\\n')
  objecttree.write_basic_tree(t, file, indent = '  ')
  file.write('\n')
  file.write(' import ScaleBar.session\n')
  file.write(' ScaleBar.session.restore_scale_bar_state(scale_bar_state)\n')
  file.write('\n')
  file.write('try:\n')
  file.write('  restore_scale_bar()\n')
  file.write('except:\n')
  file.write("  reportRestoreError('Error restoring scale bar')\n")
  file.write('\n')
Ejemplo n.º 16
0
def save_hide_dust_state(dust_table, file):

  s = Hide_Dust_State()
  s.state_from_dust_table(dust_table)
  
  from SessionUtil import objecttree
  t = objecttree.instance_tree_to_basic_tree(s)

  file.write('\n')
  file.write('def restore_hide_dust():\n')
  file.write(' hide_dust_state = \\\n')
  objecttree.write_basic_tree(t, file, indent = '   ')
  file.write('\n')
  file.write(' try:\n')
  file.write('  import HideDust.session\n')
  file.write('  HideDust.session.restore_hide_dust_state(hide_dust_state)\n')
  file.write(' except:\n')
  file.write("  reportRestoreError('Error restoring hide dust')\n")
  file.write('\n')
  file.write('registerAfterModelsCB(restore_hide_dust)\n')
  file.write('\n')
Ejemplo n.º 17
0
def save_capper_state(capper_dialog, file):

  s = Capper_Dialog_State()
  s.state_from_dialog(capper_dialog)
  
  from SessionUtil import objecttree
  t = objecttree.instance_tree_to_basic_tree(s)

  file.write('\n')
  file.write('def restore_surface_capping():\n')
  file.write(' capper_state = \\\n')
  objecttree.write_basic_tree(t, file, indent = '  ')
  file.write('\n')
  file.write(' import SurfaceCap.session\n')
  file.write(' SurfaceCap.session.restore_capper_state(capper_state)\n')
  file.write('\n')
  file.write('try:\n')
  file.write('  restore_surface_capping()\n')
  file.write('except:\n')
  file.write("  reportRestoreError('Error restoring surface capping')\n")
  file.write('\n')
Ejemplo n.º 18
0
def save_multiscale_state(multiscale_dialog, file):

  s = Multiscale_Dialog_State()
  s.state_from_dialog(multiscale_dialog)
  
  from SessionUtil import objecttree
  t = objecttree.instance_tree_to_basic_tree(s)

  file.write('\n')
  file.write('def restore_multiscale():\n')
  file.write(' multiscale_state = \\\n')
  objecttree.write_basic_tree(t, file, indent = '  ')
  file.write('\n')
  file.write(' import MultiScale.session\n')
  file.write(' MultiScale.session.restore_multiscale_state(multiscale_state)\n')
  file.write('\n')
  file.write('try:\n')
  file.write('  restore_multiscale()\n')
  file.write('except:\n')
  file.write("  reportRestoreError('Error restoring multiscale')\n")
  file.write('\n')
Ejemplo n.º 19
0
def save_capper_state(capper_dialog, file):

    s = Capper_Dialog_State()
    s.state_from_dialog(capper_dialog)

    from SessionUtil import objecttree
    t = objecttree.instance_tree_to_basic_tree(s)

    file.write('\n')
    file.write('def restore_surface_capping():\n')
    file.write(' capper_state = \\\n')
    objecttree.write_basic_tree(t, file, indent='  ')
    file.write('\n')
    file.write(' import SurfaceCap.session\n')
    file.write(' SurfaceCap.session.restore_capper_state(capper_state)\n')
    file.write('\n')
    file.write('try:\n')
    file.write('  restore_surface_capping()\n')
    file.write('except:\n')
    file.write("  reportRestoreError('Error restoring surface capping')\n")
    file.write('\n')
def save_volume_dialog_state(volume_dialog, file):

    s = Volume_Dialog_State()
    s.state_from_dialog(volume_dialog)

    from SessionUtil import objecttree
    t = objecttree.instance_tree_to_basic_tree(s)

    file.write('\n')
    file.write('def restore_volume_dialog():\n')
    file.write(' volume_dialog_state = \\\n')
    objecttree.write_basic_tree(t, file, indent='  ')
    file.write('\n')
    file.write(' from VolumeViewer import session\n')
    file.write(' session.restore_volume_dialog_state(volume_dialog_state)\n')
    file.write('\n')
    file.write('try:\n')
    file.write('  restore_volume_dialog()\n')
    file.write('except:\n')
    file.write("  reportRestoreError('Error restoring volume dialog')\n")
    file.write('\n')
def save_multiscale_state(multiscale_dialog, file):

    s = Multiscale_Dialog_State()
    s.state_from_dialog(multiscale_dialog)

    from SessionUtil import objecttree
    t = objecttree.instance_tree_to_basic_tree(s)

    file.write('\n')
    file.write('def restore_multiscale():\n')
    file.write(' multiscale_state = \\\n')
    objecttree.write_basic_tree(t, file, indent='  ')
    file.write('\n')
    file.write(' import MultiScale.session\n')
    file.write(
        ' MultiScale.session.restore_multiscale_state(multiscale_state)\n')
    file.write('\n')
    file.write('try:\n')
    file.write('  restore_multiscale()\n')
    file.write('except:\n')
    file.write("  reportRestoreError('Error restoring multiscale')\n")
    file.write('\n')
Ejemplo n.º 22
0
def save_path_tracer_state(path_tracer_dialog, file):

    s = Path_Tracer_Dialog_State()
    s.state_from_dialog(path_tracer_dialog)

    from SessionUtil import objecttree

    t = objecttree.instance_tree_to_basic_tree(s)

    file.write("\n")
    file.write("def restore_volume_path_tracer():\n")
    file.write(" path_tracer_state = \\\n")
    objecttree.write_basic_tree(t, file, indent="  ")
    file.write("\n")
    file.write(" import VolumePath.session\n")
    file.write(" VolumePath.session.restore_path_tracer_state(path_tracer_state)\n")
    file.write("\n")
    file.write("try:\n")
    file.write("  restore_volume_path_tracer()\n")
    file.write("except:\n")
    file.write("  reportRestoreError('Error restoring volume path tracer')\n")
    file.write("\n")
Ejemplo n.º 23
0
def save_surface_state(file):

    slist = []
    from chimera import openModels as om
    from _surface import SurfaceModel
    for s in om.list(modelTypes=[SurfaceModel]):
        plist = [
            p for p in s.surfacePieces
            if hasattr(p, 'save_in_session') and p.save_in_session
        ]
        if plist:
            slist.append((s, plist))
    if len(slist) == 0:
        return

    smslist = []
    for s, plist in slist:
        sms = Surface_Model_State()
        sms.state_from_surface_model(s, plist)
        smslist.append(sms)

    from SessionUtil import objecttree
    t = objecttree.instance_tree_to_basic_tree(smslist)

    file.write('\n')
    file.write('def restore_surfaces():\n')
    file.write(' surface_state = \\\n')
    objecttree.write_basic_tree(t, file, indent='  ')
    file.write('\n')
    file.write(' from Surface import session\n')
    file.write(' session.restore_surface_state(surface_state)\n')
    file.write('\n')
    file.write('try:\n')
    file.write(' restore_surfaces()\n')
    file.write('except:\n')
    file.write(" reportRestoreError('Error restoring surfaces')\n")
    file.write('\n')