Пример #1
0
class VRMLChargeFile(VRMLWireframeFile):

    color_scale = VRML.SymmetricColorScale(1.)

    def writeAtom(self, atom, configuration):
        p = atom.position(configuration)
        c = atom.charge()
        c = max(min(c, 1.), -1.)
        if p is None:
            self.warning = 1
        else:
            s = VRML.Sphere(p, 0.1*Units.Ang,
                            material = VRML.Material(diffuse_color =
                                                     self.color_scale(c)))
            s.writeToFile(self)

    bond_material = VRML.DiffuseMaterial('black')

    def writeBond(self, bond, configuration, distance):
        p1 = bond.a1.position(configuration)
        p2 = bond.a2.position(configuration)
        if p1 is not None and p2 is not None:
            bond_vector = 0.5*distance(bond.a1, bond.a2, configuration)
            cut = bond_vector != 0.5*(p2-p1)
            if not cut:
                c = VRML.Line(p1, p2, material = self.bond_material)
                c.writeToFile(self)
            else:
                c = VRML.Line(p1, p1+bond_vector, material = self.bond_material)
                c.writeToFile(self)
                c = VRML.Line(p2, p2-bond_vector, material = self.bond_material)
                c.writeToFile(self)
Пример #2
0
 def writeAtom(self, atom, configuration):
     p = atom.position(configuration)
     if p is None:
         self.warning = 1
     else:
         color = self.atomColor(atom)
         s = VRML.Sphere(p, 0.1*Units.Ang,
                         material = VRML.DiffuseMaterial(color),
                         reuse = 1)
         s.writeToFile(self)
Пример #3
0
 def writeAtom(self, atom, configuration):
     try:
         highlight = atom.highlight
     except AttributeError:
         highlight = 0
     if highlight:
         p = atom.position(configuration)
         if p is None:
             self.warning = 1
         else:
             s = VRML.Sphere(p, 0.1*Units.Ang,
                             material = VRML.DiffuseMaterial(atom.color),
                             reuse = 1)
             s.writeToFile(self)