Example #1
0
    def do(self, cutoff):
        cache = context.application.cache
        parent = cache.common_root

        def iter_translation_nodes(nodes):
            for node in nodes:
                if isinstance(node, GLTransformationMixin) and \
                   isinstance(node.transformation, Translation) and \
                   self.allow_node(node):
                    yield node
                if isinstance(node, ContainerMixin):
                    for subnode in iter_translation_nodes(node.children):
                        yield subnode

        nodes = []
        coordinates = []
        for node in iter_translation_nodes(cache.nodes_without_children):
            nodes.append(node)
            coordinates.append(node.get_frame_up_to(parent).t)
        coordinates = numpy.array(coordinates)

        unit_cell = None
        if isinstance(parent, context.application.plugins.get_node("Universe")):
            unit_cell = parent.cell

        vector_counter = 1
        for i0, i1, delta, distance in PairSearchIntra(coordinates, cutoff, unit_cell):
            vector = self.get_vector(nodes[i0], nodes[i1], distance)
            if vector is not None:
                vector.name += " %i" % vector_counter
                vector_counter += 1
                primitive.Add(vector, common_parent([nodes[i0], nodes[i1]]))
Example #2
0
    def do(self, cutoff):
        cache = context.application.cache
        parent = cache.common_root

        def iter_translation_nodes(nodes):
            for node in nodes:
                if isinstance(node, GLTransformationMixin) and \
                   isinstance(node.transformation, Translation) and \
                   self.allow_node(node):
                    yield node
                if isinstance(node, ContainerMixin):
                    for subnode in iter_translation_nodes(node.children):
                        yield subnode

        nodes = []
        coordinates = []
        for node in iter_translation_nodes(cache.nodes_without_children):
            nodes.append(node)
            coordinates.append(node.get_frame_up_to(parent).t)
        coordinates = numpy.array(coordinates)

        unit_cell = None
        if isinstance(parent,
                      context.application.plugins.get_node("Universe")):
            unit_cell = parent.cell

        vector_counter = 1
        for i0, i1, delta, distance in PairSearchIntra(coordinates, cutoff,
                                                       unit_cell):
            vector = self.get_vector(nodes[i0], nodes[i1], distance)
            if vector is not None:
                vector.name += " %i" % vector_counter
                vector_counter += 1
                primitive.Add(vector, common_parent([nodes[i0], nodes[i1]]))
Example #3
0
    def connect(self, gl_object1, gl_object2):
        try:
            new = context.application.plugins.get_node(
                self.vector_store.get_value(self.cb_vector.get_active_iter(), 0)
            )(targets=[gl_object1, gl_object2])
        except TargetError:
            return

        if(self.vector_store.get_value(self.cb_vector.get_active_iter(), 0)=="Bond"):
            new.set_bond_type(self.bondtype_store.get_value(self.cb_bondtype.get_active_iter(),1))

        primitive.Add(new, common_parent([gl_object1.parent, gl_object2.parent]))
Example #4
0
    def connect(self, gl_object1, gl_object2):
        try:
            new = context.application.plugins.get_node(
                self.vector_store.get_value(
                    self.cb_vector.get_active_iter(),
                    0))(targets=[gl_object1, gl_object2])
        except TargetError:
            return

        if (self.vector_store.get_value(self.cb_vector.get_active_iter(),
                                        0) == "Bond"):
            new.set_bond_type(
                self.bondtype_store.get_value(
                    self.cb_bondtype.get_active_iter(), 1))

        primitive.Add(new,
                      common_parent([gl_object1.parent, gl_object2.parent]))
Example #5
0
 def connect_springs(self):
     model, iter = self.tree_selection.get_selected()
     Spring = context.application.plugins.get_node("Spring")
     if self.cb_inverse.get_active() and len(model.get_value(iter,
                                                             3)[3]) > 0:
         springs = [
             Spring(targets=[node1(), node2()])
             for node1, node2 in model.get_value(iter, 3)[3]
         ]
     else:
         springs = [
             Spring(targets=[node1(), node2()])
             for node1, node2 in model.get_value(iter, 3)[2]
         ]
     parent = common_parent([self.frame1, self.frame2])
     for spring in springs:
         primitive.Add(spring, parent)
     return springs
Example #6
0
 def connect_springs(self):
     model, iter = self.tree_selection.get_selected()
     Spring = context.application.plugins.get_node("Spring")
     if self.cb_inverse.get_active() and len(model.get_value(iter, 3)[3]) > 0:
         springs = [
             Spring(targets=[node1(), node2()])
             for node1, node2
             in model.get_value(iter, 3)[3]
         ]
     else:
         springs = [
             Spring(targets=[node1(), node2()])
             for node1, node2
             in model.get_value(iter, 3)[2]
         ]
     parent = common_parent([self.frame1, self.frame2])
     for spring in springs:
         primitive.Add(spring, parent)
     return springs
Example #7
0
 def get_frame_relative_to(self, other):
     common = common_parent([self, other])
     return other.get_frame_up_to(common).inv * self.get_frame_up_to(common)
Example #8
0
 def get_common_root(self):
     return analysis.common_parent(self.nodes)
Example #9
0
 def get_common_parent(self):
     return analysis.common_parent(self.parents)
Example #10
0
 def get_common_root(self):
     return analysis.common_parent(self.nodes)
Example #11
0
 def get_common_parent(self):
     return analysis.common_parent(self.parents)
Example #12
0
 def get_frame_relative_to(self, other):
     common = common_parent([self, other])
     return other.get_frame_up_to(common).inv * self.get_frame_up_to(common)
Example #13
0
 def get_frame_relative_to(self, other):
     common = common_parent([self, other])
     temp = self.get_frame_up_to(common)
     temp.apply_inverse_after(other.get_frame_up_to(common))
     return temp