Esempio n. 1
0
    def on_copy_button_clicked_handler(self, *arg):
        try:
            v1 = float(self.vx_entry.get_text())
        except:
            msg().error("Wrong x-field in Vector.")
        try:
            v2 = float(self.vy_entry.get_text())
        except:
            msg().error("Wrong y-field in Vector.")
        try:
            v3 = float(self.vz_entry.get_text())
        except:
            msg().error("Wrong z-field in Vector.")
        v = Vector(v1, v2, v3)
        if self.system is not None:
            if self.system.INITIAL_STRUCTURE is not None:
                s = self.system.INITIAL_STRUCTURE
                s.setCarthesian()
                sel = Selection(self.group_entry.get_text(), s)
                l = []
                for i in sel.getAtoms():
                    if i >= 0 and i < len(s):
                        l.append((s.speciesIndex(i), s[i] + v))
                for i, v in l:
                    s.appendAtom(i, v)

                msg().status("OK")
                systemlist().notifySystemChanged()
            else:
                msg().error("No initial structure in the current system.")
        else:
            msg().error("No system selected.")
Esempio n. 2
0
    def rotate(self):
        try:
            v1 = float(eval(self.vx_entry.get_text()))
        except:
            msg().error("Invalid x-field in axis.")
        try:
            v2 = float(eval(self.vy_entry.get_text()))
        except:
            msg().error("Invalid y-field in axis.")
        try:
            v3 = float(eval(self.vz_entry.get_text()))
        except:
            msg().error("Invalid z-field in axis.")
        v = Vector(v1, v2, v3)

        try:
            o1 = float(eval(self.fromx_entry.get_text()))
        except:
            msg().error("Invalid x-field in center.")
        try:
            o2 = float(eval(self.fromy_entry.get_text()))
        except:
            msg().error("Invalid y-field in center.")
        try:
            o3 = float(eval(self.fromz_entry.get_text()))
        except:
            msg().error("Invalid z-field in center.")
        o = Vector(o1, o2, o3)

        try:
            a = float(eval(self.angle_entry.get_text()))
        except:
            msg().error("Invalid angle.")
        a *= pi / 180.0

        n = v.normal()
        if self.system is not None:
            if self.system.INITIAL_STRUCTURE is not None:
                s = self.system.INITIAL_STRUCTURE
                s.setCarthesian()
                sel = Selection(self.group_entry.get_text(), s)
                for i, nx, ny, nz in sel:
                    d = nx * s.basis[0] + ny * s.basis[1] + nz * s.basis[2]
                    if i >= 0 and i < len(s):
                        r = s[i] + d - o
                        s[i] = cos(a) * r + (
                            (n * r) *
                            (1 - cos(a))) * n + sin(a) * r.cross(n) + o - d

                msg().status("OK")
                systemlist().notifySystemChanged()
            else:
                msg().error("No initial structure in the current system.")
        else:
            msg().error("No system selected.")
Esempio n. 3
0
 def on_fromcms_button_clicked_handler(self, *arg):
     s = self.getStructure()
     sel = Selection(self.group_entry.get_text(), s)
     self.setFrom(cms(s, sel))
     self.updateV()
Esempio n. 4
0
 def getSelection(self, struct=None):
     #    print "selection:",self.selection
     s = Selection(self.selection, struct)
     return s.getAtoms()