def update_settings(self, new_phil=None):
    try:
      if not new_phil:
        #self.params = self.viewer.params
        new_phil = self.master_phil.format(python_object = self.params)
      #import code, traceback; code.interact(local=locals(), banner="".join( traceback.format_stack(limit=10) ) )
      self.currentphil, diff_phil = self.GetNewCurrentPhilFromPython(new_phil, self.currentphil)
      #diff = None
      self.params = self.currentphil.extract()
      phl = self.params

      if len(diff_phil.all_definitions()) < 1 and not phl.mouse_moved:
        self.mprint( "Nothing's changed", verbose=1)
        return False

      #diff = diff_phil.extract()
      self.mprint("diff phil:\n" + diff_phil.as_str(), verbose=1 )

      #self.params = self.currentphil.extract()
      #phl = self.params

      if view_3d.has_phil_path(diff_phil, "use_provided_miller_arrays"):
        phl = self.ResetPhilandViewer(self.currentphil)
        if not self.load_miller_arrays():
          return False
        self.viewer.lastscene_id = phl.viewer.scene_id

      if view_3d.has_phil_path(diff_phil, "openfilename"):
        phl = self.ResetPhilandViewer(self.currentphil)
        if not self.load_reflections_file(phl.openfilename):
          return False
        self.viewer.lastscene_id = phl.viewer.scene_id

      if view_3d.has_phil_path(diff_phil, "scene_id", "merge_data", "show_missing", \
         "show_only_missing", "show_systematic_absences", "nbins", "binner_idx",\
         "scene_bin_thresholds"):
        if self.set_scene(phl.viewer.scene_id):
          self.update_space_group_choices()
          self.set_scene_bin_thresholds(strbinvals=phl.scene_bin_thresholds,
                                         binner_idx=phl.binner_idx,
                                         nbins=phl.nbins )
      if phl.spacegroup_choice == None:
        self.mprint("! spacegroup_choice == None")
        #time.sleep(15)

      if view_3d.has_phil_path(diff_phil, "spacegroup_choice"):
        self.set_spacegroup_choice(phl.spacegroup_choice)

      if view_3d.has_phil_path(diff_phil, "tabulate_miller_array_ids"):
        self.tabulate_arrays(phl.tabulate_miller_array_ids)
        #return True

      if view_3d.has_phil_path(diff_phil, "miller_array_operations"):
        self.make_new_miller_array()

      if view_3d.has_phil_path(diff_phil, "using_space_subgroup") and phl.using_space_subgroup==False:
        self.set_default_spacegroup()

      if view_3d.has_phil_path(diff_phil, "shape_primitive"):
        self.set_shape_primitive(phl.shape_primitive)

      if view_3d.has_phil_path(diff_phil, "add_user_vector_hkl_op",
                                         "add_user_vector_abc",
                                         "add_user_vector_hkl"):
        self.add_user_vector()

      if view_3d.has_phil_path(diff_phil, "save_image_name"):
        self.SaveImageName(phl.save_image_name)
        phl.save_image_name = None

      if view_3d.has_phil_path(diff_phil, "action"):
        ret = self.set_action(phl.action)
        phl.action = "is_running" # ensure the same action in succession can be executed
        if not ret:
          return False

      if view_3d.has_phil_path(diff_phil, "savefilename"):
        self.SaveReflectionsFile(phl.savefilename)
      phl.savefilename = None # ensure the same action in succession can be executed

      if view_3d.has_phil_path(diff_phil, "viewer"):
        self.viewer.settings = phl.viewer
        self.settings = phl.viewer

      self.params = self.viewer.update_settings(diff_phil, phl)
      if view_3d.has_phil_path(diff_phil, "scene_id", "spacegroup_choice"):
        self.list_vectors()
      # parameters might have been changed. So update self.currentphil accordingly
      self.currentphil = self.master_phil.format(python_object = self.params)
      self.NewFileLoaded = False
      phl.mouse_moved = False
      self.SendCurrentPhilValues()
      if (self.viewer.miller_array is None) :
        self.mprint( NOREFLDATA, True)
        return False
      return True
    except Exception as e:
      self.mprint(to_str(e) + "\n" + traceback.format_exc(), 0)
      return False
