Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simplify/unify windows tree views #87

Open
andrea-bistacchi opened this issue Aug 16, 2024 · 0 comments
Open

simplify/unify windows tree views #87

andrea-bistacchi opened this issue Aug 16, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@andrea-bistacchi
Copy link
Collaborator

andrea-bistacchi commented Aug 16, 2024

Tree views are currently duplicated for geology, fluid and background collections, in order use a hierarchy based on geological vs topological type. This is obtained by two different methods of the BaseView() abstract class: create_geology_tree and create_topology_tree, create_fluid_tree and create_fluid_tree, and create_background_tree and create_background_tree.

On the other hand all other collections use single table views, with the exception of cross-sections that use a single tree view.

This complex system with a lot of code redundancy can be simplified with the following strategy.

  1. Use tree views for all collections. Even with a simplified structure as for cross-sections, this allows activating o hiding all entities of a given collection with a single click. Hence table views must be converted to tree views.

  2. Use a single tree for geology, fluid and background. The hierarchy can be generated using the functions we already have, that could be called by a signal (e.g. when clicking on the tree header), and should be modified to point to the same tree by using the same self.GeologyTreeWidget in both the create_geology_tree and create_topology_tree methods. TopologyTreeWidget should be simply removed from the GUI in Qt Designer.

def create_geology_tree(self):
    """Create geology tree with checkboxes and properties"""
    self.GeologyTreeWidget.clear()
    self.GeologyTreeWidget.setColumnCount(3)
    self.GeologyTreeWidget.setHeaderLabels(
        ["Type > Feature > Scenario > Name", "uid", "property"]
    )
    # hide the uid column
    self.GeologyTreeWidget.hideColumn(1)
    self.GeologyTreeWidget.setItemsExpandable(True)
    geo_types = pd_unique(self.parent.geol_coll.df.query(self.view_filter)["geological_type"])
    for geo_type in geo_types:
        # self.GeologyTreeWidget as parent -> top level
        glevel_1 = QTreeWidgetItem(
            self.GeologyTreeWidget, [geo_type]
        )
def create_topology_tree(self):
    """Create topology tree with checkboxes and properties"""
    self.TopologyTreeWidget.clear()
    self.TopologyTreeWidget.setColumnCount(3)
    self.TopologyTreeWidget.setHeaderLabels(
        ["Type > Scenario > Name", "uid", "property"]
    )
    # hide the uid column
    self.TopologyTreeWidget.hideColumn(1)
    self.TopologyTreeWidget.setItemsExpandable(True)
    topo_types = pd_unique(self.parent.geol_coll.df.query(self.view_filter)["topological_type"])

    for topo_type in topo_types:
        # self.GeologyTreeWidget as parent -> top level
        tlevel_1 = QTreeWidgetItem(
            self.TopologyTreeWidget, [topo_type]
        )
  1. The state of tick boxes and property combo boxes in e.g. self.GeologyTreeWidget and self.TopologyTreeWidget is currently synchronized between the duplicated trees and with the self.actors_df (listing all actors by uid and whether they are shown or hidden, and if a particular property is shown) with a complex system of signals in methods: update_geology_checkboxes, update_topology_checkboxes, and toggle_geology_topology_visibility. By using a single tree all these could be probably removed. The state of each actor is in any case recorded in self.actors_df and this can be used to populate tick boxes and property combo boxes when switching from geology to topology ordering.

Note that this approach could be useful to add also other different hierarchies, if needed, and to add hierarchy in other collections that at the moment do not have this option.

Ideas? Opinions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants