예제 #1
0
    def __init__(self, images=None, rotations='', show_bonds=False, expr=None):

        if not isinstance(images, Images):
            images = Images(images)

        self.images = images
        self.observers = []

        self.config = read_defaults()
        if show_bonds:
            self.config['show_bonds'] = True

        menu = self.get_menu_data()

        self.window = ui.ASEGUIWindow(close=self.exit,
                                      menu=menu,
                                      config=self.config,
                                      scroll=self.scroll,
                                      scroll_event=self.scroll_event,
                                      press=self.press,
                                      move=self.move,
                                      release=self.release,
                                      resize=self.resize)

        View.__init__(self, rotations)
        Status.__init__(self)

        self.subprocesses = []  # list of external processes
        self.movie_window = None
        self.vulnerable_windows = []
        self.simulation = {}  # Used by modules on Calculate menu.
        self.module_state = {}  # Used by modules to store their state.

        self.arrowkey_mode = self.ARROWKEY_SCAN
        self.move_atoms_mask = None

        self.set_frame(len(self.images) - 1, focus=True)

        # Used to move the structure with the mouse
        self.prev_pos = None
        self.last_scroll_time = time()
        self.orig_scale = self.scale

        if len(self.images) > 1:
            self.movie()

        if expr is None:
            expr = self.config['gui_graphs_string']

        if expr is not None and expr != '' and len(self.images) > 1:
            self.plot_graphs(expr=expr, ignore_if_nan=True)
예제 #2
0
    def __init__(self,
                 images=None,
                 rotations='',
                 show_unit_cell=True,
                 show_bonds=False):

        # Try to change into directory of file you are viewing
        try:
            os.chdir(os.path.split(sys.argv[1])[0])
        # This will fail sometimes (e.g. for starting a new session)
        except:
            pass

        if not images:
            images = Images()
            images.initialize([Atoms()])

        self.images = images

        self.config = read_defaults()

        menu = self.get_menu_data(show_unit_cell, show_bonds)

        self.window = ui.ASEGUIWindow(close=self.exit,
                                      menu=menu,
                                      config=self.config,
                                      scroll=self.scroll,
                                      scroll_event=self.scroll_event,
                                      press=self.press,
                                      move=self.move,
                                      release=self.release,
                                      resize=self.resize)

        View.__init__(self, rotations)
        Status.__init__(self)

        self.graphs = []  # list of matplotlib processes
        self.graph_wref = []  # list of weakrefs to Graph objects
        self.movie_window = None
        self.vulnerable_windows = []
        self.simulation = {}  # Used by modules on Calculate menu.
        self.module_state = {}  # Used by modules to store their state.
        self.arrowkey_mode = self.ARROWKEY_SCAN
        self.move_atoms_mask = None
예제 #3
0
파일: view.py 프로젝트: m-deimel/kmcos
    def __init__(self,
                 queue,
                 signal_queue,
                 vbox,
                 window,
                 rotations='',
                 show_unit_cell=True,
                 show_bonds=False):

        threading.Thread.__init__(self)
        self.image_queue = queue
        self.signal_queue = signal_queue
        self.configured = False
        self.ui = FakeUI.__init__(self)
        self.images = Images()
        self.aseGui = GUI()
        #self.aseGui.images.initialize([ase.atoms.Atoms()])
        self.images.initialize([ase.atoms.Atoms()])
        self.killed = False
        self.paused = False

        self.vbox = vbox
        self.window = window

        self.vbox.connect('scroll-event', self.scroll_event)
        self.window.connect('key-press-event', self.on_key_press)
        rotations = '0.0x,0.0y,0.0z'  #[3,3,3]#np.zeros(3)
        self.config = {
            'force_vector_scale': None,
            'velocity_vector_scale': None,
            'swap_mouse': False
        }
        View.__init__(self, rotations)
        Status.__init__(self)
        self.vbox.show()

        if os.name == 'posix':
            self.live_plot = True
        else:
            self.live_plot = False

        #self.drawing_area.realize()
        self.scaleA = 3.0
        self.center = np.array([8, 8, 8])
        #self.set_colors()
        #self.set_coordinates(0)
        self.center = np.array([0, 0, 0])

        self.tofs = get_tof_names()

        # history tracking arrays
        self.times = []
        self.tof_hist = []
        self.occupation_hist = []

        # prepare diagrams
        self.data_plot = plt.figure()
        #plt.xlabel('$t$ in s')
        self.tof_diagram = self.data_plot.add_subplot(211)
        self.tof_diagram.set_yscale('log')
        #self.tof_diagram.get_yaxis().get_major_formatter().set_powerlimits(
        #(3, 3))
        self.tof_plots = []
        for tof in self.tofs:
            self.tof_plots.append(self.tof_diagram.plot([], [], label=tof)[0])

        self.tof_diagram.legend(loc='lower left')
        self.tof_diagram.set_ylabel(
            'TOF in $\mathrm{s}^{-1}\mathrm{site}^{-1}$')
        self.occupation_plots = []
        self.occupation_diagram = self.data_plot.add_subplot(212)
        for species in sorted(settings.representations):
            self.occupation_plots.append(
                self.occupation_diagram.plot([], [], label=species)[0], )
        self.occupation_diagram.legend(loc=2)
        self.occupation_diagram.set_xlabel('$t$ in s')
        self.occupation_diagram.set_ylabel('Coverage')