Beispiel #1
0
    def create_edges_table(cls, sceneNode):
        datastructure = sceneNode.datastructure
        table = cls(sceneNode=sceneNode, table_type='edges')
        table.add_column('key')
        attributes = list(datastructure.default_edge_attributes.keys())
        attributes = table.sort_attributes(attributes)

        for attr in attributes:
            editable = attr[0] != '_'
            checkbox = type(
                datastructure.default_edge_attributes[attr]) == bool
            if not editable:
                attr = attr[1:]
            table.add_column(attr, Editable=editable, checkbox=checkbox)

        treecollection = forms.TreeGridItemCollection()
        for key, edge in enumerate(datastructure.edges()):
            values = [str(edge)]
            for attr in attributes:
                values.append(datastructure.edge_attribute(edge, attr))
            edge_item = forms.TreeGridItem(Values=tuple(values))
            treecollection.Add(edge_item)
            for key in edge:
                vertex_item = forms.TreeGridItem(Values=(str(key), ))
                edge_item.Children.Add(vertex_item)
        table.DataStore = treecollection
        table.Activated += table.SelectEvent(sceneNode, 'guid_edge',
                                             'guid_vertex')
        table.ColumnHeaderClick += table.HeaderClickEvent()
        table.CellEdited += table.EditEvent()
        return table
Beispiel #2
0
    def create_force_table(cls, sceneNode):
        datastructure = sceneNode.diagram
        table = cls(sceneNode=sceneNode, table_type='edges')
        table.add_column('key')

        attributes = list(datastructure.default_edge_attributes.keys())
        attributes = table.sort_attributes(attributes)

        print(attributes)

        for attr in attributes:
            checkbox = type(
                datastructure.default_edge_attributes[attr]) == bool
            print(attr)
            attr = attr.replace("_", "-")
            table.add_column(attr, Editable=False, checkbox=checkbox)

        treecollection = forms.TreeGridItemCollection()
        for key, edge in enumerate(datastructure.edges()):
            values = [str(edge)]
            for attr in attributes:
                values.append(datastructure.edge_attribute(edge, attr))
            edge_item = forms.TreeGridItem(Values=tuple(values))
            treecollection.Add(edge_item)
            # for key in edge:
            #     vertex_item = forms.TreeGridItem(Values=(str(key),))
            #     edge_item.Children.Add(vertex_item)

        table.DataStore = treecollection
        table.Activated += table.SelectEvent(sceneNode, 'guid_edge')
        table.ColumnHeaderClick += table.HeaderClickEvent()
        table.CellEdited += table.EditEvent()
        return table
Beispiel #3
0
    def create_vertices_table(cls, sceneNode, keys):
        datastructure = sceneNode.datastructure
        table = cls(sceneNode=sceneNode, table_type='vertices')
        table.add_column('Name')
        table.add_column('Value', Editable=True)
        attributes = list(datastructure.default_vertex_attributes.keys())
        attributes = table.sort_attributes(attributes)

        treecollection = forms.TreeGridItemCollection()
        key = keys[0]
        for attr in attributes:
            if attr[0] != '_' and attr != 'constraints':
                if datastructure.attributes['name'] == 'form' and attr == 'z':
                    pass
                else:
                    values = [
                        str(attr),
                        datastructure.vertex_attribute(key, attr)
                    ]
                    vertex_item = forms.TreeGridItem(Values=tuple(values))
                    treecollection.Add(vertex_item)

        table.DataStore = treecollection
        table.Activated += table.SelectEvent(sceneNode, keys)
        table.ColumnHeaderClick += table.HeaderClickEvent()
        table.CellEdited += table.EditEvent(sceneNode, keys)
        return table
Beispiel #4
0
    def sort(self, key):
        headerTexts = [column.HeaderText for column in self.Columns]
        index = headerTexts.index(key)
        print(key, index)

        def getValue(item):
            try:
                value = ast.literal_eval(item.Values[index])
            except (ValueError, TypeError):
                value = item.Values[index]
            return value

        items = sorted(self.DataStore, key=getValue, reverse=True)
        if self.last_sorted_to == key:
            items.reverse()
            self.last_sorted_to = None
        else:
            self.last_sorted_to = key

        self.DataStore = forms.TreeGridItemCollection(items)
Beispiel #5
0
    def create_faces_table(cls, sceneNode, faces):
        datastructure = sceneNode.datastructure
        table = cls(sceneNode=sceneNode, table_type='faces')
        table.add_column('Name')
        table.add_column('Value', Editable=True)
        attributes = list(datastructure.default_face_attributes.keys())
        attributes = table.sort_attributes(attributes)

        treecollection = forms.TreeGridItemCollection()
        face = faces[0]
        for attr in attributes:
            # if attr[0] != '_':  ## want to dispaly the attr '_is_loaded'
            values = [str(attr), datastructure.face_attribute(face, attr)]
            face_item = forms.TreeGridItem(Values=tuple(values))
            treecollection.Add(face_item)

        table.DataStore = treecollection
        table.Activated += table.SelectEvent(sceneNode, faces)
        table.ColumnHeaderClick += table.HeaderClickEvent()
        table.CellEdited += table.EditEvent(sceneNode, faces)
        return table
Beispiel #6
0
    def create_edges_table(cls, sceneNode, edges):
        datastructure = sceneNode.datastructure
        table = cls(sceneNode=sceneNode, table_type='edges')
        table.add_column('Name')
        table.add_column('Value', Editable=True)
        attributes = list(datastructure.default_edge_attributes.keys())
        attributes = table.sort_attributes(attributes)

        treecollection = forms.TreeGridItemCollection()
        edge = edges[0]
        for attr in attributes:
            if attr[0] != '_':
                values = [str(attr), datastructure.edge_attribute(edge, attr)]
                edge_item = forms.TreeGridItem(Values=tuple(values))
                treecollection.Add(edge_item)

        table.DataStore = treecollection
        table.Activated += table.SelectEvent(sceneNode, edges)
        table.ColumnHeaderClick += table.HeaderClickEvent()
        table.CellEdited += table.EditEvent(sceneNode, edges)
        return table
Beispiel #7
0
    def create_force_table(cls, sceneNode, dual=[]):
        datastructure = sceneNode.diagram
        table = cls(sceneNode=sceneNode, table_type='edges')
        table.add_column('EdgeLabel')
        table.add_column('Vertices')

        attributes = list(datastructure.default_edge_attributes.keys())
        attributes = table.sort_attributes(attributes)

        Allowed = ["is_ind", "f", "is_external"]
        attributes = filter(lambda attr: attr in Allowed, attributes)

        for attr in attributes:
            checkbox = type(
                datastructure.default_edge_attributes[attr]) == bool
            attr = attr.replace("_", "-")
            table.add_column(attr, Editable=False, checkbox=checkbox)

        treecollection = forms.TreeGridItemCollection()
        for index, edge in enumerate(datastructure.edges()):
            values = [index, str(edge)]

            for attr in attributes:
                value = datastructure.edge_attribute(edge, attr)
                if isinstance(value, float):
                    value = float("%.4g" % (value))
                values.append(value)

            edge_item = forms.TreeGridItem(Values=tuple(values))
            treecollection.Add(edge_item)
            # for key in edge:
            #     vertex_item = forms.TreeGridItem(Values=(str(key),))
            #     edge_item.Children.Add(vertex_item)

        table.DataStore = treecollection
        table.Activated += table.SelectEvent(sceneNode, 'guid_edge', dual=dual)
        table.ColumnHeaderClick += table.HeaderClickEvent()
        table.CellEdited += table.EditEvent()
        return table