def get_bond_lenght(self, bond): rA = CachedCml.getMolecule(bond.atomA.elementType).property["Radius"] rB = CachedCml.getMolecule(bond.atomB.elementType).property["Radius"] bond_lenght = (rA + rB) * SPRITE_RADIUS * SCALE_FACTOR if bond.bonds != 0: bond_lenght *= BOND_LENGTH_FACTOR return bond_lenght
def create_info_frame(self, formula): cml = CachedCml.getMolecule(formula) info_text = pyglet.text.decode_html("<b>%s</b><br> %s" % ( cml.property.get("Name", "Undefined"), cml.property.get("Description", "No Description Available") )) info_doc = Document(info_text, height=self.height, width=self.width/2, is_fixed_size = True) info_frame = Frame(info_doc) return info_frame
def addState(self, stateless): default_order = ["Aqueous","Gas", "Liquid", "Solid"] statefull = list() for s in stateless: m = CachedCml.getMolecule(s) for k in default_order: if k in m.states: state = m.states[k].short break statefull.append(s+"(%s)"%state) return statefull
def addState(self, stateless): default_order = ["Aqueous", "Gas", "Liquid", "Solid"] statefull = list() for s in stateless: m = CachedCml.getMolecule(s) for k in default_order: if k in m.states: state = m.states[k].short break statefull.append(s + "(%s)" % state) return statefull
def create_info_frame(self, formula): cml = CachedCml.getMolecule(formula) info_text = pyglet.text.decode_html( "<b>%s</b><br> %s" % (cml.property.get("Name", "Undefined"), cml.property.get("Description", "No Description Available"))) info_doc = Document(info_text, height=self.height, width=self.width / 2, is_fixed_size=True) info_frame = Frame(info_doc) return info_frame
def __init__(self, symbol, charge, space, batch, molecule, pos): img = pyglet_util.load_image("atom-" + symbol.lower() + ".png") group = RenderingOrder.elements pyglet.sprite.Sprite.__init__(self, img, batch=batch, group=group, subpixel=True) self.cml = CachedCml.getMolecule(symbol) self.scale = self.cml.property["Radius"] * SCALE_FACTOR self.create_electric_charge_sprite(charge, batch) self.molecule = molecule self.symbol = symbol self.charge = charge self.space = space self.active = False self.init_chipmunk() self.move(pos)
def __init__(self, formula_with_state, space, batch, pos=None, render_only=False): self.space = space self.batch = batch self.creation_time = time.time() formula, state = Reaction.split_state(formula_with_state) self.formula = formula self.cml = CachedCml.getMolecule(formula) self.cml.normalize_pos() self.current_state = self.cml.get_state(state) if self.current_state is None and render_only: self.current_state = Cml.State("Gas") elif self.current_state is None: raise Exception("Did not find state for:" + formula_with_state + " existing states are:" + str(self.cml.states.keys())) if pos is None: pos = (random.randint(10, 600), random.randint(200, 500)) self.pos = pos self.create_atoms()
def getMolecule(self,formula): return CachedCml.getMolecule(formula)
def getMolecule(self, formula): return CachedCml.getMolecule(formula)