Esempio n. 2
0
    def update_settings(self, new_phil=None):
        try:
            if not new_phil:
                new_phil = self.master_phil.format(python_object=self.params)
            #import code, traceback; code.interact(local=locals(), banner="".join( traceback.format_stack(limit=10) ) )
            self.currentphil, diff_phil = self.GetNewCurrentPhilFromPython(
                new_phil, self.currentphil)
            diff = None
            if len(diff_phil.all_definitions()) < 1:
                self.mprint("Nothing's changed")
                return False

            diff = diff_phil.extract().NGL_HKLviewer
            self.mprint("diff phil:\n" + diff_phil.as_str(), verbose=1)

            self.params = self.currentphil.extract()
            phl = self.params.NGL_HKLviewer

            if view_3d.has_phil_path(diff_phil, "filename"):
                self.ResetPhilandViewer(diff_phil)
                if not self.load_reflections_file(phl.filename):
                    return False

            if view_3d.has_phil_path(diff_phil, "scene_id") \
             or view_3d.has_phil_path(diff_phil, "merge_data") \
             or view_3d.has_phil_path(diff_phil, "nbins") \
             or view_3d.has_phil_path(diff_phil, "bin_scene_label") \
             or view_3d.has_phil_path(diff_phil, "scene_bin_thresholds"):
                #import code; code.interact(local=locals(), banner="".join( traceback.format_stack(limit=10) ) )
                if self.set_scene(phl.scene_id):
                    self.set_scene_bin_thresholds(
                        binvals=phl.scene_bin_thresholds,
                        bin_scene_label=phl.bin_scene_label,
                        nbins=phl.nbins)

            if view_3d.has_phil_path(diff_phil, "spacegroup_choice"):
                self.set_spacegroup_choice(phl.spacegroup_choice)

            if view_3d.has_phil_path(diff_phil, "using_space_subgroup"
                                     ) and phl.using_space_subgroup == False:
                self.set_default_spacegroup()

            if view_3d.has_phil_path(diff_phil, "camera_type"):
                self.set_camera_type(phl.camera_type)

            if view_3d.has_phil_path(diff_phil, "shape_primitive"):
                self.set_shape_primitive(phl.shape_primitive)

            if view_3d.has_phil_path(diff_phil, "tooltips_in_script"):
                self.viewer.script_has_tooltips = phl.tooltips_in_script

            if view_3d.has_phil_path(diff_phil, "viewer"):
                self.viewer.settings = phl.viewer
                self.settings = phl.viewer

            msg = self.viewer.update_settings(diff_phil, phl)
            self.mprint(msg, verbose=1)
            #import code, traceback; code.interact(local=locals(), banner="".join( traceback.format_stack(limit=10) ) )
            self.NewFileLoaded = False

            if (self.viewer.miller_array is None):
                self.mprint(NOREFLDATA, True)
                return False
            return True
        except Exception as e:
            self.mprint(to_str(e) + "\n" + traceback.format_exc(), 0)
            return False
Esempio n. 3
0
  def update_settings(self, new_phil=None):
    try:
      if not new_phil:
        #self.params.NGL_HKLviewer = self.viewer.params
        new_phil = self.master_phil.format(python_object = self.params)
      #import code, traceback; code.interact(local=locals(), banner="".join( traceback.format_stack(limit=10) ) )
      self.currentphil, diff_phil = self.GetNewCurrentPhilFromPython(new_phil, self.currentphil)
      #diff = None
      self.params = self.currentphil.extract()
      phl = self.params.NGL_HKLviewer

      if len(diff_phil.all_definitions()) < 1 and not phl.mouse_moved:
        self.mprint( "Nothing's changed")
        return False

      #diff = diff_phil.extract().NGL_HKLviewer
      self.mprint("diff phil:\n" + diff_phil.as_str(), verbose=1 )

      #self.params = self.currentphil.extract()
      #phl = self.params.NGL_HKLviewer

      if view_3d.has_phil_path(diff_phil, "filename"):
        self.ResetPhilandViewer(diff_phil)
        if not self.load_reflections_file(phl.filename):
          return False

      if view_3d.has_phil_path(diff_phil, "scene_id") \
       or view_3d.has_phil_path(diff_phil, "merge_data") \
       or view_3d.has_phil_path(diff_phil, "show_missing") \
       or view_3d.has_phil_path(diff_phil, "show_only_missing") \
       or view_3d.has_phil_path(diff_phil, "show_systematic_absences") \
       or view_3d.has_phil_path(diff_phil, "nbins") \
       or view_3d.has_phil_path(diff_phil, "bin_scene_label") \
       or view_3d.has_phil_path(diff_phil, "scene_bin_thresholds"):
        #import code; code.interact(local=locals(), banner="".join( traceback.format_stack(limit=10) ) )
        if self.set_scene(phl.viewer.scene_id):
          self.set_scene_bin_thresholds(binvals=phl.scene_bin_thresholds,
                                         bin_scene_label=phl.bin_scene_label,
                                         nbins=phl.nbins )

      if view_3d.has_phil_path(diff_phil, "spacegroup_choice"):
        self.set_spacegroup_choice(phl.spacegroup_choice)

      if view_3d.has_phil_path(diff_phil, "tabulate_miller_array_ids"):
        self.tabulate_miller_array(phl.tabulate_miller_array_ids)
        return True

      if view_3d.has_phil_path(diff_phil, "miller_array_operations"):
        self.make_new_miller_array()

      if view_3d.has_phil_path(diff_phil, "angle_around_vector") \
       or view_3d.has_phil_path(diff_phil, "bequiet"):
        self.rotate_around_vector(phl.clip_plane.angle_around_vector)

      if view_3d.has_phil_path(diff_phil, "using_space_subgroup") and phl.using_space_subgroup==False:
        self.set_default_spacegroup()

      if view_3d.has_phil_path(diff_phil, "shape_primitive"):
        self.set_shape_primitive(phl.shape_primitive)

      if view_3d.has_phil_path(diff_phil, "action"):
        ret = self.set_action(phl.action)
        if not ret:
          return False

      if view_3d.has_phil_path(diff_phil, "tooltips_in_script"):
        self.viewer.script_has_tooltips = phl.tooltips_in_script

      if view_3d.has_phil_path(diff_phil, "viewer"):
        self.viewer.settings = phl.viewer
        self.settings = phl.viewer

      msg, self.params.NGL_HKLviewer = self.viewer.update_settings(diff_phil, phl)
      # parameters might have been changed. So update self.currentphil accordingly
      self.currentphil = self.master_phil.format(python_object = self.params)
      self.mprint( msg, verbose=1)
      #import code, traceback; code.interact(local=locals(), banner="".join( traceback.format_stack(limit=10) ) )
      self.NewFileLoaded = False
      phl.mouse_moved = False
      if (self.viewer.miller_array is None) :
        self.mprint( NOREFLDATA, True)
        return False
      return True
    except Exception as e:
      self.mprint(to_str(e) + "\n" + traceback.format_exc(), 0)
      return False