コード例 #1
0
 def __set_parm_bind(self, _=None) -> None:
     """Set parameters binding."""
     link_expr_list: List[str] = []
     for row, gs in enumerate(list_texts(self.grounded_list)):
         try:
             link_expr = []
             # Links from grounded list
             for name in gs.replace('(', '').replace(')', '').split(", "):
                 num = int(name.replace('P', ''))
                 if num in self.configure_canvas.same:
                     name = f'P{self.configure_canvas.same[num]}'
                 link_expr.append(name)
         except KeyError:
             continue
         else:
             # Customize joints
             for joint, link in self.configure_canvas.cus.items():
                 if row == link:
                     link_expr.append(f"P{joint}")
             link_expr_str = ','.join(sorted(set(link_expr)))
             if row == self.grounded_list.currentRow():
                 link_expr_list.insert(0, link_expr_str)
             else:
                 link_expr_list.append(link_expr_str)
     self.expr_show.setText(self.get_expression(graph2vpoints(
         self.configure_canvas.graph,
         self.configure_canvas.pos,
         self.configure_canvas.cus,
         self.configure_canvas.same,
         self.grounded_list.currentRow()
     )))
コード例 #2
0
    def get_configure(self) -> Dict[str, Any]:
        """Return collection data.

        + Expression
        + input
        + Graph
        + Placement
        + Target
        + cus
        + same
        """
        for vpoint in self.vpoint_list:
            if vpoint.type in {VJoint.P, VJoint.RP}:
                raise ValueError("not support for prismatic joint yet")

        graph, grounded_list, input_list, pos, cus, same = self.get_graph()

        links: List[Set[int]] = [set() for _ in range(len(graph.nodes))]
        for joint, link in edges_view(graph):
            for node in link:
                links[node].add(joint)

        placement = set(grounded_list)
        for row, link in enumerate(links):
            if placement == link - set(same):
                grounded = row
                break
        else:
            raise ValueError("no grounded link")

        vpoint_exprs = [
            vpoint.expr()
            for vpoint in graph2vpoints(graph, pos, cus, same, grounded)
        ]

        return {
            'Expression': "M[" + ", ".join(vpoint_exprs) + "]",
            'input': input_list,
            'Graph': graph.edges,
            'Placement': {p: None
                          for p in grounded_list},
            'Target': {p: None
                       for p in cus},
            'cus': cus,
            'same': same,
        }